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,478 @@
|
|
|
1
|
+
import { readFileSync, writeFileSync, existsSync, mkdirSync } from "fs"
|
|
2
|
+
import { join, dirname } from "path"
|
|
3
|
+
import { execSync } from "child_process"
|
|
4
|
+
|
|
5
|
+
export type Role = "admin" | "architect" | "developer" | "viewer"
|
|
6
|
+
|
|
7
|
+
export type Permission =
|
|
8
|
+
| "create_feature"
|
|
9
|
+
| "create_requirement"
|
|
10
|
+
| "create_entity"
|
|
11
|
+
| "create_endpoint"
|
|
12
|
+
| "create_change"
|
|
13
|
+
| "approve_feature"
|
|
14
|
+
| "approve_requirement"
|
|
15
|
+
| "approve_architecture"
|
|
16
|
+
| "approve_breaking"
|
|
17
|
+
| "modify_constitution"
|
|
18
|
+
| "modify_decision"
|
|
19
|
+
| "execute_rollback"
|
|
20
|
+
| "manage_permissions"
|
|
21
|
+
| "sync_push"
|
|
22
|
+
| "sync_pull"
|
|
23
|
+
|
|
24
|
+
export interface RolePermissions {
|
|
25
|
+
role: Role
|
|
26
|
+
permissions: Permission[]
|
|
27
|
+
max_approvals: number
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface AuditEntry {
|
|
31
|
+
id: string
|
|
32
|
+
timestamp: string
|
|
33
|
+
user: string
|
|
34
|
+
action: string
|
|
35
|
+
target: string
|
|
36
|
+
result: "allowed" | "denied"
|
|
37
|
+
details?: string
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface PermissionConfig {
|
|
41
|
+
roles: RolePermissions[]
|
|
42
|
+
approval_requirements: Record<string, number>
|
|
43
|
+
audit_log: AuditEntry[]
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface RemoteAuthConfig {
|
|
47
|
+
provider: "github" | "gitlab" | null
|
|
48
|
+
owner: string
|
|
49
|
+
repo: string
|
|
50
|
+
token: string
|
|
51
|
+
branch: string
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface RemoteUser {
|
|
55
|
+
login: string
|
|
56
|
+
id: number
|
|
57
|
+
role: Role
|
|
58
|
+
permissions: {
|
|
59
|
+
admin: boolean
|
|
60
|
+
push: boolean
|
|
61
|
+
pull: boolean
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const PERMISSIONS_FILE = ".sdd/permissions.json"
|
|
66
|
+
const AUDIT_LOG_FILE = ".sdd/audit-log.json"
|
|
67
|
+
|
|
68
|
+
const DEFAULT_ROLES: RolePermissions[] = [
|
|
69
|
+
{
|
|
70
|
+
role: "admin",
|
|
71
|
+
permissions: [
|
|
72
|
+
"create_feature", "create_requirement", "create_entity", "create_endpoint",
|
|
73
|
+
"create_change", "approve_feature", "approve_requirement",
|
|
74
|
+
"approve_architecture", "approve_breaking", "modify_constitution",
|
|
75
|
+
"modify_decision", "execute_rollback", "manage_permissions",
|
|
76
|
+
"sync_push", "sync_pull",
|
|
77
|
+
],
|
|
78
|
+
max_approvals: 100,
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
role: "architect",
|
|
82
|
+
permissions: [
|
|
83
|
+
"create_feature", "create_requirement", "create_entity", "create_endpoint",
|
|
84
|
+
"create_change", "approve_feature", "approve_requirement",
|
|
85
|
+
"approve_architecture", "modify_decision",
|
|
86
|
+
"sync_push", "sync_pull",
|
|
87
|
+
],
|
|
88
|
+
max_approvals: 50,
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
role: "developer",
|
|
92
|
+
permissions: [
|
|
93
|
+
"create_feature", "create_requirement", "create_entity", "create_endpoint",
|
|
94
|
+
"create_change", "approve_feature", "approve_requirement",
|
|
95
|
+
"sync_push", "sync_pull",
|
|
96
|
+
],
|
|
97
|
+
max_approvals: 20,
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
role: "viewer",
|
|
101
|
+
permissions: [],
|
|
102
|
+
max_approvals: 0,
|
|
103
|
+
},
|
|
104
|
+
]
|
|
105
|
+
|
|
106
|
+
const CHANGE_TYPE_PERMISSIONS: Record<string, Permission> = {
|
|
107
|
+
feature: "approve_feature",
|
|
108
|
+
requirement: "approve_requirement",
|
|
109
|
+
architecture_component: "approve_architecture",
|
|
110
|
+
constraint: "approve_architecture",
|
|
111
|
+
decision: "modify_decision",
|
|
112
|
+
constitution: "modify_constitution",
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export function loadPermissions(projectDir: string): PermissionConfig {
|
|
116
|
+
const path = join(projectDir, PERMISSIONS_FILE)
|
|
117
|
+
if (!existsSync(path)) {
|
|
118
|
+
return {
|
|
119
|
+
roles: DEFAULT_ROLES,
|
|
120
|
+
approval_requirements: {
|
|
121
|
+
feature: 1,
|
|
122
|
+
requirement: 1,
|
|
123
|
+
architecture_component: 2,
|
|
124
|
+
breaking_change: 2,
|
|
125
|
+
},
|
|
126
|
+
audit_log: [],
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
try {
|
|
131
|
+
return JSON.parse(readFileSync(path, "utf-8"))
|
|
132
|
+
} catch {
|
|
133
|
+
return {
|
|
134
|
+
roles: DEFAULT_ROLES,
|
|
135
|
+
approval_requirements: {},
|
|
136
|
+
audit_log: [],
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export function savePermissions(projectDir: string, config: PermissionConfig): void {
|
|
142
|
+
const path = join(projectDir, PERMISSIONS_FILE)
|
|
143
|
+
const dir = dirname(path)
|
|
144
|
+
if (!existsSync(dir)) mkdirSync(dir, { recursive: true })
|
|
145
|
+
writeFileSync(path, JSON.stringify(config, null, 2), "utf-8")
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export function checkPermission(
|
|
149
|
+
userRole: Role,
|
|
150
|
+
permission: Permission,
|
|
151
|
+
projectDir: string,
|
|
152
|
+
): boolean {
|
|
153
|
+
const config = loadPermissions(projectDir)
|
|
154
|
+
const roleConfig = config.roles.find((r) => r.role === userRole)
|
|
155
|
+
if (!roleConfig) return false
|
|
156
|
+
return roleConfig.permissions.includes(permission)
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export function checkChangeApproval(
|
|
160
|
+
changeType: string,
|
|
161
|
+
userRole: Role,
|
|
162
|
+
projectDir: string,
|
|
163
|
+
): boolean {
|
|
164
|
+
const permission = CHANGE_TYPE_PERMISSIONS[changeType]
|
|
165
|
+
if (!permission) return true
|
|
166
|
+
return checkPermission(userRole, permission, projectDir)
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export function getRequiredApprovals(
|
|
170
|
+
changeType: string,
|
|
171
|
+
projectDir: string,
|
|
172
|
+
): number {
|
|
173
|
+
const config = loadPermissions(projectDir)
|
|
174
|
+
return config.approval_requirements[changeType] || 1
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export function addAuditEntry(
|
|
178
|
+
projectDir: string,
|
|
179
|
+
user: string,
|
|
180
|
+
action: string,
|
|
181
|
+
target: string,
|
|
182
|
+
result: "allowed" | "denied",
|
|
183
|
+
details?: string,
|
|
184
|
+
): void {
|
|
185
|
+
const auditPath = join(projectDir, AUDIT_LOG_FILE)
|
|
186
|
+
const dir = dirname(auditPath)
|
|
187
|
+
if (!existsSync(dir)) mkdirSync(dir, { recursive: true })
|
|
188
|
+
|
|
189
|
+
let entries: AuditEntry[] = []
|
|
190
|
+
if (existsSync(auditPath)) {
|
|
191
|
+
try {
|
|
192
|
+
entries = JSON.parse(readFileSync(auditPath, "utf-8"))
|
|
193
|
+
} catch {
|
|
194
|
+
entries = []
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
entries.push({
|
|
199
|
+
id: `audit_${Date.now()}`,
|
|
200
|
+
timestamp: new Date().toISOString(),
|
|
201
|
+
user,
|
|
202
|
+
action,
|
|
203
|
+
target,
|
|
204
|
+
result,
|
|
205
|
+
details,
|
|
206
|
+
})
|
|
207
|
+
|
|
208
|
+
if (entries.length > 1000) {
|
|
209
|
+
entries = entries.slice(-1000)
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
writeFileSync(auditPath, JSON.stringify(entries, null, 2), "utf-8")
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
export interface AuditLogFilters {
|
|
216
|
+
user?: string
|
|
217
|
+
action?: string
|
|
218
|
+
limit?: number
|
|
219
|
+
/** Filter by target (node ID, file path, etc.). */
|
|
220
|
+
target?: string
|
|
221
|
+
/** Filter by result (allowed/denied). */
|
|
222
|
+
result?: 'allowed' | 'denied'
|
|
223
|
+
/** Only entries after this ISO timestamp. */
|
|
224
|
+
dateFrom?: string
|
|
225
|
+
/** Only entries before this ISO timestamp. */
|
|
226
|
+
dateTo?: string
|
|
227
|
+
/** Max entries to return (default: all). */
|
|
228
|
+
maxEntries?: number
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/** Cache for audit log reads. Key: projectDir. */
|
|
232
|
+
const auditLogCache = new Map<string, { entries: AuditEntry[]; timestamp: number }>()
|
|
233
|
+
|
|
234
|
+
export function getAuditLog(
|
|
235
|
+
projectDir: string,
|
|
236
|
+
filters?: AuditLogFilters,
|
|
237
|
+
): AuditEntry[] {
|
|
238
|
+
const auditPath = join(projectDir, AUDIT_LOG_FILE)
|
|
239
|
+
if (!existsSync(auditPath)) return []
|
|
240
|
+
|
|
241
|
+
try {
|
|
242
|
+
let entries: AuditEntry[] = JSON.parse(readFileSync(auditPath, "utf-8"))
|
|
243
|
+
|
|
244
|
+
if (filters?.user) {
|
|
245
|
+
entries = entries.filter((e) => e.user === filters.user)
|
|
246
|
+
}
|
|
247
|
+
if (filters?.action) {
|
|
248
|
+
entries = entries.filter((e) => e.action === filters.action)
|
|
249
|
+
}
|
|
250
|
+
if (filters?.target) {
|
|
251
|
+
entries = entries.filter((e) => e.target === filters.target)
|
|
252
|
+
}
|
|
253
|
+
if (filters?.result) {
|
|
254
|
+
entries = entries.filter((e) => e.result === filters.result)
|
|
255
|
+
}
|
|
256
|
+
if (filters?.dateFrom) {
|
|
257
|
+
entries = entries.filter((e) => e.timestamp >= filters.dateFrom!)
|
|
258
|
+
}
|
|
259
|
+
if (filters?.dateTo) {
|
|
260
|
+
entries = entries.filter((e) => e.timestamp <= filters.dateTo!)
|
|
261
|
+
}
|
|
262
|
+
if (filters?.maxEntries) {
|
|
263
|
+
entries = entries.slice(-filters.maxEntries)
|
|
264
|
+
} else if (filters?.limit) {
|
|
265
|
+
entries = entries.slice(-filters.limit)
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
return entries
|
|
269
|
+
} catch {
|
|
270
|
+
return []
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
export function setRole(
|
|
275
|
+
projectDir: string,
|
|
276
|
+
user: string,
|
|
277
|
+
role: Role,
|
|
278
|
+
): void {
|
|
279
|
+
const usersFile = join(projectDir, ".sdd", "users.json")
|
|
280
|
+
|
|
281
|
+
let users: Record<string, Role> = {}
|
|
282
|
+
if (existsSync(usersFile)) {
|
|
283
|
+
try {
|
|
284
|
+
users = JSON.parse(readFileSync(usersFile, "utf-8"))
|
|
285
|
+
} catch {
|
|
286
|
+
users = {}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
users[user] = role
|
|
291
|
+
writeFileSync(usersFile, JSON.stringify(users, null, 2), "utf-8")
|
|
292
|
+
|
|
293
|
+
addAuditEntry(projectDir, "system", "set_role", user, "allowed", `Role set to ${role}`)
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export function getUserRole(projectDir: string, user: string): Role {
|
|
297
|
+
const usersFile = join(projectDir, ".sdd", "users.json")
|
|
298
|
+
if (!existsSync(usersFile)) return "viewer"
|
|
299
|
+
|
|
300
|
+
try {
|
|
301
|
+
const users: Record<string, Role> = JSON.parse(readFileSync(usersFile, "utf-8"))
|
|
302
|
+
return users[user] || "viewer"
|
|
303
|
+
} catch {
|
|
304
|
+
return "viewer"
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
export function detectRemote(projectDir: string): RemoteAuthConfig | null {
|
|
309
|
+
try {
|
|
310
|
+
const remoteUrl = execSync("git remote get-url origin", {
|
|
311
|
+
cwd: projectDir,
|
|
312
|
+
encoding: "utf-8",
|
|
313
|
+
timeout: 5000,
|
|
314
|
+
}).trim()
|
|
315
|
+
|
|
316
|
+
if (!remoteUrl) return null
|
|
317
|
+
|
|
318
|
+
let provider: "github" | "gitlab" | null = null
|
|
319
|
+
let owner = ""
|
|
320
|
+
let repo = ""
|
|
321
|
+
|
|
322
|
+
if (remoteUrl.includes("github.com")) {
|
|
323
|
+
provider = "github"
|
|
324
|
+
const match = remoteUrl.match(/github\.com[:/](.+?)\/(.+?)(?:\.git)?$/)
|
|
325
|
+
if (match) {
|
|
326
|
+
owner = match[1]
|
|
327
|
+
repo = match[2]
|
|
328
|
+
}
|
|
329
|
+
} else if (remoteUrl.includes("gitlab.com")) {
|
|
330
|
+
provider = "gitlab"
|
|
331
|
+
const match = remoteUrl.match(/gitlab\.com[:/](.+?)\/(.+?)(?:\.git)?$/)
|
|
332
|
+
if (match) {
|
|
333
|
+
owner = match[1]
|
|
334
|
+
repo = match[2]
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
if (!provider || !owner || !repo) return null
|
|
339
|
+
|
|
340
|
+
const token = process.env.GITHUB_TOKEN || process.env.GITLAB_TOKEN || ""
|
|
341
|
+
|
|
342
|
+
return {
|
|
343
|
+
provider,
|
|
344
|
+
owner,
|
|
345
|
+
repo,
|
|
346
|
+
token,
|
|
347
|
+
branch: "main",
|
|
348
|
+
}
|
|
349
|
+
} catch {
|
|
350
|
+
return null
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
export function fetchRemoteUser(projectDir: string, username: string): RemoteUser | null {
|
|
355
|
+
const remote = detectRemote(projectDir)
|
|
356
|
+
if (!remote || !remote.token) return null
|
|
357
|
+
|
|
358
|
+
try {
|
|
359
|
+
if (remote.provider === "github") {
|
|
360
|
+
const response = execSync(
|
|
361
|
+
`curl -s -H "Authorization: token ${remote.token}" "https://api.github.com/repos/${remote.owner}/${remote.repo}/collaborators/${username}/permission"`,
|
|
362
|
+
{ cwd: projectDir, encoding: "utf-8", timeout: 10000 },
|
|
363
|
+
)
|
|
364
|
+
|
|
365
|
+
const data = JSON.parse(response)
|
|
366
|
+
|
|
367
|
+
if (!data.permission) return null
|
|
368
|
+
|
|
369
|
+
const role: Role = data.permission === "admin" ? "admin"
|
|
370
|
+
: data.permission === "write" ? "developer"
|
|
371
|
+
: data.permission === "read" ? "viewer"
|
|
372
|
+
: "viewer"
|
|
373
|
+
|
|
374
|
+
return {
|
|
375
|
+
login: username,
|
|
376
|
+
id: 0,
|
|
377
|
+
role,
|
|
378
|
+
permissions: {
|
|
379
|
+
admin: data.permission === "admin",
|
|
380
|
+
push: data.permission === "admin" || data.permission === "write",
|
|
381
|
+
pull: true,
|
|
382
|
+
},
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
if (remote.provider === "gitlab") {
|
|
387
|
+
const response = execSync(
|
|
388
|
+
`curl -s -H "PRIVATE-TOKEN: ${remote.token}" "https://gitlab.com/api/v4/projects/${encodeURIComponent(`${remote.owner}/${remote.repo}`)}/members/all/${username}"`,
|
|
389
|
+
{ cwd: projectDir, encoding: "utf-8", timeout: 10000 },
|
|
390
|
+
)
|
|
391
|
+
|
|
392
|
+
const data = JSON.parse(response)
|
|
393
|
+
|
|
394
|
+
if (!data.access_level) return null
|
|
395
|
+
|
|
396
|
+
const role: Role = data.access_level >= 50 ? "admin"
|
|
397
|
+
: data.access_level >= 30 ? "developer"
|
|
398
|
+
: data.access_level >= 10 ? "viewer"
|
|
399
|
+
: "viewer"
|
|
400
|
+
|
|
401
|
+
return {
|
|
402
|
+
login: username,
|
|
403
|
+
id: data.id,
|
|
404
|
+
role,
|
|
405
|
+
permissions: {
|
|
406
|
+
admin: data.access_level >= 50,
|
|
407
|
+
push: data.access_level >= 30,
|
|
408
|
+
pull: data.access_level >= 10,
|
|
409
|
+
},
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
} catch {
|
|
413
|
+
return null
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
return null
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
export function getUserRoleWithAuth(projectDir: string, user: string): Role {
|
|
420
|
+
const localRole = getUserRole(projectDir, user)
|
|
421
|
+
if (localRole !== "viewer") return localRole
|
|
422
|
+
|
|
423
|
+
const remoteUser = fetchRemoteUser(projectDir, user)
|
|
424
|
+
if (remoteUser) {
|
|
425
|
+
return remoteUser.role
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
const remote = detectRemote(projectDir)
|
|
429
|
+
if (remote && remote.token) {
|
|
430
|
+
return "viewer"
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
return "admin"
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
export function formatRemoteStatus(remote: RemoteAuthConfig | null): string {
|
|
437
|
+
if (!remote) return "No remote configured"
|
|
438
|
+
|
|
439
|
+
const lines = [
|
|
440
|
+
`**Provider:** ${remote.provider}`,
|
|
441
|
+
`**Repository:** ${remote.owner}/${remote.repo}`,
|
|
442
|
+
`**Token:** ${remote.token ? "✅ Configured" : "❌ Not configured"}`,
|
|
443
|
+
]
|
|
444
|
+
|
|
445
|
+
return lines.join("\n")
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
export function formatPermissionCheck(
|
|
449
|
+
user: string,
|
|
450
|
+
role: Role,
|
|
451
|
+
permission: Permission,
|
|
452
|
+
allowed: boolean,
|
|
453
|
+
): string {
|
|
454
|
+
const status = allowed ? "✅" : "❌"
|
|
455
|
+
return `${status} User **${user}** (${role}) → ${permission}: ${allowed ? "ALLOWED" : "DENIED"}`
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
export function formatAuditLog(entries: AuditEntry[]): string {
|
|
459
|
+
const lines = [
|
|
460
|
+
"## Audit Log",
|
|
461
|
+
"",
|
|
462
|
+
]
|
|
463
|
+
|
|
464
|
+
if (entries.length === 0) {
|
|
465
|
+
lines.push("No audit entries found.")
|
|
466
|
+
return lines.join("\n")
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
for (const entry of entries.slice(-20)) {
|
|
470
|
+
const status = entry.result === "allowed" ? "✅" : "❌"
|
|
471
|
+
lines.push(`- ${status} **${entry.user}** ${entry.action} → ${entry.target} (${entry.timestamp})`)
|
|
472
|
+
if (entry.details) {
|
|
473
|
+
lines.push(` ${entry.details}`)
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
return lines.join("\n")
|
|
478
|
+
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import type { KnowledgeGraph, AnyNode, NodeType, NodeStatus, Relationship } from "../domain/types.js"
|
|
2
|
+
import { DEFAULT_SDD_CONFIG, type SddConfig } from "../domain/types.js"
|
|
3
|
+
import { GraphIndices } from "../graph/index.js"
|
|
4
|
+
import { existsSync, readFileSync } from "fs"
|
|
5
|
+
import { join } from "path"
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Unified interface for graph storage.
|
|
9
|
+
* Both YAML and SQLite implementations satisfy this contract.
|
|
10
|
+
*/
|
|
11
|
+
export interface GraphRepository {
|
|
12
|
+
/** Check if SDD is initialized (graph file/db exists) */
|
|
13
|
+
isInitialized(): boolean
|
|
14
|
+
|
|
15
|
+
/** Load the full graph into memory */
|
|
16
|
+
loadGraph(): KnowledgeGraph
|
|
17
|
+
|
|
18
|
+
/** Save the full graph (and update cache/indices) */
|
|
19
|
+
saveGraph(graph: KnowledgeGraph): void
|
|
20
|
+
|
|
21
|
+
/** Get pre-computed indices for O(1) queries */
|
|
22
|
+
getIndices(): GraphIndices
|
|
23
|
+
|
|
24
|
+
/** Get the underlying storage type */
|
|
25
|
+
getStorageType(): "yaml" | "sqlite"
|
|
26
|
+
|
|
27
|
+
/** Check if the cache is still valid */
|
|
28
|
+
isCacheValid(): boolean
|
|
29
|
+
|
|
30
|
+
/** Invalidate the in-memory cache */
|
|
31
|
+
invalidateCache(): void
|
|
32
|
+
|
|
33
|
+
/** Ensure the .sdd directory structure exists */
|
|
34
|
+
ensureSddDir(): void
|
|
35
|
+
|
|
36
|
+
/** Create a new project graph */
|
|
37
|
+
createProject(projectId: string, name: string, description?: string): KnowledgeGraph
|
|
38
|
+
|
|
39
|
+
/** Create a snapshot of the current state */
|
|
40
|
+
createSnapshot(description: string): string
|
|
41
|
+
|
|
42
|
+
/** List available snapshots */
|
|
43
|
+
listSnapshots(): string[]
|
|
44
|
+
|
|
45
|
+
/** Migrate to a different storage backend */
|
|
46
|
+
migrateTo(target: "yaml" | "sqlite", projectDir: string): GraphRepository
|
|
47
|
+
|
|
48
|
+
/** Get node count without loading full graph (optimized) */
|
|
49
|
+
getNodeCount(): number
|
|
50
|
+
|
|
51
|
+
/** Get relationship count without loading full graph (optimized) */
|
|
52
|
+
getRelationshipCount(): number
|
|
53
|
+
|
|
54
|
+
/** Get nodes by type without loading full graph (optimized for large graphs) */
|
|
55
|
+
getNodesByType?(type: NodeType): AnyNode[]
|
|
56
|
+
|
|
57
|
+
/** Get nodes by status without loading full graph (optimized for large graphs) */
|
|
58
|
+
getNodesByStatus?(status: NodeStatus): AnyNode[]
|
|
59
|
+
|
|
60
|
+
/** Get a single node by ID without loading full graph (optimized for large graphs) */
|
|
61
|
+
getNodeById?(id: string): AnyNode | undefined
|
|
62
|
+
|
|
63
|
+
/** Get relationships for a node without loading full graph (optimized for large graphs) */
|
|
64
|
+
getRelationshipsForNode?(nodeId: string): Relationship[]
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const MIGRATION_THRESHOLD = 1000
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Auto-detect the best storage backend and return a repository.
|
|
71
|
+
*
|
|
72
|
+
* Decision logic:
|
|
73
|
+
* - If .sdd/graph.db exists → use SQLite
|
|
74
|
+
* - If .sdd/graph.yaml exists and <1000 nodes → use YAML
|
|
75
|
+
* - If .sdd/graph.yaml exists and ≥1000 nodes → auto-migrate to SQLite
|
|
76
|
+
* - If neither exists → return YAML (default for new projects)
|
|
77
|
+
*/
|
|
78
|
+
export function createRepository(projectDir: string): GraphRepository {
|
|
79
|
+
const sddDir = join(projectDir, ".sdd")
|
|
80
|
+
const yamlPath = join(sddDir, "graph.yaml")
|
|
81
|
+
const dbPath = join(sddDir, "graph.db")
|
|
82
|
+
|
|
83
|
+
// If SQLite already exists, use it
|
|
84
|
+
if (existsSync(dbPath)) {
|
|
85
|
+
const { SqliteGraphRepository } = require("./sqlite.js")
|
|
86
|
+
return new SqliteGraphRepository(projectDir)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// If YAML exists, check if migration is needed
|
|
90
|
+
if (existsSync(yamlPath)) {
|
|
91
|
+
const nodeCount = countNodesInYaml(yamlPath)
|
|
92
|
+
if (nodeCount >= MIGRATION_THRESHOLD) {
|
|
93
|
+
// Auto-migrate to SQLite
|
|
94
|
+
return autoMigrateToSqlite(projectDir)
|
|
95
|
+
}
|
|
96
|
+
const { YamlGraphRepository } = require("./yaml.js")
|
|
97
|
+
return new YamlGraphRepository(projectDir)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Default: YAML for new projects
|
|
101
|
+
const { YamlGraphRepository } = require("./yaml.js")
|
|
102
|
+
return new YamlGraphRepository(projectDir)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Quick node count from YAML without full parse.
|
|
107
|
+
* Reads the file and counts node entries approximately.
|
|
108
|
+
*/
|
|
109
|
+
function countNodesInYaml(yamlPath: string): number {
|
|
110
|
+
try {
|
|
111
|
+
const content = readFileSync(yamlPath, "utf-8")
|
|
112
|
+
// Count "- id:" occurrences which indicates node entries
|
|
113
|
+
const matches = content.match(/^ - id:/gm)
|
|
114
|
+
return matches ? matches.length : 0
|
|
115
|
+
} catch {
|
|
116
|
+
return 0
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Auto-migrate from YAML to SQLite.
|
|
122
|
+
* Reads the YAML graph, writes to SQLite, returns SQLite repository.
|
|
123
|
+
*/
|
|
124
|
+
function autoMigrateToSqlite(projectDir: string): GraphRepository {
|
|
125
|
+
const { YamlGraphRepository } = require("./yaml.js")
|
|
126
|
+
const { SqliteGraphRepository } = require("./sqlite.js")
|
|
127
|
+
|
|
128
|
+
const yamlRepo = new YamlGraphRepository(projectDir)
|
|
129
|
+
const graph = yamlRepo.loadGraph()
|
|
130
|
+
|
|
131
|
+
const sqliteRepo = new SqliteGraphRepository(projectDir)
|
|
132
|
+
sqliteRepo.saveGraph(graph)
|
|
133
|
+
|
|
134
|
+
// Keep YAML as backup
|
|
135
|
+
const yamlPath = join(projectDir, ".sdd", "graph.yaml.bak")
|
|
136
|
+
try {
|
|
137
|
+
const { writeFileSync } = require("fs")
|
|
138
|
+
const yaml = require("js-yaml")
|
|
139
|
+
writeFileSync(yamlPath, yaml.dump(graph, { noRefs: true, lineWidth: 120 }))
|
|
140
|
+
} catch {}
|
|
141
|
+
|
|
142
|
+
return sqliteRepo
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Load the SDD configuration, falling back to defaults.
|
|
147
|
+
*/
|
|
148
|
+
export function loadSddConfig(projectDir: string): SddConfig {
|
|
149
|
+
const configPath = join(projectDir, ".sdd", "config.json")
|
|
150
|
+
if (existsSync(configPath)) {
|
|
151
|
+
try {
|
|
152
|
+
const content = readFileSync(configPath, "utf-8")
|
|
153
|
+
const parsed = JSON.parse(content) as Partial<SddConfig>
|
|
154
|
+
return {
|
|
155
|
+
...DEFAULT_SDD_CONFIG,
|
|
156
|
+
...parsed,
|
|
157
|
+
dashboard: { ...DEFAULT_SDD_CONFIG.dashboard, ...(parsed.dashboard || {}) },
|
|
158
|
+
workflow: { ...DEFAULT_SDD_CONFIG.workflow, ...(parsed.workflow || {}) },
|
|
159
|
+
graph: { ...DEFAULT_SDD_CONFIG.graph, ...(parsed.graph || {}) },
|
|
160
|
+
git: { ...DEFAULT_SDD_CONFIG.git, ...(parsed.git || {}) },
|
|
161
|
+
validation: { ...DEFAULT_SDD_CONFIG.validation, ...(parsed.validation || {}) },
|
|
162
|
+
}
|
|
163
|
+
} catch {}
|
|
164
|
+
}
|
|
165
|
+
return DEFAULT_SDD_CONFIG
|
|
166
|
+
}
|