Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
86bd7265e7 | ||
|
|
6f306acefa | ||
|
|
8141436e32 | ||
|
|
150cc83478 | ||
|
|
77bc728429 |
No files matched your search
@@ -20,6 +20,7 @@ import {
|
||||
} from "./http.ts";
|
||||
import { fixPath } from "./os-jank.ts";
|
||||
import { websocketRpcRouteLayer } from "./ws.ts";
|
||||
import { skillsHttpApiLayer } from "./skills/http.ts";
|
||||
import * as ExternalLauncher from "./process/externalLauncher.ts";
|
||||
import { layerConfig as SqlitePersistenceLayerLive } from "./persistence/Layers/Sqlite.ts";
|
||||
import * as ServerLifecycleEvents from "./serverLifecycleEvents.ts";
|
||||
@@ -431,6 +432,7 @@ export const makeRoutesLayer = Layer.mergeAll(
|
||||
Layer.provide(authHttpApiLayer),
|
||||
Layer.provide(connectHttpApiLayer),
|
||||
Layer.provide(orchestrationHttpApiLayer),
|
||||
Layer.provide(skillsHttpApiLayer),
|
||||
Layer.provide(serverEnvironmentHttpApiLayer),
|
||||
Layer.provide(environmentAuthenticatedAuthLayer),
|
||||
),
|
||||
|
||||
@@ -0,0 +1,213 @@
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
import { assert, it } from "@effect/vitest";
|
||||
import {
|
||||
ClaudeSettings,
|
||||
CodexSettings,
|
||||
ProviderDriverKind,
|
||||
ProviderInstanceId,
|
||||
} from "@t3tools/contracts";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as FileSystem from "effect/FileSystem";
|
||||
import * as Path from "effect/Path";
|
||||
import * as Schema from "effect/Schema";
|
||||
|
||||
import * as ServerSettings from "../serverSettings.ts";
|
||||
import { discoverGlobalSkillInventory, readSkillInstallations } from "./SkillInventory.ts";
|
||||
|
||||
const decodeCodexSettings = Schema.decodeSync(CodexSettings);
|
||||
const decodeClaudeSettings = Schema.decodeSync(ClaudeSettings);
|
||||
|
||||
const writeSkill = Effect.fn("SkillInventoryTest.writeSkill")(function* (
|
||||
root: string,
|
||||
directoryName: string,
|
||||
description: string,
|
||||
) {
|
||||
const fileSystem = yield* FileSystem.FileSystem;
|
||||
const path = yield* Path.Path;
|
||||
const directory = path.join(root, "skills", directoryName);
|
||||
yield* fileSystem.makeDirectory(directory, { recursive: true });
|
||||
yield* fileSystem.writeFileString(
|
||||
path.join(directory, "SKILL.md"),
|
||||
`---\nname: ${directoryName}\ndescription: ${description}\n---\n`,
|
||||
);
|
||||
});
|
||||
|
||||
it.layer(NodeServices.layer)("discoverGlobalSkillInventory", (it) => {
|
||||
it.effect("omits skills that become unreadable during inventory", () =>
|
||||
Effect.gen(function* () {
|
||||
const fileSystem = yield* FileSystem.FileSystem;
|
||||
const path = yield* Path.Path;
|
||||
const tempDirectory = yield* fileSystem.makeTempDirectoryScoped({
|
||||
prefix: "t3-skill-inventory-unreadable-",
|
||||
});
|
||||
const installations = yield* readSkillInstallations({
|
||||
instanceId: "codex",
|
||||
instance: {
|
||||
driver: ProviderDriverKind.make("codex"),
|
||||
config: decodeCodexSettings({}),
|
||||
},
|
||||
fallbackDisplayName: "Codex",
|
||||
skills: [
|
||||
{
|
||||
name: "removed",
|
||||
path: path.join(tempDirectory, "removed", "SKILL.md"),
|
||||
enabled: true,
|
||||
scope: "user",
|
||||
},
|
||||
],
|
||||
});
|
||||
assert.deepEqual(installations, []);
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("discovers global skills for configured Codex and Claude instances", () =>
|
||||
Effect.gen(function* () {
|
||||
const fileSystem = yield* FileSystem.FileSystem;
|
||||
const path = yield* Path.Path;
|
||||
const tempDirectory = yield* fileSystem.makeTempDirectoryScoped({
|
||||
prefix: "t3-skill-inventory-",
|
||||
});
|
||||
const codexHome = path.join(tempDirectory, "codex");
|
||||
const claudeHome = path.join(tempDirectory, "claude");
|
||||
yield* writeSkill(codexHome, "review", "Review with Codex.");
|
||||
yield* writeSkill(claudeHome, "deploy", "Deploy with Claude.");
|
||||
|
||||
const inventory = yield* discoverGlobalSkillInventory().pipe(
|
||||
Effect.provide(
|
||||
ServerSettings.layerTest({
|
||||
providers: {
|
||||
codex: decodeCodexSettings({ homePath: path.join(tempDirectory, "empty-codex") }),
|
||||
claudeAgent: decodeClaudeSettings({
|
||||
homePath: path.join(tempDirectory, "empty-claude"),
|
||||
}),
|
||||
},
|
||||
providerInstances: {
|
||||
[ProviderInstanceId.make("codex_work")]: {
|
||||
driver: ProviderDriverKind.make("codex"),
|
||||
displayName: "Codex Work",
|
||||
config: decodeCodexSettings({ homePath: codexHome }),
|
||||
},
|
||||
[ProviderInstanceId.make("claude_personal")]: {
|
||||
driver: ProviderDriverKind.make("claudeAgent"),
|
||||
displayName: "Claude Personal",
|
||||
config: decodeClaudeSettings({ homePath: claudeHome }),
|
||||
},
|
||||
},
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
assert.deepEqual(
|
||||
inventory.installations.map((skill) => ({
|
||||
harness: skill.harness,
|
||||
harnessDisplayName: skill.harnessDisplayName,
|
||||
name: skill.name,
|
||||
directoryPath: skill.directoryPath,
|
||||
hasContent: skill.content.includes(`#`) || skill.content.includes("description:"),
|
||||
})),
|
||||
[
|
||||
{
|
||||
harness: "claudeAgent",
|
||||
harnessDisplayName: "Claude Personal",
|
||||
name: "deploy",
|
||||
directoryPath: path.join(claudeHome, "skills", "deploy"),
|
||||
hasContent: true,
|
||||
},
|
||||
{
|
||||
harness: "codex",
|
||||
harnessDisplayName: "Codex Work",
|
||||
name: "review",
|
||||
directoryPath: path.join(codexHome, "skills", "review"),
|
||||
hasContent: true,
|
||||
},
|
||||
],
|
||||
);
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("respects provider enablement and instance environment", () =>
|
||||
Effect.gen(function* () {
|
||||
const fileSystem = yield* FileSystem.FileSystem;
|
||||
const path = yield* Path.Path;
|
||||
const tempDirectory = yield* fileSystem.makeTempDirectoryScoped({
|
||||
prefix: "t3-skill-inventory-environment-",
|
||||
});
|
||||
const codexHome = path.join(tempDirectory, "codex-env");
|
||||
const claudeHome = path.join(tempDirectory, "claude-env");
|
||||
const disabledCodexHome = path.join(tempDirectory, "codex-disabled");
|
||||
const disabledClaudeHome = path.join(tempDirectory, "claude-disabled");
|
||||
yield* writeSkill(codexHome, "codex-env-skill", "Loaded from CODEX_HOME.");
|
||||
yield* writeSkill(claudeHome, "claude-env-skill", "Loaded from CLAUDE_CONFIG_DIR.");
|
||||
yield* writeSkill(disabledCodexHome, "disabled-codex", "Must not appear.");
|
||||
yield* writeSkill(disabledClaudeHome, "disabled-claude", "Must not appear.");
|
||||
|
||||
const inventory = yield* discoverGlobalSkillInventory().pipe(
|
||||
Effect.provide(
|
||||
ServerSettings.layerTest({
|
||||
providers: {
|
||||
codex: decodeCodexSettings({ homePath: path.join(tempDirectory, "legacy-codex") }),
|
||||
claudeAgent: decodeClaudeSettings({
|
||||
homePath: path.join(tempDirectory, "legacy-claude"),
|
||||
}),
|
||||
},
|
||||
providerInstances: {
|
||||
[ProviderInstanceId.make("codex_env")]: {
|
||||
driver: ProviderDriverKind.make("codex"),
|
||||
environment: [{ name: "CODEX_HOME", value: codexHome, sensitive: false }],
|
||||
config: decodeCodexSettings({}),
|
||||
},
|
||||
[ProviderInstanceId.make("claude_env")]: {
|
||||
driver: ProviderDriverKind.make("claudeAgent"),
|
||||
environment: [{ name: "CLAUDE_CONFIG_DIR", value: claudeHome, sensitive: false }],
|
||||
config: decodeClaudeSettings({}),
|
||||
},
|
||||
[ProviderInstanceId.make("codex_disabled")]: {
|
||||
driver: ProviderDriverKind.make("codex"),
|
||||
enabled: false,
|
||||
config: decodeCodexSettings({ homePath: disabledCodexHome }),
|
||||
},
|
||||
[ProviderInstanceId.make("claude_disabled")]: {
|
||||
driver: ProviderDriverKind.make("claudeAgent"),
|
||||
config: decodeClaudeSettings({ enabled: false, homePath: disabledClaudeHome }),
|
||||
},
|
||||
},
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
assert.deepEqual(inventory.installations.map((skill) => skill.name).sort(), [
|
||||
"claude-env-skill",
|
||||
"codex-env-skill",
|
||||
]);
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("ignores unsupported provider instances", () =>
|
||||
Effect.gen(function* () {
|
||||
const fileSystem = yield* FileSystem.FileSystem;
|
||||
const path = yield* Path.Path;
|
||||
const tempDirectory = yield* fileSystem.makeTempDirectoryScoped({
|
||||
prefix: "t3-skill-inventory-empty-",
|
||||
});
|
||||
const inventory = yield* discoverGlobalSkillInventory().pipe(
|
||||
Effect.provide(
|
||||
ServerSettings.layerTest({
|
||||
providers: {
|
||||
codex: decodeCodexSettings({ homePath: path.join(tempDirectory, "codex") }),
|
||||
claudeAgent: decodeClaudeSettings({
|
||||
homePath: path.join(tempDirectory, "claude"),
|
||||
}),
|
||||
},
|
||||
providerInstances: {
|
||||
[ProviderInstanceId.make("opencode")]: {
|
||||
driver: ProviderDriverKind.make("opencode"),
|
||||
config: {},
|
||||
},
|
||||
},
|
||||
}),
|
||||
),
|
||||
);
|
||||
assert.deepEqual(inventory.installations, []);
|
||||
}),
|
||||
);
|
||||
});
|
||||
@@ -0,0 +1,136 @@
|
||||
import type {
|
||||
ProviderInstanceConfig,
|
||||
ServerProviderSkill,
|
||||
SkillInventory,
|
||||
SkillInventoryInstallation,
|
||||
} from "@t3tools/contracts";
|
||||
import { ClaudeSettings, CodexSettings, ProviderInstanceId } from "@t3tools/contracts";
|
||||
import * as Arr from "effect/Array";
|
||||
import * as DateTime from "effect/DateTime";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as FileSystem from "effect/FileSystem";
|
||||
import * as Path from "effect/Path";
|
||||
import * as Schema from "effect/Schema";
|
||||
|
||||
import { discoverClaudeSkills } from "../provider/Drivers/ClaudeSkills.ts";
|
||||
import { resolveCodexHomeLayout } from "../provider/Drivers/CodexHomeLayout.ts";
|
||||
import { deriveProviderInstanceConfigMap } from "../provider/Layers/ProviderInstanceRegistryHydration.ts";
|
||||
import { mergeProviderInstanceEnvironment } from "../provider/ProviderInstanceEnvironment.ts";
|
||||
import { ServerSettingsService } from "../serverSettings.ts";
|
||||
|
||||
const decodeCodexSettings = Schema.decodeUnknownOption(CodexSettings);
|
||||
const decodeClaudeSettings = Schema.decodeUnknownOption(ClaudeSettings);
|
||||
|
||||
function harnessDisplayName(instance: ProviderInstanceConfig, fallback: string): string {
|
||||
return instance.displayName?.trim() || fallback;
|
||||
}
|
||||
|
||||
export const readSkillInstallations = Effect.fn("SkillInventory.readSkillInstallations")(
|
||||
function* (input: {
|
||||
readonly instanceId: string;
|
||||
readonly instance: ProviderInstanceConfig;
|
||||
readonly fallbackDisplayName: string;
|
||||
readonly skills: ReadonlyArray<ServerProviderSkill>;
|
||||
}): Effect.fn.Return<
|
||||
ReadonlyArray<SkillInventoryInstallation>,
|
||||
never,
|
||||
FileSystem.FileSystem | Path.Path
|
||||
> {
|
||||
const fileSystem = yield* FileSystem.FileSystem;
|
||||
const path = yield* Path.Path;
|
||||
const installations = yield* Effect.forEach(input.skills, (skill) =>
|
||||
fileSystem.readFileString(skill.path).pipe(
|
||||
Effect.map((content) => ({
|
||||
providerInstanceId: ProviderInstanceId.make(input.instanceId),
|
||||
harness: input.instance.driver,
|
||||
harnessDisplayName: harnessDisplayName(input.instance, input.fallbackDisplayName),
|
||||
name: skill.name,
|
||||
...(skill.description ? { description: skill.description } : {}),
|
||||
directoryPath: path.dirname(skill.path),
|
||||
skillFilePath: skill.path,
|
||||
content,
|
||||
})),
|
||||
Effect.option,
|
||||
),
|
||||
);
|
||||
return Arr.getSomes(installations);
|
||||
},
|
||||
);
|
||||
|
||||
const discoverInstanceSkills = Effect.fn("SkillInventory.discoverInstanceSkills")(function* (
|
||||
instanceId: string,
|
||||
instance: ProviderInstanceConfig,
|
||||
): Effect.fn.Return<
|
||||
ReadonlyArray<SkillInventoryInstallation>,
|
||||
never,
|
||||
FileSystem.FileSystem | Path.Path
|
||||
> {
|
||||
const config = instance.config ?? {};
|
||||
const processEnv = mergeProviderInstanceEnvironment(instance.environment);
|
||||
|
||||
if (instance.driver === "codex") {
|
||||
const decoded = decodeCodexSettings(config);
|
||||
if (decoded._tag === "None") return [];
|
||||
if (!(instance.enabled ?? decoded.value.enabled)) return [];
|
||||
const configuredHomePath = decoded.value.homePath || processEnv.CODEX_HOME?.trim() || "";
|
||||
const layout = yield* resolveCodexHomeLayout({
|
||||
...decoded.value,
|
||||
homePath: configuredHomePath,
|
||||
});
|
||||
const skills = yield* discoverClaudeSkills(
|
||||
{ homePath: layout.sharedHomePath },
|
||||
undefined,
|
||||
processEnv,
|
||||
);
|
||||
return yield* readSkillInstallations({
|
||||
instanceId,
|
||||
instance,
|
||||
fallbackDisplayName: "Codex",
|
||||
skills,
|
||||
});
|
||||
}
|
||||
|
||||
if (instance.driver === "claudeAgent") {
|
||||
const decoded = decodeClaudeSettings(config);
|
||||
if (decoded._tag === "None") return [];
|
||||
if (!(instance.enabled ?? decoded.value.enabled)) return [];
|
||||
const skills = yield* discoverClaudeSkills(decoded.value, undefined, processEnv);
|
||||
return yield* readSkillInstallations({
|
||||
instanceId,
|
||||
instance,
|
||||
fallbackDisplayName: "Claude",
|
||||
skills,
|
||||
});
|
||||
}
|
||||
|
||||
// Cursor, Grok, and OpenCode do not expose compatible global skill directories.
|
||||
return [];
|
||||
});
|
||||
|
||||
export const discoverGlobalSkillInventory = Effect.fn(
|
||||
"SkillInventory.discoverGlobalSkillInventory",
|
||||
)(function* (): Effect.fn.Return<
|
||||
SkillInventory,
|
||||
never,
|
||||
FileSystem.FileSystem | Path.Path | ServerSettingsService
|
||||
> {
|
||||
const settingsService = yield* ServerSettingsService;
|
||||
const settings = yield* settingsService.getSettings.pipe(Effect.orDie);
|
||||
const providerInstances = deriveProviderInstanceConfigMap(settings);
|
||||
const installations = yield* Effect.forEach(
|
||||
Object.entries(providerInstances),
|
||||
([instanceId, instance]) => discoverInstanceSkills(instanceId, instance),
|
||||
{ concurrency: "unbounded" },
|
||||
);
|
||||
|
||||
return {
|
||||
scannedAt: DateTime.formatIso(yield* DateTime.now),
|
||||
installations: installations
|
||||
.flat()
|
||||
.sort(
|
||||
(left, right) =>
|
||||
left.harnessDisplayName.localeCompare(right.harnessDisplayName) ||
|
||||
left.name.localeCompare(right.name),
|
||||
),
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,19 @@
|
||||
import { AuthOrchestrationReadScope, EnvironmentHttpApi } from "@t3tools/contracts";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as HttpApiBuilder from "effect/unstable/httpapi/HttpApiBuilder";
|
||||
|
||||
import { annotateEnvironmentRequest, requireEnvironmentScope } from "../auth/http.ts";
|
||||
import { discoverGlobalSkillInventory } from "./SkillInventory.ts";
|
||||
|
||||
export const skillsHttpApiLayer = HttpApiBuilder.group(EnvironmentHttpApi, "skills", (handlers) =>
|
||||
Effect.succeed(
|
||||
handlers.handle(
|
||||
"inventory",
|
||||
Effect.fn("environment.skills.inventory")(function* (args) {
|
||||
yield* annotateEnvironmentRequest(args.endpoint.name);
|
||||
yield* requireEnvironmentScope(AuthOrchestrationReadScope);
|
||||
return yield* discoverGlobalSkillInventory();
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
Link2Icon,
|
||||
PaletteIcon,
|
||||
SearchIcon,
|
||||
SparklesIcon,
|
||||
Settings2Icon,
|
||||
XIcon,
|
||||
} from "lucide-react";
|
||||
@@ -50,6 +51,7 @@ const SETTINGS_SECTION_ICONS: Readonly<
|
||||
"/settings/appearance": PaletteIcon,
|
||||
"/settings/keybindings": KeyboardIcon,
|
||||
"/settings/providers": BotIcon,
|
||||
"/settings/skills": SparklesIcon,
|
||||
"/settings/source-control": GitBranchIcon,
|
||||
"/settings/connections": Link2Icon,
|
||||
"/settings/beta": FlaskConicalIcon,
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
import { ProviderDriverKind, ProviderInstanceId, type SkillInventory } from "@t3tools/contracts";
|
||||
|
||||
import {
|
||||
displayedSkillCount,
|
||||
filterSkillInventory,
|
||||
formatSkillCount,
|
||||
formatSkillPath,
|
||||
groupSkillsByHarness,
|
||||
setKeyCollapsed,
|
||||
skillContentForDisplay,
|
||||
} from "@t3tools/client-runtime/state/skills";
|
||||
|
||||
const inventory: SkillInventory = {
|
||||
scannedAt: "2026-07-27T12:00:00.000Z",
|
||||
installations: [
|
||||
{
|
||||
providerInstanceId: ProviderInstanceId.make("codex"),
|
||||
harness: ProviderDriverKind.make("codex"),
|
||||
harnessDisplayName: "Codex",
|
||||
name: "review",
|
||||
description: "Review changes",
|
||||
directoryPath: "/home/test/.codex/skills/review",
|
||||
skillFilePath: "/home/test/.codex/skills/review/SKILL.md",
|
||||
content: "---\nname: review\n---\n\n# Review",
|
||||
},
|
||||
{
|
||||
providerInstanceId: ProviderInstanceId.make("claude"),
|
||||
harness: ProviderDriverKind.make("claudeAgent"),
|
||||
harnessDisplayName: "Claude",
|
||||
name: "deploy",
|
||||
directoryPath: "/home/test/.claude/skills/deploy",
|
||||
skillFilePath: "/home/test/.claude/skills/deploy/SKILL.md",
|
||||
content: "---\nname: deploy\n---\n\n# Deploy",
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
describe("filterSkillInventory", () => {
|
||||
it("matches skill metadata, harnesses, and paths case-insensitively", () => {
|
||||
expect(
|
||||
filterSkillInventory(inventory, "REVIEW").installations.map((skill) => skill.name),
|
||||
).toEqual(["review"]);
|
||||
expect(
|
||||
filterSkillInventory(inventory, "Claude").installations.map((skill) => skill.name),
|
||||
).toEqual(["deploy"]);
|
||||
expect(
|
||||
filterSkillInventory(inventory, ".codex").installations.map((skill) => skill.name),
|
||||
).toEqual(["review"]);
|
||||
});
|
||||
|
||||
it("returns all installations for a blank query", () => {
|
||||
expect(filterSkillInventory(inventory, " ")).toBe(inventory);
|
||||
});
|
||||
});
|
||||
|
||||
describe("formatSkillPath", () => {
|
||||
it("shortens home-relative and deep paths for display", () => {
|
||||
expect(formatSkillPath("/home/theo/.claude/skills/review")).toBe("~/.claude/skills/review");
|
||||
expect(formatSkillPath("/home/theo/skills/review")).toBe("~/skills/review");
|
||||
expect(formatSkillPath("/var/lib/t3/skills/review")).toBe("…/t3/skills/review");
|
||||
});
|
||||
});
|
||||
|
||||
describe("skill explorer helpers", () => {
|
||||
it("hides a previously loaded skill count after disconnecting", () => {
|
||||
expect(displayedSkillCount(inventory, true)).toBe(2);
|
||||
expect(displayedSkillCount(inventory, false)).toBeNull();
|
||||
expect(displayedSkillCount(null, true)).toBeNull();
|
||||
});
|
||||
|
||||
it("labels filtered skill counts without hiding the installed total", () => {
|
||||
expect(formatSkillCount(12)).toBe("12 skills");
|
||||
expect(formatSkillCount(1)).toBe("1 skill");
|
||||
expect(formatSkillCount(12, 2)).toBe("2 of 12 skills");
|
||||
});
|
||||
|
||||
it("applies the requested harness collapsed state without toggling blindly", () => {
|
||||
const collapsed = setKeyCollapsed(new Set<string>(), "codex", true);
|
||||
expect([...collapsed]).toEqual(["codex"]);
|
||||
expect([...setKeyCollapsed(collapsed, "codex", true)]).toEqual(["codex"]);
|
||||
expect([...setKeyCollapsed(collapsed, "codex", false)]).toEqual([]);
|
||||
});
|
||||
|
||||
it("groups installations by harness instance and derives their shared root", () => {
|
||||
const groups = groupSkillsByHarness(inventory.installations);
|
||||
expect(
|
||||
groups.map((group) => ({
|
||||
name: group.harnessDisplayName,
|
||||
rootPath: group.rootPath,
|
||||
skills: group.skills.map((skill) => skill.name),
|
||||
})),
|
||||
).toEqual([
|
||||
{
|
||||
name: "Codex",
|
||||
rootPath: "/home/test/.codex/skills",
|
||||
skills: ["review"],
|
||||
},
|
||||
{
|
||||
name: "Claude",
|
||||
rootPath: "/home/test/.claude/skills",
|
||||
skills: ["deploy"],
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("normalizes empty skill content for the detail view", () => {
|
||||
expect(skillContentForDisplay(" \n ")).toBeNull();
|
||||
expect(skillContentForDisplay("\n# Review\n")).toBe("# Review");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,418 @@
|
||||
import { CheckIcon, ChevronRightIcon, CopyIcon, RefreshCwIcon, SparklesIcon } from "lucide-react";
|
||||
import type { SkillInventory, SkillInventoryInstallation } from "@t3tools/contracts";
|
||||
import * as Option from "effect/Option";
|
||||
import { useCallback, useEffect, useId, useMemo, useState } from "react";
|
||||
|
||||
import {
|
||||
displayedSkillCount,
|
||||
fetchEnvironmentSkillInventory,
|
||||
filterSkillInventory,
|
||||
formatSkillCount,
|
||||
formatSkillPath,
|
||||
groupSkillsByHarness,
|
||||
setKeyCollapsed,
|
||||
skillContentForDisplay,
|
||||
skillKey,
|
||||
} from "@t3tools/client-runtime/state/skills";
|
||||
import { cn } from "../../lib/utils";
|
||||
import { runtime } from "../../lib/runtime";
|
||||
import { useCopyToClipboard } from "../../hooks/useCopyToClipboard";
|
||||
import { type EnvironmentPresentation, useEnvironments } from "../../state/environments";
|
||||
import { usePreparedConnection } from "../../state/session";
|
||||
import { ConnectionStatusDot } from "../ConnectionStatusDot";
|
||||
import { PROVIDER_ICON_BY_PROVIDER } from "../chat/providerIconUtils";
|
||||
import { Button } from "../ui/button";
|
||||
import { Collapsible, CollapsibleContent } from "../ui/collapsible";
|
||||
import { Input } from "../ui/input";
|
||||
import { ScrollArea } from "../ui/scroll-area";
|
||||
import { toastManager } from "../ui/toast";
|
||||
import { SettingsPageContainer, SettingsSection } from "./settingsLayout";
|
||||
import { searchableSetting } from "./settingsSearch";
|
||||
|
||||
type InventoryState =
|
||||
| { readonly status: "loading" }
|
||||
| { readonly status: "loaded"; readonly inventory: SkillInventory }
|
||||
| { readonly status: "error"; readonly message: string };
|
||||
|
||||
function errorMessage(cause: unknown): string {
|
||||
return cause instanceof Error && cause.message.trim() ? cause.message : "Could not load skills.";
|
||||
}
|
||||
|
||||
function connectionDotClassName(phase: string): string {
|
||||
if (phase === "connected") return "bg-success";
|
||||
if (phase === "connecting" || phase === "reconnecting") return "bg-warning";
|
||||
if (phase === "error") return "bg-destructive";
|
||||
return "bg-muted-foreground/40";
|
||||
}
|
||||
|
||||
/** Chevron that points right when collapsed and down when open. */
|
||||
function DisclosureChevron({ open, className }: { open: boolean; className?: string }) {
|
||||
return (
|
||||
<ChevronRightIcon
|
||||
aria-hidden
|
||||
className={cn(
|
||||
"size-3.5 shrink-0 text-muted-foreground/60 transition-transform",
|
||||
open && "rotate-90",
|
||||
className,
|
||||
)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function StatusLine({ children, tone }: { children: string; tone?: "error" }) {
|
||||
return (
|
||||
<p
|
||||
className={cn(
|
||||
"py-2 pl-9 pr-3 text-[13px] sm:pr-4",
|
||||
tone === "error" ? "text-destructive" : "text-muted-foreground/80",
|
||||
)}
|
||||
>
|
||||
{children}
|
||||
</p>
|
||||
);
|
||||
}
|
||||
|
||||
export function SkillsSettings() {
|
||||
const { environments } = useEnvironments();
|
||||
const [query, setQuery] = useState("");
|
||||
const [refreshKey, setRefreshKey] = useState(0);
|
||||
|
||||
return (
|
||||
<SettingsPageContainer>
|
||||
<SettingsSection
|
||||
id={searchableSetting("skills").id}
|
||||
title="Skills"
|
||||
icon={<SparklesIcon className="size-4 text-muted-foreground" />}
|
||||
headerAction={
|
||||
<Button size="xs" variant="ghost" onClick={() => setRefreshKey((value) => value + 1)}>
|
||||
<RefreshCwIcon className="size-3.5" />
|
||||
Refresh all
|
||||
</Button>
|
||||
}
|
||||
>
|
||||
<div className="space-y-2.5 px-3 pb-3 sm:px-4">
|
||||
<p className="max-w-xl text-[13px] leading-[1.45] text-muted-foreground/80">
|
||||
Global skills discovered by Codex and Claude on each connected computer. Paths refer to
|
||||
the computer where the skill is installed.
|
||||
</p>
|
||||
<Input
|
||||
type="search"
|
||||
nativeInput
|
||||
value={query}
|
||||
onChange={(event) => setQuery(event.target.value)}
|
||||
placeholder="Search skills, harnesses, or paths"
|
||||
aria-label="Search skills"
|
||||
className="max-w-sm"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="divide-y divide-border/50 border-t border-border/50">
|
||||
{environments.map((environment) => (
|
||||
<EnvironmentSkillInventory
|
||||
key={environment.environmentId}
|
||||
environment={environment}
|
||||
query={query}
|
||||
refreshKey={refreshKey}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</SettingsSection>
|
||||
</SettingsPageContainer>
|
||||
);
|
||||
}
|
||||
|
||||
function EnvironmentSkillInventory({
|
||||
environment,
|
||||
query,
|
||||
refreshKey,
|
||||
}: {
|
||||
environment: EnvironmentPresentation;
|
||||
query: string;
|
||||
refreshKey: number;
|
||||
}) {
|
||||
const prepared = usePreparedConnection(environment.environmentId);
|
||||
const [state, setState] = useState<InventoryState>({ status: "loading" });
|
||||
const [collapsed, setCollapsed] = useState(false);
|
||||
const panelId = useId();
|
||||
|
||||
useEffect(() => {
|
||||
if (Option.isNone(prepared)) return;
|
||||
let cancelled = false;
|
||||
setState({ status: "loading" });
|
||||
void runtime
|
||||
.runPromise(fetchEnvironmentSkillInventory({ prepared: prepared.value }))
|
||||
.then((inventory) => {
|
||||
if (!cancelled) setState({ status: "loaded", inventory });
|
||||
})
|
||||
.catch((cause: unknown) => {
|
||||
if (!cancelled) setState({ status: "error", message: errorMessage(cause) });
|
||||
});
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, [prepared, refreshKey]);
|
||||
|
||||
const visibleInventory = useMemo(
|
||||
() => (state.status === "loaded" ? filterSkillInventory(state.inventory, query) : null),
|
||||
[query, state],
|
||||
);
|
||||
const isConnected = Option.isSome(prepared);
|
||||
const skillCount = displayedSkillCount(
|
||||
state.status === "loaded" ? state.inventory : null,
|
||||
isConnected,
|
||||
);
|
||||
const visibleSkillCount = displayedSkillCount(visibleInventory, isConnected);
|
||||
const phase = environment.connection.phase;
|
||||
const isSearching = query.trim().length > 0;
|
||||
const open = isSearching || !collapsed;
|
||||
const setOpen = (nextOpen: boolean) => {
|
||||
if (!isSearching) setCollapsed(!nextOpen);
|
||||
};
|
||||
|
||||
return (
|
||||
<section>
|
||||
{/* The status dot is its own tooltip trigger, so it stays a sibling of
|
||||
the disclosure button rather than nesting inside it. */}
|
||||
<div className="flex min-w-0 items-center gap-2 pr-3 sm:pr-4">
|
||||
<h3 className="contents">
|
||||
<button
|
||||
type="button"
|
||||
aria-expanded={open}
|
||||
// The panel unmounts while closed, so only reference it when open.
|
||||
aria-controls={open ? panelId : undefined}
|
||||
onClick={() => setOpen(!open)}
|
||||
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"
|
||||
>
|
||||
<DisclosureChevron open={open} />
|
||||
<span className="min-w-0 flex-1 truncate text-sm font-medium text-foreground">
|
||||
{environment.label}
|
||||
</span>
|
||||
</button>
|
||||
</h3>
|
||||
<ConnectionStatusDot
|
||||
tooltipText={phase}
|
||||
dotClassName={connectionDotClassName(phase)}
|
||||
pingClassName={
|
||||
phase === "connecting" || phase === "reconnecting"
|
||||
? "bg-warning/60 duration-2000"
|
||||
: null
|
||||
}
|
||||
/>
|
||||
{skillCount !== null ? (
|
||||
<span className="shrink-0 font-mono text-[11px] tabular-nums text-muted-foreground/70">
|
||||
{formatSkillCount(skillCount, isSearching ? (visibleSkillCount ?? 0) : undefined)}
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
<Collapsible open={open} onOpenChange={setOpen}>
|
||||
<CollapsibleContent id={panelId}>
|
||||
<div className="pb-2">
|
||||
{Option.isNone(prepared) ? (
|
||||
<StatusLine>Connect to this computer to inspect its skills.</StatusLine>
|
||||
) : state.status === "loading" ? (
|
||||
<StatusLine>Scanning skills…</StatusLine>
|
||||
) : state.status === "error" ? (
|
||||
<StatusLine tone="error">{state.message}</StatusLine>
|
||||
) : visibleInventory?.installations.length === 0 ? (
|
||||
<StatusLine>
|
||||
{query ? "No skills match this search." : "No global Codex or Claude skills found."}
|
||||
</StatusLine>
|
||||
) : visibleInventory ? (
|
||||
<SkillHarnessGroups inventory={visibleInventory} isSearching={isSearching} />
|
||||
) : null}
|
||||
</div>
|
||||
</CollapsibleContent>
|
||||
</Collapsible>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
function SkillHarnessGroups({
|
||||
inventory,
|
||||
isSearching,
|
||||
}: {
|
||||
inventory: SkillInventory;
|
||||
isSearching: boolean;
|
||||
}) {
|
||||
const [collapsedHarnesses, setCollapsedHarnesses] = useState<ReadonlySet<string>>(
|
||||
() => new Set(),
|
||||
);
|
||||
const groups = useMemo(() => groupSkillsByHarness(inventory.installations), [inventory]);
|
||||
|
||||
return groups.map((group) => (
|
||||
<SkillHarnessGroup
|
||||
key={group.key}
|
||||
harnessDisplayName={group.harnessDisplayName}
|
||||
harness={group.harness}
|
||||
rootPath={group.rootPath}
|
||||
skills={group.skills}
|
||||
open={isSearching || !collapsedHarnesses.has(group.key)}
|
||||
onOpenChange={(nextOpen) => {
|
||||
if (!isSearching) {
|
||||
setCollapsedHarnesses((keys) => setKeyCollapsed(keys, group.key, !nextOpen));
|
||||
}
|
||||
}}
|
||||
/>
|
||||
));
|
||||
}
|
||||
|
||||
function SkillHarnessGroup({
|
||||
harnessDisplayName,
|
||||
harness,
|
||||
rootPath,
|
||||
skills,
|
||||
open,
|
||||
onOpenChange,
|
||||
}: {
|
||||
harnessDisplayName: string;
|
||||
harness: SkillInventoryInstallation["harness"];
|
||||
rootPath: string | null;
|
||||
skills: ReadonlyArray<SkillInventoryInstallation>;
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
}) {
|
||||
const panelId = useId();
|
||||
const HarnessIcon = PROVIDER_ICON_BY_PROVIDER[harness] ?? null;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<button
|
||||
type="button"
|
||||
aria-expanded={open}
|
||||
aria-controls={open ? panelId : undefined}
|
||||
onClick={() => onOpenChange(!open)}
|
||||
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"
|
||||
>
|
||||
<DisclosureChevron open={open} className="size-3" />
|
||||
{HarnessIcon ? <HarnessIcon aria-hidden className="size-3.5 shrink-0" /> : null}
|
||||
<span className="shrink-0 text-[11px] font-semibold uppercase tracking-[0.08em] text-muted-foreground/70">
|
||||
{harnessDisplayName}
|
||||
</span>
|
||||
<span className="shrink-0 font-mono text-[11px] tabular-nums text-muted-foreground/50">
|
||||
{skills.length}
|
||||
</span>
|
||||
{rootPath ? (
|
||||
<span className="hidden min-w-0 flex-1 truncate text-right font-mono text-[11px] text-muted-foreground/40 sm:block">
|
||||
{formatSkillPath(rootPath)}
|
||||
</span>
|
||||
) : null}
|
||||
</button>
|
||||
|
||||
<Collapsible open={open} onOpenChange={onOpenChange}>
|
||||
<CollapsibleContent id={panelId}>
|
||||
{skills.map((skill) => (
|
||||
<SkillRow key={skillKey(skill)} skill={skill} />
|
||||
))}
|
||||
</CollapsibleContent>
|
||||
</Collapsible>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function SkillRow({ skill }: { skill: SkillInventoryInstallation }) {
|
||||
const [open, setOpen] = useState(false);
|
||||
const panelId = useId();
|
||||
|
||||
return (
|
||||
<div>
|
||||
<button
|
||||
type="button"
|
||||
aria-expanded={open}
|
||||
aria-controls={open ? panelId : undefined}
|
||||
onClick={() => setOpen((value) => !value)}
|
||||
className={cn(
|
||||
"flex w-full min-w-0 cursor-pointer items-center gap-2 rounded-lg py-1.5 pl-9 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-11 sm:pr-4",
|
||||
open && "bg-muted/20",
|
||||
)}
|
||||
>
|
||||
<DisclosureChevron open={open} className="size-3" />
|
||||
<span className="min-w-0 truncate text-[13px] font-medium text-foreground sm:w-44 sm:shrink-0 lg:w-52">
|
||||
{skill.name}
|
||||
</span>
|
||||
{skill.description ? (
|
||||
<span className="min-w-0 flex-1 truncate text-[12px] text-muted-foreground/70">
|
||||
{skill.description}
|
||||
</span>
|
||||
) : (
|
||||
<span className="min-w-0 flex-1" />
|
||||
)}
|
||||
<span className="hidden w-56 shrink-0 truncate text-right font-mono text-[11px] text-muted-foreground/40 lg:block">
|
||||
{formatSkillPath(skill.directoryPath)}
|
||||
</span>
|
||||
</button>
|
||||
|
||||
<Collapsible open={open} onOpenChange={setOpen}>
|
||||
<CollapsibleContent id={panelId}>
|
||||
<SkillDetail skill={skill} />
|
||||
</CollapsibleContent>
|
||||
</Collapsible>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function SkillDetail({ skill }: { skill: SkillInventoryInstallation }) {
|
||||
const content = skillContentForDisplay(skill.content);
|
||||
const { copyToClipboard, isCopied } = useCopyToClipboard({
|
||||
target: "skill path",
|
||||
timeout: 1_500,
|
||||
onError: () => toastManager.add({ type: "error", title: "Could not copy skill path" }),
|
||||
});
|
||||
const copyPath = useCallback(
|
||||
() => copyToClipboard(skill.directoryPath),
|
||||
[copyToClipboard, skill.directoryPath],
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="mx-3 mt-2 mb-5 space-y-4 rounded-lg border border-border/60 bg-muted/10 p-4 sm:ml-11 sm:mr-4 sm:p-5">
|
||||
<div className="space-y-1">
|
||||
<h4 className="text-sm font-semibold text-foreground">{skill.name}</h4>
|
||||
<p className="max-w-3xl text-[13px] leading-6 text-muted-foreground/85">
|
||||
{skill.description ?? "No description in this skill's frontmatter."}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="space-y-1.5">
|
||||
<span className="text-[11px] font-medium uppercase tracking-[0.08em] text-muted-foreground/60">
|
||||
Installed at
|
||||
</span>
|
||||
<div className="flex flex-col gap-2 sm:flex-row sm:items-center">
|
||||
<code className="min-w-0 flex-1 break-all rounded-md bg-muted/40 px-2.5 py-1.5 font-mono text-[11px] leading-[1.5] text-muted-foreground">
|
||||
{skill.directoryPath}
|
||||
</code>
|
||||
<Button
|
||||
size="xs"
|
||||
variant="outline"
|
||||
onClick={copyPath}
|
||||
aria-label={`Copy path for ${skill.name}`}
|
||||
>
|
||||
{isCopied ? <CheckIcon className="size-3.5" /> : <CopyIcon className="size-3.5" />}
|
||||
{isCopied ? "Copied" : "Copy path"}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="overflow-hidden rounded-md border border-border/60">
|
||||
<div className="flex items-center justify-between gap-2 border-b border-border/50 bg-muted/25 px-3 py-2">
|
||||
<span className="text-[11px] font-medium uppercase tracking-[0.08em] text-muted-foreground/70">
|
||||
SKILL.md
|
||||
</span>
|
||||
<span className="min-w-0 truncate font-mono text-[11px] text-muted-foreground/40">
|
||||
{formatSkillPath(skill.skillFilePath)}
|
||||
</span>
|
||||
</div>
|
||||
{content ? (
|
||||
<ScrollArea chainVerticalScroll className="max-h-[32rem] w-full rounded-none">
|
||||
<pre className="whitespace-pre-wrap break-words px-4 py-4 font-mono text-xs leading-7 text-muted-foreground/90">
|
||||
{content}
|
||||
</pre>
|
||||
</ScrollArea>
|
||||
) : (
|
||||
<p className="px-2.5 py-2 text-[12px] text-muted-foreground/70">
|
||||
This SKILL.md file is empty.
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -84,4 +84,11 @@ describe("searchSettings", () => {
|
||||
targetId: "appearance",
|
||||
});
|
||||
});
|
||||
|
||||
it("routes skill settings to the skill manager", () => {
|
||||
expect(searchSettings("skills")[0]).toMatchObject({
|
||||
id: "skills",
|
||||
to: "/settings/skills",
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -3,6 +3,7 @@ export type SettingsPath =
|
||||
| "/settings/appearance"
|
||||
| "/settings/keybindings"
|
||||
| "/settings/providers"
|
||||
| "/settings/skills"
|
||||
| "/settings/source-control"
|
||||
| "/settings/connections"
|
||||
| "/settings/beta"
|
||||
@@ -24,6 +25,7 @@ export const SETTINGS_SECTION_LABELS: Readonly<Record<SettingsPath, string>> = {
|
||||
"/settings/appearance": "Appearance",
|
||||
"/settings/keybindings": "Keybindings",
|
||||
"/settings/providers": "Providers",
|
||||
"/settings/skills": "Skills",
|
||||
"/settings/source-control": "Source Control",
|
||||
"/settings/connections": "Connections",
|
||||
"/settings/beta": "Beta",
|
||||
@@ -166,6 +168,11 @@ export const SETTINGS_SEARCH_ITEMS = [
|
||||
title: "Providers",
|
||||
to: "/settings/providers",
|
||||
},
|
||||
{
|
||||
id: "skills",
|
||||
title: "Skills",
|
||||
to: "/settings/skills",
|
||||
},
|
||||
{
|
||||
id: "source-control",
|
||||
title: "Source control",
|
||||
|
||||
@@ -15,6 +15,7 @@ import { Route as ConnectRouteImport } from './routes/connect'
|
||||
import { Route as ChatRouteImport } from './routes/_chat'
|
||||
import { Route as ChatIndexRouteImport } from './routes/_chat.index'
|
||||
import { Route as SettingsSourceControlRouteImport } from './routes/settings.source-control'
|
||||
import { Route as SettingsSkillsRouteImport } from './routes/settings.skills'
|
||||
import { Route as SettingsProvidersRouteImport } from './routes/settings.providers'
|
||||
import { Route as SettingsKeybindingsRouteImport } from './routes/settings.keybindings'
|
||||
import { Route as SettingsGeneralRouteImport } from './routes/settings.general'
|
||||
@@ -56,6 +57,11 @@ const SettingsSourceControlRoute = SettingsSourceControlRouteImport.update({
|
||||
path: '/source-control',
|
||||
getParentRoute: () => SettingsRoute,
|
||||
} as any)
|
||||
const SettingsSkillsRoute = SettingsSkillsRouteImport.update({
|
||||
id: '/skills',
|
||||
path: '/skills',
|
||||
getParentRoute: () => SettingsRoute,
|
||||
} as any)
|
||||
const SettingsProvidersRoute = SettingsProvidersRouteImport.update({
|
||||
id: '/providers',
|
||||
path: '/providers',
|
||||
@@ -127,6 +133,7 @@ export interface FileRoutesByFullPath {
|
||||
'/settings/general': typeof SettingsGeneralRoute
|
||||
'/settings/keybindings': typeof SettingsKeybindingsRoute
|
||||
'/settings/providers': typeof SettingsProvidersRoute
|
||||
'/settings/skills': typeof SettingsSkillsRoute
|
||||
'/settings/source-control': typeof SettingsSourceControlRoute
|
||||
'/$environmentId/$threadId': typeof ChatEnvironmentIdThreadIdRoute
|
||||
'/draft/$draftId': typeof ChatDraftDraftIdRoute
|
||||
@@ -144,6 +151,7 @@ export interface FileRoutesByTo {
|
||||
'/settings/general': typeof SettingsGeneralRoute
|
||||
'/settings/keybindings': typeof SettingsKeybindingsRoute
|
||||
'/settings/providers': typeof SettingsProvidersRoute
|
||||
'/settings/skills': typeof SettingsSkillsRoute
|
||||
'/settings/source-control': typeof SettingsSourceControlRoute
|
||||
'/': typeof ChatIndexRoute
|
||||
'/$environmentId/$threadId': typeof ChatEnvironmentIdThreadIdRoute
|
||||
@@ -164,6 +172,7 @@ export interface FileRoutesById {
|
||||
'/settings/general': typeof SettingsGeneralRoute
|
||||
'/settings/keybindings': typeof SettingsKeybindingsRoute
|
||||
'/settings/providers': typeof SettingsProvidersRoute
|
||||
'/settings/skills': typeof SettingsSkillsRoute
|
||||
'/settings/source-control': typeof SettingsSourceControlRoute
|
||||
'/_chat/': typeof ChatIndexRoute
|
||||
'/_chat/$environmentId/$threadId': typeof ChatEnvironmentIdThreadIdRoute
|
||||
@@ -185,6 +194,7 @@ export interface FileRouteTypes {
|
||||
| '/settings/general'
|
||||
| '/settings/keybindings'
|
||||
| '/settings/providers'
|
||||
| '/settings/skills'
|
||||
| '/settings/source-control'
|
||||
| '/$environmentId/$threadId'
|
||||
| '/draft/$draftId'
|
||||
@@ -202,6 +212,7 @@ export interface FileRouteTypes {
|
||||
| '/settings/general'
|
||||
| '/settings/keybindings'
|
||||
| '/settings/providers'
|
||||
| '/settings/skills'
|
||||
| '/settings/source-control'
|
||||
| '/'
|
||||
| '/$environmentId/$threadId'
|
||||
@@ -221,6 +232,7 @@ export interface FileRouteTypes {
|
||||
| '/settings/general'
|
||||
| '/settings/keybindings'
|
||||
| '/settings/providers'
|
||||
| '/settings/skills'
|
||||
| '/settings/source-control'
|
||||
| '/_chat/'
|
||||
| '/_chat/$environmentId/$threadId'
|
||||
@@ -279,6 +291,13 @@ declare module '@tanstack/react-router' {
|
||||
preLoaderRoute: typeof SettingsSourceControlRouteImport
|
||||
parentRoute: typeof SettingsRoute
|
||||
}
|
||||
'/settings/skills': {
|
||||
id: '/settings/skills'
|
||||
path: '/skills'
|
||||
fullPath: '/settings/skills'
|
||||
preLoaderRoute: typeof SettingsSkillsRouteImport
|
||||
parentRoute: typeof SettingsRoute
|
||||
}
|
||||
'/settings/providers': {
|
||||
id: '/settings/providers'
|
||||
path: '/providers'
|
||||
@@ -382,6 +401,7 @@ interface SettingsRouteChildren {
|
||||
SettingsGeneralRoute: typeof SettingsGeneralRoute
|
||||
SettingsKeybindingsRoute: typeof SettingsKeybindingsRoute
|
||||
SettingsProvidersRoute: typeof SettingsProvidersRoute
|
||||
SettingsSkillsRoute: typeof SettingsSkillsRoute
|
||||
SettingsSourceControlRoute: typeof SettingsSourceControlRoute
|
||||
}
|
||||
|
||||
@@ -394,6 +414,7 @@ const SettingsRouteChildren: SettingsRouteChildren = {
|
||||
SettingsGeneralRoute: SettingsGeneralRoute,
|
||||
SettingsKeybindingsRoute: SettingsKeybindingsRoute,
|
||||
SettingsProvidersRoute: SettingsProvidersRoute,
|
||||
SettingsSkillsRoute: SettingsSkillsRoute,
|
||||
SettingsSourceControlRoute: SettingsSourceControlRoute,
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
|
||||
import { SkillsSettings } from "../components/settings/SkillsSettings";
|
||||
|
||||
export const Route = createFileRoute("/settings/skills")({
|
||||
component: SkillsSettings,
|
||||
});
|
||||
@@ -0,0 +1,839 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>T3 Code Skill Manager — Exploration & Implementation Plan</title>
|
||||
<style>
|
||||
:root {
|
||||
color-scheme: dark;
|
||||
--bg: #000;
|
||||
--panel: #101010;
|
||||
--panel2: #171717;
|
||||
--line: #2b2b2b;
|
||||
--text: #fff;
|
||||
--muted: #aaa;
|
||||
--dim: #777;
|
||||
--pink: #f472d0;
|
||||
--green: #68d391;
|
||||
--yellow: #f6c85f;
|
||||
--red: #ff7272;
|
||||
--blue: #77bdfb;
|
||||
}
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
html {
|
||||
scroll-behavior: smooth;
|
||||
}
|
||||
body {
|
||||
margin: 0;
|
||||
background: var(--bg);
|
||||
color: var(--text);
|
||||
font:
|
||||
15px/1.55 ui-sans-serif,
|
||||
system-ui,
|
||||
-apple-system,
|
||||
BlinkMacSystemFont,
|
||||
"Segoe UI",
|
||||
sans-serif;
|
||||
}
|
||||
a {
|
||||
color: var(--blue);
|
||||
}
|
||||
code {
|
||||
color: #eee;
|
||||
background: #202020;
|
||||
padding: 0.12rem 0.34rem;
|
||||
border-radius: 4px;
|
||||
font:
|
||||
12px/1.4 ui-monospace,
|
||||
SFMono-Regular,
|
||||
Consolas,
|
||||
monospace;
|
||||
}
|
||||
.shell {
|
||||
max-width: 1180px;
|
||||
margin: auto;
|
||||
padding: 42px 22px 90px;
|
||||
}
|
||||
.eyebrow {
|
||||
color: var(--pink);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.14em;
|
||||
font-size: 11px;
|
||||
font-weight: 800;
|
||||
}
|
||||
h1 {
|
||||
font-size: clamp(38px, 7vw, 72px);
|
||||
line-height: 0.98;
|
||||
letter-spacing: -0.055em;
|
||||
max-width: 880px;
|
||||
margin: 14px 0 24px;
|
||||
}
|
||||
h2 {
|
||||
font-size: 28px;
|
||||
letter-spacing: -0.025em;
|
||||
margin: 0 0 14px;
|
||||
}
|
||||
h3 {
|
||||
margin: 0 0 8px;
|
||||
font-size: 17px;
|
||||
}
|
||||
p {
|
||||
margin: 0 0 14px;
|
||||
}
|
||||
.lead {
|
||||
max-width: 840px;
|
||||
color: #d0d0d0;
|
||||
font-size: 19px;
|
||||
}
|
||||
.verdict {
|
||||
display: grid;
|
||||
grid-template-columns: 160px 1fr;
|
||||
gap: 20px;
|
||||
border: 1px solid #28583a;
|
||||
background: #07130b;
|
||||
padding: 22px;
|
||||
margin: 34px 0;
|
||||
border-radius: 12px;
|
||||
}
|
||||
.score {
|
||||
font-size: 42px;
|
||||
font-weight: 850;
|
||||
color: var(--green);
|
||||
letter-spacing: -0.05em;
|
||||
}
|
||||
.score small {
|
||||
display: block;
|
||||
font-size: 11px;
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
color: #8ecba4;
|
||||
}
|
||||
nav {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 3;
|
||||
background: rgba(0, 0, 0, 0.88);
|
||||
backdrop-filter: blur(12px);
|
||||
border-block: 1px solid var(--line);
|
||||
margin: 34px -22px;
|
||||
padding: 10px 22px;
|
||||
display: flex;
|
||||
gap: 18px;
|
||||
overflow: auto;
|
||||
white-space: nowrap;
|
||||
}
|
||||
nav a {
|
||||
color: var(--muted);
|
||||
text-decoration: none;
|
||||
font-size: 12px;
|
||||
}
|
||||
nav a:hover {
|
||||
color: #fff;
|
||||
}
|
||||
section {
|
||||
padding: 42px 0;
|
||||
border-bottom: 1px solid var(--line);
|
||||
}
|
||||
.grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(12, 1fr);
|
||||
gap: 14px;
|
||||
}
|
||||
.card {
|
||||
grid-column: span 4;
|
||||
border: 1px solid var(--line);
|
||||
background: var(--panel);
|
||||
padding: 18px;
|
||||
border-radius: 10px;
|
||||
}
|
||||
.wide {
|
||||
grid-column: span 6;
|
||||
}
|
||||
.full {
|
||||
grid-column: 1/-1;
|
||||
}
|
||||
.card p,
|
||||
.muted {
|
||||
color: var(--muted);
|
||||
}
|
||||
.tag {
|
||||
display: inline-block;
|
||||
border: 1px solid var(--line);
|
||||
background: #191919;
|
||||
border-radius: 99px;
|
||||
padding: 2px 8px;
|
||||
color: #bbb;
|
||||
font-size: 11px;
|
||||
margin: 2px 3px 2px 0;
|
||||
}
|
||||
.yes {
|
||||
color: var(--green);
|
||||
}
|
||||
.partial {
|
||||
color: var(--yellow);
|
||||
}
|
||||
.no {
|
||||
color: var(--red);
|
||||
}
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
font-size: 13px;
|
||||
}
|
||||
th,
|
||||
td {
|
||||
padding: 11px 10px;
|
||||
text-align: left;
|
||||
border-bottom: 1px solid var(--line);
|
||||
vertical-align: top;
|
||||
}
|
||||
th {
|
||||
color: #888;
|
||||
font-size: 11px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.08em;
|
||||
}
|
||||
ul,
|
||||
ol {
|
||||
margin: 8px 0 0;
|
||||
padding-left: 20px;
|
||||
}
|
||||
li {
|
||||
margin: 5px 0;
|
||||
}
|
||||
.callout {
|
||||
border-left: 3px solid var(--yellow);
|
||||
background: #171307;
|
||||
padding: 14px 16px;
|
||||
color: #ddd;
|
||||
margin: 16px 0;
|
||||
}
|
||||
.good {
|
||||
border-left-color: var(--green);
|
||||
background: #07130b;
|
||||
}
|
||||
.danger {
|
||||
border-left-color: var(--red);
|
||||
background: #180909;
|
||||
}
|
||||
.diagram {
|
||||
overflow: auto;
|
||||
padding: 24px;
|
||||
background: #080808;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 10px;
|
||||
}
|
||||
.flow {
|
||||
min-width: 790px;
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 60px 1fr 60px 1fr;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
.node {
|
||||
border: 1px solid #3b3b3b;
|
||||
border-radius: 9px;
|
||||
padding: 16px;
|
||||
background: #141414;
|
||||
text-align: center;
|
||||
}
|
||||
.arrow {
|
||||
text-align: center;
|
||||
color: var(--pink);
|
||||
font-size: 24px;
|
||||
}
|
||||
.mock {
|
||||
border: 1px solid #333;
|
||||
background: #090909;
|
||||
border-radius: 12px;
|
||||
overflow: hidden;
|
||||
}
|
||||
.mockbar {
|
||||
padding: 12px 16px;
|
||||
border-bottom: 1px solid #272727;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.machine {
|
||||
margin: 12px;
|
||||
border: 1px solid #292929;
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
}
|
||||
.machine-head {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding: 12px 14px;
|
||||
background: #141414;
|
||||
}
|
||||
.harness {
|
||||
padding: 12px 14px;
|
||||
border-top: 1px solid #252525;
|
||||
}
|
||||
.skill {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(150px, 1fr) minmax(220px, 2fr) auto;
|
||||
gap: 12px;
|
||||
padding: 9px 0;
|
||||
border-top: 1px solid #1f1f1f;
|
||||
align-items: center;
|
||||
}
|
||||
.button {
|
||||
border: 1px solid #3b3b3b;
|
||||
border-radius: 6px;
|
||||
padding: 5px 8px;
|
||||
color: #ccc;
|
||||
font-size: 11px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.phase {
|
||||
grid-column: span 3;
|
||||
position: relative;
|
||||
}
|
||||
.phase b {
|
||||
color: var(--pink);
|
||||
font-size: 12px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.08em;
|
||||
}
|
||||
.checklist input {
|
||||
accent-color: var(--pink);
|
||||
}
|
||||
footer {
|
||||
padding-top: 28px;
|
||||
color: var(--dim);
|
||||
font-size: 12px;
|
||||
}
|
||||
@media (max-width: 760px) {
|
||||
.card,
|
||||
.wide,
|
||||
.phase {
|
||||
grid-column: 1/-1;
|
||||
}
|
||||
.verdict {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
.skill {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<main class="shell">
|
||||
<div class="eyebrow">Product exploration · July 2026</div>
|
||||
<h1>A skill manager for every harness, on every computer.</h1>
|
||||
<p class="lead">
|
||||
A settings page that inventories skill installations across connected T3 environments,
|
||||
explains which harnesses can use each one, copies remote paths, and eventually removes
|
||||
installations with guardrails.
|
||||
</p>
|
||||
|
||||
<div class="verdict">
|
||||
<div class="score">High<small>technical viability</small></div>
|
||||
<div>
|
||||
<strong>The read-only manager is a natural extension of T3 Code’s architecture.</strong>
|
||||
Every connected computer already runs a T3 environment server, and Codex/Claude provider
|
||||
snapshots already carry skill metadata and absolute paths. The real work is extracting
|
||||
this into a machine-level inventory service, adding adapters for the other harnesses, and
|
||||
treating filesystem mutation as a separately gated capability.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<nav>
|
||||
<a href="#shape">Product shape</a><a href="#findings">Findings</a
|
||||
><a href="#model">Data model</a><a href="#architecture">Architecture</a
|
||||
><a href="#safety">Removal safety</a><a href="#phases">Phases</a
|
||||
><a href="#testing">Testing</a><a href="#decisions">Decisions</a>
|
||||
</nav>
|
||||
|
||||
<section id="shape">
|
||||
<h2>Recommended product shape</h2>
|
||||
<div class="grid">
|
||||
<div class="card wide">
|
||||
<h3>Default view: installation inventory</h3>
|
||||
<p>
|
||||
Group by computer, then show harness visibility beneath it. A concrete directory is
|
||||
the primary record. If one directory is visible to multiple harnesses, render it once
|
||||
with multiple harness badges—not as multiple independently deletable rows.
|
||||
</p>
|
||||
</div>
|
||||
<div class="card wide">
|
||||
<h3>Scope: global first</h3>
|
||||
<p>
|
||||
V1 should inventory user/global skills. Project skills depend on a working directory
|
||||
and can only be complete for projects T3 knows about. Add a separate “Known projects”
|
||||
filter later, explicitly labeled as non-exhaustive.
|
||||
</p>
|
||||
</div>
|
||||
<div class="card full">
|
||||
<div class="mock">
|
||||
<div class="mockbar">
|
||||
<strong>Skills</strong
|
||||
><span class="muted">Search skills or paths… Refresh all</span>
|
||||
</div>
|
||||
<div class="machine">
|
||||
<div class="machine-head">
|
||||
<strong>bb-1 <span class="tag">Linux · online</span></strong
|
||||
><span class="muted">14 installations · scanned just now</span>
|
||||
</div>
|
||||
<div class="harness">
|
||||
<strong>Codex</strong> <span class="tag">direct root</span>
|
||||
<div class="skill">
|
||||
<span><strong>html-planning</strong><br /><span class="tag">Codex</span></span
|
||||
><code>~/.codex/skills/html-planning</code
|
||||
><span
|
||||
><span class="button">Copy path</span> <span class="button">•••</span></span
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div class="harness">
|
||||
<strong>Shared compatibility roots</strong> <span class="tag">deduplicated</span>
|
||||
<div class="skill">
|
||||
<span
|
||||
><strong>repo-explorer</strong><br /><span class="tag">Codex</span
|
||||
><span class="tag">OpenCode</span><span class="tag">Cursor</span></span
|
||||
><code>~/.agents/skills/repo-explorer</code
|
||||
><span
|
||||
><span class="button">Copy path</span> <span class="button">•••</span></span
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="machine">
|
||||
<div class="machine-head">
|
||||
<strong>MacBook Pro <span class="tag">offline</span></strong
|
||||
><span class="muted">Last successful scan 2h ago</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="callout good">
|
||||
<strong>Path behavior:</strong> “Copy path” copies the path meaningful on that computer.
|
||||
“Reveal in Finder / Explorer” should only appear when the selected computer is the local
|
||||
desktop host. Remote files cannot be opened locally without a future file-browser feature.
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section id="findings">
|
||||
<h2>What already exists, and what does not</h2>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Area</th>
|
||||
<th>Today</th>
|
||||
<th>Implication</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Multi-computer model</td>
|
||||
<td class="yes">
|
||||
Connected environments already have stable IDs, labels, platform, connection state,
|
||||
and per-environment authenticated HTTP/WS sessions.
|
||||
</td>
|
||||
<td>
|
||||
No central cloud indexer is required. Query each online environment and merge
|
||||
client-side.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Codex skills</td>
|
||||
<td class="yes">
|
||||
The server calls Codex app-server <code>skills/list</code> and maps name, path,
|
||||
scope, and authoritative enablement when the harness exposes it.
|
||||
</td>
|
||||
<td>
|
||||
Reuse parsing knowledge, but inventory independently of a session cwd and configured
|
||||
provider status.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Claude skills</td>
|
||||
<td class="yes">
|
||||
T3 already scans the effective Claude config root and project
|
||||
<code>.claude/skills</code>, parsing <code>SKILL.md</code> frontmatter.
|
||||
</td>
|
||||
<td>
|
||||
Refactor the scanner behind a shared inventory adapter rather than duplicating it.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>OpenCode skills</td>
|
||||
<td class="partial">
|
||||
No T3 inventory today. OpenCode supports native, Claude-compatible,
|
||||
agent-compatible, configured local, and even HTTP catalog sources.
|
||||
</td>
|
||||
<td>
|
||||
Filesystem roots are easy; config and remote catalogs need an OpenCode-specific
|
||||
adapter and read-only/remote source types.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Cursor skills</td>
|
||||
<td class="partial">
|
||||
Cursor is a provider in T3, but its provider snapshot does not expose skills.
|
||||
</td>
|
||||
<td>
|
||||
Scan documented user/project roots. Treat vendor-managed/built-in entries as
|
||||
non-removable unless ownership is proven.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Grok</td>
|
||||
<td class="no">
|
||||
No supported local skill discovery contract was found in the current T3 driver.
|
||||
</td>
|
||||
<td>
|
||||
Return an explicit “not supported by this harness” state; do not guess directories.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Settings UI</td>
|
||||
<td class="yes">
|
||||
File-based settings routes and a sidebar make a new
|
||||
<code>/settings/skills</code> page straightforward.
|
||||
</td>
|
||||
<td>Add a dedicated page rather than embedding this in Providers.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Mutation API</td>
|
||||
<td class="no">
|
||||
Provider skill paths are presentation data; there is no safe skill filesystem
|
||||
mutation endpoint.
|
||||
</td>
|
||||
<td>
|
||||
Build removal as a new capability with opaque IDs, root containment checks, and
|
||||
recoverable trashing.
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="callout">
|
||||
<strong>Inventory caveat:</strong> “All skills” can only mean all discoverable skills on
|
||||
connected computers. Offline computers show cached results, and project-scoped discovery
|
||||
is bounded by known T3 projects—not every directory on disk.
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section id="model">
|
||||
<h2>Model installations, roots, and visibility separately</h2>
|
||||
<div class="grid">
|
||||
<div class="card">
|
||||
<h3>Skill root</h3>
|
||||
<p>
|
||||
A harness-declared source: absolute path or remote catalog, scope, ownership,
|
||||
mutability, and precedence. Examples: Codex user root, shared
|
||||
<code>.agents</code> root, plugin cache.
|
||||
</p>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h3>Installation</h3>
|
||||
<p>
|
||||
One concrete skill directory/file with canonical path, real path, metadata, validation
|
||||
state, modification time, and a stable scan-local ID.
|
||||
</p>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h3>Visibility</h3>
|
||||
<p>
|
||||
One or more harness instance IDs that consume the installation, plus
|
||||
effective/overridden/disabled status where the harness can report it.
|
||||
</p>
|
||||
</div>
|
||||
<div class="card wide">
|
||||
<h3>Suggested contract</h3>
|
||||
<p>
|
||||
<code>SkillInventory { scannedAt, roots[], installations[], diagnostics[] }</code>.
|
||||
Each installation includes <code>id</code>, <code>rootId</code>,
|
||||
<code>relativePath</code>, display metadata, scope, source kind, consumers,
|
||||
capabilities, and health. Keep absolute paths for display, but never accept them back
|
||||
as mutation targets.
|
||||
</p>
|
||||
</div>
|
||||
<div class="card wide">
|
||||
<h3>Identity and deduplication</h3>
|
||||
<p>
|
||||
Canonicalize with <code>realpath</code> and filesystem identity when possible. One
|
||||
symlinked installation can appear under several roots; retain aliases for explanation
|
||||
but choose one physical-installation record. Logical name equality alone is not
|
||||
deduplication.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section id="architecture">
|
||||
<h2>Architecture</h2>
|
||||
<div class="diagram">
|
||||
<div class="flow">
|
||||
<div class="node">
|
||||
<strong>Settings / Skills</strong><br /><span class="muted"
|
||||
>queries every connected environment<br />merges live + cached results</span
|
||||
>
|
||||
</div>
|
||||
<div class="arrow">→</div>
|
||||
<div class="node">
|
||||
<strong>Environment HTTP API</strong><br /><code>GET /api/skills</code><br /><code
|
||||
>POST /api/skills/:id/trash</code
|
||||
>
|
||||
</div>
|
||||
<div class="arrow">→</div>
|
||||
<div class="node">
|
||||
<strong>SkillInventoryService</strong><br /><span class="muted"
|
||||
>Codex · Claude · OpenCode · Cursor adapters<br />root validation · dedupe ·
|
||||
diagnostics</span
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid" style="margin-top: 14px">
|
||||
<div class="card wide">
|
||||
<h3>Server and contracts</h3>
|
||||
<ul>
|
||||
<li>
|
||||
Add schema-only inventory contracts in <code>packages/contracts</code> and a new
|
||||
authenticated Environment HTTP API group.
|
||||
</li>
|
||||
<li>
|
||||
Create <code>SkillInventoryService</code> in <code>apps/server</code>; adapters
|
||||
resolve roots from provider-instance settings and process environment, then scan
|
||||
best-effort with bounded concurrency.
|
||||
</li>
|
||||
<li>
|
||||
Advertise <code>skillInventory</code> and later
|
||||
<code>skillRemoval</code> environment capabilities for version skew.
|
||||
</li>
|
||||
<li>
|
||||
Cache the latest successful inventory per server home so offline/error UI has useful
|
||||
state; refresh manually and on relevant provider-settings changes.
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="card wide">
|
||||
<h3>Web client</h3>
|
||||
<ul>
|
||||
<li>
|
||||
Add <code>/settings/skills</code>, sidebar entry, environment-scoped query atoms,
|
||||
and an aggregate selector over the existing environment catalog.
|
||||
</li>
|
||||
<li>
|
||||
Fetch only while the page is open; cap parallel environment requests and retain
|
||||
per-machine loading/error states.
|
||||
</li>
|
||||
<li>
|
||||
Search across name, description, path, computer, and harness. Filters:
|
||||
online/offline, harness, scope, health, removable.
|
||||
</li>
|
||||
<li>
|
||||
Use optimistic row removal only after the server reports the trash destination; then
|
||||
rescan that environment.
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="callout">
|
||||
<strong>Why not reuse <code>ServerProvider.skills</code> directly?</strong> It is a
|
||||
runtime/provider snapshot, can depend on a cwd, omits unsupported harnesses and roots, may
|
||||
collapse name collisions, and lacks source ownership or safe mutation identity. It can
|
||||
seed adapters, but it is not an inventory contract.
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section id="safety">
|
||||
<h2>Removal must be capability-based and recoverable</h2>
|
||||
<div class="grid">
|
||||
<div class="card">
|
||||
<h3>1 · Classify ownership</h3>
|
||||
<p>
|
||||
<span class="yes">User-managed</span> roots may be removed.
|
||||
<span class="partial">Symlinked</span> entries need a distinct unlink action.
|
||||
<span class="no">System, plugin-cache, HTTP catalog, and unknown</span> sources are
|
||||
read-only.
|
||||
</p>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h3>2 · Re-resolve server-side</h3>
|
||||
<p>
|
||||
Client sends an opaque installation ID and inventory revision. Server resolves the
|
||||
registered root + relative path again, rejects traversal, root changes, unexpected
|
||||
type changes, and escaping symlinks.
|
||||
</p>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h3>3 · Trash, do not delete</h3>
|
||||
<p>
|
||||
Atomically move the whole skill installation to a T3-owned trash directory on that
|
||||
computer, write a manifest, and expose “Undo” while retained. Permanent deletion is
|
||||
unnecessary for V1.
|
||||
</p>
|
||||
</div>
|
||||
<div class="card wide">
|
||||
<h3>Confirmation language</h3>
|
||||
<p>
|
||||
Show computer, physical path, all harnesses affected, aliases/symlinks, and whether
|
||||
another installation with the same skill name remains. Require a second confirmation
|
||||
when scripts or executable files are present.
|
||||
</p>
|
||||
</div>
|
||||
<div class="card wide">
|
||||
<h3>Race and compatibility policy</h3>
|
||||
<p>
|
||||
Reject stale revisions with <code>409</code> and force a rescan. Old servers stay
|
||||
read-only because the capability is absent. Active sessions need no forced restart,
|
||||
but the UI should say the harness may not notice the change until its next
|
||||
session/refresh.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="callout danger">
|
||||
<strong>Never implement removal as “DELETE this absolute path.”</strong> Remote clients
|
||||
are untrusted input, and skill directories can contain symlinks, scripts, or
|
||||
vendor-managed content. The server must own root registration, containment, and mutation
|
||||
policy.
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section id="phases">
|
||||
<h2>Phased implementation</h2>
|
||||
<div class="grid">
|
||||
<div class="card phase">
|
||||
<b>Phase 0 · Spike</b>
|
||||
<h3>Lock the discovery matrix</h3>
|
||||
<p>
|
||||
Fixture real harness configs; validate Codex/Claude custom homes, shared roots,
|
||||
symlinks, collisions, OpenCode config sources, and Cursor roots. Decide V1’s exact
|
||||
supported scopes.
|
||||
</p>
|
||||
</div>
|
||||
<div class="card phase">
|
||||
<b>Phase 1 · Read-only MVP</b>
|
||||
<h3>Inventory global skills</h3>
|
||||
<p>
|
||||
Contracts, capabilities, server adapters for Codex + Claude, per-environment endpoint,
|
||||
settings page, grouping, search, copy path, refresh, errors, and stale/offline
|
||||
presentation.
|
||||
</p>
|
||||
</div>
|
||||
<div class="card phase">
|
||||
<b>Phase 2 · Coverage</b>
|
||||
<h3>Add OpenCode + Cursor</h3>
|
||||
<p>
|
||||
Compatibility-root dedupe, configured OpenCode local sources, harness visibility
|
||||
badges, validation diagnostics, and known-project scope behind a filter.
|
||||
</p>
|
||||
</div>
|
||||
<div class="card phase">
|
||||
<b>Phase 3 · Management</b>
|
||||
<h3>Recoverable removal</h3>
|
||||
<p>
|
||||
Trash/undo service, ownership policy, stale-scan protection, confirmation UX, mutation
|
||||
audit log, and capability-gated UI.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<p class="muted" style="margin-top: 16px">
|
||||
Keep install/edit/sync out of the first project. Those require conflict resolution,
|
||||
copying supporting files across computers, provenance, and potentially a canonical skill
|
||||
registry—valuable, but a distinct product.
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<section id="testing">
|
||||
<h2>Verification strategy</h2>
|
||||
<div class="grid checklist">
|
||||
<div class="card wide">
|
||||
<h3>Backend focused tests</h3>
|
||||
<ul>
|
||||
<li>Per-adapter fixture trees and custom-home resolution</li>
|
||||
<li>
|
||||
Malformed frontmatter and unreadable roots remain diagnostics, not request failures
|
||||
</li>
|
||||
<li>Precedence, duplicate names, canonical-path dedupe, and symlink aliases</li>
|
||||
<li>Containment, stale revision, read-only roots, trash manifest, and undo</li>
|
||||
<li>Windows path semantics and cross-device move fallback</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="card wide">
|
||||
<h3>Frontend and integrated tests</h3>
|
||||
<ul>
|
||||
<li>
|
||||
Aggregate online, offline, unsupported, old-server, empty, and partial-failure
|
||||
environments
|
||||
</li>
|
||||
<li>Grouping/search/filter behavior and copy-path fidelity</li>
|
||||
<li>Removal confirmation lists every affected harness</li>
|
||||
<li>Run focused component/logic tests, targeted formatting/lint/type checks</li>
|
||||
<li>
|
||||
Complete one isolated <code>test-t3-app</code> browser verification of the settings
|
||||
flow after implementation
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section id="decisions">
|
||||
<h2>Decisions to make before implementation</h2>
|
||||
<ol>
|
||||
<li>
|
||||
<strong>Does V1 mean global/user skills only?</strong> Recommended: yes. Add
|
||||
known-project discovery after the global model is sound.
|
||||
</li>
|
||||
<li>
|
||||
<strong
|
||||
>Should shared physical installations appear under every harness or once?</strong
|
||||
>
|
||||
Recommended: once per machine, with consumer badges and optional “group by harness”
|
||||
presentation.
|
||||
</li>
|
||||
<li>
|
||||
<strong>Is removal permanent?</strong> Recommended: no. “Move to trash” with undo is the
|
||||
only initial mutation.
|
||||
</li>
|
||||
<li>
|
||||
<strong>Do we support only configured provider instances?</strong> Recommended: scan
|
||||
roots for configured harness instances, plus recognized shared roots; do not probe
|
||||
arbitrary software installations.
|
||||
</li>
|
||||
<li>
|
||||
<strong>How long should offline inventory persist?</strong> Recommended: cache the last
|
||||
successful scan until the environment is unlinked, with a prominent timestamp.
|
||||
</li>
|
||||
</ol>
|
||||
<div class="callout good">
|
||||
<strong>Suggested go/no-go:</strong> proceed with a narrow read-only MVP for Codex and
|
||||
Claude. It delivers most of the immediate value, proves the cross-computer aggregation
|
||||
model, and creates the safe foundation needed for broader harness coverage and removal.
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2>Likely implementation touchpoints</h2>
|
||||
<p>
|
||||
<code>packages/contracts/src/skillInventory.ts</code> ·
|
||||
<code>packages/contracts/src/environmentHttp.ts</code> ·
|
||||
<code>apps/server/src/provider/Drivers/ClaudeSkills.ts</code> ·
|
||||
<code>apps/server/src/provider/Layers/CodexProvider.ts</code> · new
|
||||
<code>apps/server/src/skills/</code> service/adapters and HTTP handler ·
|
||||
<code>apps/server/src/server.ts</code> ·
|
||||
<code>packages/client-runtime/src/state/skillInventoryHttp.ts</code> ·
|
||||
<code>apps/web/src/components/settings/SettingsSidebarNav.tsx</code> · new
|
||||
<code>apps/web/src/routes/settings.skills.tsx</code> and settings components.
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<footer>
|
||||
Evidence base: current T3 Code source and local harness layouts; official OpenCode skill
|
||||
discovery/API docs, Anthropic Claude Code skill docs, Cursor documentation/announcements,
|
||||
and the vendored/current Codex app-server integration. Computer inventory file was not
|
||||
present at its documented location, so no claims in this plan depend on a fixed personal
|
||||
machine list.
|
||||
</footer>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
@@ -99,6 +99,10 @@
|
||||
"types": "./src/state/runtime.ts",
|
||||
"default": "./src/state/runtime.ts"
|
||||
},
|
||||
"./state/skills": {
|
||||
"types": "./src/state/skillInventoryHttp.ts",
|
||||
"default": "./src/state/skillInventoryHttp.ts"
|
||||
},
|
||||
"./state/server": {
|
||||
"types": "./src/state/server.ts",
|
||||
"default": "./src/state/server.ts"
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Option from "effect/Option";
|
||||
import type {
|
||||
ProviderDriverKind,
|
||||
SkillInventory,
|
||||
SkillInventoryInstallation,
|
||||
} from "@t3tools/contracts";
|
||||
|
||||
import type { PreparedConnection } from "../connection/model.ts";
|
||||
import { environmentEndpointUrl } from "../environment/endpoint.ts";
|
||||
import { ManagedRelayDpopSigner } from "../relay/managedRelay.ts";
|
||||
import { executeEnvironmentHttpRequest, makeEnvironmentHttpApiClient } from "../rpc/http.ts";
|
||||
import { buildEnvironmentAuthHeaders, withEnvironmentCredentials } from "./environmentHttpAuth.ts";
|
||||
|
||||
const DEFAULT_SKILL_INVENTORY_TIMEOUT_MS = 10_000;
|
||||
const HOME_DIRECTORY_PREFIX = /^(?:\/(?:home|Users)\/[^/]+|[A-Za-z]:\\Users\\[^\\]+)(?=[/\\]|$)/;
|
||||
|
||||
/** Shortens a skill directory for display while preserving its useful tail. */
|
||||
export function formatSkillPath(path: string): string {
|
||||
const homeRelative = path.replace(HOME_DIRECTORY_PREFIX, "~");
|
||||
const segments = homeRelative.split(/[/\\]/).filter(Boolean);
|
||||
if (segments.length <= 4) return homeRelative;
|
||||
return `…/${segments.slice(-3).join("/")}`;
|
||||
}
|
||||
|
||||
export function filterSkillInventory(inventory: SkillInventory, query: string): SkillInventory {
|
||||
const normalizedQuery = query.trim().toLowerCase();
|
||||
if (!normalizedQuery) return inventory;
|
||||
return {
|
||||
...inventory,
|
||||
installations: inventory.installations.filter((skill) =>
|
||||
[skill.name, skill.description ?? "", skill.directoryPath, skill.harnessDisplayName].some(
|
||||
(value) => value.toLowerCase().includes(normalizedQuery),
|
||||
),
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
export function displayedSkillCount(
|
||||
inventory: SkillInventory | null,
|
||||
isConnected: boolean,
|
||||
): number | null {
|
||||
if (!isConnected || !inventory) return null;
|
||||
return inventory.installations.length;
|
||||
}
|
||||
|
||||
export function formatSkillCount(total: number, visible?: number): string {
|
||||
if (visible !== undefined && visible !== total) return `${visible} of ${total} skills`;
|
||||
return `${total} ${total === 1 ? "skill" : "skills"}`;
|
||||
}
|
||||
|
||||
export function setKeyCollapsed(
|
||||
keys: ReadonlySet<string>,
|
||||
key: string,
|
||||
collapsed: boolean,
|
||||
): ReadonlySet<string> {
|
||||
const next = new Set(keys);
|
||||
if (collapsed) next.add(key);
|
||||
else next.delete(key);
|
||||
return next;
|
||||
}
|
||||
|
||||
export interface SkillHarnessGroup {
|
||||
readonly key: string;
|
||||
readonly harness: ProviderDriverKind;
|
||||
readonly harnessDisplayName: string;
|
||||
readonly rootPath: string | null;
|
||||
readonly skills: ReadonlyArray<SkillInventoryInstallation>;
|
||||
}
|
||||
|
||||
/** Stable identity for a single installation, unique within an inventory. */
|
||||
export function skillKey(skill: SkillInventoryInstallation): string {
|
||||
return `${skill.providerInstanceId}:${skill.directoryPath}`;
|
||||
}
|
||||
|
||||
function parentDirectory(path: string): string {
|
||||
const parent = path.replace(/[/\\]+[^/\\]+[/\\]*$/, "");
|
||||
return parent || path;
|
||||
}
|
||||
|
||||
export function groupSkillsByHarness(
|
||||
installations: ReadonlyArray<SkillInventoryInstallation>,
|
||||
): ReadonlyArray<SkillHarnessGroup> {
|
||||
const groups = new Map<string, SkillInventoryInstallation[]>();
|
||||
for (const skill of installations) {
|
||||
const key = `${skill.providerInstanceId}\0${skill.harnessDisplayName}`;
|
||||
const existing = groups.get(key);
|
||||
if (existing) existing.push(skill);
|
||||
else groups.set(key, [skill]);
|
||||
}
|
||||
return [...groups.entries()].map(([key, skills]) => {
|
||||
const roots = new Set(skills.map((skill) => parentDirectory(skill.directoryPath)));
|
||||
return {
|
||||
key,
|
||||
harness: skills[0]!.harness,
|
||||
harnessDisplayName: skills[0]?.harnessDisplayName ?? key,
|
||||
rootPath: roots.size === 1 ? ([...roots][0] ?? null) : null,
|
||||
skills,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
export function skillContentForDisplay(content: string): string | null {
|
||||
const trimmed = content.trim();
|
||||
return trimmed.length > 0 ? trimmed : null;
|
||||
}
|
||||
|
||||
export const fetchEnvironmentSkillInventory = Effect.fn(
|
||||
"clientRuntime.state.fetchEnvironmentSkillInventory",
|
||||
)(function* (input: { readonly prepared: PreparedConnection; readonly timeoutMs?: number }) {
|
||||
const requestUrl = environmentEndpointUrl(input.prepared.httpBaseUrl, "/api/skills");
|
||||
const client = yield* makeEnvironmentHttpApiClient(input.prepared.httpBaseUrl);
|
||||
const signer = yield* Effect.serviceOption(ManagedRelayDpopSigner);
|
||||
const headers = yield* buildEnvironmentAuthHeaders(
|
||||
input.prepared.httpAuthorization,
|
||||
"GET",
|
||||
requestUrl,
|
||||
Option.isSome(signer) ? signer : Option.none(),
|
||||
);
|
||||
return yield* executeEnvironmentHttpRequest(
|
||||
requestUrl,
|
||||
input.timeoutMs ?? DEFAULT_SKILL_INVENTORY_TIMEOUT_MS,
|
||||
withEnvironmentCredentials(
|
||||
input.prepared.httpAuthorization,
|
||||
client.skills.inventory({ headers }),
|
||||
),
|
||||
);
|
||||
});
|
||||
@@ -26,6 +26,7 @@ import {
|
||||
} from "./auth.ts";
|
||||
import { AuthSessionId, ThreadId, TrimmedNonEmptyString } from "./baseSchemas.ts";
|
||||
import { ExecutionEnvironmentDescriptor } from "./environment.ts";
|
||||
import { SkillInventory } from "./skillInventory.ts";
|
||||
import {
|
||||
ClientOrchestrationCommand,
|
||||
DispatchResult,
|
||||
@@ -500,6 +501,14 @@ export class EnvironmentOrchestrationHttpApi extends HttpApiGroup.make("orchestr
|
||||
}).middleware(EnvironmentAuthenticatedAuth),
|
||||
) {}
|
||||
|
||||
export class EnvironmentSkillsHttpApi extends HttpApiGroup.make("skills").add(
|
||||
HttpApiEndpoint.get("inventory", "/api/skills", {
|
||||
headers: OptionalBearerHeaders,
|
||||
success: SkillInventory,
|
||||
error: EnvironmentOrchestrationSnapshotErrors,
|
||||
}).middleware(EnvironmentAuthenticatedAuth),
|
||||
) {}
|
||||
|
||||
export class EnvironmentConnectHttpApi extends HttpApiGroup.make("connect")
|
||||
.add(
|
||||
HttpApiEndpoint.post("linkProof", "/api/connect/link-proof", {
|
||||
@@ -565,4 +574,5 @@ export class EnvironmentHttpApi extends HttpApi.make("environment")
|
||||
.add(EnvironmentMetadataHttpApi)
|
||||
.add(EnvironmentAuthHttpApi)
|
||||
.add(EnvironmentOrchestrationHttpApi)
|
||||
.add(EnvironmentSkillsHttpApi)
|
||||
.add(EnvironmentConnectHttpApi) {}
|
||||
@@ -15,6 +15,7 @@ export * from "./model.ts";
|
||||
export * from "./keybindings.ts";
|
||||
export * from "./server.ts";
|
||||
export * from "./settings.ts";
|
||||
export * from "./skillInventory.ts";
|
||||
export * from "./git.ts";
|
||||
export * from "./vcs.ts";
|
||||
export * from "./sourceControl.ts";
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import * as Schema from "effect/Schema";
|
||||
|
||||
import { TrimmedNonEmptyString } from "./baseSchemas.ts";
|
||||
import { ProviderDriverKind, ProviderInstanceId } from "./providerInstance.ts";
|
||||
|
||||
/**
|
||||
* Filesystem inventory intentionally omits per-skill enablement. Codex only
|
||||
* exposes that state through its live RPC, while Claude has no equivalent,
|
||||
* so persisting it here would make the cross-harness response misleading.
|
||||
*/
|
||||
export const SkillInventoryInstallation = Schema.Struct({
|
||||
providerInstanceId: ProviderInstanceId,
|
||||
harness: ProviderDriverKind,
|
||||
harnessDisplayName: TrimmedNonEmptyString,
|
||||
name: TrimmedNonEmptyString,
|
||||
description: Schema.optional(TrimmedNonEmptyString),
|
||||
directoryPath: TrimmedNonEmptyString,
|
||||
skillFilePath: TrimmedNonEmptyString,
|
||||
content: Schema.String,
|
||||
});
|
||||
export type SkillInventoryInstallation = typeof SkillInventoryInstallation.Type;
|
||||
|
||||
export const SkillInventory = Schema.Struct({
|
||||
scannedAt: TrimmedNonEmptyString,
|
||||
installations: Schema.Array(SkillInventoryInstallation),
|
||||
});
|
||||
export type SkillInventory = typeof SkillInventory.Type;
|
||||
Reference in new issue
Block a user