bonecode 1.2.2 → 1.3.0
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.
- package/README.md +20 -0
- package/dist/src/engine/agent/prompt/compaction.txt +9 -0
- package/dist/src/engine/agent/prompt/explore.txt +18 -0
- package/dist/src/engine/agent/prompt/scout.txt +36 -0
- package/dist/src/engine/agent/prompt/summary.txt +11 -0
- package/dist/src/engine/agent/prompt/title.txt +44 -0
- package/dist/src/engine/session/prompt/anthropic.txt +105 -0
- package/dist/src/engine/session/prompt/beast.txt +147 -0
- package/dist/src/engine/session/prompt/bonescript.txt +391 -0
- package/dist/src/engine/session/prompt/build-switch.txt +5 -0
- package/dist/src/engine/session/prompt/codex.txt +79 -0
- package/dist/src/engine/session/prompt/copilot-gpt-5.txt +143 -0
- package/dist/src/engine/session/prompt/default.txt +105 -0
- package/dist/src/engine/session/prompt/gemini.txt +155 -0
- package/dist/src/engine/session/prompt/gpt.txt +107 -0
- package/dist/src/engine/session/prompt/kimi.txt +95 -0
- package/dist/src/engine/session/prompt/max-steps.txt +16 -0
- package/dist/src/engine/session/prompt/plan-reminder-anthropic.txt +67 -0
- package/dist/src/engine/session/prompt/plan.txt +26 -0
- package/dist/src/engine/session/prompt/trinity.txt +97 -0
- package/dist/src/engine/session/prompt.js +35 -2
- package/dist/src/engine/session/prompt.js.map +1 -1
- package/dist/src/engine/skill/prompt/customize-opencode.md +377 -0
- package/dist/src/engine/tool/apply_patch.txt +33 -0
- package/dist/src/engine/tool/edit.txt +10 -0
- package/dist/src/engine/tool/glob.txt +6 -0
- package/dist/src/engine/tool/grep.txt +8 -0
- package/dist/src/engine/tool/lsp.txt +24 -0
- package/dist/src/engine/tool/plan-enter.txt +14 -0
- package/dist/src/engine/tool/plan-exit.txt +13 -0
- package/dist/src/engine/tool/question.txt +10 -0
- package/dist/src/engine/tool/read.txt +14 -0
- package/dist/src/engine/tool/repo_clone.txt +5 -0
- package/dist/src/engine/tool/repo_overview.txt +4 -0
- package/dist/src/engine/tool/shell/shell.txt +77 -0
- package/dist/src/engine/tool/skill.txt +5 -0
- package/dist/src/engine/tool/task.txt +58 -0
- package/dist/src/engine/tool/task_status.txt +13 -0
- package/dist/src/engine/tool/todowrite.txt +167 -0
- package/dist/src/engine/tool/tool/apply_patch.txt +33 -0
- package/dist/src/engine/tool/tool/edit.txt +10 -0
- package/dist/src/engine/tool/tool/glob.txt +6 -0
- package/dist/src/engine/tool/tool/grep.txt +8 -0
- package/dist/src/engine/tool/tool/lsp.txt +24 -0
- package/dist/src/engine/tool/tool/plan-enter.txt +14 -0
- package/dist/src/engine/tool/tool/plan-exit.txt +13 -0
- package/dist/src/engine/tool/tool/question.txt +10 -0
- package/dist/src/engine/tool/tool/read.txt +14 -0
- package/dist/src/engine/tool/tool/repo_clone.txt +5 -0
- package/dist/src/engine/tool/tool/repo_overview.txt +4 -0
- package/dist/src/engine/tool/tool/shell/shell.txt +77 -0
- package/dist/src/engine/tool/tool/skill.txt +5 -0
- package/dist/src/engine/tool/tool/task.txt +58 -0
- package/dist/src/engine/tool/tool/task_status.txt +13 -0
- package/dist/src/engine/tool/tool/todowrite.txt +167 -0
- package/dist/src/engine/tool/tool/webfetch.txt +13 -0
- package/dist/src/engine/tool/tool/websearch.txt +14 -0
- package/dist/src/engine/tool/tool/write.txt +8 -0
- package/dist/src/engine/tool/webfetch.txt +13 -0
- package/dist/src/engine/tool/websearch.txt +14 -0
- package/dist/src/engine/tool/write.txt +8 -0
- package/dist/src/tui.js +118 -29
- package/dist/src/tui.js.map +1 -1
- package/package.json +2 -2
- package/scripts/copy_prompts.js +58 -0
- package/scripts/test_bonescript_primer.js +111 -0
- package/scripts/test_tui_render.js +278 -0
- package/src/engine/session/prompt/bonescript.txt +391 -0
- package/src/engine/session/prompt.ts +36 -2
- package/src/tui.ts +115 -30
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
- Clone or refresh a repository into OpenCode's managed cache under the data directory
|
|
2
|
+
- Accepts git URLs, forge host/path references, or GitHub owner/repo shorthand
|
|
3
|
+
- Returns the cached absolute local path so other tools can explore the cloned source
|
|
4
|
+
- Use this before Read, Glob, or Grep when the code you need lives outside the current workspace
|
|
5
|
+
- This tool is intended for dependency and documentation research workflows, not for modifying the user's workspace
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
- Summarize the structure and likely entrypoints of a cloned repository or local directory
|
|
2
|
+
- Accepts either a cached repository reference or a directory path
|
|
3
|
+
- Reports detected ecosystems, dependency files, package manager, likely entrypoints, and a compact structure tree
|
|
4
|
+
- Use this after repo_clone to orient quickly before deeper Read, Glob, or Grep investigation
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
${intro}
|
|
2
|
+
|
|
3
|
+
Be aware: OS: ${os}, Shell: ${shell}
|
|
4
|
+
|
|
5
|
+
${workdirSection}
|
|
6
|
+
|
|
7
|
+
Use `${tmp}` for temporary work outside the workspace. This directory has already been created, already exists, and is pre-approved for external directory access.
|
|
8
|
+
|
|
9
|
+
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 this instead.
|
|
10
|
+
|
|
11
|
+
${commandSection}
|
|
12
|
+
|
|
13
|
+
# Committing changes with git
|
|
14
|
+
|
|
15
|
+
Only create commits when requested by the user. If unclear, ask first. When the user asks you to create a new git commit, follow these steps carefully:
|
|
16
|
+
|
|
17
|
+
Git Safety Protocol:
|
|
18
|
+
- NEVER update the git config
|
|
19
|
+
- NEVER run destructive/irreversible git commands (like push --force, hard reset, etc) unless the user explicitly requests them
|
|
20
|
+
- NEVER skip hooks (--no-verify, --no-gpg-sign, etc) unless the user explicitly requests it
|
|
21
|
+
- NEVER run force push to main/master, warn the user if they request it
|
|
22
|
+
- Avoid git commit --amend. ONLY use --amend when ALL conditions are met:
|
|
23
|
+
(1) User explicitly requested amend, OR the commit succeeded and pre-commit hooks auto-modified files that need including — verify by checking `git log` that HEAD is the new commit before amending
|
|
24
|
+
(2) HEAD commit was created by you in this conversation (verify: git log -1 --format='%an %ae')
|
|
25
|
+
(3) Commit has NOT been pushed to remote (verify: git status shows "Your branch is ahead")
|
|
26
|
+
- CRITICAL: If commit FAILED or was REJECTED by hook, NEVER amend - fix the issue and create a NEW commit
|
|
27
|
+
- CRITICAL: If you already pushed to remote, NEVER amend unless user explicitly requests it (requires force push)
|
|
28
|
+
- NEVER commit changes unless the user explicitly asks you to. It is VERY IMPORTANT to only commit when explicitly asked, otherwise the user will feel that you are being too proactive.
|
|
29
|
+
|
|
30
|
+
1. You can call multiple tools in a single response. When multiple independent pieces of information are requested and all commands are likely to succeed, run multiple tool calls in parallel for optimal performance. run the following ${gitCommands} in parallel, each using the ${toolName} tool:
|
|
31
|
+
- Run a git status command to see all untracked files.
|
|
32
|
+
- Run a git diff command to see both staged and unstaged changes that will be committed.
|
|
33
|
+
- Run a git log command to see recent commit messages, so that you can follow this repository's commit message style.
|
|
34
|
+
2. Analyze all staged changes (both previously staged and newly added) and draft a commit message:
|
|
35
|
+
- Summarize the nature of the changes (eg. new feature, enhancement to an existing feature, bug fix, refactoring, test, docs, etc.). Ensure the message accurately reflects the changes and their purpose (i.e. "add" means a wholly new feature, "update" means an enhancement to an existing feature, "fix" means a bug fix, etc.).
|
|
36
|
+
- Do not commit files that likely contain secrets (.env, credentials.json, etc.). Warn the user if they specifically request to commit those files
|
|
37
|
+
- Draft a concise (1-2 sentences) commit message that focuses on the "why" rather than the "what"
|
|
38
|
+
- Ensure it accurately reflects the changes and their purpose
|
|
39
|
+
3. You can call multiple tools in a single response. When multiple independent pieces of information are requested and all commands are likely to succeed, run multiple tool calls in parallel for optimal performance. run the following commands:
|
|
40
|
+
- Add relevant untracked files to the staging area.
|
|
41
|
+
- Create the commit with a message
|
|
42
|
+
- Run git status after the commit completes to verify success.
|
|
43
|
+
Note: git status depends on the commit completing, so run it sequentially after the commit.
|
|
44
|
+
4. If the commit fails due to pre-commit hook, fix the issue and create a NEW commit (see amend rules above)
|
|
45
|
+
|
|
46
|
+
Important notes:
|
|
47
|
+
- NEVER run additional commands to read or explore code, besides ${gitCommandRestriction}
|
|
48
|
+
- NEVER use the TodoWrite or Task tools
|
|
49
|
+
- DO NOT push to the remote repository unless the user explicitly asks you to do so
|
|
50
|
+
- IMPORTANT: Never use git commands with the -i flag (like git rebase -i or git add -i) since they require interactive input which is not supported.
|
|
51
|
+
- If there are no changes to commit (i.e., no untracked files and no modifications), do not create an empty commit
|
|
52
|
+
|
|
53
|
+
# Creating pull requests
|
|
54
|
+
Use the gh command via the ${toolName} tool for ALL GitHub-related tasks including working with issues, pull requests, checks, and releases. If given a GitHub URL use the gh command to get the information needed.
|
|
55
|
+
|
|
56
|
+
IMPORTANT: When the user asks you to create a pull request, follow these steps carefully:
|
|
57
|
+
|
|
58
|
+
1. You can call multiple tools in a single response. When multiple independent pieces of information are requested and all commands are likely to succeed, run multiple tool calls in parallel for optimal performance. run the following ${gitCommands} in parallel using the ${toolName} tool, in order to understand the current state of the branch since it diverged from the main branch:
|
|
59
|
+
- Run a git status command to see all untracked files
|
|
60
|
+
- Run a git diff command to see both staged and unstaged changes that will be committed
|
|
61
|
+
- Check if the current branch tracks a remote branch and is up to date with the remote, so you know if you need to push to the remote
|
|
62
|
+
- Run a git log command and `git diff [base-branch]...HEAD` to understand the full commit history for the current branch (from the time it diverged from the base branch)
|
|
63
|
+
2. Analyze all changes that will be included in the pull request, making sure to look at all relevant commits (NOT just the latest commit, but ALL commits that will be included in the pull request!!!), and draft a pull request summary
|
|
64
|
+
3. You can call multiple tools in a single response. When multiple independent pieces of information are requested and all commands are likely to succeed, run multiple tool calls in parallel for optimal performance. run the following commands in parallel:
|
|
65
|
+
- Create new branch if needed
|
|
66
|
+
- Push to remote with -u flag if needed
|
|
67
|
+
- ${createPrInstruction}
|
|
68
|
+
<example>
|
|
69
|
+
${createPrExample}
|
|
70
|
+
</example>
|
|
71
|
+
|
|
72
|
+
Important:
|
|
73
|
+
- DO NOT use the TodoWrite or Task tools
|
|
74
|
+
- Return the PR URL when you're done, so the user can see it
|
|
75
|
+
|
|
76
|
+
# Other common operations
|
|
77
|
+
- View comments on a GitHub PR: gh api repos/foo/bar/pulls/123/comments
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
Load a specialized skill when the task at hand matches one of the skills listed in the system prompt.
|
|
2
|
+
|
|
3
|
+
Use this tool to inject the skill's instructions and resources into current conversation. The output may contain detailed workflow guidance as well as references to scripts, files, etc in the same directory as the skill.
|
|
4
|
+
|
|
5
|
+
The skill name must match one of the skills listed in your system prompt.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
Launch a new agent to handle complex, multistep tasks autonomously.
|
|
2
|
+
|
|
3
|
+
When using the Task tool, you must specify a subagent_type parameter to select which agent type to use.
|
|
4
|
+
|
|
5
|
+
When to use the Task tool:
|
|
6
|
+
- When you are instructed to execute custom slash commands. Use the Task tool with the slash command invocation as the entire prompt. The slash command can take arguments. For example: Task(description="Check the file", prompt="/check-file path/to/file.py")
|
|
7
|
+
|
|
8
|
+
When NOT to use the Task tool:
|
|
9
|
+
- If you want to read a specific file path, use the Read or Glob tool instead of the Task tool, to find the match more quickly
|
|
10
|
+
- If you are searching for a specific class definition like "class Foo", use the Glob tool instead, to find the match more quickly
|
|
11
|
+
- If you are searching for code within a specific file or set of 2-3 files, use the Read tool instead of the Task tool, to find the match more quickly
|
|
12
|
+
- Other tasks that are not related to the agent descriptions above
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
Usage notes:
|
|
16
|
+
1. Launch multiple agents concurrently whenever possible, to maximize performance; to do that, use a single message with multiple tool uses
|
|
17
|
+
2. When the agent is done, it will return a single message back to you. The result returned by the agent is not visible to the user. To show the user the result, you should send a text message back to the user with a concise summary of the result. The output includes a task_id you can reuse later to continue the same subagent session.
|
|
18
|
+
3. If OPENCODE_EXPERIMENTAL_BACKGROUND_SUBAGENTS is enabled, background=true launches the subagent asynchronously. Use task_status(task_id=..., wait=false) to poll, or wait=true to block until done.
|
|
19
|
+
4. Each agent invocation starts with a fresh context unless you provide task_id to resume the same subagent session (which continues with its previous messages and tool outputs). When starting fresh, your prompt should contain a highly detailed task description for the agent to perform autonomously and you should specify exactly what information the agent should return back to you in its final and only message to you.
|
|
20
|
+
5. The agent's outputs should generally be trusted
|
|
21
|
+
6. Clearly tell the agent whether you expect it to write code or just to do research (search, file reads, web fetches, etc.), since it is not aware of the user's intent. Tell it how to verify its work if possible (e.g., relevant test commands).
|
|
22
|
+
7. If the agent description mentions that it should be used proactively, then you should try your best to use it without the user having to ask for it first. Use your judgement.
|
|
23
|
+
|
|
24
|
+
Example usage (NOTE: The agents below are fictional examples for illustration only - use the actual agents listed above):
|
|
25
|
+
|
|
26
|
+
<example_agent_descriptions>
|
|
27
|
+
"code-reviewer": use this agent after you are done writing a significant piece of code
|
|
28
|
+
"greeting-responder": use this agent when to respond to user greetings with a friendly joke
|
|
29
|
+
</example_agent_description>
|
|
30
|
+
|
|
31
|
+
<example>
|
|
32
|
+
user: "Please write a function that checks if a number is prime"
|
|
33
|
+
assistant: Sure let me write a function that checks if a number is prime
|
|
34
|
+
assistant: First let me use the Write tool to write a function that checks if a number is prime
|
|
35
|
+
assistant: I'm going to use the Write tool to write the following code:
|
|
36
|
+
<code>
|
|
37
|
+
function isPrime(n) {
|
|
38
|
+
if (n <= 1) return false
|
|
39
|
+
for (let i = 2; i * i <= n; i++) {
|
|
40
|
+
if (n % i === 0) return false
|
|
41
|
+
}
|
|
42
|
+
return true
|
|
43
|
+
}
|
|
44
|
+
</code>
|
|
45
|
+
<commentary>
|
|
46
|
+
Since a significant piece of code was written and the task was completed, now use the code-reviewer agent to review the code
|
|
47
|
+
</commentary>
|
|
48
|
+
assistant: Now let me use the code-reviewer agent to review the code
|
|
49
|
+
assistant: Uses the Task tool to launch the code-reviewer agent
|
|
50
|
+
</example>
|
|
51
|
+
|
|
52
|
+
<example>
|
|
53
|
+
user: "Hello"
|
|
54
|
+
<commentary>
|
|
55
|
+
Since the user is greeting, use the greeting-responder agent to respond with a friendly joke
|
|
56
|
+
</commentary>
|
|
57
|
+
assistant: "I'm going to use the Task tool to launch the with the greeting-responder agent"
|
|
58
|
+
</example>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Poll the status of a background subagent task launched with the task tool.
|
|
2
|
+
|
|
3
|
+
Use this for tasks started with `task(background=true)`.
|
|
4
|
+
|
|
5
|
+
Parameters:
|
|
6
|
+
- `task_id` (required): the task session id returned by the task tool
|
|
7
|
+
- `wait` (optional): when true, wait for completion
|
|
8
|
+
- `timeout_ms` (optional): max wait duration in milliseconds when `wait=true`
|
|
9
|
+
|
|
10
|
+
Returns compact, parseable output:
|
|
11
|
+
- `task_id`
|
|
12
|
+
- `state` (`running`, `completed`, `error`, or `cancelled`)
|
|
13
|
+
- `<task_result>...</task_result>` or `<task_error>...</task_error>` containing final output, error summary, or current progress text
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
Use this tool to create and manage a structured task list for your current coding session. This helps you track progress, organize complex tasks, and demonstrate thoroughness to the user.
|
|
2
|
+
It also helps the user understand the progress of the task and overall progress of their requests.
|
|
3
|
+
|
|
4
|
+
## When to Use This Tool
|
|
5
|
+
Use this tool proactively in these scenarios:
|
|
6
|
+
|
|
7
|
+
1. Complex multistep tasks - When a task requires 3 or more distinct steps or actions
|
|
8
|
+
2. Non-trivial and complex tasks - Tasks that require careful planning or multiple operations
|
|
9
|
+
3. User explicitly requests todo list - When the user directly asks you to use the todo list
|
|
10
|
+
4. User provides multiple tasks - When users provide a list of things to be done (numbered or comma-separated)
|
|
11
|
+
5. After receiving new instructions - Immediately capture user requirements as todos. Feel free to edit the todo list based on new information.
|
|
12
|
+
6. After completing a task - Mark it complete and add any new follow-up tasks
|
|
13
|
+
7. When you start working on a new task, mark the todo as in_progress. Ideally you should only have one todo as in_progress at a time. Complete existing tasks before starting new ones.
|
|
14
|
+
|
|
15
|
+
## When NOT to Use This Tool
|
|
16
|
+
|
|
17
|
+
Skip using this tool when:
|
|
18
|
+
1. There is only a single, straightforward task
|
|
19
|
+
2. The task is trivial and tracking it provides no organizational benefit
|
|
20
|
+
3. The task can be completed in less than 3 trivial steps
|
|
21
|
+
4. The task is purely conversational or informational
|
|
22
|
+
|
|
23
|
+
NOTE that you should not use this tool if there is only one trivial task to do. In this case you are better off just doing the task directly.
|
|
24
|
+
|
|
25
|
+
## Examples of When to Use the Todo List
|
|
26
|
+
|
|
27
|
+
<example>
|
|
28
|
+
User: I want to add a dark mode toggle to the application settings. Make sure you run the tests and build when you're done!
|
|
29
|
+
Assistant: I'll help add a dark mode toggle to your application settings. Let me create a todo list to track this implementation.
|
|
30
|
+
*Creates todo list with the following items:*
|
|
31
|
+
1. Create dark mode toggle component in Settings page
|
|
32
|
+
2. Add dark mode state management (context/store)
|
|
33
|
+
3. Implement CSS-in-JS styles for dark theme
|
|
34
|
+
4. Update existing components to support theme switching
|
|
35
|
+
5. Run tests and build process, addressing any failures or errors that occur
|
|
36
|
+
*Begins working on the first task*
|
|
37
|
+
|
|
38
|
+
<reasoning>
|
|
39
|
+
The assistant used the todo list because:
|
|
40
|
+
1. Adding dark mode is a multi-step feature requiring UI, state management, and styling changes
|
|
41
|
+
2. The user explicitly requested tests and build be run afterward
|
|
42
|
+
3. The assistant inferred that tests and build need to pass by adding "Ensure tests and build succeed" as the final task
|
|
43
|
+
</reasoning>
|
|
44
|
+
</example>
|
|
45
|
+
|
|
46
|
+
<example>
|
|
47
|
+
User: Help me rename the function getCwd to getCurrentWorkingDirectory across my project
|
|
48
|
+
Assistant: Let me first search through your codebase to find all occurrences of 'getCwd'.
|
|
49
|
+
*Uses grep or search tools to locate all instances of getCwd in the codebase*
|
|
50
|
+
Assistant: I've found 15 instances of 'getCwd' across 8 different files. Let me create a todo list to track these changes.
|
|
51
|
+
*Creates todo list with specific items for each file that needs updating*
|
|
52
|
+
|
|
53
|
+
<reasoning>
|
|
54
|
+
The assistant used the todo list because:
|
|
55
|
+
1. First, the assistant searched to understand the scope of the task
|
|
56
|
+
2. Upon finding multiple occurrences across different files, it determined this was a complex task with multiple steps
|
|
57
|
+
3. The todo list helps ensure every instance is tracked and updated systematically
|
|
58
|
+
4. This approach prevents missing any occurrences and maintains code consistency
|
|
59
|
+
</reasoning>
|
|
60
|
+
</example>
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
<example>
|
|
64
|
+
User: I need to implement these features for my e-commerce site: user registration, product catalog, shopping cart, and checkout flow.
|
|
65
|
+
Assistant: I'll help implement these features. First, let's add all the features to the todo list.
|
|
66
|
+
*Creates a todo list breaking down each feature into specific tasks based on the project architecture*
|
|
67
|
+
Assistant: Let's start with user registration. This will involve creating database models, API endpoints, and frontend forms that integrate with your existing authentication system.
|
|
68
|
+
|
|
69
|
+
<reasoning>
|
|
70
|
+
The assistant used the todo list because:
|
|
71
|
+
1. The user provided multiple complex features to implement in a comma separated list
|
|
72
|
+
2. The todo list helps organize these large features into manageable tasks
|
|
73
|
+
3. This approach allows for tracking progress across the entire implementation
|
|
74
|
+
</reasoning>
|
|
75
|
+
</example>
|
|
76
|
+
|
|
77
|
+
<example>
|
|
78
|
+
User: Can you help optimize my React application? It's rendering slowly and has performance issues.</user>
|
|
79
|
+
Assistant: I'll help optimize your React application. First, let me examine your codebase to identify potential performance bottlenecks.
|
|
80
|
+
*Reviews component structure, render patterns, state management, and data fetching*
|
|
81
|
+
Assistant: After analyzing your codebase, I've identified several performance issues. Let me create a todo list to track our optimization efforts.
|
|
82
|
+
*Creates todo list with items like: 1) Implement memoization for expensive calculations in ProductList, 2) Add virtualization for long lists in Dashboard, 3) Optimize image loading in Gallery component, 4) Fix state update loops in ShoppingCart, 5) Review bundle size and implement code splitting*
|
|
83
|
+
Let's start by implementing memoization for the expensive calculations in your ProductList component.</assistant>
|
|
84
|
+
|
|
85
|
+
<reasoning>
|
|
86
|
+
The assistant used the todo list because:
|
|
87
|
+
1. First, the assistant examined the codebase to identify specific performance issues
|
|
88
|
+
2. Based on this analysis, it identified multiple optimization opportunities
|
|
89
|
+
3. Performance optimization is a non-trivial task requiring multiple steps
|
|
90
|
+
4. The todo list helps methodically track improvements across different components
|
|
91
|
+
5. This systematic approach ensures all performance bottlenecks are addressed
|
|
92
|
+
</reasoning>
|
|
93
|
+
</example>
|
|
94
|
+
|
|
95
|
+
## Examples of When NOT to Use the Todo List
|
|
96
|
+
|
|
97
|
+
<example>
|
|
98
|
+
User: How do I print 'Hello World' in Python?
|
|
99
|
+
Assistant: In Python, you can print "Hello World" with this simple code:
|
|
100
|
+
|
|
101
|
+
python
|
|
102
|
+
print("Hello World")
|
|
103
|
+
|
|
104
|
+
This will output the text "Hello World" to the console when executed.</assistant>
|
|
105
|
+
|
|
106
|
+
<reasoning>
|
|
107
|
+
The assistant did not use the todo list because this is a single, trivial task that can be completed in one step. There's no need to track multiple tasks or steps for such a straightforward request.
|
|
108
|
+
</reasoning>
|
|
109
|
+
</example>
|
|
110
|
+
|
|
111
|
+
<example>
|
|
112
|
+
User: What does the git status command do?
|
|
113
|
+
Assistant: The git status command shows the current state of your working directory and staging area. It displays which changes have been staged, which haven't, and which files aren't being tracked by Git. This is a fundamental command for understanding the current state of your repository before making commits.
|
|
114
|
+
|
|
115
|
+
<reasoning>
|
|
116
|
+
The assistant did not use the todo list because this is an informational request with no actual coding task to complete. The user is simply asking for an explanation, not for the assistant to perform multiple steps or tasks.
|
|
117
|
+
</reasoning>
|
|
118
|
+
</example>
|
|
119
|
+
|
|
120
|
+
<example>
|
|
121
|
+
User: Can you add a comment to the calculateTotal function to explain what it does?
|
|
122
|
+
Assistant: Sure, let me add a comment to the calculateTotal function to explain what it does.
|
|
123
|
+
* Uses the Edit tool to add a comment to the calculateTotal function *
|
|
124
|
+
|
|
125
|
+
<reasoning>
|
|
126
|
+
The assistant did not use the todo list because this is a single, straightforward task confined to one location in the code. Adding a comment doesn't require tracking multiple steps or systematic organization.
|
|
127
|
+
</reasoning>
|
|
128
|
+
</example>
|
|
129
|
+
|
|
130
|
+
<example>
|
|
131
|
+
User: Run npm install for me and tell me what happens.
|
|
132
|
+
Assistant: I'll run the npm install command for you.
|
|
133
|
+
|
|
134
|
+
*Executes: npm install*
|
|
135
|
+
|
|
136
|
+
The command completed successfully. Here's the output:
|
|
137
|
+
[Output of npm install command]
|
|
138
|
+
|
|
139
|
+
All dependencies have been installed according to your package.json file.
|
|
140
|
+
|
|
141
|
+
<reasoning>
|
|
142
|
+
The assistant did not use the todo list because this is a single command execution with immediate results. There are no multiple steps to track or organize, making the todo list unnecessary for this straightforward task.
|
|
143
|
+
</reasoning>
|
|
144
|
+
</example>
|
|
145
|
+
|
|
146
|
+
## Task States and Management
|
|
147
|
+
|
|
148
|
+
1. **Task States**: Use these states to track progress:
|
|
149
|
+
- pending: Task not yet started
|
|
150
|
+
- in_progress: Currently working on (limit to ONE task at a time)
|
|
151
|
+
- completed: Task finished successfully
|
|
152
|
+
- cancelled: Task no longer needed
|
|
153
|
+
|
|
154
|
+
2. **Task Management**:
|
|
155
|
+
- Update task status in real-time as you work
|
|
156
|
+
- Mark tasks complete IMMEDIATELY after finishing (don't batch completions)
|
|
157
|
+
- Only have ONE task in_progress at any time
|
|
158
|
+
- Complete current tasks before starting new ones
|
|
159
|
+
- Cancel tasks that become irrelevant
|
|
160
|
+
|
|
161
|
+
3. **Task Breakdown**:
|
|
162
|
+
- Create specific, actionable items
|
|
163
|
+
- Break complex tasks into smaller, manageable steps
|
|
164
|
+
- Use clear, descriptive task names
|
|
165
|
+
|
|
166
|
+
When in doubt, use this tool. Being proactive with task management demonstrates attentiveness and ensures you complete all requirements successfully.
|
|
167
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
- Fetches content from a specified URL
|
|
2
|
+
- Takes a URL and optional format as input
|
|
3
|
+
- Fetches the URL content, converts to requested format (markdown by default)
|
|
4
|
+
- Returns the content in the specified format
|
|
5
|
+
- Use this tool when you need to retrieve and analyze web content
|
|
6
|
+
|
|
7
|
+
Usage notes:
|
|
8
|
+
- IMPORTANT: if another tool is present that offers better web fetching capabilities, is more targeted to the task, or has fewer restrictions, prefer using that tool instead of this one.
|
|
9
|
+
- The URL must be a fully-formed valid URL
|
|
10
|
+
- HTTP URLs will be automatically upgraded to HTTPS
|
|
11
|
+
- Format options: "markdown" (default), "text", or "html"
|
|
12
|
+
- This tool is read-only and does not modify any files
|
|
13
|
+
- Results may be summarized if the content is very large
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
- Search the web using the session's web search provider - performs real-time web searches and can scrape content from specific URLs
|
|
2
|
+
- Provides up-to-date information for current events and recent data
|
|
3
|
+
- Supports configurable result counts and returns the content from the most relevant websites
|
|
4
|
+
- Use this tool for accessing information beyond knowledge cutoff
|
|
5
|
+
- Searches are performed automatically within a single API call
|
|
6
|
+
|
|
7
|
+
Usage notes:
|
|
8
|
+
- Supports live crawling modes when available: 'fallback' (backup if cached unavailable) or 'preferred' (prioritize live crawling)
|
|
9
|
+
- Search types when available: 'auto' (balanced), 'fast' (quick results), 'deep' (comprehensive search)
|
|
10
|
+
- Configurable context length for optimal LLM integration
|
|
11
|
+
- Domain filtering and advanced search options available
|
|
12
|
+
|
|
13
|
+
The current year is {{year}}. You MUST use this year when searching for recent information or current events
|
|
14
|
+
- Example: If the current year is 2026 and the user asks for "latest AI news", search for "AI news 2026", NOT "AI news 2025"
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
- Only use emojis if the user explicitly requests it. Avoid writing emojis to files unless asked.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
- Fetches content from a specified URL
|
|
2
|
+
- Takes a URL and optional format as input
|
|
3
|
+
- Fetches the URL content, converts to requested format (markdown by default)
|
|
4
|
+
- Returns the content in the specified format
|
|
5
|
+
- Use this tool when you need to retrieve and analyze web content
|
|
6
|
+
|
|
7
|
+
Usage notes:
|
|
8
|
+
- IMPORTANT: if another tool is present that offers better web fetching capabilities, is more targeted to the task, or has fewer restrictions, prefer using that tool instead of this one.
|
|
9
|
+
- The URL must be a fully-formed valid URL
|
|
10
|
+
- HTTP URLs will be automatically upgraded to HTTPS
|
|
11
|
+
- Format options: "markdown" (default), "text", or "html"
|
|
12
|
+
- This tool is read-only and does not modify any files
|
|
13
|
+
- Results may be summarized if the content is very large
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
- Search the web using the session's web search provider - performs real-time web searches and can scrape content from specific URLs
|
|
2
|
+
- Provides up-to-date information for current events and recent data
|
|
3
|
+
- Supports configurable result counts and returns the content from the most relevant websites
|
|
4
|
+
- Use this tool for accessing information beyond knowledge cutoff
|
|
5
|
+
- Searches are performed automatically within a single API call
|
|
6
|
+
|
|
7
|
+
Usage notes:
|
|
8
|
+
- Supports live crawling modes when available: 'fallback' (backup if cached unavailable) or 'preferred' (prioritize live crawling)
|
|
9
|
+
- Search types when available: 'auto' (balanced), 'fast' (quick results), 'deep' (comprehensive search)
|
|
10
|
+
- Configurable context length for optimal LLM integration
|
|
11
|
+
- Domain filtering and advanced search options available
|
|
12
|
+
|
|
13
|
+
The current year is {{year}}. You MUST use this year when searching for recent information or current events
|
|
14
|
+
- Example: If the current year is 2026 and the user asks for "latest AI news", search for "AI news 2026", NOT "AI news 2025"
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
- Only use emojis if the user explicitly requests it. Avoid writing emojis to files unless asked.
|
package/dist/src/tui.js
CHANGED
|
@@ -380,17 +380,81 @@ function printProviders(providers, currentProvider) {
|
|
|
380
380
|
* "text" — pass deltas through verbatim (with partial-fence detection)
|
|
381
381
|
* "fence" — buffer everything; emit marker on close fence
|
|
382
382
|
*/
|
|
383
|
+
/**
|
|
384
|
+
* Apply lightweight inline markdown styling to a streamed chunk.
|
|
385
|
+
*
|
|
386
|
+
* - `# `, `## `, `### ` at line-start become bold colored headers
|
|
387
|
+
* - `**text**` becomes bold
|
|
388
|
+
* - `` `code` `` becomes inverted gray
|
|
389
|
+
* - `- ` and `* ` at line-start become a bullet
|
|
390
|
+
*
|
|
391
|
+
* Operates per-line on the chunk. Cross-chunk markdown (a `**` opening in one
|
|
392
|
+
* delta and closing in another) is not handled — we just leave those raw.
|
|
393
|
+
* That's acceptable because it's rare and the model's output is still readable.
|
|
394
|
+
*/
|
|
395
|
+
function applyInlineMarkdown(text) {
|
|
396
|
+
if (!text)
|
|
397
|
+
return text;
|
|
398
|
+
// Split on newlines so we can match line-anchored patterns (headers, bullets)
|
|
399
|
+
const lines = text.split("\n");
|
|
400
|
+
const styled = lines.map((line) => {
|
|
401
|
+
// Headers
|
|
402
|
+
let m = line.match(/^(#{1,6})\s+(.*)$/);
|
|
403
|
+
if (m) {
|
|
404
|
+
const level = m[1].length;
|
|
405
|
+
const content = m[2];
|
|
406
|
+
if (level === 1)
|
|
407
|
+
return `${CYAN}${BOLD}${content}${R}`;
|
|
408
|
+
if (level === 2)
|
|
409
|
+
return `${CYAN}${BOLD}${content}${R}`;
|
|
410
|
+
if (level === 3)
|
|
411
|
+
return `${WHITE}${BOLD}${content}${R}`;
|
|
412
|
+
return `${WHITE}${content}${R}`;
|
|
413
|
+
}
|
|
414
|
+
// Bullets at line start
|
|
415
|
+
m = line.match(/^(\s*)[-*]\s+(.*)$/);
|
|
416
|
+
if (m) {
|
|
417
|
+
line = `${m[1]}${GRAY}•${R} ${m[2]}`;
|
|
418
|
+
}
|
|
419
|
+
// Numbered lists
|
|
420
|
+
m = line.match(/^(\s*)(\d+\.)\s+(.*)$/);
|
|
421
|
+
if (m) {
|
|
422
|
+
line = `${m[1]}${GRAY}${m[2]}${R} ${m[3]}`;
|
|
423
|
+
}
|
|
424
|
+
// Bold (**text**)
|
|
425
|
+
line = line.replace(/\*\*([^*]+)\*\*/g, `${BOLD}$1${R}`);
|
|
426
|
+
// Inline code (`code`)
|
|
427
|
+
line = line.replace(/`([^`]+)`/g, `${GRAY}$1${R}`);
|
|
428
|
+
return line;
|
|
429
|
+
});
|
|
430
|
+
return styled.join("\n");
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* Stateful code-fence collapser.
|
|
434
|
+
*
|
|
435
|
+
* Replaces ```lang ... ``` blocks with a one-line marker
|
|
436
|
+
* " ┃ code: lang, N lines" so streaming code blocks don't flood the TUI.
|
|
437
|
+
*
|
|
438
|
+
* State:
|
|
439
|
+
* "text" — pass through verbatim (with partial-fence buffering)
|
|
440
|
+
* "fence" — silently buffer body; emit final marker on close
|
|
441
|
+
*
|
|
442
|
+
* Newline handling:
|
|
443
|
+
* We strip up to one trailing newline before the opening fence and one
|
|
444
|
+
* leading newline after the closing fence so the marker sits on its own
|
|
445
|
+
* line without doubling blank lines around it.
|
|
446
|
+
*/
|
|
383
447
|
function makeCodeFenceCollapser() {
|
|
384
448
|
let mode = "text";
|
|
385
449
|
let lang = "";
|
|
386
|
-
let buffered = "";
|
|
387
|
-
let pending = "";
|
|
388
|
-
const
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
return
|
|
393
|
-
}
|
|
450
|
+
let buffered = "";
|
|
451
|
+
let pending = "";
|
|
452
|
+
const countLines = (s) => {
|
|
453
|
+
if (!s)
|
|
454
|
+
return 0;
|
|
455
|
+
const trimmed = s.replace(/^\n+/, "").replace(/\n+$/, "");
|
|
456
|
+
return trimmed ? trimmed.split("\n").length : 0;
|
|
457
|
+
};
|
|
394
458
|
return {
|
|
395
459
|
feed(chunk) {
|
|
396
460
|
let result = "";
|
|
@@ -399,23 +463,26 @@ function makeCodeFenceCollapser() {
|
|
|
399
463
|
pending = "";
|
|
400
464
|
while (i < buf.length) {
|
|
401
465
|
if (mode === "text") {
|
|
402
|
-
// Look for ``` to enter fence mode
|
|
403
466
|
const fenceIdx = buf.indexOf("```", i);
|
|
404
467
|
if (fenceIdx === -1) {
|
|
405
|
-
// No fence in remaining text
|
|
406
|
-
//
|
|
468
|
+
// No fence in remaining text. Hold last 2 chars in case they're
|
|
469
|
+
// the start of an upcoming fence.
|
|
407
470
|
const safeEnd = Math.max(i, buf.length - 2);
|
|
408
471
|
result += buf.slice(i, safeEnd);
|
|
409
472
|
pending = buf.slice(safeEnd);
|
|
410
473
|
i = buf.length;
|
|
411
474
|
break;
|
|
412
475
|
}
|
|
413
|
-
// Emit text up to the fence
|
|
414
|
-
|
|
415
|
-
|
|
476
|
+
// Emit text up to the fence, but trim a single trailing newline so
|
|
477
|
+
// the marker sits on its own line without extra blank space.
|
|
478
|
+
let preFence = buf.slice(i, fenceIdx);
|
|
479
|
+
if (preFence.endsWith("\n"))
|
|
480
|
+
preFence = preFence.slice(0, -1);
|
|
481
|
+
result += preFence;
|
|
482
|
+
// Read the language declaration (everything up to the next newline).
|
|
416
483
|
const nlIdx = buf.indexOf("\n", fenceIdx + 3);
|
|
417
484
|
if (nlIdx === -1) {
|
|
418
|
-
//
|
|
485
|
+
// Opening line not complete yet — buffer for next feed.
|
|
419
486
|
pending = buf.slice(fenceIdx);
|
|
420
487
|
i = buf.length;
|
|
421
488
|
break;
|
|
@@ -424,31 +491,35 @@ function makeCodeFenceCollapser() {
|
|
|
424
491
|
i = nlIdx + 1;
|
|
425
492
|
mode = "fence";
|
|
426
493
|
buffered = "";
|
|
427
|
-
//
|
|
428
|
-
|
|
494
|
+
// Don't emit anything yet — the final marker is written when we
|
|
495
|
+
// see the closing fence so we have the line count.
|
|
429
496
|
continue;
|
|
430
497
|
}
|
|
431
498
|
// mode === "fence" — look for closing ```
|
|
432
499
|
const closeIdx = buf.indexOf("```", i);
|
|
433
500
|
if (closeIdx === -1) {
|
|
501
|
+
// No close fence yet — buffer the body.
|
|
434
502
|
buffered += buf.slice(i);
|
|
435
|
-
// Hold last 2 chars in case they're part of an upcoming close fence
|
|
503
|
+
// Hold last 2 chars in case they're part of an upcoming close fence.
|
|
436
504
|
const safeEnd = Math.max(i, buf.length - 2);
|
|
437
505
|
buffered = buffered.slice(0, buffered.length - (buf.length - safeEnd));
|
|
438
506
|
pending = buf.slice(safeEnd);
|
|
439
507
|
i = buf.length;
|
|
440
508
|
break;
|
|
441
509
|
}
|
|
442
|
-
// Closing fence found
|
|
510
|
+
// Closing fence found.
|
|
443
511
|
buffered += buf.slice(i, closeIdx);
|
|
444
|
-
const lineCount =
|
|
445
|
-
//
|
|
446
|
-
//
|
|
447
|
-
result += `\
|
|
512
|
+
const lineCount = countLines(buffered);
|
|
513
|
+
// Emit the marker on its own line with leading and trailing newlines.
|
|
514
|
+
// The outer indenter will prepend " " to each line break.
|
|
515
|
+
result += `\n${GRAY}┃ code: ${lang}, ${lineCount} line${lineCount === 1 ? "" : "s"}${R}`;
|
|
448
516
|
i = closeIdx + 3;
|
|
449
|
-
// Skip
|
|
517
|
+
// Skip a single newline immediately after the close fence to avoid
|
|
518
|
+
// doubling blank lines.
|
|
450
519
|
if (buf[i] === "\n")
|
|
451
520
|
i++;
|
|
521
|
+
// Add a trailing newline so the next text starts on a fresh line.
|
|
522
|
+
result += "\n";
|
|
452
523
|
mode = "text";
|
|
453
524
|
lang = "";
|
|
454
525
|
buffered = "";
|
|
@@ -456,12 +527,12 @@ function makeCodeFenceCollapser() {
|
|
|
456
527
|
return result;
|
|
457
528
|
},
|
|
458
529
|
flush() {
|
|
459
|
-
const tail =
|
|
530
|
+
const tail = pending;
|
|
531
|
+
pending = "";
|
|
460
532
|
if (mode === "fence") {
|
|
461
|
-
|
|
462
|
-
const lineCount = lines(buffered.replace(/\n+$/, ""));
|
|
533
|
+
const lineCount = countLines(buffered);
|
|
463
534
|
mode = "text";
|
|
464
|
-
return tail + `\
|
|
535
|
+
return tail + `\n${GRAY}┃ code: ${lang}, ${lineCount}+ lines${R}\n`;
|
|
465
536
|
}
|
|
466
537
|
return tail;
|
|
467
538
|
},
|
|
@@ -535,8 +606,10 @@ async function streamPrompt(opts) {
|
|
|
535
606
|
// code blocks appear as "[code: lang]" placeholders instead of
|
|
536
607
|
// dumping raw source.
|
|
537
608
|
const piece = collapseCodeFences(text);
|
|
609
|
+
// Apply lightweight markdown styling (headers, bold, inline code)
|
|
610
|
+
const styled = applyInlineMarkdown(piece);
|
|
538
611
|
// Print with leading-newline indenting (so each new line gets the 3-space prefix)
|
|
539
|
-
const indented =
|
|
612
|
+
const indented = styled.replace(/\n/g, `\n `);
|
|
540
613
|
out(indented);
|
|
541
614
|
fullText += text;
|
|
542
615
|
continue;
|
|
@@ -679,6 +752,22 @@ function clearMenu(rows) {
|
|
|
679
752
|
}
|
|
680
753
|
// ─── Main TUI loop ────────────────────────────────────────────────────────────
|
|
681
754
|
async function runTUI(opts) {
|
|
755
|
+
// Force UTF-8 output on Windows so emoji and box-drawing chars render
|
|
756
|
+
// correctly. Without this, console code page 437/850 corrupts multi-byte
|
|
757
|
+
// sequences into "??" or mojibake.
|
|
758
|
+
if (process.platform === "win32") {
|
|
759
|
+
try {
|
|
760
|
+
// Set output encoding for stdout/stderr
|
|
761
|
+
process.stdout.setEncoding?.("utf-8");
|
|
762
|
+
process.stderr.setEncoding?.("utf-8");
|
|
763
|
+
// Switch the console to UTF-8 (code page 65001)
|
|
764
|
+
const { execSync } = require("child_process");
|
|
765
|
+
execSync("chcp 65001", { stdio: "ignore" });
|
|
766
|
+
}
|
|
767
|
+
catch {
|
|
768
|
+
// chcp not available — that's fine, we tried
|
|
769
|
+
}
|
|
770
|
+
}
|
|
682
771
|
let { model, provider } = opts;
|
|
683
772
|
const { port, token, worktree } = opts;
|
|
684
773
|
let sessionId = opts.sessionId || null;
|