GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — tweak: truncation dir perm · bpd1069/opencode@fd37d5b

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages/opencode
    • src
      • agent
        • agent.ts
      • tool
        • truncation.ts
    • test/agent
      • agent.test.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/opencode/src/agent/agent.ts‎

Copy file name to clipboardExpand all lines: packages/opencode/src/agent/agent.ts
+8-4Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export namespace Agent {
5050
external_directory: {
5151
"*": "ask",
5252
[Truncate.DIR]: "allow",
53+
[Truncate.GLOB]: "allow",
5354
},
5455
question: "deny",
5556
// mirrors github.com/github/gitignore Node.gitignore pattern for .env files
@@ -124,6 +125,7 @@ export namespace Agent {
124125
read: "allow",
125126
external_directory: {
126127
[Truncate.DIR]: "allow",
128+
[Truncate.GLOB]: "allow",
127129
},
128130
}),
129131
user,
@@ -213,14 +215,16 @@ export namespace Agent {
213215
// Ensure Truncate.DIR is allowed unless explicitly configured
214216
for (const name in result) {
215217
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+
})
219223
if (explicit) continue
220224

221225
result[name].permission = PermissionNext.merge(
222226
result[name].permission,
223-
PermissionNext.fromConfig({ external_directory: { [Truncate.DIR]: "allow" } }),
227+
PermissionNext.fromConfig({ external_directory: { [Truncate.DIR]: "allow", [Truncate.GLOB]: "allow" } }),
224228
)
225229
}
226230

Collapse file

‎packages/opencode/src/tool/truncation.ts‎

Copy file name to clipboardExpand all lines: packages/opencode/src/tool/truncation.ts
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export namespace Truncate {
1010
export const MAX_LINES = 2000
1111
export const MAX_BYTES = 50 * 1024
1212
export const DIR = path.join(Global.Path.data, "tool-output")
13+
export const GLOB = path.join(DIR, "*")
1314
const RETENTION_MS = 7 * 24 * 60 * 60 * 1000 // 7 days
1415

1516
export type Result = { content: string; truncated: false } | { content: string; truncated: true; outputPath: string }
Collapse file

‎packages/opencode/test/agent/agent.test.ts‎

Copy file name to clipboardExpand all lines: packages/opencode/test/agent/agent.test.ts
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,7 @@ test("Truncate.DIR is allowed even when user denies external_directory globally"
461461
fn: async () => {
462462
const build = await Agent.get("build")
463463
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")
464465
expect(PermissionNext.evaluate("external_directory", "/some/other/path", build!.permission).action).toBe("deny")
465466
},
466467
})
@@ -484,6 +485,7 @@ test("Truncate.DIR is allowed even when user denies external_directory per-agent
484485
fn: async () => {
485486
const build = await Agent.get("build")
486487
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")
487489
expect(PermissionNext.evaluate("external_directory", "/some/other/path", build!.permission).action).toBe("deny")
488490
},
489491
})
@@ -506,6 +508,7 @@ test("explicit Truncate.DIR deny is respected", async () => {
506508
fn: async () => {
507509
const build = await Agent.get("build")
508510
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")
509512
},
510513
})
511514
})

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.