@haposoft/cafekit 0.15.3 → 0.16.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.
Files changed (90) hide show
  1. package/README.md +4 -2
  2. package/bin/__tests__/codex-hooks.test.js +140 -0
  3. package/bin/__tests__/codex-native.test.js +2 -2
  4. package/bin/__tests__/develop-contract.test.js +1120 -0
  5. package/bin/__tests__/installer-safety.test.js +510 -2
  6. package/bin/__tests__/package-inventory.test.js +258 -0
  7. package/bin/__tests__/secret-scanner.test.js +157 -0
  8. package/bin/__tests__/validator-grounding.test.js +713 -0
  9. package/bin/install.js +5 -1
  10. package/bin/lib/codex-install.js +21 -6
  11. package/bin/lib/context.js +17 -6
  12. package/bin/lib/copy-utils.js +31 -0
  13. package/bin/lib/instruction-blocks.js +85 -0
  14. package/bin/lib/managed-writer.js +4 -1
  15. package/bin/lib/opencode-install.js +75 -30
  16. package/bin/phases/claude-runtime.js +103 -4
  17. package/bin/phases/codex-runtime.js +9 -5
  18. package/bin/phases/post-install.js +29 -22
  19. package/bin/phases/root-config.js +89 -10
  20. package/package.json +14 -4
  21. package/src/claude/CLAUDE.md +6 -122
  22. package/src/claude/agents/code-auditor.md +21 -22
  23. package/src/claude/agents/debugger.md +3 -3
  24. package/src/claude/agents/deployer.md +1 -1
  25. package/src/claude/agents/{god-developer.md → implementer.md} +2 -2
  26. package/src/claude/agents/project-manager.md +1 -1
  27. package/src/claude/agents/spec-maker.md +2 -2
  28. package/src/claude/hooks/__tests__/spec-gate.test.js +356 -5
  29. package/src/claude/hooks/agent.cjs +7 -14
  30. package/src/claude/hooks/rules.cjs +33 -53
  31. package/src/claude/hooks/spec-gate.cjs +66 -21
  32. package/src/claude/hooks/spec-state.cjs +5 -0
  33. package/src/claude/migration-manifest.json +9 -2
  34. package/src/claude/runtime.json +0 -3
  35. package/src/claude/scripts/generate-skill-catalog.cjs +1 -1
  36. package/src/claude/scripts/scan-staged-secrets.cjs +170 -0
  37. package/src/claude/scripts/spec-ground.cjs +189 -83
  38. package/src/claude/scripts/validate-spec-output.cjs +294 -30
  39. package/src/claude/scripts/workflow-policy.cjs +609 -0
  40. package/src/claude/skills/ai-multimodal/SKILL.md +2 -2
  41. package/src/claude/skills/ai-multimodal/references/audio-processing.md +6 -6
  42. package/src/claude/skills/ai-multimodal/references/video-analysis.md +1 -1
  43. package/src/claude/skills/backend-development/SKILL.md +4 -4
  44. package/src/claude/skills/backend-development/references/backend-architecture.md +1 -1
  45. package/src/claude/skills/backend-development/references/backend-devops.md +2 -2
  46. package/src/claude/skills/backend-development/references/backend-mindset.md +3 -3
  47. package/src/claude/skills/backend-development/references/backend-performance.md +5 -5
  48. package/src/claude/skills/backend-development/references/backend-security.md +3 -3
  49. package/src/claude/skills/backend-development/references/backend-technologies.md +5 -5
  50. package/src/claude/skills/backend-development/references/backend-testing.md +2 -2
  51. package/src/claude/skills/brainstorm/SKILL.md +2 -3
  52. package/src/claude/skills/code-review/SKILL.md +12 -8
  53. package/src/claude/skills/code-review/references/verification-gate.md +4 -4
  54. package/src/claude/skills/debug/SKILL.md +2 -0
  55. package/src/claude/skills/develop/SKILL.md +100 -52
  56. package/src/claude/skills/develop/references/parallel-waves.md +105 -26
  57. package/src/claude/skills/develop/references/quality-gate.md +58 -38
  58. package/src/claude/skills/develop/references/subagent-patterns.md +2 -2
  59. package/src/claude/skills/git/SKILL.md +44 -50
  60. package/src/claude/skills/hotfix/SKILL.md +10 -8
  61. package/src/claude/skills/hotfix/references/parallel-patterns.md +2 -2
  62. package/src/claude/skills/hotfix/references/review-cycle.md +26 -21
  63. package/src/claude/skills/inspect/SKILL.md +12 -30
  64. package/src/claude/skills/mobile-development/SKILL.md +12 -12
  65. package/src/claude/skills/mobile-development/references/mobile-android.md +7 -7
  66. package/src/claude/skills/mobile-development/references/mobile-best-practices.md +22 -23
  67. package/src/claude/skills/mobile-development/references/mobile-frameworks.md +13 -13
  68. package/src/claude/skills/mobile-development/references/mobile-ios.md +1 -1
  69. package/src/claude/skills/mobile-development/references/mobile-mindset.md +17 -19
  70. package/src/claude/skills/question/SKILL.md +13 -13
  71. package/src/claude/skills/research/SKILL.md +2 -2
  72. package/src/claude/skills/specs/SKILL.md +32 -15
  73. package/src/claude/skills/specs/references/review.md +3 -3
  74. package/src/claude/skills/specs/rules/tasks-generation.md +1 -1
  75. package/src/claude/skills/specs/templates/spec-state.json +7 -3
  76. package/src/claude/skills/sync/SKILL.md +26 -1
  77. package/src/claude/skills/sync/references/sync-protocols.md +3 -3
  78. package/src/claude/skills/test/SKILL.md +12 -4
  79. package/src/claude/skills/test/references/failure-triage.md +17 -17
  80. package/src/claude/skills/test/references/test-memory.md +2 -2
  81. package/src/codex/AGENTS.md +16 -24
  82. package/src/codex/hooks/lib/spec-receipt.cjs +57 -4
  83. package/src/codex/hooks/rules.cjs +27 -26
  84. package/src/codex/hooks/spec-gate.cjs +19 -8
  85. package/src/codex/hooks/spec-state.cjs +10 -1
  86. package/src/common/AGENTS.md +43 -0
  87. package/src/opencode/AGENTS.md +21 -121
  88. package/src/opencode/plugins/rules.ts +26 -34
  89. package/src/opencode/plugins/spec-gate.ts +283 -0
  90. package/src/claude/skills/inspect/references/external-gemini-inspection.md +0 -169
@@ -15,6 +15,33 @@ live worktree-subagent behavior (spec `develop-parallel-wave`,
15
15
  the standard **sequential fallback**.
16
16
  3. `--parallel N`: **wave cap** = N clamped to 1..5; default 3. Never exceed 5 —
17
17
  each subagent carries a ~200K context budget (orchestrator.md resource rule).
18
+ 4. The destination tree must be clean (`git status --porcelain` is empty) and
19
+ compatible with the selected base before dispatch. Record the destination
20
+ `base_sha` and stop without mutation when cleanliness, repository, or base
21
+ compatibility checks fail.
22
+ 5. Before dispatch, state whether `--parallel` consent authorizes worker commits
23
+ and orchestrator cherry-picks. If that consent is not explicit, obtain the
24
+ separate confirmation before creating worktrees or asking workers to commit.
25
+
26
+ ### Receipt contract (required per wave/task)
27
+
28
+ Every task and wave receipt records these exact fields:
29
+
30
+ ```text
31
+ base_sha: <destination commit before dispatch>
32
+ head_sha: <latest worker/integration commit>
33
+ branch: <worker branch>
34
+ worktree_path: <retained or merged worktree path>
35
+ commit_range: <base_sha>..<head_sha>
36
+ retention: retained|released
37
+ cleanup_authorization: pending|explicit-discard|merged-release
38
+ ```
39
+
40
+ Reviewer and tester commands MUST inspect `git diff <base_sha>..<head_sha>` (or
41
+ `git diff --stat <base_sha>..<head_sha>`), never an ambient working-tree diff.
42
+ Every fix is a new commit: advance `head_sha`, replace `commit_range`, and rerun
43
+ only affected gates plus the wave integration check. A receipt without these
44
+ fields is incomplete.
18
45
 
19
46
  ## 2. Wave planning (normative)
20
47
 
@@ -22,14 +49,25 @@ live worktree-subagent behavior (spec `develop-parallel-wave`,
22
49
  ready(t) = t.status == "pending" AND every dep in task_registry[t].dependencies
23
50
  has status == "done"
24
51
  candidates = ready tasks in task_registry order
25
- wave = first ≤cap candidates, EXCLUDING any task that shares a Create or Modify
26
- path (exact normalized string match over its Related Files table) with an
27
- earlier task already in the wave — the excluded task returns to the pool
52
+ wave = first ≤cap candidates, EXCLUDING any task that conflicts with an
53
+ earlier task already in the wave under the conflict graph below
28
54
  ```
29
55
 
30
- **Single writer per file per wave** is absolute. `Read` rows never conflict.
31
- If the wave is empty but pending tasks remain, dependencies are unsatisfiable in
32
- parallel — finish them with the sequential loop and say so.
56
+ **Conflict graph.** A pair conflicts when either task writes the same exact file,
57
+ one writes a directory another writes, or either touches a shared mutable surface:
58
+ lockfiles, manifests/export barrels, migrations/registries, generated artifacts,
59
+ or shared state writers. `Create`/`Modify`/`Delete` rows are writers; `Read` rows
60
+ are still conflicts when they consume a mutable generated or registry surface.
61
+ Normalize paths before comparison. If overlap is uncertain, classify it as a
62
+ conflict and defer the task to the sequential fallback; never guess that two
63
+ writers are independent.
64
+
65
+ **Single writer per file per wave** remains absolute. Read-only tasks can still
66
+ be deferred when they inspect a directory or shared generated state that a sibling
67
+ writes.
68
+
69
+ If the wave is empty but pending tasks remain, dependencies or conflicts are
70
+ unsatisfiable in parallel — finish them with the sequential loop and say so.
33
71
 
34
72
  ### Worked example
35
73
 
@@ -39,7 +77,7 @@ Registry: A (deps: –), B (deps: –), C (deps: A), D (deps: – but shares
39
77
  - Wave 1 = A, B (D excluded: path collision with B; C excluded: dep on A)
40
78
  - Wave 2 = C, D (A done unblocks C; B done releases D's path)
41
79
 
42
- ## 3. Dispatch (one god-developer per wave task)
80
+ ## 3. Dispatch (one implementer per wave task)
43
81
 
44
82
  Every dispatch uses worktree isolation + background execution and a
45
83
  self-contained prompt per `rules/orchestrator.md` (task file content, design and
@@ -52,16 +90,32 @@ these mandatory lines:
52
90
  4. "When done, `git add` your changes and `git commit -m \"task(<id>): <title>\"` —
53
91
  an uncommitted worktree cannot be merged."
54
92
  5. End with the standard `Status: DONE|CONCERNS|BLOCKED|NEEDS_INFO` block, plus
55
- your worktree path, branch, and commit hash(es).
93
+ the receipt fields from §1, including worktree path, branch, and commit range.
94
+ 6. If a worker fails or blocks, do not remove its worktree or delete its branch.
95
+ Mark `retention: retained` and `cleanup_authorization: pending` until merge
96
+ succeeds or the user gives explicit discard authorization.
56
97
 
57
- The Agent result returns `worktreePath` and `worktreeBranch` — record both per task.
98
+ The orchestrator records `base_sha` immediately before dispatch. The worker's
99
+ first accepted commit becomes `head_sha`; no receipt may use a moving ambient
100
+ HEAD as a substitute. The Agent result returns `worktreePath` and
101
+ `worktreeBranch`; record both in the receipt.
58
102
 
59
103
  ## 4. Quality gate — inside the worktree, before merge
60
104
 
61
105
  Run the unchanged Stage A + Stage B gate (`references/quality-gate.md`) per task
62
- **with the task's worktree as working directory**. Gate evidence from that run
63
- feeds the task receipt. 3 failed rounds → COLLAPSE protocol for that task only;
64
- sibling tasks in the wave keep running.
106
+ **with the task's worktree as working directory**. Before reviewing, tester and
107
+ reviewer commands must inspect the receipt's immutable range:
108
+
109
+ ```bash
110
+ git diff --stat "$BASE_SHA..$HEAD_SHA"
111
+ git diff "$BASE_SHA..$HEAD_SHA"
112
+ ```
113
+
114
+ Do not replace this range with `git diff`, `git status`, or another ambient
115
+ working-tree view. Gate evidence from that run feeds the task receipt. Three
116
+ failed rounds → COLLAPSE protocol for that task only; sibling tasks in the wave
117
+ keep running. Any fix creates a new commit and updates `head_sha`/`commit_range`
118
+ before affected gates rerun.
65
119
 
66
120
  ## 5. Merge protocol (spike-verified — do not improvise)
67
121
 
@@ -69,27 +123,50 @@ sibling tasks in the wave keep running.
69
123
  (`worktree.baseRef: "fresh"` default), NOT the session HEAD. On repos whose origin
70
124
  default diverges, `git merge <agent-branch>` explodes into unrelated conflicts.
71
125
 
72
- Therefore, for each gate-passed task, **sequentially** (one at a time, registry order):
126
+ Therefore, for each gate-passed task, sequentially (one at a time, registry order):
73
127
 
74
128
  ```bash
75
129
  git cherry-pick <agent-commit> # base-agnostic: applies only the agent's diff
76
130
  # conflict? → git cherry-pick --abort
77
131
  # → task_registry[task].status = "blocked", blocker = one-line conflict summary
78
- # → continue with the next passed task
79
- git worktree remove --force .claude/worktrees/agent-<id> # NOT auto-cleaned —
80
- git branch -D worktree-agent-<id> # explicit cleanup, always
132
+ # → retain the worktree/branch; receipt says retention=retained
81
133
  ```
82
134
 
83
- Cleanup runs for unchanged/failed worktrees too (spike: even a read-only run
84
- leaves its worktree and branch behind). Optionally set `worktree.baseRef: "head"`
85
- in settings; cherry-pick remains the recipe regardless.
135
+ A successful merge may release the worktree and branch only after the receipt
136
+ records `head_sha` at the merge result, the new `commit_range`, and
137
+ `cleanup_authorization: merged-release`:
138
+
139
+ ```bash
140
+ git worktree remove .claude/worktrees/agent-<id>
141
+ git branch -d worktree-agent-<id>
142
+ ```
143
+
144
+ Never use `--force` cleanup for failed or blocked work. Retain its identifiable
145
+ worktree and branch for inspect/resume until the merge succeeds or the user
146
+ explicitly authorizes discard; record `cleanup_authorization: explicit-discard`
147
+ when that happens. Optionally set `worktree.baseRef: "head"` in settings;
148
+ cherry-pick remains the recipe regardless.
86
149
 
87
150
  ## 6. Post-merge integration check (per wave)
88
151
 
89
- After the wave's last cherry-pick: run the project build or the affected test
90
- subset (never the full suite mid-flight — that runs once at develop completion).
91
- Failure = fix before computing the next wave. This is the wave gate of
92
- `quality-gate.md`.
152
+ After the wave's last cherry-pick, run an affected integration command derived
153
+ from the task's `## Evidence` and repository contract (build or affected test
154
+ subset; never the full suite mid-flight). Record command, `base_sha`, `head_sha`,
155
+ range, and result in the wave receipt. Failure blocks the next wave.
156
+
157
+ After the final wave, run an explicit feature/full integration command derived
158
+ from the repository contract — for example the feature's exact Evidence suite
159
+ or the repository's documented full test/build command. A final scout is not a
160
+ substitute. Classify every failure before acting as exactly one of:
161
+
162
+ - `baseline` — reproduces from the recorded destination `base_sha`;
163
+ - `environment` — tool, dependency, permission, or service unavailable;
164
+ - `spec` — requirement, acceptance, or evidence contract mismatch;
165
+ - `code` — implementation or integration regression.
166
+
167
+ Do not blind-retry. Fix `code`/`spec` failures with a new commit and affected
168
+ gates; record `baseline`/`environment` blockers and escalate or use the
169
+ sequential fallback according to the task contract.
93
170
 
94
171
  ## 7. State sync — orchestrator is the single writer
95
172
 
@@ -106,7 +183,9 @@ unchanged — a receipt-less done blocks the turn. After syncing the wave, recom
106
183
  |---|---|
107
184
  | Escape hatch on / not a git repo / no isolation | Sequential fallback + stated reason |
108
185
  | Same-wave path collision | Defer the later task to next wave (§2) |
109
- | Gate fails 3× for a task | COLLAPSE for that task; wave continues |
110
- | Cherry-pick conflict | Abort pick; task `blocked` + conflict blocker; wave continues |
111
- | Post-merge check fails | No next wave until fixed |
186
+ | Gate fails 3× for a task | COLLAPSE for that task; retain worktree/branch and receipt; wave continues |
187
+ | Worker failure or blocked task | Retain identifiable worktree/branch; no force-remove; classify and await resume or explicit discard |
188
+ | Cherry-pick conflict | Abort pick; task `blocked` + conflict blocker; retain worktree/branch; wave continues |
189
+ | Post-merge check fails | Classify baseline/environment/spec/code; no next wave until resolved or explicitly blocked |
190
+ | Final integration fails | Record failure class and stop; do not claim completion from a final scout |
112
191
  | Empty wave, tasks pending | Sequential loop for the remainder + notice |
@@ -10,6 +10,28 @@ Green tests are NOT enough. The gate requires four proofs:
10
10
 
11
11
  `--flash` is the explicit fast path. It bypasses this full gate and uses the Flash Gate defined below.
12
12
 
13
+ Executable policy source: `src/claude/scripts/workflow-policy.cjs` (installed as `.claude/scripts/workflow-policy.cjs`). Use its tier delegation, verdict consumer, flash conflict, and promotion semantics; do not duplicate policy in prose or tests.
14
+
15
+ ## Tier input (from develop Delegation policy)
16
+
17
+ Quality-gate input MUST include `execution_tier` and `ship_point`:
18
+
19
+ - **Light:** main session runs verification commands and the same spec-compliance checklist. Spawn zero `test-runner` or `code-auditor` subagents.
20
+ - **Standard:** main session runs tests and spec checks. At the ship point, run exactly one combined `code-auditor` review for spec compliance plus code quality.
21
+ - **Deep / `--parallel`:** retain the documented per-worktree Stage A+B chain in Track A. Do not treat that chain as a permanent product contract.
22
+
23
+ Checklist and FAIL conditions stay identical for every tier; tier changes only who executes each check and when.
24
+
25
+ ## Spec compliance review
26
+
27
+ Stage A applies same spec compliance review checklist for every tier: scope, requirements, completion criteria, evidence, and runtime reachability. A missing or unreachable deliverable is a FAIL.
28
+
29
+
30
+ - **Specific-task mode:** requested task is ship point. Review that task packet and its diff exactly once.
31
+ - **Full-spec Standard:** intermediate tasks receive only the main-session gate. After the final task and Final Integration Scout, run one combined auditor over the cumulative feature diff, all acceptance criteria, and runtime reachability.
32
+ - Do not set feature-level `code_done` or completion before combined auditor returns `PASS`.
33
+ - Auditor `FAIL` maps each finding to its owning task/surface. Fix only affected evidence, then rerun affected checks and the combined review; do not replay unrelated gates already passed.
34
+
13
35
  ## Automation Semantics
14
36
 
15
37
  - If the task names exact commands in `## Evidence` (legacy heading aliases still parse), those exact commands are mandatory and must run before any fallback repo defaults.
@@ -38,6 +60,8 @@ Use this only when `/hapo:develop ... --flash` is present.
38
60
  - `Mode: --flash`
39
61
  - `Tests: skipped by user request`
40
62
  - `Evidence: FLASH_UNVERIFIED`
63
+ - `Status: in_progress`
64
+ - `Blocker: awaiting /hapo:test <feature>`
41
65
  - `Next verification: /hapo:test <feature>`
42
66
 
43
67
  Terminal log:
@@ -65,46 +89,42 @@ START_LOOP:
65
89
  ---------------------------------------------------------------
66
90
  STAGE A: Test + SPEC COMPLIANCE review
67
91
  ---------------------------------------------------------------
68
- → Agent(subagent_type="test-runner",
69
- prompt="Run task-aware verification for the recently implemented code. Read the active task file(s) and execute the exact verification commands named there first, in order. Preflight compile/typecheck/build failures must be reported as PRECHECK_FAIL and take precedence over NO_TESTS. After that, run any additional repo-level typecheck/test/build checks needed for confidence. Inspect named artifacts/runtime outputs and prove runtime reachability from declared entrypoints/callers. For multi-service tasks, verify the flow does not rely on process-local stand-ins masquerading as shared state. Return PASS only if automated checks and task evidence both pass. Mark anything unexecuted as UNVERIFIED. Treat NO_TESTS as non-passing unless the task did not require a dedicated test suite.",
70
- description="Test [feature]")
71
-
72
- → Agent(subagent_type="code-auditor",
73
- prompt="SPEC COMPLIANCE REVIEW ONLY. Do not trust the implementer's report. Read the active task file(s), scope_lock, referenced requirements, design contracts, task-aware scout report, and actual code. Verify line by line that every scoped requirement and completion criterion is implemented, nothing out-of-scope was added, and every runtime-facing artifact is reachable from the declared entrypoint/caller or explicitly deferred to a named later task. Missing deliverables, placeholder-only wiring, orphan components/services, unmounted UI, unregistered routes, uncalled loaders, missing runtime entrypoints, overscope edits outside the task packet, silent replacement of named technologies/contracts, or fake cross-service proof via process-local state are Critical even if build/tests pass. Return SPEC_PASS or SPEC_FAIL, critical count, file:line findings, and evidence gaps.",
74
- description="Spec review [feature]")
75
-
76
- Wait for BOTH to return results.
77
-
78
- CASE 1 — PRECHECK_FAIL OR Automated FAIL OR required command missing OR Evidence FAIL / UNVERIFIED OR Reachability FAIL / SPEC_FAIL OR NO_TESTS when tests were required:
79
- - Increment retry_count++
80
- - If retry_count >= 3:
81
- → COLLAPSE! AskUserQuestion: "Quality gate cannot prove this task is complete! User intervention required!"
82
- - If retry_count < 3:
83
- → Return to Step 3 (god-developer). Fix the failing checks, spec gaps, or missing evidence first.
84
- → GOTO START_LOOP
85
-
86
- CASE 2 — Test PASS + Evidence PASS + SPEC_PASS:
87
- → Proceed to STAGE B code quality review.
92
+ → Light: main session executes exact Evidence commands, spec checklist,
93
+ artifact checks, and reachability checks; spawn 0 subagents.
94
+ → Standard: main session executes exact Evidence commands and spec checklist;
95
+ defer one combined auditor to the ship point.
96
+ → Deep / --parallel: run the documented per-task sequence `inspector → implementer → test-runner → code-auditor` in the
97
+ task worktree, then preserve its documented merge/integration gates.
98
+
99
+ Test result and review result use the review enum only: PASS | FAIL | BLOCKED.
100
+ PASS proceeds. FAIL returns actionable findings to implementer. BLOCKED means
101
+ execution proof, permissions, environment, or a user-owned decision is missing:
102
+ stop immediately and do not blind-retry.
103
+
104
+ Standard specific-task ship point:
105
+ → run exactly one combined code-auditor review after Stage A PASS.
106
+ Standard full-spec ship point:
107
+ → run exactly one combined code-auditor review after the final task and
108
+ Final Integration Scout over the cumulative feature diff.
109
+
110
+ CASE 1 — PRECHECK_FAIL OR Automated FAIL OR required command missing OR Evidence FAIL / UNVERIFIED OR Reachability FAIL:
111
+ - For FAIL: increment retry_count; return to implementation while retry_count < 3.
112
+ - For BLOCKED: stop without retry; record blocker and await resolution.
113
+ - If retry_count >= 3: COLLAPSE and ask for user intervention.
114
+
115
+ CASE 2 — Test PASS + Evidence PASS + spec checklist PASS:
116
+ → Proceed to the ship-point review for Standard, or the Deep Stage B review.
88
117
 
89
118
  STAGE B:
90
119
  ---------------------------------------------------------------
91
120
  CODE QUALITY REVIEW (only after spec compliance passes)
92
121
  ---------------------------------------------------------------
93
- → Agent(subagent_type="code-auditor",
94
- prompt="CODE QUALITY REVIEW. Spec compliance already passed. Review recently written code for security, logic correctness, architecture, YAGNI/KISS/DRY, maintainability, tests, and project conventions. Also re-check that no recent edits broke dependents found by the task-aware scout report. Return score (X/10), critical count, warning list, and concrete file:line findings.",
95
- description="Quality review [feature]")
96
-
97
- CASE 3 — Code quality review FAIL (Score < 9.5 OR Critical > 0):
98
- - Increment retry_count++
99
- - If retry_count >= 3:
100
- → COLLAPSE! AskUserQuestion: "Code does not meet minimum standards! User intervention required!"
101
- - If retry_count < 3:
102
- → Fix each review issue.
103
- → GOTO START_LOOP unless the fix is prose-only and cannot affect evidence; otherwise re-run Stage B.
104
-
105
- CASE 4 — Test PASS + Evidence PASS + SPEC_PASS + Code quality review PASS (Score >= 9.5 AND Critical = 0):
106
- → PASS! Auto-approved.
107
- → PROCEED to completion report with a verification receipt summarizing exact commands executed, artifact/runtime/reachability proof, spec review result, and code quality review result.
122
+ Standard uses the combined auditor described above; Deep retains the existing
123
+ Stage B quality review chain inside each worktree.
124
+ → PASS = no Critical, no High, at most one Medium; proceed to sync.
125
+ → FAIL = findings mapped to task/surface; fix affected scope and rerun only
126
+ affected evidence plus this combined review.
127
+ → BLOCKED = missing proof/permission/environment/user decision; stop, no blind retry.
108
128
  ```
109
129
 
110
130
  ## Critical Issue Definitions
@@ -124,10 +144,10 @@ STAGE B:
124
144
 
125
145
  Must log the Quality Gate result to the terminal for user visibility:
126
146
 
127
- - **Quick Pass:** `✓ Step 4 Quality Gate: Test PASS + Evidence PASS + Spec PASS + Review 9.5/10 - Auto-Approved`
128
- - **Hard-Won Pass:** `✓ Step 4 Quality Gate: Failed 2 rounds → Test PASS + Evidence PASS + Spec PASS + Review 9.6/10`
147
+ - **Quick Pass:** `✓ Step 4 Quality Gate: Test PASS + Evidence PASS + Spec PASS + Review PASS (no Critical, no High, at most one Medium) - Auto-Approved`
148
+ - **Hard-Won Pass:** `✓ Step 4 Quality Gate: Failed 2 rounds → Test PASS + Evidence PASS + Spec PASS + Review PASS (no Critical, no High, at most one Medium)`
129
149
  - **Preflight Fail:** `[x] Step 4 Quality Gate: PRECHECK_FAIL → compile/typecheck/build failed before tests mattered`
130
- - **Fix Needed:** `[~] Step 4 Quality Gate: Tests/spec/evidence failed → returned to god-developer`
150
+ - **Fix Needed:** `[~] Step 4 Quality Gate: Tests/spec/evidence failed → returned to implementer`
131
151
  - **Awaiting Rescue:** `[!] Step 4 Quality Gate: Failed 3 rounds! Awaiting user intervention...`
132
152
 
133
153
  ## Working directory (parallel mode)
@@ -15,7 +15,7 @@ Agent(subagent_type="inspector", prompt="Scan and identify all files related to
15
15
 
16
16
  ## Code Implementation Phase
17
17
  ```
18
- Agent(subagent_type="god-developer", prompt="Implement the sub-tasks from [tasks-directory] based on the specification in [spec.json]", description="Code Feature [feature]")
18
+ Agent(subagent_type="implementer", prompt="Implement the sub-tasks from [tasks-directory] based on the specification in [spec.json]", description="Code Feature [feature]")
19
19
  ```
20
20
 
21
21
  ## UI Implementation Phase
@@ -25,7 +25,7 @@ Agent(subagent_type="ui-ux-designer", prompt="Implement the frontend code for [f
25
25
 
26
26
  ## Code Review Phase
27
27
  ```
28
- Agent(subagent_type="code-auditor", prompt="Review all recently written code. Check for security holes, performance issues, and adherence to YAGNI/KISS/DRY. Return score (X/10), list of critical issues, warnings, and suggestions.", description="Review [phase]")
28
+ Agent(subagent_type="code-auditor", prompt="Review all recently written code. Check for security holes, performance issues, and adherence to YAGNI/KISS/DRY. Return a verdict (PASS = no Critical, no High, at most one Medium), severity-classified findings, and concrete suggestions.", description="Review [phase]")
29
29
  ```
30
30
 
31
31
  ## Test Execution Phase
@@ -8,59 +8,53 @@ keywords: [git, commits, pr, worktree]
8
8
  argument-hint: "commit | push | pr | finish | worktree <feature-desc>"
9
9
  metadata:
10
10
  author: haposoft
11
- version: "1.0.0"
11
+ version: "1.1.0"
12
12
  ---
13
13
  # Git Operations & Worktree
14
14
 
15
- This skill merges Version Control Systems (VSC) capabilities and parallel Worktree management into a single, clean-room execution engine utilizing pure Bash commands rather than proprietary Node scripts.
15
+ Git operations and worktree management using plain `git` commands.
16
16
 
17
- **Mantra:** Secure, Conventional, and Isolated.
17
+ ## Default (no arguments)
18
+ Present options via AskUserQuestion — header "Git Operation": commit / push / pr / finish / worktree.
18
19
 
19
20
  ## Commands
20
-
21
- ### 1. Version Control Engine
22
- - **`commit`**: Scan secrets, analyze diff, auto-split chunks into conventional commits.
23
- - **`push`**: Securely push to the current branch.
24
- - **`pr`**: Propose merging current feature into `develop` or `main`.
25
- - **`finish`**: Verify current branch/worktree, then present explicit finish options.
26
-
27
- ### 2. Worktree Engine (Safe Parallel Development)
28
- - **`worktree <feature-description>`**: Creates a sibling directory alongside the current repo to isolate dependencies and database contexts without dirtying the main worktree.
29
-
30
- ## Core Directives
31
-
32
- ### 1. Native Bash Execution Only
33
- - DO NOT rely on external JS/CJS scripts to evaluate git. Use pure system `git` CLI logic in bash.
34
- - Always check the status first: `git status && git diff --cached --stat`
35
-
36
- ### 2. Pre-Commit Security Audit
37
- - Always run secret detection before creating a commit:
38
- ```bash
39
- git diff --cached | grep -iE "(api[_-]?key|token|password|secret|credential)"
40
- ```
41
- - If a secret is matched: **HALT!** Refuse to commit. Demand the user add the file to `.gitignore` and run `git rm --cached <file>`.
42
-
43
- ### 3. Smart Worktree Strategy
44
- - Never run branching logic within the same root if the task requires heavy, isolated setup.
45
- - Worktrees MUST be created as *sibling directories*: `../<project-name>-<feature-branch>`.
46
-
47
- ### 4. Finish Branch Protocol
48
- - Before merge, push, PR, or discard, run a fresh status and verification check:
49
- ```bash
50
- git status --short
51
- git branch --show-current
52
- ```
53
- - If uncommitted changes exist, route through `commit` or ask whether to keep them unstaged.
54
- - Present explicit finish options:
55
- 1. Merge locally into the target branch.
56
- 2. Push current branch and open/update a PR.
57
- 3. Keep the branch/worktree for later.
58
- 4. Discard branch/worktree only after typed confirmation.
59
- - Never force-push or delete worktrees without explicit user confirmation.
60
- - If running inside a git worktree, detect it with `git worktree list` and clean up only the worktree created for this task.
61
-
62
- ## References & Protocols
63
-
64
- - `references/commit-protocols.md`: Strict rules for analyzing Git Diffs and determining commit splitting behavior.
65
- - `references/finish-branch.md`: Finish branch / PR / worktree closeout protocol.
66
- - `references/worktree-blueprint.md`: The 4-step Bash process to accurately construct an out-of-bounds Git Worktree Environment.
21
+ - `commit`: run installed secret scanner → analyze diff → split into conventional commits.
22
+ - `push`: push current branch.
23
+ - `pr`: push + open PR. Target = repo's integration branch — detect via
24
+ `gh repo view --json defaultBranchRef` or `origin/HEAD`; never assume `main`/`develop`.
25
+ - `finish`: fresh `git status` + verification, then present exactly 4 options:
26
+ merge locally / push + PR / keep branch-worktree / discard (typed confirmation).
27
+ - `worktree <desc>`: sibling dir `../<project>-<branch>` for isolated setup.
28
+
29
+ ## Secret scan (before every commit)
30
+ ```bash
31
+ node .claude/scripts/scan-staged-secrets.cjs
32
+ ```
33
+ The helper parses `git diff --cached --unified=0 --no-color --diff-filter=ACMR`, checks added lines only, maps hunks to source lines, and prints only file, line, and identifier. It never prints secret values or context.
34
+
35
+ Match → STOP. For an untracked secret, add an appropriate `.gitignore` rule. For a tracked secret, stop, rotate it, and ask the user before changing history or index state.
36
+
37
+ ## Split rules
38
+ Split when: mixed types (feat+fix), mixed scopes, config/deps mixed with code, >10 unrelated files.
39
+ Single commit when: same type+scope, ≤3 files, ≤50 lines.
40
+
41
+ ## Output
42
+ ```
43
+ ✓ staged: N files (+X/-Y)
44
+ ✓ secrets: none
45
+ ✓ commit: <hash> type(scope): description
46
+ ✓ pushed: yes|no
47
+ ```
48
+
49
+ ## Errors
50
+ | Error | Action |
51
+ |---|---|
52
+ | Secrets matched | Block; report only file/source line/identifier. Never show secret value, diff line, or surrounding context. |
53
+ | Nothing staged | Exit cleanly |
54
+ | Push rejected | Suggest `git pull --rebase` |
55
+ | Conflicts | List files; never auto-resolve |
56
+
57
+ Never force-push or delete a worktree without explicit confirmation.
58
+
59
+ ## References
60
+ - `references/commit-protocols.md` · `references/finish-branch.md` · `references/worktree-blueprint.md`
@@ -17,7 +17,7 @@ Kill bugs systematically. No guessing. Evidence first, fix second.
17
17
  ## Arguments
18
18
 
19
19
  - `--quick` - Reduced-depth path for trivial issues (lint, type errors, syntax); still scout-first
20
- - `--parallel` - Spawn multiple `god-developer` agents for independent issues
20
+ - `--parallel` - Spawn multiple `implementer` agents for independent issues
21
21
  - `--from-debug` - Start from an existing `hapo:debug` report and validate its root-cause contract
22
22
 
23
23
  Default: deterministic scout-first hotfix. There is no initial mode selection step.
@@ -26,6 +26,8 @@ Default: deterministic scout-first hotfix. There is no initial mode selection st
26
26
  Do NOT propose or implement fixes before completing Steps 1-2 (Scout + `hapo:debug` diagnosis).
27
27
  Symptom fixes are FAILURE. Find the root cause first.
28
28
  The exact root-cause contract is mandatory: symptom, reproduction, expected/actual, root cause file:line or config/env source, why now, evidence chain, blast radius.
29
+ Answer each item in one concrete sentence.
30
+ If any answer contains 'probably', 'I think', 'something with', or 'maybe' — it is not an answer; gather evidence instead.
29
31
  The side-effect gate is mandatory before completion.
30
32
  If 3+ fix attempts fail → STOP. Question the architecture. Discuss with user.
31
33
  Exception: `--quick` mode only abbreviates depth; it never skips scout, pre-fix evidence, diagnosis, or before/after verification.
@@ -51,10 +53,10 @@ The fix is not done until Step 5 proves:
51
53
  5. Public contracts are unchanged unless intentionally called out: function signatures, exported types, response shapes, DB schemas, env vars.
52
54
 
53
55
  If verification reveals a side effect or regression, STOP and present 2-4 concrete options to the user:
54
- - Revert this fix and try a different root-cause angle.
55
- - Narrow the fix scope to remove the regression.
56
- - Keep the fix and update named dependent files/contracts.
57
- - Accept the behavior change intentionally.
56
+ - Revert this fix and try a different root-cause angle
57
+ - Keep the fix and update <dependent files> to match the new contract
58
+ - Narrow the fix to <subset> so the regression disappears
59
+ - Accept the change — the old behavior was itself a bug
58
60
  Do not silently patch around the regression.
59
61
  </HARD-GATE-NO-SIDE-EFFECTS>
60
62
 
@@ -166,7 +168,7 @@ If any field is vague (`probably`, `maybe`, `I think`, or missing file:line/conf
166
168
  | **Trivial** | Single file, clear error, type/lint/syntax | Quick: straight to fix |
167
169
  | **Standard** | Multi-file, root cause identified via diagnosis | Standard: fix + regression test |
168
170
  | **Complex** | System-wide, architecture impact, unclear boundaries | Deep: research + plan + fix |
169
- | **Parallel** | 2+ independent issues OR `--parallel` flag | Spawn `god-developer` agents per issue |
171
+ | **Parallel** | 2+ independent issues OR `--parallel` flag | Spawn `implementer` agents per issue |
170
172
 
171
173
  **Task Orchestration (Standard+ only):**
172
174
  - Use `TaskCreate` with dependencies to track fix phases
@@ -203,7 +205,7 @@ If any field is vague (`probably`, `maybe`, `I think`, or missing file:line/conf
203
205
 
204
206
  ### Parallel Workflow
205
207
  1. Create separate `TaskCreate` per independent issue
206
- 2. Spawn `god-developer` subagents — one per issue
208
+ 2. Spawn `implementer` subagents — one per issue
207
209
  3. Each agent follows Steps 1-5 independently
208
210
  4. Aggregate results upon completion
209
211
 
@@ -274,7 +276,7 @@ Unified step markers (emit after each step):
274
276
  | `hapo:code-review` | After fix, quality check (Step 5) |
275
277
  | `git-ops` | Commit changes (Step 6) |
276
278
  | `docs-keeper` | Update docs if behavior changed (Step 6) |
277
- | `god-developer` | Parallel independent issues (each gets own agent) |
279
+ | `implementer` | Parallel independent issues (each gets own agent) |
278
280
 
279
281
  ## Specialized Paths
280
282
 
@@ -9,7 +9,7 @@ How to effectively leverage multiple subagents (the `Agent` tool) and native tas
9
9
  | Searching for root cause across 3+ directories | Parallel scout | `Explore` × 2-3 |
10
10
  | Testing 2-3 diagnostic hypotheses simultaneously | Parallel hypothesis test | `Explore` × 2-3 |
11
11
  | Verifying fix (typecheck + lint + build + test) | Parallel verification | `Bash` × 3-4 |
12
- | Fixing 2+ independent bugs in one session | Parallel issue trees | `god-developer` × N |
12
+ | Fixing 2+ independent bugs in one session | Parallel issue trees | `implementer` × N |
13
13
  | Deep workflow: scout + diagnose + research together | Parallel investigation | Mixed |
14
14
 
15
15
  ## Pattern A: Parallel Scouting
@@ -71,7 +71,7 @@ B4 = TaskCreate(subject="[Auth] Verify + test", addBlockedBy=[B3])
71
71
  TaskCreate(subject="Integration verification", addBlockedBy=[A4, B4])
72
72
  ```
73
73
 
74
- Spawn one `god-developer` agent per issue tree. Each agent claims tasks via `TaskUpdate(status="in_progress")` and completes via `TaskUpdate(status="completed")`.
74
+ Spawn one `implementer` agent per issue tree. Each agent claims tasks via `TaskUpdate(status="in_progress")` and completes via `TaskUpdate(status="completed")`.
75
75
 
76
76
  ## Pattern E: Deep Workflow — Parallel Investigation Phase
77
77
 
@@ -4,53 +4,58 @@ How to handle code review results after a fix is implemented. Ensures quality wi
4
4
 
5
5
  ## Default Review Handling
6
6
 
7
- The agent reviews its own fix using `hapo:code-review` and decides automatically:
7
+ The agent reviews its own fix using `hapo:code-review` and decides automatically. Every review returns exactly one verdict: `PASS | FAIL | BLOCKED`.
8
8
 
9
9
  ```
10
10
  attempt = 0
11
11
  LOOP:
12
- 1. Trigger hapo:code-review → receives: score, critical_issues[], warnings[]
12
+ 1. Trigger hapo:code-review → receives: verdict and severity-classified findings
13
13
 
14
14
  2. Evaluate:
15
- IF score >= 9.0 AND len(critical_issues) == 0:
16
- → ACCEPT. Log: "✓ Review [score]/10 — auto-approved"
15
+ IF verdict == PASS (no Critical, no High, at most one Medium):
16
+ → ACCEPT. Log: "✓ Review PASS — auto-approved"
17
17
  → Proceed to Step 6 (Finalize)
18
18
 
19
- ELSE IF len(critical_issues) > 0 AND attempt < 3:
20
- → AUTO-REMEDIATE critical issues only
19
+ ELSE IF verdict == BLOCKED:
20
+ → TERMINAL STOP. Do not blind-retry.
21
+ → Present the blocker and required execution proof, permission, environment,
22
+ or user-owned decision to the user.
23
+
24
+ ELSE IF verdict == FAIL AND attempt < 3:
25
+ → AUTO-REMEDIATE the reported findings
21
26
  → Re-run verification (typecheck + lint + test)
22
27
  → attempt += 1
23
28
  → GOTO LOOP
24
29
 
25
- ELSE IF attempt >= 3:
30
+ ELSE IF verdict == FAIL AND attempt >= 3:
26
31
  → HALT. Present findings to user:
27
- "3 auto-fix cycles exhausted. [N] critical issues remain."
32
+ "3 auto-fix cycles exhausted. [N] blocking findings remain."
28
33
  Options: "Fix manually" | "Approve with known issues" | "Abort"
29
-
30
- ELSE (score < 9.0, zero critical):
31
- → ACCEPT with advisory. Log: "✓ Review [score]/10 — approved, [N] warnings noted"
32
- → Proceed to Step 6
33
34
  ```
34
35
 
36
+ `BLOCKED` is terminal for this review cycle. Only `FAIL` may enter remediation retry; never retry a blocked review unchanged.
37
+
35
38
  ## Required User Pause
36
39
 
37
40
  When the fix touches production-critical code, changes public contracts, introduces a behavior change, or the user explicitly requests review control:
38
41
 
39
- 1. Run `hapo:code-review` → collect score + findings
42
+ 1. Run `hapo:code-review` → collect verdict + severity findings
40
43
  2. Present a structured summary to user:
41
44
  ```
42
45
  ┌──────────────────────────────────┐
43
- │ Review Score: [X]/10 │
46
+ │ Review Verdict: [PASS | FAIL | BLOCKED] │
44
47
  ├──────────────────────────────────┤
45
- │ Critical: [list or "none"] │
46
- │ Warnings: [list or "none"] │
47
- │ Suggestions: [list or "none"] │
48
+ │ Critical: [list or "none"] │
49
+ │ High: [list or "none"] │
50
+ │ Medium: [list or "none"] │
51
+ │ Low: [list or "none"] │
48
52
  └──────────────────────────────────┘
49
53
  ```
50
54
  3. Ask user for direction:
51
- - If critical issues exist → "Fix critical" | "Fix all" | "Approve anyway" | "Abort"
52
- - If no critical issues → "Approve" | "Address warnings" | "Abort"
53
- 4. Execute user's choice. Max 3 remediation cycles.
55
+ - If verdict is `BLOCKED` → resolve the blocker; do not retry this review cycle unchanged.
56
+ - If verdict is `FAIL` with Critical or High findings → "Fix blocking findings" | "Fix all" | "Approve anyway" | "Abort"
57
+ - If verdict is `FAIL` with only Medium/Low findings → "Approve" | "Address findings" | "Abort"
58
+ 4. Execute user's choice. Max 3 remediation cycles for `FAIL`; `BLOCKED` never enters this retry limit.
54
59
 
55
60
  ## When To Pause vs Continue
56
61
 
@@ -64,7 +69,7 @@ When the fix touches production-critical code, changes public contracts, introdu
64
69
 
65
70
  ## Blocking Issues (Never Auto-Approve)
66
71
 
67
- Regardless of score, always flag and pause for these:
72
+ Regardless of verdict, always flag and pause for these:
68
73
  - Injection vulnerabilities (SQL, XSS, command injection)
69
74
  - Authentication/authorization bypasses
70
75
  - Unbounded resource consumption (∞ loops, uncontrolled allocations)