octocode-cli 1.2.8 → 1.2.9

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 (282) hide show
  1. package/README.md +42 -35
  2. package/out/octocode-cli.js +36 -11767
  3. package/package.json +36 -36
  4. package/skills/README.md +42 -114
  5. package/skills/{octocode-code-engineer → octocode-engineer}/.claude/settings.local.json +2 -1
  6. package/skills/octocode-engineer/README.md +99 -0
  7. package/skills/octocode-engineer/SKILL.md +499 -0
  8. package/skills/octocode-engineer/build.mjs +29 -0
  9. package/skills/{octocode-code-engineer → octocode-engineer}/eslint.config.mjs +3 -13
  10. package/skills/{octocode-code-engineer → octocode-engineer}/package.json +28 -27
  11. package/skills/octocode-engineer/references/ast-reference.md +166 -0
  12. package/skills/{octocode-code-engineer → octocode-engineer}/references/cli-reference.md +80 -6
  13. package/skills/octocode-engineer/references/externals.md +86 -0
  14. package/skills/{octocode-code-engineer → octocode-engineer}/references/output-files.md +46 -6
  15. package/skills/octocode-engineer/references/quality-indicators.md +202 -0
  16. package/skills/octocode-engineer/references/tool-workflows.md +298 -0
  17. package/skills/octocode-engineer/references/validation-playbooks.md +99 -0
  18. package/skills/octocode-engineer/scripts/ast/search.js +45 -0
  19. package/skills/octocode-engineer/scripts/ast/tree-search.js +27 -0
  20. package/skills/octocode-engineer/scripts/index.js +173 -0
  21. package/skills/octocode-engineer/scripts/run.js +179 -0
  22. package/skills/octocode-engineer/src/analysis/dependencies.ts +378 -0
  23. package/skills/{octocode-code-engineer → octocode-engineer}/src/analysis/discovery.test.ts +57 -0
  24. package/skills/{octocode-code-engineer → octocode-engineer}/src/analysis/discovery.ts +43 -0
  25. package/skills/{octocode-code-engineer → octocode-engineer}/src/ast/search.test.ts +113 -0
  26. package/skills/{octocode-code-engineer → octocode-engineer}/src/ast/search.ts +64 -1
  27. package/skills/{octocode-code-engineer → octocode-engineer}/src/ast/tree-sitter.test.ts +118 -2
  28. package/skills/{octocode-code-engineer → octocode-engineer}/src/ast/tree-sitter.ts +65 -3
  29. package/skills/{octocode-code-engineer → octocode-engineer}/src/ast/ts-analyzer.test.ts +281 -1
  30. package/skills/{octocode-code-engineer → octocode-engineer}/src/ast/ts-analyzer.ts +173 -3
  31. package/skills/{octocode-code-engineer → octocode-engineer}/src/collectors/security.test.ts +73 -0
  32. package/skills/{octocode-code-engineer → octocode-engineer}/src/collectors/security.ts +62 -4
  33. package/skills/octocode-engineer/src/detector-gating.test.ts +59 -0
  34. package/skills/{octocode-code-engineer → octocode-engineer}/src/detectors/code-quality.ts +342 -0
  35. package/skills/{octocode-code-engineer → octocode-engineer}/src/detectors/index.ts +8 -0
  36. package/skills/{octocode-code-engineer → octocode-engineer}/src/index.test.ts +565 -11
  37. package/skills/octocode-engineer/src/index.ts +468 -0
  38. package/skills/octocode-engineer/src/pipeline/affected.test.ts +147 -0
  39. package/skills/octocode-engineer/src/pipeline/affected.ts +68 -0
  40. package/skills/octocode-engineer/src/pipeline/baseline.test.ts +276 -0
  41. package/skills/octocode-engineer/src/pipeline/baseline.ts +76 -0
  42. package/skills/{octocode-code-engineer → octocode-engineer}/src/pipeline/cli.test.ts +300 -53
  43. package/skills/{octocode-code-engineer → octocode-engineer}/src/pipeline/cli.ts +180 -36
  44. package/skills/octocode-engineer/src/pipeline/config-loader.test.ts +264 -0
  45. package/skills/octocode-engineer/src/pipeline/config-loader.ts +109 -0
  46. package/skills/octocode-engineer/src/pipeline/create-options.ts +55 -0
  47. package/skills/octocode-engineer/src/pipeline/health-score.test.ts +65 -0
  48. package/skills/{octocode-code-engineer → octocode-engineer}/src/pipeline/main.ts +130 -17
  49. package/skills/octocode-engineer/src/pipeline/progress.ts +51 -0
  50. package/skills/octocode-engineer/src/pipeline/reporters.test.ts +155 -0
  51. package/skills/octocode-engineer/src/pipeline/reporters.ts +64 -0
  52. package/skills/octocode-engineer/src/reporting/graph-features.test.ts +279 -0
  53. package/skills/{octocode-code-engineer → octocode-engineer}/src/reporting/output-contract.test.ts +6 -0
  54. package/skills/octocode-engineer/src/reporting/summary-md.test.ts +1066 -0
  55. package/skills/octocode-engineer/src/reporting/summary-md.ts +1604 -0
  56. package/skills/{octocode-code-engineer → octocode-engineer}/src/reporting/writer.ts +136 -13
  57. package/skills/octocode-engineer/src/run.ts +78 -0
  58. package/skills/{octocode-code-engineer → octocode-engineer}/src/sanity.test.ts +1 -1
  59. package/skills/octocode-engineer/src/types/analysis.ts +25 -0
  60. package/skills/octocode-engineer/src/types/collectors.ts +134 -0
  61. package/skills/{octocode-code-engineer → octocode-engineer}/src/types/constants.ts +75 -41
  62. package/skills/octocode-engineer/src/types/core.ts +203 -0
  63. package/skills/octocode-engineer/src/types/dependency.ts +215 -0
  64. package/skills/octocode-engineer/src/types/file-entry.ts +108 -0
  65. package/skills/octocode-engineer/src/types/findings.ts +105 -0
  66. package/skills/{octocode-code-engineer → octocode-engineer}/src/types/index.ts +60 -30
  67. package/skills/octocode-engineer/src/types/tree-sitter.ts +38 -0
  68. package/skills/{octocode-code-engineer → octocode-engineer}/tsconfig.json +1 -0
  69. package/skills/octocode-research/.octocode/scan/.cache/analysis-cache.json +1 -0
  70. package/skills/octocode-research/.octocode/scan/2026-03-22T10-32-27-073Z/architecture.json +1 -0
  71. package/skills/octocode-research/.octocode/scan/2026-03-22T10-32-27-073Z/ast-trees.txt +5566 -0
  72. package/skills/octocode-research/.octocode/scan/2026-03-22T10-32-27-073Z/code-quality.json +1 -0
  73. package/skills/octocode-research/.octocode/scan/2026-03-22T10-32-27-073Z/dead-code.json +1 -0
  74. package/skills/octocode-research/.octocode/scan/2026-03-22T10-32-27-073Z/file-inventory.json +1 -0
  75. package/skills/octocode-research/.octocode/scan/2026-03-22T10-32-27-073Z/findings.json +1 -0
  76. package/skills/octocode-research/.octocode/scan/2026-03-22T10-32-27-073Z/graph.md +189 -0
  77. package/skills/octocode-research/.octocode/scan/2026-03-22T10-32-27-073Z/security.json +1 -0
  78. package/skills/octocode-research/.octocode/scan/2026-03-22T10-32-27-073Z/summary.json +1 -0
  79. package/skills/octocode-research/.octocode/scan/2026-03-22T10-32-27-073Z/summary.md +265 -0
  80. package/skills/octocode-research/.octocode/scan/2026-03-22T10-40-10-469Z/architecture.json +1 -0
  81. package/skills/octocode-research/.octocode/scan/2026-03-22T10-40-10-469Z/ast-trees.txt +5555 -0
  82. package/skills/octocode-research/.octocode/scan/2026-03-22T10-40-10-469Z/code-quality.json +1 -0
  83. package/skills/octocode-research/.octocode/scan/2026-03-22T10-40-10-469Z/dead-code.json +1 -0
  84. package/skills/octocode-research/.octocode/scan/2026-03-22T10-40-10-469Z/file-inventory.json +1 -0
  85. package/skills/octocode-research/.octocode/scan/2026-03-22T10-40-10-469Z/findings.json +1 -0
  86. package/skills/octocode-research/.octocode/scan/2026-03-22T10-40-10-469Z/graph.md +190 -0
  87. package/skills/octocode-research/.octocode/scan/2026-03-22T10-40-10-469Z/security.json +1 -0
  88. package/skills/octocode-research/.octocode/scan/2026-03-22T10-40-10-469Z/summary.json +1 -0
  89. package/skills/octocode-research/.octocode/scan/2026-03-22T10-40-10-469Z/summary.md +265 -0
  90. package/skills/octocode-research/CHANGELOG.md +60 -0
  91. package/skills/octocode-research/README.md +102 -388
  92. package/skills/octocode-research/SKILL.md +169 -498
  93. package/skills/octocode-research/package.json +19 -31
  94. package/skills/octocode-research/references/PARALLEL_AGENT_PROTOCOL.md +19 -0
  95. package/skills/octocode-research/references/SESSION_MANAGEMENT.md +38 -0
  96. package/skills/octocode-research/scripts/server-init.js +1 -1
  97. package/skills/octocode-research/scripts/server.d.ts +2 -1
  98. package/skills/octocode-research/scripts/server.js +329 -233
  99. package/skills/octocode-research/src/__tests__/integration/promptsRoutes.test.ts +180 -0
  100. package/skills/octocode-research/src/__tests__/integration/serverHttp.test.ts +221 -0
  101. package/skills/octocode-research/src/__tests__/integration/serverLifecycle.test.ts +194 -0
  102. package/skills/octocode-research/src/__tests__/integration/toolsRoutes.test.ts +501 -0
  103. package/skills/octocode-research/src/__tests__/unit/readiness.test.ts +61 -0
  104. package/skills/octocode-research/src/__tests__/unit/resilience.test.ts +192 -0
  105. package/skills/octocode-research/src/__tests__/unit/responseFactory.test.ts +172 -0
  106. package/skills/octocode-research/src/__tests__/unit/responseParser.test.ts +288 -0
  107. package/skills/octocode-research/src/__tests__/unit/schemas.test.ts +509 -0
  108. package/skills/octocode-research/src/index.ts +4 -124
  109. package/skills/octocode-research/src/middleware/queryParser.ts +0 -26
  110. package/skills/octocode-research/src/routes/lsp.ts +58 -59
  111. package/skills/octocode-research/src/routes/package.ts +35 -65
  112. package/skills/octocode-research/src/routes/prompts.ts +3 -3
  113. package/skills/octocode-research/src/routes/tools.ts +8 -20
  114. package/skills/octocode-research/src/server-init.ts +30 -237
  115. package/skills/octocode-research/src/server.ts +50 -23
  116. package/skills/octocode-research/src/types/errorGuards.ts +9 -80
  117. package/skills/octocode-research/src/types/guards.ts +0 -28
  118. package/skills/octocode-research/src/types/mcp.ts +11 -66
  119. package/skills/octocode-research/src/types/responses.ts +11 -129
  120. package/skills/octocode-research/src/utils/circuitBreaker.ts +0 -21
  121. package/skills/octocode-research/src/utils/logger.ts +1 -97
  122. package/skills/octocode-research/src/utils/resilience.ts +2 -12
  123. package/skills/octocode-research/src/utils/responseFactory.ts +0 -42
  124. package/skills/octocode-research/src/utils/responseParser.ts +3 -25
  125. package/skills/octocode-research/src/utils/retry.ts +0 -63
  126. package/skills/octocode-research/src/utils/routeFactory.ts +1 -1
  127. package/skills/octocode-research/src/validation/httpPreprocess.ts +0 -3
  128. package/skills/octocode-research/src/validation/index.ts +0 -1
  129. package/skills/octocode-research/src/validation/schemas.ts +0 -63
  130. package/skills/octocode-research/src/validation/toolCallSchema.ts +3 -3
  131. package/skills/octocode-research/tsdown.config.ts +4 -0
  132. package/skills/octocode-research/vitest.config.ts +3 -0
  133. package/skills/octocode-code-engineer/.plan/VALIDATED_PLAN.md +0 -223
  134. package/skills/octocode-code-engineer/README.md +0 -178
  135. package/skills/octocode-code-engineer/SKILL.md +0 -418
  136. package/skills/octocode-code-engineer/minify-scripts.mjs +0 -32
  137. package/skills/octocode-code-engineer/references/agent-ast-reading-rfc.md +0 -95
  138. package/skills/octocode-code-engineer/references/architecture-techniques.md +0 -121
  139. package/skills/octocode-code-engineer/references/ast-search.md +0 -210
  140. package/skills/octocode-code-engineer/references/ast-tree-search.md +0 -151
  141. package/skills/octocode-code-engineer/references/concepts.md +0 -107
  142. package/skills/octocode-code-engineer/references/finding-categories.md +0 -128
  143. package/skills/octocode-code-engineer/references/improvement-roadmap.md +0 -304
  144. package/skills/octocode-code-engineer/references/playbooks.md +0 -204
  145. package/skills/octocode-code-engineer/references/present-results.md +0 -136
  146. package/skills/octocode-code-engineer/references/tool-workflows.md +0 -566
  147. package/skills/octocode-code-engineer/references/validate-investigate.md +0 -225
  148. package/skills/octocode-code-engineer/scripts/analysis/dependencies.js +0 -1
  149. package/skills/octocode-code-engineer/scripts/analysis/dependency-summary.js +0 -1
  150. package/skills/octocode-code-engineer/scripts/analysis/discovery.js +0 -1
  151. package/skills/octocode-code-engineer/scripts/analysis/graph-analytics.js +0 -1
  152. package/skills/octocode-code-engineer/scripts/analysis/semantic.js +0 -1
  153. package/skills/octocode-code-engineer/scripts/ast/helpers.js +0 -1
  154. package/skills/octocode-code-engineer/scripts/ast/metrics.js +0 -1
  155. package/skills/octocode-code-engineer/scripts/ast/search.js +0 -2
  156. package/skills/octocode-code-engineer/scripts/ast/tree-search.js +0 -2
  157. package/skills/octocode-code-engineer/scripts/ast/tree-sitter.js +0 -1
  158. package/skills/octocode-code-engineer/scripts/ast/ts-analyzer.js +0 -1
  159. package/skills/octocode-code-engineer/scripts/collectors/chains.js +0 -1
  160. package/skills/octocode-code-engineer/scripts/collectors/effects.js +0 -1
  161. package/skills/octocode-code-engineer/scripts/collectors/input-sources.js +0 -1
  162. package/skills/octocode-code-engineer/scripts/collectors/performance.js +0 -1
  163. package/skills/octocode-code-engineer/scripts/collectors/prototype-pollution.js +0 -1
  164. package/skills/octocode-code-engineer/scripts/collectors/security.js +0 -1
  165. package/skills/octocode-code-engineer/scripts/collectors/test-profile.js +0 -1
  166. package/skills/octocode-code-engineer/scripts/common/is-direct-run.js +0 -1
  167. package/skills/octocode-code-engineer/scripts/common/utils.js +0 -1
  168. package/skills/octocode-code-engineer/scripts/detectors/code-quality.js +0 -1
  169. package/skills/octocode-code-engineer/scripts/detectors/cohesion.js +0 -1
  170. package/skills/octocode-code-engineer/scripts/detectors/coupling.js +0 -1
  171. package/skills/octocode-code-engineer/scripts/detectors/cycle.js +0 -1
  172. package/skills/octocode-code-engineer/scripts/detectors/dead-code.js +0 -1
  173. package/skills/octocode-code-engineer/scripts/detectors/import-style.js +0 -1
  174. package/skills/octocode-code-engineer/scripts/detectors/index.js +0 -1
  175. package/skills/octocode-code-engineer/scripts/detectors/security.js +0 -1
  176. package/skills/octocode-code-engineer/scripts/detectors/semantic.js +0 -1
  177. package/skills/octocode-code-engineer/scripts/detectors/shared.js +0 -1
  178. package/skills/octocode-code-engineer/scripts/detectors/test-quality.js +0 -1
  179. package/skills/octocode-code-engineer/scripts/index.js +0 -1
  180. package/skills/octocode-code-engineer/scripts/pipeline/cache.js +0 -1
  181. package/skills/octocode-code-engineer/scripts/pipeline/cli.js +0 -1
  182. package/skills/octocode-code-engineer/scripts/pipeline/main.js +0 -2
  183. package/skills/octocode-code-engineer/scripts/reporting/analysis.js +0 -1
  184. package/skills/octocode-code-engineer/scripts/reporting/summary-md.js +0 -1
  185. package/skills/octocode-code-engineer/scripts/reporting/writer.js +0 -1
  186. package/skills/octocode-code-engineer/scripts/types/constants.js +0 -1
  187. package/skills/octocode-code-engineer/scripts/types/index.js +0 -1
  188. package/skills/octocode-code-engineer/scripts/types/interfaces.js +0 -1
  189. package/skills/octocode-code-engineer/src/analysis/dependencies.ts +0 -406
  190. package/skills/octocode-code-engineer/src/index.ts +0 -403
  191. package/skills/octocode-code-engineer/src/reporting/summary-md.test.ts +0 -421
  192. package/skills/octocode-code-engineer/src/reporting/summary-md.ts +0 -714
  193. package/skills/octocode-code-engineer/src/types/interfaces.ts +0 -682
  194. package/skills/octocode-research/src/types/toolTypes.ts +0 -33
  195. package/skills/octocode-research/src/utils/logEmoji.ts +0 -103
  196. /package/skills/{octocode-code-engineer → octocode-engineer}/.octocode/rfc/RFC-code-engineer-weakness-fixes.md +0 -0
  197. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/architecture.ts.html +0 -0
  198. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/ast-helpers.ts.html +0 -0
  199. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/ast-search.ts.html +0 -0
  200. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/base.css +0 -0
  201. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/block-navigation.js +0 -0
  202. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/cache.ts.html +0 -0
  203. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/cli.ts.html +0 -0
  204. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/clover.xml +0 -0
  205. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/collect-effects.ts.html +0 -0
  206. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/collect-input-sources.ts.html +0 -0
  207. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/collect-performance.ts.html +0 -0
  208. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/collect-prototype-pollution.ts.html +0 -0
  209. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/collect-security.ts.html +0 -0
  210. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/collect-test-profile.ts.html +0 -0
  211. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/coverage-final.json +0 -0
  212. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/dependencies.ts.html +0 -0
  213. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/dependency-summary.ts.html +0 -0
  214. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/discovery.ts.html +0 -0
  215. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/favicon.png +0 -0
  216. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/graph-analytics.ts.html +0 -0
  217. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/index.html +0 -0
  218. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/index.ts.html +0 -0
  219. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/metrics.ts.html +0 -0
  220. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/pipeline.ts.html +0 -0
  221. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/prettify.css +0 -0
  222. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/prettify.js +0 -0
  223. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/report-analysis.ts.html +0 -0
  224. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/report-writer.ts.html +0 -0
  225. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/security-detectors.ts.html +0 -0
  226. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/semantic-detectors.ts.html +0 -0
  227. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/semantic.ts.html +0 -0
  228. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/sort-arrow-sprite.png +0 -0
  229. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/sorter.js +0 -0
  230. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/summary-md.ts.html +0 -0
  231. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/test-quality-detectors.ts.html +0 -0
  232. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/tree-sitter-analyzer.ts.html +0 -0
  233. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/ts-analyzer.ts.html +0 -0
  234. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/types.ts.html +0 -0
  235. /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/utils.ts.html +0 -0
  236. /package/skills/{octocode-code-engineer → octocode-engineer}/src/analysis/dependencies.test.ts +0 -0
  237. /package/skills/{octocode-code-engineer → octocode-engineer}/src/analysis/dependency-summary.test.ts +0 -0
  238. /package/skills/{octocode-code-engineer → octocode-engineer}/src/analysis/dependency-summary.ts +0 -0
  239. /package/skills/{octocode-code-engineer → octocode-engineer}/src/analysis/graph-analytics.test.ts +0 -0
  240. /package/skills/{octocode-code-engineer → octocode-engineer}/src/analysis/graph-analytics.ts +0 -0
  241. /package/skills/{octocode-code-engineer → octocode-engineer}/src/analysis/semantic.test.ts +0 -0
  242. /package/skills/{octocode-code-engineer → octocode-engineer}/src/analysis/semantic.ts +0 -0
  243. /package/skills/{octocode-code-engineer → octocode-engineer}/src/ast/helpers.test.ts +0 -0
  244. /package/skills/{octocode-code-engineer → octocode-engineer}/src/ast/helpers.ts +0 -0
  245. /package/skills/{octocode-code-engineer → octocode-engineer}/src/ast/metrics.test.ts +0 -0
  246. /package/skills/{octocode-code-engineer → octocode-engineer}/src/ast/metrics.ts +0 -0
  247. /package/skills/{octocode-code-engineer → octocode-engineer}/src/ast/tree-search.test.ts +0 -0
  248. /package/skills/{octocode-code-engineer → octocode-engineer}/src/ast/tree-search.ts +0 -0
  249. /package/skills/{octocode-code-engineer → octocode-engineer}/src/collectors/chains.ts +0 -0
  250. /package/skills/{octocode-code-engineer → octocode-engineer}/src/collectors/effects.test.ts +0 -0
  251. /package/skills/{octocode-code-engineer → octocode-engineer}/src/collectors/effects.ts +0 -0
  252. /package/skills/{octocode-code-engineer → octocode-engineer}/src/collectors/input-sources.test.ts +0 -0
  253. /package/skills/{octocode-code-engineer → octocode-engineer}/src/collectors/input-sources.ts +0 -0
  254. /package/skills/{octocode-code-engineer → octocode-engineer}/src/collectors/performance.test.ts +0 -0
  255. /package/skills/{octocode-code-engineer → octocode-engineer}/src/collectors/performance.ts +0 -0
  256. /package/skills/{octocode-code-engineer → octocode-engineer}/src/collectors/prototype-pollution.test.ts +0 -0
  257. /package/skills/{octocode-code-engineer → octocode-engineer}/src/collectors/prototype-pollution.ts +0 -0
  258. /package/skills/{octocode-code-engineer → octocode-engineer}/src/collectors/test-profile.test.ts +0 -0
  259. /package/skills/{octocode-code-engineer → octocode-engineer}/src/collectors/test-profile.ts +0 -0
  260. /package/skills/{octocode-code-engineer → octocode-engineer}/src/common/is-direct-run.test.ts +0 -0
  261. /package/skills/{octocode-code-engineer → octocode-engineer}/src/common/is-direct-run.ts +0 -0
  262. /package/skills/{octocode-code-engineer → octocode-engineer}/src/common/utils.test.ts +0 -0
  263. /package/skills/{octocode-code-engineer → octocode-engineer}/src/common/utils.ts +0 -0
  264. /package/skills/{octocode-code-engineer → octocode-engineer}/src/detectors/cohesion.ts +0 -0
  265. /package/skills/{octocode-code-engineer → octocode-engineer}/src/detectors/coupling.ts +0 -0
  266. /package/skills/{octocode-code-engineer → octocode-engineer}/src/detectors/cycle.ts +0 -0
  267. /package/skills/{octocode-code-engineer → octocode-engineer}/src/detectors/dead-code.ts +0 -0
  268. /package/skills/{octocode-code-engineer → octocode-engineer}/src/detectors/import-style.ts +0 -0
  269. /package/skills/{octocode-code-engineer → octocode-engineer}/src/detectors/index.test.ts +0 -0
  270. /package/skills/{octocode-code-engineer → octocode-engineer}/src/detectors/security.test.ts +0 -0
  271. /package/skills/{octocode-code-engineer → octocode-engineer}/src/detectors/security.ts +0 -0
  272. /package/skills/{octocode-code-engineer → octocode-engineer}/src/detectors/semantic.ts +0 -0
  273. /package/skills/{octocode-code-engineer → octocode-engineer}/src/detectors/shared.ts +0 -0
  274. /package/skills/{octocode-code-engineer → octocode-engineer}/src/detectors/test-quality.test.ts +0 -0
  275. /package/skills/{octocode-code-engineer → octocode-engineer}/src/detectors/test-quality.ts +0 -0
  276. /package/skills/{octocode-code-engineer → octocode-engineer}/src/pipeline/cache.test.ts +0 -0
  277. /package/skills/{octocode-code-engineer → octocode-engineer}/src/pipeline/cache.ts +0 -0
  278. /package/skills/{octocode-code-engineer → octocode-engineer}/src/pipeline/main.test.ts +0 -0
  279. /package/skills/{octocode-code-engineer → octocode-engineer}/src/pipeline.test.ts +0 -0
  280. /package/skills/{octocode-code-engineer → octocode-engineer}/src/reporting/analysis.test.ts +0 -0
  281. /package/skills/{octocode-code-engineer → octocode-engineer}/src/reporting/analysis.ts +0 -0
  282. /package/skills/{octocode-code-engineer → octocode-engineer}/vitest.config.ts +0 -0
@@ -0,0 +1,202 @@
1
+ # Quality Indicators Reference
2
+
3
+ > Complete catalog of code quality signals detected by the octocode-engineer scanner.
4
+
5
+ ## Overview
6
+
7
+ The scanner detects quality indicators across 5 pillars: **Architecture**, **Code Quality**, **Dead Code**, **Security**, and **Test Quality**. Each indicator produces a finding with severity (critical/high/medium/low/info), actionable fix guidance, and LSP validation hints.
8
+
9
+ ---
10
+
11
+ ## Metrics Engine
12
+
13
+ ### Cyclomatic Complexity
14
+ - **What**: Number of independent paths through a function's source code.
15
+ - **How**: Increments for `if`, `while`, `for`, `switch/case`, `catch`, `||`, `&&`, `??`, ternary.
16
+ - **Threshold**: `criticalComplexityThreshold` (default: 30).
17
+ - **Engines**: TypeScript Compiler, Tree-sitter.
18
+
19
+ ### Cognitive Complexity
20
+ - **What**: Mental load to understand a function — penalizes nesting more than branching.
21
+ - **How**: Increments for control-flow keywords; adds nesting depth bonus for each level.
22
+ - **Threshold**: `cognitiveComplexityThreshold` (default: 15).
23
+ - **Engines**: TypeScript Compiler, Tree-sitter (now at parity).
24
+
25
+ ### Halstead Metrics
26
+ - **What**: Software science metrics based on operator/operand vocabulary.
27
+ - **Computed**: volume, difficulty, effort, time, estimated bugs.
28
+ - **Threshold**: `halsteadEffortThreshold` (default: 500,000).
29
+ - **Engine**: TypeScript Compiler only.
30
+
31
+ ### Maintainability Index (MI)
32
+ - **What**: Composite score (0–171) indicating ease of maintenance.
33
+ - **Formula**: `171 - 5.2·ln(V) - 0.23·CC - 16.2·ln(LOC)` (clamped to [0, 100]).
34
+ - **Threshold**: `maintainabilityIndexThreshold` (default: 20).
35
+ - **Engine**: TypeScript Compiler only.
36
+
37
+ ---
38
+
39
+ ## Code Quality Detectors (34 total)
40
+
41
+ ### Existing Detectors
42
+
43
+ | # | Category | Severity | Description |
44
+ |---|----------|----------|-------------|
45
+ | 1 | `duplicate-function-body` | low–high | Identical function body hash across locations |
46
+ | 2 | `duplicate-flow-structure` | low–medium | Repeated control-flow structure shapes |
47
+ | 3 | `function-optimization` | medium–high | High cyclomatic complexity or deep nesting |
48
+ | 4 | `cognitive-complexity` | medium–high | High cognitive complexity per function |
49
+ | 5 | `god-function` | high | Oversized functions by statement count + low MI |
50
+ | 6 | `excessive-parameters` | medium | Functions with too many parameters |
51
+ | 7 | `empty-catch` | medium | Empty catch blocks silently swallowing errors |
52
+ | 8 | `switch-no-default` | low | Switch statements without default case |
53
+ | 9 | `unsafe-any` | medium | Files with excessive `any` type usage |
54
+ | 10 | `halstead-effort` | medium–high | Functions with extreme Halstead effort |
55
+ | 11 | `low-maintainability` | medium–high | Functions below MI threshold |
56
+ | 12 | `type-assertion-escape` | medium | `as any`, double assertions, non-null assertions |
57
+ | 13 | `missing-error-boundary` | medium | Async functions with awaits but no try-catch |
58
+ | 14 | `promise-misuse` | low | Async functions without any await |
59
+ | 15 | `await-in-loop` | medium | Await calls inside loops (sequential where parallel possible) |
60
+ | 16 | `sync-io` | medium | Synchronous I/O calls (readFileSync, etc.) |
61
+ | 17 | `uncleared-timer` | medium | setInterval without corresponding clearInterval |
62
+ | 18 | `listener-leak-risk` | medium | Event listeners added without removal |
63
+ | 19 | `unbounded-collection` | medium | Potential unbounded collection growth |
64
+ | 20 | `similar-function-body` | low–medium | Near-duplicate functions by metric similarity |
65
+ | 21 | `message-chain` | medium–high | Deep property chains violating Law of Demeter |
66
+
67
+ ### Semantic-Gated Detectors (require `--semantic`)
68
+
69
+ | # | Category | Severity | Description |
70
+ |---|----------|----------|-------------|
71
+ | 22 | `god-module` | medium–high | Oversized modules by statement count + export count |
72
+ | 23 | `unused-parameter` | low | Function parameters never referenced in body |
73
+ | 24 | `deep-override-chain` | medium | Method override chains exceeding depth threshold |
74
+ | 25 | `interface-compliance` | medium | Types claiming to implement an interface but missing members |
75
+ | 26 | `narrowable-type` | low | Union types that could be narrowed for better type safety |
76
+
77
+ ### New Detectors (v2)
78
+
79
+ | # | Category | Severity | Description |
80
+ |---|----------|----------|-------------|
81
+ | 27 | `deep-nesting` | low–high | Functions with branch/loop nesting exceeding threshold |
82
+ | 28 | `multiple-return-paths` | low–high | Functions with too many return/throw exit points |
83
+ | 29 | `catch-rethrow` | low | Catch blocks containing a throw statement (simplification candidates) |
84
+ | 30 | `magic-string` | low–high | String literals repeated in comparisons across files |
85
+ | 31 | `boolean-parameter-cluster` | medium | Functions with 3+ boolean parameters |
86
+ | 32 | `promise-all-unhandled` | medium | Promise.all/race/any without error handling |
87
+ | 33 | `export-surface-density` | low–high | Modules where >50% of statements are exported |
88
+ | 34 | `change-risk` | medium–critical | Composite risk score from overlapping quality signals |
89
+
90
+ ---
91
+
92
+ ## New Detector Details
93
+
94
+ ### deep-nesting
95
+ - **Threshold**: `deepNestingThreshold` (default: 5)
96
+ - **Signal**: `max(maxBranchDepth, maxLoopDepth)` per function
97
+ - **Severity mapping**: `≥ threshold+3` → high, `≥ threshold+1` → medium, else → low
98
+ - **Fix strategy**: Guard clauses, early returns, extract to named helpers
99
+
100
+ ### multiple-return-paths
101
+ - **Threshold**: `multipleReturnThreshold` (default: 6)
102
+ - **Signal**: `returns` count per function (includes throw statements)
103
+ - **Severity mapping**: `≥ threshold+4` → high, `≥ threshold+2` → medium, else → low
104
+ - **Fix strategy**: Single result variable, guard clauses for error paths only
105
+
106
+ ### catch-rethrow
107
+ - **Signal**: Catch blocks containing a throw statement — candidates for simplification (may include other statements alongside the rethrow)
108
+ - **Severity**: Always low (noise reduction)
109
+ - **Fix strategy**: Remove the try-catch if only rethrowing, or add logging/wrapping before re-throw
110
+
111
+ ### magic-string
112
+ - **Threshold**: `magicStringMinOccurrences` (default: 3)
113
+ - **Signal**: String literals used in `===`, `!==`, `==`, `!=` comparisons or `case` clauses, appearing ≥ threshold times
114
+ - **Severity mapping**: `≥ 8` → high, `≥ 5` → medium, else → low
115
+ - **Fix strategy**: Extract to named constant or enum
116
+
117
+ ### boolean-parameter-cluster
118
+ - **Threshold**: `booleanParamThreshold` (default: 3)
119
+ - **Signal**: Functions with ≥ threshold parameters typed as `boolean`
120
+ - **Severity**: Always medium
121
+ - **Fix strategy**: Replace with options object or split into separate functions
122
+
123
+ ### promise-all-unhandled
124
+ - **Signal**: `Promise.all/allSettled/race/any` calls without surrounding try-catch or `.catch()` chain
125
+ - **Severity**: Always medium
126
+ - **Fix strategy**: Wrap in try-catch or chain `.catch()`
127
+
128
+ ### export-surface-density
129
+ - **Signal**: `exportCount / totalStatements` ratio ≥ 0.5 (modules with ≥ 20 statements)
130
+ - **Severity mapping**: `≥ 80%` → high, `≥ 60%` → medium, else → low
131
+ - **Fix strategy**: Make non-essential symbols private, split into facade + implementation
132
+
133
+ ### change-risk (composite)
134
+ - **Signal**: Weighted sum of overlapping quality problems in a single file
135
+ - **Components scored**:
136
+ - High average complexity → +2
137
+ - High cognitive complexity → +2
138
+ - Low maintainability functions → +count
139
+ - Empty catches → +1
140
+ - Unhandled promise combinators → +1
141
+ - Excessive exports (>15) → +1
142
+ - **Threshold**: Score ≥ 4 triggers finding
143
+ - **Severity mapping**: `≥ 8` → critical, `≥ 6` → high, else → medium
144
+
145
+ ---
146
+
147
+ ## AST Search Presets (22 total)
148
+
149
+ ### Existing Presets
150
+ `empty-catch`, `console-log`, `console-any`, `debugger`, `todo-fixme`, `any-type`, `type-assertion`, `non-null-assertion`, `fat-arrow-body`, `nested-ternary`, `throw-string`, `switch-no-default`, `class-declaration`, `async-function`, `export-default`, `import-star`
151
+
152
+ ### New Presets (v2)
153
+ | Preset | Description |
154
+ |--------|-------------|
155
+ | `catch-rethrow` | Catch blocks that only re-throw the caught error |
156
+ | `promise-all` | Promise.all calls — check for missing error handling |
157
+ | `boolean-param` | Function parameters typed as boolean |
158
+ | `magic-number` | Numeric literals (excluding 0 and 1) |
159
+ | `deep-callback` | 3+ levels of nested arrow function callbacks |
160
+ | `unused-var` | Variable declarations without call expressions |
161
+
162
+ ---
163
+
164
+ ## Thresholds Reference
165
+
166
+ All thresholds are configurable via CLI flags (e.g. `--critical-complexity-threshold 30`, `--deep-nesting-threshold 5`) or config file. See [CLI reference](./cli-reference.md) for exact flag names.
167
+
168
+ | Threshold | Default | Used By |
169
+ |-----------|---------|---------|
170
+ | `criticalComplexityThreshold` | 30 | function-optimization |
171
+ | `cognitiveComplexityThreshold` | 15 | cognitive-complexity |
172
+ | `halsteadEffortThreshold` | 500,000 | halstead-effort |
173
+ | `maintainabilityIndexThreshold` | 20 | low-maintainability |
174
+ | `parameterThreshold` | 5 | excessive-parameters |
175
+ | `anyThreshold` | 5 | unsafe-any |
176
+ | `flowDupThreshold` | 3 | duplicate-flow-structure |
177
+ | `similarityThreshold` | 0.85 | similar-function-body |
178
+ | `godFunctionStatements` | 100 | god-function |
179
+ | `godFunctionMiThreshold` | 10 | god-function |
180
+ | `deepNestingThreshold` | 5 | deep-nesting |
181
+ | `multipleReturnThreshold` | 6 | multiple-return-paths |
182
+ | `magicStringMinOccurrences` | 3 | magic-string |
183
+ | `booleanParamThreshold` | 3 | boolean-parameter-cluster |
184
+
185
+ ---
186
+
187
+ ## Algorithms
188
+
189
+ ### Tarjan's SCC (Strongly Connected Components)
190
+ Used to detect dependency cycle clusters. O(V+E) complexity. Identifies groups of modules that form circular dependencies.
191
+
192
+ ### Articulation Points & Bridge Edges
193
+ Graph theory algorithms to find critical nodes (removing one disconnects the graph) and critical edges. Identifies architectural chokepoints.
194
+
195
+ ### Structural Hashing
196
+ Functions are hashed by their AST structure (ignoring identifiers/literals) to detect true duplicates vs. near-duplicates.
197
+
198
+ ### Metric Similarity
199
+ Near-duplicate detection uses feature-vector similarity: `1 - |a-b|/max(a,b)` across 8 metrics (complexity, depth, returns, awaits, calls, loops, statements).
200
+
201
+ ### Composite Risk Scoring
202
+ The `change-risk` detector aggregates multiple quality signals into a single score per file, identifying files most likely to cause regressions.
@@ -0,0 +1,298 @@
1
+ # Tool Workflows — Research Methodology & Patterns
2
+
3
+ Step-focused workflows for code analysis. For multi-angle investigation principles and tool descriptions, see [SKILL.md](../SKILL.md#how-to-investigate). For tool params and flags, see [CLI reference](./cli-reference.md).
4
+
5
+ ---
6
+
7
+ ## Quick Decision Table
8
+
9
+ | Question | Approach |
10
+ |----------|----------|
11
+ | "What does this codebase look like?" | Explore directory structure → find large files → spot hotspots |
12
+ | "Does pattern X exist?" | AST structural search with preset or pattern |
13
+ | "Where is X defined?" | Text search to locate → jump to definition |
14
+ | "Who calls function X?" | Text search for lineHint → call hierarchy (incoming) |
15
+ | "All usages of type/var X?" | Text search for lineHint → find references |
16
+ | "Is export X dead?" | Find references (exclude declaration) → cross-check with AST import search |
17
+ | "What's the AST shape of file X?" | AST tree-search on scan artifact |
18
+ | "Read this function" | Read file content with match targeting |
19
+ | "Trace flow A → B" | Search → definition jump → call hierarchy → chain hops |
20
+ | "Architecture hotspots?" | Scan with graph analysis → validate hotFiles with reference counts |
21
+ | "Structural smells?" | AST preset sweep (batch multiple presets in parallel) |
22
+ | "Did my fix work?" | Re-scan scoped to changed files + AST preset check + project toolchain |
23
+
24
+ ---
25
+
26
+ ## Workflows
27
+
28
+ ### 1 — Full Scan → Triage → Validate
29
+
30
+ Start here for any new codebase or broad audit.
31
+
32
+ 1. **Run full scan** with graph + flow flags → generates hypotheses
33
+ 2. **Read summary.md** → health scores, pillar grades, top recommendations
34
+ 3. **Triage top findings** from findings.json → check severity, lspHints, correlated signals
35
+ 4. **Quick structural triage** — AST tree-search for function declarations to spot large/complex shapes
36
+ 5. **Explore project layout** — directory structure + largest files for hotspot candidates
37
+ 6. **Validate top findings** — use lspHints from findings to confirm or dismiss via reference counts and call hierarchy
38
+
39
+ See [output files](./output-files.md) for scan artifact schemas and read order. See [validation playbooks](./validation-playbooks.md) for per-category validation tactics.
40
+
41
+ ### 2 — Symbol Deep Dive
42
+
43
+ Trace a function: definition → callers → callees.
44
+
45
+ 1. **Check AST shape** — tree-search for the function to see its span, nesting depth, and structure
46
+ 2. **Locate the symbol** — text search to get file + lineHint
47
+ 3. **Read the function body** — targeted file content around the function
48
+ 4. **Jump to definition** — follow the symbol to its canonical definition
49
+ 5. **Find callers** — incoming call hierarchy → who depends on this?
50
+ 6. **Find callees** — outgoing call hierarchy → what does this depend on?
51
+
52
+ ### 3 — Impact Analysis (Pre-Refactor)
53
+
54
+ Assess blast radius before changing a symbol.
55
+
56
+ 1. **Map structural imports** — AST search for import patterns involving the symbol
57
+ 2. **Locate the symbol** — text search to get file + lineHint
58
+ 3. **Count all consumers** — find references, excluding declaration
59
+ 4. **Count test consumers** — find references filtered to test directories only
60
+ 5. **Count production consumers** — find references excluding test directories
61
+ 6. **Assess safety** — few production refs + high test coverage = safe to change. Many production refs = plan carefully, consider incremental migration.
62
+
63
+ ### 4 — Dead Export Validation
64
+
65
+ Fastest path from finding to verdict.
66
+
67
+ 1. **Check for consumers** — find references excluding declaration. 0 refs = likely dead, >0 = alive.
68
+ 2. **Cross-check structurally** — AST search for import statements of the export name
69
+ 3. **Check for dynamic usage** — text search for the export name to catch computed/dynamic references
70
+ 4. **Verdict** — 0 consumers across all checks = confirmed dead. Any usage found = dismiss.
71
+
72
+ ### 5 — Code Smell Sweep (AST Presets)
73
+
74
+ Structural code smell detection — zero false positives.
75
+
76
+ 1. **Run AST presets in parallel** — batch presets: empty-catch, any-type, console-log, switch-no-default, nested-ternary, non-null-assertion
77
+ 2. **Add custom pattern checks** if needed (e.g. eval usage, specific anti-patterns)
78
+ 3. **Read context** around flagged locations to understand severity
79
+ 4. **Assess impact** — check callers of flagged functions to gauge blast radius
80
+
81
+ See [AST reference](./ast-reference.md) for all presets and pattern syntax.
82
+
83
+ ### 6 — Dependency Cycle Tracing
84
+
85
+ Validate cycles from `architecture.json`.
86
+
87
+ 1. **Scan for cycles** — run scan with dependency-cycle feature + graph
88
+ 2. **Read cycle paths** from architecture.json
89
+ 3. **Find back-edge imports** — AST search for import patterns in the cycle directory
90
+ 4. **Identify importing files** — text search for imports from the cycle modules
91
+ 5. **Read the import blocks** — targeted content reading at import statements
92
+ 6. **Trace through the chain** — jump to definitions and follow call hierarchy until the cycle closes
93
+
94
+ ### 7 — Security Sink Validation
95
+
96
+ Trace data flow from source to sink.
97
+
98
+ 1. **Find sink patterns** — AST search for eval, innerHTML assignment, exec, command injection patterns
99
+ 2. **Find secret patterns** — AST rule search for strings matching password/secret/token patterns
100
+ 3. **Find guards** — text search for validation, sanitization, or normalization functions
101
+ 4. **Read sink context** — targeted content reading around the sink function
102
+ 5. **Locate the sink** — jump to definition for cross-file resolution
103
+ 6. **Trace data sources** — incoming call hierarchy to trace who feeds data to the sink
104
+ 7. **Check all call sites** — find references for the sink function to assess exposure breadth
105
+
106
+ See [validation playbooks](./validation-playbooks.md) for taint-tracing and false-positive dismissal.
107
+
108
+ ### 8 — Scoped Deep-Dive (File or Function)
109
+
110
+ Drill into a specific flagged file or function.
111
+
112
+ 1. **Re-scan scoped** — scan with scope narrowed to the target file, with flow + semantic flags
113
+ 2. **Function-level scope** — if drilling into a specific function, use `file:symbol` scope syntax
114
+ 3. **Check AST shape** — tree-search for the file to see function spans and nesting
115
+ 4. **Read public surface** — targeted content at export declarations
116
+ 5. **Read imports** — content at the top of the file for dependency context
117
+ 6. **Read target section** — content around the specific area of interest
118
+ 7. **Count consumers per export** — find references for each exported symbol
119
+ 8. **Map function dependencies** — outgoing call hierarchy per function
120
+
121
+ ### 9 — Coupling Hotspot Analysis
122
+
123
+ Quantify coupling for architecture findings.
124
+
125
+ 1. **Scan for coupling signals** — run scan with coupling + god-module features + advanced graph
126
+ 2. **Read top hotFiles** from architecture.json
127
+ 3. **Map import density** — AST search for import patterns in the hotspot directory
128
+ 4. **Count consumer files** — text search for imports from the hotspot
129
+ 5. **Assess module size** — structure view of the hotspot directory + find largest files
130
+ 6. **Quantify per-export coupling** — find references for each export, call hierarchy for each function
131
+
132
+ **Decision**: high fan-in + large files = decomposition candidate. Low fan-in = less urgent.
133
+
134
+ ### 10 — Fix Verification Loop
135
+
136
+ Confirm fixes reduced finding count. Run after every fix batch.
137
+
138
+ 1. **Re-scan changed files** — scoped scan with relevant feature flags
139
+ 2. **AST smell check** — run presets against changed directories to verify smells are gone
140
+ 3. **Spot-check fixes** — read fixed code to confirm the change looks right
141
+ 4. **Verify references** — find references to confirm moved/renamed symbols still resolve
142
+ 5. **Verify callers** — incoming call hierarchy to confirm callers are still connected
143
+ 6. **Run project toolchain** — lint (with auto-fix), tests, build → all must pass
144
+
145
+ ---
146
+
147
+ ## Extended Workflows — Architecture, Planning, Exploration
148
+
149
+ ### 11 — Pre-Implementation Check ("Where should new code live?")
150
+
151
+ Before writing new code, understand the existing landscape to pick the right location.
152
+
153
+ 1. **Explore project layout** — directory structure at depth 2
154
+ 2. **Map dependency graph** — scan with graph + advanced flags → identify hotspots
155
+ 3. **Avoid hotspots** — read top hotFiles from architecture.json, don't add to them
156
+ 4. **Find analogous patterns** — text search for similar features to see how the codebase does it
157
+ 5. **Check existing API shape** — AST search for export patterns in candidate directories
158
+ 6. **Check candidate module coupling** — find references for candidate module's exports
159
+ 7. **Read the public surface** — targeted content at exports of the target module
160
+
161
+ **Decision**: low fan-in module with related exports = good home. High fan-in hotspot = add to a new module instead.
162
+
163
+ ### 12 — Refactoring Plan (Safe Restructure)
164
+
165
+ Plan a multi-file refactor with full blast radius awareness.
166
+
167
+ 1. **Map all files containing the symbol** — text search with file-list mode
168
+ 2. **Count all consumers** — find references excluding declaration
169
+ 3. **Split test vs production consumers** — find references with include/exclude patterns for test dirs
170
+ 4. **Map callers and dependencies** — incoming and outgoing call hierarchy
171
+ 5. **Check import graph** — AST search for import patterns in the target area
172
+ 6. **Check coupling/cycle risk** — scoped scan with architecture + graph features
173
+ 7. **Assess test quality around target** — scoped scan with test-quality feature
174
+
175
+ **Output**: file list + consumer count + test coverage + coupling risk = refactoring confidence level.
176
+
177
+ ### 13 — Codebase Exploration (New Repo Orientation)
178
+
179
+ Quickly understand an unfamiliar codebase.
180
+
181
+ 1. **Layout** — top-level directory structure → source root shape with file sizes
182
+ 2. **Scale and hotspots** — find largest files, recently modified files, barrel/index files
183
+ 3. **API surface** — text search for exports (file-list mode), AST search for class declarations and default exports
184
+ 4. **Architecture shape** — full scan with graph + flow → read summary.md for health scores
185
+ 5. **Conventions** — AST search for import patterns, text search for test patterns, find test file locations
186
+
187
+ ### 14 — Test Strategy Analysis
188
+
189
+ Map test coverage gaps and test quality issues.
190
+
191
+ 1. **Test landscape** — find all test files, explore test directory structure, count test density
192
+ 2. **Coverage gaps** — text search for exported functions, then find references filtered to test dirs. 0 test refs = coverage gap.
193
+ 3. **Test quality** — scan with test-quality feature + include-tests. AST search for empty catches, mock density, assertion density in test source
194
+ 4. **Critical untested code** — scan for architecture to find critical paths, check test coverage per hotFile
195
+
196
+ **Output**: untested exports list + test quality findings + critical untested hotspots = test priority plan.
197
+
198
+ ### 15 — Code Review Support (Change Impact Analysis)
199
+
200
+ Assess the architectural impact of changed files.
201
+
202
+ 1. **Read the changes** — targeted content reading around changed functions
203
+ 2. **Blast radius per symbol** — text search for changed symbols → find references → split test vs production → incoming call hierarchy for direct callers
204
+ 3. **Architecture effect** — scoped scan of changed files with architecture + graph → AST search for new import patterns
205
+ 4. **Quality check** — scoped scan of changed files with code-quality + security features → AST preset sweep on changed dirs for new smells
206
+ 5. **Test coverage** — find references for changed symbols filtered to test directories → are all changes tested?
207
+
208
+ **Output**: consumer impact count + architecture delta + new quality issues + test coverage = review verdict.
209
+
210
+ ### 16 — Code Quality Review (Module or File)
211
+
212
+ Focused quality review of a specific target.
213
+
214
+ 1. **Scoped scan** — scan target with code-quality + dead-code features, flow + semantic flags → read summary + top findings
215
+ 2. **AST smell sweep** — batch presets: empty-catch, any-type, type-assertion, non-null-assertion, console-log, nested-ternary, switch-no-default
216
+ 3. **Complexity check** — AST tree-search for function spans + nesting, scoped scan for cognitive-complexity + god-module + god-function
217
+ 4. **Dead code check** — find references per export (0 refs = dead), AST cross-check on import patterns
218
+ 5. **Maintainability assessment** — read public surface size, map outgoing call hierarchy (dependency count), map incoming call hierarchy (fan-in per export)
219
+
220
+ **Output**: smell count + complexity scores + dead exports + fan-in/fan-out + maintainability = quality verdict with evidence.
221
+
222
+ ### 17 — Full Architecture Analysis
223
+
224
+ Complete architecture health assessment.
225
+
226
+ 1. **Full architecture scan** — graph + graph-advanced + flow + architecture features
227
+ 2. **Read architecture outputs** — summary.md health score, cycles, hotFiles (ranked), SCC clusters, chokepoints, critical paths, Mermaid graph
228
+ 3. **Validate top hotspots** — text search for hotspot files → find references for fan-in, call hierarchy for fan-out and direct callers
229
+ 4. **Module boundary analysis** — AST search for cross-module imports, text search for barrel re-exports, scan for boundary/layer violations
230
+ 5. **Cycle deep-dive** (per cycle) — AST search for imports in cycle dirs, jump to definitions to hop through, read import blocks to confirm back-edges
231
+ 6. **Critical path analysis** — read criticalPaths from architecture.json, check incoming call hierarchy for each hub
232
+
233
+ **Output**: cycle list + SCC clusters + chokepoints + hotfiles (ranked) + boundary violations + critical paths + fan-in/fan-out = full architecture health report.
234
+
235
+ ### 18 — Smart Coding (Impact-Aware Changes)
236
+
237
+ Before and after making code changes, check blast radius and verify safety.
238
+
239
+ **=== BEFORE CODING ===**
240
+
241
+ 1. **Define behavior contract** — current behavior, desired behavior, invariants, non-goals, user-facing contract
242
+ 2. **Understand the target area** — explore module layout, read current code, jump to definitions
243
+ 3. **Check blast radius** — text search for target symbol → find references (total, production-only, test-only) → incoming call hierarchy for direct callers
244
+ 4. **Check architecture safety** — scoped scan with architecture + graph → read cycles to check if the change would create new ones
245
+ 5. **Follow existing patterns** — AST search for similar patterns nearby, text search for analogous implementations
246
+
247
+ **=== MAKE THE CHANGE ===**
248
+
249
+ 6. **Implement** — apply edits
250
+
251
+ **=== AFTER CODING ===**
252
+
253
+ 7. **Verify behavior** — run project tests
254
+ 8. **Verify no new issues** — scoped scan of changed files with code-quality + architecture features, AST preset sweep for any-type + empty-catch
255
+ 9. **Verify references intact** — find references for moved/renamed symbols, incoming call hierarchy for callers
256
+ 10. **Verify user-facing contracts** — run CLI/API/integration checks when relevant, update docs when behavior changed
257
+ 11. **Run project toolchain** — lint (with auto-fix), build
258
+
259
+ **Decision gates**:
260
+ - Step 3: >20 production consumers = high-risk, consider feature flag or incremental migration
261
+ - Step 4: change touches cycle member or hotfile = extra caution, verify with re-scan after
262
+ - Step 8: new findings = fix before committing
263
+ - Step 10: docs or contract drift = fix before committing
264
+ - Step 11: any failure = investigate before proceeding
265
+
266
+ ### 19 — CLI Change Safety
267
+
268
+ Use when changing commands, flags, help text, output, or exit behavior.
269
+
270
+ 1. **Find CLI entry points** — text search for CLI frameworks (process.argv, commander, yargs, etc.) + find files named cli/bin/command
271
+ 2. **Read commands and options** — targeted content reading around command definitions, options, defaults
272
+ 3. **Find affected tests and docs** — text search for flag/command names across tests, scripts, and docs
273
+ 4. **Verify behavior** — run entry with --help, happy-path input, bad input; check stdout/stderr/exit codes
274
+ 5. **Run CLI and e2e tests** if the project has them
275
+
276
+ **Checklist**: names, aliases, defaults, positional args, stdout/stderr, exit codes, env/config inputs, machine-readable output, backward compatibility.
277
+
278
+ ### 20 — API Contract Safety
279
+
280
+ Use when changing handlers, endpoints, schemas, DTOs, or serialized responses.
281
+
282
+ 1. **Find the public surface** — text search for router/handler/endpoint/resolver patterns + schema/contract files
283
+ 2. **Read request/response code** — targeted content around route definitions
284
+ 3. **Trace affected internals** — text search for response/DTO types → find references for shared types → outgoing call hierarchy for handler→service flow
285
+ 4. **Verify the contract** — run integration, contract, and/or project test scripts
286
+
287
+ **Checklist**: request schema, response shape, status codes, error bodies, auth, pagination, idempotency, versioning, deprecation, migration notes.
288
+
289
+ ### 21 — Docs and Rollout Sync
290
+
291
+ Use when public behavior changed or a risky change needs an operational plan.
292
+
293
+ 1. **Find docs and examples** — find README, markdown, OpenAPI, env.example files + text search for changed names in docs
294
+ 2. **Update completion criteria** — docs/help/examples/migration notes updated; feature flag/rollout/telemetry/rollback decided when needed
295
+ 3. **Verify docs tooling** — run docs build/check scripts if the project has them
296
+
297
+ **Output**: updated docs list + compatibility note + rollout/rollback plan, or explicit statement that no public docs or rollout work was needed.
298
+
@@ -0,0 +1,99 @@
1
+ # Validation Playbooks
2
+
3
+ How to validate findings before presenting them. Every scanner finding is a hypothesis — never present it as fact without validation.
4
+
5
+ For the validation loop (confirmed/dismissed/uncertain), see [SKILL.md](../SKILL.md#cross-validate-findings). For tool descriptions, see [SKILL.md tools](../SKILL.md#tools). For scanner flags, see [CLI reference](./cli-reference.md).
6
+
7
+ ---
8
+
9
+ ## Category playbooks
10
+
11
+ | Category type | How to validate | Typical fix |
12
+ |---------------|----------------|-------------|
13
+ | Dead export | Find references excluding declaration → 0 refs = dead | Remove export or wire real usage |
14
+ | Coupling hotspot | Measure fan-in (find references) + fan-out (outgoing call hierarchy) | Split module by responsibility/consumer group |
15
+ | Dependency cycle | Read cycle path from architecture.json → trace imports through the chain | Break edge via shared contract/inversion |
16
+ | Security sink | Trace data sources via incoming call hierarchy → check for guards before the sink | Add/centralize validation/sanitization before sink |
17
+ | God function | Read body + map outgoing calls → count concerns and side effects | Extract focused helpers, keep orchestration thin |
18
+ | Performance (await-in-loop) | Read loop body — is each iteration independent? Check for data dependency between iterations | Collect promises with `Promise.all()`. Keep sequential only when iteration N depends on N-1 |
19
+ | Performance (sync I/O, listener leak) | Read body — sync I/O on hot path? Listeners without matching removal? | Replace sync with async; add cleanup |
20
+ | Test gap | Find references for symbol filtered to test dirs → 0 test refs = gap | Add tests around public contract and edge paths |
21
+
22
+ Use TDD for behavioral fixes when practical: failing test → fix → pass → full suite.
23
+
24
+ ---
25
+
26
+ ## Architecture interpretation
27
+
28
+ Use these signals when raw findings are noisy:
29
+ - **SCC cluster**: treat overlapping cycles as one refactor unit
30
+ - **Broker/chokepoint**: high fan-in + high fan-out = dependency pressure node
31
+ - **Bridge module**: articulation-style file connecting subsystems
32
+ - **Package chatter**: excessive cross-package traffic indicates boundary erosion
33
+
34
+ Prioritize fixes where hotspots and critical paths overlap.
35
+
36
+ ---
37
+
38
+ ## Metrics cheat sheet
39
+
40
+ | Metric | Meaning | Typical threshold signal |
41
+ |--------|---------|--------------------------|
42
+ | Instability `I = Ce / (Ca + Ce)` | how change-prone vs depended-on a module is | stable module depending on more unstable one |
43
+ | Cognitive complexity | branch/nesting mental load | >15 tends to need decomposition |
44
+ | Maintainability index | overall maintainability score | <20 is high-risk maintainability |
45
+ | Halstead effort | estimated comprehension effort | very high effort suggests split/refactor |
46
+
47
+ Use thresholds as heuristics, not absolute truth.
48
+
49
+ ---
50
+
51
+ ## Worked examples
52
+
53
+ Three end-to-end validation flows showing how to arrive at **confirmed**, **dismissed**, and **uncertain**.
54
+
55
+ ### Example 1: Confirmed — dead export
56
+
57
+ **Finding**: `findings.json` reports `dead-export` for `formatDate` in `src/utils/dates.ts` (line 42).
58
+
59
+ | Step | What was done | Result | Decision |
60
+ |------|--------------|--------|----------|
61
+ | 1 | Text search for "formatDate" scoped to the file | Match at line 42 — `export function formatDate(...)`. Got lineHint. | — |
62
+ | 2 | Find references for `formatDate` at that lineHint, excluding declaration | **0 references** outside the declaration. | No consumers. |
63
+ | 3 | Broad text search for "formatDate" across all files (file-list mode) | Only `src/utils/dates.ts` appears. No re-exports, no test imports. | No indirect usage. |
64
+
65
+ **Verdict**: **Confirmed** (high confidence). Zero consumers in production and test code. Safe to remove the export or delete the function entirely.
66
+
67
+ ---
68
+
69
+ ### Example 2: Dismissed — false-positive coupling hotspot
70
+
71
+ **Finding**: `architecture.json` lists `src/config/env.ts` as a coupling hotspot (fanIn=45, fanOut=2).
72
+
73
+ | Step | What was done | Result | Decision |
74
+ |------|--------------|--------|----------|
75
+ | 1 | Read the full file (25 lines, small enough for full content) | Exports `const ENV = { ... }` — a read-only config object from `process.env`. No logic. | Pure config. |
76
+ | 2 | Find references for `ENV` at its declaration, excluding declaration | 45 references across 32 files, all `import { ENV }` followed by property reads. No mutations. | All consumers read-only. |
77
+ | 3 | Check churn risk — find files in `src/config` modified within 90 days | Not modified in 90 days. | Stable. |
78
+
79
+ **Verdict**: **Dismissed**. High fan-in is expected and harmless for a read-only config module. No logic, no mutation, no churn. The scanner flags structural coupling but the semantics show this is a stable leaf — not a refactoring target.
80
+
81
+ ---
82
+
83
+ ### Example 3: Uncertain — god function with partial evidence
84
+
85
+ **Finding**: `findings.json` reports `god-function` for `processOrder` in `src/orders/handler.ts` (line 88, 120 statements, cognitive complexity 35).
86
+
87
+ | Step | What was done | Result | Decision |
88
+ |------|--------------|--------|----------|
89
+ | 1 | Read the function body (line 88-210) | Large function with validation, discount calculation, inventory check, payment call, email dispatch. Multiple concerns interleaved. | Confirms size and complexity. |
90
+ | 2 | Incoming call hierarchy for `processOrder` | 3 callers: `POST /orders` route handler, a batch job, and 1 test. | Moderate blast radius. |
91
+ | 3 | Outgoing call hierarchy for `processOrder` | Calls 8 functions across 5 files: validateOrder, calcDiscount, checkInventory, chargePayment, sendConfirmation, logAudit, updateMetrics, notifyWarehouse. | Orchestrates many side effects. |
92
+ | 4 | Find references filtered to test directories | 1 test reference — a single happy-path integration test. No edge-case coverage. | Sparse test coverage. |
93
+
94
+ **Verdict**: **Uncertain** (medium confidence). The function is objectively large and complex, and orchestrates many side effects — consistent with a god function. However, it may be intentionally serving as a transaction script (single orchestration point for atomicity). Cannot confirm it's harmful without knowing:
95
+ - Whether the callers expect atomic all-or-nothing behavior
96
+ - Whether extracting sub-steps would break transaction boundaries
97
+ - Whether the team considers this an acceptable orchestration pattern
98
+
99
+ **Recommendation**: flag for team review. If refactoring, extract pure computation helpers (validation, discount) first — those are side-effect-free and safe. Defer side-effect orchestration changes until transaction semantics are clarified.