@greppleai/grip 0.1.5 → 0.1.7

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 (587) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/README.md +1 -1
  3. package/dist/bun/cli.d.ts.map +1 -1
  4. package/dist/bun/cli.js.map +1 -1
  5. package/dist/bun/embedded-assets.d.ts.map +1 -1
  6. package/dist/bun/embedded-assets.js.map +1 -1
  7. package/dist/bun/register-bedrock.d.ts.map +1 -1
  8. package/dist/bun/restore-sandbox-env.d.ts.map +1 -1
  9. package/dist/bun/restore-sandbox-env.js.map +1 -1
  10. package/dist/cli/args.d.ts.map +1 -1
  11. package/dist/cli/args.js.map +1 -1
  12. package/dist/cli/config-selector.d.ts.map +1 -1
  13. package/dist/cli/config-selector.js.map +1 -1
  14. package/dist/cli/file-processor.d.ts.map +1 -1
  15. package/dist/cli/file-processor.js.map +1 -1
  16. package/dist/cli/initial-message.d.ts +1 -1
  17. package/dist/cli/initial-message.d.ts.map +1 -1
  18. package/dist/cli/initial-message.js.map +1 -1
  19. package/dist/cli/list-models.d.ts.map +1 -1
  20. package/dist/cli/list-models.js.map +1 -1
  21. package/dist/cli/session-picker.d.ts.map +1 -1
  22. package/dist/cli/session-picker.js.map +1 -1
  23. package/dist/cli.d.ts.map +1 -1
  24. package/dist/cli.js.map +1 -1
  25. package/dist/config.d.ts.map +1 -1
  26. package/dist/config.js +2 -0
  27. package/dist/config.js.map +1 -1
  28. package/dist/core/agent-session.d.ts +38 -1
  29. package/dist/core/agent-session.d.ts.map +1 -1
  30. package/dist/core/agent-session.js +289 -154
  31. package/dist/core/agent-session.js.map +1 -1
  32. package/dist/core/auth-guidance.d.ts.map +1 -1
  33. package/dist/core/auth-guidance.js.map +1 -1
  34. package/dist/core/auth-storage.d.ts +4 -0
  35. package/dist/core/auth-storage.d.ts.map +1 -1
  36. package/dist/core/auth-storage.js +3 -10
  37. package/dist/core/auth-storage.js.map +1 -1
  38. package/dist/core/bash-executor.d.ts.map +1 -1
  39. package/dist/core/bash-executor.js +19 -23
  40. package/dist/core/bash-executor.js.map +1 -1
  41. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  42. package/dist/core/compaction/branch-summarization.js.map +1 -1
  43. package/dist/core/compaction/compaction.d.ts.map +1 -1
  44. package/dist/core/compaction/compaction.js +9 -2
  45. package/dist/core/compaction/compaction.js.map +1 -1
  46. package/dist/core/compaction/compression-detection-ledger.d.ts.map +1 -1
  47. package/dist/core/compaction/compression-detection-ledger.js.map +1 -1
  48. package/dist/core/compaction/compression-detector.d.ts +1 -0
  49. package/dist/core/compaction/compression-detector.d.ts.map +1 -1
  50. package/dist/core/compaction/compression-detector.js +10 -21
  51. package/dist/core/compaction/compression-detector.js.map +1 -1
  52. package/dist/core/compaction/compression-economics.d.ts.map +1 -1
  53. package/dist/core/compaction/compression-economics.js.map +1 -1
  54. package/dist/core/compaction/utils.d.ts.map +1 -1
  55. package/dist/core/compaction/utils.js.map +1 -1
  56. package/dist/core/defaults.d.ts.map +1 -1
  57. package/dist/core/diagnostics.d.ts.map +1 -1
  58. package/dist/core/event-bus.d.ts.map +1 -1
  59. package/dist/core/event-bus.js.map +1 -1
  60. package/dist/core/exec.d.ts.map +1 -1
  61. package/dist/core/exec.js.map +1 -1
  62. package/dist/core/export-html/ansi-to-html.d.ts.map +1 -1
  63. package/dist/core/export-html/ansi-to-html.js.map +1 -1
  64. package/dist/core/export-html/index.d.ts.map +1 -1
  65. package/dist/core/export-html/index.js.map +1 -1
  66. package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
  67. package/dist/core/export-html/tool-renderer.js.map +1 -1
  68. package/dist/core/extensions/loader.d.ts.map +1 -1
  69. package/dist/core/extensions/loader.js.map +1 -1
  70. package/dist/core/extensions/runner.d.ts +3 -0
  71. package/dist/core/extensions/runner.d.ts.map +1 -1
  72. package/dist/core/extensions/runner.js +40 -30
  73. package/dist/core/extensions/runner.js.map +1 -1
  74. package/dist/core/extensions/types.d.ts +21 -1
  75. package/dist/core/extensions/types.d.ts.map +1 -1
  76. package/dist/core/extensions/types.js.map +1 -1
  77. package/dist/core/extensions/wrapper.d.ts.map +1 -1
  78. package/dist/core/extensions/wrapper.js.map +1 -1
  79. package/dist/core/footer-data-provider.d.ts.map +1 -1
  80. package/dist/core/footer-data-provider.js +15 -16
  81. package/dist/core/footer-data-provider.js.map +1 -1
  82. package/dist/core/grip-agent.d.ts.map +1 -1
  83. package/dist/core/grip-agent.js +7 -21
  84. package/dist/core/grip-agent.js.map +1 -1
  85. package/dist/core/grip-manifest.d.ts.map +1 -1
  86. package/dist/core/grip-manifest.js.map +1 -1
  87. package/dist/core/hooks/aggregate.d.ts.map +1 -1
  88. package/dist/core/hooks/aggregate.js.map +1 -1
  89. package/dist/core/hooks/config.d.ts.map +1 -1
  90. package/dist/core/hooks/config.js.map +1 -1
  91. package/dist/core/hooks/executor.d.ts.map +1 -1
  92. package/dist/core/hooks/executor.js.map +1 -1
  93. package/dist/core/hooks/index.d.ts.map +1 -1
  94. package/dist/core/hooks/index.js.map +1 -1
  95. package/dist/core/hooks/matcher.d.ts.map +1 -1
  96. package/dist/core/hooks/matcher.js.map +1 -1
  97. package/dist/core/hooks/trust-store.d.ts.map +1 -1
  98. package/dist/core/hooks/trust-store.js +0 -3
  99. package/dist/core/hooks/trust-store.js.map +1 -1
  100. package/dist/core/hooks/types.d.ts.map +1 -1
  101. package/dist/core/hooks/types.js.map +1 -1
  102. package/dist/core/http-dispatcher.d.ts.map +1 -1
  103. package/dist/core/http-dispatcher.js.map +1 -1
  104. package/dist/core/instruction-resource-loader.d.ts +1 -0
  105. package/dist/core/instruction-resource-loader.d.ts.map +1 -1
  106. package/dist/core/instruction-resource-loader.js +2 -4
  107. package/dist/core/instruction-resource-loader.js.map +1 -1
  108. package/dist/core/keybindings.d.ts.map +1 -1
  109. package/dist/core/keybindings.js +0 -1
  110. package/dist/core/keybindings.js.map +1 -1
  111. package/dist/core/lsp/abort.d.ts.map +1 -1
  112. package/dist/core/lsp/abort.js.map +1 -1
  113. package/dist/core/lsp/client.d.ts.map +1 -1
  114. package/dist/core/lsp/client.js +8 -22
  115. package/dist/core/lsp/client.js.map +1 -1
  116. package/dist/core/lsp/config-loader.d.ts.map +1 -1
  117. package/dist/core/lsp/config-loader.js.map +1 -1
  118. package/dist/core/lsp/config.d.ts.map +1 -1
  119. package/dist/core/lsp/config.js.map +1 -1
  120. package/dist/core/lsp/diagnostics.d.ts.map +1 -1
  121. package/dist/core/lsp/diagnostics.js.map +1 -1
  122. package/dist/core/lsp/file-sync.d.ts.map +1 -1
  123. package/dist/core/lsp/file-sync.js +7 -9
  124. package/dist/core/lsp/file-sync.js.map +1 -1
  125. package/dist/core/lsp/integration.d.ts.map +1 -1
  126. package/dist/core/lsp/integration.js.map +1 -1
  127. package/dist/core/lsp/language-map.d.ts.map +1 -1
  128. package/dist/core/lsp/language-map.js +2 -7
  129. package/dist/core/lsp/language-map.js.map +1 -1
  130. package/dist/core/lsp/manager.d.ts.map +1 -1
  131. package/dist/core/lsp/manager.js +18 -29
  132. package/dist/core/lsp/manager.js.map +1 -1
  133. package/dist/core/lsp/navigation.d.ts.map +1 -1
  134. package/dist/core/lsp/navigation.js.map +1 -1
  135. package/dist/core/lsp/portable-path.d.ts.map +1 -1
  136. package/dist/core/lsp/portable-path.js.map +1 -1
  137. package/dist/core/lsp/refactor.d.ts.map +1 -1
  138. package/dist/core/lsp/refactor.js.map +1 -1
  139. package/dist/core/lsp/transport.d.ts.map +1 -1
  140. package/dist/core/lsp/transport.js.map +1 -1
  141. package/dist/core/messages.d.ts.map +1 -1
  142. package/dist/core/messages.js +30 -1
  143. package/dist/core/messages.js.map +1 -1
  144. package/dist/core/model-registry.d.ts.map +1 -1
  145. package/dist/core/model-registry.js +5 -7
  146. package/dist/core/model-registry.js.map +1 -1
  147. package/dist/core/model-resolver.d.ts.map +1 -1
  148. package/dist/core/model-resolver.js.map +1 -1
  149. package/dist/core/output-guard.d.ts.map +1 -1
  150. package/dist/core/output-guard.js.map +1 -1
  151. package/dist/core/package-manager.d.ts.map +1 -1
  152. package/dist/core/package-manager.js +0 -6
  153. package/dist/core/package-manager.js.map +1 -1
  154. package/dist/core/prompt-templates.d.ts.map +1 -1
  155. package/dist/core/prompt-templates.js.map +1 -1
  156. package/dist/core/provider-display-names.d.ts.map +1 -1
  157. package/dist/core/remote-workspace-protocol/contract.d.ts.map +1 -1
  158. package/dist/core/remote-workspace-protocol/contract.js +4 -2
  159. package/dist/core/remote-workspace-protocol/contract.js.map +1 -1
  160. package/dist/core/remote-workspace-protocol/guest-shared-client.d.ts.map +1 -1
  161. package/dist/core/remote-workspace-protocol/guest-shared-client.js +1 -5
  162. package/dist/core/remote-workspace-protocol/guest-shared-client.js.map +1 -1
  163. package/dist/core/remote-workspace-protocol/guest-shared-outbound-scheduler.d.ts.map +1 -1
  164. package/dist/core/remote-workspace-protocol/guest-shared-outbound-scheduler.js +5 -10
  165. package/dist/core/remote-workspace-protocol/guest-shared-outbound-scheduler.js.map +1 -1
  166. package/dist/core/remote-workspace-protocol/guest-shared-uplink.d.ts.map +1 -1
  167. package/dist/core/remote-workspace-protocol/guest-shared-uplink.js +2 -9
  168. package/dist/core/remote-workspace-protocol/guest-shared-uplink.js.map +1 -1
  169. package/dist/core/remote-workspace-protocol/lima-owner-directory.d.ts.map +1 -1
  170. package/dist/core/remote-workspace-protocol/lima-owner-directory.js.map +1 -1
  171. package/dist/core/remote-workspace-protocol/lima-owner-lock.d.ts.map +1 -1
  172. package/dist/core/remote-workspace-protocol/lima-owner-lock.js.map +1 -1
  173. package/dist/core/remote-workspace-protocol/session.d.ts.map +1 -1
  174. package/dist/core/remote-workspace-protocol/session.js +27 -65
  175. package/dist/core/remote-workspace-protocol/session.js.map +1 -1
  176. package/dist/core/remote-workspace-protocol/shared-transport.d.ts.map +1 -1
  177. package/dist/core/remote-workspace-protocol/shared-transport.js.map +1 -1
  178. package/dist/core/resolve-config-value.d.ts.map +1 -1
  179. package/dist/core/resolve-config-value.js.map +1 -1
  180. package/dist/core/resource-loader.d.ts.map +1 -1
  181. package/dist/core/resource-loader.js +0 -48
  182. package/dist/core/resource-loader.js.map +1 -1
  183. package/dist/core/rules.d.ts.map +1 -1
  184. package/dist/core/rules.js.map +1 -1
  185. package/dist/core/sandbox/command.d.ts.map +1 -1
  186. package/dist/core/sandbox/command.js.map +1 -1
  187. package/dist/core/sandbox/config.d.ts.map +1 -1
  188. package/dist/core/sandbox/config.js.map +1 -1
  189. package/dist/core/sandbox/lima-guest-binary.d.ts.map +1 -1
  190. package/dist/core/sandbox/lima-guest-binary.js.map +1 -1
  191. package/dist/core/sandbox/lima.d.ts +2 -0
  192. package/dist/core/sandbox/lima.d.ts.map +1 -1
  193. package/dist/core/sandbox/lima.js +3 -9
  194. package/dist/core/sandbox/lima.js.map +1 -1
  195. package/dist/core/sandbox/shared-lima-roots.d.ts.map +1 -1
  196. package/dist/core/sandbox/shared-lima-roots.js.map +1 -1
  197. package/dist/core/sandbox/update-shared-guest-binary.d.ts.map +1 -1
  198. package/dist/core/sandbox/update-shared-guest-binary.js.map +1 -1
  199. package/dist/core/session/constants.d.ts.map +1 -1
  200. package/dist/core/session/context-metadata.d.ts.map +1 -1
  201. package/dist/core/session/context-metadata.js.map +1 -1
  202. package/dist/core/session/context.d.ts.map +1 -1
  203. package/dist/core/session/context.js.map +1 -1
  204. package/dist/core/session/ids.d.ts.map +1 -1
  205. package/dist/core/session/ids.js.map +1 -1
  206. package/dist/core/session/in-memory-session-manager.d.ts.map +1 -1
  207. package/dist/core/session/in-memory-session-manager.js +0 -1
  208. package/dist/core/session/in-memory-session-manager.js.map +1 -1
  209. package/dist/core/session/in-memory-session.d.ts.map +1 -1
  210. package/dist/core/session/in-memory-session.js.map +1 -1
  211. package/dist/core/session/jsonl-errors.d.ts.map +1 -1
  212. package/dist/core/session/jsonl-errors.js +0 -11
  213. package/dist/core/session/jsonl-errors.js.map +1 -1
  214. package/dist/core/session/jsonl-helpers.d.ts.map +1 -1
  215. package/dist/core/session/jsonl-helpers.js.map +1 -1
  216. package/dist/core/session/local-session-manager.d.ts.map +1 -1
  217. package/dist/core/session/local-session-manager.js +4 -6
  218. package/dist/core/session/local-session-manager.js.map +1 -1
  219. package/dist/core/session/local-session.d.ts.map +1 -1
  220. package/dist/core/session/local-session.js.map +1 -1
  221. package/dist/core/session/migrations.d.ts.map +1 -1
  222. package/dist/core/session/migrations.js.map +1 -1
  223. package/dist/core/session/remote-session-client.d.ts.map +1 -1
  224. package/dist/core/session/remote-session-client.js +0 -6
  225. package/dist/core/session/remote-session-client.js.map +1 -1
  226. package/dist/core/session/remote-session-manager.d.ts.map +1 -1
  227. package/dist/core/session/remote-session-manager.js +0 -3
  228. package/dist/core/session/remote-session-manager.js.map +1 -1
  229. package/dist/core/session/remote-session.d.ts.map +1 -1
  230. package/dist/core/session/remote-session.js +0 -1
  231. package/dist/core/session/remote-session.js.map +1 -1
  232. package/dist/core/session/session-manager.d.ts.map +1 -1
  233. package/dist/core/session/session.d.ts.map +1 -1
  234. package/dist/core/session/session.js +1 -5
  235. package/dist/core/session/session.js.map +1 -1
  236. package/dist/core/session/stores/in-memory-session-store.d.ts.map +1 -1
  237. package/dist/core/session/stores/in-memory-session-store.js +7 -6
  238. package/dist/core/session/stores/in-memory-session-store.js.map +1 -1
  239. package/dist/core/session/stores/jsonl-session-store.d.ts.map +1 -1
  240. package/dist/core/session/stores/jsonl-session-store.js +6 -14
  241. package/dist/core/session/stores/jsonl-session-store.js.map +1 -1
  242. package/dist/core/session/stores/remote-session-store.d.ts.map +1 -1
  243. package/dist/core/session/stores/remote-session-store.js +3 -8
  244. package/dist/core/session/stores/remote-session-store.js.map +1 -1
  245. package/dist/core/session/stores/session-store.d.ts.map +1 -1
  246. package/dist/core/session/types.d.ts.map +1 -1
  247. package/dist/core/session/usage-ledger.d.ts.map +1 -1
  248. package/dist/core/session/usage-ledger.js.map +1 -1
  249. package/dist/core/session-cwd.d.ts.map +1 -1
  250. package/dist/core/session-cwd.js +0 -1
  251. package/dist/core/session-cwd.js.map +1 -1
  252. package/dist/core/settings-manager.d.ts.map +1 -1
  253. package/dist/core/settings-manager.js +9 -17
  254. package/dist/core/settings-manager.js.map +1 -1
  255. package/dist/core/skills.d.ts.map +1 -1
  256. package/dist/core/skills.js +3 -2
  257. package/dist/core/skills.js.map +1 -1
  258. package/dist/core/slash-commands.d.ts.map +1 -1
  259. package/dist/core/source-info.d.ts.map +1 -1
  260. package/dist/core/source-info.js.map +1 -1
  261. package/dist/core/system-prompt.d.ts +1 -1
  262. package/dist/core/system-prompt.d.ts.map +1 -1
  263. package/dist/core/system-prompt.js +3 -2
  264. package/dist/core/system-prompt.js.map +1 -1
  265. package/dist/core/telemetry.d.ts.map +1 -1
  266. package/dist/core/telemetry.js.map +1 -1
  267. package/dist/core/timings.d.ts.map +1 -1
  268. package/dist/core/timings.js.map +1 -1
  269. package/dist/core/tools/bash.d.ts +1 -0
  270. package/dist/core/tools/bash.d.ts.map +1 -1
  271. package/dist/core/tools/bash.js +34 -28
  272. package/dist/core/tools/bash.js.map +1 -1
  273. package/dist/core/tools/compress-context.d.ts.map +1 -1
  274. package/dist/core/tools/compress-context.js.map +1 -1
  275. package/dist/core/tools/edit-diff.d.ts.map +1 -1
  276. package/dist/core/tools/edit-diff.js.map +1 -1
  277. package/dist/core/tools/edit.d.ts.map +1 -1
  278. package/dist/core/tools/edit.js.map +1 -1
  279. package/dist/core/tools/file-mutation-queue.d.ts.map +1 -1
  280. package/dist/core/tools/file-mutation-queue.js.map +1 -1
  281. package/dist/core/tools/find.d.ts.map +1 -1
  282. package/dist/core/tools/find.js.map +1 -1
  283. package/dist/core/tools/grep.d.ts.map +1 -1
  284. package/dist/core/tools/grep.js.map +1 -1
  285. package/dist/core/tools/hash-store.d.ts.map +1 -1
  286. package/dist/core/tools/hash-store.js.map +1 -1
  287. package/dist/core/tools/hashline/apply.d.ts.map +1 -1
  288. package/dist/core/tools/hashline/apply.js.map +1 -1
  289. package/dist/core/tools/hashline/hash.d.ts.map +1 -1
  290. package/dist/core/tools/hashline/hash.js.map +1 -1
  291. package/dist/core/tools/hashline/parse.d.ts.map +1 -1
  292. package/dist/core/tools/hashline/parse.js.map +1 -1
  293. package/dist/core/tools/hashline/resolve.d.ts.map +1 -1
  294. package/dist/core/tools/hashline/resolve.js.map +1 -1
  295. package/dist/core/tools/hashline-utils.d.ts.map +1 -1
  296. package/dist/core/tools/hashline-utils.js.map +1 -1
  297. package/dist/core/tools/index.d.ts.map +1 -1
  298. package/dist/core/tools/index.js.map +1 -1
  299. package/dist/core/tools/ls.d.ts.map +1 -1
  300. package/dist/core/tools/ls.js.map +1 -1
  301. package/dist/core/tools/operations.d.ts +11 -0
  302. package/dist/core/tools/operations.d.ts.map +1 -1
  303. package/dist/core/tools/operations.js +54 -28
  304. package/dist/core/tools/operations.js.map +1 -1
  305. package/dist/core/tools/output-accumulator.d.ts.map +1 -1
  306. package/dist/core/tools/output-accumulator.js +12 -18
  307. package/dist/core/tools/output-accumulator.js.map +1 -1
  308. package/dist/core/tools/path-utils.d.ts.map +1 -1
  309. package/dist/core/tools/path-utils.js.map +1 -1
  310. package/dist/core/tools/read.d.ts.map +1 -1
  311. package/dist/core/tools/read.js.map +1 -1
  312. package/dist/core/tools/render-utils.d.ts.map +1 -1
  313. package/dist/core/tools/render-utils.js.map +1 -1
  314. package/dist/core/tools/replace-diff.d.ts.map +1 -1
  315. package/dist/core/tools/replace-diff.js.map +1 -1
  316. package/dist/core/tools/replace-normalize.d.ts.map +1 -1
  317. package/dist/core/tools/replace-normalize.js.map +1 -1
  318. package/dist/core/tools/replace-render.d.ts +1 -1
  319. package/dist/core/tools/replace-render.d.ts.map +1 -1
  320. package/dist/core/tools/replace-render.js.map +1 -1
  321. package/dist/core/tools/runtime.d.ts.map +1 -1
  322. package/dist/core/tools/runtime.js.map +1 -1
  323. package/dist/core/tools/session-history.d.ts.map +1 -1
  324. package/dist/core/tools/session-history.js.map +1 -1
  325. package/dist/core/tools/subagent-agents.d.ts.map +1 -1
  326. package/dist/core/tools/subagent-agents.js.map +1 -1
  327. package/dist/core/tools/subagent.d.ts.map +1 -1
  328. package/dist/core/tools/subagent.js.map +1 -1
  329. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
  330. package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
  331. package/dist/core/tools/truncate.d.ts.map +1 -1
  332. package/dist/core/tools/truncate.js.map +1 -1
  333. package/dist/core/tools/websearch.d.ts.map +1 -1
  334. package/dist/core/tools/websearch.js.map +1 -1
  335. package/dist/core/tools/workspace-tool-host.d.ts +1 -0
  336. package/dist/core/tools/workspace-tool-host.d.ts.map +1 -1
  337. package/dist/core/tools/workspace-tool-host.js +36 -22
  338. package/dist/core/tools/workspace-tool-host.js.map +1 -1
  339. package/dist/core/tools/write.d.ts.map +1 -1
  340. package/dist/core/tools/write.js +0 -1
  341. package/dist/core/tools/write.js.map +1 -1
  342. package/dist/core/workspace-identity.d.ts.map +1 -1
  343. package/dist/daemon/activity-budget.d.ts.map +1 -1
  344. package/dist/daemon/activity-budget.js +2 -3
  345. package/dist/daemon/activity-budget.js.map +1 -1
  346. package/dist/daemon/command.d.ts.map +1 -1
  347. package/dist/daemon/command.js.map +1 -1
  348. package/dist/daemon/config.d.ts +2 -0
  349. package/dist/daemon/config.d.ts.map +1 -1
  350. package/dist/daemon/config.js +4 -0
  351. package/dist/daemon/config.js.map +1 -1
  352. package/dist/daemon/help.d.ts.map +1 -1
  353. package/dist/daemon/help.js +4 -3
  354. package/dist/daemon/help.js.map +1 -1
  355. package/dist/daemon/lsp-config.d.ts.map +1 -1
  356. package/dist/daemon/lsp-config.js.map +1 -1
  357. package/dist/daemon/outbound-budget.d.ts.map +1 -1
  358. package/dist/daemon/outbound-budget.js +2 -4
  359. package/dist/daemon/outbound-budget.js.map +1 -1
  360. package/dist/daemon/security.d.ts.map +1 -1
  361. package/dist/daemon/security.js.map +1 -1
  362. package/dist/daemon/server.d.ts.map +1 -1
  363. package/dist/daemon/server.js.map +1 -1
  364. package/dist/daemon/shared-connection.d.ts.map +1 -1
  365. package/dist/daemon/shared-connection.js +10 -15
  366. package/dist/daemon/shared-connection.js.map +1 -1
  367. package/dist/daemon/shared-revision.d.ts.map +1 -1
  368. package/dist/daemon/shared-revision.js +2 -1
  369. package/dist/daemon/shared-revision.js.map +1 -1
  370. package/dist/daemon/shared-roots.d.ts.map +1 -1
  371. package/dist/daemon/shared-roots.js +0 -1
  372. package/dist/daemon/shared-roots.js.map +1 -1
  373. package/dist/daemon/workspace-runtime.d.ts +2 -0
  374. package/dist/daemon/workspace-runtime.d.ts.map +1 -1
  375. package/dist/daemon/workspace-runtime.js +43 -15
  376. package/dist/daemon/workspace-runtime.js.map +1 -1
  377. package/dist/index.d.ts +1 -1
  378. package/dist/index.d.ts.map +1 -1
  379. package/dist/index.js.map +1 -1
  380. package/dist/main.d.ts.map +1 -1
  381. package/dist/main.js +8 -3
  382. package/dist/main.js.map +1 -1
  383. package/dist/migrations.d.ts.map +1 -1
  384. package/dist/migrations.js.map +1 -1
  385. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  386. package/dist/modes/interactive/components/assistant-message.js +3 -10
  387. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  388. package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
  389. package/dist/modes/interactive/components/bash-execution.js +4 -9
  390. package/dist/modes/interactive/components/bash-execution.js.map +1 -1
  391. package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -1
  392. package/dist/modes/interactive/components/bordered-loader.js +0 -3
  393. package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
  394. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
  395. package/dist/modes/interactive/components/branch-summary-message.js +1 -3
  396. package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
  397. package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
  398. package/dist/modes/interactive/components/compaction-summary-message.js +1 -3
  399. package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
  400. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
  401. package/dist/modes/interactive/components/config-selector.js +6 -16
  402. package/dist/modes/interactive/components/config-selector.js.map +1 -1
  403. package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -1
  404. package/dist/modes/interactive/components/countdown-timer.js +0 -5
  405. package/dist/modes/interactive/components/countdown-timer.js.map +1 -1
  406. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
  407. package/dist/modes/interactive/components/custom-editor.js +1 -8
  408. package/dist/modes/interactive/components/custom-editor.js.map +1 -1
  409. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  410. package/dist/modes/interactive/components/custom-message.js +1 -6
  411. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  412. package/dist/modes/interactive/components/diff.d.ts.map +1 -1
  413. package/dist/modes/interactive/components/diff.js.map +1 -1
  414. package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -1
  415. package/dist/modes/interactive/components/dynamic-border.js +0 -1
  416. package/dist/modes/interactive/components/dynamic-border.js.map +1 -1
  417. package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
  418. package/dist/modes/interactive/components/extension-editor.js +1 -7
  419. package/dist/modes/interactive/components/extension-editor.js.map +1 -1
  420. package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
  421. package/dist/modes/interactive/components/extension-input.js +2 -8
  422. package/dist/modes/interactive/components/extension-input.js.map +1 -1
  423. package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
  424. package/dist/modes/interactive/components/extension-selector.js +1 -9
  425. package/dist/modes/interactive/components/extension-selector.js.map +1 -1
  426. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  427. package/dist/modes/interactive/components/footer.js +8 -4
  428. package/dist/modes/interactive/components/footer.js.map +1 -1
  429. package/dist/modes/interactive/components/hook-execution.d.ts.map +1 -1
  430. package/dist/modes/interactive/components/hook-execution.js +2 -5
  431. package/dist/modes/interactive/components/hook-execution.js.map +1 -1
  432. package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -1
  433. package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
  434. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
  435. package/dist/modes/interactive/components/login-dialog.js +3 -9
  436. package/dist/modes/interactive/components/login-dialog.js.map +1 -1
  437. package/dist/modes/interactive/components/markdown-transform.d.ts.map +1 -1
  438. package/dist/modes/interactive/components/markdown-transform.js.map +1 -1
  439. package/dist/modes/interactive/components/mermaid.d.ts.map +1 -1
  440. package/dist/modes/interactive/components/mermaid.js.map +1 -1
  441. package/dist/modes/interactive/components/message-card.d.ts.map +1 -1
  442. package/dist/modes/interactive/components/message-card.js +0 -1
  443. package/dist/modes/interactive/components/message-card.js.map +1 -1
  444. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  445. package/dist/modes/interactive/components/model-selector.js +13 -28
  446. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  447. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  448. package/dist/modes/interactive/components/oauth-selector.js +3 -12
  449. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  450. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
  451. package/dist/modes/interactive/components/scoped-models-selector.js +9 -13
  452. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
  453. package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -1
  454. package/dist/modes/interactive/components/session-selector-search.js.map +1 -1
  455. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  456. package/dist/modes/interactive/components/session-selector.js +33 -58
  457. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  458. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  459. package/dist/modes/interactive/components/settings-selector.js +0 -4
  460. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  461. package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -1
  462. package/dist/modes/interactive/components/show-images-selector.js +0 -1
  463. package/dist/modes/interactive/components/show-images-selector.js.map +1 -1
  464. package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
  465. package/dist/modes/interactive/components/skill-invocation-message.js +1 -3
  466. package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
  467. package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -1
  468. package/dist/modes/interactive/components/theme-selector.js +0 -2
  469. package/dist/modes/interactive/components/theme-selector.js.map +1 -1
  470. package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
  471. package/dist/modes/interactive/components/thinking-selector.js +0 -1
  472. package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
  473. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  474. package/dist/modes/interactive/components/tool-execution.js +9 -24
  475. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  476. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
  477. package/dist/modes/interactive/components/tree-selector.js +18 -34
  478. package/dist/modes/interactive/components/tree-selector.js.map +1 -1
  479. package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -1
  480. package/dist/modes/interactive/components/user-message-selector.js +3 -6
  481. package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
  482. package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
  483. package/dist/modes/interactive/components/user-message.js +0 -4
  484. package/dist/modes/interactive/components/user-message.js.map +1 -1
  485. package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -1
  486. package/dist/modes/interactive/components/visual-truncate.js.map +1 -1
  487. package/dist/modes/interactive/interactive-mode.d.ts +13 -0
  488. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  489. package/dist/modes/interactive/interactive-mode.js +162 -136
  490. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  491. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  492. package/dist/modes/interactive/theme/theme.js +0 -7
  493. package/dist/modes/interactive/theme/theme.js.map +1 -1
  494. package/dist/modes/json-event.d.ts.map +1 -1
  495. package/dist/modes/json-event.js.map +1 -1
  496. package/dist/modes/print-mode.d.ts.map +1 -1
  497. package/dist/modes/print-mode.js.map +1 -1
  498. package/dist/modes/rpc/jsonl.d.ts.map +1 -1
  499. package/dist/modes/rpc/jsonl.js.map +1 -1
  500. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  501. package/dist/modes/rpc/rpc-client.js +10 -11
  502. package/dist/modes/rpc/rpc-client.js.map +1 -1
  503. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  504. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  505. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  506. package/dist/package-manager-cli.d.ts.map +1 -1
  507. package/dist/package-manager-cli.js +33 -2
  508. package/dist/package-manager-cli.js.map +1 -1
  509. package/dist/utils/ansi.d.ts.map +1 -1
  510. package/dist/utils/ansi.js.map +1 -1
  511. package/dist/utils/binary-self-update.d.ts +25 -0
  512. package/dist/utils/binary-self-update.d.ts.map +1 -0
  513. package/dist/utils/binary-self-update.js +159 -0
  514. package/dist/utils/binary-self-update.js.map +1 -0
  515. package/dist/utils/changelog.d.ts.map +1 -1
  516. package/dist/utils/changelog.js.map +1 -1
  517. package/dist/utils/child-process.d.ts.map +1 -1
  518. package/dist/utils/child-process.js.map +1 -1
  519. package/dist/utils/clipboard-image.d.ts.map +1 -1
  520. package/dist/utils/clipboard-image.js.map +1 -1
  521. package/dist/utils/clipboard-native.d.ts.map +1 -1
  522. package/dist/utils/clipboard-native.js.map +1 -1
  523. package/dist/utils/clipboard.d.ts.map +1 -1
  524. package/dist/utils/clipboard.js.map +1 -1
  525. package/dist/utils/deprecation.d.ts.map +1 -1
  526. package/dist/utils/deprecation.js.map +1 -1
  527. package/dist/utils/directory-completions.d.ts +8 -0
  528. package/dist/utils/directory-completions.d.ts.map +1 -1
  529. package/dist/utils/directory-completions.js +42 -1
  530. package/dist/utils/directory-completions.js.map +1 -1
  531. package/dist/utils/exif-orientation.d.ts.map +1 -1
  532. package/dist/utils/exif-orientation.js.map +1 -1
  533. package/dist/utils/frontmatter.d.ts.map +1 -1
  534. package/dist/utils/frontmatter.js.map +1 -1
  535. package/dist/utils/fs-watch.d.ts.map +1 -1
  536. package/dist/utils/fs-watch.js.map +1 -1
  537. package/dist/utils/git.d.ts.map +1 -1
  538. package/dist/utils/git.js.map +1 -1
  539. package/dist/utils/grip-user-agent.d.ts.map +1 -1
  540. package/dist/utils/grip-user-agent.js.map +1 -1
  541. package/dist/utils/html.d.ts.map +1 -1
  542. package/dist/utils/html.js.map +1 -1
  543. package/dist/utils/image-convert.d.ts.map +1 -1
  544. package/dist/utils/image-convert.js.map +1 -1
  545. package/dist/utils/image-process.d.ts.map +1 -1
  546. package/dist/utils/image-process.js.map +1 -1
  547. package/dist/utils/image-resize-core.d.ts.map +1 -1
  548. package/dist/utils/image-resize-core.js.map +1 -1
  549. package/dist/utils/image-resize-worker.d.ts.map +1 -1
  550. package/dist/utils/image-resize-worker.js.map +1 -1
  551. package/dist/utils/image-resize.d.ts.map +1 -1
  552. package/dist/utils/image-resize.js.map +1 -1
  553. package/dist/utils/json.d.ts.map +1 -1
  554. package/dist/utils/json.js.map +1 -1
  555. package/dist/utils/mime.d.ts.map +1 -1
  556. package/dist/utils/mime.js.map +1 -1
  557. package/dist/utils/open-browser.d.ts.map +1 -1
  558. package/dist/utils/open-browser.js.map +1 -1
  559. package/dist/utils/paths.d.ts.map +1 -1
  560. package/dist/utils/paths.js.map +1 -1
  561. package/dist/utils/photon.d.ts.map +1 -1
  562. package/dist/utils/photon.js +10 -5
  563. package/dist/utils/photon.js.map +1 -1
  564. package/dist/utils/shell.d.ts.map +1 -1
  565. package/dist/utils/shell.js.map +1 -1
  566. package/dist/utils/sleep.d.ts.map +1 -1
  567. package/dist/utils/sleep.js.map +1 -1
  568. package/dist/utils/syntax-highlight.d.ts.map +1 -1
  569. package/dist/utils/syntax-highlight.js +1 -1
  570. package/dist/utils/syntax-highlight.js.map +1 -1
  571. package/dist/utils/tools-manager.d.ts.map +1 -1
  572. package/dist/utils/tools-manager.js.map +1 -1
  573. package/dist/utils/version-check.d.ts.map +1 -1
  574. package/dist/utils/version-check.js.map +1 -1
  575. package/dist/utils/windows-self-update.d.ts.map +1 -1
  576. package/dist/utils/windows-self-update.js.map +1 -1
  577. package/docs/extensions.md +31 -1
  578. package/docs/sandbox.md +6 -0
  579. package/docs/sessions.md +1 -1
  580. package/docs/skills.md +4 -4
  581. package/docs/usage.md +2 -1
  582. package/examples/extensions/custom-provider-anthropic/package.json +2 -2
  583. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  584. package/examples/extensions/sandbox/package.json +2 -2
  585. package/examples/extensions/with-deps/package.json +1 -1
  586. package/npm-shrinkwrap.json +602 -834
  587. package/package.json +20 -21
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/core/hooks/types.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC/B,cAAc;IACd,kBAAkB;IAClB,YAAY;IACZ,aAAa;IACb,oBAAoB;IACpB,MAAM;IACN,aAAa;IACb,YAAY;IACZ,aAAa;IACb,YAAY;CACH,CAAC;AACX,MAAM,CAAC,MAAM,0BAA0B,GAAG,gBAAgB,CAAC;AAiQ3D,SAAS,QAAQ,CAAC,KAAc,EAAoC;IACnE,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AAAA,CACnD;AAED,MAAM,UAAU,wBAAwB,CAAC,KAAc,EAAmC;IACzF,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IAChD,IAAI,MAAe,CAAC;IACpB,IAAI,CAAC;QACJ,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,SAAS,CA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QAAQ,CAAC;QAC/D,OAAO,KAAK,CAAC,UAAU,KAAK,QAAQ,CACpC,CAAC;AAAA,CACF","sourcesContent":["import type { ToolOperations } from \"../tools/operations.ts\";\n\nexport const HOOK_EVENT_NAMES = [\n\t\"SessionStart\",\n\t\"UserPromptSubmit\",\n\t\"PreToolUse\",\n\t\"PostToolUse\",\n\t\"PostToolUseFailure\",\n\t\"Stop\",\n\t\"StopFailure\",\n\t\"PreCompact\",\n\t\"PostCompact\",\n\t\"SessionEnd\",\n] as const;\nexport const HOOK_EXECUTION_CUSTOM_TYPE = \"hook_execution\";\n\nexport type HookEventName = (typeof HOOK_EVENT_NAMES)[number];\nexport type JsonPrimitive = string | number | boolean | null;\nexport type JsonValue = JsonPrimitive | JsonValue[] | { [key: string]: JsonValue };\nexport type JsonObject = { [key: string]: JsonValue };\n\nexport type PermissionMode = \"default\" | \"plan\" | \"acceptEdits\" | \"auto\" | \"dontAsk\" | \"bypassPermissions\";\nexport type HookEffortLevel = \"low\" | \"medium\" | \"high\" | \"xhigh\" | \"max\";\n\nexport interface HookEffort {\n\tlevel: HookEffortLevel;\n}\nexport type SessionStartHookSource = \"startup\" | \"resume\" | \"clear\" | \"compact\" | \"fork\";\nexport type CompactionHookTrigger = \"manual\" | \"auto\";\n\nexport interface HookInputCommon {\n\tsession_id: string;\n\ttranscript_path: string;\n\tcwd: string;\n\thook_event_name: HookEventName;\n\tprompt_id?: string;\n\tpermission_mode?: PermissionMode;\n\tagent_id?: string;\n\tagent_type?: string;\n\teffort?: HookEffort;\n}\n\nexport interface SessionStartHookInput extends HookInputCommon {\n\thook_event_name: \"SessionStart\";\n\tsource: SessionStartHookSource;\n\tmodel?: string;\n\tsession_title?: string;\n}\nexport interface UserPromptSubmitHookInput extends HookInputCommon {\n\thook_event_name: \"UserPromptSubmit\";\n\tprompt: string;\n}\nexport interface ToolHookInput extends HookInputCommon {\n\ttool_name: string;\n\ttool_input: JsonObject;\n\ttool_use_id: string;\n}\nexport interface PreToolUseHookInput extends ToolHookInput {\n\thook_event_name: \"PreToolUse\";\n}\nexport interface PostToolUseHookInput extends ToolHookInput {\n\thook_event_name: \"PostToolUse\";\n\ttool_response: JsonValue;\n\tduration_ms?: number;\n}\nexport interface PostToolUseFailureHookInput extends ToolHookInput {\n\thook_event_name: \"PostToolUseFailure\";\n\terror: string;\n\tis_interrupt?: boolean;\n\tduration_ms?: number;\n}\nexport interface StopHookInput extends HookInputCommon {\n\thook_event_name: \"Stop\";\n\tstop_hook_active: boolean;\n\tlast_assistant_message: string;\n\tbackground_tasks?: JsonObject[];\n\tsession_crons?: JsonObject[];\n}\nexport interface StopFailureHookInput extends HookInputCommon {\n\thook_event_name: \"StopFailure\";\n\terror: string;\n\terror_details?: string;\n\tlast_assistant_message?: string;\n}\nexport interface PreCompactHookInput extends HookInputCommon {\n\thook_event_name: \"PreCompact\";\n\ttrigger: CompactionHookTrigger;\n\tcustom_instructions: string;\n}\nexport interface PostCompactHookInput extends HookInputCommon {\n\thook_event_name: \"PostCompact\";\n\ttrigger: CompactionHookTrigger;\n\tcompact_summary: string;\n}\nexport type SessionEndReason = \"clear\" | \"resume\" | \"logout\" | \"prompt_input_exit\" | \"other\";\n\nexport interface SessionEndHookInput extends HookInputCommon {\n\thook_event_name: \"SessionEnd\";\n\treason: SessionEndReason;\n}\nexport type HookInput =\n\t| SessionStartHookInput\n\t| UserPromptSubmitHookInput\n\t| PreToolUseHookInput\n\t| PostToolUseHookInput\n\t| PostToolUseFailureHookInput\n\t| StopHookInput\n\t| StopFailureHookInput\n\t| PreCompactHookInput\n\t| PostCompactHookInput\n\t| SessionEndHookInput;\n\nexport type HookCommandShell = \"bash\" | \"powershell\";\nexport type UnsupportedHookHandlerType = \"prompt\" | \"agent\" | \"mcp_tool\";\n\nexport interface HookHandlerCommon {\n\ttimeout?: number;\n\tif?: string;\n\tstatusMessage?: string;\n}\nexport interface CommandHookHandler extends HookHandlerCommon {\n\ttype: \"command\";\n\tcommand: string;\n\targs?: string[];\n\tshell?: HookCommandShell;\n}\nexport interface HttpHookHandler extends HookHandlerCommon {\n\ttype: \"http\";\n\turl: string;\n\theaders?: Record<string, string>;\n\tallowedEnvVars?: string[];\n}\nexport interface UnsupportedHookHandler extends HookHandlerCommon {\n\ttype: UnsupportedHookHandlerType;\n}\nexport type HookHandler = CommandHookHandler | HttpHookHandler | UnsupportedHookHandler;\nexport interface HookGroup {\n\tmatcher?: string;\n\thooks: HookHandler[];\n}\nexport type HookConfiguration = Partial<Record<HookEventName, HookGroup[]>>;\n\nexport type HookSettingsSourceKind = \"user\" | \"project\" | \"local\" | \"host\";\nexport interface HookSettingsSource {\n\tkind: HookSettingsSourceKind;\n\tpath: string;\n}\nexport type HookDiagnosticCode =\n\t| \"read\"\n\t| \"parse\"\n\t| \"schema\"\n\t| \"unsupported-handler\"\n\t| \"invalid-regex\"\n\t| \"execution\"\n\t| \"policy\"\n\t| \"malformed-output\"\n\t| \"system-message\"\n\t| \"unsupported-update\"\n\t| \"continuation-cap\";\n\nexport type HookDiagnosticLevel = \"warning\" | \"error\";\n\nexport interface HookDiagnostic {\n\tlevel: HookDiagnosticLevel;\n\tcode: HookDiagnosticCode;\n\tmessage: string;\n\tsource?: HookSettingsSource;\n\tevent?: HookEventName;\n}\nexport interface LoadedHookHandler {\n\tevent: HookEventName;\n\tmatcher?: string;\n\thandler: HookHandler;\n\tsource: HookSettingsSource;\n\torder: number;\n\t/** Effective settings-policy environment allowlist for this HTTP hook. */\n\thttpHookAllowedEnvVars?: readonly string[];\n}\nexport interface LoadedHooks {\n\treadonly handlers: readonly LoadedHookHandler[];\n\treadonly diagnostics: readonly HookDiagnostic[];\n\treadonly sources: readonly HookSettingsSource[];\n}\n\nexport interface HookStructuredOutput {\n\tcontinue?: boolean;\n\tstopReason?: string;\n\tsuppressOutput?: boolean;\n\tsystemMessage?: string;\n\tterminalSequence?: string;\n\tdecision?: string;\n\treason?: string;\n\thookSpecificOutput?: JsonObject;\n}\nexport type HookOutputClassification =\n\t| { kind: \"empty\" }\n\t| { kind: \"text\"; text: string; malformedJson: boolean }\n\t| { kind: \"json\"; value: HookStructuredOutput };\nexport type HookExecutionStatus = \"completed\" | \"timeout\" | \"cancelled\" | \"error\" | \"unsupported\";\n\nexport interface HookExecutionResult {\n\thook: LoadedHookHandler;\n\tstatus: HookExecutionStatus;\n\texitCode: number | null;\n\tstdout: string;\n\tstderr: string;\n\tstdoutTruncated: boolean;\n\tstderrTruncated: boolean;\n\toutput: HookOutputClassification;\n\tblocking: boolean;\n\tblockingReason?: string;\n\tdurationMs: number;\n\tdiagnostic?: HookDiagnostic;\n}\n\nexport interface HookRunOptions {\n\t/** Active workspace backend used for project/local hook isolation. */\n\ttoolOperations?: Pick<ToolOperations, \"cwd\" | \"exec\" | \"getBackendInfo\">;\n\tsignal?: AbortSignal;\n\tenv?: NodeJS.ProcessEnv;\n\tmaxOutputBytes?: number;\n\tfetch?: typeof globalThis.fetch;\n\t/** Internal/test platform override for process-tree termination behavior. */\n\tplatform?: NodeJS.Platform;\n\t/** Internal/test override for Windows process-tree termination. Return false to request direct-child fallback. */\n\tterminateWindowsProcessTree?: (pid: number) => boolean;\n\t/** Shared timeout override (used for SessionEnd matching handlers). */\n\ttimeoutSeconds?: number;\n\t/** Host ceiling for HTTP destinations. Omitted means no additional host restriction. */\n\tallowedHttpHookUrls?: readonly string[];\n\t/** Host ceiling for HTTP header environment interpolation. */\n\thttpHookAllowedEnvVars?: readonly string[];\n}\nexport type HookPermissionDecision = \"allow\" | \"ask\" | \"defer\" | \"deny\";\n\nexport interface HookAggregateResult {\n\tcontinue: boolean;\n\tblocked: boolean;\n\treason?: string;\n\tadditionalContext: string[];\n\tsystemMessages: string[];\n\tplainText: string[];\n\tpermissionDecision?: HookPermissionDecision;\n\tupdatedInput?: JsonObject;\n\tupdatedToolOutput?: JsonValue;\n\tsessionTitle?: string;\n\tinitialUserMessage?: string;\n\t/** Aggregate remaining-work metric reported by Stop hooks. Lower values indicate progress. */\n\tstopContinuationProgress?: number;\n\treloadSkills?: boolean;\n\tresults: HookExecutionResult[];\n}\n\n/** Sanitized completed handler call for host UI rendering. */\nexport interface HookExecutionCallNotice {\n\ttype: HookHandler[\"type\"];\n\tlabel: string;\n\tsource: HookSettingsSource;\n\tstatus: HookExecutionStatus;\n\texitCode: number | null;\n\tdurationMs: number;\n}\n\n/** One completed hook event execution persisted as audit-only session data and exposed to host UI observers. */\nexport interface HookExecutionNotice {\n\tevent: HookEventName;\n\tsubject?: string;\n\tcalls: HookExecutionCallNotice[];\n\treturnedPrompts: string[];\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null;\n}\n\nexport function parseHookExecutionNotice(value: unknown): HookExecutionNotice | undefined {\n\tif (typeof value !== \"string\") return undefined;\n\tlet parsed: unknown;\n\ttry {\n\t\tparsed = JSON.parse(value);\n\t} catch {\n\t\treturn undefined;\n\t}\n\tif (!isRecord(parsed) || typeof parsed.event !== \"string\") return undefined;\n\tif (!HOOK_EVENT_NAMES.includes(parsed.event as HookEventName)) return undefined;\n\tif (parsed.subject !== undefined && typeof parsed.subject !== \"string\") return undefined;\n\tif (\n\t\t!Array.isArray(parsed.returnedPrompts) ||\n\t\t!parsed.returnedPrompts.every((prompt) => typeof prompt === \"string\")\n\t) {\n\t\treturn undefined;\n\t}\n\tif (!Array.isArray(parsed.calls) || !parsed.calls.every(isHookExecutionCallNotice)) return undefined;\n\treturn parsed as unknown as HookExecutionNotice;\n}\n\nfunction isHookExecutionCallNotice(value: unknown): value is HookExecutionCallNotice {\n\tif (!isRecord(value) || !isRecord(value.source)) return false;\n\treturn (\n\t\ttypeof value.type === \"string\" &&\n\t\ttypeof value.label === \"string\" &&\n\t\ttypeof value.source.kind === \"string\" &&\n\t\ttypeof value.source.path === \"string\" &&\n\t\ttypeof value.status === \"string\" &&\n\t\t(value.exitCode === null || typeof value.exitCode === \"number\") &&\n\t\ttypeof value.durationMs === \"number\"\n\t);\n}\n\nexport type HookExecutionListener = (notice: HookExecutionNotice) => void;\nexport type HookExecutionActivityListener = (active: boolean) => void;\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/core/hooks/types.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC/B,cAAc;IACd,kBAAkB;IAClB,YAAY;IACZ,aAAa;IACb,oBAAoB;IACpB,MAAM;IACN,aAAa;IACb,YAAY;IACZ,aAAa;IACb,YAAY;CACH,CAAC;AACX,MAAM,CAAC,MAAM,0BAA0B,GAAG,gBAAgB,CAAC;AAiQ3D,SAAS,QAAQ,CAAC,KAAc;IAC/B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACpD,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,KAAc;IACtD,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IAChD,IAAI,MAAe,CAAC;IACpB,IAAI,CAAC;QACJ,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,SAAS,CAAC;IAClB,CAAC;IACD,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,OAAO,MAAM,CAAC,KAAK,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IAC5E,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAsB,CAAC;QAAE,OAAO,SAAS,CAAC;IAChF,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS,IAAI,OAAO,MAAM,CAAC,OAAO,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IACzF,IACC,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,eAAe,CAAC;QACtC,CAAC,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,OAAO,MAAM,KAAK,QAAQ,CAAC,EACpE,CAAC;QACF,OAAO,SAAS,CAAC;IAClB,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,yBAAyB,CAAC;QAAE,OAAO,SAAS,CAAC;IACrG,OAAO,MAAwC,CAAC;AACjD,CAAC;AAED,SAAS,yBAAyB,CAAC,KAAc;IAChD,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC;QAAE,OAAO,KAAK,CAAC;IAC9D,OAAO,CACN,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;QAC9B,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ;QAC/B,OAAO,KAAK,CAAC,MAAM,CAAC,IAAI,KAAK,QAAQ;QACrC,OAAO,KAAK,CAAC,MAAM,CAAC,IAAI,KAAK,QAAQ;QACrC,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ;QAChC,CAAC,KAAK,CAAC,QAAQ,KAAK,IAAI,IAAI,OAAO,KAAK,CAAC,QAAQ,KAAK,QAAQ,CAAC;QAC/D,OAAO,KAAK,CAAC,UAAU,KAAK,QAAQ,CACpC,CAAC;AACH,CAAC","sourcesContent":["import type { ToolOperations } from \"../tools/operations.ts\";\n\nexport const HOOK_EVENT_NAMES = [\n\t\"SessionStart\",\n\t\"UserPromptSubmit\",\n\t\"PreToolUse\",\n\t\"PostToolUse\",\n\t\"PostToolUseFailure\",\n\t\"Stop\",\n\t\"StopFailure\",\n\t\"PreCompact\",\n\t\"PostCompact\",\n\t\"SessionEnd\",\n] as const;\nexport const HOOK_EXECUTION_CUSTOM_TYPE = \"hook_execution\";\n\nexport type HookEventName = (typeof HOOK_EVENT_NAMES)[number];\nexport type JsonPrimitive = string | number | boolean | null;\nexport type JsonValue = JsonPrimitive | JsonValue[] | { [key: string]: JsonValue };\nexport type JsonObject = { [key: string]: JsonValue };\n\nexport type PermissionMode = \"default\" | \"plan\" | \"acceptEdits\" | \"auto\" | \"dontAsk\" | \"bypassPermissions\";\nexport type HookEffortLevel = \"low\" | \"medium\" | \"high\" | \"xhigh\" | \"max\";\n\nexport interface HookEffort {\n\tlevel: HookEffortLevel;\n}\nexport type SessionStartHookSource = \"startup\" | \"resume\" | \"clear\" | \"compact\" | \"fork\";\nexport type CompactionHookTrigger = \"manual\" | \"auto\";\n\nexport interface HookInputCommon {\n\tsession_id: string;\n\ttranscript_path: string;\n\tcwd: string;\n\thook_event_name: HookEventName;\n\tprompt_id?: string;\n\tpermission_mode?: PermissionMode;\n\tagent_id?: string;\n\tagent_type?: string;\n\teffort?: HookEffort;\n}\n\nexport interface SessionStartHookInput extends HookInputCommon {\n\thook_event_name: \"SessionStart\";\n\tsource: SessionStartHookSource;\n\tmodel?: string;\n\tsession_title?: string;\n}\nexport interface UserPromptSubmitHookInput extends HookInputCommon {\n\thook_event_name: \"UserPromptSubmit\";\n\tprompt: string;\n}\nexport interface ToolHookInput extends HookInputCommon {\n\ttool_name: string;\n\ttool_input: JsonObject;\n\ttool_use_id: string;\n}\nexport interface PreToolUseHookInput extends ToolHookInput {\n\thook_event_name: \"PreToolUse\";\n}\nexport interface PostToolUseHookInput extends ToolHookInput {\n\thook_event_name: \"PostToolUse\";\n\ttool_response: JsonValue;\n\tduration_ms?: number;\n}\nexport interface PostToolUseFailureHookInput extends ToolHookInput {\n\thook_event_name: \"PostToolUseFailure\";\n\terror: string;\n\tis_interrupt?: boolean;\n\tduration_ms?: number;\n}\nexport interface StopHookInput extends HookInputCommon {\n\thook_event_name: \"Stop\";\n\tstop_hook_active: boolean;\n\tlast_assistant_message: string;\n\tbackground_tasks?: JsonObject[];\n\tsession_crons?: JsonObject[];\n}\nexport interface StopFailureHookInput extends HookInputCommon {\n\thook_event_name: \"StopFailure\";\n\terror: string;\n\terror_details?: string;\n\tlast_assistant_message?: string;\n}\nexport interface PreCompactHookInput extends HookInputCommon {\n\thook_event_name: \"PreCompact\";\n\ttrigger: CompactionHookTrigger;\n\tcustom_instructions: string;\n}\nexport interface PostCompactHookInput extends HookInputCommon {\n\thook_event_name: \"PostCompact\";\n\ttrigger: CompactionHookTrigger;\n\tcompact_summary: string;\n}\nexport type SessionEndReason = \"clear\" | \"resume\" | \"logout\" | \"prompt_input_exit\" | \"other\";\n\nexport interface SessionEndHookInput extends HookInputCommon {\n\thook_event_name: \"SessionEnd\";\n\treason: SessionEndReason;\n}\nexport type HookInput =\n\t| SessionStartHookInput\n\t| UserPromptSubmitHookInput\n\t| PreToolUseHookInput\n\t| PostToolUseHookInput\n\t| PostToolUseFailureHookInput\n\t| StopHookInput\n\t| StopFailureHookInput\n\t| PreCompactHookInput\n\t| PostCompactHookInput\n\t| SessionEndHookInput;\n\nexport type HookCommandShell = \"bash\" | \"powershell\";\nexport type UnsupportedHookHandlerType = \"prompt\" | \"agent\" | \"mcp_tool\";\n\nexport interface HookHandlerCommon {\n\ttimeout?: number;\n\tif?: string;\n\tstatusMessage?: string;\n}\nexport interface CommandHookHandler extends HookHandlerCommon {\n\ttype: \"command\";\n\tcommand: string;\n\targs?: string[];\n\tshell?: HookCommandShell;\n}\nexport interface HttpHookHandler extends HookHandlerCommon {\n\ttype: \"http\";\n\turl: string;\n\theaders?: Record<string, string>;\n\tallowedEnvVars?: string[];\n}\nexport interface UnsupportedHookHandler extends HookHandlerCommon {\n\ttype: UnsupportedHookHandlerType;\n}\nexport type HookHandler = CommandHookHandler | HttpHookHandler | UnsupportedHookHandler;\nexport interface HookGroup {\n\tmatcher?: string;\n\thooks: HookHandler[];\n}\nexport type HookConfiguration = Partial<Record<HookEventName, HookGroup[]>>;\n\nexport type HookSettingsSourceKind = \"user\" | \"project\" | \"local\" | \"host\";\nexport interface HookSettingsSource {\n\tkind: HookSettingsSourceKind;\n\tpath: string;\n}\nexport type HookDiagnosticCode =\n\t| \"read\"\n\t| \"parse\"\n\t| \"schema\"\n\t| \"unsupported-handler\"\n\t| \"invalid-regex\"\n\t| \"execution\"\n\t| \"policy\"\n\t| \"malformed-output\"\n\t| \"system-message\"\n\t| \"unsupported-update\"\n\t| \"continuation-cap\";\n\nexport type HookDiagnosticLevel = \"warning\" | \"error\";\n\nexport interface HookDiagnostic {\n\tlevel: HookDiagnosticLevel;\n\tcode: HookDiagnosticCode;\n\tmessage: string;\n\tsource?: HookSettingsSource;\n\tevent?: HookEventName;\n}\nexport interface LoadedHookHandler {\n\tevent: HookEventName;\n\tmatcher?: string;\n\thandler: HookHandler;\n\tsource: HookSettingsSource;\n\torder: number;\n\t/** Effective settings-policy environment allowlist for this HTTP hook. */\n\thttpHookAllowedEnvVars?: readonly string[];\n}\nexport interface LoadedHooks {\n\treadonly handlers: readonly LoadedHookHandler[];\n\treadonly diagnostics: readonly HookDiagnostic[];\n\treadonly sources: readonly HookSettingsSource[];\n}\n\nexport interface HookStructuredOutput {\n\tcontinue?: boolean;\n\tstopReason?: string;\n\tsuppressOutput?: boolean;\n\tsystemMessage?: string;\n\tterminalSequence?: string;\n\tdecision?: string;\n\treason?: string;\n\thookSpecificOutput?: JsonObject;\n}\nexport type HookOutputClassification =\n\t| { kind: \"empty\" }\n\t| { kind: \"text\"; text: string; malformedJson: boolean }\n\t| { kind: \"json\"; value: HookStructuredOutput };\nexport type HookExecutionStatus = \"completed\" | \"timeout\" | \"cancelled\" | \"error\" | \"unsupported\";\n\nexport interface HookExecutionResult {\n\thook: LoadedHookHandler;\n\tstatus: HookExecutionStatus;\n\texitCode: number | null;\n\tstdout: string;\n\tstderr: string;\n\tstdoutTruncated: boolean;\n\tstderrTruncated: boolean;\n\toutput: HookOutputClassification;\n\tblocking: boolean;\n\tblockingReason?: string;\n\tdurationMs: number;\n\tdiagnostic?: HookDiagnostic;\n}\n\nexport interface HookRunOptions {\n\t/** Active workspace backend used for project/local hook isolation. */\n\ttoolOperations?: Pick<ToolOperations, \"cwd\" | \"exec\" | \"getBackendInfo\">;\n\tsignal?: AbortSignal;\n\tenv?: NodeJS.ProcessEnv;\n\tmaxOutputBytes?: number;\n\tfetch?: typeof globalThis.fetch;\n\t/** Internal/test platform override for process-tree termination behavior. */\n\tplatform?: NodeJS.Platform;\n\t/** Internal/test override for Windows process-tree termination. Return false to request direct-child fallback. */\n\tterminateWindowsProcessTree?: (pid: number) => boolean;\n\t/** Shared timeout override (used for SessionEnd matching handlers). */\n\ttimeoutSeconds?: number;\n\t/** Host ceiling for HTTP destinations. Omitted means no additional host restriction. */\n\tallowedHttpHookUrls?: readonly string[];\n\t/** Host ceiling for HTTP header environment interpolation. */\n\thttpHookAllowedEnvVars?: readonly string[];\n}\nexport type HookPermissionDecision = \"allow\" | \"ask\" | \"defer\" | \"deny\";\n\nexport interface HookAggregateResult {\n\tcontinue: boolean;\n\tblocked: boolean;\n\treason?: string;\n\tadditionalContext: string[];\n\tsystemMessages: string[];\n\tplainText: string[];\n\tpermissionDecision?: HookPermissionDecision;\n\tupdatedInput?: JsonObject;\n\tupdatedToolOutput?: JsonValue;\n\tsessionTitle?: string;\n\tinitialUserMessage?: string;\n\t/** Aggregate remaining-work metric reported by Stop hooks. Lower values indicate progress. */\n\tstopContinuationProgress?: number;\n\treloadSkills?: boolean;\n\tresults: HookExecutionResult[];\n}\n\n/** Sanitized completed handler call for host UI rendering. */\nexport interface HookExecutionCallNotice {\n\ttype: HookHandler[\"type\"];\n\tlabel: string;\n\tsource: HookSettingsSource;\n\tstatus: HookExecutionStatus;\n\texitCode: number | null;\n\tdurationMs: number;\n}\n\n/** One completed hook event execution persisted as audit-only session data and exposed to host UI observers. */\nexport interface HookExecutionNotice {\n\tevent: HookEventName;\n\tsubject?: string;\n\tcalls: HookExecutionCallNotice[];\n\treturnedPrompts: string[];\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null;\n}\n\nexport function parseHookExecutionNotice(value: unknown): HookExecutionNotice | undefined {\n\tif (typeof value !== \"string\") return undefined;\n\tlet parsed: unknown;\n\ttry {\n\t\tparsed = JSON.parse(value);\n\t} catch {\n\t\treturn undefined;\n\t}\n\tif (!isRecord(parsed) || typeof parsed.event !== \"string\") return undefined;\n\tif (!HOOK_EVENT_NAMES.includes(parsed.event as HookEventName)) return undefined;\n\tif (parsed.subject !== undefined && typeof parsed.subject !== \"string\") return undefined;\n\tif (\n\t\t!Array.isArray(parsed.returnedPrompts) ||\n\t\t!parsed.returnedPrompts.every((prompt) => typeof prompt === \"string\")\n\t) {\n\t\treturn undefined;\n\t}\n\tif (!Array.isArray(parsed.calls) || !parsed.calls.every(isHookExecutionCallNotice)) return undefined;\n\treturn parsed as unknown as HookExecutionNotice;\n}\n\nfunction isHookExecutionCallNotice(value: unknown): value is HookExecutionCallNotice {\n\tif (!isRecord(value) || !isRecord(value.source)) return false;\n\treturn (\n\t\ttypeof value.type === \"string\" &&\n\t\ttypeof value.label === \"string\" &&\n\t\ttypeof value.source.kind === \"string\" &&\n\t\ttypeof value.source.path === \"string\" &&\n\t\ttypeof value.status === \"string\" &&\n\t\t(value.exitCode === null || typeof value.exitCode === \"number\") &&\n\t\ttypeof value.durationMs === \"number\"\n\t);\n}\n\nexport type HookExecutionListener = (notice: HookExecutionNotice) => void;\nexport type HookExecutionActivityListener = (active: boolean) => void;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"http-dispatcher.d.ts","sourceRoot":"","sources":["../../src/core/http-dispatcher.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,4BAA4B,SAAU,CAAC;AAEpD,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;EAM5B,CAAC;AAEX,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAgBzE;AAED,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAMjE;AAmCD,wBAAgB,uBAAuB,CAAC,SAAS,GAAE,MAAqC,GAAG,IAAI,CAuB9F","sourcesContent":["import { EventEmitter } from \"node:events\";\nimport * as undici from \"undici\";\n\nexport const DEFAULT_HTTP_IDLE_TIMEOUT_MS = 300_000;\n\nexport const HTTP_IDLE_TIMEOUT_CHOICES = [\n\t{ label: \"30 sec\", timeoutMs: 30_000 },\n\t{ label: \"1 min\", timeoutMs: 60_000 },\n\t{ label: \"2 min\", timeoutMs: 120_000 },\n\t{ label: \"5 min\", timeoutMs: 300_000 },\n\t{ label: \"disabled\", timeoutMs: 0 },\n] as const;\n\nexport function parseHttpIdleTimeoutMs(value: unknown): number | undefined {\n\tif (typeof value === \"string\") {\n\t\tconst trimmed = value.trim();\n\t\tif (trimmed.toLowerCase() === \"disabled\") {\n\t\t\treturn 0;\n\t\t}\n\t\tif (trimmed.length === 0) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn parseHttpIdleTimeoutMs(Number(trimmed));\n\t}\n\n\tif (typeof value !== \"number\" || !Number.isFinite(value) || value < 0) {\n\t\treturn undefined;\n\t}\n\treturn Math.floor(value);\n}\n\nexport function formatHttpIdleTimeoutMs(timeoutMs: number): string {\n\tconst choice = HTTP_IDLE_TIMEOUT_CHOICES.find((item) => item.timeoutMs === timeoutMs);\n\tif (choice) {\n\t\treturn choice.label;\n\t}\n\treturn `${timeoutMs / 1000} sec`;\n}\n\nconst ignoreUndiciDispatcherError = (_error: unknown): void => {};\n\n// Undici can emit an internal Client \"error\" while terminating a mid-stream\n// fetch body. The body stream still rejects through reader.read(); this listener\n// only prevents EventEmitter's unhandled \"error\" special case from crashing grip.\nfunction withUndiciErrorListener<T extends undici.Dispatcher>(dispatcher: T): T {\n\tif (dispatcher instanceof EventEmitter) {\n\t\tEventEmitter.prototype.on.call(dispatcher, \"error\", ignoreUndiciDispatcherError);\n\t}\n\treturn dispatcher;\n}\n\nfunction createUndiciClient(origin: string | URL, options: object): undici.Dispatcher {\n\treturn withUndiciErrorListener(new undici.Client(origin, options as undici.Client.Options));\n}\n\nfunction createUndiciOriginDispatcher(origin: string | URL, options: object): undici.Dispatcher {\n\tconst dispatcherOptions = options as undici.Pool.Options;\n\tif (dispatcherOptions.connections === 1) {\n\t\treturn createUndiciClient(origin, dispatcherOptions);\n\t}\n\treturn withUndiciErrorListener(\n\t\tnew undici.Pool(origin, {\n\t\t\t...dispatcherOptions,\n\t\t\tfactory: createUndiciClient,\n\t\t}),\n\t);\n}\n\nfunction isMockedFetch(fetchImplementation: typeof globalThis.fetch | undefined): boolean {\n\treturn (fetchImplementation as { _isMockFunction?: unknown } | undefined)?._isMockFunction === true;\n}\n\nexport function configureHttpDispatcher(timeoutMs: number = DEFAULT_HTTP_IDLE_TIMEOUT_MS): void {\n\tconst normalizedTimeoutMs = parseHttpIdleTimeoutMs(timeoutMs);\n\tif (normalizedTimeoutMs === undefined) {\n\t\tthrow new Error(`Invalid HTTP idle timeout: ${String(timeoutMs)}`);\n\t}\n\tconst dispatcher = withUndiciErrorListener(\n\t\tnew undici.EnvHttpProxyAgent({\n\t\t\tallowH2: false,\n\t\t\tbodyTimeout: normalizedTimeoutMs,\n\t\t\theadersTimeout: normalizedTimeoutMs,\n\t\t\tclientFactory: createUndiciClient,\n\t\t\tfactory: createUndiciOriginDispatcher,\n\t\t}),\n\t);\n\tundici.setGlobalDispatcher(dispatcher);\n\t// Keep fetch and the dispatcher on the same undici implementation. Node 26.0's\n\t// bundled fetch can otherwise consume compressed responses through npm undici's\n\t// dispatcher without decompressing them, causing response.json() failures.\n\tconst existingFetch = globalThis.fetch;\n\tundici.install?.();\n\tif (isMockedFetch(existingFetch)) {\n\t\tglobalThis.fetch = existingFetch;\n\t}\n}\n"]}
1
+ {"version":3,"file":"http-dispatcher.d.ts","sourceRoot":"","sources":["../../src/core/http-dispatcher.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,4BAA4B,SAAU,CAAC;AAEpD,eAAO,MAAM,yBAAyB;aACnC,KAAK,EAAE,QAAQ;aAAE,SAAS,EAAE,KAAM;;aAClC,KAAK,EAAE,OAAO;aAAE,SAAS,EAAE,KAAM;;aACjC,KAAK,EAAE,OAAO;aAAE,SAAS,EAA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DLE_TIMEOUT_MS = 300_000;\n\nexport const HTTP_IDLE_TIMEOUT_CHOICES = [\n\t{ label: \"30 sec\", timeoutMs: 30_000 },\n\t{ label: \"1 min\", timeoutMs: 60_000 },\n\t{ label: \"2 min\", timeoutMs: 120_000 },\n\t{ label: \"5 min\", timeoutMs: 300_000 },\n\t{ label: \"disabled\", timeoutMs: 0 },\n] as const;\n\nexport function parseHttpIdleTimeoutMs(value: unknown): number | undefined {\n\tif (typeof value === \"string\") {\n\t\tconst trimmed = value.trim();\n\t\tif (trimmed.toLowerCase() === \"disabled\") {\n\t\t\treturn 0;\n\t\t}\n\t\tif (trimmed.length === 0) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn parseHttpIdleTimeoutMs(Number(trimmed));\n\t}\n\n\tif (typeof value !== \"number\" || !Number.isFinite(value) || value < 0) {\n\t\treturn undefined;\n\t}\n\treturn Math.floor(value);\n}\n\nexport function formatHttpIdleTimeoutMs(timeoutMs: number): string {\n\tconst choice = HTTP_IDLE_TIMEOUT_CHOICES.find((item) => item.timeoutMs === timeoutMs);\n\tif (choice) {\n\t\treturn choice.label;\n\t}\n\treturn `${timeoutMs / 1000} sec`;\n}\n\nconst ignoreUndiciDispatcherError = (_error: unknown): void => {};\n\n// Undici can emit an internal Client \"error\" while terminating a mid-stream\n// fetch body. The body stream still rejects through reader.read(); this listener\n// only prevents EventEmitter's unhandled \"error\" special case from crashing grip.\nfunction withUndiciErrorListener<T extends undici.Dispatcher>(dispatcher: T): T {\n\tif (dispatcher instanceof EventEmitter) {\n\t\tEventEmitter.prototype.on.call(dispatcher, \"error\", ignoreUndiciDispatcherError);\n\t}\n\treturn dispatcher;\n}\n\nfunction createUndiciClient(origin: string | URL, options: object): undici.Dispatcher {\n\treturn withUndiciErrorListener(new undici.Client(origin, options as undici.Client.Options));\n}\n\nfunction createUndiciOriginDispatcher(origin: string | URL, options: object): undici.Dispatcher {\n\tconst dispatcherOptions = options as undici.Pool.Options;\n\tif (dispatcherOptions.connections === 1) {\n\t\treturn createUndiciClient(origin, dispatcherOptions);\n\t}\n\treturn withUndiciErrorListener(\n\t\tnew undici.Pool(origin, {\n\t\t\t...dispatcherOptions,\n\t\t\tfactory: createUndiciClient,\n\t\t}),\n\t);\n}\n\nfunction isMockedFetch(fetchImplementation: typeof globalThis.fetch | undefined): boolean {\n\treturn (fetchImplementation as { _isMockFunction?: unknown } | undefined)?._isMockFunction === true;\n}\n\nexport function configureHttpDispatcher(timeoutMs: number = DEFAULT_HTTP_IDLE_TIMEOUT_MS): void {\n\tconst normalizedTimeoutMs = parseHttpIdleTimeoutMs(timeoutMs);\n\tif (normalizedTimeoutMs === undefined) {\n\t\tthrow new Error(`Invalid HTTP idle timeout: ${String(timeoutMs)}`);\n\t}\n\tconst dispatcher = withUndiciErrorListener(\n\t\tnew undici.EnvHttpProxyAgent({\n\t\t\tallowH2: false,\n\t\t\tbodyTimeout: normalizedTimeoutMs,\n\t\t\theadersTimeout: normalizedTimeoutMs,\n\t\t\tclientFactory: createUndiciClient,\n\t\t\tfactory: createUndiciOriginDispatcher,\n\t\t}),\n\t);\n\tundici.setGlobalDispatcher(dispatcher);\n\t// Keep fetch and the dispatcher on the same undici implementation. Node 26.0's\n\t// bundled fetch can otherwise consume compressed responses through npm undici's\n\t// dispatcher without decompressing them, causing response.json() failures.\n\tconst existingFetch = globalThis.fetch;\n\tundici.install?.();\n\tif (isMockedFetch(existingFetch)) {\n\t\tglobalThis.fetch = existingFetch;\n\t}\n}\n"]}
1
+ {"version":3,"file":"http-dispatcher.js","sourceRoot":"","sources":["../../src/core/http-dispatcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC,MAAM,CAAC,MAAM,4BAA4B,GAAG,OAAO,CAAC;AAEpD,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACxC,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,E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AC5B,OAAO,EAAE,KAAK;QACd,WAAW,EAAE,mBAAmB;QAChC,cAAc,EAAE,mBAAmB;QACnC,aAAa,EAAE,kBAAkB;QACjC,OAAO,EAAE,4BAA4B;KACrC,CAAC,CACF,CAAC;IACF,MAAM,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC;IACvC,+EAA+E;IAC/E,gFAAgF;IAChF,2EAA2E;IAC3E,MAAM,aAAa,GAAG,UAAU,CAAC,KAAK,CAAC;IACvC,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC;IACnB,IAAI,aAAa,CAAC,aAAa,CAAC,EAAE,CAAC;QAClC,UAAU,CAAC,KAAK,GAAG,aAAa,CAAC;IAClC,CAAC;AACF,CAAC","sourcesContent":["import { EventEmitter } from \"node:events\";\nimport * as undici from \"undici\";\n\nexport const DEFAULT_HTTP_IDLE_TIMEOUT_MS = 300_000;\n\nexport const HTTP_IDLE_TIMEOUT_CHOICES = [\n\t{ label: \"30 sec\", timeoutMs: 30_000 },\n\t{ label: \"1 min\", timeoutMs: 60_000 },\n\t{ label: \"2 min\", timeoutMs: 120_000 },\n\t{ label: \"5 min\", timeoutMs: 300_000 },\n\t{ label: \"disabled\", timeoutMs: 0 },\n] as const;\n\nexport function parseHttpIdleTimeoutMs(value: unknown): number | undefined {\n\tif (typeof value === \"string\") {\n\t\tconst trimmed = value.trim();\n\t\tif (trimmed.toLowerCase() === \"disabled\") {\n\t\t\treturn 0;\n\t\t}\n\t\tif (trimmed.length === 0) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn parseHttpIdleTimeoutMs(Number(trimmed));\n\t}\n\n\tif (typeof value !== \"number\" || !Number.isFinite(value) || value < 0) {\n\t\treturn undefined;\n\t}\n\treturn Math.floor(value);\n}\n\nexport function formatHttpIdleTimeoutMs(timeoutMs: number): string {\n\tconst choice = HTTP_IDLE_TIMEOUT_CHOICES.find((item) => item.timeoutMs === timeoutMs);\n\tif (choice) {\n\t\treturn choice.label;\n\t}\n\treturn `${timeoutMs / 1000} sec`;\n}\n\nconst ignoreUndiciDispatcherError = (_error: unknown): void => {};\n\n// Undici can emit an internal Client \"error\" while terminating a mid-stream\n// fetch body. The body stream still rejects through reader.read(); this listener\n// only prevents EventEmitter's unhandled \"error\" special case from crashing grip.\nfunction withUndiciErrorListener<T extends undici.Dispatcher>(dispatcher: T): T {\n\tif (dispatcher instanceof EventEmitter) {\n\t\tEventEmitter.prototype.on.call(dispatcher, \"error\", ignoreUndiciDispatcherError);\n\t}\n\treturn dispatcher;\n}\n\nfunction createUndiciClient(origin: string | URL, options: object): undici.Dispatcher {\n\treturn withUndiciErrorListener(new undici.Client(origin, options as undici.Client.Options));\n}\n\nfunction createUndiciOriginDispatcher(origin: string | URL, options: object): undici.Dispatcher {\n\tconst dispatcherOptions = options as undici.Pool.Options;\n\tif (dispatcherOptions.connections === 1) {\n\t\treturn createUndiciClient(origin, dispatcherOptions);\n\t}\n\treturn withUndiciErrorListener(\n\t\tnew undici.Pool(origin, {\n\t\t\t...dispatcherOptions,\n\t\t\tfactory: createUndiciClient,\n\t\t}),\n\t);\n}\n\nfunction isMockedFetch(fetchImplementation: typeof globalThis.fetch | undefined): boolean {\n\treturn (fetchImplementation as { _isMockFunction?: unknown } | undefined)?._isMockFunction === true;\n}\n\nexport function configureHttpDispatcher(timeoutMs: number = DEFAULT_HTTP_IDLE_TIMEOUT_MS): void {\n\tconst normalizedTimeoutMs = parseHttpIdleTimeoutMs(timeoutMs);\n\tif (normalizedTimeoutMs === undefined) {\n\t\tthrow new Error(`Invalid HTTP idle timeout: ${String(timeoutMs)}`);\n\t}\n\tconst dispatcher = withUndiciErrorListener(\n\t\tnew undici.EnvHttpProxyAgent({\n\t\t\tallowH2: false,\n\t\t\tbodyTimeout: normalizedTimeoutMs,\n\t\t\theadersTimeout: normalizedTimeoutMs,\n\t\t\tclientFactory: createUndiciClient,\n\t\t\tfactory: createUndiciOriginDispatcher,\n\t\t}),\n\t);\n\tundici.setGlobalDispatcher(dispatcher);\n\t// Keep fetch and the dispatcher on the same undici implementation. Node 26.0's\n\t// bundled fetch can otherwise consume compressed responses through npm undici's\n\t// dispatcher without decompressing them, causing response.json() failures.\n\tconst existingFetch = globalThis.fetch;\n\tundici.install?.();\n\tif (isMockedFetch(existingFetch)) {\n\t\tglobalThis.fetch = existingFetch;\n\t}\n}\n"]}
@@ -32,6 +32,7 @@ interface InstructionResourcePromptFormatOptions {
32
32
  intro: string[];
33
33
  containerTag: string;
34
34
  itemTag: string;
35
+ includeLocation?: boolean;
35
36
  }
36
37
  export interface InstructionResourceLoaderOptions {
37
38
  cwd: string;
@@ -1 +1 @@
1
- {"version":3,"file":"instruction-resource-loader.d.ts","sourceRoot":"","sources":["../../src/core/instruction-resource-loader.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAW9E,OAAO,EAA6B,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,KAAK,EAAgB,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAS1E,MAAM,WAAW,8BAA8B;IAC9C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC1B,0BAA0B,CAAC,EAAE,OAAO,CAAC;IACrC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,mBAAmB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,UAAU,CAAC;IACvB,sBAAsB,EAAE,OAAO,CAAC;IAChC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,6BAA6B,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O,EAAE,gCAAgC,GAAG,6BAA6B,CAAC,SAAS,CAAC,CAuD3G;YAEa,6CAA6C;IA4C3D,UAAgB,2BAA2B,CAC1C,OAAO,EAAE,8CAA8C,GACrD,OAAO,CAAC,6BAA6B,CAAC,SAAS,CAAC,CAAC,CAqEnD;IAED,OAAO,CAAC,yBAAyB;IAcjC,OAAO,CAAC,cAAc;YAgBR,4BAA4B;IAsB1C,OAAO,CAAC,qBAAqB;IAS7B,OAAO,CAAC,2BAA2B;IAkBnC,OAAO,CAAC,uBAAuB;IAyB/B,OAAO,CAAC,8BAA8B;IAItC,OAAO,CAAC,4BAA4B;YAgCtB,uBAAuB;YAWvB,8BAA8B;YAkB9B,gCAAgC;YA6BhC,iCAAiC;YAIjC,0CAA0C;IAkCxD,OAAO,CAAC,oBAAoB;YAQd,kCAAkC;IAmBhD,OAAO,CAAC,aAAa;IAoCrB,OAAO,CAAC,gBAAgB;CAYxB;AAED,wBAAgB,mCAAmC,CAClD,SAAS,EAAE,mBAAmB,EAAE,EAChC,OAAO,EAAE,sCAAsC,GAC7C,MAAM,CAeR","sourcesContent":["import { type Dirent, existsSync, readdirSync, readFileSync, type Stats, statSync } from \"node:fs\";\nimport { dirname, join, relative, resolve, sep } from \"node:path\";\nimport ignore from \"ignore\";\nimport { CONFIG_DIR_NAME, getAgentDir } from \"../config.ts\";\nimport { parseFrontmatter } from \"../utils/frontmatter.ts\";\nimport { canonicalizePath, resolvePath } from \"../utils/paths.ts\";\nimport type { ResourceCollision, ResourceDiagnostic } from \"./diagnostics.ts\";\nimport {\n\tdirnamePortablePath,\n\tjoinPortablePath,\n\tnormalizePortablePath,\n\ttype PortablePathFlavor,\n\tpathComparisonValue,\n\trelativePortablePath,\n\trelativeWithin,\n\tresolvePortablePath,\n} from \"./lsp/portable-path.ts\";\nimport { createSyntheticSourceInfo, type SourceInfo } from \"./source-info.ts\";\nimport type { ToolFileStat, ToolOperations } from \"./tools/operations.ts\";\n\nconst MAX_NAME_LENGTH = 64;\nconst MAX_DESCRIPTION_LENGTH = 1024;\nconst IGNORE_FILE_NAMES = [\".gitignore\", \".ignore\", \".fdignore\"];\n\ntype ConfiguredResourceSource = \"user\" | \"project\" | \"path\";\ntype ResourceSource = ConfiguredResourceSource | string;\n\nexport interface InstructionResourceFrontmatter {\n\tname?: string;\n\tdescription?: string;\n\ttools?: string | string[];\n\t\"disable-model-invocation\"?: boolean;\n\t[key: string]: unknown;\n}\n\nexport interface InstructionResource {\n\tname: string;\n\tdescription: string;\n\tfilePath: string;\n\tbaseDir: string;\n\tsourceInfo: SourceInfo;\n\tdisableModelInvocation: boolean;\n\ttools?: string[];\n\tcontent?: string;\n}\n\nexport interface InstructionResourceLoadResult<TResource extends InstructionResource> {\n\tresources: TResource[];\n\tdiagnostics: ResourceDiagnostic[];\n}\n\nexport interface InstructionResourceDirectoryOptions {\n\t/** Directory to scan for instruction resources. */\n\tdir: string;\n\t/** Source identifier for these instruction resources. */\n\tsource: string;\n}\ninterface LocalResourceTraversal<TResource extends InstructionResource> {\n\tentries: Dirent[];\n\tdir: string;\n\tsource: string;\n\tincludeRootFiles: boolean;\n\tignoreMatcher: ignore.Ignore;\n\trootDir: string;\n\tresources: TResource[];\n\tdiagnostics: ResourceDiagnostic[];\n}\n\ninterface BackendResourceTraversal<TResource extends InstructionResource> {\n\tentries: string[];\n\toperations: ToolOperations;\n\tdir: string;\n\tsource: string;\n\tincludeRootFiles: boolean;\n\tignoreMatcher: ignore.Ignore;\n\trootDir: string;\n\tresources: TResource[];\n\tdiagnostics: ResourceDiagnostic[];\n}\n\ninterface InstructionResourceParseResult<TResource extends InstructionResource> {\n\tresource: TResource | null;\n\tdiagnostics: ResourceDiagnostic[];\n}\n\ninterface InstructionResourcePromptFormatOptions {\n\tintro: string[];\n\tcontainerTag: string;\n\titemTag: string;\n}\n\nexport interface InstructionResourceLoaderOptions {\n\tcwd: string;\n\tagentDir: string;\n\tresourcePaths: string[];\n\tincludeDefaults: boolean;\n}\n\nexport interface InstructionResourceLoaderWithOperationsOptions extends InstructionResourceLoaderOptions {\n\toperations: ToolOperations;\n}\n\nexport interface InstructionResourceLoaderConfig {\n\tresourceType: ResourceCollision[\"resourceType\"];\n\tdefaultDirectoryName: string;\n\trootFileName: string;\n}\n\nfunction toPosixPath(path: string): string {\n\treturn path.split(sep).join(\"/\");\n}\n\nfunction prefixIgnorePattern(line: string, prefix: string): string | null {\n\tconst trimmed = line.trim();\n\tif (!trimmed) return null;\n\tif (trimmed.startsWith(\"#\") && !trimmed.startsWith(\"\\\\#\")) return null;\n\n\tlet pattern = line;\n\tlet negated = false;\n\tif (pattern.startsWith(\"!\")) {\n\t\tnegated = true;\n\t\tpattern = pattern.slice(1);\n\t} else if (pattern.startsWith(\"\\\\!\")) {\n\t\tpattern = pattern.slice(1);\n\t}\n\tif (pattern.startsWith(\"/\")) pattern = pattern.slice(1);\n\n\tconst prefixed = prefix ? `${prefix}${pattern}` : pattern;\n\treturn negated ? `!${prefixed}` : prefixed;\n}\n\nfunction validateName(name: string): string[] {\n\tconst errors: string[] = [];\n\tif (name.length > MAX_NAME_LENGTH) {\n\t\terrors.push(`name exceeds ${MAX_NAME_LENGTH} characters (${name.length})`);\n\t}\n\tif (!/^[a-z0-9-]+$/.test(name)) {\n\t\terrors.push(\"name contains invalid characters (must be lowercase a-z, 0-9, hyphens only)\");\n\t}\n\tif (name.startsWith(\"-\") || name.endsWith(\"-\")) {\n\t\terrors.push(\"name must not start or end with a hyphen\");\n\t}\n\tif (name.includes(\"--\")) {\n\t\terrors.push(\"name must not contain consecutive hyphens\");\n\t}\n\treturn errors;\n}\n\nfunction validateDescription(description: string | undefined): string[] {\n\tif (!description || description.trim() === \"\") return [\"description is required\"];\n\tif (description.length > MAX_DESCRIPTION_LENGTH) {\n\t\treturn [`description exceeds ${MAX_DESCRIPTION_LENGTH} characters (${description.length})`];\n\t}\n\treturn [];\n}\n\nfunction normalizeFrontmatterTools(value: unknown): string[] {\n\tconst raw = Array.isArray(value) ? value : typeof value === \"string\" ? value.split(/[\\s,]+/) : [];\n\tconst tools: string[] = [];\n\tconst seen = new Set<string>();\n\tfor (const entry of raw) {\n\t\tif (typeof entry !== \"string\") continue;\n\t\tconst trimmed = entry.trim();\n\t\tif (trimmed.length > 0 && !seen.has(trimmed)) {\n\t\t\tseen.add(trimmed);\n\t\t\ttools.push(trimmed);\n\t\t}\n\t}\n\treturn tools;\n}\n\nfunction createResourceSourceInfo(filePath: string, baseDir: string, source: ResourceSource): SourceInfo {\n\tswitch (source) {\n\t\tcase \"user\":\n\t\t\treturn createSyntheticSourceInfo(filePath, { source: \"local\", scope: \"user\", baseDir });\n\t\tcase \"project\":\n\t\t\treturn createSyntheticSourceInfo(filePath, { source: \"local\", scope: \"project\", baseDir });\n\t\tcase \"path\":\n\t\t\treturn createSyntheticSourceInfo(filePath, { source: \"local\", baseDir });\n\t\tdefault:\n\t\t\treturn createSyntheticSourceInfo(filePath, { source, baseDir });\n\t}\n}\n\nfunction isUnderPath(target: string, root: string): boolean {\n\tconst normalizedRoot = resolve(root);\n\tif (target === normalizedRoot) return true;\n\tconst prefix = normalizedRoot.endsWith(sep) ? normalizedRoot : `${normalizedRoot}${sep}`;\n\treturn target.startsWith(prefix);\n}\n\nasync function backendPathExists(operations: ToolOperations, path: string): Promise<boolean> {\n\ttry {\n\t\tawait operations.access(path, \"exists\");\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nexport abstract class InstructionResourceLoader<\n\tTResource extends InstructionResource,\n\tTFrontmatter extends InstructionResourceFrontmatter,\n> {\n\tprivate resourceType: ResourceCollision[\"resourceType\"];\n\tprivate defaultDirectoryName: string;\n\tprivate rootFileName: string;\n\n\tconstructor(config: InstructionResourceLoaderConfig) {\n\t\tthis.resourceType = config.resourceType;\n\t\tthis.defaultDirectoryName = config.defaultDirectoryName;\n\t\tthis.rootFileName = config.rootFileName;\n\t}\n\n\tprotected abstract createResource(resource: InstructionResource, frontmatter: TFrontmatter): TResource;\n\n\tprotected loadResourcesFromDir(dir: string, source: string): InstructionResourceLoadResult<TResource> {\n\t\treturn this.loadResourcesFromDirInternal(dir, source, true);\n\t}\n\n\tprivate loadResourcesFromConfiguredPath(\n\t\tresolvedPath: string,\n\t\tsource: ConfiguredResourceSource,\n\t): InstructionResourceLoadResult<TResource> {\n\t\tif (!existsSync(resolvedPath)) {\n\t\t\treturn {\n\t\t\t\tresources: [],\n\t\t\t\tdiagnostics: [{ type: \"warning\", message: `${this.resourceType} path does not exist`, path: resolvedPath }],\n\t\t\t};\n\t\t}\n\t\ttry {\n\t\t\tconst stats = statSync(resolvedPath);\n\t\t\tif (stats.isDirectory()) return this.loadResourcesFromDirInternal(resolvedPath, source, true);\n\t\t\tif (!stats.isFile() || !resolvedPath.endsWith(\".md\")) {\n\t\t\t\treturn {\n\t\t\t\t\tresources: [],\n\t\t\t\t\tdiagnostics: [\n\t\t\t\t\t\t{ type: \"warning\", message: `${this.resourceType} path is not a markdown file`, path: resolvedPath },\n\t\t\t\t\t],\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst result = this.loadResourceFromFile(resolvedPath, source);\n\t\t\treturn { resources: result.resource ? [result.resource] : [], diagnostics: result.diagnostics };\n\t\t} catch (error) {\n\t\t\treturn {\n\t\t\t\tresources: [],\n\t\t\t\tdiagnostics: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"warning\",\n\t\t\t\t\t\tmessage: error instanceof Error ? error.message : `failed to read ${this.resourceType} path`,\n\t\t\t\t\t\tpath: resolvedPath,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t};\n\t\t}\n\t}\n\n\tprotected loadResources(options: InstructionResourceLoaderOptions): InstructionResourceLoadResult<TResource> {\n\t\tconst resolvedCwd = resolvePath(options.cwd);\n\t\tconst resolvedAgentDir = resolvePath(options.agentDir ?? getAgentDir());\n\t\tconst resourceMap = new Map<string, TResource>();\n\t\tconst realPathSet = new Set<string>();\n\t\tconst allDiagnostics: ResourceDiagnostic[] = [];\n\t\tconst collisionDiagnostics: ResourceDiagnostic[] = [];\n\n\t\tconst addResources = (result: InstructionResourceLoadResult<TResource>): void => {\n\t\t\tallDiagnostics.push(...result.diagnostics);\n\t\t\tfor (const resource of result.resources) {\n\t\t\t\tconst realPath = canonicalizePath(resource.filePath);\n\t\t\t\tif (realPathSet.has(realPath)) continue;\n\t\t\t\tconst existing = resourceMap.get(resource.name);\n\t\t\t\tif (existing) {\n\t\t\t\t\tcollisionDiagnostics.push(this.createCollisionDiagnostic(resource, existing));\n\t\t\t\t} else {\n\t\t\t\t\tresourceMap.set(resource.name, resource);\n\t\t\t\t\trealPathSet.add(realPath);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tif (options.includeDefaults) {\n\t\t\taddResources(\n\t\t\t\tthis.loadResourcesFromDirInternal(join(resolvedAgentDir, this.defaultDirectoryName), \"user\", true),\n\t\t\t);\n\t\t\taddResources(\n\t\t\t\tthis.loadResourcesFromDirInternal(\n\t\t\t\t\tresolve(resolvedCwd, CONFIG_DIR_NAME, this.defaultDirectoryName),\n\t\t\t\t\t\"project\",\n\t\t\t\t\ttrue,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\tconst userDir = join(resolvedAgentDir, this.defaultDirectoryName);\n\t\tconst projectDir = resolve(resolvedCwd, CONFIG_DIR_NAME, this.defaultDirectoryName);\n\t\tconst getSource = (resolvedPath: string): ConfiguredResourceSource => {\n\t\t\tif (!options.includeDefaults) {\n\t\t\t\tif (isUnderPath(resolvedPath, userDir)) return \"user\";\n\t\t\t\tif (isUnderPath(resolvedPath, projectDir)) return \"project\";\n\t\t\t}\n\t\t\treturn \"path\";\n\t\t};\n\n\t\tfor (const rawPath of options.resourcePaths) {\n\t\t\tconst resolvedPath = resolvePath(rawPath, resolvedCwd, { trim: true });\n\t\t\taddResources(this.loadResourcesFromConfiguredPath(resolvedPath, getSource(resolvedPath)));\n\t\t}\n\n\t\treturn {\n\t\t\tresources: Array.from(resourceMap.values()),\n\t\t\tdiagnostics: [...allDiagnostics, ...collisionDiagnostics],\n\t\t};\n\t}\n\n\tprivate async loadResourcesFromConfiguredPathWithOperations(\n\t\toperations: ToolOperations,\n\t\tresolvedPath: string,\n\t\tsource: ConfiguredResourceSource,\n\t): Promise<InstructionResourceLoadResult<TResource>> {\n\t\tif (!(await backendPathExists(operations, resolvedPath))) {\n\t\t\treturn {\n\t\t\t\tresources: [],\n\t\t\t\tdiagnostics: [{ type: \"warning\", message: `${this.resourceType} path does not exist`, path: resolvedPath }],\n\t\t\t};\n\t\t}\n\t\ttry {\n\t\t\tconst stats = await operations.stat(resolvedPath);\n\t\t\tif (stats.isDirectory()) {\n\t\t\t\treturn this.loadResourcesFromDirInternalWithOperations(operations, resolvedPath, source, true);\n\t\t\t}\n\t\t\tif (!stats.isFile() || !resolvedPath.endsWith(\".md\")) {\n\t\t\t\treturn {\n\t\t\t\t\tresources: [],\n\t\t\t\t\tdiagnostics: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"warning\",\n\t\t\t\t\t\t\tmessage: `${this.resourceType} path is not a markdown file`,\n\t\t\t\t\t\t\tpath: resolvedPath,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst result = await this.loadResourceFromFileWithOperations(operations, resolvedPath, source);\n\t\t\treturn { resources: result.resource ? [result.resource] : [], diagnostics: result.diagnostics };\n\t\t} catch (error) {\n\t\t\treturn {\n\t\t\t\tresources: [],\n\t\t\t\tdiagnostics: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"warning\",\n\t\t\t\t\t\tmessage: error instanceof Error ? error.message : `failed to read ${this.resourceType} path`,\n\t\t\t\t\t\tpath: resolvedPath,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t};\n\t\t}\n\t}\n\n\tprotected async loadResourcesWithOperations(\n\t\toptions: InstructionResourceLoaderWithOperationsOptions,\n\t): Promise<InstructionResourceLoadResult<TResource>> {\n\t\tconst backend = options.operations.getBackendInfo?.();\n\t\tconst pathFlavor = backend?.type === \"remote\" && backend.configured ? backend.workspace.pathFlavor : undefined;\n\t\tconst resolvedCwd = resolvePortablePath(options.operations.cwd, options.cwd);\n\t\tconst resolvedAgentDir = normalizePortablePath(options.agentDir ?? getAgentDir(), pathFlavor);\n\t\tconst resourceMap = new Map<string, TResource>();\n\t\tconst pathSet = new Set<string>();\n\t\tconst allDiagnostics: ResourceDiagnostic[] = [];\n\t\tconst collisionDiagnostics: ResourceDiagnostic[] = [];\n\n\t\tconst addResources = (result: InstructionResourceLoadResult<TResource>): void => {\n\t\t\tallDiagnostics.push(...result.diagnostics);\n\t\t\tfor (const resource of result.resources) {\n\t\t\t\tconst canonicalPath = pathComparisonValue(resource.filePath, pathFlavor);\n\t\t\t\tif (pathSet.has(canonicalPath)) continue;\n\t\t\t\tconst existing = resourceMap.get(resource.name);\n\t\t\t\tif (existing) {\n\t\t\t\t\tcollisionDiagnostics.push(this.createCollisionDiagnostic(resource, existing));\n\t\t\t\t} else {\n\t\t\t\t\tresourceMap.set(resource.name, resource);\n\t\t\t\t\tpathSet.add(canonicalPath);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tif (options.includeDefaults) {\n\t\t\taddResources(\n\t\t\t\tawait this.loadResourcesFromDirInternalWithOperations(\n\t\t\t\t\toptions.operations,\n\t\t\t\t\tjoinPortablePath(resolvedAgentDir, this.defaultDirectoryName),\n\t\t\t\t\t\"user\",\n\t\t\t\t\ttrue,\n\t\t\t\t),\n\t\t\t);\n\t\t\taddResources(\n\t\t\t\tawait this.loadResourcesFromDirInternalWithOperations(\n\t\t\t\t\toptions.operations,\n\t\t\t\t\tjoinPortablePath(resolvedCwd, CONFIG_DIR_NAME, this.defaultDirectoryName),\n\t\t\t\t\t\"project\",\n\t\t\t\t\ttrue,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\tconst userDir = joinPortablePath(resolvedAgentDir, this.defaultDirectoryName);\n\t\tconst projectDir = joinPortablePath(resolvedCwd, CONFIG_DIR_NAME, this.defaultDirectoryName);\n\t\tconst getSource = (resolvedPath: string): ConfiguredResourceSource => {\n\t\t\tif (!options.includeDefaults) {\n\t\t\t\tif (relativeWithin(userDir, resolvedPath) !== undefined) return \"user\";\n\t\t\t\tif (relativeWithin(projectDir, resolvedPath) !== undefined) return \"project\";\n\t\t\t}\n\t\t\treturn \"path\";\n\t\t};\n\n\t\tfor (const rawPath of options.resourcePaths) {\n\t\t\tconst resolvedPath = resolvePortablePath(resolvedCwd, rawPath.trim());\n\t\t\taddResources(\n\t\t\t\tawait this.loadResourcesFromConfiguredPathWithOperations(\n\t\t\t\t\toptions.operations,\n\t\t\t\t\tresolvedPath,\n\t\t\t\t\tgetSource(resolvedPath),\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\treturn {\n\t\t\tresources: Array.from(resourceMap.values()),\n\t\t\tdiagnostics: [...allDiagnostics, ...collisionDiagnostics],\n\t\t};\n\t}\n\n\tprivate createCollisionDiagnostic(resource: TResource, existing: TResource): ResourceDiagnostic {\n\t\treturn {\n\t\t\ttype: \"collision\",\n\t\t\tmessage: `name \"${resource.name}\" collision`,\n\t\t\tpath: resource.filePath,\n\t\t\tcollision: {\n\t\t\t\tresourceType: this.resourceType,\n\t\t\t\tname: resource.name,\n\t\t\t\twinnerPath: existing.filePath,\n\t\t\t\tloserPath: resource.filePath,\n\t\t\t},\n\t\t};\n\t}\n\n\tprivate addIgnoreRules(ig: ignore.Ignore, dir: string, rootDir: string): void {\n\t\tconst relativeDir = relative(rootDir, dir);\n\t\tconst prefix = relativeDir ? `${toPosixPath(relativeDir)}/` : \"\";\n\t\tfor (const filename of IGNORE_FILE_NAMES) {\n\t\t\tconst ignorePath = join(dir, filename);\n\t\t\tif (!existsSync(ignorePath)) continue;\n\t\t\ttry {\n\t\t\t\tconst patterns = readFileSync(ignorePath, \"utf-8\")\n\t\t\t\t\t.split(/\\r?\\n/)\n\t\t\t\t\t.map((line) => prefixIgnorePattern(line, prefix))\n\t\t\t\t\t.filter((line): line is string => Boolean(line));\n\t\t\t\tif (patterns.length > 0) ig.add(patterns);\n\t\t\t} catch {}\n\t\t}\n\t}\n\n\tprivate async addIgnoreRulesWithOperations(\n\t\toperations: ToolOperations,\n\t\tig: ignore.Ignore,\n\t\tdir: string,\n\t\trootDir: string,\n\t): Promise<void> {\n\t\tconst relativeDir = relativePortablePath(rootDir, dir);\n\t\tconst prefix = relativeDir && relativeDir !== \".\" ? `${relativeDir.replace(/\\\\/g, \"/\")}/` : \"\";\n\t\tfor (const filename of IGNORE_FILE_NAMES) {\n\t\t\tconst ignorePath = joinPortablePath(dir, filename);\n\t\t\tif (!(await backendPathExists(operations, ignorePath))) continue;\n\t\t\ttry {\n\t\t\t\tconst patterns = (await operations.readFile(ignorePath))\n\t\t\t\t\t.toString(\"utf-8\")\n\t\t\t\t\t.split(/\\r?\\n/)\n\t\t\t\t\t.map((line) => prefixIgnorePattern(line, prefix))\n\t\t\t\t\t.filter((line): line is string => Boolean(line));\n\t\t\t\tif (patterns.length > 0) ig.add(patterns);\n\t\t\t} catch {}\n\t\t}\n\t}\n\n\tprivate getLocalResourceEntry(entry: Dirent, fullPath: string): Dirent | Stats | undefined {\n\t\tif (!entry.isSymbolicLink()) return entry;\n\t\ttry {\n\t\t\treturn statSync(fullPath);\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tprivate loadRootResourceFromEntries(\n\t\tentries: Dirent[],\n\t\tdir: string,\n\t\tsource: string,\n\t\tignoreMatcher: ignore.Ignore,\n\t\trootDir: string,\n\t): InstructionResourceLoadResult<TResource> | undefined {\n\t\tfor (const entry of entries) {\n\t\t\tif (entry.name !== this.rootFileName) continue;\n\t\t\tconst fullPath = join(dir, entry.name);\n\t\t\tconst resourceEntry = this.getLocalResourceEntry(entry, fullPath);\n\t\t\tif (!resourceEntry?.isFile() || ignoreMatcher.ignores(toPosixPath(relative(rootDir, fullPath)))) continue;\n\t\t\tconst result = this.loadResourceFromFile(fullPath, source);\n\t\t\treturn { resources: result.resource ? [result.resource] : [], diagnostics: result.diagnostics };\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tprivate loadNestedResourceEntry(entry: Dirent, context: LocalResourceTraversal<TResource>): void {\n\t\tif (entry.name.startsWith(\".\") || entry.name === \"node_modules\") return;\n\t\tconst fullPath = join(context.dir, entry.name);\n\t\tconst resourceEntry = this.getLocalResourceEntry(entry, fullPath);\n\t\tif (!resourceEntry) return;\n\t\tconst relativePath = toPosixPath(relative(context.rootDir, fullPath));\n\t\tif (context.ignoreMatcher.ignores(resourceEntry.isDirectory() ? `${relativePath}/` : relativePath)) return;\n\t\tif (resourceEntry.isDirectory()) {\n\t\t\tconst nested = this.loadResourcesFromDirInternal(\n\t\t\t\tfullPath,\n\t\t\t\tcontext.source,\n\t\t\t\tfalse,\n\t\t\t\tcontext.ignoreMatcher,\n\t\t\t\tcontext.rootDir,\n\t\t\t);\n\t\t\tcontext.resources.push(...nested.resources);\n\t\t\tcontext.diagnostics.push(...nested.diagnostics);\n\t\t\treturn;\n\t\t}\n\t\tif (!resourceEntry.isFile() || !context.includeRootFiles || !entry.name.endsWith(\".md\")) return;\n\t\tconst result = this.loadResourceFromFile(fullPath, context.source);\n\t\tif (result.resource) context.resources.push(result.resource);\n\t\tcontext.diagnostics.push(...result.diagnostics);\n\t}\n\n\tprivate loadNestedResourcesFromEntries(context: LocalResourceTraversal<TResource>): void {\n\t\tfor (const entry of context.entries) this.loadNestedResourceEntry(entry, context);\n\t}\n\n\tprivate loadResourcesFromDirInternal(\n\t\tdir: string,\n\t\tsource: string,\n\t\tincludeRootFiles: boolean,\n\t\tignoreMatcher?: ignore.Ignore,\n\t\trootDir?: string,\n\t): InstructionResourceLoadResult<TResource> {\n\t\tconst resources: TResource[] = [];\n\t\tconst diagnostics: ResourceDiagnostic[] = [];\n\t\tif (!existsSync(dir)) return { resources, diagnostics };\n\n\t\tconst root = rootDir ?? dir;\n\t\tconst ig = ignoreMatcher ?? ignore();\n\t\tthis.addIgnoreRules(ig, dir, root);\n\t\ttry {\n\t\t\tconst entries = readdirSync(dir, { withFileTypes: true });\n\t\t\tconst rootResource = this.loadRootResourceFromEntries(entries, dir, source, ig, root);\n\t\t\tif (rootResource) return rootResource;\n\t\t\tthis.loadNestedResourcesFromEntries({\n\t\t\t\tentries,\n\t\t\t\tdir,\n\t\t\t\tsource,\n\t\t\t\tincludeRootFiles,\n\t\t\t\tignoreMatcher: ig,\n\t\t\t\trootDir: root,\n\t\t\t\tresources,\n\t\t\t\tdiagnostics,\n\t\t\t});\n\t\t} catch {}\n\t\treturn { resources, diagnostics };\n\t}\n\n\tprivate async getBackendResourceEntry(\n\t\toperations: ToolOperations,\n\t\tfullPath: string,\n\t): Promise<ToolFileStat | undefined> {\n\t\ttry {\n\t\t\treturn await operations.stat(fullPath);\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tprivate async loadRootResourceWithOperations(\n\t\tcontext: BackendResourceTraversal<TResource>,\n\t): Promise<InstructionResourceLoadResult<TResource> | undefined> {\n\t\tfor (const name of context.entries) {\n\t\t\tif (name !== this.rootFileName) continue;\n\t\t\tconst fullPath = joinPortablePath(context.dir, name);\n\t\t\tconst resourceEntry = await this.getBackendResourceEntry(context.operations, fullPath);\n\t\t\tif (\n\t\t\t\t!resourceEntry?.isFile() ||\n\t\t\t\tcontext.ignoreMatcher.ignores(relativePortablePath(context.rootDir, fullPath).replace(/\\\\/g, \"/\"))\n\t\t\t)\n\t\t\t\tcontinue;\n\t\t\tconst result = await this.loadResourceFromFileWithOperations(context.operations, fullPath, context.source);\n\t\t\treturn { resources: result.resource ? [result.resource] : [], diagnostics: result.diagnostics };\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tprivate async loadNestedResourceWithOperations(\n\t\tname: string,\n\t\tcontext: BackendResourceTraversal<TResource>,\n\t): Promise<void> {\n\t\tif (name.startsWith(\".\") || name === \"node_modules\") return;\n\t\tconst fullPath = joinPortablePath(context.dir, name);\n\t\tconst resourceEntry = await this.getBackendResourceEntry(context.operations, fullPath);\n\t\tif (!resourceEntry) return;\n\t\tconst relativePath = relativePortablePath(context.rootDir, fullPath).replace(/\\\\/g, \"/\");\n\t\tif (context.ignoreMatcher.ignores(resourceEntry.isDirectory() ? `${relativePath}/` : relativePath)) return;\n\t\tif (resourceEntry.isDirectory()) {\n\t\t\tconst nested = await this.loadResourcesFromDirInternalWithOperations(\n\t\t\t\tcontext.operations,\n\t\t\t\tfullPath,\n\t\t\t\tcontext.source,\n\t\t\t\tfalse,\n\t\t\t\tcontext.ignoreMatcher,\n\t\t\t\tcontext.rootDir,\n\t\t\t);\n\t\t\tcontext.resources.push(...nested.resources);\n\t\t\tcontext.diagnostics.push(...nested.diagnostics);\n\t\t\treturn;\n\t\t}\n\t\tif (!resourceEntry.isFile() || !context.includeRootFiles || !name.endsWith(\".md\")) return;\n\t\tconst result = await this.loadResourceFromFileWithOperations(context.operations, fullPath, context.source);\n\t\tif (result.resource) context.resources.push(result.resource);\n\t\tcontext.diagnostics.push(...result.diagnostics);\n\t}\n\n\tprivate async loadNestedResourcesWithOperations(context: BackendResourceTraversal<TResource>): Promise<void> {\n\t\tfor (const name of context.entries) await this.loadNestedResourceWithOperations(name, context);\n\t}\n\n\tprivate async loadResourcesFromDirInternalWithOperations(\n\t\toperations: ToolOperations,\n\t\tdir: string,\n\t\tsource: string,\n\t\tincludeRootFiles: boolean,\n\t\tignoreMatcher?: ignore.Ignore,\n\t\trootDir?: string,\n\t): Promise<InstructionResourceLoadResult<TResource>> {\n\t\tconst resources: TResource[] = [];\n\t\tconst diagnostics: ResourceDiagnostic[] = [];\n\t\tif (!(await backendPathExists(operations, dir))) return { resources, diagnostics };\n\n\t\tconst root = rootDir ?? dir;\n\t\tconst ig = ignoreMatcher ?? ignore();\n\t\tawait this.addIgnoreRulesWithOperations(operations, ig, dir, root);\n\t\ttry {\n\t\t\tconst context: BackendResourceTraversal<TResource> = {\n\t\t\t\tentries: await operations.readdir(dir),\n\t\t\t\toperations,\n\t\t\t\tdir,\n\t\t\t\tsource,\n\t\t\t\tincludeRootFiles,\n\t\t\t\tignoreMatcher: ig,\n\t\t\t\trootDir: root,\n\t\t\t\tresources,\n\t\t\t\tdiagnostics,\n\t\t\t};\n\t\t\tconst rootResource = await this.loadRootResourceWithOperations(context);\n\t\t\tif (rootResource) return rootResource;\n\t\t\tawait this.loadNestedResourcesWithOperations(context);\n\t\t} catch {}\n\t\treturn { resources, diagnostics };\n\t}\n\n\tprivate loadResourceFromFile(filePath: string, source: string): InstructionResourceParseResult<TResource> {\n\t\ttry {\n\t\t\treturn this.parseResource(readFileSync(filePath, \"utf-8\"), filePath, source);\n\t\t} catch (error) {\n\t\t\treturn this.createParseError(error, filePath);\n\t\t}\n\t}\n\n\tprivate async loadResourceFromFileWithOperations(\n\t\toperations: ToolOperations,\n\t\tfilePath: string,\n\t\tsource: string,\n\t): Promise<InstructionResourceParseResult<TResource>> {\n\t\ttry {\n\t\t\tconst backend = operations.getBackendInfo?.();\n\t\t\tconst pathFlavor = backend?.type === \"remote\" && backend.configured ? backend.workspace.pathFlavor : undefined;\n\t\t\treturn this.parseResource(\n\t\t\t\t(await operations.readFile(filePath)).toString(\"utf-8\"),\n\t\t\t\tfilePath,\n\t\t\t\tsource,\n\t\t\t\tpathFlavor,\n\t\t\t);\n\t\t} catch (error) {\n\t\t\treturn this.createParseError(error, filePath);\n\t\t}\n\t}\n\n\tprivate parseResource(\n\t\trawContent: string,\n\t\tfilePath: string,\n\t\tsource: string,\n\t\tpathFlavor?: PortablePathFlavor,\n\t): InstructionResourceParseResult<TResource> {\n\t\tconst diagnostics: ResourceDiagnostic[] = [];\n\t\tconst { frontmatter } = parseFrontmatter<TFrontmatter>(rawContent);\n\t\tfor (const error of validateDescription(frontmatter.description)) {\n\t\t\tdiagnostics.push({ type: \"warning\", message: error, path: filePath });\n\t\t}\n\t\tif (!frontmatter.name || frontmatter.name.trim() === \"\") {\n\t\t\tdiagnostics.push({ type: \"warning\", message: \"name is required\", path: filePath });\n\t\t}\n\t\tconst name = frontmatter.name;\n\t\tif (name) {\n\t\t\tfor (const error of validateName(name)) {\n\t\t\t\tdiagnostics.push({ type: \"warning\", message: error, path: filePath });\n\t\t\t}\n\t\t}\n\t\tif (!name || !frontmatter.description || frontmatter.description.trim() === \"\") {\n\t\t\treturn { resource: null, diagnostics };\n\t\t}\n\t\tconst baseDir = pathFlavor ? dirnamePortablePath(filePath, pathFlavor) : dirname(filePath);\n\t\tconst resource: InstructionResource = {\n\t\t\tname,\n\t\t\tdescription: frontmatter.description,\n\t\t\tfilePath,\n\t\t\tbaseDir,\n\t\t\tsourceInfo: createResourceSourceInfo(filePath, baseDir, source),\n\t\t\tdisableModelInvocation: frontmatter[\"disable-model-invocation\"] === true,\n\t\t\ttools: normalizeFrontmatterTools(frontmatter.tools),\n\t\t};\n\t\treturn { resource: this.createResource(resource, frontmatter), diagnostics };\n\t}\n\n\tprivate createParseError(error: unknown, filePath: string): InstructionResourceParseResult<TResource> {\n\t\treturn {\n\t\t\tresource: null,\n\t\t\tdiagnostics: [\n\t\t\t\t{\n\t\t\t\t\ttype: \"warning\",\n\t\t\t\t\tmessage: error instanceof Error ? error.message : `failed to parse ${this.resourceType} file`,\n\t\t\t\t\tpath: filePath,\n\t\t\t\t},\n\t\t\t],\n\t\t};\n\t}\n}\n\nexport function formatInstructionResourcesForPrompt(\n\tresources: InstructionResource[],\n\toptions: InstructionResourcePromptFormatOptions,\n): string {\n\tconst visibleResources = resources.filter((resource) => !resource.disableModelInvocation);\n\tif (visibleResources.length === 0) return \"\";\n\n\tconst [firstIntroLine = \"\", ...remainingIntroLines] = options.intro;\n\tconst lines = [`\\n\\n${firstIntroLine}`, ...remainingIntroLines, \"\", `<${options.containerTag}>`];\n\tfor (const resource of visibleResources) {\n\t\tlines.push(` <${options.itemTag}>`);\n\t\tlines.push(` <name>${escapeXml(resource.name)}</name>`);\n\t\tlines.push(` <description>${escapeXml(resource.description)}</description>`);\n\t\tlines.push(` <location>${escapeXml(resource.filePath)}</location>`);\n\t\tlines.push(` </${options.itemTag}>`);\n\t}\n\tlines.push(`</${options.containerTag}>`);\n\treturn lines.join(\"\\n\");\n}\n\nfunction escapeXml(value: string): string {\n\treturn value\n\t\t.replace(/&/g, \"&amp;\")\n\t\t.replace(/</g, \"&lt;\")\n\t\t.replace(/>/g, \"&gt;\")\n\t\t.replace(/\"/g, \"&quot;\")\n\t\t.replace(/'/g, \"&apos;\");\n}\n"]}
1
+ {"version":3,"file":"instruction-resource-loader.d.ts","sourceRoot":"","sources":["../../src/core/instruction-resource-loader.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAW9E,OAAO,EAA6B,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,KAAK,EAAgB,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAS1E,MAAM,WAAW,8BAA8B;IAC9C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC1B,0BAA0B,CAAC,EAAE,OAAO,CAAC;IACrC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,mBAAmB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,UAAU,CAAC;IACvB,sBAAsB,EAAE,OAAO,CAAC;IAChC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,6BAA6B,CAAC,SAAS,SAAS,mBAAmB;IACnF,SAAS,EAAE,SAAS,EAAE,CAAC;IACvB,WAAW,EAAE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,CAAC,CAuD3G;YAEa,6CAA6C;IA4C3D,UAAgB,2BAA2B,CAC1C,OAAO,EAAE,8CAA8C,GACrD,OAAO,CAAC,6BAA6B,CAAC,SAAS,CAAC,CAAC,CAqEnD;IAED,OAAO,CAAC,yBAAyB;IAcjC,OAAO,CAAC,cAAc;YAgBR,4BAA4B;IAsB1C,OAAO,CAAC,qBAAqB;IAS7B,OAAO,CAAC,2BAA2B;IAkBnC,OAAO,CAAC,uBAAuB;IAyB/B,OAAO,CAAC,8BAA8B;IAItC,OAAO,CAAC,4BAA4B;YAgCtB,uBAAuB;YAWvB,8BAA8B;YAkB9B,gCAAgC;YA6BhC,iCAAiC;YAIjC,0CAA0C;IAkCxD,OAAO,CAAC,oBAAoB;YAQd,kCAAkC;IAmBhD,OAAO,CAAC,aAAa;IAoCrB,OAAO,CAAC,gBAAgB;CAYxB;AAED,wBAAgB,mCAAmC,CAClD,SAAS,EAAE,mBAAmB,EAAE,EAChC,OAAO,EAAE,sCAAsC,GAC7C,MAAM,CAeR"}
@@ -100,9 +100,6 @@ async function backendPathExists(operations, path) {
100
100
  }
101
101
  }
102
102
  export class InstructionResourceLoader {
103
- resourceType;
104
- defaultDirectoryName;
105
- rootFileName;
106
103
  constructor(config) {
107
104
  this.resourceType = config.resourceType;
108
105
  this.defaultDirectoryName = config.defaultDirectoryName;
@@ -557,7 +554,8 @@ export function formatInstructionResourcesForPrompt(resources, options) {
557
554
  lines.push(` <${options.itemTag}>`);
558
555
  lines.push(` <name>${escapeXml(resource.name)}</name>`);
559
556
  lines.push(` <description>${escapeXml(resource.description)}</description>`);
560
- lines.push(` <location>${escapeXml(resource.filePath)}</location>`);
557
+ if (options.includeLocation !== false)
558
+ lines.push(` <location>${escapeXml(resource.filePath)}</location>`);
561
559
  lines.push(` </${options.itemTag}>`);
562
560
  }
563
561
  lines.push(`</${options.containerTag}>`);
@@ -1 +1 @@
1
- {"version":3,"file":"instruction-resource-loader.js","sourceRoot":"","sources":["../../src/core/instruction-resource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AAC;SACrB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC;SACvB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AAAA,CAC1B","sourcesContent":["import { type Dirent, existsSync, readdirSync, readFileSync, type Stats, statSync } from \"node:fs\";\nimport { dirname, join, relative, resolve, sep } from \"node:path\";\nimport ignore from \"ignore\";\nimport { CONFIG_DIR_NAME, getAgentDir } from \"../config.ts\";\nimport { parseFrontmatter } from \"../utils/frontmatter.ts\";\nimport { canonicalizePath, resolvePath } from \"../utils/paths.ts\";\nimport type { ResourceCollision, ResourceDiagnostic } from \"./diagnostics.ts\";\nimport {\n\tdirnamePortablePath,\n\tjoinPortablePath,\n\tnormalizePortablePath,\n\ttype PortablePathFlavor,\n\tpathComparisonValue,\n\trelativePortablePath,\n\trelativeWithin,\n\tresolvePortablePath,\n} from \"./lsp/portable-path.ts\";\nimport { createSyntheticSourceInfo, type SourceInfo } from \"./source-info.ts\";\nimport type { ToolFileStat, ToolOperations } from \"./tools/operations.ts\";\n\nconst MAX_NAME_LENGTH = 64;\nconst MAX_DESCRIPTION_LENGTH = 1024;\nconst IGNORE_FILE_NAMES = [\".gitignore\", \".ignore\", \".fdignore\"];\n\ntype ConfiguredResourceSource = \"user\" | \"project\" | \"path\";\ntype ResourceSource = ConfiguredResourceSource | string;\n\nexport interface InstructionResourceFrontmatter {\n\tname?: string;\n\tdescription?: string;\n\ttools?: string | string[];\n\t\"disable-model-invocation\"?: boolean;\n\t[key: string]: unknown;\n}\n\nexport interface InstructionResource {\n\tname: string;\n\tdescription: string;\n\tfilePath: string;\n\tbaseDir: string;\n\tsourceInfo: SourceInfo;\n\tdisableModelInvocation: boolean;\n\ttools?: string[];\n\tcontent?: string;\n}\n\nexport interface InstructionResourceLoadResult<TResource extends InstructionResource> {\n\tresources: TResource[];\n\tdiagnostics: ResourceDiagnostic[];\n}\n\nexport interface InstructionResourceDirectoryOptions {\n\t/** Directory to scan for instruction resources. */\n\tdir: string;\n\t/** Source identifier for these instruction resources. */\n\tsource: string;\n}\ninterface LocalResourceTraversal<TResource extends InstructionResource> {\n\tentries: Dirent[];\n\tdir: string;\n\tsource: string;\n\tincludeRootFiles: boolean;\n\tignoreMatcher: ignore.Ignore;\n\trootDir: string;\n\tresources: TResource[];\n\tdiagnostics: ResourceDiagnostic[];\n}\n\ninterface BackendResourceTraversal<TResource extends InstructionResource> {\n\tentries: string[];\n\toperations: ToolOperations;\n\tdir: string;\n\tsource: string;\n\tincludeRootFiles: boolean;\n\tignoreMatcher: ignore.Ignore;\n\trootDir: string;\n\tresources: TResource[];\n\tdiagnostics: ResourceDiagnostic[];\n}\n\ninterface InstructionResourceParseResult<TResource extends InstructionResource> {\n\tresource: TResource | null;\n\tdiagnostics: ResourceDiagnostic[];\n}\n\ninterface InstructionResourcePromptFormatOptions {\n\tintro: string[];\n\tcontainerTag: string;\n\titemTag: string;\n}\n\nexport interface InstructionResourceLoaderOptions {\n\tcwd: string;\n\tagentDir: string;\n\tresourcePaths: string[];\n\tincludeDefaults: boolean;\n}\n\nexport interface InstructionResourceLoaderWithOperationsOptions extends InstructionResourceLoaderOptions {\n\toperations: ToolOperations;\n}\n\nexport interface InstructionResourceLoaderConfig {\n\tresourceType: ResourceCollision[\"resourceType\"];\n\tdefaultDirectoryName: string;\n\trootFileName: string;\n}\n\nfunction toPosixPath(path: string): string {\n\treturn path.split(sep).join(\"/\");\n}\n\nfunction prefixIgnorePattern(line: string, prefix: string): string | null {\n\tconst trimmed = line.trim();\n\tif (!trimmed) return null;\n\tif (trimmed.startsWith(\"#\") && !trimmed.startsWith(\"\\\\#\")) return null;\n\n\tlet pattern = line;\n\tlet negated = false;\n\tif (pattern.startsWith(\"!\")) {\n\t\tnegated = true;\n\t\tpattern = pattern.slice(1);\n\t} else if (pattern.startsWith(\"\\\\!\")) {\n\t\tpattern = pattern.slice(1);\n\t}\n\tif (pattern.startsWith(\"/\")) pattern = pattern.slice(1);\n\n\tconst prefixed = prefix ? `${prefix}${pattern}` : pattern;\n\treturn negated ? `!${prefixed}` : prefixed;\n}\n\nfunction validateName(name: string): string[] {\n\tconst errors: string[] = [];\n\tif (name.length > MAX_NAME_LENGTH) {\n\t\terrors.push(`name exceeds ${MAX_NAME_LENGTH} characters (${name.length})`);\n\t}\n\tif (!/^[a-z0-9-]+$/.test(name)) {\n\t\terrors.push(\"name contains invalid characters (must be lowercase a-z, 0-9, hyphens only)\");\n\t}\n\tif (name.startsWith(\"-\") || name.endsWith(\"-\")) {\n\t\terrors.push(\"name must not start or end with a hyphen\");\n\t}\n\tif (name.includes(\"--\")) {\n\t\terrors.push(\"name must not contain consecutive hyphens\");\n\t}\n\treturn errors;\n}\n\nfunction validateDescription(description: string | undefined): string[] {\n\tif (!description || description.trim() === \"\") return [\"description is required\"];\n\tif (description.length > MAX_DESCRIPTION_LENGTH) {\n\t\treturn [`description exceeds ${MAX_DESCRIPTION_LENGTH} characters (${description.length})`];\n\t}\n\treturn [];\n}\n\nfunction normalizeFrontmatterTools(value: unknown): string[] {\n\tconst raw = Array.isArray(value) ? value : typeof value === \"string\" ? value.split(/[\\s,]+/) : [];\n\tconst tools: string[] = [];\n\tconst seen = new Set<string>();\n\tfor (const entry of raw) {\n\t\tif (typeof entry !== \"string\") continue;\n\t\tconst trimmed = entry.trim();\n\t\tif (trimmed.length > 0 && !seen.has(trimmed)) {\n\t\t\tseen.add(trimmed);\n\t\t\ttools.push(trimmed);\n\t\t}\n\t}\n\treturn tools;\n}\n\nfunction createResourceSourceInfo(filePath: string, baseDir: string, source: ResourceSource): SourceInfo {\n\tswitch (source) {\n\t\tcase \"user\":\n\t\t\treturn createSyntheticSourceInfo(filePath, { source: \"local\", scope: \"user\", baseDir });\n\t\tcase \"project\":\n\t\t\treturn createSyntheticSourceInfo(filePath, { source: \"local\", scope: \"project\", baseDir });\n\t\tcase \"path\":\n\t\t\treturn createSyntheticSourceInfo(filePath, { source: \"local\", baseDir });\n\t\tdefault:\n\t\t\treturn createSyntheticSourceInfo(filePath, { source, baseDir });\n\t}\n}\n\nfunction isUnderPath(target: string, root: string): boolean {\n\tconst normalizedRoot = resolve(root);\n\tif (target === normalizedRoot) return true;\n\tconst prefix = normalizedRoot.endsWith(sep) ? normalizedRoot : `${normalizedRoot}${sep}`;\n\treturn target.startsWith(prefix);\n}\n\nasync function backendPathExists(operations: ToolOperations, path: string): Promise<boolean> {\n\ttry {\n\t\tawait operations.access(path, \"exists\");\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nexport abstract class InstructionResourceLoader<\n\tTResource extends InstructionResource,\n\tTFrontmatter extends InstructionResourceFrontmatter,\n> {\n\tprivate resourceType: ResourceCollision[\"resourceType\"];\n\tprivate defaultDirectoryName: string;\n\tprivate rootFileName: string;\n\n\tconstructor(config: InstructionResourceLoaderConfig) {\n\t\tthis.resourceType = config.resourceType;\n\t\tthis.defaultDirectoryName = config.defaultDirectoryName;\n\t\tthis.rootFileName = config.rootFileName;\n\t}\n\n\tprotected abstract createResource(resource: InstructionResource, frontmatter: TFrontmatter): TResource;\n\n\tprotected loadResourcesFromDir(dir: string, source: string): InstructionResourceLoadResult<TResource> {\n\t\treturn this.loadResourcesFromDirInternal(dir, source, true);\n\t}\n\n\tprivate loadResourcesFromConfiguredPath(\n\t\tresolvedPath: string,\n\t\tsource: ConfiguredResourceSource,\n\t): InstructionResourceLoadResult<TResource> {\n\t\tif (!existsSync(resolvedPath)) {\n\t\t\treturn {\n\t\t\t\tresources: [],\n\t\t\t\tdiagnostics: [{ type: \"warning\", message: `${this.resourceType} path does not exist`, path: resolvedPath }],\n\t\t\t};\n\t\t}\n\t\ttry {\n\t\t\tconst stats = statSync(resolvedPath);\n\t\t\tif (stats.isDirectory()) return this.loadResourcesFromDirInternal(resolvedPath, source, true);\n\t\t\tif (!stats.isFile() || !resolvedPath.endsWith(\".md\")) {\n\t\t\t\treturn {\n\t\t\t\t\tresources: [],\n\t\t\t\t\tdiagnostics: [\n\t\t\t\t\t\t{ type: \"warning\", message: `${this.resourceType} path is not a markdown file`, path: resolvedPath },\n\t\t\t\t\t],\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst result = this.loadResourceFromFile(resolvedPath, source);\n\t\t\treturn { resources: result.resource ? [result.resource] : [], diagnostics: result.diagnostics };\n\t\t} catch (error) {\n\t\t\treturn {\n\t\t\t\tresources: [],\n\t\t\t\tdiagnostics: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"warning\",\n\t\t\t\t\t\tmessage: error instanceof Error ? error.message : `failed to read ${this.resourceType} path`,\n\t\t\t\t\t\tpath: resolvedPath,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t};\n\t\t}\n\t}\n\n\tprotected loadResources(options: InstructionResourceLoaderOptions): InstructionResourceLoadResult<TResource> {\n\t\tconst resolvedCwd = resolvePath(options.cwd);\n\t\tconst resolvedAgentDir = resolvePath(options.agentDir ?? getAgentDir());\n\t\tconst resourceMap = new Map<string, TResource>();\n\t\tconst realPathSet = new Set<string>();\n\t\tconst allDiagnostics: ResourceDiagnostic[] = [];\n\t\tconst collisionDiagnostics: ResourceDiagnostic[] = [];\n\n\t\tconst addResources = (result: InstructionResourceLoadResult<TResource>): void => {\n\t\t\tallDiagnostics.push(...result.diagnostics);\n\t\t\tfor (const resource of result.resources) {\n\t\t\t\tconst realPath = canonicalizePath(resource.filePath);\n\t\t\t\tif (realPathSet.has(realPath)) continue;\n\t\t\t\tconst existing = resourceMap.get(resource.name);\n\t\t\t\tif (existing) {\n\t\t\t\t\tcollisionDiagnostics.push(this.createCollisionDiagnostic(resource, existing));\n\t\t\t\t} else {\n\t\t\t\t\tresourceMap.set(resource.name, resource);\n\t\t\t\t\trealPathSet.add(realPath);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tif (options.includeDefaults) {\n\t\t\taddResources(\n\t\t\t\tthis.loadResourcesFromDirInternal(join(resolvedAgentDir, this.defaultDirectoryName), \"user\", true),\n\t\t\t);\n\t\t\taddResources(\n\t\t\t\tthis.loadResourcesFromDirInternal(\n\t\t\t\t\tresolve(resolvedCwd, CONFIG_DIR_NAME, this.defaultDirectoryName),\n\t\t\t\t\t\"project\",\n\t\t\t\t\ttrue,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\tconst userDir = join(resolvedAgentDir, this.defaultDirectoryName);\n\t\tconst projectDir = resolve(resolvedCwd, CONFIG_DIR_NAME, this.defaultDirectoryName);\n\t\tconst getSource = (resolvedPath: string): ConfiguredResourceSource => {\n\t\t\tif (!options.includeDefaults) {\n\t\t\t\tif (isUnderPath(resolvedPath, userDir)) return \"user\";\n\t\t\t\tif (isUnderPath(resolvedPath, projectDir)) return \"project\";\n\t\t\t}\n\t\t\treturn \"path\";\n\t\t};\n\n\t\tfor (const rawPath of options.resourcePaths) {\n\t\t\tconst resolvedPath = resolvePath(rawPath, resolvedCwd, { trim: true });\n\t\t\taddResources(this.loadResourcesFromConfiguredPath(resolvedPath, getSource(resolvedPath)));\n\t\t}\n\n\t\treturn {\n\t\t\tresources: Array.from(resourceMap.values()),\n\t\t\tdiagnostics: [...allDiagnostics, ...collisionDiagnostics],\n\t\t};\n\t}\n\n\tprivate async loadResourcesFromConfiguredPathWithOperations(\n\t\toperations: ToolOperations,\n\t\tresolvedPath: string,\n\t\tsource: ConfiguredResourceSource,\n\t): Promise<InstructionResourceLoadResult<TResource>> {\n\t\tif (!(await backendPathExists(operations, resolvedPath))) {\n\t\t\treturn {\n\t\t\t\tresources: [],\n\t\t\t\tdiagnostics: [{ type: \"warning\", message: `${this.resourceType} path does not exist`, path: resolvedPath }],\n\t\t\t};\n\t\t}\n\t\ttry {\n\t\t\tconst stats = await operations.stat(resolvedPath);\n\t\t\tif (stats.isDirectory()) {\n\t\t\t\treturn this.loadResourcesFromDirInternalWithOperations(operations, resolvedPath, source, true);\n\t\t\t}\n\t\t\tif (!stats.isFile() || !resolvedPath.endsWith(\".md\")) {\n\t\t\t\treturn {\n\t\t\t\t\tresources: [],\n\t\t\t\t\tdiagnostics: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"warning\",\n\t\t\t\t\t\t\tmessage: `${this.resourceType} path is not a markdown file`,\n\t\t\t\t\t\t\tpath: resolvedPath,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst result = await this.loadResourceFromFileWithOperations(operations, resolvedPath, source);\n\t\t\treturn { resources: result.resource ? [result.resource] : [], diagnostics: result.diagnostics };\n\t\t} catch (error) {\n\t\t\treturn {\n\t\t\t\tresources: [],\n\t\t\t\tdiagnostics: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"warning\",\n\t\t\t\t\t\tmessage: error instanceof Error ? error.message : `failed to read ${this.resourceType} path`,\n\t\t\t\t\t\tpath: resolvedPath,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t};\n\t\t}\n\t}\n\n\tprotected async loadResourcesWithOperations(\n\t\toptions: InstructionResourceLoaderWithOperationsOptions,\n\t): Promise<InstructionResourceLoadResult<TResource>> {\n\t\tconst backend = options.operations.getBackendInfo?.();\n\t\tconst pathFlavor = backend?.type === \"remote\" && backend.configured ? backend.workspace.pathFlavor : undefined;\n\t\tconst resolvedCwd = resolvePortablePath(options.operations.cwd, options.cwd);\n\t\tconst resolvedAgentDir = normalizePortablePath(options.agentDir ?? getAgentDir(), pathFlavor);\n\t\tconst resourceMap = new Map<string, TResource>();\n\t\tconst pathSet = new Set<string>();\n\t\tconst allDiagnostics: ResourceDiagnostic[] = [];\n\t\tconst collisionDiagnostics: ResourceDiagnostic[] = [];\n\n\t\tconst addResources = (result: InstructionResourceLoadResult<TResource>): void => {\n\t\t\tallDiagnostics.push(...result.diagnostics);\n\t\t\tfor (const resource of result.resources) {\n\t\t\t\tconst canonicalPath = pathComparisonValue(resource.filePath, pathFlavor);\n\t\t\t\tif (pathSet.has(canonicalPath)) continue;\n\t\t\t\tconst existing = resourceMap.get(resource.name);\n\t\t\t\tif (existing) {\n\t\t\t\t\tcollisionDiagnostics.push(this.createCollisionDiagnostic(resource, existing));\n\t\t\t\t} else {\n\t\t\t\t\tresourceMap.set(resource.name, resource);\n\t\t\t\t\tpathSet.add(canonicalPath);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tif (options.includeDefaults) {\n\t\t\taddResources(\n\t\t\t\tawait this.loadResourcesFromDirInternalWithOperations(\n\t\t\t\t\toptions.operations,\n\t\t\t\t\tjoinPortablePath(resolvedAgentDir, this.defaultDirectoryName),\n\t\t\t\t\t\"user\",\n\t\t\t\t\ttrue,\n\t\t\t\t),\n\t\t\t);\n\t\t\taddResources(\n\t\t\t\tawait this.loadResourcesFromDirInternalWithOperations(\n\t\t\t\t\toptions.operations,\n\t\t\t\t\tjoinPortablePath(resolvedCwd, CONFIG_DIR_NAME, this.defaultDirectoryName),\n\t\t\t\t\t\"project\",\n\t\t\t\t\ttrue,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\tconst userDir = joinPortablePath(resolvedAgentDir, this.defaultDirectoryName);\n\t\tconst projectDir = joinPortablePath(resolvedCwd, CONFIG_DIR_NAME, this.defaultDirectoryName);\n\t\tconst getSource = (resolvedPath: string): ConfiguredResourceSource => {\n\t\t\tif (!options.includeDefaults) {\n\t\t\t\tif (relativeWithin(userDir, resolvedPath) !== undefined) return \"user\";\n\t\t\t\tif (relativeWithin(projectDir, resolvedPath) !== undefined) return \"project\";\n\t\t\t}\n\t\t\treturn \"path\";\n\t\t};\n\n\t\tfor (const rawPath of options.resourcePaths) {\n\t\t\tconst resolvedPath = resolvePortablePath(resolvedCwd, rawPath.trim());\n\t\t\taddResources(\n\t\t\t\tawait this.loadResourcesFromConfiguredPathWithOperations(\n\t\t\t\t\toptions.operations,\n\t\t\t\t\tresolvedPath,\n\t\t\t\t\tgetSource(resolvedPath),\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\treturn {\n\t\t\tresources: Array.from(resourceMap.values()),\n\t\t\tdiagnostics: [...allDiagnostics, ...collisionDiagnostics],\n\t\t};\n\t}\n\n\tprivate createCollisionDiagnostic(resource: TResource, existing: TResource): ResourceDiagnostic {\n\t\treturn {\n\t\t\ttype: \"collision\",\n\t\t\tmessage: `name \"${resource.name}\" collision`,\n\t\t\tpath: resource.filePath,\n\t\t\tcollision: {\n\t\t\t\tresourceType: this.resourceType,\n\t\t\t\tname: resource.name,\n\t\t\t\twinnerPath: existing.filePath,\n\t\t\t\tloserPath: resource.filePath,\n\t\t\t},\n\t\t};\n\t}\n\n\tprivate addIgnoreRules(ig: ignore.Ignore, dir: string, rootDir: string): void {\n\t\tconst relativeDir = relative(rootDir, dir);\n\t\tconst prefix = relativeDir ? `${toPosixPath(relativeDir)}/` : \"\";\n\t\tfor (const filename of IGNORE_FILE_NAMES) {\n\t\t\tconst ignorePath = join(dir, filename);\n\t\t\tif (!existsSync(ignorePath)) continue;\n\t\t\ttry {\n\t\t\t\tconst patterns = readFileSync(ignorePath, \"utf-8\")\n\t\t\t\t\t.split(/\\r?\\n/)\n\t\t\t\t\t.map((line) => prefixIgnorePattern(line, prefix))\n\t\t\t\t\t.filter((line): line is string => Boolean(line));\n\t\t\t\tif (patterns.length > 0) ig.add(patterns);\n\t\t\t} catch {}\n\t\t}\n\t}\n\n\tprivate async addIgnoreRulesWithOperations(\n\t\toperations: ToolOperations,\n\t\tig: ignore.Ignore,\n\t\tdir: string,\n\t\trootDir: string,\n\t): Promise<void> {\n\t\tconst relativeDir = relativePortablePath(rootDir, dir);\n\t\tconst prefix = relativeDir && relativeDir !== \".\" ? `${relativeDir.replace(/\\\\/g, \"/\")}/` : \"\";\n\t\tfor (const filename of IGNORE_FILE_NAMES) {\n\t\t\tconst ignorePath = joinPortablePath(dir, filename);\n\t\t\tif (!(await backendPathExists(operations, ignorePath))) continue;\n\t\t\ttry {\n\t\t\t\tconst patterns = (await operations.readFile(ignorePath))\n\t\t\t\t\t.toString(\"utf-8\")\n\t\t\t\t\t.split(/\\r?\\n/)\n\t\t\t\t\t.map((line) => prefixIgnorePattern(line, prefix))\n\t\t\t\t\t.filter((line): line is string => Boolean(line));\n\t\t\t\tif (patterns.length > 0) ig.add(patterns);\n\t\t\t} catch {}\n\t\t}\n\t}\n\n\tprivate getLocalResourceEntry(entry: Dirent, fullPath: string): Dirent | Stats | undefined {\n\t\tif (!entry.isSymbolicLink()) return entry;\n\t\ttry {\n\t\t\treturn statSync(fullPath);\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tprivate loadRootResourceFromEntries(\n\t\tentries: Dirent[],\n\t\tdir: string,\n\t\tsource: string,\n\t\tignoreMatcher: ignore.Ignore,\n\t\trootDir: string,\n\t): InstructionResourceLoadResult<TResource> | undefined {\n\t\tfor (const entry of entries) {\n\t\t\tif (entry.name !== this.rootFileName) continue;\n\t\t\tconst fullPath = join(dir, entry.name);\n\t\t\tconst resourceEntry = this.getLocalResourceEntry(entry, fullPath);\n\t\t\tif (!resourceEntry?.isFile() || ignoreMatcher.ignores(toPosixPath(relative(rootDir, fullPath)))) continue;\n\t\t\tconst result = this.loadResourceFromFile(fullPath, source);\n\t\t\treturn { resources: result.resource ? [result.resource] : [], diagnostics: result.diagnostics };\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tprivate loadNestedResourceEntry(entry: Dirent, context: LocalResourceTraversal<TResource>): void {\n\t\tif (entry.name.startsWith(\".\") || entry.name === \"node_modules\") return;\n\t\tconst fullPath = join(context.dir, entry.name);\n\t\tconst resourceEntry = this.getLocalResourceEntry(entry, fullPath);\n\t\tif (!resourceEntry) return;\n\t\tconst relativePath = toPosixPath(relative(context.rootDir, fullPath));\n\t\tif (context.ignoreMatcher.ignores(resourceEntry.isDirectory() ? `${relativePath}/` : relativePath)) return;\n\t\tif (resourceEntry.isDirectory()) {\n\t\t\tconst nested = this.loadResourcesFromDirInternal(\n\t\t\t\tfullPath,\n\t\t\t\tcontext.source,\n\t\t\t\tfalse,\n\t\t\t\tcontext.ignoreMatcher,\n\t\t\t\tcontext.rootDir,\n\t\t\t);\n\t\t\tcontext.resources.push(...nested.resources);\n\t\t\tcontext.diagnostics.push(...nested.diagnostics);\n\t\t\treturn;\n\t\t}\n\t\tif (!resourceEntry.isFile() || !context.includeRootFiles || !entry.name.endsWith(\".md\")) return;\n\t\tconst result = this.loadResourceFromFile(fullPath, context.source);\n\t\tif (result.resource) context.resources.push(result.resource);\n\t\tcontext.diagnostics.push(...result.diagnostics);\n\t}\n\n\tprivate loadNestedResourcesFromEntries(context: LocalResourceTraversal<TResource>): void {\n\t\tfor (const entry of context.entries) this.loadNestedResourceEntry(entry, context);\n\t}\n\n\tprivate loadResourcesFromDirInternal(\n\t\tdir: string,\n\t\tsource: string,\n\t\tincludeRootFiles: boolean,\n\t\tignoreMatcher?: ignore.Ignore,\n\t\trootDir?: string,\n\t): InstructionResourceLoadResult<TResource> {\n\t\tconst resources: TResource[] = [];\n\t\tconst diagnostics: ResourceDiagnostic[] = [];\n\t\tif (!existsSync(dir)) return { resources, diagnostics };\n\n\t\tconst root = rootDir ?? dir;\n\t\tconst ig = ignoreMatcher ?? ignore();\n\t\tthis.addIgnoreRules(ig, dir, root);\n\t\ttry {\n\t\t\tconst entries = readdirSync(dir, { withFileTypes: true });\n\t\t\tconst rootResource = this.loadRootResourceFromEntries(entries, dir, source, ig, root);\n\t\t\tif (rootResource) return rootResource;\n\t\t\tthis.loadNestedResourcesFromEntries({\n\t\t\t\tentries,\n\t\t\t\tdir,\n\t\t\t\tsource,\n\t\t\t\tincludeRootFiles,\n\t\t\t\tignoreMatcher: ig,\n\t\t\t\trootDir: root,\n\t\t\t\tresources,\n\t\t\t\tdiagnostics,\n\t\t\t});\n\t\t} catch {}\n\t\treturn { resources, diagnostics };\n\t}\n\n\tprivate async getBackendResourceEntry(\n\t\toperations: ToolOperations,\n\t\tfullPath: string,\n\t): Promise<ToolFileStat | undefined> {\n\t\ttry {\n\t\t\treturn await operations.stat(fullPath);\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tprivate async loadRootResourceWithOperations(\n\t\tcontext: BackendResourceTraversal<TResource>,\n\t): Promise<InstructionResourceLoadResult<TResource> | undefined> {\n\t\tfor (const name of context.entries) {\n\t\t\tif (name !== this.rootFileName) continue;\n\t\t\tconst fullPath = joinPortablePath(context.dir, name);\n\t\t\tconst resourceEntry = await this.getBackendResourceEntry(context.operations, fullPath);\n\t\t\tif (\n\t\t\t\t!resourceEntry?.isFile() ||\n\t\t\t\tcontext.ignoreMatcher.ignores(relativePortablePath(context.rootDir, fullPath).replace(/\\\\/g, \"/\"))\n\t\t\t)\n\t\t\t\tcontinue;\n\t\t\tconst result = await this.loadResourceFromFileWithOperations(context.operations, fullPath, context.source);\n\t\t\treturn { resources: result.resource ? [result.resource] : [], diagnostics: result.diagnostics };\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tprivate async loadNestedResourceWithOperations(\n\t\tname: string,\n\t\tcontext: BackendResourceTraversal<TResource>,\n\t): Promise<void> {\n\t\tif (name.startsWith(\".\") || name === \"node_modules\") return;\n\t\tconst fullPath = joinPortablePath(context.dir, name);\n\t\tconst resourceEntry = await this.getBackendResourceEntry(context.operations, fullPath);\n\t\tif (!resourceEntry) return;\n\t\tconst relativePath = relativePortablePath(context.rootDir, fullPath).replace(/\\\\/g, \"/\");\n\t\tif (context.ignoreMatcher.ignores(resourceEntry.isDirectory() ? `${relativePath}/` : relativePath)) return;\n\t\tif (resourceEntry.isDirectory()) {\n\t\t\tconst nested = await this.loadResourcesFromDirInternalWithOperations(\n\t\t\t\tcontext.operations,\n\t\t\t\tfullPath,\n\t\t\t\tcontext.source,\n\t\t\t\tfalse,\n\t\t\t\tcontext.ignoreMatcher,\n\t\t\t\tcontext.rootDir,\n\t\t\t);\n\t\t\tcontext.resources.push(...nested.resources);\n\t\t\tcontext.diagnostics.push(...nested.diagnostics);\n\t\t\treturn;\n\t\t}\n\t\tif (!resourceEntry.isFile() || !context.includeRootFiles || !name.endsWith(\".md\")) return;\n\t\tconst result = await this.loadResourceFromFileWithOperations(context.operations, fullPath, context.source);\n\t\tif (result.resource) context.resources.push(result.resource);\n\t\tcontext.diagnostics.push(...result.diagnostics);\n\t}\n\n\tprivate async loadNestedResourcesWithOperations(context: BackendResourceTraversal<TResource>): Promise<void> {\n\t\tfor (const name of context.entries) await this.loadNestedResourceWithOperations(name, context);\n\t}\n\n\tprivate async loadResourcesFromDirInternalWithOperations(\n\t\toperations: ToolOperations,\n\t\tdir: string,\n\t\tsource: string,\n\t\tincludeRootFiles: boolean,\n\t\tignoreMatcher?: ignore.Ignore,\n\t\trootDir?: string,\n\t): Promise<InstructionResourceLoadResult<TResource>> {\n\t\tconst resources: TResource[] = [];\n\t\tconst diagnostics: ResourceDiagnostic[] = [];\n\t\tif (!(await backendPathExists(operations, dir))) return { resources, diagnostics };\n\n\t\tconst root = rootDir ?? dir;\n\t\tconst ig = ignoreMatcher ?? ignore();\n\t\tawait this.addIgnoreRulesWithOperations(operations, ig, dir, root);\n\t\ttry {\n\t\t\tconst context: BackendResourceTraversal<TResource> = {\n\t\t\t\tentries: await operations.readdir(dir),\n\t\t\t\toperations,\n\t\t\t\tdir,\n\t\t\t\tsource,\n\t\t\t\tincludeRootFiles,\n\t\t\t\tignoreMatcher: ig,\n\t\t\t\trootDir: root,\n\t\t\t\tresources,\n\t\t\t\tdiagnostics,\n\t\t\t};\n\t\t\tconst rootResource = await this.loadRootResourceWithOperations(context);\n\t\t\tif (rootResource) return rootResource;\n\t\t\tawait this.loadNestedResourcesWithOperations(context);\n\t\t} catch {}\n\t\treturn { resources, diagnostics };\n\t}\n\n\tprivate loadResourceFromFile(filePath: string, source: string): InstructionResourceParseResult<TResource> {\n\t\ttry {\n\t\t\treturn this.parseResource(readFileSync(filePath, \"utf-8\"), filePath, source);\n\t\t} catch (error) {\n\t\t\treturn this.createParseError(error, filePath);\n\t\t}\n\t}\n\n\tprivate async loadResourceFromFileWithOperations(\n\t\toperations: ToolOperations,\n\t\tfilePath: string,\n\t\tsource: string,\n\t): Promise<InstructionResourceParseResult<TResource>> {\n\t\ttry {\n\t\t\tconst backend = operations.getBackendInfo?.();\n\t\t\tconst pathFlavor = backend?.type === \"remote\" && backend.configured ? backend.workspace.pathFlavor : undefined;\n\t\t\treturn this.parseResource(\n\t\t\t\t(await operations.readFile(filePath)).toString(\"utf-8\"),\n\t\t\t\tfilePath,\n\t\t\t\tsource,\n\t\t\t\tpathFlavor,\n\t\t\t);\n\t\t} catch (error) {\n\t\t\treturn this.createParseError(error, filePath);\n\t\t}\n\t}\n\n\tprivate parseResource(\n\t\trawContent: string,\n\t\tfilePath: string,\n\t\tsource: string,\n\t\tpathFlavor?: PortablePathFlavor,\n\t): InstructionResourceParseResult<TResource> {\n\t\tconst diagnostics: ResourceDiagnostic[] = [];\n\t\tconst { frontmatter } = parseFrontmatter<TFrontmatter>(rawContent);\n\t\tfor (const error of validateDescription(frontmatter.description)) {\n\t\t\tdiagnostics.push({ type: \"warning\", message: error, path: filePath });\n\t\t}\n\t\tif (!frontmatter.name || frontmatter.name.trim() === \"\") {\n\t\t\tdiagnostics.push({ type: \"warning\", message: \"name is required\", path: filePath });\n\t\t}\n\t\tconst name = frontmatter.name;\n\t\tif (name) {\n\t\t\tfor (const error of validateName(name)) {\n\t\t\t\tdiagnostics.push({ type: \"warning\", message: error, path: filePath });\n\t\t\t}\n\t\t}\n\t\tif (!name || !frontmatter.description || frontmatter.description.trim() === \"\") {\n\t\t\treturn { resource: null, diagnostics };\n\t\t}\n\t\tconst baseDir = pathFlavor ? dirnamePortablePath(filePath, pathFlavor) : dirname(filePath);\n\t\tconst resource: InstructionResource = {\n\t\t\tname,\n\t\t\tdescription: frontmatter.description,\n\t\t\tfilePath,\n\t\t\tbaseDir,\n\t\t\tsourceInfo: createResourceSourceInfo(filePath, baseDir, source),\n\t\t\tdisableModelInvocation: frontmatter[\"disable-model-invocation\"] === true,\n\t\t\ttools: normalizeFrontmatterTools(frontmatter.tools),\n\t\t};\n\t\treturn { resource: this.createResource(resource, frontmatter), diagnostics };\n\t}\n\n\tprivate createParseError(error: unknown, filePath: string): InstructionResourceParseResult<TResource> {\n\t\treturn {\n\t\t\tresource: null,\n\t\t\tdiagnostics: [\n\t\t\t\t{\n\t\t\t\t\ttype: \"warning\",\n\t\t\t\t\tmessage: error instanceof Error ? error.message : `failed to parse ${this.resourceType} file`,\n\t\t\t\t\tpath: filePath,\n\t\t\t\t},\n\t\t\t],\n\t\t};\n\t}\n}\n\nexport function formatInstructionResourcesForPrompt(\n\tresources: InstructionResource[],\n\toptions: InstructionResourcePromptFormatOptions,\n): string {\n\tconst visibleResources = resources.filter((resource) => !resource.disableModelInvocation);\n\tif (visibleResources.length === 0) return \"\";\n\n\tconst [firstIntroLine = \"\", ...remainingIntroLines] = options.intro;\n\tconst lines = [`\\n\\n${firstIntroLine}`, ...remainingIntroLines, \"\", `<${options.containerTag}>`];\n\tfor (const resource of visibleResources) {\n\t\tlines.push(` <${options.itemTag}>`);\n\t\tlines.push(` <name>${escapeXml(resource.name)}</name>`);\n\t\tlines.push(` <description>${escapeXml(resource.description)}</description>`);\n\t\tlines.push(` <location>${escapeXml(resource.filePath)}</location>`);\n\t\tlines.push(` </${options.itemTag}>`);\n\t}\n\tlines.push(`</${options.containerTag}>`);\n\treturn lines.join(\"\\n\");\n}\n\nfunction escapeXml(value: string): string {\n\treturn value\n\t\t.replace(/&/g, \"&amp;\")\n\t\t.replace(/</g, \"&lt;\")\n\t\t.replace(/>/g, \"&gt;\")\n\t\t.replace(/\"/g, \"&quot;\")\n\t\t.replace(/'/g, \"&apos;\");\n}\n"]}
1
+ {"version":3,"file":"instruction-resource-loader.js","sourceRoot":"","sources":["../../src/core/instruction-resource-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,UAAU,EAAE,WAAW,EAAE,YAAY,EAAc,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnG,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAA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C;QACzC,KAAK,CAAC,IAAI,CAAC,MAAM,OAAO,CAAC,OAAO,GAAG,CAAC,CAAC;QACrC,KAAK,CAAC,IAAI,CAAC,aAAa,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC3D,KAAK,CAAC,IAAI,CAAC,oBAAoB,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC;QAChF,IAAI,OAAO,CAAC,eAAe,KAAK,KAAK;YAAE,KAAK,CAAC,IAAI,CAAC,iBAAiB,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;QAC9G,KAAK,CAAC,IAAI,CAAC,OAAO,OAAO,CAAC,OAAO,GAAG,CAAC,CAAC;IACvC,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,KAAK,OAAO,CAAC,YAAY,GAAG,CAAC,CAAC;IACzC,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC;AAED,SAAS,SAAS,CAAC,KAAa;IAC/B,OAAO,KAAK;SACV,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;SACtB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC;SACvB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AAC3B,CAAC","sourcesContent":["import { type Dirent, existsSync, readdirSync, readFileSync, type Stats, statSync } from \"node:fs\";\nimport { dirname, join, relative, resolve, sep } from \"node:path\";\nimport ignore from \"ignore\";\nimport { CONFIG_DIR_NAME, getAgentDir } from \"../config.ts\";\nimport { parseFrontmatter } from \"../utils/frontmatter.ts\";\nimport { canonicalizePath, resolvePath } from \"../utils/paths.ts\";\nimport type { ResourceCollision, ResourceDiagnostic } from \"./diagnostics.ts\";\nimport {\n\tdirnamePortablePath,\n\tjoinPortablePath,\n\tnormalizePortablePath,\n\ttype PortablePathFlavor,\n\tpathComparisonValue,\n\trelativePortablePath,\n\trelativeWithin,\n\tresolvePortablePath,\n} from \"./lsp/portable-path.ts\";\nimport { createSyntheticSourceInfo, type SourceInfo } from \"./source-info.ts\";\nimport type { ToolFileStat, ToolOperations } from \"./tools/operations.ts\";\n\nconst MAX_NAME_LENGTH = 64;\nconst MAX_DESCRIPTION_LENGTH = 1024;\nconst IGNORE_FILE_NAMES = [\".gitignore\", \".ignore\", \".fdignore\"];\n\ntype ConfiguredResourceSource = \"user\" | \"project\" | \"path\";\ntype ResourceSource = ConfiguredResourceSource | string;\n\nexport interface InstructionResourceFrontmatter {\n\tname?: string;\n\tdescription?: string;\n\ttools?: string | string[];\n\t\"disable-model-invocation\"?: boolean;\n\t[key: string]: unknown;\n}\n\nexport interface InstructionResource {\n\tname: string;\n\tdescription: string;\n\tfilePath: string;\n\tbaseDir: string;\n\tsourceInfo: SourceInfo;\n\tdisableModelInvocation: boolean;\n\ttools?: string[];\n\tcontent?: string;\n}\n\nexport interface InstructionResourceLoadResult<TResource extends InstructionResource> {\n\tresources: TResource[];\n\tdiagnostics: ResourceDiagnostic[];\n}\n\nexport interface InstructionResourceDirectoryOptions {\n\t/** Directory to scan for instruction resources. */\n\tdir: string;\n\t/** Source identifier for these instruction resources. */\n\tsource: string;\n}\ninterface LocalResourceTraversal<TResource extends InstructionResource> {\n\tentries: Dirent[];\n\tdir: string;\n\tsource: string;\n\tincludeRootFiles: boolean;\n\tignoreMatcher: ignore.Ignore;\n\trootDir: string;\n\tresources: TResource[];\n\tdiagnostics: ResourceDiagnostic[];\n}\n\ninterface BackendResourceTraversal<TResource extends InstructionResource> {\n\tentries: string[];\n\toperations: ToolOperations;\n\tdir: string;\n\tsource: string;\n\tincludeRootFiles: boolean;\n\tignoreMatcher: ignore.Ignore;\n\trootDir: string;\n\tresources: TResource[];\n\tdiagnostics: ResourceDiagnostic[];\n}\n\ninterface InstructionResourceParseResult<TResource extends InstructionResource> {\n\tresource: TResource | null;\n\tdiagnostics: ResourceDiagnostic[];\n}\n\ninterface InstructionResourcePromptFormatOptions {\n\tintro: string[];\n\tcontainerTag: string;\n\titemTag: string;\n\tincludeLocation?: boolean;\n}\n\nexport interface InstructionResourceLoaderOptions {\n\tcwd: string;\n\tagentDir: string;\n\tresourcePaths: string[];\n\tincludeDefaults: boolean;\n}\n\nexport interface InstructionResourceLoaderWithOperationsOptions extends InstructionResourceLoaderOptions {\n\toperations: ToolOperations;\n}\n\nexport interface InstructionResourceLoaderConfig {\n\tresourceType: ResourceCollision[\"resourceType\"];\n\tdefaultDirectoryName: string;\n\trootFileName: string;\n}\n\nfunction toPosixPath(path: string): string {\n\treturn path.split(sep).join(\"/\");\n}\n\nfunction prefixIgnorePattern(line: string, prefix: string): string | null {\n\tconst trimmed = line.trim();\n\tif (!trimmed) return null;\n\tif (trimmed.startsWith(\"#\") && !trimmed.startsWith(\"\\\\#\")) return null;\n\n\tlet pattern = line;\n\tlet negated = false;\n\tif (pattern.startsWith(\"!\")) {\n\t\tnegated = true;\n\t\tpattern = pattern.slice(1);\n\t} else if (pattern.startsWith(\"\\\\!\")) {\n\t\tpattern = pattern.slice(1);\n\t}\n\tif (pattern.startsWith(\"/\")) pattern = pattern.slice(1);\n\n\tconst prefixed = prefix ? `${prefix}${pattern}` : pattern;\n\treturn negated ? `!${prefixed}` : prefixed;\n}\n\nfunction validateName(name: string): string[] {\n\tconst errors: string[] = [];\n\tif (name.length > MAX_NAME_LENGTH) {\n\t\terrors.push(`name exceeds ${MAX_NAME_LENGTH} characters (${name.length})`);\n\t}\n\tif (!/^[a-z0-9-]+$/.test(name)) {\n\t\terrors.push(\"name contains invalid characters (must be lowercase a-z, 0-9, hyphens only)\");\n\t}\n\tif (name.startsWith(\"-\") || name.endsWith(\"-\")) {\n\t\terrors.push(\"name must not start or end with a hyphen\");\n\t}\n\tif (name.includes(\"--\")) {\n\t\terrors.push(\"name must not contain consecutive hyphens\");\n\t}\n\treturn errors;\n}\n\nfunction validateDescription(description: string | undefined): string[] {\n\tif (!description || description.trim() === \"\") return [\"description is required\"];\n\tif (description.length > MAX_DESCRIPTION_LENGTH) {\n\t\treturn [`description exceeds ${MAX_DESCRIPTION_LENGTH} characters (${description.length})`];\n\t}\n\treturn [];\n}\n\nfunction normalizeFrontmatterTools(value: unknown): string[] {\n\tconst raw = Array.isArray(value) ? value : typeof value === \"string\" ? value.split(/[\\s,]+/) : [];\n\tconst tools: string[] = [];\n\tconst seen = new Set<string>();\n\tfor (const entry of raw) {\n\t\tif (typeof entry !== \"string\") continue;\n\t\tconst trimmed = entry.trim();\n\t\tif (trimmed.length > 0 && !seen.has(trimmed)) {\n\t\t\tseen.add(trimmed);\n\t\t\ttools.push(trimmed);\n\t\t}\n\t}\n\treturn tools;\n}\n\nfunction createResourceSourceInfo(filePath: string, baseDir: string, source: ResourceSource): SourceInfo {\n\tswitch (source) {\n\t\tcase \"user\":\n\t\t\treturn createSyntheticSourceInfo(filePath, { source: \"local\", scope: \"user\", baseDir });\n\t\tcase \"project\":\n\t\t\treturn createSyntheticSourceInfo(filePath, { source: \"local\", scope: \"project\", baseDir });\n\t\tcase \"path\":\n\t\t\treturn createSyntheticSourceInfo(filePath, { source: \"local\", baseDir });\n\t\tdefault:\n\t\t\treturn createSyntheticSourceInfo(filePath, { source, baseDir });\n\t}\n}\n\nfunction isUnderPath(target: string, root: string): boolean {\n\tconst normalizedRoot = resolve(root);\n\tif (target === normalizedRoot) return true;\n\tconst prefix = normalizedRoot.endsWith(sep) ? normalizedRoot : `${normalizedRoot}${sep}`;\n\treturn target.startsWith(prefix);\n}\n\nasync function backendPathExists(operations: ToolOperations, path: string): Promise<boolean> {\n\ttry {\n\t\tawait operations.access(path, \"exists\");\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nexport abstract class InstructionResourceLoader<\n\tTResource extends InstructionResource,\n\tTFrontmatter extends InstructionResourceFrontmatter,\n> {\n\tprivate resourceType: ResourceCollision[\"resourceType\"];\n\tprivate defaultDirectoryName: string;\n\tprivate rootFileName: string;\n\n\tconstructor(config: InstructionResourceLoaderConfig) {\n\t\tthis.resourceType = config.resourceType;\n\t\tthis.defaultDirectoryName = config.defaultDirectoryName;\n\t\tthis.rootFileName = config.rootFileName;\n\t}\n\n\tprotected abstract createResource(resource: InstructionResource, frontmatter: TFrontmatter): TResource;\n\n\tprotected loadResourcesFromDir(dir: string, source: string): InstructionResourceLoadResult<TResource> {\n\t\treturn this.loadResourcesFromDirInternal(dir, source, true);\n\t}\n\n\tprivate loadResourcesFromConfiguredPath(\n\t\tresolvedPath: string,\n\t\tsource: ConfiguredResourceSource,\n\t): InstructionResourceLoadResult<TResource> {\n\t\tif (!existsSync(resolvedPath)) {\n\t\t\treturn {\n\t\t\t\tresources: [],\n\t\t\t\tdiagnostics: [{ type: \"warning\", message: `${this.resourceType} path does not exist`, path: resolvedPath }],\n\t\t\t};\n\t\t}\n\t\ttry {\n\t\t\tconst stats = statSync(resolvedPath);\n\t\t\tif (stats.isDirectory()) return this.loadResourcesFromDirInternal(resolvedPath, source, true);\n\t\t\tif (!stats.isFile() || !resolvedPath.endsWith(\".md\")) {\n\t\t\t\treturn {\n\t\t\t\t\tresources: [],\n\t\t\t\t\tdiagnostics: [\n\t\t\t\t\t\t{ type: \"warning\", message: `${this.resourceType} path is not a markdown file`, path: resolvedPath },\n\t\t\t\t\t],\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst result = this.loadResourceFromFile(resolvedPath, source);\n\t\t\treturn { resources: result.resource ? [result.resource] : [], diagnostics: result.diagnostics };\n\t\t} catch (error) {\n\t\t\treturn {\n\t\t\t\tresources: [],\n\t\t\t\tdiagnostics: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"warning\",\n\t\t\t\t\t\tmessage: error instanceof Error ? error.message : `failed to read ${this.resourceType} path`,\n\t\t\t\t\t\tpath: resolvedPath,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t};\n\t\t}\n\t}\n\n\tprotected loadResources(options: InstructionResourceLoaderOptions): InstructionResourceLoadResult<TResource> {\n\t\tconst resolvedCwd = resolvePath(options.cwd);\n\t\tconst resolvedAgentDir = resolvePath(options.agentDir ?? getAgentDir());\n\t\tconst resourceMap = new Map<string, TResource>();\n\t\tconst realPathSet = new Set<string>();\n\t\tconst allDiagnostics: ResourceDiagnostic[] = [];\n\t\tconst collisionDiagnostics: ResourceDiagnostic[] = [];\n\n\t\tconst addResources = (result: InstructionResourceLoadResult<TResource>): void => {\n\t\t\tallDiagnostics.push(...result.diagnostics);\n\t\t\tfor (const resource of result.resources) {\n\t\t\t\tconst realPath = canonicalizePath(resource.filePath);\n\t\t\t\tif (realPathSet.has(realPath)) continue;\n\t\t\t\tconst existing = resourceMap.get(resource.name);\n\t\t\t\tif (existing) {\n\t\t\t\t\tcollisionDiagnostics.push(this.createCollisionDiagnostic(resource, existing));\n\t\t\t\t} else {\n\t\t\t\t\tresourceMap.set(resource.name, resource);\n\t\t\t\t\trealPathSet.add(realPath);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tif (options.includeDefaults) {\n\t\t\taddResources(\n\t\t\t\tthis.loadResourcesFromDirInternal(join(resolvedAgentDir, this.defaultDirectoryName), \"user\", true),\n\t\t\t);\n\t\t\taddResources(\n\t\t\t\tthis.loadResourcesFromDirInternal(\n\t\t\t\t\tresolve(resolvedCwd, CONFIG_DIR_NAME, this.defaultDirectoryName),\n\t\t\t\t\t\"project\",\n\t\t\t\t\ttrue,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\tconst userDir = join(resolvedAgentDir, this.defaultDirectoryName);\n\t\tconst projectDir = resolve(resolvedCwd, CONFIG_DIR_NAME, this.defaultDirectoryName);\n\t\tconst getSource = (resolvedPath: string): ConfiguredResourceSource => {\n\t\t\tif (!options.includeDefaults) {\n\t\t\t\tif (isUnderPath(resolvedPath, userDir)) return \"user\";\n\t\t\t\tif (isUnderPath(resolvedPath, projectDir)) return \"project\";\n\t\t\t}\n\t\t\treturn \"path\";\n\t\t};\n\n\t\tfor (const rawPath of options.resourcePaths) {\n\t\t\tconst resolvedPath = resolvePath(rawPath, resolvedCwd, { trim: true });\n\t\t\taddResources(this.loadResourcesFromConfiguredPath(resolvedPath, getSource(resolvedPath)));\n\t\t}\n\n\t\treturn {\n\t\t\tresources: Array.from(resourceMap.values()),\n\t\t\tdiagnostics: [...allDiagnostics, ...collisionDiagnostics],\n\t\t};\n\t}\n\n\tprivate async loadResourcesFromConfiguredPathWithOperations(\n\t\toperations: ToolOperations,\n\t\tresolvedPath: string,\n\t\tsource: ConfiguredResourceSource,\n\t): Promise<InstructionResourceLoadResult<TResource>> {\n\t\tif (!(await backendPathExists(operations, resolvedPath))) {\n\t\t\treturn {\n\t\t\t\tresources: [],\n\t\t\t\tdiagnostics: [{ type: \"warning\", message: `${this.resourceType} path does not exist`, path: resolvedPath }],\n\t\t\t};\n\t\t}\n\t\ttry {\n\t\t\tconst stats = await operations.stat(resolvedPath);\n\t\t\tif (stats.isDirectory()) {\n\t\t\t\treturn this.loadResourcesFromDirInternalWithOperations(operations, resolvedPath, source, true);\n\t\t\t}\n\t\t\tif (!stats.isFile() || !resolvedPath.endsWith(\".md\")) {\n\t\t\t\treturn {\n\t\t\t\t\tresources: [],\n\t\t\t\t\tdiagnostics: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"warning\",\n\t\t\t\t\t\t\tmessage: `${this.resourceType} path is not a markdown file`,\n\t\t\t\t\t\t\tpath: resolvedPath,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst result = await this.loadResourceFromFileWithOperations(operations, resolvedPath, source);\n\t\t\treturn { resources: result.resource ? [result.resource] : [], diagnostics: result.diagnostics };\n\t\t} catch (error) {\n\t\t\treturn {\n\t\t\t\tresources: [],\n\t\t\t\tdiagnostics: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"warning\",\n\t\t\t\t\t\tmessage: error instanceof Error ? error.message : `failed to read ${this.resourceType} path`,\n\t\t\t\t\t\tpath: resolvedPath,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t};\n\t\t}\n\t}\n\n\tprotected async loadResourcesWithOperations(\n\t\toptions: InstructionResourceLoaderWithOperationsOptions,\n\t): Promise<InstructionResourceLoadResult<TResource>> {\n\t\tconst backend = options.operations.getBackendInfo?.();\n\t\tconst pathFlavor = backend?.type === \"remote\" && backend.configured ? backend.workspace.pathFlavor : undefined;\n\t\tconst resolvedCwd = resolvePortablePath(options.operations.cwd, options.cwd);\n\t\tconst resolvedAgentDir = normalizePortablePath(options.agentDir ?? getAgentDir(), pathFlavor);\n\t\tconst resourceMap = new Map<string, TResource>();\n\t\tconst pathSet = new Set<string>();\n\t\tconst allDiagnostics: ResourceDiagnostic[] = [];\n\t\tconst collisionDiagnostics: ResourceDiagnostic[] = [];\n\n\t\tconst addResources = (result: InstructionResourceLoadResult<TResource>): void => {\n\t\t\tallDiagnostics.push(...result.diagnostics);\n\t\t\tfor (const resource of result.resources) {\n\t\t\t\tconst canonicalPath = pathComparisonValue(resource.filePath, pathFlavor);\n\t\t\t\tif (pathSet.has(canonicalPath)) continue;\n\t\t\t\tconst existing = resourceMap.get(resource.name);\n\t\t\t\tif (existing) {\n\t\t\t\t\tcollisionDiagnostics.push(this.createCollisionDiagnostic(resource, existing));\n\t\t\t\t} else {\n\t\t\t\t\tresourceMap.set(resource.name, resource);\n\t\t\t\t\tpathSet.add(canonicalPath);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tif (options.includeDefaults) {\n\t\t\taddResources(\n\t\t\t\tawait this.loadResourcesFromDirInternalWithOperations(\n\t\t\t\t\toptions.operations,\n\t\t\t\t\tjoinPortablePath(resolvedAgentDir, this.defaultDirectoryName),\n\t\t\t\t\t\"user\",\n\t\t\t\t\ttrue,\n\t\t\t\t),\n\t\t\t);\n\t\t\taddResources(\n\t\t\t\tawait this.loadResourcesFromDirInternalWithOperations(\n\t\t\t\t\toptions.operations,\n\t\t\t\t\tjoinPortablePath(resolvedCwd, CONFIG_DIR_NAME, this.defaultDirectoryName),\n\t\t\t\t\t\"project\",\n\t\t\t\t\ttrue,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\tconst userDir = joinPortablePath(resolvedAgentDir, this.defaultDirectoryName);\n\t\tconst projectDir = joinPortablePath(resolvedCwd, CONFIG_DIR_NAME, this.defaultDirectoryName);\n\t\tconst getSource = (resolvedPath: string): ConfiguredResourceSource => {\n\t\t\tif (!options.includeDefaults) {\n\t\t\t\tif (relativeWithin(userDir, resolvedPath) !== undefined) return \"user\";\n\t\t\t\tif (relativeWithin(projectDir, resolvedPath) !== undefined) return \"project\";\n\t\t\t}\n\t\t\treturn \"path\";\n\t\t};\n\n\t\tfor (const rawPath of options.resourcePaths) {\n\t\t\tconst resolvedPath = resolvePortablePath(resolvedCwd, rawPath.trim());\n\t\t\taddResources(\n\t\t\t\tawait this.loadResourcesFromConfiguredPathWithOperations(\n\t\t\t\t\toptions.operations,\n\t\t\t\t\tresolvedPath,\n\t\t\t\t\tgetSource(resolvedPath),\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\treturn {\n\t\t\tresources: Array.from(resourceMap.values()),\n\t\t\tdiagnostics: [...allDiagnostics, ...collisionDiagnostics],\n\t\t};\n\t}\n\n\tprivate createCollisionDiagnostic(resource: TResource, existing: TResource): ResourceDiagnostic {\n\t\treturn {\n\t\t\ttype: \"collision\",\n\t\t\tmessage: `name \"${resource.name}\" collision`,\n\t\t\tpath: resource.filePath,\n\t\t\tcollision: {\n\t\t\t\tresourceType: this.resourceType,\n\t\t\t\tname: resource.name,\n\t\t\t\twinnerPath: existing.filePath,\n\t\t\t\tloserPath: resource.filePath,\n\t\t\t},\n\t\t};\n\t}\n\n\tprivate addIgnoreRules(ig: ignore.Ignore, dir: string, rootDir: string): void {\n\t\tconst relativeDir = relative(rootDir, dir);\n\t\tconst prefix = relativeDir ? `${toPosixPath(relativeDir)}/` : \"\";\n\t\tfor (const filename of IGNORE_FILE_NAMES) {\n\t\t\tconst ignorePath = join(dir, filename);\n\t\t\tif (!existsSync(ignorePath)) continue;\n\t\t\ttry {\n\t\t\t\tconst patterns = readFileSync(ignorePath, \"utf-8\")\n\t\t\t\t\t.split(/\\r?\\n/)\n\t\t\t\t\t.map((line) => prefixIgnorePattern(line, prefix))\n\t\t\t\t\t.filter((line): line is string => Boolean(line));\n\t\t\t\tif (patterns.length > 0) ig.add(patterns);\n\t\t\t} catch {}\n\t\t}\n\t}\n\n\tprivate async addIgnoreRulesWithOperations(\n\t\toperations: ToolOperations,\n\t\tig: ignore.Ignore,\n\t\tdir: string,\n\t\trootDir: string,\n\t): Promise<void> {\n\t\tconst relativeDir = relativePortablePath(rootDir, dir);\n\t\tconst prefix = relativeDir && relativeDir !== \".\" ? `${relativeDir.replace(/\\\\/g, \"/\")}/` : \"\";\n\t\tfor (const filename of IGNORE_FILE_NAMES) {\n\t\t\tconst ignorePath = joinPortablePath(dir, filename);\n\t\t\tif (!(await backendPathExists(operations, ignorePath))) continue;\n\t\t\ttry {\n\t\t\t\tconst patterns = (await operations.readFile(ignorePath))\n\t\t\t\t\t.toString(\"utf-8\")\n\t\t\t\t\t.split(/\\r?\\n/)\n\t\t\t\t\t.map((line) => prefixIgnorePattern(line, prefix))\n\t\t\t\t\t.filter((line): line is string => Boolean(line));\n\t\t\t\tif (patterns.length > 0) ig.add(patterns);\n\t\t\t} catch {}\n\t\t}\n\t}\n\n\tprivate getLocalResourceEntry(entry: Dirent, fullPath: string): Dirent | Stats | undefined {\n\t\tif (!entry.isSymbolicLink()) return entry;\n\t\ttry {\n\t\t\treturn statSync(fullPath);\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tprivate loadRootResourceFromEntries(\n\t\tentries: Dirent[],\n\t\tdir: string,\n\t\tsource: string,\n\t\tignoreMatcher: ignore.Ignore,\n\t\trootDir: string,\n\t): InstructionResourceLoadResult<TResource> | undefined {\n\t\tfor (const entry of entries) {\n\t\t\tif (entry.name !== this.rootFileName) continue;\n\t\t\tconst fullPath = join(dir, entry.name);\n\t\t\tconst resourceEntry = this.getLocalResourceEntry(entry, fullPath);\n\t\t\tif (!resourceEntry?.isFile() || ignoreMatcher.ignores(toPosixPath(relative(rootDir, fullPath)))) continue;\n\t\t\tconst result = this.loadResourceFromFile(fullPath, source);\n\t\t\treturn { resources: result.resource ? [result.resource] : [], diagnostics: result.diagnostics };\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tprivate loadNestedResourceEntry(entry: Dirent, context: LocalResourceTraversal<TResource>): void {\n\t\tif (entry.name.startsWith(\".\") || entry.name === \"node_modules\") return;\n\t\tconst fullPath = join(context.dir, entry.name);\n\t\tconst resourceEntry = this.getLocalResourceEntry(entry, fullPath);\n\t\tif (!resourceEntry) return;\n\t\tconst relativePath = toPosixPath(relative(context.rootDir, fullPath));\n\t\tif (context.ignoreMatcher.ignores(resourceEntry.isDirectory() ? `${relativePath}/` : relativePath)) return;\n\t\tif (resourceEntry.isDirectory()) {\n\t\t\tconst nested = this.loadResourcesFromDirInternal(\n\t\t\t\tfullPath,\n\t\t\t\tcontext.source,\n\t\t\t\tfalse,\n\t\t\t\tcontext.ignoreMatcher,\n\t\t\t\tcontext.rootDir,\n\t\t\t);\n\t\t\tcontext.resources.push(...nested.resources);\n\t\t\tcontext.diagnostics.push(...nested.diagnostics);\n\t\t\treturn;\n\t\t}\n\t\tif (!resourceEntry.isFile() || !context.includeRootFiles || !entry.name.endsWith(\".md\")) return;\n\t\tconst result = this.loadResourceFromFile(fullPath, context.source);\n\t\tif (result.resource) context.resources.push(result.resource);\n\t\tcontext.diagnostics.push(...result.diagnostics);\n\t}\n\n\tprivate loadNestedResourcesFromEntries(context: LocalResourceTraversal<TResource>): void {\n\t\tfor (const entry of context.entries) this.loadNestedResourceEntry(entry, context);\n\t}\n\n\tprivate loadResourcesFromDirInternal(\n\t\tdir: string,\n\t\tsource: string,\n\t\tincludeRootFiles: boolean,\n\t\tignoreMatcher?: ignore.Ignore,\n\t\trootDir?: string,\n\t): InstructionResourceLoadResult<TResource> {\n\t\tconst resources: TResource[] = [];\n\t\tconst diagnostics: ResourceDiagnostic[] = [];\n\t\tif (!existsSync(dir)) return { resources, diagnostics };\n\n\t\tconst root = rootDir ?? dir;\n\t\tconst ig = ignoreMatcher ?? ignore();\n\t\tthis.addIgnoreRules(ig, dir, root);\n\t\ttry {\n\t\t\tconst entries = readdirSync(dir, { withFileTypes: true });\n\t\t\tconst rootResource = this.loadRootResourceFromEntries(entries, dir, source, ig, root);\n\t\t\tif (rootResource) return rootResource;\n\t\t\tthis.loadNestedResourcesFromEntries({\n\t\t\t\tentries,\n\t\t\t\tdir,\n\t\t\t\tsource,\n\t\t\t\tincludeRootFiles,\n\t\t\t\tignoreMatcher: ig,\n\t\t\t\trootDir: root,\n\t\t\t\tresources,\n\t\t\t\tdiagnostics,\n\t\t\t});\n\t\t} catch {}\n\t\treturn { resources, diagnostics };\n\t}\n\n\tprivate async getBackendResourceEntry(\n\t\toperations: ToolOperations,\n\t\tfullPath: string,\n\t): Promise<ToolFileStat | undefined> {\n\t\ttry {\n\t\t\treturn await operations.stat(fullPath);\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tprivate async loadRootResourceWithOperations(\n\t\tcontext: BackendResourceTraversal<TResource>,\n\t): Promise<InstructionResourceLoadResult<TResource> | undefined> {\n\t\tfor (const name of context.entries) {\n\t\t\tif (name !== this.rootFileName) continue;\n\t\t\tconst fullPath = joinPortablePath(context.dir, name);\n\t\t\tconst resourceEntry = await this.getBackendResourceEntry(context.operations, fullPath);\n\t\t\tif (\n\t\t\t\t!resourceEntry?.isFile() ||\n\t\t\t\tcontext.ignoreMatcher.ignores(relativePortablePath(context.rootDir, fullPath).replace(/\\\\/g, \"/\"))\n\t\t\t)\n\t\t\t\tcontinue;\n\t\t\tconst result = await this.loadResourceFromFileWithOperations(context.operations, fullPath, context.source);\n\t\t\treturn { resources: result.resource ? [result.resource] : [], diagnostics: result.diagnostics };\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tprivate async loadNestedResourceWithOperations(\n\t\tname: string,\n\t\tcontext: BackendResourceTraversal<TResource>,\n\t): Promise<void> {\n\t\tif (name.startsWith(\".\") || name === \"node_modules\") return;\n\t\tconst fullPath = joinPortablePath(context.dir, name);\n\t\tconst resourceEntry = await this.getBackendResourceEntry(context.operations, fullPath);\n\t\tif (!resourceEntry) return;\n\t\tconst relativePath = relativePortablePath(context.rootDir, fullPath).replace(/\\\\/g, \"/\");\n\t\tif (context.ignoreMatcher.ignores(resourceEntry.isDirectory() ? `${relativePath}/` : relativePath)) return;\n\t\tif (resourceEntry.isDirectory()) {\n\t\t\tconst nested = await this.loadResourcesFromDirInternalWithOperations(\n\t\t\t\tcontext.operations,\n\t\t\t\tfullPath,\n\t\t\t\tcontext.source,\n\t\t\t\tfalse,\n\t\t\t\tcontext.ignoreMatcher,\n\t\t\t\tcontext.rootDir,\n\t\t\t);\n\t\t\tcontext.resources.push(...nested.resources);\n\t\t\tcontext.diagnostics.push(...nested.diagnostics);\n\t\t\treturn;\n\t\t}\n\t\tif (!resourceEntry.isFile() || !context.includeRootFiles || !name.endsWith(\".md\")) return;\n\t\tconst result = await this.loadResourceFromFileWithOperations(context.operations, fullPath, context.source);\n\t\tif (result.resource) context.resources.push(result.resource);\n\t\tcontext.diagnostics.push(...result.diagnostics);\n\t}\n\n\tprivate async loadNestedResourcesWithOperations(context: BackendResourceTraversal<TResource>): Promise<void> {\n\t\tfor (const name of context.entries) await this.loadNestedResourceWithOperations(name, context);\n\t}\n\n\tprivate async loadResourcesFromDirInternalWithOperations(\n\t\toperations: ToolOperations,\n\t\tdir: string,\n\t\tsource: string,\n\t\tincludeRootFiles: boolean,\n\t\tignoreMatcher?: ignore.Ignore,\n\t\trootDir?: string,\n\t): Promise<InstructionResourceLoadResult<TResource>> {\n\t\tconst resources: TResource[] = [];\n\t\tconst diagnostics: ResourceDiagnostic[] = [];\n\t\tif (!(await backendPathExists(operations, dir))) return { resources, diagnostics };\n\n\t\tconst root = rootDir ?? dir;\n\t\tconst ig = ignoreMatcher ?? ignore();\n\t\tawait this.addIgnoreRulesWithOperations(operations, ig, dir, root);\n\t\ttry {\n\t\t\tconst context: BackendResourceTraversal<TResource> = {\n\t\t\t\tentries: await operations.readdir(dir),\n\t\t\t\toperations,\n\t\t\t\tdir,\n\t\t\t\tsource,\n\t\t\t\tincludeRootFiles,\n\t\t\t\tignoreMatcher: ig,\n\t\t\t\trootDir: root,\n\t\t\t\tresources,\n\t\t\t\tdiagnostics,\n\t\t\t};\n\t\t\tconst rootResource = await this.loadRootResourceWithOperations(context);\n\t\t\tif (rootResource) return rootResource;\n\t\t\tawait this.loadNestedResourcesWithOperations(context);\n\t\t} catch {}\n\t\treturn { resources, diagnostics };\n\t}\n\n\tprivate loadResourceFromFile(filePath: string, source: string): InstructionResourceParseResult<TResource> {\n\t\ttry {\n\t\t\treturn this.parseResource(readFileSync(filePath, \"utf-8\"), filePath, source);\n\t\t} catch (error) {\n\t\t\treturn this.createParseError(error, filePath);\n\t\t}\n\t}\n\n\tprivate async loadResourceFromFileWithOperations(\n\t\toperations: ToolOperations,\n\t\tfilePath: string,\n\t\tsource: string,\n\t): Promise<InstructionResourceParseResult<TResource>> {\n\t\ttry {\n\t\t\tconst backend = operations.getBackendInfo?.();\n\t\t\tconst pathFlavor = backend?.type === \"remote\" && backend.configured ? backend.workspace.pathFlavor : undefined;\n\t\t\treturn this.parseResource(\n\t\t\t\t(await operations.readFile(filePath)).toString(\"utf-8\"),\n\t\t\t\tfilePath,\n\t\t\t\tsource,\n\t\t\t\tpathFlavor,\n\t\t\t);\n\t\t} catch (error) {\n\t\t\treturn this.createParseError(error, filePath);\n\t\t}\n\t}\n\n\tprivate parseResource(\n\t\trawContent: string,\n\t\tfilePath: string,\n\t\tsource: string,\n\t\tpathFlavor?: PortablePathFlavor,\n\t): InstructionResourceParseResult<TResource> {\n\t\tconst diagnostics: ResourceDiagnostic[] = [];\n\t\tconst { frontmatter } = parseFrontmatter<TFrontmatter>(rawContent);\n\t\tfor (const error of validateDescription(frontmatter.description)) {\n\t\t\tdiagnostics.push({ type: \"warning\", message: error, path: filePath });\n\t\t}\n\t\tif (!frontmatter.name || frontmatter.name.trim() === \"\") {\n\t\t\tdiagnostics.push({ type: \"warning\", message: \"name is required\", path: filePath });\n\t\t}\n\t\tconst name = frontmatter.name;\n\t\tif (name) {\n\t\t\tfor (const error of validateName(name)) {\n\t\t\t\tdiagnostics.push({ type: \"warning\", message: error, path: filePath });\n\t\t\t}\n\t\t}\n\t\tif (!name || !frontmatter.description || frontmatter.description.trim() === \"\") {\n\t\t\treturn { resource: null, diagnostics };\n\t\t}\n\t\tconst baseDir = pathFlavor ? dirnamePortablePath(filePath, pathFlavor) : dirname(filePath);\n\t\tconst resource: InstructionResource = {\n\t\t\tname,\n\t\t\tdescription: frontmatter.description,\n\t\t\tfilePath,\n\t\t\tbaseDir,\n\t\t\tsourceInfo: createResourceSourceInfo(filePath, baseDir, source),\n\t\t\tdisableModelInvocation: frontmatter[\"disable-model-invocation\"] === true,\n\t\t\ttools: normalizeFrontmatterTools(frontmatter.tools),\n\t\t};\n\t\treturn { resource: this.createResource(resource, frontmatter), diagnostics };\n\t}\n\n\tprivate createParseError(error: unknown, filePath: string): InstructionResourceParseResult<TResource> {\n\t\treturn {\n\t\t\tresource: null,\n\t\t\tdiagnostics: [\n\t\t\t\t{\n\t\t\t\t\ttype: \"warning\",\n\t\t\t\t\tmessage: error instanceof Error ? error.message : `failed to parse ${this.resourceType} file`,\n\t\t\t\t\tpath: filePath,\n\t\t\t\t},\n\t\t\t],\n\t\t};\n\t}\n}\n\nexport function formatInstructionResourcesForPrompt(\n\tresources: InstructionResource[],\n\toptions: InstructionResourcePromptFormatOptions,\n): string {\n\tconst visibleResources = resources.filter((resource) => !resource.disableModelInvocation);\n\tif (visibleResources.length === 0) return \"\";\n\n\tconst [firstIntroLine = \"\", ...remainingIntroLines] = options.intro;\n\tconst lines = [`\\n\\n${firstIntroLine}`, ...remainingIntroLines, \"\", `<${options.containerTag}>`];\n\tfor (const resource of visibleResources) {\n\t\tlines.push(` <${options.itemTag}>`);\n\t\tlines.push(` <name>${escapeXml(resource.name)}</name>`);\n\t\tlines.push(` <description>${escapeXml(resource.description)}</description>`);\n\t\tif (options.includeLocation !== false) lines.push(` <location>${escapeXml(resource.filePath)}</location>`);\n\t\tlines.push(` </${options.itemTag}>`);\n\t}\n\tlines.push(`</${options.containerTag}>`);\n\treturn lines.join(\"\\n\");\n}\n\nfunction escapeXml(value: string): string {\n\treturn value\n\t\t.replace(/&/g, \"&amp;\")\n\t\t.replace(/</g, \"&lt;\")\n\t\t.replace(/>/g, \"&gt;\")\n\t\t.replace(/\"/g, \"&quot;\")\n\t\t.replace(/'/g, \"&apos;\");\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"keybindings.d.ts","sourceRoot":"","sources":["../../src/core/keybindings.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,UAAU,EAEf,KAAK,iBAAiB,EACtB,KAAK,KAAK,EAEV,kBAAkB,IAAI,qBAAqB,EAC3C,MAAM,qBAAqB,CAAC;AAK7B,MAAM,WAAW,cAAc;IAC9B,eAAe,EAAE,IAAI,CAAC;IACtB,WAAW,EAAE,IAAI,CAAC;IAClB,UAAU,EAAE,IAAI,CAAC;IACjB,aAAa,EAAE,IAAI,CAAC;IACpB,oBAAoB,EAAE,IAAI,CAAC;IAC3B,wBAAwB,EAAE,IAAI,CAAC;IAC/B,yBAAyB,EAAE,IAAI,CAAC;IAChC,kBAAkB,EAAE,IAAI,CAAC;IACzB,kBAAkB,EAAE,IAAI,CAAC;IACzB,qBAAqB,EAAE,IAAI,CAAC;IAC5B,+BAA+B,EAAE,IAAI,CAAC;IACtC,qBAAqB,EAAE,IAAI,CAAC;IAC5B,kBAAkB,EAAE,IAAI,CAAC;IACzB,s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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+IkB,CAAC;AAgE3C,UAAU,0BAA0B;IACnC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,QAAQ,EAAE,OAAO,CAAC;CAClB;AAyBD,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,0BAA0B,CAiBvG;AA8BD,qBAAa,kBAAmB,SAAQ,qBAAqB;IAC5D,OAAO,CAAC,UAAU,CAAqB;IAEvC,YAAY,YAAY,GAAE,iBAAsB,EAAE,UAAU,CAAC,EAAE,MAAM,EAGpE;IAED,MAAM,CAAC,MAAM,CAAC,QAAQ,GAAE,MAAsB,GAAG,kBAAkB,CAIlE;IAED,MAAM,IAAI,IAAI,CAGb;IAED,kBAAkB,IAAI,iBAAiB,CAEtC;IAED,OAAO,CAAC,MAAM,CAAC,YAAY;CAK3B;AAED,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAAC","sourcesContent":["import {\n\ttype Keybinding,\n\ttype KeybindingDefinitions,\n\ttype KeybindingsConfig,\n\ttype KeyId,\n\tTUI_KEYBINDINGS,\n\tKeybindingsManager as TuiKeybindingsManager,\n} from \"@greppleai/grip-tui\";\nimport { existsSync, readFileSync } from \"fs\";\nimport { join } from \"path\";\nimport { getAgentDir } from \"../config.ts\";\n\nexport interface AppKeybindings {\n\t\"app.interrupt\": true;\n\t\"app.clear\": true;\n\t\"app.exit\": true;\n\t\"app.suspend\": true;\n\t\"app.thinking.cycle\": true;\n\t\"app.model.cycleForward\": true;\n\t\"app.model.cycleBackward\": true;\n\t\"app.model.select\": true;\n\t\"app.tools.expand\": true;\n\t\"app.thinking.toggle\": true;\n\t\"app.session.toggleNamedFilter\": true;\n\t\"app.editor.external\": true;\n\t\"app.message.copy\": true;\n\t\"app.message.followUp\": true;\n\t\"app.message.dequeue\": true;\n\t\"app.clipboard.pasteImage\": true;\n\t\"app.session.new\": true;\n\t\"app.session.tree\": true;\n\t\"app.session.fork\": true;\n\t\"app.session.resume\": true;\n\t\"app.tree.foldOrUp\": true;\n\t\"app.tree.unfoldOrDown\": true;\n\t\"app.tree.editLabel\": true;\n\t\"app.tree.toggleLabelTimestamp\": true;\n\t\"app.session.togglePath\": true;\n\t\"app.session.toggleSort\": true;\n\t\"app.session.rename\": true;\n\t\"app.session.delete\": true;\n\t\"app.session.deleteNoninvasive\": true;\n\t\"app.models.save\": true;\n\t\"app.models.enableAll\": true;\n\t\"app.models.clearAll\": true;\n\t\"app.models.toggleProvider\": true;\n\t\"app.models.reorderUp\": true;\n\t\"app.models.reorderDown\": true;\n\t\"app.tree.filter.default\": true;\n\t\"app.tree.filter.noTools\": true;\n\t\"app.tree.filter.userOnly\": true;\n\t\"app.tree.filter.labeledOnly\": true;\n\t\"app.tree.filter.all\": true;\n\t\"app.tree.filter.cycleForward\": true;\n\t\"app.tree.filter.cycleBackward\": true;\n}\n\nexport type AppKeybinding = keyof AppKeybindings;\n\ndeclare module \"@greppleai/grip-tui\" {\n\tinterface Keybindings extends AppKeybindings {}\n}\n\nexport const KEYBINDINGS = {\n\t...TUI_KEYBINDINGS,\n\t\"app.interrupt\": { defaultKeys: \"escape\", description: \"Cancel or abort\" },\n\t\"app.clear\": { defaultKeys: \"ctrl+c\", description: \"Clear editor\" },\n\t\"app.exit\": { defaultKeys: \"ctrl+d\", description: \"Exit when editor is empty\" },\n\t\"app.suspend\": {\n\t\tdefaultKeys: process.platform === \"win32\" ? [] : \"ctrl+z\",\n\t\tdescription: \"Suspend to background\",\n\t},\n\t\"app.thinking.cycle\": {\n\t\tdefaultKeys: \"shift+tab\",\n\t\tdescription: \"Cycle thinking level\",\n\t},\n\t\"app.model.cycleForward\": {\n\t\tdefaultKeys: \"ctrl+p\",\n\t\tdescription: \"Cycle to next model\",\n\t},\n\t\"app.model.cycleBackward\": {\n\t\tdefaultKeys: \"shift+ctrl+p\",\n\t\tdescription: \"Cycle to previous model\",\n\t},\n\t\"app.model.select\": { defaultKeys: \"ctrl+l\", description: \"Open model selector\" },\n\t\"app.tools.expand\": { defaultKeys: \"ctrl+o\", description: \"Toggle tool output\" },\n\t\"app.thinking.toggle\": {\n\t\tdefaultKeys: \"ctrl+t\",\n\t\tdescription: \"Toggle thinking blocks\",\n\t},\n\t\"app.session.toggleNamedFilter\": {\n\t\tdefaultKeys: \"ctrl+n\",\n\t\tdescription: \"Toggle named session filter\",\n\t},\n\t\"app.editor.external\": {\n\t\tdefaultKeys: \"ctrl+g\",\n\t\tdescription: \"Open external editor\",\n\t},\n\t\"app.message.copy\": {\n\t\tdefaultKeys: \"ctrl+x\",\n\t\tdescription: \"Copy message to clipboard\",\n\t},\n\t\"app.message.followUp\": {\n\t\tdefaultKeys: \"alt+enter\",\n\t\tdescription: \"Queue follow-up message\",\n\t},\n\t\"app.message.dequeue\": {\n\t\tdefaultKeys: \"alt+up\",\n\t\tdescription: \"Restore queued messages\",\n\t},\n\t\"app.clipboard.pasteImage\": {\n\t\tdefaultKeys: process.platform === \"win32\" ? \"alt+v\" : \"ctrl+v\",\n\t\tdescription: \"Paste image from clipboard (text fallback)\",\n\t},\n\t\"app.session.new\": { defaultKeys: [], description: \"Start a new session\" },\n\t\"app.session.tree\": { defaultKeys: [], description: \"Open session tree\" },\n\t\"app.session.fork\": { defaultKeys: [], description: \"Fork current session\" },\n\t\"app.session.resume\": { defaultKeys: [], description: \"Resume a session\" },\n\t\"app.tree.foldOrUp\": {\n\t\tdefaultKeys: [\"ctrl+left\", \"alt+left\"],\n\t\tdescription: \"Fold tree branch or move up\",\n\t},\n\t\"app.tree.unfoldOrDown\": {\n\t\tdefaultKeys: [\"ctrl+right\", \"alt+right\"],\n\t\tdescription: \"Unfold tree branch or move down\",\n\t},\n\t\"app.tree.editLabel\": {\n\t\tdefaultKeys: \"shift+l\",\n\t\tdescription: \"Edit tree label\",\n\t},\n\t\"app.tree.toggleLabelTimestamp\": {\n\t\tdefaultKeys: \"shift+t\",\n\t\tdescription: \"Toggle tree label timestamps\",\n\t},\n\t\"app.session.togglePath\": {\n\t\tdefaultKeys: \"ctrl+p\",\n\t\tdescription: \"Toggle session path display\",\n\t},\n\t\"app.session.toggleSort\": {\n\t\tdefaultKeys: \"ctrl+s\",\n\t\tdescription: \"Toggle session sort mode\",\n\t},\n\t\"app.session.rename\": {\n\t\tdefaultKeys: \"ctrl+r\",\n\t\tdescription: \"Rename session\",\n\t},\n\t\"app.session.delete\": {\n\t\tdefaultKeys: \"ctrl+d\",\n\t\tdescription: \"Delete session\",\n\t},\n\t\"app.session.deleteNoninvasive\": {\n\t\tdefaultKeys: \"ctrl+backspace\",\n\t\tdescription: \"Delete session when query is empty\",\n\t},\n\t\"app.models.save\": {\n\t\tdefaultKeys: \"ctrl+s\",\n\t\tdescription: \"Save model selection\",\n\t},\n\t\"app.models.enableAll\": {\n\t\tdefaultKeys: \"ctrl+a\",\n\t\tdescription: \"Enable all models\",\n\t},\n\t\"app.models.clearAll\": {\n\t\tdefaultKeys: \"ctrl+x\",\n\t\tdescription: \"Clear all models\",\n\t},\n\t\"app.models.toggleProvider\": {\n\t\tdefaultKeys: \"ctrl+p\",\n\t\tdescription: \"Toggle all models for provider\",\n\t},\n\t\"app.models.reorderUp\": {\n\t\tdefaultKeys: \"alt+up\",\n\t\tdescription: \"Move model up in order\",\n\t},\n\t\"app.models.reorderDown\": {\n\t\tdefaultKeys: \"alt+down\",\n\t\tdescription: \"Move model down in order\",\n\t},\n\t\"app.tree.filter.default\": {\n\t\tdefaultKeys: \"ctrl+d\",\n\t\tdescription: \"Tree filter: default view\",\n\t},\n\t\"app.tree.filter.noTools\": {\n\t\tdefaultKeys: \"ctrl+t\",\n\t\tdescription: \"Tree filter: hide tool results\",\n\t},\n\t\"app.tree.filter.userOnly\": {\n\t\tdefaultKeys: \"ctrl+u\",\n\t\tdescription: \"Tree filter: user messages only\",\n\t},\n\t\"app.tree.filter.labeledOnly\": {\n\t\tdefaultKeys: \"ctrl+l\",\n\t\tdescription: \"Tree filter: labeled entries only\",\n\t},\n\t\"app.tree.filter.all\": {\n\t\tdefaultKeys: \"ctrl+a\",\n\t\tdescription: \"Tree filter: show all entries\",\n\t},\n\t\"app.tree.filter.cycleForward\": {\n\t\tdefaultKeys: \"ctrl+o\",\n\t\tdescription: \"Tree filter: cycle forward\",\n\t},\n\t\"app.tree.filter.cycleBackward\": {\n\t\tdefaultKeys: \"shift+ctrl+o\",\n\t\tdescription: \"Tree filter: cycle backward\",\n\t},\n} as const satisfies KeybindingDefinitions;\n\nconst KEYBINDING_NAME_MIGRATIONS = {\n\tcursorUp: \"tui.editor.cursorUp\",\n\tcursorDown: \"tui.editor.cursorDown\",\n\tcursorLeft: \"tui.editor.cursorLeft\",\n\tcursorRight: \"tui.editor.cursorRight\",\n\tcursorWordLeft: \"tui.editor.cursorWordLeft\",\n\tcursorWordRight: \"tui.editor.cursorWordRight\",\n\tcursorLineStart: \"tui.editor.cursorLineStart\",\n\tcursorLineEnd: \"tui.editor.cursorLineEnd\",\n\tjumpForward: \"tui.editor.jumpForward\",\n\tjumpBackward: \"tui.editor.jumpBackward\",\n\tpageUp: \"tui.editor.pageUp\",\n\tpageDown: \"tui.editor.pageDown\",\n\tdeleteCharBackward: \"tui.editor.deleteCharBackward\",\n\tdeleteCharForward: \"tui.editor.deleteCharForward\",\n\tdeleteWordBackward: \"tui.editor.deleteWordBackward\",\n\tdeleteWordForward: \"tui.editor.deleteWordForward\",\n\tdeleteToLineStart: \"tui.editor.deleteToLineStart\",\n\tdeleteToLineEnd: \"tui.editor.deleteToLineEnd\",\n\tyank: \"tui.editor.yank\",\n\tyankPop: \"tui.editor.yankPop\",\n\tundo: \"tui.editor.undo\",\n\tnewLine: \"tui.input.newLine\",\n\tsubmit: \"tui.input.submit\",\n\ttab: \"tui.input.tab\",\n\tcopy: \"tui.input.copy\",\n\tselectUp: \"tui.select.up\",\n\tselectDown: \"tui.select.down\",\n\tselectPageUp: \"tui.select.pageUp\",\n\tselectPageDown: \"tui.select.pageDown\",\n\tselectConfirm: \"tui.select.confirm\",\n\tselectCancel: \"tui.select.cancel\",\n\tinterrupt: \"app.interrupt\",\n\tclear: \"app.clear\",\n\texit: \"app.exit\",\n\tsuspend: \"app.suspend\",\n\tcycleThinkingLevel: \"app.thinking.cycle\",\n\tcycleModelForward: \"app.model.cycleForward\",\n\tcycleModelBackward: \"app.model.cycleBackward\",\n\tselectModel: \"app.model.select\",\n\texpandTools: \"app.tools.expand\",\n\ttoggleThinking: \"app.thinking.toggle\",\n\ttoggleSessionNamedFilter: \"app.session.toggleNamedFilter\",\n\texternalEditor: \"app.editor.external\",\n\tfollowUp: \"app.message.followUp\",\n\tdequeue: \"app.message.dequeue\",\n\tpasteImage: \"app.clipboard.pasteImage\",\n\tnewSession: \"app.session.new\",\n\ttree: \"app.session.tree\",\n\tfork: \"app.session.fork\",\n\tresume: \"app.session.resume\",\n\ttreeFoldOrUp: \"app.tree.foldOrUp\",\n\ttreeUnfoldOrDown: \"app.tree.unfoldOrDown\",\n\ttreeEditLabel: \"app.tree.editLabel\",\n\ttreeToggleLabelTimestamp: \"app.tree.toggleLabelTimestamp\",\n\ttoggleSessionPath: \"app.session.togglePath\",\n\ttoggleSessionSort: \"app.session.toggleSort\",\n\trenameSession: \"app.session.rename\",\n\tdeleteSession: \"app.session.delete\",\n\tdeleteSessionNoninvasive: \"app.session.deleteNoninvasive\",\n} as const satisfies Record<string, Keybinding>;\n\ninterface KeybindingsMigrationResult {\n\tconfig: Record<string, unknown>;\n\tmigrated: boolean;\n}\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction isLegacyKeybindingName(key: string): key is keyof typeof KEYBINDING_NAME_MIGRATIONS {\n\treturn key in KEYBINDING_NAME_MIGRATIONS;\n}\n\nfunction toKeybindingsConfig(value: unknown): KeybindingsConfig {\n\tif (!isRecord(value)) return {};\n\n\tconst config: KeybindingsConfig = {};\n\tfor (const [key, binding] of Object.entries(value)) {\n\t\tif (typeof binding === \"string\") {\n\t\t\tconfig[key] = binding as KeyId;\n\t\t\tcontinue;\n\t\t}\n\t\tif (Array.isArray(binding) && binding.every((entry) => typeof entry === \"string\")) {\n\t\t\tconfig[key] = binding as KeyId[];\n\t\t}\n\t}\n\treturn config;\n}\n\nexport function migrateKeybindingsConfig(rawConfig: Record<string, unknown>): KeybindingsMigrationResult {\n\tconst config: Record<string, unknown> = {};\n\tlet migrated = false;\n\n\tfor (const [key, value] of Object.entries(rawConfig)) {\n\t\tconst nextKey = isLegacyKeybindingName(key) ? KEYBINDING_NAME_MIGRATIONS[key] : key;\n\t\tif (nextKey !== key) {\n\t\t\tmigrated = true;\n\t\t}\n\t\tif (key !== nextKey && Object.hasOwn(rawConfig, nextKey)) {\n\t\t\tmigrated = true;\n\t\t\tcontinue;\n\t\t}\n\t\tconfig[nextKey] = value;\n\t}\n\n\treturn { config: orderKeybindingsConfig(config), migrated };\n}\n\nfunction orderKeybindingsConfig(config: Record<string, unknown>): Record<string, unknown> {\n\tconst ordered: Record<string, unknown> = {};\n\tfor (const keybinding of Object.keys(KEYBINDINGS)) {\n\t\tif (Object.hasOwn(config, keybinding)) {\n\t\t\tordered[keybinding] = config[keybinding];\n\t\t}\n\t}\n\n\tconst extras = Object.keys(config)\n\t\t.filter((key) => !Object.hasOwn(ordered, key))\n\t\t.sort();\n\tfor (const key of extras) {\n\t\tordered[key] = config[key];\n\t}\n\n\treturn ordered;\n}\n\nfunction loadRawConfig(path: string): Record<string, unknown> | undefined {\n\tif (!existsSync(path)) return undefined;\n\ttry {\n\t\tconst parsed = JSON.parse(readFileSync(path, \"utf-8\")) as unknown;\n\t\treturn isRecord(parsed) ? parsed : undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nexport class KeybindingsManager extends TuiKeybindingsManager {\n\tprivate configPath: string | undefined;\n\n\tconstructor(userBindings: KeybindingsConfig = {}, configPath?: string) {\n\t\tsuper(KEYBINDINGS, userBindings);\n\t\tthis.configPath = configPath;\n\t}\n\n\tstatic create(agentDir: string = getAgentDir()): KeybindingsManager {\n\t\tconst configPath = join(agentDir, \"keybindings.json\");\n\t\tconst userBindings = KeybindingsManager.loadFromFile(configPath);\n\t\treturn new KeybindingsManager(userBindings, configPath);\n\t}\n\n\treload(): void {\n\t\tif (!this.configPath) return;\n\t\tthis.setUserBindings(KeybindingsManager.loadFromFile(this.configPath));\n\t}\n\n\tgetEffectiveConfig(): KeybindingsConfig {\n\t\treturn this.getResolvedBindings();\n\t}\n\n\tprivate static loadFromFile(path: string): KeybindingsConfig {\n\t\tconst rawConfig = loadRawConfig(path);\n\t\tif (!rawConfig) return {};\n\t\treturn toKeybindingsConfig(migrateKeybindingsConfig(rawConfig).config);\n\t}\n}\n\nexport type { Keybinding, KeybindingsConfig, KeyId };\n"]}
1
+ {"version":3,"file":"keybindings.d.ts","sourceRoot":"","sources":["../../src/core/keybindings.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,UAAU,EAEf,KAAK,iBAAiB,EACtB,KAAK,KAAK,EAEV,kBAAkB,IAAI,qBAAqB,EAC3C,MAAM,qBAAqB,CAAC;AAK7B,MAAM,WAAW,cAAc;IAC9B,eAAe,EAAE,IAAI,CAAC;IACtB,WAAW,EAAE,IAAI,CAAC;IAClB,UAAU,EAAE,IAAI,CAAC;IACjB,aAAa,EAAE,IAAI,CAAC;IACpB,oBAAoB,EAAE,IAAI,CAAC;IAC3B,wBAAwB,EAAE,IAAI,CAAC;IAC/B,yBAAyB,EAAE,IAAI,CAAC;I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BAG5C,WAAW,EAAE,QAAQ;iBACrB,WAAW,EAAE,4BAA4B;;;iBAGzC,WAAW,EAAE,cAAc;iBAC3B,WAAW,EAAE,6BAA6B;;CAEF,CAAC;AAgE3C,UAAU,0BAA0B;IACnC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,QAAQ,EAAE,OAAO,CAAC;CAClB;AAyBD,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,0BAA0B,CAiBvG;AA8BD,qBAAa,kBAAmB,SAAQ,qBAAqB;IAC5D,OAAO,CAAC,UAAU,CAAqB;IAEvC,YAAY,YAAY,GAAE,iBAAsB,EAAE,UAAU,CAAC,EAAE,MAAM,EAGpE;IAED,MAAM,CAAC,MAAM,CAAC,QAAQ,GAAE,MAAsB,GAAG,kBAAkB,CAIlE;IAED,MAAM,IAAI,IAAI,CAGb;IAED,kBAAkB,IAAI,iBAAiB,CAEtC;IAED,OAAO,CAAC,MAAM,CAAC,YAAY;CAK3B;AAED,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAAC"}
@@ -271,7 +271,6 @@ function loadRawConfig(path) {
271
271
  }
272
272
  }
273
273
  export class KeybindingsManager extends TuiKeybindingsManager {
274
- configPath;
275
274
  constructor(userBindings = {}, configPath) {
276
275
  super(KEYBINDINGS, userBindings);
277
276
  this.configPath = configPath;