cursor adapter: pipe prompts over stdin
This commit is contained in:
@@ -76,7 +76,7 @@ Operational fields:
|
|||||||
|
|
||||||
Notes:
|
Notes:
|
||||||
- Runs are executed with: agent -p --output-format stream-json ...
|
- 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.
|
- 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-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.
|
- Paperclip auto-adds --trust unless one of --trust/--yolo/-f is already present in extraArgs.
|
||||||
|
|||||||
@@ -301,6 +301,7 @@ export async function execute(ctx: AdapterExecutionContext): Promise<AdapterExec
|
|||||||
if (autoTrustEnabled) {
|
if (autoTrustEnabled) {
|
||||||
notes.push("Auto-added --trust to bypass interactive workspace trust prompt.");
|
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 (!instructionsFilePath) return notes;
|
||||||
if (instructionsPrefix.length > 0) {
|
if (instructionsPrefix.length > 0) {
|
||||||
notes.push(
|
notes.push(
|
||||||
@@ -334,7 +335,6 @@ export async function execute(ctx: AdapterExecutionContext): Promise<AdapterExec
|
|||||||
if (mode) args.push("--mode", mode);
|
if (mode) args.push("--mode", mode);
|
||||||
if (autoTrustEnabled) args.push("--trust");
|
if (autoTrustEnabled) args.push("--trust");
|
||||||
if (extraArgs.length > 0) args.push(...extraArgs);
|
if (extraArgs.length > 0) args.push(...extraArgs);
|
||||||
args.push(prompt);
|
|
||||||
return args;
|
return args;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -346,10 +346,7 @@ export async function execute(ctx: AdapterExecutionContext): Promise<AdapterExec
|
|||||||
command,
|
command,
|
||||||
cwd,
|
cwd,
|
||||||
commandNotes,
|
commandNotes,
|
||||||
commandArgs: args.map((value, idx) => {
|
commandArgs: args,
|
||||||
if (idx === args.length - 1) return `<prompt ${prompt.length} chars>`;
|
|
||||||
return value;
|
|
||||||
}),
|
|
||||||
env: redactEnvForLogs(env),
|
env: redactEnvForLogs(env),
|
||||||
prompt,
|
prompt,
|
||||||
context,
|
context,
|
||||||
@@ -385,6 +382,7 @@ export async function execute(ctx: AdapterExecutionContext): Promise<AdapterExec
|
|||||||
env,
|
env,
|
||||||
timeoutSec,
|
timeoutSec,
|
||||||
graceSec,
|
graceSec,
|
||||||
|
stdin: prompt,
|
||||||
onLog: async (stream, chunk) => {
|
onLog: async (stream, chunk) => {
|
||||||
if (stream !== "stdout") {
|
if (stream !== "stdout") {
|
||||||
await onLog(stream, chunk);
|
await onLog(stream, chunk);
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ const fs = require("node:fs");
|
|||||||
const capturePath = process.env.PAPERCLIP_TEST_CAPTURE_PATH;
|
const capturePath = process.env.PAPERCLIP_TEST_CAPTURE_PATH;
|
||||||
const payload = {
|
const payload = {
|
||||||
argv: process.argv.slice(2),
|
argv: process.argv.slice(2),
|
||||||
prompt: process.argv.at(-1) ?? "",
|
prompt: fs.readFileSync(0, "utf8"),
|
||||||
paperclipEnvKeys: Object.keys(process.env)
|
paperclipEnvKeys: Object.keys(process.env)
|
||||||
.filter((key) => key.startsWith("PAPERCLIP_"))
|
.filter((key) => key.startsWith("PAPERCLIP_"))
|
||||||
.sort(),
|
.sort(),
|
||||||
@@ -96,6 +96,7 @@ describe("cursor execute", () => {
|
|||||||
expect(result.errorMessage).toBeNull();
|
expect(result.errorMessage).toBeNull();
|
||||||
|
|
||||||
const capture = JSON.parse(await fs.readFile(capturePath, "utf8")) as CapturePayload;
|
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("--mode");
|
||||||
expect(capture.argv).not.toContain("ask");
|
expect(capture.argv).not.toContain("ask");
|
||||||
expect(capture.paperclipEnvKeys).toEqual(
|
expect(capture.paperclipEnvKeys).toEqual(
|
||||||
|
|||||||
Reference in New Issue
Block a user