ultra-builder-pro-cli 0.9.0 → 0.11.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 (119) hide show
  1. package/CHANGELOG.md +92 -1
  2. package/README.md +11 -6
  3. package/adapters/_shared/codex-assets.cjs +23 -331
  4. package/adapters/_shared/handbook.cjs +2 -0
  5. package/adapters/_shared/runtime-assets.cjs +25 -0
  6. package/adapters/_shared/tests/handbook.test.cjs +3 -0
  7. package/adapters/_shared/tests/runtime-assets.test.cjs +12 -4
  8. package/adapters/claude.js +28 -5
  9. package/adapters/kimi.js +15 -138
  10. package/adapters/opencode.js +59 -63
  11. package/adapters/tests/claude.test.cjs +26 -9
  12. package/adapters/tests/codex.test.cjs +23 -9
  13. package/adapters/tests/kimi.test.cjs +15 -11
  14. package/adapters/tests/opencode.test.cjs +57 -10
  15. package/agents/code-reviewer.md +24 -85
  16. package/agents/debugger.md +30 -132
  17. package/agents/review-code.md +24 -104
  18. package/agents/review-comments.md +20 -83
  19. package/agents/review-coordinator.md +40 -137
  20. package/agents/review-design.md +21 -118
  21. package/agents/review-errors.md +22 -70
  22. package/agents/review-spec.md +36 -0
  23. package/agents/review-tests.md +20 -76
  24. package/agents/tdd-runner.md +26 -84
  25. package/commands/learn.md +5 -36
  26. package/commands/ultra-change.md +5 -43
  27. package/commands/ultra-deliver.md +4 -46
  28. package/commands/ultra-dev.md +4 -48
  29. package/commands/ultra-doctor.md +4 -30
  30. package/commands/ultra-init.md +5 -47
  31. package/commands/ultra-plan.md +5 -48
  32. package/commands/ultra-research.md +5 -54
  33. package/commands/ultra-status.md +5 -44
  34. package/commands/ultra-test.md +5 -45
  35. package/commands/ultra-think.md +5 -40
  36. package/docs/AGENT-CONTEXT.md +34 -12
  37. package/docs/ARCHITECTURE.md +31 -5
  38. package/docs/PLAN.zh-CN.md +3 -2
  39. package/docs/ROADMAP.md +5 -4
  40. package/docs/RUNTIME-COMPAT-MATRIX.md +7 -5
  41. package/docs/SKILL-AUTHORING.md +75 -0
  42. package/docs/USER-HANDBOOK-CONTRACT.md +9 -2
  43. package/hooks/README.md +6 -4
  44. package/hooks/active_task_context.py +14 -0
  45. package/hooks/context_spine.py +218 -0
  46. package/hooks/health_check.py +1 -1
  47. package/hooks/workflow_context.py +16 -123
  48. package/hooks/workflow_resume.py +21 -0
  49. package/mcp-server/lib/change-workflow.cjs +89 -11
  50. package/mcp-server/lib/change-workflow.test.cjs +202 -7
  51. package/mcp-server/lib/context-spine.cjs +331 -0
  52. package/mcp-server/lib/context-spine.test.cjs +73 -0
  53. package/mcp-server/lib/spec-learning.cjs +191 -0
  54. package/mcp-server/lib/spec-learning.test.cjs +62 -0
  55. package/mcp-server/lib/state-db.cjs +72 -10
  56. package/mcp-server/lib/state-db.test.cjs +7 -2
  57. package/mcp-server/server.cjs +31 -1
  58. package/mcp-server/tests/db-ops.test.cjs +3 -3
  59. package/mcp-server/tests/server-contract.test.cjs +74 -0
  60. package/mcp-server/tests/state-db.test.cjs +20 -3
  61. package/package.json +3 -2
  62. package/skills/cc-collab/SKILL.md +16 -18
  63. package/skills/code-review-expert/SKILL.md +39 -114
  64. package/skills/code-review-expert/references/correctness-reliability.md +30 -0
  65. package/skills/code-review-expert/references/design-boundaries.md +26 -0
  66. package/skills/code-review-expert/references/removal-plan.md +17 -45
  67. package/skills/codex-collab/SKILL.md +23 -28
  68. package/skills/codex-collab/evals/evals.json +18 -23
  69. package/skills/integration-rules/SKILL.md +28 -67
  70. package/skills/learn/SKILL.md +46 -105
  71. package/skills/security-rules/SKILL.md +34 -56
  72. package/skills/testing-rules/SKILL.md +28 -52
  73. package/skills/ultra-change/SKILL.md +61 -145
  74. package/skills/ultra-deliver/SKILL.md +63 -229
  75. package/skills/ultra-dev/SKILL.md +46 -338
  76. package/skills/ultra-doctor/SKILL.md +39 -71
  77. package/skills/ultra-init/SKILL.md +59 -139
  78. package/skills/ultra-plan/SKILL.md +50 -310
  79. package/skills/ultra-research/SKILL.md +59 -152
  80. package/skills/ultra-research/references/architecture.md +38 -0
  81. package/skills/ultra-research/references/problem-product.md +39 -0
  82. package/skills/ultra-research/references/quality-delivery.md +34 -0
  83. package/skills/ultra-research/references/synthesis.md +38 -0
  84. package/skills/ultra-research/references/users-scope.md +40 -0
  85. package/skills/ultra-review/SKILL.md +55 -427
  86. package/skills/ultra-review/references/unified-schema.md +76 -101
  87. package/skills/ultra-review/scripts/review_wait.py +242 -77
  88. package/skills/ultra-status/SKILL.md +38 -173
  89. package/skills/ultra-test/SKILL.md +41 -195
  90. package/skills/ultra-think/SKILL.md +43 -101
  91. package/skills/ultra-verify/SKILL.md +44 -84
  92. package/skills/ultra-verify/evals/evals.json +24 -27
  93. package/spec/cli-protocol.md +3 -0
  94. package/spec/mcp-tools.yaml +133 -4
  95. package/spec/schemas/command-manifest.schema.json +7 -25
  96. package/spec/schemas/skill-manifest.schema.json +9 -79
  97. package/spec/schemas/state-db.sql +31 -0
  98. package/skills/code-review-expert/references/code-quality-checklist.md +0 -112
  99. package/skills/code-review-expert/references/integration-checklist.md +0 -46
  100. package/skills/code-review-expert/references/security-checklist.md +0 -100
  101. package/skills/code-review-expert/references/solid-checklist.md +0 -65
  102. package/skills/ultra-research/steps/step-00-problem-validation.md +0 -154
  103. package/skills/ultra-research/steps/step-01-opportunity-discovery.md +0 -172
  104. package/skills/ultra-research/steps/step-02-market-assessment.md +0 -195
  105. package/skills/ultra-research/steps/step-03-competitive-landscape.md +0 -197
  106. package/skills/ultra-research/steps/step-04-product-strategy.md +0 -196
  107. package/skills/ultra-research/steps/step-05-assumptions-validation.md +0 -234
  108. package/skills/ultra-research/steps/step-10-user-personas.md +0 -169
  109. package/skills/ultra-research/steps/step-11-user-scenarios.md +0 -181
  110. package/skills/ultra-research/steps/step-20-user-stories.md +0 -156
  111. package/skills/ultra-research/steps/step-21-features-scope.md +0 -157
  112. package/skills/ultra-research/steps/step-22-success-metrics.md +0 -195
  113. package/skills/ultra-research/steps/step-30-architecture-context.md +0 -154
  114. package/skills/ultra-research/steps/step-31-solution-strategy.md +0 -172
  115. package/skills/ultra-research/steps/step-32-building-blocks.md +0 -188
  116. package/skills/ultra-research/steps/step-40-deployment.md +0 -123
  117. package/skills/ultra-research/steps/step-41-quality-risks.md +0 -135
  118. package/skills/ultra-research/steps/step-99-synthesis.md +0 -188
  119. package/skills/ultra-review/scripts/review_verdict_update.py +0 -99
@@ -1,150 +1,70 @@
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
- runtime: all
5
- mcp_tools_required:
6
- - task.init_project
7
- cli_fallback: "task init-project"
3
+ description: Initialize an Ultra Builder Pro project with authoritative state, baseline specification files, and optional Git setup. Use when a repository has not yet been initialized for the Ultra workflow.
8
4
  ---
9
5
 
10
- # ultra-init — Phase 3.1
6
+ # Initialize an Ultra project
11
7
 
12
- 把当前工作目录(或 `--target-dir`)初始化为一个 Ultra Builder Pro 项目:拉起
13
- `.ultra/` 骨架、初始化权威 `state.db`、建立持续变更目录、写入 `tasks.json`
14
- 初始元数据,并按需配置 git。
8
+ Create the project-local Ultra runtime without inventing product requirements or
9
+ business tasks.
15
10
 
16
- 真实的目录搭建 + 模板拷贝 + tasks.json 注入统一由 **MCP tool `task.init_project`** 完成;
17
- MCP 不可达时回退 `ultra-tools task init-project`。
11
+ ## Inputs
18
12
 
19
- ## 设计要点(对比 pre-Phase-3 行为)
13
+ Use the current working directory unless the user names another target. Inspect
14
+ existing project manifests to infer:
20
15
 
21
- - **无 Claude 独占依赖**:`task.init_project` + `ultra-tools init-project` 两条路径
22
- 都不调 Claude 原生工具,Claude Code、OpenCode、Codex 三个 runtime 都能走通。
23
- - **模板内置**:`.ultra/` 骨架来自仓内 `templates/.ultra/`;不再依赖 `~/.claude/.ultra-template/`。
24
- - **幂等**:二次 init 默认拒绝,`--overwrite` 才会备份旧 `.ultra/` 为
25
- `.ultra.backup.<ts>` 后重建。
16
+ - project name;
17
+ - project type;
18
+ - primary technologies;
19
+ - whether Git and `.ultra/` already exist.
20
+
21
+ Ask only about unresolved ambiguity, optional Git initialization, or permission to
22
+ replace an existing `.ultra/` directory. Never infer permission to overwrite it.
26
23
 
27
24
  ## Workflow
28
25
 
29
- ### Step 0: 状态检测(skill 调用方做)
30
-
31
- 在调 `task.init_project` 之前,调用方(Claude / CLI / SDK)需要先判断:
32
-
33
- - `target_dir/.ultra/` 是否已存在 → 决定是否需要 `overwrite=true`
34
- - `target_dir/.git/` 是否已存在 → 影响 Step 3 的分支
35
- - 读 `package.json` / `Cargo.toml` / `pyproject.toml` / `go.mod` 推断项目类型和栈
36
- - 如果调用方是 Claude,可在此用 `TaskCreate` 跟踪 Step 0–4 的 session 内进度
37
- (这是 runtime 的 session-local 跟踪,不走 MCP)
38
-
39
- ### Step 1: 补全参数
40
-
41
- 入参不足时补:
42
-
43
- | 字段 | 缺省 |
44
- |------|------|
45
- | `project_name` | 当前目录名(`path.basename(target_dir)`) |
46
- | `project_type` | Step 0 识别结果;多技术栈 → `fullstack` |
47
- | `stack` | Step 0 识别到的依赖(逗号分隔多值,如 `react,express,postgres`) |
48
- | `git_init` | `.git/` 不存在 → 询问用户 |
49
-
50
- ### Step 1.5: 交互确认(仅当检测到模糊或重入)
51
-
52
- 触发条件:
53
- - `target_dir/.ultra/` 已存在(重入)
54
- - 识别到多项目类型(Web + API)
55
- - 显式 `--interactive` 标志
56
-
57
- 交互渠道:
58
- - **Claude runtime**:调 `AskUserQuestion`(原生)
59
- - **其他 runtime**:使用 Host 原生提问界面;若当前表面不支持交互,
60
- 要求用户通过显式命令行参数选择
61
-
62
- 确认 4 个问题:
63
- 1. 项目类型(可多选,`detected` 标签打在识别项)
64
- 2. 技术栈(可多选)
65
- 3. 已有 `.git/` → 保留 / 重置备份 / 不用 git
66
- 4. 已有 `.ultra/` → 覆盖(备份) / 保留 / 取消
67
-
68
- ### Step 2: 调 `task.init_project` 拉起骨架
69
-
70
- **MCP 主路径**:
71
- ```jsonc
72
- // call: task.init_project
73
- {
74
- "target_dir": "/abs/path/to/project",
75
- "project_name": "my-app",
76
- "project_type": "fullstack",
77
- "stack": "react,express,postgres",
78
- "overwrite": false
79
- }
80
- // response
81
- {
82
- "created_path": "/abs/path/to/project/.ultra",
83
- "status": "created",
84
- "copied_files": [
85
- "specs/discovery.md", "specs/product.md", "specs/architecture.md",
86
- "tasks/tasks.json", "tasks/contexts/TEMPLATE.md",
87
- "changes/active/.gitkeep", "changes/archive/.gitkeep",
88
- "docs/research/README.md",
89
- "test-report.json", "delivery-report.json"
90
- ],
91
- "state_db_path": "/abs/path/to/project/.ultra/state.db"
92
- }
93
- ```
94
-
95
- **CLI 回退路径**(`UBP_MCP=off` 或 MCP 调用返回网络错):
96
- ```bash
97
- ultra-tools task init-project \
98
- --target-dir "$TARGET" \
99
- --project-name "$NAME" \
100
- --project-type "$TYPE" \
101
- --stack "$STACK" \
102
- $([ "$OVERWRITE" = "1" ] && echo --overwrite)
103
- ```
104
- CLI 最后一行是 `{ "ok": true, "data": { ... } }`(见 spec/cli-protocol.md §2)。
105
-
106
- **错误处理**:
107
- - `ULTRA_DIR_EXISTS` → Step 1.5 重新询问是否 overwrite
108
- - `TEMPLATE_MISSING` → 致命;提示检查 `templates/.ultra/` 是否被 gitignore 吞了
109
- - `TARGET_NOT_DIR` / `VALIDATION_ERROR` → 返回调用方,修参数
110
- - `IO_ERROR` → retriable=true;最多重试 2 次
111
-
112
- ### Step 3: Git 集成
113
-
114
- 根据 Step 1.5 结果:
115
-
116
- - **初始化新仓**:`git init` + 写 `.gitignore`(排除 `.ultra/backups/`、`node_modules/`、
117
- 敏感文件等项目通用规则)+ 写基础 `README.md`(若不存在)。
118
- - **保留现有 `.git/`**:仅追加 `.gitignore` 里的 `.ultra/backups/` 一行(若缺失)。
119
- - **不用 git**:跳过。
120
-
121
- 提示建议第一个 commit:`git add . && git commit -m "feat: initialize Ultra Builder Pro"`,
122
- 但不代为执行(commit 是用户决策)。
123
-
124
- ### Step 4: 成功总结 + 下一步
125
-
126
- 用中文输出:
127
- - ✅ `.ultra/` 骨架(specs / tasks / changes / docs / reports)
128
- - ✅ `.ultra/state.db` 已初始化为当前 schema,后续不再依赖第一次写操作懒创建
129
- - ✅ tasks.json 注入元数据(name / type / stack / created / updated)
130
- - ✅ git 状态(按选择)
131
- - ⚠️ **下一步**:跑 `/ultra-research` 做 17 步 discovery 填 spec;不要跳过直接 `/ultra-plan`
132
-
133
- ## 调用方式(按 runtime)
134
-
135
- | Runtime | 调用形态 |
136
- |---------|----------|
137
- | Claude | `/ultra-init [name] [type] [stack] [git]` — 命令薄壳拉起此 skill |
138
- | OpenCode | `/ultra-init …` 同上(agent frontmatter 小写化) |
139
- | Codex | `codex exec "run /ultra-init …"`(Phase 4.4 adapter 接) |
140
-
141
- ## 输出锚点
142
-
143
- - `target_dir/.ultra/tasks/tasks.json` — project.name / project.type / project.stack 已注入
144
- - `target_dir/.ultra/specs/{discovery,product,architecture}.md` — 带 `[NEEDS CLARIFICATION]` 标记
145
- - 若 `overwrite=true`:`target_dir/.ultra.backup.<ts>/` 保存旧骨架
146
-
147
- ## 不做的事
148
-
149
- - **不**创建业务 task(业务 task 由 `/ultra-plan` 在 spec 填完后批量创建)
150
- - **不**调 web:离线可执行
26
+ 1. Resolve the absolute target directory and verify that it exists.
27
+ 2. Derive the project metadata from repository evidence. Treat user-provided values
28
+ as authoritative when they conflict with inference.
29
+ 3. If `.ultra/` exists, stop and ask whether to keep it, cancel, or recreate it with
30
+ `overwrite: true`. Explain that recreation first preserves a timestamped backup.
31
+ 4. Call `task.init_project` with the smallest complete input:
32
+
33
+ ```json
34
+ {
35
+ "target_dir": "/absolute/project/path",
36
+ "project_name": "example",
37
+ "project_type": "fullstack",
38
+ "stack": "react,node,postgres",
39
+ "overwrite": false
40
+ }
41
+ ```
42
+
43
+ 5. Verify the returned `.ultra` path, `state_db_path`, status, and copied-file list.
44
+ Confirm that the returned state database and baseline specification files exist.
45
+ 6. If the user requested Git setup, initialize Git only when needed and add narrowly
46
+ scoped ignore rules. Do not stage or commit without explicit authorization.
47
+
48
+ If the MCP server cannot start, use the installed
49
+ `ultra-tools task init-project` command only when it is available. The CLI and MCP
50
+ must use the same initializer. Do not simulate initialization by creating projection
51
+ files manually.
52
+
53
+ ## Failure handling
54
+
55
+ - `ULTRA_DIR_EXISTS`: return to the overwrite decision; do not retry automatically.
56
+ - `TEMPLATE_MISSING`: stop and report an installation/package integrity failure.
57
+ - `TARGET_NOT_DIR` or `VALIDATION_ERROR`: correct the input and retry once.
58
+ - `IO_ERROR`: report the affected path and preserve any backup or partial evidence.
59
+
60
+ ## Authority and output
61
+
62
+ `.ultra/state.db` is the durable Ultra authority. Generated JSON and Markdown are
63
+ projections or workflow artifacts and must not be edited to create state.
64
+
65
+ Report the initialized path, state database path, backup path when present, Git
66
+ action, and one next action. Route incomplete product intent to `ultra-research`;
67
+ route an already validated baseline to `ultra-plan`.
68
+
69
+ Do not create business tasks, browse the web, or rewrite an existing README as part
70
+ of initialization.
@@ -1,329 +1,69 @@
1
1
  ---
2
2
  name: ultra-plan
3
- description: "Generate task breakdown from complete specs OR from a raw PRD (Phase 8A). Scope-mode-aware; writes state.db via task.create or task.parse_prd; projector generates tasks.json + contexts/*.md."
4
- runtime: all
5
- mcp_tools_required:
6
- - task.create
7
- - task.parse_prd
8
- - task.dependency_topo
9
- - plan.export
10
- - plan.get
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.
11
4
  ---
12
5
 
13
- # ultra-plan — Phase 3.3
6
+ # Plan fresh-context execution
14
7
 
15
- Transform validated `.ultra/specs/` into an executable task plan. **state.db is
16
- the authority** (D32): every new task is created via MCP `task.create`; the
17
- projector regenerates `.ultra/tasks/tasks.json` and context-md frontmatter
18
- automatically. Context-md bodies are written by this skill (not projector).
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.
19
11
 
20
- ## Authority failure boundary
12
+ ## Entry gate
21
13
 
22
- Before planning, call a state-backed MCP tool. If the MCP server is missing,
23
- unreachable, or returns any authority error, stop before creating tasks. In
24
- particular, `LEGACY_STATE_MIGRATION_REQUIRED` means the project still has a
25
- non-empty v4.4 projection; tell the user to run:
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.
26
16
 
27
- ```bash
28
- ultra-tools migrate --from=4.4 --to=4.5 --source-dir <project-root>
29
- ```
17
+ Choose one input:
30
18
 
31
- Never read or write `.ultra/tasks/tasks.json` as a fallback. It is a generated
32
- projection, not an alternate task store. There is no task-mutation CLI fallback.
19
+ - validated baseline specifications;
20
+ - one active change packet;
21
+ - a raw PRD through the approval-gated mode below.
33
22
 
34
- ## Prerequisites
23
+ Ask only for product, scope, cost, or risk decisions that cannot be derived from
24
+ current evidence. A material unresolved assumption blocks persistence.
35
25
 
36
- - `/ultra-research` completed — specs must be 100% (no `[NEEDS CLARIFICATION]`)
37
- - `.ultra/specs/product.md` + `.ultra/specs/architecture.md` exist
38
- - `.ultra/specs/research-distillate.md` preferred when present (token-efficient)
26
+ ## Planning rules
39
27
 
40
- ## Workflow
28
+ 1. Trace acceptance through an entry point, domain behavior, side effects, and a
29
+ user-observable or public seam.
30
+ 2. Prefer a walking skeleton or `tracer_bullet` before horizontal layers.
31
+ 3. Give each task one outcome, bounded ownership, explicit dependencies, required
32
+ references, and one deterministic verification command.
33
+ 4. Use the context budget returned by the current Ultra contract. Widen it only when
34
+ an approved slice cannot be split without losing correctness.
35
+ 5. Add integration checkpoints at actual boundaries, not after arbitrary task counts.
36
+ 6. Put validation, errors, recovery, documentation, and migrations in the task that
37
+ owns the behavior.
38
+ 7. Reject scaffolding with no reachable consumer.
41
39
 
42
- ### Workflow activation
40
+ Every persisted task must include its slice kind, public seam, verification command,
41
+ acceptance evidence, ownership, dependencies, documentation impact, and linked change
42
+ id when applicable.
43
43
 
44
- At entry, write `.ultra/workflow-state.json` with
45
- `{"command":"ultra-plan","task_id":"plan","step":"0","status":"active","ts":"<ISO8601>"}`.
46
- This activates the workflow-only hooks. Mark it terminal only after the MCP
47
- task writes and verification complete.
44
+ ## Baseline or change mode
48
45
 
49
- ### Input Mode Selection (BEFORE Step 0)
46
+ 1. Read the smallest authoritative references that define acceptance.
47
+ 2. Build the task DAG in memory and check dependency and ownership conflicts.
48
+ 3. Present the proposed outcome, execution order, risk concentration, and first live
49
+ seam. Obtain approval if scope, cost, or delivery semantics change materially.
50
+ 4. Persist approved tasks with `task.create`.
51
+ 5. For change-linked tasks, compile `change.context` with the planning role and gate.
52
+ Resolve every readiness blocker before calling a task executable.
53
+ 6. Call `task.dependency_topo`; cycles and missing dependencies block completion.
54
+ 7. Call `plan.export`, then verify the persisted result with `plan.get`.
55
+ 8. Call `change.breadcrumb` when a change is active and return one next action.
50
56
 
51
- Two entry points lead into the planner:
57
+ ## PRD mode
52
58
 
53
- | Mode | When | Path |
54
- |------|------|------|
55
- | **Spec Mode** (default) | `.ultra/specs/` exists and `/ultra-research` is complete | Steps 0–7 below |
56
- | **PRD Direct** (Phase 8A) | User hands you a raw PRD (path or inline text) and wants to skip the spec layer | see **PRD Direct Workflow** below |
59
+ 1. Call `task.parse_prd` with `dry_run: true`.
60
+ 2. Show the proposed slices, topology, conflict surface, and cost estimate.
61
+ 3. Require explicit approval; rejection performs no state write.
62
+ 4. On approval, repeat with `dry_run: false`, export the plan, and verify that the
63
+ dry-run and persisted task identities agree.
57
64
 
58
- ---
59
-
60
- ### PRD Direct Workflow (Phase 8A — human-gated artifact)
61
-
62
- For a one-shot PRD → task graph pipeline with approval gate:
63
-
64
- 1. **Dry-run parse** (no state.db writes):
65
- ```jsonc
66
- // MCP
67
- { "tool": "task.parse_prd", "args": { "prd_path": "<path>", "dry_run": true, "tag": "<branch>" } }
68
- ```
69
- Returns `{ tasks: [...], topo: [[...],[...]] }` without touching state.db.
70
-
71
- 2. **Build execution plan** (in-memory via the server's `plan-builder`):
72
- The server composes `computeWaves` + `files_modified` overlap + `pricing.computeCost`
73
- into a plan with `waves`, `ownership_forecast`, `conflict_surface`, and
74
- estimated cost / duration.
75
-
76
- 3. **Human gate** — ask through the current Host's native user-interaction
77
- surface with the plan summary and estimated cost:
78
- - `approve` → re-run `task.parse_prd` **with `dry_run: false`** to commit
79
- tasks, then `plan.export { out_path: ".ultra/execution-plan.json" }`
80
- to land the artifact and emit the `plan_approved` event.
81
- - `reject` → **do not** call the non-dry-run path. No state.db rows, no
82
- artifact. Prompt user for PRD revision and loop.
83
-
84
- 4. **Post-approval** — the artifact at `.ultra/execution-plan.json` is the
85
- source of truth for Phase 8B orchestration (wave-by-wave dispatch).
86
- Use `plan.get { section: "topo" | "conflicts" | "all" }` to inspect
87
- without re-reading the file.
88
-
89
- **AC guarantees**:
90
- - `reject` path performs zero state.db writes (dry_run=true on parse).
91
- - `approve` path emits exactly one `plan_approved` event, tied to the
92
- persisted artifact path.
93
- - Task IDs returned by the dry-run and the final persisted tasks are
94
- identical (parser is deterministic given the same LLM output).
95
-
96
- ---
97
-
98
- ### Step 0 — Scope Mode Selection
99
-
100
- Ask the user which posture this plan takes. **Commit once selected — do not
101
- drift silently.**
102
-
103
- | Mode | Posture | Use when |
104
- |------|---------|----------|
105
- | **EXPAND** | "What would make this 10x better for 2x effort?" — surface stretch opportunities | Greenfield, user wants to think bigger |
106
- | **SELECTIVE** (default) | Baseline scope held; optional expansions surfaced individually | Most common; feature work on existing product |
107
- | **HOLD** | Scope locked; make it bulletproof; catch every failure mode | Requirements clear, need execution depth |
108
- | **REDUCE** | Find the minimum viable version; cut ruthlessly | MVP, time pressure, PoC |
109
-
110
- Use the current Host's native picker. If that Host has no structured picker,
111
- present the choices directly and require an explicit answer.
112
-
113
- **Dual-scale effort** on every EXPAND/SELECTIVE expansion decision:
114
- `Complete: ~X LOC, AI ~Y min | Shortcut: ~X LOC, saves Y min but ___`
115
-
116
- ### Step 1 — Specification Completeness Validation (BLOCK gate)
117
-
118
- Read specs and check field-by-field. **Fail loud** — don't generate a plan
119
- against broken specs.
120
-
121
- **discovery.md** (if present):
122
- - §0 Problem Validation has demand signal + confidence %
123
- - §2 Market Assessment has TAM/SAM/SOM with numbers + sources
124
- - §3 Competitive Landscape has ≥2 competitors compared
125
- - §4 Product Strategy has ≥3 trade-offs
126
-
127
- **product.md**:
128
- - §2 Personas: ≥2 with goals + pain points
129
- - §3 Scenarios: ≥3 with current + desired flow
130
- - §4 User Stories: acceptance criteria in Given/When/Then
131
- - §5 Feature Scope: Features Out section with rationale
132
- - §6 Success Metrics: North Star has numeric target
133
-
134
- **architecture.md**:
135
- - §1 Quality Goals: ≥3 measurable scenarios
136
- - §4 Solution Strategy: tech stack with URL-cited rationale
137
- - §5 Building Blocks: modules map to features
138
- - §6 Runtime Scenarios: ≥1 with data flow
139
-
140
- **Fail if**: `[NEEDS CLARIFICATION]` markers present / file missing / checklist fails.
141
- On fail → instruct user to run `/ultra-research` targeting the gap.
142
-
143
- ### Step 2 — Requirements + Codebase Analysis
144
-
145
- **Requirements extraction** (prefer distillate):
146
- - Functional requirements (product.md §4)
147
- - Technical constraints (architecture.md §2)
148
- - Quality requirements (architecture.md §10)
149
- - Success metrics (product.md §6)
150
-
151
- **Codebase analysis** (for AI-executable context):
152
- - Directory structure (src/ tests/ config/)
153
- - Existing patterns worth referencing
154
- - Tech stack detection (framework versions, test runners)
155
- - Naming conventions
156
-
157
- ### Step 3 — Task Generation
158
-
159
- #### tasks.json schema (v4.5 projection, source in state.db)
160
-
161
- Fields per task: `id`, `title` (action verb + target), `type`
162
- (architecture/feature/bugfix), `priority` (P0-P3), `complexity` (1-10),
163
- `status` (pending initially), `deps` (task IDs), `estimated_days`,
164
- `context_file`, `trace_to` (spec section anchor).
165
-
166
- #### Integration tasks — MANDATORY inserts
167
-
168
- 1. **Walking Skeleton — always Task #1, P0, type=architecture**
169
- - Title: "Walking skeleton: {primary use case} end-to-end"
170
- - Must touch every layer: entry → use case → domain → persistence
171
- - Acceptance: one real request returns real data through all layers
172
-
173
- 2. **Contract Definition** (when specs show component boundaries)
174
- - Title: "Define contract: {component A} ↔ {component B}"
175
- - Must PRECEDE implementation tasks on both sides
176
- - Acceptance: shared interface/schema + contract test
177
-
178
- 3. **Integration Checkpoint** — every 3-4 feature tasks
179
- - Title: "Integration checkpoint: verify {feature group} connectivity"
180
- - Acceptance: components from recent tasks communicate end-to-end
181
-
182
- #### Task granularity
183
-
184
- - Ideal complexity: 3-5 (one-session completable)
185
- - Too large (>6) → split
186
- - Too small (<3) → merge
187
- - Context budget: target 40% per task; max 8 files touched; complexity ≥7 must split
188
-
189
- ### Step 4 — Dependency Analysis
190
-
191
- - Build dependency graph from each task's `deps` list
192
- - Detect cycles (DFS with visited + recursion stack) — cycles are **fatal**
193
- - Topological order → surface parallel opportunities
194
- - Vertical slicing check: flag any task touching only one layer → split or merge
195
- - Walking skeleton blocks all feature tasks
196
- - Contract tasks precede their consumer implementations
197
-
198
- ### Step 5 — Persist via MCP `task.create`
199
-
200
- For **each** task in the planned list (topological order):
201
-
202
- ```jsonc
203
- // MCP call per task
204
- {
205
- "id": "1", // optional; server mints uuid if omitted
206
- "title": "Walking skeleton: …",
207
- "type": "architecture",
208
- "priority": "P0",
209
- "complexity": 4,
210
- "estimated_days": 2,
211
- "deps": [],
212
- "tag": "<git branch>", // optional
213
- "trace_to": ".ultra/specs/product.md#US-01"
214
- }
215
- ```
216
-
217
- After each `task.create`, the server auto-runs the projector — `tasks.json`
218
- and `contexts/task-{id}.md` (frontmatter only) appear.
219
-
220
- Create one task per `task.create` call so every write is schema-validated and
221
- projected through the same live MCP contract.
222
-
223
- ### Step 5.5 — Context-md body (skill responsibility)
224
-
225
- Projector writes the frontmatter; this skill writes the body. For each task,
226
- write `.ultra/tasks/contexts/task-{id}.md` body (projector preserves it):
227
-
228
- ```markdown
229
- ## Context
230
- **What**: …
231
- **Why**: … (Persona/Scenario link)
232
- **Constraints**: - …
233
-
234
- ## Implementation
235
- **Target Files**: - path/to/file.ts (create|modify: desc)
236
- **Pattern**: …
237
- **Tech Notes**: …
238
-
239
- ## Acceptance
240
- **Tests**: - [ ] `test cmd`
241
- **Verification**: ```bash …```
242
-
243
- ## Trace
244
- **Source**: `.ultra/specs/product.md#US-01`
245
-
246
- ## Change Log
247
- | Date | Change | Specs Updated | Reason |
248
- |------|--------|---------------|--------|
249
-
250
- ## Completion
251
- > _Filled when task completed by /ultra-dev_
252
- ```
253
-
254
- ### Step 6 — Plan Verification (BLOCKING)
255
-
256
- Run programmatic checks **before** presenting to user:
257
-
258
- | Check | Severity | Action on fail |
259
- |-------|----------|----------------|
260
- | Every user story (US-XX) mapped to ≥1 task via `trace_to` | CRITICAL | create missing task or flag |
261
- | Dependency graph acyclic | CRITICAL | report cycle chain, block |
262
- | `trace_to` points at real spec anchor | WARN | suggest correction |
263
- | Tasks with complexity ≥7 | WARN | suggest split |
264
- | Tasks touching >8 files | WARN | suggest split |
265
- | Total tasks >20 | WARN | suggest phased delivery |
266
- | Per-task complexity × 5% context > 40% | WARN | split recommended |
267
-
268
- All CRITICAL pass → present to user (Step 7). Any CRITICAL fail → auto-fix or surface.
269
-
270
- ### Step 7 — Report + Next Steps
271
-
272
- Summary output:
273
- - Total tasks, priority distribution (P0/P1/P2), complexity histogram
274
- - Dependency edge count, parallel-track count
275
- - Estimated total effort (sum of `estimated_days`)
276
- - Requirement coverage % (stories mapped / stories total)
277
- - First task details (Walking Skeleton)
278
- - Suggest `/ultra-dev`
279
-
280
- ### Continuation block (MANDATORY)
281
-
282
- ```markdown
283
- ---
284
- ## ▶ Next Up
285
- **Start Development** — TDD workflow on Task #1: {Walking Skeleton title}
286
-
287
- `/clear` then `/ultra-dev`
288
-
289
- ---
290
- **Also available**: `/ultra-status`
291
- ---
292
- ```
293
-
294
- ## Quality Standards
295
-
296
- - 100% requirement coverage (every user story mapped)
297
- - Clear acceptance criteria per task
298
- - No circular dependencies
299
- - Realistic complexity (justifiable in review)
300
- - Action-verb titles
301
- - Walking Skeleton is Task #1
302
- - Every feature task is a vertical slice (≥2 layers)
303
- - Integration checkpoint every 3-4 feature tasks
304
- - Contract tasks precede cross-boundary implementations
305
-
306
- ## Integration Points
307
-
308
- | | |
309
- |---|---|
310
- | **Prerequisite** | `/ultra-research` — specs 100% complete |
311
- | **Input** | `.ultra/specs/research-distillate.md` (primary), `product.md`, `architecture.md`, `discovery.md` |
312
- | **Writes** | state.db via `task.create`; context-md bodies |
313
- | **Output (projected)** | `.ultra/tasks/tasks.json`, `.ultra/tasks/contexts/task-*.md` |
314
- | **Next** | `/ultra-dev` |
315
-
316
- ## MCP failure matrix
317
-
318
- | Purpose | MCP tool | Failure behavior |
319
- |---------|----------|------------------|
320
- | Scope mode prompt | none | current Host's native user-interaction surface |
321
- | Create task | `task.create` | stop; surface the MCP error; never write a projection |
322
-
323
- ## What this skill DOES NOT do
65
+ ## Completion gate
324
66
 
325
- - Does NOT write state.db directly — all task writes go through `task.create`
326
- - Does NOT regenerate `tasks.json` — projector owns that
327
- - Does NOT read `tasks.json` when MCP state is empty or unavailable
328
- - Does NOT start implementation — that's `/ultra-dev`
329
- - Does NOT re-run research — if specs are incomplete, redirects to `/ultra-research`
67
+ Planning is complete only when the DAG is valid, each task reaches a public seam, each
68
+ verification command is executable, every change-linked context is ready, and no
69
+ required documentation or decision remains unknown.