Fixed OpenCode skills not showing up in the composer #7572
Closedkridaydave(GitHub profile, opens in a new tab)wants to merge 13 commits into
main fromrefs/pull/7572/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- apps/server/src/provider/Drivers/OpenCodeSkills.ts lines 71 to 71OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +51,21 @@51+ ...(name ? { name } : {}),52+ ...(description ? { description } : {}),53+ };54+}55+56+/**57+ * Enumerate OpenCode skills from user config dirs, workspace `.claude/skills`,58+ * workspace `.agents/skills`, and workspace `.opencode/skills`, in that order.59+ * Discovery is best-effort: unreadable roots and malformed skill entries are skipped.60+ * On name collisions, later roots win: project beats user, `.agents` beats `.claude`,61+ * and `.opencode` beats `.agents`.62+ */63+export const discoverOpenCodeSkills = Effect.fn("discoverOpenCodeSkills")(function* (64+ cwd?: string,65+ environment?: NodeJS.ProcessEnv,66+): Effect.fn.Return<ReadonlyArray<ServerProviderSkill>, never, FileSystem.FileSystem | Path.Path> {67+ const fileSystem = yield* FileSystem.FileSystem;68+ const path = yield* Path.Path;69+ const env = environment ?? process.env;70+71+ const homeDir = NodeOS.homedir();
- apps/server/src/provider/Drivers/OpenCodeSkills.ts line 85OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +65,21 @@65+ environment?: NodeJS.ProcessEnv,66+): Effect.fn.Return<ReadonlyArray<ServerProviderSkill>, never, FileSystem.FileSystem | Path.Path> {67+ const fileSystem = yield* FileSystem.FileSystem;68+ const path = yield* Path.Path;69+ const env = environment ?? process.env;70+71+ const homeDir = env.HOME?.trim() || env.USERPROFILE?.trim() || NodeOS.homedir();72+ const xdgConfigHome = env.XDG_CONFIG_HOME?.trim();73+ const defaultConfigDir = xdgConfigHome74+ ? path.join(xdgConfigHome, "opencode")75+ : path.join(homeDir, ".config", "opencode");76+ const customConfigDir = env.OPENCODE_CONFIG_DIR?.trim();77+ const resolvedCustomConfigDir = customConfigDir78+ ? cwd79+ ? path.resolve(cwd, customConfigDir)80+ : path.resolve(customConfigDir)81+ : undefined;82+83+ const userRoots: ReadonlyArray<string> = resolvedCustomConfigDir84+ ? [path.join(resolvedCustomConfigDir, "skills")]85+ : [path.join(defaultConfigDir, "skills"), path.join(homeDir, ".opencode", "skills")];apps/server/src/provider/Drivers/OpenCodeSkills.ts line 95OutdatedResolvedby kridaydave(GitHub profile, opens in a new tab)@@ -0,0 +75,21 @@75+ : path.join(homeDir, ".config", "opencode");76+ const customConfigDir = env.OPENCODE_CONFIG_DIR?.trim();77+ const resolvedCustomConfigDir = customConfigDir78+ ? cwd79+ ? path.resolve(cwd, customConfigDir)80+ : path.resolve(customConfigDir)81+ : undefined;82+83+ const userRoots: ReadonlyArray<string> = resolvedCustomConfigDir84+ ? [path.join(resolvedCustomConfigDir, "skills")]85+ : [path.join(defaultConfigDir, "skills"), path.join(homeDir, ".opencode", "skills")];86+87+ const roots: ReadonlyArray<{ directory: string; scope: SkillScope }> = [88+ ...userRoots.map((directory) => ({ directory, scope: "user" as const })),89+ ...(cwd90+ ? [91+ { directory: path.join(cwd, ".claude", "skills"), scope: "project" as const },92+ { directory: path.join(cwd, ".agents", "skills"), scope: "project" as const },93+ { directory: path.join(cwd, ".opencode", "skills"), scope: "project" as const },94+ ]95+ : []),apps/server/src/provider/Drivers/OpenCodeSkills.ts line 95OutdatedResolvedby kridaydave(GitHub profile, opens in a new tab)@@ -0,0 +75,21 @@75+ : path.join(homeDir, ".config", "opencode");76+ const customConfigDir = env.OPENCODE_CONFIG_DIR?.trim();77+ const resolvedCustomConfigDir = customConfigDir78+ ? cwd79+ ? path.resolve(cwd, customConfigDir)80+ : path.resolve(customConfigDir)81+ : undefined;82+83+ const userRoots: ReadonlyArray<string> = resolvedCustomConfigDir84+ ? [path.join(resolvedCustomConfigDir, "skills")]85+ : [path.join(defaultConfigDir, "skills"), path.join(homeDir, ".opencode", "skills")];86+87+ const roots: ReadonlyArray<{ directory: string; scope: SkillScope }> = [88+ ...userRoots.map((directory) => ({ directory, scope: "user" as const })),89+ ...(cwd90+ ? [91+ { directory: path.join(cwd, ".claude", "skills"), scope: "project" as const },92+ { directory: path.join(cwd, ".agents", "skills"), scope: "project" as const },93+ { directory: path.join(cwd, ".opencode", "skills"), scope: "project" as const },94+ ]95+ : []),
- apps/server/src/provider/Drivers/OpenCodeSkills.ts line 143Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +91,21 @@91+ ];92+93+ const projectDirs: ReadonlyArray<string> = cwd94+ ? yield* Effect.gen(function* () {95+ const dirs: Array<string> = [];96+ let current = path.resolve(cwd);97+ while (true) {98+ dirs.push(current);99+ const gitPath = path.join(current, ".git");100+ const hasGit = yield* fileSystem.exists(gitPath).pipe(Effect.orElseSucceed(() => false));101+ if (hasGit) {102+ break;103+ }104+ const parent = path.dirname(current);105+ if (parent === current) {106+ break;107+ }108+ current = parent;109+ }110+ return dirs.reverse();111+ })
- apps/server/src/provider/Drivers/OpenCodeSkills.ts line 157Resolvedby kridaydave(GitHub profile, opens in a new tab)@@ -0,0 +102,21 @@102+ foundGit = true;103+ break;104+ }105+ const parent = path.dirname(current);106+ if (parent === current) {107+ break;108+ }109+ current = parent;110+ }111+ return foundGit ? dirs.toReversed() : [path.resolve(cwd)];112+ })113+ : [];114+115+ const roots: ReadonlyArray<{ directory: string; scope: SkillScope }> = [116+ ...userRoots.map((directory) => ({ directory, scope: "user" as const })),117+ ...projectDirs.flatMap((dir) => [118+ { directory: path.join(dir, ".claude", "skills"), scope: "project" as const },119+ { directory: path.join(dir, ".agents", "skills"), scope: "project" as const },120+ { directory: path.join(dir, ".opencode", "skills"), scope: "project" as const },121+ ]),122+ ];
- apps/server/src/provider/Drivers/OpenCodeSkills.ts line 90OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +70,21 @@70+ * Enumerate OpenCode skills from user config dirs, workspace `.claude/skills`,71+ * workspace `.agents/skills`, and workspace `.opencode/skills`, in that order.72+ * Discovery is best-effort: unreadable roots and malformed skill entries are skipped.73+ * On name collisions, later roots win: project beats user, `.agents` beats `.claude`,74+ * and `.opencode` beats `.agents`.75+ *76+ * Matches OpenCode's own gating: `OPENCODE_DISABLE_EXTERNAL_SKILLS` skips all77+ * disk-scanned roots, and `OPENCODE_DISABLE_CLAUDE_CODE` /78+ * `OPENCODE_DISABLE_CLAUDE_CODE_SKILLS` skip `.claude/skills` roots.79+ */80+export const discoverOpenCodeSkills = Effect.fn("discoverOpenCodeSkills")(function* (81+ cwd?: string,82+ environment?: NodeJS.ProcessEnv,83+): Effect.fn.Return<ReadonlyArray<ServerProviderSkill>, never, FileSystem.FileSystem | Path.Path> {84+ const fileSystem = yield* FileSystem.FileSystem;85+ const path = yield* Path.Path;86+ const env = environment ?? process.env;87+88+ if (isDisableFlagSet(env.OPENCODE_DISABLE_EXTERNAL_SKILLS)) {89+ return [];90+ }apps/server/src/provider/Drivers/OpenCodeSkills.ts line 40OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +20,21 @@20+21+import type { ServerProviderSkill } from "@t3tools/contracts";22+import * as Effect from "effect/Effect";23+import * as FileSystem from "effect/FileSystem";24+import * as Path from "effect/Path";25+import { parse as parseYamlDocument } from "yaml";26+27+type SkillScope = "user" | "project";28+29+const FRONTMATTER_PATTERN = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/;30+31+type SkillFrontmatter =32+ | { readonly kind: "missing" }33+ | { readonly kind: "malformed" }34+ | { readonly kind: "parsed"; readonly name?: string; readonly description?: string };35+36+function isDisableFlagSet(value: string | undefined): boolean {37+ const normalized = value?.trim().toLowerCase();38+ return (39+ normalized !== undefined && normalized !== "" && normalized !== "0" && normalized !== "false"40+ );
- apps/server/src/provider/Drivers/OpenCodeSkills.ts lines 31 to 31OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +11,21 @@11+ *12+ * OpenCode's own disable flags are honored so discovery matches what OpenCode13+ * actually loads: OPENCODE_DISABLE_EXTERNAL_SKILLS skips .claude/skills and14+ * .agents/skills roots, and OPENCODE_DISABLE_CLAUDE_CODE /15+ * OPENCODE_DISABLE_CLAUDE_CODE_SKILLS skip .claude/skills roots. Native16+ * OpenCode roots (.opencode, config dirs) always load. Flags enable only for17+ * "1" and "true", matching OpenCode's strict parsing.18+ *19+ * @module provider/Drivers/OpenCodeSkills20+ */21+import * as NodeOS from "node:os";22+23+import type { ServerProviderSkill } from "@t3tools/contracts";24+import * as Effect from "effect/Effect";25+import * as FileSystem from "effect/FileSystem";26+import * as Path from "effect/Path";27+import { parse as parseYamlDocument } from "yaml";28+29+type SkillScope = "user" | "project";30+31+const FRONTMATTER_PATTERN = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/;apps/server/src/provider/Layers/OpenCodeProvider.ts lines 356 to 356OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -326,9 +343,14 @@326343 openCodeSettings: OpenCodeSettings,327344 cwd: string,328345 environment?: NodeJS.ProcessEnv,329-): Effect.fn.Return<ServerProviderDraft, never, OpenCodeRuntime> {346+): Effect.fn.Return<347+ ServerProviderDraft,348+ never,349+ OpenCodeRuntime | FileSystem.FileSystem | Path.Path350+> {330351 const openCodeRuntime = yield* OpenCodeRuntime;331352 const resolvedEnvironment = environment ?? process.env;332353 const checkedAt = DateTime.formatIso(yield* DateTime.now);333354 const customModels = openCodeSettings.customModels;334355 const isExternalServer = openCodeSettings.serverUrl.trim().length > 0;356+ const discoveredSkills = yield* discoverOpenCodeSkills(cwd, resolvedEnvironment);
- apps/server/src/provider/Layers/OpenCodeProvider.ts line 489Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -457,4 +482,4 @@457482 customModels,458483 DEFAULT_OPENCODE_MODEL_CAPABILITIES,459484 );460- const skills = flattenOpenCodeSkills(inventoryExit.value);485+ const skills = mergeOpenCodeSkills(flattenOpenCodeSkills(inventoryExit.value), discoveredSkills);
- apps/server/src/provider/Drivers/OpenCodeSkills.ts line 49Resolvedby kridaydave(GitHub profile, opens in a new tab)@@ -0,0 +29,21 @@29+type SkillScope = "user" | "project";30+31+const FRONTMATTER_PATTERN = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/;32+33+type SkillFrontmatter =34+ | { readonly kind: "missing" }35+ | { readonly kind: "malformed" }36+ | { readonly kind: "parsed"; readonly name?: string; readonly description?: string };37+38+// Matches OpenCode's strict flag parsing: only "1" and "true" enable a flag.39+function isDisableFlagSet(value: string | undefined): boolean {40+ const normalized = value?.trim().toLowerCase();41+ return normalized === "1" || normalized === "true";42+}43+44+function parseSkillFrontmatter(contents: string): SkillFrontmatter {45+ const match = FRONTMATTER_PATTERN.exec(contents);46+ if (!match) {47+ // An opening `---` without a closing delimiter is invalid frontmatter, not a48+ // file without frontmatter, so skip it instead of trusting its directory name.49+ return /^---\r?\n/.test(contents) ? { kind: "malformed" } : { kind: "missing" };
- @@ -0,0 +136,21 @@136+ const parent = path.dirname(current);137+ if (parent === current) {138+ break;139+ }140+ current = parent;141+ }142+ return foundGit ? dirs.toReversed() : [path.resolve(cwd)];143+ })144+ : [];145+146+ const roots: ReadonlyArray<{ directory: string; scope: SkillScope }> = [147+ ...userRoots.map((directory) => ({ directory, scope: "user" as const })),148+ ...projectDirs.flatMap((dir) => [149+ ...(claudeSkillsDisabled150+ ? []151+ : [{ directory: path.join(dir, ".claude", "skills"), scope: "project" as const }]),152+ ...(agentsSkillsDisabled153+ ? []154+ : [{ directory: path.join(dir, ".agents", "skills"), scope: "project" as const }]),155+ { directory: path.join(dir, ".opencode", "skills"), scope: "project" as const },156+ ]),
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.


Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
fc7cd918-07a0-4e5b-8fab-defa38f6ef85You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share