@haposoft/cafekit 0.16.7 → 0.18.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/README.md +14 -22
- package/bin/__tests__/codex-hooks-ownership.test.js +2 -2
- package/bin/__tests__/codex-hooks.test.js +169 -272
- package/bin/__tests__/codex-native.test.js +100 -202
- package/bin/__tests__/develop-contract.test.js +122 -1413
- package/bin/__tests__/docs-sync-on-demand.test.js +93 -0
- package/bin/__tests__/grok-envelope.test.js +0 -56
- package/bin/__tests__/hook-payload.test.js +4 -6
- package/bin/__tests__/legacy-authority-decoupled.test.js +154 -0
- package/bin/__tests__/legacy-hooks-retired.test.js +221 -0
- package/bin/__tests__/omp-bridge.test.js +20 -17
- package/bin/__tests__/omp-hooks.test.js +0 -19
- package/bin/__tests__/optional-skill-inventory.test.js +112 -4
- package/bin/__tests__/orca-session.test.js +0 -2
- package/bin/__tests__/package-inventory.test.js +90 -925
- package/bin/__tests__/runtime-dir.test.js +0 -3
- package/bin/__tests__/runtime-schema.test.js +3 -2
- package/bin/__tests__/skill-routing-source.test.js +27 -15
- package/bin/__tests__/spec-narrowing.test.js +30 -161
- package/bin/__tests__/specs-v2-execution-closeout.test.js +0 -437
- package/bin/__tests__/test-runtime-dependency-closure.cjs +1 -2
- package/bin/__tests__/ui-ux-skill.test.js +101 -0
- package/bin/__tests__/usage-hook-retired.test.js +114 -0
- package/bin/__tests__/validator-grounding.test.js +18 -2949
- package/bin/lib/managed-writer.js +2 -3
- package/bin/phases/codex-runtime.js +27 -0
- package/bin/phases/copy-payload.js +13 -28
- package/bin/phases/omp-runtime.js +25 -0
- package/package.json +2 -3
- package/src/claude/CLAUDE.md +3 -10
- package/src/claude/agents/brainstormer.md +7 -3
- package/src/claude/agents/code-auditor.md +44 -56
- package/src/claude/agents/debugger.md +8 -88
- package/src/claude/agents/deployer.md +3 -5
- package/src/claude/agents/docs-keeper.md +6 -14
- package/src/claude/agents/git-ops.md +2 -4
- package/src/claude/agents/implementer.md +12 -16
- package/src/claude/agents/inspector.md +4 -3
- package/src/claude/agents/project-manager.md +9 -17
- package/src/claude/agents/researcher.md +9 -3
- package/src/claude/agents/spec-maker.md +15 -15
- package/src/claude/agents/test-runner.md +8 -11
- package/src/claude/agents/ui-ux-designer.md +0 -1
- package/src/claude/hooks/__tests__/fixtures/statusline-default.golden +1 -1
- package/src/claude/hooks/__tests__/spec-gate.test.js +244 -333
- package/src/claude/hooks/__tests__/spec-state-touched.test.js +160 -0
- package/src/claude/hooks/__tests__/state.test.js +68 -0
- package/src/claude/hooks/__tests__/statusline.test.js +140 -11
- package/src/claude/hooks/agent.cjs +2 -1
- package/src/claude/hooks/lib/hook-payload.cjs +2 -2
- package/src/claude/hooks/rules.cjs +2 -1
- package/src/claude/hooks/session.cjs +0 -1
- package/src/claude/hooks/spec-gate.cjs +17 -83
- package/src/claude/hooks/spec-state.cjs +142 -39
- package/src/claude/hooks/state.cjs +21 -2
- package/src/claude/migration-manifest.json +42 -22
- package/src/claude/output-styles/coding-level-0-eli5.md +9 -9
- package/src/claude/output-styles/coding-level-1-junior.md +3 -3
- package/src/claude/output-styles/coding-level-2-mid.md +3 -3
- package/src/claude/output-styles/coding-level-3-senior.md +2 -2
- package/src/claude/output-styles/coding-level-4-lead.md +5 -5
- package/src/claude/output-styles/coding-level-5-god.md +6 -6
- package/src/claude/rules/ai-dev-rules.md +2 -3
- package/src/claude/rules/hook-protocols.md +8 -15
- package/src/claude/rules/manage-docs.md +9 -23
- package/src/claude/rules/orchestrator.md +3 -4
- package/src/claude/rules/review-audit-self-decision.md +3 -3
- package/src/claude/rules/skill-domain-routing.md +1 -3
- package/src/claude/rules/skill-workflow-routing.md +4 -5
- package/src/claude/rules/state-sync.md +3 -12
- package/src/claude/rules/workflow.md +11 -19
- package/src/claude/runtime.schema.json +5 -3
- package/src/claude/scripts/generate-skill-catalog.cjs +7 -6
- package/src/claude/scripts/provenance.cjs +23 -5
- package/src/claude/scripts/spec-receipt.cjs +24 -121
- package/src/claude/scripts/spec-resolver.cjs +41 -458
- package/src/claude/scripts/workflow-policy.cjs +3 -1801
- package/src/claude/settings/settings.json +1 -32
- package/src/claude/skills/agent-browser/SKILL.md +1 -1
- package/src/claude/skills/{question → ask}/SKILL.md +9 -75
- package/src/claude/skills/brainstorm/SKILL.md +43 -131
- package/src/claude/skills/chrome-devtools/SKILL.md +14 -31
- package/src/claude/skills/code-review/SKILL.md +29 -81
- package/src/claude/skills/code-review/references/spec-compliance-review.md +4 -8
- package/src/claude/skills/debug/SKILL.md +29 -149
- package/src/claude/skills/develop/SKILL.md +26 -83
- package/src/claude/skills/develop/references/parallel-waves.md +0 -8
- package/src/claude/skills/develop/references/quality-gate.md +15 -13
- package/src/claude/skills/develop/references/subagent-patterns.md +0 -6
- package/src/claude/skills/docs/SKILL.md +2 -2
- package/src/claude/skills/docs/references/update-workflow.md +1 -1
- package/src/claude/skills/fix/SKILL.md +153 -0
- package/src/claude/skills/{hotfix → fix}/references/diagnosis-protocol.md +2 -2
- package/src/claude/skills/{hotfix → fix}/references/parallel-patterns.md +2 -2
- package/src/claude/skills/{hotfix → fix}/references/prevention-gate.md +3 -3
- package/src/claude/skills/{hotfix → fix}/references/review-cycle.md +1 -1
- package/src/claude/skills/git/SKILL.md +48 -9
- package/src/claude/skills/git/references/commit-protocols.md +35 -16
- package/src/claude/skills/git/references/worktree-blueprint.md +42 -6
- package/src/claude/skills/orca/SKILL.md +9 -8
- package/src/claude/skills/research/SKILL.md +17 -46
- package/src/claude/skills/scout/SKILL.md +61 -0
- package/src/claude/skills/{inspect → scout}/references/internal-inspection.md +26 -10
- package/src/claude/skills/specs/SKILL.md +22 -29
- package/src/claude/skills/specs/references/review.md +8 -6
- package/src/claude/skills/specs/references/templates.md +34 -41
- package/src/claude/skills/sync/SKILL.md +16 -45
- package/src/claude/skills/sync/references/rebind-and-audit.md +59 -0
- package/src/claude/skills/sync/references/sync-protocols.md +4 -13
- package/src/claude/skills/test/SKILL.md +39 -104
- package/src/claude/skills/test/references/execution-strategy.md +93 -21
- package/src/claude/skills/test/references/failure-triage.md +1 -1
- package/src/claude/skills/ui-ux/LICENSE +21 -0
- package/src/claude/skills/ui-ux/SKILL.md +497 -0
- package/src/claude/skills/ui-ux/references/brand-tokens.md +90 -0
- package/src/claude/skills/ui-ux/references/budgets.md +113 -0
- package/src/claude/skills/ui-ux/references/checklist.md +271 -0
- package/src/claude/skills/ui-ux/references/components/accordion.md +246 -0
- package/src/claude/skills/ui-ux/references/components/avatar.md +153 -0
- package/src/claude/skills/ui-ux/references/components/banner.md +43 -0
- package/src/claude/skills/ui-ux/references/components/breadcrumb.md +201 -0
- package/src/claude/skills/ui-ux/references/components/button.md +142 -0
- package/src/claude/skills/ui-ux/references/components/card.md +113 -0
- package/src/claude/skills/ui-ux/references/components/charts.md +376 -0
- package/src/claude/skills/ui-ux/references/components/chat.md +132 -0
- package/src/claude/skills/ui-ux/references/components/choice-controls.md +369 -0
- package/src/claude/skills/ui-ux/references/components/comment-thread.md +17 -0
- package/src/claude/skills/ui-ux/references/components/description-list.md +116 -0
- package/src/claude/skills/ui-ux/references/components/empty-state.md +98 -0
- package/src/claude/skills/ui-ux/references/components/file-upload.md +107 -0
- package/src/claude/skills/ui-ux/references/components/inline-edit.md +128 -0
- package/src/claude/skills/ui-ux/references/components/input.md +161 -0
- package/src/claude/skills/ui-ux/references/components/list-row.md +56 -0
- package/src/claude/skills/ui-ux/references/components/loading.md +198 -0
- package/src/claude/skills/ui-ux/references/components/logo.md +147 -0
- package/src/claude/skills/ui-ux/references/components/otp-input.md +43 -0
- package/src/claude/skills/ui-ux/references/components/quantity-input.md +100 -0
- package/src/claude/skills/ui-ux/references/components/range-slider.md +16 -0
- package/src/claude/skills/ui-ux/references/components/small-controls.md +340 -0
- package/src/claude/skills/ui-ux/references/components/sortable-header.md +86 -0
- package/src/claude/skills/ui-ux/references/components/tag-input.md +14 -0
- package/src/claude/skills/ui-ux/references/components/timeline.md +38 -0
- package/src/claude/skills/ui-ux/references/components/tree.md +30 -0
- package/src/claude/skills/ui-ux/references/design-process.md +650 -0
- package/src/claude/skills/ui-ux/references/layouts/app-kanban.html +303 -0
- package/src/claude/skills/ui-ux/references/layouts/app.md +1369 -0
- package/src/claude/skills/ui-ux/references/layouts/form.md +430 -0
- package/src/claude/skills/ui-ux/references/layouts/overlay.md +552 -0
- package/src/claude/skills/ui-ux/references/layouts/pricing.md +204 -0
- package/src/claude/skills/ui-ux/references/locked-rules.md +35 -0
- package/src/claude/skills/ui-ux/references/principles.md +408 -0
- package/src/claude/skills/ui-ux/references/refactor.md +245 -0
- package/src/claude/skills/ui-ux/references/responsive.md +195 -0
- package/src/claude/skills/ui-ux/references/review.md +528 -0
- package/src/claude/skills/ui-ux/references/rules-color.md +623 -0
- package/src/claude/skills/ui-ux/references/rules-form.md +235 -0
- package/src/claude/skills/ui-ux/references/rules-state.md +680 -0
- package/src/claude/skills/ui-ux/references/rules-type.md +369 -0
- package/src/claude/skills/ui-ux/references/styles.md +311 -0
- package/src/claude/skills/ui-ux/references/system.md +219 -0
- package/src/claude/skills/ui-ux/references/tailwind-v4-traps.md +237 -0
- package/src/claude/skills/ui-ux/references/tokens.css +362 -0
- package/src/claude/skills/ui-ux/scripts/lint-skill.mjs +216 -0
- package/src/claude/skills/ui-ux/scripts/package.json +9 -0
- package/src/claude/skills/ui-ux/scripts/probe.mjs +4447 -0
- package/src/claude/skills/ui-ux-pro-max/SKILL.md +25 -80
- package/src/claude/skills/web-testing/SKILL.md +2 -20
- package/src/claude/status.cjs +149 -144
- package/src/codex/AGENTS.md +8 -13
- package/src/codex/hooks/agent.cjs +2 -1
- package/src/codex/hooks/lib/spec-receipt.cjs +4 -32
- package/src/codex/hooks/lib/spec-utils.cjs +6 -52
- package/src/codex/hooks/rules.cjs +2 -1
- package/src/codex/hooks/session.cjs +0 -2
- package/src/codex/hooks/spec-gate.cjs +13 -81
- package/src/codex/hooks/spec-state.cjs +37 -41
- package/src/codex/hooks.json +0 -20
- package/src/codex/rules/state-sync.md +3 -12
- package/src/common/AGENTS.md +6 -12
- package/src/omp/extensions/cafekit-bridge.mjs +6 -6
- package/bin/__tests__/change-firewall.semantic-firewall.test.js +0 -2133
- package/bin/__tests__/finalizer-pass-gate.semantic-firewall.test.js +0 -342
- package/bin/__tests__/release-preflight.semantic-firewall.test.js +0 -586
- package/bin/__tests__/review-receipt-c2.semantic-firewall.test.js +0 -378
- package/bin/__tests__/specs-v2-policy-and-scaffold.test.js +0 -665
- package/bin/__tests__/specs-v2-validator-grounder-contract.test.js +0 -1132
- package/src/claude/hooks/__tests__/completion-authority.test.js +0 -990
- package/src/claude/hooks/__tests__/semantic-review-authority.test.js +0 -259
- package/src/claude/hooks/completion-authority-check.cjs +0 -56
- package/src/claude/hooks/completion-authority-state.cjs +0 -527
- package/src/claude/hooks/completion-authority.cjs +0 -163
- package/src/claude/hooks/lib/context.cjs +0 -616
- package/src/claude/hooks/lib/detect.cjs +0 -474
- package/src/claude/hooks/semantic-review-authority.cjs +0 -154
- package/src/claude/hooks/task-scaffold-guard.cjs +0 -114
- package/src/claude/hooks/usage.cjs +0 -197
- package/src/claude/scripts/change-firewall.cjs +0 -1748
- package/src/claude/scripts/spec-authoring-digest.cjs +0 -151
- package/src/claude/scripts/spec-authoring-validation.cjs +0 -126
- package/src/claude/scripts/spec-final-state.cjs +0 -290
- package/src/claude/scripts/spec-ground.cjs +0 -650
- package/src/claude/scripts/spec-readiness.cjs +0 -425
- package/src/claude/scripts/spec-scaffold.cjs +0 -2317
- package/src/claude/scripts/spec-semantic-model.cjs +0 -396
- package/src/claude/scripts/validate-spec-output.cjs +0 -3941
- package/src/claude/skills/code-review/references/verification-gate.md +0 -46
- package/src/claude/skills/delegate/SKILL.md +0 -124
- package/src/claude/skills/delegate/references/codex-delegation.md +0 -71
- package/src/claude/skills/delegate/references/grok-delegation.md +0 -84
- package/src/claude/skills/hotfix/SKILL.md +0 -289
- package/src/claude/skills/inspect/SKILL.md +0 -142
- package/src/claude/skills/loop/SKILL.md +0 -114
- package/src/claude/skills/loop/references/bounded-loop-protocol.md +0 -104
- package/src/claude/skills/loop/references/metric-and-guard-contract.md +0 -76
- package/src/claude/skills/route/SKILL.md +0 -94
- package/src/claude/skills/route/references/agent-timing.md +0 -46
- package/src/claude/skills/route/references/chaining-patterns.md +0 -53
- package/src/claude/skills/route/references/task-taxonomy.md +0 -48
- package/src/claude/skills/specs/templates/design.md +0 -82
- package/src/claude/skills/specs/templates/requirements-init.md +0 -8
- package/src/claude/skills/specs/templates/requirements.md +0 -42
- package/src/claude/skills/specs/templates/spec-state.json +0 -56
- package/src/claude/skills/specs/templates/task.md +0 -47
- package/src/codex/hooks/completion-authority-check.cjs +0 -67
- package/src/codex/hooks/completion-authority-state.cjs +0 -527
- package/src/codex/hooks/completion-authority.cjs +0 -109
- package/src/codex/hooks/semantic-review-authority.cjs +0 -130
- package/src/codex/hooks/task-scaffold-guard.cjs +0 -63
- /package/src/claude/skills/{question → ask}/templates/question.md +0 -0
- /package/src/claude/skills/{hotfix → fix}/references/escalation-tactics.md +0 -0
- /package/src/claude/skills/{hotfix → fix}/references/workflow-specialized.md +0 -0
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: verification-gate
|
|
3
|
-
description: The Iron Law of Proof. Prohibits reporting a 'PASS' status without providing concrete execution proofs (like exit code 0 or successfully passing tests).
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Verification Gate: The Iron Law of Proof
|
|
7
|
-
|
|
8
|
-
In the Hapo ecosystem, words are cheap. Code that "looks right" to an AI can easily break in production. This reference defines the strictest, most uncompromising rule for Code Review.
|
|
9
|
-
|
|
10
|
-
## 1. The Iron Law
|
|
11
|
-
**You MUST NOT issue a final verdict of PASS unless you hold concrete, verifiable execution proof.**
|
|
12
|
-
|
|
13
|
-
## 2. Hallucination Block
|
|
14
|
-
Never use the following phrases or implications to assess code functionality:
|
|
15
|
-
- "The code looks good."
|
|
16
|
-
- "The logic seems sound."
|
|
17
|
-
- "This should work as expected."
|
|
18
|
-
- "There are no obvious errors."
|
|
19
|
-
|
|
20
|
-
If you have not compiled it, ran it, or seen it pass tests, **you do not know if it works**.
|
|
21
|
-
|
|
22
|
-
## 3. Accepted Proofs of Execution
|
|
23
|
-
To clear the Verification Gate, you must cite one of the following concrete proofs in your report:
|
|
24
|
-
|
|
25
|
-
- **Test Suite Logs:** Output showing tests ran and passed (e.g., `PASS src/components/Login.test.tsx`).
|
|
26
|
-
- **Compilation/Build Status:** Terminal output proving the typescript compiler (`tsc`) or bundler succeeded with `Exit code: 0`.
|
|
27
|
-
- **Linter Completion:** Output proving no syntax errors exist.
|
|
28
|
-
- **Multimodal Visual Evidence:** `cf:ai-multimodal` when installed, or another available runtime visual capability; otherwise report visual parity as `UNPROVEN`.
|
|
29
|
-
|
|
30
|
-
For Specs v2, accepted proof must be persisted by the test owner at
|
|
31
|
-
`receipts/<task-basename>.md`; legacy `## Evidence` remains fallback-only. The
|
|
32
|
-
receipt includes identity/path, exact command, exit/result, expected versus
|
|
33
|
-
observed behavior, applicable negative/reachability/artifact proof, and bound
|
|
34
|
-
Base/Head. Final integration uses `feature-receipt.md`. Missing final receipt is
|
|
35
|
-
normal before closeout, but mandatory at closeout. Neither receipt grants
|
|
36
|
-
approval, readiness, audit status, or product semantics.
|
|
37
|
-
|
|
38
|
-
For v2.1, the semantic receipt is reviewed input, not execution proof. It binds
|
|
39
|
-
exact criteria and counterexamples shaped as `criterion`, `case_kind`,
|
|
40
|
-
`scenario`, `expected`, `decision_refs`, and `verification_ref`. Deterministic
|
|
41
|
-
validator success is never a semantic-review verdict.
|
|
42
|
-
|
|
43
|
-
## 4. How to Handle Missing Proof
|
|
44
|
-
If you are asked to review a PR or commit and no execution proof is available:
|
|
45
|
-
1. **Return `BLOCKED`** and name missing commands, artifacts, permissions, or environment access.
|
|
46
|
-
2. Do not issue `PASS`, do not downgrade to a tentative pass, and do not blind-retry. Resume only after proof arrives.
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: cf:delegate
|
|
3
|
-
description: "Delegate implementation tasks from Claude Code to external CLI agents (Codex or Grok). Covers task-brief authoring, non-interactive dispatch, permission setup, background monitoring, resume, and independent verification of the returned work."
|
|
4
|
-
user-invocable: true
|
|
5
|
-
when_to_use: "Invoke when the user asks to assign/offload a coding task to codex or grok, or to run work on an external agent CLI."
|
|
6
|
-
category: orchestration
|
|
7
|
-
keywords: [delegate, codex, grok, external-agent, offload, assign]
|
|
8
|
-
argument-hint: "<codex|grok> <task-description | path/to/task-brief.md>"
|
|
9
|
-
metadata:
|
|
10
|
-
author: haposoft
|
|
11
|
-
version: "1.0.0"
|
|
12
|
-
---
|
|
13
|
-
# Delegate to External Agents (Codex / Grok)
|
|
14
|
-
|
|
15
|
-
Dispatch a well-scoped implementation task to an external agentic CLI — **Codex** (OpenAI) or **Grok** (xAI Grok Build) — from a Claude Code session acting as orchestrator. Claude Code stays responsible for: writing the task brief, choosing safe permissions, monitoring, and **independently verifying** the result before reporting completion.
|
|
16
|
-
|
|
17
|
-
**Mantra:** Brief precisely, sandbox tightly, verify independently.
|
|
18
|
-
|
|
19
|
-
## When to Use
|
|
20
|
-
|
|
21
|
-
- User explicitly asks to hand a task to codex/grok ("giao cho codex", "assign to grok").
|
|
22
|
-
- Parallel workstreams: Claude Code keeps orchestrating while an external agent implements a scoped task.
|
|
23
|
-
- Cross-checking: a second model implements or reviews independently.
|
|
24
|
-
|
|
25
|
-
Do NOT delegate: tasks touching secrets/`.env`, deploys to shared environments, destructive migrations on live data, or tasks whose scope is still unclear (clarify first — a vague brief wastes an entire agent run).
|
|
26
|
-
|
|
27
|
-
## Workflow
|
|
28
|
-
|
|
29
|
-
### 1. Write the task brief (mandatory, file-based)
|
|
30
|
-
|
|
31
|
-
External agents run **fresh-context** — they see none of your conversation. Write the brief to a file (convention: `plans/<slug>-task.md` in the target repo), never inline-only. Follow the orchestrator prompt rules (`.claude/rules/orchestrator.md`): the brief must be self-contained.
|
|
32
|
-
|
|
33
|
-
Required sections:
|
|
34
|
-
|
|
35
|
-
```markdown
|
|
36
|
-
# Task: <title>
|
|
37
|
-
|
|
38
|
-
> Self-contained brief for a fresh-context agent. Date: <YYYY-MM-DD>.
|
|
39
|
-
> FOUNDATION: <state of the working tree the agent builds on — branch,
|
|
40
|
-
> uncommitted changes it must NOT revert, verified test/build status>
|
|
41
|
-
|
|
42
|
-
## Context — project, architecture, why this task exists
|
|
43
|
-
## Scope — numbered work items with exact file paths
|
|
44
|
-
## Constraints — what must NOT be touched (staging data, .env, deploys,
|
|
45
|
-
unrelated refactors); repo rules to obey (CLAUDE.md)
|
|
46
|
-
## Completion Criteria — verifiable, numbered
|
|
47
|
-
## Evidence required — exact commands whose output proves completion
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
Rules of thumb:
|
|
51
|
-
- Name exact files and line-level anchors where known; agents burn tokens rediscovering what you already know.
|
|
52
|
-
- State dependency order explicitly if this task builds on another agent's uncommitted work ("do NOT revert/stash existing changes").
|
|
53
|
-
- Put user-pending decisions in Constraints as forbidden actions (e.g. "do NOT touch staging rows until user confirms").
|
|
54
|
-
|
|
55
|
-
### 2. Protect the working tree
|
|
56
|
-
|
|
57
|
-
Before dispatch, snapshot state you cannot afford to lose:
|
|
58
|
-
|
|
59
|
-
```bash
|
|
60
|
-
git stash push -u -m "backup: <reason>" && git stash apply -q # snapshot, keep tree intact
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
Prefer isolation when the task is risky or parallel to other edits:
|
|
64
|
-
- Grok: `--worktree=<name>` (built-in).
|
|
65
|
-
- Codex: run with `-C <worktree-dir>` after creating a git worktree yourself.
|
|
66
|
-
|
|
67
|
-
If the agent must build on uncommitted changes, isolation is not possible — use the stash-backup pattern above and say so in the brief.
|
|
68
|
-
|
|
69
|
-
### 3. Dispatch
|
|
70
|
-
|
|
71
|
-
Load the matching reference for exact flags, permission model, and pitfalls:
|
|
72
|
-
- **Codex:** `./references/codex-delegation.md`
|
|
73
|
-
- **Grok:** `./references/grok-delegation.md`
|
|
74
|
-
|
|
75
|
-
Common principles:
|
|
76
|
-
- Run non-interactive/headless mode in a **background** shell; both CLIs stream progress to stdout.
|
|
77
|
-
- Grant the **minimum** permission set that lets the agent write code and run its Evidence commands (npm/node). Never grant full-access/bypass modes for routine tasks.
|
|
78
|
-
- Model/effort overrides: pass explicitly rather than relying on user config, so the run is reproducible.
|
|
79
|
-
- Capture the output file path; check progress after ~20–30s to confirm the agent actually started (auth errors, bad flags, and permission blocks surface early).
|
|
80
|
-
|
|
81
|
-
### 4. Monitor
|
|
82
|
-
|
|
83
|
-
- Poll the background output periodically; look for permission-block messages — both CLIs degrade to "design-only" output instead of failing loudly when a write tool is blocked.
|
|
84
|
-
- If blocked on permissions: **resume the same session** with corrected flags (both CLIs support resume; see references) — context is preserved, work continues instead of restarting.
|
|
85
|
-
- Apply the 3-strike rule from `.claude/rules/orchestrator.md`: same failure 3+ times → stop, escalate to user with evidence.
|
|
86
|
-
|
|
87
|
-
### 5. Verify independently (non-negotiable)
|
|
88
|
-
|
|
89
|
-
External-agent claims are **not** evidence (CLAUDE.md: no completion claim without fresh proof from the current run). After the agent reports done:
|
|
90
|
-
|
|
91
|
-
1. `git status` / `git diff` — confirm the changed file set matches the brief's Scope; flag out-of-scope edits.
|
|
92
|
-
2. Run the brief's Evidence commands yourself (tests, build). The agent's transcript of a test run does not count.
|
|
93
|
-
3. Check Completion Criteria one by one.
|
|
94
|
-
4. Report to user: what was delegated, what came back, verification results, and any deviations.
|
|
95
|
-
|
|
96
|
-
### 6. Sync
|
|
97
|
-
|
|
98
|
-
- Keep the brief file updated (checklist ticks / blockers) so it doubles as task state.
|
|
99
|
-
- If a spec (`specs/<slug>/`) governs the work, follow the Tollgate Protocol (`.claude/rules/state-sync.md`): update `spec.json` + task files only after verification passes.
|
|
100
|
-
- The user decides commit/merge/deploy — delegation ends at verified working-tree changes unless told otherwise.
|
|
101
|
-
|
|
102
|
-
## Choosing Codex vs Grok
|
|
103
|
-
|
|
104
|
-
Both are capable general coding agents; prefer the one the user names. If unspecified:
|
|
105
|
-
|
|
106
|
-
| Factor | Codex | Grok |
|
|
107
|
-
|---|---|---|
|
|
108
|
-
| Isolation | manual git worktree + `-C` | built-in `--worktree=<name>` |
|
|
109
|
-
| Structured output | `--output-schema` (JSON Schema) | `--json-schema` |
|
|
110
|
-
| Self-verification | ask in the brief | `--check` flag appends a verify loop |
|
|
111
|
-
| Resume | `codex exec resume <id>` | `grok --resume <id>` |
|
|
112
|
-
|
|
113
|
-
## Rules
|
|
114
|
-
|
|
115
|
-
- Never grant `--dangerously-bypass-approvals-and-sandbox` (codex) or `bypassPermissions` (grok) for routine delegation.
|
|
116
|
-
- Never let an external agent touch `.env`, secrets, staging/production data, or run deploys.
|
|
117
|
-
- Never report the agent's own success claim as completion — verify first.
|
|
118
|
-
- Never re-dispatch a blocked task unchanged (BLOCKED ≠ retry; fix the cause: permissions, context, or scope).
|
|
119
|
-
- One writer per file set: don't run two agents (or an agent + yourself) editing the same files concurrently.
|
|
120
|
-
|
|
121
|
-
## References
|
|
122
|
-
|
|
123
|
-
- `./references/codex-delegation.md` — Codex CLI: exec mode, sandbox/approval model, resume, pitfalls
|
|
124
|
-
- `./references/grok-delegation.md` — Grok CLI: headless mode, worktree, permission rules, resume, pitfalls
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
# Delegating to Codex CLI
|
|
2
|
-
|
|
3
|
-
Verified against codex-cli 0.144.4 (2026-07). Re-check `codex exec --help` if flags fail — the CLI evolves quickly.
|
|
4
|
-
|
|
5
|
-
## Preflight
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
which codex && codex --version # installed?
|
|
9
|
-
codex doctor # auth + runtime health (slow; run only when suspicious)
|
|
10
|
-
```
|
|
11
|
-
|
|
12
|
-
User-level defaults live in `~/.codex/config.toml` (`model`, `model_reasoning_effort`, agents, MCP servers). Overrides via `-m` and `-c key=value` beat config — pass them explicitly for reproducible runs.
|
|
13
|
-
|
|
14
|
-
## Non-interactive dispatch: `codex exec`
|
|
15
|
-
|
|
16
|
-
Reads the prompt from an argument, or from **stdin** when the argument is `-`. Prefer stdin + brief file:
|
|
17
|
-
|
|
18
|
-
```bash
|
|
19
|
-
codex exec \
|
|
20
|
-
-m gpt-5.6-terra \
|
|
21
|
-
-c model_reasoning_effort='"max"' \
|
|
22
|
-
--sandbox workspace-write \
|
|
23
|
-
-o /tmp/codex-last-message.txt \
|
|
24
|
-
- < plans/<slug>-task.md
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
Run it in a background shell and poll the output.
|
|
28
|
-
|
|
29
|
-
### Key flags
|
|
30
|
-
|
|
31
|
-
| Flag | Notes |
|
|
32
|
-
|---|---|
|
|
33
|
-
| `-m <model>` | model ID, e.g. `gpt-5.6-terra` (note spelling: *terra*) |
|
|
34
|
-
| `-c model_reasoning_effort='"max"'` | TOML-parsed value — keep the inner quotes |
|
|
35
|
-
| `--sandbox <mode>` | `read-only` \| `workspace-write` \| `danger-full-access` |
|
|
36
|
-
| `-o <file>` | write the agent's final message to a file — easiest completion check |
|
|
37
|
-
| `-C <dir>` | working root (use for delegating into a git worktree) |
|
|
38
|
-
| `--add-dir <dir>` | extra writable dirs alongside the workspace |
|
|
39
|
-
| `--output-schema <file>` | JSON Schema constraining the final response |
|
|
40
|
-
| `--json` | JSONL event stream on stdout (machine parsing) |
|
|
41
|
-
| `--ephemeral` | don't persist session files |
|
|
42
|
-
|
|
43
|
-
### Pitfalls
|
|
44
|
-
|
|
45
|
-
- **`-a` / `--ask-for-approval` is TUI-only.** `codex exec` rejects it (`error: unexpected argument '-a' found`). Exec mode is implicitly `approval: never` — sandbox mode is your only control there.
|
|
46
|
-
- **`workspace-write` limits writes, not reads**, to: workdir, `/tmp`, `$TMPDIR`. Network is available. Commands needing writes outside (global installs) will fail — keep Evidence commands repo-local.
|
|
47
|
-
- **Effort value is TOML**: `-c model_reasoning_effort='"max"'` (double-quoted inside single quotes). Bare `max` may parse as a literal string too, but the quoted form is unambiguous.
|
|
48
|
-
- Startup banner echoes `model:`, `reasoning effort:`, `sandbox:` — **verify these lines** ~20s after dispatch instead of assuming flags took effect.
|
|
49
|
-
- User config may define agents/hooks/MCP servers that activate automatically; `--ignore-user-config` gives a clean run if they interfere.
|
|
50
|
-
|
|
51
|
-
## Monitor & verify liveness
|
|
52
|
-
|
|
53
|
-
```bash
|
|
54
|
-
# ~20-30s after dispatch: banner shows model/sandbox; then agent narration follows
|
|
55
|
-
head -c 1200 <output-file>
|
|
56
|
-
tail -c 1500 <output-file> # progress
|
|
57
|
-
cat /tmp/codex-last-message.txt # exists → run finished; content = final report
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
## Resume
|
|
61
|
-
|
|
62
|
-
```bash
|
|
63
|
-
codex exec resume --last "<follow-up>" # most recent session
|
|
64
|
-
codex exec resume <SESSION_ID> "<follow-up>" # by id (session id printed in banner)
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
Use resume (not a fresh dispatch) when: permission-blocked mid-run, follow-up fixes after your verification failed, or continuing a design into implementation.
|
|
68
|
-
|
|
69
|
-
## Review mode
|
|
70
|
-
|
|
71
|
-
`codex review` (or `codex exec review`) runs a non-interactive code review of the current repo — useful as an independent second-opinion pass on another agent's diff.
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
# Delegating to Grok CLI (Grok Build)
|
|
2
|
-
|
|
3
|
-
Verified against grok 0.2.101 (2026-07). Re-check `grok --help` if flags fail.
|
|
4
|
-
|
|
5
|
-
## Preflight
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
which grok && grok --version
|
|
9
|
-
grok models # available model IDs
|
|
10
|
-
```
|
|
11
|
-
|
|
12
|
-
## Non-interactive dispatch
|
|
13
|
-
|
|
14
|
-
Two forms:
|
|
15
|
-
|
|
16
|
-
```bash
|
|
17
|
-
# single-turn from a brief file (preferred for delegation)
|
|
18
|
-
grok --prompt-file plans/<slug>-task.md \
|
|
19
|
-
--worktree=<slug> \
|
|
20
|
-
--check \
|
|
21
|
-
--permission-mode acceptEdits \
|
|
22
|
-
--allow "Bash(npm:*)" --allow "Bash(node:*)" \
|
|
23
|
-
--output-format plain
|
|
24
|
-
|
|
25
|
-
# short single-turn prompt
|
|
26
|
-
grok -p "<prompt>"
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
Run in a background shell and poll the output.
|
|
30
|
-
|
|
31
|
-
### Key flags
|
|
32
|
-
|
|
33
|
-
| Flag | Notes |
|
|
34
|
-
|---|---|
|
|
35
|
-
| `--prompt-file <path>` | single-turn prompt from file |
|
|
36
|
-
| `-p, --single <prompt>` | single-turn inline prompt |
|
|
37
|
-
| `--worktree=<name>` | built-in git worktree isolation (grok-managed; see pitfalls) |
|
|
38
|
-
| `--check` | appends a self-verification loop (headless only) — use it |
|
|
39
|
-
| `--permission-mode <mode>` | `default` \| `acceptEdits` \| `auto` \| `dontAsk` \| `bypassPermissions` \| `plan` |
|
|
40
|
-
| `--allow "<RULE>"` / `--deny "<RULE>"` | permission rules, Claude Code syntax: `Bash(npm:*)`, `Write`, `Edit` |
|
|
41
|
-
| `-m <model>` / `--reasoning-effort` | model + effort overrides |
|
|
42
|
-
| `--max-turns <N>` | hard cap on agent turns |
|
|
43
|
-
| `--json-schema '<schema>'` | structured final output |
|
|
44
|
-
| `--output-format plain\|json\|streaming-json` | headless output format |
|
|
45
|
-
| `--resume <SESSION_ID>` | continue a session (context preserved) |
|
|
46
|
-
| `--best-of-n <N>` | run task N ways in parallel, pick best (headless) |
|
|
47
|
-
|
|
48
|
-
## Permission model — the #1 pitfall
|
|
49
|
-
|
|
50
|
-
`--permission-mode acceptEdits` **does not reliably unblock file writes in headless runs**; grok may report "Write tool blocked" and quietly degrade to a **design-only** response that reads like progress. It still exits 0.
|
|
51
|
-
|
|
52
|
-
Mitigations:
|
|
53
|
-
- Add explicit allow rules for write tools on the first dispatch: `--allow "Write" --allow "Edit" --allow "StrReplace"` alongside `--allow "Bash(npm:*)" --allow "Bash(node:*)"`.
|
|
54
|
-
- After ~30s, grep the output for `blocked`/`chặn` — catch degradation early.
|
|
55
|
-
- If the run finished design-only: **resume the same session** with widened allows and an explicit apply instruction; grok picks up its own design and implements without re-exploring:
|
|
56
|
-
|
|
57
|
-
```bash
|
|
58
|
-
grok --resume <SESSION_ID> --no-plan \
|
|
59
|
-
--permission-mode acceptEdits \
|
|
60
|
-
--allow "Write" --allow "Edit" --allow "StrReplace" \
|
|
61
|
-
--allow "Bash(npm:*)" --allow "Bash(node:*)" \
|
|
62
|
-
--check -p "Continue: apply the designed changes, run tests, report results."
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
Even with allows granted, shell may still be policy-restricted (runs finish with "npm test BLOCKED — shell not pre-approved"). That's fine: **you run the Evidence commands yourself during verification** — do not loosen to `bypassPermissions` just to make the agent self-verify.
|
|
66
|
-
|
|
67
|
-
## Worktree pitfalls
|
|
68
|
-
|
|
69
|
-
- `--worktree=<name>` worktrees are **grok-managed**: they may not appear in the target repo's `git worktree list` and `grok worktree list` may still say "No worktrees found". **Do not trust either listing** — after the run, check `git status` in the main repo to find where changes actually landed. In practice (0.2.101, resumed sessions) grok can write **directly into the main working tree** despite the flag.
|
|
70
|
-
- Consequence: always take a stash-backup snapshot before dispatch (`git stash push -u -m "backup: ..." && git stash apply -q`), and treat the main tree as potentially modified.
|
|
71
|
-
|
|
72
|
-
## Session management
|
|
73
|
-
|
|
74
|
-
```bash
|
|
75
|
-
grok sessions list # ids + summaries
|
|
76
|
-
grok --resume <SESSION_ID> [flags] -p "..." # continue with same context
|
|
77
|
-
grok export <SESSION_ID> # transcript as Markdown
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
## Quirks
|
|
81
|
-
|
|
82
|
-
- Grok reads the target repo's `CLAUDE.md` and obeys it (including tone rules) — repo constraints apply automatically, but so do repo-wide bans; account for that in the brief.
|
|
83
|
-
- `--check` produces a self-verification section in the final report — useful signal, **not** a substitute for your independent verification.
|
|
84
|
-
- Exit code 0 means the CLI ran, not that the task succeeded. Judge by diff + your own Evidence runs.
|
|
@@ -1,289 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: cf:fix
|
|
3
|
-
description: "Use when asked to FIX a bug, error, test failure, CI/CD issue, type error, lint error, log error, UI issue, or code problem. Uses cf:debug for evidence-first diagnosis before any code change."
|
|
4
|
-
user-invocable: true
|
|
5
|
-
when_to_use: "Invoke to fix a bug or failure with scout-first diagnosis before change."
|
|
6
|
-
category: dev-tools
|
|
7
|
-
keywords: [hotfix, fix, bug, diagnosis]
|
|
8
|
-
argument-hint: "[issue] --quick|--parallel|--from-debug"
|
|
9
|
-
metadata:
|
|
10
|
-
author: haposoft
|
|
11
|
-
version: "2.0.0"
|
|
12
|
-
---
|
|
13
|
-
# Fix — root-cause repair workflow
|
|
14
|
-
|
|
15
|
-
Fix the diagnosed root cause, prove the fix with fresh evidence, and leave no
|
|
16
|
-
side effects. Evidence first, fix second.
|
|
17
|
-
|
|
18
|
-
## Arguments
|
|
19
|
-
|
|
20
|
-
- `--quick` - Reduced-depth path for trivial issues (lint, type errors, syntax); still scout-first
|
|
21
|
-
- `--parallel` - Fix independent issues concurrently, only through the Delegation Gate below
|
|
22
|
-
- `--from-debug` - Start from an existing `cf:debug` report and validate its contract before accepting it
|
|
23
|
-
|
|
24
|
-
Default: deterministic scout-first fix. There is no initial mode selection step.
|
|
25
|
-
|
|
26
|
-
## Proportional depth
|
|
27
|
-
|
|
28
|
-
Choose the smallest adequate depth from the diagnosed evidence. Depth vocabulary
|
|
29
|
-
follows `cf:debug`:
|
|
30
|
-
|
|
31
|
-
- **Quick/local:** one deterministic syntax, lint, type, or isolated-test failure
|
|
32
|
-
with obvious local scope. Quick mode only reduces depth; it never skips scout, pre-fix evidence, diagnosis, or before/after verification.
|
|
33
|
-
- **Standard:** a diagnosed root cause inside one bounded area. Fix plus a
|
|
34
|
-
regression test that fails without the fix and passes with it.
|
|
35
|
-
- **Incident/deep:** production impact, multiple components, intermittent
|
|
36
|
-
behavior, data/security risk, or concurrency. Consume the full Incident/deep
|
|
37
|
-
debug handoff (timeline, elimination path, recurrence candidates), implement in
|
|
38
|
-
stages, and verify each stage.
|
|
39
|
-
|
|
40
|
-
Depth changes evidence breadth, never the gates: scout, diagnosis, before/after
|
|
41
|
-
proof, and the side-effect gate apply at every depth.
|
|
42
|
-
|
|
43
|
-
## Bounded repair frame
|
|
44
|
-
|
|
45
|
-
Quick/local does not add a separate framing ceremony when the issue and diagnosis
|
|
46
|
-
already establish the repaired behavior and proof. For Standard or Incident/deep,
|
|
47
|
-
or whenever scope or risk remains ambiguous after diagnosis, record four short
|
|
48
|
-
fields before choosing an implementation:
|
|
49
|
-
|
|
50
|
-
- **Outcome:** the observable repaired behavior.
|
|
51
|
-
- **Constraints:** compatibility, safety, ownership, rollout, and time boundaries.
|
|
52
|
-
- **Non-goals:** adjacent behavior the repair must not absorb.
|
|
53
|
-
- **Acceptance:** the exact reproduction plus broader evidence that proves completion.
|
|
54
|
-
|
|
55
|
-
Derive repository-owned facts from scout and diagnosis. Ask the user only for a
|
|
56
|
-
missing user-owned decision that could materially change the repair. This frame
|
|
57
|
-
does not select a solution, widen the issue into feature work, or run before the
|
|
58
|
-
root cause is proven.
|
|
59
|
-
|
|
60
|
-
<HARD-GATE>
|
|
61
|
-
Do not propose or implement a fix before Steps 1-2 (scout + diagnosis) complete.
|
|
62
|
-
A symptom patch without a diagnosed root cause is a failed fix.
|
|
63
|
-
The exact root-cause contract in Step 2 is mandatory; answer each field in one concrete sentence.
|
|
64
|
-
An answer containing 'probably', 'I think', 'something with', or 'maybe' is not an answer; gather evidence instead.
|
|
65
|
-
If 3+ fix attempts fail, stop, question the architecture, and discuss with the user.
|
|
66
|
-
</HARD-GATE>
|
|
67
|
-
|
|
68
|
-
<HARD-GATE-SCOUT-FIRST>
|
|
69
|
-
Fix always scouts before asking broad clarification questions, forming hypotheses, or changing files.
|
|
70
|
-
Collect these scout outputs first:
|
|
71
|
-
1. Project type, language(s), framework(s), and package/test runner from repo files.
|
|
72
|
-
2. Exact file(s) where the symptom surfaces and their direct callers/dependents.
|
|
73
|
-
3. Related tests covering the affected area.
|
|
74
|
-
4. Recent commits touching affected files: `git log --oneline -10 -- <affected-files>`.
|
|
75
|
-
5. Existing patterns/conventions for this kind of fix.
|
|
76
|
-
Then state a concise 3-6 bullet codebase-context summary before Step 2.
|
|
77
|
-
Do not ask generic questions before this step unless there is no repo, no error text, and no observable artifact to inspect.
|
|
78
|
-
</HARD-GATE-SCOUT-FIRST>
|
|
79
|
-
|
|
80
|
-
<HARD-GATE-NO-SIDE-EFFECTS>
|
|
81
|
-
The fix is not done until Step 5 proves:
|
|
82
|
-
1. The original symptom no longer reproduces with the exact pre-fix command/user flow.
|
|
83
|
-
2. Modified files and transitively affected modules still pass relevant tests.
|
|
84
|
-
3. Blast-radius workflows have no business-logic regression.
|
|
85
|
-
4. No new lint/type/build errors were introduced.
|
|
86
|
-
5. Public contracts are unchanged unless intentionally called out: function signatures, exported types, response shapes, DB schemas, env vars.
|
|
87
|
-
|
|
88
|
-
If verification reveals a side effect or regression, stop and present 2-4 concrete options to the user:
|
|
89
|
-
- Revert this fix and try a different root-cause angle
|
|
90
|
-
- Keep the fix and update <dependent files> to match the new contract
|
|
91
|
-
- Narrow the fix to <subset> so the regression disappears
|
|
92
|
-
- Accept the change — the old behavior was itself a bug
|
|
93
|
-
Do not silently patch around the regression.
|
|
94
|
-
</HARD-GATE-NO-SIDE-EFFECTS>
|
|
95
|
-
|
|
96
|
-
## Delegation Gate
|
|
97
|
-
|
|
98
|
-
Dispatch subagents (parallel scouts, hypothesis tests, deep research, or
|
|
99
|
-
`--parallel` fix trees) only when all three conditions hold:
|
|
100
|
-
|
|
101
|
-
- The user explicitly requested or permitted delegation or parallel agents.
|
|
102
|
-
- The active runtime exposes an Explore/delegation capability.
|
|
103
|
-
- The work splits into at least two distinct, non-overlapping scopes with useful independent work.
|
|
104
|
-
|
|
105
|
-
Otherwise continue sequentially in the main agent with focused local evidence.
|
|
106
|
-
Task-tracking tools are an optional visibility fallback, never a required step;
|
|
107
|
-
a concise markdown checklist is always sufficient.
|
|
108
|
-
|
|
109
|
-
## Process Flow
|
|
110
|
-
|
|
111
|
-
```mermaid
|
|
112
|
-
flowchart TD
|
|
113
|
-
A[Issue Input] --> B[Step 1: Scout via cf:scout]
|
|
114
|
-
B --> C[Step 2: Diagnose via cf:debug]
|
|
115
|
-
C --> D[Step 3: Select Depth]
|
|
116
|
-
D --> E[Step 4: Implement Fix]
|
|
117
|
-
E --> F[Step 5: Verify + Prevent]
|
|
118
|
-
F --> G[Side-Effect Gate]
|
|
119
|
-
G -->|Pass| H[Step 6: Finalize]
|
|
120
|
-
G -->|Regression risk| C
|
|
121
|
-
F -->|Fail, <3 attempts| C
|
|
122
|
-
F -->|Fail, 3+ attempts| I[Question architecture with user]
|
|
123
|
-
H --> J[Report]
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
If prose conflicts with this flow, follow the diagram.
|
|
127
|
-
|
|
128
|
-
---
|
|
129
|
-
|
|
130
|
-
## Step 1: Scout
|
|
131
|
-
|
|
132
|
-
Understand the affected codebase before forming any hypotheses. Activate
|
|
133
|
-
`cf:scout` or perform an equivalent focused local scout (`rg` plus targeted
|
|
134
|
-
reads) to map the blast radius.
|
|
135
|
-
|
|
136
|
-
| Path | Scout depth |
|
|
137
|
-
|------|-------------|
|
|
138
|
-
| Quick/local | Minimal - project type, affected file(s), direct callers/dependents, related tests, recent commits |
|
|
139
|
-
| Standard and deeper | Full - module boundaries, test coverage, call chains, recent changes, existing patterns |
|
|
140
|
-
| `--parallel` | Per-issue independent scouts, one scope each, only through the Delegation Gate |
|
|
141
|
-
|
|
142
|
-
**Output:** `✓ Step 1: Scouted — [N] files mapped, [M] dependencies, [K] tests found`
|
|
143
|
-
|
|
144
|
-
---
|
|
145
|
-
|
|
146
|
-
## Step 2: Diagnose via `cf:debug`
|
|
147
|
-
|
|
148
|
-
Evidence-based root cause analysis; no guessing. Use `cf:debug`, or validate
|
|
149
|
-
an existing debug report when `--from-debug` is provided. See
|
|
150
|
-
`references/diagnosis-protocol.md` for the Fix-local checklist.
|
|
151
|
-
|
|
152
|
-
Diagnosis chain:
|
|
153
|
-
|
|
154
|
-
1. **Capture pre-fix state:** exact error messages, failing test output, stack traces. This is the baseline for Step 5.
|
|
155
|
-
2. **Observe:** read the actual error; locate where it occurs and when it started (`git log -p`).
|
|
156
|
-
3. **Hypothesize:** form 2-3 hypotheses, each with confirm/refute evidence and a quick test.
|
|
157
|
-
4. **Test:** validate each hypothesis against codebase evidence with focused local reads; test hypotheses in parallel only through the Delegation Gate.
|
|
158
|
-
5. **Trace root cause:** symptom → immediate cause → contributing factor → root cause.
|
|
159
|
-
6. **Escalate:** if 2+ hypotheses fail, apply `references/escalation-tactics.md`.
|
|
160
|
-
|
|
161
|
-
**Exact root-cause contract:**
|
|
162
|
-
- Symptom: exact observable failure
|
|
163
|
-
- Reproduction: command, user flow, CI job, log trigger, or route
|
|
164
|
-
- Expected vs actual behavior
|
|
165
|
-
- Trigger: event or input that activated the failure, or `unknown`
|
|
166
|
-
- Root cause: file:line, config, environment, dependency, or data source
|
|
167
|
-
- Contributing factors: conditions that raised likelihood or impact but are not sufficient causes, or `none evidenced`
|
|
168
|
-
- Why now: recent change, dependency drift, data state, environment, timing, or load
|
|
169
|
-
- Evidence chain: observations proving the cause
|
|
170
|
-
- Blast radius: affected files, modules, tests, users, workflows, or release paths
|
|
171
|
-
|
|
172
|
-
With `--from-debug`, validate the report before accepting it:
|
|
173
|
-
|
|
174
|
-
- the exact root-cause contract above is complete;
|
|
175
|
-
- `Evidence Timeline` is present — a skipped timeline is valid in either producer form (`Timeline: skipped - <reason>` or `- skipped: <reason>`);
|
|
176
|
-
- `Elimination Path` records the decisive observation for each removed or retained candidate;
|
|
177
|
-
- `Recurrence-Prevention Handoff`, when present, carries evidence-backed candidates only.
|
|
178
|
-
|
|
179
|
-
A report missing required fields routes back to diagnosis (`cf:debug`); it
|
|
180
|
-
does not enter implementation.
|
|
181
|
-
|
|
182
|
-
If any contract field is vague or missing file:line/config/env evidence, keep
|
|
183
|
-
diagnosing or ask the user for the specific missing artifact. Do not implement.
|
|
184
|
-
|
|
185
|
-
**Output:** `✓ Step 2: Diagnosed — Root cause: [summary], Evidence: [brief], Scope: [N files]`
|
|
186
|
-
|
|
187
|
-
---
|
|
188
|
-
|
|
189
|
-
## Step 3: Select Depth + Bound Repair
|
|
190
|
-
|
|
191
|
-
Apply the Proportional depth rule above. For 2+ independent issues (or
|
|
192
|
-
`--parallel`), evaluate the Delegation Gate; when it is closed, fix the issues
|
|
193
|
-
sequentially. Track progress with the runtime's task surface when available, or
|
|
194
|
-
a markdown checklist otherwise.
|
|
195
|
-
|
|
196
|
-
For Standard and Incident/deep, complete the bounded repair frame above. Quick
|
|
197
|
-
records no separate frame unless scope or risk is still ambiguous.
|
|
198
|
-
|
|
199
|
-
**Output:** `✓ Step 3: [Depth] selected — [workflow]`
|
|
200
|
-
|
|
201
|
-
---
|
|
202
|
-
|
|
203
|
-
## Step 4: Implement Fix
|
|
204
|
-
|
|
205
|
-
Rules:
|
|
206
|
-
- Fix the root cause, not the symptom. Follow diagnosis findings.
|
|
207
|
-
- Minimal changes only; follow existing code patterns.
|
|
208
|
-
- One logical change per commit boundary.
|
|
209
|
-
|
|
210
|
-
Workflows by depth:
|
|
211
|
-
- **Quick:** apply the minimal fix from completed scout + diagnosis, run the exact pre-fix command plus typecheck/lint immediately, report before/after proof.
|
|
212
|
-
- **Standard:** implement the fix, add or update a regression test that fails without the fix and passes with it, run the relevant suite.
|
|
213
|
-
- **Incident/deep:** after diagnosis, research only unresolved external facts. If
|
|
214
|
-
multiple cause-aligned remedies or an architecture decision remain, use
|
|
215
|
-
`cf:brainstorm` to compare 2-3 options against the bounded repair frame, then
|
|
216
|
-
write a concise staged implementation plan with dependencies and proof per
|
|
217
|
-
stage. When diagnosis leaves one safe direct repair, skip research and
|
|
218
|
-
brainstorm, record why it satisfies the frame, and implement it. Delegated
|
|
219
|
-
research follows the Delegation Gate; implementation starts only after the
|
|
220
|
-
direction is resolved.
|
|
221
|
-
- **Parallel:** one independent issue per agent, each following Steps 1-5, dispatched only through the Delegation Gate; aggregate results on completion.
|
|
222
|
-
|
|
223
|
-
**Output:** `✓ Step 4: Fixed — [N] files changed`
|
|
224
|
-
|
|
225
|
-
---
|
|
226
|
-
|
|
227
|
-
## Step 5: Verify + Prevent
|
|
228
|
-
|
|
229
|
-
1. **Iron-law verification:** run the exact commands from the pre-fix state capture and compare output. No claims without fresh command output from the current run.
|
|
230
|
-
2. **Regression test:** must fail without the fix and pass with it.
|
|
231
|
-
3. **Full check:** typecheck + lint + build + test (see `references/parallel-patterns.md` Pattern C).
|
|
232
|
-
4. **Prevention guard (Standard+):** see `references/prevention-gate.md`; consume the debug report's recurrence candidates when present.
|
|
233
|
-
5. **Side-effect gate:** sweep the full blast radius from Step 2 against the five checks in the gate above.
|
|
234
|
-
6. **Review:** trigger `cf:code-review`; see `references/review-cycle.md`.
|
|
235
|
-
|
|
236
|
-
Verification and review report `PASS | PASS_WITH_WARNINGS | FAIL | BLOCKED`.
|
|
237
|
-
The definition of `PASS` defers to `cf:code-review`. `PASS_WITH_WARNINGS`
|
|
238
|
-
routes through the same remediation or user-pause path as `FAIL` and never
|
|
239
|
-
auto-accepts. `BLOCKED` is terminal for the cycle; resolve the blocker instead
|
|
240
|
-
of retrying. A review-only result is not execution proof; completion claims
|
|
241
|
-
require fresh command output.
|
|
242
|
-
|
|
243
|
-
If verification fails: under 3 attempts, loop back to Step 2 and re-diagnose
|
|
244
|
-
with the new evidence; at 3+ attempts, stop and discuss with the user. Never
|
|
245
|
-
weaken, delete, or mock a failing assertion to obtain green.
|
|
246
|
-
|
|
247
|
-
**Output:** `✓ Step 5: Verified + Prevented — [before/after comparison], [N] tests added`
|
|
248
|
-
|
|
249
|
-
---
|
|
250
|
-
|
|
251
|
-
## Step 6: Finalize
|
|
252
|
-
|
|
253
|
-
1. **Report:** root cause, changes made, files affected, prevention measures, side-effect sweep result, and any remaining limitations.
|
|
254
|
-
2. **Docs update:** if API or behavior changed, update only the affected existing docs through the docs flow.
|
|
255
|
-
3. **Commit:** ask the user before committing; use conventional commits.
|
|
256
|
-
|
|
257
|
-
**Output:** `✓ Step 6: Complete — [action taken]`
|
|
258
|
-
|
|
259
|
-
---
|
|
260
|
-
|
|
261
|
-
## Output Format
|
|
262
|
-
|
|
263
|
-
Unified step markers (emit after each step):
|
|
264
|
-
```
|
|
265
|
-
✓ Step 1: Scouted — [N] files, [M] deps
|
|
266
|
-
✓ Step 2: Diagnosed — Root cause: [summary]
|
|
267
|
-
✓ Step 3: [Depth] selected — [workflow]
|
|
268
|
-
✓ Step 4: Fixed — [N] files changed
|
|
269
|
-
✓ Step 5: Verified + Prevented — [tests added], [guards added]
|
|
270
|
-
✓ Step 6: Complete — [action taken]
|
|
271
|
-
```
|
|
272
|
-
|
|
273
|
-
## Specialized Paths
|
|
274
|
-
|
|
275
|
-
Use `references/workflow-specialized.md` as a progressively disclosed overlay
|
|
276
|
-
after Step 1 scout for CI/CD failures, test suite failures, TypeScript type
|
|
277
|
-
errors, UI/visual issues, and application log errors. Load only the matching
|
|
278
|
-
section. Specialized paths add category-specific evidence and proof; they do
|
|
279
|
-
not replace the six-step flow, weaken diagnosis, or broaden the repair scope.
|
|
280
|
-
|
|
281
|
-
## References
|
|
282
|
-
|
|
283
|
-
Load as needed:
|
|
284
|
-
- `references/diagnosis-protocol.md` — Structured root cause analysis and the exact root-cause contract
|
|
285
|
-
- `references/escalation-tactics.md` — What to do when hypotheses fail (Inversion, Scale Game)
|
|
286
|
-
- `references/prevention-gate.md` — Defense-in-depth validation after fix
|
|
287
|
-
- `references/review-cycle.md` — Review verdict handling and required user-pause conditions
|
|
288
|
-
- `references/parallel-patterns.md` — Delegation Gate patterns for parallel work
|
|
289
|
-
- `references/workflow-specialized.md` — CI/CD, test, TypeScript, UI-specific workflows
|