@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
|
@@ -70,11 +70,3 @@ After the final wave, run feature integration and reachability proof. The contro
|
|
|
70
70
|
then writes inline Receipts and Status one task at a time. Worker reports and range
|
|
71
71
|
metadata are inputs, not completion authority; incomplete workers cannot be hidden
|
|
72
72
|
by successful siblings.
|
|
73
|
-
|
|
74
|
-
## Legacy workflow compatibility
|
|
75
|
-
|
|
76
|
-
For an existing `spec.json` feature, readiness and dependencies come from the
|
|
77
|
-
persisted `task_registry` and typed `coordination.boundaries`. Workers still do
|
|
78
|
-
not edit that state. The controller writes the legacy separate task receipt,
|
|
79
|
-
synchronizes registry plus nested task Markdown, and creates the required final
|
|
80
|
-
feature receipt only after integrated proof.
|
|
@@ -26,7 +26,10 @@ Before completion, verify:
|
|
|
26
26
|
4. negative/failure behavior named by Acceptance;
|
|
27
27
|
5. artifact bytes and SHA-256 when the task declares an artifact;
|
|
28
28
|
6. an inline `## Receipt` with `Verification: PASS`, exact `Command`, `Exit: 0`,
|
|
29
|
-
runtime-bound Base/Head, and non-empty fenced command output;
|
|
29
|
+
runtime-bound Base/Head, and non-empty fenced command output; take Base and Head
|
|
30
|
+
from the `Base` and `Head` fields printed by
|
|
31
|
+
`node .claude/scripts/provenance.cjs --project-root . --specs-root specs --spec-file <task file> --feature-name <feature> --session <any label> --json`,
|
|
32
|
+
run after the last change outside the specs root, and never type, abbreviate, or compute them by hand;
|
|
30
33
|
7. correctness/security/scope review at the required depth.
|
|
31
34
|
|
|
32
35
|
`PRECHECK_FAIL` outranks no-tests. Missing, pending, placeholder, contradictory,
|
|
@@ -74,19 +77,25 @@ manufacture a green result.
|
|
|
74
77
|
|
|
75
78
|
## Final-Head fixed point
|
|
76
79
|
|
|
77
|
-
Before
|
|
80
|
+
Before GATE-DONE, repeat within the same three-round repair cap:
|
|
78
81
|
|
|
79
82
|
1. Capture runtime Head and list every `done` task whose Receipt is stale or
|
|
80
83
|
bound to a different Head.
|
|
81
84
|
2. Run each stale task's exact proof freshly and let only the controller replace
|
|
82
|
-
its inline Receipt.
|
|
85
|
+
its inline Receipt. A Receipt that declares artifacts with `sha256` may instead be
|
|
86
|
+
rebound to the current Head once every declared hash is recomputed and matches, and only
|
|
87
|
+
when no file the proof reads changed between its recorded Head and the current one and
|
|
88
|
+
every claim in the Receipt is derived from those artifacts; matching bytes prove the
|
|
89
|
+
artifacts did not move, not that the proof would still produce them. Otherwise, and for a
|
|
90
|
+
Receipt with no artifact, re-run; only the controller rebinds.
|
|
91
|
+
If proof changes any non-Specs byte, stop as BLOCKED;
|
|
83
92
|
remediation must settle those bytes before proof can bind them.
|
|
84
93
|
3. Capture runtime Head again and rescan all `done` Receipts.
|
|
85
94
|
|
|
86
95
|
Stop only when consecutive Head captures are identical and every `done` Receipt
|
|
87
96
|
names that current Head. A single pass, remembered result, copied Receipt, or
|
|
88
97
|
proof promoted from another level is not a fixed point. If Head keeps moving or
|
|
89
|
-
the repair cap is reached, report the blocker instead of opening
|
|
98
|
+
the repair cap is reached, report the blocker instead of opening GATE-DONE.
|
|
90
99
|
|
|
91
100
|
## Flash gate
|
|
92
101
|
|
|
@@ -106,16 +115,9 @@ report production readiness. Only a later explicit non-Flash invocation may
|
|
|
106
115
|
recover it: discard Flash output as canonical evidence, inspect current bytes
|
|
107
116
|
and the owned diff, and run fresh proof under the same sync-finalize contract.
|
|
108
117
|
|
|
109
|
-
## Docs impact and
|
|
118
|
+
## Docs impact and GATE-DONE
|
|
110
119
|
|
|
111
120
|
After proof and review, classify docs impact as `none`, `minor`, or `major`.
|
|
112
121
|
Update only affected existing docs when impact is not none. Show the user the
|
|
113
|
-
current command evidence and limitations at
|
|
122
|
+
current command evidence and limitations at GATE-DONE; do not infer approval from a
|
|
114
123
|
receipt.
|
|
115
|
-
|
|
116
|
-
## Legacy workflow compatibility
|
|
117
|
-
|
|
118
|
-
Existing kernel packets keep their separate `receipts/<task-basename>.md`, task
|
|
119
|
-
identity/path metadata, final `feature-receipt.md`, persisted independent-audit
|
|
120
|
-
obligations, and completion-authority checks. The same proof/review ownership
|
|
121
|
-
applies. Do not copy that storage shape into a flat process-first task.
|
|
@@ -50,9 +50,3 @@ After interruption, preserve the owned diff but discard ephemeral handoffs and
|
|
|
50
50
|
remembered proof. Do not tell an implementation worker to repeat a non-idempotent
|
|
51
51
|
action blindly; scope the resumed brief to unmet Acceptance and require fresh
|
|
52
52
|
verification. Concurrent invocations remain unsupported, so drift blocks handoff.
|
|
53
|
-
|
|
54
|
-
## Legacy workflow compatibility
|
|
55
|
-
|
|
56
|
-
When the selected packet is legacy, include its persisted lane snapshot and
|
|
57
|
-
obligations in the dispatch, but do not let workers edit that state or infer an
|
|
58
|
-
independent result from a role label.
|
|
@@ -125,7 +125,7 @@ Create the standard project docs set from the current source code.
|
|
|
125
125
|
Use when:
|
|
126
126
|
- the repository has code but no useful docs
|
|
127
127
|
- the user asks to create project docs
|
|
128
|
-
-
|
|
128
|
+
- `echo '{}' | node .claude/hooks/docs-sync.cjs` reports missing documentation
|
|
129
129
|
|
|
130
130
|
Load:
|
|
131
131
|
- `references/standard-docs-workflow.md`
|
|
@@ -138,7 +138,7 @@ Refresh existing docs after code changes.
|
|
|
138
138
|
Use when:
|
|
139
139
|
- docs exist and source code changed
|
|
140
140
|
- the user asks to update or refresh docs
|
|
141
|
-
- docs-sync reports stale docs
|
|
141
|
+
- `echo '{}' | node .claude/hooks/docs-sync.cjs` reports stale docs
|
|
142
142
|
|
|
143
143
|
Load:
|
|
144
144
|
- `references/standard-docs-workflow.md`
|
|
@@ -24,7 +24,7 @@ Refresh existing living docs after code or project-state changes without rewriti
|
|
|
24
24
|
4. Identify update focus:
|
|
25
25
|
- user-named module or doc
|
|
26
26
|
- recent source diff
|
|
27
|
-
- docs-sync stale hash signal
|
|
27
|
+
- docs-sync stale hash signal (run `echo '{}' | node .claude/hooks/docs-sync.cjs` from the project root)
|
|
28
28
|
- a full docs refresh only when user asks for it
|
|
29
29
|
|
|
30
30
|
### Phase 1: Source Change Scout
|
|
@@ -0,0 +1,153 @@
|
|
|
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 side effects. Evidence first, fix second.
|
|
16
|
+
|
|
17
|
+
## Arguments
|
|
18
|
+
|
|
19
|
+
- `--quick` - Reduced-depth path for trivial issues (lint, type errors, syntax); still scout-first
|
|
20
|
+
- `--parallel` - Fix independent issues concurrently, only through the Delegation Gate below
|
|
21
|
+
- `--from-debug` - Start from an existing `cf:debug` report and validate its contract before accepting it
|
|
22
|
+
|
|
23
|
+
Default: deterministic scout-first fix. There is no initial mode selection step.
|
|
24
|
+
|
|
25
|
+
## Proportional depth
|
|
26
|
+
|
|
27
|
+
Choose the smallest adequate depth from the diagnosed evidence. Depth vocabulary follows `cf:debug`:
|
|
28
|
+
|
|
29
|
+
- **Quick/local:** one deterministic syntax, lint, type, or isolated-test failure with obvious local scope. Quick mode only reduces depth; it never skips scout, pre-fix evidence, diagnosis, or before/after verification.
|
|
30
|
+
- **Standard:** a diagnosed root cause inside one bounded area. Fix plus a regression test seen failing on the unchanged code before the fix (`HARD-GATE-RED-BEFORE-FIX`) and passing after it.
|
|
31
|
+
- **Incident/deep:** production impact, multiple components, intermittent behavior, data/security risk, or concurrency. Consume the full Incident/deep debug handoff (timeline, elimination path, recurrence candidates), implement in stages, and verify each stage.
|
|
32
|
+
|
|
33
|
+
Depth changes evidence breadth, never the gates: scout, diagnosis, before/after proof, and the side-effect gate apply at every depth.
|
|
34
|
+
|
|
35
|
+
## Bounded repair frame
|
|
36
|
+
|
|
37
|
+
Quick/local does not add a separate framing ceremony when the issue and diagnosis already establish the repaired behavior and proof. For Standard or Incident/deep, or whenever scope or risk remains ambiguous after diagnosis, record four short fields before choosing an implementation:
|
|
38
|
+
|
|
39
|
+
- **Outcome:** the observable repaired behavior.
|
|
40
|
+
- **Constraints:** compatibility, safety, ownership, rollout, and time boundaries.
|
|
41
|
+
- **Non-goals:** adjacent behavior the repair must not absorb.
|
|
42
|
+
- **Acceptance:** the exact reproduction plus broader evidence that proves completion.
|
|
43
|
+
|
|
44
|
+
Derive repository-owned facts from scout and diagnosis. Ask the user only for a missing user-owned decision that could materially change the repair. This frame does not select a solution, widen the issue into feature work, or run before the root cause is proven.
|
|
45
|
+
|
|
46
|
+
<HARD-GATE>
|
|
47
|
+
Do not propose or implement a fix before scout and diagnosis complete.
|
|
48
|
+
A symptom patch without a diagnosed root cause is a failed fix.
|
|
49
|
+
The exact root-cause contract under Diagnosis is mandatory; answer each field in one concrete sentence.
|
|
50
|
+
An answer containing 'probably', 'I think', 'something with', or 'maybe' is not an answer; gather evidence instead.
|
|
51
|
+
If 3+ fix attempts fail, stop, question the architecture, and discuss with the user.
|
|
52
|
+
</HARD-GATE>
|
|
53
|
+
|
|
54
|
+
<HARD-GATE-SCOUT-FIRST>
|
|
55
|
+
Fix always scouts before asking broad clarification questions, forming hypotheses, or changing files.
|
|
56
|
+
Collect these scout outputs first: the project type, language(s), framework(s), and package/test runner from repo files; the exact file(s) where the symptom surfaces and their direct callers/dependents; related tests covering the affected area; recent commits touching affected files (`git log --oneline -10 -- <affected-files>`); and existing patterns/conventions for this kind of fix.
|
|
57
|
+
Then state a concise 3-6 bullet codebase-context summary before diagnosis.
|
|
58
|
+
Do not ask generic questions before this step unless there is no repo, no error text, and no observable artifact to inspect.
|
|
59
|
+
</HARD-GATE-SCOUT-FIRST>
|
|
60
|
+
|
|
61
|
+
<HARD-GATE-RED-BEFORE-FIX>
|
|
62
|
+
Before the first change to any non-test file (an edit, a file write, or a shell command that rewrites it), run a test that fails on the unchanged code for the diagnosed reason, and keep its exact command and failing output for verification.
|
|
63
|
+
For a lint, type, syntax, or build failure, the exact failing check run on the unchanged code stands in for the test.
|
|
64
|
+
When no existing test fails for that reason, write or update the regression test first, then run it and see it fail.
|
|
65
|
+
Red shown after the fact does not count: stashing, checking out, reverting, or editing the fix away to make the test fail is not pre-fix evidence.
|
|
66
|
+
If no automated test or check can reproduce the failure, say so and keep the exact manual reproduction and its observed output instead.
|
|
67
|
+
This applies at every depth.
|
|
68
|
+
</HARD-GATE-RED-BEFORE-FIX>
|
|
69
|
+
|
|
70
|
+
<HARD-GATE-NO-SIDE-EFFECTS>
|
|
71
|
+
The fix is not done until verification proves:
|
|
72
|
+
1. The original symptom no longer reproduces with the exact pre-fix command/user flow.
|
|
73
|
+
2. Modified files and transitively affected modules still pass relevant tests.
|
|
74
|
+
3. Blast-radius workflows have no business-logic regression.
|
|
75
|
+
4. No new lint/type/build errors were introduced.
|
|
76
|
+
5. Public contracts are unchanged unless intentionally called out: function signatures, exported types, response shapes, DB schemas, env vars.
|
|
77
|
+
|
|
78
|
+
If verification reveals a side effect or regression, stop and present 2-4 concrete options to the user:
|
|
79
|
+
- Revert this fix and try a different root-cause angle
|
|
80
|
+
- Keep the fix and update <dependent files> to match the new contract
|
|
81
|
+
- Narrow the fix to <subset> so the regression disappears
|
|
82
|
+
- Accept the change — the old behavior was itself a bug
|
|
83
|
+
Do not silently patch around the regression.
|
|
84
|
+
</HARD-GATE-NO-SIDE-EFFECTS>
|
|
85
|
+
|
|
86
|
+
## Delegation Gate
|
|
87
|
+
|
|
88
|
+
Dispatch subagents (parallel scouts, hypothesis tests, deep research, or
|
|
89
|
+
`--parallel` fix trees) only when all three conditions hold:
|
|
90
|
+
|
|
91
|
+
- The user explicitly requested or permitted delegation or parallel agents.
|
|
92
|
+
- The active runtime exposes an Explore/delegation capability.
|
|
93
|
+
- The work splits into at least two distinct, non-overlapping scopes with useful independent work.
|
|
94
|
+
|
|
95
|
+
Otherwise continue sequentially in the main agent with focused local evidence.
|
|
96
|
+
Task-tracking tools are an optional visibility fallback, never a required step;
|
|
97
|
+
a concise markdown checklist is always sufficient.
|
|
98
|
+
|
|
99
|
+
## Standards
|
|
100
|
+
|
|
101
|
+
**Scout.** Map the blast radius before any hypothesis, with `cf:scout` or an equivalent focused local scout (`rg` plus targeted reads); scout depth follows the depth: Quick/local maps the project type, affected file(s), direct callers/dependents, related tests, and recent commits; Standard and deeper add module boundaries, test coverage, call chains, recent changes, and existing patterns; `--parallel` runs one independent scout per issue, only through the Delegation Gate.
|
|
102
|
+
|
|
103
|
+
**Diagnosis.** Evidence-based root cause analysis; no guessing. `cf:debug` may help and `--from-debug` validates its report, but neither is a required call; `references/diagnosis-protocol.md` holds the Fix-local checklist. Capture the pre-fix state first: exact error messages, failing test output, stack traces; this is the baseline for verification. When an existing test already fails for the diagnosed reason, its run belongs to this baseline; otherwise the regression test is written and seen failing at the start of implementation under `HARD-GATE-RED-BEFORE-FIX`. Locate where and when the failure started (`git log -p`), form 2-3 hypotheses each with confirm/refute evidence and a quick test, test them with focused local reads (in parallel only through the Delegation Gate), and trace symptom → immediate cause → contributing factor → root cause. If 2+ hypotheses fail, apply `references/escalation-tactics.md`.
|
|
104
|
+
|
|
105
|
+
**Exact root-cause contract** (field definitions in `references/diagnosis-protocol.md`; Expected and Actual may be one field): Symptom, Reproduction, Expected vs actual, Trigger, Root cause (file:line, config, environment, dependency, or data source), Contributing factors, Why now, Evidence chain, Blast radius.
|
|
106
|
+
- Trigger: event or input that activated the failure, or `unknown`
|
|
107
|
+
- Contributing factors: conditions that raised likelihood or impact but are not sufficient causes, or `none evidenced`
|
|
108
|
+
|
|
109
|
+
With `--from-debug`, validate the report before accepting it:
|
|
110
|
+
|
|
111
|
+
- the exact root-cause contract is complete;
|
|
112
|
+
- when `**Depth:**` is `incident/deep`, `Evidence Timeline` is present — a skipped timeline is valid in either producer form (`Timeline: skipped - <reason>` or `- skipped: <reason>`), as is one line naming the sources checked when none carries timestamps;
|
|
113
|
+
- when `**Depth:**` is `incident/deep`, `Elimination Path` records the decisive observation for each removed or retained candidate;
|
|
114
|
+
- a `quick/local` or `standard` report may omit both; a report with no `**Depth:**` line is treated as `incident/deep`;
|
|
115
|
+
- `Recurrence-Prevention Handoff`, when present, carries evidence-backed candidates only.
|
|
116
|
+
|
|
117
|
+
A report missing required fields routes back to diagnosis (`cf:debug`); it does not enter implementation.
|
|
118
|
+
|
|
119
|
+
If any contract field is vague or missing file:line/config/env evidence, keep diagnosing or ask the user for the specific missing artifact. Do not implement.
|
|
120
|
+
|
|
121
|
+
**Depth and frame.** Apply the Proportional depth rule above. For 2+ independent issues (or `--parallel`), evaluate the Delegation Gate; when it is closed, fix the issues sequentially. Track progress with the runtime's task surface when available, or a markdown checklist otherwise. For Standard and Incident/deep, complete the bounded repair frame above. Quick records no separate frame unless scope or risk is still ambiguous.
|
|
122
|
+
|
|
123
|
+
**Implementation.** Fix the root cause, not the symptom. Follow diagnosis findings. Minimal changes only; follow existing code patterns. One logical change per commit boundary.
|
|
124
|
+
- **Quick:** with the pre-fix failure observed under `HARD-GATE-RED-BEFORE-FIX`, apply the minimal fix from completed scout + diagnosis, run the exact pre-fix command plus typecheck/lint immediately, report before/after proof.
|
|
125
|
+
- **Standard:** write or update the regression test and run it to see it fail on the unchanged code (`HARD-GATE-RED-BEFORE-FIX`), then implement the fix, rerun the same test to see it pass, and run the relevant suite.
|
|
126
|
+
- **Incident/deep:** after diagnosis, research only unresolved external facts. If multiple cause-aligned remedies or an architecture decision remain, use `cf:brainstorm` to compare 2-3 options against the bounded repair frame, then write a concise staged implementation plan with dependencies and proof per stage. When diagnosis leaves one safe direct repair, skip research and brainstorm, record why it satisfies the frame, and implement it. Delegated research follows the Delegation Gate; implementation starts only after the direction is resolved.
|
|
127
|
+
- **Parallel:** one independent issue per agent, each carrying scout through verification, dispatched only through the Delegation Gate; aggregate results on completion.
|
|
128
|
+
|
|
129
|
+
**Verification and prevention.** 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. The regression proof is the failing run kept under `HARD-GATE-RED-BEFORE-FIX` and a passing run of the same test after the fix. Full check: typecheck + lint + build + test (see `references/parallel-patterns.md` Pattern C). Prevention guard (Standard+): see `references/prevention-gate.md`; consume the debug report's recurrence candidates when present. Side-effect gate: sweep the full blast radius from diagnosis against the five checks in the gate above. Review: trigger `cf:code-review`; see `references/review-cycle.md`.
|
|
130
|
+
|
|
131
|
+
Verification and review report `PASS | PASS_WITH_WARNINGS | FAIL | BLOCKED`. The definition of `PASS` defers to `cf:code-review`. `PASS_WITH_WARNINGS` routes through the same remediation or user-pause path as `FAIL` and never auto-accepts. `BLOCKED` is terminal for the cycle; resolve the blocker instead of retrying. A review-only result is not execution proof; completion claims require fresh command output.
|
|
132
|
+
|
|
133
|
+
If verification fails: under 3 attempts, return to diagnosis with the new evidence; at 3+ attempts, stop and discuss with the user. Never weaken, delete, or mock a failing assertion to obtain green.
|
|
134
|
+
|
|
135
|
+
**Finalize.** If API or behavior changed, update only the affected existing docs through the docs flow. Ask the user before committing; use conventional commits.
|
|
136
|
+
|
|
137
|
+
## Output Format
|
|
138
|
+
|
|
139
|
+
**Report:** root cause, changes made, files affected, before/after proof, prevention measures, side-effect sweep result, and any remaining limitations.
|
|
140
|
+
|
|
141
|
+
## Specialized Paths
|
|
142
|
+
|
|
143
|
+
Use `references/workflow-specialized.md` as a progressively disclosed overlay after scout for CI/CD failures, test suite failures, TypeScript type errors, UI/visual issues, and application log errors. Load only the matching section. Specialized paths add category-specific evidence and proof; they do not replace these standards, weaken diagnosis, or broaden the repair scope.
|
|
144
|
+
|
|
145
|
+
## References
|
|
146
|
+
|
|
147
|
+
Load as needed:
|
|
148
|
+
- `references/diagnosis-protocol.md` — Structured root cause analysis and the exact root-cause contract
|
|
149
|
+
- `references/escalation-tactics.md` — What to do when hypotheses fail (Inversion, Scale Game)
|
|
150
|
+
- `references/prevention-gate.md` — Defense-in-depth validation after fix
|
|
151
|
+
- `references/review-cycle.md` — Review verdict handling and required user-pause conditions
|
|
152
|
+
- `references/parallel-patterns.md` — Delegation Gate patterns for parallel work
|
|
153
|
+
- `references/workflow-specialized.md` — CI/CD, test, TypeScript, UI-specific workflows
|
|
@@ -20,7 +20,7 @@ Before any investigation, capture the current broken state as baseline:
|
|
|
20
20
|
5. Record git status / recent changes: git log --oneline -10
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
This baseline is required for
|
|
23
|
+
This baseline is required for verification — you MUST compare before/after.
|
|
24
24
|
|
|
25
25
|
## Diagnosis Chain (Follow in Order)
|
|
26
26
|
|
|
@@ -86,7 +86,7 @@ Symptom (where error appears)
|
|
|
86
86
|
|
|
87
87
|
## Exact Root-Cause Contract
|
|
88
88
|
|
|
89
|
-
Before
|
|
89
|
+
Before implementation in `cf:fix`, record:
|
|
90
90
|
|
|
91
91
|
- Symptom: exact observable failure
|
|
92
92
|
- Reproduction: command, user flow, CI job, log trigger, or route
|
|
@@ -38,7 +38,7 @@ Wait for all agents to return. Merge their findings into a unified context map b
|
|
|
38
38
|
|
|
39
39
|
## Pattern B: Parallel Hypothesis Verification
|
|
40
40
|
|
|
41
|
-
After forming 2-3 hypotheses
|
|
41
|
+
After forming 2-3 hypotheses during diagnosis, test them concurrently:
|
|
42
42
|
|
|
43
43
|
```
|
|
44
44
|
Agent(subagent_type="Explore", prompt="Verify hypothesis: cache returns stale data — check TTL config in src/cache/")
|
|
@@ -98,7 +98,7 @@ Agent(subagent_type="Explore", prompt="Scout scope B: map runtime/config paths a
|
|
|
98
98
|
```
|
|
99
99
|
|
|
100
100
|
Wait for the scout evidence, synthesize the required codebase-context summary,
|
|
101
|
-
then begin hypotheses and diagnosis. Research begins only after
|
|
101
|
+
then begin hypotheses and diagnosis. Research begins only after diagnosis
|
|
102
102
|
proves the root cause and identifies one unresolved external fact. It may inform
|
|
103
103
|
a post-diagnosis remedy decision; it never substitutes for repository evidence
|
|
104
104
|
or selects a fix early.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Prevention Gate
|
|
2
2
|
|
|
3
|
-
After a fix is verified, apply defense-in-depth to prevent the same bug class from recurring. Prevention is not the same as side-effect safety; run the
|
|
3
|
+
After a fix is verified, apply defense-in-depth to prevent the same bug class from recurring. Prevention is not the same as side-effect safety; run the side-effect sweep in `../SKILL.md` before claiming completion.
|
|
4
4
|
|
|
5
5
|
When the debug report carries a `Recurrence-Prevention Handoff`, consume its
|
|
6
6
|
evidence-backed candidates (missing invariant or validation layer,
|
|
@@ -12,8 +12,8 @@ of inventing new ones.
|
|
|
12
12
|
For every fix (Standard+ complexity), evaluate and apply at least ONE:
|
|
13
13
|
|
|
14
14
|
### 1. Regression Test Guard
|
|
15
|
-
-
|
|
16
|
-
-
|
|
15
|
+
- A test that specifically covers the fixed issue and was seen failing on the unchanged code before the fix (`HARD-GATE-RED-BEFORE-FIX` in `../SKILL.md`) counts as this guard
|
|
16
|
+
- Red produced afterwards by undoing the fix does not count; the test MUST pass with the fix
|
|
17
17
|
- Place it near related existing tests for discoverability
|
|
18
18
|
|
|
19
19
|
### 2. Input Validation Guard
|
|
@@ -18,21 +18,58 @@ Git operations and worktree management using plain `git` commands.
|
|
|
18
18
|
Present options via AskUserQuestion — header "Git Operation": commit / push / pr / finish / worktree.
|
|
19
19
|
|
|
20
20
|
## Commands
|
|
21
|
-
- `commit`:
|
|
21
|
+
- `commit`: confirm the target checkout before staging → scan the working tree for secrets before anything is staged → analyze the diff → stage and commit by group (`references/commit-protocols.md`).
|
|
22
22
|
- `push`: push current branch.
|
|
23
23
|
- `pr`: push + open PR. Target = repo's integration branch — detect via
|
|
24
24
|
`gh repo view --json defaultBranchRef` or `origin/HEAD`; never assume `main`/`develop`.
|
|
25
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.
|
|
26
|
+
merge locally / push + PR / keep branch-worktree / discard (typed confirmation, as in the worktree lifecycle: `remove <dir-name>` / `delete <branch>`).
|
|
27
|
+
- `worktree <desc>`: sibling dir `../<project>-<branch>` for isolated setup, branched from the current branch unless the user names a base, hydrating the installer-ignored `.claude/`, `.codex/`, `.agents/` it lacks. Git alone is enough (plus `rsync`); Orca, Herdr and Claude Code's own worktree are optional shortcuts, never required.
|
|
28
|
+
- `worktree list | remove <dir> | prune`: lifecycle in `references/worktree-blueprint.md` — never lose uncommitted, ignored or unmerged work: before `git worktree remove`, check `git -C <dir> status --porcelain --ignored` and `git -C <dir> log --oneline <base>..HEAD`, never `--force`, and anything they show needs the typed `remove <dir-name>`; use `git worktree prune` for a missing directory, never `rm -rf`.
|
|
28
29
|
|
|
29
|
-
##
|
|
30
|
+
## Hard rules for `commit`
|
|
31
|
+
- Stage by explicit paths, group by group; never `git add -A`, `git add .`, `git add -u` or `git commit -a` (`-am` included).
|
|
32
|
+
- Confirm the target checkout before staging: print `git rev-parse --show-toplevel` and `git branch --show-current` of the directory you will commit in, check they match what the user asked for, then run every stage and commit with `git -C <target>` (or after a `cd <target>`).
|
|
33
|
+
- Commit messages carry no `Co-Authored-By` and no other AI attribution trailer, unless the user asked for one in this request — even where a host's default guidance suggests it.
|
|
34
|
+
- Push only the current branch, never with `--force`. Bash on macOS is 3.2: no `mapfile`, `readarray`, `declare -A`, `${var,,}`, `${var^^}`, `&>>`.
|
|
35
|
+
|
|
36
|
+
## Secret scan (before anything is staged)
|
|
37
|
+
Scan the working tree first, so a secret never reaches the index. Run this working-tree scan before staging whether or not the helper is installed, inside the target checkout (`cd <target>` first; the block moves to the repository's top-level itself). Do not print file contents or diffs of changed files before the scan has run: look at `git status --short` and `git diff --stat` only, and never `cat`, `git diff`, `git show` or Read a file the scan flagged.
|
|
38
|
+
|
|
39
|
+
The block is bash 3.2 and BSD awk safe. It reads the added lines of tracked changes (or the staged diff when the repository has no commit yet) plus every untracked file, and prints `file:line:class` and nothing else: never the line, a value, or context. Prose such as the word `tokens` and empty or env-referencing values do not match.
|
|
40
|
+
|
|
41
|
+
<!-- fallback-scan:start -->
|
|
30
42
|
```bash
|
|
31
|
-
|
|
43
|
+
cd "$(git rev-parse --show-toplevel)" || exit 1
|
|
44
|
+
D='-c core.quotePath=false diff -U0 --no-color --no-ext-diff --src-prefix=a/ --dst-prefix=b/'
|
|
45
|
+
{ git $D HEAD 2>/dev/null || git $D --cached
|
|
46
|
+
git -c core.quotePath=false ls-files -z --others --exclude-standard | while IFS= read -r -d '' f; do
|
|
47
|
+
printf '+++ b/%s\n@@ -0,0 +1 @@\n' "$f"; sed 's/^/+/' "$f"; echo; done
|
|
48
|
+
} | tr -d '\r' | awk '
|
|
49
|
+
function val(l, n, lo, r, q, v, i, w) {
|
|
50
|
+
n = l; gsub(sprintf("%c", 39), "\"", n); gsub(sprintf("%c", 96), "\"", n); lo = tolower(n)
|
|
51
|
+
if (!match(lo, /(api[_-]?key|secret|password|passwd|token|private[_-]?key)[a-z0-9_-]*["]?[ ]*[:=][ ]*/)) return 0
|
|
52
|
+
r = substr(n, RSTART + RLENGTH); q = substr(r, 1, 1)
|
|
53
|
+
if (q == "\"") { r = substr(r, 2); i = index(r, "\""); if (i == 0) return 0; v = substr(r, 1, i - 1)
|
|
54
|
+
return (length(v) >= 12 && v !~ /^[$<]/ && v !~ /^process[.]env/) }
|
|
55
|
+
split(r, w, " "); v = w[1]
|
|
56
|
+
return (v ~ /^[A-Za-z0-9+\/_=-]+$/ && length(v) >= 16)
|
|
57
|
+
}
|
|
58
|
+
/^[+][+][+] / { f = ($(0) ~ /^[+][+][+] b\//) ? substr($(0), 7) : ""; sub(/\t.*$/, "", f); next }
|
|
59
|
+
/^@@/ { split($(3), a, ","); n = substr(a[1], 2) - 1; next }
|
|
60
|
+
/^[+]/ { n++; if (f == "") next; l = substr($(0), 2); c = ""
|
|
61
|
+
if (val(l)) c = "assignment"
|
|
62
|
+
if (match(l, /sk-[A-Za-z0-9_-]+/) && RLENGTH >= 20) c = "sk-prefix"
|
|
63
|
+
if (match(l, /gh[pousr]_[A-Za-z0-9]+/) && RLENGTH >= 20) c = "gh-prefix"
|
|
64
|
+
if (match(l, /Bearer [A-Za-z0-9._-]+/) && RLENGTH >= 27) c = "bearer"
|
|
65
|
+
if (l ~ /-----BEGIN [A-Z ]*PRIVATE KEY-----/) c = "private-key-block"
|
|
66
|
+
if (c != "") print f ":" n ":" c }'
|
|
32
67
|
```
|
|
33
|
-
|
|
68
|
+
<!-- fallback-scan:end -->
|
|
34
69
|
|
|
35
|
-
|
|
70
|
+
With the helper installed (`.claude/scripts/scan-staged-secrets.cjs`), also run `node .claude/scripts/scan-staged-secrets.cjs` after staging, as a second look at the staged diff (it parses `git diff --cached --unified=0 --no-color --diff-filter=ACMR`, checks added lines only, and prints only file, line, and identifier).
|
|
71
|
+
|
|
72
|
+
Match → STOP everything: commit nothing, not even the clean groups. Report file, line and class only. Do not run `git reset`, `git restore --staged` or `git rm --cached`, and do not edit `.gitignore` or history, before the user answers; with the helper, say which files are already staged. Then let the user choose: for an untracked secret a `.gitignore` rule, for a tracked one rotating it first.
|
|
36
73
|
|
|
37
74
|
## Split rules
|
|
38
75
|
Split when: mixed types (feat+fix), mixed scopes, config/deps mixed with code, >10 unrelated files.
|
|
@@ -40,8 +77,9 @@ Single commit when: same type+scope, ≤3 files, ≤50 lines.
|
|
|
40
77
|
|
|
41
78
|
## Output
|
|
42
79
|
```
|
|
43
|
-
✓
|
|
80
|
+
✓ checkout: <top-level> @ <branch>
|
|
44
81
|
✓ secrets: none
|
|
82
|
+
✓ staged: N files (+X/-Y)
|
|
45
83
|
✓ commit: <hash> type(scope): description
|
|
46
84
|
✓ pushed: yes|no
|
|
47
85
|
```
|
|
@@ -49,7 +87,8 @@ Single commit when: same type+scope, ≤3 files, ≤50 lines.
|
|
|
49
87
|
## Errors
|
|
50
88
|
| Error | Action |
|
|
51
89
|
|---|---|
|
|
52
|
-
| Secrets matched |
|
|
90
|
+
| Secrets matched | Stop all commits; report only file/source line/class. Never show secret value, diff line, or surrounding context. |
|
|
91
|
+
| Wrong checkout or branch | Stop before staging; say what differs and ask |
|
|
53
92
|
| Nothing staged | Exit cleanly |
|
|
54
93
|
| Push rejected | Suggest `git pull --rebase` |
|
|
55
94
|
| Conflicts | List files; never auto-resolve |
|
|
@@ -1,31 +1,48 @@
|
|
|
1
1
|
# Định Dạng & Tiêu Chuẩn Commit (Hapo Git Protocols)
|
|
2
2
|
|
|
3
|
-
Bộ quy chuẩn Native dành cho Hapo Agents khi gọi lệnh `commit`. Không dùng tool bên ngoài, LLM phải tự phân tích qua Bash.
|
|
3
|
+
Bộ quy chuẩn Native dành cho Hapo Agents khi gọi lệnh `commit`. Không dùng tool bên ngoài, LLM phải tự phân tích qua Bash. Các bước dưới đây theo đúng thứ tự: kiểm checkout → quét bí mật → stage theo nhóm → commit.
|
|
4
4
|
|
|
5
|
-
##
|
|
6
|
-
|
|
5
|
+
## Bước 0 — Xác nhận đúng checkout TRƯỚC khi stage
|
|
6
|
+
Xác định thư mục đích (người dùng nêu, hoặc thư mục hiện tại). In top-level và nhánh của CHÍNH thư mục đó:
|
|
7
7
|
```bash
|
|
8
|
-
git
|
|
8
|
+
git -C <đích> rev-parse --show-toplevel
|
|
9
|
+
git -C <đích> branch --show-current
|
|
9
10
|
```
|
|
11
|
+
Chỉ đi tiếp khi cả hai khớp thứ người dùng nhắm tới. Từ đây mọi lệnh stage và commit chạy bằng `git -C <đích>` (hoặc sau một `cd <đích>`; thư mục làm việc được giữ giữa các lệnh). Không khớp (đứng nhầm repo, sai nhánh, detached HEAD) thì dừng trước khi stage, nói rõ lệch ở đâu và hỏi người dùng.
|
|
12
|
+
|
|
13
|
+
Bash trên macOS là bash 3.2: không dùng `mapfile`, `readarray`, `declare -A`, `${var,,}`, `${var^^}`, `&>>`; dùng vòng `while read` hoặc `$(...)` thay thế.
|
|
14
|
+
|
|
15
|
+
## Bước 1 — Quét bí mật khi CHƯA stage
|
|
16
|
+
Chỉ xem `git status --short` và `git diff --stat` trước khi quét; không in nội dung hay diff của file đã đổi (`cat`, `git diff`, `git show`) khi chưa quét xong. Luôn chạy khối quét cây làm việc trong `SKILL.md` (giữa hai dấu `fallback-scan`) TRƯỚC khi stage, dù repo có script quét hay không, và chạy nó bên trong checkout đích (`cd <đích>` trước). Nếu repo có script, chạy thêm nó SAU khi stage như một lần nhìn thứ hai vào diff đã stage. Kết quả chỉ gồm file, dòng, loại — không bao giờ in giá trị.
|
|
17
|
+
|
|
18
|
+
Có trúng → dừng TOÀN BỘ, không commit gì, kể cả các nhóm sạch. Không đổi index hay `.gitignore` trước khi người dùng trả lời; quy tắc đầy đủ nằm ở `SKILL.md`.
|
|
19
|
+
|
|
20
|
+
## Bước 2 — Stage theo nhóm bằng đường dẫn tường minh
|
|
21
|
+
Đọc `git status --short` và `git diff --stat` rồi quyết định chia commit. Mỗi nhóm stage riêng, ví dụ:
|
|
22
|
+
```bash
|
|
23
|
+
git -C <đích> add -- src/a.js src/b.js
|
|
24
|
+
git -C <đích> diff --cached --stat
|
|
25
|
+
```
|
|
26
|
+
Không có gì được stage → thoát gọn.
|
|
10
27
|
|
|
11
28
|
## Giải Thuật: Tách Commit (Auto-Split vs Single Commit)
|
|
12
29
|
|
|
13
|
-
Đọc kỹ
|
|
30
|
+
Đọc kỹ dữ liệu do `git diff --cached --stat` cung cấp để quyết định chia nhỏ commit.
|
|
14
31
|
|
|
15
|
-
**
|
|
16
|
-
1. Có
|
|
17
|
-
2.
|
|
18
|
-
3. Số file thay đổi > 10
|
|
19
|
-
4. Trộn
|
|
32
|
+
**Tách (Split) NGAY NẾU:**
|
|
33
|
+
1. Có cả `feat` (tính năng) và `fix` (sửa lỗi) trong cùng một rổ.
|
|
34
|
+
2. Nhiều Scope đan xen: vừa sửa `auth` vừa động vào `payment`.
|
|
35
|
+
3. Số file thay đổi > 10 VÀ không chung một chủ đề.
|
|
36
|
+
4. Trộn cập nhật cấu hình (`package.json`, `.eslintrc`) với code (`src/..`).
|
|
20
37
|
|
|
21
|
-
|
|
38
|
+
**Gộp thành 1 commit NẾU:**
|
|
22
39
|
- Cùng 1 Scope/Type duy nhất.
|
|
23
|
-
- Tổng số file <= 3 và tổng
|
|
40
|
+
- Tổng số file <= 3 và tổng diff <= 50 dòng.
|
|
24
41
|
|
|
25
42
|
## Cú pháp Bắt buộc (Conventional Commits)
|
|
26
43
|
- `feat(scope): ...` — Tính năng mới
|
|
27
44
|
- `fix(scope): ...` — Vá lỗi
|
|
28
|
-
- `refactor(scope): ...` — Cấu trúc lại
|
|
45
|
+
- `refactor(scope): ...` — Cấu trúc lại mã, không đổi hành vi
|
|
29
46
|
- `perf(scope): ...` — Cải thiện hiệu suất
|
|
30
47
|
- `chore(deps): ...` — Cập nhật thư viện
|
|
31
48
|
- `docs(readme): ...` — Tài liệu
|
|
@@ -33,7 +50,9 @@ git add -A && git diff --cached --stat && git diff --cached --name-only
|
|
|
33
50
|
|
|
34
51
|
*LƯU Ý: Tuyệt đối không dùng `docs` hoặc `chore` khi có file nằm ở `.claude` thay đổi. Hãy dùng `feat` hoặc `fix`.*
|
|
35
52
|
|
|
53
|
+
Thông điệp commit không có trailer `Co-Authored-By` hay dòng ghi công AI nào, trừ khi người dùng yêu cầu trong chính lần gọi này.
|
|
54
|
+
|
|
36
55
|
## Xử lý Vướng Mắc Git (Error Handling via Bash)
|
|
37
|
-
- **Có Secret
|
|
38
|
-
- **Push bị báo Rejected:** Cấm dùng `--force
|
|
39
|
-
- **Merge Conflicts:** Báo "BLOCKED", in lệnh
|
|
56
|
+
- **Có Secret:** dừng toàn bộ như Bước 1; báo file/dòng/loại; chờ người dùng quyết định.
|
|
57
|
+
- **Push bị báo Rejected:** Cấm dùng `--force`. Chạy: `git pull --rebase origin <branch>`. Chỉ push nhánh hiện tại.
|
|
58
|
+
- **Merge Conflicts:** Báo "BLOCKED", liệt kê file, in lệnh để người dùng giải quyết hoặc gọi agent `cf:develop` xử lý file conflict.
|
|
@@ -10,7 +10,7 @@ Kêu gọi lệnh Bash để kiểm tra thư mục gốc:
|
|
|
10
10
|
git rev-parse --show-toplevel
|
|
11
11
|
git branch --show-current
|
|
12
12
|
```
|
|
13
|
-
*-> Giả sử top-level path là `/path/to/project` và current là `
|
|
13
|
+
*-> Giả sử top-level path là `/path/to/project` và current là `dev`.* Worktree mới tạo nhánh from the current branch, trừ khi User chỉ định nhánh gốc khác. Nếu `git branch --show-current` rỗng (detached HEAD), dừng lại và hỏi User nhánh gốc.
|
|
14
14
|
|
|
15
15
|
### Bước 2: Nhận Diện & Định Tên Nhánh (Slugifier)
|
|
16
16
|
Tuỳ theo `<feature-description>`, hãy sinh ra một cái tên nhánh dạng Kebab-case.
|
|
@@ -19,24 +19,44 @@ Tuỳ theo `<feature-description>`, hãy sinh ra một cái tên nhánh dạng K
|
|
|
19
19
|
*Lưu ý: Nếu User chủ động gõ tên có sẵn mã Jira (TD-1234) hoặc tên tuyệt đối thì bỏ qua prefix Type.*
|
|
20
20
|
|
|
21
21
|
### Bước 3: Khởi Sinh Worktree (Sibling Pattern)
|
|
22
|
-
**
|
|
23
|
-
|
|
22
|
+
**Mặc định luôn là cấp Sibling (`../`)**: skill không bao giờ tự tạo worktree lồng bên trong repo. Một đường dẫn lồng (dưới `.claude/worktrees/` đã bị ignore) chỉ chấp nhận khi chính người dùng hoặc công cụ host đã đặt tên và tạo ra nó; khi còn worktree lồng, không chạy `git clean -fdx` ở root repo vì nó xoá cả thư mục bị ignore.
|
|
23
|
+
|
|
24
|
+
Lối tắt tùy chọn (không bắt buộc, không phải điều kiện): `claude --worktree`, Orca, Herdr. Chỉ cần `git` (thêm `rsync` cho Bước 4); máy không có công cụ nào khác vẫn làm đủ mọi bước.
|
|
24
25
|
|
|
25
26
|
Cấu trúc lệnh Bash thực thi:
|
|
26
27
|
```bash
|
|
27
28
|
export REPO_HOME=$(git rev-parse --show-toplevel)
|
|
28
29
|
export REPO_NAME=$(basename $REPO_HOME)
|
|
30
|
+
export BASE_BRANCH="${BASE_BRANCH:-$(git branch --show-current)}"
|
|
29
31
|
export BRANCH_NAME="feat/add-auth"
|
|
30
32
|
|
|
31
33
|
# Sanitize folder path (thay / thành - để tránh lỗi subfolder nếu k cần thiết)
|
|
32
34
|
export SAFE_FOLDER_NAME="${REPO_NAME}-${BRANCH_NAME//\//-}"
|
|
33
35
|
export TARGET_DIR="$REPO_HOME/../$SAFE_FOLDER_NAME"
|
|
34
36
|
|
|
35
|
-
|
|
37
|
+
|
|
38
|
+
# Không che lỗi của git bằng `||`: hai tình huống đầu phải DỪNG và hỏi người dùng, không chạy tiếp, không tự chọn.
|
|
39
|
+
if [ -e "$TARGET_DIR" ]; then
|
|
40
|
+
echo "Thư mục $TARGET_DIR đã tồn tại — hỏi người dùng, không chạy tiếp"
|
|
41
|
+
elif git show-ref --verify --quiet "refs/heads/$BRANCH_NAME"; then
|
|
42
|
+
echo "Nhánh $BRANCH_NAME đã tồn tại — hỏi người dùng: dùng lại nhánh đó (git worktree add \"$TARGET_DIR\" \"$BRANCH_NAME\") hay đặt tên khác; không chạy tiếp"
|
|
43
|
+
else
|
|
44
|
+
git worktree add -b "$BRANCH_NAME" "$TARGET_DIR" "$BASE_BRANCH"
|
|
45
|
+
fi
|
|
36
46
|
```
|
|
47
|
+
Nhánh đã tồn tại thì KHÔNG tự gắn worktree vào nó: nhánh cũ có thể có gốc khác `$BASE_BRANCH`, trái luật "tạo từ nhánh hiện tại".
|
|
37
48
|
|
|
38
49
|
### Bước 4: Tự Động Hóa Môi Trường (Hydration)
|
|
39
|
-
|
|
50
|
+
Bộ cài CafeKit thêm `.claude/`, `.codex/`, `.agents/` vào `.gitignore`, nên `git worktree add` không mang theo hook, skill và rule. Chép những thư mục đang có ở repo gốc mà worktree mới còn thiếu, bỏ log, session state, worktree lồng của agent và môi trường cài cục bộ:
|
|
51
|
+
```bash
|
|
52
|
+
for dir in .claude .codex .agents; do
|
|
53
|
+
if [ -d "$REPO_HOME/$dir" ] && [ ! -e "$TARGET_DIR/$dir" ]; then
|
|
54
|
+
rsync -a --exclude 'session-state/' --exclude 'worktrees/' --exclude '.logs/' --exclude 'node_modules/' --exclude '.venv/' "$REPO_HOME/$dir/" "$TARGET_DIR/$dir/"
|
|
55
|
+
echo "hydrated $dir"
|
|
56
|
+
fi
|
|
57
|
+
done
|
|
58
|
+
```
|
|
59
|
+
Sau đó, tại `$TARGET_DIR` mới, bạn phải tự scan (bằng `ls` hoặc `find`) để tìm file cấu trúc và cài đặt:
|
|
40
60
|
- Nếu tìm thấy `.env.example`, tự chạy `cp .env.example .env`.
|
|
41
61
|
- Nếu tìm thấy `bun.lockb` / `bun.lock`: Chạy `bun install`.
|
|
42
62
|
- Nếu tìm thấy `pnpm-lock.yaml`: Chạy `pnpm install`.
|
|
@@ -45,4 +65,20 @@ Tại `$TARGET_DIR` mới, bạn phải tự scan (bằng `ls` hoặc `find`) đ
|
|
|
45
65
|
### Bước 5: Báo Cáo Chuyển Giao
|
|
46
66
|
Sau khi chạy hoàn thiện qua Native Bash, xuất báo cáo cho Tướng Lĩnh.
|
|
47
67
|
Nội dung thông báo (Mẫu):
|
|
48
|
-
> "✅ Worktree được khởi tạo thành công tại thư mục Sibling: `/path/to/.../project-feat-auth`. Môi trường npm và .env đã được setup. Để bắt đầu code, vui lòng mở
|
|
68
|
+
> "✅ Worktree được khởi tạo thành công tại thư mục Sibling: `/path/to/.../project-feat-auth`, nhánh `feat/auth` tạo từ `dev`. Đã chép `.claude/` (các dòng `hydrated`). Môi trường npm và .env đã được setup. Để bắt đầu code, vui lòng mở một phiên agent mới tại đường dẫn đó, để hook của worktree này chỉ canh gói specs của chính nó."
|
|
69
|
+
|
|
70
|
+
Mỗi worktree chỉ giữ một gói specs đang mở; phiên agent mới bắt đầu ngay trong thư mục worktree đó.
|
|
71
|
+
|
|
72
|
+
## Vòng đời worktree: liệt kê, gỡ, dọn
|
|
73
|
+
Mục tiêu: không bao giờ mất việc chưa lưu. Thư mục `.claude/`, `.codex/`, `.agents/` do Bước 4 chép sang là bản sao dùng lại được, nên không tính là việc chưa lưu; mọi thứ khác bị ignore (ví dụ `.env` đã sửa, kể cả `.env` chép từ `.env.example` ở Bước 4) thì có và phải hỏi.
|
|
74
|
+
|
|
75
|
+
- **Liệt kê:** `git worktree list --porcelain`. Mục có dòng `prunable` là thư mục đã mất.
|
|
76
|
+
- **Gỡ `<dir>`:** chạy hai lệnh kiểm trước, rồi mới gỡ:
|
|
77
|
+
```bash
|
|
78
|
+
git -C <dir> status --porcelain --ignored # bỏ qua các mục dưới .claude/ .codex/ .agents/ đã chép
|
|
79
|
+
git -C <dir> log --oneline <base>..HEAD # <base> = nhánh worktree được tạo từ đó, hoặc nhánh tích hợp
|
|
80
|
+
```
|
|
81
|
+
Cả hai trống → `git worktree remove <dir>` (không `--force`). Có bất cứ dòng nào → hiện ra và hỏi; chỉ gỡ sau khi người dùng gõ đúng `remove <tên-thư-mục>`.
|
|
82
|
+
- **Dọn mục `prunable`:** `git worktree prune`. Không bao giờ `rm -rf` một thư mục worktree.
|
|
83
|
+
- **Nhánh:** xoá bằng `git branch -d <nhánh>`; "đã merge" nghĩa là nhánh có trong `git branch --merged <base>`. Chỉ dùng `-D` sau khi người dùng gõ đúng `delete <tên-nhánh>`.
|
|
84
|
+
|