@haposoft/cafekit 0.15.3 → 0.16.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/README.md +4 -2
  2. package/bin/__tests__/codex-hooks.test.js +140 -0
  3. package/bin/__tests__/codex-native.test.js +2 -2
  4. package/bin/__tests__/develop-contract.test.js +1120 -0
  5. package/bin/__tests__/installer-safety.test.js +510 -2
  6. package/bin/__tests__/package-inventory.test.js +258 -0
  7. package/bin/__tests__/secret-scanner.test.js +157 -0
  8. package/bin/__tests__/validator-grounding.test.js +713 -0
  9. package/bin/install.js +5 -1
  10. package/bin/lib/codex-install.js +21 -6
  11. package/bin/lib/context.js +17 -6
  12. package/bin/lib/copy-utils.js +31 -0
  13. package/bin/lib/instruction-blocks.js +85 -0
  14. package/bin/lib/managed-writer.js +4 -1
  15. package/bin/lib/opencode-install.js +75 -30
  16. package/bin/phases/claude-runtime.js +103 -4
  17. package/bin/phases/codex-runtime.js +9 -5
  18. package/bin/phases/post-install.js +29 -22
  19. package/bin/phases/root-config.js +89 -10
  20. package/package.json +14 -4
  21. package/src/claude/CLAUDE.md +6 -122
  22. package/src/claude/agents/code-auditor.md +21 -22
  23. package/src/claude/agents/debugger.md +3 -3
  24. package/src/claude/agents/deployer.md +1 -1
  25. package/src/claude/agents/{god-developer.md → implementer.md} +2 -2
  26. package/src/claude/agents/project-manager.md +1 -1
  27. package/src/claude/agents/spec-maker.md +2 -2
  28. package/src/claude/hooks/__tests__/spec-gate.test.js +356 -5
  29. package/src/claude/hooks/agent.cjs +7 -14
  30. package/src/claude/hooks/rules.cjs +33 -53
  31. package/src/claude/hooks/spec-gate.cjs +66 -21
  32. package/src/claude/hooks/spec-state.cjs +5 -0
  33. package/src/claude/migration-manifest.json +9 -2
  34. package/src/claude/runtime.json +0 -3
  35. package/src/claude/scripts/generate-skill-catalog.cjs +1 -1
  36. package/src/claude/scripts/scan-staged-secrets.cjs +170 -0
  37. package/src/claude/scripts/spec-ground.cjs +189 -83
  38. package/src/claude/scripts/validate-spec-output.cjs +294 -30
  39. package/src/claude/scripts/workflow-policy.cjs +609 -0
  40. package/src/claude/skills/ai-multimodal/SKILL.md +2 -2
  41. package/src/claude/skills/ai-multimodal/references/audio-processing.md +6 -6
  42. package/src/claude/skills/ai-multimodal/references/video-analysis.md +1 -1
  43. package/src/claude/skills/backend-development/SKILL.md +4 -4
  44. package/src/claude/skills/backend-development/references/backend-architecture.md +1 -1
  45. package/src/claude/skills/backend-development/references/backend-devops.md +2 -2
  46. package/src/claude/skills/backend-development/references/backend-mindset.md +3 -3
  47. package/src/claude/skills/backend-development/references/backend-performance.md +5 -5
  48. package/src/claude/skills/backend-development/references/backend-security.md +3 -3
  49. package/src/claude/skills/backend-development/references/backend-technologies.md +5 -5
  50. package/src/claude/skills/backend-development/references/backend-testing.md +2 -2
  51. package/src/claude/skills/brainstorm/SKILL.md +2 -3
  52. package/src/claude/skills/code-review/SKILL.md +12 -8
  53. package/src/claude/skills/code-review/references/verification-gate.md +4 -4
  54. package/src/claude/skills/debug/SKILL.md +2 -0
  55. package/src/claude/skills/develop/SKILL.md +100 -52
  56. package/src/claude/skills/develop/references/parallel-waves.md +105 -26
  57. package/src/claude/skills/develop/references/quality-gate.md +58 -38
  58. package/src/claude/skills/develop/references/subagent-patterns.md +2 -2
  59. package/src/claude/skills/git/SKILL.md +44 -50
  60. package/src/claude/skills/hotfix/SKILL.md +10 -8
  61. package/src/claude/skills/hotfix/references/parallel-patterns.md +2 -2
  62. package/src/claude/skills/hotfix/references/review-cycle.md +26 -21
  63. package/src/claude/skills/inspect/SKILL.md +12 -30
  64. package/src/claude/skills/mobile-development/SKILL.md +12 -12
  65. package/src/claude/skills/mobile-development/references/mobile-android.md +7 -7
  66. package/src/claude/skills/mobile-development/references/mobile-best-practices.md +22 -23
  67. package/src/claude/skills/mobile-development/references/mobile-frameworks.md +13 -13
  68. package/src/claude/skills/mobile-development/references/mobile-ios.md +1 -1
  69. package/src/claude/skills/mobile-development/references/mobile-mindset.md +17 -19
  70. package/src/claude/skills/question/SKILL.md +13 -13
  71. package/src/claude/skills/research/SKILL.md +2 -2
  72. package/src/claude/skills/specs/SKILL.md +32 -15
  73. package/src/claude/skills/specs/references/review.md +3 -3
  74. package/src/claude/skills/specs/rules/tasks-generation.md +1 -1
  75. package/src/claude/skills/specs/templates/spec-state.json +7 -3
  76. package/src/claude/skills/sync/SKILL.md +26 -1
  77. package/src/claude/skills/sync/references/sync-protocols.md +3 -3
  78. package/src/claude/skills/test/SKILL.md +12 -4
  79. package/src/claude/skills/test/references/failure-triage.md +17 -17
  80. package/src/claude/skills/test/references/test-memory.md +2 -2
  81. package/src/codex/AGENTS.md +16 -24
  82. package/src/codex/hooks/lib/spec-receipt.cjs +57 -4
  83. package/src/codex/hooks/rules.cjs +27 -26
  84. package/src/codex/hooks/spec-gate.cjs +19 -8
  85. package/src/codex/hooks/spec-state.cjs +10 -1
  86. package/src/common/AGENTS.md +43 -0
  87. package/src/opencode/AGENTS.md +21 -121
  88. package/src/opencode/plugins/rules.ts +26 -34
  89. package/src/opencode/plugins/spec-gate.ts +283 -0
  90. package/src/claude/skills/inspect/references/external-gemini-inspection.md +0 -169
@@ -1,169 +0,0 @@
1
- # External Discovery with Gemini
2
-
3
- Use external Gemini CLI for faster searches with large context windows (1M+ tokens) when SCALE ≤ 5.
4
-
5
- ## Tool Selection
6
-
7
- ```
8
- SCALE ≤ 5 → gemini CLI
9
- SCALE ≥ 6 → Use internal discovery instead
10
- ```
11
-
12
- ## Configuration
13
-
14
- Read from `.claude/runtime.json`:
15
- ```json
16
- {
17
- "gemini": {
18
- "model": "gemma-4-31b-it"
19
- }
20
- }
21
- ```
22
-
23
- Default model: `gemma-4-31b-it`
24
-
25
- **Note:** This file is automatically installed when you run `npx @haposoft/cafekit`.
26
-
27
- ## When External Mode is Allowed
28
-
29
- External Gemini inspection requires:
30
-
31
- **Gemini-Specific Requirements:**
32
- 1. The prompt explicitly includes `ext` argument
33
- 2. SCALE ≤ 5 (calculated from estimated file count)
34
-
35
- **General Preflight Gate (applies to all modes):**
36
- 3. At least one concrete directory scope is present
37
- 4. The request is not a repo-root or root-wide scan
38
- 5. The built-in no-scan guidance has been applied
39
-
40
- If any condition fails, use internal discovery instead.
41
-
42
- ## Gemini CLI
43
-
44
- ### Command
45
- ```bash
46
- gemini -y -m <model> "[prompt]"
47
- ```
48
-
49
- ### Example
50
- ```bash
51
- gemini -y -m gemma-4-31b-it "Search src/ for authentication files. List paths with brief descriptions."
52
- ```
53
-
54
- ## Installation Check
55
-
56
- Before using, verify Gemini CLI is installed:
57
- ```bash
58
- which gemini
59
- ```
60
-
61
- If not installed, ask user:
62
- 1. **Yes** - Provide installation instructions (may need manual auth steps)
63
- 2. **No** - Fall back to internal discovery (`internal-inspection.md`)
64
-
65
- ## Running Parallel Gemini Commands
66
-
67
- Use the `Bash` tool for each scoped Gemini command. Run them in the same tool turn when the runtime supports parallel tool calls; otherwise run them sequentially. Do not use `Agent` with `subagent_type: "Bash"` — `Bash` is a tool, not a subagent.
68
-
69
- ```
70
- Bash: gemini -y -m gemma-4-31b-it '[prompt1]'
71
- Bash: gemini -y -m gemma-4-31b-it '[prompt2]'
72
- Bash: gemini -y -m gemma-4-31b-it '[prompt3]'
73
- ```
74
-
75
- Group by independent scopes so each command can return a focused report.
76
-
77
- ## Prompt Guidelines
78
-
79
- - Be specific about directories to search
80
- - Request file paths with descriptions
81
- - Set clear scope boundaries
82
- - Ask for patterns/relationships if relevant
83
- - Do not include no-scan paths
84
- - Do not request secret material or generated bundles
85
-
86
- ## Prompt Template
87
-
88
- ```text
89
- Inspect these scoped directories only:
90
- - {dir-1}
91
- - {dir-2}
92
-
93
- Goal:
94
- - {what to find}
95
-
96
- Return:
97
- 1. relevant file paths
98
- 2. one-line description per file
99
- 3. notable patterns or relationships
100
- 4. unresolved questions
101
-
102
- Do not inspect repo root, generated directories, or sensitive content.
103
- Do not expand beyond the provided scope.
104
- ```
105
-
106
- ## Example Workflow
107
-
108
- User: "Find database migration files" with `ext`
109
-
110
- Run 3 scoped Gemini CLI commands:
111
- ```
112
- Bash: gemini -y -m gemma-4-31b-it 'Search db/, migrations/ for migration files'
113
- Bash: gemini -y -m gemma-4-31b-it 'Search lib/, src/ for database schema files'
114
- Bash: gemini -y -m gemma-4-31b-it 'Search config/ for database configuration'
115
- ```
116
-
117
- ## Reading File Content
118
-
119
- When needing to read file content, use chunking to stay within context limits (<150K tokens safe zone).
120
-
121
- ### Step 1: Get Line Counts
122
- Use Read tool to check file size before reading.
123
-
124
- ### Step 2: Calculate Chunks
125
- - **Target:** ~500 lines per chunk (safe for most files)
126
- - **Max files per agent:** 3-5 small files OR 1 large file chunked
127
-
128
- **Chunking formula:**
129
- ```
130
- chunks = ceil(total_lines / 500)
131
- lines_per_chunk = ceil(total_lines / chunks)
132
- ```
133
-
134
- ### Step 3: Read Strategy
135
-
136
- **Small files (<500 lines each):**
137
- - Read entire file with Read tool
138
-
139
- **Large file (>500 lines):**
140
- - Use Read tool with offset/limit parameters
141
- - Read in 500-line chunks
142
-
143
- ### Chunking Decision Tree
144
- ```
145
- File < 500 lines → Read entire file
146
- File 500-1500 lines → Split into 2-3 chunks
147
- File > 1500 lines → Split into ceil(lines/500) chunks
148
- ```
149
-
150
- ## Timeout and Error Handling
151
-
152
- - Set 3-minute timeout per bash call
153
- - Skip timed-out agents
154
- - Don't restart failed agents
155
- - On persistent failures, fall back to internal discovery
156
-
157
- ## Fallback Behavior
158
-
159
- If Gemini is unavailable, misconfigured, or errors out:
160
- 1. Stop external mode
161
- 2. Continue with internal discovery
162
- 3. Note the fallback in the final report
163
-
164
- ## Expected Outcome
165
-
166
- - Scoped Gemini discovery
167
- - Concise file list with descriptions
168
- - Patterns and relationships
169
- - Fallback to internal mode if Gemini cannot run