Open History to see the last commit
1import * as NodeOS from "node:os";
2
3import * as NodeServices from "@effect/platform-node/NodeServices";
4import type * as Crypto from "effect/Crypto";
5import * as Effect from "effect/Effect";
6import * as FileSystem from "effect/FileSystem";
7import * as Path from "effect/Path";
8import type * as ChildProcessSpawner from "effect/unstable/process/ChildProcessSpawner";
9import { describe, expect, it } from "vite-plus/test";
10import type * as EffectAcpSchema from "effect-acp/schema";
11import type { CursorSettings } from "@t3tools/contracts";
12import { createModelCapabilities } from "@t3tools/shared/model";
13
14import {
15 buildCursorProviderSnapshot,
16 buildCursorCapabilitiesFromConfigOptions,
17 checkCursorProviderStatus,
18 discoverCursorModelsViaAcp,
19 getCursorFallbackModels,
20 getCursorParameterizedModelPickerUnsupportedMessage,
21 parseCursorAboutOutput,
22 parseCursorCliConfigChannel,
23 parseCursorVersionDate,
24 resolveCursorAcpBaseModelId,
25 resolveCursorAcpConfigUpdates,
26} from "./CursorProvider.ts";
27import {
28 discoverCursorSkills,
29 hasCursorSkillMention,
30 probeCursorSkills,
31 rewriteCursorSkillMentions,
32} from "../Drivers/CursorSkills.ts";
33import { execScriptSource, writeFakeCli } from "../../testUtils/fakeCli.ts";
34import { HostProcessPlatform } from "@t3tools/shared/hostProcess";
35
36const runNode = <A, E>(
37 effect: Effect.Effect<
38 A,
39 E,
40 ChildProcessSpawner.ChildProcessSpawner | Crypto.Crypto | FileSystem.FileSystem | Path.Path
41 >,
42): Promise<A> => Effect.runPromise(effect.pipe(Effect.provide(NodeServices.layer)));
43
44// Closing the probe kills the agent with SIGTERM; Windows terminates the
45// process instead, so the mock never sees a signal to log.
46const windowsHost = HostProcessPlatform.defaultValue() === "win32";
47
48const resolveMockAgentPath = Effect.fn("resolveMockAgentPath")(function* () {
49 const path = yield* Path.Path;
50 return yield* path.fromFileUrl(new URL("../../../scripts/acp-mock-agent.ts", import.meta.url));
51});
52
53function selectDescriptor(
54 id: string,
55 label: string,
56 options: ReadonlyArray<{ id: string; label: string; isDefault?: boolean }>,
57) {
58 return {
59 id,
60 label,
61 type: "select" as const,
62 options: [...options],
63 ...(options.find((option) => option.isDefault)?.id
64 ? { currentValue: options.find((option) => option.isDefault)?.id }
65 : {}),
66 };
67}
68
69function booleanDescriptor(id: string, label: string, currentValue?: boolean) {
70 return {
71 id,
72 label,
73 type: "boolean" as const,
74 ...(typeof currentValue === "boolean" ? { currentValue } : {}),
75 };
76}
77
78const makeMockAgentWrapper = Effect.fn("makeMockAgentWrapper")(function* (
79 extraEnv?: Record<string, string>,
80) {
81 const fileSystem = yield* FileSystem.FileSystem;
82 const mockAgentPath = yield* resolveMockAgentPath();
83 const dir = yield* fileSystem.makeTempDirectory({
84 directory: NodeOS.tmpdir(),
85 prefix: "cursor-provider-mock-",
86 });
87 return writeFakeCli({
88 directory: dir,
89 name: "fake-agent",
90 env: extraEnv ?? {},
91 source: execScriptSource({ scriptPath: mockAgentPath }),
92 });
93});
94
95const makeMockAgentWithAboutWrapper = Effect.fn("makeMockAgentWithAboutWrapper")(function* () {
96 const fileSystem = yield* FileSystem.FileSystem;
97 const mockAgentPath = yield* resolveMockAgentPath();
98 const dir = yield* fileSystem.makeTempDirectory({
99 directory: NodeOS.tmpdir(),
100 prefix: "cursor-provider-about-mock-",
101 });
102 return writeFakeCli({
103 directory: dir,
104 name: "fake-agent",
105 source: [
106 'if (process.argv[2] === "about") {',
107 ' process.stdout.write("CLI Version 2026.04.09-f2b0fcd\\n");',
108 ' process.stdout.write("User Email cursor@example.com\\n");',
109 " process.exit(0);",
110 "}",
111 execScriptSource({ scriptPath: mockAgentPath }),
112 ].join("\n"),
113 });
114});
115
116const waitForFileContent = Effect.fn("waitForFileContent")(function* (
117 filePath: string,
118 attempts = 40,
119) {
120 const fileSystem = yield* FileSystem.FileSystem;
121 for (let attempt = 0; attempt < attempts; attempt += 1) {
122 const content = yield* fileSystem
123 .readFileString(filePath)
124 .pipe(Effect.catch(() => Effect.void));
125 if (content !== undefined) {
126 if (content.trim().length > 0) {
127 return content;
128 }
129 }
130 yield* Effect.sleep("50 millis");
131 }
132 return yield* Effect.die(`Timed out waiting for file content at ${filePath}`);
133});
134
135const makeProviderStatusEnvFixture = Effect.fn("makeProviderStatusEnvFixture")(function* () {
136 const fileSystem = yield* FileSystem.FileSystem;
137 const path = yield* Path.Path;
138 const tempDir = yield* fileSystem.makeTempDirectory({
139 directory: NodeOS.tmpdir(),
140 prefix: "cursor-provider-status-env-",
141 });
142 return {
143 requestLogPath: path.join(tempDir, "requests.ndjson"),
144 wrapperPath: yield* makeMockAgentWithAboutWrapper(),
145 };
146});
147
148const makeExitLogFixture = Effect.fn("makeExitLogFixture")(function* (prefix: string) {
149 const fileSystem = yield* FileSystem.FileSystem;
150 const path = yield* Path.Path;
151 const tempDir = yield* fileSystem.makeTempDirectory({
152 directory: NodeOS.tmpdir(),
153 prefix,
154 });
155 const exitLogPath = path.join(tempDir, "exit.log");
156 return {
157 exitLogPath,
158 wrapperPath: yield* makeMockAgentWrapper({
159 T3_ACP_EXIT_LOG_PATH: exitLogPath,
160 }),
161 };
162});
163
164const parameterizedGpt54ConfigOptions = [
165 {
166 type: "select",
167 currentValue: "gpt-5.4-medium-fast",
168 options: [{ name: "GPT-5.4", value: "gpt-5.4-medium-fast" }],
169 category: "model",
170 id: "model",
171 name: "Model",
172 },
173 {
174 type: "select",
175 currentValue: "medium",
176 options: [
177 { name: "None", value: "none" },
178 { name: "Low", value: "low" },
179 { name: "Medium", value: "medium" },
180 { name: "High", value: "high" },
181 { name: "Extra High", value: "extra-high" },
182 ],
183 category: "thought_level",
184 id: "reasoning",
185 name: "Reasoning",
186 },
187 {
188 type: "select",
189 currentValue: "272k",
190 options: [
191 { name: "272K", value: "272k" },
192 { name: "1M", value: "1m" },
193 ],
194 category: "model_config",
195 id: "context",
196 name: "Context",
197 },
198 {
199 type: "select",
200 currentValue: "false",
201 options: [
202 { name: "Off", value: "false" },
203 { name: "Fast", value: "true" },
204 ],
205 category: "model_config",
206 id: "fast",
207 name: "Fast",
208 },
209] satisfies ReadonlyArray<EffectAcpSchema.SessionConfigOption>;
210
211const parameterizedClaudeConfigOptions = [
212 {
213 type: "select",
214 currentValue: "claude-4.6-opus-high-thinking",
215 options: [{ name: "Opus 4.6", value: "claude-4.6-opus-high-thinking" }],
216 category: "model",
217 id: "model",
218 name: "Model",
219 },
220 {
221 type: "select",
222 currentValue: "high",
223 options: [
224 { name: "Low", value: "low" },
225 { name: "Medium", value: "medium" },
226 { name: "High", value: "high" },
227 ],
228 category: "thought_level",
229 id: "reasoning",
230 name: "Reasoning",
231 },
232 {
233 type: "boolean",
234 currentValue: true,
235 category: "model_config",
236 id: "thinking",
237 name: "Thinking",
238 },
239] satisfies ReadonlyArray<EffectAcpSchema.SessionConfigOption>;
240
241const parameterizedClaudeModelOptionConfigOptions = [
242 {
243 type: "select",
244 currentValue: "claude-opus-4-6",
245 options: [{ name: "Opus 4.6", value: "claude-opus-4-6" }],
246 category: "model",
247 id: "model",
248 name: "Model",
249 },
250 {
251 type: "select",
252 currentValue: "high",
253 options: [
254 { name: "Low", value: "low" },
255 { name: "Medium", value: "medium" },
256 { name: "High", value: "high" },
257 ],
258 category: "thought_level",
259 id: "reasoning",
260 name: "Reasoning",
261 },
262 {
263 type: "select",
264 currentValue: "max",
265 options: [
266 { name: "Low", value: "low" },
267 { name: "Medium", value: "medium" },
268 { name: "High", value: "high" },
269 { name: "Max", value: "max" },
270 ],
271 category: "model_option",
272 id: "effort",
273 name: "Effort",
274 },
275 {
276 type: "select",
277 currentValue: "true",
278 options: [
279 { name: "Off", value: "false" },
280 { name: "Fast", value: "true" },
281 ],
282 category: "model_config",
283 id: "fast",
284 name: "Fast",
285 },
286 {
287 type: "select",
288 currentValue: "true",
289 options: [
290 { name: "Off", value: "false" },
291 { name: ":icon-brain:", value: "true" },
292 ],
293 category: "model_config",
294 id: "thinking",
295 name: "Thinking",
296 },
297] satisfies ReadonlyArray<EffectAcpSchema.SessionConfigOption>;
298
299const baseCursorSettings: CursorSettings = {
300 enabled: true,
301 binaryPath: "cursor-agent",
302 apiEndpoint: "",
303 customModels: [],
304};
305const cursorAcpDiscoveryFailedMessage = [
306 "Cursor ACP model discovery failed.",
307 "Cursor CLI setup may be incomplete; install or enable the Cursor CLI, restart T3 Code, and try again.",
308 "See https://cursor.com/docs/cli/installation.",
309 "Check server logs for ACP details.",
310].join(" ");
311const missingCursorBinaryPath = "/definitely/not/installed/t3-cursor-agent";
312const cursorCliCommandMissingMessage = [
313 `Cursor CLI command \`${missingCursorBinaryPath}\` was not found.`,
314 `Install or enable the Cursor CLI, make sure \`${missingCursorBinaryPath}\` is on PATH, then restart T3 Code.`,
315 "See https://cursor.com/docs/cli/installation.",
316].join(" ");
317
318describe("Cursor skills", () => {
319 it("discovers recursive project skills with project precedence", async () =>
320 await runNode(
321 Effect.gen(function* () {
322 const fileSystem = yield* FileSystem.FileSystem;
323 const path = yield* Path.Path;
324 const userHome = yield* fileSystem.makeTempDirectory({
325 directory: NodeOS.tmpdir(),
326 prefix: "cursor-skills-home-",
327 });
328 const workspace = yield* fileSystem.makeTempDirectory({
329 directory: NodeOS.tmpdir(),
330 prefix: "cursor-skills-workspace-",
331 });
332 const writeSkill = Effect.fn("writeCursorSkill")(function* (
333 root: string,
334 name: string,
335 contents: string,
336 ) {
337 const skillDirectory = path.join(root, name);
338 yield* fileSystem.makeDirectory(skillDirectory, { recursive: true });
339 yield* fileSystem.writeFileString(path.join(skillDirectory, "SKILL.md"), contents);
340 });
341
342 yield* writeSkill(
343 path.join(userHome, ".cursor", "skills"),
344 "review",
345 "---\ndescription: user review\n---\n",
346 );
347 yield* writeSkill(
348 path.join(workspace, ".agents", "skills", "nested"),
349 "review",
350 "---\nname: Review changes\ndescription: project review\n---\n",
351 );
352 yield* writeSkill(
353 path.join(workspace, ".cursor", "skills"),
354 "internal",
355 "---\nuser-invocable: false\n---\n",
356 );
357 yield* writeSkill(
358 path.join(workspace, ".cursor", "skills"),
359 "oversized",
360 "x".repeat(1_000_001),
361 );
362 yield* fileSystem.makeDirectory(path.join(userHome, ".codex"), { recursive: true });
363 yield* fileSystem.writeFileString(
364 path.join(userHome, ".codex", "skills"),
365 "not a directory",
366 );
367
368 const skills = yield* discoverCursorSkills(workspace, { HOME: userHome });
369 expect(skills).toEqual([
370 {
371 name: "internal",
372 path: path.join(workspace, ".cursor", "skills", "internal", "SKILL.md"),
373 scope: "project",
374 enabled: true,
375 userInvocable: false,
376 },
377 {
378 name: "oversized",
379 path: path.join(workspace, ".cursor", "skills", "oversized", "SKILL.md"),
380 scope: "project",
381 enabled: true,
382 },
383 {
384 name: "review",
385 displayName: "Review changes",
386 description: "project review",
387 path: path.join(workspace, ".agents", "skills", "nested", "review", "SKILL.md"),
388 scope: "project",
389 enabled: true,
390 },
391 ]);
392 expect(
393 (yield* probeCursorSkills(workspace, { HOME: userHome }).pipe(Effect.result))._tag,
394 ).toBe("Failure");
395 }),
396 ));
397
398 it("rewrites only discovered skill mentions into Cursor slash invocations", () => {
399 expect(hasCursorSkillMention("use $Review_Pr:V2 here")).toBe(true);
400 expect(hasCursorSkillMention("please $review this")).toBe(true);
401 expect(
402 rewriteCursorSkillMentions("use $review, keep $HOME and 5$review", new Set(["review"])),
403 ).toBe("use $review, keep $HOME and 5$review");
404 expect(rewriteCursorSkillMentions("please $review this", new Set(["review"]))).toBe(
405 "please /review this",
406 );
407 });
408});
409
410describe("getCursorFallbackModels", () => {
411 it("does not publish any built-in cursor models before ACP discovery", () => {
412 expect(
413 getCursorFallbackModels({
414 customModels: ["internal/cursor-model"],
415 }).map((model) => model.slug),
416 ).toEqual(["internal/cursor-model"]);
417 });
418});
419
420describe("buildCursorProviderSnapshot", () => {
421 it("downgrades ready status to warning when ACP model discovery times out", () => {
422 expect(
423 buildCursorProviderSnapshot({
424 checkedAt: "2026-01-01T00:00:00.000Z",
425 cursorSettings: baseCursorSettings,
426 parsed: {
427 version: "2026.04.09-f2b0fcd",
428 status: "ready",
429 auth: { status: "authenticated", type: "Team", label: "Cursor Team Subscription" },
430 },
431 discoveryWarning: "Cursor ACP model discovery timed out after 15000ms.",
432 }),
433 ).toMatchObject({
434 status: "warning",
435 message: "Cursor ACP model discovery timed out after 15000ms.",
436 models: [],
437 });
438 });
439
440 it("preserves provider error state while appending discovery warnings", () => {
441 expect(
442 buildCursorProviderSnapshot({
443 checkedAt: "2026-01-01T00:00:00.000Z",
444 cursorSettings: {
445 ...baseCursorSettings,
446 customModels: ["claude-sonnet-4-6"],
447 },
448 parsed: {
449 version: "2026.04.09-f2b0fcd",
450 status: "error",
451 auth: { status: "unauthenticated" },
452 message: "Cursor Agent is not authenticated. Run `agent login` and try again.",
453 },
454 discoveryWarning: cursorAcpDiscoveryFailedMessage,
455 }),
456 ).toMatchObject({
457 status: "error",
458 message: `Cursor Agent is not authenticated. Run \`agent login\` and try again. ${cursorAcpDiscoveryFailedMessage}`,
459 models: [
460 {
461 slug: "claude-sonnet-4-6",
462 isCustom: true,
463 },
464 ],
465 });
466 });
467});
468
469describe("buildCursorCapabilitiesFromConfigOptions", () => {
470 it("derives model capabilities from parameterized Cursor ACP config options", () => {
471 expect(buildCursorCapabilitiesFromConfigOptions(parameterizedGpt54ConfigOptions)).toEqual(
472 createModelCapabilities({
473 optionDescriptors: [
474 selectDescriptor("reasoning", "Reasoning", [
475 { id: "low", label: "Low" },
476 { id: "medium", label: "Medium", isDefault: true },
477 { id: "high", label: "High" },
478 { id: "xhigh", label: "Extra High" },
479 ]),
480 selectDescriptor("contextWindow", "Context", [
481 { id: "272k", label: "272K", isDefault: true },
482 { id: "1m", label: "1M" },
483 ]),
484 booleanDescriptor("fastMode", "Fast", false),
485 ],
486 }),
487 );
488 });
489
490 it("detects boolean thinking toggles from model_config options", () => {
491 expect(buildCursorCapabilitiesFromConfigOptions(parameterizedClaudeConfigOptions)).toEqual(
492 createModelCapabilities({
493 optionDescriptors: [
494 selectDescriptor("reasoning", "Reasoning", [
495 { id: "low", label: "Low" },
496 { id: "medium", label: "Medium" },
497 { id: "high", label: "High", isDefault: true },
498 ]),
499 booleanDescriptor("thinking", "Thinking", true),
500 ],
501 }),
502 );
503 });
504
505 it("prefers the newer model_option effort control over legacy thought_level", () => {
506 expect(
507 buildCursorCapabilitiesFromConfigOptions(parameterizedClaudeModelOptionConfigOptions),
508 ).toEqual(
509 createModelCapabilities({
510 optionDescriptors: [
511 selectDescriptor("reasoning", "Effort", [
512 { id: "low", label: "Low" },
513 { id: "medium", label: "Medium" },
514 { id: "high", label: "High" },
515 { id: "max", label: "Max", isDefault: true },
516 ]),
517 booleanDescriptor("fastMode", "Fast", true),
518 booleanDescriptor("thinking", "Thinking", true),
519 ],
520 }),
521 );
522 });
523});
524
525describe("checkCursorProviderStatus", () => {
526 it("reports the install docs when the Cursor CLI command is missing", async () => {
527 const provider = await runNode(
528 checkCursorProviderStatus({
529 enabled: true,
530 binaryPath: missingCursorBinaryPath,
531 apiEndpoint: "",
532 customModels: [],
533 }),
534 );
535
536 expect(provider).toMatchObject({
537 installed: false,
538 status: "error",
539 auth: { status: "unknown" },
540 message: cursorCliCommandMissingMessage,
541 });
542 });
543
544 it("passes the injected environment to ACP model discovery", async () => {
545 const { requestLogPath, wrapperPath } = await runNode(makeProviderStatusEnvFixture());
546
547 const provider = await runNode(
548 checkCursorProviderStatus(
549 {
550 enabled: true,
551 binaryPath: wrapperPath,
552 apiEndpoint: "",
553 customModels: [],
554 },
555 {
556 ...process.env,
557 T3_ACP_REQUEST_LOG_PATH: requestLogPath,
558 },
559 ),
560 );
561
562 expect(provider.models.map((model) => model.slug)).toEqual([
563 "default",
564 "composer-2",
565 "gpt-5.4",
566 "claude-opus-4-6",
567 ]);
568 await expect(runNode(waitForFileContent(requestLogPath))).resolves.toContain("initialize");
569 });
570});
571
572describe("discoverCursorModelsViaAcp", () => {
573 it("keeps the ACP probe runtime alive long enough to discover models", async () => {
574 const wrapperPath = await runNode(makeMockAgentWrapper());
575
576 const models = await runNode(
577 discoverCursorModelsViaAcp({
578 enabled: true,
579 binaryPath: wrapperPath,
580 apiEndpoint: "",
581 customModels: [],
582 }).pipe(Effect.scoped),
583 );
584
585 expect(models.map((model) => model.slug)).toEqual([
586 "default",
587 "composer-2",
588 "gpt-5.4",
589 "claude-opus-4-6",
590 ]);
591 });
592
593 it.skipIf(windowsHost)("closes the ACP probe runtime after discovery completes", async () => {
594 const { exitLogPath, wrapperPath } = await runNode(
595 makeExitLogFixture("cursor-provider-exit-log-"),
596 );
597
598 await runNode(
599 discoverCursorModelsViaAcp({
600 enabled: true,
601 binaryPath: wrapperPath,
602 apiEndpoint: "",
603 customModels: [],
604 }),
605 );
606
607 const exitLog = await runNode(waitForFileContent(exitLogPath));
608 expect(exitLog).toContain("SIGTERM");
609 });
610});
611
612describe("parseCursorAboutOutput", () => {
613 it("parses json about output and forwards subscription metadata", () => {
614 expect(
615 parseCursorAboutOutput({
616 code: 0,
617 stdout: JSON.stringify({
618 cliVersion: "2026.04.09-f2b0fcd",
619 subscriptionTier: "Team",
620 userEmail: "jmarminge@gmail.com",
621 }),
622 stderr: "",
623 }),
624 ).toEqual({
625 version: "2026.04.09-f2b0fcd",
626 status: "ready",
627 auth: {
628 status: "authenticated",
629 email: "jmarminge@gmail.com",
630 type: "Team",
631 label: "Cursor Team Subscription",
632 },
633 });
634 });
635
636 it("treats json about output with a logged-out email as unauthenticated", () => {
637 expect(
638 parseCursorAboutOutput({
639 code: 0,
640 stdout: JSON.stringify({
641 cliVersion: "2026.04.09-f2b0fcd",
642 subscriptionTier: "Team",
643 userEmail: "Not logged in",
644 }),
645 stderr: "",
646 }),
647 ).toEqual({
648 version: "2026.04.09-f2b0fcd",
649 status: "error",
650 auth: {
651 status: "unauthenticated",
652 },
653 message: "Cursor Agent is not authenticated. Run `agent login` and try again.",
654 });
655 });
656
657 it("treats json about output with a null email as unauthenticated", () => {
658 expect(
659 parseCursorAboutOutput({
660 code: 0,
661 stdout: JSON.stringify({
662 cliVersion: "2026.04.09-f2b0fcd",
663 subscriptionTier: null,
664 userEmail: null,
665 }),
666 stderr: "",
667 }),
668 ).toEqual({
669 version: "2026.04.09-f2b0fcd",
670 status: "error",
671 auth: {
672 status: "unauthenticated",
673 },
674 message: "Cursor Agent is not authenticated. Run `agent login` and try again.",
675 });
676 });
677});
678
679describe("Cursor parameterized model picker preview gating", () => {
680 it("parses Cursor CLI version dates from build versions", () => {
681 expect(parseCursorVersionDate("2026.04.08-c4e73a3")).toBe(20260408);
682 expect(parseCursorVersionDate("2026.04.09")).toBe(20260409);
683 expect(parseCursorVersionDate("not-a-version")).toBeUndefined();
684 });
685
686 it("parses the Cursor CLI channel from cli-config.json", () => {
687 expect(parseCursorCliConfigChannel('{ "channel": "lab" }')).toBe("lab");
688 expect(parseCursorCliConfigChannel('{ "channel": "stable" }')).toBe("stable");
689 expect(parseCursorCliConfigChannel('{ "version": 1 }')).toBeUndefined();
690 expect(parseCursorCliConfigChannel("not-json")).toBeUndefined();
691 });
692
693 it("returns no warning when the preview requirements are met", () => {
694 expect(
695 getCursorParameterizedModelPickerUnsupportedMessage({
696 version: "2026.04.08-c4e73a3",
697 channel: "lab",
698 }),
699 ).toBeUndefined();
700 });
701
702 it("explains when the Cursor Agent version is too old", () => {
703 expect(
704 getCursorParameterizedModelPickerUnsupportedMessage({
705 version: "2026.04.07-c4e73a3",
706 channel: "lab",
707 }),
708 ).toContain("too old");
709 });
710
711 it("explains when the Cursor Agent channel is not lab", () => {
712 expect(
713 getCursorParameterizedModelPickerUnsupportedMessage({
714 version: "2026.04.08-c4e73a3",
715 channel: "stable",
716 }),
717 ).toContain("lab channel");
718 });
719});
720
721describe("resolveCursorAcpBaseModelId", () => {
722 it("drops bracket traits without rewriting raw ACP model ids", () => {
723 expect(resolveCursorAcpBaseModelId("gpt-5.4[reasoning=medium,context=272k]")).toBe("gpt-5.4");
724 expect(resolveCursorAcpBaseModelId("gpt-5.4-medium-fast")).toBe("gpt-5.4-medium-fast");
725 expect(resolveCursorAcpBaseModelId("claude-4.6-opus-high-thinking")).toBe(
726 "claude-4.6-opus-high-thinking",
727 );
728 expect(resolveCursorAcpBaseModelId("composer-2")).toBe("composer-2");
729 expect(resolveCursorAcpBaseModelId("auto")).toBe("auto");
730 });
731});
732
733describe("resolveCursorAcpConfigUpdates", () => {
734 it("maps Cursor model options onto separate ACP config option updates", () => {
735 expect(
736 resolveCursorAcpConfigUpdates(parameterizedGpt54ConfigOptions, [
737 { id: "reasoning", value: "xhigh" },
738 { id: "fastMode", value: true },
739 { id: "contextWindow", value: "1m" },
740 ]),
741 ).toEqual([
742 { configId: "reasoning", value: "extra-high" },
743 { configId: "context", value: "1m" },
744 { configId: "fast", value: "true" },
745 ]);
746 });
747
748 it("maps boolean thinking toggles when the model exposes them separately", () => {
749 expect(
750 resolveCursorAcpConfigUpdates(parameterizedClaudeConfigOptions, [
751 { id: "thinking", value: false },
752 ]),
753 ).toEqual([{ configId: "thinking", value: false }]);
754 });
755
756 it("maps explicit fastMode: false so the adapter can clear a prior fast selection", () => {
757 expect(
758 resolveCursorAcpConfigUpdates(parameterizedGpt54ConfigOptions, [
759 { id: "fastMode", value: false },
760 ]),
761 ).toEqual([{ configId: "fast", value: "false" }]);
762 });
763
764 it("writes Cursor effort changes through the newer model_option config when available", () => {
765 expect(
766 resolveCursorAcpConfigUpdates(parameterizedClaudeModelOptionConfigOptions, [
767 { id: "reasoning", value: "max" },
768 { id: "thinking", value: false },
769 ]),
770 ).toEqual([
771 { configId: "effort", value: "max" },
772 { configId: "thinking", value: "false" },
773 ]);
774 });
775});