diff --git a/.agents/plugins/opencode-aidevops/index.mjs b/.agents/plugins/opencode-aidevops/index.mjs index 9fe6013b1..f5ed36118 100644 --- a/.agents/plugins/opencode-aidevops/index.mjs +++ b/.agents/plugins/opencode-aidevops/index.mjs @@ -1491,11 +1491,11 @@ const BUILTIN_TTSR_RULES = [ }, { id: "read-before-edit", - description: "Always Read a file before Edit or Write operations", - pattern: "(?:I'll edit|Let me edit|I'll write to|Let me write)(?:(?!I'll read|let me read|I've read|already read).){0,200}$", - correction: "ALWAYS Read a file before Edit/Write. These tools fail without a prior Read in this conversation.", + description: "Always Read a file before Edit or Write to existing files", + pattern: "(?:I'll edit|Let me edit|I'll write to|Let me write)(?!.*(?:creat|new file|new \\w+ file|generat))(?:(?!I'll read|let me read|I've read|already read).){0,200}$", + correction: "ALWAYS Read a file before Edit/Write to an existing file. These tools fail without a prior Read in this conversation. (This rule does not apply when creating new files.)", severity: "error", - systemPrompt: "ALWAYS Read a file before Edit or Write. These tools FAIL without a prior Read in this conversation.", + systemPrompt: "ALWAYS Read a file before Edit or Write to an existing file. These tools FAIL without a prior Read in this conversation. For NEW files, verify the parent directory exists instead.", }, { id: "no-credentials-in-output", diff --git a/.agents/prompts/build.txt b/.agents/prompts/build.txt index 30ec70e33..b1cc0368c 100644 --- a/.agents/prompts/build.txt +++ b/.agents/prompts/build.txt @@ -88,7 +88,7 @@ Use TodoWrite frequently to track tasks and show progress. Break complex tasks i When referencing specific functions or code include the pattern `file_path:line_number` to allow the user to easily navigate to the source code location. # File Operations (CRITICAL) -- ALWAYS Read a file before Edit or Write. These tools FAIL without a prior Read in this conversation. No exceptions. +- ALWAYS Read a file before Edit or Write to an existing file. These tools FAIL without a prior Read in this conversation. For NEW files (creating from scratch), verify the parent directory exists instead — reading a nonexistent file is not possible. - After any tool modifies a file (Edit, Write, Bash), re-read before the next Edit/Write on that same file. Stale content is the #1 error source. - Before Read/Edit/Write, verify the path exists (`git ls-files` or `fd`). Never assume a path from memory or from AGENTS.md references — paths move between releases. - When using Edit, include 3+ lines of surrounding context in oldString to ensure a unique match. Never pass identical oldString and newString — this is a silent no-op that wastes a tool call.