@vibe-agent-toolkit/cli 0.2.0-rc.7 → 0.2.0-rc.8

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 (353) hide show
  1. package/README.md +0 -1
  2. package/dist/bin/vat +34 -19
  3. package/dist/bin/vat.js +34 -19
  4. package/dist/bin/vat.js.map +1 -1
  5. package/dist/bin.js +5 -2
  6. package/dist/bin.js.map +1 -1
  7. package/dist/commands/agent/build.d.ts.map +1 -1
  8. package/dist/commands/agent/build.js +2 -1
  9. package/dist/commands/agent/build.js.map +1 -1
  10. package/dist/commands/agent/import.d.ts.map +1 -1
  11. package/dist/commands/agent/import.js +3 -2
  12. package/dist/commands/agent/import.js.map +1 -1
  13. package/dist/commands/agent/install-path.d.ts +36 -0
  14. package/dist/commands/agent/install-path.d.ts.map +1 -0
  15. package/dist/commands/agent/install-path.js +44 -0
  16. package/dist/commands/agent/install-path.js.map +1 -0
  17. package/dist/commands/agent/install.d.ts.map +1 -1
  18. package/dist/commands/agent/install.js +22 -10
  19. package/dist/commands/agent/install.js.map +1 -1
  20. package/dist/commands/agent/installed.d.ts.map +1 -1
  21. package/dist/commands/agent/installed.js +22 -12
  22. package/dist/commands/agent/installed.js.map +1 -1
  23. package/dist/commands/agent/list.d.ts.map +1 -1
  24. package/dist/commands/agent/list.js +2 -1
  25. package/dist/commands/agent/list.js.map +1 -1
  26. package/dist/commands/agent/run.d.ts.map +1 -1
  27. package/dist/commands/agent/run.js +2 -1
  28. package/dist/commands/agent/run.js.map +1 -1
  29. package/dist/commands/agent/uninstall.d.ts.map +1 -1
  30. package/dist/commands/agent/uninstall.js +13 -6
  31. package/dist/commands/agent/uninstall.js.map +1 -1
  32. package/dist/commands/agent/validate.d.ts.map +1 -1
  33. package/dist/commands/agent/validate.js +3 -2
  34. package/dist/commands/agent/validate.js.map +1 -1
  35. package/dist/commands/ard/emit.d.ts +72 -23
  36. package/dist/commands/ard/emit.d.ts.map +1 -1
  37. package/dist/commands/ard/emit.js +109 -56
  38. package/dist/commands/ard/emit.js.map +1 -1
  39. package/dist/commands/ard/index.d.ts +1 -1
  40. package/dist/commands/ard/index.d.ts.map +1 -1
  41. package/dist/commands/ard/index.js +4 -3
  42. package/dist/commands/ard/index.js.map +1 -1
  43. package/dist/commands/audit/distributed-tree.d.ts.map +1 -1
  44. package/dist/commands/audit/distributed-tree.js +9 -6
  45. package/dist/commands/audit/distributed-tree.js.map +1 -1
  46. package/dist/commands/audit/scan-population.d.ts +158 -0
  47. package/dist/commands/audit/scan-population.d.ts.map +1 -0
  48. package/dist/commands/audit/scan-population.js +292 -0
  49. package/dist/commands/audit/scan-population.js.map +1 -0
  50. package/dist/commands/audit-settings.d.ts.map +1 -1
  51. package/dist/commands/audit-settings.js +6 -5
  52. package/dist/commands/audit-settings.js.map +1 -1
  53. package/dist/commands/audit.d.ts +16 -14
  54. package/dist/commands/audit.d.ts.map +1 -1
  55. package/dist/commands/audit.js +304 -389
  56. package/dist/commands/audit.js.map +1 -1
  57. package/dist/commands/build.d.ts.map +1 -1
  58. package/dist/commands/build.js +24 -24
  59. package/dist/commands/build.js.map +1 -1
  60. package/dist/commands/cache/clear.d.ts.map +1 -1
  61. package/dist/commands/cache/clear.js +17 -10
  62. package/dist/commands/cache/clear.js.map +1 -1
  63. package/dist/commands/claude/budget.d.ts +127 -28
  64. package/dist/commands/claude/budget.d.ts.map +1 -1
  65. package/dist/commands/claude/budget.js +76 -33
  66. package/dist/commands/claude/budget.js.map +1 -1
  67. package/dist/commands/claude/context.d.ts.map +1 -1
  68. package/dist/commands/claude/context.js +3 -2
  69. package/dist/commands/claude/context.js.map +1 -1
  70. package/dist/commands/claude/marketplace/changelog-utils.d.ts +1 -1
  71. package/dist/commands/claude/marketplace/changelog-utils.d.ts.map +1 -1
  72. package/dist/commands/claude/marketplace/changelog-utils.js +1 -2
  73. package/dist/commands/claude/marketplace/changelog-utils.js.map +1 -1
  74. package/dist/commands/claude/marketplace/git-publish.d.ts.map +1 -1
  75. package/dist/commands/claude/marketplace/git-publish.js +3 -2
  76. package/dist/commands/claude/marketplace/git-publish.js.map +1 -1
  77. package/dist/commands/claude/marketplace/license-utils.d.ts.map +1 -1
  78. package/dist/commands/claude/marketplace/license-utils.js +0 -1
  79. package/dist/commands/claude/marketplace/license-utils.js.map +1 -1
  80. package/dist/commands/claude/marketplace/publish-tree.d.ts.map +1 -1
  81. package/dist/commands/claude/marketplace/publish-tree.js +0 -6
  82. package/dist/commands/claude/marketplace/publish-tree.js.map +1 -1
  83. package/dist/commands/claude/marketplace/publish.d.ts.map +1 -1
  84. package/dist/commands/claude/marketplace/publish.js +2 -1
  85. package/dist/commands/claude/marketplace/publish.js.map +1 -1
  86. package/dist/commands/claude/marketplace/validate.d.ts.map +1 -1
  87. package/dist/commands/claude/marketplace/validate.js +25 -15
  88. package/dist/commands/claude/marketplace/validate.js.map +1 -1
  89. package/dist/commands/claude/org/api-keys.d.ts +0 -3
  90. package/dist/commands/claude/org/api-keys.d.ts.map +1 -1
  91. package/dist/commands/claude/org/api-keys.js +2 -1
  92. package/dist/commands/claude/org/api-keys.js.map +1 -1
  93. package/dist/commands/claude/org/helpers.d.ts +17 -22
  94. package/dist/commands/claude/org/helpers.d.ts.map +1 -1
  95. package/dist/commands/claude/org/helpers.js +6 -22
  96. package/dist/commands/claude/org/helpers.js.map +1 -1
  97. package/dist/commands/claude/org/invites.d.ts +0 -3
  98. package/dist/commands/claude/org/invites.d.ts.map +1 -1
  99. package/dist/commands/claude/org/invites.js +3 -2
  100. package/dist/commands/claude/org/invites.js.map +1 -1
  101. package/dist/commands/claude/org/skills.d.ts +19 -1
  102. package/dist/commands/claude/org/skills.d.ts.map +1 -1
  103. package/dist/commands/claude/org/skills.js +141 -105
  104. package/dist/commands/claude/org/skills.js.map +1 -1
  105. package/dist/commands/claude/org/users.d.ts +0 -3
  106. package/dist/commands/claude/org/users.d.ts.map +1 -1
  107. package/dist/commands/claude/org/users.js +3 -2
  108. package/dist/commands/claude/org/users.js.map +1 -1
  109. package/dist/commands/claude/org/workspaces.d.ts +0 -3
  110. package/dist/commands/claude/org/workspaces.d.ts.map +1 -1
  111. package/dist/commands/claude/org/workspaces.js +6 -5
  112. package/dist/commands/claude/org/workspaces.js.map +1 -1
  113. package/dist/commands/claude/plugin/build.d.ts.map +1 -1
  114. package/dist/commands/claude/plugin/build.js +12 -31
  115. package/dist/commands/claude/plugin/build.js.map +1 -1
  116. package/dist/commands/claude/plugin/helpers.d.ts.map +1 -1
  117. package/dist/commands/claude/plugin/helpers.js +0 -6
  118. package/dist/commands/claude/plugin/helpers.js.map +1 -1
  119. package/dist/commands/claude/plugin/install.d.ts +12 -0
  120. package/dist/commands/claude/plugin/install.d.ts.map +1 -1
  121. package/dist/commands/claude/plugin/install.js +71 -60
  122. package/dist/commands/claude/plugin/install.js.map +1 -1
  123. package/dist/commands/claude/plugin/list.d.ts.map +1 -1
  124. package/dist/commands/claude/plugin/list.js +3 -2
  125. package/dist/commands/claude/plugin/list.js.map +1 -1
  126. package/dist/commands/claude/plugin/plugin-changelog.d.ts.map +1 -1
  127. package/dist/commands/claude/plugin/plugin-changelog.js +0 -2
  128. package/dist/commands/claude/plugin/plugin-changelog.js.map +1 -1
  129. package/dist/commands/claude/plugin/plugin-files.d.ts.map +1 -1
  130. package/dist/commands/claude/plugin/plugin-files.js +0 -3
  131. package/dist/commands/claude/plugin/plugin-files.js.map +1 -1
  132. package/dist/commands/claude/plugin/plugin-validators.d.ts.map +1 -1
  133. package/dist/commands/claude/plugin/plugin-validators.js +3 -6
  134. package/dist/commands/claude/plugin/plugin-validators.js.map +1 -1
  135. package/dist/commands/claude/plugin/tree-copy.d.ts +2 -1
  136. package/dist/commands/claude/plugin/tree-copy.d.ts.map +1 -1
  137. package/dist/commands/claude/plugin/tree-copy.js +15 -14
  138. package/dist/commands/claude/plugin/tree-copy.js.map +1 -1
  139. package/dist/commands/claude/plugin/uninstall.d.ts.map +1 -1
  140. package/dist/commands/claude/plugin/uninstall.js +4 -4
  141. package/dist/commands/claude/plugin/uninstall.js.map +1 -1
  142. package/dist/commands/consistency-check.d.ts +9 -13
  143. package/dist/commands/consistency-check.d.ts.map +1 -1
  144. package/dist/commands/consistency-check.js +91 -81
  145. package/dist/commands/consistency-check.js.map +1 -1
  146. package/dist/commands/corpus/report.d.ts.map +1 -1
  147. package/dist/commands/corpus/report.js +1 -2
  148. package/dist/commands/corpus/report.js.map +1 -1
  149. package/dist/commands/corpus/runner.d.ts.map +1 -1
  150. package/dist/commands/corpus/runner.js +2 -6
  151. package/dist/commands/corpus/runner.js.map +1 -1
  152. package/dist/commands/corpus/scan.d.ts.map +1 -1
  153. package/dist/commands/corpus/scan.js +2 -3
  154. package/dist/commands/corpus/scan.js.map +1 -1
  155. package/dist/commands/corpus/seed.d.ts +4 -4
  156. package/dist/commands/corpus/seed.d.ts.map +1 -1
  157. package/dist/commands/corpus/seed.js +1 -3
  158. package/dist/commands/corpus/seed.js.map +1 -1
  159. package/dist/commands/doctor.d.ts.map +1 -1
  160. package/dist/commands/doctor.js +55 -37
  161. package/dist/commands/doctor.js.map +1 -1
  162. package/dist/commands/inventory.d.ts.map +1 -1
  163. package/dist/commands/inventory.js +6 -7
  164. package/dist/commands/inventory.js.map +1 -1
  165. package/dist/commands/mcp/list-collections.d.ts.map +1 -1
  166. package/dist/commands/mcp/list-collections.js +2 -1
  167. package/dist/commands/mcp/list-collections.js.map +1 -1
  168. package/dist/commands/mcp/serve.d.ts.map +1 -1
  169. package/dist/commands/mcp/serve.js +3 -2
  170. package/dist/commands/mcp/serve.js.map +1 -1
  171. package/dist/commands/okf/index.d.ts.map +1 -1
  172. package/dist/commands/okf/index.js +14 -2
  173. package/dist/commands/okf/index.js.map +1 -1
  174. package/dist/commands/okf/validate.d.ts +157 -48
  175. package/dist/commands/okf/validate.d.ts.map +1 -1
  176. package/dist/commands/okf/validate.js +109 -76
  177. package/dist/commands/okf/validate.js.map +1 -1
  178. package/dist/commands/phase-utils.d.ts +11 -10
  179. package/dist/commands/phase-utils.d.ts.map +1 -1
  180. package/dist/commands/phase-utils.js +30 -14
  181. package/dist/commands/phase-utils.js.map +1 -1
  182. package/dist/commands/positional-args.d.ts.map +1 -1
  183. package/dist/commands/positional-args.js +2 -1
  184. package/dist/commands/positional-args.js.map +1 -1
  185. package/dist/commands/rag/clear-command.d.ts.map +1 -1
  186. package/dist/commands/rag/clear-command.js +2 -1
  187. package/dist/commands/rag/clear-command.js.map +1 -1
  188. package/dist/commands/rag/index-command.d.ts.map +1 -1
  189. package/dist/commands/rag/index-command.js +4 -1
  190. package/dist/commands/rag/index-command.js.map +1 -1
  191. package/dist/commands/rag/query-command.d.ts.map +1 -1
  192. package/dist/commands/rag/query-command.js +2 -1
  193. package/dist/commands/rag/query-command.js.map +1 -1
  194. package/dist/commands/rag/stats-command.d.ts.map +1 -1
  195. package/dist/commands/rag/stats-command.js +2 -1
  196. package/dist/commands/rag/stats-command.js.map +1 -1
  197. package/dist/commands/resources/check-progress.d.ts.map +1 -1
  198. package/dist/commands/resources/check-progress.js +5 -2
  199. package/dist/commands/resources/check-progress.js.map +1 -1
  200. package/dist/commands/resources/check-supervisor.d.ts.map +1 -1
  201. package/dist/commands/resources/check-supervisor.js +14 -7
  202. package/dist/commands/resources/check-supervisor.js.map +1 -1
  203. package/dist/commands/resources/check.d.ts +135 -4
  204. package/dist/commands/resources/check.d.ts.map +1 -1
  205. package/dist/commands/resources/check.js +97 -80
  206. package/dist/commands/resources/check.js.map +1 -1
  207. package/dist/commands/resources/index.d.ts.map +1 -1
  208. package/dist/commands/resources/index.js +24 -21
  209. package/dist/commands/resources/index.js.map +1 -1
  210. package/dist/commands/resources/query.d.ts.map +1 -1
  211. package/dist/commands/resources/query.js +4 -8
  212. package/dist/commands/resources/query.js.map +1 -1
  213. package/dist/commands/resources/scan.d.ts.map +1 -1
  214. package/dist/commands/resources/scan.js +4 -8
  215. package/dist/commands/resources/scan.js.map +1 -1
  216. package/dist/commands/resources/validate.d.ts +1 -1
  217. package/dist/commands/resources/validate.d.ts.map +1 -1
  218. package/dist/commands/resources/validate.js +0 -1
  219. package/dist/commands/resources/validate.js.map +1 -1
  220. package/dist/commands/skill/review-checklist.d.ts +3 -2
  221. package/dist/commands/skill/review-checklist.d.ts.map +1 -1
  222. package/dist/commands/skill/review-checklist.js +4 -2
  223. package/dist/commands/skill/review-checklist.js.map +1 -1
  224. package/dist/commands/skill/review.d.ts +247 -0
  225. package/dist/commands/skill/review.d.ts.map +1 -1
  226. package/dist/commands/skill/review.js +90 -60
  227. package/dist/commands/skill/review.js.map +1 -1
  228. package/dist/commands/skill/test/configure.d.ts.map +1 -1
  229. package/dist/commands/skill/test/configure.js +0 -1
  230. package/dist/commands/skill/test/configure.js.map +1 -1
  231. package/dist/commands/skill/test/run.d.ts +12 -6
  232. package/dist/commands/skill/test/run.d.ts.map +1 -1
  233. package/dist/commands/skill/test/run.js +118 -63
  234. package/dist/commands/skill/test/run.js.map +1 -1
  235. package/dist/commands/skills/build.d.ts +69 -2
  236. package/dist/commands/skills/build.d.ts.map +1 -1
  237. package/dist/commands/skills/build.js +112 -39
  238. package/dist/commands/skills/build.js.map +1 -1
  239. package/dist/commands/skills/install.d.ts +2 -1
  240. package/dist/commands/skills/install.d.ts.map +1 -1
  241. package/dist/commands/skills/install.js +20 -30
  242. package/dist/commands/skills/install.js.map +1 -1
  243. package/dist/commands/skills/list.d.ts.map +1 -1
  244. package/dist/commands/skills/list.js +14 -18
  245. package/dist/commands/skills/list.js.map +1 -1
  246. package/dist/commands/skills/package.d.ts +1 -1
  247. package/dist/commands/skills/package.d.ts.map +1 -1
  248. package/dist/commands/skills/package.js +6 -8
  249. package/dist/commands/skills/package.js.map +1 -1
  250. package/dist/commands/skills/scope-guard.d.ts.map +1 -1
  251. package/dist/commands/skills/scope-guard.js +2 -4
  252. package/dist/commands/skills/scope-guard.js.map +1 -1
  253. package/dist/commands/skills/shared.d.ts.map +1 -1
  254. package/dist/commands/skills/shared.js +2 -4
  255. package/dist/commands/skills/shared.js.map +1 -1
  256. package/dist/commands/skills/skill-discovery.d.ts.map +1 -1
  257. package/dist/commands/skills/skill-discovery.js +0 -1
  258. package/dist/commands/skills/skill-discovery.js.map +1 -1
  259. package/dist/commands/skills/source-resolvers.d.ts +15 -0
  260. package/dist/commands/skills/source-resolvers.d.ts.map +1 -1
  261. package/dist/commands/skills/source-resolvers.js +25 -4
  262. package/dist/commands/skills/source-resolvers.js.map +1 -1
  263. package/dist/commands/validate.d.ts +1 -1
  264. package/dist/commands/validate.js +8 -6
  265. package/dist/commands/validate.js.map +1 -1
  266. package/dist/commands/verify.d.ts +8 -2
  267. package/dist/commands/verify.d.ts.map +1 -1
  268. package/dist/commands/verify.js +86 -56
  269. package/dist/commands/verify.js.map +1 -1
  270. package/dist/index.d.ts +0 -1
  271. package/dist/index.d.ts.map +1 -1
  272. package/dist/index.js +5 -1
  273. package/dist/index.js.map +1 -1
  274. package/dist/report-schemas.d.ts +45 -0
  275. package/dist/report-schemas.d.ts.map +1 -0
  276. package/dist/report-schemas.js +102 -0
  277. package/dist/report-schemas.js.map +1 -0
  278. package/dist/skill-resolution/resolve-skill-reference.d.ts.map +1 -1
  279. package/dist/skill-resolution/resolve-skill-reference.js +2 -3
  280. package/dist/skill-resolution/resolve-skill-reference.js.map +1 -1
  281. package/dist/utils/agent-discovery.d.ts.map +1 -1
  282. package/dist/utils/agent-discovery.js +22 -11
  283. package/dist/utils/agent-discovery.js.map +1 -1
  284. package/dist/utils/agent-runner.d.ts.map +1 -1
  285. package/dist/utils/agent-runner.js +0 -1
  286. package/dist/utils/agent-runner.js.map +1 -1
  287. package/dist/utils/command-error.d.ts +63 -62
  288. package/dist/utils/command-error.d.ts.map +1 -1
  289. package/dist/utils/command-error.js +80 -76
  290. package/dist/utils/command-error.js.map +1 -1
  291. package/dist/utils/config-loader.d.ts +2 -1
  292. package/dist/utils/config-loader.d.ts.map +1 -1
  293. package/dist/utils/config-loader.js +3 -6
  294. package/dist/utils/config-loader.js.map +1 -1
  295. package/dist/utils/context-budget-issues.d.ts +1 -1
  296. package/dist/utils/context-budget-issues.js +1 -1
  297. package/dist/utils/corpus-target.d.ts +5 -27
  298. package/dist/utils/corpus-target.d.ts.map +1 -1
  299. package/dist/utils/corpus-target.js +7 -33
  300. package/dist/utils/corpus-target.js.map +1 -1
  301. package/dist/utils/help-loader.d.ts.map +1 -1
  302. package/dist/utils/help-loader.js +0 -1
  303. package/dist/utils/help-loader.js.map +1 -1
  304. package/dist/utils/issue-rendering.d.ts +2 -2
  305. package/dist/utils/issue-rendering.js +2 -2
  306. package/dist/utils/optional-backend.d.ts.map +1 -1
  307. package/dist/utils/optional-backend.js +2 -1
  308. package/dist/utils/optional-backend.js.map +1 -1
  309. package/dist/utils/output.d.ts +9 -0
  310. package/dist/utils/output.d.ts.map +1 -1
  311. package/dist/utils/output.js +16 -0
  312. package/dist/utils/output.js.map +1 -1
  313. package/dist/utils/package-json.d.ts +24 -0
  314. package/dist/utils/package-json.d.ts.map +1 -0
  315. package/dist/utils/package-json.js +49 -0
  316. package/dist/utils/package-json.js.map +1 -0
  317. package/dist/utils/project-root-policy.d.ts.map +1 -1
  318. package/dist/utils/project-root-policy.js +0 -2
  319. package/dist/utils/project-root-policy.js.map +1 -1
  320. package/dist/utils/resource-loader.js +2 -2
  321. package/dist/utils/resource-loader.js.map +1 -1
  322. package/dist/utils/skill-packaging-config.d.ts +27 -0
  323. package/dist/utils/skill-packaging-config.d.ts.map +1 -1
  324. package/dist/utils/skill-packaging-config.js +30 -0
  325. package/dist/utils/skill-packaging-config.js.map +1 -1
  326. package/dist/utils/url-redact.d.ts.map +1 -1
  327. package/dist/utils/url-redact.js +4 -6
  328. package/dist/utils/url-redact.js.map +1 -1
  329. package/dist/utils/user-context-scanner.d.ts.map +1 -1
  330. package/dist/utils/user-context-scanner.js +0 -2
  331. package/dist/utils/user-context-scanner.js.map +1 -1
  332. package/dist/utils/validate-help-files.d.ts.map +1 -1
  333. package/dist/utils/validate-help-files.js +3 -4
  334. package/dist/utils/validate-help-files.js.map +1 -1
  335. package/dist/utils/vat-bin-path.d.ts.map +1 -1
  336. package/dist/utils/vat-bin-path.js +0 -1
  337. package/dist/utils/vat-bin-path.js.map +1 -1
  338. package/dist/version.d.ts.map +1 -1
  339. package/dist/version.js +1 -3
  340. package/dist/version.js.map +1 -1
  341. package/docs/audit.md +44 -53
  342. package/docs/doctor.md +1 -0
  343. package/docs/index.md +18 -10
  344. package/docs/rag.md +0 -1
  345. package/docs/resources.md +0 -1
  346. package/docs/skill-test.md +10 -9
  347. package/docs/skills.md +6 -7
  348. package/package.json +22 -27
  349. package/schemas/ard-emit.json +149 -0
  350. package/schemas/claude-budget.json +197 -0
  351. package/schemas/okf-validate.json +170 -0
  352. package/schemas/resources-check.json +186 -0
  353. package/schemas/skill-review.json +230 -0
@@ -1,13 +1,15 @@
1
1
  /**
2
2
  * Shared command error handling utilities.
3
3
  *
4
- * THE single implementation of each failure exit. `commands/skills/` used to
4
+ * The failure endings a command may take, each publishing a document and
5
+ * ending on one member of the `ExitCode` contract. `commands/skills/` used to
5
6
  * carry its own `handleCommandError` that logged to stderr and exited 2 having
6
7
  * written nothing to stdout — same name, same signature, same documented
7
- * contract, silently different behaviour. Every command family routes here.
8
+ * contract, silently different behaviour. A command that ends some other way
9
+ * still names its code from `ExitCode`; the lint rule
10
+ * `no-literal-process-exit` refuses a bare number.
8
11
  */
9
- import { inspect } from 'node:util';
10
- import { countBySeverity } from '@vibe-agent-toolkit/schema';
12
+ import { ExitCode, buildErrorReport, countBySeverity, errorDiagnostics } from '@vibe-agent-toolkit/schema';
11
13
  import { writeJsonOutput, writeYamlOutput } from './output.js';
12
14
  /**
13
15
  * Format duration for human readability
@@ -23,31 +25,6 @@ export function formatDuration(ms) {
23
25
  }
24
26
  return `${(ms / 60000).toFixed(1)}m`;
25
27
  }
26
- /**
27
- * Everything about a thrown value that `error.message` alone discards.
28
- *
29
- * Exit 2 is the UNEXPECTED failure — an internal bug, not a usage mistake — and
30
- * the one thing a reader needs there is the frame that threw. A real `TypeError`
31
- * arrived here as a single line (`Cannot read properties of undefined (reading
32
- * 'readdir')`) with no file, no frames, and no flag that would produce them; the
33
- * only way to find the throw site was to hand-patch the built `dist`. A value
34
- * thrown that is not an `Error` fared worse still — the envelope flattens it to
35
- * the literal string `Unknown error`, which names neither its type nor its
36
- * contents.
37
- *
38
- * The result rides the logger's **debug** channel (`--debug`), so default output
39
- * is unchanged and no golden moves.
40
- *
41
- * @param error - The value that was thrown
42
- * @returns Stack trace for an `Error`, or an inspected rendering of a non-`Error`
43
- */
44
- export function errorDiagnostics(error) {
45
- if (error instanceof Error) {
46
- // `stack` is optional in the type and absent on some cross-realm errors.
47
- return error.stack ?? `${error.name}: ${error.message}`;
48
- }
49
- return `Non-Error value thrown: ${inspect(error, { depth: 3 })}`;
50
- }
51
28
  /**
52
29
  * Report an unexpected failure on stderr and return the document that describes
53
30
  * it, WITHOUT deciding how the caller ends.
@@ -78,8 +55,8 @@ export function reportCommandError(error, logger, startTime, commandName) {
78
55
  /**
79
56
  * Handle command error with standard formatting and exit.
80
57
  *
81
- * The command-line ending for {@link reportCommandError}. Exit 2 is the
82
- * UNEXPECTED failure, per the exit-code contract every command's help documents.
58
+ * The command-line ending for {@link reportCommandError}. `ExitCode.ERROR` is
59
+ * the UNEXPECTED failure, per the exit-code contract every command's help documents.
83
60
  *
84
61
  * 🔑 **`format` is not decoration.** Every command offering `--format json`
85
62
  * honoured it on the success path and emitted YAML here, so the one document a
@@ -98,25 +75,19 @@ export function reportCommandError(error, logger, startTime, commandName) {
98
75
  */
99
76
  export function handleCommandError(error, logger, startTime, commandName, format) {
100
77
  const document = reportCommandError(error, logger, startTime, commandName);
101
- if (format === 'json') {
102
- writeJsonOutput(document);
103
- }
104
- else {
105
- writeYamlOutput(document);
106
- }
107
- process.exit(2);
78
+ return publishFailure(document, format, ExitCode.ERROR);
108
79
  }
109
80
  /**
110
81
  * Publish an EXPECTED failure in the format the operator asked for, then exit
111
82
  * with the code the command's own contract assigns it.
112
83
  *
113
84
  * The third ending of one failure, beside {@link handleCommandError} (the
114
- * UNEXPECTED failure, always exit 2) and {@link handleValidationGateFailure}
115
- * (a validation gate, always exit 1, always YAML). This one covers the failure
116
- * that is neither: the command ran, understood the project, and has a
117
- * documented non-zero code for what it found — `vat ard emit` exiting 1 for
118
- * "this project declares no `ard:` block" or 2 for "there is no config file
119
- * here".
85
+ * UNEXPECTED failure, always `ERROR`) and {@link handleValidationGateFailure}
86
+ * (a validation gate, always `FINDINGS`, always YAML). This one covers the
87
+ * failure that is neither: the command ran, understood the project, and has a
88
+ * documented non-zero code for what it found — `vat ard emit` ending on
89
+ * `FINDINGS` for "this project declares no `ard:` block" or `ERROR` for "there
90
+ * is no config file here".
120
91
  *
121
92
  * 🔑 It exists because those endings were written inline, and an inline ending
122
93
  * publishes nothing: `ard emit` honoured `--format json` on its success path
@@ -143,6 +114,16 @@ export function handleExpectedFailure(message, exitCode, startTime, format) {
143
114
  error: message,
144
115
  duration: formatDuration(Date.now() - startTime),
145
116
  };
117
+ return publishFailure(document, format, exitCode);
118
+ }
119
+ /**
120
+ * Publish a failure document in the operator's format, then end on `exitCode`.
121
+ *
122
+ * @param document - What to write to stdout
123
+ * @param format - `json`, or anything else (and omitted) for YAML
124
+ * @param exitCode - The member of the contract this ending is
125
+ */
126
+ function publishFailure(document, format, exitCode) {
146
127
  if (format === 'json') {
147
128
  writeJsonOutput(document);
148
129
  }
@@ -151,6 +132,40 @@ export function handleExpectedFailure(message, exitCode, startTime, format) {
151
132
  }
152
133
  process.exit(exitCode);
153
134
  }
135
+ /**
136
+ * {@link handleCommandError} for a command whose document is the shared
137
+ * `Report<T>` envelope: the failure document IS the envelope
138
+ * (`buildErrorReport`), so the emitted `schemas/<command>.json` describes the
139
+ * failed run too. Every command registered as `report` in `report-schemas.ts`
140
+ * ends its unexpected failures here; `handleCommandError`'s
141
+ * `CommandErrorDocument` is the shape the legacy documents keep.
142
+ *
143
+ * @param error - The value that was thrown
144
+ * @param logger - Logger instance for error output
145
+ * @param startTime - Command start time (from Date.now())
146
+ * @param commandName - Name of the command (for the stderr line)
147
+ * @param format - What the operator asked for: `json`, or anything else (and
148
+ * omitted) for YAML
149
+ */
150
+ export function handleReportCommandError(error, logger, startTime, commandName, format) {
151
+ const { error: message } = reportCommandError(error, logger, startTime, commandName);
152
+ return publishFailure(buildErrorReport(message, Date.now() - startTime), format, ExitCode.ERROR);
153
+ }
154
+ /**
155
+ * {@link handleExpectedFailure} for a command whose document is the shared
156
+ * `Report<T>` envelope — same document as {@link handleReportCommandError},
157
+ * with the exit code the command's own contract assigns.
158
+ *
159
+ * @param message - What went wrong, in the command's own words
160
+ * @param exitCode - The code this command's `--help` assigns to this outcome
161
+ * @param startTime - Command start time (from Date.now())
162
+ * @param format - What the operator asked for: `json`, or anything else (and
163
+ * omitted) for YAML
164
+ */
165
+ export function handleReportExpectedFailure(message, exitCode, startTime, format) {
166
+ process.stderr.write(`${message}\n`);
167
+ return publishFailure(buildErrorReport(message, Date.now() - startTime), format, exitCode);
168
+ }
154
169
  /**
155
170
  * Pure: the document {@link handleValidationGateFailure} writes.
156
171
  *
@@ -163,9 +178,9 @@ export function buildValidationGateFailure(subject, issues) {
163
178
  }
164
179
  /**
165
180
  * Publish the documented failure payload for a command stopped by its OWN
166
- * validation gate, then exit 1.
181
+ * validation gate, then end on `FINDINGS`.
167
182
  *
168
- * {@link handleCommandError} above covers the UNEXPECTED failure (exit 2). This
183
+ * {@link handleCommandError} above covers the UNEXPECTED failure (`ERROR`). This
169
184
  * covers the expected one, and `vat skills build` / `vat skills package` both
170
185
  * exited it after writing zero bytes to stdout — while their `--help` texts
171
186
  * document a YAML summary on stdout and reserve exit 1 for exactly this case.
@@ -174,42 +189,31 @@ export function buildValidationGateFailure(subject, issues) {
174
189
  */
175
190
  export function handleValidationGateFailure(subject, issues) {
176
191
  writeYamlOutput(buildValidationGateFailure(subject, issues));
177
- process.exit(1);
192
+ process.exit(ExitCode.FINDINGS);
178
193
  }
179
- /**
180
- * The exit code a USAGE mistake ends on: a flag this program does not declare,
181
- * a verb it does not know, a missing or invalid argument.
182
- *
183
- * 🔑 **Two is not a style choice — one was a factual lie.** Every command's
184
- * `--help` publishes the same three-way contract: `0` no error-severity
185
- * findings, `1` at least one, `2` a system error. Commander's default for a
186
- * usage mistake is `process.exit(1)`, so `vat resources check --json` (the
187
- * option is `--format json`) exited **1** — which, read against the contract
188
- * the command itself prints, asserts that at least one check was violated.
189
- * Nothing had run. A CI wrapper spelled `if [ $? -ne 0 ]; then report_findings`
190
- * therefore reported findings that were never computed, and the operator went
191
- * looking for a violation that did not exist.
192
- *
193
- * The same hole swallowed a mistyped verb (`vat resources chekc`) and every
194
- * unknown option on all 69 commands. VAT's own refusals were already correct —
195
- * an unknown `--check` name and an unusable `--budget` both exit 2 — so the
196
- * inconsistency was Commander's default leaking through the one path VAT had
197
- * not claimed.
198
- *
199
- * ⚠️ **Help and `--version` are NOT usage mistakes.** They terminate through
200
- * the same `_exit` path with code 0 and must stay 0; only a non-zero commander
201
- * ending is remapped. See {@link exitCodeForCommanderEnding}.
202
- */
203
- export const USAGE_ERROR_EXIT_CODE = 2;
204
194
  /**
205
195
  * Map a commander termination to the exit code VAT's contract promises.
206
196
  *
197
+ * A USAGE mistake — a flag this program does not declare, a verb it does not
198
+ * know, a missing or invalid argument — ends on `ExitCode.ERROR`, and the
199
+ * reason is not style. Commander's default for a usage mistake is
200
+ * `process.exit(1)`, so `vat resources check --json` (the option is
201
+ * `--format json`) exited **1** — which, read against the contract the command
202
+ * itself prints, asserts that at least one check was violated. Nothing had
203
+ * run. A CI wrapper spelled `if [ $? -ne 0 ]; then report_findings` therefore
204
+ * reported findings that were never computed. The same hole swallowed a
205
+ * mistyped verb (`vat resources chekc`) and every unknown option on every
206
+ * command.
207
+ *
207
208
  * Commander reports BOTH successful and failing terminations through the same
208
209
  * `CommanderError`: `--help` and `--version` carry `exitCode` 0, while an
209
210
  * unknown option, an unknown command and `help({ error: true })` carry non-zero.
210
211
  * Anything non-zero is a usage mistake by construction — commander raises these
211
- * only while parsing, before any action runs — so it maps to
212
- * {@link USAGE_ERROR_EXIT_CODE}.
212
+ * only while parsing, before any action runs — so it maps to `ERROR`.
213
+ *
214
+ * ⚠️ **Help and `--version` are NOT usage mistakes.** They terminate through
215
+ * the same `_exit` path with code 0 and must stay `OK`; only a non-zero
216
+ * commander ending is remapped.
213
217
  *
214
218
  * 🪤 Do NOT switch on `error.code` (`commander.unknownOption`, `commander.help`,
215
219
  * …). The unknown-COMMAND path arrives as `commander.help` with exitCode 1,
@@ -218,9 +222,9 @@ export const USAGE_ERROR_EXIT_CODE = 2;
218
222
  * code commander already computed is the honest discriminator; the string is not.
219
223
  *
220
224
  * @param commanderExitCode - The `exitCode` commander put on its CommanderError
221
- * @returns 0 for a successful ending, {@link USAGE_ERROR_EXIT_CODE} otherwise
225
+ * @returns `OK` for a successful ending, `ERROR` otherwise
222
226
  */
223
227
  export function exitCodeForCommanderEnding(commanderExitCode) {
224
- return commanderExitCode === 0 ? 0 : USAGE_ERROR_EXIT_CODE;
228
+ return commanderExitCode === 0 ? ExitCode.OK : ExitCode.ERROR;
225
229
  }
226
230
  //# sourceMappingURL=command-error.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"command-error.js","sourceRoot":"","sources":["../../src/utils/command-error.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,eAAe,EAA6C,MAAM,4BAA4B,CAAC;AAGxG,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE/D;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,EAAU;IACvC,IAAI,EAAE,GAAG,IAAI,EAAE,CAAC;QACd,OAAO,GAAG,EAAE,IAAI,CAAC;IACnB,CAAC;IACD,IAAI,EAAE,GAAG,KAAK,EAAE,CAAC;QAC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AC,iBAAyB;IAClE,OAAO,iBAAiB,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC;AAChE,CAAC"}
@@ -5,6 +5,7 @@
5
5
  * - VAT_TEST_CONFIG: Override config file path for testing (absolute path)
6
6
  */
7
7
  import { type ProjectConfig } from '@vibe-agent-toolkit/resources';
8
+ import { VatError } from '@vibe-agent-toolkit/utils';
8
9
  /**
9
10
  * A `vibe-agent-toolkit.config.yaml` exists but failed to parse or validate.
10
11
  *
@@ -14,7 +15,7 @@ import { type ProjectConfig } from '@vibe-agent-toolkit/resources';
14
15
  * `vat skill test`) should surface this; a bulk linter (`vat audit`) may catch
15
16
  * it and fall back to config-free validation.
16
17
  */
17
- export declare class ConfigLoadError extends Error {
18
+ export declare class ConfigLoadError extends VatError {
18
19
  readonly projectRoot: string;
19
20
  constructor(projectRoot: string, cause: unknown);
20
21
  }
@@ -1 +1 @@
1
- {"version":3,"file":"config-loader.d.ts","sourceRoot":"","sources":["../../src/utils/config-loader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,EAAuD,KAAK,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAaxH;;;;;;;;GAQG;AACH,qBAAa,eAAgB,SAAQ,KAAK;IACxC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;gBACjB,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO;CAMhD;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,UAAU,CAAC,WAAW,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAkDzE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAEvD;AAqBD;;;;;GAKG;AACH,wBAAgB,sBAAsB,IAAI,IAAI,CAM7C;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAgB/E"}
1
+ {"version":3,"file":"config-loader.d.ts","sourceRoot":"","sources":["../../src/utils/config-loader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,EAAuD,KAAK,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACxH,OAAO,EAAY,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAY/D;;;;;;;;GAQG;AACH,qBAAa,eAAgB,SAAQ,QAAQ;IAC3C,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;gBACjB,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO;CAKhD;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,UAAU,CAAC,WAAW,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAgDzE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAEvD;AAqBD;;;;;GAKG;AACH,wBAAgB,sBAAsB,IAAI,IAAI,CAM7C;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAgB/E"}
@@ -7,7 +7,7 @@
7
7
  import { readFileSync, existsSync } from 'node:fs';
8
8
  import { dirname } from 'node:path';
9
9
  import { parseConfigAllowingUnknownKeys, ProjectConfigSchema } from '@vibe-agent-toolkit/resources';
10
- import { safePath } from '@vibe-agent-toolkit/utils';
10
+ import { safePath, VatError } from '@vibe-agent-toolkit/utils';
11
11
  import * as yaml from 'yaml';
12
12
  const CONFIG_FILENAME = 'vibe-agent-toolkit.config.yaml';
13
13
  /**
@@ -25,11 +25,10 @@ const warnedConfigPaths = new Set();
25
25
  * `vat skill test`) should surface this; a bulk linter (`vat audit`) may catch
26
26
  * it and fall back to config-free validation.
27
27
  */
28
- export class ConfigLoadError extends Error {
28
+ export class ConfigLoadError extends VatError {
29
29
  projectRoot;
30
30
  constructor(projectRoot, cause) {
31
- super(cause instanceof Error ? cause.message : String(cause));
32
- this.name = 'ConfigLoadError';
31
+ super('CONFIG_LOAD', cause instanceof Error ? cause.message : String(cause));
33
32
  this.projectRoot = projectRoot;
34
33
  if (cause instanceof Error)
35
34
  this.cause = cause;
@@ -59,12 +58,10 @@ export class ConfigLoadError extends Error {
59
58
  export function loadConfig(projectRoot) {
60
59
  // Override for testing: VAT_TEST_CONFIG provides explicit config path
61
60
  const configPath = process.env['VAT_TEST_CONFIG'] ?? safePath.join(projectRoot, CONFIG_FILENAME);
62
- // eslint-disable-next-line security/detect-non-literal-fs-filename -- configPath is derived from projectRoot parameter or env override
63
61
  if (!existsSync(configPath)) {
64
62
  return undefined;
65
63
  }
66
64
  try {
67
- // eslint-disable-next-line security/detect-non-literal-fs-filename -- configPath is derived from projectRoot parameter
68
65
  const content = readFileSync(configPath, 'utf-8');
69
66
  const parsed = yaml.parse(content);
70
67
  // Validate with canonical schema from resources package.
@@ -1 +1 @@
1
- {"version":3,"file":"config-loader.js","sourceRoot":"","sources":["../../src/utils/config-loader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,8BAA8B,EAAE,mBAAmB,EAAsB,MAAM,+BAA+B,CAAC;AACxH,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,MAAM,eAAe,GAAG,gCAAgC,CAAC;AAEzD;;;;GAIG;AACH,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAAU,CAAC;AAE5C;;;;;;;;GAQG;AACH,MAAM,OAAO,eAAgB,SAAQ,KAAK;IAC/B,WAAW,CAAS;IAC7B,YAAY,WAAmB,EAAE,KAAc;QAC7C,KAAK,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC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F,cAAc,CAAC,GAAG,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;QAC3C,MAAM,SAAS,CAAC;IAClB,CAAC;AACH,CAAC"}
@@ -11,7 +11,7 @@
11
11
  *
12
12
  * A sweep reports every working location, and locations sharing an instruction
13
13
  * chain share one budget — that is the whole point of the collapse. Re-measured
14
- * on VAT's own tree 2026-08-23, after the context population began declining the
14
+ * on VAT's own tree, after the context population began declining the
15
15
  * gitignored half: **366 of 589 directories** pay the single chain
16
16
  * `['CLAUDE.md']`, so emitting per location would print 366 byte-identical
17
17
  * findings, all blaming one file, the moment the root `CLAUDE.md` crossed the
@@ -11,7 +11,7 @@
11
11
  *
12
12
  * A sweep reports every working location, and locations sharing an instruction
13
13
  * chain share one budget — that is the whole point of the collapse. Re-measured
14
- * on VAT's own tree 2026-08-23, after the context population began declining the
14
+ * on VAT's own tree, after the context population began declining the
15
15
  * gitignored half: **366 of 589 directories** pay the single chain
16
16
  * `['CLAUDE.md']`, so emitting per location would print 366 byte-identical
17
17
  * findings, all blaming one file, the moment the root `CLAUDE.md` crossed the
@@ -5,34 +5,12 @@
5
5
  * about positions in it — `vat claude context` and `vat claude budget` today.
6
6
  * They ask different questions and default differently when no path is named,
7
7
  * but "is this argument inside the tree I enumerated, and what is it called
8
- * there" is one rule, and a second copy of it would be free to drift on the one
9
- * clause that only fails where nobody looks (see {@link escapesCorpusRoot}).
8
+ * there" is one rule. The predicate itself is `relativeEscapesRoot` from
9
+ * `@vibe-agent-toolkit/utils` — the one lexical classifier every lane shares,
10
+ * so the clause that only fails on Windows (a cross-drive `relative()` comes
11
+ * back ABSOLUTE, not `..`-prefixed) is tested once, there, with the string
12
+ * Windows really produces.
10
13
  */
11
- /**
12
- * Does a path already stated against the corpus root fall OUTSIDE it?
13
- *
14
- * Three spellings of "outside", not two, and the third is the one that could
15
- * only fail where nobody would see it. `safePath.relative` says "not under this
16
- * root" with a `..`-prefixed path in the ordinary case, but returns an ABSOLUTE
17
- * path when no relative route exists at all — which on Windows is exactly what a
18
- * different drive letter produces. Without the third test, `vat claude context
19
- * D:\elsewhere\doc.md` run from a `C:` repo passes the guard and answers `kind:
20
- * unknown`, indistinguishable from a typo inside the tree, which is the one
21
- * outcome {@link targetPathWithin}'s `@throws` claims to prevent. Its sibling
22
- * `escapesRoot` (`closure-extent.ts`) applies the same triple for the same
23
- * reason.
24
- *
25
- * ⛔ Exported so it can be TESTED. On POSIX `safePath.relative` between two
26
- * absolute paths never returns an absolute string, so the third clause is
27
- * unreachable through {@link targetPathWithin} on every machine a developer
28
- * runs — the branch has to be exercised directly or not at all, and "not at
29
- * all" is how it went missing in the first place.
30
- *
31
- * @param normalizedRelative - A forward-slashed path already stated against the
32
- * corpus root
33
- * @returns True when the corpus root does not contain it
34
- */
35
- export declare function escapesCorpusRoot(normalizedRelative: string): boolean;
36
14
  /**
37
15
  * The root-relative path to query, refusing anything outside the corpus.
38
16
  *
@@ -1 +1 @@
1
- {"version":3,"file":"corpus-target.d.ts","sourceRoot":"","sources":["../../src/utils/corpus-target.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,iBAAiB,CAAC,kBAAkB,EAAE,MAAM,GAAG,OAAO,CAIrE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,WAAW,EAAE,MAAM,GAClB,MAAM,CAUR"}
1
+ {"version":3,"file":"corpus-target.d.ts","sourceRoot":"","sources":["../../src/utils/corpus-target.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,WAAW,EAAE,MAAM,GAClB,MAAM,CAUR"}
@@ -5,39 +5,13 @@
5
5
  * about positions in it — `vat claude context` and `vat claude budget` today.
6
6
  * They ask different questions and default differently when no path is named,
7
7
  * but "is this argument inside the tree I enumerated, and what is it called
8
- * there" is one rule, and a second copy of it would be free to drift on the one
9
- * clause that only fails where nobody looks (see {@link escapesCorpusRoot}).
8
+ * there" is one rule. The predicate itself is `relativeEscapesRoot` from
9
+ * `@vibe-agent-toolkit/utils` — the one lexical classifier every lane shares,
10
+ * so the clause that only fails on Windows (a cross-drive `relative()` comes
11
+ * back ABSOLUTE, not `..`-prefixed) is tested once, there, with the string
12
+ * Windows really produces.
10
13
  */
11
- import { isAbsoluteAnyPlatform, safePath } from '@vibe-agent-toolkit/utils';
12
- /**
13
- * Does a path already stated against the corpus root fall OUTSIDE it?
14
- *
15
- * Three spellings of "outside", not two, and the third is the one that could
16
- * only fail where nobody would see it. `safePath.relative` says "not under this
17
- * root" with a `..`-prefixed path in the ordinary case, but returns an ABSOLUTE
18
- * path when no relative route exists at all — which on Windows is exactly what a
19
- * different drive letter produces. Without the third test, `vat claude context
20
- * D:\elsewhere\doc.md` run from a `C:` repo passes the guard and answers `kind:
21
- * unknown`, indistinguishable from a typo inside the tree, which is the one
22
- * outcome {@link targetPathWithin}'s `@throws` claims to prevent. Its sibling
23
- * `escapesRoot` (`closure-extent.ts`) applies the same triple for the same
24
- * reason.
25
- *
26
- * ⛔ Exported so it can be TESTED. On POSIX `safePath.relative` between two
27
- * absolute paths never returns an absolute string, so the third clause is
28
- * unreachable through {@link targetPathWithin} on every machine a developer
29
- * runs — the branch has to be exercised directly or not at all, and "not at
30
- * all" is how it went missing in the first place.
31
- *
32
- * @param normalizedRelative - A forward-slashed path already stated against the
33
- * corpus root
34
- * @returns True when the corpus root does not contain it
35
- */
36
- export function escapesCorpusRoot(normalizedRelative) {
37
- return normalizedRelative === '..'
38
- || normalizedRelative.startsWith('../')
39
- || isAbsoluteAnyPlatform(normalizedRelative);
40
- }
14
+ import { relativeEscapesRoot, safePath } from '@vibe-agent-toolkit/utils';
41
15
  /**
42
16
  * The root-relative path to query, refusing anything outside the corpus.
43
17
  *
@@ -51,7 +25,7 @@ export function escapesCorpusRoot(normalizedRelative) {
51
25
  */
52
26
  export function targetPathWithin(root, pathArg, commandName) {
53
27
  const relative = safePath.relative(root, safePath.resolve(process.cwd(), pathArg ?? '.'));
54
- if (escapesCorpusRoot(relative)) {
28
+ if (relativeEscapesRoot(relative)) {
55
29
  throw new Error(`${pathArg ?? process.cwd()} resolves outside the corpus root ${root}.`
56
30
  + ` ${commandName} answers only for paths inside the root it discovered —`
57
31
  + ' run it from within the project you mean to ask about.');
@@ -1 +1 @@
1
- {"version":3,"file":"corpus-target.js","sourceRoot":"","sources":["../../src/utils/corpus-target.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,qBAAqB,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAE5E;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,iBAAiB,CAAC,kBAA0B;IAC1D,OAAO,kBAAkB,KAAK,IAAI;WAC7B,kBAAkB,CAAC,UAAU,CAAC,KAAK,CAAC;WACpC,qBAAqB,CAAC,kBAAkB,CAAC,CAAC;AACjD,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,gBAAgB,CAC9B,IAAY,EACZ,OAA2B,EAC3B,WAAmB;IAEnB,MAAM,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,IAAI,GAAG,CAAC,CAAC,CAAC;IAC1F,IAAI,iBAAiB,CAAC,QAAQ,CAAC,EAAE,CAAC;QAChC,MAAM,IAAI,KAAK,CACb,GAAG,OAAO,IAAI,OAAO,CAAC,GAAG,EAAE,qCAAqC,IAAI,GAAG;cACrE,IAAI,WAAW,yDAAyD;cACxE,wDAAwD,CAC3D,CAAC;IACJ,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
1
+ {"version":3,"file":"corpus-target.js","sourceRoot":"","sources":["../../src/utils/corpus-target.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAE1E;;;;;;;;;;GAUG;AACH,MAAM,UAAU,gBAAgB,CAC9B,IAAY,EACZ,OAA2B,EAC3B,WAAmB;IAEnB,MAAM,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,IAAI,GAAG,CAAC,CAAC,CAAC;IAC1F,IAAI,mBAAmB,CAAC,QAAQ,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CACb,GAAG,OAAO,IAAI,OAAO,CAAC,GAAG,EAAE,qCAAqC,IAAI,GAAG;cACrE,IAAI,WAAW,yDAAyD;cACxE,wDAAwD,CAC3D,CAAC;IACJ,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"help-loader.d.ts","sourceRoot":"","sources":["../../src/utils/help-loader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAyBxD;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAEnD"}
1
+ {"version":3,"file":"help-loader.d.ts","sourceRoot":"","sources":["../../src/utils/help-loader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAwBxD;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAEnD"}
@@ -21,7 +21,6 @@ export function loadVerboseHelp(section) {
21
21
  const filename = section ? `${section}.md` : 'index.md';
22
22
  const helpPath = safePath.join(packageRoot, 'docs', filename);
23
23
  try {
24
- // eslint-disable-next-line security/detect-non-literal-fs-filename -- path is constructed from known safe components
25
24
  const content = readFileSync(helpPath, 'utf-8');
26
25
  return content;
27
26
  }
@@ -1 +1 @@
1
- {"version":3,"file":"help-loader.js","sourceRoot":"","sources":["../../src/utils/help-loader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAErD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,OAAgB;IAC9C,mCAAmC;IACnC,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1D,MAAM,WAAW,GAAG,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAEtD,wCAAwC;IACxC,MAAM,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC;IACxD,MAAM,QAAQ,GAAG,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;IAE9D,IAAI,CAAC;QACH,qHAAqH;QACrH,MAAM,OAAO,GAAG,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAChD,OAAO,OAAO,CAAC;IACjB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,sCAAsC;QACtC,MAAM,YAAY,GAAG,KAAK,YAAY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AE,OAAO,CAAC,CAAC;QAChD,OAAO,OAAO,CAAC;IACjB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,sCAAsC;QACtC,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC5E,OAAO;;0BAEe,QAAQ;;EAEhC,YAAY;;;CAGb,CAAC;IACA,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,aAAa,CAAC,OAAe;IAC3C,eAAe,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,IAAI,CAAC,CAAC;AACrE,CAAC"}
@@ -177,8 +177,8 @@ export declare function formatCollapsedFindingsHint(collapsed: number, report: s
177
177
  * is not: `files.dependencies` carries only what the link-graph walk discovered, so
178
178
  * every file `files:` copied in — each glob match, plus any explicit entry the walk
179
179
  * had not already bundled — is absent from the total. A bundle holding SKILL.md, one
180
- * linked doc and one declared artifact prints `2 files`. That undercount is issue
181
- * #177 and is deliberately NOT patched here; this wording is only the part that can
180
+ * linked doc and one declared artifact prints `2 files`. That undercount is a
181
+ * report-shape defect and is deliberately NOT patched here; this wording is only the part that can
182
182
  * be made true today, so nobody reads the number as an inventory of the output.
183
183
  *
184
184
  * The `+ 1` is the bundle's root `SKILL.md`, which `files.dependencies` does not
@@ -259,8 +259,8 @@ export function formatCollapsedFindingsHint(collapsed, report) {
259
259
  * is not: `files.dependencies` carries only what the link-graph walk discovered, so
260
260
  * every file `files:` copied in — each glob match, plus any explicit entry the walk
261
261
  * had not already bundled — is absent from the total. A bundle holding SKILL.md, one
262
- * linked doc and one declared artifact prints `2 files`. That undercount is issue
263
- * #177 and is deliberately NOT patched here; this wording is only the part that can
262
+ * linked doc and one declared artifact prints `2 files`. That undercount is a
263
+ * report-shape defect and is deliberately NOT patched here; this wording is only the part that can
264
264
  * be made true today, so nobody reads the number as an inventory of the output.
265
265
  *
266
266
  * The `+ 1` is the bundle's root `SKILL.md`, which `files.dependencies` does not
@@ -1 +1 @@
1
- {"version":3,"file":"optional-backend.d.ts","sourceRoot":"","sources":["../../src/utils/optional-backend.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAkBH;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAOvD;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,eAAe,GAAG,KAAK,CAcpE;AAED,6DAA6D;AAC7D,MAAM,WAAW,eAAe;IAC9B,wDAAwD;IACxD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,0EAA0E;IAC1E,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,UAAU,CAAC,IAAI,SAAS,SAAS,OAAO,EAAE,EACxD,OAAO,EAAE,eAAe,EACxB,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,GAC9C,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,CAalC"}
1
+ {"version":3,"file":"optional-backend.d.ts","sourceRoot":"","sources":["../../src/utils/optional-backend.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAoBH;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAOvD;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,eAAe,GAAG,KAAK,CAcpE;AAED,6DAA6D;AAC7D,MAAM,WAAW,eAAe;IAC9B,wDAAwD;IACxD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,0EAA0E;IAC1E,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,UAAU,CAAC,IAAI,SAAS,SAAS,OAAO,EAAE,EACxD,OAAO,EAAE,eAAe,EACxB,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,GAC9C,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,CAalC"}
@@ -25,6 +25,7 @@
25
25
  // of the rag lane's shared helpers live: that module statically imports
26
26
  // `@vibe-agent-toolkit/rag-lancedb`, so reaching for its `handleCommandError`
27
27
  // here would load the very backend this file exists to defer.
28
+ import { ExitCode } from '@vibe-agent-toolkit/schema';
28
29
  import { writeYamlOutput } from './output.js';
29
30
  /**
30
31
  * Node's code for "the module is genuinely not installed".
@@ -78,7 +79,7 @@ export function reportMissingBackend(backend) {
78
79
  error: `${backend.feature} backend not installed: ${backend.packageName}`,
79
80
  fix: install,
80
81
  });
81
- process.exit(2);
82
+ process.exit(ExitCode.ERROR);
82
83
  }
83
84
  /**
84
85
  * Bind a Commander action that loads its implementation on first invocation.
@@ -1 +1 @@
1
- {"version":3,"file":"optional-backend.js","sourceRoot":"","sources":["../../src/utils/optional-backend.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,8EAA8E;AAC9E,wEAAwE;AACxE,8EAA8E;AAC9E,8DAA8D;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C;;;;;;;GAOG;AACH,MAAM,gBAAgB,GAAG,sBAAsB,CAAC;AAEhD;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;WACtB,KAAK,KAAK,IAAI;WACd,MAAM,IAAI,KA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C,CAAC;QAChC,CAAC;QACD,MAAM,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;IACzB,CAAC,CAAC;AACJ,CAAC"}
@@ -93,6 +93,15 @@ export declare function writeYamlOutput(data: unknown): void;
93
93
  * @param data - Data to serialize as JSON
94
94
  */
95
95
  export declare function writeJsonOutput(data: unknown): void;
96
+ /**
97
+ * Write one structured document in the format a `--format` option selected:
98
+ * `json` → {@link writeJsonOutput}; anything else (including an absent option)
99
+ * → {@link writeYamlOutput}, the CLI's default document format.
100
+ *
101
+ * @param data - The document
102
+ * @param format - The selected format (`json`, or anything else for YAML)
103
+ */
104
+ export declare function writeStructuredOutput(data: unknown, format: string | undefined): void;
96
105
  /**
97
106
  * Write a test-format finding to stderr.
98
107
  *
@@ -1 +1 @@
1
- {"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/utils/output.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAKrD;AAED;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;AAoCpF,MAAM,WAAW,mBAAmB;IAClC,gFAAgF;IAChF,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,6EAA6E;IAC7E,kBAAkB,CAAC,EAAE,CAAC,kBAAkB,EAAE,MAAM,KAAK,IAAI,CAAC;CAC3D;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,UAAU,EACjB,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,mBAAwB,GAChC,IAAI,CA+BN;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAWnD;AAED;;;;;;;;;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AgB,oBAAoB,CAClC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GACd,IAAI,CAEN"}
@@ -157,6 +157,22 @@ export function writeYamlOutput(data) {
157
157
  export function writeJsonOutput(data) {
158
158
  process.stdout.write(`${JSON.stringify(data, null, 2)}\n`);
159
159
  }
160
+ /**
161
+ * Write one structured document in the format a `--format` option selected:
162
+ * `json` → {@link writeJsonOutput}; anything else (including an absent option)
163
+ * → {@link writeYamlOutput}, the CLI's default document format.
164
+ *
165
+ * @param data - The document
166
+ * @param format - The selected format (`json`, or anything else for YAML)
167
+ */
168
+ export function writeStructuredOutput(data, format) {
169
+ if (format === 'json') {
170
+ writeJsonOutput(data);
171
+ }
172
+ else {
173
+ writeYamlOutput(data);
174
+ }
175
+ }
160
176
  /**
161
177
  * Write a test-format finding to stderr.
162
178
  *
@@ -1 +1 @@
1
- {"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/utils/output.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,eAAe,CAAC,OAAe;IAC7C,YAAY,CACV,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAChE,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAC7B,CAAC;AACJ,CAAC;AAUD;;;;;;;;;GASG;AACH,MAAM,8BAA8B,GAAG,MAAM,CAAC;AAE9C,uEAAuE;AACvE,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAE/B;;;;;GAKG;AACH,SAAS,SAAS,CAAC,EAAU;IAC3B,OAA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