- Replaced plan:// protocol with notes:// for session-scoped artifact storage and plan finalization. - Added title parameter to exit_plan_mode tool to enable plan file renaming during approval workflow. - Implemented NotesProtocolHandler for notes:// URL scheme with path traversal protection and session fallback. - Added renameApprovedPlanFile function to handle plan artifact finalization with validation and error handling. - Updated system prompt documentation to reference notes:// protocol and internal URL schemes for artifact access.
40 lines
1.3 KiB
TypeScript
40 lines
1.3 KiB
TypeScript
import { describe, expect, it } from "bun:test";
|
|
import * as os from "node:os";
|
|
import * as path from "node:path";
|
|
import type { ToolSession } from "../../src/tools";
|
|
import { resolvePlanPath } from "../../src/tools/plan-mode-guard";
|
|
|
|
function makeSession(overrides: {
|
|
artifactsDir?: string | null;
|
|
sessionId?: string | null;
|
|
cwd?: string;
|
|
}): ToolSession {
|
|
return {
|
|
cwd: overrides.cwd ?? "/repo",
|
|
hasUI: false,
|
|
getSessionFile: () => null,
|
|
getSessionSpawns: () => "*",
|
|
settings: {
|
|
getPlansDirectory: () => "/plans",
|
|
},
|
|
getArtifactsDir: () => overrides.artifactsDir ?? null,
|
|
getSessionId: () => overrides.sessionId ?? null,
|
|
} as unknown as ToolSession;
|
|
}
|
|
|
|
describe("resolvePlanPath notes:// support", () => {
|
|
it("resolves notes:// paths under session artifacts notes root", () => {
|
|
const session = makeSession({ artifactsDir: "/tmp/agent-artifacts", sessionId: "abc" });
|
|
expect(resolvePlanPath(session, "notes://handoffs/result.json")).toBe(
|
|
path.join("/tmp/agent-artifacts", "notes", "handoffs", "result.json"),
|
|
);
|
|
});
|
|
|
|
it("falls back to os tmp root when artifacts dir is unavailable", () => {
|
|
const session = makeSession({ artifactsDir: null, sessionId: "session-42" });
|
|
expect(resolvePlanPath(session, "notes://memo.txt")).toBe(
|
|
path.join(os.tmpdir(), "omp-notes", "session-42", "memo.txt"),
|
|
);
|
|
});
|
|
});
|