my-pi 0.1.65 → 0.1.67

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,890 +1,163 @@
1
1
  # my-pi
2
2
 
3
3
  [![Semgrep](https://github.com/spences10/my-pi/actions/workflows/semgrep.yml/badge.svg)](https://github.com/spences10/my-pi/actions/workflows/semgrep.yml)
4
-
5
4
  [![built with vite+](https://img.shields.io/badge/built%20with-Vite+-646CFF?logo=vite&logoColor=white)](https://viteplus.dev)
6
- [![tested with vitest](https://img.shields.io/badge/tested%20with-Vitest-6E9F18?logo=vitest&logoColor=white)](https://vitest.dev)
5
+ [![tested with vitest](https://img.shields.io/badge/tested%20with-Vitest-6E9F18?logo=vitest)](https://vitest.dev)
7
6
 
8
- Composable [pi](https://pi.dev) coding agent for humans and agents.
7
+ My curated [Pi](https://pi.dev) distribution: a ready-to-run
8
+ coding-agent CLI with MCP, LSP, skills, recall, redaction, telemetry,
9
+ team mode, prompt presets, and other handy extensions prewired.
9
10
 
10
11
  ![my-pi package preview](./assets/pi-package-preview.png)
11
12
 
12
13
  Built on the
13
14
  [@earendil-works/pi-coding-agent](https://github.com/badlogic/pi-mono)
14
- SDK. Adds MCP server support, a managed extension registry, composable
15
- user extensions, LSP tools, prompt presets, local SQLite telemetry for
16
- evals, and a programmatic API.
17
-
18
- ## What this is for
19
-
20
- `my-pi` is a composable Pi-based coding-agent harness for local agent
21
- work, eval runs, and agent-ops experiments. The default CLI combines
22
- MCP, LSP, skills, prompt presets, secret-safe tooling, local
23
- telemetry, session recall, and optional team-mode orchestration.
24
-
25
- The main design goal is repeatability: run an agent task, capture
26
- structured telemetry, preserve session context, and reuse the same
27
- configuration in interactive, print, JSON, RPC, or SDK-driven flows.
28
-
29
- ## Not a Pi package
15
+ SDK. Use the full distribution directly, or install individual
16
+ `@spences10/pi-*` packages into your own Pi setup.
30
17
 
31
- Do not install this with `pi install npm:my-pi`.
32
-
33
- `my-pi` is an opinionated Pi distribution/CLI. Install the individual
34
- `@spences10/pi-*` packages as Pi packages instead, or run `my-pi`
35
- directly as its own CLI.
36
-
37
- ## Features
38
-
39
- - **Pi-native CLI + SDK wrapper** — interactive TUI, print mode, JSON
40
- mode, and programmatic runtime creation.
41
- - **MCP integration** — stdio and HTTP/streamable-HTTP servers from
42
- `mcp.json`, auto-registered as Pi tools.
43
- - **Built-in LSP tools** — diagnostics, hover, definitions,
44
- references, and document symbols via language servers.
45
- - **Managed skills** — discover, enable, disable, import, and sync
46
- Pi-native skills.
47
- - **Guardrails** — default-enabled Svelte and coding-preference checks
48
- that block configured anti-patterns before agents write them.
49
- - **Prompt presets** — base presets plus additive prompt layers with
50
- per-project persistence.
51
- - **Secret redaction** — redact API keys and other sensitive output
52
- before the model sees tool results.
53
- - **Context sidecar** — SQLite FTS storage for oversized tool output,
54
- with scoped retrieval commands.
55
- - **Recall** — teach the model to use `pirecall` for prior-session
56
- context.
57
- - **Git UI** — interactive source-control staging in the TUI.
58
- - **Local telemetry** — optional SQLite telemetry for evals, tool
59
- analysis, and operational debugging.
60
- - **Built-in registry + composable user extensions** — ship defaults,
61
- manage built-ins with `/extensions`, and layer extra project or
62
- ad-hoc extensions on top.
63
-
64
- ## Requirements
65
-
66
- - **Node.js `>=24.15.0` minimum.** my-pi uses native `node:sqlite`
67
- through the context sidecar and telemetry packages, and uses Node's
68
- built-in TypeScript type stripping for small local scripts.
69
- - **Node 24 is used in CI.** `node:sqlite` is a release-candidate Node
70
- API line, so CI runs the current Node 24 line while the code keeps
71
- SQLite usage small and synchronous.
72
- - **SQLite warning policy:** the `my-pi` CLI suppresses Node's
73
- expected `node:sqlite` `ExperimentalWarning` before built-ins load.
74
- Standalone package/API consumers own their process warning policy
75
- until Node marks `node:sqlite` stable.
76
- - **pnpm 11** is used for local development. End users can run with
77
- `pnpx`, `npx`, or `bunx`.
78
-
79
- ## Get Started
18
+ ## Quick start
80
19
 
81
20
  ```bash
82
21
  pnpx my-pi@latest
83
22
  # or: npx my-pi@latest / bunx my-pi@latest
84
23
  ```
85
24
 
86
- With pnpm's build-script approval gate, use explicit build allowances
87
- if you want a warning-free `pnpx` install:
88
-
89
- ```bash
90
- pnpm dlx --allow-build=@google/genai --allow-build=koffi --allow-build=protobufjs my-pi@latest
91
- ```
92
-
93
- ### API Keys
25
+ ## Two ways to use my-pi
94
26
 
95
- Pi handles authentication natively via `AuthStorage`. Options (in
96
- priority order):
27
+ ### 1. Run the full distribution
97
28
 
98
- 1. **`pi auth`** interactive login, stores credentials in
99
- `~/.pi/agent/auth.json`
100
- 2. **Environment variables** — `ANTHROPIC_API_KEY`, `MISTRAL_API_KEY`,
101
- `XIAOMI_API_KEY`, `CLOUDFLARE_API_KEY` + `CLOUDFLARE_ACCOUNT_ID`,
102
- etc.
103
- 3. **OAuth** — supported for providers that offer it
104
-
105
- Xiaomi MiMo Token Plan is available through Pi's built-in `xiaomi`
106
- provider:
107
-
108
- ```bash
109
- XIAOMI_API_KEY=... pnpx my-pi@latest -m xiaomi/mimo-v2.5-pro "summarize this repo"
110
- ```
111
-
112
- Cloudflare Workers AI model IDs contain slashes. Pass the provider and
113
- model together when needed:
114
-
115
- ```bash
116
- CLOUDFLARE_API_KEY=... CLOUDFLARE_ACCOUNT_ID=... \
117
- pnpx my-pi@latest -m cloudflare-workers-ai/@cf/meta/llama-3.3-70b-instruct-fp8-fast "summarize this repo"
118
- ```
119
-
120
- ## Usage
121
-
122
- ### Interactive mode (full TUI)
29
+ Use `my-pi` if you want the complete, opinionated setup:
123
30
 
124
31
  ```bash
125
32
  pnpx my-pi@latest
126
33
  ```
127
34
 
128
- Pi's full terminal UI with editor, `/commands`, model switching
129
- (`Ctrl+L`), session tree (`/tree`), and message queuing.
130
-
131
- ### Print mode (one-shot)
35
+ This is its own CLI wrapper around Pi. Do not install the root package
36
+ with `pi install npm:my-pi`.
132
37
 
133
- ```bash
134
- pnpx my-pi@latest "your prompt here"
135
- pnpx my-pi@latest -P "explicit print mode"
136
- # or: npx my-pi@latest ... / bunx my-pi@latest ...
137
- ```
38
+ ### 2. Install individual Pi packages
138
39
 
139
- ### JSON output (for agents)
40
+ Most extensions in this repo are also published as normal Pi packages:
140
41
 
141
42
  ```bash
142
- pnpx my-pi@latest --json "list all TODO comments"
143
- echo "plan a login page" | pnpx my-pi@latest --json
144
- ```
145
-
146
- Outputs NDJSON events — one JSON object per line — for programmatic
147
- consumption by other agents or scripts.
148
-
149
- In non-interactive modes (`"prompt"`, `-P`, `--json`), my-pi keeps
150
- headless-capable built-ins like MCP, LSP, prompt presets, recall,
151
- nopeek, Omnisearch, SQLite tools, hooks, and secret redaction enabled,
152
- while skipping UI-only built-ins like session auto-naming.
153
-
154
- ### RPC and team mode
155
-
156
- ```bash
157
- pnpx my-pi@latest --mode rpc
158
- ```
159
-
160
- RPC mode speaks Pi's JSONL protocol over stdin/stdout. The built-in
161
- team mode extension adds `/team` for local orchestration:
162
-
163
- ```text
164
- /team create demo
165
- /team spawn alice "claim one task and report back"
166
- /team task add alice: inspect the failing test
167
- /team dm alice status?
168
- /team status
169
- ```
170
-
171
- Team state is stored under `~/.pi/agent/teams-local` by default, or
172
- `MY_PI_TEAM_MODE_ROOT` when set.
173
-
174
- ### Local telemetry (SQLite)
175
-
176
- Telemetry is **disabled by default**. When enabled, my-pi records
177
- operational telemetry for each run in a local SQLite database. This is
178
- intended for eval harnesses, latency analysis, tool failure analysis,
179
- and local debugging. Telemetry captures structured operational data;
180
- `pirecall` complements it by retrieving the surrounding session
181
- transcript and prior-work context.
182
-
183
- ```bash
184
- pnpx my-pi@latest --telemetry --json "solve this task"
185
- pnpx my-pi@latest --telemetry --telemetry-db ./tmp/evals.db --json "run case"
186
- ```
187
-
188
- By default the database lives at:
189
-
190
- ```text
191
- ~/.pi/agent/telemetry.db
192
- ```
193
-
194
- You can relocate the whole Pi auth/config/session directory for
195
- sandboxed or CI runs with either:
196
-
197
- ```bash
198
- pnpx my-pi@latest --agent-dir /work/pi-agent --telemetry --json "run case"
199
- ```
200
-
201
- or:
202
-
203
- ```bash
204
- PI_CODING_AGENT_DIR=/work/pi-agent pnpx my-pi@latest --telemetry --json "run case"
205
- ```
206
-
207
- Use the interactive command to inspect or persist the setting:
208
-
209
- ```text
210
- /telemetry status
211
- /telemetry stats
212
- /telemetry query run=<eval-run-id> success=true limit=10
213
- /telemetry export ./tmp/eval-runs.json suite=smoke
214
- /telemetry on
215
- /telemetry off
216
- /telemetry path
217
- ```
218
-
219
- Recommended eval env vars for correlation:
220
-
221
- - `MY_PI_EVAL_RUN_ID`
222
- - `MY_PI_EVAL_CASE_ID`
223
- - `MY_PI_EVAL_ATTEMPT`
224
- - `MY_PI_EVAL_SUITE`
225
-
226
- A typical eval loop is:
227
-
228
- 1. Create a stable eval run/case id.
229
- 2. Run my-pi with `--telemetry`, usually with an isolated
230
- `PI_CODING_AGENT_DIR` and `--untrusted` for reproducibility.
231
- 3. Query or export telemetry for timings, tool calls, provider
232
- requests, and success/failure state.
233
- 4. Use `pirecall` to inspect the transcript context around the same
234
- task when the structured rows are not enough.
235
- 5. Compare attempts by `MY_PI_EVAL_RUN_ID`, `MY_PI_EVAL_CASE_ID`,
236
- `MY_PI_EVAL_ATTEMPT`, and `MY_PI_EVAL_SUITE`.
237
-
238
- Example:
239
-
240
- ```bash
241
- export MY_PI_EVAL_RUN_ID="smoke-$(date +%Y%m%d-%H%M%S)"
242
- export MY_PI_EVAL_CASE_ID="readme-review"
243
- export MY_PI_EVAL_ATTEMPT=1
244
- export MY_PI_EVAL_SUITE="smoke"
245
-
246
- PI_CODING_AGENT_DIR="$PWD/.tmp/pi-agent" \
247
- pnpx my-pi@latest \
248
- --untrusted \
249
- --telemetry \
250
- --telemetry-db "$PWD/.tmp/evals.db" \
251
- --json "review the README and report the top issue"
252
-
253
- pnpx pirecall sync --json
254
- pnpx pirecall recall "readme-review smoke" --json
255
- ```
256
-
257
- For repeatable local cases after `pnpm run build`, use the TypeScript
258
- wrapper script:
259
-
260
- ```bash
261
- pnpm run eval:local -- \
262
- --suite smoke \
263
- --case readme-review \
264
- --prompt "review the README and report the top issue"
265
- ```
266
-
267
- It sets `MY_PI_EVAL_*`, uses an isolated `.tmp/pi-agent`, writes
268
- telemetry to `.tmp/evals.db`, and passes `--untrusted` by default. Add
269
- extra my-pi flags after `--`, for example `-- --model openai:gpt-5`.
270
-
271
- For assertion-backed regression gates, run the committed smoke suite
272
- after `pnpm run build`:
273
-
274
- ```bash
275
- pnpm run eval:suite
276
- pnpm run eval:suite -- --case no-mcp-removes-mcp-tools
277
- pnpm run eval:suite -- --json
278
- ```
279
-
280
- Suites live in `evals/*.json`. Each case declares a command plus
281
- objective assertions for exit code and expected/forbidden stdout,
282
- stderr, or combined output. Cases can declare required environment
283
- variable names; missing values are reported as skips without printing
284
- secret values.
285
-
286
- Recorded tables:
287
-
288
- - `runs`
289
- - `turns`
290
- - `tool_calls`
291
- - `provider_requests`
292
-
293
- A telemetry export is JSON with one object per run and nested
294
- summaries for turns, tool calls, and provider requests, keyed by
295
- run/eval ids so it can be compared with the matching `pirecall`
296
- transcript.
297
-
298
- Query and export helpers:
299
-
300
- - `/telemetry query ...` shows recent run summaries
301
- - `/telemetry export [path] ...` writes matching runs as JSON
302
- - supported filters: `run=` / `eval_run_id=`, `case=` /
303
- `eval_case_id=`, `suite=` / `eval_suite=`,
304
- `success=true|false|null`, `limit=<n>`
305
- - `/telemetry query` defaults to `limit=20`
306
- - `/telemetry export` auto-generates a timestamped JSON file when no
307
- path is provided
308
-
309
- Schema notes:
310
-
311
- - source of truth: `packages/pi-telemetry/src/schema.sql`
312
- - current telemetry schema version: `1`
313
- - schema version is tracked with `PRAGMA user_version`
314
- - unversioned local telemetry databases are initialized/upgraded to v1
315
- on open
316
- - newer unsupported schema versions fail fast instead of silently
317
- downgrading
318
- - opens the database in WAL mode: `PRAGMA journal_mode = WAL`
319
- - waits up to 5s on lock contention: `PRAGMA busy_timeout = 5000`
320
-
321
- CLI flags `--telemetry` and `--no-telemetry` override only the current
322
- process. `/telemetry on` and `/telemetry off` update the saved default
323
- for future sessions.
324
-
325
- ### Sandbox / CI auth and config isolation
326
-
327
- If you run my-pi in containers, CI, or ephemeral sandboxes, changing
328
- `HOME` often hides the usual `~/.pi/agent/auth.json` credentials. Use
329
- a stable agent directory instead of relying on `HOME` alone.
330
-
331
- Recommended options:
332
-
333
- 1. Pass provider API keys directly via environment variables.
334
- 2. Set `--agent-dir /path/to/pi-agent` for the process.
335
- 3. Or set `PI_CODING_AGENT_DIR=/path/to/pi-agent` in the environment.
336
-
337
- The agent directory holds Pi-managed state such as:
338
-
339
- - `auth.json`
340
- - `settings.json`
341
- - `sessions/`
342
- - `telemetry.db`
343
- - `telemetry.json`
344
- - `mcp.json`, MCP backups, and MCP profiles
345
- - project trust stores for MCP, hooks, LSP binaries, and project
346
- resources
347
- - imported Pi-native skills under `skills/`
348
-
349
- Intentional exceptions: my-pi still reads user-local Claude
350
- skill/plugin sources from `~/.claude` when the skills extension is
351
- enabled. Those are upstream sources for discovery/import, not
352
- Pi-managed state. Use `--no-skills` or `--untrusted` for hermetic
353
- sandbox runs.
354
-
355
- During runtime startup my-pi temporarily exposes the effective agent
356
- directory through `PI_CODING_AGENT_DIR` for built-in extension
357
- compatibility. SDK-created runtimes restore values they changed when
358
- `runtime.dispose()` completes.
359
-
360
- A practical sandbox command looks like:
361
-
362
- ```bash
363
- PI_CODING_AGENT_DIR=/work/pi-agent \
364
- ANTHROPIC_API_KEY=... \
365
- pnpx my-pi@latest --untrusted --telemetry --json "run eval case"
366
-
367
- # Cloudflare Workers AI needs both values:
368
- CLOUDFLARE_API_KEY=... CLOUDFLARE_ACCOUNT_ID=... \
369
- pnpx my-pi@latest -m cloudflare-workers-ai/@cf/meta/llama-3.3-70b-instruct-fp8-fast --json "run eval case"
43
+ pi install npm:@spences10/pi-lsp
44
+ pi install npm:@spences10/pi-mcp
45
+ pi install npm:@spences10/pi-redact
370
46
  ```
371
47
 
372
- ### Untrusted repo safe mode
373
-
374
- Use `--untrusted` in unknown repositories, evals, or sandboxes. It
375
- keeps built-ins available but starts with conservative
376
- project-resource defaults:
48
+ Use this path if you already have your own Pi setup and only want
49
+ selected features. Package READMEs are the source of truth for install
50
+ instructions, commands, configuration, and runtime behavior.
377
51
 
378
- - skips project-local MCP config (`MY_PI_MCP_PROJECT_CONFIG=skip`)
379
- - skips Claude-style project hooks (`MY_PI_HOOKS_CONFIG=skip`)
380
- - uses global LSP binaries instead of project-local binaries
381
- (`MY_PI_LSP_PROJECT_BINARY=global`)
382
- - skips project prompt presets (`MY_PI_PROMPT_PRESETS_PROJECT=skip`)
383
- - skips project-local `.pi/skills` and `.claude/skills`
384
- (`MY_PI_PROJECT_SKILLS=skip`)
385
- - clears optional child-process env allowlists unless they were set
386
- explicitly
52
+ ## What you get
387
53
 
388
- Set the listed environment variables to `allow` or `trust` where
389
- supported to re-enable one feature intentionally while staying in safe
390
- mode.
54
+ - **Pi-native CLI + SDK wrapper** interactive TUI, print mode, JSON
55
+ mode, RPC mode, and programmatic runtime creation.
56
+ - **Project-aware MCP tools** — stdio and HTTP/streamable-HTTP servers
57
+ from `mcp.json`, scoped so sensitive or noisy tools only load for
58
+ the projects and orgs where they belong.
59
+ - **Project-aware skills** — discover, enable, disable, import, and
60
+ sync Pi-native skills, with different skill sets per project.
61
+ - **LSP tools** — diagnostics, hover, definitions, references, and
62
+ document symbols via language servers.
63
+ - **Context sidecar** — local SQLite storage for oversized tool
64
+ output, keeping long results searchable without flooding chat
65
+ context.
66
+ - **Guardrails** — Svelte and coding-preference checks that block
67
+ configured anti-patterns before agents write them.
68
+ - **Prompt presets** — base presets plus additive prompt layers with
69
+ per-project persistence.
70
+ - **Secret safety** — redaction plus reminders to use secret-safe
71
+ environment loading.
72
+ - **Recall and telemetry** — local support for prior-session lookup,
73
+ evals, latency analysis, and operational debugging.
74
+ - **Git UI** — interactive source-control staging and commit support.
75
+ - **Team mode** — local RPC teammate orchestration with tasks and
76
+ mailboxes.
77
+ - **Themes and TUI helpers** — visual polish and shared modal
78
+ primitives.
391
79
 
392
- ### Additional extensions
80
+ ## Requirements
393
81
 
394
- ```bash
395
- pnpx my-pi@latest -e ./ext/damage-control.ts -e ./ext/tool-counter.ts
396
- pnpx my-pi@latest --no-builtin -e ./ext/custom.ts "do something"
397
- ```
82
+ - Node.js `>=24.15.0`
83
+ - pnpm 11 for local development
84
+ - Pi authentication via `pi auth`, provider environment variables, or
85
+ supported OAuth flows
398
86
 
399
- Add project or ad-hoc Pi extensions with repeated `-e` / `--extension`
400
- flags. They are composed with the managed built-ins in the same
401
- runtime. Use `--no-builtin` to skip my-pi's managed built-in
402
- extensions and run only Pi defaults plus the extensions you pass
403
- explicitly.
404
-
405
- Built-in extension choices can also be saved interactively with
406
- `/extensions`. Startup flags like `--no-recall`, `--no-skills`, and
407
- `--no-svelte-guardrails` still force-disable those extensions for the
408
- current process only. The built-in registry in
409
- `src/extensions/builtin-registry.ts` is the source of truth for
410
- built-in order, API option names, disable flags, labels, and
411
- runtime-mode constraints. SDK users can disable built-ins with options
412
- such as `create_my_pi({ svelte_guardrails: false })`.
413
-
414
- ### Themes
415
-
416
- `my-pi` bundles `@spences10/pi-themes` and loads that theme pack into
417
- the runtime automatically. Vanilla Pi users can install it separately
418
- with `pi install npm:@spences10/pi-themes`. Pick a theme in
419
- `/settings`, or persist one via Pi settings JSON:
420
-
421
- ```json
422
- {
423
- "theme": "tokyo-night"
424
- }
425
- ```
87
+ `my-pi` uses native `node:sqlite` through context and telemetry
88
+ packages. The CLI suppresses Node's expected `node:sqlite`
89
+ `ExperimentalWarning`; standalone package/API consumers own their
90
+ process warning policy until Node marks it stable.
426
91
 
427
- ### Stdin piping
92
+ ## Common usage
428
93
 
429
94
  ```bash
430
- echo "review this code" | pnpx my-pi@latest
431
- cat plan.md | pnpx my-pi@latest --json
432
- ```
433
-
434
- When stdin is piped, it's read as the prompt and print mode runs
435
- automatically.
436
-
437
- ### Programmatic API
438
-
439
- ```ts
440
- import { create_my_pi, runPrintMode } from 'my-pi';
441
-
442
- const runtime = await create_my_pi({
443
- agent_dir: './tmp/pi-agent',
444
- extensions: ['./my-ext.ts'],
445
- runtime_mode: 'json',
446
- telemetry: true,
447
- telemetry_db_path: './tmp/evals.db',
448
- });
449
- await runPrintMode(runtime, {
450
- mode: 'json',
451
- initialMessage: 'hello',
452
- initialImages: [],
453
- messages: [],
454
- });
455
- ```
456
-
457
- ## MCP Servers
458
-
459
- MCP servers are configured via `mcp.json` files and managed as a pi
460
- extension. Stdio servers are spawned on startup, HTTP servers are
461
- connected remotely, and their tools are registered via
462
- `pi.registerTool()`.
463
-
464
- ### Global config
465
-
466
- `~/.pi/agent/mcp.json` — available to all projects:
467
-
468
- ```json
469
- {
470
- "mcpServers": {
471
- "mcp-sqlite-tools": {
472
- "command": "npx",
473
- "args": ["-y", "mcp-sqlite-tools"]
474
- }
475
- }
476
- }
477
- ```
95
+ # full TUI
96
+ pnpx my-pi@latest
478
97
 
479
- ### Project config
480
-
481
- `./mcp.json` in the project root — overrides global servers by name:
482
-
483
- ```json
484
- {
485
- "mcpServers": {
486
- "my-search": {
487
- "command": "npx",
488
- "args": ["-y", "some-mcp-server"],
489
- "env": {
490
- "API_KEY": "..."
491
- }
492
- }
493
- }
494
- }
495
- ```
98
+ # one-shot print mode
99
+ pnpx my-pi@latest "summarize this repo"
100
+ pnpx my-pi@latest -P "explicit print mode"
496
101
 
497
- HTTP MCP servers are supported too:
498
-
499
- ```json
500
- {
501
- "mcpServers": {
502
- "my-http-mcp": {
503
- "type": "http",
504
- "url": "https://myproject.com/api/mcp",
505
- "headers": {
506
- "Authorization": "Bearer ..."
507
- }
508
- }
509
- }
510
- }
511
- ```
102
+ # NDJSON events for scripts/agents
103
+ pnpx my-pi@latest --json "list all TODO comments"
512
104
 
513
- Use `"type": "http"` or `"type": "streamable-http"` for remote MCP
514
- servers. If `url` is present, my-pi treats the entry as HTTP.
515
-
516
- Global MCP config is loaded automatically. Project-local `mcp.json` is
517
- untrusted by default; interactive sessions prompt before loading it
518
- and headless sessions skip it unless `MY_PI_MCP_PROJECT_CONFIG=allow`
519
- or `MY_PI_MCP_PROJECT_CONFIG=trust` is set. If both configs define the
520
- same server name, the trusted project config wins.
521
-
522
- Use `/mcp` in interactive mode to open the searchable MCP server
523
- modal. Enter/Space toggles servers on or off, updates the active tool
524
- set, and persists the choice as `disabled`/`enabled` in `mcp.json`.
525
- Use `/mcp backup`, `/mcp restore`, and `/mcp profile ...` to back up,
526
- restore, save, and load reusable MCP server sets.
527
-
528
- ### Hooks
529
-
530
- Claude-style hooks are discovered from `.claude/settings.json`,
531
- `.rulesync/hooks.json`, and `.pi/hooks.json`. `PreToolUse` hooks run
532
- before a tool executes and can block by exiting with code `2` or by
533
- printing JSON like `{ "decision": "block", "reason": "..." }`.
534
- `PostToolUse` and `PostToolUseFailure` hooks run after tool execution.
535
- Because hook commands run through `bash -lc`, project hook config is
536
- untrusted by default. Interactive sessions show the hook source files
537
- and commands before allowing execution; headless sessions skip hooks
538
- unless `MY_PI_HOOKS_CONFIG=allow` or `MY_PI_HOOKS_CONFIG=trust` is
539
- set. Trusted hook approvals are remembered per project directory and
540
- hook-config hash.
541
-
542
- Hook commands receive a restricted child-process environment by
543
- default: baseline shell variables plus `CLAUDE_PROJECT_DIR`. Use
544
- `MY_PI_HOOKS_ENV_ALLOWLIST=NAME,OTHER_NAME` or the shared
545
- `MY_PI_CHILD_ENV_ALLOWLIST` to pass selected ambient variables
546
- through.
547
-
548
- ### Commands
549
-
550
- In interactive mode:
551
-
552
- - `/mcp list` — show connected servers and tool counts
553
- - `/mcp enable <server>` — enable a disabled server's tools
554
- - `/mcp disable <server>` — disable a server's tools
555
- - `/extensions` — open the built-in extensions manager
556
- - `/extensions list` — print built-in extensions with saved/effective
557
- state
558
- - `/extensions enable|disable|toggle` — without a key, open the
559
- interactive toggle list
560
- - `/extensions enable <key>` / `/extensions disable <key>` — toggle a
561
- built-in extension
562
- - `/skills` — open the interactive Pi/GitHub skills manager
563
- - `/skills add <owner/repo> <skill[@ref]>` — install a GitHub-hosted
564
- skill through `gh skill` when GitHub CLI support is available
565
- - `/skills update --dry-run|--all` — check or apply GitHub skill
566
- updates through `gh skill update`
567
- - `/skill-importer` — open the external Claude/plugin skill importer
568
- - `/skill-importer list` — show importable external skills and
569
- imported copies with sync status
570
- - `/skill-importer import <key|name>` — copy an external skill into
571
- Pi-native storage
572
- - `/skill-importer sync <key|name>` — sync an imported copy to
573
- upstream
574
- - `/skill-importer delete <key|name>` — delete only an imported copy
575
- with importer metadata
576
- - `/skills refresh` — rescan skill directories
577
- - `/skills defaults <all-enabled|all-disabled>` — set default policy
578
- - `/prompt-preset` — open the prompt preset manager (base presets +
579
- layers); `/preset` is a short alias
580
- - `/prompt-preset help` — show examples and common prompt preset
581
- commands
582
- - `/prompt-preset <name>` — activate a base preset or toggle a layer
583
- - `/prompt-preset base <name>` — activate a base preset directly
584
- - `/prompt-preset enable <layer>` / `/prompt-preset disable <layer>` —
585
- toggle a prompt layer directly
586
- - `/prompt-preset edit <name>` — edit or create a project preset in
587
- `.pi/presets/<name>.md`
588
- - `/prompt-preset edit-global <name>` — edit or create a global preset
589
- in `~/.pi/agent/presets/<name>.md`
590
- - `/prompt-preset export-defaults` — copy built-in presets to editable
591
- global Markdown files
592
- - `/prompt-preset export-defaults project` — copy built-in presets to
593
- editable project Markdown files
594
- - `/prompt-preset delete <name>` — delete a project-local preset
595
- - `/prompt-preset reset <name>` — remove a project-local override and
596
- fall back to user/built-in if available
597
- - `/prompt-preset clear` — clear the active base preset and all layers
598
- - `/lsp status|list|restart` — inspect or restart language server
599
- state
600
- - `/redact-stats` — show how many secrets were redacted this session
601
- - `/context` / `/context list [limit]` — browse recent context sidecar
602
- sources in the current project/session scope
603
- - `/context stats` / `/context-stats` — inspect scoped/global context
604
- sidecar stats and active retention policy
605
- - `/context settings` — configure context sidecar retention, storage,
606
- and capture-threshold presets
607
- - `/context purge [days|expired]` — purge old or expired context
608
- sidecar entries
609
- - `/telemetry status|stats|query|export|on|off|path` — inspect, query,
610
- export, or toggle local SQLite telemetry
611
-
612
- ### How it works
613
-
614
- 1. Pi extension loads `mcp.json` configs (global + project)
615
- 2. Connects to each MCP server using stdio or HTTP transport
616
- 3. Performs the MCP `initialize` handshake
617
- 4. Calls `tools/list` to discover available tools
618
- 5. Registers each tool via `pi.registerTool()` as
619
- `mcp__<server>__<tool>`
620
- 6. `/mcp enable/disable` toggles tools via `pi.setActiveTools()`
621
- 7. Built-in extension state can be managed via `/extensions` and is
622
- persisted in `~/.pi/agent/my-pi-settings.json`
623
- 8. Cleanup on `session_shutdown`
624
-
625
- ## Secret Redaction
626
-
627
- The secret redaction extension automatically redacts secrets (API
628
- keys, tokens, passwords, private keys) from tool output before the LLM
629
- sees them. Detection patterns come from
630
- [nopeek](https://github.com/spences10/nopeek). This is a defensive
631
- last-mile guard, not a substitute for secret hygiene: prefer `nopeek`
632
- for loading credentials and avoid printing secrets in the first place.
633
-
634
- The redactor intentionally errs on the side of caution, which means it
635
- can occasionally hide benign metadata such as URLs or documentation
636
- examples. If that happens in a trusted local context, inspect the file
637
- directly or temporarily run with `--no-filter`; do not disable the
638
- filter when reading unknown logs, `.env` files, or untrusted command
639
- output.
640
-
641
- Use `/redact-stats` to see how many secrets were caught. Disable with
642
- `--no-filter`.
643
-
644
- ## Prompt Presets
645
-
646
- Prompt presets append runtime instructions to the system prompt
647
- through a built-in extension. They are split into:
648
-
649
- - **base presets** — one active at a time
650
- - **prompt layers** — additive checkboxes you can combine
651
-
652
- Built-in base presets:
653
-
654
- - `terse` — short, direct, no fluff
655
- - `standard` — clear and concise with key context
656
- - `detailed` — more explanation when nuance matters
657
-
658
- Built-in layers:
659
-
660
- - `no-purple-prose`
661
- - `bullets`
662
- - `clarify-first`
663
- - `include-risks`
664
-
665
- Preset sources are merged in this order:
666
-
667
- 1. built-in defaults
668
- 2. `~/.pi/agent/presets.json`
669
- 3. `~/.pi/agent/presets/*.md`
670
- 4. `.pi/presets.json`
671
- 5. `.pi/presets/*.md`
672
-
673
- Project presets override global/default presets with the same name.
674
- Strings in JSON are treated as base presets by default. Object entries
675
- may set `kind: "base"` or `kind: "layer"`. Markdown preset files use
676
- the filename as the preset name and optional frontmatter:
677
-
678
- ```markdown
679
- ---
680
- kind: base
681
- description: Short, direct, no fluff
682
- ---
683
-
684
- Be concise and direct.
105
+ # RPC mode for team/agent orchestration
106
+ pnpx my-pi@latest --mode rpc
685
107
  ```
686
108
 
687
- Use `/prompt-preset export-defaults` to copy built-in presets to
688
- `~/.pi/agent/presets/*.md` for editing, or
689
- `/prompt-preset export-defaults project` to write `.pi/presets/*.md`.
690
- `/prompt-preset edit <name>` writes a project Markdown preset;
691
- `/prompt-preset edit-global <name>` writes a global one. `/preset` is
692
- a short alias for `/prompt-preset`.
693
-
694
- CLI layering is supported too:
695
-
696
- - `--preset terse,no-purple-prose,bullets`
697
- - `--system-prompt "You are terse and technical."`
698
- - `--append-system-prompt "Prefer one short paragraph."`
109
+ Pi handles model authentication natively. For provider-specific model
110
+ examples, see the Pi docs and the relevant extension/package README.
699
111
 
700
- Interactive sessions default to `terse` unless a project has a saved
701
- selection. `/preset` selections are restored on later sessions for the
702
- same project via `~/.pi/agent/prompt-preset-state.json`;
703
- `/preset clear` persists no active preset for that project.
704
-
705
- This repo also includes an example `.pi/presets.json` with sample base
706
- presets and layers.
707
-
708
- ## LSP Integration
709
-
710
- The built-in LSP extension adds Pi tools for:
711
-
712
- - diagnostics
713
- - hover
714
- - definitions
715
- - references
716
- - document symbols
717
-
718
- You still need the underlying language server binaries installed.
719
- `my-pi` prefers project-local binaries from `node_modules/.bin` and
720
- otherwise falls back to whatever is on `PATH`.
112
+ ## Reusable Pi packages
721
113
 
722
- For the main TypeScript / JavaScript / Svelte workflow, install:
114
+ Install the full distribution with `pnpx my-pi@latest`, or install
115
+ selected extensions into vanilla Pi:
723
116
 
724
117
  ```bash
725
- pnpm add -D typescript typescript-language-server svelte-language-server
118
+ # Bash/Zsh/Fish
119
+ pi install npm:@spences10/pi-{context,lsp,team-mode}
726
120
  ```
727
121
 
728
- That covers:
729
-
730
- - TypeScript / JavaScript via `typescript-language-server`
731
- - Svelte via `svelteserver`
732
-
733
- `my-pi` can also use other language servers if you already have them
734
- installed and available on `PATH`, including:
735
-
736
- - Python via `python-lsp-server`
737
- - Go via `gopls`
738
- - Rust via `rust-analyzer`
739
- - Ruby via `solargraph`
740
- - Java via `jdtls`
741
- - Lua via `lua-language-server`
122
+ Full package list here:
742
123
 
743
- Use `/lsp status` to inspect active server state and
744
- `/lsp restart all` or `/lsp restart <language>` to clear cached
745
- clients.
124
+ | Package | Purpose |
125
+ | ---------------------------------------------------------------------------------- | ---------------------------------------------------------- |
126
+ | [`@spences10/pi-coding-preferences`](./packages/pi-coding-preferences/README.md) | Configurable coding-workflow guardrails |
127
+ | [`@spences10/pi-confirm-destructive`](./packages/pi-confirm-destructive/README.md) | Destructive action confirmations |
128
+ | [`@spences10/pi-context`](./packages/pi-context/README.md) | Scoped SQLite FTS overflow cache for oversized tool output |
129
+ | [`@spences10/pi-git-ui`](./packages/pi-git-ui/README.md) | Interactive source-control staging UI |
130
+ | [`@spences10/pi-lsp`](./packages/pi-lsp/README.md) | LSP-backed diagnostics and symbol tools |
131
+ | [`@spences10/pi-mcp`](./packages/pi-mcp/README.md) | MCP server integration and `/mcp` |
132
+ | [`@spences10/pi-nopeek`](./packages/pi-nopeek/README.md) | `nopeek` reminder for secret-safe environment loading |
133
+ | [`@spences10/pi-omnisearch`](./packages/pi-omnisearch/README.md) | `mcp-omnisearch` reminder for verified web research |
134
+ | [`@spences10/pi-recall`](./packages/pi-recall/README.md) | `pirecall` reminder and background sync |
135
+ | [`@spences10/pi-redact`](./packages/pi-redact/README.md) | Output redaction and `/redact-stats` |
136
+ | [`@spences10/pi-skills`](./packages/pi-skills/README.md) | Skill management, import, and sync |
137
+ | [`@spences10/pi-sqlite-tools`](./packages/pi-sqlite-tools/README.md) | `mcp-sqlite-tools` reminder for safer SQLite database work |
138
+ | [`@spences10/pi-svelte-guardrails`](./packages/pi-svelte-guardrails/README.md) | Svelte pattern guardrails |
139
+ | [`@spences10/pi-team-mode`](./packages/pi-team-mode/README.md) | Local team mode with RPC teammates, tasks, and mailboxes |
140
+ | [`@spences10/pi-telemetry`](./packages/pi-telemetry/README.md) | Local SQLite telemetry and `/telemetry` |
141
+ | [`@spences10/pi-themes`](./packages/pi-themes/README.md) | Bundled theme pack for Pi |
746
142
 
747
- ## Session Recall
143
+ Shared helper packages such as `@spences10/pi-child-env`,
144
+ `@spences10/pi-project-trust`, `@spences10/pi-settings`, and
145
+ `@spences10/pi-tui-modal` are published as dependencies and are not
146
+ packages to install via `pi install`.
748
147
 
749
- The recall package nudges the model to use `pnpx pirecall` or
750
- `npx pirecall` when the user references prior work or when historical
751
- project context would help. It also triggers `pirecall sync --json` on
752
- session start and shutdown when the local recall database exists.
148
+ ## Project structure
753
149
 
754
- ## Reusable Pi packages
755
-
756
- This repo is a pnpm workspace. The `my-pi` harness depends on reusable
757
- Pi packages via `workspace:*`, and those packages can also be
758
- published and installed into vanilla `pi` independently. Shared helper
759
- packages such as `@spences10/pi-child-env`,
760
- `@spences10/pi-project-trust`, and `@spences10/pi-tui-modal` are
761
- published only as dependencies and are not Pi packages to install via
762
- `pi install`.
763
-
764
- ```bash
765
- pi install npm:@spences10/pi-redact
766
- pi install npm:@spences10/pi-telemetry
767
- pi install npm:@spences10/pi-context
768
- pi install npm:@spences10/pi-mcp
769
- pi install npm:@spences10/pi-lsp
770
- pi install npm:@spences10/pi-git-ui
771
- pi install npm:@spences10/pi-confirm-destructive
772
- pi install npm:@spences10/pi-coding-preferences
773
- pi install npm:@spences10/pi-skills
774
- pi install npm:@spences10/pi-recall
775
- pi install npm:@spences10/pi-nopeek
776
- pi install npm:@spences10/pi-omnisearch
777
- pi install npm:@spences10/pi-sqlite-tools
778
- pi install npm:@spences10/pi-svelte-guardrails
779
- pi install npm:@spences10/pi-team-mode
780
- pi install npm:@spences10/pi-themes
781
- ```
782
-
783
- - [`@spences10/pi-redact`](./packages/pi-redact/README.md) — output
784
- redaction and `/redact-stats`
785
- - [`@spences10/pi-telemetry`](./packages/pi-telemetry/README.md) —
786
- local SQLite telemetry and `/telemetry`
787
- - [`@spences10/pi-context`](./packages/pi-context/README.md) — scoped,
788
- redacted SQLite FTS overflow cache for oversized text output from
789
- read/bash/LSP and direct MCP results
790
- - [`@spences10/pi-mcp`](./packages/pi-mcp/README.md) — MCP server
791
- integration and `/mcp`
792
- - [`@spences10/pi-lsp`](./packages/pi-lsp/README.md) — LSP-backed
793
- diagnostics and symbol tools
794
- - [`@spences10/pi-git-ui`](./packages/pi-git-ui/README.md) —
795
- interactive source-control staging UI
796
- - [`@spences10/pi-confirm-destructive`](./packages/pi-confirm-destructive/README.md)
797
- — destructive action confirmations
798
- - [`@spences10/pi-coding-preferences`](./packages/pi-coding-preferences/README.md)
799
- — configurable coding-workflow guardrails
800
- - [`@spences10/pi-skills`](./packages/pi-skills/README.md) — skill
801
- management, import, and sync
802
- - [`@spences10/pi-recall`](./packages/pi-recall/README.md) — pirecall
803
- reminder and background sync
804
- - [`@spences10/pi-nopeek`](./packages/pi-nopeek/README.md) — nopeek
805
- reminder for secret-safe environment loading
806
- - [`@spences10/pi-omnisearch`](./packages/pi-omnisearch/README.md) —
807
- mcp-omnisearch reminder for verified web research
808
- - [`@spences10/pi-sqlite-tools`](./packages/pi-sqlite-tools/README.md)
809
- — mcp-sqlite-tools reminder for safer SQLite database work
810
- - [`@spences10/pi-svelte-guardrails`](./packages/pi-svelte-guardrails/README.md)
811
- — default-enabled Svelte pattern guardrails that block discouraged
812
- writes like `$effect`; install separately in vanilla Pi with
813
- `pi install npm:@spences10/pi-svelte-guardrails`
814
- - [`@spences10/pi-team-mode`](./packages/pi-team-mode/README.md) —
815
- local orchestrator/team mode with RPC teammates, tasks, and
816
- mailboxes
817
- - [`@spences10/pi-themes`](./packages/pi-themes/README.md) — bundled
818
- theme pack for Pi
819
-
820
- Each package README is the entry point for install instructions,
821
- commands, runtime behavior, and development notes.
822
-
823
- ## Monorepo build model
824
-
825
- Workspace package ordering comes from `workspace:*` dependencies in
826
- each `packages/*/package.json`. Root `build`, `check`, and `test`
827
- first run package `build:self` scripts through pnpm's filtered
828
- workspace graph, so sibling `dist` output is fresh before root packing
829
- or tests. Individual package `build`, `check`, and `test` scripts use
830
- the package name from `$npm_package_name^...` to build transitive
831
- workspace dependencies from metadata, then run their local `*:self`
832
- task. Do not hand-code sibling package names into scripts; add the
833
- dependency to `dependencies` instead.
834
-
835
- ## Project Structure
836
-
837
- ```
150
+ ```text
151
+ apps/
152
+ web/ Landing page for discovering my-pi and its packages
838
153
  src/
839
- index.ts CLI entry point (citty + pi SDK)
840
- api.ts Programmatic API (create_my_pi + re-exports)
841
- settings/ Root settings migration wrapper around @spences10/pi-settings
842
- current.ts Current settings read/write only
843
- schema.ts Canonical settings type, defaults, and normalization
844
- legacy.ts Legacy config discovery only; remove after two minor releases
845
- migrate.ts One-way legacy-to-current migration; remove with legacy.ts
846
- extensions/
847
- builtin-registry.ts Built-in extension metadata, ordering, flags, and loaders
848
- manager/ Built-in extension manager; reads/writes via src/settings
849
- prompt-presets/ Runtime prompt preset selection and editing
850
- session-name/ Session auto-naming
851
- hooks-resolution/ Claude-style hook resolution
154
+ index.ts CLI entry point
155
+ api.ts Programmatic API
156
+ extensions/ Root-only built-ins and distro wiring
852
157
  packages/
853
- pi-redact/ Installable Pi package for output redaction
854
- pi-settings/ Shared canonical ~/.pi/agent/my-pi-settings.json store
855
- pi-telemetry/ Installable Pi package for SQLite telemetry
856
- pi-context/ Installable Pi package for context sidecar
857
- pi-mcp/ Installable Pi package for MCP integration
858
- pi-lsp/ Installable Pi package for LSP tools
859
- pi-git-ui/ Installable Pi package for source-control staging UI
860
- pi-confirm-destructive/ Installable Pi package for destructive action confirmations
861
- pi-coding-preferences/ Installable Pi package for coding workflow guardrails
862
- pi-svelte-guardrails/ Installable Pi package for Svelte pattern guardrails
863
- pi-skills/ Installable Pi package for skill management
864
- pi-recall/ Installable Pi package for pirecall reminders
865
- pi-nopeek/ Installable Pi package for nopeek reminders
866
- pi-omnisearch/ Installable Pi package for mcp-omnisearch reminders
867
- pi-sqlite-tools/ Installable Pi package for mcp-sqlite-tools reminders
868
- pi-team-mode/ Installable Pi package for team orchestration
869
- pi-themes/ Installable Pi theme pack
870
- pi-child-env/ Shared support package, not a Pi package
871
- pi-project-trust/ Shared support package, not a Pi package
872
- pi-tui-modal/ Shared support package, not a Pi package
158
+ pi-*/ Reusable Pi packages and shared support packages
873
159
  .pi/
874
- presets.json Optional project prompt presets (JSON)
875
- presets/*.md Optional project prompt presets (Markdown files)
160
+ presets.json Optional project prompt presets
161
+ presets/*.md Optional project prompt preset files
876
162
  mcp.json Project MCP server config
877
163
  ```
878
-
879
- ## Development
880
-
881
- ```bash
882
- pnpm run dev # Watch mode
883
- pnpm run check # Lint + type check
884
- pnpm run test # Run tests
885
- pnpm run build # Production build
886
- ```
887
-
888
- ## License
889
-
890
- MIT