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,349 +1,57 @@
1
1
  ---
2
2
  name: ultra-dev
3
- description: "Agile development execution with TDD workflow. Writes state through live task MCP tools, reviews through native host subagents, and checkpoints through workflow-state plus lifecycle hooks."
4
- runtime: all
5
- mcp_tools_required:
6
- - task.update
7
- - task.get
8
- - task.list
9
- - change.get
10
- - change.context
3
+ description: Execute one authoritative Ultra task through a bounded fresh context, a red-green feedback loop, live-path verification, and review. Use when a dependency-ready planned slice is ready for implementation.
11
4
  ---
12
5
 
13
- # ultra-dev — Phase 3.4
6
+ # Execute one vertical slice
14
7
 
15
- Drive one task from `pending → completed` using a strict TDD loop, gated by
16
- `/ultra-review`. **state.db is the authority**: status transitions go through
17
- MCP `task.update`; the projector regenerates `tasks.json` and context-md
18
- frontmatter. For a task linked by `change_id`, requirement discoveries go to
19
- the active change delta first; baseline reconciliation happens in
20
- `/ultra-deliver`.
8
+ Drive one task from `pending` to `completed` without widening its contract silently.
21
9
 
22
- ## Authority failure boundary
10
+ ## Authority and recovery
23
11
 
24
- All task selection and transitions require the live MCP state tools. If they
25
- are unavailable or return an authority error, stop. For
26
- `LEGACY_STATE_MIGRATION_REQUIRED`, instruct:
12
+ Task state changes use `task.update`. Never write raw SQLite, generated task JSON, or
13
+ projected status fields. If task MCP access fails, stop and route state health to
14
+ `ultra-doctor`.
27
15
 
28
- ```bash
29
- ultra-tools migrate --from=4.4 --to=4.5 --source-dir <project-root>
30
- ```
31
-
32
- Never fall back to `.ultra/tasks/tasks.json`, direct SQLite writes, or a task
33
- CLI. The JSON file is only a projector-owned view.
34
-
35
- ## Design decisions vs pre-Phase-3
36
-
37
- - **Single-write status**: Step 1.5 / Step 5 stop touching `contexts/task-{id}.md`
38
- frontmatter or the "`> **Status**: xxx`" line. Only MCP `task.update` fires;
39
- projector rewrites frontmatter; humans read body for history.
40
- - **Native review path**: `/ultra-review all` delegates bounded review work to
41
- the current Host's installed review agents. Review is not an MCP service.
42
- - **No `/compact` dependency**: Step 4.4 writes `.ultra/workflow-state.json`;
43
- trusted lifecycle hooks preserve and restore it around compaction when the
44
- Host exposes those events.
45
-
46
- ## Prerequisites
47
-
48
- - `task.list` succeeds against state.db and returns at least one `pending` task
49
-
50
- ## Arguments
51
-
52
- - `$1`: task id (optional; default = first `pending` task in topological order)
16
+ Read `change.breadcrumb` when a change is active. Stale context, blocked readiness,
17
+ unknown documentation impact, or a HEAD mismatch blocks implementation.
53
18
 
54
19
  ## Workflow
55
20
 
56
- ### Step 0 — Workflow Resume Check
57
-
58
- Read `.ultra/workflow-state.json` if present.
59
- - If `branch` matches current `git branch --show-current` → resume from the
60
- step after `status`
61
- - If `review_session` is set → skip re-running review
62
- - Otherwise → proceed to Step 0.5
63
-
64
- ### Step 0.5 — Design Approval Gate (first run only)
65
-
66
- Fires when `.ultra/workflow-state.json` does NOT exist.
67
-
68
- 1. `task.list` → confirm plan present; if empty, instruct `/ultra-plan` and **EXIT**
69
- 2. If ANY task has `status` in (`in_progress`, `completed`) → plan was already
70
- approved → skip this gate
71
- 3. Present plan overview (totals, P0/P1/P2, Walking-Skeleton position)
72
- 4. Ask through the current Host's native user-interaction surface:
73
- - A: "Confirm, start implementation" → continue to Step 1
74
- - B: "Revise plan first" → suggest `/ultra-plan` → **EXIT**
75
- 5. On approval, write workflow-state:
76
- ```jsonc
77
- {"command":"ultra-dev","task_id":0,"branch":"","step":"0.5","status":"design_approved","ts":"<ISO8601>"}
78
- ```
79
-
80
- ### Step 1 — Task Selection
81
-
82
- ```jsonc
83
- // MCP: task.list (or runtime args supply id)
84
- { "status": "pending" }
85
- ```
86
-
87
- Pick the first result (dependency-resolved) or the one matching `$1`.
88
- Read `.ultra/tasks/contexts/task-{id}.md` body for the Implementation /
89
- Acceptance sections. Use the Acceptance list as the initial todo set.
90
-
91
- If the task has `change_id`, call `change.get` and inspect its
92
- `context-manifest.json`. The task id, git head, allowed paths, spec refs, and
93
- external provider metadata must match the current slice. Call `change.context`
94
- before editing whenever they are stale. Provider content remains external.
95
-
96
- ### Step 1.5 — Status → in_progress (single-write)
97
-
98
- ```jsonc
99
- // MCP: task.update (R: do NOT touch context-md frontmatter or "> **Status**" line)
100
- { "id": "<id>", "patch": { "status": "in_progress" } }
101
- ```
102
-
103
- Projector runs after the write → `tasks.json` + `contexts/task-{id}.md`
104
- frontmatter re-generated with `status: in_progress`. **Do not hand-edit either.**
105
-
106
- ### Step 2 — Environment Setup
107
-
108
- **Unmerged-completed recovery**: `git branch --list 'feat/task-*'`; for each,
109
- extract task id, look up status via `task.get`. If any completed task has an
110
- unmerged branch → ask the user:
111
- - "Merge task-{id} to main first" (recommended)
112
- - "Delete branch (abandoned)"
113
- - "Skip, continue with new task"
114
-
115
- **Branch setup**:
116
-
117
- | Current branch | Action |
118
- |----------------|--------|
119
- | `main` / `master` | `git pull origin main && git checkout -b feat/task-{id}-{slug}` |
120
- | `feat/task-{id}-*` (same task) | continue (resume checkpoint) |
121
- | other | ask the user: switch to main + new branch / continue current |
122
-
123
- **Dependencies**: soft-warn only; parallel work is allowed.
124
-
125
- ### Step 3 — TDD Cycle
126
-
127
- **Subagent isolation (complexity ≥ 7)**: optional — delegate a bounded TDD
128
- cycle through the current Host's native subagent surface; the subagent returns
129
- a summary and the primary agent owns verification.
130
-
131
- **Mid-TDD checkpoint (complexity ≥ 6)**: after GREEN phase, write a
132
- checkpoint. See Step 4.4 for the preferred MCP route.
133
-
134
- **RED** — write failing tests:
135
- - Mine Acceptance list for test specs
136
- - Cover 5 dimensions: functional / boundary / exception / security / integration
137
- - At least one integration test per boundary-crossing module
138
- - Run; confirm failure
139
-
140
- **GREEN** — minimum code to pass:
141
- - Production-ready (no TODO / placeholder)
142
- - Run; confirm pass
143
-
144
- **REFACTOR** — SOLID / DRY / KISS / YAGNI; tests stay green.
145
-
146
- **Checkpoint after Step 3.3**:
147
- ```jsonc
148
- {"command":"ultra-dev","task_id":<id>,"branch":"<branch>","step":"3.3","status":"tdd_complete","ts":"<iso>"}
149
- ```
150
- → `.ultra/workflow-state.json`
151
-
152
- ### Step 4 — Quality Gates
153
-
154
- | Gate | Requirement |
155
- |------|-------------|
156
- | Tests green | 0 failures |
157
- | Coverage | ≥80% overall; 100% functional-core; critical paths for shell |
158
- | Mock policy | Core logic: no mocks; external: testcontainers/stub OK |
159
- | No degradation | Zero fallback or demo code |
160
- | Integration test | Boundary-crossing code has ≥1 real integration test |
161
- | Entry-point reachable | New modules trace to a handler/listener/cron |
162
- | Spec compliance | Each Acceptance criterion implemented AND tested |
163
-
164
- Checkpoint `step="4"`, `status="gates_passed"`.
165
-
166
- ### Step 4.4 — Pre-Review Checkpoint
167
-
168
- 1. Write `.ultra/workflow-state.json` with `step=4.5, status=pre_review`.
169
- 2. Let trusted Host lifecycle hooks preserve and restore that state when
170
- compaction events exist.
171
- 3. On Hosts without compaction hooks, resume directly from the same file.
172
-
173
- **Gate**: the skill MUST NOT require `/compact`; it MUST work when the
174
- runtime cannot compact.
175
-
176
- ### Step 4.5 — Ultra Review (MANDATORY)
177
-
178
- Invoke `/ultra-review all`. The workflow uses the current Host's installed
179
- review agents and writes the unified review artifact. The primary agent owns
180
- the final verdict and re-runs relevant tests after fixes.
181
-
182
- **MAX_REVIEW_ITERATIONS = 2**
183
-
184
- | Verdict | Iter | Action |
185
- |---------|------|--------|
186
- | APPROVE | any | → Step 5 |
187
- | COMMENT | any | review P1s, fix if warranted, → Step 5 |
188
- | REQUEST_CHANGES | 1 | fix ALL P0, re-run tests, `/ultra-review recheck` |
189
- | REQUEST_CHANGES | 2 | stall check → escalate or fix |
190
-
191
- **Stall detection before iter 2**: if `curr_count >= prev_count` (P0+P1 not
192
- shrinking) → write `UNRESOLVED.md`, WARN user, proceed to Step 5.
193
-
194
- **Verification gate before Step 5**:
195
- - SUMMARY.json verdict ≠ `REQUEST_CHANGES`
196
- - All P0 resolved
197
- - Tests still green
198
-
199
- Checkpoint `step="4.5", status="review_done", review_session=<id>, review_iteration=<N>`.
200
-
201
- ### Step 5 — Status → completed (single-write)
202
-
203
- **Prerequisites**: Step 4 + Step 4.5 green.
204
-
205
- ```jsonc
206
- // MCP: task.update
207
- {
208
- "id": "<id>",
209
- "patch": {
210
- "status": "completed"
211
- }
212
- }
213
- ```
214
-
215
- Projector regenerates frontmatter. **Then** write the context-md **body**
216
- Completion section (skill responsibility, not projector):
217
-
218
- ```markdown
219
- ## Completion
220
- - **Completed**: <YYYY-MM-DD>
221
- - **Commit**: _pending_ # filled in Step 6
222
- - **Summary**: <one-line delivery summary>
223
- ```
224
-
225
- **Do not** hand-edit `> **Status**` anywhere in the body — frontmatter owns it.
226
-
227
- ### Step 5.5 — Pre-Commit Checklist (BLOCKING)
228
-
229
- Before `git commit`, verify every item:
230
-
231
- - [ ] `task.get` confirms `status="completed"`
232
- - [ ] context-md body has updated Completion section
233
- - [ ] All tests pass
234
- - [ ] Ultra Review verdict ≠ `REQUEST_CHANGES`
235
- - [ ] New modules reach a live entry point (no orphan)
236
- - [ ] Boundary-crossing code has integration test
237
-
238
- Any unchecked → fix; do NOT commit.
239
-
240
- ### Step 6 — Commit + Merge
241
-
242
- 1. `git status` → show diff
243
- 2. Ask through the current Host's native user-interaction surface:
244
- - A: "Commit + Merge to main" (recommended)
245
- - B: "Commit only, create PR later"
246
- - C: "Review diff first" → `git diff --stat` → re-ask
247
-
248
- 3. On approval:
249
- ```bash
250
- git add -A
251
- git commit -m "feat(scope): description"
252
- ```
253
-
254
- 4. Record commit hash via MCP:
255
- ```jsonc
256
- { "id": "<id>", "patch": { "completion_commit": "<sha>" } }
257
- ```
258
- Update context-md body Completion line to the real hash; amend:
259
- ```bash
260
- git add .ultra/tasks/contexts/task-<id>.md
261
- git commit --amend --no-edit
262
- ```
263
- (The amend is OK here — the first commit is a local, not-yet-pushed commit
264
- in the feature branch. Never amend pushed commits.)
265
-
266
- 5. `git fetch origin && git rebase origin/main`; resolve any conflicts.
267
-
268
- 6. Re-run tests after rebase. Fail → fix → amend → repeat 5-6.
269
-
270
- 7. If Option A chosen:
271
- ```bash
272
- git checkout main && git pull origin main
273
- git merge --no-ff feat/task-<id>-<slug>
274
- git push origin main && git branch -d feat/task-<id>-<slug>
275
- ```
276
-
277
- 8. For a task with `change_id`, call `change.context` after the final commit,
278
- rebase, and verification so the manifest records the actual HEAD and task
279
- set used for convergence.
280
-
281
- Checkpoint `step="6", status="committed", commit=<sha>`.
282
-
283
- ### Step 7 — Report
284
-
285
- - Commit hash
286
- - Project progress (`task.list` → `completed/total`)
287
- - Next task suggestion (first remaining `pending` in topological order)
288
-
289
- ## Delta-First Specification Mode
290
-
291
- Triggered when implementation reveals specification gaps or requirement changes.
292
-
293
- **Classification (mandatory before updating specs)**:
294
-
295
- | Kind | Meaning | Action |
296
- |------|---------|--------|
297
- | **EXPANSION** | new requirement surfaced | update active change delta + Change Log |
298
- | **CORRECTION** | spec error/ambiguity | update active change delta + Change Log |
299
- | **REDUCTION** | removing/weakening scope | **STOP** → ask the user for approval |
300
-
301
- **REDUCTION gate** — options:
302
- - A: "Approve reduction, update spec"
303
- - B: "Keep original scope, find alternative implementation"
304
- - C: "Split into separate task, defer to next cycle"
305
-
306
- For a task with `change_id`, update
307
- `.ultra/changes/active/<change-id>/delta/` immediately, then recompile
308
- `change.context`. Do not silently rewrite the baseline while parallel tasks are
309
- still executing. `/ultra-deliver` must reconcile the approved delta into the
310
- declared baseline files before archive.
311
-
312
- For an initial-baseline task with no `change_id`, update `.ultra/specs/`
313
- directly because no continuous-change packet exists yet. In both cases log the
314
- decision in the context-md body Change Log:
315
-
316
- ```markdown
317
- | <date> | <KIND> | <change desc> | specs/<file>#<section> | <reason> |
318
- ```
319
-
320
- **Principle**: the baseline specs describe accepted product truth; the active
321
- delta describes proposed change; task contexts record implementation history.
322
- No layer may silently shrink scope without the REDUCTION gate.
323
-
324
- ## MCP failure matrix
325
-
326
- | Purpose | MCP tool (phase) | Failure behavior |
327
- |---------|------------------|------------------|
328
- | Select pending task | `task.list` (2) / `task.get` (2) | stop and surface the MCP error |
329
- | Status → in_progress | `task.update` (2) | stop; do not edit a projection |
330
- | Pre-review checkpoint | none | write `.ultra/workflow-state.json`; lifecycle hooks restore it |
331
- | Run review | none | `/ultra-review all` + Host-native review agents |
332
- | Status → completed | `task.update` (2) | stop; do not claim completion |
333
- | Refresh linked context | `change.context` (9) | stop; do not claim the change packet is current |
334
- | Ask user | none | current Host's native user-interaction surface |
335
-
336
- ## What this skill DOES NOT do
337
-
338
- - Does NOT write `tasks.json` directly (projector owns it)
339
- - Does NOT edit context-md frontmatter (projector owns it)
340
- - Does NOT require the runtime to support `/compact`
341
- - Does NOT advertise review or checkpoint operations as MCP tools
342
-
343
- ## Integration
344
-
345
- | | |
346
- |---|---|
347
- | **Input** | state.db via MCP, plus the `context_file` body returned for the selected task |
348
- | **Writes** | state.db (via `task.update`/`change.context`), active delta or baseline spec as classified, context-md body, workflow-state checkpoints |
349
- | **Next** | `/ultra-dev <next-id>` or `/ultra-test` when all Walking Skeleton + critical-path tasks complete |
21
+ 1. Select the requested task, otherwise the first dependency-ready pending task.
22
+ 2. Call `task.get` and verify acceptance, dependencies, ownership, public seam, and
23
+ exact verification command.
24
+ 3. For a linked change, call `change.get`, then compile `change.context` for the
25
+ implementation role and gate with the smallest required references.
26
+ 4. Mark the task `in_progress` only after the context is ready.
27
+ 5. Establish the feedback-loop baseline before changing production logic:
28
+ - reproduce the smallest observable symptom at the declared seam;
29
+ - add or identify the contract or regression test;
30
+ - record the exact command, expected signal, and observed result.
31
+
32
+ A feature starts with an assertion for missing behavior. A refactor starts from a
33
+ green characterization baseline. Documentation or configuration work may use a
34
+ structural validator when no logic test applies.
35
+ 6. Implement the minimum complete path from entry point to public seam. Reuse existing
36
+ utilities, keep IO at boundaries, include required errors and recovery, and preserve
37
+ unrelated worktree changes.
38
+ 7. If the work reveals a stable requirement or public behavior absent from the
39
+ baseline, call `change.learning_propose`. Do not edit the baseline silently or store
40
+ the discovery as private Ultra memory.
41
+ 8. Verify in this order:
42
+ - the original feedback-loop command;
43
+ - adjacent focused tests;
44
+ - proportionate static checks and build;
45
+ - the live public-seam acceptance path;
46
+ - final diff and worktree scope.
47
+ 9. Run `ultra-review` against the current diff. Fix blocking findings, rerun invalidated
48
+ checks, and require independent specification-fidelity and engineering verdicts.
49
+ 10. Call `task.update` with `status=completed` and exact evidence. For a linked change,
50
+ recompile the verification context at the final HEAD, then call
51
+ `change.breadcrumb`.
52
+
53
+ ## Completion evidence
54
+
55
+ Report the task and change ids, changed paths, baseline signal, passing commands,
56
+ public-seam result, review session, specification-learning candidates, and one next
57
+ action. Leave the task in progress or blocked when required evidence is missing.
@@ -1,97 +1,65 @@
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
- runtime: all
5
- mcp_tools_required:
6
- - system.doctor
7
- 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.
8
4
  ---
9
5
 
10
- # ultra-doctor — Runtime Diagnostics and Recovery
6
+ # Diagnose and recover the Ultra runtime
11
7
 
12
- Use this workflow when Ultra state appears empty, projections disagree with
13
- `state.db`, a hook reports a missing adapter, sessions are orphaned, a change
14
- artifact is missing, or MCP operations return degraded projection metadata.
8
+ Default to read-only diagnosis. Repair only after the user explicitly authorizes it.
15
9
 
16
- ## Default is read-only
10
+ ## Project-state diagnosis
17
11
 
18
- Call `system.doctor` with `{ "repair": false }` unless the user explicitly
19
- requests repair. Read-only diagnosis reports:
12
+ Call `system.doctor` with `{ "repair": false }` and inspect:
20
13
 
21
14
  - SQLite integrity and required tables;
22
15
  - open structured incidents;
23
- - projection queue failures and event/projection cursor lag;
16
+ - event and projection cursor lag;
17
+ - failed or interrupted projection jobs;
24
18
  - orphan sessions;
25
19
  - missing active-change artifact roots;
26
- - the external ownership boundary for Memory and code graph.
20
+ - the boundary to separately installed memory and code-graph providers.
27
21
 
28
- Do not infer health from `tasks.json`. Do not mutate provider state, delete
29
- artifacts, rebuild a graph, or collect memory during diagnosis.
22
+ Do not infer health from generated task JSON. Do not mutate external provider state,
23
+ delete artifacts, or collect memory during diagnosis.
30
24
 
31
- ## Interpret the report
25
+ ## Interpret failures
32
26
 
33
- | Check | Meaning | Next action |
34
- |---|---|---|
35
- | `state_db` fail | schema/integrity problem | stop ordinary workflow; preserve DB evidence |
36
- | `incidents` fail | a structured runtime failure remains open | report code, source, retryability, and evidence |
37
- | `projections` fail | state commit is ahead of generated views or a projector failed | explicit repair is appropriate when authorized |
38
- | `sessions` fail | an orphan execution lease exists | repair may mark/reconcile it; never kill unrelated processes blindly |
39
- | `change_artifacts` fail | DB points to a missing active packet | recover from version control/backup or recreate deliberately |
40
- | `external_providers` pass | ownership is correctly external | provider availability must be checked with its own plugin/tool |
27
+ - State integrity failure blocks ordinary workflows and requires preserving database
28
+ evidence before recovery.
29
+ - An open incident requires its code, source, retryability, and evidence.
30
+ - Projection lag may be mechanically repairable when authority is healthy.
31
+ - An orphan session may be reconciled; never kill unrelated processes blindly.
32
+ - A missing change artifact requires version-control, backup, or deliberate recreation
33
+ evidence rather than silent regeneration.
41
34
 
42
- ## Explicit repair mode
35
+ ## Explicit repair
43
36
 
44
- Only after the user asks for repair, call `system.doctor` with
45
- `{ "repair": true }`, or use the fallback:
37
+ After authorization, call `system.doctor` with `{ "repair": true }` or use the
38
+ installed `ultra-tools system doctor --repair` fallback. The runtime must create a
39
+ timestamped state database backup before any mechanical repair.
46
40
 
47
- ```bash
48
- ultra-tools system doctor --repair
49
- ```
41
+ Repair is limited to documented recovery operations such as reconciling orphan
42
+ sessions, consuming staleness events, requeueing interrupted or failed projections,
43
+ and regenerating projections from authoritative state. If backup fails, stop. Always
44
+ inspect the post-repair report; a completed repair action does not imply healthy state.
50
45
 
51
- The runtime must create `.ultra/backups/state-<timestamp>.db` before any
52
- mechanical repair. Repair is bounded to:
46
+ ## Installed-plugin failures
53
47
 
54
- - boot recovery for orphan sessions;
55
- - durable consumption of spec-staleness events;
56
- - requeueing projection jobs left `running` beyond the interruption cutoff;
57
- - requeueing failed projection jobs;
58
- - regenerating projections from authoritative state.
48
+ When a hook points to a missing installed file:
59
49
 
60
- If backup fails, repair must stop with `BACKUP_FAILED`. A repair result is not
61
- automatically healthy; inspect the returned post-repair report and keep any
62
- remaining incident unresolved.
50
+ 1. Capture the hook manifest path and missing target.
51
+ 2. Run the installer doctor for the actual host and install scope.
52
+ 3. Preserve provenance, asset-hash, and host-contract findings.
53
+ 4. Reinstall through the host adapter rather than patching a cache directory.
54
+ 5. Rerun installer doctor, `system.doctor`, and a host hook smoke test.
63
55
 
64
- ## Hook/path failures
65
-
66
- For an installed hook that points to a missing cached file:
67
-
68
- 1. capture the exact hook config path and missing target;
69
- 2. run the separate read-only installer boundary check:
70
- `npx ultra-builder-pro-cli --<runtime> --local --doctor --json` (or use
71
- `--global` when that is the actual install scope);
72
- 3. preserve its provenance, asset-hash, and host-contract findings;
73
- 4. reinstall or regenerate the host-native plugin through the adapter;
74
- 5. rerun both installer doctor and `system.doctor`, then a host hook smoke test.
75
-
76
- `system.doctor` diagnoses project `.ultra/state.db` and workflow recovery.
77
- Installer `ubp --doctor` diagnoses the installed plugin files and host wiring.
78
- Neither report substitutes for the other.
79
-
80
- Do not bypass a broken hook by changing application implementation, and do not
81
- treat a hook failure as project-code evidence.
56
+ Project doctor covers `.ultra/state.db`; installer doctor covers packaged files and
57
+ host wiring. Neither substitutes for the other.
82
58
 
83
59
  ## Output
84
60
 
85
- Lead with `healthy` or `degraded`, list only failing checks, and include:
86
-
87
- - incident ids/codes and sources;
88
- - event vs projected cursor;
89
- - whether repair ran;
90
- - backup path when repair ran;
91
- - unresolved actions and their owner (`Ultra`, host plugin, or external provider).
92
-
93
- ## What this skill does not do
61
+ Lead with `healthy` or `degraded`. List failing checks, incident identifiers, cursor
62
+ lag, whether repair ran, the backup path, and each unresolved action with its owner.
94
63
 
95
- - It does not fix project code or semantic specification conflicts.
96
- - It does not delete state, force-reset git, or close live healthy sessions.
97
- - It does not install, query, refresh, or repair external Memory/graph providers.
64
+ Do not fix application code, delete state, reset Git, close healthy sessions, or
65
+ install and repair external providers through this workflow.