Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions apps/server/src/provider/Layers/ClaudeProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
} from "../providerSnapshot.ts";
import { compareCliVersions } from "../cliVersion.ts";
import { makeClaudeEnvironment } from "../Drivers/ClaudeHome.ts";
import { claudeSlashCommandsAsProviderSkills } from "../claudeSlashCommandsAsProviderSkills.ts";

const DEFAULT_CLAUDE_MODEL_CAPABILITIES: ModelCapabilities = createModelCapabilities({
optionDescriptors: [],
Expand Down Expand Up @@ -622,6 +623,7 @@ export const checkClaudeProviderStatus = Effect.fn("checkClaudeProviderStatus")(
: undefined;
const slashCommands = capabilities?.slashCommands ?? [];
const dedupedSlashCommands = dedupeSlashCommands(slashCommands);
const skillsFromSlashCommands = claudeSlashCommandsAsProviderSkills(dedupedSlashCommands);

if (!capabilities) {
return buildServerProvider({
Expand All @@ -630,6 +632,7 @@ export const checkClaudeProviderStatus = Effect.fn("checkClaudeProviderStatus")(
checkedAt,
models,
slashCommands: dedupedSlashCommands,
skills: skillsFromSlashCommands,
probe: {
installed: true,
version: parsedVersion,
Expand All @@ -650,6 +653,7 @@ export const checkClaudeProviderStatus = Effect.fn("checkClaudeProviderStatus")(
checkedAt,
models,
slashCommands: dedupedSlashCommands,
skills: skillsFromSlashCommands,
probe: {
installed: true,
version: parsedVersion,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { describe, expect, it } from "vitest";

import { claudeSlashCommandsAsProviderSkills } from "./claudeSlashCommandsAsProviderSkills.ts";

describe("claudeSlashCommandsAsProviderSkills", () => {
it("maps slash commands to skills with stable synthetic paths", () => {
const skills = claudeSlashCommandsAsProviderSkills([
{ name: "frontend-design", description: "UI help" },
{ name: "gh-fix-ci", input: { hint: "[pr-url]" } },
]);
expect(skills).toHaveLength(2);
expect(skills[0]).toMatchObject({
name: "frontend-design",
enabled: true,
scope: "claude-agent",
description: "UI help",
shortDescription: "UI help",
path: "claude-agent:///slash-command/frontend-design",
});
expect(skills[1]).toMatchObject({
name: "gh-fix-ci",
enabled: true,
scope: "claude-agent",
shortDescription: "[pr-url]",
path: "claude-agent:///slash-command/gh-fix-ci",
});
});

it("encodes command names in the path", () => {
const [skill] = claudeSlashCommandsAsProviderSkills([{ name: "a:b" }]);
expect(skill?.path).toBe("claude-agent:///slash-command/a%3Ab");
expect(skill?.name).toBe("a:b");
});
});
24 changes: 24 additions & 0 deletions apps/server/src/provider/claudeSlashCommandsAsProviderSkills.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import type { ServerProviderSlashCommand, ServerProviderSkill } from "@t3tools/contracts";

/**
* Claude reports capabilities as slash commands from SDK init. The composer
* `$` picker reads {@link ServerProviderSkill}; mirror the same inventory so
* `$` works for Claude the way Codex does with `skills/list`.
*/
export function claudeSlashCommandsAsProviderSkills(
commands: ReadonlyArray<ServerProviderSlashCommand>,
): ReadonlyArray<ServerProviderSkill> {
return commands.map((command) => {
const hint = command.input?.hint?.trim();
const desc = command.description?.trim();
const shortDescription = hint ?? desc;
return {
name: command.name,
path: `claude-agent:///slash-command/${encodeURIComponent(command.name)}`,
enabled: true,
scope: "claude-agent",
...(desc ? { description: desc } : {}),
...(shortDescription ? { shortDescription } : {}),
} satisfies ServerProviderSkill;
});
}
Loading