Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion resources/plugins/declarative/orca-testing.mjs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/main/ipc/pty/pty-launch-parity-caller.test-cases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const PAIRED_PLAN_CASES: PairedPlanCase[] = [
os: 'darwin',
agent: 'claude',
prompt: LONG_PROMPT,
provider: { command: `${POSIX_CLAUDE} '${LONG_PROMPT}'`, ...ZSH }
provider: { command: `${POSIX_CLAUDE} -- '${LONG_PROMPT}'`, ...ZSH }
},
{
name: 'aider prompt, starts clean',
Expand All @@ -101,7 +101,7 @@ const PAIRED_PLAN_CASES: PairedPlanCase[] = [
os: 'win32',
agent: 'claude',
prompt: "Bob's fix",
provider: { command: `claude '--dangerously-skip-permissions' 'Bob''s fix'`, ...POWERSHELL }
provider: { command: `claude '--dangerously-skip-permissions' -- 'Bob''s fix'`, ...POWERSHELL }
}
]

Expand Down
2 changes: 1 addition & 1 deletion src/main/runtime/runtime-worktree-agent-startup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ describe('buildWorktreeStartupForAgent extra agent args', () => {
})

expect(result.startup.command).toBe(
"claude '--dangerously-skip-permissions' '--model' 'opus' 'go'"
"claude '--dangerously-skip-permissions' '--model' 'opus' -- 'go'"
)
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ it.each(['global', 'repo'] as const)(
'docs',
'--permission-mode',
'default',
'--',
'fix'
])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ it.each([
const plan = submittedActionStartupPlan(submitted)
expect(plan?.launchCommand).toBe(
agent === 'claude'
? `claude ${'defaultGroup' in row && !pair ? "'--effort' 'high' " : ''}'--verbose' '--model' 'sonnet'${pair ? " '--effort' 'low'" : ''} 'fix'`
? `claude ${'defaultGroup' in row && !pair ? "'--effort' 'high' " : ''}'--verbose' '--model' 'sonnet'${pair ? " '--effort' 'low'" : ''} -- 'fix'`
: `codex '-c' 'disable_paste_burst=true' ${'foreignDocument' in row ? "'--effort' 'high' " : ''}'--verbose' '-m' 'gpt-5.5' '-c' 'model_reasoning_effort=low' 'fix'`
)
if (native) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ it.each(['own', 'parent'] as const)(
if (!command.ok) {
throw new Error(command.error)
}
expect(command.tokens).toEqual(['claude', '--model', 'opus', '--verbose', 'fix'])
expect(command.tokens).toEqual(['claude', '--model', 'opus', '--verbose', '--', 'fix'])
fireEvent.keyDown(document, { key: 'Escape' })
view.rerender(tree(saved))
await configure()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('submitFolderWorkspaceCreate on an Orca server', () => {
'folder-workspace-1',
expect.objectContaining({
startup: expect.objectContaining({
command: `claude 'Use Bob'"'"'s POSIX startup'`
command: `claude -- 'Use Bob'"'"'s POSIX startup'`
})
})
)
Expand Down Expand Up @@ -97,7 +97,7 @@ describe('submitFolderWorkspaceCreate on an Orca server', () => {
'folder-workspace-1',
expect.objectContaining({
startup: expect.objectContaining({
command: "claude 'Use Bob''s Windows startup'"
command: "claude -- 'Use Bob''s Windows startup'"
})
})
)
Expand Down Expand Up @@ -151,7 +151,7 @@ describe('submitFolderWorkspaceCreate on an Orca server', () => {
expect(mocks.activateAndRevealFolderWorkspace).toHaveBeenCalledWith(
'folder-workspace-1',
expect.objectContaining({
startup: expect.objectContaining({ command: "claude 'Use Bob''s server startup'" })
startup: expect.objectContaining({ command: "claude -- 'Use Bob''s server startup'" })
})
)
})
Expand Down
2 changes: 2 additions & 0 deletions src/shared/agent-launch/catalog/tui-agent-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const TUI_AGENT_CONFIG_SOURCE: Record<TuiAgent, TuiAgentConfigSource> = {
claude: {
detectCmd: 'claude',
promptInjectionMode: 'argv',
// Why: process-table argv loses quoting, so prompt text like `mkdir -p` reads as headless `claude -p`; -- ends that scan.
argvPromptSeparator: '--',
pasteNeedsTypedRequest: true,
// Native --prefill avoids paste-after-ready races (https://github.com/stablyai/orca/pull/926).
draftPromptFlag: '--prefill',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { describe, expect, it } from 'vitest'
import { buildAgentStartupPlan } from './tui-agent-startup'
import { recognizeAgentProcessFromCommandLine } from '../../agent-status/process/agent-process-recognition'
import { tokenizeCommandLine } from '../../agent-status/process/agent-command-line-entrypoint'

describe("Claude's argv prompt separator", () => {
/** Claude's launch command for `prompt`, under an optional command override. */
function launchCommandFor(prompt: string, claude?: string): string | undefined {
return buildAgentStartupPlan({
agent: 'claude',
prompt,
cmdOverrides: { claude },
platform: 'darwin'
})?.launchCommand
}

it('keeps a launched Claude recognizable when its prompt mentions -p', () => {
// Why: the process table joins argv without quotes, so prompt words reach the headless-flag scan.
const processTableLine = tokenizeCommandLine(
launchCommandFor('When done, run mkdir -p ~/orca/handoffs/x') ?? ''
).join(' ')
expect(recognizeAgentProcessFromCommandLine(processTableLine)?.agent).toBe('claude')
})

it.each([
['claude-wrapper --', "claude-wrapper -- 'Fix the bug'"],
// A required option's `--` value is not a terminator.
["claude --system-prompt '--'", "claude --system-prompt '--' -- 'Fix the bug'"],
// A wrapper's `--` ends the wrapper's options, not Claude's.
['env -- claude', "env -- claude -- 'Fix the bug'"]
])('ends Claude options exactly once behind %s', (claude, expected) => {
expect(launchCommandFor('Fix the bug', claude)).toBe(expected)
})
})
1 change: 1 addition & 0 deletions src/shared/agent-launch/startup/tui-agent-startup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import './agent-resume-argv-drop.spec'
import './agent-resume-launch-command.spec'
import './agent-startup-plan-inputs.spec'
import './agent-startup-plan-inputs-extra-agent-args.spec'
import './claude-argv-prompt-separator.spec'
import './omp-fresh-launch.spec'
import './opencode-startup-prompt.spec'
import './opencode2-resume-launch-mode.spec'
Expand Down
18 changes: 17 additions & 1 deletion src/shared/agent-launch/startup/tui-agent-startup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import {
commandSeparator,
quoteStartupArg,
resolveStartupShell,
tokenizeStartupCommand,
type AgentStartupShell
} from './tui-agent-startup-shell'
import { agentArgTerminatorIndex } from '../../agent-session/options/agent-session-option-agent-args'
import { TUI_AGENT_CONFIG } from '../catalog/tui-agent-config'
import type { StartupCommandDelivery } from './codex-startup-delivery'
import { buildSleepingAgentLaunchConfig } from '../../agent-session/lifecycle/sleeping-agent-launch-config'
Expand All @@ -33,6 +35,7 @@ export type AgentStartupPlan = {
sessionOptions?: Record<string, SessionOptionValue>
}

/** Build one agent's launch plan; an argv agent's `argvPromptSeparator` precedes the prompt unless the command already ends options. */
export function buildAgentStartupPlan(args: {
agent: TuiAgent
prompt: string
Expand Down Expand Up @@ -108,7 +111,10 @@ export function buildAgentStartupPlan(args: {
const quotedPrompt = quoteStartupArg(trimmedPrompt, shell)

if (config.promptInjectionMode === 'argv') {
const promptSeparator = config.argvPromptSeparator ? ` ${config.argvPromptSeparator}` : ''
const promptSeparator =
config.argvPromptSeparator && !launchCommandEndsOptions(agent, launchCommand, shell)
? ` ${config.argvPromptSeparator}`
: ''
return {
agent,
launchCommand:
Expand Down Expand Up @@ -197,6 +203,16 @@ export function buildAgentStartupPlan(args: {
}
}

/** Only a trailing real `--` ends the agent's options: `env -- traecli`'s is env's, `--system-prompt '--'`'s is a value; unsure appends. */
function launchCommandEndsOptions(
agent: TuiAgent,
command: string,
shell: AgentStartupShell
): boolean {
const parsed = tokenizeStartupCommand(command, shell)
return parsed.ok && agentArgTerminatorIndex(agent, parsed.tokens) === parsed.tokens.length - 1
}

/** Predict the builder’s null-followupPrompt verdict before choosing a launch surface; derive from the same injection table.
* All modes except stdin-after-start carry the prompt through the launch command; Hermes may reference an env carrier instead of literal prompt argv. */
export function agentPromptRidesLaunchCommand(agent: TuiAgent): boolean {
Expand Down
6 changes: 3 additions & 3 deletions src/shared/launch-parity-window-cases.test-fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ const SKIP = '--dangerously-skip-permissions'
const POSIX_CLAUDE = `claude '${SKIP}'`
const CMD_CLAUDE = `claude "${SKIP}"`
// The auto-submitted prompt rides on argv.
const posix = { command: `${POSIX_CLAUDE} 'fix Bob'"'"'s bug'`, agentCommand: POSIX_CLAUDE }
const ps = { command: `${POSIX_CLAUDE} 'fix Bob''s bug'`, agentCommand: POSIX_CLAUDE }
const cmd = { command: `${CMD_CLAUDE} "fix Bob's bug"`, agentCommand: CMD_CLAUDE }
const posix = { command: `${POSIX_CLAUDE} -- 'fix Bob'"'"'s bug'`, agentCommand: POSIX_CLAUDE }
const ps = { command: `${POSIX_CLAUDE} -- 'fix Bob''s bug'`, agentCommand: POSIX_CLAUDE }
const cmd = { command: `${CMD_CLAUDE} -- "fix Bob's bug"`, agentCommand: CMD_CLAUDE }

const BRAIN = '.gemini/antigravity-ide/brain/ide-id/transcript_full.jsonl'
const MAC_T = `/Users/alice/${BRAIN}`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export const WORKSPACE_START_LAUNCH_CASES: WindowLaunchCase[] = [
'darwin',
folder(POSIX_PATH),
note(BOB),
{ command: `${POSIX_CLAUDE} 'fix Bob'"'"'s bug'`, agentCommand: POSIX_CLAUDE },
{ command: `${POSIX_CLAUDE} -- 'fix Bob'"'"'s bug'`, agentCommand: POSIX_CLAUDE },
ZSH
),
// Unlike the work item, the composer quotes for the Windows shell it runs in.
Expand All @@ -139,7 +139,7 @@ export const WORKSPACE_START_LAUNCH_CASES: WindowLaunchCase[] = [
note(BOB),
// A folder has no project, so no project runtime is sent.
{
command: `${CMD_CLAUDE} "fix Bob's bug"`,
command: `${CMD_CLAUDE} -- "fix Bob's bug"`,
agentCommand: CMD_CLAUDE,
shellOverride: 'cmd.exe'
},
Expand All @@ -153,7 +153,7 @@ export const WORKSPACE_START_LAUNCH_CASES: WindowLaunchCase[] = [
folder(WIN_PATH),
note(BOB),
{
command: `${POSIX_CLAUDE} 'fix Bob'"'"'s bug'`,
command: `${POSIX_CLAUDE} -- 'fix Bob'"'"'s bug'`,
agentCommand: POSIX_CLAUDE,
shellOverride: 'wsl.exe'
},
Expand All @@ -168,7 +168,7 @@ export const WORKSPACE_START_LAUNCH_CASES: WindowLaunchCase[] = [
folder(POSIX_PATH),
note(LONG_NOTE),
{
command: `${POSIX_CLAUDE} '${LONG_NOTE}'`,
command: `${POSIX_CLAUDE} -- '${LONG_NOTE}'`,
agentCommand: POSIX_CLAUDE
},
ZSH
Expand Down
3 changes: 2 additions & 1 deletion tests/e2e/prepared-action-launch.test-fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type PreparedTerminalCreateMethod = {
handler(params: unknown, context: PreparedTerminalCreateContext): unknown
}

/** Assert the whole prepared launch command an independent action builds for `agent`. */
export function independentActionEffortPlan(agent: 'claude' | 'codex') {
const recipe = normalizeSourceControlAiActionDefaults({
fixChecks: {
Expand Down Expand Up @@ -69,7 +70,7 @@ export function independentActionEffortPlan(agent: 'claude' | 'codex') {
expect(plan.sessionOptions).toEqual({ effort: 'high' })
expect(plan.launchCommand).toBe(
agent === 'claude'
? "claude '--verbose' '--effort' 'high' 'Fix checks'"
? "claude '--verbose' '--effort' 'high' -- 'Fix checks'"
: "codex '-c' 'disable_paste_burst=true' '--verbose' '-c' 'model_reasoning_effort=high' 'Fix checks'"
)
expect(agentLaunchNeedsPreparedCommand(agent, plan.sessionOptions)).toBe(true)
Expand Down