Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

ClaudeSkills.ts

596 lines22.2 KB

1import type { ClaudeSettings, ServerProviderSkill } from "@t3tools/contracts";
2import * as Effect from "effect/Effect";
3import * as FileSystem from "effect/FileSystem";
4import * as Path from "effect/Path";
5import * as Option from "effect/Option";
6import * as Schema from "effect/Schema";
7import * as HostProcess from "@t3tools/shared/HostProcess";
8import { tokenizeCliArgs } from "@t3tools/shared/cliArgs";
9import { fromLenientJson } from "@t3tools/shared/schemaJson";
10import { SKILL_MENTION_PATTERN } from "@t3tools/shared/composerInlineTokens";
11import { parse as parseYamlDocument } from "yaml";
12​
13import { expandHomePath } from "@t3tools/provider-core/server/pathExpansion";
14​
15type ClaudeSkillScope = "user" | "project";
16​
17type ClaudeSkillRoot = {
18 readonly directory: string;
19 readonly scope: ClaudeSkillScope;
20 readonly prefix?: string;
21};
22​
23const FRONTMATTER_PATTERN = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/;
24​
25type SkillFrontmatter =
26 | { readonly kind: "missing" }
27 | { readonly kind: "malformed" }
28 | {
29 readonly kind: "parsed";
30 readonly name?: string;
31 readonly description?: string;
32 readonly userInvocationOnly?: boolean;
33 readonly userInvocable?: boolean;
34 };
35​
36/** Claude accepts YAML 1.1 booleans that this YAML 1.2 parser leaves as strings or numbers. */
37function parseFrontmatterBoolean(value: unknown): boolean | undefined {
38 if (typeof value === "boolean") return value;
39 if (typeof value === "number") {
40 return value === 1 ? true : value === 0 ? false : undefined;
41 }
42 if (typeof value !== "string") return undefined;
43 switch (value.trim().toLowerCase()) {
44 case "true":
45 case "yes":
46 case "on":
47 case "y":
48 return true;
49 case "false":
50 case "no":
51 case "off":
52 case "n":
53 return false;
54 default:
55 return undefined;
56 }
58​
59function parseSkillFrontmatter(contents: string): SkillFrontmatter {
60 const match = FRONTMATTER_PATTERN.exec(contents);
61 if (!match) {
62 return { kind: "missing" };
63 }
64​
65 const frontmatter = match[1] ?? "";
66 let parsed: unknown;
67 try {
68 parsed = parseYamlDocument(frontmatter);
69 } catch {
70 // Repair Claude's accepted ': ' scalars without disturbing comments or YAML structure.
71 const repaired = frontmatter.replace(
72 /^([\w-]+:[ \t]*)([^\r\n]*)/gm,
73 (line, prefix: string, value: string) => {
74 const scalar = value.split(/[ \t]+#/)[0] ?? "";
75 if (!/:[ \t]/.test(scalar) || /^(?:["'[\]{}|>&*!#%@`]|[-?:](?:[ \t]|$))/.test(scalar)) {
76 return line;
77 }
78 return `${prefix}${JSON.stringify(scalar)}${value.slice(scalar.length)}`;
79 },
80 );
81 try {
82 parsed = parseYamlDocument(repaired);
83 } catch {
84 return { kind: "malformed" };
85 }
86 }
87 if (typeof parsed !== "object" || parsed === null) {
88 return { kind: "malformed" };
89 }
90​
91 const record = parsed as Record<string, unknown>;
92 const name = typeof record.name === "string" ? record.name.trim() : "";
93 const description = typeof record.description === "string" ? record.description.trim() : "";
94 return {
95 kind: "parsed",
96 ...(name ? { name } : {}),
97 ...(description ? { description } : {}),
98 ...(parseFrontmatterBoolean(record["disable-model-invocation"]) === true
99 ? { userInvocationOnly: true }
100 : {}),
101 ...(parseFrontmatterBoolean(record["user-invocable"]) === false
102 ? { userInvocable: false }
103 : {}),
104 };
106​
107function claudeManagedSettingsPath(
108 path: Path.Path,
109 platform: NodeJS.Platform,
110 environment: NodeJS.ProcessEnv,
111): string | undefined {
112 if (platform === "darwin") {
113 return "/Library/Application Support/ClaudeCode/managed-settings.json";
114 }
115 if (platform === "win32") {
116 const programData = environment.PROGRAMDATA?.trim();
117 return programData ? path.join(programData, "ClaudeCode", "managed-settings.json") : undefined;
118 }
119 return "/etc/claude-code/managed-settings.json";
121​
122/** Claude Code settings files, lowest precedence first. */
123function claudeSettingsPaths(
124 path: Path.Path,
125 configDirPath: string,
126 cwd: string | undefined,
127 platform: NodeJS.Platform,
128 environment: NodeJS.ProcessEnv,
129 repositoryRoot?: string,
130): ReadonlyArray<string> {
131 const managedPath = claudeManagedSettingsPath(path, platform, environment);
132 const root = repositoryRoot !== undefined && repositoryRoot !== cwd ? repositoryRoot : undefined;
133 return [
134 path.join(configDirPath, "settings.json"),
135 ...(cwd
136 ? [
137 path.join(cwd, ".claude", "settings.json"),
138 path.join(cwd, ".claude", "settings.local.json"),
139 ]
140 : []),
141 ...(root ? [path.join(root, ".claude", "settings.local.json")] : []),
142 ...(managedPath ? [managedPath] : []),
143 ];
145​
146// Untraced: skill discovery resolves every distinct plugin project path, too often for spans.
147const findRepositoryRoot = Effect.fnUntraced(function* (
148 cwd: string,
149): Effect.fn.Return<string | undefined, never, FileSystem.FileSystem | Path.Path> {
150 const fileSystem = yield* FileSystem.FileSystem;
151 const path = yield* Path.Path;
152 let current = path.resolve(cwd);
153 while (true) {
154 const isRoot = yield* fileSystem
155 .exists(path.join(current, ".git"))
156 .pipe(Effect.orElseSucceed(() => false));
157 if (isRoot) {
158 return current;
159 }
160 const parent = path.dirname(current);
161 if (parent === current) {
162 return undefined;
163 }
164 current = parent;
165 }
166});
167​
168const findPluginRepositoryRoot = Effect.fnUntraced(function* (cwd: string) {
169 const fileSystem = yield* FileSystem.FileSystem;
170 const path = yield* Path.Path;
171 const root = yield* findRepositoryRoot(cwd);
172 if (root === undefined) return undefined;
173 const gitFile = yield* fileSystem
174 .readFileString(path.join(root, ".git"))
175 .pipe(Effect.orElseSucceed(() => ""));
176 if (!gitFile.trim().startsWith("gitdir:")) return root;
177 const gitDirectory = path.resolve(root, gitFile.trim().slice(7).trim());
178 const commonFile = yield* fileSystem
179 .readFileString(path.join(gitDirectory, "commondir"))
180 .pipe(Effect.orElseSucceed(() => ""));
181 const worktreeFile = yield* fileSystem
182 .readFileString(path.join(gitDirectory, "gitdir"))
183 .pipe(Effect.orElseSucceed(() => ""));
184 if (!commonFile.trim() || !worktreeFile.trim()) return root;
185 const commonDirectory = path.resolve(gitDirectory, commonFile.trim());
186 const backlinkPath = yield* fileSystem
187 .realPath(path.resolve(gitDirectory, worktreeFile.trim()))
188 .pipe(Effect.orElseSucceed(() => undefined));
189 const worktreeGitPath = yield* fileSystem
190 .realPath(path.join(root, ".git"))
191 .pipe(Effect.orElseSucceed(() => undefined));
192 if (
193 path.dirname(gitDirectory) !== path.join(commonDirectory, "worktrees") ||
194 backlinkPath === undefined ||
195 backlinkPath !== worktreeGitPath
196 ) {
197 return root;
198 }
199 // Claude shares plugin install records across linked worktrees, using their common repository.
200 return path.basename(commonDirectory) === ".git"
201 ? path.dirname(commonDirectory)
202 : commonDirectory;
203});
204​
205/**
206 * The CLI validates the whole map, not each entry: verified against it, one
207 * entry with an unknown value (or a boolean) makes it drop every override in
208 * that file, so this schema does the same rather than applying the valid
209 * siblings the CLI ignores.
210 */
211const SkillOverrideValue = Schema.Literals(["on", "name-only", "user-invocable-only", "off"]);
212​
213// Lenient because these settings files are hand-edited and Claude Code itself
214// tolerates comments and trailing commas in them.
215const SkillSettings = fromLenientJson(
216 Schema.Struct({
217 skillOverrides: Schema.optional(Schema.Record(Schema.String, SkillOverrideValue)),
218 enabledPlugins: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)),
219 }),
220);
221const decodeSkillSettings = Schema.decodeUnknownEffect(SkillSettings);
222​
223type SkillOverride = {
224 readonly enabled: boolean;
225 readonly userInvocationOnly: boolean;
226};
227​
228function parseSkillOverride(value: typeof SkillOverrideValue.Type): SkillOverride {
229 switch (value) {
230 case "off":
231 return { enabled: false, userInvocationOnly: false };
232 case "user-invocable-only":
233 return { enabled: true, userInvocationOnly: true };
234 case "on":
235 case "name-only":
236 return { enabled: true, userInvocationOnly: false };
237 }
239​
240const readSkillSettings = Effect.fn("readSkillSettings")(function* (
241 configDirPath: string,
242 cwd: string | undefined,
243 environment: NodeJS.ProcessEnv,
244) {
245 const fileSystem = yield* FileSystem.FileSystem;
246 const path = yield* Path.Path;
247 const platform = yield* HostProcess.Platform;
248 const overridesByName = new Map<string, SkillOverride>();
249 const enabledPlugins = new Map<string, boolean>();
250 const repositoryRoot = cwd === undefined ? undefined : yield* findRepositoryRoot(cwd);
251​
252 for (const settingsPath of claudeSettingsPaths(
253 path,
254 configDirPath,
255 cwd,
256 platform,
257 environment,
258 repositoryRoot,
259 )) {
260 const contents = yield* fileSystem
261 .readFileString(settingsPath)
262 .pipe(Effect.orElseSucceed(() => undefined));
263 if (contents === undefined) {
264 continue;
265 }
266​
267 const parsed = yield* decodeSkillSettings(contents).pipe(
268 Effect.tapError((cause) =>
269 Effect.logDebug("claude settings file is unreadable; ignoring skill settings", {
270 path: settingsPath,
271 cause,
272 }),
273 ),
274 Effect.orElseSucceed(() => undefined),
275 );
276 for (const [name, value] of Object.entries(parsed?.skillOverrides ?? {})) {
277 overridesByName.set(name, parseSkillOverride(value));
278 }
279 for (const [key, enabled] of Object.entries(parsed?.enabledPlugins ?? {})) {
280 if (typeof enabled === "boolean") {
281 enabledPlugins.set(key, enabled);
282 } else {
283 // Extended formats replace lower-precedence values without enabling the plugin here.
284 enabledPlugins.delete(key);
285 }
286 }
287 }
288​
289 return { skillOverrides: overridesByName, enabledPlugins };
290});
291​
292const InstalledPlugins = Schema.fromJsonString(
293 Schema.Struct({ plugins: Schema.Record(Schema.String, Schema.Array(Schema.Unknown)) }),
294);
295const decodeInstalledPlugin = Schema.decodeUnknownOption(
296 Schema.Struct({
297 scope: Schema.Literals(["user", "project", "local", "managed"]),
298 installPath: Schema.NonEmptyString,
299 projectPath: Schema.optional(Schema.NonEmptyString),
300 }),
301);
302const PluginManifest = Schema.fromJsonString(
303 Schema.Struct({
304 name: Schema.optional(Schema.NonEmptyString),
305 skills: Schema.optional(Schema.Union([Schema.String, Schema.Array(Schema.String)])),
306 }),
307);
308​
309function isInsideDirectory(path: Path.Path, directory: string, candidate: string): boolean {
310 const relative = path.relative(directory, candidate);
311 return relative !== ".." && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative);
313​
314const discoverPluginSkillRoots = Effect.fn("discoverPluginSkillRoots")(function* (
315 configDirPath: string,
316 cwd: string | undefined,
317 enabledPlugins: ReadonlyMap<string, boolean>,
318 environment: NodeJS.ProcessEnv,
319) {
320 const fileSystem = yield* FileSystem.FileSystem;
321 const path = yield* Path.Path;
322 const home = yield* HostProcess.HomeDirectory;
323 const pluginDirectory = environment.CLAUDE_CODE_PLUGIN_CACHE_DIR;
324 const pluginsPath = pluginDirectory
325 ? path.resolve(cwd ?? ".", expandHomePath(pluginDirectory, home))
326 : path.join(configDirPath, "plugins");
327 const installed = yield* fileSystem
328 .readFileString(path.join(pluginsPath, "installed_plugins.json"))
329 .pipe(
330 Effect.flatMap(Schema.decodeUnknownEffect(InstalledPlugins)),
331 Effect.orElseSucceed(() => undefined),
332 );
333 if (installed === undefined) return [];
334 const roots: Array<ClaudeSkillRoot> = [];
335 // The CLI's process.cwd() resolves symlinks; registry projectPath values remain lexical.
336 const workspace =
337 cwd === undefined
338 ? undefined
339 : yield* fileSystem.realPath(cwd).pipe(Effect.orElseSucceed(() => path.resolve(cwd)));
340 // Install records repeat project paths, often hundreds of times per discovery.
341 const projectRepositoryRoots = new Map<string, string | undefined>();
342 const repositoryRoot =
343 workspace === undefined ? undefined : yield* findPluginRepositoryRoot(workspace);
344​
345 for (const [key, entries] of Object.entries(installed.plugins).sort()) {
346 if (enabledPlugins.get(key) !== true) continue;
347 const applicable = yield* Effect.filter(
348 entries.flatMap((entry) => Option.toArray(decodeInstalledPlugin(entry))),
349 (record) =>
350 Effect.gen(function* () {
351 if (record.scope === "user" || record.scope === "managed") return true;
352 if (record.projectPath === undefined || workspace === undefined) return false;
353 const projectPath = path.resolve(record.projectPath);
354 if (projectPath === workspace) return true;
355 if (repositoryRoot === undefined) return false;
356 if (!projectRepositoryRoots.has(projectPath)) {
357 projectRepositoryRoots.set(projectPath, yield* findPluginRepositoryRoot(projectPath));
358 }
359 return projectRepositoryRoots.get(projectPath) === repositoryRoot;
360 }),
361 );
362 // The native loader keeps registry order, preferring the first install that exists.
363 const existing = yield* Effect.findFirst(applicable, (record) =>
364 fileSystem
365 .exists(path.resolve(cwd ?? ".", record.installPath))
366 .pipe(Effect.orElseSucceed(() => false)),
367 );
368 const install = Option.getOrElse(existing, () => applicable[0]);
369 if (!install) continue;
370 const scope = install.scope === "user" || install.scope === "managed" ? "user" : "project";
371 const installPath = path.resolve(cwd ?? ".", install.installPath);
372 const manifest = yield* fileSystem
373 .readFileString(path.join(installPath, ".claude-plugin", "plugin.json"))
374 .pipe(
375 Effect.flatMap(Schema.decodeUnknownEffect(PluginManifest)),
376 Effect.orElseSucceed(() => undefined),
377 );
378 const prefix = manifest?.name ?? key.split("@")[0];
379 if (!prefix) continue;
380​
381 const defaultDirectory = path.join(installPath, "skills");
382 const hasDefaultDirectory = yield* fileSystem
383 .exists(defaultDirectory)
384 .pipe(Effect.orElseSucceed(() => false));
385 if (hasDefaultDirectory) roots.push({ directory: defaultDirectory, scope, prefix });
386 const declared = manifest?.skills;
387 if (declared === undefined && !hasDefaultDirectory) {
388 const hasRootSkill = yield* fileSystem
389 .exists(path.join(installPath, "SKILL.md"))
390 .pipe(Effect.orElseSucceed(() => false));
391 if (hasRootSkill) roots.push({ directory: installPath, scope, prefix });
392 }
393​
394 const canonicalInstallPath = yield* fileSystem
395 .realPath(installPath)
396 .pipe(Effect.orElseSucceed(() => undefined));
397 for (const relative of typeof declared === "string" ? [declared] : (declared ?? [])) {
398 const directory = path.resolve(installPath, relative);
399 if (!isInsideDirectory(path, installPath, directory) || canonicalInstallPath === undefined) {
400 continue;
401 }
402 const canonicalDirectory = yield* fileSystem
403 .realPath(directory)
404 .pipe(Effect.orElseSucceed(() => undefined));
405 // The native loader rejects manifest roots that escape through a symlink, too.
406 if (
407 canonicalDirectory !== undefined &&
408 isInsideDirectory(path, canonicalInstallPath, canonicalDirectory)
409 ) {
410 roots.push({ directory, scope, prefix });
411 }
412 }
413 }
414 return roots;
415});
416​
417const resolveClaudeConfigDirPath = Effect.fn("resolveClaudeConfigDirPath")(function* (
418 config: Pick<ClaudeSettings, "homePath">,
419 environment: NodeJS.ProcessEnv,
420 cwd?: string,
421): Effect.fn.Return<string, never, Path.Path> {
422 const path = yield* Path.Path;
423 const home = yield* HostProcess.HomeDirectory;
424 const homePath = config.homePath.trim();
425 if (homePath.length > 0) {
426 return path.resolve(expandHomePath(homePath, home));
427 }
428 // Match the spawned CLI: preserve a literal ~ and resolve relative config against workspace cwd.
429 const environmentConfigDir = environment.CLAUDE_CONFIG_DIR?.trim() ?? "";
430 if (environmentConfigDir.length > 0) {
431 return cwd ? path.resolve(cwd, environmentConfigDir) : path.resolve(environmentConfigDir);
432 }
433 return path.join(home, ".claude");
434});
435​
436const SettingsEnv = Schema.Struct({
437 ANTHROPIC_BASE_URL: Schema.optional(Schema.String),
438 CLAUDE_CODE_ENTRYPOINT: Schema.optional(Schema.String),
439 // Unquoted JSON values must not fail the decode and drop ANTHROPIC_BASE_URL with them.
440 CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY: Schema.optional(Schema.Unknown),
441 CLAUDE_CODE_GATEWAY_MODEL_DISCOVERY_TIMEOUT_MS: Schema.optional(Schema.Unknown),
442});
443const decodeSettingsEnv = Schema.decodeUnknownEffect(
444 fromLenientJson(Schema.Struct({ env: Schema.optional(SettingsEnv) })),
445);
446​
447/** The `env` values T3 Code reads from Claude's user and managed settings; later files win. */
448export const readClaudeSettingsEnv = Effect.fn("readClaudeSettingsEnv")(function* (
449 config: Pick<ClaudeSettings, "homePath">,
450 cwd: string | undefined,
451 environment: NodeJS.ProcessEnv,
452): Effect.fn.Return<typeof SettingsEnv.Type, never, FileSystem.FileSystem | Path.Path> {
453 const fileSystem = yield* FileSystem.FileSystem;
454 const path = yield* Path.Path;
455 const platform = yield* HostProcess.Platform;
456 const configDirPath = yield* resolveClaudeConfigDirPath(config, environment, cwd);
457 const settingsEnv: typeof SettingsEnv.Type = {};
458 for (const settingsPath of claudeSettingsPaths(
459 path,
460 configDirPath,
461 undefined,
462 platform,
463 environment,
464 )) {
465 const contents = yield* fileSystem
466 .readFileString(settingsPath)
467 .pipe(Effect.orElseSucceed(() => undefined));
468 if (contents === undefined) continue;
469 const parsed = yield* decodeSettingsEnv(contents).pipe(Effect.orElseSucceed(() => undefined));
470 Object.assign(settingsEnv, parsed?.env);
471 }
472 return settingsEnv;
473});
474​
475// Claude's --add-dir is repeatable and variadic; parseCliArgs keeps only one value.
476export function claudeLaunchArgDirectories(launchArgs?: string): ReadonlyArray<string> {
477 const directories: string[] = [];
478 let collecting = false;
479 for (const token of tokenizeCliArgs(launchArgs)) {
480 if (token === "--") break;
481 if (token === "--add-dir") {
482 collecting = true;
483 } else if (token.startsWith("--add-dir=")) {
484 directories.push(token.slice("--add-dir=".length));
485 collecting = false;
486 } else if (token.startsWith("-")) {
487 collecting = false;
488 } else if (collecting) {
489 directories.push(token);
490 }
491 }
492 return directories;
494​
495/** First name wins, matching Claude Code's precedence of user skills over project skills. */
496export const discoverClaudeSkills = Effect.fn("discoverClaudeSkills")(function* (
497 config: Pick<ClaudeSettings, "homePath"> & Partial<Pick<ClaudeSettings, "launchArgs">>,
498 cwd?: string,
499 environment?: NodeJS.ProcessEnv,
500): Effect.fn.Return<ReadonlyArray<ServerProviderSkill>, never, FileSystem.FileSystem | Path.Path> {
501 const fileSystem = yield* FileSystem.FileSystem;
502 const path = yield* Path.Path;
503 const configDirPath = yield* resolveClaudeConfigDirPath(config, environment ?? process.env, cwd);
504 const { skillOverrides, enabledPlugins } = yield* readSkillSettings(
505 configDirPath,
506 cwd,
507 environment ?? process.env,
508 );
509​
510 const roots: ReadonlyArray<ClaudeSkillRoot> = [
511 { directory: path.join(configDirPath, "skills"), scope: "user" },
512 ...(cwd ? [{ directory: path.join(cwd, ".claude", "skills"), scope: "project" as const }] : []),
513 ...claudeLaunchArgDirectories(config.launchArgs)
514 .filter((directory) => directory && (cwd || path.isAbsolute(directory)))
515 .map((directory) => ({
516 directory: path.join(path.resolve(cwd ?? ".", directory), ".claude", "skills"),
517 scope: "project" as const,
518 })),
519 ...(yield* discoverPluginSkillRoots(
520 configDirPath,
521 cwd,
522 enabledPlugins,
523 environment ?? process.env,
524 )),
525 ];
526​
527 const skillsByName = new Map<string, ServerProviderSkill>();
528 for (const root of roots) {
529 const singleSkill =
530 root.prefix !== undefined &&
531 (yield* fileSystem
532 .exists(path.join(root.directory, "SKILL.md"))
533 .pipe(Effect.orElseSucceed(() => false)));
534 const entries = singleSkill
535 ? [path.basename(root.directory)]
536 : yield* fileSystem
537 .readDirectory(root.directory)
538 .pipe(Effect.orElseSucceed((): ReadonlyArray<string> => []));
539​
540 for (const entry of [...entries].sort()) {
541 const skillPath = singleSkill
542 ? path.join(root.directory, "SKILL.md")
543 : path.join(root.directory, entry, "SKILL.md");
544 const contents = yield* fileSystem
545 .readFileString(skillPath)
546 .pipe(Effect.orElseSucceed(() => undefined));
547 if (contents === undefined) {
548 continue;
549 }
550​
551 const frontmatter = parseSkillFrontmatter(contents);
552 if (frontmatter.kind === "malformed") {
553 continue;
554 }
555​
556 const directoryName = entry.trim();
557 if (!directoryName) continue;
558 let name = directoryName;
559 if (root.prefix) {
560 // Native folder skills use their folder; only a single SKILL.md uses its name field.
561 const declaredName = singleSkill && frontmatter.kind === "parsed" ? frontmatter.name : "";
562 const unprefixedName = declaredName?.startsWith(`${root.prefix}:`)
563 ? declaredName.slice(root.prefix.length + 1)
564 : declaredName;
565 name = `${root.prefix}:${(unprefixedName || entry).replace(/[^a-zA-Z0-9_-]/g, "-")}`;
566 // Advertise only exact native names the shared composer grammar can invoke.
567 const [mention] = `$${name}`.matchAll(SKILL_MENTION_PATTERN);
568 if (mention?.[2] !== name) continue;
569 }
570​
571 if (skillsByName.has(name)) {
572 continue;
573 }
574​
575 const override = root.prefix ? undefined : skillOverrides.get(name);
576 const userInvocationOnly =
577 (frontmatter.kind === "parsed" && frontmatter.userInvocationOnly === true) ||
578 override?.userInvocationOnly === true;
579 skillsByName.set(name, {
580 name,
581 path: skillPath,
582 enabled: override?.enabled ?? true,
583 scope: root.scope,
584 ...(frontmatter.kind === "parsed" && frontmatter.description
585 ? { description: frontmatter.description }
586 : {}),
587 ...(userInvocationOnly ? { userInvocationOnly: true } : {}),
588 ...(frontmatter.kind === "parsed" && frontmatter.userInvocable === false
589 ? { userInvocable: false }
590 : {}),
591 });
592 }
593 }
594​
595 return [...skillsByName.values()].sort((left, right) => left.name.localeCompare(right.name));
596});