pi-usereq 0.49.0 → 0.51.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 (940) hide show
  1. package/README.md +1 -1
  2. package/package.json +5 -1
  3. package/scripts/lib/extension-debug-harness.ts +443 -0
  4. package/scripts/lib/recording-extension-api.ts +855 -0
  5. package/scripts/lib/sdk-smoke.ts +503 -0
  6. package/src/core/extension-status.ts +13 -4
  7. package/src/index.ts +105 -71
  8. package/.g.conf +0 -16
  9. package/.github/workflows/release-npm.yml +0 -134
  10. package/.gitignore +0 -274
  11. package/CHANGELOG.md +0 -706
  12. package/TODO.md +0 -20
  13. package/docs/pi.dev/agent-document-manifest.json +0 -6399
  14. package/docs/pi.dev/coding-agent-docs/compaction.md +0 -394
  15. package/docs/pi.dev/coding-agent-docs/custom-provider.md +0 -637
  16. package/docs/pi.dev/coding-agent-docs/development.md +0 -71
  17. package/docs/pi.dev/coding-agent-docs/extensions.md +0 -2536
  18. package/docs/pi.dev/coding-agent-docs/images/doom-extension.png +0 -0
  19. package/docs/pi.dev/coding-agent-docs/images/exy.png +0 -0
  20. package/docs/pi.dev/coding-agent-docs/images/interactive-mode.png +0 -0
  21. package/docs/pi.dev/coding-agent-docs/images/tree-view.png +0 -0
  22. package/docs/pi.dev/coding-agent-docs/json.md +0 -82
  23. package/docs/pi.dev/coding-agent-docs/keybindings.md +0 -197
  24. package/docs/pi.dev/coding-agent-docs/models.md +0 -395
  25. package/docs/pi.dev/coding-agent-docs/packages.md +0 -218
  26. package/docs/pi.dev/coding-agent-docs/prompt-templates.md +0 -88
  27. package/docs/pi.dev/coding-agent-docs/providers.md +0 -196
  28. package/docs/pi.dev/coding-agent-docs/rpc.md +0 -1407
  29. package/docs/pi.dev/coding-agent-docs/sdk.md +0 -1149
  30. package/docs/pi.dev/coding-agent-docs/session.md +0 -412
  31. package/docs/pi.dev/coding-agent-docs/settings.md +0 -248
  32. package/docs/pi.dev/coding-agent-docs/shell-aliases.md +0 -13
  33. package/docs/pi.dev/coding-agent-docs/skills.md +0 -232
  34. package/docs/pi.dev/coding-agent-docs/terminal-setup.md +0 -106
  35. package/docs/pi.dev/coding-agent-docs/termux.md +0 -127
  36. package/docs/pi.dev/coding-agent-docs/themes.md +0 -295
  37. package/docs/pi.dev/coding-agent-docs/tmux.md +0 -61
  38. package/docs/pi.dev/coding-agent-docs/tree.md +0 -233
  39. package/docs/pi.dev/coding-agent-docs/tui.md +0 -918
  40. package/docs/pi.dev/coding-agent-docs/windows.md +0 -17
  41. package/docs/pi.dev/mom-docs/artifacts-server.md +0 -475
  42. package/docs/pi.dev/mom-docs/events.md +0 -307
  43. package/docs/pi.dev/mom-docs/new.md +0 -970
  44. package/docs/pi.dev/mom-docs/sandbox.md +0 -153
  45. package/docs/pi.dev/mom-docs/slack-bot-minimal-guide.md +0 -399
  46. package/docs/pi.dev/mom-docs/v86.md +0 -319
  47. package/docs/pi.dev/pods-docs/gml-4.5.md +0 -189
  48. package/docs/pi.dev/pods-docs/gpt-oss.md +0 -233
  49. package/docs/pi.dev/pods-docs/implementation-plan.md +0 -183
  50. package/docs/pi.dev/pods-docs/kimi-k2.md +0 -197
  51. package/docs/pi.dev/pods-docs/models.md +0 -116
  52. package/docs/pi.dev/pods-docs/plan.md +0 -166
  53. package/docs/pi.dev/pods-docs/qwen3-coder.md +0 -132
  54. package/images/flowchart-bw.png +0 -0
  55. package/images/flowchart-bw.svg +0 -102
  56. package/images/flowchart.md +0 -100
  57. package/images/flowchart.png +0 -0
  58. package/images/flowchart.svg +0 -3
  59. package/pi-usereq/docs/REFERENCES.md +0 -5713
  60. package/pi-usereq/docs/REQUIREMENTS.md +0 -781
  61. package/pi-usereq/docs/WORKFLOW.md +0 -1341
  62. package/pi.dev-src/pi-mono/agent/src/agent-loop.ts +0 -683
  63. package/pi.dev-src/pi-mono/agent/src/agent.ts +0 -543
  64. package/pi.dev-src/pi-mono/agent/src/index.ts +0 -8
  65. package/pi.dev-src/pi-mono/agent/src/proxy.ts +0 -367
  66. package/pi.dev-src/pi-mono/agent/src/types.ts +0 -364
  67. package/pi.dev-src/pi-mono/agent/test/agent-loop.test.ts +0 -1181
  68. package/pi.dev-src/pi-mono/agent/test/agent.test.ts +0 -463
  69. package/pi.dev-src/pi-mono/agent/test/e2e.test.ts +0 -404
  70. package/pi.dev-src/pi-mono/agent/test/utils/calculate.ts +0 -32
  71. package/pi.dev-src/pi-mono/agent/test/utils/get-current-time.ts +0 -46
  72. package/pi.dev-src/pi-mono/agent/vitest.config.ts +0 -9
  73. package/pi.dev-src/pi-mono/ai/bedrock-provider.d.ts +0 -1
  74. package/pi.dev-src/pi-mono/ai/bedrock-provider.js +0 -1
  75. package/pi.dev-src/pi-mono/ai/scripts/generate-models.ts +0 -1635
  76. package/pi.dev-src/pi-mono/ai/scripts/generate-test-image.ts +0 -34
  77. package/pi.dev-src/pi-mono/ai/src/api-registry.ts +0 -98
  78. package/pi.dev-src/pi-mono/ai/src/bedrock-provider.ts +0 -6
  79. package/pi.dev-src/pi-mono/ai/src/cli.ts +0 -133
  80. package/pi.dev-src/pi-mono/ai/src/env-api-keys.ts +0 -134
  81. package/pi.dev-src/pi-mono/ai/src/index.ts +0 -35
  82. package/pi.dev-src/pi-mono/ai/src/models.generated.ts +0 -14928
  83. package/pi.dev-src/pi-mono/ai/src/models.ts +0 -82
  84. package/pi.dev-src/pi-mono/ai/src/oauth.ts +0 -1
  85. package/pi.dev-src/pi-mono/ai/src/providers/amazon-bedrock.ts +0 -929
  86. package/pi.dev-src/pi-mono/ai/src/providers/anthropic.ts +0 -1125
  87. package/pi.dev-src/pi-mono/ai/src/providers/azure-openai-responses.ts +0 -253
  88. package/pi.dev-src/pi-mono/ai/src/providers/faux.ts +0 -499
  89. package/pi.dev-src/pi-mono/ai/src/providers/github-copilot-headers.ts +0 -37
  90. package/pi.dev-src/pi-mono/ai/src/providers/google-gemini-cli.ts +0 -996
  91. package/pi.dev-src/pi-mono/ai/src/providers/google-shared.ts +0 -354
  92. package/pi.dev-src/pi-mono/ai/src/providers/google-vertex.ts +0 -543
  93. package/pi.dev-src/pi-mono/ai/src/providers/google.ts +0 -500
  94. package/pi.dev-src/pi-mono/ai/src/providers/mistral.ts +0 -629
  95. package/pi.dev-src/pi-mono/ai/src/providers/openai-codex-responses.ts +0 -984
  96. package/pi.dev-src/pi-mono/ai/src/providers/openai-completions.ts +0 -1063
  97. package/pi.dev-src/pi-mono/ai/src/providers/openai-responses-shared.ts +0 -539
  98. package/pi.dev-src/pi-mono/ai/src/providers/openai-responses.ts +0 -264
  99. package/pi.dev-src/pi-mono/ai/src/providers/register-builtins.ts +0 -433
  100. package/pi.dev-src/pi-mono/ai/src/providers/simple-options.ts +0 -47
  101. package/pi.dev-src/pi-mono/ai/src/providers/transform-messages.ts +0 -220
  102. package/pi.dev-src/pi-mono/ai/src/stream.ts +0 -59
  103. package/pi.dev-src/pi-mono/ai/src/types.ts +0 -417
  104. package/pi.dev-src/pi-mono/ai/src/utils/event-stream.ts +0 -87
  105. package/pi.dev-src/pi-mono/ai/src/utils/hash.ts +0 -13
  106. package/pi.dev-src/pi-mono/ai/src/utils/headers.ts +0 -7
  107. package/pi.dev-src/pi-mono/ai/src/utils/json-parse.ts +0 -124
  108. package/pi.dev-src/pi-mono/ai/src/utils/overflow.ts +0 -138
  109. package/pi.dev-src/pi-mono/ai/src/utils/sanitize-unicode.ts +0 -25
  110. package/pi.dev-src/pi-mono/ai/src/utils/typebox-helpers.ts +0 -24
  111. package/pi.dev-src/pi-mono/ai/src/utils/validation.ts +0 -324
  112. package/pi.dev-src/pi-mono/ai/test/abort.test.ts +0 -260
  113. package/pi.dev-src/pi-mono/ai/test/anthropic-oauth.test.ts +0 -99
  114. package/pi.dev-src/pi-mono/ai/test/anthropic-opus-4-7-smoke.test.ts +0 -72
  115. package/pi.dev-src/pi-mono/ai/test/anthropic-sse-parsing.test.ts +0 -113
  116. package/pi.dev-src/pi-mono/ai/test/anthropic-thinking-disable.test.ts +0 -152
  117. package/pi.dev-src/pi-mono/ai/test/anthropic-tool-name-normalization.test.ts +0 -205
  118. package/pi.dev-src/pi-mono/ai/test/azure-utils.ts +0 -28
  119. package/pi.dev-src/pi-mono/ai/test/bedrock-endpoint-resolution.test.ts +0 -131
  120. package/pi.dev-src/pi-mono/ai/test/bedrock-models.test.ts +0 -66
  121. package/pi.dev-src/pi-mono/ai/test/bedrock-thinking-payload.test.ts +0 -107
  122. package/pi.dev-src/pi-mono/ai/test/bedrock-utils.ts +0 -18
  123. package/pi.dev-src/pi-mono/ai/test/cache-retention.test.ts +0 -335
  124. package/pi.dev-src/pi-mono/ai/test/context-overflow.test.ts +0 -714
  125. package/pi.dev-src/pi-mono/ai/test/cross-provider-handoff.test.ts +0 -458
  126. package/pi.dev-src/pi-mono/ai/test/data/red-circle.png +0 -0
  127. package/pi.dev-src/pi-mono/ai/test/empty.test.ts +0 -742
  128. package/pi.dev-src/pi-mono/ai/test/faux-provider.test.ts +0 -597
  129. package/pi.dev-src/pi-mono/ai/test/fireworks-models.test.ts +0 -49
  130. package/pi.dev-src/pi-mono/ai/test/github-copilot-anthropic.test.ts +0 -108
  131. package/pi.dev-src/pi-mono/ai/test/github-copilot-oauth.test.ts +0 -196
  132. package/pi.dev-src/pi-mono/ai/test/google-gemini-cli-claude-thinking-header.test.ts +0 -103
  133. package/pi.dev-src/pi-mono/ai/test/google-gemini-cli-empty-stream.test.ts +0 -108
  134. package/pi.dev-src/pi-mono/ai/test/google-gemini-cli-retry-delay.test.ts +0 -53
  135. package/pi.dev-src/pi-mono/ai/test/google-shared-convert-tools.test.ts +0 -187
  136. package/pi.dev-src/pi-mono/ai/test/google-shared-gemini3-unsigned-tool-call.test.ts +0 -172
  137. package/pi.dev-src/pi-mono/ai/test/google-shared-image-tool-result-routing.test.ts +0 -124
  138. package/pi.dev-src/pi-mono/ai/test/google-thinking-disable.test.ts +0 -183
  139. package/pi.dev-src/pi-mono/ai/test/google-thinking-signature.test.ts +0 -38
  140. package/pi.dev-src/pi-mono/ai/test/google-tool-call-missing-args.test.ts +0 -105
  141. package/pi.dev-src/pi-mono/ai/test/google-vertex-api-key-resolution.test.ts +0 -144
  142. package/pi.dev-src/pi-mono/ai/test/image-tool-result.test.ts +0 -481
  143. package/pi.dev-src/pi-mono/ai/test/interleaved-thinking.test.ts +0 -145
  144. package/pi.dev-src/pi-mono/ai/test/lazy-module-load.test.ts +0 -102
  145. package/pi.dev-src/pi-mono/ai/test/mistral-reasoning-mode.test.ts +0 -66
  146. package/pi.dev-src/pi-mono/ai/test/mistral-tool-schema.test.ts +0 -61
  147. package/pi.dev-src/pi-mono/ai/test/oauth.ts +0 -89
  148. package/pi.dev-src/pi-mono/ai/test/openai-codex-cache-affinity-e2e.test.ts +0 -36
  149. package/pi.dev-src/pi-mono/ai/test/openai-codex-stream.test.ts +0 -686
  150. package/pi.dev-src/pi-mono/ai/test/openai-completions-cache-control-format.test.ts +0 -189
  151. package/pi.dev-src/pi-mono/ai/test/openai-completions-prompt-cache.test.ts +0 -198
  152. package/pi.dev-src/pi-mono/ai/test/openai-completions-thinking-as-text.test.ts +0 -214
  153. package/pi.dev-src/pi-mono/ai/test/openai-completions-tool-choice.test.ts +0 -560
  154. package/pi.dev-src/pi-mono/ai/test/openai-completions-tool-result-images.test.ts +0 -101
  155. package/pi.dev-src/pi-mono/ai/test/openai-responses-cache-affinity-e2e.test.ts +0 -32
  156. package/pi.dev-src/pi-mono/ai/test/openai-responses-copilot-provider.test.ts +0 -128
  157. package/pi.dev-src/pi-mono/ai/test/openai-responses-foreign-toolcall-id.test.ts +0 -66
  158. package/pi.dev-src/pi-mono/ai/test/openai-responses-partial-json-cleanup.test.ts +0 -101
  159. package/pi.dev-src/pi-mono/ai/test/openai-responses-reasoning-replay-e2e.test.ts +0 -292
  160. package/pi.dev-src/pi-mono/ai/test/openai-responses-tool-result-images.test.ts +0 -200
  161. package/pi.dev-src/pi-mono/ai/test/openrouter-cache-write-repro.test.ts +0 -78
  162. package/pi.dev-src/pi-mono/ai/test/overflow.test.ts +0 -64
  163. package/pi.dev-src/pi-mono/ai/test/responseid.test.ts +0 -145
  164. package/pi.dev-src/pi-mono/ai/test/stream.test.ts +0 -1405
  165. package/pi.dev-src/pi-mono/ai/test/supports-xhigh.test.ts +0 -34
  166. package/pi.dev-src/pi-mono/ai/test/tokens.test.ts +0 -304
  167. package/pi.dev-src/pi-mono/ai/test/tool-call-id-normalization.test.ts +0 -291
  168. package/pi.dev-src/pi-mono/ai/test/tool-call-without-result.test.ts +0 -313
  169. package/pi.dev-src/pi-mono/ai/test/total-tokens.test.ts +0 -695
  170. package/pi.dev-src/pi-mono/ai/test/transform-messages-copilot-openai-to-anthropic.test.ts +0 -191
  171. package/pi.dev-src/pi-mono/ai/test/unicode-surrogate.test.ts +0 -754
  172. package/pi.dev-src/pi-mono/ai/test/validation.test.ts +0 -116
  173. package/pi.dev-src/pi-mono/ai/test/xhigh.test.ts +0 -71
  174. package/pi.dev-src/pi-mono/ai/test/zen.test.ts +0 -25
  175. package/pi.dev-src/pi-mono/ai/vitest.config.ts +0 -9
  176. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/antigravity-image-gen.ts +0 -418
  177. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/auto-commit-on-exit.ts +0 -49
  178. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/bash-spawn-hook.ts +0 -30
  179. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/bookmark.ts +0 -50
  180. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/built-in-tool-renderer.ts +0 -249
  181. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/claude-rules.ts +0 -86
  182. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/commands.ts +0 -72
  183. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/confirm-destructive.ts +0 -59
  184. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/custom-compaction.ts +0 -127
  185. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/custom-footer.ts +0 -64
  186. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/custom-header.ts +0 -73
  187. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/custom-provider-anthropic/index.ts +0 -604
  188. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/custom-provider-anthropic/package-lock.json +0 -24
  189. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/custom-provider-gitlab-duo/index.ts +0 -349
  190. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/custom-provider-gitlab-duo/test.ts +0 -82
  191. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/custom-provider-qwen-cli/index.ts +0 -345
  192. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/dirty-repo-guard.ts +0 -56
  193. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/doom-overlay/doom/build.sh +0 -152
  194. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +0 -72
  195. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/doom-overlay/doom-component.ts +0 -132
  196. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/doom-overlay/doom-engine.ts +0 -173
  197. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/doom-overlay/doom-keys.ts +0 -104
  198. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/doom-overlay/index.ts +0 -74
  199. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/doom-overlay/wad-finder.ts +0 -51
  200. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/dynamic-resources/SKILL.md +0 -8
  201. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/dynamic-resources/dynamic.json +0 -79
  202. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/dynamic-resources/dynamic.md +0 -5
  203. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/dynamic-resources/index.ts +0 -15
  204. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/dynamic-tools.ts +0 -74
  205. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/event-bus.ts +0 -43
  206. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/file-trigger.ts +0 -41
  207. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/git-checkpoint.ts +0 -53
  208. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/github-issue-autocomplete.ts +0 -185
  209. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/handoff.ts +0 -153
  210. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/hello.ts +0 -26
  211. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/hidden-thinking-label.ts +0 -53
  212. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/inline-bash.ts +0 -94
  213. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/input-transform.ts +0 -43
  214. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/interactive-shell.ts +0 -196
  215. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/mac-system-theme.ts +0 -47
  216. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/message-renderer.ts +0 -59
  217. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/minimal-mode.ts +0 -426
  218. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/modal-editor.ts +0 -85
  219. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/model-status.ts +0 -31
  220. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/notify.ts +0 -55
  221. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/overlay-qa-tests.ts +0 -1348
  222. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/overlay-test.ts +0 -150
  223. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/permission-gate.ts +0 -34
  224. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/pirate.ts +0 -47
  225. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/plan-mode/index.ts +0 -340
  226. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/plan-mode/utils.ts +0 -168
  227. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/preset.ts +0 -430
  228. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/prompt-customizer.ts +0 -97
  229. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/protected-paths.ts +0 -30
  230. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/provider-payload.ts +0 -18
  231. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/qna.ts +0 -122
  232. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/question.ts +0 -264
  233. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/questionnaire.ts +0 -427
  234. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/rainbow-editor.ts +0 -88
  235. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/reload-runtime.ts +0 -37
  236. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/rpc-demo.ts +0 -118
  237. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/sandbox/index.ts +0 -321
  238. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/sandbox/package-lock.json +0 -92
  239. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/send-user-message.ts +0 -97
  240. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/session-name.ts +0 -27
  241. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/shutdown-command.ts +0 -63
  242. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/snake.ts +0 -343
  243. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/space-invaders.ts +0 -560
  244. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/ssh.ts +0 -220
  245. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/status-line.ts +0 -32
  246. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/structured-output.ts +0 -65
  247. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/subagent/agents/planner.md +0 -37
  248. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/subagent/agents/reviewer.md +0 -35
  249. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/subagent/agents/scout.md +0 -50
  250. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/subagent/agents/worker.md +0 -24
  251. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/subagent/agents.ts +0 -126
  252. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/subagent/index.ts +0 -987
  253. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/subagent/prompts/implement-and-review.md +0 -10
  254. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/subagent/prompts/implement.md +0 -10
  255. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/subagent/prompts/scout-and-plan.md +0 -9
  256. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/summarize.ts +0 -206
  257. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/system-prompt-header.ts +0 -17
  258. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/tic-tac-toe.ts +0 -1008
  259. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/timed-confirm.ts +0 -70
  260. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/titlebar-spinner.ts +0 -58
  261. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/todo.ts +0 -297
  262. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/tool-override.ts +0 -144
  263. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/tools.ts +0 -141
  264. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/trigger-compact.ts +0 -50
  265. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/truncated-tool.ts +0 -195
  266. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/widget-placement.ts +0 -9
  267. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/with-deps/index.ts +0 -32
  268. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/with-deps/package-lock.json +0 -31
  269. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/working-indicator.ts +0 -123
  270. package/pi.dev-src/pi-mono/coding-agent/examples/extensions/working-message-test.ts +0 -25
  271. package/pi.dev-src/pi-mono/coding-agent/examples/rpc-extension-ui.ts +0 -632
  272. package/pi.dev-src/pi-mono/coding-agent/examples/sdk/01-minimal.ts +0 -22
  273. package/pi.dev-src/pi-mono/coding-agent/examples/sdk/02-custom-model.ts +0 -49
  274. package/pi.dev-src/pi-mono/coding-agent/examples/sdk/03-custom-prompt.ts +0 -62
  275. package/pi.dev-src/pi-mono/coding-agent/examples/sdk/04-skills.ts +0 -55
  276. package/pi.dev-src/pi-mono/coding-agent/examples/sdk/05-tools.ts +0 -44
  277. package/pi.dev-src/pi-mono/coding-agent/examples/sdk/06-extensions.ts +0 -90
  278. package/pi.dev-src/pi-mono/coding-agent/examples/sdk/07-context-files.ts +0 -42
  279. package/pi.dev-src/pi-mono/coding-agent/examples/sdk/08-prompt-templates.ts +0 -51
  280. package/pi.dev-src/pi-mono/coding-agent/examples/sdk/09-api-keys-and-oauth.ts +0 -48
  281. package/pi.dev-src/pi-mono/coding-agent/examples/sdk/10-settings.ts +0 -53
  282. package/pi.dev-src/pi-mono/coding-agent/examples/sdk/11-sessions.ts +0 -48
  283. package/pi.dev-src/pi-mono/coding-agent/examples/sdk/12-full-control.ts +0 -73
  284. package/pi.dev-src/pi-mono/coding-agent/examples/sdk/13-session-runtime.ts +0 -67
  285. package/pi.dev-src/pi-mono/coding-agent/scripts/migrate-sessions.sh +0 -93
  286. package/pi.dev-src/pi-mono/coding-agent/src/bun/cli.ts +0 -6
  287. package/pi.dev-src/pi-mono/coding-agent/src/bun/register-bedrock.ts +0 -4
  288. package/pi.dev-src/pi-mono/coding-agent/src/cli/args.ts +0 -335
  289. package/pi.dev-src/pi-mono/coding-agent/src/cli/config-selector.ts +0 -52
  290. package/pi.dev-src/pi-mono/coding-agent/src/cli/file-processor.ts +0 -100
  291. package/pi.dev-src/pi-mono/coding-agent/src/cli/initial-message.ts +0 -43
  292. package/pi.dev-src/pi-mono/coding-agent/src/cli/list-models.ts +0 -110
  293. package/pi.dev-src/pi-mono/coding-agent/src/cli/session-picker.ts +0 -52
  294. package/pi.dev-src/pi-mono/coding-agent/src/cli.ts +0 -17
  295. package/pi.dev-src/pi-mono/coding-agent/src/config.ts +0 -261
  296. package/pi.dev-src/pi-mono/coding-agent/src/core/agent-session-runtime.ts +0 -394
  297. package/pi.dev-src/pi-mono/coding-agent/src/core/agent-session-services.ts +0 -196
  298. package/pi.dev-src/pi-mono/coding-agent/src/core/agent-session.ts +0 -3096
  299. package/pi.dev-src/pi-mono/coding-agent/src/core/auth-storage.ts +0 -493
  300. package/pi.dev-src/pi-mono/coding-agent/src/core/bash-executor.ts +0 -154
  301. package/pi.dev-src/pi-mono/coding-agent/src/core/compaction/branch-summarization.ts +0 -355
  302. package/pi.dev-src/pi-mono/coding-agent/src/core/compaction/compaction.ts +0 -839
  303. package/pi.dev-src/pi-mono/coding-agent/src/core/compaction/index.ts +0 -7
  304. package/pi.dev-src/pi-mono/coding-agent/src/core/compaction/utils.ts +0 -170
  305. package/pi.dev-src/pi-mono/coding-agent/src/core/defaults.ts +0 -3
  306. package/pi.dev-src/pi-mono/coding-agent/src/core/diagnostics.ts +0 -15
  307. package/pi.dev-src/pi-mono/coding-agent/src/core/event-bus.ts +0 -33
  308. package/pi.dev-src/pi-mono/coding-agent/src/core/exec.ts +0 -107
  309. package/pi.dev-src/pi-mono/coding-agent/src/core/export-html/ansi-to-html.ts +0 -258
  310. package/pi.dev-src/pi-mono/coding-agent/src/core/export-html/index.ts +0 -314
  311. package/pi.dev-src/pi-mono/coding-agent/src/core/export-html/template.css +0 -1017
  312. package/pi.dev-src/pi-mono/coding-agent/src/core/export-html/template.html +0 -55
  313. package/pi.dev-src/pi-mono/coding-agent/src/core/export-html/template.js +0 -1770
  314. package/pi.dev-src/pi-mono/coding-agent/src/core/export-html/tool-renderer.ts +0 -158
  315. package/pi.dev-src/pi-mono/coding-agent/src/core/export-html/vendor/highlight.min.js +0 -1213
  316. package/pi.dev-src/pi-mono/coding-agent/src/core/export-html/vendor/marked.min.js +0 -6
  317. package/pi.dev-src/pi-mono/coding-agent/src/core/extensions/index.ts +0 -171
  318. package/pi.dev-src/pi-mono/coding-agent/src/core/extensions/loader.ts +0 -606
  319. package/pi.dev-src/pi-mono/coding-agent/src/core/extensions/runner.ts +0 -1019
  320. package/pi.dev-src/pi-mono/coding-agent/src/core/extensions/types.ts +0 -1542
  321. package/pi.dev-src/pi-mono/coding-agent/src/core/extensions/wrapper.ts +0 -30
  322. package/pi.dev-src/pi-mono/coding-agent/src/core/footer-data-provider.ts +0 -354
  323. package/pi.dev-src/pi-mono/coding-agent/src/core/index.ts +0 -77
  324. package/pi.dev-src/pi-mono/coding-agent/src/core/keybindings.ts +0 -370
  325. package/pi.dev-src/pi-mono/coding-agent/src/core/messages.ts +0 -195
  326. package/pi.dev-src/pi-mono/coding-agent/src/core/model-registry.ts +0 -858
  327. package/pi.dev-src/pi-mono/coding-agent/src/core/model-resolver.ts +0 -629
  328. package/pi.dev-src/pi-mono/coding-agent/src/core/output-guard.ts +0 -74
  329. package/pi.dev-src/pi-mono/coding-agent/src/core/package-manager.ts +0 -2408
  330. package/pi.dev-src/pi-mono/coding-agent/src/core/prompt-templates.ts +0 -296
  331. package/pi.dev-src/pi-mono/coding-agent/src/core/resolve-config-value.ts +0 -142
  332. package/pi.dev-src/pi-mono/coding-agent/src/core/resource-loader.ts +0 -917
  333. package/pi.dev-src/pi-mono/coding-agent/src/core/sdk.ts +0 -380
  334. package/pi.dev-src/pi-mono/coding-agent/src/core/session-cwd.ts +0 -59
  335. package/pi.dev-src/pi-mono/coding-agent/src/core/session-manager.ts +0 -1425
  336. package/pi.dev-src/pi-mono/coding-agent/src/core/settings-manager.ts +0 -999
  337. package/pi.dev-src/pi-mono/coding-agent/src/core/skills.ts +0 -508
  338. package/pi.dev-src/pi-mono/coding-agent/src/core/slash-commands.ts +0 -39
  339. package/pi.dev-src/pi-mono/coding-agent/src/core/source-info.ts +0 -40
  340. package/pi.dev-src/pi-mono/coding-agent/src/core/system-prompt.ts +0 -172
  341. package/pi.dev-src/pi-mono/coding-agent/src/core/telemetry.ts +0 -13
  342. package/pi.dev-src/pi-mono/coding-agent/src/core/timings.ts +0 -31
  343. package/pi.dev-src/pi-mono/coding-agent/src/core/tools/bash.ts +0 -448
  344. package/pi.dev-src/pi-mono/coding-agent/src/core/tools/edit-diff.ts +0 -445
  345. package/pi.dev-src/pi-mono/coding-agent/src/core/tools/edit.ts +0 -487
  346. package/pi.dev-src/pi-mono/coding-agent/src/core/tools/file-mutation-queue.ts +0 -39
  347. package/pi.dev-src/pi-mono/coding-agent/src/core/tools/find.ts +0 -370
  348. package/pi.dev-src/pi-mono/coding-agent/src/core/tools/grep.ts +0 -384
  349. package/pi.dev-src/pi-mono/coding-agent/src/core/tools/index.ts +0 -196
  350. package/pi.dev-src/pi-mono/coding-agent/src/core/tools/ls.ts +0 -229
  351. package/pi.dev-src/pi-mono/coding-agent/src/core/tools/path-utils.ts +0 -94
  352. package/pi.dev-src/pi-mono/coding-agent/src/core/tools/read.ts +0 -273
  353. package/pi.dev-src/pi-mono/coding-agent/src/core/tools/render-utils.ts +0 -64
  354. package/pi.dev-src/pi-mono/coding-agent/src/core/tools/tool-definition-wrapper.ts +0 -45
  355. package/pi.dev-src/pi-mono/coding-agent/src/core/tools/truncate.ts +0 -265
  356. package/pi.dev-src/pi-mono/coding-agent/src/core/tools/write.ts +0 -281
  357. package/pi.dev-src/pi-mono/coding-agent/src/index.ts +0 -352
  358. package/pi.dev-src/pi-mono/coding-agent/src/main.ts +0 -731
  359. package/pi.dev-src/pi-mono/coding-agent/src/migrations.ts +0 -314
  360. package/pi.dev-src/pi-mono/coding-agent/src/modes/index.ts +0 -9
  361. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/assets/clankolas.png +0 -0
  362. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/armin.ts +0 -382
  363. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/assistant-message.ts +0 -147
  364. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/bash-execution.ts +0 -218
  365. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/bordered-loader.ts +0 -68
  366. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/branch-summary-message.ts +0 -58
  367. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/compaction-summary-message.ts +0 -59
  368. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/config-selector.ts +0 -592
  369. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/countdown-timer.ts +0 -38
  370. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/custom-editor.ts +0 -80
  371. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/custom-message.ts +0 -99
  372. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/daxnuts.ts +0 -164
  373. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/diff.ts +0 -147
  374. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/dynamic-border.ts +0 -25
  375. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/earendil-announcement.ts +0 -53
  376. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/extension-editor.ts +0 -147
  377. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/extension-input.ts +0 -87
  378. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/extension-selector.ts +0 -107
  379. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/footer.ts +0 -220
  380. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/index.ts +0 -32
  381. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/keybinding-hints.ts +0 -24
  382. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/login-dialog.ts +0 -178
  383. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/model-selector.ts +0 -338
  384. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/oauth-selector.ts +0 -121
  385. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/scoped-models-selector.ts +0 -355
  386. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/session-selector-search.ts +0 -194
  387. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/session-selector.ts +0 -1026
  388. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/settings-selector.ts +0 -456
  389. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/show-images-selector.ts +0 -50
  390. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/skill-invocation-message.ts +0 -55
  391. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/theme-selector.ts +0 -67
  392. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/thinking-selector.ts +0 -74
  393. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/tool-execution.ts +0 -352
  394. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/tree-selector.ts +0 -1246
  395. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/user-message-selector.ts +0 -155
  396. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/user-message.ts +0 -35
  397. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/components/visual-truncate.ts +0 -50
  398. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/interactive-mode.ts +0 -5155
  399. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/theme/dark.json +0 -85
  400. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/theme/light.json +0 -84
  401. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/theme/theme-schema.json +0 -335
  402. package/pi.dev-src/pi-mono/coding-agent/src/modes/interactive/theme/theme.ts +0 -1141
  403. package/pi.dev-src/pi-mono/coding-agent/src/modes/print-mode.ts +0 -158
  404. package/pi.dev-src/pi-mono/coding-agent/src/modes/rpc/jsonl.ts +0 -58
  405. package/pi.dev-src/pi-mono/coding-agent/src/modes/rpc/rpc-client.ts +0 -515
  406. package/pi.dev-src/pi-mono/coding-agent/src/modes/rpc/rpc-mode.ts +0 -745
  407. package/pi.dev-src/pi-mono/coding-agent/src/modes/rpc/rpc-types.ts +0 -264
  408. package/pi.dev-src/pi-mono/coding-agent/src/package-manager-cli.ts +0 -270
  409. package/pi.dev-src/pi-mono/coding-agent/src/utils/changelog.ts +0 -99
  410. package/pi.dev-src/pi-mono/coding-agent/src/utils/child-process.ts +0 -86
  411. package/pi.dev-src/pi-mono/coding-agent/src/utils/clipboard-image.ts +0 -300
  412. package/pi.dev-src/pi-mono/coding-agent/src/utils/clipboard-native.ts +0 -22
  413. package/pi.dev-src/pi-mono/coding-agent/src/utils/clipboard.ts +0 -81
  414. package/pi.dev-src/pi-mono/coding-agent/src/utils/exif-orientation.ts +0 -183
  415. package/pi.dev-src/pi-mono/coding-agent/src/utils/frontmatter.ts +0 -39
  416. package/pi.dev-src/pi-mono/coding-agent/src/utils/fs-watch.ts +0 -30
  417. package/pi.dev-src/pi-mono/coding-agent/src/utils/git.ts +0 -192
  418. package/pi.dev-src/pi-mono/coding-agent/src/utils/image-convert.ts +0 -41
  419. package/pi.dev-src/pi-mono/coding-agent/src/utils/image-resize.ts +0 -176
  420. package/pi.dev-src/pi-mono/coding-agent/src/utils/mime.ts +0 -30
  421. package/pi.dev-src/pi-mono/coding-agent/src/utils/paths.ts +0 -20
  422. package/pi.dev-src/pi-mono/coding-agent/src/utils/photon.ts +0 -139
  423. package/pi.dev-src/pi-mono/coding-agent/src/utils/shell.ts +0 -210
  424. package/pi.dev-src/pi-mono/coding-agent/src/utils/sleep.ts +0 -18
  425. package/pi.dev-src/pi-mono/coding-agent/src/utils/tools-manager.ts +0 -287
  426. package/pi.dev-src/pi-mono/coding-agent/test/agent-session-auto-compaction-queue.test.ts +0 -437
  427. package/pi.dev-src/pi-mono/coding-agent/test/agent-session-branching.test.ts +0 -156
  428. package/pi.dev-src/pi-mono/coding-agent/test/agent-session-compaction.test.ts +0 -208
  429. package/pi.dev-src/pi-mono/coding-agent/test/agent-session-concurrent.test.ts +0 -618
  430. package/pi.dev-src/pi-mono/coding-agent/test/agent-session-dynamic-provider.test.ts +0 -117
  431. package/pi.dev-src/pi-mono/coding-agent/test/agent-session-dynamic-tools.test.ts +0 -182
  432. package/pi.dev-src/pi-mono/coding-agent/test/agent-session-retry.test.ts +0 -318
  433. package/pi.dev-src/pi-mono/coding-agent/test/agent-session-runtime-events.test.ts +0 -208
  434. package/pi.dev-src/pi-mono/coding-agent/test/agent-session-stats.test.ts +0 -143
  435. package/pi.dev-src/pi-mono/coding-agent/test/agent-session-tree-navigation.test.ts +0 -323
  436. package/pi.dev-src/pi-mono/coding-agent/test/args.test.ts +0 -328
  437. package/pi.dev-src/pi-mono/coding-agent/test/assistant-message.test.ts +0 -57
  438. package/pi.dev-src/pi-mono/coding-agent/test/auth-storage.test.ts +0 -462
  439. package/pi.dev-src/pi-mono/coding-agent/test/bash-close-hang-windows.test.ts +0 -126
  440. package/pi.dev-src/pi-mono/coding-agent/test/bash-execution-width.test.ts +0 -80
  441. package/pi.dev-src/pi-mono/coding-agent/test/block-images.test.ts +0 -120
  442. package/pi.dev-src/pi-mono/coding-agent/test/clipboard-image-bmp-conversion.test.ts +0 -88
  443. package/pi.dev-src/pi-mono/coding-agent/test/clipboard-image.test.ts +0 -136
  444. package/pi.dev-src/pi-mono/coding-agent/test/compaction-extensions-example.test.ts +0 -66
  445. package/pi.dev-src/pi-mono/coding-agent/test/compaction-extensions.test.ts +0 -415
  446. package/pi.dev-src/pi-mono/coding-agent/test/compaction-serialization.test.ts +0 -79
  447. package/pi.dev-src/pi-mono/coding-agent/test/compaction-summary-reasoning.test.ts +0 -118
  448. package/pi.dev-src/pi-mono/coding-agent/test/compaction-thinking-model.test.ts +0 -223
  449. package/pi.dev-src/pi-mono/coding-agent/test/compaction.test.ts +0 -550
  450. package/pi.dev-src/pi-mono/coding-agent/test/config.test.ts +0 -30
  451. package/pi.dev-src/pi-mono/coding-agent/test/edit-tool-legacy-input.test.ts +0 -116
  452. package/pi.dev-src/pi-mono/coding-agent/test/edit-tool-no-full-redraw.test.ts +0 -235
  453. package/pi.dev-src/pi-mono/coding-agent/test/export-html-whitespace.test.ts +0 -12
  454. package/pi.dev-src/pi-mono/coding-agent/test/export-html-xss.test.ts +0 -28
  455. package/pi.dev-src/pi-mono/coding-agent/test/extensions-discovery.test.ts +0 -463
  456. package/pi.dev-src/pi-mono/coding-agent/test/extensions-input-event.test.ts +0 -112
  457. package/pi.dev-src/pi-mono/coding-agent/test/extensions-runner.test.ts +0 -805
  458. package/pi.dev-src/pi-mono/coding-agent/test/file-mutation-queue.test.ts +0 -163
  459. package/pi.dev-src/pi-mono/coding-agent/test/fixtures/assistant-message-with-thinking-code.json +0 -33
  460. package/pi.dev-src/pi-mono/coding-agent/test/fixtures/before-compaction.jsonl +0 -1003
  461. package/pi.dev-src/pi-mono/coding-agent/test/fixtures/empty-agent/.gitkeep +0 -0
  462. package/pi.dev-src/pi-mono/coding-agent/test/fixtures/empty-cwd/.gitkeep +0 -0
  463. package/pi.dev-src/pi-mono/coding-agent/test/fixtures/large-session.jsonl +0 -1019
  464. package/pi.dev-src/pi-mono/coding-agent/test/fixtures/skills/consecutive-hyphens/SKILL.md +0 -8
  465. package/pi.dev-src/pi-mono/coding-agent/test/fixtures/skills/disable-model-invocation/SKILL.md +0 -9
  466. package/pi.dev-src/pi-mono/coding-agent/test/fixtures/skills/invalid-name-chars/SKILL.md +0 -8
  467. package/pi.dev-src/pi-mono/coding-agent/test/fixtures/skills/invalid-yaml/SKILL.md +0 -8
  468. package/pi.dev-src/pi-mono/coding-agent/test/fixtures/skills/long-name/SKILL.md +0 -8
  469. package/pi.dev-src/pi-mono/coding-agent/test/fixtures/skills/missing-description/SKILL.md +0 -7
  470. package/pi.dev-src/pi-mono/coding-agent/test/fixtures/skills/multiline-description/SKILL.md +0 -11
  471. package/pi.dev-src/pi-mono/coding-agent/test/fixtures/skills/name-mismatch/SKILL.md +0 -8
  472. package/pi.dev-src/pi-mono/coding-agent/test/fixtures/skills/nested/child-skill/SKILL.md +0 -8
  473. package/pi.dev-src/pi-mono/coding-agent/test/fixtures/skills/no-frontmatter/SKILL.md +0 -3
  474. package/pi.dev-src/pi-mono/coding-agent/test/fixtures/skills/root-skill-preferred/SKILL.md +0 -3
  475. package/pi.dev-src/pi-mono/coding-agent/test/fixtures/skills/root-skill-preferred/nested-child/SKILL.md +0 -3
  476. package/pi.dev-src/pi-mono/coding-agent/test/fixtures/skills/unknown-field/SKILL.md +0 -10
  477. package/pi.dev-src/pi-mono/coding-agent/test/fixtures/skills/valid-skill/SKILL.md +0 -8
  478. package/pi.dev-src/pi-mono/coding-agent/test/fixtures/skills-collision/first/calendar/SKILL.md +0 -8
  479. package/pi.dev-src/pi-mono/coding-agent/test/fixtures/skills-collision/second/calendar/SKILL.md +0 -8
  480. package/pi.dev-src/pi-mono/coding-agent/test/footer-data-provider.test.ts +0 -265
  481. package/pi.dev-src/pi-mono/coding-agent/test/footer-width.test.ts +0 -115
  482. package/pi.dev-src/pi-mono/coding-agent/test/frontmatter.test.ts +0 -60
  483. package/pi.dev-src/pi-mono/coding-agent/test/git-ssh-url.test.ts +0 -78
  484. package/pi.dev-src/pi-mono/coding-agent/test/git-update.test.ts +0 -411
  485. package/pi.dev-src/pi-mono/coding-agent/test/image-processing.test.ts +0 -145
  486. package/pi.dev-src/pi-mono/coding-agent/test/image-resize-callers.test.ts +0 -53
  487. package/pi.dev-src/pi-mono/coding-agent/test/initial-message.test.ts +0 -48
  488. package/pi.dev-src/pi-mono/coding-agent/test/interactive-mode-anthropic-warning.test.ts +0 -73
  489. package/pi.dev-src/pi-mono/coding-agent/test/interactive-mode-clone-command.test.ts +0 -77
  490. package/pi.dev-src/pi-mono/coding-agent/test/interactive-mode-compaction.test.ts +0 -57
  491. package/pi.dev-src/pi-mono/coding-agent/test/interactive-mode-import-command.test.ts +0 -144
  492. package/pi.dev-src/pi-mono/coding-agent/test/interactive-mode-status.test.ts +0 -635
  493. package/pi.dev-src/pi-mono/coding-agent/test/interactive-mode-suspend.test.ts +0 -149
  494. package/pi.dev-src/pi-mono/coding-agent/test/keybindings-migration.test.ts +0 -88
  495. package/pi.dev-src/pi-mono/coding-agent/test/model-registry.test.ts +0 -1209
  496. package/pi.dev-src/pi-mono/coding-agent/test/model-resolver.test.ts +0 -436
  497. package/pi.dev-src/pi-mono/coding-agent/test/package-command-paths.test.ts +0 -144
  498. package/pi.dev-src/pi-mono/coding-agent/test/package-manager-ssh.test.ts +0 -97
  499. package/pi.dev-src/pi-mono/coding-agent/test/package-manager.test.ts +0 -1795
  500. package/pi.dev-src/pi-mono/coding-agent/test/path-utils.test.ts +0 -162
  501. package/pi.dev-src/pi-mono/coding-agent/test/plan-mode-utils.test.ts +0 -261
  502. package/pi.dev-src/pi-mono/coding-agent/test/print-mode.test.ts +0 -140
  503. package/pi.dev-src/pi-mono/coding-agent/test/prompt-templates.test.ts +0 -515
  504. package/pi.dev-src/pi-mono/coding-agent/test/resource-loader.test.ts +0 -576
  505. package/pi.dev-src/pi-mono/coding-agent/test/rpc-client-clone.test.ts +0 -29
  506. package/pi.dev-src/pi-mono/coding-agent/test/rpc-example.ts +0 -86
  507. package/pi.dev-src/pi-mono/coding-agent/test/rpc-jsonl.test.ts +0 -65
  508. package/pi.dev-src/pi-mono/coding-agent/test/rpc-prompt-response-semantics.test.ts +0 -285
  509. package/pi.dev-src/pi-mono/coding-agent/test/rpc.test.ts +0 -321
  510. package/pi.dev-src/pi-mono/coding-agent/test/sdk-codex-cache-probe-tool-loop.ts +0 -364
  511. package/pi.dev-src/pi-mono/coding-agent/test/sdk-openrouter-attribution.test.ts +0 -181
  512. package/pi.dev-src/pi-mono/coding-agent/test/sdk-session-manager.test.ts +0 -95
  513. package/pi.dev-src/pi-mono/coding-agent/test/sdk-skills.test.ts +0 -109
  514. package/pi.dev-src/pi-mono/coding-agent/test/session-cwd.test.ts +0 -91
  515. package/pi.dev-src/pi-mono/coding-agent/test/session-info-modified-timestamp.test.ts +0 -83
  516. package/pi.dev-src/pi-mono/coding-agent/test/session-manager/build-context.test.ts +0 -268
  517. package/pi.dev-src/pi-mono/coding-agent/test/session-manager/custom-session-id.test.ts +0 -109
  518. package/pi.dev-src/pi-mono/coding-agent/test/session-manager/file-operations.test.ts +0 -208
  519. package/pi.dev-src/pi-mono/coding-agent/test/session-manager/labels.test.ts +0 -198
  520. package/pi.dev-src/pi-mono/coding-agent/test/session-manager/migration.test.ts +0 -78
  521. package/pi.dev-src/pi-mono/coding-agent/test/session-manager/save-entry.test.ts +0 -55
  522. package/pi.dev-src/pi-mono/coding-agent/test/session-manager/tree-traversal.test.ts +0 -533
  523. package/pi.dev-src/pi-mono/coding-agent/test/session-selector-path-delete.test.ts +0 -315
  524. package/pi.dev-src/pi-mono/coding-agent/test/session-selector-rename.test.ts +0 -111
  525. package/pi.dev-src/pi-mono/coding-agent/test/session-selector-search.test.ts +0 -195
  526. package/pi.dev-src/pi-mono/coding-agent/test/settings-manager-bug.test.ts +0 -147
  527. package/pi.dev-src/pi-mono/coding-agent/test/settings-manager.test.ts +0 -319
  528. package/pi.dev-src/pi-mono/coding-agent/test/skills.test.ts +0 -432
  529. package/pi.dev-src/pi-mono/coding-agent/test/stdout-cleanliness.test.ts +0 -103
  530. package/pi.dev-src/pi-mono/coding-agent/test/streaming-render-debug.ts +0 -97
  531. package/pi.dev-src/pi-mono/coding-agent/test/suite/agent-session-bash-persistence.test.ts +0 -242
  532. package/pi.dev-src/pi-mono/coding-agent/test/suite/agent-session-compaction.test.ts +0 -343
  533. package/pi.dev-src/pi-mono/coding-agent/test/suite/agent-session-model-extension.test.ts +0 -325
  534. package/pi.dev-src/pi-mono/coding-agent/test/suite/agent-session-prompt.test.ts +0 -323
  535. package/pi.dev-src/pi-mono/coding-agent/test/suite/agent-session-queue.test.ts +0 -422
  536. package/pi.dev-src/pi-mono/coding-agent/test/suite/agent-session-retry-events.test.ts +0 -358
  537. package/pi.dev-src/pi-mono/coding-agent/test/suite/agent-session-runtime.test.ts +0 -553
  538. package/pi.dev-src/pi-mono/coding-agent/test/suite/harness.ts +0 -208
  539. package/pi.dev-src/pi-mono/coding-agent/test/suite/regressions/2023-queued-slash-command-followup.test.ts +0 -80
  540. package/pi.dev-src/pi-mono/coding-agent/test/suite/regressions/2753-reload-stale-resource-settings.test.ts +0 -100
  541. package/pi.dev-src/pi-mono/coding-agent/test/suite/regressions/2781-skill-collision-precedence.test.ts +0 -120
  542. package/pi.dev-src/pi-mono/coding-agent/test/suite/regressions/2791-fswatch-error-crash.test.ts +0 -106
  543. package/pi.dev-src/pi-mono/coding-agent/test/suite/regressions/2835-tools-allowlist-filters-extension-tools.test.ts +0 -94
  544. package/pi.dev-src/pi-mono/coding-agent/test/suite/regressions/2860-replaced-session-context.test.ts +0 -274
  545. package/pi.dev-src/pi-mono/coding-agent/test/suite/regressions/3217-scoped-model-order.test.ts +0 -104
  546. package/pi.dev-src/pi-mono/coding-agent/test/suite/regressions/3302-find-path-glob.test.ts +0 -72
  547. package/pi.dev-src/pi-mono/coding-agent/test/suite/regressions/3303-find-nested-gitignore.test.ts +0 -83
  548. package/pi.dev-src/pi-mono/coding-agent/test/suite/regressions/3317-network-connection-lost-retry.test.ts +0 -33
  549. package/pi.dev-src/pi-mono/coding-agent/test/system-prompt.test.ts +0 -102
  550. package/pi.dev-src/pi-mono/coding-agent/test/test-harness.test.ts +0 -321
  551. package/pi.dev-src/pi-mono/coding-agent/test/test-harness.ts +0 -446
  552. package/pi.dev-src/pi-mono/coding-agent/test/test-theme-colors.ts +0 -246
  553. package/pi.dev-src/pi-mono/coding-agent/test/theme-export.test.ts +0 -104
  554. package/pi.dev-src/pi-mono/coding-agent/test/tool-execution-component.test.ts +0 -331
  555. package/pi.dev-src/pi-mono/coding-agent/test/tools.test.ts +0 -889
  556. package/pi.dev-src/pi-mono/coding-agent/test/tree-selector.test.ts +0 -655
  557. package/pi.dev-src/pi-mono/coding-agent/test/trigger-compact-extension.test.ts +0 -57
  558. package/pi.dev-src/pi-mono/coding-agent/test/truncate-to-width.test.ts +0 -81
  559. package/pi.dev-src/pi-mono/coding-agent/test/user-message.test.ts +0 -25
  560. package/pi.dev-src/pi-mono/coding-agent/test/utilities.ts +0 -316
  561. package/pi.dev-src/pi-mono/coding-agent/tsconfig.examples.json +0 -16
  562. package/pi.dev-src/pi-mono/coding-agent/vitest.config.ts +0 -26
  563. package/pi.dev-src/pi-mono/mom/dev.sh +0 -30
  564. package/pi.dev-src/pi-mono/mom/docker.sh +0 -95
  565. package/pi.dev-src/pi-mono/mom/scripts/migrate-timestamps.ts +0 -121
  566. package/pi.dev-src/pi-mono/mom/src/agent.ts +0 -882
  567. package/pi.dev-src/pi-mono/mom/src/context.ts +0 -180
  568. package/pi.dev-src/pi-mono/mom/src/download.ts +0 -117
  569. package/pi.dev-src/pi-mono/mom/src/events.ts +0 -442
  570. package/pi.dev-src/pi-mono/mom/src/fs-watch.ts +0 -30
  571. package/pi.dev-src/pi-mono/mom/src/log.ts +0 -271
  572. package/pi.dev-src/pi-mono/mom/src/main.ts +0 -367
  573. package/pi.dev-src/pi-mono/mom/src/sandbox.ts +0 -221
  574. package/pi.dev-src/pi-mono/mom/src/slack.ts +0 -623
  575. package/pi.dev-src/pi-mono/mom/src/store.ts +0 -234
  576. package/pi.dev-src/pi-mono/mom/src/tools/attach.ts +0 -47
  577. package/pi.dev-src/pi-mono/mom/src/tools/bash.ts +0 -97
  578. package/pi.dev-src/pi-mono/mom/src/tools/edit.ts +0 -165
  579. package/pi.dev-src/pi-mono/mom/src/tools/index.ts +0 -19
  580. package/pi.dev-src/pi-mono/mom/src/tools/read.ts +0 -159
  581. package/pi.dev-src/pi-mono/mom/src/tools/truncate.ts +0 -236
  582. package/pi.dev-src/pi-mono/mom/src/tools/write.ts +0 -45
  583. package/pi.dev-src/pi-mono/mom/test/events.test.ts +0 -50
  584. package/pi.dev-src/pi-mono/pods/scripts/model_run.sh +0 -83
  585. package/pi.dev-src/pi-mono/pods/scripts/pod_setup.sh +0 -336
  586. package/pi.dev-src/pi-mono/pods/src/cli.ts +0 -360
  587. package/pi.dev-src/pi-mono/pods/src/commands/models.ts +0 -753
  588. package/pi.dev-src/pi-mono/pods/src/commands/pods.ts +0 -205
  589. package/pi.dev-src/pi-mono/pods/src/commands/prompt.ts +0 -84
  590. package/pi.dev-src/pi-mono/pods/src/config.ts +0 -80
  591. package/pi.dev-src/pi-mono/pods/src/index.ts +0 -2
  592. package/pi.dev-src/pi-mono/pods/src/model-configs.ts +0 -111
  593. package/pi.dev-src/pi-mono/pods/src/models.json +0 -295
  594. package/pi.dev-src/pi-mono/pods/src/ssh.ts +0 -151
  595. package/pi.dev-src/pi-mono/pods/src/types.ts +0 -27
  596. package/pi.dev-src/pi-mono/tui/src/autocomplete.ts +0 -783
  597. package/pi.dev-src/pi-mono/tui/src/components/box.ts +0 -137
  598. package/pi.dev-src/pi-mono/tui/src/components/cancellable-loader.ts +0 -40
  599. package/pi.dev-src/pi-mono/tui/src/components/editor.ts +0 -2280
  600. package/pi.dev-src/pi-mono/tui/src/components/image.ts +0 -104
  601. package/pi.dev-src/pi-mono/tui/src/components/input.ts +0 -503
  602. package/pi.dev-src/pi-mono/tui/src/components/loader.ts +0 -86
  603. package/pi.dev-src/pi-mono/tui/src/components/markdown.ts +0 -852
  604. package/pi.dev-src/pi-mono/tui/src/components/select-list.ts +0 -229
  605. package/pi.dev-src/pi-mono/tui/src/components/settings-list.ts +0 -250
  606. package/pi.dev-src/pi-mono/tui/src/components/spacer.ts +0 -28
  607. package/pi.dev-src/pi-mono/tui/src/components/text.ts +0 -106
  608. package/pi.dev-src/pi-mono/tui/src/components/truncated-text.ts +0 -65
  609. package/pi.dev-src/pi-mono/tui/src/editor-component.ts +0 -74
  610. package/pi.dev-src/pi-mono/tui/src/fuzzy.ts +0 -133
  611. package/pi.dev-src/pi-mono/tui/src/index.ts +0 -106
  612. package/pi.dev-src/pi-mono/tui/src/keybindings.ts +0 -244
  613. package/pi.dev-src/pi-mono/tui/src/keys.ts +0 -1400
  614. package/pi.dev-src/pi-mono/tui/src/kill-ring.ts +0 -46
  615. package/pi.dev-src/pi-mono/tui/src/stdin-buffer.ts +0 -386
  616. package/pi.dev-src/pi-mono/tui/src/terminal-image.ts +0 -414
  617. package/pi.dev-src/pi-mono/tui/src/terminal.ts +0 -373
  618. package/pi.dev-src/pi-mono/tui/src/tui.ts +0 -1243
  619. package/pi.dev-src/pi-mono/tui/src/undo-stack.ts +0 -28
  620. package/pi.dev-src/pi-mono/tui/src/utils.ts +0 -1085
  621. package/pi.dev-src/pi-mono/tui/test/autocomplete.test.ts +0 -542
  622. package/pi.dev-src/pi-mono/tui/test/bug-regression-isimageline-startswith-bug.test.ts +0 -237
  623. package/pi.dev-src/pi-mono/tui/test/chat-simple.ts +0 -129
  624. package/pi.dev-src/pi-mono/tui/test/editor.test.ts +0 -3812
  625. package/pi.dev-src/pi-mono/tui/test/fuzzy.test.ts +0 -98
  626. package/pi.dev-src/pi-mono/tui/test/image-test.ts +0 -56
  627. package/pi.dev-src/pi-mono/tui/test/input.test.ts +0 -580
  628. package/pi.dev-src/pi-mono/tui/test/key-tester.ts +0 -105
  629. package/pi.dev-src/pi-mono/tui/test/keybindings.test.ts +0 -38
  630. package/pi.dev-src/pi-mono/tui/test/keys.test.ts +0 -614
  631. package/pi.dev-src/pi-mono/tui/test/markdown.test.ts +0 -1236
  632. package/pi.dev-src/pi-mono/tui/test/overlay-non-capturing.test.ts +0 -609
  633. package/pi.dev-src/pi-mono/tui/test/overlay-options.test.ts +0 -538
  634. package/pi.dev-src/pi-mono/tui/test/overlay-short-content.test.ts +0 -56
  635. package/pi.dev-src/pi-mono/tui/test/regression-regional-indicator-width.test.ts +0 -52
  636. package/pi.dev-src/pi-mono/tui/test/select-list.test.ts +0 -116
  637. package/pi.dev-src/pi-mono/tui/test/stdin-buffer.test.ts +0 -422
  638. package/pi.dev-src/pi-mono/tui/test/terminal-image.test.ts +0 -279
  639. package/pi.dev-src/pi-mono/tui/test/test-themes.ts +0 -38
  640. package/pi.dev-src/pi-mono/tui/test/truncate-to-width.test.ts +0 -62
  641. package/pi.dev-src/pi-mono/tui/test/truncated-text.test.ts +0 -129
  642. package/pi.dev-src/pi-mono/tui/test/tui-cell-size-input.test.ts +0 -81
  643. package/pi.dev-src/pi-mono/tui/test/tui-overlay-style-leak.test.ts +0 -72
  644. package/pi.dev-src/pi-mono/tui/test/tui-render.test.ts +0 -509
  645. package/pi.dev-src/pi-mono/tui/test/viewport-overwrite-repro.ts +0 -106
  646. package/pi.dev-src/pi-mono/tui/test/virtual-terminal.ts +0 -218
  647. package/pi.dev-src/pi-mono/tui/test/wrap-ansi.test.ts +0 -207
  648. package/pi.dev-src/pi-mono/tui/vitest.config.ts +0 -7
  649. package/pi.dev-src/pi-mono/web-ui/example/index.html +0 -13
  650. package/pi.dev-src/pi-mono/web-ui/example/src/app.css +0 -1
  651. package/pi.dev-src/pi-mono/web-ui/example/src/custom-messages.ts +0 -99
  652. package/pi.dev-src/pi-mono/web-ui/example/src/main.ts +0 -421
  653. package/pi.dev-src/pi-mono/web-ui/example/tsconfig.json +0 -23
  654. package/pi.dev-src/pi-mono/web-ui/example/vite.config.ts +0 -6
  655. package/pi.dev-src/pi-mono/web-ui/scripts/count-prompt-tokens.ts +0 -88
  656. package/pi.dev-src/pi-mono/web-ui/src/ChatPanel.ts +0 -209
  657. package/pi.dev-src/pi-mono/web-ui/src/app.css +0 -68
  658. package/pi.dev-src/pi-mono/web-ui/src/components/AgentInterface.ts +0 -403
  659. package/pi.dev-src/pi-mono/web-ui/src/components/AttachmentTile.ts +0 -107
  660. package/pi.dev-src/pi-mono/web-ui/src/components/ConsoleBlock.ts +0 -72
  661. package/pi.dev-src/pi-mono/web-ui/src/components/CustomProviderCard.ts +0 -100
  662. package/pi.dev-src/pi-mono/web-ui/src/components/ExpandableSection.ts +0 -46
  663. package/pi.dev-src/pi-mono/web-ui/src/components/Input.ts +0 -113
  664. package/pi.dev-src/pi-mono/web-ui/src/components/MessageEditor.ts +0 -405
  665. package/pi.dev-src/pi-mono/web-ui/src/components/MessageList.ts +0 -98
  666. package/pi.dev-src/pi-mono/web-ui/src/components/Messages.ts +0 -383
  667. package/pi.dev-src/pi-mono/web-ui/src/components/ProviderKeyInput.ts +0 -153
  668. package/pi.dev-src/pi-mono/web-ui/src/components/SandboxedIframe.ts +0 -626
  669. package/pi.dev-src/pi-mono/web-ui/src/components/StreamingMessageContainer.ts +0 -103
  670. package/pi.dev-src/pi-mono/web-ui/src/components/ThinkingBlock.ts +0 -43
  671. package/pi.dev-src/pi-mono/web-ui/src/components/message-renderer-registry.ts +0 -28
  672. package/pi.dev-src/pi-mono/web-ui/src/components/sandbox/ArtifactsRuntimeProvider.ts +0 -220
  673. package/pi.dev-src/pi-mono/web-ui/src/components/sandbox/AttachmentsRuntimeProvider.ts +0 -66
  674. package/pi.dev-src/pi-mono/web-ui/src/components/sandbox/ConsoleRuntimeProvider.ts +0 -186
  675. package/pi.dev-src/pi-mono/web-ui/src/components/sandbox/FileDownloadRuntimeProvider.ts +0 -110
  676. package/pi.dev-src/pi-mono/web-ui/src/components/sandbox/RuntimeMessageBridge.ts +0 -82
  677. package/pi.dev-src/pi-mono/web-ui/src/components/sandbox/RuntimeMessageRouter.ts +0 -216
  678. package/pi.dev-src/pi-mono/web-ui/src/components/sandbox/SandboxRuntimeProvider.ts +0 -52
  679. package/pi.dev-src/pi-mono/web-ui/src/dialogs/ApiKeyPromptDialog.ts +0 -75
  680. package/pi.dev-src/pi-mono/web-ui/src/dialogs/AttachmentOverlay.ts +0 -636
  681. package/pi.dev-src/pi-mono/web-ui/src/dialogs/CustomProviderDialog.ts +0 -274
  682. package/pi.dev-src/pi-mono/web-ui/src/dialogs/ModelSelector.ts +0 -370
  683. package/pi.dev-src/pi-mono/web-ui/src/dialogs/PersistentStorageDialog.ts +0 -144
  684. package/pi.dev-src/pi-mono/web-ui/src/dialogs/ProvidersModelsTab.ts +0 -212
  685. package/pi.dev-src/pi-mono/web-ui/src/dialogs/SessionListDialog.ts +0 -150
  686. package/pi.dev-src/pi-mono/web-ui/src/dialogs/SettingsDialog.ts +0 -218
  687. package/pi.dev-src/pi-mono/web-ui/src/index.ts +0 -120
  688. package/pi.dev-src/pi-mono/web-ui/src/prompts/prompts.ts +0 -282
  689. package/pi.dev-src/pi-mono/web-ui/src/storage/app-storage.ts +0 -60
  690. package/pi.dev-src/pi-mono/web-ui/src/storage/backends/indexeddb-storage-backend.ts +0 -193
  691. package/pi.dev-src/pi-mono/web-ui/src/storage/store.ts +0 -33
  692. package/pi.dev-src/pi-mono/web-ui/src/storage/stores/custom-providers-store.ts +0 -62
  693. package/pi.dev-src/pi-mono/web-ui/src/storage/stores/provider-keys-store.ts +0 -33
  694. package/pi.dev-src/pi-mono/web-ui/src/storage/stores/sessions-store.ts +0 -136
  695. package/pi.dev-src/pi-mono/web-ui/src/storage/stores/settings-store.ts +0 -34
  696. package/pi.dev-src/pi-mono/web-ui/src/storage/types.ts +0 -206
  697. package/pi.dev-src/pi-mono/web-ui/src/tools/artifacts/ArtifactElement.ts +0 -14
  698. package/pi.dev-src/pi-mono/web-ui/src/tools/artifacts/ArtifactPill.ts +0 -26
  699. package/pi.dev-src/pi-mono/web-ui/src/tools/artifacts/Console.ts +0 -93
  700. package/pi.dev-src/pi-mono/web-ui/src/tools/artifacts/DocxArtifact.ts +0 -213
  701. package/pi.dev-src/pi-mono/web-ui/src/tools/artifacts/ExcelArtifact.ts +0 -231
  702. package/pi.dev-src/pi-mono/web-ui/src/tools/artifacts/GenericArtifact.ts +0 -117
  703. package/pi.dev-src/pi-mono/web-ui/src/tools/artifacts/HtmlArtifact.ts +0 -195
  704. package/pi.dev-src/pi-mono/web-ui/src/tools/artifacts/ImageArtifact.ts +0 -116
  705. package/pi.dev-src/pi-mono/web-ui/src/tools/artifacts/MarkdownArtifact.ts +0 -82
  706. package/pi.dev-src/pi-mono/web-ui/src/tools/artifacts/PdfArtifact.ts +0 -201
  707. package/pi.dev-src/pi-mono/web-ui/src/tools/artifacts/SvgArtifact.ts +0 -119
  708. package/pi.dev-src/pi-mono/web-ui/src/tools/artifacts/TextArtifact.ts +0 -148
  709. package/pi.dev-src/pi-mono/web-ui/src/tools/artifacts/artifacts-tool-renderer.ts +0 -310
  710. package/pi.dev-src/pi-mono/web-ui/src/tools/artifacts/artifacts.ts +0 -713
  711. package/pi.dev-src/pi-mono/web-ui/src/tools/artifacts/index.ts +0 -7
  712. package/pi.dev-src/pi-mono/web-ui/src/tools/extract-document.ts +0 -275
  713. package/pi.dev-src/pi-mono/web-ui/src/tools/index.ts +0 -46
  714. package/pi.dev-src/pi-mono/web-ui/src/tools/javascript-repl.ts +0 -293
  715. package/pi.dev-src/pi-mono/web-ui/src/tools/renderer-registry.ts +0 -130
  716. package/pi.dev-src/pi-mono/web-ui/src/tools/renderers/BashRenderer.ts +0 -52
  717. package/pi.dev-src/pi-mono/web-ui/src/tools/renderers/CalculateRenderer.ts +0 -58
  718. package/pi.dev-src/pi-mono/web-ui/src/tools/renderers/DefaultRenderer.ts +0 -103
  719. package/pi.dev-src/pi-mono/web-ui/src/tools/renderers/GetCurrentTimeRenderer.ts +0 -92
  720. package/pi.dev-src/pi-mono/web-ui/src/tools/types.ts +0 -15
  721. package/pi.dev-src/pi-mono/web-ui/src/utils/attachment-utils.ts +0 -472
  722. package/pi.dev-src/pi-mono/web-ui/src/utils/auth-token.ts +0 -22
  723. package/pi.dev-src/pi-mono/web-ui/src/utils/format.ts +0 -42
  724. package/pi.dev-src/pi-mono/web-ui/src/utils/i18n.ts +0 -653
  725. package/pi.dev-src/pi-mono/web-ui/src/utils/model-discovery.ts +0 -277
  726. package/pi.dev-src/pi-mono/web-ui/src/utils/proxy-utils.ts +0 -139
  727. package/pi.dev-src/pi-mono/web-ui/src/utils/test-sessions.ts +0 -2357
  728. package/pi.dev-src/pi-mono/web-ui/tsconfig.json +0 -7
  729. package/tests/attended-results-scenarios.ts +0 -648
  730. package/tests/attended-results.test.ts +0 -39
  731. package/tests/cli-command-option-parity.test.ts +0 -798
  732. package/tests/debug-extension-harness.test.ts +0 -466
  733. package/tests/extension-registration.test.ts +0 -6785
  734. package/tests/fixtures/fixture_c.c +0 -361
  735. package/tests/fixtures/fixture_cpp.cpp +0 -407
  736. package/tests/fixtures/fixture_csharp.cs +0 -411
  737. package/tests/fixtures/fixture_elixir.ex +0 -409
  738. package/tests/fixtures/fixture_go.go +0 -341
  739. package/tests/fixtures/fixture_haskell.hs +0 -250
  740. package/tests/fixtures/fixture_java.java +0 -430
  741. package/tests/fixtures/fixture_javascript.js +0 -383
  742. package/tests/fixtures/fixture_kotlin.kt +0 -451
  743. package/tests/fixtures/fixture_lua.lua +0 -276
  744. package/tests/fixtures/fixture_perl.pl +0 -310
  745. package/tests/fixtures/fixture_php.php +0 -433
  746. package/tests/fixtures/fixture_python.py +0 -502
  747. package/tests/fixtures/fixture_ruby.rb +0 -345
  748. package/tests/fixtures/fixture_rust.rs +0 -380
  749. package/tests/fixtures/fixture_scala.scala +0 -398
  750. package/tests/fixtures/fixture_shell.sh +0 -276
  751. package/tests/fixtures/fixture_swift.swift +0 -397
  752. package/tests/fixtures/fixture_typescript.ts +0 -434
  753. package/tests/fixtures/fixture_zig.zig +0 -295
  754. package/tests/fixtures_attended_results/project/compress-line-numbers.json +0 -5
  755. package/tests/fixtures_attended_results/project/compress.json +0 -5
  756. package/tests/fixtures_attended_results/project/enable-static-check-invalid-command.json +0 -5
  757. package/tests/fixtures_attended_results/project/enable-static-check-valid.json +0 -5
  758. package/tests/fixtures_attended_results/project/files-static-check.json +0 -5
  759. package/tests/fixtures_attended_results/project/find-line-numbers.json +0 -5
  760. package/tests/fixtures_attended_results/project/find.json +0 -5
  761. package/tests/fixtures_attended_results/project/get-base-path.json +0 -5
  762. package/tests/fixtures_attended_results/project/git-check-clean.json +0 -5
  763. package/tests/fixtures_attended_results/project/git-check-dirty.json +0 -5
  764. package/tests/fixtures_attended_results/project/git-path.json +0 -5
  765. package/tests/fixtures_attended_results/project/git-wt-create-invalid.json +0 -5
  766. package/tests/fixtures_attended_results/project/git-wt-create-valid.json +0 -5
  767. package/tests/fixtures_attended_results/project/git-wt-delete-nonexistent.json +0 -5
  768. package/tests/fixtures_attended_results/project/git-wt-delete-valid.json +0 -5
  769. package/tests/fixtures_attended_results/project/git-wt-name.json +0 -5
  770. package/tests/fixtures_attended_results/project/static-check.json +0 -5
  771. package/tests/fixtures_attended_results/project/summarize.json +0 -5
  772. package/tests/fixtures_attended_results/project/tokens.json +0 -5
  773. package/tests/fixtures_attended_results/standalone/files-compress/fixture_c.c.json +0 -5
  774. package/tests/fixtures_attended_results/standalone/files-compress/fixture_cpp.cpp.json +0 -5
  775. package/tests/fixtures_attended_results/standalone/files-compress/fixture_csharp.cs.json +0 -5
  776. package/tests/fixtures_attended_results/standalone/files-compress/fixture_elixir.ex.json +0 -5
  777. package/tests/fixtures_attended_results/standalone/files-compress/fixture_go.go.json +0 -5
  778. package/tests/fixtures_attended_results/standalone/files-compress/fixture_haskell.hs.json +0 -5
  779. package/tests/fixtures_attended_results/standalone/files-compress/fixture_java.java.json +0 -5
  780. package/tests/fixtures_attended_results/standalone/files-compress/fixture_javascript.js.json +0 -5
  781. package/tests/fixtures_attended_results/standalone/files-compress/fixture_kotlin.kt.json +0 -5
  782. package/tests/fixtures_attended_results/standalone/files-compress/fixture_lua.lua.json +0 -5
  783. package/tests/fixtures_attended_results/standalone/files-compress/fixture_perl.pl.json +0 -5
  784. package/tests/fixtures_attended_results/standalone/files-compress/fixture_php.php.json +0 -5
  785. package/tests/fixtures_attended_results/standalone/files-compress/fixture_python.py.json +0 -5
  786. package/tests/fixtures_attended_results/standalone/files-compress/fixture_ruby.rb.json +0 -5
  787. package/tests/fixtures_attended_results/standalone/files-compress/fixture_rust.rs.json +0 -5
  788. package/tests/fixtures_attended_results/standalone/files-compress/fixture_scala.scala.json +0 -5
  789. package/tests/fixtures_attended_results/standalone/files-compress/fixture_shell.sh.json +0 -5
  790. package/tests/fixtures_attended_results/standalone/files-compress/fixture_swift.swift.json +0 -5
  791. package/tests/fixtures_attended_results/standalone/files-compress/fixture_typescript.ts.json +0 -5
  792. package/tests/fixtures_attended_results/standalone/files-compress/fixture_zig.zig.json +0 -5
  793. package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_c.c.json +0 -5
  794. package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_cpp.cpp.json +0 -5
  795. package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_csharp.cs.json +0 -5
  796. package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_elixir.ex.json +0 -5
  797. package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_go.go.json +0 -5
  798. package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_haskell.hs.json +0 -5
  799. package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_java.java.json +0 -5
  800. package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_javascript.js.json +0 -5
  801. package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_kotlin.kt.json +0 -5
  802. package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_lua.lua.json +0 -5
  803. package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_perl.pl.json +0 -5
  804. package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_php.php.json +0 -5
  805. package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_python.py.json +0 -5
  806. package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_ruby.rb.json +0 -5
  807. package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_rust.rs.json +0 -5
  808. package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_scala.scala.json +0 -5
  809. package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_shell.sh.json +0 -5
  810. package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_swift.swift.json +0 -5
  811. package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_typescript.ts.json +0 -5
  812. package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_zig.zig.json +0 -5
  813. package/tests/fixtures_attended_results/standalone/files-find/fixture_c.c.json +0 -5
  814. package/tests/fixtures_attended_results/standalone/files-find/fixture_cpp.cpp.json +0 -5
  815. package/tests/fixtures_attended_results/standalone/files-find/fixture_csharp.cs.json +0 -5
  816. package/tests/fixtures_attended_results/standalone/files-find/fixture_elixir.ex.json +0 -5
  817. package/tests/fixtures_attended_results/standalone/files-find/fixture_go.go.json +0 -5
  818. package/tests/fixtures_attended_results/standalone/files-find/fixture_haskell.hs.json +0 -5
  819. package/tests/fixtures_attended_results/standalone/files-find/fixture_java.java.json +0 -5
  820. package/tests/fixtures_attended_results/standalone/files-find/fixture_javascript.js.json +0 -5
  821. package/tests/fixtures_attended_results/standalone/files-find/fixture_kotlin.kt.json +0 -5
  822. package/tests/fixtures_attended_results/standalone/files-find/fixture_lua.lua.json +0 -5
  823. package/tests/fixtures_attended_results/standalone/files-find/fixture_perl.pl.json +0 -5
  824. package/tests/fixtures_attended_results/standalone/files-find/fixture_php.php.json +0 -5
  825. package/tests/fixtures_attended_results/standalone/files-find/fixture_python.py.json +0 -5
  826. package/tests/fixtures_attended_results/standalone/files-find/fixture_ruby.rb.json +0 -5
  827. package/tests/fixtures_attended_results/standalone/files-find/fixture_rust.rs.json +0 -5
  828. package/tests/fixtures_attended_results/standalone/files-find/fixture_scala.scala.json +0 -5
  829. package/tests/fixtures_attended_results/standalone/files-find/fixture_shell.sh.json +0 -5
  830. package/tests/fixtures_attended_results/standalone/files-find/fixture_swift.swift.json +0 -5
  831. package/tests/fixtures_attended_results/standalone/files-find/fixture_typescript.ts.json +0 -5
  832. package/tests/fixtures_attended_results/standalone/files-find/fixture_zig.zig.json +0 -5
  833. package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_c.c.json +0 -5
  834. package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_cpp.cpp.json +0 -5
  835. package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_csharp.cs.json +0 -5
  836. package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_elixir.ex.json +0 -5
  837. package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_go.go.json +0 -5
  838. package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_haskell.hs.json +0 -5
  839. package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_java.java.json +0 -5
  840. package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_javascript.js.json +0 -5
  841. package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_kotlin.kt.json +0 -5
  842. package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_lua.lua.json +0 -5
  843. package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_perl.pl.json +0 -5
  844. package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_php.php.json +0 -5
  845. package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_python.py.json +0 -5
  846. package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_ruby.rb.json +0 -5
  847. package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_rust.rs.json +0 -5
  848. package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_scala.scala.json +0 -5
  849. package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_shell.sh.json +0 -5
  850. package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_swift.swift.json +0 -5
  851. package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_typescript.ts.json +0 -5
  852. package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_zig.zig.json +0 -5
  853. package/tests/fixtures_attended_results/standalone/files-summarize/fixture_c.c.json +0 -5
  854. package/tests/fixtures_attended_results/standalone/files-summarize/fixture_cpp.cpp.json +0 -5
  855. package/tests/fixtures_attended_results/standalone/files-summarize/fixture_csharp.cs.json +0 -5
  856. package/tests/fixtures_attended_results/standalone/files-summarize/fixture_elixir.ex.json +0 -5
  857. package/tests/fixtures_attended_results/standalone/files-summarize/fixture_go.go.json +0 -5
  858. package/tests/fixtures_attended_results/standalone/files-summarize/fixture_haskell.hs.json +0 -5
  859. package/tests/fixtures_attended_results/standalone/files-summarize/fixture_java.java.json +0 -5
  860. package/tests/fixtures_attended_results/standalone/files-summarize/fixture_javascript.js.json +0 -5
  861. package/tests/fixtures_attended_results/standalone/files-summarize/fixture_kotlin.kt.json +0 -5
  862. package/tests/fixtures_attended_results/standalone/files-summarize/fixture_lua.lua.json +0 -5
  863. package/tests/fixtures_attended_results/standalone/files-summarize/fixture_perl.pl.json +0 -5
  864. package/tests/fixtures_attended_results/standalone/files-summarize/fixture_php.php.json +0 -5
  865. package/tests/fixtures_attended_results/standalone/files-summarize/fixture_python.py.json +0 -5
  866. package/tests/fixtures_attended_results/standalone/files-summarize/fixture_ruby.rb.json +0 -5
  867. package/tests/fixtures_attended_results/standalone/files-summarize/fixture_rust.rs.json +0 -5
  868. package/tests/fixtures_attended_results/standalone/files-summarize/fixture_scala.scala.json +0 -5
  869. package/tests/fixtures_attended_results/standalone/files-summarize/fixture_shell.sh.json +0 -5
  870. package/tests/fixtures_attended_results/standalone/files-summarize/fixture_swift.swift.json +0 -5
  871. package/tests/fixtures_attended_results/standalone/files-summarize/fixture_typescript.ts.json +0 -5
  872. package/tests/fixtures_attended_results/standalone/files-summarize/fixture_zig.zig.json +0 -5
  873. package/tests/fixtures_attended_results/standalone/files-tokens/fixture_c.c.json +0 -5
  874. package/tests/fixtures_attended_results/standalone/files-tokens/fixture_cpp.cpp.json +0 -5
  875. package/tests/fixtures_attended_results/standalone/files-tokens/fixture_csharp.cs.json +0 -5
  876. package/tests/fixtures_attended_results/standalone/files-tokens/fixture_elixir.ex.json +0 -5
  877. package/tests/fixtures_attended_results/standalone/files-tokens/fixture_go.go.json +0 -5
  878. package/tests/fixtures_attended_results/standalone/files-tokens/fixture_haskell.hs.json +0 -5
  879. package/tests/fixtures_attended_results/standalone/files-tokens/fixture_java.java.json +0 -5
  880. package/tests/fixtures_attended_results/standalone/files-tokens/fixture_javascript.js.json +0 -5
  881. package/tests/fixtures_attended_results/standalone/files-tokens/fixture_kotlin.kt.json +0 -5
  882. package/tests/fixtures_attended_results/standalone/files-tokens/fixture_lua.lua.json +0 -5
  883. package/tests/fixtures_attended_results/standalone/files-tokens/fixture_perl.pl.json +0 -5
  884. package/tests/fixtures_attended_results/standalone/files-tokens/fixture_php.php.json +0 -5
  885. package/tests/fixtures_attended_results/standalone/files-tokens/fixture_python.py.json +0 -5
  886. package/tests/fixtures_attended_results/standalone/files-tokens/fixture_ruby.rb.json +0 -5
  887. package/tests/fixtures_attended_results/standalone/files-tokens/fixture_rust.rs.json +0 -5
  888. package/tests/fixtures_attended_results/standalone/files-tokens/fixture_scala.scala.json +0 -5
  889. package/tests/fixtures_attended_results/standalone/files-tokens/fixture_shell.sh.json +0 -5
  890. package/tests/fixtures_attended_results/standalone/files-tokens/fixture_swift.swift.json +0 -5
  891. package/tests/fixtures_attended_results/standalone/files-tokens/fixture_typescript.ts.json +0 -5
  892. package/tests/fixtures_attended_results/standalone/files-tokens/fixture_zig.zig.json +0 -5
  893. package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_c.c.json +0 -5
  894. package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_cpp.cpp.json +0 -5
  895. package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_csharp.cs.json +0 -5
  896. package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_elixir.ex.json +0 -5
  897. package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_go.go.json +0 -5
  898. package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_haskell.hs.json +0 -5
  899. package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_java.java.json +0 -5
  900. package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_javascript.js.json +0 -5
  901. package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_kotlin.kt.json +0 -5
  902. package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_lua.lua.json +0 -5
  903. package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_perl.pl.json +0 -5
  904. package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_php.php.json +0 -5
  905. package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_python.py.json +0 -5
  906. package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_ruby.rb.json +0 -5
  907. package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_rust.rs.json +0 -5
  908. package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_scala.scala.json +0 -5
  909. package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_shell.sh.json +0 -5
  910. package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_swift.swift.json +0 -5
  911. package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_typescript.ts.json +0 -5
  912. package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_zig.zig.json +0 -5
  913. package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_c.c.json +0 -5
  914. package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_cpp.cpp.json +0 -5
  915. package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_csharp.cs.json +0 -5
  916. package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_elixir.ex.json +0 -5
  917. package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_go.go.json +0 -5
  918. package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_haskell.hs.json +0 -5
  919. package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_java.java.json +0 -5
  920. package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_javascript.js.json +0 -5
  921. package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_kotlin.kt.json +0 -5
  922. package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_lua.lua.json +0 -5
  923. package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_perl.pl.json +0 -5
  924. package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_php.php.json +0 -5
  925. package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_python.py.json +0 -5
  926. package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_ruby.rb.json +0 -5
  927. package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_rust.rs.json +0 -5
  928. package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_scala.scala.json +0 -5
  929. package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_shell.sh.json +0 -5
  930. package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_swift.swift.json +0 -5
  931. package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_typescript.ts.json +0 -5
  932. package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_zig.zig.json +0 -5
  933. package/tests/helpers.ts +0 -236
  934. package/tests/oracle-project.test.ts +0 -67
  935. package/tests/oracle-standalone.test.ts +0 -68
  936. package/tests/prompt-command-summary.test.ts +0 -36
  937. package/tests/prompt-rendering.test.ts +0 -103
  938. package/tests/python_oracle_stubs/tiktoken.py +0 -76
  939. package/tests/release-workflow.test.ts +0 -195
  940. package/tests/static-check-bundled.test.ts +0 -332
@@ -1,2408 +0,0 @@
1
- import { type ChildProcess, type ChildProcessByStdio, spawn, spawnSync } from "node:child_process";
2
- import { createHash } from "node:crypto";
3
- import {
4
- existsSync,
5
- mkdirSync,
6
- readdirSync,
7
- readFileSync,
8
- realpathSync,
9
- rmSync,
10
- statSync,
11
- writeFileSync,
12
- } from "node:fs";
13
- import { homedir, tmpdir } from "node:os";
14
- import { basename, dirname, join, relative, resolve, sep } from "node:path";
15
- import type { Readable } from "node:stream";
16
- import { globSync } from "glob";
17
- import ignore from "ignore";
18
- import { minimatch } from "minimatch";
19
- import { CONFIG_DIR_NAME } from "../config.js";
20
- import { type GitSource, parseGitUrl } from "../utils/git.js";
21
- import { isLocalPath } from "../utils/paths.js";
22
- import { isStdoutTakenOver } from "./output-guard.js";
23
- import type { PackageSource, SettingsManager } from "./settings-manager.js";
24
-
25
- const NETWORK_TIMEOUT_MS = 10000;
26
- const UPDATE_CHECK_CONCURRENCY = 4;
27
- const GIT_UPDATE_CONCURRENCY = 4;
28
-
29
- function isOfflineModeEnabled(): boolean {
30
- const value = process.env.PI_OFFLINE;
31
- if (!value) return false;
32
- return value === "1" || value.toLowerCase() === "true" || value.toLowerCase() === "yes";
33
- }
34
-
35
- export interface PathMetadata {
36
- source: string;
37
- scope: SourceScope;
38
- origin: "package" | "top-level";
39
- baseDir?: string;
40
- }
41
-
42
- export interface ResolvedResource {
43
- path: string;
44
- enabled: boolean;
45
- metadata: PathMetadata;
46
- }
47
-
48
- export interface ResolvedPaths {
49
- extensions: ResolvedResource[];
50
- skills: ResolvedResource[];
51
- prompts: ResolvedResource[];
52
- themes: ResolvedResource[];
53
- }
54
-
55
- export type MissingSourceAction = "install" | "skip" | "error";
56
-
57
- export interface ProgressEvent {
58
- type: "start" | "progress" | "complete" | "error";
59
- action: "install" | "remove" | "update" | "clone" | "pull";
60
- source: string;
61
- message?: string;
62
- }
63
-
64
- export type ProgressCallback = (event: ProgressEvent) => void;
65
-
66
- export interface PackageUpdate {
67
- source: string;
68
- displayName: string;
69
- type: "npm" | "git";
70
- scope: Exclude<SourceScope, "temporary">;
71
- }
72
-
73
- export interface ConfiguredPackage {
74
- source: string;
75
- scope: "user" | "project";
76
- filtered: boolean;
77
- installedPath?: string;
78
- }
79
-
80
- export interface PackageManager {
81
- resolve(onMissing?: (source: string) => Promise<MissingSourceAction>): Promise<ResolvedPaths>;
82
- install(source: string, options?: { local?: boolean }): Promise<void>;
83
- installAndPersist(source: string, options?: { local?: boolean }): Promise<void>;
84
- remove(source: string, options?: { local?: boolean }): Promise<void>;
85
- removeAndPersist(source: string, options?: { local?: boolean }): Promise<boolean>;
86
- update(source?: string): Promise<void>;
87
- listConfiguredPackages(): ConfiguredPackage[];
88
- resolveExtensionSources(
89
- sources: string[],
90
- options?: { local?: boolean; temporary?: boolean },
91
- ): Promise<ResolvedPaths>;
92
- addSourceToSettings(source: string, options?: { local?: boolean }): boolean;
93
- removeSourceFromSettings(source: string, options?: { local?: boolean }): boolean;
94
- setProgressCallback(callback: ProgressCallback | undefined): void;
95
- getInstalledPath(source: string, scope: "user" | "project"): string | undefined;
96
- }
97
-
98
- interface PackageManagerOptions {
99
- cwd: string;
100
- agentDir: string;
101
- settingsManager: SettingsManager;
102
- }
103
-
104
- type SourceScope = "user" | "project" | "temporary";
105
-
106
- type NpmSource = {
107
- type: "npm";
108
- spec: string;
109
- name: string;
110
- pinned: boolean;
111
- };
112
-
113
- type LocalSource = {
114
- type: "local";
115
- path: string;
116
- };
117
-
118
- type ParsedSource = NpmSource | GitSource | LocalSource;
119
-
120
- type InstalledSourceScope = Exclude<SourceScope, "temporary">;
121
-
122
- interface ConfiguredUpdateSource {
123
- source: string;
124
- scope: InstalledSourceScope;
125
- }
126
-
127
- interface NpmUpdateTarget extends ConfiguredUpdateSource {
128
- parsed: NpmSource;
129
- }
130
-
131
- interface GitUpdateTarget extends ConfiguredUpdateSource {
132
- parsed: GitSource;
133
- }
134
-
135
- interface PiManifest {
136
- extensions?: string[];
137
- skills?: string[];
138
- prompts?: string[];
139
- themes?: string[];
140
- }
141
-
142
- interface ResourceAccumulator {
143
- extensions: Map<string, { metadata: PathMetadata; enabled: boolean }>;
144
- skills: Map<string, { metadata: PathMetadata; enabled: boolean }>;
145
- prompts: Map<string, { metadata: PathMetadata; enabled: boolean }>;
146
- themes: Map<string, { metadata: PathMetadata; enabled: boolean }>;
147
- }
148
-
149
- /**
150
- * Compute a numeric precedence rank for a resource based on its metadata.
151
- * Lower rank = higher precedence. Used to sort resolved resources so that
152
- * name-collision resolution ("first wins") produces the correct outcome.
153
- *
154
- * Precedence (highest to lowest):
155
- * 0 project + settings entry (source: "local", scope: "project")
156
- * 1 project + auto-discovered (source: "auto", scope: "project")
157
- * 2 user + settings entry (source: "local", scope: "user")
158
- * 3 user + auto-discovered (source: "auto", scope: "user")
159
- * 4 package resource (origin: "package")
160
- */
161
- function resourcePrecedenceRank(m: PathMetadata): number {
162
- if (m.origin === "package") return 4;
163
- const scopeBase = m.scope === "project" ? 0 : 2;
164
- return scopeBase + (m.source === "local" ? 0 : 1);
165
- }
166
-
167
- interface PackageFilter {
168
- extensions?: string[];
169
- skills?: string[];
170
- prompts?: string[];
171
- themes?: string[];
172
- }
173
-
174
- type ResourceType = "extensions" | "skills" | "prompts" | "themes";
175
-
176
- const RESOURCE_TYPES: ResourceType[] = ["extensions", "skills", "prompts", "themes"];
177
-
178
- const FILE_PATTERNS: Record<ResourceType, RegExp> = {
179
- extensions: /\.(ts|js)$/,
180
- skills: /\.md$/,
181
- prompts: /\.md$/,
182
- themes: /\.json$/,
183
- };
184
-
185
- const IGNORE_FILE_NAMES = [".gitignore", ".ignore", ".fdignore"];
186
-
187
- type IgnoreMatcher = ReturnType<typeof ignore>;
188
-
189
- function toPosixPath(p: string): string {
190
- return p.split(sep).join("/");
191
- }
192
-
193
- function getHomeDir(): string {
194
- return process.env.HOME || homedir();
195
- }
196
-
197
- function prefixIgnorePattern(line: string, prefix: string): string | null {
198
- const trimmed = line.trim();
199
- if (!trimmed) return null;
200
- if (trimmed.startsWith("#") && !trimmed.startsWith("\\#")) return null;
201
-
202
- let pattern = line;
203
- let negated = false;
204
-
205
- if (pattern.startsWith("!")) {
206
- negated = true;
207
- pattern = pattern.slice(1);
208
- } else if (pattern.startsWith("\\!")) {
209
- pattern = pattern.slice(1);
210
- }
211
-
212
- if (pattern.startsWith("/")) {
213
- pattern = pattern.slice(1);
214
- }
215
-
216
- const prefixed = prefix ? `${prefix}${pattern}` : pattern;
217
- return negated ? `!${prefixed}` : prefixed;
218
- }
219
-
220
- function addIgnoreRules(ig: IgnoreMatcher, dir: string, rootDir: string): void {
221
- const relativeDir = relative(rootDir, dir);
222
- const prefix = relativeDir ? `${toPosixPath(relativeDir)}/` : "";
223
-
224
- for (const filename of IGNORE_FILE_NAMES) {
225
- const ignorePath = join(dir, filename);
226
- if (!existsSync(ignorePath)) continue;
227
- try {
228
- const content = readFileSync(ignorePath, "utf-8");
229
- const patterns = content
230
- .split(/\r?\n/)
231
- .map((line) => prefixIgnorePattern(line, prefix))
232
- .filter((line): line is string => Boolean(line));
233
- if (patterns.length > 0) {
234
- ig.add(patterns);
235
- }
236
- } catch {}
237
- }
238
- }
239
-
240
- function isPattern(s: string): boolean {
241
- return s.startsWith("!") || s.startsWith("+") || s.startsWith("-") || s.includes("*") || s.includes("?");
242
- }
243
-
244
- function isOverridePattern(s: string): boolean {
245
- return s.startsWith("!") || s.startsWith("+") || s.startsWith("-");
246
- }
247
-
248
- function hasGlobPattern(s: string): boolean {
249
- return s.includes("*") || s.includes("?");
250
- }
251
-
252
- function splitPatterns(entries: string[]): { plain: string[]; patterns: string[] } {
253
- const plain: string[] = [];
254
- const patterns: string[] = [];
255
- for (const entry of entries) {
256
- if (isPattern(entry)) {
257
- patterns.push(entry);
258
- } else {
259
- plain.push(entry);
260
- }
261
- }
262
- return { plain, patterns };
263
- }
264
-
265
- function collectFiles(
266
- dir: string,
267
- filePattern: RegExp,
268
- skipNodeModules = true,
269
- ignoreMatcher?: IgnoreMatcher,
270
- rootDir?: string,
271
- ): string[] {
272
- const files: string[] = [];
273
- if (!existsSync(dir)) return files;
274
-
275
- const root = rootDir ?? dir;
276
- const ig = ignoreMatcher ?? ignore();
277
- addIgnoreRules(ig, dir, root);
278
-
279
- try {
280
- const entries = readdirSync(dir, { withFileTypes: true });
281
- for (const entry of entries) {
282
- if (entry.name.startsWith(".")) continue;
283
- if (skipNodeModules && entry.name === "node_modules") continue;
284
-
285
- const fullPath = join(dir, entry.name);
286
- let isDir = entry.isDirectory();
287
- let isFile = entry.isFile();
288
-
289
- if (entry.isSymbolicLink()) {
290
- try {
291
- const stats = statSync(fullPath);
292
- isDir = stats.isDirectory();
293
- isFile = stats.isFile();
294
- } catch {
295
- continue;
296
- }
297
- }
298
-
299
- const relPath = toPosixPath(relative(root, fullPath));
300
- const ignorePath = isDir ? `${relPath}/` : relPath;
301
- if (ig.ignores(ignorePath)) continue;
302
-
303
- if (isDir) {
304
- files.push(...collectFiles(fullPath, filePattern, skipNodeModules, ig, root));
305
- } else if (isFile && filePattern.test(entry.name)) {
306
- files.push(fullPath);
307
- }
308
- }
309
- } catch {
310
- // Ignore errors
311
- }
312
-
313
- return files;
314
- }
315
-
316
- type SkillDiscoveryMode = "pi" | "agents";
317
-
318
- function collectSkillEntries(
319
- dir: string,
320
- mode: SkillDiscoveryMode,
321
- ignoreMatcher?: IgnoreMatcher,
322
- rootDir?: string,
323
- ): string[] {
324
- const entries: string[] = [];
325
- if (!existsSync(dir)) return entries;
326
-
327
- const root = rootDir ?? dir;
328
- const ig = ignoreMatcher ?? ignore();
329
- addIgnoreRules(ig, dir, root);
330
-
331
- try {
332
- const dirEntries = readdirSync(dir, { withFileTypes: true });
333
-
334
- for (const entry of dirEntries) {
335
- if (entry.name !== "SKILL.md") {
336
- continue;
337
- }
338
-
339
- const fullPath = join(dir, entry.name);
340
- let isFile = entry.isFile();
341
- if (entry.isSymbolicLink()) {
342
- try {
343
- isFile = statSync(fullPath).isFile();
344
- } catch {
345
- continue;
346
- }
347
- }
348
-
349
- const relPath = toPosixPath(relative(root, fullPath));
350
- if (isFile && !ig.ignores(relPath)) {
351
- entries.push(fullPath);
352
- return entries;
353
- }
354
- }
355
-
356
- for (const entry of dirEntries) {
357
- if (entry.name.startsWith(".")) continue;
358
- if (entry.name === "node_modules") continue;
359
-
360
- const fullPath = join(dir, entry.name);
361
- let isDir = entry.isDirectory();
362
- let isFile = entry.isFile();
363
-
364
- if (entry.isSymbolicLink()) {
365
- try {
366
- const stats = statSync(fullPath);
367
- isDir = stats.isDirectory();
368
- isFile = stats.isFile();
369
- } catch {
370
- continue;
371
- }
372
- }
373
-
374
- const relPath = toPosixPath(relative(root, fullPath));
375
- if (mode === "pi" && dir === root && isFile && entry.name.endsWith(".md") && !ig.ignores(relPath)) {
376
- entries.push(fullPath);
377
- continue;
378
- }
379
-
380
- if (!isDir) continue;
381
- if (ig.ignores(`${relPath}/`)) continue;
382
-
383
- entries.push(...collectSkillEntries(fullPath, mode, ig, root));
384
- }
385
- } catch {
386
- // Ignore errors
387
- }
388
-
389
- return entries;
390
- }
391
-
392
- function collectAutoSkillEntries(dir: string, mode: SkillDiscoveryMode): string[] {
393
- return collectSkillEntries(dir, mode);
394
- }
395
-
396
- function findGitRepoRoot(startDir: string): string | null {
397
- let dir = resolve(startDir);
398
- while (true) {
399
- if (existsSync(join(dir, ".git"))) {
400
- return dir;
401
- }
402
- const parent = dirname(dir);
403
- if (parent === dir) {
404
- return null;
405
- }
406
- dir = parent;
407
- }
408
- }
409
-
410
- function collectAncestorAgentsSkillDirs(startDir: string): string[] {
411
- const skillDirs: string[] = [];
412
- const resolvedStartDir = resolve(startDir);
413
- const gitRepoRoot = findGitRepoRoot(resolvedStartDir);
414
-
415
- let dir = resolvedStartDir;
416
- while (true) {
417
- skillDirs.push(join(dir, ".agents", "skills"));
418
- if (gitRepoRoot && dir === gitRepoRoot) {
419
- break;
420
- }
421
- const parent = dirname(dir);
422
- if (parent === dir) {
423
- break;
424
- }
425
- dir = parent;
426
- }
427
-
428
- return skillDirs;
429
- }
430
-
431
- function collectAutoPromptEntries(dir: string): string[] {
432
- const entries: string[] = [];
433
- if (!existsSync(dir)) return entries;
434
-
435
- const ig = ignore();
436
- addIgnoreRules(ig, dir, dir);
437
-
438
- try {
439
- const dirEntries = readdirSync(dir, { withFileTypes: true });
440
- for (const entry of dirEntries) {
441
- if (entry.name.startsWith(".")) continue;
442
- if (entry.name === "node_modules") continue;
443
-
444
- const fullPath = join(dir, entry.name);
445
- let isFile = entry.isFile();
446
- if (entry.isSymbolicLink()) {
447
- try {
448
- isFile = statSync(fullPath).isFile();
449
- } catch {
450
- continue;
451
- }
452
- }
453
-
454
- const relPath = toPosixPath(relative(dir, fullPath));
455
- if (ig.ignores(relPath)) continue;
456
-
457
- if (isFile && entry.name.endsWith(".md")) {
458
- entries.push(fullPath);
459
- }
460
- }
461
- } catch {
462
- // Ignore errors
463
- }
464
-
465
- return entries;
466
- }
467
-
468
- function collectAutoThemeEntries(dir: string): string[] {
469
- const entries: string[] = [];
470
- if (!existsSync(dir)) return entries;
471
-
472
- const ig = ignore();
473
- addIgnoreRules(ig, dir, dir);
474
-
475
- try {
476
- const dirEntries = readdirSync(dir, { withFileTypes: true });
477
- for (const entry of dirEntries) {
478
- if (entry.name.startsWith(".")) continue;
479
- if (entry.name === "node_modules") continue;
480
-
481
- const fullPath = join(dir, entry.name);
482
- let isFile = entry.isFile();
483
- if (entry.isSymbolicLink()) {
484
- try {
485
- isFile = statSync(fullPath).isFile();
486
- } catch {
487
- continue;
488
- }
489
- }
490
-
491
- const relPath = toPosixPath(relative(dir, fullPath));
492
- if (ig.ignores(relPath)) continue;
493
-
494
- if (isFile && entry.name.endsWith(".json")) {
495
- entries.push(fullPath);
496
- }
497
- }
498
- } catch {
499
- // Ignore errors
500
- }
501
-
502
- return entries;
503
- }
504
-
505
- function readPiManifestFile(packageJsonPath: string): PiManifest | null {
506
- try {
507
- const content = readFileSync(packageJsonPath, "utf-8");
508
- const pkg = JSON.parse(content) as { pi?: PiManifest };
509
- return pkg.pi ?? null;
510
- } catch {
511
- return null;
512
- }
513
- }
514
-
515
- function resolveExtensionEntries(dir: string): string[] | null {
516
- const packageJsonPath = join(dir, "package.json");
517
- if (existsSync(packageJsonPath)) {
518
- const manifest = readPiManifestFile(packageJsonPath);
519
- if (manifest?.extensions?.length) {
520
- const entries: string[] = [];
521
- for (const extPath of manifest.extensions) {
522
- const resolvedExtPath = resolve(dir, extPath);
523
- if (existsSync(resolvedExtPath)) {
524
- entries.push(resolvedExtPath);
525
- }
526
- }
527
- if (entries.length > 0) {
528
- return entries;
529
- }
530
- }
531
- }
532
-
533
- const indexTs = join(dir, "index.ts");
534
- const indexJs = join(dir, "index.js");
535
- if (existsSync(indexTs)) {
536
- return [indexTs];
537
- }
538
- if (existsSync(indexJs)) {
539
- return [indexJs];
540
- }
541
-
542
- return null;
543
- }
544
-
545
- function collectAutoExtensionEntries(dir: string): string[] {
546
- const entries: string[] = [];
547
- if (!existsSync(dir)) return entries;
548
-
549
- // First check if this directory itself has explicit extension entries (package.json or index)
550
- const rootEntries = resolveExtensionEntries(dir);
551
- if (rootEntries) {
552
- return rootEntries;
553
- }
554
-
555
- // Otherwise, discover extensions from directory contents
556
- const ig = ignore();
557
- addIgnoreRules(ig, dir, dir);
558
-
559
- try {
560
- const dirEntries = readdirSync(dir, { withFileTypes: true });
561
- for (const entry of dirEntries) {
562
- if (entry.name.startsWith(".")) continue;
563
- if (entry.name === "node_modules") continue;
564
-
565
- const fullPath = join(dir, entry.name);
566
- let isDir = entry.isDirectory();
567
- let isFile = entry.isFile();
568
-
569
- if (entry.isSymbolicLink()) {
570
- try {
571
- const stats = statSync(fullPath);
572
- isDir = stats.isDirectory();
573
- isFile = stats.isFile();
574
- } catch {
575
- continue;
576
- }
577
- }
578
-
579
- const relPath = toPosixPath(relative(dir, fullPath));
580
- const ignorePath = isDir ? `${relPath}/` : relPath;
581
- if (ig.ignores(ignorePath)) continue;
582
-
583
- if (isFile && (entry.name.endsWith(".ts") || entry.name.endsWith(".js"))) {
584
- entries.push(fullPath);
585
- } else if (isDir) {
586
- const resolvedEntries = resolveExtensionEntries(fullPath);
587
- if (resolvedEntries) {
588
- entries.push(...resolvedEntries);
589
- }
590
- }
591
- }
592
- } catch {
593
- // Ignore errors
594
- }
595
-
596
- return entries;
597
- }
598
-
599
- /**
600
- * Collect resource files from a directory based on resource type.
601
- * Extensions use smart discovery (index.ts in subdirs), others use recursive collection.
602
- */
603
- function collectResourceFiles(dir: string, resourceType: ResourceType): string[] {
604
- if (resourceType === "skills") {
605
- return collectSkillEntries(dir, "pi");
606
- }
607
- if (resourceType === "extensions") {
608
- return collectAutoExtensionEntries(dir);
609
- }
610
- return collectFiles(dir, FILE_PATTERNS[resourceType]);
611
- }
612
-
613
- function matchesAnyPattern(filePath: string, patterns: string[], baseDir: string): boolean {
614
- const rel = toPosixPath(relative(baseDir, filePath));
615
- const name = basename(filePath);
616
- const filePathPosix = toPosixPath(filePath);
617
- const isSkillFile = name === "SKILL.md";
618
- const parentDir = isSkillFile ? dirname(filePath) : undefined;
619
- const parentRel = isSkillFile ? toPosixPath(relative(baseDir, parentDir!)) : undefined;
620
- const parentName = isSkillFile ? basename(parentDir!) : undefined;
621
- const parentDirPosix = isSkillFile ? toPosixPath(parentDir!) : undefined;
622
-
623
- return patterns.some((pattern) => {
624
- const normalizedPattern = toPosixPath(pattern);
625
- if (
626
- minimatch(rel, normalizedPattern) ||
627
- minimatch(name, normalizedPattern) ||
628
- minimatch(filePathPosix, normalizedPattern)
629
- ) {
630
- return true;
631
- }
632
- if (!isSkillFile) return false;
633
- return (
634
- minimatch(parentRel!, normalizedPattern) ||
635
- minimatch(parentName!, normalizedPattern) ||
636
- minimatch(parentDirPosix!, normalizedPattern)
637
- );
638
- });
639
- }
640
-
641
- function normalizeExactPattern(pattern: string): string {
642
- const normalized = pattern.startsWith("./") || pattern.startsWith(".\\") ? pattern.slice(2) : pattern;
643
- return toPosixPath(normalized);
644
- }
645
-
646
- function matchesAnyExactPattern(filePath: string, patterns: string[], baseDir: string): boolean {
647
- if (patterns.length === 0) return false;
648
- const rel = toPosixPath(relative(baseDir, filePath));
649
- const name = basename(filePath);
650
- const filePathPosix = toPosixPath(filePath);
651
- const isSkillFile = name === "SKILL.md";
652
- const parentDir = isSkillFile ? dirname(filePath) : undefined;
653
- const parentRel = isSkillFile ? toPosixPath(relative(baseDir, parentDir!)) : undefined;
654
- const parentDirPosix = isSkillFile ? toPosixPath(parentDir!) : undefined;
655
-
656
- return patterns.some((pattern) => {
657
- const normalized = normalizeExactPattern(pattern);
658
- if (normalized === rel || normalized === filePathPosix) {
659
- return true;
660
- }
661
- if (!isSkillFile) return false;
662
- return normalized === parentRel || normalized === parentDirPosix;
663
- });
664
- }
665
-
666
- function getOverridePatterns(entries: string[]): string[] {
667
- return entries.filter((pattern) => pattern.startsWith("!") || pattern.startsWith("+") || pattern.startsWith("-"));
668
- }
669
-
670
- function isEnabledByOverrides(filePath: string, patterns: string[], baseDir: string): boolean {
671
- const overrides = getOverridePatterns(patterns);
672
- const excludes = overrides.filter((pattern) => pattern.startsWith("!")).map((pattern) => pattern.slice(1));
673
- const forceIncludes = overrides.filter((pattern) => pattern.startsWith("+")).map((pattern) => pattern.slice(1));
674
- const forceExcludes = overrides.filter((pattern) => pattern.startsWith("-")).map((pattern) => pattern.slice(1));
675
-
676
- let enabled = true;
677
- if (excludes.length > 0 && matchesAnyPattern(filePath, excludes, baseDir)) {
678
- enabled = false;
679
- }
680
- if (forceIncludes.length > 0 && matchesAnyExactPattern(filePath, forceIncludes, baseDir)) {
681
- enabled = true;
682
- }
683
- if (forceExcludes.length > 0 && matchesAnyExactPattern(filePath, forceExcludes, baseDir)) {
684
- enabled = false;
685
- }
686
- return enabled;
687
- }
688
-
689
- /**
690
- * Apply patterns to paths and return a Set of enabled paths.
691
- * Pattern types:
692
- * - Plain patterns: include matching paths
693
- * - `!pattern`: exclude matching paths
694
- * - `+path`: force-include exact path (overrides exclusions)
695
- * - `-path`: force-exclude exact path (overrides force-includes)
696
- */
697
- function applyPatterns(allPaths: string[], patterns: string[], baseDir: string): Set<string> {
698
- const includes: string[] = [];
699
- const excludes: string[] = [];
700
- const forceIncludes: string[] = [];
701
- const forceExcludes: string[] = [];
702
-
703
- for (const p of patterns) {
704
- if (p.startsWith("+")) {
705
- forceIncludes.push(p.slice(1));
706
- } else if (p.startsWith("-")) {
707
- forceExcludes.push(p.slice(1));
708
- } else if (p.startsWith("!")) {
709
- excludes.push(p.slice(1));
710
- } else {
711
- includes.push(p);
712
- }
713
- }
714
-
715
- // Step 1: Apply includes (or all if no includes)
716
- let result: string[];
717
- if (includes.length === 0) {
718
- result = [...allPaths];
719
- } else {
720
- result = allPaths.filter((filePath) => matchesAnyPattern(filePath, includes, baseDir));
721
- }
722
-
723
- // Step 2: Apply excludes
724
- if (excludes.length > 0) {
725
- result = result.filter((filePath) => !matchesAnyPattern(filePath, excludes, baseDir));
726
- }
727
-
728
- // Step 3: Force-include (add back from allPaths, overriding exclusions)
729
- if (forceIncludes.length > 0) {
730
- for (const filePath of allPaths) {
731
- if (!result.includes(filePath) && matchesAnyExactPattern(filePath, forceIncludes, baseDir)) {
732
- result.push(filePath);
733
- }
734
- }
735
- }
736
-
737
- // Step 4: Force-exclude (remove even if included or force-included)
738
- if (forceExcludes.length > 0) {
739
- result = result.filter((filePath) => !matchesAnyExactPattern(filePath, forceExcludes, baseDir));
740
- }
741
-
742
- return new Set(result);
743
- }
744
-
745
- export class DefaultPackageManager implements PackageManager {
746
- private cwd: string;
747
- private agentDir: string;
748
- private settingsManager: SettingsManager;
749
- private globalNpmRoot: string | undefined;
750
- private globalNpmRootCommandKey: string | undefined;
751
- private progressCallback: ProgressCallback | undefined;
752
-
753
- constructor(options: PackageManagerOptions) {
754
- this.cwd = options.cwd;
755
- this.agentDir = options.agentDir;
756
- this.settingsManager = options.settingsManager;
757
- }
758
-
759
- setProgressCallback(callback: ProgressCallback | undefined): void {
760
- this.progressCallback = callback;
761
- }
762
-
763
- addSourceToSettings(source: string, options?: { local?: boolean }): boolean {
764
- const scope: SourceScope = options?.local ? "project" : "user";
765
- const currentSettings =
766
- scope === "project" ? this.settingsManager.getProjectSettings() : this.settingsManager.getGlobalSettings();
767
- const currentPackages = currentSettings.packages ?? [];
768
- const normalizedSource = this.normalizePackageSourceForSettings(source, scope);
769
- const exists = currentPackages.some((existing) => this.packageSourcesMatch(existing, source, scope));
770
- if (exists) {
771
- return false;
772
- }
773
- const nextPackages = [...currentPackages, normalizedSource];
774
- if (scope === "project") {
775
- this.settingsManager.setProjectPackages(nextPackages);
776
- } else {
777
- this.settingsManager.setPackages(nextPackages);
778
- }
779
- return true;
780
- }
781
-
782
- removeSourceFromSettings(source: string, options?: { local?: boolean }): boolean {
783
- const scope: SourceScope = options?.local ? "project" : "user";
784
- const currentSettings =
785
- scope === "project" ? this.settingsManager.getProjectSettings() : this.settingsManager.getGlobalSettings();
786
- const currentPackages = currentSettings.packages ?? [];
787
- const nextPackages = currentPackages.filter((existing) => !this.packageSourcesMatch(existing, source, scope));
788
- const changed = nextPackages.length !== currentPackages.length;
789
- if (!changed) {
790
- return false;
791
- }
792
- if (scope === "project") {
793
- this.settingsManager.setProjectPackages(nextPackages);
794
- } else {
795
- this.settingsManager.setPackages(nextPackages);
796
- }
797
- return true;
798
- }
799
-
800
- getInstalledPath(source: string, scope: "user" | "project"): string | undefined {
801
- const parsed = this.parseSource(source);
802
- if (parsed.type === "npm") {
803
- const path = this.getNpmInstallPath(parsed, scope);
804
- return existsSync(path) ? path : undefined;
805
- }
806
- if (parsed.type === "git") {
807
- const path = this.getGitInstallPath(parsed, scope);
808
- return existsSync(path) ? path : undefined;
809
- }
810
- if (parsed.type === "local") {
811
- const baseDir = this.getBaseDirForScope(scope);
812
- const path = this.resolvePathFromBase(parsed.path, baseDir);
813
- return existsSync(path) ? path : undefined;
814
- }
815
- return undefined;
816
- }
817
-
818
- private emitProgress(event: ProgressEvent): void {
819
- this.progressCallback?.(event);
820
- }
821
-
822
- private async withProgress(
823
- action: ProgressEvent["action"],
824
- source: string,
825
- message: string,
826
- operation: () => Promise<void>,
827
- ): Promise<void> {
828
- this.emitProgress({ type: "start", action, source, message });
829
- try {
830
- await operation();
831
- this.emitProgress({ type: "complete", action, source });
832
- } catch (error) {
833
- const errorMessage = error instanceof Error ? error.message : String(error);
834
- this.emitProgress({ type: "error", action, source, message: errorMessage });
835
- throw error;
836
- }
837
- }
838
-
839
- async resolve(onMissing?: (source: string) => Promise<MissingSourceAction>): Promise<ResolvedPaths> {
840
- const accumulator = this.createAccumulator();
841
- const globalSettings = this.settingsManager.getGlobalSettings();
842
- const projectSettings = this.settingsManager.getProjectSettings();
843
-
844
- // Collect all packages with scope (project first so cwd resources win collisions)
845
- const allPackages: Array<{ pkg: PackageSource; scope: SourceScope }> = [];
846
- for (const pkg of projectSettings.packages ?? []) {
847
- allPackages.push({ pkg, scope: "project" });
848
- }
849
- for (const pkg of globalSettings.packages ?? []) {
850
- allPackages.push({ pkg, scope: "user" });
851
- }
852
-
853
- // Dedupe: project scope wins over global for same package identity
854
- const packageSources = this.dedupePackages(allPackages);
855
- await this.resolvePackageSources(packageSources, accumulator, onMissing);
856
-
857
- const globalBaseDir = this.agentDir;
858
- const projectBaseDir = join(this.cwd, CONFIG_DIR_NAME);
859
-
860
- for (const resourceType of RESOURCE_TYPES) {
861
- const target = this.getTargetMap(accumulator, resourceType);
862
- const globalEntries = (globalSettings[resourceType] ?? []) as string[];
863
- const projectEntries = (projectSettings[resourceType] ?? []) as string[];
864
- this.resolveLocalEntries(
865
- projectEntries,
866
- resourceType,
867
- target,
868
- {
869
- source: "local",
870
- scope: "project",
871
- origin: "top-level",
872
- },
873
- projectBaseDir,
874
- );
875
- this.resolveLocalEntries(
876
- globalEntries,
877
- resourceType,
878
- target,
879
- {
880
- source: "local",
881
- scope: "user",
882
- origin: "top-level",
883
- },
884
- globalBaseDir,
885
- );
886
- }
887
-
888
- this.addAutoDiscoveredResources(accumulator, globalSettings, projectSettings, globalBaseDir, projectBaseDir);
889
-
890
- return this.toResolvedPaths(accumulator);
891
- }
892
-
893
- async resolveExtensionSources(
894
- sources: string[],
895
- options?: { local?: boolean; temporary?: boolean },
896
- ): Promise<ResolvedPaths> {
897
- const accumulator = this.createAccumulator();
898
- const scope: SourceScope = options?.temporary ? "temporary" : options?.local ? "project" : "user";
899
- const packageSources = sources.map((source) => ({ pkg: source as PackageSource, scope }));
900
- await this.resolvePackageSources(packageSources, accumulator);
901
- return this.toResolvedPaths(accumulator);
902
- }
903
-
904
- listConfiguredPackages(): ConfiguredPackage[] {
905
- const globalSettings = this.settingsManager.getGlobalSettings();
906
- const projectSettings = this.settingsManager.getProjectSettings();
907
- const configuredPackages: ConfiguredPackage[] = [];
908
-
909
- for (const pkg of globalSettings.packages ?? []) {
910
- const source = typeof pkg === "string" ? pkg : pkg.source;
911
- configuredPackages.push({
912
- source,
913
- scope: "user",
914
- filtered: typeof pkg === "object",
915
- installedPath: this.getInstalledPath(source, "user"),
916
- });
917
- }
918
-
919
- for (const pkg of projectSettings.packages ?? []) {
920
- const source = typeof pkg === "string" ? pkg : pkg.source;
921
- configuredPackages.push({
922
- source,
923
- scope: "project",
924
- filtered: typeof pkg === "object",
925
- installedPath: this.getInstalledPath(source, "project"),
926
- });
927
- }
928
-
929
- return configuredPackages;
930
- }
931
-
932
- async install(source: string, options?: { local?: boolean }): Promise<void> {
933
- const parsed = this.parseSource(source);
934
- const scope: SourceScope = options?.local ? "project" : "user";
935
- await this.withProgress("install", source, `Installing ${source}...`, async () => {
936
- if (parsed.type === "npm") {
937
- await this.installNpm(parsed, scope, false);
938
- return;
939
- }
940
- if (parsed.type === "git") {
941
- await this.installGit(parsed, scope);
942
- return;
943
- }
944
- if (parsed.type === "local") {
945
- const resolved = this.resolvePath(parsed.path);
946
- if (!existsSync(resolved)) {
947
- throw new Error(`Path does not exist: ${resolved}`);
948
- }
949
- return;
950
- }
951
- throw new Error(`Unsupported install source: ${source}`);
952
- });
953
- }
954
-
955
- async installAndPersist(source: string, options?: { local?: boolean }): Promise<void> {
956
- await this.install(source, options);
957
- this.addSourceToSettings(source, options);
958
- }
959
-
960
- async remove(source: string, options?: { local?: boolean }): Promise<void> {
961
- const parsed = this.parseSource(source);
962
- const scope: SourceScope = options?.local ? "project" : "user";
963
- await this.withProgress("remove", source, `Removing ${source}...`, async () => {
964
- if (parsed.type === "npm") {
965
- await this.uninstallNpm(parsed, scope);
966
- return;
967
- }
968
- if (parsed.type === "git") {
969
- await this.removeGit(parsed, scope);
970
- return;
971
- }
972
- if (parsed.type === "local") {
973
- return;
974
- }
975
- throw new Error(`Unsupported remove source: ${source}`);
976
- });
977
- }
978
-
979
- async removeAndPersist(source: string, options?: { local?: boolean }): Promise<boolean> {
980
- await this.remove(source, options);
981
- return this.removeSourceFromSettings(source, options);
982
- }
983
-
984
- async update(source?: string): Promise<void> {
985
- const globalSettings = this.settingsManager.getGlobalSettings();
986
- const projectSettings = this.settingsManager.getProjectSettings();
987
- const identity = source ? this.getPackageIdentity(source) : undefined;
988
- let matched = false;
989
- const updateSources: ConfiguredUpdateSource[] = [];
990
-
991
- for (const pkg of globalSettings.packages ?? []) {
992
- const sourceStr = typeof pkg === "string" ? pkg : pkg.source;
993
- if (identity && this.getPackageIdentity(sourceStr, "user") !== identity) continue;
994
- matched = true;
995
- updateSources.push({ source: sourceStr, scope: "user" });
996
- }
997
- for (const pkg of projectSettings.packages ?? []) {
998
- const sourceStr = typeof pkg === "string" ? pkg : pkg.source;
999
- if (identity && this.getPackageIdentity(sourceStr, "project") !== identity) continue;
1000
- matched = true;
1001
- updateSources.push({ source: sourceStr, scope: "project" });
1002
- }
1003
-
1004
- if (source && !matched) {
1005
- throw new Error(
1006
- this.buildNoMatchingPackageMessage(source, [
1007
- ...(globalSettings.packages ?? []),
1008
- ...(projectSettings.packages ?? []),
1009
- ]),
1010
- );
1011
- }
1012
-
1013
- await this.updateConfiguredSources(updateSources);
1014
- }
1015
-
1016
- private async updateConfiguredSources(sources: ConfiguredUpdateSource[]): Promise<void> {
1017
- if (isOfflineModeEnabled() || sources.length === 0) {
1018
- return;
1019
- }
1020
-
1021
- const npmCandidates: NpmUpdateTarget[] = [];
1022
- const gitCandidates: GitUpdateTarget[] = [];
1023
-
1024
- for (const entry of sources) {
1025
- const parsed = this.parseSource(entry.source);
1026
- if (parsed.type === "local" || parsed.pinned) {
1027
- continue;
1028
- }
1029
- if (parsed.type === "npm") {
1030
- npmCandidates.push({ ...entry, parsed });
1031
- continue;
1032
- }
1033
- gitCandidates.push({ ...entry, parsed });
1034
- }
1035
-
1036
- const npmCheckTasks = npmCandidates.map((entry) => async () => ({
1037
- entry,
1038
- shouldUpdate: await this.shouldUpdateNpmSource(entry.parsed, entry.scope),
1039
- }));
1040
- const npmCheckResults = await this.runWithConcurrency(npmCheckTasks, UPDATE_CHECK_CONCURRENCY);
1041
- const userNpmUpdates: NpmUpdateTarget[] = [];
1042
- const projectNpmUpdates: NpmUpdateTarget[] = [];
1043
- for (const result of npmCheckResults) {
1044
- if (!result.shouldUpdate) {
1045
- continue;
1046
- }
1047
- if (result.entry.scope === "user") {
1048
- userNpmUpdates.push(result.entry);
1049
- } else {
1050
- projectNpmUpdates.push(result.entry);
1051
- }
1052
- }
1053
-
1054
- const tasks: Promise<void>[] = [];
1055
- if (userNpmUpdates.length > 0) {
1056
- tasks.push(this.updateNpmBatch(userNpmUpdates, "user"));
1057
- }
1058
- if (projectNpmUpdates.length > 0) {
1059
- tasks.push(this.updateNpmBatch(projectNpmUpdates, "project"));
1060
- }
1061
- if (gitCandidates.length > 0) {
1062
- const gitTasks = gitCandidates.map(
1063
- (entry) => async () =>
1064
- this.withProgress("update", entry.source, `Updating ${entry.source}...`, async () => {
1065
- await this.updateGit(entry.parsed, entry.scope);
1066
- }),
1067
- );
1068
- tasks.push(this.runWithConcurrency(gitTasks, GIT_UPDATE_CONCURRENCY).then(() => {}));
1069
- }
1070
-
1071
- await Promise.all(tasks);
1072
- }
1073
-
1074
- private async shouldUpdateNpmSource(source: NpmSource, scope: InstalledSourceScope): Promise<boolean> {
1075
- const installedPath = this.getNpmInstallPath(source, scope);
1076
- const installedVersion = existsSync(installedPath) ? this.getInstalledNpmVersion(installedPath) : undefined;
1077
- if (!installedVersion) {
1078
- return true;
1079
- }
1080
-
1081
- try {
1082
- const latestVersion = await this.getLatestNpmVersion(source.name);
1083
- return latestVersion !== installedVersion;
1084
- } catch {
1085
- // Preserve existing update behavior when version lookup fails.
1086
- return true;
1087
- }
1088
- }
1089
-
1090
- private async updateNpmBatch(sources: NpmUpdateTarget[], scope: InstalledSourceScope): Promise<void> {
1091
- if (sources.length === 0) {
1092
- return;
1093
- }
1094
-
1095
- const sourceLabel = sources.length === 1 ? sources[0].source : `${scope} npm packages`;
1096
- const message = sources.length === 1 ? `Updating ${sources[0].source}...` : `Updating ${scope} npm packages...`;
1097
- const specs = sources.map((entry) => `${entry.parsed.name}@latest`);
1098
-
1099
- await this.withProgress("update", sourceLabel, message, async () => {
1100
- await this.installNpmBatch(specs, scope);
1101
- });
1102
- }
1103
-
1104
- private async installNpmBatch(specs: string[], scope: InstalledSourceScope): Promise<void> {
1105
- if (scope === "user") {
1106
- await this.runNpmCommand(["install", "-g", ...specs]);
1107
- return;
1108
- }
1109
- const installRoot = this.getNpmInstallRoot(scope, false);
1110
- this.ensureNpmProject(installRoot);
1111
- await this.runNpmCommand(["install", ...specs, "--prefix", installRoot]);
1112
- }
1113
-
1114
- async checkForAvailableUpdates(): Promise<PackageUpdate[]> {
1115
- if (isOfflineModeEnabled()) {
1116
- return [];
1117
- }
1118
-
1119
- const globalSettings = this.settingsManager.getGlobalSettings();
1120
- const projectSettings = this.settingsManager.getProjectSettings();
1121
- const allPackages: Array<{ pkg: PackageSource; scope: SourceScope }> = [];
1122
- for (const pkg of projectSettings.packages ?? []) {
1123
- allPackages.push({ pkg, scope: "project" });
1124
- }
1125
- for (const pkg of globalSettings.packages ?? []) {
1126
- allPackages.push({ pkg, scope: "user" });
1127
- }
1128
-
1129
- const packageSources = this.dedupePackages(allPackages);
1130
- const checks = packageSources
1131
- .filter(
1132
- (entry): entry is { pkg: PackageSource; scope: Exclude<SourceScope, "temporary"> } =>
1133
- entry.scope !== "temporary",
1134
- )
1135
- .map((entry) => async (): Promise<PackageUpdate | undefined> => {
1136
- const source = typeof entry.pkg === "string" ? entry.pkg : entry.pkg.source;
1137
- const parsed = this.parseSource(source);
1138
- if (parsed.type === "local" || parsed.pinned) {
1139
- return undefined;
1140
- }
1141
-
1142
- if (parsed.type === "npm") {
1143
- const installedPath = this.getNpmInstallPath(parsed, entry.scope);
1144
- if (!existsSync(installedPath)) {
1145
- return undefined;
1146
- }
1147
- const hasUpdate = await this.npmHasAvailableUpdate(parsed, installedPath);
1148
- if (!hasUpdate) {
1149
- return undefined;
1150
- }
1151
- return {
1152
- source,
1153
- displayName: parsed.name,
1154
- type: "npm",
1155
- scope: entry.scope,
1156
- };
1157
- }
1158
-
1159
- const installedPath = this.getGitInstallPath(parsed, entry.scope);
1160
- if (!existsSync(installedPath)) {
1161
- return undefined;
1162
- }
1163
- const hasUpdate = await this.gitHasAvailableUpdate(installedPath);
1164
- if (!hasUpdate) {
1165
- return undefined;
1166
- }
1167
- return {
1168
- source,
1169
- displayName: `${parsed.host}/${parsed.path}`,
1170
- type: "git",
1171
- scope: entry.scope,
1172
- };
1173
- });
1174
-
1175
- const results = await this.runWithConcurrency(checks, UPDATE_CHECK_CONCURRENCY);
1176
- return results.filter((result): result is PackageUpdate => result !== undefined);
1177
- }
1178
-
1179
- private async resolvePackageSources(
1180
- sources: Array<{ pkg: PackageSource; scope: SourceScope }>,
1181
- accumulator: ResourceAccumulator,
1182
- onMissing?: (source: string) => Promise<MissingSourceAction>,
1183
- ): Promise<void> {
1184
- for (const { pkg, scope } of sources) {
1185
- const sourceStr = typeof pkg === "string" ? pkg : pkg.source;
1186
- const filter = typeof pkg === "object" ? pkg : undefined;
1187
- const parsed = this.parseSource(sourceStr);
1188
- const metadata: PathMetadata = { source: sourceStr, scope, origin: "package" };
1189
-
1190
- if (parsed.type === "local") {
1191
- const baseDir = this.getBaseDirForScope(scope);
1192
- this.resolveLocalExtensionSource(parsed, accumulator, filter, metadata, baseDir);
1193
- continue;
1194
- }
1195
-
1196
- const installMissing = async (): Promise<boolean> => {
1197
- if (isOfflineModeEnabled()) {
1198
- return false;
1199
- }
1200
- if (!onMissing) {
1201
- await this.installParsedSource(parsed, scope);
1202
- return true;
1203
- }
1204
- const action = await onMissing(sourceStr);
1205
- if (action === "skip") return false;
1206
- if (action === "error") throw new Error(`Missing source: ${sourceStr}`);
1207
- await this.installParsedSource(parsed, scope);
1208
- return true;
1209
- };
1210
-
1211
- if (parsed.type === "npm") {
1212
- const installedPath = this.getNpmInstallPath(parsed, scope);
1213
- const needsInstall =
1214
- !existsSync(installedPath) ||
1215
- (parsed.pinned && !(await this.installedNpmMatchesPinnedVersion(parsed, installedPath)));
1216
- if (needsInstall) {
1217
- const installed = await installMissing();
1218
- if (!installed) continue;
1219
- }
1220
- metadata.baseDir = installedPath;
1221
- this.collectPackageResources(installedPath, accumulator, filter, metadata);
1222
- continue;
1223
- }
1224
-
1225
- if (parsed.type === "git") {
1226
- const installedPath = this.getGitInstallPath(parsed, scope);
1227
- if (!existsSync(installedPath)) {
1228
- const installed = await installMissing();
1229
- if (!installed) continue;
1230
- } else if (scope === "temporary" && !parsed.pinned && !isOfflineModeEnabled()) {
1231
- await this.refreshTemporaryGitSource(parsed, sourceStr);
1232
- }
1233
- metadata.baseDir = installedPath;
1234
- this.collectPackageResources(installedPath, accumulator, filter, metadata);
1235
- }
1236
- }
1237
- }
1238
-
1239
- private resolveLocalExtensionSource(
1240
- source: LocalSource,
1241
- accumulator: ResourceAccumulator,
1242
- filter: PackageFilter | undefined,
1243
- metadata: PathMetadata,
1244
- baseDir: string,
1245
- ): void {
1246
- const resolved = this.resolvePathFromBase(source.path, baseDir);
1247
- if (!existsSync(resolved)) {
1248
- return;
1249
- }
1250
-
1251
- try {
1252
- const stats = statSync(resolved);
1253
- if (stats.isFile()) {
1254
- metadata.baseDir = dirname(resolved);
1255
- this.addResource(accumulator.extensions, resolved, metadata, true);
1256
- return;
1257
- }
1258
- if (stats.isDirectory()) {
1259
- metadata.baseDir = resolved;
1260
- const resources = this.collectPackageResources(resolved, accumulator, filter, metadata);
1261
- if (!resources) {
1262
- this.addResource(accumulator.extensions, resolved, metadata, true);
1263
- }
1264
- }
1265
- } catch {
1266
- return;
1267
- }
1268
- }
1269
-
1270
- private async installParsedSource(parsed: ParsedSource, scope: SourceScope): Promise<void> {
1271
- if (parsed.type === "npm") {
1272
- await this.installNpm(parsed, scope, scope === "temporary");
1273
- return;
1274
- }
1275
- if (parsed.type === "git") {
1276
- await this.installGit(parsed, scope);
1277
- return;
1278
- }
1279
- }
1280
-
1281
- private getPackageSourceString(pkg: PackageSource): string {
1282
- return typeof pkg === "string" ? pkg : pkg.source;
1283
- }
1284
-
1285
- private getSourceMatchKeyForInput(source: string): string {
1286
- const parsed = this.parseSource(source);
1287
- if (parsed.type === "npm") {
1288
- return `npm:${parsed.name}`;
1289
- }
1290
- if (parsed.type === "git") {
1291
- return `git:${parsed.host}/${parsed.path}`;
1292
- }
1293
- return `local:${this.resolvePath(parsed.path)}`;
1294
- }
1295
-
1296
- private getSourceMatchKeyForSettings(source: string, scope: SourceScope): string {
1297
- const parsed = this.parseSource(source);
1298
- if (parsed.type === "npm") {
1299
- return `npm:${parsed.name}`;
1300
- }
1301
- if (parsed.type === "git") {
1302
- return `git:${parsed.host}/${parsed.path}`;
1303
- }
1304
- const baseDir = this.getBaseDirForScope(scope);
1305
- return `local:${this.resolvePathFromBase(parsed.path, baseDir)}`;
1306
- }
1307
-
1308
- private buildNoMatchingPackageMessage(source: string, configuredPackages: PackageSource[]): string {
1309
- const suggestion = this.findSuggestedConfiguredSource(source, configuredPackages);
1310
- if (!suggestion) {
1311
- return `No matching package found for ${source}`;
1312
- }
1313
- return `No matching package found for ${source}. Did you mean ${suggestion}?`;
1314
- }
1315
-
1316
- private findSuggestedConfiguredSource(source: string, configuredPackages: PackageSource[]): string | undefined {
1317
- const trimmedSource = source.trim();
1318
- const suggestions = new Set<string>();
1319
-
1320
- for (const pkg of configuredPackages) {
1321
- const sourceStr = this.getPackageSourceString(pkg);
1322
- const parsed = this.parseSource(sourceStr);
1323
- if (parsed.type === "npm") {
1324
- if (trimmedSource === parsed.name || trimmedSource === parsed.spec) {
1325
- suggestions.add(sourceStr);
1326
- }
1327
- continue;
1328
- }
1329
- if (parsed.type === "git") {
1330
- const shorthand = `${parsed.host}/${parsed.path}`;
1331
- const shorthandWithRef = parsed.ref ? `${shorthand}@${parsed.ref}` : undefined;
1332
- if (trimmedSource === shorthand || (shorthandWithRef && trimmedSource === shorthandWithRef)) {
1333
- suggestions.add(sourceStr);
1334
- }
1335
- }
1336
- }
1337
-
1338
- return suggestions.values().next().value;
1339
- }
1340
-
1341
- private packageSourcesMatch(existing: PackageSource, inputSource: string, scope: SourceScope): boolean {
1342
- const left = this.getSourceMatchKeyForSettings(this.getPackageSourceString(existing), scope);
1343
- const right = this.getSourceMatchKeyForInput(inputSource);
1344
- return left === right;
1345
- }
1346
-
1347
- private normalizePackageSourceForSettings(source: string, scope: SourceScope): string {
1348
- const parsed = this.parseSource(source);
1349
- if (parsed.type !== "local") {
1350
- return source;
1351
- }
1352
- const baseDir = this.getBaseDirForScope(scope);
1353
- const resolved = this.resolvePath(parsed.path);
1354
- const rel = relative(baseDir, resolved);
1355
- return rel || ".";
1356
- }
1357
-
1358
- private parseSource(source: string): ParsedSource {
1359
- if (source.startsWith("npm:")) {
1360
- const spec = source.slice("npm:".length).trim();
1361
- const { name, version } = this.parseNpmSpec(spec);
1362
- return {
1363
- type: "npm",
1364
- spec,
1365
- name,
1366
- pinned: Boolean(version),
1367
- };
1368
- }
1369
-
1370
- if (isLocalPath(source)) {
1371
- return { type: "local", path: source };
1372
- }
1373
-
1374
- // Try parsing as git URL
1375
- const gitParsed = parseGitUrl(source);
1376
- if (gitParsed) {
1377
- return gitParsed;
1378
- }
1379
-
1380
- return { type: "local", path: source };
1381
- }
1382
-
1383
- private async installedNpmMatchesPinnedVersion(source: NpmSource, installedPath: string): Promise<boolean> {
1384
- const installedVersion = this.getInstalledNpmVersion(installedPath);
1385
- if (!installedVersion) {
1386
- return false;
1387
- }
1388
-
1389
- const { version: pinnedVersion } = this.parseNpmSpec(source.spec);
1390
- if (!pinnedVersion) {
1391
- return true;
1392
- }
1393
-
1394
- return installedVersion === pinnedVersion;
1395
- }
1396
-
1397
- private async npmHasAvailableUpdate(source: NpmSource, installedPath: string): Promise<boolean> {
1398
- if (isOfflineModeEnabled()) {
1399
- return false;
1400
- }
1401
-
1402
- const installedVersion = this.getInstalledNpmVersion(installedPath);
1403
- if (!installedVersion) {
1404
- return false;
1405
- }
1406
-
1407
- try {
1408
- const latestVersion = await this.getLatestNpmVersion(source.name);
1409
- return latestVersion !== installedVersion;
1410
- } catch {
1411
- return false;
1412
- }
1413
- }
1414
-
1415
- private getInstalledNpmVersion(installedPath: string): string | undefined {
1416
- const packageJsonPath = join(installedPath, "package.json");
1417
- if (!existsSync(packageJsonPath)) return undefined;
1418
- try {
1419
- const content = readFileSync(packageJsonPath, "utf-8");
1420
- const pkg = JSON.parse(content) as { version?: string };
1421
- return pkg.version;
1422
- } catch {
1423
- return undefined;
1424
- }
1425
- }
1426
-
1427
- private async getLatestNpmVersion(packageName: string): Promise<string> {
1428
- const npmCommand = this.getNpmCommand();
1429
- const stdout = await this.runCommandCapture(
1430
- npmCommand.command,
1431
- [...npmCommand.args, "view", packageName, "version", "--json"],
1432
- { cwd: this.cwd, timeoutMs: NETWORK_TIMEOUT_MS },
1433
- );
1434
- const raw = stdout.trim();
1435
- if (!raw) throw new Error("Empty response from npm view");
1436
- return JSON.parse(raw);
1437
- }
1438
-
1439
- private async gitHasAvailableUpdate(installedPath: string): Promise<boolean> {
1440
- if (isOfflineModeEnabled()) {
1441
- return false;
1442
- }
1443
-
1444
- try {
1445
- const localHead = await this.runCommandCapture("git", ["rev-parse", "HEAD"], {
1446
- cwd: installedPath,
1447
- timeoutMs: NETWORK_TIMEOUT_MS,
1448
- });
1449
- const remoteHead = await this.getRemoteGitHead(installedPath);
1450
- return localHead.trim() !== remoteHead.trim();
1451
- } catch {
1452
- return false;
1453
- }
1454
- }
1455
-
1456
- private async getRemoteGitHead(installedPath: string): Promise<string> {
1457
- const upstreamRef = await this.getGitUpstreamRef(installedPath);
1458
- if (upstreamRef) {
1459
- const remoteHead = await this.runGitRemoteCommand(installedPath, ["ls-remote", "origin", upstreamRef]);
1460
- const match = remoteHead.match(/^([0-9a-f]{40})\s+/m);
1461
- if (match?.[1]) {
1462
- return match[1];
1463
- }
1464
- }
1465
-
1466
- const remoteHead = await this.runGitRemoteCommand(installedPath, ["ls-remote", "origin", "HEAD"]);
1467
- const match = remoteHead.match(/^([0-9a-f]{40})\s+HEAD$/m);
1468
- if (!match?.[1]) {
1469
- throw new Error("Failed to determine remote HEAD");
1470
- }
1471
- return match[1];
1472
- }
1473
-
1474
- private async getLocalGitUpdateTarget(
1475
- installedPath: string,
1476
- ): Promise<{ ref: string; head: string; fetchArgs: string[] }> {
1477
- try {
1478
- const upstream = await this.runCommandCapture("git", ["rev-parse", "--abbrev-ref", "@{upstream}"], {
1479
- cwd: installedPath,
1480
- timeoutMs: NETWORK_TIMEOUT_MS,
1481
- });
1482
- const trimmedUpstream = upstream.trim();
1483
- if (!trimmedUpstream.startsWith("origin/")) {
1484
- throw new Error(`Unsupported upstream remote: ${trimmedUpstream}`);
1485
- }
1486
- const branch = trimmedUpstream.slice("origin/".length);
1487
- if (!branch) {
1488
- throw new Error("Missing upstream branch name");
1489
- }
1490
- const head = await this.runCommandCapture("git", ["rev-parse", "@{upstream}"], {
1491
- cwd: installedPath,
1492
- timeoutMs: NETWORK_TIMEOUT_MS,
1493
- });
1494
- return {
1495
- ref: "@{upstream}",
1496
- head,
1497
- fetchArgs: [
1498
- "fetch",
1499
- "--prune",
1500
- "--no-tags",
1501
- "origin",
1502
- `+refs/heads/${branch}:refs/remotes/origin/${branch}`,
1503
- ],
1504
- };
1505
- } catch {
1506
- await this.runCommand("git", ["remote", "set-head", "origin", "-a"], { cwd: installedPath }).catch(() => {});
1507
- const head = await this.runCommandCapture("git", ["rev-parse", "origin/HEAD"], {
1508
- cwd: installedPath,
1509
- timeoutMs: NETWORK_TIMEOUT_MS,
1510
- });
1511
- const originHeadRef = await this.runCommandCapture("git", ["symbolic-ref", "refs/remotes/origin/HEAD"], {
1512
- cwd: installedPath,
1513
- timeoutMs: NETWORK_TIMEOUT_MS,
1514
- }).catch(() => "");
1515
- const branch = originHeadRef.trim().replace(/^refs\/remotes\/origin\//, "");
1516
- if (branch) {
1517
- return {
1518
- ref: "origin/HEAD",
1519
- head,
1520
- fetchArgs: [
1521
- "fetch",
1522
- "--prune",
1523
- "--no-tags",
1524
- "origin",
1525
- `+refs/heads/${branch}:refs/remotes/origin/${branch}`,
1526
- ],
1527
- };
1528
- }
1529
- return {
1530
- ref: "origin/HEAD",
1531
- head,
1532
- fetchArgs: ["fetch", "--prune", "--no-tags", "origin", "+HEAD:refs/remotes/origin/HEAD"],
1533
- };
1534
- }
1535
- }
1536
-
1537
- private async getGitUpstreamRef(installedPath: string): Promise<string | undefined> {
1538
- try {
1539
- const upstream = await this.runCommandCapture("git", ["rev-parse", "--abbrev-ref", "@{upstream}"], {
1540
- cwd: installedPath,
1541
- timeoutMs: NETWORK_TIMEOUT_MS,
1542
- });
1543
- const trimmed = upstream.trim();
1544
- if (!trimmed.startsWith("origin/")) {
1545
- return undefined;
1546
- }
1547
- const branch = trimmed.slice("origin/".length);
1548
- return branch ? `refs/heads/${branch}` : undefined;
1549
- } catch {
1550
- return undefined;
1551
- }
1552
- }
1553
-
1554
- private runGitRemoteCommand(installedPath: string, args: string[]): Promise<string> {
1555
- return this.runCommandCapture("git", args, {
1556
- cwd: installedPath,
1557
- timeoutMs: NETWORK_TIMEOUT_MS,
1558
- env: {
1559
- GIT_TERMINAL_PROMPT: "0",
1560
- },
1561
- });
1562
- }
1563
-
1564
- private async runWithConcurrency<T>(tasks: Array<() => Promise<T>>, limit: number): Promise<T[]> {
1565
- if (tasks.length === 0) {
1566
- return [];
1567
- }
1568
-
1569
- const results: T[] = new Array(tasks.length);
1570
- let nextIndex = 0;
1571
- const workerCount = Math.max(1, Math.min(limit, tasks.length));
1572
-
1573
- const worker = async () => {
1574
- while (true) {
1575
- const index = nextIndex;
1576
- nextIndex += 1;
1577
- if (index >= tasks.length) {
1578
- return;
1579
- }
1580
- results[index] = await tasks[index]();
1581
- }
1582
- };
1583
-
1584
- await Promise.all(Array.from({ length: workerCount }, () => worker()));
1585
- return results;
1586
- }
1587
-
1588
- /**
1589
- * Get a unique identity for a package, ignoring version/ref.
1590
- * Used to detect when the same package is in both global and project settings.
1591
- * For git packages, uses normalized host/path to ensure SSH and HTTPS URLs
1592
- * for the same repository are treated as identical.
1593
- */
1594
- private getPackageIdentity(source: string, scope?: SourceScope): string {
1595
- const parsed = this.parseSource(source);
1596
- if (parsed.type === "npm") {
1597
- return `npm:${parsed.name}`;
1598
- }
1599
- if (parsed.type === "git") {
1600
- // Use host/path for identity to normalize SSH and HTTPS
1601
- return `git:${parsed.host}/${parsed.path}`;
1602
- }
1603
- if (scope) {
1604
- const baseDir = this.getBaseDirForScope(scope);
1605
- return `local:${this.resolvePathFromBase(parsed.path, baseDir)}`;
1606
- }
1607
- return `local:${this.resolvePath(parsed.path)}`;
1608
- }
1609
-
1610
- /**
1611
- * Dedupe packages: if same package identity appears in both global and project,
1612
- * keep only the project one (project wins).
1613
- */
1614
- private dedupePackages(
1615
- packages: Array<{ pkg: PackageSource; scope: SourceScope }>,
1616
- ): Array<{ pkg: PackageSource; scope: SourceScope }> {
1617
- const seen = new Map<string, { pkg: PackageSource; scope: SourceScope }>();
1618
-
1619
- for (const entry of packages) {
1620
- const sourceStr = typeof entry.pkg === "string" ? entry.pkg : entry.pkg.source;
1621
- const identity = this.getPackageIdentity(sourceStr, entry.scope);
1622
-
1623
- const existing = seen.get(identity);
1624
- if (!existing) {
1625
- seen.set(identity, entry);
1626
- } else if (entry.scope === "project" && existing.scope === "user") {
1627
- // Project wins over user
1628
- seen.set(identity, entry);
1629
- }
1630
- // If existing is project and new is global, keep existing (project)
1631
- // If both are same scope, keep first one
1632
- }
1633
-
1634
- return Array.from(seen.values());
1635
- }
1636
-
1637
- private parseNpmSpec(spec: string): { name: string; version?: string } {
1638
- const match = spec.match(/^(@?[^@]+(?:\/[^@]+)?)(?:@(.+))?$/);
1639
- if (!match) {
1640
- return { name: spec };
1641
- }
1642
- const name = match[1] ?? spec;
1643
- const version = match[2];
1644
- return { name, version };
1645
- }
1646
-
1647
- private getNpmCommand(): { command: string; args: string[] } {
1648
- const configuredCommand = this.settingsManager.getNpmCommand();
1649
- if (!configuredCommand || configuredCommand.length === 0) {
1650
- return { command: "npm", args: [] };
1651
- }
1652
- const [command, ...args] = configuredCommand;
1653
- if (!command) {
1654
- throw new Error("Invalid npmCommand: first array entry must be a non-empty command");
1655
- }
1656
- return { command, args };
1657
- }
1658
-
1659
- private async runNpmCommand(args: string[], options?: { cwd?: string }): Promise<void> {
1660
- const npmCommand = this.getNpmCommand();
1661
- await this.runCommand(npmCommand.command, [...npmCommand.args, ...args], options);
1662
- }
1663
-
1664
- private runNpmCommandSync(args: string[]): string {
1665
- const npmCommand = this.getNpmCommand();
1666
- return this.runCommandSync(npmCommand.command, [...npmCommand.args, ...args]);
1667
- }
1668
-
1669
- private async installNpm(source: NpmSource, scope: SourceScope, temporary: boolean): Promise<void> {
1670
- if (scope === "user" && !temporary) {
1671
- await this.runNpmCommand(["install", "-g", source.spec]);
1672
- return;
1673
- }
1674
- const installRoot = this.getNpmInstallRoot(scope, temporary);
1675
- this.ensureNpmProject(installRoot);
1676
- await this.runNpmCommand(["install", source.spec, "--prefix", installRoot]);
1677
- }
1678
-
1679
- private async uninstallNpm(source: NpmSource, scope: SourceScope): Promise<void> {
1680
- if (scope === "user") {
1681
- await this.runNpmCommand(["uninstall", "-g", source.name]);
1682
- return;
1683
- }
1684
- const installRoot = this.getNpmInstallRoot(scope, false);
1685
- if (!existsSync(installRoot)) {
1686
- return;
1687
- }
1688
- await this.runNpmCommand(["uninstall", source.name, "--prefix", installRoot]);
1689
- }
1690
-
1691
- private async installGit(source: GitSource, scope: SourceScope): Promise<void> {
1692
- const targetDir = this.getGitInstallPath(source, scope);
1693
- if (existsSync(targetDir)) {
1694
- return;
1695
- }
1696
- const gitRoot = this.getGitInstallRoot(scope);
1697
- if (gitRoot) {
1698
- this.ensureGitIgnore(gitRoot);
1699
- }
1700
- mkdirSync(dirname(targetDir), { recursive: true });
1701
-
1702
- await this.runCommand("git", ["clone", source.repo, targetDir]);
1703
- if (source.ref) {
1704
- await this.runCommand("git", ["checkout", source.ref], { cwd: targetDir });
1705
- }
1706
- const packageJsonPath = join(targetDir, "package.json");
1707
- if (existsSync(packageJsonPath)) {
1708
- await this.runNpmCommand(["install", "--omit=dev"], { cwd: targetDir });
1709
- }
1710
- }
1711
-
1712
- private async updateGit(source: GitSource, scope: SourceScope): Promise<void> {
1713
- const targetDir = this.getGitInstallPath(source, scope);
1714
- if (!existsSync(targetDir)) {
1715
- await this.installGit(source, scope);
1716
- return;
1717
- }
1718
-
1719
- const target = await this.getLocalGitUpdateTarget(targetDir);
1720
-
1721
- // Fetch only the ref we will reset to, avoiding unrelated branch/tag noise.
1722
- await this.runCommand("git", target.fetchArgs, { cwd: targetDir });
1723
-
1724
- const localHead = await this.runCommandCapture("git", ["rev-parse", "HEAD"], {
1725
- cwd: targetDir,
1726
- timeoutMs: NETWORK_TIMEOUT_MS,
1727
- });
1728
- const refreshedTargetHead = await this.runCommandCapture("git", ["rev-parse", target.ref], {
1729
- cwd: targetDir,
1730
- timeoutMs: NETWORK_TIMEOUT_MS,
1731
- });
1732
- if (localHead.trim() === refreshedTargetHead.trim()) {
1733
- return;
1734
- }
1735
-
1736
- await this.runCommand("git", ["reset", "--hard", target.ref], { cwd: targetDir });
1737
-
1738
- // Clean untracked files (extensions should be pristine)
1739
- await this.runCommand("git", ["clean", "-fdx"], { cwd: targetDir });
1740
-
1741
- const packageJsonPath = join(targetDir, "package.json");
1742
- if (existsSync(packageJsonPath)) {
1743
- await this.runNpmCommand(["install", "--omit=dev"], { cwd: targetDir });
1744
- }
1745
- }
1746
-
1747
- private async refreshTemporaryGitSource(source: GitSource, sourceStr: string): Promise<void> {
1748
- if (isOfflineModeEnabled()) {
1749
- return;
1750
- }
1751
- try {
1752
- await this.withProgress("pull", sourceStr, `Refreshing ${sourceStr}...`, async () => {
1753
- await this.updateGit(source, "temporary");
1754
- });
1755
- } catch {
1756
- // Keep cached temporary checkout if refresh fails.
1757
- }
1758
- }
1759
-
1760
- private async removeGit(source: GitSource, scope: SourceScope): Promise<void> {
1761
- const targetDir = this.getGitInstallPath(source, scope);
1762
- if (!existsSync(targetDir)) return;
1763
- rmSync(targetDir, { recursive: true, force: true });
1764
- this.pruneEmptyGitParents(targetDir, this.getGitInstallRoot(scope));
1765
- }
1766
-
1767
- private pruneEmptyGitParents(targetDir: string, installRoot: string | undefined): void {
1768
- if (!installRoot) return;
1769
- const resolvedRoot = resolve(installRoot);
1770
- let current = dirname(targetDir);
1771
- while (current.startsWith(resolvedRoot) && current !== resolvedRoot) {
1772
- if (!existsSync(current)) {
1773
- current = dirname(current);
1774
- continue;
1775
- }
1776
- const entries = readdirSync(current);
1777
- if (entries.length > 0) {
1778
- break;
1779
- }
1780
- try {
1781
- rmSync(current, { recursive: true, force: true });
1782
- } catch {
1783
- break;
1784
- }
1785
- current = dirname(current);
1786
- }
1787
- }
1788
-
1789
- private ensureNpmProject(installRoot: string): void {
1790
- if (!existsSync(installRoot)) {
1791
- mkdirSync(installRoot, { recursive: true });
1792
- }
1793
- this.ensureGitIgnore(installRoot);
1794
- const packageJsonPath = join(installRoot, "package.json");
1795
- if (!existsSync(packageJsonPath)) {
1796
- const pkgJson = { name: "pi-extensions", private: true };
1797
- writeFileSync(packageJsonPath, JSON.stringify(pkgJson, null, 2), "utf-8");
1798
- }
1799
- }
1800
-
1801
- private ensureGitIgnore(dir: string): void {
1802
- if (!existsSync(dir)) {
1803
- mkdirSync(dir, { recursive: true });
1804
- }
1805
- const ignorePath = join(dir, ".gitignore");
1806
- if (!existsSync(ignorePath)) {
1807
- writeFileSync(ignorePath, "*\n!.gitignore\n", "utf-8");
1808
- }
1809
- }
1810
-
1811
- private getNpmInstallRoot(scope: SourceScope, temporary: boolean): string {
1812
- if (temporary) {
1813
- return this.getTemporaryDir("npm");
1814
- }
1815
- if (scope === "project") {
1816
- return join(this.cwd, CONFIG_DIR_NAME, "npm");
1817
- }
1818
- return join(this.getGlobalNpmRoot(), "..");
1819
- }
1820
-
1821
- private getGlobalNpmRoot(): string {
1822
- const npmCommand = this.getNpmCommand();
1823
- const commandKey = [npmCommand.command, ...npmCommand.args].join("\0");
1824
- if (this.globalNpmRoot && this.globalNpmRootCommandKey === commandKey) {
1825
- return this.globalNpmRoot;
1826
- }
1827
- const result = this.runNpmCommandSync(["root", "-g"]);
1828
- this.globalNpmRoot = result.trim();
1829
- this.globalNpmRootCommandKey = commandKey;
1830
- return this.globalNpmRoot;
1831
- }
1832
-
1833
- private getNpmInstallPath(source: NpmSource, scope: SourceScope): string {
1834
- if (scope === "temporary") {
1835
- return join(this.getTemporaryDir("npm"), "node_modules", source.name);
1836
- }
1837
- if (scope === "project") {
1838
- return join(this.cwd, CONFIG_DIR_NAME, "npm", "node_modules", source.name);
1839
- }
1840
- return join(this.getGlobalNpmRoot(), source.name);
1841
- }
1842
-
1843
- private getGitInstallPath(source: GitSource, scope: SourceScope): string {
1844
- if (scope === "temporary") {
1845
- return this.getTemporaryDir(`git-${source.host}`, source.path);
1846
- }
1847
- if (scope === "project") {
1848
- return join(this.cwd, CONFIG_DIR_NAME, "git", source.host, source.path);
1849
- }
1850
- return join(this.agentDir, "git", source.host, source.path);
1851
- }
1852
-
1853
- private getGitInstallRoot(scope: SourceScope): string | undefined {
1854
- if (scope === "temporary") {
1855
- return undefined;
1856
- }
1857
- if (scope === "project") {
1858
- return join(this.cwd, CONFIG_DIR_NAME, "git");
1859
- }
1860
- return join(this.agentDir, "git");
1861
- }
1862
-
1863
- private getTemporaryDir(prefix: string, suffix?: string): string {
1864
- const hash = createHash("sha256")
1865
- .update(`${prefix}-${suffix ?? ""}`)
1866
- .digest("hex")
1867
- .slice(0, 8);
1868
- return join(tmpdir(), "pi-extensions", prefix, hash, suffix ?? "");
1869
- }
1870
-
1871
- private getBaseDirForScope(scope: SourceScope): string {
1872
- if (scope === "project") {
1873
- return join(this.cwd, CONFIG_DIR_NAME);
1874
- }
1875
- if (scope === "user") {
1876
- return this.agentDir;
1877
- }
1878
- return this.cwd;
1879
- }
1880
-
1881
- private resolvePath(input: string): string {
1882
- const trimmed = input.trim();
1883
- if (trimmed === "~") return getHomeDir();
1884
- if (trimmed.startsWith("~/")) return join(getHomeDir(), trimmed.slice(2));
1885
- if (trimmed.startsWith("~")) return join(getHomeDir(), trimmed.slice(1));
1886
- return resolve(this.cwd, trimmed);
1887
- }
1888
-
1889
- private resolvePathFromBase(input: string, baseDir: string): string {
1890
- const trimmed = input.trim();
1891
- if (trimmed === "~") return getHomeDir();
1892
- if (trimmed.startsWith("~/")) return join(getHomeDir(), trimmed.slice(2));
1893
- if (trimmed.startsWith("~")) return join(getHomeDir(), trimmed.slice(1));
1894
- return resolve(baseDir, trimmed);
1895
- }
1896
-
1897
- private collectPackageResources(
1898
- packageRoot: string,
1899
- accumulator: ResourceAccumulator,
1900
- filter: PackageFilter | undefined,
1901
- metadata: PathMetadata,
1902
- ): boolean {
1903
- if (filter) {
1904
- for (const resourceType of RESOURCE_TYPES) {
1905
- const patterns = filter[resourceType as keyof PackageFilter];
1906
- const target = this.getTargetMap(accumulator, resourceType);
1907
- if (patterns !== undefined) {
1908
- this.applyPackageFilter(packageRoot, patterns, resourceType, target, metadata);
1909
- } else {
1910
- this.collectDefaultResources(packageRoot, resourceType, target, metadata);
1911
- }
1912
- }
1913
- return true;
1914
- }
1915
-
1916
- const manifest = this.readPiManifest(packageRoot);
1917
- if (manifest) {
1918
- for (const resourceType of RESOURCE_TYPES) {
1919
- const entries = manifest[resourceType as keyof PiManifest];
1920
- this.addManifestEntries(
1921
- entries,
1922
- packageRoot,
1923
- resourceType,
1924
- this.getTargetMap(accumulator, resourceType),
1925
- metadata,
1926
- );
1927
- }
1928
- return true;
1929
- }
1930
-
1931
- let hasAnyDir = false;
1932
- for (const resourceType of RESOURCE_TYPES) {
1933
- const dir = join(packageRoot, resourceType);
1934
- if (existsSync(dir)) {
1935
- // Collect all files from the directory (all enabled by default)
1936
- const files = collectResourceFiles(dir, resourceType);
1937
- for (const f of files) {
1938
- this.addResource(this.getTargetMap(accumulator, resourceType), f, metadata, true);
1939
- }
1940
- hasAnyDir = true;
1941
- }
1942
- }
1943
- return hasAnyDir;
1944
- }
1945
-
1946
- private collectDefaultResources(
1947
- packageRoot: string,
1948
- resourceType: ResourceType,
1949
- target: Map<string, { metadata: PathMetadata; enabled: boolean }>,
1950
- metadata: PathMetadata,
1951
- ): void {
1952
- const manifest = this.readPiManifest(packageRoot);
1953
- const entries = manifest?.[resourceType as keyof PiManifest];
1954
- if (entries) {
1955
- this.addManifestEntries(entries, packageRoot, resourceType, target, metadata);
1956
- return;
1957
- }
1958
- const dir = join(packageRoot, resourceType);
1959
- if (existsSync(dir)) {
1960
- // Collect all files from the directory (all enabled by default)
1961
- const files = collectResourceFiles(dir, resourceType);
1962
- for (const f of files) {
1963
- this.addResource(target, f, metadata, true);
1964
- }
1965
- }
1966
- }
1967
-
1968
- private applyPackageFilter(
1969
- packageRoot: string,
1970
- userPatterns: string[],
1971
- resourceType: ResourceType,
1972
- target: Map<string, { metadata: PathMetadata; enabled: boolean }>,
1973
- metadata: PathMetadata,
1974
- ): void {
1975
- const { allFiles } = this.collectManifestFiles(packageRoot, resourceType);
1976
-
1977
- if (userPatterns.length === 0) {
1978
- // Empty array explicitly disables all resources of this type
1979
- for (const f of allFiles) {
1980
- this.addResource(target, f, metadata, false);
1981
- }
1982
- return;
1983
- }
1984
-
1985
- // Apply user patterns
1986
- const enabledByUser = applyPatterns(allFiles, userPatterns, packageRoot);
1987
-
1988
- for (const f of allFiles) {
1989
- const enabled = enabledByUser.has(f);
1990
- this.addResource(target, f, metadata, enabled);
1991
- }
1992
- }
1993
-
1994
- /**
1995
- * Collect all files from a package for a resource type, applying manifest patterns.
1996
- * Returns { allFiles, enabledByManifest } where enabledByManifest is the set of files
1997
- * that pass the manifest's own patterns.
1998
- */
1999
- private collectManifestFiles(
2000
- packageRoot: string,
2001
- resourceType: ResourceType,
2002
- ): { allFiles: string[]; enabledByManifest: Set<string> } {
2003
- const manifest = this.readPiManifest(packageRoot);
2004
- const entries = manifest?.[resourceType as keyof PiManifest];
2005
- if (entries && entries.length > 0) {
2006
- const allFiles = this.collectFilesFromManifestEntries(entries, packageRoot, resourceType);
2007
- const manifestPatterns = entries.filter(isOverridePattern);
2008
- const enabledByManifest =
2009
- manifestPatterns.length > 0 ? applyPatterns(allFiles, manifestPatterns, packageRoot) : new Set(allFiles);
2010
- return { allFiles: Array.from(enabledByManifest), enabledByManifest };
2011
- }
2012
-
2013
- const conventionDir = join(packageRoot, resourceType);
2014
- if (!existsSync(conventionDir)) {
2015
- return { allFiles: [], enabledByManifest: new Set() };
2016
- }
2017
- const allFiles = collectResourceFiles(conventionDir, resourceType);
2018
- return { allFiles, enabledByManifest: new Set(allFiles) };
2019
- }
2020
-
2021
- private readPiManifest(packageRoot: string): PiManifest | null {
2022
- const packageJsonPath = join(packageRoot, "package.json");
2023
- if (!existsSync(packageJsonPath)) {
2024
- return null;
2025
- }
2026
-
2027
- try {
2028
- const content = readFileSync(packageJsonPath, "utf-8");
2029
- const pkg = JSON.parse(content) as { pi?: PiManifest };
2030
- return pkg.pi ?? null;
2031
- } catch {
2032
- return null;
2033
- }
2034
- }
2035
-
2036
- private addManifestEntries(
2037
- entries: string[] | undefined,
2038
- root: string,
2039
- resourceType: ResourceType,
2040
- target: Map<string, { metadata: PathMetadata; enabled: boolean }>,
2041
- metadata: PathMetadata,
2042
- ): void {
2043
- if (!entries) return;
2044
-
2045
- const allFiles = this.collectFilesFromManifestEntries(entries, root, resourceType);
2046
- const patterns = entries.filter(isOverridePattern);
2047
- const enabledPaths = applyPatterns(allFiles, patterns, root);
2048
-
2049
- for (const f of allFiles) {
2050
- if (enabledPaths.has(f)) {
2051
- this.addResource(target, f, metadata, true);
2052
- }
2053
- }
2054
- }
2055
-
2056
- private collectFilesFromManifestEntries(entries: string[], root: string, resourceType: ResourceType): string[] {
2057
- const sourceEntries = entries.filter((entry) => !isOverridePattern(entry));
2058
- const resolved = sourceEntries.flatMap((entry) => {
2059
- if (!hasGlobPattern(entry)) {
2060
- return [resolve(root, entry)];
2061
- }
2062
-
2063
- return globSync(entry, {
2064
- cwd: root,
2065
- absolute: true,
2066
- dot: false,
2067
- nodir: false,
2068
- }).map((match) => resolve(match));
2069
- });
2070
- return this.collectFilesFromPaths(resolved, resourceType);
2071
- }
2072
-
2073
- private resolveLocalEntries(
2074
- entries: string[],
2075
- resourceType: ResourceType,
2076
- target: Map<string, { metadata: PathMetadata; enabled: boolean }>,
2077
- metadata: PathMetadata,
2078
- baseDir: string,
2079
- ): void {
2080
- if (entries.length === 0) return;
2081
-
2082
- // Collect all files from plain entries (non-pattern entries)
2083
- const { plain, patterns } = splitPatterns(entries);
2084
- const resolvedPlain = plain.map((p) => this.resolvePathFromBase(p, baseDir));
2085
- const allFiles = this.collectFilesFromPaths(resolvedPlain, resourceType);
2086
-
2087
- // Determine which files are enabled based on patterns
2088
- const enabledPaths = applyPatterns(allFiles, patterns, baseDir);
2089
-
2090
- // Add all files with their enabled state
2091
- for (const f of allFiles) {
2092
- this.addResource(target, f, metadata, enabledPaths.has(f));
2093
- }
2094
- }
2095
-
2096
- private addAutoDiscoveredResources(
2097
- accumulator: ResourceAccumulator,
2098
- globalSettings: ReturnType<SettingsManager["getGlobalSettings"]>,
2099
- projectSettings: ReturnType<SettingsManager["getProjectSettings"]>,
2100
- globalBaseDir: string,
2101
- projectBaseDir: string,
2102
- ): void {
2103
- const userMetadata: PathMetadata = {
2104
- source: "auto",
2105
- scope: "user",
2106
- origin: "top-level",
2107
- baseDir: globalBaseDir,
2108
- };
2109
- const projectMetadata: PathMetadata = {
2110
- source: "auto",
2111
- scope: "project",
2112
- origin: "top-level",
2113
- baseDir: projectBaseDir,
2114
- };
2115
-
2116
- const userOverrides = {
2117
- extensions: (globalSettings.extensions ?? []) as string[],
2118
- skills: (globalSettings.skills ?? []) as string[],
2119
- prompts: (globalSettings.prompts ?? []) as string[],
2120
- themes: (globalSettings.themes ?? []) as string[],
2121
- };
2122
- const projectOverrides = {
2123
- extensions: (projectSettings.extensions ?? []) as string[],
2124
- skills: (projectSettings.skills ?? []) as string[],
2125
- prompts: (projectSettings.prompts ?? []) as string[],
2126
- themes: (projectSettings.themes ?? []) as string[],
2127
- };
2128
-
2129
- const userDirs = {
2130
- extensions: join(globalBaseDir, "extensions"),
2131
- skills: join(globalBaseDir, "skills"),
2132
- prompts: join(globalBaseDir, "prompts"),
2133
- themes: join(globalBaseDir, "themes"),
2134
- };
2135
- const projectDirs = {
2136
- extensions: join(projectBaseDir, "extensions"),
2137
- skills: join(projectBaseDir, "skills"),
2138
- prompts: join(projectBaseDir, "prompts"),
2139
- themes: join(projectBaseDir, "themes"),
2140
- };
2141
- const userAgentsSkillsDir = join(getHomeDir(), ".agents", "skills");
2142
- const projectAgentsSkillDirs = collectAncestorAgentsSkillDirs(this.cwd).filter(
2143
- (dir) => resolve(dir) !== resolve(userAgentsSkillsDir),
2144
- );
2145
-
2146
- const addResources = (
2147
- resourceType: ResourceType,
2148
- paths: string[],
2149
- metadata: PathMetadata,
2150
- overrides: string[],
2151
- baseDir: string,
2152
- ) => {
2153
- const target = this.getTargetMap(accumulator, resourceType);
2154
- for (const path of paths) {
2155
- const enabled = isEnabledByOverrides(path, overrides, baseDir);
2156
- this.addResource(target, path, metadata, enabled);
2157
- }
2158
- };
2159
-
2160
- addResources(
2161
- "extensions",
2162
- collectAutoExtensionEntries(projectDirs.extensions),
2163
- projectMetadata,
2164
- projectOverrides.extensions,
2165
- projectBaseDir,
2166
- );
2167
- addResources(
2168
- "skills",
2169
- [
2170
- ...collectAutoSkillEntries(projectDirs.skills, "pi"),
2171
- ...projectAgentsSkillDirs.flatMap((dir) => collectAutoSkillEntries(dir, "agents")),
2172
- ],
2173
- projectMetadata,
2174
- projectOverrides.skills,
2175
- projectBaseDir,
2176
- );
2177
- addResources(
2178
- "prompts",
2179
- collectAutoPromptEntries(projectDirs.prompts),
2180
- projectMetadata,
2181
- projectOverrides.prompts,
2182
- projectBaseDir,
2183
- );
2184
- addResources(
2185
- "themes",
2186
- collectAutoThemeEntries(projectDirs.themes),
2187
- projectMetadata,
2188
- projectOverrides.themes,
2189
- projectBaseDir,
2190
- );
2191
-
2192
- addResources(
2193
- "extensions",
2194
- collectAutoExtensionEntries(userDirs.extensions),
2195
- userMetadata,
2196
- userOverrides.extensions,
2197
- globalBaseDir,
2198
- );
2199
- addResources(
2200
- "skills",
2201
- [...collectAutoSkillEntries(userDirs.skills, "pi"), ...collectAutoSkillEntries(userAgentsSkillsDir, "agents")],
2202
- userMetadata,
2203
- userOverrides.skills,
2204
- globalBaseDir,
2205
- );
2206
- addResources(
2207
- "prompts",
2208
- collectAutoPromptEntries(userDirs.prompts),
2209
- userMetadata,
2210
- userOverrides.prompts,
2211
- globalBaseDir,
2212
- );
2213
- addResources(
2214
- "themes",
2215
- collectAutoThemeEntries(userDirs.themes),
2216
- userMetadata,
2217
- userOverrides.themes,
2218
- globalBaseDir,
2219
- );
2220
- }
2221
-
2222
- private collectFilesFromPaths(paths: string[], resourceType: ResourceType): string[] {
2223
- const files: string[] = [];
2224
- for (const p of paths) {
2225
- if (!existsSync(p)) continue;
2226
-
2227
- try {
2228
- const stats = statSync(p);
2229
- if (stats.isFile()) {
2230
- files.push(p);
2231
- } else if (stats.isDirectory()) {
2232
- files.push(...collectResourceFiles(p, resourceType));
2233
- }
2234
- } catch {
2235
- // Ignore errors
2236
- }
2237
- }
2238
- return files;
2239
- }
2240
-
2241
- private getTargetMap(
2242
- accumulator: ResourceAccumulator,
2243
- resourceType: ResourceType,
2244
- ): Map<string, { metadata: PathMetadata; enabled: boolean }> {
2245
- switch (resourceType) {
2246
- case "extensions":
2247
- return accumulator.extensions;
2248
- case "skills":
2249
- return accumulator.skills;
2250
- case "prompts":
2251
- return accumulator.prompts;
2252
- case "themes":
2253
- return accumulator.themes;
2254
- default:
2255
- throw new Error(`Unknown resource type: ${resourceType}`);
2256
- }
2257
- }
2258
-
2259
- private addResource(
2260
- map: Map<string, { metadata: PathMetadata; enabled: boolean }>,
2261
- path: string,
2262
- metadata: PathMetadata,
2263
- enabled: boolean,
2264
- ): void {
2265
- if (!path) return;
2266
- if (!map.has(path)) {
2267
- map.set(path, { metadata, enabled });
2268
- }
2269
- }
2270
-
2271
- private createAccumulator(): ResourceAccumulator {
2272
- return {
2273
- extensions: new Map(),
2274
- skills: new Map(),
2275
- prompts: new Map(),
2276
- themes: new Map(),
2277
- };
2278
- }
2279
-
2280
- private toResolvedPaths(accumulator: ResourceAccumulator): ResolvedPaths {
2281
- const toResolved = (entries: Map<string, { metadata: PathMetadata; enabled: boolean }>): ResolvedResource[] => {
2282
- const resolved = Array.from(entries.entries()).map(([path, { metadata, enabled }]) => ({
2283
- path,
2284
- enabled,
2285
- metadata,
2286
- }));
2287
- resolved.sort((a, b) => resourcePrecedenceRank(a.metadata) - resourcePrecedenceRank(b.metadata));
2288
- return resolved;
2289
- };
2290
-
2291
- const seenCanonicalSkillPaths = new Set<string>();
2292
- const resolvedSkills = toResolved(accumulator.skills).filter((entry) => {
2293
- let canonicalPath: string;
2294
- try {
2295
- // Resolve symlink aliases to detect duplicate files.
2296
- canonicalPath = realpathSync(entry.path);
2297
- } catch {
2298
- // Fallback to raw path to match loadSkills() behavior.
2299
- canonicalPath = entry.path;
2300
- }
2301
-
2302
- if (seenCanonicalSkillPaths.has(canonicalPath)) {
2303
- return false;
2304
- }
2305
-
2306
- seenCanonicalSkillPaths.add(canonicalPath);
2307
- return true;
2308
- });
2309
-
2310
- return {
2311
- extensions: toResolved(accumulator.extensions),
2312
- skills: resolvedSkills,
2313
- prompts: toResolved(accumulator.prompts),
2314
- themes: toResolved(accumulator.themes),
2315
- };
2316
- }
2317
-
2318
- private spawnCommand(command: string, args: string[], options?: { cwd?: string }): ChildProcess {
2319
- return spawn(command, args, {
2320
- cwd: options?.cwd,
2321
- stdio: isStdoutTakenOver() ? ["ignore", 2, 2] : "inherit",
2322
- shell: process.platform === "win32",
2323
- });
2324
- }
2325
-
2326
- private spawnCaptureCommand(
2327
- command: string,
2328
- args: string[],
2329
- options?: { cwd?: string; env?: Record<string, string> },
2330
- ): ChildProcessByStdio<null, Readable, Readable> {
2331
- return spawn(command, args, {
2332
- cwd: options?.cwd,
2333
- stdio: ["ignore", "pipe", "pipe"],
2334
- shell: process.platform === "win32",
2335
- env: options?.env ? { ...process.env, ...options.env } : process.env,
2336
- });
2337
- }
2338
-
2339
- private runCommandCapture(
2340
- command: string,
2341
- args: string[],
2342
- options?: { cwd?: string; timeoutMs?: number; env?: Record<string, string> },
2343
- ): Promise<string> {
2344
- return new Promise((resolvePromise, reject) => {
2345
- const child = this.spawnCaptureCommand(command, args, options);
2346
- let stdout = "";
2347
- let stderr = "";
2348
- let timedOut = false;
2349
- const timeout =
2350
- typeof options?.timeoutMs === "number"
2351
- ? setTimeout(() => {
2352
- timedOut = true;
2353
- child.kill();
2354
- }, options.timeoutMs)
2355
- : undefined;
2356
-
2357
- child.stdout?.on("data", (data) => {
2358
- stdout += data.toString();
2359
- });
2360
- child.stderr?.on("data", (data) => {
2361
- stderr += data.toString();
2362
- });
2363
- child.once("error", (error) => {
2364
- if (timeout) clearTimeout(timeout);
2365
- reject(error);
2366
- });
2367
- child.once("close", (code, signal) => {
2368
- if (timeout) clearTimeout(timeout);
2369
- if (timedOut) {
2370
- reject(new Error(`${command} ${args.join(" ")} timed out after ${options?.timeoutMs}ms`));
2371
- return;
2372
- }
2373
- if (code === 0) {
2374
- resolvePromise(stdout.trim());
2375
- return;
2376
- }
2377
- const exitStatus = code === null ? `signal ${signal ?? "unknown"}` : `code ${code}`;
2378
- reject(new Error(`${command} ${args.join(" ")} failed with ${exitStatus}: ${stderr || stdout}`));
2379
- });
2380
- });
2381
- }
2382
-
2383
- private runCommand(command: string, args: string[], options?: { cwd?: string }): Promise<void> {
2384
- return new Promise((resolvePromise, reject) => {
2385
- const child = this.spawnCommand(command, args, options);
2386
- child.on("error", reject);
2387
- child.on("exit", (code) => {
2388
- if (code === 0) {
2389
- resolvePromise();
2390
- } else {
2391
- reject(new Error(`${command} ${args.join(" ")} failed with code ${code}`));
2392
- }
2393
- });
2394
- });
2395
- }
2396
-
2397
- private runCommandSync(command: string, args: string[]): string {
2398
- const result = spawnSync(command, args, {
2399
- stdio: ["ignore", "pipe", "pipe"],
2400
- encoding: "utf-8",
2401
- shell: process.platform === "win32",
2402
- });
2403
- if (result.status !== 0) {
2404
- throw new Error(`Failed to run ${command} ${args.join(" ")}: ${result.stderr || result.stdout}`);
2405
- }
2406
- return (result.stdout || result.stderr || "").trim();
2407
- }
2408
- }