fix(cursor): honor auto and full access modes (#9283)

Co-authored-by: maria-rcks <[email protected]>
This commit is contained in:
mariaandmaria-rcks authored and GitHub committed 2026-09-02 19:27:53 -04:00
1 parent c742edd46c
commit 994bd7373c
5 files changed
+59 -5

No files matched your search

@@ -820,6 +820,9 @@ cursorAdapterTestLayer("CursorAdapterLive", (it) => {
);
assert.isDefined(permissionResponse);
const argvRuns = yield* Effect.promise(() => readArgvLog(argvLogPath));
assert.deepStrictEqual(argvRuns, [["--force", "acp"]]);
yield* adapter.stopSession(threadId);
}),
);
@@ -1260,7 +1263,7 @@ cursorAdapterTestLayer("CursorAdapterLive", (it) => {
const argvRuns = yield* Effect.promise(() => readArgvLog(argvLogPath));
assert.lengthOf(argvRuns, 1, "session should not restart — only one spawn");
assert.deepStrictEqual(argvRuns[0], ["acp"]);
assert.deepStrictEqual(argvRuns[0], ["--force", "acp"]);
const requests = yield* Effect.promise(() => readJsonLines(requestLogPath));
const setConfigRequests = requests.filter(
@@ -537,6 +537,7 @@ export function makeCursorAdapter(
...(options?.environment ? { environment: options.environment } : {}),
childProcessSpawner,
cwd,
runtimeMode: input.runtimeMode,
...(resumeSessionId ? { resumeSessionId } : {}),
clientInfo: { name: "t3-code", version: "0.0.0" },
...(mcpSession
@@ -74,6 +74,33 @@ describe("buildCursorAcpSpawnInput", () => {
cwd: "/tmp/project",
});
});
it("forces approval in full-access mode", () => {
expect(buildCursorAcpSpawnInput(undefined, "/tmp/project", undefined, "full-access")).toEqual({
command: "cursor-agent",
args: ["--force", "acp"],
cwd: "/tmp/project",
});
});
it("uses Cursor auto-review in auto mode", () => {
expect(buildCursorAcpSpawnInput(undefined, "/tmp/project", undefined, "auto")).toEqual({
command: "cursor-agent",
args: ["--auto-review", "acp"],
cwd: "/tmp/project",
});
});
it.each(["approval-required", "auto-accept-edits"] as const)(
"does not relax approval in %s mode",
(runtimeMode) => {
expect(buildCursorAcpSpawnInput(undefined, "/tmp/project", undefined, runtimeMode)).toEqual({
command: "cursor-agent",
args: ["acp"],
cwd: "/tmp/project",
});
},
);
});
describe("applyCursorAcpModelSelection", () => {
@@ -1,4 +1,8 @@
import { type CursorSettings, type ProviderOptionSelection } from "@t3tools/contracts";
import {
type CursorSettings,
type ProviderOptionSelection,
type RuntimeMode,
} from "@t3tools/contracts";
import * as Crypto from "effect/Crypto";
import * as Effect from "effect/Effect";
import * as Layer from "effect/Layer";
@@ -15,6 +19,17 @@ import * as AcpSessionRuntime from "./AcpSessionRuntime.ts";
type CursorAcpRuntimeCursorSettings = Pick<CursorSettings, "apiEndpoint" | "binaryPath">;
function cursorAcpPermissionArgs(runtimeMode?: RuntimeMode): ReadonlyArray<string> {
switch (runtimeMode) {
case "auto":
return ["--auto-review"];
case "full-access":
return ["--force"];
default:
return [];
}
}
export interface CursorAcpRuntimeInput extends Omit<
AcpSessionRuntime.AcpSessionRuntimeOptions,
"authMethodId" | "clientCapabilities" | "spawn"
@@ -22,6 +37,7 @@ export interface CursorAcpRuntimeInput extends Omit<
readonly childProcessSpawner: ChildProcessSpawner.ChildProcessSpawner["Service"];
readonly cursorSettings: CursorAcpRuntimeCursorSettings | null | undefined;
readonly environment?: NodeJS.ProcessEnv;
readonly runtimeMode?: RuntimeMode;
}
export interface CursorAcpModelSelectionErrorContext {
@@ -34,11 +50,13 @@ export function buildCursorAcpSpawnInput(
cursorSettings: CursorAcpRuntimeCursorSettings | null | undefined,
cwd: string,
environment?: NodeJS.ProcessEnv,
runtimeMode?: RuntimeMode,
): AcpSessionRuntime.AcpSpawnInput {
return {
command: cursorSettings?.binaryPath || "cursor-agent",
args: [
...(cursorSettings?.apiEndpoint ? (["-e", cursorSettings.apiEndpoint] as const) : []),
...cursorAcpPermissionArgs(runtimeMode),
"acp",
],
cwd,
@@ -57,7 +75,12 @@ export const makeCursorAcpRuntime = (
const acpContext = yield* Layer.build(
AcpSessionRuntime.layer({
...input,
spawn: buildCursorAcpSpawnInput(input.cursorSettings, input.cwd, input.environment),
spawn: buildCursorAcpSpawnInput(
input.cursorSettings,
input.cwd,
input.environment,
input.runtimeMode,
),
authMethodId: "cursor_login",
clientCapabilities: CURSOR_PARAMETERIZED_MODEL_PICKER_CAPABILITIES,
}).pipe(
+2 -2
View File
@@ -17,8 +17,8 @@ without prompting; commands and anything else still stop for approval.
**Auto**: routine actions proceed without you; risky ones still ask. How this is enforced depends
on the provider: Codex delegates routine approvals to an AI reviewer, Claude uses its own auto
permission mode, and providers without an equivalent (such as OpenCode) fall back to asking, like
Supervised.
permission mode, Cursor uses Smart Auto review, and providers without an equivalent (such as
OpenCode) fall back to asking, like Supervised.
**Full access**: allow commands and edits without prompts. The default. The agent runs
unattended until it finishes or asks a question of its own.