mirror of
https://github.com/getpaseo/paseo.git
synced 2026-10-25 18:52:39 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4f5224122a | ||
|
|
af27e28054 |
@@ -242,6 +242,54 @@ describe("Codex active-turn steering admission", () => {
|
|||||||
appServer.assertNoErrors();
|
appServer.assertNoErrors();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("a steer resolves a Codex skill mentioned after prose into app-server skill input", async () => {
|
||||||
|
const appServer = createFakeCodexAppServer({
|
||||||
|
"skills/list": () => ({
|
||||||
|
data: [
|
||||||
|
{
|
||||||
|
cwd: "/workspace/project",
|
||||||
|
skills: [
|
||||||
|
{
|
||||||
|
name: "paseo-implement",
|
||||||
|
description: "Execute an existing Paseo plan.",
|
||||||
|
path: "/workspace/skills/paseo-implement/SKILL.md",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
errors: [],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
"turn/steer": () => ({ turn: { id: "native-A" } }),
|
||||||
|
});
|
||||||
|
const { session, paseoTurnId } = await startPublicSteeringSession(appServer);
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
session.steerActiveTurn!("Then use /paseo-implement to complete it.", {
|
||||||
|
expectedTurnId: paseoTurnId,
|
||||||
|
}),
|
||||||
|
).resolves.toEqual({ status: "accepted" });
|
||||||
|
|
||||||
|
const steer = appServer.requests().find((request) => request.method === "turn/steer");
|
||||||
|
expect(steer?.params).toEqual(
|
||||||
|
expect.objectContaining({
|
||||||
|
input: [
|
||||||
|
{
|
||||||
|
type: "skill",
|
||||||
|
name: "paseo-implement",
|
||||||
|
path: "/workspace/skills/paseo-implement/SKILL.md",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "text",
|
||||||
|
text: "Then use $paseo-implement to complete it.",
|
||||||
|
text_elements: [],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
await session.close();
|
||||||
|
appServer.assertNoErrors();
|
||||||
|
});
|
||||||
|
|
||||||
test("a clearing steer denies every pending permission through its provider handler", async () => {
|
test("a clearing steer denies every pending permission through its provider handler", async () => {
|
||||||
const appServer = createFakeCodexAppServer({
|
const appServer = createFakeCodexAppServer({
|
||||||
"turn/steer": () => ({ turn: { id: "native-A" } }),
|
"turn/steer": () => ({ turn: { id: "native-A" } }),
|
||||||
@@ -2233,6 +2281,59 @@ describe("Codex app-server provider", () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("resolves a Codex skill mentioned after prose into app-server skill input", async () => {
|
||||||
|
const session = createSession();
|
||||||
|
const request = vi.fn(async (method: string) => {
|
||||||
|
if (method === "skills/list") {
|
||||||
|
return {
|
||||||
|
data: [
|
||||||
|
{
|
||||||
|
cwd: "/tmp/codex-question-test",
|
||||||
|
skills: [
|
||||||
|
{
|
||||||
|
name: "paseo-implement",
|
||||||
|
description: "Execute an existing Paseo plan.",
|
||||||
|
path: "/tmp/skills/paseo-implement/SKILL.md",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
errors: [],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (method === "thread/loaded/list") {
|
||||||
|
return { data: ["test-thread"] };
|
||||||
|
}
|
||||||
|
if (method === "turn/start") {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
throw new Error(`Unexpected request: ${method}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
session.activeForegroundTurnId = null;
|
||||||
|
session.client = createStub<CodexClientLike>({ request });
|
||||||
|
|
||||||
|
await session.startTurn("Review the accepted plan, then use /paseo-implement to complete it.");
|
||||||
|
|
||||||
|
const turnStartCall = request.mock.calls.find(([method]) => method === "turn/start");
|
||||||
|
expect(turnStartCall?.[1]).toEqual(
|
||||||
|
expect.objectContaining({
|
||||||
|
input: [
|
||||||
|
{
|
||||||
|
type: "skill",
|
||||||
|
name: "paseo-implement",
|
||||||
|
path: "/tmp/skills/paseo-implement/SKILL.md",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "text",
|
||||||
|
text: "Review the accepted plan, then use $paseo-implement to complete it.",
|
||||||
|
text_elements: [],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
test("lists project skill commands when app-server receives the project cwd in cwds", async () => {
|
test("lists project skill commands when app-server receives the project cwd in cwds", async () => {
|
||||||
const commands = await listCommandsFromFakeCodex([
|
const commands = await listCommandsFromFakeCodex([
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3169,6 +3169,26 @@ function enabledCodexSkills(
|
|||||||
return Array.from(skillsByName.values());
|
return Array.from(skillsByName.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Composer autocomplete inserts skills as `/name` anywhere in the prompt, while
|
||||||
|
// Codex only injects a skill it receives as a skill input item.
|
||||||
|
const SKILL_MENTION_PATTERN = /(^|\s)\/([^\s/"']+)/g;
|
||||||
|
|
||||||
|
function resolveCodexSkillMentions(
|
||||||
|
text: string,
|
||||||
|
skills: ReadonlyArray<{ name: string; path: string }>,
|
||||||
|
): { skills: CodexSkillPromptBlock[]; text: string } {
|
||||||
|
const mentioned = new Map<string, CodexSkillPromptBlock>();
|
||||||
|
const rewritten = text.replace(SKILL_MENTION_PATTERN, (mention, prefix: string, name: string) => {
|
||||||
|
const skill = skills.find((entry) => entry.name === name);
|
||||||
|
if (!skill) {
|
||||||
|
return mention;
|
||||||
|
}
|
||||||
|
mentioned.set(skill.name, { type: "skill", name: skill.name, path: skill.path });
|
||||||
|
return `${prefix}$${skill.name}`;
|
||||||
|
});
|
||||||
|
return { skills: Array.from(mentioned.values()), text: rewritten };
|
||||||
|
}
|
||||||
|
|
||||||
type CodexPromptContentBlock = AgentPromptContentBlock | CodexSkillPromptBlock;
|
type CodexPromptContentBlock = AgentPromptContentBlock | CodexSkillPromptBlock;
|
||||||
type CodexPromptInput = string | CodexPromptContentBlock[];
|
type CodexPromptInput = string | CodexPromptContentBlock[];
|
||||||
interface CodexTextElement {
|
interface CodexTextElement {
|
||||||
@@ -4063,6 +4083,18 @@ export class CodexAppServerAgentSession implements AgentSession {
|
|||||||
return args ? `$${commandName} ${args}` : `$${commandName}`;
|
return args ? `$${commandName} ${args}` : `$${commandName}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async attachMentionedSkills(prompt: AgentPromptInput): Promise<CodexPromptInput> {
|
||||||
|
if (typeof prompt !== "string" || !prompt.includes("/")) {
|
||||||
|
return prompt;
|
||||||
|
}
|
||||||
|
await this.loadSkills();
|
||||||
|
const resolved = resolveCodexSkillMentions(prompt, this.cachedSkills ?? []);
|
||||||
|
if (resolved.skills.length === 0) {
|
||||||
|
return prompt;
|
||||||
|
}
|
||||||
|
return [...resolved.skills, { type: "text", text: resolved.text }];
|
||||||
|
}
|
||||||
|
|
||||||
private async buildTurnStartParams(
|
private async buildTurnStartParams(
|
||||||
prompt: CodexPromptInput,
|
prompt: CodexPromptInput,
|
||||||
options?: AgentRunOptions,
|
options?: AgentRunOptions,
|
||||||
@@ -4266,7 +4298,7 @@ export class CodexAppServerAgentSession implements AgentSession {
|
|||||||
const slashCommand = await this.resolveSlashCommandInvocation(prompt);
|
const slashCommand = await this.resolveSlashCommandInvocation(prompt);
|
||||||
const effectivePrompt = slashCommand
|
const effectivePrompt = slashCommand
|
||||||
? await this.buildCommandPromptInput(slashCommand.commandName, slashCommand.args)
|
? await this.buildCommandPromptInput(slashCommand.commandName, slashCommand.args)
|
||||||
: prompt;
|
: await this.attachMentionedSkills(prompt);
|
||||||
|
|
||||||
if (this.currentThreadId) {
|
if (this.currentThreadId) {
|
||||||
await this.ensureThreadLoaded();
|
await this.ensureThreadLoaded();
|
||||||
@@ -4333,7 +4365,7 @@ export class CodexAppServerAgentSession implements AgentSession {
|
|||||||
if (!this.matchesSteerAdmission({ client, threadId, nativeTurnId, foregroundTurnId })) {
|
if (!this.matchesSteerAdmission({ client, threadId, nativeTurnId, foregroundTurnId })) {
|
||||||
return { status: "unavailable" };
|
return { status: "unavailable" };
|
||||||
}
|
}
|
||||||
const input = await this.buildUserInput(prompt);
|
const input = await this.buildUserInput(await this.attachMentionedSkills(prompt));
|
||||||
if (!this.matchesSteerAdmission({ client, threadId, nativeTurnId, foregroundTurnId })) {
|
if (!this.matchesSteerAdmission({ client, threadId, nativeTurnId, foregroundTurnId })) {
|
||||||
return { status: "unavailable" };
|
return { status: "unavailable" };
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user