@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
@@ -1,12 +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 { type SeverityCounts, type ValidationIssue } from '@vibe-agent-toolkit/agent-schema';
12
+ import { type ExitCodeValue, type SeverityCounts, type ValidationIssue } from '@vibe-agent-toolkit/schema';
10
13
  import type { Logger } from './logger.js';
11
14
  /**
12
15
  * Format duration for human readability
@@ -14,33 +17,119 @@ import type { Logger } from './logger.js';
14
17
  * @returns Formatted duration string (e.g., "500ms", "1.5s", "1.5m")
15
18
  */
16
19
  export declare function formatDuration(ms: number): string;
20
+ /** The document a command publishes when an unexpected failure stops it. */
21
+ export interface CommandErrorDocument {
22
+ status: 'error';
23
+ error: string;
24
+ duration: string;
25
+ }
17
26
  /**
18
- * Everything about a thrown value that `error.message` alone discards.
27
+ * Report an unexpected failure on stderr and return the document that describes
28
+ * it, WITHOUT deciding how the caller ends.
19
29
  *
20
- * Exit 2 is the UNEXPECTED failure — an internal bug, not a usage mistake — and
21
- * the one thing a reader needs there is the frame that threw. A real `TypeError`
22
- * arrived here as a single line (`Cannot read properties of undefined (reading
23
- * 'readdir')`) with no file, no frames, and no flag that would produce them; the
24
- * only way to find the throw site was to hand-patch the built `dist`. A value
25
- * thrown that is not an `Error` fared worse still — the envelope flattens it to
26
- * the literal string `Unknown error`, which names neither its type nor its
27
- * contents.
30
+ * Split out of {@link handleCommandError} because the same failure now has two
31
+ * endings and must not grow two policies. A command run from the command line
32
+ * writes this document to stdout and exits 2; the same command run as a phase of
33
+ * `vat validate` / `vat verify` / `vat build` runs in the orchestrator's own
34
+ * process, where exiting would kill the whole run and skip every later phase —
35
+ * so it hands the document back and the orchestrator nests it under that phase's
36
+ * `report`, exactly as it used to nest the child's captured stdout.
28
37
  *
29
- * The result rides the logger's **debug** channel (`--debug`), so default output
30
- * is unchanged and no golden moves.
38
+ * The stderr half is identical in both lanes: progress and diagnostics have
39
+ * always streamed live, and that is unchanged by there no longer being a child.
31
40
  *
32
41
  * @param error - The value that was thrown
33
- * @returns Stack trace for an `Error`, or an inspected rendering of a non-`Error`
42
+ * @param logger - Logger instance for error output
43
+ * @param startTime - Command start time (from Date.now())
44
+ * @param commandName - Name of the command (for the error message)
34
45
  */
35
- export declare function errorDiagnostics(error: unknown): string;
46
+ export declare function reportCommandError(error: unknown, logger: Logger, startTime: number, commandName: string): CommandErrorDocument;
36
47
  /**
37
- * Handle command error with standard formatting and exit
48
+ * Handle command error with standard formatting and exit.
49
+ *
50
+ * The command-line ending for {@link reportCommandError}. `ExitCode.ERROR` is
51
+ * the UNEXPECTED failure, per the exit-code contract every command's help documents.
52
+ *
53
+ * 🔑 **`format` is not decoration.** Every command offering `--format json`
54
+ * honoured it on the success path and emitted YAML here, so the one document a
55
+ * CI wrapper most needs to read — the one explaining why the command failed —
56
+ * arrived in a format its parser rejects. A consumer running
57
+ * `vat resources check --format json | jq .error` got a parse error on top of
58
+ * whatever went wrong, and had to guess at the second failure to find the first.
59
+ * A caller that has a `--format` option MUST pass it.
60
+ *
38
61
  * @param error - The error that occurred
39
62
  * @param logger - Logger instance for error output
40
63
  * @param startTime - Command start time (from Date.now())
41
64
  * @param commandName - Name of the command (for error message)
65
+ * @param format - What the operator asked for: `json`, or anything else (and
66
+ * omitted) for YAML — matching the success path's own two-branch switch
67
+ */
68
+ export declare function handleCommandError(error: unknown, logger: Logger, startTime: number, commandName: string, format?: string | undefined): never;
69
+ /**
70
+ * Publish an EXPECTED failure in the format the operator asked for, then exit
71
+ * with the code the command's own contract assigns it.
72
+ *
73
+ * The third ending of one failure, beside {@link handleCommandError} (the
74
+ * UNEXPECTED failure, always `ERROR`) and {@link handleValidationGateFailure}
75
+ * (a validation gate, always `FINDINGS`, always YAML). This one covers the
76
+ * failure that is neither: the command ran, understood the project, and has a
77
+ * documented non-zero code for what it found — `vat ard emit` ending on
78
+ * `FINDINGS` for "this project declares no `ard:` block" or `ERROR` for "there
79
+ * is no config file here".
80
+ *
81
+ * 🔑 It exists because those endings were written inline, and an inline ending
82
+ * publishes nothing: `ard emit` honoured `--format json` on its success path
83
+ * and through `handleCommandError`, then wrote **zero bytes to stdout** on the
84
+ * two exits a repository actually reaches — the commonest being the first run
85
+ * of any repository that never opted into ARD. A CI wrapper reading stdout got
86
+ * an empty document and a bare non-zero code, which is the exact failure the
87
+ * `format` note on {@link handleCommandError} exists to forbid.
88
+ *
89
+ * The message goes to stderr as it always did — humans read it there — and the
90
+ * document goes to stdout, matching what both neighbours already do.
91
+ *
92
+ * @param message - What went wrong, in the command's own words
93
+ * @param exitCode - The code this command's `--help` assigns to this outcome
94
+ * @param startTime - Command start time (from Date.now()), so the document
95
+ * reports the run's real duration rather than a fabricated zero
96
+ * @param format - What the operator asked for: `json`, or anything else (and
97
+ * omitted) for YAML — the same two-branch switch the success path uses
42
98
  */
43
- export declare function handleCommandError(error: unknown, logger: Logger, startTime: number, commandName: string): never;
99
+ export declare function handleExpectedFailure(message: string, exitCode: ExitCodeValue, startTime: number, format?: string | undefined): never;
100
+ /**
101
+ * {@link handleCommandError} for a command whose document is the shared
102
+ * `Report<T>` envelope: the failure document IS the envelope
103
+ * (`buildErrorReport`), so the emitted `schemas/<command>.json` describes the
104
+ * failed run too. Every command registered as `report` in `report-schemas.ts`
105
+ * ends its unexpected failures here; `handleCommandError`'s
106
+ * `CommandErrorDocument` is the shape the legacy documents keep.
107
+ *
108
+ * @param error - The value that was thrown
109
+ * @param logger - Logger instance for error output
110
+ * @param startTime - Command start time (from Date.now())
111
+ * @param commandName - Name of the command (for the stderr line)
112
+ * @param format - What the operator asked for: `json`, or anything else (and
113
+ * omitted) for YAML
114
+ */
115
+ export declare function handleReportCommandError(error: unknown, logger: Logger, startTime: number, commandName: string, format?: string | undefined): never;
116
+ /**
117
+ * {@link handleExpectedFailure} for a command whose document is the shared
118
+ * `Report<T>` envelope — same document as {@link handleReportCommandError}.
119
+ *
120
+ * 🔑 No exit-code parameter, deliberately. The document is the envelope's
121
+ * ERROR branch, so its code is {@link exitCodeForReport}'s answer for it: 2.
122
+ * It used to take the code from the caller, and `vat ard emit` passed 1 — a
123
+ * document saying "could not do its job" beside a code saying "the project
124
+ * failed its gate". An outcome that is a finding about the project is
125
+ * published as a finding, not through here.
126
+ *
127
+ * @param message - What went wrong, in the command's own words
128
+ * @param startTime - Command start time (from Date.now())
129
+ * @param format - What the operator asked for: `json`, or anything else (and
130
+ * omitted) for YAML
131
+ */
132
+ export declare function handleReportExpectedFailure(message: string, startTime: number, format?: string | undefined): never;
44
133
  /** The payload a command publishes when its own validation gate stops it. */
45
134
  export interface ValidationGateFailure {
46
135
  status: 'error';
@@ -58,9 +147,9 @@ export interface ValidationGateFailure {
58
147
  export declare function buildValidationGateFailure(subject: string, issues: readonly ValidationIssue[]): ValidationGateFailure;
59
148
  /**
60
149
  * Publish the documented failure payload for a command stopped by its OWN
61
- * validation gate, then exit 1.
150
+ * validation gate, then end on `FINDINGS`.
62
151
  *
63
- * {@link handleCommandError} above covers the UNEXPECTED failure (exit 2). This
152
+ * {@link handleCommandError} above covers the UNEXPECTED failure (`ERROR`). This
64
153
  * covers the expected one, and `vat skills build` / `vat skills package` both
65
154
  * exited it after writing zero bytes to stdout — while their `--help` texts
66
155
  * document a YAML summary on stdout and reserve exit 1 for exactly this case.
@@ -68,4 +157,38 @@ export declare function buildValidationGateFailure(subject: string, issues: read
68
157
  * a bare non-zero code.
69
158
  */
70
159
  export declare function handleValidationGateFailure(subject: string, issues: readonly ValidationIssue[]): never;
160
+ /**
161
+ * Map a commander termination to the exit code VAT's contract promises.
162
+ *
163
+ * A USAGE mistake — a flag this program does not declare, a verb it does not
164
+ * know, a missing or invalid argument — ends on `ExitCode.ERROR`, and the
165
+ * reason is not style. Commander's default for a usage mistake is
166
+ * `process.exit(1)`, so `vat resources check --json` (the option is
167
+ * `--format json`) exited **1** — which, read against the contract the command
168
+ * itself prints, asserts that at least one check was violated. Nothing had
169
+ * run. A CI wrapper spelled `if [ $? -ne 0 ]; then report_findings` therefore
170
+ * reported findings that were never computed. The same hole swallowed a
171
+ * mistyped verb (`vat resources chekc`) and every unknown option on every
172
+ * command.
173
+ *
174
+ * Commander reports BOTH successful and failing terminations through the same
175
+ * `CommanderError`: `--help` and `--version` carry `exitCode` 0, while an
176
+ * unknown option, an unknown command and `help({ error: true })` carry non-zero.
177
+ * Anything non-zero is a usage mistake by construction — commander raises these
178
+ * only while parsing, before any action runs — so it maps to `ERROR`.
179
+ *
180
+ * ⚠️ **Help and `--version` are NOT usage mistakes.** They terminate through
181
+ * the same `_exit` path with code 0 and must stay `OK`; only a non-zero
182
+ * commander ending is remapped.
183
+ *
184
+ * 🪤 Do NOT switch on `error.code` (`commander.unknownOption`, `commander.help`,
185
+ * …). The unknown-COMMAND path arrives as `commander.help` with exitCode 1,
186
+ * because the `command:*` handler renders help with `{ error: true }` — so the
187
+ * code string says "help" for a case that is emphatically not one. The exit
188
+ * code commander already computed is the honest discriminator; the string is not.
189
+ *
190
+ * @param commanderExitCode - The `exitCode` commander put on its CommanderError
191
+ * @returns `OK` for a successful ending, `ERROR` otherwise
192
+ */
193
+ export declare function exitCodeForCommanderEnding(commanderExitCode: number): ExitCodeValue;
71
194
  //# sourceMappingURL=command-error.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"command-error.d.ts","sourceRoot":"","sources":["../../src/utils/command-error.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,EAAmB,KAAK,cAAc,EAAE,KAAK,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAE9G,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAG1C;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAQjD;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAMvD;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,GAClB,KAAK,CAYP;AAED,6EAA6E;AAC7E,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW,EAAE,cAAc,CAAC;IAC5B,iFAAiF;IACjF,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,MAAM,EACf,MAAM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;;;;;;GAcG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,GAC1B,KAAK,CAIP;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,GAC1B,KAAK,CAIP;AAED,6EAA6E;AAC7E,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW,EAAE,cAAc,CAAC;IAC5B,iFAAiF;IACjF,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,SAAS,eAAe,EAAE,GACjC,qBAAqB,CAEvB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,SAAS,eAAe,EAAE,GACjC,KAAK,CAGP;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,0BAA0B,CAAC,iBAAiB,EAAE,MAAM,GAAG,aAAa,CAEnF"}
@@ -1,14 +1,16 @@
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/agent-schema';
11
- import { writeYamlOutput } from './output.js';
12
+ import { ExitCode, buildErrorReport, countBySeverity, errorDiagnostics, exitCodeForReport } from '@vibe-agent-toolkit/schema';
13
+ import { writeJsonOutput, writeYamlOutput } from './output.js';
12
14
  /**
13
15
  * Format duration for human readability
14
16
  * @param ms - Duration in milliseconds
@@ -24,47 +26,152 @@ export function formatDuration(ms) {
24
26
  return `${(ms / 60000).toFixed(1)}m`;
25
27
  }
26
28
  /**
27
- * Everything about a thrown value that `error.message` alone discards.
29
+ * Report an unexpected failure on stderr and return the document that describes
30
+ * it, WITHOUT deciding how the caller ends.
28
31
  *
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.
32
+ * Split out of {@link handleCommandError} because the same failure now has two
33
+ * endings and must not grow two policies. A command run from the command line
34
+ * writes this document to stdout and exits 2; the same command run as a phase of
35
+ * `vat validate` / `vat verify` / `vat build` runs in the orchestrator's own
36
+ * process, where exiting would kill the whole run and skip every later phase —
37
+ * so it hands the document back and the orchestrator nests it under that phase's
38
+ * `report`, exactly as it used to nest the child's captured stdout.
37
39
  *
38
- * The result rides the logger's **debug** channel (`--debug`), so default output
39
- * is unchanged and no golden moves.
40
+ * The stderr half is identical in both lanes: progress and diagnostics have
41
+ * always streamed live, and that is unchanged by there no longer being a child.
40
42
  *
41
43
  * @param error - The value that was thrown
42
- * @returns Stack trace for an `Error`, or an inspected rendering of a non-`Error`
44
+ * @param logger - Logger instance for error output
45
+ * @param startTime - Command start time (from Date.now())
46
+ * @param commandName - Name of the command (for the error message)
43
47
  */
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 })}`;
48
+ export function reportCommandError(error, logger, startTime, commandName) {
49
+ const duration = Date.now() - startTime;
50
+ const message = error instanceof Error ? error.message : 'Unknown error';
51
+ logger.error(`${commandName} failed: ${message}`);
52
+ logger.debug(errorDiagnostics(error));
53
+ return { status: 'error', error: message, duration: formatDuration(duration) };
50
54
  }
51
55
  /**
52
- * Handle command error with standard formatting and exit
56
+ * Handle command error with standard formatting and exit.
57
+ *
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.
60
+ *
61
+ * 🔑 **`format` is not decoration.** Every command offering `--format json`
62
+ * honoured it on the success path and emitted YAML here, so the one document a
63
+ * CI wrapper most needs to read — the one explaining why the command failed —
64
+ * arrived in a format its parser rejects. A consumer running
65
+ * `vat resources check --format json | jq .error` got a parse error on top of
66
+ * whatever went wrong, and had to guess at the second failure to find the first.
67
+ * A caller that has a `--format` option MUST pass it.
68
+ *
53
69
  * @param error - The error that occurred
54
70
  * @param logger - Logger instance for error output
55
71
  * @param startTime - Command start time (from Date.now())
56
72
  * @param commandName - Name of the command (for error message)
73
+ * @param format - What the operator asked for: `json`, or anything else (and
74
+ * omitted) for YAML — matching the success path's own two-branch switch
57
75
  */
58
- export function handleCommandError(error, logger, startTime, commandName) {
59
- const duration = Date.now() - startTime;
60
- logger.error(`${commandName} failed: ${error instanceof Error ? error.message : 'Unknown error'}`);
61
- logger.debug(errorDiagnostics(error));
62
- writeYamlOutput({
76
+ export function handleCommandError(error, logger, startTime, commandName, format) {
77
+ const document = reportCommandError(error, logger, startTime, commandName);
78
+ return publishFailure(document, format, ExitCode.ERROR);
79
+ }
80
+ /**
81
+ * Publish an EXPECTED failure in the format the operator asked for, then exit
82
+ * with the code the command's own contract assigns it.
83
+ *
84
+ * The third ending of one failure, beside {@link handleCommandError} (the
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".
91
+ *
92
+ * 🔑 It exists because those endings were written inline, and an inline ending
93
+ * publishes nothing: `ard emit` honoured `--format json` on its success path
94
+ * and through `handleCommandError`, then wrote **zero bytes to stdout** on the
95
+ * two exits a repository actually reaches — the commonest being the first run
96
+ * of any repository that never opted into ARD. A CI wrapper reading stdout got
97
+ * an empty document and a bare non-zero code, which is the exact failure the
98
+ * `format` note on {@link handleCommandError} exists to forbid.
99
+ *
100
+ * The message goes to stderr as it always did — humans read it there — and the
101
+ * document goes to stdout, matching what both neighbours already do.
102
+ *
103
+ * @param message - What went wrong, in the command's own words
104
+ * @param exitCode - The code this command's `--help` assigns to this outcome
105
+ * @param startTime - Command start time (from Date.now()), so the document
106
+ * reports the run's real duration rather than a fabricated zero
107
+ * @param format - What the operator asked for: `json`, or anything else (and
108
+ * omitted) for YAML — the same two-branch switch the success path uses
109
+ */
110
+ export function handleExpectedFailure(message, exitCode, startTime, format) {
111
+ process.stderr.write(`${message}\n`);
112
+ const document = {
63
113
  status: 'error',
64
- error: error instanceof Error ? error.message : 'Unknown error',
65
- duration: formatDuration(duration),
66
- });
67
- process.exit(2);
114
+ error: message,
115
+ duration: formatDuration(Date.now() - startTime),
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) {
127
+ if (format === 'json') {
128
+ writeJsonOutput(document);
129
+ }
130
+ else {
131
+ writeYamlOutput(document);
132
+ }
133
+ process.exit(exitCode);
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
+ const report = buildErrorReport(message, Date.now() - startTime);
153
+ return publishFailure(report, format, exitCodeForReport(report));
154
+ }
155
+ /**
156
+ * {@link handleExpectedFailure} for a command whose document is the shared
157
+ * `Report<T>` envelope — same document as {@link handleReportCommandError}.
158
+ *
159
+ * 🔑 No exit-code parameter, deliberately. The document is the envelope's
160
+ * ERROR branch, so its code is {@link exitCodeForReport}'s answer for it: 2.
161
+ * It used to take the code from the caller, and `vat ard emit` passed 1 — a
162
+ * document saying "could not do its job" beside a code saying "the project
163
+ * failed its gate". An outcome that is a finding about the project is
164
+ * published as a finding, not through here.
165
+ *
166
+ * @param message - What went wrong, in the command's own words
167
+ * @param startTime - Command start time (from Date.now())
168
+ * @param format - What the operator asked for: `json`, or anything else (and
169
+ * omitted) for YAML
170
+ */
171
+ export function handleReportExpectedFailure(message, startTime, format) {
172
+ process.stderr.write(`${message}\n`);
173
+ const report = buildErrorReport(message, Date.now() - startTime);
174
+ return publishFailure(report, format, exitCodeForReport(report));
68
175
  }
69
176
  /**
70
177
  * Pure: the document {@link handleValidationGateFailure} writes.
@@ -78,9 +185,9 @@ export function buildValidationGateFailure(subject, issues) {
78
185
  }
79
186
  /**
80
187
  * Publish the documented failure payload for a command stopped by its OWN
81
- * validation gate, then exit 1.
188
+ * validation gate, then end on `FINDINGS`.
82
189
  *
83
- * {@link handleCommandError} above covers the UNEXPECTED failure (exit 2). This
190
+ * {@link handleCommandError} above covers the UNEXPECTED failure (`ERROR`). This
84
191
  * covers the expected one, and `vat skills build` / `vat skills package` both
85
192
  * exited it after writing zero bytes to stdout — while their `--help` texts
86
193
  * document a YAML summary on stdout and reserve exit 1 for exactly this case.
@@ -89,6 +196,42 @@ export function buildValidationGateFailure(subject, issues) {
89
196
  */
90
197
  export function handleValidationGateFailure(subject, issues) {
91
198
  writeYamlOutput(buildValidationGateFailure(subject, issues));
92
- process.exit(1);
199
+ process.exit(ExitCode.FINDINGS);
200
+ }
201
+ /**
202
+ * Map a commander termination to the exit code VAT's contract promises.
203
+ *
204
+ * A USAGE mistake — a flag this program does not declare, a verb it does not
205
+ * know, a missing or invalid argument — ends on `ExitCode.ERROR`, and the
206
+ * reason is not style. Commander's default for a usage mistake is
207
+ * `process.exit(1)`, so `vat resources check --json` (the option is
208
+ * `--format json`) exited **1** — which, read against the contract the command
209
+ * itself prints, asserts that at least one check was violated. Nothing had
210
+ * run. A CI wrapper spelled `if [ $? -ne 0 ]; then report_findings` therefore
211
+ * reported findings that were never computed. The same hole swallowed a
212
+ * mistyped verb (`vat resources chekc`) and every unknown option on every
213
+ * command.
214
+ *
215
+ * Commander reports BOTH successful and failing terminations through the same
216
+ * `CommanderError`: `--help` and `--version` carry `exitCode` 0, while an
217
+ * unknown option, an unknown command and `help({ error: true })` carry non-zero.
218
+ * Anything non-zero is a usage mistake by construction — commander raises these
219
+ * only while parsing, before any action runs — so it maps to `ERROR`.
220
+ *
221
+ * ⚠️ **Help and `--version` are NOT usage mistakes.** They terminate through
222
+ * the same `_exit` path with code 0 and must stay `OK`; only a non-zero
223
+ * commander ending is remapped.
224
+ *
225
+ * 🪤 Do NOT switch on `error.code` (`commander.unknownOption`, `commander.help`,
226
+ * …). The unknown-COMMAND path arrives as `commander.help` with exitCode 1,
227
+ * because the `command:*` handler renders help with `{ error: true }` — so the
228
+ * code string says "help" for a case that is emphatically not one. The exit
229
+ * code commander already computed is the honest discriminator; the string is not.
230
+ *
231
+ * @param commanderExitCode - The `exitCode` commander put on its CommanderError
232
+ * @returns `OK` for a successful ending, `ERROR` otherwise
233
+ */
234
+ export function exitCodeForCommanderEnding(commanderExitCode) {
235
+ return commanderExitCode === 0 ? ExitCode.OK : ExitCode.ERROR;
93
236
  }
94
237
  //# 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,kCAAkC,CAAC;AAG9G,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C;;;;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;QACf,OAAO,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;IACtC,CAAC;IACD,OAAO,GAAG,CAAC,EAAE,GAAG,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;AACvC,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,yEAAyE;QACzE,OAAO,KAAK,CAAC,KAAK,IAAI,GAAG,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,OAAO,EAA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GAAG,SAAS,CAAC,CAAC;IACjE,OAAO,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC;AACnE,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,2BAA2B,CACzC,OAAe,EACf,SAAiB,EACjB,MAA2B;IAE3B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,IAAI,CAAC,CAAC;IACrC,MAAM,MAAM,GAAG,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC,CAAC;IACjE,OAAO,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC;AACnE,CAAC;AAUD;;;;;;GAMG;AACH,MAAM,UAAU,0BAA0B,CACxC,OAAe,EACf,MAAkC;IAElC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,eAAe,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AACnF,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,2BAA2B,CACzC,OAAe,EACf,MAAkC;IAElC,eAAe,CAAC,0BAA0B,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;IAC7D,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAClC,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,UAAU,0BAA0B,CAAC,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,EAAuB,KAAK,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAMxF;;;;;;;;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,CA8BzE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAEvD;AAqBD;;;;;GAKG;AACH,wBAAgB,sBAAsB,IAAI,IAAI,CAG7C;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"}
@@ -6,10 +6,16 @@
6
6
  */
7
7
  import { readFileSync, existsSync } from 'node:fs';
8
8
  import { dirname } from 'node:path';
9
- import { ProjectConfigSchema } from '@vibe-agent-toolkit/resources';
10
- import { safePath } from '@vibe-agent-toolkit/utils';
9
+ import { parseConfigAllowingUnknownKeys, ProjectConfigSchema } from '@vibe-agent-toolkit/resources';
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
+ /**
14
+ * Config paths already warned about for unknown keys, so one config governing
15
+ * many skills produces one line rather than one per skill. Cleared with the
16
+ * config cache, which is what a test isolating a fixture resets.
17
+ */
18
+ const warnedConfigPaths = new Set();
13
19
  /**
14
20
  * A `vibe-agent-toolkit.config.yaml` exists but failed to parse or validate.
15
21
  *
@@ -19,11 +25,10 @@ const CONFIG_FILENAME = 'vibe-agent-toolkit.config.yaml';
19
25
  * `vat skill test`) should surface this; a bulk linter (`vat audit`) may catch
20
26
  * it and fall back to config-free validation.
21
27
  */
22
- export class ConfigLoadError extends Error {
28
+ export class ConfigLoadError extends VatError {
23
29
  projectRoot;
24
30
  constructor(projectRoot, cause) {
25
- super(cause instanceof Error ? cause.message : String(cause));
26
- this.name = 'ConfigLoadError';
31
+ super('CONFIG_LOAD', cause instanceof Error ? cause.message : String(cause));
27
32
  this.projectRoot = projectRoot;
28
33
  if (cause instanceof Error)
29
34
  this.cause = cause;
@@ -53,24 +58,42 @@ export class ConfigLoadError extends Error {
53
58
  export function loadConfig(projectRoot) {
54
59
  // Override for testing: VAT_TEST_CONFIG provides explicit config path
55
60
  const configPath = process.env['VAT_TEST_CONFIG'] ?? safePath.join(projectRoot, CONFIG_FILENAME);
56
- // eslint-disable-next-line security/detect-non-literal-fs-filename -- configPath is derived from projectRoot parameter or env override
57
61
  if (!existsSync(configPath)) {
58
62
  return undefined;
59
63
  }
60
64
  try {
61
- // eslint-disable-next-line security/detect-non-literal-fs-filename -- configPath is derived from projectRoot parameter
62
65
  const content = readFileSync(configPath, 'utf-8');
63
66
  const parsed = yaml.parse(content);
64
- // Validate with canonical schema from resources package
65
- const result = ProjectConfigSchema.safeParse(parsed);
66
- if (!result.success) {
67
- throw new Error(`Invalid configuration file: ${result.error.message}`);
68
- }
69
- return result.data;
67
+ // Validate with canonical schema from resources package.
68
+ //
69
+ // 🔑 The message comes from the shared formatter, NOT from `error.message`.
70
+ // In Zod 3 that property is a **JSON dump of the issue array**, and it was
71
+ // what an adopter got: five verbs exiting 2 in under a second on a blob that
72
+ // never named this file, never said which key was refused in words, and
73
+ // offered no remedy. Every strict block in the schema is a refusal an
74
+ // adopter has to be able to act on from the terminal alone.
75
+ // An UNKNOWN key warns and is dropped; every other validation failure still
76
+ // throws. See `parseConfigAllowingUnknownKeys` for the reasoning — briefly:
77
+ // a key VAT has no field for is a key VAT was already discarding, and
78
+ // turning that into an exit 2 broke commands that never read the section it
79
+ // was in. Warned once per config path, because `loadConfigCached` will
80
+ // otherwise re-warn for every skill under one project.
81
+ return parseConfigAllowingUnknownKeys(ProjectConfigSchema, parsed, (message) => {
82
+ if (warnedConfigPaths.has(configPath))
83
+ return;
84
+ warnedConfigPaths.add(configPath);
85
+ process.stderr.write(`${message}\n`);
86
+ }, { configPath });
70
87
  }
71
88
  catch (error) {
72
89
  if (error instanceof Error) {
73
- throw new Error(`Failed to load config: ${error.message}`);
90
+ // `cause` is load-bearing, not decoration: callers decide whether to
91
+ // degrade or abort by asking `isFilesystemAccessError`, which reads the
92
+ // errno off the error. Re-wrapping without it produced a plain Error with
93
+ // no `code`, so an unreadable config read as "a bug in VAT" and aborted the
94
+ // whole run — the exact failure `vat audit`'s guard exists to prevent,
95
+ // reintroduced by a message-formatting layer.
96
+ throw new Error(`Failed to load config: ${error.message}`, { cause: error });
74
97
  }
75
98
  throw error;
76
99
  }
@@ -107,6 +130,9 @@ const loadErrorCache = new Map();
107
130
  export function resetLoadedConfigCache() {
108
131
  loadedConfigCache.clear();
109
132
  loadErrorCache.clear();
133
+ // The warn-once ledger is part of this cache's state: a test that resets the
134
+ // caches and re-loads the same fixture expects to see the warning again.
135
+ warnedConfigPaths.clear();
110
136
  }
111
137
  /**
112
138
  * Cached variant of {@link loadConfig} keyed by `projectRoot`.
@@ -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,mBAAmB,EAAsB,MAAM,+BAA+B,CAAC;AACxF,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,MAAM,eAAe,GAAG,gCAAgC,CAAC;AAEzD;;;;;;;;GAQG;AACH,MAAM,OAAO,eAAgB,SAAQ,KAAK;IAC/B,WAAW,CAAS;IAC7B,YAAY,WAAmB,EAAE,KAAc;QAC7C,KAAK,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK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