289dd770c8
- Extended `tools/yield.ts` with typed incremental sections, raw last-turn terminal results, and updated yield guidance in the subagent system prompts. - Reworked `task/executor.ts`, `task/render.ts`, and `task/types.ts` to assemble typed yield sections, render reviewer results from incremental yield data, and preserve the typed result shape. - Switched `prompts/agents/reviewer.md`, `review-request.md`, and `review-custom-request.md` from `report_finding` calls to incremental `yield` sections. - Added incremental-yield coverage in `test/task/executor-warnings.test.ts`, `test/task/render-yield-shape.test.ts`, `test/tools/yield-extraction.test.ts`, and `test/tools/yield.test.ts`.
90 lines
2.3 KiB
TypeScript
90 lines
2.3 KiB
TypeScript
import { describe, expect, it } from "bun:test";
|
|
import "@oh-my-pi/pi-coding-agent/tools/yield";
|
|
import { subprocessToolRegistry } from "@oh-my-pi/pi-coding-agent/task/subprocess-tool-registry";
|
|
|
|
describe("yield subprocess extraction", () => {
|
|
const handler = subprocessToolRegistry.getHandler("yield");
|
|
|
|
it("extracts valid yield payloads", () => {
|
|
expect(handler?.extractData).toBeDefined();
|
|
const data = handler?.extractData?.({
|
|
toolName: "yield",
|
|
toolCallId: "call-1",
|
|
result: {
|
|
content: [{ type: "text", text: "Result submitted." }],
|
|
details: {
|
|
status: "success",
|
|
data: { ok: true },
|
|
type: ["notes"],
|
|
useLastTurn: true,
|
|
},
|
|
},
|
|
isError: false,
|
|
});
|
|
expect(data).toEqual({
|
|
status: "success",
|
|
data: { ok: true },
|
|
error: undefined,
|
|
type: ["notes"],
|
|
useLastTurn: true,
|
|
});
|
|
});
|
|
|
|
it("ignores malformed yield details without status", () => {
|
|
const data = handler?.extractData?.({
|
|
toolName: "yield",
|
|
toolCallId: "call-2",
|
|
result: {
|
|
content: [{ type: "text", text: "Tool execution was aborted." }],
|
|
details: {},
|
|
},
|
|
isError: true,
|
|
});
|
|
expect(data).toBeUndefined();
|
|
});
|
|
|
|
it("classifies terminal and incremental yield completions", () => {
|
|
expect(handler?.shouldTerminate).toBeDefined();
|
|
expect(
|
|
handler?.shouldTerminate?.({
|
|
toolName: "yield",
|
|
toolCallId: "call-terminal-untyped",
|
|
result: {
|
|
content: [{ type: "text", text: "Result submitted." }],
|
|
details: { status: "success", data: { ok: true } },
|
|
},
|
|
isError: false,
|
|
}),
|
|
).toBe(true);
|
|
expect(
|
|
handler?.shouldTerminate?.({
|
|
toolName: "yield",
|
|
toolCallId: "call-terminal-string",
|
|
result: {
|
|
content: [{ type: "text", text: "Result submitted." }],
|
|
details: { status: "success", type: "summary", useLastTurn: true },
|
|
},
|
|
isError: false,
|
|
}),
|
|
).toBe(true);
|
|
expect(
|
|
handler?.shouldTerminate?.({
|
|
toolName: "yield",
|
|
toolCallId: "call-incremental",
|
|
result: {
|
|
content: [{ type: "text", text: "Result submitted." }],
|
|
details: { status: "success", data: { ok: true }, type: ["notes"] },
|
|
},
|
|
isError: false,
|
|
}),
|
|
).toBe(false);
|
|
expect(
|
|
handler?.shouldTerminate?.({
|
|
toolName: "yield",
|
|
toolCallId: "call-tool-error",
|
|
isError: true,
|
|
}),
|
|
).toBe(false);
|
|
});
|
|
});
|