@manhquy/flow-skill 0.1.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +60 -0
- package/LICENSE +21 -0
- package/README.md +152 -0
- package/README_VN.md +134 -0
- package/SECURITY.md +69 -0
- package/bin/cli.mjs +382 -0
- package/package.json +52 -0
- package/skills/flow/SKILL.md +234 -0
- package/skills/flow/_templates/00-idea.md +16 -0
- package/skills/flow/_templates/00-inspect.md +42 -0
- package/skills/flow/_templates/01-research.md +59 -0
- package/skills/flow/_templates/02-scope.md +71 -0
- package/skills/flow/_templates/03-prd.md +57 -0
- package/skills/flow/_templates/04-adr.md +21 -0
- package/skills/flow/_templates/05-contract.md +59 -0
- package/skills/flow/_templates/card.md +26 -0
- package/skills/flow/_templates/constitution.md +22 -0
- package/skills/flow/eval/fixtures/f01a/flow/01-research.md +77 -0
- package/skills/flow/eval/fixtures/f01b/flow/01-research.md +75 -0
- package/skills/flow/eval/fixtures/f02a/flow/02-scope.md +56 -0
- package/skills/flow/eval/fixtures/f02b/flow/02-scope.md +65 -0
- package/skills/flow/eval/fixtures/fcda/.flow/.gitkeep +0 -0
- package/skills/flow/eval/fixtures/fcda/cards/C-001.md +46 -0
- package/skills/flow/eval/fixtures/fcdb/.flow/.gitkeep +0 -0
- package/skills/flow/eval/fixtures/fcdb/cards/C-001.md +35 -0
- package/skills/flow/eval/manifest.tsv +7 -0
- package/skills/flow/harness/README.md +117 -0
- package/skills/flow/harness/_db.py +228 -0
- package/skills/flow/harness/_domain.py +161 -0
- package/skills/flow/harness/_presence.py +109 -0
- package/skills/flow/harness/flow_harness.py +1103 -0
- package/skills/flow/harness/repo_map.py +93 -0
- package/skills/flow/harness/schema/001-init.sql +129 -0
- package/skills/flow/harness/schema/002-story-verify.sql +9 -0
- package/skills/flow/harness/schema/003-tool-registry.sql +15 -0
- package/skills/flow/harness/schema/004-intervention.sql +15 -0
- package/skills/flow/harness/schema/005-tool-extensions.sql +20 -0
- package/skills/flow/harness/schema/009-accessed-count.sql +11 -0
- package/skills/flow/harness/schema/010-usage-event.sql +42 -0
- package/skills/flow/harness/schema/011-usage-gate-reason.sql +8 -0
- package/skills/flow/harness/schema/012-usage-ephemeral.sql +10 -0
- package/skills/flow/law/CLAUDE.md +140 -0
- package/skills/flow/law/DESIGN.md +141 -0
- package/skills/flow/law/RETRO.md +13 -0
- package/skills/flow/playbooks/README.md +28 -0
- package/skills/flow/playbooks/cloudflare-ai-gateway-qwen.md +346 -0
- package/skills/flow/playbooks/docker-deploy-stale-cache.md +32 -0
- package/skills/flow/playbooks/rag-lite-postgres-cloudflare.md +192 -0
- package/skills/flow/playbooks/windows-gitbash-jsonl-telemetry.md +57 -0
- package/skills/flow/references/adversarial-review.md +197 -0
- package/skills/flow/references/agent-detection.md +88 -0
- package/skills/flow/references/agent-stage-mapping.md +114 -0
- package/skills/flow/references/antigravity-integration.md +92 -0
- package/skills/flow/references/auto-run.md +81 -0
- package/skills/flow/references/claudekit-skills.md +128 -0
- package/skills/flow/references/codex-integration.md +104 -0
- package/skills/flow/references/command-dispatch.md +54 -0
- package/skills/flow/references/debt-and-halts.md +41 -0
- package/skills/flow/references/design-review-checklist.md +42 -0
- package/skills/flow/references/gate-eval.md +186 -0
- package/skills/flow/references/gate-rules.md +171 -0
- package/skills/flow/references/ground-truth-gates.md +49 -0
- package/skills/flow/references/loop-harness-2026-principles.md +52 -0
- package/skills/flow/references/mode-work.md +37 -0
- package/skills/flow/references/project-types.md +42 -0
- package/skills/flow/references/stage-state-machine.md +47 -0
- package/skills/flow/references/ui-patterns-tcr.md +49 -0
- package/skills/flow/runner/flow.cmd +18 -0
- package/skills/flow/runner/flow.sh +3297 -0
- package/skills-manifest.json +70 -0
- package/src/constants.mjs +65 -0
- package/src/detect.mjs +36 -0
- package/src/help.mjs +42 -0
- package/src/installer.mjs +231 -0
- package/src/prompt.mjs +60 -0
- package/src/tty.mjs +11 -0
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
# Adversarial review (the Review gate)
|
|
2
|
+
|
|
3
|
+
Before a card merges, it is reviewed by a reviewer whose job is to **find issues** — not to
|
|
4
|
+
bless. "No 'looks good' allowed. Zero findings triggers a halt: re-analyze, or explain why
|
|
5
|
+
nothing was found." (BMAD adversarial-review pattern.) Prefer `bmad-code-review` when
|
|
6
|
+
present; else `code-reviewer`; else run the three lenses yourself as separate passes.
|
|
7
|
+
|
|
8
|
+
## Security-class lens selection
|
|
9
|
+
|
|
10
|
+
When a card is **security-class** (auth, authorization, admin exposure, tenancy, payments,
|
|
11
|
+
data migration, removing/weakening validation — same trigger as `auto-run.md` Tier-C),
|
|
12
|
+
the Review gate uses the **`security-reviewer` AGENT** (STRIDE/OWASP, secrets, injection,
|
|
13
|
+
SSRF) as the primary acceptance lens, **layered with `code-reviewer`**. Non-security cards
|
|
14
|
+
stay with the generic `code-reviewer` — no change to that path.
|
|
15
|
+
|
|
16
|
+
**Agent vs skill:** `security-reviewer` is an **AGENT** (`Task(subagent_type="security-reviewer")`)
|
|
17
|
+
invoked in subagent isolation — it sees the diff, contract, and acceptance only. `ck-security`
|
|
18
|
+
is a **SKILL** (main-context Skill tool, no subagent isolation); it may be used as an optional
|
|
19
|
+
inline pass by the orchestrator, but it is **never** the delegated review subagent.
|
|
20
|
+
|
|
21
|
+
**Offer `ck-security` on a security-class card (opt-in-with-prompt).** When a card is
|
|
22
|
+
security-class and the `security-reviewer` agent is absent (or as an extra threat-model pass),
|
|
23
|
+
offer the `ck-security` SKILL (STRIDE+OWASP attacker personas) — the operator confirms; it is not
|
|
24
|
+
auto-fired. Its output INFORMS triage and **never auto-passes the Tier-C HALT** (see the Critical
|
|
25
|
+
note below). After it runs, record the lazy durable metric via `flow.sh harness intervention add`
|
|
26
|
+
(the wired-gate skill-telemetry — `claudekit-skills.md` §"Lazy capture"). See `claudekit-skills.md`.
|
|
27
|
+
|
|
28
|
+
**Portability degrade rung** (detect-first, gate identical on every rung):
|
|
29
|
+
1. `security-reviewer` AGENT present → run it layered with `code-reviewer` (primary path).
|
|
30
|
+
2. `security-reviewer` absent → `code-reviewer` runs an explicit STRIDE/OWASP checklist
|
|
31
|
+
covering the Tier-C keyword list (auth, authz, tenancy, payments, injection, secrets, SSRF).
|
|
32
|
+
3. Neither available → inline security review against the Tier-C keyword list by the orchestrator.
|
|
33
|
+
|
|
34
|
+
**Gate parity — the lens INFORMS triage; it NEVER auto-fails or auto-passes a card.** A
|
|
35
|
+
`security-reviewer` "looks fine" verdict is advisory evidence fed into the same triage table
|
|
36
|
+
below. The Review gate still decides.
|
|
37
|
+
|
|
38
|
+
**Critical: the lens NEVER releases the Tier-C operator HALT.** The security-class HALT
|
|
39
|
+
(`auto-run.md:13,57`) is triggered by CLASSIFICATION and resolved ONLY by written operator
|
|
40
|
+
acknowledgment in `DEBT.md`. A `security-reviewer` clean verdict can NEVER substitute for, or
|
|
41
|
+
auto-release, that HALT — it is advisory evidence for the operator, not a gate key.
|
|
42
|
+
|
|
43
|
+
**No-defang rule applies to the security dispatch.** Hand the `security-reviewer` the diff,
|
|
44
|
+
the contract, and the card's acceptance — never add "don't flag X" or "treat as minor at
|
|
45
|
+
most". The same defang prohibition above governs the security dispatch equally.
|
|
46
|
+
|
|
47
|
+
## Language-specialist lens selection
|
|
48
|
+
|
|
49
|
+
When a card's changed files have a detectable primary language, the Review gate adds the
|
|
50
|
+
matching **language-specialist AGENT** as a layered lens alongside `code-reviewer`:
|
|
51
|
+
|
|
52
|
+
- `.ts / .tsx / .js / .jsx` extensions → **`typescript-reviewer` AGENT** (type-safety, async
|
|
53
|
+
correctness, Node/web idioms).
|
|
54
|
+
- `.py` extensions → **`python-reviewer` AGENT** (PEP 8, type hints, Pythonic idioms,
|
|
55
|
+
security via Bandit lens).
|
|
56
|
+
- No dominant language-match → generic **`code-reviewer`** only (no specialist layer).
|
|
57
|
+
|
|
58
|
+
Detect the primary language from the card's `## Allowed files` list (majority extension wins;
|
|
59
|
+
mixed-language cards with no majority default to `code-reviewer`).
|
|
60
|
+
|
|
61
|
+
**The specialist is LAYERED with `code-reviewer`** — it is an additional reviewer, not a
|
|
62
|
+
replacement. Running both gives two review angles on the same diff; the gate's triage table
|
|
63
|
+
weighs findings from both.
|
|
64
|
+
|
|
65
|
+
**Composes with the security lens.** A security-class TypeScript card triggers
|
|
66
|
+
`security-reviewer` + `typescript-reviewer` + `code-reviewer` — all three run. The lenses
|
|
67
|
+
are additive. Security-class detection (`## Security-class lens selection`) and language
|
|
68
|
+
detection are independent: each is evaluated separately, and the resulting set is the union.
|
|
69
|
+
|
|
70
|
+
**Portability degrade rungs** (detect-first, gate identical on every rung):
|
|
71
|
+
1. Language-specialist AGENT present → run it layered with `code-reviewer` (primary path).
|
|
72
|
+
2. Specialist absent → `code-reviewer` runs an explicit checklist targeting the primary
|
|
73
|
+
language's known failure modes (e.g. TypeScript: `any` escapes, unhandled promise
|
|
74
|
+
rejections, missing strict-mode; Python: bare `except`, missing type hints, mutable
|
|
75
|
+
default args).
|
|
76
|
+
3. Neither available → inline language-aware checklist run by the orchestrator.
|
|
77
|
+
|
|
78
|
+
**Gate parity — the specialist lens INFORMS triage; it NEVER auto-fails or auto-passes a
|
|
79
|
+
card.** A `typescript-reviewer` or `python-reviewer` verdict is advisory evidence fed into
|
|
80
|
+
the same triage table below. The Review gate still decides. A clean specialist verdict never
|
|
81
|
+
substitutes for the acceptance audit or the three-layer review structure.
|
|
82
|
+
|
|
83
|
+
**No-defang rule applies to the specialist dispatch.** Hand the specialist the diff, the
|
|
84
|
+
contract, and the card's acceptance — never add "don't flag X" or "the team already chose
|
|
85
|
+
this pattern". The same defang prohibition in the next section governs every lens equally.
|
|
86
|
+
|
|
87
|
+
## Don't defang the reviewer (controller-side input)
|
|
88
|
+
|
|
89
|
+
The "must find issues" rule above governs the reviewer's **output**. It is defeated at the source if
|
|
90
|
+
you hand the reviewer a **poisoned prompt**. When you construct a review dispatch, you may not
|
|
91
|
+
pre-judge its findings:
|
|
92
|
+
|
|
93
|
+
- Never write "don't flag X", "treat it as Minor at most", "the plan already chose this", or any
|
|
94
|
+
steer that tells the reviewer what NOT to find. If you believe a finding would be a false
|
|
95
|
+
positive, let the reviewer raise it and adjudicate it in triage — do not pre-empt it.
|
|
96
|
+
- The card's own example/scaffold code is a starting point, not evidence its weaknesses were
|
|
97
|
+
intentional. Do not present it to the reviewer as "the chosen design".
|
|
98
|
+
- Hand the reviewer the diff as a file (or scoped repo read), the contract, and the card's
|
|
99
|
+
acceptance — not your opinion of the diff. The reviewer's lens is acceptance + contract + the
|
|
100
|
+
three hunts, nothing you added to spare yourself a review loop.
|
|
101
|
+
|
|
102
|
+
A reviewer told what not to find is not adversarial. If the dispatch you are writing contains any
|
|
103
|
+
"do not flag" steer, stop — that is the failure this gate exists to prevent, one layer up.
|
|
104
|
+
|
|
105
|
+
## Three layers (information asymmetry — each sees less, so each catches different things)
|
|
106
|
+
|
|
107
|
+
| Layer | Sees | Hunts for |
|
|
108
|
+
|---|---|---|
|
|
109
|
+
| **Blind Hunter** | the diff ONLY (no context) | bugs visible on the diff surface; smells |
|
|
110
|
+
| **Edge Case Hunter** | diff + repo read access | every branch/boundary/empty/error path |
|
|
111
|
+
| **Acceptance Auditor** | diff + `flow/05-contract.md` + `flow/03-prd.md` + the card | contract-shape violations, PRD acceptance gaps, missing specified behavior |
|
|
112
|
+
|
|
113
|
+
Run them as separate scoped subagents (or separate passes) so no single context biases the
|
|
114
|
+
others. The Acceptance Auditor is the one that catches producer/consumer drift — it checks
|
|
115
|
+
the diff's shapes against the contract.
|
|
116
|
+
|
|
117
|
+
## Optional 4th lens — Codex cross-MODEL reviewer (different vendor, not just different context)
|
|
118
|
+
|
|
119
|
+
The three lenses above differ by *information* but share one *model* (Claude) → correlated blind
|
|
120
|
+
spots. When the codex tier is USABLE (`codex-integration.md`), add a **cross-model** lens: run
|
|
121
|
+
`codex-companion.mjs review|adversarial-review [--base <ref>] [--scope working-tree|branch]`
|
|
122
|
+
(review/adversarial-review go through `codex-companion.mjs` — the `codex:codex-rescue` subagent
|
|
123
|
+
only forwards to `task`, so it is NOT a review path). A different engine (GPT-5.x) catches failure modes a
|
|
124
|
+
same-model panel structurally can't — cross-model review markedly outperforms same-model
|
|
125
|
+
self-review (gemini-cli study: 43% → 91% merge-ready), and same-model judges carry systematic
|
|
126
|
+
self-bias.
|
|
127
|
+
|
|
128
|
+
- **It INFORMS, never decides.** Codex returns a `ReviewResult` (`verdict`, `findings[]` with
|
|
129
|
+
severity/confidence, `next_steps`). Feed its findings into the SAME triage below. The gate still
|
|
130
|
+
judges; a Codex `needs-attention` never auto-fails a card and a Codex `approve` never auto-passes
|
|
131
|
+
one. Apply the "do not blindly accept findings" rules to Codex output too.
|
|
132
|
+
- **When to spend it (cost gate — the SAME three triggers as `codex-integration.md`).** Run the
|
|
133
|
+
Codex lens only on: a **security-class card review** (which also triggers the `security-reviewer`
|
|
134
|
+
specialist lens — see `## Security-class lens selection` above), a **two-strikes** review deadlock, or an
|
|
135
|
+
**explicit operator opt-in** — and only when the tier is USABLE. A suspicious same-model "all
|
|
136
|
+
clear" (zero findings) is a good reason to *ask the operator to opt in* to a cross-check, **not**
|
|
137
|
+
an automatic trigger — auto-firing on every zero-findings card would blow past the cost gate.
|
|
138
|
+
Codex calls are billable (`codex-integration.md` §Cost gate).
|
|
139
|
+
- **Record the durable metric (S2).** Log whether the cross-model lens AGREED or surfaced a class
|
|
140
|
+
the same-model panel missed: `flow.sh harness intervention add` (disagreement = a caught miss) or
|
|
141
|
+
`intake`. This feeds the cross-model-catch-rate in `docs/quality-metrics.md` — the measured
|
|
142
|
+
justification for keeping the lens.
|
|
143
|
+
|
|
144
|
+
## Optional 5th lens — Antigravity (Gemini-3) cross-vendor reviewer (a third vendor)
|
|
145
|
+
|
|
146
|
+
When the Antigravity tier is USABLE (`antigravity-integration.md`), add Gemini-3 as a further
|
|
147
|
+
cross-vendor lens — the SAME three triggers and cost/data gate as Codex. With Claude × GPT-5.x ×
|
|
148
|
+
Gemini-3 you get a **three-model** gate; three vendors rarely share one blind spot. Run it AFTER
|
|
149
|
+
Codex on a two-strikes deadlock (a third independent engine before escalating to the operator), or
|
|
150
|
+
in parallel on a security-class card / explicit opt-in. **Usability is stricter here:** `agy`'s exit
|
|
151
|
+
code lies (exit 0 + empty stdout even when unauthenticated), so route ONLY on non-empty expected
|
|
152
|
+
output, prefer the **interactive** path (IDE Agent Manager / real `agy` terminal, paste the
|
|
153
|
+
`ReviewResult` back), and treat an empty Gemini result as **"review unavailable", never an approval**.
|
|
154
|
+
Same parity rule: it INFORMS, never auto-passes/auto-fails. Log the same durable metric.
|
|
155
|
+
|
|
156
|
+
## Optional lens — review-pr (PR-context, when the card ships as a GitHub PR)
|
|
157
|
+
|
|
158
|
+
The three layers + cross-model lenses all review a **diff**. When the card's change lives as a
|
|
159
|
+
**GitHub PR**, offer the `review-pr` SKILL as an additional lens — it adds the PR-context checks a
|
|
160
|
+
diff-only review structurally can't see: duplicate prior work, AI-slop patterns, breaking-change
|
|
161
|
+
detection across the whole PR, and CI-blocker triage (with optional `--fix`). It is **distinct from
|
|
162
|
+
the wired `code-reviewer` agent** (diff lens), not a twin — see `claudekit-skills.md`.
|
|
163
|
+
|
|
164
|
+
- **Opt-in-with-prompt.** Offer it when a PR exists; the operator confirms. Do not auto-fire it on
|
|
165
|
+
every card, and never on a local-only (no-remote) build.
|
|
166
|
+
- **Gate parity — INFORMS, never decides.** `review-pr` findings feed the SAME triage below; a
|
|
167
|
+
clean `review-pr` never auto-passes a card and a flagged one never auto-fails it. The Review gate
|
|
168
|
+
still judges. The "do not defang the reviewer" rule applies — hand it the PR, not your verdict.
|
|
169
|
+
- **Lazy durable metric (S2).** After it runs, record via `flow.sh harness intervention add`
|
|
170
|
+
whether it caught a class the diff lenses missed (this is the wired-gate skill-telemetry — see
|
|
171
|
+
`claudekit-skills.md` §"Lazy capture").
|
|
172
|
+
|
|
173
|
+
## Triage
|
|
174
|
+
Group every finding by severity x actionability:
|
|
175
|
+
- **Must-fix (correctness/contract/security)** -> Tier-B repair by a FRESH subagent before merge.
|
|
176
|
+
- **Should-fix (maintainability)** -> fix now if cheap, else note.
|
|
177
|
+
- **Observation** -> record, proceed.
|
|
178
|
+
Two-strikes: a second red review on the same card -> try the next USABLE cross-vendor engine
|
|
179
|
+
(Codex, then Antigravity) as a fresh-engine pass; if none usable or still red, escalate to the
|
|
180
|
+
operator, don't loop.
|
|
181
|
+
|
|
182
|
+
## Apply your own decision rules (do not blindly accept findings)
|
|
183
|
+
- Validate each finding against what the code actually does and protects. "Theoretically
|
|
184
|
+
yes, practically no" findings are documented, not blindly fixed.
|
|
185
|
+
- A verified decision is not reversed by a review opinion alone — only by a NEW issue the
|
|
186
|
+
verification missed, or changed context. Surface conflicts to the operator with the source.
|
|
187
|
+
- Security-class findings (auth/authz/data/payments) are never waved through — they are
|
|
188
|
+
Tier-C: operator decides, in writing (`debt-and-halts.md`).
|
|
189
|
+
- No performative agreement. When a finding lands, do not answer "you're absolutely right" /
|
|
190
|
+
"great catch" and then comply — that reflex launders a wrong finding into a change. State the
|
|
191
|
+
adjudication: confirmed (→ fix) or refuted-with-reason (→ documented). Agreement is a verdict you
|
|
192
|
+
reach, not a courtesy you extend.
|
|
193
|
+
|
|
194
|
+
## Output
|
|
195
|
+
A short report: findings by layer, triage, and the verdict (green / repair-needed /
|
|
196
|
+
escalate). On green, proceed to `flow.sh check` -> merge -> deploy -> live verify. Record a
|
|
197
|
+
`trace`; on a red that overrode an agent, record an `intervention`.
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# Agent detection & priority
|
|
2
|
+
|
|
3
|
+
`/flow` orchestrates whatever specialist agents exist in the host, and degrades to
|
|
4
|
+
built-in behavior when none are present. It stays portable: rich where agents exist,
|
|
5
|
+
unbroken where they don't.
|
|
6
|
+
|
|
7
|
+
## Detection (at runtime, by the skill = Claude)
|
|
8
|
+
|
|
9
|
+
You already know which agents and skills the host exposes (the Task tool's
|
|
10
|
+
`subagent_type` registry + the available Skills list). Detect by checking that registry —
|
|
11
|
+
do NOT assume. Also glob for project-local definitions when unsure:
|
|
12
|
+
- ck: agents: `.claude/agents/*.md` (project) and the host agent registry.
|
|
13
|
+
- bmad skills: the Skills list (`bmad-*`) and `.claude/skills/bmad-*`.
|
|
14
|
+
|
|
15
|
+
## Priority order (operator chose: ck: first, bmad alternative)
|
|
16
|
+
|
|
17
|
+
For each stage, pick the FIRST available:
|
|
18
|
+
1. **ck: agent** (primary) — planner, researcher, architect, fullstack-developer, code-reviewer, typescript-reviewer, python-reviewer, tester, ui-ux-designer, docs-manager, git-manager, debugger, scout.
|
|
19
|
+
2. **bmad-* skill** (alternative) — bmad-prd, bmad-create-architecture, bmad-spec, bmad-create-story, bmad-dev-story, bmad-code-review, bmad-check-implementation-readiness, bmad-market-research, bmad-technical-research, bmad-qa-generate-e2e-tests.
|
|
20
|
+
3. **built-in fallback** — you (Claude) do it inline, or spawn a generic `Explore`/`general-purpose` agent. Output shape must match the agent path so the gate is identical.
|
|
21
|
+
|
|
22
|
+
## Codex — the cross-vendor second engine (a tier that crosses the ladder, not just sits under it)
|
|
23
|
+
|
|
24
|
+
When the `openai-codex` plugin is present, a **fourth path** unlocks: **Codex (OpenAI GPT-5.x)**.
|
|
25
|
+
Codex is not "tier 4 below built-in" in the linear sense — it is a *cross-vendor engine* used at
|
|
26
|
+
three specific moments where a genuinely different model is worth more than another Claude pass.
|
|
27
|
+
Full seam (invocation surfaces, shapes, cost gate): **`references/codex-integration.md`**.
|
|
28
|
+
|
|
29
|
+
- **Rescue / escalation (default use).** When a same-model agent returns BLOCKED a second time
|
|
30
|
+
(two-strikes), hand the scoped brief to `codex:codex-rescue` BEFORE escalating to the operator.
|
|
31
|
+
A different engine breaks deadlocks correlated blind spots can't. This *replaces* "fresh subagent
|
|
32
|
+
or escalate" as the preferred second strike when Codex is available.
|
|
33
|
+
- **Cross-model review.** At the Review gate, run Codex as an extra adversarial lens
|
|
34
|
+
(`codex-companion.mjs review|adversarial-review`) — see `adversarial-review.md`. It INFORMS
|
|
35
|
+
triage; the gate still judges. Never let Codex's verdict auto-pass or auto-fail a card.
|
|
36
|
+
- **Opt-in primary drafter.** The operator MAY select Codex as the primary drafter for a
|
|
37
|
+
research or build stage (`codex:codex-rescue --write` / `codex-companion.mjs task --write`).
|
|
38
|
+
Default stays ck:; the identical stage gate judges the Codex-drafted artifact.
|
|
39
|
+
|
|
40
|
+
**Detection (I1) — installed ≠ usable.** The codex tier has two states (`codex-integration.md` §I1):
|
|
41
|
+
**INSTALLED** (`codex:codex-rescue` in the registry OR the `openai-codex` plugin dir exists) and
|
|
42
|
+
**USABLE** (INSTALLED + a non-billable `codex-companion.mjs setup --json` check reports
|
|
43
|
+
`ready` + `auth.loggedIn`; NOT `status`, which has no auth field — see `codex-integration.md`).
|
|
44
|
+
**Only select Codex when USABLE.** INSTALLED-but-not-usable (no auth / unreachable — common in
|
|
45
|
+
headless/CI) or absent → **degrade** to ck:→bmad→built-in, announce "codex tier unavailable —
|
|
46
|
+
degraded to <path>", record the reason. Never route to Codex on mere presence: that would spend a
|
|
47
|
+
billable attempt then fail at invocation. Codex absence/unusability never lowers a gate and never
|
|
48
|
+
breaks a run — this is the portability promise. "Eligible" in this file means USABLE.
|
|
49
|
+
|
|
50
|
+
**Cost gate (F-D).** Codex calls are billable (external GPT-5.x). Fire them ONLY at high-value
|
|
51
|
+
moments: a two-strikes deadlock, a security-class card review, or an explicit operator opt-in.
|
|
52
|
+
Never call Codex on every stage by default.
|
|
53
|
+
|
|
54
|
+
## Antigravity — the cross-vendor third engine (Gemini-3)
|
|
55
|
+
|
|
56
|
+
When `agy` (CLI) or the Antigravity IDE is present, a **fifth path** unlocks: **Antigravity
|
|
57
|
+
(Google Gemini-3)** — a third vendor's model, sibling to Codex. Used at the same three high-value
|
|
58
|
+
moments (two-strikes after Codex, security-class review, operator opt-in) to give a genuine
|
|
59
|
+
**three-model** adversarial gate. Full seam (invocation, shapes, cost/data gate): **`references/antigravity-integration.md`**.
|
|
60
|
+
|
|
61
|
+
**Detection — installed ≠ usable, and NEVER route on exit code.** Antigravity needs the strictest
|
|
62
|
+
usability check: `agy -p` returns **exit 0 with empty stdout even when unauthenticated** (the error
|
|
63
|
+
only lands in `--log-file`; non-TTY capture is empty). So **only non-empty expected output proves
|
|
64
|
+
USABLE** — never exit code, never empty stdout. INSTALLED = `agy`/IDE/`~/.gemini` present; USABLE =
|
|
65
|
+
INSTALLED + a liveness probe returns a non-empty sentinel token. Not usable (unauthenticated, or
|
|
66
|
+
non-TTY capture empty — common in headless/CI and piped agent harnesses) or absent → **degrade** to
|
|
67
|
+
Codex / ck:→bmad→built-in, announce "antigravity tier unavailable — degraded to <path>", record the
|
|
68
|
+
reason. Because headless capture is unreliable, the **supported default is interactive** (IDE Agent
|
|
69
|
+
Manager / real `agy` terminal, paste the ReviewResult back); an empty Gemini result is
|
|
70
|
+
"review-unavailable", **never** an approval. Same billable + data-leaves-machine cost gate as Codex.
|
|
71
|
+
|
|
72
|
+
## Rules
|
|
73
|
+
|
|
74
|
+
- **Same gate regardless of path.** The buildflow gate (`flow.sh` + `gate-rules.md`) is the
|
|
75
|
+
contract. An agent fills an artifact; the gate still judges it. A missing agent never
|
|
76
|
+
lowers a gate — it only changes who drafts.
|
|
77
|
+
- **Context isolation (orchestration-protocol).** Give each subagent ONLY: the task, the
|
|
78
|
+
specific files to read/modify, acceptance criteria, and relevant law/contract excerpts.
|
|
79
|
+
Never the full session history. One card = one scoped brief.
|
|
80
|
+
- **Status protocol.** Every subagent returns DONE / DONE_WITH_CONCERNS / BLOCKED /
|
|
81
|
+
NEEDS_CONTEXT. Handle BLOCKED/NEEDS_CONTEXT before retry (more context → simpler task →
|
|
82
|
+
escalate). Two-strikes: a second red result → **Codex rescue if the tier is eligible**
|
|
83
|
+
(`codex:codex-rescue`, a different engine), else fresh subagent, else escalate to operator.
|
|
84
|
+
- **Durable record hook.** After a stage/card agent finishes, write the durable record via
|
|
85
|
+
`flow.sh harness ...` (story add/update, trace, decision add) so progress survives the
|
|
86
|
+
session. See `agent-stage-mapping.md` for the per-stage hook.
|
|
87
|
+
- **Announce the path.** Tell the operator which path ran ("research via `researcher`
|
|
88
|
+
agent" / "via bmad-market-research" / "inline fallback") so the run is legible.
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# Stage -> agent mapping
|
|
2
|
+
|
|
3
|
+
How each buildflow stage delegates to a specialist. Pick the path by `agent-detection.md`
|
|
4
|
+
priority (ck: first, bmad alternative, built-in fallback). The artifact + gate are
|
|
5
|
+
identical across paths; only the drafter changes.
|
|
6
|
+
|
|
7
|
+
**Codex (cross-vendor second engine) column.** When the codex tier is eligible
|
|
8
|
+
(`agent-detection.md` / `codex-integration.md`), each stage gains two extra options on top of the
|
|
9
|
+
ladder below: (1) **rescue** — if the chosen path is BLOCKED twice, hand the scoped brief to
|
|
10
|
+
`codex:codex-rescue` before escalating; (2) **opt-in primary** — the operator may select Codex as
|
|
11
|
+
the primary drafter for **research** and **build** stages (`codex:codex-rescue --write` /
|
|
12
|
+
`codex-companion.mjs task --write`). **Default stays ck:**; Codex-as-primary is operator-selected,
|
|
13
|
+
never automatic. The scope/PRD/ADR/Contract judgment stages stay Claude by default (Codex may
|
|
14
|
+
still rescue them). The stage gate is identical on the Codex path — Codex drafts, the gate judges. In `teach` mode you do NOT author — you
|
|
15
|
+
gatekeep; agents assist the operator. In `work`/`auto` mode you (or the agent) draft, then
|
|
16
|
+
the gate still judges.
|
|
17
|
+
|
|
18
|
+
Artifact language: **Vietnamese for user-facing copy** (per `law/DESIGN.md`: VN native,
|
|
19
|
+
`₫` prices, VietQR), **English for code identifiers/endpoints**.
|
|
20
|
+
|
|
21
|
+
## Brownfield pre-stage (existing codebase)
|
|
22
|
+
|
|
23
|
+
If the project ALREADY EXISTS, run `/flow assess` first → `flow/00-inspect.md` (current-state map:
|
|
24
|
+
stack, functionality/UI/UX vs product goals, risks, test baseline). Delegate to `ck:scout` +
|
|
25
|
+
`researcher` (or `bmad-document-project`); the gate is operator-reviewed. This seeds planning (and
|
|
26
|
+
the harness) with reality before stage 01. Greenfield projects skip it and start at `/flow next` (00).
|
|
27
|
+
|
|
28
|
+
## Planning stages (flow/)
|
|
29
|
+
|
|
30
|
+
| Stage | ck: (primary) | bmad (alt) | fallback | Durable hook |
|
|
31
|
+
|---|---|---|---|---|
|
|
32
|
+
| 01 Research | `researcher` | `bmad-market-research` / `bmad-technical-research` | `Explore` + WebSearch | `harness intake --type new_spec` |
|
|
33
|
+
| 02 Scope | `planner` | `bmad-prd` (scope) | inline | record scope decision |
|
|
34
|
+
| 03 PRD | `planner` | `bmad-prd` / `bmad-product-brief` | inline | — |
|
|
35
|
+
| 04 ADR | `architect` | `bmad-create-architecture` | inline | `harness decision add` per ADR |
|
|
36
|
+
| 05 Contract | `planner` | `bmad-spec` (5-field kernel) | inline | — |
|
|
37
|
+
|
|
38
|
+
**Optional ck-skill enrichments per stage** (the skill layer on top of the agents above; the
|
|
39
|
+
agent drafts, a skill adds a distinct verb): the curated whitelist + the rules (skill INFORMS,
|
|
40
|
+
gate JUDGES; Claude-side detection; opt-in-with-prompt) live in **`references/claudekit-skills.md`**.
|
|
41
|
+
Deep-wired into the gate ritual (all opt-in-with-prompt, degrade silently, never auto-pass a
|
|
42
|
+
gate): **`ck-predict` at ADR** (5-persona pre-decision debate) and **`ck-scenario` at Contract**
|
|
43
|
+
(12-dim edge-case → acceptance + contract tests) — both in `gate-rules.md`; **`review-pr` +
|
|
44
|
+
`ck-security` at the Review gate** (PR-context lens / STRIDE+OWASP on security-class cards) — in
|
|
45
|
+
`adversarial-review.md`; **`retro` at Retro** (git-history numbers for the operator's line) — in
|
|
46
|
+
`law/RETRO.md`. After any of these runs at its gate, record the lazy durable metric
|
|
47
|
+
(`flow.sh harness intervention add`). Full whitelist + rules: `references/claudekit-skills.md`.
|
|
48
|
+
|
|
49
|
+
## Shipping (inside cards/)
|
|
50
|
+
|
|
51
|
+
| Step | ck: (primary) | bmad (alt) | fallback | Durable hook |
|
|
52
|
+
|---|---|---|---|---|
|
|
53
|
+
| Build card | `fullstack-developer` | `bmad-dev-story` / `bmad-quick-dev` | inline | `harness story update --status in_progress` |
|
|
54
|
+
| UI card | `ui-ux-designer` | — | inline + `law/DESIGN.md` | review vs DESIGN.md |
|
|
55
|
+
| Repair / diagnostic | `debugger` | — | inline root-cause + fresh same-ladder subagent | `harness intervention add` |
|
|
56
|
+
| Review | `code-reviewer` (+ `typescript-reviewer` or `python-reviewer` layered — see language-specialist lens) | `bmad-code-review` (3-layer adversarial) | inline | `harness intervention add` on red |
|
|
57
|
+
| Deploy / git ship | `git-manager` | — | inline commit + PR guide | `harness story update --status implemented` |
|
|
58
|
+
| Docs sync | `docs-manager` | — | inline doc update | — |
|
|
59
|
+
| Verify-live | `tester` / `web-testing` | `bmad-qa-generate-e2e-tests` | curl/Playwright | `harness story update --e2e 1` + `trace` |
|
|
60
|
+
|
|
61
|
+
**Portability degrade rungs for git-manager and docs-manager:**
|
|
62
|
+
- `git-manager` absent → inline: operator runs `git commit` + `git push` + opens PR manually following the durable-hook pattern. Gate (PR merged, SHA logged in `AUTO-LOG.md`) is identical.
|
|
63
|
+
- `docs-manager` absent → inline: Claude updates docs directly after card implementation; gate (impacted docs under `docs/` match the code change) is identical.
|
|
64
|
+
|
|
65
|
+
**Portability degrade rungs for the language-specialist Review lens** (`adversarial-review.md` §Language-specialist lens selection):
|
|
66
|
+
- `typescript-reviewer` or `python-reviewer` AGENT present → run it layered with `code-reviewer` for `.ts/.tsx/.js/.jsx` or `.py` cards respectively. Gate (triage table, adversarial verdict) is identical.
|
|
67
|
+
- Specialist absent → `code-reviewer` runs an explicit language-targeted checklist (TypeScript: `any` escapes, unhandled promises, strict mode; Python: bare `except`, missing type hints, mutable defaults). Gate is identical.
|
|
68
|
+
- No dominant language → `code-reviewer` only; no specialist layer. Gate is identical.
|
|
69
|
+
|
|
70
|
+
## Scoped prompt template (use for EVERY delegation)
|
|
71
|
+
|
|
72
|
+
Keep it small. No session history. Fill every slot from the live artifacts.
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
Task: <one stage/card goal>
|
|
76
|
+
Read for context: flow/05-contract.md (shapes), law/DESIGN.md (UI only),
|
|
77
|
+
flow/03-prd.md (features), the card file <path>, playbooks/<stack>.md if the stack matches
|
|
78
|
+
Files to modify: <card ## Allowed files ONLY>
|
|
79
|
+
Acceptance criteria: <the stage gate from gate-rules.md, or the card ## Verify steps>
|
|
80
|
+
Constraints: contract is the seam (never improvise a shape); done = world-state evidence;
|
|
81
|
+
Vietnamese user-facing copy; touch only allowed files
|
|
82
|
+
Return: the drafted artifact + status (DONE/DONE_WITH_CONCERNS/BLOCKED/NEEDS_CONTEXT)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Stage notes
|
|
86
|
+
|
|
87
|
+
- **05 Contract via bmad-spec:** the 5-field spec kernel (Why, Capabilities, Constraints,
|
|
88
|
+
Non-goals, Success signal) maps onto the contract — Capabilities -> endpoints, Constraints
|
|
89
|
+
-> auth/shape rules. Use it to harden the seam against producer/consumer drift. The
|
|
90
|
+
endpoint table in `flow/05-contract.md` remains the runtime-checkable source of truth.
|
|
91
|
+
- **Review via bmad-code-review (3-layer):** when present, prefer it for card review — Blind
|
|
92
|
+
Hunter (diff only), Edge Case Hunter (diff + repo), Acceptance Auditor (diff + contract +
|
|
93
|
+
PRD). "Must find issues; zero findings -> re-analyze." This is the adversarial gate
|
|
94
|
+
detailed in `adversarial-review.md` (Phase 4).
|
|
95
|
+
- **Build via fullstack-developer:** one card = one scoped session. Pass the card's Scope +
|
|
96
|
+
Allowed files + the contract shapes it consumes. It must honor shapes exactly.
|
|
97
|
+
- **Repair / diagnostic via debugger:** detect-first ladder entry — NOT a hard dependency.
|
|
98
|
+
Dispatch `Task(subagent_type="debugger")` with a scoped brief: task description, the failing
|
|
99
|
+
card file, test output, and `## Verify` acceptance criteria. NO session history (context
|
|
100
|
+
isolation per orchestration-protocol). If `debugger` is ABSENT in the host, degrade to inline
|
|
101
|
+
root-cause analysis + a fresh same-ladder (Claude) subagent for the redraw. A missing agent
|
|
102
|
+
changes WHO diagnoses, never whether `## Verify` + `flow.sh check` must pass for real.
|
|
103
|
+
Escalation order: debugger (Claude diagnostic) -> Codex (if USABLE) -> Antigravity (if USABLE)
|
|
104
|
+
-> operator.
|
|
105
|
+
- **Verify-live:** the proof is the LIVE surface (deployed URL, real curl), not "tests pass".
|
|
106
|
+
Record `story update --e2e 1` + a `trace` only after the live check.
|
|
107
|
+
|
|
108
|
+
## After any delegation
|
|
109
|
+
1. Run the gate (`flow.sh next` for stages, `flow.sh check C-NNN` for cards).
|
|
110
|
+
2. Apply the semantic challenge from `gate-rules.md`.
|
|
111
|
+
3. Write the durable hook above. NOTE: the engine now AUTO-fires some — `flow next` past 01 seeds
|
|
112
|
+
`intake`, past 04 reminds `decision add`; `flow check` (done) records the `trace` and shows its
|
|
113
|
+
tier. You still author the content the engine can't (decision rationale, interventions, rich traces).
|
|
114
|
+
4. Announce which path ran + the gate verdict to the operator.
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Antigravity — cross-vendor third engine (the seam)
|
|
2
|
+
|
|
3
|
+
`/flow` reaches Google **Antigravity (Gemini-3)** through the `agy` CLI and/or the Antigravity IDE
|
|
4
|
+
(detected, never required). Antigravity is a *third engine* alongside the ck:→bmad→built-in ladder
|
|
5
|
+
and the Codex (GPT-5.x) second engine — a genuinely different vendor's model used where a third
|
|
6
|
+
independent perspective is worth more than another Claude or Codex pass. This file is the single
|
|
7
|
+
source of truth for the seam; `agent-detection.md` (detection + priority) and `adversarial-review.md`
|
|
8
|
+
(cross-model review) point here for the shapes. It mirrors `codex-integration.md`; read that first.
|
|
9
|
+
|
|
10
|
+
## Why a third vendor
|
|
11
|
+
|
|
12
|
+
Cross-model review empirically catches more than single-model (a gemini-cli study: 43% vs 91%
|
|
13
|
+
merge-ready). flow already crosses Claude × Codex; adding Gemini-3 gives a **three-model** adversarial
|
|
14
|
+
gate — three vendors rarely share the same blind spot. Antigravity also runs natively as the
|
|
15
|
+
operator's daily IDE/CLI, so flow installed there is a portability win even before any review use.
|
|
16
|
+
|
|
17
|
+
## Detection — two states: INSTALLED vs USABLE (never route on "installed", and NEVER on exit code)
|
|
18
|
+
|
|
19
|
+
Antigravity needs the **strictest** usability check of any tier, because of a measured platform fact:
|
|
20
|
+
|
|
21
|
+
> **The `agy` exit code lies.** `agy -p "<prompt>"` returns **exit 0 with empty stdout** even when it
|
|
22
|
+
> is unauthenticated ("You are not logged into Antigravity") — the error surfaces only in
|
|
23
|
+
> `--log-file`. Non-TTY stdout capture is also empty (raw pipe and `winpty` both yield nothing on
|
|
24
|
+
> Windows Git Bash). Verified 2026-06-16. So exit code 0 means **nothing** here; only **non-empty,
|
|
25
|
+
> expected output** proves usability.
|
|
26
|
+
|
|
27
|
+
- **INSTALLED** — `agy` is on `PATH` (or `~/AppData/Local/agy/bin/agy`), or the IDE
|
|
28
|
+
(`~/AppData/Local/Programs/Antigravity`), or `~/.gemini/` exists. Necessary, not sufficient.
|
|
29
|
+
- **USABLE** — INSTALLED **and** a liveness probe returns a **non-empty response containing an
|
|
30
|
+
expected sentinel token** (e.g. ask `agy -p` to echo `FLOWPONG` and require that token in stdout).
|
|
31
|
+
**Never** treat exit 0 as success; **never** treat empty stdout as success. If the probe is empty
|
|
32
|
+
or the log shows "not logged into Antigravity" → state = NOT USABLE.
|
|
33
|
+
|
|
34
|
+
**Selection rule:** only select the Antigravity tier when state = **USABLE**. INSTALLED-but-not-USABLE
|
|
35
|
+
(unauthenticated, or non-TTY capture returns empty — common in headless/CI and in agent harnesses
|
|
36
|
+
that pipe stdout) or absent → **degrade** to Codex / ck:→bmad→built-in, announce
|
|
37
|
+
`"antigravity tier unavailable (installed but not authenticated / no capturable output) — degraded
|
|
38
|
+
to <path>"`, record the reason. Degrading is silent-but-announced, never an error, never a gate change.
|
|
39
|
+
|
|
40
|
+
## Headless capture is unreliable → interactive is the supported default
|
|
41
|
+
|
|
42
|
+
Because non-TTY `agy -p` capture is empty on this platform, the **supported** way to run a Gemini-3
|
|
43
|
+
cross-model review is **interactive**: the operator runs the review in the Antigravity IDE (Agent
|
|
44
|
+
Manager) or a real `agy` terminal and pastes the `ReviewResult` back to flow. The **headless** path
|
|
45
|
+
(`agy -p` from flow's runner) is offered ONLY behind a passing liveness probe; if the probe is empty,
|
|
46
|
+
flow must NOT fall back to "no findings = pass" — an empty Gemini result is **"review unavailable"**,
|
|
47
|
+
never an approval. This is the loud-degrade rule applied to a vendor whose exit code can't be trusted.
|
|
48
|
+
|
|
49
|
+
## Cost / data gate — when the Antigravity tier is allowed to fire
|
|
50
|
+
|
|
51
|
+
Gemini-3 calls are **billable** external inference and **send the diff + specs to Google's API**
|
|
52
|
+
(governed by the operator's Google/Gemini plan and its retention/training terms). Fire ONLY at
|
|
53
|
+
high-value moments, same closed set as Codex:
|
|
54
|
+
- a **two-strikes deadlock** (after Codex, if both a same-model and the second engine stall),
|
|
55
|
+
- a **security-class card review** (auth/authorization/tenancy/payments/data-migration), or
|
|
56
|
+
- an **explicit operator opt-in** (e.g. "review this on Antigravity", "/flow ... antigravity").
|
|
57
|
+
|
|
58
|
+
Never call Antigravity on every stage by default. Default engine stays ck:; second engine stays Codex.
|
|
59
|
+
For a sensitive/regulated/NDA'd codebase the operator must opt in knowingly — the code and specs leave
|
|
60
|
+
the machine to a third vendor.
|
|
61
|
+
|
|
62
|
+
## Invocation surfaces (do not improvise other shapes)
|
|
63
|
+
|
|
64
|
+
| Use | Invocation | Notes |
|
|
65
|
+
|---|---|---|
|
|
66
|
+
| **Liveness probe (USABLE check)** | `agy -p "echo token FLOWPONG" --print-timeout 30s` | require `FLOWPONG` in non-empty stdout; exit code is ignored (it lies) |
|
|
67
|
+
| **Interactive review (supported default)** | operator runs Antigravity IDE Agent Manager / real `agy` terminal, pastes back `ReviewResult` | the only path not blocked by non-TTY capture |
|
|
68
|
+
| **Headless review (gated on liveness)** | `agy -p "<review brief>" --log-file <f> --print-timeout <t>` | only if liveness passed; require non-empty output; empty = review-unavailable, NEVER a pass |
|
|
69
|
+
| **Skill install homes** | flow's installer deploys to CLI `~/.gemini/antigravity-cli/skills/flow` + IDE `~/.gemini/config/skills/flow`. Antigravity also recognizes shared `~/.gemini/skills/` and project `<root>/.agents/skills/flow`, but the installer does NOT write those (use them only for a manual/project copy). | same `SKILL.md` bundle Antigravity reads (no restructuring) |
|
|
70
|
+
|
|
71
|
+
`agy inspect` lists the config + skills Antigravity has loaded — use it to confirm flow is discovered.
|
|
72
|
+
|
|
73
|
+
### ScopedBrief / ReviewResult / Status protocol
|
|
74
|
+
Identical to `codex-integration.md`: give the engine ONLY task · read-for-context · files-to-modify ·
|
|
75
|
+
acceptance · constraints · return (never session history). Review output is coerced to the same
|
|
76
|
+
`ReviewResult` shape (verdict / summary / findings[] / next_steps). Handoffs return
|
|
77
|
+
`DONE | DONE_WITH_CONCERNS | BLOCKED | NEEDS_CONTEXT`.
|
|
78
|
+
|
|
79
|
+
## Gate parity (absolute) & auth (delegated)
|
|
80
|
+
|
|
81
|
+
- **Gate parity.** Antigravity DRAFTS or CRITIQUES; the identical stage gate (`flow.sh` +
|
|
82
|
+
`gate-rules.md`) still judges. A Gemini-3 review INFORMS triage — it never auto-passes or
|
|
83
|
+
auto-fails a card.
|
|
84
|
+
- **Auth.** Delegated entirely to `agy`/the IDE (interactive `agy` login). `/flow` never reads,
|
|
85
|
+
stores, or logs Antigravity credentials. An unauthenticated `agy` is NOT USABLE (see detection).
|
|
86
|
+
|
|
87
|
+
## Durable metric & announce
|
|
88
|
+
|
|
89
|
+
After an Antigravity tier use, log it (`flow.sh harness intervention add` / `decision add`) so the
|
|
90
|
+
quality loop can read the three-model-catch trend. Always announce which engine ran:
|
|
91
|
+
`"review via Antigravity (Gemini-3) cross-model lens (needs-attention, 2 findings)"` /
|
|
92
|
+
`"antigravity tier unavailable (not authenticated) — degraded to Codex"`. A run stays legible.
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# /flow auto — autonomous build run
|
|
2
|
+
|
|
3
|
+
`/flow auto` drives the card-building phase autonomously. Preflight via
|
|
4
|
+
`flow.sh auto` (planning complete + cards exist), then YOU (Claude) orchestrate per the
|
|
5
|
+
principles below. Operator chose: **Tier-A auto-merge green cards; halt at security-class.**
|
|
6
|
+
|
|
7
|
+
## Tiers (decide per card before acting)
|
|
8
|
+
|
|
9
|
+
| Tier | What | Action |
|
|
10
|
+
|---|---|---|
|
|
11
|
+
| **A** | Card built, review green, verify-live passed, no security-class concern | **Auto-merge without asking.** Log PR URL + merged SHA in `AUTO-LOG.md`. |
|
|
12
|
+
| **B** | Built but review found fixable issues, or verify ambiguous | First repair = **`Task(subagent_type="debugger")`** with scoped brief (task + card + test output + acceptance; no session history). If `debugger` is absent, degrade to inline root-cause + fresh same-ladder (Claude) subagent. If THAT repair is still red — the **two-strikes deadlock** — THEN try the next USABLE cross-vendor engine: **Codex** (`codex:codex-rescue`) first, then **Antigravity/Gemini-3** (`antigravity-integration.md`) if Codex is unusable or also red; else escalate to operator. (A cross-vendor engine may come in earlier ONLY on a security-class card or explicit operator opt-in — the cost gate. Do NOT call a billable engine on the first red of an ordinary card.) |
|
|
13
|
+
| **C** | Security-class touch (auth, authorization, admin exposure, tenancy, payments, data migration, removing validation) OR a debt skip | **HALT.** Operator must accept the exposure in writing in `DEBT.md`. Never planner-decided. |
|
|
14
|
+
|
|
15
|
+
## Loop per card (serial by default; parallel only when `/flow ready` says safe)
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
for each todo card in card-number order:
|
|
19
|
+
0. tier-classify. If Tier-C -> HALT, write DEBT line, ask operator. Do not proceed.
|
|
20
|
+
1. spawn ONE scoped subagent (agent-stage-mapping.md) in its own worktree
|
|
21
|
+
git worktree add ../<project>-C-NNN -b card/C-NNN
|
|
22
|
+
2. agent builds to contract, touches only allowed files, runs ## Verify for real
|
|
23
|
+
3. review the diff (code-reviewer or bmad-code-review 3-layer; see adversarial-review.md).
|
|
24
|
+
On a security-class card, add a USABLE cross-vendor lens (Codex, and/or Antigravity/Gemini-3).
|
|
25
|
+
red (strike 1) -> repair: spawn Task(subagent_type="debugger") with a SCOPED BRIEF
|
|
26
|
+
(task + failing card file + test output + ## Verify acceptance; NO session history).
|
|
27
|
+
Debugger diagnoses root cause and returns a fix recommendation or revised implementation.
|
|
28
|
+
Degrade rung: if `debugger` is ABSENT in the host, run inline root-cause analysis then
|
|
29
|
+
spawn a FRESH same-ladder (Claude) subagent for the redraw. A missing `debugger` changes
|
|
30
|
+
WHO diagnoses, never whether ## Verify + flow.sh check must pass for real.
|
|
31
|
+
still red (strike 2 / deadlock) -> Codex fresh-engine repair if USABLE, then Antigravity if
|
|
32
|
+
USABLE, else escalate
|
|
33
|
+
green -> continue
|
|
34
|
+
4. flow.sh check C-NNN must PASS (mechanical) + gate-rules semantic check
|
|
35
|
+
5. merge to main in card order; deploy; VERIFY ON LIVE URL (merge != shipped)
|
|
36
|
+
6. paste world-state evidence into the card; status: done
|
|
37
|
+
7. flow.sh harness story update --status implemented + trace; log AUTO-LOG.md
|
|
38
|
+
8. remove worktree
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Hard stops (mandatory — see loop-harness-2026-principles.md in Phase 4)
|
|
42
|
+
- Iteration cap per card (e.g. 2 repair attempts), token budget, wall-clock cap. Exceed any
|
|
43
|
+
-> HALT + report. A loop with no cap is an antipattern.
|
|
44
|
+
- Ground-truth gates only at decision points: `flow.sh` exit, `## Verify` real runs, story
|
|
45
|
+
`verify_command`, deploy + live check. Never advance on an agent's self-assessment alone.
|
|
46
|
+
|
|
47
|
+
## Repair discipline — full-suite re-run required
|
|
48
|
+
A control-flow / runner repair (any change to `flow.sh`, `run_all.sh`, a test helper, or any
|
|
49
|
+
shared test fixture) MUST re-run the FULL suite (`bash tests/run_all.sh`) before claiming
|
|
50
|
+
green — not just the targeted suite that triggered the repair. A repair subagent that ran
|
|
51
|
+
**only the targeted suite** is **BLOCKED**, not done. Rationale: runner-layer changes can break
|
|
52
|
+
suites that were not failing before the repair (the C-015 regression was caught only by the
|
|
53
|
+
full run, not by the targeted re-run).
|
|
54
|
+
|
|
55
|
+
## AUTO-LOG.md schema (one line per card)
|
|
56
|
+
```
|
|
57
|
+
- C-NNN | <title> | tier=A | review=green | PR=<url> | merged=<sha> | live=<verified-url> | <date>
|
|
58
|
+
- C-NNN | <title> | tier=C HALT | reason=<security-class> | DEBT opened | <date>
|
|
59
|
+
- C-NNN | <title> | tier=B | repair=codex:codex-rescue | result=green | PR=<url> | <date>
|
|
60
|
+
```
|
|
61
|
+
When a Codex engine drafted/repaired/reviewed a card, name it in the line (`repair=` / `review=`)
|
|
62
|
+
and log the durable metric (`flow.sh harness intervention add`) per `codex-integration.md` §Durable metric.
|
|
63
|
+
|
|
64
|
+
## Parallel groups
|
|
65
|
+
`/flow ready` lists todo cards with deps met AND no allowed-files overlap. Only those run in
|
|
66
|
+
parallel, each in its own worktree/session. Merge back in card-number order, one at a time,
|
|
67
|
+
running the merged app once between merges. A merge conflict means the overlap check was
|
|
68
|
+
gamed — stop and re-plan. Cards needing the deployed app (contract-tests, e2e) are serial.
|
|
69
|
+
|
|
70
|
+
**Human-driven `/flow workspace` coexists with this auto loop.** `auto` provisions a worktree per
|
|
71
|
+
card internally (`git worktree add ../<project>-C-NNN -b card/C-NNN`); `/flow workspace add card/C-NNN`
|
|
72
|
+
uses the *same* `card/C-NNN` branch naming, so if a human and an `auto` run ever target one card,
|
|
73
|
+
git's own "a branch can only be checked out in one worktree" refusal is the guard — the second
|
|
74
|
+
`add` fails verbatim rather than double-creating. Run `/flow workspace doctor` after an `auto` run
|
|
75
|
+
to reconcile any worktree it left as an orphan tree (no side-file record).
|
|
76
|
+
|
|
77
|
+
## Security-class halt (never silent, never planner-decided)
|
|
78
|
+
auth · authorization · admin-surface exposure · tenancy · payments · data loss/migration ·
|
|
79
|
+
removing/weakening validation. On any: stop, write the `DEBT.md` line with the concrete
|
|
80
|
+
exposure + close condition, and get explicit operator acknowledgment before continuing.
|
|
81
|
+
Closing a run with open security debt requires the operator to acknowledge it in writing.
|