Skip to content

Commit f868719

Browse files
committed
.
1 parent d5ebfad commit f868719

10 files changed

Lines changed: 11 additions & 71 deletions

File tree

packages/opencode/src/cli/cmd/agent.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import matter from "gray-matter"
1212
import { Instance } from "../../project/instance"
1313
import { EOL } from "os"
1414
import type { Argv } from "yargs"
15+
1516
type AgentMode = "all" | "primary" | "subagent"
1617

1718
// Permission keys (not raw tool names). Multiple tools can map to a single

packages/opencode/src/config/agent.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,10 @@ const normalize = (agent: Schema.Schema.Type<typeof AgentSchema>): Schema.Schema
8585
const permission: ConfigPermission.Info = {}
8686
for (const [tool, enabled] of Object.entries(agent.tools ?? {})) {
8787
const action = enabled ? "allow" : "deny"
88-
if (tool === "write" || tool === "edit" || tool === "patch" || tool === "multiedit") {
88+
if (tool === "write" || tool === "edit" || tool === "patch") {
8989
permission.edit = action
9090
continue
9191
}
92-
if (tool === "bash") {
93-
permission.bash = action
94-
continue
95-
}
9692
permission[tool] = action
9793
}
9894
globalThis.Object.assign(permission, agent.permission)

packages/opencode/src/config/config.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -666,14 +666,10 @@ export const layer = Layer.effect(
666666
const perms: Record<string, ConfigPermission.Action> = {}
667667
for (const [tool, enabled] of Object.entries(result.tools)) {
668668
const action: ConfigPermission.Action = enabled ? "allow" : "deny"
669-
if (tool === "write" || tool === "edit" || tool === "patch" || tool === "multiedit") {
669+
if (tool === "write" || tool === "edit" || tool === "patch") {
670670
perms.edit = action
671671
continue
672672
}
673-
if (tool === "bash") {
674-
perms.bash = action
675-
continue
676-
}
677673
perms[tool] = action
678674
}
679675
result.permission = mergeDeep(perms, result.permission ?? {})

packages/opencode/src/permission/evaluate.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ type Rule = {
88

99
export function evaluate(permission: string, pattern: string, ...rulesets: Rule[][]): Rule {
1010
const rules = rulesets.flat()
11-
const match = rules.findLast((rule) => Wildcard.match(permission, rule.permission) && Wildcard.match(pattern, rule.pattern))
11+
const match = rules.findLast(
12+
(rule) => Wildcard.match(permission, rule.permission) && Wildcard.match(pattern, rule.pattern),
13+
)
1214
return match ?? { action: "ask", permission, pattern: "*" }
1315
}

packages/opencode/src/session/message-v2.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ const part = (row: typeof PartTable.$inferSelect) =>
679679
id: row.id,
680680
sessionID: row.session_id,
681681
messageID: row.message_id,
682-
} as Part)
682+
}) as Part
683683

684684
const older = (row: Cursor) =>
685685
or(lt(MessageTable.time_created, row.time), and(eq(MessageTable.time_created, row.time), lt(MessageTable.id, row.id)))

packages/opencode/src/tool/task.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ export const TaskTool = Tool.define(
3939
ctx: Tool.Context,
4040
) {
4141
const cfg = yield* config.get()
42-
const primaryTools = cfg.experimental?.primary_tools ?? []
4342

4443
if (!ctx.extra?.bypassAgentCheck) {
4544
yield* ctx.ask({
@@ -89,11 +88,11 @@ export const TaskTool = Tool.define(
8988
action: "deny" as const,
9089
},
9190
]),
92-
...primaryTools.map((item) => ({
91+
...(cfg.experimental?.primary_tools?.map((item) => ({
9392
pattern: "*",
9493
action: "allow" as const,
9594
permission: item,
96-
})),
95+
})) ?? []),
9796
],
9897
}))
9998

@@ -140,7 +139,7 @@ export const TaskTool = Tool.define(
140139
tools: {
141140
...(canTodo ? {} : { todowrite: false }),
142141
...(canTask ? {} : { task: false }),
143-
...Object.fromEntries(primaryTools.map((item) => [item, false])),
142+
...Object.fromEntries((cfg.experimental?.primary_tools ?? []).map((item) => [item, false])),
144143
},
145144
parts,
146145
})

packages/opencode/test/config/config.test.ts

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1669,32 +1669,6 @@ test("permission config preserves user key order", async () => {
16691669
})
16701670
})
16711671

1672-
test("permission config preserves bash key", async () => {
1673-
await using tmp = await tmpdir({
1674-
init: async (dir) => {
1675-
await Filesystem.write(
1676-
path.join(dir, "opencode.json"),
1677-
JSON.stringify({
1678-
$schema: "https://opencode.ai/config.json",
1679-
permission: {
1680-
bash: "allow",
1681-
},
1682-
}),
1683-
)
1684-
},
1685-
})
1686-
await Instance.provide({
1687-
directory: tmp.path,
1688-
fn: async () => {
1689-
const config = await load()
1690-
expect(Object.keys(config.permission!)).toEqual(["bash"])
1691-
expect(config.permission).toEqual({
1692-
bash: "allow",
1693-
})
1694-
},
1695-
})
1696-
})
1697-
16981672
test("Effect config parser preserves permission order while rejecting unknown top-level keys", () => {
16991673
const config = ConfigParse.effectSchema(
17001674
Config.Info,

packages/opencode/test/permission/next.test.ts

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -103,28 +103,6 @@ test("fromConfig - mixed string and object values", () => {
103103
])
104104
})
105105

106-
test("fromConfig - custom key remains separate from bash", () => {
107-
const result = Permission.fromConfig({
108-
custom: "deny",
109-
bash: "allow",
110-
})
111-
expect(result).toEqual([
112-
{ permission: "custom", pattern: "*", action: "deny" },
113-
{ permission: "bash", pattern: "*", action: "allow" },
114-
])
115-
expect(Permission.evaluate("bash", "ls", result).action).toBe("allow")
116-
expect(Permission.evaluate("custom", "ls", result).action).toBe("deny")
117-
})
118-
119-
test("fromConfig - custom rules do not affect bash rules", () => {
120-
const result = Permission.fromConfig({
121-
custom: { "rm *": "deny" },
122-
bash: { "*": "allow", "rm *": "ask" },
123-
})
124-
expect(Permission.evaluate("custom", "rm foo", result).action).toBe("deny")
125-
expect(Permission.evaluate("bash", "rm foo", result).action).toBe("ask")
126-
})
127-
128106
test("fromConfig - empty object", () => {
129107
const result = Permission.fromConfig({})
130108
expect(result).toEqual([])
@@ -304,11 +282,6 @@ test("evaluate - exact pattern match", () => {
304282
expect(result.action).toBe("deny")
305283
})
306284

307-
test("evaluate - custom tool does not match bash rules", () => {
308-
const result = Permission.evaluate("custom", "rm", [{ permission: "bash", pattern: "rm", action: "deny" }])
309-
expect(result.action).toBe("ask")
310-
})
311-
312285
test("evaluate - wildcard pattern match", () => {
313286
const result = Permission.evaluate("bash", "rm", [{ permission: "bash", pattern: "*", action: "allow" }])
314287
expect(result.action).toBe("allow")

packages/opencode/test/session/snapshot-tool-race.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,5 +246,4 @@ it.live("tool execution produces non-empty session diff (snapshot race)", () =>
246246
}),
247247
{ git: true, config: providerCfg },
248248
),
249-
20_000,
250249
)

packages/ui/src/components/shell-submessage-motion.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Interactive playground for animating the Shell tool subtitle ("submessage") in t
1616
1717
### Production component path
1818
- Trigger layout: \`packages/ui/src/components/basic-tool.tsx\`
19-
- Shell tool subtitle source: \`packages/ui/src/components/message-part.tsx\` (tool: \`bash\`, \`trigger.subtitle\`)
19+
- Bash tool subtitle source: \`packages/ui/src/components/message-part.tsx\` (tool: \`bash\`, \`trigger.subtitle\`)
2020
2121
### What this playground tunes
2222
- Width reveal (spring-driven pixel width via \`useSpring\`)

0 commit comments

Comments
 (0)