refactor(server): serve raw filesystem content (#31911)

This commit is contained in:
Dax 2026-06-11 11:20:11 -04:00 committed by GitHub
commit 31c5454ee6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 67 additions and 93 deletions

View file

@ -1,6 +1,5 @@
import fs from "fs/promises"
import path from "path"
import { fileURLToPath } from "url"
import { describe, expect } from "bun:test"
import { Effect, Exit, Layer } from "effect"
import { FileSystem } from "@opencode-ai/core/filesystem"
@ -40,9 +39,9 @@ describe("FileSystem", () => {
const service = yield* FileSystem.Service
const text = yield* service.read({ path: RelativePath.make("text.txt") })
const binary = yield* service.read({ path: RelativePath.make("data.bin") })
expect(text).toMatchObject({ name: "text.txt", content: "hello", encoding: "utf8", mime: "text/plain" })
expect(fileURLToPath(text.uri)).toBe(path.join(directory, "text.txt"))
expect(binary).toMatchObject({ name: "data.bin", content: "AAEC", encoding: "base64" })
expect(new TextDecoder().decode(text.content)).toBe("hello")
expect(text.mime).toBe("text/plain")
expect(binary.content).toEqual(new Uint8Array([0, 1, 2]))
}).pipe(provide(directory)),
),
)