@greppleai/grip 0.0.0-stage → 0.1.3

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 (1119) hide show
  1. package/CHANGELOG.md +115 -0
  2. package/README.md +731 -2
  3. package/dist/bun/cli.d.ts +3 -0
  4. package/dist/bun/cli.d.ts.map +1 -0
  5. package/dist/bun/cli.js +13 -0
  6. package/dist/bun/cli.js.map +1 -0
  7. package/dist/bun/embedded-assets.d.ts +3 -0
  8. package/dist/bun/embedded-assets.d.ts.map +1 -0
  9. package/dist/bun/embedded-assets.js +52 -0
  10. package/dist/bun/embedded-assets.js.map +1 -0
  11. package/dist/bun/register-bedrock.d.ts +2 -0
  12. package/dist/bun/register-bedrock.d.ts.map +1 -0
  13. package/dist/bun/register-bedrock.js +4 -0
  14. package/dist/bun/register-bedrock.js.map +1 -0
  15. package/dist/bun/restore-sandbox-env.d.ts +13 -0
  16. package/dist/bun/restore-sandbox-env.d.ts.map +1 -0
  17. package/dist/bun/restore-sandbox-env.js +32 -0
  18. package/dist/bun/restore-sandbox-env.js.map +1 -0
  19. package/dist/cli/args.d.ts +70 -0
  20. package/dist/cli/args.d.ts.map +1 -0
  21. package/dist/cli/args.js +442 -0
  22. package/dist/cli/args.js.map +1 -0
  23. package/dist/cli/config-selector.d.ts +14 -0
  24. package/dist/cli/config-selector.d.ts.map +1 -0
  25. package/dist/cli/config-selector.js +31 -0
  26. package/dist/cli/config-selector.js.map +1 -0
  27. package/dist/cli/file-processor.d.ts +15 -0
  28. package/dist/cli/file-processor.d.ts.map +1 -0
  29. package/dist/cli/file-processor.js +60 -0
  30. package/dist/cli/file-processor.js.map +1 -0
  31. package/dist/cli/initial-message.d.ts +18 -0
  32. package/dist/cli/initial-message.d.ts.map +1 -0
  33. package/dist/cli/initial-message.js +22 -0
  34. package/dist/cli/initial-message.js.map +1 -0
  35. package/dist/cli/list-models.d.ts +9 -0
  36. package/dist/cli/list-models.d.ts.map +1 -0
  37. package/dist/cli/list-models.js +98 -0
  38. package/dist/cli/list-models.js.map +1 -0
  39. package/dist/cli/session-picker.d.ts +9 -0
  40. package/dist/cli/session-picker.d.ts.map +1 -0
  41. package/dist/cli/session-picker.js +35 -0
  42. package/dist/cli/session-picker.js.map +1 -0
  43. package/dist/cli.d.ts +3 -0
  44. package/dist/cli.d.ts.map +1 -0
  45. package/dist/cli.js +14 -0
  46. package/dist/cli.js.map +1 -0
  47. package/dist/config.d.ts +82 -0
  48. package/dist/config.d.ts.map +1 -0
  49. package/dist/config.js +406 -0
  50. package/dist/config.js.map +1 -0
  51. package/dist/core/agent-session.d.ts +970 -0
  52. package/dist/core/agent-session.d.ts.map +1 -0
  53. package/dist/core/agent-session.js +5191 -0
  54. package/dist/core/agent-session.js.map +1 -0
  55. package/dist/core/auth-guidance.d.ts +5 -0
  56. package/dist/core/auth-guidance.d.ts.map +1 -0
  57. package/dist/core/auth-guidance.js +21 -0
  58. package/dist/core/auth-guidance.js.map +1 -0
  59. package/dist/core/auth-storage.d.ts +150 -0
  60. package/dist/core/auth-storage.d.ts.map +1 -0
  61. package/dist/core/auth-storage.js +557 -0
  62. package/dist/core/auth-storage.js.map +1 -0
  63. package/dist/core/bash-executor.d.ts +26 -0
  64. package/dist/core/bash-executor.d.ts.map +1 -0
  65. package/dist/core/bash-executor.js +99 -0
  66. package/dist/core/bash-executor.js.map +1 -0
  67. package/dist/core/compaction/branch-summarization.d.ts +83 -0
  68. package/dist/core/compaction/branch-summarization.d.ts.map +1 -0
  69. package/dist/core/compaction/branch-summarization.js +220 -0
  70. package/dist/core/compaction/branch-summarization.js.map +1 -0
  71. package/dist/core/compaction/compaction.d.ts +65 -0
  72. package/dist/core/compaction/compaction.d.ts.map +1 -0
  73. package/dist/core/compaction/compaction.js +550 -0
  74. package/dist/core/compaction/compaction.js.map +1 -0
  75. package/dist/core/compaction/compression-detection-ledger.d.ts +34 -0
  76. package/dist/core/compaction/compression-detection-ledger.d.ts.map +1 -0
  77. package/dist/core/compaction/compression-detection-ledger.js +52 -0
  78. package/dist/core/compaction/compression-detection-ledger.js.map +1 -0
  79. package/dist/core/compaction/compression-detector.d.ts +71 -0
  80. package/dist/core/compaction/compression-detector.d.ts.map +1 -0
  81. package/dist/core/compaction/compression-detector.js +407 -0
  82. package/dist/core/compaction/compression-detector.js.map +1 -0
  83. package/dist/core/compaction/compression-economics.d.ts +55 -0
  84. package/dist/core/compaction/compression-economics.d.ts.map +1 -0
  85. package/dist/core/compaction/compression-economics.js +151 -0
  86. package/dist/core/compaction/compression-economics.js.map +1 -0
  87. package/dist/core/compaction/utils.d.ts +28 -0
  88. package/dist/core/compaction/utils.d.ts.map +1 -0
  89. package/dist/core/compaction/utils.js +165 -0
  90. package/dist/core/compaction/utils.js.map +1 -0
  91. package/dist/core/defaults.d.ts +3 -0
  92. package/dist/core/defaults.d.ts.map +1 -0
  93. package/dist/core/defaults.js +2 -0
  94. package/dist/core/defaults.js.map +1 -0
  95. package/dist/core/diagnostics.d.ts +18 -0
  96. package/dist/core/diagnostics.d.ts.map +1 -0
  97. package/dist/core/diagnostics.js +2 -0
  98. package/dist/core/diagnostics.js.map +1 -0
  99. package/dist/core/event-bus.d.ts +9 -0
  100. package/dist/core/event-bus.d.ts.map +1 -0
  101. package/dist/core/event-bus.js +25 -0
  102. package/dist/core/event-bus.js.map +1 -0
  103. package/dist/core/exec.d.ts +29 -0
  104. package/dist/core/exec.d.ts.map +1 -0
  105. package/dist/core/exec.js +75 -0
  106. package/dist/core/exec.js.map +1 -0
  107. package/dist/core/export-html/ansi-to-html.d.ts +22 -0
  108. package/dist/core/export-html/ansi-to-html.d.ts.map +1 -0
  109. package/dist/core/export-html/ansi-to-html.js +245 -0
  110. package/dist/core/export-html/ansi-to-html.js.map +1 -0
  111. package/dist/core/export-html/index.d.ts +21 -0
  112. package/dist/core/export-html/index.d.ts.map +1 -0
  113. package/dist/core/export-html/index.js +230 -0
  114. package/dist/core/export-html/index.js.map +1 -0
  115. package/dist/core/export-html/template.css +1066 -0
  116. package/dist/core/export-html/template.html +55 -0
  117. package/dist/core/export-html/template.js +1864 -0
  118. package/dist/core/export-html/tool-renderer.d.ts +32 -0
  119. package/dist/core/export-html/tool-renderer.d.ts.map +1 -0
  120. package/dist/core/export-html/tool-renderer.js +108 -0
  121. package/dist/core/export-html/tool-renderer.js.map +1 -0
  122. package/dist/core/export-html/vendor/highlight.min.js +1213 -0
  123. package/dist/core/export-html/vendor/marked.min.js +78 -0
  124. package/dist/core/extensions/loader.d.ts +24 -0
  125. package/dist/core/extensions/loader.d.ts.map +1 -0
  126. package/dist/core/extensions/loader.js +613 -0
  127. package/dist/core/extensions/loader.js.map +1 -0
  128. package/dist/core/extensions/runner.d.ts +160 -0
  129. package/dist/core/extensions/runner.d.ts.map +1 -0
  130. package/dist/core/extensions/runner.js +962 -0
  131. package/dist/core/extensions/runner.js.map +1 -0
  132. package/dist/core/extensions/types.d.ts +1311 -0
  133. package/dist/core/extensions/types.d.ts.map +1 -0
  134. package/dist/core/extensions/types.js +51 -0
  135. package/dist/core/extensions/types.js.map +1 -0
  136. package/dist/core/extensions/wrapper.d.ts +20 -0
  137. package/dist/core/extensions/wrapper.d.ts.map +1 -0
  138. package/dist/core/extensions/wrapper.js +22 -0
  139. package/dist/core/extensions/wrapper.js.map +1 -0
  140. package/dist/core/footer-data-provider.d.ts +52 -0
  141. package/dist/core/footer-data-provider.d.ts.map +1 -0
  142. package/dist/core/footer-data-provider.js +318 -0
  143. package/dist/core/footer-data-provider.js.map +1 -0
  144. package/dist/core/grip-agent.d.ts +240 -0
  145. package/dist/core/grip-agent.d.ts.map +1 -0
  146. package/dist/core/grip-agent.js +1243 -0
  147. package/dist/core/grip-agent.js.map +1 -0
  148. package/dist/core/grip-manifest.d.ts +9 -0
  149. package/dist/core/grip-manifest.d.ts.map +1 -0
  150. package/dist/core/grip-manifest.js +25 -0
  151. package/dist/core/grip-manifest.js.map +1 -0
  152. package/dist/core/hooks/aggregate.d.ts +5 -0
  153. package/dist/core/hooks/aggregate.d.ts.map +1 -0
  154. package/dist/core/hooks/aggregate.js +226 -0
  155. package/dist/core/hooks/aggregate.js.map +1 -0
  156. package/dist/core/hooks/config.d.ts +14 -0
  157. package/dist/core/hooks/config.d.ts.map +1 -0
  158. package/dist/core/hooks/config.js +372 -0
  159. package/dist/core/hooks/config.js.map +1 -0
  160. package/dist/core/hooks/executor.d.ts +12 -0
  161. package/dist/core/hooks/executor.d.ts.map +1 -0
  162. package/dist/core/hooks/executor.js +708 -0
  163. package/dist/core/hooks/executor.js.map +1 -0
  164. package/dist/core/hooks/index.d.ts +9 -0
  165. package/dist/core/hooks/index.d.ts.map +1 -0
  166. package/dist/core/hooks/index.js +14 -0
  167. package/dist/core/hooks/index.js.map +1 -0
  168. package/dist/core/hooks/matcher.d.ts +10 -0
  169. package/dist/core/hooks/matcher.d.ts.map +1 -0
  170. package/dist/core/hooks/matcher.js +70 -0
  171. package/dist/core/hooks/matcher.js.map +1 -0
  172. package/dist/core/hooks/trust-store.d.ts +38 -0
  173. package/dist/core/hooks/trust-store.d.ts.map +1 -0
  174. package/dist/core/hooks/trust-store.js +167 -0
  175. package/dist/core/hooks/trust-store.js.map +1 -0
  176. package/dist/core/hooks/types.d.ts +234 -0
  177. package/dist/core/hooks/types.d.ts.map +1 -0
  178. package/dist/core/hooks/types.js +52 -0
  179. package/dist/core/hooks/types.js.map +1 -0
  180. package/dist/core/http-dispatcher.d.ts +21 -0
  181. package/dist/core/http-dispatcher.d.ts.map +1 -0
  182. package/dist/core/http-dispatcher.js +82 -0
  183. package/dist/core/http-dispatcher.js.map +1 -0
  184. package/dist/core/instruction-resource-loader.d.ts +81 -0
  185. package/dist/core/instruction-resource-loader.d.ts.map +1 -0
  186. package/dist/core/instruction-resource-loader.js +574 -0
  187. package/dist/core/instruction-resource-loader.js.map +1 -0
  188. package/dist/core/keybindings.d.ts +399 -0
  189. package/dist/core/keybindings.d.ts.map +1 -0
  190. package/dist/core/keybindings.js +299 -0
  191. package/dist/core/keybindings.js.map +1 -0
  192. package/dist/core/lsp/abort.d.ts +3 -0
  193. package/dist/core/lsp/abort.d.ts.map +1 -0
  194. package/dist/core/lsp/abort.js +28 -0
  195. package/dist/core/lsp/abort.js.map +1 -0
  196. package/dist/core/lsp/client.d.ts +108 -0
  197. package/dist/core/lsp/client.d.ts.map +1 -0
  198. package/dist/core/lsp/client.js +586 -0
  199. package/dist/core/lsp/client.js.map +1 -0
  200. package/dist/core/lsp/config-loader.d.ts +44 -0
  201. package/dist/core/lsp/config-loader.d.ts.map +1 -0
  202. package/dist/core/lsp/config-loader.js +223 -0
  203. package/dist/core/lsp/config-loader.js.map +1 -0
  204. package/dist/core/lsp/config.d.ts +134 -0
  205. package/dist/core/lsp/config.d.ts.map +1 -0
  206. package/dist/core/lsp/config.js +682 -0
  207. package/dist/core/lsp/config.js.map +1 -0
  208. package/dist/core/lsp/diagnostics.d.ts +18 -0
  209. package/dist/core/lsp/diagnostics.d.ts.map +1 -0
  210. package/dist/core/lsp/diagnostics.js +311 -0
  211. package/dist/core/lsp/diagnostics.js.map +1 -0
  212. package/dist/core/lsp/file-sync.d.ts +58 -0
  213. package/dist/core/lsp/file-sync.d.ts.map +1 -0
  214. package/dist/core/lsp/file-sync.js +432 -0
  215. package/dist/core/lsp/file-sync.js.map +1 -0
  216. package/dist/core/lsp/integration.d.ts +62 -0
  217. package/dist/core/lsp/integration.d.ts.map +1 -0
  218. package/dist/core/lsp/integration.js +145 -0
  219. package/dist/core/lsp/integration.js.map +1 -0
  220. package/dist/core/lsp/language-map.d.ts +54 -0
  221. package/dist/core/lsp/language-map.d.ts.map +1 -0
  222. package/dist/core/lsp/language-map.js +300 -0
  223. package/dist/core/lsp/language-map.js.map +1 -0
  224. package/dist/core/lsp/manager.d.ts +120 -0
  225. package/dist/core/lsp/manager.d.ts.map +1 -0
  226. package/dist/core/lsp/manager.js +636 -0
  227. package/dist/core/lsp/manager.js.map +1 -0
  228. package/dist/core/lsp/navigation.d.ts +32 -0
  229. package/dist/core/lsp/navigation.d.ts.map +1 -0
  230. package/dist/core/lsp/navigation.js +327 -0
  231. package/dist/core/lsp/navigation.js.map +1 -0
  232. package/dist/core/lsp/portable-path.d.ts +18 -0
  233. package/dist/core/lsp/portable-path.d.ts.map +1 -0
  234. package/dist/core/lsp/portable-path.js +83 -0
  235. package/dist/core/lsp/portable-path.js.map +1 -0
  236. package/dist/core/lsp/refactor.d.ts +32 -0
  237. package/dist/core/lsp/refactor.d.ts.map +1 -0
  238. package/dist/core/lsp/refactor.js +519 -0
  239. package/dist/core/lsp/refactor.js.map +1 -0
  240. package/dist/core/lsp/transport.d.ts +39 -0
  241. package/dist/core/lsp/transport.d.ts.map +1 -0
  242. package/dist/core/lsp/transport.js +261 -0
  243. package/dist/core/lsp/transport.js.map +1 -0
  244. package/dist/core/messages.d.ts +34 -0
  245. package/dist/core/messages.d.ts.map +1 -0
  246. package/dist/core/messages.js +140 -0
  247. package/dist/core/messages.js.map +1 -0
  248. package/dist/core/model-registry.d.ts +148 -0
  249. package/dist/core/model-registry.d.ts.map +1 -0
  250. package/dist/core/model-registry.js +812 -0
  251. package/dist/core/model-registry.js.map +1 -0
  252. package/dist/core/model-resolver.d.ts +115 -0
  253. package/dist/core/model-resolver.d.ts.map +1 -0
  254. package/dist/core/model-resolver.js +498 -0
  255. package/dist/core/model-resolver.js.map +1 -0
  256. package/dist/core/output-guard.d.ts +7 -0
  257. package/dist/core/output-guard.d.ts.map +1 -0
  258. package/dist/core/output-guard.js +89 -0
  259. package/dist/core/output-guard.js.map +1 -0
  260. package/dist/core/package-manager.d.ts +209 -0
  261. package/dist/core/package-manager.d.ts.map +1 -0
  262. package/dist/core/package-manager.js +2341 -0
  263. package/dist/core/package-manager.js.map +1 -0
  264. package/dist/core/prompt-templates.d.ts +57 -0
  265. package/dist/core/prompt-templates.d.ts.map +1 -0
  266. package/dist/core/prompt-templates.js +353 -0
  267. package/dist/core/prompt-templates.js.map +1 -0
  268. package/dist/core/provider-display-names.d.ts +2 -0
  269. package/dist/core/provider-display-names.d.ts.map +1 -0
  270. package/dist/core/provider-display-names.js +33 -0
  271. package/dist/core/provider-display-names.js.map +1 -0
  272. package/dist/core/remote-workspace-protocol/contract.d.ts +465 -0
  273. package/dist/core/remote-workspace-protocol/contract.d.ts.map +1 -0
  274. package/dist/core/remote-workspace-protocol/contract.js +825 -0
  275. package/dist/core/remote-workspace-protocol/contract.js.map +1 -0
  276. package/dist/core/remote-workspace-protocol/guest-shared-client.d.ts +16 -0
  277. package/dist/core/remote-workspace-protocol/guest-shared-client.d.ts.map +1 -0
  278. package/dist/core/remote-workspace-protocol/guest-shared-client.js +54 -0
  279. package/dist/core/remote-workspace-protocol/guest-shared-client.js.map +1 -0
  280. package/dist/core/remote-workspace-protocol/guest-shared-outbound-scheduler.d.ts +23 -0
  281. package/dist/core/remote-workspace-protocol/guest-shared-outbound-scheduler.d.ts.map +1 -0
  282. package/dist/core/remote-workspace-protocol/guest-shared-outbound-scheduler.js +112 -0
  283. package/dist/core/remote-workspace-protocol/guest-shared-outbound-scheduler.js.map +1 -0
  284. package/dist/core/remote-workspace-protocol/guest-shared-uplink.d.ts +30 -0
  285. package/dist/core/remote-workspace-protocol/guest-shared-uplink.d.ts.map +1 -0
  286. package/dist/core/remote-workspace-protocol/guest-shared-uplink.js +243 -0
  287. package/dist/core/remote-workspace-protocol/guest-shared-uplink.js.map +1 -0
  288. package/dist/core/remote-workspace-protocol/lima-owner-directory.d.ts +3 -0
  289. package/dist/core/remote-workspace-protocol/lima-owner-directory.d.ts.map +1 -0
  290. package/dist/core/remote-workspace-protocol/lima-owner-directory.js +31 -0
  291. package/dist/core/remote-workspace-protocol/lima-owner-directory.js.map +1 -0
  292. package/dist/core/remote-workspace-protocol/lima-owner-lock.d.ts +9 -0
  293. package/dist/core/remote-workspace-protocol/lima-owner-lock.d.ts.map +1 -0
  294. package/dist/core/remote-workspace-protocol/lima-owner-lock.js +89 -0
  295. package/dist/core/remote-workspace-protocol/lima-owner-lock.js.map +1 -0
  296. package/dist/core/remote-workspace-protocol/session.d.ts +249 -0
  297. package/dist/core/remote-workspace-protocol/session.d.ts.map +1 -0
  298. package/dist/core/remote-workspace-protocol/session.js +1842 -0
  299. package/dist/core/remote-workspace-protocol/session.js.map +1 -0
  300. package/dist/core/remote-workspace-protocol/shared-transport.d.ts +71 -0
  301. package/dist/core/remote-workspace-protocol/shared-transport.d.ts.map +1 -0
  302. package/dist/core/remote-workspace-protocol/shared-transport.js +68 -0
  303. package/dist/core/remote-workspace-protocol/shared-transport.js.map +1 -0
  304. package/dist/core/resolve-config-value.d.ts +32 -0
  305. package/dist/core/resolve-config-value.d.ts.map +1 -0
  306. package/dist/core/resolve-config-value.js +257 -0
  307. package/dist/core/resolve-config-value.js.map +1 -0
  308. package/dist/core/resource-loader.d.ts +200 -0
  309. package/dist/core/resource-loader.d.ts.map +1 -0
  310. package/dist/core/resource-loader.js +1209 -0
  311. package/dist/core/resource-loader.js.map +1 -0
  312. package/dist/core/rules.d.ts +40 -0
  313. package/dist/core/rules.d.ts.map +1 -0
  314. package/dist/core/rules.js +57 -0
  315. package/dist/core/rules.js.map +1 -0
  316. package/dist/core/sandbox/command.d.ts +25 -0
  317. package/dist/core/sandbox/command.d.ts.map +1 -0
  318. package/dist/core/sandbox/command.js +102 -0
  319. package/dist/core/sandbox/command.js.map +1 -0
  320. package/dist/core/sandbox/config.d.ts +91 -0
  321. package/dist/core/sandbox/config.d.ts.map +1 -0
  322. package/dist/core/sandbox/config.js +88 -0
  323. package/dist/core/sandbox/config.js.map +1 -0
  324. package/dist/core/sandbox/lima-guest-binary.d.ts +11 -0
  325. package/dist/core/sandbox/lima-guest-binary.d.ts.map +1 -0
  326. package/dist/core/sandbox/lima-guest-binary.js +140 -0
  327. package/dist/core/sandbox/lima-guest-binary.js.map +1 -0
  328. package/dist/core/sandbox/lima.d.ts +57 -0
  329. package/dist/core/sandbox/lima.d.ts.map +1 -0
  330. package/dist/core/sandbox/lima.js +716 -0
  331. package/dist/core/sandbox/lima.js.map +1 -0
  332. package/dist/core/sandbox/shared-lima-roots.d.ts +11 -0
  333. package/dist/core/sandbox/shared-lima-roots.d.ts.map +1 -0
  334. package/dist/core/sandbox/shared-lima-roots.js +25 -0
  335. package/dist/core/sandbox/shared-lima-roots.js.map +1 -0
  336. package/dist/core/sandbox/update-shared-guest-binary.d.ts +8 -0
  337. package/dist/core/sandbox/update-shared-guest-binary.d.ts.map +1 -0
  338. package/dist/core/sandbox/update-shared-guest-binary.js +100 -0
  339. package/dist/core/sandbox/update-shared-guest-binary.js.map +1 -0
  340. package/dist/core/session/constants.d.ts +2 -0
  341. package/dist/core/session/constants.d.ts.map +1 -0
  342. package/dist/core/session/constants.js +2 -0
  343. package/dist/core/session/constants.js.map +1 -0
  344. package/dist/core/session/context-metadata.d.ts +5 -0
  345. package/dist/core/session/context-metadata.d.ts.map +1 -0
  346. package/dist/core/session/context-metadata.js +55 -0
  347. package/dist/core/session/context-metadata.js.map +1 -0
  348. package/dist/core/session/context.d.ts +14 -0
  349. package/dist/core/session/context.d.ts.map +1 -0
  350. package/dist/core/session/context.js +117 -0
  351. package/dist/core/session/context.js.map +1 -0
  352. package/dist/core/session/ids.d.ts +9 -0
  353. package/dist/core/session/ids.d.ts.map +1 -0
  354. package/dist/core/session/ids.js +21 -0
  355. package/dist/core/session/ids.js.map +1 -0
  356. package/dist/core/session/in-memory-session-manager.d.ts +17 -0
  357. package/dist/core/session/in-memory-session-manager.d.ts.map +1 -0
  358. package/dist/core/session/in-memory-session-manager.js +40 -0
  359. package/dist/core/session/in-memory-session-manager.js.map +1 -0
  360. package/dist/core/session/in-memory-session.d.ts +7 -0
  361. package/dist/core/session/in-memory-session.d.ts.map +1 -0
  362. package/dist/core/session/in-memory-session.js +11 -0
  363. package/dist/core/session/in-memory-session.js.map +1 -0
  364. package/dist/core/session/jsonl-errors.d.ts +36 -0
  365. package/dist/core/session/jsonl-errors.d.ts.map +1 -0
  366. package/dist/core/session/jsonl-errors.js +49 -0
  367. package/dist/core/session/jsonl-errors.js.map +1 -0
  368. package/dist/core/session/jsonl-helpers.d.ts +20 -0
  369. package/dist/core/session/jsonl-helpers.d.ts.map +1 -0
  370. package/dist/core/session/jsonl-helpers.js +21 -0
  371. package/dist/core/session/jsonl-helpers.js.map +1 -0
  372. package/dist/core/session/local-session-manager.d.ts +30 -0
  373. package/dist/core/session/local-session-manager.d.ts.map +1 -0
  374. package/dist/core/session/local-session-manager.js +205 -0
  375. package/dist/core/session/local-session-manager.js.map +1 -0
  376. package/dist/core/session/local-session.d.ts +9 -0
  377. package/dist/core/session/local-session.d.ts.map +1 -0
  378. package/dist/core/session/local-session.js +15 -0
  379. package/dist/core/session/local-session.js.map +1 -0
  380. package/dist/core/session/migrations.d.ts +11 -0
  381. package/dist/core/session/migrations.d.ts.map +1 -0
  382. package/dist/core/session/migrations.js +78 -0
  383. package/dist/core/session/migrations.js.map +1 -0
  384. package/dist/core/session/remote-session-client.d.ts +83 -0
  385. package/dist/core/session/remote-session-client.d.ts.map +1 -0
  386. package/dist/core/session/remote-session-client.js +224 -0
  387. package/dist/core/session/remote-session-client.js.map +1 -0
  388. package/dist/core/session/remote-session-manager.d.ts +32 -0
  389. package/dist/core/session/remote-session-manager.d.ts.map +1 -0
  390. package/dist/core/session/remote-session-manager.js +124 -0
  391. package/dist/core/session/remote-session-manager.js.map +1 -0
  392. package/dist/core/session/remote-session.d.ts +20 -0
  393. package/dist/core/session/remote-session.d.ts.map +1 -0
  394. package/dist/core/session/remote-session.js +33 -0
  395. package/dist/core/session/remote-session.js.map +1 -0
  396. package/dist/core/session/session-manager.d.ts +18 -0
  397. package/dist/core/session/session-manager.d.ts.map +1 -0
  398. package/dist/core/session/session-manager.js +2 -0
  399. package/dist/core/session/session-manager.js.map +1 -0
  400. package/dist/core/session/session.d.ts +140 -0
  401. package/dist/core/session/session.d.ts.map +1 -0
  402. package/dist/core/session/session.js +461 -0
  403. package/dist/core/session/session.js.map +1 -0
  404. package/dist/core/session/stores/in-memory-session-store.d.ts +39 -0
  405. package/dist/core/session/stores/in-memory-session-store.d.ts.map +1 -0
  406. package/dist/core/session/stores/in-memory-session-store.js +168 -0
  407. package/dist/core/session/stores/in-memory-session-store.js.map +1 -0
  408. package/dist/core/session/stores/jsonl-session-store.d.ts +97 -0
  409. package/dist/core/session/stores/jsonl-session-store.d.ts.map +1 -0
  410. package/dist/core/session/stores/jsonl-session-store.js +1140 -0
  411. package/dist/core/session/stores/jsonl-session-store.js.map +1 -0
  412. package/dist/core/session/stores/remote-session-store.d.ts +44 -0
  413. package/dist/core/session/stores/remote-session-store.d.ts.map +1 -0
  414. package/dist/core/session/stores/remote-session-store.js +159 -0
  415. package/dist/core/session/stores/remote-session-store.js.map +1 -0
  416. package/dist/core/session/stores/session-store.d.ts +42 -0
  417. package/dist/core/session/stores/session-store.d.ts.map +1 -0
  418. package/dist/core/session/stores/session-store.js +2 -0
  419. package/dist/core/session/stores/session-store.js.map +1 -0
  420. package/dist/core/session/types.d.ts +141 -0
  421. package/dist/core/session/types.d.ts.map +1 -0
  422. package/dist/core/session/types.js +2 -0
  423. package/dist/core/session/types.js.map +1 -0
  424. package/dist/core/session/usage-ledger.d.ts +18 -0
  425. package/dist/core/session/usage-ledger.d.ts.map +1 -0
  426. package/dist/core/session/usage-ledger.js +68 -0
  427. package/dist/core/session/usage-ledger.js.map +1 -0
  428. package/dist/core/session-cwd.d.ts +19 -0
  429. package/dist/core/session-cwd.d.ts.map +1 -0
  430. package/dist/core/session-cwd.js +38 -0
  431. package/dist/core/session-cwd.js.map +1 -0
  432. package/dist/core/settings-manager.d.ts +314 -0
  433. package/dist/core/settings-manager.d.ts.map +1 -0
  434. package/dist/core/settings-manager.js +991 -0
  435. package/dist/core/settings-manager.js.map +1 -0
  436. package/dist/core/skills.d.ts +40 -0
  437. package/dist/core/skills.d.ts.map +1 -0
  438. package/dist/core/skills.js +57 -0
  439. package/dist/core/skills.js.map +1 -0
  440. package/dist/core/slash-commands.d.ts +15 -0
  441. package/dist/core/slash-commands.d.ts.map +1 -0
  442. package/dist/core/slash-commands.js +36 -0
  443. package/dist/core/slash-commands.js.map +1 -0
  444. package/dist/core/source-info.d.ts +26 -0
  445. package/dist/core/source-info.d.ts.map +1 -0
  446. package/dist/core/source-info.js +27 -0
  447. package/dist/core/source-info.js.map +1 -0
  448. package/dist/core/system-prompt.d.ts +32 -0
  449. package/dist/core/system-prompt.d.ts.map +1 -0
  450. package/dist/core/system-prompt.js +131 -0
  451. package/dist/core/system-prompt.js.map +1 -0
  452. package/dist/core/telemetry.d.ts +3 -0
  453. package/dist/core/telemetry.d.ts.map +1 -0
  454. package/dist/core/telemetry.js +9 -0
  455. package/dist/core/telemetry.js.map +1 -0
  456. package/dist/core/timings.d.ts +10 -0
  457. package/dist/core/timings.d.ts.map +1 -0
  458. package/dist/core/timings.js +41 -0
  459. package/dist/core/timings.js.map +1 -0
  460. package/dist/core/tools/bash.d.ts +51 -0
  461. package/dist/core/tools/bash.d.ts.map +1 -0
  462. package/dist/core/tools/bash.js +321 -0
  463. package/dist/core/tools/bash.js.map +1 -0
  464. package/dist/core/tools/compress-context.d.ts +27 -0
  465. package/dist/core/tools/compress-context.d.ts.map +1 -0
  466. package/dist/core/tools/compress-context.js +142 -0
  467. package/dist/core/tools/compress-context.js.map +1 -0
  468. package/dist/core/tools/edit-diff.d.ts +82 -0
  469. package/dist/core/tools/edit-diff.d.ts.map +1 -0
  470. package/dist/core/tools/edit-diff.js +327 -0
  471. package/dist/core/tools/edit-diff.js.map +1 -0
  472. package/dist/core/tools/edit.d.ts +50 -0
  473. package/dist/core/tools/edit.d.ts.map +1 -0
  474. package/dist/core/tools/edit.js +324 -0
  475. package/dist/core/tools/edit.js.map +1 -0
  476. package/dist/core/tools/file-mutation-queue.d.ts +8 -0
  477. package/dist/core/tools/file-mutation-queue.d.ts.map +1 -0
  478. package/dist/core/tools/file-mutation-queue.js +69 -0
  479. package/dist/core/tools/file-mutation-queue.js.map +1 -0
  480. package/dist/core/tools/find.d.ts +22 -0
  481. package/dist/core/tools/find.d.ts.map +1 -0
  482. package/dist/core/tools/find.js +268 -0
  483. package/dist/core/tools/find.js.map +1 -0
  484. package/dist/core/tools/grep.d.ts +27 -0
  485. package/dist/core/tools/grep.d.ts.map +1 -0
  486. package/dist/core/tools/grep.js +332 -0
  487. package/dist/core/tools/grep.js.map +1 -0
  488. package/dist/core/tools/hash-store.d.ts +12 -0
  489. package/dist/core/tools/hash-store.d.ts.map +1 -0
  490. package/dist/core/tools/hash-store.js +48 -0
  491. package/dist/core/tools/hash-store.js.map +1 -0
  492. package/dist/core/tools/hashline/apply.d.ts +40 -0
  493. package/dist/core/tools/hashline/apply.d.ts.map +1 -0
  494. package/dist/core/tools/hashline/apply.js +261 -0
  495. package/dist/core/tools/hashline/apply.js.map +1 -0
  496. package/dist/core/tools/hashline/hash.d.ts +56 -0
  497. package/dist/core/tools/hashline/hash.d.ts.map +1 -0
  498. package/dist/core/tools/hashline/hash.js +196 -0
  499. package/dist/core/tools/hashline/hash.js.map +1 -0
  500. package/dist/core/tools/hashline/parse.d.ts +8 -0
  501. package/dist/core/tools/hashline/parse.d.ts.map +1 -0
  502. package/dist/core/tools/hashline/parse.js +41 -0
  503. package/dist/core/tools/hashline/parse.js.map +1 -0
  504. package/dist/core/tools/hashline/resolve.d.ts +51 -0
  505. package/dist/core/tools/hashline/resolve.d.ts.map +1 -0
  506. package/dist/core/tools/hashline/resolve.js +187 -0
  507. package/dist/core/tools/hashline/resolve.js.map +1 -0
  508. package/dist/core/tools/hashline-utils.d.ts +6 -0
  509. package/dist/core/tools/hashline-utils.d.ts.map +1 -0
  510. package/dist/core/tools/hashline-utils.js +23 -0
  511. package/dist/core/tools/hashline-utils.js.map +1 -0
  512. package/dist/core/tools/index.d.ts +36 -0
  513. package/dist/core/tools/index.d.ts.map +1 -0
  514. package/dist/core/tools/index.js +141 -0
  515. package/dist/core/tools/index.js.map +1 -0
  516. package/dist/core/tools/ls.d.ts +21 -0
  517. package/dist/core/tools/ls.d.ts.map +1 -0
  518. package/dist/core/tools/ls.js +156 -0
  519. package/dist/core/tools/ls.js.map +1 -0
  520. package/dist/core/tools/operations.d.ts +212 -0
  521. package/dist/core/tools/operations.d.ts.map +1 -0
  522. package/dist/core/tools/operations.js +793 -0
  523. package/dist/core/tools/operations.js.map +1 -0
  524. package/dist/core/tools/output-accumulator.d.ts +54 -0
  525. package/dist/core/tools/output-accumulator.d.ts.map +1 -0
  526. package/dist/core/tools/output-accumulator.js +184 -0
  527. package/dist/core/tools/output-accumulator.js.map +1 -0
  528. package/dist/core/tools/path-utils.d.ts +9 -0
  529. package/dist/core/tools/path-utils.d.ts.map +1 -0
  530. package/dist/core/tools/path-utils.js +99 -0
  531. package/dist/core/tools/path-utils.js.map +1 -0
  532. package/dist/core/tools/read.d.ts +32 -0
  533. package/dist/core/tools/read.d.ts.map +1 -0
  534. package/dist/core/tools/read.js +318 -0
  535. package/dist/core/tools/read.js.map +1 -0
  536. package/dist/core/tools/render-utils.d.ts +33 -0
  537. package/dist/core/tools/render-utils.d.ts.map +1 -0
  538. package/dist/core/tools/render-utils.js +61 -0
  539. package/dist/core/tools/render-utils.js.map +1 -0
  540. package/dist/core/tools/replace-diff.d.ts +16 -0
  541. package/dist/core/tools/replace-diff.d.ts.map +1 -0
  542. package/dist/core/tools/replace-diff.js +117 -0
  543. package/dist/core/tools/replace-diff.js.map +1 -0
  544. package/dist/core/tools/replace-normalize.d.ts +2 -0
  545. package/dist/core/tools/replace-normalize.d.ts.map +1 -0
  546. package/dist/core/tools/replace-normalize.js +73 -0
  547. package/dist/core/tools/replace-normalize.js.map +1 -0
  548. package/dist/core/tools/replace-render.d.ts +51 -0
  549. package/dist/core/tools/replace-render.d.ts.map +1 -0
  550. package/dist/core/tools/replace-render.js +162 -0
  551. package/dist/core/tools/replace-render.js.map +1 -0
  552. package/dist/core/tools/runtime.d.ts +2 -0
  553. package/dist/core/tools/runtime.d.ts.map +1 -0
  554. package/dist/core/tools/runtime.js +6 -0
  555. package/dist/core/tools/runtime.js.map +1 -0
  556. package/dist/core/tools/session-history.d.ts +55 -0
  557. package/dist/core/tools/session-history.d.ts.map +1 -0
  558. package/dist/core/tools/session-history.js +649 -0
  559. package/dist/core/tools/session-history.js.map +1 -0
  560. package/dist/core/tools/subagent-agents.d.ts +29 -0
  561. package/dist/core/tools/subagent-agents.d.ts.map +1 -0
  562. package/dist/core/tools/subagent-agents.js +223 -0
  563. package/dist/core/tools/subagent-agents.js.map +1 -0
  564. package/dist/core/tools/subagent.d.ts +185 -0
  565. package/dist/core/tools/subagent.d.ts.map +1 -0
  566. package/dist/core/tools/subagent.js +1309 -0
  567. package/dist/core/tools/subagent.js.map +1 -0
  568. package/dist/core/tools/tool-definition-wrapper.d.ts +14 -0
  569. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -0
  570. package/dist/core/tools/tool-definition-wrapper.js +34 -0
  571. package/dist/core/tools/tool-definition-wrapper.js.map +1 -0
  572. package/dist/core/tools/truncate.d.ts +39 -0
  573. package/dist/core/tools/truncate.d.ts.map +1 -0
  574. package/dist/core/tools/truncate.js +215 -0
  575. package/dist/core/tools/truncate.js.map +1 -0
  576. package/dist/core/tools/websearch.d.ts +33 -0
  577. package/dist/core/tools/websearch.d.ts.map +1 -0
  578. package/dist/core/tools/websearch.js +341 -0
  579. package/dist/core/tools/websearch.js.map +1 -0
  580. package/dist/core/tools/workspace-tool-host.d.ts +102 -0
  581. package/dist/core/tools/workspace-tool-host.d.ts.map +1 -0
  582. package/dist/core/tools/workspace-tool-host.js +348 -0
  583. package/dist/core/tools/workspace-tool-host.js.map +1 -0
  584. package/dist/core/tools/write.d.ts +16 -0
  585. package/dist/core/tools/write.d.ts.map +1 -0
  586. package/dist/core/tools/write.js +204 -0
  587. package/dist/core/tools/write.js.map +1 -0
  588. package/dist/core/workspace-identity.d.ts +7 -0
  589. package/dist/core/workspace-identity.d.ts.map +1 -0
  590. package/dist/core/workspace-identity.js +2 -0
  591. package/dist/core/workspace-identity.js.map +1 -0
  592. package/dist/daemon/activity-budget.d.ts +10 -0
  593. package/dist/daemon/activity-budget.d.ts.map +1 -0
  594. package/dist/daemon/activity-budget.js +34 -0
  595. package/dist/daemon/activity-budget.js.map +1 -0
  596. package/dist/daemon/command.d.ts +6 -0
  597. package/dist/daemon/command.d.ts.map +1 -0
  598. package/dist/daemon/command.js +58 -0
  599. package/dist/daemon/command.js.map +1 -0
  600. package/dist/daemon/config.d.ts +45 -0
  601. package/dist/daemon/config.d.ts.map +1 -0
  602. package/dist/daemon/config.js +319 -0
  603. package/dist/daemon/config.js.map +1 -0
  604. package/dist/daemon/help.d.ts +2 -0
  605. package/dist/daemon/help.d.ts.map +1 -0
  606. package/dist/daemon/help.js +42 -0
  607. package/dist/daemon/help.js.map +1 -0
  608. package/dist/daemon/lsp-config.d.ts +4 -0
  609. package/dist/daemon/lsp-config.d.ts.map +1 -0
  610. package/dist/daemon/lsp-config.js +155 -0
  611. package/dist/daemon/lsp-config.js.map +1 -0
  612. package/dist/daemon/outbound-budget.d.ts +10 -0
  613. package/dist/daemon/outbound-budget.d.ts.map +1 -0
  614. package/dist/daemon/outbound-budget.js +30 -0
  615. package/dist/daemon/outbound-budget.js.map +1 -0
  616. package/dist/daemon/security.d.ts +19 -0
  617. package/dist/daemon/security.d.ts.map +1 -0
  618. package/dist/daemon/security.js +177 -0
  619. package/dist/daemon/security.js.map +1 -0
  620. package/dist/daemon/server.d.ts +20 -0
  621. package/dist/daemon/server.d.ts.map +1 -0
  622. package/dist/daemon/server.js +480 -0
  623. package/dist/daemon/server.js.map +1 -0
  624. package/dist/daemon/shared-connection.d.ts +33 -0
  625. package/dist/daemon/shared-connection.d.ts.map +1 -0
  626. package/dist/daemon/shared-connection.js +271 -0
  627. package/dist/daemon/shared-connection.js.map +1 -0
  628. package/dist/daemon/shared-revision.d.ts +5 -0
  629. package/dist/daemon/shared-revision.d.ts.map +1 -0
  630. package/dist/daemon/shared-revision.js +61 -0
  631. package/dist/daemon/shared-revision.js.map +1 -0
  632. package/dist/daemon/shared-roots.d.ts +9 -0
  633. package/dist/daemon/shared-roots.d.ts.map +1 -0
  634. package/dist/daemon/shared-roots.js +33 -0
  635. package/dist/daemon/shared-roots.js.map +1 -0
  636. package/dist/daemon/workspace-runtime.d.ts +46 -0
  637. package/dist/daemon/workspace-runtime.d.ts.map +1 -0
  638. package/dist/daemon/workspace-runtime.js +705 -0
  639. package/dist/daemon/workspace-runtime.js.map +1 -0
  640. package/dist/index.d.ts +109 -0
  641. package/dist/index.d.ts.map +1 -0
  642. package/dist/index.js +107 -0
  643. package/dist/index.js.map +1 -0
  644. package/dist/main.d.ts +39 -0
  645. package/dist/main.d.ts.map +1 -0
  646. package/dist/main.js +765 -0
  647. package/dist/main.js.map +1 -0
  648. package/dist/migrations.d.ts +35 -0
  649. package/dist/migrations.d.ts.map +1 -0
  650. package/dist/migrations.js +412 -0
  651. package/dist/migrations.js.map +1 -0
  652. package/dist/modes/interactive/components/assistant-message.d.ts +30 -0
  653. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -0
  654. package/dist/modes/interactive/components/assistant-message.js +159 -0
  655. package/dist/modes/interactive/components/assistant-message.js.map +1 -0
  656. package/dist/modes/interactive/components/bash-execution.d.ts +36 -0
  657. package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -0
  658. package/dist/modes/interactive/components/bash-execution.js +173 -0
  659. package/dist/modes/interactive/components/bash-execution.js.map +1 -0
  660. package/dist/modes/interactive/components/bordered-loader.d.ts +18 -0
  661. package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -0
  662. package/dist/modes/interactive/components/bordered-loader.js +54 -0
  663. package/dist/modes/interactive/components/bordered-loader.js.map +1 -0
  664. package/dist/modes/interactive/components/branch-summary-message.d.ts +17 -0
  665. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -0
  666. package/dist/modes/interactive/components/branch-summary-message.js +45 -0
  667. package/dist/modes/interactive/components/branch-summary-message.js.map +1 -0
  668. package/dist/modes/interactive/components/compaction-summary-message.d.ts +17 -0
  669. package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -0
  670. package/dist/modes/interactive/components/compaction-summary-message.js +46 -0
  671. package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -0
  672. package/dist/modes/interactive/components/config-selector.d.ts +74 -0
  673. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -0
  674. package/dist/modes/interactive/components/config-selector.js +514 -0
  675. package/dist/modes/interactive/components/config-selector.js.map +1 -0
  676. package/dist/modes/interactive/components/countdown-timer.d.ts +14 -0
  677. package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -0
  678. package/dist/modes/interactive/components/countdown-timer.js +33 -0
  679. package/dist/modes/interactive/components/countdown-timer.js.map +1 -0
  680. package/dist/modes/interactive/components/custom-editor.d.ts +25 -0
  681. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -0
  682. package/dist/modes/interactive/components/custom-editor.js +85 -0
  683. package/dist/modes/interactive/components/custom-editor.js.map +1 -0
  684. package/dist/modes/interactive/components/custom-message.d.ts +20 -0
  685. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -0
  686. package/dist/modes/interactive/components/custom-message.js +81 -0
  687. package/dist/modes/interactive/components/custom-message.js.map +1 -0
  688. package/dist/modes/interactive/components/diff.d.ts +12 -0
  689. package/dist/modes/interactive/components/diff.d.ts.map +1 -0
  690. package/dist/modes/interactive/components/diff.js +118 -0
  691. package/dist/modes/interactive/components/diff.js.map +1 -0
  692. package/dist/modes/interactive/components/dynamic-border.d.ts +15 -0
  693. package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -0
  694. package/dist/modes/interactive/components/dynamic-border.js +21 -0
  695. package/dist/modes/interactive/components/dynamic-border.js.map +1 -0
  696. package/dist/modes/interactive/components/extension-editor.d.ts +22 -0
  697. package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -0
  698. package/dist/modes/interactive/components/extension-editor.js +128 -0
  699. package/dist/modes/interactive/components/extension-editor.js.map +1 -0
  700. package/dist/modes/interactive/components/extension-input.d.ts +23 -0
  701. package/dist/modes/interactive/components/extension-input.d.ts.map +1 -0
  702. package/dist/modes/interactive/components/extension-input.js +61 -0
  703. package/dist/modes/interactive/components/extension-input.js.map +1 -0
  704. package/dist/modes/interactive/components/extension-selector.d.ts +26 -0
  705. package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -0
  706. package/dist/modes/interactive/components/extension-selector.js +83 -0
  707. package/dist/modes/interactive/components/extension-selector.js.map +1 -0
  708. package/dist/modes/interactive/components/footer.d.ts +36 -0
  709. package/dist/modes/interactive/components/footer.d.ts.map +1 -0
  710. package/dist/modes/interactive/components/footer.js +227 -0
  711. package/dist/modes/interactive/components/footer.js.map +1 -0
  712. package/dist/modes/interactive/components/hook-execution.d.ts +19 -0
  713. package/dist/modes/interactive/components/hook-execution.d.ts.map +1 -0
  714. package/dist/modes/interactive/components/hook-execution.js +185 -0
  715. package/dist/modes/interactive/components/hook-execution.js.map +1 -0
  716. package/dist/modes/interactive/components/keybinding-hints.d.ts +13 -0
  717. package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -0
  718. package/dist/modes/interactive/components/keybinding-hints.js +36 -0
  719. package/dist/modes/interactive/components/keybinding-hints.js.map +1 -0
  720. package/dist/modes/interactive/components/login-dialog.d.ts +55 -0
  721. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -0
  722. package/dist/modes/interactive/components/login-dialog.js +176 -0
  723. package/dist/modes/interactive/components/login-dialog.js.map +1 -0
  724. package/dist/modes/interactive/components/markdown-transform.d.ts +4 -0
  725. package/dist/modes/interactive/components/markdown-transform.d.ts.map +1 -0
  726. package/dist/modes/interactive/components/markdown-transform.js +19 -0
  727. package/dist/modes/interactive/components/markdown-transform.js.map +1 -0
  728. package/dist/modes/interactive/components/mermaid.d.ts +14 -0
  729. package/dist/modes/interactive/components/mermaid.d.ts.map +1 -0
  730. package/dist/modes/interactive/components/mermaid.js +228 -0
  731. package/dist/modes/interactive/components/mermaid.js.map +1 -0
  732. package/dist/modes/interactive/components/message-card.d.ts +9 -0
  733. package/dist/modes/interactive/components/message-card.d.ts.map +1 -0
  734. package/dist/modes/interactive/components/message-card.js +24 -0
  735. package/dist/modes/interactive/components/message-card.js.map +1 -0
  736. package/dist/modes/interactive/components/model-selector.d.ts +52 -0
  737. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -0
  738. package/dist/modes/interactive/components/model-selector.js +296 -0
  739. package/dist/modes/interactive/components/model-selector.js.map +1 -0
  740. package/dist/modes/interactive/components/oauth-selector.d.ts +33 -0
  741. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -0
  742. package/dist/modes/interactive/components/oauth-selector.js +165 -0
  743. package/dist/modes/interactive/components/oauth-selector.js.map +1 -0
  744. package/dist/modes/interactive/components/scoped-models-selector.d.ts +50 -0
  745. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -0
  746. package/dist/modes/interactive/components/scoped-models-selector.js +300 -0
  747. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -0
  748. package/dist/modes/interactive/components/session-selector-search.d.ts +22 -0
  749. package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -0
  750. package/dist/modes/interactive/components/session-selector-search.js +144 -0
  751. package/dist/modes/interactive/components/session-selector-search.js.map +1 -0
  752. package/dist/modes/interactive/components/session-selector.d.ts +108 -0
  753. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -0
  754. package/dist/modes/interactive/components/session-selector.js +835 -0
  755. package/dist/modes/interactive/components/session-selector.js.map +1 -0
  756. package/dist/modes/interactive/components/settings-selector.d.ts +81 -0
  757. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -0
  758. package/dist/modes/interactive/components/settings-selector.js +455 -0
  759. package/dist/modes/interactive/components/settings-selector.js.map +1 -0
  760. package/dist/modes/interactive/components/show-images-selector.d.ts +10 -0
  761. package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -0
  762. package/dist/modes/interactive/components/show-images-selector.js +39 -0
  763. package/dist/modes/interactive/components/show-images-selector.js.map +1 -0
  764. package/dist/modes/interactive/components/skill-invocation-message.d.ts +18 -0
  765. package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -0
  766. package/dist/modes/interactive/components/skill-invocation-message.js +48 -0
  767. package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -0
  768. package/dist/modes/interactive/components/theme-selector.d.ts +11 -0
  769. package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -0
  770. package/dist/modes/interactive/components/theme-selector.js +50 -0
  771. package/dist/modes/interactive/components/theme-selector.js.map +1 -0
  772. package/dist/modes/interactive/components/thinking-selector.d.ts +11 -0
  773. package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -0
  774. package/dist/modes/interactive/components/thinking-selector.js +51 -0
  775. package/dist/modes/interactive/components/thinking-selector.js.map +1 -0
  776. package/dist/modes/interactive/components/tool-execution.d.ts +67 -0
  777. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -0
  778. package/dist/modes/interactive/components/tool-execution.js +312 -0
  779. package/dist/modes/interactive/components/tool-execution.js.map +1 -0
  780. package/dist/modes/interactive/components/tree-selector.d.ts +127 -0
  781. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -0
  782. package/dist/modes/interactive/components/tree-selector.js +1098 -0
  783. package/dist/modes/interactive/components/tree-selector.js.map +1 -0
  784. package/dist/modes/interactive/components/user-message-selector.d.ts +30 -0
  785. package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -0
  786. package/dist/modes/interactive/components/user-message-selector.js +114 -0
  787. package/dist/modes/interactive/components/user-message-selector.js.map +1 -0
  788. package/dist/modes/interactive/components/user-message.d.ts +16 -0
  789. package/dist/modes/interactive/components/user-message.d.ts.map +1 -0
  790. package/dist/modes/interactive/components/user-message.js +50 -0
  791. package/dist/modes/interactive/components/user-message.js.map +1 -0
  792. package/dist/modes/interactive/components/visual-truncate.d.ts +24 -0
  793. package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -0
  794. package/dist/modes/interactive/components/visual-truncate.js +33 -0
  795. package/dist/modes/interactive/components/visual-truncate.js.map +1 -0
  796. package/dist/modes/interactive/interactive-mode.d.ts +554 -0
  797. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -0
  798. package/dist/modes/interactive/interactive-mode.js +5870 -0
  799. package/dist/modes/interactive/interactive-mode.js.map +1 -0
  800. package/dist/modes/interactive/theme/dark.json +86 -0
  801. package/dist/modes/interactive/theme/light.json +85 -0
  802. package/dist/modes/interactive/theme/theme-schema.json +335 -0
  803. package/dist/modes/interactive/theme/theme.d.ts +109 -0
  804. package/dist/modes/interactive/theme/theme.d.ts.map +1 -0
  805. package/dist/modes/interactive/theme/theme.js +1040 -0
  806. package/dist/modes/interactive/theme/theme.js.map +1 -0
  807. package/dist/modes/json-event.d.ts +28 -0
  808. package/dist/modes/json-event.d.ts.map +1 -0
  809. package/dist/modes/json-event.js +12 -0
  810. package/dist/modes/json-event.js.map +1 -0
  811. package/dist/modes/print-mode.d.ts +29 -0
  812. package/dist/modes/print-mode.d.ts.map +1 -0
  813. package/dist/modes/print-mode.js +142 -0
  814. package/dist/modes/print-mode.js.map +1 -0
  815. package/dist/modes/rpc/jsonl.d.ts +17 -0
  816. package/dist/modes/rpc/jsonl.d.ts.map +1 -0
  817. package/dist/modes/rpc/jsonl.js +49 -0
  818. package/dist/modes/rpc/jsonl.js.map +1 -0
  819. package/dist/modes/rpc/rpc-client.d.ts +321 -0
  820. package/dist/modes/rpc/rpc-client.d.ts.map +1 -0
  821. package/dist/modes/rpc/rpc-client.js +755 -0
  822. package/dist/modes/rpc/rpc-client.js.map +1 -0
  823. package/dist/modes/rpc/rpc-mode.d.ts +20 -0
  824. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -0
  825. package/dist/modes/rpc/rpc-mode.js +963 -0
  826. package/dist/modes/rpc/rpc-mode.js.map +1 -0
  827. package/dist/modes/rpc/rpc-types.d.ts +652 -0
  828. package/dist/modes/rpc/rpc-types.d.ts.map +1 -0
  829. package/dist/modes/rpc/rpc-types.js +8 -0
  830. package/dist/modes/rpc/rpc-types.js.map +1 -0
  831. package/dist/package-manager-cli.d.ts +4 -0
  832. package/dist/package-manager-cli.d.ts.map +1 -0
  833. package/dist/package-manager-cli.js +488 -0
  834. package/dist/package-manager-cli.js.map +1 -0
  835. package/dist/utils/ansi.d.ts +2 -0
  836. package/dist/utils/ansi.d.ts.map +1 -0
  837. package/dist/utils/ansi.js +25 -0
  838. package/dist/utils/ansi.js.map +1 -0
  839. package/dist/utils/changelog.d.ts +23 -0
  840. package/dist/utils/changelog.d.ts.map +1 -0
  841. package/dist/utils/changelog.js +74 -0
  842. package/dist/utils/changelog.js.map +1 -0
  843. package/dist/utils/child-process.d.ts +15 -0
  844. package/dist/utils/child-process.d.ts.map +1 -0
  845. package/dist/utils/child-process.js +88 -0
  846. package/dist/utils/child-process.js.map +1 -0
  847. package/dist/utils/clipboard-image.d.ts +13 -0
  848. package/dist/utils/clipboard-image.d.ts.map +1 -0
  849. package/dist/utils/clipboard-image.js +248 -0
  850. package/dist/utils/clipboard-image.js.map +1 -0
  851. package/dist/utils/clipboard-native.d.ts +11 -0
  852. package/dist/utils/clipboard-native.d.ts.map +1 -0
  853. package/dist/utils/clipboard-native.js +20 -0
  854. package/dist/utils/clipboard-native.js.map +1 -0
  855. package/dist/utils/clipboard.d.ts +4 -0
  856. package/dist/utils/clipboard.d.ts.map +1 -0
  857. package/dist/utils/clipboard.js +171 -0
  858. package/dist/utils/clipboard.js.map +1 -0
  859. package/dist/utils/deprecation.d.ts +4 -0
  860. package/dist/utils/deprecation.d.ts.map +1 -0
  861. package/dist/utils/deprecation.js +13 -0
  862. package/dist/utils/deprecation.js.map +1 -0
  863. package/dist/utils/directory-completions.d.ts +5 -0
  864. package/dist/utils/directory-completions.d.ts.map +1 -0
  865. package/dist/utils/directory-completions.js +64 -0
  866. package/dist/utils/directory-completions.js.map +1 -0
  867. package/dist/utils/exif-orientation.d.ts +6 -0
  868. package/dist/utils/exif-orientation.d.ts.map +1 -0
  869. package/dist/utils/exif-orientation.js +166 -0
  870. package/dist/utils/exif-orientation.js.map +1 -0
  871. package/dist/utils/frontmatter.d.ts +8 -0
  872. package/dist/utils/frontmatter.d.ts.map +1 -0
  873. package/dist/utils/frontmatter.js +26 -0
  874. package/dist/utils/frontmatter.js.map +1 -0
  875. package/dist/utils/fs-watch.d.ts +5 -0
  876. package/dist/utils/fs-watch.d.ts.map +1 -0
  877. package/dist/utils/fs-watch.js +25 -0
  878. package/dist/utils/fs-watch.js.map +1 -0
  879. package/dist/utils/git.d.ts +27 -0
  880. package/dist/utils/git.d.ts.map +1 -0
  881. package/dist/utils/git.js +237 -0
  882. package/dist/utils/git.js.map +1 -0
  883. package/dist/utils/grip-user-agent.d.ts +2 -0
  884. package/dist/utils/grip-user-agent.d.ts.map +1 -0
  885. package/dist/utils/grip-user-agent.js +5 -0
  886. package/dist/utils/grip-user-agent.js.map +1 -0
  887. package/dist/utils/html.d.ts +7 -0
  888. package/dist/utils/html.d.ts.map +1 -0
  889. package/dist/utils/html.js +40 -0
  890. package/dist/utils/html.js.map +1 -0
  891. package/dist/utils/image-convert.d.ts +12 -0
  892. package/dist/utils/image-convert.d.ts.map +1 -0
  893. package/dist/utils/image-convert.js +43 -0
  894. package/dist/utils/image-convert.js.map +1 -0
  895. package/dist/utils/image-process.d.ts +18 -0
  896. package/dist/utils/image-process.d.ts.map +1 -0
  897. package/dist/utils/image-process.js +83 -0
  898. package/dist/utils/image-process.js.map +1 -0
  899. package/dist/utils/image-resize-core.d.ts +30 -0
  900. package/dist/utils/image-resize-core.d.ts.map +1 -0
  901. package/dist/utils/image-resize-core.js +133 -0
  902. package/dist/utils/image-resize-core.js.map +1 -0
  903. package/dist/utils/image-resize-worker.d.ts +2 -0
  904. package/dist/utils/image-resize-worker.d.ts.map +1 -0
  905. package/dist/utils/image-resize-worker.js +31 -0
  906. package/dist/utils/image-resize-worker.js.map +1 -0
  907. package/dist/utils/image-resize.d.ts +19 -0
  908. package/dist/utils/image-resize.d.ts.map +1 -0
  909. package/dist/utils/image-resize.js +86 -0
  910. package/dist/utils/image-resize.js.map +1 -0
  911. package/dist/utils/json.d.ts +3 -0
  912. package/dist/utils/json.d.ts.map +1 -0
  913. package/dist/utils/json.js +7 -0
  914. package/dist/utils/json.js.map +1 -0
  915. package/dist/utils/mime.d.ts +3 -0
  916. package/dist/utils/mime.d.ts.map +1 -0
  917. package/dist/utils/mime.js +110 -0
  918. package/dist/utils/mime.js.map +1 -0
  919. package/dist/utils/open-browser.d.ts +9 -0
  920. package/dist/utils/open-browser.d.ts.map +1 -0
  921. package/dist/utils/open-browser.js +22 -0
  922. package/dist/utils/open-browser.js.map +1 -0
  923. package/dist/utils/paths.d.ts +31 -0
  924. package/dist/utils/paths.d.ts.map +1 -0
  925. package/dist/utils/paths.js +87 -0
  926. package/dist/utils/paths.js.map +1 -0
  927. package/dist/utils/photon.d.ts +22 -0
  928. package/dist/utils/photon.d.ts.map +1 -0
  929. package/dist/utils/photon.js +126 -0
  930. package/dist/utils/photon.js.map +1 -0
  931. package/dist/utils/shell.d.ts +28 -0
  932. package/dist/utils/shell.d.ts.map +1 -0
  933. package/dist/utils/shell.js +188 -0
  934. package/dist/utils/shell.js.map +1 -0
  935. package/dist/utils/sleep.d.ts +5 -0
  936. package/dist/utils/sleep.d.ts.map +1 -0
  937. package/dist/utils/sleep.js +17 -0
  938. package/dist/utils/sleep.js.map +1 -0
  939. package/dist/utils/syntax-highlight.d.ts +12 -0
  940. package/dist/utils/syntax-highlight.d.ts.map +1 -0
  941. package/dist/utils/syntax-highlight.js +125 -0
  942. package/dist/utils/syntax-highlight.js.map +1 -0
  943. package/dist/utils/tools-manager.d.ts +5 -0
  944. package/dist/utils/tools-manager.d.ts.map +1 -0
  945. package/dist/utils/tools-manager.js +329 -0
  946. package/dist/utils/tools-manager.js.map +1 -0
  947. package/dist/utils/version-check.d.ts +14 -0
  948. package/dist/utils/version-check.d.ts.map +1 -0
  949. package/dist/utils/version-check.js +91 -0
  950. package/dist/utils/version-check.js.map +1 -0
  951. package/dist/utils/windows-self-update.d.ts +3 -0
  952. package/dist/utils/windows-self-update.d.ts.map +1 -0
  953. package/dist/utils/windows-self-update.js +77 -0
  954. package/dist/utils/windows-self-update.js.map +1 -0
  955. package/docs/compaction.md +408 -0
  956. package/docs/custom-provider.md +714 -0
  957. package/docs/daemon-architecture.md +399 -0
  958. package/docs/daemon.md +112 -0
  959. package/docs/development.md +72 -0
  960. package/docs/docs.json +164 -0
  961. package/docs/extensions.md +2745 -0
  962. package/docs/hooks.md +85 -0
  963. package/docs/images/doom-extension.png +0 -0
  964. package/docs/images/exy.png +0 -0
  965. package/docs/images/interactive-mode.png +0 -0
  966. package/docs/images/tree-view.png +0 -0
  967. package/docs/index.md +77 -0
  968. package/docs/json.md +89 -0
  969. package/docs/keybindings.md +230 -0
  970. package/docs/lsp.md +499 -0
  971. package/docs/migrating-to-grip.md +18 -0
  972. package/docs/models.md +496 -0
  973. package/docs/packages.md +228 -0
  974. package/docs/prompt-templates.md +88 -0
  975. package/docs/providers.md +251 -0
  976. package/docs/quickstart.md +159 -0
  977. package/docs/rpc.md +1492 -0
  978. package/docs/rules.md +117 -0
  979. package/docs/sandbox.md +104 -0
  980. package/docs/sdk.md +360 -0
  981. package/docs/session-format.md +414 -0
  982. package/docs/sessions.md +137 -0
  983. package/docs/settings.md +372 -0
  984. package/docs/shell-aliases.md +13 -0
  985. package/docs/skills.md +246 -0
  986. package/docs/terminal-setup.md +112 -0
  987. package/docs/termux.md +112 -0
  988. package/docs/themes.md +295 -0
  989. package/docs/tmux.md +61 -0
  990. package/docs/tui.md +918 -0
  991. package/docs/usage.md +304 -0
  992. package/docs/windows.md +17 -0
  993. package/examples/README.md +29 -0
  994. package/examples/daemon-docker/Dockerfile +43 -0
  995. package/examples/daemon-docker/README.md +45 -0
  996. package/examples/extensions/README.md +208 -0
  997. package/examples/extensions/auto-commit-on-exit.ts +46 -0
  998. package/examples/extensions/bash-spawn-hook.ts +30 -0
  999. package/examples/extensions/bookmark.ts +50 -0
  1000. package/examples/extensions/border-status-editor.ts +145 -0
  1001. package/examples/extensions/built-in-tool-renderer.ts +259 -0
  1002. package/examples/extensions/claude-rules.ts +86 -0
  1003. package/examples/extensions/commands.ts +82 -0
  1004. package/examples/extensions/confirm-destructive.ts +59 -0
  1005. package/examples/extensions/custom-compaction.ts +131 -0
  1006. package/examples/extensions/custom-footer.ts +79 -0
  1007. package/examples/extensions/custom-header.ts +73 -0
  1008. package/examples/extensions/custom-provider-anthropic/index.ts +707 -0
  1009. package/examples/extensions/custom-provider-anthropic/package-lock.json +24 -0
  1010. package/examples/extensions/custom-provider-anthropic/package.json +19 -0
  1011. package/examples/extensions/custom-provider-gitlab-duo/index.ts +402 -0
  1012. package/examples/extensions/custom-provider-gitlab-duo/package.json +16 -0
  1013. package/examples/extensions/custom-provider-gitlab-duo/test.ts +104 -0
  1014. package/examples/extensions/dirty-repo-guard.ts +59 -0
  1015. package/examples/extensions/doom-overlay/README.md +46 -0
  1016. package/examples/extensions/doom-overlay/doom/build/doom.js +21 -0
  1017. package/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
  1018. package/examples/extensions/doom-overlay/doom/build.sh +152 -0
  1019. package/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +72 -0
  1020. package/examples/extensions/doom-overlay/doom-component.ts +133 -0
  1021. package/examples/extensions/doom-overlay/doom-engine.ts +173 -0
  1022. package/examples/extensions/doom-overlay/doom-keys.ts +104 -0
  1023. package/examples/extensions/doom-overlay/index.ts +74 -0
  1024. package/examples/extensions/doom-overlay/wad-finder.ts +51 -0
  1025. package/examples/extensions/dynamic-resources/RULES.md +8 -0
  1026. package/examples/extensions/dynamic-resources/SKILL.md +8 -0
  1027. package/examples/extensions/dynamic-resources/dynamic.json +79 -0
  1028. package/examples/extensions/dynamic-resources/dynamic.md +5 -0
  1029. package/examples/extensions/dynamic-resources/index.ts +16 -0
  1030. package/examples/extensions/dynamic-tools.ts +74 -0
  1031. package/examples/extensions/event-bus.ts +43 -0
  1032. package/examples/extensions/file-trigger.ts +41 -0
  1033. package/examples/extensions/git-checkpoint.ts +53 -0
  1034. package/examples/extensions/git-merge-and-resolve.ts +125 -0
  1035. package/examples/extensions/github-issue-autocomplete.ts +191 -0
  1036. package/examples/extensions/handoff.ts +191 -0
  1037. package/examples/extensions/hello.ts +26 -0
  1038. package/examples/extensions/hidden-thinking-label.ts +53 -0
  1039. package/examples/extensions/inline-bash.ts +104 -0
  1040. package/examples/extensions/input-transform.ts +43 -0
  1041. package/examples/extensions/interactive-shell.ts +194 -0
  1042. package/examples/extensions/mac-system-theme.ts +47 -0
  1043. package/examples/extensions/message-renderer.ts +59 -0
  1044. package/examples/extensions/minimal-mode.ts +428 -0
  1045. package/examples/extensions/modal-editor.ts +86 -0
  1046. package/examples/extensions/model-status.ts +31 -0
  1047. package/examples/extensions/notify.ts +55 -0
  1048. package/examples/extensions/overlay-qa-tests.ts +1374 -0
  1049. package/examples/extensions/overlay-test.ts +171 -0
  1050. package/examples/extensions/permission-gate.ts +34 -0
  1051. package/examples/extensions/pirate.ts +47 -0
  1052. package/examples/extensions/plan-mode/README.md +65 -0
  1053. package/examples/extensions/plan-mode/index.ts +346 -0
  1054. package/examples/extensions/plan-mode/utils.ts +172 -0
  1055. package/examples/extensions/preset.ts +426 -0
  1056. package/examples/extensions/prompt-customizer.ts +97 -0
  1057. package/examples/extensions/protected-paths.ts +29 -0
  1058. package/examples/extensions/provider-payload.ts +18 -0
  1059. package/examples/extensions/qna.ts +125 -0
  1060. package/examples/extensions/question.ts +294 -0
  1061. package/examples/extensions/questionnaire.ts +459 -0
  1062. package/examples/extensions/rainbow-editor.ts +88 -0
  1063. package/examples/extensions/reload-runtime.ts +37 -0
  1064. package/examples/extensions/rpc-demo.ts +118 -0
  1065. package/examples/extensions/sandbox/index.ts +320 -0
  1066. package/examples/extensions/sandbox/package-lock.json +92 -0
  1067. package/examples/extensions/sandbox/package.json +19 -0
  1068. package/examples/extensions/send-user-message.ts +97 -0
  1069. package/examples/extensions/session-name.ts +27 -0
  1070. package/examples/extensions/shutdown-command.ts +63 -0
  1071. package/examples/extensions/snake.ts +381 -0
  1072. package/examples/extensions/space-invaders.ts +597 -0
  1073. package/examples/extensions/status-line.ts +32 -0
  1074. package/examples/extensions/structured-output.ts +65 -0
  1075. package/examples/extensions/subagent/README.md +175 -0
  1076. package/examples/extensions/subagent/agents/planner.md +37 -0
  1077. package/examples/extensions/subagent/agents/reviewer.md +35 -0
  1078. package/examples/extensions/subagent/agents/scout.md +50 -0
  1079. package/examples/extensions/subagent/agents/worker.md +24 -0
  1080. package/examples/extensions/subagent/agents.ts +126 -0
  1081. package/examples/extensions/subagent/index.ts +1083 -0
  1082. package/examples/extensions/subagent/prompts/implement-and-review.md +10 -0
  1083. package/examples/extensions/subagent/prompts/implement.md +10 -0
  1084. package/examples/extensions/subagent/prompts/scout-and-plan.md +9 -0
  1085. package/examples/extensions/summarize.ts +186 -0
  1086. package/examples/extensions/system-prompt-header.ts +17 -0
  1087. package/examples/extensions/tic-tac-toe.ts +1091 -0
  1088. package/examples/extensions/timed-confirm.ts +70 -0
  1089. package/examples/extensions/titlebar-spinner.ts +58 -0
  1090. package/examples/extensions/todo.ts +306 -0
  1091. package/examples/extensions/tool-override.ts +144 -0
  1092. package/examples/extensions/tools.ts +141 -0
  1093. package/examples/extensions/trigger-compact.ts +50 -0
  1094. package/examples/extensions/truncated-tool.ts +200 -0
  1095. package/examples/extensions/widget-placement.ts +9 -0
  1096. package/examples/extensions/with-deps/index.ts +32 -0
  1097. package/examples/extensions/with-deps/package-lock.json +31 -0
  1098. package/examples/extensions/with-deps/package.json +22 -0
  1099. package/examples/extensions/working-indicator.ts +123 -0
  1100. package/examples/extensions/working-message-test.ts +25 -0
  1101. package/examples/remote-session-server/README.md +71 -0
  1102. package/examples/remote-session-server/server.ts +353 -0
  1103. package/examples/rpc-extension-ui.ts +642 -0
  1104. package/examples/sdk/01-minimal.ts +27 -0
  1105. package/examples/sdk/02-custom-model.ts +54 -0
  1106. package/examples/sdk/03-custom-prompt.ts +76 -0
  1107. package/examples/sdk/04-skills.ts +60 -0
  1108. package/examples/sdk/05-tools.ts +55 -0
  1109. package/examples/sdk/06-extensions.ts +94 -0
  1110. package/examples/sdk/07-context-files.ts +47 -0
  1111. package/examples/sdk/08-prompt-templates.ts +56 -0
  1112. package/examples/sdk/09-api-keys-and-oauth.ts +50 -0
  1113. package/examples/sdk/10-settings.ts +58 -0
  1114. package/examples/sdk/11-sessions.ts +54 -0
  1115. package/examples/sdk/12-full-control.ts +79 -0
  1116. package/examples/sdk/13-session-runtime.ts +49 -0
  1117. package/examples/sdk/README.md +94 -0
  1118. package/npm-shrinkwrap.json +1878 -0
  1119. package/package.json +101 -5
@@ -0,0 +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,CAAC,SAAS,SAAS,mBAAmB;IACnF,SAAS,EAAE,SAAS,EAAE,CAAC;IACvB,WAAW,EAAE,kBAAkB,EAAE,CAAC;CAClC;AAED,MAAM,WAAW,mCAAmC;IACnD,mDAAmD;IACnD,GAAG,EAAE,MAAM,CAAC;IACZ,yDAAyD;IACzD,MAAM,EAAE,MAAM,CAAC;CACf;AA6BD,UAAU,sCAAsC;IAC/C,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,gCAAgC;IAChD,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,eAAe,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,WAAW,8CAA+C,SAAQ,gCAAgC;IACvG,UAAU,EAAE,cAAc,CAAC;CAC3B;AAED,MAAM,WAAW,+BAA+B;IAC/C,YAAY,EAAE,iBAAiB,CAAC,cAAc,CAAC,CAAC;IAChD,oBAAoB,EAAE,MAAM,CAAC;IAC7B,YAAY,EAAE,MAAM,CAAC;CACrB;AA8FD,8BAAsB,yBAAyB,CAC9C,SAAS,SAAS,mBAAmB,EACrC,YAAY,SAAS,8BAA8B;IAEnD,OAAO,CAAC,YAAY,CAAoC;IACxD,OAAO,CAAC,oBAAoB,CAAS;IACrC,OAAO,CAAC,YAAY,CAAS;IAE7B,YAAY,MAAM,EAAE,+BAA+B,EAIlD;IAED,SAAS,CAAC,QAAQ,CAAC,cAAc,CAAC,QAAQ,EAAE,mBAAmB,EAAE,WAAW,EAAE,YAAY,GAAG,SAAS,CAAC;IAEvG,SAAS,CAAC,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,6BAA6B,CAAC,SAAS,CAAC,CAEpG;IAED,OAAO,CAAC,+BAA+B;IAqCvC,SAAS,CAAC,aAAa,CAAC,OAAO,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"]}
@@ -0,0 +1,574 @@
1
+ import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
2
+ import { dirname, join, relative, resolve, sep } from "node:path";
3
+ import ignore from "ignore";
4
+ import { CONFIG_DIR_NAME, getAgentDir } from "../config.js";
5
+ import { parseFrontmatter } from "../utils/frontmatter.js";
6
+ import { canonicalizePath, resolvePath } from "../utils/paths.js";
7
+ import { dirnamePortablePath, joinPortablePath, normalizePortablePath, pathComparisonValue, relativePortablePath, relativeWithin, resolvePortablePath, } from "./lsp/portable-path.js";
8
+ import { createSyntheticSourceInfo } from "./source-info.js";
9
+ const MAX_NAME_LENGTH = 64;
10
+ const MAX_DESCRIPTION_LENGTH = 1024;
11
+ const IGNORE_FILE_NAMES = [".gitignore", ".ignore", ".fdignore"];
12
+ function toPosixPath(path) {
13
+ return path.split(sep).join("/");
14
+ }
15
+ function prefixIgnorePattern(line, prefix) {
16
+ const trimmed = line.trim();
17
+ if (!trimmed)
18
+ return null;
19
+ if (trimmed.startsWith("#") && !trimmed.startsWith("\\#"))
20
+ return null;
21
+ let pattern = line;
22
+ let negated = false;
23
+ if (pattern.startsWith("!")) {
24
+ negated = true;
25
+ pattern = pattern.slice(1);
26
+ }
27
+ else if (pattern.startsWith("\\!")) {
28
+ pattern = pattern.slice(1);
29
+ }
30
+ if (pattern.startsWith("/"))
31
+ pattern = pattern.slice(1);
32
+ const prefixed = prefix ? `${prefix}${pattern}` : pattern;
33
+ return negated ? `!${prefixed}` : prefixed;
34
+ }
35
+ function validateName(name) {
36
+ const errors = [];
37
+ if (name.length > MAX_NAME_LENGTH) {
38
+ errors.push(`name exceeds ${MAX_NAME_LENGTH} characters (${name.length})`);
39
+ }
40
+ if (!/^[a-z0-9-]+$/.test(name)) {
41
+ errors.push("name contains invalid characters (must be lowercase a-z, 0-9, hyphens only)");
42
+ }
43
+ if (name.startsWith("-") || name.endsWith("-")) {
44
+ errors.push("name must not start or end with a hyphen");
45
+ }
46
+ if (name.includes("--")) {
47
+ errors.push("name must not contain consecutive hyphens");
48
+ }
49
+ return errors;
50
+ }
51
+ function validateDescription(description) {
52
+ if (!description || description.trim() === "")
53
+ return ["description is required"];
54
+ if (description.length > MAX_DESCRIPTION_LENGTH) {
55
+ return [`description exceeds ${MAX_DESCRIPTION_LENGTH} characters (${description.length})`];
56
+ }
57
+ return [];
58
+ }
59
+ function normalizeFrontmatterTools(value) {
60
+ const raw = Array.isArray(value) ? value : typeof value === "string" ? value.split(/[\s,]+/) : [];
61
+ const tools = [];
62
+ const seen = new Set();
63
+ for (const entry of raw) {
64
+ if (typeof entry !== "string")
65
+ continue;
66
+ const trimmed = entry.trim();
67
+ if (trimmed.length > 0 && !seen.has(trimmed)) {
68
+ seen.add(trimmed);
69
+ tools.push(trimmed);
70
+ }
71
+ }
72
+ return tools;
73
+ }
74
+ function createResourceSourceInfo(filePath, baseDir, source) {
75
+ switch (source) {
76
+ case "user":
77
+ return createSyntheticSourceInfo(filePath, { source: "local", scope: "user", baseDir });
78
+ case "project":
79
+ return createSyntheticSourceInfo(filePath, { source: "local", scope: "project", baseDir });
80
+ case "path":
81
+ return createSyntheticSourceInfo(filePath, { source: "local", baseDir });
82
+ default:
83
+ return createSyntheticSourceInfo(filePath, { source, baseDir });
84
+ }
85
+ }
86
+ function isUnderPath(target, root) {
87
+ const normalizedRoot = resolve(root);
88
+ if (target === normalizedRoot)
89
+ return true;
90
+ const prefix = normalizedRoot.endsWith(sep) ? normalizedRoot : `${normalizedRoot}${sep}`;
91
+ return target.startsWith(prefix);
92
+ }
93
+ async function backendPathExists(operations, path) {
94
+ try {
95
+ await operations.access(path, "exists");
96
+ return true;
97
+ }
98
+ catch {
99
+ return false;
100
+ }
101
+ }
102
+ export class InstructionResourceLoader {
103
+ resourceType;
104
+ defaultDirectoryName;
105
+ rootFileName;
106
+ constructor(config) {
107
+ this.resourceType = config.resourceType;
108
+ this.defaultDirectoryName = config.defaultDirectoryName;
109
+ this.rootFileName = config.rootFileName;
110
+ }
111
+ loadResourcesFromDir(dir, source) {
112
+ return this.loadResourcesFromDirInternal(dir, source, true);
113
+ }
114
+ loadResourcesFromConfiguredPath(resolvedPath, source) {
115
+ if (!existsSync(resolvedPath)) {
116
+ return {
117
+ resources: [],
118
+ diagnostics: [{ type: "warning", message: `${this.resourceType} path does not exist`, path: resolvedPath }],
119
+ };
120
+ }
121
+ try {
122
+ const stats = statSync(resolvedPath);
123
+ if (stats.isDirectory())
124
+ return this.loadResourcesFromDirInternal(resolvedPath, source, true);
125
+ if (!stats.isFile() || !resolvedPath.endsWith(".md")) {
126
+ return {
127
+ resources: [],
128
+ diagnostics: [
129
+ { type: "warning", message: `${this.resourceType} path is not a markdown file`, path: resolvedPath },
130
+ ],
131
+ };
132
+ }
133
+ const result = this.loadResourceFromFile(resolvedPath, source);
134
+ return { resources: result.resource ? [result.resource] : [], diagnostics: result.diagnostics };
135
+ }
136
+ catch (error) {
137
+ return {
138
+ resources: [],
139
+ diagnostics: [
140
+ {
141
+ type: "warning",
142
+ message: error instanceof Error ? error.message : `failed to read ${this.resourceType} path`,
143
+ path: resolvedPath,
144
+ },
145
+ ],
146
+ };
147
+ }
148
+ }
149
+ loadResources(options) {
150
+ const resolvedCwd = resolvePath(options.cwd);
151
+ const resolvedAgentDir = resolvePath(options.agentDir ?? getAgentDir());
152
+ const resourceMap = new Map();
153
+ const realPathSet = new Set();
154
+ const allDiagnostics = [];
155
+ const collisionDiagnostics = [];
156
+ const addResources = (result) => {
157
+ allDiagnostics.push(...result.diagnostics);
158
+ for (const resource of result.resources) {
159
+ const realPath = canonicalizePath(resource.filePath);
160
+ if (realPathSet.has(realPath))
161
+ continue;
162
+ const existing = resourceMap.get(resource.name);
163
+ if (existing) {
164
+ collisionDiagnostics.push(this.createCollisionDiagnostic(resource, existing));
165
+ }
166
+ else {
167
+ resourceMap.set(resource.name, resource);
168
+ realPathSet.add(realPath);
169
+ }
170
+ }
171
+ };
172
+ if (options.includeDefaults) {
173
+ addResources(this.loadResourcesFromDirInternal(join(resolvedAgentDir, this.defaultDirectoryName), "user", true));
174
+ addResources(this.loadResourcesFromDirInternal(resolve(resolvedCwd, CONFIG_DIR_NAME, this.defaultDirectoryName), "project", true));
175
+ }
176
+ const userDir = join(resolvedAgentDir, this.defaultDirectoryName);
177
+ const projectDir = resolve(resolvedCwd, CONFIG_DIR_NAME, this.defaultDirectoryName);
178
+ const getSource = (resolvedPath) => {
179
+ if (!options.includeDefaults) {
180
+ if (isUnderPath(resolvedPath, userDir))
181
+ return "user";
182
+ if (isUnderPath(resolvedPath, projectDir))
183
+ return "project";
184
+ }
185
+ return "path";
186
+ };
187
+ for (const rawPath of options.resourcePaths) {
188
+ const resolvedPath = resolvePath(rawPath, resolvedCwd, { trim: true });
189
+ addResources(this.loadResourcesFromConfiguredPath(resolvedPath, getSource(resolvedPath)));
190
+ }
191
+ return {
192
+ resources: Array.from(resourceMap.values()),
193
+ diagnostics: [...allDiagnostics, ...collisionDiagnostics],
194
+ };
195
+ }
196
+ async loadResourcesFromConfiguredPathWithOperations(operations, resolvedPath, source) {
197
+ if (!(await backendPathExists(operations, resolvedPath))) {
198
+ return {
199
+ resources: [],
200
+ diagnostics: [{ type: "warning", message: `${this.resourceType} path does not exist`, path: resolvedPath }],
201
+ };
202
+ }
203
+ try {
204
+ const stats = await operations.stat(resolvedPath);
205
+ if (stats.isDirectory()) {
206
+ return this.loadResourcesFromDirInternalWithOperations(operations, resolvedPath, source, true);
207
+ }
208
+ if (!stats.isFile() || !resolvedPath.endsWith(".md")) {
209
+ return {
210
+ resources: [],
211
+ diagnostics: [
212
+ {
213
+ type: "warning",
214
+ message: `${this.resourceType} path is not a markdown file`,
215
+ path: resolvedPath,
216
+ },
217
+ ],
218
+ };
219
+ }
220
+ const result = await this.loadResourceFromFileWithOperations(operations, resolvedPath, source);
221
+ return { resources: result.resource ? [result.resource] : [], diagnostics: result.diagnostics };
222
+ }
223
+ catch (error) {
224
+ return {
225
+ resources: [],
226
+ diagnostics: [
227
+ {
228
+ type: "warning",
229
+ message: error instanceof Error ? error.message : `failed to read ${this.resourceType} path`,
230
+ path: resolvedPath,
231
+ },
232
+ ],
233
+ };
234
+ }
235
+ }
236
+ async loadResourcesWithOperations(options) {
237
+ const backend = options.operations.getBackendInfo?.();
238
+ const pathFlavor = backend?.type === "remote" && backend.configured ? backend.workspace.pathFlavor : undefined;
239
+ const resolvedCwd = resolvePortablePath(options.operations.cwd, options.cwd);
240
+ const resolvedAgentDir = normalizePortablePath(options.agentDir ?? getAgentDir(), pathFlavor);
241
+ const resourceMap = new Map();
242
+ const pathSet = new Set();
243
+ const allDiagnostics = [];
244
+ const collisionDiagnostics = [];
245
+ const addResources = (result) => {
246
+ allDiagnostics.push(...result.diagnostics);
247
+ for (const resource of result.resources) {
248
+ const canonicalPath = pathComparisonValue(resource.filePath, pathFlavor);
249
+ if (pathSet.has(canonicalPath))
250
+ continue;
251
+ const existing = resourceMap.get(resource.name);
252
+ if (existing) {
253
+ collisionDiagnostics.push(this.createCollisionDiagnostic(resource, existing));
254
+ }
255
+ else {
256
+ resourceMap.set(resource.name, resource);
257
+ pathSet.add(canonicalPath);
258
+ }
259
+ }
260
+ };
261
+ if (options.includeDefaults) {
262
+ addResources(await this.loadResourcesFromDirInternalWithOperations(options.operations, joinPortablePath(resolvedAgentDir, this.defaultDirectoryName), "user", true));
263
+ addResources(await this.loadResourcesFromDirInternalWithOperations(options.operations, joinPortablePath(resolvedCwd, CONFIG_DIR_NAME, this.defaultDirectoryName), "project", true));
264
+ }
265
+ const userDir = joinPortablePath(resolvedAgentDir, this.defaultDirectoryName);
266
+ const projectDir = joinPortablePath(resolvedCwd, CONFIG_DIR_NAME, this.defaultDirectoryName);
267
+ const getSource = (resolvedPath) => {
268
+ if (!options.includeDefaults) {
269
+ if (relativeWithin(userDir, resolvedPath) !== undefined)
270
+ return "user";
271
+ if (relativeWithin(projectDir, resolvedPath) !== undefined)
272
+ return "project";
273
+ }
274
+ return "path";
275
+ };
276
+ for (const rawPath of options.resourcePaths) {
277
+ const resolvedPath = resolvePortablePath(resolvedCwd, rawPath.trim());
278
+ addResources(await this.loadResourcesFromConfiguredPathWithOperations(options.operations, resolvedPath, getSource(resolvedPath)));
279
+ }
280
+ return {
281
+ resources: Array.from(resourceMap.values()),
282
+ diagnostics: [...allDiagnostics, ...collisionDiagnostics],
283
+ };
284
+ }
285
+ createCollisionDiagnostic(resource, existing) {
286
+ return {
287
+ type: "collision",
288
+ message: `name "${resource.name}" collision`,
289
+ path: resource.filePath,
290
+ collision: {
291
+ resourceType: this.resourceType,
292
+ name: resource.name,
293
+ winnerPath: existing.filePath,
294
+ loserPath: resource.filePath,
295
+ },
296
+ };
297
+ }
298
+ addIgnoreRules(ig, dir, rootDir) {
299
+ const relativeDir = relative(rootDir, dir);
300
+ const prefix = relativeDir ? `${toPosixPath(relativeDir)}/` : "";
301
+ for (const filename of IGNORE_FILE_NAMES) {
302
+ const ignorePath = join(dir, filename);
303
+ if (!existsSync(ignorePath))
304
+ continue;
305
+ try {
306
+ const patterns = readFileSync(ignorePath, "utf-8")
307
+ .split(/\r?\n/)
308
+ .map((line) => prefixIgnorePattern(line, prefix))
309
+ .filter((line) => Boolean(line));
310
+ if (patterns.length > 0)
311
+ ig.add(patterns);
312
+ }
313
+ catch { }
314
+ }
315
+ }
316
+ async addIgnoreRulesWithOperations(operations, ig, dir, rootDir) {
317
+ const relativeDir = relativePortablePath(rootDir, dir);
318
+ const prefix = relativeDir && relativeDir !== "." ? `${relativeDir.replace(/\\/g, "/")}/` : "";
319
+ for (const filename of IGNORE_FILE_NAMES) {
320
+ const ignorePath = joinPortablePath(dir, filename);
321
+ if (!(await backendPathExists(operations, ignorePath)))
322
+ continue;
323
+ try {
324
+ const patterns = (await operations.readFile(ignorePath))
325
+ .toString("utf-8")
326
+ .split(/\r?\n/)
327
+ .map((line) => prefixIgnorePattern(line, prefix))
328
+ .filter((line) => Boolean(line));
329
+ if (patterns.length > 0)
330
+ ig.add(patterns);
331
+ }
332
+ catch { }
333
+ }
334
+ }
335
+ getLocalResourceEntry(entry, fullPath) {
336
+ if (!entry.isSymbolicLink())
337
+ return entry;
338
+ try {
339
+ return statSync(fullPath);
340
+ }
341
+ catch {
342
+ return undefined;
343
+ }
344
+ }
345
+ loadRootResourceFromEntries(entries, dir, source, ignoreMatcher, rootDir) {
346
+ for (const entry of entries) {
347
+ if (entry.name !== this.rootFileName)
348
+ continue;
349
+ const fullPath = join(dir, entry.name);
350
+ const resourceEntry = this.getLocalResourceEntry(entry, fullPath);
351
+ if (!resourceEntry?.isFile() || ignoreMatcher.ignores(toPosixPath(relative(rootDir, fullPath))))
352
+ continue;
353
+ const result = this.loadResourceFromFile(fullPath, source);
354
+ return { resources: result.resource ? [result.resource] : [], diagnostics: result.diagnostics };
355
+ }
356
+ return undefined;
357
+ }
358
+ loadNestedResourceEntry(entry, context) {
359
+ if (entry.name.startsWith(".") || entry.name === "node_modules")
360
+ return;
361
+ const fullPath = join(context.dir, entry.name);
362
+ const resourceEntry = this.getLocalResourceEntry(entry, fullPath);
363
+ if (!resourceEntry)
364
+ return;
365
+ const relativePath = toPosixPath(relative(context.rootDir, fullPath));
366
+ if (context.ignoreMatcher.ignores(resourceEntry.isDirectory() ? `${relativePath}/` : relativePath))
367
+ return;
368
+ if (resourceEntry.isDirectory()) {
369
+ const nested = this.loadResourcesFromDirInternal(fullPath, context.source, false, context.ignoreMatcher, context.rootDir);
370
+ context.resources.push(...nested.resources);
371
+ context.diagnostics.push(...nested.diagnostics);
372
+ return;
373
+ }
374
+ if (!resourceEntry.isFile() || !context.includeRootFiles || !entry.name.endsWith(".md"))
375
+ return;
376
+ const result = this.loadResourceFromFile(fullPath, context.source);
377
+ if (result.resource)
378
+ context.resources.push(result.resource);
379
+ context.diagnostics.push(...result.diagnostics);
380
+ }
381
+ loadNestedResourcesFromEntries(context) {
382
+ for (const entry of context.entries)
383
+ this.loadNestedResourceEntry(entry, context);
384
+ }
385
+ loadResourcesFromDirInternal(dir, source, includeRootFiles, ignoreMatcher, rootDir) {
386
+ const resources = [];
387
+ const diagnostics = [];
388
+ if (!existsSync(dir))
389
+ return { resources, diagnostics };
390
+ const root = rootDir ?? dir;
391
+ const ig = ignoreMatcher ?? ignore();
392
+ this.addIgnoreRules(ig, dir, root);
393
+ try {
394
+ const entries = readdirSync(dir, { withFileTypes: true });
395
+ const rootResource = this.loadRootResourceFromEntries(entries, dir, source, ig, root);
396
+ if (rootResource)
397
+ return rootResource;
398
+ this.loadNestedResourcesFromEntries({
399
+ entries,
400
+ dir,
401
+ source,
402
+ includeRootFiles,
403
+ ignoreMatcher: ig,
404
+ rootDir: root,
405
+ resources,
406
+ diagnostics,
407
+ });
408
+ }
409
+ catch { }
410
+ return { resources, diagnostics };
411
+ }
412
+ async getBackendResourceEntry(operations, fullPath) {
413
+ try {
414
+ return await operations.stat(fullPath);
415
+ }
416
+ catch {
417
+ return undefined;
418
+ }
419
+ }
420
+ async loadRootResourceWithOperations(context) {
421
+ for (const name of context.entries) {
422
+ if (name !== this.rootFileName)
423
+ continue;
424
+ const fullPath = joinPortablePath(context.dir, name);
425
+ const resourceEntry = await this.getBackendResourceEntry(context.operations, fullPath);
426
+ if (!resourceEntry?.isFile() ||
427
+ context.ignoreMatcher.ignores(relativePortablePath(context.rootDir, fullPath).replace(/\\/g, "/")))
428
+ continue;
429
+ const result = await this.loadResourceFromFileWithOperations(context.operations, fullPath, context.source);
430
+ return { resources: result.resource ? [result.resource] : [], diagnostics: result.diagnostics };
431
+ }
432
+ return undefined;
433
+ }
434
+ async loadNestedResourceWithOperations(name, context) {
435
+ if (name.startsWith(".") || name === "node_modules")
436
+ return;
437
+ const fullPath = joinPortablePath(context.dir, name);
438
+ const resourceEntry = await this.getBackendResourceEntry(context.operations, fullPath);
439
+ if (!resourceEntry)
440
+ return;
441
+ const relativePath = relativePortablePath(context.rootDir, fullPath).replace(/\\/g, "/");
442
+ if (context.ignoreMatcher.ignores(resourceEntry.isDirectory() ? `${relativePath}/` : relativePath))
443
+ return;
444
+ if (resourceEntry.isDirectory()) {
445
+ const nested = await this.loadResourcesFromDirInternalWithOperations(context.operations, fullPath, context.source, false, context.ignoreMatcher, context.rootDir);
446
+ context.resources.push(...nested.resources);
447
+ context.diagnostics.push(...nested.diagnostics);
448
+ return;
449
+ }
450
+ if (!resourceEntry.isFile() || !context.includeRootFiles || !name.endsWith(".md"))
451
+ return;
452
+ const result = await this.loadResourceFromFileWithOperations(context.operations, fullPath, context.source);
453
+ if (result.resource)
454
+ context.resources.push(result.resource);
455
+ context.diagnostics.push(...result.diagnostics);
456
+ }
457
+ async loadNestedResourcesWithOperations(context) {
458
+ for (const name of context.entries)
459
+ await this.loadNestedResourceWithOperations(name, context);
460
+ }
461
+ async loadResourcesFromDirInternalWithOperations(operations, dir, source, includeRootFiles, ignoreMatcher, rootDir) {
462
+ const resources = [];
463
+ const diagnostics = [];
464
+ if (!(await backendPathExists(operations, dir)))
465
+ return { resources, diagnostics };
466
+ const root = rootDir ?? dir;
467
+ const ig = ignoreMatcher ?? ignore();
468
+ await this.addIgnoreRulesWithOperations(operations, ig, dir, root);
469
+ try {
470
+ const context = {
471
+ entries: await operations.readdir(dir),
472
+ operations,
473
+ dir,
474
+ source,
475
+ includeRootFiles,
476
+ ignoreMatcher: ig,
477
+ rootDir: root,
478
+ resources,
479
+ diagnostics,
480
+ };
481
+ const rootResource = await this.loadRootResourceWithOperations(context);
482
+ if (rootResource)
483
+ return rootResource;
484
+ await this.loadNestedResourcesWithOperations(context);
485
+ }
486
+ catch { }
487
+ return { resources, diagnostics };
488
+ }
489
+ loadResourceFromFile(filePath, source) {
490
+ try {
491
+ return this.parseResource(readFileSync(filePath, "utf-8"), filePath, source);
492
+ }
493
+ catch (error) {
494
+ return this.createParseError(error, filePath);
495
+ }
496
+ }
497
+ async loadResourceFromFileWithOperations(operations, filePath, source) {
498
+ try {
499
+ const backend = operations.getBackendInfo?.();
500
+ const pathFlavor = backend?.type === "remote" && backend.configured ? backend.workspace.pathFlavor : undefined;
501
+ return this.parseResource((await operations.readFile(filePath)).toString("utf-8"), filePath, source, pathFlavor);
502
+ }
503
+ catch (error) {
504
+ return this.createParseError(error, filePath);
505
+ }
506
+ }
507
+ parseResource(rawContent, filePath, source, pathFlavor) {
508
+ const diagnostics = [];
509
+ const { frontmatter } = parseFrontmatter(rawContent);
510
+ for (const error of validateDescription(frontmatter.description)) {
511
+ diagnostics.push({ type: "warning", message: error, path: filePath });
512
+ }
513
+ if (!frontmatter.name || frontmatter.name.trim() === "") {
514
+ diagnostics.push({ type: "warning", message: "name is required", path: filePath });
515
+ }
516
+ const name = frontmatter.name;
517
+ if (name) {
518
+ for (const error of validateName(name)) {
519
+ diagnostics.push({ type: "warning", message: error, path: filePath });
520
+ }
521
+ }
522
+ if (!name || !frontmatter.description || frontmatter.description.trim() === "") {
523
+ return { resource: null, diagnostics };
524
+ }
525
+ const baseDir = pathFlavor ? dirnamePortablePath(filePath, pathFlavor) : dirname(filePath);
526
+ const resource = {
527
+ name,
528
+ description: frontmatter.description,
529
+ filePath,
530
+ baseDir,
531
+ sourceInfo: createResourceSourceInfo(filePath, baseDir, source),
532
+ disableModelInvocation: frontmatter["disable-model-invocation"] === true,
533
+ tools: normalizeFrontmatterTools(frontmatter.tools),
534
+ };
535
+ return { resource: this.createResource(resource, frontmatter), diagnostics };
536
+ }
537
+ createParseError(error, filePath) {
538
+ return {
539
+ resource: null,
540
+ diagnostics: [
541
+ {
542
+ type: "warning",
543
+ message: error instanceof Error ? error.message : `failed to parse ${this.resourceType} file`,
544
+ path: filePath,
545
+ },
546
+ ],
547
+ };
548
+ }
549
+ }
550
+ export function formatInstructionResourcesForPrompt(resources, options) {
551
+ const visibleResources = resources.filter((resource) => !resource.disableModelInvocation);
552
+ if (visibleResources.length === 0)
553
+ return "";
554
+ const [firstIntroLine = "", ...remainingIntroLines] = options.intro;
555
+ const lines = [`\n\n${firstIntroLine}`, ...remainingIntroLines, "", `<${options.containerTag}>`];
556
+ for (const resource of visibleResources) {
557
+ lines.push(` <${options.itemTag}>`);
558
+ lines.push(` <name>${escapeXml(resource.name)}</name>`);
559
+ lines.push(` <description>${escapeXml(resource.description)}</description>`);
560
+ lines.push(` <location>${escapeXml(resource.filePath)}</location>`);
561
+ lines.push(` </${options.itemTag}>`);
562
+ }
563
+ lines.push(`</${options.containerTag}>`);
564
+ return lines.join("\n");
565
+ }
566
+ function escapeXml(value) {
567
+ return value
568
+ .replace(/&/g, "&amp;")
569
+ .replace(/</g, "&lt;")
570
+ .replace(/>/g, "&gt;")
571
+ .replace(/"/g, "&quot;")
572
+ .replace(/'/g, "&apos;");
573
+ }
574
+ //# sourceMappingURL=instruction-resource-loader.js.map