From f5a7ae85863c2874cc25e28c0cd9e2be89e31331 Mon Sep 17 00:00:00 2001 From: Taylor Dolezal <117500+onlydole@users.noreply.github.com> Date: Mon, 2 Nov 2026 16:21:39 -0800 Subject: [PATCH 1/2] perf(server): Claude skill discovery resolves each repository root once Every Claude turn start, steer and provider refresh resolved the repository root of each project-scoped plugin install record, and many records share a project path. Cache the result per path for one discovery, and stop writing a span for each lookup. Co-Authored-By: Claude Opus 5.5 --- .../src/provider/Drivers/ClaudeSkills.test.ts | 44 +++++++++++++++++++ .../src/provider/Drivers/ClaudeSkills.ts | 19 +++++--- 2 files changed, 56 insertions(+), 7 deletions(-) diff --git a/apps/server/src/provider/Drivers/ClaudeSkills.test.ts b/apps/server/src/provider/Drivers/ClaudeSkills.test.ts index 860280aa91e89..3ed8dea758e55 100644 --- a/apps/server/src/provider/Drivers/ClaudeSkills.test.ts +++ b/apps/server/src/provider/Drivers/ClaudeSkills.test.ts @@ -209,6 +209,50 @@ it.layer(NodeServices.layer)("discoverClaudeSkills", (it) => { }), ); + it.effect("resolves each install record's project repository once per discovery", () => + Effect.gen(function* () { + const fs = yield* FileSystem.FileSystem; + const path = yield* Path.Path; + const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" }); + const configDir = path.join(tempDir, "claude-home"); + const workspace = path.join(tempDir, "workspace"); + const otherProject = path.join(tempDir, "other", "packages", "app"); + yield* fs.makeDirectory(path.join(workspace, ".git"), { recursive: true }); + yield* fs.makeDirectory(path.join(tempDir, "other", ".git"), { recursive: true }); + yield* fs.makeDirectory(otherProject, { recursive: true }); + const records = Array.from({ length: 4 }, () => ({ + scope: "project", + projectPath: otherProject, + installPath: path.join(configDir, "plugins", "elsewhere"), + })); + const plugins = ["a@shop", "b@shop", "c@shop"]; + yield* fs.makeDirectory(path.join(configDir, "plugins"), { recursive: true }); + yield* fs.writeFileString( + path.join(configDir, "plugins", "installed_plugins.json"), + JSON.stringify({ plugins: Object.fromEntries(plugins.map((key) => [key, records])) }), + ); + yield* fs.writeFileString( + path.join(configDir, "settings.json"), + JSON.stringify({ enabledPlugins: Object.fromEntries(plugins.map((key) => [key, true])) }), + ); + + const probed: Array = []; + yield* discoverClaudeSkills({ homePath: configDir }, workspace).pipe( + Effect.provideService(FileSystem.FileSystem, { + ...fs, + exists: (target) => { + probed.push(target); + return fs.exists(target); + }, + }), + ); + assert.strictEqual( + probed.filter((target) => target === path.join(otherProject, ".git")).length, + 1, + ); + }), + ); + it.effect("publishes and dispatches canonical plugin folder names regardless of aliases", () => Effect.gen(function* () { const fs = yield* FileSystem.FileSystem; diff --git a/apps/server/src/provider/Drivers/ClaudeSkills.ts b/apps/server/src/provider/Drivers/ClaudeSkills.ts index c73385374fbc0..2bcf9ca472f0c 100644 --- a/apps/server/src/provider/Drivers/ClaudeSkills.ts +++ b/apps/server/src/provider/Drivers/ClaudeSkills.ts @@ -143,7 +143,8 @@ function claudeSettingsPaths( ]; } -const findRepositoryRoot = Effect.fn("findRepositoryRoot")(function* ( +// Untraced: skill discovery resolves every distinct plugin project path, too often for spans. +const findRepositoryRoot = Effect.fnUntraced(function* ( cwd: string, ): Effect.fn.Return { const fileSystem = yield* FileSystem.FileSystem; @@ -164,7 +165,7 @@ const findRepositoryRoot = Effect.fn("findRepositoryRoot")(function* ( } }); -const findPluginRepositoryRoot = Effect.fn("findPluginRepositoryRoot")(function* (cwd: string) { +const findPluginRepositoryRoot = Effect.fnUntraced(function* (cwd: string) { const fileSystem = yield* FileSystem.FileSystem; const path = yield* Path.Path; const root = yield* findRepositoryRoot(cwd); @@ -336,6 +337,8 @@ const discoverPluginSkillRoots = Effect.fn("discoverPluginSkillRoots")(function* cwd === undefined ? undefined : yield* fileSystem.realPath(cwd).pipe(Effect.orElseSucceed(() => path.resolve(cwd))); + // Install records repeat project paths, often hundreds of times per discovery. + const projectRepositoryRoots = new Map(); const repositoryRoot = workspace === undefined ? undefined : yield* findPluginRepositoryRoot(workspace); @@ -347,11 +350,13 @@ const discoverPluginSkillRoots = Effect.fn("discoverPluginSkillRoots")(function* Effect.gen(function* () { if (record.scope === "user" || record.scope === "managed") return true; if (record.projectPath === undefined || workspace === undefined) return false; - if (path.resolve(record.projectPath) === workspace) return true; - return ( - repositoryRoot !== undefined && - (yield* findPluginRepositoryRoot(record.projectPath)) === repositoryRoot - ); + const projectPath = path.resolve(record.projectPath); + if (projectPath === workspace) return true; + if (repositoryRoot === undefined) return false; + if (!projectRepositoryRoots.has(projectPath)) { + projectRepositoryRoots.set(projectPath, yield* findPluginRepositoryRoot(projectPath)); + } + return projectRepositoryRoots.get(projectPath) === repositoryRoot; }), ); // The native loader keeps registry order, preferring the first install that exists. From f3ae461c3f1cd1ed482d8b78460715ec99b8faa3 Mon Sep 17 00:00:00 2001 From: Taylor Dolezal <117500+onlydole@users.noreply.github.com> Date: Mon, 2 Nov 2026 16:38:04 -0800 Subject: [PATCH 2/2] test(server): skill discovery cache keeps separate repository roots Extends the repository-root cache test with a plugin installed for a project inside the workspace repository. Discovery must still include it while excluding the plugin for another repository, so one cached root can't stand in for another project's. The test resolves its temp directory so it also passes behind macOS's /var symlink. Co-Authored-By: Claude Opus 5.5 --- .../src/provider/Drivers/ClaudeSkills.test.ts | 33 +++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/apps/server/src/provider/Drivers/ClaudeSkills.test.ts b/apps/server/src/provider/Drivers/ClaudeSkills.test.ts index 3ed8dea758e55..b4ce31cac866c 100644 --- a/apps/server/src/provider/Drivers/ClaudeSkills.test.ts +++ b/apps/server/src/provider/Drivers/ClaudeSkills.test.ts @@ -213,31 +213,48 @@ it.layer(NodeServices.layer)("discoverClaudeSkills", (it) => { Effect.gen(function* () { const fs = yield* FileSystem.FileSystem; const path = yield* Path.Path; - const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" }); + // Real path: macOS temp dirs sit behind a /var -> /private/var symlink. + const tempDir = yield* fs.realPath( + yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" }), + ); const configDir = path.join(tempDir, "claude-home"); const workspace = path.join(tempDir, "workspace"); const otherProject = path.join(tempDir, "other", "packages", "app"); + const sameRepoProject = path.join(workspace, "packages", "app"); yield* fs.makeDirectory(path.join(workspace, ".git"), { recursive: true }); yield* fs.makeDirectory(path.join(tempDir, "other", ".git"), { recursive: true }); yield* fs.makeDirectory(otherProject, { recursive: true }); + yield* fs.makeDirectory(sameRepoProject, { recursive: true }); + const elsewhereInstall = path.join(configDir, "plugins", "elsewhere"); + const sameRepoInstall = path.join(configDir, "plugins", "same-repo"); + yield* writeSkill(path.join(elsewhereInstall, "skills"), "elsewhere", "# Elsewhere"); + yield* writeSkill(path.join(sameRepoInstall, "skills"), "same-repo", "# Same repo"); const records = Array.from({ length: 4 }, () => ({ scope: "project", projectPath: otherProject, - installPath: path.join(configDir, "plugins", "elsewhere"), + installPath: elsewhereInstall, })); const plugins = ["a@shop", "b@shop", "c@shop"]; - yield* fs.makeDirectory(path.join(configDir, "plugins"), { recursive: true }); yield* fs.writeFileString( path.join(configDir, "plugins", "installed_plugins.json"), - JSON.stringify({ plugins: Object.fromEntries(plugins.map((key) => [key, records])) }), + JSON.stringify({ + plugins: { + ...Object.fromEntries(plugins.map((key) => [key, records])), + "d@shop": [ + { scope: "project", projectPath: sameRepoProject, installPath: sameRepoInstall }, + ], + }, + }), ); yield* fs.writeFileString( path.join(configDir, "settings.json"), - JSON.stringify({ enabledPlugins: Object.fromEntries(plugins.map((key) => [key, true])) }), + JSON.stringify({ + enabledPlugins: Object.fromEntries([...plugins, "d@shop"].map((key) => [key, true])), + }), ); const probed: Array = []; - yield* discoverClaudeSkills({ homePath: configDir }, workspace).pipe( + const skills = yield* discoverClaudeSkills({ homePath: configDir }, workspace).pipe( Effect.provideService(FileSystem.FileSystem, { ...fs, exists: (target) => { @@ -250,6 +267,10 @@ it.layer(NodeServices.layer)("discoverClaudeSkills", (it) => { probed.filter((target) => target === path.join(otherProject, ".git")).length, 1, ); + assert.deepEqual( + skills.map((skill) => skill.name), + ["d:same-repo"], + ); }), );