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,796 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { Command } = require('commander');
|
|
4
|
+
const chalk = require('chalk');
|
|
5
|
+
const inquirer = require('inquirer');
|
|
6
|
+
const fs = require('fs-extra');
|
|
7
|
+
const path = require('path');
|
|
8
|
+
const { spawn } = require('child_process');
|
|
9
|
+
const { getI18n } = require('../lib/i18n');
|
|
10
|
+
const doctorCommand = require('../lib/commands/doctor');
|
|
11
|
+
const adoptCommand = require('../lib/commands/adopt');
|
|
12
|
+
const upgradeCommand = require('../lib/commands/upgrade');
|
|
13
|
+
const rollbackCommand = require('../lib/commands/rollback');
|
|
14
|
+
const watchCommands = require('../lib/commands/watch');
|
|
15
|
+
const workflowsCommand = require('../lib/commands/workflows');
|
|
16
|
+
const registerCollabCommands = require('../lib/commands/collab');
|
|
17
|
+
const { registerSpecBootstrapCommand } = require('../lib/commands/spec-bootstrap');
|
|
18
|
+
const { registerSpecPipelineCommand } = require('../lib/commands/spec-pipeline');
|
|
19
|
+
const { registerSpecGateCommand } = require('../lib/commands/spec-gate');
|
|
20
|
+
const { registerValueCommands } = require('../lib/commands/value');
|
|
21
|
+
const VersionChecker = require('../lib/version/version-checker');
|
|
22
|
+
|
|
23
|
+
const i18n = getI18n();
|
|
24
|
+
const t = (key, params) => i18n.t(key, params);
|
|
25
|
+
|
|
26
|
+
// Read version from package.json
|
|
27
|
+
const packageJson = require('../package.json');
|
|
28
|
+
|
|
29
|
+
// Create version checker instance
|
|
30
|
+
const versionChecker = new VersionChecker();
|
|
31
|
+
|
|
32
|
+
// Helper function to check version before command execution
|
|
33
|
+
async function checkVersionBeforeCommand(options = {}) {
|
|
34
|
+
const projectPath = process.cwd();
|
|
35
|
+
const noVersionCheck = options.noVersionCheck || false;
|
|
36
|
+
|
|
37
|
+
if (!noVersionCheck) {
|
|
38
|
+
await versionChecker.checkVersion(projectPath, { noVersionCheck });
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const program = new Command();
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Normalize `sce spec ...` compatibility routes.
|
|
46
|
+
*
|
|
47
|
+
* Supported routes:
|
|
48
|
+
* - `sce spec bootstrap ...` -> `sce spec-bootstrap ...`
|
|
49
|
+
* - `sce spec pipeline ...` -> `sce spec-pipeline ...`
|
|
50
|
+
* - `sce spec gate ...` -> `sce spec-gate ...`
|
|
51
|
+
* - `sce spec create <name> ...` -> `sce create-spec <name> ...`
|
|
52
|
+
* - `sce spec <name> ...` -> `sce create-spec <name> ...` (legacy)
|
|
53
|
+
*
|
|
54
|
+
* @param {string[]} argv
|
|
55
|
+
* @returns {string[]}
|
|
56
|
+
*/
|
|
57
|
+
function normalizeSpecCommandArgs(argv) {
|
|
58
|
+
if (!Array.isArray(argv) || argv.length === 0) {
|
|
59
|
+
return argv;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const normalized = [...argv];
|
|
63
|
+
const commandIndex = findCommandIndex(normalized);
|
|
64
|
+
if (commandIndex < 0 || normalized[commandIndex] !== 'spec') {
|
|
65
|
+
return normalized;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const commandToken = normalized[commandIndex + 1];
|
|
69
|
+
|
|
70
|
+
if (commandToken === 'bootstrap') {
|
|
71
|
+
normalized.splice(commandIndex, 2, 'spec-bootstrap');
|
|
72
|
+
return normalized;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (commandToken === 'pipeline') {
|
|
76
|
+
normalized.splice(commandIndex, 2, 'spec-pipeline');
|
|
77
|
+
return normalized;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (commandToken === 'gate') {
|
|
81
|
+
normalized.splice(commandIndex, 2, 'spec-gate');
|
|
82
|
+
return normalized;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (commandToken === 'create') {
|
|
86
|
+
normalized.splice(commandIndex, 2, 'create-spec');
|
|
87
|
+
return normalized;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
normalized.splice(commandIndex, 1, 'create-spec');
|
|
91
|
+
return normalized;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Find command token index after global options.
|
|
96
|
+
* @param {string[]} args
|
|
97
|
+
* @returns {number}
|
|
98
|
+
*/
|
|
99
|
+
function findCommandIndex(args) {
|
|
100
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
101
|
+
const token = args[index];
|
|
102
|
+
if (!token.startsWith('-')) {
|
|
103
|
+
return index;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (token === '-l' || token === '--lang') {
|
|
107
|
+
index += 1;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return -1;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// 版本和基本信息
|
|
115
|
+
program
|
|
116
|
+
.name(t('cli.name'))
|
|
117
|
+
.description(t('cli.description'))
|
|
118
|
+
.version(packageJson.version, '-v, --version', 'Display version number')
|
|
119
|
+
.option('-l, --lang <locale>', 'Set language (en/zh)', (locale) => {
|
|
120
|
+
i18n.setLocale(locale);
|
|
121
|
+
})
|
|
122
|
+
.option('--no-version-check', 'Suppress version mismatch warnings')
|
|
123
|
+
.option('--skip-steering-check', 'Skip steering directory compliance check (not recommended)')
|
|
124
|
+
.option('--force-steering-check', 'Force steering directory compliance check even if cache is valid');
|
|
125
|
+
|
|
126
|
+
// 初始化项目命令
|
|
127
|
+
program
|
|
128
|
+
.command('init [project-name]')
|
|
129
|
+
.description(t('cli.commands.init.description'))
|
|
130
|
+
.option('-f, --force', t('cli.commands.init.forceOption'))
|
|
131
|
+
.action(async (projectName, options) => {
|
|
132
|
+
console.log(chalk.red('🔥') + ' ' + t('cli.commands.init.description'));
|
|
133
|
+
console.log();
|
|
134
|
+
|
|
135
|
+
// 获取项目名称
|
|
136
|
+
if (!projectName) {
|
|
137
|
+
const answers = await inquirer.prompt([
|
|
138
|
+
{
|
|
139
|
+
type: 'input',
|
|
140
|
+
name: 'projectName',
|
|
141
|
+
message: t('cli.commands.init.projectNamePrompt'),
|
|
142
|
+
default: path.basename(process.cwd())
|
|
143
|
+
}
|
|
144
|
+
]);
|
|
145
|
+
projectName = answers.projectName;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// 检查是否已存在 .kiro 目录
|
|
149
|
+
const kiroDir = path.join(process.cwd(), '.kiro');
|
|
150
|
+
if (fs.existsSync(kiroDir) && !options.force) {
|
|
151
|
+
console.log(chalk.yellow(t('cli.commands.init.alreadyExists')));
|
|
152
|
+
const { overwrite } = await inquirer.prompt([
|
|
153
|
+
{
|
|
154
|
+
type: 'confirm',
|
|
155
|
+
name: 'overwrite',
|
|
156
|
+
message: t('cli.commands.init.overwritePrompt'),
|
|
157
|
+
default: false
|
|
158
|
+
}
|
|
159
|
+
]);
|
|
160
|
+
if (!overwrite) {
|
|
161
|
+
console.log(t('cli.commands.init.cancelled'));
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
try {
|
|
167
|
+
// 复制模板文件
|
|
168
|
+
const templateDir = path.join(__dirname, '../template');
|
|
169
|
+
await fs.copy(templateDir, process.cwd(), { overwrite: true });
|
|
170
|
+
|
|
171
|
+
// 更新项目配置
|
|
172
|
+
await updateProjectConfig(projectName);
|
|
173
|
+
|
|
174
|
+
console.log();
|
|
175
|
+
console.log(chalk.green(t('cli.commands.init.success')));
|
|
176
|
+
console.log();
|
|
177
|
+
console.log(chalk.blue(t('cli.commands.init.nextSteps')));
|
|
178
|
+
console.log(' 1. ' + t('cli.commands.init.step1'));
|
|
179
|
+
console.log(' 2. ' + t('cli.commands.init.step2'));
|
|
180
|
+
console.log(' 3. ' + t('cli.commands.init.step3'));
|
|
181
|
+
console.log();
|
|
182
|
+
console.log(chalk.red('🔥') + ' ' + t('cli.commands.init.startJourney'));
|
|
183
|
+
} catch (error) {
|
|
184
|
+
console.error(chalk.red(t('cli.commands.init.error')), error.message);
|
|
185
|
+
process.exit(1);
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
// 增强文档命令
|
|
190
|
+
program
|
|
191
|
+
.command('enhance <stage> <file>')
|
|
192
|
+
.description('Enhance document quality with Ultrawork spirit')
|
|
193
|
+
.option('-r, --requirements <file>', 'Requirements file (needed for design stage)')
|
|
194
|
+
.action(async (stage, file, options) => {
|
|
195
|
+
console.log(chalk.red('🔥') + ` Starting ${stage} stage Ultrawork enhancement...`);
|
|
196
|
+
|
|
197
|
+
// 检查 Python 和工具是否可用
|
|
198
|
+
const toolPath = path.join(process.cwd(), '.kiro/tools/ultrawork_enhancer.py');
|
|
199
|
+
if (!fs.existsSync(toolPath)) {
|
|
200
|
+
console.error(chalk.red('❌ Ultrawork tool not found. Please run: sce init'));
|
|
201
|
+
process.exit(1);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// 构建 Python 命令
|
|
205
|
+
let args = [toolPath, stage, file];
|
|
206
|
+
if (stage === 'design' && options.requirements) {
|
|
207
|
+
args.push(options.requirements);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// 执行 Python 工具
|
|
211
|
+
const python = spawn('python', args, { stdio: 'inherit' });
|
|
212
|
+
|
|
213
|
+
python.on('close', (code) => {
|
|
214
|
+
if (code === 0) {
|
|
215
|
+
console.log(chalk.green('✅ Ultrawork enhancement completed!'));
|
|
216
|
+
} else {
|
|
217
|
+
console.error(chalk.red('❌ Enhancement failed with code:'), code);
|
|
218
|
+
process.exit(code);
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
python.on('error', (error) => {
|
|
223
|
+
console.error(chalk.red('❌ Error running Python tool:'), error.message);
|
|
224
|
+
console.log(chalk.yellow('💡 Make sure Python 3.8+ is installed and in PATH'));
|
|
225
|
+
process.exit(1);
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
// 创建 Spec 命令
|
|
230
|
+
program
|
|
231
|
+
.command('create-spec <spec-name>')
|
|
232
|
+
.alias('spec')
|
|
233
|
+
.description('Create a new spec directory')
|
|
234
|
+
.option('-t, --template <template-id>', 'Use a template from the library')
|
|
235
|
+
.option('-f, --force', 'Overwrite existing spec directory')
|
|
236
|
+
.action(async (specName, options) => {
|
|
237
|
+
const specPath = path.join(process.cwd(), '.kiro/specs', specName);
|
|
238
|
+
|
|
239
|
+
try {
|
|
240
|
+
// Check if using template
|
|
241
|
+
if (options.template) {
|
|
242
|
+
const TemplateManager = require('../lib/templates/template-manager');
|
|
243
|
+
const manager = new TemplateManager();
|
|
244
|
+
|
|
245
|
+
console.log(chalk.red('🔥') + ' Creating Spec from Template');
|
|
246
|
+
console.log();
|
|
247
|
+
console.log(` ${chalk.gray('Spec:')} ${specName}`);
|
|
248
|
+
console.log(` ${chalk.gray('Template:')} ${options.template}`);
|
|
249
|
+
console.log();
|
|
250
|
+
|
|
251
|
+
await manager.applyTemplate(specName, options.template, {
|
|
252
|
+
force: options.force
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
console.log(chalk.green('✅ Spec created successfully'));
|
|
256
|
+
console.log();
|
|
257
|
+
console.log(chalk.blue('📋 Next steps:'));
|
|
258
|
+
console.log(' 1. Review and customize the generated files');
|
|
259
|
+
console.log(' 2. Fill in project-specific details');
|
|
260
|
+
console.log(' 3. Start implementing tasks');
|
|
261
|
+
} else {
|
|
262
|
+
// Create empty spec directory
|
|
263
|
+
await fs.ensureDir(specPath);
|
|
264
|
+
console.log(chalk.green('✅ Created spec directory:'), specPath);
|
|
265
|
+
console.log();
|
|
266
|
+
console.log(chalk.blue('📋 Next steps:'));
|
|
267
|
+
console.log(' 1. Create requirements.md in the spec directory');
|
|
268
|
+
console.log(' 2. Enhance with: ' + chalk.cyan(`sce enhance requirements ${specPath}/requirements.md`));
|
|
269
|
+
console.log();
|
|
270
|
+
console.log(chalk.yellow('💡 Tip:'));
|
|
271
|
+
console.log(' Use a template: ' + chalk.cyan(`sce spec create ${specName} --template <template-id>`));
|
|
272
|
+
console.log(' Browse templates: ' + chalk.cyan('sce templates list'));
|
|
273
|
+
console.log(' Legacy alias (still works): ' + chalk.cyan('kse templates list'));
|
|
274
|
+
}
|
|
275
|
+
} catch (error) {
|
|
276
|
+
console.error(chalk.red('❌ Error creating spec:'), error.message);
|
|
277
|
+
if (error.suggestions) {
|
|
278
|
+
console.log();
|
|
279
|
+
console.log(chalk.yellow('💡 Suggestions:'));
|
|
280
|
+
error.suggestions.forEach(s => console.log(` • ${s}`));
|
|
281
|
+
}
|
|
282
|
+
process.exit(1);
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
// Spec bootstrap wizard command
|
|
287
|
+
registerSpecBootstrapCommand(program);
|
|
288
|
+
|
|
289
|
+
// Spec workflow pipeline command
|
|
290
|
+
registerSpecPipelineCommand(program);
|
|
291
|
+
|
|
292
|
+
// Spec gate command
|
|
293
|
+
registerSpecGateCommand(program);
|
|
294
|
+
|
|
295
|
+
// 系统诊断命令
|
|
296
|
+
program
|
|
297
|
+
.command('doctor')
|
|
298
|
+
.description(t('cli.commands.doctor.description'))
|
|
299
|
+
.option('--docs', 'Show detailed document governance diagnostics')
|
|
300
|
+
.option('--fix-gitignore', 'Check and fix .gitignore for team collaboration')
|
|
301
|
+
.action((options) => {
|
|
302
|
+
doctorCommand(options);
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
// 项目接管命令
|
|
306
|
+
program
|
|
307
|
+
.command('adopt')
|
|
308
|
+
.description('Adopt existing project into SCE (Scene Capability Engine)')
|
|
309
|
+
.option('--interactive', 'Enable interactive mode (legacy behavior with prompts)')
|
|
310
|
+
.option('--dry-run', 'Show what would change without making changes')
|
|
311
|
+
.option('--verbose', 'Show detailed logs')
|
|
312
|
+
.option('--no-backup', 'Skip backup creation (dangerous, not recommended)')
|
|
313
|
+
.option('--skip-update', 'Skip template file updates')
|
|
314
|
+
.option('--force', 'Force overwrite conflicting files (legacy, creates backup first)')
|
|
315
|
+
.option('--auto', 'Skip confirmations (legacy, use --interactive for old behavior)')
|
|
316
|
+
.option('--mode <mode>', 'Force specific adoption mode (legacy: fresh/partial/full)')
|
|
317
|
+
.action((options) => {
|
|
318
|
+
adoptCommand(options);
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
// 项目升级命令
|
|
322
|
+
program
|
|
323
|
+
.command('upgrade')
|
|
324
|
+
.description('Upgrade project to newer version')
|
|
325
|
+
.option('--auto', 'Skip confirmations (use with caution)')
|
|
326
|
+
.option('--dry-run', 'Show upgrade plan without making changes')
|
|
327
|
+
.option('--to <version>', 'Target version (default: current sce version)')
|
|
328
|
+
.action((options) => {
|
|
329
|
+
upgradeCommand(options);
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
// 回滚命令
|
|
333
|
+
program
|
|
334
|
+
.command('rollback')
|
|
335
|
+
.description('Restore project from backup')
|
|
336
|
+
.option('--auto', 'Skip confirmations (use with caution)')
|
|
337
|
+
.option('--backup <id>', 'Specific backup ID to restore')
|
|
338
|
+
.action((options) => {
|
|
339
|
+
rollbackCommand(options);
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
// 状态检查命令
|
|
343
|
+
const statusCommand = require('../lib/commands/status');
|
|
344
|
+
|
|
345
|
+
program
|
|
346
|
+
.command('status')
|
|
347
|
+
.description('Check project status and available specs')
|
|
348
|
+
.option('--verbose', 'Show detailed information')
|
|
349
|
+
.option('--team', 'Show team activity')
|
|
350
|
+
.action(async (options) => {
|
|
351
|
+
await statusCommand(options);
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
// 版本信息命令
|
|
355
|
+
program
|
|
356
|
+
.command('version-info')
|
|
357
|
+
.description('Display detailed version information')
|
|
358
|
+
.action(async () => {
|
|
359
|
+
const projectPath = process.cwd();
|
|
360
|
+
await versionChecker.displayVersionInfo(projectPath);
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
// Watch mode commands
|
|
364
|
+
const watchCmd = program
|
|
365
|
+
.command('watch')
|
|
366
|
+
.description('Manage watch mode for automated file monitoring');
|
|
367
|
+
|
|
368
|
+
watchCmd
|
|
369
|
+
.command('start')
|
|
370
|
+
.description('Start watch mode')
|
|
371
|
+
.option('-c, --config <path>', 'Custom config file path')
|
|
372
|
+
.option('-p, --patterns <patterns>', 'Override patterns (comma-separated)')
|
|
373
|
+
.action(watchCommands.startWatch);
|
|
374
|
+
|
|
375
|
+
watchCmd
|
|
376
|
+
.command('stop')
|
|
377
|
+
.description('Stop watch mode')
|
|
378
|
+
.action(watchCommands.stopWatch);
|
|
379
|
+
|
|
380
|
+
watchCmd
|
|
381
|
+
.command('status')
|
|
382
|
+
.description('Show watch mode status')
|
|
383
|
+
.action(watchCommands.statusWatch);
|
|
384
|
+
|
|
385
|
+
watchCmd
|
|
386
|
+
.command('logs')
|
|
387
|
+
.description('Display execution logs')
|
|
388
|
+
.option('-t, --tail <lines>', 'Number of lines to show', '50')
|
|
389
|
+
.option('-f, --follow', 'Follow mode (tail -f)')
|
|
390
|
+
.action(watchCommands.logsWatch);
|
|
391
|
+
|
|
392
|
+
watchCmd
|
|
393
|
+
.command('metrics')
|
|
394
|
+
.description('Display automation metrics')
|
|
395
|
+
.option('--format <format>', 'Output format (text/json)', 'text')
|
|
396
|
+
.action(watchCommands.metricsWatch);
|
|
397
|
+
|
|
398
|
+
watchCmd
|
|
399
|
+
.command('init')
|
|
400
|
+
.description('Initialize watch configuration')
|
|
401
|
+
.option('-f, --force', 'Overwrite existing config')
|
|
402
|
+
.action(watchCommands.initWatch);
|
|
403
|
+
|
|
404
|
+
watchCmd
|
|
405
|
+
.command('presets')
|
|
406
|
+
.description('List available watch presets')
|
|
407
|
+
.action(watchCommands.listPresetsWatch);
|
|
408
|
+
|
|
409
|
+
watchCmd
|
|
410
|
+
.command('install <preset>')
|
|
411
|
+
.description('Install a watch preset')
|
|
412
|
+
.option('-f, --force', 'Overwrite existing actions')
|
|
413
|
+
.action(watchCommands.installPresetWatch);
|
|
414
|
+
|
|
415
|
+
// Workflows commands
|
|
416
|
+
const workflowsCmd = program
|
|
417
|
+
.command('workflows [action] [workflow-id]')
|
|
418
|
+
.description('Manage manual workflows and checklists')
|
|
419
|
+
.action(async (action, workflowId) => {
|
|
420
|
+
await workflowsCommand(action, workflowId);
|
|
421
|
+
});
|
|
422
|
+
|
|
423
|
+
// Document governance commands
|
|
424
|
+
const docsCommand = require('../lib/commands/docs');
|
|
425
|
+
|
|
426
|
+
const docsCmd = program
|
|
427
|
+
.command('docs')
|
|
428
|
+
.description('Document governance and lifecycle management');
|
|
429
|
+
|
|
430
|
+
docsCmd
|
|
431
|
+
.command('diagnose')
|
|
432
|
+
.alias('diagnostic')
|
|
433
|
+
.description('Scan project for document violations')
|
|
434
|
+
.action(async () => {
|
|
435
|
+
const exitCode = await docsCommand('diagnose');
|
|
436
|
+
process.exit(exitCode);
|
|
437
|
+
});
|
|
438
|
+
|
|
439
|
+
docsCmd
|
|
440
|
+
.command('cleanup')
|
|
441
|
+
.description('Remove temporary documents')
|
|
442
|
+
.option('--dry-run, --dry', 'Preview changes without applying them')
|
|
443
|
+
.option('-i, --interactive', 'Prompt for confirmation before each deletion')
|
|
444
|
+
.option('--spec <name>', 'Target specific Spec directory')
|
|
445
|
+
.action(async (options) => {
|
|
446
|
+
const exitCode = await docsCommand('cleanup', options);
|
|
447
|
+
process.exit(exitCode);
|
|
448
|
+
});
|
|
449
|
+
|
|
450
|
+
docsCmd
|
|
451
|
+
.command('validate')
|
|
452
|
+
.description('Validate document structure')
|
|
453
|
+
.option('--spec <name>', 'Validate specific Spec directory')
|
|
454
|
+
.option('--all', 'Validate all Spec directories')
|
|
455
|
+
.action(async (options) => {
|
|
456
|
+
const exitCode = await docsCommand('validate', options);
|
|
457
|
+
process.exit(exitCode);
|
|
458
|
+
});
|
|
459
|
+
|
|
460
|
+
docsCmd
|
|
461
|
+
.command('archive')
|
|
462
|
+
.description('Organize Spec artifacts into subdirectories')
|
|
463
|
+
.option('--spec <name>', 'Target Spec directory (required)')
|
|
464
|
+
.option('--dry-run, --dry', 'Preview changes without applying them')
|
|
465
|
+
.action(async (options) => {
|
|
466
|
+
const exitCode = await docsCommand('archive', options);
|
|
467
|
+
process.exit(exitCode);
|
|
468
|
+
});
|
|
469
|
+
|
|
470
|
+
docsCmd
|
|
471
|
+
.command('hooks <action>')
|
|
472
|
+
.description('Manage Git hooks (install, uninstall, status)')
|
|
473
|
+
.action(async (action) => {
|
|
474
|
+
const exitCode = await docsCommand('hooks', { _: [action] });
|
|
475
|
+
process.exit(exitCode);
|
|
476
|
+
});
|
|
477
|
+
|
|
478
|
+
docsCmd
|
|
479
|
+
.command('config [key] [value]')
|
|
480
|
+
.description('Display or modify configuration')
|
|
481
|
+
.option('--set', 'Set configuration value (use with key and value arguments)')
|
|
482
|
+
.option('--reset', 'Reset configuration to defaults')
|
|
483
|
+
.action(async (key, value, options) => {
|
|
484
|
+
// Build options object for the docs command
|
|
485
|
+
const cmdOptions = {
|
|
486
|
+
set: options.set,
|
|
487
|
+
reset: options.reset,
|
|
488
|
+
_: ['config']
|
|
489
|
+
};
|
|
490
|
+
|
|
491
|
+
// Add key and value if provided
|
|
492
|
+
if (key) cmdOptions._.push(key);
|
|
493
|
+
if (value) cmdOptions._.push(value);
|
|
494
|
+
|
|
495
|
+
const exitCode = await docsCommand('config', cmdOptions);
|
|
496
|
+
process.exit(exitCode);
|
|
497
|
+
});
|
|
498
|
+
|
|
499
|
+
docsCmd
|
|
500
|
+
.command('stats')
|
|
501
|
+
.description('Display compliance statistics')
|
|
502
|
+
.action(async () => {
|
|
503
|
+
const exitCode = await docsCommand('stats');
|
|
504
|
+
process.exit(exitCode);
|
|
505
|
+
});
|
|
506
|
+
|
|
507
|
+
docsCmd
|
|
508
|
+
.command('report')
|
|
509
|
+
.description('Generate compliance report')
|
|
510
|
+
.action(async () => {
|
|
511
|
+
const exitCode = await docsCommand('report');
|
|
512
|
+
process.exit(exitCode);
|
|
513
|
+
});
|
|
514
|
+
|
|
515
|
+
docsCmd
|
|
516
|
+
.command('check-refs')
|
|
517
|
+
.alias('check-references')
|
|
518
|
+
.description('Check for incorrect project references and placeholders')
|
|
519
|
+
.option('--report', 'Save report to file')
|
|
520
|
+
.option('--verbose', 'Show detailed error information')
|
|
521
|
+
.action(async (options) => {
|
|
522
|
+
const exitCode = await docsCommand('check-refs', options);
|
|
523
|
+
process.exit(exitCode);
|
|
524
|
+
});
|
|
525
|
+
|
|
526
|
+
// DevOps integration commands
|
|
527
|
+
const opsCommand = require('../lib/commands/ops');
|
|
528
|
+
|
|
529
|
+
const opsCmd = program
|
|
530
|
+
.command('ops <subcommand> [args...]')
|
|
531
|
+
.description('DevOps integration foundation commands');
|
|
532
|
+
|
|
533
|
+
// Note: The ops command handles its own subcommand routing internally
|
|
534
|
+
opsCmd.action(async (subcommand, args, options) => {
|
|
535
|
+
await opsCommand(subcommand, args, options);
|
|
536
|
+
});
|
|
537
|
+
|
|
538
|
+
// Multi-workspace management commands
|
|
539
|
+
const workspaceCommand = require('../lib/commands/workspace-multi');
|
|
540
|
+
|
|
541
|
+
const workspaceCmd = program
|
|
542
|
+
.command('workspace')
|
|
543
|
+
.description('Manage multiple SCE project workspaces');
|
|
544
|
+
|
|
545
|
+
workspaceCmd
|
|
546
|
+
.command('create <name>')
|
|
547
|
+
.description('Create a new workspace')
|
|
548
|
+
.option('-p, --path <path>', 'Workspace path (defaults to current directory)')
|
|
549
|
+
.action(async (name, options) => {
|
|
550
|
+
await workspaceCommand.createWorkspace(name, options);
|
|
551
|
+
});
|
|
552
|
+
|
|
553
|
+
workspaceCmd
|
|
554
|
+
.command('list')
|
|
555
|
+
.alias('ls')
|
|
556
|
+
.description('List all workspaces')
|
|
557
|
+
.option('-v, --verbose', 'Show detailed information')
|
|
558
|
+
.action(async (options) => {
|
|
559
|
+
await workspaceCommand.listWorkspaces(options);
|
|
560
|
+
});
|
|
561
|
+
|
|
562
|
+
workspaceCmd
|
|
563
|
+
.command('switch <name>')
|
|
564
|
+
.description('Switch to a workspace')
|
|
565
|
+
.action(async (name) => {
|
|
566
|
+
await workspaceCommand.switchWorkspace(name);
|
|
567
|
+
});
|
|
568
|
+
|
|
569
|
+
workspaceCmd
|
|
570
|
+
.command('remove <name>')
|
|
571
|
+
.alias('rm')
|
|
572
|
+
.description('Remove a workspace')
|
|
573
|
+
.option('-f, --force', 'Skip confirmation prompt')
|
|
574
|
+
.action(async (name, options) => {
|
|
575
|
+
await workspaceCommand.removeWorkspace(name, options);
|
|
576
|
+
});
|
|
577
|
+
|
|
578
|
+
workspaceCmd
|
|
579
|
+
.command('info [name]')
|
|
580
|
+
.description('Show workspace information (defaults to current workspace)')
|
|
581
|
+
.action(async (name) => {
|
|
582
|
+
await workspaceCommand.infoWorkspace(name);
|
|
583
|
+
});
|
|
584
|
+
|
|
585
|
+
// Environment configuration management commands
|
|
586
|
+
const envCommand = require('../lib/commands/env');
|
|
587
|
+
|
|
588
|
+
const envCmd = program
|
|
589
|
+
.command('env <subcommand> [args...]')
|
|
590
|
+
.description('Manage environment configurations');
|
|
591
|
+
|
|
592
|
+
envCmd.action(async (subcommand, args, options) => {
|
|
593
|
+
const exitCode = await envCommand.handleCommand([subcommand, ...args]);
|
|
594
|
+
process.exit(exitCode);
|
|
595
|
+
});
|
|
596
|
+
|
|
597
|
+
// Multi-repository management commands
|
|
598
|
+
const repoCommand = require('../lib/commands/repo');
|
|
599
|
+
|
|
600
|
+
const repoCmd = program
|
|
601
|
+
.command('repo')
|
|
602
|
+
.description('Manage multiple Git subrepositories');
|
|
603
|
+
|
|
604
|
+
repoCmd
|
|
605
|
+
.command('init')
|
|
606
|
+
.description('Initialize repository configuration')
|
|
607
|
+
.option('-y, --yes', 'Skip confirmation prompts')
|
|
608
|
+
.option('--max-depth <depth>', 'Maximum scan depth', parseInt)
|
|
609
|
+
.option('--exclude <paths>', 'Comma-separated paths to exclude')
|
|
610
|
+
.option('--nested', 'Enable nested repository scanning (default)')
|
|
611
|
+
.option('--no-nested', 'Disable nested repository scanning')
|
|
612
|
+
.action(async (options) => {
|
|
613
|
+
await repoCommand.initRepo(options);
|
|
614
|
+
});
|
|
615
|
+
|
|
616
|
+
repoCmd
|
|
617
|
+
.command('status')
|
|
618
|
+
.description('Display repository status')
|
|
619
|
+
.option('-v, --verbose', 'Show detailed status')
|
|
620
|
+
.action(async (options) => {
|
|
621
|
+
await repoCommand.statusRepo(options);
|
|
622
|
+
});
|
|
623
|
+
|
|
624
|
+
repoCmd
|
|
625
|
+
.command('exec <command>')
|
|
626
|
+
.description('Execute command across repositories')
|
|
627
|
+
.option('--dry-run', 'Show commands without executing')
|
|
628
|
+
.action(async (command, options) => {
|
|
629
|
+
await repoCommand.execRepo(command, options);
|
|
630
|
+
});
|
|
631
|
+
|
|
632
|
+
repoCmd
|
|
633
|
+
.command('health')
|
|
634
|
+
.description('Check repository health')
|
|
635
|
+
.action(async (options) => {
|
|
636
|
+
await repoCommand.healthRepo(options);
|
|
637
|
+
});
|
|
638
|
+
|
|
639
|
+
// Spec-level collaboration commands
|
|
640
|
+
registerCollabCommands(program);
|
|
641
|
+
|
|
642
|
+
// Autonomous control commands
|
|
643
|
+
const { registerAutoCommands } = require('../lib/commands/auto');
|
|
644
|
+
registerAutoCommands(program);
|
|
645
|
+
|
|
646
|
+
// Scene runtime commands
|
|
647
|
+
const { registerSceneCommands } = require('../lib/commands/scene');
|
|
648
|
+
registerSceneCommands(program);
|
|
649
|
+
|
|
650
|
+
// Lock commands for multi-user collaboration
|
|
651
|
+
const { registerLockCommands } = require('../lib/commands/lock');
|
|
652
|
+
registerLockCommands(program);
|
|
653
|
+
|
|
654
|
+
// Knowledge management commands
|
|
655
|
+
const { registerKnowledgeCommands } = require('../lib/commands/knowledge');
|
|
656
|
+
registerKnowledgeCommands(program);
|
|
657
|
+
|
|
658
|
+
// Orchestration commands
|
|
659
|
+
const { registerOrchestrateCommands } = require('../lib/commands/orchestrate');
|
|
660
|
+
registerOrchestrateCommands(program);
|
|
661
|
+
|
|
662
|
+
// Value realization and observability commands
|
|
663
|
+
registerValueCommands(program);
|
|
664
|
+
|
|
665
|
+
// Template management commands
|
|
666
|
+
const templatesCommand = require('../lib/commands/templates');
|
|
667
|
+
|
|
668
|
+
const templatesCmd = program
|
|
669
|
+
.command('templates')
|
|
670
|
+
.description('Manage Spec templates from official and custom sources');
|
|
671
|
+
|
|
672
|
+
templatesCmd
|
|
673
|
+
.command('list')
|
|
674
|
+
.description('List all available templates')
|
|
675
|
+
.option('--category <category>', 'Filter by category')
|
|
676
|
+
.option('--source <source>', 'Filter by source')
|
|
677
|
+
.action(async (options) => {
|
|
678
|
+
await templatesCommand.listTemplates(options);
|
|
679
|
+
});
|
|
680
|
+
|
|
681
|
+
templatesCmd
|
|
682
|
+
.command('search <keyword>')
|
|
683
|
+
.description('Search templates by keyword')
|
|
684
|
+
.option('--category <category>', 'Filter by category')
|
|
685
|
+
.action(async (keyword, options) => {
|
|
686
|
+
await templatesCommand.searchTemplates(keyword, options);
|
|
687
|
+
});
|
|
688
|
+
|
|
689
|
+
templatesCmd
|
|
690
|
+
.command('show <template-path>')
|
|
691
|
+
.description('Show template details')
|
|
692
|
+
.action(async (templatePath) => {
|
|
693
|
+
await templatesCommand.showTemplate(templatePath);
|
|
694
|
+
});
|
|
695
|
+
|
|
696
|
+
templatesCmd
|
|
697
|
+
.command('update')
|
|
698
|
+
.description('Update templates from sources')
|
|
699
|
+
.option('--source <source>', 'Update specific source only')
|
|
700
|
+
.option('--version <version>', 'Checkout specific version/tag')
|
|
701
|
+
.action(async (options) => {
|
|
702
|
+
await templatesCommand.updateTemplates(options);
|
|
703
|
+
});
|
|
704
|
+
|
|
705
|
+
templatesCmd
|
|
706
|
+
.command('add-source <name> <git-url>')
|
|
707
|
+
.description('Add custom template source')
|
|
708
|
+
.action(async (name, gitUrl) => {
|
|
709
|
+
await templatesCommand.addSource(name, gitUrl);
|
|
710
|
+
});
|
|
711
|
+
|
|
712
|
+
templatesCmd
|
|
713
|
+
.command('remove-source <name>')
|
|
714
|
+
.description('Remove template source')
|
|
715
|
+
.action(async (name) => {
|
|
716
|
+
await templatesCommand.removeSource(name);
|
|
717
|
+
});
|
|
718
|
+
|
|
719
|
+
templatesCmd
|
|
720
|
+
.command('sources')
|
|
721
|
+
.description('List configured template sources')
|
|
722
|
+
.action(async () => {
|
|
723
|
+
await templatesCommand.listSources();
|
|
724
|
+
});
|
|
725
|
+
|
|
726
|
+
templatesCmd
|
|
727
|
+
.command('cache')
|
|
728
|
+
.description('Manage template cache')
|
|
729
|
+
.option('--clear', 'Clear cache')
|
|
730
|
+
.option('--source <source>', 'Target specific source')
|
|
731
|
+
.action(async (options) => {
|
|
732
|
+
await templatesCommand.cacheCommand(options);
|
|
733
|
+
});
|
|
734
|
+
|
|
735
|
+
templatesCmd
|
|
736
|
+
.command('guide')
|
|
737
|
+
.description('Display template usage guide')
|
|
738
|
+
.action(async () => {
|
|
739
|
+
await templatesCommand.displayGuide();
|
|
740
|
+
});
|
|
741
|
+
|
|
742
|
+
templatesCmd
|
|
743
|
+
.command('create-from-spec')
|
|
744
|
+
.description('Create template from existing Spec')
|
|
745
|
+
.option('--spec <identifier>', 'Spec identifier (number or name)')
|
|
746
|
+
.option('--output <path>', 'Custom output directory')
|
|
747
|
+
.option('--preview', 'Show diff before export')
|
|
748
|
+
.option('--dry-run', 'Simulate without writing files')
|
|
749
|
+
.option('--no-interactive', 'Use defaults for all prompts')
|
|
750
|
+
.action(async (options) => {
|
|
751
|
+
await templatesCommand.createFromSpec(options);
|
|
752
|
+
});
|
|
753
|
+
|
|
754
|
+
// 更新项目配置的辅助函数
|
|
755
|
+
async function updateProjectConfig(projectName) {
|
|
756
|
+
const envPath = path.join(process.cwd(), '.kiro/steering/ENVIRONMENT.md');
|
|
757
|
+
const contextPath = path.join(process.cwd(), '.kiro/steering/CURRENT_CONTEXT.md');
|
|
758
|
+
|
|
759
|
+
// 更新 ENVIRONMENT.md
|
|
760
|
+
if (fs.existsSync(envPath)) {
|
|
761
|
+
let content = await fs.readFile(envPath, 'utf8');
|
|
762
|
+
content = content.replace(/\[请修改为你的项目名称\]/g, projectName);
|
|
763
|
+
await fs.writeFile(envPath, content);
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
// 更新 CURRENT_CONTEXT.md
|
|
767
|
+
if (fs.existsSync(contextPath)) {
|
|
768
|
+
let content = await fs.readFile(contextPath, 'utf8');
|
|
769
|
+
content = content.replace(/新项目/g, projectName);
|
|
770
|
+
await fs.writeFile(contextPath, content);
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
// Run steering directory compliance check before parsing commands
|
|
775
|
+
(async function() {
|
|
776
|
+
const { runSteeringComplianceCheck } = require('../lib/steering');
|
|
777
|
+
const normalizedArgs = normalizeSpecCommandArgs(process.argv.slice(2));
|
|
778
|
+
process.argv = [process.argv[0], process.argv[1], ...normalizedArgs];
|
|
779
|
+
|
|
780
|
+
// Check for bypass flags
|
|
781
|
+
const args = process.argv.slice(2);
|
|
782
|
+
const skipCheck = args.includes('--skip-steering-check') ||
|
|
783
|
+
process.env.KSE_SKIP_STEERING_CHECK === '1';
|
|
784
|
+
const forceCheck = args.includes('--force-steering-check');
|
|
785
|
+
|
|
786
|
+
// Run compliance check
|
|
787
|
+
await runSteeringComplianceCheck({
|
|
788
|
+
skip: skipCheck,
|
|
789
|
+
force: forceCheck,
|
|
790
|
+
projectPath: process.cwd(),
|
|
791
|
+
version: packageJson.version
|
|
792
|
+
});
|
|
793
|
+
|
|
794
|
+
// 解析命令行参数
|
|
795
|
+
program.parse();
|
|
796
|
+
})();
|