Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

CursorProvider.test.ts

778 lines23.8 KB

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