@ashx-j/lunr-dev 0.2.21-dev.12.1 → 0.2.25-dev.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (570) hide show
  1. package/CHANGELOG.md +25 -2
  2. package/dist/builtin-extensions/ashxj-tui.d.ts.map +1 -1
  3. package/dist/builtin-extensions/ashxj-tui.js +2 -2
  4. package/dist/builtin-extensions/ashxj-tui.js.map +1 -1
  5. package/dist/builtin-extensions/index.d.ts.map +1 -1
  6. package/dist/builtin-extensions/index.js +1 -0
  7. package/dist/builtin-extensions/index.js.map +1 -1
  8. package/dist/builtin-extensions/lunr-browser.d.ts +9 -0
  9. package/dist/builtin-extensions/lunr-browser.d.ts.map +1 -0
  10. package/dist/builtin-extensions/lunr-browser.js +169 -0
  11. package/dist/builtin-extensions/lunr-browser.js.map +1 -0
  12. package/dist/builtin-extensions/lunr-computer-use.d.ts.map +1 -1
  13. package/dist/builtin-extensions/lunr-computer-use.js +3 -3
  14. package/dist/builtin-extensions/lunr-computer-use.js.map +1 -1
  15. package/dist/builtin-extensions/lunr-plan-tools.d.ts +7 -7
  16. package/dist/builtin-extensions/lunr-plan-tools.d.ts.map +1 -1
  17. package/dist/builtin-extensions/lunr-plan-tools.js +12 -12
  18. package/dist/builtin-extensions/lunr-plan-tools.js.map +1 -1
  19. package/dist/builtin-extensions/lunr-todos.d.ts.map +1 -1
  20. package/dist/builtin-extensions/lunr-todos.js +15 -0
  21. package/dist/builtin-extensions/lunr-todos.js.map +1 -1
  22. package/dist/builtin-extensions/pi-intercom/index.d.ts.map +1 -1
  23. package/dist/builtin-extensions/pi-intercom/index.js +5 -0
  24. package/dist/builtin-extensions/pi-intercom/index.js.map +1 -1
  25. package/dist/builtin-extensions/pi-mcp-adapter/direct-tools.d.ts.map +1 -1
  26. package/dist/builtin-extensions/pi-mcp-adapter/direct-tools.js +1 -0
  27. package/dist/builtin-extensions/pi-mcp-adapter/direct-tools.js.map +1 -1
  28. package/dist/builtin-extensions/pi-mcp-adapter/index.d.ts.map +1 -1
  29. package/dist/builtin-extensions/pi-mcp-adapter/index.js +1 -1
  30. package/dist/builtin-extensions/pi-mcp-adapter/index.js.map +1 -1
  31. package/dist/builtin-extensions/pi-subagents/src/extension/control-notices.d.ts +1 -1
  32. package/dist/builtin-extensions/pi-subagents/src/extension/control-notices.d.ts.map +1 -1
  33. package/dist/builtin-extensions/pi-subagents/src/extension/control-notices.js +5 -1
  34. package/dist/builtin-extensions/pi-subagents/src/extension/control-notices.js.map +1 -1
  35. package/dist/builtin-extensions/pi-subagents/src/extension/index.d.ts +2 -2
  36. package/dist/builtin-extensions/pi-subagents/src/extension/index.d.ts.map +1 -1
  37. package/dist/builtin-extensions/pi-subagents/src/extension/index.js +18 -5
  38. package/dist/builtin-extensions/pi-subagents/src/extension/index.js.map +1 -1
  39. package/dist/builtin-extensions/pi-subagents/src/extension/schemas.d.ts.map +1 -1
  40. package/dist/builtin-extensions/pi-subagents/src/extension/schemas.js +1 -1
  41. package/dist/builtin-extensions/pi-subagents/src/extension/schemas.js.map +1 -1
  42. package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.d.ts +4 -3
  43. package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.d.ts.map +1 -1
  44. package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.js +8 -3
  45. package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.js.map +1 -1
  46. package/dist/builtin-extensions/pi-subagents/src/intercom/communication.d.ts +17 -0
  47. package/dist/builtin-extensions/pi-subagents/src/intercom/communication.d.ts.map +1 -0
  48. package/dist/builtin-extensions/pi-subagents/src/intercom/communication.js +45 -0
  49. package/dist/builtin-extensions/pi-subagents/src/intercom/communication.js.map +1 -0
  50. package/dist/builtin-extensions/pi-subagents/src/intercom/intercom-bridge.d.ts +2 -0
  51. package/dist/builtin-extensions/pi-subagents/src/intercom/intercom-bridge.d.ts.map +1 -1
  52. package/dist/builtin-extensions/pi-subagents/src/intercom/intercom-bridge.js +10 -14
  53. package/dist/builtin-extensions/pi-subagents/src/intercom/intercom-bridge.js.map +1 -1
  54. package/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.d.ts +4 -1
  55. package/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.d.ts.map +1 -1
  56. package/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.js +167 -53
  57. package/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.js.map +1 -1
  58. package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-ask.d.ts.map +1 -1
  59. package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-ask.js +5 -0
  60. package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-ask.js.map +1 -1
  61. package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-questions.d.ts +2 -0
  62. package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-questions.d.ts.map +1 -1
  63. package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-questions.js +3 -2
  64. package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-questions.js.map +1 -1
  65. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.d.ts +2 -0
  66. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.d.ts.map +1 -1
  67. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.js +4 -0
  68. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.js.map +1 -1
  69. package/dist/builtin-extensions/pi-subagents/src/runs/background/auto-drain.d.ts +1 -0
  70. package/dist/builtin-extensions/pi-subagents/src/runs/background/auto-drain.d.ts.map +1 -1
  71. package/dist/builtin-extensions/pi-subagents/src/runs/background/auto-drain.js +2 -1
  72. package/dist/builtin-extensions/pi-subagents/src/runs/background/auto-drain.js.map +1 -1
  73. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.d.ts.map +1 -1
  74. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.js +1 -1
  75. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.js.map +1 -1
  76. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.d.ts +3 -0
  77. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.d.ts.map +1 -1
  78. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.js +11 -0
  79. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.js.map +1 -1
  80. package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.d.ts.map +1 -1
  81. package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.js +41 -3
  82. package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.js.map +1 -1
  83. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.d.ts +1 -0
  84. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.d.ts.map +1 -1
  85. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.js +5 -1
  86. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.js.map +1 -1
  87. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.d.ts.map +1 -1
  88. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.js +3 -2
  89. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.js.map +1 -1
  90. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.d.ts.map +1 -1
  91. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js +23 -0
  92. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js.map +1 -1
  93. package/dist/builtin-extensions/pi-subagents/src/runs/shared/child-tools.d.ts +1 -1
  94. package/dist/builtin-extensions/pi-subagents/src/runs/shared/child-tools.d.ts.map +1 -1
  95. package/dist/builtin-extensions/pi-subagents/src/runs/shared/child-tools.js +1 -1
  96. package/dist/builtin-extensions/pi-subagents/src/runs/shared/child-tools.js.map +1 -1
  97. package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.d.ts +2 -0
  98. package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.d.ts.map +1 -1
  99. package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.js +20 -15
  100. package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.js.map +1 -1
  101. package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-control.d.ts +1 -0
  102. package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-control.d.ts.map +1 -1
  103. package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-control.js +3 -0
  104. package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-control.js.map +1 -1
  105. package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.d.ts.map +1 -1
  106. package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.js +4 -2
  107. package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.js.map +1 -1
  108. package/dist/builtin-extensions/pi-subagents/src/shared/child-spec.d.ts.map +1 -1
  109. package/dist/builtin-extensions/pi-subagents/src/shared/child-spec.js +2 -2
  110. package/dist/builtin-extensions/pi-subagents/src/shared/child-spec.js.map +1 -1
  111. package/dist/builtin-extensions/pi-subagents/src/shared/types.d.ts +2 -0
  112. package/dist/builtin-extensions/pi-subagents/src/shared/types.d.ts.map +1 -1
  113. package/dist/builtin-extensions/pi-subagents/src/shared/types.js.map +1 -1
  114. package/dist/builtin-extensions/pi-subagents/src/tui/communication.d.ts +18 -0
  115. package/dist/builtin-extensions/pi-subagents/src/tui/communication.d.ts.map +1 -0
  116. package/dist/builtin-extensions/pi-subagents/src/tui/communication.js +48 -0
  117. package/dist/builtin-extensions/pi-subagents/src/tui/communication.js.map +1 -0
  118. package/dist/builtin-extensions/pi-web-access/index.d.ts.map +1 -1
  119. package/dist/builtin-extensions/pi-web-access/index.js +11 -7
  120. package/dist/builtin-extensions/pi-web-access/index.js.map +1 -1
  121. package/dist/cli/args.d.ts.map +1 -1
  122. package/dist/cli/args.js +2 -1
  123. package/dist/cli/args.js.map +1 -1
  124. package/dist/cli/install-cli.d.ts.map +1 -1
  125. package/dist/cli/install-cli.js +15 -45
  126. package/dist/cli/install-cli.js.map +1 -1
  127. package/dist/core/agent-session-runtime.d.ts +9 -0
  128. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  129. package/dist/core/agent-session-runtime.js +126 -29
  130. package/dist/core/agent-session-runtime.js.map +1 -1
  131. package/dist/core/agent-session.d.ts +23 -1
  132. package/dist/core/agent-session.d.ts.map +1 -1
  133. package/dist/core/agent-session.js +255 -109
  134. package/dist/core/agent-session.js.map +1 -1
  135. package/dist/core/browser/network.d.ts +9 -0
  136. package/dist/core/browser/network.d.ts.map +1 -0
  137. package/dist/core/browser/network.js +146 -0
  138. package/dist/core/browser/network.js.map +1 -0
  139. package/dist/core/browser/runtime.d.ts +24 -0
  140. package/dist/core/browser/runtime.d.ts.map +1 -0
  141. package/dist/core/browser/runtime.js +289 -0
  142. package/dist/core/browser/runtime.js.map +1 -0
  143. package/dist/core/browser/schema.d.ts +16 -0
  144. package/dist/core/browser/schema.d.ts.map +1 -0
  145. package/dist/core/browser/schema.js +36 -0
  146. package/dist/core/browser/schema.js.map +1 -0
  147. package/dist/core/browser/settings.d.ts +8 -0
  148. package/dist/core/browser/settings.d.ts.map +1 -0
  149. package/dist/core/browser/settings.js +30 -0
  150. package/dist/core/browser/settings.js.map +1 -0
  151. package/dist/core/browser/setup.d.ts +2 -0
  152. package/dist/core/browser/setup.d.ts.map +1 -0
  153. package/dist/core/browser/setup.js +16 -0
  154. package/dist/core/browser/setup.js.map +1 -0
  155. package/dist/core/catalog-cache-scope.d.ts.map +1 -1
  156. package/dist/core/catalog-cache-scope.js +3 -1
  157. package/dist/core/catalog-cache-scope.js.map +1 -1
  158. package/dist/core/computer-use/image.d.ts +1 -0
  159. package/dist/core/computer-use/image.d.ts.map +1 -1
  160. package/dist/core/computer-use/image.js +8 -0
  161. package/dist/core/computer-use/image.js.map +1 -1
  162. package/dist/core/computer-use/schemas.d.ts +1 -0
  163. package/dist/core/computer-use/schemas.d.ts.map +1 -1
  164. package/dist/core/computer-use/schemas.js +2 -1
  165. package/dist/core/computer-use/schemas.js.map +1 -1
  166. package/dist/core/computer-use/workflow.d.ts.map +1 -1
  167. package/dist/core/computer-use/workflow.js +89 -23
  168. package/dist/core/computer-use/workflow.js.map +1 -1
  169. package/dist/core/customize.d.ts.map +1 -1
  170. package/dist/core/customize.js +15 -14
  171. package/dist/core/customize.js.map +1 -1
  172. package/dist/core/export-html/index.d.ts.map +1 -1
  173. package/dist/core/export-html/index.js +1 -1
  174. package/dist/core/export-html/index.js.map +1 -1
  175. package/dist/core/extensions/loader.d.ts.map +1 -1
  176. package/dist/core/extensions/loader.js +4 -0
  177. package/dist/core/extensions/loader.js.map +1 -1
  178. package/dist/core/extensions/runner.d.ts +1 -0
  179. package/dist/core/extensions/runner.d.ts.map +1 -1
  180. package/dist/core/extensions/runner.js +1 -1
  181. package/dist/core/extensions/runner.js.map +1 -1
  182. package/dist/core/extensions/types.d.ts +1 -1
  183. package/dist/core/extensions/types.d.ts.map +1 -1
  184. package/dist/core/extensions/types.js.map +1 -1
  185. package/dist/core/install-features.d.ts.map +1 -1
  186. package/dist/core/install-features.js +10 -8
  187. package/dist/core/install-features.js.map +1 -1
  188. package/dist/core/memory-cap.d.ts.map +1 -1
  189. package/dist/core/memory-cap.js +5 -3
  190. package/dist/core/memory-cap.js.map +1 -1
  191. package/dist/core/model-runtime.d.ts.map +1 -1
  192. package/dist/core/model-runtime.js +3 -2
  193. package/dist/core/model-runtime.js.map +1 -1
  194. package/dist/core/model-tiers.d.ts.map +1 -1
  195. package/dist/core/model-tiers.js +9 -6
  196. package/dist/core/model-tiers.js.map +1 -1
  197. package/dist/core/permissions.d.ts +16 -23
  198. package/dist/core/permissions.d.ts.map +1 -1
  199. package/dist/core/permissions.js +71 -142
  200. package/dist/core/permissions.js.map +1 -1
  201. package/dist/core/plan-mode.d.ts +10 -12
  202. package/dist/core/plan-mode.d.ts.map +1 -1
  203. package/dist/core/plan-mode.js +20 -19
  204. package/dist/core/plan-mode.js.map +1 -1
  205. package/dist/core/process-registry.d.ts.map +1 -1
  206. package/dist/core/process-registry.js +6 -4
  207. package/dist/core/process-registry.js.map +1 -1
  208. package/dist/core/runtime-bridges.d.ts.map +1 -1
  209. package/dist/core/runtime-bridges.js +2 -0
  210. package/dist/core/runtime-bridges.js.map +1 -1
  211. package/dist/core/runtime-scope.d.ts +11 -0
  212. package/dist/core/runtime-scope.d.ts.map +1 -0
  213. package/dist/core/runtime-scope.js +3 -0
  214. package/dist/core/runtime-scope.js.map +1 -0
  215. package/dist/core/sdk.d.ts.map +1 -1
  216. package/dist/core/sdk.js +26 -6
  217. package/dist/core/sdk.js.map +1 -1
  218. package/dist/core/session-handoff.d.ts +35 -0
  219. package/dist/core/session-handoff.d.ts.map +1 -0
  220. package/dist/core/session-handoff.js +214 -0
  221. package/dist/core/session-handoff.js.map +1 -0
  222. package/dist/core/session-manager.d.ts +20 -0
  223. package/dist/core/session-manager.d.ts.map +1 -1
  224. package/dist/core/session-manager.js +191 -22
  225. package/dist/core/session-manager.js.map +1 -1
  226. package/dist/core/session-ownership.d.ts +28 -0
  227. package/dist/core/session-ownership.d.ts.map +1 -0
  228. package/dist/core/session-ownership.js +138 -0
  229. package/dist/core/session-ownership.js.map +1 -0
  230. package/dist/core/session-retention.d.ts.map +1 -1
  231. package/dist/core/session-retention.js +11 -2
  232. package/dist/core/session-retention.js.map +1 -1
  233. package/dist/core/settings-manager.d.ts +20 -1
  234. package/dist/core/settings-manager.d.ts.map +1 -1
  235. package/dist/core/settings-manager.js +67 -1
  236. package/dist/core/settings-manager.js.map +1 -1
  237. package/dist/core/slash-commands.d.ts.map +1 -1
  238. package/dist/core/slash-commands.js +6 -4
  239. package/dist/core/slash-commands.js.map +1 -1
  240. package/dist/core/subagent-permission-inherit.d.ts +6 -10
  241. package/dist/core/subagent-permission-inherit.d.ts.map +1 -1
  242. package/dist/core/subagent-permission-inherit.js +14 -14
  243. package/dist/core/subagent-permission-inherit.js.map +1 -1
  244. package/dist/core/subagent-wait-interruption.d.ts +11 -0
  245. package/dist/core/subagent-wait-interruption.d.ts.map +1 -0
  246. package/dist/core/subagent-wait-interruption.js +19 -0
  247. package/dist/core/subagent-wait-interruption.js.map +1 -0
  248. package/dist/core/system-prompt.d.ts +2 -0
  249. package/dist/core/system-prompt.d.ts.map +1 -1
  250. package/dist/core/system-prompt.js +14 -4
  251. package/dist/core/system-prompt.js.map +1 -1
  252. package/dist/core/todo-settings.d.ts +5 -0
  253. package/dist/core/todo-settings.d.ts.map +1 -0
  254. package/dist/core/todo-settings.js +7 -0
  255. package/dist/core/todo-settings.js.map +1 -0
  256. package/dist/core/tools/bash.d.ts.map +1 -1
  257. package/dist/core/tools/bash.js +4 -4
  258. package/dist/core/tools/bash.js.map +1 -1
  259. package/dist/core/tools/edit.d.ts.map +1 -1
  260. package/dist/core/tools/edit.js +5 -3
  261. package/dist/core/tools/edit.js.map +1 -1
  262. package/dist/core/tools/find.d.ts.map +1 -1
  263. package/dist/core/tools/find.js +4 -4
  264. package/dist/core/tools/find.js.map +1 -1
  265. package/dist/core/tools/grep.d.ts.map +1 -1
  266. package/dist/core/tools/grep.js +4 -4
  267. package/dist/core/tools/grep.js.map +1 -1
  268. package/dist/core/tools/ls.d.ts.map +1 -1
  269. package/dist/core/tools/ls.js +4 -4
  270. package/dist/core/tools/ls.js.map +1 -1
  271. package/dist/core/tools/read.d.ts.map +1 -1
  272. package/dist/core/tools/read.js +4 -4
  273. package/dist/core/tools/read.js.map +1 -1
  274. package/dist/core/tools/render-utils.d.ts +14 -5
  275. package/dist/core/tools/render-utils.d.ts.map +1 -1
  276. package/dist/core/tools/render-utils.js +34 -7
  277. package/dist/core/tools/render-utils.js.map +1 -1
  278. package/dist/core/tools/write.d.ts.map +1 -1
  279. package/dist/core/tools/write.js +4 -4
  280. package/dist/core/tools/write.js.map +1 -1
  281. package/dist/core/usage-service.d.ts.map +1 -1
  282. package/dist/core/usage-service.js +5 -3
  283. package/dist/core/usage-service.js.map +1 -1
  284. package/dist/gateway/adapters/discord.d.ts +12 -1
  285. package/dist/gateway/adapters/discord.d.ts.map +1 -1
  286. package/dist/gateway/adapters/discord.js +114 -24
  287. package/dist/gateway/adapters/discord.js.map +1 -1
  288. package/dist/gateway/adapters/telegram.d.ts +4 -2
  289. package/dist/gateway/adapters/telegram.d.ts.map +1 -1
  290. package/dist/gateway/adapters/telegram.js +41 -11
  291. package/dist/gateway/adapters/telegram.js.map +1 -1
  292. package/dist/gateway/agent-bridge.d.ts +18 -4
  293. package/dist/gateway/agent-bridge.d.ts.map +1 -1
  294. package/dist/gateway/agent-bridge.js +305 -73
  295. package/dist/gateway/agent-bridge.js.map +1 -1
  296. package/dist/gateway/approval.d.ts +3 -6
  297. package/dist/gateway/approval.d.ts.map +1 -1
  298. package/dist/gateway/approval.js +62 -24
  299. package/dist/gateway/approval.js.map +1 -1
  300. package/dist/gateway/authz.d.ts +2 -0
  301. package/dist/gateway/authz.d.ts.map +1 -1
  302. package/dist/gateway/authz.js +13 -0
  303. package/dist/gateway/authz.js.map +1 -1
  304. package/dist/gateway/buttons.d.ts +3 -1
  305. package/dist/gateway/buttons.d.ts.map +1 -1
  306. package/dist/gateway/buttons.js +45 -20
  307. package/dist/gateway/buttons.js.map +1 -1
  308. package/dist/gateway/command.d.ts.map +1 -1
  309. package/dist/gateway/command.js +49 -4
  310. package/dist/gateway/command.js.map +1 -1
  311. package/dist/gateway/commands.d.ts +2 -0
  312. package/dist/gateway/commands.d.ts.map +1 -1
  313. package/dist/gateway/commands.js +52 -16
  314. package/dist/gateway/commands.js.map +1 -1
  315. package/dist/gateway/config.d.ts +6 -0
  316. package/dist/gateway/config.d.ts.map +1 -1
  317. package/dist/gateway/config.js +7 -0
  318. package/dist/gateway/config.js.map +1 -1
  319. package/dist/gateway/conversations.d.ts +14 -0
  320. package/dist/gateway/conversations.d.ts.map +1 -0
  321. package/dist/gateway/conversations.js +30 -0
  322. package/dist/gateway/conversations.js.map +1 -0
  323. package/dist/gateway/cron.d.ts +1 -1
  324. package/dist/gateway/cron.d.ts.map +1 -1
  325. package/dist/gateway/cron.js +2 -2
  326. package/dist/gateway/cron.js.map +1 -1
  327. package/dist/gateway/download.d.ts +2 -0
  328. package/dist/gateway/download.d.ts.map +1 -0
  329. package/dist/gateway/download.js +36 -0
  330. package/dist/gateway/download.js.map +1 -0
  331. package/dist/gateway/index.d.ts.map +1 -1
  332. package/dist/gateway/index.js +106 -47
  333. package/dist/gateway/index.js.map +1 -1
  334. package/dist/gateway/mobile-commands.d.ts +24 -0
  335. package/dist/gateway/mobile-commands.d.ts.map +1 -0
  336. package/dist/gateway/mobile-commands.js +423 -0
  337. package/dist/gateway/mobile-commands.js.map +1 -0
  338. package/dist/gateway/presenter.d.ts +27 -0
  339. package/dist/gateway/presenter.d.ts.map +1 -0
  340. package/dist/gateway/presenter.js +308 -0
  341. package/dist/gateway/presenter.js.map +1 -0
  342. package/dist/gateway/router.d.ts +6 -5
  343. package/dist/gateway/router.d.ts.map +1 -1
  344. package/dist/gateway/router.js +126 -43
  345. package/dist/gateway/router.js.map +1 -1
  346. package/dist/gateway/service.d.ts +46 -0
  347. package/dist/gateway/service.d.ts.map +1 -0
  348. package/dist/gateway/service.js +404 -0
  349. package/dist/gateway/service.js.map +1 -0
  350. package/dist/gateway/setup.d.ts +9 -0
  351. package/dist/gateway/setup.d.ts.map +1 -0
  352. package/dist/gateway/setup.js +202 -0
  353. package/dist/gateway/setup.js.map +1 -0
  354. package/dist/gateway/stream.d.ts +6 -5
  355. package/dist/gateway/stream.d.ts.map +1 -1
  356. package/dist/gateway/stream.js +24 -11
  357. package/dist/gateway/stream.js.map +1 -1
  358. package/dist/gateway/types.d.ts +4 -2
  359. package/dist/gateway/types.d.ts.map +1 -1
  360. package/dist/gateway/types.js.map +1 -1
  361. package/dist/index.d.ts +2 -0
  362. package/dist/index.d.ts.map +1 -1
  363. package/dist/index.js +2 -0
  364. package/dist/index.js.map +1 -1
  365. package/dist/main.d.ts.map +1 -1
  366. package/dist/main.js +3 -3
  367. package/dist/main.js.map +1 -1
  368. package/dist/modes/interactive/components/assistant-message.d.ts +19 -2
  369. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  370. package/dist/modes/interactive/components/assistant-message.js +78 -17
  371. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  372. package/dist/modes/interactive/components/copyable-text.d.ts +27 -0
  373. package/dist/modes/interactive/components/copyable-text.d.ts.map +1 -0
  374. package/dist/modes/interactive/components/copyable-text.js +156 -0
  375. package/dist/modes/interactive/components/copyable-text.js.map +1 -0
  376. package/dist/modes/interactive/components/custom-entry.d.ts +1 -0
  377. package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -1
  378. package/dist/modes/interactive/components/custom-entry.js +8 -0
  379. package/dist/modes/interactive/components/custom-entry.js.map +1 -1
  380. package/dist/modes/interactive/components/custom-message.d.ts +1 -0
  381. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  382. package/dist/modes/interactive/components/custom-message.js +8 -0
  383. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  384. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  385. package/dist/modes/interactive/components/session-selector.js +16 -0
  386. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  387. package/dist/modes/interactive/components/settings-selector.d.ts +12 -1
  388. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  389. package/dist/modes/interactive/components/settings-selector.js +74 -3
  390. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  391. package/dist/modes/interactive/components/thinking-tail.d.ts +9 -2
  392. package/dist/modes/interactive/components/thinking-tail.d.ts.map +1 -1
  393. package/dist/modes/interactive/components/thinking-tail.js +43 -1
  394. package/dist/modes/interactive/components/thinking-tail.js.map +1 -1
  395. package/dist/modes/interactive/components/tool-execution.d.ts +5 -3
  396. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  397. package/dist/modes/interactive/components/tool-execution.js +44 -45
  398. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  399. package/dist/modes/interactive/interactive-mode.d.ts +10 -2
  400. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  401. package/dist/modes/interactive/interactive-mode.js +342 -133
  402. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  403. package/dist/modes/interactive/theme/theme.d.ts +1 -0
  404. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  405. package/dist/modes/interactive/theme/theme.js +23 -0
  406. package/dist/modes/interactive/theme/theme.js.map +1 -1
  407. package/dist/node-runtime/agent-session-services-MQUPZSIN.js +51 -0
  408. package/dist/node-runtime/{builtin-extensions-SRCYQPZ6.js → builtin-extensions-4GNDR6U3.js} +7 -6
  409. package/dist/node-runtime/{chunk-LTXUQJI4.js → chunk-24C5IAJ4.js} +1 -6
  410. package/dist/node-runtime/chunk-2BLXLDJR.js +144 -0
  411. package/dist/node-runtime/{chunk-RQ5DNUNG.js → chunk-2CMV4L24.js} +21 -124
  412. package/dist/node-runtime/{chunk-LTYWTR3V.js → chunk-2MI5OPMN.js} +17 -2
  413. package/dist/node-runtime/{chunk-W3CVH5RX.js → chunk-2TKODGBZ.js} +11 -6
  414. package/dist/node-runtime/{chunk-GT5F3OKM.js → chunk-33SIKK3Y.js} +38 -164
  415. package/dist/node-runtime/{chunk-GZQHMEWL.js → chunk-3DKIWPKN.js} +19 -4
  416. package/dist/node-runtime/{chunk-3GHXVUAK.js → chunk-3VEY2IYY.js} +1 -1
  417. package/dist/node-runtime/chunk-4ER2ZV4Z.js +537 -0
  418. package/dist/node-runtime/chunk-4EULYYR4.js +62 -0
  419. package/dist/node-runtime/{chunk-LOYUC2ID.js → chunk-4SBQAI4T.js} +27 -27
  420. package/dist/node-runtime/{chunk-CZUBYPFP.js → chunk-53ARRUHA.js} +674 -257
  421. package/dist/node-runtime/{chunk-VTPM5V35.js → chunk-5Q4A37RB.js} +10 -4
  422. package/dist/node-runtime/{chunk-SWSN6HAB.js → chunk-5UZOPGE3.js} +1 -1
  423. package/dist/node-runtime/{chunk-XSRCAQK2.js → chunk-5Z5PCXGY.js} +263 -222
  424. package/dist/node-runtime/chunk-7JIYPIQU.js +356 -0
  425. package/dist/node-runtime/{chunk-D466UAID.js → chunk-AJ6R5VTV.js} +60 -88
  426. package/dist/node-runtime/chunk-ATIF3RX5.js +352 -0
  427. package/dist/node-runtime/{chunk-A3KMVBZV.js → chunk-BBUVIEZB.js} +1 -10
  428. package/dist/node-runtime/chunk-CCCN2UCX.js +14 -0
  429. package/dist/node-runtime/chunk-CJS4KQFI.js +3412 -0
  430. package/dist/node-runtime/chunk-DO6PALE2.js +205 -0
  431. package/dist/node-runtime/{chunk-N3PNL74S.js → chunk-DRJI7ZSC.js} +63 -163
  432. package/dist/node-runtime/{chunk-VTGEKB7R.js → chunk-E75WFZ33.js} +1 -1
  433. package/dist/node-runtime/{chunk-MJQDX3BA.js → chunk-EBB4BJW4.js} +3 -3
  434. package/dist/node-runtime/{chunk-VQ4UBWSA.js → chunk-EOEAQIJV.js} +63 -6
  435. package/dist/node-runtime/chunk-EOPL2HMM.js +117 -0
  436. package/dist/node-runtime/chunk-H4K3JDRB.js +47 -0
  437. package/dist/node-runtime/{chunk-HRS4HMDX.js → chunk-HT2XEJNP.js} +19 -3
  438. package/dist/node-runtime/chunk-IMLCWLPI.js +9 -0
  439. package/dist/node-runtime/{chunk-BJ6H7DPI.js → chunk-JJWZB7S3.js} +62 -50
  440. package/dist/node-runtime/chunk-KFFOQR4G.js +672 -0
  441. package/dist/node-runtime/chunk-L5LZUGT7.js +40 -0
  442. package/dist/node-runtime/chunk-LV6CEFW2.js +97 -0
  443. package/dist/node-runtime/{chunk-VSELYKWU.js → chunk-LWYIVUGV.js} +2 -1
  444. package/dist/node-runtime/{chunk-BYQ2MOFI.js → chunk-MFV2LOOX.js} +184 -2192
  445. package/dist/node-runtime/{chunk-5SQDLSZJ.js → chunk-MNRO3UCV.js} +2 -2
  446. package/dist/node-runtime/{chunk-JHYKXIMM.js → chunk-MPKSOJBT.js} +1 -1
  447. package/dist/node-runtime/{chunk-C4O2RSQQ.js → chunk-N4TUWAGA.js} +1 -1
  448. package/dist/node-runtime/{chunk-7NBZ5P7I.js → chunk-NAY6UUQZ.js} +1 -1
  449. package/dist/node-runtime/chunk-NKH2QBKF.js +773 -0
  450. package/dist/node-runtime/chunk-O2AT4MEU.js +124 -0
  451. package/dist/node-runtime/chunk-OAR4TYZE.js +146 -0
  452. package/dist/node-runtime/{chunk-DDGMHUOW.js → chunk-OGJN3OZV.js} +2 -1
  453. package/dist/node-runtime/{chunk-MX3GJNXJ.js → chunk-PLGA743X.js} +23 -0
  454. package/dist/node-runtime/chunk-Q3FEOEDA.js +1364 -0
  455. package/dist/node-runtime/{chunk-H2BI7G7T.js → chunk-QFADHUQV.js} +2 -1
  456. package/dist/node-runtime/{chunk-W3SILANP.js → chunk-RBZQU6TJ.js} +12 -9
  457. package/dist/node-runtime/{chunk-ZVSORYRM.js → chunk-RVOQBXTA.js} +10 -6
  458. package/dist/node-runtime/{chunk-HXJS2PJM.js → chunk-RW4PYFNE.js} +14 -94
  459. package/dist/node-runtime/chunk-TP7K7YWS.js +2830 -0
  460. package/dist/node-runtime/{chunk-ZOIIMEN6.js → chunk-TVLBDVTR.js} +32 -21
  461. package/dist/node-runtime/chunk-UAEOTO52.js +119 -0
  462. package/dist/node-runtime/{chunk-MGWCVY6Y.js → chunk-UDKX3PFN.js} +3 -3
  463. package/dist/node-runtime/{chunk-AY6CAJSL.js → chunk-UJOCPOMX.js} +6 -3
  464. package/dist/node-runtime/{chunk-WJVFOIB5.js → chunk-UQUCFAJ3.js} +1 -1
  465. package/dist/node-runtime/chunk-US544NN6.js +13 -0
  466. package/dist/node-runtime/{chunk-7AFOFSDY.js → chunk-V3HK3FE7.js} +1 -1
  467. package/dist/node-runtime/{chunk-6UB6NKA3.js → chunk-VIVYOI7C.js} +130 -27
  468. package/dist/node-runtime/{chunk-MW2XJZIK.js → chunk-XHIRAZ26.js} +1 -1
  469. package/dist/node-runtime/chunk-YPHAIRZT.js +10 -0
  470. package/dist/node-runtime/{chunk-3RCWXWAY.js → chunk-YRUY57IN.js} +1 -1
  471. package/dist/node-runtime/cli-runtime.js +2 -2
  472. package/dist/node-runtime/command-PYBNGLPP.js +45 -0
  473. package/dist/node-runtime/{commands-BZGSLIP7.js → commands-EMBQQVVT.js} +13 -13
  474. package/dist/node-runtime/commands-Y2OUC2T7.js +37 -0
  475. package/dist/node-runtime/config-7DYMNJUO.js +20 -0
  476. package/dist/node-runtime/{customize-LF5VST47.js → customize-VFJV3U6A.js} +2 -1
  477. package/dist/node-runtime/{direct-tool-executor-BSZDHIYR.js → direct-tool-executor-4D7UXYU4.js} +10 -10
  478. package/dist/node-runtime/{export-html-E4DT6ZJQ.js → export-html-ETFOKW3M.js} +4 -3
  479. package/dist/node-runtime/{extension-input-RV5N6APL.js → extension-input-7QODTFAS.js} +4 -4
  480. package/dist/node-runtime/{extension-selector-CPD5LWDD.js → extension-selector-T65JEDJ5.js} +4 -4
  481. package/dist/node-runtime/{extract-XLQSJN4V.js → extract-EQJE7FZZ.js} +2 -2
  482. package/dist/node-runtime/gateway-QENRQA5X.js +1476 -0
  483. package/dist/node-runtime/{gemini-search-U7SUMPQA.js → gemini-search-35OCRFLN.js} +1 -1
  484. package/dist/node-runtime/{gemini-url-context-PXWCBQHK.js → gemini-url-context-UQY3PHHW.js} +2 -2
  485. package/dist/node-runtime/index.js +113 -73
  486. package/dist/node-runtime/{init-DVJUAOUO.js → init-P5AUV77I.js} +5 -5
  487. package/dist/node-runtime/{install-cli-TH7IJJQQ.js → install-cli-KHAXYBOO.js} +21 -82
  488. package/dist/node-runtime/interactive-mode-IN77GQGX.js +74 -0
  489. package/dist/node-runtime/{interactive-view-N6F4KUIT.js → interactive-view-OMWDFGUQ.js} +10 -10
  490. package/dist/node-runtime/lunr-browser-VVPRWC3F.js +174 -0
  491. package/dist/node-runtime/{lunr-computer-use-TJNDAMWM.js → lunr-computer-use-IAUNXSXH.js} +11 -8
  492. package/dist/node-runtime/{lunr-cron-J64I72C6.js → lunr-cron-P6ZJGVEF.js} +21 -7
  493. package/dist/node-runtime/main.js +47 -34
  494. package/dist/node-runtime/{mcp-auth-flow-YL6RWPYG.js → mcp-auth-flow-QVLFVLEO.js} +2 -2
  495. package/dist/node-runtime/{memory-cap-3S4XRLNP.js → memory-cap-EL3KL4JJ.js} +2 -1
  496. package/dist/node-runtime/mobile-commands-WKFSFACZ.js +33 -0
  497. package/dist/node-runtime/model-runtime-YXGJS5OJ.js +16 -0
  498. package/dist/node-runtime/{model-tiers-NJLHUEGK.js → model-tiers-OU3U5CZG.js} +2 -1
  499. package/dist/node-runtime/{package-manager-cli-VMYX4Y2S.js → package-manager-cli-J337RKTI.js} +25 -17
  500. package/dist/node-runtime/{pi-intercom-NV2LW6X7.js → pi-intercom-QM53RLTS.js} +6 -1
  501. package/dist/node-runtime/{pi-mcp-adapter-JLB5YL2F.js → pi-mcp-adapter-3PHF4KZ4.js} +8 -7
  502. package/dist/node-runtime/{pi-subagents-WEHV3W7H.js → pi-subagents-RCHPB6UK.js} +255 -88
  503. package/dist/node-runtime/{pi-web-access-FN5YC5T6.js → pi-web-access-PNG35XW7.js} +15 -15
  504. package/dist/node-runtime/process-registry-PVJ44F7H.js +31 -0
  505. package/dist/node-runtime/{proxy-modes-OR7ISBXK.js → proxy-modes-5FAPSZEZ.js} +11 -11
  506. package/dist/node-runtime/rpc-entry.js +47 -34
  507. package/dist/node-runtime/{rpc-mode-SJNSOA4G.js → rpc-mode-SH7VB4RH.js} +2 -2
  508. package/dist/node-runtime/runtime-4VA6JKNF.js +373 -0
  509. package/dist/node-runtime/runtime-bridges-3CQHWVVY.js +21 -0
  510. package/dist/node-runtime/service-HGGU3STY.js +36 -0
  511. package/dist/node-runtime/session-handoff-IAFIK7QP.js +33 -0
  512. package/dist/node-runtime/{session-manager-QEMZBMTM.js → session-manager-TCEFDKBL.js} +2 -1
  513. package/dist/node-runtime/{session-selector-URVJLOTK.js → session-selector-HG5J4BDZ.js} +5 -4
  514. package/dist/node-runtime/{settings-manager-3CCU326G.js → settings-manager-HIBIUNBK.js} +12 -5
  515. package/dist/node-runtime/setup-JBKOLJ6F.js +18 -0
  516. package/dist/node-runtime/setup-YU5LKRL3.js +215 -0
  517. package/dist/node-runtime/{subagent-executor-CXKXQDHH.js → subagent-executor-2BH76MMS.js} +64 -23
  518. package/dist/node-runtime/theme-WTJWZSGD.js +68 -0
  519. package/dist/node-runtime/trust-manager-6ZQANSBX.js +17 -0
  520. package/dist/node-runtime/{update-cli-NM7B4CKL.js → update-cli-TVTPVUNM.js} +6 -3
  521. package/dist/node-runtime/usage-service-LFB2SWYV.js +37 -0
  522. package/dist/node-runtime/{video-extract-OYT5WKS5.js → video-extract-OOZHR7SU.js} +2 -2
  523. package/dist/node-runtime/{workflow-C26QCUTW.js → workflow-TVJNKKQP.js} +80 -39
  524. package/dist/node-runtime/{youtube-extract-TQYKGFGS.js → youtube-extract-FNPAUNHU.js} +6 -6
  525. package/dist/startup/interactive-view.d.ts.map +1 -1
  526. package/dist/startup/interactive-view.js +5 -1
  527. package/dist/startup/interactive-view.js.map +1 -1
  528. package/dist/utils/image-resize-core.d.ts +2 -0
  529. package/dist/utils/image-resize-core.d.ts.map +1 -1
  530. package/dist/utils/image-resize-core.js +10 -0
  531. package/dist/utils/image-resize-core.js.map +1 -1
  532. package/docs/browser.md +86 -0
  533. package/docs/computer-use.md +134 -48
  534. package/docs/extensions.md +2 -0
  535. package/docs/features.md +108 -27
  536. package/docs/index.md +1 -1
  537. package/docs/interactive-startup.md +2 -1
  538. package/docs/keybindings.md +1 -1
  539. package/docs/providers.md +6 -2
  540. package/docs/quickstart.md +2 -2
  541. package/docs/sessions.md +10 -0
  542. package/docs/settings.md +3 -1
  543. package/docs/tui.md +2 -0
  544. package/docs/usage.md +20 -4
  545. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  546. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  547. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  548. package/examples/extensions/gondolin/package-lock.json +2 -2
  549. package/examples/extensions/gondolin/package.json +1 -1
  550. package/examples/extensions/plan-mode/README.md +1 -1
  551. package/examples/extensions/sandbox/package-lock.json +2 -2
  552. package/examples/extensions/sandbox/package.json +1 -1
  553. package/examples/extensions/with-deps/package-lock.json +2 -2
  554. package/examples/extensions/with-deps/package.json +1 -1
  555. package/install-lock/package-lock.json +39 -25
  556. package/install-lock/package.json +2 -2
  557. package/npm-shrinkwrap.json +36 -22
  558. package/package.json +10 -7
  559. package/scripts/install-browser.mjs +20 -0
  560. package/dist/node-runtime/agent-session-services-QANFGM2V.js +0 -40
  561. package/dist/node-runtime/chunk-LISUTZS3.js +0 -19
  562. package/dist/node-runtime/chunk-VGYZ3APQ.js +0 -59
  563. package/dist/node-runtime/chunk-XAUQOKYK.js +0 -6011
  564. package/dist/node-runtime/command-ZURZJDXF.js +0 -13
  565. package/dist/node-runtime/gateway-FWHRIBK5.js +0 -2139
  566. package/dist/node-runtime/interactive-mode-BBASNWHN.js +0 -62
  567. package/dist/node-runtime/runtime-bridges-2VQTLPOZ.js +0 -12
  568. package/dist/node-runtime/{chunk-U6C7VTR5.js → chunk-7IQGBKBJ.js} +3 -3
  569. package/dist/node-runtime/{mcp-panel-IIGMXQGP.js → mcp-panel-KTTFXJZ4.js} +3 -3
  570. package/dist/node-runtime/{src-BPQFJR76.js → src-IVPNZ2BX.js} +9 -9
@@ -5,39 +5,17 @@ import {
5
5
  import {
6
6
  isStdoutTakenOver
7
7
  } from "./chunk-OBMWP3I5.js";
8
- import {
9
- parseFrontmatter
10
- } from "./chunk-QFWG2RVL.js";
11
8
  import {
12
9
  minimatch
13
10
  } from "./chunk-CGBXPL3E.js";
14
- import {
15
- SettingsManager
16
- } from "./chunk-VQ4UBWSA.js";
17
- import {
18
- getGlobalInstructionsPath,
19
- loadSelectedUserInstructions
20
- } from "./chunk-M3LZLQW2.js";
21
- import {
22
- measureStartup,
23
- resetTimings
24
- } from "./chunk-PVCDKGR6.js";
25
- import {
26
- loadThemeFromPath,
27
- theme
28
- } from "./chunk-MX3GJNXJ.js";
29
11
  import {
30
12
  CONFIG_DIR_NAME,
31
13
  canonicalizePath,
32
- getAgentDir,
33
- isBunBinary,
34
14
  isLocalPath,
35
- isNodeBundle,
36
15
  markPathIgnoredByCloudSync,
37
16
  resolvePath,
38
17
  spawnProcess,
39
- spawnProcessSync,
40
- waitForChildProcess
18
+ spawnProcessSync
41
19
  } from "./chunk-PCIGF2XK.js";
42
20
  import {
43
21
  __commonJS,
@@ -635,13 +613,13 @@ var require_hosts = __commonJS({
635
613
  var maybeJoin = (...args) => args.every((arg) => arg) ? args.join("") : "", maybeEncode = (arg) => arg ? encodeURIComponent(arg) : "", formatHashFragment = (f) => f.toLowerCase().replace(/^\W+/g, "").replace(/(?<!\W)\W+$/, "").replace(/\//g, "").replace(/\W+/g, "-"), defaults = {
636
614
  sshtemplate: ({ domain, user, project, committish }) => `git@${domain}:${user}/${project}.git${maybeJoin("#", committish)}`,
637
615
  sshurltemplate: ({ domain, user, project, committish }) => `git+ssh://git@${domain}/${user}/${project}.git${maybeJoin("#", committish)}`,
638
- edittemplate: ({ domain, user, project, committish, editpath, path: path2 }) => `https://${domain}/${user}/${project}${maybeJoin("/", editpath, "/", maybeEncode(committish || "HEAD"), "/", path2)}`,
616
+ edittemplate: ({ domain, user, project, committish, editpath, path }) => `https://${domain}/${user}/${project}${maybeJoin("/", editpath, "/", maybeEncode(committish || "HEAD"), "/", path)}`,
639
617
  browsetemplate: ({ domain, user, project, committish, treepath }) => `https://${domain}/${user}/${project}${maybeJoin("/", treepath, "/", maybeEncode(committish))}`,
640
- browsetreetemplate: ({ domain, user, project, committish, treepath, path: path2, fragment, hashformat }) => `https://${domain}/${user}/${project}/${treepath}/${maybeEncode(committish || "HEAD")}/${path2}${maybeJoin("#", hashformat(fragment || ""))}`,
641
- browseblobtemplate: ({ domain, user, project, committish, blobpath, path: path2, fragment, hashformat }) => `https://${domain}/${user}/${project}/${blobpath}/${maybeEncode(committish || "HEAD")}/${path2}${maybeJoin("#", hashformat(fragment || ""))}`,
618
+ browsetreetemplate: ({ domain, user, project, committish, treepath, path, fragment, hashformat }) => `https://${domain}/${user}/${project}/${treepath}/${maybeEncode(committish || "HEAD")}/${path}${maybeJoin("#", hashformat(fragment || ""))}`,
619
+ browseblobtemplate: ({ domain, user, project, committish, blobpath, path, fragment, hashformat }) => `https://${domain}/${user}/${project}/${blobpath}/${maybeEncode(committish || "HEAD")}/${path}${maybeJoin("#", hashformat(fragment || ""))}`,
642
620
  docstemplate: ({ domain, user, project, treepath, committish }) => `https://${domain}/${user}/${project}${maybeJoin("/", treepath, "/", maybeEncode(committish))}#readme`,
643
621
  httpstemplate: ({ auth, domain, user, project, committish }) => `git+https://${maybeJoin(auth, "@")}${domain}/${user}/${project}.git${maybeJoin("#", committish)}`,
644
- filetemplate: ({ domain, user, project, committish, path: path2 }) => `https://${domain}/${user}/${project}/raw/${maybeEncode(committish || "HEAD")}/${path2}`,
622
+ filetemplate: ({ domain, user, project, committish, path }) => `https://${domain}/${user}/${project}/raw/${maybeEncode(committish || "HEAD")}/${path}`,
645
623
  shortcuttemplate: ({ type, user, project, committish }) => `${type}:${user}/${project}${maybeJoin("#", committish)}`,
646
624
  pathtemplate: ({ user, project, committish }) => `${user}/${project}${maybeJoin("#", committish)}`,
647
625
  bugstemplate: ({ domain, user, project }) => `https://${domain}/${user}/${project}/issues`,
@@ -655,7 +633,7 @@ var require_hosts = __commonJS({
655
633
  treepath: "tree",
656
634
  blobpath: "blob",
657
635
  editpath: "edit",
658
- filetemplate: ({ auth, user, project, committish, path: path2 }) => `https://${maybeJoin(auth, "@")}raw.githubusercontent.com/${user}/${project}/${maybeEncode(committish || "HEAD")}/${path2}`,
636
+ filetemplate: ({ auth, user, project, committish, path }) => `https://${maybeJoin(auth, "@")}raw.githubusercontent.com/${user}/${project}/${maybeEncode(committish || "HEAD")}/${path}`,
659
637
  gittemplate: ({ auth, domain, user, project, committish }) => `git://${maybeJoin(auth, "@")}${domain}/${user}/${project}.git${maybeJoin("#", committish)}`,
660
638
  tarballtemplate: ({ domain, user, project, committish }) => `https://codeload.${domain}/${user}/${project}/tar.gz/${maybeEncode(committish || "HEAD")}`,
661
639
  extract: (url) => {
@@ -670,7 +648,7 @@ var require_hosts = __commonJS({
670
648
  treepath: "src",
671
649
  blobpath: "src",
672
650
  editpath: "?mode=edit",
673
- edittemplate: ({ domain, user, project, committish, treepath, path: path2, editpath }) => `https://${domain}/${user}/${project}${maybeJoin("/", treepath, "/", maybeEncode(committish || "HEAD"), "/", path2, editpath)}`,
651
+ edittemplate: ({ domain, user, project, committish, treepath, path, editpath }) => `https://${domain}/${user}/${project}${maybeJoin("/", treepath, "/", maybeEncode(committish || "HEAD"), "/", path, editpath)}`,
674
652
  tarballtemplate: ({ domain, user, project, committish }) => `https://${domain}/${user}/${project}/get/${maybeEncode(committish || "HEAD")}.tar.gz`,
675
653
  extract: (url) => {
676
654
  let [, user, project, aux] = url.pathname.split("/", 4);
@@ -686,10 +664,10 @@ var require_hosts = __commonJS({
686
664
  editpath: "-/edit",
687
665
  tarballtemplate: ({ domain, user, project, committish }) => `https://${domain}/api/v4/projects/${maybeEncode(user + "/" + project)}/repository/archive.tar.gz?sha=${maybeEncode(committish || "HEAD")}`,
688
666
  extract: (url) => {
689
- let path2 = url.pathname.slice(1);
690
- if (path2.includes("/-/") || path2.includes("/archive.tar.gz"))
667
+ let path = url.pathname.slice(1);
668
+ if (path.includes("/-/") || path.includes("/archive.tar.gz"))
691
669
  return;
692
- let segments = path2.split("/"), project = segments.pop();
670
+ let segments = path.split("/"), project = segments.pop();
693
671
  project.endsWith(".git") && (project = project.slice(0, -4));
694
672
  let user = segments.join("/");
695
673
  if (!(!user || !project))
@@ -704,11 +682,11 @@ var require_hosts = __commonJS({
704
682
  sshurltemplate: ({ domain, project, committish }) => `git+ssh://git@${domain}/${project}.git${maybeJoin("#", committish)}`,
705
683
  edittemplate: ({ domain, user, project, committish, editpath }) => `https://${domain}/${user}/${project}${maybeJoin("/", maybeEncode(committish))}/${editpath}`,
706
684
  browsetemplate: ({ domain, project, committish }) => `https://${domain}/${project}${maybeJoin("/", maybeEncode(committish))}`,
707
- browsetreetemplate: ({ domain, project, committish, path: path2, hashformat }) => `https://${domain}/${project}${maybeJoin("/", maybeEncode(committish))}${maybeJoin("#", hashformat(path2))}`,
708
- browseblobtemplate: ({ domain, project, committish, path: path2, hashformat }) => `https://${domain}/${project}${maybeJoin("/", maybeEncode(committish))}${maybeJoin("#", hashformat(path2))}`,
685
+ browsetreetemplate: ({ domain, project, committish, path, hashformat }) => `https://${domain}/${project}${maybeJoin("/", maybeEncode(committish))}${maybeJoin("#", hashformat(path))}`,
686
+ browseblobtemplate: ({ domain, project, committish, path, hashformat }) => `https://${domain}/${project}${maybeJoin("/", maybeEncode(committish))}${maybeJoin("#", hashformat(path))}`,
709
687
  docstemplate: ({ domain, project, committish }) => `https://${domain}/${project}${maybeJoin("/", maybeEncode(committish))}`,
710
688
  httpstemplate: ({ domain, project, committish }) => `git+https://${domain}/${project}.git${maybeJoin("#", committish)}`,
711
- filetemplate: ({ user, project, committish, path: path2 }) => `https://gist.githubusercontent.com/${user}/${project}/raw${maybeJoin("/", maybeEncode(committish))}/${path2}`,
689
+ filetemplate: ({ user, project, committish, path }) => `https://gist.githubusercontent.com/${user}/${project}/raw${maybeJoin("/", maybeEncode(committish))}/${path}`,
712
690
  shortcuttemplate: ({ type, project, committish }) => `${type}:${project}${maybeJoin("#", committish)}`,
713
691
  pathtemplate: ({ project, committish }) => `${project}${maybeJoin("#", committish)}`,
714
692
  bugstemplate: ({ domain, project }) => `https://${domain}/${project}`,
@@ -734,7 +712,7 @@ var require_hosts = __commonJS({
734
712
  domain: "git.sr.ht",
735
713
  treepath: "tree",
736
714
  blobpath: "tree",
737
- filetemplate: ({ domain, user, project, committish, path: path2 }) => `https://${domain}/${user}/${project}/blob/${maybeEncode(committish) || "HEAD"}/${path2}`,
715
+ filetemplate: ({ domain, user, project, committish, path }) => `https://${domain}/${user}/${project}/blob/${maybeEncode(committish) || "HEAD"}/${path}`,
738
716
  httpstemplate: ({ domain, user, project, committish }) => `https://${domain}/${user}/${project}${maybeJoin("#", committish)}`,
739
717
  tarballtemplate: ({ domain, user, project, committish }) => `https://${domain}/${user}/${project}/archive/${maybeEncode(committish) || "HEAD"}.tar.gz`,
740
718
  bugstemplate: () => null,
@@ -836,8 +814,8 @@ var require_lib = __commonJS({
836
814
  } = new URL(url);
837
815
  if (!hostname)
838
816
  return null;
839
- let proto = /(?:git\+)http:$/.test(protocol) ? "http:" : "https:", path2 = pathname.replace(/\.git$/, "");
840
- return `${proto}//${hostname}${path2}`;
817
+ let proto = /(?:git\+)http:$/.test(protocol) ? "http:" : "https:", path = pathname.replace(/\.git$/, "");
818
+ return `${proto}//${hostname}${path}`;
841
819
  } catch {
842
820
  return null;
843
821
  }
@@ -912,16 +890,16 @@ var require_lib = __commonJS({
912
890
  sshurl(opts) {
913
891
  return this.#fill(this.sshurltemplate, opts);
914
892
  }
915
- browse(path2, ...args) {
916
- return typeof path2 != "string" ? this.#fill(this.browsetemplate, path2) : typeof args[0] != "string" ? this.#fill(this.browsetreetemplate, { ...args[0], path: path2 }) : this.#fill(this.browsetreetemplate, { ...args[1], fragment: args[0], path: path2 });
893
+ browse(path, ...args) {
894
+ return typeof path != "string" ? this.#fill(this.browsetemplate, path) : typeof args[0] != "string" ? this.#fill(this.browsetreetemplate, { ...args[0], path }) : this.#fill(this.browsetreetemplate, { ...args[1], fragment: args[0], path });
917
895
  }
918
896
  // If the path is known to be a file, then browseFile should be used. For some hosts
919
897
  // the url is the same as browse, but for others like GitHub a file can use both `/tree/`
920
898
  // and `/blob/` in the path. When using a default committish of `HEAD` then the `/tree/`
921
899
  // path will redirect to a specific commit. Using the `/blob/` path avoids this and
922
900
  // does not redirect to a different commit.
923
- browseFile(path2, ...args) {
924
- return typeof args[0] != "string" ? this.#fill(this.browseblobtemplate, { ...args[0], path: path2 }) : this.#fill(this.browseblobtemplate, { ...args[1], fragment: args[0], path: path2 });
901
+ browseFile(path, ...args) {
902
+ return typeof args[0] != "string" ? this.#fill(this.browseblobtemplate, { ...args[0], path }) : this.#fill(this.browseblobtemplate, { ...args[1], fragment: args[0], path });
925
903
  }
926
904
  docs(opts) {
927
905
  return this.#fill(this.docstemplate, opts);
@@ -944,11 +922,11 @@ var require_lib = __commonJS({
944
922
  tarball(opts) {
945
923
  return this.#fill(this.tarballtemplate, { ...opts, noCommittish: !1 });
946
924
  }
947
- file(path2, opts) {
948
- return this.#fill(this.filetemplate, { ...opts, path: path2 });
925
+ file(path, opts) {
926
+ return this.#fill(this.filetemplate, { ...opts, path });
949
927
  }
950
- edit(path2, opts) {
951
- return this.#fill(this.edittemplate, { ...opts, path: path2 });
928
+ edit(path, opts) {
929
+ return this.#fill(this.edittemplate, { ...opts, path });
952
930
  }
953
931
  getDefaultRepresentation() {
954
932
  return this.default;
@@ -1198,11 +1176,11 @@ var require_ignore = __commonJS({
1198
1176
  // path matching.
1199
1177
  // - check `string` either `MODE_IGNORE` or `MODE_CHECK_IGNORE`
1200
1178
  // @returns {TestResult} true if a file is ignored
1201
- test(path2, checkUnignored, mode) {
1179
+ test(path, checkUnignored, mode) {
1202
1180
  let ignored = !1, unignored = !1, matchedRule;
1203
1181
  this._rules.forEach((rule) => {
1204
1182
  let { negative } = rule;
1205
- unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored || !rule[mode].test(path2) || (ignored = !negative, unignored = negative, matchedRule = negative ? UNDEFINED : rule);
1183
+ unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored || !rule[mode].test(path) || (ignored = !negative, unignored = negative, matchedRule = negative ? UNDEFINED : rule);
1206
1184
  });
1207
1185
  let ret = {
1208
1186
  ignored,
@@ -1212,13 +1190,13 @@ var require_ignore = __commonJS({
1212
1190
  }
1213
1191
  }, throwError = (message, Ctor) => {
1214
1192
  throw new Ctor(message);
1215
- }, checkPath = (path2, originalPath, doThrow) => isString(path2) ? path2 ? checkPath.isNotRelative(path2) ? doThrow(
1193
+ }, checkPath = (path, originalPath, doThrow) => isString(path) ? path ? checkPath.isNotRelative(path) ? doThrow(
1216
1194
  `path should be a \`path.relative()\`d string, but got "${originalPath}"`,
1217
1195
  RangeError
1218
1196
  ) : !0 : doThrow("path must not be empty", TypeError) : doThrow(
1219
1197
  `path must be a string, but got \`${originalPath}\``,
1220
1198
  TypeError
1221
- ), isNotRelative = (path2) => REGEX_TEST_INVALID_PATH.test(path2);
1199
+ ), isNotRelative = (path) => REGEX_TEST_INVALID_PATH.test(path);
1222
1200
  checkPath.isNotRelative = isNotRelative;
1223
1201
  checkPath.convert = (p) => p;
1224
1202
  var Ignore = class {
@@ -1241,17 +1219,17 @@ var require_ignore = __commonJS({
1241
1219
  }
1242
1220
  // @returns {TestResult}
1243
1221
  _test(originalPath, cache, checkUnignored, slices) {
1244
- let path2 = originalPath && checkPath.convert(originalPath);
1222
+ let path = originalPath && checkPath.convert(originalPath);
1245
1223
  return checkPath(
1246
- path2,
1224
+ path,
1247
1225
  originalPath,
1248
1226
  this._strictPathCheck ? throwError : RETURN_FALSE
1249
- ), this._t(path2, cache, checkUnignored, slices);
1227
+ ), this._t(path, cache, checkUnignored, slices);
1250
1228
  }
1251
- checkIgnore(path2) {
1252
- if (!REGEX_TEST_TRAILING_SLASH.test(path2))
1253
- return this.test(path2);
1254
- let slices = path2.split(SLASH).filter(Boolean);
1229
+ checkIgnore(path) {
1230
+ if (!REGEX_TEST_TRAILING_SLASH.test(path))
1231
+ return this.test(path);
1232
+ let slices = path.split(SLASH).filter(Boolean);
1255
1233
  if (slices.pop(), slices.length) {
1256
1234
  let parent = this._t(
1257
1235
  slices.join(SLASH) + SLASH,
@@ -1262,39 +1240,39 @@ var require_ignore = __commonJS({
1262
1240
  if (parent.ignored)
1263
1241
  return parent;
1264
1242
  }
1265
- return this._rules.test(path2, !1, MODE_CHECK_IGNORE);
1243
+ return this._rules.test(path, !1, MODE_CHECK_IGNORE);
1266
1244
  }
1267
- _t(path2, cache, checkUnignored, slices) {
1268
- if (path2 in cache)
1269
- return cache[path2];
1270
- if (slices || (slices = path2.split(SLASH).filter(Boolean)), slices.pop(), !slices.length)
1271
- return cache[path2] = this._rules.test(path2, checkUnignored, MODE_IGNORE);
1245
+ _t(path, cache, checkUnignored, slices) {
1246
+ if (path in cache)
1247
+ return cache[path];
1248
+ if (slices || (slices = path.split(SLASH).filter(Boolean)), slices.pop(), !slices.length)
1249
+ return cache[path] = this._rules.test(path, checkUnignored, MODE_IGNORE);
1272
1250
  let parent = this._t(
1273
1251
  slices.join(SLASH) + SLASH,
1274
1252
  cache,
1275
1253
  checkUnignored,
1276
1254
  slices
1277
1255
  );
1278
- return cache[path2] = parent.ignored ? parent : this._rules.test(path2, checkUnignored, MODE_IGNORE);
1256
+ return cache[path] = parent.ignored ? parent : this._rules.test(path, checkUnignored, MODE_IGNORE);
1279
1257
  }
1280
- ignores(path2) {
1281
- return this._test(path2, this._ignoreCache, !1).ignored;
1258
+ ignores(path) {
1259
+ return this._test(path, this._ignoreCache, !1).ignored;
1282
1260
  }
1283
1261
  createFilter() {
1284
- return (path2) => !this.ignores(path2);
1262
+ return (path) => !this.ignores(path);
1285
1263
  }
1286
1264
  filter(paths) {
1287
1265
  return makeArray(paths).filter(this.createFilter());
1288
1266
  }
1289
1267
  // @returns {TestResult}
1290
- test(path2) {
1291
- return this._test(path2, this._testCache, !0);
1268
+ test(path) {
1269
+ return this._test(path, this._testCache, !0);
1292
1270
  }
1293
- }, factory = (options) => new Ignore(options), isPathValid = (path2) => checkPath(path2 && checkPath.convert(path2), path2, RETURN_FALSE), setupWindows = () => {
1271
+ }, factory = (options) => new Ignore(options), isPathValid = (path) => checkPath(path && checkPath.convert(path), path, RETURN_FALSE), setupWindows = () => {
1294
1272
  let makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
1295
1273
  checkPath.convert = makePosix;
1296
1274
  let REGEX_TEST_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
1297
- checkPath.isNotRelative = (path2) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path2) || isNotRelative(path2);
1275
+ checkPath.isNotRelative = (path) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path) || isNotRelative(path);
1298
1276
  };
1299
1277
  // Detect `process` so that it can run in browsers.
1300
1278
  typeof process < "u" && process.platform === "win32" && setupWindows();
@@ -1305,417 +1283,6 @@ var require_ignore = __commonJS({
1305
1283
  }
1306
1284
  });
1307
1285
 
1308
- // packages/coding-agent/dist/core/event-bus.js
1309
- import { EventEmitter } from "node:events";
1310
- function createEventBus() {
1311
- let emitter = new EventEmitter();
1312
- return {
1313
- emit: (channel, data) => {
1314
- emitter.emit(channel, data);
1315
- },
1316
- on: (channel, handler) => {
1317
- let safeHandler = async (data) => {
1318
- try {
1319
- await handler(data);
1320
- } catch (err) {
1321
- console.error(`Event handler error (${channel}):`, err);
1322
- }
1323
- };
1324
- return emitter.on(channel, safeHandler), () => emitter.off(channel, safeHandler);
1325
- },
1326
- clear: () => {
1327
- emitter.removeAllListeners();
1328
- }
1329
- };
1330
- }
1331
-
1332
- // packages/coding-agent/dist/core/source-info.js
1333
- function createSourceInfo(path2, metadata) {
1334
- return {
1335
- path: path2,
1336
- source: metadata.source,
1337
- scope: metadata.scope,
1338
- origin: metadata.origin,
1339
- baseDir: metadata.baseDir
1340
- };
1341
- }
1342
- function createSyntheticSourceInfo(path2, options) {
1343
- return {
1344
- path: path2,
1345
- source: options.source,
1346
- scope: options.scope ?? "temporary",
1347
- origin: options.origin ?? "top-level",
1348
- baseDir: options.baseDir
1349
- };
1350
- }
1351
-
1352
- // packages/coding-agent/dist/core/extensions/loader.js
1353
- import * as fs from "node:fs";
1354
- import { createRequire } from "node:module";
1355
- import * as path from "node:path";
1356
- import { fileURLToPath } from "node:url";
1357
-
1358
- // packages/coding-agent/dist/core/exec.js
1359
- import { spawn } from "node:child_process";
1360
- async function execCommand(command, args, cwd, options) {
1361
- return new Promise((resolve6) => {
1362
- let proc = spawn(command, args, {
1363
- cwd,
1364
- shell: !1,
1365
- stdio: ["ignore", "pipe", "pipe"]
1366
- }), stdout = "", stderr = "", killed = !1, timeoutId, killProcess = () => {
1367
- killed || (killed = !0, proc.kill("SIGTERM"), setTimeout(() => {
1368
- proc.killed || proc.kill("SIGKILL");
1369
- }, 5e3));
1370
- };
1371
- options?.signal && (options.signal.aborted ? killProcess() : options.signal.addEventListener("abort", killProcess, { once: !0 })), options?.timeout && options.timeout > 0 && (timeoutId = setTimeout(() => {
1372
- killProcess();
1373
- }, options.timeout)), proc.stdout?.on("data", (data) => {
1374
- stdout += data.toString();
1375
- }), proc.stderr?.on("data", (data) => {
1376
- stderr += data.toString();
1377
- }), waitForChildProcess(proc).then((code) => {
1378
- timeoutId && clearTimeout(timeoutId), options?.signal && options.signal.removeEventListener("abort", killProcess), resolve6({ stdout, stderr, code: code ?? 0, killed });
1379
- }).catch((_err) => {
1380
- timeoutId && clearTimeout(timeoutId), options?.signal && options.signal.removeEventListener("abort", killProcess), resolve6({ stdout, stderr, code: 1, killed });
1381
- });
1382
- });
1383
- }
1384
-
1385
- // packages/coding-agent/dist/core/extensions/loader.js
1386
- var bunExtensionHost, createJitiFn;
1387
- var require2 = createRequire(new URL("../core/extensions/loader.js", import.meta.url).href), _aliases = null;
1388
- function getAliases() {
1389
- if (_aliases)
1390
- return _aliases;
1391
- let __dirname = path.dirname(fileURLToPath(new URL("../core/extensions/loader.js", import.meta.url).href)), packageIndex = path.resolve(__dirname, "../..", isNodeBundle ? "node-runtime/index.js" : "index.js"), typeboxEntry = require2.resolve("typebox"), typeboxCompileEntry = require2.resolve("typebox/compile"), typeboxValueEntry = require2.resolve("typebox/value"), packagesRoot = path.resolve(__dirname, "../../../../"), resolveWorkspaceOrImport = (workspaceRelativePath, specifier) => {
1392
- let workspacePath = path.join(packagesRoot, workspaceRelativePath);
1393
- return fs.existsSync(workspacePath) ? workspacePath : fileURLToPath(import.meta.resolve(specifier));
1394
- }, piCodingAgentEntry = packageIndex, piAgentCoreEntry = resolveWorkspaceOrImport("agent/dist/index.js", "@ashx-j/lunr-agent"), piTuiEntry = resolveWorkspaceOrImport("tui/dist/index.js", "@ashx-j/lunr-tui"), piAiCompatEntry = resolveWorkspaceOrImport("ai/dist/compat.js", "@ashx-j/lunr-ai/compat"), piAiOauthEntry = resolveWorkspaceOrImport("ai/dist/oauth.js", "@ashx-j/lunr-ai/oauth"), piAiProvidersEntry = resolveWorkspaceOrImport("ai/dist/providers/all.js", "@ashx-j/lunr-ai/providers/all");
1395
- return _aliases = {
1396
- "@ashx-j/lunr-dev": piCodingAgentEntry,
1397
- "@ashx-j/lunr-agent": piAgentCoreEntry,
1398
- "@ashx-j/lunr-tui": piTuiEntry,
1399
- "@ashx-j/lunr-ai/providers/all": piAiProvidersEntry,
1400
- "@ashx-j/lunr-ai/compat": piAiCompatEntry,
1401
- "@ashx-j/lunr-ai/oauth": piAiOauthEntry,
1402
- "@ashx-j/lunr-ai": piAiCompatEntry,
1403
- "@ashx-j/lunr": piCodingAgentEntry,
1404
- "@ashx-j/lunr-agent": piAgentCoreEntry,
1405
- "@ashx-j/lunr-tui": piTuiEntry,
1406
- "@ashx-j/lunr-ai/providers/all": piAiProvidersEntry,
1407
- "@ashx-j/lunr-ai/compat": piAiCompatEntry,
1408
- "@ashx-j/lunr-ai/oauth": piAiOauthEntry,
1409
- "@ashx-j/lunr-ai": piAiCompatEntry,
1410
- "@mariozechner/pi-coding-agent": piCodingAgentEntry,
1411
- "@mariozechner/pi-agent-core": piAgentCoreEntry,
1412
- "@mariozechner/pi-tui": piTuiEntry,
1413
- "@mariozechner/pi-ai/providers/all": piAiProvidersEntry,
1414
- "@mariozechner/pi-ai/compat": piAiCompatEntry,
1415
- "@mariozechner/pi-ai/oauth": piAiOauthEntry,
1416
- "@mariozechner/pi-ai": piAiCompatEntry,
1417
- typebox: typeboxEntry,
1418
- "typebox/compile": typeboxCompileEntry,
1419
- "typebox/value": typeboxValueEntry,
1420
- "@sinclair/typebox": typeboxEntry,
1421
- "@sinclair/typebox/compile": typeboxCompileEntry,
1422
- "@sinclair/typebox/value": typeboxValueEntry
1423
- }, _aliases;
1424
- }
1425
- var extensionCacheCwd, extensionCacheGeneration = 0, extensionCache = /* @__PURE__ */ new Map();
1426
- function clearExtensionCache() {
1427
- extensionCache.clear(), extensionCacheCwd = void 0, extensionCacheGeneration++;
1428
- }
1429
- function useExtensionCacheCwd(cwd) {
1430
- let resolvedCwd = resolvePath(cwd);
1431
- return extensionCacheCwd !== void 0 && extensionCacheCwd !== resolvedCwd && clearExtensionCache(), extensionCacheCwd = resolvedCwd, { cwd: resolvedCwd, generation: extensionCacheGeneration };
1432
- }
1433
- function createExtensionRuntime() {
1434
- let notInitialized = () => {
1435
- throw new Error("Extension runtime not initialized. Action methods cannot be called during extension loading.");
1436
- }, state = {}, runtime = {
1437
- sendMessage: notInitialized,
1438
- sendUserMessage: notInitialized,
1439
- appendEntry: notInitialized,
1440
- setSessionName: notInitialized,
1441
- getSessionName: notInitialized,
1442
- setLabel: notInitialized,
1443
- getActiveTools: notInitialized,
1444
- getAllTools: notInitialized,
1445
- setActiveTools: notInitialized,
1446
- // registerTool() is valid during extension load; refresh is only needed post-bind.
1447
- refreshTools: () => {
1448
- },
1449
- getCommands: notInitialized,
1450
- setModel: () => Promise.reject(new Error("Extension runtime not initialized")),
1451
- getThinkingLevel: notInitialized,
1452
- setThinkingLevel: notInitialized,
1453
- flagValues: /* @__PURE__ */ new Map(),
1454
- pendingProviderRegistrations: [],
1455
- assertActive: () => {
1456
- if (state.staleMessage)
1457
- throw new Error(state.staleMessage);
1458
- },
1459
- invalidate: (message) => {
1460
- state.staleMessage ??= message ?? "This extension ctx is stale after session replacement or reload. Do not use a captured pi or command ctx after ctx.newSession(), ctx.fork(), ctx.switchSession(), or ctx.reload(). For newSession, fork, and switchSession, move post-replacement work into withSession and use the ctx passed to withSession. For reload, do not use the old ctx after await ctx.reload().";
1461
- },
1462
- // Pre-bind: queue registrations so bindCore() can flush them once the
1463
- // model registry is available. bindCore() replaces both with direct calls.
1464
- registerProvider: (name, config, extensionPath = "<unknown>") => {
1465
- runtime.pendingProviderRegistrations.push({ name, config, extensionPath });
1466
- },
1467
- unregisterProvider: (name) => {
1468
- runtime.pendingProviderRegistrations = runtime.pendingProviderRegistrations.filter((r) => r.name !== name);
1469
- }
1470
- };
1471
- return runtime;
1472
- }
1473
- function createExtensionAPI(extension, runtime, cwd, eventBus) {
1474
- return {
1475
- // Registration methods - write to extension
1476
- on(event, handler) {
1477
- runtime.assertActive();
1478
- let list = extension.handlers.get(event) ?? [];
1479
- list.push(handler), extension.handlers.set(event, list);
1480
- },
1481
- registerTool(tool) {
1482
- runtime.assertActive(), extension.tools.set(tool.name, {
1483
- definition: tool,
1484
- sourceInfo: extension.sourceInfo
1485
- }), runtime.refreshTools();
1486
- },
1487
- registerCommand(name, options) {
1488
- runtime.assertActive(), extension.commands.set(name, {
1489
- name,
1490
- sourceInfo: extension.sourceInfo,
1491
- ...options
1492
- });
1493
- },
1494
- registerShortcut(shortcut, options) {
1495
- runtime.assertActive(), extension.shortcuts.set(shortcut, { shortcut, extensionPath: extension.path, ...options });
1496
- },
1497
- registerFlag(name, options) {
1498
- runtime.assertActive(), extension.flags.set(name, { name, extensionPath: extension.path, ...options }), options.default !== void 0 && !runtime.flagValues.has(name) && runtime.flagValues.set(name, options.default);
1499
- },
1500
- registerMessageRenderer(customType, renderer) {
1501
- runtime.assertActive(), extension.messageRenderers.set(customType, renderer);
1502
- },
1503
- registerEntryRenderer(customType, renderer) {
1504
- runtime.assertActive(), extension.entryRenderers ??= /* @__PURE__ */ new Map(), extension.entryRenderers.set(customType, renderer);
1505
- },
1506
- // Flag access - checks extension registered it, reads from runtime
1507
- getFlag(name) {
1508
- if (runtime.assertActive(), !!extension.flags.has(name))
1509
- return runtime.flagValues.get(name);
1510
- },
1511
- // Action methods - delegate to shared runtime
1512
- sendMessage(message, options) {
1513
- runtime.assertActive(), runtime.sendMessage(message, options);
1514
- },
1515
- sendUserMessage(content, options) {
1516
- runtime.assertActive(), runtime.sendUserMessage(content, options);
1517
- },
1518
- appendEntry(customType, data) {
1519
- runtime.assertActive(), runtime.appendEntry(customType, data);
1520
- },
1521
- setSessionName(name) {
1522
- runtime.assertActive(), runtime.setSessionName(name);
1523
- },
1524
- getSessionName() {
1525
- return runtime.assertActive(), runtime.getSessionName();
1526
- },
1527
- setLabel(entryId, label) {
1528
- runtime.assertActive(), runtime.setLabel(entryId, label);
1529
- },
1530
- exec(command, args, options) {
1531
- return runtime.assertActive(), execCommand(command, args, options?.cwd ?? cwd, options);
1532
- },
1533
- getActiveTools() {
1534
- return runtime.assertActive(), runtime.getActiveTools();
1535
- },
1536
- getAllTools() {
1537
- return runtime.assertActive(), runtime.getAllTools();
1538
- },
1539
- setActiveTools(toolNames) {
1540
- runtime.assertActive(), runtime.setActiveTools(toolNames);
1541
- },
1542
- getCommands() {
1543
- return runtime.assertActive(), runtime.getCommands();
1544
- },
1545
- setModel(model) {
1546
- return runtime.assertActive(), runtime.setModel(model);
1547
- },
1548
- getThinkingLevel() {
1549
- return runtime.assertActive(), runtime.getThinkingLevel();
1550
- },
1551
- setThinkingLevel(level) {
1552
- runtime.assertActive(), runtime.setThinkingLevel(level);
1553
- },
1554
- registerProvider(name, config) {
1555
- runtime.assertActive(), runtime.registerProvider(name, config, extension.path);
1556
- },
1557
- unregisterProvider(name) {
1558
- runtime.assertActive(), runtime.unregisterProvider(name, extension.path);
1559
- },
1560
- events: eventBus
1561
- };
1562
- }
1563
- function isCurrentCacheToken(cacheToken) {
1564
- return cacheToken !== void 0 && extensionCacheCwd === cacheToken.cwd && extensionCacheGeneration === cacheToken.generation;
1565
- }
1566
- async function ensureExtensionHost() {
1567
- if (createJitiFn)
1568
- return createJitiFn;
1569
- if (isBunBinary && bunExtensionHost)
1570
- return bunExtensionHost.createJiti;
1571
- let { createJiti } = await import("jiti/static");
1572
- return createJitiFn = createJiti, createJiti;
1573
- }
1574
- async function loadExtensionModule(extensionPath, cacheToken) {
1575
- if (isCurrentCacheToken(cacheToken)) {
1576
- let cachedFactory = extensionCache.get(extensionPath);
1577
- if (cachedFactory)
1578
- return cachedFactory;
1579
- }
1580
- let factory = await (await ensureExtensionHost())(new URL("../core/extensions/loader.js", import.meta.url).href, {
1581
- moduleCache: !1,
1582
- // In Bun binary: use virtualModules for bundled packages (no filesystem resolution)
1583
- // Also disable tryNative so jiti handles ALL imports (not just the entry point)
1584
- // In Node.js/dev: use aliases to resolve to node_modules paths
1585
- ...isBunBinary ? { virtualModules: bunExtensionHost?.virtualModules, tryNative: !1 } : { alias: getAliases() }
1586
- }).import(extensionPath, { default: !0 });
1587
- if (typeof factory == "function")
1588
- return isCurrentCacheToken(cacheToken) && extensionCache.set(extensionPath, factory), factory;
1589
- }
1590
- function createExtension(extensionPath, resolvedPath) {
1591
- let source = extensionPath.startsWith("<") && extensionPath.endsWith(">") ? extensionPath.slice(1, -1).split(":")[0] || "temporary" : "local", baseDir = extensionPath.startsWith("<") ? void 0 : path.dirname(resolvedPath);
1592
- return {
1593
- path: extensionPath,
1594
- resolvedPath,
1595
- sourceInfo: createSyntheticSourceInfo(extensionPath, { source, baseDir }),
1596
- handlers: /* @__PURE__ */ new Map(),
1597
- tools: /* @__PURE__ */ new Map(),
1598
- messageRenderers: /* @__PURE__ */ new Map(),
1599
- entryRenderers: /* @__PURE__ */ new Map(),
1600
- commands: /* @__PURE__ */ new Map(),
1601
- flags: /* @__PURE__ */ new Map(),
1602
- shortcuts: /* @__PURE__ */ new Map()
1603
- };
1604
- }
1605
- async function loadExtension(extensionPath, cwd, eventBus, runtime, cacheToken) {
1606
- let resolvedPath = resolvePath(extensionPath, cwd, { normalizeUnicodeSpaces: !0 });
1607
- try {
1608
- let factory = await measureStartup(`${extensionPath} module import`, () => loadExtensionModule(resolvedPath, cacheToken));
1609
- if (!factory)
1610
- return { extension: null, error: `Extension does not export a valid factory function: ${extensionPath}` };
1611
- let extension = createExtension(extensionPath, resolvedPath), api = createExtensionAPI(extension, runtime, cwd, eventBus);
1612
- return await measureStartup(`${extensionPath} factory`, () => factory(api)), { extension, error: null };
1613
- } catch (err) {
1614
- return { extension: null, error: `Failed to load extension: ${err instanceof Error ? err.message : String(err)}` };
1615
- }
1616
- }
1617
- async function loadExtensionFromFactory(factory, cwd, eventBus, runtime, extensionPath = "<inline>") {
1618
- let extension = createExtension(extensionPath, extensionPath), resolvedCwd = resolvePath(cwd), api = createExtensionAPI(extension, runtime, resolvedCwd, eventBus);
1619
- return await measureStartup(`${extensionPath} factory`, () => factory(api)), extension;
1620
- }
1621
- async function loadExtensionsInternal(paths, cwd, eventBus, runtime, useCache = !1) {
1622
- let extensions = [], errors = [], cacheToken = useCache ? useExtensionCacheCwd(cwd) : void 0, resolvedCwd = cacheToken?.cwd ?? resolvePath(cwd), resolvedEventBus = eventBus ?? createEventBus(), resolvedRuntime = runtime ?? createExtensionRuntime();
1623
- for (let extPath of paths) {
1624
- let { extension, error } = await loadExtension(extPath, resolvedCwd, resolvedEventBus, resolvedRuntime, cacheToken);
1625
- if (error) {
1626
- errors.push({ path: extPath, error });
1627
- continue;
1628
- }
1629
- extension && extensions.push(extension);
1630
- }
1631
- return {
1632
- extensions,
1633
- errors,
1634
- runtime: resolvedRuntime
1635
- };
1636
- }
1637
- async function loadExtensions(paths, cwd, eventBus, runtime) {
1638
- return loadExtensionsInternal(paths, cwd, eventBus, runtime);
1639
- }
1640
- async function loadExtensionsCached(paths, cwd, eventBus, runtime) {
1641
- return loadExtensionsInternal(paths, cwd, eventBus, runtime, !0);
1642
- }
1643
- function readPiManifest(packageJsonPath) {
1644
- try {
1645
- let content = fs.readFileSync(packageJsonPath, "utf-8"), pkg = JSON.parse(content);
1646
- return pkg.pi && typeof pkg.pi == "object" ? pkg.pi : null;
1647
- } catch {
1648
- return null;
1649
- }
1650
- }
1651
- function isExtensionFile(name) {
1652
- return name.endsWith(".ts") || name.endsWith(".js");
1653
- }
1654
- function resolveExtensionEntries(dir) {
1655
- let packageJsonPath = path.join(dir, "package.json");
1656
- if (fs.existsSync(packageJsonPath)) {
1657
- let manifest = readPiManifest(packageJsonPath);
1658
- if (manifest?.extensions?.length) {
1659
- let entries = [];
1660
- for (let extPath of manifest.extensions) {
1661
- let resolvedExtPath = path.resolve(dir, extPath);
1662
- fs.existsSync(resolvedExtPath) && entries.push(resolvedExtPath);
1663
- }
1664
- if (entries.length > 0)
1665
- return entries;
1666
- }
1667
- }
1668
- let indexTs = path.join(dir, "index.ts"), indexJs = path.join(dir, "index.js");
1669
- return fs.existsSync(indexTs) ? [indexTs] : fs.existsSync(indexJs) ? [indexJs] : null;
1670
- }
1671
- function discoverExtensionsInDir(dir) {
1672
- if (!fs.existsSync(dir))
1673
- return [];
1674
- let discovered = [];
1675
- try {
1676
- let entries = fs.readdirSync(dir, { withFileTypes: !0 });
1677
- for (let entry of entries) {
1678
- let entryPath = path.join(dir, entry.name);
1679
- if ((entry.isFile() || entry.isSymbolicLink()) && isExtensionFile(entry.name)) {
1680
- discovered.push(entryPath);
1681
- continue;
1682
- }
1683
- if (entry.isDirectory() || entry.isSymbolicLink()) {
1684
- let entries2 = resolveExtensionEntries(entryPath);
1685
- entries2 && discovered.push(...entries2);
1686
- }
1687
- }
1688
- } catch {
1689
- return [];
1690
- }
1691
- return discovered;
1692
- }
1693
- async function discoverAndLoadExtensions(configuredPaths, cwd, agentDir = getAgentDir(), eventBus) {
1694
- let resolvedCwd = resolvePath(cwd), resolvedAgentDir = resolvePath(agentDir), allPaths = [], seen = /* @__PURE__ */ new Set(), addPaths = (paths) => {
1695
- for (let p of paths) {
1696
- let resolved = path.resolve(p);
1697
- seen.has(resolved) || (seen.add(resolved), allPaths.push(p));
1698
- }
1699
- }, localExtDir = path.join(resolvedCwd, CONFIG_DIR_NAME, "extensions");
1700
- addPaths(discoverExtensionsInDir(localExtDir));
1701
- let globalExtDir = path.join(resolvedAgentDir, "extensions");
1702
- addPaths(discoverExtensionsInDir(globalExtDir));
1703
- for (let p of configuredPaths) {
1704
- let resolved = resolvePath(p, resolvedCwd, { normalizeUnicodeSpaces: !0 });
1705
- if (fs.existsSync(resolved) && fs.statSync(resolved).isDirectory()) {
1706
- let entries = resolveExtensionEntries(resolved);
1707
- if (entries) {
1708
- addPaths(entries);
1709
- continue;
1710
- }
1711
- addPaths(discoverExtensionsInDir(resolved));
1712
- continue;
1713
- }
1714
- addPaths([resolved]);
1715
- }
1716
- return loadExtensions(allPaths, resolvedCwd, eventBus);
1717
- }
1718
-
1719
1286
  // packages/coding-agent/dist/utils/git.js
1720
1287
  var import_hosted_git_info = __toESM(require_lib(), 1);
1721
1288
  function splitRef(url) {
@@ -1786,23 +1353,23 @@ function buildGitSource(args) {
1786
1353
  };
1787
1354
  }
1788
1355
  function parseGenericGitUrl(url) {
1789
- let { repo: repoWithoutRef, ref } = splitRef(url), repo = repoWithoutRef, host = "", path2 = "", scpLikeMatch = repoWithoutRef.match(/^git@([^:]+):(.+)$/);
1356
+ let { repo: repoWithoutRef, ref } = splitRef(url), repo = repoWithoutRef, host = "", path = "", scpLikeMatch = repoWithoutRef.match(/^git@([^:]+):(.+)$/);
1790
1357
  if (scpLikeMatch)
1791
- host = scpLikeMatch[1] ?? "", path2 = scpLikeMatch[2] ?? "";
1358
+ host = scpLikeMatch[1] ?? "", path = scpLikeMatch[2] ?? "";
1792
1359
  else if (repoWithoutRef.startsWith("https://") || repoWithoutRef.startsWith("http://") || repoWithoutRef.startsWith("ssh://") || repoWithoutRef.startsWith("git://"))
1793
1360
  try {
1794
1361
  let parsed = new URL(repoWithoutRef);
1795
- host = parsed.hostname, path2 = parsed.pathname.replace(/^\/+/, "");
1362
+ host = parsed.hostname, path = parsed.pathname.replace(/^\/+/, "");
1796
1363
  } catch {
1797
1364
  return null;
1798
1365
  }
1799
1366
  else {
1800
1367
  let slashIndex = repoWithoutRef.indexOf("/");
1801
- if (slashIndex < 0 || (host = repoWithoutRef.slice(0, slashIndex), path2 = repoWithoutRef.slice(slashIndex + 1), !host.includes(".") && host !== "localhost"))
1368
+ if (slashIndex < 0 || (host = repoWithoutRef.slice(0, slashIndex), path = repoWithoutRef.slice(slashIndex + 1), !host.includes(".") && host !== "localhost"))
1802
1369
  return null;
1803
1370
  repo = `https://${repoWithoutRef}`;
1804
1371
  }
1805
- return buildGitSource({ repo, host, path: path2, ref });
1372
+ return buildGitSource({ repo, host, path, ref });
1806
1373
  }
1807
1374
  function parseGitUrl(source) {
1808
1375
  let trimmed = source.trim(), hasGitPrefix = trimmed.startsWith("git:"), url = hasGitPrefix ? trimmed.slice(4).trim() : trimmed;
@@ -1842,9 +1409,9 @@ function parseGitUrl(source) {
1842
1409
 
1843
1410
  // packages/coding-agent/dist/core/package-manager.js
1844
1411
  import { createHash } from "node:crypto";
1845
- import { chmodSync, existsSync as existsSync2, mkdirSync, readdirSync as readdirSync2, readFileSync as readFileSync2, rmSync, statSync as statSync2, writeFileSync } from "node:fs";
1412
+ import { chmodSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs";
1846
1413
  import { homedir } from "node:os";
1847
- import { basename, dirname as dirname2, join as join2, relative, resolve as resolve2, sep } from "node:path";
1414
+ import { basename, dirname, join, relative, resolve, sep } from "node:path";
1848
1415
 
1849
1416
  // node_modules/glob/dist/esm/index.min.js
1850
1417
  import { fileURLToPath as Wi } from "node:url";
@@ -1877,12 +1444,12 @@ var Gt = (n7, t, e) => {
1877
1444
  s.length && o !== void 0 && (h = [r, o]);
1878
1445
  }
1879
1446
  return h;
1880
- }, fe = "\0SLASH" + Math.random() + "\0", ue = "\0OPEN" + Math.random() + "\0", qt = "\0CLOSE" + Math.random() + "\0", de = "\0COMMA" + Math.random() + "\0", pe = "\0PERIOD" + Math.random() + "\0", is = new RegExp(fe, "g"), rs = new RegExp(ue, "g"), ns = new RegExp(qt, "g"), os = new RegExp(de, "g"), hs = new RegExp(pe, "g"), as = /\\\\/g, ls = /\\{/g, cs = /\\}/g, fs2 = /\\,/g, us = /\\./g, ds = 1e5;
1447
+ }, fe = "\0SLASH" + Math.random() + "\0", ue = "\0OPEN" + Math.random() + "\0", qt = "\0CLOSE" + Math.random() + "\0", de = "\0COMMA" + Math.random() + "\0", pe = "\0PERIOD" + Math.random() + "\0", is = new RegExp(fe, "g"), rs = new RegExp(ue, "g"), ns = new RegExp(qt, "g"), os = new RegExp(de, "g"), hs = new RegExp(pe, "g"), as = /\\\\/g, ls = /\\{/g, cs = /\\}/g, fs = /\\,/g, us = /\\./g, ds = 1e5;
1881
1448
  function Ht(n7) {
1882
1449
  return isNaN(n7) ? n7.charCodeAt(0) : parseInt(n7, 10);
1883
1450
  }
1884
1451
  function ps(n7) {
1885
- return n7.replace(as, fe).replace(ls, ue).replace(cs, qt).replace(fs2, de).replace(us, pe);
1452
+ return n7.replace(as, fe).replace(ls, ue).replace(cs, qt).replace(fs, de).replace(us, pe);
1886
1453
  }
1887
1454
  function ms(n7) {
1888
1455
  return n7.replace(is, "\\").replace(rs, "{").replace(ns, "}").replace(os, ",").replace(hs, ".");
@@ -4651,7 +4218,7 @@ function getEnv() {
4651
4218
  if (process.platform !== "linux" || Object.keys(process.env).length > 0)
4652
4219
  return process.env;
4653
4220
  try {
4654
- let data = readFileSync2("/proc/self/environ", "utf-8"), env = {};
4221
+ let data = readFileSync("/proc/self/environ", "utf-8"), env = {};
4655
4222
  for (let entry of data.split("\0")) {
4656
4223
  let idx = entry.indexOf("=");
4657
4224
  idx > 0 && (env[entry.slice(0, idx)] = entry.slice(idx + 1));
@@ -4688,7 +4255,7 @@ function getHomeDir() {
4688
4255
  return process.env.HOME || homedir();
4689
4256
  }
4690
4257
  function getExtensionTempFolder(agentDir) {
4691
- let tempFolder = join2(agentDir, "tmp", "extensions");
4258
+ let tempFolder = join(agentDir, "tmp", "extensions");
4692
4259
  return mkdirSync(tempFolder, { recursive: !0, mode: 448 }), chmodSync(tempFolder, 448), tempFolder;
4693
4260
  }
4694
4261
  function prefixIgnorePattern(line, prefix) {
@@ -4703,10 +4270,10 @@ function prefixIgnorePattern(line, prefix) {
4703
4270
  function addIgnoreRules(ig, dir, rootDir) {
4704
4271
  let relativeDir = relative(rootDir, dir), prefix = relativeDir ? `${toPosixPath(relativeDir)}/` : "";
4705
4272
  for (let filename of IGNORE_FILE_NAMES) {
4706
- let ignorePath = join2(dir, filename);
4707
- if (existsSync2(ignorePath))
4273
+ let ignorePath = join(dir, filename);
4274
+ if (existsSync(ignorePath))
4708
4275
  try {
4709
- let patterns = readFileSync2(ignorePath, "utf-8").split(/\r?\n/).map((line) => prefixIgnorePattern(line, prefix)).filter((line) => !!line);
4276
+ let patterns = readFileSync(ignorePath, "utf-8").split(/\r?\n/).map((line) => prefixIgnorePattern(line, prefix)).filter((line) => !!line);
4710
4277
  patterns.length > 0 && ig.add(patterns);
4711
4278
  } catch {
4712
4279
  }
@@ -4729,19 +4296,19 @@ function splitPatterns(entries) {
4729
4296
  }
4730
4297
  function collectFiles(dir, filePattern, skipNodeModules = !0, ignoreMatcher, rootDir) {
4731
4298
  let files = [];
4732
- if (!existsSync2(dir))
4299
+ if (!existsSync(dir))
4733
4300
  return files;
4734
4301
  let root = rootDir ?? dir, ig = ignoreMatcher ?? (0, import_ignore.default)();
4735
4302
  addIgnoreRules(ig, dir, root);
4736
4303
  try {
4737
- let entries = readdirSync2(dir, { withFileTypes: !0 });
4304
+ let entries = readdirSync(dir, { withFileTypes: !0 });
4738
4305
  for (let entry of entries) {
4739
4306
  if (entry.name.startsWith(".") || skipNodeModules && entry.name === "node_modules")
4740
4307
  continue;
4741
- let fullPath = join2(dir, entry.name), isDir = entry.isDirectory(), isFile = entry.isFile();
4308
+ let fullPath = join(dir, entry.name), isDir = entry.isDirectory(), isFile = entry.isFile();
4742
4309
  if (entry.isSymbolicLink())
4743
4310
  try {
4744
- let stats = statSync2(fullPath);
4311
+ let stats = statSync(fullPath);
4745
4312
  isDir = stats.isDirectory(), isFile = stats.isFile();
4746
4313
  } catch {
4747
4314
  continue;
@@ -4755,19 +4322,19 @@ function collectFiles(dir, filePattern, skipNodeModules = !0, ignoreMatcher, roo
4755
4322
  }
4756
4323
  function collectSkillEntries(dir, mode, ignoreMatcher, rootDir) {
4757
4324
  let entries = [];
4758
- if (!existsSync2(dir))
4325
+ if (!existsSync(dir))
4759
4326
  return entries;
4760
4327
  let root = rootDir ?? dir, ig = ignoreMatcher ?? (0, import_ignore.default)();
4761
4328
  addIgnoreRules(ig, dir, root);
4762
4329
  try {
4763
- let dirEntries = readdirSync2(dir, { withFileTypes: !0 });
4330
+ let dirEntries = readdirSync(dir, { withFileTypes: !0 });
4764
4331
  for (let entry of dirEntries) {
4765
4332
  if (entry.name !== "SKILL.md")
4766
4333
  continue;
4767
- let fullPath = join2(dir, entry.name), isFile = entry.isFile();
4334
+ let fullPath = join(dir, entry.name), isFile = entry.isFile();
4768
4335
  if (entry.isSymbolicLink())
4769
4336
  try {
4770
- isFile = statSync2(fullPath).isFile();
4337
+ isFile = statSync(fullPath).isFile();
4771
4338
  } catch {
4772
4339
  continue;
4773
4340
  }
@@ -4778,10 +4345,10 @@ function collectSkillEntries(dir, mode, ignoreMatcher, rootDir) {
4778
4345
  for (let entry of dirEntries) {
4779
4346
  if (entry.name.startsWith(".") || entry.name === "node_modules")
4780
4347
  continue;
4781
- let fullPath = join2(dir, entry.name), isDir = entry.isDirectory(), isFile = entry.isFile();
4348
+ let fullPath = join(dir, entry.name), isDir = entry.isDirectory(), isFile = entry.isFile();
4782
4349
  if (entry.isSymbolicLink())
4783
4350
  try {
4784
- let stats = statSync2(fullPath);
4351
+ let stats = statSync(fullPath);
4785
4352
  isDir = stats.isDirectory(), isFile = stats.isFile();
4786
4353
  } catch {
4787
4354
  continue;
@@ -4801,20 +4368,20 @@ function collectAutoSkillEntries(dir, mode) {
4801
4368
  return collectSkillEntries(dir, mode);
4802
4369
  }
4803
4370
  function findGitRepoRoot(startDir) {
4804
- let dir = resolve2(startDir);
4371
+ let dir = resolve(startDir);
4805
4372
  for (; ; ) {
4806
- if (existsSync2(join2(dir, ".git")))
4373
+ if (existsSync(join(dir, ".git")))
4807
4374
  return dir;
4808
- let parent = dirname2(dir);
4375
+ let parent = dirname(dir);
4809
4376
  if (parent === dir)
4810
4377
  return null;
4811
4378
  dir = parent;
4812
4379
  }
4813
4380
  }
4814
4381
  function collectAncestorAgentsSkillDirs(startDir) {
4815
- let skillDirs = [], resolvedStartDir = resolve2(startDir), gitRepoRoot = findGitRepoRoot(resolvedStartDir), dir = resolvedStartDir;
4816
- for (; skillDirs.push(join2(dir, ".agents", "skills")), !(gitRepoRoot && dir === gitRepoRoot); ) {
4817
- let parent = dirname2(dir);
4382
+ let skillDirs = [], resolvedStartDir = resolve(startDir), gitRepoRoot = findGitRepoRoot(resolvedStartDir), dir = resolvedStartDir;
4383
+ for (; skillDirs.push(join(dir, ".agents", "skills")), !(gitRepoRoot && dir === gitRepoRoot); ) {
4384
+ let parent = dirname(dir);
4818
4385
  if (parent === dir)
4819
4386
  break;
4820
4387
  dir = parent;
@@ -4823,19 +4390,19 @@ function collectAncestorAgentsSkillDirs(startDir) {
4823
4390
  }
4824
4391
  function collectAutoPromptEntries(dir) {
4825
4392
  let entries = [];
4826
- if (!existsSync2(dir))
4393
+ if (!existsSync(dir))
4827
4394
  return entries;
4828
4395
  let ig = (0, import_ignore.default)();
4829
4396
  addIgnoreRules(ig, dir, dir);
4830
4397
  try {
4831
- let dirEntries = readdirSync2(dir, { withFileTypes: !0 });
4398
+ let dirEntries = readdirSync(dir, { withFileTypes: !0 });
4832
4399
  for (let entry of dirEntries) {
4833
4400
  if (entry.name.startsWith(".") || entry.name === "node_modules")
4834
4401
  continue;
4835
- let fullPath = join2(dir, entry.name), isFile = entry.isFile();
4402
+ let fullPath = join(dir, entry.name), isFile = entry.isFile();
4836
4403
  if (entry.isSymbolicLink())
4837
4404
  try {
4838
- isFile = statSync2(fullPath).isFile();
4405
+ isFile = statSync(fullPath).isFile();
4839
4406
  } catch {
4840
4407
  continue;
4841
4408
  }
@@ -4848,19 +4415,19 @@ function collectAutoPromptEntries(dir) {
4848
4415
  }
4849
4416
  function collectAutoThemeEntries(dir) {
4850
4417
  let entries = [];
4851
- if (!existsSync2(dir))
4418
+ if (!existsSync(dir))
4852
4419
  return entries;
4853
4420
  let ig = (0, import_ignore.default)();
4854
4421
  addIgnoreRules(ig, dir, dir);
4855
4422
  try {
4856
- let dirEntries = readdirSync2(dir, { withFileTypes: !0 });
4423
+ let dirEntries = readdirSync(dir, { withFileTypes: !0 });
4857
4424
  for (let entry of dirEntries) {
4858
4425
  if (entry.name.startsWith(".") || entry.name === "node_modules")
4859
4426
  continue;
4860
- let fullPath = join2(dir, entry.name), isFile = entry.isFile();
4427
+ let fullPath = join(dir, entry.name), isFile = entry.isFile();
4861
4428
  if (entry.isSymbolicLink())
4862
4429
  try {
4863
- isFile = statSync2(fullPath).isFile();
4430
+ isFile = statSync(fullPath).isFile();
4864
4431
  } catch {
4865
4432
  continue;
4866
4433
  }
@@ -4873,47 +4440,47 @@ function collectAutoThemeEntries(dir) {
4873
4440
  }
4874
4441
  function readPiManifestFile(packageJsonPath) {
4875
4442
  try {
4876
- let content = readFileSync2(packageJsonPath, "utf-8");
4443
+ let content = readFileSync(packageJsonPath, "utf-8");
4877
4444
  return JSON.parse(content).pi ?? null;
4878
4445
  } catch {
4879
4446
  return null;
4880
4447
  }
4881
4448
  }
4882
- function resolveExtensionEntries2(dir) {
4883
- let packageJsonPath = join2(dir, "package.json");
4884
- if (existsSync2(packageJsonPath)) {
4449
+ function resolveExtensionEntries(dir) {
4450
+ let packageJsonPath = join(dir, "package.json");
4451
+ if (existsSync(packageJsonPath)) {
4885
4452
  let manifest = readPiManifestFile(packageJsonPath);
4886
4453
  if (manifest?.extensions?.length) {
4887
4454
  let entries = [];
4888
4455
  for (let extPath of manifest.extensions) {
4889
- let resolvedExtPath = resolve2(dir, extPath);
4890
- existsSync2(resolvedExtPath) && entries.push(resolvedExtPath);
4456
+ let resolvedExtPath = resolve(dir, extPath);
4457
+ existsSync(resolvedExtPath) && entries.push(resolvedExtPath);
4891
4458
  }
4892
4459
  if (entries.length > 0)
4893
4460
  return entries;
4894
4461
  }
4895
4462
  }
4896
- let indexTs = join2(dir, "index.ts"), indexJs = join2(dir, "index.js");
4897
- return existsSync2(indexTs) ? [indexTs] : existsSync2(indexJs) ? [indexJs] : null;
4463
+ let indexTs = join(dir, "index.ts"), indexJs = join(dir, "index.js");
4464
+ return existsSync(indexTs) ? [indexTs] : existsSync(indexJs) ? [indexJs] : null;
4898
4465
  }
4899
4466
  function collectAutoExtensionEntries(dir) {
4900
4467
  let entries = [];
4901
- if (!existsSync2(dir))
4468
+ if (!existsSync(dir))
4902
4469
  return entries;
4903
- let rootEntries = resolveExtensionEntries2(dir);
4470
+ let rootEntries = resolveExtensionEntries(dir);
4904
4471
  if (rootEntries)
4905
4472
  return rootEntries;
4906
4473
  let ig = (0, import_ignore.default)();
4907
4474
  addIgnoreRules(ig, dir, dir);
4908
4475
  try {
4909
- let dirEntries = readdirSync2(dir, { withFileTypes: !0 });
4476
+ let dirEntries = readdirSync(dir, { withFileTypes: !0 });
4910
4477
  for (let entry of dirEntries) {
4911
4478
  if (entry.name.startsWith(".") || entry.name === "node_modules")
4912
4479
  continue;
4913
- let fullPath = join2(dir, entry.name), isDir = entry.isDirectory(), isFile = entry.isFile();
4480
+ let fullPath = join(dir, entry.name), isDir = entry.isDirectory(), isFile = entry.isFile();
4914
4481
  if (entry.isSymbolicLink())
4915
4482
  try {
4916
- let stats = statSync2(fullPath);
4483
+ let stats = statSync(fullPath);
4917
4484
  isDir = stats.isDirectory(), isFile = stats.isFile();
4918
4485
  } catch {
4919
4486
  continue;
@@ -4923,7 +4490,7 @@ function collectAutoExtensionEntries(dir) {
4923
4490
  if (isFile && (entry.name.endsWith(".ts") || entry.name.endsWith(".js")))
4924
4491
  entries.push(fullPath);
4925
4492
  else if (isDir) {
4926
- let resolvedEntries = resolveExtensionEntries2(fullPath);
4493
+ let resolvedEntries = resolveExtensionEntries(fullPath);
4927
4494
  resolvedEntries && entries.push(...resolvedEntries);
4928
4495
  }
4929
4496
  }
@@ -4936,7 +4503,7 @@ function collectResourceFiles(dir, resourceType) {
4936
4503
  return resourceType === "skills" ? collectSkillEntries(dir, "pi") : resourceType === "extensions" ? collectAutoExtensionEntries(dir) : collectFiles(dir, FILE_PATTERNS[resourceType]);
4937
4504
  }
4938
4505
  function matchesAnyPattern(filePath, patterns, baseDir) {
4939
- let rel = toPosixPath(relative(baseDir, filePath)), name = basename(filePath), filePathPosix = toPosixPath(filePath), isSkillFile = name === "SKILL.md", parentDir = isSkillFile ? dirname2(filePath) : void 0, parentRel = isSkillFile ? toPosixPath(relative(baseDir, parentDir)) : void 0, parentName = isSkillFile ? basename(parentDir) : void 0, parentDirPosix = isSkillFile ? toPosixPath(parentDir) : void 0;
4506
+ let rel = toPosixPath(relative(baseDir, filePath)), name = basename(filePath), filePathPosix = toPosixPath(filePath), isSkillFile = name === "SKILL.md", parentDir = isSkillFile ? dirname(filePath) : void 0, parentRel = isSkillFile ? toPosixPath(relative(baseDir, parentDir)) : void 0, parentName = isSkillFile ? basename(parentDir) : void 0, parentDirPosix = isSkillFile ? toPosixPath(parentDir) : void 0;
4940
4507
  return patterns.some((pattern) => {
4941
4508
  let normalizedPattern = toPosixPath(pattern);
4942
4509
  return minimatch(rel, normalizedPattern) || minimatch(name, normalizedPattern) || minimatch(filePathPosix, normalizedPattern) ? !0 : isSkillFile ? minimatch(parentRel, normalizedPattern) || minimatch(parentName, normalizedPattern) || minimatch(parentDirPosix, normalizedPattern) : !1;
@@ -4949,7 +4516,7 @@ function normalizeExactPattern(pattern) {
4949
4516
  function matchesAnyExactPattern(filePath, patterns, baseDir) {
4950
4517
  if (patterns.length === 0)
4951
4518
  return !1;
4952
- let rel = toPosixPath(relative(baseDir, filePath)), name = basename(filePath), filePathPosix = toPosixPath(filePath), isSkillFile = name === "SKILL.md", parentDir = isSkillFile ? dirname2(filePath) : void 0, parentRel = isSkillFile ? toPosixPath(relative(baseDir, parentDir)) : void 0, parentDirPosix = isSkillFile ? toPosixPath(parentDir) : void 0;
4519
+ let rel = toPosixPath(relative(baseDir, filePath)), name = basename(filePath), filePathPosix = toPosixPath(filePath), isSkillFile = name === "SKILL.md", parentDir = isSkillFile ? dirname(filePath) : void 0, parentRel = isSkillFile ? toPosixPath(relative(baseDir, parentDir)) : void 0, parentDirPosix = isSkillFile ? toPosixPath(parentDir) : void 0;
4953
4520
  return patterns.some((pattern) => {
4954
4521
  let normalized = normalizeExactPattern(pattern);
4955
4522
  return normalized === rel || normalized === filePathPosix ? !0 : isSkillFile ? normalized === parentRel || normalized === parentDirPosix : !1;
@@ -5013,16 +4580,16 @@ var DefaultPackageManager = class {
5013
4580
  getInstalledPath(source, scope) {
5014
4581
  let parsed = this.parseSource(source);
5015
4582
  if (parsed.type === "npm") {
5016
- let path2 = this.getNpmInstallPath(parsed, scope);
5017
- return existsSync2(path2) ? path2 : void 0;
4583
+ let path = this.getNpmInstallPath(parsed, scope);
4584
+ return existsSync(path) ? path : void 0;
5018
4585
  }
5019
4586
  if (parsed.type === "git") {
5020
- let path2 = this.getGitInstallPath(parsed, scope);
5021
- return existsSync2(path2) ? path2 : void 0;
4587
+ let path = this.getGitInstallPath(parsed, scope);
4588
+ return existsSync(path) ? path : void 0;
5022
4589
  }
5023
4590
  if (parsed.type === "local") {
5024
- let baseDir = this.getBaseDirForScope(scope), path2 = this.resolvePathFromBase(parsed.path, baseDir);
5025
- return existsSync2(path2) ? path2 : void 0;
4591
+ let baseDir = this.getBaseDirForScope(scope), path = this.resolvePathFromBase(parsed.path, baseDir);
4592
+ return existsSync(path) ? path : void 0;
5026
4593
  }
5027
4594
  }
5028
4595
  emitProgress(event) {
@@ -5045,7 +4612,7 @@ var DefaultPackageManager = class {
5045
4612
  allPackages.push({ pkg, scope: "user" });
5046
4613
  let packageSources = this.dedupePackages(allPackages);
5047
4614
  await this.resolvePackageSources(packageSources, accumulator, onMissing);
5048
- let globalBaseDir = this.agentDir, projectBaseDir = join2(this.cwd, CONFIG_DIR_NAME);
4615
+ let globalBaseDir = this.agentDir, projectBaseDir = join(this.cwd, CONFIG_DIR_NAME);
5049
4616
  for (let resourceType of RESOURCE_TYPES) {
5050
4617
  let target = this.getTargetMap(accumulator, resourceType), globalEntries = globalSettings[resourceType] ?? [], projectEntries = projectSettings[resourceType] ?? [];
5051
4618
  this.resolveLocalEntries(projectEntries, resourceType, target, {
@@ -5099,7 +4666,7 @@ var DefaultPackageManager = class {
5099
4666
  }
5100
4667
  if (parsed.type === "local") {
5101
4668
  let resolved = this.resolvePath(parsed.path);
5102
- if (!existsSync2(resolved))
4669
+ if (!existsSync(resolved))
5103
4670
  throw new Error(`Path does not exist: ${resolved}`);
5104
4671
  return;
5105
4672
  }
@@ -5169,7 +4736,7 @@ var DefaultPackageManager = class {
5169
4736
  await Promise.all(tasks);
5170
4737
  }
5171
4738
  async shouldUpdateNpmSource(source, scope) {
5172
- let installedPath = this.getManagedNpmInstallPath(source, scope), installedVersion = existsSync2(installedPath) ? this.getInstalledNpmVersion(installedPath) : void 0;
4739
+ let installedPath = this.getManagedNpmInstallPath(source, scope), installedVersion = existsSync(installedPath) ? this.getInstalledNpmVersion(installedPath) : void 0;
5173
4740
  if (!installedVersion)
5174
4741
  return !0;
5175
4742
  try {
@@ -5212,7 +4779,7 @@ var DefaultPackageManager = class {
5212
4779
  };
5213
4780
  if (parsed.type === "npm") {
5214
4781
  let installedPath = this.getNpmInstallPath(parsed, resolvedScope);
5215
- if (!existsSync2(installedPath) || !await this.installedNpmMatchesConfiguredVersion(parsed, installedPath)) {
4782
+ if (!existsSync(installedPath) || !await this.installedNpmMatchesConfiguredVersion(parsed, installedPath)) {
5216
4783
  if (!await installMissing())
5217
4784
  continue;
5218
4785
  installedPath = this.getNpmInstallPath(parsed, resolvedScope);
@@ -5222,7 +4789,7 @@ var DefaultPackageManager = class {
5222
4789
  }
5223
4790
  if (parsed.type === "git") {
5224
4791
  let installedPath = this.getGitInstallPath(parsed, resolvedScope);
5225
- if (existsSync2(installedPath))
4792
+ if (existsSync(installedPath))
5226
4793
  resolvedScope === "temporary" && !parsed.pinned && !isOfflineModeEnabled() && await this.refreshTemporaryGitSource(parsed, resolvedSource);
5227
4794
  else if (!await installMissing())
5228
4795
  continue;
@@ -5238,11 +4805,11 @@ var DefaultPackageManager = class {
5238
4805
  }
5239
4806
  resolveLocalExtensionSource(source, accumulator, filter, metadata, baseDir) {
5240
4807
  let resolved = this.resolvePathFromBase(source.path, baseDir);
5241
- if (existsSync2(resolved))
4808
+ if (existsSync(resolved))
5242
4809
  try {
5243
- let stats = statSync2(resolved);
4810
+ let stats = statSync(resolved);
5244
4811
  if (stats.isFile()) {
5245
- metadata.baseDir = dirname2(resolved), this.addResource(accumulator.extensions, resolved, metadata, !0);
4812
+ metadata.baseDir = dirname(resolved), this.addResource(accumulator.extensions, resolved, metadata, !0);
5246
4813
  return;
5247
4814
  }
5248
4815
  stats.isDirectory() && (metadata.baseDir = resolved, this.collectPackageResources(resolved, accumulator, filter, metadata) || this.addResource(accumulator.extensions, resolved, metadata, !0));
@@ -5328,10 +4895,10 @@ var DefaultPackageManager = class {
5328
4895
  return installedVersion ? source.range ? (0, import_semver.satisfies)(installedVersion, source.range) : !0 : !1;
5329
4896
  }
5330
4897
  getInstalledNpmVersion(installedPath) {
5331
- let packageJsonPath = join2(installedPath, "package.json");
5332
- if (existsSync2(packageJsonPath))
4898
+ let packageJsonPath = join(installedPath, "package.json");
4899
+ if (existsSync(packageJsonPath))
5333
4900
  try {
5334
- let content = readFileSync2(packageJsonPath, "utf-8");
4901
+ let content = readFileSync(packageJsonPath, "utf-8");
5335
4902
  return JSON.parse(content).version;
5336
4903
  } catch {
5337
4904
  return;
@@ -5509,7 +5076,7 @@ var DefaultPackageManager = class {
5509
5076
  }
5510
5077
  async uninstallNpm(source, scope) {
5511
5078
  let installRoot = this.getNpmInstallRoot(scope, !1);
5512
- if (!existsSync2(installRoot))
5079
+ if (!existsSync(installRoot))
5513
5080
  return;
5514
5081
  let packageManagerName = this.getPackageManagerName();
5515
5082
  if (packageManagerName === "bun") {
@@ -5521,7 +5088,7 @@ var DefaultPackageManager = class {
5521
5088
  }
5522
5089
  async installGit(source, scope) {
5523
5090
  let targetDir = this.getGitInstallPath(source, scope);
5524
- if (existsSync2(targetDir)) {
5091
+ if (existsSync(targetDir)) {
5525
5092
  if (source.ref) {
5526
5093
  await this.ensureGitRef(targetDir, ["fetch", "origin", source.ref], "FETCH_HEAD");
5527
5094
  return;
@@ -5531,16 +5098,16 @@ var DefaultPackageManager = class {
5531
5098
  return;
5532
5099
  }
5533
5100
  let gitRoot = this.getGitInstallRoot(scope);
5534
- gitRoot && this.ensureGitIgnore(gitRoot), mkdirSync(dirname2(targetDir), { recursive: !0 }), await this.runCommand("git", ["clone", source.repo, targetDir], { timeoutMs: PACKAGE_INSTALL_TIMEOUT_MS }), source.ref && await this.runCommand("git", ["checkout", source.ref], {
5101
+ gitRoot && this.ensureGitIgnore(gitRoot), mkdirSync(dirname(targetDir), { recursive: !0 }), await this.runCommand("git", ["clone", source.repo, targetDir], { timeoutMs: PACKAGE_INSTALL_TIMEOUT_MS }), source.ref && await this.runCommand("git", ["checkout", source.ref], {
5535
5102
  cwd: targetDir,
5536
5103
  timeoutMs: PACKAGE_INSTALL_TIMEOUT_MS
5537
5104
  });
5538
- let packageJsonPath = join2(targetDir, "package.json");
5539
- existsSync2(packageJsonPath) && await this.runNpmCommand(this.getGitDependencyInstallArgs(), { cwd: targetDir });
5105
+ let packageJsonPath = join(targetDir, "package.json");
5106
+ existsSync(packageJsonPath) && await this.runNpmCommand(this.getGitDependencyInstallArgs(), { cwd: targetDir });
5540
5107
  }
5541
5108
  async updateGit(source, scope) {
5542
5109
  let targetDir = this.getGitInstallPath(source, scope);
5543
- if (!existsSync2(targetDir)) {
5110
+ if (!existsSync(targetDir)) {
5544
5111
  await this.installGit(source, scope);
5545
5112
  return;
5546
5113
  }
@@ -5563,8 +5130,8 @@ var DefaultPackageManager = class {
5563
5130
  if (localHead.trim() === targetHead.trim())
5564
5131
  return;
5565
5132
  await this.runCommand("git", ["reset", "--hard", commitRef], { cwd: targetDir }), await this.runCommand("git", ["clean", "-fdx"], { cwd: targetDir });
5566
- let packageJsonPath = join2(targetDir, "package.json");
5567
- existsSync2(packageJsonPath) && await this.runNpmCommand(this.getGitDependencyInstallArgs(), { cwd: targetDir });
5133
+ let packageJsonPath = join(targetDir, "package.json");
5134
+ existsSync(packageJsonPath) && await this.runNpmCommand(this.getGitDependencyInstallArgs(), { cwd: targetDir });
5568
5135
  }
5569
5136
  async refreshTemporaryGitSource(source, sourceStr) {
5570
5137
  if (!isOfflineModeEnabled())
@@ -5577,41 +5144,41 @@ var DefaultPackageManager = class {
5577
5144
  }
5578
5145
  async removeGit(source, scope) {
5579
5146
  let targetDir = this.getGitInstallPath(source, scope);
5580
- existsSync2(targetDir) && (rmSync(targetDir, { recursive: !0, force: !0 }), this.pruneEmptyGitParents(targetDir, this.getGitInstallRoot(scope)));
5147
+ existsSync(targetDir) && (rmSync(targetDir, { recursive: !0, force: !0 }), this.pruneEmptyGitParents(targetDir, this.getGitInstallRoot(scope)));
5581
5148
  }
5582
5149
  pruneEmptyGitParents(targetDir, installRoot) {
5583
5150
  if (!installRoot)
5584
5151
  return;
5585
- let resolvedRoot = resolve2(installRoot), current = dirname2(targetDir);
5152
+ let resolvedRoot = resolve(installRoot), current = dirname(targetDir);
5586
5153
  for (; current.startsWith(resolvedRoot) && current !== resolvedRoot; ) {
5587
- if (!existsSync2(current)) {
5588
- current = dirname2(current);
5154
+ if (!existsSync(current)) {
5155
+ current = dirname(current);
5589
5156
  continue;
5590
5157
  }
5591
- if (readdirSync2(current).length > 0)
5158
+ if (readdirSync(current).length > 0)
5592
5159
  break;
5593
5160
  try {
5594
5161
  rmSync(current, { recursive: !0, force: !0 });
5595
5162
  } catch {
5596
5163
  break;
5597
5164
  }
5598
- current = dirname2(current);
5165
+ current = dirname(current);
5599
5166
  }
5600
5167
  }
5601
5168
  ensureNpmProject(installRoot) {
5602
- existsSync2(installRoot) || mkdirSync(installRoot, { recursive: !0 }), markPathIgnoredByCloudSync(installRoot), this.ensureGitIgnore(installRoot);
5603
- let packageJsonPath = join2(installRoot, "package.json");
5604
- existsSync2(packageJsonPath) || writeFileSync(packageJsonPath, JSON.stringify({ name: "pi-extensions", private: !0 }, null, 2), "utf-8");
5169
+ existsSync(installRoot) || mkdirSync(installRoot, { recursive: !0 }), markPathIgnoredByCloudSync(installRoot), this.ensureGitIgnore(installRoot);
5170
+ let packageJsonPath = join(installRoot, "package.json");
5171
+ existsSync(packageJsonPath) || writeFileSync(packageJsonPath, JSON.stringify({ name: "pi-extensions", private: !0 }, null, 2), "utf-8");
5605
5172
  }
5606
5173
  ensureGitIgnore(dir) {
5607
- existsSync2(dir) || mkdirSync(dir, { recursive: !0 });
5608
- let ignorePath = join2(dir, ".gitignore");
5609
- existsSync2(ignorePath) || writeFileSync(ignorePath, `*
5174
+ existsSync(dir) || mkdirSync(dir, { recursive: !0 });
5175
+ let ignorePath = join(dir, ".gitignore");
5176
+ existsSync(ignorePath) || writeFileSync(ignorePath, `*
5610
5177
  !.gitignore
5611
5178
  `, "utf-8");
5612
5179
  }
5613
5180
  getNpmInstallRoot(scope, temporary) {
5614
- return temporary ? this.getTemporaryDir("npm") : scope === "project" ? (this.assertProjectTrustedForScope(scope), join2(this.cwd, CONFIG_DIR_NAME, "npm")) : join2(this.agentDir, "npm");
5181
+ return temporary ? this.getTemporaryDir("npm") : scope === "project" ? (this.assertProjectTrustedForScope(scope), join(this.cwd, CONFIG_DIR_NAME, "npm")) : join(this.agentDir, "npm");
5615
5182
  }
5616
5183
  getGlobalNpmRoot() {
5617
5184
  let npmCommand = this.getNpmCommand(), commandKey = [npmCommand.command, ...npmCommand.args].join("\0");
@@ -5619,7 +5186,7 @@ var DefaultPackageManager = class {
5619
5186
  return this.globalNpmRoot;
5620
5187
  if (this.getPackageManagerName() === "bun") {
5621
5188
  let binDir = this.runNpmCommandSync(["pm", "bin", "-g"]).trim();
5622
- this.globalNpmRoot = join2(dirname2(binDir), "install", "global", "node_modules");
5189
+ this.globalNpmRoot = join(dirname(binDir), "install", "global", "node_modules");
5623
5190
  } else
5624
5191
  this.globalNpmRoot = this.runNpmCommandSync(["root", "-g"]).trim();
5625
5192
  return this.globalNpmRootCommandKey = commandKey, this.globalNpmRoot;
@@ -5629,27 +5196,27 @@ var DefaultPackageManager = class {
5629
5196
  return;
5630
5197
  let output = this.runNpmCommandSync(["list", "-g", "--depth", "0", "--json"]), entries = JSON.parse(output);
5631
5198
  for (let entry of entries) {
5632
- let path2 = entry.dependencies?.[packageName]?.path;
5633
- if (path2)
5634
- return path2;
5199
+ let path = entry.dependencies?.[packageName]?.path;
5200
+ if (path)
5201
+ return path;
5635
5202
  }
5636
5203
  }
5637
5204
  getManagedNpmInstallPath(source, scope) {
5638
- return scope === "temporary" ? join2(this.getTemporaryDir("npm"), "node_modules", source.name) : scope === "project" ? (this.assertProjectTrustedForScope(scope), join2(this.cwd, CONFIG_DIR_NAME, "npm", "node_modules", source.name)) : join2(this.agentDir, "npm", "node_modules", source.name);
5205
+ return scope === "temporary" ? join(this.getTemporaryDir("npm"), "node_modules", source.name) : scope === "project" ? (this.assertProjectTrustedForScope(scope), join(this.cwd, CONFIG_DIR_NAME, "npm", "node_modules", source.name)) : join(this.agentDir, "npm", "node_modules", source.name);
5639
5206
  }
5640
5207
  getLegacyGlobalNpmInstallPath(source) {
5641
5208
  try {
5642
- return this.getPnpmGlobalPackagePath(source.name) ?? join2(this.getGlobalNpmRoot(), source.name);
5209
+ return this.getPnpmGlobalPackagePath(source.name) ?? join(this.getGlobalNpmRoot(), source.name);
5643
5210
  } catch {
5644
5211
  return;
5645
5212
  }
5646
5213
  }
5647
5214
  getNpmInstallPath(source, scope) {
5648
5215
  let managedPath = this.getManagedNpmInstallPath(source, scope);
5649
- if (scope !== "user" || existsSync2(managedPath))
5216
+ if (scope !== "user" || existsSync(managedPath))
5650
5217
  return managedPath;
5651
5218
  let legacyPath = this.getLegacyGlobalNpmInstallPath(source);
5652
- return legacyPath && existsSync2(legacyPath) ? legacyPath : managedPath;
5219
+ return legacyPath && existsSync(legacyPath) ? legacyPath : managedPath;
5653
5220
  }
5654
5221
  getGitInstallPath(source, scope) {
5655
5222
  if (scope === "temporary")
@@ -5661,20 +5228,20 @@ var DefaultPackageManager = class {
5661
5228
  }
5662
5229
  getGitInstallRoot(scope) {
5663
5230
  if (scope !== "temporary")
5664
- return scope === "project" ? (this.assertProjectTrustedForScope(scope), join2(this.cwd, CONFIG_DIR_NAME, "git")) : join2(this.agentDir, "git");
5231
+ return scope === "project" ? (this.assertProjectTrustedForScope(scope), join(this.cwd, CONFIG_DIR_NAME, "git")) : join(this.agentDir, "git");
5665
5232
  }
5666
5233
  getTemporaryDir(prefix, suffix) {
5667
5234
  let root = this.resolveManagedPath(getExtensionTempFolder(this.agentDir), prefix), hash = createHash("sha256").update(`${prefix}-${suffix ?? ""}`).digest("hex").slice(0, 8);
5668
5235
  return this.resolveManagedPath(root, hash, suffix ?? "");
5669
5236
  }
5670
5237
  resolveManagedPath(root, ...parts) {
5671
- let resolvedRoot = resolve2(root), resolvedPath = resolve2(resolvedRoot, ...parts);
5238
+ let resolvedRoot = resolve(root), resolvedPath = resolve(resolvedRoot, ...parts);
5672
5239
  if (resolvedPath !== resolvedRoot && !resolvedPath.startsWith(`${resolvedRoot}${sep}`))
5673
5240
  throw new Error(`Refusing to use path outside package install root: ${resolvedPath}`);
5674
5241
  return resolvedPath;
5675
5242
  }
5676
5243
  getBaseDirForScope(scope) {
5677
- return scope === "project" ? (this.assertProjectTrustedForScope(scope), join2(this.cwd, CONFIG_DIR_NAME)) : scope === "user" ? this.agentDir : this.cwd;
5244
+ return scope === "project" ? (this.assertProjectTrustedForScope(scope), join(this.cwd, CONFIG_DIR_NAME)) : scope === "user" ? this.agentDir : this.cwd;
5678
5245
  }
5679
5246
  resolvePath(input) {
5680
5247
  return resolvePath(input, this.cwd, { homeDir: getHomeDir(), trim: !0 });
@@ -5700,8 +5267,8 @@ var DefaultPackageManager = class {
5700
5267
  }
5701
5268
  let hasAnyDir = !1;
5702
5269
  for (let resourceType of RESOURCE_TYPES) {
5703
- let dir = join2(packageRoot, resourceType);
5704
- if (existsSync2(dir)) {
5270
+ let dir = join(packageRoot, resourceType);
5271
+ if (existsSync(dir)) {
5705
5272
  let files = collectResourceFiles(dir, resourceType);
5706
5273
  for (let f of files)
5707
5274
  this.addResource(this.getTargetMap(accumulator, resourceType), f, metadata, !0);
@@ -5716,8 +5283,8 @@ var DefaultPackageManager = class {
5716
5283
  this.addManifestEntries(entries, packageRoot, resourceType, target, metadata);
5717
5284
  return;
5718
5285
  }
5719
- let dir = join2(packageRoot, resourceType);
5720
- if (existsSync2(dir)) {
5286
+ let dir = join(packageRoot, resourceType);
5287
+ if (existsSync(dir)) {
5721
5288
  let files = collectResourceFiles(dir, resourceType);
5722
5289
  for (let f of files)
5723
5290
  this.addResource(target, f, metadata, !0);
@@ -5754,18 +5321,18 @@ var DefaultPackageManager = class {
5754
5321
  let allFiles2 = this.collectFilesFromManifestEntries(entries, packageRoot, resourceType), manifestPatterns = entries.filter(isOverridePattern), enabledByManifest = manifestPatterns.length > 0 ? applyPatterns(allFiles2, manifestPatterns, packageRoot) : new Set(allFiles2);
5755
5322
  return { allFiles: Array.from(enabledByManifest), enabledByManifest };
5756
5323
  }
5757
- let conventionDir = join2(packageRoot, resourceType);
5758
- if (!existsSync2(conventionDir))
5324
+ let conventionDir = join(packageRoot, resourceType);
5325
+ if (!existsSync(conventionDir))
5759
5326
  return { allFiles: [], enabledByManifest: /* @__PURE__ */ new Set() };
5760
5327
  let allFiles = collectResourceFiles(conventionDir, resourceType);
5761
5328
  return { allFiles, enabledByManifest: new Set(allFiles) };
5762
5329
  }
5763
5330
  readPiManifest(packageRoot) {
5764
- let packageJsonPath = join2(packageRoot, "package.json");
5765
- if (!existsSync2(packageJsonPath))
5331
+ let packageJsonPath = join(packageRoot, "package.json");
5332
+ if (!existsSync(packageJsonPath))
5766
5333
  return null;
5767
5334
  try {
5768
- let content = readFileSync2(packageJsonPath, "utf-8");
5335
+ let content = readFileSync(packageJsonPath, "utf-8");
5769
5336
  return JSON.parse(content).pi ?? null;
5770
5337
  } catch {
5771
5338
  return null;
@@ -5784,7 +5351,7 @@ var DefaultPackageManager = class {
5784
5351
  absolute: !0,
5785
5352
  dot: !1,
5786
5353
  nodir: !1
5787
- }).map((match) => resolve2(match)) : [resolve2(root, entry)]);
5354
+ }).map((match) => resolve(match)) : [resolve(root, entry)]);
5788
5355
  return this.collectFilesFromPaths(resolved, resourceType);
5789
5356
  }
5790
5357
  resolveLocalEntries(entries, resourceType, target, metadata, baseDir) {
@@ -5816,32 +5383,32 @@ var DefaultPackageManager = class {
5816
5383
  prompts: projectSettings.prompts ?? [],
5817
5384
  themes: projectSettings.themes ?? []
5818
5385
  }, userDirs = {
5819
- extensions: join2(globalBaseDir, "extensions"),
5820
- skills: join2(globalBaseDir, "skills"),
5821
- prompts: join2(globalBaseDir, "prompts"),
5822
- themes: join2(globalBaseDir, "themes")
5386
+ extensions: join(globalBaseDir, "extensions"),
5387
+ skills: join(globalBaseDir, "skills"),
5388
+ prompts: join(globalBaseDir, "prompts"),
5389
+ themes: join(globalBaseDir, "themes")
5823
5390
  }, projectDirs = {
5824
- extensions: join2(projectBaseDir, "extensions"),
5825
- skills: join2(projectBaseDir, "skills"),
5826
- prompts: join2(projectBaseDir, "prompts"),
5827
- themes: join2(projectBaseDir, "themes")
5828
- }, userAgentsSkillsDir = join2(getHomeDir(), ".agents", "skills"), projectTrusted = this.settingsManager.isProjectTrusted(), projectAgentsSkillDirs = projectTrusted ? collectAncestorAgentsSkillDirs(this.cwd).filter((dir) => resolve2(dir) !== resolve2(userAgentsSkillsDir)) : [], addResources = (resourceType, paths, metadata, overrides, baseDir) => {
5391
+ extensions: join(projectBaseDir, "extensions"),
5392
+ skills: join(projectBaseDir, "skills"),
5393
+ prompts: join(projectBaseDir, "prompts"),
5394
+ themes: join(projectBaseDir, "themes")
5395
+ }, userAgentsSkillsDir = join(getHomeDir(), ".agents", "skills"), projectTrusted = this.settingsManager.isProjectTrusted(), projectAgentsSkillDirs = projectTrusted ? collectAncestorAgentsSkillDirs(this.cwd).filter((dir) => resolve(dir) !== resolve(userAgentsSkillsDir)) : [], addResources = (resourceType, paths, metadata, overrides, baseDir) => {
5829
5396
  let target = this.getTargetMap(accumulator, resourceType);
5830
- for (let path2 of paths) {
5831
- let enabled = isEnabledByOverrides(path2, overrides, baseDir);
5832
- this.addResource(target, path2, metadata, enabled);
5397
+ for (let path of paths) {
5398
+ let enabled = isEnabledByOverrides(path, overrides, baseDir);
5399
+ this.addResource(target, path, metadata, enabled);
5833
5400
  }
5834
5401
  };
5835
5402
  projectTrusted && (addResources("extensions", collectAutoExtensionEntries(projectDirs.extensions), projectMetadata, projectOverrides.extensions, projectBaseDir), addResources("skills", collectAutoSkillEntries(projectDirs.skills, "pi"), projectMetadata, projectOverrides.skills, projectBaseDir));
5836
5403
  for (let agentsSkillsDir of projectAgentsSkillDirs) {
5837
- let agentsBaseDir = dirname2(agentsSkillsDir), agentsMetadata = {
5404
+ let agentsBaseDir = dirname(agentsSkillsDir), agentsMetadata = {
5838
5405
  ...projectMetadata,
5839
5406
  baseDir: agentsBaseDir
5840
5407
  };
5841
5408
  addResources("skills", collectAutoSkillEntries(agentsSkillsDir, "agents"), agentsMetadata, projectOverrides.skills, agentsBaseDir);
5842
5409
  }
5843
5410
  projectTrusted && (addResources("prompts", collectAutoPromptEntries(projectDirs.prompts), projectMetadata, projectOverrides.prompts, projectBaseDir), addResources("themes", collectAutoThemeEntries(projectDirs.themes), projectMetadata, projectOverrides.themes, projectBaseDir)), addResources("extensions", collectAutoExtensionEntries(userDirs.extensions), userMetadata, userOverrides.extensions, globalBaseDir), addResources("skills", collectAutoSkillEntries(userDirs.skills, "pi"), userMetadata, userOverrides.skills, globalBaseDir);
5844
- let userAgentsBaseDir = dirname2(userAgentsSkillsDir), userAgentsMetadata = {
5411
+ let userAgentsBaseDir = dirname(userAgentsSkillsDir), userAgentsMetadata = {
5845
5412
  ...userMetadata,
5846
5413
  baseDir: userAgentsBaseDir
5847
5414
  };
@@ -5850,9 +5417,9 @@ var DefaultPackageManager = class {
5850
5417
  collectFilesFromPaths(paths, resourceType) {
5851
5418
  let files = [];
5852
5419
  for (let p of paths)
5853
- if (existsSync2(p))
5420
+ if (existsSync(p))
5854
5421
  try {
5855
- let stats = statSync2(p);
5422
+ let stats = statSync(p);
5856
5423
  stats.isFile() ? files.push(p) : stats.isDirectory() && files.push(...collectResourceFiles(p, resourceType));
5857
5424
  } catch {
5858
5425
  }
@@ -5872,8 +5439,8 @@ var DefaultPackageManager = class {
5872
5439
  throw new Error(`Unknown resource type: ${resourceType}`);
5873
5440
  }
5874
5441
  }
5875
- addResource(map, path2, metadata, enabled) {
5876
- path2 && (map.has(path2) || map.set(path2, { metadata, enabled }));
5442
+ addResource(map, path, metadata, enabled) {
5443
+ path && (map.has(path) || map.set(path, { metadata, enabled }));
5877
5444
  }
5878
5445
  createAccumulator() {
5879
5446
  return {
@@ -5885,8 +5452,8 @@ var DefaultPackageManager = class {
5885
5452
  }
5886
5453
  toResolvedPaths(accumulator) {
5887
5454
  let mapToResolved = (entries) => {
5888
- let resolved = Array.from(entries.entries()).map(([path2, { metadata, enabled }]) => ({
5889
- path: path2,
5455
+ let resolved = Array.from(entries.entries()).map(([path, { metadata, enabled }]) => ({
5456
+ path,
5890
5457
  enabled,
5891
5458
  metadata
5892
5459
  }));
@@ -5976,1583 +5543,8 @@ var DefaultPackageManager = class {
5976
5543
  }
5977
5544
  };
5978
5545
 
5979
- // packages/coding-agent/dist/core/skills.js
5980
- var import_ignore2 = __toESM(require_ignore(), 1);
5981
- import { existsSync as existsSync3, readdirSync as readdirSync3, readFileSync as readFileSync3, statSync as statSync3 } from "fs";
5982
- import { basename as basename2, dirname as dirname3, join as join3, relative as relative2, resolve as resolve3, sep as sep2 } from "path";
5983
- var MAX_NAME_LENGTH = 64, MAX_DESCRIPTION_LENGTH = 1024, IGNORE_FILE_NAMES2 = [".gitignore", ".ignore", ".fdignore"];
5984
- function toPosixPath2(p) {
5985
- return p.split(sep2).join("/");
5986
- }
5987
- function prefixIgnorePattern2(line, prefix) {
5988
- let trimmed = line.trim();
5989
- if (!trimmed || trimmed.startsWith("#") && !trimmed.startsWith("\\#"))
5990
- return null;
5991
- let pattern = line, negated = !1;
5992
- pattern.startsWith("!") ? (negated = !0, pattern = pattern.slice(1)) : pattern.startsWith("\\!") && (pattern = pattern.slice(1)), pattern.startsWith("/") && (pattern = pattern.slice(1));
5993
- let prefixed = prefix ? `${prefix}${pattern}` : pattern;
5994
- return negated ? `!${prefixed}` : prefixed;
5995
- }
5996
- function addIgnoreRules2(ig, dir, rootDir) {
5997
- let relativeDir = relative2(rootDir, dir), prefix = relativeDir ? `${toPosixPath2(relativeDir)}/` : "";
5998
- for (let filename of IGNORE_FILE_NAMES2) {
5999
- let ignorePath = join3(dir, filename);
6000
- if (existsSync3(ignorePath))
6001
- try {
6002
- let patterns = readFileSync3(ignorePath, "utf-8").split(/\r?\n/).map((line) => prefixIgnorePattern2(line, prefix)).filter((line) => !!line);
6003
- patterns.length > 0 && ig.add(patterns);
6004
- } catch {
6005
- }
6006
- }
6007
- }
6008
- function validateName(name) {
6009
- let errors = [];
6010
- return name.length > MAX_NAME_LENGTH && errors.push(`name exceeds ${MAX_NAME_LENGTH} characters (${name.length})`), /^[a-z0-9-]+$/.test(name) || errors.push("name contains invalid characters (must be lowercase a-z, 0-9, hyphens only)"), (name.startsWith("-") || name.endsWith("-")) && errors.push("name must not start or end with a hyphen"), name.includes("--") && errors.push("name must not contain consecutive hyphens"), errors;
6011
- }
6012
- function validateDescription(description) {
6013
- let errors = [];
6014
- return !description || description.trim() === "" ? errors.push("description is required") : description.length > MAX_DESCRIPTION_LENGTH && errors.push(`description exceeds ${MAX_DESCRIPTION_LENGTH} characters (${description.length})`), errors;
6015
- }
6016
- function createSkillSourceInfo(filePath, baseDir, source) {
6017
- switch (source) {
6018
- case "user":
6019
- return createSyntheticSourceInfo(filePath, {
6020
- source: "local",
6021
- scope: "user",
6022
- baseDir
6023
- });
6024
- case "project":
6025
- return createSyntheticSourceInfo(filePath, {
6026
- source: "local",
6027
- scope: "project",
6028
- baseDir
6029
- });
6030
- case "path":
6031
- return createSyntheticSourceInfo(filePath, {
6032
- source: "local",
6033
- baseDir
6034
- });
6035
- default:
6036
- return createSyntheticSourceInfo(filePath, { source, baseDir });
6037
- }
6038
- }
6039
- function loadSkillsFromDir(options) {
6040
- let { dir, source } = options;
6041
- return loadSkillsFromDirInternal(dir, source, !0);
6042
- }
6043
- function loadSkillsFromDirInternal(dir, source, includeRootFiles, ignoreMatcher, rootDir) {
6044
- let skills = [], diagnostics = [];
6045
- if (!existsSync3(dir))
6046
- return { skills, diagnostics };
6047
- let root = rootDir ?? dir, ig = ignoreMatcher ?? (0, import_ignore2.default)();
6048
- addIgnoreRules2(ig, dir, root);
6049
- try {
6050
- let entries = readdirSync3(dir, { withFileTypes: !0 });
6051
- for (let entry of entries) {
6052
- if (entry.name !== "SKILL.md")
6053
- continue;
6054
- let fullPath = join3(dir, entry.name), isFile = entry.isFile();
6055
- if (entry.isSymbolicLink())
6056
- try {
6057
- isFile = statSync3(fullPath).isFile();
6058
- } catch {
6059
- continue;
6060
- }
6061
- let relPath = toPosixPath2(relative2(root, fullPath));
6062
- if (!isFile || ig.ignores(relPath))
6063
- continue;
6064
- let result = loadSkillFromFile(fullPath, source);
6065
- return result.skill && skills.push(result.skill), diagnostics.push(...result.diagnostics), { skills, diagnostics };
6066
- }
6067
- for (let entry of entries) {
6068
- if (entry.name.startsWith(".") || entry.name === "node_modules")
6069
- continue;
6070
- let fullPath = join3(dir, entry.name), isDirectory = entry.isDirectory(), isFile = entry.isFile();
6071
- if (entry.isSymbolicLink())
6072
- try {
6073
- let stats = statSync3(fullPath);
6074
- isDirectory = stats.isDirectory(), isFile = stats.isFile();
6075
- } catch {
6076
- continue;
6077
- }
6078
- let relPath = toPosixPath2(relative2(root, fullPath)), ignorePath = isDirectory ? `${relPath}/` : relPath;
6079
- if (ig.ignores(ignorePath))
6080
- continue;
6081
- if (isDirectory) {
6082
- let subResult = loadSkillsFromDirInternal(fullPath, source, !1, ig, root);
6083
- skills.push(...subResult.skills), diagnostics.push(...subResult.diagnostics);
6084
- continue;
6085
- }
6086
- if (!isFile || !includeRootFiles || !entry.name.endsWith(".md"))
6087
- continue;
6088
- let result = loadSkillFromFile(fullPath, source);
6089
- result.skill && skills.push(result.skill), diagnostics.push(...result.diagnostics);
6090
- }
6091
- } catch {
6092
- }
6093
- return { skills, diagnostics };
6094
- }
6095
- function loadSkillFromFile(filePath, source) {
6096
- let diagnostics = [];
6097
- try {
6098
- let rawContent = readFileSync3(filePath, "utf-8"), { frontmatter } = parseFrontmatter(rawContent), skillDir = dirname3(filePath), parentDirName = basename2(skillDir), descErrors = validateDescription(frontmatter.description);
6099
- for (let error of descErrors)
6100
- diagnostics.push({ type: "warning", message: error, path: filePath });
6101
- let name = frontmatter.name || parentDirName, nameErrors = validateName(name);
6102
- for (let error of nameErrors)
6103
- diagnostics.push({ type: "warning", message: error, path: filePath });
6104
- return !frontmatter.description || frontmatter.description.trim() === "" ? { skill: null, diagnostics } : {
6105
- skill: {
6106
- name,
6107
- description: frontmatter.description,
6108
- filePath,
6109
- baseDir: skillDir,
6110
- sourceInfo: createSkillSourceInfo(filePath, skillDir, source),
6111
- disableModelInvocation: frontmatter["disable-model-invocation"] === !0
6112
- },
6113
- diagnostics
6114
- };
6115
- } catch (error) {
6116
- let message = error instanceof Error ? error.message : "failed to parse skill file";
6117
- return diagnostics.push({ type: "warning", message, path: filePath }), { skill: null, diagnostics };
6118
- }
6119
- }
6120
- function formatSkillsForPrompt(skills) {
6121
- let visibleSkills = skills.filter((s) => !s.disableModelInvocation);
6122
- if (visibleSkills.length === 0)
6123
- return "";
6124
- let lines = [
6125
- `
6126
-
6127
- The following skills provide specialized instructions for specific tasks.`,
6128
- "Use the read tool to load a skill's file when the task matches its description.",
6129
- "When a skill file references a relative path, resolve it against the skill directory (parent of SKILL.md / dirname of the path) and use that absolute path in tool commands.",
6130
- "",
6131
- "<available_skills>"
6132
- ];
6133
- for (let skill of visibleSkills)
6134
- lines.push(" <skill>"), lines.push(` <name>${escapeXml(skill.name)}</name>`), lines.push(` <description>${escapeXml(skill.description)}</description>`), lines.push(` <location>${escapeXml(skill.filePath)}</location>`), lines.push(" </skill>");
6135
- return lines.push("</available_skills>"), lines.join(`
6136
- `);
6137
- }
6138
- function escapeXml(str) {
6139
- return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
6140
- }
6141
- function loadSkills(options) {
6142
- let { agentDir, skillPaths, includeDefaults } = options, resolvedCwd = resolvePath(options.cwd), resolvedAgentDir = resolvePath(agentDir ?? getAgentDir()), skillMap = /* @__PURE__ */ new Map(), realPathSet = /* @__PURE__ */ new Set(), allDiagnostics = [], collisionDiagnostics = [];
6143
- function addSkills(result) {
6144
- allDiagnostics.push(...result.diagnostics);
6145
- for (let skill of result.skills) {
6146
- let realPath = canonicalizePath(skill.filePath);
6147
- if (realPathSet.has(realPath))
6148
- continue;
6149
- let existing = skillMap.get(skill.name);
6150
- existing ? collisionDiagnostics.push({
6151
- type: "collision",
6152
- message: `name "${skill.name}" collision`,
6153
- path: skill.filePath,
6154
- collision: {
6155
- resourceType: "skill",
6156
- name: skill.name,
6157
- winnerPath: existing.filePath,
6158
- loserPath: skill.filePath
6159
- }
6160
- }) : (skillMap.set(skill.name, skill), realPathSet.add(realPath));
6161
- }
6162
- }
6163
- includeDefaults && (addSkills(loadSkillsFromDirInternal(join3(resolvedAgentDir, "skills"), "user", !0)), addSkills(loadSkillsFromDirInternal(resolve3(resolvedCwd, CONFIG_DIR_NAME, "skills"), "project", !0)));
6164
- let userSkillsDir = join3(resolvedAgentDir, "skills"), projectSkillsDir = resolve3(resolvedCwd, CONFIG_DIR_NAME, "skills"), isUnderPath = (target, root) => {
6165
- let normalizedRoot = resolve3(root);
6166
- if (target === normalizedRoot)
6167
- return !0;
6168
- let prefix = normalizedRoot.endsWith(sep2) ? normalizedRoot : `${normalizedRoot}${sep2}`;
6169
- return target.startsWith(prefix);
6170
- }, getSource = (resolvedPath) => {
6171
- if (!includeDefaults) {
6172
- if (isUnderPath(resolvedPath, userSkillsDir))
6173
- return "user";
6174
- if (isUnderPath(resolvedPath, projectSkillsDir))
6175
- return "project";
6176
- }
6177
- return "path";
6178
- };
6179
- for (let rawPath of skillPaths) {
6180
- let resolvedPath = resolvePath(rawPath, resolvedCwd, { trim: !0 });
6181
- if (!existsSync3(resolvedPath)) {
6182
- allDiagnostics.push({ type: "warning", message: "skill path does not exist", path: resolvedPath });
6183
- continue;
6184
- }
6185
- try {
6186
- let stats = statSync3(resolvedPath), source = getSource(resolvedPath);
6187
- if (stats.isDirectory())
6188
- addSkills(loadSkillsFromDirInternal(resolvedPath, source, !0));
6189
- else if (stats.isFile() && resolvedPath.endsWith(".md")) {
6190
- let result = loadSkillFromFile(resolvedPath, source);
6191
- result.skill ? addSkills({ skills: [result.skill], diagnostics: result.diagnostics }) : allDiagnostics.push(...result.diagnostics);
6192
- } else
6193
- allDiagnostics.push({ type: "warning", message: "skill path is not a markdown file", path: resolvedPath });
6194
- } catch (error) {
6195
- let message = error instanceof Error ? error.message : "failed to read skill path";
6196
- allDiagnostics.push({ type: "warning", message, path: resolvedPath });
6197
- }
6198
- }
6199
- return {
6200
- skills: Array.from(skillMap.values()),
6201
- diagnostics: [...allDiagnostics, ...collisionDiagnostics]
6202
- };
6203
- }
6204
-
6205
- // packages/coding-agent/dist/core/resource-loader.js
6206
- import { existsSync as existsSync5, readdirSync as readdirSync5, readFileSync as readFileSync5, statSync as statSync5 } from "node:fs";
6207
- import { dirname as dirname5, join as join5, resolve as resolve5, sep as sep4 } from "node:path";
6208
- import chalk from "chalk";
6209
-
6210
- // packages/coding-agent/dist/core/prompt-templates.js
6211
- import { existsSync as existsSync4, readdirSync as readdirSync4, readFileSync as readFileSync4, statSync as statSync4 } from "fs";
6212
- import { basename as basename3, dirname as dirname4, join as join4, resolve as resolve4, sep as sep3 } from "path";
6213
- function parseCommandArgs(argsString) {
6214
- let args = [], current = "", inQuote = null;
6215
- for (let i = 0; i < argsString.length; i++) {
6216
- let char = argsString[i];
6217
- inQuote ? char === inQuote ? inQuote = null : current += char : char === '"' || char === "'" ? inQuote = char : /\s/.test(char) ? current && (args.push(current), current = "") : current += char;
6218
- }
6219
- return current && args.push(current), args;
6220
- }
6221
- function substituteArgs(content, args) {
6222
- let allArgs = args.join(" ");
6223
- return content.replace(/\$\{(\d+):-([^}]*)\}|\$\{@:(\d+)(?::(\d+))?\}|\$(ARGUMENTS|@|\d+)/g, (_match, defaultNum, defaultValue, sliceStart, sliceLength, simple) => {
6224
- if (defaultNum) {
6225
- let index2 = parseInt(defaultNum, 10) - 1, value = args[index2];
6226
- return value || defaultValue;
6227
- }
6228
- if (sliceStart) {
6229
- let start = parseInt(sliceStart, 10) - 1;
6230
- if (start < 0 && (start = 0), sliceLength) {
6231
- let length = parseInt(sliceLength, 10);
6232
- return args.slice(start, start + length).join(" ");
6233
- }
6234
- return args.slice(start).join(" ");
6235
- }
6236
- if (simple === "ARGUMENTS" || simple === "@")
6237
- return allArgs;
6238
- let index = parseInt(simple, 10) - 1;
6239
- return args[index] ?? "";
6240
- });
6241
- }
6242
- function loadTemplateFromFile(filePath, sourceInfo) {
6243
- try {
6244
- let rawContent = readFileSync4(filePath, "utf-8"), { frontmatter, body } = parseFrontmatter(rawContent), name = basename3(filePath).replace(/\.md$/, ""), description = frontmatter.description || "";
6245
- if (!description) {
6246
- let firstLine = body.split(`
6247
- `).find((line) => line.trim());
6248
- firstLine && (description = firstLine.slice(0, 60), firstLine.length > 60 && (description += "..."));
6249
- }
6250
- return {
6251
- name,
6252
- description,
6253
- ...frontmatter["argument-hint"] && { argumentHint: frontmatter["argument-hint"] },
6254
- content: body,
6255
- sourceInfo,
6256
- filePath
6257
- };
6258
- } catch {
6259
- return null;
6260
- }
6261
- }
6262
- function loadTemplatesFromDir(dir, getSourceInfo) {
6263
- let templates = [];
6264
- if (!existsSync4(dir))
6265
- return templates;
6266
- try {
6267
- let entries = readdirSync4(dir, { withFileTypes: !0 });
6268
- for (let entry of entries) {
6269
- let fullPath = join4(dir, entry.name), isFile = entry.isFile();
6270
- if (entry.isSymbolicLink())
6271
- try {
6272
- isFile = statSync4(fullPath).isFile();
6273
- } catch {
6274
- continue;
6275
- }
6276
- if (isFile && entry.name.endsWith(".md")) {
6277
- let template = loadTemplateFromFile(fullPath, getSourceInfo(fullPath));
6278
- template && templates.push(template);
6279
- }
6280
- }
6281
- } catch {
6282
- return templates;
6283
- }
6284
- return templates;
6285
- }
6286
- function loadPromptTemplates(options) {
6287
- let resolvedCwd = resolvePath(options.cwd), resolvedAgentDir = resolvePath(options.agentDir), promptPaths = options.promptPaths, includeDefaults = options.includeDefaults, templates = [], globalPromptsDir = join4(resolvedAgentDir, "prompts"), projectPromptsDir = resolve4(resolvedCwd, CONFIG_DIR_NAME, "prompts"), isUnderPath = (target, root) => {
6288
- let normalizedRoot = resolve4(root);
6289
- if (target === normalizedRoot)
6290
- return !0;
6291
- let prefix = normalizedRoot.endsWith(sep3) ? normalizedRoot : `${normalizedRoot}${sep3}`;
6292
- return target.startsWith(prefix);
6293
- }, getSourceInfo = (resolvedPath) => isUnderPath(resolvedPath, globalPromptsDir) ? createSyntheticSourceInfo(resolvedPath, {
6294
- source: "local",
6295
- scope: "user",
6296
- baseDir: globalPromptsDir
6297
- }) : isUnderPath(resolvedPath, projectPromptsDir) ? createSyntheticSourceInfo(resolvedPath, {
6298
- source: "local",
6299
- scope: "project",
6300
- baseDir: projectPromptsDir
6301
- }) : createSyntheticSourceInfo(resolvedPath, {
6302
- source: "local",
6303
- baseDir: statSync4(resolvedPath).isDirectory() ? resolvedPath : dirname4(resolvedPath)
6304
- });
6305
- includeDefaults && (templates.push(...loadTemplatesFromDir(globalPromptsDir, getSourceInfo)), templates.push(...loadTemplatesFromDir(projectPromptsDir, getSourceInfo)));
6306
- for (let rawPath of promptPaths) {
6307
- let resolvedPath = resolvePath(rawPath, resolvedCwd, { trim: !0 });
6308
- if (existsSync4(resolvedPath))
6309
- try {
6310
- let stats = statSync4(resolvedPath);
6311
- if (stats.isDirectory())
6312
- templates.push(...loadTemplatesFromDir(resolvedPath, getSourceInfo));
6313
- else if (stats.isFile() && resolvedPath.endsWith(".md")) {
6314
- let template = loadTemplateFromFile(resolvedPath, getSourceInfo(resolvedPath));
6315
- template && templates.push(template);
6316
- }
6317
- } catch {
6318
- }
6319
- }
6320
- return templates;
6321
- }
6322
- function expandPromptTemplate(text, templates) {
6323
- if (!text.startsWith("/"))
6324
- return text;
6325
- let match = text.match(/^\/([^\s]+)(?:\s+([\s\S]*))?$/);
6326
- if (!match)
6327
- return text;
6328
- let templateName = match[1], argsString = match[2] ?? "", template = templates.find((t) => t.name === templateName);
6329
- if (template) {
6330
- let args = parseCommandArgs(argsString);
6331
- return substituteArgs(template.content, args);
6332
- }
6333
- return text;
6334
- }
6335
-
6336
- // packages/coding-agent/dist/core/resource-loader.js
6337
- function inlineExtensionPath(input, index) {
6338
- return `<inline:${typeof input != "function" ? input.name : index + 1}>`;
6339
- }
6340
- function resolvePromptInput(input, description) {
6341
- if (input) {
6342
- if (existsSync5(input))
6343
- try {
6344
- return readFileSync5(input, "utf-8");
6345
- } catch (error) {
6346
- return console.error(chalk.yellow(`Warning: Could not read ${description} file ${input}: ${error}`)), input;
6347
- }
6348
- return input;
6349
- }
6350
- }
6351
- function loadContextFileFromDir(dir) {
6352
- let candidates = ["AGENTS.md", "AGENTS.MD", "CLAUDE.md", "CLAUDE.MD"];
6353
- for (let filename of candidates) {
6354
- let filePath = join5(dir, filename);
6355
- if (existsSync5(filePath))
6356
- try {
6357
- return {
6358
- path: filePath,
6359
- content: readFileSync5(filePath, "utf-8")
6360
- };
6361
- } catch (error) {
6362
- console.error(chalk.yellow(`Warning: Could not read ${filePath}: ${error}`));
6363
- }
6364
- }
6365
- return null;
6366
- }
6367
- function loadProjectContextFiles(options) {
6368
- let resolvedCwd = resolvePath(options.cwd), resolvedAgentDir = resolvePath(options.agentDir), contextFiles = [], seenPaths = /* @__PURE__ */ new Set(), userContexts = options.settingsManager ? loadSelectedUserInstructions({ agentDir: resolvedAgentDir, settingsManager: options.settingsManager }) : [getGlobalInstructionsPath(resolvedAgentDir)].map((path2) => loadContextFileFromDir(dirname5(path2))).filter((file) => file !== null);
6369
- for (let userContext of userContexts)
6370
- contextFiles.push(userContext), seenPaths.add(userContext.path);
6371
- let ancestorContextFiles = [], currentDir = resolvedCwd;
6372
- for (; ; ) {
6373
- let contextFile = loadContextFileFromDir(currentDir);
6374
- contextFile && !seenPaths.has(contextFile.path) && (ancestorContextFiles.unshift(contextFile), seenPaths.add(contextFile.path));
6375
- let parentDir = dirname5(currentDir);
6376
- if (parentDir === currentDir)
6377
- break;
6378
- currentDir = parentDir;
6379
- }
6380
- return contextFiles.push(...ancestorContextFiles), contextFiles;
6381
- }
6382
- var DefaultResourceLoader = class {
6383
- cwd;
6384
- agentDir;
6385
- settingsManager;
6386
- eventBus;
6387
- packageManager;
6388
- additionalExtensionPaths;
6389
- additionalSkillPaths;
6390
- additionalPromptTemplatePaths;
6391
- additionalThemePaths;
6392
- extensionFactories;
6393
- noExtensions;
6394
- noSkills;
6395
- noPromptTemplates;
6396
- noThemes;
6397
- noContextFiles;
6398
- systemPromptSource;
6399
- appendSystemPromptSource;
6400
- extensionsOverride;
6401
- skillsOverride;
6402
- promptsOverride;
6403
- themesOverride;
6404
- agentsFilesOverride;
6405
- systemPromptOverride;
6406
- appendSystemPromptOverride;
6407
- extensionsResult;
6408
- skills;
6409
- skillDiagnostics;
6410
- prompts;
6411
- promptDiagnostics;
6412
- themes;
6413
- themeDiagnostics;
6414
- agentsFiles;
6415
- systemPrompt;
6416
- appendSystemPrompt;
6417
- lastSkillPaths;
6418
- extensionSkillSourceInfos;
6419
- extensionPromptSourceInfos;
6420
- extensionThemeSourceInfos;
6421
- lastPromptPaths;
6422
- lastThemePaths;
6423
- loaded;
6424
- constructor(options) {
6425
- this.cwd = resolvePath(options.cwd), this.agentDir = resolvePath(options.agentDir), this.settingsManager = options.settingsManager ?? SettingsManager.create(this.cwd, this.agentDir), this.eventBus = options.eventBus ?? createEventBus(), this.packageManager = new DefaultPackageManager({
6426
- cwd: this.cwd,
6427
- agentDir: this.agentDir,
6428
- settingsManager: this.settingsManager
6429
- }), this.additionalExtensionPaths = options.additionalExtensionPaths ?? [], this.additionalSkillPaths = options.additionalSkillPaths ?? [], this.additionalPromptTemplatePaths = options.additionalPromptTemplatePaths ?? [], this.additionalThemePaths = options.additionalThemePaths ?? [], this.extensionFactories = options.extensionFactories ?? [], this.noExtensions = options.noExtensions ?? !1, this.noSkills = options.noSkills ?? !1, this.noPromptTemplates = options.noPromptTemplates ?? !1, this.noThemes = options.noThemes ?? !1, this.noContextFiles = options.noContextFiles ?? !1, this.systemPromptSource = options.systemPrompt, this.appendSystemPromptSource = options.appendSystemPrompt, this.extensionsOverride = options.extensionsOverride, this.skillsOverride = options.skillsOverride, this.promptsOverride = options.promptsOverride, this.themesOverride = options.themesOverride, this.agentsFilesOverride = options.agentsFilesOverride, this.systemPromptOverride = options.systemPromptOverride, this.appendSystemPromptOverride = options.appendSystemPromptOverride, this.extensionsResult = { extensions: [], errors: [], runtime: createExtensionRuntime() }, this.skills = [], this.skillDiagnostics = [], this.prompts = [], this.promptDiagnostics = [], this.themes = [], this.themeDiagnostics = [], this.agentsFiles = [], this.appendSystemPrompt = [], this.lastSkillPaths = [], this.extensionSkillSourceInfos = /* @__PURE__ */ new Map(), this.extensionPromptSourceInfos = /* @__PURE__ */ new Map(), this.extensionThemeSourceInfos = /* @__PURE__ */ new Map(), this.lastPromptPaths = [], this.lastThemePaths = [], this.loaded = !1;
6430
- }
6431
- getExtensions() {
6432
- return this.extensionsResult;
6433
- }
6434
- getSkills() {
6435
- return { skills: this.skills, diagnostics: this.skillDiagnostics };
6436
- }
6437
- getPrompts() {
6438
- return { prompts: this.prompts, diagnostics: this.promptDiagnostics };
6439
- }
6440
- getThemes() {
6441
- return { themes: this.themes, diagnostics: this.themeDiagnostics };
6442
- }
6443
- getAgentsFiles() {
6444
- return { agentsFiles: this.agentsFiles };
6445
- }
6446
- contextFilesEnabled() {
6447
- return !this.noContextFiles;
6448
- }
6449
- getSystemPrompt() {
6450
- return this.systemPrompt;
6451
- }
6452
- getAppendSystemPrompt() {
6453
- return this.appendSystemPrompt;
6454
- }
6455
- async attachInlineExtensions(factories) {
6456
- let loaded = new Set(this.extensionsResult.extensions.map((extension) => extension.path)), pending = factories.filter((factory, index) => {
6457
- let path2 = inlineExtensionPath(factory, this.extensionFactories.length + index);
6458
- return !loaded.has(path2);
6459
- });
6460
- if (pending.length === 0)
6461
- return { extensions: [], errors: [], runtime: this.extensionsResult.runtime };
6462
- let attached = await this.loadExtensionFactories(this.extensionsResult.runtime, pending);
6463
- return this.extensionFactories.push(...pending), this.extensionsResult.extensions.push(...attached.extensions), this.extensionsResult.errors.push(...attached.errors), this.addExtensionConflictDiagnostics(this.extensionsResult), {
6464
- extensions: attached.extensions,
6465
- errors: attached.errors,
6466
- runtime: this.extensionsResult.runtime
6467
- };
6468
- }
6469
- extendResources(paths) {
6470
- let skillPaths = this.normalizeExtensionPaths(paths.skillPaths ?? []), promptPaths = this.normalizeExtensionPaths(paths.promptPaths ?? []), themePaths = this.normalizeExtensionPaths(paths.themePaths ?? []);
6471
- for (let entry of skillPaths)
6472
- this.extensionSkillSourceInfos.set(entry.path, createSourceInfo(entry.path, entry.metadata));
6473
- for (let entry of promptPaths)
6474
- this.extensionPromptSourceInfos.set(entry.path, createSourceInfo(entry.path, entry.metadata));
6475
- for (let entry of themePaths)
6476
- this.extensionThemeSourceInfos.set(entry.path, createSourceInfo(entry.path, entry.metadata));
6477
- skillPaths.length > 0 && (this.lastSkillPaths = this.mergePaths(this.lastSkillPaths, skillPaths.map((entry) => entry.path)), this.updateSkillsFromPaths(this.lastSkillPaths)), promptPaths.length > 0 && (this.lastPromptPaths = this.mergePaths(this.lastPromptPaths, promptPaths.map((entry) => entry.path)), this.updatePromptsFromPaths(this.lastPromptPaths)), themePaths.length > 0 && (this.lastThemePaths = this.mergePaths(this.lastThemePaths, themePaths.map((entry) => entry.path)), this.updateThemesFromPaths(this.lastThemePaths));
6478
- }
6479
- resolveOnMissing(skipMissingPackageInstall) {
6480
- if (skipMissingPackageInstall)
6481
- return async () => "skip";
6482
- }
6483
- async loadProjectTrustExtensions(options) {
6484
- return this.settingsManager.setProjectTrusted(!1), await this.settingsManager.reload(), this.loadCurrentExtensionSet({
6485
- includeInlineFactories: !0,
6486
- skipMissingPackageInstall: options?.skipMissingPackageInstall
6487
- });
6488
- }
6489
- async reload(options) {
6490
- resetTimings("extensions"), this.loaded && clearExtensionCache();
6491
- let preTrustExtensions;
6492
- if (options?.resolveProjectTrust) {
6493
- preTrustExtensions = await this.loadProjectTrustExtensions(options);
6494
- let projectTrusted = await options.resolveProjectTrust({ extensionsResult: preTrustExtensions });
6495
- this.settingsManager.setProjectTrusted(projectTrusted);
6496
- }
6497
- await this.settingsManager.reload();
6498
- let resolvedPaths = await this.packageManager.resolve(this.resolveOnMissing(options?.skipMissingPackageInstall)), cliExtensionPaths = await this.packageManager.resolveExtensionSources(this.additionalExtensionPaths, {
6499
- temporary: !0
6500
- }), metadataByPath = /* @__PURE__ */ new Map();
6501
- this.extensionSkillSourceInfos = /* @__PURE__ */ new Map(), this.extensionPromptSourceInfos = /* @__PURE__ */ new Map(), this.extensionThemeSourceInfos = /* @__PURE__ */ new Map();
6502
- let getEnabledResources = (resources) => {
6503
- for (let r of resources)
6504
- metadataByPath.has(r.path) || metadataByPath.set(r.path, r.metadata);
6505
- return resources.filter((r) => r.enabled);
6506
- }, getEnabledPaths = (resources) => getEnabledResources(resources).map((r) => r.path), enabledExtensions = getEnabledPaths(resolvedPaths.extensions), enabledSkillResources = getEnabledResources(resolvedPaths.skills), enabledPrompts = getEnabledPaths(resolvedPaths.prompts), enabledThemes = getEnabledPaths(resolvedPaths.themes), enabledSkills = enabledSkillResources.map((resource) => this.mapSkillPath(resource, metadataByPath));
6507
- for (let r of cliExtensionPaths.extensions)
6508
- metadataByPath.has(r.path) || metadataByPath.set(r.path, { source: "cli", scope: "temporary", origin: "top-level" });
6509
- for (let r of cliExtensionPaths.skills)
6510
- metadataByPath.has(r.path) || metadataByPath.set(r.path, { source: "cli", scope: "temporary", origin: "top-level" });
6511
- let cliEnabledExtensions = getEnabledPaths(cliExtensionPaths.extensions), cliEnabledSkills = getEnabledPaths(cliExtensionPaths.skills), cliEnabledPrompts = getEnabledPaths(cliExtensionPaths.prompts), cliEnabledThemes = getEnabledPaths(cliExtensionPaths.themes), extensionPaths = this.noExtensions ? cliEnabledExtensions : this.mergePaths(cliEnabledExtensions, enabledExtensions), extensionsResult = await this.loadFinalExtensionSet(extensionPaths, preTrustExtensions);
6512
- for (let p of this.additionalExtensionPaths)
6513
- if (isLocalPath(p)) {
6514
- let resolved = this.resolveResourcePath(p);
6515
- existsSync5(resolved) || extensionsResult.errors.push({ path: resolved, error: `Extension path does not exist: ${resolved}` });
6516
- }
6517
- this.extensionsResult = this.extensionsOverride ? this.extensionsOverride(extensionsResult) : extensionsResult, this.applyExtensionSourceInfo(this.extensionsResult.extensions, metadataByPath);
6518
- let skillPaths = this.noSkills ? this.mergePaths(cliEnabledSkills, this.additionalSkillPaths) : this.mergePaths([...cliEnabledSkills, ...enabledSkills], this.additionalSkillPaths);
6519
- this.lastSkillPaths = skillPaths, this.updateSkillsFromPaths(skillPaths, metadataByPath);
6520
- for (let p of this.additionalSkillPaths)
6521
- if (isLocalPath(p)) {
6522
- let resolved = this.resolveResourcePath(p);
6523
- !existsSync5(resolved) && !this.skillDiagnostics.some((d) => d.path === resolved) && this.skillDiagnostics.push({ type: "error", message: "Skill path does not exist", path: resolved });
6524
- }
6525
- let promptPaths = this.noPromptTemplates ? this.mergePaths(cliEnabledPrompts, this.additionalPromptTemplatePaths) : this.mergePaths([...cliEnabledPrompts, ...enabledPrompts], this.additionalPromptTemplatePaths);
6526
- this.lastPromptPaths = promptPaths, this.updatePromptsFromPaths(promptPaths, metadataByPath);
6527
- for (let p of this.additionalPromptTemplatePaths)
6528
- if (isLocalPath(p)) {
6529
- let resolved = this.resolveResourcePath(p);
6530
- !existsSync5(resolved) && !this.promptDiagnostics.some((d) => d.path === resolved) && this.promptDiagnostics.push({
6531
- type: "error",
6532
- message: "Prompt template path does not exist",
6533
- path: resolved
6534
- });
6535
- }
6536
- let themePaths = this.noThemes ? this.mergePaths(cliEnabledThemes, this.additionalThemePaths) : this.mergePaths([...cliEnabledThemes, ...enabledThemes], this.additionalThemePaths);
6537
- this.lastThemePaths = themePaths, this.updateThemesFromPaths(themePaths, metadataByPath);
6538
- for (let p of this.additionalThemePaths) {
6539
- let resolved = this.resolveResourcePath(p);
6540
- !existsSync5(resolved) && !this.themeDiagnostics.some((d) => d.path === resolved) && this.themeDiagnostics.push({ type: "error", message: "Theme path does not exist", path: resolved });
6541
- }
6542
- let agentsFiles = {
6543
- agentsFiles: this.noContextFiles ? [] : loadProjectContextFiles({
6544
- cwd: this.cwd,
6545
- agentDir: this.agentDir,
6546
- settingsManager: this.settingsManager
6547
- })
6548
- }, resolvedAgentsFiles = this.agentsFilesOverride ? this.agentsFilesOverride(agentsFiles) : agentsFiles;
6549
- this.agentsFiles = resolvedAgentsFiles.agentsFiles;
6550
- let baseSystemPrompt = resolvePromptInput(this.systemPromptSource ?? this.discoverSystemPromptFile(), "system prompt");
6551
- this.systemPrompt = this.systemPromptOverride ? this.systemPromptOverride(baseSystemPrompt) : baseSystemPrompt;
6552
- let baseAppend = (this.appendSystemPromptSource ?? (this.discoverAppendSystemPromptFile() ? [this.discoverAppendSystemPromptFile()] : [])).map((s) => resolvePromptInput(s, "append system prompt")).filter((s) => s !== void 0);
6553
- this.appendSystemPrompt = this.appendSystemPromptOverride ? this.appendSystemPromptOverride(baseAppend) : baseAppend, this.loaded = !0;
6554
- }
6555
- async loadCurrentExtensionSet(options) {
6556
- let resolvedPaths = await this.packageManager.resolve(this.resolveOnMissing(options.skipMissingPackageInstall)), cliExtensionPaths = await this.packageManager.resolveExtensionSources(this.additionalExtensionPaths, {
6557
- temporary: !0
6558
- }), enabledExtensions = resolvedPaths.extensions.filter((r) => r.enabled).map((r) => r.path), cliEnabledExtensions = cliExtensionPaths.extensions.filter((r) => r.enabled).map((r) => r.path), extensionPaths = this.noExtensions ? cliEnabledExtensions : this.mergePaths(cliEnabledExtensions, enabledExtensions), extensionsResult = await loadExtensionsCached(extensionPaths, this.cwd, this.eventBus);
6559
- if (!options.includeInlineFactories)
6560
- return extensionsResult;
6561
- let inlineExtensions = await this.loadExtensionFactories(extensionsResult.runtime);
6562
- return extensionsResult.extensions.push(...inlineExtensions.extensions), extensionsResult.errors.push(...inlineExtensions.errors), extensionsResult;
6563
- }
6564
- resolveExtensionLoadPath(path2) {
6565
- return resolvePath(path2, this.cwd, { normalizeUnicodeSpaces: !0 });
6566
- }
6567
- async loadFinalExtensionSet(extensionPaths, preTrustExtensions) {
6568
- if (!preTrustExtensions) {
6569
- let extensionsResult2 = await loadExtensionsCached(extensionPaths, this.cwd, this.eventBus), inlineExtensions2 = await this.loadExtensionFactories(extensionsResult2.runtime);
6570
- return extensionsResult2.extensions.push(...inlineExtensions2.extensions), extensionsResult2.errors.push(...inlineExtensions2.errors), this.addExtensionConflictDiagnostics(extensionsResult2), extensionsResult2;
6571
- }
6572
- let preloadedByPath = new Map(preTrustExtensions.extensions.filter((extension) => !extension.path.startsWith("<inline:")).map((extension) => [extension.resolvedPath, extension])), failedPreloadPaths = new Set(preTrustExtensions.errors.map((error) => this.resolveExtensionLoadPath(error.path))), remainingPaths = extensionPaths.filter((path2) => {
6573
- let resolvedPath = this.resolveExtensionLoadPath(path2);
6574
- return !preloadedByPath.has(resolvedPath) && !failedPreloadPaths.has(resolvedPath);
6575
- }), remainingExtensions = await loadExtensionsCached(remainingPaths, this.cwd, this.eventBus, preTrustExtensions.runtime), loadedByPath = new Map(preloadedByPath);
6576
- for (let extension of remainingExtensions.extensions)
6577
- loadedByPath.set(extension.resolvedPath, extension);
6578
- let inlineExtensions = preTrustExtensions.extensions.filter((extension) => extension.path.startsWith("<inline:")), orderedExtensions = extensionPaths.map((path2) => loadedByPath.get(this.resolveExtensionLoadPath(path2))).filter((extension) => extension !== void 0);
6579
- orderedExtensions.push(...inlineExtensions);
6580
- let extensionsResult = {
6581
- extensions: orderedExtensions,
6582
- errors: [...preTrustExtensions.errors, ...remainingExtensions.errors],
6583
- runtime: preTrustExtensions.runtime
6584
- };
6585
- return this.addExtensionConflictDiagnostics(extensionsResult), extensionsResult;
6586
- }
6587
- addExtensionConflictDiagnostics(extensionsResult) {
6588
- let conflicts = this.detectExtensionConflicts(extensionsResult.extensions);
6589
- for (let conflict of conflicts)
6590
- extensionsResult.errors.push({ path: conflict.path, error: conflict.message });
6591
- }
6592
- mapSkillPath(resource, metadataByPath) {
6593
- if (resource.metadata.source !== "auto" && resource.metadata.origin !== "package")
6594
- return resource.path;
6595
- try {
6596
- if (!statSync5(resource.path).isDirectory())
6597
- return resource.path;
6598
- } catch {
6599
- return resource.path;
6600
- }
6601
- let skillFile = join5(resource.path, "SKILL.md");
6602
- return existsSync5(skillFile) ? (metadataByPath.has(skillFile) || metadataByPath.set(skillFile, resource.metadata), skillFile) : resource.path;
6603
- }
6604
- normalizeExtensionPaths(entries) {
6605
- return entries.map((entry) => {
6606
- let metadata = entry.metadata.baseDir ? { ...entry.metadata, baseDir: this.resolveResourcePath(entry.metadata.baseDir) } : entry.metadata;
6607
- return {
6608
- path: this.resolveResourcePath(entry.path),
6609
- metadata
6610
- };
6611
- });
6612
- }
6613
- updateSkillsFromPaths(skillPaths, metadataByPath) {
6614
- let skillsResult;
6615
- this.noSkills && skillPaths.length === 0 ? skillsResult = { skills: [], diagnostics: [] } : skillsResult = loadSkills({
6616
- cwd: this.cwd,
6617
- agentDir: this.agentDir,
6618
- skillPaths,
6619
- includeDefaults: !1
6620
- });
6621
- let resolvedSkills = this.skillsOverride ? this.skillsOverride(skillsResult) : skillsResult;
6622
- this.skills = resolvedSkills.skills.map((skill) => ({
6623
- ...skill,
6624
- sourceInfo: this.findSourceInfoForPath(skill.filePath, this.extensionSkillSourceInfos, metadataByPath) ?? skill.sourceInfo ?? this.getDefaultSourceInfoForPath(skill.filePath)
6625
- })), this.skillDiagnostics = resolvedSkills.diagnostics;
6626
- }
6627
- updatePromptsFromPaths(promptPaths, metadataByPath) {
6628
- let promptsResult;
6629
- if (this.noPromptTemplates && promptPaths.length === 0)
6630
- promptsResult = { prompts: [], diagnostics: [] };
6631
- else {
6632
- let allPrompts = loadPromptTemplates({
6633
- cwd: this.cwd,
6634
- agentDir: this.agentDir,
6635
- promptPaths,
6636
- includeDefaults: !1
6637
- });
6638
- promptsResult = this.dedupePrompts(allPrompts);
6639
- }
6640
- let resolvedPrompts = this.promptsOverride ? this.promptsOverride(promptsResult) : promptsResult;
6641
- this.prompts = resolvedPrompts.prompts.map((prompt) => ({
6642
- ...prompt,
6643
- sourceInfo: this.findSourceInfoForPath(prompt.filePath, this.extensionPromptSourceInfos, metadataByPath) ?? prompt.sourceInfo ?? this.getDefaultSourceInfoForPath(prompt.filePath)
6644
- })), this.promptDiagnostics = resolvedPrompts.diagnostics;
6645
- }
6646
- updateThemesFromPaths(themePaths, metadataByPath) {
6647
- let themesResult;
6648
- if (this.noThemes && themePaths.length === 0)
6649
- themesResult = { themes: [], diagnostics: [] };
6650
- else {
6651
- let loaded = this.loadThemes(themePaths, !1), deduped = this.dedupeThemes(loaded.themes);
6652
- themesResult = { themes: deduped.themes, diagnostics: [...loaded.diagnostics, ...deduped.diagnostics] };
6653
- }
6654
- let resolvedThemes = this.themesOverride ? this.themesOverride(themesResult) : themesResult;
6655
- this.themes = resolvedThemes.themes.map((theme2) => {
6656
- let sourcePath = theme2.sourcePath;
6657
- return theme2.sourceInfo = sourcePath ? this.findSourceInfoForPath(sourcePath, this.extensionThemeSourceInfos, metadataByPath) ?? theme2.sourceInfo ?? this.getDefaultSourceInfoForPath(sourcePath) : theme2.sourceInfo, theme2;
6658
- }), this.themeDiagnostics = resolvedThemes.diagnostics;
6659
- }
6660
- applyExtensionSourceInfo(extensions, metadataByPath) {
6661
- for (let extension of extensions) {
6662
- extension.sourceInfo = this.findSourceInfoForPath(extension.path, void 0, metadataByPath) ?? this.getDefaultSourceInfoForPath(extension.path);
6663
- for (let command of extension.commands.values())
6664
- command.sourceInfo = extension.sourceInfo;
6665
- for (let tool of extension.tools.values())
6666
- tool.sourceInfo = extension.sourceInfo;
6667
- }
6668
- }
6669
- findSourceInfoForPath(resourcePath, extraSourceInfos, metadataByPath) {
6670
- if (!resourcePath)
6671
- return;
6672
- if (resourcePath.startsWith("<"))
6673
- return this.getDefaultSourceInfoForPath(resourcePath);
6674
- let normalizedResourcePath = resolve5(resourcePath);
6675
- if (extraSourceInfos)
6676
- for (let [sourcePath, sourceInfo] of extraSourceInfos.entries()) {
6677
- let normalizedSourcePath = resolve5(sourcePath);
6678
- if (normalizedResourcePath === normalizedSourcePath || normalizedResourcePath.startsWith(`${normalizedSourcePath}${sep4}`))
6679
- return { ...sourceInfo, path: resourcePath };
6680
- }
6681
- if (metadataByPath) {
6682
- let exact = metadataByPath.get(normalizedResourcePath) ?? metadataByPath.get(resourcePath);
6683
- if (exact)
6684
- return createSourceInfo(resourcePath, exact);
6685
- for (let [sourcePath, metadata] of metadataByPath.entries()) {
6686
- let normalizedSourcePath = resolve5(sourcePath);
6687
- if (normalizedResourcePath === normalizedSourcePath || normalizedResourcePath.startsWith(`${normalizedSourcePath}${sep4}`))
6688
- return createSourceInfo(resourcePath, metadata);
6689
- }
6690
- }
6691
- }
6692
- getDefaultSourceInfoForPath(filePath) {
6693
- if (filePath.startsWith("<") && filePath.endsWith(">"))
6694
- return {
6695
- path: filePath,
6696
- source: filePath.slice(1, -1).split(":")[0] || "temporary",
6697
- scope: "temporary",
6698
- origin: "top-level"
6699
- };
6700
- let normalizedPath = resolve5(filePath), agentRoots = [
6701
- join5(this.agentDir, "skills"),
6702
- join5(this.agentDir, "prompts"),
6703
- join5(this.agentDir, "themes"),
6704
- join5(this.agentDir, "extensions")
6705
- ], projectRoots = [
6706
- join5(this.cwd, CONFIG_DIR_NAME, "skills"),
6707
- join5(this.cwd, CONFIG_DIR_NAME, "prompts"),
6708
- join5(this.cwd, CONFIG_DIR_NAME, "themes"),
6709
- join5(this.cwd, CONFIG_DIR_NAME, "extensions")
6710
- ];
6711
- for (let root of agentRoots)
6712
- if (this.isUnderPath(normalizedPath, root))
6713
- return { path: filePath, source: "local", scope: "user", origin: "top-level", baseDir: root };
6714
- for (let root of projectRoots)
6715
- if (this.isUnderPath(normalizedPath, root))
6716
- return { path: filePath, source: "local", scope: "project", origin: "top-level", baseDir: root };
6717
- return {
6718
- path: filePath,
6719
- source: "local",
6720
- scope: "temporary",
6721
- origin: "top-level",
6722
- baseDir: statSync5(normalizedPath).isDirectory() ? normalizedPath : resolve5(normalizedPath, "..")
6723
- };
6724
- }
6725
- mergePaths(primary, additional) {
6726
- let merged = [], seen = /* @__PURE__ */ new Set();
6727
- for (let p of [...primary, ...additional]) {
6728
- let resolved = this.resolveResourcePath(p), canonicalPath = canonicalizePath(resolved);
6729
- seen.has(canonicalPath) || (seen.add(canonicalPath), merged.push(resolved));
6730
- }
6731
- return merged;
6732
- }
6733
- resolveResourcePath(p) {
6734
- return resolvePath(p, this.cwd, { trim: !0 });
6735
- }
6736
- loadThemes(paths, includeDefaults = !0) {
6737
- let themes = [], diagnostics = [];
6738
- if (includeDefaults) {
6739
- let defaultDirs = [join5(this.agentDir, "themes"), join5(this.cwd, CONFIG_DIR_NAME, "themes")];
6740
- for (let dir of defaultDirs)
6741
- this.loadThemesFromDir(dir, themes, diagnostics);
6742
- }
6743
- for (let p of paths) {
6744
- let resolved = this.resolveResourcePath(p);
6745
- if (!existsSync5(resolved)) {
6746
- diagnostics.push({ type: "warning", message: "theme path does not exist", path: resolved });
6747
- continue;
6748
- }
6749
- try {
6750
- let stats = statSync5(resolved);
6751
- stats.isDirectory() ? this.loadThemesFromDir(resolved, themes, diagnostics) : stats.isFile() && resolved.endsWith(".json") ? this.loadThemeFromFile(resolved, themes, diagnostics) : diagnostics.push({ type: "warning", message: "theme path is not a json file", path: resolved });
6752
- } catch (error) {
6753
- let message = error instanceof Error ? error.message : "failed to read theme path";
6754
- diagnostics.push({ type: "warning", message, path: resolved });
6755
- }
6756
- }
6757
- return { themes, diagnostics };
6758
- }
6759
- loadThemesFromDir(dir, themes, diagnostics) {
6760
- if (existsSync5(dir))
6761
- try {
6762
- let entries = readdirSync5(dir, { withFileTypes: !0 });
6763
- for (let entry of entries) {
6764
- let isFile = entry.isFile();
6765
- if (entry.isSymbolicLink())
6766
- try {
6767
- isFile = statSync5(join5(dir, entry.name)).isFile();
6768
- } catch {
6769
- continue;
6770
- }
6771
- isFile && entry.name.endsWith(".json") && this.loadThemeFromFile(join5(dir, entry.name), themes, diagnostics);
6772
- }
6773
- } catch (error) {
6774
- let message = error instanceof Error ? error.message : "failed to read theme directory";
6775
- diagnostics.push({ type: "warning", message, path: dir });
6776
- }
6777
- }
6778
- loadThemeFromFile(filePath, themes, diagnostics) {
6779
- try {
6780
- themes.push(loadThemeFromPath(filePath));
6781
- } catch (error) {
6782
- let message = error instanceof Error ? error.message : "failed to load theme";
6783
- diagnostics.push({ type: "warning", message, path: filePath });
6784
- }
6785
- }
6786
- async loadExtensionFactories(runtime, factories = this.extensionFactories) {
6787
- let extensions = [], errors = [];
6788
- for (let [index, input] of factories.entries()) {
6789
- let factory = typeof input != "function" ? input.factory : input, extensionPath = inlineExtensionPath(input, index);
6790
- try {
6791
- let extension = await loadExtensionFromFactory(factory, this.cwd, this.eventBus, runtime, extensionPath);
6792
- extensions.push(extension);
6793
- } catch (error) {
6794
- let message = error instanceof Error ? error.message : "failed to load extension";
6795
- errors.push({ path: extensionPath, error: message });
6796
- }
6797
- }
6798
- return { extensions, errors };
6799
- }
6800
- dedupePrompts(prompts) {
6801
- let seen = /* @__PURE__ */ new Map(), diagnostics = [];
6802
- for (let prompt of prompts) {
6803
- let existing = seen.get(prompt.name);
6804
- existing ? diagnostics.push({
6805
- type: "collision",
6806
- message: `name "/${prompt.name}" collision`,
6807
- path: prompt.filePath,
6808
- collision: {
6809
- resourceType: "prompt",
6810
- name: prompt.name,
6811
- winnerPath: existing.filePath,
6812
- loserPath: prompt.filePath
6813
- }
6814
- }) : seen.set(prompt.name, prompt);
6815
- }
6816
- return { prompts: Array.from(seen.values()), diagnostics };
6817
- }
6818
- dedupeThemes(themes) {
6819
- let seen = /* @__PURE__ */ new Map(), diagnostics = [];
6820
- for (let t of themes) {
6821
- let name = t.name ?? "unnamed", existing = seen.get(name);
6822
- existing ? diagnostics.push({
6823
- type: "collision",
6824
- message: `name "${name}" collision`,
6825
- path: t.sourcePath,
6826
- collision: {
6827
- resourceType: "theme",
6828
- name,
6829
- winnerPath: existing.sourcePath ?? "<builtin>",
6830
- loserPath: t.sourcePath ?? "<builtin>"
6831
- }
6832
- }) : seen.set(name, t);
6833
- }
6834
- return { themes: Array.from(seen.values()), diagnostics };
6835
- }
6836
- discoverSystemPromptFile() {
6837
- let projectPath = join5(this.cwd, CONFIG_DIR_NAME, "SYSTEM.md");
6838
- if (this.settingsManager.isProjectTrusted() && existsSync5(projectPath))
6839
- return projectPath;
6840
- let globalPath = join5(this.agentDir, "SYSTEM.md");
6841
- if (existsSync5(globalPath))
6842
- return globalPath;
6843
- }
6844
- discoverAppendSystemPromptFile() {
6845
- let projectPath = join5(this.cwd, CONFIG_DIR_NAME, "APPEND_SYSTEM.md");
6846
- if (this.settingsManager.isProjectTrusted() && existsSync5(projectPath))
6847
- return projectPath;
6848
- let globalPath = join5(this.agentDir, "APPEND_SYSTEM.md");
6849
- if (existsSync5(globalPath))
6850
- return globalPath;
6851
- }
6852
- isUnderPath(target, root) {
6853
- let normalizedRoot = resolve5(root);
6854
- if (target === normalizedRoot)
6855
- return !0;
6856
- let prefix = normalizedRoot.endsWith(sep4) ? normalizedRoot : `${normalizedRoot}${sep4}`;
6857
- return target.startsWith(prefix);
6858
- }
6859
- detectExtensionConflicts(extensions) {
6860
- let conflicts = [], toolOwners = /* @__PURE__ */ new Map(), flagOwners = /* @__PURE__ */ new Map();
6861
- for (let ext of extensions) {
6862
- for (let toolName of ext.tools.keys()) {
6863
- let existingOwner = toolOwners.get(toolName);
6864
- existingOwner && existingOwner !== ext.path ? conflicts.push({
6865
- path: ext.path,
6866
- message: `Tool "${toolName}" conflicts with ${existingOwner}`
6867
- }) : toolOwners.set(toolName, ext.path);
6868
- }
6869
- for (let flagName of ext.flags.keys()) {
6870
- let existingOwner = flagOwners.get(flagName);
6871
- existingOwner && existingOwner !== ext.path ? conflicts.push({
6872
- path: ext.path,
6873
- message: `Flag "--${flagName}" conflicts with ${existingOwner}`
6874
- }) : flagOwners.set(flagName, ext.path);
6875
- }
6876
- }
6877
- return conflicts;
6878
- }
6879
- };
6880
-
6881
- // packages/coding-agent/dist/core/extensions/runner.js
6882
- var RESERVED_KEYBINDINGS_FOR_EXTENSION_CONFLICTS = [
6883
- "app.interrupt",
6884
- "app.clear",
6885
- "app.exit",
6886
- "app.suspend",
6887
- "app.thinking.cycle",
6888
- "app.mode.cycle",
6889
- "app.model.cycleForward",
6890
- "app.model.cycleBackward",
6891
- "app.model.select",
6892
- "app.tools.expand",
6893
- "app.thinking.toggle",
6894
- "app.editor.external",
6895
- "app.message.copy",
6896
- "app.message.followUp",
6897
- "tui.input.submit",
6898
- "tui.select.confirm",
6899
- "tui.select.cancel",
6900
- "tui.input.copy",
6901
- "tui.editor.deleteToLineEnd"
6902
- ], buildBuiltinKeybindings = (resolvedKeybindings) => {
6903
- let builtinKeybindings = {};
6904
- for (let [keybinding, keys] of Object.entries(resolvedKeybindings)) {
6905
- if (keys === void 0)
6906
- continue;
6907
- let keyList = Array.isArray(keys) ? keys : [keys], restrictOverride = RESERVED_KEYBINDINGS_FOR_EXTENSION_CONFLICTS.includes(keybinding);
6908
- for (let key of keyList) {
6909
- let normalizedKey = key.toLowerCase();
6910
- builtinKeybindings[normalizedKey]?.restrictOverride && !restrictOverride || (builtinKeybindings[normalizedKey] = {
6911
- keybinding,
6912
- restrictOverride
6913
- });
6914
- }
6915
- }
6916
- return builtinKeybindings;
6917
- };
6918
- async function emitSessionShutdownEvent(extensionRunner, event) {
6919
- return extensionRunner.hasHandlers("session_shutdown") ? (await extensionRunner.emit(event), !0) : !1;
6920
- }
6921
- async function emitProjectTrustEvent(extensionsResult, event, ctx) {
6922
- let errors = [];
6923
- for (let ext of extensionsResult.extensions) {
6924
- let handlers = ext.handlers.get("project_trust");
6925
- if (!(!handlers || handlers.length === 0))
6926
- for (let handler of handlers)
6927
- try {
6928
- let handlerResult = await handler(event, ctx);
6929
- if (handlerResult.trusted === "undecided")
6930
- continue;
6931
- return { result: handlerResult, errors };
6932
- } catch (error) {
6933
- errors.push({
6934
- extensionPath: ext.path,
6935
- event: event.type,
6936
- error: error instanceof Error ? error.message : String(error),
6937
- stack: error instanceof Error ? error.stack : void 0
6938
- });
6939
- }
6940
- }
6941
- return { errors };
6942
- }
6943
- var noOpUIContext = {
6944
- select: async () => {
6945
- },
6946
- confirm: async () => !1,
6947
- input: async () => {
6948
- },
6949
- notify: () => {
6950
- },
6951
- onTerminalInput: () => () => {
6952
- },
6953
- setStatus: () => {
6954
- },
6955
- setWorkingMessage: () => {
6956
- },
6957
- setWorkingVisible: () => {
6958
- },
6959
- setWorkingIndicator: () => {
6960
- },
6961
- setHiddenThinkingLabel: () => {
6962
- },
6963
- setWidget: () => {
6964
- },
6965
- setFooter: () => {
6966
- },
6967
- setHeader: () => {
6968
- },
6969
- setTitle: () => {
6970
- },
6971
- custom: async () => {
6972
- },
6973
- pasteToEditor: () => {
6974
- },
6975
- setEditorText: () => {
6976
- },
6977
- getEditorText: () => "",
6978
- editor: async () => {
6979
- },
6980
- addAutocompleteProvider: () => {
6981
- },
6982
- setEditorComponent: () => {
6983
- },
6984
- getEditorComponent: () => {
6985
- },
6986
- get theme() {
6987
- return theme;
6988
- },
6989
- getAllThemes: () => [],
6990
- getTheme: () => {
6991
- },
6992
- setTheme: (_theme) => ({ success: !1, error: "UI not available" }),
6993
- getToolsExpanded: () => !1,
6994
- setToolsExpanded: () => {
6995
- }
6996
- }, ExtensionRunner = class {
6997
- extensions;
6998
- runtime;
6999
- uiContext;
7000
- mode = "print";
7001
- cwd;
7002
- sessionManager;
7003
- modelRegistry;
7004
- errorListeners = /* @__PURE__ */ new Set();
7005
- getModel = () => {
7006
- };
7007
- isIdleFn = () => !0;
7008
- isProjectTrustedFn = () => !0;
7009
- getSignalFn = () => {
7010
- };
7011
- waitForIdleFn = async () => {
7012
- };
7013
- abortFn = () => {
7014
- };
7015
- hasPendingMessagesFn = () => !1;
7016
- getContextUsageFn = () => {
7017
- };
7018
- compactFn = () => {
7019
- };
7020
- getSystemPromptFn = () => "";
7021
- getSystemPromptOptionsFn = () => ({ cwd: this.cwd });
7022
- newSessionHandler = async () => ({ cancelled: !1 });
7023
- forkHandler = async () => ({ cancelled: !1 });
7024
- navigateTreeHandler = async () => ({ cancelled: !1 });
7025
- switchSessionHandler = async () => ({ cancelled: !1 });
7026
- reloadHandler = async () => {
7027
- };
7028
- shutdownHandler = () => {
7029
- };
7030
- shortcutDiagnostics = [];
7031
- commandDiagnostics = [];
7032
- staleMessage;
7033
- constructor(extensions, runtime, cwd, sessionManager, modelRegistry) {
7034
- this.extensions = extensions, this.runtime = runtime, this.uiContext = noOpUIContext, this.cwd = cwd, this.sessionManager = sessionManager, this.modelRegistry = modelRegistry;
7035
- }
7036
- bindCore(actions, contextActions, providerActions) {
7037
- this.runtime.sendMessage = actions.sendMessage, this.runtime.sendUserMessage = actions.sendUserMessage, this.runtime.appendEntry = actions.appendEntry, this.runtime.setSessionName = actions.setSessionName, this.runtime.getSessionName = actions.getSessionName, this.runtime.setLabel = actions.setLabel, this.runtime.getActiveTools = actions.getActiveTools, this.runtime.getAllTools = actions.getAllTools, this.runtime.setActiveTools = actions.setActiveTools, this.runtime.refreshTools = actions.refreshTools, this.runtime.getCommands = actions.getCommands, this.runtime.setModel = actions.setModel, this.runtime.getThinkingLevel = actions.getThinkingLevel, this.runtime.setThinkingLevel = actions.setThinkingLevel, this.getModel = contextActions.getModel, this.isIdleFn = contextActions.isIdle, this.isProjectTrustedFn = contextActions.isProjectTrusted, this.getSignalFn = contextActions.getSignal, this.abortFn = contextActions.abort, this.hasPendingMessagesFn = contextActions.hasPendingMessages, this.shutdownHandler = contextActions.shutdown, this.getContextUsageFn = contextActions.getContextUsage, this.compactFn = contextActions.compact, this.getSystemPromptFn = contextActions.getSystemPrompt, this.getSystemPromptOptionsFn = contextActions.getSystemPromptOptions ?? (() => ({ cwd: this.cwd }));
7038
- for (let { name, config, extensionPath } of this.runtime.pendingProviderRegistrations)
7039
- try {
7040
- providerActions?.registerProvider ? providerActions.registerProvider(name, config) : this.modelRegistry.registerProvider(name, config);
7041
- } catch (err) {
7042
- this.emitError({
7043
- extensionPath,
7044
- event: "register_provider",
7045
- error: err instanceof Error ? err.message : String(err),
7046
- stack: err instanceof Error ? err.stack : void 0
7047
- });
7048
- }
7049
- this.runtime.pendingProviderRegistrations = [], this.runtime.registerProvider = (name, config) => {
7050
- if (providerActions?.registerProvider) {
7051
- providerActions.registerProvider(name, config);
7052
- return;
7053
- }
7054
- this.modelRegistry.registerProvider(name, config);
7055
- }, this.runtime.unregisterProvider = (name) => {
7056
- if (providerActions?.unregisterProvider) {
7057
- providerActions.unregisterProvider(name);
7058
- return;
7059
- }
7060
- this.modelRegistry.unregisterProvider(name);
7061
- };
7062
- }
7063
- bindCommandContext(actions) {
7064
- if (actions) {
7065
- this.waitForIdleFn = actions.waitForIdle, this.newSessionHandler = actions.newSession, this.forkHandler = actions.fork, this.navigateTreeHandler = actions.navigateTree, this.switchSessionHandler = actions.switchSession, this.reloadHandler = actions.reload;
7066
- return;
7067
- }
7068
- this.waitForIdleFn = async () => {
7069
- }, this.newSessionHandler = async () => ({ cancelled: !1 }), this.forkHandler = async () => ({ cancelled: !1 }), this.navigateTreeHandler = async () => ({ cancelled: !1 }), this.switchSessionHandler = async () => ({ cancelled: !1 }), this.reloadHandler = async () => {
7070
- };
7071
- }
7072
- setUIContext(uiContext, mode = "print") {
7073
- this.uiContext = uiContext ?? noOpUIContext, this.mode = mode;
7074
- }
7075
- getUIContext() {
7076
- return this.uiContext;
7077
- }
7078
- hasUI() {
7079
- return this.uiContext !== noOpUIContext;
7080
- }
7081
- getExtensionPaths() {
7082
- return this.extensions.map((e) => e.path);
7083
- }
7084
- /** Append already-loaded extensions to this runner. Bindings stay on the existing runtime. */
7085
- appendExtensions(extensions) {
7086
- let existing = new Set(this.extensions), existingPaths = new Set(this.extensions.map((extension) => extension.path));
7087
- for (let extension of extensions)
7088
- existing.has(extension) || existingPaths.has(extension.path) || (this.extensions.push(extension), existing.add(extension), existingPaths.add(extension.path));
7089
- }
7090
- /** Get all registered tools from all extensions (first registration per name wins). */
7091
- getAllRegisteredTools() {
7092
- let toolsByName = /* @__PURE__ */ new Map();
7093
- for (let ext of this.extensions)
7094
- for (let tool of ext.tools.values())
7095
- toolsByName.has(tool.definition.name) || toolsByName.set(tool.definition.name, tool);
7096
- return Array.from(toolsByName.values());
7097
- }
7098
- /** Get a tool definition by name. Returns undefined if not found. */
7099
- getToolDefinition(toolName) {
7100
- for (let ext of this.extensions) {
7101
- let tool = ext.tools.get(toolName);
7102
- if (tool)
7103
- return tool.definition;
7104
- }
7105
- }
7106
- getFlags() {
7107
- let allFlags = /* @__PURE__ */ new Map();
7108
- for (let ext of this.extensions)
7109
- for (let [name, flag] of ext.flags)
7110
- allFlags.has(name) || allFlags.set(name, flag);
7111
- return allFlags;
7112
- }
7113
- setFlagValue(name, value) {
7114
- this.runtime.flagValues.set(name, value);
7115
- }
7116
- getFlagValues() {
7117
- return new Map(this.runtime.flagValues);
7118
- }
7119
- getShortcuts(resolvedKeybindings) {
7120
- this.shortcutDiagnostics = [];
7121
- let builtinKeybindings = buildBuiltinKeybindings(resolvedKeybindings), extensionShortcuts = /* @__PURE__ */ new Map(), addDiagnostic = (message, extensionPath) => {
7122
- this.shortcutDiagnostics.push({ type: "warning", message, path: extensionPath }), this.hasUI() || console.warn(message);
7123
- };
7124
- for (let ext of this.extensions)
7125
- for (let [key, shortcut] of ext.shortcuts) {
7126
- let normalizedKey = key.toLowerCase(), builtInKeybinding = builtinKeybindings[normalizedKey];
7127
- if (builtInKeybinding?.restrictOverride === !0) {
7128
- addDiagnostic(`Extension shortcut '${key}' from ${shortcut.extensionPath} conflicts with built-in shortcut. Skipping.`, shortcut.extensionPath);
7129
- continue;
7130
- }
7131
- builtInKeybinding?.restrictOverride === !1 && addDiagnostic(`Extension shortcut conflict: '${key}' is built-in shortcut for ${builtInKeybinding.keybinding} and ${shortcut.extensionPath}. Using ${shortcut.extensionPath}.`, shortcut.extensionPath);
7132
- let existingExtensionShortcut = extensionShortcuts.get(normalizedKey);
7133
- existingExtensionShortcut && addDiagnostic(`Extension shortcut conflict: '${key}' registered by both ${existingExtensionShortcut.extensionPath} and ${shortcut.extensionPath}. Using ${shortcut.extensionPath}.`, shortcut.extensionPath), extensionShortcuts.set(normalizedKey, shortcut);
7134
- }
7135
- return extensionShortcuts;
7136
- }
7137
- getShortcutDiagnostics() {
7138
- return this.shortcutDiagnostics;
7139
- }
7140
- invalidate(message = "This extension ctx is stale after session replacement or reload. Do not use a captured pi or command ctx after ctx.newSession(), ctx.fork(), ctx.switchSession(), or ctx.reload(). For newSession, fork, and switchSession, move post-replacement work into withSession and use the ctx passed to withSession. For reload, do not use the old ctx after await ctx.reload().") {
7141
- this.staleMessage || (this.staleMessage = message, this.runtime.invalidate(message));
7142
- }
7143
- assertActive() {
7144
- if (this.staleMessage)
7145
- throw new Error(this.staleMessage);
7146
- }
7147
- onError(listener) {
7148
- return this.errorListeners.add(listener), () => this.errorListeners.delete(listener);
7149
- }
7150
- emitError(error) {
7151
- for (let listener of this.errorListeners)
7152
- listener(error);
7153
- }
7154
- hasHandlers(eventType) {
7155
- for (let ext of this.extensions) {
7156
- let handlers = ext.handlers.get(eventType);
7157
- if (handlers && handlers.length > 0)
7158
- return !0;
7159
- }
7160
- return !1;
7161
- }
7162
- getMessageRenderer(customType) {
7163
- for (let ext of this.extensions) {
7164
- let renderer = ext.messageRenderers.get(customType);
7165
- if (renderer)
7166
- return renderer;
7167
- }
7168
- }
7169
- getEntryRenderer(customType) {
7170
- for (let ext of this.extensions) {
7171
- let renderer = ext.entryRenderers?.get(customType);
7172
- if (renderer)
7173
- return renderer;
7174
- }
7175
- }
7176
- resolveRegisteredCommands() {
7177
- let commands = [], counts = /* @__PURE__ */ new Map();
7178
- for (let ext of this.extensions)
7179
- for (let command of ext.commands.values())
7180
- commands.push(command), counts.set(command.name, (counts.get(command.name) ?? 0) + 1);
7181
- let seen = /* @__PURE__ */ new Map(), takenInvocationNames = /* @__PURE__ */ new Set();
7182
- return commands.map((command) => {
7183
- let occurrence = (seen.get(command.name) ?? 0) + 1;
7184
- seen.set(command.name, occurrence);
7185
- let invocationName = (counts.get(command.name) ?? 0) > 1 ? `${command.name}:${occurrence}` : command.name;
7186
- if (takenInvocationNames.has(invocationName)) {
7187
- let suffix = occurrence;
7188
- do
7189
- suffix++, invocationName = `${command.name}:${suffix}`;
7190
- while (takenInvocationNames.has(invocationName));
7191
- }
7192
- return takenInvocationNames.add(invocationName), {
7193
- ...command,
7194
- invocationName
7195
- };
7196
- });
7197
- }
7198
- getModelRegistry() {
7199
- return this.modelRegistry;
7200
- }
7201
- getRegisteredCommands() {
7202
- return this.commandDiagnostics = [], this.resolveRegisteredCommands();
7203
- }
7204
- getCommandDiagnostics() {
7205
- return this.commandDiagnostics;
7206
- }
7207
- getCommand(name) {
7208
- return this.resolveRegisteredCommands().find((command) => command.invocationName === name);
7209
- }
7210
- /**
7211
- * Request a graceful shutdown. Called by extension tools and event handlers.
7212
- * The actual shutdown behavior is provided by the mode via bindExtensions().
7213
- */
7214
- shutdown() {
7215
- this.shutdownHandler();
7216
- }
7217
- getActiveTools() {
7218
- return this.assertActive(), this.runtime.getActiveTools();
7219
- }
7220
- /**
7221
- * Create an ExtensionContext for use in event handlers and tool execution.
7222
- * Context values are resolved at call time, so changes via bindCore/bindUI are reflected.
7223
- */
7224
- createContext() {
7225
- let runner = this, getModel = this.getModel;
7226
- return {
7227
- get ui() {
7228
- return runner.assertActive(), runner.uiContext;
7229
- },
7230
- get mode() {
7231
- return runner.assertActive(), runner.mode;
7232
- },
7233
- get hasUI() {
7234
- return runner.assertActive(), runner.hasUI();
7235
- },
7236
- get cwd() {
7237
- return runner.assertActive(), runner.cwd;
7238
- },
7239
- get sessionManager() {
7240
- return runner.assertActive(), runner.sessionManager;
7241
- },
7242
- get modelRegistry() {
7243
- return runner.assertActive(), runner.modelRegistry;
7244
- },
7245
- get model() {
7246
- return runner.assertActive(), getModel();
7247
- },
7248
- isIdle: () => (runner.assertActive(), runner.isIdleFn()),
7249
- isProjectTrusted: () => (runner.assertActive(), runner.isProjectTrustedFn()),
7250
- get signal() {
7251
- return runner.assertActive(), runner.getSignalFn();
7252
- },
7253
- abort: () => {
7254
- runner.assertActive(), runner.abortFn();
7255
- },
7256
- hasPendingMessages: () => (runner.assertActive(), runner.hasPendingMessagesFn()),
7257
- shutdown: () => {
7258
- runner.assertActive(), runner.shutdownHandler();
7259
- },
7260
- getContextUsage: () => (runner.assertActive(), runner.getContextUsageFn()),
7261
- compact: (options) => {
7262
- runner.assertActive(), runner.compactFn(options);
7263
- },
7264
- getSystemPrompt: () => (runner.assertActive(), runner.getSystemPromptFn())
7265
- };
7266
- }
7267
- createCommandContext() {
7268
- let context = Object.defineProperties({}, Object.getOwnPropertyDescriptors(this.createContext()));
7269
- return context.getSystemPromptOptions = () => (this.assertActive(), this.getSystemPromptOptionsFn()), context.waitForIdle = () => (this.assertActive(), this.waitForIdleFn()), context.newSession = (options) => (this.assertActive(), this.newSessionHandler(options)), context.fork = (entryId, options) => (this.assertActive(), this.forkHandler(entryId, options)), context.navigateTree = (targetId, options) => (this.assertActive(), this.navigateTreeHandler(targetId, options)), context.switchSession = (sessionPath, options) => (this.assertActive(), this.switchSessionHandler(sessionPath, options)), context.reload = () => (this.assertActive(), this.reloadHandler()), context;
7270
- }
7271
- isSessionBeforeEvent(event) {
7272
- return event.type === "session_before_switch" || event.type === "session_before_fork" || event.type === "session_before_compact" || event.type === "session_before_tree";
7273
- }
7274
- async emit(event) {
7275
- let ctx = this.createContext(), result;
7276
- for (let ext of this.extensions) {
7277
- let handlers = ext.handlers.get(event.type);
7278
- if (!(!handlers || handlers.length === 0))
7279
- for (let handler of handlers)
7280
- try {
7281
- let handlerResult = await handler(event, ctx);
7282
- if (this.isSessionBeforeEvent(event) && handlerResult && (result = handlerResult, result.cancel))
7283
- return result;
7284
- } catch (err) {
7285
- let message = err instanceof Error ? err.message : String(err), stack = err instanceof Error ? err.stack : void 0;
7286
- this.emitError({
7287
- extensionPath: ext.path,
7288
- event: event.type,
7289
- error: message,
7290
- stack
7291
- });
7292
- }
7293
- }
7294
- return result;
7295
- }
7296
- async emitMessageEnd(event) {
7297
- let ctx = this.createContext(), currentMessage = event.message, modified = !1;
7298
- for (let ext of this.extensions) {
7299
- let handlers = ext.handlers.get("message_end");
7300
- if (!(!handlers || handlers.length === 0))
7301
- for (let handler of handlers)
7302
- try {
7303
- let currentEvent = { ...event, message: currentMessage }, handlerResult = await handler(currentEvent, ctx);
7304
- if (!handlerResult?.message)
7305
- continue;
7306
- if (handlerResult.message.role !== currentMessage.role) {
7307
- this.emitError({
7308
- extensionPath: ext.path,
7309
- event: "message_end",
7310
- error: "message_end handlers must return a message with the same role"
7311
- });
7312
- continue;
7313
- }
7314
- currentMessage = handlerResult.message, modified = !0;
7315
- } catch (err) {
7316
- let message = err instanceof Error ? err.message : String(err), stack = err instanceof Error ? err.stack : void 0;
7317
- this.emitError({
7318
- extensionPath: ext.path,
7319
- event: "message_end",
7320
- error: message,
7321
- stack
7322
- });
7323
- }
7324
- }
7325
- return modified ? currentMessage : void 0;
7326
- }
7327
- async emitToolResult(event) {
7328
- let ctx = this.createContext(), currentEvent = { ...event }, modified = !1;
7329
- for (let ext of this.extensions) {
7330
- let handlers = ext.handlers.get("tool_result");
7331
- if (!(!handlers || handlers.length === 0))
7332
- for (let handler of handlers)
7333
- try {
7334
- let handlerResult = await handler(currentEvent, ctx);
7335
- if (!handlerResult)
7336
- continue;
7337
- handlerResult.content !== void 0 && (currentEvent.content = handlerResult.content, modified = !0), handlerResult.details !== void 0 && (currentEvent.details = handlerResult.details, modified = !0), handlerResult.isError !== void 0 && (currentEvent.isError = handlerResult.isError, modified = !0);
7338
- } catch (err) {
7339
- let message = err instanceof Error ? err.message : String(err), stack = err instanceof Error ? err.stack : void 0;
7340
- this.emitError({
7341
- extensionPath: ext.path,
7342
- event: "tool_result",
7343
- error: message,
7344
- stack
7345
- });
7346
- }
7347
- }
7348
- if (modified)
7349
- return {
7350
- content: currentEvent.content,
7351
- details: currentEvent.details,
7352
- isError: currentEvent.isError
7353
- };
7354
- }
7355
- async emitToolCall(event) {
7356
- let ctx = this.createContext(), result;
7357
- for (let ext of this.extensions) {
7358
- let handlers = ext.handlers.get("tool_call");
7359
- if (!(!handlers || handlers.length === 0))
7360
- for (let handler of handlers) {
7361
- let handlerResult = await handler(event, ctx);
7362
- if (handlerResult && (result = handlerResult, result.block))
7363
- return result;
7364
- }
7365
- }
7366
- return result;
7367
- }
7368
- async emitUserBash(event) {
7369
- let ctx = this.createContext();
7370
- for (let ext of this.extensions) {
7371
- let handlers = ext.handlers.get("user_bash");
7372
- if (!(!handlers || handlers.length === 0))
7373
- for (let handler of handlers)
7374
- try {
7375
- let handlerResult = await handler(event, ctx);
7376
- if (handlerResult)
7377
- return handlerResult;
7378
- } catch (err) {
7379
- let message = err instanceof Error ? err.message : String(err), stack = err instanceof Error ? err.stack : void 0;
7380
- this.emitError({
7381
- extensionPath: ext.path,
7382
- event: "user_bash",
7383
- error: message,
7384
- stack
7385
- });
7386
- }
7387
- }
7388
- }
7389
- async emitContext(messages) {
7390
- let ctx = this.createContext(), currentMessages = structuredClone(messages);
7391
- for (let ext of this.extensions) {
7392
- let handlers = ext.handlers.get("context");
7393
- if (!(!handlers || handlers.length === 0))
7394
- for (let handler of handlers)
7395
- try {
7396
- let handlerResult = await handler({ type: "context", messages: currentMessages }, ctx);
7397
- handlerResult && handlerResult.messages && (currentMessages = handlerResult.messages);
7398
- } catch (err) {
7399
- let message = err instanceof Error ? err.message : String(err), stack = err instanceof Error ? err.stack : void 0;
7400
- this.emitError({
7401
- extensionPath: ext.path,
7402
- event: "context",
7403
- error: message,
7404
- stack
7405
- });
7406
- }
7407
- }
7408
- return currentMessages;
7409
- }
7410
- async emitBeforeProviderRequest(payload) {
7411
- let ctx = this.createContext(), currentPayload = payload;
7412
- for (let ext of this.extensions) {
7413
- let handlers = ext.handlers.get("before_provider_request");
7414
- if (!(!handlers || handlers.length === 0))
7415
- for (let handler of handlers)
7416
- try {
7417
- let handlerResult = await handler({
7418
- type: "before_provider_request",
7419
- payload: currentPayload
7420
- }, ctx);
7421
- handlerResult !== void 0 && (currentPayload = handlerResult);
7422
- } catch (err) {
7423
- let message = err instanceof Error ? err.message : String(err), stack = err instanceof Error ? err.stack : void 0;
7424
- this.emitError({
7425
- extensionPath: ext.path,
7426
- event: "before_provider_request",
7427
- error: message,
7428
- stack
7429
- });
7430
- }
7431
- }
7432
- return currentPayload;
7433
- }
7434
- async emitBeforeProviderHeaders(headers) {
7435
- let ctx = this.createContext();
7436
- for (let ext of this.extensions) {
7437
- let handlers = ext.handlers.get("before_provider_headers");
7438
- if (!(!handlers || handlers.length === 0))
7439
- for (let handler of handlers)
7440
- try {
7441
- await handler({
7442
- type: "before_provider_headers",
7443
- headers
7444
- }, ctx);
7445
- } catch (err) {
7446
- let message = err instanceof Error ? err.message : String(err), stack = err instanceof Error ? err.stack : void 0;
7447
- this.emitError({
7448
- extensionPath: ext.path,
7449
- event: "before_provider_headers",
7450
- error: message,
7451
- stack
7452
- });
7453
- }
7454
- }
7455
- return headers;
7456
- }
7457
- async emitBeforeAgentStart(prompt, images, systemPrompt, systemPromptOptions) {
7458
- let currentSystemPrompt = systemPrompt, ctx = Object.defineProperties({}, Object.getOwnPropertyDescriptors(this.createContext()));
7459
- ctx.getSystemPrompt = () => (this.assertActive(), currentSystemPrompt);
7460
- let messages = [], systemPromptModified = !1;
7461
- for (let ext of this.extensions) {
7462
- let handlers = ext.handlers.get("before_agent_start");
7463
- if (!(!handlers || handlers.length === 0))
7464
- for (let handler of handlers)
7465
- try {
7466
- let handlerResult = await handler({
7467
- type: "before_agent_start",
7468
- prompt,
7469
- images,
7470
- systemPrompt: currentSystemPrompt,
7471
- systemPromptOptions
7472
- }, ctx);
7473
- if (handlerResult) {
7474
- let result = handlerResult;
7475
- result.message && messages.push(result.message), result.systemPrompt !== void 0 && (currentSystemPrompt = result.systemPrompt, systemPromptModified = !0);
7476
- }
7477
- } catch (err) {
7478
- let message = err instanceof Error ? err.message : String(err), stack = err instanceof Error ? err.stack : void 0;
7479
- this.emitError({
7480
- extensionPath: ext.path,
7481
- event: "before_agent_start",
7482
- error: message,
7483
- stack
7484
- });
7485
- }
7486
- }
7487
- if (messages.length > 0 || systemPromptModified)
7488
- return {
7489
- messages: messages.length > 0 ? messages : void 0,
7490
- systemPrompt: systemPromptModified ? currentSystemPrompt : void 0
7491
- };
7492
- }
7493
- async emitResourcesDiscover(cwd, reason) {
7494
- let ctx = this.createContext(), skillPaths = [], promptPaths = [], themePaths = [];
7495
- for (let ext of this.extensions) {
7496
- let handlers = ext.handlers.get("resources_discover");
7497
- if (!(!handlers || handlers.length === 0))
7498
- for (let handler of handlers)
7499
- try {
7500
- let result = await handler({ type: "resources_discover", cwd, reason }, ctx);
7501
- result?.skillPaths?.length && skillPaths.push(...result.skillPaths.map((path2) => ({ path: path2, extensionPath: ext.path }))), result?.promptPaths?.length && promptPaths.push(...result.promptPaths.map((path2) => ({ path: path2, extensionPath: ext.path }))), result?.themePaths?.length && themePaths.push(...result.themePaths.map((path2) => ({ path: path2, extensionPath: ext.path })));
7502
- } catch (err) {
7503
- let message = err instanceof Error ? err.message : String(err), stack = err instanceof Error ? err.stack : void 0;
7504
- this.emitError({
7505
- extensionPath: ext.path,
7506
- event: "resources_discover",
7507
- error: message,
7508
- stack
7509
- });
7510
- }
7511
- }
7512
- return { skillPaths, promptPaths, themePaths };
7513
- }
7514
- /** Emit input event. Transforms chain, "handled" short-circuits. */
7515
- async emitInput(text, images, source, streamingBehavior) {
7516
- let ctx = this.createContext(), currentText = text, currentImages = images;
7517
- for (let ext of this.extensions)
7518
- for (let handler of ext.handlers.get("input") ?? [])
7519
- try {
7520
- let result = await handler({
7521
- type: "input",
7522
- text: currentText,
7523
- images: currentImages,
7524
- source,
7525
- streamingBehavior
7526
- }, ctx);
7527
- if (result?.action === "handled")
7528
- return result;
7529
- result?.action === "transform" && (currentText = result.text, currentImages = result.images ?? currentImages);
7530
- } catch (err) {
7531
- this.emitError({
7532
- extensionPath: ext.path,
7533
- event: "input",
7534
- error: err instanceof Error ? err.message : String(err),
7535
- stack: err instanceof Error ? err.stack : void 0
7536
- });
7537
- }
7538
- return currentText !== text || currentImages !== images ? { action: "transform", text: currentText, images: currentImages } : { action: "continue" };
7539
- }
7540
- };
7541
-
7542
5546
  export {
7543
- createEventBus,
7544
- createSyntheticSourceInfo,
7545
- createExtensionRuntime,
7546
- discoverAndLoadExtensions,
5547
+ require_ignore,
7547
5548
  parseGitUrl,
7548
- DefaultPackageManager,
7549
- expandPromptTemplate,
7550
- loadSkillsFromDir,
7551
- formatSkillsForPrompt,
7552
- loadSkills,
7553
- loadProjectContextFiles,
7554
- DefaultResourceLoader,
7555
- emitSessionShutdownEvent,
7556
- emitProjectTrustEvent,
7557
- ExtensionRunner
5549
+ DefaultPackageManager
7558
5550
  };