From 7e247eac465cf732db7e8190e698c6eee941a732 Mon Sep 17 00:00:00 2001 From: can1357 Date: Mon, 22 Jun 2026 05:44:01 +0200 Subject: [PATCH] refactor(coding-agent/prompts): updated system and tool prompts to present - Updated system and tool prompts to present dedicated tools as preferred defaults rather than absolute prohibitions. - Relaxed the hard-forbidding of shell equivalents for file operations, searching, and editing. - Retained guidance on prioritizing tools for their gitignore semantics, structure, and line-anchoring capabilities. --- packages/coding-agent/CHANGELOG.md | 2 ++ .../src/prompts/system/system-prompt.md | 20 +++++++++---------- .../coding-agent/src/prompts/tools/bash.md | 1 - .../coding-agent/src/prompts/tools/find.md | 3 --- .../coding-agent/src/prompts/tools/read.md | 3 +-- .../coding-agent/src/prompts/tools/replace.md | 2 +- .../coding-agent/src/prompts/tools/search.md | 1 - 7 files changed, 14 insertions(+), 18 deletions(-) diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md index 869b6c4fb..5321f1daf 100644 --- a/packages/coding-agent/CHANGELOG.md +++ b/packages/coding-agent/CHANGELOG.md @@ -4,6 +4,8 @@ ### Changed +- Unified subprocess lifecycle management for mnemopi, speech, tiny-model, and TTS workers +- Softened the system-prompt and tool-prompt guidance that hard-forbade reaching for shell equivalents of dedicated tools (`grep`/`rg`, `sed`/`perl -i`, `cat`/`head`/`tail`, `find`/`fd`). The "Specialized Tool Priority" section, the `bash`/`search`/`find`/`read`/`replace` tool prompts, and the FORBIDDEN/NEVER framing now state the dedicated tools as the preferred default rather than an absolute prohibition, so the agent no longer fights itself when a quick shell command is the right call. The opt-in `bashInterceptor` (default off) still hard-blocks these commands for users who enable it. - Refined TUI dashboard and list component layout logic for consistent rendering - Standardized scrollbar behaviors and keyboard navigation across all list components - Optimized internal message framing logic for better performance when handling large data bursts diff --git a/packages/coding-agent/src/prompts/system/system-prompt.md b/packages/coding-agent/src/prompts/system/system-prompt.md index 1a46b0594..99e53fdc0 100644 --- a/packages/coding-agent/src/prompts/system/system-prompt.md +++ b/packages/coding-agent/src/prompts/system/system-prompt.md @@ -101,17 +101,17 @@ Use tools whenever they improve correctness, completeness, or grounding. {{#if secretsEnabled}}- Redacted `#XXXX#` tokens in output are opaque strings.{{/if}} {{#has tools "inspect_image"}}- Image tasks: prefer `{{toolRefs.inspect_image}}` over `{{toolRefs.read}}` to spare session context.{{/has}} -# Specialized Tool Priority -You MUST use the specialized tool over its shell equivalent: -{{#has tools "read"}}- File or directory reads → `{{toolRefs.read}}`, not `cat` or `ls` (a directory path lists entries).{{/has}} -{{#has tools "edit"}}- Surgical edits → `{{toolRefs.edit}}`, not `sed`.{{/has}} -{{#has tools "write"}}- Create or overwrite → `{{toolRefs.write}}`, not shell redirection.{{/has}} -{{#has tools "lsp"}}- Code intelligence → `{{toolRefs.lsp}}`, not blind search.{{/has}} -{{#has tools "search"}}- Regex search → `{{toolRefs.search}}`, not `grep`, `rg`, or `awk`.{{/has}} -{{#has tools "find"}}- Globbing → `{{toolRefs.find}}`, not `ls **/*.ext` or `fd`.{{/has}} +# Specialized Tools +Dedicated tools add gitignore semantics, structured output, and line anchors a raw shell command lacks — reach for them first when they fit: +{{#has tools "read"}}- File or directory reads → `{{toolRefs.read}}` (a directory path lists entries).{{/has}} +{{#has tools "edit"}}- Surgical edits → `{{toolRefs.edit}}`.{{/has}} +{{#has tools "write"}}- Create or overwrite → `{{toolRefs.write}}`.{{/has}} +{{#has tools "lsp"}}- Code intelligence → `{{toolRefs.lsp}}`.{{/has}} +{{#has tools "search"}}- Regex search → `{{toolRefs.search}}`.{{/has}} +{{#has tools "find"}}- Globbing → `{{toolRefs.find}}`.{{/has}} {{#has tools "eval"}}- Quick compute → `{{toolRefs.eval}}`; you SHOULD go step by step.{{/has}} -{{#has tools "bash"}}- Use `{{toolRefs.bash}}` for terminal work—builds, tests, git, package managers—and pipelines that COMPUTE a fact: `wc -l`, `sort | uniq -c`, `comm`, `diff a b`, checksums. Commands shadowing the tools above are blocked. -- Litmus: produces a count, frequency, set difference, or checksum no tool returns → bash. Merely moves, pages, or trims bytes a tool can fetch → use the tool.{{/has}} +{{#has tools "bash"}}- Use `{{toolRefs.bash}}` for terminal work—builds, tests, git, package managers—and pipelines that COMPUTE a fact: `wc -l`, `sort | uniq -c`, `comm`, `diff a b`, checksums. +- Litmus: produces a count, frequency, set difference, or checksum no tool returns → bash. Otherwise a dedicated tool usually fits.{{/has}} {{#has tools "report_tool_issue"}} diff --git a/packages/coding-agent/src/prompts/tools/bash.md b/packages/coding-agent/src/prompts/tools/bash.md index 9661a4f48..6031544f8 100644 --- a/packages/coding-agent/src/prompts/tools/bash.md +++ b/packages/coding-agent/src/prompts/tools/bash.md @@ -14,7 +14,6 @@ Runs bash in a shell session — terminal ops: git, bun, cargo, python. -- NEVER shell out to fetch, display, list, page, or search what a dedicated tool serves: `cat`/`head`/`tail`/`less`/`more`/`ls` → `read`; `grep`/`rg`/`ag`/`ack` → `search`; `find`/`fd` → `find`; `sed -i`/`perl -i`/`awk -i` → `edit`; `echo >`/heredoc → `write`. Tools keep gitignore semantics, line anchors, structured output shell loses. - NEVER trim or silence output: no `| head -n N`, `| tail -n N`, `| less`, `2>&1`, `2>/dev/null`. stderr already merged; long output auto-truncated, FULL capture kept at `artifact://`. - Pipelines that COMPUTE a new fact are correct bash: `wc -l`, `sort | uniq -c`, `comm`, `cut`, `diff a b`, `shasum`. Litmus: produces a count, frequency table, set difference, or checksum no tool returns → bash. Merely moves or trims bytes a tool can fetch → use the tool. diff --git a/packages/coding-agent/src/prompts/tools/find.md b/packages/coding-agent/src/prompts/tools/find.md index 5f12ad0af..5436dca0c 100644 --- a/packages/coding-agent/src/prompts/tools/find.md +++ b/packages/coding-agent/src/prompts/tools/find.md @@ -14,6 +14,3 @@ Matching paths sorted by mtime (newest first), grouped under `# /` headers Open-ended searches needing multiple rounds of globbing/searching: you MUST use the Task tool instead. - -- You MUST use the built-in Find tool for every file-name lookup. NEVER shell out to `find`, `fd`, `locate`, `ls`, or `git ls-files` via Bash — they ignore `.gitignore`, blow past result limits, and waste tokens. - diff --git a/packages/coding-agent/src/prompts/tools/read.md b/packages/coding-agent/src/prompts/tools/read.md index bce1be1da..2bc641189 100644 --- a/packages/coding-agent/src/prompts/tools/read.md +++ b/packages/coding-agent/src/prompts/tools/read.md @@ -70,7 +70,6 @@ For `.sqlite`, `.sqlite3`, `.db`, `.db3`: All URI schemes take the same line selectors. `artifact://` recovers full output a bash/eval/tool result spilled or truncated. `history://` = agent transcript; bare `history://` lists agents. -- MUST use `read` for every file/directory/archive/URL inspection. `cat`, `head`, `tail`, `less`, `more`, `ls`, `tar`, `unzip`, `curl`, `wget` are FORBIDDEN bash calls, however convenient. -- Line ranges go in the selector (`path="src/foo.ts:50-200"`) — NEVER `sed -n`, `awk NR`, or `head`/`tail` pipelines. +- Line ranges go in the selector: `path="src/foo.ts:50-200"`. - Summary footer names elided ranges? Re-issue ONLY those ranges. NEVER guess `..`/`…` content. diff --git a/packages/coding-agent/src/prompts/tools/replace.md b/packages/coding-agent/src/prompts/tools/replace.md index 3f404d660..ce5e10f45 100644 --- a/packages/coding-agent/src/prompts/tools/replace.md +++ b/packages/coding-agent/src/prompts/tools/replace.md @@ -25,5 +25,5 @@ For pattern-addressed bulk changes, bash is more efficient: |Bulk replace across files|`sd 'pattern' 'replacement' **/*.ts`| Use Replace when _content itself_ identifies location; use `ast_edit` for structure-aware codemods. -NEVER use `sed -i`/`perl -i`/heredoc redirection for edits — those calls are blocked; use this tool or `write`. +For in-place edits prefer this tool or `write` — you get a diff preview and fuzzy matching. diff --git a/packages/coding-agent/src/prompts/tools/search.md b/packages/coding-agent/src/prompts/tools/search.md index 097d1a3fd..6e30b3e29 100644 --- a/packages/coding-agent/src/prompts/tools/search.md +++ b/packages/coding-agent/src/prompts/tools/search.md @@ -17,6 +17,5 @@ Searches files using regex. -- MUST use built-in `search` for any content search. NEVER shell out to `grep`, `rg`, `ripgrep`, `ag`, `ack`, `git grep`, `awk`, `sed`-for-search, or any CLI search via Bash — not even for one match or a quick check. - Open-ended search needing multiple rounds? MUST use the Task tool with the explore subagent, NOT chained `search` calls.