mu-agent 0.1.0

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.
Files changed (280) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/LICENSE +21 -0
  3. package/README.md +62 -0
  4. package/dist/bundle/chunks/anthropic-messages-MYU5ZMRF.js +6 -0
  5. package/dist/bundle/chunks/anthropic.js +75 -0
  6. package/dist/bundle/chunks/azure-openai-responses-HUSQ3GP2.js +2 -0
  7. package/dist/bundle/chunks/bedrock-converse-stream.js +83 -0
  8. package/dist/bundle/chunks/chunk-4L3WN2XY.js +2 -0
  9. package/dist/bundle/chunks/chunk-6CYCI3EJ.js +12 -0
  10. package/dist/bundle/chunks/chunk-6R7UI4IY.js +2 -0
  11. package/dist/bundle/chunks/chunk-7ZC4UXSL.js +2 -0
  12. package/dist/bundle/chunks/chunk-A3JYRWB6.js +2 -0
  13. package/dist/bundle/chunks/chunk-DRQDKNXA.js +2 -0
  14. package/dist/bundle/chunks/chunk-DTD7JQ7Y.js +42 -0
  15. package/dist/bundle/chunks/chunk-FUXEF6JQ.js +44 -0
  16. package/dist/bundle/chunks/chunk-L2ZPNLYD.js +2 -0
  17. package/dist/bundle/chunks/chunk-NUHFSC37.js +25 -0
  18. package/dist/bundle/chunks/chunk-PGXDEOVV.js +2 -0
  19. package/dist/bundle/chunks/chunk-PJACZCIR.js +2 -0
  20. package/dist/bundle/chunks/chunk-PRRNXB7S.js +2 -0
  21. package/dist/bundle/chunks/chunk-QB4HYZZE.js +1561 -0
  22. package/dist/bundle/chunks/chunk-RCZIEVGO.js +11 -0
  23. package/dist/bundle/chunks/chunk-S7SZN6Z3.js +2 -0
  24. package/dist/bundle/chunks/chunk-TEPMHNKQ.js +2 -0
  25. package/dist/bundle/chunks/chunk-TRDNDS6A.js +4 -0
  26. package/dist/bundle/chunks/chunk-USJZMAIR.js +2 -0
  27. package/dist/bundle/chunks/chunk-WIUZI2CJ.js +11 -0
  28. package/dist/bundle/chunks/chunk-XDUWOHPL.js +6 -0
  29. package/dist/bundle/chunks/chunk-XNGRGP62.js +2 -0
  30. package/dist/bundle/chunks/chunk-Z2DUOAN4.js +2 -0
  31. package/dist/bundle/chunks/github-copilot.js +2 -0
  32. package/dist/bundle/chunks/google-generative-ai-IMS5EK2Y.js +2 -0
  33. package/dist/bundle/chunks/google-vertex-O4YJEQUW.js +2 -0
  34. package/dist/bundle/chunks/https-proxy-agent-2VXB7436.js +13 -0
  35. package/dist/bundle/chunks/image-resize-worker.js +2 -0
  36. package/dist/bundle/chunks/jiti-loader-C3NU2SDH.js +21 -0
  37. package/dist/bundle/chunks/jiti-static-loader-E6ANQD5T.js +2 -0
  38. package/dist/bundle/chunks/kimi-coding.js +2 -0
  39. package/dist/bundle/chunks/lib-HGQMNYVT.js +9 -0
  40. package/dist/bundle/chunks/mistral-conversations-NOSQHBEY.js +5 -0
  41. package/dist/bundle/chunks/multipart-parser-SQ6GDJL7.js +3 -0
  42. package/dist/bundle/chunks/node-O3RIBJRH.js +16 -0
  43. package/dist/bundle/chunks/node-TWVVAGPO.js +2 -0
  44. package/dist/bundle/chunks/openai-codex-responses-QDSOTBBO.js +10 -0
  45. package/dist/bundle/chunks/openai-codex.js +75 -0
  46. package/dist/bundle/chunks/openai-completions-KQPOPEVM.js +7 -0
  47. package/dist/bundle/chunks/openai-responses-HWEUZ6WZ.js +2 -0
  48. package/dist/bundle/chunks/openrouter-images-N4XVVFSD.js +2 -0
  49. package/dist/bundle/chunks/openrouter.js +75 -0
  50. package/dist/bundle/chunks/pi-messages-GFKBWJHZ.js +8 -0
  51. package/dist/bundle/chunks/radius.js +75 -0
  52. package/dist/bundle/chunks/src-UK77SYZE.js +4 -0
  53. package/dist/bundle/chunks/virtual-modules-ROULVYS3.js +2 -0
  54. package/dist/bundle/chunks/xai.js +2 -0
  55. package/dist/bundle/cli.js +3 -0
  56. package/dist/bundle/index.js +2 -0
  57. package/dist/bundle/native/darwin/prebuilds/darwin-arm64/darwin-platform.node +0 -0
  58. package/dist/bundle/native/darwin/prebuilds/darwin-x64/darwin-platform.node +0 -0
  59. package/dist/bundle/native/linux/prebuilds/linux-arm64/linux-platform-x11.node +0 -0
  60. package/dist/bundle/native/linux/prebuilds/linux-x64/linux-platform-x11.node +0 -0
  61. package/dist/bundle/native/win32/prebuilds/win32-arm64/win32-platform.node +0 -0
  62. package/dist/bundle/native/win32/prebuilds/win32-x64/win32-platform.node +0 -0
  63. package/dist/bundle/rpc-entry.js +3 -0
  64. package/dist/core/export-html/template.css +1066 -0
  65. package/dist/core/export-html/template.html +55 -0
  66. package/dist/core/export-html/template.js +1864 -0
  67. package/dist/core/export-html/vendor/highlight.min.js +1213 -0
  68. package/dist/core/export-html/vendor/marked.min.js +78 -0
  69. package/dist/modes/interactive/assets/clankolas.png +0 -0
  70. package/dist/modes/interactive/theme/dark.json +91 -0
  71. package/dist/modes/interactive/theme/light.json +90 -0
  72. package/dist/modes/interactive/theme/theme-controller.d.ts +41 -0
  73. package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -0
  74. package/dist/modes/interactive/theme/theme-controller.js +130 -0
  75. package/dist/modes/interactive/theme/theme-controller.js.map +1 -0
  76. package/dist/modes/interactive/theme/theme-json.d.ts +84 -0
  77. package/dist/modes/interactive/theme/theme-json.d.ts.map +1 -0
  78. package/dist/modes/interactive/theme/theme-json.js +130 -0
  79. package/dist/modes/interactive/theme/theme-json.js.map +1 -0
  80. package/dist/modes/interactive/theme/theme-schema.json +356 -0
  81. package/dist/modes/interactive/theme/theme.d.ts +131 -0
  82. package/dist/modes/interactive/theme/theme.d.ts.map +1 -0
  83. package/dist/modes/interactive/theme/theme.js +991 -0
  84. package/dist/modes/interactive/theme/theme.js.map +1 -0
  85. package/dist/native/darwin/prebuilds/darwin-arm64/darwin-platform.node +0 -0
  86. package/dist/native/darwin/prebuilds/darwin-x64/darwin-platform.node +0 -0
  87. package/dist/native/linux/prebuilds/linux-arm64/linux-platform-x11.node +0 -0
  88. package/dist/native/linux/prebuilds/linux-x64/linux-platform-x11.node +0 -0
  89. package/dist/native/win32/prebuilds/win32-arm64/win32-platform.node +0 -0
  90. package/dist/native/win32/prebuilds/win32-x64/win32-platform.node +0 -0
  91. package/docs/compaction.md +444 -0
  92. package/docs/containerization.md +156 -0
  93. package/docs/custom-provider.md +786 -0
  94. package/docs/development.md +90 -0
  95. package/docs/docs.json +160 -0
  96. package/docs/environment-variables.md +100 -0
  97. package/docs/extensions.md +3037 -0
  98. package/docs/images/doom-extension.png +0 -0
  99. package/docs/images/exy.png +0 -0
  100. package/docs/images/interactive-mode.png +0 -0
  101. package/docs/images/tree-view.png +0 -0
  102. package/docs/index.md +84 -0
  103. package/docs/json.md +98 -0
  104. package/docs/keybindings.md +239 -0
  105. package/docs/llama-cpp.md +101 -0
  106. package/docs/models.md +605 -0
  107. package/docs/packages.md +228 -0
  108. package/docs/prompt-templates.md +96 -0
  109. package/docs/providers.md +317 -0
  110. package/docs/quickstart.md +167 -0
  111. package/docs/rpc.md +1618 -0
  112. package/docs/sdk.md +1226 -0
  113. package/docs/security.md +59 -0
  114. package/docs/session-format.md +480 -0
  115. package/docs/sessions.md +172 -0
  116. package/docs/settings.md +428 -0
  117. package/docs/shell-aliases.md +13 -0
  118. package/docs/skills.md +232 -0
  119. package/docs/terminal-setup.md +192 -0
  120. package/docs/termux.md +126 -0
  121. package/docs/themes.md +322 -0
  122. package/docs/tmux.md +63 -0
  123. package/docs/tui.md +961 -0
  124. package/docs/usage.md +312 -0
  125. package/docs/windows.md +39 -0
  126. package/examples/README.md +28 -0
  127. package/examples/extensions/README.md +212 -0
  128. package/examples/extensions/auto-commit-on-exit.ts +49 -0
  129. package/examples/extensions/bash-spawn-hook.ts +30 -0
  130. package/examples/extensions/bookmark.ts +50 -0
  131. package/examples/extensions/border-status-editor.ts +150 -0
  132. package/examples/extensions/built-in-tool-renderer.ts +249 -0
  133. package/examples/extensions/claude-rules.ts +86 -0
  134. package/examples/extensions/commands.ts +72 -0
  135. package/examples/extensions/confirm-destructive.ts +59 -0
  136. package/examples/extensions/custom-compaction.ts +117 -0
  137. package/examples/extensions/custom-footer.ts +64 -0
  138. package/examples/extensions/custom-header.ts +73 -0
  139. package/examples/extensions/custom-provider-anthropic/index.ts +617 -0
  140. package/examples/extensions/custom-provider-anthropic/package-lock.json +24 -0
  141. package/examples/extensions/custom-provider-anthropic/package.json +19 -0
  142. package/examples/extensions/custom-provider-gitlab-duo/index.ts +405 -0
  143. package/examples/extensions/custom-provider-gitlab-duo/package.json +16 -0
  144. package/examples/extensions/custom-provider-gitlab-duo/test.ts +82 -0
  145. package/examples/extensions/dirty-repo-guard.ts +56 -0
  146. package/examples/extensions/doom-overlay/README.md +46 -0
  147. package/examples/extensions/doom-overlay/doom/build/doom.js +21 -0
  148. package/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
  149. package/examples/extensions/doom-overlay/doom/build.sh +152 -0
  150. package/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +72 -0
  151. package/examples/extensions/doom-overlay/doom-component.ts +132 -0
  152. package/examples/extensions/doom-overlay/doom-engine.ts +173 -0
  153. package/examples/extensions/doom-overlay/doom-keys.ts +104 -0
  154. package/examples/extensions/doom-overlay/index.ts +74 -0
  155. package/examples/extensions/doom-overlay/wad-finder.ts +55 -0
  156. package/examples/extensions/dynamic-resources/SKILL.md +8 -0
  157. package/examples/extensions/dynamic-resources/dynamic.json +81 -0
  158. package/examples/extensions/dynamic-resources/dynamic.md +5 -0
  159. package/examples/extensions/dynamic-resources/index.ts +15 -0
  160. package/examples/extensions/dynamic-tools.ts +74 -0
  161. package/examples/extensions/entry-renderer.ts +41 -0
  162. package/examples/extensions/event-bus.ts +43 -0
  163. package/examples/extensions/file-trigger.ts +41 -0
  164. package/examples/extensions/git-checkpoint.ts +53 -0
  165. package/examples/extensions/git-merge-and-resolve.ts +115 -0
  166. package/examples/extensions/github-issue-autocomplete.ts +185 -0
  167. package/examples/extensions/gondolin/index.ts +531 -0
  168. package/examples/extensions/gondolin/package-lock.json +185 -0
  169. package/examples/extensions/gondolin/package.json +19 -0
  170. package/examples/extensions/handoff.ts +190 -0
  171. package/examples/extensions/hello.ts +26 -0
  172. package/examples/extensions/hidden-thinking-label.ts +53 -0
  173. package/examples/extensions/inline-bash.ts +94 -0
  174. package/examples/extensions/input-transform-streaming.ts +39 -0
  175. package/examples/extensions/input-transform.ts +43 -0
  176. package/examples/extensions/interactive-shell.ts +196 -0
  177. package/examples/extensions/mac-system-theme.ts +47 -0
  178. package/examples/extensions/message-renderer.ts +59 -0
  179. package/examples/extensions/minimal-mode.ts +426 -0
  180. package/examples/extensions/modal-editor.ts +85 -0
  181. package/examples/extensions/model-status.ts +31 -0
  182. package/examples/extensions/notify.ts +57 -0
  183. package/examples/extensions/overlay-qa-tests.ts +1450 -0
  184. package/examples/extensions/overlay-test.ts +153 -0
  185. package/examples/extensions/permission-gate.ts +34 -0
  186. package/examples/extensions/pirate.ts +47 -0
  187. package/examples/extensions/plan-mode/README.md +66 -0
  188. package/examples/extensions/plan-mode/index.ts +390 -0
  189. package/examples/extensions/plan-mode/utils.ts +168 -0
  190. package/examples/extensions/preset.ts +436 -0
  191. package/examples/extensions/project-trust.ts +64 -0
  192. package/examples/extensions/prompt-customizer.ts +49 -0
  193. package/examples/extensions/protected-paths.ts +30 -0
  194. package/examples/extensions/provider-payload.ts +18 -0
  195. package/examples/extensions/qna.ts +118 -0
  196. package/examples/extensions/question.ts +286 -0
  197. package/examples/extensions/questionnaire.ts +448 -0
  198. package/examples/extensions/rainbow-editor.ts +88 -0
  199. package/examples/extensions/reload-runtime.ts +37 -0
  200. package/examples/extensions/rpc-demo.ts +118 -0
  201. package/examples/extensions/sandbox/index.ts +321 -0
  202. package/examples/extensions/sandbox/package-lock.json +92 -0
  203. package/examples/extensions/sandbox/package.json +19 -0
  204. package/examples/extensions/send-user-message.ts +97 -0
  205. package/examples/extensions/session-name.ts +27 -0
  206. package/examples/extensions/shutdown-command.ts +63 -0
  207. package/examples/extensions/snake.ts +343 -0
  208. package/examples/extensions/space-invaders.ts +560 -0
  209. package/examples/extensions/ssh.ts +220 -0
  210. package/examples/extensions/status-line.ts +32 -0
  211. package/examples/extensions/structured-output.ts +65 -0
  212. package/examples/extensions/subagent/README.md +177 -0
  213. package/examples/extensions/subagent/agents/planner.md +37 -0
  214. package/examples/extensions/subagent/agents/reviewer.md +35 -0
  215. package/examples/extensions/subagent/agents/scout.md +50 -0
  216. package/examples/extensions/subagent/agents/worker.md +24 -0
  217. package/examples/extensions/subagent/agents.ts +157 -0
  218. package/examples/extensions/subagent/index.ts +1038 -0
  219. package/examples/extensions/subagent/prompts/implement-and-review.md +10 -0
  220. package/examples/extensions/subagent/prompts/implement.md +10 -0
  221. package/examples/extensions/subagent/prompts/scout-and-plan.md +9 -0
  222. package/examples/extensions/summarize.ts +199 -0
  223. package/examples/extensions/system-prompt-header.ts +17 -0
  224. package/examples/extensions/tic-tac-toe.ts +1008 -0
  225. package/examples/extensions/timed-confirm.ts +70 -0
  226. package/examples/extensions/titlebar-spinner.ts +58 -0
  227. package/examples/extensions/todo.ts +297 -0
  228. package/examples/extensions/tool-override.ts +144 -0
  229. package/examples/extensions/tools.ts +146 -0
  230. package/examples/extensions/trigger-compact.ts +50 -0
  231. package/examples/extensions/truncated-tool.ts +195 -0
  232. package/examples/extensions/widget-placement.ts +9 -0
  233. package/examples/extensions/with-deps/index.ts +32 -0
  234. package/examples/extensions/with-deps/package-lock.json +31 -0
  235. package/examples/extensions/with-deps/package.json +22 -0
  236. package/examples/extensions/working-indicator.ts +123 -0
  237. package/examples/extensions/working-message-test.ts +25 -0
  238. package/examples/plugins/pi-example-plugin/README.md +38 -0
  239. package/examples/plugins/pi-example-plugin/package.json +10 -0
  240. package/examples/plugins/pi-example-plugin/src/contract.ts +13 -0
  241. package/examples/plugins/pi-example-plugin/src/session.ts +23 -0
  242. package/examples/plugins/pi-example-plugin/src/tui.ts +31 -0
  243. package/examples/rpc-extension-ui.ts +641 -0
  244. package/examples/sdk/01-minimal.ts +26 -0
  245. package/examples/sdk/02-custom-model.ts +49 -0
  246. package/examples/sdk/03-custom-prompt.ts +75 -0
  247. package/examples/sdk/04-skills.ts +55 -0
  248. package/examples/sdk/05-tools.ts +48 -0
  249. package/examples/sdk/06-extensions.ts +99 -0
  250. package/examples/sdk/07-context-files.ts +47 -0
  251. package/examples/sdk/08-prompt-templates.ts +51 -0
  252. package/examples/sdk/09-api-keys-and-oauth.ts +34 -0
  253. package/examples/sdk/10-settings.ts +53 -0
  254. package/examples/sdk/11-sessions.ts +52 -0
  255. package/examples/sdk/12-full-control.ts +74 -0
  256. package/examples/sdk/13-session-runtime.ts +67 -0
  257. package/examples/sdk/README.md +140 -0
  258. package/judge/THIRD_PARTY_NOTICES.md +35 -0
  259. package/judge/agents/browser.md +17 -0
  260. package/judge/agents/investigator.md +16 -0
  261. package/judge/agents/planner.md +15 -0
  262. package/judge/agents/reviewer.md +17 -0
  263. package/judge/agents/scout.md +19 -0
  264. package/judge/agents/worker.md +15 -0
  265. package/judge/dist/chrome.js +326 -0
  266. package/judge/dist/kyrn-judge.js +52542 -0
  267. package/judge/package.json +6 -0
  268. package/judge/prompts/implement-and-review.md +14 -0
  269. package/judge/prompts/implement.md +15 -0
  270. package/judge/prompts/init.md +18 -0
  271. package/judge/prompts/scout-and-plan.md +12 -0
  272. package/judge/skills/mu-browser/SKILL.md +30 -0
  273. package/judge/skills/mu-github/SKILL.md +90 -0
  274. package/kyrn/bin/kyrn-doctor +202 -0
  275. package/kyrn/bin/kyrn-judge-local +131 -0
  276. package/kyrn/bin/kyrn-ledger +90 -0
  277. package/kyrn/bin/mu.mjs +1120 -0
  278. package/kyrn/local-judge/requirements.lock.txt +26 -0
  279. package/kyrn/local-judge/server.py +332 -0
  280. package/package.json +45 -0
@@ -0,0 +1,90 @@
1
+ # Development
2
+
3
+ See [AGENTS.md](https://github.com/earendil-works/pi/blob/main/AGENTS.md) for additional guidelines.
4
+
5
+ ## Setup
6
+
7
+ ```bash
8
+ git clone https://github.com/earendil-works/pi
9
+ cd pi
10
+ npm install
11
+ npm run build
12
+ ```
13
+
14
+ Run from source:
15
+
16
+ ```bash
17
+ /path/to/pi/pi-test.sh
18
+ ```
19
+
20
+ The script can be run from any directory. Pi keeps the caller's current working directory.
21
+
22
+ ### Experimental remote harness
23
+
24
+ The remote harness server/client integration is development-only. Run it from the repository with:
25
+
26
+ ```bash
27
+ PI_EXPERIMENTAL=1 ./pi-test.sh server
28
+ PI_EXPERIMENTAL=1 ./pi-test.sh client
29
+ ```
30
+
31
+ `PI_SERVER_DIR` overrides the server profile and socket directory (default: `~/.pi/server`). `PI_SERVER_ID` selects the logical server ID when `--server-id` is omitted.
32
+
33
+ The `client` and `experimental/plugin` package subpaths resolve only under the `source` condition in a checkout. Their implementations and the server/client commands are excluded from npm packages and standalone binaries. `pi-client`, `pi-protocol`, and `pi-server` are development dependencies of coding-agent, not runtime dependencies. The local SDK and stdio RPC API are unchanged.
34
+
35
+ ## Forking / Rebranding
36
+
37
+ Configure via `package.json`:
38
+
39
+ ```json
40
+ {
41
+ "piConfig": {
42
+ "name": "pi",
43
+ "configDir": ".pi"
44
+ }
45
+ }
46
+ ```
47
+
48
+ Change `name`, `configDir`, and `bin` field for your fork. Affects CLI banner, config paths, and environment variable names.
49
+
50
+ ## Path Resolution
51
+
52
+ Three execution modes: npm install, standalone binary, tsx from source.
53
+
54
+ **Always use `src/config.ts`** for package assets:
55
+
56
+ ```typescript
57
+ import { getPackageDir, getThemeDir } from "./config.js";
58
+ ```
59
+
60
+ Never use `__dirname` directly for package assets.
61
+
62
+ ## Debug Command
63
+
64
+ `/debug` (hidden) writes to `~/.pi/agent/pi-debug.log`:
65
+ - Rendered TUI lines with ANSI codes
66
+ - Last messages sent to the LLM
67
+
68
+ ## Testing
69
+
70
+ ```bash
71
+ ./test.sh # Run non-LLM tests (no API keys needed)
72
+ npm test # Run all tests
73
+ npm test -- test/specific.test.ts # Run specific test
74
+ ```
75
+
76
+ ### Published package smoke test
77
+
78
+ After building, run `npm run check:package-install`. It packs the public packages and installs only coding-agent as a direct dependency in a temporary directory outside the repository. Local tarball overrides select declared transitive dependencies without installing development-only packages. The check verifies SDK imports and CLI startup without credentials or model requests.
79
+
80
+ `npm run check` also checks runtime dependency declarations and rejects excluded development sources pulled into a package's build through imports.
81
+
82
+ ## Project Structure
83
+
84
+ ```
85
+ packages/
86
+ ai/ # LLM provider abstraction
87
+ agent/ # Agent loop and message types
88
+ tui/ # Terminal UI components
89
+ coding-agent/ # CLI and interactive mode
90
+ ```
package/docs/docs.json ADDED
@@ -0,0 +1,160 @@
1
+ {
2
+ "navigation": [
3
+ {
4
+ "title": "Start here",
5
+ "items": [
6
+ {
7
+ "title": "Overview",
8
+ "path": "index.md"
9
+ },
10
+ {
11
+ "title": "Quickstart",
12
+ "path": "quickstart.md"
13
+ },
14
+ {
15
+ "title": "Using Pi",
16
+ "path": "usage.md"
17
+ },
18
+ {
19
+ "title": "Providers",
20
+ "path": "providers.md"
21
+ },
22
+ {
23
+ "title": "Security",
24
+ "path": "security.md"
25
+ },
26
+ {
27
+ "title": "Containerization",
28
+ "path": "containerization.md"
29
+ },
30
+ {
31
+ "title": "Settings",
32
+ "path": "settings.md"
33
+ },
34
+ {
35
+ "title": "Keybindings",
36
+ "path": "keybindings.md"
37
+ },
38
+ {
39
+ "title": "Sessions",
40
+ "path": "sessions.md"
41
+ },
42
+ {
43
+ "title": "Compaction",
44
+ "path": "compaction.md"
45
+ }
46
+ ]
47
+ },
48
+ {
49
+ "title": "Customization",
50
+ "items": [
51
+ {
52
+ "title": "Extensions",
53
+ "path": "extensions.md"
54
+ },
55
+ {
56
+ "title": "Skills",
57
+ "path": "skills.md"
58
+ },
59
+ {
60
+ "title": "Prompt Templates",
61
+ "path": "prompt-templates.md"
62
+ },
63
+ {
64
+ "title": "Themes",
65
+ "path": "themes.md"
66
+ },
67
+ {
68
+ "title": "Pi Packages",
69
+ "path": "packages.md"
70
+ },
71
+ {
72
+ "title": "Custom Models",
73
+ "path": "models.md"
74
+ },
75
+ {
76
+ "title": "Custom Providers",
77
+ "path": "custom-provider.md"
78
+ }
79
+ ]
80
+ },
81
+ {
82
+ "title": "Reference",
83
+ "items": [
84
+ {
85
+ "title": "Environment Variables",
86
+ "path": "environment-variables.md"
87
+ },
88
+ {
89
+ "title": "Session Format",
90
+ "path": "session-format.md"
91
+ }
92
+ ]
93
+ },
94
+ {
95
+ "title": "Programmatic Usage",
96
+ "items": [
97
+ {
98
+ "title": "SDK",
99
+ "path": "sdk.md"
100
+ },
101
+ {
102
+ "title": "RPC Mode",
103
+ "path": "rpc.md"
104
+ },
105
+ {
106
+ "title": "JSON Event Stream Mode",
107
+ "path": "json.md"
108
+ },
109
+ {
110
+ "title": "TUI Components",
111
+ "path": "tui.md"
112
+ }
113
+ ]
114
+ },
115
+ {
116
+ "title": "Platform Setup",
117
+ "items": [
118
+ {
119
+ "title": "Windows",
120
+ "path": "windows.md"
121
+ },
122
+ {
123
+ "title": "Termux on Android",
124
+ "path": "termux.md"
125
+ },
126
+ {
127
+ "title": "tmux",
128
+ "path": "tmux.md"
129
+ },
130
+ {
131
+ "title": "Terminal Setup",
132
+ "path": "terminal-setup.md"
133
+ },
134
+ {
135
+ "title": "Shell Aliases",
136
+ "path": "shell-aliases.md"
137
+ }
138
+ ]
139
+ },
140
+ {
141
+ "title": "Development",
142
+ "items": [
143
+ {
144
+ "title": "Development",
145
+ "path": "development.md"
146
+ }
147
+ ]
148
+ }
149
+ ],
150
+ "redirects": [
151
+ {
152
+ "from": "session.md",
153
+ "to": "session-format.md"
154
+ },
155
+ {
156
+ "from": "tree.md",
157
+ "to": "sessions.md"
158
+ }
159
+ ]
160
+ }
@@ -0,0 +1,100 @@
1
+ # Environment Variables
2
+
3
+ Pi uses environment variables in three ways:
4
+
5
+ - Variables such as `PI_OFFLINE` configure the Pi process.
6
+ - Pi sets process markers so child processes can identify Pi as the launching agent.
7
+ - Commands run by the LLM-callable shell tools receive `PI_*` variables describing the current session.
8
+
9
+ Provider API-key variables are documented separately in [Providers](providers.md#environment-variables-or-auth-file).
10
+
11
+ ## Process Marker
12
+
13
+ The CLI and RPC entry points set two process markers:
14
+
15
+ - `AI_AGENT=pi` is a generic marker that lets tooling identify Pi as the agent that launched the process.
16
+ - `PI_CODING_AGENT=true` is Pi-specific and lets child processes detect that they run inside Pi.
17
+
18
+ Child processes inherit both markers. They are not session-specific and are not set automatically when Pi is embedded through the SDK.
19
+
20
+ ## Shell Tool Session Environment
21
+
22
+ Commands run by the `bash` and `powershell` tools receive the current Pi session state:
23
+
24
+ | Variable | Description |
25
+ |----------|-------------|
26
+ | `PI_SESSION_ID` | Current session ID |
27
+ | `PI_SESSION_FILE` | Absolute path to the current session JSONL file; unset for ephemeral sessions |
28
+ | `PI_PROVIDER` | Currently selected model provider |
29
+ | `PI_MODEL` | Currently selected model ID |
30
+ | `PI_REASONING_LEVEL` | Current effective reasoning level: `off`, `minimal`, `low`, `medium`, `high`, `xhigh`, or `max` |
31
+
32
+ The values are resolved when each command starts. Switching models or changing the reasoning level therefore affects the next shell command without restarting Pi. `PI_PROVIDER` and `PI_MODEL` identify the selected Pi model, not a different upstream model that a router may choose internally.
33
+
34
+ When asked which model or provider is running, inspect these variables instead of inferring the answer from the system prompt:
35
+
36
+ ```bash
37
+ printf '%s/%s\n' "$PI_PROVIDER" "$PI_MODEL"
38
+ printf 'reasoning=%s session=%s\n' "$PI_REASONING_LEVEL" "$PI_SESSION_ID"
39
+ ```
40
+
41
+ The session file can be inspected directly when the session is persistent:
42
+
43
+ ```bash
44
+ if [ -n "$PI_SESSION_FILE" ]; then
45
+ tail -n 1 "$PI_SESSION_FILE"
46
+ fi
47
+ ```
48
+
49
+ These variables are injected into the LLM-callable `bash` and `powershell` tools. They are not injected into user-entered `!` or `!!` commands.
50
+
51
+ ### Custom Shell Tools
52
+
53
+ Tools created with `createBashTool()` or `createPowerShellTool()` expose the session environment by default when registered with Pi. Injection happens before `spawnHook`, so a hook receives the variables in `ctx.env`:
54
+
55
+ ```typescript
56
+ const bashTool = createBashTool(cwd, {
57
+ spawnHook: (ctx) => ({
58
+ ...ctx,
59
+ env: { ...ctx.env, CI: "1" },
60
+ }),
61
+ });
62
+ ```
63
+
64
+ Disable session metadata independently of the spawn hook:
65
+
66
+ ```typescript
67
+ const powershellTool = createPowerShellTool(cwd, {
68
+ exposeSessionEnvironment: false,
69
+ spawnHook: (ctx) => ctx,
70
+ });
71
+ ```
72
+
73
+ When disabled, Pi removes inherited values for these variables so nested Pi processes do not expose stale parent-session metadata.
74
+
75
+ ## Pi Process Configuration
76
+
77
+ These variables are read by Pi itself:
78
+
79
+ | Variable | Description |
80
+ |----------|-------------|
81
+ | `PI_CODING_AGENT_DIR` | Override the config directory; default is `~/.pi/agent` |
82
+ | `PI_CODING_AGENT_SESSION_DIR` | Override session storage; overridden by `--session-dir` |
83
+ | `PI_PACKAGE_DIR` | Override the package directory, useful for Nix/Guix store paths |
84
+ | `PI_OFFLINE` | Disable startup network operations, including update checks, package updates, and install/update telemetry |
85
+ | `PI_SKIP_VERSION_CHECK` | Disable the `pi.dev` latest-version request |
86
+ | `PI_TELEMETRY` | Override install/update telemetry and provider attribution headers: `1`/`true`/`yes` or `0`/`false`/`no` |
87
+ | `PI_CACHE_RETENTION` | Set to `long` for extended provider prompt caching where supported |
88
+ | `PI_SHARE_VIEWER_URL` | Override the base URL used by `/share` |
89
+ | `PI_RADIUS_GATEWAY` | Override the Radius gateway origin used by `/bug` uploads and Radius relay connections |
90
+ | `PI_HARDWARE_CURSOR` | Set to `1` to show the hardware cursor; see [Terminal setup](terminal-setup.md) |
91
+ | `PI_HYPERLINKS` | Override OSC 8 hyperlink detection with `1`, `0`, or `auto` |
92
+ | `PI_IMAGE_PROTOCOL` | Override inline image detection with `kitty`, `iterm2`, `none`, or `auto` |
93
+ | `PI_TRUE_COLOR` | Override truecolor detection with `1`, `0`, or `auto` |
94
+ | `PI_TUI_ESC_TIMEOUT` | How long to wait after a lone ESC before treating it as Escape, in milliseconds; defaults to `100` over SSH and `10` otherwise. Increase if Alt-key input is misread as Escape |
95
+ | `VISUAL`, `EDITOR` | External editor fallback when `externalEditor` is unset |
96
+ | `HTTP_PROXY`, `HTTPS_PROXY` | Proxy outbound HTTP requests |
97
+
98
+ Provider credentials such as `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, and cloud-provider configuration are listed in [Providers](providers.md#environment-variables-or-auth-file).
99
+
100
+ `PI_SERVER_DIR` and `PI_SERVER_ID` apply only to the source-only [experimental remote harness](development.md#experimental-remote-harness), not distributed builds.