scene-capability-engine 3.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/CHANGELOG.md +2513 -0
- package/LICENSE +21 -0
- package/README.md +765 -0
- package/README.zh.md +630 -0
- package/bin/kiro-spec-engine.js +796 -0
- package/bin/kse.js +3 -0
- package/bin/sce.js +3 -0
- package/bin/sco.js +3 -0
- package/docs/331-poc-adaptation-roadmap.md +156 -0
- package/docs/331-poc-dual-track-integration-guide.md +120 -0
- package/docs/331-poc-weekly-delivery-checklist.md +52 -0
- package/docs/OFFLINE_INSTALL.md +96 -0
- package/docs/README.md +279 -0
- package/docs/adopt-migration-guide.md +599 -0
- package/docs/adoption-guide.md +616 -0
- package/docs/agent-hooks-analysis.md +815 -0
- package/docs/architecture.md +733 -0
- package/docs/articles/ai-driven-development-philosophy-and-practice-review.md +208 -0
- package/docs/articles/ai-driven-development-philosophy-and-practice.en.md +459 -0
- package/docs/articles/ai-driven-development-philosophy-and-practice.md +492 -0
- package/docs/autonomous-control-guide.md +851 -0
- package/docs/command-reference.md +1368 -0
- package/docs/community.md +115 -0
- package/docs/cross-tool-guide.md +555 -0
- package/docs/developer-guide.md +619 -0
- package/docs/document-governance.md +865 -0
- package/docs/environment-management-guide.md +526 -0
- package/docs/examples/add-export-command/design.md +194 -0
- package/docs/examples/add-export-command/requirements.md +110 -0
- package/docs/examples/add-export-command/tasks.md +88 -0
- package/docs/examples/add-rest-api/design.md +855 -0
- package/docs/examples/add-rest-api/requirements.md +323 -0
- package/docs/examples/add-rest-api/tasks.md +355 -0
- package/docs/examples/add-user-dashboard/design.md +192 -0
- package/docs/examples/add-user-dashboard/requirements.md +143 -0
- package/docs/examples/add-user-dashboard/tasks.md +91 -0
- package/docs/faq.md +697 -0
- package/docs/handoffs/evidence/ontology/moqui-template-baseline-2026-02-17-232922.json +156 -0
- package/docs/handoffs/evidence/ontology/moqui-template-baseline-2026-02-17-232922.md +24 -0
- package/docs/images/wechat-qr.png +0 -0
- package/docs/integration-modes.md +529 -0
- package/docs/integration-philosophy.md +313 -0
- package/docs/knowledge-management-guide.md +263 -0
- package/docs/manual-workflows-guide.md +418 -0
- package/docs/moqui-capability-matrix.md +73 -0
- package/docs/moqui-template-core-library-playbook.md +109 -0
- package/docs/multi-agent-coordination-guide.md +553 -0
- package/docs/multi-repo-management-guide.md +1344 -0
- package/docs/quick-start-with-ai-tools.md +375 -0
- package/docs/quick-start.md +146 -0
- package/docs/release-checklist.md +121 -0
- package/docs/releases/README.md +13 -0
- package/docs/releases/v1.46.2-validation.md +45 -0
- package/docs/releases/v1.46.2.md +50 -0
- package/docs/scene-runtime-guide.md +347 -0
- package/docs/spec-collaboration-guide.md +369 -0
- package/docs/spec-locking-guide.md +225 -0
- package/docs/spec-numbering-guide.md +348 -0
- package/docs/spec-workflow.md +519 -0
- package/docs/steering-strategy-guide.md +196 -0
- package/docs/team-collaboration-guide.md +465 -0
- package/docs/testing-strategy.md +272 -0
- package/docs/tools/claude-guide.md +654 -0
- package/docs/tools/cursor-guide.md +706 -0
- package/docs/tools/generic-guide.md +446 -0
- package/docs/tools/kiro-guide.md +308 -0
- package/docs/tools/vscode-guide.md +445 -0
- package/docs/tools/windsurf-guide.md +391 -0
- package/docs/troubleshooting.md +1135 -0
- package/docs/upgrade-guide.md +639 -0
- package/docs/value-observability-guide.md +127 -0
- package/docs/zh/README.md +341 -0
- package/docs/zh/quick-start.md +764 -0
- package/docs/zh/release-checklist.md +121 -0
- package/docs/zh/releases/README.md +13 -0
- package/docs/zh/releases/v1.46.2-validation.md +45 -0
- package/docs/zh/releases/v1.46.2.md +50 -0
- package/docs/zh/spec-numbering-guide.md +348 -0
- package/docs/zh/tools/claude-guide.md +349 -0
- package/docs/zh/tools/cursor-guide.md +281 -0
- package/docs/zh/tools/generic-guide.md +499 -0
- package/docs/zh/tools/kiro-guide.md +342 -0
- package/docs/zh/tools/vscode-guide.md +449 -0
- package/docs/zh/tools/windsurf-guide.md +378 -0
- package/docs/zh/value-observability-guide.md +127 -0
- package/docs//344/272/244/344/273/230/346/270/205/345/215/225.md +75 -0
- package/lib/adoption/adoption-logger.js +487 -0
- package/lib/adoption/adoption-strategy.js +538 -0
- package/lib/adoption/backup-manager.js +420 -0
- package/lib/adoption/conflict-resolver.js +410 -0
- package/lib/adoption/detection-engine.js +275 -0
- package/lib/adoption/diff-viewer.js +226 -0
- package/lib/adoption/error-formatter.js +509 -0
- package/lib/adoption/file-classifier.js +385 -0
- package/lib/adoption/progress-reporter.js +534 -0
- package/lib/adoption/smart-orchestrator.js +470 -0
- package/lib/adoption/strategy-selector.js +218 -0
- package/lib/adoption/summary-generator.js +493 -0
- package/lib/adoption/template-sync.js +605 -0
- package/lib/auto/autonomous-engine.js +485 -0
- package/lib/auto/checkpoint-manager.js +300 -0
- package/lib/auto/close-loop-runner.js +2476 -0
- package/lib/auto/config-schema.js +176 -0
- package/lib/auto/decision-engine.js +344 -0
- package/lib/auto/error-recovery-manager.js +580 -0
- package/lib/auto/goal-decomposer.js +278 -0
- package/lib/auto/progress-tracker.js +502 -0
- package/lib/auto/safety-manager.js +186 -0
- package/lib/auto/semantic-decomposer.js +137 -0
- package/lib/auto/state-manager.js +126 -0
- package/lib/auto/task-queue-manager.js +340 -0
- package/lib/backup/backup-system.js +372 -0
- package/lib/backup/selective-backup.js +207 -0
- package/lib/collab/agent-registry.js +240 -0
- package/lib/collab/collab-manager.js +285 -0
- package/lib/collab/contract-manager.js +320 -0
- package/lib/collab/coordinator.js +370 -0
- package/lib/collab/dependency-manager.js +280 -0
- package/lib/collab/index.js +20 -0
- package/lib/collab/integration-manager.js +202 -0
- package/lib/collab/merge-coordinator.js +252 -0
- package/lib/collab/metadata-manager.js +233 -0
- package/lib/collab/multi-agent-config.js +120 -0
- package/lib/collab/spec-lifecycle-manager.js +304 -0
- package/lib/collab/sync-barrier.js +88 -0
- package/lib/collab/visualizer.js +208 -0
- package/lib/commands/adopt.js +749 -0
- package/lib/commands/auto.js +19559 -0
- package/lib/commands/collab.js +275 -0
- package/lib/commands/context.js +99 -0
- package/lib/commands/docs.js +808 -0
- package/lib/commands/doctor.js +273 -0
- package/lib/commands/env.js +420 -0
- package/lib/commands/knowledge.js +309 -0
- package/lib/commands/lock.js +235 -0
- package/lib/commands/ops.js +409 -0
- package/lib/commands/orchestrate.js +446 -0
- package/lib/commands/prompt.js +105 -0
- package/lib/commands/repo.js +118 -0
- package/lib/commands/rollback.js +219 -0
- package/lib/commands/scene.js +15549 -0
- package/lib/commands/spec-bootstrap.js +147 -0
- package/lib/commands/spec-gate.js +157 -0
- package/lib/commands/spec-pipeline.js +205 -0
- package/lib/commands/status.js +321 -0
- package/lib/commands/task.js +199 -0
- package/lib/commands/templates.js +654 -0
- package/lib/commands/upgrade.js +231 -0
- package/lib/commands/value.js +569 -0
- package/lib/commands/watch.js +684 -0
- package/lib/commands/workflows.js +240 -0
- package/lib/commands/workspace-multi.js +325 -0
- package/lib/commands/workspace.js +189 -0
- package/lib/context/context-exporter.js +378 -0
- package/lib/context/prompt-generator.js +482 -0
- package/lib/data/moqui-capability-lexicon.json +45 -0
- package/lib/environment/backup-system.js +189 -0
- package/lib/environment/environment-manager.js +379 -0
- package/lib/environment/environment-registry.js +168 -0
- package/lib/gitignore/gitignore-backup.js +229 -0
- package/lib/gitignore/gitignore-detector.js +239 -0
- package/lib/gitignore/gitignore-integration.js +267 -0
- package/lib/gitignore/gitignore-transformer.js +193 -0
- package/lib/gitignore/layered-rules-template.js +42 -0
- package/lib/governance/archive-tool.js +284 -0
- package/lib/governance/cleanup-tool.js +237 -0
- package/lib/governance/config-manager.js +186 -0
- package/lib/governance/diagnostic-engine.js +271 -0
- package/lib/governance/doc-reference-checker.js +200 -0
- package/lib/governance/execution-logger.js +243 -0
- package/lib/governance/file-scanner.js +285 -0
- package/lib/governance/hooks-manager.js +333 -0
- package/lib/governance/reporter.js +337 -0
- package/lib/governance/validation-engine.js +181 -0
- package/lib/i18n.js +79 -0
- package/lib/knowledge/entry-manager.js +208 -0
- package/lib/knowledge/index-manager.js +261 -0
- package/lib/knowledge/knowledge-manager.js +273 -0
- package/lib/knowledge/template-manager.js +191 -0
- package/lib/lock/index.js +21 -0
- package/lib/lock/lock-file.js +192 -0
- package/lib/lock/lock-manager.js +321 -0
- package/lib/lock/machine-identifier.js +135 -0
- package/lib/lock/steering-file-lock.js +207 -0
- package/lib/lock/task-lock-manager.js +345 -0
- package/lib/operations/audit-logger.js +293 -0
- package/lib/operations/feedback-manager.js +1147 -0
- package/lib/operations/index.js +23 -0
- package/lib/operations/models/index.js +170 -0
- package/lib/operations/operations-manager.js +151 -0
- package/lib/operations/operations-validator.js +280 -0
- package/lib/operations/permission-manager.js +354 -0
- package/lib/operations/template-loader.js +143 -0
- package/lib/orchestrator/agent-spawner.js +629 -0
- package/lib/orchestrator/bootstrap-prompt-builder.js +236 -0
- package/lib/orchestrator/index.js +19 -0
- package/lib/orchestrator/orchestration-engine.js +1270 -0
- package/lib/orchestrator/orchestrator-config.js +173 -0
- package/lib/orchestrator/status-monitor.js +591 -0
- package/lib/python-checker.js +209 -0
- package/lib/repo/config-manager.js +580 -0
- package/lib/repo/errors/config-error.js +13 -0
- package/lib/repo/errors/git-error.js +15 -0
- package/lib/repo/errors/repo-error.js +14 -0
- package/lib/repo/git-operations.js +181 -0
- package/lib/repo/handlers/.gitkeep +1 -0
- package/lib/repo/handlers/exec-handler.js +155 -0
- package/lib/repo/handlers/health-handler.js +169 -0
- package/lib/repo/handlers/init-handler.js +197 -0
- package/lib/repo/handlers/status-handler.js +176 -0
- package/lib/repo/output-formatter.js +184 -0
- package/lib/repo/path-resolver.js +178 -0
- package/lib/repo/repo-manager.js +514 -0
- package/lib/scene-runtime/audit-emitter.js +59 -0
- package/lib/scene-runtime/binding-plugin-loader.js +351 -0
- package/lib/scene-runtime/binding-registry.js +349 -0
- package/lib/scene-runtime/eval-bridge.js +44 -0
- package/lib/scene-runtime/index.js +19 -0
- package/lib/scene-runtime/moqui-adapter.js +620 -0
- package/lib/scene-runtime/moqui-client.js +606 -0
- package/lib/scene-runtime/moqui-extractor.js +2029 -0
- package/lib/scene-runtime/plan-compiler.js +208 -0
- package/lib/scene-runtime/policy-gate.js +58 -0
- package/lib/scene-runtime/runtime-executor.js +358 -0
- package/lib/scene-runtime/scene-loader.js +96 -0
- package/lib/scene-runtime/scene-ontology.js +959 -0
- package/lib/scene-runtime/scene-template-linter.js +852 -0
- package/lib/scene-runtime/templates/scene-template-erp-query-v0.1.yaml +28 -0
- package/lib/scene-runtime/templates/scene-template-hybrid-shadow-v0.1.yaml +34 -0
- package/lib/spec/bootstrap/context-collector.js +48 -0
- package/lib/spec/bootstrap/draft-generator.js +158 -0
- package/lib/spec/bootstrap/questionnaire-engine.js +70 -0
- package/lib/spec/bootstrap/trace-emitter.js +59 -0
- package/lib/spec/multi-spec-orchestrate.js +93 -0
- package/lib/spec/pipeline/constants.js +6 -0
- package/lib/spec/pipeline/stage-adapters.js +118 -0
- package/lib/spec/pipeline/stage-runner.js +146 -0
- package/lib/spec/pipeline/state-store.js +119 -0
- package/lib/spec-gate/engine/gate-engine.js +165 -0
- package/lib/spec-gate/policy/default-policy.js +22 -0
- package/lib/spec-gate/policy/policy-loader.js +103 -0
- package/lib/spec-gate/result-emitter.js +81 -0
- package/lib/spec-gate/rules/default-rules.js +156 -0
- package/lib/spec-gate/rules/rule-registry.js +51 -0
- package/lib/steering/adoption-config.js +164 -0
- package/lib/steering/compliance-auto-fixer.js +204 -0
- package/lib/steering/compliance-cache.js +99 -0
- package/lib/steering/compliance-error-reporter.js +70 -0
- package/lib/steering/context-sync-manager.js +273 -0
- package/lib/steering/index.js +92 -0
- package/lib/steering/spec-steering.js +230 -0
- package/lib/steering/steering-compliance-checker.js +73 -0
- package/lib/steering/steering-loader.js +144 -0
- package/lib/steering/steering-manager.js +289 -0
- package/lib/task/index.js +12 -0
- package/lib/task/task-claimer.js +489 -0
- package/lib/task/task-status-store.js +418 -0
- package/lib/templates/cache-manager.js +440 -0
- package/lib/templates/content-generalizer.js +247 -0
- package/lib/templates/frontmatter-generator.js +128 -0
- package/lib/templates/git-handler.js +471 -0
- package/lib/templates/metadata-collector.js +328 -0
- package/lib/templates/path-utils.js +144 -0
- package/lib/templates/registry-parser.js +505 -0
- package/lib/templates/spec-reader.js +216 -0
- package/lib/templates/template-applicator.js +249 -0
- package/lib/templates/template-creator.js +256 -0
- package/lib/templates/template-error.js +143 -0
- package/lib/templates/template-exporter.js +502 -0
- package/lib/templates/template-manager.js +782 -0
- package/lib/templates/template-validator.js +361 -0
- package/lib/upgrade/migration-engine.js +382 -0
- package/lib/upgrade/migrations/.gitkeep +52 -0
- package/lib/upgrade/migrations/1.0.0-to-1.1.0.js +78 -0
- package/lib/utils/file-diff.js +177 -0
- package/lib/utils/fs-utils.js +274 -0
- package/lib/utils/tool-detector.js +383 -0
- package/lib/utils/validation.js +324 -0
- package/lib/value/gate-summary-emitter.js +99 -0
- package/lib/value/metric-contract-loader.js +210 -0
- package/lib/value/risk-evaluator.js +117 -0
- package/lib/value/weekly-snapshot-builder.js +61 -0
- package/lib/version/version-checker.js +156 -0
- package/lib/version/version-manager.js +327 -0
- package/lib/watch/action-executor.js +458 -0
- package/lib/watch/event-debouncer.js +323 -0
- package/lib/watch/execution-logger.js +550 -0
- package/lib/watch/file-watcher.js +499 -0
- package/lib/watch/presets.js +266 -0
- package/lib/watch/watch-manager.js +533 -0
- package/lib/workspace/multi/global-config.js +150 -0
- package/lib/workspace/multi/index.js +22 -0
- package/lib/workspace/multi/path-utils.js +173 -0
- package/lib/workspace/multi/workspace-context-resolver.js +244 -0
- package/lib/workspace/multi/workspace-registry.js +196 -0
- package/lib/workspace/multi/workspace-state-manager.js +537 -0
- package/lib/workspace/multi/workspace.js +90 -0
- package/lib/workspace/workspace-manager.js +370 -0
- package/lib/workspace/workspace-sync.js +356 -0
- package/locales/en.json +114 -0
- package/locales/zh.json +114 -0
- package/package.json +102 -0
- package/template/.kiro/README.md +247 -0
- package/template/.kiro/hooks/check-spec-on-create.kiro.hook +17 -0
- package/template/.kiro/hooks/run-tests-on-save.kiro.hook +13 -0
- package/template/.kiro/hooks/sync-tasks-on-edit.kiro.hook +16 -0
- package/template/.kiro/specs/SPEC_WORKFLOW_GUIDE.md +134 -0
- package/template/.kiro/steering/CORE_PRINCIPLES.md +133 -0
- package/template/.kiro/steering/CURRENT_CONTEXT.md +30 -0
- package/template/.kiro/steering/ENVIRONMENT.md +35 -0
- package/template/.kiro/steering/RULES_GUIDE.md +46 -0
- package/template/.kiro/templates/operations/default/change-impact.md +112 -0
- package/template/.kiro/templates/operations/default/deployment.md +91 -0
- package/template/.kiro/templates/operations/default/feedback-response.md +269 -0
- package/template/.kiro/templates/operations/default/migration-plan.md +172 -0
- package/template/.kiro/templates/operations/default/monitoring.md +135 -0
- package/template/.kiro/templates/operations/default/operations.md +135 -0
- package/template/.kiro/templates/operations/default/rollback.md +143 -0
- package/template/.kiro/templates/operations/default/tools.yaml +364 -0
- package/template/.kiro/templates/operations/default/troubleshooting.md +123 -0
- package/template/.kiro/tools/backup_manager.py +295 -0
- package/template/.kiro/tools/configuration_manager.py +218 -0
- package/template/.kiro/tools/document_evaluator.py +550 -0
- package/template/.kiro/tools/enhancement_logger.py +168 -0
- package/template/.kiro/tools/error_handler.py +335 -0
- package/template/.kiro/tools/improvement_identifier.py +444 -0
- package/template/.kiro/tools/modification_applicator.py +737 -0
- package/template/.kiro/tools/quality_gate_enforcer.py +207 -0
- package/template/.kiro/tools/quality_scorer.py +305 -0
- package/template/.kiro/tools/report_generator.py +154 -0
- package/template/.kiro/tools/ultrawork_enhancer.py +676 -0
- package/template/.kiro/tools/ultrawork_enhancer_refactored.py +0 -0
- package/template/.kiro/tools/ultrawork_enhancer_v2.py +463 -0
- package/template/.kiro/tools/ultrawork_enhancer_v3.py +606 -0
- package/template/.kiro/tools/workflow_quality_gate.py +100 -0
- package/template/README.md +111 -0
|
@@ -0,0 +1,493 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Summary Generator
|
|
3
|
+
*
|
|
4
|
+
* Generates comprehensive adoption summaries with rollback instructions.
|
|
5
|
+
* Aggregates data from the adoption process and formats it into structured summaries.
|
|
6
|
+
*
|
|
7
|
+
* Core Responsibilities:
|
|
8
|
+
* - Aggregate adoption process data
|
|
9
|
+
* - Generate structured summary objects
|
|
10
|
+
* - Provide rollback instructions
|
|
11
|
+
* - Suggest next steps
|
|
12
|
+
* - Analyze adoption results
|
|
13
|
+
*
|
|
14
|
+
* Requirements Traceability:
|
|
15
|
+
* - FR-2.3.2: Result summary
|
|
16
|
+
*
|
|
17
|
+
* Design Traceability:
|
|
18
|
+
* - Summary Generator component
|
|
19
|
+
* - Summary structure and display specifications
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
const path = require('path');
|
|
23
|
+
const chalk = require('chalk');
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Summary Generator for adoption process
|
|
27
|
+
*/
|
|
28
|
+
class SummaryGenerator {
|
|
29
|
+
constructor() {
|
|
30
|
+
// Summary data will be built up during adoption
|
|
31
|
+
this.summaryData = {
|
|
32
|
+
mode: null,
|
|
33
|
+
backup: null,
|
|
34
|
+
changes: {
|
|
35
|
+
created: [],
|
|
36
|
+
updated: [],
|
|
37
|
+
deleted: [],
|
|
38
|
+
preserved: []
|
|
39
|
+
},
|
|
40
|
+
warnings: [],
|
|
41
|
+
errors: [],
|
|
42
|
+
metadata: {
|
|
43
|
+
startTime: null,
|
|
44
|
+
endTime: null,
|
|
45
|
+
duration: null
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Starts summary generation (records start time)
|
|
52
|
+
*/
|
|
53
|
+
start() {
|
|
54
|
+
this.summaryData.metadata.startTime = Date.now();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Sets the adoption mode
|
|
59
|
+
*
|
|
60
|
+
* @param {string} mode - Adoption mode (fresh, smart-adopt, smart-update, skip, warning)
|
|
61
|
+
*/
|
|
62
|
+
setMode(mode) {
|
|
63
|
+
this.summaryData.mode = mode;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Sets backup information
|
|
68
|
+
*
|
|
69
|
+
* @param {Object} backup - Backup result
|
|
70
|
+
* @param {string} backup.id - Backup ID
|
|
71
|
+
* @param {string} backup.location - Backup location
|
|
72
|
+
* @param {number} backup.filesCount - Number of files backed up
|
|
73
|
+
* @param {number} backup.totalSize - Total size in bytes
|
|
74
|
+
*/
|
|
75
|
+
setBackup(backup) {
|
|
76
|
+
this.summaryData.backup = {
|
|
77
|
+
id: backup.id,
|
|
78
|
+
location: backup.location,
|
|
79
|
+
filesCount: backup.filesCount || backup.filesBackedUp?.length || 0,
|
|
80
|
+
totalSize: backup.totalSize || 0
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Adds a file change to the summary
|
|
86
|
+
*
|
|
87
|
+
* @param {string} operation - Operation type: 'create', 'update', 'delete', 'preserve'
|
|
88
|
+
* @param {string} filePath - File path
|
|
89
|
+
*/
|
|
90
|
+
addFileChange(operation, filePath) {
|
|
91
|
+
const normalizedPath = this._normalizePath(filePath);
|
|
92
|
+
|
|
93
|
+
switch (operation) {
|
|
94
|
+
case 'create':
|
|
95
|
+
if (!this.summaryData.changes.created.includes(normalizedPath)) {
|
|
96
|
+
this.summaryData.changes.created.push(normalizedPath);
|
|
97
|
+
}
|
|
98
|
+
break;
|
|
99
|
+
case 'update':
|
|
100
|
+
if (!this.summaryData.changes.updated.includes(normalizedPath)) {
|
|
101
|
+
this.summaryData.changes.updated.push(normalizedPath);
|
|
102
|
+
}
|
|
103
|
+
break;
|
|
104
|
+
case 'delete':
|
|
105
|
+
if (!this.summaryData.changes.deleted.includes(normalizedPath)) {
|
|
106
|
+
this.summaryData.changes.deleted.push(normalizedPath);
|
|
107
|
+
}
|
|
108
|
+
break;
|
|
109
|
+
case 'preserve':
|
|
110
|
+
if (!this.summaryData.changes.preserved.includes(normalizedPath)) {
|
|
111
|
+
this.summaryData.changes.preserved.push(normalizedPath);
|
|
112
|
+
}
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Adds multiple file changes at once
|
|
119
|
+
*
|
|
120
|
+
* @param {string} operation - Operation type
|
|
121
|
+
* @param {string[]} filePaths - Array of file paths
|
|
122
|
+
*/
|
|
123
|
+
addFileChanges(operation, filePaths) {
|
|
124
|
+
filePaths.forEach(filePath => {
|
|
125
|
+
this.addFileChange(operation, filePath);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Adds a warning to the summary
|
|
131
|
+
*
|
|
132
|
+
* @param {string} warning - Warning message
|
|
133
|
+
*/
|
|
134
|
+
addWarning(warning) {
|
|
135
|
+
if (!this.summaryData.warnings.includes(warning)) {
|
|
136
|
+
this.summaryData.warnings.push(warning);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Adds an error to the summary
|
|
142
|
+
*
|
|
143
|
+
* @param {string} error - Error message
|
|
144
|
+
*/
|
|
145
|
+
addError(error) {
|
|
146
|
+
if (!this.summaryData.errors.includes(error)) {
|
|
147
|
+
this.summaryData.errors.push(error);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Completes summary generation (records end time)
|
|
153
|
+
*/
|
|
154
|
+
complete() {
|
|
155
|
+
this.summaryData.metadata.endTime = Date.now();
|
|
156
|
+
if (this.summaryData.metadata.startTime) {
|
|
157
|
+
this.summaryData.metadata.duration =
|
|
158
|
+
this.summaryData.metadata.endTime - this.summaryData.metadata.startTime;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Generates a comprehensive summary object
|
|
164
|
+
*
|
|
165
|
+
* @returns {Object} Complete adoption summary
|
|
166
|
+
*/
|
|
167
|
+
generateSummary() {
|
|
168
|
+
const summary = {
|
|
169
|
+
mode: this.summaryData.mode,
|
|
170
|
+
backup: this.summaryData.backup,
|
|
171
|
+
changes: {
|
|
172
|
+
created: [...this.summaryData.changes.created],
|
|
173
|
+
updated: [...this.summaryData.changes.updated],
|
|
174
|
+
deleted: [...this.summaryData.changes.deleted],
|
|
175
|
+
preserved: [...this.summaryData.changes.preserved],
|
|
176
|
+
total: this._getTotalChanges()
|
|
177
|
+
},
|
|
178
|
+
statistics: this._generateStatistics(),
|
|
179
|
+
rollback: this._generateRollbackInfo(),
|
|
180
|
+
nextSteps: this._generateNextSteps(),
|
|
181
|
+
warnings: [...this.summaryData.warnings],
|
|
182
|
+
errors: [...this.summaryData.errors],
|
|
183
|
+
metadata: {
|
|
184
|
+
...this.summaryData.metadata,
|
|
185
|
+
success: this.summaryData.errors.length === 0
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
return summary;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Generates a text-based summary for display
|
|
194
|
+
*
|
|
195
|
+
* @param {Object} options - Display options
|
|
196
|
+
* @param {boolean} options.verbose - Show detailed information
|
|
197
|
+
* @param {boolean} options.color - Use colored output
|
|
198
|
+
* @returns {string} Formatted summary text
|
|
199
|
+
*/
|
|
200
|
+
generateTextSummary(options = {}) {
|
|
201
|
+
const { verbose = false, color = true } = options;
|
|
202
|
+
const summary = this.generateSummary();
|
|
203
|
+
const lines = [];
|
|
204
|
+
|
|
205
|
+
// Header
|
|
206
|
+
if (summary.metadata.success) {
|
|
207
|
+
lines.push(color ? chalk.green('✅ Adoption completed successfully!') : '✅ Adoption completed successfully!');
|
|
208
|
+
} else {
|
|
209
|
+
lines.push(color ? chalk.red('❌ Adoption failed') : '❌ Adoption failed');
|
|
210
|
+
}
|
|
211
|
+
lines.push('');
|
|
212
|
+
|
|
213
|
+
// Summary section
|
|
214
|
+
lines.push(color ? chalk.blue('📊 Summary:') : '📊 Summary:');
|
|
215
|
+
lines.push(` Mode: ${this._getModeDisplayName(summary.mode)}`);
|
|
216
|
+
|
|
217
|
+
if (summary.backup) {
|
|
218
|
+
lines.push(` Backup: ${summary.backup.id}`);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// Individual file counts (for compatibility with tests)
|
|
222
|
+
if (summary.changes.updated.length > 0) {
|
|
223
|
+
lines.push(` Updated: ${summary.changes.updated.length} file(s)`);
|
|
224
|
+
}
|
|
225
|
+
if (summary.changes.created.length > 0) {
|
|
226
|
+
lines.push(` Created: ${summary.changes.created.length} file(s)`);
|
|
227
|
+
}
|
|
228
|
+
if (summary.changes.deleted.length > 0) {
|
|
229
|
+
lines.push(` Deleted: ${summary.changes.deleted.length} file(s)`);
|
|
230
|
+
}
|
|
231
|
+
if (summary.changes.preserved.length > 0) {
|
|
232
|
+
lines.push(` Preserved: ${summary.changes.preserved.length} file(s)`);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// Duration in verbose mode
|
|
236
|
+
if (verbose && summary.metadata.duration) {
|
|
237
|
+
lines.push(` Duration: ${this._formatDuration(summary.metadata.duration)}`);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
lines.push('');
|
|
241
|
+
|
|
242
|
+
// Updated files
|
|
243
|
+
if (summary.changes.updated.length > 0) {
|
|
244
|
+
lines.push(color ? chalk.blue('Updated files:') : 'Updated files:');
|
|
245
|
+
summary.changes.updated.forEach(file => {
|
|
246
|
+
lines.push(color ? chalk.green(` ✅ ${file}`) : ` ✅ ${file}`);
|
|
247
|
+
});
|
|
248
|
+
lines.push('');
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// Created files (verbose mode)
|
|
252
|
+
if (verbose && summary.changes.created.length > 0) {
|
|
253
|
+
lines.push(color ? chalk.blue('Created files:') : 'Created files:');
|
|
254
|
+
summary.changes.created.forEach(file => {
|
|
255
|
+
lines.push(color ? chalk.green(` ➕ ${file}`) : ` ➕ ${file}`);
|
|
256
|
+
});
|
|
257
|
+
lines.push('');
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// Preserved files
|
|
261
|
+
if (summary.changes.preserved.length > 0) {
|
|
262
|
+
lines.push(color ? chalk.gray('Preserved files:') : 'Preserved files:');
|
|
263
|
+
summary.changes.preserved.forEach(file => {
|
|
264
|
+
lines.push(color ? chalk.gray(` ⏭️ ${file}`) : ` ⏭️ ${file}`);
|
|
265
|
+
});
|
|
266
|
+
lines.push('');
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// Rollback info
|
|
270
|
+
if (summary.rollback && summary.rollback.available) {
|
|
271
|
+
lines.push(color ? chalk.blue('💡 Your original files are safely backed up.') : '💡 Your original files are safely backed up.');
|
|
272
|
+
const cmd = color ? chalk.cyan(summary.rollback.command) : summary.rollback.command;
|
|
273
|
+
lines.push(color ? chalk.gray(` To restore: ${cmd}`) : ` To restore: ${cmd}`);
|
|
274
|
+
lines.push('');
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// Warnings
|
|
278
|
+
if (summary.warnings.length > 0) {
|
|
279
|
+
lines.push(color ? chalk.yellow('⚠️ Warnings:') : '⚠️ Warnings:');
|
|
280
|
+
summary.warnings.forEach(warning => {
|
|
281
|
+
lines.push(color ? chalk.yellow(` ${warning}`) : ` ${warning}`);
|
|
282
|
+
});
|
|
283
|
+
lines.push('');
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// Errors
|
|
287
|
+
if (summary.errors.length > 0) {
|
|
288
|
+
lines.push(color ? chalk.red('❌ Errors:') : '❌ Errors:');
|
|
289
|
+
summary.errors.forEach(error => {
|
|
290
|
+
lines.push(color ? chalk.red(` ${error}`) : ` ${error}`);
|
|
291
|
+
});
|
|
292
|
+
lines.push('');
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
// Next steps
|
|
296
|
+
if (summary.nextSteps.length > 0) {
|
|
297
|
+
lines.push(color ? chalk.blue('📋 Next steps:') : '📋 Next steps:');
|
|
298
|
+
summary.nextSteps.forEach((step, index) => {
|
|
299
|
+
lines.push(` ${index + 1}. ${step}`);
|
|
300
|
+
});
|
|
301
|
+
lines.push('');
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
return lines.join('\n');
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Resets the summary generator for a new adoption
|
|
309
|
+
*/
|
|
310
|
+
reset() {
|
|
311
|
+
this.summaryData = {
|
|
312
|
+
mode: null,
|
|
313
|
+
backup: null,
|
|
314
|
+
changes: {
|
|
315
|
+
created: [],
|
|
316
|
+
updated: [],
|
|
317
|
+
deleted: [],
|
|
318
|
+
preserved: []
|
|
319
|
+
},
|
|
320
|
+
warnings: [],
|
|
321
|
+
errors: [],
|
|
322
|
+
metadata: {
|
|
323
|
+
startTime: null,
|
|
324
|
+
endTime: null,
|
|
325
|
+
duration: null
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Generates statistics about the adoption
|
|
332
|
+
*
|
|
333
|
+
* @returns {Object} Statistics object
|
|
334
|
+
* @private
|
|
335
|
+
*/
|
|
336
|
+
_generateStatistics() {
|
|
337
|
+
return {
|
|
338
|
+
totalFiles: this._getTotalChanges(),
|
|
339
|
+
filesCreated: this.summaryData.changes.created.length,
|
|
340
|
+
filesUpdated: this.summaryData.changes.updated.length,
|
|
341
|
+
filesDeleted: this.summaryData.changes.deleted.length,
|
|
342
|
+
filesPreserved: this.summaryData.changes.preserved.length,
|
|
343
|
+
hasBackup: !!this.summaryData.backup,
|
|
344
|
+
hasWarnings: this.summaryData.warnings.length > 0,
|
|
345
|
+
hasErrors: this.summaryData.errors.length > 0
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* Generates rollback information
|
|
351
|
+
*
|
|
352
|
+
* @returns {Object} Rollback info
|
|
353
|
+
* @private
|
|
354
|
+
*/
|
|
355
|
+
_generateRollbackInfo() {
|
|
356
|
+
if (!this.summaryData.backup) {
|
|
357
|
+
return {
|
|
358
|
+
available: false,
|
|
359
|
+
command: null,
|
|
360
|
+
description: 'No backup available'
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
return {
|
|
365
|
+
available: true,
|
|
366
|
+
command: `kse rollback ${this.summaryData.backup.id}`,
|
|
367
|
+
description: 'Restore all files from backup',
|
|
368
|
+
backupId: this.summaryData.backup.id,
|
|
369
|
+
backupLocation: this.summaryData.backup.location
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Generates suggested next steps based on adoption results
|
|
375
|
+
*
|
|
376
|
+
* @returns {string[]} Array of next step suggestions
|
|
377
|
+
* @private
|
|
378
|
+
*/
|
|
379
|
+
_generateNextSteps() {
|
|
380
|
+
const steps = [];
|
|
381
|
+
const mode = this.summaryData.mode;
|
|
382
|
+
const hasErrors = this.summaryData.errors.length > 0;
|
|
383
|
+
|
|
384
|
+
if (hasErrors) {
|
|
385
|
+
steps.push('Review error messages above');
|
|
386
|
+
steps.push('Check log files for detailed error information');
|
|
387
|
+
if (this.summaryData.backup) {
|
|
388
|
+
steps.push(`Run 'kse rollback ${this.summaryData.backup.id}' to restore if needed`);
|
|
389
|
+
}
|
|
390
|
+
return steps;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
// Mode-specific suggestions
|
|
394
|
+
switch (mode) {
|
|
395
|
+
case 'fresh':
|
|
396
|
+
steps.push('Review the created .kiro/ structure');
|
|
397
|
+
steps.push('Customize CURRENT_CONTEXT.md for your project');
|
|
398
|
+
steps.push('Start creating your first spec with: kse spec create');
|
|
399
|
+
break;
|
|
400
|
+
|
|
401
|
+
case 'smart-update':
|
|
402
|
+
steps.push('Review updated template files');
|
|
403
|
+
steps.push('Check if CURRENT_CONTEXT.md needs updates');
|
|
404
|
+
steps.push('Continue working on your specs');
|
|
405
|
+
break;
|
|
406
|
+
|
|
407
|
+
case 'smart-adopt':
|
|
408
|
+
steps.push('Review the adoption changes');
|
|
409
|
+
steps.push('Verify your specs are intact');
|
|
410
|
+
steps.push('Update CURRENT_CONTEXT.md if needed');
|
|
411
|
+
break;
|
|
412
|
+
|
|
413
|
+
case 'skip':
|
|
414
|
+
steps.push('Your project is already up-to-date');
|
|
415
|
+
steps.push('Continue working on your specs');
|
|
416
|
+
break;
|
|
417
|
+
|
|
418
|
+
default:
|
|
419
|
+
steps.push('Review the changes made');
|
|
420
|
+
steps.push('Continue working on your project');
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
// Add general suggestions
|
|
424
|
+
if (this.summaryData.warnings.length > 0) {
|
|
425
|
+
steps.push('Review warnings above and address if needed');
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
return steps;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* Gets total number of file changes
|
|
433
|
+
*
|
|
434
|
+
* @returns {number} Total changes
|
|
435
|
+
* @private
|
|
436
|
+
*/
|
|
437
|
+
_getTotalChanges() {
|
|
438
|
+
return this.summaryData.changes.created.length +
|
|
439
|
+
this.summaryData.changes.updated.length +
|
|
440
|
+
this.summaryData.changes.deleted.length;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Normalizes file path for consistent display
|
|
445
|
+
*
|
|
446
|
+
* @param {string} filePath - File path
|
|
447
|
+
* @returns {string} Normalized path
|
|
448
|
+
* @private
|
|
449
|
+
*/
|
|
450
|
+
_normalizePath(filePath) {
|
|
451
|
+
// Convert to forward slashes for consistency
|
|
452
|
+
return filePath.replace(/\\/g, '/');
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* Gets display name for adoption mode
|
|
457
|
+
*
|
|
458
|
+
* @param {string} mode - Adoption mode
|
|
459
|
+
* @returns {string} Display name
|
|
460
|
+
* @private
|
|
461
|
+
*/
|
|
462
|
+
_getModeDisplayName(mode) {
|
|
463
|
+
const names = {
|
|
464
|
+
'fresh': 'Fresh Adoption',
|
|
465
|
+
'smart-adopt': 'Smart Adoption',
|
|
466
|
+
'smart-update': 'Smart Update',
|
|
467
|
+
'skip': 'Already Up-to-Date',
|
|
468
|
+
'warning': 'Version Warning'
|
|
469
|
+
};
|
|
470
|
+
return names[mode] || mode;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
/**
|
|
474
|
+
* Formats duration in human-readable format
|
|
475
|
+
*
|
|
476
|
+
* @param {number} ms - Duration in milliseconds
|
|
477
|
+
* @returns {string} Formatted duration
|
|
478
|
+
* @private
|
|
479
|
+
*/
|
|
480
|
+
_formatDuration(ms) {
|
|
481
|
+
if (ms < 1000) {
|
|
482
|
+
return `${ms}ms`;
|
|
483
|
+
} else if (ms < 60000) {
|
|
484
|
+
return `${(ms / 1000).toFixed(1)}s`;
|
|
485
|
+
} else {
|
|
486
|
+
const minutes = Math.floor(ms / 60000);
|
|
487
|
+
const seconds = Math.floor((ms % 60000) / 1000);
|
|
488
|
+
return `${minutes}m ${seconds}s`;
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
module.exports = SummaryGenerator;
|