@kkelly-offical/kkcode 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 (196) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +445 -0
  3. package/package.json +46 -0
  4. package/src/agent/agent.mjs +170 -0
  5. package/src/agent/custom-agent-loader.mjs +158 -0
  6. package/src/agent/generator.mjs +115 -0
  7. package/src/agent/prompt/architect.txt +36 -0
  8. package/src/agent/prompt/build-fixer.txt +71 -0
  9. package/src/agent/prompt/build.txt +101 -0
  10. package/src/agent/prompt/compaction.txt +12 -0
  11. package/src/agent/prompt/explore.txt +29 -0
  12. package/src/agent/prompt/guide.txt +40 -0
  13. package/src/agent/prompt/longagent.txt +178 -0
  14. package/src/agent/prompt/plan.txt +50 -0
  15. package/src/agent/prompt/researcher.txt +23 -0
  16. package/src/agent/prompt/reviewer.txt +44 -0
  17. package/src/agent/prompt/security-reviewer.txt +62 -0
  18. package/src/agent/prompt/tdd-guide.txt +84 -0
  19. package/src/agent/prompt/title.txt +8 -0
  20. package/src/command/custom-commands.mjs +57 -0
  21. package/src/commands/agent.mjs +71 -0
  22. package/src/commands/audit.mjs +77 -0
  23. package/src/commands/background.mjs +86 -0
  24. package/src/commands/chat.mjs +114 -0
  25. package/src/commands/command.mjs +41 -0
  26. package/src/commands/config.mjs +44 -0
  27. package/src/commands/doctor.mjs +148 -0
  28. package/src/commands/hook.mjs +29 -0
  29. package/src/commands/init.mjs +141 -0
  30. package/src/commands/longagent.mjs +100 -0
  31. package/src/commands/mcp.mjs +89 -0
  32. package/src/commands/permission.mjs +36 -0
  33. package/src/commands/prompt.mjs +42 -0
  34. package/src/commands/review.mjs +266 -0
  35. package/src/commands/rule.mjs +34 -0
  36. package/src/commands/session.mjs +235 -0
  37. package/src/commands/theme.mjs +98 -0
  38. package/src/commands/usage.mjs +91 -0
  39. package/src/config/defaults.mjs +195 -0
  40. package/src/config/import-config.mjs +76 -0
  41. package/src/config/load-config.mjs +76 -0
  42. package/src/config/schema.mjs +509 -0
  43. package/src/context.mjs +40 -0
  44. package/src/core/constants.mjs +46 -0
  45. package/src/core/errors.mjs +57 -0
  46. package/src/core/events.mjs +29 -0
  47. package/src/core/types.mjs +57 -0
  48. package/src/github/api.mjs +78 -0
  49. package/src/github/auth.mjs +286 -0
  50. package/src/github/flow.mjs +298 -0
  51. package/src/github/workspace.mjs +212 -0
  52. package/src/index.mjs +82 -0
  53. package/src/knowledge/api-design.txt +9 -0
  54. package/src/knowledge/cpp.txt +10 -0
  55. package/src/knowledge/docker.txt +10 -0
  56. package/src/knowledge/dotnet.txt +9 -0
  57. package/src/knowledge/electron.txt +10 -0
  58. package/src/knowledge/flutter.txt +10 -0
  59. package/src/knowledge/go.txt +9 -0
  60. package/src/knowledge/graphql.txt +10 -0
  61. package/src/knowledge/java.txt +9 -0
  62. package/src/knowledge/kotlin.txt +10 -0
  63. package/src/knowledge/loader.mjs +125 -0
  64. package/src/knowledge/next.txt +8 -0
  65. package/src/knowledge/node.txt +8 -0
  66. package/src/knowledge/nuxt.txt +9 -0
  67. package/src/knowledge/php.txt +10 -0
  68. package/src/knowledge/python.txt +10 -0
  69. package/src/knowledge/react-native.txt +10 -0
  70. package/src/knowledge/react.txt +9 -0
  71. package/src/knowledge/ruby.txt +11 -0
  72. package/src/knowledge/rust.txt +9 -0
  73. package/src/knowledge/svelte.txt +9 -0
  74. package/src/knowledge/swift.txt +10 -0
  75. package/src/knowledge/tailwind.txt +10 -0
  76. package/src/knowledge/testing.txt +8 -0
  77. package/src/knowledge/typescript.txt +8 -0
  78. package/src/knowledge/vue.txt +9 -0
  79. package/src/mcp/client-http.mjs +157 -0
  80. package/src/mcp/client-sse.mjs +286 -0
  81. package/src/mcp/client-stdio.mjs +451 -0
  82. package/src/mcp/registry.mjs +394 -0
  83. package/src/mcp/stdio-framing.mjs +127 -0
  84. package/src/orchestration/background-manager.mjs +358 -0
  85. package/src/orchestration/background-worker.mjs +245 -0
  86. package/src/orchestration/longagent-manager.mjs +116 -0
  87. package/src/orchestration/stage-scheduler.mjs +489 -0
  88. package/src/orchestration/subagent-router.mjs +62 -0
  89. package/src/orchestration/task-scheduler.mjs +74 -0
  90. package/src/permission/engine.mjs +92 -0
  91. package/src/permission/exec-policy.mjs +372 -0
  92. package/src/permission/prompt.mjs +39 -0
  93. package/src/permission/rules.mjs +120 -0
  94. package/src/permission/workspace-trust.mjs +44 -0
  95. package/src/plugin/builtin-hooks/console-warn.mjs +41 -0
  96. package/src/plugin/builtin-hooks/extract-patterns.mjs +75 -0
  97. package/src/plugin/builtin-hooks/post-edit-format.mjs +57 -0
  98. package/src/plugin/builtin-hooks/post-edit-typecheck.mjs +61 -0
  99. package/src/plugin/builtin-hooks/strategic-compaction.mjs +38 -0
  100. package/src/plugin/hook-bus.mjs +154 -0
  101. package/src/provider/anthropic.mjs +389 -0
  102. package/src/provider/ollama.mjs +236 -0
  103. package/src/provider/openai-compatible.mjs +1 -0
  104. package/src/provider/openai.mjs +339 -0
  105. package/src/provider/retry-policy.mjs +68 -0
  106. package/src/provider/router.mjs +228 -0
  107. package/src/provider/sse.mjs +91 -0
  108. package/src/repl.mjs +2929 -0
  109. package/src/review/diff-parser.mjs +36 -0
  110. package/src/review/rejection-queue.mjs +62 -0
  111. package/src/review/review-store.mjs +21 -0
  112. package/src/review/risk-score.mjs +61 -0
  113. package/src/rules/load-rules.mjs +64 -0
  114. package/src/runtime.mjs +1 -0
  115. package/src/session/checkpoint.mjs +239 -0
  116. package/src/session/compaction.mjs +276 -0
  117. package/src/session/engine.mjs +225 -0
  118. package/src/session/instinct-manager.mjs +172 -0
  119. package/src/session/instruction-loader.mjs +25 -0
  120. package/src/session/longagent-plan.mjs +329 -0
  121. package/src/session/longagent-scaffold.mjs +100 -0
  122. package/src/session/longagent.mjs +1462 -0
  123. package/src/session/loop.mjs +905 -0
  124. package/src/session/memory-loader.mjs +75 -0
  125. package/src/session/project-context.mjs +367 -0
  126. package/src/session/prompt/anthropic.txt +151 -0
  127. package/src/session/prompt/beast.txt +37 -0
  128. package/src/session/prompt/max-steps.txt +6 -0
  129. package/src/session/prompt/plan.txt +9 -0
  130. package/src/session/prompt/qwen.txt +46 -0
  131. package/src/session/prompt-loader.mjs +18 -0
  132. package/src/session/recovery.mjs +52 -0
  133. package/src/session/store.mjs +503 -0
  134. package/src/session/system-prompt.mjs +260 -0
  135. package/src/session/task-validator.mjs +266 -0
  136. package/src/session/usability-gates.mjs +379 -0
  137. package/src/skill/builtin/backend-patterns.mjs +123 -0
  138. package/src/skill/builtin/commit.mjs +64 -0
  139. package/src/skill/builtin/debug.mjs +45 -0
  140. package/src/skill/builtin/frontend-patterns.mjs +120 -0
  141. package/src/skill/builtin/frontend.mjs +188 -0
  142. package/src/skill/builtin/init.mjs +220 -0
  143. package/src/skill/builtin/review.mjs +49 -0
  144. package/src/skill/builtin/security-checklist.mjs +80 -0
  145. package/src/skill/builtin/tdd.mjs +54 -0
  146. package/src/skill/generator.mjs +113 -0
  147. package/src/skill/registry.mjs +336 -0
  148. package/src/storage/audit-store.mjs +83 -0
  149. package/src/storage/event-log.mjs +82 -0
  150. package/src/storage/ghost-commit-store.mjs +235 -0
  151. package/src/storage/json-store.mjs +53 -0
  152. package/src/storage/paths.mjs +148 -0
  153. package/src/theme/color.mjs +64 -0
  154. package/src/theme/default-theme.mjs +29 -0
  155. package/src/theme/load-theme.mjs +71 -0
  156. package/src/theme/markdown.mjs +135 -0
  157. package/src/theme/schema.mjs +45 -0
  158. package/src/theme/status-bar.mjs +158 -0
  159. package/src/tool/audit-wrapper.mjs +38 -0
  160. package/src/tool/edit-transaction.mjs +126 -0
  161. package/src/tool/executor.mjs +109 -0
  162. package/src/tool/file-lock-manager.mjs +85 -0
  163. package/src/tool/git-auto.mjs +545 -0
  164. package/src/tool/git-full-auto.mjs +478 -0
  165. package/src/tool/image-util.mjs +276 -0
  166. package/src/tool/prompt/background_cancel.txt +1 -0
  167. package/src/tool/prompt/background_output.txt +1 -0
  168. package/src/tool/prompt/bash.txt +71 -0
  169. package/src/tool/prompt/codesearch.txt +18 -0
  170. package/src/tool/prompt/edit.txt +27 -0
  171. package/src/tool/prompt/enter_plan.txt +74 -0
  172. package/src/tool/prompt/exit_plan.txt +62 -0
  173. package/src/tool/prompt/glob.txt +33 -0
  174. package/src/tool/prompt/grep.txt +43 -0
  175. package/src/tool/prompt/list.txt +8 -0
  176. package/src/tool/prompt/multiedit.txt +20 -0
  177. package/src/tool/prompt/notebookedit.txt +21 -0
  178. package/src/tool/prompt/patch.txt +24 -0
  179. package/src/tool/prompt/question.txt +44 -0
  180. package/src/tool/prompt/read.txt +40 -0
  181. package/src/tool/prompt/task.txt +83 -0
  182. package/src/tool/prompt/todowrite.txt +117 -0
  183. package/src/tool/prompt/webfetch.txt +38 -0
  184. package/src/tool/prompt/websearch.txt +43 -0
  185. package/src/tool/prompt/write.txt +38 -0
  186. package/src/tool/prompt-loader.mjs +18 -0
  187. package/src/tool/question-prompt.mjs +86 -0
  188. package/src/tool/registry.mjs +1309 -0
  189. package/src/tool/task-tool.mjs +28 -0
  190. package/src/ui/activity-renderer.mjs +410 -0
  191. package/src/ui/repl-dashboard.mjs +357 -0
  192. package/src/usage/pricing.mjs +121 -0
  193. package/src/usage/usage-meter.mjs +113 -0
  194. package/src/util/git.mjs +496 -0
  195. package/src/util/template.mjs +10 -0
  196. package/src/util/yaml.mjs +100 -0
@@ -0,0 +1,24 @@
1
+ Replace a range of lines in a file by line number. Transactional with automatic rollback.
2
+
3
+ Usage:
4
+ - You MUST `read` the file first — patches on unread files are rejected.
5
+ - Use `read` with offset/limit to view the relevant section, note line numbers, then call `patch`.
6
+ - Lines are 1-based and the range is inclusive (both start_line and end_line are replaced).
7
+ - To delete lines without replacement, pass content as empty string "".
8
+
9
+ Parameters:
10
+ - path (required): file path
11
+ - start_line (required): first line to replace (1-based, inclusive)
12
+ - end_line (required): last line to replace (1-based, inclusive)
13
+ - content (required): replacement text (replaces the entire line range)
14
+
15
+ When to use `patch` vs `edit`:
16
+ - You know exact line numbers from a recent `read` → use `patch`
17
+ - You know exact text to match but not line numbers → use `edit`
18
+ - You need to replace many occurrences of a string → use `edit` with replace_all
19
+ - You want to replace a large section (50+ lines) → use `patch` (only needs new content, not old)
20
+
21
+ Workflow for large file modifications:
22
+ 1. `read` the file (or section with offset/limit)
23
+ 2. Note the line numbers of the section to change
24
+ 3. Call `patch` with start_line, end_line, and new content
@@ -0,0 +1,44 @@
1
+ Ask the user one or more structured questions during execution. Use when you need user input to proceed.
2
+
3
+ ## When to Use
4
+
5
+ - Gather user preferences or requirements
6
+ - Clarify ambiguous instructions
7
+ - Get decisions on implementation choices as you work
8
+ - Offer choices about what direction to take
9
+
10
+ <example>
11
+ You're implementing a caching layer but unsure which strategy the user prefers:
12
+ → question(questions=[{id: "cache", text: "Which caching strategy should we use?", options: [{label: "Redis (Recommended)", description: "Distributed cache, best for multi-server"}, {label: "In-memory", description: "Simple, single-server only"}, {label: "File-based", description: "Persistent, slower"}]}])
13
+ </example>
14
+
15
+ <example>
16
+ User says "fix the bug" but there are multiple potential issues:
17
+ → question(questions=[{id: "bug", text: "Which issue should I fix first?", options: [{label: "Auth timeout", description: "Users get logged out after 5 minutes"}, {label: "API 500 error", description: "POST /users returns 500 on duplicate email"}]}])
18
+ </example>
19
+
20
+ ## When NOT to Use
21
+
22
+ - Do NOT use this to ask "Is my plan ready?" or "Should I proceed?" — use `exit_plan` for plan approval.
23
+ - Do NOT use this for trivial confirmations that don't affect the outcome.
24
+ - If you can reasonably infer the answer from context, just proceed.
25
+
26
+ ## Parameters
27
+
28
+ - questions (required): array of question objects (1-4 questions per call)
29
+ - id (required): unique question identifier
30
+ - text (required): the complete question text (should end with ?)
31
+ - description (optional): supplementary explanation
32
+ - options (optional): array of predefined choices (2-4 options)
33
+ - label (required): display text (concise, 1-5 words). If you recommend a specific option, list it first and add "(Recommended)" to its label.
34
+ - value (optional): option value (defaults to label)
35
+ - description (optional): explanation of what this option means or what will happen if chosen
36
+ - multi (optional, default false): allow multiple selections. Use when choices are not mutually exclusive.
37
+ - allowCustom (optional, default true): allow custom text input
38
+
39
+ ## Tips
40
+
41
+ - Users will always be able to provide custom text input regardless of options
42
+ - Keep option labels concise and clearly distinct from each other
43
+ - When you have 2-4 distinct approaches, use options. When the answer is open-ended, skip options.
44
+ - In plan mode, use this tool to clarify requirements BEFORE finalizing your plan. Do NOT use this to ask "Is my plan ready?" — use `exit_plan` for that.
@@ -0,0 +1,40 @@
1
+ Reads a file from the local filesystem. You can access any file directly by using this tool.
2
+ 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.
3
+
4
+ ## Usage
5
+
6
+ - The path parameter can be absolute or relative to the working directory.
7
+ - By default, it reads up to 2000 lines starting from the beginning of the file. You can optionally specify offset and limit for large files.
8
+ - Any lines longer than 2000 characters will be truncated.
9
+ - Results are returned with line numbers in " 1→content" format.
10
+
11
+ ## File Type Support
12
+
13
+ - **Text files**: All text files are read with line numbers. This is the default behavior.
14
+ - **Image files** (PNG, JPG, GIF, SVG, WebP, BMP, ICO): Returns a base64-encoded data URI that can be visually analyzed. Use this when the user asks you to look at a screenshot or image.
15
+ - **PDF files** (.pdf): Extracts text content from PDF pages. For large PDFs (10+ pages), use the `pages` parameter to read specific page ranges (e.g. pages="1-5"). Maximum 20 pages per request.
16
+ - **Jupyter notebooks** (.ipynb): Parses the notebook JSON and returns all cells with their type, source, and outputs in a readable format. Combines code, text, and output for easy understanding.
17
+
18
+ ## Critical Rules
19
+
20
+ - ALWAYS use `read` to view files. NEVER use `bash` with cat/head/tail/type/Get-Content.
21
+ - You MUST read a file before editing it with `edit`. Edits on unread files are rejected.
22
+ - You can call multiple `read` tools in a single response. It is always better to speculatively read multiple potentially useful files in parallel.
23
+ - If the user provides a path to a screenshot, ALWAYS use this tool to view the file at that path.
24
+
25
+ ## Parameters
26
+
27
+ - path (required): file path (absolute or relative)
28
+ - offset (optional): start line number (1-based). Only provide if the file is too large to read at once.
29
+ - limit (optional): max lines to return. Only provide if the file is too large to read at once.
30
+ - encoding (optional): file encoding (default: utf8)
31
+ - pages (optional): page range for PDF files (e.g. "1-5", "3", "10-20"). Only applicable to PDF files.
32
+
33
+ ## Tips
34
+
35
+ - Read the full file first to understand context before editing. Do not provide offset/limit unless necessary.
36
+ - For large files (1000+ lines), use offset+limit to read specific sections.
37
+ - After a failed edit, re-read the file — it may have changed since your last read.
38
+ - Line numbers in output help you locate exact positions for edits.
39
+ - When reading multiple related files, read them all in parallel for efficiency.
40
+ - When editing text from read output, preserve the exact indentation (tabs/spaces) as it appears AFTER the line number prefix. The line number prefix format is: spaces + line number + →. Everything after that → is the actual file content to match. Never include any part of the line number prefix in edit operations.
@@ -0,0 +1,83 @@
1
+ Launch a subagent to handle complex, multi-step tasks autonomously.
2
+
3
+ Each task spawns a full, independent LLM session with its own context window. The subagent makes its own tool calls and returns a single result message when done.
4
+
5
+ # Available subagent types
6
+
7
+ - **explore** — Fast codebase exploration specialist. Use for: finding files by patterns, searching code for keywords, understanding project structure, tracing import/export chains, answering questions about the codebase. Read-only. (Tools: read, glob, grep, list, bash)
8
+ - **architect** — Feature architecture designer. Use for: analyzing codebase patterns and conventions, designing implementation blueprints with specific files to create/modify, component designs, data flows, and build sequences. Read-only. (Tools: read, glob, grep, list, bash)
9
+ - **reviewer** — Code review specialist. Use for: finding bugs, logic errors, security vulnerabilities, code quality issues, and adherence to project conventions. Read-only. (Tools: read, glob, grep, list, bash)
10
+ - **researcher** — Deep research agent. Use for: investigating unfamiliar libraries, combining local code analysis with web search, producing research reports with sources. Read-only with web access. (Tools: read, glob, grep, list, bash, websearch, codesearch, webfetch)
11
+ - **guide** — kkcode self-help guide. Use when the user asks "How do I...", "Can kkcode...", "What tool should I use for..." questions about kkcode itself. Searches kkcode source code for accurate answers. Read-only. (Tools: read, glob, grep, list, webfetch, websearch)
12
+ - **security-reviewer** — Security audit specialist. Use for: OWASP Top 10 checks, hardcoded secret scans, dependency audits, authentication/authorization reviews. Read-only. (Tools: read, glob, grep, list, bash)
13
+ - **tdd-guide** — TDD specialist. Use for: guiding test-driven development workflows (scaffold→RED→GREEN→REFACTOR), writing failing tests first, targeting 80%+ coverage. Full access. (Tools: read, write, edit, bash, glob, grep, list)
14
+ - **build-fixer** — Build error resolver. Use for: diagnosing build failures, identifying root causes (type errors, missing imports, dependency conflicts), applying fixes, verifying builds. Full access. (Tools: read, write, edit, bash, glob, grep, list)
15
+ - **(default)** — Full-capability build agent. Use for: complex multi-file changes, refactoring, test writing, any task requiring file mutations.
16
+
17
+ # When to Use This Tool
18
+
19
+ Use `task` when the work:
20
+ - Requires multiple tool calls and autonomous reasoning (e.g. "refactor module X", "write tests for Y")
21
+ - Benefits from an independent context window (protects main conversation from result noise)
22
+ - Involves code review, deep research, or broad codebase exploration
23
+ - Can be parallelized — launch multiple independent tasks simultaneously
24
+
25
+ <example>
26
+ User: "Please investigate how authentication works in this project"
27
+ → Launch task with subagent_type="explore", prompt="Trace the authentication flow..."
28
+
29
+ Reasoning: Open-ended exploration that may require many file reads. Subagent keeps main context clean.
30
+ </example>
31
+
32
+ <example>
33
+ User: "Refactor the database module and update all tests"
34
+ → Launch task with default subagent, prompt="Refactor src/db/... and update test/db/..."
35
+
36
+ Reasoning: Complex multi-file change requiring autonomous execution.
37
+ </example>
38
+
39
+ <example>
40
+ User: "Review this PR for security issues"
41
+ → Launch task with subagent_type="reviewer", prompt="Review all changed files for..."
42
+
43
+ Reasoning: Code review benefits from dedicated context and structured output.
44
+ </example>
45
+
46
+ # When NOT to Use — use the appropriate tool directly instead
47
+
48
+ Do NOT use `task` as a wrapper for simple operations:
49
+ - Reading a specific file → use `read` directly
50
+ - Searching for a specific class/function → use `grep` or `glob` directly
51
+ - Running a shell command → use `bash` directly
52
+ - Making a small file edit → use `edit` directly
53
+ - Creating a file → use `write` directly
54
+ - Any single-step operation → use the appropriate tool directly
55
+
56
+ <example>
57
+ BAD: task(prompt="Read the file src/config.mjs and tell me what it exports")
58
+ GOOD: read(path="src/config.mjs") — then analyze the content yourself
59
+
60
+ BAD: task(prompt="Search for all files named *.test.js")
61
+ GOOD: glob(pattern="**/*.test.js")
62
+ </example>
63
+
64
+ # Parameters
65
+
66
+ - **prompt** (required): Detailed task description with ALL necessary context. The subagent starts fresh — it cannot see your conversation history. Include:
67
+ - What to do (specific instructions)
68
+ - Why (context for decision-making)
69
+ - Whether to write code or just research
70
+ - Key file paths or patterns to start with
71
+
72
+ - **subagent_type** (optional): One of "explore", "architect", "reviewer", "researcher", or omit for default build agent.
73
+
74
+ - **run_in_background** (optional): Set to true to run as a background worker. Returns a task_id immediately — use `background_output` to check results later.
75
+
76
+ # Important Behaviors
77
+
78
+ - Each `task` call spawns a full LLM session — it is expensive and slow. Use it deliberately.
79
+ - The subagent's result is NOT visible to the user. You MUST send a text message summarizing the result.
80
+ - You can launch multiple tasks in parallel for independent work — this is a key advantage.
81
+ - Avoid duplicating work that subagents are already doing. If you delegated research, don't also search yourself.
82
+ - Provide clear, self-contained prompts. The subagent has no access to your conversation context.
83
+ - Clearly state whether you expect the agent to write code or just do research, since it cannot infer your intent.
@@ -0,0 +1,117 @@
1
+ Create and manage a structured task list for tracking multi-step work. This helps you track progress, organize complex tasks, and demonstrate thoroughness to the user. It also helps the user understand the progress of your work.
2
+
3
+ ## When to Use This Tool
4
+
5
+ Use this tool proactively in these scenarios:
6
+
7
+ 1. **Complex multi-step tasks** — When a task requires 3 or more distinct steps or actions
8
+ 2. **Non-trivial tasks** — Tasks requiring careful planning or multiple operations
9
+ 3. **User provides multiple tasks** — When users provide a list of things to be done (numbered or comma-separated)
10
+ 4. **After receiving new instructions** — Immediately capture user requirements as todos
11
+ 5. **When you start working on a task** — Mark it as in_progress BEFORE beginning work
12
+ 6. **After completing a task** — Mark it as completed and add any follow-up tasks discovered during implementation
13
+
14
+ ## When NOT to Use This Tool
15
+
16
+ Skip using this tool when:
17
+ 1. There is only a single, straightforward task
18
+ 2. The task is trivial and tracking provides no benefit
19
+ 3. The task can be completed in less than 3 trivial steps
20
+ 4. The task is purely conversational or informational
21
+
22
+ NOTE: Do NOT use this tool if there is only one trivial task. Just do it directly.
23
+
24
+ ## Examples of When to Use
25
+
26
+ <example>
27
+ User: I want to add a dark mode toggle to the application settings. Make sure you run the tests when done!
28
+ → Create todo list:
29
+ 1. Create dark mode toggle component in Settings page
30
+ 2. Add dark mode state management (context/store)
31
+ 3. Implement theme styles for dark mode
32
+ 4. Update existing components to support theme switching
33
+ 5. Run tests and fix any failures
34
+
35
+ Reasoning: Multi-step feature requiring UI, state management, and styling changes. User explicitly asked for tests.
36
+ </example>
37
+
38
+ <example>
39
+ User: Help me rename the function getCwd to getCurrentWorkingDirectory across my project
40
+ → First search to understand scope, then create todo list with one item per file that needs updating.
41
+
42
+ Reasoning: Multiple files affected, systematic tracking prevents missing any occurrence.
43
+ </example>
44
+
45
+ <example>
46
+ User: I need to implement user registration, product catalog, shopping cart, and checkout flow.
47
+ → Create todo list breaking down each feature into specific tasks.
48
+
49
+ Reasoning: User provided multiple complex features in a list.
50
+ </example>
51
+
52
+ ## Examples of When NOT to Use
53
+
54
+ <example>
55
+ User: How do I print "Hello World" in Python?
56
+ → Just answer directly. No todo needed.
57
+
58
+ Reasoning: Single, trivial, informational task.
59
+ </example>
60
+
61
+ <example>
62
+ User: Fix the typo in the README
63
+ → Just fix it directly. No todo needed.
64
+
65
+ Reasoning: Single straightforward task, no multi-step planning required.
66
+ </example>
67
+
68
+ <example>
69
+ User: Run npm install for me
70
+ → Just run it. No todo needed.
71
+
72
+ Reasoning: Single command execution with immediate results.
73
+ </example>
74
+
75
+ ## Task States and Management
76
+
77
+ Task states: pending, in_progress, completed
78
+
79
+ IMPORTANT — Task descriptions must have two forms:
80
+ - content: imperative form describing what needs to be done (e.g. "Run tests", "Fix authentication bug")
81
+ - activeForm: present continuous form shown during execution (e.g. "Running tests", "Fixing authentication bug")
82
+
83
+ Rules:
84
+ - Update task status in real-time as you work
85
+ - Mark tasks complete IMMEDIATELY after finishing (don't batch completions)
86
+ - Exactly ONE task must be in_progress at any time (not less, not more)
87
+ - Complete current tasks before starting new ones
88
+ - Remove tasks that are no longer relevant from the list entirely
89
+
90
+ ## Task Completion Requirements
91
+
92
+ - ONLY mark a task as completed when you have FULLY accomplished it
93
+ - If you encounter errors, blockers, or cannot finish, keep the task as in_progress
94
+ - When blocked, create a new task describing what needs to be resolved
95
+ - Never mark a task as completed if:
96
+ - Tests are failing
97
+ - Implementation is partial
98
+ - You encountered unresolved errors
99
+ - You couldn't find necessary files or dependencies
100
+
101
+ ## Task Breakdown Guidelines
102
+
103
+ - Create specific, actionable items
104
+ - Break complex tasks into smaller, manageable steps
105
+ - Use clear, descriptive task names
106
+ - Always provide both forms:
107
+ - content: "Fix authentication bug"
108
+ - activeForm: "Fixing authentication bug"
109
+
110
+ When in doubt, use this tool. Being proactive with task management demonstrates attentiveness and ensures you complete all requirements successfully.
111
+
112
+ ## Parameters
113
+
114
+ - todos (required): array of task objects
115
+ - content (required): task description in imperative form
116
+ - status (required): "pending" | "in_progress" | "completed"
117
+ - activeForm (required): present continuous form shown during execution
@@ -0,0 +1,38 @@
1
+ Fetch content from a URL and return it as processed text.
2
+
3
+ IMPORTANT: WebFetch WILL FAIL for authenticated or private URLs. Before using this tool, check if the URL points to an authenticated service (e.g. Google Docs, Confluence, Jira, private GitHub repos). For GitHub URLs, prefer using `bash` with `gh` CLI instead (e.g. gh pr view, gh issue view, gh api).
4
+
5
+ Use cases:
6
+ - Retrieve documentation or API references from public URLs
7
+ - Read web pages for research
8
+ - Fetch remote configuration or data
9
+
10
+ Parameters:
11
+ - url (required): URL to fetch (must be a valid HTTP/HTTPS URL)
12
+ - prompt (optional): instruction for how to process/extract information from the content
13
+
14
+ Notes:
15
+ - HTML is automatically converted to Markdown for readability
16
+ - Large content (over 50KB) is truncated
17
+ - Only use for public, unauthenticated URLs
18
+ - HTTP URLs are automatically upgraded to HTTPS
19
+ - Includes a 30-second timeout
20
+ - Includes a self-cleaning 15-minute cache for faster repeat access
21
+ - Do NOT use for local file reading — use `read` instead
22
+ - Do NOT generate or guess URLs. Only use URLs provided by the user or found in project files.
23
+
24
+ Examples:
25
+ <good-example>
26
+ # Fetch public documentation
27
+ webfetch url="https://docs.example.com/api" prompt="Extract all REST endpoints and their parameters"
28
+ </good-example>
29
+ <bad-example>
30
+ # WRONG: authenticated URL — will fail
31
+ webfetch url="https://docs.google.com/document/d/abc123/edit"
32
+ # Instead: ask the user to paste the content or use an MCP tool with auth
33
+ </bad-example>
34
+ <bad-example>
35
+ # WRONG: GitHub URL — use gh CLI instead
36
+ webfetch url="https://github.com/org/repo/pull/42"
37
+ # Instead: bash "gh pr view 42"
38
+ </bad-example>
@@ -0,0 +1,43 @@
1
+ Search the web for up-to-date information using Exa AI.
2
+
3
+ IMPORTANT — When to use PROACTIVELY (reduce hallucination):
4
+ - You are unsure about a fact, API, library version, or behavior
5
+ - The user asks about recent events, releases, or changelogs
6
+ - You encounter an unfamiliar error message or deprecation warning
7
+ - You need to verify correct syntax or configuration for a specific version
8
+ - The topic is beyond your training data cutoff
9
+
10
+ Do NOT guess when you can search. A quick websearch is always better than a confident hallucination.
11
+
12
+ Parameters:
13
+ - query (required): search query — be specific, include version numbers and context
14
+ - numResults (optional): number of results (default: 5)
15
+ - type (optional): "auto" (balanced, default), "fast" (quick), "deep" (comprehensive)
16
+
17
+ ## When NOT to Use
18
+ - Do NOT search for information you already know with high confidence (basic syntax, well-known APIs).
19
+ - Do NOT search when the answer is in the local codebase — use `grep` or `read` first.
20
+ - Do NOT search for user-specific context (their business logic, variable names, etc.) — that's in their code.
21
+
22
+ Tips:
23
+ - ALWAYS include the current year in queries for time-sensitive topics (e.g. "React 19 new hooks 2026")
24
+ - Use specific error messages as queries when debugging
25
+ - Prefer "deep" type for complex research questions
26
+ - Include library/framework version numbers when relevant
27
+
28
+ Examples:
29
+ <good-example>
30
+ # Debugging an unfamiliar error
31
+ websearch query="TypeError: Cannot read properties of undefined reading 'map' React 18 2026"
32
+ </good-example>
33
+ <good-example>
34
+ # Checking latest API syntax
35
+ websearch query="Next.js 15 app router middleware configuration 2026"
36
+ </good-example>
37
+ <bad-example>
38
+ # Too vague — add specifics
39
+ websearch query="how to use React"
40
+ # Better: websearch query="React 19 useOptimistic hook example 2026"
41
+ </bad-example>
42
+
43
+ CRITICAL: After answering the user's question with search results, you MUST include a "Sources:" section at the end with source URLs as markdown hyperlinks so the user can verify the information.
@@ -0,0 +1,38 @@
1
+ Writes a file to the local filesystem. Creates parent directories automatically.
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.
6
+ - ALWAYS prefer editing existing files with `edit`. NEVER write new files unless explicitly required.
7
+ - NEVER proactively create documentation files (*.md) or README files. Only create documentation if explicitly requested by the user.
8
+ - Only use emojis if the user explicitly requests it. Avoid writing emojis to files unless asked.
9
+
10
+ IMPORTANT:
11
+ - Parent directories are created automatically — no need to `mkdir` first.
12
+ - For small files: include COMPLETE content in a single call.
13
+ - For large files (200+ lines): use mode="append" to build incrementally across multiple calls.
14
+ - For reading files, use the `read` tool — never use `bash` with cat/type/Get-Content.
15
+ - Do NOT use `write` when only a small part of an existing file needs to change — use `edit` or `patch` instead.
16
+ - Do NOT delegate file creation to `task` — just call `write` directly.
17
+
18
+ Parameters:
19
+ - path (required): file path (absolute or relative)
20
+ - content (required): file content to write
21
+ - mode (optional): "overwrite" (default), "append", or "insert"
22
+ - overwrite: replaces entire file (default behavior)
23
+ - append: adds content to end of existing file (creates file if new)
24
+ - insert: inserts content at a specific line, shifting existing lines down
25
+ - insert_at_line (optional): 1-based line number for insert mode
26
+
27
+ Building large files incrementally (avoids output truncation):
28
+ 1. First call: write(path, content, mode="overwrite") — create with initial section
29
+ 2. Subsequent calls: write(path, content, mode="append") — add remaining sections
30
+ Each call should be ~100-150 lines to stay well within output limits.
31
+
32
+ When to use `write` vs `edit` vs `patch`:
33
+ - New file that doesn't exist yet → `write`
34
+ - Replacing entire file content → `write` (after reading it first)
35
+ - Adding content to end of file → `write` with mode="append"
36
+ - Changing a few lines in an existing file → `edit`
37
+ - Renaming a variable across a file → `edit` with replace_all
38
+ - Replacing a large section by line numbers → `patch`
@@ -0,0 +1,18 @@
1
+ import path from "node:path"
2
+ import { readFile } from "node:fs/promises"
3
+ import { fileURLToPath } from "node:url"
4
+ import { renderTemplate } from "../util/template.mjs"
5
+
6
+ const __dirname = path.dirname(fileURLToPath(import.meta.url))
7
+ const PROMPT_DIR = path.join(__dirname, "prompt")
8
+
9
+ const cache = new Map()
10
+
11
+ export async function loadToolPrompt(name, vars = {}) {
12
+ if (!cache.has(name)) {
13
+ const file = path.join(PROMPT_DIR, name)
14
+ const text = (await readFile(file, "utf8")).trim()
15
+ cache.set(name, text)
16
+ }
17
+ return renderTemplate(cache.get(name), vars)
18
+ }
@@ -0,0 +1,86 @@
1
+ import { stdin as input, stdout as output } from "node:process"
2
+ import { createInterface } from "node:readline/promises"
3
+
4
+ let customPromptHandler = null
5
+
6
+ export function setQuestionPromptHandler(handler) {
7
+ customPromptHandler = typeof handler === "function" ? handler : null
8
+ }
9
+
10
+ export async function askQuestionInteractive({ questions }) {
11
+ if (!Array.isArray(questions) || questions.length === 0) {
12
+ return {}
13
+ }
14
+
15
+ // 1. TUI handler (registered by repl.mjs)
16
+ if (customPromptHandler) {
17
+ const answers = await customPromptHandler({ questions })
18
+ if (answers && typeof answers === "object") return answers
19
+ }
20
+
21
+ // 2. Non-TTY: return empty answers
22
+ if (!process.stdout.isTTY || !process.stdin.isTTY) {
23
+ return Object.fromEntries(questions.map((q) => [q.id, ""]))
24
+ }
25
+
26
+ // 3. TTY fallback: readline sequential Q&A
27
+ const rl = createInterface({ input, output })
28
+ const answers = {}
29
+ try {
30
+ for (const q of questions) {
31
+ console.log("")
32
+ console.log(` ${q.text}`)
33
+ if (q.description) console.log(` ${q.description}`)
34
+ const options = Array.isArray(q.options) ? q.options : []
35
+ if (options.length) {
36
+ for (let i = 0; i < options.length; i++) {
37
+ const opt = options[i]
38
+ console.log(` ${i + 1}. ${opt.label}`)
39
+ if (opt.description) console.log(` ${opt.description}`)
40
+ }
41
+ if (q.allowCustom !== false) {
42
+ console.log(` ${options.length + 1}. Custom...`)
43
+ }
44
+ }
45
+ const raw = (await rl.question(" > ")).trim()
46
+ if (options.length) {
47
+ const idx = parseInt(raw, 10)
48
+ if (idx >= 1 && idx <= options.length) {
49
+ const chosen = options[idx - 1]
50
+ answers[q.id] = chosen.value || chosen.label
51
+ } else {
52
+ answers[q.id] = raw
53
+ }
54
+ } else {
55
+ answers[q.id] = raw
56
+ }
57
+ }
58
+ } finally {
59
+ rl.close()
60
+ }
61
+ return answers
62
+ }
63
+
64
+ export async function askPlanApproval({ plan, files = [] }) {
65
+ const fileList = files.length ? `\nFiles to modify:\n${files.map(f => ` - ${f}`).join("\n")}` : ""
66
+ const questions = [
67
+ {
68
+ id: "plan_approval",
69
+ text: `Plan Review`,
70
+ description: `${plan}${fileList}`,
71
+ options: [
72
+ { label: "Approve", value: "approve", description: "Proceed with this plan" },
73
+ { label: "Reject", value: "reject", description: "Reject and provide feedback" }
74
+ ],
75
+ multi: false,
76
+ allowCustom: true
77
+ }
78
+ ]
79
+ const answers = await askQuestionInteractive({ questions })
80
+ const answer = String(answers.plan_approval || "").trim().toLowerCase()
81
+ if (answer === "approve" || answer === "1") {
82
+ return { approved: true, feedback: "" }
83
+ }
84
+ const feedback = answer === "reject" || answer === "2" ? "" : answer
85
+ return { approved: false, feedback }
86
+ }