Luigit
repositories / pi-ext

pi-ext

bugabingas pi extensions

owned by admin

extensions/prompt-autopsy/README.md

Raw
Rendered preview

prompt-autopsy

System-prompt autopsy command for Pi.

Install / load

Loaded through the root pi-ext package. See the root README.

Commands / tools / settings

  • Command: /prompt-autopsy
  • Shortcut: Ctrl+Alt+A
  • Hooks: session_start, session_shutdown, before_agent_start, agent_start
  • Tools: none
  • Settings: none

Bench

Run mise run bench here, or mise //extensions/prompt-autopsy:bench from the repository root, to benchmark system prompt grouping.

Behavior

Writes the current generated system prompt to a private temporary file. Opens it with $VISUAL, else $EDITOR, else vi.

before_agent_start captures Pi's rendered system prompt. agent_start replaces it with the final prompt after every before_agent_start edit.

Grouping reads Pi 0.86 top-level XML sections from the final prompt:

  • [TOOLS] for <tools>
  • [RULES] for Pi's native <rules>
  • [GENERAL GUIDELINES] for PFUI's <general_guidelines>
  • [TOOL GUIDELINES] for PFUI's <tool_guidelines>
  • [DOCS] for <docs>
  • [APPEND] for <addendum>
  • [CTX] for <project_context>
  • [SKILLS] for <skills>
  • [CWD] for <cwd>
  • [SECTION name] for custom sections
  • [PREAMBLE] for text before the first section
  • [CORE] for later unsectioned text

Nested XML remains inside its owning top-level section. If no turn has started since session start or reload, the command warns and writes nothing rather than showing Pi's pre-hook base prompt as provider-effective context.

Debug

Opt in through debug configuration. Safe events: session.start, session.shutdown, prompt.open.start, prompt.open.finish, prompt.open.error.

# prompt-autopsy

System-prompt autopsy command for Pi.

## Install / load

Loaded through the root pi-ext package.
See the [root README](../../README.md).

## Commands / tools / settings

- Command: `/prompt-autopsy`
- Shortcut: `Ctrl+Alt+A`
- Hooks: `session_start`, `session_shutdown`, `before_agent_start`,
  `agent_start`
- Tools: none
- Settings: none

## Bench

Run `mise run bench` here, or `mise //extensions/prompt-autopsy:bench` from the repository root, to benchmark system prompt grouping.

## Behavior

Writes the current generated system prompt to a private temporary file.
Opens it with `$VISUAL`, else `$EDITOR`, else `vi`.

`before_agent_start` captures Pi's rendered system prompt.
`agent_start` replaces it with the final prompt after every `before_agent_start` edit.

Grouping reads Pi 0.86 top-level XML sections from the final prompt:

- `[TOOLS]` for `<tools>`
- `[RULES]` for Pi's native `<rules>`
- `[GENERAL GUIDELINES]` for PFUI's `<general_guidelines>`
- `[TOOL GUIDELINES]` for PFUI's `<tool_guidelines>`
- `[DOCS]` for `<docs>`
- `[APPEND]` for `<addendum>`
- `[CTX]` for `<project_context>`
- `[SKILLS]` for `<skills>`
- `[CWD]` for `<cwd>`
- `[SECTION name]` for custom sections
- `[PREAMBLE]` for text before the first section
- `[CORE]` for later unsectioned text

Nested XML remains inside its owning top-level section.
If no turn has started since session start or reload, the command warns and writes nothing rather than showing Pi's pre-hook base prompt as provider-effective context.

## Debug

Opt in through [debug configuration](../DEBUG.md).
Safe events: `session.start`, `session.shutdown`, `prompt.open.start`, `prompt.open.finish`, `prompt.open.error`.