repositories / pi-ext

pi-ext

bugabingas pi extensions

owned by bugabinga

extensions/tune/README.md

Raw

tune

Tune code through autonomous experiment loops for Pi.

Install / load

Loaded through the root pi-ext package. Slug: tune. Package: @bugabinga/pi-ext-tune. See root README.

Commands / tools / settings

Commands: /tune [off|clear|export|<text>] — start, stop, clear, or resume tune mode. clear deletes .pi/tune/session.jsonl; it leaves ideas.md, benchmarks, checks, and hooks intact.

Tools:

Settings: Keyboard shortcuts configurable in <agent-dir>/extensions/tune.json.

Hooks

State

All state lives in .pi/tune/.

File Purpose
session.jsonl Append-only experiment log
session.md Living document: objective, what's been tried
ideas.md Backlog of untried optimizations
benchmark.mjs Benchmark script
checks.mjs Optional correctness gate
config.json Optional (maxIterations)
hooks/before.mjs Optional pre-iteration hook
hooks/after.mjs Optional post-iteration hook

Behavior

Tunes through an autonomous loop: edit → benchmark → log → keep or discard → repeat.

VCS behavior is native per repo: jj repos use jj describe / jj new / jj abandon; non-jj repos use Git. Tune takes an exclusive .pi/tune/lock.json repo lock per Pi session. Parallel tune runs in one checkout are rejected; use a separate checkout/workspace for parallel tuning.

Confidence scoring (MAD-based) after 3+ runs: ≥2.0× = real, 1.0–2.0× = marginal, <1.0× = noise.

Backpressure: if checks.mjs exists, runs after every passing benchmark. Failures block keep.

Hooks: .mjs scripts that receive JSON on stdin. Stdout → steer message to agent. Cross-platform.

Markdown source
File outline
# tune

Tune code through autonomous experiment loops for Pi.

## Install / load

Loaded through the root `pi-ext` package.
Slug: `tune`. Package: `@bugabinga/pi-ext-tune`.
See [root README](../../README.md).

## Commands / tools / settings

Commands:
`/tune [off|clear|export|<text>]` — start, stop, clear, or resume tune mode.
`clear` deletes `.pi/tune/session.jsonl`; it leaves `ideas.md`, benchmarks, checks, and hooks intact.

Tools:
- `init_experiment` — configure session (name, metric, unit, direction)
- `run_experiment` — run a timed command, capture output and metrics
- `log_experiment` — record result, keep or discard VCS changes

Settings:
Keyboard shortcuts configurable in `<agent-dir>/extensions/tune.json`.

## Hooks

- `session_start` / `session_tree`: reconstruct state from `.pi/tune/session.jsonl`
- `before_agent_start`: inject tune system prompt when mode active
- `session_before_compact`: produce deterministic compaction summary
- `agent_end`: schedule auto-resume when mode active
- `session_shutdown`: clean up UI and timers

## State

All state lives in `.pi/tune/`.

| File | Purpose |
|---|---|
| `session.jsonl` | Append-only experiment log |
| `session.md` | Living document: objective, what's been tried |
| `ideas.md` | Backlog of untried optimizations |
| `benchmark.mjs` | Benchmark script |
| `checks.mjs` | Optional correctness gate |
| `config.json` | Optional (`maxIterations`) |
| `hooks/before.mjs` | Optional pre-iteration hook |
| `hooks/after.mjs` | Optional post-iteration hook |

## Behavior

Tunes through an autonomous loop: edit → benchmark → log → keep or discard → repeat.

VCS behavior is native per repo: jj repos use `jj describe` / `jj new` / `jj abandon`; non-jj repos use Git. Tune takes an exclusive `.pi/tune/lock.json` repo lock per Pi session. Parallel tune runs in one checkout are rejected; use a separate checkout/workspace for parallel tuning.

Confidence scoring (MAD-based) after 3+ runs: ≥2.0× = real, 1.0–2.0× = marginal, <1.0× = noise.

Backpressure: if `checks.mjs` exists, runs after every passing benchmark. Failures block `keep`.

Hooks: `.mjs` scripts that receive JSON on stdin. Stdout → steer message to agent. Cross-platform.