Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .agents/plugins/opencode-aidevops/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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}$",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The keywords creat and generat are too broad and could lead to false negatives. For instance, if an agent's response is "I will edit file X, then create a pull request", the keyword creat will match "create", causing this rule to be incorrectly skipped. The read-before-edit check should still apply to file X in this scenario.

To make this more robust, the keywords should be more specific to file creation, for example by tying creat and generat to the word file.

Suggested change
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}$",
pattern: "(?:I'll edit|Let me edit|I'll write to|Let me write)(?!.*(?:creat.*file|new file|new \\w+ file|generat.*file))(?:(?!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",
Expand Down
2 changes: 1 addition & 1 deletion .agents/prompts/build.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading