@korallis/k-pi 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 (348) hide show
  1. package/CHANGELOG.md +5619 -0
  2. package/LICENSE +21 -0
  3. package/NOTICE +66 -0
  4. package/README.md +723 -0
  5. package/dist/bundle/chunks/anthropic-messages-IBCPCIJO.js +45 -0
  6. package/dist/bundle/chunks/anthropic.js +75 -0
  7. package/dist/bundle/chunks/azure-openai-responses-GUUG57CZ.js +2 -0
  8. package/dist/bundle/chunks/bedrock-converse-stream.js +74 -0
  9. package/dist/bundle/chunks/chunk-4L3WN2XY.js +2 -0
  10. package/dist/bundle/chunks/chunk-6CYCI3EJ.js +12 -0
  11. package/dist/bundle/chunks/chunk-6R7UI4IY.js +2 -0
  12. package/dist/bundle/chunks/chunk-AXIIZGTV.js +2 -0
  13. package/dist/bundle/chunks/chunk-CO7LIZG5.js +2 -0
  14. package/dist/bundle/chunks/chunk-DRQDKNXA.js +2 -0
  15. package/dist/bundle/chunks/chunk-GMWCTUPB.js +2 -0
  16. package/dist/bundle/chunks/chunk-HOFU6X66.js +50 -0
  17. package/dist/bundle/chunks/chunk-JUUC5AZY.js +2 -0
  18. package/dist/bundle/chunks/chunk-L2ZPNLYD.js +2 -0
  19. package/dist/bundle/chunks/chunk-MNAIPA3J.js +2 -0
  20. package/dist/bundle/chunks/chunk-NBBFIJUL.js +11 -0
  21. package/dist/bundle/chunks/chunk-NUHFSC37.js +25 -0
  22. package/dist/bundle/chunks/chunk-PGXDEOVV.js +2 -0
  23. package/dist/bundle/chunks/chunk-PJACZCIR.js +2 -0
  24. package/dist/bundle/chunks/chunk-PRRNXB7S.js +2 -0
  25. package/dist/bundle/chunks/chunk-TEPMHNKQ.js +2 -0
  26. package/dist/bundle/chunks/chunk-TRDNDS6A.js +4 -0
  27. package/dist/bundle/chunks/chunk-UAQELI3K.js +2 -0
  28. package/dist/bundle/chunks/chunk-X5QHCKY4.js +1653 -0
  29. package/dist/bundle/chunks/chunk-XDUWOHPL.js +6 -0
  30. package/dist/bundle/chunks/github-copilot.js +2 -0
  31. package/dist/bundle/chunks/google-generative-ai-YRXF7C4I.js +2 -0
  32. package/dist/bundle/chunks/google-vertex-BVZ6VBRQ.js +2 -0
  33. package/dist/bundle/chunks/https-proxy-agent-2VXB7436.js +13 -0
  34. package/dist/bundle/chunks/image-resize-worker.js +2 -0
  35. package/dist/bundle/chunks/kimi-coding.js +2 -0
  36. package/dist/bundle/chunks/lib-HGQMNYVT.js +9 -0
  37. package/dist/bundle/chunks/mistral-conversations-Q3AWZJAZ.js +5 -0
  38. package/dist/bundle/chunks/multipart-parser-SQ6GDJL7.js +3 -0
  39. package/dist/bundle/chunks/openai-codex-responses-GJVBJXLB.js +8 -0
  40. package/dist/bundle/chunks/openai-codex.js +75 -0
  41. package/dist/bundle/chunks/openai-completions-OICQQ5JB.js +7 -0
  42. package/dist/bundle/chunks/openai-responses-P5LIZTXX.js +2 -0
  43. package/dist/bundle/chunks/openrouter-images-XTKS2AS3.js +2 -0
  44. package/dist/bundle/chunks/openrouter.js +75 -0
  45. package/dist/bundle/chunks/pi-messages-TPFH44NP.js +8 -0
  46. package/dist/bundle/chunks/radius.js +75 -0
  47. package/dist/bundle/chunks/src-UK77SYZE.js +4 -0
  48. package/dist/bundle/chunks/xai.js +2 -0
  49. package/dist/bundle/cli.js +3 -0
  50. package/dist/bundle/client.js +2 -0
  51. package/dist/bundle/index.js +2 -0
  52. package/dist/bundle/rpc-entry.js +3 -0
  53. package/dist/core/export-html/template.css +1066 -0
  54. package/dist/core/export-html/template.html +55 -0
  55. package/dist/core/export-html/template.js +1864 -0
  56. package/dist/core/export-html/vendor/highlight.min.js +1213 -0
  57. package/dist/core/export-html/vendor/marked.min.js +78 -0
  58. package/dist/kpi/graphs/coding-loop.auto.json +377 -0
  59. package/dist/kpi/graphs/coding-loop.gated.json +417 -0
  60. package/dist/kpi/graphs/spec-first.json +40 -0
  61. package/dist/kpi/kstack/NOTICE +5 -0
  62. package/dist/kpi/kstack/UPSTREAM.md +23 -0
  63. package/dist/kpi/kstack/generated/LICENSE +21 -0
  64. package/dist/kpi/kstack/generated/skills/architect/SKILL.md +83 -0
  65. package/dist/kpi/kstack/generated/skills/architect/references/design-red-flags.md +33 -0
  66. package/dist/kpi/kstack/generated/skills/architect/references/rationale-template.md +35 -0
  67. package/dist/kpi/kstack/generated/skills/architect/references/runner-prompt.md +20 -0
  68. package/dist/kpi/kstack/generated/skills/arena/SKILL.md +29 -0
  69. package/dist/kpi/kstack/generated/skills/blast-radius/SKILL.md +50 -0
  70. package/dist/kpi/kstack/generated/skills/bro/SKILL.md +7 -0
  71. package/dist/kpi/kstack/generated/skills/create-verification-skill/SKILL.md +44 -0
  72. package/dist/kpi/kstack/generated/skills/create-verification-skill/references/feature-map-example/README.md +47 -0
  73. package/dist/kpi/kstack/generated/skills/create-verification-skill/references/feature-map-example/create-note.md +39 -0
  74. package/dist/kpi/kstack/generated/skills/create-verification-skill/references/feature-map-example/search.md +45 -0
  75. package/dist/kpi/kstack/generated/skills/figure-it-out/SKILL.md +55 -0
  76. package/dist/kpi/kstack/generated/skills/how/SKILL.md +135 -0
  77. package/dist/kpi/kstack/generated/skills/how/references/critic-prompt.md +59 -0
  78. package/dist/kpi/kstack/generated/skills/how/references/critique-rubric.md +58 -0
  79. package/dist/kpi/kstack/generated/skills/how/references/explainer-prompt.md +55 -0
  80. package/dist/kpi/kstack/generated/skills/how/references/explorer-prompt.md +52 -0
  81. package/dist/kpi/kstack/generated/skills/interrogate/SKILL.md +113 -0
  82. package/dist/kpi/kstack/generated/skills/interrogate/references/code-quality-review.md +47 -0
  83. package/dist/kpi/kstack/generated/skills/interrogate/references/lead-judgment.md +58 -0
  84. package/dist/kpi/kstack/generated/skills/interrogate/references/reviewer-prompt.md +72 -0
  85. package/dist/kpi/kstack/generated/skills/interrogate/references/rubric.md +77 -0
  86. package/dist/kpi/kstack/generated/skills/k-agent/SKILL.md +17 -0
  87. package/dist/kpi/kstack/generated/skills/k-mode/SKILL.md +64 -0
  88. package/dist/kpi/kstack/generated/skills/k-stack-principles/SKILL.md +24 -0
  89. package/dist/kpi/kstack/generated/skills/maintain-verification-skill/SKILL.md +39 -0
  90. package/dist/kpi/kstack/generated/skills/no-comments/SKILL.md +24 -0
  91. package/dist/kpi/kstack/generated/skills/playbook-arena/SKILL.md +20 -0
  92. package/dist/kpi/kstack/generated/skills/playbook-autonomous-run/SKILL.md +22 -0
  93. package/dist/kpi/kstack/generated/skills/playbook-autopilot-full/SKILL.md +20 -0
  94. package/dist/kpi/kstack/generated/skills/playbook-autopilot-stack/SKILL.md +20 -0
  95. package/dist/kpi/kstack/generated/skills/playbook-bug-fix/SKILL.md +21 -0
  96. package/dist/kpi/kstack/generated/skills/playbook-feature/SKILL.md +22 -0
  97. package/dist/kpi/kstack/generated/skills/playbook-investigation/SKILL.md +21 -0
  98. package/dist/kpi/kstack/generated/skills/playbook-shipping/SKILL.md +18 -0
  99. package/dist/kpi/kstack/generated/skills/playbook-swarm/SKILL.md +20 -0
  100. package/dist/kpi/kstack/generated/skills/principle-boundary-discipline/SKILL.md +34 -0
  101. package/dist/kpi/kstack/generated/skills/principle-build-the-lever/SKILL.md +23 -0
  102. package/dist/kpi/kstack/generated/skills/principle-encode-lessons-in-structure/SKILL.md +31 -0
  103. package/dist/kpi/kstack/generated/skills/principle-exhaust-the-design-space/SKILL.md +21 -0
  104. package/dist/kpi/kstack/generated/skills/principle-experience-first/SKILL.md +19 -0
  105. package/dist/kpi/kstack/generated/skills/principle-fix-root-causes/SKILL.md +23 -0
  106. package/dist/kpi/kstack/generated/skills/principle-foundational-thinking/SKILL.md +21 -0
  107. package/dist/kpi/kstack/generated/skills/principle-guard-the-context-window/SKILL.md +17 -0
  108. package/dist/kpi/kstack/generated/skills/principle-laziness-protocol/SKILL.md +18 -0
  109. package/dist/kpi/kstack/generated/skills/principle-make-operations-idempotent/SKILL.md +24 -0
  110. package/dist/kpi/kstack/generated/skills/principle-migrate-callers-then-delete-legacy-apis/SKILL.md +22 -0
  111. package/dist/kpi/kstack/generated/skills/principle-minimize-reader-load/SKILL.md +23 -0
  112. package/dist/kpi/kstack/generated/skills/principle-model-the-domain/SKILL.md +26 -0
  113. package/dist/kpi/kstack/generated/skills/principle-never-block-on-the-human/SKILL.md +23 -0
  114. package/dist/kpi/kstack/generated/skills/principle-outcome-oriented-execution/SKILL.md +22 -0
  115. package/dist/kpi/kstack/generated/skills/principle-prove-it-works/SKILL.md +33 -0
  116. package/dist/kpi/kstack/generated/skills/principle-redesign-from-first-principles/SKILL.md +16 -0
  117. package/dist/kpi/kstack/generated/skills/principle-separate-before-serializing-shared-state/SKILL.md +16 -0
  118. package/dist/kpi/kstack/generated/skills/principle-sequence-verifiable-units/SKILL.md +22 -0
  119. package/dist/kpi/kstack/generated/skills/principle-subtract-before-you-add/SKILL.md +22 -0
  120. package/dist/kpi/kstack/generated/skills/principle-type-system-discipline/SKILL.md +31 -0
  121. package/dist/kpi/kstack/generated/skills/recall/SKILL.md +35 -0
  122. package/dist/kpi/kstack/generated/skills/reflect/SKILL.md +77 -0
  123. package/dist/kpi/kstack/generated/skills/reflect/references/divergent-reviewer.md +43 -0
  124. package/dist/kpi/kstack/generated/skills/reflect/references/judgment-reviewer.md +42 -0
  125. package/dist/kpi/kstack/generated/skills/reflect/references/synthesizer.md +56 -0
  126. package/dist/kpi/kstack/generated/skills/reflect/references/tooling-reviewer.md +57 -0
  127. package/dist/kpi/kstack/generated/skills/setup-kstack/SKILL.md +48 -0
  128. package/dist/kpi/kstack/generated/skills/show-me-your-work/SKILL.md +82 -0
  129. package/dist/kpi/kstack/generated/skills/show-me-your-work/references/decision-log-template.tsv +1 -0
  130. package/dist/kpi/kstack/generated/skills/show-me-your-work/scripts/log.sh +40 -0
  131. package/dist/kpi/kstack/generated/skills/swarm/SKILL.md +27 -0
  132. package/dist/kpi/kstack/generated/skills/tdd/SKILL.md +44 -0
  133. package/dist/kpi/kstack/generated/skills/teach/SKILL.md +21 -0
  134. package/dist/kpi/kstack/generated/skills/technical-writing/SKILL.md +130 -0
  135. package/dist/kpi/kstack/generated/skills/typescript-best-practices/SKILL.md +30 -0
  136. package/dist/kpi/kstack/generated/skills/typescript-best-practices/references/patterns.md +313 -0
  137. package/dist/kpi/kstack/generated/skills/unslop/SKILL.md +81 -0
  138. package/dist/kpi/kstack/generated/skills/why/SKILL.md +230 -0
  139. package/dist/kpi/kstack/generated/skills/why/references/epistemics.md +144 -0
  140. package/dist/kpi/kstack/generated/skills/why/references/investigator-prompt.md +103 -0
  141. package/dist/kpi/kstack/generated/skills/why/references/source-playbook.md +17 -0
  142. package/dist/kpi/kstack/generated/skills/why/references/sources/code-archaeology.md +88 -0
  143. package/dist/kpi/kstack/generated/skills/why/references/sources/databricks.md +70 -0
  144. package/dist/kpi/kstack/generated/skills/why/references/sources/datadog.md +99 -0
  145. package/dist/kpi/kstack/generated/skills/why/references/sources/incident-postmortem.md +15 -0
  146. package/dist/kpi/kstack/generated/skills/why/references/sources/linear.md +48 -0
  147. package/dist/kpi/kstack/generated/skills/why/references/sources/notion.md +55 -0
  148. package/dist/kpi/kstack/generated/skills/why/references/sources/sentry.md +100 -0
  149. package/dist/kpi/kstack/generated/skills/why/references/sources/slack.md +54 -0
  150. package/dist/kpi/kstack/generated/skills/why/references/synthesizer-prompt.md +135 -0
  151. package/dist/kpi/kstack/model-ladder.md +50 -0
  152. package/dist/kpi/kstack/provenance.json +17 -0
  153. package/dist/kpi/prompts/implement.md +6 -0
  154. package/dist/kpi/prompts/plan.md +6 -0
  155. package/dist/kpi/prompts/review.md +6 -0
  156. package/dist/kpi/prompts/ship.md +6 -0
  157. package/dist/kpi/prompts/specify.md +6 -0
  158. package/dist/kpi/prompts/verify.md +6 -0
  159. package/dist/kpi/schemas/event.schema.json +1314 -0
  160. package/dist/kpi/schemas/evidence.schema.json +43 -0
  161. package/dist/kpi/schemas/stack.schema.json +102 -0
  162. package/dist/kpi/schemas/task.schema.json +165 -0
  163. package/dist/kpi/schemas/verdict.schema.json +44 -0
  164. package/dist/kpi/skills/concise-output/SKILL.md +10 -0
  165. package/dist/kpi/skills/context-pack/SKILL.md +10 -0
  166. package/dist/kpi/skills/conventional-commit/SKILL.md +12 -0
  167. package/dist/kpi/skills/isolated-review/SKILL.md +10 -0
  168. package/dist/kpi/skills/kg-claim/SKILL.md +26 -0
  169. package/dist/kpi/skills/minimalist/SKILL.md +24 -0
  170. package/dist/kpi/skills/quality-gates/SKILL.md +10 -0
  171. package/dist/kpi/skills/spec-first/SKILL.md +10 -0
  172. package/dist/kpi/skills/tdd-cycle/SKILL.md +10 -0
  173. package/dist/kpi/templates/AGENTS.md +31 -0
  174. package/dist/kpi/templates/APPEND_SYSTEM.md +13 -0
  175. package/dist/kpi/templates/context-pack/product.md +7 -0
  176. package/dist/kpi/templates/context-pack/structure.md +7 -0
  177. package/dist/kpi/templates/context-pack/tech.md +9 -0
  178. package/dist/kpi/templates/policy.json +17 -0
  179. package/dist/kpi/themes/loop-amber.json +82 -0
  180. package/dist/kpi/themes/protocol-blue.json +82 -0
  181. package/dist/modes/interactive/assets/clankolas.png +0 -0
  182. package/dist/modes/interactive/theme/dark.json +90 -0
  183. package/dist/modes/interactive/theme/light.json +89 -0
  184. package/dist/modes/interactive/theme/theme-schema.json +352 -0
  185. package/docs/compaction.md +418 -0
  186. package/docs/containerization.md +111 -0
  187. package/docs/custom-provider.md +777 -0
  188. package/docs/development.md +71 -0
  189. package/docs/docs.json +156 -0
  190. package/docs/environment-variables.md +97 -0
  191. package/docs/extensions.md +3020 -0
  192. package/docs/images/doom-extension.png +0 -0
  193. package/docs/images/exy.png +0 -0
  194. package/docs/images/interactive-mode.png +0 -0
  195. package/docs/images/tree-view.png +0 -0
  196. package/docs/index.md +84 -0
  197. package/docs/json.md +98 -0
  198. package/docs/keybindings.md +236 -0
  199. package/docs/llama-cpp.md +101 -0
  200. package/docs/models.md +571 -0
  201. package/docs/packages.md +228 -0
  202. package/docs/prompt-templates.md +96 -0
  203. package/docs/providers.md +317 -0
  204. package/docs/quickstart.md +167 -0
  205. package/docs/rpc.md +1618 -0
  206. package/docs/sdk.md +1219 -0
  207. package/docs/security.md +59 -0
  208. package/docs/session-format.md +438 -0
  209. package/docs/sessions.md +145 -0
  210. package/docs/settings.md +369 -0
  211. package/docs/shell-aliases.md +13 -0
  212. package/docs/skills.md +232 -0
  213. package/docs/terminal-setup.md +177 -0
  214. package/docs/termux.md +127 -0
  215. package/docs/themes.md +320 -0
  216. package/docs/tmux.md +63 -0
  217. package/docs/tui.md +942 -0
  218. package/docs/usage.md +311 -0
  219. package/docs/windows.md +39 -0
  220. package/examples/README.md +25 -0
  221. package/examples/extensions/README.md +213 -0
  222. package/examples/extensions/auto-commit-on-exit.ts +49 -0
  223. package/examples/extensions/bash-spawn-hook.ts +30 -0
  224. package/examples/extensions/bookmark.ts +50 -0
  225. package/examples/extensions/border-status-editor.ts +150 -0
  226. package/examples/extensions/built-in-tool-renderer.ts +249 -0
  227. package/examples/extensions/claude-rules.ts +86 -0
  228. package/examples/extensions/commands.ts +72 -0
  229. package/examples/extensions/confirm-destructive.ts +59 -0
  230. package/examples/extensions/custom-compaction.ts +117 -0
  231. package/examples/extensions/custom-footer.ts +64 -0
  232. package/examples/extensions/custom-header.ts +73 -0
  233. package/examples/extensions/custom-provider-anthropic/index.ts +611 -0
  234. package/examples/extensions/custom-provider-anthropic/package-lock.json +24 -0
  235. package/examples/extensions/custom-provider-anthropic/package.json +19 -0
  236. package/examples/extensions/custom-provider-gitlab-duo/index.ts +405 -0
  237. package/examples/extensions/custom-provider-gitlab-duo/package.json +16 -0
  238. package/examples/extensions/custom-provider-gitlab-duo/test.ts +82 -0
  239. package/examples/extensions/dirty-repo-guard.ts +56 -0
  240. package/examples/extensions/doom-overlay/README.md +46 -0
  241. package/examples/extensions/doom-overlay/doom/build/doom.js +21 -0
  242. package/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
  243. package/examples/extensions/doom-overlay/doom/build.sh +152 -0
  244. package/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +72 -0
  245. package/examples/extensions/doom-overlay/doom-component.ts +132 -0
  246. package/examples/extensions/doom-overlay/doom-engine.ts +173 -0
  247. package/examples/extensions/doom-overlay/doom-keys.ts +104 -0
  248. package/examples/extensions/doom-overlay/index.ts +74 -0
  249. package/examples/extensions/doom-overlay/wad-finder.ts +55 -0
  250. package/examples/extensions/dynamic-resources/SKILL.md +8 -0
  251. package/examples/extensions/dynamic-resources/dynamic.json +79 -0
  252. package/examples/extensions/dynamic-resources/dynamic.md +5 -0
  253. package/examples/extensions/dynamic-resources/index.ts +15 -0
  254. package/examples/extensions/dynamic-tools.ts +74 -0
  255. package/examples/extensions/entry-renderer.ts +41 -0
  256. package/examples/extensions/event-bus.ts +43 -0
  257. package/examples/extensions/file-trigger.ts +41 -0
  258. package/examples/extensions/git-checkpoint.ts +53 -0
  259. package/examples/extensions/git-merge-and-resolve.ts +115 -0
  260. package/examples/extensions/github-issue-autocomplete.ts +185 -0
  261. package/examples/extensions/gondolin/index.ts +531 -0
  262. package/examples/extensions/gondolin/package-lock.json +185 -0
  263. package/examples/extensions/gondolin/package.json +19 -0
  264. package/examples/extensions/handoff.ts +190 -0
  265. package/examples/extensions/hello.ts +26 -0
  266. package/examples/extensions/hidden-thinking-label.ts +53 -0
  267. package/examples/extensions/inline-bash.ts +94 -0
  268. package/examples/extensions/input-transform-streaming.ts +39 -0
  269. package/examples/extensions/input-transform.ts +43 -0
  270. package/examples/extensions/interactive-shell.ts +196 -0
  271. package/examples/extensions/kimi-deferred-tools.ts +61 -0
  272. package/examples/extensions/mac-system-theme.ts +47 -0
  273. package/examples/extensions/message-renderer.ts +59 -0
  274. package/examples/extensions/minimal-mode.ts +426 -0
  275. package/examples/extensions/modal-editor.ts +85 -0
  276. package/examples/extensions/model-status.ts +31 -0
  277. package/examples/extensions/notify.ts +57 -0
  278. package/examples/extensions/overlay-qa-tests.ts +1450 -0
  279. package/examples/extensions/overlay-test.ts +153 -0
  280. package/examples/extensions/permission-gate.ts +34 -0
  281. package/examples/extensions/pirate.ts +47 -0
  282. package/examples/extensions/plan-mode/README.md +66 -0
  283. package/examples/extensions/plan-mode/index.ts +390 -0
  284. package/examples/extensions/plan-mode/utils.ts +168 -0
  285. package/examples/extensions/preset.ts +436 -0
  286. package/examples/extensions/project-trust.ts +64 -0
  287. package/examples/extensions/prompt-customizer.ts +97 -0
  288. package/examples/extensions/protected-paths.ts +30 -0
  289. package/examples/extensions/provider-payload.ts +18 -0
  290. package/examples/extensions/qna.ts +118 -0
  291. package/examples/extensions/question.ts +286 -0
  292. package/examples/extensions/questionnaire.ts +448 -0
  293. package/examples/extensions/rainbow-editor.ts +88 -0
  294. package/examples/extensions/reload-runtime.ts +37 -0
  295. package/examples/extensions/rpc-demo.ts +118 -0
  296. package/examples/extensions/sandbox/index.ts +321 -0
  297. package/examples/extensions/sandbox/package-lock.json +92 -0
  298. package/examples/extensions/sandbox/package.json +19 -0
  299. package/examples/extensions/send-user-message.ts +97 -0
  300. package/examples/extensions/session-name.ts +27 -0
  301. package/examples/extensions/shutdown-command.ts +63 -0
  302. package/examples/extensions/snake.ts +343 -0
  303. package/examples/extensions/space-invaders.ts +560 -0
  304. package/examples/extensions/ssh.ts +220 -0
  305. package/examples/extensions/status-line.ts +32 -0
  306. package/examples/extensions/structured-output.ts +65 -0
  307. package/examples/extensions/subagent/README.md +177 -0
  308. package/examples/extensions/subagent/agents/planner.md +37 -0
  309. package/examples/extensions/subagent/agents/reviewer.md +35 -0
  310. package/examples/extensions/subagent/agents/scout.md +50 -0
  311. package/examples/extensions/subagent/agents/worker.md +24 -0
  312. package/examples/extensions/subagent/agents.ts +157 -0
  313. package/examples/extensions/subagent/index.ts +1038 -0
  314. package/examples/extensions/subagent/prompts/implement-and-review.md +10 -0
  315. package/examples/extensions/subagent/prompts/implement.md +10 -0
  316. package/examples/extensions/subagent/prompts/scout-and-plan.md +9 -0
  317. package/examples/extensions/summarize.ts +199 -0
  318. package/examples/extensions/system-prompt-header.ts +17 -0
  319. package/examples/extensions/tic-tac-toe.ts +1008 -0
  320. package/examples/extensions/timed-confirm.ts +70 -0
  321. package/examples/extensions/titlebar-spinner.ts +58 -0
  322. package/examples/extensions/todo.ts +297 -0
  323. package/examples/extensions/tool-override.ts +144 -0
  324. package/examples/extensions/tools.ts +146 -0
  325. package/examples/extensions/trigger-compact.ts +50 -0
  326. package/examples/extensions/truncated-tool.ts +195 -0
  327. package/examples/extensions/widget-placement.ts +9 -0
  328. package/examples/extensions/with-deps/index.ts +32 -0
  329. package/examples/extensions/with-deps/package-lock.json +31 -0
  330. package/examples/extensions/with-deps/package.json +22 -0
  331. package/examples/extensions/working-indicator.ts +123 -0
  332. package/examples/extensions/working-message-test.ts +25 -0
  333. package/examples/rpc-extension-ui.ts +641 -0
  334. package/examples/sdk/01-minimal.ts +26 -0
  335. package/examples/sdk/02-custom-model.ts +49 -0
  336. package/examples/sdk/03-custom-prompt.ts +75 -0
  337. package/examples/sdk/04-skills.ts +55 -0
  338. package/examples/sdk/05-tools.ts +48 -0
  339. package/examples/sdk/06-extensions.ts +99 -0
  340. package/examples/sdk/07-context-files.ts +47 -0
  341. package/examples/sdk/08-prompt-templates.ts +51 -0
  342. package/examples/sdk/09-api-keys-and-oauth.ts +34 -0
  343. package/examples/sdk/10-settings.ts +53 -0
  344. package/examples/sdk/11-sessions.ts +52 -0
  345. package/examples/sdk/12-full-control.ts +74 -0
  346. package/examples/sdk/13-session-runtime.ts +67 -0
  347. package/examples/sdk/README.md +140 -0
  348. package/package.json +55 -0
package/README.md ADDED
@@ -0,0 +1,723 @@
1
+ # K-π harness core (forked from Pi)
2
+
3
+ > **This is K-π source, not the Pi distribution.** This workspace is the upstream Pi coding-agent package, forked at `v0.84.4` (commit `b79e4cc834970cca69daebffab7df1da7d1e52c4`) and maintained inside K-π. It builds the `kpi` / `k-pi` executable, uses `.kpi/` and `~/.kpi/agent/` for config, and compiles K-π's control plane (`src/kpi/`) in as a built-in extension.
4
+ >
5
+ > - **Do not `npm install` this package.** It is not published under this name. The internal package name is kept upstream-compatible only so upstream releases merge cleanly; nothing resolves it from a registry.
6
+ > - **Build from the repository root:** `npm install && npm run build`, then `node packages/coding-agent/dist/bundle/cli.js` or `npm link --workspace @earendil-works/pi-coding-agent` and run `kpi`.
7
+ > - **Product documentation is the repository root:** [`README.md`](../../README.md), [`AGENTS.md`](../../AGENTS.md), [`docs/`](../../docs), and the fork policy in [`UPSTREAM.md`](../../UPSTREAM.md).
8
+ > - **Issues belong to this fork**, not to the Pi maintainers. Attribution and licence: [`NOTICE`](../../NOTICE), [`LICENSE`](../../LICENSE).
9
+ >
10
+ > Everything below is upstream's reference documentation for the harness base, kept close to upstream to keep merges cheap. Where it says `pi`, read `kpi`; where it says `~/.pi/agent` or `.pi/`, read `~/.kpi/agent` or `.kpi/`; the global-install and package-publishing instructions do not apply to K-π.
11
+
12
+ ---
13
+
14
+ Pi is a minimal terminal coding harness. Adapt pi to your workflows, not the other way around, without having to fork and modify pi internals. Extend it with TypeScript [Extensions](#extensions), [Skills](#skills), [Prompt Templates](#prompt-templates), and [Themes](#themes). Put your extensions, skills, prompt templates, and themes in [Pi Packages](#pi-packages) and share them with others via npm or git.
15
+
16
+ Pi ships with powerful defaults but skips features like sub agents and plan mode. Instead, you can ask pi to build what you want or install a third party pi package that matches your workflow.
17
+
18
+ Pi runs in four modes: interactive, print or JSON, RPC for process integration, and an SDK for embedding in your own apps.
19
+
20
+ ## Share your OSS coding agent sessions
21
+
22
+ If you use pi for open source work, please share your coding agent sessions.
23
+
24
+ Public OSS session data helps improve models, prompts, tools, and evaluations using real development workflows.
25
+
26
+ For the full explanation, see [this post on X](https://x.com/badlogicgames/status/2037811643774652911).
27
+
28
+ To publish sessions, use [`badlogic/pi-share-hf`](https://github.com/badlogic/pi-share-hf). Read its README.md for setup instructions. All you need is a Hugging Face account, the Hugging Face CLI, and `pi-share-hf`.
29
+
30
+ You can also watch [this video](https://x.com/badlogicgames/status/2041151967695634619), where I show how I publish my `pi-mono` sessions.
31
+
32
+ I regularly publish my own `pi-mono` work sessions here:
33
+
34
+ - [badlogicgames/pi-mono on Hugging Face](https://huggingface.co/datasets/badlogicgames/pi-mono)
35
+
36
+ ## Table of Contents
37
+
38
+ - [Quick Start](#quick-start)
39
+ - [Providers & Models](#providers--models)
40
+ - [Interactive Mode](#interactive-mode)
41
+ - [Editor](#editor)
42
+ - [Commands](#commands)
43
+ - [Keyboard Shortcuts](#keyboard-shortcuts)
44
+ - [Message Queue](#message-queue)
45
+ - [Sessions](#sessions)
46
+ - [Branching](#branching)
47
+ - [Compaction](#compaction)
48
+ - [Settings](#settings)
49
+ - [Context Files](#context-files)
50
+ - [Customization](#customization)
51
+ - [Prompt Templates](#prompt-templates)
52
+ - [Skills](#skills)
53
+ - [Extensions](#extensions)
54
+ - [Themes](#themes)
55
+ - [Pi Packages](#pi-packages)
56
+ - [Programmatic Usage](#programmatic-usage)
57
+ - [Philosophy](#philosophy)
58
+ - [CLI Reference](#cli-reference)
59
+
60
+ ---
61
+
62
+ ## Quick Start
63
+
64
+ K-π is built from source, not installed from a registry:
65
+
66
+ ```bash
67
+ npm install # repository root
68
+ npm run build
69
+ npm link --workspace @earendil-works/pi-coding-agent
70
+ ```
71
+
72
+ Authenticate with an API key:
73
+
74
+ ```bash
75
+ export ANTHROPIC_API_KEY=sk-ant-...
76
+ kpi
77
+ ```
78
+
79
+ <details>
80
+ <summary>Upstream Pi install instructions (do not apply to K-π)</summary>
81
+
82
+ ```bash
83
+ npm install -g --ignore-scripts @earendil-works/pi-coding-agent
84
+ curl -fsSL https://pi.dev/install.sh | sh
85
+ ```
86
+
87
+ </details>
88
+
89
+ Or use your existing subscription:
90
+
91
+ ```bash
92
+ pi
93
+ /login # Then select provider
94
+ ```
95
+
96
+ Then just talk to pi. By default, pi gives the model four tools: `read`, `write`, `edit`, and `bash`. The model uses these to fulfill your requests. Add capabilities via [skills](#skills), [prompt templates](#prompt-templates), [extensions](#extensions), or [pi packages](#pi-packages).
97
+
98
+ **Platform notes:** [Windows](docs/windows.md) | [Termux (Android)](docs/termux.md) | [tmux](docs/tmux.md) | [Terminal setup](docs/terminal-setup.md) | [Shell aliases](docs/shell-aliases.md)
99
+
100
+ ---
101
+
102
+ ## Providers & Models
103
+
104
+ For each built-in provider, pi maintains a list of tool-capable models. Configured provider catalogs refresh automatically; run `pi update --models` to force an immediate refresh. Authenticate via subscription (`/login`) or API key, then select any model from that provider via `/model` (or Ctrl+L). Press Ctrl+S in the model picker to save the highlighted model as the startup default.
105
+
106
+ **Subscriptions:**
107
+ - Anthropic Claude Pro/Max
108
+ - OpenAI ChatGPT Plus/Pro (Codex)
109
+ - GitHub Copilot
110
+
111
+ **API keys:**
112
+ - Anthropic
113
+ - Ant Ling
114
+ - OpenAI
115
+ - Azure OpenAI
116
+ - DeepSeek
117
+ - NVIDIA NIM
118
+ - Google Gemini
119
+ - Google Vertex
120
+ - Amazon Bedrock
121
+ - Mistral
122
+ - Groq
123
+ - Cerebras
124
+ - Cloudflare AI Gateway
125
+ - Cloudflare Workers AI
126
+ - xAI
127
+ - OpenRouter
128
+ - Vercel AI Gateway
129
+ - ZAI Coding Plan (Global)
130
+ - ZAI Coding Plan (China)
131
+ - OpenCode Zen
132
+ - OpenCode Go
133
+ - Hugging Face
134
+ - Fireworks
135
+ - Together AI
136
+ - Baseten
137
+ - Kimi For Coding
138
+ - MiniMax
139
+ - Xiaomi MiMo
140
+ - Xiaomi MiMo Token Plan (China)
141
+ - Xiaomi MiMo Token Plan (Amsterdam)
142
+ - Xiaomi MiMo Token Plan (Singapore)
143
+
144
+ Pi also supports the llama.cpp router server. Configure it with `/login llama.cpp`, manage downloads and loaded models with `/llama`, then select a loaded model with `/model`. See [docs/llama-cpp.md](docs/llama-cpp.md) for setup and usage.
145
+
146
+ See [docs/providers.md](docs/providers.md) for other provider setup instructions.
147
+
148
+ **Custom providers & models:** Add providers via `~/.pi/agent/models.json` if they speak a supported API (OpenAI, Anthropic, Google). For custom APIs or OAuth, use extensions. See [docs/models.md](docs/models.md) and [docs/custom-provider.md](docs/custom-provider.md).
149
+
150
+ ---
151
+
152
+ ## Interactive Mode
153
+
154
+ <p align="center"><img src="docs/images/interactive-mode.png" alt="Interactive Mode" width="600"></p>
155
+
156
+ The interface from top to bottom:
157
+
158
+ - **Startup header** - Shows shortcuts (`/hotkeys` for all), loaded AGENTS.md files, prompt templates, skills, and extensions
159
+ - **Messages** - Your messages, assistant responses, tool calls and results, notifications, errors, and extension UI
160
+ - **Editor** - Where you type; border color indicates thinking level
161
+ - **Footer** - Working directory, session name, total token/cache usage (`↑` input, `↓` output, `R` cache read, `W` cache write, `CH` latest cache hit rate), cost, context usage, current model. Totals include assistant responses, usage reported by tools, and summary generation.
162
+
163
+ The editor can be temporarily replaced by other UI, like built-in `/settings` or custom UI from extensions (e.g., a Q&A tool that lets the user answer model questions in a structured format). [Extensions](#extensions) can also replace the editor, add widgets above/below it, a status line, custom footer, or overlays.
164
+
165
+ ### Editor
166
+
167
+ | Feature | How |
168
+ |---------|-----|
169
+ | File reference | Type `@` to fuzzy-search project files |
170
+ | Path completion | Tab to complete paths |
171
+ | Multi-line | Shift+Enter (or Ctrl+Enter on Windows Terminal) |
172
+ | External editor | Ctrl+G opens `externalEditor`, `$VISUAL`, `$EDITOR`, Notepad on Windows, or `nano` elsewhere |
173
+ | Clipboard | Ctrl+V to paste an image or text (Alt+V on Windows), or drag images onto terminal |
174
+ | Bash commands | `!command` runs and sends output to LLM, `!!command` runs without sending |
175
+
176
+ Standard editing keybindings for delete word, undo, etc. See [docs/keybindings.md](docs/keybindings.md).
177
+
178
+ ### Commands
179
+
180
+ Type `/` in the editor to trigger commands. [Extensions](#extensions) can register custom commands, [skills](#skills) are available as `/skill:name`, and [prompt templates](#prompt-templates) expand via `/templatename`.
181
+
182
+ | Command | Description |
183
+ |---------|-------------|
184
+ | `/login`, `/logout` | Manage provider credentials |
185
+ | [`/llama`](docs/llama-cpp.md) | Download, load, and unload llama.cpp router models |
186
+ | `/model` | Switch models; Ctrl+S in the picker saves the startup default |
187
+ | `/thinking` | Switch thinking level; Ctrl+S in the picker saves the startup default |
188
+ | `/scoped-models` | Enable/disable models for Ctrl+P cycling |
189
+ | `/settings` | Theme, message delivery, transport, and other preferences |
190
+ | `/resume` | Pick from previous sessions |
191
+ | `/new` | Start a new session |
192
+ | `/name <name>` | Set session display name |
193
+ | `/session` | Show session info (file, ID, messages, tokens, cost) |
194
+ | `/tree` | Jump to any point in the session and continue from there |
195
+ | `/trust` | Save project trust decision for future sessions (restart required) |
196
+ | `/fork` | Create a new session from a previous user message |
197
+ | `/clone` | Duplicate the current active branch into a new session |
198
+ | `/compact [prompt]` | Manually compact context, optional custom instructions |
199
+ | `/copy` | Copy last assistant message to clipboard |
200
+ | `/export [file]` | Export session to HTML or JSONL file |
201
+ | `/import <file>` | Import and resume a session from a JSONL file |
202
+ | `/share` | Upload as private GitHub gist with shareable HTML link |
203
+ | `/reload` | Reload keybindings, extensions, skills, prompts, themes, and context files |
204
+ | `/hotkeys` | Show all keyboard shortcuts |
205
+ | `/changelog` | Display version history |
206
+ | `/quit` | Quit pi |
207
+
208
+ ### Keyboard Shortcuts
209
+
210
+ See `/hotkeys` for the full list. Customize via `~/.pi/agent/keybindings.json`. See [docs/keybindings.md](docs/keybindings.md).
211
+
212
+ **Commonly used:**
213
+
214
+ | Key | Action |
215
+ |-----|--------|
216
+ | Ctrl+C | Clear editor |
217
+ | Ctrl+C twice | Quit |
218
+ | Escape | Cancel/abort |
219
+ | Escape twice | Open `/tree` |
220
+ | Ctrl+L | Open model selector |
221
+ | Ctrl+P / Shift+Ctrl+P | Cycle scoped models forward/backward |
222
+ | Shift+Tab | Cycle thinking level |
223
+ | Ctrl+O | Collapse/expand tool output |
224
+ | Ctrl+T | Collapse/expand thinking blocks |
225
+ | Ctrl+X | Copy the last assistant message; with fullscreen copy-on-select disabled, copy the active text selection |
226
+
227
+ ### Message Queue
228
+
229
+ Submit messages while the agent is working:
230
+
231
+ - **Enter** queues a *steering* message, delivered after the current assistant turn finishes executing its tool calls
232
+ - **Alt+Enter** queues a *follow-up* message, delivered only after the agent finishes all work
233
+ - **Escape** aborts and restores queued messages to editor
234
+ - **Alt+Up** retrieves queued messages back to editor
235
+
236
+ On Windows Terminal, `Alt+Enter` is fullscreen by default. Remap it in [docs/terminal-setup.md](docs/terminal-setup.md) so pi can receive the follow-up shortcut.
237
+
238
+ Configure delivery in [settings](docs/settings.md): `steeringMode` and `followUpMode` can be `"one-at-a-time"` (default, waits for response) or `"all"` (delivers all queued at once). `transport` selects provider transport preference (`"sse"`, `"websocket"`, or `"auto"`) for providers that support multiple transports.
239
+
240
+ ---
241
+
242
+ ## Sessions
243
+
244
+ Sessions are stored as JSONL files with a tree structure. Each entry has an `id` and `parentId`, enabling in-place branching without creating new files. See [docs/session-format.md](docs/session-format.md) for file format.
245
+
246
+ ### Management
247
+
248
+ Sessions auto-save to `~/.pi/agent/sessions/` organized by working directory.
249
+
250
+ ```bash
251
+ pi -c # Continue most recent session
252
+ pi -r # Browse and select from past sessions
253
+ pi --no-session # Ephemeral mode (don't save)
254
+ pi --name "my task" # Set session display name at startup
255
+ pi --session <path|id> # Use specific session file or ID
256
+ pi --fork <path|id> # Fork specific session file or ID into a new session
257
+ ```
258
+
259
+ Use `/session` in interactive mode to see the current session ID before reusing it with `--session <id>` or `--fork <id>`.
260
+
261
+ ### Branching
262
+
263
+ **`/tree`** - Navigate the session tree in-place. Select any previous point, continue from there, and switch between branches. All history preserved in a single file.
264
+
265
+ <p align="center"><img src="docs/images/tree-view.png" alt="Tree View" width="600"></p>
266
+
267
+ - Search by typing, fold/unfold and jump between branches with Ctrl+←/Ctrl+→ or Alt+←/Alt+→, page with ←/→
268
+ - Filter modes (Ctrl+O): default → no-tools → user-only → labeled-only → all
269
+ - Press Ctrl+X to copy the selected message
270
+ - Press Shift+L to label entries as bookmarks and Shift+T to toggle label timestamps
271
+
272
+ **`/fork`** - Create a new session file from a previous user message on the active branch. Opens a selector, copies the active path up to that point, and places the selected prompt in the editor for modification.
273
+
274
+ **`/clone`** - Duplicate the current active branch into a new session file at the current position. The new session keeps the full active-path history and opens with an empty editor.
275
+
276
+ **`--fork <path|id>`** - Fork an existing session file or partial session UUID directly from the CLI. This copies the full source session into a new session file in the current project.
277
+
278
+ ### Compaction
279
+
280
+ Long sessions can exhaust context windows. Compaction summarizes older messages while keeping recent ones.
281
+
282
+ **Manual:** `/compact` or `/compact <custom instructions>`
283
+
284
+ **Automatic:** Enabled by default. Triggers on context overflow (recovers and retries) or when approaching the limit (proactive). Configure via `/settings` or `settings.json`.
285
+
286
+ Compaction is lossy. The full history remains in the JSONL file; use `/tree` to revisit. Customize compaction behavior via [extensions](#extensions). See [docs/compaction.md](docs/compaction.md) for internals.
287
+
288
+ ---
289
+
290
+ ## Settings
291
+
292
+ Use `/settings` to modify common options, or edit JSON files directly:
293
+
294
+ | Location | Scope |
295
+ |----------|-------|
296
+ | `~/.pi/agent/settings.json` | Global (all projects) |
297
+ | `.pi/settings.json` | Project (overrides global) |
298
+
299
+ See [docs/settings.md](docs/settings.md) for all options.
300
+
301
+ ### Project Trust
302
+
303
+ On interactive startup, pi asks before trusting a project folder that contains project-local settings, resources, or project `.agents/skills` and has no saved decision for the folder or a parent folder in `~/.pi/agent/trust.json`. Trusting a project allows pi to load `.pi/settings.json` and `.pi` resources, install missing project packages, and execute project extensions.
304
+
305
+ Before the trust decision, pi loads only context files, user/global extensions, and CLI `-e` extensions so they can handle the `project_trust` event. Project-local extensions, project package-managed extensions, and project settings are loaded only after the project is trusted. This split also applies when switching to a session from a different cwd whose trust has not been resolved in the current process.
306
+
307
+ Non-interactive modes (`-p`, `--mode json`, and `--mode rpc`) do not show a trust prompt. Without an applicable saved trust decision, they use `defaultProjectTrust` from global settings: `ask` (default) and `never` ignore those project resources, while `always` trusts them. Pass `--approve`/`-a` or `--no-approve`/`-na` to override project trust for one run.
308
+
309
+ If no extension or saved decision applies, `defaultProjectTrust` controls the fallback behavior. Set it to `"ask"`, `"always"`, or `"never"` in `~/.pi/agent/settings.json`, or change it with `/settings`.
310
+
311
+ `pi config` and package commands use the same project trust flow, except `pi update` never prompts. Pass `--approve` to trust project-local settings for one command or `--no-approve` to ignore them.
312
+
313
+ Use `/trust` in interactive mode to save a project trust decision for future sessions, including trust for the immediate parent folder. It writes `~/.pi/agent/trust.json` only; the current session is not reloaded, so restart pi for changes to take effect.
314
+
315
+ ### Telemetry and update checks
316
+
317
+ Pi has two separate startup features:
318
+
319
+ - **Update check:** fetches `https://pi.dev/api/latest-version` to check whether a newer Pi version exists. Disable it with `PI_SKIP_VERSION_CHECK=1`. Disabling update checks only turns off this check.
320
+ - **Install/update telemetry:** after first install or a changelog-detected update, sends an anonymous version ping to `https://pi.dev/api/report-install`. This setting also controls optional provider attribution headers for OpenRouter, Cloudflare, and direct NVIDIA NIM requests. Opt out by setting `enableInstallTelemetry` to `false` in `settings.json`, or by setting `PI_TELEMETRY=0`. This does not disable update checks; Pi may still contact `pi.dev` for the latest version unless update checks are disabled or offline mode is enabled.
321
+
322
+ Use `--offline` or `PI_OFFLINE=1` to disable all startup network operations described here, including update checks, package update checks, and install/update telemetry.
323
+
324
+ ---
325
+
326
+ ## Context Files
327
+
328
+ Pi loads `AGENTS.md` (or `CLAUDE.md`) at startup from:
329
+ - `~/.pi/agent/AGENTS.md` (global)
330
+ - Parent directories (walking up from cwd)
331
+ - Current directory
332
+
333
+ If a directory contains `AGENTS.override.md`, Pi loads it instead of `AGENTS.md` or `CLAUDE.md` from that directory. Context files from other directories are still concatenated.
334
+
335
+ Use for project instructions (`AGENTS.md`/`CLAUDE.md`), conventions, common commands. All matching files are concatenated.
336
+
337
+ Disable context file loading with `--no-context-files` (or `-nc`).
338
+
339
+ ### System Prompt
340
+
341
+ Replace the default system prompt with `.pi/SYSTEM.md` (project) or `~/.pi/agent/SYSTEM.md` (global). Append without replacing via `APPEND_SYSTEM.md`.
342
+
343
+ ---
344
+
345
+ ## Customization
346
+
347
+ ### Prompt Templates
348
+
349
+ Reusable prompts as Markdown files. Type `/name` to expand.
350
+
351
+ ```markdown
352
+ <!-- ~/.pi/agent/prompts/review.md -->
353
+ Review this code for bugs, security issues, and performance problems.
354
+ Focus on: {{focus}}
355
+ ```
356
+
357
+ Place in `~/.pi/agent/prompts/`, `.pi/prompts/`, or a [pi package](#pi-packages) to share with others. See [docs/prompt-templates.md](docs/prompt-templates.md).
358
+
359
+ ### Skills
360
+
361
+ On-demand capability packages following the [Agent Skills standard](https://agentskills.io). Invoke via `/skill:name` or let the agent load them automatically.
362
+
363
+ ```markdown
364
+ <!-- ~/.pi/agent/skills/my-skill/SKILL.md -->
365
+ # My Skill
366
+ Use this skill when the user asks about X.
367
+
368
+ ## Steps
369
+ 1. Do this
370
+ 2. Then that
371
+ ```
372
+
373
+ Place in `~/.pi/agent/skills/`, `~/.agents/skills/`, `.pi/skills/`, or `.agents/skills/` (from `cwd` up through parent directories) or a [pi package](#pi-packages) to share with others. See [docs/skills.md](docs/skills.md).
374
+
375
+ ### Extensions
376
+
377
+ <p align="center"><img src="docs/images/doom-extension.png" alt="Doom Extension" width="600"></p>
378
+
379
+ TypeScript modules that extend pi with custom tools, commands, keyboard shortcuts, event handlers, and UI components.
380
+
381
+ ```typescript
382
+ export default function (pi: ExtensionAPI) {
383
+ pi.registerTool({ name: "deploy", ... });
384
+ pi.registerCommand("stats", { ... });
385
+ pi.on("tool_call", async (event, ctx) => { ... });
386
+ }
387
+ ```
388
+
389
+ The default export can also be `async`. pi waits for async extension factories before startup continues, which is useful for one-time initialization such as fetching remote model lists before calling `pi.registerProvider()`.
390
+
391
+ **What's possible:**
392
+ - Custom tools (or replace built-in tools entirely)
393
+ - Sub-agents and plan mode
394
+ - Custom compaction and summarization
395
+ - Permission gates and path protection
396
+ - Custom editors and UI components
397
+ - Status lines, headers, footers
398
+ - Git checkpointing and auto-commit
399
+ - SSH and sandbox execution
400
+ - MCP server integration
401
+ - Make pi look like Claude Code
402
+ - Games while waiting (yes, Doom runs)
403
+ - ...anything you can dream up
404
+
405
+ Place in `~/.pi/agent/extensions/`, `.pi/extensions/`, or a [pi package](#pi-packages) to share with others. See [docs/extensions.md](docs/extensions.md) and [examples/extensions/](examples/extensions/).
406
+
407
+ ### Themes
408
+
409
+ Built-in: `dark`, `light`. Themes hot-reload: modify the active theme file and pi immediately applies changes.
410
+
411
+ Place in `~/.pi/agent/themes/`, `.pi/themes/`, or a [pi package](#pi-packages) to share with others. See [docs/themes.md](docs/themes.md).
412
+
413
+ ### Pi Packages
414
+
415
+ Bundle and share extensions, skills, prompts, and themes via npm or git. Find packages on [npmjs.com](https://www.npmjs.com/search?q=keywords%3Api-package) or [Discord](https://discord.com/channels/1456806362351669492/1457744485428629628).
416
+
417
+ > **Security:** Pi packages run with full system access. Extensions execute arbitrary code, and skills can instruct the model to perform any action including running executables. Review source code before installing third-party packages.
418
+
419
+ ```bash
420
+ pi install npm:@foo/pi-tools
421
+ pi install npm:@foo/pi-tools@1.2.3 # pinned version
422
+ pi install git:github.com/user/repo
423
+ pi install git:github.com/user/repo@v1 # tag or commit
424
+ pi install git:git@github.com:user/repo
425
+ pi install git:git@github.com:user/repo@v1 # tag or commit
426
+ pi install https://github.com/user/repo
427
+ pi install https://github.com/user/repo@v1 # tag or commit
428
+ pi install ssh://git@github.com/user/repo
429
+ pi install ssh://git@github.com/user/repo@v1 # tag or commit
430
+ pi remove npm:@foo/pi-tools
431
+ pi uninstall npm:@foo/pi-tools # alias for remove
432
+ pi list
433
+ pi update # update pi only
434
+ pi update --all # update pi and packages
435
+ pi update --extensions # update packages only
436
+ pi update --models # refresh model catalogs only
437
+ pi update --self # update pi only
438
+ pi update --self --force # reinstall pi even if current
439
+ pi update npm:@foo/pi-tools # update one package
440
+ pi config # enable/disable extensions, skills, prompts, themes
441
+ ```
442
+
443
+ Packages install to `~/.pi/agent/git/` (git) or `~/.pi/agent/npm/` (npm). Use `-l` for project-local installs (`.pi/git/`, `.pi/npm/`). Git `@ref` values are pinned tags or commits; pinned packages are skipped by `pi update --extensions` and `pi update --all`, so use `pi install git:host/user/repo@new-ref` to move an existing package to a new ref. Git packages install dependencies with `npm install --omit=dev` by default, so runtime deps must be listed under `dependencies`; when `npmCommand` is configured, git packages use plain `install` for compatibility with wrappers. If you use a Node version manager and want package installs to reuse a stable npm context, set `npmCommand` in `settings.json`, for example `["mise", "exec", "node@20", "--", "npm"]`.
444
+
445
+ Create a package by adding a `pi` key to `package.json`:
446
+
447
+ ```json
448
+ {
449
+ "name": "my-pi-package",
450
+ "keywords": ["pi-package"],
451
+ "pi": {
452
+ "extensions": ["./extensions"],
453
+ "skills": ["./skills"],
454
+ "prompts": ["./prompts"],
455
+ "themes": ["./themes"]
456
+ }
457
+ }
458
+ ```
459
+
460
+ Without a `pi` manifest, pi auto-discovers from conventional directories (`extensions/`, `skills/`, `prompts/`, `themes/`).
461
+
462
+ See [docs/packages.md](docs/packages.md).
463
+
464
+ ---
465
+
466
+ ## Programmatic Usage
467
+
468
+ ### SDK
469
+
470
+ ```typescript
471
+ import { createAgentSession, ModelRuntime, SessionManager } from "@earendil-works/pi-coding-agent";
472
+
473
+ const modelRuntime = await ModelRuntime.create();
474
+ const { session } = await createAgentSession({
475
+ sessionManager: SessionManager.inMemory(),
476
+ modelRuntime,
477
+ });
478
+
479
+ await session.prompt("What files are in the current directory?");
480
+ ```
481
+
482
+ For advanced multi-session runtime replacement, use `createAgentSessionRuntime()` and `AgentSessionRuntime`.
483
+
484
+ See [docs/sdk.md](docs/sdk.md) and [examples/sdk/](examples/sdk/).
485
+
486
+ ### RPC Mode
487
+
488
+ For non-Node.js integrations, use RPC mode over stdin/stdout:
489
+
490
+ ```bash
491
+ pi --mode rpc
492
+ ```
493
+
494
+ RPC mode uses strict LF-delimited JSONL framing. Clients must split records on `\n` only. Do not use generic line readers like Node `readline`, which also split on Unicode separators inside JSON payloads.
495
+
496
+ See [docs/rpc.md](docs/rpc.md) for the protocol.
497
+
498
+ ---
499
+
500
+ ## Philosophy
501
+
502
+ Pi is aggressively extensible so it doesn't have to dictate your workflow. Features that other tools bake in can be built with [extensions](#extensions), [skills](#skills), or installed from third-party [pi packages](#pi-packages). This keeps the core minimal while letting you shape pi to fit how you work.
503
+
504
+ **No MCP.** Build CLI tools with READMEs (see [Skills](#skills)), or build an extension that adds MCP support. [Why?](https://mariozechner.at/posts/2025-11-02-what-if-you-dont-need-mcp/)
505
+
506
+ **No sub-agents.** There's many ways to do this. Spawn pi instances via tmux, or build your own with [extensions](#extensions), or install a package that does it your way.
507
+
508
+ **No permission popups.** Run in a container, or build your own confirmation flow with [extensions](#extensions) inline with your environment and security requirements.
509
+
510
+ **No plan mode.** Write plans to files, or build it with [extensions](#extensions), or install a package.
511
+
512
+ **No built-in to-dos.** They confuse models. Use a TODO.md file, or build your own with [extensions](#extensions).
513
+
514
+ **No background bash.** Use tmux. Full observability, direct interaction.
515
+
516
+ Read the [blog post](https://mariozechner.at/posts/2025-11-30-pi-coding-agent/) for the full rationale.
517
+
518
+ ---
519
+
520
+ ## CLI Reference
521
+
522
+ ```bash
523
+ pi [options] [--] [@files...] [messages...]
524
+ ```
525
+
526
+ ### Package Commands
527
+
528
+ ```bash
529
+ pi install <source> [-l] # Install package, -l for project-local
530
+ pi remove <source> [-l] # Remove package
531
+ pi uninstall <source> [-l] # Alias for remove
532
+ pi update [source|self|pi] # Update pi only, or one package source
533
+ pi update --all # Update pi and packages
534
+ pi update --extensions # Update packages only
535
+ pi update --models # Refresh model catalogs only
536
+ pi update --self # Update pi only
537
+ pi update --self --force # Reinstall pi even if current
538
+ pi update --extension <src> # Update one package
539
+ pi list # List installed packages
540
+ pi config # Enable/disable package resources
541
+ ```
542
+
543
+ `pi config` and project package commands accept `--approve`/`--no-approve` to trust or ignore project-local settings for one command. `pi update` never prompts for project trust.
544
+
545
+ ### Modes
546
+
547
+ | Flag | Description |
548
+ |------|-------------|
549
+ | (default) | Interactive mode |
550
+ | `-p`, `--print` | Print response and exit |
551
+ | `--mode json` | Output all events as JSON lines (see [docs/json.md](docs/json.md)) |
552
+ | `--mode rpc` | RPC mode for process integration (see [docs/rpc.md](docs/rpc.md)) |
553
+ | `--export <in> [out]` | Export session to HTML |
554
+
555
+ In print mode, pi also reads piped stdin and merges it into the initial prompt:
556
+
557
+ ```bash
558
+ cat README.md | pi -p "Summarize this text"
559
+ ```
560
+
561
+ ### Model Options
562
+
563
+ | Option | Description |
564
+ |--------|-------------|
565
+ | `--provider <name>` | Provider (anthropic, openai, google, etc.) |
566
+ | `--model <pattern>` | Model pattern or ID (supports `provider/id` and optional `:<thinking>`) |
567
+ | `--api-key <key>` | API key (overrides env vars) |
568
+ | `--thinking <level>` | `off`, `minimal`, `low`, `medium`, `high`, `xhigh`, `max` |
569
+ | `--models <patterns>` | Comma-separated patterns for Ctrl+P cycling |
570
+ | `--list-models [search]` | List available models |
571
+
572
+ ### Session Options
573
+
574
+ | Option | Description |
575
+ |--------|-------------|
576
+ | `-c`, `--continue` | Continue most recent session |
577
+ | `-r`, `--resume` | Browse and select session |
578
+ | `--session <path\|id>` | Use specific session file or partial UUID |
579
+ | `--fork <path\|id>` | Fork specific session file or partial UUID into a new session |
580
+ | `--session-dir <dir>` | Custom session storage directory |
581
+ | `--no-session` | Ephemeral mode (don't save) |
582
+ | `--name <name>`, `-n <name>` | Set session display name at startup |
583
+
584
+ ### Tool Options
585
+
586
+ | Option | Description |
587
+ |--------|-------------|
588
+ | `--tools <list>`, `-t <list>` | Allowlist specific tool names across built-in, extension, and custom tools |
589
+ | `--exclude-tools <list>`, `-xt <list>` | Disable specific tool names across built-in, extension, and custom tools |
590
+ | `--no-builtin-tools`, `-nbt` | Disable built-in tools by default but keep extension/custom tools enabled |
591
+ | `--no-tools`, `-nt` | Disable all tools by default |
592
+
593
+ Available built-in tools: `read`, `bash`, `powershell` (Windows), `edit`, `write`, `grep`, `find`, `ls`
594
+
595
+ ### Resource Options
596
+
597
+ | Option | Description |
598
+ |--------|-------------|
599
+ | `-e`, `--extension <source>` | Load extension from path, npm, or git (repeatable) |
600
+ | `--no-extensions` | Disable extension discovery |
601
+ | `--skill <path>` | Load skill (repeatable) |
602
+ | `--no-skills` | Disable skill discovery |
603
+ | `--prompt-template <path>` | Load prompt template (repeatable) |
604
+ | `--no-prompt-templates` | Disable prompt template discovery |
605
+ | `--theme <path>` | Load theme (repeatable) |
606
+ | `--no-themes` | Disable theme discovery |
607
+ | `--no-context-files`, `-nc` | Disable AGENTS.md and CLAUDE.md context file discovery |
608
+
609
+ Combine `--no-*` with explicit flags to load exactly what you need, ignoring settings.json (e.g., `--no-extensions -e ./my-ext.ts`).
610
+
611
+ ### Other Options
612
+
613
+ | Option | Description |
614
+ |--------|-------------|
615
+ | `--system-prompt <text>` | Replace default prompt (context files and skills still appended) |
616
+ | `--append-system-prompt <text>` | Append to system prompt |
617
+ | `--tui-mode <mode>` | TUI mode: `regular` (default) or experimental `fullscreen` |
618
+ | `--use-theme <name[/name]>` | Set the initial interactive theme for this run without changing settings |
619
+ | `--verbose` | Force verbose startup |
620
+ | `-a`, `--approve` | Trust project-local files for this run |
621
+ | `-na`, `--no-approve` | Ignore project-local files for this run |
622
+ | `--` | Stop option parsing; remaining arguments are prompts or `@file` inputs |
623
+ | `-h`, `--help` | Show help |
624
+ | `-v`, `--version` | Show version |
625
+
626
+ ### File Arguments
627
+
628
+ Prefix files with `@` to include in the message:
629
+
630
+ ```bash
631
+ pi @prompt.md "Answer this"
632
+ pi -p @screenshot.png "What's in this image?"
633
+ pi @code.ts @test.ts "Review these files"
634
+ ```
635
+
636
+ ### Examples
637
+
638
+ ```bash
639
+ # Interactive with initial prompt
640
+ pi "List all .ts files in src/"
641
+
642
+ # Non-interactive
643
+ pi -p "Summarize this codebase"
644
+
645
+ # Prompt beginning with a dash
646
+ pi -p -- "- Summarize these points"
647
+
648
+ # Non-interactive with piped stdin
649
+ cat README.md | pi -p "Summarize this text"
650
+
651
+ # Named one-shot session
652
+ pi --name "release audit" -p "Audit this repository"
653
+
654
+ # Different model
655
+ pi --provider openai --model gpt-4o "Help me refactor"
656
+
657
+ # Model with provider prefix (no --provider needed)
658
+ pi --model openai/gpt-4o "Help me refactor"
659
+
660
+ # Model with thinking level shorthand
661
+ pi --model sonnet:high "Solve this complex problem"
662
+
663
+ # Limit model cycling
664
+ pi --models "claude-*,gpt-4o"
665
+
666
+ # Read-only mode
667
+ pi --tools read,grep,find,ls -p "Review the code"
668
+
669
+ # Disable one extension or built-in tool while keeping the rest available
670
+ pi --exclude-tools ask_question
671
+
672
+ # High thinking level
673
+ pi --thinking high "Solve this complex problem"
674
+ ```
675
+
676
+ ### Environment Variables
677
+
678
+ | Variable | Description |
679
+ |----------|-------------|
680
+ | `AI_AGENT` | Set to `pi` by the CLI and RPC entry points so generic tooling can attribute child processes to Pi |
681
+ | `PI_CODING_AGENT` | Set to `true` by the CLI and RPC entry points so child processes can detect that they run inside Pi |
682
+ | `PI_CODING_AGENT_DIR` | Override config directory (default: `~/.pi/agent`) |
683
+ | `PI_CODING_AGENT_SESSION_DIR` | Override session storage directory (overridden by `--session-dir`) |
684
+ | `PI_PACKAGE_DIR` | Override package directory (useful for Nix/Guix where store paths tokenize poorly) |
685
+ | `PI_OFFLINE` | Disable startup network operations, including update checks, package update checks, and install/update telemetry |
686
+ | `PI_SKIP_VERSION_CHECK` | Skip the Pi version update check at startup. This prevents the `pi.dev` latest-version request |
687
+ | `PI_TELEMETRY` | Override install/update telemetry and provider attribution headers. Use `1`/`true`/`yes` to enable or `0`/`false`/`no` to disable. This does not disable update checks |
688
+ | `PI_CACHE_RETENTION` | Set to `long` for extended prompt cache (Anthropic: 1h, OpenAI: 24h) |
689
+ | `VISUAL`, `EDITOR` | Fallback external editor for Ctrl+G when `externalEditor` is unset; defaults to Notepad on Windows and `nano` elsewhere |
690
+
691
+ Commands run by the LLM-callable `bash` and `powershell` tools also receive current session metadata:
692
+
693
+ | Variable | Description |
694
+ |----------|-------------|
695
+ | `PI_SESSION_ID` | Current session ID |
696
+ | `PI_SESSION_FILE` | Absolute session JSONL path; unset for ephemeral sessions |
697
+ | `PI_PROVIDER` | Currently selected model provider |
698
+ | `PI_MODEL` | Currently selected model ID |
699
+ | `PI_REASONING_LEVEL` | Current effective reasoning level |
700
+
701
+ These values are resolved when each command starts. See [Environment Variables](docs/environment-variables.md#shell-tool-session-environment) for semantics, examples, and custom-tool opt-out.
702
+
703
+ ---
704
+
705
+ ## Contributing & Development
706
+
707
+ See [CONTRIBUTING.md](../../CONTRIBUTING.md) for guidelines and [docs/development.md](docs/development.md) for setup, forking, and debugging.
708
+
709
+ ## License
710
+
711
+ MIT
712
+
713
+ ## See Also
714
+
715
+ - [@earendil-works/pi-ai](https://www.npmjs.com/package/@earendil-works/pi-ai): Core LLM toolkit
716
+ - [@earendil-works/pi-agent-core](https://www.npmjs.com/package/@earendil-works/pi-agent-core): Agent framework
717
+ - [@earendil-works/pi-tui](https://www.npmjs.com/package/@earendil-works/pi-tui): Terminal UI components
718
+
719
+ <p align="center">
720
+ <a href="https://pi.dev">pi.dev</a> domain graciously donated by
721
+ <br /><br />
722
+ <a href="https://exe.dev"><img src="docs/images/exy.png" alt="Exy mascot" width="48" /><br />exe.dev</a>
723
+ </p>