fix(settings): make skill inventory states explicit
This commit is contained in:
5 files changed
+48
-5
No files matched your search
@@ -12,7 +12,7 @@ import * as Path from "effect/Path";
|
||||
import * as Schema from "effect/Schema";
|
||||
|
||||
import * as ServerSettings from "../serverSettings.ts";
|
||||
import { discoverGlobalSkillInventory } from "./SkillInventory.ts";
|
||||
import { discoverGlobalSkillInventory, readSkillInstallations } from "./SkillInventory.ts";
|
||||
|
||||
const decodeCodexSettings = Schema.decodeSync(CodexSettings);
|
||||
const decodeClaudeSettings = Schema.decodeSync(ClaudeSettings);
|
||||
@@ -33,6 +33,33 @@ const writeSkill = Effect.fn("SkillInventoryTest.writeSkill")(function* (
|
||||
});
|
||||
|
||||
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;
|
||||
|
||||
@@ -5,6 +5,7 @@ import type {
|
||||
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";
|
||||
@@ -24,7 +25,7 @@ function harnessDisplayName(instance: ProviderInstanceConfig, fallback: string):
|
||||
return instance.displayName?.trim() || fallback;
|
||||
}
|
||||
|
||||
const readSkillInstallations = Effect.fn("SkillInventory.readSkillInstallations")(
|
||||
export const readSkillInstallations = Effect.fn("SkillInventory.readSkillInstallations")(
|
||||
function* (input: {
|
||||
readonly instanceId: string;
|
||||
readonly instance: ProviderInstanceConfig;
|
||||
@@ -37,9 +38,8 @@ const readSkillInstallations = Effect.fn("SkillInventory.readSkillInstallations"
|
||||
> {
|
||||
const fileSystem = yield* FileSystem.FileSystem;
|
||||
const path = yield* Path.Path;
|
||||
return yield* Effect.forEach(input.skills, (skill) =>
|
||||
const installations = yield* Effect.forEach(input.skills, (skill) =>
|
||||
fileSystem.readFileString(skill.path).pipe(
|
||||
Effect.orElseSucceed(() => ""),
|
||||
Effect.map((content) => ({
|
||||
providerInstanceId: ProviderInstanceId.make(input.instanceId),
|
||||
harness: input.instance.driver,
|
||||
@@ -50,8 +50,10 @@ const readSkillInstallations = Effect.fn("SkillInventory.readSkillInstallations"
|
||||
skillFilePath: skill.path,
|
||||
content,
|
||||
})),
|
||||
Effect.option,
|
||||
),
|
||||
);
|
||||
return Arr.getSomes(installations);
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import { ProviderDriverKind, ProviderInstanceId, type SkillInventory } from "@t3
|
||||
import {
|
||||
displayedSkillCount,
|
||||
filterSkillInventory,
|
||||
formatSkillCount,
|
||||
formatSkillPath,
|
||||
groupSkillsByHarness,
|
||||
setKeyCollapsed,
|
||||
@@ -68,6 +69,12 @@ describe("skill explorer helpers", () => {
|
||||
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"]);
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
displayedSkillCount,
|
||||
fetchEnvironmentSkillInventory,
|
||||
filterSkillInventory,
|
||||
formatSkillCount,
|
||||
formatSkillPath,
|
||||
groupSkillsByHarness,
|
||||
setKeyCollapsed,
|
||||
@@ -160,6 +161,7 @@ function EnvironmentSkillInventory({
|
||||
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;
|
||||
@@ -198,7 +200,7 @@ function EnvironmentSkillInventory({
|
||||
/>
|
||||
{skillCount !== null ? (
|
||||
<span className="shrink-0 font-mono text-[11px] tabular-nums text-muted-foreground/70">
|
||||
{skillCount} {skillCount === 1 ? "skill" : "skills"}
|
||||
{formatSkillCount(skillCount, isSearching ? (visibleSkillCount ?? 0) : undefined)}
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
@@ -44,6 +44,11 @@ export function displayedSkillCount(
|
||||
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,
|
||||
|
||||
Reference in new issue
Block a user