Skip to content

Commit 6c5d081

Browse files
committed
don't couple tool permissions
1 parent 7ddc22c commit 6c5d081

2 files changed

Lines changed: 2 additions & 12 deletions

File tree

packages/opencode/src/config/config.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -734,13 +734,7 @@ export namespace Config {
734734
// Convert legacy tools config to permissions
735735
const permission: Permission = {}
736736
for (const [tool, enabled] of Object.entries(agent.tools ?? {})) {
737-
const action = enabled ? "allow" : "deny"
738-
// write, edit, patch, multiedit all map to edit permission
739-
if (tool === "write" || tool === "edit" || tool === "patch" || tool === "multiedit") {
740-
permission.edit = action
741-
} else {
742-
permission[tool] = action
743-
}
737+
permission[tool] = enabled ? "allow" : "deny"
744738
}
745739
Object.assign(permission, agent.permission)
746740

packages/opencode/src/permission/next.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,14 +237,10 @@ export namespace PermissionNext {
237237
return match ?? { action: "ask", permission, pattern: "*" }
238238
}
239239

240-
const EDIT_TOOLS = ["edit", "write", "patch", "multiedit"]
241-
242240
export function disabled(tools: string[], ruleset: Ruleset): Set<string> {
243241
const result = new Set<string>()
244242
for (const tool of tools) {
245-
const permission = EDIT_TOOLS.includes(tool) ? "edit" : tool
246-
247-
const rule = ruleset.findLast((r) => Wildcard.match(permission, r.permission))
243+
const rule = ruleset.findLast((r) => Wildcard.match(tool, r.permission))
248244
if (!rule) continue
249245
if (rule.pattern === "*" && rule.action === "deny") result.add(tool)
250246
}

0 commit comments

Comments
 (0)