dal-code 1.0.44 → 1.0.46

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 (780) hide show
  1. package/CHANGELOG.md +103 -0
  2. package/NOTICE +66 -1
  3. package/PRIVACY.md +159 -102
  4. package/dal-docs/README.md +1 -1
  5. package/dal-docs/keybindings.md +1 -0
  6. package/dal-docs/settings.md +5 -0
  7. package/dist/bun/register-bedrock.js +1 -0
  8. package/dist/cli/args.js +2 -2
  9. package/dist/cli/auth-check.js +1 -1
  10. package/dist/cli/auth-command.js +6 -5
  11. package/dist/cli/credential-print.js +1 -1
  12. package/dist/cli/experimental/auth.js +1 -0
  13. package/dist/cli/experimental/cli.js +1 -0
  14. package/dist/cli/experimental/command-options.js +1 -0
  15. package/dist/cli/experimental/command.js +1 -0
  16. package/dist/cli/experimental/commands/client.js +1 -0
  17. package/dist/cli/experimental/commands/pi.js +1 -0
  18. package/dist/cli/experimental/commands/server.js +1 -0
  19. package/dist/cli/experimental/transport-address.js +1 -0
  20. package/dist/cli/list-models.js +2 -2
  21. package/dist/cli/piped-stdin.js +2 -0
  22. package/dist/cli/startup-diagnostics.js +1 -0
  23. package/dist/client/index.js +1 -0
  24. package/dist/client/remote-session.js +1 -0
  25. package/dist/client/transcript.js +1 -0
  26. package/dist/config.d.ts +1 -0
  27. package/dist/config.js +1 -1
  28. package/dist/core/agent-log.d.ts +6 -0
  29. package/dist/core/agent-log.js +3 -0
  30. package/dist/core/agent-session-runtime.js +1 -1
  31. package/dist/core/agent-session-services.d.ts +0 -1
  32. package/dist/core/agent-session-services.js +1 -1
  33. package/dist/core/agent-session.d.ts +20 -3
  34. package/dist/core/agent-session.js +8 -8
  35. package/dist/core/auth-storage.js +1 -1
  36. package/dist/core/background-processes.js +7 -7
  37. package/dist/core/client-identity.js +1 -0
  38. package/dist/core/compaction/branch-summarization.js +3 -3
  39. package/dist/core/compaction/compaction.d.ts +2 -2
  40. package/dist/core/compaction/compaction.js +11 -9
  41. package/dist/core/compaction-backoff.js +1 -0
  42. package/dist/core/dal-session-headers.js +1 -0
  43. package/dist/core/export-html/index.js +2 -2
  44. package/dist/core/export-html/template.html +1 -0
  45. package/dist/core/export-html/template.js +35 -35
  46. package/dist/core/export-html/vendor/marked-cjk-friendly.min.js +6 -0
  47. package/dist/core/export-html/vendor/marked.min.js +30 -29
  48. package/dist/core/extensions/loader.js +1 -1
  49. package/dist/core/extensions/runner.d.ts +6 -0
  50. package/dist/core/extensions/runner.js +1 -1
  51. package/dist/core/extensions/types.d.ts +6 -1
  52. package/dist/core/extensions/virtual-modules.js +1 -1
  53. package/dist/core/http-dispatcher.js +1 -1
  54. package/dist/core/key-id-schema.js +1 -0
  55. package/dist/core/keybindings-schema.js +1 -0
  56. package/dist/core/keybindings.d.ts +5 -0
  57. package/dist/core/keybindings.js +1 -1
  58. package/dist/core/model-config.d.ts +1805 -102
  59. package/dist/core/model-config.js +4 -4
  60. package/dist/core/model-identity.js +2 -0
  61. package/dist/core/model-resolver.d.ts +30 -10
  62. package/dist/core/model-resolver.js +1 -1
  63. package/dist/core/model-runtime.d.ts +3 -0
  64. package/dist/core/model-runtime.js +2 -2
  65. package/dist/core/package-manager.d.ts +7 -0
  66. package/dist/core/package-manager.js +2 -2
  67. package/dist/core/permissions/shell-words.d.ts +26 -0
  68. package/dist/core/project-trust.js +2 -2
  69. package/dist/core/prompt-templates.js +2 -2
  70. package/dist/core/provider-attribution.js +1 -1
  71. package/dist/core/provider-composer.d.ts +2 -1
  72. package/dist/core/provider-composer.js +1 -1
  73. package/dist/core/remote-catalog-provider.js +1 -1
  74. package/dist/core/resource-loader.js +1 -1
  75. package/dist/core/sandbox/bwrap-placeholders.js +1 -1
  76. package/dist/core/sandbox/index.d.ts +1 -1
  77. package/dist/core/sandbox/index.js +1 -1
  78. package/dist/core/sandbox/libreoffice.js +1 -0
  79. package/dist/core/sandbox/policy.d.ts +4 -0
  80. package/dist/core/sandbox/policy.js +1 -1
  81. package/dist/core/sandbox/runtime.d.ts +3 -0
  82. package/dist/core/sandbox/runtime.js +1 -1
  83. package/dist/core/sandbox/shell-sandbox.d.ts +2 -0
  84. package/dist/core/sandbox/shell-sandbox.js +6 -6
  85. package/dist/core/sandbox/windows.js +4 -4
  86. package/dist/core/sdk.js +1 -1
  87. package/dist/core/session-manager.d.ts +1 -0
  88. package/dist/core/session-manager.js +12 -12
  89. package/dist/core/session-stall-monitor.d.ts +41 -0
  90. package/dist/core/session-stall-monitor.js +2 -0
  91. package/dist/core/settings-defaults.js +1 -0
  92. package/dist/core/settings-manager.d.ts +9 -0
  93. package/dist/core/settings-manager.js +1 -1
  94. package/dist/core/settings-schema.d.ts +231 -0
  95. package/dist/core/settings-schema.js +1 -0
  96. package/dist/core/stall-watchdog.d.ts +55 -0
  97. package/dist/core/stall-watchdog.js +1 -0
  98. package/dist/core/system-prompt.js +10 -10
  99. package/dist/core/tools/bash-read-only.d.ts +1 -0
  100. package/dist/core/tools/bash.d.ts +1 -0
  101. package/dist/core/tools/bash.js +14 -14
  102. package/dist/core/tools/edit.d.ts +1 -1
  103. package/dist/core/tools/edit.js +3 -3
  104. package/dist/core/tools/grep.js +1 -1
  105. package/dist/core/tools/path-utils.d.ts +1 -0
  106. package/dist/core/tools/path-utils.js +1 -1
  107. package/dist/core/tools/read.js +12 -12
  108. package/dist/core/tools/render-utils.d.ts +40 -0
  109. package/dist/core/tools/render-utils.js +7 -7
  110. package/dist/core/tools/renderers/read.js +8 -8
  111. package/dist/core/trust-manager.js +1 -1
  112. package/dist/core/workspace-lock.d.ts +6 -2
  113. package/dist/core/workspace-lock.js +3 -3
  114. package/dist/dal/builtins.js +2 -2
  115. package/dist/dal/extension-compat.js +4 -4
  116. package/dist/dal/hooks/config.d.ts +5 -1
  117. package/dist/dal/hooks/config.js +1 -1
  118. package/dist/dal/hooks/extension.js +3 -3
  119. package/dist/dal/hooks/index.d.ts +1 -1
  120. package/dist/dal/hooks/index.js +1 -1
  121. package/dist/dal/i18n.js +1 -1
  122. package/dist/dal/manifest.d.ts +1 -0
  123. package/dist/dal/manifest.js +1 -1
  124. package/dist/dal/safety-net.js +3 -1
  125. package/dist/extensions/codemode/execute.js +22 -15
  126. package/dist/extensions/codemode/index.js +1 -1
  127. package/dist/extensions/codemode/renderer.js +6 -6
  128. package/dist/extensions/codemode/tool.d.ts +2 -3
  129. package/dist/extensions/codemode/tool.js +9 -12
  130. package/dist/extensions/mcp/cli.js +4 -4
  131. package/dist/extensions/mcp/config.js +2 -2
  132. package/dist/extensions/mcp/index.js +12 -12
  133. package/dist/extensions/mcp/oauth.js +2 -2
  134. package/dist/extensions/mcp/resources.d.ts +0 -5
  135. package/dist/extensions/mcp/resources.js +1 -1
  136. package/dist/extensions/mcp/runtime.d.ts +1 -4
  137. package/dist/extensions/mcp/runtime.js +3 -3
  138. package/dist/extensions/mcp/tools.js +7 -7
  139. package/dist/extensions/tool-search/tool.js +3 -3
  140. package/dist/index.d.ts +7 -3
  141. package/dist/index.js +1 -1
  142. package/dist/main.js +4 -4
  143. package/dist/migrations.js +3 -5
  144. package/dist/modes/interactive/components/daxnuts.js +1 -0
  145. package/dist/modes/interactive/components/settings-selector.d.ts +3 -1
  146. package/dist/modes/interactive/components/settings-selector.js +1 -1
  147. package/dist/modes/interactive/components/status-indicator.d.ts +1 -1
  148. package/dist/modes/interactive/components/status-indicator.js +1 -1
  149. package/dist/modes/interactive/components/tree-selector.js +1 -1
  150. package/dist/modes/interactive/external-editor.js +1 -1
  151. package/dist/modes/interactive/interactive-mode.d.ts +7 -7
  152. package/dist/modes/interactive/interactive-mode.js +26 -26
  153. package/dist/modes/interactive/session-share.js +2 -2
  154. package/dist/modes/interactive/theme/dark.json +1 -1
  155. package/dist/modes/interactive/theme/light.json +1 -1
  156. package/dist/modes/interactive/theme/theme-json.js +4 -4
  157. package/dist/modes/interactive/theme/theme-schema.d.ts +18 -0
  158. package/dist/modes/interactive/theme/theme-schema.js +12 -0
  159. package/dist/modes/interactive/theme/theme-schema.json +2 -7
  160. package/dist/modes/interactive/theme/theme-tokens.d.ts +255 -0
  161. package/dist/modes/interactive/theme/theme-tokens.js +1 -0
  162. package/dist/modes/interactive/theme/theme.d.ts +7 -10
  163. package/dist/modes/interactive/theme/theme.js +5 -5
  164. package/dist/modes/print-mode.d.ts +1 -0
  165. package/dist/modes/print-mode.js +8 -7
  166. package/dist/modes/rpc/rpc-client.d.ts +5 -1
  167. package/dist/modes/rpc/rpc-client.js +3 -3
  168. package/dist/modes/rpc/rpc-mode.js +1 -1
  169. package/dist/modes/rpc/rpc-types.d.ts +20 -0
  170. package/dist/node_modules/@dalcode/dal-advisor/package.json +3 -3
  171. package/dist/node_modules/@dalcode/dal-advisor/src/index.js +8 -8
  172. package/dist/node_modules/@dalcode/dal-awake/package.json +2 -2
  173. package/dist/node_modules/@dalcode/dal-bridge/package.json +2 -2
  174. package/dist/node_modules/@dalcode/dal-capabilities/package.json +4 -4
  175. package/dist/node_modules/@dalcode/dal-capabilities/src/catalogue.js +1 -1
  176. package/dist/node_modules/@dalcode/dal-capabilities/src/index.js +9 -9
  177. package/dist/node_modules/@dalcode/dal-capabilities/src/match.js +1 -1
  178. package/dist/node_modules/@dalcode/dal-capabilities/src/state.js +3 -3
  179. package/dist/node_modules/@dalcode/dal-codeindex/package.json +34 -0
  180. package/dist/node_modules/@dalcode/dal-codeindex/src/extract.js +3 -0
  181. package/dist/node_modules/@dalcode/dal-codeindex/src/format.js +11 -0
  182. package/dist/node_modules/@dalcode/dal-codeindex/src/index.js +4 -0
  183. package/dist/node_modules/@dalcode/dal-codeindex/src/indexer.js +1 -0
  184. package/dist/node_modules/@dalcode/dal-codeindex/src/languages.js +176 -0
  185. package/dist/node_modules/@dalcode/dal-codeindex/src/project.js +1 -0
  186. package/dist/node_modules/@dalcode/dal-codeindex/src/query.js +2 -0
  187. package/dist/node_modules/@dalcode/dal-codeindex/src/runtime.js +1 -0
  188. package/dist/node_modules/@dalcode/dal-codeindex/src/scan.js +1 -0
  189. package/dist/node_modules/@dalcode/dal-codeindex/src/semantic.js +2 -0
  190. package/dist/node_modules/@dalcode/dal-codeindex/src/sqlite.js +1 -0
  191. package/dist/node_modules/@dalcode/dal-codeindex/src/store.js +33 -0
  192. package/dist/node_modules/@dalcode/dal-codeindex/src/worker.js +1 -0
  193. package/dist/node_modules/@dalcode/dal-compat/package.json +2 -2
  194. package/dist/node_modules/@dalcode/dal-dap/package.json +2 -2
  195. package/dist/node_modules/@dalcode/dal-dap/src/install.js +2 -2
  196. package/dist/node_modules/@dalcode/dal-gateway/package.json +2 -2
  197. package/dist/node_modules/@dalcode/dal-goal/package.json +3 -3
  198. package/dist/node_modules/@dalcode/dal-guard/package.json +5 -4
  199. package/dist/node_modules/@dalcode/dal-guard/src/credentials.js +7 -1
  200. package/dist/node_modules/@dalcode/dal-guard/src/edit-anchor-core.js +25 -23
  201. package/dist/node_modules/@dalcode/dal-guard/src/edit-anchor.js +4 -4
  202. package/dist/node_modules/@dalcode/dal-guard/src/index.js +4 -2
  203. package/dist/node_modules/@dalcode/dal-guard/src/mode.js +2 -2
  204. package/dist/node_modules/@dalcode/dal-guard/src/policy.js +1 -0
  205. package/dist/node_modules/@dalcode/dal-guard/src/session-files.js +1 -0
  206. package/dist/node_modules/@dalcode/dal-guard/src/suspicion.js +1 -0
  207. package/dist/node_modules/@dalcode/dal-guard/src/workspace.js +2 -2
  208. package/dist/node_modules/@dalcode/dal-halo/package.json +1 -1
  209. package/dist/node_modules/@dalcode/dal-interactive/package.json +2 -2
  210. package/dist/node_modules/@dalcode/dal-lang/package.json +3 -3
  211. package/dist/node_modules/@dalcode/dal-learn/package.json +4 -2
  212. package/dist/node_modules/@dalcode/dal-learn/src/engine.js +4 -4
  213. package/dist/node_modules/@dalcode/dal-learn/src/index.js +15 -14
  214. package/dist/node_modules/@dalcode/dal-learn/src/revisions.js +3 -0
  215. package/dist/node_modules/@dalcode/dal-learn/src/safety.js +1 -1
  216. package/dist/node_modules/@dalcode/dal-learn/src/skill-evolution.js +14 -14
  217. package/dist/node_modules/@dalcode/dal-lsp/package.json +5 -3
  218. package/dist/node_modules/@dalcode/dal-lsp/src/config.js +1 -1
  219. package/dist/node_modules/@dalcode/dal-lsp/src/index.js +14 -11
  220. package/dist/node_modules/@dalcode/dal-lsp/src/managed.js +1 -0
  221. package/dist/node_modules/@dalcode/dal-mcp/package.json +8 -5
  222. package/dist/node_modules/@dalcode/dal-mcp/src/child-env.js +3 -0
  223. package/dist/node_modules/@dalcode/dal-mcp/src/http-client.d.ts +9 -27
  224. package/dist/node_modules/@dalcode/dal-mcp/src/http-client.js +1 -2
  225. package/dist/node_modules/@dalcode/dal-mcp/src/index.js +17 -17
  226. package/dist/node_modules/@dalcode/dal-mcp/src/protocol-client.d.ts +38 -0
  227. package/dist/node_modules/@dalcode/dal-mcp/src/protocol-client.js +1 -0
  228. package/dist/node_modules/@dalcode/dal-mcp/src/proxy.js +6 -6
  229. package/dist/node_modules/@dalcode/dal-mcp/src/resources.js +1 -0
  230. package/dist/node_modules/@dalcode/dal-mcp/src/stdio-client.d.ts +10 -18
  231. package/dist/node_modules/@dalcode/dal-mcp/src/stdio-client.js +4 -5
  232. package/dist/node_modules/@dalcode/dal-mcp/src/types.d.ts +50 -5
  233. package/dist/node_modules/@dalcode/dal-mcp/src/types.js +1 -1
  234. package/dist/node_modules/@dalcode/dal-office/package.json +3 -2
  235. package/dist/node_modules/@dalcode/dal-office/src/extract/cell.js +1 -0
  236. package/dist/node_modules/@dalcode/dal-office/src/extract/index.js +2 -2
  237. package/dist/node_modules/@dalcode/dal-office/src/extract/ooxml.js +4 -4
  238. package/dist/node_modules/@dalcode/dal-office/src/extract/pdf.js +4 -4
  239. package/dist/node_modules/@dalcode/dal-office/src/facts.d.ts +15 -0
  240. package/dist/node_modules/@dalcode/dal-office/src/facts.js +4 -0
  241. package/dist/node_modules/@dalcode/dal-office/src/index.js +1 -1
  242. package/dist/node_modules/@dalcode/dal-office/src/lazy.js +1 -0
  243. package/dist/node_modules/@dalcode/dal-office/src/{index.d.ts → office.d.ts} +4 -5
  244. package/dist/node_modules/@dalcode/dal-office/src/office.js +1 -0
  245. package/dist/node_modules/@dalcode/dal-office/src/render/capture.d.ts +21 -0
  246. package/dist/node_modules/@dalcode/dal-office/src/render/capture.js +13 -0
  247. package/dist/node_modules/@dalcode/dal-office/src/render/chart.d.ts +15 -0
  248. package/dist/node_modules/@dalcode/dal-office/src/render/chart.js +3 -3
  249. package/dist/node_modules/@dalcode/dal-office/src/render/docx.d.ts +4 -0
  250. package/dist/node_modules/@dalcode/dal-office/src/render/docx.js +1 -1
  251. package/dist/node_modules/@dalcode/dal-office/src/render/pptx.d.ts +10 -0
  252. package/dist/node_modules/@dalcode/dal-office/src/render/pptx.js +4 -3
  253. package/dist/node_modules/@dalcode/dal-office/src/render/table-layout.js +1 -0
  254. package/dist/node_modules/@dalcode/dal-office/src/render/xlsx-chart.d.ts +24 -0
  255. package/dist/node_modules/@dalcode/dal-office/src/render/xlsx-chart.js +1 -0
  256. package/dist/node_modules/@dalcode/dal-office/src/render/xlsx.d.ts +9 -0
  257. package/dist/node_modules/@dalcode/dal-office/src/render/xlsx.js +1 -1
  258. package/dist/node_modules/@dalcode/dal-office/src/scratchpad.d.ts +2 -0
  259. package/dist/node_modules/@dalcode/dal-office/src/scratchpad.js +1 -1
  260. package/dist/node_modules/@dalcode/dal-office/src/table-stats.js +2 -0
  261. package/dist/node_modules/@dalcode/dal-office/src/themes.d.ts +2 -0
  262. package/dist/node_modules/@dalcode/dal-office/src/themes.js +1 -1
  263. package/dist/node_modules/@dalcode/dal-office/src/tools/chart-generate.js +4 -3
  264. package/dist/node_modules/@dalcode/dal-office/src/tools/doc-generate.js +2 -3
  265. package/dist/node_modules/@dalcode/dal-office/src/tools/docx-edit.js +5 -5
  266. package/dist/node_modules/@dalcode/dal-office/src/tools/drawio-generate.js +2 -3
  267. package/dist/node_modules/@dalcode/dal-office/src/tools/md-generate.js +2 -3
  268. package/dist/node_modules/@dalcode/dal-office/src/tools/ppt-generate.js +5 -2
  269. package/dist/node_modules/@dalcode/dal-office/src/tools/ppt-plan.js +4 -2
  270. package/dist/node_modules/@dalcode/dal-office/src/tools/pptx-edit.js +5 -5
  271. package/dist/node_modules/@dalcode/dal-office/src/tools/read-file.js +4 -3
  272. package/dist/node_modules/@dalcode/dal-office/src/tools/render-page.js +4 -0
  273. package/dist/node_modules/@dalcode/dal-office/src/tools/sheet-generate.js +3 -3
  274. package/dist/node_modules/@dalcode/dal-office/src/tools/xlsx-edit.js +3 -3
  275. package/dist/node_modules/@dalcode/dal-pi-kit/dist/i18n.js +19 -13
  276. package/dist/node_modules/@dalcode/dal-pi-kit/dist/index.js +1 -1
  277. package/dist/node_modules/@dalcode/dal-pi-kit/dist/project-size.js +1 -0
  278. package/dist/node_modules/@dalcode/dal-pi-kit/dist/session-scope.js +1 -0
  279. package/dist/node_modules/@dalcode/dal-pi-kit/package.json +1 -1
  280. package/dist/node_modules/@dalcode/dal-pi-kit/src/i18n.js +19 -13
  281. package/dist/node_modules/@dalcode/dal-pi-kit/src/index.js +1 -1
  282. package/dist/node_modules/@dalcode/dal-pi-kit/src/project-size.js +1 -0
  283. package/dist/node_modules/@dalcode/dal-pi-kit/src/session-scope.js +1 -0
  284. package/dist/node_modules/@dalcode/dal-plugins/package.json +4 -5
  285. package/dist/node_modules/@dalcode/dal-plugins/src/brand.js +1 -1
  286. package/dist/node_modules/@dalcode/dal-plugins/src/index.js +10 -10
  287. package/dist/node_modules/@dalcode/dal-plugins/src/manage.js +7 -7
  288. package/dist/node_modules/@dalcode/dal-recall/package.json +2 -2
  289. package/dist/node_modules/@dalcode/dal-recall/src/index.js +1 -1
  290. package/dist/node_modules/@dalcode/dal-remote/package.json +2 -2
  291. package/dist/node_modules/@dalcode/dal-review/package.json +3 -3
  292. package/dist/node_modules/@dalcode/dal-rewind/package.json +2 -2
  293. package/dist/node_modules/@dalcode/dal-rewind/src/commands.js +1 -1
  294. package/dist/node_modules/@dalcode/dal-rewind/src/core.d.ts +2 -1
  295. package/dist/node_modules/@dalcode/dal-rewind/src/core.js +8 -8
  296. package/dist/node_modules/@dalcode/dal-rewind/src/index.js +1 -1
  297. package/dist/node_modules/@dalcode/dal-rewind/src/state.js +1 -1
  298. package/dist/node_modules/@dalcode/dal-router/package.json +13 -10
  299. package/dist/node_modules/@dalcode/dal-router/src/advisor.js +1 -1
  300. package/dist/node_modules/@dalcode/dal-router/src/commands.js +8 -8
  301. package/dist/node_modules/@dalcode/dal-router/src/config.d.ts +12 -34
  302. package/dist/node_modules/@dalcode/dal-router/src/config.js +2 -2
  303. package/dist/node_modules/@dalcode/dal-router/src/index.js +2 -4
  304. package/dist/node_modules/@dalcode/dal-router/src/notice.js +1 -0
  305. package/dist/node_modules/@dalcode/dal-router/src/roles/changes.js +5 -0
  306. package/dist/node_modules/@dalcode/dal-router/src/roles/deliverables.js +4 -0
  307. package/dist/node_modules/@dalcode/dal-router/src/roles/index.js +15 -0
  308. package/dist/node_modules/@dalcode/dal-router/src/roles/models.d.ts +50 -0
  309. package/dist/node_modules/@dalcode/dal-router/src/roles/models.js +1 -0
  310. package/dist/node_modules/@dalcode/dal-router/src/roles/planner.js +4 -0
  311. package/dist/node_modules/@dalcode/dal-router/src/roles/prompts.js +42 -0
  312. package/dist/node_modules/@dalcode/dal-router/src/roles/signals.js +2 -0
  313. package/dist/node_modules/@dalcode/dal-router/src/runtime.d.ts +3 -13
  314. package/dist/node_modules/@dalcode/dal-router/src/runtime.js +1 -1
  315. package/dist/node_modules/@dalcode/dal-router/src/subagent.js +1 -1
  316. package/dist/node_modules/@dalcode/dal-router/src/task-shape.d.ts +8 -0
  317. package/dist/node_modules/@dalcode/dal-router/src/task-shape.js +1 -0
  318. package/dist/node_modules/@dalcode/dal-rtk/package.json +2 -2
  319. package/dist/node_modules/@dalcode/dal-skills/package.json +4 -3
  320. package/dist/node_modules/@dalcode/dal-skills/src/bundled/chart-design/SKILL.md +35 -0
  321. package/dist/node_modules/@dalcode/dal-skills/src/bundled/dal-slides/SKILL.md +82 -0
  322. package/dist/node_modules/@dalcode/dal-skills/src/bundled/diagram-design/SKILL.md +7 -5
  323. package/dist/node_modules/@dalcode/dal-skills/src/bundled/poster-design/SKILL.md +8 -6
  324. package/dist/node_modules/@dalcode/dal-skills/src/bundled/print-design/SKILL.md +21 -8
  325. package/dist/node_modules/@dalcode/dal-skills/src/bundled/visual-kit/diagram.html +1 -1
  326. package/dist/node_modules/@dalcode/dal-skills/src/bundled/visual-kit/mindmap.html +1 -1
  327. package/dist/node_modules/@dalcode/dal-skills/src/bundled/visual-kit/posters/event-poster.html +1 -1
  328. package/dist/node_modules/@dalcode/dal-skills/src/bundled/visual-kit/posters/poster.css +1 -1
  329. package/dist/node_modules/@dalcode/dal-skills/src/bundled/visual-kit/posters/square-card.html +1 -1
  330. package/dist/node_modules/@dalcode/dal-skills/src/bundled/visual-kit/posters/wechat-cover.html +1 -1
  331. package/dist/node_modules/@dalcode/dal-skills/src/bundled/visual-kit/posters/xhs-card.html +1 -1
  332. package/dist/node_modules/@dalcode/dal-skills/src/bundled/visual-kit/posters/xhs-cover.html +8 -5
  333. package/dist/node_modules/@dalcode/dal-skills/src/bundled/visual-kit/print/letter.html +1 -1
  334. package/dist/node_modules/@dalcode/dal-skills/src/bundled/visual-kit/print/report.html +1 -1
  335. package/dist/node_modules/@dalcode/dal-skills/src/bundled/visual-kit/print/resume.html +7 -3
  336. package/dist/node_modules/@dalcode/dal-skills/src/bundled/web-design/SKILL.md +4 -4
  337. package/dist/node_modules/@dalcode/dal-skills/src/bundled.js +1 -1
  338. package/dist/node_modules/@dalcode/dal-skills/src/catalog.js +3 -2
  339. package/dist/node_modules/@dalcode/dal-skills/src/client.js +1 -1
  340. package/dist/node_modules/@dalcode/dal-skills/src/hint.js +1 -0
  341. package/dist/node_modules/@dalcode/dal-skills/src/index.js +13 -14
  342. package/dist/node_modules/@dalcode/dal-skills/src/packages.js +3 -3
  343. package/dist/node_modules/@dalcode/dal-skills/src/search.js +1 -1
  344. package/dist/node_modules/@dalcode/dal-statusline/package.json +2 -2
  345. package/dist/node_modules/@dalcode/dal-structured/package.json +2 -2
  346. package/dist/node_modules/@dalcode/dal-subagent/package.json +5 -5
  347. package/dist/node_modules/@dalcode/dal-subagent/src/background.js +10 -10
  348. package/dist/node_modules/@dalcode/dal-subagent/src/index.js +18 -20
  349. package/dist/node_modules/@dalcode/dal-telemetry/package.json +3 -3
  350. package/dist/node_modules/@dalcode/dal-terminal/package.json +2 -2
  351. package/dist/node_modules/@dalcode/dal-tool-catalog/package.json +2 -2
  352. package/dist/node_modules/@dalcode/dal-tool-catalog/src/groups.js +1 -1
  353. package/dist/node_modules/@dalcode/dal-tool-catalog/src/index.js +4 -4
  354. package/dist/node_modules/@dalcode/dal-usage/package.json +2 -2
  355. package/dist/node_modules/@dalcode/dal-web/package.json +3 -3
  356. package/dist/node_modules/@dalcode/dal-workflow/LICENSE +27 -0
  357. package/dist/node_modules/@dalcode/dal-workflow/package.json +2 -2
  358. package/dist/node_modules/@dalcode/dal-workflow/src/announce-check.js +3 -1
  359. package/dist/node_modules/@dalcode/dal-workflow/src/deliverable-scope.js +1 -0
  360. package/dist/node_modules/@dalcode/dal-workflow/src/index.js +4 -4
  361. package/dist/node_modules/@dalcode/dal-workflow/src/plan-mode.js +13 -13
  362. package/dist/node_modules/@dalcode/dal-workflow/src/test-proof-note.js +3 -0
  363. package/dist/node_modules/@dalcode/dal-workflow/src/todo-snapshot.js +2 -0
  364. package/dist/node_modules/@dalcode/dal-workflow/src/todo.js +3 -3
  365. package/dist/node_modules/@dalcode/dal-workflow/src/truncation-check.js +1 -0
  366. package/dist/node_modules/@dalcode/dal-workflow/src/working-contract.js +1 -1
  367. package/dist/node_modules/@dalcode/deepailab/package.json +3 -3
  368. package/dist/node_modules/@dalcode/deepailab/src/index.js +3 -3
  369. package/dist/node_modules/@earendil-works/pi-agent-core/README.md +5 -0
  370. package/dist/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.d.ts +2 -1
  371. package/dist/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js +1 -1
  372. package/dist/node_modules/@earendil-works/pi-agent-core/dist/agent.d.ts +3 -1
  373. package/dist/node_modules/@earendil-works/pi-agent-core/dist/agent.js +1 -1
  374. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.js +1 -0
  375. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/branch-summarization.js +37 -0
  376. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.js +104 -0
  377. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/utils.js +16 -0
  378. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/config.js +1 -0
  379. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/context.js +1 -0
  380. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.js +10 -0
  381. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/events.js +1 -0
  382. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/execution/assistant.js +1 -0
  383. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/execution/effect-gate.js +1 -0
  384. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/execution/tools.js +1 -0
  385. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/hooks.js +1 -0
  386. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/messages.js +17 -0
  387. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/bash.js +1 -0
  388. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/bounded.js +1 -0
  389. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/chord.js +1 -0
  390. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/context.js +1 -0
  391. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/harness.js +1 -0
  392. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/hooks.js +1 -0
  393. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/index.js +1 -0
  394. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/jsonl.js +4 -0
  395. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/kinds/collapse.js +3 -0
  396. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/kinds/entries.js +1 -0
  397. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/kinds/frames.js +1 -0
  398. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/kinds/generation.js +1 -0
  399. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/kinds/job.js +1 -0
  400. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/kinds/plugin.js +1 -0
  401. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/kinds/post-tools.js +1 -0
  402. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/kinds/task-api.js +1 -0
  403. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/kinds/tool.js +3 -0
  404. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/membrane.js +1 -0
  405. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/memory.js +1 -0
  406. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/scheduler.js +1 -0
  407. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/session.js +1 -0
  408. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/system.js +8 -0
  409. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/types.js +1 -0
  410. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/view.js +1 -0
  411. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/prompt-templates.js +5 -0
  412. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/reducer.js +1 -0
  413. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/result.js +1 -0
  414. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/drive/boundary.js +1 -0
  415. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/drive/checkpoint.js +1 -0
  416. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/drive/deferred.js +1 -0
  417. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/drive/generation.js +1 -0
  418. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/drive/reconcile.js +1 -0
  419. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/drive/recovery.js +1 -0
  420. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/drive/response.js +1 -0
  421. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/drive/retry.js +1 -0
  422. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/drive/structural.js +1 -0
  423. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/drive/terminal.js +1 -0
  424. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/drive/tool-placement.js +1 -0
  425. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/drive/tools.js +1 -0
  426. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/drive.js +1 -0
  427. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/harness.js +1 -0
  428. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/index.js +1 -0
  429. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/lane.js +1 -0
  430. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/progress.js +1 -0
  431. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/reducer.js +1 -0
  432. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/restore.js +1 -0
  433. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/transcript.js +1 -0
  434. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/types.js +1 -0
  435. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/commit.js +1 -0
  436. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/context.js +1 -0
  437. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/fork-policy.js +1 -0
  438. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/fork.js +1 -0
  439. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/in-memory-storage-state.js +1 -0
  440. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/index.js +1 -0
  441. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/codec.js +1 -0
  442. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/errors.js +1 -0
  443. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/fork.js +1 -0
  444. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/index.js +1 -0
  445. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/io.js +3 -0
  446. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/legacy-v3.js +1 -0
  447. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/repo.js +1 -0
  448. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/storage.js +8 -0
  449. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/types.js +1 -0
  450. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-repo.js +1 -0
  451. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-storage.js +5 -0
  452. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl.js +1 -0
  453. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-repo.js +1 -0
  454. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-storage.js +1 -0
  455. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory.js +1 -0
  456. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/mutation-line.js +1 -0
  457. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo-utils.js +1 -0
  458. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.js +1 -0
  459. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/state.js +1 -0
  460. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/testing/benchmark/datasets.js +1 -0
  461. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/testing/benchmark/session-repo.js +1 -0
  462. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/testing/benchmark/storage.js +1 -0
  463. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/testing/conformance/session-repo.js +1 -0
  464. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/testing/conformance/storage.js +1 -0
  465. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/testing/conformance.js +1 -0
  466. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/testing/gating-storage.js +1 -0
  467. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/testing/index.js +1 -0
  468. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/testing/instrumented-storage.js +1 -0
  469. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/testing/storage-decorator.js +1 -0
  470. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/types.js +1 -0
  471. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/values.js +1 -0
  472. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/skills.js +10 -0
  473. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/system-prompt.js +2 -0
  474. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/telemetry.js +1 -0
  475. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/bash.js +12 -0
  476. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/edit-diff.js +16 -0
  477. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/edit.js +1 -0
  478. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/file-mutation-queue.js +1 -0
  479. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/image.js +1 -0
  480. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/index.js +1 -0
  481. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/path-utils.js +1 -0
  482. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/read.js +14 -0
  483. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/write.js +1 -0
  484. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/types.js +1 -0
  485. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/adaptive-publisher.js +1 -0
  486. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/output-capture.js +5 -0
  487. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/shell-output.js +1 -0
  488. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/truncate.js +5 -0
  489. package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/usage.js +1 -0
  490. package/dist/node_modules/@earendil-works/pi-agent-core/dist/node.js +1 -0
  491. package/dist/node_modules/@earendil-works/pi-agent-core/dist/search/scanning.js +1 -0
  492. package/dist/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts +2 -0
  493. package/dist/node_modules/@earendil-works/pi-agent-core/package.json +2 -2
  494. package/dist/node_modules/@earendil-works/pi-ai/README.md +83 -37
  495. package/dist/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +5 -5
  496. package/dist/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.js +1 -1
  497. package/dist/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js +1 -1
  498. package/dist/node_modules/@earendil-works/pi-ai/dist/api/classifier-shared.js +1 -1
  499. package/dist/node_modules/@earendil-works/pi-ai/dist/api/cloudflare-gateway-binding.js +1 -0
  500. package/dist/node_modules/@earendil-works/pi-ai/dist/api/cloudflare-workers-ai-system-one.js +1 -1
  501. package/dist/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.js +1 -1
  502. package/dist/node_modules/@earendil-works/pi-ai/dist/api/google-shared.js +2 -2
  503. package/dist/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.js +1 -1
  504. package/dist/node_modules/@earendil-works/pi-ai/dist/api/lazy.d.ts +6 -2
  505. package/dist/node_modules/@earendil-works/pi-ai/dist/api/lazy.js +1 -1
  506. package/dist/node_modules/@earendil-works/pi-ai/dist/api/llama-cpp-classify.js +5 -5
  507. package/dist/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js +4 -4
  508. package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js +6 -6
  509. package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js +5 -5
  510. package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js +11 -6
  511. package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js +3 -2
  512. package/dist/node_modules/@earendil-works/pi-ai/dist/api/openrouter-images.js +1 -1
  513. package/dist/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.js +4 -4
  514. package/dist/node_modules/@earendil-works/pi-ai/dist/api/simple-options.js +1 -1
  515. package/dist/node_modules/@earendil-works/pi-ai/dist/api/system-one-shared.js +1 -1
  516. package/dist/node_modules/@earendil-works/pi-ai/dist/api/typesafe-system-one.js +1 -1
  517. package/dist/node_modules/@earendil-works/pi-ai/dist/auth/oauth/oauth-page.js +74 -0
  518. package/dist/node_modules/@earendil-works/pi-ai/dist/cli.js +0 -0
  519. package/dist/node_modules/@earendil-works/pi-ai/dist/image-models.generated.js +1 -0
  520. package/dist/node_modules/@earendil-works/pi-ai/dist/images-models.js +1 -0
  521. package/dist/node_modules/@earendil-works/pi-ai/dist/index.d.ts +2 -1
  522. package/dist/node_modules/@earendil-works/pi-ai/dist/index.js +1 -1
  523. package/dist/node_modules/@earendil-works/pi-ai/dist/models.d.ts +5 -0
  524. package/dist/node_modules/@earendil-works/pi-ai/dist/models.js +1 -1
  525. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.js +1 -0
  526. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.models.js +1 -0
  527. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/compat-schema.d.ts +539 -0
  528. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/compat-schema.js +1 -0
  529. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
  530. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/amazon-bedrock.json +1 -1
  531. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/anthropic.json +1 -1
  532. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/azure.json +1 -1
  533. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/baseten.json +1 -1
  534. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/cerebras.json +1 -1
  535. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-ai-gateway.json +1 -1
  536. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-workers-ai.json +1 -1
  537. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/fireworks.json +1 -1
  538. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/github-copilot.json +1 -1
  539. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/google.json +1 -1
  540. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/groq.json +1 -1
  541. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/huggingface.json +1 -1
  542. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/kimi-coding.json +1 -1
  543. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/minimax-cn.json +1 -1
  544. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/minimax.json +1 -1
  545. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/mistral.json +1 -1
  546. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/moonshotai-cn.json +1 -1
  547. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/nvidia.json +1 -1
  548. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openai-codex.json +1 -1
  549. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openai.json +1 -1
  550. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode-go.json +1 -1
  551. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
  552. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
  553. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan-cn.json +1 -1
  554. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan.json +1 -1
  555. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/radius.json +1 -1
  556. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/together.json +1 -1
  557. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/typesafe.json +1 -1
  558. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
  559. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/xai.json +1 -1
  560. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-ams.json +1 -1
  561. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-cn.json +1 -1
  562. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-sgp.json +1 -1
  563. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi.json +1 -1
  564. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.js +1 -1
  565. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/model-schema.d.ts +90 -0
  566. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/model-schema.js +1 -0
  567. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/openrouter-api.js +1 -0
  568. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/openrouter-images.js +1 -0
  569. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.js +1 -1
  570. package/dist/node_modules/@earendil-works/pi-ai/dist/telemetry.d.ts +286 -0
  571. package/dist/node_modules/@earendil-works/pi-ai/dist/telemetry.js +1 -0
  572. package/dist/node_modules/@earendil-works/pi-ai/dist/types.d.ts +23 -148
  573. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/deferred-tools.js +1 -0
  574. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/event-stream.d.ts +4 -0
  575. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/event-stream.js +1 -1
  576. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/identity.d.ts +27 -0
  577. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/identity.js +1 -0
  578. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/overflow.js +1 -1
  579. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/provider-retry.js +1 -1
  580. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/retry.js +1 -1
  581. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/transcript.d.ts +3 -2
  582. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/transcript.js +2 -2
  583. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/version.d.ts +1 -0
  584. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/version.js +1 -0
  585. package/dist/node_modules/@earendil-works/pi-ai/package.json +2 -2
  586. package/dist/node_modules/@earendil-works/pi-codemode/README.md +195 -11
  587. package/dist/node_modules/@earendil-works/pi-codemode/dist/cloudflare.js +1 -0
  588. package/dist/node_modules/@earendil-works/pi-codemode/dist/declarations.d.ts +0 -2
  589. package/dist/node_modules/@earendil-works/pi-codemode/dist/declarations.js +9 -84
  590. package/dist/node_modules/@earendil-works/pi-codemode/dist/index.d.ts +5 -2
  591. package/dist/node_modules/@earendil-works/pi-codemode/dist/index.js +1 -1
  592. package/dist/node_modules/@earendil-works/pi-codemode/dist/portable.js +1 -0
  593. package/dist/node_modules/@earendil-works/pi-codemode/dist/runtime/execution.d.ts +29 -0
  594. package/dist/node_modules/@earendil-works/pi-codemode/dist/runtime/execution.js +1 -0
  595. package/dist/node_modules/@earendil-works/pi-codemode/dist/runtime/host.d.ts +3 -16
  596. package/dist/node_modules/@earendil-works/pi-codemode/dist/runtime/host.js +1 -1
  597. package/dist/node_modules/@earendil-works/pi-codemode/dist/runtime/inline.d.ts +13 -0
  598. package/dist/node_modules/@earendil-works/pi-codemode/dist/runtime/inline.js +1 -0
  599. package/dist/node_modules/@earendil-works/pi-codemode/dist/runtime/prelude-source.js +14 -6
  600. package/dist/node_modules/@earendil-works/pi-codemode/dist/runtime/protocol.d.ts +72 -0
  601. package/dist/node_modules/@earendil-works/pi-codemode/dist/runtime/protocol.js +1 -1
  602. package/dist/node_modules/@earendil-works/pi-codemode/dist/runtime/remote.d.ts +32 -0
  603. package/dist/node_modules/@earendil-works/pi-codemode/dist/runtime/remote.js +1 -0
  604. package/dist/node_modules/@earendil-works/pi-codemode/dist/runtime/vm.js +3 -0
  605. package/dist/node_modules/@earendil-works/pi-codemode/dist/runtime/worker.js +1 -3
  606. package/dist/node_modules/@earendil-works/pi-codemode/dist/source.js +4 -3
  607. package/dist/node_modules/@earendil-works/pi-codemode/dist/types.d.ts +51 -1
  608. package/dist/node_modules/@earendil-works/pi-codemode/package.json +14 -2
  609. package/dist/node_modules/@earendil-works/pi-coding-agent/package.json +1 -1
  610. package/dist/node_modules/@earendil-works/pi-mcp/CHANGELOG.md +15 -0
  611. package/dist/node_modules/@earendil-works/pi-mcp/dist/client.js +1 -1
  612. package/dist/node_modules/@earendil-works/pi-mcp/dist/index.d.ts +1 -1
  613. package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/errors.d.ts +2 -2
  614. package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/errors.js +1 -1
  615. package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/flow.js +1 -1
  616. package/dist/node_modules/@earendil-works/pi-mcp/dist/protocol/content.d.ts +1 -1
  617. package/dist/node_modules/@earendil-works/pi-mcp/dist/transports/streamable-http.d.ts +2 -2
  618. package/dist/node_modules/@earendil-works/pi-mcp/dist/transports/streamable-http.js +4 -4
  619. package/dist/node_modules/@earendil-works/pi-mcp/dist/transports/transport.d.ts +4 -1
  620. package/dist/node_modules/@earendil-works/pi-mcp/package.json +1 -1
  621. package/dist/node_modules/@earendil-works/pi-telemetry/README.md +167 -21
  622. package/dist/node_modules/@earendil-works/pi-telemetry/dist/index.d.ts +77 -2
  623. package/dist/node_modules/@earendil-works/pi-telemetry/dist/index.js +1 -1
  624. package/dist/node_modules/@earendil-works/pi-telemetry/dist/memory.d.ts +35 -2
  625. package/dist/node_modules/@earendil-works/pi-telemetry/dist/memory.js +1 -1
  626. package/dist/node_modules/@earendil-works/pi-telemetry/dist/metrics.d.ts +70 -0
  627. package/dist/node_modules/@earendil-works/pi-telemetry/dist/metrics.js +1 -0
  628. package/dist/node_modules/@earendil-works/pi-telemetry/dist/noop.d.ts +5 -2
  629. package/dist/node_modules/@earendil-works/pi-telemetry/dist/noop.js +1 -1
  630. package/dist/node_modules/@earendil-works/pi-telemetry/dist/render.js +2 -0
  631. package/dist/node_modules/@earendil-works/pi-telemetry/dist/testing/conformance.js +1 -1
  632. package/dist/node_modules/@earendil-works/pi-telemetry/package.json +6 -1
  633. package/dist/node_modules/@earendil-works/pi-tui/README.md +5 -3
  634. package/dist/node_modules/@earendil-works/pi-tui/dist/autocomplete.js +2 -2
  635. package/dist/node_modules/@earendil-works/pi-tui/dist/components/editor.js +6 -6
  636. package/dist/node_modules/@earendil-works/pi-tui/dist/components/input.js +2 -2
  637. package/dist/node_modules/@earendil-works/pi-tui/dist/components/markdown.js +8 -7
  638. package/dist/node_modules/@earendil-works/pi-tui/dist/index.d.ts +1 -1
  639. package/dist/node_modules/@earendil-works/pi-tui/dist/index.js +1 -1
  640. package/dist/node_modules/@earendil-works/pi-tui/dist/keys.js +5 -5
  641. package/dist/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.d.ts +3 -0
  642. package/dist/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.js +1 -1
  643. package/dist/node_modules/@earendil-works/pi-tui/dist/terminal-image.js +1 -1
  644. package/dist/node_modules/@earendil-works/pi-tui/dist/terminal.d.ts +3 -0
  645. package/dist/node_modules/@earendil-works/pi-tui/dist/terminal.js +1 -1
  646. package/dist/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.d.ts +2 -0
  647. package/dist/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.js +4 -4
  648. package/dist/node_modules/@earendil-works/pi-tui/dist/tui-main-screen.js +1 -1
  649. package/dist/node_modules/@earendil-works/pi-tui/dist/tui.d.ts +7 -0
  650. package/dist/node_modules/@earendil-works/pi-tui/dist/tui.js +2 -2
  651. package/dist/node_modules/@earendil-works/pi-tui/dist/utils.js +1 -1
  652. package/dist/node_modules/@earendil-works/pi-tui/package.json +3 -2
  653. package/dist/package-manager-cli.js +9 -9
  654. package/dist/sdk/index.d.ts +3 -3
  655. package/dist/sdk/index.js +1 -1
  656. package/dist/sdk/office.d.ts +1 -1
  657. package/dist/sdk/office.js +1 -1
  658. package/dist/sdk/rewind.d.ts +1 -1
  659. package/dist/sdk/rewind.js +1 -1
  660. package/dist/sdk/router.d.ts +4 -4
  661. package/dist/sdk/router.js +1 -1
  662. package/dist/server/create-harness.js +1 -0
  663. package/dist/utils/clipboard-command.js +1 -1
  664. package/dist/utils/clipboard-native.js +1 -0
  665. package/dist/utils/clipboard.js +1 -1
  666. package/dist/utils/output-files.js +1 -1
  667. package/dist/utils/pi-user-agent.js +1 -1
  668. package/dist/utils/shell.js +2 -2
  669. package/dist/utils/temp-files.js +1 -0
  670. package/dist/utils/tools-manager.js +1 -1
  671. package/docs/security.md +24 -7
  672. package/examples/README.md +0 -3
  673. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  674. package/examples/extensions/dynamic-resources/dynamic.json +1 -1
  675. package/examples/extensions/gondolin/package-lock.json +2 -2
  676. package/examples/extensions/gondolin/package.json +1 -1
  677. package/examples/extensions/minimal-mode.ts +4 -5
  678. package/examples/extensions/overlay-test.ts +2 -2
  679. package/examples/extensions/sandbox/package-lock.json +2 -2
  680. package/examples/extensions/sandbox/package.json +1 -1
  681. package/examples/extensions/subagent/index.ts +4 -6
  682. package/examples/extensions/with-deps/package-lock.json +2 -2
  683. package/examples/extensions/with-deps/package.json +1 -1
  684. package/npm-shrinkwrap.json +22 -460
  685. package/package.json +7 -12
  686. package/dist/modes/interactive/theme/theme-json.d.ts +0 -75
  687. package/dist/node_modules/@dalcode/dal-guard/src/review.js +0 -3
  688. package/dist/node_modules/@dalcode/dal-office/src/scenes.js +0 -1
  689. package/dist/node_modules/@dalcode/dal-plugins/src/rank.js +0 -4
  690. package/dist/node_modules/@dalcode/dal-router/src/assist.js +0 -4
  691. package/dist/node_modules/@dalcode/dal-router/src/compact-defer.js +0 -3
  692. package/dist/node_modules/@dalcode/dal-router/src/jev.d.ts +0 -52
  693. package/dist/node_modules/@dalcode/dal-router/src/jev.js +0 -5
  694. package/dist/node_modules/@dalcode/dal-router/src/router.d.ts +0 -32
  695. package/dist/node_modules/@dalcode/dal-router/src/router.js +0 -1
  696. package/dist/node_modules/@dalcode/dal-router/src/services.js +0 -1
  697. package/dist/node_modules/@dalcode/dal-subagent/src/role-pick.js +0 -2
  698. package/dist/node_modules/@earendil-works/chord/README.md +0 -264
  699. package/dist/node_modules/@earendil-works/chord/dist/api.js +0 -1
  700. package/dist/node_modules/@earendil-works/chord/dist/bundler.js +0 -1
  701. package/dist/node_modules/@earendil-works/chord/dist/context/index.js +0 -1
  702. package/dist/node_modules/@earendil-works/chord/dist/delta/apply-immutable-trusted.js +0 -1
  703. package/dist/node_modules/@earendil-works/chord/dist/delta/diff.js +0 -1
  704. package/dist/node_modules/@earendil-works/chord/dist/delta/index.js +0 -1
  705. package/dist/node_modules/@earendil-works/chord/dist/delta/revision-validator.js +0 -1
  706. package/dist/node_modules/@earendil-works/chord/dist/delta/tracker.js +0 -1
  707. package/dist/node_modules/@earendil-works/chord/dist/facets/host.js +0 -1
  708. package/dist/node_modules/@earendil-works/chord/dist/facets/loader.js +0 -1
  709. package/dist/node_modules/@earendil-works/chord/dist/index.js +0 -1
  710. package/dist/node_modules/@earendil-works/chord/dist/json.js +0 -1
  711. package/dist/node_modules/@earendil-works/chord/dist/node/bundle-loader.js +0 -2
  712. package/dist/node_modules/@earendil-works/chord/dist/node/bundle.js +0 -4
  713. package/dist/node_modules/@earendil-works/chord/dist/node/manifest.js +0 -1
  714. package/dist/node_modules/@earendil-works/chord/dist/node/package.js +0 -1
  715. package/dist/node_modules/@earendil-works/chord/dist/node.js +0 -1
  716. package/dist/node_modules/@earendil-works/chord/dist/services/consumer.js +0 -1
  717. package/dist/node_modules/@earendil-works/chord/dist/services/errors.js +0 -1
  718. package/dist/node_modules/@earendil-works/chord/dist/services/handle.js +0 -1
  719. package/dist/node_modules/@earendil-works/chord/dist/services/instances.js +0 -1
  720. package/dist/node_modules/@earendil-works/chord/dist/services/loopback.js +0 -1
  721. package/dist/node_modules/@earendil-works/chord/dist/services/provider.js +0 -1
  722. package/dist/node_modules/@earendil-works/chord/dist/services/state-codec.js +0 -1
  723. package/dist/node_modules/@earendil-works/chord/dist/services/state-internals.js +0 -1
  724. package/dist/node_modules/@earendil-works/chord/dist/services/state.js +0 -1
  725. package/dist/node_modules/@earendil-works/chord/dist/services/wire.js +0 -1
  726. package/dist/node_modules/@earendil-works/chord/package.json +0 -62
  727. package/dist/node_modules/@earendil-works/chord/src/delta/README.md +0 -191
  728. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/assistant-message-frame.d.ts +0 -63
  729. package/dist/node_modules/@earendil-works/pi-client/CHANGELOG.md +0 -45
  730. package/dist/node_modules/@earendil-works/pi-client/LICENSE +0 -21
  731. package/dist/node_modules/@earendil-works/pi-client/README.md +0 -72
  732. package/dist/node_modules/@earendil-works/pi-client/dist/client.js +0 -1
  733. package/dist/node_modules/@earendil-works/pi-client/dist/connection.js +0 -1
  734. package/dist/node_modules/@earendil-works/pi-client/dist/errors.js +0 -1
  735. package/dist/node_modules/@earendil-works/pi-client/dist/index.js +0 -1
  736. package/dist/node_modules/@earendil-works/pi-client/dist/promise.js +0 -1
  737. package/dist/node_modules/@earendil-works/pi-client/dist/types.js +0 -0
  738. package/dist/node_modules/@earendil-works/pi-client/dist/unix.js +0 -1
  739. package/dist/node_modules/@earendil-works/pi-client/package.json +0 -46
  740. package/dist/node_modules/@earendil-works/pi-protocol/LICENSE +0 -21
  741. package/dist/node_modules/@earendil-works/pi-protocol/README.md +0 -41
  742. package/dist/node_modules/@earendil-works/pi-protocol/dist/cbor/decoder.js +0 -1
  743. package/dist/node_modules/@earendil-works/pi-protocol/dist/cbor/encoder.js +0 -1
  744. package/dist/node_modules/@earendil-works/pi-protocol/dist/cbor/index.js +0 -1
  745. package/dist/node_modules/@earendil-works/pi-protocol/dist/cbor/options.js +0 -1
  746. package/dist/node_modules/@earendil-works/pi-protocol/dist/codec.js +0 -1
  747. package/dist/node_modules/@earendil-works/pi-protocol/dist/framing.js +0 -1
  748. package/dist/node_modules/@earendil-works/pi-protocol/dist/index.js +0 -1
  749. package/dist/node_modules/@earendil-works/pi-protocol/dist/protocol.js +0 -1
  750. package/dist/node_modules/@earendil-works/pi-protocol/dist/schemas.js +0 -1
  751. package/dist/node_modules/@earendil-works/pi-protocol/package.json +0 -39
  752. package/dist/node_modules/@earendil-works/pi-server/CHANGELOG.md +0 -81
  753. package/dist/node_modules/@earendil-works/pi-server/LICENSE +0 -21
  754. package/dist/node_modules/@earendil-works/pi-server/README.md +0 -63
  755. package/dist/node_modules/@earendil-works/pi-server/dist/connection.js +0 -1
  756. package/dist/node_modules/@earendil-works/pi-server/dist/errors.js +0 -1
  757. package/dist/node_modules/@earendil-works/pi-server/dist/index.js +0 -1
  758. package/dist/node_modules/@earendil-works/pi-server/dist/listener.js +0 -0
  759. package/dist/node_modules/@earendil-works/pi-server/dist/server.js +0 -1
  760. package/dist/node_modules/@earendil-works/pi-server/dist/session-router.js +0 -1
  761. package/dist/node_modules/@earendil-works/pi-server/dist/testing/client.js +0 -1
  762. package/dist/node_modules/@earendil-works/pi-server/dist/testing/host.js +0 -1
  763. package/dist/node_modules/@earendil-works/pi-server/dist/testing/index.js +0 -1
  764. package/dist/node_modules/@earendil-works/pi-server/dist/testing/server.js +0 -1
  765. package/dist/node_modules/@earendil-works/pi-server/dist/transports/unix/address.js +0 -1
  766. package/dist/node_modules/@earendil-works/pi-server/dist/transports/unix/index.js +0 -1
  767. package/dist/node_modules/@earendil-works/pi-server/dist/transports/unix/listener.js +0 -1
  768. package/dist/node_modules/@earendil-works/pi-server/dist/transports/unix/preset.js +0 -1
  769. package/dist/node_modules/@earendil-works/pi-server/dist/transports/unix/types.js +0 -0
  770. package/dist/node_modules/@earendil-works/pi-server/dist/types.js +0 -0
  771. package/dist/node_modules/@earendil-works/pi-server/package.json +0 -45
  772. package/examples/plugins/pi-example-plugin/README.md +0 -38
  773. package/examples/plugins/pi-example-plugin/package.json +0 -10
  774. package/examples/plugins/pi-example-plugin/src/contract.ts +0 -13
  775. package/examples/plugins/pi-example-plugin/src/session.ts +0 -24
  776. package/examples/plugins/pi-example-plugin/src/tui.ts +0 -31
  777. /package/dist/node_modules/{@earendil-works/chord → @dalcode/dal-codeindex}/LICENSE +0 -0
  778. /package/dist/node_modules/@earendil-works/{chord/dist → pi-agent-core/dist/harness/session/testing}/types.js +0 -0
  779. /package/dist/node_modules/@earendil-works/{chord/dist/delta/draft.js → pi-agent-core/dist/harness/tools/tool-context.js} +0 -0
  780. /package/dist/node_modules/@earendil-works/{pi-client/dist/transport.js → pi-agent-core/dist/search/index.js} +0 -0
@@ -1,3 +1,3 @@
1
- var J=Object.defineProperty;var n=(e,t)=>J(e,"name",{value:t,configurable:!0});var F=Object.defineProperty,s=n((e,t)=>F(e,"name",{value:t,configurable:!0}),"r");import{existsSync as T,readFileSync as l}from"node:fs";import{join as d}from"node:path";import{declaredDataFormat as R,withFileLockSync as D,writeFileAtomicSync as _}from"@dalcode/dal-pi-kit";const c=1;function u(e){return d(e,"capabilities.json")}n(u,"m"),s(u,"statePath");function N(){return{formatVersion:c,disabled:[],declined:[],approved:[],installed:{}}}n(N,"v"),s(N,"emptyState");function f(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}n(f,"u"),s(f,"stringList");function p(e){try{const t=JSON.parse(l(u(e),"utf8"));return{...t,formatVersion:c,disabled:f(t.disabled),declined:f(t.declined),approved:f(t.approved),installed:t.installed&&typeof t.installed=="object"&&!Array.isArray(t.installed)?t.installed:{}}}catch{return N()}}n(p,"L"),s(p,"readState");function o(e,t){const a=u(e);return D(a,()=>{if(T(a))try{if(R(JSON.parse(l(a,"utf8")))>c)return p(e)}catch{}const i=p(e);return t(i),_(a,`${JSON.stringify(i,null,2)}
2
- `),i})}n(o,"l"),s(o,"updateState");function I(e,t){e.includes(t)||e.push(t)}n(I,"f"),s(I,"addUnique");function O(e,t,a){o(e,i=>{i.disabled=i.disabled.filter(r=>r!==t),a?I(i.disabled,t):i.declined=i.declined.filter(r=>r!==t)})}n(O,"U"),s(O,"markDisabled");function g(e,t){o(e,a=>I(a.declined,t))}n(g,"j"),s(g,"markDeclined");function v(e,t){o(e,a=>I(a.approved,t))}n(v,"J"),s(v,"markApproved");function k(e,t,a,i){o(e,r=>{r.installed[t]={kind:a,at:new Date().toISOString(),...i?{version:i}:{}}})}n(k,"h"),s(k,"markInstalled");function m(e){try{const t=JSON.parse(l(e,"utf8")).capabilities;return t&&typeof t=="object"&&!Array.isArray(t)?t:void 0}catch{return}}n(m,"w"),s(m,"readCapabilitiesSetting");function E(e,t,a=process.env,i=".dal"){const r=m(d(e,"settings.json"))??{},j=m(d(t,i,"settings.json"))??{},y={...r,...j},A=s((C,h)=>typeof y[C]=="boolean"?y[C]:h,"flag"),b=/^(0|off|false|no)$/i,L=/^(1|on|true|yes)$/i,w=a.DAL_CAPABILITIES?.trim()??"",S=a.DAL_CAPABILITIES_AUTO_INSTALL?.trim()??"";return{enabled:!b.test(w)&&A("enabled",!0),autoInstall:b.test(S)?!1:L.test(S)?!0:A("autoInstall",!0),allowInCI:L.test(S)||A("allowInCI",!1)}}n(E,"F"),s(E,"readSettings");function B(e,t){const a=d(e,"settings.json");D(a,()=>{let i={};T(a)&&(i=JSON.parse(l(a,"utf8")));const r=i.capabilities&&typeof i.capabilities=="object"&&!Array.isArray(i.capabilities)?i.capabilities:{};i.capabilities={...r,autoInstall:t},_(a,`${JSON.stringify(i,null,2)}
3
- `)})}n(B,"P"),s(B,"writeAutoInstall");const P=["GITHUB_ACTIONS","GITLAB_CI","BUILDKITE","JENKINS_URL","TF_BUILD","TEAMCITY_VERSION","CIRCLECI","DRONE","GITEA_ACTIONS","BITBUCKET_BUILD_NUMBER","CODEBUILD_BUILD_ID"];function U(e=process.env){const t=e.CI?.trim().toLowerCase();return t&&t!=="0"&&t!=="false"?!0:P.some(a=>!!e[a]?.trim())}n(U,"V"),s(U,"isCiLike");export{c as STATE_FORMAT,U as isCiLike,v as markApproved,g as markDeclined,O as markDisabled,k as markInstalled,E as readSettings,p as readState,u as statePath,o as updateState,B as writeAutoInstall};
1
+ var F=Object.defineProperty;var n=(e,t)=>F(e,"name",{value:t,configurable:!0});var P=Object.defineProperty,s=n((e,t)=>P(e,"name",{value:t,configurable:!0}),"r");import{existsSync as T,readFileSync as o}from"node:fs";import{join as d}from"node:path";import{declaredDataFormat as R,withFileLockSync as D,writeFileAtomicSync as _}from"@dalcode/dal-pi-kit";const c=1;function u(e){return d(e,"capabilities.json")}n(u,"m"),s(u,"statePath");function k(){return{formatVersion:c,disabled:[],declined:[],approved:[],installed:{}}}n(k,"_"),s(k,"emptyState");function f(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}n(f,"u"),s(f,"stringList");function p(e){try{const t=JSON.parse(o(u(e),"utf8"));return{...t,formatVersion:c,disabled:f(t.disabled),declined:f(t.declined),approved:f(t.approved),installed:t.installed&&typeof t.installed=="object"&&!Array.isArray(t.installed)?t.installed:{}}}catch{return k()}}n(p,"L"),s(p,"readState");function l(e,t){const a=u(e);return D(a,()=>{if(T(a))try{if(R(JSON.parse(o(a,"utf8")))>c)return p(e)}catch{}const i=p(e);return t(i),_(a,`${JSON.stringify(i,null,2)}
2
+ `),i})}n(l,"o"),s(l,"updateState");function I(e,t){e.includes(t)||e.push(t)}n(I,"f"),s(I,"addUnique");function N(e,t,a){l(e,i=>{i.disabled=i.disabled.filter(r=>r!==t),a?I(i.disabled,t):i.declined=i.declined.filter(r=>r!==t)})}n(N,"U"),s(N,"markDisabled");function O(e,t){l(e,a=>I(a.declined,t))}n(O,"j"),s(O,"markDeclined");function g(e,t){l(e,a=>I(a.approved,t))}n(g,"J"),s(g,"markApproved");function E(e,t,a,i){l(e,r=>{r.installed[t]={kind:a,at:new Date().toISOString(),...i?{version:i}:{}}})}n(E,"h"),s(E,"markInstalled");function U(e,t){l(e,a=>{delete a.installed[t]})}n(U,"F"),s(U,"markUninstalled");function S(e){try{const t=JSON.parse(o(e,"utf8")).capabilities;return t&&typeof t=="object"&&!Array.isArray(t)?t:void 0}catch{return}}n(S,"w"),s(S,"readCapabilitiesSetting");function v(e,t,a=process.env,i=".dal"){const r=S(d(e,"settings.json"))??{},w=S(d(t,i,"settings.json"))??{},y={...r,...w},A=s((C,J)=>typeof y[C]=="boolean"?y[C]:J,"flag"),b=/^(0|off|false|no)$/i,L=/^(1|on|true|yes)$/i,h=a.DAL_CAPABILITIES?.trim()??"",m=a.DAL_CAPABILITIES_AUTO_INSTALL?.trim()??"";return{enabled:!b.test(h)&&A("enabled",!0),autoInstall:b.test(m)?!1:L.test(m)?!0:A("autoInstall",!0),allowInCI:L.test(m)||A("allowInCI",!1)}}n(v,"P"),s(v,"readSettings");function B(e,t){const a=d(e,"settings.json");D(a,()=>{let i={};T(a)&&(i=JSON.parse(o(a,"utf8")));const r=i.capabilities&&typeof i.capabilities=="object"&&!Array.isArray(i.capabilities)?i.capabilities:{};i.capabilities={...r,autoInstall:t},_(a,`${JSON.stringify(i,null,2)}
3
+ `)})}n(B,"V"),s(B,"writeAutoInstall");const $=["GITHUB_ACTIONS","GITLAB_CI","BUILDKITE","JENKINS_URL","TF_BUILD","TEAMCITY_VERSION","CIRCLECI","DRONE","GITEA_ACTIONS","BITBUCKET_BUILD_NUMBER","CODEBUILD_BUILD_ID"];function j(e=process.env){const t=e.CI?.trim().toLowerCase();return t&&t!=="0"&&t!=="false"?!0:$.some(a=>!!e[a]?.trim())}n(j,"$"),s(j,"isCiLike");export{c as STATE_FORMAT,j as isCiLike,g as markApproved,O as markDeclined,N as markDisabled,E as markInstalled,U as markUninstalled,v as readSettings,p as readState,u as statePath,l as updateState,B as writeAutoInstall};
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@dalcode/dal-codeindex",
3
+ "version": "1.0.46",
4
+ "private": true,
5
+ "description": "Code index: a persistent local symbol and reference index (tree-sitter WebAssembly grammars) the model queries to find definitions, callers, file outlines and related files without repeated grep.",
6
+ "type": "module",
7
+ "main": "./src/index.js",
8
+ "exports": {
9
+ ".": "./src/index.js",
10
+ "./package.json": "./package.json"
11
+ },
12
+ "files": [
13
+ "src"
14
+ ],
15
+ "pi": {
16
+ "extensions": [
17
+ "./src/index.js"
18
+ ]
19
+ },
20
+ "dependencies": {
21
+ "@dalcode/dal-pi-kit": "1.0.46",
22
+ "@vscode/tree-sitter-wasm": "0.3.1",
23
+ "ignore": "7.0.8",
24
+ "typebox": "1.3.27"
25
+ },
26
+ "peerDependencies": {
27
+ "@earendil-works/pi-coding-agent": "^1.0.9"
28
+ },
29
+ "peerDependenciesMeta": {
30
+ "@earendil-works/pi-coding-agent": {
31
+ "optional": false
32
+ }
33
+ }
34
+ }
@@ -0,0 +1,3 @@
1
+ var J=Object.defineProperty;var d=(r,t)=>J(r,"name",{value:t,configurable:!0});var U=Object.defineProperty,m=d((r,t)=>U(r,"name",{value:t,configurable:!0}),"u");import{readFileSync as V}from"node:fs";import{createRequire as X}from"node:module";import{dirname as Y,join as L}from"node:path";import{CONTAINER_KINDS as D}from"./languages.js";const Z=2e4,ee=200,F=160,j=X(import.meta.url);let x,C;const M=new Map,R=new Map;let S;function P(){return Y(j.resolve("@vscode/tree-sitter-wasm/wasm/tree-sitter.js"))}d(P,"z"),m(P,"wasmDirectory");async function W(){if(x)return x;const r=P(),t=j("@vscode/tree-sitter-wasm/wasm/tree-sitter.js");return C??=t.Parser.init({locateFile:m(a=>L(r,a),"locateFile")}),await C,x={module:t,wasmDir:r},x}d(W,"U"),m(W,"ensureRuntime");async function Q(r){const{module:t,wasmDir:a}=await W();let o=M.get(r.grammar);o||(o=await t.Language.load(V(L(a,`tree-sitter-${r.grammar}.wasm`))),M.set(r.grammar,o));const p=`${r.grammar}\0${r.query}`;let l=R.get(p);return l||(l=new t.Query(o,r.query),R.set(p,l)),S??=new t.Parser,S.setLanguage(o),{parser:S,language:o,query:l}}d(Q,"B"),m(Q,"load");function T(r,t){const a=r.indexOf(`
2
+ `),o=(a===-1?r:r.slice(0,a)).trim();return o.length>t?`${o.slice(0,t-1)}\u2026`:o}d(T,"J"),m(T,"firstLine");function N(r){for(const t of r.split(`
3
+ `)){const a=t.replace(/^\s*(\/\*\*?|\*\/|\*|\/\/\/?|#+|--)\s?/,"").replace(/\*\/\s*$/,"").trim();if(a&&!a.startsWith("@")&&!/^[-=*#/]+$/.test(a))return a.length>F?`${a.slice(0,F-1)}\u2026`:a}}d(N,"O"),m(N,"commentText");const te=new Set(["export_statement","decorated_definition","ambient_declaration","template_declaration"]);function A(r){let t=r;for(;t.parent&&te.has(t.parent.type);)t=t.parent;t.type==="variable_declarator"&&t.parent&&(t=t.parent);const a=t.previousNamedSibling;if(a&&/comment/.test(a.type)&&t.startPosition.row-a.endPosition.row<=1)return N(a.text);const o=r.childForFieldName("body")?.firstNamedChild;if(o?.type==="expression_statement"&&o.firstNamedChild?.type==="string")return N(o.firstNamedChild.text.replace(/^[rubf]*("""|'''|"|')|("""|'''|"|')$/gi,""))}d(A,"Y"),m(A,"documentation");const E={constant:0,variable:0,field:1,declaration:1};function O(r){const t=/^(.*?)(?:::|\.)([^:.]+)$/.exec(r);return t?{name:t[2],qualifier:t[1]}:{name:r}}d(O,"A"),m(O,"splitQualified");async function K(r,t){const{parser:a,query:o}=await Q(t),p=a.parse(r);if(!p)return{definitions:[],references:[]};try{const l=new Map,b=[],w=[];for(const e of o.matches(p.rootNode)){let n,s,k;for(const i of e.captures)i.name==="name"?s=i.node:i.name==="receiver"?k=i.node.text:i.name==="scope"?n={kind:"scope",node:i.node,role:"scope"}:i.name.startsWith("def.")?n={kind:i.name.slice(4),node:i.node,role:"def"}:i.name.startsWith("ref.")&&(n={kind:i.name.slice(4),node:i.node,role:"ref"});if(!n||!s)continue;const h=s.text;if(!h||h.length>200)continue;if(n.role==="ref"){if(w.length>=Z)continue;const{name:i}=O(h);w.push({name:i,kind:n.kind,start:n.node.startIndex,nameStart:s.startIndex,line:s.startPosition.row+1,column:s.startPosition.column+1});continue}const{name:G,qualifier:H}=O(h.replace(/^["'`]|["'`]$/g,"")),f={name:n.role==="scope"?h.replace(/<.*$/s,""):G,kind:n.kind,line:n.node.startPosition.row+1,endLine:n.node.endPosition.row+1,column:s.startPosition.column+1,container:k??H,parent:-1,signature:T(n.node.text,ee),start:n.node.startIndex,end:n.node.endIndex,nameStart:s.startIndex,scopeOnly:n.role==="scope"};if(f.scopeOnly){b.push(f);continue}const _=l.get(f.nameStart);_&&(E[_.kind]??2)>=(E[f.kind]??2)||(f.doc=A(n.node),l.set(f.nameStart,f))}const z=[...l.values(),...b].sort((e,n)=>e.start-n.start||n.end-e.end),$=[],v=new Map,u=[];for(const e of z){for(;u.length>0&&u[u.length-1].end<=e.start;)u.pop();const n=u[u.length-1];if(n){e.container??=n.name;const s=[...u].reverse().find(k=>!k.scopeOnly);s&&(e.parent=v.get(s)??-1),e.kind==="function"&&(n.scopeOnly||["class","interface","struct"].includes(n.kind))&&(e.kind="method")}(D.has(e.kind)||e.scopeOnly)&&u.push(e),!e.scopeOnly&&(v.set(e,$.length),$.push({name:e.name,kind:e.kind,line:e.line,endLine:e.endLine,column:e.column,container:e.container,parent:e.parent,signature:e.signature,doc:e.doc}))}const B=new Set(l.keys()),y=[...l.values()].filter(e=>D.has(e.kind)).sort((e,n)=>e.start-n.start||n.end-e.end);w.sort((e,n)=>e.start-n.start);const q=[],I=new Set,c=[];let g=0;for(const e of w){if(B.has(e.nameStart))continue;for(;g<y.length&&y[g].start<=e.start;){for(;c.length>0&&c[c.length-1].end<=y[g].start;)c.pop();c.push(y[g]),g+=1}for(;c.length>0&&c[c.length-1].end<=e.start;)c.pop();const n=`${e.name}\0${e.line}\0${e.kind}`;if(I.has(n))continue;I.add(n);const s=c[c.length-1];q.push({name:e.name,kind:e.kind,line:e.line,column:e.column,caller:s?v.get(s)??-1:-1})}return{definitions:$,references:q}}finally{p.delete()}}d(K,"ie"),m(K,"extract");export{K as extract,P as wasmDirectory};
@@ -0,0 +1,11 @@
1
+ var N=Object.defineProperty;var h=(t,r)=>N(t,"name",{value:r,configurable:!0});var z=Object.defineProperty,E=h((t,r)=>z(t,"name",{value:r,configurable:!0}),"h");import{readFileSync as R}from"node:fs";import{join as d,relative as q}from"node:path";import{t as l}from"@dalcode/dal-pi-kit";function i(t,r){const u=q(t.cwd,d(t.root,r));return u===""?".":u}h(i,"u"),E(i,"shownPath");function f(t){return t.toLocaleString("en-US")}h(f,"g"),E(f,"count");function L(t,r){const u=r&&!r.done?r.total||t?.total||0:t?.total??0,a=r&&!r.done?r.pending:t?.pending??0,n=t?.note??r?.note;return!t||t.lastScan===0&&u===0?{complete:!1,text:l("[\u7D22\u5F15\u6B63\u5728\u5EFA\u7ACB\uFF0C\u8FD8\u6CA1\u6709\u7ED3\u679C\uFF1B\u6CA1\u627E\u5230\u4E0D\u4EE3\u8868\u4E0D\u5B58\u5728\uFF0C\u53EF\u7528 grep \u8865\u5145]")}:a>0?{complete:!1,text:l("[\u7D22\u5F15\u5EFA\u7ACB\u4E2D\uFF1A\u5DF2\u5B8C\u6210 {done}/{total} \u4E2A\u6587\u4EF6\uFF0C\u7ED3\u679C\u53EF\u80FD\u4E0D\u5168\uFF1B\u6CA1\u627E\u5230\u4E0D\u4EE3\u8868\u4E0D\u5B58\u5728\uFF0C\u53EF\u7528 grep \u8865\u5145]").replace("{done}",f(Math.max(0,u-a))).replace("{total}",f(u))}:n?.startsWith("max-files:")?{complete:!1,text:l("[\u7D22\u5F15\u53EA\u8986\u76D6 {total} \u4E2A\u6587\u4EF6\uFF0C\u53E6\u6709 {left} \u4E2A\u8D85\u51FA\u6587\u4EF6\u6570\u4E0A\u9650\u672A\u7D22\u5F15\uFF1B\u6CA1\u627E\u5230\u53EF\u7528 grep \u8865\u5145]").replace("{total}",f(u)).replace("{left}",f(Number(n.slice(10))))}:n==="max-disk"?{complete:!1,text:l("[\u7D22\u5F15\u5DF2\u8FBE\u78C1\u76D8\u4E0A\u9650\uFF0C\u90E8\u5206\u6587\u4EF6\u672A\u7D22\u5F15\uFF1B\u6CA1\u627E\u5230\u53EF\u7528 grep \u8865\u5145]")}:{complete:!0,text:l("[\u7D22\u5F15\u5B8C\u6574\uFF1A{total} \u4E2A\u6587\u4EF6]").replace("{total}",f(u))}}h(L,"N"),E(L,"statusLine");function C(t){return t.container?`${t.container}.${t.name}`:t.name}h(C,"m"),E(C,"qualified");function A(t,r,u){let a;try{a=R(d(t.root,r.path),"utf8")}catch{return}const n=a.split(`
2
+ `),e=Math.max(1,r.line),o=Math.min(n.length,r.endLine);if(e>n.length)return;const c=Math.min(o,e+u-1),F=n.slice(e-1,c).map((s,p)=>`${String(e+p).padStart(5)} ${s}`);return c<o&&F.push(l(" \u2026 \u5171 {lines} \u884C\uFF0C\u5176\u4F59\u7528 read \u8BFB {path} \u7B2C {from}-{to} \u884C").replace("{lines}",String(o-e+1)).replace("{path}",i(t,r.path)).replace("{from}",String(c+1)).replace("{to}",String(o))),F.join(`
3
+ `)}h(A,"w"),E(A,"codeLines");const P=new Set(["class","interface","struct","enum","module","type"]),I=60,$=40;function S(t,r,u,a,n){const e=[],o=l("{symbol} \u7684\u5B9A\u4E49\uFF08{count} \u5904\uFF09\uFF1A").replace("{symbol}",r).replace("{count}",String(n.total??u.length));e.push(n.caseInsensitive?`${o} ${l("\uFF08\u6CA1\u6709\u5927\u5C0F\u5199\u5B8C\u5168\u4E00\u81F4\u7684\uFF0C\u4EE5\u4E0B\u662F\u5FFD\u7565\u5927\u5C0F\u5199\u7684\u5339\u914D\uFF09")}`:o);const c=u.length<=3;for(const F of u){if(e.push(`${i(t,F.path)}:${F.line}-${F.endLine} ${F.kind} ${C(F)}`),F.doc&&e.push(` // ${F.doc}`),!c){e.push(` ${F.signature}`);continue}if(P.has(F.kind)&&F.endLine-F.line>12){e.push(A(t,{...F,endLine:F.line},1)??` ${F.signature}`);const s=a(F);if(s.length>0){e.push(l(" \u6210\u5458\uFF1A"));for(const p of s.slice(0,$))e.push(` L${p.line} ${p.kind} ${p.signature}`);s.length>$&&e.push(l(" \u2026 \u53E6\u6709 {count} \u4E2A\uFF0C\u7528 outline \u67E5\u770B\u5168\u90E8").replace("{count}",String(s.length-$)))}}else e.push(A(t,F,I)??` ${F.signature}`)}return(n.total??u.length)>u.length&&e.push(l("\u2026 \u53E6\u6709 {count} \u5904\uFF0C\u7528 path \u9650\u5B9A\u76EE\u5F55\u6216\u5199\u6210 \u5BB9\u5668.\u540D\u5B57 \u7F29\u5C0F\u8303\u56F4").replace("{count}",String((n.total??u.length)-u.length))),e.join(`
4
+ `)}h(S,"v"),E(S,"formatDefinitions");function y(t,r,u){const a=[l("\u6CA1\u6709\u627E\u5230\u540D\u4E3A {symbol} \u7684\u5B9A\u4E49\u3002").replace("{symbol}",r)];if(u.length>0){a.push(l("\u76F8\u8FD1\u7684\u7B26\u53F7\uFF1A"));for(const n of u)a.push(` ${i(t,n.path)}:${n.line} ${n.kind} ${C(n)}`)}return a.join(`
5
+ `)}h(y,"A"),E(y,"formatNotFound");function B(t,r){if(r.length<=1)return;const u=r.slice(0,6).map(a=>`${i(t,a.path)}:${a.line} ${C(a)}`).join("; ");return l("\u6CE8\u610F\uFF1A\u540C\u540D\u5B9A\u4E49\u6709 {count} \u5904\uFF08{list}\uFF09\uFF0C\u6309\u540D\u5B57\u5339\u914D\u4F1A\u6DF7\u5165\u5B83\u4EEC\u7684\u5F15\u7528\uFF1B\u7528 path \u7F29\u5C0F\u8303\u56F4\uFF0C\u6216\u7528 lsp \u5BF9\u5177\u4F53\u4F4D\u7F6E\u7CBE\u786E\u6838\u5BF9\u3002").replace("{count}",String(r.length)).replace("{list}",u)}h(B,"d"),E(B,"sameNameNote");const O=40,m=8;function b(t,r,u,a){const n=new Map;for(const F of u.references){const s=n.get(F.path)??[];s.push(F),n.set(F.path,s)}const e=[l("{symbol} \u7684\u5F15\u7528\uFF1A\u5171 {total} \u5904\uFF0C{files} \u4E2A\u6587\u4EF6").replace("{symbol}",r).replace("{total}",f(u.total)).replace("{files}",f(n.size)+(u.total>u.references.length?"+":""))],o=B(t,a);o&&e.push(o);let c=0;for(const[F,s]of n){if(c>=O)break;c+=1,e.push(i(t,F));for(const p of s.slice(0,m)){const w=p.caller?` ${l("\u5728")} ${C({name:p.caller,container:p.callerContainer})}`:"";e.push(` L${p.line} ${p.kind}${w}`)}s.length>m&&e.push(l(" \u2026 \u672C\u6587\u4EF6\u53E6\u6709 {count} \u5904").replace("{count}",String(s.length-m)))}return(n.size>c||u.total>u.references.length)&&e.push(l("\u2026 \u7ED3\u679C\u8FC7\u591A\u5DF2\u622A\u65AD\uFF1B\u7528 path \u9650\u5B9A\u76EE\u5F55\u7F29\u5C0F\u8303\u56F4")),u.total===0&&e.push(l("\uFF08\u7D22\u5F15\u91CC\u6CA1\u6709\u5BF9\u5B83\u7684\u5F15\u7528\uFF09")),e.join(`
6
+ `)}h(b,"X"),E(b,"formatReferences");const g=80;function j(t,r,u,a){const n=new Map;for(const F of u.references){const s=`${F.path}\0${F.caller??""}\0${F.callerLine??""}`;let p=n.get(s);p||(p={path:F.path,caller:F.caller,container:F.callerContainer,callerLine:F.callerLine,lines:[]},n.set(s,p)),p.lines.push(F.line)}const e=[l("{symbol} \u7684\u8C03\u7528\u65B9\uFF1A\u5171 {total} \u5904\u8C03\u7528\uFF0C\u6765\u81EA {callers} \u4E2A\u51FD\u6570/\u4F4D\u7F6E").replace("{symbol}",r).replace("{total}",f(u.total)).replace("{callers}",f(n.size)+(u.total>u.references.length?"+":""))],o=B(t,a);o&&e.push(o);let c=0;for(const F of n.values()){if(c>=g)break;c+=1;const s=F.caller?`${i(t,F.path)}:${F.callerLine} ${C({name:F.caller,container:F.container})}`:`${i(t,F.path)} ${l("\uFF08\u9876\u5C42\u4EE3\u7801\uFF09")}`;e.push(`${s} ${l("\u8C03\u7528\u4E8E")} L${F.lines.slice(0,6).join(", L")}${F.lines.length>6?" \u2026":""}`)}return(n.size>c||u.total>u.references.length)&&e.push(l("\u2026 \u7ED3\u679C\u8FC7\u591A\u5DF2\u622A\u65AD\uFF1B\u7528 path \u9650\u5B9A\u76EE\u5F55\u7F29\u5C0F\u8303\u56F4")),u.total===0&&e.push(l("\uFF08\u7D22\u5F15\u91CC\u6CA1\u6709\u5BF9\u5B83\u7684\u8C03\u7528\uFF09")),e.join(`
7
+ `)}h(j,"P"),E(j,"formatCallers");function x(t,r,u,a){const n=[l("{symbol} \u7684\u5B9E\u73B0\u548C\u5B50\u7C7B\uFF08\u76F4\u63A5\u7EE7\u627F/\u5B9E\u73B0\uFF0C\u5171 {total} \u5904\uFF09\uFF1A").replace("{symbol}",r).replace("{total}",f(u.total))],e=B(t,a);e&&n.push(e);for(const o of u.references.slice(0,g)){const c=o.caller?`${i(t,o.path)}:${o.callerLine} ${C({name:o.caller,container:o.callerContainer})}`:`${i(t,o.path)}:${o.line}`;n.push(`${c} ${o.kind}`)}return u.total>Math.min(u.references.length,g)&&n.push(l("\u2026 \u7ED3\u679C\u8FC7\u591A\u5DF2\u622A\u65AD\uFF1B\u7528 path \u9650\u5B9A\u76EE\u5F55\u7F29\u5C0F\u8303\u56F4")),u.total===0&&n.push(l("\uFF08\u7D22\u5F15\u91CC\u6CA1\u6709\u76F4\u63A5\u7EE7\u627F\u6216\u5B9E\u73B0\u5B83\u7684\u7C7B\u578B\uFF1BGo \u7684\u63A5\u53E3\u662F\u9690\u5F0F\u5B9E\u73B0\u7684\uFF0C\u6539\u7528 lsp implementation\uFF09")),n.join(`
8
+ `)}h(x,"q"),E(x,"formatImplementations");const D=300;function k(t,r,u,a,n){const e=[l("{path}\uFF08{language}\uFF0C{count} \u4E2A\u7B26\u53F7\uFF09\uFF1A").replace("{path}",i(t,r)).replace("{language}",u??"?").replace("{count}",String(a.length))];for(const o of a.slice(0,D)){const c=" ".repeat(Math.min(6,n.get(o.id)??0)),F=o.doc?` // ${o.doc}`:"";e.push(`${c}L${o.line}-${o.endLine} ${o.kind} ${o.signature}${F}`)}return a.length>D&&e.push(l("\u2026 \u53E6\u6709 {count} \u4E2A\u7B26\u53F7").replace("{count}",String(a.length-D))),a.length===0&&e.push(l("\uFF08\u6CA1\u6709\u63D0\u53D6\u5230\u7B26\u53F7\uFF09")),e.join(`
9
+ `)}h(k,"z"),E(k,"formatOutline");function v(t,r,u){const a=[l("\u4E0E {path} \u76F8\u5173\u7684\u6587\u4EF6\uFF1A").replace("{path}",i(t,r))];for(const n of u){const e=n.via.length>0?`\uFF1A${n.via.join(", ")}`:"",o=n.direction==="test"?l("\u6D4B\u8BD5"):n.direction==="uses"?l("\u5B83\u7528\u5230\u7684"):n.direction==="used-by"?l("\u7528\u5230\u5B83\u7684"):l("\u4E92\u76F8\u5F15\u7528");a.push(`${i(t,n.path)} (${o}${e})`)}return u.length===0&&a.push(l("\uFF08\u7D22\u5F15\u91CC\u6CA1\u6709\u627E\u5230\u901A\u8FC7\u7B26\u53F7\u5173\u8054\u7684\u6587\u4EF6\uFF09")),a.join(`
10
+ `)}h(v,"B"),E(v,"formatRelated");function M(t,r,u,a,n){const e=[l("\u4E0E\u300C{query}\u300D\u76F8\u5173\u7684\u7B26\u53F7\uFF1A").replace("{query}",r)];for(const o of u){const c=o.doc?` // ${o.doc}`:` ${o.signature}`;e.push(`${i(t,o.path)}:${o.line} ${o.kind} ${C(o)}${c}`)}if(u.length===0&&e.push(l("\uFF08\u6CA1\u6709\u5339\u914D\u7684\u7B26\u53F7\uFF1B\u8BD5\u8BD5\u6362\u6210\u4EE3\u7801\u91CC\u53EF\u80FD\u7528\u7684\u82F1\u6587\u5355\u8BCD\uFF09")),a.length>0){e.push(l("\u8DEF\u5F84\u5339\u914D\u7684\u6587\u4EF6\uFF1A"));for(const o of a)e.push(` ${i(t,o)}`)}if(n?.files.length){e.push(l("\u8BED\u4E49\u76F8\u8FD1\u7684\u6587\u4EF6\uFF08\u672C\u673A\u6A21\u578B\uFF09\uFF1A"));for(const o of n.files)e.push(` ${i(t,o.path)} ${o.score.toFixed(2)}`)}return n?.note&&e.push(n.note),e.join(`
11
+ `)}h(M,"H"),E(M,"formatSearch");export{j as formatCallers,S as formatDefinitions,x as formatImplementations,y as formatNotFound,k as formatOutline,b as formatReferences,v as formatRelated,M as formatSearch,i as shownPath,L as statusLine};
@@ -0,0 +1,4 @@
1
+ var uu=Object.defineProperty;var m=(e,r)=>uu(e,"name",{value:r,configurable:!0});var eu=Object.defineProperty,E=m((e,r)=>eu(e,"name",{value:r,configurable:!0}),"u");import{existsSync as tu,statSync as nu}from"node:fs";import{homedir as ou}from"node:os";import{isAbsolute as L,join as j,relative as ru,resolve as T,sep as iu}from"node:path";import{isSmallProject as su,t as n}from"@dalcode/dal-pi-kit";import{getAgentDir as A}from"@earendil-works/pi-coding-agent";import{Type as B}from"typebox";import{formatCallers as au,formatDefinitions as Fu,formatImplementations as cu,formatNotFound as lu,formatOutline as Eu,formatReferences as du,formatRelated as fu,formatSearch as mu,shownPath as _,statusLine as pu}from"./format.js";import{languageForPath as N}from"./languages.js";import{locateProject as w,markUsed as Du,pruneIndexes as Cu,readSettings as h}from"./project.js";import{childDefinitions as Bu,embeddedFileCount as q,fileLanguage as Au,fileOutline as hu,findDefinitions as b,findReferences as M,indexCounts as gu,outlineDepths as xu,relatedFiles as yu,searchPaths as Su,searchSymbols as U,semanticFiles as wu}from"./query.js";import{embedQuery as bu,lastRequested as vu,onProgress as _u,openIndex as I,progressOf as R,requestFiles as Pu,requestSync as k,semanticPendingOf as W,shutdownRuntime as Iu}from"./runtime.js";import{installSemantic as Ru,MODEL_ID as O,semanticDir as G,semanticRuntimePresent as ku}from"./semantic.js";import{storeBytes as Ou}from"./store.js";import{extract as $u}from"./extract.js";import{languageForPath as Lu}from"./languages.js";import{locateProject as ju,readSettings as Tu}from"./project.js";import{findDefinitions as Nu,findReferences as qu,relatedFiles as Mu,searchSymbols as Uu}from"./query.js";import{requestSync as Wu,shutdownRuntime as Gu}from"./runtime.js";import{openStore as Hu}from"./store.js";const Ju=["definition","references","callers","implementations","outline","related","search","status"],Qu=B.Object({action:B.Union(Ju.map(e=>B.Literal(e)),{description:n('definition\uFF08\u6309\u540D\u5B57\u627E\u5B9A\u4E49\uFF0C\u5C11\u91CF\u7ED3\u679C\u65F6\u76F4\u63A5\u9644\u4E0A\u4EE3\u7801\uFF09\u3001references\uFF08\u5168\u90E8\u5F15\u7528\uFF09\u3001callers\uFF08\u8C03\u7528\u65B9\uFF0C\u6309\u6240\u5728\u51FD\u6570\u5F52\u7EC4\uFF09\u3001implementations\uFF08\u76F4\u63A5\u7EE7\u627F\u6216\u5B9E\u73B0\u67D0\u4E2A\u7C7B/\u63A5\u53E3\u7684\u7C7B\u578B\uFF09\u3001outline\uFF08\u6587\u4EF6\u5927\u7EB2\uFF09\u3001related\uFF08\u4E0E\u67D0\u6587\u4EF6\u901A\u8FC7\u7B26\u53F7\u5173\u8054\u7684\u6587\u4EF6\u548C\u6D4B\u8BD5\uFF09\u3001search\uFF08\u6309\u529F\u80FD\u5173\u952E\u8BCD\u627E\u7B26\u53F7\uFF0C\u5982 "session restore"\uFF09\u3001status\uFF08\u7D22\u5F15\u72B6\u6001\uFF09')}),symbol:B.Optional(B.String({description:n("\u7B26\u53F7\u540D\uFF0C\u5982 openSession\u3001SessionService.openSession\uFF1Bdefinition/references/callers/implementations \u9700\u8981")})),query:B.Optional(B.String({description:n("search \u7684\u5173\u952E\u8BCD\uFF0C\u7528\u4EE3\u7801\u91CC\u53EF\u80FD\u51FA\u73B0\u7684\u82F1\u6587\u5355\u8BCD")})),path:B.Optional(B.String({description:n("outline/related \u7684\u6587\u4EF6\uFF1B\u5176\u4ED6\u67E5\u8BE2\u91CC\u7528\u6765\u9650\u5B9A\u76EE\u5F55\u6216\u6587\u4EF6\uFF0C\u7F29\u5C0F\u540C\u540D\u7B26\u53F7\u7684\u8303\u56F4")})),kind:B.Optional(B.String({description:n("\u53EF\u9009\u8FC7\u6EE4\uFF1Adefinition \u7684\u7B26\u53F7\u79CD\u7C7B\uFF08class\u3001function\u3001method\u3001interface\u2026\uFF09\uFF0Creferences \u7684\u5F15\u7528\u79CD\u7C7B\uFF08call\u3001new\u3001type\u3001import\u3001extends\uFF09")}))});function x(e,r){return{content:[{type:"text",text:e}],details:r}}m(x,"I"),E(x,"textResult");const Xu=15e3,zu=3e3;function H(e,r){const t=r.startsWith("@")?r.slice(1):r;return t==="~"||t.startsWith("~/")?T(ou(),t.slice(2)):L(t)?t:T(e,t)}m(H,"ve"),E(H,"resolvePathArg");function v(e,r,t){const u=ru(e.root,H(r,t.trim()));if(!(u.startsWith("..")||L(u)))return u.split(iu).join("/")}m(v,"E"),E(v,"rootRelative");function J(e,r){return new Promise(t=>{const u=setTimeout(t,r);u.unref?.(),e.then(()=>{clearTimeout(u),t()})})}m(J,"Ae"),E(J,"waitAtMost");function y(e,r){if(!r.semantic)return;const t=G(e);return ku(t)?t:void 0}m(y,"C"),E(y,"activeSemanticDir");async function Q(e){const r=A(),t=h(r);if(!t.enabled)return{error:n("\u4EE3\u7801\u7D22\u5F15\u5DF2\u5173\u95ED\uFF08\u8BBE\u7F6E dalCodeIndex.enabled \u4E3A false\uFF0C\u6216 DAL_CODEINDEX=off\uFF09\u3002\u6539\u7528 grep/find\u3002")};const u=w(e,r);if(!u)return{error:n("\u5F53\u524D\u76EE\u5F55\u4E0D\u662F\u4E00\u4E2A\u9879\u76EE\uFF08\u4E3B\u76EE\u5F55\u6216\u7CFB\u7EDF\u6839\u76EE\u5F55\uFF09\uFF0C\u4E0D\u5EFA\u7ACB\u4EE3\u7801\u7D22\u5F15\u3002\u6539\u7528 grep/find\u3002")};const a=vu(u.root);if(a===void 0||Date.now()-a>Xu){const l=I(u),s=k(u,t,e,y(r,t));l?.state?.complete&&await J(s,zu)}return{location:u,opened:I(u)}}m(Q,"Oe"),E(Q,"prepare");async function $(e,r){const t=await Q(r);if("error"in t)return x(t.error,{ok:!1});const{location:u,opened:a}=t,l=pu(a?.state,R(u.root)),s={ok:!0,action:e.action,complete:l.complete};if(!a)return x(l.text,{...s,ok:!1});const o={store:a.store,rootId:a.rootId},i={cwd:r,root:u.root},F=e.symbol?.trim(),D=e.kind?.trim()||void 0;let d;if(e.path?.trim()&&e.action!=="outline"&&e.action!=="related"&&(d=v(u,r,e.path),d===void 0))return x(n("code_index: path \u4E0D\u5728\u5F53\u524D\u9879\u76EE\u91CC\u3002"),{...s,ok:!1});const p=E(c=>x(`${l.text}
2
+ ${c}`,s),"reply");switch(e.action){case"status":{const c=gu(o),f=a.state;return p([n("\u7D22\u5F15\u76EE\u5F55\uFF1A{dir}").replace("{dir}",u.indexDir),n("\u9879\u76EE\u6839\u76EE\u5F55\uFF1A{root}").replace("{root}",u.root),n("\u5DF2\u7D22\u5F15 {files} \u4E2A\u6587\u4EF6\u3001{defs} \u4E2A\u5B9A\u4E49\uFF1B\u5360\u7528 {mb} MB").replace("{files}",c.files.toLocaleString("en-US")).replace("{defs}",c.definitions.toLocaleString("en-US")).replace("{mb}",(Ou(u.dbPath)/1024/1024).toFixed(1)),f?.lastScan?n("\u4E0A\u6B21\u5B8C\u6574\u626B\u63CF\uFF1A{time}").replace("{time}",new Date(f.lastScan).toLocaleString()):"",R(u.root)?.error?`${n("\u4E0A\u6B21\u51FA\u9519\uFF1A")}${R(u.root)?.error}`:"",X(u,o)].filter(Boolean).join(`
3
+ `))}case"definition":{if(!F)throw new Error(n("code_index: definition \u9700\u8981 symbol\u3002"));const c=b(o,{symbol:F,kind:D,pathPrefix:d},20);if(c.definitions.length===0)return p(lu(i,F,U(o,F,8,d)));const f=b(o,{symbol:F,kind:D,pathPrefix:d},2e3).definitions.length;return p(Fu(i,F,c.definitions,C=>Bu(o,C),{caseInsensitive:c.caseInsensitive,total:f}))}case"implementations":{if(!F)throw new Error(n("code_index: implementations \u9700\u8981 symbol\u3002"));const c=M(o,{symbol:F,kinds:["extends","implements"],pathPrefix:d});return s.total=c.total,p(cu(i,F,c,b(o,{symbol:F},50).definitions))}case"references":case"callers":{if(!F)throw new Error(n("code_index: references \u548C callers \u9700\u8981 symbol\u3002"));const c=e.action==="callers"?["call","new"]:D?[D]:void 0,f=M(o,{symbol:F,kinds:c,pathPrefix:d}),C=b(o,{symbol:F},50).definitions;return s.total=f.total,p(e.action==="callers"?au(i,F,f,C):du(i,F,f,C))}case"outline":case"related":{if(!e.path?.trim())throw new Error(n("code_index: outline \u548C related \u9700\u8981 path\uFF08\u4E00\u4E2A\u6E90\u6587\u4EF6\uFF09\u3002"));const c=v(u,r,e.path);if(c===void 0)return x(n("code_index: path \u4E0D\u5728\u5F53\u524D\u9879\u76EE\u91CC\u3002"),{...s,ok:!1});const f=j(u.root,c);if(!tu(f)||!nu(f).isFile())return p(n("code_index: \u6587\u4EF6\u4E0D\u5B58\u5728\uFF1A{path}").replace("{path}",_(i,c)));if(!N(c))return p(n("code_index: \u4E0D\u652F\u6301\u8FD9\u79CD\u6587\u4EF6\u7C7B\u578B\uFF08{path}\uFF09\uFF0C\u6539\u7528 read\u3002").replace("{path}",_(i,c)));if(e.action==="outline"){const S=hu(o,c);return p(S?Eu(i,c,Au(o,c),S,xu(S,o)):n("code_index: {path} \u8FD8\u6CA1\u6709\u7D22\u5F15\uFF08\u88AB\u5FFD\u7565\u3001\u8FC7\u5927\uFF0C\u6216\u7D22\u5F15\u5C1A\u672A\u5B8C\u6210\uFF09\uFF1B\u6539\u7528 read\u3002").replace("{path}",_(i,c)))}const C=yu(o,c,15);return p(C?fu(i,c,C):n("code_index: {path} \u8FD8\u6CA1\u6709\u7D22\u5F15\uFF08\u88AB\u5FFD\u7565\u3001\u8FC7\u5927\uFF0C\u6216\u7D22\u5F15\u5C1A\u672A\u5B8C\u6210\uFF09\u3002").replace("{path}",_(i,c)))}case"search":{const c=(e.query??F??"").trim();if(!c)throw new Error(n("code_index: search \u9700\u8981 query\u3002"));let f=U(o,c,25,d);const C=await z(u,o,c,d);if(C?.files.length){const S=new Map(C.files.map((g,P)=>[g.path,1+.5/(P+1)]));f=f.map(g=>({...g,score:g.score*(S.get(g.path)??1)})).sort((g,P)=>P.score-g.score),s.semantic=!0}return p(mu(i,c,f,Su(o,c,8),C))}}}m($,"W"),E($,"runQuery");function X(e,r){const t=A(),u=h(t);return u.semantic?y(t,u)?n("\u8BED\u4E49\u68C0\u7D22\uFF1A\u5DF2\u5D4C\u5165 {files} \u4E2A\u6587\u4EF6\uFF0C\u8FD8\u5269 {left} \u4E2A").replace("{files}",String(q(r,O))).replace("{left}",String(W(e.root)??0)):n("\u8BED\u4E49\u68C0\u7D22\uFF1A\u5DF2\u5F00\u542F\uFF0C\u6A21\u578B\u672A\u5B89\u88C5\uFF08/codeindex semantic install\uFF09"):n("\u8BED\u4E49\u68C0\u7D22\uFF1A\u672A\u5F00\u542F\uFF08\u9ED8\u8BA4\u5173\u95ED\uFF09")}m(X,"Te"),E(X,"semanticStatus");async function z(e,r,t,u){const a=A(),l=h(a);if(!l.semantic)return;const s=y(a,l);if(!s)return{note:n("\uFF08\u8BED\u4E49\u68C0\u7D22\u5DF2\u5F00\u542F\u4F46\u6A21\u578B\u672A\u5B89\u88C5\uFF1A\u8FD0\u884C /codeindex semantic install\uFF09"),files:[]};const o=q(r,O),i=W(e.root)??0,F=i>0?n("\uFF08\u8BED\u4E49\u7D22\u5F15\u5EFA\u7ACB\u4E2D\uFF1A\u5DF2\u5B8C\u6210 {done} \u4E2A\u6587\u4EF6\uFF0C\u8FD8\u5269 {left} \u4E2A\uFF09").replace("{done}",String(o)).replace("{left}",String(i)):void 0;if(o===0)return{note:F,files:[]};const D=await bu(l,s,t);return D?{note:F,files:wu(r,`${e.dbPath}\0${e.root}`,O,D,8,u)}:{note:n("\uFF08\u8BED\u4E49\u68C0\u7D22\u6682\u65F6\u4E0D\u53EF\u7528\uFF0C\u4EE5\u4E0B\u53EA\u6309\u5173\u952E\u8BCD\u5339\u914D\uFF09"),files:[]}}m(z,"Fe"),E(z,"semanticSearch");const Ku=Symbol.for("dalcode.codeindex.api");function K(e,r,t){const u=A();if(!h(u).enabled)return[];const a=w(e,u),l=a?I(a):void 0;if(!a||!l)return[];const s=b({store:l.store,rootId:l.rootId},{symbol:r},20).definitions,o=t?v(a,e,t):void 0;return s.sort((i,F)=>+(F.path===o)-+(i.path===o)),s.map(i=>({filePath:j(a.root,i.path),line:i.line,character:i.column}))}m(K,"Ne"),E(K,"locate");let V=!1,Y=!1;function Z(e){if(!h(A()).enabled)return;globalThis[Ku]={locate:K},V||(V=!0,process.once("exit",()=>{Iu()}));let r;e.on("session_start",(t,u)=>{const a=A(),l=h(a);if(!l.enabled)return;const s=Number(process.env.DAL_CODE_INDEX_MIN_FILES),o=su(u.cwd,Number.isFinite(s)&&s>=0?s:void 0),i=e.getActiveTools();if(o&&i.includes("code_index")&&e.setActiveTools(i.filter(D=>D!=="code_index")),o)return;const F=w(u.cwd,a);if(F){try{Y||(Y=!0,Cu(a,F.indexDir,l.maxTotalDiskBytes)),k(F,l,u.cwd,y(a,l)).then(()=>Du(F))}catch{return}u.hasUI&&(r?.(),r=_u((D,d)=>{if(D!==F.root)return;const p=!d.done&&d.pending>200;u.ui.setStatus("codeindex",p?n("\u4EE3\u7801\u7D22\u5F15 {done}/{total}").replace("{done}",String(Math.max(0,d.total-d.pending))).replace("{total}",String(d.total)):void 0)}))}}),e.on("session_shutdown",()=>{r?.(),r=void 0}),e.on("tool_result",(t,u)=>{if(t.toolName!=="edit"&&t.toolName!=="write"||t.isError)return;const a=t.input,l=typeof a.path=="string"?a.path:typeof a.file_path=="string"?a.file_path:"";if(!l)return;const s=A(),o=h(s);if(!o.enabled)return;const i=w(u.cwd,s);if(!i)return;const F=v(i,u.cwd,l);F&&N(F)&&Pu(i,o,[F])}),e.registerTool({name:"code_index",label:n("\u4EE3\u7801\u7D22\u5F15"),description:n("\u672C\u5730\u4EE3\u7801\u7D22\u5F15\uFF08\u5E38\u9A7B\u3001\u8DE8\u4F1A\u8BDD\uFF0C\u6309\u6587\u4EF6\u53D8\u5316\u589E\u91CF\u66F4\u65B0\uFF09\uFF1A\u6309\u540D\u5B57\u627E\u5B9A\u4E49\u5E76\u9644\u4EE3\u7801\uFF08definition\uFF09\u3001\u627E\u5168\u90E8\u5F15\u7528\uFF08references\uFF09\u3001\u627E\u8C03\u7528\u65B9\uFF08callers\uFF09\u3001\u627E\u5B9E\u73B0\u548C\u5B50\u7C7B\uFF08implementations\uFF09\u3001\u6587\u4EF6\u5927\u7EB2\uFF08outline\uFF09\u3001\u76F8\u5173\u6587\u4EF6\u4E0E\u6D4B\u8BD5\uFF08related\uFF09\u3001\u6309\u529F\u80FD\u5173\u952E\u8BCD\u627E\u7B26\u53F7\uFF08search\uFF09\u3002")+n("\u652F\u6301 TypeScript/JavaScript\u3001Python\u3001Go\u3001Java\u3001Rust\u3001C/C++\u3001C#\u3001Ruby\u3001PHP\u3002")+n("\u6309\u540D\u5B57\u5339\u914D\u3001\u4E0D\u505A\u7C7B\u578B\u89E3\u6790\uFF0C\u540C\u540D\u7B26\u53F7\u4F1A\u6DF7\u5728\u4E00\u8D77\uFF1B\u7ED3\u679C\u5F00\u5934\u6CE8\u660E\u7D22\u5F15\u662F\u5426\u5B8C\u6574\u3002"),promptSnippet:n("code_index - \u672C\u5730\u4EE3\u7801\u7D22\u5F15\uFF1A\u6309\u540D\u5B57\u627E\u5B9A\u4E49\uFF08\u9644\u4EE3\u7801\uFF09\u3001\u5F15\u7528\u548C\u8C03\u7528\u65B9\u3001\u6587\u4EF6\u5927\u7EB2\u3001\u76F8\u5173\u6587\u4EF6\u3001\u6309\u529F\u80FD\u627E\u4EE3\u7801\uFF1B\u5927\u9879\u76EE\u91CC\u6BD4 grep \u5FEB\u5F97\u591A"),promptGuidelines:[n("\u627E\u4EE3\u7801\u5148\u7528 code_index\uFF08definition \u76F4\u63A5\u8FD4\u56DE\u4EE3\u7801\uFF0Ccallers/references/implementations \u76F4\u63A5\u4F20\u540D\u5B57\uFF0C\u53EA\u77E5\u9053\u529F\u80FD\u7528 search\uFF09\uFF0C\u4E0D\u8981\u7528 grep/find \u53CD\u590D\u8BD5\u63A2\uFF1B\u7D22\u5F15\u672A\u5B8C\u6210\u65F6\u6CA1\u627E\u5230\u518D\u7528 grep \u786E\u8BA4\u3002")],parameters:Qu,execute:E(async(t,u,a,l,s)=>{try{return await $(u,s.cwd)}catch(o){const i=o instanceof Error?o.message:String(o);if(i.startsWith("code_index:"))throw o;return x(`${n("code_index: \u67E5\u8BE2\u5931\u8D25\uFF1A")}${i}${n("\u3002\u6539\u7528 grep/find\u3002")}`,{ok:!1,reason:i})}},"execute")}),e.registerCommand("codeindex",{description:n("\u4EE3\u7801\u7D22\u5F15\uFF1A\u67E5\u770B\u5F53\u524D\u9879\u76EE\u7684\u7D22\u5F15\u72B6\u6001\uFF0C\u6216\u7ACB\u5373\u540C\u6B65\uFF08sync\uFF09"),getArgumentCompletions:E(t=>["status","sync","semantic install"].filter(u=>u.startsWith(t.trim())).map(u=>({value:u,label:u})),"getArgumentCompletions"),handler:E(async(t,u)=>{const a=E(s=>{u.hasUI?u.ui.notify(s,"info"):process.stdout.write(`${s}
4
+ `)},"say");if(t.trim()==="semantic install"){const s=G(A());a(n("\u6B63\u5728\u4E0B\u8F7D\u8BED\u4E49\u68C0\u7D22\u7684\u672C\u673A\u6A21\u578B\u548C\u8FD0\u884C\u65F6\uFF08\u7EA6 57 MB\uFF0C\u53EA\u6B64\u4E00\u6B21\uFF1B\u6587\u4EF6\u6309\u56FA\u5B9A\u7684 SHA-256 \u6821\u9A8C\uFF09\u2026"));try{await Ru(s),a(n("\u8BED\u4E49\u68C0\u7D22\u5DF2\u5B89\u88C5\u5230 {dir}\u3002\u5728\u8BBE\u7F6E\u91CC\u628A dalCodeIndex.semantic \u8BBE\u4E3A true \u5373\u53EF\u542F\u7528\u3002").replace("{dir}",s))}catch(o){a(`${n("\u8BED\u4E49\u68C0\u7D22\u5B89\u88C5\u5931\u8D25\uFF1A")}${o instanceof Error?o.message:String(o)}`)}return}if(t.trim()==="sync"){const s=A(),o=w(u.cwd,s),i=h(s),F=setInterval(()=>{},1e3);try{o&&await k(o,i,u.cwd,y(s,i))}finally{clearInterval(F)}}const l=await $({action:"status"},u.cwd);a(l.content[0]?.text??"")},"handler")})}m(Z,"je"),E(Z,"dalCodeIndex");export{Z as default,$u as extract,Nu as findDefinitions,qu as findReferences,Lu as languageForPath,ju as locateProject,Hu as openStore,Tu as readSettings,Mu as relatedFiles,Wu as requestSync,Uu as searchSymbols,Gu as shutdownRuntime};
@@ -0,0 +1 @@
1
+ var P=Object.defineProperty;var p=(t,e)=>P(t,"name",{value:e,configurable:!0});var k=Object.defineProperty,g=p((t,e)=>k(t,"name",{value:e,configurable:!0}),"g");import{createHash as C}from"node:crypto";import{readFileSync as D,statSync as A}from"node:fs";import{join as I}from"node:path";import{extract as _}from"./extract.js";import{languageForPath as O}from"./languages.js";import{scanProject as U}from"./scan.js";import{fileText as z}from"./semantic.js";import{acquireRoot as G,fileStamps as K,heartbeat as H,releaseRoot as W,rootId as M,StoreWriter as S,storeBytes as j,updateRootProgress as R}from"./store.js";const J=200,Y=1500,q=400,x={definitions:[],references:[]};function L(t){return t.subarray(0,8192).includes(0)}p(L,"G"),g(L,"looksBinary");function B(t){if(t.length<2e4)return!1;let e=1;for(let a=0;a<t.length;a++)t.charCodeAt(a)===10&&(e+=1);return t.length/e>q}p(B,"K"),g(B,"looksMinified");async function w(t,e,a,l){const d=I(a,l);let o,r;try{const s=A(d);if(!s.isFile())return!1;o=D(d),r={size:s.size,mtimeMs:Math.trunc(s.mtimeMs)}}catch{return!1}const n=C("sha1").update(o).digest("hex"),m=t.knownBlob(n);if(m!==void 0)return t.setFile(e,l,m,r),!0;const b=O(l);let c=x;if(b&&!L(o)){const s=o.toString("utf8");if(!B(s))try{c=await _(s,b)}catch{c=x}}const h=t.knownBlob(n)??t.addBlob(n,b?.language,c);return t.setFile(e,l,h,r),!0}p(w,"L"),g(w,"indexFile");async function v(t){const{store:e,rootPath:a,limits:l,owner:d}=t,o=M(e,a);if(!G(e,o,d))return!1;const r=new S(e);try{const n=U(a,l,t.focus),m=K(e,o),b=new Set,c=[];for(const f of n.files){b.add(f.path);const u=m.get(f.path);(!u||u.size!==f.size||u.mtimeMs!==f.mtimeMs)&&c.push(f.path)}const h=[...m.keys()].filter(f=>!b.has(f));let s=n.truncated>0?`max-files:${n.truncated}`:null;r.transaction(()=>{for(const f of h)r.removeFile(o,f);R(e,o,{total:n.files.length,pending:c.length,complete:c.length===0&&s===null,note:s})});let i=c.length;t.onProgress({root:a,total:n.files.length,pending:i,done:!1,note:s??void 0});let y=0;for(;y<c.length;){if(t.shouldStop())return!0;if(j(e.path)>l.maxDiskBytes){s="max-disk";break}const f=Date.now(),u=[];for(;y<c.length&&u.length<J&&Date.now()-f<Y;)u.push(c[y]),y+=1;e.db.exec("BEGIN IMMEDIATE");try{for(const E of u)await w(r,o,a,E)||r.removeFile(o,E);if(i-=u.length,R(e,o,{pending:i}),!H(e,o,d))return e.db.exec("ROLLBACK"),!0;e.db.exec("COMMIT")}catch(E){throw e.db.exec("ROLLBACK"),E}t.onProgress({root:a,total:n.files.length,pending:i,done:!1}),await t.betweenBatches()}return R(e,o,{pending:Math.max(0,i),complete:i<=0&&s===null,lastScan:Date.now(),note:s}),e.db.exec("PRAGMA wal_checkpoint(TRUNCATE)"),t.onProgress({root:a,total:n.files.length,pending:i,done:!0,note:s??void 0}),!0}finally{W(e,o,d)}}p(v,"ee"),g(v,"syncRoot");async function N(t,e,a,l){const d=M(t,e),o=new S(t);t.db.exec("BEGIN IMMEDIATE");try{for(const r of a){if(!O(r))continue;let n=-1;try{n=A(I(e,r)).size}catch{}(n<=0||n>l.maxFileBytes||!await w(o,d,e,r))&&o.removeFile(d,r)}t.db.exec("COMMIT")}catch(r){throw t.db.exec("ROLLBACK"),r}}p(N,"te"),g(N,"updateFiles");const T=16,V=60;async function F(t){const{store:e}=t,a=M(e,t.rootPath),l=e.db.prepare("SELECT f.blob_id AS blob_id, b.hash AS hash, min(f.path) AS path FROM files f JOIN blobs b ON b.id = f.blob_id LEFT JOIN vectors v ON v.hash = b.hash AND v.model = ? WHERE f.root_id = ? AND v.hash IS NULL GROUP BY f.blob_id").all(t.model,a),d=e.db.prepare("SELECT n.name AS name, d.kind AS kind, d.doc AS doc FROM defs d JOIN names n ON n.id = d.name_id WHERE d.blob_id = ? ORDER BY d.parent IS NOT NULL, d.line LIMIT ?"),o=e.db.prepare("INSERT OR REPLACE INTO vectors(hash, model, vec) VALUES (?, ?, ?)");let r=l.length;t.onProgress(r,!1);for(let n=0;n<l.length;n+=T){if(t.shouldStop())return;const m=l.slice(n,n+T),b=m.map(h=>{const s=d.all(h.blob_id,V);return z(h.path,s.map(i=>({name:i.name,kind:i.kind,doc:i.doc??void 0})))}),c=await t.embed(b);e.db.exec("BEGIN IMMEDIATE");try{m.forEach((h,s)=>{const i=c[s];o.run(h.hash,t.model,new Uint8Array(i.buffer,i.byteOffset,i.byteLength))}),e.db.exec("COMMIT")}catch(h){throw e.db.exec("ROLLBACK"),h}r-=m.length,t.onProgress(r,!1),await t.betweenBatches()}t.onProgress(0,!0)}p(F,"ne"),g(F,"embedRoot");export{F as embedRoot,v as syncRoot,N as updateFiles};
@@ -0,0 +1,176 @@
1
+ var u=Object.defineProperty;var f=(n,i)=>u(n,"name",{value:i,configurable:!0});var y=Object.defineProperty,g=f((n,i)=>y(n,"name",{value:i,configurable:!0}),"d");const m=`
2
+ (function_declaration name: (identifier) @name) @def.function
3
+ (generator_function_declaration name: (identifier) @name) @def.function
4
+ (function_signature name: (identifier) @name) @def.function
5
+ (class_declaration name: (_) @name) @def.class
6
+ (abstract_class_declaration name: (type_identifier) @name) @def.class
7
+ (interface_declaration name: (type_identifier) @name) @def.interface
8
+ (type_alias_declaration name: (type_identifier) @name) @def.type
9
+ (enum_declaration name: (identifier) @name) @def.enum
10
+ (internal_module name: (_) @name) @def.module
11
+ (method_definition name: (_) @name) @def.method
12
+ (method_signature name: (_) @name) @def.method
13
+ (abstract_method_signature name: (_) @name) @def.method
14
+ (public_field_definition name: (_) @name) @def.field
15
+ (property_signature name: (_) @name) @def.field
16
+ (variable_declarator name: (identifier) @name value: [(arrow_function) (function_expression)]) @def.function
17
+ (program (lexical_declaration (variable_declarator name: (identifier) @name) @def.constant))
18
+ (program (export_statement declaration: (lexical_declaration (variable_declarator name: (identifier) @name) @def.constant)))
19
+ (pair key: (property_identifier) @name value: [(arrow_function) (function_expression)]) @def.function
20
+ `,x=`
21
+ (function_declaration name: (identifier) @name) @def.function
22
+ (generator_function_declaration name: (identifier) @name) @def.function
23
+ (class_declaration name: (_) @name) @def.class
24
+ (class name: (_) @name) @def.class
25
+ (method_definition name: (_) @name) @def.method
26
+ (field_definition property: (_) @name) @def.field
27
+ (variable_declarator name: (identifier) @name value: [(arrow_function) (function_expression)]) @def.function
28
+ (assignment_expression left: (member_expression property: (property_identifier) @name) right: [(arrow_function) (function_expression)]) @def.function
29
+ (program (lexical_declaration (variable_declarator name: (identifier) @name) @def.constant))
30
+ (program (export_statement declaration: (lexical_declaration (variable_declarator name: (identifier) @name) @def.constant)))
31
+ (pair key: (property_identifier) @name value: [(arrow_function) (function_expression)]) @def.function
32
+ `,c=`
33
+ (call_expression function: (identifier) @name) @ref.call
34
+ (call_expression function: (member_expression property: (_) @name)) @ref.call
35
+ (new_expression constructor: (identifier) @name) @ref.new
36
+ (new_expression constructor: (member_expression property: (property_identifier) @name)) @ref.new
37
+ (decorator (identifier) @name) @ref.call
38
+ (class_heritage (identifier) @name) @ref.extends
39
+ (import_specifier name: (identifier) @name) @ref.import
40
+ `,o=`
41
+ (jsx_opening_element name: (identifier) @name) @ref.call
42
+ (jsx_self_closing_element name: (identifier) @name) @ref.call
43
+ `,l=`${c.replace("(class_heritage (identifier) @name) @ref.extends","(extends_clause value: (identifier) @name) @ref.extends")}
44
+ (implements_clause (type_identifier) @name) @ref.implements
45
+ (implements_clause (generic_type name: (type_identifier) @name)) @ref.implements
46
+ (extends_type_clause type: (type_identifier) @name) @ref.extends
47
+ (extends_type_clause type: (generic_type name: (type_identifier) @name)) @ref.extends
48
+ (type_identifier) @name @ref.type
49
+ `,_=`
50
+ (class_definition name: (identifier) @name) @def.class
51
+ (function_definition name: (identifier) @name) @def.function
52
+ (module (expression_statement (assignment left: (identifier) @name) @def.constant))
53
+ (call function: (identifier) @name) @ref.call
54
+ (call function: (attribute attribute: (identifier) @name)) @ref.call
55
+ (class_definition superclasses: (argument_list (identifier) @name)) @ref.extends
56
+ (class_definition superclasses: (argument_list (attribute attribute: (identifier) @name))) @ref.extends
57
+ (decorator (identifier) @name) @ref.call
58
+ (import_from_statement name: (dotted_name (identifier) @name)) @ref.import
59
+ (import_from_statement name: (aliased_import name: (dotted_name (identifier) @name))) @ref.import
60
+ (type (identifier) @name) @ref.type
61
+ `,h=`
62
+ (function_declaration name: (identifier) @name) @def.function
63
+ (method_declaration receiver: (parameter_list (parameter_declaration type: [(type_identifier) @receiver (pointer_type (type_identifier) @receiver) (generic_type type: (type_identifier) @receiver) (pointer_type (generic_type type: (type_identifier) @receiver))])) name: (field_identifier) @name) @def.method
64
+ (type_spec name: (type_identifier) @name type: (struct_type)) @def.struct
65
+ (type_spec name: (type_identifier) @name type: (interface_type)) @def.interface
66
+ (type_spec name: (type_identifier) @name type: [(type_identifier) (qualified_type) (function_type) (map_type) (slice_type) (array_type) (pointer_type) (channel_type) (generic_type)]) @def.type
67
+ (type_alias name: (type_identifier) @name) @def.type
68
+ (method_elem name: (field_identifier) @name) @def.method
69
+ (field_declaration name: (field_identifier) @name) @def.field
70
+ (source_file (const_declaration (const_spec name: (identifier) @name) @def.constant))
71
+ (source_file (var_declaration (var_spec name: (identifier) @name) @def.variable))
72
+ (call_expression function: (identifier) @name) @ref.call
73
+ (call_expression function: (selector_expression field: (field_identifier) @name)) @ref.call
74
+ (type_identifier) @name @ref.type
75
+ `,b=`
76
+ (class_declaration name: (identifier) @name) @def.class
77
+ (interface_declaration name: (identifier) @name) @def.interface
78
+ (enum_declaration name: (identifier) @name) @def.enum
79
+ (record_declaration name: (identifier) @name) @def.class
80
+ (annotation_type_declaration name: (identifier) @name) @def.interface
81
+ (method_declaration name: (identifier) @name) @def.method
82
+ (constructor_declaration name: (identifier) @name) @def.constructor
83
+ (field_declaration declarator: (variable_declarator name: (identifier) @name)) @def.field
84
+ (enum_constant name: (identifier) @name) @def.member
85
+ (method_invocation name: (identifier) @name) @ref.call
86
+ (object_creation_expression type: (type_identifier) @name) @ref.new
87
+ (superclass (type_identifier) @name) @ref.extends
88
+ (super_interfaces (type_list (type_identifier) @name)) @ref.implements
89
+ (super_interfaces (type_list (generic_type (type_identifier) @name))) @ref.implements
90
+ (superclass (generic_type (type_identifier) @name)) @ref.extends
91
+ (extends_interfaces (type_list (type_identifier) @name)) @ref.extends
92
+ (type_identifier) @name @ref.type
93
+ `,v=`
94
+ (struct_item name: (type_identifier) @name) @def.struct
95
+ (enum_item name: (type_identifier) @name) @def.enum
96
+ (union_item name: (type_identifier) @name) @def.struct
97
+ (type_item name: (type_identifier) @name) @def.type
98
+ (trait_item name: (type_identifier) @name) @def.interface
99
+ (function_item name: (identifier) @name) @def.function
100
+ (function_signature_item name: (identifier) @name) @def.function
101
+ (mod_item name: (identifier) @name) @def.module
102
+ (macro_definition name: (identifier) @name) @def.macro
103
+ (const_item name: (identifier) @name) @def.constant
104
+ (static_item name: (identifier) @name) @def.constant
105
+ (field_declaration name: (field_identifier) @name) @def.field
106
+ (enum_variant name: (identifier) @name) @def.member
107
+ (impl_item type: (_) @name) @scope
108
+ (call_expression function: (identifier) @name) @ref.call
109
+ (call_expression function: (field_expression field: (field_identifier) @name)) @ref.call
110
+ (call_expression function: (scoped_identifier name: (identifier) @name)) @ref.call
111
+ (call_expression function: (generic_function function: (identifier) @name)) @ref.call
112
+ (call_expression function: (generic_function function: (scoped_identifier name: (identifier) @name))) @ref.call
113
+ (call_expression function: (generic_function function: (field_expression field: (field_identifier) @name))) @ref.call
114
+ (macro_invocation macro: (identifier) @name) @ref.call
115
+ (impl_item trait: (type_identifier) @name) @ref.implements
116
+ (use_declaration argument: (scoped_identifier name: (identifier) @name)) @ref.import
117
+ (type_identifier) @name @ref.type
118
+ `,w=`
119
+ (function_definition declarator: (function_declarator declarator: (_) @name)) @def.function
120
+ (function_definition declarator: (pointer_declarator declarator: (function_declarator declarator: (_) @name))) @def.function
121
+ (function_definition declarator: (reference_declarator (function_declarator declarator: (_) @name))) @def.function
122
+ (declaration declarator: (function_declarator declarator: (identifier) @name)) @def.declaration
123
+ (declaration declarator: (pointer_declarator declarator: (function_declarator declarator: (identifier) @name))) @def.declaration
124
+ (field_declaration declarator: (function_declarator declarator: (_) @name)) @def.method
125
+ (struct_specifier name: (type_identifier) @name body: (_)) @def.struct
126
+ (class_specifier name: (type_identifier) @name body: (_)) @def.class
127
+ (union_specifier name: (type_identifier) @name body: (_)) @def.struct
128
+ (enum_specifier name: (type_identifier) @name body: (_)) @def.enum
129
+ (type_definition declarator: (type_identifier) @name) @def.type
130
+ (alias_declaration name: (type_identifier) @name) @def.type
131
+ (namespace_definition name: (_) @name) @def.module
132
+ (preproc_def name: (identifier) @name) @def.macro
133
+ (preproc_function_def name: (identifier) @name) @def.macro
134
+ (field_declaration declarator: (field_identifier) @name) @def.field
135
+ (enumerator name: (identifier) @name) @def.member
136
+ (call_expression function: (identifier) @name) @ref.call
137
+ (call_expression function: (field_expression field: (field_identifier) @name)) @ref.call
138
+ (call_expression function: (qualified_identifier name: (identifier) @name)) @ref.call
139
+ (call_expression function: (template_function name: (identifier) @name)) @ref.call
140
+ (new_expression type: (type_identifier) @name) @ref.new
141
+ (base_class_clause (type_identifier) @name) @ref.extends
142
+ (type_identifier) @name @ref.type
143
+ `,q=`
144
+ (class_declaration name: (identifier) @name) @def.class
145
+ (interface_declaration name: (identifier) @name) @def.interface
146
+ (struct_declaration name: (identifier) @name) @def.struct
147
+ (enum_declaration name: (identifier) @name) @def.enum
148
+ (record_declaration name: (identifier) @name) @def.class
149
+ (method_declaration name: (identifier) @name) @def.method
150
+ (constructor_declaration name: (identifier) @name) @def.constructor
151
+ (property_declaration name: (identifier) @name) @def.field
152
+ (namespace_declaration name: (_) @name) @def.module
153
+ (invocation_expression function: (identifier) @name) @ref.call
154
+ (invocation_expression function: (member_access_expression name: (identifier) @name)) @ref.call
155
+ (object_creation_expression type: (identifier) @name) @ref.new
156
+ (base_list (identifier) @name) @ref.extends
157
+ `,j=`
158
+ (class name: (constant) @name) @def.class
159
+ (module name: (constant) @name) @def.module
160
+ (method name: (_) @name) @def.method
161
+ (singleton_method name: (_) @name) @def.method
162
+ (call method: (identifier) @name) @ref.call
163
+ (superclass (constant) @name) @ref.extends
164
+ `,P=`
165
+ (class_declaration name: (name) @name) @def.class
166
+ (interface_declaration name: (name) @name) @def.interface
167
+ (trait_declaration name: (name) @name) @def.interface
168
+ (enum_declaration name: (name) @name) @def.enum
169
+ (function_definition name: (name) @name) @def.function
170
+ (method_declaration name: (name) @name) @def.method
171
+ (function_call_expression function: (name) @name) @ref.call
172
+ (member_call_expression name: (name) @name) @ref.call
173
+ (scoped_call_expression name: (name) @name) @ref.call
174
+ (object_creation_expression (name) @name) @ref.new
175
+ (base_clause (name) @name) @ref.extends
176
+ `,a={language:"TypeScript",grammar:"typescript",query:m+l},S={language:"TypeScript",grammar:"tsx",query:m+l+o},t={language:"JavaScript",grammar:"javascript",query:x+c+o},e={language:"C/C++",grammar:"cpp",query:w},s=new Map([[".ts",a],[".mts",a],[".cts",a],[".tsx",S],[".js",t],[".mjs",t],[".cjs",t],[".jsx",t],[".py",{language:"Python",grammar:"python",query:_}],[".pyi",{language:"Python",grammar:"python",query:_}],[".go",{language:"Go",grammar:"go",query:h}],[".java",{language:"Java",grammar:"java",query:b}],[".rs",{language:"Rust",grammar:"rust",query:v}],[".c",e],[".h",e],[".cc",e],[".cpp",e],[".cxx",e],[".c++",e],[".hh",e],[".hpp",e],[".hxx",e],[".h++",e],[".inl",e],[".cs",{language:"C#",grammar:"c-sharp",query:q}],[".rb",{language:"Ruby",grammar:"ruby",query:j}],[".php",{language:"PHP",grammar:"php",query:P}]]);function p(n){const i=n.lastIndexOf("/"),r=n.slice(i+1).toLowerCase();if(r.endsWith(".d.ts"))return a;const d=r.lastIndexOf(".");return d>0?s.get(r.slice(d)):void 0}f(p,"P"),g(p,"languageForPath");const N=new Set(["class","interface","struct","enum","module","type","function","method","constructor"]);export{N as CONTAINER_KINDS,s as LANGUAGES_BY_EXTENSION,p as languageForPath};
@@ -0,0 +1 @@
1
+ var T=Object.defineProperty;var a=(t,e)=>T(t,"name",{value:e,configurable:!0});var C=Object.defineProperty,m=a((t,e)=>C(t,"name",{value:e,configurable:!0}),"c");import{spawnSync as j}from"node:child_process";import{createHash as E}from"node:crypto";import{readdirSync as N,readFileSync as A,realpathSync as L,rmSync as _,statSync as P,utimesSync as O,writeFileSync as $}from"node:fs";import{homedir as U}from"node:os";import{basename as b,dirname as z,join as d,parse as G,resolve as M,sep as g}from"node:path";import{storeBytes as H}from"./store.js";const u={enabled:!0,maxFiles:3e5,maxFileBytes:1024*1024,maxDiskBytes:2*1024*1024*1024,maxTotalDiskBytes:8*1024*1024*1024,maxMemoryMb:512,semantic:!1};function y(t,e,s,o){return typeof t=="number"&&Number.isFinite(t)?Math.min(o,Math.max(s,Math.round(t))):e}a(y,"x"),m(y,"positive");function B(t){let e={};try{const n=JSON.parse(A(d(t,"settings.json"),"utf8"));n.dalCodeIndex&&typeof n.dalCodeIndex=="object"&&(e=n.dalCodeIndex)}catch{}const s=process.env.DAL_CODEINDEX?.trim().toLowerCase(),o=1024*1024;return{enabled:s==="off"||s==="0"||s==="false"?!1:e.enabled!==!1,maxFiles:y(e.maxFiles,u.maxFiles,100,5e6),maxFileBytes:y(e.maxFileKB,u.maxFileBytes/1024,1,64*1024)*1024,maxDiskBytes:y(e.maxDiskMB,u.maxDiskBytes/o,16,1024*1024)*o,maxTotalDiskBytes:y(e.maxTotalDiskMB,u.maxTotalDiskBytes/o,64,4*1024*1024)*o,maxMemoryMb:y(e.maxMemoryMB,u.maxMemoryMb,64,16*1024),semantic:process.env.DAL_CODEINDEX_SEMANTIC==="on"||e.semantic===!0}}a(B,"z"),m(B,"readSettings");function x(t){try{return L(t)}catch{return M(t)}}a(x,"f"),m(x,"real");function S(t){const e=j("git",["-C",t,"rev-parse","--show-toplevel","--git-common-dir"],{encoding:"utf8",windowsHide:!0,stdio:["ignore","pipe","ignore"],timeout:5e3});if(e.status!==0||typeof e.stdout!="string")return;const[s,o]=e.stdout.split(/\r?\n/);if(!(!s||!o))return{root:x(s),commonDir:x(M(t,o))}}a(S,"N"),m(S,"gitLocation");function D(t,e){return e===t||e.startsWith(t.endsWith(g)?t:t+g)}a(D,"h"),m(D,"isInside");const v=new Map;function F(t,e){const s=`${t}\0${e}`,o=v.get(s);if(o!==void 0)return o??void 0;const n=S(t),i=n?.root??x(t),f=x(e);let l=null;if(i!==x(U())&&i!==G(i).root&&!D(f,i)&&!D(i,f)){const r=n?b(n.commonDir)===".git"?z(n.commonDir):n.commonDir:i,c=b(r).replace(/[^A-Za-z0-9._-]+/g,"-").slice(0,40)||"project",p=E("sha256").update(r).digest("hex").slice(0,12),h=d(e,"codeindex",`${c}-${p}`);l={root:i,indexDir:h,dbPath:d(h,"index.db")}}return v.set(s,l),l??void 0}a(F,"G"),m(F,"locateProject");const k="last-used";function I(t){const e=d(t.indexDir,k);try{const s=new Date;try{O(e,s,s)}catch{$(e,"",{mode:384})}}catch{}}a(I,"J"),m(I,"markUsed");function w(t,e,s){const o=d(t,"codeindex");let n;try{n=N(o,{withFileTypes:!0})}catch{return[]}const i=n.filter(r=>r.isDirectory()).map(r=>{const c=d(o,r.name);let p=0;try{p=P(d(c,k)).mtimeMs}catch{}return{dir:c,used:p,bytes:H(d(c,"index.db"))}}).sort((r,c)=>r.used-c.used);let f=i.reduce((r,c)=>r+c.bytes,0);const l=[];for(const r of i){if(f<=s)break;r.dir!==e&&(_(r.dir,{recursive:!0,force:!0}),f-=r.bytes,l.push(r.dir))}return l}a(w,"K"),m(w,"pruneIndexes");export{u as DEFAULT_SETTINGS,F as locateProject,I as markUsed,w as pruneIndexes,B as readSettings};
@@ -0,0 +1,2 @@
1
+ var Y=Object.defineProperty;var p=(e,t)=>Y(e,"name",{value:t,configurable:!0});var z=Object.defineProperty,f=p((e,t)=>z(e,"name",{value:t,configurable:!0}),"f");import{identifierWords as T}from"./store.js";const g="d.id AS id, f.path AS path, n.name AS name, d.kind AS kind, d.line AS line, d.end_line AS end_line, d.col AS col, d.container AS container, d.signature AS signature, d.doc AS doc";function S(e){return{id:e.id,path:e.path,name:e.name,kind:e.kind,line:e.line,endLine:e.end_line,column:e.col,container:e.container??void 0,signature:e.signature,doc:e.doc??void 0}}p(S,"O"),f(S,"toDefinition");const K=/(^|\/)(tests?|__tests__|spec|specs|testdata|fixtures?)(\/|$)|[._-](test|spec)s?\.[a-z]+$|_test\.go$/i;function m(e){return K.test(e)}p(m,"I"),f(m,"isTestPath");const C={class:0,interface:0,struct:0,enum:1,type:1,function:1,method:1,constructor:2,module:2,macro:2,constant:3,variable:3,field:3,member:4,declaration:5};function v(e,t){return Number(m(e.path))-Number(m(t.path))||(C[e.kind]??3)-(C[t.kind]??3)||Number(e.path.endsWith(".d.ts"))-Number(t.path.endsWith(".d.ts"))||e.path.length-t.path.length||e.path.localeCompare(t.path)||e.line-t.line}p(v,"v"),f(v,"definitionOrder");function R(e){const t=e.trim().replace(/\(\)$/,""),r=/^(.*?)(?:::|\.|#)([^:.#]+)$/.exec(t);if(!r)return{name:t};const a=r[1].split(/::|\.|#/);return{name:r[2],container:a[a.length-1]}}p(R,"D"),f(R,"splitSymbol");function A(e,t){if(!e)return"";const r=e.replace(/^\.\/+/,"").replace(/\/+$/,"");return!r||r==="."?"":(t.push(r,`${r}/%`)," AND (f.path = ? OR f.path LIKE ?)")}p(A,"L"),f(A,"pathClause");function M(e,t,r=50){const{name:a,container:c}=R(t.symbol),s=f(u=>{const n=[e.rootId,a];let i=`SELECT ${g} FROM names n JOIN defs d ON d.name_id = n.id JOIN files f ON f.blob_id = d.blob_id AND f.root_id = ? WHERE n.name = ?${u?" COLLATE NOCASE":""}`;return c&&(i+=" AND d.container = ?",n.push(c)),t.kind&&(i+=" AND d.kind = ?",n.push(t.kind)),i+=A(t.pathPrefix,n),i+=" LIMIT 2000",e.store.db.prepare(i).all(...n).map(S)},"run");let o=s(!1),d=!1;return o.length===0&&(o=s(!0),d=o.length>0),{definitions:o.sort(v).slice(0,r),caseInsensitive:d||void 0}}p(M,"J"),f(M,"findDefinitions");function D(e,t,r=2e3){const{name:a}=R(t.symbol),c=[e.rootId,a];let s="WHERE n.name = ?";t.kinds&&t.kinds.length>0&&(s+=` AND r.kind IN (${t.kinds.map(()=>"?").join(", ")})`,c.push(...t.kinds)),s+=A(t.pathPrefix,c);const o="FROM names n JOIN refs r ON r.name_id = n.id JOIN files f ON f.blob_id = r.blob_id AND f.root_id = ?",d=Number(e.store.db.prepare(`SELECT count(*) AS n ${o} ${s}`).get(...c).n),u=e.store.db.prepare(`SELECT f.path AS path, r.line AS line, r.col AS col, r.kind AS kind, cn.name AS caller, cd.container AS caller_container, cd.line AS caller_line ${o} LEFT JOIN defs cd ON cd.id = r.caller LEFT JOIN names cn ON cn.id = cd.name_id ${s} LIMIT ?`).all(...c,r).map(n=>({path:n.path,line:n.line,column:n.col,kind:n.kind,caller:n.caller??void 0,callerContainer:n.caller_container??void 0,callerLine:n.caller_line??void 0}));return u.sort((n,i)=>Number(m(n.path))-Number(m(i.path))||n.path.localeCompare(i.path)||n.line-i.line),{references:u,total:d}}p(D,"y"),f(D,"findReferences");function $(e,t){return e.store.db.prepare("SELECT blob_id FROM files WHERE root_id = ? AND path = ?").get(e.rootId,t)?e.store.db.prepare(`SELECT ${g} FROM files f JOIN defs d ON d.blob_id = f.blob_id JOIN names n ON n.id = d.name_id WHERE f.root_id = ? AND f.path = ? ORDER BY d.line, d.col`).all(e.rootId,t).map(S):void 0}p($,"B"),f($,"fileOutline");function F(e,t){const r=new Map;if(e.length>0){const s=e.map(d=>d.id),o=t.store.db.prepare(`SELECT id, parent FROM defs WHERE id IN (${s.map(()=>"?").join(", ")})`).all(...s);for(const d of o)r.set(d.id,d.parent)}const a=new Map,c=f((s,o=0)=>{const d=a.get(s);if(d!==void 0)return d;const u=r.get(s),n=u==null||o>20?0:c(u,o+1)+1;return a.set(s,n),n},"depthOf");for(const s of e)c(s.id);return a}p(F,"Q"),f(F,"outlineDepths");const q=new Set(["the","a","an","of","to","in","for","and","or","is","where","which","what","how","code","that","this","with","on","by","from","handle","handles","handling","logic","function","implementation"]);function L(e){const t=T(e.replace(/[^\p{L}\p{N}_]+/gu," ")).split(" ").map(r=>r.toLowerCase()).filter(r=>/^[a-z0-9_]+$/.test(r)&&r.length>=2&&!q.has(r));return[...new Set(t)].slice(0,12)}p(L,"x"),f(L,"queryTerms");function k(e,t,r=25,a){const c=L(t);if(c.length===0)return[];const s=[c.map(n=>`"${n}"*`).join(" OR "),e.rootId],o=A(a,s),d=e.store.db.prepare(`WITH hits AS (SELECT rowid AS id, bm25(defs_fts, 4.0, 1.0) AS rank FROM defs_fts WHERE defs_fts MATCH ? ORDER BY rank LIMIT 4000)
2
+ SELECT ${g}, hits.rank AS rank FROM hits CROSS JOIN defs d ON d.id = hits.id JOIN files f ON f.blob_id = d.blob_id AND f.root_id = ? JOIN names n ON n.id = d.name_id WHERE 1${o} ORDER BY hits.rank LIMIT 400`).all(...s),u=[];for(const n of d){const i=S(n),I=`${T(i.name)} ${i.container?T(i.container):""} ${(i.doc??"").toLowerCase()} ${i.path.toLowerCase()}`,O=c.filter(b=>I.includes(b)).length/c.length,E=1/(1+(C[i.kind]??3)*.25),h=c.filter(b=>i.path.toLowerCase().includes(b)).length,l=-n.rank*E*(.25+O*O)*(1+.3*h)*(m(i.path)?.5:1);u.push({...i,score:l})}return u.sort((n,i)=>i.score-n.score),u.slice(0,r)}p(k,"P"),f(k,"searchSymbols");function W(e,t,r=10){const a=L(t);if(a.length===0)return[];const c=[e.rootId],s=a.map(o=>(c.push(`%${o}%`),"lower(path) LIKE ?"));return e.store.db.prepare(`SELECT path FROM files WHERE root_id = ? AND (${s.join(" OR ")}) LIMIT 5000`).all(...c).map(o=>({path:o.path,hits:a.filter(d=>o.path.toLowerCase().includes(d)).length})).filter(o=>o.hits>=Math.min(2,a.length)).sort((o,d)=>d.hits-o.hits||o.path.length-d.path.length).slice(0,r).map(o=>o.path)}p(W,"V"),f(W,"searchPaths");const H=3;function w(e,t,r=15){const{db:a}=e.store,c=a.prepare("SELECT blob_id FROM files WHERE root_id = ? AND path = ?").get(e.rootId,t);if(!c)return;const s=new Map,o=f((h,l,b,N)=>{if(h===t)return;let _=s.get(h);_||(_={score:0,via:new Set,uses:!1,usedBy:!1},s.set(h,_)),_.score+=b,_.via.size<6&&_.via.add(l),N==="uses"?_.uses=!0:_.usedBy=!0},"add"),d=a.prepare("SELECT DISTINCT f.path AS path FROM defs d JOIN files f ON f.blob_id = d.blob_id AND f.root_id = ? WHERE d.name_id = ? LIMIT 4"),u=a.prepare("SELECT f.path AS path, count(*) AS uses FROM refs r JOIN files f ON f.blob_id = r.blob_id AND f.root_id = ? WHERE r.name_id = ? GROUP BY f.path LIMIT 5000"),n=a.prepare("SELECT name FROM names WHERE id = ?"),i=a.prepare("SELECT DISTINCT name_id FROM refs WHERE blob_id = ? LIMIT 2000").all(c.blob_id);for(const{name_id:h}of i){const l=d.all(e.rootId,h);if(l.length===0||l.length>H)continue;const b=n.get(h).name;for(const N of l)o(N.path,b,1/l.length,"uses")}const I=a.prepare("SELECT DISTINCT name_id FROM defs WHERE blob_id = ? AND kind NOT IN ('field', 'member', 'variable') LIMIT 1000").all(c.blob_id);for(const{name_id:h}of I){const l=d.all(e.rootId,h);if(l.length>H)continue;const b=n.get(h).name;for(const N of u.all(e.rootId,h))o(N.path,b,Math.min(3,N.uses)/Math.max(1,l.length),"used-by")}const O=[...s.entries()].map(([h,l])=>({path:h,score:l.score,via:[...l.via],direction:l.uses&&l.usedBy?"both":l.uses?"uses":"used-by"})),E=t.replace(/^.*\//,"").replace(/\.[^.]+$/,"").replace(/([._-](test|spec)s?$)|(^test_)/i,"");if(E){const h=a.prepare("SELECT path FROM files WHERE root_id = ? AND path LIKE ? LIMIT 50").all(e.rootId,`%${E}%`);for(const l of h)if(l.path!==t&&l.path.replace(/^.*\//,"").replace(/\.[^.]+$/,"").replace(/([._-](test|spec)s?$)|(^test_)/i,"")===E&&m(l.path)!==m(t)){const b=O.find(N=>N.path===l.path);b?b.score+=5:O.push({path:l.path,score:5,via:[],direction:"test"})}}return O.sort((h,l)=>l.score-h.score||h.path.localeCompare(l.path)).slice(0,r)}p(w,"Y"),f(w,"relatedFiles");function J(e){const{db:t}=e.store,r=f(a=>Number(t.prepare(a).get(e.rootId).n),"count");return{files:r("SELECT count(*) AS n FROM files WHERE root_id = ?"),definitions:r("SELECT count(*) AS n FROM files f JOIN defs d ON d.blob_id = f.blob_id WHERE f.root_id = ?")}}p(J,"j"),f(J,"indexCounts");function y(e,t){return e.store.db.prepare(`SELECT ${g} FROM defs d JOIN names n ON n.id = d.name_id JOIN files f ON f.blob_id = d.blob_id AND f.root_id = ? AND f.path = ? WHERE d.parent = ? ORDER BY d.line`).all(e.rootId,t.path,t.id).map(S)}p(y,"K"),f(y,"childDefinitions");function x(e,t){return e.store.db.prepare("SELECT b.language AS language FROM files f JOIN blobs b ON b.id = f.blob_id WHERE f.root_id = ? AND f.path = ?").get(e.rootId,t)?.language??void 0}p(x,"z"),f(x,"fileLanguage");const B=new Map,G=3e4;function P(e,t,r,a,c=10,s){let o=B.get(t);if(!o||Date.now()-o.at>G){const n=e.store.db.prepare("SELECT f.path AS path, v.vec AS vec FROM files f JOIN blobs b ON b.id = f.blob_id JOIN vectors v ON v.hash = b.hash AND v.model = ? WHERE f.root_id = ?").all(r,e.rootId);o={at:Date.now(),paths:n.map(i=>i.path),vectors:n.map(i=>new Float32Array(i.vec.buffer.slice(i.vec.byteOffset,i.vec.byteOffset+i.vec.byteLength)))},B.set(t,o)}const d=s?.replace(/^\.\/+/,"").replace(/\/+$/,""),u=[];for(let n=0;n<o.vectors.length;n++){const i=o.paths[n];if(d&&d!=="."&&i!==d&&!i.startsWith(`${d}/`))continue;const I=o.vectors[n];if(I.length!==a.length)continue;let O=0;for(let E=0;E<I.length;E++)O+=I[E]*a[E];u.push({path:i,score:O*(m(i)?.9:1)})}return u.sort((n,i)=>i.score-n.score),u.slice(0,c)}p(P,"U"),f(P,"semanticFiles");function j(e,t){return Number(e.store.db.prepare("SELECT count(*) AS n FROM files f JOIN blobs b ON b.id = f.blob_id JOIN vectors v ON v.hash = b.hash AND v.model = ? WHERE f.root_id = ?").get(t,e.rootId).n)}p(j,"G"),f(j,"embeddedFileCount");export{y as childDefinitions,j as embeddedFileCount,x as fileLanguage,$ as fileOutline,M as findDefinitions,D as findReferences,J as indexCounts,m as isTestPath,F as outlineDepths,L as queryTerms,w as relatedFiles,W as searchPaths,k as searchSymbols,P as semanticFiles,R as splitSymbol};
@@ -0,0 +1 @@
1
+ var O=Object.defineProperty;var n=(e,t)=>O(e,"name",{value:t,configurable:!0});var S=Object.defineProperty,a=n((e,t)=>S(e,"name",{value:t,configurable:!0}),"s");import{randomUUID as I}from"node:crypto";import{Worker as R}from"node:worker_threads";import{openStore as A,rootId as B,rootState as E,touchRoot as T}from"./store.js";const b=Symbol.for("dalcode.codeindex.runtime"),j=3;function i(){const e=globalThis;let t=e[b];return t||(t={workerFailures:0,owner:`${process.pid}:${I()}`,readers:new Map,progress:new Map,requested:new Map,waiters:new Map,listeners:new Set,semanticPending:new Map,nextEmbedId:1,embedWaiters:new Map},e[b]=t),t}n(i,"i"),a(i,"runtime");function u(e){const t=i(),r=t.waiters.get(e);if(r){t.waiters.delete(e);for(const o of r)o()}}n(u,"a"),a(u,"settle");function m(e,t){const r=i();r.progress.set(e,t);for(const o of r.listeners)o(e,t)}n(m,"p"),a(m,"setProgress");function y(e){if(e.type==="semantic"){i().semanticPending.set(e.root,e.done?0:e.pending);return}if(e.type==="embedded"){const t=i().embedWaiters.get(e.id);i().embedWaiters.delete(e.id),t?.(e.vector);return}if(e.type==="progress")m(e.root,{total:e.total,pending:e.pending,done:e.done,note:e.note,updatedAt:Date.now()}),e.done&&u(e.root);else if(e.type==="busy"){const t=i().progress.get(e.root);m(e.root,{total:t?.total??0,pending:t?.pending??0,done:!1,busyElsewhere:!0,updatedAt:Date.now()}),u(e.root)}else{const t=i().progress.get(e.root);m(e.root,{total:t?.total??0,pending:t?.pending??0,done:!0,error:e.message,updatedAt:Date.now()}),u(e.root)}}n(y,"W"),a(y,"onMessage");function f(e){const t=i();if(t.worker)return t.worker;if(t.workerFailures>=j)return;const r=new R(new URL("./worker.js",import.meta.url),{resourceLimits:{maxOldGenerationSizeMb:e},stdout:!0,stderr:!0});r.on("message",y);const o=a(s=>{if(t.worker===r){t.worker=void 0,t.workerFailures+=1;for(const[d,c]of t.progress)c.done||m(d,{...c,done:!0,error:s,updatedAt:Date.now()}),u(d)}},"fail");return r.on("error",s=>o(s instanceof Error?s.message:String(s))),r.on("exit",s=>o(`index worker exited (${s})`)),r.unref(),t.worker=r,r}n(f,"m"),a(f,"ensureWorker");function p(e){return{maxFiles:e.maxFiles,maxFileBytes:e.maxFileBytes,maxDiskBytes:e.maxDiskBytes}}n(p,"w"),a(p,"limitsOf");function P(e,t,r,o){const s=i(),d=f(t.maxMemoryMb);if(!d)return Promise.resolve();s.requested.set(e.root,Date.now());const c=s.progress.get(e.root);m(e.root,{total:c?.total??0,pending:c?.pending??0,done:!1,note:c?.note,updatedAt:Date.now()});const l=new Promise(W=>{const w=s.waiters.get(e.root)??[];w.push(W),s.waiters.set(e.root,w)}),g={type:"sync",dbPath:e.dbPath,root:e.root,focus:r,limits:p(t),owner:s.owner,semanticDir:o};return d.postMessage(g),l}n(P,"A"),a(P,"requestSync");function x(e,t,r){const o=f(t.maxMemoryMb);if(!o||r.length===0)return;const s={type:"files",dbPath:e.dbPath,root:e.root,paths:r,limits:p(t)};o.postMessage(s)}n(x,"L"),a(x,"requestFiles");function k(e,t,r){const o=i(),s=f(e.maxMemoryMb);if(!s)return Promise.resolve(void 0);const d=o.nextEmbedId++;return new Promise(c=>{const l=setTimeout(()=>{o.embedWaiters.delete(d),c(void 0)},15e3);l.unref?.(),o.embedWaiters.set(d,g=>{clearTimeout(l),c(g)}),s.postMessage({type:"embed",id:d,semanticDir:t,text:r})})}n(k,"D"),a(k,"embedQuery");function M(e){return i().semanticPending.get(e)}n(M,"E"),a(M,"semanticPendingOf");function h(e){return i().requested.get(e)}n(h,"O"),a(h,"lastRequested");function v(e){return i().progress.get(e)}n(v,"j"),a(v,"progressOf");function D(e){const t=i();return t.listeners.add(e),()=>t.listeners.delete(e)}n(D,"C"),a(D,"onProgress");function q(e){const t=i();let r=t.readers.get(e.dbPath);if(!r){try{r=A(e.dbPath)}catch{return}t.readers.set(e.dbPath,r)}const o=B(r,e.root);if(!(o<0))return T(r,o),{store:r,rootId:o,state:E(r,o)}}n(q,"B"),a(q,"openIndex");async function F(){const e=i(),t=e.worker;e.worker=void 0,t&&(t.postMessage({type:"stop"}),await t.terminate().catch(()=>{}));for(const r of e.readers.values())try{r.db.close()}catch{}e.readers.clear(),e.progress.clear(),e.requested.clear(),e.semanticPending.clear();for(const r of e.embedWaiters.values())r(void 0);e.embedWaiters.clear();for(const r of[...e.waiters.keys()])u(r);e.workerFailures=0}n(F,"T"),a(F,"shutdownRuntime");export{k as embedQuery,h as lastRequested,p as limitsOf,D as onProgress,q as openIndex,v as progressOf,x as requestFiles,P as requestSync,M as semanticPendingOf,F as shutdownRuntime};
@@ -0,0 +1 @@
1
+ var b=Object.defineProperty;var u=(t,e)=>b(t,"name",{value:e,configurable:!0});var x=Object.defineProperty,d=u((t,e)=>x(t,"name",{value:e,configurable:!0}),"f");import{spawnSync as S}from"node:child_process";import{readdirSync as z,readFileSync as D,statSync as k}from"node:fs";import{join as h,relative as g,sep as v}from"node:path";import E from"ignore";import{languageForPath as W}from"./languages.js";const y=new Set(["node_modules","bower_components","jspm_packages","vendor","dist","build","out","target","coverage","__pycache__","site-packages",".venv","venv",".git",".hg",".svn",".next",".nuxt",".cache",".gradle",".idea",".vscode-test","Pods","DerivedData"]);function j(t){if(!W(t)||/\.min\.(js|mjs|cjs)$/i.test(t)||/[-.]bundle\.js$/i.test(t))return!1;for(const e of t.split("/").slice(0,-1))if(y.has(e))return!1;return!0}u(j,"_"),d(j,"wanted");function w(t){const e=S("git",["-c","core.fsmonitor=false","-C",t,"ls-files","-z","--cached","--others","--exclude-standard"],{encoding:"utf8",maxBuffer:1073741824,windowsHide:!0,stdio:["ignore","pipe","ignore"]});if(!(e.status!==0||typeof e.stdout!="string"))return e.stdout.split("\0").filter(Boolean)}u(w,"k"),d(w,"gitPaths");function P(t,e){const o=[],a=[{dir:t,rules:[]}];for(;a.length>0&&o.length<e;){const{dir:c,rules:f}=a.pop();let r=f;try{const i=D(h(c,".gitignore"),"utf8");r=[...f,{base:c,matcher:E().add(i)}]}catch{}let l;try{l=z(c,{withFileTypes:!0})}catch{continue}for(const i of l){const n=h(c,i.name),s=i.isDirectory();!s&&!i.isFile()||s&&(y.has(i.name)||i.name.startsWith("."))||r.some(({base:m,matcher:_})=>{const p=g(m,n).split(v).join("/");return p!==""&&_.ignores(s?`${p}/`:p)})||(s?a.push({dir:n,rules:r}):o.push(g(t,n).split(v).join("/")))}}return o}u(P,"z"),d(P,"walkPaths");function F(t,e,o){const a=w(t),c=a?"git":"walk",f=(a??P(t,e.maxFiles*4)).filter(j),r=o?g(t,o).split(v).join("/"):"";if(r&&!r.startsWith("..")){const n=`${r}/`;f.sort((s,m)=>+!s.startsWith(n)-+!m.startsWith(n))}const l=[];let i=0;for(const n of f){if(l.length>=e.maxFiles){i+=1;continue}let s;try{s=k(h(t,n))}catch{continue}!s.isFile()||s.size>e.maxFileBytes||s.size===0||l.push({path:n,size:s.size,mtimeMs:Math.trunc(s.mtimeMs)})}return{files:l,truncated:i,method:c}}u(F,"E"),d(F,"scanProject");export{y as SKIPPED_DIRECTORIES,F as scanProject};
@@ -0,0 +1,2 @@
1
+ var H=Object.defineProperty;var f=(n,o)=>H(n,"name",{value:o,configurable:!0});var J=Object.defineProperty,d=f((n,o)=>J(n,"name",{value:o,configurable:!0}),"f");import{createHash as U}from"node:crypto";import{existsSync as D,mkdirSync as $,readFileSync as S,renameSync as G,rmSync as _,writeFileSync as M}from"node:fs";import{createRequire as K}from"node:module";import{dirname as T,join as l}from"node:path";import{gunzipSync as Z}from"node:zlib";const k="all-MiniLM-L6-v2-int8",Q=384,V=128,y="751bff37182d3f1213fa05d7196b954e230abad9",Y=[{urls:["https://registry.npmjs.org/onnxruntime-web/-/onnxruntime-web-1.30.0.tgz","https://registry.npmmirror.com/onnxruntime-web/-/onnxruntime-web-1.30.0.tgz"],sha256:"d2228df7e4616bc3348bf504ee888f3bec43789a273f0a63f3e68d203ce3bf71",extract:[{from:"package/package.json",to:"node_modules/onnxruntime-web/package.json"},{from:"package/dist/ort.node.min.js",to:"node_modules/onnxruntime-web/dist/ort.node.min.js"},{from:"package/dist/ort-wasm-simd-threaded.mjs",to:"node_modules/onnxruntime-web/dist/ort-wasm-simd-threaded.mjs"},{from:"package/dist/ort-wasm-simd-threaded.wasm",to:"node_modules/onnxruntime-web/dist/ort-wasm-simd-threaded.wasm"}]},{urls:["https://registry.npmjs.org/onnxruntime-common/-/onnxruntime-common-1.30.0.tgz","https://registry.npmmirror.com/onnxruntime-common/-/onnxruntime-common-1.30.0.tgz"],sha256:"7906c439e0d3e0f4048caa23b64cdfadc0f455c377f579ce1ab2a4b778f07d5f",extract:[{from:"package/",to:"node_modules/onnxruntime-common/"}]},{urls:[`https://huggingface.co/Xenova/all-MiniLM-L6-v2/resolve/${y}/onnx/model_quantized.onnx`,`https://hf-mirror.com/Xenova/all-MiniLM-L6-v2/resolve/${y}/onnx/model_quantized.onnx`],sha256:"afdb6f1a0e45b715d0bb9b11772f032c399babd23bfc31fed1c170afc848bdb1",to:"model/model_quantized.onnx"},{urls:[`https://huggingface.co/Xenova/all-MiniLM-L6-v2/resolve/${y}/vocab.txt`,`https://hf-mirror.com/Xenova/all-MiniLM-L6-v2/resolve/${y}/vocab.txt`],sha256:"07eced375cec144d27c900241f3e339478dec958f92fddbc551f295c992038a3",to:"model/vocab.txt"}];function B(n){return l(n,"codeindex","semantic")}f(B,"te"),d(B,"semanticDir");const N="installed.json";function j(n){try{return JSON.parse(S(l(n,N),"utf8")).model===k}catch{return!1}}f(j,"R"),d(j,"semanticInstalled");function P(n){return U("sha256").update(n).digest("hex")}f(P,"C"),d(P,"sha256");function q(n){const o=new Map;let s=0;for(;s+512<=n.length;){const t=n.subarray(s,s+512);if(t.every(c=>c===0))break;const e=t.subarray(0,100).toString("utf8").replace(/\0.*$/s,""),i=t.subarray(345,500).toString("utf8").replace(/\0.*$/s,""),a=Number.parseInt(t.subarray(124,136).toString("utf8").replace(/\0.*$/s,"").trim()||"0",8),r=String.fromCharCode(t[156]||48),m=i?`${i}/${e}`:e;s+=512,(r==="0"||r==="\0")&&o.set(m,Buffer.from(n.subarray(s,s+a))),s+=Math.ceil(a/512)*512}return o}f(q,"X"),d(q,"untar");async function A(n,o){const s=[];for(const t of n.urls)try{const e=await o(t,{redirect:"follow"});if(!e.ok){s.push(`${t}: HTTP ${e.status}`);continue}const i=Buffer.from(await e.arrayBuffer()),a=P(i);if(a!==n.sha256){s.push(`${t}: sha256 ${a} != ${n.sha256}`);continue}return i}catch(e){s.push(`${t}: ${e instanceof Error?e.message:String(e)}`)}throw new Error(s.join("; "))}f(A,"W"),d(A,"download");async function O(n,o={}){const s=o.fetchImpl??fetch,t=`${n}.partial`;_(t,{recursive:!0,force:!0}),$(t,{recursive:!0,mode:448});try{for(const e of Y){o.onProgress?.(e.urls[0]);const i=await A(e,s);if(e.to){$(T(l(t,e.to)),{recursive:!0}),M(l(t,e.to),i);continue}const a=q(Z(i));for(const r of e.extract??[]){const m=r.from.endsWith("/")?[...a.keys()].filter(c=>c.startsWith(r.from)):a.has(r.from)?[r.from]:[];if(m.length===0)throw new Error(`${r.from} missing from ${e.urls[0]}`);for(const c of m){const b=l(t,r.to+(r.from.endsWith("/")?c.slice(r.from.length):""));if(!b.startsWith(t))throw new Error(`unsafe path in archive: ${c}`);$(T(b),{recursive:!0}),M(b,a.get(c))}}}M(l(t,N),JSON.stringify({model:k,installedAt:new Date().toISOString()})),_(n,{recursive:!0,force:!0}),G(t,n)}catch(e){throw _(t,{recursive:!0,force:!0}),e}}f(O,"ne"),d(O,"installSemantic");function C(n){const o=[],s=n.toLowerCase().normalize("NFD").replace(/[̀-ͯ]/g,"");for(const t of s.split(/\s+/)){let e="";for(const i of t)/[\p{P}\p{S}]/u.test(i)||/[一-鿿]/.test(i)?(e&&o.push(e),o.push(i),e=""):e+=i;e&&o.push(e)}return o}f(C,"U"),d(C,"basicTokens");function z(n,o,s=V){const t=n.get("[UNK]")??100,e=[n.get("[CLS]")??101];for(const i of C(o)){if(e.length>=s-1)break;if(i.length>100){e.push(t);continue}const a=[];let r=0;for(;r<i.length;){let m=i.length,c;for(;r<m&&(c=n.get((r>0?"##":"")+i.slice(r,m)),c===void 0);)m-=1;if(c===void 0){a.length=0,a.push(t);break}a.push(c),r=m}e.push(...a)}return e.length=Math.min(e.length,s-1),e.push(n.get("[SEP]")??102),e}f(z,"H"),d(z,"tokenize");function F(n,o){const s=[n.replace(/\.[^./]+$/,"").split(/[/._-]+/).join(" ")];for(const t of o){const e=t.name.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/_/g," ");s.push(t.doc?`${e}: ${t.doc}`:e)}return s.join(". ")}f(F,"re"),d(F,"fileText");async function W(n){const o=K(l(n,"node_modules","loader.cjs"))("onnxruntime-web");o.env.wasm.numThreads=1;const s=await o.InferenceSession.create(S(l(n,"model","model_quantized.onnx"))),t=new Map;S(l(n,"model","vocab.txt"),"utf8").split(`
2
+ `).forEach((a,r)=>{a&&t.set(a.replace(/\r$/,""),r)});let e=Promise.resolve();const i=d(async a=>{if(a.length===0)return[];const r=a.map(h=>z(t,h)),m=Math.max(...r.map(h=>h.length)),c=r.length,b=new BigInt64Array(c*m),E=new BigInt64Array(c*m);r.forEach((h,p)=>{h.forEach((v,g)=>{b[p*m+g]=BigInt(v),E[p*m+g]=1n})});const I=(await s.run({input_ids:new o.Tensor("int64",b,[c,m]),attention_mask:new o.Tensor("int64",E,[c,m]),token_type_ids:new o.Tensor("int64",new BigInt64Array(c*m),[c,m])})).last_hidden_state,w=I.dims[2],L=[];for(let h=0;h<c;h++){const p=new Float32Array(w),v=r[h].length;for(let u=0;u<v;u++){const R=(h*m+u)*w;for(let x=0;x<w;x++)p[x]+=I.data[R+x]}let g=0;for(let u=0;u<w;u++)g+=p[u]*p[u];g=Math.sqrt(g)||1;for(let u=0;u<w;u++)p[u]/=g;L.push(p)}return L},"run");return a=>{const r=e.then(()=>i(a));return e=r.catch(()=>{}),r}}f(W,"oe"),d(W,"createEmbedder");function X(n){return j(n)&&D(l(n,"node_modules","onnxruntime-web","dist","ort-wasm-simd-threaded.wasm"))&&D(l(n,"model","model_quantized.onnx"))}f(X,"se"),d(X,"semanticRuntimePresent");export{Q as EMBEDDING_DIMENSIONS,k as MODEL_ID,W as createEmbedder,F as fileText,O as installSemantic,B as semanticDir,j as semanticInstalled,X as semanticRuntimePresent,z as tokenize};
@@ -0,0 +1 @@
1
+ var c=Object.defineProperty;var r=(e,n)=>c(e,"name",{value:n,configurable:!0});var p=Object.defineProperty,a=r((e,n)=>p(e,"name",{value:n,configurable:!0}),"i");import{createRequire as f}from"node:module";const u=f(import.meta.url);let i;function o(e,n){const t=typeof e=="string"?e:e.message;return(typeof e!="string"?e.name:typeof n[0]=="string"?n[0]:n[0]?.type)==="ExperimentalWarning"&&/sqlite/i.test(t)}r(o,"a"),a(o,"isSqliteExperimentalWarning");function s(){if(i)return i;const e=process.emitWarning;process.emitWarning=function(n,...t){if(!o(n,t))return e.call(this,n,...t)};try{i=u("node:sqlite")}finally{process.emitWarning=e}return i}r(s,"p"),a(s,"loadSqlite");function l(e,n){const{DatabaseSync:t}=s();return new t(e,{readOnly:n?.readOnly===!0})}r(l,"d"),a(l,"openSqlite");export{l as openSqlite};
@@ -0,0 +1,33 @@
1
+ var D=Object.defineProperty;var E=(r,e)=>D(r,"name",{value:e,configurable:!0});var C=Object.defineProperty,a=E((r,e)=>C(r,"name",{value:e,configurable:!0}),"i");import{chmodSync as g,closeSync as w,constants as R,fstatSync as y,lstatSync as B,mkdirSync as W,openSync as X,statSync as G}from"node:fs";import{dirname as v}from"node:path";import{openSqlite as H}from"./sqlite.js";const d=2,l=2,x=`
2
+ CREATE TABLE IF NOT EXISTS meta (key TEXT PRIMARY KEY, value TEXT NOT NULL);
3
+ CREATE TABLE IF NOT EXISTS roots (
4
+ id INTEGER PRIMARY KEY, path TEXT NOT NULL UNIQUE,
5
+ total INTEGER NOT NULL DEFAULT 0, pending INTEGER NOT NULL DEFAULT 0, complete INTEGER NOT NULL DEFAULT 0,
6
+ last_scan INTEGER NOT NULL DEFAULT 0, last_used INTEGER NOT NULL DEFAULT 0, note TEXT,
7
+ owner TEXT, heartbeat INTEGER NOT NULL DEFAULT 0
8
+ );
9
+ CREATE TABLE IF NOT EXISTS names (id INTEGER PRIMARY KEY, name TEXT NOT NULL UNIQUE);
10
+ CREATE INDEX IF NOT EXISTS names_nocase ON names(name COLLATE NOCASE);
11
+ CREATE TABLE IF NOT EXISTS blobs (id INTEGER PRIMARY KEY, hash TEXT NOT NULL UNIQUE, language TEXT);
12
+ CREATE TABLE IF NOT EXISTS files (
13
+ root_id INTEGER NOT NULL, path TEXT NOT NULL, blob_id INTEGER NOT NULL,
14
+ size INTEGER NOT NULL, mtime_ms INTEGER NOT NULL, PRIMARY KEY (root_id, path)
15
+ ) WITHOUT ROWID;
16
+ CREATE INDEX IF NOT EXISTS files_blob ON files(blob_id);
17
+ CREATE TABLE IF NOT EXISTS defs (
18
+ id INTEGER PRIMARY KEY, blob_id INTEGER NOT NULL, name_id INTEGER NOT NULL, kind TEXT NOT NULL,
19
+ line INTEGER NOT NULL, end_line INTEGER NOT NULL, col INTEGER NOT NULL, parent INTEGER,
20
+ container TEXT, signature TEXT NOT NULL, doc TEXT
21
+ );
22
+ CREATE INDEX IF NOT EXISTS defs_name ON defs(name_id);
23
+ CREATE INDEX IF NOT EXISTS defs_blob ON defs(blob_id);
24
+ CREATE TABLE IF NOT EXISTS refs (
25
+ name_id INTEGER NOT NULL, blob_id INTEGER NOT NULL, line INTEGER NOT NULL, col INTEGER NOT NULL,
26
+ kind TEXT NOT NULL, caller INTEGER, PRIMARY KEY (name_id, blob_id, line, col, kind)
27
+ ) WITHOUT ROWID;
28
+ CREATE INDEX IF NOT EXISTS refs_blob ON refs(blob_id);
29
+ CREATE TABLE IF NOT EXISTS vectors (hash TEXT PRIMARY KEY, model TEXT NOT NULL, vec BLOB NOT NULL);
30
+ CREATE VIRTUAL TABLE IF NOT EXISTS defs_fts USING fts5(
31
+ words, doc, content='', contentless_delete=1, tokenize='porter unicode61'
32
+ );
33
+ `,P=["vectors","defs_fts","refs","defs","files","blobs","names","roots","meta"];function c(r){if(!r.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'meta'").get())return;const e=r.prepare("SELECT value FROM meta WHERE key = 'schema'").get(),t=Number(e?.value);return Number.isInteger(t)&&t>0?t:void 0}E(c,"u"),a(c,"storedSchema");function I(r){const e=v(r);if(W(e,{recursive:!0,mode:448}),!B(e).isDirectory())throw new Error(`index directory is not a real directory: ${e}`);const t=X(r,R.O_RDWR|R.O_CREAT|(R.O_NOFOLLOW??0),384);try{if(!y(t).isFile())throw new Error("index database path is not a regular file")}finally{w(t)}process.platform!=="win32"&&g(r,384)}E(I,"U"),a(I,"secureFile");function L(r){const e=r.prepare("SELECT value FROM meta WHERE key = 'extractor'").get();if(!(Number(e?.value)>=l)){r.exec("BEGIN IMMEDIATE");try{Number(r.prepare("SELECT value FROM meta WHERE key = 'extractor'").get()?.value)>=l||(r.exec("DELETE FROM defs_fts; DELETE FROM refs; DELETE FROM defs; DELETE FROM files; DELETE FROM blobs;"),r.exec("UPDATE roots SET total = 0, pending = 0, complete = 0, last_scan = 0"),r.prepare("INSERT OR REPLACE INTO meta(key, value) VALUES ('extractor', ?)").run(String(l))),r.exec("COMMIT")}catch(t){throw r.exec("ROLLBACK"),t}}}E(L,"F"),a(L,"resetIfExtractorChanged");function O(r){I(r);const e=H(r);try{e.exec("PRAGMA busy_timeout = 10000"),e.exec("PRAGMA journal_mode = WAL"),e.exec("PRAGMA synchronous = NORMAL");const t=c(e);if(t!==void 0&&t>d)return{db:e,path:r,readOnly:!0};if(t===d)return L(e),{db:e,path:r,readOnly:!1};e.exec("BEGIN IMMEDIATE");try{const o=c(e);if(o===void 0||o<d){for(const s of P)e.exec(`DROP TABLE IF EXISTS ${s}`);e.exec(x),e.prepare("INSERT INTO meta(key, value) VALUES ('schema', ?)").run(String(d)),e.prepare("INSERT INTO meta(key, value) VALUES ('extractor', ?)").run(String(l))}e.exec("COMMIT")}catch(o){throw e.exec("ROLLBACK"),o}return{db:e,path:r,readOnly:c(e)!==d}}catch(t){throw e.close(),t}}E(O,"C"),a(O,"openStore");function u(r){let e=0;for(const t of["","-wal","-shm"])try{e+=G(r+t).size}catch{}return e}E(u,"v"),a(u,"storeBytes");function b(r,e){const t=r.db.prepare("SELECT id FROM roots WHERE path = ?").get(e);return t?t.id:r.readOnly?-1:(r.db.prepare("INSERT OR IGNORE INTO roots(path) VALUES (?)").run(e),r.db.prepare("SELECT id FROM roots WHERE path = ?").get(e).id)}E(b,"B"),a(b,"rootId");function m(r,e){const t=r.db.prepare("SELECT * FROM roots WHERE id = ?").get(e);if(t)return{id:t.id,path:t.path,total:t.total,pending:t.pending,complete:t.complete===1,lastScan:t.last_scan,note:t.note??void 0,owner:t.owner??void 0,heartbeat:t.heartbeat}}E(m,"W"),a(m,"rootState");const f=3e4;function S(r,e,t,o=Date.now()){const{db:s}=r;s.exec("BEGIN IMMEDIATE");try{const i=s.prepare("SELECT owner, heartbeat FROM roots WHERE id = ?").get(e),T=!i?.owner||i.owner===t||o-i.heartbeat>f;return T&&s.prepare("UPDATE roots SET owner = ?, heartbeat = ? WHERE id = ?").run(t,o,e),s.exec("COMMIT"),T}catch(i){throw s.exec("ROLLBACK"),i}}E(S,"X"),a(S,"acquireRoot");function h(r,e,t){r.db.prepare("UPDATE roots SET owner = NULL WHERE id = ? AND owner = ?").run(e,t)}E(h,"G"),a(h,"releaseRoot");function A(r,e,t,o=Date.now()){return Number(r.db.prepare("UPDATE roots SET heartbeat = ? WHERE id = ? AND owner = ?").run(o,e,t).changes)>0}E(A,"H"),a(A,"heartbeat");function U(r,e,t){const o=[],s=[];t.total!==void 0&&(o.push("total = ?"),s.push(t.total)),t.pending!==void 0&&(o.push("pending = ?"),s.push(t.pending)),t.complete!==void 0&&(o.push("complete = ?"),s.push(t.complete?1:0)),t.lastScan!==void 0&&(o.push("last_scan = ?"),s.push(t.lastScan)),t.note!==void 0&&(o.push("note = ?"),s.push(t.note)),o.length!==0&&r.db.prepare(`UPDATE roots SET ${o.join(", ")} WHERE id = ?`).run(...s,e)}E(U,"P"),a(U,"updateRootProgress");function _(r,e,t=Date.now()){r.readOnly||r.db.prepare("UPDATE roots SET last_used = ? WHERE id = ?").run(t,e)}E(_,"k"),a(_,"touchRoot");function M(r,e){const t=new Map,o=r.db.prepare("SELECT path, size, mtime_ms FROM files WHERE root_id = ?").all(e);for(const s of o)t.set(s.path,{size:s.size,mtimeMs:s.mtime_ms});return t}E(M,"V"),a(M,"fileStamps");function N(r){const e=r.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").split(/[^A-Za-z0-9]+/).filter(Boolean).map(t=>t.toLowerCase());return[r,...e].join(" ")}E(N,"p"),a(N,"identifierWords");class k{static{E(this,"z")}static{a(this,"StoreWriter")}store;nameIds=new Map;statements;constructor(e){if(e.readOnly)throw new Error("index was written by a newer DAL; it is read-only");this.store=e,this.statements=this.prepare()}prepare(){const{db:e}=this.store;return{findName:e.prepare("SELECT id FROM names WHERE name = ?"),insertName:e.prepare("INSERT INTO names(name) VALUES (?)"),findBlob:e.prepare("SELECT id FROM blobs WHERE hash = ?"),insertBlob:e.prepare("INSERT INTO blobs(hash, language) VALUES (?, ?)"),insertDef:e.prepare("INSERT INTO defs(blob_id, name_id, kind, line, end_line, col, parent, container, signature, doc) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"),insertFts:e.prepare("INSERT INTO defs_fts(rowid, words, doc) VALUES (?, ?, ?)"),insertRef:e.prepare("INSERT OR IGNORE INTO refs(blob_id, name_id, line, col, kind, caller) VALUES (?, ?, ?, ?, ?, ?)"),fileBlob:e.prepare("SELECT blob_id FROM files WHERE root_id = ? AND path = ?"),upsertFile:e.prepare("INSERT INTO files(root_id, path, blob_id, size, mtime_ms) VALUES (?, ?, ?, ?, ?) ON CONFLICT(root_id, path) DO UPDATE SET blob_id = excluded.blob_id, size = excluded.size, mtime_ms = excluded.mtime_ms"),deleteFile:e.prepare("DELETE FROM files WHERE root_id = ? AND path = ?"),blobUsed:e.prepare("SELECT 1 FROM files WHERE blob_id = ? LIMIT 1"),blobDefIds:e.prepare("SELECT id FROM defs WHERE blob_id = ?"),deleteFts:e.prepare("DELETE FROM defs_fts WHERE rowid = ?"),deleteDefs:e.prepare("DELETE FROM defs WHERE blob_id = ?"),deleteRefs:e.prepare("DELETE FROM refs WHERE blob_id = ?"),deleteBlob:e.prepare("DELETE FROM blobs WHERE id = ?"),blobHash:e.prepare("SELECT hash FROM blobs WHERE id = ?"),deleteVector:e.prepare("DELETE FROM vectors WHERE hash = ?")}}nameId(e){const t=this.nameIds.get(e);if(t!==void 0)return t;const o=this.statements.findName.get(e),s=o?o.id:Number(this.statements.insertName.run(e).lastInsertRowid);return this.nameIds.size>2e5&&this.nameIds.clear(),this.nameIds.set(e,s),s}knownBlob(e){return this.statements.findBlob.get(e)?.id}addBlob(e,t,o){const s=this.statements,i=Number(s.insertBlob.run(e,t??null).lastInsertRowid),T=[];for(const n of o.definitions){const F=n.parent>=0?T[n.parent]??null:null,p=Number(s.insertDef.run(i,this.nameId(n.name),n.kind,n.line,n.endLine,n.column,F,n.container??null,n.signature,n.doc??null).lastInsertRowid);T.push(p),s.insertFts.run(p,`${N(n.name)} ${n.container?N(n.container):""}`,n.doc??"")}for(const n of o.references)s.insertRef.run(i,this.nameId(n.name),n.line,n.column,n.kind,n.caller>=0?T[n.caller]??null:null);return i}dropBlobIfUnused(e){const t=this.statements;if(t.blobUsed.get(e))return;for(const s of t.blobDefIds.all(e))t.deleteFts.run(s.id);t.deleteDefs.run(e),t.deleteRefs.run(e);const o=t.blobHash.get(e)?.hash;o&&t.deleteVector.run(o),t.deleteBlob.run(e)}setFile(e,t,o,s){const i=this.statements,T=i.fileBlob.get(e,t)?.blob_id;i.upsertFile.run(e,t,o,s.size,Math.trunc(s.mtimeMs)),T!==void 0&&T!==o&&this.dropBlobIfUnused(T)}removeFile(e,t){const o=this.statements,s=o.fileBlob.get(e,t)?.blob_id;s!==void 0&&(o.deleteFile.run(e,t),this.dropBlobIfUnused(s))}transaction(e){const{db:t}=this.store;t.exec("BEGIN IMMEDIATE");try{const o=e();return t.exec("COMMIT"),o}catch(o){throw t.exec("ROLLBACK"),o}}}export{l as EXTRACTOR_VERSION,f as LOCK_STALE_MS,d as STORE_SCHEMA_VERSION,k as StoreWriter,S as acquireRoot,M as fileStamps,A as heartbeat,N as identifierWords,O as openStore,h as releaseRoot,b as rootId,m as rootState,u as storeBytes,_ as touchRoot,U as updateRootProgress};
@@ -0,0 +1 @@
1
+ var S=Object.defineProperty;var r=(t,e)=>S(t,"name",{value:e,configurable:!0});var v=Object.defineProperty,o=r((t,e)=>v(t,"name",{value:e,configurable:!0}),"r");import{parentPort as D}from"node:worker_threads";import{embedRoot as M,syncRoot as x,updateFiles as B}from"./indexer.js";import{createEmbedder as E,MODEL_ID as O}from"./semantic.js";import{openStore as I}from"./store.js";const w=D,b=new Map;let i=!1,u=!1;const f=[],c=new Map,l=new Map;function y(t){let e=l.get(t);return e||(e=E(t),l.set(t,e),e.catch(()=>l.delete(t))),e}r(y,"f"),o(y,"embedder");function s(t){w?.postMessage(t)}r(s,"o"),o(s,"post");function h(t){let e=b.get(t);return e||(e=I(t),b.set(t,e)),e}r(h,"b"),o(h,"store");function m(t){return t instanceof Error?t.message:String(t)}r(m,"g"),o(m,"errorText");async function d(){for(;f.length>0;){const t=f.shift();try{const e=h(t.dbPath);e.readOnly||await B(e,t.root,t.paths,t.limits)}catch(e){s({type:"error",root:t.root,message:m(e)})}}}r(d,"d"),o(d,"drainFiles");async function g(){if(!u){u=!0;try{for(await d();c.size>0&&!i;){const[t,e]=c.entries().next().value;c.delete(t);try{const a=h(e.dbPath);if(a.readOnly)continue;if(!await x({store:a,rootPath:e.root,focus:e.focus,limits:e.limits,owner:e.owner,shouldStop:o(()=>i,"shouldStop"),betweenBatches:o(async()=>{await new Promise(n=>setImmediate(n)),await d()},"betweenBatches"),onProgress:o(n=>s({type:"progress",...n}),"onProgress")}))s({type:"busy",root:e.root});else if(e.semanticDir&&!i){const n=await y(e.semanticDir);await M({store:a,rootPath:e.root,model:O,embed:n,shouldStop:o(()=>i||c.size>0,"shouldStop"),betweenBatches:o(async()=>{await new Promise(p=>setImmediate(p)),await d()},"betweenBatches"),onProgress:o((p,P)=>s({type:"semantic",root:e.root,pending:p,done:P}),"onProgress")})}}catch(a){s({type:"error",root:e.root,message:m(a)})}await d()}}finally{u=!1}}}r(g,"v"),o(g,"runQueue"),w?.on("message",t=>{if(t.type==="stop"){i=!0;return}if(t.type==="embed"){y(t.semanticDir).then(e=>e([t.text])).then(([e])=>s({type:"embedded",id:t.id,vector:e}),e=>s({type:"embedded",id:t.id,error:m(e)}));return}t.type==="files"?f.push(t):c.set(`${t.dbPath}\0${t.root}`,t),g()});
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-compat",
3
- "version": "1.0.44",
3
+ "version": "1.0.46",
4
4
  "private": true,
5
5
  "description": "Claude Code compatibility: the user's and project's .claude/rules/ and .claude/CLAUDE.md apply in DAL. Grown from the claude-rules extension example.",
6
6
  "type": "module",
@@ -18,7 +18,7 @@
18
18
  ]
19
19
  },
20
20
  "dependencies": {
21
- "@dalcode/dal-pi-kit": "1.0.44",
21
+ "@dalcode/dal-pi-kit": "1.0.46",
22
22
  "minimatch": "10.2.6"
23
23
  },
24
24
  "peerDependencies": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-dap",
3
- "version": "1.0.44",
3
+ "version": "1.0.46",
4
4
  "private": true,
5
5
  "description": "Debugger for DAL: breakpoints, stepping, call stacks and variables in Node.js and Python programs over the Debug Adapter Protocol, installing the adapter on first use. The DAP client is adapted from oh-my-pi's src/dap (MIT).",
6
6
  "license": "MIT",
@@ -24,7 +24,7 @@
24
24
  ]
25
25
  },
26
26
  "dependencies": {
27
- "@dalcode/dal-pi-kit": "1.0.44",
27
+ "@dalcode/dal-pi-kit": "1.0.46",
28
28
  "typebox": "1.3.27"
29
29
  },
30
30
  "peerDependencies": {
@@ -1,2 +1,2 @@
1
- var M=Object.defineProperty;var i=(e,r)=>M(e,"name",{value:r,configurable:!0});var L=Object.defineProperty,l=i((e,r)=>L(e,"name",{value:r,configurable:!0}),"l");import{spawn as T}from"node:child_process";import{createHash as U,randomBytes as _}from"node:crypto";import{existsSync as G,mkdirSync as v,readFileSync as H,renameSync as W,rmSync as F,writeFileSync as S}from"node:fs";import{join as m}from"node:path";import{gunzipSync as J}from"node:zlib";import{t as p}from"@dalcode/dal-pi-kit";import{getAgentDir as V}from"@earendil-works/pi-coding-agent";const A=["https://registry.npmmirror.com","https://registry.npmjs.org"];function B(e,r,t){const o=r.includes("/")?r.slice(r.indexOf("/")+1):r;return`${e.replace(/\/+$/,"")}/${r}/-/${o}-${t}.tgz`}i(B,"D"),l(B,"npmTarballUrl");const Y={id:"debugpy-1.8.21",label:"debugpy 1.8.21",file:"debugpy-1.8.21-py2.py3-none-any.whl",sha256:"b1e37d333663c8851516a47364ef473da127f9caebe4417e6df6f5825a7e9a92",bytes:5374e3,urls:["https://mirrors.aliyun.com/pypi/packages/95/51/67e7cf11a53e40694f720457d5b3a1cdaaa3d5a9a633e482f225456b93ff/debugpy-1.8.21-py2.py3-none-any.whl","https://files.pythonhosted.org/packages/95/51/67e7cf11a53e40694f720457d5b3a1cdaaa3d5a9a633e482f225456b93ff/debugpy-1.8.21-py2.py3-none-any.whl"],format:"wheel"},q={id:"js-debug-1.140.0",label:"vscode-js-debug 1.140.0",file:"js-debug-dap-v1.140.0.tar.gz",sha256:"27dab92937ec1ab35821ae955aac867544fe06a1b6307229049f2d789af10968",bytes:1249709,urls:["https://github.com/microsoft/vscode-js-debug/releases/download/v1.140.0/js-debug-dap-v1.140.0.tar.gz"],format:"tar.gz",npm:{name:"@deepailab/js-debug-dap",version:"1.140.0"}},x=20*1024*1024,K=12e4,P=".dal-installed";function E(){return m(V(),"tools","dap")}i(E,"E"),l(E,"adapterInstallRoot");function y(e,r=E()){const t=m(r,e.id);try{return H(m(t,P),"utf8").trim()===e.sha256?t:void 0}catch{return}}i(y,"w"),l(y,"installedArtifactDir");function k(){return process.env.DALCODE_MCP_MIRROR?.trim().toLowerCase()==="off"}i(k,"F"),l(k,"mirrorsOff");function j(){const e=process.env.PI_OFFLINE?.toLowerCase();return e==="1"||e==="true"||e==="yes"}i(j,"j"),l(j,"offline");function C(e){try{return new URL(e).host}catch{return e}}i(C,"v"),l(C,"hostOf");function I(e){if(k())return e.urls.slice(-1).map(t=>({url:t,inNpmPackage:!1}));const r=e.npm;return[...r?A.map(t=>({url:B(t,r.name,r.version),inNpmPackage:!0})):[],...e.urls.map(t=>({url:t,inNpmPackage:!1}))]}i(I,"T"),l(I,"sourcesOf");function D(e,r){let t=0,o;for(;t+512<=e.length;){const d=e.subarray(t,t+512);if(d.every(b=>b===0))return;const c=l((b,h)=>{const w=d.subarray(b,b+h),g=w.indexOf(0);return w.subarray(0,g===-1?h:g).toString("utf8")},"field"),n=Number.parseInt(c(124,12).trim()||"0",8),a=t+512;if(!Number.isFinite(n)||n<0||a+n>e.length)return;const u=String.fromCharCode(d[156]??0),s=c(345,155),f=o??(s?`${s}/${c(0,100)}`:c(0,100));if(o=void 0,u==="x")o=/(?:^|\n)\d+ path=([^\n]*)\n/.exec(e.subarray(a,a+n).toString("utf8"))?.[1];else if((u==="0"||u==="\0")&&f===r)return Buffer.from(e.subarray(a,a+n));t=a+Math.ceil(n/512)*512}}i(D,"U"),l(D,"tarMember");function O(e,r){let t;try{t=J(e,{maxOutputLength:x*2})}catch{throw new Error(p("npm \u5305\u65E0\u6CD5\u89E3\u5F00"))}const o=D(t,`package/${r.file}`);if(!o)throw new Error(p("npm \u5305\u91CC\u6CA1\u6709 {file}").replace("{file}",r.file));return o}i(O,"G"),l(O,"fromNpmPackage");async function R(e,r,t,o){const d=e.url,c=AbortSignal.timeout(K),n=await t(d,{signal:o?AbortSignal.any([o,c]):c});if(!n.ok)throw await n.body?.cancel(),new Error(`HTTP ${n.status}`);const a=n.body?.getReader();if(!a)throw new Error(p("\u54CD\u5E94\u6CA1\u6709\u5185\u5BB9"));const u=[];let s=0;for(;;){const{done:w,value:g}=await a.read();if(w)break;if(s+=g.byteLength,s>x)throw await a.cancel(),new Error(p("\u6587\u4EF6\u8D85\u8FC7 20 MB\uFF0C\u5DF2\u505C\u6B62\u4E0B\u8F7D"));u.push(g)}const f=Buffer.concat(u),b=e.inNpmPackage?O(f,r):f,h=U("sha256").update(b).digest("hex");if(h!==r.sha256)throw new Error(p("\u6821\u9A8C\u503C\u4E0D\u7B26\uFF08\u4E0B\u8F7D\u5230\u7684 {got}\uFF0C\u5E94\u4E3A {want}\uFF09\uFF0C\u5DF2\u4E22\u5F03").replace("{got}",h.slice(0,12)).replace("{want}",r.sha256.slice(0,12)));return b}i(R,"H"),l(R,"downloadVerified");function $(e,r,t){return new Promise((o,d)=>{const c=T(e,r,{cwd:t,stdio:["ignore","ignore","pipe"],windowsHide:!0});let n="";c.stderr.on("data",a=>{n=(n+a.toString("utf8")).slice(-2e3)}),c.once("error",d),c.once("exit",a=>a===0?o():d(new Error(`${e} exited ${a}: ${n.trim()}`)))})}i($,"P"),l($,"run");function z(){if(process.platform!=="win32")return"tar";const e=m(process.env.SystemRoot??"C:\\Windows","System32","tar.exe");return G(e)?e:"tar.exe"}i(z,"W"),l(z,"tarCommand");async function N(e,r={}){const t=r.root??E(),o=y(e,t);if(o)return o;if(j())throw new Error(p("\u79BB\u7EBF\u6A21\u5F0F\u4E0B\u4E0D\u80FD\u4E0B\u8F7D\u8C03\u8BD5\u5668 {label}\u3002").replace("{label}",e.label));const d=r.fetchImpl??((u,s)=>fetch(u,s)),c=[];let n;for(const u of I(e)){const s=u.url;r.onProgress?.(p("\u6B63\u5728\u5B89\u88C5\u8C03\u8BD5\u5668 {label}\uFF08\u7EA6 {size} MB\uFF0C\u6765\u6E90 {host}\uFF09\u2026").replace("{label}",e.label).replace("{size}",(e.bytes/1024/1024).toFixed(1)).replace("{host}",C(s)));try{n=await R(u,e,d,r.signal);break}catch(f){if(r.signal?.aborted)throw f;c.push(`${C(s)}: ${f instanceof Error?f.message:String(f)}`)}}if(!n)throw new Error(`${p("\u8C03\u8BD5\u5668 {label} \u4E0B\u8F7D\u5931\u8D25\uFF1A").replace("{label}",e.label)}${c.join("\uFF1B")}${p("\u3002\u8BF7\u68C0\u67E5\u7F51\u7EDC\u6216\u4EE3\u7406\u8BBE\u7F6E\u540E\u91CD\u8BD5\u3002")}`);v(t,{recursive:!0});const a=m(t,`.${e.id}-${process.pid}-${_(4).toString("hex")}`);v(a,{recursive:!0});try{const u=m(a,e.file);if(S(u,n),e.format==="wheel"){if(!r.python)throw new Error(p("\u89E3\u538B debugpy \u9700\u8981 Python"));await $(r.python,["-I","-m","zipfile","-e",u,a],a)}else await $(z(),["-xzf",u,"-C",a],a);F(u,{force:!0}),S(m(a,P),`${e.sha256}
2
- `);const s=m(t,e.id);if(y(e,t))return s;F(s,{recursive:!0,force:!0});try{W(a,s)}catch(f){if(y(e,t))return s;throw f}return s}catch(u){throw new Error(`${p("\u8C03\u8BD5\u5668 {label} \u89E3\u538B\u5931\u8D25\uFF1A").replace("{label}",e.label)}${u instanceof Error?u.message:String(u)}`)}finally{F(a,{recursive:!0,force:!0})}}i(N,"te"),l(N,"ensureArtifact");export{Y as DEBUGPY,q as JS_DEBUG,A as NPM_REGISTRIES,E as adapterInstallRoot,N as ensureArtifact,y as installedArtifactDir,B as npmTarballUrl,D as tarMember};
1
+ var L=Object.defineProperty;var i=(e,r)=>L(e,"name",{value:r,configurable:!0});var T=Object.defineProperty,l=i((e,r)=>T(e,"name",{value:r,configurable:!0}),"l");import{spawn as U}from"node:child_process";import{createHash as _,randomBytes as G}from"node:crypto";import{existsSync as H,mkdirSync as v,readFileSync as W,renameSync as Y,rmSync as E,writeFileSync as S}from"node:fs";import{join as g}from"node:path";import{gunzipSync as J}from"node:zlib";import{t as m}from"@dalcode/dal-pi-kit";import{getAgentDir as V}from"@earendil-works/pi-coding-agent";const A=["https://registry.npmmirror.com","https://registry.npmjs.org"];function B(e,r,t){const o=r.includes("/")?r.slice(r.indexOf("/")+1):r;return`${e.replace(/\/+$/,"")}/${r}/-/${o}-${t}.tgz`}i(B,"R"),l(B,"npmTarballUrl");const q={id:"debugpy-1.8.21",label:"debugpy 1.8.21",file:"debugpy-1.8.21-py2.py3-none-any.whl",sha256:"b1e37d333663c8851516a47364ef473da127f9caebe4417e6df6f5825a7e9a92",bytes:5374e3,urls:["https://mirrors.aliyun.com/pypi/packages/95/51/67e7cf11a53e40694f720457d5b3a1cdaaa3d5a9a633e482f225456b93ff/debugpy-1.8.21-py2.py3-none-any.whl","https://files.pythonhosted.org/packages/95/51/67e7cf11a53e40694f720457d5b3a1cdaaa3d5a9a633e482f225456b93ff/debugpy-1.8.21-py2.py3-none-any.whl"],format:"wheel"},K={id:"js-debug-1.140.0",label:"vscode-js-debug 1.140.0",file:"js-debug-dap-v1.140.0.tar.gz",sha256:"27dab92937ec1ab35821ae955aac867544fe06a1b6307229049f2d789af10968",bytes:1249709,urls:["https://github.com/microsoft/vscode-js-debug/releases/download/v1.140.0/js-debug-dap-v1.140.0.tar.gz"],format:"tar.gz",npm:{name:"@deepailab/js-debug-dap",version:"1.140.0"}},x=20*1024*1024,Q=12e4,k=".dal-installed";function F(){return g(V(),"debug-adapters")}i(F,"E"),l(F,"adapterInstallRoot");function y(e,r=F()){const t=g(r,e.id);try{return W(g(t,k),"utf8").trim()===e.sha256?t:void 0}catch{return}}i(y,"w"),l(y,"installedArtifactDir");function P(){return process.env.DALCODE_MCP_MIRROR?.trim().toLowerCase()==="off"}i(P,"C"),l(P,"mirrorsOff");function j(){const e=process.env.PI_OFFLINE?.toLowerCase();return e==="1"||e==="true"||e==="yes"}i(j,"j"),l(j,"offline");function C(e){try{return new URL(e).host}catch{return e}}i(C,"v"),l(C,"hostOf");function I(e){if(P())return e.urls.slice(-1).map(t=>({url:t,inNpmPackage:!1}));const r=e.npm;return[...r?A.map(t=>({url:B(t,r.name,r.version),inNpmPackage:!0})):[],...e.urls.map(t=>({url:t,inNpmPackage:!1}))]}i(I,"T"),l(I,"sourcesOf");function D(e,r){let t=0,o;for(;t+512<=e.length;){const d=e.subarray(t,t+512);if(d.every(f=>f===0))return;const p=l((f,b)=>{const w=d.subarray(f,f+b),h=w.indexOf(0);return w.subarray(0,h===-1?b:h).toString("utf8")},"field"),u=Number.parseInt(p(124,12).trim()||"0",8),a=t+512;if(!Number.isFinite(u)||u<0||a+u>e.length)return;const s=String.fromCharCode(d[156]??0),n=p(345,155),c=o??(n?`${n}/${p(0,100)}`:p(0,100));if(o=void 0,s==="x")o=/(?:^|\n)\d+ path=([^\n]*)\n/.exec(e.subarray(a,a+u).toString("utf8"))?.[1];else if((s==="0"||s==="\0")&&c===r)return Buffer.from(e.subarray(a,a+u));t=a+Math.ceil(u/512)*512}}i(D,"U"),l(D,"tarMember");function O(e,r){let t;try{t=J(e,{maxOutputLength:x*2})}catch{throw new Error(m("npm \u5305\u65E0\u6CD5\u89E3\u5F00"))}const o=D(t,`package/${r.file}`);if(!o)throw new Error(m("npm \u5305\u91CC\u6CA1\u6709 {file}").replace("{file}",r.file));return o}i(O,"G"),l(O,"fromNpmPackage");async function R(e,r,t,o){const d=e.url,p=AbortSignal.timeout(Q),u=await t(d,{signal:o?AbortSignal.any([o,p]):p});if(!u.ok)throw await u.body?.cancel(),new Error(`HTTP ${u.status}`);const a=u.body?.getReader();if(!a)throw new Error(m("\u54CD\u5E94\u6CA1\u6709\u5185\u5BB9"));const s=[];let n=0;for(;;){const{done:w,value:h}=await a.read();if(w)break;if(n+=h.byteLength,n>x)throw await a.cancel(),new Error(m("\u6587\u4EF6\u8D85\u8FC7 20 MB\uFF0C\u5DF2\u505C\u6B62\u4E0B\u8F7D"));s.push(h)}const c=Buffer.concat(s),f=e.inNpmPackage?O(c,r):c,b=_("sha256").update(f).digest("hex");if(b!==r.sha256)throw new Error(m("\u6821\u9A8C\u503C\u4E0D\u7B26\uFF08\u4E0B\u8F7D\u5230\u7684 {got}\uFF0C\u5E94\u4E3A {want}\uFF09\uFF0C\u5DF2\u4E22\u5F03").replace("{got}",b.slice(0,12)).replace("{want}",r.sha256.slice(0,12)));return f}i(R,"H"),l(R,"downloadVerified");function $(e,r,t){return new Promise((o,d)=>{const p=U(e,r,{cwd:t,stdio:["ignore","ignore","pipe"],windowsHide:!0});let u="";p.stderr.on("data",a=>{u=(u+a.toString("utf8")).slice(-2e3)}),p.once("error",d),p.once("exit",a=>a===0?o():d(new Error(`${e} exited ${a}: ${u.trim()}`)))})}i($,"k"),l($,"run");function z(){if(process.platform!=="win32")return"tar";const e=g(process.env.SystemRoot??"C:\\Windows","System32","tar.exe");return H(e)?e:"tar.exe"}i(z,"W"),l(z,"tarCommand");function M(){return{offline:m("\u79BB\u7EBF\u6A21\u5F0F\u4E0B\u4E0D\u80FD\u4E0B\u8F7D\u8C03\u8BD5\u5668 {label}\u3002"),installing:m("\u6B63\u5728\u5B89\u88C5\u8C03\u8BD5\u5668 {label}\uFF08\u7EA6 {size} MB\uFF0C\u6765\u6E90 {host}\uFF09\u2026"),downloadFailed:m("\u8C03\u8BD5\u5668 {label} \u4E0B\u8F7D\u5931\u8D25\uFF1A"),unpackFailed:m("\u8C03\u8BD5\u5668 {label} \u89E3\u538B\u5931\u8D25\uFF1A")}}i(M,"Y"),l(M,"debuggerMessages");async function N(e,r={}){const t=r.root??F(),o=y(e,t);if(o)return o;const d=r.messages??M();if(j())throw new Error(d.offline.replace("{label}",e.label));const p=r.fetchImpl??((n,c)=>fetch(n,c)),u=[];let a;for(const n of I(e)){const c=n.url;r.onProgress?.(d.installing.replace("{label}",e.label).replace("{size}",(e.bytes/1024/1024).toFixed(1)).replace("{host}",C(c)));try{a=await R(n,e,p,r.signal);break}catch(f){if(r.signal?.aborted)throw f;u.push(`${C(c)}: ${f instanceof Error?f.message:String(f)}`)}}if(!a)throw new Error(`${d.downloadFailed.replace("{label}",e.label)}${u.join("\uFF1B")}${m("\u3002\u8BF7\u68C0\u67E5\u7F51\u7EDC\u6216\u4EE3\u7406\u8BBE\u7F6E\u540E\u91CD\u8BD5\u3002")}`);v(t,{recursive:!0});const s=g(t,`.${e.id}-${process.pid}-${G(4).toString("hex")}`);v(s,{recursive:!0});try{const n=g(s,e.file);if(S(n,a),e.format==="wheel"){if(!r.python)throw new Error(m("\u89E3\u538B debugpy \u9700\u8981 Python"));await $(r.python,["-I","-m","zipfile","-e",n,s],s)}else await $(z(),["-xzf",n,"-C",s],s);E(n,{force:!0}),S(g(s,k),`${e.sha256}
2
+ `);const c=g(t,e.id);if(y(e,t))return c;E(c,{recursive:!0,force:!0});try{Y(s,c)}catch(f){if(y(e,t))return c;throw f}return c}catch(n){throw new Error(`${d.unpackFailed.replace("{label}",e.label)}${n instanceof Error?n.message:String(n)}`)}finally{E(s,{recursive:!0,force:!0})}}i(N,"te"),l(N,"ensureArtifact");export{q as DEBUGPY,K as JS_DEBUG,A as NPM_REGISTRIES,F as adapterInstallRoot,N as ensureArtifact,y as installedArtifactDir,B as npmTarballUrl,D as tarMember};