Skip to content

Commit 680593e

Browse files
terisukeclaude
andcommitted
fix(team): allow single-task delegation and reduce big() false positives #32
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
1 parent 9952a4e commit 680593e

5 files changed

Lines changed: 10 additions & 47 deletions

File tree

‎packages/guardrails/managed/opencode.json‎

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -79,34 +79,16 @@
7979
"external_directory": "ask",
8080
"bash": {
8181
"*": "ask",
82-
"node *": "allow",
83-
"npm *": "allow",
84-
"npx *": "allow",
85-
"bun *": "allow",
86-
"git status*": "allow",
87-
"git diff*": "allow",
88-
"git log*": "allow",
89-
"git show*": "allow",
90-
"git branch*": "allow",
91-
"git remote*": "allow",
92-
"git stash*": "allow",
93-
"gh *": "allow",
94-
"ls *": "allow",
95-
"pwd": "allow",
96-
"which *": "allow",
97-
"echo *": "allow",
98-
"cat *": "ask",
9982
"rm -rf *": "deny",
100-
"rm -r *": "deny",
10183
"sudo *": "deny",
10284
"curl * | sh*": "deny",
10385
"wget * | sh*": "deny"
10486
},
10587
"read": {
10688
"*": "allow",
107-
"*.env.example": "allow",
10889
"*.env": "deny",
10990
"*.env.*": "deny",
91+
"*.env.example": "allow",
11092
"*id_rsa*": "deny",
11193
"*id_ed25519*": "deny",
11294
"*.pem": "deny",

‎packages/guardrails/profile/agents/implement.md‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,12 @@ permission:
55
question: allow
66
plan_enter: allow
77
bash:
8-
"*": ask
98
"git checkout -- *": deny
109
"git merge *": deny
1110
"git push --force*": deny
1211
"git push * --force*": deny
1312
"git reset --hard*": deny
1413
"gh pr merge *": deny
15-
"rm -rf *": deny
16-
"rm -r *": deny
17-
"sudo *": deny
18-
"curl * | sh*": deny
19-
"wget * | sh*": deny
2014
---
2115

2216
Implement changes in bounded increments.

‎packages/guardrails/profile/opencode.json‎

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -80,25 +80,7 @@
8080
"external_directory": "ask",
8181
"bash": {
8282
"*": "ask",
83-
"node *": "allow",
84-
"npm *": "allow",
85-
"npx *": "allow",
86-
"bun *": "allow",
87-
"git status*": "allow",
88-
"git diff*": "allow",
89-
"git log*": "allow",
90-
"git show*": "allow",
91-
"git branch*": "allow",
92-
"git remote*": "allow",
93-
"git stash*": "allow",
94-
"gh *": "allow",
95-
"ls *": "allow",
96-
"pwd": "allow",
97-
"which *": "allow",
98-
"echo *": "allow",
99-
"cat *": "ask",
10083
"rm -rf *": "deny",
101-
"rm -r *": "deny",
10284
"sudo *": "deny",
10385
"git checkout -- *": "deny",
10486
"git merge *": "deny",
@@ -111,9 +93,9 @@
11193
},
11294
"read": {
11395
"*": "allow",
114-
"*.env.example": "allow",
11596
"*.env": "deny",
11697
"*.env.*": "deny",
98+
"*.env.example": "allow",
11799
"*id_rsa*": "deny",
118100
"*id_ed25519*": "deny",
119101
"*.pem": "deny",

‎packages/guardrails/profile/plugins/guardrail.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ export default async function guardrail(input: {
437437
if ((item.tool === "edit" || item.tool === "write") && file && code(file)) {
438438
const count = await budget()
439439
if (count >= 4) {
440-
const err = `context budget exceeded after ${count} source reads; narrow scope or delegate before editing`
440+
const err = `context budget exceeded after ${count} source reads; call the team tool to delegate this edit to an isolated worker, or narrow scope`
441441
await mark({ last_block: item.tool, last_file: rel(input.worktree, file), last_reason: err })
442442
throw new Error(text(err))
443443
}

‎packages/guardrails/profile/plugins/team.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,11 @@ function mut(cmd: string) {
165165
function big(text: string) {
166166
const data = text.trim()
167167
if (!data) return false
168+
// Exempt read-only investigation requests that start with investigation verbs
169+
// and do NOT contain write-intent keywords
170+
const readOnly = /^\s*(investigate|diagnose|explain|analyze|check|status|report|describe|show|list|review|audit|inspect|確認|調査|分析|説明|レビュー)/i.test(data)
171+
&& !/(implement|create|rewrite|patch|refactor|fix|add|edit|write|modify|実装|改修|修正|追加)/i.test(data)
172+
if (readOnly) return false
168173
const plan = (data.match(/^\s*([-*]|\d+\.)\s+/gm) ?? []).length
169174
const impl = /(implement|implementation|build|create|add|fix|refactor|rewrite|patch|parallel|subagent|team|background|worker|修正|実装|追加|改修|並列|サブエージェント|チーム)/i.test(
170175
data,
@@ -475,7 +480,7 @@ export default async function team(input: {
475480
},
476481
async execute(args, ctx) {
477482
defs(args.tasks)
478-
if (args.tasks.length < 2) throw new Error("team requires at least two tasks")
483+
if (args.tasks.length < 1) throw new Error("team requires at least one task")
479484
ctx.metadata({
480485
title: "team run",
481486
metadata: {
@@ -738,7 +743,7 @@ export default async function team(input: {
738743
messageID: out.message.id,
739744
type: "text",
740745
text:
741-
"Parallel implementation policy is active for this request. Before any edit, write, apply_patch, or mutating bash call, you MUST call the `team` tool and fan out at least two worker tasks. Mark tasks that should edit code with `write: true`; those tasks will be isolated in git worktrees and merged back when possible. Use `background` only for side work that should keep running after this turn.",
746+
"Parallel implementation policy is active for this request. Before any edit, write, apply_patch, or mutating bash call, you MUST call the `team` tool and fan out at least one worker task. Mark tasks that should edit code with `write: true`; those tasks will be isolated in git worktrees and merged back when possible. Use `background` only for side work that should keep running after this turn.",
742747
})
743748
},
744749
"tool.execute.before": async (

0 commit comments

Comments
 (0)