fix(daemon): stop passing literal dash to cursor-agent (#160)

This commit is contained in:
初晨 2026-04-30 18:06:03 +08:00 committed by GitHub
parent 8f34e39b7b
commit 39c0399ded
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 3 deletions

View file

@ -312,8 +312,10 @@ export const AGENT_DEFS = [
{ id: 'sonnet-4-thinking', label: 'sonnet-4-thinking' },
{ id: 'gpt-5', label: 'gpt-5' },
],
// Prompt delivered via stdin (`cursor-agent -`) to avoid Windows
// `spawn ENAMETOOLONG` while preserving Cursor Agent's structured stream.
// Cursor Agent does not use `-` as a "read prompt from stdin" sentinel.
// Passing it makes the CLI treat the dash as the literal user prompt,
// which then surfaces as "your message only contains '-'". Keep stdin
// piped for prompt delivery, but do not append a fake prompt arg.
buildArgs: (_prompt, _imagePaths, _extra, options = {}, runtimeContext = {}) => {
const args = [];
args.push('--print', '--output-format', 'stream-json', '--stream-partial-output', '--force', '--trust');
@ -323,7 +325,6 @@ export const AGENT_DEFS = [
if (options.model && options.model !== 'default') {
args.push('--model', options.model);
}
args.push('-');
return args;
},
promptViaStdin: true,

View file

@ -4,6 +4,7 @@ import assert from 'node:assert/strict';
import { AGENT_DEFS } from '../src/agents.js';
const codex = AGENT_DEFS.find((agent) => agent.id === 'codex');
const cursorAgent = AGENT_DEFS.find((agent) => agent.id === 'cursor-agent');
const originalDisablePlugins = process.env.OD_CODEX_DISABLE_PLUGINS;
afterEach(() => {
@ -49,3 +50,18 @@ test('codex args keep plugins enabled when OD_CODEX_DISABLE_PLUGINS is not 1', (
assert.equal(args.includes('plugins'), false);
assert.equal(args.at(-1), '-');
});
test('cursor-agent args deliver prompts via stdin without passing a literal dash prompt', () => {
const args = cursorAgent.buildArgs('', [], [], {}, { cwd: '/tmp/od-project' });
assert.deepEqual(args, [
'--print',
'--output-format',
'stream-json',
'--stream-partial-output',
'--force',
'--trust',
'--workspace',
'/tmp/od-project',
]);
});