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,311 +0,0 @@
1
- package analyzer
2
-
3
- import (
4
- "go/ast"
5
- "strings"
6
- )
7
-
8
- // SOLIDAnalyzer analyzes Go code for SOLID principle violations
9
- type SOLIDAnalyzer struct {
10
- parser *Parser
11
- functions []Function
12
- structs []Struct
13
- interfaces []Interface
14
- }
15
-
16
- // NewSOLIDAnalyzer creates a new SOLID analyzer
17
- func NewSOLIDAnalyzer(parser *Parser) *SOLIDAnalyzer {
18
- return &SOLIDAnalyzer{
19
- parser: parser,
20
- functions: parser.ExtractFunctions(),
21
- structs: parser.ExtractStructs(),
22
- interfaces: parser.ExtractInterfaces(),
23
- }
24
- }
25
-
26
- // Analyze performs SOLID principle analysis
27
- func (s *SOLIDAnalyzer) Analyze() []Violation {
28
- var violations []Violation
29
-
30
- // Analyze function/struct size (was the single-responsibility proxy)
31
- violations = append(violations, s.analyzeFunctionSize()...)
32
- violations = append(violations, s.analyzeStructSize()...)
33
-
34
- // Analyze switch/type-switch size
35
- violations = append(violations, s.analyzeSwitchSize()...)
36
-
37
- // Analyze Liskov Substitution Principle
38
- violations = append(violations, s.analyzeLSP()...)
39
-
40
- // Analyze Interface Segregation Principle
41
- violations = append(violations, s.analyzeISP()...)
42
-
43
- return violations
44
- }
45
-
46
- // analyzeFunctionSize analyzes function *size* (`function-size`).
47
- //
48
- // Spec-49: the old `single-responsibility` category claimed the Single
49
- // Responsibility Principle from a composite of three size signals — complexity,
50
- // return count, and parameter count. "Responsibility" is semantic; the
51
- // syntax-only go/parser has no cohesion analysis, so the SRP reading is blocked
52
- // (see the ledger). What remains is the size signal under an honest name: a
53
- // function with high complexity AND multiple returns AND many parameters is
54
- // large in every dimension.
55
- func (s *SOLIDAnalyzer) analyzeFunctionSize() []Violation {
56
- var violations []Violation
57
-
58
- for _, function := range s.functions {
59
- returns := strings.Split(function.ReturnType, ",")
60
- // 2026-09-12 recalibration: complexity ceiling aligned to the 20-cyclomatic
61
- // threshold, params aligned to the TS `parameter-count` default of 6. The
62
- // rule is AND-combined (complexity + returns + params) so it stays conservative.
63
- complex := function.Complexity > 20
64
- multiReturn := len(returns) > 2
65
- manyParams := len(function.Parameters) > 6
66
- if complex && multiReturn && manyParams {
67
- violations = append(violations, Violation{
68
- File: function.File,
69
- Line: function.StartLine,
70
- Severity: "high",
71
- Message: "Function has many parameters, multiple returns, and high complexity",
72
- Details: map[string]interface{}{
73
- "function": function.Name,
74
- "complexity": function.Complexity,
75
- "parameters": len(function.Parameters),
76
- "returns": len(returns),
77
- },
78
- Suggestion: "Consider breaking this function into smaller, more focused functions",
79
- Analyzer: "solid",
80
- Rule: "function-size",
81
- })
82
- }
83
- }
84
-
85
- return violations
86
- }
87
-
88
- // analyzeStructSize analyzes struct *size* (`struct-size`).
89
- //
90
- // Spec-49: the old `single-responsibility` struct variant claimed SRP from a
91
- // composite of field count and a `mixedTypes` substring heuristic. Two defects:
92
- // the composite score could never exceed 4 (the fire threshold was 5), so the
93
- // rule was dead code; and `strings.Contains(field.Type, "int")` false-matched
94
- // `*Point` (a pointer whose type name merely contains "int"). The SRP reading is
95
- // blocked; the honest size reading is a direct field count.
96
- func (s *SOLIDAnalyzer) analyzeStructSize() []Violation {
97
- var violations []Violation
98
-
99
- for _, structInfo := range s.structs {
100
- // 2026-09-12 recalibration: 10 flags ordinary config/model structs; 15 is a god-struct.
101
- if len(structInfo.Fields) > 15 {
102
- violations = append(violations, Violation{
103
- File: structInfo.File,
104
- Line: structInfo.StartLine,
105
- Severity: "high",
106
- Message: "Struct has many fields",
107
- Details: map[string]interface{}{
108
- "struct": structInfo.Name,
109
- "fieldCount": len(structInfo.Fields),
110
- },
111
- Suggestion: "Consider splitting this struct into smaller, more focused structs",
112
- Analyzer: "solid",
113
- Rule: "struct-size",
114
- })
115
- }
116
- }
117
-
118
- return violations
119
- }
120
-
121
- // analyzeSwitchSize analyzes switch/type-switch *size* (`switch-size`).
122
- //
123
- // Spec-49: the old `open-closed` category claimed to detect the Open/Closed
124
- // Principle from a raw case count. Case count is a size reading, not an OCP
125
- // reading — whether a switch is "closed to extension" depends on whether it
126
- // dispatches over a stable enum vs an extensible type, which the syntax-only
127
- // go/parser cannot resolve. The honest OCP computation is blocked (needs type
128
- // resolution); what remains is the size signal under an honest name.
129
- func (s *SOLIDAnalyzer) analyzeSwitchSize() []Violation {
130
- var violations []Violation
131
-
132
- // Check for large switch/type-switch statements (a size reading only).
133
- for filePath, file := range s.parser.files {
134
- ast.Inspect(file, func(n ast.Node) bool {
135
- switch node := n.(type) {
136
- case *ast.SwitchStmt:
137
- caseCount := s.countSwitchCases(node)
138
- // 2026-09-12 recalibration: 5 flags idiomatic dispatch (HTTP status /
139
- // command maps); 8 suggests table-driven lookup.
140
- if caseCount > 8 {
141
- pos := s.parser.fileSet.Position(node.Pos())
142
- violations = append(violations, Violation{
143
- File: filePath,
144
- Line: pos.Line,
145
- Severity: "high",
146
- Message: "Switch statement has many case clauses",
147
- Details: map[string]interface{}{
148
- "caseCount": caseCount,
149
- "kind": "switch",
150
- },
151
- Suggestion: "Consider consolidating related cases or a table-driven lookup if the switch grows unwieldy",
152
- Analyzer: "solid",
153
- Rule: "switch-size",
154
- })
155
- }
156
- case *ast.TypeSwitchStmt:
157
- caseCount := s.countTypeSwitchCases(node)
158
- if caseCount > 8 {
159
- pos := s.parser.fileSet.Position(node.Pos())
160
- violations = append(violations, Violation{
161
- File: filePath,
162
- Line: pos.Line,
163
- Severity: "high",
164
- Message: "Type switch has many case clauses",
165
- Details: map[string]interface{}{
166
- "caseCount": caseCount,
167
- "kind": "type-switch",
168
- },
169
- Suggestion: "Consider consolidating related cases; a type switch over a sealed set is maintainable, but an open set grows unwieldy",
170
- Analyzer: "solid",
171
- Rule: "switch-size",
172
- })
173
- }
174
- }
175
- return true
176
- })
177
- }
178
-
179
- return violations
180
- }
181
-
182
- // analyzeLSP analyzes Liskov Substitution Principle violations.
183
- //
184
- // A method that calls panic() breaks substitutability: a caller holding the
185
- // interface (or embedding) has no way to recover from a panic the way it can
186
- // from an error return. The honest, directly-observable signal is "the method
187
- // body contains a panic() call" — we walk the AST for exactly that. We do not
188
- // (yet) resolve whether the method overrides a parent, so the message claims
189
- // only the panic, never the override.
190
- func (s *SOLIDAnalyzer) analyzeLSP() []Violation {
191
- var violations []Violation
192
-
193
- for filePath, file := range s.parser.files {
194
- ast.Inspect(file, func(n ast.Node) bool {
195
- funcDecl, ok := n.(*ast.FuncDecl)
196
- if !ok {
197
- return true
198
- }
199
- // LSP governs methods only — a free function has no supertype to
200
- // violate. Test functions are test entry points, not production API.
201
- if funcDecl.Recv == nil || funcDecl.Body == nil || isTestFunction(funcDecl.Name.Name) {
202
- return true
203
- }
204
- if !methodCallsPanic(funcDecl) {
205
- return true
206
- }
207
- pos := s.parser.fileSet.Position(funcDecl.Pos())
208
- violations = append(violations, Violation{
209
- File: filePath,
210
- Line: pos.Line,
211
- Severity: "severe",
212
- Message: "Method calls panic()",
213
- Details: map[string]interface{}{
214
- "function": funcDecl.Name.Name,
215
- "principle": "LSP",
216
- },
217
- Suggestion: "Return an error instead of panicking so the method stays substitutable",
218
- Analyzer: "solid",
219
- Rule: "liskov-substitution",
220
- })
221
- return true
222
- })
223
- }
224
-
225
- return violations
226
- }
227
-
228
- // analyzeISP analyzes interface *size* (`interface-size`).
229
- //
230
- // Spec-49: the old `interface-segregation` category claimed to detect the
231
- // Interface Segregation Principle ("clients forced to depend on methods they do
232
- // not use") from a raw method count. Method count is a size reading, not a
233
- // segregation reading. The honest ISP computation (client-usage sets — which
234
- // callers use which disjoint subsets of an interface's methods) needs type
235
- // resolution / a call graph, which the syntax-only go/parser has not, so that
236
- // reading is blocked (see the ledger). What remains is the size signal under an
237
- // honest name.
238
- func (s *SOLIDAnalyzer) analyzeISP() []Violation {
239
- var violations []Violation
240
-
241
- for _, interfaceInfo := range s.interfaces {
242
- // 2026-09-12 recalibration: 5 flags idiomatic Reader/Writer-style interfaces;
243
- // 10 is where segregation is warranted.
244
- if len(interfaceInfo.Methods) > 10 {
245
- violations = append(violations, Violation{
246
- File: interfaceInfo.File,
247
- Line: interfaceInfo.StartLine,
248
- Severity: "high",
249
- Message: "Interface has many methods",
250
- Details: map[string]interface{}{
251
- "interface": interfaceInfo.Name,
252
- "methodCount": len(interfaceInfo.Methods),
253
- "principle": "ISP",
254
- },
255
- Suggestion: "Consider splitting this large interface into smaller, more focused interfaces",
256
- Analyzer: "solid",
257
- Rule: "interface-size",
258
- })
259
- }
260
- }
261
-
262
- return violations
263
- }
264
-
265
- // Helper methods for analysis
266
-
267
- func (s *SOLIDAnalyzer) countSwitchCases(switchStmt *ast.SwitchStmt) int {
268
- caseCount := 0
269
- if switchStmt.Body != nil {
270
- for _, stmt := range switchStmt.Body.List {
271
- if _, ok := stmt.(*ast.CaseClause); ok {
272
- caseCount++
273
- }
274
- }
275
- }
276
- return caseCount
277
- }
278
-
279
- func (s *SOLIDAnalyzer) countTypeSwitchCases(typeSwitchStmt *ast.TypeSwitchStmt) int {
280
- caseCount := 0
281
- if typeSwitchStmt.Body != nil {
282
- for _, stmt := range typeSwitchStmt.Body.List {
283
- if _, ok := stmt.(*ast.CaseClause); ok {
284
- caseCount++
285
- }
286
- }
287
- }
288
- return caseCount
289
- }
290
-
291
- // methodCallsPanic reports whether a function body contains a direct panic()
292
- // call. It matches the exact call shape — a call expression whose function is
293
- // the identifier `panic` — so a helper that merely has "panic" in its name or
294
- // a doc comment does not trip it (the near-miss the old name-substring check
295
- // false-positived on).
296
- func methodCallsPanic(funcDecl *ast.FuncDecl) bool {
297
- callsPanic := false
298
- ast.Inspect(funcDecl.Body, func(n ast.Node) bool {
299
- call, ok := n.(*ast.CallExpr)
300
- if !ok {
301
- return true
302
- }
303
- ident, ok := call.Fun.(*ast.Ident)
304
- if ok && ident.Name == "panic" {
305
- callsPanic = true
306
- return false
307
- }
308
- return true
309
- })
310
- return callsPanic
311
- }
@@ -1,25 +0,0 @@
1
- package analyzer
2
-
3
- import "strings"
4
-
5
- // Go test conventions — mirrors languages/testConventions.ts.
6
- //
7
- // `go test` compiles only `*_test.go` files; within them the `testing` package
8
- // recognizes Test/Benchmark/Example/Fuzz-prefixed functions as entry points.
9
- // Test code is not production API: it is exempt from analysis and indexing the
10
- // same way the TypeScript pipeline exempts `.test.`/`.spec.` files. One
11
- // per-language convention, not a hardcoded TS/JS list.
12
-
13
- // isTestFile reports whether filePath is a Go test file (`*_test.go`).
14
- func isTestFile(filePath string) bool {
15
- return strings.HasSuffix(filePath, "_test.go")
16
- }
17
-
18
- // isTestFunction reports whether name is a Go test function
19
- // (Test*/Benchmark*/Example*/Fuzz*).
20
- func isTestFunction(name string) bool {
21
- return strings.HasPrefix(name, "Test") ||
22
- strings.HasPrefix(name, "Benchmark") ||
23
- strings.HasPrefix(name, "Example") ||
24
- strings.HasPrefix(name, "Fuzz")
25
- }
@@ -1,156 +0,0 @@
1
- package analyzer
2
-
3
- // AnalysisOptions represents options for the analysis
4
- type AnalysisOptions struct {
5
- Analyzers []string `json:"analyzers"`
6
- MinSeverity string `json:"minSeverity"`
7
- Timeout int `json:"timeout"`
8
- Language string `json:"language"`
9
- Verbose bool `json:"verbose"`
10
-
11
- // Declared tenant-scoping inputs, resolved on the TypeScript side by
12
- // buildOrgFilterTierSet (Tier 1 explicit orgFilterTables, Tier 2 configured
13
- // schemas, Tier 3 DDL migrations) and handed to this syntax-only subprocess
14
- // so it does not guess tenancy from a hardcoded word list.
15
- OrgFilterTables []string `json:"orgFilterTables"`
16
- KnownTables []string `json:"knownTables"`
17
- OrgFilterColumns []string `json:"orgFilterColumns"`
18
- }
19
-
20
- // AnalysisResult represents the result of code analysis
21
- type AnalysisResult struct {
22
- Violations []Violation `json:"violations"`
23
- IndexEntries []IndexEntry `json:"indexEntries"`
24
- Metrics Metrics `json:"metrics"`
25
- Errors []Error `json:"errors"`
26
- }
27
-
28
- // Violation represents a code quality violation
29
- type Violation struct {
30
- File string `json:"file"`
31
- Line int `json:"line"`
32
- Column int `json:"column"`
33
- Severity string `json:"severity"`
34
- Message string `json:"message"`
35
- Details map[string]interface{} `json:"details,omitempty"`
36
- Snippet string `json:"snippet,omitempty"`
37
- Suggestion string `json:"suggestion,omitempty"`
38
- Analyzer string `json:"analyzer"`
39
- Rule string `json:"rule"`
40
- }
41
-
42
- // IndexEntry represents an entity in the code index
43
- type IndexEntry struct {
44
- ID string `json:"id"`
45
- Name string `json:"name"`
46
- Type string `json:"type"`
47
- Language string `json:"language"`
48
- File string `json:"file"`
49
- Signature string `json:"signature"`
50
- Parameters []Parameter `json:"parameters"`
51
- Purpose string `json:"purpose"`
52
- Context string `json:"context"`
53
- StartLine int `json:"startLine"`
54
- EndLine int `json:"endLine"`
55
- Metadata map[string]interface{} `json:"metadata,omitempty"`
56
- }
57
-
58
- // Parameter represents a function parameter
59
- type Parameter struct {
60
- Name string `json:"name"`
61
- Type string `json:"type"`
62
- Optional bool `json:"optional"`
63
- Language string `json:"language"`
64
- }
65
-
66
- // Metrics represents analysis metrics
67
- type Metrics struct {
68
- FilesAnalyzed int64 `json:"filesAnalyzed"`
69
- ExecutionTime int64 `json:"executionTime"`
70
- }
71
-
72
- // Error represents an analysis error
73
- type Error struct {
74
- Message string `json:"message"`
75
- Type string `json:"type"`
76
- File string `json:"file,omitempty"`
77
- Line int `json:"line,omitempty"`
78
- }
79
-
80
- // EntityInfo represents information about a Go entity
81
- type EntityInfo struct {
82
- Name string
83
- Type string
84
- File string
85
- StartLine int
86
- EndLine int
87
- Signature string
88
- Parameters []Parameter
89
- ReturnType string
90
- Purpose string
91
- Context string
92
- Receiver string // For methods
93
- Package string
94
- }
95
-
96
- // Function represents a Go function
97
- type Function struct {
98
- EntityInfo
99
- IsMethod bool
100
- IsExported bool
101
- Complexity int
102
- Dependencies []string
103
- }
104
-
105
- // Struct represents a Go struct
106
- type Struct struct {
107
- EntityInfo
108
- Fields []Field
109
- Methods []string
110
- IsExported bool
111
- }
112
-
113
- // Interface represents a Go interface
114
- type Interface struct {
115
- EntityInfo
116
- Methods []Method
117
- IsExported bool
118
- }
119
-
120
- // Field represents a struct field
121
- type Field struct {
122
- Name string
123
- Type string
124
- Tag string
125
- IsExported bool
126
- }
127
-
128
- // Method represents an interface method
129
- type Method struct {
130
- Name string
131
- Signature string
132
- Parameters []Parameter
133
- ReturnType string
134
- }
135
-
136
- // SOLIDViolation represents SOLID principle violations specific to Go
137
- type SOLIDViolation struct {
138
- Principle string // SRP, OCP, LSP, ISP, DIP
139
- Entity string
140
- Description string
141
- Suggestion string
142
- Severity string
143
- Examples []string
144
- }
145
-
146
- // Package represents a Go package
147
- type Package struct {
148
- Name string
149
- Path string
150
- Files []string
151
- Imports []string
152
- Exports []string
153
- Functions []Function
154
- Structs []Struct
155
- Interfaces []Interface
156
- }
@@ -1,7 +0,0 @@
1
- module code-auditor-go
2
-
3
- go 1.19
4
-
5
- replace code-auditor-go/analyzer => ./analyzer-src
6
-
7
- require code-auditor-go/analyzer v0.0.0-00010101000000-000000000000
@@ -1,203 +0,0 @@
1
- package main
2
-
3
- import (
4
- "bufio"
5
- "encoding/json"
6
- "fmt"
7
- "io"
8
- "os"
9
- "strings"
10
-
11
- "code-auditor-go/analyzer"
12
- )
13
-
14
- // JSON-RPC request structure
15
- type Request struct {
16
- Method string `json:"method"`
17
- Params interface{} `json:"params"`
18
- ID interface{} `json:"id"`
19
- }
20
-
21
- // JSON-RPC response structure
22
- type Response struct {
23
- Result interface{} `json:"result,omitempty"`
24
- Error *RPCError `json:"error,omitempty"`
25
- ID interface{} `json:"id"`
26
- }
27
-
28
- // RPC error structure
29
- type RPCError struct {
30
- Code int `json:"code"`
31
- Message string `json:"message"`
32
- }
33
-
34
- // Analysis parameters structure
35
- type AnalysisParams struct {
36
- Files []string `json:"files"`
37
- Options analyzer.AnalysisOptions `json:"options"`
38
- }
39
-
40
- // Content analysis parameters structure
41
- type ContentAnalysisParams struct {
42
- File string `json:"file"`
43
- Content string `json:"content"`
44
- Options analyzer.AnalysisOptions `json:"options"`
45
- }
46
-
47
- func main() {
48
- // Log startup to stderr (won't interfere with JSON-RPC on stdout)
49
- fmt.Fprintf(os.Stderr, "[GoAnalyzer] Starting Go analyzer server\n")
50
-
51
- // Create a buffered reader for stdin
52
- reader := bufio.NewReader(os.Stdin)
53
-
54
- for {
55
- // Read a line from stdin
56
- line, err := reader.ReadString('\n')
57
- if err != nil {
58
- if err == io.EOF {
59
- fmt.Fprintf(os.Stderr, "[GoAnalyzer] EOF reached\n")
60
- break
61
- }
62
- fmt.Fprintf(os.Stderr, "[GoAnalyzer] Read error: %v\n", err)
63
- sendError(-1, fmt.Sprintf("Error reading input: %v", err), nil)
64
- continue
65
- }
66
-
67
- line = strings.TrimSpace(line)
68
- fmt.Fprintf(os.Stderr, "[GoAnalyzer] Received: %s\n", line)
69
-
70
- if line == "" {
71
- fmt.Fprintf(os.Stderr, "[GoAnalyzer] Empty line, skipping\n")
72
- continue
73
- }
74
-
75
- // Parse JSON-RPC request
76
- var req Request
77
- if err := json.Unmarshal([]byte(line), &req); err != nil {
78
- fmt.Fprintf(os.Stderr, "[GoAnalyzer] Parse error: %v\n", err)
79
- sendError(-32700, "Parse error", req.ID)
80
- continue
81
- }
82
-
83
- fmt.Fprintf(os.Stderr, "[GoAnalyzer] Handling request: %s\n", req.Method)
84
- // Handle the request
85
- handleRequest(req)
86
- }
87
- fmt.Fprintf(os.Stderr, "[GoAnalyzer] Server shutting down\n")
88
- }
89
-
90
- func handleRequest(req Request) {
91
- switch req.Method {
92
- case "analyze":
93
- handleAnalyze(req)
94
- case "analyzeContent":
95
- handleAnalyzeContent(req)
96
- case "ping":
97
- sendResult("pong", req.ID)
98
- case "version":
99
- sendResult("1.0.0", req.ID)
100
- default:
101
- sendError(-32601, "Method not found", req.ID)
102
- }
103
- }
104
-
105
- func handleAnalyze(req Request) {
106
- // Parse parameters
107
- paramsBytes, err := json.Marshal(req.Params)
108
- if err != nil {
109
- sendError(-32602, "Invalid params", req.ID)
110
- return
111
- }
112
-
113
- var params AnalysisParams
114
- if err := json.Unmarshal(paramsBytes, &params); err != nil {
115
- sendError(-32602, "Invalid params", req.ID)
116
- return
117
- }
118
-
119
- // Filter Go files
120
- var goFiles []string
121
- for _, file := range params.Files {
122
- if strings.HasSuffix(file, ".go") {
123
- goFiles = append(goFiles, file)
124
- }
125
- }
126
-
127
- if len(goFiles) == 0 {
128
- sendError(-32603, "No Go files provided", req.ID)
129
- return
130
- }
131
-
132
- // Create and run analyzer
133
- goAnalyzer := analyzer.NewAnalyzer(params.Options)
134
- result, err := goAnalyzer.Analyze(goFiles)
135
- if err != nil {
136
- sendError(-32603, fmt.Sprintf("Analysis failed: %v", err), req.ID)
137
- return
138
- }
139
-
140
- // Send successful result
141
- sendResult(result, req.ID)
142
- }
143
-
144
- func sendResult(result interface{}, id interface{}) {
145
- response := Response{
146
- Result: result,
147
- ID: id,
148
- }
149
- sendResponse(response)
150
- }
151
-
152
- func sendError(code int, message string, id interface{}) {
153
- response := Response{
154
- Error: &RPCError{
155
- Code: code,
156
- Message: message,
157
- },
158
- ID: id,
159
- }
160
- sendResponse(response)
161
- }
162
-
163
- func sendResponse(response Response) {
164
- data, err := json.Marshal(response)
165
- if err != nil {
166
- fmt.Fprintf(os.Stderr, "Error marshaling response: %v\n", err)
167
- return
168
- }
169
-
170
- fmt.Println(string(data))
171
- }
172
-
173
- func handleAnalyzeContent(req Request) {
174
- // Parse parameters
175
- paramsBytes, err := json.Marshal(req.Params)
176
- if err != nil {
177
- sendError(-32602, "Invalid params", req.ID)
178
- return
179
- }
180
-
181
- var params ContentAnalysisParams
182
- if err := json.Unmarshal(paramsBytes, &params); err != nil {
183
- sendError(-32602, "Invalid params", req.ID)
184
- return
185
- }
186
-
187
- // Validate file extension
188
- if !strings.HasSuffix(params.File, ".go") {
189
- sendError(-32603, "Not a Go file", req.ID)
190
- return
191
- }
192
-
193
- // Create and run analyzer with content
194
- goAnalyzer := analyzer.NewAnalyzer(params.Options)
195
- result, err := goAnalyzer.AnalyzeContent(params.File, params.Content)
196
- if err != nil {
197
- sendError(-32603, fmt.Sprintf("Content analysis failed: %v", err), req.ID)
198
- return
199
- }
200
-
201
- // Send successful result
202
- sendResult(result, req.ID)
203
- }