@haposoft/cafekit 0.7.29 → 0.8.0

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 (28) hide show
  1. package/README.md +21 -12
  2. package/package.json +4 -1
  3. package/src/claude/CLAUDE.md +81 -135
  4. package/src/claude/agents/brainstormer.md +24 -13
  5. package/src/claude/agents/code-auditor.md +1 -1
  6. package/src/claude/agents/spec-maker.md +2 -2
  7. package/src/claude/agents/test-runner.md +10 -8
  8. package/src/claude/rules/ai-dev-rules.md +36 -51
  9. package/src/claude/rules/hook-protocols.md +35 -0
  10. package/src/claude/rules/orchestrator.md +11 -0
  11. package/src/claude/rules/workflow.md +41 -45
  12. package/src/claude/skills/brainstorm/SKILL.md +123 -39
  13. package/src/claude/skills/chrome-devtools/scripts/package.json +3 -1
  14. package/src/claude/skills/code-review/references/spec-compliance-review.md +1 -1
  15. package/src/claude/skills/develop/SKILL.md +4 -4
  16. package/src/claude/skills/develop/references/quality-gate.md +2 -2
  17. package/src/claude/skills/git/SKILL.md +19 -2
  18. package/src/claude/skills/git/references/finish-branch.md +61 -0
  19. package/src/claude/skills/pdf/scripts/__pycache__/check_bounding_boxes.cpython-314.pyc +0 -0
  20. package/src/claude/skills/specs/SKILL.md +15 -6
  21. package/src/claude/skills/specs/references/review.md +1 -1
  22. package/src/claude/skills/specs/rules/tasks-generation.md +3 -3
  23. package/src/claude/skills/specs/templates/task.md +4 -2
  24. package/src/claude/skills/sync/SKILL.md +2 -2
  25. package/src/claude/skills/sync/references/sync-protocols.md +4 -4
  26. package/src/claude/skills/test/SKILL.md +4 -1
  27. package/src/claude/skills/test/references/execution-strategy.md +3 -1
  28. package/src/claude/skills/test/references/test-memory.md +2 -2
@@ -0,0 +1,35 @@
1
+ # Hook Protocols
2
+
3
+ Hooks are instruction boundaries. Do not bypass or work around them.
4
+
5
+ ## Privacy Block Hook
6
+
7
+ When a tool call is blocked by the privacy hook, the output contains a JSON marker between:
8
+
9
+ ```text
10
+ @@PRIVACY_PROMPT_START@@
11
+ ...
12
+ @@PRIVACY_PROMPT_END@@
13
+ ```
14
+
15
+ Required flow:
16
+
17
+ 1. Parse the JSON payload from the marker.
18
+ 2. Ask the user for approval using the available user-question tool and the prompt/options from the payload.
19
+ 3. If approved, retry only the blocked action.
20
+ 4. If denied, continue without reading that file or performing that blocked action.
21
+
22
+ Never use another command, path, encoding, or side channel to access a privacy-blocked file without explicit approval.
23
+
24
+ ## State And Spec Hooks
25
+
26
+ - If a hook reports state drift, run the appropriate sync/audit flow before continuing.
27
+ - If a hook rejects task completion, keep the task `in_progress` or `blocked` until proof exists.
28
+ - Do not mark a task `done` unless the matching task file contains a valid verification receipt.
29
+
30
+ ## Hook Failure Handling
31
+
32
+ - Treat hook errors as blockers when they affect safety, privacy, or task state.
33
+ - Record the blocker in the task/spec state when relevant.
34
+ - If the hook output is malformed, stop and ask for clarification instead of guessing.
35
+
@@ -40,6 +40,16 @@ Use when each step relies on the output of the previous one:
40
40
 
41
41
  Each agent must finish completely before the next one starts. Forward relevant outputs in the handoff prompt.
42
42
 
43
+ ### Implementation Review Chain
44
+
45
+ For implementation tasks, keep the chain explicit:
46
+
47
+ 1. Implement against one active task/spec scope.
48
+ 2. Verify with `test-runner` using task files and exact evidence commands.
49
+ 3. Review with `code-auditor` using task files, design contracts, and the diff.
50
+
51
+ Do not dispatch multiple implementation agents against the same files or same task. Parallelize only independent scopes with distinct file ownership.
52
+
43
53
  ### Parallel (independent tasks)
44
54
 
45
55
  Spawn concurrent agents when work does not overlap:
@@ -88,6 +98,7 @@ Agent lacks information to proceed. Supply the missing context and re-dispatch.
88
98
  ## Prompt Engineering for Subagents
89
99
 
90
100
  Subagents operate in a fresh context — they have **zero knowledge** of the parent session.
101
+ They should receive task files, relevant design/requirements excerpts, file paths, acceptance criteria, and current diffs. Do not rely on inherited chat history.
91
102
 
92
103
  ### Prompt Template
93
104
 
@@ -1,60 +1,56 @@
1
1
  # Execution Workflow
2
2
 
3
- > Token efficiency matters deliver high quality without wasting context.
3
+ Use the CafeKit loop: **Understand -> Plan -> Execute -> Verify -> Sync**.
4
4
 
5
- ## Phase 0: Understand
5
+ ## 1. Understand
6
6
 
7
- Before planning, establish project awareness:
7
+ - Read `./README.md` before feature planning or coding.
8
+ - Read the active spec/task file when one exists.
9
+ - Read and activate any CafeKit skill that likely applies before taking action.
10
+ - Inspect only the code needed to understand the affected area.
11
+ - Use `hapo:inspect` or focused search when structure is unclear.
8
12
 
9
- - Read `./docs/codebase-summary.md` if it exists and is fresh (< 2 days old)
10
- - Otherwise, generate one using `repomix` or delegate to `hapo:inspect` for scoped discovery
11
- - Scan `./docs/code-standards.md` and `./docs/system-architecture.md` for constraints
12
- - Identify which parts of the codebase are affected by the upcoming work
13
+ ## 2. Plan
13
14
 
14
- ## Phase 1: Plan
15
+ - For non-trivial features, use `/hapo:specs` to create or validate the spec.
16
+ - For approved specs, work one task file at a time.
17
+ - Extract from the active task:
18
+ - `Objective`
19
+ - `Constraints`
20
+ - `Related Files`
21
+ - `Completion Criteria`
22
+ - `Task Test Plan & Verification Evidence`
23
+ - If these are missing or too vague to verify, route back to spec correction.
15
24
 
16
- - Delegate to `hapo:spec-maker` to draft an implementation plan with actionable TODO items in `./specs`
17
- - For complex features, spawn multiple `hapo:researcher` agents in parallel to investigate different technical areas, then feed findings back into the plan
18
- - Never start coding without a clear, reviewed plan
25
+ ## 3. Execute
19
26
 
20
- ## Phase 2: Execute
27
+ - Implement only the active scope.
28
+ - Modify existing files directly; do not create duplicate "enhanced" variants.
29
+ - Keep named contracts from `design.md` intact.
30
+ - Do not use placeholder wiring, process-local stand-ins, or fake adapters as completion proof.
21
31
 
22
- ### 2a. Implement
32
+ ## 4. Verify
23
33
 
24
- - Produce clean, maintainable code following the project's architectural patterns
25
- - Modify existing files do not create "enhanced" duplicates
26
- - Cover edge cases and error paths
27
- - Run compile/build after every file change to catch issues immediately
34
+ - Run exact commands from `Task Test Plan & Verification Evidence` first.
35
+ - Then run repo-level lint/test/build as needed for confidence.
36
+ - Use only fresh verification from the current run when claiming completion.
37
+ - `PRECHECK_FAIL` outranks `NO_TESTS`.
38
+ - `NO_TESTS` or `0 tests + exit 0` is not a pass when automated tests are required.
39
+ - If verification fails, fix root cause and rerun. After 3 failed attempts, escalate with evidence.
28
40
 
29
- ### 2b. Test
41
+ ## 5. Sync
30
42
 
31
- - Delegate to `hapo:test-runner` to validate the **final, production-ready code**
32
- - Expectations for test suites:
33
- - Comprehensive unit coverage
34
- - Error scenario testing
35
- - Performance validation where applicable
36
- - Absolutely **no fake data, mocks-for-passing, or temporary workarounds** to make CI green
37
- - If tests fail: fix the root cause, re-run via `hapo:test-runner`, repeat until all pass — never end a session with red tests
38
- - If a test failure persists after **3 fix attempts**, stop and escalate to the user with a diagnostic summary
43
+ - Mark task state only after implementation, tests/evidence, and review pass.
44
+ - Write a verification receipt with commands run, outcomes, and artifact/runtime proof.
45
+ - Keep `spec.json.task_registry` and markdown task files aligned.
46
+ - Run docs checkpoint when a completed task affects public docs or architecture docs.
39
47
 
40
- ### 2c. Review
48
+ ## Production Or CI Issues
41
49
 
42
- - Once tests are green, delegate to `hapo:code-auditor` for a code quality pass
43
- - Self-documenting code is the goal; add comments only for genuinely complex logic
44
- - Optimize for long-term maintainability and runtime performance
50
+ 1. Capture the failing signal.
51
+ 2. Diagnose root cause with logs/tests.
52
+ 3. Implement the smallest fix.
53
+ 4. Rerun the failing check plus relevant regression checks.
54
+ 5. Review before syncing or shipping.
45
55
 
46
- ## Phase 3: Integrate & Verify
47
-
48
- - Follow the plan established by `hapo:planner` throughout integration
49
- - Honor existing API contracts and preserve backward compatibility
50
- - Document any breaking changes explicitly
51
- - Delegate to `hapo:docs-keeper` to keep `./docs` in sync with the implementation
52
-
53
- ### Handling Production Issues
54
-
55
- When bugs surface in production or CI/CD:
56
-
57
- 1. Delegate to `hapo:debugger` to analyze failures and produce a diagnostic report
58
- 2. Implement the fix based on the report
59
- 3. Delegate to `hapo:test-runner` to verify the fix
60
- 4. If new test failures appear, resolve them and loop back to **Phase 2c (Review)**
56
+ Do not patch symptoms before diagnosis unless the issue is a trivial syntax/type/lint failure with an obvious local cause.
@@ -1,12 +1,51 @@
1
1
  ---
2
2
  name: hapo:brainstorm
3
- description: "Pragmatic Brainstorming: Socratic architectural challenges combined with step-by-step interactive design. Use for ideation, scope gating, and translating raw ideas into specs."
4
- version: 2.0.0
3
+ description: "Scout-first brainstorming for unclear ideas, architectural choices, scope gates, and translating raw intent into a spec-ready design."
4
+ argument-hint: "<idea_or_problem>"
5
+ version: 2.1.0
5
6
  ---
6
7
 
7
8
  # Brainstorming Skill
8
9
 
9
- You execute the Brainstorm workflow. It is designed to aggressively interrogate assumptions, decompose features, and iteratively validate architectural solutions before any code is drafted.
10
+ You execute CafeKit's pre-spec design workflow. Your job is to turn a raw idea into a validated, spec-ready design without writing code or starting implementation.
11
+
12
+ `hapo:brainstorm` is the workflow entrypoint. The `brainstormer` agent is a specialist you may call for difficult architectural debate; it is not a replacement for this workflow.
13
+
14
+ ## Core Stance
15
+
16
+ - Scout before asking. Do not ask generic questions when the repository can make the question concrete.
17
+ - Make requirements exact before proposing architecture.
18
+ - Challenge assumptions without turning the session into a debate for its own sake.
19
+ - Prefer the simplest design that satisfies the agreed acceptance criteria.
20
+ - Keep design approval incremental: small sections, explicit confirmation, then handoff.
21
+
22
+ <HARD-GATE>
23
+ Do NOT invoke implementation skills, write code, scaffold files, modify source, or begin `/hapo:develop` until the design has been presented and explicitly approved by the user.
24
+ </HARD-GATE>
25
+
26
+ <HARD-GATE-SCOUT-FIRST>
27
+ Before asking clarifying questions or proposing approaches, run `hapo:inspect` or perform a narrow equivalent scout.
28
+
29
+ Mandatory scout findings:
30
+ 1. Project type, primary languages, and major frameworks.
31
+ 2. Existing files/modules relevant to the topic.
32
+ 3. Current patterns or conventions for similar work.
33
+ 4. Relevant docs, specs, or plans already present.
34
+ 5. Constraints discovered from code, schemas, APIs, naming, or runtime setup.
35
+
36
+ Then summarize the useful findings to the user in 3-6 bullets before Discovery.
37
+ </HARD-GATE-SCOUT-FIRST>
38
+
39
+ <HARD-GATE-EXACT-REQUIREMENTS>
40
+ Before proposing solutions, capture concrete answers for:
41
+ 1. Expected output: feature behavior, artifact, UI surface, API shape, CLI behavior, or document.
42
+ 2. Acceptance criteria: observable checks that prove done.
43
+ 3. Scope boundary: what is explicitly out of scope for this round.
44
+ 4. Non-negotiable constraints: stack, files, compatibility, deadlines, naming, runtime.
45
+ 5. Touchpoints: existing files/modules/data/contracts the design will affect.
46
+
47
+ If any item is vague, ask one more grounded question. Do not proceed with phrases like "make it better" or "add validation" unless you have concrete examples.
48
+ </HARD-GATE-EXACT-REQUIREMENTS>
10
49
 
11
50
  ## Anti-Rationalization
12
51
 
@@ -22,63 +61,108 @@ You execute the Brainstorm workflow. It is designed to aggressively interrogate
22
61
 
23
62
  Leverage these specific tools or sub-agents to execute the workflow effectively:
24
63
  - `AskUserQuestion`: Use this to enforce the "One Question at a Time" rule and to present multiple choices.
25
- - `hapo:inspect`: Use this to discover codebase files and understand context.
64
+ - `hapo:inspect`: Mandatory first pass for repo-aware brainstorming.
26
65
  - `hapo:ai-multimodal`: Use this when analyzing visual materials and mockups.
66
+ - `hapo:generate-graph`: Use when a diagram would make architecture, flows, or trade-offs easier to validate.
27
67
  - `repomix --remote`: Use this bash command to summarize external Github repositories if a URL is provided.
28
68
  - `psql`: Query database schemas to understand existing data structures.
69
+ - `brainstormer`: Call only for medium/high-complexity architecture trade-offs.
29
70
  - **Ecosystem Swarm (`SendMessage`):** Call `researcher` (validation), `docs-keeper` (architecture boundaries), or `project-manager` (scope warnings) for deeply complex specs.
30
71
 
31
- ## The Hybrid Workflow
72
+ ## Authoritative Workflow
32
73
 
33
74
  ```mermaid
34
75
  flowchart TD
35
- A["/hapo:inspect"] --> B[Assess Scope & Context]
36
- B --> C{Multiple Subsystems?}
37
- C -->|Yes| D[Force Sub-project Decomposition]
38
- D --> B
39
- C -->|No| E[Ask ONE Clarifying Question]
40
- E --> F[Present 2-3 Solutions]
41
- F --> R{Is Task Complex?}
42
- R -->|Yes| S["Call researcher & docs-keeper via SendMessage"]
43
- S --> G
44
- R -->|No| G[Debate & Recommend Simplest Options]
45
- G --> H[Present Design in Segments]
46
- H --> I{User Approves Segment?}
47
- I -->|No, Revise| H
48
- I -->|Yes| J[Run 4-Point Spec Review]
49
- J --> K{Final Approval?}
50
- K -->|No| G
51
- K -->|Yes| M[Write Design Doc / Report]
52
- M --> L["/hapo:specs"]
53
- L --> N["/hapo:journal"]
76
+ A["Run /hapo:inspect or narrow scout"] --> B["Summarize codebase findings"]
77
+ B --> C["Ask one grounded clarifying question"]
78
+ C --> D{"Exact requirements captured?"}
79
+ D -->|No| C
80
+ D -->|Yes| E{"Multiple independent subsystems?"}
81
+ E -->|Yes| F["Decompose into sub-projects"]
82
+ F --> C
83
+ E -->|No| G{"Medium/high complexity?"}
84
+ G -->|Yes| H["Call brainstormer/researcher/docs-keeper as needed"]
85
+ G -->|No| I["Propose 2-3 approaches"]
86
+ H --> I
87
+ I --> J["Recommend simplest viable option"]
88
+ J --> K["Present design in sections"]
89
+ K --> L{"User approves section?"}
90
+ L -->|No, revise| K
91
+ L -->|Yes| M["Run 4-point review"]
92
+ M --> N{"Final approval?"}
93
+ N -->|No| I
94
+ N -->|Yes| O["Write Design Doc / Summary Report"]
95
+ O --> P["Invoke /hapo:specs with report context"]
96
+ P --> Q["Optional /hapo:journal"]
54
97
  ```
55
98
 
56
99
  ## Tactical Execution Rules
57
100
 
58
- ### 1. The Interrogation
59
- - Ask exactly **one question at a time**. Do not stack 5 bulleted questions in one response. Use `AskUserQuestion` to enforce this.
60
- - Structure your questions as multiple-choice evaluations where feasible.
61
- - Attack unexamined assumptions first. Ask "Why do you need this?" rather than just "How should we build it?"
101
+ ### 1. Scout Phase
102
+
103
+ - Start with `hapo:inspect` for normal repositories. Use direct `Glob`/`Grep` only when the scope is tiny and obvious.
104
+ - Do not scan the entire repository blindly. Target the user's topic.
105
+ - If the user gives a GitHub URL, use `repomix --remote` before discussing architecture.
106
+ - Report only useful findings, not raw file dumps.
62
107
 
63
- ### 2. Trade-Off Analysis
108
+ ### 2. Discovery Phase
109
+
110
+ - Ask exactly **one question at a time**. Do not stack multiple unrelated questions.
111
+ - Prefer multiple-choice options grounded in scout findings.
112
+ - Push vague intent into concrete examples, sample inputs/outputs, or acceptance criteria.
113
+ - Challenge the first proposed solution when the underlying goal suggests a simpler path.
114
+
115
+ ### 3. Scope Guard
116
+
117
+ - If the request spans 3+ independent subsystems, stop and decompose it.
118
+ - Each sub-project should be able to move through brainstorm -> specs -> develop -> test -> review independently.
119
+ - Do not design a monolithic spec when the work needs multiple specs.
120
+
121
+ ### 4. Trade-Off Analysis
64
122
  Whenever multiple approaches exist, compare them using specific dimensions:
65
- - Technical Debt & Maintenance Burden
66
- - Cognitive Complexity
67
- - User Experience (UX) and Developer Experience (DX)
68
- - Time vs. Value proportion
123
+ - setup cost
124
+ - runtime complexity
125
+ - maintenance load
126
+ - user experience and developer experience
127
+ - compatibility and migration risk
128
+ - time-to-value
129
+
130
+ Always name the simplest viable option and explain the trade-off that makes it preferable.
69
131
 
70
- ### 3. Visual & UI Protocols
71
- If the topic involves UI layouts, interactive elements, or visual styling: do not force text-only guesswork. Leverage the `hapo:ai-multimodal` skill to process mockups or structural blueprints when necessary. Prioritize visual alignment over abstract textual descriptions for frontend features.
132
+ ### 5. Visual & UI Protocols
72
133
 
73
- ### 4. 4-Point Spec Review
134
+ If the topic involves UI layouts, interactive elements, visual styling, architecture diagrams, or spatial flows:
135
+ - Use `hapo:ai-multimodal` for supplied images, videos, PDFs, or mockups.
136
+ - Use `hapo:generate-graph` when a diagram would make trade-offs clearer.
137
+ - Do not force text-only guesswork for visual choices.
138
+ - Visual aids support the brainstorm; they do not bypass user approval.
139
+
140
+ ### 6. Design Presentation
141
+
142
+ - Present design in sections sized to complexity: Architecture, Data Flow, Interfaces, UX, Error Cases, Testing Strategy, Rollout.
143
+ - Ask for approval after each meaningful section.
144
+ - Keep changes tied to discovered touchpoints.
145
+ - Do not invent unrelated refactors.
146
+
147
+ ### 7. 4-Point Spec Review
74
148
  Before passing the completed design to the user for final review, you must internally sanitize the drafted document:
75
149
  1. **Placeholder Scan:** Hunt and eliminate any "TBD", "TODO", or vague placeholder variables.
76
150
  2. **Consistency Check:** Ensure no contradictory flows exist between architecture and behavior segments.
77
151
  3. **Scope Check:** Verify the design addresses only the agreed feature bounds without uncontrolled scope creep.
78
152
  4. **Ambiguity Check:** Replace abstract claims ("we will implement logic here") with concrete instructions.
79
153
 
80
- ### 5. Final Handoff & Documentation
154
+ ### 8. Final Handoff & Documentation
81
155
  Upon the user's explicit final approval of the sanitized design document:
82
156
  1. Generate the final **Design Doc / Summary Report**.
83
- 2. Immediately invoke `/hapo:specs` to hand off the project into the implementation planning phase based on your report.
84
- 3. Conclude by optionally invoking `/hapo:journal` if the project context should be persisted for future developer memory.
157
+ 2. Include: problem statement, exact requirements, evaluated approaches, recommended solution, risks, validation criteria, and next steps.
158
+ 3. Invoke `/hapo:specs` with the report context to hand off into CafeKit's structured specification phase.
159
+ 4. Optionally invoke `/hapo:journal` if the project context should be persisted for future developer memory.
160
+
161
+ ## Completion Bar
162
+
163
+ You are done only when:
164
+ - Scout findings were summarized.
165
+ - The five exact requirement fields are concrete.
166
+ - The selected design was approved by the user.
167
+ - The 4-point review found no blocking gaps.
168
+ - The summary/report is ready for `/hapo:specs`.
@@ -3,7 +3,9 @@
3
3
  "version": "1.1.0",
4
4
  "description": "Browser automation scripts for Chrome DevTools Agent Skill",
5
5
  "type": "module",
6
- "scripts": {},
6
+ "scripts": {
7
+ "test": "node --test __tests__/*.test.js"
8
+ },
7
9
  "dependencies": {
8
10
  "debug": "^4.4.0",
9
11
  "puppeteer": "^24.15.0",
@@ -24,7 +24,7 @@ Do not attempt a standard text-based review if the project includes Visual Specs
24
24
  3. If NO (Markdown Spec only): Read the spec directly and extract:
25
25
  - requirement bullets
26
26
  - task `Completion Criteria`
27
- - task `Verification & Evidence`
27
+ - task `Task Test Plan & Verification Evidence` (or legacy `Verification & Evidence`)
28
28
  - canonical contracts/invariants from `design.md`
29
29
  Then verify the changed files against those concrete obligations.
30
30
 
@@ -45,7 +45,7 @@ DO NOT write implementation code until an approved spec exists.
45
45
 
46
46
  <DEFINITION-OF-DONE>
47
47
  A task is NOT done because code compiles or a placeholder renders.
48
- A task is done only when the task file's Completion Criteria AND Verification & Evidence section are satisfied with real execution proof.
48
+ A task is done only when the task file's Completion Criteria AND Task Test Plan & Verification Evidence section are satisfied with real execution proof. Existing specs may use legacy `Verification & Evidence`; treat that as the same contract.
49
49
  </DEFINITION-OF-DONE>
50
50
 
51
51
  <CONTRACT-FIDELITY>
@@ -85,7 +85,7 @@ flowchart TD
85
85
  - Objective + Constraints
86
86
  - Related Files
87
87
  - Completion Criteria
88
- - Verification & Evidence
88
+ - Task Test Plan & Verification Evidence (or legacy Verification & Evidence)
89
89
  - Exact executable verification commands named in the task
90
90
  - Requirement IDs referenced by the task
91
91
  - Named technologies, frameworks, protocols, and data stores that the task/spec explicitly requires
@@ -118,7 +118,7 @@ The moment you finish coding, DO NOT proceed further. Switch to `references/qual
118
118
  **Mantra:** All feedback from code-auditor must be addressed thoroughly: Score >= 9.5 & Zero Critical issues.
119
119
 
120
120
  - Passing Step 4 requires ALL of the following:
121
- 1. Automated verification passes, including preflight compile/typecheck/build health and every exact command named in the task's `Verification & Evidence` section
121
+ 1. Automated verification passes, including preflight compile/typecheck/build health and every exact command named in the task's `Task Test Plan & Verification Evidence` section (or legacy `Verification & Evidence`)
122
122
  2. Code review passes
123
123
  3. Task evidence passes (artifacts/runtime surfaces/negative-path checks from the task file are proven)
124
124
  - `PRECHECK_FAIL` outranks `NO_TESTS`. If compile/typecheck/build fails, the task is FAIL even when no test suite exists yet.
@@ -135,7 +135,7 @@ The moment you finish coding, DO NOT proceed further. Switch to `references/qual
135
135
  - `spec.json.task_registry[path].status = "done"`
136
136
  - `completed_at` + `last_updated_at`
137
137
  - synchronized top-level `updated_at`
138
- - a human-readable verification receipt inside the task's `Verification & Evidence` section showing which commands ran, their outcomes, and what proof was observed
138
+ - a human-readable verification receipt inside the task's `Task Test Plan & Verification Evidence` section showing which commands ran, their outcomes, and what proof was observed
139
139
  - Verification receipts with `PRECHECK_FAIL`, `FAIL`, `UNVERIFIED`, or an explicit note that the implementation intentionally simplified a named contract MUST NOT be synchronized as `done`.
140
140
  - After syncing the active task, run a **Task Closeout Docs Checkpoint**
141
141
  - Task Closeout Docs Checkpoint:
@@ -9,7 +9,7 @@ Green tests are NOT enough. The gate requires three proofs:
9
9
 
10
10
  ## Automation Semantics
11
11
 
12
- - If the task names exact commands in `Verification & Evidence`, those exact commands are mandatory and must run before any fallback repo defaults.
12
+ - If the task names exact commands in `Task Test Plan & Verification Evidence` (or legacy `Verification & Evidence`), those exact commands are mandatory and must run before any fallback repo defaults.
13
13
  - Preflight compile/typecheck/build health is mandatory. If compile/typecheck/build fails before tests are meaningful, the gate result is `PRECHECK_FAIL`, not `NO_TESTS`.
14
14
  - `NO_TESTS` is never an automatic PASS.
15
15
  - `NO_TESTS` is acceptable only when the task does **not** require a dedicated test suite command and every other required automated command/evidence item passes.
@@ -26,7 +26,7 @@ Variable: retry_count = 0
26
26
 
27
27
  Before START_LOOP:
28
28
  - Read the active task file(s)
29
- - Extract Related Files, Completion Criteria, Verification & Evidence
29
+ - Extract Related Files, Completion Criteria, Task Test Plan & Verification Evidence (or legacy Verification & Evidence)
30
30
  - Extract the exact executable verification commands in declaration order
31
31
  - Extract relevant design contracts/invariants for the touched area
32
32
  - If any of these are missing or too vague to verify, FAIL immediately and route back to spec correction
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: hapo:git
3
- description: "Hapo Native Git Operations & Worktree Management. Handles safe commits, conventional split, secret scanning, and sibling-branch worktrees locally."
4
- argument-hint: "commit | push | pr | worktree <feature-desc>"
3
+ description: "Hapo Native Git Operations & Worktree Management. Handles safe commits, conventional split, branch finish choices, secret scanning, and sibling-branch worktrees locally."
4
+ argument-hint: "commit | push | pr | finish | worktree <feature-desc>"
5
5
  version: "1.0.0"
6
6
  ---
7
7
 
@@ -17,6 +17,7 @@ This skill merges Version Control Systems (VSC) capabilities and parallel Worktr
17
17
  - **`commit`**: Scan secrets, analyze diff, auto-split chunks into conventional commits.
18
18
  - **`push`**: Securely push to the current branch.
19
19
  - **`pr`**: Propose merging current feature into `develop` or `main`.
20
+ - **`finish`**: Verify current branch/worktree, then present explicit finish options.
20
21
 
21
22
  ### 2. Worktree Engine (Safe Parallel Development)
22
23
  - **`worktree <feature-description>`**: Creates a sibling directory alongside the current repo to isolate dependencies and database contexts without dirtying the main worktree.
@@ -38,7 +39,23 @@ This skill merges Version Control Systems (VSC) capabilities and parallel Worktr
38
39
  - Never run branching logic within the same root if the task requires heavy, isolated setup.
39
40
  - Worktrees MUST be created as *sibling directories*: `../<project-name>-<feature-branch>`.
40
41
 
42
+ ### 4. Finish Branch Protocol
43
+ - Before merge, push, PR, or discard, run a fresh status and verification check:
44
+ ```bash
45
+ git status --short
46
+ git branch --show-current
47
+ ```
48
+ - If uncommitted changes exist, route through `commit` or ask whether to keep them unstaged.
49
+ - Present explicit finish options:
50
+ 1. Merge locally into the target branch.
51
+ 2. Push current branch and open/update a PR.
52
+ 3. Keep the branch/worktree for later.
53
+ 4. Discard branch/worktree only after typed confirmation.
54
+ - Never force-push or delete worktrees without explicit user confirmation.
55
+ - If running inside a git worktree, detect it with `git worktree list` and clean up only the worktree created for this task.
56
+
41
57
  ## References & Protocols
42
58
 
43
59
  - `references/commit-protocols.md`: Strict rules for analyzing Git Diffs and determining commit splitting behavior.
60
+ - `references/finish-branch.md`: Finish branch / PR / worktree closeout protocol.
44
61
  - `references/worktree-blueprint.md`: The 4-step Bash process to accurately construct an out-of-bounds Git Worktree Environment.
@@ -0,0 +1,61 @@
1
+ # Finish Branch Protocol
2
+
3
+ Use this protocol for `hapo:git finish`.
4
+
5
+ ## Goal
6
+
7
+ Finish the current branch deliberately. Do not assume the user wants merge, push, PR, keep, or discard.
8
+
9
+ ## Step 1: Inspect Current State
10
+
11
+ Run:
12
+
13
+ ```bash
14
+ git rev-parse --show-toplevel
15
+ git branch --show-current
16
+ git status --short
17
+ git worktree list
18
+ ```
19
+
20
+ Identify:
21
+
22
+ - current branch
23
+ - whether this is a linked worktree
24
+ - uncommitted changes
25
+ - upstream tracking branch
26
+ - likely target branch (`main`, `develop`, or user-provided target)
27
+
28
+ ## Step 2: Verify Before Finish
29
+
30
+ Before any merge/push/PR/discard recommendation, run the task-required verification or the repository default checks. If verification is not available, report `NO_TESTS` / `UNVERIFIED` honestly.
31
+
32
+ Never claim a branch is ready from stale output.
33
+
34
+ ## Step 3: Present Finish Options
35
+
36
+ Offer explicit options:
37
+
38
+ 1. **Merge locally** — merge current branch into target branch.
39
+ 2. **Push / PR** — push current branch and create or update a pull request.
40
+ 3. **Keep** — leave branch/worktree as-is for later work.
41
+ 4. **Discard** — delete branch/worktree only after explicit typed confirmation.
42
+
43
+ Do not select an option silently unless the user already requested it.
44
+
45
+ ## Step 4: Safety Rules
46
+
47
+ - Never force-push by default.
48
+ - Never delete a branch with unmerged commits without typed confirmation.
49
+ - Never remove a worktree you did not create or cannot identify.
50
+ - Never discard uncommitted changes without explicit typed confirmation.
51
+ - If verification fails, recommend fix/retest before merge or PR.
52
+
53
+ ## Step 5: Completion Report
54
+
55
+ Report:
56
+
57
+ - branch and target
58
+ - chosen finish action
59
+ - verification commands and result
60
+ - commit/push/PR result
61
+ - remaining risks or unresolved questions
@@ -85,7 +85,8 @@ Display selection menu via `AskUserQuestion`:
85
85
  ### When called WITH a feature description
86
86
 
87
87
  System auto-analyzes the description:
88
- - If description is too short (< 20 words) or vague → stop and ask 1-2 clarifying questions
88
+ - If description is too short (< 20 words) or missing one concrete detail → stop and ask 1-2 clarifying questions
89
+ - If the idea has unresolved architecture choices, unclear acceptance criteria, unclear scope boundaries, or multiple plausible approaches → stop and route to `/hapo:brainstorm <idea>` before creating spec artifacts
89
90
  - If task is simple (small bugfix, config change) → suggest "A spec may not be needed for this. Continue anyway?"
90
91
  - If task is complex (multi-module, security/migration related) → auto-activate deep research, ask user 3 scope questions
91
92
 
@@ -111,7 +112,9 @@ flowchart TD
111
112
  A["Call /hapo:specs"] --> B{Has description?}
112
113
  B -->|No| C["Menu: init / status / resume / --validate / archive"]
113
114
  B -->|Yes| D["Step 1: Analyze description"]
114
- D --> E{Clear enough?}
115
+ D --> DB{"Needs pre-spec brainstorm?"}
116
+ DB -->|Yes| DB2["Stop: run /hapo:brainstorm with same idea"]
117
+ DB -->|No| E{Clear enough?}
115
118
  E -->|No| F["Ask user 1-2 clarifying questions"]
116
119
  F --> D
117
120
  E -->|Yes| G["Step 2: Scan specs/ for related specs"]
@@ -148,6 +151,12 @@ flowchart TD
148
151
 
149
152
  ### Step 1: Analyze Description
150
153
  - Assess clarity and complexity of the description
154
+ - Route to `hapo:brainstorm` before creating files when:
155
+ - the expected output or acceptance criteria are not concrete
156
+ - the scope boundary is unknown
157
+ - the request has 2-3 viable architectures and no user-approved direction
158
+ - the feature spans 3+ independent subsystems and needs decomposition
159
+ - the user is explicitly asking to explore, compare, debate, or decide
151
160
  - **Multimodal & Document Auto-Ingestion (MANDATORY)**: If the input includes file paths or URLs pointing to images, audio, video, or Office documents, you MUST spawn the matching subagent to extract content BEFORE proceeding:
152
161
  - `.mp3`, `.wav`, `.mp4`, `.mov`, `.jpg`, `.png`, `.webp` → `Task(subagent_type="hapo:ai-multimodal", prompt="Transcribe/Analyze [path]")`
153
162
  - `.pdf` → `Task(subagent_type="hapo:pdf", prompt="Extract text and tables from [path]")`
@@ -218,7 +227,7 @@ Load: `references/scope-inquiry.md`
218
227
  - Load `rules/tasks-generation.md` for core principles
219
228
  - Load `rules/tasks-parallel-analysis.md` for parallel markers (default: enabled)
220
229
  - Each task file follows template `templates/task.md`
221
- - Each task file MUST include `Completion Criteria` and `Verification & Evidence` sections detailed enough that a downstream quality gate can prove the task is truly done.
230
+ - Each task file MUST include `Completion Criteria` and `Task Test Plan & Verification Evidence` sections detailed enough that a downstream quality gate can prove the task is truly done.
222
231
  - Build `spec.json.task_registry` alongside `task_files`. For each task file, register at minimum:
223
232
  - `id`
224
233
  - `title`
@@ -311,8 +320,8 @@ Load: `references/review.md` + `rules/design-review.md`
311
320
  - FAIL if any task file exists on disk but is missing from `task_registry`
312
321
  - FAIL if any path in `task_registry` does not exist on disk
313
322
  - FAIL if any requirement or NFR mapping uses non-numeric labels (`NFR-1`, `SEC-1`, etc.)
314
- - FAIL if a task lacks `Completion Criteria` or `Verification & Evidence`
315
- - FAIL if accepted validation decisions exist in reports but are not reflected in the implementation-facing sections of affected artifacts (`Objective`, `Constraints`, `Implementation Steps`, `Completion Criteria`, `Verification & Evidence`, canonical contracts, or requirements text).
323
+ - FAIL if a task lacks `Completion Criteria` or `Task Test Plan & Verification Evidence` (legacy `Verification & Evidence` is accepted only for pre-existing task files)
324
+ - FAIL if accepted validation decisions exist in reports but are not reflected in the implementation-facing sections of affected artifacts (`Objective`, `Constraints`, `Implementation Steps`, `Completion Criteria`, `Task Test Plan & Verification Evidence`, canonical contracts, or requirements text).
316
325
  - FAIL if the spec scope/provider was switched away from Anthropic/Claude but `requirements.md`, `design.md`, or `tasks/*.md` still contain stale provider-specific strings such as `Claude API`, `Haiku`, or `haiku_reachable`. `research.md` is the only allowed place for historical cost comparisons.
317
326
  - FAIL if privacy/delete-data work lacks a single canonical deletion policy. The design MUST explicitly choose either:
318
327
  1. hard-delete with no re-registration lock, or
@@ -446,7 +455,7 @@ Before finalizing any specification, assert all the following:
446
455
  - [ ] **Requirements traceability** matrix present in design.md
447
456
  - [ ] **Canonical Contracts & Invariants** filled for auth/transport/persistence/artifact-sensitive work
448
457
  - [ ] **Every task file** maps to at least 1 valid in-scope requirement ID
449
- - [ ] **Every task file** includes `Verification & Evidence` with executable or inspectable proof
458
+ - [ ] **Every task file** includes `Task Test Plan & Verification Evidence` with executable or inspectable proof
450
459
  - [ ] **State Machine Blueprint:** design.md contains Mermaid diagrams for non-trivial flows
451
460
  - [ ] **Dependency graph complete**: no task can start before its blockers are listed
452
461
  - [ ] **Risk matrix filled**: likelihood × impact, with mitigation for High items
@@ -42,7 +42,7 @@ These rules override any self-reasoning or optimization the system may attempt:
42
42
  4. **Apply YAGNI to fixes.** When user says "configure later" or "decide later", add a single note to the task file. Do NOT generate multiple concrete implementations (e.g., 4 provider files when user only asked for abstraction).
43
43
  5. **No false completion.** You MUST NOT set `validation.status = "completed"` or `ready_for_implementation = true` until a reconciliation audit proves the accepted findings and validation decisions are reflected in the physical spec artifacts.
44
44
  6. **Provider drift is a real defect.** If the scope changed away from Claude/Anthropic, stale strings like `Claude API`, `Haiku`, or `haiku_reachable` in `requirements.md`, `design.md`, or `tasks/*.md` are validation failures. `research.md` may mention them only as historical comparison.
45
- 7. **Implementation-facing propagation is mandatory.** A decision that affects implementation is NOT considered applied if it only appears in `Risk Assessment`, `validate-log.md`, or `red-team-report.md`. It must update at least one of: `requirements.md`, `Canonical Contracts & Invariants`, `Objective`, `Constraints`, `Implementation Steps`, `Completion Criteria`, or `Verification & Evidence`.
45
+ 7. **Implementation-facing propagation is mandatory.** A decision that affects implementation is NOT considered applied if it only appears in `Risk Assessment`, `validate-log.md`, or `red-team-report.md`. It must update at least one of: `requirements.md`, `Canonical Contracts & Invariants`, `Objective`, `Constraints`, `Implementation Steps`, `Completion Criteria`, or `Task Test Plan & Verification Evidence`.
46
46
 
47
47
  ---
48
48