feat(server): expose Grok skills in provider snapshots #5960
Closedrksfn(GitHub profile, opens in a new tab)wants to merge 6 commits into
main fromrefs/pull/5960/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/Layers/GrokProvider.ts line 259OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -251,7 +256,4 @@251256 });252257 }253258254- const discoveryExit = yield* discoverGrokModelsViaAcp(grokSettings, environment).pipe(255- Effect.timeoutOption(GROK_ACP_MODEL_DISCOVERY_TIMEOUT_MS),256- Effect.exit,257- );259+ const skills = yield* discoverGrokSkills(cwd);
- apps/server/src/provider/Drivers/ProviderSkills.ts lines 41 to 41Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +19,21 @@19+const decodeSkillFrontmatter = Schema.decodeUnknownOption(SkillFrontmatter);20+21+type ParsedSkillFrontmatter =22+ | { readonly kind: "missing" }23+ | { readonly kind: "malformed" }24+ | { readonly kind: "parsed"; readonly name?: string; readonly description?: string };25+26+function parseSkillFrontmatter(contents: string): ParsedSkillFrontmatter {27+ const match = FRONTMATTER_PATTERN.exec(contents);28+ if (!match) {29+ return { kind: "missing" };30+ }31+32+ let document: unknown;33+ try {34+ document = parseYamlDocument(match[1] ?? "");35+ } catch {36+ return { kind: "malformed" };37+ }38+39+ const decoded = decodeSkillFrontmatter(document);apps/server/src/provider/Drivers/ProviderSkills.ts lines 81 to 81Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +55,21 @@55+): Effect.fn.Return<ReadonlyArray<ServerProviderSkill>, never, FileSystem.FileSystem | Path.Path> {56+ const fileSystem = yield* FileSystem.FileSystem;57+ const path = yield* Path.Path;58+ const skillsByName = new Map<string, ServerProviderSkill>();59+60+ for (const root of roots) {61+ const entries = yield* fileSystem62+ .readDirectory(root.directory)63+ .pipe(Effect.orElseSucceed((): ReadonlyArray<string> => []));64+65+ for (const entry of [...entries].sort()) {66+ const skillPath = path.join(root.directory, entry, "SKILL.md");67+ const contents = yield* fileSystem68+ .readFileString(skillPath)69+ .pipe(Effect.orElseSucceed(() => undefined));70+ if (contents === undefined) {71+ continue;72+ }73+74+ const frontmatter = parseSkillFrontmatter(contents);75+ if (frontmatter.kind === "malformed") {
- apps/server/src/provider/Drivers/GrokSkills.ts line 18OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +1,18 @@1+import * as NodeOS from "node:os";2+3+import type { ServerProviderSkill } from "@t3tools/contracts";4+import * as Effect from "effect/Effect";5+import * as FileSystem from "effect/FileSystem";6+import * as Path from "effect/Path";7+8+import { discoverSkillsFromRoots } from "./ProviderSkills.ts";9+10+export const discoverGrokSkills = Effect.fn("discoverGrokSkills")(function* (11+ cwd?: string,12+ homeDirectory = NodeOS.homedir(),13+): Effect.fn.Return<ReadonlyArray<ServerProviderSkill>, never, FileSystem.FileSystem | Path.Path> {14+ const path = yield* Path.Path;15+16+ return yield* discoverSkillsFromRoots([17+ { directory: path.join(homeDirectory, ".agents", "skills"), scope: "user" },18+ { directory: path.join(homeDirectory, ".grok", "skills"), scope: "user" },
- apps/server/src/provider/Drivers/ProviderSkills.ts line 29Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +8,21 @@8+import { parse as parseYamlDocument } from "yaml";9+10+export interface ProviderSkillRoot {11+ readonly directory: string;12+ readonly scope: string;13+}14+15+const FRONTMATTER_PATTERN = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/;16+const SkillFrontmatter = Schema.Struct({17+ name: Schema.optional(Schema.Unknown),18+ description: Schema.optional(Schema.Unknown),19+});20+const decodeSkillFrontmatter = Schema.decodeUnknownOption(SkillFrontmatter);21+22+type ParsedSkillFrontmatter =23+ | { readonly kind: "missing" }24+ | { readonly kind: "malformed" }25+ | { readonly kind: "parsed"; readonly name?: string; readonly description?: string };26+27+function parseSkillFrontmatter(contents: string): ParsedSkillFrontmatter {28+ const match = FRONTMATTER_PATTERN.exec(contents);
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:
6b34c9c5-0019-44ea-b179-7b24e1d2d426You 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