# Implementation

Use an independent declarative action catalog for the sixteen existing command handlers and the public shortcut paths. Store sparse `commands.<action>` lists, expanded `keybindings` leaves (existing `keybindings.dashboard` paths preserved), and `pauseOrder` (`together`, `goal-first`, `turn-first`) in the existing locked global/project settings layers. Resolve and report provenance per action/leaf. Validate syntax centrally; compare conflicts by overlapping input contexts and normalized key identities. Disabled arrays must remain distinct from inheritance. Mutations retain existing atomic writes and concurrent merge guarantees.

Build command roots from the effective configuration on extension load and dispatch longest complete-word routes to the existing handlers. Preserve the fixed `/goal-settings` recovery route. Use Pi's public registration and argument completion API. Pi has no public command unregister API: apply route changes through an explicit idle reload from the controls screen and display pending status until then. Keep key handling live through the existing terminal input listener and cached settings. No model tools or profiles are added. Existing instructions use configured command spellings; default prompt fixtures stay unchanged and the controls registry never enters model context.

Pi's boundary `continue` flag requests an extra model turn; returning false does not stop the normal tool loop. Goal-first therefore uses the public abort at the finished-turn boundary. Pi displays its normal abort status after the completed tool output; no host internals or transcript messages are patched.

Encapsulate interruption state in the goal core. A turn-only hold belongs to one goal and session, suppresses the abort-to-pause cascade for that interrupted run, clears pending continuation/recovery and prevents scheduling/claiming while held. Ordinary user work or explicit resume clears it. Focus replacement and session teardown clear old interruption state. Existing SDK signal and `agent_settled.aborted` compatibility paths consult the same decision. Goal-first uses the durable paused goal status and stops the host at `turn_end` after the in-flight turn finishes, preventing another provider request; a second key press aborts immediately. A resume before abort settlement must arm its saved continuation once the host settles. A refused resume leaves the hold intact.

Implement a custom bounded Controls component using Pi's theme, Input, key parser and UI custom component API. Separate pure catalog, parsing, conflict/route logic, screen model and render/input logic so behaviour can be tested without a model. Commands, key lists and pause order share scope and inheritance affordances. Capture keys before the global goal handler by using the existing modal-depth guard. Custom goal questionnaires and confirmation dialogs use the same declarative `keybindings.dialog` controls; their context is separate from live goal shortcuts. Settings navigation retains Pi's own controls for recovery. Keep modal cleanup exception-safe.

Validation: focused parser/layering/routing and interruption tests; rendered widths/heights and input state transitions; full type/lint/test checks; actual installed Pi 1.4 CLI walkthrough with isolated settings/provider and captured screens; supported old SDK boundary checks for changed public APIs; focused context/performance checks where relevant. Record iterations, failures and results in MILESTONES.md.

## Review implementation

Initialize pause choices from the selected scope's current value; format comma-containing key lists losslessly. Size the controls body after reserving space for provenance, help and navigation, and implement Page Up/Down and Home/End for long lists. Clear obsolete navigation errors and use recovery-only wording for settings without aliases. Cover all catalog entries and every editor operation with stateful input tests, plus expanded actual-CLI walkthroughs.

Use configured confirmation, cancellation and paging hints in questionnaires. In the answer editor, ignore printable dialog shortcuts and shortcuts reserved by Pi's editor; retain the existing Tab navigation and native Escape, plus free custom function/modifier keys. Test letter-based controls with character-by-character answer entry.

Keep three CI jobs: validation and two compatibility groups, with at most two isolated hosts running per group. Reuse the installed SDK when it matches; otherwise install only the host test dependencies in a separate directory. Retain all seven declared versions and both minimum Node checks. Run full tests with the manifest check once; run the full suite, RPC lifecycle and bounded CLI walkthroughs concurrently, collecting per-task logs and propagating every failure. Run benchmarks after those tasks settle. A tested path classifier skips runtime work only for explicitly recognized prose/assets and never prevents a required job from completing. Reuse npm's download cache; keep release verification intact. References: [GitHub workflow conditions](https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax), [setup-node caching](https://github.com/actions/setup-node#caching-global-packages-data).

The direct Node validation runner must preserve npm's local executable PATH. Otherwise the existing RPC recovery tests can skip when they cannot find the installed Pi CLI. Verify this with a local-only executable fixture. The full-suite task rejects skipped tests or a missing summary, so a green exit alone cannot conceal lost coverage.
