octocode-cli 1.2.8 → 1.2.10
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.
- package/README.md +45 -38
- package/out/octocode-cli.js +73 -11763
- package/package.json +35 -36
- package/skills/README.md +42 -114
- package/skills/{octocode-code-engineer → octocode-engineer}/.claude/settings.local.json +2 -1
- package/skills/octocode-engineer/README.md +99 -0
- package/skills/octocode-engineer/SKILL.md +413 -0
- package/skills/octocode-engineer/build.mjs +29 -0
- package/skills/{octocode-code-engineer → octocode-engineer}/eslint.config.mjs +3 -13
- package/skills/{octocode-code-engineer → octocode-engineer}/package.json +28 -27
- package/skills/octocode-engineer/references/ast-reference.md +166 -0
- package/skills/{octocode-code-engineer → octocode-engineer}/references/cli-reference.md +80 -6
- package/skills/octocode-engineer/references/externals.md +86 -0
- package/skills/{octocode-code-engineer → octocode-engineer}/references/output-files.md +46 -6
- package/skills/octocode-engineer/references/quality-indicators.md +202 -0
- package/skills/octocode-engineer/references/tool-workflows.md +298 -0
- package/skills/octocode-engineer/references/validation-playbooks.md +99 -0
- package/skills/octocode-engineer/scripts/ast/search.js +45 -0
- package/skills/octocode-engineer/scripts/ast/tree-search.js +27 -0
- package/skills/octocode-engineer/scripts/index.js +173 -0
- package/skills/octocode-engineer/scripts/run.js +179 -0
- package/skills/octocode-engineer/src/analysis/dependencies.ts +378 -0
- package/skills/{octocode-code-engineer → octocode-engineer}/src/analysis/discovery.test.ts +57 -0
- package/skills/{octocode-code-engineer → octocode-engineer}/src/analysis/discovery.ts +43 -0
- package/skills/{octocode-code-engineer → octocode-engineer}/src/ast/search.test.ts +113 -0
- package/skills/{octocode-code-engineer → octocode-engineer}/src/ast/search.ts +64 -1
- package/skills/{octocode-code-engineer → octocode-engineer}/src/ast/tree-sitter.test.ts +118 -2
- package/skills/{octocode-code-engineer → octocode-engineer}/src/ast/tree-sitter.ts +65 -3
- package/skills/{octocode-code-engineer → octocode-engineer}/src/ast/ts-analyzer.test.ts +281 -1
- package/skills/{octocode-code-engineer → octocode-engineer}/src/ast/ts-analyzer.ts +173 -3
- package/skills/{octocode-code-engineer → octocode-engineer}/src/collectors/security.test.ts +73 -0
- package/skills/{octocode-code-engineer → octocode-engineer}/src/collectors/security.ts +62 -4
- package/skills/octocode-engineer/src/detector-gating.test.ts +59 -0
- package/skills/{octocode-code-engineer → octocode-engineer}/src/detectors/code-quality.ts +342 -0
- package/skills/{octocode-code-engineer → octocode-engineer}/src/detectors/index.ts +8 -0
- package/skills/{octocode-code-engineer → octocode-engineer}/src/index.test.ts +565 -11
- package/skills/octocode-engineer/src/index.ts +468 -0
- package/skills/octocode-engineer/src/pipeline/affected.test.ts +147 -0
- package/skills/octocode-engineer/src/pipeline/affected.ts +68 -0
- package/skills/octocode-engineer/src/pipeline/baseline.test.ts +276 -0
- package/skills/octocode-engineer/src/pipeline/baseline.ts +76 -0
- package/skills/{octocode-code-engineer → octocode-engineer}/src/pipeline/cli.test.ts +300 -53
- package/skills/{octocode-code-engineer → octocode-engineer}/src/pipeline/cli.ts +180 -36
- package/skills/octocode-engineer/src/pipeline/config-loader.test.ts +264 -0
- package/skills/octocode-engineer/src/pipeline/config-loader.ts +109 -0
- package/skills/octocode-engineer/src/pipeline/create-options.ts +55 -0
- package/skills/octocode-engineer/src/pipeline/health-score.test.ts +65 -0
- package/skills/{octocode-code-engineer → octocode-engineer}/src/pipeline/main.ts +130 -17
- package/skills/octocode-engineer/src/pipeline/progress.ts +51 -0
- package/skills/octocode-engineer/src/pipeline/reporters.test.ts +155 -0
- package/skills/octocode-engineer/src/pipeline/reporters.ts +64 -0
- package/skills/octocode-engineer/src/reporting/graph-features.test.ts +279 -0
- package/skills/{octocode-code-engineer → octocode-engineer}/src/reporting/output-contract.test.ts +6 -0
- package/skills/octocode-engineer/src/reporting/summary-md.test.ts +1066 -0
- package/skills/octocode-engineer/src/reporting/summary-md.ts +1604 -0
- package/skills/{octocode-code-engineer → octocode-engineer}/src/reporting/writer.ts +136 -13
- package/skills/octocode-engineer/src/run.ts +78 -0
- package/skills/{octocode-code-engineer → octocode-engineer}/src/sanity.test.ts +1 -1
- package/skills/octocode-engineer/src/types/analysis.ts +25 -0
- package/skills/octocode-engineer/src/types/collectors.ts +134 -0
- package/skills/{octocode-code-engineer → octocode-engineer}/src/types/constants.ts +75 -41
- package/skills/octocode-engineer/src/types/core.ts +203 -0
- package/skills/octocode-engineer/src/types/dependency.ts +215 -0
- package/skills/octocode-engineer/src/types/file-entry.ts +108 -0
- package/skills/octocode-engineer/src/types/findings.ts +105 -0
- package/skills/{octocode-code-engineer → octocode-engineer}/src/types/index.ts +60 -30
- package/skills/octocode-engineer/src/types/tree-sitter.ts +38 -0
- package/skills/{octocode-code-engineer → octocode-engineer}/tsconfig.json +1 -0
- package/skills/octocode-research/.octocode/scan/.cache/analysis-cache.json +1 -0
- package/skills/octocode-research/.octocode/scan/2026-03-22T10-32-27-073Z/architecture.json +1 -0
- package/skills/octocode-research/.octocode/scan/2026-03-22T10-32-27-073Z/ast-trees.txt +5566 -0
- package/skills/octocode-research/.octocode/scan/2026-03-22T10-32-27-073Z/code-quality.json +1 -0
- package/skills/octocode-research/.octocode/scan/2026-03-22T10-32-27-073Z/dead-code.json +1 -0
- package/skills/octocode-research/.octocode/scan/2026-03-22T10-32-27-073Z/file-inventory.json +1 -0
- package/skills/octocode-research/.octocode/scan/2026-03-22T10-32-27-073Z/findings.json +1 -0
- package/skills/octocode-research/.octocode/scan/2026-03-22T10-32-27-073Z/graph.md +189 -0
- package/skills/octocode-research/.octocode/scan/2026-03-22T10-32-27-073Z/security.json +1 -0
- package/skills/octocode-research/.octocode/scan/2026-03-22T10-32-27-073Z/summary.json +1 -0
- package/skills/octocode-research/.octocode/scan/2026-03-22T10-32-27-073Z/summary.md +265 -0
- package/skills/octocode-research/.octocode/scan/2026-03-22T10-40-10-469Z/architecture.json +1 -0
- package/skills/octocode-research/.octocode/scan/2026-03-22T10-40-10-469Z/ast-trees.txt +5555 -0
- package/skills/octocode-research/.octocode/scan/2026-03-22T10-40-10-469Z/code-quality.json +1 -0
- package/skills/octocode-research/.octocode/scan/2026-03-22T10-40-10-469Z/dead-code.json +1 -0
- package/skills/octocode-research/.octocode/scan/2026-03-22T10-40-10-469Z/file-inventory.json +1 -0
- package/skills/octocode-research/.octocode/scan/2026-03-22T10-40-10-469Z/findings.json +1 -0
- package/skills/octocode-research/.octocode/scan/2026-03-22T10-40-10-469Z/graph.md +190 -0
- package/skills/octocode-research/.octocode/scan/2026-03-22T10-40-10-469Z/security.json +1 -0
- package/skills/octocode-research/.octocode/scan/2026-03-22T10-40-10-469Z/summary.json +1 -0
- package/skills/octocode-research/.octocode/scan/2026-03-22T10-40-10-469Z/summary.md +265 -0
- package/skills/octocode-research/CHANGELOG.md +60 -0
- package/skills/octocode-research/README.md +102 -388
- package/skills/octocode-research/SKILL.md +169 -498
- package/skills/octocode-research/package.json +19 -31
- package/skills/octocode-research/references/PARALLEL_AGENT_PROTOCOL.md +19 -0
- package/skills/octocode-research/references/SESSION_MANAGEMENT.md +38 -0
- package/skills/octocode-research/scripts/server-init.js +1 -1
- package/skills/octocode-research/scripts/server.d.ts +2 -1
- package/skills/octocode-research/scripts/server.js +329 -233
- package/skills/octocode-research/src/__tests__/integration/promptsRoutes.test.ts +180 -0
- package/skills/octocode-research/src/__tests__/integration/serverHttp.test.ts +221 -0
- package/skills/octocode-research/src/__tests__/integration/serverLifecycle.test.ts +194 -0
- package/skills/octocode-research/src/__tests__/integration/toolsRoutes.test.ts +501 -0
- package/skills/octocode-research/src/__tests__/unit/readiness.test.ts +61 -0
- package/skills/octocode-research/src/__tests__/unit/resilience.test.ts +192 -0
- package/skills/octocode-research/src/__tests__/unit/responseFactory.test.ts +172 -0
- package/skills/octocode-research/src/__tests__/unit/responseParser.test.ts +288 -0
- package/skills/octocode-research/src/__tests__/unit/schemas.test.ts +509 -0
- package/skills/octocode-research/src/index.ts +4 -124
- package/skills/octocode-research/src/middleware/queryParser.ts +0 -26
- package/skills/octocode-research/src/routes/lsp.ts +58 -59
- package/skills/octocode-research/src/routes/package.ts +35 -65
- package/skills/octocode-research/src/routes/prompts.ts +3 -3
- package/skills/octocode-research/src/routes/tools.ts +8 -20
- package/skills/octocode-research/src/server-init.ts +30 -237
- package/skills/octocode-research/src/server.ts +50 -23
- package/skills/octocode-research/src/types/errorGuards.ts +9 -80
- package/skills/octocode-research/src/types/guards.ts +0 -28
- package/skills/octocode-research/src/types/mcp.ts +11 -66
- package/skills/octocode-research/src/types/responses.ts +11 -129
- package/skills/octocode-research/src/utils/circuitBreaker.ts +0 -21
- package/skills/octocode-research/src/utils/logger.ts +1 -97
- package/skills/octocode-research/src/utils/resilience.ts +2 -12
- package/skills/octocode-research/src/utils/responseFactory.ts +0 -42
- package/skills/octocode-research/src/utils/responseParser.ts +3 -25
- package/skills/octocode-research/src/utils/retry.ts +0 -63
- package/skills/octocode-research/src/utils/routeFactory.ts +1 -1
- package/skills/octocode-research/src/validation/httpPreprocess.ts +0 -3
- package/skills/octocode-research/src/validation/index.ts +0 -1
- package/skills/octocode-research/src/validation/schemas.ts +0 -63
- package/skills/octocode-research/src/validation/toolCallSchema.ts +3 -3
- package/skills/octocode-research/tsdown.config.ts +4 -0
- package/skills/octocode-research/vitest.config.ts +3 -0
- package/skills/octocode-code-engineer/.plan/VALIDATED_PLAN.md +0 -223
- package/skills/octocode-code-engineer/README.md +0 -178
- package/skills/octocode-code-engineer/SKILL.md +0 -418
- package/skills/octocode-code-engineer/minify-scripts.mjs +0 -32
- package/skills/octocode-code-engineer/references/agent-ast-reading-rfc.md +0 -95
- package/skills/octocode-code-engineer/references/architecture-techniques.md +0 -121
- package/skills/octocode-code-engineer/references/ast-search.md +0 -210
- package/skills/octocode-code-engineer/references/ast-tree-search.md +0 -151
- package/skills/octocode-code-engineer/references/concepts.md +0 -107
- package/skills/octocode-code-engineer/references/finding-categories.md +0 -128
- package/skills/octocode-code-engineer/references/improvement-roadmap.md +0 -304
- package/skills/octocode-code-engineer/references/playbooks.md +0 -204
- package/skills/octocode-code-engineer/references/present-results.md +0 -136
- package/skills/octocode-code-engineer/references/tool-workflows.md +0 -566
- package/skills/octocode-code-engineer/references/validate-investigate.md +0 -225
- package/skills/octocode-code-engineer/scripts/analysis/dependencies.js +0 -1
- package/skills/octocode-code-engineer/scripts/analysis/dependency-summary.js +0 -1
- package/skills/octocode-code-engineer/scripts/analysis/discovery.js +0 -1
- package/skills/octocode-code-engineer/scripts/analysis/graph-analytics.js +0 -1
- package/skills/octocode-code-engineer/scripts/analysis/semantic.js +0 -1
- package/skills/octocode-code-engineer/scripts/ast/helpers.js +0 -1
- package/skills/octocode-code-engineer/scripts/ast/metrics.js +0 -1
- package/skills/octocode-code-engineer/scripts/ast/search.js +0 -2
- package/skills/octocode-code-engineer/scripts/ast/tree-search.js +0 -2
- package/skills/octocode-code-engineer/scripts/ast/tree-sitter.js +0 -1
- package/skills/octocode-code-engineer/scripts/ast/ts-analyzer.js +0 -1
- package/skills/octocode-code-engineer/scripts/collectors/chains.js +0 -1
- package/skills/octocode-code-engineer/scripts/collectors/effects.js +0 -1
- package/skills/octocode-code-engineer/scripts/collectors/input-sources.js +0 -1
- package/skills/octocode-code-engineer/scripts/collectors/performance.js +0 -1
- package/skills/octocode-code-engineer/scripts/collectors/prototype-pollution.js +0 -1
- package/skills/octocode-code-engineer/scripts/collectors/security.js +0 -1
- package/skills/octocode-code-engineer/scripts/collectors/test-profile.js +0 -1
- package/skills/octocode-code-engineer/scripts/common/is-direct-run.js +0 -1
- package/skills/octocode-code-engineer/scripts/common/utils.js +0 -1
- package/skills/octocode-code-engineer/scripts/detectors/code-quality.js +0 -1
- package/skills/octocode-code-engineer/scripts/detectors/cohesion.js +0 -1
- package/skills/octocode-code-engineer/scripts/detectors/coupling.js +0 -1
- package/skills/octocode-code-engineer/scripts/detectors/cycle.js +0 -1
- package/skills/octocode-code-engineer/scripts/detectors/dead-code.js +0 -1
- package/skills/octocode-code-engineer/scripts/detectors/import-style.js +0 -1
- package/skills/octocode-code-engineer/scripts/detectors/index.js +0 -1
- package/skills/octocode-code-engineer/scripts/detectors/security.js +0 -1
- package/skills/octocode-code-engineer/scripts/detectors/semantic.js +0 -1
- package/skills/octocode-code-engineer/scripts/detectors/shared.js +0 -1
- package/skills/octocode-code-engineer/scripts/detectors/test-quality.js +0 -1
- package/skills/octocode-code-engineer/scripts/index.js +0 -1
- package/skills/octocode-code-engineer/scripts/pipeline/cache.js +0 -1
- package/skills/octocode-code-engineer/scripts/pipeline/cli.js +0 -1
- package/skills/octocode-code-engineer/scripts/pipeline/main.js +0 -2
- package/skills/octocode-code-engineer/scripts/reporting/analysis.js +0 -1
- package/skills/octocode-code-engineer/scripts/reporting/summary-md.js +0 -1
- package/skills/octocode-code-engineer/scripts/reporting/writer.js +0 -1
- package/skills/octocode-code-engineer/scripts/types/constants.js +0 -1
- package/skills/octocode-code-engineer/scripts/types/index.js +0 -1
- package/skills/octocode-code-engineer/scripts/types/interfaces.js +0 -1
- package/skills/octocode-code-engineer/src/analysis/dependencies.ts +0 -406
- package/skills/octocode-code-engineer/src/index.ts +0 -403
- package/skills/octocode-code-engineer/src/reporting/summary-md.test.ts +0 -421
- package/skills/octocode-code-engineer/src/reporting/summary-md.ts +0 -714
- package/skills/octocode-code-engineer/src/types/interfaces.ts +0 -682
- package/skills/octocode-research/src/types/toolTypes.ts +0 -33
- package/skills/octocode-research/src/utils/logEmoji.ts +0 -103
- /package/skills/{octocode-code-engineer → octocode-engineer}/.octocode/rfc/RFC-code-engineer-weakness-fixes.md +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/architecture.ts.html +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/ast-helpers.ts.html +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/ast-search.ts.html +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/base.css +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/block-navigation.js +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/cache.ts.html +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/cli.ts.html +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/clover.xml +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/collect-effects.ts.html +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/collect-input-sources.ts.html +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/collect-performance.ts.html +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/collect-prototype-pollution.ts.html +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/collect-security.ts.html +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/collect-test-profile.ts.html +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/coverage-final.json +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/dependencies.ts.html +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/dependency-summary.ts.html +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/discovery.ts.html +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/favicon.png +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/graph-analytics.ts.html +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/index.html +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/index.ts.html +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/metrics.ts.html +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/pipeline.ts.html +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/prettify.css +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/prettify.js +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/report-analysis.ts.html +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/report-writer.ts.html +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/security-detectors.ts.html +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/semantic-detectors.ts.html +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/semantic.ts.html +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/sort-arrow-sprite.png +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/sorter.js +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/summary-md.ts.html +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/test-quality-detectors.ts.html +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/tree-sitter-analyzer.ts.html +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/ts-analyzer.ts.html +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/types.ts.html +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/coverage/utils.ts.html +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/src/analysis/dependencies.test.ts +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/src/analysis/dependency-summary.test.ts +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/src/analysis/dependency-summary.ts +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/src/analysis/graph-analytics.test.ts +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/src/analysis/graph-analytics.ts +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/src/analysis/semantic.test.ts +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/src/analysis/semantic.ts +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/src/ast/helpers.test.ts +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/src/ast/helpers.ts +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/src/ast/metrics.test.ts +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/src/ast/metrics.ts +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/src/ast/tree-search.test.ts +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/src/ast/tree-search.ts +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/src/collectors/chains.ts +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/src/collectors/effects.test.ts +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/src/collectors/effects.ts +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/src/collectors/input-sources.test.ts +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/src/collectors/input-sources.ts +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/src/collectors/performance.test.ts +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/src/collectors/performance.ts +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/src/collectors/prototype-pollution.test.ts +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/src/collectors/prototype-pollution.ts +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/src/collectors/test-profile.test.ts +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/src/collectors/test-profile.ts +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/src/common/is-direct-run.test.ts +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/src/common/is-direct-run.ts +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/src/common/utils.test.ts +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/src/common/utils.ts +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/src/detectors/cohesion.ts +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/src/detectors/coupling.ts +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/src/detectors/cycle.ts +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/src/detectors/dead-code.ts +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/src/detectors/import-style.ts +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/src/detectors/index.test.ts +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/src/detectors/security.test.ts +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/src/detectors/security.ts +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/src/detectors/semantic.ts +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/src/detectors/shared.ts +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/src/detectors/test-quality.test.ts +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/src/detectors/test-quality.ts +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/src/pipeline/cache.test.ts +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/src/pipeline/cache.ts +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/src/pipeline/main.test.ts +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/src/pipeline.test.ts +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/src/reporting/analysis.test.ts +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/src/reporting/analysis.ts +0 -0
- /package/skills/{octocode-code-engineer → octocode-engineer}/vitest.config.ts +0 -0
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
# AST Search Reference
|
|
2
|
-
|
|
3
|
-
Structural code search powered by [`@ast-grep/napi`](https://ast-grep.github.io/). Finds code by AST shape, not text — `console.log(x)` matches regardless of whitespace or formatting.
|
|
4
|
-
|
|
5
|
-
```bash
|
|
6
|
-
node <SKILL_DIR>/scripts/ast/search.js [options]
|
|
7
|
-
```
|
|
8
|
-
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
## Search Modes
|
|
12
|
-
|
|
13
|
-
Pick one per invocation.
|
|
14
|
-
|
|
15
|
-
### Pattern (`-p`, `--pattern`)
|
|
16
|
-
|
|
17
|
-
Write the code shape. Replace variable parts with `$X` (one node) or `$$$X` (zero or more).
|
|
18
|
-
|
|
19
|
-
```bash
|
|
20
|
-
-p 'console.log($$$ARGS)' # all console.log
|
|
21
|
-
-p 'console.$METHOD($$$ARGS)' # any console method
|
|
22
|
-
-p 'if ($COND) { return $VAL }' # early returns
|
|
23
|
-
-p 'import { $$$NAMES } from $MOD' # named imports (any module)
|
|
24
|
-
-p 'export const $NAME = $VAL' # exported constants
|
|
25
|
-
-p 'process.env.$VAR' # env access
|
|
26
|
-
-p 'throw new Error($$$MSG)' # error throws
|
|
27
|
-
-p 'function $NAME($$$P) { $$$B }' # function declarations
|
|
28
|
-
-p 'const $NAME = ($$$P) => $BODY' # arrow assignments
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
Meta-variables captured in JSON output under `metaVariables`:
|
|
32
|
-
|
|
33
|
-
```json
|
|
34
|
-
{ "$METHOD": "log", "$$$ARGS": "\"hello\", 42" }
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
> **Quote sensitivity**: `'fs'` won't match `"fs"`. Use `$MOD` wildcard to match any quote style.
|
|
38
|
-
|
|
39
|
-
### Kind (`-k`, `--kind`)
|
|
40
|
-
|
|
41
|
-
Match all nodes of an AST kind.
|
|
42
|
-
|
|
43
|
-
```bash
|
|
44
|
-
-k function_declaration -k arrow_function -k class_declaration
|
|
45
|
-
-k interface_declaration -k type_alias_declaration -k import_statement
|
|
46
|
-
-k try_statement -k switch_statement -k for_in_statement
|
|
47
|
-
-k await_expression -k template_string -k object_pattern
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
> TS-only kinds (`predefined_type`, `interface_declaration`) are silently skipped on `.js` files.
|
|
51
|
-
|
|
52
|
-
### Preset (`--preset`)
|
|
53
|
-
|
|
54
|
-
16 built-in rules for common patterns. List with `--list-presets`.
|
|
55
|
-
|
|
56
|
-
| Preset | Finds |
|
|
57
|
-
|--------|-------|
|
|
58
|
-
| `empty-catch` | `catch (e) {}` — silently swallowed errors |
|
|
59
|
-
| `console-log` | `console.log(...)` left in production |
|
|
60
|
-
| `console-any` | Any `console.*()` call |
|
|
61
|
-
| `debugger` | `debugger;` statements |
|
|
62
|
-
| `todo-fixme` | TODO/FIXME/HACK/XXX/BUG comments |
|
|
63
|
-
| `any-type` | `: any` annotations (TS only) |
|
|
64
|
-
| `type-assertion` | `x as Type` assertions |
|
|
65
|
-
| `non-null-assertion` | `x!` non-null assertions |
|
|
66
|
-
| `fat-arrow-body` | `() => { return x }` — could be expression |
|
|
67
|
-
| `nested-ternary` | `a ? (b ? 1 : 2) : 3` |
|
|
68
|
-
| `throw-string` | `throw "oops"` — should be Error |
|
|
69
|
-
| `switch-no-default` | `switch` without `default` |
|
|
70
|
-
| `class-declaration` | All class declarations |
|
|
71
|
-
| `async-function` | `async function` declarations |
|
|
72
|
-
| `export-default` | `export default` statements |
|
|
73
|
-
| `import-star` | `import * as X` namespace imports |
|
|
74
|
-
|
|
75
|
-
### Rule (`--rule`)
|
|
76
|
-
|
|
77
|
-
Raw ast-grep rule JSON. Use for negation, regex, or nested structural queries.
|
|
78
|
-
|
|
79
|
-
```bash
|
|
80
|
-
# Negation: if without else
|
|
81
|
-
--rule '{"rule":{"kind":"if_statement","not":{"has":{"kind":"else_clause"}}}}'
|
|
82
|
-
|
|
83
|
-
# Regex on text: secrets in strings
|
|
84
|
-
--rule '{"rule":{"kind":"string","regex":"password|secret|token|api.?key"}}'
|
|
85
|
-
|
|
86
|
-
# Nested: try with finally
|
|
87
|
-
--rule '{"rule":{"kind":"try_statement","has":{"kind":"finally_clause","stopBy":"end"}}}'
|
|
88
|
-
|
|
89
|
-
# Long param lists
|
|
90
|
-
--rule '{"rule":{"kind":"formal_parameters","regex":"(,.*){5,}"}}'
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
**Rule operators:**
|
|
94
|
-
|
|
95
|
-
| Operator | Purpose | Example |
|
|
96
|
-
|----------|---------|---------|
|
|
97
|
-
| `kind` | Match node kind | `{"kind":"catch_clause"}` |
|
|
98
|
-
| `pattern` | Match code shape | `{"pattern":"console.log($$$A)"}` |
|
|
99
|
-
| `regex` | Match node text | `{"regex":"TODO\|FIXME"}` |
|
|
100
|
-
| `has` | Child matches rule | `{"has":{"kind":"finally_clause"}}` |
|
|
101
|
-
| `not` | Negate | `{"not":{"has":{"kind":"else_clause"}}}` |
|
|
102
|
-
| `all` | AND | `{"all":[{"kind":"X"},{"regex":"Y"}]}` |
|
|
103
|
-
| `any` | OR | `{"any":[{"kind":"X"},{"kind":"Y"}]}` |
|
|
104
|
-
| `stopBy: "end"` | Search descendants (not just direct children) | `{"has":{"kind":"X","stopBy":"end"}}` |
|
|
105
|
-
| `field` | Match by grammar field | `{"has":{"field":"default"}}` |
|
|
106
|
-
|
|
107
|
-
---
|
|
108
|
-
|
|
109
|
-
## CLI Reference
|
|
110
|
-
|
|
111
|
-
```
|
|
112
|
-
node scripts/ast/search.js [options]
|
|
113
|
-
|
|
114
|
-
Search (pick one):
|
|
115
|
-
-p, --pattern <code> Code shape with $X/$$$X wildcards
|
|
116
|
-
-k, --kind <name> AST node kind
|
|
117
|
-
--preset <name> Built-in rule (see --list-presets)
|
|
118
|
-
--rule <json> Raw ast-grep rule JSON
|
|
119
|
-
|
|
120
|
-
Options:
|
|
121
|
-
--root <path> Search directory (default: cwd)
|
|
122
|
-
--json JSON output (use for programmatic consumption)
|
|
123
|
-
--limit N Max matches (default: 500)
|
|
124
|
-
--include-tests Include *.test.*, *.spec.*, __tests__/
|
|
125
|
-
-C, --context N Context lines around matches (text mode only)
|
|
126
|
-
--list-presets List presets and exit
|
|
127
|
-
-h, --help Show help
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
| Flag | Default | Notes |
|
|
131
|
-
|------|---------|-------|
|
|
132
|
-
| `--root` | cwd | Relative or absolute |
|
|
133
|
-
| `--json` | off | Outputs `AstSearchResult` — always use for agent consumption |
|
|
134
|
-
| `--limit` | 500 | Global cap across all files |
|
|
135
|
-
| `--include-tests` | off | Test files excluded by default |
|
|
136
|
-
| `--context` | 0 | Shows source lines around matches with `>` marker |
|
|
137
|
-
|
|
138
|
-
**Scanned**: `.ts`, `.tsx`, `.js`, `.jsx`, `.mjs`, `.cjs` (excludes `.d.ts`)
|
|
139
|
-
|
|
140
|
-
**Skipped dirs**: `.git`, `.next`, `.yarn`, `.cache`, `.octocode`, `node_modules`, `dist`, `coverage`, `out`
|
|
141
|
-
|
|
142
|
-
---
|
|
143
|
-
|
|
144
|
-
## Output
|
|
145
|
-
|
|
146
|
-
### Text (default)
|
|
147
|
-
|
|
148
|
-
```
|
|
149
|
-
🔍 preset:empty-catch — Empty catch blocks that silently swallow errors
|
|
150
|
-
3 matches across 2 files
|
|
151
|
-
|
|
152
|
-
── packages/core/src/parser.ts ──
|
|
153
|
-
L42:4 [catch_clause] catch (e) { }
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
### Text with `--context 2`
|
|
157
|
-
|
|
158
|
-
```
|
|
159
|
-
── src/index.ts ──
|
|
160
|
-
896 | for (const [key, file] of Object.entries(outputFiles)) {
|
|
161
|
-
897 | let size = '—';
|
|
162
|
-
> 898 | try { size = formatFileSize(fs.statSync(path.join(dir, file)).size); } catch {}
|
|
163
|
-
899 | lines.push(...);
|
|
164
|
-
900 | }
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
### JSON (`--json`)
|
|
168
|
-
|
|
169
|
-
```json
|
|
170
|
-
{
|
|
171
|
-
"query": "preset:empty-catch — ...",
|
|
172
|
-
"queryType": "preset",
|
|
173
|
-
"totalMatches": 3,
|
|
174
|
-
"totalFiles": 2,
|
|
175
|
-
"matches": [{
|
|
176
|
-
"file": "packages/core/src/parser.ts",
|
|
177
|
-
"kind": "catch_clause",
|
|
178
|
-
"text": "catch (e) { }",
|
|
179
|
-
"lineStart": 42, "lineEnd": 42,
|
|
180
|
-
"columnStart": 4, "columnEnd": 18,
|
|
181
|
-
"metaVariables": {}
|
|
182
|
-
}]
|
|
183
|
-
}
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
---
|
|
187
|
-
|
|
188
|
-
## Agent Guide
|
|
189
|
-
|
|
190
|
-
### Decision Tree
|
|
191
|
-
|
|
192
|
-
```
|
|
193
|
-
"Find all X() calls" → -p 'X($$$ARGS)'
|
|
194
|
-
"Find all X nodes" → -k X_kind_name
|
|
195
|
-
"Known code smell" → --preset name
|
|
196
|
-
"Negation / regex / nesting" → --rule '{...}'
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
### Rules for Agents
|
|
200
|
-
|
|
201
|
-
1. **Always `--json`** for programmatic use. Parse `totalMatches`, iterate `matches[]`.
|
|
202
|
-
2. **Start narrow**: `--limit 10 --root <specific-dir>` before broad search.
|
|
203
|
-
3. **Chain with scan**: `index.js` flags `unsafe-any` → `--preset any-type --root <pkg>`.
|
|
204
|
-
4. **Use `$MOD`** for imports — avoids quote mismatch.
|
|
205
|
-
5. **`--rule` for negation** — patterns can't express "X without Y".
|
|
206
|
-
6. **`stopBy: "end"`** required for recursive `has` (descendant search, not just children).
|
|
207
|
-
7. **Grammar-safe**: TS-only kinds silently skipped on JS files.
|
|
208
|
-
8. **`--include-tests`** for `describe`, `it`, `expect` patterns.
|
|
209
|
-
9. **Meta-variables** appear in JSON — extract captured `$NAME`, `$MOD`, `$$$ARGS`.
|
|
210
|
-
10. **`-C N`** for context — shows N lines before/after matches in text mode.
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
# AST Tree Search
|
|
2
|
-
|
|
3
|
-
Use `ast/tree-search.js` to inspect the generated `ast-trees.txt` artifact from one specific scan.
|
|
4
|
-
|
|
5
|
-
This is the canonical way to read AST snapshot output for agents because it keeps the search pinned to the current scan and bounds noisy output by default.
|
|
6
|
-
|
|
7
|
-
## When to Use It
|
|
8
|
-
|
|
9
|
-
- use it after reading `summary.md` when you want fast structure-first triage
|
|
10
|
-
- use it before `ast/search.js` when you are still deciding which file deserves deeper source-level inspection
|
|
11
|
-
- use it to narrow by node kind, file, or section without accidentally reading a different scan
|
|
12
|
-
|
|
13
|
-
Do not use it as proof of live-code behavior. After artifact triage, validate important claims with Octocode local and LSP tools, or with `ast/search.js` for structural confirmation.
|
|
14
|
-
|
|
15
|
-
## What `ast-trees.txt` Looks Like
|
|
16
|
-
|
|
17
|
-
Each file gets a `## package — path` header. Nodes are `Kind[startLine:endLine]`, nesting = indentation. Truncated subtrees end with `...`.
|
|
18
|
-
|
|
19
|
-
```
|
|
20
|
-
## my-package — src/services/storage.ts
|
|
21
|
-
SourceFile[1:152]
|
|
22
|
-
ImportDeclaration[1:3]
|
|
23
|
-
FunctionDeclaration[10:45]
|
|
24
|
-
Block[11:44]
|
|
25
|
-
IfStatement[12:20] ...
|
|
26
|
-
ReturnStatement[43]
|
|
27
|
-
ExportDeclaration[50:52]
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
This tells you: `storage.ts` has a function spanning lines 10-45 with a conditional inside it. Use this to decide which files and functions deserve source-level inspection.
|
|
31
|
-
|
|
32
|
-
## Usage
|
|
33
|
-
|
|
34
|
-
```bash
|
|
35
|
-
node <SKILL_DIR>/scripts/ast/tree-search.js [options]
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
Core options:
|
|
39
|
-
|
|
40
|
-
- `--input, -i <path>`: `ast-trees.txt`, a timestamped scan directory, or the scan root
|
|
41
|
-
- `--kind, -k <kind>`: match node kinds such as `function_declaration` or `ClassDeclaration`
|
|
42
|
-
- `--pattern, -p <regex>`: regex against AST tree lines
|
|
43
|
-
- `--file <regex>`: filter to section file paths that match the regex
|
|
44
|
-
- `--section <regex>`: filter to section headers that match the regex
|
|
45
|
-
- `--limit <n>`: default `50`; use `0` for all matches
|
|
46
|
-
- `--context, -C <n>`: include surrounding lines
|
|
47
|
-
- `--json`: machine-readable output
|
|
48
|
-
- `--ignore-case`: case-insensitive matching
|
|
49
|
-
|
|
50
|
-
## Input Resolution
|
|
51
|
-
|
|
52
|
-
The `-i` flag accepts three kinds of input, resolved automatically:
|
|
53
|
-
|
|
54
|
-
| Input | What happens | Selection mode |
|
|
55
|
-
|-------|-------------|----------------|
|
|
56
|
-
| Path to `ast-trees.txt` file | Uses that file directly | `direct-file` |
|
|
57
|
-
| Path to a scan directory (e.g., `.octocode/scan/2026-03-19T00-01-19-468Z`) | Looks for `ast-trees.txt` inside it | `scan-dir` |
|
|
58
|
-
| Path to scan root (e.g., `.octocode/scan`) | Finds the latest timestamped directory with an `ast-trees.txt` | `latest-scan` |
|
|
59
|
-
|
|
60
|
-
Default when `-i` is omitted: `.octocode/scan` (resolves to latest scan automatically).
|
|
61
|
-
|
|
62
|
-
## Recommended Flow
|
|
63
|
-
|
|
64
|
-
1. Start from `<CURRENT_SCAN>/ast-trees.txt` or just pass `-i .octocode/scan` for the latest.
|
|
65
|
-
2. Run a bounded query with `--limit 25` or smaller.
|
|
66
|
-
3. Narrow with `--file` or `--section` once you know the suspicious area.
|
|
67
|
-
4. Switch to `ast/search.js` when you need source-level structural matching.
|
|
68
|
-
5. Validate final claims with Octocode local and LSP tools.
|
|
69
|
-
|
|
70
|
-
## Examples
|
|
71
|
-
|
|
72
|
-
```bash
|
|
73
|
-
# Find all function declarations (latest scan)
|
|
74
|
-
node <SKILL_DIR>/scripts/ast/tree-search.js -i .octocode/scan -k function_declaration --limit 25
|
|
75
|
-
|
|
76
|
-
# Find classes in a specific file
|
|
77
|
-
node <SKILL_DIR>/scripts/ast/tree-search.js -i <CURRENT_SCAN>/ast-trees.txt --file 'src/report' -k class_declaration --limit 10
|
|
78
|
-
|
|
79
|
-
# Find control flow nodes
|
|
80
|
-
node <SKILL_DIR>/scripts/ast/tree-search.js -i <CURRENT_SCAN>/ast-trees.txt -p 'IfStatement|SwitchStatement|ForStatement|WhileStatement' --limit 25
|
|
81
|
-
|
|
82
|
-
# JSON output for programmatic use
|
|
83
|
-
node <SKILL_DIR>/scripts/ast/tree-search.js -i <CURRENT_SCAN>/ast-trees.txt --section 'src/services' -k function_declaration --json
|
|
84
|
-
|
|
85
|
-
# With context lines to see surrounding tree structure
|
|
86
|
-
node <SKILL_DIR>/scripts/ast/tree-search.js -i .octocode/scan -k function_declaration -C 2 --limit 10
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
## Output
|
|
90
|
-
|
|
91
|
-
### Text (default)
|
|
92
|
-
|
|
93
|
-
```
|
|
94
|
-
AST tree search: kind=function_declaration
|
|
95
|
-
Requested input: /path/to/.octocode/scan
|
|
96
|
-
Selected AST file: /path/to/.octocode/scan/2026-03-19T00-01-19-468Z/ast-trees.txt (latest-scan)
|
|
97
|
-
Matches: 42 total, showing 10 (limit 10)
|
|
98
|
-
Matched files: 5
|
|
99
|
-
|
|
100
|
-
-- my-package — src/services/storage.ts --
|
|
101
|
-
L14 (src/services/storage.ts) FunctionDeclaration[10:45]
|
|
102
|
-
L68 (src/services/storage.ts) FunctionDeclaration[50:80]
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
### Text with `--context 2`
|
|
106
|
-
|
|
107
|
-
```
|
|
108
|
-
-- my-package — src/services/storage.ts --
|
|
109
|
-
12 | ImportDeclaration[1:3]
|
|
110
|
-
13 | ExportDeclaration[5:8]
|
|
111
|
-
> 14 | FunctionDeclaration[10:45]
|
|
112
|
-
15 | ExportKeyword[10]
|
|
113
|
-
16 | Identifier[10]
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
### JSON (`--json`)
|
|
117
|
-
|
|
118
|
-
```json
|
|
119
|
-
{
|
|
120
|
-
"requestedInput": "/path/to/.octocode/scan",
|
|
121
|
-
"inputFile": "/path/to/.octocode/scan/2026-03-19T.../ast-trees.txt",
|
|
122
|
-
"selectionMode": "latest-scan",
|
|
123
|
-
"query": "kind=function_declaration",
|
|
124
|
-
"limit": 25,
|
|
125
|
-
"totalMatches": 42,
|
|
126
|
-
"returnedMatches": 25,
|
|
127
|
-
"truncated": true,
|
|
128
|
-
"uniqueFiles": 5,
|
|
129
|
-
"matches": [{
|
|
130
|
-
"section": "my-package — src/services/storage.ts",
|
|
131
|
-
"file": "src/services/storage.ts",
|
|
132
|
-
"lineNumber": 14,
|
|
133
|
-
"line": " FunctionDeclaration[10:45]",
|
|
134
|
-
"context": [{ "lineNumber": 14, "line": " FunctionDeclaration[10:45]" }]
|
|
135
|
-
}]
|
|
136
|
-
}
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
Use `totalMatches` vs `returnedMatches` to know if results are truncated. Use `selectionMode` to confirm which scan was selected.
|
|
140
|
-
|
|
141
|
-
## Difference from `ast/search.js`
|
|
142
|
-
|
|
143
|
-
| | `ast/tree-search.js` | `ast/search.js` |
|
|
144
|
-
|---|---|---|
|
|
145
|
-
| **Searches** | Generated `ast-trees.txt` artifact | Actual source files on disk |
|
|
146
|
-
| **Powered by** | Regex / kind matching on text | `@ast-grep/napi` structural matching |
|
|
147
|
-
| **Input** | `-i <scan-path>` | `--root <source-dir>` |
|
|
148
|
-
| **Best for** | Quick triage — find where to look | Proof — confirm a code pattern exists |
|
|
149
|
-
| **Proves behavior** | No — artifact only | Partial — structural shape, not runtime |
|
|
150
|
-
|
|
151
|
-
Use `ast/tree-search.js` to decide where to look. Use `ast/search.js` to prove a source-level structural pattern exists.
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
# Concepts — Metric Definitions
|
|
2
|
-
|
|
3
|
-
## Instability (SDP)
|
|
4
|
-
|
|
5
|
-
**Formula**: `I = Ce / (Ca + Ce)` where Ca = inbound (afferent) coupling, Ce = outbound (efferent) coupling.
|
|
6
|
-
|
|
7
|
-
**Range**: 0 (maximally stable) to 1 (maximally unstable).
|
|
8
|
-
|
|
9
|
-
**Threshold**: An SDP violation fires when a stable module (I < 0.5) depends on a more unstable module with delta > 0.15. Delta > 0.3 = high severity.
|
|
10
|
-
|
|
11
|
-
**Interpretation**: I=0 means everything depends on this module and it depends on nothing — changing it breaks many consumers. I=1 means it depends on many modules but nothing depends on it — safe to change. Violations mean a hard-to-change module depends on an easy-to-change one, creating fragility.
|
|
12
|
-
|
|
13
|
-
**Example**: Module A (I=0.2, 8 importers, 2 imports) depends on module B (I=0.8, 1 importer, 4 imports). Delta=0.6. Fix: extract an interface in A that B implements.
|
|
14
|
-
|
|
15
|
-
## Cognitive Complexity
|
|
16
|
-
|
|
17
|
-
**Formula**: Each `if`/`for`/`while`/`switch`/`catch`/`&&`/`||` adds +1. Each nesting level adds +1 more per construct inside it.
|
|
18
|
-
|
|
19
|
-
**Default threshold**: 15. Above 15 = flagged.
|
|
20
|
-
|
|
21
|
-
**Interpretation**: Unlike cyclomatic complexity, cognitive complexity penalizes deeply nested code much more heavily. A flat chain of 10 `if` statements scores 10, but 5 nested `if` blocks score 5+4+3+2+1=15.
|
|
22
|
-
|
|
23
|
-
**Example**: A function with cognitive complexity 42 has deeply nested branches. Target: refactor to <15 by extracting guard clauses, breaking into helper functions, or using early returns.
|
|
24
|
-
|
|
25
|
-
## Halstead Metrics
|
|
26
|
-
|
|
27
|
-
**Formula**: Volume = Length × log₂(Vocabulary). Effort = Volume × Difficulty. Difficulty = (distinctOperators/2) × (totalOperands/distinctOperands).
|
|
28
|
-
|
|
29
|
-
**Default threshold**: Effort > 500,000 triggers a finding.
|
|
30
|
-
|
|
31
|
-
**Interpretation**: Effort estimates the mental effort to understand or recreate the code. Volume measures information content. EstimatedBugs = Volume / 3000 gives a rough bug prediction.
|
|
32
|
-
|
|
33
|
-
**Example**: A 200-line function with effort 1,200,000 is ~2.4× the threshold — it likely needs decomposition into 3-4 smaller functions each under 500K effort.
|
|
34
|
-
|
|
35
|
-
## Maintainability Index
|
|
36
|
-
|
|
37
|
-
**Formula**: `MI = 171 - 5.2×ln(Volume) - 0.23×CC - 16.2×ln(LOC)`, rescaled to 0-100.
|
|
38
|
-
|
|
39
|
-
**Default threshold**: MI < 20 triggers a finding.
|
|
40
|
-
|
|
41
|
-
**Interpretation**: >65 = highly maintainable. 40-65 = moderate. 20-40 = difficult. <20 = very difficult to maintain. The index combines volume, complexity, and size into one number.
|
|
42
|
-
|
|
43
|
-
**Example**: MI=12 on a 300-line function means it's in the danger zone. Splitting it into 4 focused helpers of ~75 lines each would likely push each above MI=40.
|
|
44
|
-
|
|
45
|
-
## Abstractness (A)
|
|
46
|
-
|
|
47
|
-
**Formula**: `A = abstractExports / totalExports` — share of exports that are types/interfaces.
|
|
48
|
-
|
|
49
|
-
**Range**: 0 (fully concrete) to 1 (fully abstract).
|
|
50
|
-
|
|
51
|
-
**Interpretation**: Combined with Instability to compute Distance from Main Sequence.
|
|
52
|
-
|
|
53
|
-
**Example**: A module with 10 exports, 3 of which are types → A = 0.3.
|
|
54
|
-
|
|
55
|
-
## Distance from Main Sequence (D)
|
|
56
|
-
|
|
57
|
-
**Formula**: `D = |A + I - 1|` where A = Abstractness, I = Instability.
|
|
58
|
-
|
|
59
|
-
**Default thresholds**: D > 0.7 (and module has minimum coupling) triggers a finding. Severity high if D > 0.8.
|
|
60
|
-
|
|
61
|
-
**Interpretation**: D = 0 means the module sits on the "main sequence" (balanced abstraction vs. stability). High D means the module is either in the **Zone of Pain** (concrete + stable = hard to change) or **Zone of Uselessness** (abstract + unstable = unused abstractions).
|
|
62
|
-
|
|
63
|
-
**Example**: Module with I=0.1, A=0.1 → D = |0.1 + 0.1 - 1| = 0.8 (Zone of Pain). Fix: add abstractions or reduce inbound coupling.
|
|
64
|
-
|
|
65
|
-
## Hot-File Risk Score
|
|
66
|
-
|
|
67
|
-
**Formula**: `risk = fanIn * 3 + complexity + fanOut + (onCriticalPath ? 100 : 0) + (inCycle ? 50 : 0)`
|
|
68
|
-
|
|
69
|
-
**Interpretation**: Ranks files by danger-to-change. High fan-in means many consumers break. High complexity means the file itself is fragile. Critical path and cycle membership amplify risk.
|
|
70
|
-
|
|
71
|
-
**Example**: `types/index.ts` with fanIn=54, complexity=1 → risk = 54*3 + 1 + 2 + 100 = 265. The highest risk files are the most important to keep stable and well-tested.
|
|
72
|
-
|
|
73
|
-
## Low Cohesion (LCOM)
|
|
74
|
-
|
|
75
|
-
**Method**: For each file, compare the set of imports used by each export. If exports share few common dependencies, the file has low cohesion — its exports serve unrelated purposes.
|
|
76
|
-
|
|
77
|
-
**Default thresholds**: minExports ≥ 3, internal dependencies from 3+ distinct groups.
|
|
78
|
-
|
|
79
|
-
**Interpretation**: A file with low cohesion is doing multiple jobs and should be split. LCOM > 1 suggests the module boundary is wrong.
|
|
80
|
-
|
|
81
|
-
**Example**: `utils.ts` exports `parseDate()`, `formatCurrency()`, and `validateEmail()` — each uses different imports and serves a different domain. Split into `date-utils.ts`, `currency-utils.ts`, `validation-utils.ts`.
|
|
82
|
-
|
|
83
|
-
## Cyclomatic Density
|
|
84
|
-
|
|
85
|
-
**Formula**: `CC / LOC` (cyclomatic complexity divided by lines of code).
|
|
86
|
-
|
|
87
|
-
**Note**: Not used as a standalone finding category. Cyclomatic complexity is folded into the `function-optimization` detector and the Maintainability Index calculation.
|
|
88
|
-
|
|
89
|
-
**Interpretation**: Density > 0.5 means on average every other line is a branch point. The code is almost entirely control flow with minimal straight-line logic.
|
|
90
|
-
|
|
91
|
-
**Example**: A function with CC=30 and LOC=45 has density 0.67 — nearly pure branching logic. Consider extracting branch groups into named helpers or using lookup tables.
|
|
92
|
-
|
|
93
|
-
## Reachability
|
|
94
|
-
|
|
95
|
-
**Method**: BFS from entrypoints (`index`, `main`, `app`, `server`, `cli`, `public`, `*.config.*`). Files not reached are flagged as `unreachable-module`.
|
|
96
|
-
|
|
97
|
-
**Interpretation**: Stricter than orphan-module detection (which only checks for zero inbound imports). A file may have importers but still be unreachable from any entrypoint if its entire import subtree is disconnected.
|
|
98
|
-
|
|
99
|
-
**Example**: `utils/legacy-helper.ts` has 2 importers, but both importers are also unreachable from any entrypoint — the entire cluster is dead code.
|
|
100
|
-
|
|
101
|
-
## Package Boundaries
|
|
102
|
-
|
|
103
|
-
**Rule**: `packages/A/` should import from `packages/B/src/index.ts` (public API), never `packages/B/src/internal/bar.ts`.
|
|
104
|
-
|
|
105
|
-
**Interpretation**: Crossing into another package's internal modules creates tight coupling that bypasses the package's public contract. Changes to internals can break consumers silently.
|
|
106
|
-
|
|
107
|
-
**Example**: `packages/cli/src/run.ts` imports `packages/core/src/internal/parser.ts` instead of using the public `packages/core/src/index.ts` re-export. Fix: add the needed symbol to core's public API or restructure the dependency.
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
# Finding Categories
|
|
2
|
-
|
|
3
|
-
All categories detected by the scan, grouped by pillar. Categories marked `--semantic` require the `--semantic` flag.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## Architecture Risk
|
|
8
|
-
|
|
9
|
-
| Category | Severity | Detects | Requires |
|
|
10
|
-
|----------|----------|---------|----------|
|
|
11
|
-
| `dependency-cycle` | high | Circular import chains | — |
|
|
12
|
-
| `dependency-critical-path` | high — critical | High-weight transitive dependency chains | — |
|
|
13
|
-
| `dependency-test-only` | medium | Production modules imported only from tests | — |
|
|
14
|
-
| `architecture-sdp-violation` | medium — high | Stable module depends on unstable module (I = Ce/(Ca+Ce)) | — |
|
|
15
|
-
| `high-coupling` | medium — high | Excessive Ca + Ce connections | — |
|
|
16
|
-
| `god-module-coupling` | medium — high | High fan-in (bottleneck) or fan-out (sprawl) | — |
|
|
17
|
-
| `mega-folder` | medium | Directory with excessive file count | — |
|
|
18
|
-
| `orphan-module` | medium | Zero inbound AND zero outbound dependencies | — |
|
|
19
|
-
| `unreachable-module` | high | Not reachable from any entrypoint via BFS | — |
|
|
20
|
-
| `layer-violation` | high | Import backwards in configured layer order | — |
|
|
21
|
-
| `low-cohesion` | medium — high | Exports serve unrelated purposes (LCOM > 1) | — |
|
|
22
|
-
| `distance-from-main-sequence` | medium — high | Module far from A + I = 1 (Zone of Pain / Uselessness) | — |
|
|
23
|
-
| `feature-envy` | medium — high | Module imports 60%+ symbols from single external module | — |
|
|
24
|
-
| `untested-critical-code` | high — critical | Hot/critical-path file with zero test imports | — |
|
|
25
|
-
| `cycle-cluster` | medium — high | Strongly connected file cluster large enough to behave like one tangled subsystem | — |
|
|
26
|
-
| `broker-module` | medium — high | Module concentrates graph pressure across fan-in, fan-out, articulation, or critical-path signals | — |
|
|
27
|
-
| `bridge-module` | medium — high | Structural articulation point or bridge between subsystems | — |
|
|
28
|
-
| `package-boundary-chatter` | medium — high | Excessive cross-package dependency edges between two package groups | — |
|
|
29
|
-
| `startup-risk-hub` | medium — high | Import-time side effects on a high fan-in structural hub | — |
|
|
30
|
-
| `over-abstraction` | medium | Interface/abstract class with exactly 1 implementor | `--semantic` |
|
|
31
|
-
| `concrete-dependency` | medium | Import resolves to concrete class (DIP violation) | `--semantic` |
|
|
32
|
-
| `circular-type-dependency` | high | Type A references Type B, B references A (type-level cycle) | `--semantic` |
|
|
33
|
-
| `shotgun-surgery` | medium — high | Export referenced from 8+ unique files (change amplification risk) | `--semantic` |
|
|
34
|
-
| `import-side-effect-risk` | low — critical | Module executes risky work at import time (sync I/O, exec, eval, timers, listeners); scored by AST evidence + architecture context (fan-in, critical path, cycle, entry role) | — |
|
|
35
|
-
| `namespace-import` | medium | Namespace import (`import * as X`) pulling in entire module surface | — |
|
|
36
|
-
| `commonjs-in-esm` | medium | CommonJS `require()` in an ESM-style codebase | — |
|
|
37
|
-
| `export-star-leak` | medium — high | `export * from` re-exports leaking internal symbols | — |
|
|
38
|
-
| `mixed-module-format` | medium | File mixes CommonJS and ESM syntax | — |
|
|
39
|
-
|
|
40
|
-
---
|
|
41
|
-
|
|
42
|
-
## Code Quality
|
|
43
|
-
|
|
44
|
-
| Category | Severity | Detects | Requires |
|
|
45
|
-
|----------|----------|---------|----------|
|
|
46
|
-
| `duplicate-function-body` | low — high | Identical function implementations across files | — |
|
|
47
|
-
| `duplicate-flow-structure` | medium — high | Repeated control-flow patterns | — |
|
|
48
|
-
| `similar-function-body` | medium — high | Near-clone functions (Type-2: renamed vars, different literals) | — |
|
|
49
|
-
| `function-optimization` | medium — high | High complexity, deep nesting, oversized functions | — |
|
|
50
|
-
| `cognitive-complexity` | medium — high | Nesting-aware complexity score | — |
|
|
51
|
-
| `god-module` | high | Files with excessive statements or exports | — |
|
|
52
|
-
| `god-function` | high | Functions with excessive statements | — |
|
|
53
|
-
| `halstead-effort` | medium — high | Halstead effort > threshold or estimated bugs > 2.0 | — |
|
|
54
|
-
| `low-maintainability` | high — critical | Maintainability Index below threshold | — |
|
|
55
|
-
| `excessive-parameters` | medium — high | Function exceeds parameter threshold | — |
|
|
56
|
-
| `unsafe-any` | medium — high | Excessive `any` types | — |
|
|
57
|
-
| `empty-catch` | medium | Empty catch block | — |
|
|
58
|
-
| `switch-no-default` | low | Switch missing default case | — |
|
|
59
|
-
| `type-assertion-escape` | medium — high | `as any`, `as unknown as T`, non-null `!` assertions | — |
|
|
60
|
-
| `missing-error-boundary` | low — high | Async function with await(s) but no try-catch or `.catch()` handler; severity tiers: 1 await = low, 2-3 = medium, 4+ = high | — |
|
|
61
|
-
| `promise-misuse` | medium | `async` function that never uses `await` | — |
|
|
62
|
-
| `await-in-loop` | high | await inside loop body — sequential async (N+1 latency) | — |
|
|
63
|
-
| `sync-io` | medium | Synchronous I/O calls (readFileSync, execSync, etc.) | — |
|
|
64
|
-
| `uncleared-timer` | medium | setInterval without clearInterval in scope | — |
|
|
65
|
-
| `listener-leak-risk` | medium | Event listeners added without corresponding removal | — |
|
|
66
|
-
| `unbounded-collection` | low | Collection growth inside nested loops without size guard | — |
|
|
67
|
-
| `unused-parameter` | medium | Function parameter never referenced in body (semantic) | `--semantic` |
|
|
68
|
-
| `deep-override-chain` | medium — high | Method overridden beyond depth threshold in class hierarchy | `--semantic` |
|
|
69
|
-
| `interface-compliance` | medium — high | Class `implements I` with missing or any-cast members | `--semantic` |
|
|
70
|
-
| `narrowable-type` | low | Parameter declared broad but all callers pass narrow type | `--semantic` |
|
|
71
|
-
| `message-chain` | medium — high | Property-access chains of depth ≥ 4 (`a.b.c.d`) violating the Law of Demeter. Medium at depth 4–5; high at depth ≥ 6. Deep chains tightly couple the caller to intermediate object structure | — |
|
|
72
|
-
|
|
73
|
-
---
|
|
74
|
-
|
|
75
|
-
## Dead Code & Hygiene
|
|
76
|
-
|
|
77
|
-
| Category | Severity | Detects | Requires |
|
|
78
|
-
|----------|----------|---------|----------|
|
|
79
|
-
| `dead-export` | medium — high | Exported symbol with no usage (import matching) | — |
|
|
80
|
-
| `dead-re-export` | medium | Barrel re-export with no consumers | — |
|
|
81
|
-
| `re-export-duplication` | medium | Same symbol re-exported from multiple paths | — |
|
|
82
|
-
| `re-export-shadowed` | high | Local export and re-export name collision | — |
|
|
83
|
-
| `unused-npm-dependency` | low — medium | package.json dep not imported anywhere | — |
|
|
84
|
-
| `package-boundary-violation` | medium — high | Cross-package import bypassing public API | — |
|
|
85
|
-
| `barrel-explosion` | medium — high | Barrel with excessive re-exports or chain depth | — |
|
|
86
|
-
| `redundant-re-export` | low — medium | *(planned)* Barrel re-export with 0 consumers through the barrel path; includes `export *` where <50% of symbols are consumed | — |
|
|
87
|
-
| `redundant-comment` | low | *(planned)* Comment that restates what the code already says (narrating patterns: `// Import`, `// Define`, `// Return`, `// Set`, `// Get`, `// Handle`, `// Create`, etc.) | — |
|
|
88
|
-
| `unused-import` | low | Imported symbol never semantically used (TypeChecker confirmed) | `--semantic` |
|
|
89
|
-
| `orphan-implementation` | medium | Exported class with no external references and no interface | `--semantic` |
|
|
90
|
-
| `move-to-caller` | low | Exported symbol consumed by exactly 1 file (candidate for inlining) | `--semantic` |
|
|
91
|
-
| `semantic-dead-export` | high | Exported symbol with zero semantic references (TypeChecker confirmed, stricter than `dead-export`) | `--semantic` |
|
|
92
|
-
| `dead-file` | medium | File with no inbound or outbound dependencies — likely stale | — |
|
|
93
|
-
|
|
94
|
-
---
|
|
95
|
-
|
|
96
|
-
## Security
|
|
97
|
-
|
|
98
|
-
| Category | Severity | Detects | Requires |
|
|
99
|
-
|----------|----------|---------|----------|
|
|
100
|
-
| `hardcoded-secret` | high | String literals matching secret patterns (password, API key, token) or high-entropy strings | — |
|
|
101
|
-
| `eval-usage` | critical | `eval()`, `new Function()`, string-based `setTimeout`/`setInterval` | — |
|
|
102
|
-
| `unsafe-html` | high | `innerHTML`, `outerHTML`, `dangerouslySetInnerHTML`, `document.write` | — |
|
|
103
|
-
| `sql-injection-risk` | high | Template literal with SQL keywords and interpolated expressions | — |
|
|
104
|
-
| `unsafe-regex` | medium | Regex with nested quantifiers (catastrophic backtracking / ReDoS) | — |
|
|
105
|
-
| `prototype-pollution-risk` | medium — high | `Object.assign()` without `__proto__` guard, deep merge/extend utilities, computed-property bracket writes (`obj[key] = val`) | — |
|
|
106
|
-
| `unvalidated-input-sink` | high | Function receives external input (param name heuristic) and uses a dangerous sink (eval, innerHTML, SQL, exec, fs write) without validation evidence | — |
|
|
107
|
-
| `input-passthrough-risk` | low — medium | Function receives external input and passes it to other functions without validation; severity by param confidence (high-confidence params like `req`, `body` = medium; medium-confidence like `input`, `event` = low; low-confidence like `data`, `args` = filtered out). Trace downstream with `lspCallHierarchy` | — |
|
|
108
|
-
| `path-traversal-risk` | medium — high | Function receives external input that flows into `fs.readFile`, `path.resolve`, or `path.join` without validation (normalize → prefix check → realpath). High severity when no validation; medium when partial validation detected | — |
|
|
109
|
-
| `command-injection-risk` | high — critical | Function receives external input that flows into `exec`/`execSync` (critical) or `spawn` with potential `shell:true` (high). exec with string interpolation enables arbitrary OS command execution | — |
|
|
110
|
-
| `debug-log-leakage` | medium — high | `debugger` statements (high) or `console.debug`/`console.trace` calls (medium) in non-test production files. Information disclosure risk — exposes internal state and execution paths | — |
|
|
111
|
-
| `sensitive-data-logging` | high | `console.*` calls whose argument text matches a sensitive-data pattern: password, token, secret, credential, API key, session, SSN, credit card. Logs write secrets to stdout, log aggregators, and persistent storage | — |
|
|
112
|
-
|
|
113
|
-
---
|
|
114
|
-
|
|
115
|
-
## Test Quality
|
|
116
|
-
|
|
117
|
-
Requires `--include-tests` (or auto-enabled when `--features=test-quality`).
|
|
118
|
-
|
|
119
|
-
| Category | Severity | Detects | Requires |
|
|
120
|
-
|----------|----------|---------|----------|
|
|
121
|
-
| `low-assertion-density` | medium | Average < 1 assertion per test block | `--include-tests` |
|
|
122
|
-
| `test-no-assertion` | high | `it()`/`test()` block with zero assertions | `--include-tests` |
|
|
123
|
-
| `excessive-mocking` | medium | Mock/spy calls exceeding threshold per test file | `--include-tests` |
|
|
124
|
-
| `shared-mutable-state` | medium | `let`/`var` at describe scope — mutation across tests | `--include-tests` |
|
|
125
|
-
| `missing-test-cleanup` | medium | `beforeAll`/`beforeEach` without corresponding `afterAll`/`afterEach` | `--include-tests` |
|
|
126
|
-
| `focused-test` | medium | `.only`, `.skip`, or `.todo` committed in a test file | `--include-tests` |
|
|
127
|
-
| `fake-timer-no-restore` | medium | Fake timers enabled without restoring real timers | `--include-tests` |
|
|
128
|
-
| `missing-mock-restoration` | medium | Spies/stubs created without restore or restoreAll cleanup | `--include-tests` |
|