feat(web): add cross-harness skill manager #4630
Closedt3dotgg(GitHub profile, opens in a new tab)wants to merge 5 commits into
main fromt3code/plan-skill-manager-1opened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XXL
- apps/web/src/components/settings/SkillsSettings.tsx line 205Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +183,21 @@183+ >184+ <DisclosureChevron open={open} />185+ <span className="min-w-0 flex-1 truncate text-sm font-medium text-foreground">186+ {environment.label}187+ </span>188+ </button>189+ </h3>190+ <ConnectionStatusDot191+ tooltipText={phase}192+ dotClassName={connectionDotClassName(phase)}193+ pingClassName={194+ phase === "connecting" || phase === "reconnecting"195+ ? "bg-warning/60 duration-2000"196+ : null197+ }198+ />199+ {skillCount !== undefined ? (200+ <span className="shrink-0 font-mono text-[11px] tabular-nums text-muted-foreground/70">201+ {skillCount} {skillCount === 1 ? "skill" : "skills"}202+ </span>203+ ) : null}apps/web/src/components/settings/SkillsSettings.tsx line 301OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +281,21 @@281+ aria-expanded={open}282+ aria-controls={open ? panelId : undefined}283+ onClick={onToggle}284+ className="flex w-full min-w-0 cursor-pointer items-center gap-2 rounded-lg py-1.5 pl-7 pr-3 text-left transition-colors hover:bg-muted/25 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset sm:pl-8 sm:pr-4"285+ >286+ <DisclosureChevron open={open} className="size-3" />287+ {HarnessIcon ? <HarnessIcon aria-hidden className="size-3.5 shrink-0" /> : null}288+ <span className="shrink-0 text-[11px] font-semibold uppercase tracking-[0.08em] text-muted-foreground/70">289+ {harnessDisplayName}290+ </span>291+ <span className="shrink-0 font-mono text-[11px] tabular-nums text-muted-foreground/50">292+ {skills.length}293+ </span>294+ {rootPath ? (295+ <span className="hidden min-w-0 flex-1 truncate text-right font-mono text-[11px] text-muted-foreground/40 sm:block">296+ {formatSkillPath(rootPath)}297+ </span>298+ ) : null}299+ </button>300+301+ <Collapsible open={open} onOpenChange={onToggle}>
- apps/server/src/skills/SkillInventory.test.ts lines 14 to 14OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +1,14 @@1+import * as NodeServices from "@effect/platform-node/NodeServices";2+import { assert, it } from "@effect/vitest";3+import {4+ ClaudeSettings,5+ CodexSettings,6+ ProviderDriverKind,7+ ProviderInstanceId,8+} from "@t3tools/contracts";9+import * as Effect from "effect/Effect";10+import * as FileSystem from "effect/FileSystem";11+import * as Path from "effect/Path";12+import * as Schema from "effect/Schema";13+14+import { layerTest as serverSettingsLayerTest } from "../serverSettings.ts";
- apps/server/src/skills/SkillInventory.ts line 108Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +63,21 @@63+ const skills = yield* discoverClaudeSkills(decoded.value, undefined);64+ return yield* Effect.forEach(skills, (skill) =>65+ fileSystem.readFileString(skill.path).pipe(66+ Effect.orElseSucceed(() => ""),67+ Effect.map((content) => ({68+ providerInstanceId: ProviderInstanceId.make(instanceId),69+ harness: instance.driver,70+ harnessDisplayName: harnessDisplayName(instance, "Claude"),71+ name: skill.name,72+ ...(skill.description ? { description: skill.description } : {}),73+ directoryPath: path.dirname(skill.path),74+ skillFilePath: skill.path,75+ content,76+ enabled: skill.enabled,77+ })),78+ ),79+ );80+ }81+82+ return [];83+});apps/server/src/skills/SkillInventory.ts line 63OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +43,21 @@43+ fileSystem.readFileString(skill.path).pipe(44+ Effect.orElseSucceed(() => ""),45+ Effect.map((content) => ({46+ providerInstanceId: ProviderInstanceId.make(instanceId),47+ harness: instance.driver,48+ harnessDisplayName: harnessDisplayName(instance, "Codex"),49+ name: skill.name,50+ ...(skill.description ? { description: skill.description } : {}),51+ directoryPath: path.dirname(skill.path),52+ skillFilePath: skill.path,53+ content,54+ enabled: skill.enabled,55+ })),56+ ),57+ );58+ }59+60+ if (instance.driver === "claudeAgent") {61+ const decoded = decodeClaudeSettings(config);62+ if (decoded._tag === "None") return [];63+ const skills = yield* discoverClaudeSkills(decoded.value, undefined);
- apps/server/src/skills/SkillInventory.test.ts line 14OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -0,0 +1,14 @@1+import * as NodeServices from "@effect/platform-node/NodeServices";2+import { assert, it } from "@effect/vitest";3+import {4+ ClaudeSettings,5+ CodexSettings,6+ ProviderDriverKind,7+ ProviderInstanceId,8+} from "@t3tools/contracts";9+import * as Effect from "effect/Effect";10+import * as FileSystem from "effect/FileSystem";11+import * as Path from "effect/Path";12+import * as Schema from "effect/Schema";13+14+import { layerTest as serverSettingsLayerTest } from "../serverSettings.ts";apps/web/src/components/settings/SkillsSettings.logic.ts lines 1 to 102OutdatedResolvedby t3dotgg(GitHub profile, opens in a new tab)@@ -0,0 +82,21 @@82+ const existing = groups.get(key);83+ if (existing) existing.push(skill);84+ else groups.set(key, [skill]);85+ }86+ return [...groups.entries()].map(([key, skills]) => {87+ const roots = new Set(skills.map((skill) => parentDirectory(skill.directoryPath)));88+ return {89+ key,90+ harness: skills[0]!.harness,91+ harnessDisplayName: skills[0]?.harnessDisplayName ?? key,92+ rootPath: roots.size === 1 ? ([...roots][0] ?? null) : null,93+ skills,94+ };95+ });96+}97+98+/** Raw SKILL.md text ready to render, or `null` when the file has no content. */99+export function skillContentForDisplay(content: string): string | null {100+ const trimmed = content.trim();101+ return trimmed.length > 0 ? trimmed : null;102+}
t3dotgg(GitHub profile, opens in a new tab) changed the title
- packages/client-runtime/src/state/skillInventoryHttp.ts lines 27 to 27OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +7,21 @@7+} from "@t3tools/contracts";8+9+import type { PreparedConnection } from "../connection/model.ts";10+import { environmentEndpointUrl } from "../environment/endpoint.ts";11+import { ManagedRelayDpopSigner } from "../relay/managedRelay.ts";12+import { executeEnvironmentHttpRequest, makeEnvironmentHttpApiClient } from "../rpc/http.ts";13+import { buildEnvironmentAuthHeaders, withEnvironmentCredentials } from "./environmentHttpAuth.ts";14+15+const DEFAULT_SKILL_INVENTORY_TIMEOUT_MS = 10_000;16+const HOME_DIRECTORY_PREFIX = /^(?:\/(?:home|Users)\/[^/]+|[A-Za-z]:\\Users\\[^\\]+)(?=[/\\]|$)/;17+18+/** Shortens a skill directory for display while preserving its useful tail. */19+export function formatSkillPath(path: string): string {20+ const homeRelative = path.replace(HOME_DIRECTORY_PREFIX, "~");21+ const segments = homeRelative.split(/[/\\]/).filter(Boolean);22+ if (segments.length <= 4) return homeRelative;23+ return `…/${segments.slice(-3).join("/")}`;24+}25+26+export function filterSkillInventory(inventory: SkillInventory, query: string): SkillInventory {27+ const normalizedQuery = query.trim().toLocaleLowerCase();apps/web/src/components/settings/SkillsSettings.tsx lines 162 to 162OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +142,21 @@142+ .runPromise(fetchEnvironmentSkillInventory({ prepared: prepared.value }))143+ .then((inventory) => {144+ if (!cancelled) setState({ status: "loaded", inventory });145+ })146+ .catch((cause: unknown) => {147+ if (!cancelled) setState({ status: "error", message: errorMessage(cause) });148+ });149+ return () => {150+ cancelled = true;151+ };152+ }, [prepared, refreshKey]);153+154+ const visibleInventory = useMemo(155+ () => (state.status === "loaded" ? filterSkillInventory(state.inventory, query) : null),156+ [query, state],157+ );158+ const isConnected = Option.isSome(prepared);159+ const skillCount = displayedSkillCount(visibleInventory, isConnected);160+ const phase = environment.connection.phase;161+ const isSearching = query.trim().length > 0;162+ const open = !collapsed;
- apps/web/src/components/settings/SkillsSettings.tsx line 200OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +180,21 @@180+ onClick={() => setCollapsed((value) => !value)}181+ className="flex min-w-0 flex-1 cursor-pointer items-center gap-2 rounded-lg py-2 pl-3 text-left transition-colors hover:bg-muted/25 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset sm:pl-4"182+ >183+ <DisclosureChevron open={open} />184+ <span className="min-w-0 flex-1 truncate text-sm font-medium text-foreground">185+ {environment.label}186+ </span>187+ </button>188+ </h3>189+ <ConnectionStatusDot190+ tooltipText={phase}191+ dotClassName={connectionDotClassName(phase)}192+ pingClassName={193+ phase === "connecting" || phase === "reconnecting"194+ ? "bg-warning/60 duration-2000"195+ : null196+ }197+ />198+ {skillCount !== null ? (199+ <span className="shrink-0 font-mono text-[11px] tabular-nums text-muted-foreground/70">200+ {skillCount} {skillCount === 1 ? "skill" : "skills"}apps/server/src/skills/SkillInventory.ts line 52Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +33,21 @@33+ }): Effect.fn.Return<34+ ReadonlyArray<SkillInventoryInstallation>,35+ never,36+ FileSystem.FileSystem | Path.Path37+ > {38+ const fileSystem = yield* FileSystem.FileSystem;39+ const path = yield* Path.Path;40+ return yield* Effect.forEach(input.skills, (skill) =>41+ fileSystem.readFileString(skill.path).pipe(42+ Effect.orElseSucceed(() => ""),43+ Effect.map((content) => ({44+ providerInstanceId: ProviderInstanceId.make(input.instanceId),45+ harness: input.instance.driver,46+ harnessDisplayName: harnessDisplayName(input.instance, input.fallbackDisplayName),47+ name: skill.name,48+ ...(skill.description ? { description: skill.description } : {}),49+ directoryPath: path.dirname(skill.path),50+ skillFilePath: skill.path,51+ content,52+ enabled: skill.enabled,53+ })),
- apps/server/src/skills/SkillInventory.ts line 42Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +21,21 @@21+const decodeClaudeSettings = Schema.decodeUnknownOption(ClaudeSettings);22+23+function harnessDisplayName(instance: ProviderInstanceConfig, fallback: string): string {24+ return instance.displayName?.trim() || fallback;25+}26+27+const readSkillInstallations = Effect.fn("SkillInventory.readSkillInstallations")(28+ function* (input: {29+ readonly instanceId: string;30+ readonly instance: ProviderInstanceConfig;31+ readonly fallbackDisplayName: string;32+ readonly skills: ReadonlyArray<ServerProviderSkill>;33+ }): Effect.fn.Return<34+ ReadonlyArray<SkillInventoryInstallation>,35+ never,36+ FileSystem.FileSystem | Path.Path37+ > {38+ const fileSystem = yield* FileSystem.FileSystem;39+ const path = yield* Path.Path;40+ return yield* Effect.forEach(input.skills, (skill) =>41+ fileSystem.readFileString(skill.path).pipe(
- apps/web/src/components/settings/SkillsSettings.tsx line 163Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +142,21 @@142+ .runPromise(fetchEnvironmentSkillInventory({ prepared: prepared.value }))143+ .then((inventory) => {144+ if (!cancelled) setState({ status: "loaded", inventory });145+ })146+ .catch((cause: unknown) => {147+ if (!cancelled) setState({ status: "error", message: errorMessage(cause) });148+ });149+ return () => {150+ cancelled = true;151+ };152+ }, [prepared, refreshKey]);153+154+ const visibleInventory = useMemo(155+ () => (state.status === "loaded" ? filterSkillInventory(state.inventory, query) : null),156+ [query, state],157+ );158+ const isConnected = Option.isSome(prepared);159+ const skillCount = displayedSkillCount(160+ state.status === "loaded" ? state.inventory : null,161+ isConnected,162+ );
- @@ -0,0 +22,21 @@22+const decodeClaudeSettings = Schema.decodeUnknownOption(ClaudeSettings);23+24+function harnessDisplayName(instance: ProviderInstanceConfig, fallback: string): string {25+ return instance.displayName?.trim() || fallback;26+}27+28+export const readSkillInstallations = Effect.fn("SkillInventory.readSkillInstallations")(29+ function* (input: {30+ readonly instanceId: string;31+ readonly instance: ProviderInstanceConfig;32+ readonly fallbackDisplayName: string;33+ readonly skills: ReadonlyArray<ServerProviderSkill>;34+ }): Effect.fn.Return<35+ ReadonlyArray<SkillInventoryInstallation>,36+ never,37+ FileSystem.FileSystem | Path.Path38+ > {39+ const fileSystem = yield* FileSystem.FileSystem;40+ const path = yield* Path.Path;41+ const installations = yield* Effect.forEach(input.skills, (skill) =>42+ fileSystem.readFileString(skill.path).pipe(
- @@ -0,0 +200,21 @@200+ />201+ {skillCount !== null ? (202+ <span className="shrink-0 font-mono text-[11px] tabular-nums text-muted-foreground/70">203+ {formatSkillCount(skillCount, isSearching ? (visibleSkillCount ?? 0) : undefined)}204+ </span>205+ ) : null}206+ </div>207+208+ <Collapsible open={open} onOpenChange={setOpen}>209+ <CollapsibleContent id={panelId}>210+ <div className="pb-2">211+ {Option.isNone(prepared) ? (212+ <StatusLine>Connect to this computer to inspect its skills.</StatusLine>213+ ) : state.status === "loading" ? (214+ <StatusLine>Scanning skills…</StatusLine>215+ ) : state.status === "error" ? (216+ <StatusLine tone="error">{state.message}</StatusLine>217+ ) : visibleInventory?.installations.length === 0 ? (218+ <StatusLine>219+ {query ? "No skills match this search." : "No global Codex or Claude skills found."}220+ </StatusLine>
maria-rcks closed this
Sign in to join this conversation.



🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)#
✅ Passed checks (4 passed)
✨ Finishing Touches
🧪 Generate unit tests (beta)
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