Skip to content

Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.

Use `fff` for workspace search queries (#3099)

Julius Marminged12da198ad5a
diff --git a/apps/server/integration/OrchestrationEngineHarness.integration.ts b/apps/server/integration/OrchestrationEngineHarness.integration.ts
index 19a4b5641..bc1229811 100644
--- a/apps/server/integration/OrchestrationEngineHarness.integration.ts
+++ b/apps/server/integration/OrchestrationEngineHarness.integration.ts
@@ -72,7 +72,7 @@ import {
type TestProviderAdapterHarness,
} from "./TestProviderAdapter.integration.ts";
import { deriveServerPaths, ServerConfig } from "../src/config.ts";
-import { WorkspaceEntriesLive } from "../src/workspace/Layers/WorkspaceEntries.ts";
+import * as WorkspaceEntries from "../src/workspace/WorkspaceEntries.ts";
import { WorkspacePathsLive } from "../src/workspace/Layers/WorkspacePaths.ts";
import * as VcsDriverRegistry from "../src/vcs/VcsDriverRegistry.ts";
import { VcsStatusBroadcaster } from "../src/vcs/VcsStatusBroadcaster.ts";
@@ -348,7 +348,7 @@ export const makeOrchestrationIntegrationHarness = (
}),
),
Layer.provideMerge(
- WorkspaceEntriesLive.pipe(
+ WorkspaceEntries.layer.pipe(
Layer.provide(WorkspacePathsLive),
Layer.provideMerge(VcsDriverRegistry.layer),
Layer.provide(NodeServices.layer),
diff --git a/apps/server/package.json b/apps/server/package.json
index 8ef9784ba..de012aada 100644
--- a/apps/server/package.json
+++ b/apps/server/package.json
@@ -27,6 +27,7 @@
"@effect/platform-node": "catalog:",
"@effect/platform-node-shared": "catalog:",
"@effect/sql-sqlite-bun": "catalog:",
+ "@ff-labs/fff-node": "^0.9.4",
"@opencode-ai/sdk": "^1.3.15",
"@pierre/diffs": "catalog:",
"effect": "catalog:",
diff --git a/apps/server/src/orchestration/Layers/CheckpointReactor.test.ts b/apps/server/src/orchestration/Layers/CheckpointReactor.test.ts
index 3c9ec2cdf..5e36f9f4b 100644
--- a/apps/server/src/orchestration/Layers/CheckpointReactor.test.ts
+++ b/apps/server/src/orchestration/Layers/CheckpointReactor.test.ts
@@ -56,7 +56,7 @@ import {
} from "../../provider/Services/ProviderService.ts";
import { checkpointRefForThreadTurn } from "../../checkpointing/Utils.ts";
import { ServerConfig } from "../../config.ts";
-import { WorkspaceEntriesLive } from "../../workspace/Layers/WorkspaceEntries.ts";
+import * as WorkspaceEntries from "../../workspace/WorkspaceEntries.ts";
import { WorkspacePathsLive } from "../../workspace/Layers/WorkspacePaths.ts";
const asProjectId = (value: string): ProjectId => ProjectId.make(value);
@@ -330,7 +330,7 @@ describe("CheckpointReactor", () => {
Layer.provideMerge(vcsStatusBroadcasterLayer),
Layer.provideMerge(CheckpointStoreLive.pipe(Layer.provide(VcsDriverRegistry.layer))),
Layer.provideMerge(
- WorkspaceEntriesLive.pipe(
+ WorkspaceEntries.layer.pipe(
Layer.provide(WorkspacePathsLive),
Layer.provideMerge(VcsDriverRegistry.layer),
),
diff --git a/apps/server/src/orchestration/Layers/CheckpointReactor.ts b/apps/server/src/orchestration/Layers/CheckpointReactor.ts
index 40291ec4f..48ff133f5 100644
--- a/apps/server/src/orchestration/Layers/CheckpointReactor.ts
+++ b/apps/server/src/orchestration/Layers/CheckpointReactor.ts
@@ -34,7 +34,7 @@ import type { CheckpointStoreError } from "../../checkpointing/Errors.ts";
import type { OrchestrationDispatchError } from "../Errors.ts";
import { isGitRepository } from "../../git/Utils.ts";
import { VcsStatusBroadcaster } from "../../vcs/VcsStatusBroadcaster.ts";
-import { WorkspaceEntries } from "../../workspace/Services/WorkspaceEntries.ts";
+import * as WorkspaceEntries from "../../workspace/WorkspaceEntries.ts";
const nowIso = Effect.map(DateTime.now, DateTime.formatIso);
@@ -83,7 +83,7 @@ const make = Effect.gen(function* () {
const providerService = yield* ProviderService;
const checkpointStore = yield* CheckpointStore;
const receiptBus = yield* RuntimeReceiptBus;
- const workspaceEntries = yield* WorkspaceEntries;
+ const workspaceEntries = yield* WorkspaceEntries.WorkspaceEntries;
const vcsStatusBroadcaster = yield* VcsStatusBroadcaster;
const appendRevertFailureActivity = (input: {
@@ -252,9 +252,9 @@ const make = Effect.gen(function* () {
checkpointRef: targetCheckpointRef,
});
- // Invalidate the workspace entry cache so the @-mention file picker
+ // Refresh the workspace entry index so the @-mention file picker
// reflects files created or deleted during this turn.
- yield* workspaceEntries.invalidate(input.cwd);
+ yield* workspaceEntries.refresh(input.cwd);
const files = yield* checkpointStore
.diffCheckpoints({
@@ -690,9 +690,9 @@ const make = Effect.gen(function* () {
return;
}
- // Invalidate the workspace entry cache so the @-mention file picker
+ // Refresh the workspace entry index so the @-mention file picker
// reflects the reverted filesystem state.
- yield* workspaceEntries.invalidate(sessionRuntime.value.cwd);
+ yield* workspaceEntries.refresh(sessionRuntime.value.cwd);
const rolledBackTurns = Math.max(0, currentTurnCount - event.payload.turnCount);
if (rolledBackTurns > 0) {
diff --git a/apps/server/src/server.test.ts b/apps/server/src/server.test.ts
index e23ab797f..77a4dbde2 100644
--- a/apps/server/src/server.test.ts
+++ b/apps/server/src/server.test.ts
@@ -51,6 +51,7 @@ import * as Option from "effect/Option";
import * as Path from "effect/Path";
import * as PubSub from "effect/PubSub";
import * as Stream from "effect/Stream";
+import * as TestClock from "effect/testing/TestClock";
import { ChildProcessSpawner } from "effect/unstable/process";
import {
FetchHttpClient,
@@ -118,7 +119,7 @@ import {
ServerEnvironment,
type ServerEnvironmentShape,
} from "./environment/Services/ServerEnvironment.ts";
-import { WorkspaceEntriesLive } from "./workspace/Layers/WorkspaceEntries.ts";
+import * as WorkspaceEntries from "./workspace/WorkspaceEntries.ts";
import { WorkspaceFileSystemLive } from "./workspace/Layers/WorkspaceFileSystem.ts";
import { WorkspacePathsLive } from "./workspace/Layers/WorkspacePaths.ts";
import * as GitVcsDriver from "./vcs/GitVcsDriver.ts";
@@ -504,7 +505,7 @@ const buildAppUnderTest = (options?: {
const gitManagerLayer = Layer.mock(GitManager)({
...options?.layers?.gitManager,
});
- const workspaceEntriesLayer = WorkspaceEntriesLive.pipe(
+ const workspaceEntriesLayer = WorkspaceEntries.layer.pipe(
Layer.provide(WorkspacePathsLive),
Layer.provideMerge(vcsDriverRegistryLayer),
);
@@ -4354,7 +4355,7 @@ it.layer(NodeServices.layer)("server router seam", (it) => {
assert.isAtLeast(response.entries.length, 1);
assert.isTrue(response.entries.some((entry) => entry.path === "needle-file.ts"));
assert.equal(response.truncated, false);
- }).pipe(Effect.provide(NodeHttpServer.layerTest)),
+ }).pipe(Effect.provide(NodeHttpServer.layerTest), TestClock.withLive),
);
it.effect("routes websocket rpc projects.listEntries and projects.readFile", () =>
@@ -4390,7 +4391,7 @@ it.layer(NodeServices.layer)("server router seam", (it) => {
byteLength: 26,
truncated: false,
});
- }).pipe(Effect.provide(NodeHttpServer.layerTest)),
+ }).pipe(Effect.provide(NodeHttpServer.layerTest), TestClock.withLive),
);
it.effect("routes websocket rpc projects.searchEntries excludes gitignored files", () =>
@@ -4447,7 +4448,7 @@ it.layer(NodeServices.layer)("server router seam", (it) => {
assert.equal(response.entries.length, 0);
assert.equal(response.truncated, false);
- }).pipe(Effect.provide(NodeHttpServer.layerTest)),
+ }).pipe(Effect.provide(NodeHttpServer.layerTest), TestClock.withLive),
);
it.effect("routes websocket rpc projects.searchEntries errors", () =>
diff --git a/apps/server/src/server.ts b/apps/server/src/server.ts
index cd4e11487..f5f51efc9 100644
--- a/apps/server/src/server.ts
+++ b/apps/server/src/server.ts
@@ -54,7 +54,7 @@ import { ProviderRegistryLive } from "./provider/Layers/ProviderRegistry.ts";
import { ServerSettingsLive } from "./serverSettings.ts";
import { ProjectFaviconResolverLive } from "./project/Layers/ProjectFaviconResolver.ts";
import { RepositoryIdentityResolverLive } from "./project/Layers/RepositoryIdentityResolver.ts";
-import { WorkspaceEntriesLive } from "./workspace/Layers/WorkspaceEntries.ts";
+import * as WorkspaceEntries from "./workspace/WorkspaceEntries.ts";
import { WorkspaceFileSystemLive } from "./workspace/Layers/WorkspaceFileSystem.ts";
import { WorkspacePathsLive } from "./workspace/Layers/WorkspacePaths.ts";
import * as GitVcsDriver from "./vcs/GitVcsDriver.ts";
@@ -247,10 +247,7 @@ const PreviewLayerLive = Layer.empty.pipe(
Layer.provideMerge(PortScannerLayerLive),
);
-const WorkspaceEntriesLayerLive = WorkspaceEntriesLive.pipe(
- Layer.provide(WorkspacePathsLive),
- Layer.provideMerge(VcsDriverRegistryLayerLive),
-);
+const WorkspaceEntriesLayerLive = WorkspaceEntries.layer.pipe(Layer.provide(WorkspacePathsLive));
const WorkspaceFileSystemLayerLive = WorkspaceFileSystemLive.pipe(
Layer.provide(WorkspacePathsLive),
diff --git a/apps/server/src/workspace/Layers/WorkspaceEntries.ts b/apps/server/src/workspace/Layers/WorkspaceEntries.ts
deleted file mode 100644
index 2128a78bc..000000000
--- a/apps/server/src/workspace/Layers/WorkspaceEntries.ts
+++ /dev/null
@@ -1,555 +0,0 @@
-// @effect-diagnostics nodeBuiltinImport:off
-import * as NodeOS from "node:os";
-import fsPromises from "node:fs/promises";
-import type { Dirent } from "node:fs";
-
-import * as Cache from "effect/Cache";
-import * as DateTime from "effect/DateTime";
-import * as Duration from "effect/Duration";
-import * as Effect from "effect/Effect";
-import * as Exit from "effect/Exit";
-import * as Layer from "effect/Layer";
-import * as Path from "effect/Path";
-
-import { type FilesystemBrowseInput, type ProjectEntry } from "@t3tools/contracts";
-import { HostProcessPlatform } from "@t3tools/shared/hostProcess";
-import { isExplicitRelativePath, isWindowsAbsolutePath } from "@t3tools/shared/path";
-import {
- insertRankedSearchResult,
- normalizeSearchQuery,
- scoreQueryMatch,
- type RankedSearchResult,
-} from "@t3tools/shared/searchRanking";
-
-import { VcsDriverRegistry } from "../../vcs/VcsDriverRegistry.ts";
-import {
- WorkspaceEntries,
- WorkspaceEntriesBrowseError,
- WorkspaceEntriesError,
- type WorkspaceEntriesShape,
-} from "../Services/WorkspaceEntries.ts";
-import { WorkspacePaths } from "../Services/WorkspacePaths.ts";
-
-const WORKSPACE_CACHE_TTL_MS = 15_000;
-const WORKSPACE_CACHE_MAX_KEYS = 4;
-const WORKSPACE_INDEX_MAX_ENTRIES = 25_000;
-const WORKSPACE_SCAN_READDIR_CONCURRENCY = 32;
-const IGNORED_DIRECTORY_NAMES = new Set([
- ".git",
- ".convex",
- "node_modules",
- ".next",
- ".turbo",
- ".vite-plus",
- "dist",
- "build",
- "out",
- ".cache",
-]);
-
-interface WorkspaceIndex {
- scannedAt: number;
- entries: SearchableWorkspaceEntry[];
- truncated: boolean;
-}
-
-interface SearchableWorkspaceEntry extends ProjectEntry {
- normalizedPath: string;
- normalizedName: string;
-}
-
-type RankedWorkspaceEntry = RankedSearchResult<SearchableWorkspaceEntry>;
-
-function toPosixPath(input: string): string {
- return input.replaceAll("\\", "/");
-}
-
-function expandHomePath(input: string, path: Path.Path): string {
- if (input === "~") {
- return NodeOS.homedir();
- }
- if (input.startsWith("~/") || input.startsWith("~\\")) {
- return path.join(NodeOS.homedir(), input.slice(2));
- }
- return input;
-}
-
-function parentPathOf(input: string): string | undefined {
- const separatorIndex = input.lastIndexOf("/");
- if (separatorIndex === -1) {
- return undefined;
- }
- return input.slice(0, separatorIndex);
-}
-
-function basenameOf(input: string): string {
- const separatorIndex = input.lastIndexOf("/");
- if (separatorIndex === -1) {
- return input;
- }
- return input.slice(separatorIndex + 1);
-}
-
-function toSearchableWorkspaceEntry(entry: ProjectEntry): SearchableWorkspaceEntry {
- const normalizedPath = entry.path.toLowerCase();
- return {
- ...entry,
- normalizedPath,
- normalizedName: basenameOf(normalizedPath),
- };
-}
-
-function scoreEntry(entry: SearchableWorkspaceEntry, query: string): number | null {
- if (!query) {
- return entry.kind === "directory" ? 0 : 1;
- }
-
- const { normalizedPath, normalizedName } = entry;
-
- const scores = [
- scoreQueryMatch({
- value: normalizedName,
- query,
- exactBase: 0,
- prefixBase: 2,
- includesBase: 5,
- fuzzyBase: 100,
- }),
- scoreQueryMatch({
- value: normalizedPath,
- query,
- exactBase: 1,
- prefixBase: 3,
- boundaryBase: 4,
- includesBase: 6,
- fuzzyBase: 200,
- boundaryMarkers: ["/"],
- }),
- ].filter((score): score is number => score !== null);
-
- if (scores.length === 0) {
- return null;
- }
-
- return Math.min(...scores);
-}
-
-function isPathInIgnoredDirectory(relativePath: string): boolean {
- const firstSegment = relativePath.split("/")[0];
- if (!firstSegment) return false;
- return IGNORED_DIRECTORY_NAMES.has(firstSegment);
-}
-
-function directoryAncestorsOf(relativePath: string): string[] {
- const segments = relativePath.split("/").filter((segment) => segment.length > 0);
- if (segments.length <= 1) return [];
-
- const directories: string[] = [];
- for (let index = 1; index < segments.length; index += 1) {
- directories.push(segments.slice(0, index).join("/"));
- }
- return directories;
-}
-
-const resolveBrowseTarget = (
- input: FilesystemBrowseInput,
- pathService: Path.Path,
-): Effect.Effect<string, WorkspaceEntriesBrowseError> =>
- Effect.gen(function* () {
- const platform = yield* HostProcessPlatform;
- if (platform !== "win32" && isWindowsAbsolutePath(input.partialPath)) {
- return yield* new WorkspaceEntriesBrowseError({
- cwd: input.cwd,
- partialPath: input.partialPath,
- operation: "workspaceEntries.resolveBrowseTarget",
- detail: "Windows-style paths are only supported on Windows.",
- });
- }
-
- if (!isExplicitRelativePath(input.partialPath)) {
- return pathService.resolve(expandHomePath(input.partialPath, pathService));
- }
-
- if (!input.cwd) {
- return yield* new WorkspaceEntriesBrowseError({
- cwd: input.cwd,
- partialPath: input.partialPath,
- operation: "workspaceEntries.resolveBrowseTarget",
- detail: "Relative filesystem browse paths require a current project.",
- });
- }
-
- return pathService.resolve(expandHomePath(input.cwd, pathService), input.partialPath);
- });
-
-export const makeWorkspaceEntries = Effect.gen(function* () {
- const path = yield* Path.Path;
- const vcsRegistry = yield* VcsDriverRegistry;
- const workspacePaths = yield* WorkspacePaths;
-
- const isInsideVcsWorkTree = (cwd: string): Effect.Effect<boolean> =>
- vcsRegistry.detect({ cwd }).pipe(
- Effect.map((handle) => handle !== null),
- Effect.orElseSucceed(() => false),
- );
-
- const filterVcsIgnoredPaths = (
- cwd: string,
- relativePaths: string[],
- ): Effect.Effect<string[], never> =>
- vcsRegistry.detect({ cwd }).pipe(
- Effect.flatMap((handle) =>
- handle
- ? handle.driver.filterIgnoredPaths(cwd, relativePaths).pipe(
- Effect.map((paths) => [...paths]),
- Effect.orElseSucceed(() => relativePaths),
- )
- : Effect.succeed(relativePaths),
- ),
- Effect.orElseSucceed(() => relativePaths),
- );
-
- const buildWorkspaceIndexFromVcs = Effect.fn("WorkspaceEntries.buildWorkspaceIndexFromVcs")(
- function* (cwd: string) {
- const vcs = yield* vcsRegistry.detect({ cwd }).pipe(Effect.orElseSucceed(() => null));
- if (!vcs) {
- return null;
- }
-
- const listedFiles = yield* vcs.driver
- .listWorkspaceFiles(cwd)
- .pipe(Effect.orElseSucceed(() => null));
-
- if (!listedFiles) {
- return null;
- }
-
- const listedPaths: Array<string> = [];
- for (const rawEntry of listedFiles.paths) {
- const entry = toPosixPath(rawEntry);
- if (entry.length > 0 && !isPathInIgnoredDirectory(entry)) {
- listedPaths.push(entry);
- }
- }
- const filePaths = yield* vcs.driver.filterIgnoredPaths(cwd, listedPaths).pipe(
- Effect.map((paths) => [...paths]),
- Effect.catch(() => filterVcsIgnoredPaths(cwd, listedPaths)),
- );
-
- const directorySet = new Set<string>();
- for (const filePath of filePaths) {
- for (const directoryPath of directoryAncestorsOf(filePath)) {
- if (!isPathInIgnoredDirectory(directoryPath)) {
- directorySet.add(directoryPath);
- }
- }
- }
-
- const directoryEntries = [...directorySet]
- .toSorted((left, right) => left.localeCompare(right))
- .map(
- (directoryPath): ProjectEntry => ({
- path: directoryPath,
- kind: "directory",
- parentPath: parentPathOf(directoryPath),
- }),
- )
- .map(toSearchableWorkspaceEntry);
- const fileEntries = [...new Set(filePaths)]
- .toSorted((left, right) => left.localeCompare(right))
- .map(
- (filePath): ProjectEntry => ({
- path: filePath,
- kind: "file",
- parentPath: parentPathOf(filePath),
- }),
- )
- .map(toSearchableWorkspaceEntry);
-
- const now = yield* DateTime.now;
- const entries = [...directoryEntries, ...fileEntries];
- return {
- scannedAt: now.epochMilliseconds,
- entries: entries.slice(0, WORKSPACE_INDEX_MAX_ENTRIES),
- truncated: listedFiles.truncated || entries.length > WORKSPACE_INDEX_MAX_ENTRIES,
- };
- },
- );
-
- const readDirectoryEntries = Effect.fn("WorkspaceEntries.readDirectoryEntries")(function* (
- cwd: string,
- relativeDir: string,
- ): Effect.fn.Return<
- { readonly relativeDir: string; readonly dirents: Dirent[] | null },
- WorkspaceEntriesError
- > {
- return yield* Effect.tryPromise({
- try: async () => {
- const absoluteDir = relativeDir ? path.join(cwd, relativeDir) : cwd;
- const dirents = await fsPromises.readdir(absoluteDir, { withFileTypes: true });
- return { relativeDir, dirents };
- },
- catch: (cause) =>
- new WorkspaceEntriesError({
- cwd,
- operation: "workspaceEntries.readDirectoryEntries",
- detail: cause instanceof Error ? cause.message : String(cause),
- cause,
- }),
- }).pipe(
- Effect.catchIf(
- () => relativeDir.length > 0,
- () => Effect.succeed({ relativeDir, dirents: null }),
- ),
- );
- });
-
- const buildWorkspaceIndexFromFilesystem = Effect.fn(
- "WorkspaceEntries.buildWorkspaceIndexFromFilesystem",
- )(function* (cwd: string): Effect.fn.Return<WorkspaceIndex, WorkspaceEntriesError> {
- const shouldFilterWithGitIgnore = yield* isInsideVcsWorkTree(cwd);
-
- let pendingDirectories: string[] = [""];
- const entries: SearchableWorkspaceEntry[] = [];
- let truncated = false;
-
- while (pendingDirectories.length > 0 && !truncated) {
- const currentDirectories = pendingDirectories;
- pendingDirectories = [];
-
- const directoryEntries = yield* Effect.forEach(
- currentDirectories,
- (relativeDir) => readDirectoryEntries(cwd, relativeDir),
- { concurrency: WORKSPACE_SCAN_READDIR_CONCURRENCY },
- );
-
- const candidateEntriesByDirectory = directoryEntries.map((directoryEntry) => {
- const { relativeDir, dirents } = directoryEntry;
- if (!dirents) return [] as Array<{ dirent: Dirent; relativePath: string }>;
-
- dirents.sort((left, right) => left.name.localeCompare(right.name));
- const candidates: Array<{ dirent: Dirent; relativePath: string }> = [];
- for (const dirent of dirents) {
- if (!dirent.name || dirent.name === "." || dirent.name === "..") {
- continue;
- }
- if (dirent.isDirectory() && IGNORED_DIRECTORY_NAMES.has(dirent.name)) {
- continue;
- }
- if (!dirent.isDirectory() && !dirent.isFile()) {
- continue;
- }
-
- const relativePath = toPosixPath(
- relativeDir ? path.join(relativeDir, dirent.name) : dirent.name,
- );
- if (isPathInIgnoredDirectory(relativePath)) {
- continue;
- }
- candidates.push({ dirent, relativePath });
- }
- return candidates;
- });
-
- const candidatePaths = candidateEntriesByDirectory.flatMap((candidateEntries) =>
- candidateEntries.map((entry) => entry.relativePath),
- );
- const allowedPathSet = shouldFilterWithGitIgnore
- ? new Set(yield* filterVcsIgnoredPaths(cwd, candidatePaths))
- : null;
-
- for (const candidateEntries of candidateEntriesByDirectory) {
- for (const candidate of candidateEntries) {
- if (allowedPathSet && !allowedPathSet.has(candidate.relativePath)) {
- continue;
- }
-
- const entry = toSearchableWorkspaceEntry({
- path: candidate.relativePath,
- kind: candidate.dirent.isDirectory() ? "directory" : "file",
- parentPath: parentPathOf(candidate.relativePath),
- });
- entries.push(entry);
-
- if (candidate.dirent.isDirectory()) {
- pendingDirectories.push(candidate.relativePath);
- }
-
- if (entries.length >= WORKSPACE_INDEX_MAX_ENTRIES) {
- truncated = true;
- break;
- }
- }
-
- if (truncated) {
- break;
- }
- }
- }
-
- const now = yield* DateTime.now;
- return {
- scannedAt: now.epochMilliseconds,
- entries,
- truncated,
- };
- });
-
- const buildWorkspaceIndex = Effect.fn("WorkspaceEntries.buildWorkspaceIndex")(function* (
- cwd: string,
- ): Effect.fn.Return<WorkspaceIndex, WorkspaceEntriesError> {
- const vcsIndexed = yield* buildWorkspaceIndexFromVcs(cwd);
- if (vcsIndexed) {
- return vcsIndexed;
- }
- return yield* buildWorkspaceIndexFromFilesystem(cwd);
- });
-
- const workspaceIndexCache = yield* Cache.makeWith<string, WorkspaceIndex, WorkspaceEntriesError>(
- buildWorkspaceIndex,
- {
- capacity: WORKSPACE_CACHE_MAX_KEYS,
- timeToLive: (exit) =>
- Exit.isSuccess(exit) ? Duration.millis(WORKSPACE_CACHE_TTL_MS) : Duration.zero,
- },
- );
-
- const normalizeWorkspaceRoot = Effect.fn("WorkspaceEntries.normalizeWorkspaceRoot")(function* (
- cwd: string,
- ): Effect.fn.Return<string, WorkspaceEntriesError> {
- return yield* workspacePaths.normalizeWorkspaceRoot(cwd).pipe(
- Effect.mapError(
- (cause) =>
- new WorkspaceEntriesError({
- cwd,
- operation: "workspaceEntries.normalizeWorkspaceRoot",
- detail: cause.message,
- cause,
- }),
- ),
- );
- });
-
- const invalidate: WorkspaceEntriesShape["invalidate"] = Effect.fn("WorkspaceEntries.invalidate")(
- function* (cwd) {
- const normalizedCwd = yield* normalizeWorkspaceRoot(cwd).pipe(
- Effect.orElseSucceed(() => cwd),
- );
- yield* Cache.invalidate(workspaceIndexCache, cwd);
- if (normalizedCwd !== cwd) {
- yield* Cache.invalidate(workspaceIndexCache, normalizedCwd);
- }
- },
- );
-
- const browse: WorkspaceEntriesShape["browse"] = Effect.fn("WorkspaceEntries.browse")(
- function* (input) {
- const resolvedInputPath = yield* resolveBrowseTarget(input, path);
- const endsWithSeparator = /[\\/]$/.test(input.partialPath) || input.partialPath === "~";
- const parentPath = endsWithSeparator ? resolvedInputPath : path.dirname(resolvedInputPath);
- const prefix = endsWithSeparator ? "" : path.basename(resolvedInputPath);
-
- const dirents = yield* Effect.tryPromise({
- try: () => fsPromises.readdir(parentPath, { withFileTypes: true }),
- catch: (cause) =>
- new WorkspaceEntriesBrowseError({
- cwd: input.cwd,
- partialPath: input.partialPath,
- operation: "workspaceEntries.browse.readDirectory",
- detail: `Unable to browse '${parentPath}': ${cause instanceof Error ? cause.message : String(cause)}`,
- cause,
- }),
- }).pipe(
- // The user can deny macOS TCC prompts for the target dir (Documents,
- // Downloads, Music, etc.); surface an empty listing instead of an
- // error so the caller doesn't retry-loop the prompt.
- Effect.catchIf(
- (error) => {
- const code = (error.cause as NodeJS.ErrnoException | undefined)?.code;
- return code === "EACCES" || code === "EPERM";
- },
- () => Effect.succeed<Dirent[]>([]),
- ),
- );
-
- const showHidden = endsWithSeparator || prefix.startsWith(".");
- const lowerPrefix = prefix.toLowerCase();
- const entries: Array<{ readonly name: string; readonly fullPath: string }> = [];
- for (const dirent of dirents) {
- if (
- dirent.isDirectory() &&
- dirent.name.toLowerCase().startsWith(lowerPrefix) &&
- (showHidden || !dirent.name.startsWith("."))
- ) {
- entries.push({
- name: dirent.name,
- fullPath: path.join(parentPath, dirent.name),
- });
- }
- }
-
- return {
- parentPath,
- entries: entries.toSorted((left, right) => left.name.localeCompare(right.name)),
- };
- },
- );
-
- const search: WorkspaceEntriesShape["search"] = Effect.fn("WorkspaceEntries.search")(
- function* (input) {
- const normalizedCwd = yield* normalizeWorkspaceRoot(input.cwd);
- return yield* Cache.get(workspaceIndexCache, normalizedCwd).pipe(
- Effect.map((index) => {
- const normalizedQuery = normalizeSearchQuery(input.query, {
- trimLeadingPattern: /^[@./]+/,
- });
- const limit = Math.max(0, Math.floor(input.limit));
- const rankedEntries: RankedWorkspaceEntry[] = [];
- let matchedEntryCount = 0;
-
- for (const entry of index.entries) {
- const score = scoreEntry(entry, normalizedQuery);
- if (score === null) {
- continue;
- }
-
- matchedEntryCount += 1;
- insertRankedSearchResult(
- rankedEntries,
- { item: entry, score, tieBreaker: entry.path },
- limit,
- );
- }
-
- return {
- entries: rankedEntries.map((candidate) => candidate.item),
- truncated: index.truncated || matchedEntryCount > limit,
- };
- }),
- );
- },
- );
-
- const list: WorkspaceEntriesShape["list"] = Effect.fn("WorkspaceEntries.list")(function* (input) {
- const normalizedCwd = yield* normalizeWorkspaceRoot(input.cwd);
- return yield* Cache.get(workspaceIndexCache, normalizedCwd).pipe(
- Effect.map((index) => ({
- entries: index.entries.map(({ path: entryPath, kind, parentPath }) => ({
- path: entryPath,
- kind,
- ...(parentPath ? { parentPath } : {}),
- })),
- truncated: index.truncated,
- })),
- );
- });
-
- return {
- browse,
- invalidate,
- list,
- search,
- } satisfies WorkspaceEntriesShape;
-});
-
-export const WorkspaceEntriesLive = Layer.effect(WorkspaceEntries, makeWorkspaceEntries);
diff --git a/apps/server/src/workspace/Layers/WorkspaceFileSystem.test.ts b/apps/server/src/workspace/Layers/WorkspaceFileSystem.test.ts
index 149873b3e..5a4ec5468 100644
--- a/apps/server/src/workspace/Layers/WorkspaceFileSystem.test.ts
+++ b/apps/server/src/workspace/Layers/WorkspaceFileSystem.test.ts
@@ -8,20 +8,19 @@ import * as Path from "effect/Path";
import { ServerConfig } from "../../config.ts";
import * as VcsDriverRegistry from "../../vcs/VcsDriverRegistry.ts";
import * as VcsProcess from "../../vcs/VcsProcess.ts";
-import { WorkspaceEntries } from "../Services/WorkspaceEntries.ts";
+import * as WorkspaceEntries from "../WorkspaceEntries.ts";
import { WorkspaceFileSystem } from "../Services/WorkspaceFileSystem.ts";
-import { WorkspaceEntriesLive } from "./WorkspaceEntries.ts";
import { WorkspaceFileSystemLive } from "./WorkspaceFileSystem.ts";
import { WorkspacePathsLive } from "./WorkspacePaths.ts";
const ProjectLayer = WorkspaceFileSystemLive.pipe(
Layer.provide(WorkspacePathsLive),
- Layer.provide(WorkspaceEntriesLive.pipe(Layer.provide(WorkspacePathsLive))),
+ Layer.provide(WorkspaceEntries.layer.pipe(Layer.provide(WorkspacePathsLive))),
);
const TestLayer = Layer.empty.pipe(
Layer.provideMerge(ProjectLayer),
- Layer.provideMerge(WorkspaceEntriesLive.pipe(Layer.provide(WorkspacePathsLive))),
+ Layer.provideMerge(WorkspaceEntries.layer.pipe(Layer.provide(WorkspacePathsLive))),
Layer.provideMerge(WorkspacePathsLive),
Layer.provideMerge(VcsDriverRegistry.layer.pipe(Layer.provide(VcsProcess.layer))),
Layer.provide(
@@ -53,7 +52,7 @@ const writeTextFile = Effect.fn("writeTextFile")(function* (
yield* fileSystem.writeFileString(absolutePath, contents).pipe(Effect.orDie);
});
-it.layer(TestLayer)("WorkspaceFileSystemLive", (it) => {
+it.layer(TestLayer, { excludeTestServices: true })("WorkspaceFileSystemLive", (it) => {
describe("readFile", () => {
it.effect("reads UTF-8 files relative to the workspace root", () =>
Effect.gen(function* () {
@@ -135,20 +134,15 @@ it.layer(TestLayer)("WorkspaceFileSystemLive", (it) => {
it.effect("invalidates workspace entry search cache after writes", () =>
Effect.gen(function* () {
- const workspaceEntries = yield* WorkspaceEntries;
+ const workspaceEntries = yield* WorkspaceEntries.WorkspaceEntries;
const workspaceFileSystem = yield* WorkspaceFileSystem;
const cwd = yield* makeTempDir;
yield* writeTextFile(cwd, "src/existing.ts", "export {};\n");
- const beforeWrite = yield* workspaceEntries.search({
- cwd,
- query: "rpc",
- limit: 10,
- });
- expect(beforeWrite).toEqual({
- entries: [],
- truncated: false,
- });
+ const beforeWrite = yield* workspaceEntries.list({ cwd });
+ expect(beforeWrite.entries.some((entry) => entry.path === "plans/effect-rpc.md")).toBe(
+ false,
+ );
yield* workspaceFileSystem.writeFile({
cwd,
@@ -156,11 +150,7 @@ it.layer(TestLayer)("WorkspaceFileSystemLive", (it) => {
contents: "# Plan\n",
});
- const afterWrite = yield* workspaceEntries.search({
- cwd,
- query: "rpc",
- limit: 10,
- });
+ const afterWrite = yield* workspaceEntries.list({ cwd });
expect(afterWrite.entries).toEqual(
expect.arrayContaining([expect.objectContaining({ path: "plans/effect-rpc.md" })]),
);
diff --git a/apps/server/src/workspace/Layers/WorkspaceFileSystem.ts b/apps/server/src/workspace/Layers/WorkspaceFileSystem.ts
index 309896e85..61056042b 100644
--- a/apps/server/src/workspace/Layers/WorkspaceFileSystem.ts
+++ b/apps/server/src/workspace/Layers/WorkspaceFileSystem.ts
@@ -11,7 +11,7 @@ import {
WorkspaceFileSystemError,
type WorkspaceFileSystemShape,
} from "../Services/WorkspaceFileSystem.ts";
-import { WorkspaceEntries } from "../Services/WorkspaceEntries.ts";
+import * as WorkspaceEntries from "../WorkspaceEntries.ts";
import { WorkspacePaths } from "../Services/WorkspacePaths.ts";
const PROJECT_READ_FILE_MAX_BYTES = 1024 * 1024;
@@ -20,7 +20,7 @@ export const makeWorkspaceFileSystem = Effect.gen(function* () {
const fileSystem = yield* FileSystem.FileSystem;
const path = yield* Path.Path;
const workspacePaths = yield* WorkspacePaths;
- const workspaceEntries = yield* WorkspaceEntries;
+ const workspaceEntries = yield* WorkspaceEntries.WorkspaceEntries;
const readFile: WorkspaceFileSystemShape["readFile"] = Effect.fn("WorkspaceFileSystem.readFile")(
function* (input) {
@@ -114,7 +114,7 @@ export const makeWorkspaceFileSystem = Effect.gen(function* () {
}),
),
);
- yield* workspaceEntries.invalidate(input.cwd);
+ yield* workspaceEntries.refresh(input.cwd);
return { relativePath: target.relativePath };
});
return { readFile, writeFile } satisfies WorkspaceFileSystemShape;
diff --git a/apps/server/src/workspace/Services/WorkspaceEntries.ts b/apps/server/src/workspace/Services/WorkspaceEntries.ts
deleted file mode 100644
index 888eff2ef..000000000
--- a/apps/server/src/workspace/Services/WorkspaceEntries.ts
+++ /dev/null
@@ -1,81 +0,0 @@
-/**
- * WorkspaceEntries - Effect service contract for cached workspace entry search.
- *
- * Owns indexed workspace entry search plus cache invalidation for workspace
- * roots when the underlying filesystem changes.
- *
- * @module WorkspaceEntries
- */
-import * as Schema from "effect/Schema";
-import * as Context from "effect/Context";
-import type * as Effect from "effect/Effect";
-
-import type {
- FilesystemBrowseInput,
- FilesystemBrowseResult,
- ProjectListEntriesInput,
- ProjectListEntriesResult,
- ProjectSearchEntriesInput,
- ProjectSearchEntriesResult,
-} from "@t3tools/contracts";
-
-export class WorkspaceEntriesError extends Schema.TaggedErrorClass<WorkspaceEntriesError>()(
- "WorkspaceEntriesError",
- {
- cwd: Schema.String,
- operation: Schema.String,
- detail: Schema.String,
- cause: Schema.optional(Schema.Defect()),
- },
-) {}
-
-export class WorkspaceEntriesBrowseError extends Schema.TaggedErrorClass<WorkspaceEntriesBrowseError>()(
- "WorkspaceEntriesBrowseError",
- {
- cwd: Schema.optional(Schema.String),
- partialPath: Schema.String,
- operation: Schema.String,
- detail: Schema.String,
- cause: Schema.optional(Schema.Defect()),
- },
-) {}
-
-/**
- * WorkspaceEntriesShape - Service API for workspace entry search and cache
- * invalidation.
- */
-export interface WorkspaceEntriesShape {
- /**
- * Browse matching directories for the provided partial path.
- */
- readonly browse: (
- input: FilesystemBrowseInput,
- ) => Effect.Effect<FilesystemBrowseResult, WorkspaceEntriesBrowseError>;
-
- /**
- * List the cached workspace index for a project root.
- */
- readonly list: (
- input: ProjectListEntriesInput,
- ) => Effect.Effect<ProjectListEntriesResult, WorkspaceEntriesError>;
-
- /**
- * Search indexed workspace entries for files and directories matching the
- * provided query.
- */
- readonly search: (
- input: ProjectSearchEntriesInput,
- ) => Effect.Effect<ProjectSearchEntriesResult, WorkspaceEntriesError>;
-
- /**
- * Drop any cached workspace entries for the given workspace root.
- */
- readonly invalidate: (cwd: string) => Effect.Effect<void>;
-}
-
-/**
- * WorkspaceEntries - Service tag for cached workspace entry search.
- */
-export class WorkspaceEntries extends Context.Service<WorkspaceEntries, WorkspaceEntriesShape>()(
- "t3/workspace/Services/WorkspaceEntries",
-) {}
diff --git a/apps/server/src/workspace/Layers/WorkspaceEntries.test.ts b/apps/server/src/workspace/WorkspaceEntries.test.ts
similarity index 76%
rename from apps/server/src/workspace/Layers/WorkspaceEntries.test.ts
rename to apps/server/src/workspace/WorkspaceEntries.test.ts
index 88562d6f5..f8a518d8b 100644
--- a/apps/server/src/workspace/Layers/WorkspaceEntries.test.ts
+++ b/apps/server/src/workspace/WorkspaceEntries.test.ts
@@ -1,27 +1,24 @@
// @effect-diagnostics nodeBuiltinImport:off
import fsPromises from "node:fs/promises";
import * as NodeServices from "@effect/platform-node/NodeServices";
+import { FileFinder } from "@ff-labs/fff-node";
import { it, afterEach, describe, expect, vi } from "@effect/vitest";
import * as Effect from "effect/Effect";
-import * as Fiber from "effect/Fiber";
import * as FileSystem from "effect/FileSystem";
import * as Layer from "effect/Layer";
import * as Path from "effect/Path";
import * as PlatformError from "effect/PlatformError";
-import { ServerConfig } from "../../config.ts";
+import { ServerConfig } from "../config.ts";
import { HostProcessPlatform } from "@t3tools/shared/hostProcess";
-import * as VcsDriverRegistry from "../../vcs/VcsDriverRegistry.ts";
-import * as VcsProcess from "../../vcs/VcsProcess.ts";
-import { WorkspaceEntries } from "../Services/WorkspaceEntries.ts";
-import { WorkspaceEntriesLive } from "./WorkspaceEntries.ts";
-import { WorkspacePathsLive } from "./WorkspacePaths.ts";
+import * as VcsProcess from "../vcs/VcsProcess.ts";
+import * as WorkspaceEntries from "./WorkspaceEntries.ts";
+import { WorkspacePathsLive } from "./Layers/WorkspacePaths.ts";
const TestLayer = Layer.empty.pipe(
- Layer.provideMerge(WorkspaceEntriesLive.pipe(Layer.provide(WorkspacePathsLive))),
+ Layer.provideMerge(WorkspaceEntries.layer.pipe(Layer.provide(WorkspacePathsLive))),
Layer.provideMerge(WorkspacePathsLive),
Layer.provideMerge(VcsProcess.layer),
- Layer.provideMerge(VcsDriverRegistry.layer.pipe(Layer.provide(VcsProcess.layer))),
Layer.provide(
ServerConfig.layerTest(process.cwd(), {
prefix: "t3-workspace-entries-test-",
@@ -71,7 +68,7 @@ const git = (cwd: string, args: ReadonlyArray<string>, env?: NodeJS.ProcessEnv)
const searchWorkspaceEntries = (input: { cwd: string; query: string; limit: number }) =>
Effect.gen(function* () {
- const workspaceEntries = yield* WorkspaceEntries;
+ const workspaceEntries = yield* WorkspaceEntries.WorkspaceEntries;
return yield* workspaceEntries.search(input);
});
@@ -82,7 +79,7 @@ const appendSeparator = (input: string) =>
: `${input}${platform === "win32" ? "\\" : "/"}`,
);
-it.layer(TestLayer)("WorkspaceEntriesLive", (it) => {
+it.layer(TestLayer, { excludeTestServices: true })("WorkspaceEntries", (it) => {
afterEach(() => {
vi.restoreAllMocks();
});
@@ -95,17 +92,16 @@ it.layer(TestLayer)("WorkspaceEntriesLive", (it) => {
yield* writeTextFile(cwd, "README.md");
yield* writeTextFile(cwd, "node_modules/pkg/index.js");
- const workspaceEntries = yield* WorkspaceEntries;
+ const workspaceEntries = yield* WorkspaceEntries.WorkspaceEntries;
const result = yield* workspaceEntries.list({ cwd });
expect(result.entries).toEqual(
expect.arrayContaining([
{ path: "src", kind: "directory" },
- { path: "src/components", kind: "directory", parentPath: "src" },
+ { path: "src/components", kind: "directory" },
{
path: "src/components/Composer.tsx",
kind: "file",
- parentPath: "src/components",
},
{ path: "README.md", kind: "file" },
]),
@@ -253,94 +249,39 @@ it.layer(TestLayer)("WorkspaceEntriesLive", (it) => {
}),
);
- it.effect("deduplicates concurrent index builds for the same cwd", () =>
+ it.effect("supports typo-resistant file search through fff", () =>
Effect.gen(function* () {
- const cwd = yield* makeTempDir({ prefix: "t3code-workspace-concurrent-build-" });
+ const cwd = yield* makeTempDir({ prefix: "t3code-workspace-fff-typo-" });
yield* writeTextFile(cwd, "src/components/Composer.tsx");
- let rootReadCount = 0;
- let releaseRootRead: (() => void) | undefined;
- const rootReadGate = new Promise<void>((resolve) => {
- releaseRootRead = resolve;
- });
- const originalReaddir = fsPromises.readdir.bind(fsPromises);
- vi.spyOn(fsPromises, "readdir").mockImplementation((async (
- ...args: Parameters<typeof fsPromises.readdir>
- ) => {
- if (args[0] === cwd) {
- rootReadCount += 1;
- await rootReadGate;
- }
- return originalReaddir(...args);
- }) as typeof fsPromises.readdir);
-
- const searches = yield* Effect.all(
- [
- searchWorkspaceEntries({ cwd, query: "", limit: 100 }),
- searchWorkspaceEntries({ cwd, query: "comp", limit: 100 }),
- searchWorkspaceEntries({ cwd, query: "src", limit: 100 }),
- ],
- { concurrency: "unbounded" },
- ).pipe(Effect.forkScoped);
- for (let attempt = 0; attempt < 50; attempt += 1) {
- if (rootReadCount > 0) {
- break;
- }
- yield* Effect.yieldNow;
- }
- releaseRootRead?.();
- yield* Fiber.join(searches);
-
- expect(rootReadCount).toBe(1);
+ const result = yield* searchWorkspaceEntries({ cwd, query: "compoesr", limit: 10 });
+
+ expect(result.entries).toEqual(
+ expect.arrayContaining([
+ expect.objectContaining({ path: "src/components/Composer.tsx" }),
+ ]),
+ );
}),
);
- it.effect("limits concurrent directory reads while walking the filesystem", () =>
+ it.effect("rebuilds the cached index after refresh fails", () =>
Effect.gen(function* () {
- const cwd = yield* makeTempDir({ prefix: "t3code-workspace-read-concurrency-" });
- yield* Effect.forEach(
- Array.from({ length: 80 }, (_, index) => index),
- (index) => writeTextFile(cwd, `group-${index}/entry-${index}.ts`, "export {};"),
- { discard: true },
- );
+ const cwd = yield* makeTempDir({ prefix: "t3code-workspace-refresh-failure-" });
+ yield* writeTextFile(cwd, "src/index.ts", "export {};\n");
+
+ const workspaceEntries = yield* WorkspaceEntries.WorkspaceEntries;
+ const createSpy = vi.spyOn(FileFinder, "create");
+ yield* workspaceEntries.list({ cwd });
+ expect(createSpy).toHaveBeenCalledTimes(1);
- let activeReads = 0;
- let peakReads = 0;
- let releaseReads: (() => void) | undefined;
- const readsGate = new Promise<void>((resolve) => {
- releaseReads = resolve;
+ vi.spyOn(FileFinder.prototype, "scanFiles").mockReturnValueOnce({
+ ok: false,
+ error: "scan failed",
});
- const originalReaddir = fsPromises.readdir.bind(fsPromises);
- vi.spyOn(fsPromises, "readdir").mockImplementation((async (
- ...args: Parameters<typeof fsPromises.readdir>
- ) => {
- const target = args[0];
- if (typeof target === "string" && target.startsWith(cwd)) {
- activeReads += 1;
- peakReads = Math.max(peakReads, activeReads);
- await readsGate;
- try {
- return await originalReaddir(...args);
- } finally {
- activeReads -= 1;
- }
- }
- return originalReaddir(...args);
- }) as typeof fsPromises.readdir);
-
- const search = yield* searchWorkspaceEntries({ cwd, query: "", limit: 200 }).pipe(
- Effect.forkScoped,
- );
- for (let attempt = 0; attempt < 50; attempt += 1) {
- if (activeReads > 0) {
- break;
- }
- yield* Effect.yieldNow;
- }
- releaseReads?.();
- yield* Fiber.join(search);
-
- expect(peakReads).toBeLessThanOrEqual(32);
+ yield* workspaceEntries.refresh(cwd);
+
+ yield* workspaceEntries.list({ cwd });
+ expect(createSpy).toHaveBeenCalledTimes(2);
}),
);
});
@@ -348,7 +289,7 @@ it.layer(TestLayer)("WorkspaceEntriesLive", (it) => {
describe("browse", () => {
it.effect("returns matching directories and excludes files", () =>
Effect.gen(function* () {
- const workspaceEntries = yield* WorkspaceEntries;
+ const workspaceEntries = yield* WorkspaceEntries.WorkspaceEntries;
const path = yield* Path.Path;
const cwd = yield* makeTempDir({ prefix: "t3code-workspace-browse-prefix-" });
yield* writeTextFile(cwd, "alphabet.txt", "ignore me");
@@ -371,7 +312,7 @@ it.layer(TestLayer)("WorkspaceEntriesLive", (it) => {
it.effect("shows dot directories in directory mode and hidden-prefix mode", () =>
Effect.gen(function* () {
- const workspaceEntries = yield* WorkspaceEntries;
+ const workspaceEntries = yield* WorkspaceEntries.WorkspaceEntries;
const path = yield* Path.Path;
const cwd = yield* makeTempDir({ prefix: "t3code-workspace-browse-hidden-" });
yield* writeTextFile(cwd, ".config/settings.json", "{}");
@@ -395,7 +336,7 @@ it.layer(TestLayer)("WorkspaceEntriesLive", (it) => {
it.effect("supports relative paths when cwd is provided", () =>
Effect.gen(function* () {
- const workspaceEntries = yield* WorkspaceEntries;
+ const workspaceEntries = yield* WorkspaceEntries.WorkspaceEntries;
const path = yield* Path.Path;
const cwd = yield* makeTempDir({ prefix: "t3code-workspace-browse-relative-" });
yield* writeTextFile(cwd, "packages/pkg.json", "{}");
@@ -414,7 +355,7 @@ it.layer(TestLayer)("WorkspaceEntriesLive", (it) => {
it.effect("rejects relative paths without cwd", () =>
Effect.gen(function* () {
- const workspaceEntries = yield* WorkspaceEntries;
+ const workspaceEntries = yield* WorkspaceEntries.WorkspaceEntries;
const error = yield* workspaceEntries
.browse({
@@ -428,7 +369,7 @@ it.layer(TestLayer)("WorkspaceEntriesLive", (it) => {
it.effect("returns an empty listing when the OS denies directory access", () =>
Effect.gen(function* () {
- const workspaceEntries = yield* WorkspaceEntries;
+ const workspaceEntries = yield* WorkspaceEntries.WorkspaceEntries;
const cwd = yield* makeTempDir({ prefix: "t3code-workspace-browse-eacces-" });
const denied = Object.assign(new Error("EACCES: permission denied"), { code: "EACCES" });
diff --git a/apps/server/src/workspace/WorkspaceEntries.ts b/apps/server/src/workspace/WorkspaceEntries.ts
new file mode 100644
index 000000000..bf9a51c74
--- /dev/null
+++ b/apps/server/src/workspace/WorkspaceEntries.ts
@@ -0,0 +1,252 @@
+// @effect-diagnostics nodeBuiltinImport:off
+import * as NodeFSP from "node:fs/promises";
+import * as NodeOS from "node:os";
+
+import * as Context from "effect/Context";
+import * as Effect from "effect/Effect";
+import * as Layer from "effect/Layer";
+import * as Path from "effect/Path";
+import * as RcMap from "effect/RcMap";
+import * as Schema from "effect/Schema";
+
+import type {
+ FilesystemBrowseInput,
+ FilesystemBrowseResult,
+ ProjectListEntriesInput,
+ ProjectListEntriesResult,
+ ProjectSearchEntriesInput,
+ ProjectSearchEntriesResult,
+} from "@t3tools/contracts";
+import { HostProcessPlatform } from "@t3tools/shared/hostProcess";
+import { isExplicitRelativePath, isWindowsAbsolutePath } from "@t3tools/shared/path";
+
+import * as WorkspacePaths from "./Services/WorkspacePaths.ts";
+import * as WorkspaceSearchIndex from "./WorkspaceSearchIndex.ts";
+
+export class WorkspaceEntriesError extends Schema.TaggedErrorClass<WorkspaceEntriesError>()(
+ "WorkspaceEntriesError",
+ {
+ cwd: Schema.String,
+ operation: Schema.String,
+ detail: Schema.String,
+ cause: Schema.optional(Schema.Defect()),
+ },
+) {}
+
+export class WorkspaceEntriesBrowseError extends Schema.TaggedErrorClass<WorkspaceEntriesBrowseError>()(
+ "WorkspaceEntriesBrowseError",
+ {
+ cwd: Schema.optional(Schema.String),
+ partialPath: Schema.String,
+ operation: Schema.String,
+ detail: Schema.String,
+ cause: Schema.optional(Schema.Defect()),
+ },
+) {}
+
+export class WorkspaceEntries extends Context.Service<
+ WorkspaceEntries,
+ {
+ readonly browse: (
+ input: FilesystemBrowseInput,
+ ) => Effect.Effect<FilesystemBrowseResult, WorkspaceEntriesBrowseError>;
+ readonly list: (
+ input: ProjectListEntriesInput,
+ ) => Effect.Effect<ProjectListEntriesResult, WorkspaceEntriesError>;
+ readonly search: (
+ input: ProjectSearchEntriesInput,
+ ) => Effect.Effect<ProjectSearchEntriesResult, WorkspaceEntriesError>;
+ readonly refresh: (cwd: string) => Effect.Effect<void>;
+ }
+>()("t3/workspace/WorkspaceEntries") {}
+
+function expandHomePath(input: string, path: Path.Path): string {
+ if (input === "~") {
+ return NodeOS.homedir();
+ }
+ if (input.startsWith("~/") || input.startsWith("~\\")) {
+ return path.join(NodeOS.homedir(), input.slice(2));
+ }
+ return input;
+}
+
+const resolveBrowseTarget = (
+ input: FilesystemBrowseInput,
+ path: Path.Path,
+): Effect.Effect<string, WorkspaceEntriesBrowseError> =>
+ Effect.gen(function* () {
+ const platform = yield* HostProcessPlatform;
+ if (platform !== "win32" && isWindowsAbsolutePath(input.partialPath)) {
+ return yield* new WorkspaceEntriesBrowseError({
+ cwd: input.cwd,
+ partialPath: input.partialPath,
+ operation: "workspaceEntries.resolveBrowseTarget",
+ detail: "Windows-style paths are only supported on Windows.",
+ });
+ }
+
+ if (!isExplicitRelativePath(input.partialPath)) {
+ return path.resolve(expandHomePath(input.partialPath, path));
+ }
+
+ if (!input.cwd) {
+ return yield* new WorkspaceEntriesBrowseError({
+ cwd: input.cwd,
+ partialPath: input.partialPath,
+ operation: "workspaceEntries.resolveBrowseTarget",
+ detail: "Relative filesystem browse paths require a current project.",
+ });
+ }
+
+ return path.resolve(expandHomePath(input.cwd, path), input.partialPath);
+ });
+
+const make = Effect.gen(function* () {
+ const path = yield* Path.Path;
+ const workspacePaths = yield* WorkspacePaths.WorkspacePaths;
+ const workspaceSearchIndexes = yield* WorkspaceSearchIndex.WorkspaceSearchIndexMap;
+
+ const normalizeWorkspaceRoot = Effect.fn("WorkspaceEntries.normalizeWorkspaceRoot")(function* (
+ cwd: string,
+ ): Effect.fn.Return<string, WorkspaceEntriesError> {
+ return yield* workspacePaths.normalizeWorkspaceRoot(cwd).pipe(
+ Effect.mapError(
+ (cause) =>
+ new WorkspaceEntriesError({
+ cwd,
+ operation: "workspaceEntries.normalizeWorkspaceRoot",
+ detail: cause.message,
+ cause,
+ }),
+ ),
+ );
+ });
+
+ const refresh: WorkspaceEntries["Service"]["refresh"] = Effect.fn("WorkspaceEntries.refresh")(
+ function* (cwd) {
+ const normalizedCwd = yield* normalizeWorkspaceRoot(cwd).pipe(
+ Effect.orElseSucceed(() => cwd),
+ );
+ if (!(yield* RcMap.has(workspaceSearchIndexes.rcMap, normalizedCwd))) {
+ return;
+ }
+ yield* Effect.gen(function* () {
+ const searchIndex = yield* WorkspaceSearchIndex.WorkspaceSearchIndex;
+ yield* searchIndex.refresh();
+ }).pipe(
+ Effect.provide(workspaceSearchIndexes.get(normalizedCwd)),
+ Effect.catch((cause) =>
+ Effect.gen(function* () {
+ yield* Effect.logWarning("Failed to refresh workspace search index", {
+ cwd,
+ cause,
+ });
+ yield* workspaceSearchIndexes.invalidate(normalizedCwd);
+ }),
+ ),
+ );
+ },
+ );
+
+ const browse: WorkspaceEntries["Service"]["browse"] = Effect.fn("WorkspaceEntries.browse")(
+ function* (input) {
+ const resolvedInputPath = yield* resolveBrowseTarget(input, path);
+ const endsWithSeparator = /[\\/]$/.test(input.partialPath) || input.partialPath === "~";
+ const parentPath = endsWithSeparator ? resolvedInputPath : path.dirname(resolvedInputPath);
+ const prefix = endsWithSeparator ? "" : path.basename(resolvedInputPath);
+
+ const dirents = yield* Effect.tryPromise({
+ try: () => NodeFSP.readdir(parentPath, { withFileTypes: true }),
+ catch: (cause) =>
+ new WorkspaceEntriesBrowseError({
+ cwd: input.cwd,
+ partialPath: input.partialPath,
+ operation: "workspaceEntries.browse.readDirectory",
+ detail: `Unable to browse '${parentPath}': ${cause instanceof Error ? cause.message : String(cause)}`,
+ cause,
+ }),
+ }).pipe(
+ Effect.catchIf(
+ (error) => {
+ const code = (error.cause as NodeJS.ErrnoException | undefined)?.code;
+ return code === "EACCES" || code === "EPERM";
+ },
+ () => Effect.succeed([]),
+ ),
+ );
+
+ const showHidden = endsWithSeparator || prefix.startsWith(".");
+ const lowerPrefix = prefix.toLowerCase();
+ const entries: Array<{ readonly name: string; readonly fullPath: string }> = [];
+ for (const dirent of dirents) {
+ if (
+ dirent.isDirectory() &&
+ dirent.name.toLowerCase().startsWith(lowerPrefix) &&
+ (showHidden || !dirent.name.startsWith("."))
+ ) {
+ entries.push({
+ name: dirent.name,
+ fullPath: path.join(parentPath, dirent.name),
+ });
+ }
+ }
+
+ return {
+ parentPath,
+ entries: entries.toSorted((left, right) => left.name.localeCompare(right.name)),
+ };
+ },
+ );
+
+ const search: WorkspaceEntries["Service"]["search"] = Effect.fn("WorkspaceEntries.search")(
+ function* (input) {
+ const normalizedCwd = yield* normalizeWorkspaceRoot(input.cwd);
+ const normalizedQuery = input.query
+ .trim()
+ .toLowerCase()
+ .replace(/^[@./]+/, "");
+ return yield* Effect.gen(function* () {
+ const searchIndex = yield* WorkspaceSearchIndex.WorkspaceSearchIndex;
+ return yield* searchIndex.search(normalizedQuery, input.limit);
+ }).pipe(
+ Effect.provide(workspaceSearchIndexes.get(normalizedCwd)),
+ Effect.mapError(
+ (cause) =>
+ new WorkspaceEntriesError({
+ cwd: input.cwd,
+ operation: "workspaceEntries.search",
+ detail: cause.message,
+ cause,
+ }),
+ ),
+ );
+ },
+ );
+
+ const list: WorkspaceEntries["Service"]["list"] = Effect.fn("WorkspaceEntries.list")(
+ function* (input) {
+ const normalizedCwd = yield* normalizeWorkspaceRoot(input.cwd);
+ return yield* Effect.gen(function* () {
+ const searchIndex = yield* WorkspaceSearchIndex.WorkspaceSearchIndex;
+ return yield* searchIndex.list();
+ }).pipe(
+ Effect.provide(workspaceSearchIndexes.get(normalizedCwd)),
+ Effect.mapError(
+ (cause) =>
+ new WorkspaceEntriesError({
+ cwd: input.cwd,
+ operation: "workspaceEntries.list",
+ detail: cause.message,
+ cause,
+ }),
+ ),
+ );
+ },
+ );
+
+ return WorkspaceEntries.of({ browse, list, refresh, search });
+});
+
+export const layer = Layer.effect(WorkspaceEntries, make).pipe(
+ Layer.provide(WorkspaceSearchIndex.WorkspaceSearchIndexMap.layer),
+);
diff --git a/apps/server/src/workspace/WorkspaceSearchIndex.ts b/apps/server/src/workspace/WorkspaceSearchIndex.ts
new file mode 100644
index 000000000..4bee3cbc0
--- /dev/null
+++ b/apps/server/src/workspace/WorkspaceSearchIndex.ts
@@ -0,0 +1,245 @@
+import { FileFinder, type MixedItem, type MixedSearchResult } from "@ff-labs/fff-node";
+import * as Context from "effect/Context";
+import * as Effect from "effect/Effect";
+import * as Layer from "effect/Layer";
+import * as LayerMap from "effect/LayerMap";
+import * as Schedule from "effect/Schedule";
+import * as Schema from "effect/Schema";
+
+import type {
+ ProjectEntry,
+ ProjectListEntriesResult,
+ ProjectSearchEntriesResult,
+} from "@t3tools/contracts";
+
+const WORKSPACE_INDEX_MAX_ENTRIES = 25_000;
+const WORKSPACE_INDEX_PAGE_SIZE = WORKSPACE_INDEX_MAX_ENTRIES + 2;
+const WORKSPACE_INDEX_SCAN_TIMEOUT = "15 seconds";
+const WORKSPACE_INDEX_IDLE_TTL = "15 minutes";
+const WORKSPACE_INDEX_SCAN_POLL_INTERVAL = "50 millis";
+
+export class WorkspaceSearchIndexCreateFailed extends Schema.TaggedErrorClass<WorkspaceSearchIndexCreateFailed>()(
+ "WorkspaceSearchIndexCreateFailed",
+ {
+ cwd: Schema.String,
+ reason: Schema.String,
+ },
+) {
+ override get message(): string {
+ return `Failed to create the workspace search index for '${this.cwd}': ${this.reason}`;
+ }
+}
+
+export class WorkspaceSearchIndexScanTimedOut extends Schema.TaggedErrorClass<WorkspaceSearchIndexScanTimedOut>()(
+ "WorkspaceSearchIndexScanTimedOut",
+ {
+ cwd: Schema.String,
+ timeout: Schema.String,
+ },
+) {
+ override get message(): string {
+ return `Workspace search index for '${this.cwd}' did not finish scanning within ${this.timeout}`;
+ }
+}
+
+export class WorkspaceSearchIndexSearchFailed extends Schema.TaggedErrorClass<WorkspaceSearchIndexSearchFailed>()(
+ "WorkspaceSearchIndexSearchFailed",
+ {
+ cwd: Schema.String,
+ reason: Schema.String,
+ },
+) {
+ override get message(): string {
+ return `Workspace search failed for '${this.cwd}': ${this.reason}`;
+ }
+}
+
+export class WorkspaceSearchIndexRefreshFailed extends Schema.TaggedErrorClass<WorkspaceSearchIndexRefreshFailed>()(
+ "WorkspaceSearchIndexRefreshFailed",
+ {
+ cwd: Schema.String,
+ reason: Schema.String,
+ },
+) {
+ override get message(): string {
+ return `Failed to refresh the workspace search index for '${this.cwd}': ${this.reason}`;
+ }
+}
+
+export type WorkspaceSearchIndexError =
+ | WorkspaceSearchIndexCreateFailed
+ | WorkspaceSearchIndexScanTimedOut
+ | WorkspaceSearchIndexSearchFailed
+ | WorkspaceSearchIndexRefreshFailed;
+
+export class WorkspaceSearchIndex extends Context.Service<
+ WorkspaceSearchIndex,
+ {
+ readonly list: () => Effect.Effect<ProjectListEntriesResult, WorkspaceSearchIndexSearchFailed>;
+ readonly search: (
+ query: string,
+ limit: number,
+ ) => Effect.Effect<ProjectSearchEntriesResult, WorkspaceSearchIndexSearchFailed>;
+ readonly refresh: () => Effect.Effect<
+ void,
+ WorkspaceSearchIndexRefreshFailed | WorkspaceSearchIndexScanTimedOut
+ >;
+ }
+>()("t3/workspace/WorkspaceSearchIndex") {}
+
+function toPosixPath(input: string): string {
+ return input.replaceAll("\\", "/");
+}
+
+function trimDirectorySeparator(input: string): string {
+ return input.endsWith("/") ? input.slice(0, -1) : input;
+}
+
+function parentPathOf(input: string): string | undefined {
+ const separatorIndex = input.lastIndexOf("/");
+ return separatorIndex === -1 ? undefined : input.slice(0, separatorIndex);
+}
+
+function toProjectEntry(item: MixedItem): ProjectEntry | null {
+ const normalizedPath = trimDirectorySeparator(toPosixPath(item.item.relativePath));
+ if (!normalizedPath) {
+ return null;
+ }
+
+ return {
+ path: normalizedPath,
+ kind: item.type,
+ };
+}
+
+function mapMixedSearchResult(
+ result: MixedSearchResult,
+ limit: number,
+): { readonly entries: ProjectEntry[]; readonly truncated: boolean } {
+ const entries: ProjectEntry[] = [];
+ for (const item of result.items) {
+ const entry = toProjectEntry(item);
+ if (entry) {
+ entries.push(entry);
+ }
+ if (entries.length >= limit) {
+ break;
+ }
+ }
+
+ const rootDirectoryCount = result.items.some(
+ (item) => item.type === "directory" && item.item.relativePath.length === 0,
+ )
+ ? 1
+ : 0;
+ return {
+ entries,
+ truncated: result.totalMatched - rootDirectoryCount > limit,
+ };
+}
+
+function withDirectoryAncestors(entries: ReadonlyArray<ProjectEntry>): ProjectEntry[] {
+ const entryByPath = new Map(entries.map((entry) => [entry.path, entry]));
+ for (const entry of entries) {
+ let parentPath = parentPathOf(entry.path);
+ while (parentPath) {
+ if (!entryByPath.has(parentPath)) {
+ entryByPath.set(parentPath, { path: parentPath, kind: "directory" });
+ }
+ parentPath = parentPathOf(parentPath);
+ }
+ }
+ return [...entryByPath.values()];
+}
+
+const createFinder = Effect.fn("WorkspaceSearchIndex.createFinder")(function* (cwd: string) {
+ const result = FileFinder.create({
+ basePath: cwd,
+ disableMmapCache: true,
+ disableContentIndexing: true,
+ aiMode: false,
+ enableFsRootScanning: true,
+ enableHomeDirScanning: true,
+ });
+ if (result.ok) return result.value;
+ return yield* new WorkspaceSearchIndexCreateFailed({ cwd, reason: result.error });
+});
+
+const waitForScan = Effect.fn("WorkspaceSearchIndex.waitForScan")(function* (
+ cwd: string,
+ finder: FileFinder,
+) {
+ yield* Effect.sync(() => finder.isScanning()).pipe(
+ Effect.repeat({
+ while: (scanning) => scanning,
+ schedule: Schedule.spaced(WORKSPACE_INDEX_SCAN_POLL_INTERVAL),
+ }),
+ Effect.timeoutOrElse({
+ duration: WORKSPACE_INDEX_SCAN_TIMEOUT,
+ orElse: () =>
+ new WorkspaceSearchIndexScanTimedOut({ cwd, timeout: WORKSPACE_INDEX_SCAN_TIMEOUT }),
+ }),
+ );
+});
+
+const makeWorkspaceSearchIndex = (cwd: string) =>
+ Effect.acquireRelease(createFinder(cwd), (finder) => Effect.sync(() => finder.destroy())).pipe(
+ Effect.tap((finder) => waitForScan(cwd, finder)),
+ Effect.map((finder) => {
+ const runMixedSearch = Effect.fn("WorkspaceSearchIndex.runMixedSearch")(function* (
+ query: string,
+ pageSize: number,
+ ) {
+ const result = yield* Effect.sync(() => finder.mixedSearch(query, { pageSize }));
+ if (!result.ok) {
+ return yield* new WorkspaceSearchIndexSearchFailed({ cwd, reason: result.error });
+ }
+ return result.value;
+ });
+
+ const refresh: WorkspaceSearchIndex["Service"]["refresh"] = Effect.fn(
+ "WorkspaceSearchIndex.refresh",
+ )(function* () {
+ const result = yield* Effect.sync(() => finder.scanFiles());
+ if (!result.ok) {
+ return yield* new WorkspaceSearchIndexRefreshFailed({ cwd, reason: result.error });
+ }
+ yield* waitForScan(cwd, finder);
+ });
+
+ const list: WorkspaceSearchIndex["Service"]["list"] = Effect.fn("WorkspaceSearchIndex.list")(
+ function* () {
+ const result = yield* runMixedSearch("", WORKSPACE_INDEX_PAGE_SIZE);
+ const mapped = mapMixedSearchResult(result, WORKSPACE_INDEX_MAX_ENTRIES);
+ const sortedEntries = withDirectoryAncestors(mapped.entries).toSorted((left, right) =>
+ left.path.localeCompare(right.path),
+ );
+ const entries = sortedEntries.slice(0, WORKSPACE_INDEX_MAX_ENTRIES);
+ return {
+ entries,
+ truncated: mapped.truncated || entries.length < sortedEntries.length,
+ };
+ },
+ );
+
+ const search: WorkspaceSearchIndex["Service"]["search"] = Effect.fn(
+ "WorkspaceSearchIndex.search",
+ )(function* (query, limit) {
+ const result = yield* runMixedSearch(query, Math.max(1, limit + 1));
+ return mapMixedSearchResult(result, limit);
+ });
+
+ return WorkspaceSearchIndex.of({ list, refresh, search });
+ }),
+ );
+
+const workspaceSearchIndexLayer = (cwd: string) =>
+ Layer.effect(WorkspaceSearchIndex, makeWorkspaceSearchIndex(cwd));
+
+export class WorkspaceSearchIndexMap extends LayerMap.Service<WorkspaceSearchIndexMap>()(
+ "t3/workspace/WorkspaceSearchIndexMap",
+ {
+ lookup: workspaceSearchIndexLayer,
+ idleTimeToLive: WORKSPACE_INDEX_IDLE_TTL,
+ },
+) {}
diff --git a/apps/server/src/ws.ts b/apps/server/src/ws.ts
index 99ee6146a..34c993de8 100644
--- a/apps/server/src/ws.ts
+++ b/apps/server/src/ws.ts
@@ -78,7 +78,7 @@ import * as PreviewAutomationBroker from "./mcp/PreviewAutomationBroker.ts";
import * as PreviewManager from "./preview/Manager.ts";
import { issueAssetUrl } from "./assets/AssetAccess.ts";
import * as PortScanner from "./preview/PortScanner.ts";
-import { WorkspaceEntries } from "./workspace/Services/WorkspaceEntries.ts";
+import * as WorkspaceEntries from "./workspace/WorkspaceEntries.ts";
import { WorkspaceFileSystem } from "./workspace/Services/WorkspaceFileSystem.ts";
import { WorkspacePathOutsideRootError } from "./workspace/Services/WorkspacePaths.ts";
import { VcsStatusBroadcaster } from "./vcs/VcsStatusBroadcaster.ts";
@@ -272,7 +272,7 @@ const makeWsRpcLayer = (currentSession: AuthenticatedSession) =>
const lifecycleEvents = yield* ServerLifecycleEvents;
const serverSettings = yield* ServerSettingsService;
const startup = yield* ServerRuntimeStartup;
- const workspaceEntries = yield* WorkspaceEntries;
+ const workspaceEntries = yield* WorkspaceEntries.WorkspaceEntries;
const workspaceFileSystem = yield* WorkspaceFileSystem;
const projectSetupScriptRunner = yield* ProjectSetupScriptRunner;
const repositoryIdentityResolver = yield* RepositoryIdentityResolver;
diff --git a/apps/web/src/components/ChatView.browser.tsx b/apps/web/src/components/ChatView.browser.tsx
index 794f50267..6f620d9a0 100644
--- a/apps/web/src/components/ChatView.browser.tsx
+++ b/apps/web/src/components/ChatView.browser.tsx
@@ -4432,7 +4432,6 @@ describe("ChatView timeline estimator parity (full app)", () => {
{
path: "path/to/package.json",
kind: "file",
- parentPath: "path/to",
},
],
truncated: false,
diff --git a/apps/web/src/components/chat/ChatComposer.tsx b/apps/web/src/components/chat/ChatComposer.tsx
index 50568e8ac..ac440320a 100644
--- a/apps/web/src/components/chat/ChatComposer.tsx
+++ b/apps/web/src/components/chat/ChatComposer.tsx
@@ -928,7 +928,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
path: entry.path,
pathKind: entry.kind,
label: basenameOfPath(entry.path),
- description: entry.parentPath ?? "",
+ description: entry.path.slice(0, Math.max(0, entry.path.lastIndexOf("/"))),
}));
}
if (composerTrigger.kind === "slash-command") {
diff --git a/packages/client-runtime/src/composerPathSearchState.ts b/packages/client-runtime/src/composerPathSearchState.ts
index e8652ce56..693d60cb4 100644
--- a/packages/client-runtime/src/composerPathSearchState.ts
+++ b/packages/client-runtime/src/composerPathSearchState.ts
@@ -8,7 +8,6 @@ import { Atom, type AtomRegistry } from "effect/unstable/reactivity";
export interface ComposerPathSearchEntry {
readonly path: string;
readonly kind: "file" | "directory";
- readonly parentPath?: string;
}
export interface ComposerPathSearchState {
@@ -84,11 +83,7 @@ export function getComposerPathSearchTargetKey(target: ComposerPathSearchTarget)
function toSearchEntries(
entries: ProjectSearchEntriesResult["entries"],
): ReadonlyArray<ComposerPathSearchEntry> {
- return entries.map((entry) => ({
- path: entry.path,
- kind: entry.kind === "directory" ? "directory" : "file",
- ...(entry.parentPath !== undefined ? { parentPath: entry.parentPath } : {}),
- }));
+ return entries;
}
export function createComposerPathSearchManager(config: {
diff --git a/packages/contracts/src/project.ts b/packages/contracts/src/project.ts
index 0d38efec2..296108452 100644
--- a/packages/contracts/src/project.ts
+++ b/packages/contracts/src/project.ts
@@ -17,7 +17,6 @@ const ProjectEntryKind = Schema.Literals(["file", "directory"]);
export const ProjectEntry = Schema.Struct({
path: TrimmedNonEmptyString,
kind: ProjectEntryKind,
- parentPath: Schema.optional(TrimmedNonEmptyString),
});
export type ProjectEntry = typeof ProjectEntry.Type;
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 7fbbda5a7..f1bd60b2f 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -395,6 +395,9 @@ importers:
'@effect/sql-sqlite-bun':
specifier: 4.0.0-beta.78
version: 4.0.0-beta.78([email protected](patch_hash=883249d8efbb462e928e21fefef96027b66aec50751178cafdce45f08eee3754))
+ '@ff-labs/fff-node':
+ specifier: ^0.9.4
+ version: 0.9.4
'@opencode-ai/sdk':
specifier: ^1.3.15
version: 1.15.13
@@ -2374,6 +2377,52 @@ packages:
resolution: {integrity: sha512-4aQzz9vgxcNXFfo/iyNgDDYfsU5XGKKxWxZopw0cVotHiW+U8IJbIxMaxsINs6bHhtkG3StKNPcOrn3eBuxKPw==}
hasBin: true
+ '@ff-labs/[email protected]':
+ resolution: {integrity: sha512-xyivu2xB++O5xXDx5Qm50JsU2aXt8YgXlGVhH/HE7UMYDrE6L6f1RYdYs8Y0bn0D3D0+bFBrN5ELPszK9E4Wbw==}
+ cpu: [arm64]
+ os: [darwin]
+
+ '@ff-labs/[email protected]':
+ resolution: {integrity: sha512-xLooAhCnTDCipPSMMZz7kGF3lhRHx6aP5fb6DJ0Ipyw/w/UWJb+xITJFszUl/QnIBoJ/qjDc93/FZMo1dk6gVA==}
+ cpu: [x64]
+ os: [darwin]
+
+ '@ff-labs/[email protected]':
+ resolution: {integrity: sha512-m5+8vA+1veaUUWonwva1WsU6m1HRm8CpYUzr06KDB65mewlmPbqz7+Fh7hjEfiD8C4mHVHe6RysULvAH1yhsdw==}
+ cpu: [arm64]
+ os: [linux]
+
+ '@ff-labs/[email protected]':
+ resolution: {integrity: sha512-EMeWm7CSTVkizy4ZEzUkLDP024tVcbCUthduuIhekFQRDsiaAze0YboIylWb9HBHJCZlCCoZrWAl4nnJbsX7AA==}
+ cpu: [arm64]
+ os: [linux]
+
+ '@ff-labs/[email protected]':
+ resolution: {integrity: sha512-pglE0uLkhnlE6bStXqfgUjYTSj+2sVwXaPfoA0QksidAsQor6NRt8004mygzC9DPubgHq5B9QezPfEwigKaP9Q==}
+ cpu: [x64]
+ os: [linux]
+
+ '@ff-labs/[email protected]':
+ resolution: {integrity: sha512-VNKxgl8qs3aTfXViX7lqRK1aLu311h8dtBFqG4Scv+9Oi7WprybUp5L7IZ8sxKERaDAaiJMXHodXa1c90QdK8w==}
+ cpu: [x64]
+ os: [linux]
+
+ '@ff-labs/[email protected]':
+ resolution: {integrity: sha512-uFEt0aNL54vQxq1ivjxRuo+thnhS4wLqa4INl4VXnXJUmwB42XXxD+gsj7vzhBLLx4cFf0aWgy/+TVDR8yjZtQ==}
+ cpu: [arm64]
+ os: [win32]
+
+ '@ff-labs/[email protected]':
+ resolution: {integrity: sha512-Yd2Eyxj+slWv+0QDW9/xBpu9FXq+hwD0rXQD5184/88d+xwWCLKhEP2w8I6OO9XCg+kLT79UJb+k0WwXUtBtMw==}
+ cpu: [x64]
+ os: [win32]
+
+ '@ff-labs/[email protected]':
+ resolution: {integrity: sha512-yUphwzcVBuNrg1iEAE5XVPOWfCLuq/BE1scUxtHMmLo+e1KuKWBRgSKFXGjNBfL8lV3c5VGwIgK66aBqmhqVBQ==}
+ engines: {node: '>=18.0.0'}
+ cpu: [x64, arm64]
+ os: [darwin, linux, win32]
+
'@floating-ui/[email protected]':
resolution: {integrity: sha512-1Ih4WTWyw0+lKyFMcBHGbb5U5FtuHJuujoyyr5zTaWS5EYMeT6Jb2AuDeftsCsEuchO+mM2ij5+q9crhydzLhQ==}
@@ -4804,6 +4853,72 @@ packages:
resolution: {integrity: sha512-TQwDdQGtwwDt+2cgKDLn0IRaSxYu1tSUjgKarSDkUM0ZNiSRXFpjxEsvc/Zgc5kq5omJ+V0a8/kIM2WD3sMOYg==}
+ '@yuuang/[email protected]':
+ resolution: {integrity: sha512-eDYLT0kVBkp7e2BwdRDmt6N1rkeDPUHDefk3ZX0/nok+GLsqfy1WBoSL3Yg7HVXN1EyW8OBVc2uK8Zq8HbmaSA==}
+ engines: {node: '>= 12'}
+ cpu: [arm64]
+ os: [android]
+
+ '@yuuang/[email protected]':
+ resolution: {integrity: sha512-kRdgPaOM6TfuC5wHUwstlatk4HNie2lwSLJWQL2LiAUIJ7+96CoiWUNVhwBcFrhdfxhnWenYS6F668CV0vit8Q==}
+ engines: {node: '>= 12'}
+ cpu: [arm64]
+ os: [darwin]
+
+ '@yuuang/[email protected]':
+ resolution: {integrity: sha512-O3AlVgre8FQcZRJe44Xs7A6iDLumoPXqbw40+eJCa2gyXaXyLPdHoWrS1W9rBCa1QZRRnG7zRulPVFw8C5uo8g==}
+ engines: {node: '>= 12'}
+ cpu: [x64]
+ os: [darwin]
+
+ '@yuuang/[email protected]':
+ resolution: {integrity: sha512-IXiNdTbIcTCPny5eeElijFWYeKSJjQWSjt9ZyJNdLHYiB1Np+XD6K7wNZS6EOMgMelhW1kQE62T654skGkVDIA==}
+ engines: {node: '>= 12'}
+ cpu: [arm]
+ os: [linux]
+
+ '@yuuang/[email protected]':
+ resolution: {integrity: sha512-gWFO6xufUK9lPYUqDvKa6IR243dPqdetgl9Q7HrZWaDu7wLo06QQrosw8QTzndafQnOcBKm6LoLujmGCfTgJOA==}
+ engines: {node: '>= 12'}
+ cpu: [arm64]
+ os: [linux]
+
+ '@yuuang/[email protected]':
+ resolution: {integrity: sha512-lejvOSqypPziQH5rzfkDlJ6e92qhWbDutE9ttOO6z5I2k83zoh9iZhZWhaXSU5VqgQpcshRkrbtXb9gy1ft5dA==}
+ engines: {node: '>= 12'}
+ cpu: [arm64]
+ os: [linux]
+
+ '@yuuang/[email protected]':
+ resolution: {integrity: sha512-s8VCFazaJKmgY2hgMTpWk4TtBY/zy5ovbaGgwyY0FvBD0YvyhcET4IrMsDJpHhFVTPCYfKZ1dN45clD/YiFp6g==}
+ engines: {node: '>= 12'}
+ cpu: [x64]
+ os: [linux]
+
+ '@yuuang/[email protected]':
+ resolution: {integrity: sha512-Ahr5chfKZKWUik20bEZRug+be57LZ2yYrtolyjSRoo7A4ZniBUHBZUNWm6TD6i0CJayqyxWeVk/XiaABD8bY0w==}
+ engines: {node: '>= 12'}
+ cpu: [x64]
+ os: [linux]
+
+ '@yuuang/[email protected]':
+ resolution: {integrity: sha512-yhpLcj0qel5VNlpzxPZfNmi7+rEX8444QHjUP6WWLxdRfqPllROu/Cp3OpkBpw3BLdxfcDhWkjWMD5QsJN0Pvg==}
+ engines: {node: '>= 12'}
+ cpu: [arm64]
+ os: [win32]
+
+ '@yuuang/[email protected]':
+ resolution: {integrity: sha512-BFVSbdtg/7mJBw5kQFOPKFiA+SF7z3240HpzHN81Umm4Bp4dWkyx0msYn8+Q7/BBJiLQ4F6bi3Nftk58YA9r9w==}
+ engines: {node: '>= 12'}
+ cpu: [x64, ia32]
+ os: [win32]
+
+ '@yuuang/[email protected]':
+ resolution: {integrity: sha512-ZL5MJ76n2rjwGo26kCWW7wK6QT/cee00Rx8pfW79pz6vM6jqfhoE7zTnwFiw4aOQUes9+HUc5DeeJ3z+Vb9oLg==}
+ engines: {node: '>= 12'}
+ cpu: [x64]
+ os: [win32]
+
'@zxcvbn-ts/[email protected]':
resolution: {integrity: sha512-aQeiT0F09FuJaAqNrxynlAwZ2mW/1MdXakKWNmGM1Qp/VaY6CnB/GfnMS2T8gB2231Esp1/maCWd8vTG4OuShw==}
@@ -6353,6 +6468,9 @@ packages:
resolution: {integrity: sha512-m6I8ALe4L4XpdETy7MJZWs6L1IVMbjs99bwbpIKphxX+0CTns4IKDWJY0LWfr4YsFjfg+z1TjzTMU8lKl8rG0w==}
+ resolution: {integrity: sha512-4s8dX9VbBw/jd5NOuE3EJRqXaIVdjMyiumeeDzrOhtjQRwp6Bz2za7iksWXTnvTQKV/tTdm1s1w7mObe92zPjQ==}
+
resolution: {integrity: sha512-5giy2PkLYY1cP39p17Ech+2xlpTRL9HLspOfEgm0L6CwBXBTgsK5ou0JtzYuepxkaQ/tvhCFIJ5uXo0OrM2DxA==}
@@ -11712,6 +11830,43 @@ snapshots:
chalk: 4.1.2
js-yaml: 4.2.0
+ '@ff-labs/[email protected]':
+ optional: true
+
+ '@ff-labs/[email protected]':
+ optional: true
+
+ '@ff-labs/[email protected]':
+ optional: true
+
+ '@ff-labs/[email protected]':
+ optional: true
+
+ '@ff-labs/[email protected]':
+ optional: true
+
+ '@ff-labs/[email protected]':
+ optional: true
+
+ '@ff-labs/[email protected]':
+ optional: true
+
+ '@ff-labs/[email protected]':
+ optional: true
+
+ '@ff-labs/[email protected]':
+ dependencies:
+ ffi-rs: 1.3.2
+ optionalDependencies:
+ '@ff-labs/fff-bin-darwin-arm64': 0.9.4
+ '@ff-labs/fff-bin-darwin-x64': 0.9.4
+ '@ff-labs/fff-bin-linux-arm64-gnu': 0.9.4
+ '@ff-labs/fff-bin-linux-arm64-musl': 0.9.4
+ '@ff-labs/fff-bin-linux-x64-gnu': 0.9.4
+ '@ff-labs/fff-bin-linux-x64-musl': 0.9.4
+ '@ff-labs/fff-bin-win32-arm64': 0.9.4
+ '@ff-labs/fff-bin-win32-x64': 0.9.4
+
'@floating-ui/[email protected]':
dependencies:
'@floating-ui/utils': 0.2.11
@@ -13938,6 +14093,39 @@ snapshots:
'@xterm/[email protected]': {}
+ '@yuuang/[email protected]':
+ optional: true
+
+ '@yuuang/[email protected]':
+ optional: true
+
+ '@yuuang/[email protected]':
+ optional: true
+
+ '@yuuang/[email protected]':
+ optional: true
+
+ '@yuuang/[email protected]':
+ optional: true
+
+ '@yuuang/[email protected]':
+ optional: true
+
+ '@yuuang/[email protected]':
+ optional: true
+
+ '@yuuang/[email protected]':
+ optional: true
+
+ '@yuuang/[email protected]':
+ optional: true
+
+ '@yuuang/[email protected]':
+ optional: true
+
+ '@yuuang/[email protected]':
+ optional: true
+
'@zxcvbn-ts/[email protected]':
dependencies:
fastest-levenshtein: 1.0.16
@@ -15732,6 +15920,20 @@ snapshots:
+ optionalDependencies:
+ '@yuuang/ffi-rs-android-arm64': 1.3.2
+ '@yuuang/ffi-rs-darwin-arm64': 1.3.2
+ '@yuuang/ffi-rs-darwin-x64': 1.3.2
+ '@yuuang/ffi-rs-linux-arm-gnueabihf': 1.3.2
+ '@yuuang/ffi-rs-linux-arm64-gnu': 1.3.2
+ '@yuuang/ffi-rs-linux-arm64-musl': 1.3.2
+ '@yuuang/ffi-rs-linux-x64-gnu': 1.3.2
+ '@yuuang/ffi-rs-linux-x64-musl': 1.3.2
+ '@yuuang/ffi-rs-win32-arm64-msvc': 1.3.2
+ '@yuuang/ffi-rs-win32-ia32-msvc': 1.3.2
+ '@yuuang/ffi-rs-win32-x64-msvc': 1.3.2
+
dependencies:
minimatch: 5.1.9