-
Notifications
You must be signed in to change notification settings - Fork 8
fix: add main-branch write restrictions for subagents #343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -37,6 +37,12 @@ tools: | |||||||
|
|
||||||||
| **Process**: Complete task first, cite evidence, check duplicates, propose specific fix, ask permission | ||||||||
|
|
||||||||
| **Write Restrictions (MANDATORY)**: This subagent has `write: true` but MUST respect branch protection. When the working directory is on `main`/`master`: | ||||||||
|
|
||||||||
| - **ALLOWED writes**: `README.md`, `TODO.md`, `todo/PLANS.md`, `todo/tasks/*` | ||||||||
| - **BLOCKED writes**: All other files (agent definitions, scripts, configs, code) | ||||||||
| - **For code changes**: Return proposed edits to the calling agent; do NOT write directly. The calling agent will apply them in a worktree. | ||||||||
|
Comment on lines
+43
to
+44
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The distinction between
Suggested change
|
||||||||
|
|
||||||||
| **Testing**: Use OpenCode CLI to test agent/config changes without restarting TUI: | ||||||||
|
|
||||||||
| ```bash | ||||||||
|
|
||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -241,10 +241,19 @@ tools: | |||||
|
|
||||||
| **Note on permissions**: Path-based permissions (e.g., restricting which files can be edited) are configured in `opencode.json` for OpenCode, not in markdown frontmatter. The frontmatter defines which tools are available; the JSON config defines granular restrictions. | ||||||
|
|
||||||
| **Main-branch write restrictions**: Subagents with `write: true` / `edit: true` that are invoked via the Task tool MUST respect the same branch protection as the primary agent. When the working directory is on `main`/`master`: | ||||||
|
|
||||||
| - **ALLOWED**: `README.md`, `TODO.md`, `todo/PLANS.md`, `todo/tasks/*` (planning and documentation files) | ||||||
| - **BLOCKED**: All other files (code, scripts, configs, agent definitions) | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The guidance for
Suggested change
|
||||||
| - **WORKTREE**: If a worktree is active, writes to the worktree path are unrestricted | ||||||
|
|
||||||
| Subagents cannot run `pre-edit-check.sh` (many lack `bash: true`), so this rule must be stated explicitly in the subagent's markdown. Add a "Write Restrictions" section to any subagent that has `write: true` and may be invoked on the main repo path. | ||||||
|
|
||||||
| **Why this matters:** | ||||||
| - Prevents confusion when agents recommend actions they cannot perform | ||||||
| - Makes agent capabilities explicit and predictable | ||||||
| - Enables safer parallel execution (read-only agents can't conflict) | ||||||
| - Prevents subagents from bypassing branch protection when invoked via Task tool | ||||||
| - Documents intent for both humans and AI systems | ||||||
|
|
||||||
| #### Agent Directory Architecture | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For better readability and consistency with the other updated files in this PR, consider restructuring this rule using a list format. This will make the allowed file paths easier to parse for both humans and agents.