@haposoft/cafekit 0.14.1 → 0.14.2

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 (60) hide show
  1. package/README.md +7 -3
  2. package/bin/__tests__/installer-safety.test.js +145 -0
  3. package/bin/install.js +9 -1
  4. package/bin/lib/backup.js +60 -16
  5. package/bin/lib/context.js +1 -1
  6. package/bin/phases/claude-runtime.js +57 -4
  7. package/bin/phases/post-install.js +39 -26
  8. package/bin/phases/select-platform.js +14 -9
  9. package/package.json +1 -1
  10. package/src/claude/CLAUDE.md +1 -1
  11. package/src/claude/agents/code-auditor.md +1 -1
  12. package/src/claude/agents/debugger.md +1 -0
  13. package/src/claude/agents/god-developer.md +10 -1
  14. package/src/claude/agents/inspector.md +1 -0
  15. package/src/claude/agents/spec-maker.md +1 -1
  16. package/src/claude/agents/test-runner.md +2 -2
  17. package/src/claude/hooks/__tests__/privacy-block.test.js +50 -10
  18. package/src/claude/hooks/__tests__/spec-gate.test.js +75 -1
  19. package/src/claude/hooks/__tests__/state.test.js +65 -0
  20. package/src/claude/hooks/docs-sync.cjs +15 -21
  21. package/src/claude/hooks/inspect-block.cjs +1 -1
  22. package/src/claude/hooks/lib/config.cjs +0 -5
  23. package/src/claude/hooks/privacy-block.cjs +39 -62
  24. package/src/claude/hooks/spec-gate.cjs +18 -7
  25. package/src/claude/hooks/spec-state.cjs +4 -0
  26. package/src/claude/hooks/state.cjs +13 -3
  27. package/src/claude/hooks/usage.cjs +6 -0
  28. package/src/claude/rules/orchestrator.md +2 -2
  29. package/src/claude/rules/skill-domain-routing.md +27 -86
  30. package/src/claude/rules/skill-workflow-routing.md +11 -82
  31. package/src/claude/rules/state-sync.md +1 -1
  32. package/src/claude/runtime.json +7 -7
  33. package/src/claude/scripts/validate-spec-output.cjs +6 -0
  34. package/src/claude/skills/code-review/references/spec-compliance-review.md +1 -1
  35. package/src/claude/skills/develop/SKILL.md +26 -5
  36. package/src/claude/skills/develop/references/parallel-waves.md +112 -0
  37. package/src/claude/skills/develop/references/quality-gate.md +10 -2
  38. package/src/claude/skills/hotfix/references/parallel-patterns.md +1 -1
  39. package/src/claude/skills/inspect/SKILL.md +42 -113
  40. package/src/claude/skills/inspect/references/internal-inspection.md +16 -135
  41. package/src/claude/skills/specs/SKILL.md +134 -386
  42. package/src/claude/skills/specs/rules/tasks-generation.md +1 -1
  43. package/src/claude/skills/specs/templates/task.md +3 -1
  44. package/src/claude/skills/sync/SKILL.md +2 -2
  45. package/src/claude/skills/sync/references/sync-protocols.md +4 -4
  46. package/src/claude/skills/test/SKILL.md +1 -1
  47. package/src/claude/status.cjs +9 -6
  48. package/src/opencode/plugins/docs-sync.ts +10 -16
  49. package/src/claude/archive-command/code/SKILL.md +0 -55
  50. package/src/claude/archive-command/code/references/execution-loop.md +0 -21
  51. package/src/claude/archive-command/code.md +0 -17
  52. package/src/claude/archive-command/docs.md +0 -609
  53. package/src/claude/archive-command/review/codebase/parallel.md +0 -76
  54. package/src/claude/archive-command/spec-design.md +0 -247
  55. package/src/claude/archive-command/spec-init.md +0 -120
  56. package/src/claude/archive-command/spec-requirements.md +0 -138
  57. package/src/claude/archive-command/spec-status.md +0 -98
  58. package/src/claude/archive-command/spec-tasks.md +0 -173
  59. package/src/claude/archive-command/spec-validate.md +0 -118
  60. package/src/claude/archive-command/test.md +0 -8
@@ -1,609 +0,0 @@
1
- ---
2
- name: docs
3
- description: Documentation management command. Use '/docs init' to create initial docs, '/docs update' to update existing docs.
4
- allowed-tools: Read, Write, Glob, Grep, Bash
5
- argument-hint: <init|update> [--focus=dir1,dir2]
6
- ---
7
-
8
- # /docs - Documentation Management
9
-
10
- $ARGUMENTS
11
-
12
- ---
13
-
14
- ## Purpose
15
-
16
- Unified command for project documentation:
17
- - `/docs init` - Initialize comprehensive documentation (replaces old /init)
18
- - `/docs update` - Update docs after code changes
19
-
20
- ---
21
-
22
- ## Parse Arguments
23
-
24
- **Extract subcommand:**
25
- - If `$ARGUMENTS` starts with `init` → Run INIT workflow
26
- - If `$ARGUMENTS` starts with `update` → Run UPDATE workflow
27
- - Else → Show usage help
28
-
29
- **Extract flags:**
30
- - `--focus=dir1,dir2` - Focus on specific directories
31
- - `--dir=./path` - Target specific directory
32
-
33
- ---
34
-
35
- ## INIT Workflow (`/docs init`)
36
-
37
- ### Step 1: Check Prerequisites
38
-
39
- ```bash
40
- # Check if docs/ already exists
41
- ls -la docs/ 2>/dev/null && echo "EXISTS" || echo "NOT_FOUND"
42
-
43
- # Check repomix
44
- which repomix || npm list -g repomix 2>/dev/null || echo "REPOMIX_NOT_FOUND"
45
- ```
46
-
47
- **If docs/ exists:**
48
- - Ask: "docs/ already exists. Overwrite / Merge / Skip?"
49
-
50
- ### Step 2: Install Repomix (if needed)
51
-
52
- ```bash
53
- # Check if repomix is installed
54
- which repomix 2>/dev/null || npm list -g repomix 2>/dev/null
55
- ```
56
-
57
- **If repomix not found:**
58
- - Detect package manager: npm, pnpm, yarn, bun
59
- - Install repomix globally:
60
-
61
- ```bash
62
- # Detect package manager
63
- test -f pnpm-lock.yaml && PM="pnpm"
64
- test -f yarn.lock && PM="yarn"
65
- test -f bun.lockb && PM="bun"
66
- PM="${PM:-npm}"
67
-
68
- # Install repomix globally
69
- $PM install -g repomix
70
-
71
- # Verify installation
72
- which repomix
73
- ```
74
-
75
- **Report:**
76
- ```
77
- 📦 Installing repomix... ✅ Done
78
- ```
79
-
80
- ### Step 3: Run Repomix
81
-
82
- ```bash
83
- # Generate codebase compaction
84
- repomix
85
-
86
- # Verify output
87
- ls -la ./repomix-output.xml
88
- ```
89
-
90
- ### Step 4: Auto-Detect Project Info
91
-
92
- ```bash
93
- # Package manager & config
94
- test -f pnpm-lock.yaml && echo "PNPM"
95
- test -f yarn.lock && echo "YARN"
96
- test -f package-lock.json && echo "NPM"
97
- test -f bun.lockb && echo "BUN"
98
- test -f requirements.txt && echo "PIP"
99
- test -f poetry.lock && echo "POETRY"
100
- test -f go.mod && echo "GO"
101
- test -f Cargo.toml && echo "CARGO"
102
-
103
- # Read configs
104
- cat package.json 2>/dev/null
105
- cat pyproject.toml 2>/dev/null
106
- cat go.mod 2>/dev/null
107
- ```
108
-
109
- **Extract:**
110
- - Project name, version, description
111
- - Tech stack with versions
112
- - Scripts/commands
113
- - Dependencies
114
-
115
- ### Step 5: Detect Structure & Platform
116
-
117
- ```bash
118
- # Directory structure
119
- find . -maxdepth 3 -type d ! -path './node_modules/*' ! -path './.git/*' ! -path './.*' 2>/dev/null | sort | head -40
120
-
121
- # Deployment platform
122
- test -f vercel.json && echo "Vercel"
123
- test -f netlify.toml && echo "Netlify"
124
- test -f Dockerfile && echo "Docker"
125
- test -f docker-compose.yml && echo "Docker Compose"
126
- test -f fly.toml && echo "Fly.io"
127
- test -d .github/workflows && echo "GitHub Actions"
128
-
129
- # Database
130
- test -f prisma/schema.prisma && echo "Prisma"
131
- test -f drizzle.config.ts && echo "Drizzle"
132
-
133
- # API
134
- test -d src/app/api && echo "NextJS_API"
135
- test -d src/routes && echo "Express_Routes"
136
-
137
- # Testing
138
- cat package.json | grep -E '"(vitest|jest|playwright|cypress)"' && echo "Testing"
139
- ```
140
-
141
- ### Step 6: Generate 7 Documentation Files
142
-
143
- Create `docs/` directory and generate:
144
-
145
- #### 1. codebase-summary.md
146
- ```markdown
147
- # Codebase Summary
148
-
149
- > Auto-generated project overview
150
-
151
- ## Project Info
152
- | Property | Value |
153
- |----------|-------|
154
- | **Name** | {detected} |
155
- | **Version** | {detected} |
156
- | **Type** | {detected} |
157
-
158
- ## Statistics
159
- | Metric | Value |
160
- |--------|-------|
161
- | Files | {from repomix} |
162
- | Tokens | {from repomix} |
163
- | Generated | {timestamp} |
164
-
165
- ## Tech Stack
166
- | Layer | Technology |
167
- |-------|------------|
168
- | {detected} | {with versions} |
169
-
170
- ## Structure
171
- ```
172
- {directory tree}
173
- ```
174
- ```
175
-
176
- #### 2. project-overview-pdr.md
177
- ```markdown
178
- # Project Overview (PDR)
179
-
180
- ## Identity
181
- - **Name:** {name}
182
- - **Type:** {type}
183
- - **Status:** Active
184
-
185
- ## Description
186
- {from package.json or README}
187
-
188
- ## Features
189
- {extracted from codebase}
190
-
191
- ## Roadmap
192
- - [ ] Current sprint
193
- - [ ] Next milestones
194
- ```
195
-
196
- #### 3. code-standards.md
197
- ```markdown
198
- # Code Standards
199
-
200
- ## Stack
201
- - Language: {detected}
202
- - Framework: {detected}
203
- - Linting: {detected}
204
-
205
- ## Conventions
206
- {inferred from codebase patterns}
207
-
208
- ## Patterns
209
- {common patterns detected}
210
- ```
211
-
212
- #### 4. system-architecture.md
213
- ```markdown
214
- # System Architecture
215
-
216
- ## Overview
217
- {architecture type}
218
-
219
- ## Components
220
- | Component | Tech | Purpose |
221
- |-----------|------|---------|
222
- | {detected} | {tech} | {purpose} |
223
-
224
- ## Data Flow
225
- {simple description}
226
-
227
- ## API Structure
228
- {if detected}
229
-
230
- ## Database
231
- {if detected}
232
- ```
233
-
234
- #### 5. design-guidelines.md
235
- ```markdown
236
- # Design Guidelines
237
-
238
- ## System
239
- - CSS: {Tailwind/Styled/etc}
240
- - UI Library: {detected}
241
-
242
- ## Patterns
243
- {detected patterns}
244
-
245
- ## Responsive
246
- {breakpoints}
247
- ```
248
-
249
- #### 6. deployment-guide.md
250
- ```markdown
251
- # Deployment Guide
252
-
253
- ## Platform
254
- {detected platform}
255
-
256
- ## Quick Deploy
257
- ```bash
258
- {platform commands}
259
- ```
260
-
261
- ## Environment
262
- {from .env.example if exists}
263
-
264
- ## Commands
265
- | Command | Purpose |
266
- |---------|---------|
267
- | {from package.json} | {description} |
268
- ```
269
-
270
- #### 7. project-roadmap.md
271
- ```markdown
272
- # Project Roadmap
273
-
274
- ## Current
275
- {detected state}
276
-
277
- ## Short Term (30d)
278
- - [ ] Tasks
279
-
280
- ## Medium Term (90d)
281
- - [ ] Enhancements
282
-
283
- ## Long Term (6mo)
284
- - [ ] Scale
285
-
286
- ## Tech Debt
287
- {detected issues}
288
- ```
289
-
290
- ### Step 7: Generate CLAUDE.md
291
-
292
- ```bash
293
- # Check if CLAUDE.md exists
294
- test -f CLAUDE.md && echo "EXISTS" || echo "NOT_FOUND"
295
- ```
296
-
297
- **Create or update CLAUDE.md:**
298
-
299
- ```markdown
300
- # {Project Name}
301
-
302
- > Project-specific context for Claude Code. See `.claude/ROUTING.md` for agent routing rules.
303
-
304
- ---
305
-
306
- ## Project Overview
307
-
308
- {description from package.json or README}
309
-
310
- ---
311
-
312
- ## Tech Stack
313
-
314
- | Layer | Technology |
315
- |-------|------------|
316
- | {detected from package.json} | {with versions} |
317
-
318
- ---
319
-
320
- ## Project Structure
321
-
322
- ```
323
- {key directories from analysis}
324
- ```
325
-
326
- ---
327
-
328
- ## Key Directories
329
-
330
- | Directory | Purpose |
331
- |-----------|---------|
332
- | {detected} | {description} |
333
-
334
- ---
335
-
336
- ## Quick Commands
337
-
338
- | Task | Command |
339
- |------|---------|
340
- | {from package.json scripts} | `{pm} run {script}` |
341
-
342
- ---
343
-
344
- ## Project Docs (On-demand)
345
-
346
- | Doc | Purpose | Load when |
347
- |-----|---------|-----------|
348
- | `docs/codebase-summary.md` | Project overview | "summary", "overview" |
349
- | `docs/project-overview-pdr.md` | Product requirements | "requirements", "pdr" |
350
- | `docs/code-standards.md` | Coding conventions | "standards", "conventions" |
351
- | `docs/system-architecture.md` | Architecture | "architecture", "design" |
352
- | `docs/deployment-guide.md` | Deployment | "deploy", "production" |
353
-
354
- ---
355
-
356
- ## Framework Reference
357
-
358
- See `.claude/ROUTING.md` for agent routing and framework rules.
359
-
360
- ---
361
-
362
- **Last Updated:** {timestamp}
363
- ```
364
-
365
- **Write to file:**
366
- ```bash
367
- # Generate CLAUDE.md content
368
- cat > CLAUDE.md << 'EOF'
369
- # {Project Name}
370
-
371
- > Project-specific context for Claude Code. See `.claude/ROUTING.md` for agent routing rules.
372
-
373
- ---
374
-
375
- ## Project Overview
376
-
377
- {description}
378
-
379
- ---
380
-
381
- ## Tech Stack
382
-
383
- | Layer | Technology |
384
- |-------|------------|
385
- {tech_stack_rows}
386
-
387
- ---
388
-
389
- ## Project Structure
390
-
391
- ```
392
- {structure}
393
- ```
394
-
395
- ---
396
-
397
- ## Key Directories
398
-
399
- | Directory | Purpose |
400
- |-----------|---------|
401
- {directory_rows}
402
-
403
- ---
404
-
405
- ## Quick Commands
406
-
407
- | Task | Command |
408
- |------|---------|
409
- {commands_rows}
410
-
411
- ---
412
-
413
- ## Project Docs (On-demand)
414
-
415
- | Doc | Purpose | Load when |
416
- |-----|---------|-----------|
417
- | `docs/codebase-summary.md` | Project overview | "summary", "overview" |
418
- | `docs/project-overview-pdr.md` | Product requirements | "requirements", "pdr" |
419
- | `docs/code-standards.md` | Coding conventions | "standards", "conventions" |
420
- | `docs/system-architecture.md` | Architecture | "architecture", "design" |
421
- | `docs/design-guidelines.md` | UI/UX standards | "design", "ui", "ux" |
422
- | `docs/deployment-guide.md` | Deployment | "deploy", "production" |
423
- | `docs/project-roadmap.md` | Roadmap | "roadmap", "future" |
424
-
425
- ---
426
-
427
- ## Framework Reference
428
-
429
- See `.claude/ROUTING.md` for agent routing and framework rules.
430
-
431
- ---
432
-
433
- **Last Updated:** {timestamp}
434
- EOF
435
- ```
436
-
437
- ### Step 8: Report
438
-
439
- ```markdown
440
- ✅ Documentation initialized!
441
-
442
- 📊 Detected:
443
- - Project: {name}
444
- - Type: {type}
445
- - Stack: {summary}
446
- - Files: {count} | Tokens: {count}
447
-
448
- 📁 Generated (docs/):
449
- ✓ codebase-summary.md
450
- ✓ project-overview-pdr.md
451
- ✓ code-standards.md
452
- ✓ system-architecture.md
453
- ✓ design-guidelines.md
454
- ✓ deployment-guide.md
455
- ✓ project-roadmap.md
456
-
457
- 📝 Also created:
458
- ✓ repomix-output.xml (AI context)
459
- ✓ CLAUDE.md (root)
460
-
461
- 🚀 Next: Run `/docs update` after code changes
462
- ```
463
-
464
- ---
465
-
466
- ## UPDATE Workflow (`/docs update`)
467
-
468
- ### Step 1: Verify
469
-
470
- ```bash
471
- # Check docs/ exists
472
- ls docs/ 2>/dev/null || echo "ERROR: Run '/docs init' first"
473
-
474
- # Backup
475
- cp -r docs docs.backup.$(date +%Y%m%d_%H%M%S)
476
- ```
477
-
478
- ### Step 2: Ensure Repomix Installed
479
-
480
- ```bash
481
- # Check if repomix is installed
482
- which repomix 2>/dev/null || npm list -g repomix 2>/dev/null
483
- ```
484
-
485
- **If repomix not found:**
486
- - Detect package manager
487
- - Install repomix globally
488
-
489
- ```bash
490
- # Detect package manager
491
- test -f pnpm-lock.yaml && PM="pnpm"
492
- test -f yarn.lock && PM="yarn"
493
- test -f bun.lockb && PM="bun"
494
- PM="${PM:-npm}"
495
-
496
- # Install repomix
497
- $PM install -g repomix
498
- ```
499
-
500
- ### Step 3: Re-analyze
501
-
502
- ```bash
503
- # Fresh repomix
504
- repomix
505
-
506
- # Detect changes
507
- git diff --stat HEAD~5..HEAD 2>/dev/null
508
- ```
509
-
510
- ### Step 4: Update Files
511
-
512
- Read existing docs, merge with new analysis:
513
-
514
- 1. **codebase-summary.md** - Refresh stats, structure
515
- 2. **project-overview-pdr.md** - Add new features
516
- 3. **code-standards.md** - Update patterns
517
- 4. **system-architecture.md** - Sync components
518
- 5. **design-guidelines.md** - Refresh UI patterns
519
- 6. **deployment-guide.md** - Update commands
520
- 7. **project-roadmap.md** - Mark progress
521
-
522
- ### Step 5: Update CLAUDE.md
523
-
524
- Update `CLAUDE.md` with latest project info:
525
-
526
- ```bash
527
- # Read existing CLAUDE.md if exists
528
- test -f CLAUDE.md && cat CLAUDE.md || echo "NOT_FOUND"
529
-
530
- # Update key sections:
531
- # - Tech Stack (from package.json)
532
- # - Project Structure (from repomix)
533
- # - Quick Commands (from package.json scripts)
534
- # - Last Updated timestamp
535
- ```
536
-
537
- **Update content:**
538
- - Refresh "Tech Stack" table with latest versions
539
- - Update "Project Structure" if directories changed
540
- - Sync "Quick Commands" with package.json scripts
541
- - Update "Last Updated" timestamp
542
-
543
- **If CLAUDE.md doesn't exist:**
544
- - Create new following INIT workflow template
545
-
546
- ### Step 6: Report
547
-
548
- ```markdown
549
- 🔄 Documentation updated!
550
-
551
- 📊 Changes:
552
- - Files: {old} → {new}
553
- - Tokens: {old} → {new}
554
-
555
- 📝 Updated:
556
- ✓ codebase-summary.md
557
- ✓ project-overview-pdr.md
558
- ✓ code-standards.md
559
- ✓ system-architecture.md
560
- ✓ design-guidelines.md
561
- ✓ deployment-guide.md
562
- ✓ project-roadmap.md
563
- ✓ CLAUDE.md (root)
564
-
565
- 💡 Review docs/ for any manual adjustments needed
566
- ```
567
-
568
- ---
569
-
570
- ## HELP (no valid subcommand)
571
-
572
- ```markdown
573
- /docs - Documentation Management
574
-
575
- Usage:
576
- /docs init - Create initial documentation
577
- /docs update - Update docs after code changes
578
-
579
- Options:
580
- --focus=dir1,dir2 - Focus on specific directories
581
- --dir=./path - Target specific directory
582
-
583
- Examples:
584
- /docs init
585
- /docs init --focus=src,api
586
- /docs update
587
- /docs update --focus=ui
588
- ```
589
-
590
- ---
591
-
592
- ## Error Handling
593
-
594
- | Scenario | Action |
595
- |----------|--------|
596
- | repomix not found | Warn, continue with manual analysis |
597
- | No package.json | Ask user for project type |
598
- | docs/ exists (init) | Ask: Overwrite/Merge/Skip |
599
- | docs/ not found (update) | Prompt to run `/docs init` |
600
- | Permission denied | Report path, suggest fix |
601
-
602
- ---
603
-
604
- ## Notes
605
-
606
- - Always use detected values, never placeholders
607
- - Include versions: "Next.js 14.1.0" not "Next.js"
608
- - repomix-output.xml helps AI understand full context
609
- - 7 docs files = comprehensive coverage
@@ -1,76 +0,0 @@
1
- # Parallel Review Workflow
2
-
3
- **Ultrathink** to exhaustively list ALL potential edge cases, then dispatch parallel `code-reviewer` agents to verify: <scope>$ARGUMENTS</scope>
4
-
5
- **IMPORTANT:** Activate needed skills. Ensure token efficiency. Sacrifice grammar for concision.
6
-
7
- ## Workflow
8
-
9
- ### 1. Ultrathink Edge Cases
10
-
11
- Main agent deeply analyzes the scope to LIST all potential edge cases FIRST:
12
- - Read `codebase-summary.md` for context
13
- - Use `/ck:scout` to find relevant files
14
- - **Think exhaustively** about what could go wrong:
15
- - Null/undefined scenarios
16
- - Boundary conditions (off-by-one, empty, max values)
17
- - Error handling gaps
18
- - Race conditions, async edge cases
19
- - Input validation holes
20
- - Security vulnerabilities
21
- - Resource leaks
22
- - Untested code paths
23
-
24
- **Output format:**
25
- ```markdown
26
- ## Edge Cases Identified
27
-
28
- ### Category: [scope-area]
29
- 1. [edge case description] → files: [file1, file2]
30
- ```
31
-
32
- ### 2. Categorize & Assign
33
-
34
- Group edge cases by similar scope for parallel verification:
35
- - Each category → one `code-reviewer` agent
36
- - Max 6 categories (merge small ones)
37
- - Each reviewer gets specific edge cases to VERIFY, not discover
38
-
39
- ### 3. Parallel Verification
40
-
41
- Launch N `code-reviewer` subagents simultaneously:
42
- - Pass: category name, list of edge cases, relevant files
43
- - Task: **VERIFY** if each edge case is properly handled in code
44
- - Report: which edge cases are handled vs unhandled
45
-
46
- ### 4. Aggregate Results
47
-
48
- ```markdown
49
- ## Edge Case Verification Report
50
-
51
- ### Summary
52
- - Total edge cases: X
53
- - Handled: Y
54
- - Unhandled: Z
55
- - Partial: W
56
-
57
- ### Unhandled Edge Cases (Need Fix)
58
- | # | Edge Case | File | Status |
59
- |---|-----------|------|--------|
60
- ```
61
-
62
- ### 5. Adversarial Review (Always-On)
63
-
64
- After aggregation, spawn adversarial reviewer (see `adversarial-review.md`) on the full scope:
65
- - Adversarial reviewer receives aggregated findings + unhandled edge cases as context
66
- - Actively tries to break the code beyond what edge case verification found
67
- - Adjudicate findings: Accept / Reject / Defer
68
-
69
- ### 6. Auto-Fix Pipeline
70
-
71
- **IF** unhandled/partial edge cases found:
72
- - Ask: "Found N unhandled edge cases. Fix with /ck:fix --parallel? [Y/n]"
73
-
74
- ### 7. Final Report
75
- - Summary of verification
76
- - Ask: "Commit? [Y/n]" → use `git-manager`