feat(files): open markdown, HTML, and PDF files outside the workspace (#9140)

Co-authored-by: Claude Code <[email protected]>
This commit is contained in:
Julius MarmingeandClaude Code authored and GitHub committed 2026-09-01 19:31:55 -07:00
1 parent f2a914b858
commit f46a709ee4
26 files changed
+394 -89

No files matched your search

@@ -1,3 +1,6 @@
// @effect-diagnostics nodeBuiltinImport:off - FileSystem cannot create a FIFO.
import * as NodeChildProcess from "node:child_process";
import * as NodeServices from "@effect/platform-node/NodeServices";
import { it, describe, expect } from "@effect/vitest";
import * as Effect from "effect/Effect";
@@ -73,6 +76,53 @@ it.layer(TestLayer, { excludeTestServices: true })("WorkspaceFileSystemLive", (i
}),
);
it.effect("reads host files outside the workspace root by absolute path", () =>
Effect.gen(function* () {
const workspaceFileSystem = yield* WorkspaceFileSystem.WorkspaceFileSystem;
const path = yield* Path.Path;
const cwd = yield* makeTempDir;
const outsideDir = yield* makeTempDir;
yield* writeTextFile(outsideDir, "cleanup-report.md", "# Report\n");
const absolutePath = path.join(outsideDir, "cleanup-report.md");
const result = yield* workspaceFileSystem.readFile({
cwd,
relativePath: absolutePath,
});
expect(result).toEqual({
relativePath: absolutePath,
contents: "# Report\n",
byteLength: 9,
truncated: false,
});
}),
);
it.effect("rejects a FIFO without blocking on open", () =>
Effect.gen(function* () {
const workspaceFileSystem = yield* WorkspaceFileSystem.WorkspaceFileSystem;
const path = yield* Path.Path;
const cwd = yield* makeTempDir;
const outsideDir = yield* makeTempDir;
const fifoPath = path.join(outsideDir, "pipe");
yield* Effect.promise(
() =>
new Promise<void>((resolve, reject) =>
NodeChildProcess.execFile("mkfifo", [fifoPath], (error) =>
error ? reject(error) : resolve(),
),
),
);
const error = yield* workspaceFileSystem
.readFile({ cwd, relativePath: fifoPath })
.pipe(Effect.flip);
expect(error).toBeInstanceOf(WorkspaceFileSystem.WorkspacePathNotFileError);
}),
);
it.effect("rejects reads outside the workspace root", () =>
Effect.gen(function* () {
const workspaceFileSystem = yield* WorkspaceFileSystem.WorkspaceFileSystem;
@@ -212,6 +262,22 @@ it.layer(TestLayer, { excludeTestServices: true })("WorkspaceFileSystemLive", (i
}),
);
it.effect("rejects writes by absolute path", () =>
Effect.gen(function* () {
const workspaceFileSystem = yield* WorkspaceFileSystem.WorkspaceFileSystem;
const path = yield* Path.Path;
const cwd = yield* makeTempDir;
const outsideDir = yield* makeTempDir;
const absolutePath = path.join(outsideDir, "cleanup-report.md");
const error = yield* workspaceFileSystem
.writeFile({ cwd, relativePath: absolutePath, contents: "# Edited\n" })
.pipe(Effect.flip);
expect(error).toBeInstanceOf(WorkspacePaths.WorkspacePathOutsideRootError);
}),
);
it.effect("invalidates workspace entry search cache after writes", () =>
Effect.gen(function* () {
const workspaceEntries = yield* WorkspaceEntries.WorkspaceEntries;