TypeScript
fix(claude): discover enabled installed plugin skills (#15662)
mariac2b127f8f110
diff --git a/apps/server/src/provider/Drivers/ClaudeSkills.test.ts b/apps/server/src/provider/Drivers/ClaudeSkills.test.tsindex d930984b9ab..ce304fbd373 100644--- a/apps/server/src/provider/Drivers/ClaudeSkills.test.ts+++ b/apps/server/src/provider/Drivers/ClaudeSkills.test.ts@@ -21,6 +21,276 @@ const writeSkill = Effect.fn(function* (});it.layer(NodeServices.layer)("discoverClaudeSkills", (it) => {+ it.effect("discovers enabled plugin skills with manifest names and ignores skill overrides", () =>+ 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 plugin = path.join(configDir, "plugins", "cache", "shop", "plugin", "1.0.0");+ const disabled = path.join(configDir, "plugins", "disabled");+ yield* writeSkill(path.join(disabled, "skills"), "hidden", "# Hidden");+ yield* writeSkill(path.join(plugin, "skills"), "plain", "# Plain");+ yield* writeSkill(+ path.join(plugin, "engineering"),+ "review",+ "---\nname: review-alias\ndescription: Review changes.\ndisable-model-invocation: true\nuser-invocable: false\n---\n",+ );+ yield* fs.makeDirectory(path.join(plugin, ".claude-plugin"), { recursive: true });+ yield* fs.writeFileString(+ path.join(plugin, ".claude-plugin", "plugin.json"),+ '{"name":"manifest-plugin","skills":["./engineering/review"]}',+ );+ yield* fs.writeFileString(+ path.join(configDir, "plugins", "installed_plugins.json"),+ JSON.stringify({+ plugins: {+ "plugin@shop": [{ scope: "user", installPath: plugin }],+ "disabled@shop": [{ scope: "user", installPath: disabled }],+ "unconfigured@shop": [{ scope: "user", installPath: disabled }],+ },+ }),+ );+ yield* fs.writeFileString(+ path.join(configDir, "settings.json"),+ '{"enabledPlugins":{"plugin@shop":true,"disabled@shop":false,"uninstalled@shop":true,"other@shop":["^1.0.0"]},"skillOverrides":{"manifest-plugin:plain":"off"}}',+ );++ const skills = yield* discoverClaudeSkills({ homePath: configDir });+ assert.deepEqual(skills, [+ {+ name: "manifest-plugin:plain",+ path: path.join(plugin, "skills", "plain", "SKILL.md"),+ enabled: true,+ scope: "user",+ },+ {+ name: "manifest-plugin:review-alias",+ path: path.join(plugin, "engineering", "review", "SKILL.md"),+ enabled: true,+ scope: "user",+ description: "Review changes.",+ userInvocationOnly: true,+ userInvocable: false,+ },+ ]);+ }),+ );++ it.effect("merges plugin enablement and selects installs in native registry order", () =>+ 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 nestedWorkspace = path.join(workspace, "packages", "app");+ const aliasedWorkspace = path.join(tempDir, "aliased-workspace");+ const userInstall = path.join(configDir, "plugins", "user");+ const projectInstall = path.join(configDir, "plugins", "project");+ const localInstall = path.join(configDir, "plugins", "local");+ const managedInstall = path.join(configDir, "plugins", "managed");+ yield* fs.makeDirectory(path.join(workspace, ".git"), { recursive: true });+ yield* fs.makeDirectory(nestedWorkspace, { recursive: true });+ yield* fs.symlink(workspace, aliasedWorkspace);+ for (const install of [userInstall, projectInstall, localInstall, managedInstall]) {+ yield* writeSkill(path.join(install, "skills"), "review", "# Review");+ }+ yield* fs.writeFileString(+ path.join(configDir, "plugins", "installed_plugins.json"),+ JSON.stringify({+ plugins: {+ "plugin@shop": [+ { scope: "project", projectPath: aliasedWorkspace, installPath: localInstall },+ { scope: "project", projectPath: workspace, installPath: projectInstall },+ { scope: "user", installPath: userInstall },+ { scope: "managed", installPath: managedInstall },+ ],+ "local@shop": [+ { scope: "local", projectPath: workspace, installPath: localInstall },+ { scope: "project", projectPath: workspace, installPath: projectInstall },+ { scope: "managed", installPath: path.join(configDir, "plugins", "missing") },+ { scope: "managed", installPath: managedInstall },+ { scope: "user", installPath: userInstall },+ ],+ },+ }),+ );+ yield* fs.writeFileString(+ path.join(configDir, "settings.json"),+ '{"enabledPlugins":{"plugin@shop":true,"local@shop":false}}',+ );+ yield* fs.makeDirectory(path.join(workspace, ".claude"), { recursive: true });+ yield* fs.writeFileString(+ path.join(workspace, ".claude", "settings.json"),+ '{"enabledPlugins":{"plugin@shop":false,"local@shop":true,"other@shop":["^1.0.0"]}}',+ );+ const projectSettings = yield* discoverClaudeSkills({ homePath: configDir }, workspace);+ assert.deepEqual(+ projectSettings.map((skill) => [skill.name, skill.scope, skill.path]),+ [["local:review", "project", path.join(localInstall, "skills", "review", "SKILL.md")]],+ );+ assert.deepEqual(+ (yield* discoverClaudeSkills({ homePath: configDir }, nestedWorkspace)).map((skill) => [+ skill.name,+ skill.scope,+ skill.path,+ ]),+ [["plugin:review", "project", path.join(projectInstall, "skills", "review", "SKILL.md")]],+ );+ yield* fs.writeFileString(+ path.join(workspace, ".claude", "settings.local.json"),+ '{"enabledPlugins":{"plugin@shop":true,"local@shop":false},"skillOverrides":{"invalid":"bogus"}}',+ );+ assert.deepEqual(+ yield* discoverClaudeSkills({ homePath: configDir }, workspace),+ projectSettings,+ );+ yield* fs.writeFileString(+ path.join(workspace, ".claude", "settings.local.json"),+ '{"enabledPlugins":{"plugin@shop":true,"local@shop":true}}',+ );+ const localSettings = yield* discoverClaudeSkills({ homePath: configDir }, workspace);+ assert.deepEqual(+ localSettings.map((skill) => [skill.name, skill.scope, skill.path]),+ [+ ["local:review", "project", path.join(localInstall, "skills", "review", "SKILL.md")],+ ["plugin:review", "project", path.join(projectInstall, "skills", "review", "SKILL.md")],+ ],+ );+ assert.deepEqual(+ yield* discoverClaudeSkills({ homePath: configDir }, nestedWorkspace),+ localSettings,+ );+ assert.deepEqual(+ yield* discoverClaudeSkills({ homePath: configDir }, aliasedWorkspace),+ localSettings,+ );+ yield* fs.writeFileString(+ path.join(workspace, ".claude", "settings.local.json"),+ '{"enabledPlugins":{"local@shop":["^1.0.0"]}}',+ );+ assert.deepEqual(yield* discoverClaudeSkills({ homePath: configDir }, workspace), []);+ yield* fs.writeFileString(+ path.join(configDir, "settings.json"),+ '{"enabledPlugins":{"plugin@shop":true,"local@shop":true}}',+ );+ const separateRepository = path.join(workspace, "separate");+ yield* fs.makeDirectory(path.join(separateRepository, ".git"), { recursive: true });+ for (const cwd of [undefined, path.join(tempDir, "elsewhere"), separateRepository]) {+ const elsewhere = yield* discoverClaudeSkills({ homePath: configDir }, cwd);+ assert.deepEqual(+ elsewhere.map((skill) => [skill.name, skill.scope, skill.path]),+ [+ ["local:review", "user", path.join(managedInstall, "skills", "review", "SKILL.md")],+ ["plugin:review", "user", path.join(userInstall, "skills", "review", "SKILL.md")],+ ],+ );+ }+ const worktree = path.join(tempDir, "worktree");+ const worktreeGitDirectory = path.join(workspace, ".git", "worktrees", "fixture");+ yield* fs.makeDirectory(worktree);+ yield* fs.makeDirectory(worktreeGitDirectory, { recursive: true });+ yield* fs.writeFileString(path.join(worktree, ".git"), `gitdir: ${worktreeGitDirectory}\n`);+ yield* fs.writeFileString(path.join(worktreeGitDirectory, "commondir"), "../..\n");+ yield* fs.writeFileString(+ path.join(worktreeGitDirectory, "gitdir"),+ path.join(worktree, ".git"),+ );+ assert.deepEqual(+ yield* discoverClaudeSkills({ homePath: configDir }, worktree),+ localSettings,+ );+ const linkedWorktree = path.join(tempDir, "linked-worktree");+ yield* fs.symlink(worktree, linkedWorktree);+ assert.deepEqual(+ yield* discoverClaudeSkills({ homePath: configDir }, linkedWorktree),+ localSettings,+ );+ }),+ );++ it.effect("publishes and dispatches canonical plugin folder names regardless of aliases", () =>+ Effect.gen(function* () {+ const fs = yield* FileSystem.FileSystem;+ const path = yield* Path.Path;+ const configDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" });+ const plugin = path.join(configDir, "plugins", "installed");+ yield* writeSkill(path.join(plugin, "skills"), "review", "---\nname: review-alias\n---\n");+ yield* writeSkill(path.join(plugin, "skills"), "alias", "---\nname: dot.alias\n---\n");+ yield* fs.writeFileString(+ path.join(configDir, "plugins", "installed_plugins.json"),+ JSON.stringify({ plugins: { "plugin@shop": [{ scope: "user", installPath: plugin }] } }),+ );+ yield* fs.writeFileString(+ path.join(configDir, "settings.json"),+ '{"enabledPlugins":{"plugin@shop":true}}',+ );++ const skills = yield* discoverClaudeSkills({ homePath: configDir });+ assert.deepEqual(+ planClaudeSkillDispatch(+ "$plugin:alias focus on auth",+ new Map(skills.map((skill) => [skill.name, skill])),+ ),+ {+ leadingText: undefined,+ commandText: "/plugin:alias focus on auth",+ skillName: "plugin:alias",+ },+ );+ assert.deepEqual(+ skills.map((skill) => skill.name),+ ["plugin:alias", "plugin:review"],+ );+ }),+ );++ it.effect("uses the native cache root, root-skill fallback and manifest path boundaries", () =>+ Effect.gen(function* () {+ const fs = yield* FileSystem.FileSystem;+ const path = yield* Path.Path;+ const workspace = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skills-" });+ const configDir = path.join(workspace, "config");+ const pluginsDir = path.join(workspace, "plugin-cache");+ const plugin = path.join(pluginsDir, "installed");+ const outside = path.join(workspace, "outside");+ yield* writeSkill(pluginsDir, "installed", "---\nname: plugin:root.alias\n---\n");+ yield* fs.makeDirectory(configDir);+ yield* fs.writeFileString(+ path.join(configDir, "settings.json"),+ '{"enabledPlugins":{"plugin@shop":true}}',+ );+ yield* fs.writeFileString(+ path.join(pluginsDir, "installed_plugins.json"),+ JSON.stringify({ plugins: { "plugin@shop": [{ scope: "user", installPath: plugin }] } }),+ );+ const environment = { CLAUDE_CODE_PLUGIN_CACHE_DIR: "plugin-cache" };+ assert.deepEqual(+ (yield* discoverClaudeSkills({ homePath: configDir }, workspace, environment)).map(+ (skill) => skill.name,+ ),+ ["plugin:root-alias"],+ );++ yield* writeSkill(path.join(plugin, "skills"), "plain", "# Plain");+ yield* writeSkill(plugin, "custom", "---\nname: custom.review\n---\n");+ yield* writeSkill(outside, "escaped", "# Outside");+ yield* fs.symlink(outside, path.join(plugin, "escape"));+ yield* fs.makeDirectory(path.join(plugin, ".claude-plugin"));+ yield* fs.writeFileString(+ path.join(plugin, ".claude-plugin", "plugin.json"),+ '{"skills":["./custom","./escape","../../outside"]}',+ );+ assert.deepEqual(+ (yield* discoverClaudeSkills({ homePath: configDir }, workspace, environment)).map(+ (skill) => skill.name,+ ),+ ["plugin:custom-review", "plugin:plain"],+ );+ }),+ );+it.effect("discovers user and project skills with frontmatter metadata", () =>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.tsindex 9828dafe452..b63a0fb48b4 100644--- a/apps/server/src/provider/Drivers/ClaudeSkills.ts+++ b/apps/server/src/provider/Drivers/ClaudeSkills.ts@@ -2,16 +2,24 @@ import type { ClaudeSettings, ServerProviderSkill } from "@t3tools/contracts";import * as Effect from "effect/Effect";import * as FileSystem from "effect/FileSystem";import * as Path from "effect/Path";+import * as Option from "effect/Option";import * as Schema from "effect/Schema";import * as HostProcess from "@t3tools/shared/HostProcess";import { parseCliArgs } from "@t3tools/shared/cliArgs";import { fromLenientJson } from "@t3tools/shared/schemaJson";+import { SKILL_MENTION_PATTERN } from "@t3tools/shared/composerInlineTokens";import { parse as parseYamlDocument } from "yaml";import { expandHomePath } from "@t3tools/provider-core/server/pathExpansion";type ClaudeSkillScope = "user" | "project";+type ClaudeSkillRoot = {+ readonly directory: string;+ readonly scope: ClaudeSkillScope;+ readonly prefix?: string;+};+const FRONTMATTER_PATTERN = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/;type SkillFrontmatter =@@ -19,6 +27,7 @@ type SkillFrontmatter =| { readonly kind: "malformed" }| {readonly kind: "parsed";+ readonly name?: string;readonly description?: string;readonly userInvocationOnly?: boolean;readonly userInvocable?: boolean;@@ -85,9 +94,11 @@ function parseSkillFrontmatter(contents: string): SkillFrontmatter {}const record = parsed as Record<string, unknown>;+ const name = typeof record.name === "string" ? record.name.trim() : "";const description = typeof record.description === "string" ? record.description.trim() : "";return {kind: "parsed",+ ...(name ? { name } : {}),...(description ? { description } : {}),...(parseFrontmatterBoolean(record["disable-model-invocation"]) === true? { userInvocationOnly: true }@@ -157,6 +168,43 @@ const findRepositoryRoot = Effect.fn("findRepositoryRoot")(function* (}});+const findPluginRepositoryRoot = Effect.fn("findPluginRepositoryRoot")(function* (cwd: string) {+ const fileSystem = yield* FileSystem.FileSystem;+ const path = yield* Path.Path;+ const root = yield* findRepositoryRoot(cwd);+ if (root === undefined) return undefined;+ const gitFile = yield* fileSystem+ .readFileString(path.join(root, ".git"))+ .pipe(Effect.orElseSucceed(() => ""));+ if (!gitFile.trim().startsWith("gitdir:")) return root;+ const gitDirectory = path.resolve(root, gitFile.trim().slice(7).trim());+ const commonFile = yield* fileSystem+ .readFileString(path.join(gitDirectory, "commondir"))+ .pipe(Effect.orElseSucceed(() => ""));+ const worktreeFile = yield* fileSystem+ .readFileString(path.join(gitDirectory, "gitdir"))+ .pipe(Effect.orElseSucceed(() => ""));+ if (!commonFile.trim() || !worktreeFile.trim()) return root;+ const commonDirectory = path.resolve(gitDirectory, commonFile.trim());+ const backlinkPath = yield* fileSystem+ .realPath(path.resolve(gitDirectory, worktreeFile.trim()))+ .pipe(Effect.orElseSucceed(() => undefined));+ const worktreeGitPath = yield* fileSystem+ .realPath(path.join(root, ".git"))+ .pipe(Effect.orElseSucceed(() => undefined));+ if (+ path.dirname(gitDirectory) !== path.join(commonDirectory, "worktrees") ||+ backlinkPath === undefined ||+ backlinkPath !== worktreeGitPath+ ) {+ return root;+ }+ // Claude shares plugin install records across linked worktrees, using their common repository.+ return path.basename(commonDirectory) === ".git"+ ? path.dirname(commonDirectory)+ : commonDirectory;+});+/*** The CLI validates the whole map, not each entry: verified against it, one* entry with an unknown value (or a boolean) makes it drop every override in@@ -167,12 +215,13 @@ const SkillOverrideValue = Schema.Literals(["on", "name-only", "user-invocable-o// Lenient because these settings files are hand-edited and Claude Code itself// tolerates comments and trailing commas in them.-const SkillOverrideSettings = fromLenientJson(+const SkillSettings = fromLenientJson(Schema.Struct({skillOverrides: Schema.optional(Schema.Record(Schema.String, SkillOverrideValue)),+ enabledPlugins: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)),}),);-const decodeSkillOverrideSettings = Schema.decodeUnknownEffect(SkillOverrideSettings);+const decodeSkillSettings = Schema.decodeUnknownEffect(SkillSettings);type SkillOverride = {readonly enabled: boolean;@@ -191,15 +240,16 @@ function parseSkillOverride(value: typeof SkillOverrideValue.Type): SkillOverrid}}-const readSkillOverrides = Effect.fn("readSkillOverrides")(function* (+const readSkillSettings = Effect.fn("readSkillSettings")(function* (configDirPath: string,cwd: string | undefined,environment: NodeJS.ProcessEnv,-): Effect.fn.Return<ReadonlyMap<string, SkillOverride>, never, FileSystem.FileSystem | Path.Path> {+) {const fileSystem = yield* FileSystem.FileSystem;const path = yield* Path.Path;const platform = yield* HostProcess.Platform;const overridesByName = new Map<string, SkillOverride>();+ const enabledPlugins = new Map<string, boolean>();const repositoryRoot = cwd === undefined ? undefined : yield* findRepositoryRoot(cwd);for (const settingsPath of skillOverrideSettingsPaths(@@ -217,26 +267,150 @@ const readSkillOverrides = Effect.fn("readSkillOverrides")(function* (continue;}- const parsed = yield* decodeSkillOverrideSettings(contents).pipe(+ const parsed = yield* decodeSkillSettings(contents).pipe(Effect.tapError((cause) =>- Effect.logDebug("claude settings file is unreadable; ignoring skillOverrides", {+ Effect.logDebug("claude settings file is unreadable; ignoring skill settings", {path: settingsPath,cause,}),),Effect.orElseSucceed(() => undefined),);- const overrides = parsed?.skillOverrides;- if (!overrides) {- continue;- }-- for (const [name, value] of Object.entries(overrides)) {+ for (const [name, value] of Object.entries(parsed?.skillOverrides ?? {})) {overridesByName.set(name, parseSkillOverride(value));}+ for (const [key, enabled] of Object.entries(parsed?.enabledPlugins ?? {})) {+ if (typeof enabled === "boolean") {+ enabledPlugins.set(key, enabled);+ } else {+ // Extended formats replace lower-precedence values without enabling the plugin here.+ enabledPlugins.delete(key);+ }+ }}- return overridesByName;+ return { skillOverrides: overridesByName, enabledPlugins };+});++const InstalledPlugins = Schema.fromJsonString(+ Schema.Struct({ plugins: Schema.Record(Schema.String, Schema.Array(Schema.Unknown)) }),+);+const decodeInstalledPlugin = Schema.decodeUnknownOption(+ Schema.Struct({+ scope: Schema.Literals(["user", "project", "local", "managed"]),+ installPath: Schema.NonEmptyString,+ projectPath: Schema.optional(Schema.NonEmptyString),+ }),+);+const PluginManifest = Schema.fromJsonString(+ Schema.Struct({+ name: Schema.optional(Schema.NonEmptyString),+ skills: Schema.optional(Schema.Union([Schema.String, Schema.Array(Schema.String)])),+ }),+);++function isInsideDirectory(path: Path.Path, directory: string, candidate: string): boolean {+ const relative = path.relative(directory, candidate);+ return relative !== ".." && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative);+}++const discoverPluginSkillRoots = Effect.fn("discoverPluginSkillRoots")(function* (+ configDirPath: string,+ cwd: string | undefined,+ enabledPlugins: ReadonlyMap<string, boolean>,+ environment: NodeJS.ProcessEnv,+) {+ const fileSystem = yield* FileSystem.FileSystem;+ const path = yield* Path.Path;+ const home = yield* HostProcess.HomeDirectory;+ const pluginDirectory = environment.CLAUDE_CODE_PLUGIN_CACHE_DIR;+ const pluginsPath = pluginDirectory+ ? path.resolve(cwd ?? ".", expandHomePath(pluginDirectory, home))+ : path.join(configDirPath, "plugins");+ const installed = yield* fileSystem+ .readFileString(path.join(pluginsPath, "installed_plugins.json"))+ .pipe(+ Effect.flatMap(Schema.decodeUnknownEffect(InstalledPlugins)),+ Effect.orElseSucceed(() => undefined),+ );+ if (installed === undefined) return [];+ const roots: Array<ClaudeSkillRoot> = [];+ // The CLI's process.cwd() resolves symlinks; registry projectPath values remain lexical.+ const workspace =+ cwd === undefined+ ? undefined+ : yield* fileSystem.realPath(cwd).pipe(Effect.orElseSucceed(() => path.resolve(cwd)));+ const repositoryRoot =+ workspace === undefined ? undefined : yield* findPluginRepositoryRoot(workspace);++ for (const [key, entries] of Object.entries(installed.plugins).sort()) {+ if (enabledPlugins.get(key) !== true) continue;+ const applicable = yield* Effect.filter(+ entries.flatMap((entry) => Option.toArray(decodeInstalledPlugin(entry))),+ (record) =>+ 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+ );+ }),+ );+ // The native loader keeps registry order, preferring the first install that exists.+ const existing = yield* Effect.findFirst(applicable, (record) =>+ fileSystem+ .exists(path.resolve(cwd ?? ".", record.installPath))+ .pipe(Effect.orElseSucceed(() => false)),+ );+ const install = Option.getOrElse(existing, () => applicable[0]);+ if (!install) continue;+ const scope = install.scope === "user" || install.scope === "managed" ? "user" : "project";+ const installPath = path.resolve(cwd ?? ".", install.installPath);+ const manifest = yield* fileSystem+ .readFileString(path.join(installPath, ".claude-plugin", "plugin.json"))+ .pipe(+ Effect.flatMap(Schema.decodeUnknownEffect(PluginManifest)),+ Effect.orElseSucceed(() => undefined),+ );+ const prefix = manifest?.name ?? key.split("@")[0];+ if (!prefix) continue;++ const defaultDirectory = path.join(installPath, "skills");+ const hasDefaultDirectory = yield* fileSystem+ .exists(defaultDirectory)+ .pipe(Effect.orElseSucceed(() => false));+ if (hasDefaultDirectory) roots.push({ directory: defaultDirectory, scope, prefix });+ const declared = manifest?.skills;+ if (declared === undefined && !hasDefaultDirectory) {+ const hasRootSkill = yield* fileSystem+ .exists(path.join(installPath, "SKILL.md"))+ .pipe(Effect.orElseSucceed(() => false));+ if (hasRootSkill) roots.push({ directory: installPath, scope, prefix });+ }++ const canonicalInstallPath = yield* fileSystem+ .realPath(installPath)+ .pipe(Effect.orElseSucceed(() => undefined));+ for (const relative of typeof declared === "string" ? [declared] : (declared ?? [])) {+ const directory = path.resolve(installPath, relative);+ if (!isInsideDirectory(path, installPath, directory) || canonicalInstallPath === undefined) {+ continue;+ }+ const canonicalDirectory = yield* fileSystem+ .realPath(directory)+ .pipe(Effect.orElseSucceed(() => undefined));+ // The native loader rejects manifest roots that escape through a symlink, too.+ if (+ canonicalDirectory !== undefined &&+ isInsideDirectory(path, canonicalInstallPath, canonicalDirectory)+ ) {+ roots.push({ directory, scope, prefix });+ }+ }+ }+ return roots;});const resolveClaudeConfigDirPath = Effect.fn("resolveClaudeConfigDirPath")(function* (@@ -275,11 +449,15 @@ export const discoverClaudeSkills = Effect.fn("discoverClaudeSkills")(function*const fileSystem = yield* FileSystem.FileSystem;const path = yield* Path.Path;const configDirPath = yield* resolveClaudeConfigDirPath(config, environment ?? process.env, cwd);- const skillOverrides = yield* readSkillOverrides(configDirPath, cwd, environment ?? process.env);+ const { skillOverrides, enabledPlugins } = yield* readSkillSettings(+ configDirPath,+ cwd,+ environment ?? process.env,+ );// Use the session's argument parser so discovery sees the same --add-dir value.const additionalDirectory = parseCliArgs(config.launchArgs ?? "").flags["add-dir"];- const roots: ReadonlyArray<{ directory: string; scope: ClaudeSkillScope }> = [+ const roots: ReadonlyArray<ClaudeSkillRoot> = [{ directory: path.join(configDirPath, "skills"), scope: "user" },...(cwd ? [{ directory: path.join(cwd, ".claude", "skills"), scope: "project" as const }] : []),...(additionalDirectory && (cwd || path.isAbsolute(additionalDirectory))@@ -294,16 +472,31 @@ export const discoverClaudeSkills = Effect.fn("discoverClaudeSkills")(function*},]: []),+ ...(yield* discoverPluginSkillRoots(+ configDirPath,+ cwd,+ enabledPlugins,+ environment ?? process.env,+ )),];const skillsByName = new Map<string, ServerProviderSkill>();for (const root of roots) {- const entries = yield* fileSystem- .readDirectory(root.directory)- .pipe(Effect.orElseSucceed((): ReadonlyArray<string> => []));+ const singleSkill =+ root.prefix !== undefined &&+ (yield* fileSystem+ .exists(path.join(root.directory, "SKILL.md"))+ .pipe(Effect.orElseSucceed(() => false)));+ const entries = singleSkill+ ? [path.basename(root.directory)]+ : yield* fileSystem+ .readDirectory(root.directory)+ .pipe(Effect.orElseSucceed((): ReadonlyArray<string> => []));for (const entry of [...entries].sort()) {- const skillPath = path.join(root.directory, entry, "SKILL.md");+ const skillPath = singleSkill+ ? path.join(root.directory, "SKILL.md")+ : path.join(root.directory, entry, "SKILL.md");const contents = yield* fileSystem.readFileString(skillPath).pipe(Effect.orElseSucceed(() => undefined));@@ -316,22 +509,26 @@ export const discoverClaudeSkills = Effect.fn("discoverClaudeSkills")(function*continue;}- // Claude Code identifies a skill by its directory, not by the- // frontmatter `name`: verified against the CLI, a skill in `probe-alias/`- // declaring `name: probe-alias-frontmatter` is published as- // `probe-alias`, and only `skillOverrides["probe-alias"]` switches it- // off. Keying off the frontmatter name would report a command that does- // not exist and miss the override that disables it.- const name = entry.trim();- if (!name) {- continue;+ const directoryName = entry.trim();+ if (!directoryName) continue;+ let name = directoryName;+ if (root.prefix) {+ // Native folder skills use their folder; only a single SKILL.md uses its name field.+ const declaredName = singleSkill && frontmatter.kind === "parsed" ? frontmatter.name : "";+ const unprefixedName = declaredName?.startsWith(`${root.prefix}:`)+ ? declaredName.slice(root.prefix.length + 1)+ : declaredName;+ name = `${root.prefix}:${(unprefixedName || entry).replace(/[^a-zA-Z0-9_-]/g, "-")}`;+ // Advertise only exact native names the shared composer grammar can invoke.+ const [mention] = `$${name}`.matchAll(SKILL_MENTION_PATTERN);+ if (mention?.[2] !== name) continue;}if (skillsByName.has(name)) {continue;}- const override = skillOverrides.get(name);+ const override = root.prefix ? undefined : skillOverrides.get(name);const userInvocationOnly =(frontmatter.kind === "parsed" && frontmatter.userInvocationOnly === true) ||override?.userInvocationOnly === true;diff --git a/docs/user/providers-claude.md b/docs/user/providers-claude.mdindex 514673beb26..a569c5b8f39 100644--- a/docs/user/providers-claude.md+++ b/docs/user/providers-claude.md@@ -71,7 +71,8 @@ Claude skills come from the config directory's `skills` folder and the project's`.claude/skills` folder. If both define the same name, the config-directory copywins. Skills disabled in Claude's settings do not appear in the composer.-Use `$` in the composer to select a skill. Skills marked `disable-model-invocation`+Use `$` in the composer to select a skill. Enabled installed Claude plugins also+contribute skills under names such as `plugin:review`. Skills marked `disable-model-invocation`can still be started by you. Invoke those one per message: Claude directly runsonly the last named skill and may try to start earlier ones through its Skilltool, which refuses skills reserved for manual invocation.