#!/usr/bin/env moshscript // Connect Claude Code to W3BS Training // Exported from W3BS Training episode ep_36773bc43575d95f on 2026-10-19 (w3bs-training 0.2.6). // The task below is an OpenTask 0.1 document: https://logicsrc.com/docs/opentask // // moshcode run connect-claude-code-to-w3bs-training-qgajo2.mosh opens claude with this task // moshcode run connect-claude-code-to-w3bs-training-qgajo2.mosh codex or another engine // moshcode run connect-claude-code-to-w3bs-training-qgajo2.mosh --dry-run shows what it would do // // The recording holds semantic steps (app, control, shortcut): no coordinates, and typed text only as placeholders. // Nothing here is replayed. The engine does the task through // the W3BS Agentic Desktop Layer (MCP server "w3bs-desktop"), looking at the screen // before every action and asking you before anything it cannot undo. One-time setup: // w3bs desktop agents add claude-code --preset broad // w3bs desktop setup claude-code --agent claude-code // Enable the layer from the tray before running. const task = { "type": "logicsrc.opentask", "version": "0.1", "id": "connect-claude-code-to-w3bs-training-qgajo2", "title": "Connect Claude Code to W3BS Training", "goal": "Add the W3BS Training MCP server to Claude Code so it can look up your recorded tasks.", "explanation": "Open the training app, copy the setup command from your notes, and run it in the terminal.", "apps": [ { "name": "TronBrowser", "kind": "browser" }, { "name": "Sublime Text", "kind": "desktop" }, { "name": "hqterm", "kind": "terminal" } ], "steps": [ { "n": 1, "action": "focus", "app": "TronBrowser", "target": { "role": "page", "name": "W3BS Training" }, "evidence": "observed" }, { "n": 2, "action": "focus", "app": "Sublime Text", "note": "Copy the claude mcp add command from your notes.", "evidence": "observed" }, { "n": 3, "action": "focus", "app": "hqterm", "evidence": "observed" }, { "n": 4, "action": "type", "app": "hqterm", "text": "{{setup_command}}", "evidence": "inferred" }, { "n": 5, "action": "key", "app": "hqterm", "keys": [ "enter" ], "evidence": "inferred" } ], "capture": { "profile": "visual-review", "window_titles": "removed", "gaps": [] }, "stop_conditions": [ "a target cannot be found on the current screen", "an unexpected dialog appears", "a credential or payment prompt appears" ], "approvals": [ "before running a command in the terminal" ], "success": { "check": "claude mcp list shows w3bs-training.", "evidence": "screen" }, "source": { "kind": "demonstration", "recorder": "w3bs-training 0.2.6", "episode": "ep_36773bc43575d95f", "reviewed": true, "outcome": "success" }, "status": "untested", "parameters": [ { "name": "setup_command", "description": "The command that adds the MCP server", "sensitivity": "public", "example": "claude mcp add w3bs-training -- w3bs training mcp serve --stdio --consumer claude-code" } ] }; const engine = (argv[0] || "claude").toLowerCase(); const apps = task.apps.map((a) => a.name); const gaps = (task.capture && task.capture.gaps) || []; say(`🎸 ${task.goal}`); say(` ${task.steps.length} step(s) across ${apps.join(", ") || "the desktop"}`); const describe = (s) => [ s.action, s.app, s.window && `(window: ${s.window})`, s.target && `[${[s.target.role, s.target.name].filter(Boolean).join(" ")}]`, s.keys && `keys ${s.keys.join("+")}`, s.text && `text ${s.text}`, s.note && `(${s.note})`, ] .filter(Boolean) .join(" "); for (const s of task.steps) say(` ${s.n}. ${describe(s)}`); const prompt = [ `Do this task on my desktop: ${task.goal}`, task.explanation ? `In my words: ${task.explanation}` : "", "", `I recorded it once with W3BS Training. The recording holds semantic steps (app, control, shortcut): no coordinates, and typed text only as placeholders,`, "so work out each action from what is on screen. The steps I took:", ...task.steps.map((s) => `${s.n}. ${describe(s)}`), (task.parameters || []).length ? `Text in {{braces}} is a value you must ask me for: ${task.parameters.map((p) => p.name).join(", ")}.` : "", gaps.length ? `Parts were not captured (${gaps.join(", ")}); do not guess what happened there, ask me.` : "", "", "Use the w3bs-desktop MCP tools. Observe the screen before every action and never reuse old", "coordinates.", task.source && task.source.episode ? `If the w3bs-training MCP is connected, training_get_frames with episode_id ${task.source.episode} shows the screenshots I recorded.` : "", `Stop and tell me if: ${task.stop_conditions.join("; ")}.`, task.approvals.length ? `Ask me ${task.approvals.join("; ")}.` : "", `It worked when: ${task.success.check}`, "When you finish or stop, say what you did and what is left, and report it with", "training_report_run if that tool is available.", ] .filter((l, i, all) => l !== "" || all[i - 1] !== "") .join("\n"); const quote = (s) => `'${String(s).replace(/'/g, `'\\''`)}'`; if (!shell("command -v w3bs >/dev/null 2>&1").ok) { say("w3bs is not installed: curl -fsSL https://w3bs.org/install.sh | sh, then the setup lines at the top of this file."); } else if (engine === "claude" || engine === "codex") { // Interactive, so you see and approve each desktop action as it happens. shell(`${engine} ${quote(prompt)}`); } else { say(await ai(prompt, { engine })); }