ultra-builder-pro-cli 0.9.0 → 0.10.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 (52) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/README.md +11 -6
  3. package/adapters/_shared/codex-assets.cjs +10 -0
  4. package/adapters/_shared/handbook.cjs +2 -0
  5. package/adapters/_shared/runtime-assets.cjs +1 -0
  6. package/adapters/_shared/tests/handbook.test.cjs +3 -0
  7. package/adapters/_shared/tests/runtime-assets.test.cjs +1 -0
  8. package/adapters/kimi.js +2 -2
  9. package/adapters/opencode.js +46 -17
  10. package/adapters/tests/claude.test.cjs +4 -1
  11. package/adapters/tests/codex.test.cjs +4 -3
  12. package/adapters/tests/kimi.test.cjs +6 -2
  13. package/adapters/tests/opencode.test.cjs +46 -3
  14. package/docs/AGENT-CONTEXT.md +34 -12
  15. package/docs/ARCHITECTURE.md +31 -5
  16. package/docs/PLAN.zh-CN.md +3 -2
  17. package/docs/ROADMAP.md +5 -4
  18. package/docs/RUNTIME-COMPAT-MATRIX.md +7 -5
  19. package/docs/USER-HANDBOOK-CONTRACT.md +9 -2
  20. package/hooks/README.md +6 -4
  21. package/hooks/active_task_context.py +14 -0
  22. package/hooks/context_spine.py +218 -0
  23. package/hooks/health_check.py +1 -1
  24. package/hooks/workflow_context.py +16 -123
  25. package/hooks/workflow_resume.py +21 -0
  26. package/mcp-server/lib/change-workflow.cjs +89 -11
  27. package/mcp-server/lib/change-workflow.test.cjs +202 -7
  28. package/mcp-server/lib/context-spine.cjs +331 -0
  29. package/mcp-server/lib/context-spine.test.cjs +73 -0
  30. package/mcp-server/lib/spec-learning.cjs +191 -0
  31. package/mcp-server/lib/spec-learning.test.cjs +62 -0
  32. package/mcp-server/lib/state-db.cjs +72 -10
  33. package/mcp-server/lib/state-db.test.cjs +7 -2
  34. package/mcp-server/server.cjs +31 -1
  35. package/mcp-server/tests/db-ops.test.cjs +3 -3
  36. package/mcp-server/tests/server-contract.test.cjs +74 -0
  37. package/mcp-server/tests/state-db.test.cjs +20 -3
  38. package/package.json +1 -1
  39. package/skills/learn/SKILL.md +1 -0
  40. package/skills/ultra-change/SKILL.md +91 -118
  41. package/skills/ultra-deliver/SKILL.md +93 -221
  42. package/skills/ultra-dev/SKILL.md +81 -310
  43. package/skills/ultra-doctor/SKILL.md +1 -0
  44. package/skills/ultra-init/SKILL.md +1 -0
  45. package/skills/ultra-plan/SKILL.md +72 -292
  46. package/skills/ultra-review/SKILL.md +79 -407
  47. package/skills/ultra-status/SKILL.md +55 -168
  48. package/skills/ultra-test/SKILL.md +64 -183
  49. package/skills/ultra-think/SKILL.md +1 -0
  50. package/spec/cli-protocol.md +3 -0
  51. package/spec/mcp-tools.yaml +133 -4
  52. package/spec/schemas/state-db.sql +31 -0
@@ -1,6 +1,7 @@
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."
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
4
5
  runtime: all
5
6
  mcp_tools_required:
6
7
  - task.create
@@ -8,322 +9,101 @@ mcp_tools_required:
8
9
  - task.dependency_topo
9
10
  - plan.export
10
11
  - plan.get
12
+ - change.get
13
+ - change.context
14
+ - change.breadcrumb
11
15
  ---
12
16
 
13
- # ultra-plan — Phase 3.3
17
+ # ultra-plan — Fresh-Context Execution Planning
14
18
 
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).
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.
19
22
 
20
- ## Authority failure boundary
23
+ ## Failure boundary
21
24
 
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:
25
+ Start with a state-backed MCP read. On `LEGACY_STATE_MIGRATION_REQUIRED`, stop and
26
+ instruct:
26
27
 
27
28
  ```bash
28
29
  ultra-tools migrate --from=4.4 --to=4.5 --source-dir <project-root>
29
30
  ```
30
31
 
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.
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.
33
34
 
34
- ## Prerequisites
35
+ ## Inputs
35
36
 
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)
37
+ Choose exactly one:
39
38
 
40
- ## Workflow
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.
41
42
 
42
- ### Workflow activation
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.
43
45
 
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.
46
+ ## Planning rules
48
47
 
49
- ### Input Mode Selection (BEFORE Step 0)
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.
50
60
 
51
- Two entry points lead into the planner:
61
+ ## Task contract
52
62
 
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 |
63
+ Every `task.create` must carry or be paired with:
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
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.
183
74
 
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
- ```
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.
293
78
 
294
- ## Quality Standards
79
+ ## Spec mode / change mode
295
80
 
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
81
+ 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.
305
89
 
306
- ## Integration Points
90
+ ## PRD direct mode
307
91
 
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` |
92
+ 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.
315
97
 
316
- ## MCP failure matrix
98
+ ## Context body
317
99
 
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 |
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.
322
104
 
323
- ## What this skill DOES NOT do
105
+ ## Completion gate
324
106
 
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`
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.