octocode-cli 1.2.6 → 1.2.7
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/LICENSE +21 -63
- package/README.md +85 -142
- package/out/octocode-cli.js +7026 -6945
- package/package.json +8 -6
- package/skills/README.md +97 -120
- package/skills/octocode-code-engineer/.claude/settings.local.json +18 -0
- package/skills/octocode-code-engineer/.octocode/rfc/RFC-code-engineer-weakness-fixes.md +255 -0
- package/skills/octocode-code-engineer/.plan/VALIDATED_PLAN.md +223 -0
- package/skills/octocode-code-engineer/README.md +178 -0
- package/skills/octocode-code-engineer/SKILL.md +418 -0
- package/skills/octocode-code-engineer/coverage/architecture.ts.html +7828 -0
- package/skills/octocode-code-engineer/coverage/ast-helpers.ts.html +211 -0
- package/skills/octocode-code-engineer/coverage/ast-search.ts.html +1795 -0
- package/skills/octocode-code-engineer/coverage/base.css +224 -0
- package/skills/octocode-code-engineer/coverage/block-navigation.js +87 -0
- package/skills/octocode-code-engineer/coverage/cache.ts.html +376 -0
- package/skills/octocode-code-engineer/coverage/cli.ts.html +982 -0
- package/skills/octocode-code-engineer/coverage/clover.xml +3217 -0
- package/skills/octocode-code-engineer/coverage/collect-effects.ts.html +664 -0
- package/skills/octocode-code-engineer/coverage/collect-input-sources.ts.html +577 -0
- package/skills/octocode-code-engineer/coverage/collect-performance.ts.html +331 -0
- package/skills/octocode-code-engineer/coverage/collect-prototype-pollution.ts.html +421 -0
- package/skills/octocode-code-engineer/coverage/collect-security.ts.html +604 -0
- package/skills/octocode-code-engineer/coverage/collect-test-profile.ts.html +589 -0
- package/skills/octocode-code-engineer/coverage/coverage-final.json +30 -0
- package/skills/octocode-code-engineer/coverage/dependencies.ts.html +997 -0
- package/skills/octocode-code-engineer/coverage/dependency-summary.ts.html +688 -0
- package/skills/octocode-code-engineer/coverage/discovery.ts.html +322 -0
- package/skills/octocode-code-engineer/coverage/favicon.png +0 -0
- package/skills/octocode-code-engineer/coverage/graph-analytics.ts.html +1510 -0
- package/skills/octocode-code-engineer/coverage/index.html +536 -0
- package/skills/octocode-code-engineer/coverage/index.ts.html +826 -0
- package/skills/octocode-code-engineer/coverage/metrics.ts.html +553 -0
- package/skills/octocode-code-engineer/coverage/pipeline.ts.html +2044 -0
- package/skills/octocode-code-engineer/coverage/prettify.css +1 -0
- package/skills/octocode-code-engineer/coverage/prettify.js +2 -0
- package/skills/octocode-code-engineer/coverage/report-analysis.ts.html +1570 -0
- package/skills/octocode-code-engineer/coverage/report-writer.ts.html +1102 -0
- package/skills/octocode-code-engineer/coverage/security-detectors.ts.html +1747 -0
- package/skills/octocode-code-engineer/coverage/semantic-detectors.ts.html +2152 -0
- package/skills/octocode-code-engineer/coverage/semantic.ts.html +1897 -0
- package/skills/octocode-code-engineer/coverage/sort-arrow-sprite.png +0 -0
- package/skills/octocode-code-engineer/coverage/sorter.js +210 -0
- package/skills/octocode-code-engineer/coverage/summary-md.ts.html +1222 -0
- package/skills/octocode-code-engineer/coverage/test-quality-detectors.ts.html +1039 -0
- package/skills/octocode-code-engineer/coverage/tree-sitter-analyzer.ts.html +955 -0
- package/skills/octocode-code-engineer/coverage/ts-analyzer.ts.html +1213 -0
- package/skills/octocode-code-engineer/coverage/types.ts.html +2473 -0
- package/skills/octocode-code-engineer/coverage/utils.ts.html +820 -0
- package/skills/octocode-code-engineer/eslint.config.mjs +54 -0
- package/skills/octocode-code-engineer/minify-scripts.mjs +32 -0
- package/skills/octocode-code-engineer/package.json +54 -0
- package/skills/octocode-code-engineer/references/agent-ast-reading-rfc.md +95 -0
- package/skills/octocode-code-engineer/references/architecture-techniques.md +121 -0
- package/skills/octocode-code-engineer/references/ast-search.md +210 -0
- package/skills/octocode-code-engineer/references/ast-tree-search.md +151 -0
- package/skills/octocode-code-engineer/references/cli-reference.md +167 -0
- package/skills/octocode-code-engineer/references/concepts.md +107 -0
- package/skills/octocode-code-engineer/references/finding-categories.md +128 -0
- package/skills/octocode-code-engineer/references/improvement-roadmap.md +304 -0
- package/skills/octocode-code-engineer/references/output-files.md +144 -0
- package/skills/octocode-code-engineer/references/playbooks.md +204 -0
- package/skills/octocode-code-engineer/references/present-results.md +136 -0
- package/skills/octocode-code-engineer/references/tool-workflows.md +566 -0
- package/skills/octocode-code-engineer/references/validate-investigate.md +225 -0
- package/skills/octocode-code-engineer/scripts/analysis/dependencies.js +1 -0
- package/skills/octocode-code-engineer/scripts/analysis/dependency-summary.js +1 -0
- package/skills/octocode-code-engineer/scripts/analysis/discovery.js +1 -0
- package/skills/octocode-code-engineer/scripts/analysis/graph-analytics.js +1 -0
- package/skills/octocode-code-engineer/scripts/analysis/semantic.js +1 -0
- package/skills/octocode-code-engineer/scripts/ast/helpers.js +1 -0
- package/skills/octocode-code-engineer/scripts/ast/metrics.js +1 -0
- package/skills/octocode-code-engineer/scripts/ast/search.js +2 -0
- package/skills/octocode-code-engineer/scripts/ast/tree-search.js +2 -0
- package/skills/octocode-code-engineer/scripts/ast/tree-sitter.js +1 -0
- package/skills/octocode-code-engineer/scripts/ast/ts-analyzer.js +1 -0
- package/skills/octocode-code-engineer/scripts/collectors/chains.js +1 -0
- package/skills/octocode-code-engineer/scripts/collectors/effects.js +1 -0
- package/skills/octocode-code-engineer/scripts/collectors/input-sources.js +1 -0
- package/skills/octocode-code-engineer/scripts/collectors/performance.js +1 -0
- package/skills/octocode-code-engineer/scripts/collectors/prototype-pollution.js +1 -0
- package/skills/octocode-code-engineer/scripts/collectors/security.js +1 -0
- package/skills/octocode-code-engineer/scripts/collectors/test-profile.js +1 -0
- package/skills/octocode-code-engineer/scripts/common/is-direct-run.js +1 -0
- package/skills/octocode-code-engineer/scripts/common/utils.js +1 -0
- package/skills/octocode-code-engineer/scripts/detectors/code-quality.js +1 -0
- package/skills/octocode-code-engineer/scripts/detectors/cohesion.js +1 -0
- package/skills/octocode-code-engineer/scripts/detectors/coupling.js +1 -0
- package/skills/octocode-code-engineer/scripts/detectors/cycle.js +1 -0
- package/skills/octocode-code-engineer/scripts/detectors/dead-code.js +1 -0
- package/skills/octocode-code-engineer/scripts/detectors/import-style.js +1 -0
- package/skills/octocode-code-engineer/scripts/detectors/index.js +1 -0
- package/skills/octocode-code-engineer/scripts/detectors/security.js +1 -0
- package/skills/octocode-code-engineer/scripts/detectors/semantic.js +1 -0
- package/skills/octocode-code-engineer/scripts/detectors/shared.js +1 -0
- package/skills/octocode-code-engineer/scripts/detectors/test-quality.js +1 -0
- package/skills/octocode-code-engineer/scripts/index.js +1 -0
- package/skills/octocode-code-engineer/scripts/pipeline/cache.js +1 -0
- package/skills/octocode-code-engineer/scripts/pipeline/cli.js +1 -0
- package/skills/octocode-code-engineer/scripts/pipeline/main.js +2 -0
- package/skills/octocode-code-engineer/scripts/reporting/analysis.js +1 -0
- package/skills/octocode-code-engineer/scripts/reporting/summary-md.js +1 -0
- package/skills/octocode-code-engineer/scripts/reporting/writer.js +1 -0
- package/skills/octocode-code-engineer/scripts/types/constants.js +1 -0
- package/skills/octocode-code-engineer/scripts/types/index.js +1 -0
- package/skills/octocode-code-engineer/scripts/types/interfaces.js +1 -0
- package/skills/octocode-code-engineer/src/analysis/dependencies.test.ts +545 -0
- package/skills/octocode-code-engineer/src/analysis/dependencies.ts +406 -0
- package/skills/octocode-code-engineer/src/analysis/dependency-summary.test.ts +566 -0
- package/skills/octocode-code-engineer/src/analysis/dependency-summary.ts +257 -0
- package/skills/octocode-code-engineer/src/analysis/discovery.test.ts +420 -0
- package/skills/octocode-code-engineer/src/analysis/discovery.ts +87 -0
- package/skills/octocode-code-engineer/src/analysis/graph-analytics.test.ts +449 -0
- package/skills/octocode-code-engineer/src/analysis/graph-analytics.ts +534 -0
- package/skills/octocode-code-engineer/src/analysis/semantic.test.ts +1533 -0
- package/skills/octocode-code-engineer/src/analysis/semantic.ts +830 -0
- package/skills/octocode-code-engineer/src/ast/helpers.test.ts +185 -0
- package/skills/octocode-code-engineer/src/ast/helpers.ts +62 -0
- package/skills/octocode-code-engineer/src/ast/metrics.test.ts +304 -0
- package/skills/octocode-code-engineer/src/ast/metrics.ts +204 -0
- package/skills/octocode-code-engineer/src/ast/search.test.ts +647 -0
- package/skills/octocode-code-engineer/src/ast/search.ts +648 -0
- package/skills/octocode-code-engineer/src/ast/tree-search.test.ts +199 -0
- package/skills/octocode-code-engineer/src/ast/tree-search.ts +392 -0
- package/skills/octocode-code-engineer/src/ast/tree-sitter.test.ts +407 -0
- package/skills/octocode-code-engineer/src/ast/tree-sitter.ts +402 -0
- package/skills/octocode-code-engineer/src/ast/ts-analyzer.test.ts +1864 -0
- package/skills/octocode-code-engineer/src/ast/ts-analyzer.ts +509 -0
- package/skills/octocode-code-engineer/src/collectors/chains.ts +74 -0
- package/skills/octocode-code-engineer/src/collectors/effects.test.ts +490 -0
- package/skills/octocode-code-engineer/src/collectors/effects.ts +332 -0
- package/skills/octocode-code-engineer/src/collectors/input-sources.test.ts +144 -0
- package/skills/octocode-code-engineer/src/collectors/input-sources.ts +196 -0
- package/skills/octocode-code-engineer/src/collectors/performance.test.ts +82 -0
- package/skills/octocode-code-engineer/src/collectors/performance.ts +141 -0
- package/skills/octocode-code-engineer/src/collectors/prototype-pollution.test.ts +55 -0
- package/skills/octocode-code-engineer/src/collectors/prototype-pollution.ts +162 -0
- package/skills/octocode-code-engineer/src/collectors/security.test.ts +124 -0
- package/skills/octocode-code-engineer/src/collectors/security.ts +309 -0
- package/skills/octocode-code-engineer/src/collectors/test-profile.test.ts +97 -0
- package/skills/octocode-code-engineer/src/collectors/test-profile.ts +269 -0
- package/skills/octocode-code-engineer/src/common/is-direct-run.test.ts +32 -0
- package/skills/octocode-code-engineer/src/common/is-direct-run.ts +13 -0
- package/skills/octocode-code-engineer/src/common/utils.test.ts +463 -0
- package/skills/octocode-code-engineer/src/common/utils.ts +304 -0
- package/skills/octocode-code-engineer/src/detectors/code-quality.ts +966 -0
- package/skills/octocode-code-engineer/src/detectors/cohesion.ts +539 -0
- package/skills/octocode-code-engineer/src/detectors/coupling.ts +323 -0
- package/skills/octocode-code-engineer/src/detectors/cycle.ts +349 -0
- package/skills/octocode-code-engineer/src/detectors/dead-code.ts +320 -0
- package/skills/octocode-code-engineer/src/detectors/import-style.ts +376 -0
- package/skills/octocode-code-engineer/src/detectors/index.test.ts +3061 -0
- package/skills/octocode-code-engineer/src/detectors/index.ts +88 -0
- package/skills/octocode-code-engineer/src/detectors/security.test.ts +882 -0
- package/skills/octocode-code-engineer/src/detectors/security.ts +821 -0
- package/skills/octocode-code-engineer/src/detectors/semantic.ts +758 -0
- package/skills/octocode-code-engineer/src/detectors/shared.ts +49 -0
- package/skills/octocode-code-engineer/src/detectors/test-quality.test.ts +388 -0
- package/skills/octocode-code-engineer/src/detectors/test-quality.ts +367 -0
- package/skills/octocode-code-engineer/src/index.test.ts +4425 -0
- package/skills/octocode-code-engineer/src/index.ts +403 -0
- package/skills/octocode-code-engineer/src/pipeline/cache.test.ts +199 -0
- package/skills/octocode-code-engineer/src/pipeline/cache.ts +130 -0
- package/skills/octocode-code-engineer/src/pipeline/cli.test.ts +493 -0
- package/skills/octocode-code-engineer/src/pipeline/cli.ts +344 -0
- package/skills/octocode-code-engineer/src/pipeline/main.test.ts +174 -0
- package/skills/octocode-code-engineer/src/pipeline/main.ts +1074 -0
- package/skills/octocode-code-engineer/src/pipeline.test.ts +84 -0
- package/skills/octocode-code-engineer/src/reporting/analysis.test.ts +782 -0
- package/skills/octocode-code-engineer/src/reporting/analysis.ts +688 -0
- package/skills/octocode-code-engineer/src/reporting/output-contract.test.ts +463 -0
- package/skills/octocode-code-engineer/src/reporting/summary-md.test.ts +421 -0
- package/skills/octocode-code-engineer/src/reporting/summary-md.ts +714 -0
- package/skills/octocode-code-engineer/src/reporting/writer.ts +430 -0
- package/skills/octocode-code-engineer/src/sanity.test.ts +47 -0
- package/skills/octocode-code-engineer/src/types/constants.ts +248 -0
- package/skills/octocode-code-engineer/src/types/index.ts +80 -0
- package/skills/octocode-code-engineer/src/types/interfaces.ts +682 -0
- package/skills/octocode-code-engineer/tsconfig.json +17 -0
- package/skills/octocode-code-engineer/vitest.config.ts +8 -0
- package/skills/octocode-documentation-writer/README.md +113 -0
- package/skills/octocode-documentation-writer/SKILL.md +886 -0
- package/skills/octocode-documentation-writer/references/agent-discovery-analysis.md +453 -0
- package/skills/octocode-documentation-writer/references/agent-documentation-writer.md +255 -0
- package/skills/octocode-documentation-writer/references/agent-engineer-questions.md +247 -0
- package/skills/octocode-documentation-writer/references/agent-orchestrator.md +370 -0
- package/skills/octocode-documentation-writer/references/agent-qa-validator.md +227 -0
- package/skills/octocode-documentation-writer/references/agent-researcher.md +250 -0
- package/skills/octocode-documentation-writer/schemas/analysis-schema.json +886 -0
- package/skills/octocode-documentation-writer/schemas/discovery-tasks.json +96 -0
- package/skills/octocode-documentation-writer/schemas/documentation-structure.json +373 -0
- package/skills/octocode-documentation-writer/schemas/partial-discovery-schema.json +102 -0
- package/skills/octocode-documentation-writer/schemas/partial-research-schema.json +98 -0
- package/skills/octocode-documentation-writer/schemas/qa-results-schema.json +113 -0
- package/skills/octocode-documentation-writer/schemas/questions-schema.json +228 -0
- package/skills/octocode-documentation-writer/schemas/research-schema.json +104 -0
- package/skills/octocode-documentation-writer/schemas/state-schema.json +222 -0
- package/skills/octocode-documentation-writer/schemas/work-assignments-schema.json +74 -0
- package/skills/octocode-plan/SKILL.md +122 -116
- package/skills/octocode-prompt-optimizer/SKILL.md +617 -0
- package/skills/octocode-pull-request-reviewer/README.md +249 -0
- package/skills/octocode-pull-request-reviewer/SKILL.md +479 -0
- package/skills/octocode-pull-request-reviewer/references/dependency-check.md +74 -0
- package/skills/octocode-pull-request-reviewer/references/domain-reviewers.md +24 -0
- package/skills/octocode-pull-request-reviewer/references/execution-lifecycle.md +441 -0
- package/skills/octocode-pull-request-reviewer/references/flow-analysis-protocol.md +64 -0
- package/skills/octocode-pull-request-reviewer/references/output-template.md +174 -0
- package/skills/octocode-pull-request-reviewer/references/parallel-agent-protocol.md +182 -0
- package/skills/octocode-pull-request-reviewer/references/review-guidelines.md +26 -0
- package/skills/octocode-pull-request-reviewer/references/verification-checklist.md +40 -0
- package/skills/octocode-research/.claude/settings.local.json +46 -0
- package/skills/octocode-research/.octocode/plan/code-review-fixes/plan.md +312 -0
- package/skills/octocode-research/.octocode/plan/code-review-fixes/research.md +212 -0
- package/skills/octocode-research/.octocode/plans/NODE_SERVER_START_PLAN.md +755 -0
- package/skills/octocode-research/.octocode/research/code-review/research.md +371 -0
- package/skills/octocode-research/.octocode/review/IMPROVEMENTS.md +391 -0
- package/skills/octocode-research/.octocode/review/REVIEW_PLAN.md +289 -0
- package/skills/octocode-research/.octocode/review/REVIEW_REPORT.md +356 -0
- package/skills/octocode-research/AGENTS.md +349 -0
- package/skills/octocode-research/README.md +494 -0
- package/skills/octocode-research/SKILL.md +652 -274
- package/skills/octocode-research/docs/API_REFERENCE.md +562 -0
- package/skills/octocode-research/docs/ARCHITECTURE.md +554 -0
- package/skills/octocode-research/docs/FLOWS.md +577 -0
- package/skills/octocode-research/docs/OVERVIEW.md +564 -0
- package/skills/octocode-research/docs/SERVER_FLOWS.md +631 -0
- package/skills/octocode-research/ecosystem.config.cjs +88 -0
- package/skills/octocode-research/eslint.config.mjs +27 -0
- package/skills/octocode-research/package.json +84 -0
- package/skills/octocode-research/references/GUARDRAILS.md +40 -0
- package/skills/octocode-research/references/PARALLEL_AGENT_PROTOCOL.md +178 -0
- package/skills/octocode-research/references/roast-prompt.md +149 -0
- package/skills/octocode-research/scripts/server-init.d.ts +2 -0
- package/skills/octocode-research/scripts/server-init.js +2 -0
- package/skills/octocode-research/scripts/server.d.ts +8 -0
- package/skills/octocode-research/scripts/server.js +445 -0
- package/skills/octocode-research/src/__tests__/integration/circuitBreaker.test.ts +205 -0
- package/skills/octocode-research/src/__tests__/integration/routes.test.ts +374 -0
- package/skills/octocode-research/src/__tests__/unit/circuitBreaker.test.ts +245 -0
- package/skills/octocode-research/src/__tests__/unit/errorHandler.test.ts +183 -0
- package/skills/octocode-research/src/__tests__/unit/httpPreprocess.test.ts +157 -0
- package/skills/octocode-research/src/__tests__/unit/logger.test.ts +143 -0
- package/skills/octocode-research/src/__tests__/unit/queryParser.test.ts +130 -0
- package/skills/octocode-research/src/__tests__/unit/responseBuilder.test.ts +469 -0
- package/skills/octocode-research/src/__tests__/unit/retry.test.ts +205 -0
- package/skills/octocode-research/src/index.ts +186 -0
- package/skills/octocode-research/src/mcpCache.ts +49 -0
- package/skills/octocode-research/src/middleware/errorHandler.ts +65 -0
- package/skills/octocode-research/src/middleware/logger.ts +61 -0
- package/skills/octocode-research/src/middleware/queryParser.ts +115 -0
- package/skills/octocode-research/src/middleware/readiness.ts +17 -0
- package/skills/octocode-research/src/routes/github.ts +197 -0
- package/skills/octocode-research/src/routes/local.ts +175 -0
- package/skills/octocode-research/src/routes/lsp.ts +177 -0
- package/skills/octocode-research/src/routes/package.ts +127 -0
- package/skills/octocode-research/src/routes/prompts.ts +138 -0
- package/skills/octocode-research/src/routes/tools.ts +677 -0
- package/skills/octocode-research/src/server-init.ts +363 -0
- package/skills/octocode-research/src/server.ts +285 -0
- package/skills/octocode-research/src/types/errorGuards.ts +151 -0
- package/skills/octocode-research/src/types/express.d.ts +76 -0
- package/skills/octocode-research/src/types/guards.ts +98 -0
- package/skills/octocode-research/src/types/mcp.ts +119 -0
- package/skills/octocode-research/src/types/responses.ts +199 -0
- package/skills/octocode-research/src/types/toolTypes.ts +33 -0
- package/skills/octocode-research/src/utils/asyncTimeout.ts +116 -0
- package/skills/octocode-research/src/utils/circuitBreaker.ts +492 -0
- package/skills/octocode-research/src/utils/colors.ts +53 -0
- package/skills/octocode-research/src/utils/errorQueue.ts +71 -0
- package/skills/octocode-research/src/utils/logEmoji.ts +103 -0
- package/skills/octocode-research/src/utils/logger.ts +413 -0
- package/skills/octocode-research/src/utils/resilience.ts +169 -0
- package/skills/octocode-research/src/utils/responseBuilder.ts +495 -0
- package/skills/octocode-research/src/utils/responseFactory.ts +100 -0
- package/skills/octocode-research/src/utils/responseParser.ts +272 -0
- package/skills/octocode-research/src/utils/retry.ts +280 -0
- package/skills/octocode-research/src/utils/routeFactory.ts +117 -0
- package/skills/octocode-research/src/utils/url.ts +20 -0
- package/skills/octocode-research/src/validation/httpPreprocess.ts +155 -0
- package/skills/octocode-research/src/validation/index.ts +2 -0
- package/skills/octocode-research/src/validation/schemas.ts +578 -0
- package/skills/octocode-research/src/validation/toolCallSchema.ts +132 -0
- package/skills/octocode-research/tsconfig.json +21 -0
- package/skills/octocode-research/tsdown.config.ts +42 -0
- package/skills/octocode-research/vitest.config.ts +20 -0
- package/skills/octocode-researcher/SKILL.md +461 -0
- package/skills/octocode-researcher/references/fallbacks.md +120 -0
- package/skills/{octocode-local-search → octocode-researcher}/references/tool-reference.md +132 -49
- package/skills/{octocode-local-search → octocode-researcher}/references/workflow-patterns.md +204 -4
- package/skills/octocode-rfc-generator/SKILL.md +223 -0
- package/skills/octocode-rfc-generator/references/rfc-template.md +193 -0
- package/skills/octocode-roast/SKILL.md +63 -21
- package/skills/octocode-implement/SKILL.md +0 -293
- package/skills/octocode-implement/references/execution-phases.md +0 -317
- package/skills/octocode-implement/references/tool-reference.md +0 -403
- package/skills/octocode-implement/references/workflow-patterns.md +0 -385
- package/skills/octocode-local-search/SKILL.md +0 -449
- package/skills/octocode-pr-review/SKILL.md +0 -391
- package/skills/octocode-pr-review/references/domain-reviewers.md +0 -105
- package/skills/octocode-pr-review/references/execution-lifecycle.md +0 -116
- package/skills/octocode-pr-review/references/research-flows.md +0 -75
- package/skills/octocode-research/references/tool-reference.md +0 -304
- package/skills/octocode-research/references/workflow-patterns.md +0 -325
|
@@ -0,0 +1,566 @@
|
|
|
1
|
+
# Tool Workflows — Research Methodology & Patterns
|
|
2
|
+
|
|
3
|
+
Complete reference for code analysis using all available tools. General approaches first, then workflows for quality audits, architecture analysis, pre-implementation checks, refactoring, and exploration.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Research Primitives
|
|
8
|
+
|
|
9
|
+
Three fundamental operations. Every investigation chains them.
|
|
10
|
+
|
|
11
|
+
### SEARCH — find where things are
|
|
12
|
+
|
|
13
|
+
| Tool | Searches | Best for | Key flags |
|
|
14
|
+
|------|----------|----------|-----------|
|
|
15
|
+
| `localSearchCode` | Live source (ripgrep) | Text patterns, getting `lineHint` for LSP | `filesOnly`, `fixedString`, `filePageNumber` |
|
|
16
|
+
| `ast/search.js` | Live source (AST) | Structural patterns, zero false-positive proof | `--preset`, `-p`, `-k`, `--rule`, `--json`, `--limit` |
|
|
17
|
+
| `ast/tree-search.js` | Scan artifact `ast-trees.txt` | Fast triage before reading source | `--file`, `-k`, `-C`, `--json`, `--limit` |
|
|
18
|
+
| `localFindFiles` | File metadata | Files by name, size, modification time | `names`, `sortBy`, `sizeGreater`, `modifiedWithin` |
|
|
19
|
+
| `lspFindReferences` | Semantic symbol graph | All usages of type/var/export (definitive) | `includeDeclaration`, `includePattern`, `excludePattern` |
|
|
20
|
+
| `lspCallHierarchy` | Semantic call graph | Who calls a function / what it calls | `direction`, `depth=1` + chain, `fromRanges[]` |
|
|
21
|
+
|
|
22
|
+
**Rules:**
|
|
23
|
+
- `localSearchCode` always first → produces `lineHint` for all LSP tools
|
|
24
|
+
- `ast/search.js` for structural proof → confirms by AST shape, not text
|
|
25
|
+
- `ast/tree-search.js` for fast triage → decides where to drill before source reading
|
|
26
|
+
- `lspFindReferences` for types/vars/exports; `lspCallHierarchy` for functions only
|
|
27
|
+
- Never guess `lineHint`
|
|
28
|
+
|
|
29
|
+
### FETCH — read what you found
|
|
30
|
+
|
|
31
|
+
| Tool | Reads | Best for | Key flags |
|
|
32
|
+
|------|-------|----------|-----------|
|
|
33
|
+
| `localGetFileContent` | Any local file | Targeted or paginated reading | `matchString`, `matchStringContextLines`, `charOffset`, `charLength`, `fullContent`, `startLine`/`endLine` |
|
|
34
|
+
| `lspGotoDefinition` | Symbol definition | Cross-file jump to where a symbol is defined | `lineHint` (required from search) |
|
|
35
|
+
|
|
36
|
+
**Strategy by file size:**
|
|
37
|
+
|
|
38
|
+
| Size | Approach | Flags |
|
|
39
|
+
|------|----------|-------|
|
|
40
|
+
| <200 lines | Full read | `fullContent=true` |
|
|
41
|
+
| 200-1000 | Jump to section | `matchString="target"`, `matchStringContextLines=5` |
|
|
42
|
+
| 1000+ | Paginate | `charOffset=0, charLength=500` → page through |
|
|
43
|
+
| Unknown | Match first | `matchString` → check `totalLines` in response |
|
|
44
|
+
|
|
45
|
+
**Rules:**
|
|
46
|
+
- Never `fullContent` on large files — use `matchString` to land on the right section
|
|
47
|
+
- `charOffset=0` for imports, `charOffset=<end>` for file tail
|
|
48
|
+
- `lspGotoDefinition` after `localSearchCode` — jumps across files
|
|
49
|
+
- Read after search, never before
|
|
50
|
+
|
|
51
|
+
### STRUCTURE — see the shape
|
|
52
|
+
|
|
53
|
+
| Tool | Shows | Best for | Key flags |
|
|
54
|
+
|------|-------|----------|-----------|
|
|
55
|
+
| `localViewStructure` | Directory tree (live) | Project layout, module boundaries | `depth`, `filesOnly`, `directoriesOnly`, `extension`, `details` |
|
|
56
|
+
| `ast/tree-search.js` | AST tree (scan artifact) | Function spans, nesting, class shapes | `--file`, `-k function_declaration`, `-C 2` |
|
|
57
|
+
| `index.js --graph` | Dependency graph | Cycles, critical paths, hotspots | `--graph`, `--graph-advanced`, `--scope` |
|
|
58
|
+
|
|
59
|
+
**Rules:**
|
|
60
|
+
- `localViewStructure(depth=2, directoriesOnly=true)` first → project layout
|
|
61
|
+
- `ast/tree-search.js --file X -C 2` → AST shape before reading source
|
|
62
|
+
- `index.js --graph --graph-advanced` → architecture with hotFiles, cycles, chokepoints
|
|
63
|
+
- Structure informs which files to search and fetch — run before deep reading
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## The Research Funnel
|
|
68
|
+
|
|
69
|
+
Chain primitives in this order. Each stage narrows scope for the next.
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
STRUCTURE → SEARCH → FETCH
|
|
73
|
+
80-90% 90-99% 100%
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
| Stage | Reduction | Tools |
|
|
77
|
+
|-------|-----------|-------|
|
|
78
|
+
| 1. Structure | 80-90% — know where to look | `localViewStructure`, `ast/tree-search.js`, `index.js --graph` |
|
|
79
|
+
| 2. Search | 90-99% — know what and where | `localSearchCode`, `ast/search.js`, `localFindFiles`, LSP search |
|
|
80
|
+
| 3. Fetch | 100% — read the evidence | `localGetFileContent`, `lspGotoDefinition` |
|
|
81
|
+
|
|
82
|
+
**Reverse funnel** when you have exact coordinates (e.g. `lspHints` from `findings.json`):
|
|
83
|
+
- `lspFindReferences(lineHint=N)` → skip to semantic proof
|
|
84
|
+
- `localGetFileContent(startLine, endLine)` → skip to reading
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## Quick Decision Table
|
|
89
|
+
|
|
90
|
+
| Question | Approach | Tools |
|
|
91
|
+
|----------|----------|-------|
|
|
92
|
+
| "What does this codebase look like?" | Structure | `localViewStructure(depth=2)` → `localFindFiles(sortBy=size)` |
|
|
93
|
+
| "Does pattern X exist?" | Search (AST) | `ast/search.js --preset` or `-p 'pattern'` |
|
|
94
|
+
| "Where is X defined?" | Search → Fetch | `localSearchCode` → `lspGotoDefinition(lineHint)` |
|
|
95
|
+
| "Who calls function X?" | Search → Search | `localSearchCode` → `lspCallHierarchy(incoming, lineHint)` |
|
|
96
|
+
| "All usages of type/var X?" | Search → Search | `localSearchCode` → `lspFindReferences(lineHint)` |
|
|
97
|
+
| "Is export X dead?" | Search → Search | `lspFindReferences(lineHint, includeDecl=false)` → `ast/search.js -p` cross-check |
|
|
98
|
+
| "What's the AST shape of file X?" | Structure (AST) | `ast/tree-search.js --file X -C 2` |
|
|
99
|
+
| "Read this function" | Fetch | `localGetFileContent(matchString="funcName", contextLines=5)` |
|
|
100
|
+
| "Trace flow A → B" | Search chain | `localSearchCode` → `lspGotoDefinition` → `lspCallHierarchy` → repeat |
|
|
101
|
+
| "Architecture hotspots?" | Structure → Search | `index.js --graph-advanced` → `lspFindReferences` on hotFiles |
|
|
102
|
+
| "Structural smells?" | Search (batch) | `ast/search.js --preset` (multiple presets in parallel) |
|
|
103
|
+
| "Did my fix work?" | Search → Structure | `index.js --scope=<changed>` + `ast/search.js --preset` + toolchain |
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## AST Presets Reference
|
|
108
|
+
|
|
109
|
+
16 built-in presets for `ast/search.js --preset <name> --json --root <dir>`:
|
|
110
|
+
|
|
111
|
+
| Preset | Finds |
|
|
112
|
+
|--------|-------|
|
|
113
|
+
| `empty-catch` | `catch (e) {}` — silently swallowed errors |
|
|
114
|
+
| `console-log` | `console.log(...)` left in production |
|
|
115
|
+
| `console-any` | Any `console.*()` call |
|
|
116
|
+
| `debugger` | `debugger;` statements |
|
|
117
|
+
| `todo-fixme` | TODO/FIXME/HACK/XXX/BUG comments |
|
|
118
|
+
| `any-type` | `: any` annotations |
|
|
119
|
+
| `type-assertion` | `x as Type` assertions |
|
|
120
|
+
| `non-null-assertion` | `x!` non-null assertions |
|
|
121
|
+
| `fat-arrow-body` | `() => { return x }` — could be expression |
|
|
122
|
+
| `nested-ternary` | `a ? (b ? 1 : 2) : 3` |
|
|
123
|
+
| `throw-string` | `throw "oops"` — should be Error |
|
|
124
|
+
| `switch-no-default` | `switch` without `default` |
|
|
125
|
+
| `class-declaration` | All class declarations |
|
|
126
|
+
| `async-function` | `async function` declarations |
|
|
127
|
+
| `export-default` | `export default` statements |
|
|
128
|
+
| `import-star` | `import * as X` namespace imports |
|
|
129
|
+
|
|
130
|
+
Custom patterns: `-p 'eval($$$A)'`, `-p 'import { $$$N } from $MOD'`, `-k function_declaration`
|
|
131
|
+
Advanced rules: `--rule '{"rule":{"kind":"string","regex":"password|secret|token"}}'`
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## Efficiency Tips
|
|
136
|
+
|
|
137
|
+
| Pattern | DO | DON'T |
|
|
138
|
+
|---------|-----|-------|
|
|
139
|
+
| Layer order | Structure → Search → Fetch | Jump to LSP without search context |
|
|
140
|
+
| LSP calls | `localSearchCode` first for `lineHint` | Guess `lineHint` |
|
|
141
|
+
| AST search | `--json --limit 10` to start | `--limit 0` on first call |
|
|
142
|
+
| AST triage vs proof | `tree-search.js` to decide, `search.js` to prove | `tree-search` as proof of live behavior |
|
|
143
|
+
| Large results | `filesOnly=true` for discovery, then drill | Full content on first call |
|
|
144
|
+
| File reading | `matchString` for targeted sections | `fullContent` on files >200 lines |
|
|
145
|
+
| References | `lspFindReferences` for types/vars, `lspCallHierarchy` for functions | `lspCallHierarchy` on types (fails) |
|
|
146
|
+
| Pagination | `charOffset` for content, `filePageNumber` for lists | Skip pagination — data is lost |
|
|
147
|
+
| Filters | `includePattern`/`excludePattern` to scope refs | Read all refs then manually filter |
|
|
148
|
+
| Batching | Independent tool calls in parallel | Sequential when order doesn't matter |
|
|
149
|
+
| Depth | `lspCallHierarchy(depth=1)` + chain manually | `depth=3` single call (slower, noisier) |
|
|
150
|
+
| Re-scan | `--scope=<changed-files>` after fix batch | Full re-scan when one file changed |
|
|
151
|
+
| Presets | AST presets for known smells (zero false-positive) | Text grep for structural patterns |
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## Workflows
|
|
156
|
+
|
|
157
|
+
### 1 — Full Scan → Triage → Validate
|
|
158
|
+
|
|
159
|
+
Start here for any new codebase or broad audit.
|
|
160
|
+
|
|
161
|
+
```
|
|
162
|
+
index.js --graph --flow → scan + generate hypotheses
|
|
163
|
+
summary.md → health scores, hotspots, top recs
|
|
164
|
+
findings.json | jq '.[:5]' → top findings with lspHints
|
|
165
|
+
ast/tree-search.js -k function_declaration --limit 25 → structural triage
|
|
166
|
+
localViewStructure(depth=2, directoriesOnly=true) → project layout
|
|
167
|
+
localFindFiles(sortBy="size", sizeGreater="10k") → hotspot files
|
|
168
|
+
lspFindReferences(lineHint=N, includeDeclaration=false) → validate findings via lspHints
|
|
169
|
+
lspCallHierarchy(incoming, depth=1) → confirm coupling
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### 2 — Symbol Deep Dive
|
|
173
|
+
|
|
174
|
+
Trace a function: definition → callers → callees.
|
|
175
|
+
|
|
176
|
+
```
|
|
177
|
+
ast/tree-search.js --file 'target' -k function_declaration -C 2 → AST shape
|
|
178
|
+
localSearchCode(pattern="funcName", filesOnly=true) → file + lineHint
|
|
179
|
+
localGetFileContent(matchString="funcName", contextLines=5) → read context
|
|
180
|
+
lspGotoDefinition(lineHint=N) → jump to definition
|
|
181
|
+
lspCallHierarchy(incoming, depth=1) → who calls it?
|
|
182
|
+
lspCallHierarchy(outgoing, depth=1) → what does it call?
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### 3 — Impact Analysis (Pre-Refactor)
|
|
186
|
+
|
|
187
|
+
Assess blast radius before changing a symbol.
|
|
188
|
+
|
|
189
|
+
```
|
|
190
|
+
ast/search.js -p 'import { $$$NAMES } from $MOD' --json → structural import map
|
|
191
|
+
localSearchCode(pattern="symbolName") → lineHint + text matches
|
|
192
|
+
lspFindReferences(includeDeclaration=false) → all usages
|
|
193
|
+
lspFindReferences(includePattern=["**/tests/**"]) → test coverage count
|
|
194
|
+
lspFindReferences(excludePattern=["**/tests/**"]) → production usages only
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
Few production refs + high test coverage = safe. Many production refs = plan carefully.
|
|
198
|
+
|
|
199
|
+
### 4 — Dead Export Validation
|
|
200
|
+
|
|
201
|
+
Fastest path from finding to verdict.
|
|
202
|
+
|
|
203
|
+
```
|
|
204
|
+
lspFindReferences(lineHint=N, includeDeclaration=false) → 0 refs = dead, >0 = false positive
|
|
205
|
+
ast/search.js -p 'import { exportName } from $MOD' --json → structural cross-check
|
|
206
|
+
ast/search.js -p 'exportName' --json --root src/ → catch dynamic usage
|
|
207
|
+
localSearchCode(pattern="exportName") → fallback if no lspHints
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### 5 — Code Smell Sweep (AST Presets)
|
|
211
|
+
|
|
212
|
+
Structural code smell detection — zero false positives.
|
|
213
|
+
|
|
214
|
+
```
|
|
215
|
+
ast/search.js --preset empty-catch --json --root src/
|
|
216
|
+
ast/search.js --preset any-type --json --root src/
|
|
217
|
+
ast/search.js --preset console-log --json --root src/
|
|
218
|
+
ast/search.js --preset switch-no-default --json --root src/
|
|
219
|
+
ast/search.js --preset nested-ternary --json --root src/
|
|
220
|
+
ast/search.js --preset non-null-assertion --json --root src/
|
|
221
|
+
ast/search.js -p 'eval($$$A)' --json --root src/ → custom patterns
|
|
222
|
+
localGetFileContent(matchString="match", contextLines=5) → read context
|
|
223
|
+
lspCallHierarchy(incoming, depth=1) → impact assessment
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### 6 — Dependency Cycle Tracing
|
|
227
|
+
|
|
228
|
+
Validate cycles from `architecture.json`.
|
|
229
|
+
|
|
230
|
+
```
|
|
231
|
+
index.js --features=dependency-cycle --graph → cycle evidence
|
|
232
|
+
architecture.json | jq '.cycles' → cycle paths
|
|
233
|
+
ast/search.js -p 'import { $$$N } from $MOD' --json --root <dir> → find back-edge imports
|
|
234
|
+
localSearchCode(pattern="import.*from.*moduleA", filesOnly=true) → importing files
|
|
235
|
+
localGetFileContent(matchString="import") → read import block
|
|
236
|
+
lspGotoDefinition(lineHint=N) → hop through chain
|
|
237
|
+
lspCallHierarchy(incoming, depth=1) → trace until cycle closes
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### 7 — Security Sink Validation
|
|
241
|
+
|
|
242
|
+
Trace data flow from source to sink.
|
|
243
|
+
|
|
244
|
+
```
|
|
245
|
+
ast/search.js -p 'eval($$$A)' --json --root src/
|
|
246
|
+
ast/search.js -p '$OBJ.innerHTML = $VAL' --json --root src/
|
|
247
|
+
ast/search.js -p 'exec($$$A)' --json --root src/
|
|
248
|
+
ast/search.js --rule '{"rule":{"kind":"string","regex":"password|secret|token|api.?key"}}' --json
|
|
249
|
+
localSearchCode(pattern="validate|sanitize|normalize") → find guards
|
|
250
|
+
localGetFileContent(matchString="sinkFunc", contextLines=10) → read sink context
|
|
251
|
+
lspGotoDefinition(lineHint=N) → locate sink
|
|
252
|
+
lspCallHierarchy(incoming, depth=1) → trace source
|
|
253
|
+
lspFindReferences(lineHint=N) → all call sites
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
See [validate-investigate.md](./validate-investigate.md) for taint-tracing and false-positive dismissal.
|
|
257
|
+
|
|
258
|
+
### 8 — Scoped Deep-Dive (File or Function)
|
|
259
|
+
|
|
260
|
+
Drill into a specific flagged file or function.
|
|
261
|
+
|
|
262
|
+
```
|
|
263
|
+
index.js --scope=file.ts --flow --semantic → scoped re-scan
|
|
264
|
+
index.js --scope=file.ts:funcName --features=cognitive-complexity → function-level
|
|
265
|
+
ast/tree-search.js --file 'fileName' -C 2 --limit 50 → full AST shape
|
|
266
|
+
ast/search.js -k function_declaration --json --root <dir> → function spans
|
|
267
|
+
localGetFileContent(matchString="export", contextLines=2) → public surface
|
|
268
|
+
localGetFileContent(charOffset=0, charLength=500) → imports + top
|
|
269
|
+
localGetFileContent(matchString="target", contextLines=5) → specific section
|
|
270
|
+
lspFindReferences(lineHint=N, includeDeclaration=false) → per-export consumers
|
|
271
|
+
lspCallHierarchy(outgoing, depth=1) → per-function deps
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
### 9 — Coupling Hotspot Analysis
|
|
275
|
+
|
|
276
|
+
Quantify coupling for architecture findings.
|
|
277
|
+
|
|
278
|
+
```
|
|
279
|
+
index.js --features=high-coupling,god-module-coupling --graph --graph-advanced
|
|
280
|
+
architecture.json | jq '.hotFiles[:5]' → top hotfiles
|
|
281
|
+
ast/search.js -p 'import { $$$N } from $MOD' --json --root <dir> → import density
|
|
282
|
+
localSearchCode(pattern="import.*from.*hotspot", filesOnly=true) → consumer count
|
|
283
|
+
localViewStructure(path="hotspot/", filesOnly=true) → module file count
|
|
284
|
+
localFindFiles(sortBy="size", sizeGreater="10k", path="hotspot/") → largest files
|
|
285
|
+
lspFindReferences(lineHint=N, includeDeclaration=false) → consumers per export
|
|
286
|
+
lspCallHierarchy(incoming, depth=1) → callers per function
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
High fan-in + large files = decomposition candidate. Low fan-in = less urgent.
|
|
290
|
+
|
|
291
|
+
### 10 — Fix Verification Loop
|
|
292
|
+
|
|
293
|
+
Confirm fixes reduced finding count. Run after every fix batch.
|
|
294
|
+
|
|
295
|
+
```
|
|
296
|
+
index.js --scope=<changed-files> --features=<category> → re-scan
|
|
297
|
+
ast/search.js --preset <preset> --json --root <changed-dir> → verify smells gone
|
|
298
|
+
localGetFileContent(matchString="fixedCode", contextLines=3) → spot-check fix
|
|
299
|
+
lspFindReferences(lineHint=N) → symbols still resolve
|
|
300
|
+
lspCallHierarchy(incoming, depth=1) → callers still connected
|
|
301
|
+
<pm> run lint --fix → auto-fix + check
|
|
302
|
+
<pm> run test → no regressions
|
|
303
|
+
<pm> run build → compiles clean
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
---
|
|
307
|
+
|
|
308
|
+
## Extended Workflows — Architecture, Planning, Exploration
|
|
309
|
+
|
|
310
|
+
### 11 — Pre-Implementation Check ("Where should new code live?")
|
|
311
|
+
|
|
312
|
+
Before writing new code, understand the existing landscape to pick the right location and avoid coupling traps.
|
|
313
|
+
|
|
314
|
+
```
|
|
315
|
+
localViewStructure(depth=2, directoriesOnly=true) → project layout
|
|
316
|
+
index.js --graph --graph-advanced → dependency map + hotspots
|
|
317
|
+
architecture.json | jq '.hotFiles[:5]' → avoid adding to hotspots
|
|
318
|
+
localSearchCode(pattern="similar-feature", filesOnly=true) → find analogous patterns
|
|
319
|
+
ast/search.js -p 'export function $NAME($$$P) { $$$B }' --json --root <candidate-dir>
|
|
320
|
+
→ existing public API shape
|
|
321
|
+
lspFindReferences(lineHint=N, includeDeclaration=false) → consumer count of candidate module
|
|
322
|
+
localGetFileContent(matchString="export", contextLines=2) → public surface of target
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
**Decision**: low fan-in module with related exports = good home. High fan-in hotspot = add to a new module instead. Check for existing patterns — follow the codebase's conventions.
|
|
326
|
+
|
|
327
|
+
### 12 — Refactoring Plan (Safe Restructure)
|
|
328
|
+
|
|
329
|
+
Plan a multi-file refactor with full blast radius awareness.
|
|
330
|
+
|
|
331
|
+
```
|
|
332
|
+
# Step 1: Map what exists
|
|
333
|
+
localSearchCode(pattern="targetSymbol", filesOnly=true) → all files containing symbol
|
|
334
|
+
lspFindReferences(lineHint=N, includeDeclaration=false) → all consumers
|
|
335
|
+
lspFindReferences(includePattern=["**/tests/**"]) → test coverage
|
|
336
|
+
lspFindReferences(excludePattern=["**/tests/**"]) → production consumers
|
|
337
|
+
|
|
338
|
+
# Step 2: Understand dependencies
|
|
339
|
+
lspCallHierarchy(incoming, depth=1) → who calls it?
|
|
340
|
+
lspCallHierarchy(outgoing, depth=1) → what does it depend on?
|
|
341
|
+
ast/search.js -p 'import { $$$N } from $MOD' --json --root <dir> → import graph
|
|
342
|
+
|
|
343
|
+
# Step 3: Check for hidden coupling
|
|
344
|
+
index.js --scope=<target-files> --features=architecture --graph → cycle/coupling risk
|
|
345
|
+
architecture.json | jq '.cycles' → will refactor create/break cycles?
|
|
346
|
+
|
|
347
|
+
# Step 4: Assess safety
|
|
348
|
+
index.js --scope=<target-files> --features=test-quality --include-tests → test quality around target
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
**Output**: file list + consumer count + test coverage + coupling risk = refactoring confidence level.
|
|
352
|
+
|
|
353
|
+
### 13 — Codebase Exploration (New Repo Orientation)
|
|
354
|
+
|
|
355
|
+
Quickly understand an unfamiliar codebase's shape, patterns, and conventions.
|
|
356
|
+
|
|
357
|
+
```
|
|
358
|
+
# Step 1: Layout
|
|
359
|
+
localViewStructure(depth=2, directoriesOnly=true) → top-level structure
|
|
360
|
+
localViewStructure(depth=1, path="src/", details=true) → source root shape + sizes
|
|
361
|
+
|
|
362
|
+
# Step 2: Scale and hotspots
|
|
363
|
+
localFindFiles(sortBy="size", sizeGreater="10k") → largest files = architectural hotspots
|
|
364
|
+
localFindFiles(modifiedWithin="7d", sortBy="modified") → recently active areas
|
|
365
|
+
localFindFiles(names=["index.ts", "index.js"]) → barrel files = module boundaries
|
|
366
|
+
|
|
367
|
+
# Step 3: API surface
|
|
368
|
+
localSearchCode(pattern="export", filesOnly=true, filesPerPage=5) → public API breadth
|
|
369
|
+
ast/search.js -k class_declaration --json --root src/ → class-based patterns?
|
|
370
|
+
ast/search.js -p 'export default' --json --root src/ → default export patterns?
|
|
371
|
+
|
|
372
|
+
# Step 4: Architecture shape
|
|
373
|
+
index.js --graph --flow → dependency graph + flow
|
|
374
|
+
summary.md → health scores overview
|
|
375
|
+
|
|
376
|
+
# Step 5: Conventions
|
|
377
|
+
ast/search.js -p 'import { $$$N } from $MOD' --json --limit 20 --root src/ → import style
|
|
378
|
+
localSearchCode(pattern="describe\\(|it\\(", filesOnly=true) → test patterns
|
|
379
|
+
localFindFiles(names=["*.test.ts", "*.spec.ts"]) → test file locations
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
### 14 — Test Strategy Analysis
|
|
383
|
+
|
|
384
|
+
Map test coverage gaps and test quality issues.
|
|
385
|
+
|
|
386
|
+
```
|
|
387
|
+
# Step 1: Test landscape
|
|
388
|
+
localFindFiles(names=["*.test.ts", "*.spec.ts", "*.test.js"]) → all test files
|
|
389
|
+
localViewStructure(path="tests/", depth=2, directoriesOnly=true) → test structure
|
|
390
|
+
localSearchCode(pattern="describe\\(", filesOnly=true) → test file density
|
|
391
|
+
|
|
392
|
+
# Step 2: Coverage gaps — find untested exports
|
|
393
|
+
localSearchCode(pattern="export function", filesOnly=true, path="src/")
|
|
394
|
+
lspFindReferences(lineHint=N, includePattern=["**/tests/**"]) → per-export test refs
|
|
395
|
+
→ 0 test refs = coverage gap
|
|
396
|
+
|
|
397
|
+
# Step 3: Test quality
|
|
398
|
+
index.js --features=test-quality --include-tests → flaky patterns, mock abuse
|
|
399
|
+
ast/search.js --preset empty-catch --json --include-tests → swallowed errors in tests
|
|
400
|
+
ast/search.js -p 'vi.mock($$$A)' --json --include-tests → mock density
|
|
401
|
+
ast/search.js -p 'expect($$$A)' --json --include-tests → assertion density
|
|
402
|
+
|
|
403
|
+
# Step 4: Critical untested code
|
|
404
|
+
index.js --graph --features=architecture → identify critical paths
|
|
405
|
+
architecture.json | jq '.hotFiles[:5]' → high-risk files
|
|
406
|
+
lspFindReferences(lineHint=N, includePattern=["**/tests/**"]) → test coverage per hotfile
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
**Output**: untested exports list + test quality findings + critical untested hotspots = test priority plan.
|
|
410
|
+
|
|
411
|
+
### 15 — Code Review Support (Change Impact Analysis)
|
|
412
|
+
|
|
413
|
+
Assess the architectural impact of a set of changed files.
|
|
414
|
+
|
|
415
|
+
```
|
|
416
|
+
# Step 1: Understand the changes
|
|
417
|
+
localGetFileContent(matchString="changed-function", contextLines=5) → read changed code
|
|
418
|
+
|
|
419
|
+
# Step 2: Blast radius per changed symbol
|
|
420
|
+
localSearchCode(pattern="changedSymbol") → lineHint
|
|
421
|
+
lspFindReferences(lineHint=N, includeDeclaration=false) → all consumers affected
|
|
422
|
+
lspFindReferences(excludePattern=["**/tests/**"]) → production impact only
|
|
423
|
+
lspCallHierarchy(incoming, depth=1) → direct callers
|
|
424
|
+
|
|
425
|
+
# Step 3: Architecture effect
|
|
426
|
+
index.js --scope=<changed-files> --features=architecture --graph → coupling/cycle delta
|
|
427
|
+
ast/search.js -p 'import { $$$N } from $MOD' --json --root <dir> → new import patterns
|
|
428
|
+
|
|
429
|
+
# Step 4: Quality check on changed code
|
|
430
|
+
index.js --scope=<changed-files> --features=code-quality,security → new quality issues?
|
|
431
|
+
ast/search.js --preset any-type --json --root <changed-dir> → new `: any` introduced?
|
|
432
|
+
ast/search.js --preset empty-catch --json --root <changed-dir> → new empty catches?
|
|
433
|
+
|
|
434
|
+
# Step 5: Test coverage of changes
|
|
435
|
+
lspFindReferences(lineHint=N, includePattern=["**/tests/**"]) → are changes tested?
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
**Output**: consumer impact count + architecture delta + new quality issues + test coverage = review verdict.
|
|
439
|
+
|
|
440
|
+
### 16 — Code Quality Review (Module or File)
|
|
441
|
+
|
|
442
|
+
Focused quality review of a specific module, file, or directory — smells, complexity, dead code, type safety, and maintainability.
|
|
443
|
+
|
|
444
|
+
```
|
|
445
|
+
# Step 1: Scoped scan with all quality signals
|
|
446
|
+
index.js --scope=<target> --features=code-quality,dead-code --flow --semantic
|
|
447
|
+
summary.md → health scores for target
|
|
448
|
+
findings.json | jq '.[:10]' → top findings
|
|
449
|
+
|
|
450
|
+
# Step 2: AST smell sweep (zero false-positive structural checks)
|
|
451
|
+
ast/search.js --preset empty-catch --json --root <target>
|
|
452
|
+
ast/search.js --preset any-type --json --root <target>
|
|
453
|
+
ast/search.js --preset type-assertion --json --root <target>
|
|
454
|
+
ast/search.js --preset non-null-assertion --json --root <target>
|
|
455
|
+
ast/search.js --preset console-log --json --root <target>
|
|
456
|
+
ast/search.js --preset nested-ternary --json --root <target>
|
|
457
|
+
ast/search.js --preset switch-no-default --json --root <target>
|
|
458
|
+
|
|
459
|
+
# Step 3: Complexity and god-module check
|
|
460
|
+
ast/tree-search.js --file '<target>' -k function_declaration -C 2 → function spans + nesting
|
|
461
|
+
index.js --scope=<target> --features=cognitive-complexity,god-module,god-function
|
|
462
|
+
|
|
463
|
+
# Step 4: Dead code in target
|
|
464
|
+
lspFindReferences(lineHint=N, includeDeclaration=false) → per-export consumer count
|
|
465
|
+
→ 0 refs = dead export
|
|
466
|
+
ast/search.js -p 'import { $$$N } from $MOD' --json → structural cross-check
|
|
467
|
+
|
|
468
|
+
# Step 5: Maintainability assessment
|
|
469
|
+
localGetFileContent(matchString="export", contextLines=2) → public surface size
|
|
470
|
+
lspCallHierarchy(outgoing, depth=1) → dependency count per function
|
|
471
|
+
lspCallHierarchy(incoming, depth=1) → fan-in per export
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
**Output**: smell count + complexity scores + dead exports + fan-in/fan-out + maintainability = quality verdict with file:line evidence.
|
|
475
|
+
|
|
476
|
+
### 17 — Full Architecture Analysis
|
|
477
|
+
|
|
478
|
+
Complete architecture health assessment: dependency graph, cycles, coupling, boundaries, critical paths.
|
|
479
|
+
|
|
480
|
+
```
|
|
481
|
+
# Step 1: Full architecture scan
|
|
482
|
+
index.js --graph --graph-advanced --flow --features=architecture
|
|
483
|
+
summary.md → architecture health score
|
|
484
|
+
architecture.json | jq '.cycles' → all dependency cycles
|
|
485
|
+
architecture.json | jq '.hotFiles[:10]' → top risk files (fan-in + complexity + cycle membership)
|
|
486
|
+
architecture.json | jq '.sccClusters' → strongly connected components
|
|
487
|
+
architecture.json | jq '.chokepoints' → architectural bottlenecks
|
|
488
|
+
graph.md → Mermaid dependency visualization
|
|
489
|
+
|
|
490
|
+
# Step 2: Validate top hotspots with LSP
|
|
491
|
+
localSearchCode(pattern="hotFileName", filesOnly=true) → lineHint
|
|
492
|
+
lspFindReferences(lineHint=N, includeDeclaration=false) → fan-in (consumer count)
|
|
493
|
+
lspCallHierarchy(outgoing, depth=1) → fan-out (dependency count)
|
|
494
|
+
lspCallHierarchy(incoming, depth=1) → direct callers
|
|
495
|
+
|
|
496
|
+
# Step 3: Module boundary analysis
|
|
497
|
+
ast/search.js -p 'import { $$$N } from $MOD' --json --root src/ → cross-module imports
|
|
498
|
+
localSearchCode(pattern="export \\* from", filesOnly=true) → barrel re-exports
|
|
499
|
+
index.js --features=package-boundary-violation,layer-violation → boundary violations
|
|
500
|
+
|
|
501
|
+
# Step 4: Cycle deep-dive (per cycle)
|
|
502
|
+
ast/search.js -p 'import { $$$N } from $MOD' --json --root <cycle-dir>
|
|
503
|
+
lspGotoDefinition(lineHint=N) → hop through cycle
|
|
504
|
+
localGetFileContent(matchString="import") → confirm back-edge
|
|
505
|
+
|
|
506
|
+
# Step 5: Critical path analysis
|
|
507
|
+
architecture.json | jq '.criticalPaths' → longest dependency chains
|
|
508
|
+
lspCallHierarchy(incoming, depth=1) → who depends on each hub?
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
**Output**: cycle list + SCC clusters + chokepoints + hotfiles (ranked) + boundary violations + critical paths + fan-in/fan-out per module = full architecture health report.
|
|
512
|
+
|
|
513
|
+
### 18 — Smart Coding (Impact-Aware Changes)
|
|
514
|
+
|
|
515
|
+
Before and after making code changes, check blast radius and verify safety. Use this whenever implementing features, fixing bugs, or modifying existing code.
|
|
516
|
+
|
|
517
|
+
```
|
|
518
|
+
# === BEFORE CODING ===
|
|
519
|
+
|
|
520
|
+
# Step 1: Understand the target area
|
|
521
|
+
localViewStructure(path="target/dir", depth=2) → module layout
|
|
522
|
+
localGetFileContent(matchString="targetFunction", contextLines=10) → read current code
|
|
523
|
+
lspGotoDefinition(lineHint=N) → understand definitions
|
|
524
|
+
|
|
525
|
+
# Step 2: Blast radius check
|
|
526
|
+
localSearchCode(pattern="targetSymbol") → lineHint
|
|
527
|
+
lspFindReferences(lineHint=N, includeDeclaration=false) → total consumers
|
|
528
|
+
lspFindReferences(excludePattern=["**/tests/**"]) → production consumers
|
|
529
|
+
lspFindReferences(includePattern=["**/tests/**"]) → test coverage
|
|
530
|
+
lspCallHierarchy(incoming, depth=1) → direct callers
|
|
531
|
+
|
|
532
|
+
# Step 3: Architecture safety
|
|
533
|
+
index.js --scope=<target-files> --features=architecture --graph → coupling/cycle risk
|
|
534
|
+
architecture.json | jq '.cycles' → will change create new cycles?
|
|
535
|
+
|
|
536
|
+
# Step 4: Existing patterns (follow conventions)
|
|
537
|
+
ast/search.js -p 'similar-pattern' --json --root <nearby-dir> → how does the codebase do this?
|
|
538
|
+
localSearchCode(pattern="similar-feature", filesOnly=true) → analogous implementations
|
|
539
|
+
|
|
540
|
+
# === MAKE THE CHANGE ===
|
|
541
|
+
|
|
542
|
+
# Step 5: Implement the code change
|
|
543
|
+
# ... (apply edits) ...
|
|
544
|
+
|
|
545
|
+
# === AFTER CODING ===
|
|
546
|
+
|
|
547
|
+
# Step 6: Verify no new issues
|
|
548
|
+
index.js --scope=<changed-files> --features=code-quality,architecture
|
|
549
|
+
ast/search.js --preset any-type --json --root <changed-dir> → no new `: any`?
|
|
550
|
+
ast/search.js --preset empty-catch --json --root <changed-dir> → no new swallowed errors?
|
|
551
|
+
|
|
552
|
+
# Step 7: Verify references intact
|
|
553
|
+
lspFindReferences(lineHint=N) → moved/renamed symbols resolve
|
|
554
|
+
lspCallHierarchy(incoming, depth=1) → callers still connected
|
|
555
|
+
|
|
556
|
+
# Step 8: Project toolchain
|
|
557
|
+
<pm> run lint --fix
|
|
558
|
+
<pm> run test
|
|
559
|
+
<pm> run build
|
|
560
|
+
```
|
|
561
|
+
|
|
562
|
+
**Decision gates**:
|
|
563
|
+
- Step 2: >20 production consumers = high-risk change, consider feature flag or incremental migration
|
|
564
|
+
- Step 3: change touches cycle member or hotfile = extra caution, verify with re-scan after
|
|
565
|
+
- Step 6: new findings = fix before committing
|
|
566
|
+
- Step 8: any failure = investigate before proceeding
|