Principle:3641397194 wq Gpt6 Astra Pack Rendering
| 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:
- Template loading: read the seat-specific `.md` template and the per-seat workflow file.
- Token replacement: replace each `Template:TOKEN` with its resolved value using string `replaceAll`.
- Component assembly: the `Template:ROUTER` token expands to a concatenation of 5 layers (head, normalizer, parent routes, leaf index, leaf skills).
- 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.