repositories / pi-ext

pi-ext

bugabingas pi extensions

owned by bugabinga

docs: update extension guides and demos

c428b01f4e48953a914ffb770dcf56dca2424ded

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Changed files (27)

+345 / −87 text lines · 8 binary (striped old/new sizes in 64-byte units, not churn) · lines and sizes scale separately

Diff layout

README.md

Modified

+11 / −5 text lines

11# pi-ext
3Personal Pi extension pack:
4tools, footers, shell bridges, workflow hacks, small demons.
3Personal Pi extension pack: tools, footers, shell bridges, workflow hacks,
4small demons.
66## Install
1212All extensions via git, pinned:
1414```bash
15pi install git:github.com/bugabinga/pi-ext@v0.0.2
15pi install git:github.com/bugabinga/pi-ext@v0.0.3
1616```
1818Default branch install:
2121pi install git:github.com/bugabinga/pi-ext
2222```
24Local checkout, absolute path:
26```bash
27pi install /home/me/Workspace/pi-ext
28```
2430Local checkout, `~` path:
2632```bash
3440 "packages": [
3541 {
36 "source": "git:github.com/bugabinga/pi-ext@v0.0.2",
42 "source": "git:github.com/bugabinga/pi-ext@v0.0.3",
3743 "extensions": ["extensions/web/index.ts"],
3844 "skills": [],
3945 "prompts": [],
127133---
129135Fat prompts rot in bins.\
130Pi cats claw the workflow gods.\
136Pi cats claw workflow gods.\
131137Small tools drink the dark.

TMUX_AGENT_WORKFLOWS.md

Added
new file mode 100644

+229 / −0 text lines

1# tmux for Agent Workflows
2
3Practical patterns for using tmux to drive real interactive agents, TUI apps,
4long-running jobs, and manual integration tests.
5
6## Use Cases
7
8- Real interactive testing: exercise actual terminal UI, not mocks.
9- Long-running workflows: let agents, builds, servers, or model calls run while
10 you inspect from outside.
11- Input timing tests: send input while a process is busy, idle, paused, or
12 waiting.
13- UI verification: capture status bars, widgets, spinners, prompts, and
14 wrapped text.
15- Repro sandboxes: run each scenario in a fresh cwd/session dir.
16- Debug artifacts: preserve logs, transcripts, temp files, and captured pane output.
17- Remote work: keep sessions alive across SSH disconnects.
18- Multi-process orchestration: agent pane + server pane + logs pane + watcher pane.
20## Pros
22- Tests real behavior end-to-end.
23- Works with any terminal app.
24- Non-blocking: launch, poll, inspect, continue.
25- Scriptable enough for smoke tests.
26- Great for reproducing bugs found only in interactive mode.
27- Keeps visible history while also allowing machine-readable session/log inspection.
29## Cons
31- Timing can be brittle; sleeps and polling are imperfect.
32- Pane output may wrap, truncate, or include ANSI/control artifacts.
33- Assertions are weaker than structured APIs.
34- Cleanup matters: stale tmux sessions and temp dirs cause false results.
35- Real providers/network/LLMs add cost, latency, and nondeterminism.
36- Terminal dimensions affect rendering.
38## Core Pattern
40```bash
41set -euo pipefail
43name=my_agent_test
44work=/tmp/$name
46rm -rf "$work"
47mkdir -p "$work"
48tmux kill-session -t "$name" 2>/dev/null || true
50tmux new-session -d -s "$name" -x 120 -y 40 "cd '$work' && your-agent-or-tui"
52sleep 2
53tmux capture-pane -t "$name" -p -S -80
54```
56## Sending Input
58```bash
59tmux set-buffer -t "$name" 'your input here'
60tmux paste-buffer -t "$name"
61tmux send-keys -t "$name" Enter
62```
64For special keys:
66```bash
67tmux send-keys -t "$name" C-c
68tmux send-keys -t "$name" Escape
69tmux send-keys -t "$name" Tab
70```
72## Polling for Completion
74Prefer semantic stop conditions over fixed sleeps.
76```bash
77for i in {1..30}; do
78 sleep 5
79 out=$(tmux capture-pane -t "$name" -p -S -200)
80 echo "$out" | tail -80
81 echo "$out" | grep -q 'DONE_MARKER' && break
82done
83```
85Use unique markers in prompts/tasks:
87```text
88Create file proof.txt containing EXACT_MARKER_123, then print DONE_MARKER_123.
89```
91## Capturing UI State
93```bash
94tmux capture-pane -t "$name" -p -S -200 > /tmp/pane.txt
95```
97Tips:
99- Use fixed pane size: `-x 120 -y 40`.
100- Capture enough scrollback: `-S -200` or more.
101- Prefer checking stable text, not exact whole-screen snapshots.
102- For wrapping/color bugs, inspect both pane output and screenshots if needed.
104## Inspecting Artifacts
106Pair tmux with structured logs/session files.
108```bash
109find "$work" -type f -maxdepth 3 -print
110cat "$work/log.jsonl" 2>/dev/null || true
111```
113For JSONL:
115```bash
116python - <<'PY' "$work/session.jsonl"
117import json, sys
118for line in open(sys.argv[1]):
119 obj = json.loads(line)
120 if obj.get("type") in {"event", "state", "custom"}:
121 print(json.dumps(obj, ensure_ascii=False))
122PY
123```
125## Testing Busy-State Input
127tmux is useful for testing input while a process is occupied.
129```bash
130# start a long task
131send 'run a command that sleeps 10 seconds'
132sleep 2
134# send another input during the busy period
135send 'this should queue/steer/cancel/be rejected'
136```
138Check:
140- Was input accepted?
141- Was it queued or applied immediately?
142- Did it interrupt the running operation?
143- Did final state include the new instruction?
144- Did UI show pending/queued/steering state?
146## Multi-Pane Workflow
148```bash
149tmux new-session -d -s "$name" -x 160 -y 48 -n main "cd '$work' && agent"
150tmux split-window -t "$name" -h "cd '$work' && tail -f app.log"
151tmux split-window -t "$name" -v "cd '$work' && watch -n1 'find . -maxdepth 2 -type f -ls'"
152tmux select-pane -t "$name":0.0
153```
155Useful layouts:
157- Left: agent/TUI
158- Right top: logs
159- Right bottom: filesystem/session watcher
161## Cleanup
163```bash
164tmux kill-session -t "$name" 2>/dev/null || true
165rm -rf "$work"
166```
168For debugging, do not delete immediately. Print paths instead:
170```bash
171echo "tmux attach -t $name"
172echo "workdir: $work"
173```
175## Best Practices
1771. Start with unit/API tests.
1782. Use tmux for real interactive smoke tests.
1793. If tmux finds a bug, add a deterministic unit/harness regression.
1804. Re-run tmux once after the fix.
1815. Keep tmux tests short and marker-based.
1826. Avoid exact full-pane assertions unless testing layout.
1837. Always isolate cwd, config, session/log dirs.
1848. Always kill old sessions before starting.
1859. Use real network/model/provider tests sparingly.
18610. Record exact command, cwd, model/env, pane capture, and artifact paths.
188## Common Failure Modes
190- Prompt sent before app is ready → add readiness polling.
191- Input pasted while app uses alternate screen/editor mode → use `send-keys` or
192 paste buffer carefully.
193- Output wraps differently → fix pane dimensions.
194- Grep matches old scrollback → use unique markers or clear pane before scenario.
195- Stale session reused → kill session and reset workdir.
196- App still running when assertions start → poll for a completion marker.
198## Reusable Helpers
200```bash
201send() {
202 tmux set-buffer -t "$name" "$1"
203 tmux paste-buffer -t "$name"
204 tmux send-keys -t "$name" Enter
205}
207pane() {
208 tmux capture-pane -t "$name" -p -S "${1:--200}"
209}
211wait_for() {
212 local needle="$1"
213 for i in {1..60}; do
214 sleep 1
215 pane -300 | grep -q "$needle" && return 0
216 done
217 pane -300 >&2
218 return 1
219}
220```
222## When Not to Use tmux
224- Pure deterministic logic tests.
225- Fast CI checks where APIs expose structured state.
226- Security-sensitive automation with secrets visible in pane scrollback.
227- Large-scale regression suites needing strict determinism.
229Use tmux as a realism layer, not as the only test harness.

extensions/angel/README.md

Modified

+5 / −4 text lines

55Angel is available only when the active executor model matches a configured
66executor/advisor pair and the advisor model is registered.
7
78It builds a context packet, asks the paired advisor model for JSON advice,
89injects advice after tool errors, and blocks selected dangerous shell commands
910once.
1112## Install / load
1314Angel is loaded through the root `pi-ext` package.
14See [root README](../../README.md).
15See [root README](../../README.md).
1617## Commands / tools / settings
113114 file, 9 recent tool errors, and 60k chars of system prompt.
114115- Tracks touched files from prior `read`, `edit`, and `write` tool calls.
115116- Calls the configured advisor model for the active executor model.
116- Requires an API key for the advisor model provider.
117117- Requests JSON advice with summary, next action, risks, assumptions, validation
118118 checklist, enforceable policy, advisory-only guidance, confidence, and
119119 insufficient-context flag.
132132## Policy Gates
134134No popups.
135136When `policyGate` is `block`:
1371381. Executor attempts selected dangerous `bash`:
138139 `sudo`, `rm -rf`, `git push`, `npm publish`, `pnpm publish`, `bun publish`,
139 recursive `chmod`/`chown`, `dd if=`/`dd of=`, `mkfs`, `curl|sh`, `curl|bash`,
140 `wget|sh`, `wget|bash`, or fork bomb syntax.
140 recursive `chmod`/`chown`, `dd if=`/`dd of=`, `mkfs`, `curl|sh`,
141 `curl|bash`, `wget|sh`, `wget|bash`, or fork bomb syntax.
1411422. Angel blocks that exact command once.
1421433. Angel consults the advisor and returns formatted advice in the block reason.
1431444. Executor may retry the same command if still correct.

extensions/builtin-tools/README.md

Modified

+3 / −5 text lines

55## Install / load
77Loaded through root pi-ext package.
8See [root README](../../README.md).
8See [root README](../../README.md).
1010## Commands / tools / settings
3232`/builtin-tools` checks registered tools, then toggles available built-ins:
34- if all are active:
35 disables them
36- otherwise:
37 enables them
34- if all are active: disables them
35- otherwise: enables them
3937UI notifications report changed tools.
4038If no target tools are registered, the command reports that.

extensions/context-size/README.md

Modified

+6 / −10 text lines

55## Install / load
77Loaded through the root `pi-ext` package.
8See [root README](../../README.md).
8See [root README](../../README.md).
1010## Commands / tools / settings
3131Emits:
33- `footer:segment` to publish/clear `context-size` footer segment.
33- `footer:segment` to publish/clear the `context-size` footer segment.
3535## Behavior
4545Usage color:
47- `< 70%`:
48 muted
49- `≥ 70%`:
50 warning
51- `≥ 85%`:
52 error
53- unknown percent:
54 muted
47- `< 70%`: muted
48- `≥ 70%`: warning
49- `≥ 85%`: error
50- unknown percent: muted
5652No UI update runs when UI is unavailable.

extensions/cost/README.md

Modified

+4 / −2 text lines

11# cost
3Pi token and spend telemetry.
3Token and spend telemetry for Pi.
55## Install / load
77Loaded through the root `pi-ext` package.
8See [root README](../../README.md).
8See [root README](../../README.md).
1010## Commands / tools / settings
3535- `footer:segment` when `@bugabinga/pi-ext-footer` is loaded:
3636 `tokens`, `cost` in the `llm` zone.
37 `tokens` uses `muted`, order `2`.
38 `cost` uses `success`, order `3`.
3840UI status:

extensions/ctx/README.md

Modified

+4 / −4 text lines

1818Pi hooks:
2020- `tool_result`:
21 watches builtin `read` results and may replace large full-file reads with a
21 watches builtin `read` results and may replace large read output with a
2222 bounded head/tail view.
2424Pi settings:
3838`ctx` does one thing:
40401. watches `read` tool results
412. ignores errors and bounded reads with `limit` or `l`
412. ignores errors and reads with `limit` or `l`
42423. compares UTF-8 byte length against threshold
434. if full read output exceeds threshold, returns:
434. if read output exceeds threshold, returns:
4444 - first 8 lines
4545 - `[ctx compacted read:
4646 ...]` marker
5252`20000` bytes.
5454Invalid env values fall back to default.
55`0` compacts any non-empty full read.
55`0` compacts any non-empty read.
5757No DB.
5858No search tool.

extensions/cwd/README.md

Modified

+2 / −2 text lines

11# cwd
3Switch Pi cwd without leaving current session.
3Switch Pi cwd without leaving the session.
55## Install / load
77This extension is loaded through the root pi-ext package.
8See [root README](../../README.md).
8See [root README](../../README.md).
1010## Commands / tools / settings

extensions/devil/README.md

Modified

+2 / −10 text lines

66## Install / load
88Loaded through the root pi-ext package.
9See [root README](../../README.md).
11## Quick Start
13```bash
14pi
15/devil we should switch to microservices
16```
9See [root README](../../README.md).
1811## Commands / tools / settings
3124Commands:
3326- `/devil <idea>` — start an interactive debate.
34- `/devil` — reports `Usage:
35 /devil <your idea>`.
27- `/devil` — reports `Usage: /devil <your idea>`.
3729Registered flags:

extensions/diff-review/README.md

Modified

+9 / −7 text lines

11# diff-review
3Browser UI for reviewing git diffs and sending findings back to Pi.
4
35<!-- demo:diff-review:start -->
57| **Pi bridge** | **Browser UI** |
911<!-- demo:diff-review:end -->
11Browser UI for reviewing git diffs and sending findings back to Pi.
1313## Install / load
1515Loaded through the root pi-ext package.
16See [root README](../../README.md).
16See [root README](../../README.md).
1818## Commands / tools / settings
2222- `/diff-review`
2323- `/diff-review --staged`
2424- `/diff-review --base <ref>` or `/diff-review --base=<ref>`
25- `/diff-review --files <path[,path...]>` or `/diff-review
26 --files=<path[,path...]>`
25- `/diff-review --files <path[,path...]>` or `/diff-review --files=<path[,path...]>`
2726- `/diff-review-cancel`
2928Tools:
3231Hooks:
3433- `session_start`:
35 restores review state, open findings status, and live browser review when
36 present.
34 restores persisted review rounds and open findings state.
35 Persisted live reviews are not auto-reopened.
3736- `session_shutdown`:
3837 closes active review server.
5453 reviews staged diff.
5554- `--base <ref>`:
5655 reviews `<ref>...HEAD`.
56- `--base` rejects refs that start with `-` or contain NUL.
5757- `--staged` and `--base` are mutually exclusive.
5858- `--files` accepts comma-separated relative paths.
5959 Absolute paths, `..`, and NUL are rejected.
6060- Path filters are rebased from Pi cwd to repo root before `git diff`.
6161- Uses `git diff --no-ext-diff --find-renames --src-prefix=a/ --dst-prefix=b/
6262 --unified=3`.
63- Preserves rename metadata in staged diffs.
64- Normalizes quoted git paths for diff parsing.
6365- Starts a local HTTP server on `127.0.0.1`; prefers port `47717`, falls back to
6466 an ephemeral port if busy.
6567- Review URL carries a token.

extensions/diff-review/assets/diff_review_browser.gif

Modified

Binary size (old → new): 180264 → 250712 bytes.

extensions/diff-review/assets/diff_review_terminal.gif

Modified

Binary size (old → new): 90288 → 90749 bytes.

extensions/fast/README.md

Modified

+26 / −9 text lines

77Loaded through the root `pi-ext` package.
88See [../../README.md](../../README.md).
10## Settings
10## Commands / tools / settings
12Commands: none.
14Tools: none.
16Hooks:
18- `session_start`: refreshes settings from the session cwd.
19- `model_select`: refreshes settings from the session cwd.
21Settings:
1223```json
1829```
31`fast.enable` is a boolean. Project settings override global settings.
32Default: disabled.
2034## Behavior
22When enabled, wraps `openai-codex` streaming and sends native `serviceTier:
23"priority"`.
36Registers provider `openai-codex` with API `openai-codex-responses`.
38When enabled, wraps `openai-codex` streaming and sends native
39`serviceTier: "priority"`.
41When disabled, uses the normal simple OpenAI Codex response stream.
2543Scope:
27- provider:
28 `openai-codex`
29- API:
30 `openai-codex-responses`
45- provider: `openai-codex`
46- API: `openai-codex-responses`
3147- all OpenAI Codex models
33No commands.
34No tools.
49Reasoning options are clamped for the selected model before sending.
50If the clamped reasoning level is `off`, no `reasoningEffort` is sent.
3552No model allowlist.

extensions/footer/README.md

Modified

+3 / −6 text lines

1111## Install / load
1313Loaded through the root `pi-ext` package.
14See [root README](../../README.md).
14See [root README](../../README.md).
1616## Commands / tools / settings
4545Optional fields:
4646`variants`, `icon`, `color`, `bar`, `suffix`, `order`.
48Send `{ id, text:
49undefined }` to remove a segment.
48Send `{ id, text: undefined }` to remove a segment.
5150Segments sort by `order`; default is `50`.
5251Current session name is inserted in the `workspace` zone with order `0.5`.
6362Bar values clamp to `0..100`.
6564Publishes capability state at `Symbol.for("@bugabinga/pi-ext-footer")`:
66`{ version:
671, loaded:
68true }`.
65`{ version: 1, loaded: true }`.
6966On quit/reload shutdown, `loaded` becomes `false`.
7168Hidden mode swaps in a zero-height footer stub.

extensions/footer/assets/footer.gif

Modified

Binary size (old → new): 535294 → 62531 bytes.

extensions/ghost/README.md

Modified

+1 / −1 text lines

55## Install / load
77Loaded through the root pi-ext package.
8See [root README](../../README.md).
8See [root README](../../README.md).
1010## Commands / tools / settings

extensions/git-safe/README.md

Modified

+2 / −0 text lines

2121 optional branch name
2222- Hooks:
2323 - `session_start`
24 - `session_shutdown`
2425 - `tool_result` for `read`
2526- Settings:
2627 none
5657 count, symlink count, symlink paths, and warnings
5758- recovers marked clone dirs on `session_start` by scanning cwd, temp dir,
5859 `~/.local/state/pi`, and home up to depth 4
60- cancels stale async recovery work on `session_shutdown`
5961- notifies UI when recovered clone dirs are found
6062- wraps text `read` results from tracked clone dirs in `<untrusted_external_data
6163 marker="...">` markers with a git-specific warning preamble

extensions/leaks/README.md

Modified

+17 / −3 text lines

55## Install / load
7Loaded through the root [pi-ext package](../../README.md).
7Loaded through the root [pi-ext package](../../README.md).
99## Commands / tools / settings
1111Command:
1212`/leaks status|reload|test <text>|clear`.
14Tools: none.
16Hooks:
17provider requests, context messages, tool calls, assistant message end.
1419Settings namespace:
1520`leaks` in Pi `settings.json`.
2025 "enabled": true,
2126 "keywords": ["acme-internal"],
2227 "regex": [{ "pattern": "foo_[A-Za-z0-9]{32}", "label": "FOO_TOKEN" }],
23 "secretFiles": [".env", ".env.local"],
28 "secretFiles": [".env", ".env.local", ".env.*.local"],
2429 "exclude": ["localhost", "127.0.0.1"]
2530 }
2934## Behavior
3136Redacts only copies sent to providers.
32Local tools receive restored args.
37Context-message copies are redacted without mutating originals.
38Local tools receive restored args before execution.
3339Final assistant messages are restored locally.
40Secret values are loaded from configured files relative to Pi cwd.
41Built-in rules cover common AI provider tokens, developer tokens, cloud keys,
42JWTs, private keys, and selected connection strings.
43Custom `keywords` use smart boundaries.
44Custom `regex` entries may be strings or objects with `pattern`, `flags`, and
45`label`.
46Generic assignment redaction requires sufficiently random values and skips
47common false positives.
3448Placeholders are generic:
3549`__LEAK_<hash>__`.

extensions/model-info/README.md

Modified

+9 / −5 text lines

11# model-info
3Pi model and thinking telemetry.
3Model and thinking telemetry for Pi.
55## Install / load
77Loaded through the root `pi-ext` package.
8See [root README](../../README.md).
8See [root README](../../README.md).
1010## Commands / tools / settings
1818Settings read:
2020- `fast.enable`:
21 appends `fast` when current provider is `openai-codex`.
21 when the current provider is `openai-codex`, appends `fast` if enabled.
22 Project setting overrides global setting.
2324Hooks:
2526- `session_start`, `model_select`, `thinking_level_select`, `session_compact`:
2627 publish telemetry.
2728- `session_shutdown`:
28 clear published status/footer segment.
29 clears published status/footer segment.
3031Events emitted:
4849Model label uses the last `/`-separated model id segment.
4950Missing model becomes `no-model`.
51Thinking level comes from `thinking_level_select`; otherwise from latest
52Thinking level comes from `thinking_level_select`; otherwise from the latest
5253`thinking_level_change` session entry; fallback is `off`.
55Publishing only runs when UI is available. On shutdown, the extension clears its
56footer segment and status fallback.

extensions/neko/README.md

Modified

+1 / −1 text lines

77## Install / load
99Loaded through the root pi-ext package.
10See [root README](../../README.md).
10See [root README](../../README.md).
1212## Commands / tools / settings

extensions/nu-bang/README.md

Modified

+5 / −2 text lines

99## Install / load
1111Loaded through the root pi-ext package.
12See [root README](../../README.md).
12See [root README](../../README.md).
1414## Commands / tools / settings
2828 Pi-provided command.
2929- Commands run as `nu -l --no-history --error-style fancy --table-mode none -c
3030 <command>`.
31- Stdout and stderr stream back through Pi shell execution.
3231- Execution receives Pi cwd, env, abort signal, and timeout.
3332- Working directory is checked before execution and completion.
3433- Abort and timeout send `SIGTERM`, then `SIGKILL` after 250 ms if the process
3534 group is still alive.
35- Output has terminal control sequences removed before it is returned.
36- Long output is truncated with Pi's output truncation helper.
37- Truncated full output is written to `pi-nu-bang-output-*.log` temp files with
38 mode `0600`.
3639- `session_start` wraps the current autocomplete provider.
3740- Bang completion strips leading `!` or `!!` before asking Nushell for
3841 completions.

extensions/prompt-autopsy/README.md

Modified

+6 / −11 text lines

55## Install / load
77Loaded through the root pi-ext package.
8See [../../README.md](../../README.md).
8See the [root README](../../README.md).
1010## Commands / tools / settings
12- Command:
13 `/prompt-autopsy`
14- Shortcut:
15 `Ctrl+Alt+A`
16- Hooks:
17 `session_start`, `session_shutdown`, `before_agent_start`, `agent_start`
18- Tools:
19 none
20- Settings:
21 none
12- Command: `/prompt-autopsy`
13- Shortcut: `Ctrl+Alt+A`
14- Hooks: `session_start`, `session_shutdown`, `before_agent_start`, `agent_start`
15- Tools: none
16- Settings: none
2318## Behavior

extensions/prune/assets/prune.gif

Modified

Binary size (old → new): 267812 → 269756 bytes.

extensions/terse/assets/terse_after.gif

Modified

Binary size (old → new): 417710 → 356155 bytes.

extensions/terse/assets/terse_before.gif

Modified

Binary size (old → new): 403352 → 464469 bytes.

extensions/tldr/assets/tldr.gif

Modified

Binary size (old → new): 176452 → 191929 bytes.

extensions/tps/assets/tps.gif

Modified

Binary size (old → new): 148520 → 153813 bytes.