CodeNomad/packages/server/src/permissions/opencode-replier.test.ts
Pascal André 775c6c6ca1
refactor(v2): remove dead migration scaffolding
Delete the obsolete pre-MVP roadmap and task references now that Git preserves that development history, while retaining current V2 operational and architecture guidance.

Remove behavior-neutral server and UI plumbing that has no remaining caller: unused workspace options and cached endpoint state, redundant auto-accept metadata, an unused PTY get adapter, and a one-use message-loading helper. Keep lifecycle proof, restore gates, timeline projection, and targeted invalidation because they still enforce runtime behavior.

Validated with server and UI typechecks, the full server suite (308 passed, 3 skipped), focused UI matrices, browser-conditioned UI tests, production server/UI build, diff checks, caller searches, and an independent regression review.
2026-08-18 23:21:43 +02:00

53 lines
2 KiB
TypeScript

import assert from "node:assert/strict"
import { describe, it } from "node:test"
import type { OpenCodeClient } from "@opencode-ai/client"
import type { WorkspaceManager } from "../workspaces/manager"
import { createOpencodePermissionReplier } from "./opencode-replier"
describe("createOpencodePermissionReplier", () => {
it("uses the native permission reply input", async () => {
const calls: Array<Record<string, unknown>> = []
const client = {
session: {
get: async () => ({ location: { directory: "/repo" } }),
},
permission: { reply: async (input: Record<string, unknown>) => { calls.push(input) } },
} as unknown as OpenCodeClient
const workspaceManager = {
get: () => ({ path: "/repo" }),
getSharedServiceClient: async () => client,
ownsDirectory: async (_instanceId: string, directory: string) => directory === "/repo",
} as unknown as WorkspaceManager
const replier = createOpencodePermissionReplier({ workspaceManager })
await replier({
instanceId: "instance",
sessionId: "session",
permissionId: "permission",
})
assert.deepEqual(calls, [{ sessionID: "session", requestID: "permission", reply: "once" }])
})
it("does not reply across logical workspace ownership", async () => {
const calls: Array<Record<string, unknown>> = []
const client = {
session: { get: async () => ({ location: { directory: "/other" } }) },
permission: { reply: async (input: Record<string, unknown>) => { calls.push(input) } },
} as unknown as OpenCodeClient
const workspaceManager = {
get: () => ({ path: "/repo" }),
getSharedServiceClient: async () => client,
ownsDirectory: async () => false,
} as unknown as WorkspaceManager
const replier = createOpencodePermissionReplier({ workspaceManager })
await assert.rejects(replier({
instanceId: "instance",
sessionId: "foreign-session",
permissionId: "permission",
}), /does not belong/)
assert.deepEqual(calls, [])
})
})