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(control): install nodeterm CLI shim + manage-nodeterm-canvas skill

enes81efa4010f3a
diff --git a/src/main/canvas-control.ts b/src/main/canvas-control.ts
new file mode 100644
index 000000000..a020a81d0
--- /dev/null
+++ b/src/main/canvas-control.ts
@@ -0,0 +1,86 @@
+// Installs the outbound canvas-control CLI + a Claude skill describing it. Mirrors
+// context-link.ts: a self-contained CLI (canvas-control-cli.mjs, run via Electron-as-Node
+// through nodeterm.sh) POSTs to the hook server's /control/* routes; the skill tells the
+// agent how + when to call it. The CLI no-ops unless NODETERM_CANVAS_CONTROL is set.
+import fs from 'fs'
+import os from 'os'
+import path from 'path'
+import { app } from 'electron'
+import { CONTROL_CLI_SCRIPT } from './canvas-control-core'
+
+function dir(): string {
+ return path.join(app.getPath('userData'), 'canvas-control')
+}
+function cliScriptPath(): string {
+ return path.join(dir(), 'canvas-control-cli.mjs')
+}
+function shimPath(): string {
+ return path.join(dir(), 'nodeterm.sh')
+}
+function skillPath(): string {
+ return path.join(os.homedir(), '.claude', 'skills', 'manage-nodeterm-canvas', 'SKILL.md')
+}
+
+function writeCliFiles(): void {
+ const d = dir()
+ fs.mkdirSync(d, { recursive: true })
+ fs.writeFileSync(cliScriptPath(), CONTROL_CLI_SCRIPT)
+ const shim = `#!/bin/sh
+# nodeterm canvas-control CLI shim (auto-generated — do not edit).
+ELECTRON_RUN_AS_NODE=1 exec "${process.execPath}" "${cliScriptPath()}" "$@"
+`
+ fs.writeFileSync(shimPath(), shim)
+ try {
+ fs.chmodSync(shimPath(), 0o755)
+ } catch {
+ /* fail open */
+ }
+}
+
+function installSkill(): void {
+ const body = `---
+name: manage-nodeterm-canvas
+description: Open and control nodes on the nodeterm canvas — spawn Claude/terminal sessions, show an image/video/web page, write to or close a terminal. Use when the user asks you to open sessions, visualize something, or render the code/output you produced on the canvas. Only works inside a nodeterm Claude session.
+---
+
+# Manage the nodeterm canvas
+
+You are running inside a node on the nodeterm canvas. You can create and control nodes by
+running the local CLI shim below. Every node you open is connected to your node by an edge.
+
+Run the shim (absolute path):
+
+\`\`\`sh
+sh "${shimPath()}" <verb> [args]
+\`\`\`
+
+Verbs:
+- \`list\` — list current nodes (id, kind, title). Start here when you need a node id.
+- \`open-terminal [--cwd P] [--cmd C]\` — open a terminal node.
+- \`open-claude [--count N] [--cwd P] [--prompt T]\` — open N Claude sessions (default 1).
+- \`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).
+- \`write --node <id> --text "..."\` — type text into a terminal node. (Asks the user to confirm.)
+- \`close --node <id>\` — close a node. (Asks the user to confirm.)
+
+Notes:
+- \`write\` and \`close\` require the user to approve a confirmation dialog; they may be denied.
+- If the CLI says canvas control is unavailable, you are not in a controllable nodeterm session — do not retry.
+`
+ try {
+ fs.mkdirSync(path.dirname(skillPath()), { recursive: true })
+ fs.writeFileSync(skillPath(), body, 'utf8')
+ } catch (e) {
+ console.warn('[canvas-control] skill install failed', e)
+ }
+}
+
+export function initCanvasControl(): void {
+ try {
+ writeCliFiles()
+ installSkill()
+ } catch (e) {
+ console.error('[canvas-control] setup failed', e)
+ }
+}
diff --git a/src/main/index.ts b/src/main/index.ts
index 63edbdb3c..1863b3632 100644
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@ -33,6 +33,7 @@ import { childArgs } from './remote-ssh/control-master'
import { posixQuote } from '../shared/ssh'
import { buildHandoff } from './handoff'
import { initContextLink, setNodeTranscript } from './context-link'
+import { initCanvasControl } from './canvas-control'
import { initTranscriptIndex, searchTranscripts } from './transcript-index'
import { initTelemetry } from './telemetry'
import { initClaudeUsage } from './claude-usage'
@@ -596,6 +597,7 @@ app.whenReady().then(async () => {
initMediaProtocol()
initContextLink(win, ptyManager)
+ initCanvasControl()
initClaudeUsage(win)
initTelemetry(() => settingsStore.get())
initLicense(win)