pi-mono/packages/coding-agent/examples
Petr Houška 8dfd53c835
fix(tui,coding-agent): Shift+Backspace/Delete in Input and /tree, printable keys in p2 and examples (#12740)
Follow-up to #12728 (refs #12727). Covers the gaps left after that fix.

**Shift+Backspace / Shift+Delete in `Input` and `/tree` search**

Problem: with the Kitty keyboard protocol or xterm `modifyOtherKeys`,
Shift+Backspace arrives as `\x1b[127;2u` or `\x1b[27;2;127~`. Before
#12728 `Input` inserted DEL for it; after #12728 it is ignored. The
`Editor` deletes, because it hard-codes `matchesKey(data,
"shift+backspace")` and `"shift+delete"`.

Fix: add `shift+backspace` and `shift+delete` to the
`tui.editor.deleteCharBackward` / `tui.editor.deleteCharForward`
defaults and drop the hard-coded checks in `Editor`. `Input`, `TreeList`
and p2's `SecretInput` already match those keybindings, so they now
delete too, and users can rebind them.

**p2 callers still on `decodeKittyPrintable`**

`apps/p2/src/tui/components/secret-input.ts` (masked API key prompt) and
`apps/p2/src/hosts/tui-trusted-ui.ts` (trusted directory picker filter)
dropped shifted keys under `modifyOtherKeys`. Both now use
`decodePrintableKey`.

**Example extensions**

`overlay-test.ts` and `overlay-qa-tests.ts` accepted only `data.length
=== 1` text, so they dropped every Kitty CSI-u and `modifyOtherKeys`
key. They now use `decodePrintableKey`.

**Testing**
- `packages/tui/test/input.test.ts`, `editor.test.ts`: Shift+Backspace
(both encodings) and Shift+Delete delete
- `packages/coding-agent/test/tree-selector.test.ts`: Shift+Backspace
removes search characters
- `npm run check`, `cd apps/p2 && npm run check`
2026-12-01 21:34:33 +01:00
..
extensions fix(tui,coding-agent): Shift+Backspace/Delete in Input and /tree, printable keys in p2 and examples (#12740) 2026-12-01 21:34:33 +01:00
sdk fix(ai,coding-agent): update tests and defaults for removed catalog models 2026-12-01 10:07:13 +01:00
README.md feat(coding-agent): remove the experimental server stack and the client, protocol, and server packages 2026-10-12 10:41:59 +00:00
rpc-client.ts feat: build with TypeScript 7 and run sources with plain node 2026-09-25 13:14:33 +02:00
rpc-extension-ui.ts fix(mcp,ai,agent,coding-agent,tui): read large streamed lines and events in linear time (#12451) 2026-11-25 00:45:10 +01:00
tsconfig.json feat(p2,chord): per-host stores and Files v2; session files move into the session's store 2026-11-06 06:42:38 +00:00

Examples

Example code for the pi-coding-agent SDK, process integration, and extensions.

CLI integration

rpc-client.ts uses the typed RpcClient to run Pi in a child process, stream events, and wait for the run to settle.

Build the coding-agent package before running it from a repository checkout:

node examples/rpc-client.ts "Explain this repository"

Directories

sdk/

Programmatic usage via createAgentSession(). Shows how to customize models, prompts, tools, extensions, and session management.

extensions/

Example extensions demonstrating:

  • Lifecycle event handlers (tool interception, safety gates, context modifications)
  • Custom tools (todo lists, questions, subagents, output truncation)
  • Commands and keyboard shortcuts
  • Custom UI (footers, headers, editors, overlays)
  • Git integration (checkpoints, auto-commit)
  • System prompt modifications and custom compaction
  • External integrations (SSH, file watchers, system theme sync)
  • Custom providers (Anthropic with custom streaming, GitLab Duo)

Documentation