opencode-telos 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +927 -0
- package/dist/code-intelligence/analyzer.d.ts +9 -0
- package/dist/code-intelligence/analyzer.d.ts.map +1 -0
- package/dist/code-intelligence/analyzer.js +321 -0
- package/dist/code-intelligence/analyzer.js.map +1 -0
- package/dist/code-intelligence/ast/cache.d.ts +16 -0
- package/dist/code-intelligence/ast/cache.d.ts.map +1 -0
- package/dist/code-intelligence/ast/cache.js +44 -0
- package/dist/code-intelligence/ast/cache.js.map +1 -0
- package/dist/code-intelligence/ast/common.d.ts +8 -0
- package/dist/code-intelligence/ast/common.d.ts.map +1 -0
- package/dist/code-intelligence/ast/common.js +42 -0
- package/dist/code-intelligence/ast/common.js.map +1 -0
- package/dist/code-intelligence/ast/component.d.ts +10 -0
- package/dist/code-intelligence/ast/component.d.ts.map +1 -0
- package/dist/code-intelligence/ast/component.js +38 -0
- package/dist/code-intelligence/ast/component.js.map +1 -0
- package/dist/code-intelligence/ast/fallback.d.ts +9 -0
- package/dist/code-intelligence/ast/fallback.d.ts.map +1 -0
- package/dist/code-intelligence/ast/fallback.js +38 -0
- package/dist/code-intelligence/ast/fallback.js.map +1 -0
- package/dist/code-intelligence/ast/index.d.ts +5 -0
- package/dist/code-intelligence/ast/index.d.ts.map +1 -0
- package/dist/code-intelligence/ast/index.js +5 -0
- package/dist/code-intelligence/ast/index.js.map +1 -0
- package/dist/code-intelligence/ast/ir.d.ts +72 -0
- package/dist/code-intelligence/ast/ir.d.ts.map +1 -0
- package/dist/code-intelligence/ast/ir.js +2 -0
- package/dist/code-intelligence/ast/ir.js.map +1 -0
- package/dist/code-intelligence/ast/metrics.d.ts +25 -0
- package/dist/code-intelligence/ast/metrics.d.ts.map +1 -0
- package/dist/code-intelligence/ast/metrics.js +38 -0
- package/dist/code-intelligence/ast/metrics.js.map +1 -0
- package/dist/code-intelligence/ast/registry.d.ts +5 -0
- package/dist/code-intelligence/ast/registry.d.ts.map +1 -0
- package/dist/code-intelligence/ast/registry.js +22 -0
- package/dist/code-intelligence/ast/registry.js.map +1 -0
- package/dist/code-intelligence/ast/tree-sitter.d.ts +8 -0
- package/dist/code-intelligence/ast/tree-sitter.d.ts.map +1 -0
- package/dist/code-intelligence/ast/tree-sitter.js +247 -0
- package/dist/code-intelligence/ast/tree-sitter.js.map +1 -0
- package/dist/code-intelligence/ast/typescript.d.ts +8 -0
- package/dist/code-intelligence/ast/typescript.d.ts.map +1 -0
- package/dist/code-intelligence/ast/typescript.js +147 -0
- package/dist/code-intelligence/ast/typescript.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/server.d.ts +27 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +67 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/opencode/hooks.d.ts +9 -0
- package/dist/opencode/hooks.d.ts.map +1 -0
- package/dist/opencode/hooks.js +583 -0
- package/dist/opencode/hooks.js.map +1 -0
- package/dist/opencode/router/categories.d.ts +31 -0
- package/dist/opencode/router/categories.d.ts.map +1 -0
- package/dist/opencode/router/categories.js +165 -0
- package/dist/opencode/router/categories.js.map +1 -0
- package/dist/opencode/router/embeddings.d.ts +41 -0
- package/dist/opencode/router/embeddings.d.ts.map +1 -0
- package/dist/opencode/router/embeddings.js +136 -0
- package/dist/opencode/router/embeddings.js.map +1 -0
- package/dist/opencode/router/graph-state-snapshot.d.ts +35 -0
- package/dist/opencode/router/graph-state-snapshot.d.ts.map +1 -0
- package/dist/opencode/router/graph-state-snapshot.js +129 -0
- package/dist/opencode/router/graph-state-snapshot.js.map +1 -0
- package/dist/opencode/router/index.d.ts +21 -0
- package/dist/opencode/router/index.d.ts.map +1 -0
- package/dist/opencode/router/index.js +23 -0
- package/dist/opencode/router/index.js.map +1 -0
- package/dist/opencode/router/intent-classifier.d.ts +35 -0
- package/dist/opencode/router/intent-classifier.d.ts.map +1 -0
- package/dist/opencode/router/intent-classifier.js +108 -0
- package/dist/opencode/router/intent-classifier.js.map +1 -0
- package/dist/opencode/router/semantic-nudge.d.ts +42 -0
- package/dist/opencode/router/semantic-nudge.d.ts.map +1 -0
- package/dist/opencode/router/semantic-nudge.js +73 -0
- package/dist/opencode/router/semantic-nudge.js.map +1 -0
- package/dist/opencode/router/state-gate.d.ts +25 -0
- package/dist/opencode/router/state-gate.d.ts.map +1 -0
- package/dist/opencode/router/state-gate.js +178 -0
- package/dist/opencode/router/state-gate.js.map +1 -0
- package/dist/opencode/router/tool-embeddings.d.ts +36 -0
- package/dist/opencode/router/tool-embeddings.d.ts.map +1 -0
- package/dist/opencode/router/tool-embeddings.js +140 -0
- package/dist/opencode/router/tool-embeddings.js.map +1 -0
- package/dist/opencode/router/tool-registry.d.ts +45 -0
- package/dist/opencode/router/tool-registry.d.ts.map +1 -0
- package/dist/opencode/router/tool-registry.js +103 -0
- package/dist/opencode/router/tool-registry.js.map +1 -0
- package/dist/opencode/router/tool-taxonomy.d.ts +51 -0
- package/dist/opencode/router/tool-taxonomy.d.ts.map +1 -0
- package/dist/opencode/router/tool-taxonomy.js +250 -0
- package/dist/opencode/router/tool-taxonomy.js.map +1 -0
- package/dist/opencode/router/tools-composite.d.ts +21 -0
- package/dist/opencode/router/tools-composite.d.ts.map +1 -0
- package/dist/opencode/router/tools-composite.js +684 -0
- package/dist/opencode/router/tools-composite.js.map +1 -0
- package/dist/opencode/shell-hooks.d.ts +7 -0
- package/dist/opencode/shell-hooks.d.ts.map +1 -0
- package/dist/opencode/shell-hooks.js +96 -0
- package/dist/opencode/shell-hooks.js.map +1 -0
- package/dist/opencode/system-prompt.d.ts +10 -0
- package/dist/opencode/system-prompt.d.ts.map +1 -0
- package/dist/opencode/system-prompt.js +600 -0
- package/dist/opencode/system-prompt.js.map +1 -0
- package/dist/opencode/tools.d.ts +8 -0
- package/dist/opencode/tools.d.ts.map +1 -0
- package/dist/opencode/tools.js +3731 -0
- package/dist/opencode/tools.js.map +1 -0
- package/dist/opencode/workflows/chains.d.ts +52 -0
- package/dist/opencode/workflows/chains.d.ts.map +1 -0
- package/dist/opencode/workflows/chains.js +170 -0
- package/dist/opencode/workflows/chains.js.map +1 -0
- package/dist/opencode/workflows/executor.d.ts +52 -0
- package/dist/opencode/workflows/executor.d.ts.map +1 -0
- package/dist/opencode/workflows/executor.js +130 -0
- package/dist/opencode/workflows/executor.js.map +1 -0
- package/dist/opencode/workflows/index.d.ts +14 -0
- package/dist/opencode/workflows/index.d.ts.map +1 -0
- package/dist/opencode/workflows/index.js +15 -0
- package/dist/opencode/workflows/index.js.map +1 -0
- package/dist/opencode/workflows/tools-workflow.d.ts +24 -0
- package/dist/opencode/workflows/tools-workflow.d.ts.map +1 -0
- package/dist/opencode/workflows/tools-workflow.js +85 -0
- package/dist/opencode/workflows/tools-workflow.js.map +1 -0
- package/dist/opencode/workflows/types.d.ts +32 -0
- package/dist/opencode/workflows/types.d.ts.map +1 -0
- package/dist/opencode/workflows/types.js +13 -0
- package/dist/opencode/workflows/types.js.map +1 -0
- package/dist/sdd/analysis/compliance.d.ts +30 -0
- package/dist/sdd/analysis/compliance.d.ts.map +1 -0
- package/dist/sdd/analysis/compliance.js +251 -0
- package/dist/sdd/analysis/compliance.js.map +1 -0
- package/dist/sdd/analysis/scalability.d.ts +15 -0
- package/dist/sdd/analysis/scalability.d.ts.map +1 -0
- package/dist/sdd/analysis/scalability.js +72 -0
- package/dist/sdd/analysis/scalability.js.map +1 -0
- package/dist/sdd/analysis/security.d.ts +25 -0
- package/dist/sdd/analysis/security.d.ts.map +1 -0
- package/dist/sdd/analysis/security.js +94 -0
- package/dist/sdd/analysis/security.js.map +1 -0
- package/dist/sdd/brownfield/scanner.d.ts +31 -0
- package/dist/sdd/brownfield/scanner.d.ts.map +1 -0
- package/dist/sdd/brownfield/scanner.js +228 -0
- package/dist/sdd/brownfield/scanner.js.map +1 -0
- package/dist/sdd/cache/manager.d.ts +237 -0
- package/dist/sdd/cache/manager.d.ts.map +1 -0
- package/dist/sdd/cache/manager.js +770 -0
- package/dist/sdd/cache/manager.js.map +1 -0
- package/dist/sdd/cache/snapshot-store.d.ts +39 -0
- package/dist/sdd/cache/snapshot-store.d.ts.map +1 -0
- package/dist/sdd/cache/snapshot-store.js +156 -0
- package/dist/sdd/cache/snapshot-store.js.map +1 -0
- package/dist/sdd/changes/manager.d.ts +58 -0
- package/dist/sdd/changes/manager.d.ts.map +1 -0
- package/dist/sdd/changes/manager.js +235 -0
- package/dist/sdd/changes/manager.js.map +1 -0
- package/dist/sdd/cicd/generators.d.ts +16 -0
- package/dist/sdd/cicd/generators.d.ts.map +1 -0
- package/dist/sdd/cicd/generators.js +1042 -0
- package/dist/sdd/cicd/generators.js.map +1 -0
- package/dist/sdd/code-quality/complexity.d.ts +38 -0
- package/dist/sdd/code-quality/complexity.d.ts.map +1 -0
- package/dist/sdd/code-quality/complexity.js +161 -0
- package/dist/sdd/code-quality/complexity.js.map +1 -0
- package/dist/sdd/code-quality/conventions.d.ts +33 -0
- package/dist/sdd/code-quality/conventions.d.ts.map +1 -0
- package/dist/sdd/code-quality/conventions.js +193 -0
- package/dist/sdd/code-quality/conventions.js.map +1 -0
- package/dist/sdd/code-quality/dependencies.d.ts +27 -0
- package/dist/sdd/code-quality/dependencies.d.ts.map +1 -0
- package/dist/sdd/code-quality/dependencies.js +142 -0
- package/dist/sdd/code-quality/dependencies.js.map +1 -0
- package/dist/sdd/code-quality/import-analyzer.d.ts +49 -0
- package/dist/sdd/code-quality/import-analyzer.d.ts.map +1 -0
- package/dist/sdd/code-quality/import-analyzer.js +213 -0
- package/dist/sdd/code-quality/import-analyzer.js.map +1 -0
- package/dist/sdd/code-quality/metrics.d.ts +35 -0
- package/dist/sdd/code-quality/metrics.d.ts.map +1 -0
- package/dist/sdd/code-quality/metrics.js +172 -0
- package/dist/sdd/code-quality/metrics.js.map +1 -0
- package/dist/sdd/code-quality/smells.d.ts +38 -0
- package/dist/sdd/code-quality/smells.d.ts.map +1 -0
- package/dist/sdd/code-quality/smells.js +319 -0
- package/dist/sdd/code-quality/smells.js.map +1 -0
- package/dist/sdd/code-quality/symbol-parser.d.ts +28 -0
- package/dist/sdd/code-quality/symbol-parser.d.ts.map +1 -0
- package/dist/sdd/code-quality/symbol-parser.js +230 -0
- package/dist/sdd/code-quality/symbol-parser.js.map +1 -0
- package/dist/sdd/code-quality/usage-tracker.d.ts +59 -0
- package/dist/sdd/code-quality/usage-tracker.d.ts.map +1 -0
- package/dist/sdd/code-quality/usage-tracker.js +402 -0
- package/dist/sdd/code-quality/usage-tracker.js.map +1 -0
- package/dist/sdd/code-quality/utils.d.ts +6 -0
- package/dist/sdd/code-quality/utils.d.ts.map +1 -0
- package/dist/sdd/code-quality/utils.js +14 -0
- package/dist/sdd/code-quality/utils.js.map +1 -0
- package/dist/sdd/codegen/generator.d.ts +42 -0
- package/dist/sdd/codegen/generator.d.ts.map +1 -0
- package/dist/sdd/codegen/generator.js +1023 -0
- package/dist/sdd/codegen/generator.js.map +1 -0
- package/dist/sdd/constitution/validator.d.ts +37 -0
- package/dist/sdd/constitution/validator.d.ts.map +1 -0
- package/dist/sdd/constitution/validator.js +192 -0
- package/dist/sdd/constitution/validator.js.map +1 -0
- package/dist/sdd/cost/estimator.d.ts +31 -0
- package/dist/sdd/cost/estimator.d.ts.map +1 -0
- package/dist/sdd/cost/estimator.js +92 -0
- package/dist/sdd/cost/estimator.js.map +1 -0
- package/dist/sdd/coverage/tracker.d.ts +47 -0
- package/dist/sdd/coverage/tracker.d.ts.map +1 -0
- package/dist/sdd/coverage/tracker.js +251 -0
- package/dist/sdd/coverage/tracker.js.map +1 -0
- package/dist/sdd/disaster/recovery.d.ts +11 -0
- package/dist/sdd/disaster/recovery.d.ts.map +1 -0
- package/dist/sdd/disaster/recovery.js +55 -0
- package/dist/sdd/disaster/recovery.js.map +1 -0
- package/dist/sdd/discovery/adaptive.d.ts +14 -0
- package/dist/sdd/discovery/adaptive.d.ts.map +1 -0
- package/dist/sdd/discovery/adaptive.js +145 -0
- package/dist/sdd/discovery/adaptive.js.map +1 -0
- package/dist/sdd/discovery/briefing-analyzer.d.ts +66 -0
- package/dist/sdd/discovery/briefing-analyzer.d.ts.map +1 -0
- package/dist/sdd/discovery/briefing-analyzer.js +672 -0
- package/dist/sdd/discovery/briefing-analyzer.js.map +1 -0
- package/dist/sdd/discovery/briefing.d.ts +109 -0
- package/dist/sdd/discovery/briefing.d.ts.map +1 -0
- package/dist/sdd/discovery/briefing.js +617 -0
- package/dist/sdd/discovery/briefing.js.map +1 -0
- package/dist/sdd/discovery/graph-builder.d.ts +10 -0
- package/dist/sdd/discovery/graph-builder.d.ts.map +1 -0
- package/dist/sdd/discovery/graph-builder.js +510 -0
- package/dist/sdd/discovery/graph-builder.js.map +1 -0
- package/dist/sdd/documentation/generator.d.ts +7 -0
- package/dist/sdd/documentation/generator.d.ts.map +1 -0
- package/dist/sdd/documentation/generator.js +119 -0
- package/dist/sdd/documentation/generator.js.map +1 -0
- package/dist/sdd/domain/types.d.ts +460 -0
- package/dist/sdd/domain/types.d.ts.map +1 -0
- package/dist/sdd/domain/types.js +25 -0
- package/dist/sdd/domain/types.js.map +1 -0
- package/dist/sdd/drift/detector.d.ts +28 -0
- package/dist/sdd/drift/detector.d.ts.map +1 -0
- package/dist/sdd/drift/detector.js +379 -0
- package/dist/sdd/drift/detector.js.map +1 -0
- package/dist/sdd/drift/exclusion.d.ts +54 -0
- package/dist/sdd/drift/exclusion.d.ts.map +1 -0
- package/dist/sdd/drift/exclusion.js +179 -0
- package/dist/sdd/drift/exclusion.js.map +1 -0
- package/dist/sdd/drift/signals.d.ts +52 -0
- package/dist/sdd/drift/signals.d.ts.map +1 -0
- package/dist/sdd/drift/signals.js +470 -0
- package/dist/sdd/drift/signals.js.map +1 -0
- package/dist/sdd/enforcement/interceptor.d.ts +47 -0
- package/dist/sdd/enforcement/interceptor.d.ts.map +1 -0
- package/dist/sdd/enforcement/interceptor.js +365 -0
- package/dist/sdd/enforcement/interceptor.js.map +1 -0
- package/dist/sdd/enforcement/workflow-tracker.d.ts +66 -0
- package/dist/sdd/enforcement/workflow-tracker.d.ts.map +1 -0
- package/dist/sdd/enforcement/workflow-tracker.js +229 -0
- package/dist/sdd/enforcement/workflow-tracker.js.map +1 -0
- package/dist/sdd/graph/engine.d.ts +44 -0
- package/dist/sdd/graph/engine.d.ts.map +1 -0
- package/dist/sdd/graph/engine.js +203 -0
- package/dist/sdd/graph/engine.js.map +1 -0
- package/dist/sdd/graph/index.d.ts +160 -0
- package/dist/sdd/graph/index.d.ts.map +1 -0
- package/dist/sdd/graph/index.js +624 -0
- package/dist/sdd/graph/index.js.map +1 -0
- package/dist/sdd/graph/integrity-guard.d.ts +129 -0
- package/dist/sdd/graph/integrity-guard.d.ts.map +1 -0
- package/dist/sdd/graph/integrity-guard.js +263 -0
- package/dist/sdd/graph/integrity-guard.js.map +1 -0
- package/dist/sdd/graph/integrity.d.ts +79 -0
- package/dist/sdd/graph/integrity.d.ts.map +1 -0
- package/dist/sdd/graph/integrity.js +462 -0
- package/dist/sdd/graph/integrity.js.map +1 -0
- package/dist/sdd/graph/pruner.d.ts +27 -0
- package/dist/sdd/graph/pruner.d.ts.map +1 -0
- package/dist/sdd/graph/pruner.js +203 -0
- package/dist/sdd/graph/pruner.js.map +1 -0
- package/dist/sdd/graph/traverse.d.ts +43 -0
- package/dist/sdd/graph/traverse.d.ts.map +1 -0
- package/dist/sdd/graph/traverse.js +265 -0
- package/dist/sdd/graph/traverse.js.map +1 -0
- package/dist/sdd/incidents/manager.d.ts +10 -0
- package/dist/sdd/incidents/manager.d.ts.map +1 -0
- package/dist/sdd/incidents/manager.js +63 -0
- package/dist/sdd/incidents/manager.js.map +1 -0
- package/dist/sdd/knowledge/transfer.d.ts +24 -0
- package/dist/sdd/knowledge/transfer.d.ts.map +1 -0
- package/dist/sdd/knowledge/transfer.js +94 -0
- package/dist/sdd/knowledge/transfer.js.map +1 -0
- package/dist/sdd/migrations/fixes.d.ts +2 -0
- package/dist/sdd/migrations/fixes.d.ts.map +1 -0
- package/dist/sdd/migrations/fixes.js +159 -0
- package/dist/sdd/migrations/fixes.js.map +1 -0
- package/dist/sdd/migrations/index.d.ts +2 -0
- package/dist/sdd/migrations/index.d.ts.map +1 -0
- package/dist/sdd/migrations/index.js +5 -0
- package/dist/sdd/migrations/index.js.map +1 -0
- package/dist/sdd/migrations/migration-runner.d.ts +41 -0
- package/dist/sdd/migrations/migration-runner.d.ts.map +1 -0
- package/dist/sdd/migrations/migration-runner.js +91 -0
- package/dist/sdd/migrations/migration-runner.js.map +1 -0
- package/dist/sdd/monitoring/setup.d.ts +40 -0
- package/dist/sdd/monitoring/setup.d.ts.map +1 -0
- package/dist/sdd/monitoring/setup.js +177 -0
- package/dist/sdd/monitoring/setup.js.map +1 -0
- package/dist/sdd/monitoring/telemetry.d.ts +18 -0
- package/dist/sdd/monitoring/telemetry.d.ts.map +1 -0
- package/dist/sdd/monitoring/telemetry.js +37 -0
- package/dist/sdd/monitoring/telemetry.js.map +1 -0
- package/dist/sdd/patterns/anti-patterns.d.ts +21 -0
- package/dist/sdd/patterns/anti-patterns.d.ts.map +1 -0
- package/dist/sdd/patterns/anti-patterns.js +286 -0
- package/dist/sdd/patterns/anti-patterns.js.map +1 -0
- package/dist/sdd/patterns/ast-clones.d.ts +23 -0
- package/dist/sdd/patterns/ast-clones.d.ts.map +1 -0
- package/dist/sdd/patterns/ast-clones.js +171 -0
- package/dist/sdd/patterns/ast-clones.js.map +1 -0
- package/dist/sdd/patterns/config-drift.d.ts +16 -0
- package/dist/sdd/patterns/config-drift.d.ts.map +1 -0
- package/dist/sdd/patterns/config-drift.js +322 -0
- package/dist/sdd/patterns/config-drift.js.map +1 -0
- package/dist/sdd/patterns/contradictions.d.ts +38 -0
- package/dist/sdd/patterns/contradictions.d.ts.map +1 -0
- package/dist/sdd/patterns/contradictions.js +237 -0
- package/dist/sdd/patterns/contradictions.js.map +1 -0
- package/dist/sdd/patterns/learner.d.ts +49 -0
- package/dist/sdd/patterns/learner.d.ts.map +1 -0
- package/dist/sdd/patterns/learner.js +226 -0
- package/dist/sdd/patterns/learner.js.map +1 -0
- package/dist/sdd/permissions/access.d.ts +69 -0
- package/dist/sdd/permissions/access.d.ts.map +1 -0
- package/dist/sdd/permissions/access.js +333 -0
- package/dist/sdd/permissions/access.js.map +1 -0
- package/dist/sdd/persistence/repository.d.ts +60 -0
- package/dist/sdd/persistence/repository.d.ts.map +1 -0
- package/dist/sdd/persistence/repository.js +96 -0
- package/dist/sdd/persistence/repository.js.map +1 -0
- package/dist/sdd/persistence/sqlite.d.ts +122 -0
- package/dist/sdd/persistence/sqlite.d.ts.map +1 -0
- package/dist/sdd/persistence/sqlite.js +602 -0
- package/dist/sdd/persistence/sqlite.js.map +1 -0
- package/dist/sdd/persistence/yaml.d.ts +41 -0
- package/dist/sdd/persistence/yaml.d.ts.map +1 -0
- package/dist/sdd/persistence/yaml.js +382 -0
- package/dist/sdd/persistence/yaml.js.map +1 -0
- package/dist/sdd/promises/classifier.d.ts +48 -0
- package/dist/sdd/promises/classifier.d.ts.map +1 -0
- package/dist/sdd/promises/classifier.js +215 -0
- package/dist/sdd/promises/classifier.js.map +1 -0
- package/dist/sdd/promises/tracker.d.ts +20 -0
- package/dist/sdd/promises/tracker.d.ts.map +1 -0
- package/dist/sdd/promises/tracker.js +204 -0
- package/dist/sdd/promises/tracker.js.map +1 -0
- package/dist/sdd/quality/scorer.d.ts +44 -0
- package/dist/sdd/quality/scorer.d.ts.map +1 -0
- package/dist/sdd/quality/scorer.js +216 -0
- package/dist/sdd/quality/scorer.js.map +1 -0
- package/dist/sdd/rollback/manager.d.ts +45 -0
- package/dist/sdd/rollback/manager.d.ts.map +1 -0
- package/dist/sdd/rollback/manager.js +266 -0
- package/dist/sdd/rollback/manager.js.map +1 -0
- package/dist/sdd/session/handoff.d.ts +52 -0
- package/dist/sdd/session/handoff.d.ts.map +1 -0
- package/dist/sdd/session/handoff.js +264 -0
- package/dist/sdd/session/handoff.js.map +1 -0
- package/dist/sdd/sla/tracker.d.ts +11 -0
- package/dist/sdd/sla/tracker.d.ts.map +1 -0
- package/dist/sdd/sla/tracker.js +52 -0
- package/dist/sdd/sla/tracker.js.map +1 -0
- package/dist/sdd/sync/git-sync.d.ts +61 -0
- package/dist/sdd/sync/git-sync.d.ts.map +1 -0
- package/dist/sdd/sync/git-sync.js +297 -0
- package/dist/sdd/sync/git-sync.js.map +1 -0
- package/dist/sdd/toggle/state.d.ts +8 -0
- package/dist/sdd/toggle/state.d.ts.map +1 -0
- package/dist/sdd/toggle/state.js +32 -0
- package/dist/sdd/toggle/state.js.map +1 -0
- package/dist/sdd/transactions/manager.d.ts +12 -0
- package/dist/sdd/transactions/manager.d.ts.map +1 -0
- package/dist/sdd/transactions/manager.js +80 -0
- package/dist/sdd/transactions/manager.js.map +1 -0
- package/dist/sdd/validation/coverage-index.d.ts +117 -0
- package/dist/sdd/validation/coverage-index.d.ts.map +1 -0
- package/dist/sdd/validation/coverage-index.js +251 -0
- package/dist/sdd/validation/coverage-index.js.map +1 -0
- package/dist/sdd/validation/executable.d.ts +26 -0
- package/dist/sdd/validation/executable.d.ts.map +1 -0
- package/dist/sdd/validation/executable.js +122 -0
- package/dist/sdd/validation/executable.js.map +1 -0
- package/dist/sdd/validation/smart-validator.d.ts +53 -0
- package/dist/sdd/validation/smart-validator.d.ts.map +1 -0
- package/dist/sdd/validation/smart-validator.js +347 -0
- package/dist/sdd/validation/smart-validator.js.map +1 -0
- package/dist/sdd/validation/validator.d.ts +39 -0
- package/dist/sdd/validation/validator.d.ts.map +1 -0
- package/dist/sdd/validation/validator.js +512 -0
- package/dist/sdd/validation/validator.js.map +1 -0
- package/dist/sdd/workflow/exporter.d.ts +36 -0
- package/dist/sdd/workflow/exporter.d.ts.map +1 -0
- package/dist/sdd/workflow/exporter.js +112 -0
- package/dist/sdd/workflow/exporter.js.map +1 -0
- package/dist/sdd/workflows/ab-testing.d.ts +18 -0
- package/dist/sdd/workflows/ab-testing.d.ts.map +1 -0
- package/dist/sdd/workflows/ab-testing.js +67 -0
- package/dist/sdd/workflows/ab-testing.js.map +1 -0
- package/dist/sdd/workflows/bug-fix.d.ts +13 -0
- package/dist/sdd/workflows/bug-fix.d.ts.map +1 -0
- package/dist/sdd/workflows/bug-fix.js +65 -0
- package/dist/sdd/workflows/bug-fix.js.map +1 -0
- package/dist/sdd/workflows/data-migration.d.ts +14 -0
- package/dist/sdd/workflows/data-migration.d.ts.map +1 -0
- package/dist/sdd/workflows/data-migration.js +68 -0
- package/dist/sdd/workflows/data-migration.js.map +1 -0
- package/dist/sdd/workflows/deprecation.d.ts +15 -0
- package/dist/sdd/workflows/deprecation.d.ts.map +1 -0
- package/dist/sdd/workflows/deprecation.js +68 -0
- package/dist/sdd/workflows/deprecation.js.map +1 -0
- package/dist/sdd/workflows/feature-flags.d.ts +14 -0
- package/dist/sdd/workflows/feature-flags.d.ts.map +1 -0
- package/dist/sdd/workflows/feature-flags.js +73 -0
- package/dist/sdd/workflows/feature-flags.js.map +1 -0
- package/dist/sdd/workflows/hotfix.d.ts +13 -0
- package/dist/sdd/workflows/hotfix.d.ts.map +1 -0
- package/dist/sdd/workflows/hotfix.js +67 -0
- package/dist/sdd/workflows/hotfix.js.map +1 -0
- package/dist/sdd/workflows/multi-tenancy.d.ts +13 -0
- package/dist/sdd/workflows/multi-tenancy.d.ts.map +1 -0
- package/dist/sdd/workflows/multi-tenancy.js +68 -0
- package/dist/sdd/workflows/multi-tenancy.js.map +1 -0
- package/dist/sdd/workflows/onboarding.d.ts +7 -0
- package/dist/sdd/workflows/onboarding.d.ts.map +1 -0
- package/dist/sdd/workflows/onboarding.js +43 -0
- package/dist/sdd/workflows/onboarding.js.map +1 -0
- package/dist/sdd/workflows/refactoring.d.ts +14 -0
- package/dist/sdd/workflows/refactoring.d.ts.map +1 -0
- package/dist/sdd/workflows/refactoring.js +73 -0
- package/dist/sdd/workflows/refactoring.js.map +1 -0
- package/dist/server/events.d.ts +64 -0
- package/dist/server/events.d.ts.map +1 -0
- package/dist/server/events.js +149 -0
- package/dist/server/events.js.map +1 -0
- package/dist/server/server.d.ts +33 -0
- package/dist/server/server.d.ts.map +1 -0
- package/dist/server/server.js +1019 -0
- package/dist/server/server.js.map +1 -0
- package/marketplace.json +39 -0
- package/package.json +65 -0
- package/src/code-intelligence/analyzer.ts +350 -0
- package/src/code-intelligence/ast/cache.ts +61 -0
- package/src/code-intelligence/ast/common.ts +62 -0
- package/src/code-intelligence/ast/component.ts +39 -0
- package/src/code-intelligence/ast/fallback.ts +44 -0
- package/src/code-intelligence/ast/index.ts +4 -0
- package/src/code-intelligence/ast/ir.ts +91 -0
- package/src/code-intelligence/ast/metrics.ts +65 -0
- package/src/code-intelligence/ast/registry.ts +28 -0
- package/src/code-intelligence/ast/tree-sitter.ts +226 -0
- package/src/code-intelligence/ast/typescript.ts +140 -0
- package/src/index.ts +22 -0
- package/src/mcp/server.ts +77 -0
- package/src/opencode/hooks.ts +728 -0
- package/src/opencode/router/categories.ts +192 -0
- package/src/opencode/router/embeddings.ts +149 -0
- package/src/opencode/router/graph-state-snapshot.ts +163 -0
- package/src/opencode/router/index.ts +44 -0
- package/src/opencode/router/intent-classifier.ts +140 -0
- package/src/opencode/router/semantic-nudge.ts +89 -0
- package/src/opencode/router/state-gate.ts +192 -0
- package/src/opencode/router/tool-embeddings.ts +162 -0
- package/src/opencode/router/tool-registry.ts +135 -0
- package/src/opencode/router/tool-taxonomy.ts +284 -0
- package/src/opencode/router/tools-composite.ts +685 -0
- package/src/opencode/shell-hooks.ts +115 -0
- package/src/opencode/system-prompt.ts +617 -0
- package/src/opencode/tools.ts +4102 -0
- package/src/opencode/workflows/chains.ts +205 -0
- package/src/opencode/workflows/executor.ts +172 -0
- package/src/opencode/workflows/index.ts +21 -0
- package/src/opencode/workflows/tools-workflow.ts +91 -0
- package/src/opencode/workflows/types.ts +42 -0
- package/src/sdd/analysis/compliance.ts +279 -0
- package/src/sdd/analysis/scalability.ts +97 -0
- package/src/sdd/analysis/security.ts +135 -0
- package/src/sdd/brownfield/scanner.ts +276 -0
- package/src/sdd/cache/manager.ts +899 -0
- package/src/sdd/cache/snapshot-store.ts +185 -0
- package/src/sdd/changes/manager.ts +326 -0
- package/src/sdd/cicd/generators.ts +1095 -0
- package/src/sdd/code-quality/complexity.ts +235 -0
- package/src/sdd/code-quality/conventions.ts +220 -0
- package/src/sdd/code-quality/dependencies.ts +203 -0
- package/src/sdd/code-quality/import-analyzer.ts +294 -0
- package/src/sdd/code-quality/metrics.ts +232 -0
- package/src/sdd/code-quality/smells.ts +415 -0
- package/src/sdd/code-quality/symbol-parser.ts +335 -0
- package/src/sdd/code-quality/usage-tracker.ts +527 -0
- package/src/sdd/code-quality/utils.ts +13 -0
- package/src/sdd/codegen/generator.ts +1181 -0
- package/src/sdd/constitution/validator.ts +253 -0
- package/src/sdd/cost/estimator.ts +147 -0
- package/src/sdd/coverage/tracker.ts +342 -0
- package/src/sdd/disaster/recovery.ts +79 -0
- package/src/sdd/discovery/adaptive.ts +167 -0
- package/src/sdd/discovery/briefing-analyzer.ts +802 -0
- package/src/sdd/discovery/briefing.ts +770 -0
- package/src/sdd/discovery/graph-builder.ts +598 -0
- package/src/sdd/documentation/generator.ts +158 -0
- package/src/sdd/domain/types.ts +658 -0
- package/src/sdd/drift/detector.ts +465 -0
- package/src/sdd/drift/exclusion.ts +223 -0
- package/src/sdd/drift/signals.ts +577 -0
- package/src/sdd/enforcement/interceptor.ts +444 -0
- package/src/sdd/enforcement/workflow-tracker.ts +263 -0
- package/src/sdd/graph/engine.ts +277 -0
- package/src/sdd/graph/index.ts +700 -0
- package/src/sdd/graph/integrity-guard.ts +348 -0
- package/src/sdd/graph/integrity.ts +628 -0
- package/src/sdd/graph/pruner.ts +221 -0
- package/src/sdd/graph/traverse.ts +331 -0
- package/src/sdd/incidents/manager.ts +87 -0
- package/src/sdd/knowledge/transfer.ts +140 -0
- package/src/sdd/migrations/fixes.ts +154 -0
- package/src/sdd/migrations/index.ts +14 -0
- package/src/sdd/migrations/migration-runner.ts +118 -0
- package/src/sdd/monitoring/setup.ts +237 -0
- package/src/sdd/monitoring/telemetry.ts +44 -0
- package/src/sdd/patterns/anti-patterns.ts +333 -0
- package/src/sdd/patterns/ast-clones.ts +214 -0
- package/src/sdd/patterns/config-drift.ts +346 -0
- package/src/sdd/patterns/contradictions.ts +323 -0
- package/src/sdd/patterns/learner.ts +266 -0
- package/src/sdd/permissions/access.ts +478 -0
- package/src/sdd/persistence/repository.ts +166 -0
- package/src/sdd/persistence/sqlite.ts +703 -0
- package/src/sdd/persistence/yaml.ts +409 -0
- package/src/sdd/promises/classifier.ts +253 -0
- package/src/sdd/promises/tracker.ts +258 -0
- package/src/sdd/quality/scorer.ts +263 -0
- package/src/sdd/rollback/manager.ts +361 -0
- package/src/sdd/session/handoff.ts +354 -0
- package/src/sdd/sla/tracker.ts +68 -0
- package/src/sdd/sync/git-sync.ts +401 -0
- package/src/sdd/toggle/state.ts +38 -0
- package/src/sdd/transactions/manager.ts +93 -0
- package/src/sdd/validation/coverage-index.ts +339 -0
- package/src/sdd/validation/executable.ts +127 -0
- package/src/sdd/validation/smart-validator.ts +470 -0
- package/src/sdd/validation/validator.ts +641 -0
- package/src/sdd/workflow/exporter.ts +169 -0
- package/src/sdd/workflows/ab-testing.ts +90 -0
- package/src/sdd/workflows/bug-fix.ts +81 -0
- package/src/sdd/workflows/data-migration.ts +86 -0
- package/src/sdd/workflows/deprecation.ts +87 -0
- package/src/sdd/workflows/feature-flags.ts +91 -0
- package/src/sdd/workflows/hotfix.ts +83 -0
- package/src/sdd/workflows/multi-tenancy.ts +84 -0
- package/src/sdd/workflows/onboarding.ts +82 -0
- package/src/sdd/workflows/refactoring.ts +90 -0
- package/src/server/events.ts +184 -0
- package/src/server/server.ts +1088 -0
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
import { fileMatchesFocus } from "./utils.js"
|
|
2
|
+
|
|
3
|
+
export interface CodeSmell {
|
|
4
|
+
type: string
|
|
5
|
+
name: string
|
|
6
|
+
severity: 'info' | 'warning' | 'error'
|
|
7
|
+
location: string
|
|
8
|
+
description: string
|
|
9
|
+
recommendation: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface CodeSmellReport {
|
|
13
|
+
smells: CodeSmell[]
|
|
14
|
+
summary: {
|
|
15
|
+
total_smells: number
|
|
16
|
+
by_type: Record<string, number>
|
|
17
|
+
by_severity: Record<string, number>
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Options for controlling code smell detection scope.
|
|
23
|
+
*/
|
|
24
|
+
export interface CodeSmellDetectionOptions {
|
|
25
|
+
/** Only detect these smell types (e.g., ["god_class", "long_method"]). */
|
|
26
|
+
focusSmells?: string[]
|
|
27
|
+
/** Skip these smell types. */
|
|
28
|
+
excludeSmells?: string[]
|
|
29
|
+
/** Only analyze files matching these name patterns (supports * wildcard). */
|
|
30
|
+
focusFiles?: string[]
|
|
31
|
+
/** Minimum severity to report ("info" | "warning" | "error"). */
|
|
32
|
+
minSeverity?: "info" | "warning" | "error"
|
|
33
|
+
/** Maximum smells to report. */
|
|
34
|
+
maxResults?: number
|
|
35
|
+
/** Cache for file analysis results (file_name → smells). Reuse if file unchanged. */
|
|
36
|
+
fileCache?: Map<string, CodeSmellReport>
|
|
37
|
+
/** Hash of file content to check cache validity. */
|
|
38
|
+
contentHash?: string
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function detectLongParameterList(code: string, fileName: string): CodeSmell[] {
|
|
42
|
+
const smells: CodeSmell[] = []
|
|
43
|
+
|
|
44
|
+
const functionRegex = /(?:function\s+(\w+)|(?:const|let|var)\s+(\w+)\s*=\s*(?:async\s*)?\(|(?:async\s+)?(\w+)\s*\(([^)]*)\)\s*(?::\s*\w+\s*)?\{)/g
|
|
45
|
+
|
|
46
|
+
let match
|
|
47
|
+
while ((match = functionRegex.exec(code)) !== null) {
|
|
48
|
+
const name = match[1] || match[2] || match[3]
|
|
49
|
+
const params = match[4] || ''
|
|
50
|
+
|
|
51
|
+
if (params) {
|
|
52
|
+
const paramCount = params.split(',').filter(p => p.trim()).length
|
|
53
|
+
if (paramCount > 5) {
|
|
54
|
+
const line = code.substring(0, match.index).split('\n').length
|
|
55
|
+
smells.push({
|
|
56
|
+
type: 'long_parameter_list',
|
|
57
|
+
name,
|
|
58
|
+
severity: paramCount > 7 ? 'error' : 'warning',
|
|
59
|
+
location: `${fileName}:${line}`,
|
|
60
|
+
description: `Função ${name} tem ${paramCount} parâmetros`,
|
|
61
|
+
recommendation: 'Considere usar um objeto de opções ou agrupar parâmetros relacionados',
|
|
62
|
+
})
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return smells
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function detectGodClass(code: string, fileName: string): CodeSmell[] {
|
|
71
|
+
const smells: CodeSmell[] = []
|
|
72
|
+
|
|
73
|
+
const classRegex = /class\s+(\w+)[^{]*\{/g
|
|
74
|
+
let match
|
|
75
|
+
|
|
76
|
+
while ((match = classRegex.exec(code)) !== null) {
|
|
77
|
+
const className = match[1]
|
|
78
|
+
const startIdx = match.index
|
|
79
|
+
|
|
80
|
+
let braceCount = 0
|
|
81
|
+
let classBody = ''
|
|
82
|
+
let inClass = false
|
|
83
|
+
|
|
84
|
+
for (let i = startIdx; i < code.length; i++) {
|
|
85
|
+
if (code[i] === '{') {
|
|
86
|
+
braceCount++
|
|
87
|
+
inClass = true
|
|
88
|
+
} else if (code[i] === '}') {
|
|
89
|
+
braceCount--
|
|
90
|
+
if (inClass && braceCount === 0) {
|
|
91
|
+
classBody = code.substring(startIdx, i + 1)
|
|
92
|
+
break
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const methodCount = (classBody.match(/(?:public|private|protected|static|async|\w+\s*\([^)]*\)\s*\{)/g) || []).length
|
|
98
|
+
const propertyCount = (classBody.match(/(?:this\.\w+\s*=|private\s+\w+|protected\s+\w+|public\s+\w+)/g) || []).length
|
|
99
|
+
const LOC = classBody.split('\n').length
|
|
100
|
+
|
|
101
|
+
if (methodCount > 10 || propertyCount > 10 || LOC > 200) {
|
|
102
|
+
const line = code.substring(0, match.index).split('\n').length
|
|
103
|
+
smells.push({
|
|
104
|
+
type: 'god_class',
|
|
105
|
+
name: className,
|
|
106
|
+
severity: methodCount > 15 || propertyCount > 15 ? 'error' : 'warning',
|
|
107
|
+
location: `${fileName}:${line}`,
|
|
108
|
+
description: `Classe ${className} tem ${methodCount} métodos, ${propertyCount} propriedades e ${LOC} linhas`,
|
|
109
|
+
recommendation: 'Considere dividir em classes menores com responsabilidades específicas',
|
|
110
|
+
})
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return smells
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function detectFeatureEnvy(code: string, fileName: string): CodeSmell[] {
|
|
118
|
+
const smells: CodeSmell[] = []
|
|
119
|
+
|
|
120
|
+
const functionRegex = /(?:function\s+(\w+)|(?:const|let|var)\s+(\w+)\s*=\s*(?:async\s*)?\(|(?:async\s+)?(\w+)\s*\([^)]*\)\s*(?::\s*\w+\s*)?\{)/g
|
|
121
|
+
|
|
122
|
+
let match
|
|
123
|
+
while ((match = functionRegex.exec(code)) !== null) {
|
|
124
|
+
const name = match[1] || match[2] || match[3]
|
|
125
|
+
const startIdx = match.index
|
|
126
|
+
|
|
127
|
+
let braceCount = 0
|
|
128
|
+
let functionBody = ''
|
|
129
|
+
let inFunction = false
|
|
130
|
+
|
|
131
|
+
for (let i = startIdx; i < code.length; i++) {
|
|
132
|
+
if (code[i] === '{') {
|
|
133
|
+
braceCount++
|
|
134
|
+
inFunction = true
|
|
135
|
+
} else if (code[i] === '}') {
|
|
136
|
+
braceCount--
|
|
137
|
+
if (inFunction && braceCount === 0) {
|
|
138
|
+
functionBody = code.substring(startIdx, i + 1)
|
|
139
|
+
break
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const externalCalls = (functionBody.match(/(\w+)\.\w+\s*\(/g) || [])
|
|
145
|
+
const callCounts: Record<string, number> = {}
|
|
146
|
+
|
|
147
|
+
for (const call of externalCalls) {
|
|
148
|
+
const obj = call.split('.')[0]
|
|
149
|
+
callCounts[obj] = (callCounts[obj] || 0) + 1
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const maxCalls = Math.max(...Object.values(callCounts), 0)
|
|
153
|
+
const maxObj = Object.keys(callCounts).find(k => callCounts[k] === maxCalls)
|
|
154
|
+
|
|
155
|
+
if (maxCalls > 5 && maxObj && !['this', 'self'].includes(maxObj)) {
|
|
156
|
+
const line = code.substring(0, match.index).split('\n').length
|
|
157
|
+
smells.push({
|
|
158
|
+
type: 'feature_envy',
|
|
159
|
+
name,
|
|
160
|
+
severity: maxCalls > 8 ? 'error' : 'warning',
|
|
161
|
+
location: `${fileName}:${line}`,
|
|
162
|
+
description: `Função ${name} chama ${maxObj}.${maxCalls} vezes`,
|
|
163
|
+
recommendation: `Considere mover esta função para a classe ${maxObj}`,
|
|
164
|
+
})
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return smells
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function detectSwitchStatements(code: string, fileName: string): CodeSmell[] {
|
|
172
|
+
const smells: CodeSmell[] = []
|
|
173
|
+
|
|
174
|
+
const switchRegex = /switch\s*\([^)]*\)\s*\{/g
|
|
175
|
+
let match
|
|
176
|
+
|
|
177
|
+
while ((match = switchRegex.exec(code)) !== null) {
|
|
178
|
+
const line = code.substring(0, match.index).split('\n').length
|
|
179
|
+
|
|
180
|
+
let braceCount = 0
|
|
181
|
+
let switchBody = ''
|
|
182
|
+
let inSwitch = false
|
|
183
|
+
|
|
184
|
+
for (let i = match.index; i < code.length; i++) {
|
|
185
|
+
if (code[i] === '{') {
|
|
186
|
+
braceCount++
|
|
187
|
+
inSwitch = true
|
|
188
|
+
} else if (code[i] === '}') {
|
|
189
|
+
braceCount--
|
|
190
|
+
if (inSwitch && braceCount === 0) {
|
|
191
|
+
switchBody = code.substring(match.index, i + 1)
|
|
192
|
+
break
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const caseCount = (switchBody.match(/case\s+/g) || []).length
|
|
198
|
+
|
|
199
|
+
if (caseCount > 3) {
|
|
200
|
+
smells.push({
|
|
201
|
+
type: 'switch_statement',
|
|
202
|
+
name: `Switch na linha ${line}`,
|
|
203
|
+
severity: caseCount > 5 ? 'error' : 'warning',
|
|
204
|
+
location: `${fileName}:${line}`,
|
|
205
|
+
description: `Switch com ${caseCount} cases`,
|
|
206
|
+
recommendation: 'Considere usar polimorfismo, strategy pattern ou map de objetos',
|
|
207
|
+
})
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
return smells
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function detectLongMethods(code: string, fileName: string): CodeSmell[] {
|
|
215
|
+
const smells: CodeSmell[] = []
|
|
216
|
+
|
|
217
|
+
const functionRegex = /(?:function\s+(\w+)|(?:const|let|var)\s+(\w+)\s*=\s*(?:async\s*)?\(|(?:async\s+)?(\w+)\s*\([^)]*\)\s*(?::\s*\w+\s*)?\{)/g
|
|
218
|
+
|
|
219
|
+
let match
|
|
220
|
+
while ((match = functionRegex.exec(code)) !== null) {
|
|
221
|
+
const name = match[1] || match[2] || match[3]
|
|
222
|
+
const startLine = code.substring(0, match.index).split('\n').length
|
|
223
|
+
|
|
224
|
+
let braceCount = 0
|
|
225
|
+
let endLine = startLine
|
|
226
|
+
let inFunction = false
|
|
227
|
+
|
|
228
|
+
for (let i = match.index; i < code.length; i++) {
|
|
229
|
+
if (code[i] === '{') {
|
|
230
|
+
braceCount++
|
|
231
|
+
inFunction = true
|
|
232
|
+
} else if (code[i] === '}') {
|
|
233
|
+
braceCount--
|
|
234
|
+
if (inFunction && braceCount === 0) {
|
|
235
|
+
endLine = code.substring(0, i + 1).split('\n').length
|
|
236
|
+
break
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const lines = endLine - startLine + 1
|
|
242
|
+
|
|
243
|
+
if (lines > 50) {
|
|
244
|
+
smells.push({
|
|
245
|
+
type: 'long_method',
|
|
246
|
+
name,
|
|
247
|
+
severity: lines > 100 ? 'error' : 'warning',
|
|
248
|
+
location: `${fileName}:${startLine}`,
|
|
249
|
+
description: `Função ${name} tem ${lines} linhas`,
|
|
250
|
+
recommendation: 'Considere extrair lógica em funções menores',
|
|
251
|
+
})
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
return smells
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function detectDataClumps(code: string, fileName: string): CodeSmell[] {
|
|
259
|
+
const smells: CodeSmell[] = []
|
|
260
|
+
|
|
261
|
+
const functionRegex = /(?:function\s+(\w+)|(?:const|let|var)\s+(\w+)\s*=\s*(?:async\s*)?\(|(?:async\s+)?(\w+)\s*\(([^)]*)\)\s*(?::\s*\w+\s*)?\{)/g
|
|
262
|
+
|
|
263
|
+
const paramGroups: Record<string, string[]> = {}
|
|
264
|
+
|
|
265
|
+
let match
|
|
266
|
+
while ((match = functionRegex.exec(code)) !== null) {
|
|
267
|
+
const name = match[1] || match[2] || match[3]
|
|
268
|
+
const params = match[4] || ''
|
|
269
|
+
|
|
270
|
+
if (params) {
|
|
271
|
+
const paramList = params.split(',').map(p => p.trim()).filter(p => p)
|
|
272
|
+
for (const param of paramList) {
|
|
273
|
+
const type = param.split(':')[1]?.trim() || 'any'
|
|
274
|
+
if (!paramGroups[type]) paramGroups[type] = []
|
|
275
|
+
paramGroups[type].push(name)
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
for (const [type, funcs] of Object.entries(paramGroups)) {
|
|
281
|
+
if (funcs.length > 3) {
|
|
282
|
+
const line = code.substring(0, code.indexOf(funcs[0])).split('\n').length
|
|
283
|
+
smells.push({
|
|
284
|
+
type: 'data_clump',
|
|
285
|
+
name: `Parâmetros do tipo ${type}`,
|
|
286
|
+
severity: 'warning',
|
|
287
|
+
location: `${fileName}:${line}`,
|
|
288
|
+
description: `${funcs.length} funções compartilham parâmetros do tipo ${type}`,
|
|
289
|
+
recommendation: `Considere criar uma classe para agrupar os parâmetros do tipo ${type}`,
|
|
290
|
+
})
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
return smells
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
export function detectCodeSmells(
|
|
298
|
+
code: string,
|
|
299
|
+
fileName: string,
|
|
300
|
+
options?: CodeSmellDetectionOptions,
|
|
301
|
+
): CodeSmellReport {
|
|
302
|
+
// Check file cache first
|
|
303
|
+
if (options?.fileCache && options.contentHash) {
|
|
304
|
+
const cacheKey = `${fileName}||${options.contentHash}`
|
|
305
|
+
const cached = options.fileCache.get(cacheKey)
|
|
306
|
+
if (cached) return cached
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
// Early return if file doesn't match focusFiles
|
|
310
|
+
if (options?.focusFiles?.length && !fileMatchesFocus(fileName, options.focusFiles)) {
|
|
311
|
+
return { smells: [], summary: { total_smells: 0, by_type: {}, by_severity: {} } }
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
const focusSet = options?.focusSmells ? new Set(options.focusSmells) : null
|
|
315
|
+
const excludeSet = options?.excludeSmells ? new Set(options.excludeSmells) : null
|
|
316
|
+
const severityOrder: Record<string, number> = { info: 0, warning: 1, error: 2 }
|
|
317
|
+
const minSeverityLevel = options?.minSeverity ? severityOrder[options.minSeverity] ?? 0 : 0
|
|
318
|
+
|
|
319
|
+
const shouldDetect = (type: string) => {
|
|
320
|
+
if (excludeSet?.has(type)) return false
|
|
321
|
+
if (focusSet && !focusSet.has(type)) return false
|
|
322
|
+
return true
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
const detectors: Array<{ type: string; fn: () => CodeSmell[] }> = [
|
|
326
|
+
{ type: "long_parameter_list", fn: () => detectLongParameterList(code, fileName) },
|
|
327
|
+
{ type: "god_class", fn: () => detectGodClass(code, fileName) },
|
|
328
|
+
{ type: "feature_envy", fn: () => detectFeatureEnvy(code, fileName) },
|
|
329
|
+
{ type: "switch_statement", fn: () => detectSwitchStatements(code, fileName) },
|
|
330
|
+
{ type: "long_method", fn: () => detectLongMethods(code, fileName) },
|
|
331
|
+
{ type: "data_clump", fn: () => detectDataClumps(code, fileName) },
|
|
332
|
+
]
|
|
333
|
+
|
|
334
|
+
let smells: CodeSmell[] = []
|
|
335
|
+
for (const detector of detectors) {
|
|
336
|
+
if (shouldDetect(detector.type)) {
|
|
337
|
+
smells.push(...detector.fn())
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
// Apply severity filter
|
|
342
|
+
smells = smells.filter(s => (severityOrder[s.severity] ?? 0) >= minSeverityLevel)
|
|
343
|
+
|
|
344
|
+
// Apply max results limit
|
|
345
|
+
if (options?.maxResults && smells.length > options.maxResults) {
|
|
346
|
+
smells = smells.slice(0, options.maxResults)
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
const byType: Record<string, number> = {}
|
|
350
|
+
const bySeverity: Record<string, number> = {}
|
|
351
|
+
|
|
352
|
+
for (const smell of smells) {
|
|
353
|
+
byType[smell.type] = (byType[smell.type] || 0) + 1
|
|
354
|
+
bySeverity[smell.severity] = (bySeverity[smell.severity] || 0) + 1
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
const result: CodeSmellReport = {
|
|
358
|
+
smells,
|
|
359
|
+
summary: {
|
|
360
|
+
total_smells: smells.length,
|
|
361
|
+
by_type: byType,
|
|
362
|
+
by_severity: bySeverity,
|
|
363
|
+
},
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
// Store in file cache if provided
|
|
367
|
+
if (options?.fileCache && options.contentHash) {
|
|
368
|
+
const cacheKey = `${fileName}||${options.contentHash}`
|
|
369
|
+
options.fileCache.set(cacheKey, result)
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
return result
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
export function formatCodeSmellReport(report: CodeSmellReport): string {
|
|
376
|
+
const lines = [
|
|
377
|
+
'## Detecção de Code Smells',
|
|
378
|
+
'',
|
|
379
|
+
`**Total:** ${report.summary.total_smells}`,
|
|
380
|
+
'',
|
|
381
|
+
]
|
|
382
|
+
|
|
383
|
+
if (Object.keys(report.summary.by_severity).length > 0) {
|
|
384
|
+
lines.push('### Por Severidade')
|
|
385
|
+
for (const [severity, count] of Object.entries(report.summary.by_severity)) {
|
|
386
|
+
const icon = severity === 'error' ? '❌' : severity === 'warning' ? '⚠️' : 'ℹ️'
|
|
387
|
+
lines.push(`${icon} **${severity}:** ${count}`)
|
|
388
|
+
}
|
|
389
|
+
lines.push('')
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
if (Object.keys(report.summary.by_type).length > 0) {
|
|
393
|
+
lines.push('### Por Tipo')
|
|
394
|
+
for (const [type, count] of Object.entries(report.summary.by_type)) {
|
|
395
|
+
lines.push(`- **${type}:** ${count}`)
|
|
396
|
+
}
|
|
397
|
+
lines.push('')
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
if (report.smells.length > 0) {
|
|
401
|
+
lines.push('### Problemas Detectados')
|
|
402
|
+
for (const smell of report.smells) {
|
|
403
|
+
const icon = smell.severity === 'error' ? '❌' : smell.severity === 'warning' ? '⚠️' : 'ℹ️'
|
|
404
|
+
lines.push(`${icon} **${smell.type}** (${smell.name})`)
|
|
405
|
+
lines.push(` - **Local:** ${smell.location}`)
|
|
406
|
+
lines.push(` - **Descrição:** ${smell.description}`)
|
|
407
|
+
lines.push(` - **Recomendação:** ${smell.recommendation}`)
|
|
408
|
+
lines.push('')
|
|
409
|
+
}
|
|
410
|
+
} else {
|
|
411
|
+
lines.push('✅ Nenhum code smell detectado')
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
return lines.join('\n')
|
|
415
|
+
}
|