From ff5f259efd008abb6d796f1f4fef45515ba6db34 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Sun, 1 Nov 2026 15:43:30 +0000 Subject: [PATCH 1/4] test(cursor): reproduce #28713 missing catalog params on Cursor runs Adds a failing adapter test: with a grok-4.5 catalog from getModels, a selection with no options (Settings default) and one with only fastMode false both reach the Cursor SDK without the catalog's effort default, at agent open and on send. These tests reproduce pingdotgg/t3code#28713. Co-Authored-By: Claude Opus 5.5 --- .../src/server/adapter.test.ts | 163 +++++++++++++++++- 1 file changed, 162 insertions(+), 1 deletion(-) diff --git a/packages/provider-cursor/src/server/adapter.test.ts b/packages/provider-cursor/src/server/adapter.test.ts index 5318e160f610c..9a63f76df0622 100644 --- a/packages/provider-cursor/src/server/adapter.test.ts +++ b/packages/provider-cursor/src/server/adapter.test.ts @@ -1,6 +1,6 @@ import * as NodeServices from "@effect/platform-node/NodeServices"; import { assert, describe, it } from "@effect/vitest"; -import type { InteractionUpdate } from "@cursor/sdk"; +import type { InteractionUpdate, ModelSelection as CursorSdkModelSelection } from "@cursor/sdk"; import { EnvironmentId, MessageId, @@ -33,6 +33,7 @@ import { nestedToolCallFromEnvelope, } from "./adapter.ts"; import * as CursorAgentSdk from "./CursorAgentSdk.ts"; +import { buildCursorDiscoveredModelsFromSdk } from "./status.ts"; import { ConfigurationError } from "./sdk.ts"; describe("CursorAdapterV2", () => { @@ -1585,6 +1586,166 @@ describe("CursorAdapterV2", () => { ), ); + it.effect("sends every catalog parameter when the selection leaves them unset", () => + Effect.gen(function* () { + const fileSystem = yield* FileSystem.FileSystem; + const workspace = yield* fileSystem.makeTempDirectoryScoped({ prefix: "cursor-v2-params-" }); + const instanceId = ProviderInstanceId.make("cursor"); + const threadId = ThreadId.make("cursor-params-thread"); + const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({ + runtimeMode: "full-access", + interactionMode: "default", + cwd: workspace, + }); + const models = buildCursorDiscoveredModelsFromSdk([ + { + id: "grok-4.5", + displayName: "Grok 4.5", + parameters: [ + { + id: "effort", + displayName: "Effort", + values: [{ value: "low" }, { value: "medium" }, { value: "high" }], + }, + { id: "fast", displayName: "Fast", values: [{ value: "false" }, { value: "true" }] }, + ], + variants: [ + { + displayName: "Grok 4.5 High Fast", + isDefault: true, + params: [ + { id: "effort", value: "high" }, + { id: "fast", value: "true" }, + ], + }, + ], + }, + ]); + const sent: Array<{ readonly method: string; readonly model: unknown }> = []; + const record = (method: string, model: CursorSdkModelSelection | undefined) => + sent.push({ + method, + model: + model === undefined + ? undefined + : { + id: model.id, + params: model.params?.toSorted((a, b) => a.id.localeCompare(b.id)), + }, + }); + const adapter = yield* makeCursorAdapterV2({ + instanceId, + environment: { HOME: workspace }, + getModels: () => models, + }).pipe( + Effect.provideService(CursorAgentSdk.CursorAgentSdkRunner, { + assertComplete: Effect.void, + open: (input) => { + record(`agent.${input.operation}`, input.options.model); + return Effect.succeed({ + agentId: "native-cursor-params", + listMessages: Effect.succeed([]), + close: Effect.void, + send: (sendInput) => { + record("run.start", sendInput.options?.model); + return Effect.fail( + new CursorAgentSdk.CursorAgentSdkRunnerError({ + method: "run.start", + cause: new Error("stop after recording the model"), + }), + ); + }, + }); + }, + }), + Effect.provide(TestProviderHost.layer({ cwd: workspace })), + ); + // A default model from Settings carries no options; the composer adds only Fast off. + const settingsDefault = { instanceId, model: "grok-4.5" }; + const composerSelection = { + instanceId, + model: "grok-4.5", + options: [{ id: "fastMode", value: false }], + }; + const runtime = yield* adapter.openSession({ + threadId, + providerSessionId: ProviderSessionId.make("cursor-params-session"), + modelSelection: settingsDefault, + runtimePolicy, + }); + const providerThread = yield* runtime.ensureThread({ + threadId, + modelSelection: settingsDefault, + runtimePolicy, + }); + const now = yield* DateTime.now; + for (const [ordinal, modelSelection] of [settingsDefault, composerSelection].entries()) { + yield* runtime + .startTurn({ + threadId, + providerThread, + modelSelection, + runtimePolicy, + runId: RunId.make(`cursor-params-run-${ordinal}`), + runOrdinal: ordinal + 1, + providerTurnOrdinal: ordinal + 1, + attemptId: RunAttemptId.make(`cursor-params-attempt-${ordinal}`), + rootNodeId: NodeId.make(`cursor-params-root-${ordinal}`), + appThread: { + id: threadId, + projectId: ProjectId.make("cursor-params-project"), + createdBy: "user", + creationSource: "web", + title: "Cursor params", + providerInstanceId: instanceId, + modelSelection, + runtimeMode: "full-access", + interactionMode: "default", + branch: null, + worktreePath: null, + activeProviderThreadId: providerThread.id, + lineage: { parentThreadId: null, relationshipToParent: null, rootThreadId: threadId }, + forkedFrom: null, + createdAt: now, + updatedAt: now, + archivedAt: null, + settledOverride: null, + settledAt: null, + lastVisitedAt: null, + deletedAt: null, + }, + message: { + messageId: MessageId.make(`cursor-params-message-${ordinal}`), + createdBy: "user", + creationSource: "web", + text: "Hello.", + attachments: [], + }, + }) + .pipe(Effect.flip); + } + + // Cursor rejects some plans' runs unless each catalog parameter is set; Fast stays off. + const catalogDefaults = { + id: "grok-4.5", + params: [ + { id: "effort", value: "high" }, + { id: "fast", value: "false" }, + ], + }; + assert.deepEqual(sent, [ + { method: "agent.create", model: catalogDefaults }, + { method: "run.start", model: catalogDefaults }, + { method: "run.start", model: catalogDefaults }, + ]); + }).pipe( + Effect.scoped, + Effect.provide( + Layer.mergeAll(NodeServices.layer, IdAllocator.layer, McpProviderSessions.layer), + ), + ), + ); + it("maps runtime modes to the SDK sandbox and auto-review controls", () => { const base = { interactionMode: "default" as const, From f85838ff22eb6220e39f9ba6af07cb2bb6a68a88 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Sun, 1 Nov 2026 15:48:32 +0000 Subject: [PATCH 2/4] fix(cursor): send every catalog parameter with Cursor model selections Cursor rejects runs on some plans ("Model unavailable on Plus ... with fixed settings") when the model selection leaves a catalog parameter unset. New chats using the Settings default, delegate_task without options, scheduled tasks and mobile all sent incomplete selections. cursorSdkModelSelection now fills each option the selection leaves unset from the model's catalog descriptor default, with Fast sent as off. The adapter passes its catalog at agent open and on every run. Models missing from the catalog keep sending only their explicit options. Fixes pingdotgg/t3code#28713 Co-Authored-By: Claude Opus 5.5 --- .../provider-cursor/src/server/adapter.ts | 9 +++++++-- .../provider-cursor/src/server/driver.test.ts | 2 +- .../provider-cursor/src/server/sdkModel.ts | 20 ++++++++++++++++--- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/packages/provider-cursor/src/server/adapter.ts b/packages/provider-cursor/src/server/adapter.ts index ab6afddb4b899..546a818528545 100644 --- a/packages/provider-cursor/src/server/adapter.ts +++ b/packages/provider-cursor/src/server/adapter.ts @@ -296,6 +296,7 @@ const CURSOR_AGENT_SETTING_SOURCES = [ export function makeCursorAgentOptions(input: { readonly apiKey?: string; readonly modelSelection: ModelSelection; + readonly models?: ReadonlyArray; readonly runtimePolicy: ProviderAdapter.ProviderAdapterV2RuntimePolicy; readonly threadId: ThreadId; readonly mcpSession: McpProviderSession.McpProviderSessionConfig | undefined; @@ -304,7 +305,7 @@ export function makeCursorAgentOptions(input: { const policy = cursorRuntimeAgentPolicy(input.runtimePolicy, input.platform); const mcpServers = cursorMcpServers(input.mcpSession); return { - model: cursorSdkModelSelection(input.modelSelection), + model: cursorSdkModelSelection(input.modelSelection, input.models), name: `T3 Code ${input.threadId}`, mode: input.runtimePolicy.interactionMode === "plan" ? "plan" : "agent", ...(input.apiKey === undefined ? {} : { apiKey: input.apiKey }), @@ -2234,6 +2235,7 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* ( const options = makeCursorAgentOptions({ ...(apiKey === undefined ? {} : { apiKey }), modelSelection: openInput.modelSelection, + models: adapterOptions.getModels?.() ?? [], runtimePolicy: openInput.runtimePolicy, platform, threadId: openInput.threadId, @@ -2392,7 +2394,10 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* ( .send({ message, options: { - model: cursorSdkModelSelection(turnInput.modelSelection), + model: cursorSdkModelSelection( + turnInput.modelSelection, + adapterOptions.getModels?.() ?? [], + ), mode: turnInput.runtimePolicy.interactionMode === "plan" ? "plan" : "agent", }, onDelta: (update) => { diff --git a/packages/provider-cursor/src/server/driver.test.ts b/packages/provider-cursor/src/server/driver.test.ts index 5a3202fd20e4d..ed1310ea20076 100644 --- a/packages/provider-cursor/src/server/driver.test.ts +++ b/packages/provider-cursor/src/server/driver.test.ts @@ -371,7 +371,7 @@ it.layer(layerTest)("CursorDriver", (it) => { allowance: DEFAULT_HANDOFF_TOKEN_CAP, }, catalogDefault: { - model: { id: "claude-opus-5-5" }, + model: { id: "claude-opus-5-5", params: [{ id: "context", value: "1m" }] }, window: 1_000_000, allowance: DEFAULT_HANDOFF_TOKEN_CAP, }, diff --git a/packages/provider-cursor/src/server/sdkModel.ts b/packages/provider-cursor/src/server/sdkModel.ts index fec0bafc45eee..ec2a53b6aea71 100644 --- a/packages/provider-cursor/src/server/sdkModel.ts +++ b/packages/provider-cursor/src/server/sdkModel.ts @@ -55,13 +55,27 @@ export function cursorContextWindowTokens( return Number.isSafeInteger(tokens) && tokens > 0 ? tokens : undefined; } -export function cursorSdkModelSelection(modelSelection: ModelSelection): CursorSdkModelSelection { +export function cursorSdkModelSelection( + modelSelection: ModelSelection, + models: ReadonlyArray = [], +): CursorSdkModelSelection { + const explicit = modelSelection.options ?? []; + const descriptors = + models.find((model) => model.slug === modelSelection.model)?.capabilities?.optionDescriptors ?? + []; + // Some Cursor plans reject runs that leave a catalog parameter unset; T3 keeps Fast off until picked. + const defaults = descriptors.flatMap((descriptor) => { + if (explicit.some((option) => option.id === descriptor.id)) return []; + const value = descriptor.id === "fastMode" ? false : getProviderOptionCurrentValue(descriptor); + return value === undefined ? [] : [{ id: descriptor.id, value }]; + }); + const options = [...explicit, ...defaults]; return { id: modelSelection.model === "auto" ? "default" : modelSelection.model, - ...(modelSelection.options === undefined || modelSelection.options.length === 0 + ...(options.length === 0 ? {} : { - params: modelSelection.options.map((option): ModelParameterValue => ({ + params: options.map((option): ModelParameterValue => ({ id: cursorSdkParameterId(option.id), value: String(option.value), })), From 8b10fb952f6d82f64e634d86c6c36f1bbd00067f Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Sun, 1 Nov 2026 15:58:46 +0000 Subject: [PATCH 3/4] fix(cursor): text generation sends catalog parameters too Thread titles and commit or PR text built through Cursor sent a bare model id, which Cursor Plus rejects the same way it rejects chat runs. Co-Authored-By: Claude Opus 5.5 --- packages/provider-cursor/src/server/driver.ts | 1 + .../src/server/textGeneration.test.ts | 57 +++++++++++++++++++ .../src/server/textGeneration.ts | 9 ++- 3 files changed, 65 insertions(+), 2 deletions(-) diff --git a/packages/provider-cursor/src/server/driver.ts b/packages/provider-cursor/src/server/driver.ts index de7251fb56b10..83c4fcd83ccb0 100644 --- a/packages/provider-cursor/src/server/driver.ts +++ b/packages/provider-cursor/src/server/driver.ts @@ -211,6 +211,7 @@ export const CursorDriver: ProviderDriver< processEnv, auth.requireApiKey, auth.withAccess, + () => catalogModels, ); const checkProvider = auth.readApiKey.pipe( diff --git a/packages/provider-cursor/src/server/textGeneration.test.ts b/packages/provider-cursor/src/server/textGeneration.test.ts index 7d5e98357bbb1..7b7aba62d8fc2 100644 --- a/packages/provider-cursor/src/server/textGeneration.test.ts +++ b/packages/provider-cursor/src/server/textGeneration.test.ts @@ -9,6 +9,7 @@ import * as Schema from "effect/Schema"; import { createModelSelection } from "@t3tools/shared/model"; import { beforeEach, vi } from "vite-plus/test"; +import { buildCursorDiscoveredModelsFromSdk } from "./status.ts"; import { makeCursorTextGeneration } from "./textGeneration.ts"; import * as CursorSdk from "./CursorSdk.ts"; @@ -103,6 +104,62 @@ describe("CursorTextGeneration", () => { }).pipe(Effect.provide(layerTest)), ); + it.effect("sends every catalog parameter when the selection leaves them unset", () => + Effect.gen(function* () { + const models = buildCursorDiscoveredModelsFromSdk([ + { + id: "grok-4.5", + displayName: "Grok 4.5", + parameters: [ + { + id: "effort", + displayName: "Effort", + values: [{ value: "low" }, { value: "medium" }, { value: "high" }], + }, + { id: "fast", displayName: "Fast", values: [{ value: "false" }, { value: "true" }] }, + ], + variants: [ + { + displayName: "Grok 4.5 High Fast", + isDefault: true, + params: [ + { id: "effort", value: "high" }, + { id: "fast", value: "true" }, + ], + }, + ], + }, + ]); + const generation = yield* makeCursorTextGeneration( + cursorSettings, + { CURSOR_API_KEY: "test-cursor-key" }, + undefined, + undefined, + () => models, + ); + + yield* generation.generateCommitMessage({ + cwd: process.cwd(), + branch: "feature/cursor", + stagedSummary: "M file.ts", + stagedPatch: "diff", + modelSelection: createModelSelection(ProviderInstanceId.make("cursor"), "grok-4.5"), + }); + + expect(cursorSdkMock.create).toHaveBeenLastCalledWith( + expect.objectContaining({ + model: { + id: "grok-4.5", + params: [ + { id: "effort", value: "high" }, + { id: "fast", value: "false" }, + ], + }, + }), + ); + }).pipe(Effect.provide(layerTest)), + ); + it.effect("continues in the temp directory when the SDK cannot sandbox", () => Effect.gen(function* () { cursorSdkMock.create.mockImplementationOnce(async () => { diff --git a/packages/provider-cursor/src/server/textGeneration.ts b/packages/provider-cursor/src/server/textGeneration.ts index 278f35f0f91a6..4daddb52dd8bf 100644 --- a/packages/provider-cursor/src/server/textGeneration.ts +++ b/packages/provider-cursor/src/server/textGeneration.ts @@ -5,7 +5,11 @@ import * as Effect from "effect/Effect"; import * as Option from "effect/Option"; import * as Schema from "effect/Schema"; -import { type ProviderSetupError, TextGenerationError } from "@t3tools/contracts"; +import { + type ProviderSetupError, + type ServerProviderModel, + TextGenerationError, +} from "@t3tools/contracts"; import type { CursorSettings } from "../settings.ts"; import * as TextGenerationOperations from "@t3tools/provider-core/server/textGenerationOperations"; @@ -48,6 +52,7 @@ export const makeCursorTextGeneration = Effect.fn("makeCursorTextGeneration")(fu environment?: NodeJS.ProcessEnv, resolveApiKey?: Effect.Effect, withAccess?: CursorAuth["withAccess"], + getModels?: () => ReadonlyArray, ) { const fs = yield* FileSystem.FileSystem; const { Agent, SqliteLocalAgentStore } = yield* CursorSdk.CursorSdk; @@ -101,7 +106,7 @@ export const makeCursorTextGeneration = Effect.fn("makeCursorTextGeneration")(fu const agentOptions = { apiKey, mode: "plan", - model: cursorSdkModelSelection(modelSelection), + model: cursorSdkModelSelection(modelSelection, getModels?.() ?? []), local: { cwd, store, From a71e89c76a0ad1a49459a4d87d956cf20a0da8c7 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Tue, 10 Nov 2026 23:46:28 +0000 Subject: [PATCH 4/4] test(cursor): cover catalog parameter defaults at the model selection layer Replaces the adapter and text generation wrapper tests with one unit test of cursorSdkModelSelection, the function the fix changed. AI-assisted; verified with the tests and tools listed above. --- .../src/server/adapter.test.ts | 163 +----------------- .../src/server/sdkModel.test.ts | 73 ++++++++ .../src/server/textGeneration.test.ts | 57 ------ 3 files changed, 74 insertions(+), 219 deletions(-) create mode 100644 packages/provider-cursor/src/server/sdkModel.test.ts diff --git a/packages/provider-cursor/src/server/adapter.test.ts b/packages/provider-cursor/src/server/adapter.test.ts index 39d68fb5ac36c..3f04ac7328323 100644 --- a/packages/provider-cursor/src/server/adapter.test.ts +++ b/packages/provider-cursor/src/server/adapter.test.ts @@ -1,6 +1,6 @@ import * as NodeServices from "@effect/platform-node/NodeServices"; import { assert, describe, it } from "@effect/vitest"; -import type { InteractionUpdate, ModelSelection as CursorSdkModelSelection } from "@cursor/sdk"; +import type { InteractionUpdate } from "@cursor/sdk"; import { toolOutputImages } from "@t3tools/shared/toolOutput"; import { EnvironmentId, @@ -35,7 +35,6 @@ import { nestedToolCallFromEnvelope, } from "./adapter.ts"; import * as CursorAgentSdk from "./CursorAgentSdk.ts"; -import { buildCursorDiscoveredModelsFromSdk } from "./status.ts"; import { loadCursorSdk } from "./sdk.ts"; const { ConfigurationError } = loadCursorSdk(); @@ -1749,166 +1748,6 @@ describe("CursorAdapterV2", () => { ), ); - it.effect("sends every catalog parameter when the selection leaves them unset", () => - Effect.gen(function* () { - const fileSystem = yield* FileSystem.FileSystem; - const workspace = yield* fileSystem.makeTempDirectoryScoped({ prefix: "cursor-v2-params-" }); - const instanceId = ProviderInstanceId.make("cursor"); - const threadId = ThreadId.make("cursor-params-thread"); - const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({ - runtimeMode: "full-access", - interactionMode: "default", - cwd: workspace, - }); - const models = buildCursorDiscoveredModelsFromSdk([ - { - id: "grok-4.5", - displayName: "Grok 4.5", - parameters: [ - { - id: "effort", - displayName: "Effort", - values: [{ value: "low" }, { value: "medium" }, { value: "high" }], - }, - { id: "fast", displayName: "Fast", values: [{ value: "false" }, { value: "true" }] }, - ], - variants: [ - { - displayName: "Grok 4.5 High Fast", - isDefault: true, - params: [ - { id: "effort", value: "high" }, - { id: "fast", value: "true" }, - ], - }, - ], - }, - ]); - const sent: Array<{ readonly method: string; readonly model: unknown }> = []; - const record = (method: string, model: CursorSdkModelSelection | undefined) => - sent.push({ - method, - model: - model === undefined - ? undefined - : { - id: model.id, - params: model.params?.toSorted((a, b) => a.id.localeCompare(b.id)), - }, - }); - const adapter = yield* makeCursorAdapterV2({ - instanceId, - environment: { HOME: workspace }, - getModels: () => models, - }).pipe( - Effect.provideService(CursorAgentSdk.CursorAgentSdkRunner, { - assertComplete: Effect.void, - open: (input) => { - record(`agent.${input.operation}`, input.options.model); - return Effect.succeed({ - agentId: "native-cursor-params", - listMessages: Effect.succeed([]), - close: Effect.void, - send: (sendInput) => { - record("run.start", sendInput.options?.model); - return Effect.fail( - new CursorAgentSdk.CursorAgentSdkRunnerError({ - method: "run.start", - cause: new Error("stop after recording the model"), - }), - ); - }, - }); - }, - }), - Effect.provide(TestProviderHost.layer({ cwd: workspace })), - ); - // A default model from Settings carries no options; the composer adds only Fast off. - const settingsDefault = { instanceId, model: "grok-4.5" }; - const composerSelection = { - instanceId, - model: "grok-4.5", - options: [{ id: "fastMode", value: false }], - }; - const runtime = yield* adapter.openSession({ - threadId, - providerSessionId: ProviderSessionId.make("cursor-params-session"), - modelSelection: settingsDefault, - runtimePolicy, - }); - const providerThread = yield* runtime.ensureThread({ - threadId, - modelSelection: settingsDefault, - runtimePolicy, - }); - const now = yield* DateTime.now; - for (const [ordinal, modelSelection] of [settingsDefault, composerSelection].entries()) { - yield* runtime - .startTurn({ - threadId, - providerThread, - modelSelection, - runtimePolicy, - runId: RunId.make(`cursor-params-run-${ordinal}`), - runOrdinal: ordinal + 1, - providerTurnOrdinal: ordinal + 1, - attemptId: RunAttemptId.make(`cursor-params-attempt-${ordinal}`), - rootNodeId: NodeId.make(`cursor-params-root-${ordinal}`), - appThread: { - id: threadId, - projectId: ProjectId.make("cursor-params-project"), - createdBy: "user", - creationSource: "web", - title: "Cursor params", - providerInstanceId: instanceId, - modelSelection, - runtimeMode: "full-access", - interactionMode: "default", - branch: null, - worktreePath: null, - activeProviderThreadId: providerThread.id, - lineage: { parentThreadId: null, relationshipToParent: null, rootThreadId: threadId }, - forkedFrom: null, - createdAt: now, - updatedAt: now, - archivedAt: null, - settledOverride: null, - settledAt: null, - lastVisitedAt: null, - deletedAt: null, - }, - message: { - messageId: MessageId.make(`cursor-params-message-${ordinal}`), - createdBy: "user", - creationSource: "web", - text: "Hello.", - attachments: [], - }, - }) - .pipe(Effect.flip); - } - - // Cursor rejects some plans' runs unless each catalog parameter is set; Fast stays off. - const catalogDefaults = { - id: "grok-4.5", - params: [ - { id: "effort", value: "high" }, - { id: "fast", value: "false" }, - ], - }; - assert.deepEqual(sent, [ - { method: "agent.create", model: catalogDefaults }, - { method: "run.start", model: catalogDefaults }, - { method: "run.start", model: catalogDefaults }, - ]); - }).pipe( - Effect.scoped, - Effect.provide( - Layer.mergeAll(NodeServices.layer, IdAllocator.layer, McpProviderSessions.layer), - ), - ), - ); - it("maps runtime modes to the SDK sandbox and auto-review controls", () => { const base = { interactionMode: "default" as const, diff --git a/packages/provider-cursor/src/server/sdkModel.test.ts b/packages/provider-cursor/src/server/sdkModel.test.ts new file mode 100644 index 0000000000000..4ad129e1ae239 --- /dev/null +++ b/packages/provider-cursor/src/server/sdkModel.test.ts @@ -0,0 +1,73 @@ +import { ProviderInstanceId } from "@t3tools/contracts"; +import { describe, expect, it } from "vite-plus/test"; + +import { cursorSdkModelSelection } from "./sdkModel.ts"; +import { buildCursorDiscoveredModelsFromSdk } from "./status.ts"; + +const instanceId = ProviderInstanceId.make("cursor"); +const models = buildCursorDiscoveredModelsFromSdk([ + { + id: "grok-4.5", + displayName: "Grok 4.5", + parameters: [ + { + id: "effort", + displayName: "Effort", + values: [{ value: "low" }, { value: "medium" }, { value: "high" }], + }, + { id: "fast", displayName: "Fast", values: [{ value: "false" }, { value: "true" }] }, + ], + variants: [ + { + displayName: "Grok 4.5 High Fast", + isDefault: true, + params: [ + { id: "effort", value: "high" }, + { id: "fast", value: "true" }, + ], + }, + ], + }, +]); + +describe("cursorSdkModelSelection", () => { + it.each([ + { + name: "fills unset catalog parameters and keeps Fast off", + options: undefined, + params: [ + { id: "effort", value: "high" }, + { id: "fast", value: "false" }, + ], + }, + { + name: "keeps explicit options", + options: [ + { id: "effort", value: "low" }, + { id: "fastMode", value: true }, + ], + params: [ + { id: "effort", value: "low" }, + { id: "fast", value: "true" }, + ], + }, + ])("$name", ({ options, params }) => { + const selection = cursorSdkModelSelection( + { instanceId, model: "grok-4.5", ...(options === undefined ? {} : { options }) }, + models, + ); + expect({ + ...selection, + params: selection.params?.toSorted((a, b) => a.id.localeCompare(b.id)), + }).toEqual({ + id: "grok-4.5", + params, + }); + }); + + it("sends no parameters for a model missing from the catalog", () => { + expect(cursorSdkModelSelection({ instanceId, model: "auto" }, models)).toEqual({ + id: "default", + }); + }); +}); diff --git a/packages/provider-cursor/src/server/textGeneration.test.ts b/packages/provider-cursor/src/server/textGeneration.test.ts index 45c4aab40e6b9..bfb02df390d83 100644 --- a/packages/provider-cursor/src/server/textGeneration.test.ts +++ b/packages/provider-cursor/src/server/textGeneration.test.ts @@ -9,7 +9,6 @@ import * as Schema from "effect/Schema"; import { createModelSelection } from "@t3tools/shared/model"; import { beforeEach, vi } from "vite-plus/test"; -import { buildCursorDiscoveredModelsFromSdk } from "./status.ts"; import { makeCursorTextGeneration } from "./textGeneration.ts"; import * as CursorSdk from "./CursorSdk.ts"; @@ -106,62 +105,6 @@ describe("CursorTextGeneration", () => { }).pipe(Effect.provide(layerTest)), ); - it.effect("sends every catalog parameter when the selection leaves them unset", () => - Effect.gen(function* () { - const models = buildCursorDiscoveredModelsFromSdk([ - { - id: "grok-4.5", - displayName: "Grok 4.5", - parameters: [ - { - id: "effort", - displayName: "Effort", - values: [{ value: "low" }, { value: "medium" }, { value: "high" }], - }, - { id: "fast", displayName: "Fast", values: [{ value: "false" }, { value: "true" }] }, - ], - variants: [ - { - displayName: "Grok 4.5 High Fast", - isDefault: true, - params: [ - { id: "effort", value: "high" }, - { id: "fast", value: "true" }, - ], - }, - ], - }, - ]); - const generation = yield* makeCursorTextGeneration( - cursorSettings, - { CURSOR_API_KEY: "test-cursor-key" }, - undefined, - undefined, - () => models, - ); - - yield* generation.generateCommitMessage({ - cwd: process.cwd(), - branch: "feature/cursor", - stagedSummary: "M file.ts", - stagedPatch: "diff", - modelSelection: createModelSelection(ProviderInstanceId.make("cursor"), "grok-4.5"), - }); - - expect(cursorSdkMock.create).toHaveBeenLastCalledWith( - expect.objectContaining({ - model: { - id: "grok-4.5", - params: [ - { id: "effort", value: "high" }, - { id: "fast", value: "false" }, - ], - }, - }), - ); - }).pipe(Effect.provide(layerTest)), - ); - it.effect("continues in the temp directory when the SDK cannot sandbox", () => Effect.gen(function* () { cursorSdkMock.create.mockImplementationOnce(async () => {