cursor adapter: pipe prompts over stdin

This commit is contained in:
Dotta
2026-03-05 09:35:43 -06:00
parent 59bc52f527
commit bc68c3a504
3 changed files with 6 additions and 7 deletions

View File

@@ -76,7 +76,7 @@ Operational fields:
Notes:
- Runs are executed with: agent -p --output-format stream-json ...
- Prompts are passed as a final positional argument.
- Prompts are piped to Cursor via stdin.
- Sessions are resumed with --resume when stored session cwd matches current cwd.
- Paperclip auto-injects local skills into "~/.cursor/skills" when missing, so Cursor can discover "$paperclip" and related skills on local runs.
- Paperclip auto-adds --trust unless one of --trust/--yolo/-f is already present in extraArgs.

View File

@@ -301,6 +301,7 @@ export async function execute(ctx: AdapterExecutionContext): Promise<AdapterExec
if (autoTrustEnabled) {
notes.push("Auto-added --trust to bypass interactive workspace trust prompt.");
}
notes.push("Prompt is piped to Cursor via stdin.");
if (!instructionsFilePath) return notes;
if (instructionsPrefix.length > 0) {
notes.push(
@@ -334,7 +335,6 @@ export async function execute(ctx: AdapterExecutionContext): Promise<AdapterExec
if (mode) args.push("--mode", mode);
if (autoTrustEnabled) args.push("--trust");
if (extraArgs.length > 0) args.push(...extraArgs);
args.push(prompt);
return args;
};
@@ -346,10 +346,7 @@ export async function execute(ctx: AdapterExecutionContext): Promise<AdapterExec
command,
cwd,
commandNotes,
commandArgs: args.map((value, idx) => {
if (idx === args.length - 1) return `<prompt ${prompt.length} chars>`;
return value;
}),
commandArgs: args,
env: redactEnvForLogs(env),
prompt,
context,
@@ -385,6 +382,7 @@ export async function execute(ctx: AdapterExecutionContext): Promise<AdapterExec
env,
timeoutSec,
graceSec,
stdin: prompt,
onLog: async (stream, chunk) => {
if (stream !== "stdout") {
await onLog(stream, chunk);

View File

@@ -11,7 +11,7 @@ const fs = require("node:fs");
const capturePath = process.env.PAPERCLIP_TEST_CAPTURE_PATH;
const payload = {
argv: process.argv.slice(2),
prompt: process.argv.at(-1) ?? "",
prompt: fs.readFileSync(0, "utf8"),
paperclipEnvKeys: Object.keys(process.env)
.filter((key) => key.startsWith("PAPERCLIP_"))
.sort(),
@@ -96,6 +96,7 @@ describe("cursor execute", () => {
expect(result.errorMessage).toBeNull();
const capture = JSON.parse(await fs.readFile(capturePath, "utf8")) as CapturePayload;
expect(capture.argv).not.toContain("Follow the paperclip heartbeat.");
expect(capture.argv).not.toContain("--mode");
expect(capture.argv).not.toContain("ask");
expect(capture.paperclipEnvKeys).toEqual(