feat: add cursor local adapter across server ui and cli

This commit is contained in:
Dotta
2026-03-05 06:31:22 -06:00
parent b4a02ebc3f
commit 8a85173150
35 changed files with 1871 additions and 20 deletions

View File

@@ -1,6 +1,10 @@
import { describe, expect, it } from "vitest";
import { sessionCodec as claudeSessionCodec } from "@paperclipai/adapter-claude-local/server";
import { sessionCodec as codexSessionCodec, isCodexUnknownSessionError } from "@paperclipai/adapter-codex-local/server";
import {
sessionCodec as cursorSessionCodec,
isCursorUnknownSessionError,
} from "@paperclipai/adapter-cursor-local/server";
import {
sessionCodec as opencodeSessionCodec,
isOpenCodeUnknownSessionError,
@@ -60,6 +64,24 @@ describe("adapter session codecs", () => {
});
expect(opencodeSessionCodec.getDisplayId?.(serialized ?? null)).toBe("opencode-session-1");
});
it("normalizes cursor session params with cwd", () => {
const parsed = cursorSessionCodec.deserialize({
session_id: "cursor-session-1",
cwd: "/tmp/cursor",
});
expect(parsed).toEqual({
sessionId: "cursor-session-1",
cwd: "/tmp/cursor",
});
const serialized = cursorSessionCodec.serialize(parsed);
expect(serialized).toEqual({
sessionId: "cursor-session-1",
cwd: "/tmp/cursor",
});
expect(cursorSessionCodec.getDisplayId?.(serialized ?? null)).toBe("cursor-session-1");
});
});
describe("codex resume recovery detection", () => {
@@ -101,3 +123,26 @@ describe("opencode resume recovery detection", () => {
).toBe(false);
});
});
describe("cursor resume recovery detection", () => {
it("detects unknown session errors from cursor output", () => {
expect(
isCursorUnknownSessionError(
"",
"Error: unknown session id abc",
),
).toBe(true);
expect(
isCursorUnknownSessionError(
"",
"chat abc not found",
),
).toBe(true);
expect(
isCursorUnknownSessionError(
"{\"type\":\"result\",\"subtype\":\"success\"}",
"",
),
).toBe(false);
});
});