Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:3641397194 wq Gpt6 Astra Pack Rendering

From Leeroopedia
Knowledge Sources
Domains Prompt_Engineering, Template_Processing, Configuration_Management
Last Updated 2026-10-26 12:00 GMT

Overview

A template substitution mechanism that generates seat-specific prompt packs by injecting constants, routing skills, and workflow definitions into per-seat Markdown templates.

Description

Pack Rendering is the process of producing the final "破甲" (armor-breaking) prompt text for a specific AI model client seat. Each seat has a base template (`.md` file) containing placeholder tokens like `Template:APP TITLE`, `Template:ACTIVATION WORD`, `Template:ROUTER`, etc. The rendering engine replaces each token with its resolved value, then wraps the result in seat-specific begin/end markers.

The key challenge is compositional assembly. A rendered pack is not just the seat template — it includes:

  • The router (assembled from `ROUTER.md` + `NORMALIZER.md` + 6 route parent files + leaf index + 80 leaf skill files)
  • The activation reply (shared activation page payload)
  • The unified work order (cross-seat work specification)
  • The IDA MCP block (per-seat IDA MCP usage documentation)
  • The per-seat workflow (三拍 / three-beat pattern)

All of these are concatenated and template-substituted into the final pack string, which is wrapped in `` markers for idempotent injection.

Usage

Use this principle when you need to generate the full prompt pack text for installation into a specific AI model client's config directory. It is called during the write-plan preview phase of the install flow and again during verification to compare expected vs. actual file content.

Theoretical Basis

The rendering pipeline applies staged template substitution:

  1. Template loading: read the seat-specific `.md` template and the per-seat workflow file.
  2. Token replacement: replace each `Template:TOKEN` with its resolved value using string `replaceAll`.
  3. Component assembly: the `Template:ROUTER` token expands to a concatenation of 5 layers (head, normalizer, parent routes, leaf index, leaf skills).
  4. Marker wrapping: wrap the final text in seat-specific HTML comment markers for idempotent marked-region injection.

Pseudo-code Logic:

# Abstract algorithm (NOT real implementation)
def render_pack(seat_id):
    template = read(f"packs/{seat_id}.md")
    workflow = read(f"packs/workflows/{seat_id}.md") or ""
    router = assemble_router()  # head + normalizer + parents + index + leaves
    text = template
    text = text.replace("{{APP_TITLE}}", APP_TITLE)
    text = text.replace("{{ACTIVATION_WORD}}", ACTIVATION_WORD)
    text = text.replace("{{ROUTER}}", router)
    text = text.replace("{{ACTIVATION_REPLY}}", activation_reply())
    # ... remaining tokens ...
    return wrap_markers(seat_id, text)

def assemble_router():
    head = read("routes/ROUTER.md")
    normalizer = read("routes/NORMALIZER.md")
    parents = [read(f"routes/{id}.md") for id in ROUTE_IDS]
    index = read("routes/leaves/INDEX.md")
    leaves = [read(f"routes/leaves/{id}.md") for id in leaf_ids()]
    return join([head, normalizer, parents, index, leaves])

The marker wrapping ensures idempotent injection: if a pack is re-installed, the marked region is replaced rather than duplicated, because the transaction layer detects existing begin/end markers and replaces the content between them.

Practical Guide

  • The `PACK_IDS` array defines the 11 supported seats; any other seat id throws `missing pack`.
  • The `packsDir()` function resolves the packs directory at dev time (`__dirname/packs`) or at packaged time (`process.resourcesPath/packs`).
  • Template substitution is order-independent since `replaceAll` handles all occurrences of each token.
  • The rendered pack is cached implicitly by the caller — `renderPack` reads files fresh each call.

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment