From d78bbff4399ea86190476b7033f9d04b0ede02c8 Mon Sep 17 00:00:00 2001 From: Arpad Krejczinger Date: Thu, 11 Sep 2025 21:01:09 +0200 Subject: [PATCH] Remove path-based restrictions --- packages/opencode/src/tool/bash.ts | 12 ++++++------ packages/opencode/src/tool/edit.ts | 8 ++++---- packages/opencode/src/tool/read.ts | 8 ++++---- packages/opencode/src/tool/write.ts | 8 ++++---- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/packages/opencode/src/tool/bash.ts b/packages/opencode/src/tool/bash.ts index a7b6ec24..8edb2cb5 100644 --- a/packages/opencode/src/tool/bash.ts +++ b/packages/opencode/src/tool/bash.ts @@ -4,7 +4,7 @@ import { exec } from "child_process" import { Tool } from "./tool" import DESCRIPTION from "./bash.txt" import { Permission } from "../permission" -import { Filesystem } from "../util/filesystem" +// import { Filesystem } from "../util/filesystem" import { lazy } from "../util/lazy" import { Log } from "../util/log" import { Wildcard } from "../util/wildcard" @@ -87,11 +87,11 @@ export const BashTool = Tool.define("bash", { .text() .then((x) => x.trim()) log.info("resolved path", { arg, resolved }) - if (resolved && !Filesystem.contains(Instance.directory, resolved)) { - throw new Error( - `This command references paths outside of ${Instance.directory} so it is not allowed to be executed.`, - ) - } + // if (resolved && !Filesystem.contains(Instance.directory, resolved)) { + // throw new Error( + // `This command references paths outside of ${Instance.directory} so it is not allowed to be executed.`, + // ) + // } } } diff --git a/packages/opencode/src/tool/edit.ts b/packages/opencode/src/tool/edit.ts index 88e45302..3cec2e72 100644 --- a/packages/opencode/src/tool/edit.ts +++ b/packages/opencode/src/tool/edit.ts @@ -13,7 +13,7 @@ import DESCRIPTION from "./edit.txt" import { File } from "../file" import { Bus } from "../bus" import { FileTime } from "../file/time" -import { Filesystem } from "../util/filesystem" +// import { Filesystem } from "../util/filesystem" import { Instance } from "../project/instance" import { Agent } from "../agent/agent" @@ -35,9 +35,9 @@ export const EditTool = Tool.define("edit", { } const filePath = path.isAbsolute(params.filePath) ? params.filePath : path.join(Instance.directory, params.filePath) - if (!Filesystem.contains(Instance.directory, filePath)) { - throw new Error(`File ${filePath} is not in the current working directory`) - } + // if (!Filesystem.contains(Instance.directory, filePath)) { + // throw new Error(`File ${filePath} is not in the current working directory`) + // } const agent = await Agent.get(ctx.agent) let diff = "" diff --git a/packages/opencode/src/tool/read.ts b/packages/opencode/src/tool/read.ts index 2aaaf7a4..c6eb264d 100644 --- a/packages/opencode/src/tool/read.ts +++ b/packages/opencode/src/tool/read.ts @@ -5,7 +5,7 @@ import { Tool } from "./tool" import { LSP } from "../lsp" import { FileTime } from "../file/time" import DESCRIPTION from "./read.txt" -import { Filesystem } from "../util/filesystem" +// import { Filesystem } from "../util/filesystem" import { Instance } from "../project/instance" const DEFAULT_READ_LIMIT = 2000 @@ -23,9 +23,9 @@ export const ReadTool = Tool.define("read", { if (!path.isAbsolute(filepath)) { filepath = path.join(process.cwd(), filepath) } - if (!ctx.extra?.["bypassCwdCheck"] && !Filesystem.contains(Instance.directory, filepath)) { - throw new Error(`File ${filepath} is not in the current working directory`) - } + // if (!ctx.extra?.["bypassCwdCheck"] && !Filesystem.contains(Instance.directory, filepath)) { + // throw new Error(`File ${filepath} is not in the current working directory`) + // } const file = Bun.file(filepath) if (!(await file.exists())) { diff --git a/packages/opencode/src/tool/write.ts b/packages/opencode/src/tool/write.ts index dbd6e294..5c20870d 100644 --- a/packages/opencode/src/tool/write.ts +++ b/packages/opencode/src/tool/write.ts @@ -7,7 +7,7 @@ import DESCRIPTION from "./write.txt" import { Bus } from "../bus" import { File } from "../file" import { FileTime } from "../file/time" -import { Filesystem } from "../util/filesystem" +// import { Filesystem } from "../util/filesystem" import { Instance } from "../project/instance" import { Agent } from "../agent/agent" @@ -19,9 +19,9 @@ export const WriteTool = Tool.define("write", { }), async execute(params, ctx) { const filepath = path.isAbsolute(params.filePath) ? params.filePath : path.join(Instance.directory, params.filePath) - if (!Filesystem.contains(Instance.directory, filepath)) { - throw new Error(`File ${filepath} is not in the current working directory`) - } + // if (!Filesystem.contains(Instance.directory, filepath)) { + // throw new Error(`File ${filepath} is not in the current working directory`) + // } const file = Bun.file(filepath) const exists = await file.exists()