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): teach agents open-project and --project, in the PR that makes them real

enes77894e87f872
diff --git a/src/main/canvas-control-core.test.ts b/src/main/canvas-control-core.test.ts
index f8aed63af..266c55014 100644
--- a/src/main/canvas-control-core.test.ts
+++ b/src/main/canvas-control-core.test.ts
@@ -8,6 +8,7 @@ import {
CONTROL_SHIM_SCRIPT
} from './canvas-control-core'
import { RETRYABLE } from '../core/agents/agent-message-decide'
+import { PROJECT_TARGETABLE_VERBS } from './project-grants'
import { STRICT_CONTROL_VERBS } from '../core/agents/node-identity-policy'
import { BROWSER_ACTION_KEYS } from '../core/browser-verb'
import { BROWSER_RETRYABLE, BROWSER_OUTCOME_LABEL } from '../core/browser-outcomes'
@@ -444,3 +445,56 @@ describe('the messaging verbs parse', () => {
expect(isDestructiveVerb('notify')).toBe(false)
})
})
+
+describe('open-project + --project docs land with the dispatch (issue #338, spec §8)', () => {
+ const bodies: [string, string][] = [
+ ['skill', buildCanvasSkillBody('/x/shim.sh')],
+ ['instructions', buildCanvasControlInstructions('/x/shim.sh')]
+ ]
+
+ it('both bodies document open-project: idempotent, confirmed (a denial is final), local-only, the returned id, no tab focus', () => {
+ for (const [name, body] of bodies) {
+ expect(body, name).toContain('open-project --cwd')
+ expect(body, name).toMatch(/[Ii]dempotent/)
+ // The confirm may be denied, and a denial is terminal — never advice to retry it.
+ expect(body, name).toMatch(/denial is final/)
+ // Local-only (B5) and no focus (B4), stated to the agent as facts.
+ expect(body, name).toMatch(/refused from an SSH project/)
+ expect(body, name).toMatch(/never\s+focuses/)
+ expect(body, name).toContain('projectId')
+ }
+ })
+
+ it('every --project-targetable verb line documents the flag — walked off the REAL set', () => {
+ // The drift alarm walks PROJECT_TARGETABLE_VERBS (src/main/project-grants.ts) rather than a
+ // re-typed list: a fourth verb joining the set without its doc line goes red here, and a doc
+ // line dropping the flag goes red too.
+ for (const [name, body] of bodies) {
+ for (const verb of PROJECT_TARGETABLE_VERBS) {
+ const line = body.split('\n').find((l) => l.includes(`\`${verb} `))
+ expect(line, `${name}: a doc line for ${verb}`).toBeTruthy()
+ expect(line, `${name}: ${verb} documents --project`).toContain('--project')
+ }
+ }
+ })
+
+ it('both bodies state the own-or-returned-id rule as fact, the cold-open contract, and the flag exclusion', () => {
+ for (const [name, body] of bodies) {
+ expect(body, name).toContain('any other id is refused')
+ // The cold-open sentence: a session opened into a non-active project starts when the user
+ // next views it — and the agent is told not to poll for that.
+ expect(body, name).toMatch(/starts when the user next views/)
+ expect(body, name).toMatch(/do not poll/)
+ expect(body, name).toMatch(/`--group`\/`--after` cannot\s+be combined with `--project`/)
+ }
+ })
+
+ it('the orchestration recipe gains the multi-repo pattern', () => {
+ for (const [name, body] of bodies) {
+ expect(body, name).toContain('one project per repository')
+ expect(body, name).toContain('open-project --cwd <repo>')
+ // v1 has no cross-project links; the workaround is named.
+ expect(body, name).toMatch(/reader agent inside that project/)
+ }
+ })
+})
diff --git a/src/main/canvas-control-core.ts b/src/main/canvas-control-core.ts
index 61391abf6..fc0693ccd 100644
--- a/src/main/canvas-control-core.ts
+++ b/src/main/canvas-control-core.ts
@@ -284,15 +284,25 @@ export function buildCanvasControlInstructions(shimPath: string): string {
'',
'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.',
- '- `open-claude [--count N] [--cwd P] [--prompt T] [--group <id>] [--after <id,id>]` — open N Claude sessions.',
- `- \`open-agent --agent ${agentChoices} [--count N] [--cwd P] [--prompt T] [--group <id>] [--after <id,id>]\` — open`,
+ '- `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] [--group <id>] [--after <id,id>] [--project <id>]` — open N Claude sessions.',
+ `- \`open-agent --agent ${agentChoices} [--count N] [--cwd P] [--prompt T] [--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',
' their work when it wakes — use it for "B needs what A produced" instead of polling. Only',
` status-reporting agent nodes (${statusAgents}, or custom agents based on them) may be waited on; a plain terminal never`,
- ' reports finishing, so waiting on one is refused.',
+ ' reports finishing, so waiting on one is refused. `--project <id>` opens the node(s) in another',
+ ' project instead of yours: it accepts your OWN project id, or an id `open-project` returned to',
+ ' YOU in this session — any other id is refused. 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`.',
+ '- `open-project --cwd </abs/path> [--name N] [--color C]` — register (or find) the project for a',
+ ' local directory; the reply carries `{ projectId, name, cwd, created }`. Idempotent: the same',
+ ' cwd always returns the same project, never a duplicate. Creating/adding asks the user to',
+ ' confirm (your first open of an already-registered project asks once too) and may be denied —',
+ ' a denial is final, do not retry it. Local only (refused from an SSH project), and it never',
+ ' focuses the new project\'s tab. The returned id is what `--project` accepts.',
'- `show-image <path>` / `show-video <path>` — open a media file as a node.',
'- `show-web (--url U | --file P.html | --html "<...>")` — open a web viewer.',
'- `open-browser --url U` — open a navigable browser node.',
@@ -364,7 +374,13 @@ export function buildCanvasControlInstructions(shimPath: string): string {
'context link (the linked-context CLI — see the get-linked-context section in your global',
'agent instructions) and reconcile the streams into ONE synthesis yourself; a station you',
'never read is one you cannot vouch for. The user merges when a stream is done;',
- '`close-worktree --group <id>` releases a finished station.'
+ '`close-worktree --group <id>` releases a finished station.',
+ '',
+ 'Multi-repo orchestration: one project per repository — `open-project --cwd <repo>` (the user',
+ 'confirms once), then `open-agent --agent claude --project <returned id> --prompt "…"` per repo,',
+ 'one repo at a time. Sessions in a non-active project start when the user views that project —',
+ 'do not poll for them. v1 has no cross-project links: read a repo\'s results by opening a',
+ 'reader agent inside that project and linking within it.'
].join('\n')
}
@@ -529,9 +545,9 @@ 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).
-- \`open-claude [--count N] [--cwd P] [--prompt T] [--group <id>] [--after <id,id>]\` — open N Claude sessions (default 1).
-- \`open-agent --agent ${agentChoices} [--count N] [--cwd P] [--prompt T] [--group <id>] [--after <id,id>]\` — open N sessions of any agent CLI.
+- \`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] [--group <id>] [--after <id,id>] [--project <id>]\` — open N Claude sessions (default 1).
+- \`open-agent --agent ${agentChoices} [--count N] [--cwd P] [--prompt T] [--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
@@ -542,6 +558,20 @@ Verbs:
plain terminal never reports finishing and the node would hang forever. Note the semantics:
"idle" is the end of a station's TURN, not proof its whole job is done — right for a station
given one self-contained prompt, wrong if you expect a long conversation first.
+ \`--project <id>\` opens the node(s) in ANOTHER project instead of yours, without switching the
+ user's view. It accepts exactly two things: your OWN project id, or an id \`open-project\`
+ returned to YOU in this session — any other id is refused. Defaults inside the target are the
+ 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\`.
+- \`open-project --cwd </abs/path> [--name N] [--color C]\` — register (or find) the project for a
+ local directory; the reply carries \`{ projectId, name, cwd, created }\`. Idempotent: the same
+ cwd always returns the same project, never a duplicate — and \`--name\`/\`--color\` apply only
+ when the project is created (an existing project's name is never changed; the reply tells you
+ its real name). Creating/adding asks the user to confirm (your first open of an
+ already-registered project asks once too) and may be denied — a denial is final, do not retry
+ it. Local only (refused from an SSH project), and it never focuses the new project's tab: use
+ the returned id with \`--project\` to open sessions there.
- \`show-image <path>\` — open an image file as a node.
- \`show-video <path>\` — open a video file as a player node.
- \`show-web (--url U | --file P.html | --html "<...>")\` — open a web viewer (live URL or local HTML you wrote).
@@ -691,5 +721,15 @@ across Nodeterm sessions), be the orchestration chef — plan the kitchen, then
your synthesis, and say which findings you accepted and which you dismissed and why.
7. Hand back: the user merges from the group's chip (never merge for them); release a finished
station with \`close-worktree --group <id>\` (unbind keeps the directory).
+
+## Multi-repo orchestration (one project per repository)
+
+When the workstreams live in DIFFERENT repositories, give each repo its own project instead of
+piling every session onto your canvas: \`open-project --cwd <repo>\` (the user confirms once;
+idempotent thereafter), then \`open-agent --agent claude --project <returned id> --prompt
+"<task>"\` — one repo at a time. Neither verb moves the user's view, and a session opened into a
+non-active project starts when the user next views that project — do not poll for it. v1 has no
+cross-project links: read a repo's results by opening a reader agent inside that project and
+linking within it.
`
}