gencode-ai 0.1.1 → 0.1.3

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 (287) hide show
  1. package/.gencode/settings.local.json +7 -0
  2. package/CLAUDE.md +86 -0
  3. package/README.md +13 -16
  4. package/dist/agent/agent.d.ts +50 -1
  5. package/dist/agent/agent.d.ts.map +1 -1
  6. package/dist/agent/agent.js +96 -16
  7. package/dist/agent/agent.js.map +1 -1
  8. package/dist/agent/index.d.ts +1 -0
  9. package/dist/agent/index.d.ts.map +1 -1
  10. package/dist/agent/types.d.ts +14 -1
  11. package/dist/agent/types.d.ts.map +1 -1
  12. package/dist/cli/components/App.d.ts +8 -1
  13. package/dist/cli/components/App.d.ts.map +1 -1
  14. package/dist/cli/components/App.js +266 -29
  15. package/dist/cli/components/App.js.map +1 -1
  16. package/dist/cli/components/CommandSuggestions.d.ts.map +1 -1
  17. package/dist/cli/components/CommandSuggestions.js +2 -0
  18. package/dist/cli/components/CommandSuggestions.js.map +1 -1
  19. package/dist/cli/components/Header.d.ts +1 -1
  20. package/dist/cli/components/Header.d.ts.map +1 -1
  21. package/dist/cli/components/Header.js +4 -6
  22. package/dist/cli/components/Header.js.map +1 -1
  23. package/dist/cli/components/Logo.d.ts +1 -0
  24. package/dist/cli/components/Logo.d.ts.map +1 -1
  25. package/dist/cli/components/Logo.js +16 -3
  26. package/dist/cli/components/Logo.js.map +1 -1
  27. package/dist/cli/components/Messages.d.ts +4 -4
  28. package/dist/cli/components/Messages.d.ts.map +1 -1
  29. package/dist/cli/components/Messages.js +66 -23
  30. package/dist/cli/components/Messages.js.map +1 -1
  31. package/dist/cli/components/PermissionPrompt.d.ts +60 -0
  32. package/dist/cli/components/PermissionPrompt.d.ts.map +1 -0
  33. package/dist/cli/components/PermissionPrompt.js +192 -0
  34. package/dist/cli/components/PermissionPrompt.js.map +1 -0
  35. package/dist/cli/components/ProviderManager.js +3 -3
  36. package/dist/cli/components/ProviderManager.js.map +1 -1
  37. package/dist/cli/components/QuestionPrompt.d.ts +23 -0
  38. package/dist/cli/components/QuestionPrompt.d.ts.map +1 -0
  39. package/dist/cli/components/QuestionPrompt.js +231 -0
  40. package/dist/cli/components/QuestionPrompt.js.map +1 -0
  41. package/dist/cli/components/Spinner.d.ts +7 -2
  42. package/dist/cli/components/Spinner.d.ts.map +1 -1
  43. package/dist/cli/components/Spinner.js +116 -25
  44. package/dist/cli/components/Spinner.js.map +1 -1
  45. package/dist/cli/components/TodoList.d.ts +7 -0
  46. package/dist/cli/components/TodoList.d.ts.map +1 -0
  47. package/dist/cli/components/TodoList.js +34 -0
  48. package/dist/cli/components/TodoList.js.map +1 -0
  49. package/dist/cli/components/index.d.ts +2 -0
  50. package/dist/cli/components/index.d.ts.map +1 -1
  51. package/dist/cli/components/index.js +2 -0
  52. package/dist/cli/components/index.js.map +1 -1
  53. package/dist/cli/components/theme.d.ts +7 -0
  54. package/dist/cli/components/theme.d.ts.map +1 -1
  55. package/dist/cli/components/theme.js +11 -1
  56. package/dist/cli/components/theme.js.map +1 -1
  57. package/dist/cli/index.js +47 -7
  58. package/dist/cli/index.js.map +1 -1
  59. package/dist/config/index.d.ts +13 -4
  60. package/dist/config/index.d.ts.map +1 -1
  61. package/dist/config/index.js +18 -3
  62. package/dist/config/index.js.map +1 -1
  63. package/dist/config/levels.d.ts +49 -0
  64. package/dist/config/levels.d.ts.map +1 -0
  65. package/dist/config/levels.js +222 -0
  66. package/dist/config/levels.js.map +1 -0
  67. package/dist/config/loader.d.ts +46 -0
  68. package/dist/config/loader.d.ts.map +1 -0
  69. package/dist/config/loader.js +153 -0
  70. package/dist/config/loader.js.map +1 -0
  71. package/dist/config/manager.d.ts +115 -15
  72. package/dist/config/manager.d.ts.map +1 -1
  73. package/dist/config/manager.js +260 -34
  74. package/dist/config/manager.js.map +1 -1
  75. package/dist/config/manager.test.d.ts +5 -0
  76. package/dist/config/manager.test.d.ts.map +1 -0
  77. package/dist/config/manager.test.js +192 -0
  78. package/dist/config/manager.test.js.map +1 -0
  79. package/dist/config/merger.d.ts +56 -0
  80. package/dist/config/merger.d.ts.map +1 -0
  81. package/dist/config/merger.js +177 -0
  82. package/dist/config/merger.js.map +1 -0
  83. package/dist/config/test-utils.d.ts +24 -0
  84. package/dist/config/test-utils.d.ts.map +1 -0
  85. package/dist/config/test-utils.js +55 -0
  86. package/dist/config/test-utils.js.map +1 -0
  87. package/dist/config/types.d.ts +78 -9
  88. package/dist/config/types.d.ts.map +1 -1
  89. package/dist/config/types.js +52 -2
  90. package/dist/config/types.js.map +1 -1
  91. package/dist/memory/import-resolver.d.ts +46 -0
  92. package/dist/memory/import-resolver.d.ts.map +1 -0
  93. package/dist/memory/import-resolver.js +117 -0
  94. package/dist/memory/import-resolver.js.map +1 -0
  95. package/dist/memory/index.d.ts +7 -6
  96. package/dist/memory/index.d.ts.map +1 -1
  97. package/dist/memory/index.js +7 -5
  98. package/dist/memory/index.js.map +1 -1
  99. package/dist/memory/init-prompt.d.ts +22 -0
  100. package/dist/memory/init-prompt.d.ts.map +1 -0
  101. package/dist/memory/init-prompt.js +103 -0
  102. package/dist/memory/init-prompt.js.map +1 -0
  103. package/dist/memory/memory-manager.d.ts +119 -0
  104. package/dist/memory/memory-manager.d.ts.map +1 -0
  105. package/dist/memory/memory-manager.js +587 -0
  106. package/dist/memory/memory-manager.js.map +1 -0
  107. package/dist/memory/rules-parser.d.ts +38 -0
  108. package/dist/memory/rules-parser.d.ts.map +1 -0
  109. package/dist/memory/rules-parser.js +69 -0
  110. package/dist/memory/rules-parser.js.map +1 -0
  111. package/dist/memory/test-utils.d.ts +20 -0
  112. package/dist/memory/test-utils.d.ts.map +1 -0
  113. package/dist/memory/test-utils.js +44 -0
  114. package/dist/memory/test-utils.js.map +1 -0
  115. package/dist/memory/types.d.ts +70 -63
  116. package/dist/memory/types.d.ts.map +1 -1
  117. package/dist/memory/types.js +42 -2
  118. package/dist/memory/types.js.map +1 -1
  119. package/dist/permissions/audit.d.ts +82 -0
  120. package/dist/permissions/audit.d.ts.map +1 -0
  121. package/dist/permissions/audit.js +229 -0
  122. package/dist/permissions/audit.js.map +1 -0
  123. package/dist/permissions/index.d.ts +11 -1
  124. package/dist/permissions/index.d.ts.map +1 -1
  125. package/dist/permissions/index.js +15 -0
  126. package/dist/permissions/index.js.map +1 -1
  127. package/dist/permissions/manager.d.ts +149 -13
  128. package/dist/permissions/manager.d.ts.map +1 -1
  129. package/dist/permissions/manager.js +480 -35
  130. package/dist/permissions/manager.js.map +1 -1
  131. package/dist/permissions/manager.test.d.ts +5 -0
  132. package/dist/permissions/manager.test.d.ts.map +1 -0
  133. package/dist/permissions/manager.test.js +213 -0
  134. package/dist/permissions/manager.test.js.map +1 -0
  135. package/dist/permissions/persistence.d.ts +74 -0
  136. package/dist/permissions/persistence.d.ts.map +1 -0
  137. package/dist/permissions/persistence.js +248 -0
  138. package/dist/permissions/persistence.js.map +1 -0
  139. package/dist/permissions/persistence.test.d.ts +5 -0
  140. package/dist/permissions/persistence.test.d.ts.map +1 -0
  141. package/dist/permissions/persistence.test.js +171 -0
  142. package/dist/permissions/persistence.test.js.map +1 -0
  143. package/dist/permissions/prompt-matcher.d.ts +64 -0
  144. package/dist/permissions/prompt-matcher.d.ts.map +1 -0
  145. package/dist/permissions/prompt-matcher.js +415 -0
  146. package/dist/permissions/prompt-matcher.js.map +1 -0
  147. package/dist/permissions/prompt-matcher.test.d.ts +5 -0
  148. package/dist/permissions/prompt-matcher.test.d.ts.map +1 -0
  149. package/dist/permissions/prompt-matcher.test.js +107 -0
  150. package/dist/permissions/prompt-matcher.test.js.map +1 -0
  151. package/dist/permissions/types.d.ts +157 -0
  152. package/dist/permissions/types.d.ts.map +1 -1
  153. package/dist/permissions/types.js +45 -8
  154. package/dist/permissions/types.js.map +1 -1
  155. package/dist/prompts/index.d.ts +92 -0
  156. package/dist/prompts/index.d.ts.map +1 -0
  157. package/dist/prompts/index.js +241 -0
  158. package/dist/prompts/index.js.map +1 -0
  159. package/dist/tools/builtin/ask-user.d.ts +64 -0
  160. package/dist/tools/builtin/ask-user.d.ts.map +1 -0
  161. package/dist/tools/builtin/ask-user.js +148 -0
  162. package/dist/tools/builtin/ask-user.js.map +1 -0
  163. package/dist/tools/builtin/bash.d.ts.map +1 -1
  164. package/dist/tools/builtin/bash.js +2 -1
  165. package/dist/tools/builtin/bash.js.map +1 -1
  166. package/dist/tools/builtin/edit.d.ts.map +1 -1
  167. package/dist/tools/builtin/edit.js +2 -1
  168. package/dist/tools/builtin/edit.js.map +1 -1
  169. package/dist/tools/builtin/glob.d.ts.map +1 -1
  170. package/dist/tools/builtin/glob.js +2 -1
  171. package/dist/tools/builtin/glob.js.map +1 -1
  172. package/dist/tools/builtin/grep.d.ts.map +1 -1
  173. package/dist/tools/builtin/grep.js +2 -1
  174. package/dist/tools/builtin/grep.js.map +1 -1
  175. package/dist/tools/builtin/read.d.ts.map +1 -1
  176. package/dist/tools/builtin/read.js +2 -1
  177. package/dist/tools/builtin/read.js.map +1 -1
  178. package/dist/tools/builtin/todowrite.d.ts +15 -0
  179. package/dist/tools/builtin/todowrite.d.ts.map +1 -0
  180. package/dist/tools/builtin/todowrite.js +88 -0
  181. package/dist/tools/builtin/todowrite.js.map +1 -0
  182. package/dist/tools/builtin/webfetch.d.ts.map +1 -1
  183. package/dist/tools/builtin/webfetch.js +2 -5
  184. package/dist/tools/builtin/webfetch.js.map +1 -1
  185. package/dist/tools/builtin/websearch.d.ts.map +1 -1
  186. package/dist/tools/builtin/websearch.js +2 -16
  187. package/dist/tools/builtin/websearch.js.map +1 -1
  188. package/dist/tools/builtin/write.d.ts.map +1 -1
  189. package/dist/tools/builtin/write.js +2 -1
  190. package/dist/tools/builtin/write.js.map +1 -1
  191. package/dist/tools/index.d.ts +19 -0
  192. package/dist/tools/index.d.ts.map +1 -1
  193. package/dist/tools/index.js +8 -0
  194. package/dist/tools/index.js.map +1 -1
  195. package/dist/tools/types.d.ts +39 -0
  196. package/dist/tools/types.d.ts.map +1 -1
  197. package/dist/tools/types.js +8 -0
  198. package/dist/tools/types.js.map +1 -1
  199. package/docs/config-system-comparison.md +707 -0
  200. package/docs/memory-system.md +238 -0
  201. package/docs/permissions.md +368 -0
  202. package/docs/proposals/0005-todo-system.md +350 -85
  203. package/docs/proposals/0006-memory-system.md +11 -10
  204. package/docs/proposals/0012-ask-user-question.md +1007 -207
  205. package/docs/proposals/0023-permission-enhancements.md +61 -2
  206. package/docs/proposals/0041-configuration-system.md +33 -2
  207. package/docs/proposals/0042-prompt-optimization.md +866 -0
  208. package/docs/proposals/README.md +7 -6
  209. package/examples/test-ask-user.ts +167 -0
  210. package/jest.config.js +26 -0
  211. package/package.json +8 -2
  212. package/src/agent/agent.ts +130 -16
  213. package/src/agent/index.ts +1 -0
  214. package/src/agent/types.ts +13 -1
  215. package/src/cli/components/App.tsx +362 -37
  216. package/src/cli/components/CommandSuggestions.tsx +2 -0
  217. package/src/cli/components/Header.tsx +11 -17
  218. package/src/cli/components/Logo.tsx +76 -9
  219. package/src/cli/components/Messages.tsx +104 -41
  220. package/src/cli/components/PermissionPrompt.tsx +388 -0
  221. package/src/cli/components/ProviderManager.tsx +5 -5
  222. package/src/cli/components/QuestionPrompt.tsx +462 -0
  223. package/src/cli/components/Spinner.tsx +138 -25
  224. package/src/cli/components/TodoList.tsx +54 -0
  225. package/src/cli/components/index.ts +7 -0
  226. package/src/cli/components/theme.ts +11 -1
  227. package/src/cli/index.tsx +54 -6
  228. package/src/config/index.ts +78 -4
  229. package/src/config/levels.test.ts +163 -0
  230. package/src/config/levels.ts +285 -0
  231. package/src/config/loader.test.ts +120 -0
  232. package/src/config/loader.ts +178 -0
  233. package/src/config/manager.test.ts +215 -0
  234. package/src/config/manager.ts +328 -40
  235. package/src/config/merger.test.ts +360 -0
  236. package/src/config/merger.ts +221 -0
  237. package/src/config/test-utils.ts +79 -0
  238. package/src/config/types.ts +152 -9
  239. package/src/memory/import-resolver.test.ts +117 -0
  240. package/src/memory/import-resolver.ts +149 -0
  241. package/src/memory/index.ts +11 -0
  242. package/src/memory/init-prompt.ts +113 -0
  243. package/src/memory/memory-manager.test.ts +198 -0
  244. package/src/memory/memory-manager.ts +716 -0
  245. package/src/memory/rules-parser.test.ts +182 -0
  246. package/src/memory/rules-parser.ts +82 -0
  247. package/src/memory/test-utils.ts +60 -0
  248. package/src/memory/types.ts +119 -0
  249. package/src/permissions/audit.ts +284 -0
  250. package/src/permissions/index.ts +20 -1
  251. package/src/permissions/manager.test.ts +260 -0
  252. package/src/permissions/manager.ts +592 -40
  253. package/src/permissions/persistence.test.ts +220 -0
  254. package/src/permissions/persistence.ts +301 -0
  255. package/src/permissions/prompt-matcher.test.ts +213 -0
  256. package/src/permissions/prompt-matcher.ts +472 -0
  257. package/src/permissions/types.ts +238 -8
  258. package/src/prompts/index.test.ts +279 -0
  259. package/src/prompts/index.ts +306 -0
  260. package/src/prompts/system/anthropic.txt +29 -0
  261. package/src/prompts/system/base.txt +166 -0
  262. package/src/prompts/system/gemini.txt +35 -0
  263. package/src/prompts/system/generic.txt +128 -0
  264. package/src/prompts/system/openai.txt +29 -0
  265. package/src/prompts/tools/ask-user.txt +110 -0
  266. package/src/prompts/tools/bash.txt +60 -0
  267. package/src/prompts/tools/edit.txt +29 -0
  268. package/src/prompts/tools/glob.txt +35 -0
  269. package/src/prompts/tools/grep.txt +43 -0
  270. package/src/prompts/tools/read.txt +22 -0
  271. package/src/prompts/tools/todowrite.txt +71 -0
  272. package/src/prompts/tools/webfetch.txt +34 -0
  273. package/src/prompts/tools/websearch.txt +41 -0
  274. package/src/prompts/tools/write.txt +23 -0
  275. package/src/tools/builtin/ask-user.ts +185 -0
  276. package/src/tools/builtin/bash.ts +2 -1
  277. package/src/tools/builtin/edit.ts +2 -1
  278. package/src/tools/builtin/glob.ts +2 -1
  279. package/src/tools/builtin/grep.ts +2 -1
  280. package/src/tools/builtin/read.ts +2 -1
  281. package/src/tools/builtin/todowrite.ts +102 -0
  282. package/src/tools/builtin/webfetch.ts +2 -5
  283. package/src/tools/builtin/websearch.ts +2 -16
  284. package/src/tools/builtin/write.ts +2 -1
  285. package/src/tools/index.ts +19 -0
  286. package/src/tools/types.ts +30 -0
  287. package/tsconfig.json +1 -1
@@ -0,0 +1,110 @@
1
+ Use this tool when you need to ask the user questions during execution.
2
+
3
+ CRITICAL: You MUST use this tool for ANY question with 2+ choices. NEVER present options as plain text, numbered lists, or bullet points.
4
+
5
+ WRONG (never do this):
6
+ - "Which do you prefer? 1. Option A 2. Option B"
7
+ - "What type? - Web - CLI - API"
8
+ - Writing any numbered or bulleted choices in your response
9
+
10
+ CORRECT: Call this tool with structured questions and options.
11
+
12
+ This allows you to:
13
+ 1. Gather user preferences or requirements
14
+ 2. Clarify ambiguous instructions
15
+ 3. Get decisions on implementation choices as you work
16
+ 4. Offer choices to the user about what direction to take
17
+
18
+ ## When to Use This Tool
19
+
20
+ Use when you encounter:
21
+ - Ambiguous requirements that could be interpreted multiple ways
22
+ - Technology choices where user preference matters (database, framework, etc.)
23
+ - Implementation approaches with different trade-offs
24
+ - Features or options that should be user-selected
25
+
26
+ ## When NOT to Use This Tool
27
+
28
+ Don't use for:
29
+ - Asking "Is my plan ready?" or "Should I proceed?" - just proceed or use planning tools
30
+ - Simple yes/no confirmations - just make a reasonable choice
31
+ - Questions you can answer by reading the codebase
32
+ - Trivial implementation details
33
+
34
+ ## Usage Guidelines
35
+
36
+ - Keep headers short (max 12 chars): "Database", "Auth", "Features"
37
+ - Provide 2-4 options per question
38
+ - Put recommended option FIRST and add "(Recommended)" to its label
39
+ - Use multiSelect: true for non-mutually-exclusive options
40
+ - "Other" option is automatically added - don't include it manually
41
+ - Keep option labels concise (1-5 words)
42
+ - Descriptions should explain trade-offs or implications
43
+
44
+ ## Examples
45
+
46
+ ### Single Choice - Technology Selection
47
+ ```json
48
+ {
49
+ "questions": [{
50
+ "question": "Which database should we use?",
51
+ "header": "Database",
52
+ "options": [
53
+ { "label": "PostgreSQL (Recommended)", "description": "Robust relational DB" },
54
+ { "label": "MongoDB", "description": "Document-based NoSQL" },
55
+ { "label": "SQLite", "description": "Lightweight embedded DB" }
56
+ ],
57
+ "multiSelect": false
58
+ }]
59
+ }
60
+ ```
61
+
62
+ ### Multi-Select - Feature Selection
63
+ ```json
64
+ {
65
+ "questions": [{
66
+ "question": "Which features should we enable?",
67
+ "header": "Features",
68
+ "options": [
69
+ { "label": "TypeScript", "description": "Type safety" },
70
+ { "label": "ESLint", "description": "Code linting" },
71
+ { "label": "Testing", "description": "Unit tests" },
72
+ { "label": "Tailwind", "description": "CSS framework" }
73
+ ],
74
+ "multiSelect": true
75
+ }]
76
+ }
77
+ ```
78
+
79
+ ### Multiple Questions
80
+ ```json
81
+ {
82
+ "questions": [
83
+ {
84
+ "question": "Which auth method?",
85
+ "header": "Auth",
86
+ "options": [
87
+ { "label": "OAuth 2.0 (Recommended)", "description": "Industry standard" },
88
+ { "label": "JWT", "description": "Stateless tokens" }
89
+ ],
90
+ "multiSelect": false
91
+ },
92
+ {
93
+ "question": "Which providers to support?",
94
+ "header": "Providers",
95
+ "options": [
96
+ { "label": "Google", "description": "Most common" },
97
+ { "label": "GitHub", "description": "Developer-focused" }
98
+ ],
99
+ "multiSelect": true
100
+ }
101
+ ]
102
+ }
103
+ ```
104
+
105
+ ## Constraints
106
+
107
+ - Maximum 4 questions per call
108
+ - Maximum 4 options per question
109
+ - Header: max 12 characters
110
+ - multiSelect must be explicitly set (required, not optional)
@@ -0,0 +1,60 @@
1
+ Executes a bash command in a persistent shell session with optional timeout.
2
+
3
+ IMPORTANT: This tool is for terminal operations like git, npm, docker, etc. DO NOT use it for file operations (reading, writing, editing, searching, finding files) - use the specialized tools for those instead.
4
+
5
+ Before executing the command:
6
+
7
+ 1. Directory Verification:
8
+ - If the command will create new directories or files, first use `ls` to verify the parent directory exists
9
+ - For example, before running "mkdir foo/bar", first use `ls foo` to check that "foo" exists
10
+
11
+ 2. Command Execution:
12
+ - Always quote file paths that contain spaces with double quotes
13
+ - Examples of proper quoting:
14
+ - cd "/Users/name/My Documents" (correct)
15
+ - cd /Users/name/My Documents (incorrect - will fail)
16
+
17
+ Usage notes:
18
+ - The command argument is required
19
+ - You can specify an optional timeout in milliseconds (default: 30000, max: 600000)
20
+ - If output exceeds 30000 characters, it will be truncated
21
+
22
+ Avoid using these commands via Bash (use specialized tools instead):
23
+ - File search: Use Glob (NOT find or ls)
24
+ - Content search: Use Grep (NOT grep or rg)
25
+ - Read files: Use Read (NOT cat/head/tail)
26
+ - Edit files: Use Edit (NOT sed/awk)
27
+ - Write files: Use Write (NOT echo)
28
+
29
+ When issuing multiple commands:
30
+ - If independent, make multiple Bash calls in parallel
31
+ - If dependent, chain with && (e.g., `git add . && git commit -m "message"`)
32
+ - Use ; only when you don't care if earlier commands fail
33
+
34
+ # Git Operations
35
+
36
+ Only create commits when requested by the user. When committing:
37
+
38
+ Git Safety Protocol:
39
+ - NEVER update git config
40
+ - NEVER run destructive commands (push --force, hard reset) unless explicitly requested
41
+ - NEVER skip hooks (--no-verify) unless explicitly requested
42
+ - NEVER commit unless explicitly asked
43
+
44
+ Commit workflow:
45
+ 1. Run git status and git diff in parallel to understand changes
46
+ 2. Run git log to see recent commit message style
47
+ 3. Add relevant files and create commit
48
+ 4. Run git status to verify success
49
+
50
+ # Creating Pull Requests
51
+
52
+ Use the gh command for GitHub-related tasks. When creating PRs:
53
+ 1. Check git status and branch state
54
+ 2. Run git log and git diff to understand all changes
55
+ 3. Push to remote if needed
56
+ 4. Create PR with gh pr create
57
+
58
+ Important:
59
+ - NEVER use git commands with -i flag (interactive mode not supported)
60
+ - DO NOT push unless explicitly asked
@@ -0,0 +1,29 @@
1
+ Performs exact string replacements in files.
2
+
3
+ Usage:
4
+ - You must use the Read tool at least once before editing. This tool will error if you attempt an edit without reading the file first.
5
+ - When editing text from Read tool output, ensure you preserve the exact indentation (tabs/spaces) as it appears AFTER the line number prefix. The line number prefix format is: spaces + line number + tab. Everything after that tab is the actual file content to match. Never include any part of the line number prefix in the old_string or new_string.
6
+ - ALWAYS prefer editing existing files. NEVER write new files unless explicitly required.
7
+
8
+ Critical Rules:
9
+ - The edit will FAIL if old_string is not unique in the file
10
+ - Either provide a larger string with more surrounding context to make it unique, or use replace_all to change every instance
11
+ - Use replace_all for renaming variables or strings across the file
12
+
13
+ <example>
14
+ Changing a function name:
15
+ old_string: "function oldName("
16
+ new_string: "function newName("
17
+ </example>
18
+
19
+ <example>
20
+ Updating a variable value:
21
+ old_string: "const MAX_RETRIES = 3;"
22
+ new_string: "const MAX_RETRIES = 5;"
23
+ </example>
24
+
25
+ Best Practices:
26
+ - Include enough context to make old_string unique
27
+ - Preserve exact whitespace and indentation
28
+ - Test changes compile/work after editing
29
+ - Make minimal, focused changes
@@ -0,0 +1,35 @@
1
+ Fast file pattern matching tool that works with any codebase size.
2
+
3
+ Supports glob patterns like "**/*.js" or "src/**/*.ts".
4
+
5
+ Returns matching file paths sorted by modification time.
6
+
7
+ Usage:
8
+ - Use this tool when you need to find files by name patterns
9
+ - Supports standard glob syntax:
10
+ - * matches any characters except /
11
+ - ** matches any characters including /
12
+ - ? matches a single character
13
+ - [abc] matches any of a, b, or c
14
+ - {a,b} matches either a or b
15
+
16
+ <example>
17
+ Find all TypeScript files:
18
+ pattern: "**/*.ts"
19
+ </example>
20
+
21
+ <example>
22
+ Find test files:
23
+ pattern: "**/*.test.{ts,js}"
24
+ </example>
25
+
26
+ <example>
27
+ Find files in a specific directory:
28
+ pattern: "src/components/**/*.tsx"
29
+ </example>
30
+
31
+ Best Practices:
32
+ - Use specific patterns to narrow results
33
+ - Combine with Read to examine matching files
34
+ - Call multiple globs in parallel if searching for different patterns
35
+ - Use Grep instead if you need to search file contents
@@ -0,0 +1,43 @@
1
+ A powerful search tool for finding patterns in file contents.
2
+
3
+ Supports full regex syntax (e.g., "log.*Error", "function\\s+\\w+").
4
+
5
+ Usage:
6
+ - Use this tool for content search tasks
7
+ - NEVER invoke grep or rg as a Bash command - use this tool instead
8
+ - Filter files with glob parameter (e.g., "*.js", "**/*.tsx")
9
+ - Output modes:
10
+ - "content" shows matching lines
11
+ - "files_with_matches" shows only file paths (default)
12
+ - "count" shows match counts
13
+
14
+ <example>
15
+ Find all console.log statements:
16
+ pattern: "console\\.log"
17
+ glob: "**/*.ts"
18
+ output_mode: "content"
19
+ </example>
20
+
21
+ <example>
22
+ Find files containing a function:
23
+ pattern: "function handleSubmit"
24
+ output_mode: "files_with_matches"
25
+ </example>
26
+
27
+ <example>
28
+ Find TODO comments with context:
29
+ pattern: "TODO:"
30
+ output_mode: "content"
31
+ -C: 2 (show 2 lines before and after)
32
+ </example>
33
+
34
+ Pattern Syntax:
35
+ - Uses ripgrep syntax (not grep)
36
+ - Literal braces need escaping (use `interface\\{\\}` for `interface{}`)
37
+ - Use -i for case insensitive search
38
+ - Use multiline: true for patterns spanning multiple lines
39
+
40
+ Best Practices:
41
+ - Start with files_with_matches to find relevant files
42
+ - Then use content mode with context flags for details
43
+ - Combine with Read to see full file context
@@ -0,0 +1,22 @@
1
+ Reads a file from the local filesystem. You can access any file directly by using this tool.
2
+
3
+ Assume this tool is able to read all files on the machine. If the user provides a path to a file, assume that path is valid. It is okay to read a file that does not exist; an error will be returned.
4
+
5
+ Usage:
6
+ - The file_path parameter must be an absolute path, not a relative path
7
+ - By default, it reads up to 2000 lines starting from the beginning of the file
8
+ - You can optionally specify a line offset and limit (especially handy for long files), but it's recommended to read the whole file by not providing these parameters
9
+ - Any lines longer than 2000 characters will be truncated
10
+ - Results are returned using cat -n format, with line numbers starting at 1
11
+ - You have the capability to call multiple tools in a single response. It is always better to speculatively read multiple files as a batch that are potentially useful.
12
+ - If you read a file that exists but has empty contents you will receive a system reminder warning in place of file contents.
13
+
14
+ <example>
15
+ user: What's in config.json?
16
+ assistant: [Uses Read tool with file_path="/path/to/config.json"]
17
+ </example>
18
+
19
+ When exploring a codebase:
20
+ - Read related files together in parallel
21
+ - Start with entry points and work outward
22
+ - Use Glob/Grep first if you're unsure which files to read
@@ -0,0 +1,71 @@
1
+ Use this tool to create and manage a structured task list for your current session.
2
+
3
+ This tool serves TWO purposes:
4
+ 1. User visibility: Shows task progress in CLI so users understand what you're doing
5
+ 2. Your external memory: The rendered result helps YOU remember your plan across turns
6
+
7
+ This helps you:
8
+ - Track progress and demonstrate thoroughness to the user
9
+ - Organize complex tasks into manageable steps
10
+ - Avoid forgetting tasks in long conversations
11
+
12
+ ## When to Use This Tool
13
+
14
+ Use proactively in these scenarios:
15
+
16
+ 1. Complex multi-step tasks - When a task requires 3 or more distinct steps
17
+ 2. Non-trivial tasks - Tasks requiring careful planning or multiple operations
18
+ 3. User provides multiple tasks - Numbered or comma-separated lists
19
+ 4. After receiving instructions - Immediately capture requirements as todos
20
+ 5. When starting a task - Mark it as in_progress BEFORE beginning work
21
+ 6. After completing a task - Mark as completed and add any follow-up tasks discovered
22
+
23
+ ## When NOT to Use This Tool
24
+
25
+ Skip for:
26
+ - Single, straightforward tasks
27
+ - Trivial tasks that can be completed in under 3 steps
28
+ - Purely conversational or informational requests
29
+
30
+ ## Task States
31
+
32
+ - pending: Task not yet started
33
+ - in_progress: Currently working on (limit to ONE task at a time)
34
+ - completed: Task finished successfully
35
+
36
+ ## Task Management Rules
37
+
38
+ - Update task status in real-time as you work
39
+ - Mark tasks complete IMMEDIATELY after finishing (don't batch completions)
40
+ - Exactly ONE task should be in_progress at any time
41
+ - Complete current tasks before starting new ones
42
+ - Remove tasks that are no longer relevant
43
+
44
+ ## Completion Requirements
45
+
46
+ ONLY mark a task as completed when you have FULLY accomplished it.
47
+
48
+ Never mark completed if:
49
+ - Tests are failing
50
+ - Implementation is partial
51
+ - You encountered unresolved errors
52
+ - You couldn't find necessary files
53
+
54
+ If blocked, create a new task describing what needs to be resolved.
55
+
56
+ <example>
57
+ user: Run the build and fix any errors
58
+ assistant: Creating todo list:
59
+ 1. Run the build [in_progress]
60
+ 2. Fix any errors [pending]
61
+
62
+ Running build...
63
+
64
+ Found 3 errors. Updating todos:
65
+ 1. Run the build [completed]
66
+ 2. Fix error in auth.ts [in_progress]
67
+ 3. Fix error in api.ts [pending]
68
+ 4. Fix error in utils.ts [pending]
69
+
70
+ Starting with first error...
71
+ </example>
@@ -0,0 +1,34 @@
1
+ Fetches content from a URL and processes it.
2
+
3
+ Takes a URL and a prompt as input:
4
+ 1. Fetches the URL content
5
+ 2. Converts HTML to markdown
6
+ 3. Processes the content with the prompt using a fast model
7
+ 4. Returns the model's response about the content
8
+
9
+ Usage:
10
+ - The URL must be a fully-formed valid URL
11
+ - HTTP URLs will be automatically upgraded to HTTPS
12
+ - The prompt should describe what information you want to extract
13
+
14
+ <example>
15
+ Fetching documentation:
16
+ url: "https://docs.example.com/api"
17
+ prompt: "Extract the authentication methods and their parameters"
18
+ </example>
19
+
20
+ <example>
21
+ Reading a GitHub README:
22
+ url: "https://github.com/owner/repo"
23
+ prompt: "Summarize the project's main features and installation steps"
24
+ </example>
25
+
26
+ Behavior notes:
27
+ - Results may be summarized if content is very large
28
+ - Includes a 15-minute cache for faster repeated access
29
+ - When a URL redirects to a different host, the tool will inform you and provide the redirect URL - make a new WebFetch request with that URL
30
+
31
+ Best Practices:
32
+ - Be specific in your prompt about what information you need
33
+ - Use for documentation, tutorials, and reference material
34
+ - Combine with WebSearch to find relevant URLs first
@@ -0,0 +1,41 @@
1
+ Search the web for current information.
2
+
3
+ Use this tool when you need:
4
+ - Up-to-date information beyond your knowledge cutoff
5
+ - Current documentation or release notes
6
+ - Recent solutions to technical problems
7
+ - Current best practices
8
+
9
+ Usage:
10
+ - query: The search query (minimum 2 characters)
11
+ - num_results: Number of results to return (optional)
12
+ - allowed_domains: Only include results from these domains (optional)
13
+ - blocked_domains: Exclude results from these domains (optional)
14
+
15
+ <example>
16
+ Search for documentation:
17
+ query: "React useEffect cleanup function"
18
+ </example>
19
+
20
+ <example>
21
+ Search within specific domains:
22
+ query: "TypeScript strict mode configuration"
23
+ allowed_domains: ["typescriptlang.org", "github.com"]
24
+ </example>
25
+
26
+ IMPORTANT: After answering using search results, include a "Sources:" section with relevant URLs as markdown hyperlinks.
27
+
28
+ Example response format:
29
+ ```
30
+ [Your answer based on search results]
31
+
32
+ Sources:
33
+ - [React Documentation](https://react.dev/...)
34
+ - [Stack Overflow Answer](https://stackoverflow.com/...)
35
+ ```
36
+
37
+ Best Practices:
38
+ - Use specific, targeted queries
39
+ - Include technology versions when relevant (e.g., "React 18 hooks")
40
+ - Use allowed_domains to filter to authoritative sources
41
+ - Follow up with WebFetch for detailed page content
@@ -0,0 +1,23 @@
1
+ Writes a file to the local filesystem.
2
+
3
+ Usage:
4
+ - This tool will overwrite the existing file if there is one at the provided path
5
+ - If this is an existing file, you MUST use the Read tool first to read the file's contents. This tool will fail if you did not read the file first.
6
+ - ALWAYS prefer editing existing files in the codebase. NEVER write new files unless explicitly required.
7
+ - NEVER proactively create documentation files (*.md) or README files. Only create documentation files if explicitly requested by the user.
8
+
9
+ When to use Write vs Edit:
10
+ - Use Write for creating new files
11
+ - Use Write when you need to completely replace file contents
12
+ - Use Edit for making targeted changes to existing files
13
+ - Prefer Edit over Write for existing files as it's more precise
14
+
15
+ <example>
16
+ user: Create a new utility file
17
+ assistant: [Uses Write tool with file_path and content]
18
+ </example>
19
+
20
+ Important:
21
+ - Ensure the parent directory exists before writing
22
+ - Use appropriate file extensions
23
+ - Follow existing code style in the project
@@ -0,0 +1,185 @@
1
+ /**
2
+ * AskUserQuestion Tool - Structured user questioning
3
+ *
4
+ * Allows the agent to pause execution and present structured questions
5
+ * to the user with predefined options. Supports single-select, multi-select,
6
+ * and custom "Other" input.
7
+ */
8
+
9
+ import { z } from 'zod';
10
+ import type { Tool, ToolResult, ToolContext } from '../types.js';
11
+ import { loadToolDescription } from '../../prompts/index.js';
12
+
13
+ // ============================================================================
14
+ // Zod Schemas
15
+ // ============================================================================
16
+
17
+ export const QuestionOptionSchema = z.object({
18
+ label: z
19
+ .string()
20
+ .min(1)
21
+ .max(50)
22
+ .describe('Display text for this option (1-5 words, concise)'),
23
+ description: z
24
+ .string()
25
+ .min(1)
26
+ .max(200)
27
+ .describe('Explanation of what this option means or implications'),
28
+ });
29
+
30
+ export const QuestionSchema = z.object({
31
+ question: z
32
+ .string()
33
+ .min(1)
34
+ .describe('The complete question to ask the user, ending with a question mark'),
35
+ header: z
36
+ .string()
37
+ .min(1)
38
+ .max(12)
39
+ .describe('Very short label displayed as a chip/tag (max 12 chars)'),
40
+ options: z
41
+ .array(QuestionOptionSchema)
42
+ .min(2)
43
+ .max(4)
44
+ .describe('2-4 options for the user to choose from'),
45
+ multiSelect: z
46
+ .boolean()
47
+ .describe('Set to true to allow multiple selections, false for single choice'),
48
+ });
49
+
50
+ export const AskUserQuestionInputSchema = z.object({
51
+ questions: z
52
+ .array(QuestionSchema)
53
+ .min(1)
54
+ .max(4)
55
+ .describe('1-4 questions to ask the user'),
56
+ });
57
+
58
+ // ============================================================================
59
+ // Types
60
+ // ============================================================================
61
+
62
+ export type QuestionOption = z.infer<typeof QuestionOptionSchema>;
63
+ export type Question = z.infer<typeof QuestionSchema>;
64
+ export type AskUserQuestionInput = z.infer<typeof AskUserQuestionInputSchema>;
65
+
66
+ export interface QuestionAnswer {
67
+ question: string;
68
+ header: string;
69
+ selectedOptions: string[];
70
+ customInput?: string;
71
+ }
72
+
73
+ export interface AskUserQuestionResult {
74
+ answers: QuestionAnswer[];
75
+ }
76
+
77
+ // ============================================================================
78
+ // Answer Formatting
79
+ // ============================================================================
80
+
81
+ /**
82
+ * Format answers for display to the agent
83
+ */
84
+ export function formatAnswersForAgent(answers: QuestionAnswer[]): string {
85
+ const lines: string[] = ['User answered the following questions:', ''];
86
+
87
+ answers.forEach((answer, index) => {
88
+ lines.push(`${index + 1}. ${answer.header} (${answer.question})`);
89
+
90
+ if (answer.selectedOptions.length > 0) {
91
+ lines.push(` Selected: ${answer.selectedOptions.join(', ')}`);
92
+ }
93
+
94
+ if (answer.customInput) {
95
+ lines.push(` Custom input: ${answer.customInput}`);
96
+ }
97
+
98
+ lines.push('');
99
+ });
100
+
101
+ lines.push('Proceeding with user selections.');
102
+
103
+ return lines.join('\n');
104
+ }
105
+
106
+ /**
107
+ * Format answers for CLI confirmation display
108
+ */
109
+ export function formatAnswersForDisplay(answers: QuestionAnswer[]): string {
110
+ return answers
111
+ .map((answer) => {
112
+ const selections = answer.customInput
113
+ ? [...answer.selectedOptions, answer.customInput].join(', ')
114
+ : answer.selectedOptions.join(', ');
115
+ return `✔ ${answer.header}: ${selections}`;
116
+ })
117
+ .join('\n');
118
+ }
119
+
120
+ // ============================================================================
121
+ // Tool Implementation
122
+ // ============================================================================
123
+
124
+ /**
125
+ * AskUserQuestion tool
126
+ *
127
+ * This tool is special - it doesn't execute immediately but signals
128
+ * the agent loop to pause and wait for user input via the CLI.
129
+ *
130
+ * The actual questioning is handled by the CLI layer (QuestionPrompt component).
131
+ * This tool just validates the input and returns a marker for the agent loop.
132
+ */
133
+ export const askUserQuestionTool: Tool<AskUserQuestionInput> = {
134
+ name: 'AskUserQuestion',
135
+ description: loadToolDescription('ask-user'),
136
+ parameters: AskUserQuestionInputSchema,
137
+
138
+ async execute(input: AskUserQuestionInput, context: ToolContext): Promise<ToolResult> {
139
+ // Validation is handled by Zod schema
140
+ // Additional validation for recommended options format
141
+ for (const question of input.questions) {
142
+ // Check if first option has (Recommended) - this is just a hint, not enforced
143
+ const firstOption = question.options[0];
144
+ if (firstOption && !firstOption.label.includes('(Recommended)')) {
145
+ // This is fine - recommended suffix is optional
146
+ }
147
+ }
148
+
149
+ // Check if context has askUser callback
150
+ if (context.askUser) {
151
+ try {
152
+ const answers = await context.askUser(input.questions);
153
+ return {
154
+ success: true,
155
+ output: formatAnswersForAgent(answers),
156
+ metadata: {
157
+ title: 'AskUserQuestion',
158
+ subtitle: `${answers.length} answer(s) received`,
159
+ },
160
+ };
161
+ } catch (error) {
162
+ return {
163
+ success: false,
164
+ output: '',
165
+ error: `Failed to get user response: ${error instanceof Error ? error.message : String(error)}`,
166
+ };
167
+ }
168
+ }
169
+
170
+ // If no askUser callback, return a special marker
171
+ // The agent loop should detect this and handle it specially
172
+ return {
173
+ success: true,
174
+ output: JSON.stringify({
175
+ type: 'ask_user_question',
176
+ questions: input.questions,
177
+ requiresUserInput: true,
178
+ }),
179
+ metadata: {
180
+ title: 'AskUserQuestion',
181
+ subtitle: `${input.questions.length} question(s) pending`,
182
+ },
183
+ };
184
+ },
185
+ };
@@ -5,10 +5,11 @@
5
5
  import { spawn } from 'child_process';
6
6
  import type { Tool, ToolContext, ToolResult } from '../types.js';
7
7
  import { BashInputSchema, type BashInput } from '../types.js';
8
+ import { loadToolDescription } from '../../prompts/index.js';
8
9
 
9
10
  export const bashTool: Tool<BashInput> = {
10
11
  name: 'Bash',
11
- description: 'Execute a bash command and return its output. Use for running scripts, git commands, npm, etc.',
12
+ description: loadToolDescription('bash'),
12
13
  parameters: BashInputSchema,
13
14
 
14
15
  async execute(input: BashInput, context: ToolContext): Promise<ToolResult> {
@@ -5,10 +5,11 @@
5
5
  import * as fs from 'fs/promises';
6
6
  import type { Tool, ToolResult } from '../types.js';
7
7
  import { EditInputSchema, type EditInput, resolvePath, getErrorMessage } from '../types.js';
8
+ import { loadToolDescription } from '../../prompts/index.js';
8
9
 
9
10
  export const editTool: Tool<EditInput> = {
10
11
  name: 'Edit',
11
- description: 'Edit a file by replacing a specific string with another. The old_string must be unique in the file.',
12
+ description: loadToolDescription('edit'),
12
13
  parameters: EditInputSchema,
13
14
 
14
15
  async execute(input, context): Promise<ToolResult> {