buildanything 2.0.0 → 2.1.2
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.
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +9 -1
- package/README.md +57 -61
- package/agents/a11y-architect.md +2 -0
- package/agents/briefing-officer.md +172 -0
- package/agents/business-model.md +14 -12
- package/agents/code-architect.md +6 -1
- package/agents/code-reviewer.md +3 -2
- package/agents/code-simplifier.md +12 -4
- package/agents/design-brand-guardian.md +19 -0
- package/agents/design-critic.md +16 -11
- package/agents/design-inclusive-visuals-specialist.md +2 -0
- package/agents/design-ui-designer.md +17 -0
- package/agents/design-ux-architect.md +15 -0
- package/agents/design-ux-researcher.md +102 -7
- package/agents/engineering-ai-engineer.md +2 -0
- package/agents/engineering-backend-architect.md +2 -0
- package/agents/engineering-data-engineer.md +2 -0
- package/agents/engineering-devops-automator.md +2 -0
- package/agents/engineering-frontend-developer.md +13 -0
- package/agents/engineering-mobile-app-builder.md +2 -0
- package/agents/engineering-rapid-prototyper.md +15 -2
- package/agents/engineering-security-engineer.md +2 -0
- package/agents/engineering-senior-developer.md +13 -0
- package/agents/engineering-sre.md +2 -0
- package/agents/engineering-technical-writer.md +2 -0
- package/agents/feature-intel.md +8 -7
- package/agents/ios-app-review-guardian.md +2 -0
- package/agents/ios-foundation-models-specialist.md +2 -0
- package/agents/ios-product-reality-auditor.md +292 -0
- package/agents/ios-storekit-specialist.md +2 -0
- package/agents/ios-swift-architect.md +1 -0
- package/agents/ios-swift-search.md +1 -0
- package/agents/ios-swift-ui-design.md +7 -4
- package/agents/marketing-app-store-optimizer.md +2 -0
- package/agents/planner.md +6 -1
- package/agents/pr-test-analyzer.md +3 -2
- package/agents/product-feedback-synthesizer.md +62 -0
- package/agents/product-owner.md +163 -0
- package/agents/product-reality-auditor.md +216 -0
- package/agents/product-spec-writer.md +176 -0
- package/agents/refactor-cleaner.md +9 -1
- package/agents/security-reviewer.md +2 -1
- package/agents/silent-failure-hunter.md +2 -1
- package/agents/swift-build-resolver.md +2 -0
- package/agents/swift-reviewer.md +2 -1
- package/agents/tech-feasibility.md +5 -3
- package/agents/testing-api-tester.md +2 -0
- package/agents/testing-evidence-collector.md +24 -0
- package/agents/testing-performance-benchmarker.md +2 -0
- package/agents/testing-reality-checker.md +2 -1
- package/agents/visual-research.md +7 -5
- package/bin/adapters/scribe-tool.ts +4 -2
- package/bin/adapters/write-lease-tool.ts +1 -1
- package/bin/buildanything-runtime.ts +20 -107
- package/bin/graph-index.js +24 -0
- package/bin/graph-index.ts +340 -0
- package/bin/mcp-servers/graph-mcp.js +26 -0
- package/bin/mcp-servers/graph-mcp.ts +481 -0
- package/bin/mcp-servers/orchestrator-mcp.js +26 -0
- package/bin/mcp-servers/orchestrator-mcp.ts +361 -0
- package/bin/setup.js +272 -111
- package/commands/build.md +424 -177
- package/commands/idea-sweep.md +2 -2
- package/commands/setup.md +15 -4
- package/commands/ux-review.md +3 -3
- package/commands/verify.md +3 -0
- package/docs/migration/phase-graph.yaml +573 -157
- package/hooks/design-md-lint +4 -0
- package/hooks/design-md-lint.ts +295 -0
- package/hooks/pre-tool-use.ts +37 -6
- package/hooks/record-mode-transitions.ts +63 -6
- package/hooks/subagent-start.ts +3 -2
- package/package.json +3 -1
- package/protocols/agent-prompt-authoring.md +165 -0
- package/protocols/architecture-schema.md +10 -3
- package/protocols/cleanup.md +4 -0
- package/protocols/decision-log.md +8 -4
- package/protocols/design-md-authoring.md +520 -0
- package/protocols/design-md-spec.md +362 -0
- package/protocols/fake-data-detector.md +1 -1
- package/protocols/ios-fake-data-detector.md +65 -0
- package/protocols/ios-phase-branches.md +128 -43
- package/protocols/launch-readiness.md +9 -5
- package/protocols/metric-loop.md +1 -1
- package/protocols/page-spec-schema.md +234 -0
- package/protocols/product-spec-schema.md +354 -0
- package/protocols/sprint-tasks-schema.md +53 -0
- package/protocols/state-schema.json +38 -3
- package/protocols/state-schema.md +32 -2
- package/protocols/verify.md +29 -1
- package/protocols/web-phase-branches.md +246 -76
- package/skills/ios/ios-bootstrap/SKILL.md +1 -1
- package/src/graph/ids.ts +86 -0
- package/src/graph/index.ts +32 -0
- package/src/graph/parser/architecture.ts +603 -0
- package/src/graph/parser/component-manifest.ts +268 -0
- package/src/graph/parser/decisions-jsonl.ts +407 -0
- package/src/graph/parser/design-md-pass2.ts +253 -0
- package/src/graph/parser/design-md.ts +477 -0
- package/src/graph/parser/page-spec.ts +496 -0
- package/src/graph/parser/product-spec.ts +930 -0
- package/src/graph/parser/screenshot.ts +342 -0
- package/src/graph/parser/sprint-tasks.ts +317 -0
- package/src/graph/storage/index.ts +1154 -0
- package/src/graph/types.ts +432 -0
- package/src/graph/util/dhash.ts +84 -0
- package/src/lrr/aggregator.ts +105 -10
- package/src/orchestrator/hooks/context-header.ts +34 -10
- package/src/orchestrator/hooks/token-accounting.ts +25 -14
- package/src/orchestrator/mcp/cycle-counter.ts +2 -1
- package/src/orchestrator/mcp/scribe.ts +27 -16
- package/src/orchestrator/mcp/write-lease.ts +30 -13
- package/src/orchestrator/phase4-shared-context.ts +20 -4
- package/protocols/visual-dna.md +0 -185
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
"$comment": "Schema version migration table: schema_version 1 = Stages 1-3; schema_version 2 = Stage 4 (adds backward_routing_count, backward_routing_count_by_target_phase, in_flight_backward_edge, mode_transitions); schema_version 3 = Stage 5 (adds lrr_cycle_state); schema_version 4 = Stage 6 (adds current_sprint_context_hash). --- Runtime validation rules (not encodable in JSON Schema, require code): Rule 5 — step prefix must match current phase number; Rule 6 — mode/autonomous consistency (mode==='autonomous' iff autonomous===true); Rule 7 — iOS fields gating (app_name, bundle_id, xcodeproj_path, ios_features, phase_progress.phase_minus_1 exist iff project_type==='ios'); Rule 10 — pending/in-progress disjoint (in_progress_task.task_id not in pending_tasks or completed_tasks); Rule 11 — resume_point.phase/step must not be ahead of top-level phase/step; Rule 12 — timestamps monotonic (session_last_saved >= session_started).",
|
|
3
|
+
"$comment": "Schema version migration table: schema_version 1 = Stages 1-3; schema_version 2 = Stage 4 (adds backward_routing_count, backward_routing_count_by_target_phase, in_flight_backward_edge, mode_transitions); schema_version 3 = Stage 5 (adds lrr_cycle_state); schema_version 4 = Stage 6 (adds current_sprint_context_hash), schema_version 5 = Stage 7 (adds feature_delegation_plan_path, current_wave, completed_features, feature_acceptance, feature_briefs). --- Runtime validation rules (not encodable in JSON Schema, require code): Rule 5 — step prefix must match current phase number; Rule 6 — mode/autonomous consistency (mode==='autonomous' iff autonomous===true); Rule 7 — iOS fields gating (app_name, bundle_id, xcodeproj_path, ios_features, phase_progress.phase_minus_1 exist iff project_type==='ios'); Rule 10 — pending/in-progress disjoint (in_progress_task.task_id not in pending_tasks or completed_tasks); Rule 11 — resume_point.phase/step must not be ahead of top-level phase/step; Rule 12 — timestamps monotonic (session_last_saved >= session_started).",
|
|
4
4
|
"title": ".build-state.json",
|
|
5
5
|
"description": "Typed source of truth for BuildAnything build state. Validated by the PreToolUse schema lint hook (W2-2). additionalProperties: false enforces fail-closed per A8 SSOT rule.",
|
|
6
6
|
"type": "object",
|
|
@@ -229,8 +229,8 @@
|
|
|
229
229
|
"schema_version": {
|
|
230
230
|
"type": "integer",
|
|
231
231
|
"minimum": 1,
|
|
232
|
-
"maximum":
|
|
233
|
-
"description": "Currently
|
|
232
|
+
"maximum": 5,
|
|
233
|
+
"description": "Currently 5 (Stage 7). Bumped to 2 at Stage 4, 3 at Stage 5, 4 at Stage 6, 5 at Stage 7."
|
|
234
234
|
},
|
|
235
235
|
"project_type": {
|
|
236
236
|
"type": "string",
|
|
@@ -349,6 +349,11 @@
|
|
|
349
349
|
"items": { "$ref": "#/$defs/blocker" },
|
|
350
350
|
"description": "Open blockers. Omitted when empty."
|
|
351
351
|
},
|
|
352
|
+
"decisions_pruned_at_phase0": {
|
|
353
|
+
"type": "boolean",
|
|
354
|
+
"default": false,
|
|
355
|
+
"description": "Set to true after Phase 0 archives stale decision rows from previous builds"
|
|
356
|
+
},
|
|
352
357
|
"decisions_next_id": {
|
|
353
358
|
"type": "object",
|
|
354
359
|
"additionalProperties": { "type": "integer", "minimum": 0 },
|
|
@@ -383,6 +388,36 @@
|
|
|
383
388
|
"current_sprint_context_hash": {
|
|
384
389
|
"type": "string",
|
|
385
390
|
"description": "Stage 6+ (schema_version >= 4). Hash of sprint-scoped shared context; triggers re-render only on sprint boundary."
|
|
391
|
+
},
|
|
392
|
+
|
|
393
|
+
"feature_delegation_plan_path": {
|
|
394
|
+
"type": "string",
|
|
395
|
+
"$comment": "Stage 7+ (schema_version >= 5). Populated at Phase 4 Step 4.1 by product-owner agent.",
|
|
396
|
+
"description": "Stage 7+ (schema_version >= 5). Path to feature-delegation-plan.json written by Product Owner in Phase 4 Step 4.1."
|
|
397
|
+
},
|
|
398
|
+
"current_wave": {
|
|
399
|
+
"type": "integer",
|
|
400
|
+
"minimum": 1,
|
|
401
|
+
"$comment": "Stage 7+ (schema_version >= 5). Initialized to 1 at Step 4.1; incremented by orchestrator at Step 4.4.",
|
|
402
|
+
"description": "Stage 7+ (schema_version >= 5). Current wave number in the feature-delegation plan."
|
|
403
|
+
},
|
|
404
|
+
"completed_features": {
|
|
405
|
+
"type": "array",
|
|
406
|
+
"items": { "type": "string" },
|
|
407
|
+
"$comment": "Stage 7+ (schema_version >= 5). Append-only. Set by orchestrator after product-owner ACCEPTED verdict.",
|
|
408
|
+
"description": "Stage 7+ (schema_version >= 5). Feature names accepted by Product Owner."
|
|
409
|
+
},
|
|
410
|
+
"feature_acceptance": {
|
|
411
|
+
"type": "object",
|
|
412
|
+
"additionalProperties": { "type": "string", "enum": ["ACCEPTED", "NEEDS_REVISION", "PENDING"] },
|
|
413
|
+
"$comment": "Stage 7+ (schema_version >= 5). Written by orchestrator after each product-owner acceptance dispatch (Step 4.3).",
|
|
414
|
+
"description": "Stage 7+ (schema_version >= 5). Product Owner acceptance verdict per feature."
|
|
415
|
+
},
|
|
416
|
+
"feature_briefs": {
|
|
417
|
+
"type": "object",
|
|
418
|
+
"additionalProperties": { "type": "string" },
|
|
419
|
+
"$comment": "Stage 7+ (schema_version >= 5). Written by orchestrator after each briefing-officer dispatch (Step 4.2.a).",
|
|
420
|
+
"description": "Stage 7+ (schema_version >= 5). Map of feature name to feature brief file path (docs/plans/feature-briefs/{feature}.md)."
|
|
386
421
|
}
|
|
387
422
|
}
|
|
388
423
|
}
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
| 2 | Stage 4 | `backward_routing_count` (newly typed), `backward_routing_count_by_target_phase`, `in_flight_backward_edge`, `mode_transitions[]` | A7 forward-reject on `schema_version > MAX_SUPPORTED_SCHEMA_VERSION`; A3 stale-edge decrement on `--resume` |
|
|
17
17
|
| 3 | Stage 5 | `lrr_cycle_state` (object; interior fields loose-typed pending Stage 5 iteration — see "Fields added at v3" below) | `BUILDANYTHING_SDK_LRR=false` reverts to markdown aggregator; `lrr_cycle_state` becomes an ignored field on the orchestrator read path (additive-only, no data loss on downgrade) |
|
|
18
18
|
| 4 | Stage 6 | `current_sprint_context_hash` | `BUILDANYTHING_SDK_SPRINT_CONTEXT=false` (web) and/or `BUILDANYTHING_SDK_SPRINT_CONTEXT_IOS=false` (iOS parity gate) reverts Phase 4 to per-task refs re-send; `current_sprint_context_hash` becomes an ignored field on the orchestrator read path (additive-only, no data loss on downgrade) |
|
|
19
|
+
| 5 | Stage 7 | `feature_delegation_plan_path`, `current_wave`, `completed_features`, `feature_acceptance`, `feature_briefs` | Feature-level fields are additive and optional; a Stage 6 runtime reading a Stage 7 state file with `schema_version` downgraded to `4` will ignore these fields without data loss on the read path |
|
|
19
20
|
|
|
20
21
|
**A7 forward-reject rule.** When `bin/buildanything-runtime.ts` reads `.build-state.json` at session start, if `schema_version > MAX_SUPPORTED_SCHEMA_VERSION`, the runtime refuses to proceed and emits a clear error pointing to the compat matrix (`docs/migration/sdk-host-compat.md`). This is the A7 defense against silent schema drift — an old runtime must never silently ignore fields a newer runtime persisted. See **Task 4.5.2** for the runtime implementation (out of scope for this prose-only update).
|
|
21
22
|
|
|
@@ -23,7 +24,7 @@
|
|
|
23
24
|
|
|
24
25
|
```jsonc
|
|
25
26
|
{
|
|
26
|
-
"schema_version":
|
|
27
|
+
"schema_version": 5,
|
|
27
28
|
"project_type": "ios",
|
|
28
29
|
"phase": 6,
|
|
29
30
|
"step": "6.4",
|
|
@@ -53,7 +54,7 @@
|
|
|
53
54
|
|
|
54
55
|
| Field | Type | Required | Notes |
|
|
55
56
|
|---|---|---|---|
|
|
56
|
-
| `schema_version` | integer | yes | Currently `
|
|
57
|
+
| `schema_version` | integer | yes | Currently `5`; see version table above. Bumped on each Shape-B migration stage. |
|
|
57
58
|
| `project_type` | enum | yes | `"ios"` or `"web"`. Drives mode-branch routing. |
|
|
58
59
|
| `phase` | integer | yes | Current phase, one of `-1, 0, 1, 2, 3, 4, 5, 6, 7`. |
|
|
59
60
|
| `step` | string | yes | Dotted step identifier within the phase (e.g., `"5.3b"`, `"6.4"`). |
|
|
@@ -80,6 +81,11 @@
|
|
|
80
81
|
| `resume_point` | object | yes | `{phase, step, autonomous, completed_summary, git_branch}`. Snapshot used by Phase-0 resume logic. |
|
|
81
82
|
| `verification` | object | yes | `{last_verify_result, last_verify_timestamp}`. `last_verify_result` is one of `"PRODUCTION_READY"`, `"NEEDS_WORK"`, `"BLOCKED"`, or `null`. |
|
|
82
83
|
| `blockers` | array | no | Open blockers. Each: `{id, description, surfaced_at, type}`. Type is `"build"`, `"design"`, `"dep"`, or `"external"`. |
|
|
84
|
+
| `decisions_pruned_at_phase0` | boolean | no | Default `false`. Set to `true` after Phase 0 archives stale decision rows. |
|
|
85
|
+
|
|
86
|
+
### Decision Log Pruning (Phase 0)
|
|
87
|
+
|
|
88
|
+
At Phase 0, if `docs/plans/decisions.jsonl` exists and contains rows from a previous `session_id`, archive them: copy the file to `docs/plans/decisions.jsonl.prev`, then filter `decisions.jsonl` to retain only rows matching the current `session_id`. Set `decisions_pruned_at_phase0: true`. This prevents unbounded growth across builds while preserving history in the `.prev` file. The LRR Aggregator's star rule only needs current-build decisions for backward routing.
|
|
83
89
|
|
|
84
90
|
### Fields added at v2 (Stage 4)
|
|
85
91
|
|
|
@@ -118,6 +124,22 @@ These fields are present only when `schema_version >= 4`. They support the Shape
|
|
|
118
124
|
|
|
119
125
|
**SSOT note.** Kiro-owned `protocols/state-schema.json` is authoritative: `properties.current_sprint_context_hash` (string) is already declared, `schema_version.maximum` is already `4`, and the top-level `$comment` migration table already lists Stage 6. This prose mirrors that shape; any future interior fields (should the sprint-context module persist more than a hash) will be documented by tightening this entry alongside a JSON Schema update.
|
|
120
126
|
|
|
127
|
+
### Fields added at v5 (Stage 7)
|
|
128
|
+
|
|
129
|
+
These fields are present only when `schema_version >= 5`. They support the three-tier feature delegation architecture in Phase 4 — Product Owner planning, Briefing Officer per-feature briefs, and wave-based execution with acceptance gates.
|
|
130
|
+
|
|
131
|
+
| Field | Type | Required | Added in | Notes |
|
|
132
|
+
|---|---|---|---|---|
|
|
133
|
+
| `feature_delegation_plan_path` | string | no | v5 | Path to `docs/plans/feature-delegation-plan.json`. Set at Step 4.1. |
|
|
134
|
+
| `current_wave` | integer | no | v5 | Current wave being executed (1-indexed). Set at Step 4.1, incremented at Step 4.4. |
|
|
135
|
+
| `completed_features` | string[] | no | v5 | Feature names that have been ACCEPTED by the Product Owner. |
|
|
136
|
+
| `feature_acceptance` | object | no | v5 | Map of feature name → verdict (`ACCEPTED`, `NEEDS_REVISION`, `IN_PROGRESS`). |
|
|
137
|
+
| `feature_briefs` | object | no | v5 | Map of feature name → path to feature brief file (`docs/plans/feature-briefs/{feature}.md`). |
|
|
138
|
+
|
|
139
|
+
**v5 migration concern — none in wild.** As of this task, Stage 7 has not shipped. No `.build-state.json` files with `schema_version: 5` exist outside development probes. The runtime will be bumped to `5` as part of Stage 7 activation, not here.
|
|
140
|
+
|
|
141
|
+
**v5 rollback semantics.** All five fields are additive and optional. A Stage 6 runtime reading a Stage 7 state file with `schema_version` downgraded to `4` will ignore these fields without data loss on the read path. Phase 4 simply reverts to the flat per-task execution model without feature-level delegation.
|
|
142
|
+
|
|
121
143
|
## Rendering contract
|
|
122
144
|
|
|
123
145
|
`.build-state.md` is regenerated from `.build-state.json` on every state change by the orchestrator's state-save routine. It is a view, not a source. The rendering is deterministic: same JSON in → same markdown out.
|
|
@@ -152,6 +174,10 @@ Direct writes to `.build-state.json` are prohibited — a partial write leaves u
|
|
|
152
174
|
|
|
153
175
|
This section is the authoritative write contract. Other protocol/command files that say "write to `.build-state.json`" mean "via this protocol."
|
|
154
176
|
|
|
177
|
+
### Compaction Safety Net
|
|
178
|
+
|
|
179
|
+
The PreCompact hook is a prompt-level reminder (type: "prompt"), not a hard command. As defense-in-depth, the `session-start` hook reads `.build-state.json` on every session start and rebuilds TodoWrite from it. If compaction fires without the orchestrator saving state first, the session-start recovery path restores from the last checkpoint. This is a safety net, not a substitute for the orchestrator honoring compaction checkpoints.
|
|
180
|
+
|
|
155
181
|
## Validation rules
|
|
156
182
|
|
|
157
183
|
A well-formed `.build-state.json` must satisfy:
|
|
@@ -170,3 +196,7 @@ A well-formed `.build-state.json` must satisfy:
|
|
|
170
196
|
12. **Timestamps monotonic** — `session_last_saved >= session_started`.
|
|
171
197
|
|
|
172
198
|
The Wave 2 `PreToolUse` schema lint hook (W2-2) validates every Write|Edit to `.build-state.json` against these rules and denies writes that fail.
|
|
199
|
+
|
|
200
|
+
## Consumers — non-orchestrator readers of state
|
|
201
|
+
|
|
202
|
+
- **Step 7.1.5 Completion Report** (`commands/build.md`) reads `backward_routing_count`, `backward_routing_count_by_target_phase`, and `mode_transitions[]` to surface end-of-build quality signals. See `commands/build.md` Step 7.1.5 for the report template.
|
package/protocols/verify.md
CHANGED
|
@@ -47,6 +47,27 @@ The agent runs these checks in order, stopping on the first FAIL:
|
|
|
47
47
|
ONE AGENT, ONE PASS: The orchestrator spawns exactly ONE agent for the entire verification. This is a single Agent tool call, not 6 separate agents. The agent runs each check as a sequential shell command and evaluates the result before proceeding.
|
|
48
48
|
</HARD-GATE>
|
|
49
49
|
|
|
50
|
+
**Scope macros** (the caller selects which subset of the 7 checks to run):
|
|
51
|
+
|
|
52
|
+
| Scope | Checks included |
|
|
53
|
+
|-------|-----------------|
|
|
54
|
+
| `full` | All 7 checks (default) |
|
|
55
|
+
| `build` | Check 1 only |
|
|
56
|
+
| `types` | Check 2 only |
|
|
57
|
+
| `lint` | Check 3 only |
|
|
58
|
+
| `test` | Check 4 only |
|
|
59
|
+
| `security` | Check 5 only |
|
|
60
|
+
| `diff` | Check 6 only |
|
|
61
|
+
| `behavioral` | Check 7 only |
|
|
62
|
+
| `static` | Checks 1, 2, 3, 6 (build, types, lint, diff — no test/security/behavioral) |
|
|
63
|
+
| `ci` | Checks 1, 2, 3, 4 (build, types, lint, test — no security/diff/behavioral) |
|
|
64
|
+
|
|
65
|
+
The `static` macro is the standard Phase 6 post-metric-loop scope — the metric loop owns behavioral evaluation, so Phase 6 verify skips checks 4 (test), 5 (security), and 7 (behavioral).
|
|
66
|
+
|
|
67
|
+
The `ci` macro is for CI pipeline integration — it runs the four deterministic, automatable checks and skips security (often handled by separate CI tooling), diff review (no uncommitted changes in CI), and behavioral (requires a running app).
|
|
68
|
+
|
|
69
|
+
If no scope is specified, default to `full`.
|
|
70
|
+
|
|
50
71
|
## Step 2b — Test stub detector
|
|
51
72
|
|
|
52
73
|
After running the Test check in Step 2, AND after running it as PASS, the orchestrator MUST run the test-stub detector. The detector greps every test file in the project's test directory and fails the verification if any file matches a stub pattern.
|
|
@@ -105,10 +126,15 @@ exit $EXIT
|
|
|
105
126
|
|
|
106
127
|
## Step 3: Handle Result
|
|
107
128
|
|
|
108
|
-
**On PASS:**
|
|
129
|
+
**On PASS:** Return `VERIFY: PASS (N/N)` to the caller via stdout. State persistence is the orchestrator's responsibility (`.build-state.json.verification` is Reality Checker's field, not the gate's). Proceed to next phase.
|
|
109
130
|
|
|
110
131
|
**On FAIL:** Read the failure reason and spawn a targeted fix agent:
|
|
111
132
|
|
|
133
|
+
**Fix-agent dispatch mode (SDK-gated — matches `commands/build.md:946`):**
|
|
134
|
+
|
|
135
|
+
- **`BUILDANYTHING_SDK=on` (default):** dispatch the fix agent through `claude-agent-sdk` with `maxTurns: 15`. This is a hard safety rail preventing runaway remediation loops. If a fix exceeds 15 turns, the orchestrator flags to user (interactive mode) or logs a warning and fails the verify (autonomous mode) — do NOT let the subagent churn indefinitely.
|
|
136
|
+
- **`BUILDANYTHING_SDK=off`:** fall back to Agent tool dispatch with a self-reported 15-tool-call cap (surfaced via `tool_calls_used` in the agent's return). Same enforcement policy as SDK mode.
|
|
137
|
+
|
|
112
138
|
| Failed Check | Fix Strategy |
|
|
113
139
|
|-------------|-------------|
|
|
114
140
|
| Build / Type-Check / Lint | Run the Build-Fix Protocol (`protocols/build-fix.md`). It isolates the first error, fixes it, rebuilds, detects cascade resolution, and reverts bad fixes automatically. |
|
|
@@ -119,6 +145,8 @@ exit $EXIT
|
|
|
119
145
|
|
|
120
146
|
After the fix agent completes, re-run verification from Step 2.
|
|
121
147
|
|
|
148
|
+
**Token accounting (Stage 3 G3):** each fix-agent dispatch emits a cost line to `docs/plans/build-log.md` via `src/orchestrator/hooks/token-accounting-emitter.ts`. Under `BUILDANYTHING_SDK=on`, the emitter subscribes to SDK `usage` messages automatically. Under markdown fallback, the orchestrator writes the line using the subagent's self-reported token count. Verify's fix loop is a known cost hotspot and must be attributed to the parent phase.
|
|
149
|
+
|
|
122
150
|
<HARD-GATE>
|
|
123
151
|
MAX 3 FIX ATTEMPTS: If verification fails 3 times on the same phase:
|
|
124
152
|
- **Interactive mode:** present the failure history to the user. Ask for direction.
|