Add system prompt options to extension commands
This commit is contained in:
@@ -2,7 +2,7 @@ import type { AgentTool, ThinkingLevel } from "@earendil-works/pi-agent-core";
|
||||
import { fauxAssistantMessage, fauxToolCall, type Model } from "@earendil-works/pi-ai";
|
||||
import { Type } from "typebox";
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import type { ExtensionAPI } from "../../src/index.ts";
|
||||
import type { BuildSystemPromptOptions, ExtensionAPI } from "../../src/index.ts";
|
||||
import { createHarness, getAssistantTexts, type Harness } from "./harness.ts";
|
||||
|
||||
describe("AgentSession model and extension characterization", () => {
|
||||
@@ -260,6 +260,34 @@ describe("AgentSession model and extension characterization", () => {
|
||||
expect(extensionApi).toBeDefined();
|
||||
});
|
||||
|
||||
it("allows extension commands to inspect live system prompt options", async () => {
|
||||
const seenOptions: BuildSystemPromptOptions[] = [];
|
||||
const harness = await createHarness({
|
||||
extensionFactories: [
|
||||
(pi) => {
|
||||
pi.registerCommand("inspect-options", {
|
||||
description: "Inspect system prompt options",
|
||||
handler: async (_args, ctx) => {
|
||||
const options = ctx.getSystemPromptOptions();
|
||||
seenOptions.push(options);
|
||||
options.selectedTools?.push("mutated_tool");
|
||||
},
|
||||
});
|
||||
},
|
||||
],
|
||||
});
|
||||
harnesses.push(harness);
|
||||
|
||||
await harness.session.prompt("/inspect-options");
|
||||
await harness.session.prompt("/inspect-options");
|
||||
|
||||
expect(seenOptions).toHaveLength(2);
|
||||
expect(seenOptions[0]).toBe(seenOptions[1]);
|
||||
expect(seenOptions[0]?.cwd).toBe(harness.tempDir);
|
||||
expect(seenOptions[0]?.selectedTools).toContain("read");
|
||||
expect(seenOptions[1]?.selectedTools).toContain("mutated_tool");
|
||||
});
|
||||
|
||||
it("allows before_agent_start handlers to inject custom messages and modify the system prompt", async () => {
|
||||
const harness = await createHarness({
|
||||
extensionFactories: [
|
||||
|
||||
Reference in New Issue
Block a user