Skip to content

Commit f2021a8

Browse files
committed
fix: allow attachments outside cwd, and support svg
1 parent 7d54f89 commit f2021a8

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

packages/opencode/src/session/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,7 @@ export namespace Session {
525525
abort: new AbortController().signal,
526526
agent: input.agent!,
527527
messageID: userMsg.id,
528+
extra: { bypassCwdCheck: true },
528529
metadata: async () => {},
529530
}),
530531
)

packages/opencode/src/tool/read.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const ReadTool = Tool.define("read", {
2424
filepath = path.join(process.cwd(), filepath)
2525
}
2626
const app = App.info()
27-
if (!Filesystem.contains(app.path.cwd, filepath)) {
27+
if (!ctx.extra?.["bypassCwdCheck"] && !Filesystem.contains(app.path.cwd, filepath)) {
2828
throw new Error(`File ${filepath} is not in the current working directory`)
2929
}
3030

@@ -98,8 +98,6 @@ function isImageFile(filePath: string): string | false {
9898
return "GIF"
9999
case ".bmp":
100100
return "BMP"
101-
case ".svg":
102-
return "SVG"
103101
case ".webp":
104102
return "WebP"
105103
default:

packages/opencode/src/tool/tool.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export namespace Tool {
1010
agent: string
1111
callID?: string
1212
abort: AbortSignal
13+
extra?: { [key: string]: any }
1314
metadata(input: { title?: string; metadata?: M }): void
1415
}
1516
export interface Info<Parameters extends StandardSchemaV1 = StandardSchemaV1, M extends Metadata = Metadata> {

0 commit comments

Comments
 (0)