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,749 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adopt Command
|
|
3
|
+
*
|
|
4
|
+
* Intelligently adopts existing projects into kiro-spec-engine.
|
|
5
|
+
*
|
|
6
|
+
* Default Behavior (Smart Mode):
|
|
7
|
+
* - Zero user interaction
|
|
8
|
+
* - Automatic mode selection
|
|
9
|
+
* - Mandatory backups
|
|
10
|
+
* - Smart conflict resolution
|
|
11
|
+
*
|
|
12
|
+
* Legacy Behavior (Interactive Mode):
|
|
13
|
+
* - Use --interactive flag
|
|
14
|
+
* - Manual conflict resolution
|
|
15
|
+
* - User confirmations
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const chalk = require('chalk');
|
|
19
|
+
const inquirer = require('inquirer');
|
|
20
|
+
const path = require('path');
|
|
21
|
+
const DetectionEngine = require('../adoption/detection-engine');
|
|
22
|
+
const { getAdoptionStrategy } = require('../adoption/adoption-strategy');
|
|
23
|
+
const BackupSystem = require('../backup/backup-system');
|
|
24
|
+
const VersionManager = require('../version/version-manager');
|
|
25
|
+
const SteeringManager = require('../steering/steering-manager');
|
|
26
|
+
const AdoptionConfig = require('../steering/adoption-config');
|
|
27
|
+
const { detectTool, generateAutoConfig } = require('../utils/tool-detector');
|
|
28
|
+
const ConflictResolver = require('../adoption/conflict-resolver');
|
|
29
|
+
const SelectiveBackup = require('../backup/selective-backup');
|
|
30
|
+
const SmartOrchestrator = require('../adoption/smart-orchestrator');
|
|
31
|
+
const { pathExists, ensureDirectory, writeJSON } = require('../utils/fs-utils');
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Executes the adopt command
|
|
35
|
+
*
|
|
36
|
+
* @param {Object} options - Command options
|
|
37
|
+
* @param {boolean} options.interactive - Enable interactive mode (legacy behavior)
|
|
38
|
+
* @param {boolean} options.dryRun - Show what would change without making changes
|
|
39
|
+
* @param {boolean} options.verbose - Show detailed logs
|
|
40
|
+
* @param {boolean} options.noBackup - Skip backup creation (dangerous)
|
|
41
|
+
* @param {boolean} options.skipUpdate - Skip template file updates
|
|
42
|
+
* @param {boolean} options.force - Force overwrite (legacy, implies non-interactive)
|
|
43
|
+
* @param {boolean} options.auto - Skip confirmations (legacy, implies non-interactive)
|
|
44
|
+
* @param {string} options.mode - Force specific adoption mode (legacy)
|
|
45
|
+
* @returns {Promise<void>}
|
|
46
|
+
*/
|
|
47
|
+
async function adoptCommand(options = {}) {
|
|
48
|
+
const {
|
|
49
|
+
interactive = false,
|
|
50
|
+
dryRun = false,
|
|
51
|
+
verbose = false,
|
|
52
|
+
noBackup = false,
|
|
53
|
+
skipUpdate = false,
|
|
54
|
+
force = false,
|
|
55
|
+
auto = false,
|
|
56
|
+
mode: forcedMode = null
|
|
57
|
+
} = options;
|
|
58
|
+
const projectPath = process.cwd();
|
|
59
|
+
|
|
60
|
+
console.log(chalk.red('đĨ') + ' Kiro Spec Engine - Project Adoption');
|
|
61
|
+
console.log();
|
|
62
|
+
|
|
63
|
+
// Warn about dangerous options
|
|
64
|
+
if (noBackup) {
|
|
65
|
+
console.log(chalk.red('â ī¸ WARNING: --no-backup flag detected'));
|
|
66
|
+
console.log(chalk.yellow(' This will skip backup creation - changes cannot be undone!'));
|
|
67
|
+
console.log();
|
|
68
|
+
|
|
69
|
+
if (!interactive && !force) {
|
|
70
|
+
const { confirmNoBackup } = await inquirer.prompt([
|
|
71
|
+
{
|
|
72
|
+
type: 'confirm',
|
|
73
|
+
name: 'confirmNoBackup',
|
|
74
|
+
message: 'Are you sure you want to proceed without backup?',
|
|
75
|
+
default: false
|
|
76
|
+
}
|
|
77
|
+
]);
|
|
78
|
+
|
|
79
|
+
if (!confirmNoBackup) {
|
|
80
|
+
console.log(chalk.yellow('Adoption cancelled'));
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Route to appropriate handler
|
|
87
|
+
if (interactive || (auto && !force)) {
|
|
88
|
+
// Legacy interactive mode
|
|
89
|
+
await adoptInteractive(projectPath, { auto, dryRun, mode: forcedMode, force });
|
|
90
|
+
} else {
|
|
91
|
+
// Smart mode (default)
|
|
92
|
+
await adoptSmart(projectPath, { dryRun, verbose, noBackup, skipUpdate });
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Smart adoption mode (default)
|
|
98
|
+
* Zero interaction, automatic decisions, mandatory backups
|
|
99
|
+
*
|
|
100
|
+
* @param {string} projectPath - Project path
|
|
101
|
+
* @param {Object} options - Options
|
|
102
|
+
* @returns {Promise<void>}
|
|
103
|
+
*/
|
|
104
|
+
async function adoptSmart(projectPath, options) {
|
|
105
|
+
const { dryRun, verbose, noBackup, skipUpdate } = options;
|
|
106
|
+
|
|
107
|
+
try {
|
|
108
|
+
// Create smart orchestrator
|
|
109
|
+
const orchestrator = new SmartOrchestrator();
|
|
110
|
+
|
|
111
|
+
// Execute orchestration
|
|
112
|
+
console.log(chalk.blue('đ Starting adoption...'));
|
|
113
|
+
console.log();
|
|
114
|
+
|
|
115
|
+
const result = await orchestrator.orchestrate(projectPath, {
|
|
116
|
+
dryRun,
|
|
117
|
+
verbose,
|
|
118
|
+
skipBackup: noBackup,
|
|
119
|
+
skipUpdate
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
// Handle results
|
|
123
|
+
if (!result.success) {
|
|
124
|
+
console.log();
|
|
125
|
+
console.log(chalk.red('â Adoption failed'));
|
|
126
|
+
console.log();
|
|
127
|
+
|
|
128
|
+
result.errors.forEach(error => {
|
|
129
|
+
console.log(chalk.red(` ${error}`));
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
if (result.backup) {
|
|
133
|
+
console.log();
|
|
134
|
+
console.log(chalk.blue('đĻ Backup available:'), result.backup.id);
|
|
135
|
+
console.log(chalk.gray(' Run'), chalk.cyan('kse rollback'), chalk.gray('to restore'));
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
process.exit(1);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Summary is already displayed by orchestrator
|
|
142
|
+
|
|
143
|
+
// Detect tool and offer automation setup
|
|
144
|
+
if (!dryRun) {
|
|
145
|
+
await offerAutomationSetup(projectPath);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// Show next steps
|
|
149
|
+
if (!dryRun) {
|
|
150
|
+
console.log(chalk.blue('đĄ Next steps:'));
|
|
151
|
+
console.log(' 1. Tell your AI: "Read .kiro/README.md to understand project methodology"');
|
|
152
|
+
console.log(' 2. Start working: Ask AI to implement features following Spec-driven approach');
|
|
153
|
+
console.log(' 3. Check progress: ' + chalk.cyan('kse status'));
|
|
154
|
+
console.log();
|
|
155
|
+
console.log(chalk.red('đĨ') + ' Project now follows Spec-driven development!');
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
} catch (error) {
|
|
159
|
+
console.log();
|
|
160
|
+
console.log(chalk.red('â Error:'), error.message);
|
|
161
|
+
console.log();
|
|
162
|
+
console.log(chalk.gray('If you need help, please report this issue:'));
|
|
163
|
+
console.log(chalk.cyan('https://github.com/heguangyong/scene-capability-engine/issues'));
|
|
164
|
+
process.exit(1);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Interactive adoption mode (legacy)
|
|
170
|
+
* Prompts user for decisions, manual conflict resolution
|
|
171
|
+
*
|
|
172
|
+
* @param {string} projectPath - Project path
|
|
173
|
+
* @param {Object} options - Options
|
|
174
|
+
* @returns {Promise<void>}
|
|
175
|
+
*/
|
|
176
|
+
async function adoptInteractive(projectPath, options) {
|
|
177
|
+
const { auto, dryRun, mode: forcedMode, force } = options;
|
|
178
|
+
|
|
179
|
+
try {
|
|
180
|
+
// 1. Detect project structure
|
|
181
|
+
console.log(chalk.blue('đĻ Analyzing project structure...'));
|
|
182
|
+
const detectionEngine = new DetectionEngine();
|
|
183
|
+
const detection = await detectionEngine.analyze(projectPath);
|
|
184
|
+
|
|
185
|
+
// 2. Determine strategy
|
|
186
|
+
const strategy = forcedMode || detectionEngine.determineStrategy(detection);
|
|
187
|
+
|
|
188
|
+
// 3. Show analysis to user
|
|
189
|
+
console.log();
|
|
190
|
+
console.log(detectionEngine.getSummary(detection));
|
|
191
|
+
console.log();
|
|
192
|
+
|
|
193
|
+
// 4. Show adoption plan
|
|
194
|
+
console.log(chalk.blue('đ Adoption Plan:'));
|
|
195
|
+
console.log(` Mode: ${chalk.cyan(strategy)}`);
|
|
196
|
+
|
|
197
|
+
if (strategy === 'fresh') {
|
|
198
|
+
console.log(' Actions:');
|
|
199
|
+
console.log(' - Create .kiro/ directory structure');
|
|
200
|
+
console.log(' - Copy template files (steering, tools, docs)');
|
|
201
|
+
console.log(' - Create version.json');
|
|
202
|
+
} else if (strategy === 'partial') {
|
|
203
|
+
console.log(' Actions:');
|
|
204
|
+
console.log(' - Preserve existing specs/ and steering/');
|
|
205
|
+
console.log(' - Add missing components');
|
|
206
|
+
console.log(' - Create/update version.json');
|
|
207
|
+
if (detection.hasKiroDir) {
|
|
208
|
+
console.log(' - Create backup before changes');
|
|
209
|
+
}
|
|
210
|
+
} else if (strategy === 'full') {
|
|
211
|
+
console.log(' Actions:');
|
|
212
|
+
console.log(` - Upgrade from ${detection.existingVersion || 'unknown'} to current version`);
|
|
213
|
+
console.log(' - Update template files');
|
|
214
|
+
console.log(' - Preserve user content (specs/)');
|
|
215
|
+
console.log(' - Create backup before changes');
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// Show conflicts if any (brief summary)
|
|
219
|
+
if (detection.conflicts.length > 0) {
|
|
220
|
+
console.log();
|
|
221
|
+
console.log(chalk.yellow('â ī¸ Conflicts detected:'));
|
|
222
|
+
detection.conflicts.forEach(conflict => {
|
|
223
|
+
console.log(` - ${conflict.path}`);
|
|
224
|
+
});
|
|
225
|
+
console.log();
|
|
226
|
+
|
|
227
|
+
if (force) {
|
|
228
|
+
console.log(chalk.red(' â ī¸ --force enabled: Conflicting files will be overwritten'));
|
|
229
|
+
console.log(chalk.gray(' A backup will be created before overwriting'));
|
|
230
|
+
} else if (auto) {
|
|
231
|
+
console.log(chalk.gray(' --auto mode: Existing files will be preserved'));
|
|
232
|
+
} else {
|
|
233
|
+
console.log(chalk.gray(' You will be prompted to choose how to handle conflicts'));
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
console.log();
|
|
238
|
+
|
|
239
|
+
// 5. Dry run mode
|
|
240
|
+
if (dryRun) {
|
|
241
|
+
console.log(chalk.yellow('đ Dry run mode - no changes will be made'));
|
|
242
|
+
console.log();
|
|
243
|
+
|
|
244
|
+
// Show how conflicts would be handled
|
|
245
|
+
if (detection.conflicts.length > 0) {
|
|
246
|
+
console.log(chalk.blue('Conflict Resolution Preview:'));
|
|
247
|
+
console.log();
|
|
248
|
+
|
|
249
|
+
if (force) {
|
|
250
|
+
console.log(chalk.yellow(' With --force flag:'));
|
|
251
|
+
console.log(' - All conflicting files would be overwritten');
|
|
252
|
+
console.log(' - Backup would be created before overwriting');
|
|
253
|
+
console.log();
|
|
254
|
+
console.log(' Files that would be overwritten:');
|
|
255
|
+
detection.conflicts.forEach(conflict => {
|
|
256
|
+
console.log(chalk.red(` ~ ${conflict.path}`));
|
|
257
|
+
});
|
|
258
|
+
} else if (auto) {
|
|
259
|
+
console.log(chalk.gray(' With --auto flag:'));
|
|
260
|
+
console.log(' - All conflicting files would be preserved');
|
|
261
|
+
console.log(' - Template files would be skipped');
|
|
262
|
+
console.log();
|
|
263
|
+
console.log(' Files that would be skipped:');
|
|
264
|
+
detection.conflicts.forEach(conflict => {
|
|
265
|
+
console.log(chalk.gray(` - ${conflict.path}`));
|
|
266
|
+
});
|
|
267
|
+
} else {
|
|
268
|
+
console.log(chalk.blue(' In interactive mode:'));
|
|
269
|
+
console.log(' - You would be prompted to choose:');
|
|
270
|
+
console.log(' âĸ Skip all conflicting files');
|
|
271
|
+
console.log(' âĸ Overwrite all (with backup)');
|
|
272
|
+
console.log(' âĸ Review each conflict individually');
|
|
273
|
+
console.log();
|
|
274
|
+
console.log(' Conflicting files:');
|
|
275
|
+
detection.conflicts.forEach(conflict => {
|
|
276
|
+
console.log(chalk.yellow(` ? ${conflict.path}`));
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
console.log();
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
const adoptionStrategy = getAdoptionStrategy(strategy);
|
|
284
|
+
const versionManager = new VersionManager();
|
|
285
|
+
const packageJson = require('../../package.json');
|
|
286
|
+
|
|
287
|
+
const result = await adoptionStrategy.execute(projectPath, strategy, {
|
|
288
|
+
kseVersion: packageJson.version,
|
|
289
|
+
dryRun: true,
|
|
290
|
+
force
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
if (result.success) {
|
|
294
|
+
console.log(chalk.green('â
Dry run completed successfully'));
|
|
295
|
+
console.log();
|
|
296
|
+
console.log('Files that would be created:');
|
|
297
|
+
result.filesCreated.forEach(file => console.log(` + ${file}`));
|
|
298
|
+
if (result.filesUpdated.length > 0) {
|
|
299
|
+
console.log('Files that would be updated:');
|
|
300
|
+
result.filesUpdated.forEach(file => console.log(` ~ ${file}`));
|
|
301
|
+
}
|
|
302
|
+
if (result.filesSkipped.length > 0) {
|
|
303
|
+
console.log('Files that would be skipped:');
|
|
304
|
+
result.filesSkipped.forEach(file => console.log(` - ${file}`));
|
|
305
|
+
}
|
|
306
|
+
} else {
|
|
307
|
+
console.log(chalk.red('â Dry run failed'));
|
|
308
|
+
result.errors.forEach(error => console.log(` ${error}`));
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// 6. Confirm with user (unless --auto)
|
|
315
|
+
if (!auto) {
|
|
316
|
+
const { confirmed } = await inquirer.prompt([
|
|
317
|
+
{
|
|
318
|
+
type: 'confirm',
|
|
319
|
+
name: 'confirmed',
|
|
320
|
+
message: 'Proceed with adoption?',
|
|
321
|
+
default: true
|
|
322
|
+
}
|
|
323
|
+
]);
|
|
324
|
+
|
|
325
|
+
if (!confirmed) {
|
|
326
|
+
console.log(chalk.yellow('Adoption cancelled'));
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
console.log();
|
|
332
|
+
|
|
333
|
+
// 7. Handle conflicts interactively
|
|
334
|
+
let resolutionMap = {};
|
|
335
|
+
let conflictBackupId = null;
|
|
336
|
+
|
|
337
|
+
if (detection.conflicts.length > 0) {
|
|
338
|
+
if (!auto && !force) {
|
|
339
|
+
// Interactive mode: prompt user for conflict resolution
|
|
340
|
+
const resolver = new ConflictResolver();
|
|
341
|
+
|
|
342
|
+
// Show detailed conflict summary
|
|
343
|
+
resolver.displayConflictSummary(detection.conflicts);
|
|
344
|
+
|
|
345
|
+
// Get resolution strategy
|
|
346
|
+
const conflictStrategy = await resolver.promptStrategy(detection.conflicts);
|
|
347
|
+
|
|
348
|
+
// Resolve conflicts
|
|
349
|
+
resolutionMap = await resolver.resolveConflicts(detection.conflicts, conflictStrategy, projectPath);
|
|
350
|
+
|
|
351
|
+
// Create selective backup if any files will be overwritten
|
|
352
|
+
const filesToOverwrite = Object.entries(resolutionMap)
|
|
353
|
+
.filter(([_, resolution]) => resolution === 'overwrite')
|
|
354
|
+
.map(([filePath, _]) => filePath);
|
|
355
|
+
|
|
356
|
+
if (filesToOverwrite.length > 0) {
|
|
357
|
+
console.log();
|
|
358
|
+
console.log(chalk.blue('đĻ Creating backup of files to be overwritten...'));
|
|
359
|
+
const selectiveBackup = new SelectiveBackup();
|
|
360
|
+
|
|
361
|
+
try {
|
|
362
|
+
const backup = await selectiveBackup.createSelectiveBackup(
|
|
363
|
+
projectPath,
|
|
364
|
+
filesToOverwrite,
|
|
365
|
+
{ type: 'conflict' }
|
|
366
|
+
);
|
|
367
|
+
conflictBackupId = backup.id;
|
|
368
|
+
console.log(chalk.green(`â
Backup created: ${conflictBackupId}`));
|
|
369
|
+
} catch (backupError) {
|
|
370
|
+
console.log(chalk.red(`â Failed to create backup: ${backupError.message}`));
|
|
371
|
+
console.log();
|
|
372
|
+
console.log(chalk.yellow('â ī¸ Aborting adoption for safety'));
|
|
373
|
+
console.log(chalk.gray(' Possible causes:'));
|
|
374
|
+
console.log(chalk.gray(' - Insufficient disk space'));
|
|
375
|
+
console.log(chalk.gray(' - Permission denied'));
|
|
376
|
+
console.log(chalk.gray(' - File system error'));
|
|
377
|
+
console.log();
|
|
378
|
+
console.log(chalk.gray(' Please resolve the issue and try again'));
|
|
379
|
+
process.exit(1);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
} else if (force) {
|
|
383
|
+
// Force mode: overwrite all with backup
|
|
384
|
+
console.log();
|
|
385
|
+
console.log(chalk.blue('đĻ Creating backup of conflicting files...'));
|
|
386
|
+
const filesToOverwrite = detection.conflicts.map(c => c.path);
|
|
387
|
+
const selectiveBackup = new SelectiveBackup();
|
|
388
|
+
|
|
389
|
+
try {
|
|
390
|
+
const backup = await selectiveBackup.createSelectiveBackup(
|
|
391
|
+
projectPath,
|
|
392
|
+
filesToOverwrite,
|
|
393
|
+
{ type: 'conflict' }
|
|
394
|
+
);
|
|
395
|
+
conflictBackupId = backup.id;
|
|
396
|
+
console.log(chalk.green(`â
Backup created: ${conflictBackupId}`));
|
|
397
|
+
} catch (backupError) {
|
|
398
|
+
console.log(chalk.red(`â Failed to create backup: ${backupError.message}`));
|
|
399
|
+
console.log();
|
|
400
|
+
console.log(chalk.yellow('â ī¸ Aborting adoption for safety'));
|
|
401
|
+
console.log(chalk.gray(' Cannot proceed with --force without a backup'));
|
|
402
|
+
console.log();
|
|
403
|
+
console.log(chalk.gray(' Possible solutions:'));
|
|
404
|
+
console.log(chalk.gray(' - Free up disk space'));
|
|
405
|
+
console.log(chalk.gray(' - Check file permissions'));
|
|
406
|
+
console.log(chalk.gray(' - Try without --force to skip conflicts'));
|
|
407
|
+
process.exit(1);
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
resolutionMap = detection.conflicts.reduce((map, conflict) => {
|
|
411
|
+
map[conflict.path] = 'overwrite';
|
|
412
|
+
return map;
|
|
413
|
+
}, {});
|
|
414
|
+
} else if (auto) {
|
|
415
|
+
// Auto mode: skip all conflicts
|
|
416
|
+
resolutionMap = detection.conflicts.reduce((map, conflict) => {
|
|
417
|
+
map[conflict.path] = 'keep';
|
|
418
|
+
return map;
|
|
419
|
+
}, {});
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
console.log();
|
|
424
|
+
|
|
425
|
+
// 8. Handle steering strategy if conflicts detected
|
|
426
|
+
let steeringStrategy = null;
|
|
427
|
+
let steeringBackupId = null;
|
|
428
|
+
|
|
429
|
+
if (detection.steeringDetection && detection.steeringDetection.hasExistingSteering) {
|
|
430
|
+
console.log(chalk.blue('đ¯ Handling steering files...'));
|
|
431
|
+
const steeringManager = new SteeringManager();
|
|
432
|
+
|
|
433
|
+
// Prompt for strategy
|
|
434
|
+
steeringStrategy = await steeringManager.promptStrategy(detection.steeringDetection);
|
|
435
|
+
|
|
436
|
+
if (steeringStrategy === 'use-kse') {
|
|
437
|
+
// Backup existing steering files
|
|
438
|
+
console.log(chalk.blue('đĻ Backing up existing steering files...'));
|
|
439
|
+
const backupResult = await steeringManager.backupSteering(projectPath);
|
|
440
|
+
|
|
441
|
+
if (backupResult.success) {
|
|
442
|
+
steeringBackupId = backupResult.backupId;
|
|
443
|
+
console.log(chalk.green(`â
Steering backup created: ${steeringBackupId}`));
|
|
444
|
+
|
|
445
|
+
// Install kse steering files
|
|
446
|
+
console.log(chalk.blue('đ Installing kse steering files...'));
|
|
447
|
+
const installResult = await steeringManager.installKseSteering(projectPath);
|
|
448
|
+
|
|
449
|
+
if (installResult.success) {
|
|
450
|
+
console.log(chalk.green(`â
Installed ${installResult.filesInstalled} kse steering file(s)`));
|
|
451
|
+
} else {
|
|
452
|
+
console.log(chalk.red(`â Failed to install kse steering: ${installResult.error}`));
|
|
453
|
+
console.log(chalk.yellow('Aborting adoption'));
|
|
454
|
+
return;
|
|
455
|
+
}
|
|
456
|
+
} else {
|
|
457
|
+
console.log(chalk.red(`â Failed to backup steering: ${backupResult.error}`));
|
|
458
|
+
console.log(chalk.yellow('Aborting adoption for safety'));
|
|
459
|
+
return;
|
|
460
|
+
}
|
|
461
|
+
} else if (steeringStrategy === 'use-project') {
|
|
462
|
+
console.log(chalk.blue('â
Keeping existing steering files'));
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
// Save steering strategy to adoption config
|
|
466
|
+
const adoptionConfig = new AdoptionConfig(projectPath);
|
|
467
|
+
await adoptionConfig.updateSteeringStrategy(steeringStrategy, steeringBackupId);
|
|
468
|
+
|
|
469
|
+
console.log();
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
// 9. Create backup if needed (for non-conflict scenarios)
|
|
473
|
+
let backupId = null;
|
|
474
|
+
if (detection.hasKiroDir && (strategy === 'partial' || strategy === 'full')) {
|
|
475
|
+
console.log(chalk.blue('đĻ Creating backup...'));
|
|
476
|
+
const backupSystem = new BackupSystem();
|
|
477
|
+
|
|
478
|
+
try {
|
|
479
|
+
const backup = await backupSystem.createBackup(projectPath, { type: 'adopt' });
|
|
480
|
+
backupId = backup.id;
|
|
481
|
+
console.log(chalk.green(`â
Backup created: ${backupId}`));
|
|
482
|
+
} catch (error) {
|
|
483
|
+
console.log(chalk.red(`â Failed to create backup: ${error.message}`));
|
|
484
|
+
console.log(chalk.yellow('Aborting adoption for safety'));
|
|
485
|
+
return;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
console.log();
|
|
490
|
+
|
|
491
|
+
// 10. Execute adoption
|
|
492
|
+
console.log(chalk.blue('đ Executing adoption...'));
|
|
493
|
+
const adoptionStrategy = getAdoptionStrategy(strategy);
|
|
494
|
+
const packageJson = require('../../package.json');
|
|
495
|
+
|
|
496
|
+
const result = await adoptionStrategy.execute(projectPath, strategy, {
|
|
497
|
+
kseVersion: packageJson.version,
|
|
498
|
+
dryRun: false,
|
|
499
|
+
backupId,
|
|
500
|
+
force,
|
|
501
|
+
resolutionMap // Pass resolution map to adoption strategy
|
|
502
|
+
});
|
|
503
|
+
|
|
504
|
+
console.log();
|
|
505
|
+
|
|
506
|
+
// 11. Report results
|
|
507
|
+
if (result.success) {
|
|
508
|
+
console.log(chalk.green('â
Adoption completed successfully!'));
|
|
509
|
+
console.log();
|
|
510
|
+
|
|
511
|
+
// Show conflict resolution summary if conflicts were handled
|
|
512
|
+
if (detection.conflicts.length > 0) {
|
|
513
|
+
console.log(chalk.blue('đ Conflict Resolution Summary:'));
|
|
514
|
+
console.log(` Total conflicts: ${detection.conflicts.length}`);
|
|
515
|
+
|
|
516
|
+
const overwrittenFiles = Object.entries(resolutionMap)
|
|
517
|
+
.filter(([_, resolution]) => resolution === 'overwrite')
|
|
518
|
+
.map(([path, _]) => path);
|
|
519
|
+
|
|
520
|
+
const skippedFiles = Object.entries(resolutionMap)
|
|
521
|
+
.filter(([_, resolution]) => resolution === 'keep')
|
|
522
|
+
.map(([path, _]) => path);
|
|
523
|
+
|
|
524
|
+
if (overwrittenFiles.length > 0) {
|
|
525
|
+
console.log(chalk.yellow(` Overwritten: ${overwrittenFiles.length} file(s)`));
|
|
526
|
+
overwrittenFiles.forEach(file => {
|
|
527
|
+
console.log(chalk.red(` ~ ${file}`));
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
if (skippedFiles.length > 0) {
|
|
532
|
+
console.log(chalk.gray(` Skipped: ${skippedFiles.length} file(s)`));
|
|
533
|
+
skippedFiles.forEach(file => {
|
|
534
|
+
console.log(chalk.gray(` - ${file}`));
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
if (conflictBackupId) {
|
|
539
|
+
console.log();
|
|
540
|
+
console.log(chalk.blue('đĻ Conflict Backup:'), conflictBackupId);
|
|
541
|
+
console.log(chalk.gray(' To restore overwritten files, run:'));
|
|
542
|
+
console.log(chalk.cyan(` kse rollback ${conflictBackupId}`));
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
console.log();
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
if (steeringStrategy) {
|
|
549
|
+
console.log(chalk.blue('Steering Strategy:'), steeringStrategy);
|
|
550
|
+
if (steeringBackupId) {
|
|
551
|
+
console.log(chalk.gray(' Backup:'), steeringBackupId);
|
|
552
|
+
}
|
|
553
|
+
console.log();
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
if (result.filesCreated.length > 0) {
|
|
557
|
+
console.log(chalk.blue('Files created:'));
|
|
558
|
+
result.filesCreated.forEach(file => console.log(` + ${file}`));
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
if (result.filesUpdated.length > 0) {
|
|
562
|
+
console.log(chalk.blue('Files updated:'));
|
|
563
|
+
result.filesUpdated.forEach(file => console.log(` ~ ${file}`));
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
if (result.filesSkipped.length > 0 && detection.conflicts.length === 0) {
|
|
567
|
+
// Only show this if not already shown in conflict summary
|
|
568
|
+
console.log(chalk.gray('Files skipped:'));
|
|
569
|
+
result.filesSkipped.forEach(file => console.log(` - ${file}`));
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
if (result.warnings.length > 0) {
|
|
573
|
+
console.log();
|
|
574
|
+
console.log(chalk.yellow('â ī¸ Warnings:'));
|
|
575
|
+
result.warnings.forEach(warning => console.log(` ${warning}`));
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
if (backupId) {
|
|
579
|
+
console.log();
|
|
580
|
+
console.log(chalk.blue('đĻ Full Backup:'), backupId);
|
|
581
|
+
console.log(chalk.gray(' Run'), chalk.cyan('kse rollback'), chalk.gray('if you need to undo changes'));
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
console.log();
|
|
585
|
+
|
|
586
|
+
// 12. Detect tool and offer automation setup
|
|
587
|
+
console.log(chalk.blue('đ Detecting your development environment...'));
|
|
588
|
+
try {
|
|
589
|
+
const toolDetection = await detectTool(projectPath);
|
|
590
|
+
const autoConfig = await generateAutoConfig(toolDetection, projectPath);
|
|
591
|
+
|
|
592
|
+
console.log();
|
|
593
|
+
console.log(chalk.blue('Tool Detected:'), chalk.cyan(toolDetection.primaryTool));
|
|
594
|
+
console.log(chalk.blue('Confidence:'), autoConfig.confidence);
|
|
595
|
+
|
|
596
|
+
if (autoConfig.notes.length > 0) {
|
|
597
|
+
console.log();
|
|
598
|
+
autoConfig.notes.forEach(note => console.log(chalk.gray(` âšī¸ ${note}`)));
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
// Offer automation setup (unless --auto)
|
|
602
|
+
if (!auto && autoConfig.suggestedPresets.length > 0) {
|
|
603
|
+
console.log();
|
|
604
|
+
const { setupAutomation } = await inquirer.prompt([
|
|
605
|
+
{
|
|
606
|
+
type: 'confirm',
|
|
607
|
+
name: 'setupAutomation',
|
|
608
|
+
message: 'Would you like to set up automation for this tool?',
|
|
609
|
+
default: true
|
|
610
|
+
}
|
|
611
|
+
]);
|
|
612
|
+
|
|
613
|
+
if (setupAutomation) {
|
|
614
|
+
console.log();
|
|
615
|
+
console.log(chalk.blue('đ Recommended automation setup:'));
|
|
616
|
+
console.log();
|
|
617
|
+
console.log(chalk.gray('Suggested presets:'));
|
|
618
|
+
autoConfig.suggestedPresets.forEach(preset => {
|
|
619
|
+
console.log(` - ${preset}`);
|
|
620
|
+
});
|
|
621
|
+
console.log();
|
|
622
|
+
console.log(chalk.gray('Run these commands to set up:'));
|
|
623
|
+
autoConfig.suggestedCommands.forEach(cmd => {
|
|
624
|
+
console.log(chalk.cyan(` ${cmd}`));
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
} else if (autoConfig.suggestedCommands.length > 0) {
|
|
628
|
+
console.log();
|
|
629
|
+
console.log(chalk.blue('đĄ Automation setup:'));
|
|
630
|
+
autoConfig.suggestedCommands.forEach(cmd => {
|
|
631
|
+
console.log(chalk.gray(` ${cmd}`));
|
|
632
|
+
});
|
|
633
|
+
}
|
|
634
|
+
} catch (toolError) {
|
|
635
|
+
// Tool detection is optional, don't fail adoption if it errors
|
|
636
|
+
console.log(chalk.yellow('â ī¸ Could not detect development tool'));
|
|
637
|
+
console.log(chalk.gray(' You can manually set up automation later'));
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
console.log();
|
|
641
|
+
console.log(chalk.blue('đĄ Next steps:'));
|
|
642
|
+
console.log(' 1. Tell your AI: "Read .kiro/README.md to understand project methodology"');
|
|
643
|
+
console.log(' 2. Start working: Ask AI to implement features following Spec-driven approach');
|
|
644
|
+
console.log(' 3. Check progress: ' + chalk.cyan('kse status'));
|
|
645
|
+
console.log();
|
|
646
|
+
console.log(chalk.red('đĨ') + ' Project now follows Spec-driven development!');
|
|
647
|
+
} else {
|
|
648
|
+
console.log(chalk.red('â Adoption failed'));
|
|
649
|
+
console.log();
|
|
650
|
+
result.errors.forEach(error => console.log(chalk.red(` ${error}`)));
|
|
651
|
+
|
|
652
|
+
if (backupId) {
|
|
653
|
+
console.log();
|
|
654
|
+
console.log(chalk.blue('đĻ Backup available:'), backupId);
|
|
655
|
+
console.log(chalk.gray(' Run'), chalk.cyan('kse rollback'), chalk.gray('to restore'));
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
process.exit(1);
|
|
659
|
+
}
|
|
660
|
+
} catch (error) {
|
|
661
|
+
console.log();
|
|
662
|
+
console.log(chalk.red('â Error:'), error.message);
|
|
663
|
+
console.log();
|
|
664
|
+
console.log(chalk.gray('If you need help, please report this issue:'));
|
|
665
|
+
console.log(chalk.cyan('https://github.com/heguangyong/scene-capability-engine/issues'));
|
|
666
|
+
process.exit(1);
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
/**
|
|
671
|
+
* Offers automation setup based on detected tool
|
|
672
|
+
*
|
|
673
|
+
* @param {string} projectPath - Project path
|
|
674
|
+
* @returns {Promise<void>}
|
|
675
|
+
*/
|
|
676
|
+
/**
|
|
677
|
+
* Creates default MCP settings for Kiro IDE
|
|
678
|
+
* Only called when Kiro IDE is detected
|
|
679
|
+
*
|
|
680
|
+
* @param {string} projectPath - Project root path
|
|
681
|
+
*/
|
|
682
|
+
async function setupKiroMcpConfig(projectPath) {
|
|
683
|
+
const mcpConfigPath = path.join(projectPath, '.kiro', 'settings', 'mcp.json');
|
|
684
|
+
|
|
685
|
+
// Don't overwrite existing config
|
|
686
|
+
if (await pathExists(mcpConfigPath)) {
|
|
687
|
+
return;
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
const mcpConfig = {
|
|
691
|
+
mcpServers: {
|
|
692
|
+
shell: {
|
|
693
|
+
command: 'npx',
|
|
694
|
+
args: ['-y', 'mcp-server-commands'],
|
|
695
|
+
env: {},
|
|
696
|
+
disabled: false,
|
|
697
|
+
autoApprove: ['run_process']
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
};
|
|
701
|
+
|
|
702
|
+
try {
|
|
703
|
+
await ensureDirectory(path.join(projectPath, '.kiro', 'settings'));
|
|
704
|
+
await writeJSON(mcpConfigPath, mcpConfig);
|
|
705
|
+
console.log(chalk.green(' â
Created .kiro/settings/mcp.json (shell MCP server)'));
|
|
706
|
+
} catch (error) {
|
|
707
|
+
// Non-fatal, just log warning
|
|
708
|
+
console.log(chalk.yellow(' â ī¸ Could not create MCP config: ' + error.message));
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
async function offerAutomationSetup(projectPath) {
|
|
713
|
+
console.log(chalk.blue('đ Detecting your development environment...'));
|
|
714
|
+
|
|
715
|
+
try {
|
|
716
|
+
const toolDetection = await detectTool(projectPath);
|
|
717
|
+
const autoConfig = await generateAutoConfig(toolDetection, projectPath);
|
|
718
|
+
|
|
719
|
+
console.log();
|
|
720
|
+
console.log(chalk.blue('Tool Detected:'), chalk.cyan(toolDetection.primaryTool));
|
|
721
|
+
console.log(chalk.blue('Confidence:'), autoConfig.confidence);
|
|
722
|
+
|
|
723
|
+
if (autoConfig.notes.length > 0) {
|
|
724
|
+
console.log();
|
|
725
|
+
autoConfig.notes.forEach(note => console.log(chalk.gray(` âšī¸ ${note}`)));
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
if (autoConfig.suggestedCommands.length > 0) {
|
|
729
|
+
console.log();
|
|
730
|
+
console.log(chalk.blue('đĄ Automation setup:'));
|
|
731
|
+
autoConfig.suggestedCommands.forEach(cmd => {
|
|
732
|
+
console.log(chalk.gray(` ${cmd}`));
|
|
733
|
+
});
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
// If Kiro IDE detected, create default MCP settings
|
|
737
|
+
if (toolDetection.primaryTool === 'kiro') {
|
|
738
|
+
await setupKiroMcpConfig(projectPath);
|
|
739
|
+
}
|
|
740
|
+
} catch (toolError) {
|
|
741
|
+
// Tool detection is optional, don't fail adoption if it errors
|
|
742
|
+
console.log(chalk.yellow('â ī¸ Could not detect development tool'));
|
|
743
|
+
console.log(chalk.gray(' You can manually set up automation later'));
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
console.log();
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
module.exports = adoptCommand;
|