Show skill autocomplete anywhere in prompts

This commit is contained in:
Mohamed Boudra
2026-06-09 17:15:03 +07:00
parent 9f41904c6f
commit c5bcec5c71
15 changed files with 393 additions and 61 deletions
@@ -481,6 +481,8 @@ export interface AgentRuntimeInfo {
extra?: AgentMetadata;
}
export type AgentSlashCommandKind = "command" | "skill";
/**
* Represents a slash command available in an agent session.
* Commands are executed by sending them as prompts with / prefix.
@@ -489,6 +491,7 @@ export interface AgentSlashCommand {
name: string;
description: string;
argumentHint: string;
kind?: AgentSlashCommandKind;
}
export interface ListPersistedAgentsOptions {
@@ -1486,11 +1486,13 @@ describe("ACPAgentSession slash commands", () => {
name: "research_codebase",
description: "Search the workspace for relevant files",
argumentHint: "",
kind: "command",
},
{
name: "create_plan",
description: "Draft a plan for the requested work",
argumentHint: "",
kind: "command",
},
]);
@@ -1499,11 +1501,13 @@ describe("ACPAgentSession slash commands", () => {
name: "research_codebase",
description: "Search the workspace for relevant files",
argumentHint: "",
kind: "command",
},
{
name: "create_plan",
description: "Draft a plan for the requested work",
argumentHint: "",
kind: "command",
},
]);
});
@@ -1989,6 +1989,7 @@ export class ACPAgentSession implements AgentSession, ACPClient {
name: command.name,
description: command.description,
argumentHint: "",
kind: "command",
}));
this.settleCommandsReady();
return [];
@@ -2081,6 +2081,7 @@ class ClaudeAgentSession implements AgentSession {
name: cmd.name,
description: cmd.description,
argumentHint: cmd.argumentHint,
kind: "command",
});
}
}
@@ -725,6 +725,7 @@ describe("Codex app-server provider", () => {
name: "shipper",
description: "Ship changes carefully.",
argumentHint: "",
kind: "skill",
});
expect(workspaceGitService.resolveRepoRoot).toHaveBeenCalledWith(cwd);
} finally {
@@ -983,6 +984,7 @@ describe("Codex app-server provider", () => {
name: "paseo",
description: "Shared orchestration skill.",
argumentHint: "",
kind: "skill",
},
]);
});
@@ -1890,6 +1892,7 @@ describe("Codex app-server provider", () => {
name: "compact",
description: "Summarize conversation to prevent hitting the context limit",
argumentHint: "",
kind: "command",
});
const handler = session.tryHandleOutOfBand?.("/compact");
@@ -631,6 +631,7 @@ async function listCodexCustomPrompts(): Promise<AgentSlashCommand[]> {
name: `prompts:${name}`,
description,
argumentHint,
kind: "command",
};
}),
);
@@ -695,6 +696,7 @@ export async function listCodexSkills(
name,
description,
argumentHint: "",
kind: "skill",
});
}
}
@@ -3949,6 +3951,7 @@ export class CodexAppServerAgentSession implements AgentSession {
name: skill.name,
description: skill.description,
argumentHint: "",
kind: "skill" as const,
}));
const fallbackSkills =
appServerSkills.length === 0
@@ -3959,6 +3962,7 @@ export class CodexAppServerAgentSession implements AgentSession {
name: "compact",
description: "Summarize conversation to prevent hitting the context limit",
argumentHint: "",
kind: "command",
},
];
if (this.goalsEnabled) {
@@ -3966,6 +3970,7 @@ export class CodexAppServerAgentSession implements AgentSession {
name: "goal",
description: "Set, pause, resume, or clear the agent's goal",
argumentHint: "[<objective>|pause|resume|clear]",
kind: "command",
});
}
return [...builtin, ...appServerSkills, ...fallbackSkills, ...prompts].sort((a, b) =>
@@ -252,8 +252,18 @@ const OPENCODE_PROVIDER_LIST_TIMEOUT_MS = 30_000;
const OPENCODE_METADATA_CONCURRENCY = 4;
const openCodeMetadataLimit = pLimit(OPENCODE_METADATA_CONCURRENCY);
const OPENCODE_HANDLED_BUILTIN_SLASH_COMMANDS: AgentSlashCommand[] = [
{ name: "compact", description: "Compact the current session", argumentHint: "" },
{ name: "summarize", description: "Compact the current session", argumentHint: "" },
{
name: "compact",
description: "Compact the current session",
argumentHint: "",
kind: "command",
},
{
name: "summarize",
description: "Compact the current session",
argumentHint: "",
kind: "command",
},
];
const OPENCODE_HEADERS_TIMEOUT_TOKENS = [
"headers timeout",
@@ -1720,6 +1730,7 @@ async function listOpenCodeCommandsFromSdk(
name: cmd.name,
description: cmd.description ?? "",
argumentHint: cmd.hints?.length ? cmd.hints.join(" ") : "",
kind: cmd.source === "skill" ? "skill" : "command",
});
}
@@ -830,15 +830,17 @@ describe("PiRpcAgentClient", () => {
name: "compact",
description: "Manually compact the session context",
argumentHint: "[instructions]",
kind: "command",
},
{
name: "autocompact",
description: "Toggle automatic context compaction",
argumentHint: "[on|off|toggle]",
kind: "command",
},
{ name: "review", description: "Review changes", argumentHint: "" },
{ name: "fix-tests", description: "Fix tests", argumentHint: "" },
{ name: "skill:docs", description: "Read docs", argumentHint: "" },
{ name: "review", description: "Review changes", argumentHint: "", kind: "command" },
{ name: "fix-tests", description: "Fix tests", argumentHint: "", kind: "command" },
{ name: "skill:docs", description: "Read docs", argumentHint: "", kind: "skill" },
]);
});
@@ -852,11 +854,13 @@ describe("PiRpcAgentClient", () => {
name: "compact",
description: "Manually compact the session context",
argumentHint: "[instructions]",
kind: "command",
});
await expect(session.listCommands()).resolves.toContainEqual({
name: "autocompact",
description: "Toggle automatic context compaction",
argumentHint: "[on|off|toggle]",
kind: "command",
});
});
@@ -872,11 +876,13 @@ describe("PiRpcAgentClient", () => {
name: "compact",
description: "Compact from RPC",
argumentHint: "[instructions]",
kind: "command",
},
{
name: "autocompact",
description: "Auto compact from RPC",
argumentHint: "[on|off|toggle]",
kind: "command",
},
]);
});
@@ -23,6 +23,7 @@ import {
type AgentSession,
type AgentSessionConfig,
type AgentSlashCommand,
type AgentSlashCommandKind,
type AgentStreamEvent,
type AgentUsage,
type ListPersistedAgentsOptions,
@@ -101,14 +102,23 @@ const PI_HANDLED_BUILTIN_SLASH_COMMANDS: AgentSlashCommand[] = [
name: "compact",
description: "Manually compact the session context",
argumentHint: "[instructions]",
kind: "command",
},
{
name: "autocompact",
description: "Toggle automatic context compaction",
argumentHint: "[on|off|toggle]",
kind: "command",
},
];
function mapPiCommandKind(source: PiRpcSlashCommand["source"]): AgentSlashCommandKind {
if (source === "skill") {
return "skill";
}
return "command";
}
const PI_CAPABILITIES: AgentCapabilityFlags = {
supportsStreaming: true,
supportsSessionPersistence: true,
@@ -1190,6 +1200,7 @@ export class PiRpcAgentSession implements AgentSession {
name: command.name,
description: command.description ?? command.source,
argumentHint: knownCommand?.argumentHint ?? "",
kind: mapPiCommandKind(command.source),
});
}
return [...mappedCommands.values()];