Files
oh-my-pi/packages/coding-agent/test/tools/plan-mode-guard-local.test.ts
T
can1357 cd5c9655aa refactor: renamed notes protocol to local
- Renamed the `notes://` protocol to `local://` for better clarity.
- Updated all internal references, prompts, and tool documentation.
- Migrated plan storage paths to use the new `local://` scheme.
2026-02-22 18:05:22 +01:00

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 local:// support", () => {
it("resolves local:// paths under session artifacts local root", () => {
const session = makeSession({ artifactsDir: "/tmp/agent-artifacts", sessionId: "abc" });
expect(resolvePlanPath(session, "local://handoffs/result.json")).toBe(
path.join("/tmp/agent-artifacts", "local", "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, "local://memo.txt")).toBe(
path.join(os.tmpdir(), "omp-local", "session-42", "memo.txt"),
);
});
});