code-auditor-mcp 5.0.1 → 5.2.0

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 (360) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/CHANGELOG.md +227 -3
  3. package/README.md +24 -2
  4. package/configs/hhra-compat.json +12 -118
  5. package/dist/analyzers/cross-language/DependencyGraphBuilder.d.ts.map +1 -1
  6. package/dist/analyzers/cross-language/DependencyGraphBuilder.js +11 -1
  7. package/dist/analyzers/cross-language/DependencyGraphBuilder.js.map +1 -1
  8. package/dist/analyzers/crossDomain/CrossDomainAnalyzer.d.ts.map +1 -1
  9. package/dist/analyzers/crossDomain/CrossDomainAnalyzer.js +57 -52
  10. package/dist/analyzers/crossDomain/CrossDomainAnalyzer.js.map +1 -1
  11. package/dist/analyzers/handleIdentification.d.ts.map +1 -1
  12. package/dist/analyzers/handleIdentification.js +4 -1
  13. package/dist/analyzers/handleIdentification.js.map +1 -1
  14. package/dist/analyzers/provenance.d.ts +9 -4
  15. package/dist/analyzers/provenance.d.ts.map +1 -1
  16. package/dist/analyzers/provenance.js +8 -25
  17. package/dist/analyzers/provenance.js.map +1 -1
  18. package/dist/analyzers/reactAnalyzer.d.ts.map +1 -1
  19. package/dist/analyzers/reactAnalyzer.js +0 -5
  20. package/dist/analyzers/reactAnalyzer.js.map +1 -1
  21. package/dist/analyzers/receiverRoot.d.ts +20 -0
  22. package/dist/analyzers/receiverRoot.d.ts.map +1 -1
  23. package/dist/analyzers/receiverRoot.js +42 -0
  24. package/dist/analyzers/receiverRoot.js.map +1 -1
  25. package/dist/analyzers/ruleRegistry.js +4 -4
  26. package/dist/analyzers/ruleRegistry.js.map +1 -1
  27. package/dist/analyzers/ruleTiming.d.ts +1 -1
  28. package/dist/analyzers/ruleTiming.js +2 -2
  29. package/dist/analyzers/ruleTiming.js.map +1 -1
  30. package/dist/analyzers/tsEcosystem.d.ts.map +1 -1
  31. package/dist/analyzers/tsEcosystem.js +10 -0
  32. package/dist/analyzers/tsEcosystem.js.map +1 -1
  33. package/dist/analyzers/universal/UniversalConventionsAnalyzer.d.ts.map +1 -1
  34. package/dist/analyzers/universal/UniversalConventionsAnalyzer.js +22 -26
  35. package/dist/analyzers/universal/UniversalConventionsAnalyzer.js.map +1 -1
  36. package/dist/analyzers/universal/UniversalDataAccessAnalyzer.d.ts +32 -15
  37. package/dist/analyzers/universal/UniversalDataAccessAnalyzer.d.ts.map +1 -1
  38. package/dist/analyzers/universal/UniversalDataAccessAnalyzer.js +189 -115
  39. package/dist/analyzers/universal/UniversalDataAccessAnalyzer.js.map +1 -1
  40. package/dist/analyzers/universal/UniversalSOLIDAnalyzer.d.ts +0 -2
  41. package/dist/analyzers/universal/UniversalSOLIDAnalyzer.d.ts.map +1 -1
  42. package/dist/analyzers/universal/UniversalSOLIDAnalyzer.js +0 -5
  43. package/dist/analyzers/universal/UniversalSOLIDAnalyzer.js.map +1 -1
  44. package/dist/analyzers/universal/UniversalStylesAnalyzer.d.ts +2 -10
  45. package/dist/analyzers/universal/UniversalStylesAnalyzer.d.ts.map +1 -1
  46. package/dist/analyzers/universal/UniversalStylesAnalyzer.js +7 -49
  47. package/dist/analyzers/universal/UniversalStylesAnalyzer.js.map +1 -1
  48. package/dist/analyzers/universal/schema/config.d.ts.map +1 -1
  49. package/dist/analyzers/universal/schema/config.js +0 -2
  50. package/dist/analyzers/universal/schema/config.js.map +1 -1
  51. package/dist/analyzers/universal/schema/types.d.ts +0 -2
  52. package/dist/analyzers/universal/schema/types.d.ts.map +1 -1
  53. package/dist/analyzers/vendorSurfaces.d.ts +126 -0
  54. package/dist/analyzers/vendorSurfaces.d.ts.map +1 -0
  55. package/dist/analyzers/vendorSurfaces.js +580 -0
  56. package/dist/analyzers/vendorSurfaces.js.map +1 -0
  57. package/dist/auditRunner.d.ts +2 -0
  58. package/dist/auditRunner.d.ts.map +1 -1
  59. package/dist/auditRunner.js +159 -160
  60. package/dist/auditRunner.js.map +1 -1
  61. package/dist/churn/churnExtractor.d.ts +0 -1
  62. package/dist/churn/churnExtractor.d.ts.map +1 -1
  63. package/dist/churn/churnExtractor.js +2 -4
  64. package/dist/churn/churnExtractor.js.map +1 -1
  65. package/dist/cli.d.ts +1 -1
  66. package/dist/cli.d.ts.map +1 -1
  67. package/dist/cli.js +212 -29
  68. package/dist/cli.js.map +1 -1
  69. package/dist/codeIndex/migrations.d.ts.map +1 -1
  70. package/dist/codeIndex/migrations.js +4 -3
  71. package/dist/codeIndex/migrations.js.map +1 -1
  72. package/dist/codeIndexDB.d.ts +11 -2
  73. package/dist/codeIndexDB.d.ts.map +1 -1
  74. package/dist/codeIndexDB.js +27 -2
  75. package/dist/codeIndexDB.js.map +1 -1
  76. package/dist/config/configLoader.d.ts +60 -7
  77. package/dist/config/configLoader.d.ts.map +1 -1
  78. package/dist/config/configLoader.js +252 -60
  79. package/dist/config/configLoader.js.map +1 -1
  80. package/dist/config/defaults.d.ts +77 -18
  81. package/dist/config/defaults.d.ts.map +1 -1
  82. package/dist/config/defaults.js +105 -43
  83. package/dist/config/defaults.js.map +1 -1
  84. package/dist/constants.d.ts +2 -1
  85. package/dist/constants.d.ts.map +1 -1
  86. package/dist/constants.js +4 -0
  87. package/dist/constants.js.map +1 -1
  88. package/dist/daemon/main.d.ts +0 -1
  89. package/dist/daemon/main.d.ts.map +1 -1
  90. package/dist/daemon/main.js +31 -8
  91. package/dist/daemon/main.js.map +1 -1
  92. package/dist/dataPaths.d.ts +17 -11
  93. package/dist/dataPaths.d.ts.map +1 -1
  94. package/dist/dataPaths.js +51 -16
  95. package/dist/dataPaths.js.map +1 -1
  96. package/dist/graph/resolutionEnvironment.d.ts +61 -0
  97. package/dist/graph/resolutionEnvironment.d.ts.map +1 -0
  98. package/dist/graph/resolutionEnvironment.js +57 -0
  99. package/dist/graph/resolutionEnvironment.js.map +1 -0
  100. package/dist/hookLog.d.ts +54 -0
  101. package/dist/hookLog.d.ts.map +1 -0
  102. package/dist/hookLog.js +105 -0
  103. package/dist/hookLog.js.map +1 -0
  104. package/dist/hookLogPath.generated.d.ts +3 -0
  105. package/dist/hookLogPath.generated.d.ts.map +1 -0
  106. package/dist/hookLogPath.generated.js +8 -0
  107. package/dist/hookLogPath.generated.js.map +1 -0
  108. package/dist/index.d.ts +0 -5
  109. package/dist/index.d.ts.map +1 -1
  110. package/dist/index.js +0 -7
  111. package/dist/index.js.map +1 -1
  112. package/dist/installConfig.d.ts +15 -2
  113. package/dist/installConfig.d.ts.map +1 -1
  114. package/dist/installConfig.js +17 -2
  115. package/dist/installConfig.js.map +1 -1
  116. package/dist/languages/typescript/TreeSitterTypeScriptAdapter.d.ts.map +1 -1
  117. package/dist/languages/typescript/TreeSitterTypeScriptAdapter.js +18 -3
  118. package/dist/languages/typescript/TreeSitterTypeScriptAdapter.js.map +1 -1
  119. package/dist/mcp-tools/workflowGuide.js +8 -8
  120. package/dist/mcp-tools/workflowGuide.js.map +1 -1
  121. package/dist/mcp-tools-shared.d.ts.map +1 -1
  122. package/dist/mcp-tools-shared.js +5 -2
  123. package/dist/mcp-tools-shared.js.map +1 -1
  124. package/dist/mcp-ui-simple.d.ts +5 -0
  125. package/dist/mcp-ui-simple.d.ts.map +1 -1
  126. package/dist/mcp-ui-simple.js +9 -2
  127. package/dist/mcp-ui-simple.js.map +1 -1
  128. package/dist/mcp.d.ts +0 -1
  129. package/dist/mcp.d.ts.map +1 -1
  130. package/dist/mcp.js +36 -33
  131. package/dist/mcp.js.map +1 -1
  132. package/dist/mcpAuditJobs.d.ts +10 -0
  133. package/dist/mcpAuditJobs.d.ts.map +1 -1
  134. package/dist/mcpAuditJobs.js +10 -1
  135. package/dist/mcpAuditJobs.js.map +1 -1
  136. package/dist/mcpAutoIndex.d.ts.map +1 -1
  137. package/dist/mcpAutoIndex.js +2 -1
  138. package/dist/mcpAutoIndex.js.map +1 -1
  139. package/dist/phase/colorMath.d.ts +18 -5
  140. package/dist/phase/colorMath.d.ts.map +1 -1
  141. package/dist/phase/colorMath.js +88 -5
  142. package/dist/phase/colorMath.js.map +1 -1
  143. package/dist/phase/dataAccessCallsCandidates.js +1 -1
  144. package/dist/phase/dataAccessCallsCandidates.js.map +1 -1
  145. package/dist/phase/goFunctionAnalysis.d.ts +2 -2
  146. package/dist/phase/goFunctionAnalysis.js +2 -2
  147. package/dist/phase/goFunctions.d.ts +2 -2
  148. package/dist/phase/goFunctions.js +2 -2
  149. package/dist/phase/goImports.d.ts +2 -2
  150. package/dist/phase/goImports.js +2 -2
  151. package/dist/phase/goSwitches.d.ts +2 -2
  152. package/dist/phase/goSwitches.js +2 -2
  153. package/dist/phase/loopQueryCandidates.js +1 -1
  154. package/dist/phase/loopQueryCandidates.js.map +1 -1
  155. package/dist/phase/phaseModel.d.ts +37 -8
  156. package/dist/phase/phaseModel.d.ts.map +1 -1
  157. package/dist/phase/phaseModel.js +94 -46
  158. package/dist/phase/phaseModel.js.map +1 -1
  159. package/dist/phase/producers.d.ts.map +1 -1
  160. package/dist/phase/producers.js +27 -17
  161. package/dist/phase/producers.js.map +1 -1
  162. package/dist/phase/reachability.d.ts +44 -1
  163. package/dist/phase/reachability.d.ts.map +1 -1
  164. package/dist/phase/reachability.js +79 -0
  165. package/dist/phase/reachability.js.map +1 -1
  166. package/dist/phase/receiverConsumers.d.ts +8 -1
  167. package/dist/phase/receiverConsumers.d.ts.map +1 -1
  168. package/dist/phase/receiverConsumers.js +59 -21
  169. package/dist/phase/receiverConsumers.js.map +1 -1
  170. package/dist/phase/receiverProvenance.d.ts +23 -0
  171. package/dist/phase/receiverProvenance.d.ts.map +1 -1
  172. package/dist/phase/receiverProvenance.js +40 -0
  173. package/dist/phase/receiverProvenance.js.map +1 -1
  174. package/dist/phase/rules/crossDomain.d.ts.map +1 -1
  175. package/dist/phase/rules/crossDomain.js +16 -6
  176. package/dist/phase/rules/crossDomain.js.map +1 -1
  177. package/dist/phase/rules/dry.d.ts.map +1 -1
  178. package/dist/phase/rules/dry.js +0 -1
  179. package/dist/phase/rules/dry.js.map +1 -1
  180. package/dist/phase/rules/goRules.d.ts +2 -2
  181. package/dist/phase/rules/goRules.js +2 -2
  182. package/dist/phase/rules/secrets.d.ts +22 -8
  183. package/dist/phase/rules/secrets.d.ts.map +1 -1
  184. package/dist/phase/rules/secrets.js +48 -67
  185. package/dist/phase/rules/secrets.js.map +1 -1
  186. package/dist/phase/rules/styles.d.ts +23 -9
  187. package/dist/phase/rules/styles.d.ts.map +1 -1
  188. package/dist/phase/rules/styles.js +47 -15
  189. package/dist/phase/rules/styles.js.map +1 -1
  190. package/dist/phase/rules/unreferencedModule.d.ts.map +1 -1
  191. package/dist/phase/rules/unreferencedModule.js +16 -5
  192. package/dist/phase/rules/unreferencedModule.js.map +1 -1
  193. package/dist/phase/runner.d.ts +16 -7
  194. package/dist/phase/runner.d.ts.map +1 -1
  195. package/dist/phase/runner.js +32 -20
  196. package/dist/phase/runner.js.map +1 -1
  197. package/dist/phase/stylesCss.d.ts.map +1 -1
  198. package/dist/phase/stylesCss.js +4 -0
  199. package/dist/phase/stylesCss.js.map +1 -1
  200. package/dist/phase/stylesMarkup.d.ts.map +1 -1
  201. package/dist/phase/stylesMarkup.js +4 -0
  202. package/dist/phase/stylesMarkup.js.map +1 -1
  203. package/dist/phase/stylesSource.d.ts.map +1 -1
  204. package/dist/phase/stylesSource.js +6 -0
  205. package/dist/phase/stylesSource.js.map +1 -1
  206. package/dist/phase/testProgram.d.ts +57 -0
  207. package/dist/phase/testProgram.d.ts.map +1 -0
  208. package/dist/phase/testProgram.js +244 -0
  209. package/dist/phase/testProgram.js.map +1 -0
  210. package/dist/phase/typeDeclarations.d.ts +2 -2
  211. package/dist/phase/typeDeclarations.js +2 -2
  212. package/dist/phase/types.d.ts +54 -0
  213. package/dist/phase/types.d.ts.map +1 -1
  214. package/dist/pipelineAdapters.d.ts +1 -171
  215. package/dist/pipelineAdapters.d.ts.map +1 -1
  216. package/dist/pipelineAdapters.js +47 -1281
  217. package/dist/pipelineAdapters.js.map +1 -1
  218. package/dist/reporting/csvReportGenerator.d.ts.map +1 -1
  219. package/dist/reporting/csvReportGenerator.js +0 -6
  220. package/dist/reporting/csvReportGenerator.js.map +1 -1
  221. package/dist/reporting/htmlReportGenerator.d.ts.map +1 -1
  222. package/dist/reporting/htmlReportGenerator.js +0 -4
  223. package/dist/reporting/htmlReportGenerator.js.map +1 -1
  224. package/dist/reporting/jsonReportGenerator.d.ts.map +1 -1
  225. package/dist/reporting/jsonReportGenerator.js +0 -1
  226. package/dist/reporting/jsonReportGenerator.js.map +1 -1
  227. package/dist/reporting/sarifReportGenerator.d.ts.map +1 -1
  228. package/dist/reporting/sarifReportGenerator.js +0 -7
  229. package/dist/reporting/sarifReportGenerator.js.map +1 -1
  230. package/dist/sqlite/driver.d.ts +17 -1
  231. package/dist/sqlite/driver.d.ts.map +1 -1
  232. package/dist/sqlite/driver.js +28 -5
  233. package/dist/sqlite/driver.js.map +1 -1
  234. package/dist/styles/cssInJsHarvest.d.ts +36 -0
  235. package/dist/styles/cssInJsHarvest.d.ts.map +1 -0
  236. package/dist/styles/cssInJsHarvest.js +78 -0
  237. package/dist/styles/cssInJsHarvest.js.map +1 -0
  238. package/dist/styles/definedClasses.d.ts +95 -0
  239. package/dist/styles/definedClasses.d.ts.map +1 -0
  240. package/dist/styles/definedClasses.js +129 -0
  241. package/dist/styles/definedClasses.js.map +1 -0
  242. package/dist/styles/markupStyleHarvest.d.ts +33 -0
  243. package/dist/styles/markupStyleHarvest.d.ts.map +1 -0
  244. package/dist/styles/markupStyleHarvest.js +73 -0
  245. package/dist/styles/markupStyleHarvest.js.map +1 -0
  246. package/dist/styles/styleExtractor.d.ts +37 -0
  247. package/dist/styles/styleExtractor.d.ts.map +1 -1
  248. package/dist/styles/styleExtractor.js +89 -33
  249. package/dist/styles/styleExtractor.js.map +1 -1
  250. package/dist/styles/styleIndexer.d.ts.map +1 -1
  251. package/dist/styles/styleIndexer.js +11 -10
  252. package/dist/styles/styleIndexer.js.map +1 -1
  253. package/dist/styles/tailwindExpander.d.ts.map +1 -1
  254. package/dist/styles/tailwindExpander.js +31 -10
  255. package/dist/styles/tailwindExpander.js.map +1 -1
  256. package/dist/telemetry.d.ts +67 -1
  257. package/dist/telemetry.d.ts.map +1 -1
  258. package/dist/telemetry.js +100 -20
  259. package/dist/telemetry.js.map +1 -1
  260. package/dist/types/crossLanguage.d.ts +1 -0
  261. package/dist/types/crossLanguage.d.ts.map +1 -1
  262. package/dist/types.d.ts +36 -56
  263. package/dist/types.d.ts.map +1 -1
  264. package/dist/types.js +4 -4
  265. package/dist/types.js.map +1 -1
  266. package/dist/version.generated.d.ts +1 -1
  267. package/dist/version.generated.js +1 -1
  268. package/examples/.auditrc.example.json +7 -22
  269. package/examples/.auditrc.json +12 -155
  270. package/examples/.code-auditor.json +8 -51
  271. package/examples/nextjs.auditrc.json +7 -34
  272. package/examples/node-api.auditrc.json +6 -46
  273. package/examples/react.auditrc.json +8 -25
  274. package/examples/tolerant-solid.auditrc.json +12 -44
  275. package/package.json +13 -9
  276. package/plugin/.claude-plugin/manifest.json +10 -9
  277. package/plugin/.claude-plugin/plugin.json +1 -1
  278. package/plugin/hooks/hooks.json +4 -4
  279. package/plugin/scripts/hook-audit.sh +14 -2
  280. package/plugin/scripts/hook-common.sh +41 -11
  281. package/plugin/scripts/hook-drift-check.sh +19 -6
  282. package/plugin/scripts/hook-log-path.sh +7 -0
  283. package/plugin/scripts/hook-self-audit.sh +14 -2
  284. package/plugin/scripts/hook-warm.sh +22 -17
  285. package/plugin/skills/code-auditor/SKILL.md +26 -3
  286. package/server.json +10 -4
  287. package/dist/__tests__/fixtures/spec-20/scripts/tool.d.ts +0 -6
  288. package/dist/__tests__/fixtures/spec-20/scripts/tool.d.ts.map +0 -1
  289. package/dist/__tests__/fixtures/spec-20/scripts/tool.js +0 -12
  290. package/dist/__tests__/fixtures/spec-20/scripts/tool.js.map +0 -1
  291. package/dist/__tests__/fixtures/spec-20/src/demo-module.d.ts +0 -7
  292. package/dist/__tests__/fixtures/spec-20/src/demo-module.d.ts.map +0 -1
  293. package/dist/__tests__/fixtures/spec-20/src/demo-module.js +0 -13
  294. package/dist/__tests__/fixtures/spec-20/src/demo-module.js.map +0 -1
  295. package/dist/__tests__/fixtures/spec-52/item-01-prepare-in-loop.d.ts +0 -14
  296. package/dist/__tests__/fixtures/spec-52/item-01-prepare-in-loop.d.ts.map +0 -1
  297. package/dist/__tests__/fixtures/spec-52/item-01-prepare-in-loop.js +0 -16
  298. package/dist/__tests__/fixtures/spec-52/item-01-prepare-in-loop.js.map +0 -1
  299. package/dist/__tests__/fixtures/spec-52/item-02-prepare-bind-accumulate-batch.d.ts +0 -15
  300. package/dist/__tests__/fixtures/spec-52/item-02-prepare-bind-accumulate-batch.d.ts.map +0 -1
  301. package/dist/__tests__/fixtures/spec-52/item-02-prepare-bind-accumulate-batch.js +0 -17
  302. package/dist/__tests__/fixtures/spec-52/item-02-prepare-bind-accumulate-batch.js.map +0 -1
  303. package/dist/__tests__/fixtures/spec-52/item-03-exec-in-loop.d.ts +0 -14
  304. package/dist/__tests__/fixtures/spec-52/item-03-exec-in-loop.d.ts.map +0 -1
  305. package/dist/__tests__/fixtures/spec-52/item-03-exec-in-loop.js +0 -19
  306. package/dist/__tests__/fixtures/spec-52/item-03-exec-in-loop.js.map +0 -1
  307. package/dist/__tests__/fixtures/spec-52/item-04-storage-sql-exec-in-loop.d.ts +0 -18
  308. package/dist/__tests__/fixtures/spec-52/item-04-storage-sql-exec-in-loop.d.ts.map +0 -1
  309. package/dist/__tests__/fixtures/spec-52/item-04-storage-sql-exec-in-loop.js +0 -19
  310. package/dist/__tests__/fixtures/spec-52/item-04-storage-sql-exec-in-loop.js.map +0 -1
  311. package/dist/__tests__/fixtures/spec-52/item-05-upsert-forms.d.ts +0 -19
  312. package/dist/__tests__/fixtures/spec-52/item-05-upsert-forms.d.ts.map +0 -1
  313. package/dist/__tests__/fixtures/spec-52/item-05-upsert-forms.js +0 -19
  314. package/dist/__tests__/fixtures/spec-52/item-05-upsert-forms.js.map +0 -1
  315. package/dist/__tests__/fixtures/spec-52/item-06-chained-prepare-run-in-loop.d.ts +0 -17
  316. package/dist/__tests__/fixtures/spec-52/item-06-chained-prepare-run-in-loop.d.ts.map +0 -1
  317. package/dist/__tests__/fixtures/spec-52/item-06-chained-prepare-run-in-loop.js +0 -19
  318. package/dist/__tests__/fixtures/spec-52/item-06-chained-prepare-run-in-loop.js.map +0 -1
  319. package/dist/__tests__/fixtures/spec-52/item-07-chained-prepare-bind-first-in-loop.d.ts +0 -25
  320. package/dist/__tests__/fixtures/spec-52/item-07-chained-prepare-bind-first-in-loop.d.ts.map +0 -1
  321. package/dist/__tests__/fixtures/spec-52/item-07-chained-prepare-bind-first-in-loop.js +0 -21
  322. package/dist/__tests__/fixtures/spec-52/item-07-chained-prepare-bind-first-in-loop.js.map +0 -1
  323. package/dist/__tests__/fixtures/spec-52/item-08-promise-all-of-statements-in-loop.d.ts +0 -15
  324. package/dist/__tests__/fixtures/spec-52/item-08-promise-all-of-statements-in-loop.d.ts.map +0 -1
  325. package/dist/__tests__/fixtures/spec-52/item-08-promise-all-of-statements-in-loop.js +0 -19
  326. package/dist/__tests__/fixtures/spec-52/item-08-promise-all-of-statements-in-loop.js.map +0 -1
  327. package/dist/__tests__/fixtures/spec-52/item-09-promise-all-map-of-statements-in-loop.d.ts +0 -14
  328. package/dist/__tests__/fixtures/spec-52/item-09-promise-all-map-of-statements-in-loop.d.ts.map +0 -1
  329. package/dist/__tests__/fixtures/spec-52/item-09-promise-all-map-of-statements-in-loop.js +0 -14
  330. package/dist/__tests__/fixtures/spec-52/item-09-promise-all-map-of-statements-in-loop.js.map +0 -1
  331. package/dist/__tests__/fixtures/spec-52/item-10-promise-all-map-of-eager-all-in-loop.d.ts +0 -15
  332. package/dist/__tests__/fixtures/spec-52/item-10-promise-all-map-of-eager-all-in-loop.d.ts.map +0 -1
  333. package/dist/__tests__/fixtures/spec-52/item-10-promise-all-map-of-eager-all-in-loop.js +0 -16
  334. package/dist/__tests__/fixtures/spec-52/item-10-promise-all-map-of-eager-all-in-loop.js.map +0 -1
  335. package/dist/languages/go/analyzer-darwin-amd64 +0 -0
  336. package/dist/languages/go/analyzer-darwin-arm64 +0 -0
  337. package/dist/languages/go/analyzer-linux-amd64 +0 -0
  338. package/dist/languages/go/analyzer-linux-arm64 +0 -0
  339. package/dist/languages/go/analyzer-src/analyzer.go +0 -643
  340. package/dist/languages/go/analyzer-src/dataaccess.go +0 -388
  341. package/dist/languages/go/analyzer-src/go.mod +0 -3
  342. package/dist/languages/go/analyzer-src/indexer.go +0 -268
  343. package/dist/languages/go/analyzer-src/parser.go +0 -461
  344. package/dist/languages/go/analyzer-src/solid.go +0 -311
  345. package/dist/languages/go/analyzer-src/testconventions.go +0 -25
  346. package/dist/languages/go/analyzer-src/types.go +0 -156
  347. package/dist/languages/go/analyzer-windows-amd64.exe +0 -0
  348. package/dist/languages/go/go.mod +0 -7
  349. package/dist/languages/go/main.go +0 -203
  350. package/dist/native/ast-grep-napi.darwin-arm64.node +0 -0
  351. package/dist/native/ast-grep-napi.darwin-x64.node +0 -0
  352. package/dist/native/ast-grep-napi.linux-arm64-gnu.node +0 -0
  353. package/dist/native/ast-grep-napi.linux-arm64-musl.node +0 -0
  354. package/dist/native/ast-grep-napi.linux-x64-gnu.node +0 -0
  355. package/dist/native/ast-grep-napi.linux-x64-musl.node +0 -0
  356. package/dist/native/ast-grep-napi.win32-x64-msvc.node +0 -0
  357. package/dist/native-bootstrap.d.ts +0 -15
  358. package/dist/native-bootstrap.d.ts.map +0 -1
  359. package/dist/native-bootstrap.js +0 -75
  360. package/dist/native-bootstrap.js.map +0 -1
@@ -1,7 +1,4 @@
1
1
  {
2
- "projectRoot": ".",
3
- "reportTitle": "Node.js API Audit",
4
-
5
2
  "includePaths": [
6
3
  "src/**/*.{ts,js}",
7
4
  "lib/**/*.{ts,js}",
@@ -11,7 +8,7 @@
11
8
  "services/**/*.{ts,js}",
12
9
  "models/**/*.{ts,js}"
13
10
  ],
14
-
11
+
15
12
  "excludePaths": [
16
13
  "**/node_modules/**",
17
14
  "**/dist/**",
@@ -21,55 +18,18 @@
21
18
  "**/__tests__/**",
22
19
  "**/coverage/**"
23
20
  ],
24
-
25
- "analyzerConfig": {
26
- "security": {
27
- "authPatterns": ["authenticate", "authorize", "requireAuth", "passport"],
28
- "rateLimitPatterns": ["rateLimit", "throttle", "limiter"],
29
- "securityHeaders": [
30
- "helmet",
31
- "cors",
32
- "Content-Security-Policy"
33
- ]
34
- },
35
- "data-access": {
36
- "databasePatterns": {
37
- "postgres": ["pg", "postgres"],
38
- "mysql": ["mysql", "mysql2"],
39
- "mongodb": ["mongodb", "mongoose"]
40
- },
41
- "securityPatterns": {
42
- "parameterized": ["?", "$1", ":id"],
43
- "sanitized": ["sanitize", "escape", "validator"]
44
- },
45
- "performanceThresholds": {
46
- "maxJoins": 4,
47
- "warnOnSelectStar": true
48
- }
49
- },
21
+
22
+ "analyzerConfigs": {
50
23
  "solid": {
51
24
  "maxMethodsPerClass": 12,
52
25
  "maxLinesPerMethod": 60,
53
26
  "maxParametersPerMethod": 5
54
27
  }
55
28
  },
56
-
57
- "outputFormats": ["json", "html"],
58
- "outputDirectory": "./audit-reports",
59
-
29
+
60
30
  "minSeverity": "severe",
61
- "failOnCritical": true,
62
-
31
+
63
32
  "thresholds": {
64
- "maxCritical": 0,
65
- "maxWarnings": 10,
66
33
  "minHealthScore": 90
67
- },
68
-
69
- "integrations": {
70
- "ci": {
71
- "provider": "github",
72
- "failOnThreshold": true
73
- }
74
34
  }
75
- }
35
+ }
@@ -1,11 +1,8 @@
1
1
  {
2
- "projectRoot": ".",
3
- "reportTitle": "React Project Audit",
4
-
5
2
  "includePaths": [
6
3
  "src/**/*.{ts,tsx,js,jsx}"
7
4
  ],
8
-
5
+
9
6
  "excludePaths": [
10
7
  "**/node_modules/**",
11
8
  "**/build/**",
@@ -16,18 +13,10 @@
16
13
  "**/coverage/**",
17
14
  "**/*.stories.{ts,tsx,js,jsx}"
18
15
  ],
19
-
20
- "analyzerConfig": {
21
- "component": {
22
- "checkErrorBoundaries": true,
23
- "checkPropTypes": true,
24
- "maxComplexity": 12,
25
- "frameworkPatterns": {
26
- "react": {
27
- "hooks": ["use*"],
28
- "context": ["*Context", "*Provider"]
29
- }
30
- }
16
+
17
+ "analyzerConfigs": {
18
+ "react": {
19
+ "maxComponentComplexity": 12
31
20
  },
32
21
  "solid": {
33
22
  "maxMethodsPerClass": 8,
@@ -38,16 +27,10 @@
38
27
  "checkImports": true
39
28
  }
40
29
  },
41
-
42
- "outputFormats": ["html", "json"],
43
- "outputDirectory": "./audit-reports",
44
-
30
+
45
31
  "minSeverity": "severe",
46
- "showProgress": true,
47
-
32
+
48
33
  "thresholds": {
49
- "maxCritical": 0,
50
- "maxWarnings": 30,
51
34
  "minHealthScore": 75
52
35
  }
53
- }
36
+ }
@@ -1,11 +1,8 @@
1
1
  {
2
- "projectRoot": ".",
3
- "reportTitle": "Project Audit with Relaxed SOLID Tolerances",
4
-
5
2
  "includePaths": [
6
3
  "src/**/*.{ts,tsx,js,jsx}"
7
4
  ],
8
-
5
+
9
6
  "excludePaths": [
10
7
  "**/node_modules/**",
11
8
  "**/build/**",
@@ -13,53 +10,24 @@
13
10
  "**/*.test.{ts,tsx,js,jsx}",
14
11
  "**/*.spec.{ts,tsx,js,jsx}"
15
12
  ],
16
-
13
+
17
14
  "analyzerConfigs": {
18
15
  "solid": {
19
- "componentResponsibilityThresholds": {
20
- "default": 2,
21
- "layout": 2,
22
- "dashboard": 4,
23
- "table": 3,
24
- "form": 3
25
- },
26
-
27
- "classResponsibilityThresholds": {
28
- "default": 2,
29
- "repository": 2,
30
- "service": 3,
31
- "controller": 3,
32
- "model": 3
33
- },
34
-
35
- "ifElseChainThreshold": 5,
36
- "switchCaseThreshold": 7,
37
- "classMethodThreshold": 12,
38
- "interfaceMemberThreshold": 20,
39
- "dependencyInjectionLimit": 6
16
+ "classMethodsThreshold": 40,
17
+ "maxInterfaceMembers": 50,
18
+ "maxMethodComplexity": 100
40
19
  },
41
-
20
+
42
21
  "dry": {
43
- "minLineThreshold": 15,
44
- "similarityThreshold": 0.85,
45
- "checkImports": true,
46
- "unusedImportsConfig": {
47
- "checkLevel": "function",
48
- "includeTypeOnlyImports": false,
49
- "ignorePatterns": ["React", "^_", "test.*"]
50
- }
22
+ "minLineThreshold": 15,
23
+ "similarityThreshold": 0.85,
24
+ "checkImports": true
51
25
  }
52
26
  },
53
-
54
- "outputFormats": ["html", "json"],
55
- "outputDirectory": "./audit-reports",
56
-
27
+
57
28
  "minSeverity": "severe",
58
- "showProgress": true,
59
-
29
+
60
30
  "thresholds": {
61
- "maxCritical": 5,
62
- "maxWarnings": 50,
63
31
  "minHealthScore": 70
64
32
  }
65
- }
33
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "code-auditor-mcp",
3
- "version": "5.0.1",
4
- "description": "Architectural invariants and code quality analysis, enforced inside your AI agent's edit loop. MCP server + CLI + Claude Code plugin. TypeScript, JavaScript, Go.",
3
+ "version": "5.2.0",
4
+ "description": "Enforces architectural invariants and code quality rules inside your AI agent's edit loop.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "type": "module",
@@ -12,9 +12,9 @@
12
12
  "code-auditor-daemon": "dist/daemon/main.js"
13
13
  },
14
14
  "scripts": {
15
- "build": "pnpm run build:version && tsc && pnpm run build:grammars && pnpm run download:natives && pnpm run build:skills && pnpm run build:manifest",
15
+ "build": "pnpm run build:version && pnpm run build:hooklog && tsc && pnpm run build:grammars && pnpm run build:skills && pnpm run build:manifest",
16
16
  "build:version": "node scripts/write-version.mjs",
17
- "download:natives": "bash scripts/download-natives.sh",
17
+ "build:hooklog": "node scripts/write-hook-log-path.mjs",
18
18
  "build:grammars": "mkdir -p dist/grammars && cp node_modules/tree-sitter-typescript/tree-sitter-typescript.wasm node_modules/tree-sitter-typescript/tree-sitter-tsx.wasm node_modules/tree-sitter-go/tree-sitter-go.wasm node_modules/tree-sitter-css/tree-sitter-css.wasm grammars/tree-sitter-scss.wasm dist/grammars/",
19
19
  "build:skills": "node scripts/build-skills.mjs",
20
20
  "build:manifest": "node scripts/build-manifest.mjs",
@@ -36,6 +36,8 @@
36
36
  "verify:disk-space": "node scripts/verify-disk-space.mjs",
37
37
  "verify:types": "tsc --noEmit",
38
38
  "verify:dist-fresh": "node scripts/verify-dist-fresh.mjs",
39
+ "verify:hook-log-path": "node scripts/verify-hook-log-path.mjs",
40
+ "verify:version-fresh": "node scripts/verify-version-fresh.mjs",
39
41
  "verify:clean-install": "bash scripts/verify-clean-install.sh",
40
42
  "verify:dist": "npm pack --silent && bash scripts/verify-dist.sh && rm -f code-auditor-mcp-*.tgz",
41
43
  "verify:self": "node scripts/verify-self.mjs && node scripts/verify-languages.mjs",
@@ -45,23 +47,26 @@
45
47
  "verify:gate-budget": "node scripts/verify-gate-budget.mjs",
46
48
  "verify:recall-value-drift": "tsx scripts/verify-recall-value-drift.ts",
47
49
  "verify:extraction-completeness": "tsx scripts/verify-extraction-completeness.ts",
48
- "verify:oracle-shortfalls": "tsx scripts/verify-oracle-shortfalls.ts",
50
+ "verify:recall-cases": "tsx scripts/verify-recall-cases.ts",
49
51
  "verify:close": "node scripts/verify-close.mjs"
50
52
  },
51
53
  "keywords": [
52
54
  "mcp",
53
55
  "code-quality",
54
56
  "static-analysis",
57
+ "ai-agent",
55
58
  "ai-agents",
56
59
  "claude-code",
57
- "invariants",
60
+ "cursor",
61
+ "codex",
58
62
  "sarif",
59
63
  "tree-sitter",
60
- "linter",
61
64
  "solid",
65
+ "go",
62
66
  "typescript",
63
67
  "javascript",
64
- "go"
68
+ "invariants",
69
+ "linter"
65
70
  ],
66
71
  "author": "benahammond",
67
72
  "license": "MIT",
@@ -119,7 +124,6 @@
119
124
  "files": [
120
125
  "dist/**/*",
121
126
  "dist/grammars/",
122
- "dist/native/",
123
127
  "plugin/**/*",
124
128
  ".claude-plugin/**/*",
125
129
  "examples/**/*",
@@ -1,16 +1,17 @@
1
1
  {
2
- "version": "5.0.1",
2
+ "version": "5.2.0",
3
3
  "files": {
4
- ".claude-plugin/plugin.json": "3703d82b6985618b4d93577d72542790d36b38bf9ffd84a8a84c5f200ab5add9",
4
+ ".claude-plugin/plugin.json": "b492a180519f2991d0aa18211c3c9e45e6569c4715339e79d2032bbeec6ff44d",
5
5
  "README.md": "6e51516ead6c7d0b4e77629e071e139b899d30a47838e8721c0d534eb733ad45",
6
- "hooks/hooks.json": "4480d9d4fe80dbeb8fc8dacb0a6c67a46f45bf4610b42718876ed4a01935e7b1",
7
- "scripts/hook-audit.sh": "5286ee058a73ce9cf3a2fdbb325b8835ae70d85436365d691e95ad6c52bcb84c",
8
- "scripts/hook-common.sh": "e6a7b8da6a5e5d528c297c9ab381c77a1d360a6813775ef85342ff200d07a020",
9
- "scripts/hook-drift-check.sh": "6fcb897fc5fe6814e9a4cae3138532e6783bb44044c549f89fbfe8eb44580e44",
10
- "scripts/hook-self-audit.sh": "4b218f754ca466052da16b0578e2889bdff1abf16d7cbc27a259f71e332af392",
11
- "scripts/hook-warm.sh": "9923fe1434e5579abebae868772aba1e53d25d7392b4181ccd4a41dc3692dd55",
6
+ "hooks/hooks.json": "f9817f337d147bbd0e175741e57c6bd0718c64352ddbff15b5ba9357272b6725",
7
+ "scripts/hook-audit.sh": "3fa178a87c8ac4d4d49d0cac16df308a37ccc89d778a5eda614799fc69e3e6c8",
8
+ "scripts/hook-common.sh": "0f29ac77e94ca7ba3f6ffe23bc91f9ce0c77f1568d9f13e29288d0cf5eef6bd8",
9
+ "scripts/hook-drift-check.sh": "4e6ed8e4e33d0765a5ed6adfda6fb3ecec5750d836632aa4ee6d7a6acce69665",
10
+ "scripts/hook-log-path.sh": "4ac27ac22dcb29fd82cbd9a936b3da7115c5182386a0e3290ed5ac9e529bc132",
11
+ "scripts/hook-self-audit.sh": "593926cd4714c653269791ed53675b46fbc92310074bff9194772e25665b0257",
12
+ "scripts/hook-warm.sh": "22d750e8e36164920515c8370f02dd48f9f09f26bfe4a21e67de91f45b5ffef9",
12
13
  "skills/code-auditor/SKILL-RULE-KINDS.md": "be1bbe1b56b19dc112c2657c1f5984f6f704b2ac9c1c0f78a561a58b110d508a",
13
14
  "skills/code-auditor/SKILL-SEARCH.md": "95d2df4474995bc5b18e14cc55ac55fb828024541463f109239567e2aa5ab7b0",
14
- "skills/code-auditor/SKILL.md": "f120c4b45fe38deeeb2f76ea74df763e87269a15defa6c0508413a41972447ec"
15
+ "skills/code-auditor/SKILL.md": "0f88508c4549f4b53fdfee431e43a27c7eba2ac99e0eaad64ba55492429be41b"
15
16
  }
16
17
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "code-auditor",
3
3
  "description": "Diff-scoped code quality auditing on every edit. Indexes your codebase, enforces invariants, and feeds violations back to the agent so fixes happen inline.",
4
- "version": "5.0.1",
4
+ "version": "5.2.0",
5
5
  "author": {
6
6
  "name": "Ben Hammond",
7
7
  "email": "ben@benhammond.tech"
@@ -6,11 +6,11 @@
6
6
  "hooks": [
7
7
  {
8
8
  "type": "command",
9
- "command": "if [ -z \"${CLAUDE_PLUGIN_ROOT}\" ]; then exit 0; fi; \"${CLAUDE_PLUGIN_ROOT}\"/scripts/hook-warm.sh"
9
+ "command": "if [ -z \"${CLAUDE_PLUGIN_ROOT}\" ]; then dir=\"${XDG_CACHE_HOME:-$HOME/.cache}/code-auditor/logs\"; mkdir -p \"$dir\" 2>/dev/null || true; echo \"[$(date -u +%Y-%m-%dT%H:%M:%SZ)] [code-auditor] HOOK NOT RUNNING: CLAUDE_PLUGIN_ROOT is unset — could not locate the plugin; the warm-up is not running.\" >> \"$dir/hook.log\" 2>/dev/null || true; exit 0; fi; \"${CLAUDE_PLUGIN_ROOT}\"/scripts/hook-warm.sh"
10
10
  },
11
11
  {
12
12
  "type": "command",
13
- "command": "if [ -z \"${CLAUDE_PLUGIN_ROOT}\" ]; then exit 0; fi; \"${CLAUDE_PLUGIN_ROOT}\"/scripts/hook-drift-check.sh"
13
+ "command": "if [ -z \"${CLAUDE_PLUGIN_ROOT}\" ]; then dir=\"${XDG_CACHE_HOME:-$HOME/.cache}/code-auditor/logs\"; mkdir -p \"$dir\" 2>/dev/null || true; echo \"[$(date -u +%Y-%m-%dT%H:%M:%SZ)] [code-auditor] HOOK NOT RUNNING: CLAUDE_PLUGIN_ROOT is unset — could not locate the plugin; the drift check is not running.\" >> \"$dir/hook.log\" 2>/dev/null || true; exit 0; fi; \"${CLAUDE_PLUGIN_ROOT}\"/scripts/hook-drift-check.sh"
14
14
  }
15
15
  ]
16
16
  }
@@ -21,11 +21,11 @@
21
21
  "hooks": [
22
22
  {
23
23
  "type": "command",
24
- "command": "if [ -z \"${CLAUDE_PLUGIN_ROOT}\" ]; then exit 0; fi; \"${CLAUDE_PLUGIN_ROOT}\"/scripts/hook-audit.sh"
24
+ "command": "if [ -z \"${CLAUDE_PLUGIN_ROOT}\" ]; then dir=\"${XDG_CACHE_HOME:-$HOME/.cache}/code-auditor/logs\"; mkdir -p \"$dir\" 2>/dev/null || true; echo \"[$(date -u +%Y-%m-%dT%H:%M:%SZ)] [code-auditor] HOOK NOT RUNNING: CLAUDE_PLUGIN_ROOT is unset — could not locate the plugin; the audit is not running.\" >> \"$dir/hook.log\" 2>/dev/null || true; exit 0; fi; \"${CLAUDE_PLUGIN_ROOT}\"/scripts/hook-audit.sh"
25
25
  },
26
26
  {
27
27
  "type": "command",
28
- "command": "if [ -z \"${CLAUDE_PLUGIN_ROOT}\" ]; then exit 0; fi; \"${CLAUDE_PLUGIN_ROOT}\"/scripts/hook-self-audit.sh"
28
+ "command": "if [ -z \"${CLAUDE_PLUGIN_ROOT}\" ]; then dir=\"${XDG_CACHE_HOME:-$HOME/.cache}/code-auditor/logs\"; mkdir -p \"$dir\" 2>/dev/null || true; echo \"[$(date -u +%Y-%m-%dT%H:%M:%SZ)] [code-auditor] HOOK NOT RUNNING: CLAUDE_PLUGIN_ROOT is unset — could not locate the plugin; the self-audit is not running.\" >> \"$dir/hook.log\" 2>/dev/null || true; exit 0; fi; \"${CLAUDE_PLUGIN_ROOT}\"/scripts/hook-self-audit.sh"
29
29
  }
30
30
  ]
31
31
  }
@@ -16,8 +16,11 @@
16
16
  # failure surfaces on the next explicit audit, never on the edit.
17
17
  set -euo pipefail
18
18
 
19
- # Shared resolver + compatibility pinning (see hook-common.sh).
20
- . "${CLAUDE_PLUGIN_ROOT}/scripts/hook-common.sh"
19
+ # Shared resolver + compatibility pinning (see hook-common.sh). Source it from
20
+ # this script's own directory — the plugin's scripts/ — never from a host
21
+ # environment variable.
22
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" 2>/dev/null && pwd)"
23
+ . "${SCRIPT_DIR}/hook-common.sh"
21
24
 
22
25
  # Read event JSON from stdin
23
26
  event="$(cat)"
@@ -89,6 +92,15 @@ fi
89
92
  exit_code=$?
90
93
  set -e
91
94
 
95
+ # A completed run — clean (0) or finding (2) — is the positive "the hook is
96
+ # alive and enqueueing" signal. Write it so the explicit-audit reader
97
+ # (src/hookLog.ts) can clear a prior HOOK NOT RUNNING condition: the reader
98
+ # resolves a condition by newest-record order, and without this line a hook that
99
+ # recovered would leave the stale condition live forever.
100
+ if [ "${exit_code}" -eq 0 ] || [ "${exit_code}" -eq 2 ]; then
101
+ hook_log "[code-auditor] HOOK RAN"
102
+ fi
103
+
92
104
  # Exit 2 = a finding read from the daemon cache; propagate so Claude Code feeds
93
105
  # stdout back.
94
106
  if [ ${exit_code} -eq 2 ]; then
@@ -1,9 +1,12 @@
1
1
  #!/usr/bin/env bash
2
2
  # Shared helpers for the code-auditor PostToolUse hooks.
3
3
  #
4
- # Sourced by hook-audit.sh and hook-self-audit.sh. CLAUDE_PLUGIN_ROOT is
5
- # guaranteed set before either hook runs (the hooks.json guard exits 1 when it
6
- # is unset).
4
+ # Sourced by hook-audit.sh, hook-self-audit.sh, hook-warm.sh, and
5
+ # hook-drift-check.sh. The plugin root is derived from where THIS file lives —
6
+ # `<plugin>/scripts/hook-common.sh`, so the root is its grand-parent — never
7
+ # from a host environment variable. `CLAUDE_PLUGIN_ROOT` is honored only as a
8
+ # validated override (see plugin_root below), so an unset or wrong value can
9
+ # never decide whether the tool runs.
7
10
  #
8
11
  # Two rules enforced here are the fix for "the hook died quietly" (three times:
9
12
  # unset CLAUDE_PLUGIN_ROOT, a stale global binary, a removed CLI flag):
@@ -30,6 +33,32 @@
30
33
  #
31
34
  # The sourcing hook runs with `set -euo pipefail`.
32
35
 
36
+ # plugin_root — the plugin's install root.
37
+ #
38
+ # This file ships at `<plugin>/scripts/hook-common.sh`, so the plugin root is the
39
+ # grand-parent of its own location. That fixed, known-at-build-time offset is the
40
+ # single source of truth: every path a hook needs (the manifest, the bundled CLI
41
+ # sibling) is derived from here, not read from a host variable that may be unset.
42
+ # `CLAUDE_PLUGIN_ROOT` is honored only when it actually points at a plugin — it
43
+ # must contain this same `scripts/hook-common.sh` — so a stale or wrong value
44
+ # never shadows the real location, and an absent one is a non-event.
45
+ plugin_root() {
46
+ local here root
47
+ here="$(cd "$(dirname "${BASH_SOURCE[0]}")" 2>/dev/null && pwd)"
48
+ root="$(dirname "${here}")"
49
+ if [ -n "${CLAUDE_PLUGIN_ROOT:-}" ] && [ -f "${CLAUDE_PLUGIN_ROOT}/scripts/hook-common.sh" ]; then
50
+ printf '%s' "${CLAUDE_PLUGIN_ROOT}"
51
+ return
52
+ fi
53
+ printf '%s' "${root}"
54
+ }
55
+
56
+ # The hook-log path tail + file name are single-sourced in hook-log-path.sh,
57
+ # generated by scripts/write-hook-log-path.mjs from the same source as
58
+ # src/hookLogPath.generated.ts (the reader's copy). Sourced here so the write
59
+ # half and the read half (src/hookLog.ts) can never drift apart.
60
+ . "$(cd "$(dirname "${BASH_SOURCE[0]}")" 2>/dev/null && pwd)/hook-log-path.sh"
61
+
33
62
  # hook_log_dir / hook_log_file / hook_log — the hook's diagnostic log.
34
63
  #
35
64
  # The PostToolUse hook must never write stderr: the host may block on stderr
@@ -38,10 +67,10 @@
38
67
  # still exits 0. A broken install therefore surfaces on the next explicit audit
39
68
  # (and in this log), never on the edit itself.
40
69
  hook_log_dir() {
41
- printf '%s' "${XDG_CACHE_HOME:-$HOME/.cache}/code-auditor/logs"
70
+ printf '%s' "${XDG_CACHE_HOME:-$HOME/.cache}/${HOOK_LOG_DIR_TAIL}"
42
71
  }
43
72
  hook_log_file() {
44
- printf '%s' "$(hook_log_dir)/hook.log"
73
+ printf '%s' "$(hook_log_dir)/${HOOK_LOG_FILE}"
45
74
  }
46
75
  hook_log() {
47
76
  mkdir -p "$(hook_log_dir)" 2>/dev/null || return 0
@@ -55,7 +84,7 @@ hook_log() {
55
84
  # manifest version. A stale candidate is warned about and skipped, so a mismatched
56
85
  # binary no longer turns the hook into a hard failure.
57
86
  #
58
- # 1. The plugin's bundled CLI (`${CLAUDE_PLUGIN_ROOT}/../dist/cli.js` ships in the
87
+ # 1. The plugin's bundled CLI (`$(plugin_root)/../dist/cli.js` ships in the
59
88
  # same npm package, so it usually matches) — but a marketplace checkout has no
60
89
  # npm-paired dist/, and a locally built one can be stale, so it is
61
90
  # version-checked like everything else.
@@ -66,9 +95,10 @@ hook_log() {
66
95
  # 3. Project-local install (consumer project's own node_modules) — if compatible.
67
96
  # 4. Global install / PATH — if compatible.
68
97
  resolve_code_audit() {
69
- local candidate
70
- if [ -n "${CLAUDE_PLUGIN_ROOT:-}" ] && [ -f "${CLAUDE_PLUGIN_ROOT}/../dist/cli.js" ]; then
71
- candidate="${CLAUDE_PLUGIN_ROOT}/../dist/cli.js"
98
+ local candidate root
99
+ root="$(plugin_root)"
100
+ if [ -f "${root}/../dist/cli.js" ]; then
101
+ candidate="${root}/../dist/cli.js"
72
102
  if cli_is_compatible "${candidate}"; then
73
103
  echo "${candidate}"
74
104
  return
@@ -165,7 +195,7 @@ plugin_version() {
165
195
  return
166
196
  fi
167
197
  __CODE_AUDITOR_PLUGIN_VERSION="$(
168
- node -e "const fs=require('fs');const p=process.env.CLAUDE_PLUGIN_ROOT;for(const f of [p+'/.claude-plugin/plugin.json', p+'/plugin.json']){try{const v=JSON.parse(fs.readFileSync(f,'utf8')).version;if(v){process.stdout.write(v);break}}catch(e){}}" 2>/dev/null
198
+ node -e 'const fs=require("fs");const p=process.argv[1];for(const f of [p+"/.claude-plugin/plugin.json", p+"/plugin.json"]){try{const v=JSON.parse(fs.readFileSync(f,"utf8")).version;if(v){process.stdout.write(v);break}}catch(e){}}' "$(plugin_root)" 2>/dev/null
169
199
  )"
170
200
  __CODE_AUDITOR_PLUGIN_VERSION_RESOLVED=1
171
201
  printf '%s' "${__CODE_AUDITOR_PLUGIN_VERSION}"
@@ -220,7 +250,7 @@ assert_compatible() {
220
250
  # bundled sibling, a project-local install, a global on PATH) are NOT
221
251
  # path-guaranteed — the resolver's `cli_is_compatible` already version-checked
222
252
  # them, and the full check below remains the loud backstop for any of them.
223
- if [ -n "${CLAUDE_PLUGIN_ROOT:-}" ] && [ "${bin}" = "$(pin_dir)/node_modules/.bin/code-audit" ]; then
253
+ if [ "${bin}" = "$(pin_dir)/node_modules/.bin/code-audit" ]; then
224
254
  return 0
225
255
  fi
226
256
  pv="$(plugin_version)"
@@ -18,20 +18,30 @@
18
18
  # single source of truth; the fix is to reinstall (or restore the file).
19
19
  set -uo pipefail
20
20
 
21
- # The hooks.json command already guards an unset CLAUDE_PLUGIN_ROOT, but keep
22
- # this a no-op if it is somehow absent here.
23
- [ -n "${CLAUDE_PLUGIN_ROOT:-}" ] || exit 0
21
+ # Source the shared resolver from this script's own directory — the plugin's
22
+ # scripts/ — never from a host environment variable. plugin_root() self-locates
23
+ # the plugin root, so an unset or wrong CLAUDE_PLUGIN_ROOT is a non-event.
24
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" 2>/dev/null && pwd)"
25
+ . "${SCRIPT_DIR}/hook-common.sh"
26
+
27
+ ROOT="$(plugin_root)"
24
28
 
25
29
  # The manifest ships at .claude-plugin/manifest.json; a few installs flatten the
26
30
  # plugin.json to the plugin root, so check both locations (mirrors
27
31
  # hook-common.sh's plugin_version).
28
32
  manifest=""
29
- for f in "${CLAUDE_PLUGIN_ROOT}/.claude-plugin/manifest.json" "${CLAUDE_PLUGIN_ROOT}/manifest.json"; do
33
+ for f in "${ROOT}/.claude-plugin/manifest.json" "${ROOT}/manifest.json"; do
30
34
  if [ -f "$f" ]; then manifest="$f"; break; fi
31
35
  done
32
- [ -n "${manifest}" ] || exit 0
36
+ if [ -z "${manifest}" ]; then
37
+ # No manifest to compare against is still a completed run — the drift check
38
+ # never exits non-zero, so write the success record that resolves a prior
39
+ # HOOK NOT RUNNING condition before the no-op exit.
40
+ hook_log "[code-auditor] HOOK RAN"
41
+ exit 0
42
+ fi
33
43
 
34
- MANIFEST_PATH="${manifest}" PLUGIN_ROOT="${CLAUDE_PLUGIN_ROOT}" node <<'NODE'
44
+ MANIFEST_PATH="${manifest}" PLUGIN_ROOT="${ROOT}" node <<'NODE'
35
45
  const fs = require('fs');
36
46
  const crypto = require('crypto');
37
47
  const path = require('path');
@@ -69,4 +79,7 @@ if (problems.length > 0) {
69
79
  }
70
80
  NODE
71
81
 
82
+ # A completed run (drift found or not) resolves a prior HOOK NOT RUNNING
83
+ # condition — the drift check never exits non-zero.
84
+ hook_log "[code-auditor] HOOK RAN"
72
85
  exit 0
@@ -0,0 +1,7 @@
1
+ # @generated — do not edit. Written by `scripts/write-hook-log-path.mjs`.
2
+ #
3
+ # Single source of truth for the hook-log path, shared by the TS reader
4
+ # (src/hookLog.ts) and the bash writer (plugin/scripts/hook-common.sh).
5
+ # Regenerate with `npm run build:hooklog`.
6
+ HOOK_LOG_DIR_TAIL='code-auditor/logs'
7
+ HOOK_LOG_FILE='hook.log'
@@ -20,8 +20,11 @@
20
20
  # the log file, not stderr, and still exits 0 (Spec 68 §hook-contract).
21
21
  set -euo pipefail
22
22
 
23
- # Shared resolver + compatibility pinning (see hook-common.sh).
24
- . "${CLAUDE_PLUGIN_ROOT}/scripts/hook-common.sh"
23
+ # Shared resolver + compatibility pinning (see hook-common.sh). Source it from
24
+ # this script's own directory — the plugin's scripts/ — never from a host
25
+ # environment variable.
26
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" 2>/dev/null && pwd)"
27
+ . "${SCRIPT_DIR}/hook-common.sh"
25
28
 
26
29
  # Read event JSON from stdin
27
30
  event="$(cat)"
@@ -89,6 +92,15 @@ fi
89
92
  exit_code=$?
90
93
  set -e
91
94
 
95
+ # A completed run — clean (0) or finding (2) — is the positive "the hook is
96
+ # alive" signal, mirroring hook-audit.sh. Write it so the reader (src/hookLog.ts)
97
+ # can clear a prior HOOK NOT RUNNING condition: the reader resolves by
98
+ # newest-record order, and without this line a recovered hook would leave the
99
+ # stale condition live forever.
100
+ if [ "${exit_code}" -eq 0 ] || [ "${exit_code}" -eq 2 ]; then
101
+ hook_log "[code-auditor] HOOK RAN"
102
+ fi
103
+
92
104
  # Exit 2 = a blocking self-audit finding; propagate so Claude Code feeds it back.
93
105
  if [ ${exit_code} -eq 2 ]; then
94
106
  exit 2
@@ -17,28 +17,33 @@
17
17
  # at all — a warm session must not re-check on every launch.
18
18
  set -uo pipefail
19
19
 
20
- # Belt-and-suspenders: the hooks.json command already guards an unset
21
- # CLAUDE_PLUGIN_ROOT, but keep the warm a no-op if it is somehow absent here.
22
- [ -n "${CLAUDE_PLUGIN_ROOT:-}" ] || exit 0
23
-
24
- # Shared version lookup (plugin_version / semver_of / pin_dir).
25
- . "${CLAUDE_PLUGIN_ROOT}/scripts/hook-common.sh"
20
+ # Source the shared resolver from this script's own directory — the plugin's
21
+ # scripts/ — never from a host environment variable. plugin_root() self-locates
22
+ # the plugin root, so an unset or wrong CLAUDE_PLUGIN_ROOT is a non-event.
23
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" 2>/dev/null && pwd)"
24
+ . "${SCRIPT_DIR}/hook-common.sh"
26
25
 
27
26
  # Nothing safe to warm if the manifest version can't be read: warming @latest
28
27
  # could pin a different version than resolve_code_audit's fallback would fetch.
29
28
  pv="$(plugin_version)"
30
- [ -n "${pv}" ] || exit 0
31
29
 
32
- dir="$(pin_dir)"
33
- bin="${dir}/node_modules/.bin/code-audit"
30
+ if [ -n "${pv}" ]; then
31
+ dir="$(pin_dir)"
32
+ bin="${dir}/node_modules/.bin/code-audit"
34
33
 
35
- # Already installed — nothing to warm. Re-running npm install here would re-check
36
- # the registry on every session, which is exactly the cost this hook exists to avoid.
37
- [ -x "${bin}" ] && exit 0
34
+ # Already installed — nothing to warm. Re-running npm install here would re-check
35
+ # the registry on every session, which is exactly the cost this hook exists to avoid.
36
+ if [ ! -x "${bin}" ]; then
37
+ # Background the exact install the hook's last-resort path runs. Output to
38
+ # /dev/null (silent), stdin from /dev/null (don't hold the hook's stdin open),
39
+ # nohup so the install survives this hook's exit.
40
+ nohup npm install --prefer-offline --prefix "${dir}" "code-auditor-mcp@${pv}" \
41
+ --no-audit --no-fund --ignore-scripts --silent >/dev/null 2>&1 </dev/null &
42
+ fi
43
+ fi
38
44
 
39
- # Background the exact install the hook's last-resort path runs. Output to
40
- # /dev/null (silent), stdin from /dev/null (don't hold the hook's stdin open),
41
- # nohup so the install survives this hook's exit.
42
- nohup npm install --prefer-offline --prefix "${dir}" "code-auditor-mcp@${pv}" \
43
- --no-audit --no-fund --ignore-scripts --silent >/dev/null 2>&1 </dev/null &
45
+ # A completed run — the warm hook never exits non-zero, so every path through it
46
+ # is a success — writes the positive record that resolves a prior HOOK NOT RUNNING
47
+ # condition (CLAUDE_PLUGIN_ROOT unset) in the reader (src/hookLog.ts).
48
+ hook_log "[code-auditor] HOOK RAN"
44
49
  exit 0