repositories / pi-ext

pi-ext

bugabingas pi extensions

owned by bugabinga

remove: retire demo and release assets

c1a1aa4e316e5bd5067319a04653c275ede5ed2e

Oliver Jan Krylow <oliver@bugabinga.net> ·

SSH signature · not checked

Browse filesCompare with HEAD

Changed files (28)

.pi/prompts/drive-demo.md

Deleted
deleted file mode 100644
1 ----
2 -description: Create or refine an interactive Pi demo driver and GIF recording workflow
3 -argument-hint: "<extension-or-demo-name>"
4 ----
6 -# Create or refine an interactive Pi demo driver and GIF recording workflow
8 -Create/refine demo driver for `$ARGUMENTS`.
10 -Goal:
11 -animated GIF only.
12 -No screenshot.
13 -Use asciinema + expect + agg.
15 -Rules:
17 -- Manual workflow only; never run from check/release gates.
18 -- Driver files live in `drivers/*.mjs`; readable, small, commentable.
19 -- Driver names are focused extension names.
20 - No `*_suite` drivers.
21 -- `scripts/demo.mjs` is engine; drivers contain data/steps only.
22 -- `mise run demo -- ...` is the public interface; it delegates to `node
23 - scripts/demo.mjs ...`.
24 -- Batch/all/changed/list actions live under `mise run demo --` args.
25 -- README missing → fail.
26 - Do not create README silently.
27 -- Assets land in each target extension:
28 - `extensions/<target>/assets/<demo>.gif`.
29 -- `targets` are README/asset owners, usually exactly one primary extension.
30 -- `extensions` may include support extensions when needed for visible UX.
31 -- README demo block is generated after the H1 title:
32 - `<!-- demo:<readme_id-or-name>:start -->` … `<!-- demo:<readme_id-or-name>:end
33 - -->`.
34 -- Side-by-side before/after demos use the same user prompt; only loaded
35 - extensions/support state may differ.
36 -- Side-by-side demos use shared `readme_id` + identical `readme_items =
37 - [(caption, gif), ...]` across paired drivers.
38 -- Existing generated demo blocks and `## Demo\n\nNone.` placeholders are
39 - removed.
40 -- No screenshots.
41 - GIF is source of truth for visual QA.
43 -Recording defaults:
45 -- cols:
46 - 100
47 -- rows:
48 - 28
49 -- theme:
50 - Pi default; do not force `--theme dark`.
51 -- cwd:
52 - choose demo-friendly extension/project dir.
53 -- Pi isolation flags:
54 - `--no-session --no-context-files --no-skills --no-prompt-templates
55 - --no-extensions`
56 -- Load exact extensions with `-e ./extensions/<name>`.
57 -- For footer demos, load footer + client extensions together, but target only
58 - `footer`.
59 -- For footer-client demos, load `footer` as support only when it improves
60 - visibility; target the client.
61 -- Terminal-only extensions need no demo unless they have a stable visible
62 - non-terminal UI.
63 -- Real LLM/quota calls OK for manual demos.
65 -Pexpect driving:
67 -- Spawn real interactive `pi` in PTY with fixed dimensions.
68 -- Actively pump child output to stdout; sleeping alone records empty casts.
69 -- Type commands/prompts char-by-char with deliberate delay so GIF shows typing.
70 -- Pause before Enter.
71 -- Use longer holds for human readability.
72 -- With `--capture-input`, `expect(...)` can match typed prompt text; do not
73 - expect strings that appear in the prompt.
74 -- Modifiers/key overlays:
75 - skip unless Pi visibly reacts; asciinema has no native modifier overlay here.
77 -Good pacing baseline:
79 -- startup settle:
80 - 5s
81 -- command typing delay:
82 - ~55–75ms/char
83 -- prompt typing delay:
84 - ~35–55ms/char
85 -- post `/quota`:
86 - 6–7s
87 -- post `/footer` hide:
88 - 4s
89 -- post `/footer` show:
90 - 5–6s
91 -- LLM prompt wait:
92 - 14–18s or until clear final output if reliable
93 -- final hold:
94 - 5–6s
96 -Asciinema:
98 -- record with `--headless --overwrite --capture-input --window-size 100x28 -i
99 - 4.0`
100 -- output `.demo/<name>.cast`
102 -Agg:
104 -- render GIF from cast:
105 - `agg --cols 100 --rows 28 --theme asciinema --text-font-family "JetBrains
106 - Mono" --font-size 14 --line-height 1.25 --idle-time-limit 4.0
107 - --last-frame-duration 5 --fps-cap 24 <cast> <gif>`
109 -QA:
111 -- Inspect GIF manually as source of visual truth.
112 -- Use `.txt` only for semantic sanity:
113 - `asciinema convert -f txt <cast> <txt> --overwrite`
114 -- `.txt` may show duplicate lines/artifacts from terminal control sequences;
115 - acceptable if GIF looks good.
116 -- Extract representative PNG frames for assistant-side visual checks:
117 - `convert '<gif>[80]' /tmp/<demo>-80.png` or `magick '<gif>[80]'
118 - /tmp/<demo>-80.png`.
119 -- Prefer final/mid frames over first frame; first frame is often blank startup.
120 -- `understand_image` on animated GIFs is unreliable; it may hallucinate
121 - unrelated terminal content.
122 -- If using vision, run it on extracted PNG frames, not GIFs.
123 -- Avoid `asciinema play` in main terminal; it can disturb visible scrollback due
124 - recorded control sequences.
126 -Driver shape:
128 -```py
129 -title = "Footer"
130 -extensions = ["footer", "context-size", "cost", "vcs-status", "runtime", "quota"]
131 -targets = ["footer"]
132 -cols = 100
133 -rows = 28
134 -cwd = "."
135 -steps = [
136 - ("wait", 1500),
137 - ("command", "/quota", 0),
138 - ("expect", r"quota|usage|provider", 15000, 2000),
139 - ("prompt", "Count from one to ten, then finish with: footer clients updated.", 0),
140 - ("expect", r"footer clients updated", 30000, 3000),
141 - ("command", "/footer", 4000),
142 - ("command", "/footer", 5000),
143 - ("wait", 6000),
145 -```
147 -Supported step ops should stay tiny:
149 -- `wait(ms)`
150 -- `type(text[, delay_ms])`
151 -- `send(text[, after_ms])`
152 -- `command(text[, after_ms])` — type text slowly, pause, Enter, wait
153 -- `prompt(text[, after_ms])` — type prompt slowly, pause, Enter, wait
154 -- `expect(regex, timeout_ms[, hold_ms])` — semantic readiness check; use after
155 - `command(..., 0)`/`prompt(..., 0)` when needed
156 -- `ready([timeout_ms])` — broad prompt readiness check
157 -- `ctrl(key)`
158 -- `quit()`
160 -Batch/all demos:
162 -- Use `mise run demo -- changed` for demo drivers needing refresh.
163 -- It selects drivers whose driver file, target extension, or loaded extension
164 - changed since latest release tag.
165 -- It skips unchanged demos and prints `OK demo <name> skipped (unchanged since
166 - <tag>)`.
167 -- Use `mise run demo -- all` only when explicitly refreshing everything.
168 -- Use `mise run demo -- <driver>` for one focused demo.
169 -- Use `mise run demo -- <driver> --out /tmp/<driver>.gif --no-install` for
170 - disposable smoke renders.
171 -- Do not force rerender unchanged demos just to satisfy release/readme checks.
172 -- If no release tag exists, current behavior applies:
173 - treat all relevant demos as changed.
175 -When asked to create a driver:
177 -1. Pick focused primary extension/story:
178 - what user sees, why ext matters.
179 -2. Pick exact support extensions; keep `targets` to README/asset owner(s),
180 - usually one.
181 -3. Do not create suite demos that target multiple unrelated extensions.
182 -4. Add/read driver in `drivers/`.
183 -5. Run smoke once:
184 - `mise run demo -- <demo> --out /tmp/<demo>.gif --no-install`.
185 -6. Ask user to inspect GIF before committing assets/README changes.
187 -When asked to refresh demos:
189 -1. For one driver, run `mise run demo -- <name>`.
190 -2. For all changed drivers, run `mise run demo -- changed`.
191 -3. Inspect changed GIFs, not txt, before claiming ready.

.pi/prompts/release.md

Modified
10 10 Goal:
11 11 verify release, do not publish.
12 -Tie check/readme/demo/dry-run together.
12 +Tie check/readme/dry-run together.
14 14 Rules:
16 16 - Do not commit, tag, push, or publish unless user explicitly says OK after
17 17 report.
18 18 - Prefer jj if `jj root` succeeds; otherwise git.
19 -- Stop on unrelated dirty changes, failing checks, missing README/demo assets,
19 +- Stop on unrelated dirty changes, failing checks, missing READMEs,
20 20 or ambiguous release scope.
21 -- Use changed-since-release behavior already in `scripts/extensions.mjs` / `mise
22 - run demo -- changed`; do not rerun unchanged readmes/demos manually unless
23 - user asks.
24 -- Demos are manual visual QA.
25 - Never make them required by `mise run build`.
21 +- Use existing changed-since-release behavior; do not regenerate unchanged READMEs unless the user asks.
27 23 Workflow:
32 28 - read `mise.toml` and `scripts/extensions.mjs` if release flow looks stale
33 29 2. Scope:
34 30 - Determine target extension(s) from `$ARGUMENTS`; empty/all means all.
35 - - Determine changed extensions/drivers since latest release tag.
31 + - Determine changed extensions since latest release tag.
36 32 3. Check:
37 33 - `mise run build -- <extension>` for one extension.
38 34 - `mise run ci` for all/multi-extension release.
39 35 4. README:
40 36 - `mise run readme`
41 37 - Verify generated README diffs only touch intended files.
42 -5. Demo:
43 - - List drivers:
44 - `mise run demo -- list`.
45 - - Single/known driver:
46 - `mise run demo -- <driver>`.
47 - - Batch changed-since-release path:
48 - `mise run demo -- changed`.
49 - - Force all only if asked:
50 - `mise run demo -- all`.
51 - - Smoke render:
52 - `mise run demo -- <driver> --out /tmp/<driver>.gif --no-install`.
53 - - If assets changed, inspect GIFs as source of truth; text output is sanity
54 - only.
55 -6. Dry run:
38 +5. Dry run:
56 39 - `mise run publish -- --dry-run --no-push`
57 - - Verify version, changed demos, README/changelog text, selected extensions.
58 -7. Report:
40 + - Verify version, README/changelog text, selected extensions.
41 +6. Report:
59 42 - READY | NOT READY
60 43 - scope
61 44 - checks run
62 45 - readmes updated/skipped
63 - - demos updated/skipped + GIFs inspected/not inspected
64 46 - dry-run outcome
65 47 - exact publish command to run after OK

README.md

Modified
92 92 | `session-rename` | Automatic short session names for Pi. | [README](extensions/session-rename/README.md) |
93 93 | `the-system` | Project governance through one `/system` command. | [README](extensions/the-system/README.md) |
94 94 | `os-notifier` | Native-first OS notifications for interactive Pi completion. | [README](extensions/os-notifier/README.md) |
95 -| `terse` | Terse response protocol injector for Pi. | [README](extensions/terse/README.md) |
96 95 | `tldr` | Live TLDR widget above Pi editor. | [README](extensions/tldr/README.md) |
97 96 | `tps` | Tokens-per-second footer segment for Pi. | [README](extensions/tps/README.md) |
98 97 | `tune` | Autonomous experiment loops for tuning code with benchmarks. | [README](extensions/tune/README.md) |

docs/super/specs/2026-06-27-ultra-workflow-engine-design.md

Modified
337 337 - **Command path — the deterministic, must-pass anchor.** `send-keys "/ultra ultra-review"` (the bundled example — drops no file into the user's `.pi/workflows/`), poll until the board renders, `Tab` to focus an agent, assert the drill-in transcript streams, optionally `s`+text to steer and assert the run shows `steered`, `Esc` to abort, assert clean teardown. Deterministic human invocation, so it is the gate's pass/fail signal.
338 338 - **Tool path — best-effort, structural only.** A strong forcing prompt that asks the model to run a trivial **2-agent** ephemeral fan-out via the `workflow` tool; assert structurally that a board rendered and a JSON result returned. Whether MiniMax-M3 _chooses_ to call the tool is outside our control, so a miss here does **not** fail the gate (logged, not asserted).
340 -**Scope and cost.** Temp cases are trivial 2-agent fan-outs (never 16), keeping one run cheap. Assertions are structural (board present, agent rows present, JSON result present, exit code), never exact text. A final `capture-pane` dump is saved as a human-reviewable artifact (the `scripts/demo.py` pattern).
340 +**Scope and cost.** Temp cases are trivial 2-agent fan-outs (never 16), keeping one run cheap. Assertions are structural (board present, agent rows present, JSON result present, exit code), never exact text. A final `capture-pane` dump is saved as a human-reviewable artifact.
342 342 **Gating and who runs it.** Skips cleanly with a clear message when `tmux` is absent or `MINIMAX_API_KEY` is unset (the `leaks/real` skip pattern). The enabling dependency is the `index.ts` wiring (plan Task 9): nothing is reachable in a live Pi until the `workflow` tool and `/ultra` command register, so the live run is the **acceptance gate run immediately after Task 9** and **re-run at release**, and is available on demand at any later strategic checkpoint (e.g. after a runner/engine/ui change). `MINIMAX_API_KEY` is present in the current dev environment, so the agent can execute this gate directly once wiring lands — it is not solely a human-run step.

docs/super/specs/2026-06-27-ultra-workflow-engine-plan.md

Modified
114 114 - Launch inside a detached tmux session **from the repo root** (so the `pi.extensions` glob loads `ultra`): `pi --model "$ULTRA_E2E_MODEL" --session-dir <tmpdir> --no-session` (`--model` accepts `provider/id[:thinking]`; `$ULTRA_E2E_MODEL` defaults to `minimax/MiniMax-M3`, overridable).
115 115 - **Scenario A — command path, the deterministic must-pass anchor**: `send-keys "/ultra ultra-review"` (the **bundled** example — no file dropped into the user's `.pi/workflows/`), poll until the board renders, `Tab` to focus, assert the drill-in transcript streams, optionally `s`+text to steer **a multi-step / tool-driven sub-agent** (a single-turn analysis agent won't be redirected — the steer needs a step boundary to land on; validated: P4) and assert `steered`, `Esc` to abort, assert clean teardown. For the abort assertion, fire abort **≥10× before natural completion** and use a **wall-time-vs-baseline + tool-never-fired** discriminator (both model-agnostic). Caveat on the timing window: the prototype's _highspeed_ model finished in ~300 ms–1 s and ignored long-output instructions, which makes an abort fired _near_ natural completion false-positive; M3 (the Task 10 default) may run longer and honor long-output hints — making abort easier to test cleanly, not a trap. So **measure the M3 baseline at runtime** and size the "before natural completion" window from that, rather than assuming the highspeed timing (validated: P1). This scenario is the gate's pass/fail signal.
116 116 - **Scenario B — tool path, best-effort/structural**: a strong forcing prompt asking the model to run a trivial **2-agent** ephemeral fan-out via the `workflow` tool; assert structurally that a board rendered and a JSON result returned. A model that declines to call the tool **does not fail the gate** (logged, not asserted).
117 - - **Cost + teardown**: temp cases are trivial 2-agent fan-outs (never 16); a `finally`/`trap` runs `tmux kill-session` and removes the tmpdir even on failure; the final `capture-pane` dump is saved as a human-reviewable artifact (the `scripts/demo.py` pattern).
117 + - **Cost + teardown**: temp cases are trivial 2-agent fan-outs (never 16); a `finally`/`trap` runs `tmux kill-session` and removes the tmpdir even on failure; the final `capture-pane` dump is saved as a human-reviewable artifact.
118 118 - **Test/Done**: with `tmux` present and `MINIMAX_API_KEY` set, Scenario A passes end-to-end against `minimax/MiniMax-M3`; with either missing, the script **skips cleanly** with a clear message (the `leaks/real` pattern) and is absent from `mise run ci`; no orphaned tmux sessions or temp dirs after a run (assert in teardown). `MINIMAX_API_KEY` is present in the dev environment, so the agent can execute this gate directly once Task 9 lands.
120 120 ## Task 11 — Companion skill (`authoring-workflows`) + discovery wiring

docs/super/specs/2026-07-12-mise-task-architecture-design.md

Modified
38 38 - `bench`: aggregate extension benchmarks sequentially.
39 39 - `check`: run static extension, static type checking, and packaging checks.
40 40 - `ci`: run `check`, `lint`, `test`, `e2e`.
41 -- Existing repository-wide extension listing, changelog, README, demo, release, publish, clean, and Git-hook tasks remain at root.
41 +- Existing repository-wide extension listing, changelog, README, release, publish, clean, and Git-hook tasks remain at root.
43 43 The following extension-specific root tasks are removed:

drivers/ctx.mjs

Deleted
deleted file mode 100644
1 -export const title = "ctx read compaction";
2 -export const extensions = ["ctx"];
3 -export const targets = ["ctx"];
4 -export const cols = 100;
5 -export const rows = 28;
6 -export const cwd = "extensions/ctx";
7 -export const steps = [
8 - ["wait", 5000],
9 - [
10 - "prompt",
11 - "Use the read tool on ./bun.lock. Then explain in one short sentence what ctx did to the oversized output.",
12 - 18000,
13 - ],
14 - [
15 - "prompt",
16 - "Now use read with offset 120 and limit 8 on ./bun.lock to recover a small hidden slice.",
17 - 14000,
18 - ],
19 - ["wait", 6000],
20 -];

drivers/footer.mjs

Deleted
deleted file mode 100644
1 -export const title = "Footer";
2 -export const extensions = [
3 - "footer",
4 - "context-size",
5 - "cost",
6 - "vcs-status",
7 - "runtime",
8 - "quota",
9 - "tps",
10 - "model-info",
11 -];
12 -export const targets = ["footer"];
13 -export const cols = 100;
14 -export const rows = 28;
15 -export const cwd = ".";
16 -export const steps = [
17 - ["wait", 5000],
18 - ["command", "/quota", 0],
19 - ["expect", "quota|usage|provider", 15000, 2000],
20 - [
21 - "prompt",
22 - "Count from one to ten, then finish with: footer clients updated.",
23 - 0,
24 - ],
25 - ["expect", "footer clients updated", 30000, 3000],
26 - ["command", "/footer", 4000],
27 - ["command", "/footer", 5000],
28 - ["wait", 6000],
29 -];

drivers/forget.mjs

Deleted
deleted file mode 100644
1 -export const title = "Forget active context";
2 -export const extensions = ["forget"];
3 -export const targets = ["forget"];
4 -export const cols = 100;
5 -export const rows = 28;
6 -export const cwd = "extensions/forget";
7 -export const steps = [
8 - ["wait", 5000],
9 - [
10 - "prompt",
11 - "Remember OLD_DEMO_SECRET. Then call forget inspect and explain which entry could be kept to drop older context.",
12 - 18000,
13 - ],
14 - ["wait", 6000],
15 -];

drivers/prune.mjs

Deleted
deleted file mode 100644
1 -export const title = "Prune recall";
2 -export const extensions = ["prune"];
3 -export const targets = ["prune"];
4 -export const cols = 100;
5 -export const rows = 28;
6 -export const cwd = "extensions/prune";
7 -export const steps = [
8 - ["wait", 5000],
9 - [
10 - "prompt",
11 - "Remember this phrase for the demo: lossless compaction keeps recall searchable.",
12 - 12000,
13 - ],
14 - ["command", "/prune-recall compaction all", 5000],
15 - ["command", "/prune demo focus", 8000],
16 - ["wait", 6000],
17 -];

drivers/terse_after.mjs

Deleted
deleted file mode 100644
1 -export const title = "After terse";
2 -export const readme_id = "terse";
3 -export const readme_items = [
4 - ["Same prompt", "terse_before.gif"],
5 - ["Same prompt + terse", "terse_after.gif"],
6 -];
7 -export const extensions = ["terse"];
8 -export const targets = ["terse"];
9 -export const cols = 100;
10 -export const rows = 28;
11 -export const cwd = ".";
12 -const prompt = `Use only these facts; do not inspect files or run tools.
13 -Facts: pi-ext contains tools, footers, workflow helpers, prompts, skills, and themes.
14 -Explain what each part contributes.
15 -Explain how a new Pi user should think about it according to the active response style.
16 -End with marker: same terse demo prompt.`;
17 -export const steps = [
18 - ["wait", 1500],
19 - ["prompt", prompt, 30000],
20 - ["wait", 6000],
21 -];

drivers/terse_before.mjs

Deleted
deleted file mode 100644
1 -export const title = "Before terse";
2 -export const readme_id = "terse";
3 -export const readme_items = [
4 - ["Same prompt", "terse_before.gif"],
5 - ["Same prompt + terse", "terse_after.gif"],
6 -];
7 -export const extensions = [];
8 -export const targets = ["terse"];
9 -export const cols = 100;
10 -export const rows = 28;
11 -export const cwd = ".";
12 -const prompt = `Use only these facts; do not inspect files or run tools.
13 -Facts: pi-ext contains tools, footers, workflow helpers, prompts, skills, and themes.
14 -Explain what each part contributes.
15 -Explain how a new Pi user should think about it according to the active response style.
16 -End with marker: same terse demo prompt.`;
17 -export const steps = [
18 - ["wait", 1500],
19 - ["prompt", prompt, 30000],
20 - ["wait", 6000],
21 -];

drivers/tldr.mjs

Deleted
deleted file mode 100644
1 -export const title = "TLDR live summary";
2 -export const extensions = ["tldr"];
3 -export const targets = ["tldr"];
4 -export const cols = 100;
5 -export const rows = 28;
6 -export const cwd = ".";
7 -export const steps = [
8 - ["wait", 1500],
9 - ["command", "/tldr status", 0],
10 - ["expect", "tldr on|model: current", 10000, 1500],
11 - ["prompt", "Answer exactly: TLDR demo checkpoint complete.", 0],
12 - ["expect", "TLDR demo checkpoint complete", 30000, 4000],
13 - ["prompt", "Answer exactly: TLDR widget live summary ready.", 0],
14 - ["expect", "TLDR widget live summary ready", 30000, 5000],
15 - ["wait", 6000],
16 -];

drivers/tps.mjs

Deleted
deleted file mode 100644
1 -export const title = "Tokens per second";
2 -export const extensions = ["footer", "tps"];
3 -export const targets = ["tps"];
4 -export const cols = 100;
5 -export const rows = 28;
6 -export const cwd = ".";
7 -export const steps = [
8 - ["wait", 5000],
9 - [
10 - "prompt",
11 - "Count from one to twelve, one item per line, then finish with: tokens streamed.",
12 - 18000,
13 - ],
14 - ["wait", 4000],
15 - [
16 - "prompt",
17 - "Reply with exactly eight short words about streaming token speed.",
18 - 14000,
19 - ],
20 - ["wait", 6000],
21 -];

extensions/footer/README.md

Modified
57 57 Hidden mode swaps in a zero-height footer stub.
58 58 Shutdown clears segments and footer context.
60 -## Demo
62 -<!-- demo:footer:start -->
64 -![Footer](assets/footer.gif)
66 -<!-- demo:footer:end -->

extensions/footer/assets/footer.gif

Deleted
deleted file mode 100644

Previous version contains binary or non-UTF-8 data.

extensions/terse/CHANGELOG.md

Deleted
deleted file mode 100644
1 -# Changelog
3 -## 0.0.3
5 -- Add side-by-side terse demo
6 -- Replace suite demos
7 -- Switch workspace tests from bun to vitest
8 -- Isolate extension harness environment
10 -## 0.0.2
12 -- Cut version-only release; no diff from v0.0.1.
13 -- Keep before_agent_start prompt injection unchanged.
14 -- Keep README, harness test, benchmark, package metadata unchanged.
16 -## 0.1.0 - 2026-05-21
18 -- a40a427 prepare extensions for npm release
19 -- 133cb7d chore(pi):
20 - migrate extensions to earendil packages
21 -- 5ca1296 Rework Pi agent extensions

extensions/terse/README.md

Deleted
deleted file mode 100644
1 -# terse
3 -Terse response protocol injector for Pi.
5 -## Demo
7 -<!-- demo:terse:start -->
9 -| **Same prompt** | **Same prompt + terse** |
10 -| --------------------------------------- | ---------------------------------------------- |
11 -| ![Same prompt](assets/terse_before.gif) | ![Same prompt + terse](assets/terse_after.gif) |
13 -<!-- demo:terse:end -->
15 -## Install / load
17 -Loaded through the root pi-ext package.
18 -See [root README](../../README.md).
20 -## Commands / tools / settings
22 -- Commands: none.
23 -- Tools: none.
24 -- Settings: none.
25 -- Hooks: `before_agent_start`.
27 -## Bench
29 -Run `mise run bench` here, or `mise //extensions/terse:bench` from the repository root, to benchmark terse prompt injection.
31 -## Behavior
33 -On `before_agent_start`, rewrites the agent system prompt with
34 -`injectTerseBlock`.
36 -- injects `## Response Protocol — terse`
37 -- skips injection when prompt already contains the full terse block
38 -- inserts before Pi SDK `Current date:` footer when present
39 -- appends to prompt when footer is absent
40 -- requires output only: no preamble, recap, hedging, filler, or style labels
41 -- defaults to one sentence and ≤20 words, max two short lines, hard max ≤35 unless the user asks for detail, and ≤15 for simple answers
42 -- treats explain-only prompts as prose-only: cause → effect → fix, no code block
43 -- tells the model to delete nonessential words/sentences and merge outputs longer than two sentences
44 -- marks >35 words, unsolicited code blocks, style labels, and filler openers as failures
45 -- preserves the current user message language while compressing phrasing
46 -- includes one terse example
47 -- pushes terse phrasing: fragments, abbreviations, causality arrows
48 -- keeps code, tool args, file contents, and quoted errors exact
49 -- prefers clarity over compression for security, user confusion, and destructive
50 - ops

extensions/terse/__bench__/bench.ts

Deleted
deleted file mode 100644
1 -import { cpus } from "node:os";
2 -import { injectTerseBlock, TERSE_BLOCK } from "../index.ts";
4 -const prompt = `You are a coding agent. Use tools.
6 -## Available tools
7 -- read: Read files
8 -- bash: Execute shell commands
9 -- edit: Precise replacement
10 -- write: Write files
12 -## Guidelines
13 -${"- Use concise output.\n".repeat(120)}
15 -# Response style
16 -- Abbreviate: DB/auth/config/req/res/fn/impl
17 -- Strip conjunctions, articles
18 -- Arrows: X → Y → Z
19 -- Fragments OK
20 -- No filler, hedging, pleasantries
22 -# Project Context
24 -${"Use exact edits. Prefer rg/fd.\n".repeat(160)}
25 -Current date: 2026-05-04
26 -Current working directory: /repo`;
28 -function oldBuildTerseSystemPrompt(p: string): string {
29 - return `${p}\n\n${TERSE_BLOCK}`;
30 -}
32 -const mode = process.argv[2] === "old" ? "old" : "new";
33 -const threads = cpus().length;
34 -let sink = 0;
36 -function consume(s: string): void {
37 - sink ^=
38 - s.length ^
39 - s.charCodeAt(0) ^
40 - s.charCodeAt(s.length >> 1) ^
41 - s.charCodeAt(s.length - 1);
42 -}
44 -function bench(
45 - name: string,
46 - fn: () => string,
47 - n = 1_000_000,
48 - rounds = 12,
49 -): void {
50 - for (let i = 0; i < 3_000; i++) consume(fn());
51 - for (let r = 0; r < rounds; r++) {
52 - const start = performance.now();
53 - for (let i = 0; i < n; i++) consume(fn());
54 - const ns = ((performance.now() - start) * 1_000_000) / n;
55 - console.log(`Benchmark${name}-${threads}\t${n}\t${ns.toFixed(0)} ns/op`);
56 - }
57 -}
59 -bench(
60 - "TersePrompt",
61 - mode === "old"
62 - ? () => oldBuildTerseSystemPrompt(prompt)
63 - : () => injectTerseBlock(prompt),
64 -);
65 -if (sink === 42) console.log("sink", sink);

extensions/terse/__tests__/harness.test.ts

Deleted
deleted file mode 100644
1 -import { afterEach, describe, expect, it } from "vitest";
2 -import { createTestSession, type TestSession } from "../../../test/harness";
3 -import terseExtension, { injectTerseBlock, TERSE_BLOCK } from "../index";
5 -describe("terse pi-test-harness", () => {
6 - let t: TestSession | undefined;
8 - afterEach(() => {
9 - t?.dispose();
10 - t = undefined;
11 - });
13 - it("loads in real Pi extension runtime", async () => {
14 - t = await createTestSession({ extensionFactories: [terseExtension] });
16 - expect(t.session.extensionRunner.extensions).toHaveLength(1);
17 - });
19 - it("injects before Pi footer", () => {
20 - const prompt =
21 - "base\nCurrent date: 2026-06-16\nCurrent working directory: /repo";
23 - expect(injectTerseBlock(prompt)).toBe(
24 - `base\n\n${TERSE_BLOCK}\nCurrent date: 2026-06-16\nCurrent working directory: /repo`,
25 - );
26 - });
28 - it("appends when Pi footer is absent", () => {
29 - expect(injectTerseBlock("base")).toBe(`base\n\n${TERSE_BLOCK}`);
30 - });
32 - it("defines no-announcement and language preservation rules", () => {
33 - expect(TERSE_BLOCK).toContain("Never name or announce this style");
34 - expect(TERSE_BLOCK).toContain("Preserve current user message language");
35 - expect(TERSE_BLOCK).toContain("Ignore previous-turn language");
36 - });
38 - it("includes one terse example", () => {
39 - expect(TERSE_BLOCK.match(/^Example — /gm)).toHaveLength(1);
40 - });
42 - it("defines a brutal default response budget", () => {
43 - expect(TERSE_BLOCK).toContain("Default: one sentence");
44 - expect(TERSE_BLOCK).toContain("hard max ≤35");
45 - expect(TERSE_BLOCK).toContain("Failure: >35 words");
46 - expect(TERSE_BLOCK).toContain("Explain-only prompt → no code block");
47 - });
49 - it("anchors the live React probe as a no-code terse example", () => {
50 - expect(TERSE_BLOCK).toContain(
51 - "Inline object prop → new ref → memo compare fails → re-render.",
52 - );
53 - expect(TERSE_BLOCK).toContain("Use `useMemo` or pass primitives.");
54 - });
56 - it("does not duplicate existing terse block", () => {
57 - const prompt = `base\n\n${TERSE_BLOCK}`;
59 - expect(injectTerseBlock(prompt)).toBe(prompt);
60 - });
62 - it("still injects when prompt only mentions the terse heading", () => {
63 - const prompt = "base\nDo not write ## Response Protocol — terse yourself.";
65 - expect(injectTerseBlock(prompt)).toBe(
66 - `base\nDo not write ## Response Protocol — terse yourself.\n\n${TERSE_BLOCK}`,
67 - );
68 - });
69 -});

extensions/terse/assets/terse_after.gif

Deleted
deleted file mode 100644

Previous version contains binary or non-UTF-8 data.

extensions/terse/assets/terse_before.gif

Deleted
deleted file mode 100644

Previous version contains binary or non-UTF-8 data.

extensions/terse/index.ts

Deleted
deleted file mode 100644
1 -import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
3 -const TERSE_TITLE = "## Response Protocol — terse";
4 -const PI_DATE_FOOTER_MARKER = "\nCurrent date:";
6 -const TERSE_RULES = [
7 - "- Output only. No preamble, recap, hedging, filler.",
8 - "- Default: one sentence, ≤20 words. Max 2 short lines; hard max ≤35 unless user asks detail.",
9 - "- Aim lower: ≤15 words for simple answers.",
10 - "- Explain-only prompt → no code block. Answer cause → effect → fix in prose.",
11 - "- Before output, delete every nonessential word/sentence. If >2 sentences, merge.",
12 - "- Failure: >35 words, unsolicited code block, style label, or filler opener.",
13 - "- Never name or announce this style. No mode labels or recap headings.",
14 - "- Preserve current user message language. Ignore previous-turn language. Compress style, not language.",
15 - "- Drop articles/conjunctions when safe. Fragments OK. Prefer one sentence over list.",
16 - "- Abbrev: DB/auth/config/req/res/fn/impl/ref/ctx/obj/conn/comp.",
17 - "- Causality: X → Y → Z. Lists only when asked: •. Alternatives: A | B.",
18 - "- Repeated concept >2x → α/β/γ if clear.",
19 - "- Code, tool args, file contents, quoted errors: exact, uncompressed.",
20 - "- Security/user confusion/destructive ops: clarity > compression.",
21 - "Example — terse: Inline object prop → new ref → memo compare fails → re-render. Use `useMemo` or pass primitives.",
22 -];
24 -export const TERSE_BLOCK = [TERSE_TITLE, ...TERSE_RULES].join("\n");
26 -export function injectTerseBlock(prompt: string): string {
27 - if (prompt.includes(TERSE_BLOCK)) return prompt;
28 - const footer = prompt.lastIndexOf(PI_DATE_FOOTER_MARKER);
29 - return footer >= 0
30 - ? `${prompt.slice(0, footer)}\n\n${TERSE_BLOCK}${prompt.slice(footer)}`
31 - : `${prompt}\n\n${TERSE_BLOCK}`;
32 -}
34 -export default function (pi: ExtensionAPI) {
35 - pi.on("before_agent_start", (event) => ({
36 - systemPrompt: injectTerseBlock(event.systemPrompt),
37 - }));
38 -}

extensions/tldr/README.md

Modified
1 1 # tldr
3 -<!-- demo:tldr:start -->
5 -![TLDR live summary](assets/tldr.gif)
7 -<!-- demo:tldr:end -->
9 3 Live TLDR widget above the Pi editor.
11 5 ## Install / load

extensions/tldr/assets/tldr.gif

Deleted
deleted file mode 100644

Previous version contains binary or non-UTF-8 data.

extensions/tps/README.md

Modified
47 47 - Shared footer present: emits a `footer:segment` in the `llm` zone.
48 48 - No shared footer: falls back to `ctx.ui.setStatus("tps", ...)`.
49 49 - `session_shutdown`: clears state and removes status/segment.
51 -## Demo
53 -<!-- demo:tps:start -->
55 -![Tokens per second](assets/tps.gif)
57 -<!-- demo:tps:end -->

extensions/tps/assets/tps.gif

Deleted
deleted file mode 100644

Previous version contains binary or non-UTF-8 data.

scripts/demo.mjs

Deleted
deleted file mode 100644
1 -#!/usr/bin/env node
2 -import { spawnSync } from "node:child_process";
3 -import {
4 - copyFileSync,
5 - existsSync,
6 - mkdirSync,
7 - readdirSync,
8 - readFileSync,
9 - writeFileSync,
10 -} from "node:fs";
11 -import { dirname, join, resolve } from "node:path";
12 -import { pathToFileURL } from "node:url";
13 -import { commandExists, git, ROOT, rel, run } from "./lib/common.mjs";
15 -const DRIVERS = join(ROOT, "drivers");
16 -const EXTENSIONS = join(ROOT, "extensions");
17 -const OUT = join(ROOT, ".demo");
18 -const CAST_IDLE_LIMIT = "4.0";
19 -const AGG_ARGS = [
20 - "--theme",
21 - "asciinema",
22 - "--text-font-family",
23 - "JetBrains Mono",
24 - "--font-size",
25 - "14",
26 - "--line-height",
27 - "1.25",
28 - "--idle-time-limit",
29 - "4.0",
30 - "--last-frame-duration",
31 - "5",
32 - "--fps-cap",
33 - "24",
34 -];
36 -async function loadDriver(name) {
37 - const path = join(DRIVERS, `${name}.mjs`);
38 - if (!existsSync(path)) throw new Error(`driver not found: ${path}`);
39 - const m = await import(`${pathToFileURL(path).href}?v=${Date.now()}`);
40 - const driver = {
41 - name,
42 - title: m.title ?? name.replaceAll("_", " "),
43 - extensions: m.extensions,
44 - targets: m.targets,
45 - cols: m.cols ?? 100,
46 - rows: m.rows ?? 28,
47 - cwd: resolve(ROOT, m.cwd ?? "."),
48 - steps: m.steps,
49 - readme_id: m.readme_id ?? name,
50 - readme_items: m.readme_items,
51 - browser_script: m.browser_script,
52 - env: m.env ?? {},
53 - };
54 - return driver;
57 -function validateDriver(d) {
58 - for (const key of ["extensions", "targets", "steps"])
59 - if (!Array.isArray(d[key]))
60 - throw new Error(`${d.name}: ${key} must be array`);
61 - if (
62 - !Number.isInteger(d.cols) ||
63 - !Number.isInteger(d.rows) ||
64 - d.cols < 40 ||
65 - d.rows < 12
66 - )
67 - throw new Error(`${d.name}: bad cols/rows`);
68 - if (!existsSync(d.cwd)) throw new Error(`${d.name}: cwd missing ${d.cwd}`);
69 - for (const name of d.extensions)
70 - if (!existsSync(join(EXTENSIONS, name, "index.ts")))
71 - throw new Error(`${d.name}: missing extension ${name}`);
72 - for (const name of d.targets)
73 - if (!existsSync(join(EXTENSIONS, name, "README.md")))
74 - throw new Error(`${d.name}: missing target ${name}`);
77 -function shellQuote(s) {
78 - return `'${String(s).replaceAll("'", `'\\''`)}'`;
80 -function piCommand(d) {
81 - const parts = [
82 - "pi",
83 - "--no-session",
84 - "--no-context-files",
85 - "--no-skills",
86 - "--no-prompt-templates",
87 - "--no-extensions",
88 - ];
89 - for (const name of d.extensions) parts.push("-e", join(EXTENSIONS, name));
90 - return parts.map(shellQuote).join(" ");
92 -function expectQuote(s) {
93 - return `{${String(s).replaceAll("}", "\\}")}}`;
95 -function expectScript(d) {
96 - const lines = [
97 - `set timeout 90`,
98 - `cd ${expectQuote(d.cwd)}`,
99 - ...Object.entries(d.env).map(([k, v]) => `set env(${k}) ${expectQuote(v)}`),
100 - `spawn -noecho -nottycopy -nottyinit -winsize ${d.rows} ${d.cols} sh -lc ${expectQuote(piCommand(d))}`,
101 - ];
102 - for (const step of d.steps) {
103 - const [op, a, b, c] = step;
104 - if (op === "wait") lines.push(`after ${a}`);
105 - else if (op === "type" || op === "send")
106 - lines.push(`send -- ${expectQuote(a)}`, `after ${b ?? 500}`);
107 - else if (op === "command" || op === "prompt")
108 - lines.push(
109 - `send -- ${expectQuote(a)}`,
110 - `after ${op === "prompt" ? 450 : 350}`,
111 - `send -- "\\r"`,
112 - `after ${b ?? (op === "prompt" ? 12000 : 1000)}`,
113 - );
114 - else if (op === "expect")
115 - lines.push(
116 - `expect -timeout ${Math.ceil((b ?? 30000) / 1000)} -re ${expectQuote(a)}`,
117 - `after ${c ?? 300}`,
118 - );
119 - else if (op === "ready")
120 - lines.push(
121 - `expect -timeout ${Math.ceil((a ?? 30000) / 1000)} -re {(›|❯|> )}`,
122 - `after 300`,
123 - );
124 - else if (op === "ctrl") lines.push(`send \\003`, `after 500`);
125 - else if (op === "quit") break;
126 - }
127 - lines.push(`send \\003`, `after 500`, `catch {close}`, `wait`);
128 - return `${lines.join("\n")}\n`;
131 -function ensureTools() {
132 - const missing = ["asciinema", "agg", "expect"].filter(
133 - (tool) => !commandExists(tool),
134 - );
135 - if (missing.length) throw new Error(`missing tool(s): ${missing.join(", ")}`);
137 -function drive(d) {
138 - validateDriver(d);
139 - if (!commandExists("expect")) throw new Error("missing tool: expect");
140 - const script = expectScript(d);
141 - const r = spawnSync("expect", ["-c", script], {
142 - cwd: ROOT,
143 - stdio: "inherit",
144 - encoding: "utf8",
145 - });
146 - return r.status ?? 1;
148 -function record(d, gifOut) {
149 - validateDriver(d);
150 - mkdirSync(OUT, { recursive: true });
151 - const cast = join(OUT, `${d.name}.cast`),
152 - gif = gifOut ?? join(OUT, `${d.name}.gif`),
153 - txt = join(OUT, `${d.name}.txt`);
154 - mkdirSync(dirname(gif), { recursive: true });
155 - if (d.browser_script) {
156 - if (!existsSync(join(ROOT, d.browser_script)))
157 - throw new Error(`${d.name}: browser_script missing`);
158 - run("bun", [join(ROOT, d.browser_script), "--out", gif], { cwd: ROOT });
159 - writeFileSync(cast, "browser demo: no asciinema cast\n");
160 - writeFileSync(txt, "browser demo\n");
161 - return [cast, gif, txt];
162 - }
163 - ensureTools();
164 - run(
165 - "asciinema",
166 - [
167 - "rec",
168 - "--headless",
169 - "--overwrite",
170 - "--capture-input",
171 - "--window-size",
172 - `${d.cols}x${d.rows}`,
173 - "-i",
174 - CAST_IDLE_LIMIT,
175 - "-c",
176 - `node ${shellQuote(join(ROOT, "scripts/demo.mjs"))} --drive ${shellQuote(d.name)}`,
177 - cast,
178 - ],
179 - { cwd: ROOT },
180 - );
181 - run(
182 - "agg",
183 - [
184 - "--cols",
185 - String(d.cols),
186 - "--rows",
187 - String(d.rows),
188 - ...AGG_ARGS,
189 - cast,
190 - gif,
191 - ],
192 - { cwd: ROOT },
193 - );
194 - run("asciinema", ["convert", "-f", "txt", cast, txt, "--overwrite"], {
195 - cwd: ROOT,
196 - capture: true,
197 - });
198 - return [cast, gif, txt];
200 -function row(cells, widths) {
201 - return `| ${cells.map((c, i) => c.padEnd(widths[i])).join(" | ")} |`;
203 -function readmeBlock(d) {
204 - if (d.readme_items) {
205 - const headers = d.readme_items.map(([caption]) => `**${caption}**`),
206 - images = d.readme_items.map(
207 - ([caption, gif]) => `![${caption}](assets/${gif})`,
208 - ),
209 - widths = headers.map((h, i) => Math.max(h.length, images[i].length, 3));
210 - return `<!-- demo:${d.readme_id}:start -->\n\n${row(headers, widths)}\n${row(
211 - widths.map((w) => "-".repeat(w)),
212 - widths,
213 - )}\n${row(images, widths)}\n\n<!-- demo:${d.readme_id}:end -->`;
214 - }
215 - return `<!-- demo:${d.readme_id}:start -->\n![${d.title}](assets/${d.name}.gif)\n<!-- demo:${d.readme_id}:end -->`;
217 -function stripDemoBlocks(text) {
218 - return (
219 - text
220 - .replace(
221 - /\n*## Demo\n\n<!-- demo:[^:\n]+:start -->[\s\S]*?<!-- demo:[^:\n]+:end -->\n*/g,
222 - "\n\n",
223 - )
224 - .replace(
225 - /\n*<!-- demo:[^:\n]+:start -->[\s\S]*?<!-- demo:[^:\n]+:end -->\n*/g,
226 - "\n\n",
227 - )
228 - .replace(/\n*## Demo\n\nNone\.\n*/g, "\n\n")
229 - .replace(/\n{3,}/g, "\n\n")
230 - .trim() + "\n"
231 - );
233 -function updateReadme(path, d) {
234 - const text = stripDemoBlocks(readFileSync(path, "utf8"));
235 - const lines = text.split(/\r?\n/);
236 - const idx = lines.findIndex((l) => l.startsWith("# "));
237 - if (idx === -1) throw new Error(`README missing H1 title: ${path}`);
238 - writeFileSync(
239 - path,
240 - `${lines
241 - .slice(0, idx + 1)
242 - .join("\n")
243 - .trim()}\n\n${readmeBlock(d)}\n\n${lines
244 - .slice(idx + 1)
245 - .join("\n")
246 - .trimStart()}`.trimEnd() + "\n",
247 - );
249 -function installAssets(d, gif) {
250 - for (const name of d.targets) {
251 - const assets = join(EXTENSIONS, name, "assets");
252 - mkdirSync(assets, { recursive: true });
253 - copyFileSync(gif, join(assets, `${d.name}.gif`));
254 - updateReadme(join(EXTENSIONS, name, "README.md"), d);
255 - console.log(`OK asset ${name}/assets/${d.name}.gif`);
256 - }
258 -function driverNames() {
259 - return readdirSync(DRIVERS)
260 - .filter((n) => n.endsWith(".mjs") && !n.startsWith("__"))
261 - .map((n) => n.replace(/\.mjs$/, ""))
262 - .sort();
264 -function latestReleaseTag() {
265 - const r = git(["tag", "--list", "v*", "--sort=-creatordate"], {
266 - capture: true,
267 - });
268 - return r.stdout.split(/\r?\n/).filter(Boolean)[0];
270 -function changedSinceRelease(path, tag) {
271 - if (
272 - git(["status", "--porcelain", "--", rel(path)], {
273 - capture: true,
274 - }).stdout.trim()
275 - )
276 - return true;
277 - return (
278 - !tag ||
279 - git(["diff", "--quiet", tag, "--", rel(path)], { check: false }).status !==
280 - 0
281 - );
283 -function driverWatchPaths(d) {
284 - return [
285 - join(DRIVERS, `${d.name}.mjs`),
286 - ...[...new Set([...d.targets, ...d.extensions])]
287 - .sort()
288 - .map((n) => join(EXTENSIONS, n)),
289 - ];
291 -async function changedDriverNames(names) {
292 - const tag = latestReleaseTag(),
293 - out = [];
294 - for (const name of names) {
295 - const d = await loadDriver(name);
296 - if (driverWatchPaths(d).some((p) => changedSinceRelease(p, tag)))
297 - out.push(name);
298 - else console.log(`OK demo ${name} skipped (unchanged since ${tag})`);
299 - }
300 - return out;
302 -async function printDrivers() {
303 - for (const name of driverNames()) {
304 - const d = await loadDriver(name);
305 - console.log(
306 - `${name}\ttargets=${d.targets.join(",")}\textensions=${d.extensions.join(",")}`,
307 - );
308 - }
310 -async function runDemo(name, noInstall, gifOut) {
311 - const d = await loadDriver(name);
312 - const [cast, gif, txt] = record(d, gifOut);
313 - console.log(`OK cast ${cast}`);
314 - console.log(`OK gif ${gif}`);
315 - console.log(`OK txt ${txt}`);
316 - if (!noInstall) installAssets(d, gif);
317 - return d.targets.map((t) => join(EXTENSIONS, t));
319 -async function selectedNames(items, all, changed) {
320 - if (items[0] === "all") return [driverNames(), false];
321 - if (items[0] === "changed")
322 - return [
323 - await changedDriverNames(
324 - items.slice(1).length ? items.slice(1) : driverNames(),
325 - ),
326 - true,
327 - ];
328 - if (all) return [driverNames(), false];
329 - if (changed)
330 - return [
331 - await changedDriverNames(items.length ? items : driverNames()),
332 - true,
333 - ];
334 - return [items, false];
336 -async function main(argv = process.argv.slice(2)) {
337 - const flags = new Set(argv.filter((a) => a.startsWith("--")));
338 - const value = (flag) => {
339 - const i = argv.indexOf(flag);
340 - return i === -1 ? undefined : argv[i + 1];
341 - };
342 - if (value("--drive")) return drive(await loadDriver(value("--drive")));
343 - const items = argv.filter(
344 - (a, i) =>
345 - !a.startsWith("--") &&
346 - argv[i - 1] !== "--drive" &&
347 - argv[i - 1] !== "--out",
348 - );
349 - if (flags.has("--list") || ["list", "ls"].includes(items[0])) {
350 - await printDrivers();
351 - return 0;
352 - }
353 - const [names, wasChanged] = await selectedNames(
354 - items,
355 - flags.has("--all"),
356 - flags.has("--changed"),
357 - );
358 - if (!names.length) {
359 - if (wasChanged) console.log("OK demo none");
360 - else await printDrivers();
361 - return 0;
362 - }
363 - if (value("--out") && names.length !== 1)
364 - throw new Error("--out requires exactly one driver");
365 - for (const name of names) {
366 - await runDemo(name, flags.has("--no-install"), value("--out"));
367 - console.log(`OK demo ${name}`);
368 - }
369 - return 0;
371 -if (import.meta.url === `file://${process.argv[1]}`)
372 - main()
373 - .then((code) => process.exit(code))
374 - .catch((e) => {
375 - console.error(e.message);
376 - process.exit(1);
377 - });