gencode-ai 0.1.1 → 0.1.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 (263) hide show
  1. package/.gencode/settings.local.json +7 -0
  2. package/README.md +11 -11
  3. package/dist/agent/agent.d.ts +42 -1
  4. package/dist/agent/agent.d.ts.map +1 -1
  5. package/dist/agent/agent.js +82 -15
  6. package/dist/agent/agent.js.map +1 -1
  7. package/dist/cli/components/App.d.ts +8 -1
  8. package/dist/cli/components/App.d.ts.map +1 -1
  9. package/dist/cli/components/App.js +231 -29
  10. package/dist/cli/components/App.js.map +1 -1
  11. package/dist/cli/components/CommandSuggestions.d.ts.map +1 -1
  12. package/dist/cli/components/CommandSuggestions.js +2 -0
  13. package/dist/cli/components/CommandSuggestions.js.map +1 -1
  14. package/dist/cli/components/Header.d.ts +1 -1
  15. package/dist/cli/components/Header.d.ts.map +1 -1
  16. package/dist/cli/components/Header.js +4 -6
  17. package/dist/cli/components/Header.js.map +1 -1
  18. package/dist/cli/components/Logo.d.ts +1 -0
  19. package/dist/cli/components/Logo.d.ts.map +1 -1
  20. package/dist/cli/components/Logo.js +16 -3
  21. package/dist/cli/components/Logo.js.map +1 -1
  22. package/dist/cli/components/Messages.d.ts +4 -4
  23. package/dist/cli/components/Messages.d.ts.map +1 -1
  24. package/dist/cli/components/Messages.js +51 -25
  25. package/dist/cli/components/Messages.js.map +1 -1
  26. package/dist/cli/components/PermissionPrompt.d.ts +60 -0
  27. package/dist/cli/components/PermissionPrompt.d.ts.map +1 -0
  28. package/dist/cli/components/PermissionPrompt.js +192 -0
  29. package/dist/cli/components/PermissionPrompt.js.map +1 -0
  30. package/dist/cli/components/ProviderManager.js +3 -3
  31. package/dist/cli/components/ProviderManager.js.map +1 -1
  32. package/dist/cli/components/Spinner.d.ts +7 -2
  33. package/dist/cli/components/Spinner.d.ts.map +1 -1
  34. package/dist/cli/components/Spinner.js +116 -25
  35. package/dist/cli/components/Spinner.js.map +1 -1
  36. package/dist/cli/components/TodoList.d.ts +7 -0
  37. package/dist/cli/components/TodoList.d.ts.map +1 -0
  38. package/dist/cli/components/TodoList.js +34 -0
  39. package/dist/cli/components/TodoList.js.map +1 -0
  40. package/dist/cli/components/index.d.ts +1 -0
  41. package/dist/cli/components/index.d.ts.map +1 -1
  42. package/dist/cli/components/index.js +1 -0
  43. package/dist/cli/components/index.js.map +1 -1
  44. package/dist/cli/index.js +47 -7
  45. package/dist/cli/index.js.map +1 -1
  46. package/dist/config/index.d.ts +13 -4
  47. package/dist/config/index.d.ts.map +1 -1
  48. package/dist/config/index.js +18 -3
  49. package/dist/config/index.js.map +1 -1
  50. package/dist/config/levels.d.ts +49 -0
  51. package/dist/config/levels.d.ts.map +1 -0
  52. package/dist/config/levels.js +222 -0
  53. package/dist/config/levels.js.map +1 -0
  54. package/dist/config/loader.d.ts +46 -0
  55. package/dist/config/loader.d.ts.map +1 -0
  56. package/dist/config/loader.js +153 -0
  57. package/dist/config/loader.js.map +1 -0
  58. package/dist/config/manager.d.ts +115 -15
  59. package/dist/config/manager.d.ts.map +1 -1
  60. package/dist/config/manager.js +260 -34
  61. package/dist/config/manager.js.map +1 -1
  62. package/dist/config/manager.test.d.ts +5 -0
  63. package/dist/config/manager.test.d.ts.map +1 -0
  64. package/dist/config/manager.test.js +192 -0
  65. package/dist/config/manager.test.js.map +1 -0
  66. package/dist/config/merger.d.ts +56 -0
  67. package/dist/config/merger.d.ts.map +1 -0
  68. package/dist/config/merger.js +177 -0
  69. package/dist/config/merger.js.map +1 -0
  70. package/dist/config/test-utils.d.ts +24 -0
  71. package/dist/config/test-utils.d.ts.map +1 -0
  72. package/dist/config/test-utils.js +55 -0
  73. package/dist/config/test-utils.js.map +1 -0
  74. package/dist/config/types.d.ts +78 -9
  75. package/dist/config/types.d.ts.map +1 -1
  76. package/dist/config/types.js +52 -2
  77. package/dist/config/types.js.map +1 -1
  78. package/dist/memory/import-resolver.d.ts +46 -0
  79. package/dist/memory/import-resolver.d.ts.map +1 -0
  80. package/dist/memory/import-resolver.js +117 -0
  81. package/dist/memory/import-resolver.js.map +1 -0
  82. package/dist/memory/index.d.ts +7 -6
  83. package/dist/memory/index.d.ts.map +1 -1
  84. package/dist/memory/index.js +7 -5
  85. package/dist/memory/index.js.map +1 -1
  86. package/dist/memory/init-prompt.d.ts +22 -0
  87. package/dist/memory/init-prompt.d.ts.map +1 -0
  88. package/dist/memory/init-prompt.js +103 -0
  89. package/dist/memory/init-prompt.js.map +1 -0
  90. package/dist/memory/memory-manager.d.ts +119 -0
  91. package/dist/memory/memory-manager.d.ts.map +1 -0
  92. package/dist/memory/memory-manager.js +587 -0
  93. package/dist/memory/memory-manager.js.map +1 -0
  94. package/dist/memory/rules-parser.d.ts +38 -0
  95. package/dist/memory/rules-parser.d.ts.map +1 -0
  96. package/dist/memory/rules-parser.js +69 -0
  97. package/dist/memory/rules-parser.js.map +1 -0
  98. package/dist/memory/test-utils.d.ts +20 -0
  99. package/dist/memory/test-utils.d.ts.map +1 -0
  100. package/dist/memory/test-utils.js +44 -0
  101. package/dist/memory/test-utils.js.map +1 -0
  102. package/dist/memory/types.d.ts +70 -63
  103. package/dist/memory/types.d.ts.map +1 -1
  104. package/dist/memory/types.js +42 -2
  105. package/dist/memory/types.js.map +1 -1
  106. package/dist/permissions/audit.d.ts +82 -0
  107. package/dist/permissions/audit.d.ts.map +1 -0
  108. package/dist/permissions/audit.js +229 -0
  109. package/dist/permissions/audit.js.map +1 -0
  110. package/dist/permissions/index.d.ts +11 -1
  111. package/dist/permissions/index.d.ts.map +1 -1
  112. package/dist/permissions/index.js +15 -0
  113. package/dist/permissions/index.js.map +1 -1
  114. package/dist/permissions/manager.d.ts +149 -13
  115. package/dist/permissions/manager.d.ts.map +1 -1
  116. package/dist/permissions/manager.js +480 -35
  117. package/dist/permissions/manager.js.map +1 -1
  118. package/dist/permissions/manager.test.d.ts +5 -0
  119. package/dist/permissions/manager.test.d.ts.map +1 -0
  120. package/dist/permissions/manager.test.js +213 -0
  121. package/dist/permissions/manager.test.js.map +1 -0
  122. package/dist/permissions/persistence.d.ts +74 -0
  123. package/dist/permissions/persistence.d.ts.map +1 -0
  124. package/dist/permissions/persistence.js +248 -0
  125. package/dist/permissions/persistence.js.map +1 -0
  126. package/dist/permissions/persistence.test.d.ts +5 -0
  127. package/dist/permissions/persistence.test.d.ts.map +1 -0
  128. package/dist/permissions/persistence.test.js +171 -0
  129. package/dist/permissions/persistence.test.js.map +1 -0
  130. package/dist/permissions/prompt-matcher.d.ts +64 -0
  131. package/dist/permissions/prompt-matcher.d.ts.map +1 -0
  132. package/dist/permissions/prompt-matcher.js +415 -0
  133. package/dist/permissions/prompt-matcher.js.map +1 -0
  134. package/dist/permissions/prompt-matcher.test.d.ts +5 -0
  135. package/dist/permissions/prompt-matcher.test.d.ts.map +1 -0
  136. package/dist/permissions/prompt-matcher.test.js +107 -0
  137. package/dist/permissions/prompt-matcher.test.js.map +1 -0
  138. package/dist/permissions/types.d.ts +157 -0
  139. package/dist/permissions/types.d.ts.map +1 -1
  140. package/dist/permissions/types.js +43 -8
  141. package/dist/permissions/types.js.map +1 -1
  142. package/dist/prompts/index.d.ts +92 -0
  143. package/dist/prompts/index.d.ts.map +1 -0
  144. package/dist/prompts/index.js +241 -0
  145. package/dist/prompts/index.js.map +1 -0
  146. package/dist/tools/builtin/bash.d.ts.map +1 -1
  147. package/dist/tools/builtin/bash.js +2 -1
  148. package/dist/tools/builtin/bash.js.map +1 -1
  149. package/dist/tools/builtin/edit.d.ts.map +1 -1
  150. package/dist/tools/builtin/edit.js +2 -1
  151. package/dist/tools/builtin/edit.js.map +1 -1
  152. package/dist/tools/builtin/glob.d.ts.map +1 -1
  153. package/dist/tools/builtin/glob.js +2 -1
  154. package/dist/tools/builtin/glob.js.map +1 -1
  155. package/dist/tools/builtin/grep.d.ts.map +1 -1
  156. package/dist/tools/builtin/grep.js +2 -1
  157. package/dist/tools/builtin/grep.js.map +1 -1
  158. package/dist/tools/builtin/read.d.ts.map +1 -1
  159. package/dist/tools/builtin/read.js +2 -1
  160. package/dist/tools/builtin/read.js.map +1 -1
  161. package/dist/tools/builtin/todowrite.d.ts +15 -0
  162. package/dist/tools/builtin/todowrite.d.ts.map +1 -0
  163. package/dist/tools/builtin/todowrite.js +88 -0
  164. package/dist/tools/builtin/todowrite.js.map +1 -0
  165. package/dist/tools/builtin/webfetch.d.ts.map +1 -1
  166. package/dist/tools/builtin/webfetch.js +2 -5
  167. package/dist/tools/builtin/webfetch.js.map +1 -1
  168. package/dist/tools/builtin/websearch.d.ts.map +1 -1
  169. package/dist/tools/builtin/websearch.js +2 -16
  170. package/dist/tools/builtin/websearch.js.map +1 -1
  171. package/dist/tools/builtin/write.d.ts.map +1 -1
  172. package/dist/tools/builtin/write.js +2 -1
  173. package/dist/tools/builtin/write.js.map +1 -1
  174. package/dist/tools/index.d.ts +7 -0
  175. package/dist/tools/index.d.ts.map +1 -1
  176. package/dist/tools/index.js +4 -0
  177. package/dist/tools/index.js.map +1 -1
  178. package/dist/tools/types.d.ts +22 -0
  179. package/dist/tools/types.d.ts.map +1 -1
  180. package/dist/tools/types.js +8 -0
  181. package/dist/tools/types.js.map +1 -1
  182. package/docs/config-system-comparison.md +707 -0
  183. package/docs/memory-system.md +238 -0
  184. package/docs/permissions.md +368 -0
  185. package/docs/proposals/0005-todo-system.md +350 -85
  186. package/docs/proposals/0006-memory-system.md +11 -10
  187. package/docs/proposals/0012-ask-user-question.md +941 -206
  188. package/docs/proposals/0023-permission-enhancements.md +61 -2
  189. package/docs/proposals/0041-configuration-system.md +33 -2
  190. package/docs/proposals/0042-prompt-optimization.md +866 -0
  191. package/docs/proposals/README.md +6 -5
  192. package/jest.config.js +26 -0
  193. package/package.json +8 -2
  194. package/src/agent/agent.ts +111 -16
  195. package/src/cli/components/App.tsx +309 -36
  196. package/src/cli/components/CommandSuggestions.tsx +2 -0
  197. package/src/cli/components/Header.tsx +11 -17
  198. package/src/cli/components/Logo.tsx +76 -9
  199. package/src/cli/components/Messages.tsx +73 -53
  200. package/src/cli/components/PermissionPrompt.tsx +388 -0
  201. package/src/cli/components/ProviderManager.tsx +5 -5
  202. package/src/cli/components/Spinner.tsx +138 -25
  203. package/src/cli/components/TodoList.tsx +54 -0
  204. package/src/cli/components/index.ts +6 -0
  205. package/src/cli/index.tsx +54 -6
  206. package/src/config/index.ts +78 -4
  207. package/src/config/levels.test.ts +163 -0
  208. package/src/config/levels.ts +285 -0
  209. package/src/config/loader.test.ts +120 -0
  210. package/src/config/loader.ts +178 -0
  211. package/src/config/manager.test.ts +215 -0
  212. package/src/config/manager.ts +328 -40
  213. package/src/config/merger.test.ts +360 -0
  214. package/src/config/merger.ts +221 -0
  215. package/src/config/test-utils.ts +79 -0
  216. package/src/config/types.ts +152 -9
  217. package/src/memory/import-resolver.test.ts +117 -0
  218. package/src/memory/import-resolver.ts +149 -0
  219. package/src/memory/index.ts +11 -0
  220. package/src/memory/init-prompt.ts +113 -0
  221. package/src/memory/memory-manager.test.ts +198 -0
  222. package/src/memory/memory-manager.ts +716 -0
  223. package/src/memory/rules-parser.test.ts +182 -0
  224. package/src/memory/rules-parser.ts +82 -0
  225. package/src/memory/test-utils.ts +60 -0
  226. package/src/memory/types.ts +119 -0
  227. package/src/permissions/audit.ts +284 -0
  228. package/src/permissions/index.ts +20 -1
  229. package/src/permissions/manager.test.ts +260 -0
  230. package/src/permissions/manager.ts +592 -40
  231. package/src/permissions/persistence.test.ts +220 -0
  232. package/src/permissions/persistence.ts +301 -0
  233. package/src/permissions/prompt-matcher.test.ts +213 -0
  234. package/src/permissions/prompt-matcher.ts +472 -0
  235. package/src/permissions/types.ts +236 -8
  236. package/src/prompts/index.test.ts +279 -0
  237. package/src/prompts/index.ts +306 -0
  238. package/src/prompts/system/anthropic.txt +29 -0
  239. package/src/prompts/system/base.txt +124 -0
  240. package/src/prompts/system/gemini.txt +35 -0
  241. package/src/prompts/system/generic.txt +128 -0
  242. package/src/prompts/system/openai.txt +29 -0
  243. package/src/prompts/tools/bash.txt +60 -0
  244. package/src/prompts/tools/edit.txt +29 -0
  245. package/src/prompts/tools/glob.txt +35 -0
  246. package/src/prompts/tools/grep.txt +43 -0
  247. package/src/prompts/tools/read.txt +22 -0
  248. package/src/prompts/tools/todowrite.txt +71 -0
  249. package/src/prompts/tools/webfetch.txt +34 -0
  250. package/src/prompts/tools/websearch.txt +41 -0
  251. package/src/prompts/tools/write.txt +23 -0
  252. package/src/tools/builtin/bash.ts +2 -1
  253. package/src/tools/builtin/edit.ts +2 -1
  254. package/src/tools/builtin/glob.ts +2 -1
  255. package/src/tools/builtin/grep.ts +2 -1
  256. package/src/tools/builtin/read.ts +2 -1
  257. package/src/tools/builtin/todowrite.ts +102 -0
  258. package/src/tools/builtin/webfetch.ts +2 -5
  259. package/src/tools/builtin/websearch.ts +2 -16
  260. package/src/tools/builtin/write.ts +2 -1
  261. package/src/tools/index.ts +4 -0
  262. package/src/tools/types.ts +12 -0
  263. package/tsconfig.json +1 -1
@@ -0,0 +1,866 @@
1
+ # GenCode Prompt System Optimization Proposal
2
+
3
+ - **Proposal ID**: 0042
4
+ - **Author**: GenCode Team
5
+ - **Status**: Implemented
6
+ - **Created**: 2026-01-16
7
+ - **Updated**: 2026-01-16
8
+ - **Implemented**: 2026-01-16
9
+
10
+ ---
11
+
12
+ ## Table of Contents
13
+
14
+ 1. [Overview](#1-overview)
15
+ 2. [Current State Analysis](#2-current-state-analysis)
16
+ 3. [Research Findings](#3-research-findings)
17
+ 4. [Architecture Design](#4-architecture-design)
18
+ 5. [Implementation Details](#5-implementation-details)
19
+ 6. [Prompt Loading Timing](#6-prompt-loading-timing)
20
+ 7. [Provider Comparison](#7-provider-comparison)
21
+ 8. [Verification Plan](#8-verification-plan)
22
+ 9. [Future Enhancements](#9-future-enhancements)
23
+ 10. [Implementation Notes](#10-implementation-notes)
24
+ 11. [References](#11-references)
25
+
26
+ ---
27
+
28
+ ## 1. Overview
29
+
30
+ This proposal outlines a comprehensive refactoring of GenCode's prompt system based on research of production AI coding assistants including Claude Code, OpenCode, Gemini CLI, and Cursor.
31
+
32
+ ### 1.1 Goals
33
+
34
+ 1. Improve prompt effectiveness and AI response quality
35
+ 2. Establish a maintainable prompt architecture
36
+ 3. Support provider-based and model-based prompt loading
37
+ 4. Add task management capabilities
38
+
39
+ ### 1.2 Scope
40
+
41
+ - System prompt optimization
42
+ - Enhanced tool descriptions
43
+ - Provider-specific and model-specific prompt adaptations
44
+ - TodoWrite tool implementation
45
+
46
+ ---
47
+
48
+ ## 2. Current State Analysis
49
+
50
+ ### 2.1 Current GenCode Prompt System
51
+
52
+ #### 2.1.1 System Prompt (`src/agent/agent.ts`)
53
+
54
+ Currently only ~10 lines with limited guidance:
55
+
56
+ ```typescript
57
+ const DEFAULT_SYSTEM_PROMPT = `You are a helpful AI assistant...
58
+ When using tools:
59
+ - Use Read to view file contents before editing
60
+ ...
61
+ Be concise and focus on completing the user's task.`;
62
+ ```
63
+
64
+ #### 2.1.2 Tool Descriptions
65
+
66
+ Inline in TypeScript files, only 1-2 lines:
67
+
68
+ ```typescript
69
+ description: 'Read the contents of a file. Returns the file content with line numbers.',
70
+ ```
71
+
72
+ ### 2.2 Comparison Analysis
73
+
74
+ | # | Aspect | GenCode | Claude Code | OpenCode |
75
+ |---|--------|---------|-------------|----------|
76
+ | 1 | System prompt | ~10 lines | ~192 lines | ~100+ lines |
77
+ | 2 | Tool descriptions | Inline, 1-2 lines | 20-50 lines/tool | Separate `.txt` files |
78
+ | 3 | Provider adaptation | None | N/A | 5 variants |
79
+ | 4 | Examples | None | Extensive | Extensive |
80
+ | 5 | Maintainability | Low | Medium | High |
81
+
82
+ ### 2.3 Problem Summary
83
+
84
+ 1. **Insufficient Guidance**: System prompt too brief, lacking critical guidance
85
+ 2. **Sparse Tool Descriptions**: Missing usage instructions and examples
86
+ 3. **No Provider Adaptation**: All providers use the same prompt
87
+ 4. **Hard to Maintain**: Prompts inline in code, requiring recompilation
88
+ 5. **No Task Management**: Unable to track complex task progress
89
+
90
+ ---
91
+
92
+ ## 3. Research Findings
93
+
94
+ ### 3.1 Content Patterns (What to Say)
95
+
96
+ #### 3.1.1 Tone & Style
97
+
98
+ All production tools emphasize:
99
+
100
+ 1. Conciseness (fewer than 4 lines unless detailed response requested)
101
+ 2. Direct communication (no preamble/postamble)
102
+ 3. Minimal emojis (only when requested)
103
+ 4. Professional objectivity over validation
104
+
105
+ #### 3.1.2 Proactiveness Boundaries
106
+
107
+ 1. Do the right thing when asked
108
+ 2. Don't surprise users with unsolicited actions
109
+ 3. Ask for clarification rather than guessing
110
+
111
+ #### 3.1.3 Code Quality
112
+
113
+ 1. Follow existing conventions in the codebase
114
+ 2. Never assume library availability
115
+ 3. No comments unless asked
116
+ 4. Security best practices (no secrets exposure)
117
+
118
+ #### 3.1.4 Task Management
119
+
120
+ 1. Use todo tools frequently
121
+ 2. Break complex tasks into steps
122
+ 3. Mark tasks complete immediately
123
+ 4. Track only ONE task as in_progress at a time
124
+
125
+ ### 3.2 Organization Patterns (How to Structure)
126
+
127
+ #### 3.2.1 OpenCode Pattern (Recommended)
128
+
129
+ ```
130
+ src/
131
+ ├── prompts/
132
+ │ ├── system/
133
+ │ │ ├── base.txt # Common system prompt
134
+ │ │ ├── anthropic.txt # Claude-specific
135
+ │ │ ├── openai.txt # GPT-specific
136
+ │ │ └── gemini.txt # Gemini-specific
137
+ │ └── tools/
138
+ │ ├── read.txt
139
+ │ ├── bash.txt
140
+ │ └── ...
141
+ └── tools/
142
+ └── builtin/
143
+ └── read.ts # Imports from prompts/tools/read.txt
144
+ ```
145
+
146
+ #### 3.2.2 Pattern Benefits
147
+
148
+ 1. Prompts editable without code changes
149
+ 2. Easy to compare/diff prompt changes
150
+ 3. Version control friendly
151
+ 4. Supports prompt engineering iteration
152
+
153
+ ### 3.3 Tool Description Best Practices
154
+
155
+ #### 3.3.1 Effective Structure
156
+
157
+ ```
158
+ 1. Core function (1 line)
159
+ 2. Assumptions/guarantees (2-3 lines)
160
+ 3. Usage notes (bullet points)
161
+ 4. Examples for complex tools
162
+ ```
163
+
164
+ #### 3.3.2 Example Transformation
165
+
166
+ | # | Aspect | Before | After |
167
+ |---|--------|--------|-------|
168
+ | 1 | Line count | 1 line | 30-50 lines |
169
+ | 2 | Usage notes | None | Detailed bullets |
170
+ | 3 | Examples | None | Multiple examples |
171
+ | 4 | Edge cases | None | Explicitly documented |
172
+
173
+ ---
174
+
175
+ ## 4. Architecture Design
176
+
177
+ ### 4.1 Directory Structure
178
+
179
+ ```
180
+ src/prompts/
181
+ ├── index.ts # Prompt loader module
182
+ ├── system/
183
+ │ ├── base.txt # Common system prompt (~100 lines)
184
+ │ ├── anthropic.txt # Claude-specific adjustments
185
+ │ ├── openai.txt # GPT-specific adjustments
186
+ │ ├── gemini.txt # Gemini-specific adjustments
187
+ │ └── generic.txt # Fallback for unknown providers
188
+ └── tools/
189
+ ├── read.txt # ~35 lines
190
+ ├── write.txt # ~25 lines
191
+ ├── edit.txt # ~40 lines
192
+ ├── bash.txt # ~80 lines (includes git workflow)
193
+ ├── glob.txt # ~20 lines
194
+ ├── grep.txt # ~25 lines
195
+ ├── webfetch.txt # ~30 lines
196
+ ├── websearch.txt # ~35 lines
197
+ └── todowrite.txt # ~50 lines
198
+ ```
199
+
200
+ ### 4.2 Prompt Loading Strategy
201
+
202
+ The prompt loading system uses a **model → provider → prompt** flow, leveraging the `~/.gencode/providers.json` configuration to automatically determine which prompt to use.
203
+
204
+ #### 4.2.1 Loading Flow
205
+
206
+ ```
207
+ model ID (e.g., "claude-sonnet-4-5@20250929")
208
+
209
+
210
+ ┌─────────────────────────────────────┐
211
+ │ Look up provider in providers.json │
212
+ │ (search models.{provider}.list) │
213
+ └──────────────┬──────────────────────┘
214
+
215
+ ┌──────────┴──────────┐
216
+ │ Found? │
217
+ ▼ ▼
218
+ ┌────────┐ ┌─────────────┐
219
+ │ Yes │ │ No │
220
+ │ ↓ │ │ ↓ │
221
+ │ Use │ │ Use fallback│
222
+ │ provider│ │ provider or │
223
+ │ │ │ 'generic' │
224
+ └────┬───┘ └──────┬──────┘
225
+ │ │
226
+ └──────────┬──────────┘
227
+
228
+ ┌─────────────────────────────────────┐
229
+ │ Map provider → prompt type │
230
+ │ anthropic → anthropic.txt │
231
+ │ openai → openai.txt │
232
+ │ gemini → gemini.txt │
233
+ │ (other) → generic.txt │
234
+ └──────────────┬──────────────────────┘
235
+
236
+ ┌─────────────────────────────────────┐
237
+ │ Load base.txt + {provider}.txt │
238
+ │ Inject environment info │
239
+ │ Add memory context if available │
240
+ └─────────────────────────────────────┘
241
+ ```
242
+
243
+ #### 4.2.2 Provider Lookup from providers.json
244
+
245
+ The `~/.gencode/providers.json` file stores cached models for each connected provider:
246
+
247
+ ```json
248
+ {
249
+ "models": {
250
+ "anthropic": {
251
+ "list": [
252
+ { "id": "claude-sonnet-4-5@20250929", "name": "Claude Sonnet 4.5" },
253
+ { "id": "claude-opus-4-1@20250805", "name": "Claude Opus 4.1" }
254
+ ]
255
+ },
256
+ "gemini": {
257
+ "list": [
258
+ { "id": "gemini-2.5-pro", "name": "Gemini 2.5 Pro" }
259
+ ]
260
+ }
261
+ }
262
+ }
263
+ ```
264
+
265
+ Given a model ID, the system searches through each provider's model list to find the owning provider.
266
+
267
+ #### 4.2.3 Provider to Prompt Type Mapping
268
+
269
+ | # | Provider | Prompt Type | Description |
270
+ |---|----------|-------------|-------------|
271
+ | 1 | anthropic | anthropic | Claude series |
272
+ | 2 | openai | openai | GPT series |
273
+ | 3 | gemini | gemini | Gemini series |
274
+ | 4 | (unknown) | generic | Fallback for unknown providers |
275
+
276
+ #### 4.2.4 Fallback Strategy
277
+
278
+ If model lookup fails (model not in providers.json):
279
+ 1. Use the fallback provider from agent config (if provided)
280
+ 2. Otherwise, use `generic` prompt
281
+
282
+ This ensures the system always has a valid prompt to use.
283
+
284
+ ---
285
+
286
+ ## 5. Implementation Details
287
+
288
+ ### 5.1 Prompt Loader Module
289
+
290
+ **File**: `src/prompts/index.ts`
291
+
292
+ ```typescript
293
+ // 5.1.1 Provider Type Definition
294
+ export type ProviderType = 'anthropic' | 'openai' | 'gemini' | 'generic';
295
+
296
+ // 5.1.2 Look up provider for a model from ~/.gencode/providers.json
297
+ export function getProviderForModel(model: string): string | null {
298
+ const config = loadProvidersConfig();
299
+ if (!config?.models) return null;
300
+
301
+ for (const [provider, cache] of Object.entries(config.models)) {
302
+ if (cache.list?.some((m) => m.id === model)) {
303
+ return provider;
304
+ }
305
+ }
306
+ return null;
307
+ }
308
+
309
+ // 5.1.3 Map provider to prompt type
310
+ export function mapProviderToPromptType(provider: string): ProviderType {
311
+ switch (provider) {
312
+ case 'anthropic': return 'anthropic';
313
+ case 'openai': return 'openai';
314
+ case 'gemini': return 'gemini';
315
+ default: return 'generic';
316
+ }
317
+ }
318
+
319
+ // 5.1.4 Get prompt type for a model (model → provider → prompt)
320
+ export function getPromptTypeForModel(model: string, fallbackProvider?: string): ProviderType {
321
+ const provider = getProviderForModel(model);
322
+ if (provider) return mapProviderToPromptType(provider);
323
+ if (fallbackProvider) return mapProviderToPromptType(fallbackProvider);
324
+ return 'generic';
325
+ }
326
+
327
+ // 5.1.5 Build system prompt for a model (recommended API)
328
+ export function buildSystemPromptForModel(
329
+ model: string,
330
+ cwd: string,
331
+ isGitRepo: boolean = false,
332
+ memoryContext?: string,
333
+ fallbackProvider?: string
334
+ ): string {
335
+ const promptType = getPromptTypeForModel(model, fallbackProvider);
336
+ return buildSystemPromptWithMemory(promptType, cwd, isGitRepo, memoryContext);
337
+ }
338
+ ```
339
+
340
+ ### 5.2 Agent Integration
341
+
342
+ ```typescript
343
+ // In Agent.run(), build system prompt using model → provider → prompt flow
344
+ const systemPrompt = this.config.systemPrompt ??
345
+ buildSystemPromptForModel(
346
+ this.config.model, // e.g., "claude-sonnet-4-5@20250929"
347
+ this.config.cwd ?? process.cwd(),
348
+ true,
349
+ this.loadedMemory?.context,
350
+ this.config.provider // Fallback if model lookup fails
351
+ );
352
+ ```
353
+
354
+ ### 5.3 System Prompt Structure
355
+
356
+ **File**: `src/prompts/system/base.txt`
357
+
358
+ | # | Section | Lines | Content |
359
+ |---|---------|-------|---------|
360
+ | 1 | Identity & Purpose | ~5 | Define AI role |
361
+ | 2 | Tone & Style | ~15 | Conciseness, no emojis, markdown |
362
+ | 3 | Proactiveness | ~10 | Balance action vs asking |
363
+ | 4 | Following Conventions | ~15 | Code style, existing patterns |
364
+ | 5 | Task Management | ~30 | TodoWrite examples |
365
+ | 6 | Tool Usage Policy | ~20 | When to use which tool |
366
+ | 7 | Code References | ~5 | file:line format |
367
+ | 8 | Environment Info | Dynamic | Working dir, platform, date |
368
+
369
+ ### 5.4 Provider-Specific Adjustments
370
+
371
+ #### 5.4.1 anthropic.txt - Claude-Specific
372
+
373
+ 1. Extended thinking usage
374
+ 2. Parallel tool call optimization
375
+ 3. Professional objectivity emphasis
376
+ 4. Claude documentation references
377
+
378
+ #### 5.4.2 openai.txt - GPT-Specific
379
+
380
+ 1. Structured response preferences
381
+ 2. Function calling best practices
382
+ 3. Token efficiency guidelines
383
+
384
+ #### 5.4.3 gemini.txt - Gemini-Specific
385
+
386
+ 1. Multimodal capability notes
387
+ 2. Streaming response handling
388
+ 3. Context window optimization
389
+
390
+ ### 5.5 TodoWrite Tool
391
+
392
+ **File**: `src/tools/builtin/todowrite.ts`
393
+
394
+ #### 5.5.1 Input Schema
395
+
396
+ ```typescript
397
+ export const TodoItemSchema = z.object({
398
+ content: z.string().min(1).describe('Task description (imperative form)'),
399
+ status: z.enum(['pending', 'in_progress', 'completed']),
400
+ activeForm: z.string().min(1).describe('Present continuous form'),
401
+ });
402
+
403
+ export const TodoWriteInputSchema = z.object({
404
+ todos: z.array(TodoItemSchema),
405
+ });
406
+ ```
407
+
408
+ #### 5.5.2 Features
409
+
410
+ | # | Feature | Description |
411
+ |---|---------|-------------|
412
+ | 1 | State Management | pending/in_progress/completed |
413
+ | 2 | Single Task Limit | Only one in_progress at a time |
414
+ | 3 | Progress Display | Formatted output of current state |
415
+ | 4 | Validation Rules | Ensures todo list is valid |
416
+
417
+ ### 5.6 File Changes Summary
418
+
419
+ | # | File | Type | Changes |
420
+ |---|------|------|---------|
421
+ | 1 | `src/prompts/index.ts` | New | Prompt loader module |
422
+ | 2 | `src/prompts/system/base.txt` | New | Common system prompt |
423
+ | 3 | `src/prompts/system/anthropic.txt` | New | Claude-specific |
424
+ | 4 | `src/prompts/system/openai.txt` | New | GPT-specific |
425
+ | 5 | `src/prompts/system/gemini.txt` | New | Gemini-specific |
426
+ | 6 | `src/prompts/system/generic.txt` | New | Fallback for unknown providers |
427
+ | 7 | `src/prompts/tools/*.txt` | New | 9 tool descriptions |
428
+ | 8 | `src/tools/builtin/todowrite.ts` | New | TodoWrite tool |
429
+ | 9 | `src/tools/index.ts` | Modified | Export TodoWrite |
430
+ | 10 | `src/tools/types.ts` | Modified | TodoWrite schema |
431
+ | 11 | `src/tools/builtin/*.ts` | Modified | Load descriptions from .txt |
432
+ | 12 | `src/agent/agent.ts` | Modified | Use provider-specific prompts |
433
+
434
+ ---
435
+
436
+ ## 6. Prompt Loading Timing
437
+
438
+ This section documents when and how prompts are loaded during the GenCode lifecycle.
439
+
440
+ ### 6.1 Loading Sequence Diagram
441
+
442
+ ```
443
+ ┌─────────────────────────────────────────────────────────────────────────────┐
444
+ │ GenCode Startup & Prompt Loading │
445
+ └─────────────────────────────────────────────────────────────────────────────┘
446
+
447
+ User starts GenCode CLI
448
+
449
+
450
+ ┌─────────────────────┐
451
+ │ 1. CLI Initialization│
452
+ │ - Parse args │
453
+ │ - Load config │
454
+ └──────────┬──────────┘
455
+
456
+
457
+ ┌─────────────────────┐
458
+ │ 2. Agent Creation │
459
+ │ - Get model ID │
460
+ │ - Get provider │
461
+ └──────────┬──────────┘
462
+
463
+
464
+ ┌─────────────────────┐ ┌─────────────────────────────┐
465
+ │ 3. Memory Loading │────▶│ Load ~/.gencode/GENCODE.md │
466
+ │ (if exists) │ │ Load ./CLAUDE.md (fallback) │
467
+ └──────────┬──────────┘ └─────────────────────────────┘
468
+
469
+
470
+ ┌─────────────────────┐ ┌─────────────────────────────┐
471
+ │ 4. First User Input │────▶│ Triggers Agent.run() │
472
+ └──────────┬──────────┘ └─────────────────────────────┘
473
+
474
+
475
+ ┌─────────────────────────────────────────────────────────┐
476
+ │ 5. System Prompt Construction (LAZY - on first run) │
477
+ │ │
478
+ │ buildSystemPromptForModel(model, cwd, isGitRepo, │
479
+ │ memoryContext, provider) │
480
+ │ │
481
+ │ ┌─────────────────────────────────────────────────┐ │
482
+ │ │ a. getPromptTypeForModel(model, fallback) │ │
483
+ │ │ - Look up provider in ~/.gencode/providers.json│
484
+ │ │ - Map provider → prompt type │ │
485
+ │ │ - Fallback to 'generic' if not found │ │
486
+ │ └─────────────────────────────────────────────────┘ │
487
+ │ │ │
488
+ │ ▼ │
489
+ │ ┌─────────────────────────────────────────────────┐ │
490
+ │ │ b. loadSystemPrompt(promptType) │ │
491
+ │ │ - Read src/prompts/system/base.txt │ │
492
+ │ │ - Read src/prompts/system/{provider}.txt │ │
493
+ │ │ - Concatenate: base + provider │ │
494
+ │ └─────────────────────────────────────────────────┘ │
495
+ │ │ │
496
+ │ ▼ │
497
+ │ ┌─────────────────────────────────────────────────┐ │
498
+ │ │ c. Inject Environment Info │ │
499
+ │ │ - Replace {{ENVIRONMENT}} placeholder │ │
500
+ │ │ - Add cwd, platform, date, git status │ │
501
+ │ └─────────────────────────────────────────────────┘ │
502
+ │ │ │
503
+ │ ▼ │
504
+ │ ┌─────────────────────────────────────────────────┐ │
505
+ │ │ d. Append Memory Context (if loaded) │ │
506
+ │ │ - Wrap in <claudeMd> tags │ │
507
+ │ │ - Add importance instructions │ │
508
+ │ └─────────────────────────────────────────────────┘ │
509
+ └─────────────────────────────────────────────────────────┘
510
+
511
+
512
+ ┌─────────────────────────────────────────────────────────┐
513
+ │ 6. Tool Description Loading (LAZY - per tool) │
514
+ │ │
515
+ │ When tool is registered: │
516
+ │ loadToolDescription('read') │
517
+ │ → Read src/prompts/tools/read.txt │
518
+ │ → Return description string │
519
+ │ │
520
+ │ Note: Tool descriptions are loaded at import time, │
521
+ │ not at runtime. They are static after module load. │
522
+ └─────────────────────────────────────────────────────────┘
523
+
524
+
525
+ ┌─────────────────────┐
526
+ │ 7. LLM API Call │
527
+ │ - System prompt │
528
+ │ - User message │
529
+ │ - Tool definitions│
530
+ └─────────────────────┘
531
+ ```
532
+
533
+ ### 6.2 Loading Timing Summary
534
+
535
+ | # | Component | When Loaded | Cached | Notes |
536
+ |---|-----------|-------------|--------|-------|
537
+ | 1 | Tool descriptions | Module import time | Yes (static) | Loaded once when tool file is imported |
538
+ | 2 | providers.json | First prompt build | No (re-read each time) | Could be cached for performance |
539
+ | 3 | base.txt | First Agent.run() | No (re-read each time) | Allows hot-reloading during development |
540
+ | 4 | {provider}.txt | First Agent.run() | No (re-read each time) | Same as base.txt |
541
+ | 5 | Memory context | Agent creation | Yes (per session) | Loaded once at session start |
542
+ | 6 | Environment info | Each prompt build | No (dynamic) | Reflects current state |
543
+
544
+ ### 6.3 File Resolution
545
+
546
+ ```
547
+ Tool descriptions resolution:
548
+ ─────────────────────────────
549
+
550
+ Running from: Prompts loaded from:
551
+ dist/prompts/index.js ───▶ src/prompts/system/*.txt
552
+ src/prompts/tools/*.txt
553
+
554
+ This allows editing .txt files without recompiling TypeScript.
555
+ The loader checks if running from dist/ and redirects to src/.
556
+ ```
557
+
558
+ ---
559
+
560
+ ## 7. Provider Comparison
561
+
562
+ ### 7.1 Prompt Line Count Comparison
563
+
564
+ | Provider | GenCode | OpenCode | Claude Code | Notes |
565
+ |----------|---------|----------|-------------|-------|
566
+ | Base | 108 | N/A | N/A | GenCode uses base + provider pattern |
567
+ | Anthropic | 29 | 105 | 192 | OpenCode/Claude are standalone |
568
+ | OpenAI | 29 | 143 | N/A | OpenCode uses copilot-gpt-5.txt |
569
+ | Gemini | 35 | 155 | N/A | OpenCode's most detailed prompt |
570
+ | Generic | 127 | N/A | N/A | GenCode fallback for unknown providers |
571
+ | **Total (Anthropic)** | **137** | **105** | **192** | base.txt + anthropic.txt |
572
+
573
+ ### 7.2 Feature Coverage Comparison
574
+
575
+ | # | Feature | GenCode | OpenCode | Claude Code |
576
+ |---|---------|---------|----------|-------------|
577
+ | 1 | Tone & Style | ✅ | ✅ | ✅ |
578
+ | 2 | Conciseness guidance | ✅ | ✅ | ✅ |
579
+ | 3 | No emoji policy | ✅ | ✅ | ✅ |
580
+ | 4 | Proactiveness boundaries | ✅ | ✅ | ✅ |
581
+ | 5 | Code conventions | ✅ | ✅ | ✅ |
582
+ | 6 | Library verification | ✅ | ✅ | ✅ |
583
+ | 7 | Task management (TodoWrite) | ✅ | ✅ | ✅ |
584
+ | 8 | Tool usage policy | ✅ | ✅ | ✅ |
585
+ | 9 | Git safety protocol | ✅ | ✅ | ✅ |
586
+ | 10 | Code references (file:line) | ✅ | ✅ | ✅ |
587
+ | 11 | Security guidance | ✅ | ✅ | ✅ |
588
+ | 12 | New application workflow | ❌ | ✅ | ❌ |
589
+ | 13 | Extended thinking guidance | ✅ | ❌ | ❌ |
590
+ | 14 | Parallel tool optimization | ✅ | ✅ | ✅ |
591
+
592
+ ### 7.3 Provider-Specific Adaptations
593
+
594
+ When adapting prompts for different providers, consider these adjustments:
595
+
596
+ #### 7.3.1 Anthropic (Claude)
597
+
598
+ ```
599
+ Strengths to leverage:
600
+ - Extended thinking / chain-of-thought
601
+ - Parallel tool calling
602
+ - Professional objectivity
603
+ - Long context handling
604
+
605
+ Prompt adjustments:
606
+ - Emphasize thinking through complex problems
607
+ - Encourage parallel tool batching
608
+ - Reference Claude documentation for self-help
609
+ ```
610
+
611
+ #### 7.3.2 OpenAI (GPT)
612
+
613
+ ```
614
+ Strengths to leverage:
615
+ - Structured output generation
616
+ - Function calling reliability
617
+ - Code generation quality
618
+
619
+ Prompt adjustments:
620
+ - Prefer structured responses
621
+ - Use code blocks with language identifiers
622
+ - TypeScript over JavaScript when applicable
623
+ ```
624
+
625
+ #### 7.3.3 Gemini
626
+
627
+ ```
628
+ Strengths to leverage:
629
+ - Multimodal capabilities
630
+ - Large context windows
631
+ - Fast streaming responses
632
+
633
+ Prompt adjustments:
634
+ - Note image processing capability
635
+ - Emphasize structured formats (lists, tables)
636
+ - Context window optimization
637
+ ```
638
+
639
+ #### 7.3.4 Generic (Unknown Providers)
640
+
641
+ ```
642
+ Design principles:
643
+ - Comprehensive standalone guidance (no assumptions)
644
+ - All best practices included inline
645
+ - Extensive examples for clarity
646
+ - No provider-specific features assumed
647
+
648
+ The generic.txt is intentionally verbose (126 lines) to ensure
649
+ good performance with any LLM without prior knowledge of its capabilities.
650
+ ```
651
+
652
+ ### 7.4 Prompt Adaptation Notes
653
+
654
+ When adding support for new providers:
655
+
656
+ 1. **Research the model**: Understand its strengths, weaknesses, and unique features
657
+ 2. **Start from generic**: Copy generic.txt as a baseline
658
+ 3. **Add provider strengths**: Include guidance that leverages unique capabilities
659
+ 4. **Remove irrelevant sections**: Remove guidance for features the model lacks
660
+ 5. **Test extensively**: Verify with real tasks before deployment
661
+ 6. **Document differences**: Note what changed and why in this section
662
+
663
+ ---
664
+
665
+ ## 8. Verification Plan
666
+
667
+ ### 8.1 Test Matrix
668
+
669
+ | # | Test Type | Content | Status |
670
+ |---|-----------|---------|--------|
671
+ | 1 | Unit Tests | Prompt loading correctness | ⏳ |
672
+ | 2 | Integration Tests | Agent tool selection | ⏳ |
673
+ | 3 | Comparison Tests | Response quality before/after | ⏳ |
674
+ | 4 | Provider Tests | Anthropic/OpenAI/Gemini | ⏳ |
675
+ | 5 | Build Tests | TypeScript compiles without errors | ✅ |
676
+
677
+ ### 8.2 Success Metrics
678
+
679
+ | # | Metric | Target | Status |
680
+ |---|--------|--------|--------|
681
+ | 1 | Prompt file separation | `.txt` files independent | ✅ |
682
+ | 2 | System prompt coverage | All production patterns | ✅ |
683
+ | 3 | Tool description lines | 30-50 lines/tool | ✅ |
684
+ | 4 | Provider prompts | 3 variants | ✅ |
685
+ | 5 | TodoWrite tool | With detailed examples | ✅ |
686
+ | 6 | Behavior regression | No regression | ⏳ |
687
+
688
+ ---
689
+
690
+ ## 9. Future Enhancements
691
+
692
+ ### 9.1 Short-Term
693
+
694
+ | # | Task | Priority | Description |
695
+ |---|------|----------|-------------|
696
+ | 1 | Model-specific prompts | High | Add o1, Gemini 2.0 specific prompts |
697
+ | 2 | More tool examples | High | Enhance tool descriptions |
698
+ | 3 | Git workflow refinement | High | Commit/PR guidance |
699
+ | 4 | Error handling guidance | Medium | Error recovery strategies |
700
+
701
+ ### 9.2 Mid-Term
702
+
703
+ | # | Task | Priority | Description |
704
+ |---|------|----------|-------------|
705
+ | 1 | Agent subtype prompts | High | explore/plan/code agents |
706
+ | 2 | Prompt versioning | Medium | Version tracking |
707
+ | 3 | A/B testing framework | Medium | Effectiveness evaluation |
708
+
709
+ ### 9.3 Long-Term
710
+
711
+ | # | Task | Priority | Description |
712
+ |---|------|----------|-------------|
713
+ | 1 | User feedback optimization | High | Based on usage data |
714
+ | 2 | Effectiveness metrics | Medium | Quantitative evaluation |
715
+ | 3 | Automated evaluation | Low | Quality auto-detection |
716
+
717
+ ---
718
+
719
+ ## 10. Implementation Notes
720
+
721
+ ### 10.1 Files Created/Modified
722
+
723
+ | # | File | Type | Description |
724
+ |---|------|------|-------------|
725
+ | 1 | `src/prompts/index.ts` | Created | Prompt loader module with provider detection |
726
+ | 2 | `src/prompts/system/base.txt` | Created | Common system prompt (108 lines) |
727
+ | 3 | `src/prompts/system/anthropic.txt` | Created | Claude-specific adjustments (29 lines) |
728
+ | 4 | `src/prompts/system/openai.txt` | Created | GPT-specific adjustments (29 lines) |
729
+ | 5 | `src/prompts/system/gemini.txt` | Created | Gemini-specific adjustments (35 lines) |
730
+ | 6 | `src/prompts/system/generic.txt` | Created | Comprehensive fallback (126 lines) |
731
+ | 7 | `src/prompts/tools/read.txt` | Created | Read tool description |
732
+ | 8 | `src/prompts/tools/write.txt` | Created | Write tool description |
733
+ | 9 | `src/prompts/tools/edit.txt` | Created | Edit tool description |
734
+ | 10 | `src/prompts/tools/bash.txt` | Created | Bash tool description (61 lines) |
735
+ | 11 | `src/prompts/tools/glob.txt` | Created | Glob tool description |
736
+ | 12 | `src/prompts/tools/grep.txt` | Created | Grep tool description |
737
+ | 13 | `src/prompts/tools/webfetch.txt` | Created | WebFetch tool description |
738
+ | 14 | `src/prompts/tools/websearch.txt` | Created | WebSearch tool description |
739
+ | 15 | `src/prompts/tools/todowrite.txt` | Created | TodoWrite tool description (72 lines) |
740
+ | 16 | `src/tools/builtin/todowrite.ts` | Created | TodoWrite tool implementation |
741
+ | 17 | `src/tools/builtin/*.ts` | Modified | Load descriptions from .txt files |
742
+ | 18 | `src/agent/agent.ts` | Modified | Use buildSystemPromptForModel() |
743
+
744
+ ### 10.2 Key Implementation Decisions
745
+
746
+ #### 10.2.1 Base + Provider Pattern
747
+
748
+ GenCode uses a **base + provider** pattern instead of standalone provider prompts:
749
+
750
+ ```
751
+ Final Prompt = base.txt + {provider}.txt + environment + memory
752
+ ```
753
+
754
+ **Rationale**:
755
+ - Avoids duplication of common guidance across providers
756
+ - Easier to maintain consistency
757
+ - Provider files focus only on unique characteristics
758
+
759
+ #### 10.2.2 Generic Prompt Design
760
+
761
+ The `generic.txt` is intentionally verbose (126 lines) because:
762
+
763
+ 1. Unknown providers may have varying capabilities
764
+ 2. Cannot assume any specific features are available
765
+ 3. Must provide complete guidance standalone
766
+ 4. Includes extensive examples for clarity
767
+
768
+ #### 10.2.3 Lazy Loading
769
+
770
+ Prompts are loaded lazily (on first use) rather than at startup:
771
+
772
+ - Allows hot-reloading during development
773
+ - Reduces startup time
774
+ - Memory efficient (only loads what's needed)
775
+
776
+ #### 10.2.4 File Resolution for Development
777
+
778
+ The loader detects when running from `dist/` and redirects to `src/`:
779
+
780
+ ```typescript
781
+ if (__dirname.includes('/dist/')) {
782
+ const srcPath = __dirname.replace('/dist/', '/src/');
783
+ if (existsSync(srcPath)) {
784
+ return srcPath;
785
+ }
786
+ }
787
+ ```
788
+
789
+ This allows editing `.txt` files without recompiling TypeScript.
790
+
791
+ ### 10.3 Testing Results
792
+
793
+ ```bash
794
+ # Build test
795
+ npm run build # ✅ Passes
796
+
797
+ # Prompt loading test
798
+ node -e "import('./dist/prompts/index.js').then(m => console.log(m.buildSystemPrompt('anthropic', '/tmp', true).substring(0, 100)))"
799
+ # ✅ Returns system prompt correctly
800
+ ```
801
+
802
+ ### 10.4 Claude Code Essence Integration (Phase 2)
803
+
804
+ Added Claude Code's key guidance patterns to both `base.txt` and `generic.txt`:
805
+
806
+ | # | Guidance | Description |
807
+ |---|----------|-------------|
808
+ | 1 | Token minimization | "Minimize output tokens as much as possible" |
809
+ | 2 | CommonMark rendering | "Rendered in monospace font using CommonMark specification" |
810
+ | 3 | No preamble/postamble | Explicit list of forbidden phrases |
811
+ | 4 | Non-trivial command explanation | "Explain what the command does and why" |
812
+ | 5 | No preaching on refusals | "Don't say why, offer alternatives" |
813
+ | 6 | Additional examples | Added 4 more examples (2+2, golf balls, watch command, multi-turn) |
814
+
815
+ **Files modified**:
816
+ - `src/prompts/system/base.txt`: 108 → ~125 lines
817
+ - `src/prompts/system/generic.txt`: 127 → ~155 lines
818
+
819
+ ### 10.5 Known Limitations
820
+
821
+ 1. **No caching**: providers.json is re-read on each prompt build
822
+ 2. **No model-specific prompts**: Only provider-level differentiation
823
+ 3. **Static tool descriptions**: Cannot be changed at runtime
824
+ 4. **No prompt versioning**: Changes are not tracked
825
+
826
+ ---
827
+
828
+ ## 11. References
829
+
830
+ ### 11.1 Research Sources
831
+
832
+ | # | Source | Path | Key Insights |
833
+ |---|--------|------|--------------|
834
+ | 1 | Claude Code | `system-prompts-and-models-of-ai-tools/Anthropic/Claude Code/` | Tone, task management, examples |
835
+ | 2 | OpenCode | `opencode/packages/opencode/src/session/prompt/` | File organization, provider variants |
836
+ | 3 | Cursor | `system-prompts-and-models-of-ai-tools/Cursor Prompts/` | Tool definitions, agent patterns |
837
+
838
+ ### 11.2 Key Files
839
+
840
+ | # | Project | File | Lines | Purpose |
841
+ |---|---------|------|-------|---------|
842
+ | 1 | Claude Code | `Prompt.txt` | 192 | System prompt |
843
+ | 2 | OpenCode | `anthropic.txt` | 106 | Claude prompt |
844
+ | 3 | OpenCode | `bash.txt` | 116 | Bash tool description |
845
+ | 4 | OpenCode | `todowrite.txt` | 89 | Task management description |
846
+
847
+ ---
848
+
849
+ ## Appendix
850
+
851
+ ### A. Glossary
852
+
853
+ | Term | Definition |
854
+ |------|------------|
855
+ | System Prompt | Base instructions defining AI behavior |
856
+ | Tool Description | Instructions telling AI how to use a tool |
857
+ | Provider | LLM provider (Anthropic/OpenAI/Google) |
858
+ | Provider-Based Loading | Loading prompts based on the LLM provider |
859
+ | Model-Based Loading | Loading prompts based on the specific model |
860
+ | TodoWrite | Task management tool for tracking work progress |
861
+
862
+ ### B. Related Documentation
863
+
864
+ 1. [GenCode README](../../README.md)
865
+ 2. [Provider Documentation](../providers.md)
866
+ 3. [Tool Development Guide](../tools.md)