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.
Files changed (336) hide show
  1. package/CHANGELOG.md +2513 -0
  2. package/LICENSE +21 -0
  3. package/README.md +765 -0
  4. package/README.zh.md +630 -0
  5. package/bin/kiro-spec-engine.js +796 -0
  6. package/bin/kse.js +3 -0
  7. package/bin/sce.js +3 -0
  8. package/bin/sco.js +3 -0
  9. package/docs/331-poc-adaptation-roadmap.md +156 -0
  10. package/docs/331-poc-dual-track-integration-guide.md +120 -0
  11. package/docs/331-poc-weekly-delivery-checklist.md +52 -0
  12. package/docs/OFFLINE_INSTALL.md +96 -0
  13. package/docs/README.md +279 -0
  14. package/docs/adopt-migration-guide.md +599 -0
  15. package/docs/adoption-guide.md +616 -0
  16. package/docs/agent-hooks-analysis.md +815 -0
  17. package/docs/architecture.md +733 -0
  18. package/docs/articles/ai-driven-development-philosophy-and-practice-review.md +208 -0
  19. package/docs/articles/ai-driven-development-philosophy-and-practice.en.md +459 -0
  20. package/docs/articles/ai-driven-development-philosophy-and-practice.md +492 -0
  21. package/docs/autonomous-control-guide.md +851 -0
  22. package/docs/command-reference.md +1368 -0
  23. package/docs/community.md +115 -0
  24. package/docs/cross-tool-guide.md +555 -0
  25. package/docs/developer-guide.md +619 -0
  26. package/docs/document-governance.md +865 -0
  27. package/docs/environment-management-guide.md +526 -0
  28. package/docs/examples/add-export-command/design.md +194 -0
  29. package/docs/examples/add-export-command/requirements.md +110 -0
  30. package/docs/examples/add-export-command/tasks.md +88 -0
  31. package/docs/examples/add-rest-api/design.md +855 -0
  32. package/docs/examples/add-rest-api/requirements.md +323 -0
  33. package/docs/examples/add-rest-api/tasks.md +355 -0
  34. package/docs/examples/add-user-dashboard/design.md +192 -0
  35. package/docs/examples/add-user-dashboard/requirements.md +143 -0
  36. package/docs/examples/add-user-dashboard/tasks.md +91 -0
  37. package/docs/faq.md +697 -0
  38. package/docs/handoffs/evidence/ontology/moqui-template-baseline-2026-02-17-232922.json +156 -0
  39. package/docs/handoffs/evidence/ontology/moqui-template-baseline-2026-02-17-232922.md +24 -0
  40. package/docs/images/wechat-qr.png +0 -0
  41. package/docs/integration-modes.md +529 -0
  42. package/docs/integration-philosophy.md +313 -0
  43. package/docs/knowledge-management-guide.md +263 -0
  44. package/docs/manual-workflows-guide.md +418 -0
  45. package/docs/moqui-capability-matrix.md +73 -0
  46. package/docs/moqui-template-core-library-playbook.md +109 -0
  47. package/docs/multi-agent-coordination-guide.md +553 -0
  48. package/docs/multi-repo-management-guide.md +1344 -0
  49. package/docs/quick-start-with-ai-tools.md +375 -0
  50. package/docs/quick-start.md +146 -0
  51. package/docs/release-checklist.md +121 -0
  52. package/docs/releases/README.md +13 -0
  53. package/docs/releases/v1.46.2-validation.md +45 -0
  54. package/docs/releases/v1.46.2.md +50 -0
  55. package/docs/scene-runtime-guide.md +347 -0
  56. package/docs/spec-collaboration-guide.md +369 -0
  57. package/docs/spec-locking-guide.md +225 -0
  58. package/docs/spec-numbering-guide.md +348 -0
  59. package/docs/spec-workflow.md +519 -0
  60. package/docs/steering-strategy-guide.md +196 -0
  61. package/docs/team-collaboration-guide.md +465 -0
  62. package/docs/testing-strategy.md +272 -0
  63. package/docs/tools/claude-guide.md +654 -0
  64. package/docs/tools/cursor-guide.md +706 -0
  65. package/docs/tools/generic-guide.md +446 -0
  66. package/docs/tools/kiro-guide.md +308 -0
  67. package/docs/tools/vscode-guide.md +445 -0
  68. package/docs/tools/windsurf-guide.md +391 -0
  69. package/docs/troubleshooting.md +1135 -0
  70. package/docs/upgrade-guide.md +639 -0
  71. package/docs/value-observability-guide.md +127 -0
  72. package/docs/zh/README.md +341 -0
  73. package/docs/zh/quick-start.md +764 -0
  74. package/docs/zh/release-checklist.md +121 -0
  75. package/docs/zh/releases/README.md +13 -0
  76. package/docs/zh/releases/v1.46.2-validation.md +45 -0
  77. package/docs/zh/releases/v1.46.2.md +50 -0
  78. package/docs/zh/spec-numbering-guide.md +348 -0
  79. package/docs/zh/tools/claude-guide.md +349 -0
  80. package/docs/zh/tools/cursor-guide.md +281 -0
  81. package/docs/zh/tools/generic-guide.md +499 -0
  82. package/docs/zh/tools/kiro-guide.md +342 -0
  83. package/docs/zh/tools/vscode-guide.md +449 -0
  84. package/docs/zh/tools/windsurf-guide.md +378 -0
  85. package/docs/zh/value-observability-guide.md +127 -0
  86. package/docs//344/272/244/344/273/230/346/270/205/345/215/225.md +75 -0
  87. package/lib/adoption/adoption-logger.js +487 -0
  88. package/lib/adoption/adoption-strategy.js +538 -0
  89. package/lib/adoption/backup-manager.js +420 -0
  90. package/lib/adoption/conflict-resolver.js +410 -0
  91. package/lib/adoption/detection-engine.js +275 -0
  92. package/lib/adoption/diff-viewer.js +226 -0
  93. package/lib/adoption/error-formatter.js +509 -0
  94. package/lib/adoption/file-classifier.js +385 -0
  95. package/lib/adoption/progress-reporter.js +534 -0
  96. package/lib/adoption/smart-orchestrator.js +470 -0
  97. package/lib/adoption/strategy-selector.js +218 -0
  98. package/lib/adoption/summary-generator.js +493 -0
  99. package/lib/adoption/template-sync.js +605 -0
  100. package/lib/auto/autonomous-engine.js +485 -0
  101. package/lib/auto/checkpoint-manager.js +300 -0
  102. package/lib/auto/close-loop-runner.js +2476 -0
  103. package/lib/auto/config-schema.js +176 -0
  104. package/lib/auto/decision-engine.js +344 -0
  105. package/lib/auto/error-recovery-manager.js +580 -0
  106. package/lib/auto/goal-decomposer.js +278 -0
  107. package/lib/auto/progress-tracker.js +502 -0
  108. package/lib/auto/safety-manager.js +186 -0
  109. package/lib/auto/semantic-decomposer.js +137 -0
  110. package/lib/auto/state-manager.js +126 -0
  111. package/lib/auto/task-queue-manager.js +340 -0
  112. package/lib/backup/backup-system.js +372 -0
  113. package/lib/backup/selective-backup.js +207 -0
  114. package/lib/collab/agent-registry.js +240 -0
  115. package/lib/collab/collab-manager.js +285 -0
  116. package/lib/collab/contract-manager.js +320 -0
  117. package/lib/collab/coordinator.js +370 -0
  118. package/lib/collab/dependency-manager.js +280 -0
  119. package/lib/collab/index.js +20 -0
  120. package/lib/collab/integration-manager.js +202 -0
  121. package/lib/collab/merge-coordinator.js +252 -0
  122. package/lib/collab/metadata-manager.js +233 -0
  123. package/lib/collab/multi-agent-config.js +120 -0
  124. package/lib/collab/spec-lifecycle-manager.js +304 -0
  125. package/lib/collab/sync-barrier.js +88 -0
  126. package/lib/collab/visualizer.js +208 -0
  127. package/lib/commands/adopt.js +749 -0
  128. package/lib/commands/auto.js +19559 -0
  129. package/lib/commands/collab.js +275 -0
  130. package/lib/commands/context.js +99 -0
  131. package/lib/commands/docs.js +808 -0
  132. package/lib/commands/doctor.js +273 -0
  133. package/lib/commands/env.js +420 -0
  134. package/lib/commands/knowledge.js +309 -0
  135. package/lib/commands/lock.js +235 -0
  136. package/lib/commands/ops.js +409 -0
  137. package/lib/commands/orchestrate.js +446 -0
  138. package/lib/commands/prompt.js +105 -0
  139. package/lib/commands/repo.js +118 -0
  140. package/lib/commands/rollback.js +219 -0
  141. package/lib/commands/scene.js +15549 -0
  142. package/lib/commands/spec-bootstrap.js +147 -0
  143. package/lib/commands/spec-gate.js +157 -0
  144. package/lib/commands/spec-pipeline.js +205 -0
  145. package/lib/commands/status.js +321 -0
  146. package/lib/commands/task.js +199 -0
  147. package/lib/commands/templates.js +654 -0
  148. package/lib/commands/upgrade.js +231 -0
  149. package/lib/commands/value.js +569 -0
  150. package/lib/commands/watch.js +684 -0
  151. package/lib/commands/workflows.js +240 -0
  152. package/lib/commands/workspace-multi.js +325 -0
  153. package/lib/commands/workspace.js +189 -0
  154. package/lib/context/context-exporter.js +378 -0
  155. package/lib/context/prompt-generator.js +482 -0
  156. package/lib/data/moqui-capability-lexicon.json +45 -0
  157. package/lib/environment/backup-system.js +189 -0
  158. package/lib/environment/environment-manager.js +379 -0
  159. package/lib/environment/environment-registry.js +168 -0
  160. package/lib/gitignore/gitignore-backup.js +229 -0
  161. package/lib/gitignore/gitignore-detector.js +239 -0
  162. package/lib/gitignore/gitignore-integration.js +267 -0
  163. package/lib/gitignore/gitignore-transformer.js +193 -0
  164. package/lib/gitignore/layered-rules-template.js +42 -0
  165. package/lib/governance/archive-tool.js +284 -0
  166. package/lib/governance/cleanup-tool.js +237 -0
  167. package/lib/governance/config-manager.js +186 -0
  168. package/lib/governance/diagnostic-engine.js +271 -0
  169. package/lib/governance/doc-reference-checker.js +200 -0
  170. package/lib/governance/execution-logger.js +243 -0
  171. package/lib/governance/file-scanner.js +285 -0
  172. package/lib/governance/hooks-manager.js +333 -0
  173. package/lib/governance/reporter.js +337 -0
  174. package/lib/governance/validation-engine.js +181 -0
  175. package/lib/i18n.js +79 -0
  176. package/lib/knowledge/entry-manager.js +208 -0
  177. package/lib/knowledge/index-manager.js +261 -0
  178. package/lib/knowledge/knowledge-manager.js +273 -0
  179. package/lib/knowledge/template-manager.js +191 -0
  180. package/lib/lock/index.js +21 -0
  181. package/lib/lock/lock-file.js +192 -0
  182. package/lib/lock/lock-manager.js +321 -0
  183. package/lib/lock/machine-identifier.js +135 -0
  184. package/lib/lock/steering-file-lock.js +207 -0
  185. package/lib/lock/task-lock-manager.js +345 -0
  186. package/lib/operations/audit-logger.js +293 -0
  187. package/lib/operations/feedback-manager.js +1147 -0
  188. package/lib/operations/index.js +23 -0
  189. package/lib/operations/models/index.js +170 -0
  190. package/lib/operations/operations-manager.js +151 -0
  191. package/lib/operations/operations-validator.js +280 -0
  192. package/lib/operations/permission-manager.js +354 -0
  193. package/lib/operations/template-loader.js +143 -0
  194. package/lib/orchestrator/agent-spawner.js +629 -0
  195. package/lib/orchestrator/bootstrap-prompt-builder.js +236 -0
  196. package/lib/orchestrator/index.js +19 -0
  197. package/lib/orchestrator/orchestration-engine.js +1270 -0
  198. package/lib/orchestrator/orchestrator-config.js +173 -0
  199. package/lib/orchestrator/status-monitor.js +591 -0
  200. package/lib/python-checker.js +209 -0
  201. package/lib/repo/config-manager.js +580 -0
  202. package/lib/repo/errors/config-error.js +13 -0
  203. package/lib/repo/errors/git-error.js +15 -0
  204. package/lib/repo/errors/repo-error.js +14 -0
  205. package/lib/repo/git-operations.js +181 -0
  206. package/lib/repo/handlers/.gitkeep +1 -0
  207. package/lib/repo/handlers/exec-handler.js +155 -0
  208. package/lib/repo/handlers/health-handler.js +169 -0
  209. package/lib/repo/handlers/init-handler.js +197 -0
  210. package/lib/repo/handlers/status-handler.js +176 -0
  211. package/lib/repo/output-formatter.js +184 -0
  212. package/lib/repo/path-resolver.js +178 -0
  213. package/lib/repo/repo-manager.js +514 -0
  214. package/lib/scene-runtime/audit-emitter.js +59 -0
  215. package/lib/scene-runtime/binding-plugin-loader.js +351 -0
  216. package/lib/scene-runtime/binding-registry.js +349 -0
  217. package/lib/scene-runtime/eval-bridge.js +44 -0
  218. package/lib/scene-runtime/index.js +19 -0
  219. package/lib/scene-runtime/moqui-adapter.js +620 -0
  220. package/lib/scene-runtime/moqui-client.js +606 -0
  221. package/lib/scene-runtime/moqui-extractor.js +2029 -0
  222. package/lib/scene-runtime/plan-compiler.js +208 -0
  223. package/lib/scene-runtime/policy-gate.js +58 -0
  224. package/lib/scene-runtime/runtime-executor.js +358 -0
  225. package/lib/scene-runtime/scene-loader.js +96 -0
  226. package/lib/scene-runtime/scene-ontology.js +959 -0
  227. package/lib/scene-runtime/scene-template-linter.js +852 -0
  228. package/lib/scene-runtime/templates/scene-template-erp-query-v0.1.yaml +28 -0
  229. package/lib/scene-runtime/templates/scene-template-hybrid-shadow-v0.1.yaml +34 -0
  230. package/lib/spec/bootstrap/context-collector.js +48 -0
  231. package/lib/spec/bootstrap/draft-generator.js +158 -0
  232. package/lib/spec/bootstrap/questionnaire-engine.js +70 -0
  233. package/lib/spec/bootstrap/trace-emitter.js +59 -0
  234. package/lib/spec/multi-spec-orchestrate.js +93 -0
  235. package/lib/spec/pipeline/constants.js +6 -0
  236. package/lib/spec/pipeline/stage-adapters.js +118 -0
  237. package/lib/spec/pipeline/stage-runner.js +146 -0
  238. package/lib/spec/pipeline/state-store.js +119 -0
  239. package/lib/spec-gate/engine/gate-engine.js +165 -0
  240. package/lib/spec-gate/policy/default-policy.js +22 -0
  241. package/lib/spec-gate/policy/policy-loader.js +103 -0
  242. package/lib/spec-gate/result-emitter.js +81 -0
  243. package/lib/spec-gate/rules/default-rules.js +156 -0
  244. package/lib/spec-gate/rules/rule-registry.js +51 -0
  245. package/lib/steering/adoption-config.js +164 -0
  246. package/lib/steering/compliance-auto-fixer.js +204 -0
  247. package/lib/steering/compliance-cache.js +99 -0
  248. package/lib/steering/compliance-error-reporter.js +70 -0
  249. package/lib/steering/context-sync-manager.js +273 -0
  250. package/lib/steering/index.js +92 -0
  251. package/lib/steering/spec-steering.js +230 -0
  252. package/lib/steering/steering-compliance-checker.js +73 -0
  253. package/lib/steering/steering-loader.js +144 -0
  254. package/lib/steering/steering-manager.js +289 -0
  255. package/lib/task/index.js +12 -0
  256. package/lib/task/task-claimer.js +489 -0
  257. package/lib/task/task-status-store.js +418 -0
  258. package/lib/templates/cache-manager.js +440 -0
  259. package/lib/templates/content-generalizer.js +247 -0
  260. package/lib/templates/frontmatter-generator.js +128 -0
  261. package/lib/templates/git-handler.js +471 -0
  262. package/lib/templates/metadata-collector.js +328 -0
  263. package/lib/templates/path-utils.js +144 -0
  264. package/lib/templates/registry-parser.js +505 -0
  265. package/lib/templates/spec-reader.js +216 -0
  266. package/lib/templates/template-applicator.js +249 -0
  267. package/lib/templates/template-creator.js +256 -0
  268. package/lib/templates/template-error.js +143 -0
  269. package/lib/templates/template-exporter.js +502 -0
  270. package/lib/templates/template-manager.js +782 -0
  271. package/lib/templates/template-validator.js +361 -0
  272. package/lib/upgrade/migration-engine.js +382 -0
  273. package/lib/upgrade/migrations/.gitkeep +52 -0
  274. package/lib/upgrade/migrations/1.0.0-to-1.1.0.js +78 -0
  275. package/lib/utils/file-diff.js +177 -0
  276. package/lib/utils/fs-utils.js +274 -0
  277. package/lib/utils/tool-detector.js +383 -0
  278. package/lib/utils/validation.js +324 -0
  279. package/lib/value/gate-summary-emitter.js +99 -0
  280. package/lib/value/metric-contract-loader.js +210 -0
  281. package/lib/value/risk-evaluator.js +117 -0
  282. package/lib/value/weekly-snapshot-builder.js +61 -0
  283. package/lib/version/version-checker.js +156 -0
  284. package/lib/version/version-manager.js +327 -0
  285. package/lib/watch/action-executor.js +458 -0
  286. package/lib/watch/event-debouncer.js +323 -0
  287. package/lib/watch/execution-logger.js +550 -0
  288. package/lib/watch/file-watcher.js +499 -0
  289. package/lib/watch/presets.js +266 -0
  290. package/lib/watch/watch-manager.js +533 -0
  291. package/lib/workspace/multi/global-config.js +150 -0
  292. package/lib/workspace/multi/index.js +22 -0
  293. package/lib/workspace/multi/path-utils.js +173 -0
  294. package/lib/workspace/multi/workspace-context-resolver.js +244 -0
  295. package/lib/workspace/multi/workspace-registry.js +196 -0
  296. package/lib/workspace/multi/workspace-state-manager.js +537 -0
  297. package/lib/workspace/multi/workspace.js +90 -0
  298. package/lib/workspace/workspace-manager.js +370 -0
  299. package/lib/workspace/workspace-sync.js +356 -0
  300. package/locales/en.json +114 -0
  301. package/locales/zh.json +114 -0
  302. package/package.json +102 -0
  303. package/template/.kiro/README.md +247 -0
  304. package/template/.kiro/hooks/check-spec-on-create.kiro.hook +17 -0
  305. package/template/.kiro/hooks/run-tests-on-save.kiro.hook +13 -0
  306. package/template/.kiro/hooks/sync-tasks-on-edit.kiro.hook +16 -0
  307. package/template/.kiro/specs/SPEC_WORKFLOW_GUIDE.md +134 -0
  308. package/template/.kiro/steering/CORE_PRINCIPLES.md +133 -0
  309. package/template/.kiro/steering/CURRENT_CONTEXT.md +30 -0
  310. package/template/.kiro/steering/ENVIRONMENT.md +35 -0
  311. package/template/.kiro/steering/RULES_GUIDE.md +46 -0
  312. package/template/.kiro/templates/operations/default/change-impact.md +112 -0
  313. package/template/.kiro/templates/operations/default/deployment.md +91 -0
  314. package/template/.kiro/templates/operations/default/feedback-response.md +269 -0
  315. package/template/.kiro/templates/operations/default/migration-plan.md +172 -0
  316. package/template/.kiro/templates/operations/default/monitoring.md +135 -0
  317. package/template/.kiro/templates/operations/default/operations.md +135 -0
  318. package/template/.kiro/templates/operations/default/rollback.md +143 -0
  319. package/template/.kiro/templates/operations/default/tools.yaml +364 -0
  320. package/template/.kiro/templates/operations/default/troubleshooting.md +123 -0
  321. package/template/.kiro/tools/backup_manager.py +295 -0
  322. package/template/.kiro/tools/configuration_manager.py +218 -0
  323. package/template/.kiro/tools/document_evaluator.py +550 -0
  324. package/template/.kiro/tools/enhancement_logger.py +168 -0
  325. package/template/.kiro/tools/error_handler.py +335 -0
  326. package/template/.kiro/tools/improvement_identifier.py +444 -0
  327. package/template/.kiro/tools/modification_applicator.py +737 -0
  328. package/template/.kiro/tools/quality_gate_enforcer.py +207 -0
  329. package/template/.kiro/tools/quality_scorer.py +305 -0
  330. package/template/.kiro/tools/report_generator.py +154 -0
  331. package/template/.kiro/tools/ultrawork_enhancer.py +676 -0
  332. package/template/.kiro/tools/ultrawork_enhancer_refactored.py +0 -0
  333. package/template/.kiro/tools/ultrawork_enhancer_v2.py +463 -0
  334. package/template/.kiro/tools/ultrawork_enhancer_v3.py +606 -0
  335. package/template/.kiro/tools/workflow_quality_gate.py +100 -0
  336. package/template/README.md +111 -0
@@ -0,0 +1,851 @@
1
+ # Autonomous Control Guide
2
+
3
+ ## Overview
4
+
5
+ The Autonomous Control feature transforms kse from an interactive assistant into an autonomous development partner. AI can independently manage entire development workflows - from understanding user goals to delivering production-ready features.
6
+
7
+ **Key Capabilities**:
8
+ - **Autonomous Spec Creation**: Generate requirements, design, and tasks without step-by-step confirmation
9
+ - **Automatic Closed-Loop Progression**: Execute continuously toward completion without manual phase-by-phase confirmations
10
+ - **Automatic Master/Sub Portfolio Split**: Decompose broad goals into dependency-wired multi-spec plans
11
+ - **Semantic Goal Decomposition**: Use clause/category analysis to infer decomposition tracks from mixed-language goals
12
+ - **Continuous Task Execution**: Execute multiple tasks without interruption
13
+ - **Intelligent Error Recovery**: Automatically diagnose and fix errors (3 retry attempts)
14
+ - **Program Convergence Gate**: Enforce minimum success-rate + risk threshold before program reports final pass
15
+ - **Strategic Checkpoints**: Pause only at meaningful milestones for user review
16
+ - **Learning System**: Improve over time by learning from successes and failures
17
+ - **Safety Boundaries**: Respect workspace boundaries, require confirmation for sensitive operations
18
+
19
+ ## Quick Start
20
+
21
+ ### Run a Goal as an Autonomous Closed Loop
22
+
23
+ ```bash
24
+ # Single command:
25
+ # 1) auto decompose goal into master/sub specs
26
+ # 2) initialize collaboration metadata and assignments
27
+ # 3) run orchestration to terminal state
28
+ kse auto close-loop "build autonomous close-loop and master/sub multi-spec execution for kse"
29
+
30
+ # Disable live status stream output when running in quiet terminals
31
+ kse auto close-loop "build autonomous close-loop and master/sub multi-spec execution for kse" --no-stream
32
+
33
+ # Add final Definition-of-Done (DoD) test gate
34
+ kse auto close-loop "build autonomous close-loop and master/sub multi-spec execution for kse" \
35
+ --dod-tests "npm run test:smoke"
36
+
37
+ # Strict DoD: require all tasks checklists are closed
38
+ kse auto close-loop "build autonomous close-loop and master/sub multi-spec execution for kse" \
39
+ --dod-tasks-closed
40
+
41
+ # Persist DoD evidence into a custom report file
42
+ kse auto close-loop "build autonomous close-loop and master/sub multi-spec execution for kse" \
43
+ --dod-report ".kiro/reports/close-loop-dod.json"
44
+
45
+ # Resume interrupted close-loop from latest session
46
+ kse auto close-loop --resume latest
47
+
48
+ # Resume interrupted close-loop from a specific session id
49
+ kse auto close-loop --resume 117-20260214230000
50
+
51
+ # Increase automatic replan budget after orchestration failures
52
+ kse auto close-loop "build autonomous close-loop and master/sub multi-spec execution for kse" \
53
+ --replan-attempts 2
54
+
55
+ # Use fixed replan budget strategy (adaptive is default)
56
+ kse auto close-loop "build autonomous close-loop and master/sub multi-spec execution for kse" \
57
+ --replan-attempts 2 \
58
+ --replan-strategy fixed
59
+
60
+ # Batch mode: run multiple goals autonomously (each goal gets its own master/sub portfolio)
61
+ kse auto close-loop-batch .kiro/goals.json --json
62
+
63
+ # Program mode: decompose one broad goal into multiple batch goals automatically
64
+ kse auto close-loop-batch \
65
+ --decompose-goal "build autonomous close-loop, master/sub decomposition, orchestration and quality rollout" \
66
+ --program-goals 4 \
67
+ --program-min-quality-score 85 \
68
+ --program-quality-gate \
69
+ --json
70
+
71
+ # Program command: broad goal -> semantic decomposition -> autonomous batch closed-loop
72
+ kse auto close-loop-program \
73
+ "build autonomous close-loop, master/sub decomposition, orchestration and quality rollout" \
74
+ --program-goals 4 \
75
+ --program-quality-gate \
76
+ --program-recover-max-rounds 6 \
77
+ --program-recover-max-minutes 30 \
78
+ --program-gate-profile staging \
79
+ --program-gate-fallback-chain staging,prod \
80
+ --program-gate-fallback-profile prod \
81
+ --program-min-success-rate 95 \
82
+ --program-max-risk-level medium \
83
+ --program-max-elapsed-minutes 60 \
84
+ --program-max-agent-budget 12 \
85
+ --program-max-total-sub-specs 80 \
86
+ --program-kpi-out .kiro/reports/close-loop-program-kpi.json \
87
+ --program-audit-out .kiro/reports/close-loop-program-audit.json \
88
+ --json
89
+
90
+ # Controller command: drain queue goals with autonomous close-loop-program runtime
91
+ kse auto close-loop-controller .kiro/auto/program-queue.lines \
92
+ --dequeue-limit 2 \
93
+ --max-cycles 20 \
94
+ --controller-done-file .kiro/auto/program-done.lines \
95
+ --controller-failed-file .kiro/auto/program-failed.lines \
96
+ --json
97
+
98
+ # Persistent controller mode: keep polling queue and execute new goals automatically
99
+ kse auto close-loop-controller .kiro/auto/program-queue.lines \
100
+ --wait-on-empty \
101
+ --poll-seconds 30 \
102
+ --max-cycles 1000 \
103
+ --max-minutes 240
104
+
105
+ # Resume from latest persisted controller session
106
+ kse auto close-loop-controller --controller-resume latest --json
107
+
108
+ # Recovery command: consume diagnostics and auto-recover unresolved goals
109
+ kse auto close-loop-recover latest --json
110
+ kse auto close-loop-recover .kiro/auto/close-loop-batch-summaries/batch-20260215090000.json \
111
+ --use-action 2 \
112
+ --recover-until-complete \
113
+ --recover-max-rounds 3 \
114
+ --recover-max-minutes 20 \
115
+ --recovery-memory-ttl-days 30 \
116
+ --recovery-memory-scope release-main \
117
+ --program-audit-out .kiro/reports/close-loop-recover-audit.json \
118
+ --dry-run --json
119
+
120
+ # Default autonomous batch run (continue-on-error + adaptive scheduling + retry-until-complete)
121
+ kse auto close-loop-batch .kiro/goals.json --json
122
+
123
+ # Batch parallel mode: run multiple goals concurrently
124
+ kse auto close-loop-batch .kiro/goals.json --batch-parallel 3 --json
125
+
126
+ # Batch with global agent budget (automatic per-goal maxParallel throttling)
127
+ kse auto close-loop-batch .kiro/goals.json \
128
+ --batch-parallel 3 \
129
+ --batch-agent-budget 6 \
130
+ --json
131
+
132
+ # Batch priority scheduling with aging (favor complex goals, prevent starvation)
133
+ kse auto close-loop-batch .kiro/goals.json \
134
+ --batch-priority critical-first \
135
+ --batch-aging-factor 3 \
136
+ --json
137
+
138
+ # Auto-retry failed/stopped goals in the same batch run
139
+ kse auto close-loop-batch .kiro/goals.json \
140
+ --batch-retry-rounds 1 \
141
+ --batch-retry-strategy adaptive \
142
+ --json
143
+
144
+ # Keep retrying until all goals complete (bounded)
145
+ kse auto close-loop-batch .kiro/goals.json \
146
+ --batch-retry-until-complete \
147
+ --batch-retry-max-rounds 10 \
148
+ --json
149
+
150
+ # Disable autonomous closed-loop batch policy (only when you need legacy/manual tuning)
151
+ kse auto close-loop-batch .kiro/goals.json \
152
+ --no-batch-autonomous \
153
+ --json
154
+
155
+ # Resume a stopped/failed batch from previous summary output
156
+ kse auto close-loop-batch --resume-from-summary .kiro/reports/close-loop-batch.json --json
157
+
158
+ # Resume from latest persisted batch summary session
159
+ kse auto close-loop-batch --resume-from-summary latest --json
160
+
161
+ # Resume only failed/error goals from summary
162
+ kse auto close-loop-batch --resume-from-summary .kiro/reports/close-loop-batch.json \
163
+ --resume-strategy failed-only --json
164
+
165
+ # Batch dry-run for portfolio planning only
166
+ kse auto close-loop-batch .kiro/goals.txt --format lines --dry-run --json
167
+ ```
168
+
169
+ Default DoD gates:
170
+ - Spec docs exist (`requirements.md`, `design.md`, `tasks.md`)
171
+ - Orchestration reaches `completed` terminal state (unless `--no-run`)
172
+ - Collaboration statuses are reconciled to `completed` (unless `--no-run`)
173
+
174
+ Optional DoD gates:
175
+ - `--dod-tests <command>`: run a final validation command
176
+ - `--dod-tests-timeout <ms>`: timeout for test gate command
177
+ - `--dod-tasks-closed`: enforce closed checklist items in `tasks.md`
178
+
179
+ DoD evidence archive:
180
+ - Default output: `.kiro/specs/<master-spec>/custom/dod-report.json`
181
+ - `--dod-report <path>`: override report path
182
+ - `--no-dod-report`: disable report generation
183
+
184
+ Session persistence and resume:
185
+ - Default session archive: `.kiro/auto/close-loop-sessions/*.json`
186
+ - `--session-id <id>`: override generated session id
187
+ - `--resume <session-or-file>`: continue from prior session (supports `latest`)
188
+ - `--no-session`: disable session snapshot persistence
189
+ - `--session-keep <n>`: automatically prune old snapshots and keep newest `n` after each close-loop run
190
+ - `--session-older-than-days <n>`: when pruning, only delete snapshots older than `n` days
191
+ - `kse auto session list [--limit <n>] [--status <csv>]`: inspect persisted sessions (`--status` supports comma-separated, case-insensitive filters)
192
+ - `kse auto session stats [--days <n>] [--status <csv>] [--json]`: aggregate session status/topology telemetry in an optional recent-day window
193
+ - `kse auto session prune --keep <n> [--older-than-days <n>]`: enforce retention policy
194
+ - List JSON output includes `status_filter` and `status_counts` for filtered session distributions.
195
+ - Stats JSON output includes `criteria`, completion/failure rates, `sub_spec_count_sum`, `master_spec_counts`, and `latest_sessions`.
196
+
197
+ Spec directory maintenance:
198
+ - `kse auto spec-session list [--limit <n>] [--json]`: inspect spec directory inventory under `.kiro/specs`
199
+ - `kse auto spec-session prune --keep <n> [--older-than-days <n>] [--no-protect-active] [--protect-window-days <n>] [--show-protection-reasons] [--dry-run] [--json]`: prune old spec directories by retention policy (default protects active/recent specs)
200
+ - Protection sources include collaboration state, close-loop sessions, batch summaries, and controller sessions (via nested batch summary references).
201
+ - JSON output always includes `protection_ranking_top`; enable `--show-protection-reasons` for full `protection_ranking` and per-spec reason payload.
202
+
203
+ Batch summary session persistence and maintenance:
204
+ - Default batch summary archive: `.kiro/auto/close-loop-batch-summaries/*.json`
205
+ - `--batch-session-id <id>`: override generated batch summary session id
206
+ - `--batch-session-keep <n>`: auto-prune archive and keep newest `n` summaries after each batch run
207
+ - `--batch-session-older-than-days <n>`: when pruning, only delete summaries older than `n` days
208
+ - `--no-batch-session`: disable batch summary archive for the current run
209
+ - `kse auto batch-session list [--limit <n>] [--status <csv>]`: inspect persisted batch summary sessions (`--status` supports comma-separated, case-insensitive filters)
210
+ - `kse auto batch-session stats [--days <n>] [--status <csv>] [--json]`: aggregate batch session status/goal-volume telemetry in an optional recent-day window
211
+ - `kse auto batch-session prune --keep <n> [--older-than-days <n>]`: enforce batch summary retention policy
212
+ - List JSON output includes `status_filter` and `status_counts` for filtered status composition.
213
+ - Stats JSON output includes `criteria`, completion/failure rates, goal-volume sums, processed ratio, and `latest_sessions`.
214
+
215
+ Controller summary session persistence and maintenance:
216
+ - Default controller summary archive: `.kiro/auto/close-loop-controller-sessions/*.json`
217
+ - `--controller-session-id <id>`: override generated controller session id
218
+ - `--controller-session-keep <n>`: auto-prune archive and keep newest `n` summaries after each controller run
219
+ - `--controller-session-older-than-days <n>`: when pruning, only delete summaries older than `n` days
220
+ - `--no-controller-session`: disable controller summary archive for the current run
221
+ - `kse auto controller-session list [--limit <n>] [--status <csv>]`: inspect persisted controller summary sessions (`--status` supports comma-separated, case-insensitive filters)
222
+ - `kse auto controller-session stats [--days <n>] [--status <csv>] [--json]`: aggregate controller session status/throughput telemetry in an optional recent-day window
223
+ - `kse auto controller-session prune --keep <n> [--older-than-days <n>]`: enforce controller summary retention policy
224
+ - List JSON output includes `status_filter` and `status_counts` for filtered status composition.
225
+ - Stats JSON output includes `criteria`, `status_counts`, `queue_format_counts`, completion/failure rates, goal-volume sums, and `latest_sessions`.
226
+
227
+ Cross-archive governance snapshot:
228
+ - `kse auto governance stats [--days <n>] [--status <csv>] [--json]`: aggregate a unified governance cockpit over session/batch/controller archives plus recovery memory state.
229
+ - JSON output includes `totals`, `throughput`, `top_master_specs`, per-archive `archives.*` stats payloads, and `health` diagnostics (`risk_level`, `concerns`, `recommendations`) for one-command close-loop governance checks.
230
+ - `kse auto governance maintain [--days <n>] [--status <csv>] [--session-keep <n>] [--batch-session-keep <n>] [--controller-session-keep <n>] [--recovery-memory-older-than-days <n>] [--apply] [--dry-run] [--json]`: close-loop governance maintenance entrypoint.
231
+ - Default is plan-only (`assessment` + `plan`).
232
+ - `--apply` executes maintenance actions for archive hygiene (session/batch/controller pruning + recovery-memory stale-entry pruning).
233
+ - `--dry-run` can be combined with `--apply` to validate maintenance impact before deletion.
234
+ - `kse auto governance close-loop [--max-rounds <n>] [--target-risk <low|medium|high>] [--governance-resume <session|latest|file>] [--governance-resume-allow-drift] [--governance-session-id <id>] [--no-governance-session] [--governance-session-keep <n>] [--governance-session-older-than-days <n>] [--execute-advisory] [--advisory-recover-max-rounds <n>] [--advisory-controller-max-cycles <n>] [--plan-only] [--dry-run] [--json]`: governance round-loop runner.
235
+ - Orchestrates repeated `governance maintain` rounds until target risk or stop condition is reached.
236
+ - Governance close-loop sessions persist by default at `.kiro/auto/governance-close-loop-sessions`; use `--governance-resume` to continue interrupted governance loops.
237
+ - Resume defaults inherit persisted governance policy (`target_risk`, `execute_advisory`, `advisory_policy`) to avoid accidental configuration drift; explicit drift is blocked unless `--governance-resume-allow-drift` is set.
238
+ - `--governance-session-keep` enables automatic post-run governance session pruning (optional age window via `--governance-session-older-than-days`) while preserving the current run session file.
239
+ - `--execute-advisory` enables automatic advisory action execution when detected (`recover-latest`, `controller-resume-latest`), with autonomous source selection (latest recoverable summary / latest pending controller session) and `skipped` telemetry when no actionable source exists.
240
+ - Emits round history (`risk_before`/`risk_after`, planned/applicable/applied/failed actions), advisory telemetry (`advisory_*` fields), plus initial/final assessments for auditable autonomous governance convergence.
241
+ - `kse auto governance session list [--limit <n>] [--status <csv>] [--resume-only] [--json]`: inspect persisted governance close-loop session archive (optional resumed-chain filter).
242
+ - `kse auto governance session stats [--days <n>] [--status <csv>] [--resume-only] [--json]`: aggregate governance session completion/failure/convergence/risk telemetry with resumed-session ratio/source breakdown.
243
+ - `kse auto governance session prune [--keep <n>] [--older-than-days <n>] [--dry-run] [--json]`: enforce governance session retention policy.
244
+
245
+ Recovery memory maintenance:
246
+ - Default recovery memory file: `.kiro/auto/close-loop-recovery-memory.json`
247
+ - `kse auto recovery-memory show [--scope <scope>] [--json]`: inspect learned failure signatures and action stats (optionally by scope)
248
+ - `kse auto recovery-memory scopes [--json]`: inspect aggregated recovery-memory metrics grouped by scope
249
+ - `kse auto recovery-memory prune [--older-than-days <n>] [--scope <scope>] [--dry-run] [--json]`: prune stale memory entries (optionally by scope)
250
+ - `kse auto recovery-memory clear [--json]`: clear learned recovery memory
251
+
252
+ Automatic decomposition scale:
253
+ - Default sub-spec count is inferred from goal complexity (typically `3-5`)
254
+ - Use `--subs <n>` to pin a specific decomposition size (`2-5`)
255
+
256
+ Automatic failure replanning:
257
+ - Default behavior: one remediation replan cycle after failed orchestration
258
+ - `--replan-attempts <n>`: set replan budget (`0-5`)
259
+ - `--replan-strategy <strategy>`: choose `adaptive` (default) or `fixed` cycle budget
260
+ - `--replan-no-progress-window <n>`: stop replanning when no net progress persists for `n` failed cycles (`1-10`, default `3`)
261
+ - `--no-replan`: disable remediation replan cycles
262
+ - Repeated failed-spec signatures auto-stop replanning to prevent infinite low-value retry loops
263
+
264
+ Batch multi-goal autonomous execution:
265
+ - Command: `kse auto close-loop-batch <goals-file>`
266
+ - Goals file formats: JSON array / JSON `{ "goals": [] }` / line-based text
267
+ - `--format <auto|json|lines>`: force parser mode when needed
268
+ - `--decompose-goal <goal>`: generate batch goals from one broad goal using semantic decomposition
269
+ - `--program-goals <n>`: target generated-goal count for `--decompose-goal` (`2-12`, default adaptive)
270
+ - `--program-min-quality-score <n>`: minimum decomposition quality score before automatic refinement (`0-100`, default `70`)
271
+ - `--program-quality-gate`: fail fast when final decomposition quality remains below `--program-min-quality-score`
272
+ - `--resume-from-summary <path>`: resume only pending goals from previous batch summary
273
+ - `--resume-from-summary latest`: resolve and resume from latest persisted batch summary session
274
+ - `--resume-strategy <pending|failed-only>`: control whether summary resume includes unprocessed goals (`pending`) or only failed/error goals (`failed-only`)
275
+ - `--batch-parallel <n>`: run multiple goals concurrently (`1-20`, default adaptive under autonomous policy)
276
+ - `--batch-agent-budget <n>`: set global agent parallel budget shared across all active goals (`1-500`)
277
+ - `--batch-priority <strategy>`: choose `fifo`, `complex-first`, `complex-last`, or `critical-first` scheduling (default `complex-first` under autonomous policy)
278
+ - `--batch-aging-factor <n>`: increase waiting-goal score per scheduling cycle (`0-100`, default `2` under autonomous policy)
279
+ - `--batch-retry-rounds <n>`: automatically retry failed/stopped goals for `n` extra rounds (`0-5`, default `0`, or until-complete under autonomous policy)
280
+ - `--batch-retry-strategy <strategy>`: choose `adaptive` (default) or `strict` retry behavior
281
+ - `--batch-retry-until-complete`: enable goal-draining retry mode until completion or max rounds
282
+ - `--batch-retry-max-rounds <n>`: max extra rounds for until-complete mode (`1-20`, default `10`)
283
+ - `--no-batch-autonomous`: disable autonomous defaults and use explicit batch flags only
284
+ - `--batch-session-id <id>`: set explicit id for persisted batch summary session
285
+ - `--batch-session-keep <n>`: keep newest `n` persisted batch summary sessions (`0-1000`)
286
+ - `--batch-session-older-than-days <n>`: when pruning persisted batch summaries, only delete sessions older than `n` days (`0-36500`)
287
+ - `--spec-session-keep <n>`: keep newest `n` spec directories under `.kiro/specs` after run (`0-5000`)
288
+ - `--spec-session-older-than-days <n>`: when pruning specs, only delete directories older than `n` days (`0-36500`)
289
+ - `--no-spec-session-protect-active`: allow pruning active/recently referenced spec directories
290
+ - `--spec-session-protect-window-days <n>`: protection window (days) for recent session references during spec pruning (`0-36500`, default `7`)
291
+ - `--spec-session-max-total <n>`: spec directory budget ceiling under `.kiro/specs` (`1-500000`)
292
+ - `--spec-session-max-created <n>`: spec growth guard for maximum estimated created directories per run (`0-500000`)
293
+ - `--spec-session-max-created-per-goal <n>`: spec growth guard for estimated created directories per processed goal (`0-1000`)
294
+ - `--spec-session-max-duplicate-goals <n>`: goal-input duplicate guard for batch inputs (`0-500000`)
295
+ - `--spec-session-budget-hard-fail`: fail run when spec count exceeds `--spec-session-max-total` before/after execution
296
+ - `--no-batch-session`: disable persisted batch summary session archive for this run
297
+ - `--continue-on-error`: continue remaining goals when one goal fails (enabled by default under autonomous policy)
298
+ - Returns one summary with per-goal statuses (`completed`, `failed`, `error`, `planned`)
299
+ - Summary includes `resource_plan` and aggregate `metrics` (success rate, status breakdown, avg sub-spec count, avg replan cycles)
300
+ - `--program-goals` requires `--decompose-goal`, and goal sources are mutually exclusive (`<goals-file>` vs `--resume-from-summary` vs `--decompose-goal`)
301
+ - In `--decompose-goal` mode, summary also exposes `generated_from_goal` diagnostics (strategy, target/produced counts, clause/category signals, and `quality` score/warnings)
302
+ - Summary also exposes `batch_retry` diagnostics (strategy, until-complete mode, configured/max/performed rounds, exhausted flag, and per-round counters)
303
+ - Summary also exposes `batch_session` metadata when persistence is enabled (session id and file path)
304
+ - `resource_plan` exposes scheduling telemetry (`scheduling_strategy`, `aging_factor`, `max_wait_ticks`, `starvation_wait_events`) for autonomous portfolio tuning
305
+ - In budget mode, complexity-weighted scheduling is enabled (`goal_weight`/`scheduling_weight`) to prioritize shared capacity and reduce concurrent goal count when high-complexity goals are active.
306
+ - Each goal still keeps independent session snapshots and governance artifacts
307
+
308
+ Close-loop program command:
309
+ - Command: `kse auto close-loop-program "<goal>"`
310
+ - Built for broad, multi-track goals and defaults to autonomous batch closed-loop policy.
311
+ - Automatically performs semantic decomposition into multiple goals and executes them as one program.
312
+ - `--program-goals <n>` tunes decomposition width (`2-12`, default adaptive).
313
+ - Reuses batch execution controls and summary/session persistence controls.
314
+ - Program command now includes built-in auto recovery loop by default; it does not require a second manual command.
315
+ - `--no-program-auto-recover` disables built-in recovery loop.
316
+ - `--program-recover-use-action <n>` pins remediation action for built-in recovery; if omitted, KSE picks from recovery memory or falls back to action `1`.
317
+ - `--program-recover-resume-strategy <pending|failed-only>` controls recovery scope.
318
+ - `--program-recover-max-rounds <n>` sets bounded built-in recovery rounds (`1-20`, default `5`).
319
+ - `--program-recover-max-minutes <n>` sets elapsed-time budget for built-in recovery loop (minutes, default unlimited).
320
+ - `--program-gate-profile <profile>` sets baseline convergence policy (`default|dev|staging|prod`).
321
+ - `--program-gate-fallback-profile <profile>` defines fallback gate profile (`none|default|dev|staging|prod`) when primary gate fails.
322
+ - `--program-gate-fallback-chain <profiles>` defines ordered fallback profiles (comma-separated) after primary gate failure.
323
+ - `--program-min-success-rate <n>` + `--program-max-risk-level <level>` define the final convergence gate policy.
324
+ - `--program-max-elapsed-minutes <n>` + `--program-max-agent-budget <n>` + `--program-max-total-sub-specs <n>` add program budget gates (time/concurrency/sub-spec volume).
325
+ - `--no-program-gate-auto-remediate` disables automatic remediation patch/prune hints after gate failure.
326
+ - `--program-min-quality-score <n>` enforces decomposition quality threshold and triggers auto refinement when needed.
327
+ - `--program-quality-gate` enables hard failure when final decomposition quality still violates threshold.
328
+ - `--recovery-memory-scope <scope>` isolates remediation memory by scope (default auto: project + git branch).
329
+ - `--spec-session-keep <n>` + `--spec-session-older-than-days <n>` enable automatic spec-directory retention after run.
330
+ - `--no-spec-session-protect-active` disables active/recent spec protection during automatic retention prune.
331
+ - `--spec-session-protect-window-days <n>` tunes how long recent session references protect specs from pruning.
332
+ - `--spec-session-max-total <n>` + `--spec-session-budget-hard-fail` add optional spec-count budget governance for autonomous programs.
333
+ - Summary includes `program_kpi` (`convergence_state`, `risk_level`, retry recovery, complexity ratio, wait profile).
334
+ - `--program-kpi-out <path>` writes a standalone KPI snapshot JSON for dashboards and audit archives.
335
+ - Summary includes `program_gate` verdict (`passed`, policy, actuals, reasons) and returns non-zero when gate fails.
336
+ - Summary includes `program_gate_fallbacks` and `program_gate_effective` so fallback gate evaluation is fully auditable.
337
+ - `--program-audit-out <path>` writes program/recovery coordination audit JSON for governance traceability.
338
+ - Summary also includes `program_diagnostics` (`failure_clusters`, `remediation_actions`) to drive automatic follow-up and convergence recovery.
339
+ - Summary includes `program_coordination` (master/sub topology, unresolved goal indexes, scheduler telemetry) and `auto_recovery` metadata.
340
+
341
+ Close-loop controller command:
342
+ - Command: `kse auto close-loop-controller [queue-file]`
343
+ - Runs a queue-driven autonomous loop: dequeue broad goals, execute each by `close-loop-program`, persist remaining queue, and continue until stop condition.
344
+ - Queue file defaults to `.kiro/auto/close-loop-controller-goals.lines`; supports `auto|json|lines` parsing via `--queue-format`.
345
+ - `--controller-resume <session-or-file>` resumes queue/controller context from persisted controller session (`latest`, session id, or file path).
346
+ - Duplicate broad goals are deduped by default; use `--no-controller-dedupe` to preserve raw queue duplicates.
347
+ - `--dequeue-limit <n>` controls how many queued goals are consumed in one cycle (`1-100`, default: all pending goals).
348
+ - `--wait-on-empty` + `--poll-seconds <n>` enables long-running poll mode for continuously appended program queues.
349
+ - `--max-cycles <n>` + `--max-minutes <n>` bound controller runtime to prevent unbounded loops.
350
+ - Controller lease lock is enabled by default to prevent concurrent queue corruption (`--controller-lock-file`, `--controller-lock-ttl-seconds`, `--no-controller-lock`).
351
+ - `--stop-on-goal-failure` stops controller immediately on the first failed dequeued goal.
352
+ - `--controller-done-file` / `--controller-failed-file` append per-goal archive lines for downstream ops and replay.
353
+ - Controller summaries are persisted by default (`.kiro/auto/close-loop-controller-sessions`); use `--controller-session-id`, `--controller-session-keep`, `--controller-session-older-than-days`, `--no-controller-session` as needed.
354
+ - `--controller-print-program-summary` prints each nested program summary in realtime during controller execution.
355
+ - Supports full program governance/gate/recovery policy controls (`--program-*`, `--batch-*`, `--continue-on-error`, `--recovery-memory-scope`, `--dry-run`, `--json`).
356
+ - Output summary includes `history`, `results`, final `pending_goals`, `stop_reason`, `exhausted`, dedupe/lock/session, and resume-source telemetry.
357
+
358
+ Close-loop recovery command:
359
+ - Command: `kse auto close-loop-recover [summary]` (defaults to `latest` if summary is omitted).
360
+ - Loads unresolved goals from a prior summary and applies selected remediation strategy patch automatically.
361
+ - `--use-action <n>` chooses which remediation action to execute.
362
+ - `--recover-until-complete` + `--recover-max-rounds` enables self-healing multi-round recovery until convergence.
363
+ - `--recover-max-minutes <n>` bounds elapsed recovery duration.
364
+ - `--recovery-memory-ttl-days <n>` prunes stale memory before automatic action selection.
365
+ - `--recovery-memory-scope <scope>` isolates remediation memory by scope (default auto: project + git branch).
366
+ - `--spec-session-keep <n>` + `--spec-session-older-than-days <n>` enable automatic spec-directory retention after run.
367
+ - `--no-spec-session-protect-active` disables active/recent spec protection during automatic retention prune.
368
+ - `--spec-session-protect-window-days <n>` tunes how long recent session references protect specs from pruning.
369
+ - `--spec-session-max-total <n>` + `--spec-session-budget-hard-fail` add optional spec-count budget governance for autonomous recovery loops.
370
+ - `--program-gate-profile <profile>` + `--program-gate-fallback-*` + `--program-min-success-rate` + `--program-max-risk-level` + `--program-max-*` make recovery use the same convergence/budget gate strategy as program mode.
371
+ - `--no-program-gate-auto-remediate` disables automatic remediation patch/prune hints after recovery gate failure.
372
+ - When `--use-action` is omitted, KSE can auto-select action from learned recovery memory.
373
+ - `--program-audit-out <path>` exports full recovery/program audit JSON.
374
+ - Output includes `recovered_from_summary`, `recovery_plan` (including `selection_explain`), `recovery_cycle` (with elapsed/budget metadata), and `recovery_memory` (including scope + selection explanation) for full auditability of applied strategy changes.
375
+
376
+ Program governance loop (for `close-loop-program`):
377
+ - `--program-govern-until-stable` enables bounded post-run governance rounds.
378
+ - `--program-govern-max-rounds <n>` and `--program-govern-max-minutes <n>` bound governance loop cost.
379
+ - `--program-govern-anomaly-weeks <n>` + `--program-govern-anomaly-period <week|day>` make governance anomaly-aware using autonomous KPI trend.
380
+ - `--no-program-govern-anomaly` limits governance trigger to gate/budget failures only.
381
+ - `--program-govern-use-action <n>` pins remediation action index for governance rounds.
382
+ - `--no-program-govern-auto-action` disables automatic remediation action selection/execution inside governance.
383
+ - Output includes `program_governance`, `program_kpi_trend`, and `program_kpi_anomalies` for traceable autonomous stabilization history.
384
+
385
+ KPI trend command:
386
+ - `kse auto kpi trend --weeks <n> --mode <all|batch|program|recover|controller> --period <week|day> --json` aggregates periodic success/completion, failure, sub-spec, and spec-growth telemetry from persisted autonomous session summaries.
387
+ - Add `--csv` to print/export trend buckets as CSV (`--out` writes CSV when `--csv` is enabled).
388
+ - JSON output now includes `mode_breakdown` (batch/program/recover/controller/other distribution), `anomaly_detection`, and `anomalies` for latest-period regression signals (success-rate drop, failed-goal spike, spec-growth spike).
389
+
390
+ ### Create and Run a Feature Autonomously
391
+
392
+ ```bash
393
+ # Create a new Spec and execute it autonomously
394
+ kse auto create "user authentication with JWT tokens"
395
+ ```
396
+
397
+ This single command will:
398
+ 1. Generate requirements.md with acceptance criteria
399
+ 2. Generate design.md with architecture and components
400
+ 3. Generate tasks.md with implementation plan
401
+ 4. Execute all tasks continuously
402
+ 5. Handle errors automatically
403
+ 6. Create checkpoints at phase boundaries
404
+ 7. Deliver the complete feature
405
+
406
+ ### Run an Existing Spec
407
+
408
+ ```bash
409
+ # Run an existing Spec autonomously
410
+ kse auto run 33-00-ai-autonomous-control
411
+ ```
412
+
413
+ ### Check Status
414
+
415
+ ```bash
416
+ # View current execution status
417
+ kse auto status
418
+ ```
419
+
420
+ ### Resume After Pause
421
+
422
+ ```bash
423
+ # Resume from last checkpoint
424
+ kse auto resume
425
+ ```
426
+
427
+ ### Stop Execution
428
+
429
+ ```bash
430
+ # Gracefully stop and save state
431
+ kse auto stop
432
+ ```
433
+
434
+ ## Execution Modes
435
+
436
+ ### Conservative Mode (Default)
437
+
438
+ **Best for**: Production features, critical systems, first-time users
439
+
440
+ **Behavior**:
441
+ - Creates checkpoints after each major phase
442
+ - Requests user approval at phase boundaries
443
+ - More cautious error recovery
444
+ - Detailed logging
445
+
446
+ **Configuration**:
447
+ ```json
448
+ {
449
+ "mode": "conservative",
450
+ "checkpoints": {
451
+ "requirementsReview": true,
452
+ "designReview": true,
453
+ "phaseCompletion": true,
454
+ "finalReview": true
455
+ }
456
+ }
457
+ ```
458
+
459
+ ### Balanced Mode
460
+
461
+ **Best for**: Most development scenarios
462
+
463
+ **Behavior**:
464
+ - Creates checkpoints at phase completions
465
+ - Requests approval for major decisions
466
+ - Standard error recovery
467
+ - Balanced logging
468
+
469
+ **Configuration**:
470
+ ```json
471
+ {
472
+ "mode": "balanced",
473
+ "checkpoints": {
474
+ "requirementsReview": false,
475
+ "designReview": false,
476
+ "phaseCompletion": true,
477
+ "finalReview": true
478
+ }
479
+ }
480
+ ```
481
+
482
+ ### Aggressive Mode
483
+
484
+ **Best for**: Rapid prototyping, experimental features, experienced users
485
+
486
+ **Behavior**:
487
+ - Minimal checkpoints (only on fatal errors)
488
+ - No approval requests
489
+ - Aggressive error recovery
490
+ - Minimal logging
491
+
492
+ **Configuration**:
493
+ ```json
494
+ {
495
+ "mode": "aggressive",
496
+ "checkpoints": {
497
+ "requirementsReview": false,
498
+ "designReview": false,
499
+ "phaseCompletion": false,
500
+ "finalReview": false
501
+ }
502
+ }
503
+ ```
504
+
505
+ ## Configuration
506
+
507
+ ### Global Configuration
508
+
509
+ Location: `.kiro/auto/config.json`
510
+
511
+ ```json
512
+ {
513
+ "version": "1.0.0",
514
+ "mode": "balanced",
515
+ "checkpoints": {
516
+ "requirementsReview": false,
517
+ "designReview": false,
518
+ "tasksReview": false,
519
+ "phaseCompletion": true,
520
+ "finalReview": true,
521
+ "errorThreshold": 3
522
+ },
523
+ "errorRecovery": {
524
+ "enabled": true,
525
+ "maxAttempts": 3,
526
+ "strategies": ["syntax-fix", "import-resolution", "type-correction", "null-check", "error-handling"],
527
+ "learningEnabled": true
528
+ },
529
+ "safety": {
530
+ "requireProductionConfirmation": true,
531
+ "requireExternalResourceConfirmation": true,
532
+ "requireDestructiveOperationConfirmation": true,
533
+ "allowedOperations": [],
534
+ "blockedOperations": []
535
+ },
536
+ "performance": {
537
+ "maxConcurrentTasks": 1,
538
+ "taskTimeout": 300000,
539
+ "checkpointInterval": 600000
540
+ }
541
+ }
542
+ ```
543
+
544
+ ### Per-Spec Configuration
545
+
546
+ Location: `.kiro/specs/{spec-name}/auto-config.json`
547
+
548
+ Per-spec configuration overrides global settings.
549
+
550
+ ### Manage Configuration
551
+
552
+ ```bash
553
+ # View current configuration
554
+ kse auto config
555
+
556
+ # Set mode
557
+ kse auto config --mode aggressive
558
+
559
+ # Enable/disable checkpoints
560
+ kse auto config --checkpoint phaseCompletion=false
561
+
562
+ # Set error recovery attempts
563
+ kse auto config --error-recovery maxAttempts=5
564
+ ```
565
+
566
+ ## Error Recovery
567
+
568
+ ### Automatic Recovery Strategies
569
+
570
+ 1. **Syntax Fix**: Parse error messages and fix syntax issues
571
+ 2. **Import Resolution**: Add missing imports, fix module paths
572
+ 3. **Type Correction**: Fix type mismatches and add type annotations
573
+ 4. **Null Check**: Add null/undefined checks
574
+ 5. **Error Handling**: Wrap code in try-catch blocks
575
+
576
+ ### Recovery Process
577
+
578
+ 1. **Error Detection**: Error encountered during task execution
579
+ 2. **Error Analysis**: Classify error type and severity
580
+ 3. **Strategy Selection**: Choose best recovery strategy (learned from history)
581
+ 4. **Apply Fix**: Implement the fix
582
+ 5. **Validation**: Re-run tests to verify fix
583
+ 6. **Retry or Pause**: If successful, continue; if failed after 3 attempts, pause
584
+
585
+ ### Learning System
586
+
587
+ The error recovery system learns from experience:
588
+ - **Success History**: Tracks which strategies work for each error type
589
+ - **Failure History**: Tracks which strategies fail
590
+ - **Strategy Prioritization**: Prioritizes strategies with higher success rates
591
+ - **Continuous Improvement**: Gets better over time
592
+
593
+ ## Checkpoints and Rollback
594
+
595
+ ### Checkpoint Types
596
+
597
+ - **Requirements Complete**: After requirements.md generated
598
+ - **Design Complete**: After design.md generated
599
+ - **Tasks Complete**: After tasks.md generated
600
+ - **Phase Complete**: After each major phase (implementation, QA)
601
+ - **Fatal Error**: When unrecoverable error occurs
602
+ - **External Resource Needed**: When API keys or credentials required
603
+ - **Final Review**: Before marking Spec complete
604
+
605
+ ### Rollback
606
+
607
+ ```bash
608
+ # List available checkpoints
609
+ kse auto checkpoints
610
+
611
+ # Rollback to specific checkpoint
612
+ kse auto rollback <checkpoint-id>
613
+
614
+ # Rollback to last checkpoint
615
+ kse auto rollback --last
616
+ ```
617
+
618
+ **What Gets Rolled Back**:
619
+ - File modifications
620
+ - Task queue state
621
+ - Progress tracking
622
+ - Execution log (preserved for audit)
623
+
624
+ ## Safety Boundaries
625
+
626
+ ### Automatic Safety Checks
627
+
628
+ 1. **Production Environment**: Requires confirmation before modifying production
629
+ 2. **Workspace Boundary**: Blocks operations outside workspace directory
630
+ 3. **External Access**: Requires confirmation for API calls and network requests
631
+ 4. **Destructive Operations**: Requires confirmation for file deletion, database drops
632
+
633
+ ### Override Safety Checks
634
+
635
+ ```bash
636
+ # Allow specific operation
637
+ kse auto config --safety allowedOperations=api-call,network-request
638
+
639
+ # Block specific operation
640
+ kse auto config --safety blockedOperations=delete-file,drop-database
641
+ ```
642
+
643
+ ## Progress Tracking
644
+
645
+ ### Real-Time Status
646
+
647
+ ```bash
648
+ kse auto status
649
+ ```
650
+
651
+ **Output**:
652
+ ```
653
+ Autonomous Execution Status
654
+ ===========================
655
+
656
+ Spec: 33-00-ai-autonomous-control
657
+ Mode: balanced
658
+ Status: Running
659
+
660
+ Progress: 65%
661
+ Phase: implementation
662
+ Current Task: 9.6 Implement continuous task execution
663
+
664
+ Tasks: 12/18 completed (6 remaining)
665
+ Errors: 2 encountered, 2 resolved (100% recovery rate)
666
+
667
+ Started: 2026-02-02T10:30:00Z
668
+ Estimated Completion: 2026-02-02T11:45:00Z
669
+
670
+ Recent Actions:
671
+ ✅ 10:45:23 - Task 9.5 completed
672
+ ✅ 10:44:15 - Error recovered (strategy: import-resolution)
673
+ ❌ 10:44:10 - Error encountered: Cannot find module 'fs-extra'
674
+ ✅ 10:42:30 - Task 9.4 completed
675
+ ✅ 10:40:15 - Task 9.3 completed
676
+ ```
677
+
678
+ ### Detailed Report
679
+
680
+ ```bash
681
+ # Generate detailed report
682
+ kse auto report --format markdown --output report.md
683
+ kse auto report --format json --output report.json
684
+ ```
685
+
686
+ ## Best Practices
687
+
688
+ ### When to Use Autonomous Mode
689
+
690
+ **✅ Good Use Cases**:
691
+ - Implementing well-defined features
692
+ - Creating new Specs from clear requirements
693
+ - Repetitive implementation tasks
694
+ - Prototyping and experimentation
695
+ - Batch processing multiple similar tasks
696
+
697
+ **❌ Not Recommended**:
698
+ - Unclear or ambiguous requirements
699
+ - Complex architectural decisions requiring human judgment
700
+ - Features requiring external resources you don't have
701
+ - Critical production changes without review
702
+
703
+ ### Optimizing Autonomous Execution
704
+
705
+ 1. **Clear Feature Descriptions**: Provide detailed, specific feature descriptions
706
+ 2. **Choose Right Mode**: Use conservative for critical features, aggressive for prototypes
707
+ 3. **Monitor Progress**: Check status periodically
708
+ 4. **Review Checkpoints**: Review and approve at checkpoint boundaries
709
+ 5. **Learn from History**: Let the system learn from multiple executions
710
+
711
+ ### Handling Interruptions
712
+
713
+ **Graceful Stop**:
714
+ ```bash
715
+ # Stop and save state
716
+ kse auto stop
717
+ ```
718
+
719
+ **Emergency Stop** (Ctrl+C):
720
+ - State automatically saved
721
+ - Can resume from last checkpoint
722
+ - No data loss
723
+
724
+ **Resume**:
725
+ ```bash
726
+ # Resume from where you left off
727
+ kse auto resume
728
+ ```
729
+
730
+ ## Troubleshooting
731
+
732
+ ### Execution Stuck
733
+
734
+ **Symptom**: Progress not advancing
735
+
736
+ **Solutions**:
737
+ 1. Check status: `kse auto status`
738
+ 2. Review recent actions for errors
739
+ 3. Check if waiting for user input
740
+ 4. Stop and resume: `kse auto stop && kse auto resume`
741
+
742
+ ### Repeated Errors
743
+
744
+ **Symptom**: Same error occurring multiple times
745
+
746
+ **Solutions**:
747
+ 1. Review error in execution log
748
+ 2. Check if error is environmental (missing dependencies, permissions)
749
+ 3. Manually fix the issue
750
+ 4. Resume execution
751
+
752
+ ### Checkpoint Not Created
753
+
754
+ **Symptom**: Expected checkpoint not appearing
755
+
756
+ **Solutions**:
757
+ 1. Check mode configuration
758
+ 2. Verify checkpoint settings: `kse auto config`
759
+ 3. Ensure phase actually completed
760
+
761
+ ### Rollback Failed
762
+
763
+ **Symptom**: Cannot rollback to checkpoint
764
+
765
+ **Solutions**:
766
+ 1. Check if checkpoint exists: `kse auto checkpoints`
767
+ 2. Verify no external file modifications
768
+ 3. Try earlier checkpoint
769
+ 4. Manual recovery if needed
770
+
771
+ ## Advanced Usage
772
+
773
+ ### Custom Recovery Strategies
774
+
775
+ ```javascript
776
+ // In your project's .kiro/auto/custom-strategies.js
777
+ module.exports = {
778
+ 'custom-fix': async (error, context) => {
779
+ // Your custom recovery logic
780
+ return {
781
+ success: true,
782
+ action: 'custom-action',
783
+ details: 'Applied custom fix'
784
+ };
785
+ }
786
+ };
787
+ ```
788
+
789
+ ### Integration with CI/CD
790
+
791
+ ```yaml
792
+ # .github/workflows/autonomous-feature.yml
793
+ name: Autonomous Feature Development
794
+
795
+ on:
796
+ issues:
797
+ types: [labeled]
798
+
799
+ jobs:
800
+ develop:
801
+ if: github.event.label.name == 'auto-implement'
802
+ runs-on: ubuntu-latest
803
+ steps:
804
+ - uses: actions/checkout@v2
805
+ - name: Install kse
806
+ run: npm install -g kiro-spec-engine
807
+ - name: Create feature autonomously
808
+ run: kse auto create "${{ github.event.issue.title }}"
809
+ - name: Create pull request
810
+ uses: peter-evans/create-pull-request@v4
811
+ ```
812
+
813
+ ### Monitoring and Alerts
814
+
815
+ ```bash
816
+ # Enable notifications
817
+ kse auto config --notifications enabled=true onError=true onCompletion=true
818
+
819
+ # Export logs for monitoring
820
+ kse auto report --format json | jq '.errors'
821
+ ```
822
+
823
+ ## FAQ
824
+
825
+ **Q: How long does autonomous execution take?**
826
+ A: Depends on feature complexity. Simple features: 5-15 minutes. Complex features: 30-60 minutes. The system provides real-time estimates.
827
+
828
+ **Q: Can I interrupt autonomous execution?**
829
+ A: Yes, use `kse auto stop` or Ctrl+C. State is saved and you can resume later.
830
+
831
+ **Q: What happens if my computer crashes during execution?**
832
+ A: State is saved periodically. Resume from last checkpoint with `kse auto resume`.
833
+
834
+ **Q: How accurate is error recovery?**
835
+ A: Improves over time. Initial success rate ~60-70%, improves to ~85-90% with learning.
836
+
837
+ **Q: Can I review changes before they're applied?**
838
+ A: Yes, use conservative mode with checkpoint reviews enabled.
839
+
840
+ **Q: Does autonomous mode work with existing Specs?**
841
+ A: Yes, use `kse auto run <spec-name>` to execute existing Specs autonomously.
842
+
843
+ **Q: How do I disable autonomous mode?**
844
+ A: Simply don't use `kse auto` commands. Use regular `kse` commands for interactive mode.
845
+
846
+ ## See Also
847
+
848
+ - [Spec Workflow Guide](./spec-workflow.md)
849
+ - [Testing Strategy](./testing-strategy.md)
850
+ - [CORE_PRINCIPLES](./.kiro/steering/CORE_PRINCIPLES.md)
851
+ - [Command Reference](./command-reference.md)