@vibe-agent-toolkit/cli 0.2.0-rc.1 → 0.2.0-rc.11

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 (504) hide show
  1. package/README.md +4 -5
  2. package/dist/bin/vat +97 -28
  3. package/dist/bin/vat.js +97 -28
  4. package/dist/bin/vat.js.map +1 -1
  5. package/dist/bin.js +115 -76
  6. package/dist/bin.js.map +1 -1
  7. package/dist/command-loaders.d.ts +44 -0
  8. package/dist/command-loaders.d.ts.map +1 -0
  9. package/dist/command-loaders.js +60 -0
  10. package/dist/command-loaders.js.map +1 -0
  11. package/dist/commands/agent/build.d.ts.map +1 -1
  12. package/dist/commands/agent/build.js +2 -1
  13. package/dist/commands/agent/build.js.map +1 -1
  14. package/dist/commands/agent/import.d.ts.map +1 -1
  15. package/dist/commands/agent/import.js +3 -2
  16. package/dist/commands/agent/import.js.map +1 -1
  17. package/dist/commands/agent/index.js +1 -1
  18. package/dist/commands/agent/install-path.d.ts +36 -0
  19. package/dist/commands/agent/install-path.d.ts.map +1 -0
  20. package/dist/commands/agent/install-path.js +44 -0
  21. package/dist/commands/agent/install-path.js.map +1 -0
  22. package/dist/commands/agent/install.d.ts.map +1 -1
  23. package/dist/commands/agent/install.js +66 -13
  24. package/dist/commands/agent/install.js.map +1 -1
  25. package/dist/commands/agent/installed.d.ts.map +1 -1
  26. package/dist/commands/agent/installed.js +22 -12
  27. package/dist/commands/agent/installed.js.map +1 -1
  28. package/dist/commands/agent/list.d.ts.map +1 -1
  29. package/dist/commands/agent/list.js +2 -1
  30. package/dist/commands/agent/list.js.map +1 -1
  31. package/dist/commands/agent/run.d.ts.map +1 -1
  32. package/dist/commands/agent/run.js +2 -1
  33. package/dist/commands/agent/run.js.map +1 -1
  34. package/dist/commands/agent/uninstall.d.ts.map +1 -1
  35. package/dist/commands/agent/uninstall.js +13 -6
  36. package/dist/commands/agent/uninstall.js.map +1 -1
  37. package/dist/commands/agent/validate.d.ts.map +1 -1
  38. package/dist/commands/agent/validate.js +3 -2
  39. package/dist/commands/agent/validate.js.map +1 -1
  40. package/dist/commands/ard/emit.d.ts +165 -0
  41. package/dist/commands/ard/emit.d.ts.map +1 -0
  42. package/dist/commands/ard/emit.js +338 -0
  43. package/dist/commands/ard/emit.js.map +1 -0
  44. package/dist/commands/ard/index.d.ts +12 -0
  45. package/dist/commands/ard/index.d.ts.map +1 -0
  46. package/dist/commands/ard/index.js +84 -0
  47. package/dist/commands/ard/index.js.map +1 -0
  48. package/dist/commands/ard/surfaces.d.ts +56 -0
  49. package/dist/commands/ard/surfaces.d.ts.map +1 -0
  50. package/dist/commands/ard/surfaces.js +150 -0
  51. package/dist/commands/ard/surfaces.js.map +1 -0
  52. package/dist/commands/audit/distributed-tree.d.ts +2 -2
  53. package/dist/commands/audit/distributed-tree.d.ts.map +1 -1
  54. package/dist/commands/audit/distributed-tree.js +11 -7
  55. package/dist/commands/audit/distributed-tree.js.map +1 -1
  56. package/dist/commands/audit/git-url-clone.d.ts +1 -1
  57. package/dist/commands/audit/git-url-clone.d.ts.map +1 -1
  58. package/dist/commands/audit/git-url-clone.js.map +1 -1
  59. package/dist/commands/audit/hierarchical-output.d.ts +1 -1
  60. package/dist/commands/audit/hierarchical-output.d.ts.map +1 -1
  61. package/dist/commands/audit/hierarchical-output.js +1 -1
  62. package/dist/commands/audit/hierarchical-output.js.map +1 -1
  63. package/dist/commands/audit/provenance.d.ts.map +1 -1
  64. package/dist/commands/audit/provenance.js +4 -3
  65. package/dist/commands/audit/provenance.js.map +1 -1
  66. package/dist/commands/audit/scan-population.d.ts +158 -0
  67. package/dist/commands/audit/scan-population.d.ts.map +1 -0
  68. package/dist/commands/audit/scan-population.js +292 -0
  69. package/dist/commands/audit/scan-population.js.map +1 -0
  70. package/dist/commands/audit-settings.d.ts.map +1 -1
  71. package/dist/commands/audit-settings.js +6 -5
  72. package/dist/commands/audit-settings.js.map +1 -1
  73. package/dist/commands/audit.d.ts +98 -8
  74. package/dist/commands/audit.d.ts.map +1 -1
  75. package/dist/commands/audit.js +1150 -394
  76. package/dist/commands/audit.js.map +1 -1
  77. package/dist/commands/build.d.ts +1 -1
  78. package/dist/commands/build.d.ts.map +1 -1
  79. package/dist/commands/build.js +40 -36
  80. package/dist/commands/build.js.map +1 -1
  81. package/dist/commands/cache/cache-control.d.ts +82 -0
  82. package/dist/commands/cache/cache-control.d.ts.map +1 -0
  83. package/dist/commands/cache/cache-control.js +86 -0
  84. package/dist/commands/cache/cache-control.js.map +1 -0
  85. package/dist/commands/cache/clear.d.ts +34 -6
  86. package/dist/commands/cache/clear.d.ts.map +1 -1
  87. package/dist/commands/cache/clear.js +101 -15
  88. package/dist/commands/cache/clear.js.map +1 -1
  89. package/dist/commands/cache/index.d.ts +13 -63
  90. package/dist/commands/cache/index.d.ts.map +1 -1
  91. package/dist/commands/cache/index.js +47 -79
  92. package/dist/commands/cache/index.js.map +1 -1
  93. package/dist/commands/claude/claude-config.d.ts.map +1 -1
  94. package/dist/commands/claude/claude-config.js +6 -0
  95. package/dist/commands/claude/claude-config.js.map +1 -1
  96. package/dist/commands/claude/context.d.ts +372 -0
  97. package/dist/commands/claude/context.d.ts.map +1 -0
  98. package/dist/commands/claude/context.js +1115 -0
  99. package/dist/commands/claude/context.js.map +1 -0
  100. package/dist/commands/claude/index.d.ts +14 -0
  101. package/dist/commands/claude/index.d.ts.map +1 -1
  102. package/dist/commands/claude/index.js +22 -2
  103. package/dist/commands/claude/index.js.map +1 -1
  104. package/dist/commands/claude/marketplace/changelog-utils.d.ts +1 -1
  105. package/dist/commands/claude/marketplace/changelog-utils.d.ts.map +1 -1
  106. package/dist/commands/claude/marketplace/changelog-utils.js +1 -2
  107. package/dist/commands/claude/marketplace/changelog-utils.js.map +1 -1
  108. package/dist/commands/claude/marketplace/git-publish.d.ts.map +1 -1
  109. package/dist/commands/claude/marketplace/git-publish.js +40 -31
  110. package/dist/commands/claude/marketplace/git-publish.js.map +1 -1
  111. package/dist/commands/claude/marketplace/license-utils.d.ts.map +1 -1
  112. package/dist/commands/claude/marketplace/license-utils.js +0 -1
  113. package/dist/commands/claude/marketplace/license-utils.js.map +1 -1
  114. package/dist/commands/claude/marketplace/publish-tree.d.ts.map +1 -1
  115. package/dist/commands/claude/marketplace/publish-tree.js +0 -6
  116. package/dist/commands/claude/marketplace/publish-tree.js.map +1 -1
  117. package/dist/commands/claude/marketplace/publish.d.ts.map +1 -1
  118. package/dist/commands/claude/marketplace/publish.js +2 -1
  119. package/dist/commands/claude/marketplace/publish.js.map +1 -1
  120. package/dist/commands/claude/marketplace/validate.d.ts +73 -22
  121. package/dist/commands/claude/marketplace/validate.d.ts.map +1 -1
  122. package/dist/commands/claude/marketplace/validate.js +407 -72
  123. package/dist/commands/claude/marketplace/validate.js.map +1 -1
  124. package/dist/commands/claude/org/api-keys.d.ts +0 -3
  125. package/dist/commands/claude/org/api-keys.d.ts.map +1 -1
  126. package/dist/commands/claude/org/api-keys.js +2 -1
  127. package/dist/commands/claude/org/api-keys.js.map +1 -1
  128. package/dist/commands/claude/org/helpers.d.ts +54 -1
  129. package/dist/commands/claude/org/helpers.d.ts.map +1 -1
  130. package/dist/commands/claude/org/helpers.js +42 -7
  131. package/dist/commands/claude/org/helpers.js.map +1 -1
  132. package/dist/commands/claude/org/index.d.ts.map +1 -1
  133. package/dist/commands/claude/org/index.js +24 -16
  134. package/dist/commands/claude/org/index.js.map +1 -1
  135. package/dist/commands/claude/org/invites.d.ts +0 -3
  136. package/dist/commands/claude/org/invites.d.ts.map +1 -1
  137. package/dist/commands/claude/org/invites.js +3 -2
  138. package/dist/commands/claude/org/invites.js.map +1 -1
  139. package/dist/commands/claude/org/skills.d.ts +527 -0
  140. package/dist/commands/claude/org/skills.d.ts.map +1 -1
  141. package/dist/commands/claude/org/skills.js +1414 -108
  142. package/dist/commands/claude/org/skills.js.map +1 -1
  143. package/dist/commands/claude/org/users.d.ts +0 -3
  144. package/dist/commands/claude/org/users.d.ts.map +1 -1
  145. package/dist/commands/claude/org/users.js +6 -3
  146. package/dist/commands/claude/org/users.js.map +1 -1
  147. package/dist/commands/claude/org/workspaces.d.ts +0 -3
  148. package/dist/commands/claude/org/workspaces.d.ts.map +1 -1
  149. package/dist/commands/claude/org/workspaces.js +11 -7
  150. package/dist/commands/claude/org/workspaces.js.map +1 -1
  151. package/dist/commands/claude/plugin/build.d.ts +41 -3
  152. package/dist/commands/claude/plugin/build.d.ts.map +1 -1
  153. package/dist/commands/claude/plugin/build.js +147 -80
  154. package/dist/commands/claude/plugin/build.js.map +1 -1
  155. package/dist/commands/claude/plugin/helpers.d.ts.map +1 -1
  156. package/dist/commands/claude/plugin/helpers.js +2 -7
  157. package/dist/commands/claude/plugin/helpers.js.map +1 -1
  158. package/dist/commands/claude/plugin/install.d.ts +12 -0
  159. package/dist/commands/claude/plugin/install.d.ts.map +1 -1
  160. package/dist/commands/claude/plugin/install.js +93 -62
  161. package/dist/commands/claude/plugin/install.js.map +1 -1
  162. package/dist/commands/claude/plugin/list.d.ts.map +1 -1
  163. package/dist/commands/claude/plugin/list.js +3 -2
  164. package/dist/commands/claude/plugin/list.js.map +1 -1
  165. package/dist/commands/claude/plugin/marketplace-json.d.ts +24 -9
  166. package/dist/commands/claude/plugin/marketplace-json.d.ts.map +1 -1
  167. package/dist/commands/claude/plugin/marketplace-json.js +10 -9
  168. package/dist/commands/claude/plugin/marketplace-json.js.map +1 -1
  169. package/dist/commands/claude/plugin/plugin-changelog.d.ts.map +1 -1
  170. package/dist/commands/claude/plugin/plugin-changelog.js +0 -2
  171. package/dist/commands/claude/plugin/plugin-changelog.js.map +1 -1
  172. package/dist/commands/claude/plugin/plugin-files.d.ts.map +1 -1
  173. package/dist/commands/claude/plugin/plugin-files.js +3 -6
  174. package/dist/commands/claude/plugin/plugin-files.js.map +1 -1
  175. package/dist/commands/claude/plugin/plugin-validators.d.ts.map +1 -1
  176. package/dist/commands/claude/plugin/plugin-validators.js +3 -6
  177. package/dist/commands/claude/plugin/plugin-validators.js.map +1 -1
  178. package/dist/commands/claude/plugin/tree-copy.d.ts +73 -0
  179. package/dist/commands/claude/plugin/tree-copy.d.ts.map +1 -1
  180. package/dist/commands/claude/plugin/tree-copy.js +221 -14
  181. package/dist/commands/claude/plugin/tree-copy.js.map +1 -1
  182. package/dist/commands/claude/plugin/uninstall.d.ts.map +1 -1
  183. package/dist/commands/claude/plugin/uninstall.js +4 -4
  184. package/dist/commands/claude/plugin/uninstall.js.map +1 -1
  185. package/dist/commands/consistency-check.d.ts +17 -15
  186. package/dist/commands/consistency-check.d.ts.map +1 -1
  187. package/dist/commands/consistency-check.js +152 -106
  188. package/dist/commands/consistency-check.js.map +1 -1
  189. package/dist/commands/corpus/index.d.ts.map +1 -1
  190. package/dist/commands/corpus/index.js +3 -0
  191. package/dist/commands/corpus/index.js.map +1 -1
  192. package/dist/commands/corpus/report.d.ts +1 -2
  193. package/dist/commands/corpus/report.d.ts.map +1 -1
  194. package/dist/commands/corpus/report.js +1 -3
  195. package/dist/commands/corpus/report.js.map +1 -1
  196. package/dist/commands/corpus/runner.d.ts +58 -1
  197. package/dist/commands/corpus/runner.d.ts.map +1 -1
  198. package/dist/commands/corpus/runner.js +95 -41
  199. package/dist/commands/corpus/runner.js.map +1 -1
  200. package/dist/commands/corpus/scan.d.ts.map +1 -1
  201. package/dist/commands/corpus/scan.js +20 -12
  202. package/dist/commands/corpus/scan.js.map +1 -1
  203. package/dist/commands/corpus/seed.d.ts +4 -4
  204. package/dist/commands/corpus/seed.d.ts.map +1 -1
  205. package/dist/commands/corpus/seed.js +1 -3
  206. package/dist/commands/corpus/seed.js.map +1 -1
  207. package/dist/commands/doctor.d.ts +50 -0
  208. package/dist/commands/doctor.d.ts.map +1 -1
  209. package/dist/commands/doctor.js +245 -52
  210. package/dist/commands/doctor.js.map +1 -1
  211. package/dist/commands/inventory.d.ts +13 -1
  212. package/dist/commands/inventory.d.ts.map +1 -1
  213. package/dist/commands/inventory.js +121 -17
  214. package/dist/commands/inventory.js.map +1 -1
  215. package/dist/commands/mcp/collections.d.ts +1 -1
  216. package/dist/commands/mcp/collections.d.ts.map +1 -1
  217. package/dist/commands/mcp/list-collections.d.ts.map +1 -1
  218. package/dist/commands/mcp/list-collections.js +2 -1
  219. package/dist/commands/mcp/list-collections.js.map +1 -1
  220. package/dist/commands/mcp/serve.d.ts.map +1 -1
  221. package/dist/commands/mcp/serve.js +3 -2
  222. package/dist/commands/mcp/serve.js.map +1 -1
  223. package/dist/commands/okf/index.d.ts +11 -0
  224. package/dist/commands/okf/index.d.ts.map +1 -0
  225. package/dist/commands/okf/index.js +116 -0
  226. package/dist/commands/okf/index.js.map +1 -0
  227. package/dist/commands/okf/validate.d.ts +195 -0
  228. package/dist/commands/okf/validate.d.ts.map +1 -0
  229. package/dist/commands/okf/validate.js +199 -0
  230. package/dist/commands/okf/validate.js.map +1 -0
  231. package/dist/commands/phase-utils.d.ts +182 -114
  232. package/dist/commands/phase-utils.d.ts.map +1 -1
  233. package/dist/commands/phase-utils.js +154 -163
  234. package/dist/commands/phase-utils.js.map +1 -1
  235. package/dist/commands/positional-args.d.ts.map +1 -1
  236. package/dist/commands/positional-args.js +3 -2
  237. package/dist/commands/positional-args.js.map +1 -1
  238. package/dist/commands/rag/clear-command.d.ts.map +1 -1
  239. package/dist/commands/rag/clear-command.js +2 -1
  240. package/dist/commands/rag/clear-command.js.map +1 -1
  241. package/dist/commands/rag/index-command.d.ts +64 -0
  242. package/dist/commands/rag/index-command.d.ts.map +1 -1
  243. package/dist/commands/rag/index-command.js +72 -6
  244. package/dist/commands/rag/index-command.js.map +1 -1
  245. package/dist/commands/rag/index.d.ts.map +1 -1
  246. package/dist/commands/rag/index.js +23 -10
  247. package/dist/commands/rag/index.js.map +1 -1
  248. package/dist/commands/rag/query-command.d.ts.map +1 -1
  249. package/dist/commands/rag/query-command.js +2 -1
  250. package/dist/commands/rag/query-command.js.map +1 -1
  251. package/dist/commands/rag/stats-command.d.ts.map +1 -1
  252. package/dist/commands/rag/stats-command.js +2 -1
  253. package/dist/commands/rag/stats-command.js.map +1 -1
  254. package/dist/commands/resources/builtin-help.d.ts +27 -0
  255. package/dist/commands/resources/builtin-help.d.ts.map +1 -0
  256. package/dist/commands/resources/builtin-help.js +46 -0
  257. package/dist/commands/resources/builtin-help.js.map +1 -0
  258. package/dist/commands/resources/check-progress.d.ts +167 -0
  259. package/dist/commands/resources/check-progress.d.ts.map +1 -0
  260. package/dist/commands/resources/check-progress.js +250 -0
  261. package/dist/commands/resources/check-progress.js.map +1 -0
  262. package/dist/commands/resources/check-supervisor.d.ts +479 -0
  263. package/dist/commands/resources/check-supervisor.d.ts.map +1 -0
  264. package/dist/commands/resources/check-supervisor.js +587 -0
  265. package/dist/commands/resources/check-supervisor.js.map +1 -0
  266. package/dist/commands/resources/check.d.ts +620 -0
  267. package/dist/commands/resources/check.d.ts.map +1 -0
  268. package/dist/commands/resources/check.js +1452 -0
  269. package/dist/commands/resources/check.js.map +1 -0
  270. package/dist/commands/resources/index.d.ts.map +1 -1
  271. package/dist/commands/resources/index.js +430 -4
  272. package/dist/commands/resources/index.js.map +1 -1
  273. package/dist/commands/resources/query.d.ts +106 -0
  274. package/dist/commands/resources/query.d.ts.map +1 -0
  275. package/dist/commands/resources/query.js +177 -0
  276. package/dist/commands/resources/query.js.map +1 -0
  277. package/dist/commands/resources/scan.d.ts +24 -0
  278. package/dist/commands/resources/scan.d.ts.map +1 -1
  279. package/dist/commands/resources/scan.js +17 -8
  280. package/dist/commands/resources/scan.js.map +1 -1
  281. package/dist/commands/resources/validate.d.ts +42 -2
  282. package/dist/commands/resources/validate.d.ts.map +1 -1
  283. package/dist/commands/resources/validate.js +208 -55
  284. package/dist/commands/resources/validate.js.map +1 -1
  285. package/dist/commands/skill/review-checklist.d.ts +3 -2
  286. package/dist/commands/skill/review-checklist.d.ts.map +1 -1
  287. package/dist/commands/skill/review-checklist.js +40 -2
  288. package/dist/commands/skill/review-checklist.js.map +1 -1
  289. package/dist/commands/skill/review.d.ts +247 -0
  290. package/dist/commands/skill/review.d.ts.map +1 -1
  291. package/dist/commands/skill/review.js +100 -62
  292. package/dist/commands/skill/review.js.map +1 -1
  293. package/dist/commands/skill/test/configure.d.ts +56 -0
  294. package/dist/commands/skill/test/configure.d.ts.map +1 -1
  295. package/dist/commands/skill/test/configure.js +75 -16
  296. package/dist/commands/skill/test/configure.js.map +1 -1
  297. package/dist/commands/skill/test/run.d.ts +63 -10
  298. package/dist/commands/skill/test/run.d.ts.map +1 -1
  299. package/dist/commands/skill/test/run.js +258 -77
  300. package/dist/commands/skill/test/run.js.map +1 -1
  301. package/dist/commands/skills/build.d.ts +94 -4
  302. package/dist/commands/skills/build.d.ts.map +1 -1
  303. package/dist/commands/skills/build.js +325 -97
  304. package/dist/commands/skills/build.js.map +1 -1
  305. package/dist/commands/skills/install.d.ts +2 -1
  306. package/dist/commands/skills/install.d.ts.map +1 -1
  307. package/dist/commands/skills/install.js +20 -31
  308. package/dist/commands/skills/install.js.map +1 -1
  309. package/dist/commands/skills/list.d.ts +2 -1
  310. package/dist/commands/skills/list.d.ts.map +1 -1
  311. package/dist/commands/skills/list.js +44 -26
  312. package/dist/commands/skills/list.js.map +1 -1
  313. package/dist/commands/skills/package.d.ts +1 -1
  314. package/dist/commands/skills/package.d.ts.map +1 -1
  315. package/dist/commands/skills/package.js +6 -8
  316. package/dist/commands/skills/package.js.map +1 -1
  317. package/dist/commands/skills/scope-guard.d.ts.map +1 -1
  318. package/dist/commands/skills/scope-guard.js +8 -6
  319. package/dist/commands/skills/scope-guard.js.map +1 -1
  320. package/dist/commands/skills/shared.d.ts.map +1 -1
  321. package/dist/commands/skills/shared.js +2 -4
  322. package/dist/commands/skills/shared.js.map +1 -1
  323. package/dist/commands/skills/skill-discovery.d.ts +47 -6
  324. package/dist/commands/skills/skill-discovery.d.ts.map +1 -1
  325. package/dist/commands/skills/skill-discovery.js +61 -11
  326. package/dist/commands/skills/skill-discovery.js.map +1 -1
  327. package/dist/commands/skills/source-resolvers.d.ts +15 -0
  328. package/dist/commands/skills/source-resolvers.d.ts.map +1 -1
  329. package/dist/commands/skills/source-resolvers.js +25 -4
  330. package/dist/commands/skills/source-resolvers.js.map +1 -1
  331. package/dist/commands/skills/validate-command.d.ts.map +1 -1
  332. package/dist/commands/skills/validate-command.js +11 -3
  333. package/dist/commands/skills/validate-command.js.map +1 -1
  334. package/dist/commands/skills/validate.d.ts +140 -4
  335. package/dist/commands/skills/validate.d.ts.map +1 -1
  336. package/dist/commands/skills/validate.js +224 -67
  337. package/dist/commands/skills/validate.js.map +1 -1
  338. package/dist/commands/validate.d.ts +1 -1
  339. package/dist/commands/validate.d.ts.map +1 -1
  340. package/dist/commands/validate.js +63 -27
  341. package/dist/commands/validate.js.map +1 -1
  342. package/dist/commands/verify.d.ts +119 -15
  343. package/dist/commands/verify.d.ts.map +1 -1
  344. package/dist/commands/verify.js +357 -142
  345. package/dist/commands/verify.js.map +1 -1
  346. package/dist/index.d.ts +0 -1
  347. package/dist/index.d.ts.map +1 -1
  348. package/dist/index.js +5 -1
  349. package/dist/index.js.map +1 -1
  350. package/dist/report-schemas.d.ts +45 -0
  351. package/dist/report-schemas.d.ts.map +1 -0
  352. package/dist/report-schemas.js +100 -0
  353. package/dist/report-schemas.js.map +1 -0
  354. package/dist/skill-resolution/classify.js +2 -2
  355. package/dist/skill-resolution/classify.js.map +1 -1
  356. package/dist/skill-resolution/packaging-config.d.ts +49 -5
  357. package/dist/skill-resolution/packaging-config.d.ts.map +1 -1
  358. package/dist/skill-resolution/packaging-config.js +59 -19
  359. package/dist/skill-resolution/packaging-config.js.map +1 -1
  360. package/dist/skill-resolution/resolve-skill-reference.d.ts.map +1 -1
  361. package/dist/skill-resolution/resolve-skill-reference.js +55 -57
  362. package/dist/skill-resolution/resolve-skill-reference.js.map +1 -1
  363. package/dist/utils/agent-discovery.d.ts.map +1 -1
  364. package/dist/utils/agent-discovery.js +22 -11
  365. package/dist/utils/agent-discovery.js.map +1 -1
  366. package/dist/utils/agent-runner.d.ts.map +1 -1
  367. package/dist/utils/agent-runner.js +7 -4
  368. package/dist/utils/agent-runner.js.map +1 -1
  369. package/dist/utils/claude-context-lens.d.ts +34 -0
  370. package/dist/utils/claude-context-lens.d.ts.map +1 -0
  371. package/dist/utils/claude-context-lens.js +39 -0
  372. package/dist/utils/claude-context-lens.js.map +1 -0
  373. package/dist/utils/command-error.d.ts +143 -20
  374. package/dist/utils/command-error.d.ts.map +1 -1
  375. package/dist/utils/command-error.js +179 -36
  376. package/dist/utils/command-error.js.map +1 -1
  377. package/dist/utils/config-loader.d.ts +2 -1
  378. package/dist/utils/config-loader.d.ts.map +1 -1
  379. package/dist/utils/config-loader.js +40 -14
  380. package/dist/utils/config-loader.js.map +1 -1
  381. package/dist/utils/corpus-target.d.ts +26 -0
  382. package/dist/utils/corpus-target.d.ts.map +1 -0
  383. package/dist/utils/corpus-target.js +72 -0
  384. package/dist/utils/corpus-target.js.map +1 -0
  385. package/dist/utils/edge-lens-evaluation.d.ts +83 -0
  386. package/dist/utils/edge-lens-evaluation.d.ts.map +1 -0
  387. package/dist/utils/edge-lens-evaluation.js +110 -0
  388. package/dist/utils/edge-lens-evaluation.js.map +1 -0
  389. package/dist/utils/help-loader.d.ts.map +1 -1
  390. package/dist/utils/help-loader.js +0 -1
  391. package/dist/utils/help-loader.js.map +1 -1
  392. package/dist/utils/issue-anchor.d.ts +2 -2
  393. package/dist/utils/issue-anchor.d.ts.map +1 -1
  394. package/dist/utils/issue-anchor.js +1 -1
  395. package/dist/utils/issue-rendering.d.ts +3 -3
  396. package/dist/utils/issue-rendering.d.ts.map +1 -1
  397. package/dist/utils/issue-rendering.js +3 -3
  398. package/dist/utils/issue-rendering.js.map +1 -1
  399. package/dist/utils/issue-severity.d.ts +12 -5
  400. package/dist/utils/issue-severity.d.ts.map +1 -1
  401. package/dist/utils/issue-severity.js +1 -1
  402. package/dist/utils/issue-severity.js.map +1 -1
  403. package/dist/utils/optional-backend.d.ts +78 -0
  404. package/dist/utils/optional-backend.d.ts.map +1 -0
  405. package/dist/utils/optional-backend.js +117 -0
  406. package/dist/utils/optional-backend.js.map +1 -0
  407. package/dist/utils/output.d.ts +26 -0
  408. package/dist/utils/output.d.ts.map +1 -1
  409. package/dist/utils/output.js +35 -0
  410. package/dist/utils/output.js.map +1 -1
  411. package/dist/utils/package-json.d.ts +24 -0
  412. package/dist/utils/package-json.d.ts.map +1 -0
  413. package/dist/utils/package-json.js +49 -0
  414. package/dist/utils/package-json.js.map +1 -0
  415. package/dist/utils/population-wiring.d.ts +100 -0
  416. package/dist/utils/population-wiring.d.ts.map +1 -0
  417. package/dist/utils/population-wiring.js +98 -0
  418. package/dist/utils/population-wiring.js.map +1 -0
  419. package/dist/utils/project-root-policy.d.ts +20 -0
  420. package/dist/utils/project-root-policy.d.ts.map +1 -1
  421. package/dist/utils/project-root-policy.js +30 -0
  422. package/dist/utils/project-root-policy.js.map +1 -1
  423. package/dist/utils/projection-lenses.d.ts +98 -0
  424. package/dist/utils/projection-lenses.d.ts.map +1 -0
  425. package/dist/utils/projection-lenses.js +203 -0
  426. package/dist/utils/projection-lenses.js.map +1 -0
  427. package/dist/utils/projection-query.d.ts +324 -0
  428. package/dist/utils/projection-query.d.ts.map +1 -0
  429. package/dist/utils/projection-query.js +357 -0
  430. package/dist/utils/projection-query.js.map +1 -0
  431. package/dist/utils/projection-store.d.ts +335 -0
  432. package/dist/utils/projection-store.d.ts.map +1 -0
  433. package/dist/utils/projection-store.js +522 -0
  434. package/dist/utils/projection-store.js.map +1 -0
  435. package/dist/utils/relation-limits.d.ts +50 -0
  436. package/dist/utils/relation-limits.d.ts.map +1 -0
  437. package/dist/utils/relation-limits.js +50 -0
  438. package/dist/utils/relation-limits.js.map +1 -0
  439. package/dist/utils/repeatable-option.d.ts +37 -0
  440. package/dist/utils/repeatable-option.d.ts.map +1 -0
  441. package/dist/utils/repeatable-option.js +39 -0
  442. package/dist/utils/repeatable-option.js.map +1 -0
  443. package/dist/utils/resource-loader.d.ts +134 -2
  444. package/dist/utils/resource-loader.d.ts.map +1 -1
  445. package/dist/utils/resource-loader.js +290 -27
  446. package/dist/utils/resource-loader.js.map +1 -1
  447. package/dist/utils/root-argv.d.ts +53 -0
  448. package/dist/utils/root-argv.d.ts.map +1 -0
  449. package/dist/utils/root-argv.js +215 -0
  450. package/dist/utils/root-argv.js.map +1 -0
  451. package/dist/utils/run-integrity.d.ts +95 -0
  452. package/dist/utils/run-integrity.d.ts.map +1 -0
  453. package/dist/utils/run-integrity.js +102 -0
  454. package/dist/utils/run-integrity.js.map +1 -0
  455. package/dist/utils/skill-discovery.d.ts.map +1 -1
  456. package/dist/utils/skill-discovery.js +2 -1
  457. package/dist/utils/skill-discovery.js.map +1 -1
  458. package/dist/utils/skill-packaging-config.d.ts +63 -1
  459. package/dist/utils/skill-packaging-config.d.ts.map +1 -1
  460. package/dist/utils/skill-packaging-config.js +56 -1
  461. package/dist/utils/skill-packaging-config.js.map +1 -1
  462. package/dist/utils/sqlite-experimental-warning.d.ts +69 -0
  463. package/dist/utils/sqlite-experimental-warning.d.ts.map +1 -0
  464. package/dist/utils/sqlite-experimental-warning.js +144 -0
  465. package/dist/utils/sqlite-experimental-warning.js.map +1 -0
  466. package/dist/utils/url-redact.d.ts.map +1 -1
  467. package/dist/utils/url-redact.js +4 -6
  468. package/dist/utils/url-redact.js.map +1 -1
  469. package/dist/utils/user-context-scanner.d.ts +8 -0
  470. package/dist/utils/user-context-scanner.d.ts.map +1 -1
  471. package/dist/utils/user-context-scanner.js +4 -2
  472. package/dist/utils/user-context-scanner.js.map +1 -1
  473. package/dist/utils/validate-help-files.d.ts.map +1 -1
  474. package/dist/utils/validate-help-files.js +12 -6
  475. package/dist/utils/validate-help-files.js.map +1 -1
  476. package/dist/utils/vat-bin-path.d.ts +36 -0
  477. package/dist/utils/vat-bin-path.d.ts.map +1 -0
  478. package/dist/utils/vat-bin-path.js +48 -0
  479. package/dist/utils/vat-bin-path.js.map +1 -0
  480. package/dist/utils/verdict-helpers.d.ts +1 -1
  481. package/dist/utils/verdict-helpers.d.ts.map +1 -1
  482. package/dist/utils/verdict-helpers.js +1 -1
  483. package/dist/utils/verdict-helpers.js.map +1 -1
  484. package/dist/version.d.ts.map +1 -1
  485. package/dist/version.js +1 -3
  486. package/dist/version.js.map +1 -1
  487. package/docs/agent.md +2 -2
  488. package/docs/audit.md +143 -39
  489. package/docs/doctor.md +7 -6
  490. package/docs/index.md +19 -11
  491. package/docs/mcp.md +2 -2
  492. package/docs/rag.md +3 -2
  493. package/docs/resources.md +13 -3
  494. package/docs/skill-test.md +10 -9
  495. package/docs/skills.md +53 -69
  496. package/package.json +36 -27
  497. package/schemas/ard-emit.json +152 -0
  498. package/schemas/okf-validate.json +170 -0
  499. package/schemas/resources-check.json +257 -0
  500. package/schemas/skill-review.json +230 -0
  501. package/dist/commands/resources/command-helpers.d.ts +0 -5
  502. package/dist/commands/resources/command-helpers.d.ts.map +0 -1
  503. package/dist/commands/resources/command-helpers.js +0 -6
  504. package/dist/commands/resources/command-helpers.js.map +0 -1
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Which lenses a run evaluates, and when it does NOT — the selection that keeps
3
+ * the derived relations affordable.
4
+ *
5
+ * ðŸšĻ **The selector over-selects on purpose: a FALSE NEGATIVE fails a run that
6
+ * had an answer.** A lens skipped when its relation is named leaves that
7
+ * relation ABSENT from the run's database, so the statement is refused with
8
+ * `no such table` — loud rather than wrong, because the refusal is SQLite's and
9
+ * does not depend on this scan. The cost that forced the selection, the rules
10
+ * that keep it fail-safe, and why the registry lives in the CLI rather than in a
11
+ * population are in
12
+ * `docs/architecture/zones.md` §2, "A lens is evaluated only when a statement
13
+ * names one of its relations".
14
+ */
15
+ import { type DerivedTableName, type PopulationCache, type Projection } from '@vibe-agent-toolkit/resources';
16
+ import type { Logger } from './logger.js';
17
+ /**
18
+ * The rows one lens evaluation produced, keyed by `DERIVED_TABLES`' own keys.
19
+ *
20
+ * Structurally `projection-sqlite`'s `DerivedRows`, spelled here so every lens
21
+ * states its output in terms of the RELATION REGISTRY rather than of a storage
22
+ * backend. `writeDerived` accepts it unchanged.
23
+ */
24
+ export type LensRows = {
25
+ readonly [Name in DerivedTableName]?: readonly Record<string, unknown>[];
26
+ };
27
+ /** Everything a lens may read while evaluating. */
28
+ export interface LensEvaluationInput {
29
+ /** The resources-lane projection the run already populated. */
30
+ readonly projection: Projection;
31
+ /** Absolute corpus root, for a lens that must populate a lane of its own. */
32
+ readonly root: string;
33
+ /** Where a lens's own blob-stage refusals go — stderr. */
34
+ readonly logger: Logger;
35
+ /** The run's projection store, so a lens's own population can hit it. */
36
+ readonly cache: PopulationCache | undefined;
37
+ }
38
+ /** One lens: the relations it owns, and how to produce their rows. */
39
+ export interface ProjectionLens {
40
+ /** How the lens names itself in `lensesEvaluated` and in a refusal. */
41
+ readonly name: string;
42
+ /**
43
+ * Every relation this lens produces, by registry key.
44
+ *
45
+ * ⛔ Disjoint from every other lens's. Two lenses claiming one relation would
46
+ * make "was it evaluated" unanswerable, and the second `writeDerived` would
47
+ * CLEAR the first's rows — `writeDerived` replaces a relation's contents.
48
+ */
49
+ readonly relations: readonly DerivedTableName[];
50
+ /**
51
+ * Produce the rows.
52
+ *
53
+ * @param input - The projection, the root, and the run's oracles
54
+ * @returns Every relation this lens owns — all of them, every time, because
55
+ * omitting one leaves its previous contents in place
56
+ */
57
+ readonly evaluate: (input: LensEvaluationInput) => Promise<LensRows> | LensRows;
58
+ }
59
+ /** The authored-link lens: `lens_contexts`, `edges`, `edge_resolutions`. */
60
+ export declare const AUTHORED_LINK_LENS: ProjectionLens;
61
+ /** The always-loaded context lens: `claude_context_chains`, `claude_context_loads`. */
62
+ export declare const CLAUDE_CONTEXT_LENS: ProjectionLens;
63
+ /** Every lens the query lane can evaluate, in evaluation order. */
64
+ export declare const PROJECTION_LENSES: readonly ProjectionLens[];
65
+ /**
66
+ * The SQL names of a lens's relations. Read off `DERIVED_TABLES` rather than
67
+ * restated: the SQL name and the registry key are deliberately different
68
+ * vocabularies (`edgeResolutions` is spelled `edge_resolutions`), so a second
69
+ * copy here would be a rename waiting to be missed.
70
+ *
71
+ * @param lens - The lens
72
+ * @returns Its relations as SQL spells them
73
+ */
74
+ export declare function lensRelationNames(lens: ProjectionLens): readonly string[];
75
+ /**
76
+ * The lenses a run has to evaluate, given the statements it declared.
77
+ *
78
+ * @param statements - Every statement the run may ask, or `undefined` when the
79
+ * caller cannot enumerate them. ⛔ `undefined` selects EVERY lens — see the
80
+ * header on why the fail-safe direction is not negotiable
81
+ * @returns The lenses to evaluate, in {@link PROJECTION_LENSES} order
82
+ */
83
+ export declare function lensesNamedBy(statements: readonly string[] | undefined): readonly ProjectionLens[];
84
+ /**
85
+ * Evaluate one lens and hand back its rows, refusing any that are not exactly
86
+ * the relations it declares.
87
+ *
88
+ * `LensRows` makes every relation optional, so a lens that forgot one compiles —
89
+ * and `writeDerived` would leave that relation empty, a table that reads as a
90
+ * healthy tree. Checked here because this is the one place every lens passes.
91
+ *
92
+ * @param lens - The lens
93
+ * @param input - What it may read
94
+ * @returns Its rows
95
+ * @throws Error When the rows omit a declared relation or carry an undeclared one
96
+ */
97
+ export declare function evaluateLens(lens: ProjectionLens, input: LensEvaluationInput): Promise<LensRows>;
98
+ //# sourceMappingURL=projection-lenses.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projection-lenses.d.ts","sourceRoot":"","sources":["../../src/utils/projection-lenses.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAkB,KAAK,gBAAgB,EAAE,KAAK,eAAe,EAAE,KAAK,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAI7H,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C;;;;;;GAMG;AACH,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,EAAE,IAAI,IAAI,gBAAgB,CAAC,CAAC,EAAE,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,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derived relations affordable.
4
+ *
5
+ * ðŸšĻ **The selector over-selects on purpose: a FALSE NEGATIVE fails a run that
6
+ * had an answer.** A lens skipped when its relation is named leaves that
7
+ * relation ABSENT from the run's database, so the statement is refused with
8
+ * `no such table` — loud rather than wrong, because the refusal is SQLite's and
9
+ * does not depend on this scan. The cost that forced the selection, the rules
10
+ * that keep it fail-safe, and why the registry lives in the CLI rather than in a
11
+ * population are in
12
+ * `docs/architecture/zones.md` §2, "A lens is evaluated only when a statement
13
+ * names one of its relations".
14
+ */
15
+ import { DERIVED_TABLES } from '@vibe-agent-toolkit/resources';
16
+ import { evaluateClaudeContextLens } from './claude-context-lens.js';
17
+ import { evaluateAuthoredLenses } from './edge-lens-evaluation.js';
18
+ /** The authored-link lens: `lens_contexts`, `edges`, `edge_resolutions`. */
19
+ export const AUTHORED_LINK_LENS = {
20
+ name: 'authored-link',
21
+ relations: ['lensContexts', 'edges', 'edgeResolutions'],
22
+ evaluate: ({ projection }) => evaluateAuthoredLenses(projection),
23
+ };
24
+ /** The always-loaded context lens: `claude_context_chains`, `claude_context_loads`. */
25
+ export const CLAUDE_CONTEXT_LENS = {
26
+ name: 'claude-context',
27
+ relations: ['claudeContextChains', 'claudeContextLoads'],
28
+ evaluate: ({ root, logger, cache }) => evaluateClaudeContextLens({ root, logger, cache }),
29
+ };
30
+ /** Every lens the query lane can evaluate, in evaluation order. */
31
+ export const PROJECTION_LENSES = [
32
+ AUTHORED_LINK_LENS,
33
+ CLAUDE_CONTEXT_LENS,
34
+ ];
35
+ /**
36
+ * The SQL names of a lens's relations. Read off `DERIVED_TABLES` rather than
37
+ * restated: the SQL name and the registry key are deliberately different
38
+ * vocabularies (`edgeResolutions` is spelled `edge_resolutions`), so a second
39
+ * copy here would be a rename waiting to be missed.
40
+ *
41
+ * @param lens - The lens
42
+ * @returns Its relations as SQL spells them
43
+ */
44
+ export function lensRelationNames(lens) {
45
+ return lens.relations.map((name) => DERIVED_TABLES[name].name);
46
+ }
47
+ /**
48
+ * The lenses a run has to evaluate, given the statements it declared.
49
+ *
50
+ * @param statements - Every statement the run may ask, or `undefined` when the
51
+ * caller cannot enumerate them. ⛔ `undefined` selects EVERY lens — see the
52
+ * header on why the fail-safe direction is not negotiable
53
+ * @returns The lenses to evaluate, in {@link PROJECTION_LENSES} order
54
+ */
55
+ export function lensesNamedBy(statements) {
56
+ if (statements === undefined)
57
+ return PROJECTION_LENSES;
58
+ const readable = statements.map((sql) => wordsIn(withoutCommentsAndLiterals(sql)));
59
+ return PROJECTION_LENSES.filter((lens) => lensRelationNames(lens).some((relation) => readable.some((words) => namesRelation(words, relation))));
60
+ }
61
+ /**
62
+ * Evaluate one lens and hand back its rows, refusing any that are not exactly
63
+ * the relations it declares.
64
+ *
65
+ * `LensRows` makes every relation optional, so a lens that forgot one compiles —
66
+ * and `writeDerived` would leave that relation empty, a table that reads as a
67
+ * healthy tree. Checked here because this is the one place every lens passes.
68
+ *
69
+ * @param lens - The lens
70
+ * @param input - What it may read
71
+ * @returns Its rows
72
+ * @throws Error When the rows omit a declared relation or carry an undeclared one
73
+ */
74
+ export async function evaluateLens(lens, input) {
75
+ const rows = await lens.evaluate(input);
76
+ const declared = lens.relations;
77
+ const missing = declared.filter((name) => !Object.hasOwn(rows, name));
78
+ const undeclared = Object.keys(rows).filter((name) => !declared.includes(name));
79
+ if (missing.length > 0 || undeclared.length > 0) {
80
+ throw new Error(`Lens "${lens.name}" must produce exactly [${declared.join(', ')}];`
81
+ + ` missing [${missing.join(', ')}], undeclared [${undeclared.join(', ')}]`);
82
+ }
83
+ return rows;
84
+ }
85
+ /**
86
+ * Blank out the parts of a statement that cannot name a table: line comments,
87
+ * block comments and single-quoted string literals. Quoted IDENTIFIERS
88
+ * (`"edges"`, `[edges]`, backticked) are deliberately left alone — those ARE
89
+ * table references, spelled differently. Replaced with spaces rather than
90
+ * removed, so a block comment between `FROM` and `edges` cannot let the two run
91
+ * together.
92
+ *
93
+ * @param sql - The statement
94
+ * @returns The statement with every non-code span blanked
95
+ */
96
+ function withoutCommentsAndLiterals(sql) {
97
+ let out = '';
98
+ let index = 0;
99
+ while (index < sql.length) {
100
+ const end = spanEnd(sql, index);
101
+ if (end === undefined) {
102
+ out += sql.charAt(index);
103
+ index += 1;
104
+ continue;
105
+ }
106
+ const span = sql.slice(index, end);
107
+ out += QUOTED_IDENTIFIER_CLOSERS.has(span.charAt(0)) ? span : ' '.repeat(span.length);
108
+ index = end;
109
+ }
110
+ return out;
111
+ }
112
+ /** The characters that open a quoted identifier, and the one that closes each. */
113
+ const QUOTED_IDENTIFIER_CLOSERS = new Map([['"', '"'], ['[', ']'], ['`', '`']]);
114
+ /** Every quoted span's opener and closer: the identifiers, plus `'` for a literal. */
115
+ const QUOTE_CLOSERS = new Map([...QUOTED_IDENTIFIER_CLOSERS, ["'", "'"]]);
116
+ /**
117
+ * Where a span starting at `start` ends: a line comment, a block comment, a
118
+ * single-quoted literal — or a quoted IDENTIFIER, consumed only so it can be
119
+ * handed back unblanked.
120
+ *
121
+ * ⛔ Quoted identifiers MUST be consumed by this same scan even though their
122
+ * contents stay code, and the reason is the whole of this function. SQLite gives
123
+ * `'`, `--` and `/*` no meaning inside `"â€Ķ"`, `[â€Ķ]` or `` `â€Ķ` ``. A scanner that
124
+ * skips those spans lets a character inside one open a literal or a comment that
125
+ * SQLite never opened, desynchronises, and blanks a span of REAL SQL — taking the
126
+ * relation name with it. The statement then reads an EMPTY relation and answers 0
127
+ * instead of being refused, which for a declared check is a silent exit 0: a gate
128
+ * that cannot fail.
129
+ *
130
+ * Scanning left to right is what keeps the spans mutually exclusive: a comment
131
+ * marker inside a literal is never looked at, nor a quote inside a comment.
132
+ *
133
+ * @param sql - The statement
134
+ * @param start - Where to look
135
+ * @returns The index just past the span, or undefined when none opens here
136
+ */
137
+ function spanEnd(sql, start) {
138
+ const pair = sql.slice(start, start + 2);
139
+ if (pair === '--') {
140
+ const newline = sql.indexOf('\n', start);
141
+ return newline === -1 ? sql.length : newline;
142
+ }
143
+ if (pair === '/*') {
144
+ const close = sql.indexOf('*/', start + 2);
145
+ return close === -1 ? undefined : close + 2;
146
+ }
147
+ const closer = QUOTE_CLOSERS.get(sql.charAt(start));
148
+ return closer === undefined ? undefined : quotedEnd(sql, start, closer);
149
+ }
150
+ /**
151
+ * Where a quoted span ends. A doubled closer (`''`, `""`, two backticks) is an
152
+ * escaped one; `[â€Ķ]` has no escape. Left unterminated, the span ends at the last
153
+ * doubled closer instead — what the single pattern this replaced did by
154
+ * backtracking.
155
+ *
156
+ * @param sql - The statement
157
+ * @param start - The opening quote
158
+ * @param closer - The character that closes it
159
+ * @returns The index just past the span, or undefined when it never closes
160
+ */
161
+ function quotedEnd(sql, start, closer) {
162
+ let fallback;
163
+ let from = start + 1;
164
+ for (;;) {
165
+ const close = sql.indexOf(closer, from);
166
+ if (close === -1)
167
+ return fallback;
168
+ if (closer === ']' || sql.charAt(close + 1) !== closer)
169
+ return close + 1;
170
+ fallback = close + 1;
171
+ from = close + 2;
172
+ }
173
+ }
174
+ /**
175
+ * Every whole word in a statement, lowercased.
176
+ *
177
+ * Relation names are `[a-z_]` only and `_` is a word character, so membership in
178
+ * this set answers exactly what a `\b`-anchored search would: `my_edges`
179
+ * tokenizes whole and never answers for `edges`. One pass per statement, rather
180
+ * than one pattern per relation, and no `RegExp` built from a variable.
181
+ *
182
+ * @param sql - The statement, already stripped of comments and literals
183
+ * @returns Its identifier-character runs, lowercased
184
+ */
185
+ function wordsIn(sql) {
186
+ return new Set((sql.match(IDENTIFIER_RUNS) ?? []).map((word) => word.toLowerCase()));
187
+ }
188
+ /** Runs of identifier characters — SQL's word boundaries, the `\b` equivalent. */
189
+ const IDENTIFIER_RUNS = /[a-z0-9_]+/gi;
190
+ /**
191
+ * Does a statement's word set name this relation?
192
+ *
193
+ * Case-folds the relation as well as the words: a registry name spelled with an
194
+ * uppercase letter would otherwise miss every statement silently.
195
+ *
196
+ * @param words - The statement's words, from {@link wordsIn}
197
+ * @param relation - The relation's SQL name
198
+ * @returns True when the statement could be reading that relation
199
+ */
200
+ function namesRelation(words, relation) {
201
+ return words.has(relation.toLowerCase());
202
+ }
203
+ //# sourceMappingURL=projection-lenses.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projection-lenses.js","sourceRoot":"","sources":["../../src/utils/projection-lenses.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,cAAc,EAAgE,MAAM,+BAA+B,CAAC;AAE7H,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAgDnE,4EAA4E;AAC5E,MAAM,CAAC,MAAM,kBAAkB,GAAmB;IAChD,IAAI,EAAE,eAAe;IACrB,SAAS,EAAE,CAAC,cAAc,EAAE,OAAO,EAAE,iBAAiB,CAAC;IACvD,QAAQ,EAAE,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,sBAAsB,CAAC,UAAU,CAAC;CACjE,CAAC;AAEF,uFAAuF;AACvF,MAAM,CAAC,MAAM,mBAAmB,GAAmB;IACjD,IAAI,EAAE,gBAAgB;IACtB,SAAS,EAAE,CAAC,qBAAqB,EAAE,oBAAoB,CAAC;IACxD,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,yBAAyB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;CAC1F,CAAC;AAEF,mEAAmE;AACnE,MAAM,CAAC,MAAM,iBAAiB,GAA8B;IAC1D,kBAAkB;IAClB,mBAAmB;CACpB,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAoB;IACpD,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;AACjE,CAAC;AAED;;;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,GAAG,CAAC,CAAC,KAAK,MAAM;YAAE,OAAO,KAAK,GAAG,CAAC,CAAC;QACzE,QAAQ,GAAG,KAAK,GAAG,CAAC,CAAC;QACrB,IAAI,GAAG,KAAK,GAAG,CAAC,CAAC;IACnB,CAAC;AACH,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAS,OAAO,CAAC,GAAW;IAC1B,OAAO,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;AACvF,CAAC;AAED,kFAAkF;AAClF,MAAM,eAAe,GAAG,cAAc,CAAC;AAEvC;;;;;;;;;GASG;AACH,SAAS,aAAa,CAAC,KAA0B,EAAE,QAAgB;IACjE,OAAO,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC;AAC3C,CAAC"}
@@ -0,0 +1,324 @@
1
+ /**
2
+ * Populating a tree's resource projection and putting it somewhere ASKABLE —
3
+ * the shared half of every command that runs SQL over it.
4
+ *
5
+ * `vat resources query` runs one statement a person typed; `vat resources check`
6
+ * runs the statements a project wrote down. They differ in what they do with
7
+ * rows and in nothing else: same population, same store selection, same
8
+ * ephemeral fallback, same cache tell. This module is that "and in nothing
9
+ * else", stated once so the two cannot drift into answering about different
10
+ * corpora.
11
+ *
12
+ * ## ðŸšĻ The SQL ALWAYS runs against a per-run in-memory database. Never the store.
13
+ *
14
+ * This is a correctness property, not an optimisation choice, and it was learned
15
+ * the expensive way. The on-disk projection store is **one database per VAT
16
+ * release, shared by every root on the machine** (`defaultStoreDirectory()` is
17
+ * `tmpdir/.vat-cache/<version>/projection-<shapeDigest>`), it retains three tree
18
+ * hashes per root, and its blob tier is never evicted and carries no tree key at
19
+ * all. `ProjectionStore.readExtent` narrows by `(rootId, treeHash)`; **arbitrary
20
+ * SQL does not**, and cannot be made to — a `WHERE` clause the caller wrote is
21
+ * not a key predicate.
22
+ *
23
+ * So running a user's statement against the file-backed store answered from
24
+ * every projection on the machine. Measured on a two-file scratch repository:
25
+ * `SELECT COUNT(*) FROM resource_realizations` returned **3** with no store and
26
+ * **5,779** with one, and `WHERE path LIKE 'packages/%'` returned paths from a
27
+ * different repository entirely. That is a wrong answer and a cross-project
28
+ * disclosure of link text, heading text and frontmatter — the same material
29
+ * `store.ts` cites as the reason it chmods the cache `0o700`.
30
+ *
31
+ * ⇒ The store's job is to make the POPULATION cheap, and that is all. Whatever
32
+ * `populate()` returns — served from the store or derived — is written into a
33
+ * fresh in-memory database that holds this tree and nothing else, and the SQL
34
+ * runs there. The saving is untouched (it was always in the population: on this
35
+ * repository {@link ProjectionProvenance.populationMs} reads 1.16-1.18 s derived
36
+ * against 0.29-0.31 s served), and "one tree, one answer" stops being a claim
37
+ * about how callers behave and becomes a property of the shape.
38
+ *
39
+ * ## The store never reaches a caller
40
+ *
41
+ * Work runs against an `ask` closure rather than a store handle. That is
42
+ * deliberate: `utils/projection-store.ts` is the one module in the toolkit that
43
+ * knows `@vibe-agent-toolkit/projection-sqlite` exists, and handing commands a
44
+ * backend-typed object would spread that knowledge to every future verb. A
45
+ * closure also puts the legible-failure wrapper on the single path that can
46
+ * throw, so no command can forget it.
47
+ */
48
+ import { type Projection } from '@vibe-agent-toolkit/resources';
49
+ import type { Logger } from './logger.js';
50
+ /** Where the POPULATION a statement ran against came from. */
51
+ export type PopulationOrigin = 'derived' | 'store';
52
+ /**
53
+ * What a run's rows are, and where they came from.
54
+ *
55
+ * ⚠ïļ There is deliberately no `engine` field beside these. An earlier version
56
+ * published one (`sqlite | ephemeral`) to say which database answered the SQL;
57
+ * it is gone because the answer is now always the same — see the header — and a
58
+ * field with one possible value tells a reader nothing while implying the other
59
+ * value is reachable.
60
+ */
61
+ export interface ProjectionProvenance {
62
+ /**
63
+ * 🔑 The cache tell. Reported rather than inferred, because it CANNOT be
64
+ * inferred: a correct store hit and a correct re-derivation produce identical
65
+ * rows. A hit short-circuits `populate()` before the builder exists, so no
66
+ * contributor timing is filed — an empty record list IS the hit.
67
+ *
68
+ * It describes the POPULATION, which is the only thing the store now affects.
69
+ */
70
+ readonly population: PopulationOrigin;
71
+ /**
72
+ * 🔑 What that origin was WORTH. {@link population} says whether the
73
+ * projection was served or re-derived; this says what the difference cost, so
74
+ * the tell stops being a bare label a reader has to take on faith.
75
+ *
76
+ * Measured as THIS field, by running `vat resources query 'SELECT COUNT(*) AS
77
+ * n FROM blobs'` against this repository three times per arm with the parse
78
+ * cache warm: **1.16-1.18 s derived against 0.29-0.31 s served**. With a cold
79
+ * parse cache the derived arm is 33-35 s, so the pair above is the store's
80
+ * saving and not the parse cache's.
81
+ *
82
+ * The wall time of the SHARED setup and nothing else: everything
83
+ * {@link withQueriedProjection} does before it hands control to the caller's
84
+ * work — opening the population cache (which, when a store is selected, is a
85
+ * `git write-tree` spawn plus the backend's dynamic import and
86
+ * `openSqliteProjectionStore()`), the git tracker, `buildResourceProjection`,
87
+ * opening the ephemeral database, and writing the blob tier and the extent
88
+ * into it.
89
+ *
90
+ * ⚠ïļ The population cache's CLOSE is outside it, necessarily: that runs in
91
+ * `withPopulationCache`'s `finally`, after the caller's work returns, and a
92
+ * span that ends before the work begins cannot contain it. It is a handle
93
+ * release, not population.
94
+ *
95
+ * ðŸŠĪ **The span's start is load-bearing, and moving it inward is silent.**
96
+ * This shipped with the clock started on the first line INSIDE
97
+ * `withPopulationCache`'s callback — which put the population-cache open, the
98
+ * only part of the setup a store adds, OUTSIDE the measurement, and only on
99
+ * the arm where a store exists. Measured on a two-file corpus with identical
100
+ * total wall time on both arms: no store 0.145 of 0.146 s, cold store 0.0475
101
+ * of 0.161 s. Same work, `populationSecs` three times apart, and a reader
102
+ * comparing a no-store run to a warm-store run read a 42x saving where the
103
+ * honest totals differ by 1.75x. The field was added to stop the cache tell
104
+ * being a label taken on faith and had become the artifact instead. A
105
+ * measurement that flatters one arm is this repository's most-repeated
106
+ * defect; the system suite now pins `populationSecs / durationSecs > 0.6` on a
107
+ * cold run so the next inward move is red rather than quiet.
108
+ *
109
+ * ## Why it belongs on shared provenance rather than on one verb
110
+ *
111
+ * Both verbs pay it, identically, because it is the half of the run they hold
112
+ * in common — a `check` that runs forty statements and a `query` that runs one
113
+ * do the same population first. And a per-statement cost is UNREADABLE without
114
+ * it: `vat resources check` publishes what each rule's SQL cost, and a reader
115
+ * handed forty small numbers and a large total has no way to tell an expensive
116
+ * rule from a setup everybody shares. Absent this field the only arithmetic
117
+ * available is "total minus the statements", which silently attributes the
118
+ * shared setup to whichever rule the reader is looking at.
119
+ *
120
+ * ⚠ïļ Measured with `performance.now()`, not `Date.now()`. A warm population
121
+ * lands well under a millisecond on a small tree, and a millisecond-granularity
122
+ * clock reports that as `0` — which reads as "not measured" rather than "very
123
+ * fast", turning the best case the store has into its least credible number.
124
+ *
125
+ * ⚠ïļ Deliberately ONE number, not a breakdown. Splitting it into crawl, parse
126
+ * and store-load is a real question and it is the lab's: an instrument that
127
+ * gets reviewed and re-run, rather than a product document that would then owe
128
+ * every consumer a stable sub-phase vocabulary.
129
+ */
130
+ readonly populationMs: number;
131
+ /**
132
+ * The lenses this run evaluated, by name, in evaluation order.
133
+ *
134
+ * 🔑 **Published because "which lenses ran" became a DECISION, and an
135
+ * unpublished decision is one nobody can check.** Without it an empty derived
136
+ * relation is ambiguous — no rows, or no evaluation? This is the tell, in the
137
+ * same family as {@link population}, and what makes a `lensSecs` of `0`
138
+ * legible rather than alarming.
139
+ *
140
+ * ⚠ïļ Not the only guard: a relation no evaluated lens produced does not
141
+ * EXIST in the run's database, so a statement naming it is refused by SQLite
142
+ * (see {@link withQueriedProjection}). This field explains a cheap run rather
143
+ * than excusing a blind one.
144
+ */
145
+ readonly lensesEvaluated: readonly string[];
146
+ /**
147
+ * What EVALUATING THE LENSES cost, separately from populating the tree.
148
+ *
149
+ * Separate because the two answer different questions and a reader must be
150
+ * able to tell them apart. Population is work every verb pays and the store
151
+ * can make cheap; this is work the *derived relations* cost, and a store hit
152
+ * does NOT make an authored-link evaluation cheaper — it is a pass over the
153
+ * served rows just as over derived ones. Folded into `populationMs` it would
154
+ * look like the store getting worse.
155
+ *
156
+ * ⚠ïļ **Not an unconditional cost.** A run whose statements name no derived
157
+ * relation evaluates nothing and reports `0`; {@link lensesEvaluated} says
158
+ * which lenses the number covers.
159
+ *
160
+ * ⚠ïļ **DISJOINT from `populationMs`, and that is enforced by where the
161
+ * population clock stops, not by convention.** It shipped overlapping: the
162
+ * population span ended after the lens write, so this value was contained in
163
+ * that one while all three docstrings said otherwise, and anyone adding the
164
+ * two over-counted wall time. If you move either clock, keep them disjoint —
165
+ * a reader comparing a served run against a derived one is the whole reason
166
+ * they are two fields.
167
+ *
168
+ * ⚠ïļ Published rather than merely measured, because a cost that is invisible
169
+ * is the one nobody can argue with. It is the evidence the selection above
170
+ * rests on, and the evidence any future flag would rest on.
171
+ */
172
+ readonly lensMs: number;
173
+ }
174
+ /**
175
+ * How much of the tree the population actually covered.
176
+ *
177
+ * ## Why this is not a field on {@link ProjectionProvenance}
178
+ *
179
+ * Provenance is a fact both verbs PUBLISH verbatim — "these rows were served or
180
+ * re-derived" is the same sentence in either document. This is a fact a verb
181
+ * REASONS with, and only one of them has anything to reason about: `vat
182
+ * resources query` prints the rows a person selected, so its reader can see the
183
+ * extent for themselves, while `vat resources check` prints a verdict and a
184
+ * count of rules. Only the second can pass vacuously, and only the second needs
185
+ * to know.
186
+ *
187
+ * ## 🔑 The failure it exists to make visible
188
+ *
189
+ * `vat resources check` reported how many CHECKS ran; nothing said how many ROWS
190
+ * they ran against. So "four checks passed over eight thousand files" and "four
191
+ * checks passed over ZERO files" were byte-identical documents, and the second
192
+ * was a green gate asserting nothing. A broad `.gitignore`, a shallow or sparse
193
+ * checkout, a root that resolved elsewhere, or an extent source that enumerated
194
+ * nothing all produce it — and `buildResourceProjection` DECLINES ignored
195
+ * members rather than flagging them, so an emptied enumeration leaves no trace
196
+ * in the tables either.
197
+ */
198
+ export interface PopulationExtent {
199
+ /**
200
+ * One per `(extentId, path)` row the population enumerated.
201
+ *
202
+ * ðŸŠĪ Realizations rather than any other count, because every alternative
203
+ * fails to reach zero on the case that matters: `roots` always holds exactly
204
+ * one row (the invariant thrown for below), so a total over every table
205
+ * is never 0; `blobs` is content-keyed and deduped, so it counts parse REACH
206
+ * and already has its own guard in `onBlobPopulation`; and `resources` counts
207
+ * identities, which a corpus can legitimately have none of while enumerating
208
+ * plenty. One row per enumerated path is non-zero exactly when something was
209
+ * enumerated.
210
+ */
211
+ readonly membersEnumerated: number;
212
+ }
213
+ /** One statement a run intends to ask, with the values it will bind to it. */
214
+ export interface PreflightStatement {
215
+ readonly sql: string;
216
+ /** Bound in order, one per `?`. Empty for a statement that binds nothing. */
217
+ readonly parameters: readonly string[];
218
+ }
219
+ /** Run one read-only statement against the populated projection. */
220
+ export type AskProjection = (sql: string, ...parameters: readonly string[]) => readonly Record<string, unknown>[];
221
+ /**
222
+ * Compile every statement a run intends to ask, against the schema and NO rows,
223
+ * before anything is populated.
224
+ *
225
+ * ## 🔑 What this buys, measured
226
+ *
227
+ * SQLite resolves table and column names when a statement is *prepared*, not
228
+ * when it is stepped — so a typo is knowable before a single row exists. It was
229
+ * not knowable in practice, because the only place a statement met the schema
230
+ * was after the projection had been built. On a real adopter tree, `SELECT path,
231
+ * no_such_column â€Ķ` cost **8.3 s**, every millisecond of it spent building a
232
+ * projection the statement could never have read. The same typo now costs the
233
+ * price of an empty in-memory database — one extra `createSchema` into
234
+ * `:memory:`, which is the whole overhead this adds on the happy path.
235
+ *
236
+ * It also moves the KIND refusals — a second statement, an `ATTACH`, a `PRAGMA`
237
+ * — in front of the population, so a statement rejected for what it is costs no
238
+ * more than one rejected for what it names.
239
+ *
240
+ * ⚠ïļ **This is a pre-flight, not a second gate.** `ask` still compiles and runs
241
+ * the real statement against the real projection, and nothing here is trusted in
242
+ * place of that. A statement that compiles here can still fail there — SQLite
243
+ * resolves names against a schema, and this is the same schema, but a run-time
244
+ * error (a bad cast, an overflow) belongs to stepping and is unreachable from a
245
+ * prepare.
246
+ *
247
+ * ⚠ïļ It deliberately does not STEP anything. Stepping is where a check's
248
+ * unbounded cost lives, and a preflight that ran `WITH RECURSIVE â€Ķ` would hang
249
+ * before the run it exists to make cheap had begun.
250
+ *
251
+ * ⚠ïļ Each statement comes WITH the values it will be bound to, because the
252
+ * placeholder count is part of what compiles: a `?` the caller forgot to bind is
253
+ * SQL NULL at run time, and the statement then selects nothing and reports
254
+ * success — the same silent class as a typo'd column, and worth the same early
255
+ * refusal. The backend does the counting; this only has to hand it the values.
256
+ *
257
+ * @param statements - Every statement the run will ask, in any order, each with
258
+ * the values it will bind
259
+ * @throws The same legible failure `ask` throws, for the first statement that
260
+ * does not compile or does not pair its placeholders with its values
261
+ */
262
+ export declare function assertQueriesCompile(statements: readonly PreflightStatement[]): Promise<void>;
263
+ /**
264
+ * Populate the tree, load it into something askable, and hand the caller a way
265
+ * to ask.
266
+ *
267
+ * @param options - The run
268
+ * @param options.root - Absolute corpus root
269
+ * @param options.logger - Where blob-stage refusals are reported (stderr, so a
270
+ * parseable document on stdout stays parseable)
271
+ * @param options.preflight - Every statement this run intends to ask, compiled
272
+ * against the empty schema BEFORE the population starts. See
273
+ * {@link assertQueriesCompile}
274
+ * @param options.statements - Every statement this run may ask, for LENS
275
+ * SELECTION only — never compiled, never bound, and deliberately separate from
276
+ * `preflight`. ⛔ Omitting it evaluates EVERY lens, which is the correct answer
277
+ * and the expensive one
278
+ * @param work - Given the asker, where its rows came from, how much of the tree
279
+ * they cover, and the ROWS THEMSELVES. The store is open for exactly this call
280
+ * and closed however it ends
281
+ * @returns Whatever `work` returned
282
+ */
283
+ export declare function withQueriedProjection<T>(options: {
284
+ root: string;
285
+ logger: Logger;
286
+ preflight?: readonly PreflightStatement[];
287
+ statements?: readonly string[];
288
+ }, work: (ask: AskProjection, provenance: ProjectionProvenance, extent: PopulationExtent, projection: Projection) => Promise<T> | T): Promise<T>;
289
+ /**
290
+ * Turn a rejected statement into a message that names the surface it missed.
291
+ *
292
+ * ## Why this wrapper exists
293
+ *
294
+ * VAT ships no schema version, by standing rule — the *cache* is safe across a
295
+ * shape change because its digest self-invalidates, but submitted SQL is not: it
296
+ * simply breaks. Pre-1.0 that is acceptable. A raw SQLite error reaching the
297
+ * user is not, because `no such column: contentHash` says nothing about what the
298
+ * column is called now. It matters more for a CHECK than for a query: a query's
299
+ * author is at the keyboard, while a check's author wrote it months ago and the
300
+ * person reading the failure is someone else.
301
+ *
302
+ * ⚠ïļ **A legibility wrapper, not a validator.** It does not parse SQL and does
303
+ * not check a statement before running it — it reacts to a failure by listing
304
+ * what the query COULD have named. When the statement mentions a known table,
305
+ * that table's columns are listed, which is the case that actually answers "what
306
+ * moved"; otherwise the table names are, which at least answers "what is there".
307
+ *
308
+ * ðŸŠĪ **Only a name that was not found gets the listing.** The engine also refuses
309
+ * a write and this backend refuses a second statement, and neither is answered by
310
+ * a column list — appending one says the problem is the schema when the problem
311
+ * is what the caller asked for. A wrapper that decorates every failure identically
312
+ * teaches the reader to skip the decoration, which costs the case it was written for.
313
+ *
314
+ * Matching is a plain lowercase substring test rather than a regex: the input is
315
+ * user text, and a pattern built from it is both a lint failure here and a
316
+ * needless hazard.
317
+ *
318
+ * @param sql - The statement that was submitted
319
+ * @param message - What the engine said
320
+ * @returns The message to surface, with the queryable surface appended when the
321
+ * failure was a name this projection does not have
322
+ */
323
+ export declare function describeQueryFailure(sql: string, message: string): string;
324
+ //# sourceMappingURL=projection-query.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projection-query.d.ts","sourceRoot":"","sources":["../../src/utils/projection-query.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AAIH,OAAO,EAKL,KAAK,UAAU,EAChB,MAAM,+BAA+B,CAAC;AAIvC,OAAO,KAAK,EAAE,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