Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

feat(agents): honor flag-prompt injection at launch (opencode --prompt)

enes2f4081717f0a
diff --git a/src/renderer/state/workspace.test.ts b/src/renderer/state/workspace.test.ts
index abe597715..bf3a7c3c5 100644
--- a/src/renderer/state/workspace.test.ts
+++ b/src/renderer/state/workspace.test.ts
@@ -323,3 +323,18 @@ describe('createAgentNode permission mode', () => {
expect(node.data.initialCommand).toBe('codex')
})
})
+
+describe('createAgentNode prompt injection', () => {
+ it('uses --prompt for flag-prompt agents (opencode)', () => {
+ const n = createAgentNode('opencode', 0, undefined, undefined, "rerank the results")
+ expect(n.data.initialCommand).toBe("opencode --prompt 'rerank the results'")
+ })
+ it('shell-quotes a flag-prompt safely', () => {
+ const n = createAgentNode('opencode', 0, undefined, undefined, "it's tricky")
+ expect(n.data.initialCommand).toBe("opencode --prompt 'it'\\''s tricky'")
+ })
+ it('keeps argv injection byte-identical for codex and gemini', () => {
+ expect(createAgentNode('codex', 0, undefined, undefined, 'do X').data.initialCommand).toBe("codex 'do X'")
+ expect(createAgentNode('gemini', 0, undefined, undefined, 'do X').data.initialCommand).toBe("gemini 'do X'")
+ })
+})
diff --git a/src/renderer/state/workspace.ts b/src/renderer/state/workspace.ts
index b2d91ea3f..e2bc66407 100644
--- a/src/renderer/state/workspace.ts
+++ b/src/renderer/state/workspace.ts
@@ -296,8 +296,17 @@ export function createAgentNode(
): CanvasNode {
const { label, color, launchCmd } = resolveAgent(agentId)
const baseCmd = agentId === 'claude' ? claudeLaunchCommand() : launchCmd
- const withPrompt = initialPrompt
- ? `${baseCmd} ${shellSingleQuote(initialPrompt.replace(/\s+/g, ' ').trim())}`
+ // A flag-prompt agent (opencode) takes the initial prompt via its flag — a bare positional
+ // would be misread (opencode treats it as a project path). Everything else keeps the
+ // historical argv append, INCLUDING stdin-after-start agents (gemini has always launched
+ // via argv here; changing that is a separate decision).
+ const promptArg = initialPrompt
+ ? shellSingleQuote(initialPrompt.replace(/\s+/g, ' ').trim())
+ : null
+ const withPrompt = promptArg
+ ? agentConfig(agentId)?.promptInjectionMode === 'flag-prompt'
+ ? `${baseCmd} --prompt ${promptArg}`
+ : `${baseCmd} ${promptArg}`
: baseCmd
// Flag goes last: the prompt is claude's positional argv and must stay adjacent to the binary.
// No mode passed (e.g. a legacy/test call site) = bare command, exactly as before this setting.