diff --git a/packages/opencode/src/cli/cmd/debug/file.ts b/packages/opencode/src/cli/cmd/debug/file.ts index 312ad8b8eb..0e6ef98c24 100644 --- a/packages/opencode/src/cli/cmd/debug/file.ts +++ b/packages/opencode/src/cli/cmd/debug/file.ts @@ -40,8 +40,11 @@ const FileReadCommand = effectCmd({ handler: Effect.fn("Cli.debug.file.read")(function* (args) { const file = yield* filesystem(FileSystem.Service.use((svc) => svc.read({ path: RelativePath.make(args.path) }))) process.stdout.write( - JSON.stringify({ content: Buffer.from(file.content).toString("base64"), encoding: "base64", mime: file.mime }, null, 2) + - EOL, + JSON.stringify( + { content: Buffer.from(file.content).toString("base64"), encoding: "base64", mime: file.mime }, + null, + 2, + ) + EOL, ) }), }) diff --git a/packages/sdk/openapi.json b/packages/sdk/openapi.json index bf8b8e131a..4df27ec7ca 100644 --- a/packages/sdk/openapi.json +++ b/packages/sdk/openapi.json @@ -12463,7 +12463,7 @@ ] } }, - "/api/fs/read": { + "/api/fs/read/*": { "get": { "tags": ["filesystem"], "operationId": "v2.fs.read", @@ -12486,14 +12486,6 @@ "required": false, "style": "deepObject", "explode": true - }, - { - "name": "path", - "in": "query", - "schema": { - "type": "string" - }, - "required": true } ], "security": [], @@ -12501,19 +12493,10 @@ "200": { "description": "Success", "content": { - "application/json": { + "application/octet-stream": { "schema": { - "type": "object", - "properties": { - "location": { - "$ref": "#/components/schemas/LocationInfo" - }, - "data": { - "$ref": "#/components/schemas/FileSystemContent" - } - }, - "required": ["location", "data"], - "additionalProperties": false + "type": "string", + "format": "binary" } } } @@ -12539,7 +12522,7 @@ } } }, - "description": "Read one file relative to the requested location.", + "description": "Serve one file relative to the requested location.", "summary": "Read file", "x-codeSamples": [ { @@ -26560,29 +26543,6 @@ "required": ["id", "projectID", "action", "resource"], "additionalProperties": false }, - "FileSystemContent": { - "type": "object", - "properties": { - "uri": { - "type": "string" - }, - "name": { - "type": "string" - }, - "content": { - "type": "string" - }, - "encoding": { - "type": "string", - "enum": ["utf8", "base64"] - }, - "mime": { - "type": "string" - } - }, - "required": ["uri", "content", "encoding", "mime"], - "additionalProperties": false - }, "FileSystemEntry": { "type": "object", "properties": { diff --git a/packages/server/src/handlers/fs.ts b/packages/server/src/handlers/fs.ts index 5b3b58c1dc..963bf51d85 100644 --- a/packages/server/src/handlers/fs.ts +++ b/packages/server/src/handlers/fs.ts @@ -12,7 +12,9 @@ export const FileSystemHandler = HttpApiBuilder.group(Api, "server.fs", (handler .handleRaw("fs.read", (ctx) => Effect.gen(function* () { const file = yield* (yield* FileSystem.Service).read({ - path: RelativePath.make(decodeURIComponent(new URL(ctx.request.url, "http://localhost").pathname.slice(13))), + path: RelativePath.make( + decodeURIComponent(new URL(ctx.request.url, "http://localhost").pathname.slice(13)), + ), }) return HttpServerResponse.uint8Array(file.content, { contentType: file.mime }) }),