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,700 @@
|
|
|
1
|
+
import type { KnowledgeGraph, AnyNode, NodeType, NodeStatus, Relationship, RelationshipType } from "../domain/types.js"
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Pre-computed indices for O(1) lookups on a KnowledgeGraph.
|
|
5
|
+
* Supports both full rebuild and incremental updates.
|
|
6
|
+
*/
|
|
7
|
+
export class GraphIndices {
|
|
8
|
+
readonly byId: Map<string, AnyNode>
|
|
9
|
+
readonly byType: Map<NodeType, AnyNode[]>
|
|
10
|
+
readonly byStatus: Map<NodeStatus, AnyNode[]>
|
|
11
|
+
readonly outgoing: Map<string, Relationship[]>
|
|
12
|
+
readonly incoming: Map<string, Relationship[]>
|
|
13
|
+
readonly all: Map<string, Relationship[]>
|
|
14
|
+
readonly relByType: Map<RelationshipType, Relationship[]>
|
|
15
|
+
readonly neighbors: Map<string, Set<string>>
|
|
16
|
+
readonly searchIndex: InvertedIndex
|
|
17
|
+
readonly totalNodes: number
|
|
18
|
+
readonly totalRelationships: number
|
|
19
|
+
|
|
20
|
+
private constructor(graph: KnowledgeGraph) {
|
|
21
|
+
this.byId = new Map()
|
|
22
|
+
this.byType = new Map()
|
|
23
|
+
this.byStatus = new Map()
|
|
24
|
+
this.outgoing = new Map()
|
|
25
|
+
this.incoming = new Map()
|
|
26
|
+
this.all = new Map()
|
|
27
|
+
this.relByType = new Map()
|
|
28
|
+
this.neighbors = new Map()
|
|
29
|
+
this.searchIndex = new InvertedIndex()
|
|
30
|
+
this.totalNodes = graph.nodes.length
|
|
31
|
+
this.totalRelationships = graph.relationships.length
|
|
32
|
+
|
|
33
|
+
this.buildNodeIndices(graph)
|
|
34
|
+
this.buildRelationshipIndices(graph)
|
|
35
|
+
this.buildSearchIndex(graph)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
static from(graph: KnowledgeGraph): GraphIndices {
|
|
39
|
+
return new GraphIndices(graph)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// ── Node index building ────────────────────────────────────────────
|
|
43
|
+
|
|
44
|
+
private buildNodeIndices(graph: KnowledgeGraph): void {
|
|
45
|
+
for (const node of graph.nodes) {
|
|
46
|
+
this.byId.set(node.id, node)
|
|
47
|
+
|
|
48
|
+
const typeList = this.byType.get(node.type)
|
|
49
|
+
if (typeList) typeList.push(node)
|
|
50
|
+
else this.byType.set(node.type, [node])
|
|
51
|
+
|
|
52
|
+
const statusList = this.byStatus.get(node.status)
|
|
53
|
+
if (statusList) statusList.push(node)
|
|
54
|
+
else this.byStatus.set(node.status, [node])
|
|
55
|
+
|
|
56
|
+
this.neighbors.set(node.id, new Set())
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// ── Relationship index building ────────────────────────────────────
|
|
61
|
+
|
|
62
|
+
private buildRelationshipIndices(graph: KnowledgeGraph): void {
|
|
63
|
+
for (const rel of graph.relationships) {
|
|
64
|
+
this.addToRelIndices(rel)
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
private addToRelIndices(rel: Relationship): void {
|
|
69
|
+
const outgoingList = this.outgoing.get(rel.from)
|
|
70
|
+
if (outgoingList) outgoingList.push(rel)
|
|
71
|
+
else this.outgoing.set(rel.from, [rel])
|
|
72
|
+
|
|
73
|
+
const incomingList = this.incoming.get(rel.to)
|
|
74
|
+
if (incomingList) incomingList.push(rel)
|
|
75
|
+
else this.incoming.set(rel.to, [rel])
|
|
76
|
+
|
|
77
|
+
const allList = this.all.get(rel.from)
|
|
78
|
+
if (allList) allList.push(rel)
|
|
79
|
+
else this.all.set(rel.from, [rel])
|
|
80
|
+
|
|
81
|
+
if (rel.from !== rel.to) {
|
|
82
|
+
const allListTo = this.all.get(rel.to)
|
|
83
|
+
if (allListTo) allListTo.push(rel)
|
|
84
|
+
else this.all.set(rel.to, [rel])
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const relTypeList = this.relByType.get(rel.type)
|
|
88
|
+
if (relTypeList) relTypeList.push(rel)
|
|
89
|
+
else this.relByType.set(rel.type, [rel])
|
|
90
|
+
|
|
91
|
+
this.neighbors.get(rel.from)?.add(rel.to)
|
|
92
|
+
this.neighbors.get(rel.to)?.add(rel.from)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
private removeFromRelIndices(rel: Relationship): void {
|
|
96
|
+
const removeById = (map: Map<string, Relationship[]>, key: string, rel: Relationship) => {
|
|
97
|
+
const list = map.get(key)
|
|
98
|
+
if (list) {
|
|
99
|
+
const idx = list.findIndex(r => r.id === rel.id)
|
|
100
|
+
if (idx !== -1) list.splice(idx, 1)
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
removeById(this.outgoing, rel.from, rel)
|
|
105
|
+
removeById(this.incoming, rel.to, rel)
|
|
106
|
+
removeById(this.all, rel.from, rel)
|
|
107
|
+
if (rel.from !== rel.to) removeById(this.all, rel.to, rel)
|
|
108
|
+
|
|
109
|
+
const relTypeList = this.relByType.get(rel.type)
|
|
110
|
+
if (relTypeList) {
|
|
111
|
+
const idx = relTypeList.findIndex(r => r.id === rel.id)
|
|
112
|
+
if (idx !== -1) relTypeList.splice(idx, 1)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
this.neighbors.get(rel.from)?.delete(rel.to)
|
|
116
|
+
this.neighbors.get(rel.to)?.delete(rel.from)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// ── Search index building ──────────────────────────────────────────
|
|
120
|
+
|
|
121
|
+
private buildSearchIndex(graph: KnowledgeGraph): void {
|
|
122
|
+
for (const node of graph.nodes) {
|
|
123
|
+
this.indexNodeForSearch(node)
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
private indexNodeForSearch(node: AnyNode): void {
|
|
128
|
+
const tokens = new Set<string>()
|
|
129
|
+
|
|
130
|
+
tokens.add(node.id.toLowerCase())
|
|
131
|
+
tokens.add(node.type.toLowerCase())
|
|
132
|
+
tokens.add(node.status.toLowerCase())
|
|
133
|
+
tokens.add(node.name.toLowerCase())
|
|
134
|
+
|
|
135
|
+
if (node.description) {
|
|
136
|
+
tokenize(node.description, tokens)
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const meta = node.metadata as Record<string, unknown>
|
|
140
|
+
for (const [key, value] of Object.entries(meta)) {
|
|
141
|
+
tokens.add(key.toLowerCase())
|
|
142
|
+
if (typeof value === "string") {
|
|
143
|
+
tokenize(value, tokens)
|
|
144
|
+
} else if (typeof value === "number") {
|
|
145
|
+
tokens.add(String(value))
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
this.searchIndex.add(node.id, tokens)
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// ── Incremental Updates ────────────────────────────────────────────
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Add a single node to all indices without rebuilding.
|
|
156
|
+
* O(1) per index, no full scan.
|
|
157
|
+
*/
|
|
158
|
+
addNode(node: AnyNode): void {
|
|
159
|
+
this.byId.set(node.id, node)
|
|
160
|
+
|
|
161
|
+
const typeList = this.byType.get(node.type)
|
|
162
|
+
if (typeList) typeList.push(node)
|
|
163
|
+
else this.byType.set(node.type, [node])
|
|
164
|
+
|
|
165
|
+
const statusList = this.byStatus.get(node.status)
|
|
166
|
+
if (statusList) statusList.push(node)
|
|
167
|
+
else this.byStatus.set(node.status, [node])
|
|
168
|
+
|
|
169
|
+
this.neighbors.set(node.id, new Set())
|
|
170
|
+
this.indexNodeForSearch(node)
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Update a single node in all indices without rebuilding.
|
|
175
|
+
* Only updates the specific entries that changed.
|
|
176
|
+
*/
|
|
177
|
+
updateNode(oldNode: AnyNode, newNode: AnyNode): void {
|
|
178
|
+
// Update byId
|
|
179
|
+
this.byId.set(newNode.id, newNode)
|
|
180
|
+
|
|
181
|
+
// Update byType if type changed
|
|
182
|
+
if (oldNode.type !== newNode.type) {
|
|
183
|
+
const oldTypeList = this.byType.get(oldNode.type)
|
|
184
|
+
if (oldTypeList) {
|
|
185
|
+
const idx = oldTypeList.findIndex(n => n.id === oldNode.id)
|
|
186
|
+
if (idx !== -1) oldTypeList.splice(idx, 1)
|
|
187
|
+
}
|
|
188
|
+
const newTypeList = this.byType.get(newNode.type)
|
|
189
|
+
if (newTypeList) newTypeList.push(newNode)
|
|
190
|
+
else this.byType.set(newNode.type, [newNode])
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// Update byStatus if status changed
|
|
194
|
+
if (oldNode.status !== newNode.status) {
|
|
195
|
+
const oldStatusList = this.byStatus.get(oldNode.status)
|
|
196
|
+
if (oldStatusList) {
|
|
197
|
+
const idx = oldStatusList.findIndex(n => n.id === oldNode.id)
|
|
198
|
+
if (idx !== -1) oldStatusList.splice(idx, 1)
|
|
199
|
+
}
|
|
200
|
+
const newStatusList = this.byStatus.get(newNode.status)
|
|
201
|
+
if (newStatusList) newStatusList.push(newNode)
|
|
202
|
+
else this.byStatus.set(newNode.status, [newNode])
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// Update search index
|
|
206
|
+
this.searchIndex.remove(oldNode.id)
|
|
207
|
+
this.indexNodeForSearch(newNode)
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Remove a single node from all indices without rebuilding.
|
|
212
|
+
*/
|
|
213
|
+
removeNode(nodeId: string): void {
|
|
214
|
+
const node = this.byId.get(nodeId)
|
|
215
|
+
if (!node) return
|
|
216
|
+
|
|
217
|
+
this.byId.delete(nodeId)
|
|
218
|
+
|
|
219
|
+
// Remove from byType
|
|
220
|
+
const typeList = this.byType.get(node.type)
|
|
221
|
+
if (typeList) {
|
|
222
|
+
const idx = typeList.findIndex(n => n.id === nodeId)
|
|
223
|
+
if (idx !== -1) typeList.splice(idx, 1)
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// Remove from byStatus
|
|
227
|
+
const statusList = this.byStatus.get(node.status)
|
|
228
|
+
if (statusList) {
|
|
229
|
+
const idx = statusList.findIndex(n => n.id === nodeId)
|
|
230
|
+
if (idx !== -1) statusList.splice(idx, 1)
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// Remove from neighbors
|
|
234
|
+
this.neighbors.delete(nodeId)
|
|
235
|
+
for (const [, neighbors] of this.neighbors) {
|
|
236
|
+
neighbors.delete(nodeId)
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// Remove from search index
|
|
240
|
+
this.searchIndex.remove(nodeId)
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Add a relationship to indices without rebuilding.
|
|
245
|
+
*/
|
|
246
|
+
addRelationship(rel: Relationship): void {
|
|
247
|
+
this.addToRelIndices(rel)
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Remove a relationship from indices without rebuilding.
|
|
252
|
+
*/
|
|
253
|
+
removeRelationship(rel: Relationship): void {
|
|
254
|
+
this.removeFromRelIndices(rel)
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// ── Query helpers ──────────────────────────────────────────────────
|
|
258
|
+
|
|
259
|
+
getNode(id: string): AnyNode | undefined {
|
|
260
|
+
return this.byId.get(id)
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
getNodesByType(type: NodeType): AnyNode[] {
|
|
264
|
+
return this.byType.get(type) || []
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
getNodesByStatus(status: NodeStatus): AnyNode[] {
|
|
268
|
+
return this.byStatus.get(status) || []
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
getOutgoing(nodeId: string): Relationship[] {
|
|
272
|
+
return this.outgoing.get(nodeId) || []
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
getIncoming(nodeId: string): Relationship[] {
|
|
276
|
+
return this.incoming.get(nodeId) || []
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
getRelationships(nodeId: string): Relationship[] {
|
|
280
|
+
return this.all.get(nodeId) || []
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
getNeighborIds(nodeId: string): Set<string> {
|
|
284
|
+
return this.neighbors.get(nodeId) || new Set()
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
search(query: string, type?: NodeType): AnyNode[] {
|
|
288
|
+
const queryTokens = new Set<string>()
|
|
289
|
+
tokenize(query, queryTokens)
|
|
290
|
+
if (queryTokens.size === 0) return []
|
|
291
|
+
|
|
292
|
+
let candidateIds = this.searchIndex.search(queryTokens)
|
|
293
|
+
if (type) {
|
|
294
|
+
const typeNodes = this.byType.get(type)
|
|
295
|
+
if (!typeNodes) return []
|
|
296
|
+
const typeIdSet = new Set(typeNodes.map(n => n.id))
|
|
297
|
+
candidateIds = candidateIds.filter(id => typeIdSet.has(id))
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
return candidateIds
|
|
301
|
+
.map(id => this.byId.get(id))
|
|
302
|
+
.filter((n): n is AnyNode => n !== undefined)
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Inverted index for fast text search.
|
|
308
|
+
* Supports incremental add/remove.
|
|
309
|
+
*/
|
|
310
|
+
export class InvertedIndex {
|
|
311
|
+
private index: Map<string, Set<string>> = new Map()
|
|
312
|
+
|
|
313
|
+
add(nodeId: string, tokens: Set<string>): void {
|
|
314
|
+
for (const token of tokens) {
|
|
315
|
+
const existing = this.index.get(token)
|
|
316
|
+
if (existing) existing.add(nodeId)
|
|
317
|
+
else this.index.set(token, new Set([nodeId]))
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
remove(nodeId: string): void {
|
|
322
|
+
for (const [, nodeIds] of this.index) {
|
|
323
|
+
nodeIds.delete(nodeId)
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
search(queryTokens: Set<string>): string[] {
|
|
328
|
+
const resultIds = new Set<string>()
|
|
329
|
+
for (const token of queryTokens) {
|
|
330
|
+
const matches = this.index.get(token)
|
|
331
|
+
if (matches) {
|
|
332
|
+
for (const id of matches) resultIds.add(id)
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
return [...resultIds]
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
searchAnd(queryTokens: Set<string>): string[] {
|
|
339
|
+
const arrays: string[][] = []
|
|
340
|
+
for (const token of queryTokens) {
|
|
341
|
+
const matches = this.index.get(token)
|
|
342
|
+
if (!matches || matches.size === 0) return []
|
|
343
|
+
arrays.push([...matches])
|
|
344
|
+
}
|
|
345
|
+
if (arrays.length === 0) return []
|
|
346
|
+
|
|
347
|
+
arrays.sort((a, b) => a.length - b.length)
|
|
348
|
+
|
|
349
|
+
let result = new Set(arrays[0])
|
|
350
|
+
for (let i = 1; i < arrays.length; i++) {
|
|
351
|
+
const currentSet = new Set(arrays[i])
|
|
352
|
+
result = new Set([...result].filter(id => currentSet.has(id)))
|
|
353
|
+
if (result.size === 0) return []
|
|
354
|
+
}
|
|
355
|
+
return [...result]
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
// ── Utility ──────────────────────────────────────────────────────────
|
|
360
|
+
|
|
361
|
+
function tokenize(text: string, output: Set<string>): void {
|
|
362
|
+
const normalized = text
|
|
363
|
+
.toLowerCase()
|
|
364
|
+
.replace(/[^a-z0-9\u00C0-\u024F]+/g, " ")
|
|
365
|
+
.trim()
|
|
366
|
+
|
|
367
|
+
for (const word of normalized.split(/\s+/)) {
|
|
368
|
+
if (word.length > 1) {
|
|
369
|
+
output.add(word)
|
|
370
|
+
const stemmed = stem(word)
|
|
371
|
+
if (stemmed !== word) output.add(stemmed)
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
function stem(word: string): string {
|
|
377
|
+
if (word.length <= 4) return word
|
|
378
|
+
const suffixes = [
|
|
379
|
+
"mentes", "mento", "ções", "ção", "mente", "avel", "ivel",
|
|
380
|
+
"ments", "tion", "ness", "able", "ible", "ling",
|
|
381
|
+
"ated", "ting", "ship", "less", "ence", "ance",
|
|
382
|
+
"ised", "ized", "ally", "ical",
|
|
383
|
+
"es", "ed", "er", "ly", "ing", "ion", "al", "en", "s",
|
|
384
|
+
]
|
|
385
|
+
for (const suffix of suffixes) {
|
|
386
|
+
if (word.endsWith(suffix) && word.length - suffix.length >= 3) {
|
|
387
|
+
return word.slice(0, -suffix.length)
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
return word
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
// ── Per-Type Graph Cache ─────────────────────────────────────────────
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* Granular graph cache that stores nodes by type separately.
|
|
397
|
+
* Only the affected type is invalidated on mutation.
|
|
398
|
+
*/
|
|
399
|
+
export class PerTypeGraphCache {
|
|
400
|
+
private nodesByType: Map<NodeType, AnyNode[]> = new Map()
|
|
401
|
+
private relationships: Relationship[] = []
|
|
402
|
+
private graphVersion: number = 0
|
|
403
|
+
private lastFullRebuild: number = 0
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* Get nodes of a specific type from cache.
|
|
407
|
+
* Returns null if cache miss for that type.
|
|
408
|
+
*/
|
|
409
|
+
getNodesByType(type: NodeType, currentVersion: number): AnyNode[] | null {
|
|
410
|
+
if (currentVersion !== this.graphVersion) return null
|
|
411
|
+
return this.nodesByType.get(type) || []
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* Get all relationships from cache.
|
|
416
|
+
*/
|
|
417
|
+
getRelationships(currentVersion: number): Relationship[] | null {
|
|
418
|
+
if (currentVersion !== this.graphVersion) return null
|
|
419
|
+
return this.relationships
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* Populate cache for a specific type only.
|
|
424
|
+
*/
|
|
425
|
+
setType(type: NodeType, nodes: AnyNode[], version: number): void {
|
|
426
|
+
this.nodesByType.set(type, nodes)
|
|
427
|
+
this.graphVersion = version
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* Set relationships cache.
|
|
432
|
+
*/
|
|
433
|
+
setRelationships(rels: Relationship[], version: number): void {
|
|
434
|
+
this.relationships = rels
|
|
435
|
+
this.graphVersion = version
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* Invalidate only a specific type.
|
|
440
|
+
*/
|
|
441
|
+
invalidateType(type: NodeType): void {
|
|
442
|
+
this.nodesByType.delete(type)
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* Invalidate relationships.
|
|
447
|
+
*/
|
|
448
|
+
invalidateRelationships(): void {
|
|
449
|
+
this.relationships = []
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* Full invalidation (all types).
|
|
454
|
+
*/
|
|
455
|
+
invalidateAll(): void {
|
|
456
|
+
this.nodesByType.clear()
|
|
457
|
+
this.relationships = []
|
|
458
|
+
this.graphVersion = 0
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* Check if cache is valid for a given version.
|
|
463
|
+
*/
|
|
464
|
+
isValid(version: number): boolean {
|
|
465
|
+
return version === this.graphVersion
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
// ── Incremental Graph Hash ───────────────────────────────────────────
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* Calculate a graph hash incrementally without reading the full graph.
|
|
473
|
+
* Based on node count + relationship count + mutation counter.
|
|
474
|
+
*/
|
|
475
|
+
export class IncrementalGraphHash {
|
|
476
|
+
private hash: string = ""
|
|
477
|
+
private nodeCount: number = 0
|
|
478
|
+
private relCount: number = 0
|
|
479
|
+
private mutationCount: number = 0
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* Initialize from graph metadata.
|
|
483
|
+
*/
|
|
484
|
+
initialize(nodeCount: number, relCount: number): void {
|
|
485
|
+
this.nodeCount = nodeCount
|
|
486
|
+
this.relCount = relCount
|
|
487
|
+
this.mutationCount = 0
|
|
488
|
+
this.hash = this.computeHash()
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
/**
|
|
492
|
+
* Record a mutation (add/update/remove node or relationship).
|
|
493
|
+
*/
|
|
494
|
+
recordMutation(): void {
|
|
495
|
+
this.mutationCount++
|
|
496
|
+
this.hash = this.computeHash()
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* Record node count change.
|
|
501
|
+
*/
|
|
502
|
+
recordNodeCountChange(delta: number): void {
|
|
503
|
+
this.nodeCount += delta
|
|
504
|
+
this.mutationCount++
|
|
505
|
+
this.hash = this.computeHash()
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
* Record relationship count change.
|
|
510
|
+
*/
|
|
511
|
+
recordRelCountChange(delta: number): void {
|
|
512
|
+
this.relCount += delta
|
|
513
|
+
this.mutationCount++
|
|
514
|
+
this.hash = this.computeHash()
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* Get current hash.
|
|
519
|
+
*/
|
|
520
|
+
getHash(): string {
|
|
521
|
+
return this.hash
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
/**
|
|
525
|
+
* Get current node count.
|
|
526
|
+
*/
|
|
527
|
+
getNodeCount(): number {
|
|
528
|
+
return this.nodeCount
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* Get current relationship count.
|
|
533
|
+
*/
|
|
534
|
+
getRelCount(): number {
|
|
535
|
+
return this.relCount
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
/**
|
|
539
|
+
* Check if hash matches.
|
|
540
|
+
*/
|
|
541
|
+
matches(otherHash: string): boolean {
|
|
542
|
+
return this.hash === otherHash
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
private computeHash(): string {
|
|
546
|
+
const data = `${this.nodeCount}:${this.relCount}:${this.mutationCount}`
|
|
547
|
+
// Simple hash without crypto dependency
|
|
548
|
+
let hash = 0
|
|
549
|
+
for (let i = 0; i < data.length; i++) {
|
|
550
|
+
const char = data.charCodeAt(i)
|
|
551
|
+
hash = ((hash << 5) - hash) + char
|
|
552
|
+
hash = hash & hash // Convert to 32-bit integer
|
|
553
|
+
}
|
|
554
|
+
return hash.toString(36)
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
// ── Dirty State for Incremental Analysis ─────────────────────────────
|
|
559
|
+
|
|
560
|
+
export interface DirtyState {
|
|
561
|
+
dirtyNodeIds: Set<string>
|
|
562
|
+
dirtyTypes: Set<NodeType>
|
|
563
|
+
allChanged: boolean
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
export function computeDirtyState(
|
|
567
|
+
oldGraph: KnowledgeGraph | null,
|
|
568
|
+
newGraph: KnowledgeGraph,
|
|
569
|
+
): DirtyState {
|
|
570
|
+
if (!oldGraph) {
|
|
571
|
+
return { dirtyNodeIds: new Set(), dirtyTypes: new Set(), allChanged: true }
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
const dirtyNodeIds = new Set<string>()
|
|
575
|
+
const dirtyTypes = new Set<NodeType>()
|
|
576
|
+
|
|
577
|
+
const oldNodeIds = new Set(oldGraph.nodes.map(n => n.id))
|
|
578
|
+
const newNodeIds = new Set(newGraph.nodes.map(n => n.id))
|
|
579
|
+
|
|
580
|
+
for (const node of newGraph.nodes) {
|
|
581
|
+
if (!oldNodeIds.has(node.id)) {
|
|
582
|
+
dirtyNodeIds.add(node.id)
|
|
583
|
+
dirtyTypes.add(node.type)
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
for (const node of oldGraph.nodes) {
|
|
588
|
+
if (!newNodeIds.has(node.id)) {
|
|
589
|
+
dirtyNodeIds.add(node.id)
|
|
590
|
+
dirtyTypes.add(node.type)
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
const oldNodeMap = new Map(oldGraph.nodes.map(n => [n.id, n]))
|
|
595
|
+
for (const node of newGraph.nodes) {
|
|
596
|
+
const old = oldNodeMap.get(node.id)
|
|
597
|
+
if (old && old.version !== node.version) {
|
|
598
|
+
dirtyNodeIds.add(node.id)
|
|
599
|
+
dirtyTypes.add(node.type)
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
if (oldGraph.relationships.length !== newGraph.relationships.length) {
|
|
604
|
+
return { dirtyNodeIds, dirtyTypes, allChanged: true }
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
const oldRelKeys = new Set(
|
|
608
|
+
oldGraph.relationships.map(r => `${r.from}||${r.to}||${r.type}`)
|
|
609
|
+
)
|
|
610
|
+
for (const rel of newGraph.relationships) {
|
|
611
|
+
const key = `${rel.from}||${rel.to}||${rel.type}`
|
|
612
|
+
if (!oldRelKeys.has(key)) {
|
|
613
|
+
dirtyNodeIds.add(rel.from)
|
|
614
|
+
dirtyNodeIds.add(rel.to)
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
const expandedDirty = new Set(dirtyNodeIds)
|
|
619
|
+
const relIndex = new Map<string, Set<string>>()
|
|
620
|
+
for (const rel of newGraph.relationships) {
|
|
621
|
+
if (!relIndex.has(rel.from)) relIndex.set(rel.from, new Set())
|
|
622
|
+
if (!relIndex.has(rel.to)) relIndex.set(rel.to, new Set())
|
|
623
|
+
relIndex.get(rel.from)!.add(rel.to)
|
|
624
|
+
relIndex.get(rel.to)!.add(rel.from)
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
for (const dirtyId of dirtyNodeIds) {
|
|
628
|
+
const adjacent = relIndex.get(dirtyId)
|
|
629
|
+
if (adjacent) {
|
|
630
|
+
for (const adjId of adjacent) expandedDirty.add(adjId)
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
// Adaptive threshold: larger graphs tolerate higher % of dirty nodes
|
|
635
|
+
// before falling back to full validation
|
|
636
|
+
const adaptiveThreshold = computeAdaptiveThreshold(
|
|
637
|
+
newGraph.nodes.length,
|
|
638
|
+
dirtyNodeIds.size,
|
|
639
|
+
dirtyTypes,
|
|
640
|
+
)
|
|
641
|
+
|
|
642
|
+
return {
|
|
643
|
+
dirtyNodeIds: expandedDirty,
|
|
644
|
+
dirtyTypes,
|
|
645
|
+
allChanged: dirtyNodeIds.size > newGraph.nodes.length * adaptiveThreshold,
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
/**
|
|
650
|
+
* Compute an adaptive threshold for deciding when to fall back to full validation.
|
|
651
|
+
*
|
|
652
|
+
* Strategy:
|
|
653
|
+
* - Small graphs (<50 nodes): conservative, fall back at 30%
|
|
654
|
+
* - Medium graphs (50-200): moderate, fall back at 20%
|
|
655
|
+
* - Large graphs (>200): permissive, fall back at 10%
|
|
656
|
+
* - Metadata-only changes (no structural types): +15% more tolerance
|
|
657
|
+
* - Structural changes (types/relationships): -10% less tolerance
|
|
658
|
+
*/
|
|
659
|
+
function computeAdaptiveThreshold(
|
|
660
|
+
graphSize: number,
|
|
661
|
+
dirtyCount: number,
|
|
662
|
+
dirtyTypes: Set<NodeType>,
|
|
663
|
+
): number {
|
|
664
|
+
// Base threshold by graph size
|
|
665
|
+
let threshold: number
|
|
666
|
+
if (graphSize < 50) {
|
|
667
|
+
threshold = 0.30
|
|
668
|
+
} else if (graphSize < 200) {
|
|
669
|
+
threshold = 0.20
|
|
670
|
+
} else {
|
|
671
|
+
threshold = 0.10
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
// Adjust for change type
|
|
675
|
+
const STRUCTURAL_TYPES: Set<string> = new Set([
|
|
676
|
+
"architecture_component", "database", "table",
|
|
677
|
+
"constitution", "deprecation", "migration",
|
|
678
|
+
])
|
|
679
|
+
const METADATA_ONLY_TYPES: Set<string> = new Set([
|
|
680
|
+
"task", "test", "decision", "constraint", "assumption",
|
|
681
|
+
"metric", "alert", "sla",
|
|
682
|
+
])
|
|
683
|
+
|
|
684
|
+
let hasStructural = false
|
|
685
|
+
let hasMetadataOnly = true
|
|
686
|
+
for (const t of dirtyTypes) {
|
|
687
|
+
if (STRUCTURAL_TYPES.has(t)) hasStructural = true
|
|
688
|
+
if (!METADATA_ONLY_TYPES.has(t)) hasMetadataOnly = false
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
if (hasMetadataOnly && dirtyTypes.size > 0) {
|
|
692
|
+
threshold += 0.15 // More tolerance for metadata-only changes
|
|
693
|
+
}
|
|
694
|
+
if (hasStructural) {
|
|
695
|
+
threshold -= 0.10 // Less tolerance for structural changes
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
// Clamp between 5% and 50%
|
|
699
|
+
return Math.max(0.05, Math.min(0.5, threshold))
|
|
700
|
+
}
|