ultra-builder-pro-cli 0.10.0 → 0.12.1

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 (137) hide show
  1. package/.ultra-template/specs/architecture.md +54 -223
  2. package/.ultra-template/specs/discovery.md +34 -231
  3. package/.ultra-template/specs/product.md +44 -200
  4. package/.ultra-template/tasks/contexts/TEMPLATE.md +36 -0
  5. package/.ultra-template/tasks/tasks.json +6 -0
  6. package/CHANGELOG.md +86 -1
  7. package/README.md +21 -9
  8. package/adapters/_shared/codex-assets.cjs +24 -342
  9. package/adapters/_shared/handbook.cjs +4 -3
  10. package/adapters/_shared/runtime-assets.cjs +24 -0
  11. package/adapters/_shared/tests/handbook.test.cjs +4 -0
  12. package/adapters/_shared/tests/runtime-assets.test.cjs +11 -4
  13. package/adapters/claude.js +28 -5
  14. package/adapters/kimi.js +15 -138
  15. package/adapters/opencode.js +22 -49
  16. package/adapters/tests/claude.test.cjs +22 -8
  17. package/adapters/tests/codex.test.cjs +21 -8
  18. package/adapters/tests/kimi-hook.test.cjs +1 -1
  19. package/adapters/tests/kimi.test.cjs +11 -11
  20. package/adapters/tests/opencode.test.cjs +47 -8
  21. package/agents/code-reviewer.md +24 -85
  22. package/agents/debugger.md +30 -132
  23. package/agents/review-code.md +24 -104
  24. package/agents/review-comments.md +20 -83
  25. package/agents/review-coordinator.md +40 -137
  26. package/agents/review-design.md +21 -118
  27. package/agents/review-errors.md +22 -70
  28. package/agents/review-spec.md +36 -0
  29. package/agents/review-tests.md +20 -76
  30. package/agents/tdd-runner.md +26 -84
  31. package/commands/learn.md +5 -36
  32. package/commands/ultra-change.md +5 -43
  33. package/commands/ultra-deliver.md +4 -46
  34. package/commands/ultra-dev.md +4 -48
  35. package/commands/ultra-doctor.md +4 -30
  36. package/commands/ultra-init.md +5 -47
  37. package/commands/ultra-plan.md +5 -48
  38. package/commands/ultra-research.md +5 -54
  39. package/commands/ultra-status.md +5 -44
  40. package/commands/ultra-test.md +5 -45
  41. package/commands/ultra-think.md +5 -40
  42. package/docs/AGENT-CONTEXT.md +16 -8
  43. package/docs/ARCHITECTURE.md +32 -5
  44. package/docs/PLAN.zh-CN.md +8 -6
  45. package/docs/ROADMAP.md +5 -3
  46. package/docs/RUNTIME-COMPAT-MATRIX.md +8 -5
  47. package/docs/SKILL-AUTHORING.md +75 -0
  48. package/docs/STATE-DB-ACCESS-POLICY.md +17 -11
  49. package/docs/USER-HANDBOOK-CONTRACT.md +8 -5
  50. package/hooks/README.md +4 -3
  51. package/hooks/adapters/codex.py +1 -1
  52. package/hooks/adapters/kimi.py +1 -1
  53. package/hooks/context_spine.py +120 -16
  54. package/hooks/health_check.py +11 -0
  55. package/hooks/pre_stop_check.py +6 -5
  56. package/mcp-server/lib/baseline-workflow.cjs +415 -0
  57. package/mcp-server/lib/baseline-workflow.test.cjs +225 -0
  58. package/mcp-server/lib/change-workflow.cjs +24 -27
  59. package/mcp-server/lib/change-workflow.test.cjs +202 -6
  60. package/mcp-server/lib/context-spine.cjs +74 -9
  61. package/mcp-server/lib/context-spine.test.cjs +15 -0
  62. package/mcp-server/lib/doctor.cjs +14 -0
  63. package/mcp-server/lib/doctor.test.cjs +25 -1
  64. package/mcp-server/lib/init-project.cjs +49 -14
  65. package/mcp-server/lib/provider-refs.cjs +42 -0
  66. package/mcp-server/lib/spec-learning.test.cjs +5 -0
  67. package/mcp-server/lib/state-db.cjs +63 -4
  68. package/mcp-server/lib/state-db.test.cjs +8 -3
  69. package/mcp-server/server.cjs +48 -3
  70. package/mcp-server/tests/init-project.test.cjs +54 -8
  71. package/mcp-server/tests/server-contract.test.cjs +99 -2
  72. package/mcp-server/tests/state-db.test.cjs +11 -2
  73. package/package.json +3 -2
  74. package/skills/cc-collab/SKILL.md +16 -18
  75. package/skills/code-review-expert/SKILL.md +39 -114
  76. package/skills/code-review-expert/references/correctness-reliability.md +30 -0
  77. package/skills/code-review-expert/references/design-boundaries.md +26 -0
  78. package/skills/code-review-expert/references/removal-plan.md +17 -45
  79. package/skills/codex-collab/SKILL.md +23 -28
  80. package/skills/codex-collab/evals/evals.json +18 -23
  81. package/skills/integration-rules/SKILL.md +28 -67
  82. package/skills/learn/SKILL.md +46 -106
  83. package/skills/security-rules/SKILL.md +34 -56
  84. package/skills/testing-rules/SKILL.md +28 -52
  85. package/skills/ultra-change/SKILL.md +68 -114
  86. package/skills/ultra-deliver/SKILL.md +58 -86
  87. package/skills/ultra-dev/SKILL.md +46 -105
  88. package/skills/ultra-doctor/SKILL.md +45 -72
  89. package/skills/ultra-init/SKILL.md +62 -147
  90. package/skills/ultra-init/references/brownfield-adoption.md +65 -0
  91. package/skills/ultra-plan/SKILL.md +56 -89
  92. package/skills/ultra-research/SKILL.md +64 -152
  93. package/skills/ultra-research/references/architecture.md +38 -0
  94. package/skills/ultra-research/references/problem-product.md +39 -0
  95. package/skills/ultra-research/references/quality-delivery.md +34 -0
  96. package/skills/ultra-research/references/synthesis.md +38 -0
  97. package/skills/ultra-research/references/users-scope.md +40 -0
  98. package/skills/ultra-review/SKILL.md +54 -98
  99. package/skills/ultra-review/references/unified-schema.md +76 -101
  100. package/skills/ultra-review/scripts/review_wait.py +242 -77
  101. package/skills/ultra-status/SKILL.md +41 -56
  102. package/skills/ultra-test/SKILL.md +37 -72
  103. package/skills/ultra-think/SKILL.md +43 -102
  104. package/skills/ultra-verify/SKILL.md +44 -84
  105. package/skills/ultra-verify/evals/evals.json +24 -27
  106. package/spec/cli-protocol.md +4 -0
  107. package/spec/mcp-tools.yaml +223 -4
  108. package/spec/schemas/command-manifest.schema.json +7 -25
  109. package/spec/schemas/mcp-tools.schema.json +1 -1
  110. package/spec/schemas/skill-manifest.schema.json +9 -79
  111. package/spec/schemas/state-db.sql +33 -2
  112. package/ultra-tools/commands/status.cjs +20 -2
  113. package/ultra-tools/commands/task.cjs +4 -1
  114. package/ultra-tools/status-command.test.cjs +20 -0
  115. package/ultra-tools/system-command.test.cjs +5 -0
  116. package/skills/code-review-expert/references/code-quality-checklist.md +0 -112
  117. package/skills/code-review-expert/references/integration-checklist.md +0 -46
  118. package/skills/code-review-expert/references/security-checklist.md +0 -100
  119. package/skills/code-review-expert/references/solid-checklist.md +0 -65
  120. package/skills/ultra-research/steps/step-00-problem-validation.md +0 -154
  121. package/skills/ultra-research/steps/step-01-opportunity-discovery.md +0 -172
  122. package/skills/ultra-research/steps/step-02-market-assessment.md +0 -195
  123. package/skills/ultra-research/steps/step-03-competitive-landscape.md +0 -197
  124. package/skills/ultra-research/steps/step-04-product-strategy.md +0 -196
  125. package/skills/ultra-research/steps/step-05-assumptions-validation.md +0 -234
  126. package/skills/ultra-research/steps/step-10-user-personas.md +0 -169
  127. package/skills/ultra-research/steps/step-11-user-scenarios.md +0 -181
  128. package/skills/ultra-research/steps/step-20-user-stories.md +0 -156
  129. package/skills/ultra-research/steps/step-21-features-scope.md +0 -157
  130. package/skills/ultra-research/steps/step-22-success-metrics.md +0 -195
  131. package/skills/ultra-research/steps/step-30-architecture-context.md +0 -154
  132. package/skills/ultra-research/steps/step-31-solution-strategy.md +0 -172
  133. package/skills/ultra-research/steps/step-32-building-blocks.md +0 -188
  134. package/skills/ultra-research/steps/step-40-deployment.md +0 -123
  135. package/skills/ultra-research/steps/step-41-quality-risks.md +0 -135
  136. package/skills/ultra-research/steps/step-99-synthesis.md +0 -188
  137. package/skills/ultra-review/scripts/review_verdict_update.py +0 -99
@@ -1,98 +1,71 @@
1
1
  ---
2
2
  name: ultra-doctor
3
- description: "Inspect Ultra state, projection, session, incident, and active-change health; optionally run explicit backup-first mechanical recovery."
4
- user-invocable: true
5
- runtime: all
6
- mcp_tools_required:
7
- - system.doctor
8
- cli_fallback: "system doctor"
3
+ description: Diagnose Ultra state, projection, session, incident, change-artifact, and installed-plugin health with bounded recovery. Use when Ultra state appears missing, projections disagree, hooks fail, or MCP operations report degraded health.
9
4
  ---
10
5
 
11
- # ultra-doctor — Runtime Diagnostics and Recovery
6
+ # Diagnose and recover the Ultra runtime
12
7
 
13
- Use this workflow when Ultra state appears empty, projections disagree with
14
- `state.db`, a hook reports a missing adapter, sessions are orphaned, a change
15
- artifact is missing, or MCP operations return degraded projection metadata.
8
+ Default to read-only diagnosis. Repair only after the user explicitly authorizes it.
16
9
 
17
- ## Default is read-only
10
+ ## Project-state diagnosis
18
11
 
19
- Call `system.doctor` with `{ "repair": false }` unless the user explicitly
20
- requests repair. Read-only diagnosis reports:
12
+ Call `system.doctor` with `{ "repair": false }` and inspect:
21
13
 
22
14
  - SQLite integrity and required tables;
23
15
  - open structured incidents;
24
- - projection queue failures and event/projection cursor lag;
16
+ - event and projection cursor lag;
17
+ - failed or interrupted projection jobs;
25
18
  - orphan sessions;
26
19
  - missing active-change artifact roots;
27
- - the external ownership boundary for Memory and code graph.
20
+ - missing, incomplete, or stale project baseline readiness and specification digests;
21
+ - the boundary to separately installed memory and code-graph providers.
28
22
 
29
- Do not infer health from `tasks.json`. Do not mutate provider state, delete
30
- artifacts, rebuild a graph, or collect memory during diagnosis.
23
+ Do not infer health from generated task JSON. Do not mutate external provider state,
24
+ delete artifacts, or collect memory during diagnosis.
31
25
 
32
- ## Interpret the report
26
+ ## Interpret failures
33
27
 
34
- | Check | Meaning | Next action |
35
- |---|---|---|
36
- | `state_db` fail | schema/integrity problem | stop ordinary workflow; preserve DB evidence |
37
- | `incidents` fail | a structured runtime failure remains open | report code, source, retryability, and evidence |
38
- | `projections` fail | state commit is ahead of generated views or a projector failed | explicit repair is appropriate when authorized |
39
- | `sessions` fail | an orphan execution lease exists | repair may mark/reconcile it; never kill unrelated processes blindly |
40
- | `change_artifacts` fail | DB points to a missing active packet | recover from version control/backup or recreate deliberately |
41
- | `external_providers` pass | ownership is correctly external | provider availability must be checked with its own plugin/tool |
28
+ - State integrity failure blocks ordinary workflows and requires preserving database
29
+ evidence before recovery.
30
+ - An open incident requires its code, source, retryability, and evidence.
31
+ - Projection lag may be mechanically repairable when authority is healthy.
32
+ - An orphan session may be reconciled; never kill unrelated processes blindly.
33
+ - A missing change artifact requires version-control, backup, or deliberate recreation
34
+ evidence rather than silent regeneration.
35
+ - Missing or incomplete baseline evidence routes to `ultra-init`. Doctor repair does
36
+ not approve a baseline, accept known-red verification, or invent adoption evidence.
37
+ Baseline readiness is an advisory workflow check, not state-database corruption and
38
+ not a reason for doctor repair.
42
39
 
43
- ## Explicit repair mode
40
+ ## Explicit repair
44
41
 
45
- Only after the user asks for repair, call `system.doctor` with
46
- `{ "repair": true }`, or use the fallback:
42
+ After authorization, call `system.doctor` with `{ "repair": true }` or use the
43
+ installed `ultra-tools system doctor --repair` fallback. The runtime must create a
44
+ timestamped state database backup before any mechanical repair.
47
45
 
48
- ```bash
49
- ultra-tools system doctor --repair
50
- ```
46
+ Repair is limited to documented recovery operations such as reconciling orphan
47
+ sessions, consuming staleness events, requeueing interrupted or failed projections,
48
+ and regenerating projections from authoritative state. If backup fails, stop. Always
49
+ inspect the post-repair report; a completed repair action does not imply healthy state.
51
50
 
52
- The runtime must create `.ultra/backups/state-<timestamp>.db` before any
53
- mechanical repair. Repair is bounded to:
51
+ ## Installed-plugin failures
54
52
 
55
- - boot recovery for orphan sessions;
56
- - durable consumption of spec-staleness events;
57
- - requeueing projection jobs left `running` beyond the interruption cutoff;
58
- - requeueing failed projection jobs;
59
- - regenerating projections from authoritative state.
53
+ When a hook points to a missing installed file:
60
54
 
61
- If backup fails, repair must stop with `BACKUP_FAILED`. A repair result is not
62
- automatically healthy; inspect the returned post-repair report and keep any
63
- remaining incident unresolved.
55
+ 1. Capture the hook manifest path and missing target.
56
+ 2. Run the installer doctor for the actual host and install scope.
57
+ 3. Preserve provenance, asset-hash, and host-contract findings.
58
+ 4. Reinstall through the host adapter rather than patching a cache directory.
59
+ 5. Rerun installer doctor, `system.doctor`, and a host hook smoke test.
64
60
 
65
- ## Hook/path failures
66
-
67
- For an installed hook that points to a missing cached file:
68
-
69
- 1. capture the exact hook config path and missing target;
70
- 2. run the separate read-only installer boundary check:
71
- `npx ultra-builder-pro-cli --<runtime> --local --doctor --json` (or use
72
- `--global` when that is the actual install scope);
73
- 3. preserve its provenance, asset-hash, and host-contract findings;
74
- 4. reinstall or regenerate the host-native plugin through the adapter;
75
- 5. rerun both installer doctor and `system.doctor`, then a host hook smoke test.
76
-
77
- `system.doctor` diagnoses project `.ultra/state.db` and workflow recovery.
78
- Installer `ubp --doctor` diagnoses the installed plugin files and host wiring.
79
- Neither report substitutes for the other.
80
-
81
- Do not bypass a broken hook by changing application implementation, and do not
82
- treat a hook failure as project-code evidence.
61
+ Project doctor covers `.ultra/state.db`; installer doctor covers packaged files and
62
+ host wiring. Neither substitutes for the other.
83
63
 
84
64
  ## Output
85
65
 
86
- Lead with `healthy` or `degraded`, list only failing checks, and include:
87
-
88
- - incident ids/codes and sources;
89
- - event vs projected cursor;
90
- - whether repair ran;
91
- - backup path when repair ran;
92
- - unresolved actions and their owner (`Ultra`, host plugin, or external provider).
93
-
94
- ## What this skill does not do
66
+ Lead with `healthy` or `degraded`. List failing authority checks separately from
67
+ baseline warnings, incident identifiers, cursor lag, whether repair ran, the backup
68
+ path, and each unresolved action with its owner.
95
69
 
96
- - It does not fix project code or semantic specification conflicts.
97
- - It does not delete state, force-reset git, or close live healthy sessions.
98
- - It does not install, query, refresh, or repair external Memory/graph providers.
70
+ Do not fix application code, delete state, reset Git, close healthy sessions, or
71
+ install and repair external providers through this workflow.
@@ -1,151 +1,66 @@
1
1
  ---
2
2
  name: ultra-init
3
- description: "Initialize Ultra Builder Pro project: detect context, confirm with user, scaffold .ultra/ via task.init_project, set up git."
4
- user-invocable: true
5
- runtime: all
6
- mcp_tools_required:
7
- - task.init_project
8
- cli_fallback: "task init-project"
3
+ description: Initialize Ultra Builder Pro or resume greenfield and brownfield baseline adoption. Use when a repository lacks Ultra state or its project baseline is missing, draft, adopting, or blocked.
9
4
  ---
10
5
 
11
- # ultra-init — Phase 3.1
12
-
13
- 把当前工作目录(或 `--target-dir`)初始化为一个 Ultra Builder Pro 项目:拉起
14
- `.ultra/` 骨架、初始化权威 `state.db`、建立持续变更目录、写入 `tasks.json`
15
- 初始元数据,并按需配置 git。
16
-
17
- 真实的目录搭建 + 模板拷贝 + tasks.json 注入统一由 **MCP tool `task.init_project`** 完成;
18
- MCP 不可达时回退 `ultra-tools task init-project`。
19
-
20
- ## 设计要点(对比 pre-Phase-3 行为)
21
-
22
- - **无 Claude 独占依赖**:`task.init_project` + `ultra-tools init-project` 两条路径
23
- 都不调 Claude 原生工具,Claude Code、OpenCode、Codex 三个 runtime 都能走通。
24
- - **模板内置**:`.ultra/` 骨架来自仓内 `templates/.ultra/`;不再依赖 `~/.claude/.ultra-template/`。
25
- - **幂等**:二次 init 默认拒绝,`--overwrite` 才会备份旧 `.ultra/` 为
26
- `.ultra.backup.<ts>` 后重建。
27
-
28
- ## Workflow
29
-
30
- ### Step 0: 状态检测(skill 调用方做)
31
-
32
- 在调 `task.init_project` 之前,调用方(Claude / CLI / SDK)需要先判断:
33
-
34
- - `target_dir/.ultra/` 是否已存在 → 决定是否需要 `overwrite=true`
35
- - `target_dir/.git/` 是否已存在 → 影响 Step 3 的分支
36
- - 读 `package.json` / `Cargo.toml` / `pyproject.toml` / `go.mod` 推断项目类型和栈
37
- - 如果调用方是 Claude,可在此用 `TaskCreate` 跟踪 Step 0–4 的 session 内进度
38
- (这是 runtime 的 session-local 跟踪,不走 MCP)
39
-
40
- ### Step 1: 补全参数
41
-
42
- 入参不足时补:
43
-
44
- | 字段 | 缺省 |
45
- |------|------|
46
- | `project_name` | 当前目录名(`path.basename(target_dir)`) |
47
- | `project_type` | Step 0 识别结果;多技术栈 → `fullstack` |
48
- | `stack` | Step 0 识别到的依赖(逗号分隔多值,如 `react,express,postgres`) |
49
- | `git_init` | `.git/` 不存在 → 询问用户 |
50
-
51
- ### Step 1.5: 交互确认(仅当检测到模糊或重入)
52
-
53
- 触发条件:
54
- - `target_dir/.ultra/` 已存在(重入)
55
- - 识别到多项目类型(Web + API)
56
- - 显式 `--interactive` 标志
57
-
58
- 交互渠道:
59
- - **Claude runtime**:调 `AskUserQuestion`(原生)
60
- - **其他 runtime**:使用 Host 原生提问界面;若当前表面不支持交互,
61
- 要求用户通过显式命令行参数选择
62
-
63
- 确认 4 个问题:
64
- 1. 项目类型(可多选,`detected` 标签打在识别项)
65
- 2. 技术栈(可多选)
66
- 3. 已有 `.git/` → 保留 / 重置备份 / 不用 git
67
- 4. 已有 `.ultra/` → 覆盖(备份) / 保留 / 取消
68
-
69
- ### Step 2: 调 `task.init_project` 拉起骨架
70
-
71
- **MCP 主路径**:
72
- ```jsonc
73
- // call: task.init_project
74
- {
75
- "target_dir": "/abs/path/to/project",
76
- "project_name": "my-app",
77
- "project_type": "fullstack",
78
- "stack": "react,express,postgres",
79
- "overwrite": false
80
- }
81
- // response
82
- {
83
- "created_path": "/abs/path/to/project/.ultra",
84
- "status": "created",
85
- "copied_files": [
86
- "specs/discovery.md", "specs/product.md", "specs/architecture.md",
87
- "tasks/tasks.json", "tasks/contexts/TEMPLATE.md",
88
- "changes/active/.gitkeep", "changes/archive/.gitkeep",
89
- "docs/research/README.md",
90
- "test-report.json", "delivery-report.json"
91
- ],
92
- "state_db_path": "/abs/path/to/project/.ultra/state.db"
93
- }
94
- ```
95
-
96
- **CLI 回退路径**(`UBP_MCP=off` 或 MCP 调用返回网络错):
97
- ```bash
98
- ultra-tools task init-project \
99
- --target-dir "$TARGET" \
100
- --project-name "$NAME" \
101
- --project-type "$TYPE" \
102
- --stack "$STACK" \
103
- $([ "$OVERWRITE" = "1" ] && echo --overwrite)
104
- ```
105
- CLI 最后一行是 `{ "ok": true, "data": { ... } }`(见 spec/cli-protocol.md §2)。
106
-
107
- **错误处理**:
108
- - `ULTRA_DIR_EXISTS` → Step 1.5 重新询问是否 overwrite
109
- - `TEMPLATE_MISSING` → 致命;提示检查 `templates/.ultra/` 是否被 gitignore 吞了
110
- - `TARGET_NOT_DIR` / `VALIDATION_ERROR` → 返回调用方,修参数
111
- - `IO_ERROR` → retriable=true;最多重试 2 次
112
-
113
- ### Step 3: Git 集成
114
-
115
- 根据 Step 1.5 结果:
116
-
117
- - **初始化新仓**:`git init` + 写 `.gitignore`(排除 `.ultra/backups/`、`node_modules/`、
118
- 敏感文件等项目通用规则)+ 写基础 `README.md`(若不存在)。
119
- - **保留现有 `.git/`**:仅追加 `.gitignore` 里的 `.ultra/backups/` 一行(若缺失)。
120
- - **不用 git**:跳过。
121
-
122
- 提示建议第一个 commit:`git add . && git commit -m "feat: initialize Ultra Builder Pro"`,
123
- 但不代为执行(commit 是用户决策)。
124
-
125
- ### Step 4: 成功总结 + 下一步
126
-
127
- 用中文输出:
128
- - ✅ `.ultra/` 骨架(specs / tasks / changes / docs / reports)
129
- - ✅ `.ultra/state.db` 已初始化为当前 schema,后续不再依赖第一次写操作懒创建
130
- - ✅ tasks.json 注入元数据(name / type / stack / created / updated)
131
- - ✅ git 状态(按选择)
132
- - ⚠️ **下一步**:跑 `/ultra-research` 做 17 步 discovery 填 spec;不要跳过直接 `/ultra-plan`
133
-
134
- ## 调用方式(按 runtime)
135
-
136
- | Runtime | 调用形态 |
137
- |---------|----------|
138
- | Claude | `/ultra-init [name] [type] [stack] [git]` — 命令薄壳拉起此 skill |
139
- | OpenCode | `/ultra-init …` 同上(agent frontmatter 小写化) |
140
- | Codex | `codex exec "run /ultra-init …"`(Phase 4.4 adapter 接) |
141
-
142
- ## 输出锚点
143
-
144
- - `target_dir/.ultra/tasks/tasks.json` — project.name / project.type / project.stack 已注入
145
- - `target_dir/.ultra/specs/{discovery,product,architecture}.md` — 带 `[NEEDS CLARIFICATION]` 标记
146
- - 若 `overwrite=true`:`target_dir/.ultra.backup.<ts>/` 保存旧骨架
147
-
148
- ## 不做的事
149
-
150
- - **不**创建业务 task(业务 task 由 `/ultra-plan` 在 spec 填完后批量创建)
151
- - **不**调 web:离线可执行
6
+ # Initialize or adopt a project
7
+
8
+ Create project-local Ultra state, then route the repository according to its actual
9
+ baseline status. Do not treat an existing codebase as a new product.
10
+
11
+ ## Preflight
12
+
13
+ Use the current working directory unless the user names another target. Inspect the
14
+ root, project manifests, Git state, and `.ultra/` without mutation.
15
+
16
+ If `.ultra/` exists, call `baseline.get` and `system.doctor`:
17
+
18
+ - a healthy `ready` baseline routes to `ultra-change` or `ultra-status`;
19
+ - `draft`, `adopting`, or baseline-blocked state resumes this workflow;
20
+ - state integrity or migration failure routes to `ultra-doctor`;
21
+ - recreation requires explicit authorization and must preserve the returned backup.
22
+
23
+ Never overwrite `.ultra/` merely because the repository is old or its documents are
24
+ incomplete.
25
+
26
+ ## Bootstrap
27
+
28
+ When `.ultra/` is absent, derive project name, type, and stack from repository evidence,
29
+ then call `task.init_project` with `mode: "auto"`. Use an explicit `greenfield` or
30
+ `brownfield` mode only when the user has made that classification authoritative.
31
+
32
+ Verify the returned mode, baseline id and status, state database path, initial
33
+ projection, and copied specification files.
34
+
35
+ ## Route by mode
36
+
37
+ ### Greenfield
38
+
39
+ The new baseline begins as `draft`. Route unresolved product or architecture intent to
40
+ `ultra-research`. That workflow records evidence and converges the baseline before
41
+ planning. Do not create implementation tasks during initialization.
42
+
43
+ ### Brownfield
44
+
45
+ Read `references/brownfield-adoption.md` completely. Adopt current behavior from the
46
+ checkout, tests, maintained documentation, and runtime evidence. Use `baseline.record`
47
+ for the bounded snapshot and `baseline.converge` only after the owner approves the
48
+ captured baseline and any accepted known-red verification.
49
+
50
+ ## Failure handling
51
+
52
+ - `ULTRA_DIR_EXISTS`: inspect and resume; do not retry with overwrite automatically.
53
+ - `BASELINE_EXISTS`: keep the ready baseline unless explicit re-adoption is required.
54
+ - `BASELINE_IN_PROGRESS`: resume the named baseline rather than creating another.
55
+ - `TEMPLATE_MISSING`: report a package-integrity failure and route to installer doctor.
56
+ - `TARGET_NOT_DIR`, `VALIDATION_ERROR`, or `IO_ERROR`: correct only the evidenced input;
57
+ preserve any backup and partial diagnostic.
58
+
59
+ ## Output
60
+
61
+ Report target path, detected mode, baseline id/status/revision, state health, known-red
62
+ verification, blocking unknowns, and one next action. `.ultra/state.db` is authoritative;
63
+ JSON and Markdown projections do not create state.
64
+
65
+ Do not browse by default, invent missing behavior, rewrite application code, create
66
+ business tasks, stage files, or commit as part of initialization.
@@ -0,0 +1,65 @@
1
+ # Brownfield adoption
2
+
3
+ Use this procedure only after `task.init_project` selects `brownfield`, or when an
4
+ existing baseline remains `adopting` or `blocked`.
5
+
6
+ ## Establish the snapshot boundary
7
+
8
+ Bind the repository root, current Git HEAD when available, included paths, excluded
9
+ generated or vendored paths, project manifests, and the user-visible or public seams.
10
+ Use the revision returned by `baseline.record`; non-Git projects receive a deterministic
11
+ workspace revision from the recorded evidence.
12
+
13
+ ## Read current behavior
14
+
15
+ Inspect only the evidence needed to explain the maintained system:
16
+
17
+ - entry points and consumers;
18
+ - persisted state and its writers;
19
+ - external interfaces, events, permissions, and failure paths;
20
+ - tests and their live seams;
21
+ - deployment, migration, and recovery paths when present;
22
+ - maintained documents and their relationship to source.
23
+
24
+ Classify every statement as observed, verified, decided, or unknown. Source and runtime
25
+ evidence outrank stale prose. External memory and code-graph providers may supply
26
+ references, but their content remains outside Ultra state.
27
+
28
+ ## Capture the baseline
29
+
30
+ Update `.ultra/specs/product.md` with confirmed behavior, actors, entry points, failures,
31
+ and acceptance. Update `.ultra/specs/architecture.md` with actual boundaries, authority,
32
+ runtime paths, dependencies, permissions, and recovery. Use `discovery.md` only for
33
+ evidence or decisions that affect scope.
34
+
35
+ Do not redesign the project, normalize it to a preferred architecture, manufacture
36
+ personas or alternatives, or convert every source file into documentation.
37
+
38
+ Run the repository's existing verification commands. Record each result as `pass`,
39
+ `known_red`, or `not_run`. A known-red item needs evidence and a rationale; a missing
40
+ command is not a passing result. Mark an unknown blocking when it can change accepted
41
+ behavior, authority, security, data integrity, or the next implementation plan.
42
+
43
+ Call `baseline.record` with full replacement arrays for:
44
+
45
+ - scope and repository revision;
46
+ - product and architecture specification paths;
47
+ - bounded source, documentation, runtime, test, deployment, or external references;
48
+ - verification results;
49
+ - blocking and non-blocking unknowns;
50
+ - external provider metadata references, when supplied.
51
+
52
+ The server computes specification digests. Do not send prompt, transcript, memory, or
53
+ code-graph payloads.
54
+
55
+ ## Converge
56
+
57
+ Present the observed behavior, known-red verification, blocking unknowns, and material
58
+ decisions to the project owner. After explicit approval, call `baseline.converge` with
59
+ the recorded revision, approver, approval note, and `accept_known_red` only when the
60
+ owner accepted those failures.
61
+
62
+ Resolve returned blockers through evidence or an owner decision, record the replacement
63
+ snapshot, and retry. Adoption is complete only when `baseline.get` and `system.doctor`
64
+ report the baseline ready and current. Route the first new outcome to `ultra-change`, or
65
+ route planning of already accepted work to `ultra-plan`.
@@ -1,109 +1,76 @@
1
1
  ---
2
2
  name: ultra-plan
3
- description: "Turn a validated baseline, active delta, or approved PRD into fresh-context vertical slices with public seams and exact verification contracts."
4
- user-invocable: true
5
- runtime: all
6
- mcp_tools_required:
7
- - task.create
8
- - task.parse_prd
9
- - task.dependency_topo
10
- - plan.export
11
- - plan.get
12
- - change.get
13
- - change.context
14
- - change.breadcrumb
3
+ description: Convert a validated baseline, active delta, or approved PRD into dependency-valid vertical slices with bounded context and exact verification. Use when requirements are ready to become authoritative Ultra tasks.
15
4
  ---
16
5
 
17
- # ultra-plan — Fresh-Context Execution Planning
6
+ # Plan fresh-context execution
18
7
 
19
- Produce a dependency-valid plan whose tasks can be executed in isolated contexts.
20
- `.ultra/state.db` is authoritative; the projector owns task JSON and context
21
- frontmatter.
8
+ Produce a task graph whose slices can be completed independently and verified through
9
+ live product seams. `.ultra/state.db` remains authoritative; task JSON and context
10
+ Markdown are generated projections.
22
11
 
23
- ## Failure boundary
12
+ ## Entry gate
24
13
 
25
- Start with a state-backed MCP read. On `LEGACY_STATE_MIGRATION_REQUIRED`, stop and
26
- instruct:
14
+ Start with a state-backed MCP read. If state or schema health blocks access, stop and
15
+ route to `ultra-doctor`. Never read or write `.ultra/tasks/tasks.json` as a fallback.
16
+ Call `baseline.get`. Initial product planning is blocked until the baseline is
17
+ `ready` and current; route its missing, adopting, blocked, or stale state to
18
+ `ultra-init`. Planning an already active bounded change may continue with the
19
+ baseline condition recorded as a warning. Convergence still requires approved
20
+ adoption, and archive atomically reconciles and verifies revision/spec drift.
27
21
 
28
- ```bash
29
- ultra-tools migrate --from=4.4 --to=4.5 --source-dir <project-root>
30
- ```
22
+ Choose one input:
31
23
 
32
- Never read or write `.ultra/tasks/tasks.json` as authority. If task MCP mutation is
33
- unavailable, stop; there is no task-creation CLI fallback.
24
+ - validated baseline specifications;
25
+ - one active change packet;
26
+ - a raw PRD through the approval-gated mode below.
34
27
 
35
- ## Inputs
36
-
37
- Choose exactly one:
38
-
39
- - validated baseline specs under `.ultra/specs/`;
40
- - one active change packet (`intent.md`, `delta/`, `plan.md`);
41
- - raw PRD using the approval-gated direct mode below.
42
-
43
- Ask only for a product or risk decision that cannot be derived from current evidence.
44
- Record assumptions explicitly; unresolved material assumptions block planning.
28
+ Ask only for product, scope, cost, or risk decisions that cannot be derived from
29
+ current evidence. A material unresolved assumption blocks persistence.
45
30
 
46
31
  ## Planning rules
47
32
 
48
- 1. Trace acceptance through a live entry point, domain behavior, side effects, and a
49
- user-observable/public seam.
50
- 2. Prefer a walking skeleton / `tracer_bullet` before horizontal layers.
51
- 3. Make each task completable in a fresh context: one outcome, bounded references,
52
- explicit dependencies, and one deterministic verification command.
53
- 4. Keep the default context packet at or below 12 files, 12k approximate tokens, and
54
- 40% of the fresh context budget.
55
- 5. Use `expand_contract` only when a wider change is approved and cannot be split
56
- without losing correctness.
57
- 6. Create integration checkpoints at real seams, not after arbitrary task counts.
58
- 7. Include error, recovery, documentation, and migration work in the task that owns
59
- the behavior; do not create unreachable scaffolding tasks.
60
-
61
- ## Task contract
62
-
63
- Every `task.create` must carry or be paired with:
64
-
65
- - outcome and acceptance assertions;
66
- - priority, complexity, dependencies, and ownership paths;
67
- - linked `change_id` when planning a delta;
68
- - `slice_kind`: `tracer_bullet`, `expand_contract`, or `integration_checkpoint`;
69
- - `public_seam`;
70
- - exact `verification_command`;
71
- - required context references and their reasons;
72
- - expected red/green signal for fixes and incidents;
73
- - documentation impact.
74
-
75
- After each task is persisted, compile `change.context` with `role=plan` and
76
- `gate=planning` when it belongs to a change. A blocked readiness result must be fixed
77
- before the task is called executable.
78
-
79
- ## Spec mode / change mode
33
+ 1. Trace acceptance through an entry point, domain behavior, side effects, and a
34
+ user-observable or public seam.
35
+ 2. Prefer a walking skeleton or `tracer_bullet` before horizontal layers.
36
+ 3. Give each task one outcome, bounded ownership, explicit dependencies, required
37
+ references, and one deterministic verification command.
38
+ 4. Use the context budget as an attention signal. Prefer bounded excerpts, direct
39
+ reads, or a smaller slice, but keep necessary files when correctness requires them.
40
+ Budget overflow is a warning, never a reason to inflate a threshold or manufacture
41
+ a smaller but incomplete contract.
42
+ 5. Add integration checkpoints at actual boundaries, not after arbitrary task counts.
43
+ 6. Put validation, errors, recovery, documentation, and migrations in the task that
44
+ owns the behavior.
45
+ 7. Reject scaffolding with no reachable consumer.
46
+
47
+ Every persisted task must include its slice kind, public seam, verification command,
48
+ acceptance evidence, ownership, dependencies, documentation impact, and linked change
49
+ id when applicable.
50
+
51
+ ## Baseline or change mode
80
52
 
81
53
  1. Read the smallest authoritative references that define acceptance.
82
- 2. Build a task DAG in memory and check file-ownership conflicts.
83
- 3. Present the outcome, order, cost/risk concentration, and walking-skeleton seam.
84
- 4. Obtain approval when the plan materially changes scope or cost.
85
- 5. Persist tasks through `task.create`.
86
- 6. Call `task.dependency_topo`; cycles or missing dependencies are blocking.
87
- 7. Call `plan.export`, then verify it with `plan.get` rather than reparsing the file.
88
- 8. For an active change, call `change.breadcrumb` and report its one next action.
89
-
90
- ## PRD direct mode
54
+ 2. Build the task DAG in memory and check dependency and ownership conflicts.
55
+ 3. Present the proposed outcome, execution order, risk concentration, and first live
56
+ seam. Obtain approval if scope, cost, or delivery semantics change materially.
57
+ 4. Persist approved tasks with `task.create`.
58
+ 5. For change-linked tasks, compile `change.context` with the planning role and gate.
59
+ Resolve every readiness blocker before calling a task executable.
60
+ 6. Call `task.dependency_topo`; cycles and missing dependencies block completion.
61
+ 7. Call `plan.export`, then verify the persisted result with `plan.get`.
62
+ 8. Call `change.breadcrumb` when a change is active and return one next action.
63
+
64
+ ## PRD mode
91
65
 
92
66
  1. Call `task.parse_prd` with `dry_run: true`.
93
- 2. Show the proposed vertical slices, topology, conflict surface, and estimated cost.
94
- 3. Require explicit approval. Rejection performs no state write.
95
- 4. On approval, repeat the same parse with `dry_run: false`, then `plan.export`.
96
- 5. Verify dry-run and persisted task ids match; mismatch is a deterministic failure.
97
-
98
- ## Context body
99
-
100
- Human-readable task context may explain intent, acceptance, seam, red/green signal,
101
- and relevant references. It must not duplicate entire specs, provider memory, or a
102
- static codebase tour. The next worker should be able to begin from the manifest and
103
- verify the slice without recovering the planner's full conversation.
67
+ 2. Show the proposed slices, topology, conflict surface, and cost estimate.
68
+ 3. Require explicit approval; rejection performs no state write.
69
+ 4. On approval, repeat with `dry_run: false`, export the plan, and verify that the
70
+ dry-run and persisted task identities agree.
104
71
 
105
72
  ## Completion gate
106
73
 
107
- Planning is complete only when the DAG is valid, every task is reachable through a
108
- public seam, every command is executable, every change-linked task has a ready Context
109
- Manifest v2 snapshot, and no required documentation or decision is unknown.
74
+ Planning is complete only when the DAG is valid, each task reaches a public seam, each
75
+ verification command is executable, every change-linked context is ready, and no
76
+ required documentation or decision remains unknown.