Skip to content

Commit 70ca572

Browse files
committed
noooooooooo brekaing changes
1 parent 9d9830b commit 70ca572

21 files changed

Lines changed: 48 additions & 72 deletions

File tree

packages/opencode/src/acp/agent.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ export class Agent implements ACPAgent {
292292
const content: ToolCallContent[] = []
293293
if (output) {
294294
const hash = Hash.fast(output)
295-
if (ShellToolID.normalize(part.tool) === ShellToolID.id) {
295+
if (part.tool === ShellToolID.id) {
296296
if (this.shellSnapshots.get(part.callID) === hash) {
297297
await this.connection
298298
.sessionUpdate({
@@ -1107,7 +1107,7 @@ export class Agent implements ACPAgent {
11071107
}
11081108

11091109
private shellOutput(part: ToolPart) {
1110-
if (ShellToolID.normalize(part.tool) !== ShellToolID.id) return
1110+
if (part.tool !== ShellToolID.id) return
11111111
if (!("metadata" in part.state) || !part.state.metadata || typeof part.state.metadata !== "object") return
11121112
const output = part.state.metadata["output"]
11131113
if (typeof output !== "string") return
@@ -1550,7 +1550,7 @@ export class Agent implements ACPAgent {
15501550

15511551
function toToolKind(toolName: string): ToolKind {
15521552
const tool = toolName.toLocaleLowerCase()
1553-
if (ShellToolID.normalize(tool) === ShellToolID.id) return "execute"
1553+
if (tool === ShellToolID.id) return "execute"
15541554

15551555
switch (tool) {
15561556
case "webfetch":
@@ -1577,7 +1577,7 @@ function toToolKind(toolName: string): ToolKind {
15771577

15781578
function toLocations(toolName: string, input: Record<string, any>): { path: string }[] {
15791579
const tool = toolName.toLocaleLowerCase()
1580-
if (ShellToolID.normalize(tool) === ShellToolID.id) return []
1580+
if (tool === ShellToolID.id) return []
15811581

15821582
switch (tool) {
15831583
case "read":

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import fs from "fs/promises"
1010
import { Filesystem } from "../../util"
1111
import matter from "gray-matter"
1212
import { Instance } from "../../project/instance"
13-
import { ShellToolID } from "../../tool/shell/id"
1413
import { EOL } from "os"
1514
import type { Argv } from "yargs"
1615
type AgentMode = "all" | "primary" | "subagent"
@@ -129,7 +128,6 @@ const AgentCreateCommand = cmd({
129128
cliTools
130129
.split(",")
131130
.map((t) => t.trim())
132-
.map(ShellToolID.normalize)
133131
.filter(Boolean),
134132
),
135133
]

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ export const RunCommand = cmd({
409409
async function execute(sdk: OpencodeClient) {
410410
function tool(part: ToolPart) {
411411
try {
412-
if (ShellToolID.normalize(part.tool) === ShellToolID.id) return shell(props<typeof ShellTool>(part))
412+
if (part.tool === ShellToolID.id) return shell(props<typeof ShellTool>(part))
413413
if (part.tool === "glob") return glob(props<typeof GlobTool>(part))
414414
if (part.tool === "grep") return grep(props<typeof GrepTool>(part))
415415
if (part.tool === "read") return read(props<typeof ReadTool>(part))

packages/opencode/src/cli/cmd/tui/routes/session/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1551,7 +1551,7 @@ function ToolPart(props: { last: boolean; part: ToolPart; message: AssistantMess
15511551
return (
15521552
<Show when={!shouldHide()}>
15531553
<Switch>
1554-
<Match when={ShellToolID.normalize(props.part.tool) === ShellToolID.id}>
1554+
<Match when={props.part.tool === ShellToolID.id}>
15551555
<Shell {...toolprops} />
15561556
</Match>
15571557
<Match when={props.part.tool === "glob"}>

packages/opencode/src/cli/cmd/tui/routes/session/permission.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ export function PermissionPrompt(props: { request: PermissionRequest }) {
288288
}
289289
}
290290

291-
if (ShellToolID.normalize(permission) === ShellToolID.id) {
291+
if (permission === ShellToolID.id) {
292292
const title =
293293
typeof data.description === "string" && data.description ? data.description : "Shell command"
294294
const command = typeof data.command === "string" ? data.command : ""

packages/opencode/src/config/agent.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import * as ConfigMarkdown from "./markdown"
1212
import { ConfigModelID } from "./model-id"
1313
import { ConfigParse } from "./parse"
1414
import { ConfigPermission } from "./permission"
15-
import { ShellToolID } from "@/tool/shell/id"
1615

1716
const log = Log.create({ service: "config" })
1817

@@ -90,7 +89,7 @@ const normalize = (agent: Schema.Schema.Type<typeof AgentSchema>): Schema.Schema
9089
permission.edit = action
9190
continue
9291
}
93-
if (ShellToolID.normalize(tool) === ShellToolID.id) {
92+
if (tool === "bash") {
9493
permission.bash = action
9594
continue
9695
}

packages/opencode/src/config/config.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ import { ConfigServer } from "./server"
4343
import { ConfigSkills } from "./skills"
4444
import { ConfigVariable } from "./variable"
4545
import { Npm } from "@opencode-ai/core/npm"
46-
import { ShellToolID } from "@/tool/shell/id"
4746

4847
const log = Log.create({ service: "config" })
4948

@@ -671,7 +670,7 @@ export const layer = Layer.effect(
671670
perms.edit = action
672671
continue
673672
}
674-
if (ShellToolID.normalize(tool) === ShellToolID.id) {
673+
if (tool === "bash") {
675674
perms.bash = action
676675
continue
677676
}
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Wildcard } from "@/util"
2-
import { ShellToolID } from "@/tool/shell/id"
32

43
type Rule = {
54
permission: string
@@ -8,10 +7,7 @@ type Rule = {
87
}
98

109
export function evaluate(permission: string, pattern: string, ...rulesets: Rule[][]): Rule {
11-
const next = ShellToolID.normalize(permission)
1210
const rules = rulesets.flat()
13-
const match = rules.findLast(
14-
(rule) => Wildcard.match(next, ShellToolID.normalize(rule.permission)) && Wildcard.match(pattern, rule.pattern),
15-
)
11+
const match = rules.findLast((rule) => Wildcard.match(permission, rule.permission) && Wildcard.match(pattern, rule.pattern))
1612
return match ?? { action: "ask", permission, pattern: "*" }
1713
}

packages/opencode/src/permission/index.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import { Deferred, Effect, Layer, Schema, Context } from "effect"
1414
import os from "os"
1515
import { evaluate as evalRule } from "./evaluate"
1616
import { PermissionID } from "./schema"
17-
import { ShellToolID } from "@/tool/shell/id"
1817

1918
const log = Log.create({ service: "permission" })
2019

@@ -187,9 +186,7 @@ export const layer = Layer.effect(
187186
log.info("evaluated", { permission: request.permission, pattern, action: rule })
188187
if (rule.action === "deny") {
189188
return yield* new DeniedError({
190-
ruleset: ruleset.filter((rule) =>
191-
Wildcard.match(ShellToolID.normalize(request.permission), ShellToolID.normalize(rule.permission)),
192-
),
189+
ruleset: ruleset.filter((rule) => Wildcard.match(request.permission, rule.permission)),
193190
})
194191
}
195192
if (rule.action === "allow") continue
@@ -294,13 +291,12 @@ function expand(pattern: string): string {
294291
export function fromConfig(permission: ConfigPermission.Info) {
295292
const ruleset: Ruleset = []
296293
for (const [key, value] of Object.entries(permission)) {
297-
const permission = ShellToolID.normalize(key)
298294
if (typeof value === "string") {
299-
ruleset.push({ permission, action: value, pattern: "*" })
295+
ruleset.push({ permission: key, action: value, pattern: "*" })
300296
continue
301297
}
302298
ruleset.push(
303-
...Object.entries(value).map(([pattern, action]) => ({ permission, pattern: expand(pattern), action })),
299+
...Object.entries(value).map(([pattern, action]) => ({ permission: key, pattern: expand(pattern), action })),
304300
)
305301
}
306302
return ruleset
@@ -315,8 +311,8 @@ const EDIT_TOOLS = ["edit", "write", "apply_patch"]
315311
export function disabled(tools: string[], ruleset: Ruleset): Set<string> {
316312
const result = new Set<string>()
317313
for (const tool of tools) {
318-
const permission = EDIT_TOOLS.includes(tool) ? "edit" : ShellToolID.normalize(tool)
319-
const rule = ruleset.findLast((rule) => Wildcard.match(permission, ShellToolID.normalize(rule.permission)))
314+
const permission = EDIT_TOOLS.includes(tool) ? "edit" : tool
315+
const rule = ruleset.findLast((rule) => Wildcard.match(permission, rule.permission))
320316
if (!rule) continue
321317
if (rule.pattern === "*" && rule.action === "deny") result.add(tool)
322318
}

packages/opencode/src/session/llm.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import { Auth } from "@/auth"
2222
import { Installation } from "@/installation"
2323
import { InstallationVersion } from "@opencode-ai/core/installation/version"
2424
import { EffectBridge } from "@/effect"
25-
import { ShellToolID } from "@/tool/shell/id"
2625
import * as Option from "effect/Option"
2726
import * as OtelTracer from "@effect/opentelemetry/Tracer"
2827

@@ -447,7 +446,7 @@ export const defaultLayer = Layer.suspend(() =>
447446
)
448447

449448
export function repairToolName(toolName: string, tools: Record<string, Tool>) {
450-
const next = ShellToolID.normalize(toolName.toLowerCase())
449+
const next = toolName.toLowerCase()
451450
if (!tools[next]) return
452451
return next
453452
}

0 commit comments

Comments
 (0)