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.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
fix(agents): grok takes a POSITIONAL prompt, behind a `--` separator
enesa74a370ede95
diff --git a/src/renderer/state/workspace.agent-prompt.test.ts b/src/renderer/state/workspace.agent-prompt.test.tsnew file mode 100644index 000000000..ad5fbfa7a--- /dev/null+++ b/src/renderer/state/workspace.agent-prompt.test.ts@@ -0,0 +1,31 @@+import { describe, expect, it } from 'vitest'+import { createAgentNode } from './workspace'++/**+ * The separator is the whole reason `argvPromptSeparator` exists, and it is invisible in the config+ * unless the command that comes out is pinned: grok's usage is `grok [OPTIONS] [PROMPT] [COMMAND]`,+ * so a one-word prompt collides with a subcommand. Measured on the shipped binary, `grok version`+ * prints the version and exits while `grok -- version` asks the model about "version".+ */+describe('createAgentNode — the argv prompt separator', () => {+ const cmd = (agentId: string, prompt?: string): string =>+ (createAgentNode(agentId, 0, undefined, undefined, prompt).data.initialCommand as string) ?? ''++ it('puts `--` between grok and its prompt', () => {+ expect(cmd('grok', 'explain this repo')).toBe("grok -- 'explain this repo'")+ })++ it('protects a prompt that is also a subcommand name — the case it exists for', () => {+ expect(cmd('grok', 'version')).toBe("grok -- 'version'")+ })++ it('leaves grok bare when there is no prompt (no dangling separator)', () => {+ expect(cmd('grok')).toBe('grok')+ })++ it('does NOT add a separator for the other agents', () => {+ // claude's command line has to stay byte-identical to what it has always been.+ expect(cmd('claude', 'hello')).toContain("claude 'hello'")+ expect(cmd('claude', 'hello')).not.toContain('--')+ })+})diff --git a/src/renderer/state/workspace.ts b/src/renderer/state/workspace.tsindex ac2dd7dec..1f95e5dd6 100644--- a/src/renderer/state/workspace.ts+++ b/src/renderer/state/workspace.ts@@ -335,10 +335,15 @@ export function createAgentNode(const promptArg = initialPrompt? shellSingleQuote(initialPrompt.replace(/\s+/g, ' ').trim()): null+ // A CLI whose positional prompt shares its slot with subcommands needs a separator, or a+ // one-word prompt runs as a command instead (grok: `grok version` prints the version, `grok --+ // version` asks the model about "version"). Absent for everyone else, so their command line is+ // byte-identical to what it was.+ const sep = agentConfig(agentId)?.argvPromptSeparatorconst withPrompt = promptArg? agentConfig(agentId)?.promptInjectionMode === 'flag-prompt'? `${baseCmd} --prompt ${promptArg}`- : `${baseCmd} ${promptArg}`+ : `${baseCmd} ${sep ? `${sep} ` : ''}${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.diff --git a/src/shared/agents/config.capabilities.test.ts b/src/shared/agents/config.capabilities.test.tsindex 8f8299d69..7d4a76c4f 100644--- a/src/shared/agents/config.capabilities.test.ts+++ b/src/shared/agents/config.capabilities.test.ts@@ -84,11 +84,22 @@ describe('grok capabilities', () => {expect(AGENT_CONFIG.grok.label).toBe('Grok')})- it('takes its prompt through stdin, because a bare positional is REJECTED by the CLI', () => {- // `grok "explain this"` → "error: unrecognized subcommand": its usage is- // `grok [OPTIONS] [COMMAND]`, so a bare word parses as a subcommand. `-p/--single` prints one- // answer and exits, so it is not an interactive session either. That leaves the TUI.- expect(AGENT_CONFIG.grok.promptInjectionMode).toBe('stdin-after-start')+ it('takes its prompt as a positional, BEHIND a `--` separator', () => {+ // Measured against the shipped 1.0.0 binary, whose usage is `grok [OPTIONS] [PROMPT] [COMMAND]`+ // — the prompt shares its slot with the subcommand list. `grok version` prints the version and+ // exits; `grok -- version` opens a session with "version" as the prompt. Without the separator+ // a prompt of `help`, `version`, `login`, `models` or `export` is executed as a command and+ // never reaches the model.+ expect(AGENT_CONFIG.grok.promptInjectionMode).toBe('argv')+ expect(AGENT_CONFIG.grok.argvPromptSeparator).toBe('--')+ })++ it('is the ONLY agent that asks for a separator', () => {+ // claude takes a positional too, but has no subcommand a one-word prompt could shadow — and+ // adding `--` there would change a command line that works today.+ for (const id of BUILTIN_AGENT_IDS.filter((a) => a !== 'grok')) {+ expect(AGENT_CONFIG[id].argvPromptSeparator, id).toBeUndefined()+ }})it('claims resume and nothing beyond it', () => {diff --git a/src/shared/agents/config.ts b/src/shared/agents/config.tsindex 69d734a96..01cd92ce3 100644--- a/src/shared/agents/config.ts+++ b/src/shared/agents/config.ts@@ -13,6 +13,20 @@ export interface AgentConfig {color: string // node colorlaunchCmd: string // base launch commandpromptInjectionMode: PromptInjectionMode+ /**+ * Put this between the command and an `argv` prompt — in practice `'--'`, and only for a CLI+ * whose grammar has BOTH a positional prompt and subcommands.+ *+ * grok is the case that needs it: its usage is `grok [OPTIONS] [PROMPT] [COMMAND]`, so a+ * one-word prompt collides with a subcommand name. Measured against the shipped binary, `grok+ * version` PRINTS THE VERSION AND EXITS while `grok -- version` opens a session with "version"+ * as the prompt — so without the separator a prompt of `help`, `version`, `login`, `models` or+ * `export` is silently executed as a command and never reaches the model.+ *+ * Omitted for every other agent: claude takes a positional and has no subcommand that could+ * shadow one, and adding a `--` there would change a command line that works today.+ */+ argvPromptSeparator?: stringexpectedProcess: string}@@ -59,12 +73,14 @@ export const AGENT_CONFIG: Record<BuiltinAgentId, AgentConfig> = {label: 'Grok',color: '#64748b',launchCmd: 'grok',- // NOT `argv`, and this was checked against the binary rather than assumed: `grok "prompt"`- // is rejected outright ("error: unrecognized subcommand"), because the CLI's usage is- // `grok [OPTIONS] [COMMAND]` and a bare word is read as a subcommand. Its `-p/--single`- // prints one answer and EXITS, so it is not an interactive node either. That leaves typing- // the prompt into the TUI after it starts — the same shape gemini needs.- promptInjectionMode: 'stdin-after-start',+ // Verified against the SHIPPED 1.0.0 binary: usage is `grok [OPTIONS] [PROMPT] [COMMAND]`, so+ // the prompt is a positional — but one that shares its slot with the subcommand list, which is+ // what the separator is for (see `argvPromptSeparator`). An earlier reading of this file said+ // `stdin-after-start`, taken from grok 0.1.220, which had no positional at all; npm's `latest`+ // tag on the platform package still points at that old build, so the first binary a `npm pack`+ // hands you is NOT the one `@xai-official/grok` installs.+ promptInjectionMode: 'argv',+ argvPromptSeparator: '--',expectedProcess: 'grok'}}