@celljs/ta 0.0.0-stage → 4.5.1

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 (325) hide show
  1. package/README.md +94 -2
  2. package/bin/ta.mjs +10 -0
  3. package/dist/cli.mjs +517 -0
  4. package/dist/pi/CHANGELOG.md +32 -0
  5. package/dist/pi/dist/bundle/chunks/anthropic-messages-BWGCKOF4.js +6 -0
  6. package/dist/pi/dist/bundle/chunks/anthropic.js +75 -0
  7. package/dist/pi/dist/bundle/chunks/azure-openai-responses-FSC6BAW3.js +2 -0
  8. package/dist/pi/dist/bundle/chunks/bedrock-converse-stream.js +89 -0
  9. package/dist/pi/dist/bundle/chunks/chunk-36QC74V4.js +2 -0
  10. package/dist/pi/dist/bundle/chunks/chunk-3TGLJEWK.js +2 -0
  11. package/dist/pi/dist/bundle/chunks/chunk-44DLKSKE.js +1232 -0
  12. package/dist/pi/dist/bundle/chunks/chunk-4EYXVSA5.js +129 -0
  13. package/dist/pi/dist/bundle/chunks/chunk-5AGIVGSV.js +6 -0
  14. package/dist/pi/dist/bundle/chunks/chunk-62VOPMLK.js +65 -0
  15. package/dist/pi/dist/bundle/chunks/chunk-6QGV3IWD.js +6 -0
  16. package/dist/pi/dist/bundle/chunks/chunk-7CBJINYJ.js +20 -0
  17. package/dist/pi/dist/bundle/chunks/chunk-7DDKXS2Q.js +2 -0
  18. package/dist/pi/dist/bundle/chunks/chunk-7O7QKK6A.js +2 -0
  19. package/dist/pi/dist/bundle/chunks/chunk-7ZC4UXSL.js +2 -0
  20. package/dist/pi/dist/bundle/chunks/chunk-B46VJEHW.js +44 -0
  21. package/dist/pi/dist/bundle/chunks/chunk-C2WU32PX.js +2 -0
  22. package/dist/pi/dist/bundle/chunks/chunk-CF5GWZHW.js +31 -0
  23. package/dist/pi/dist/bundle/chunks/chunk-CHWNPHIS.js +82 -0
  24. package/dist/pi/dist/bundle/chunks/chunk-EBFHJFEE.js +2 -0
  25. package/dist/pi/dist/bundle/chunks/chunk-EOO47QGR.js +2 -0
  26. package/dist/pi/dist/bundle/chunks/chunk-FFMDRXC4.js +10 -0
  27. package/dist/pi/dist/bundle/chunks/chunk-GN3QYODH.js +16 -0
  28. package/dist/pi/dist/bundle/chunks/chunk-JXWJOIH4.js +2 -0
  29. package/dist/pi/dist/bundle/chunks/chunk-L2ZPNLYD.js +2 -0
  30. package/dist/pi/dist/bundle/chunks/chunk-LPXNMA2W.js +2 -0
  31. package/dist/pi/dist/bundle/chunks/chunk-LVVZS2NO.js +12 -0
  32. package/dist/pi/dist/bundle/chunks/chunk-NL4X6LBY.js +4 -0
  33. package/dist/pi/dist/bundle/chunks/chunk-NZY7EIPA.js +4 -0
  34. package/dist/pi/dist/bundle/chunks/chunk-P7FPUEYA.js +2 -0
  35. package/dist/pi/dist/bundle/chunks/chunk-PGXDEOVV.js +2 -0
  36. package/dist/pi/dist/bundle/chunks/chunk-PJACZCIR.js +2 -0
  37. package/dist/pi/dist/bundle/chunks/chunk-PMRZO46Y.js +2 -0
  38. package/dist/pi/dist/bundle/chunks/chunk-PRRNXB7S.js +2 -0
  39. package/dist/pi/dist/bundle/chunks/chunk-R2EGYMOO.js +7 -0
  40. package/dist/pi/dist/bundle/chunks/chunk-RDZVAGPR.js +2 -0
  41. package/dist/pi/dist/bundle/chunks/chunk-TMTOQ7H7.js +2 -0
  42. package/dist/pi/dist/bundle/chunks/chunk-UKVNB6C4.js +2 -0
  43. package/dist/pi/dist/bundle/chunks/chunk-USJZMAIR.js +2 -0
  44. package/dist/pi/dist/bundle/chunks/chunk-UTB4DTYQ.js +2 -0
  45. package/dist/pi/dist/bundle/chunks/chunk-V6KH5QG4.js +9 -0
  46. package/dist/pi/dist/bundle/chunks/chunk-VOLAXWGI.js +2 -0
  47. package/dist/pi/dist/bundle/chunks/chunk-YZKQS34S.js +9 -0
  48. package/dist/pi/dist/bundle/chunks/cli-MCOUW5WS.js +53 -0
  49. package/dist/pi/dist/bundle/chunks/cloudflare-workers-ai-system-one-WLAFJSP6.js +2 -0
  50. package/dist/pi/dist/bundle/chunks/codemode-worker.js +478 -0
  51. package/dist/pi/dist/bundle/chunks/easter-egg-3d-WMBNSJ4M.js +2 -0
  52. package/dist/pi/dist/bundle/chunks/execute-4CEBORGZ.js +505 -0
  53. package/dist/pi/dist/bundle/chunks/github-copilot.js +2 -0
  54. package/dist/pi/dist/bundle/chunks/google-generative-ai-INGKNW72.js +2 -0
  55. package/dist/pi/dist/bundle/chunks/google-vertex-IBTX6MBF.js +2 -0
  56. package/dist/pi/dist/bundle/chunks/https-proxy-agent-LVOO5TPL.js +13 -0
  57. package/dist/pi/dist/bundle/chunks/image-resize-worker.js +2 -0
  58. package/dist/pi/dist/bundle/chunks/jiti-loader-GL4HJFAD.js +21 -0
  59. package/dist/pi/dist/bundle/chunks/jiti-static-loader-2RCDI6B4.js +2 -0
  60. package/dist/pi/dist/bundle/chunks/kimi-coding.js +2 -0
  61. package/dist/pi/dist/bundle/chunks/lib-4AVRLBHM.js +9 -0
  62. package/dist/pi/dist/bundle/chunks/llama-cpp-classify-V5U3QKXI.js +22 -0
  63. package/dist/pi/dist/bundle/chunks/meta.js +2 -0
  64. package/dist/pi/dist/bundle/chunks/mistral-conversations-S4OWXIXQ.js +5 -0
  65. package/dist/pi/dist/bundle/chunks/multipart-parser-FMGQ7342.js +3 -0
  66. package/dist/pi/dist/bundle/chunks/node-AUOGOBCN.js +2 -0
  67. package/dist/pi/dist/bundle/chunks/node-KCMANYC2.js +16 -0
  68. package/dist/pi/dist/bundle/chunks/openai-chatgpt.js +75 -0
  69. package/dist/pi/dist/bundle/chunks/openai-codex-responses-QAWLOQSN.js +10 -0
  70. package/dist/pi/dist/bundle/chunks/openai-codex.js +75 -0
  71. package/dist/pi/dist/bundle/chunks/openai-completions-EJNYB6IX.js +7 -0
  72. package/dist/pi/dist/bundle/chunks/openai-decisions-IXI34BYG.js +5 -0
  73. package/dist/pi/dist/bundle/chunks/openai-responses-MD3562FB.js +4 -0
  74. package/dist/pi/dist/bundle/chunks/openrouter-images-PISKSFMS.js +2 -0
  75. package/dist/pi/dist/bundle/chunks/openrouter.js +75 -0
  76. package/dist/pi/dist/bundle/chunks/pi-messages-NORUKF4E.js +8 -0
  77. package/dist/pi/dist/bundle/chunks/radius.js +75 -0
  78. package/dist/pi/dist/bundle/chunks/runtime-FQB7RU7U.js +2 -0
  79. package/dist/pi/dist/bundle/chunks/src-QKGKDFSU.js +4 -0
  80. package/dist/pi/dist/bundle/chunks/typesafe-system-one-CHVC2UUI.js +2 -0
  81. package/dist/pi/dist/bundle/chunks/virtual-modules-O76XM3OB.js +2 -0
  82. package/dist/pi/dist/bundle/chunks/xai.js +2 -0
  83. package/dist/pi/dist/bundle/cli-runtime.js +3 -0
  84. package/dist/pi/dist/bundle/cli.js +5 -0
  85. package/dist/pi/dist/bundle/index.js +2 -0
  86. package/dist/pi/dist/bundle/rpc-entry.js +3 -0
  87. package/dist/pi/dist/core/export-html/ansi-to-html.js +249 -0
  88. package/dist/pi/dist/core/export-html/index.js +228 -0
  89. package/dist/pi/dist/core/export-html/template.css +1085 -0
  90. package/dist/pi/dist/core/export-html/template.html +56 -0
  91. package/dist/pi/dist/core/export-html/template.js +2044 -0
  92. package/dist/pi/dist/core/export-html/tool-renderer.js +113 -0
  93. package/dist/pi/dist/core/export-html/vendor/highlight.min.js +1213 -0
  94. package/dist/pi/dist/core/export-html/vendor/marked-cjk-friendly.min.js +6 -0
  95. package/dist/pi/dist/core/export-html/vendor/marked.min.js +79 -0
  96. package/dist/pi/dist/modes/interactive/assets/clankolas.png +0 -0
  97. package/dist/pi/dist/modes/interactive/theme/dark.json +78 -0
  98. package/dist/pi/dist/modes/interactive/theme/light.json +78 -0
  99. package/dist/pi/docs/cli-integration.md +106 -0
  100. package/dist/pi/docs/cli.md +343 -0
  101. package/dist/pi/docs/codemode.md +230 -0
  102. package/dist/pi/docs/compaction.md +463 -0
  103. package/dist/pi/docs/configuration.md +47 -0
  104. package/dist/pi/docs/containerization.md +183 -0
  105. package/dist/pi/docs/custom-provider.md +227 -0
  106. package/dist/pi/docs/docs.json +220 -0
  107. package/dist/pi/docs/environment-variables.md +103 -0
  108. package/dist/pi/docs/extensions.md +3347 -0
  109. package/dist/pi/docs/how-pi-works.md +49 -0
  110. package/dist/pi/docs/images/doom-extension.png +0 -0
  111. package/dist/pi/docs/images/exy.png +0 -0
  112. package/dist/pi/docs/images/interactive-mode.png +0 -0
  113. package/dist/pi/docs/images/tree-view.png +0 -0
  114. package/dist/pi/docs/index.md +39 -0
  115. package/dist/pi/docs/json.md +226 -0
  116. package/dist/pi/docs/keybindings.md +195 -0
  117. package/dist/pi/docs/llama-cpp.md +132 -0
  118. package/dist/pi/docs/mcp.md +274 -0
  119. package/dist/pi/docs/message-types.md +279 -0
  120. package/dist/pi/docs/models-configuration.md +196 -0
  121. package/dist/pi/docs/models.md +225 -0
  122. package/dist/pi/docs/nvidia-rtx-llama-cpp.md +96 -0
  123. package/dist/pi/docs/packages.md +153 -0
  124. package/dist/pi/docs/prompt-templates.md +59 -0
  125. package/dist/pi/docs/providers.md +247 -0
  126. package/dist/pi/docs/quickstart.md +140 -0
  127. package/dist/pi/docs/rpc-commands.md +860 -0
  128. package/dist/pi/docs/rpc-extension-ui.md +200 -0
  129. package/dist/pi/docs/rpc.md +193 -0
  130. package/dist/pi/docs/sdk.md +147 -0
  131. package/dist/pi/docs/security.md +99 -0
  132. package/dist/pi/docs/session-format.md +293 -0
  133. package/dist/pi/docs/sessions.md +74 -0
  134. package/dist/pi/docs/settings.md +173 -0
  135. package/dist/pi/docs/shell-aliases.md +93 -0
  136. package/dist/pi/docs/skills.md +93 -0
  137. package/dist/pi/docs/slash-commands.md +61 -0
  138. package/dist/pi/docs/terminal-setup.md +235 -0
  139. package/dist/pi/docs/termux.md +117 -0
  140. package/dist/pi/docs/themes.md +138 -0
  141. package/dist/pi/docs/tmux.md +61 -0
  142. package/dist/pi/docs/tui.md +197 -0
  143. package/dist/pi/docs/usage.md +94 -0
  144. package/dist/pi/docs/virtual-models.md +114 -0
  145. package/dist/pi/docs/windows.md +108 -0
  146. package/dist/pi/examples/README.md +36 -0
  147. package/dist/pi/examples/extensions/README.md +215 -0
  148. package/dist/pi/examples/extensions/auto-commit-on-exit.ts +49 -0
  149. package/dist/pi/examples/extensions/bash-spawn-hook.ts +30 -0
  150. package/dist/pi/examples/extensions/bookmark.ts +50 -0
  151. package/dist/pi/examples/extensions/border-status-editor.ts +150 -0
  152. package/dist/pi/examples/extensions/built-in-tool-renderer.ts +225 -0
  153. package/dist/pi/examples/extensions/claude-rules.ts +86 -0
  154. package/dist/pi/examples/extensions/commands.ts +72 -0
  155. package/dist/pi/examples/extensions/confirm-destructive.ts +59 -0
  156. package/dist/pi/examples/extensions/custom-compaction.ts +117 -0
  157. package/dist/pi/examples/extensions/custom-footer.ts +64 -0
  158. package/dist/pi/examples/extensions/custom-header.ts +73 -0
  159. package/dist/pi/examples/extensions/custom-provider-anthropic/index.ts +613 -0
  160. package/dist/pi/examples/extensions/custom-provider-anthropic/package-lock.json +24 -0
  161. package/dist/pi/examples/extensions/custom-provider-anthropic/package.json +19 -0
  162. package/dist/pi/examples/extensions/custom-provider-gitlab-duo/index.ts +405 -0
  163. package/dist/pi/examples/extensions/custom-provider-gitlab-duo/package.json +16 -0
  164. package/dist/pi/examples/extensions/custom-provider-gitlab-duo/test.ts +82 -0
  165. package/dist/pi/examples/extensions/debug-provider.ts +90 -0
  166. package/dist/pi/examples/extensions/dirty-repo-guard.ts +56 -0
  167. package/dist/pi/examples/extensions/doom-overlay/README.md +46 -0
  168. package/dist/pi/examples/extensions/doom-overlay/doom/build/doom.js +21 -0
  169. package/dist/pi/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
  170. package/dist/pi/examples/extensions/doom-overlay/doom/build.sh +152 -0
  171. package/dist/pi/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +72 -0
  172. package/dist/pi/examples/extensions/doom-overlay/doom-component.ts +132 -0
  173. package/dist/pi/examples/extensions/doom-overlay/doom-engine.ts +173 -0
  174. package/dist/pi/examples/extensions/doom-overlay/doom-keys.ts +104 -0
  175. package/dist/pi/examples/extensions/doom-overlay/index.ts +74 -0
  176. package/dist/pi/examples/extensions/doom-overlay/wad-finder.ts +55 -0
  177. package/dist/pi/examples/extensions/dynamic-resources/SKILL.md +8 -0
  178. package/dist/pi/examples/extensions/dynamic-resources/dynamic.json +81 -0
  179. package/dist/pi/examples/extensions/dynamic-resources/dynamic.md +5 -0
  180. package/dist/pi/examples/extensions/dynamic-resources/index.ts +15 -0
  181. package/dist/pi/examples/extensions/dynamic-tools.ts +74 -0
  182. package/dist/pi/examples/extensions/entry-renderer.ts +41 -0
  183. package/dist/pi/examples/extensions/event-bus.ts +43 -0
  184. package/dist/pi/examples/extensions/file-trigger.ts +41 -0
  185. package/dist/pi/examples/extensions/git-checkpoint.ts +53 -0
  186. package/dist/pi/examples/extensions/git-merge-and-resolve.ts +115 -0
  187. package/dist/pi/examples/extensions/github-issue-autocomplete.ts +185 -0
  188. package/dist/pi/examples/extensions/gondolin/index.ts +531 -0
  189. package/dist/pi/examples/extensions/gondolin/package-lock.json +175 -0
  190. package/dist/pi/examples/extensions/gondolin/package.json +19 -0
  191. package/dist/pi/examples/extensions/handoff.ts +190 -0
  192. package/dist/pi/examples/extensions/hello.ts +26 -0
  193. package/dist/pi/examples/extensions/hidden-thinking-label.ts +53 -0
  194. package/dist/pi/examples/extensions/inline-bash.ts +94 -0
  195. package/dist/pi/examples/extensions/input-transform-streaming.ts +39 -0
  196. package/dist/pi/examples/extensions/input-transform.ts +43 -0
  197. package/dist/pi/examples/extensions/interactive-shell.ts +196 -0
  198. package/dist/pi/examples/extensions/jev-router.ts +113 -0
  199. package/dist/pi/examples/extensions/mac-system-theme.ts +47 -0
  200. package/dist/pi/examples/extensions/message-renderer.ts +59 -0
  201. package/dist/pi/examples/extensions/minimal-mode.ts +353 -0
  202. package/dist/pi/examples/extensions/modal-editor.ts +85 -0
  203. package/dist/pi/examples/extensions/model-status.ts +31 -0
  204. package/dist/pi/examples/extensions/notify.ts +57 -0
  205. package/dist/pi/examples/extensions/overlay-qa-tests.ts +1450 -0
  206. package/dist/pi/examples/extensions/overlay-test.ts +153 -0
  207. package/dist/pi/examples/extensions/permission-gate.ts +34 -0
  208. package/dist/pi/examples/extensions/pirate.ts +47 -0
  209. package/dist/pi/examples/extensions/plan-mode/README.md +66 -0
  210. package/dist/pi/examples/extensions/plan-mode/index.ts +394 -0
  211. package/dist/pi/examples/extensions/plan-mode/utils.ts +168 -0
  212. package/dist/pi/examples/extensions/preset.ts +438 -0
  213. package/dist/pi/examples/extensions/project-trust.ts +64 -0
  214. package/dist/pi/examples/extensions/prompt-customizer.ts +49 -0
  215. package/dist/pi/examples/extensions/protected-paths.ts +30 -0
  216. package/dist/pi/examples/extensions/provider-payload.ts +18 -0
  217. package/dist/pi/examples/extensions/qna.ts +118 -0
  218. package/dist/pi/examples/extensions/question.ts +286 -0
  219. package/dist/pi/examples/extensions/questionnaire.ts +448 -0
  220. package/dist/pi/examples/extensions/rainbow-editor.ts +88 -0
  221. package/dist/pi/examples/extensions/reload-runtime.ts +49 -0
  222. package/dist/pi/examples/extensions/rpc-demo.ts +118 -0
  223. package/dist/pi/examples/extensions/send-user-message.ts +97 -0
  224. package/dist/pi/examples/extensions/session-name.ts +27 -0
  225. package/dist/pi/examples/extensions/shutdown-command.ts +63 -0
  226. package/dist/pi/examples/extensions/snake.ts +343 -0
  227. package/dist/pi/examples/extensions/space-invaders.ts +560 -0
  228. package/dist/pi/examples/extensions/ssh.ts +220 -0
  229. package/dist/pi/examples/extensions/status-line.ts +32 -0
  230. package/dist/pi/examples/extensions/structured-output.ts +65 -0
  231. package/dist/pi/examples/extensions/subagent/README.md +177 -0
  232. package/dist/pi/examples/extensions/subagent/agents/planner.md +37 -0
  233. package/dist/pi/examples/extensions/subagent/agents/reviewer.md +35 -0
  234. package/dist/pi/examples/extensions/subagent/agents/scout.md +50 -0
  235. package/dist/pi/examples/extensions/subagent/agents/worker.md +24 -0
  236. package/dist/pi/examples/extensions/subagent/agents.ts +157 -0
  237. package/dist/pi/examples/extensions/subagent/index.ts +1036 -0
  238. package/dist/pi/examples/extensions/subagent/prompts/implement-and-review.md +10 -0
  239. package/dist/pi/examples/extensions/subagent/prompts/implement.md +10 -0
  240. package/dist/pi/examples/extensions/subagent/prompts/scout-and-plan.md +9 -0
  241. package/dist/pi/examples/extensions/summarize.ts +199 -0
  242. package/dist/pi/examples/extensions/system-prompt-header.ts +17 -0
  243. package/dist/pi/examples/extensions/tic-tac-toe.ts +1008 -0
  244. package/dist/pi/examples/extensions/timed-confirm.ts +70 -0
  245. package/dist/pi/examples/extensions/titlebar-spinner.ts +58 -0
  246. package/dist/pi/examples/extensions/todo.ts +304 -0
  247. package/dist/pi/examples/extensions/tool-override.ts +144 -0
  248. package/dist/pi/examples/extensions/tools.ts +148 -0
  249. package/dist/pi/examples/extensions/trigger-compact.ts +50 -0
  250. package/dist/pi/examples/extensions/truncated-tool.ts +195 -0
  251. package/dist/pi/examples/extensions/widget-placement.ts +9 -0
  252. package/dist/pi/examples/extensions/with-deps/index.ts +32 -0
  253. package/dist/pi/examples/extensions/with-deps/package-lock.json +31 -0
  254. package/dist/pi/examples/extensions/with-deps/package.json +22 -0
  255. package/dist/pi/examples/extensions/working-indicator.ts +123 -0
  256. package/dist/pi/examples/extensions/working-message-test.ts +25 -0
  257. package/dist/pi/examples/rpc-client.ts +35 -0
  258. package/dist/pi/examples/rpc-extension-ui.ts +661 -0
  259. package/dist/pi/examples/sdk/01-minimal.ts +26 -0
  260. package/dist/pi/examples/sdk/02-custom-model.ts +49 -0
  261. package/dist/pi/examples/sdk/03-custom-prompt.ts +75 -0
  262. package/dist/pi/examples/sdk/04-skills.ts +55 -0
  263. package/dist/pi/examples/sdk/05-tools.ts +48 -0
  264. package/dist/pi/examples/sdk/06-extensions.ts +99 -0
  265. package/dist/pi/examples/sdk/07-context-files.ts +47 -0
  266. package/dist/pi/examples/sdk/08-prompt-templates.ts +51 -0
  267. package/dist/pi/examples/sdk/09-api-keys-and-oauth.ts +34 -0
  268. package/dist/pi/examples/sdk/10-settings.ts +53 -0
  269. package/dist/pi/examples/sdk/11-sessions.ts +52 -0
  270. package/dist/pi/examples/sdk/12-full-control.ts +74 -0
  271. package/dist/pi/examples/sdk/13-session-runtime.ts +67 -0
  272. package/dist/pi/examples/sdk/14-codemode-mcp.ts +61 -0
  273. package/dist/pi/examples/sdk/README.md +141 -0
  274. package/dist/pi/examples/tsconfig.json +180 -0
  275. package/dist/pi/node_modules/@silvia-odwyer/photon-node/LICENSE.md +201 -0
  276. package/dist/pi/node_modules/@silvia-odwyer/photon-node/README.md +158 -0
  277. package/dist/pi/node_modules/@silvia-odwyer/photon-node/package.json +23 -0
  278. package/dist/pi/node_modules/@silvia-odwyer/photon-node/photon_rs.d.ts +3226 -0
  279. package/dist/pi/node_modules/@silvia-odwyer/photon-node/photon_rs.js +4521 -0
  280. package/dist/pi/node_modules/@silvia-odwyer/photon-node/photon_rs_bg.js +4270 -0
  281. package/dist/pi/node_modules/@silvia-odwyer/photon-node/photon_rs_bg.wasm +0 -0
  282. package/dist/pi/node_modules/jiti/LICENSE +21 -0
  283. package/dist/pi/node_modules/jiti/README.md +258 -0
  284. package/dist/pi/node_modules/jiti/dist/babel.cjs +257 -0
  285. package/dist/pi/node_modules/jiti/dist/jiti.cjs +1 -0
  286. package/dist/pi/node_modules/jiti/lib/jiti-cli.mjs +34 -0
  287. package/dist/pi/node_modules/jiti/lib/jiti-hooks.mjs +124 -0
  288. package/dist/pi/node_modules/jiti/lib/jiti-native.mjs +121 -0
  289. package/dist/pi/node_modules/jiti/lib/jiti-register.d.mts +1 -0
  290. package/dist/pi/node_modules/jiti/lib/jiti-register.mjs +4 -0
  291. package/dist/pi/node_modules/jiti/lib/jiti-static.mjs +23 -0
  292. package/dist/pi/node_modules/jiti/lib/jiti.cjs +30 -0
  293. package/dist/pi/node_modules/jiti/lib/jiti.d.cts +8 -0
  294. package/dist/pi/node_modules/jiti/lib/jiti.d.mts +8 -0
  295. package/dist/pi/node_modules/jiti/lib/jiti.mjs +29 -0
  296. package/dist/pi/node_modules/jiti/lib/types.d.ts +420 -0
  297. package/dist/pi/node_modules/jiti/package.json +146 -0
  298. package/dist/pi/node_modules/quickjs-wasi/LICENSE +21 -0
  299. package/dist/pi/node_modules/quickjs-wasi/README.md +852 -0
  300. package/dist/pi/node_modules/quickjs-wasi/dist/extensions.d.ts +110 -0
  301. package/dist/pi/node_modules/quickjs-wasi/dist/extensions.d.ts.map +1 -0
  302. package/dist/pi/node_modules/quickjs-wasi/dist/extensions.js +372 -0
  303. package/dist/pi/node_modules/quickjs-wasi/dist/extensions.js.map +1 -0
  304. package/dist/pi/node_modules/quickjs-wasi/dist/index.d.ts +1263 -0
  305. package/dist/pi/node_modules/quickjs-wasi/dist/index.d.ts.map +1 -0
  306. package/dist/pi/node_modules/quickjs-wasi/dist/index.js +2787 -0
  307. package/dist/pi/node_modules/quickjs-wasi/dist/index.js.map +1 -0
  308. package/dist/pi/node_modules/quickjs-wasi/dist/version.d.ts +2 -0
  309. package/dist/pi/node_modules/quickjs-wasi/dist/version.d.ts.map +1 -0
  310. package/dist/pi/node_modules/quickjs-wasi/dist/version.js +3 -0
  311. package/dist/pi/node_modules/quickjs-wasi/dist/version.js.map +1 -0
  312. package/dist/pi/node_modules/quickjs-wasi/dist/wasi-shim.d.ts +61 -0
  313. package/dist/pi/node_modules/quickjs-wasi/dist/wasi-shim.d.ts.map +1 -0
  314. package/dist/pi/node_modules/quickjs-wasi/dist/wasi-shim.js +103 -0
  315. package/dist/pi/node_modules/quickjs-wasi/dist/wasi-shim.js.map +1 -0
  316. package/dist/pi/node_modules/quickjs-wasi/extensions/crypto/crypto.so +0 -0
  317. package/dist/pi/node_modules/quickjs-wasi/extensions/encoding/encoding.so +0 -0
  318. package/dist/pi/node_modules/quickjs-wasi/extensions/headers/headers.so +0 -0
  319. package/dist/pi/node_modules/quickjs-wasi/extensions/structured-clone/structured-clone.so +0 -0
  320. package/dist/pi/node_modules/quickjs-wasi/extensions/url/url.so +0 -0
  321. package/dist/pi/node_modules/quickjs-wasi/package.json +69 -0
  322. package/dist/pi/node_modules/quickjs-wasi/quickjs.wasm +0 -0
  323. package/dist/pi/package.json +9 -0
  324. package/dist/serve/index.mjs +16495 -0
  325. package/package.json +52 -4
package/README.md CHANGED
@@ -1,3 +1,95 @@
1
- # Temporary Holding Version
1
+ # ta
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ 基于 Cell 与 [pi](https://www.npmjs.com/package/@earendil-works/pi-coding-agent) 的 coding agent。`ta` 就是改名为 ta 的 pi:交互界面、`-p`、`--mode json|rpc`、斜杠命令、会话树、扩展、Skills、pi 包都与 pi 一致;另外多两样东西:
4
+
5
+ - **默认用 codemode**:模型通过 `codemode` 写 JavaScript 脚本调用所有工具,可以并行调用、在脚本里过滤大输出,只有脚本的输出进上下文(见下文「pi 补丁」)。
6
+ - **会话锁**:同一个会话文件同时只能被一个 ta 进程写(pi 没有锁,两个进程会交错写入)。
7
+ - **ta 的外观与身份**:终端界面启动时显示 Cell 的像素小恐龙、版本和常用按键(按展开键看全部按键;`quietStartup: true` 时不显示);system prompt、提示文字、MCP 客户端名都说 ta;`/bug` 在浏览器里打开 ta 的 GitHub issue(带版本、模型、平台,不带别的);去掉了依赖 pi 官方服务(Radius)的 `/share`;`/changelog` 显示 ta 的更新记录。pi 面向 pi.dev 的版本检查和安装统计默认关闭(`TA_SKIP_VERSION_CHECK=0`、`TA_TELEMETRY=1` 可打开)。pi 的环境变量在 ta 里叫 `TA_OFFLINE`、`TA_SELF_UPDATE_COMMAND`、`TA_TELEMETRY`,原来的 `PI_*` 名字也照样生效。
8
+ - **`ta serve`**:把 pi 会话通过 WebSocket 提供给任意多个客户端(Web、桌面、手机),见 [@celljs/ta-host](../../ta-packages/ta-host/README.md)。
9
+
10
+ ## 安装
11
+
12
+ ```bash
13
+ npm i -g @celljs/ta # Node.js >= 22.19
14
+ ta # 交互模式
15
+ ta -p "总结这个仓库" # 一次性运行
16
+ ```
17
+
18
+ ## 与 pi 的对应
19
+
20
+ | | pi | ta |
21
+ | --- | --- | --- |
22
+ | 全局目录 | `~/.pi/agent/` | `~/.ta/agent/`(auth.json、models.json、settings.json、sessions/、extensions/ …,内容格式相同) |
23
+ | 项目目录 | `.pi/` | `.ta/`;项目说明仍是 `AGENTS.md` |
24
+ | 环境变量 | `PI_CODING_AGENT_DIR` | `TA_CODING_AGENT_DIR`、`TA_CODING_AGENT_SESSION_DIR` |
25
+ | 子命令 | `install` `remove` `update` `list` `mcp` | 相同,另加 `serve` |
26
+
27
+ pi 的扩展和 pi 包可以直接用:`ta install npm:<包名>`。想复用项目里已有的 `.pi/skills`,在 `.ta/settings.json` 里写 `"skills": ["../.pi/skills"]`。
28
+
29
+ ta 和 pi 一样,默认不在工具调用前请求批准;需要的话安装可选包 [@celljs/ta-permission-gate](../../ta-packages/ta-permission-gate/README.md)。
30
+
31
+ ## ta serve
32
+
33
+ ```bash
34
+ ta serve # 127.0.0.1,随机端口
35
+ ta serve --host 0.0.0.0 --port 4100
36
+ ```
37
+
38
+ 启动后把地址和访问 token 写进 `~/.ta/agent/serve.json`(权限 0600)。`TA_SERVE_TOKEN` 可指定 token(例如由桌面壳生成)。客户端用 [@celljs/ta-client](../../ta-packages/ta-client/README.md) 连接。
39
+
40
+ ## 构建
41
+
42
+ `bun run build` 先用 `cell build --root serve` 把 ta serve 的服务端打成 `dist/serve/index.mjs`,再由 `scripts/assemble.ts` 把 `ta` 命令(ta-harness 的 `TaCli`)打成 `dist/cli.mjs`,并生成 `dist/pi/`:一个把 pi 改名为 ta 的 package.json(`piConfig`),加上 pi 的主题、HTML 导出模板、docs 和 examples。`ta` 启动时让 pi 从这个目录读取品牌信息(`PI_PACKAGE_DIR`),和 pi 官方二进制的目录布局相同。
43
+
44
+ `ta` 运行时用到的都在 `dist/` 里,所以发布的包没有 `dependencies`,装 `ta` 不会再装 Cell 和 pi;构建用到的包都是 `devDependencies`。ta serve 的服务端是 `serve/` 下单独的 Cell 应用(私有,不在 workspaces 里):Cell 只从 `dependencies` 收集组件,它的 `serve/package.json` 列出这些组件,`@celljs/ta` 自己就不必有 `dependencies`。给 ta serve 加组件时,两处都要加(`serve/package.json` 的 `dependencies` 决定打包内容,`package.json` 的 `devDependencies` 决定 turbo 的构建顺序)。
45
+
46
+ `ta` 命令本身不加载 Cell,启动时间和内存与 `pi` 相同;只有 `ta serve` 加载 Cell。
47
+
48
+ ## pi 补丁
49
+
50
+ pi 里写死的品牌文字和 `/bug`、`/share` 两个内置命令,用补丁改:
51
+
52
+ - 补丁是仓库根目录的 `patches/@earendil-works%2Fpi-coding-agent@<版本>.patch`,由 `bun patch` 生成,登记在根 `package.json` 的 `patchedDependencies`,`bun install` 时自动打上。只改 pi 的打包产物 `dist/bundle`(ta 只运行它)。
53
+ - 包管理器的补丁只在本仓库生效,所以构建时 `scripts/assemble.ts` 把打过补丁的 `dist/bundle` 复制进 `dist/pi/dist/bundle` 随包发布(约 9 MB);`ta` 设置 `PI_PACKAGE_DIR` 指向 `dist/pi`,`PiBundleUtil` 就加载这一份。进程里只有这一份 pi,扩展通过它内置的模块表拿到同一个实例。没打补丁时构建直接失败。
54
+ - 打包产物运行时从 node_modules 加载的 `jiti`(加载扩展)、`@silvia-odwyer/photon-node`(图片缩放)和 `quickjs-wasi`(codemode 的 WebAssembly)也由 `scripts/assemble.ts` 从 pi 旁边复制进 `dist/pi/node_modules`,版本与 pi 相同;扩展用到的 `typebox` 和 pi 自己的包走打包产物内置的模块表。构建时会扫描打包产物里按名字加载的包,出现不在这份清单(或可选清单)里的就失败,升级 pi 时照提示补上。
55
+
56
+ 改了什么:
57
+
58
+ | 位置 | 改动 |
59
+ | --- | --- |
60
+ | 内置命令 | 去掉 `/share`(上传到 Radius)和 pi 的 `/bug`(发给 pi 的开发者);`/bug` 由 ta 的扩展提供 |
61
+ | 提示文字 | 崩溃后的 `/bug` 提示、tmux 设置提示、项目信任提示、ChatGPT 登录端口占用提示:pi → ta |
62
+ | 帮助 | `ta -h`、`ta update -h`、`ta auth -h` 里的 pi → ta;环境变量列为 `TA_*`(由 `TaBrand.activate` 转给 pi 的 `PI_*`),去掉 ta 自己设置的 `PI_PACKAGE_DIR` 和随 `/share` 去掉的 `PI_SHARE_VIEWER_URL`;示例里的 MCP 服务 `radius` 换成 `github`;`ta update ta` 与 `ta update self` 同义 |
63
+ | system prompt | 开头改为 ta;pi 文档一节说明 pi 的 `~/.pi/agent`、`.pi/`、`pi` 命令在 ta 里是什么 |
64
+ | MCP | 客户端名 `pi` → `ta` |
65
+ | 默认工具 | 默认工具加上 `codemode`,`codemode.mode` 默认 `only`:模型只看到 `codemode` 一个工具,read / bash / edit / write、扩展工具和 MCP 工具都在脚本里用 `tools.<name>()` 调用。改回 pi 的行为:`settings.json` 写 `"codemode": { "mode": "on" }`(其他工具也直接提供)或 `"defaultTools": ["-codemode"]`(不用 codemode),单次运行用 `--tools -codemode` |
66
+
67
+ 升级 pi 时:改 `ai-packages/ai-coding-agent` 等处的 pi 版本并 `bun install`;补丁按版本登记,新版本没有补丁,`apps/ta` 构建会报"not patched"。这时 `bun patch @earendil-works/pi-coding-agent`,在 `node_modules/@earendil-works/pi-coding-agent/dist/bundle` 里按上表重做修改(旧补丁可作参照),`bun patch --commit node_modules/@earendil-works/pi-coding-agent`,删掉旧补丁,再跑 `bun run test`。`bun patch --commit` 有时会把 `.bun-tag-*` 空文件也记进补丁(以 `diff --git a/node_modules/` 开头的段),提交前删掉这些段。
68
+
69
+ 没有改的:pi 文档正文(system prompt 已告诉模型如何对应)、Radius 登录选项的介绍(那是 pi 官方的服务,文字属实)、设置页"Pi's drawn cursor"和包管理器的一条错误信息(在几十 KB 的长行里,补丁代价大于收益)。
70
+
71
+ ## 性能基准
72
+
73
+ ```bash
74
+ bun run bench # 除长时间场景外全部运行,约 3 分钟,输出 Markdown 表格
75
+ bun run bench streaming # 指定场景;--help 列出全部场景
76
+ ```
77
+
78
+ 基准用本机构建产物(先 `bun run build`),模型是独立进程里的假 OpenAI 兼容服务(`bench/fake-model.ts`:`rate` 首 token 200 ms、每秒 100 个 token;`burst` 尽快输出 5000 个 token)。对照组是 `pi --mode rpc`:pi 要服务多个会话只能每个会话一个进程。内存与 CPU 从进程外用 `ps`(Linux 读 `/proc`)采样,不干扰被测进程。
79
+
80
+ 参考结果(Apple M4 Pro,Node.js 24):
81
+
82
+ | 场景 | pi | ta |
83
+ | --- | --- | --- |
84
+ | `--version` / `-p` | 0.12 s 112 MB / 0.18 s 127 MB | 0.12 s 114 MB / 0.19 s 128 MB |
85
+ | ta serve 空载 | — | 66 MB,空闲 CPU 0 |
86
+ | 32 个会话 | 每会话一个进程,约 127 MB × 32 | 181 MB(每会话约 1.6 MB) |
87
+ | 单会话流式(rate)首 token / CPU | 209 ms / 5% | 209 ms / 5–6% |
88
+ | 10 个会话同时流式 | 1693 MB,4.57 s CPU | 191 MB,1.92 s CPU |
89
+ | 50 个客户端看同一会话 | — | 每客户端每 delta 约 35 µs |
90
+
91
+ `endurance`(长时间场景,需显式指定)在 64 MB 堆上限下连续 60 轮突发输出,检查内存是否收敛。
92
+
93
+ ## 测试
94
+
95
+ `bun run test` 是集成测试:真实构建产物 + 本地假的 OpenAI 兼容模型服务,覆盖 print / JSON 模式、会话锁、安装 pi 包与权限拦截,以及 ta serve 的多客户端广播、断线补发、审批先到先得、幂等回执、会话锁、空闲回收和限流。
package/bin/ta.mjs ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env node
2
+ import { enableCompileCache } from 'node:module';
3
+ import { dirname, join } from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
5
+
6
+ enableCompileCache();
7
+
8
+ const dist = join(dirname(fileURLToPath(import.meta.url)), '..', 'dist');
9
+ const { TaCli } = await import('../dist/cli.mjs');
10
+ await TaCli.run(process.argv.slice(2), { brandDir: join(dist, 'pi'), serveEntry: join(dist, 'serve', 'index.mjs') });
package/dist/cli.mjs ADDED
@@ -0,0 +1,517 @@
1
+ // ../../ta-packages/ta-harness/esm/node/ta-cli.js
2
+ import { parseArgs } from "node:util";
3
+
4
+ // ../../ai-packages/ai-coding-agent/esm/node/pi/pi-bundle-util.js
5
+ import { fileURLToPath as __cellFileURLToPath } from "node:url";
6
+ import { dirname as __cellDirname } from "node:path";
7
+ import { existsSync } from "node:fs";
8
+ import { createRequire } from "node:module";
9
+ import { join } from "node:path";
10
+ import { pathToFileURL } from "node:url";
11
+ var __filename2 = __cellFileURLToPath(import.meta.url);
12
+ var __dirname2 = __cellDirname(__filename2);
13
+ var PiBundleUtil;
14
+ (function(PiBundleUtil2) {
15
+ const PACKAGE = "@earendil-works/pi-coding-agent";
16
+ const BUNDLE = "dist/bundle/index.js";
17
+ function specifier() {
18
+ var _a;
19
+ if (process.versions.bun) {
20
+ return PACKAGE;
21
+ }
22
+ const packageDir = process.env.PI_PACKAGE_DIR;
23
+ if (packageDir && existsSync(join(packageDir, BUNDLE))) {
24
+ return pathToFileURL(join(packageDir, BUNDLE)).href;
25
+ }
26
+ for (const nodeModules of (_a = createRequire(__filename2).resolve.paths(PACKAGE)) !== null && _a !== undefined ? _a : []) {
27
+ const bundle = join(nodeModules, PACKAGE, BUNDLE);
28
+ if (existsSync(bundle)) {
29
+ return pathToFileURL(bundle).href;
30
+ }
31
+ }
32
+ return PACKAGE;
33
+ }
34
+ PiBundleUtil2.specifier = specifier;
35
+ })(PiBundleUtil || (PiBundleUtil = {}));
36
+
37
+ // ../../ta-packages/ta-harness/esm/node/bug-report.js
38
+ import { spawn } from "node:child_process";
39
+ var BugReport;
40
+ (function(BugReport2) {
41
+ BugReport2.ISSUES_URL = "https://github.com/cellbang/cell/issues/new";
42
+ function issueUrl(description, environment) {
43
+ var _a;
44
+ const url = new URL(BugReport2.ISSUES_URL);
45
+ url.searchParams.set("title", `[ta] ${description.trim() || "Describe the bug"}`);
46
+ url.searchParams.set("labels", "ta");
47
+ url.searchParams.set("body", [
48
+ "## What happened",
49
+ "",
50
+ description.trim() || "<!-- What did you do, what did you expect, what happened instead? -->",
51
+ "",
52
+ "## Environment",
53
+ "",
54
+ `- ta ${environment.version}`,
55
+ `- model: ${(_a = environment.model) !== null && _a !== undefined ? _a : "none"}`,
56
+ `- ${environment.platform}, Node.js ${environment.node}`
57
+ ].join(`
58
+ `));
59
+ return url.href;
60
+ }
61
+ BugReport2.issueUrl = issueUrl;
62
+ function currentEnvironment(version, model) {
63
+ return { version, model: model && `${model.provider}/${model.id}`, platform: `${process.platform} ${process.arch}`, node: process.versions.node };
64
+ }
65
+ BugReport2.currentEnvironment = currentEnvironment;
66
+ function open(url) {
67
+ const [command, ...args] = process.platform === "darwin" ? ["open"] : process.platform === "win32" ? ["cmd", "/c", "start", '""'] : ["xdg-open"];
68
+ const child = spawn(command, [...args, url], { detached: true, stdio: "ignore" });
69
+ child.on("error", () => {
70
+ return;
71
+ });
72
+ child.unref();
73
+ }
74
+ BugReport2.open = open;
75
+ })(BugReport || (BugReport = {}));
76
+
77
+ // ../../ta-packages/ta-harness/esm/node/dino-logo.js
78
+ var DinoLogo;
79
+ (function(DinoLogo2) {
80
+ const PIXELS = [
81
+ "........######..",
82
+ ".......########.",
83
+ ".......##.######",
84
+ ".......#########",
85
+ "#......#########",
86
+ "#......####.....",
87
+ "##.....#######..",
88
+ "##....#######...",
89
+ "###..########...",
90
+ ".###########.##.",
91
+ "..##########..#.",
92
+ "...########.....",
93
+ "....######......",
94
+ "....##..##......",
95
+ "....##..##......",
96
+ "...###..###....."
97
+ ];
98
+ DinoLogo2.WIDTH = PIXELS[0].length;
99
+ DinoLogo2.HEIGHT = PIXELS.length / 2;
100
+ const GREEN = { truecolor: "\x1B[38;2;16;185;129m", "256color": "\x1B[38;5;36m" };
101
+ const RESET = "\x1B[39m";
102
+ function lines(mode) {
103
+ const lines2 = [];
104
+ for (let row = 0;row < PIXELS.length; row += 2) {
105
+ let line = "";
106
+ for (let column = 0;column < DinoLogo2.WIDTH; column++) {
107
+ line += cell(PIXELS[row][column] === "#", PIXELS[row + 1][column] === "#");
108
+ }
109
+ lines2.push(paint(mode, line));
110
+ }
111
+ return lines2;
112
+ }
113
+ DinoLogo2.lines = lines;
114
+ function paint(mode, text) {
115
+ return `${GREEN[mode]}${text}${RESET}`;
116
+ }
117
+ DinoLogo2.paint = paint;
118
+ function cell(top, bottom) {
119
+ if (top && bottom) {
120
+ return "█";
121
+ }
122
+ if (top) {
123
+ return "▀";
124
+ }
125
+ return bottom ? "▄" : " ";
126
+ }
127
+ function isSupported(env = process.env) {
128
+ return env.TERM_PROGRAM !== "Apple_Terminal";
129
+ }
130
+ DinoLogo2.isSupported = isSupported;
131
+ })(DinoLogo || (DinoLogo = {}));
132
+
133
+ // ../../ta-packages/ta-harness/esm/node/ta-header.js
134
+ var INDENT = 2;
135
+ var GAP = 4;
136
+ var SEPARATOR = " · ";
137
+ var LOGO_MIN_WIDTH = INDENT + DinoLogo.WIDTH + GAP + 36;
138
+ var COMPACT_HINTS = [
139
+ [
140
+ { key: "app.interrupt", description: "interrupt" },
141
+ { key: "app.clear", description: "clear" },
142
+ { key: "app.exit", description: "exit" }
143
+ ],
144
+ [
145
+ { key: "/", description: "commands", raw: true },
146
+ { key: "!", description: "bash", raw: true },
147
+ { key: "app.tools.expand", description: "more" }
148
+ ]
149
+ ];
150
+ var EXPANDED_HINTS = [
151
+ { key: "app.interrupt", description: "to interrupt" },
152
+ { key: "app.clear", description: "to clear" },
153
+ { key: "app.exit", description: "to exit (empty)" },
154
+ { key: "app.suspend", description: "to suspend" },
155
+ { key: "tui.editor.deleteToLineEnd", description: "to delete to end" },
156
+ { key: "app.thinking.cycle", description: "to cycle thinking level" },
157
+ { key: "app.model.cycleForward", description: "to cycle models" },
158
+ { key: "app.model.select", description: "to select model" },
159
+ { key: "app.tools.expand", description: "to expand tools" },
160
+ { key: "app.thinking.toggle", description: "to expand thinking" },
161
+ { key: "app.editor.external", description: "for external editor" },
162
+ { key: "/", description: "for commands", raw: true },
163
+ { key: "!", description: "to run bash", raw: true },
164
+ { key: "!!", description: "to run bash (no context)", raw: true },
165
+ { key: "app.message.followUp", description: "to queue follow-up" },
166
+ { key: "app.message.dequeue", description: "to edit all queued messages" },
167
+ { key: "app.clipboard.pasteImage", description: "to paste images or files" }
168
+ ];
169
+
170
+ class TaHeader {
171
+ constructor(theme, options) {
172
+ this.theme = theme;
173
+ this.options = options;
174
+ this.expanded = false;
175
+ }
176
+ setExpanded(expanded) {
177
+ this.expanded = expanded;
178
+ }
179
+ invalidate() {}
180
+ render(width) {
181
+ var _a;
182
+ const withLogo = ((_a = this.options.logo) !== null && _a !== undefined ? _a : DinoLogo.isSupported()) && width >= LOGO_MIN_WIDTH;
183
+ const lines = withLogo ? this.besideLogo(width) : this.indented(this.intro(width - INDENT));
184
+ if (this.expanded) {
185
+ lines.push("", ...this.indented(this.keyTable(width - INDENT)));
186
+ }
187
+ lines.push("");
188
+ return lines;
189
+ }
190
+ besideLogo(width) {
191
+ const logo = DinoLogo.lines(this.theme.getColorMode());
192
+ const intro = this.intro(width - INDENT - DinoLogo.WIDTH - GAP);
193
+ const top = Math.max(0, Math.floor((logo.length - intro.length) / 2));
194
+ const pad = " ".repeat(INDENT);
195
+ const gap = " ".repeat(GAP);
196
+ return Array.from({ length: Math.max(logo.length, top + intro.length) }, (_, i) => {
197
+ var _a;
198
+ var _b, _c;
199
+ const text = (_b = (_a = intro[i - top]) === null || _a === undefined ? undefined : _a.text) !== null && _b !== undefined ? _b : "";
200
+ return `${pad}${(_c = logo[i]) !== null && _c !== undefined ? _c : " ".repeat(DinoLogo.WIDTH)}${text ? gap + text : ""}`;
201
+ });
202
+ }
203
+ intro(width) {
204
+ const { theme } = this;
205
+ const title = `ta v${this.options.version}`;
206
+ const green = (text) => DinoLogo.paint(theme.getColorMode(), text);
207
+ return [
208
+ this.span(title, width, (text) => text === title ? `${theme.bold(green("ta"))} ${theme.fg("dim", title.slice(4))}` : green(text)),
209
+ this.span("a coding agent on Cell and pi", width, (text) => theme.fg("muted", text)),
210
+ { text: "", width: 0 },
211
+ ...COMPACT_HINTS.flatMap((group) => this.flow(this.hints(group), width)),
212
+ { text: "", width: 0 },
213
+ this.span("Ask ta how to use or extend it.", width, (text) => theme.fg("dim", text))
214
+ ];
215
+ }
216
+ flow(hints, width) {
217
+ const separator = this.theme.fg("dim", SEPARATOR);
218
+ const lines = [];
219
+ for (const hint of hints) {
220
+ const last = lines[lines.length - 1];
221
+ if (last && last.width + SEPARATOR.length + hint.width <= width) {
222
+ last.text += separator + hint.text;
223
+ last.width += SEPARATOR.length + hint.width;
224
+ } else if (hint.width <= width) {
225
+ lines.push({ ...hint });
226
+ }
227
+ }
228
+ return lines;
229
+ }
230
+ keyTable(width) {
231
+ const hints = this.resolve(EXPANDED_HINTS);
232
+ const keyWidth = Math.max(...hints.map((hint) => hint.keys.length));
233
+ const cellWidth = keyWidth + 2 + Math.max(...hints.map((hint) => hint.description.length));
234
+ const columnWidth = cellWidth + GAP;
235
+ const columns = Math.max(1, Math.floor((width + GAP) / columnWidth));
236
+ const rows = Math.ceil(hints.length / columns);
237
+ const lines = [];
238
+ for (let row = 0;row < rows; row++) {
239
+ const cells = hints.slice(row * columns, row * columns + columns).map((hint) => {
240
+ const description = hint.description.padEnd(cellWidth - keyWidth - 2);
241
+ return `${this.theme.fg("text", hint.keys.padEnd(keyWidth))} ${this.theme.fg("muted", description)}`;
242
+ });
243
+ const lineWidth = cells.length * columnWidth - GAP;
244
+ lines.push(lineWidth <= width ? { text: cells.join(" ".repeat(GAP)), width: lineWidth } : this.span(`${hints[row].keys} ${hints[row].description}`, width, (text) => this.theme.fg("muted", text)));
245
+ }
246
+ return lines;
247
+ }
248
+ hints(hints) {
249
+ return this.resolve(hints).map(({ keys, description }) => ({
250
+ text: `${this.theme.fg("text", keys)} ${this.theme.fg("muted", description)}`,
251
+ width: keys.length + 1 + description.length
252
+ }));
253
+ }
254
+ resolve(hints) {
255
+ return hints.map((hint) => ({ keys: hint.raw ? hint.key : this.options.keyText(hint.key), description: hint.description })).filter((hint) => hint.keys);
256
+ }
257
+ span(plain, width, style) {
258
+ const text = plain.length > width ? `${plain.slice(0, Math.max(0, width - 1))}…` : plain;
259
+ return { text: text ? style(text) : "", width: Math.min(plain.length, width) };
260
+ }
261
+ indented(spans) {
262
+ return spans.map((span) => span.text ? " ".repeat(INDENT) + span.text : "");
263
+ }
264
+ }
265
+
266
+ // ../../ta-packages/ta-harness/esm/node/brand-extension.js
267
+ class BrandExtension {
268
+ constructor(sdk) {
269
+ this.sdk = sdk;
270
+ this.name = "ta:brand";
271
+ }
272
+ register(pi) {
273
+ pi.on("session_start", (_event, ctx) => {
274
+ if (ctx.mode === "tui" && !this.isQuiet(ctx.cwd)) {
275
+ const keyText = this.sdk.keyText;
276
+ ctx.ui.setHeader((_tui, theme) => new TaHeader(theme, { version: this.sdk.VERSION, keyText }));
277
+ }
278
+ });
279
+ pi.registerCommand("bug", {
280
+ description: "Open an issue for ta on GitHub",
281
+ handler: async (args, ctx) => {
282
+ const url = BugReport.issueUrl(args, BugReport.currentEnvironment(this.sdk.VERSION, ctx.model));
283
+ if (ctx.mode === "tui") {
284
+ BugReport.open(url);
285
+ }
286
+ ctx.ui.notify(`A new issue for ta, with its version, the model and the platform and nothing else, opens in the browser. If it did not:
287
+ ${url}`, "info");
288
+ }
289
+ });
290
+ }
291
+ isQuiet(cwd) {
292
+ return this.sdk.SettingsManager.create(cwd, this.sdk.getAgentDir()).getQuietStartup() === true;
293
+ }
294
+ }
295
+
296
+ // ../../ta-packages/ta-harness/esm/node/extensions.js
297
+ var TaExtensionUtil;
298
+ (function(TaExtensionUtil2) {
299
+ function toInline(extension) {
300
+ return { name: extension.name, factory: (pi) => extension.register(pi) };
301
+ }
302
+ TaExtensionUtil2.toInline = toInline;
303
+ function bundle(extensions) {
304
+ return {
305
+ name: "ta",
306
+ factory: (pi) => {
307
+ for (const extension of extensions) {
308
+ extension.register(pi);
309
+ }
310
+ }
311
+ };
312
+ }
313
+ TaExtensionUtil2.bundle = bundle;
314
+ })(TaExtensionUtil || (TaExtensionUtil = {}));
315
+
316
+ class SessionLockExtension {
317
+ constructor(lock) {
318
+ this.lock = lock;
319
+ this.name = "ta:session-lock";
320
+ }
321
+ register(pi) {
322
+ pi.on("session_before_switch", (event) => {
323
+ if (event.targetSessionFile && this.lock.isHeldByOther(event.targetSessionFile)) {
324
+ return { cancel: true };
325
+ }
326
+ return;
327
+ });
328
+ pi.on("session_start", (_event, ctx) => {
329
+ const file = ctx.sessionManager.getSessionFile();
330
+ if (file && !this.lock.acquire(file)) {
331
+ this.refuse(file, ctx);
332
+ }
333
+ });
334
+ pi.on("session_shutdown", (_event, ctx) => {
335
+ const file = ctx.sessionManager.getSessionFile();
336
+ if (file) {
337
+ this.lock.release(file);
338
+ }
339
+ });
340
+ }
341
+ refuse(file, ctx) {
342
+ const message = `This session is open in another ta process. If that process is gone, delete ${this.lock.path(file)}.`;
343
+ if (ctx.mode === "tui") {
344
+ ctx.ui.notify(message, "error");
345
+ ctx.shutdown();
346
+ return;
347
+ }
348
+ process.stderr.write(`${message}
349
+ `);
350
+ process.exit(1);
351
+ }
352
+ }
353
+
354
+ // ../../ta-packages/ta-harness/esm/node/session-lock.js
355
+ import { randomUUID } from "node:crypto";
356
+ import { linkSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
357
+ import { hostname } from "node:os";
358
+ import { dirname } from "node:path";
359
+
360
+ class SessionLock {
361
+ constructor() {
362
+ this.owner = randomUUID();
363
+ this.held = new Set;
364
+ }
365
+ acquire(sessionFile) {
366
+ if (this.held.has(sessionFile)) {
367
+ return true;
368
+ }
369
+ mkdirSync(dirname(sessionFile), { recursive: true });
370
+ for (let attempt = 0;attempt < 2; attempt++) {
371
+ if (this.create(sessionFile)) {
372
+ this.held.add(sessionFile);
373
+ return true;
374
+ }
375
+ if (this.isHeldByOther(sessionFile)) {
376
+ return false;
377
+ }
378
+ rmSync(this.path(sessionFile), { force: true });
379
+ }
380
+ return false;
381
+ }
382
+ isHeldByOther(sessionFile) {
383
+ const lock = this.read(sessionFile);
384
+ return lock !== undefined && lock.owner !== this.owner && this.isAlive(lock);
385
+ }
386
+ release(sessionFile) {
387
+ if (this.held.delete(sessionFile)) {
388
+ rmSync(this.path(sessionFile), { force: true });
389
+ }
390
+ }
391
+ releaseAll() {
392
+ for (const sessionFile of [...this.held]) {
393
+ this.release(sessionFile);
394
+ }
395
+ }
396
+ path(sessionFile) {
397
+ return `${sessionFile}.lock`;
398
+ }
399
+ create(sessionFile) {
400
+ const lock = { owner: this.owner, pid: process.pid, host: hostname(), createdAt: Date.now() };
401
+ const draft = `${this.path(sessionFile)}.${this.owner}`;
402
+ writeFileSync(draft, JSON.stringify(lock));
403
+ try {
404
+ linkSync(draft, this.path(sessionFile));
405
+ return true;
406
+ } catch (error) {
407
+ if (error.code === "EEXIST") {
408
+ return false;
409
+ }
410
+ throw error;
411
+ } finally {
412
+ rmSync(draft, { force: true });
413
+ }
414
+ }
415
+ read(sessionFile) {
416
+ try {
417
+ return JSON.parse(readFileSync(this.path(sessionFile), "utf8"));
418
+ } catch (error) {
419
+ if (error.code === "ENOENT") {
420
+ return;
421
+ }
422
+ throw error;
423
+ }
424
+ }
425
+ isAlive(lock) {
426
+ if (lock.host !== hostname()) {
427
+ return true;
428
+ }
429
+ try {
430
+ process.kill(lock.pid, 0);
431
+ return true;
432
+ } catch (error) {
433
+ return error.code === "EPERM";
434
+ }
435
+ }
436
+ }
437
+
438
+ // ../../ta-packages/ta-harness/esm/node/ta-brand.js
439
+ import { homedir } from "node:os";
440
+ import { join as join2 } from "node:path";
441
+ var TaBrand;
442
+ (function(TaBrand2) {
443
+ TaBrand2.NAME = "ta";
444
+ TaBrand2.ENV_ALIASES = {
445
+ TA_OFFLINE: "PI_OFFLINE",
446
+ TA_SELF_UPDATE_COMMAND: "PI_SELF_UPDATE_COMMAND",
447
+ TA_TELEMETRY: "PI_TELEMETRY",
448
+ TA_SKIP_VERSION_CHECK: "PI_SKIP_VERSION_CHECK"
449
+ };
450
+ function agentDir() {
451
+ var _a;
452
+ return (_a = process.env.TA_CODING_AGENT_DIR) !== null && _a !== undefined ? _a : join2(homedir(), ".ta", "agent");
453
+ }
454
+ TaBrand2.agentDir = agentDir;
455
+ function activate(brandDir) {
456
+ var _a, _b;
457
+ var _c, _d;
458
+ process.env.PI_PACKAGE_DIR = brandDir;
459
+ for (const [ta, pi] of Object.entries(TaBrand2.ENV_ALIASES)) {
460
+ if (process.env[ta] !== undefined) {
461
+ process.env[pi] = process.env[ta];
462
+ }
463
+ }
464
+ (_a = (_c = process.env).PI_SKIP_VERSION_CHECK) !== null && _a !== undefined || (_c.PI_SKIP_VERSION_CHECK = "1");
465
+ (_b = (_d = process.env).PI_TELEMETRY) !== null && _b !== undefined || (_d.PI_TELEMETRY = "0");
466
+ process.env.PI_CODING_AGENT = "true";
467
+ process.env.AI_AGENT = TaBrand2.NAME;
468
+ process.title = TaBrand2.NAME;
469
+ process.emitWarning = () => {
470
+ return;
471
+ };
472
+ }
473
+ TaBrand2.activate = activate;
474
+ })(TaBrand || (TaBrand = {}));
475
+
476
+ // ../../ta-packages/ta-harness/esm/node/ta-cli.js
477
+ var SERVE_HELP = `Usage: ta serve [--host <host>] [--port <port>]
478
+
479
+ Serves pi sessions over WebSocket to any number of clients. Stops on SIGINT or SIGTERM.
480
+
481
+ --host Address to listen on. Default: 127.0.0.1
482
+ --port Port to listen on. Default: a free port
483
+
484
+ The URL and the access token are written to serve.json in the agent directory.
485
+ Set TA_SERVE_TOKEN to choose the token.
486
+ `;
487
+ var TaCli;
488
+ (function(TaCli2) {
489
+ async function run(argv, options) {
490
+ TaBrand.activate(options.brandDir);
491
+ if (argv[0] === "serve") {
492
+ await serve(argv.slice(1), options.serveEntry);
493
+ return;
494
+ }
495
+ const sdk = await import(PiBundleUtil.specifier());
496
+ const builtIn = TaExtensionUtil.bundle([new SessionLockExtension(new SessionLock), new BrandExtension(sdk)]);
497
+ await sdk.main(argv, { extensionFactories: [builtIn] });
498
+ }
499
+ TaCli2.run = run;
500
+ async function serve(argv, entry) {
501
+ const { values } = parseArgs({ args: argv, options: { host: { type: "string" }, port: { type: "string" }, help: { type: "boolean", short: "h" } } });
502
+ if (values.help) {
503
+ process.stdout.write(SERVE_HELP);
504
+ return;
505
+ }
506
+ if (values.host) {
507
+ process.env.CELL_SERVER__HOST = values.host;
508
+ }
509
+ if (values.port) {
510
+ process.env.CELL_SERVER__PORT = values.port;
511
+ }
512
+ await import(entry);
513
+ }
514
+ })(TaCli || (TaCli = {}));
515
+ export {
516
+ TaCli
517
+ };
@@ -0,0 +1,32 @@
1
+ # @celljs/ta
2
+
3
+ ## 4.5.1
4
+
5
+ ### Patch Changes
6
+
7
+ - f4bcde1: ta 不再有 dependencies:`ta` 命令打包为 `dist/cli.mjs`,pi 打包产物运行时需要的 jiti、photon-node、quickjs-wasi 随包放在 `dist/pi/node_modules`,安装 ta 不再连带安装 Cell 和 pi
8
+
9
+ ## 4.5.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 70b250e: New: ta, a coding agent on pi. The `ta` command is pi renamed (`~/.ta/agent`, `.ta/`, same modes, commands, extensions and packages) with a session lock; `ta serve` serves pi sessions over WebSocket to many clients, with event replay on reconnect, dialogs answered by the first client, idempotent prompts and idle session cleanup. `@celljs/ai-coding-agent` loads pi's bundled build on Node.js (about 6 times faster to import, 30 MB less) and exports `AgentToolUtil`. `@celljs/rpc` adds `RpcWebSocketGuard` to refuse WebSocket connections on the upgrade request, and no longer crashes when a refused client hangs up early.
14
+
15
+ ### Patch Changes
16
+
17
+ - 04c7f88: ta looks and speaks as ta: the terminal UI starts with Cell's pixel dinosaur, the version and the keys that matter first (all of pi's keys when expanded; none with `quietStartup: true`); the system prompt says the model runs inside ta and maps pi's documentation to ta's directories and command; `/changelog` shows ta's changes. pi's update check and install telemetry, which report to pi.dev about pi releases, are off unless `PI_SKIP_VERSION_CHECK` / `PI_TELEMETRY` say otherwise. ta's built-in extensions are listed as one extension, `ta`.
18
+ - 37f1e78: ta calls every tool through codemode by default: its patch of pi adds `codemode` to the default tools and makes `codemode.mode` default to `only`, so the model is offered `codemode` alone and reaches read, bash, edit, write, extension and MCP tools from scripts. `"codemode": { "mode": "on" }` or `--tools -codemode` / `"defaultTools": ["-codemode"]` bring pi's behavior back. Sessions of `ta serve` now load pi's built-in codemode, tool search and MCP extensions as the `ta` command does; stdio MCP servers start in the execution environment when it is not this machine.
19
+ - 48698c1: `ta serve` no longer holds the first token of a reply for the 30 ms batching interval: only streamed events (`message_update`, `tool_execution_update`) are batched, the first of them leaves at once, and other events (a message starts, a tool ends, a dialog opens) leave at once. Its first token now arrives with pi's own. `apps/ta` has benchmarks against pi: `bun run bench`.
20
+ - c249cfd: ta ships pi's bundled build patched for ta (`bun patch`, `patches/`): pi's `/share` (Radius) and `/bug` (reports to pi's developers) are gone, and ta's `/bug` opens a GitHub issue for ta with its version, the model and the platform; the system prompt, hints, messages and the help of `ta` and its commands say ta, with pi's environment variables listed as `TA_OFFLINE`, `TA_SELF_UPDATE_COMMAND` and `TA_TELEMETRY` (the `PI_*` names still work); MCP servers see the client `ta`. `ta` loads that build through `PI_PACKAGE_DIR`: `PiBundleUtil` of `@celljs/ai-coding-agent` now prefers a bundle in that directory. The system prompt is no longer rewritten at run time.
21
+ - Updated dependencies [04c7f88]
22
+ - Updated dependencies [37f1e78]
23
+ - Updated dependencies [70b250e]
24
+ - Updated dependencies [48698c1]
25
+ - Updated dependencies [c249cfd]
26
+ - @celljs/ta-harness@4.5.0
27
+ - @celljs/ta-host@4.5.0
28
+ - @celljs/ai-coding-agent@4.5.0
29
+ - @celljs/rpc@4.5.0
30
+ - @celljs/core@4.5.0
31
+ - @celljs/express-adapter@4.5.0
32
+ - @celljs/web@4.5.0