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(canvas-control): --prompt-file carries a multi-line brief (#520)

enes3f07c868b392
diff --git a/src/main/canvas-control-core.test.ts b/src/main/canvas-control-core.test.ts
index 2ac2983f1..3d5a10e40 100644
--- a/src/main/canvas-control-core.test.ts
+++ b/src/main/canvas-control-core.test.ts
@@ -315,6 +315,21 @@ describe('parseControlRequest', () => {
}
})
+ it('both agent-facing texts document --prompt-file and the one-line --prompt fact (issue #520)', () => {
+ for (const body of [buildCanvasSkillBody('/x/shim.sh'), buildCanvasControlInstructions('/tmp/nodeterm.sh')]) {
+ // `assembleLaunchCommand` collapses every whitespace run in a --prompt literal (it rides
+ // argv on a line typed into the pane). An agent that does not know this writes a numbered
+ // brief and gets one paragraph — and the fix, --prompt-file, is useless undocumented.
+ expect(body.toUpperCase()).toContain('ONE LINE')
+ expect(body).toContain('--prompt-file')
+ // The per-role escape on spawn-team must be named too, or teams stay prose-only.
+ expect(body).toContain('promptFile')
+ // The failure that costs a whole station: flattened, a leading slash command swallows the
+ // task as its argument, and the node then reads as idle to `--after`.
+ expect(body.toLowerCase()).toMatch(/begin a prompt with `\/`|start a prompt with `\/`/)
+ }
+ })
+
it('both agent-facing texts document the sticky verb', () => {
for (const body of [buildCanvasSkillBody('/x/shim.sh'), buildCanvasControlInstructions('/tmp/nodeterm.sh')]) {
expect(body).toContain('`sticky --node')
diff --git a/src/main/canvas-control-core.ts b/src/main/canvas-control-core.ts
index 6799dbb6d..62d121fd6 100644
--- a/src/main/canvas-control-core.ts
+++ b/src/main/canvas-control-core.ts
@@ -290,8 +290,8 @@ export function buildCanvasControlInstructions(shimPath: string): string {
'- `list` — current nodes (id, kind, title). Start here when you need a node id.',
'- `help` — print the verb list. Answered by the shim itself, so it works even if the app is down.',
'- `open-terminal [--count N] [--cwd P] [--cmd C] [--group <id>] [--after <id,id>] [--project <id>]` — open N plain terminals.',
- '- `open-claude [--count N] [--cwd P] [--prompt T] [--model M] [--group <id>] [--after <id,id>] [--project <id>]` — open N Claude sessions.',
- `- \`open-agent --agent ${agentChoices} [--count N] [--cwd P] [--prompt T] [--model M] [--group <id>] [--after <id,id>] [--project <id>]\` — open`,
+ '- `open-claude [--count N] [--cwd P] [--prompt T | --prompt-file F] [--model M] [--group <id>] [--after <id,id>] [--project <id>]` — open N Claude sessions.',
+ `- \`open-agent --agent ${agentChoices} [--count N] [--cwd P] [--prompt T | --prompt-file F] [--model M] [--group <id>] [--after <id,id>] [--project <id>]\` — open`,
' any agent CLI. `--group` parents the node(s) into a group frame; a worktree-bound group also',
' hands its worktree path down as the cwd. `--after <id,id>` opens the node ARMED: it does not',
' start until every listed station has gone idle, and is context-linked to them so it can read',
@@ -303,6 +303,14 @@ export function buildCanvasControlInstructions(shimPath: string): string {
' included); or an id `open-project` returned to YOU in this session, which never switches the',
' user\'s view. A session opened into a non-active project starts when the user next views that',
' project — do not poll for it. `--group`/`--after` cannot be combined with `--project`.',
+ ' `--prompt` arrives on ONE LINE: every whitespace run in it, newlines included, is collapsed',
+ ' to a single space (the prompt rides the launch command line typed into the pane). For a',
+ ' structured or multi-line brief use `--prompt-file <abs path>` instead: write the brief to a',
+ ' file, pass the absolute path, and the session starts with the file\'s exact contents —',
+ ' newlines, numbered lists and headings preserved. The file is read when the session LAUNCHES',
+ ' (later than the call for an `--after`-armed node), so leave it in place until the station has',
+ ' started. Never begin a prompt with `/`: the agent reads the whole text as that slash',
+ ' command\'s arguments and your task is never seen — use `--model` to pick a model.',
' `--model <id>` picks the model the session launches with, instead of inheriting the',
' default. Use it to keep a cheap station cheap: a node whose whole job is editing a README',
' does not need the model you give the node rewriting a test suite. Honoured by claude, codex',
@@ -338,7 +346,8 @@ export function buildCanvasControlInstructions(shimPath: string): string {
'- `spawn-team --label L --team \'[{"title":"UI","prompt":"...","agent":"claude","model":"..."}]\'` — one agent per',
' role (max 8), arranged in a grid, wrapped in a labeled group, each connected + context-linked to you.',
' `model` is per role, so one team can mix tiers — give an expensive model to the role that needs it',
- ' and a cheap one to the rest. Same rule as `--model` below.',
+ ' and a cheap one to the rest. Same rule as `--model` below. A role may carry `promptFile`',
+ ' (absolute path) instead of `prompt` — same multi-line-brief semantics as `--prompt-file`.',
'- `open-worktree --branch <name> [--base <ref>] [--path P] [--group <id>]` — create a git worktree',
' wrapped in a bound group frame (terminals inside it run in the worktree). Local projects only.',
'- `close-worktree --group <id> [--mode unbind|remove]` — unbind keeps the directory; remove asks',
@@ -653,8 +662,8 @@ Verbs:
- \`help\` — print the verb list. The shim answers this itself, without reaching the app, so it
is also what to run when you are unsure whether the control endpoint is alive.
- \`open-terminal [--count N] [--cwd P] [--cmd C] [--group <id>] [--after <id,id>] [--project <id>]\` — open N plain terminals (default 1).
-- \`open-claude [--count N] [--cwd P] [--prompt T] [--model M] [--group <id>] [--after <id,id>] [--project <id>]\` — open N Claude sessions (default 1).
-- \`open-agent --agent ${agentChoices} [--count N] [--cwd P] [--prompt T] [--model M] [--group <id>] [--after <id,id>] [--project <id>]\` — open N sessions of any agent CLI.
+- \`open-claude [--count N] [--cwd P] [--prompt T | --prompt-file F] [--model M] [--group <id>] [--after <id,id>] [--project <id>]\` — open N Claude sessions (default 1).
+- \`open-agent --agent ${agentChoices} [--count N] [--cwd P] [--prompt T | --prompt-file F] [--model M] [--group <id>] [--after <id,id>] [--project <id>]\` — open N sessions of any agent CLI.
\`--group\` parents the node(s) into an existing group frame; a worktree-bound group also
hands its worktree path down as the cwd.
\`--after <id,id>\` opens the node **armed**: it does NOT start yet, and launches itself once
@@ -672,6 +681,20 @@ Verbs:
TARGET project's (its cwd, its default account and permission mode). A session opened into a
non-active project starts when the user next views that project — do not poll for it; the reply
says so. \`--group\`/\`--after\` cannot be combined with \`--project\`.
+ \`--prompt\` arrives on ONE LINE. Every run of whitespace in it — newlines included — is
+ collapsed to a single space, because the prompt is passed as an argument on the agent CLI's
+ launch command line and that line is typed into the pane. Two consequences:
+ - **A structured brief goes through \`--prompt-file <abs path>\`.** Write the brief (numbered
+ acceptance criteria, file lists, guard clauses — anything multi-line) to a file, pass the
+ absolute path, and the session starts with the file's exact contents: the launch line stays
+ one line and the pane's shell reads the file at execution. The file is read when the session
+ LAUNCHES — for an \`--after\`-armed node that is later than your call — so leave it in place
+ until the station has started. On an SSH project the path is on the host (where you run).
+ Pass either \`--prompt\` or \`--prompt-file\`, not both.
+ - **Never start a prompt with \`/\`.** The agent reads the whole prompt as arguments to that
+ slash command, your task is never seen, and the node then sits at an idle prompt looking
+ healthy — including to \`--after\`, which will arm everything behind it. Use \`--model\` for
+ the model; there is no supported way to run a slash command at launch.
\`--model <id>\` decides which model the session LAUNCHES with, instead of inheriting the
project default. This is the lever for cost: a station whose job is editing a README does not
need the model you give the station rewriting a 1000-line test suite, and without this flag
@@ -729,7 +752,9 @@ Verbs:
open one agent per role (each prompt starts that member working), arrange them in a grid,
wrap them in a labeled group, and connect + context-link each to you. Max 8 roles per call.
\`model\` is optional and per role — the same selector \`--model\` applies, so a single team can
- run its heavy role on a large model and the rest on a cheap one.
+ run its heavy role on a large model and the rest on a cheap one. A role may carry
+ \`promptFile\` (absolute path) instead of \`prompt\` — the \`--prompt-file\` semantics per role,
+ for members whose brief is structured or multi-line.
- \`open-worktree --branch <name> [--base <ref>] [--path P] [--group <id>]\` — create a git
worktree (new branch off base, default: the repo's default branch) and wrap it in a bound
group frame (or bind it to an existing empty group). Terminals created inside the group
diff --git a/src/main/control-shim-parse.test.ts b/src/main/control-shim-parse.test.ts
index 1d24345a0..648f073de 100644
--- a/src/main/control-shim-parse.test.ts
+++ b/src/main/control-shim-parse.test.ts
@@ -82,6 +82,14 @@ describe('the control shim translates flags', () => {
expect(run(['rename', '--node', 'n1', '--title='])).toEqual(['arg.node=n1', 'arg.title='])
})
+ // Hyphenated flag names ride through as-is — the loop strips only the leading `--`, so
+ // `--prompt-file` lands as `arg.prompt-file` and the server reads args['prompt-file'].
+ it('a hyphenated flag name (--prompt-file) keeps its hyphen in the arg key', () => {
+ expect(run(['open-claude', '--prompt-file', '/tmp/brief.md'])).toEqual([
+ 'arg.prompt-file=/tmp/brief.md'
+ ])
+ })
+
// The peek tests for `--`, not for `-`: a single-dash token is a VALUE. `--scroll -600` must
// keep working, or the fix trades one silent misparse for another.
it('a negative number is still consumed as a value', () => {
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsx
index 5462d48b4..6eff80499 100644
--- a/src/renderer/canvas/Canvas.tsx
+++ b/src/renderer/canvas/Canvas.tsx
@@ -366,6 +366,7 @@ import {
type AgentPermissionMode
} from '@shared/agents/config'
import { withPermissionMode } from '@shared/agents/approval-mode'
+import { promptFilePathError } from '@shared/agents/launch'
import { relativeTime } from '../lib/relativeTime'
import { AgentIcon } from '../lib/agentIcons'
import { branchClaudeSession } from '../lib/claudeBranch'
@@ -8641,6 +8642,32 @@ export function Canvas() {
)
const after = resolveAfter()
if (after === null) return // bad --after, already replied
+ // `--prompt-file` (issue #520): a multi-line brief travels as a FILE the new node's
+ // shell reads at launch (`"$(cat …)"` in the assembler), because `--prompt` rides a
+ // command line typed into the pane and is collapsed to one line. Validated here — the
+ // path shape by the pure rule, existence against the filesystem the node will read it
+ // from (the HOST's on an SSH project). A missing file would launch the agent with an
+ // EMPTY prompt (the substitution expands to nothing), which is the silent failure the
+ // check exists to catch; a check that itself errors fails OPEN, since the pane shows
+ // cat's own error where a wrongly-refused open shows nothing.
+ const promptFile = (args['prompt-file'] ?? '').trim() || undefined
+ if (promptFile && args.prompt) {
+ reply({ ok: false, error: `${verb}: pass either --prompt or --prompt-file, not both` })
+ return
+ }
+ if (promptFile) {
+ const pfErr = promptFilePathError(promptFile)
+ if (pfErr) {
+ reply({ ok: false, error: `${verb}: --prompt-file ${pfErr}` })
+ return
+ }
+ const pfFs = ctlSsh && ctlProject ? sshFs(ctlProject.id) : api.fs
+ const pfExists = await pfFs.exists(promptFile).catch(() => true)
+ if (!pfExists) {
+ reply({ ok: false, error: `${verb}: --prompt-file not found: ${promptFile}` })
+ return
+ }
+ }
const agentCwd = args.cwd || groupCwd || srcCwd
const make = (i: number): CanvasNode =>
armAfter(
@@ -8659,7 +8686,8 @@ export function Canvas() {
// `--model` is a pass-through: `withAgentModel` re-validates the value at the
// interpolation site and emits nothing for an agent outside MODEL_SWITCH_CAPABLE,
// so an unsupported agent's command line stays byte-identical.
- args.model
+ args.model,
+ promptFile
),
after ?? [],
undefined,
@@ -9083,22 +9111,59 @@ export function Canvas() {
return
}
case 'spawn-team': {
- let roles: { title?: string; prompt?: string; agent?: string; model?: string }[]
+ let roles: {
+ title?: string
+ prompt?: string
+ promptFile?: string
+ agent?: string
+ model?: string
+ }[]
try {
const parsed = JSON.parse(args.team ?? '')
roles = Array.isArray(parsed) ? parsed : []
} catch {
reply({
ok: false,
- error: 'spawn-team: --team must be a JSON array of {title?, prompt, agent?, model?}'
+ error:
+ 'spawn-team: --team must be a JSON array of {title?, prompt|promptFile, agent?, model?}'
})
return
}
- roles = roles.filter((r) => r && typeof r.prompt === 'string' && r.prompt.trim()).slice(0, 8)
+ roles = roles
+ .filter(
+ (r) =>
+ r &&
+ ((typeof r.prompt === 'string' && r.prompt.trim()) ||
+ (typeof r.promptFile === 'string' && r.promptFile.trim()))
+ )
+ .slice(0, 8)
if (roles.length === 0) {
- reply({ ok: false, error: 'spawn-team: --team needs at least one role with a prompt' })
+ reply({
+ ok: false,
+ error: 'spawn-team: --team needs at least one role with a prompt (or promptFile)'
+ })
return
}
+ // Per-role `promptFile` — the same contract as `--prompt-file` on the open verbs
+ // (issue #520): path shape by the pure rule, existence against the filesystem the new
+ // node reads it from, missing file refused (an empty `$(cat …)` would silently start
+ // the member with no task), a check that errors fails open.
+ for (const [ri, r] of roles.entries()) {
+ const rf = typeof r.promptFile === 'string' ? r.promptFile.trim() : ''
+ if (!rf) continue
+ const roleName = r.title?.trim() ? `"${r.title.trim()}"` : `#${ri + 1}`
+ const rfErr = promptFilePathError(rf)
+ if (rfErr) {
+ reply({ ok: false, error: `spawn-team: role ${roleName} promptFile ${rfErr}` })
+ return
+ }
+ const rfFs = ctlSsh && ctlProject ? sshFs(ctlProject.id) : api.fs
+ const rfExists = await rfFs.exists(rf).catch(() => true)
+ if (!rfExists) {
+ reply({ ok: false, error: `spawn-team: role ${roleName} promptFile not found: ${rf}` })
+ return
+ }
+ }
const live = nodesRef.current as CanvasNode[]
// Same account funnel as open-claude/open-agent above; per-role the factory
// drops the account for non-claude agents.
@@ -9125,7 +9190,11 @@ export function Canvas() {
teamStore.activeProjectId,
// Per-role model, so one team can mix tiers in a single call. A role naming a
// model its agent cannot switch simply launches bare (withAgentModel no-ops).
- typeof r.model === 'string' ? r.model : undefined
+ typeof r.model === 'string' ? r.model : undefined,
+ // Per-role promptFile (validated above); wins over `prompt` in the assembler.
+ typeof r.promptFile === 'string' && r.promptFile.trim()
+ ? r.promptFile.trim()
+ : undefined
)
return r.title ? { ...node, data: { ...node.data, title: r.title, titleAuto: false } } : node
})
diff --git a/src/renderer/state/workspace.ts b/src/renderer/state/workspace.ts
index b999f795d..eeefdac20 100644
--- a/src/renderer/state/workspace.ts
+++ b/src/renderer/state/workspace.ts
@@ -588,7 +588,13 @@ export function createAgentNode(
* agent, so passing a model for one is harmless — it's simply not appended). Persisted as
* `data.agentModel` so cold-restore and later restarts keep the model. Trails `projectId`: every
* existing caller passes that ninth argument, so the model is the one that had to move. */
- model?: string
+ model?: string,
+ /** Absolute path to a file holding the first prompt (canvas-control `--prompt-file`). Wins over
+ * `initialPrompt`; composed by the assembler as a `"$(cat …)"` substitution so a multi-line
+ * brief survives the single-line typed delivery. Validated by the caller
+ * (`promptFilePathError` + an existence check) — the factory trusts it. Trailing/optional so
+ * every existing caller is unchanged. */
+ promptFile?: string
): CanvasNode {
const { label, color } = resolveAgent(agentId)
// The launch-command override (this project's `.nodeterm/settings.json` first, then Settings →
@@ -625,6 +631,7 @@ export function createAgentNode(
agentId,
customAgent,
initialPrompt,
+ promptFile,
permissionMode,
sessionId: mintedSessionId,
sessionIdFlagSupported,
diff --git a/src/shared/agents/launch.test.ts b/src/shared/agents/launch.test.ts
index a3a416cfe..6c73fd7a0 100644
--- a/src/shared/agents/launch.test.ts
+++ b/src/shared/agents/launch.test.ts
@@ -1,5 +1,5 @@
import { afterEach, describe, expect, it } from 'vitest'
-import { assembleLaunchCommand, assembleResumeCommand } from './launch'
+import { assembleLaunchCommand, assembleResumeCommand, promptFilePathError } from './launch'
import { setCustomAgentBaseResolver } from './config'
import type { CustomAgent } from '../types'
@@ -284,3 +284,75 @@ describe('quoting by construction — env values can never become shell syntax o
expect(missingEnv).toEqual(['GONE'])
})
})
+
+describe('assembleLaunchCommand — promptFile (issue #520)', () => {
+ // The whole point: the TYPED line stays single-line while the pane's shell expands the file at
+ // execution, so a multi-line brief reaches the CLI with its structure intact.
+ it('claude composes the prompt as a "$(cat …)" substitution with the PATH single-quoted', () => {
+ expect(
+ assembleLaunchCommand({ agentId: 'claude', promptFile: '/tmp/brief.md' }, ENV).command
+ ).toBe('claude "$(cat \'/tmp/brief.md\')"')
+ })
+ it('flags still land after the prompt for claude', () => {
+ expect(
+ assembleLaunchCommand(
+ { agentId: 'claude', promptFile: '/tmp/brief.md', permissionMode: 'auto' },
+ ENV
+ ).command
+ ).toBe('claude "$(cat \'/tmp/brief.md\')" --permission-mode auto')
+ })
+ it('grok keeps its flags BEFORE the -- separator, substitution after it', () => {
+ expect(
+ assembleLaunchCommand(
+ { agentId: 'grok', promptFile: '/tmp/brief.md', permissionMode: 'plan' },
+ ENV
+ ).command
+ ).toBe('grok --permission-mode plan -- "$(cat \'/tmp/brief.md\')"')
+ })
+ it('a flag-prompt agent passes the substitution through its prompt flag', () => {
+ expect(assembleLaunchCommand({ agentId: 'opencode', promptFile: '/tmp/b.md' }, ENV).command).toBe(
+ 'opencode --prompt "$(cat \'/tmp/b.md\')"'
+ )
+ })
+ it('promptFile wins over initialPrompt', () => {
+ expect(
+ assembleLaunchCommand(
+ { agentId: 'claude', initialPrompt: 'ignored', promptFile: '/tmp/brief.md' },
+ ENV
+ ).command
+ ).toBe('claude "$(cat \'/tmp/brief.md\')"')
+ })
+ it('a path with a quote in it cannot break out of the quoting', () => {
+ // shellSingleQuote's '\'' dance — the path stays ONE argument to cat and nothing in it
+ // reaches the shell as syntax.
+ const cmd = assembleLaunchCommand(
+ { agentId: 'claude', promptFile: "/tmp/my brief's.md" },
+ ENV
+ ).command
+ expect(cmd.startsWith('claude "$(cat ')).toBe(true)
+ expect(cmd).toContain("'/tmp/my brief'\\''s.md'")
+ })
+ it('the --prompt literal is still collapsed to one line (unchanged behavior)', () => {
+ expect(
+ assembleLaunchCommand({ agentId: 'claude', initialPrompt: 'a\nb\n\n c' }, ENV).command
+ ).toBe("claude 'a b c'")
+ })
+})
+
+describe('promptFilePathError', () => {
+ it('accepts an absolute POSIX path', () => {
+ expect(promptFilePathError('/tmp/brief.md')).toBeNull()
+ })
+ it('accepts a Windows drive path', () => {
+ expect(promptFilePathError('C:\\briefs\\x.md')).toBeNull()
+ })
+ it('refuses a relative path', () => {
+ expect(promptFilePathError('brief.md')).toMatch(/absolute/)
+ })
+ it('refuses an empty path', () => {
+ expect(promptFilePathError(' ')).toMatch(/needs a path/)
+ })
+ it('refuses a newline in the path — it would break the single-line typed delivery', () => {
+ expect(promptFilePathError('/tmp/a\nb')).toMatch(/newlines/)
+ })
+})
diff --git a/src/shared/agents/launch.ts b/src/shared/agents/launch.ts
index ecf6b1416..d80a7d32e 100644
--- a/src/shared/agents/launch.ts
+++ b/src/shared/agents/launch.ts
@@ -39,8 +39,17 @@ export interface LaunchInputs {
* Trusted verbatim, exactly like a custom agent's `launchCmd`: it is the local user's own
* settings and is typed into their own pane. */
launchCmdOverride?: string
- /** First-launch prompt. Empty/undefined = start the agent with no prompt. */
+ /** First-launch prompt. Empty/undefined = start the agent with no prompt. Collapsed to ONE
+ * line (every whitespace run → a single space): the prompt rides argv on a command line typed
+ * into the pane, and a newline would submit the half-typed line. Multi-line briefs go through
+ * `promptFile` instead. */
initialPrompt?: string
+ /** Absolute path to a file holding the first-launch prompt (canvas-control `--prompt-file`).
+ * Wins over `initialPrompt`. Composed as `"$(cat '<path>')"` so the TYPED line stays one line
+ * while the pane's shell expands the file — newlines and all — into a single argv element at
+ * execution. Requires a POSIX-style shell in the new node; validate with
+ * `promptFilePathError` before passing. */
+ promptFile?: string
/** Permission mode to start in. `undefined` = no flag (the agent's own default). */
permissionMode?: AgentPermissionMode
/** Per-node model override, applied through the effective base harness. */
@@ -125,6 +134,26 @@ function expandedProgram(
return { value: tokens.join(' '), missing }
}
+/**
+ * Validate a `--prompt-file` path BEFORE it is composed into the launch line. Returns a short
+ * error fragment, or null when the path is usable. The rules exist because the path is
+ * interpolated into a command that is typed into the pane as ONE line: a newline in the path
+ * would break the single-line delivery the whole mechanism exists to preserve, and a relative
+ * path is ambiguous between the calling agent's cwd and the new node's cwd — requiring an
+ * absolute path removes the guess. (Quoting itself is `shellSingleQuote`'s job — a space or a
+ * quote in the path is fine.)
+ */
+export function promptFilePathError(p: string): string | null {
+ const t = p.trim()
+ if (!t) return 'needs a path'
+ // eslint-disable-next-line no-control-regex
+ if (/[\r\n\x00]/.test(t)) return 'must not contain newlines or control characters'
+ if (!(t.startsWith('/') || /^[A-Za-z]:[\\/]/.test(t))) {
+ return `must be an absolute path (got "${t}")`
+ }
+ return null
+}
+
/**
* Assemble the FIRST-LAUNCH command: `<launchCmd> <args> [sep] [prompt] [permission flag]
* [session-id flag]`. The prompt and flags land per the resolved prompt convention (separator
@@ -154,9 +183,22 @@ export function assembleLaunchCommand(
const { fragment: argsFragment, missing: m2 } = expandedArgs(inputs.customAgent?.args ?? '', env)
const baseCmd = argsFragment ? `${program} ${argsFragment}` : program
- const promptArg = inputs.initialPrompt
- ? shellSingleQuote(inputs.initialPrompt.replace(/\s+/g, ' ').trim())
- : null
+ // The prompt becomes an ARGUMENT on a command line that is then typed into the pane
+ // (`writeWhenShellReady` → `deliverCommand`, which echo-verifies the line before submitting).
+ // A raw newline inside it would submit the half-typed line and fail that verification, so:
+ // - `initialPrompt` (a literal) has every whitespace run collapsed to a single space —
+ // load-bearing for the delivery path, not tidying (issue #520 / PR #516's finding).
+ // - `promptFile` keeps structure WITHOUT putting it on the typed line: the argument is a
+ // `"$(cat '<path>')"` command substitution, so the pane's shell reads the file at execution
+ // and hands the CLI its exact contents as ONE argv element. The double quotes make the
+ // substitution a single word and keep its RESULT data — file content is never re-parsed as
+ // shell syntax. On an SSH project the path (and the `cat`) are on the host, which is exactly
+ // where the node runs. Only the PATH is interpolated, and it is single-quoted.
+ const promptArg = inputs.promptFile
+ ? `"$(cat ${shellSingleQuote(inputs.promptFile.trim())})"`
+ : inputs.initialPrompt
+ ? shellSingleQuote(inputs.initialPrompt.replace(/\s+/g, ' ').trim())
+ : null
const sep = eff.argvPromptSeparator
const promptFlag =
eff.promptInjectionMode === 'flag-prompt'