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,361 @@
|
|
|
1
|
+
import type { KnowledgeGraph, ChangeNode } from "../domain/types.js"
|
|
2
|
+
import { getNode, updateNode } from "../graph/engine.js"
|
|
3
|
+
import { execSync } from "child_process"
|
|
4
|
+
import { readFileSync, writeFileSync, existsSync, mkdirSync, copyFileSync, readdirSync } from "fs"
|
|
5
|
+
import { join, dirname } from "path"
|
|
6
|
+
|
|
7
|
+
export interface RollbackResult {
|
|
8
|
+
success: boolean
|
|
9
|
+
method: "git" | "snapshot" | "backup" | "failed"
|
|
10
|
+
details: string
|
|
11
|
+
restored_files?: string[]
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface RollbackSnapshot {
|
|
15
|
+
id: string
|
|
16
|
+
change_id: string
|
|
17
|
+
timestamp: string
|
|
18
|
+
graph_state: KnowledgeGraph
|
|
19
|
+
backed_up_files: Array<{ path: string; backup_path: string }>
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface RollbackHistory {
|
|
23
|
+
rollbacks: Array<{
|
|
24
|
+
id: string
|
|
25
|
+
change_id: string
|
|
26
|
+
timestamp: string
|
|
27
|
+
method: string
|
|
28
|
+
success: boolean
|
|
29
|
+
}>
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const SNAPSHOTS_DIR = ".sdd/snapshots"
|
|
33
|
+
const BACKUPS_DIR = ".sdd/backups"
|
|
34
|
+
const ROLLBACK_HISTORY_FILE = ".sdd/rollback-history.json"
|
|
35
|
+
|
|
36
|
+
export function createSnapshot(
|
|
37
|
+
graph: KnowledgeGraph,
|
|
38
|
+
changeId: string,
|
|
39
|
+
projectDir: string,
|
|
40
|
+
): RollbackSnapshot {
|
|
41
|
+
const snapshotId = `snap_${Date.now()}`
|
|
42
|
+
const snapshot: RollbackSnapshot = {
|
|
43
|
+
id: snapshotId,
|
|
44
|
+
change_id: changeId,
|
|
45
|
+
timestamp: new Date().toISOString(),
|
|
46
|
+
graph_state: JSON.parse(JSON.stringify(graph)),
|
|
47
|
+
backed_up_files: [],
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const change = getNode(graph, changeId) as ChangeNode | undefined
|
|
51
|
+
if (change && change.metadata.affected_files) {
|
|
52
|
+
const backupDir = join(projectDir, BACKUPS_DIR, snapshotId)
|
|
53
|
+
if (!existsSync(backupDir)) mkdirSync(backupDir, { recursive: true })
|
|
54
|
+
|
|
55
|
+
for (const file of change.metadata.affected_files) {
|
|
56
|
+
const fullPath = join(projectDir, file)
|
|
57
|
+
if (existsSync(fullPath)) {
|
|
58
|
+
const backupPath = join(backupDir, file.replace(/\//g, "_"))
|
|
59
|
+
try {
|
|
60
|
+
copyFileSync(fullPath, backupPath)
|
|
61
|
+
snapshot.backed_up_files.push({ path: file, backup_path: backupPath })
|
|
62
|
+
} catch {
|
|
63
|
+
// skip files that can't be copied
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const snapshotsDir = join(projectDir, SNAPSHOTS_DIR)
|
|
70
|
+
if (!existsSync(snapshotsDir)) mkdirSync(snapshotsDir, { recursive: true })
|
|
71
|
+
writeFileSync(join(snapshotsDir, `${snapshotId}.json`), JSON.stringify(snapshot, null, 2), "utf-8")
|
|
72
|
+
|
|
73
|
+
return snapshot
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function rollbackByGit(
|
|
77
|
+
projectDir: string,
|
|
78
|
+
changeId: string,
|
|
79
|
+
options?: Pick<RollbackOptions, 'commitCache'>,
|
|
80
|
+
): RollbackResult {
|
|
81
|
+
try {
|
|
82
|
+
const commitHash = findCommitForChange(projectDir, changeId, options?.commitCache)
|
|
83
|
+
if (!commitHash) {
|
|
84
|
+
return { success: false, method: "git", details: "No commit found for this change" }
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
execSync(`git revert ${commitHash} --no-edit`, {
|
|
88
|
+
cwd: projectDir,
|
|
89
|
+
encoding: "utf-8",
|
|
90
|
+
timeout: 30000,
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
return {
|
|
94
|
+
success: true,
|
|
95
|
+
method: "git",
|
|
96
|
+
details: `Successfully reverted commit ${commitHash}`,
|
|
97
|
+
}
|
|
98
|
+
} catch (error) {
|
|
99
|
+
return {
|
|
100
|
+
success: false,
|
|
101
|
+
method: "git",
|
|
102
|
+
details: `Git revert failed: ${error instanceof Error ? error.message : "unknown"}`,
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export function rollbackBySnapshot(
|
|
108
|
+
graph: KnowledgeGraph,
|
|
109
|
+
changeId: string,
|
|
110
|
+
projectDir: string,
|
|
111
|
+
options?: Pick<RollbackOptions, 'snapshotIndex'>,
|
|
112
|
+
): RollbackResult {
|
|
113
|
+
const snapshot = findSnapshot(projectDir, changeId, options)
|
|
114
|
+
if (!snapshot) {
|
|
115
|
+
return { success: false, method: "snapshot", details: "No snapshot found for this change" }
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const restoredFiles: string[] = []
|
|
119
|
+
|
|
120
|
+
for (const backedUp of snapshot.backed_up_files) {
|
|
121
|
+
if (existsSync(backedUp.backup_path)) {
|
|
122
|
+
const fullPath = join(projectDir, backedUp.path)
|
|
123
|
+
const dir = dirname(fullPath)
|
|
124
|
+
if (!existsSync(dir)) mkdirSync(dir, { recursive: true })
|
|
125
|
+
try {
|
|
126
|
+
copyFileSync(backedUp.backup_path, fullPath)
|
|
127
|
+
restoredFiles.push(backedUp.path)
|
|
128
|
+
} catch {
|
|
129
|
+
// skip
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const change = getNode(graph, changeId) as ChangeNode | undefined
|
|
135
|
+
if (change) {
|
|
136
|
+
change.status = "ROLLED_BACK"
|
|
137
|
+
const metadata = change.metadata as Record<string, unknown>
|
|
138
|
+
metadata.rollback_snapshot = snapshot.id
|
|
139
|
+
metadata.rollback_at = new Date().toISOString()
|
|
140
|
+
updateNode(graph, changeId, {
|
|
141
|
+
status: "ROLLED_BACK",
|
|
142
|
+
metadata,
|
|
143
|
+
})
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return {
|
|
147
|
+
success: true,
|
|
148
|
+
method: "snapshot",
|
|
149
|
+
details: `Restored from snapshot ${snapshot.id}`,
|
|
150
|
+
restored_files: restoredFiles,
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export function rollbackByBackup(
|
|
155
|
+
_graph: KnowledgeGraph,
|
|
156
|
+
changeId: string,
|
|
157
|
+
projectDir: string,
|
|
158
|
+
options?: Pick<RollbackOptions, 'snapshotIndex'>,
|
|
159
|
+
): RollbackResult {
|
|
160
|
+
const snapshot = findSnapshot(projectDir, changeId, options)
|
|
161
|
+
if (!snapshot) {
|
|
162
|
+
return { success: false, method: "backup", details: "No backup found for this change" }
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const restoredFiles: string[] = []
|
|
166
|
+
|
|
167
|
+
for (const backedUp of snapshot.backed_up_files) {
|
|
168
|
+
if (existsSync(backedUp.backup_path)) {
|
|
169
|
+
const fullPath = join(projectDir, backedUp.path)
|
|
170
|
+
const dir = dirname(fullPath)
|
|
171
|
+
if (!existsSync(dir)) mkdirSync(dir, { recursive: true })
|
|
172
|
+
try {
|
|
173
|
+
copyFileSync(backedUp.backup_path, fullPath)
|
|
174
|
+
restoredFiles.push(backedUp.path)
|
|
175
|
+
} catch {
|
|
176
|
+
// skip
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return {
|
|
182
|
+
success: true,
|
|
183
|
+
method: "backup",
|
|
184
|
+
details: `Restored ${restoredFiles.length} files from backup`,
|
|
185
|
+
restored_files: restoredFiles,
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export function executeRollback(
|
|
190
|
+
graph: KnowledgeGraph,
|
|
191
|
+
changeId: string,
|
|
192
|
+
projectDir: string,
|
|
193
|
+
options?: RollbackOptions,
|
|
194
|
+
): RollbackResult {
|
|
195
|
+
let result = rollbackByGit(projectDir, changeId, options)
|
|
196
|
+
if (result.success) {
|
|
197
|
+
recordRollback(projectDir, changeId, result)
|
|
198
|
+
return result
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
result = rollbackBySnapshot(graph, changeId, projectDir, options)
|
|
202
|
+
if (result.success) {
|
|
203
|
+
recordRollback(projectDir, changeId, result)
|
|
204
|
+
return result
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
result = rollbackByBackup(graph, changeId, projectDir, options)
|
|
208
|
+
if (result.success) {
|
|
209
|
+
recordRollback(projectDir, changeId, result)
|
|
210
|
+
return result
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
result = { success: false, method: "failed", details: "All rollback methods failed" }
|
|
214
|
+
recordRollback(projectDir, changeId, result)
|
|
215
|
+
return result
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function findCommitForChange(
|
|
219
|
+
projectDir: string,
|
|
220
|
+
changeId: string,
|
|
221
|
+
commitCache?: Map<string, string | null>,
|
|
222
|
+
): string | null {
|
|
223
|
+
// Fast path: use cache
|
|
224
|
+
if (commitCache?.has(changeId)) return commitCache.get(changeId)!
|
|
225
|
+
|
|
226
|
+
let result: string | null = null
|
|
227
|
+
try {
|
|
228
|
+
const log = execSync(`git log --all --oneline --grep="${changeId}"`, {
|
|
229
|
+
cwd: projectDir,
|
|
230
|
+
encoding: "utf-8",
|
|
231
|
+
timeout: 10000,
|
|
232
|
+
}).trim()
|
|
233
|
+
|
|
234
|
+
if (log) {
|
|
235
|
+
const firstLine = log.split("\n")[0]
|
|
236
|
+
result = firstLine.split(" ")[0]
|
|
237
|
+
}
|
|
238
|
+
} catch {
|
|
239
|
+
// git not available or no matching commit
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
commitCache?.set(changeId, result)
|
|
243
|
+
return result
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export interface RollbackOptions {
|
|
247
|
+
/** Index for O(1) snapshot lookup (changeId → snapshotId). */
|
|
248
|
+
snapshotIndex?: Map<string, string>
|
|
249
|
+
/** Only look for these specific change IDs. */
|
|
250
|
+
focusChangeId?: string[]
|
|
251
|
+
/** Cache for git commit lookups (changeId → commitHash). */
|
|
252
|
+
commitCache?: Map<string, string | null>
|
|
253
|
+
/** Only look for commits matching these change IDs. */
|
|
254
|
+
focusChangeIds?: string[]
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function findSnapshot(
|
|
258
|
+
projectDir: string,
|
|
259
|
+
changeId: string,
|
|
260
|
+
options?: Pick<RollbackOptions, 'snapshotIndex' | 'focusChangeId'>,
|
|
261
|
+
): RollbackSnapshot | null {
|
|
262
|
+
// Fast path: use index
|
|
263
|
+
if (options?.snapshotIndex?.has(changeId)) {
|
|
264
|
+
const snapshotId = options.snapshotIndex.get(changeId)!
|
|
265
|
+
const snapshotPath = join(projectDir, SNAPSHOTS_DIR, `${snapshotId}.json`)
|
|
266
|
+
if (existsSync(snapshotPath)) {
|
|
267
|
+
try {
|
|
268
|
+
return JSON.parse(readFileSync(snapshotPath, "utf-8")) as RollbackSnapshot
|
|
269
|
+
} catch { /* skip */ }
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
const snapshotsDir = join(projectDir, SNAPSHOTS_DIR)
|
|
274
|
+
if (!existsSync(snapshotsDir)) return null
|
|
275
|
+
|
|
276
|
+
const files = readdirSync(snapshotsDir).filter((f) => f.endsWith(".json"))
|
|
277
|
+
for (const file of files) {
|
|
278
|
+
try {
|
|
279
|
+
const snapshot = JSON.parse(readFileSync(join(snapshotsDir, file), "utf-8")) as RollbackSnapshot
|
|
280
|
+
if (snapshot.change_id === changeId) {
|
|
281
|
+
options?.snapshotIndex?.set(snapshot.change_id, snapshot.id)
|
|
282
|
+
return snapshot
|
|
283
|
+
}
|
|
284
|
+
} catch {
|
|
285
|
+
// skip
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
return null
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function recordRollback(
|
|
293
|
+
projectDir: string,
|
|
294
|
+
changeId: string,
|
|
295
|
+
result: RollbackResult,
|
|
296
|
+
): void {
|
|
297
|
+
const history = loadRollbackHistory(projectDir)
|
|
298
|
+
history.rollbacks.push({
|
|
299
|
+
id: `rb_${Date.now()}`,
|
|
300
|
+
change_id: changeId,
|
|
301
|
+
timestamp: new Date().toISOString(),
|
|
302
|
+
method: result.method,
|
|
303
|
+
success: result.success,
|
|
304
|
+
})
|
|
305
|
+
saveRollbackHistory(projectDir, history)
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
export function loadRollbackHistory(projectDir: string): RollbackHistory {
|
|
309
|
+
const path = join(projectDir, ROLLBACK_HISTORY_FILE)
|
|
310
|
+
if (!existsSync(path)) return { rollbacks: [] }
|
|
311
|
+
try {
|
|
312
|
+
return JSON.parse(readFileSync(path, "utf-8"))
|
|
313
|
+
} catch {
|
|
314
|
+
return { rollbacks: [] }
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
function saveRollbackHistory(projectDir: string, history: RollbackHistory): void {
|
|
319
|
+
const path = join(projectDir, ROLLBACK_HISTORY_FILE)
|
|
320
|
+
const dir = dirname(path)
|
|
321
|
+
if (!existsSync(dir)) mkdirSync(dir, { recursive: true })
|
|
322
|
+
writeFileSync(path, JSON.stringify(history, null, 2), "utf-8")
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
export function formatRollbackResult(result: RollbackResult): string {
|
|
326
|
+
const lines = [
|
|
327
|
+
"## Rollback Result",
|
|
328
|
+
"",
|
|
329
|
+
`- **Success:** ${result.success ? "✅ Yes" : "❌ No"}`,
|
|
330
|
+
`- **Method:** ${result.method}`,
|
|
331
|
+
`- **Details:** ${result.details}`,
|
|
332
|
+
]
|
|
333
|
+
|
|
334
|
+
if (result.restored_files && result.restored_files.length > 0) {
|
|
335
|
+
lines.push("\n### Restored Files")
|
|
336
|
+
for (const file of result.restored_files) {
|
|
337
|
+
lines.push(`- ${file}`)
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
return lines.join("\n")
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
export function formatRollbackHistory(history: RollbackHistory): string {
|
|
345
|
+
const lines = [
|
|
346
|
+
"## Rollback History",
|
|
347
|
+
"",
|
|
348
|
+
]
|
|
349
|
+
|
|
350
|
+
if (history.rollbacks.length === 0) {
|
|
351
|
+
lines.push("No rollbacks recorded.")
|
|
352
|
+
return lines.join("\n")
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
for (const rb of history.rollbacks) {
|
|
356
|
+
const status = rb.success ? "✅" : "❌"
|
|
357
|
+
lines.push(`- ${status} **${rb.change_id}** (${rb.method}) at ${rb.timestamp}`)
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
return lines.join("\n")
|
|
361
|
+
}
|
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
import type { KnowledgeGraph, ChangeNode, DecisionNode, AnyNode, SpecPromise } from "../domain/types.js"
|
|
2
|
+
import { getNodesByType } from "../graph/engine.js"
|
|
3
|
+
import { getPendingChanges } from "../changes/manager.js"
|
|
4
|
+
import { getPromiseReport } from "../promises/tracker.js"
|
|
5
|
+
import { calculateQualityScore } from "../quality/scorer.js"
|
|
6
|
+
import { readFileSync, writeFileSync, existsSync, mkdirSync } from "fs"
|
|
7
|
+
import { join, dirname } from "path"
|
|
8
|
+
|
|
9
|
+
export interface SessionHandoff {
|
|
10
|
+
project_id: string
|
|
11
|
+
last_session: string
|
|
12
|
+
active_changes: ChangeNode[]
|
|
13
|
+
pending_promises: SpecPromise[]
|
|
14
|
+
quality_score: number
|
|
15
|
+
recent_decisions: DecisionNode[]
|
|
16
|
+
blocked_items: AnyNode[]
|
|
17
|
+
summary: string
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const SESSION_FILE = ".sdd/sessions/latest.json"
|
|
21
|
+
|
|
22
|
+
export interface HandoffOptions {
|
|
23
|
+
/** Skip quality score calculation (faster handoff). */
|
|
24
|
+
skipQualityCheck?: boolean
|
|
25
|
+
/** Cached quality score to reuse. */
|
|
26
|
+
qualityCache?: { score: number; timestamp: number }
|
|
27
|
+
/** Max age in ms for quality cache (default: 60000). */
|
|
28
|
+
qualityCacheMaxAge?: number
|
|
29
|
+
/** Skip cycle detection in graph health (DFS O(V+E)). */
|
|
30
|
+
skipCycleDetection?: boolean
|
|
31
|
+
/** Only analyze these node types in health check. */
|
|
32
|
+
focusNodeTypes?: string[]
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function generateHandoff(
|
|
36
|
+
graph: KnowledgeGraph,
|
|
37
|
+
projectDir: string,
|
|
38
|
+
options?: HandoffOptions,
|
|
39
|
+
): SessionHandoff {
|
|
40
|
+
// Auto-archive stale changes (>14 days without activity)
|
|
41
|
+
autoArchiveStaleChanges(graph)
|
|
42
|
+
|
|
43
|
+
const activeChanges = getPendingChanges(graph)
|
|
44
|
+
|
|
45
|
+
const promiseReport = getPromiseReport(graph)
|
|
46
|
+
const pendingPromises = promiseReport.promises.filter((p) => p.status === "pending")
|
|
47
|
+
|
|
48
|
+
let qualityScore = 0
|
|
49
|
+
if (!options?.skipQualityCheck) {
|
|
50
|
+
try {
|
|
51
|
+
const cacheMaxAge = options?.qualityCacheMaxAge ?? 60000
|
|
52
|
+
const cached = options?.qualityCache
|
|
53
|
+
if (cached && Date.now() - cached.timestamp < cacheMaxAge) {
|
|
54
|
+
qualityScore = cached.score
|
|
55
|
+
} else {
|
|
56
|
+
const quality = calculateQualityScore(graph, projectDir)
|
|
57
|
+
qualityScore = quality.score
|
|
58
|
+
if (options?.qualityCache) {
|
|
59
|
+
options.qualityCache.score = qualityScore
|
|
60
|
+
options.qualityCache.timestamp = Date.now()
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
} catch {
|
|
64
|
+
qualityScore = 0
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const recentDecisions = getNodesByType<DecisionNode>(graph, "decision")
|
|
69
|
+
.sort((a, b) => b.created_at.localeCompare(a.created_at))
|
|
70
|
+
.slice(0, 5)
|
|
71
|
+
|
|
72
|
+
const blockedItems = graph.nodes.filter((n) => n.status === "BLOCKED")
|
|
73
|
+
|
|
74
|
+
const summary = buildSummary(graph, activeChanges, pendingPromises, qualityScore, blockedItems)
|
|
75
|
+
|
|
76
|
+
// Compute graph health for proactive monitoring
|
|
77
|
+
const health = computeGraphHealth(graph, { skipCycleDetection: options?.skipCycleDetection, focusNodeTypes: options?.focusNodeTypes })
|
|
78
|
+
|
|
79
|
+
const handoff: SessionHandoff = {
|
|
80
|
+
project_id: graph.project_id,
|
|
81
|
+
last_session: new Date().toISOString(),
|
|
82
|
+
active_changes: activeChanges,
|
|
83
|
+
pending_promises: pendingPromises.slice(0, 10),
|
|
84
|
+
quality_score: qualityScore,
|
|
85
|
+
recent_decisions: recentDecisions,
|
|
86
|
+
blocked_items: blockedItems,
|
|
87
|
+
summary,
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Attach health data (not part of the interface but used in formatting)
|
|
91
|
+
;(handoff as any).health = health
|
|
92
|
+
|
|
93
|
+
return handoff
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Auto-archive changes that have been PROPOSED/APPROVED/DRAFT for >14 days.
|
|
98
|
+
* Marks them as DEPRECATED to keep the graph clean.
|
|
99
|
+
*/
|
|
100
|
+
function autoArchiveStaleChanges(graph: KnowledgeGraph): void {
|
|
101
|
+
const now = Date.now()
|
|
102
|
+
const STALE_THRESHOLD = 14 * 24 * 60 * 60 * 1000 // 14 days
|
|
103
|
+
let archivedCount = 0
|
|
104
|
+
|
|
105
|
+
for (const node of graph.nodes) {
|
|
106
|
+
if (node.type !== "change") continue
|
|
107
|
+
const change = node as ChangeNode
|
|
108
|
+
if (!["PROPOSED", "APPROVED", "DRAFT"].includes(change.status)) continue
|
|
109
|
+
|
|
110
|
+
const age = now - new Date(change.created_at).getTime()
|
|
111
|
+
if (age > STALE_THRESHOLD) {
|
|
112
|
+
change.status = "DEPRECATED"
|
|
113
|
+
change.updated_at = new Date().toISOString()
|
|
114
|
+
change.metadata = {
|
|
115
|
+
...change.metadata,
|
|
116
|
+
auto_archived: true,
|
|
117
|
+
archived_reason: `Auto-archived: pending for ${Math.floor(age / (24 * 60 * 60 * 1000))} days`,
|
|
118
|
+
}
|
|
119
|
+
archivedCount++
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (archivedCount > 0) {
|
|
124
|
+
graph.metadata.updated_at = new Date().toISOString()
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function buildSummary(
|
|
129
|
+
graph: KnowledgeGraph,
|
|
130
|
+
activeChanges: ChangeNode[],
|
|
131
|
+
pendingPromises: SpecPromise[],
|
|
132
|
+
qualityScore: number,
|
|
133
|
+
blockedItems: AnyNode[],
|
|
134
|
+
): string {
|
|
135
|
+
const parts: string[] = []
|
|
136
|
+
|
|
137
|
+
parts.push(`Project "${graph.project_id}" has ${graph.nodes.length} nodes and ${graph.relationships.length} relationships.`)
|
|
138
|
+
|
|
139
|
+
if (activeChanges.length > 0) {
|
|
140
|
+
parts.push(`${activeChanges.length} active change(s): ${activeChanges.map((c) => c.id).join(", ")}.`)
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (pendingPromises.length > 0) {
|
|
144
|
+
parts.push(`${pendingPromises.length} pending promises to fulfill.`)
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (blockedItems.length > 0) {
|
|
148
|
+
parts.push(`${blockedItems.length} blocked item(s) require attention.`)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const qualityPercent = (qualityScore * 100).toFixed(0)
|
|
152
|
+
parts.push(`Quality score: ${qualityPercent}%.`)
|
|
153
|
+
|
|
154
|
+
return parts.join(" ")
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Compute graph health indicators for proactive monitoring.
|
|
159
|
+
*/
|
|
160
|
+
export interface GraphHealth {
|
|
161
|
+
staleChanges: number
|
|
162
|
+
staleChangeIds: string[]
|
|
163
|
+
cyclesDetected: number
|
|
164
|
+
godNodes: Array<{ id: string; name: string; relCount: number }>
|
|
165
|
+
orphanChanges: number
|
|
166
|
+
draftEndpoints: number
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export interface GraphHealthOptions {
|
|
170
|
+
/** Skip cycle detection (DFS O(V+E)). */
|
|
171
|
+
skipCycleDetection?: boolean
|
|
172
|
+
/** Only check these node types for god nodes and orphans. */
|
|
173
|
+
focusNodeTypes?: string[]
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export function computeGraphHealth(graph: KnowledgeGraph, options?: GraphHealthOptions): GraphHealth {
|
|
177
|
+
const now = Date.now()
|
|
178
|
+
const STALE_DAYS = 7
|
|
179
|
+
const GOD_THRESHOLD = Math.max(50, graph.nodes.length * 0.25)
|
|
180
|
+
|
|
181
|
+
// Stale changes (PROPOSED/APPROVED for >7 days)
|
|
182
|
+
const staleChanges: string[] = []
|
|
183
|
+
const allChanges = graph.nodes.filter((n) => n.type === "change") as ChangeNode[]
|
|
184
|
+
for (const change of allChanges) {
|
|
185
|
+
if (["PROPOSED", "APPROVED", "DRAFT"].includes(change.status)) {
|
|
186
|
+
const age = now - new Date(change.created_at).getTime()
|
|
187
|
+
if (age > STALE_DAYS * 24 * 60 * 60 * 1000) {
|
|
188
|
+
staleChanges.push(change.id)
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// Cycles detection (simplified) — skippable
|
|
194
|
+
let cyclesDetected = 0
|
|
195
|
+
if (!options?.skipCycleDetection) {
|
|
196
|
+
const adjList = new Map<string, string[]>()
|
|
197
|
+
for (const rel of graph.relationships) {
|
|
198
|
+
if (!adjList.has(rel.from)) adjList.set(rel.from, [])
|
|
199
|
+
adjList.get(rel.from)!.push(rel.to)
|
|
200
|
+
}
|
|
201
|
+
const visitedGlobal = new Set<string>()
|
|
202
|
+
const inStack = new Set<string>()
|
|
203
|
+
|
|
204
|
+
function dfsCycle(nodeId: string): void {
|
|
205
|
+
if (inStack.has(nodeId)) { cyclesDetected++; return }
|
|
206
|
+
if (visitedGlobal.has(nodeId)) return
|
|
207
|
+
visitedGlobal.add(nodeId)
|
|
208
|
+
inStack.add(nodeId)
|
|
209
|
+
for (const neighbor of adjList.get(nodeId) || []) {
|
|
210
|
+
dfsCycle(neighbor)
|
|
211
|
+
}
|
|
212
|
+
inStack.delete(nodeId)
|
|
213
|
+
}
|
|
214
|
+
for (const node of graph.nodes) {
|
|
215
|
+
if (!visitedGlobal.has(node.id)) dfsCycle(node.id)
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// God nodes — optionally filtered by focusNodeTypes
|
|
220
|
+
const relCounts = new Map<string, number>()
|
|
221
|
+
for (const rel of graph.relationships) {
|
|
222
|
+
relCounts.set(rel.from, (relCounts.get(rel.from) || 0) + 1)
|
|
223
|
+
relCounts.set(rel.to, (relCounts.get(rel.to) || 0) + 1)
|
|
224
|
+
}
|
|
225
|
+
const godNodes: Array<{ id: string; name: string; relCount: number }> = []
|
|
226
|
+
for (const [nodeId, count] of relCounts.entries()) {
|
|
227
|
+
if (count > GOD_THRESHOLD) {
|
|
228
|
+
const node = graph.nodes.find((n) => n.id === nodeId)
|
|
229
|
+
if (node && node.type !== "project") {
|
|
230
|
+
if (!options?.focusNodeTypes || options.focusNodeTypes.includes(node.type)) {
|
|
231
|
+
godNodes.push({ id: nodeId, name: node.name, relCount: count })
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// Orphan changes (CHG nodes with no relationships)
|
|
238
|
+
let orphanChanges = 0
|
|
239
|
+
for (const change of allChanges) {
|
|
240
|
+
const hasRels = graph.relationships.some(
|
|
241
|
+
(r) => r.from === change.id || r.to === change.id
|
|
242
|
+
)
|
|
243
|
+
if (!hasRels) orphanChanges++
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// DRAFT endpoints
|
|
247
|
+
const draftEndpoints = graph.nodes.filter(
|
|
248
|
+
(n) => n.type === "endpoint" && n.status === "DRAFT"
|
|
249
|
+
).length
|
|
250
|
+
|
|
251
|
+
return {
|
|
252
|
+
staleChanges: staleChanges.length,
|
|
253
|
+
staleChangeIds: staleChanges,
|
|
254
|
+
cyclesDetected,
|
|
255
|
+
godNodes,
|
|
256
|
+
orphanChanges,
|
|
257
|
+
draftEndpoints,
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function formatHealthReport(health: GraphHealth): string {
|
|
262
|
+
const issues: string[] = []
|
|
263
|
+
|
|
264
|
+
if (health.staleChanges > 0) {
|
|
265
|
+
issues.push(`🔴 ${health.staleChanges} stale change(s) (>7 days without activity): ${health.staleChangeIds.slice(0, 5).join(", ")}${health.staleChanges > 5 ? "..." : ""}`)
|
|
266
|
+
}
|
|
267
|
+
if (health.cyclesDetected > 0) {
|
|
268
|
+
issues.push(`🔴 ${health.cyclesDetected} cycle(s) detected in graph traversal`)
|
|
269
|
+
}
|
|
270
|
+
if (health.godNodes.length > 0) {
|
|
271
|
+
for (const gn of health.godNodes.slice(0, 3)) {
|
|
272
|
+
issues.push(`🟡 God node: "${gn.name}" (${gn.relCount} relationships) — consider splitting`)
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
if (health.orphanChanges > 0) {
|
|
276
|
+
issues.push(`🟡 ${health.orphanChanges} orphan change node(s) with no relationships`)
|
|
277
|
+
}
|
|
278
|
+
if (health.draftEndpoints > 0) {
|
|
279
|
+
issues.push(`🔵 ${health.draftEndpoints} endpoint(s) still in DRAFT status`)
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
if (issues.length === 0) {
|
|
283
|
+
return "✅ Graph health: No issues detected."
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
return ["## ⚠️ Graph Health Issues", "", ...issues].join("\n")
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
export function formatHandoffPack(handoff: SessionHandoff): string {
|
|
290
|
+
const lines = [
|
|
291
|
+
"## SDD Session Handoff",
|
|
292
|
+
`**Project:** ${handoff.project_id}`,
|
|
293
|
+
`**Last Session:** ${handoff.last_session}`,
|
|
294
|
+
`**Quality Score:** ${(handoff.quality_score * 100).toFixed(1)}%`,
|
|
295
|
+
"",
|
|
296
|
+
handoff.summary,
|
|
297
|
+
]
|
|
298
|
+
|
|
299
|
+
// Include graph health report if available
|
|
300
|
+
if ((handoff as any).health) {
|
|
301
|
+
lines.push("")
|
|
302
|
+
lines.push(formatHealthReport((handoff as any).health))
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
if (handoff.active_changes.length > 0) {
|
|
306
|
+
lines.push("\n### Active Changes")
|
|
307
|
+
for (const c of handoff.active_changes) {
|
|
308
|
+
lines.push(`- **${c.id}** (${c.status}): ${c.metadata.title}`)
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
if (handoff.blocked_items.length > 0) {
|
|
313
|
+
lines.push("\n### Blocked Items")
|
|
314
|
+
for (const item of handoff.blocked_items) {
|
|
315
|
+
lines.push(`- **${item.id}** (${item.type}): ${item.name}`)
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
if (handoff.recent_decisions.length > 0) {
|
|
320
|
+
lines.push("\n### Recent Decisions")
|
|
321
|
+
for (const d of handoff.recent_decisions) {
|
|
322
|
+
lines.push(`- **${d.id}**: ${d.metadata.decision}`)
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
if (handoff.pending_promises.length > 0) {
|
|
327
|
+
lines.push("\n### Pending Promises (top 10)")
|
|
328
|
+
for (const p of handoff.pending_promises) {
|
|
329
|
+
lines.push(`- **${p.id}**: ${p.description}`)
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
return lines.join("\n")
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
export function saveSessionLog(projectDir: string, action: string): void {
|
|
337
|
+
const path = join(projectDir, SESSION_FILE)
|
|
338
|
+
const dir = dirname(path)
|
|
339
|
+
if (!existsSync(dir)) mkdirSync(dir, { recursive: true })
|
|
340
|
+
|
|
341
|
+
let log: Array<{ timestamp: string; action: string }> = []
|
|
342
|
+
if (existsSync(path)) {
|
|
343
|
+
try {
|
|
344
|
+
log = JSON.parse(readFileSync(path, "utf-8"))
|
|
345
|
+
} catch {
|
|
346
|
+
log = []
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
log.push({ timestamp: new Date().toISOString(), action })
|
|
351
|
+
if (log.length > 100) log.splice(0, log.length - 100)
|
|
352
|
+
|
|
353
|
+
writeFileSync(path, JSON.stringify(log, null, 2), "utf-8")
|
|
354
|
+
}
|