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.

docs(control): document --flag=value, and record the shim's SSH staleness window

enes1ef63a5fc42d
diff --git a/CLAUDE.md b/CLAUDE.md
index ca72103b2..6144df796 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -970,6 +970,16 @@ persisted — only `unread`/`session`/`sessionId` go to localStorage under
control the desktop's canvas. The shim is generated source no compiler checks:
`canvas-control-shim.test.ts` runs it for real (/bin/sh against a real hook server, port AND
unix-socket transports) — keep it that way.
+ **Flag syntax**: `--flag value`, `--flag=value`, or a valueless flag anywhere on the line. The
+ shim used to consume the next token after any `--flag` *unconditionally*, so `--read --node b1`
+ became `arg.read=--node` with `b1` silently dropped and the server answering about the wrong
+ flag; it now peeks. The trade: a value that itself starts with `--` must use the `=` form
+ (`--cmd=--version`), which was previously unexpressible in either direction. Two parsers are in
+ play and both are tested — the sh loop (`control-shim-parse.test.ts`, real `sh` + a fake `curl`
+ that records argv) and `parseControlBody` reading what it built (`canvas-control-shim.test.ts`).
+ **A new verb must not DEPEND on the fix**: the shim is rewritten locally every app boot but onto
+ an SSH host only inside `RemoteHooks.setup()` (on connect), so an already-connected project keeps
+ the old loop with no signal on the wire. Give every flag a value and both loops agree.
**Grouping verbs** (`group` / `ungroup` / `move` / `arrange` / `align`): `group` wraps **sibling**
objects — nodes or frames — into a new frame in their shared container (a mixed-container set, or
an ancestor plus its descendant, is refused with that reason); `ungroup --group <id>` dissolves a
diff --git a/docs/ssh-agent-skills.md b/docs/ssh-agent-skills.md
index 0e0d43126..576d890d2 100644
--- a/docs/ssh-agent-skills.md
+++ b/docs/ssh-agent-skills.md
@@ -66,6 +66,26 @@ at it (`NODETERM_HOOK_ENDPOINT`) along with `NODETERM_NODE_ID`. So the design ru
installed. It now mirrors the local `hookServer.buildPtyEnv` exactly, `canControlCanvas`
gate included.
+### Flag syntax, and why a verb must not depend on it
+
+Flags are `--flag value` or `--flag=value`, and a flag may carry no value at all, anywhere on the
+line. The `=` form is the **only** way to pass a value that itself starts with `--`
+(`open-terminal --cmd=--version`); written as two tokens, a leading `--` is read as the next flag,
+so `--text --oops` sends an empty `--text` plus a stray `--oops`.
+
+That is a deliberate trade. The loop used to consume the token after any `--flag`
+*unconditionally*, so `--read --node b1` became `arg.read=--node` with `b1` dropped, and a
+valueless flag was expressible only as the last token on the line. Both failures were **silent** —
+the request stayed well-formed and the server answered about the wrong flag, which sends the next
+debugger to the verb table instead of to the shim.
+
+**The staleness window this lives in:** the shim is rewritten locally at every app boot, but onto
+an SSH host only inside `RemoteHooks.setup()`, i.e. **on connect**. An already-connected SSH
+project keeps the shim it was handed, so a parser improvement reaches remote agent nodes only
+after a reconnect, with nothing on the wire to say which loop is running — the same shape as the
+managed hook script's stale window. New verbs are therefore designed to parse identically under
+both loops: give every flag a value and the old and new loops agree.
+
### Gating and failure behavior
Install is gated on **both** a resolved remote `$HOME` (every remote path must be absolute — a
diff --git a/src/main/canvas-control-core.test.ts b/src/main/canvas-control-core.test.ts
index d693f118e..47b65ed58 100644
--- a/src/main/canvas-control-core.test.ts
+++ b/src/main/canvas-control-core.test.ts
@@ -3,7 +3,8 @@ import {
parseControlRequest,
isDestructiveVerb,
mergeCanvasControlBlock,
- buildCanvasControlInstructions
+ buildCanvasControlInstructions,
+ buildCanvasSkillBody
} from './canvas-control-core'
describe('parseControlRequest', () => {
@@ -183,6 +184,21 @@ describe('parseControlRequest', () => {
expect(body.toLowerCase()).toContain('confirm')
})
+ // The parser change in this commit's sibling is only half a fix: an agent that never learns the
+ // `=` form simply cannot express a value beginning with `--`, and the failure stays silent for it.
+ // So both agent-facing texts must carry the rule, not just one of them.
+ it('the skill text documents --flag=value and warns about values starting with --', () => {
+ const body = buildCanvasSkillBody('/x/shim.sh')
+ expect(body).toContain('--flag=value')
+ expect(body).toMatch(/starts? with `--`/)
+ })
+
+ it('the codex/gemini instructions carry the same rule', () => {
+ const body = buildCanvasControlInstructions('/tmp/nodeterm.sh')
+ expect(body).toContain('--flag=value')
+ expect(body).toMatch(/starts? with `--`/)
+ })
+
it('spawn-team requires --team and none of the layout verbs are destructive', () => {
expect(parseControlRequest('spawn-team', {})).toEqual({ error: 'spawn-team requires --team <json>' })
expect(parseControlRequest('spawn-team', { team: '[]' })).toEqual({ verb: 'spawn-team', args: { team: '[]' } })
diff --git a/src/main/canvas-control-core.ts b/src/main/canvas-control-core.ts
index 3b233f94f..711f6b946 100644
--- a/src/main/canvas-control-core.ts
+++ b/src/main/canvas-control-core.ts
@@ -138,6 +138,10 @@ export function buildCanvasControlInstructions(shimPath: string): string {
`sh "${shimPath}" <verb> [args]`,
'```',
'',
+ 'Flags take a value: `--flag value`, or `--flag=value`. Use the `=` form when the value itself',
+ 'starts with `--` (`--cmd=--version`); written as two tokens, a leading `--` is read as the next',
+ 'flag. A flag with no value is allowed anywhere on the line.',
+ '',
'Verbs:',
'- `list` — current nodes (id, kind, title). Start here when you need a node id.',
'- `open-terminal [--count N] [--cwd P] [--cmd C] [--group <id>] [--after <id,id>]` — open N plain terminals.',
@@ -215,6 +219,13 @@ export function buildCanvasControlInstructions(shimPath: string): string {
// request is form-urlencoded rather than JSON because `curl --data-urlencode` does the escaping
// for us — emitting valid JSON from sh for arbitrary values (`--prompt`, `--html`, `--team`)
// could not be made safe.
+//
+// INSTALL LIFECYCLE, and why a verb must not depend on this parser's fixes: the shim is rewritten
+// locally at every app boot, but onto an SSH host ONLY inside RemoteHooks.setup(), i.e. on connect.
+// An already-connected SSH project keeps the shim it was handed. So a parsing improvement reaches
+// remote agent nodes only after a reconnect, with no signal on the wire — the same shape as the
+// managed hook script's stale window. Verbs are therefore designed to parse identically under both
+// the old and the new loop: give every flag a value, and the two loops agree.
export const CONTROL_SHIM_SCRIPT = `#!/bin/sh
# nodeterm canvas-control CLI (auto-generated — do not edit).
@@ -348,6 +359,11 @@ Run the shim (absolute path):
sh "${shimPath}" <verb> [args]
\`\`\`
+Flags take a value: \`--flag value\`, or \`--flag=value\`. Use the \`=\` form when the value itself
+starts with \`--\` (\`--cmd=--version\`); written as two tokens, a leading \`--\` is read as the
+next flag, so \`--text --oops\` sends an empty \`--text\` plus a stray \`--oops\`. A flag with no
+value is allowed anywhere on the line, not only at the end.
+
Verbs:
- \`list\` — list current nodes (id, kind, title). Start here when you need a node id.
- \`open-terminal [--count N] [--cwd P] [--cmd C] [--group <id>] [--after <id,id>]\` — open N plain terminals (default 1).