Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.

Commit 4c2e888

Browse files
committed
no mr llm, you may not read that
1 parent c78fd09 commit 4c2e888

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

packages/opencode/src/tool/read.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { Provider } from "../provider/provider"
1111
import { Identifier } from "../id/id"
1212
import { Permission } from "../permission"
1313
import { Agent } from "@/agent/agent"
14+
import { iife } from "@/util/iife"
1415

1516
const DEFAULT_READ_LIMIT = 2000
1617
const MAX_LINE_LENGTH = 2000
@@ -48,6 +49,19 @@ export const ReadTool = Tool.define("read", {
4849
}
4950
}
5051

52+
const block = (() => {
53+
const whitelist = [".env.example", ".env.sample"]
54+
55+
if (whitelist.some((w) => filepath.endsWith(w))) return false
56+
if (filepath.includes(".env")) return true
57+
58+
return false
59+
})()
60+
61+
if (block) {
62+
throw new Error(`The user has blocked you from reading ${filepath}, DO NOT make further attempts to read it`)
63+
}
64+
5165
const file = Bun.file(filepath)
5266
if (!(await file.exists())) {
5367
const dir = path.dirname(filepath)

0 commit comments

Comments
 (0)