diff options
| author | Aiden Cline <[email protected]> | 2025-11-13 19:16:07 -0600 |
|---|---|---|
| committer | Aiden Cline <[email protected]> | 2025-11-13 19:16:07 -0600 |
| commit | 4c2e888709fde5aa870d426cf272c6d00495d5b5 (patch) | |
| tree | 64ce5e60e92309f0c9c9b3381720dd60412a0e9c | |
| parent | c78fd097d1b3b965499c4ee913f0458683b917be (diff) | |
| download | opencode-4c2e888709fde5aa870d426cf272c6d00495d5b5.tar.gz opencode-4c2e888709fde5aa870d426cf272c6d00495d5b5.zip | |
no mr llm, you may not read that
| -rw-r--r-- | packages/opencode/src/tool/read.ts | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/packages/opencode/src/tool/read.ts b/packages/opencode/src/tool/read.ts index 4d8e15bfb..fc33463a3 100644 --- a/packages/opencode/src/tool/read.ts +++ b/packages/opencode/src/tool/read.ts @@ -11,6 +11,7 @@ import { Provider } from "../provider/provider" import { Identifier } from "../id/id" import { Permission } from "../permission" import { Agent } from "@/agent/agent" +import { iife } from "@/util/iife" const DEFAULT_READ_LIMIT = 2000 const MAX_LINE_LENGTH = 2000 @@ -48,6 +49,19 @@ export const ReadTool = Tool.define("read", { } } + const block = (() => { + const whitelist = [".env.example", ".env.sample"] + + if (whitelist.some((w) => filepath.endsWith(w))) return false + if (filepath.includes(".env")) return true + + return false + })() + + if (block) { + throw new Error(`The user has blocked you from reading ${filepath}, DO NOT make further attempts to read it`) + } + const file = Bun.file(filepath) if (!(await file.exists())) { const dir = path.dirname(filepath) |
