GeezerVison is showing github.com — tweak: truncation dir perm · bpd1069/opencode@fd37d5b
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: packages/opencode/src/agent/agent.ts +8-4Lines changed: 8 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -50,6 +50,7 @@ export namespace Agent { | 50 | 50 | external_directory: { | 51 | 51 | "*": "ask", | 52 | 52 | [Truncate.DIR]: "allow", | | 53 | + [Truncate.GLOB]: "allow", | 53 | 54 | }, | 54 | 55 | question: "deny", | 55 | 56 | // mirrors github.com/github/gitignore Node.gitignore pattern for .env files | @@ -124,6 +125,7 @@ export namespace Agent { | 124 | 125 | read: "allow", | 125 | 126 | external_directory: { | 126 | 127 | [Truncate.DIR]: "allow", | | 128 | + [Truncate.GLOB]: "allow", | 127 | 129 | }, | 128 | 130 | }), | 129 | 131 | user, | @@ -213,14 +215,16 @@ export namespace Agent { | 213 | 215 | // Ensure Truncate.DIR is allowed unless explicitly configured | 214 | 216 | for (const name in result) { | 215 | 217 | const agent = result[name] | 216 | | - const explicit = agent.permission.some( | 217 | | - (r) => r.permission === "external_directory" && r.pattern === Truncate.DIR && r.action === "deny", | 218 | | - ) | | 218 | + const explicit = agent.permission.some((r) => { | | 219 | + if (r.permission !== "external_directory") return false | | 220 | + if (r.action !== "deny") return false | | 221 | + return r.pattern === Truncate.DIR || r.pattern === Truncate.GLOB | | 222 | + }) | 219 | 223 | if (explicit) continue | 220 | 224 |
| 221 | 225 | result[name].permission = PermissionNext.merge( | 222 | 226 | result[name].permission, | 223 | | - PermissionNext.fromConfig({ external_directory: { [Truncate.DIR]: "allow" } }), | | 227 | + PermissionNext.fromConfig({ external_directory: { [Truncate.DIR]: "allow", [Truncate.GLOB]: "allow" } }), | 224 | 228 | ) | 225 | 229 | } | 226 | 230 |
| |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/src/tool/truncation.ts +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -10,6 +10,7 @@ export namespace Truncate { | 10 | 10 | export const MAX_LINES = 2000 | 11 | 11 | export const MAX_BYTES = 50 * 1024 | 12 | 12 | export const DIR = path.join(Global.Path.data, "tool-output") | | 13 | + export const GLOB = path.join(DIR, "*") | 13 | 14 | const RETENTION_MS = 7 * 24 * 60 * 60 * 1000 // 7 days | 14 | 15 |
| 15 | 16 | export type Result = { content: string; truncated: false } | { content: string; truncated: true; outputPath: string } | |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/test/agent/agent.test.ts +3Lines changed: 3 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -461,6 +461,7 @@ test("Truncate.DIR is allowed even when user denies external_directory globally" | 461 | 461 | fn: async () => { | 462 | 462 | const build = await Agent.get("build") | 463 | 463 | expect(PermissionNext.evaluate("external_directory", Truncate.DIR, build!.permission).action).toBe("allow") | | 464 | + expect(PermissionNext.evaluate("external_directory", Truncate.GLOB, build!.permission).action).toBe("allow") | 464 | 465 | expect(PermissionNext.evaluate("external_directory", "/some/other/path", build!.permission).action).toBe("deny") | 465 | 466 | }, | 466 | 467 | }) | @@ -484,6 +485,7 @@ test("Truncate.DIR is allowed even when user denies external_directory per-agent | 484 | 485 | fn: async () => { | 485 | 486 | const build = await Agent.get("build") | 486 | 487 | expect(PermissionNext.evaluate("external_directory", Truncate.DIR, build!.permission).action).toBe("allow") | | 488 | + expect(PermissionNext.evaluate("external_directory", Truncate.GLOB, build!.permission).action).toBe("allow") | 487 | 489 | expect(PermissionNext.evaluate("external_directory", "/some/other/path", build!.permission).action).toBe("deny") | 488 | 490 | }, | 489 | 491 | }) | @@ -506,6 +508,7 @@ test("explicit Truncate.DIR deny is respected", async () => { | 506 | 508 | fn: async () => { | 507 | 509 | const build = await Agent.get("build") | 508 | 510 | expect(PermissionNext.evaluate("external_directory", Truncate.DIR, build!.permission).action).toBe("deny") | | 511 | + expect(PermissionNext.evaluate("external_directory", Truncate.GLOB, build!.permission).action).toBe("deny") | 509 | 512 | }, | 510 | 513 | }) | 511 | 514 | }) |
|