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,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
@@ -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> {
@@ -5,12 +5,13 @@
5
5
  import fastGlob from 'fast-glob';
6
6
  import type { Tool, ToolResult } from '../types.js';
7
7
  import { GlobInputSchema, type GlobInput, resolvePath, getErrorMessage } from '../types.js';
8
+ import { loadToolDescription } from '../../prompts/index.js';
8
9
 
9
10
  const MAX_RESULTS = 100;
10
11
 
11
12
  export const globTool: Tool<GlobInput> = {
12
13
  name: 'Glob',
13
- description: 'Find files matching a glob pattern. Returns a list of matching file paths.',
14
+ description: loadToolDescription('glob'),
14
15
  parameters: GlobInputSchema,
15
16
 
16
17
  async execute(input, context): Promise<ToolResult> {
@@ -7,12 +7,13 @@ import * as path from 'path';
7
7
  import fastGlob from 'fast-glob';
8
8
  import type { Tool, ToolResult } from '../types.js';
9
9
  import { GrepInputSchema, type GrepInput, resolvePath, getErrorMessage } from '../types.js';
10
+ import { loadToolDescription } from '../../prompts/index.js';
10
11
 
11
12
  const MAX_MATCHES = 50;
12
13
 
13
14
  export const grepTool: Tool<GrepInput> = {
14
15
  name: 'Grep',
15
- description: 'Search for a regex pattern in files. Returns matching lines with file paths and line numbers.',
16
+ description: loadToolDescription('grep'),
16
17
  parameters: GrepInputSchema,
17
18
 
18
19
  async execute(input, context): 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 { ReadInputSchema, type ReadInput, resolvePath, getErrorMessage } from '../types.js';
8
+ import { loadToolDescription } from '../../prompts/index.js';
8
9
 
9
10
  export const readTool: Tool<ReadInput> = {
10
11
  name: 'Read',
11
- description: 'Read the contents of a file. Returns the file content with line numbers.',
12
+ description: loadToolDescription('read'),
12
13
  parameters: ReadInputSchema,
13
14
 
14
15
  async execute(input, context): Promise<ToolResult> {
@@ -0,0 +1,102 @@
1
+ /**
2
+ * TodoWrite Tool - Manage task list for tracking progress
3
+ */
4
+
5
+ import type { Tool, ToolResult, TodoItem } from '../types.js';
6
+ import { TodoWriteInputSchema, type TodoWriteInput } from '../types.js';
7
+ import { loadToolDescription } from '../../prompts/index.js';
8
+
9
+ // Global todo state - shared across tool invocations
10
+ let currentTodos: TodoItem[] = [];
11
+
12
+ /**
13
+ * Get the current todo list
14
+ */
15
+ export function getTodos(): TodoItem[] {
16
+ return [...currentTodos];
17
+ }
18
+
19
+ /**
20
+ * Clear all todos
21
+ */
22
+ export function clearTodos(): void {
23
+ currentTodos = [];
24
+ }
25
+
26
+ /**
27
+ * Format todos for display
28
+ */
29
+ function formatTodos(todos: TodoItem[]): string {
30
+ if (todos.length === 0) {
31
+ return 'Todo list is empty.';
32
+ }
33
+
34
+ const statusIcons: Record<string, string> = {
35
+ pending: '[ ]',
36
+ in_progress: '[>]',
37
+ completed: '[x]',
38
+ };
39
+
40
+ const lines = todos.map((todo, index) => {
41
+ const icon = statusIcons[todo.status] || '[ ]';
42
+ return `${index + 1}. ${icon} ${todo.content}`;
43
+ });
44
+
45
+ return lines.join('\n');
46
+ }
47
+
48
+ /**
49
+ * Validate todo list rules
50
+ */
51
+ function validateTodos(todos: TodoItem[]): string | null {
52
+ const inProgress = todos.filter((t) => t.status === 'in_progress');
53
+ if (inProgress.length > 1) {
54
+ return `Only one task should be in_progress at a time. Found ${inProgress.length} tasks in progress.`;
55
+ }
56
+ return null;
57
+ }
58
+
59
+ export const todowriteTool: Tool<TodoWriteInput> = {
60
+ name: 'TodoWrite',
61
+ description: loadToolDescription('todowrite'),
62
+ parameters: TodoWriteInputSchema,
63
+
64
+ async execute(input): Promise<ToolResult> {
65
+ try {
66
+ // Validate the todo list
67
+ const validationError = validateTodos(input.todos);
68
+ if (validationError) {
69
+ return {
70
+ success: false,
71
+ output: '',
72
+ error: validationError,
73
+ };
74
+ }
75
+
76
+ // Update the global todo state (auto-generate id if missing)
77
+ currentTodos = input.todos.map((todo, index) => ({
78
+ ...todo,
79
+ id: todo.id || `todo-${index + 1}`,
80
+ }));
81
+
82
+ // Count statistics
83
+ const pending = currentTodos.filter((t) => t.status === 'pending').length;
84
+ const inProgress = currentTodos.filter((t) => t.status === 'in_progress').length;
85
+ const completed = currentTodos.filter((t) => t.status === 'completed').length;
86
+
87
+ const summary = `Todos updated: ${completed} completed, ${inProgress} in progress, ${pending} pending`;
88
+ const formatted = formatTodos(currentTodos);
89
+
90
+ return {
91
+ success: true,
92
+ output: `${summary}\n\n${formatted}`,
93
+ };
94
+ } catch (error) {
95
+ return {
96
+ success: false,
97
+ output: '',
98
+ error: `Failed to update todos: ${error instanceof Error ? error.message : String(error)}`,
99
+ };
100
+ }
101
+ },
102
+ };
@@ -7,6 +7,7 @@ import { z } from 'zod';
7
7
  import type { Tool, ToolContext, ToolResult } from '../types.js';
8
8
  import { getErrorMessage } from '../types.js';
9
9
  import { validateUrl } from '../utils/ssrf.js';
10
+ import { loadToolDescription } from '../../prompts/index.js';
10
11
 
11
12
  // Constants
12
13
  const MAX_RESPONSE_SIZE = 5 * 1024 * 1024; // 5MB
@@ -148,11 +149,7 @@ function truncateOutput(output: string): string {
148
149
  */
149
150
  export const webfetchTool: Tool<WebFetchInput> = {
150
151
  name: 'WebFetch',
151
- description: `Fetch content from a URL and return it in the specified format.
152
- - Converts HTML to Markdown by default for easier reading
153
- - Supports text, markdown, and html output formats
154
- - Maximum response size: 5MB
155
- - Timeout: 30 seconds (configurable up to 120 seconds)`,
152
+ description: loadToolDescription('webfetch'),
156
153
  parameters: WebFetchInputSchema,
157
154
 
158
155
  async execute(input: WebFetchInput, context: ToolContext): Promise<ToolResult> {
@@ -10,6 +10,7 @@ import {
10
10
  getCurrentSearchProviderName,
11
11
  type SearchResult,
12
12
  } from '../../providers/search/index.js';
13
+ import { loadToolDescription } from '../../prompts/index.js';
13
14
 
14
15
  // Constants
15
16
  const DEFAULT_NUM_RESULTS = 10;
@@ -62,22 +63,7 @@ function formatResults(results: SearchResult[], query: string): string {
62
63
  */
63
64
  export const websearchTool: Tool<WebSearchInput> = {
64
65
  name: 'WebSearch',
65
- description: `Search the web for current information.
66
-
67
- Use this tool when you need:
68
- - Up-to-date information beyond your knowledge cutoff
69
- - Current documentation or release notes
70
- - Recent solutions to technical problems
71
- - Current best practices
72
-
73
- IMPORTANT: After answering, include a "Sources:" section with all relevant URLs as markdown hyperlinks.
74
-
75
- Example:
76
- [Your answer]
77
-
78
- Sources:
79
- - [Title 1](https://url1)
80
- - [Title 2](https://url2)`,
66
+ description: loadToolDescription('websearch'),
81
67
  parameters: WebSearchInputSchema,
82
68
 
83
69
  async execute(input: WebSearchInput, context: ToolContext): Promise<ToolResult> {
@@ -6,10 +6,11 @@ import * as fs from 'fs/promises';
6
6
  import * as path from 'path';
7
7
  import type { Tool, ToolResult } from '../types.js';
8
8
  import { WriteInputSchema, type WriteInput, resolvePath, getErrorMessage } from '../types.js';
9
+ import { loadToolDescription } from '../../prompts/index.js';
9
10
 
10
11
  export const writeTool: Tool<WriteInput> = {
11
12
  name: 'Write',
12
- description: 'Write content to a file. Creates the file if it does not exist, overwrites if it does.',
13
+ description: loadToolDescription('write'),
13
14
  parameters: WriteInputSchema,
14
15
 
15
16
  async execute(input, context): Promise<ToolResult> {
@@ -14,6 +14,7 @@ export { globTool } from './builtin/glob.js';
14
14
  export { grepTool } from './builtin/grep.js';
15
15
  export { webfetchTool } from './builtin/webfetch.js';
16
16
  export { websearchTool } from './builtin/websearch.js';
17
+ export { todowriteTool, getTodos, clearTodos } from './builtin/todowrite.js';
17
18
 
18
19
  import { ToolRegistry } from './registry.js';
19
20
  import { readTool } from './builtin/read.js';
@@ -24,6 +25,7 @@ import { globTool } from './builtin/glob.js';
24
25
  import { grepTool } from './builtin/grep.js';
25
26
  import { webfetchTool } from './builtin/webfetch.js';
26
27
  import { websearchTool } from './builtin/websearch.js';
28
+ import { todowriteTool } from './builtin/todowrite.js';
27
29
 
28
30
  /**
29
31
  * Create a registry with all built-in tools
@@ -39,6 +41,7 @@ export function createDefaultRegistry(): ToolRegistry {
39
41
  grepTool,
40
42
  webfetchTool,
41
43
  websearchTool,
44
+ todowriteTool,
42
45
  ]);
43
46
  return registry;
44
47
  }
@@ -55,4 +58,5 @@ export const builtinTools = [
55
58
  grepTool,
56
59
  webfetchTool,
57
60
  websearchTool,
61
+ todowriteTool,
58
62
  ];
@@ -108,6 +108,18 @@ export const WebFetchInputSchema = z.object({
108
108
  });
109
109
  export type WebFetchInput = z.infer<typeof WebFetchInputSchema>;
110
110
 
111
+ export const TodoItemSchema = z.object({
112
+ content: z.string().min(1).describe('The task description'),
113
+ status: z.enum(['pending', 'in_progress', 'completed']).describe('Current status of the task'),
114
+ id: z.string().optional().describe('Unique task identifier'),
115
+ });
116
+ export type TodoItem = z.infer<typeof TodoItemSchema>;
117
+
118
+ export const TodoWriteInputSchema = z.object({
119
+ todos: z.array(TodoItemSchema).describe('The complete todo list to write'),
120
+ });
121
+ export type TodoWriteInput = z.infer<typeof TodoWriteInputSchema>;
122
+
111
123
  // ============================================================================
112
124
  // JSON Schema Conversion
113
125
  // ============================================================================
package/tsconfig.json CHANGED
@@ -17,5 +17,5 @@
17
17
  "jsx": "react-jsx"
18
18
  },
19
19
  "include": ["src/**/*"],
20
- "exclude": ["node_modules", "dist", "examples"]
20
+ "exclude": ["node_modules", "dist", "examples", "**/*.test.ts"]
21
21
  }