@haposoft/cafekit 0.8.11 → 0.8.13

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.
@@ -11,11 +11,11 @@ Kill bugs systematically. No guessing. Evidence first, fix second.
11
11
 
12
12
  ## Arguments
13
13
 
14
- - `--quick` - Fast track for trivial issues (lint, type errors, syntax)
14
+ - `--quick` - Reduced-depth path for trivial issues (lint, type errors, syntax); still scout-first
15
15
  - `--parallel` - Spawn multiple `god-developer` agents for independent issues
16
16
  - `--from-debug` - Start from an existing `hapo:debug` report and validate its root-cause contract
17
17
 
18
- Default: Autonomous mode — auto-approve when confidence is high.
18
+ Default: deterministic scout-first hotfix. There is no initial mode selection step.
19
19
 
20
20
  <HARD-GATE>
21
21
  Do NOT propose or implement fixes before completing Steps 1-2 (Scout + `hapo:debug` diagnosis).
@@ -23,9 +23,36 @@ Symptom fixes are FAILURE. Find the root cause first.
23
23
  The exact root-cause contract is mandatory: symptom, reproduction, expected/actual, root cause file:line or config/env source, why now, evidence chain, blast radius.
24
24
  The side-effect gate is mandatory before completion.
25
25
  If 3+ fix attempts fail → STOP. Question the architecture. Discuss with user.
26
- Exception: `--quick` mode allows abbreviated scout→diagnose→fix for trivial issues.
26
+ Exception: `--quick` mode only abbreviates depth; it never skips scout, pre-fix evidence, diagnosis, or before/after verification.
27
27
  </HARD-GATE>
28
28
 
29
+ <HARD-GATE-SCOUT-FIRST>
30
+ Hotfix ALWAYS scouts before asking broad clarification questions, forming hypotheses, or changing files.
31
+ Collect these scout outputs first:
32
+ 1. Project type, language(s), framework(s), and package/test runner from repo files.
33
+ 2. Exact file(s) where the symptom surfaces and their direct callers/dependents.
34
+ 3. Related tests covering the affected area.
35
+ 4. Recent commits touching affected files: `git log --oneline -10 -- <affected-files>`.
36
+ 5. Existing patterns/conventions for this kind of fix.
37
+ Then state a concise 3-6 bullet codebase-context summary before Step 2.
38
+ </HARD-GATE-SCOUT-FIRST>
39
+
40
+ <HARD-GATE-NO-SIDE-EFFECTS>
41
+ The fix is not done until Step 5 proves:
42
+ 1. The original symptom no longer reproduces with the exact pre-fix command/user flow.
43
+ 2. Modified files and transitively affected modules still pass relevant tests.
44
+ 3. Blast-radius workflows have no business-logic regression.
45
+ 4. No new lint/type/build errors were introduced.
46
+ 5. Public contracts are unchanged unless intentionally called out: function signatures, exported types, response shapes, DB schemas, env vars.
47
+
48
+ If verification reveals a side effect or regression, STOP and present 2-4 concrete options to the user:
49
+ - Revert this fix and try a different root-cause angle.
50
+ - Narrow the fix scope to remove the regression.
51
+ - Keep the fix and update named dependent files/contracts.
52
+ - Accept the behavior change intentionally.
53
+ Do not silently patch around the regression.
54
+ </HARD-GATE-NO-SIDE-EFFECTS>
55
+
29
56
  ## Anti-Rationalization
30
57
 
31
58
  | Thought | Reality |
@@ -35,6 +62,7 @@ Exception: `--quick` mode allows abbreviated scout→diagnose→fix for trivial
35
62
  | "Just try changing X" | Random fixes waste time and create new bugs. Diagnose first. |
36
63
  | "It's probably X" | "Probably" = guessing. Use structured diagnosis. |
37
64
  | "One more fix attempt" (after 2+) | 3+ failures = wrong approach. Question architecture. |
65
+ | "Quick mode means skip process" | Quick mode only reduces depth. Scout, diagnosis, and before/after proof remain mandatory. |
38
66
 
39
67
  ## Process Flow
40
68
 
@@ -43,7 +71,7 @@ flowchart TD
43
71
  A[Issue Input] --> B[Step 1: Scout via hapo:inspect]
44
72
  B --> C[Step 2: Diagnose via hapo:debug]
45
73
  C --> D[Step 3: Classify Complexity]
46
- D -->|Trivial| E[Quick Fix]
74
+ D -->|Trivial| E[Quick Fix after scout+diagnose]
47
75
  D -->|Standard| F[Standard Fix]
48
76
  D -->|Complex| G[Deep Fix + Subagents]
49
77
  D -->|Multiple Issues| H[Parallel Fix]
@@ -70,17 +98,22 @@ flowchart TD
70
98
 
71
99
  **Action:** Activate `hapo:inspect` skill to map the blast radius.
72
100
 
73
- | Mode | Scout Depth |
101
+ Do not ask generic questions before this step unless there is no repo, no error text, and no observable artifact to inspect.
102
+
103
+ | Path | Scout Depth |
74
104
  |------|-------------|
75
- | `--quick` | Minimal — locate affected file(s) and direct dependencies only |
76
- | Standard | Full — map module boundaries, test coverage, call chains |
105
+ | `--quick` | Minimal — project type, affected file(s), direct callers/dependents, related tests, recent commits |
106
+ | Standard | Full — project type, module boundaries, test coverage, call chains, recent changes, existing patterns |
77
107
  | `--parallel` | Per-issue independent scouts |
78
108
 
79
109
  **Checklist:**
110
+ - [ ] Project type, language, framework, package manager, and test runner identified
80
111
  - [ ] Affected files identified
81
- - [ ] Direct dependencies mapped (imports/exports)
112
+ - [ ] Direct callers/dependents mapped (imports/exports, route registrations, provider wiring, consumers)
82
113
  - [ ] Related tests located
83
114
  - [ ] Recent git changes checked: `git log --oneline -10 -- <affected-files>`
115
+ - [ ] Existing local patterns for this code path identified
116
+ - [ ] 3-6 bullet codebase-context summary reported before diagnosis
84
117
 
85
118
  **Output:** `✓ Step 1: Scouted — [N] files mapped, [M] dependencies, [K] tests found`
86
119
 
@@ -115,6 +148,8 @@ Use `hapo:debug` or validate an existing debug report when `--from-debug` is pro
115
148
  - Evidence chain: observations proving the cause
116
149
  - Blast radius: affected files, modules, tests, users, workflows, or release paths
117
150
 
151
+ If any field is vague (`probably`, `maybe`, `I think`, or missing file:line/config/env evidence), keep diagnosing or ask the user for the specific missing artifact. Do not implement.
152
+
118
153
  **Output:** `✓ Step 2: Diagnosed — Root cause: [summary], Evidence: [brief], Scope: [N files]`
119
154
 
120
155
  ---
@@ -131,6 +166,7 @@ Use `hapo:debug` or validate an existing debug report when `--from-debug` is pro
131
166
  **Task Orchestration (Standard+ only):**
132
167
  - Use `TaskCreate` with dependencies to track fix phases
133
168
  - Skip for Trivial (overhead exceeds benefit)
169
+ - If `TaskCreate` / `TaskUpdate` are unavailable, use a concise markdown checklist or `TodoWrite` fallback. Do not block the hotfix because structured task tools are missing.
134
170
 
135
171
  **Output:** `✓ Step 3: [Complexity] detected — [workflow] selected`
136
172
 
@@ -144,8 +180,9 @@ Use `hapo:debug` or validate an existing debug report when `--from-debug` is pro
144
180
  - One logical change per commit boundary.
145
181
 
146
182
  ### Quick Workflow
147
- 1. Apply the obvious fix directly from diagnosis
148
- 2. Run typecheck/lint immediately
183
+ 1. Apply the minimal fix directly from completed scout + diagnosis
184
+ 2. Run exact pre-fix command plus typecheck/lint immediately
185
+ 3. Report before/after proof
149
186
 
150
187
  ### Standard Workflow
151
188
  1. Implement fix targeting root cause
@@ -178,20 +215,27 @@ Use `hapo:debug` or validate an existing debug report when `--from-debug` is pro
178
215
  2. **Regression test:** The test MUST fail without the fix and pass with it.
179
216
  3. **Parallel verification:** Run typecheck + lint + build + test simultaneously via `Bash`. See `references/parallel-patterns.md` Pattern C.
180
217
  4. **Prevention guard (Standard+ only):** See `references/prevention-gate.md`.
181
- 5. **Side-effect gate:** Run the sweep in `references/debugger/side-effect-gate.md`.
182
- 6. **Code review:** Trigger `hapo:code-review` and handle results per `references/review-cycle.md` (autonomous auto-approve loop or HITL depending on fix criticality).
218
+ 5. **Side-effect gate:** Sweep the full blast radius identified in Step 2:
219
+ - Modified files and direct dependents pass relevant tests
220
+ - Affected user/API/CLI workflows still work
221
+ - Public contracts unchanged unless intentionally called out
222
+ - No new lint/type/build errors
223
+ 6. **Code review:** Trigger `hapo:code-review`; never auto-approve blocking security, auth, data-loss, resource-exhaustion, or public-contract issues.
183
224
 
184
225
  **If verification fails:**
185
226
  - < 3 attempts → Loop back to Step 2 (re-diagnose with new evidence)
186
227
  - 3+ attempts → STOP. Question architecture. Discuss with user.
187
228
 
229
+ **If a side effect appears:**
230
+ - STOP and present concrete options to the user. Do not silently broaden the fix.
231
+
188
232
  **Output:** `✓ Step 5: Verified + Prevented — [before/after comparison], [N] tests added`
189
233
 
190
234
  ---
191
235
 
192
236
  ## Step 6: Finalize (MANDATORY — never skip)
193
237
 
194
- 1. **Report:** Confidence score, root cause, changes made, files affected, prevention measures
238
+ 1. **Report:** Confidence score, root cause, changes made, files affected, prevention measures, side-effect sweep result
195
239
  2. **Docs update:** If API/behavior changed → delegate to `docs-keeper` subagent
196
240
  3. **Task cleanup:** `TaskUpdate` → mark all tasks `completed` (skip if no tasks created)
197
241
  4. **Commit:** Ask user if ready to commit via `git-ops` subagent
@@ -227,16 +271,23 @@ Unified step markers (emit after each step):
227
271
  | `docs-keeper` | Update docs if behavior changed (Step 6) |
228
272
  | `god-developer` | Parallel independent issues (each gets own agent) |
229
273
 
274
+ ## Specialized Paths
275
+
276
+ Use `references/workflow-specialized.md` as an overlay after Step 1 scout:
277
+ - CI/CD failures
278
+ - Test suite failures
279
+ - TypeScript type errors
280
+ - UI / visual issues
281
+ - Application log errors
282
+
283
+ Specialized paths do not replace the 6-step hotfix process.
284
+
230
285
  ## References
231
286
 
232
287
  Load as needed:
233
288
  - `references/diagnosis-protocol.md` — Structured root cause analysis methodology
234
289
  - `references/escalation-tactics.md` — What to do when hypotheses fail (Inversion, Scale Game)
235
290
  - `references/prevention-gate.md` — Defense-in-depth validation after fix
236
- - `references/review-cycle.md` — Autonomous approval loop + HITL review handling
291
+ - `references/review-cycle.md` — Review handling and required user-pause conditions
237
292
  - `references/parallel-patterns.md` — Parallel Explore/Bash/Task coordination with code templates
238
293
  - `references/workflow-specialized.md` — CI/CD, test, TypeScript, UI-specific workflows
239
- - `references/debugger/frontend-verification.md` — Browser/UI evidence and visual verification
240
- - `references/debugger/performance-diagnostics.md` — Baseline-driven performance diagnosis
241
- - `references/debugger/condition-based-waiting.md` — Flaky async test diagnosis
242
- - `references/debugger/side-effect-gate.md` — Regression and blast-radius sweep
@@ -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 `references/debugger/side-effect-gate.md` before claiming completion.
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 Step 5 side-effect sweep in `../SKILL.md` before claiming completion.
4
4
 
5
5
  ## Mandatory Prevention Checklist
6
6
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  How to handle code review results after a fix is implemented. Ensures quality without unnecessary friction.
4
4
 
5
- ## Autonomous Mode (Default)
5
+ ## Default Review Handling
6
6
 
7
7
  The agent reviews its own fix using `hapo:code-review` and decides automatically:
8
8
 
@@ -32,9 +32,9 @@ LOOP:
32
32
  → Proceed to Step 6
33
33
  ```
34
34
 
35
- ## Human-in-the-Loop Mode
35
+ ## Required User Pause
36
36
 
37
- When the fix touches production-critical code or the user explicitly requests review control:
37
+ When the fix touches production-critical code, changes public contracts, introduces a behavior change, or the user explicitly requests review control:
38
38
 
39
39
  1. Run `hapo:code-review` → collect score + findings
40
40
  2. Present a structured summary to user:
@@ -52,15 +52,15 @@ When the fix touches production-critical code or the user explicitly requests re
52
52
  - If no critical issues → "Approve" | "Address warnings" | "Abort"
53
53
  4. Execute user's choice. Max 3 remediation cycles.
54
54
 
55
- ## When to Use HITL vs Autonomous
55
+ ## When To Pause vs Continue
56
56
 
57
57
  | Situation | Mode |
58
58
  |-----------|------|
59
- | Type errors, lint, syntax fixes | Autonomous (always) |
60
- | Single-file logic bugs | Autonomous |
61
- | Multi-file changes touching auth/payments/data | HITL recommended |
62
- | Architecture-impacting changes | HITL required |
63
- | User said "review with me" or similar | HITL |
59
+ | Type errors, lint, syntax fixes | Continue after passing verification |
60
+ | Single-file logic bugs | Continue after passing verification |
61
+ | Multi-file changes touching auth/payments/data | Pause recommended |
62
+ | Architecture-impacting changes | Pause required |
63
+ | User said "review with me" or similar | Pause required |
64
64
 
65
65
  ## Blocking Issues (Never Auto-Approve)
66
66
 
@@ -27,7 +27,7 @@ When unit/integration/e2e tests are failing:
27
27
  2. **Check for pollution:** Does it pass alone but fail in suite? → Test order dependency or shared state leaking
28
28
  3. **Check for staleness:** Did the implementation change but the test assertions were not updated?
29
29
  4. **Snapshot drift:** If snapshot tests fail, review the diff carefully — is it an intentional change or a regression?
30
- 5. **Flaky async:** Replace arbitrary sleeps with condition-based waits. See `references/debugger/condition-based-waiting.md`.
30
+ 5. **Flaky async:** Replace arbitrary sleeps with condition-based waits: wait for observable state, DOM condition, network completion, queue drain, or explicit event instead of fixed timeouts.
31
31
 
32
32
  ---
33
33
 
@@ -52,7 +52,7 @@ When the interface is broken, misaligned, or not rendering:
52
52
  1. **Capture visual evidence:** Use `pushd skills/chrome-devtools/scripts && node screenshot.js --url <url> && popd`
53
53
  2. **Check ARIA structure:** `pushd skills/chrome-devtools/scripts && node aria-snapshot.js --url <url> && popd` — reveals hidden overlays, z-index battles
54
54
  3. **Check console errors:** `pushd skills/chrome-devtools/scripts && node console.js --url <url> && popd` — catches JS crashes preventing render
55
- 4. **Run frontend verification:** Follow `references/debugger/frontend-verification.md` for screenshot, console, network, accessibility, responsive, and interaction evidence.
55
+ 4. **Run frontend verification:** collect screenshot, console, network, accessibility, responsive, and interaction evidence before/after the fix.
56
56
  5. **Common traps:**
57
57
  - CSS specificity wars (use browser DevTools or ARIA snapshot to verify computed styles)
58
58
  - Hydration mismatch in SSR frameworks (server HTML differs from client render)
@@ -14,7 +14,8 @@ const fs = require('fs');
14
14
  const path = require('path');
15
15
 
16
16
  // Import modular components
17
- const { green, yellow, red, cyan, magenta, dim, coloredBar, RESET, shouldUseColor } = require('./hooks/lib/color.cjs');
17
+ const colors = require('./hooks/lib/color.cjs');
18
+ const { green, yellow, red, cyan, magenta, dim, coloredBar, RESET } = colors;
18
19
  const { parseTranscript } = require('./hooks/lib/parser.cjs');
19
20
  const { countConfigs } = require('./hooks/lib/counter.cjs');
20
21
  const { loadConfig } = require('./hooks/lib/config.cjs');
@@ -358,7 +359,7 @@ function render(ctx, singleLineMode = false) {
358
359
 
359
360
  // Output all lines with non-breaking spaces for alignment
360
361
  for (const line of lines) {
361
- const outputLine = shouldUseColor ? `${RESET}${line.replace(/ /g, '\u00A0')}` : line;
362
+ const outputLine = colors.shouldUseColor ? `${RESET}${line.replace(/ /g, '\u00A0')}` : line;
362
363
  console.log(outputLine);
363
364
  }
364
365
  }
@@ -509,6 +510,7 @@ async function main() {
509
510
  // Load config and get statusline mode
510
511
  const config = loadConfig({ includeProject: false, includeAssertions: false, includeLocale: false });
511
512
  const statuslineMode = config.statusline || 'full';
513
+ colors.setColorEnabled(config.statuslineColors !== false);
512
514
 
513
515
  // Render based on mode
514
516
  switch (statuslineMode) {