tandem-editor 0.2.2 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli/index.js CHANGED
@@ -154,8 +154,8 @@ function buildMcpEntries(channelPath) {
154
154
  function detectTargets(opts = {}) {
155
155
  const home = opts.homeOverride ?? homedir();
156
156
  const targets = [];
157
- const claudeCodeConfig = join(home, ".claude", "mcp_settings.json");
158
- const claudeCodeDir = dirname(claudeCodeConfig);
157
+ const claudeCodeConfig = join(home, ".claude.json");
158
+ const claudeCodeDir = join(home, ".claude");
159
159
  if (opts.force || existsSync(claudeCodeConfig) || existsSync(claudeCodeDir)) {
160
160
  targets.push({ label: "Claude Code", configPath: claudeCodeConfig });
161
161
  }
@@ -337,7 +337,7 @@ var init_start = __esm({
337
337
 
338
338
  // src/cli/index.ts
339
339
  import updateNotifier from "update-notifier";
340
- var version = true ? "0.2.2" : "0.0.0-dev";
340
+ var version = true ? "0.2.4" : "0.0.0-dev";
341
341
  updateNotifier({ pkg: { name: "tandem-editor", version } }).notify();
342
342
  var args = process.argv.slice(2);
343
343
  if (args.includes("--help") || args.includes("-h")) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/shared/constants.ts","../../src/cli/skill-content.ts","../../src/cli/setup.ts","../../src/cli/start.ts","../../src/cli/index.ts"],"sourcesContent":["export const DEFAULT_WS_PORT = 3478;\r\nexport const DEFAULT_MCP_PORT = 3479;\r\n\r\n/** File extensions the server accepts for opening. */\r\nexport const SUPPORTED_EXTENSIONS = new Set([\".md\", \".txt\", \".html\", \".htm\", \".docx\"]);\r\nexport const MAX_FILE_SIZE = 50 * 1024 * 1024; // 50MB\r\nexport const MAX_WS_PAYLOAD = 10 * 1024 * 1024; // 10MB\r\nexport const MAX_WS_CONNECTIONS = 4;\r\nexport const IDLE_TIMEOUT = 30 * 60 * 1000; // 30 minutes\r\nexport const SESSION_MAX_AGE = 30 * 24 * 60 * 60 * 1000; // 30 days\r\nexport const TYPING_DEBOUNCE = 3000; // 3 seconds\r\nexport const DISCONNECT_DEBOUNCE_MS = 3000; // 3 seconds before showing \"server not reachable\"\r\nexport const PROLONGED_DISCONNECT_MS = 30_000; // 30 seconds before showing App-level disconnect banner\r\nexport const OVERLAY_STALE_DEBOUNCE = 200; // 200ms\r\nexport const REVIEW_BANNER_THRESHOLD = 5;\r\n\r\nexport const HIGHLIGHT_COLORS: Record<string, string> = {\r\n yellow: \"rgba(255, 235, 59, 0.3)\",\r\n red: \"rgba(244, 67, 54, 0.3)\",\r\n green: \"rgba(76, 175, 80, 0.3)\",\r\n blue: \"rgba(33, 150, 243, 0.3)\",\r\n purple: \"rgba(156, 39, 176, 0.3)\",\r\n};\r\n\r\nexport const INTERRUPTION_MODE_DEFAULT = \"all\" as const;\r\nexport const INTERRUPTION_MODE_KEY = \"tandem:interruptionMode\";\r\n\r\n// Large file thresholds\r\nexport const CHARS_PER_PAGE = 3_000;\r\nexport const LARGE_FILE_PAGE_THRESHOLD = 50;\r\nexport const VERY_LARGE_FILE_PAGE_THRESHOLD = 100;\r\n\r\nexport const CLAUDE_PRESENCE_COLOR = \"#6366f1\";\r\nexport const CLAUDE_FOCUS_OPACITY = 0.1;\r\n\r\nexport const CTRL_ROOM = \"__tandem_ctrl__\";\r\n\r\n/** Y.Map key constants — centralized to prevent silent bugs from string typos. */\r\nexport const Y_MAP_ANNOTATIONS = \"annotations\";\r\nexport const Y_MAP_AWARENESS = \"awareness\";\r\nexport const Y_MAP_USER_AWARENESS = \"userAwareness\";\r\nexport const Y_MAP_CHAT = \"chat\";\r\nexport const Y_MAP_DOCUMENT_META = \"documentMeta\";\r\nexport const Y_MAP_SAVED_AT_VERSION = \"savedAtVersion\";\r\n\r\nexport const SERVER_INFO_DIR = \".tandem\";\r\nexport const SERVER_INFO_FILE = \".tandem/.server-info\";\r\n\r\nexport const RECENT_FILES_KEY = \"tandem:recentFiles\";\r\nexport const RECENT_FILES_CAP = 20;\r\n\r\nexport const USER_NAME_KEY = \"tandem:userName\";\r\nexport const USER_NAME_DEFAULT = \"You\";\r\n\r\n// Toast notifications\r\nexport const TOAST_DISMISS_MS = { error: 8000, warning: 6000, info: 4000 } as const;\r\nexport const MAX_VISIBLE_TOASTS = 5;\r\nexport const NOTIFICATION_BUFFER_SIZE = 50;\r\n\r\n// Onboarding tutorial\r\nexport const TUTORIAL_COMPLETED_KEY = \"tandem:tutorialCompleted\";\r\nexport const TUTORIAL_ANNOTATION_PREFIX = \"tutorial-\";\r\n\r\n// Channel / event queue\r\nexport const CHANNEL_EVENT_BUFFER_SIZE = 200;\r\nexport const CHANNEL_EVENT_BUFFER_AGE_MS = 60_000; // 60 seconds\r\nexport const CHANNEL_SSE_KEEPALIVE_MS = 15_000; // 15 seconds\r\nexport const CHANNEL_MAX_RETRIES = 5;\r\nexport const CHANNEL_RETRY_DELAY_MS = 2_000;\r\n","/**\r\n * SKILL.md content installed to ~/.claude/skills/tandem/ by `tandem setup`.\r\n * Claude Code auto-discovers this and uses it when tandem_* tools are present.\r\n */\r\nexport const SKILL_CONTENT = `---\r\nname: tandem\r\ndescription: >\r\n Use when tandem_* MCP tools are available, the user asks about Tandem\r\n document editing, or collaborative document review. Provides workflow\r\n guidance, annotation strategy, and tool usage patterns for the Tandem\r\n collaborative editor.\r\n---\r\n\r\n# Tandem — Collaborative Document Editor\r\n\r\nTandem lets you annotate and edit documents alongside the user in real time. The user sees your changes in a browser editor; you interact via 28 tandem_* MCP tools.\r\n\r\n## Hard Rules\r\n\r\nThese prevent the most common failures. Follow them always.\r\n\r\n1. **Resolve before mutating.** Call \\`tandem_resolveRange\\` (or \\`tandem_search\\`) to get offsets before calling \\`tandem_edit\\`, \\`tandem_highlight\\`, \\`tandem_comment\\`, \\`tandem_suggest\\`, or \\`tandem_flag\\`. Never compute offsets by counting characters in previously-read text — they go stale when the user edits.\r\n2. **Pass \\`textSnapshot\\`.** Include the matched text as \\`textSnapshot\\` on mutations and annotations. If the text moved, the server returns \\`RANGE_MOVED\\` with relocated coordinates instead of corrupting the document.\r\n3. **Use \\`tandem_getTextContent\\`, not \\`tandem_getContent\\`.** \\`getContent\\` returns ProseMirror JSON and burns tokens. Use \\`getTextContent({ section: \"Section Name\" })\\` for targeted reads. The \\`section\\` parameter is case-insensitive.\r\n4. **\\`tandem_edit\\` cannot create paragraphs.** Newlines become literal characters. For multi-paragraph changes, use multiple \\`tandem_edit\\` calls or \\`tandem_suggest\\`.\r\n5. **\\`.docx\\` files are read-only.** Use annotations instead of \\`tandem_edit\\`. Offer \\`tandem_convertToMarkdown\\` if the user wants an editable copy.\r\n\r\n## Workflow\r\n\r\nStandard review sequence:\r\n\r\n1. \\`tandem_status\\` — check for already-open documents (sessions restore automatically)\r\n2. \\`tandem_getOutline\\` — understand document structure\r\n3. \\`tandem_setStatus(\"Reviewing [section]...\", { focusParagraph: N })\\` — show progress (use \\`index\\` from outline)\r\n4. \\`tandem_getTextContent({ section: \"...\" })\\` — read one section at a time\r\n5. Annotate findings (see annotation guide below)\r\n6. \\`tandem_checkInbox\\` — check for user messages and actions\r\n7. Repeat steps 3-6 for each section\r\n8. \\`tandem_save\\` — persist edits to disk when done\r\n\r\n## Annotation Guide\r\n\r\nChoose the right type for each finding:\r\n\r\n- **\\`tandem_highlight\\`** — Visual marker with a short note. Colors: green (verified/good), red (problem), yellow (needs attention). Use when the finding is self-evident from the color and a brief note.\r\n- **\\`tandem_comment\\`** — Observation requiring explanation. Use when you need more than one sentence to convey reasoning.\r\n- **\\`tandem_suggest\\`** — Specific text replacement. **Prefer over comment when you can provide replacement text** — the user gets one-click accept/reject. Cannot create new paragraphs.\r\n- **\\`tandem_flag\\`** — Blocking issue the user must address before the document ships. Factual errors, compliance risks, missing required content. Always visible in urgent-only interruption mode.\r\n\r\n**Priority:** Set \\`priority: 'urgent'\\` on any annotation type when the finding is critical and the user may be in urgent-only mode.\r\n\r\n**User-created types:** \\`question\\` and \\`overlay\\` annotations are created by users, not Claude. When you see a \\`question\\` in \\`tandem_checkInbox\\` or \\`tandem_getAnnotations\\`, respond with a \\`tandem_comment\\` on the same range or \\`tandem_reply\\` for conversational answers.\r\n\r\n## Interruption Modes\r\n\r\nCheck \\`interruptionMode\\` from \\`tandem_status\\` or \\`tandem_checkInbox\\` and adapt:\r\n\r\n- **All** (default) — Annotate freely.\r\n- **Urgent-only** (\\`\"urgent-only\"\\`) — Only create \\`tandem_flag\\` and annotations with \\`priority: 'urgent'\\`. Continue reading and preparing findings, but hold non-urgent annotations until the mode changes.\r\n- **Paused** — Hold all new annotations. Keep working (read, outline, prepare) but don't push findings until the mode changes.\r\n\r\n## Collaboration Etiquette\r\n\r\n- Check \\`tandem_getActivity()\\` before annotating near the user's cursor. If \\`isTyping\\` is true, wait for typing to stop before annotating that area.\r\n- Use \\`tandem_setStatus\\` to show what you're working on — the user sees it in the browser status bar.\r\n- **Call \\`tandem_checkInbox\\` every 2-3 tool calls**, not just at the end of a task. The real-time channel is often not connected; polling is the reliable path.\r\n- Reply to chat messages with \\`tandem_reply\\`, not annotations.\r\n\r\n## .docx Review Workflow\r\n\r\n1. \\`tandem_open\\` — opens in read-only mode (\\`readOnly: true\\`)\r\n2. \\`tandem_getAnnotations({ author: \"import\" })\\` — check for imported Word comments; read and act on them\r\n3. Annotate with findings (highlight, comment, suggest, flag)\r\n4. \\`tandem_exportAnnotations\\` — generate a review summary the user can share\r\n5. If the user wants editable text, offer \\`tandem_convertToMarkdown\\`\r\n\r\n## Error Recovery\r\n\r\n- **\\`RANGE_MOVED\\`** — Text shifted since you read it. The response includes \\`resolvedFrom\\`/\\`resolvedTo\\` — use those coordinates for your next call.\r\n- **\\`RANGE_GONE\\`** — The text was deleted. Re-read the section with \\`tandem_getTextContent\\` and re-assess.\r\n- **\\`INVALID_RANGE\\`** — You hit heading markup (e.g., \\`## \\`). Target text content only, not the heading prefix.\r\n- **\\`FORMAT_ERROR\\`** — Attempted \\`tandem_edit\\` on a read-only \\`.docx\\`. Use annotations instead.\r\n\r\n## Session Handoff\r\n\r\nWhen starting a new Claude session with Tandem already running:\r\n\r\n1. \\`tandem_status()\\` — check \\`openDocuments\\` array for restored sessions\r\n2. \\`tandem_listDocuments()\\` — see all open docs with details\r\n3. \\`tandem_getOutline()\\` — orient on the active document\r\n4. \\`tandem_getAnnotations()\\` — see what was already reviewed\r\n5. Continue where the previous session left off\r\n\r\n## Multi-Document\r\n\r\nWhen multiple documents are open, always pass \\`documentId\\` explicitly — omitting it targets the active document, which may have changed since your last call. Use \\`tandem_listDocuments\\` to see what's available. Cross-reference by reading both docs via \\`tandem_getTextContent({ documentId: \"...\" })\\` and annotating the relevant one.\r\n`;\r\n","import { readFileSync, existsSync } from \"node:fs\";\r\nimport { writeFile, rename, copyFile, unlink, mkdir } from \"node:fs/promises\";\r\nimport { homedir } from \"node:os\";\r\nimport { join, dirname, resolve } from \"node:path\";\r\nimport { fileURLToPath } from \"node:url\";\r\nimport { randomUUID } from \"node:crypto\";\r\nimport { DEFAULT_MCP_PORT } from \"../shared/constants.js\";\r\nimport { SKILL_CONTENT } from \"./skill-content.js\";\r\n\r\nconst __dirname = dirname(fileURLToPath(import.meta.url));\r\n\r\n// Absolute path to dist/channel/index.js (sibling of dist/cli/)\r\nconst CHANNEL_DIST = resolve(__dirname, \"../channel/index.js\");\r\n\r\nconst MCP_URL = `http://localhost:${DEFAULT_MCP_PORT}`;\r\n\r\nexport interface McpEntry {\r\n type?: \"http\";\r\n url?: string;\r\n command?: string;\r\n args?: string[];\r\n env?: Record<string, string>;\r\n}\r\n\r\nexport interface McpEntries {\r\n tandem: McpEntry;\r\n \"tandem-channel\": McpEntry;\r\n}\r\n\r\nexport function buildMcpEntries(channelPath: string): McpEntries {\r\n return {\r\n tandem: {\r\n type: \"http\",\r\n url: `${MCP_URL}/mcp`,\r\n },\r\n \"tandem-channel\": {\r\n command: \"node\",\r\n args: [channelPath],\r\n env: { TANDEM_URL: MCP_URL },\r\n },\r\n };\r\n}\r\n\r\nexport interface DetectedTarget {\r\n label: string;\r\n configPath: string;\r\n}\r\n\r\ninterface DetectOptions {\r\n homeOverride?: string;\r\n force?: boolean;\r\n}\r\n\r\nexport function detectTargets(opts: DetectOptions = {}): DetectedTarget[] {\r\n const home = opts.homeOverride ?? homedir();\r\n const targets: DetectedTarget[] = [];\r\n\r\n // Claude Code — cross-platform.\r\n // Detect if the config file exists OR if ~/.claude directory exists\r\n // (Claude Code creates ~/.claude at install; mcp_settings.json may not exist yet).\r\n // With --force, always include regardless.\r\n const claudeCodeConfig = join(home, \".claude\", \"mcp_settings.json\");\r\n const claudeCodeDir = dirname(claudeCodeConfig);\r\n if (opts.force || existsSync(claudeCodeConfig) || existsSync(claudeCodeDir)) {\r\n targets.push({ label: \"Claude Code\", configPath: claudeCodeConfig });\r\n }\r\n\r\n // Claude Desktop — platform-specific.\r\n // Only detect if the config file already exists (user has launched Desktop at least once).\r\n // With --force, always include.\r\n let desktopConfig: string | null = null;\r\n if (process.platform === \"win32\") {\r\n const appdata = process.env.APPDATA ?? join(home, \"AppData\", \"Roaming\");\r\n desktopConfig = join(appdata, \"Claude\", \"claude_desktop_config.json\");\r\n } else if (process.platform === \"darwin\") {\r\n desktopConfig = join(\r\n home,\r\n \"Library\",\r\n \"Application Support\",\r\n \"Claude\",\r\n \"claude_desktop_config.json\",\r\n );\r\n } else {\r\n desktopConfig = join(home, \".config\", \"claude\", \"claude_desktop_config.json\");\r\n }\r\n\r\n if (desktopConfig && (opts.force || existsSync(desktopConfig))) {\r\n targets.push({ label: \"Claude Desktop\", configPath: desktopConfig });\r\n }\r\n\r\n return targets;\r\n}\r\n\r\n/**\r\n * Atomic write: write to a temp file in the SAME directory as the destination,\r\n * then rename. Using the same directory avoids EXDEV errors on Windows when\r\n * %TEMP% and %APPDATA% are on different drives.\r\n */\r\nasync function atomicWrite(content: string, dest: string): Promise<void> {\r\n const tmp = join(dirname(dest), `.tandem-setup-${randomUUID()}.tmp`);\r\n await writeFile(tmp, content, \"utf-8\");\r\n try {\r\n await rename(tmp, dest);\r\n } catch (err) {\r\n // EXDEV: cross-device link — fall back to copy + delete\r\n if ((err as NodeJS.ErrnoException).code === \"EXDEV\") {\r\n await copyFile(tmp, dest);\r\n await unlink(tmp).catch((cleanupErr: Error) => {\r\n console.error(` Warning: could not remove temp file ${tmp}: ${cleanupErr.message}`);\r\n });\r\n } else {\r\n await unlink(tmp).catch((cleanupErr: Error) => {\r\n console.error(` Warning: could not remove temp file ${tmp}: ${cleanupErr.message}`);\r\n });\r\n throw err;\r\n }\r\n }\r\n}\r\n\r\nexport async function applyConfig(configPath: string, entries: McpEntries): Promise<void> {\r\n // Read existing config or start fresh — no existsSync guard needed.\r\n // ENOENT and malformed JSON start fresh; other errors (permissions, disk) propagate.\r\n let existing: { mcpServers?: Record<string, McpEntry> } = {};\r\n try {\r\n existing = JSON.parse(readFileSync(configPath, \"utf-8\"));\r\n } catch (err) {\r\n const code = (err as NodeJS.ErrnoException).code;\r\n if (code === \"ENOENT\") {\r\n // File doesn't exist yet — start fresh\r\n } else if (err instanceof SyntaxError) {\r\n console.error(\r\n ` Warning: ${configPath} contains malformed JSON — replacing with fresh config`,\r\n );\r\n } else {\r\n throw err; // Permission errors, disk errors, etc. should not be silently swallowed\r\n }\r\n }\r\n\r\n const updated = {\r\n ...existing,\r\n mcpServers: {\r\n ...(existing.mcpServers ?? {}),\r\n ...entries,\r\n },\r\n };\r\n\r\n await mkdir(dirname(configPath), { recursive: true });\r\n await atomicWrite(JSON.stringify(updated, null, 2) + \"\\n\", configPath);\r\n}\r\n\r\n/**\r\n * Install the Tandem skill to ~/.claude/skills/tandem/SKILL.md.\r\n * Claude Code auto-discovers skills in this directory and uses the description\r\n * field to trigger them when tandem_* tools are present.\r\n */\r\nexport async function installSkill(opts: { homeOverride?: string } = {}): Promise<void> {\r\n const home = opts.homeOverride ?? homedir();\r\n const skillPath = join(home, \".claude\", \"skills\", \"tandem\", \"SKILL.md\");\r\n await mkdir(dirname(skillPath), { recursive: true });\r\n await atomicWrite(SKILL_CONTENT, skillPath);\r\n}\r\n\r\n/** Run the setup command. Writes MCP config to all detected Claude installs. */\r\nexport async function runSetup(opts: { force?: boolean } = {}): Promise<void> {\r\n console.error(\"\\nTandem Setup\\n\");\r\n console.error(\"Detecting Claude installations...\");\r\n\r\n const targets = detectTargets({ force: opts.force });\r\n\r\n if (targets.length === 0) {\r\n console.error(\r\n \" No Claude installations detected.\\n\" +\r\n \" If Claude Code is installed, ensure ~/.claude exists.\\n\" +\r\n \" You can force configuration to default paths with: tandem setup --force\",\r\n );\r\n return;\r\n }\r\n\r\n for (const t of targets) {\r\n console.error(` Found: ${t.label} (${t.configPath})`);\r\n }\r\n\r\n console.error(\"\\nWriting MCP configuration...\");\r\n const entries = buildMcpEntries(CHANNEL_DIST);\r\n\r\n let failures = 0;\r\n for (const t of targets) {\r\n try {\r\n await applyConfig(t.configPath, entries);\r\n console.error(` \\x1b[32m✓\\x1b[0m ${t.label}`);\r\n } catch (err) {\r\n failures++;\r\n console.error(\r\n ` \\x1b[31m✗\\x1b[0m ${t.label}: ${err instanceof Error ? err.message : String(err)}`,\r\n );\r\n }\r\n }\r\n\r\n if (failures === targets.length) {\r\n console.error(\"\\nSetup failed — could not write any configuration. Check file permissions.\");\r\n process.exit(1);\r\n } else if (failures > 0) {\r\n console.error(\r\n `\\nSetup partially complete (${failures} target(s) failed). Start Tandem with: tandem`,\r\n );\r\n } else {\r\n console.error(\"\\nSetup complete! Start Tandem with: tandem\");\r\n console.error(\"Then in Claude, your tandem_* tools will be available.\");\r\n }\r\n\r\n // Install Claude Code skill (best-effort — doesn't block MCP setup)\r\n console.error(\"\\nInstalling Claude Code skill...\");\r\n try {\r\n await installSkill();\r\n console.error(\" \\x1b[32m✓\\x1b[0m ~/.claude/skills/tandem/SKILL.md\");\r\n } catch (err) {\r\n console.error(\r\n ` \\x1b[33m⚠\\x1b[0m Could not install skill: ${err instanceof Error ? err.message : String(err)}`,\r\n );\r\n }\r\n\r\n // Channel activation instructions (shown on all successful setups)\r\n if (failures < targets.length) {\r\n console.error(\r\n \"\\n\\x1b[1mReal-time push notifications (optional):\\x1b[0m\\n\" +\r\n \" To receive chat messages and events instantly (instead of polling),\\n\" +\r\n \" start Claude Code with the channel flag:\\n\\n\" +\r\n \" claude --dangerously-load-development-channels server:tandem-channel\\n\\n\" +\r\n \" Without this flag, Claude still works but relies on tandem_checkInbox polling.\\n\",\r\n );\r\n }\r\n}\r\n","import { spawn } from \"node:child_process\";\r\nimport { existsSync } from \"node:fs\";\r\nimport { dirname, resolve } from \"node:path\";\r\nimport { fileURLToPath } from \"node:url\";\r\n\r\nconst __dirname = dirname(fileURLToPath(import.meta.url));\r\nconst SERVER_DIST = resolve(__dirname, \"../server/index.js\");\r\n\r\nexport function runStart(): void {\r\n if (!existsSync(SERVER_DIST)) {\r\n console.error(`[Tandem] Server not found at ${SERVER_DIST}`);\r\n console.error(\"[Tandem] The installation may be corrupted. Try: npm install -g tandem-editor\");\r\n process.exit(1);\r\n }\r\n\r\n console.error(\"[Tandem] Starting server...\");\r\n\r\n const proc = spawn(\"node\", [SERVER_DIST], {\r\n stdio: \"inherit\",\r\n env: { ...process.env, TANDEM_OPEN_BROWSER: \"1\" },\r\n });\r\n\r\n proc.on(\"error\", (err) => {\r\n console.error(`[Tandem] Failed to start server: ${err.message}`);\r\n process.exit(1);\r\n });\r\n\r\n proc.on(\"exit\", (code) => {\r\n process.exit(code ?? 0);\r\n });\r\n\r\n // Forward signals — proc.kill() with no argument uses SIGTERM on Unix\r\n // and TerminateProcess on Windows (correct cross-platform behavior).\r\n // On Windows SIGTERM is not emitted by the OS, but SIGINT (Ctrl+C) works.\r\n // Both are listed for Unix compatibility.\r\n for (const sig of [\"SIGINT\", \"SIGTERM\"] as const) {\r\n process.once(sig, () => proc.kill());\r\n }\r\n}\r\n","/**\r\n * Tandem CLI — entry point for the `tandem` global command.\r\n * Shebang is added by tsup banner at build time.\r\n *\r\n * Usage:\r\n * tandem Start the Tandem server and open the browser\r\n * tandem setup Register Tandem MCP tools with Claude Code / Claude Desktop\r\n * tandem setup --force Register even if no Claude install is auto-detected\r\n * tandem --help Show this help\r\n * tandem --version Show version\r\n */\r\n\r\nimport updateNotifier from \"update-notifier\";\r\n\r\n// Injected at build time by tsup define; declared here for TypeScript\r\ndeclare const __TANDEM_VERSION__: string;\r\nconst version = typeof __TANDEM_VERSION__ !== \"undefined\" ? __TANDEM_VERSION__ : \"0.0.0-dev\";\r\n\r\n// Check for updates in background (non-blocking, throttled to once/day)\r\nupdateNotifier({ pkg: { name: \"tandem-editor\", version } }).notify();\r\n\r\nconst args = process.argv.slice(2);\r\n\r\nif (args.includes(\"--help\") || args.includes(\"-h\")) {\r\n console.log(`tandem v${version}\r\n\r\nUsage:\r\n tandem Start Tandem server and open the browser\r\n tandem setup Register MCP tools with Claude Code / Claude Desktop\r\n tandem setup --force Register to default paths regardless of detection\r\n tandem --version\r\n tandem --help\r\n`);\r\n process.exit(0);\r\n}\r\n\r\nif (args.includes(\"--version\") || args.includes(\"-v\")) {\r\n console.log(version);\r\n process.exit(0);\r\n}\r\n\r\ntry {\r\n if (args[0] === \"setup\") {\r\n const { runSetup } = await import(\"./setup.js\");\r\n await runSetup({ force: args.includes(\"--force\") });\r\n } else if (!args[0] || args[0] === \"start\") {\r\n const { runStart } = await import(\"./start.js\");\r\n runStart();\r\n } else {\r\n console.error(`Unknown command: ${args[0]}`);\r\n console.error(\"Run 'tandem --help' for usage.\");\r\n process.exit(1);\r\n }\r\n} catch (err) {\r\n console.error(`\\n[Tandem] Fatal error: ${err instanceof Error ? err.message : String(err)}`);\r\n console.error(\"If this persists, try reinstalling: npm install -g tandem-editor\\n\");\r\n process.exit(1);\r\n}\r\n"],"mappings":";;;;;;;;;;;;AAAA,IACa,kBAIA,eACA,gBAEA,cACA;AATb;AAAA;AAAA;AACO,IAAM,mBAAmB;AAIzB,IAAM,gBAAgB,KAAK,OAAO;AAClC,IAAM,iBAAiB,KAAK,OAAO;AAEnC,IAAM,eAAe,KAAK,KAAK;AAC/B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ACnB,UAAQ,KAAK,CAAC;AAChB;AAEA,IAAI;AACF,MAAI,KAAK,CAAC,MAAM,SAAS;AACvB,UAAM,EAAE,UAAAC,UAAS,IAAI,MAAM;AAC3B,UAAMA,UAAS,EAAE,OAAO,KAAK,SAAS,SAAS,EAAE,CAAC;AAAA,EACpD,WAAW,CAAC,KAAK,CAAC,KAAK,KAAK,CAAC,MAAM,SAAS;AAC1C,UAAM,EAAE,UAAAC,UAAS,IAAI,MAAM;AAC3B,IAAAA,UAAS;AAAA,EACX,OAAO;AACL,YAAQ,MAAM,oBAAoB,KAAK,CAAC,CAAC,EAAE;AAC3C,YAAQ,MAAM,gCAAgC;AAC9C,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF,SAAS,KAAK;AACZ,UAAQ,MAAM;AAAA,wBAA2B,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,CAAC,EAAE;AAC3F,UAAQ,MAAM,oEAAoE;AAClF,UAAQ,KAAK,CAAC;AAChB;","names":["existsSync","dirname","resolve","fileURLToPath","__dirname","runSetup","runStart"]}
1
+ {"version":3,"sources":["../../src/shared/constants.ts","../../src/cli/skill-content.ts","../../src/cli/setup.ts","../../src/cli/start.ts","../../src/cli/index.ts"],"sourcesContent":["export const DEFAULT_WS_PORT = 3478;\r\nexport const DEFAULT_MCP_PORT = 3479;\r\n\r\n/** File extensions the server accepts for opening. */\r\nexport const SUPPORTED_EXTENSIONS = new Set([\".md\", \".txt\", \".html\", \".htm\", \".docx\"]);\r\nexport const MAX_FILE_SIZE = 50 * 1024 * 1024; // 50MB\r\nexport const MAX_WS_PAYLOAD = 10 * 1024 * 1024; // 10MB\r\nexport const MAX_WS_CONNECTIONS = 4;\r\nexport const IDLE_TIMEOUT = 30 * 60 * 1000; // 30 minutes\r\nexport const SESSION_MAX_AGE = 30 * 24 * 60 * 60 * 1000; // 30 days\r\nexport const TYPING_DEBOUNCE = 3000; // 3 seconds\r\nexport const DISCONNECT_DEBOUNCE_MS = 3000; // 3 seconds before showing \"server not reachable\"\r\nexport const PROLONGED_DISCONNECT_MS = 30_000; // 30 seconds before showing App-level disconnect banner\r\nexport const OVERLAY_STALE_DEBOUNCE = 200; // 200ms\r\nexport const REVIEW_BANNER_THRESHOLD = 5;\r\n\r\nexport const HIGHLIGHT_COLORS: Record<string, string> = {\r\n yellow: \"rgba(255, 235, 59, 0.3)\",\r\n red: \"rgba(244, 67, 54, 0.3)\",\r\n green: \"rgba(76, 175, 80, 0.3)\",\r\n blue: \"rgba(33, 150, 243, 0.3)\",\r\n purple: \"rgba(156, 39, 176, 0.3)\",\r\n};\r\n\r\nexport const INTERRUPTION_MODE_DEFAULT = \"all\" as const;\r\nexport const INTERRUPTION_MODE_KEY = \"tandem:interruptionMode\";\r\n\r\n// Large file thresholds\r\nexport const CHARS_PER_PAGE = 3_000;\r\nexport const LARGE_FILE_PAGE_THRESHOLD = 50;\r\nexport const VERY_LARGE_FILE_PAGE_THRESHOLD = 100;\r\n\r\nexport const CLAUDE_PRESENCE_COLOR = \"#6366f1\";\r\nexport const CLAUDE_FOCUS_OPACITY = 0.1;\r\n\r\nexport const CTRL_ROOM = \"__tandem_ctrl__\";\r\n\r\n/** Y.Map key constants — centralized to prevent silent bugs from string typos. */\r\nexport const Y_MAP_ANNOTATIONS = \"annotations\";\r\nexport const Y_MAP_AWARENESS = \"awareness\";\r\nexport const Y_MAP_USER_AWARENESS = \"userAwareness\";\r\nexport const Y_MAP_CHAT = \"chat\";\r\nexport const Y_MAP_DOCUMENT_META = \"documentMeta\";\r\nexport const Y_MAP_SAVED_AT_VERSION = \"savedAtVersion\";\r\n\r\nexport const SERVER_INFO_DIR = \".tandem\";\r\nexport const SERVER_INFO_FILE = \".tandem/.server-info\";\r\n\r\nexport const RECENT_FILES_KEY = \"tandem:recentFiles\";\r\nexport const RECENT_FILES_CAP = 20;\r\n\r\nexport const USER_NAME_KEY = \"tandem:userName\";\r\nexport const USER_NAME_DEFAULT = \"You\";\r\n\r\n// Toast notifications\r\nexport const TOAST_DISMISS_MS = { error: 8000, warning: 6000, info: 4000 } as const;\r\nexport const MAX_VISIBLE_TOASTS = 5;\r\nexport const NOTIFICATION_BUFFER_SIZE = 50;\r\n\r\n// Onboarding tutorial\r\nexport const TUTORIAL_COMPLETED_KEY = \"tandem:tutorialCompleted\";\r\nexport const TUTORIAL_ANNOTATION_PREFIX = \"tutorial-\";\r\n\r\n// Channel / event queue\r\nexport const CHANNEL_EVENT_BUFFER_SIZE = 200;\r\nexport const CHANNEL_EVENT_BUFFER_AGE_MS = 60_000; // 60 seconds\r\nexport const CHANNEL_SSE_KEEPALIVE_MS = 15_000; // 15 seconds\r\nexport const CHANNEL_MAX_RETRIES = 5;\r\nexport const CHANNEL_RETRY_DELAY_MS = 2_000;\r\n","/**\r\n * SKILL.md content installed to ~/.claude/skills/tandem/ by `tandem setup`.\r\n * Claude Code auto-discovers this and uses it when tandem_* tools are present.\r\n */\r\nexport const SKILL_CONTENT = `---\r\nname: tandem\r\ndescription: >\r\n Use when tandem_* MCP tools are available, the user asks about Tandem\r\n document editing, or collaborative document review. Provides workflow\r\n guidance, annotation strategy, and tool usage patterns for the Tandem\r\n collaborative editor.\r\n---\r\n\r\n# Tandem — Collaborative Document Editor\r\n\r\nTandem lets you annotate and edit documents alongside the user in real time. The user sees your changes in a browser editor; you interact via 28 tandem_* MCP tools.\r\n\r\n## Hard Rules\r\n\r\nThese prevent the most common failures. Follow them always.\r\n\r\n1. **Resolve before mutating.** Call \\`tandem_resolveRange\\` (or \\`tandem_search\\`) to get offsets before calling \\`tandem_edit\\`, \\`tandem_highlight\\`, \\`tandem_comment\\`, \\`tandem_suggest\\`, or \\`tandem_flag\\`. Never compute offsets by counting characters in previously-read text — they go stale when the user edits.\r\n2. **Pass \\`textSnapshot\\`.** Include the matched text as \\`textSnapshot\\` on mutations and annotations. If the text moved, the server returns \\`RANGE_MOVED\\` with relocated coordinates instead of corrupting the document.\r\n3. **Use \\`tandem_getTextContent\\`, not \\`tandem_getContent\\`.** \\`getContent\\` returns ProseMirror JSON and burns tokens. Use \\`getTextContent({ section: \"Section Name\" })\\` for targeted reads. The \\`section\\` parameter is case-insensitive.\r\n4. **\\`tandem_edit\\` cannot create paragraphs.** Newlines become literal characters. For multi-paragraph changes, use multiple \\`tandem_edit\\` calls or \\`tandem_suggest\\`.\r\n5. **\\`.docx\\` files are read-only.** Use annotations instead of \\`tandem_edit\\`. Offer \\`tandem_convertToMarkdown\\` if the user wants an editable copy.\r\n\r\n## Workflow\r\n\r\nStandard review sequence:\r\n\r\n1. \\`tandem_status\\` — check for already-open documents (sessions restore automatically)\r\n2. \\`tandem_getOutline\\` — understand document structure\r\n3. \\`tandem_setStatus(\"Reviewing [section]...\", { focusParagraph: N })\\` — show progress (use \\`index\\` from outline)\r\n4. \\`tandem_getTextContent({ section: \"...\" })\\` — read one section at a time\r\n5. Annotate findings (see annotation guide below)\r\n6. \\`tandem_checkInbox\\` — check for user messages and actions\r\n7. Repeat steps 3-6 for each section\r\n8. \\`tandem_save\\` — persist edits to disk when done\r\n\r\n## Annotation Guide\r\n\r\nChoose the right type for each finding:\r\n\r\n- **\\`tandem_highlight\\`** — Visual marker with a short note. Colors: green (verified/good), red (problem), yellow (needs attention). Use when the finding is self-evident from the color and a brief note.\r\n- **\\`tandem_comment\\`** — Observation requiring explanation. Use when you need more than one sentence to convey reasoning.\r\n- **\\`tandem_suggest\\`** — Specific text replacement. **Prefer over comment when you can provide replacement text** — the user gets one-click accept/reject. Cannot create new paragraphs.\r\n- **\\`tandem_flag\\`** — Blocking issue the user must address before the document ships. Factual errors, compliance risks, missing required content. Always visible in urgent-only interruption mode.\r\n\r\n**Priority:** Set \\`priority: 'urgent'\\` on any annotation type when the finding is critical and the user may be in urgent-only mode.\r\n\r\n**User-created types:** \\`question\\` and \\`overlay\\` annotations are created by users, not Claude. When you see a \\`question\\` in \\`tandem_checkInbox\\` or \\`tandem_getAnnotations\\`, respond with a \\`tandem_comment\\` on the same range or \\`tandem_reply\\` for conversational answers.\r\n\r\n## Interruption Modes\r\n\r\nCheck \\`interruptionMode\\` from \\`tandem_status\\` or \\`tandem_checkInbox\\` and adapt:\r\n\r\n- **All** (default) — Annotate freely.\r\n- **Urgent-only** (\\`\"urgent-only\"\\`) — Only create \\`tandem_flag\\` and annotations with \\`priority: 'urgent'\\`. Continue reading and preparing findings, but hold non-urgent annotations until the mode changes.\r\n- **Paused** — Hold all new annotations. Keep working (read, outline, prepare) but don't push findings until the mode changes.\r\n\r\n## Collaboration Etiquette\r\n\r\n- Check \\`tandem_getActivity()\\` before annotating near the user's cursor. If \\`isTyping\\` is true, wait for typing to stop before annotating that area.\r\n- Use \\`tandem_setStatus\\` to show what you're working on — the user sees it in the browser status bar.\r\n- **Call \\`tandem_checkInbox\\` every 2-3 tool calls**, not just at the end of a task. The real-time channel is often not connected; polling is the reliable path.\r\n- Reply to chat messages with \\`tandem_reply\\`, not annotations.\r\n\r\n## .docx Review Workflow\r\n\r\n1. \\`tandem_open\\` — opens in read-only mode (\\`readOnly: true\\`)\r\n2. \\`tandem_getAnnotations({ author: \"import\" })\\` — check for imported Word comments; read and act on them\r\n3. Annotate with findings (highlight, comment, suggest, flag)\r\n4. \\`tandem_exportAnnotations\\` — generate a review summary the user can share\r\n5. If the user wants editable text, offer \\`tandem_convertToMarkdown\\`\r\n\r\n## Error Recovery\r\n\r\n- **\\`RANGE_MOVED\\`** — Text shifted since you read it. The response includes \\`resolvedFrom\\`/\\`resolvedTo\\` — use those coordinates for your next call.\r\n- **\\`RANGE_GONE\\`** — The text was deleted. Re-read the section with \\`tandem_getTextContent\\` and re-assess.\r\n- **\\`INVALID_RANGE\\`** — You hit heading markup (e.g., \\`## \\`). Target text content only, not the heading prefix.\r\n- **\\`FORMAT_ERROR\\`** — Attempted \\`tandem_edit\\` on a read-only \\`.docx\\`. Use annotations instead.\r\n\r\n## Session Handoff\r\n\r\nWhen starting a new Claude session with Tandem already running:\r\n\r\n1. \\`tandem_status()\\` — check \\`openDocuments\\` array for restored sessions\r\n2. \\`tandem_listDocuments()\\` — see all open docs with details\r\n3. \\`tandem_getOutline()\\` — orient on the active document\r\n4. \\`tandem_getAnnotations()\\` — see what was already reviewed\r\n5. Continue where the previous session left off\r\n\r\n## Multi-Document\r\n\r\nWhen multiple documents are open, always pass \\`documentId\\` explicitly — omitting it targets the active document, which may have changed since your last call. Use \\`tandem_listDocuments\\` to see what's available. Cross-reference by reading both docs via \\`tandem_getTextContent({ documentId: \"...\" })\\` and annotating the relevant one.\r\n`;\r\n","import { readFileSync, existsSync } from \"node:fs\";\r\nimport { writeFile, rename, copyFile, unlink, mkdir } from \"node:fs/promises\";\r\nimport { homedir } from \"node:os\";\r\nimport { join, dirname, resolve } from \"node:path\";\r\nimport { fileURLToPath } from \"node:url\";\r\nimport { randomUUID } from \"node:crypto\";\r\nimport { DEFAULT_MCP_PORT } from \"../shared/constants.js\";\r\nimport { SKILL_CONTENT } from \"./skill-content.js\";\r\n\r\nconst __dirname = dirname(fileURLToPath(import.meta.url));\r\n\r\n// Absolute path to dist/channel/index.js (sibling of dist/cli/)\r\nconst CHANNEL_DIST = resolve(__dirname, \"../channel/index.js\");\r\n\r\nconst MCP_URL = `http://localhost:${DEFAULT_MCP_PORT}`;\r\n\r\nexport interface McpEntry {\r\n type?: \"http\";\r\n url?: string;\r\n command?: string;\r\n args?: string[];\r\n env?: Record<string, string>;\r\n}\r\n\r\nexport interface McpEntries {\r\n tandem: McpEntry;\r\n \"tandem-channel\": McpEntry;\r\n}\r\n\r\nexport function buildMcpEntries(channelPath: string): McpEntries {\r\n return {\r\n tandem: {\r\n type: \"http\",\r\n url: `${MCP_URL}/mcp`,\r\n },\r\n \"tandem-channel\": {\r\n command: \"node\",\r\n args: [channelPath],\r\n env: { TANDEM_URL: MCP_URL },\r\n },\r\n };\r\n}\r\n\r\nexport interface DetectedTarget {\r\n label: string;\r\n configPath: string;\r\n}\r\n\r\ninterface DetectOptions {\r\n homeOverride?: string;\r\n force?: boolean;\r\n}\r\n\r\nexport function detectTargets(opts: DetectOptions = {}): DetectedTarget[] {\r\n const home = opts.homeOverride ?? homedir();\r\n const targets: DetectedTarget[] = [];\r\n\r\n // Claude Code — cross-platform.\r\n // MCP servers are configured in ~/.claude.json under the \"mcpServers\" key.\r\n // Detect if the file exists OR if ~/.claude directory exists (Claude Code is installed).\r\n // With --force, always include regardless.\r\n const claudeCodeConfig = join(home, \".claude.json\");\r\n const claudeCodeDir = join(home, \".claude\");\r\n if (opts.force || existsSync(claudeCodeConfig) || existsSync(claudeCodeDir)) {\r\n targets.push({ label: \"Claude Code\", configPath: claudeCodeConfig });\r\n }\r\n\r\n // Claude Desktop — platform-specific.\r\n // Only detect if the config file already exists (user has launched Desktop at least once).\r\n // With --force, always include.\r\n let desktopConfig: string | null = null;\r\n if (process.platform === \"win32\") {\r\n const appdata = process.env.APPDATA ?? join(home, \"AppData\", \"Roaming\");\r\n desktopConfig = join(appdata, \"Claude\", \"claude_desktop_config.json\");\r\n } else if (process.platform === \"darwin\") {\r\n desktopConfig = join(\r\n home,\r\n \"Library\",\r\n \"Application Support\",\r\n \"Claude\",\r\n \"claude_desktop_config.json\",\r\n );\r\n } else {\r\n desktopConfig = join(home, \".config\", \"claude\", \"claude_desktop_config.json\");\r\n }\r\n\r\n if (desktopConfig && (opts.force || existsSync(desktopConfig))) {\r\n targets.push({ label: \"Claude Desktop\", configPath: desktopConfig });\r\n }\r\n\r\n return targets;\r\n}\r\n\r\n/**\r\n * Atomic write: write to a temp file in the SAME directory as the destination,\r\n * then rename. Using the same directory avoids EXDEV errors on Windows when\r\n * %TEMP% and %APPDATA% are on different drives.\r\n */\r\nasync function atomicWrite(content: string, dest: string): Promise<void> {\r\n const tmp = join(dirname(dest), `.tandem-setup-${randomUUID()}.tmp`);\r\n await writeFile(tmp, content, \"utf-8\");\r\n try {\r\n await rename(tmp, dest);\r\n } catch (err) {\r\n // EXDEV: cross-device link — fall back to copy + delete\r\n if ((err as NodeJS.ErrnoException).code === \"EXDEV\") {\r\n await copyFile(tmp, dest);\r\n await unlink(tmp).catch((cleanupErr: Error) => {\r\n console.error(` Warning: could not remove temp file ${tmp}: ${cleanupErr.message}`);\r\n });\r\n } else {\r\n await unlink(tmp).catch((cleanupErr: Error) => {\r\n console.error(` Warning: could not remove temp file ${tmp}: ${cleanupErr.message}`);\r\n });\r\n throw err;\r\n }\r\n }\r\n}\r\n\r\nexport async function applyConfig(configPath: string, entries: McpEntries): Promise<void> {\r\n // Read existing config or start fresh — no existsSync guard needed.\r\n // ENOENT and malformed JSON start fresh; other errors (permissions, disk) propagate.\r\n let existing: { mcpServers?: Record<string, McpEntry> } = {};\r\n try {\r\n existing = JSON.parse(readFileSync(configPath, \"utf-8\"));\r\n } catch (err) {\r\n const code = (err as NodeJS.ErrnoException).code;\r\n if (code === \"ENOENT\") {\r\n // File doesn't exist yet — start fresh\r\n } else if (err instanceof SyntaxError) {\r\n console.error(\r\n ` Warning: ${configPath} contains malformed JSON — replacing with fresh config`,\r\n );\r\n } else {\r\n throw err; // Permission errors, disk errors, etc. should not be silently swallowed\r\n }\r\n }\r\n\r\n const updated = {\r\n ...existing,\r\n mcpServers: {\r\n ...(existing.mcpServers ?? {}),\r\n ...entries,\r\n },\r\n };\r\n\r\n await mkdir(dirname(configPath), { recursive: true });\r\n await atomicWrite(JSON.stringify(updated, null, 2) + \"\\n\", configPath);\r\n}\r\n\r\n/**\r\n * Install the Tandem skill to ~/.claude/skills/tandem/SKILL.md.\r\n * Claude Code auto-discovers skills in this directory and uses the description\r\n * field to trigger them when tandem_* tools are present.\r\n */\r\nexport async function installSkill(opts: { homeOverride?: string } = {}): Promise<void> {\r\n const home = opts.homeOverride ?? homedir();\r\n const skillPath = join(home, \".claude\", \"skills\", \"tandem\", \"SKILL.md\");\r\n await mkdir(dirname(skillPath), { recursive: true });\r\n await atomicWrite(SKILL_CONTENT, skillPath);\r\n}\r\n\r\n/** Run the setup command. Writes MCP config to all detected Claude installs. */\r\nexport async function runSetup(opts: { force?: boolean } = {}): Promise<void> {\r\n console.error(\"\\nTandem Setup\\n\");\r\n console.error(\"Detecting Claude installations...\");\r\n\r\n const targets = detectTargets({ force: opts.force });\r\n\r\n if (targets.length === 0) {\r\n console.error(\r\n \" No Claude installations detected.\\n\" +\r\n \" If Claude Code is installed, ensure ~/.claude exists.\\n\" +\r\n \" You can force configuration to default paths with: tandem setup --force\",\r\n );\r\n return;\r\n }\r\n\r\n for (const t of targets) {\r\n console.error(` Found: ${t.label} (${t.configPath})`);\r\n }\r\n\r\n console.error(\"\\nWriting MCP configuration...\");\r\n const entries = buildMcpEntries(CHANNEL_DIST);\r\n\r\n let failures = 0;\r\n for (const t of targets) {\r\n try {\r\n await applyConfig(t.configPath, entries);\r\n console.error(` \\x1b[32m✓\\x1b[0m ${t.label}`);\r\n } catch (err) {\r\n failures++;\r\n console.error(\r\n ` \\x1b[31m✗\\x1b[0m ${t.label}: ${err instanceof Error ? err.message : String(err)}`,\r\n );\r\n }\r\n }\r\n\r\n if (failures === targets.length) {\r\n console.error(\"\\nSetup failed — could not write any configuration. Check file permissions.\");\r\n process.exit(1);\r\n } else if (failures > 0) {\r\n console.error(\r\n `\\nSetup partially complete (${failures} target(s) failed). Start Tandem with: tandem`,\r\n );\r\n } else {\r\n console.error(\"\\nSetup complete! Start Tandem with: tandem\");\r\n console.error(\"Then in Claude, your tandem_* tools will be available.\");\r\n }\r\n\r\n // Install Claude Code skill (best-effort — doesn't block MCP setup)\r\n console.error(\"\\nInstalling Claude Code skill...\");\r\n try {\r\n await installSkill();\r\n console.error(\" \\x1b[32m✓\\x1b[0m ~/.claude/skills/tandem/SKILL.md\");\r\n } catch (err) {\r\n console.error(\r\n ` \\x1b[33m⚠\\x1b[0m Could not install skill: ${err instanceof Error ? err.message : String(err)}`,\r\n );\r\n }\r\n\r\n // Channel activation instructions (shown on all successful setups)\r\n if (failures < targets.length) {\r\n console.error(\r\n \"\\n\\x1b[1mReal-time push notifications (optional):\\x1b[0m\\n\" +\r\n \" To receive chat messages and events instantly (instead of polling),\\n\" +\r\n \" start Claude Code with the channel flag:\\n\\n\" +\r\n \" claude --dangerously-load-development-channels server:tandem-channel\\n\\n\" +\r\n \" Without this flag, Claude still works but relies on tandem_checkInbox polling.\\n\",\r\n );\r\n }\r\n}\r\n","import { spawn } from \"node:child_process\";\r\nimport { existsSync } from \"node:fs\";\r\nimport { dirname, resolve } from \"node:path\";\r\nimport { fileURLToPath } from \"node:url\";\r\n\r\nconst __dirname = dirname(fileURLToPath(import.meta.url));\r\nconst SERVER_DIST = resolve(__dirname, \"../server/index.js\");\r\n\r\nexport function runStart(): void {\r\n if (!existsSync(SERVER_DIST)) {\r\n console.error(`[Tandem] Server not found at ${SERVER_DIST}`);\r\n console.error(\"[Tandem] The installation may be corrupted. Try: npm install -g tandem-editor\");\r\n process.exit(1);\r\n }\r\n\r\n console.error(\"[Tandem] Starting server...\");\r\n\r\n const proc = spawn(\"node\", [SERVER_DIST], {\r\n stdio: \"inherit\",\r\n env: { ...process.env, TANDEM_OPEN_BROWSER: \"1\" },\r\n });\r\n\r\n proc.on(\"error\", (err) => {\r\n console.error(`[Tandem] Failed to start server: ${err.message}`);\r\n process.exit(1);\r\n });\r\n\r\n proc.on(\"exit\", (code) => {\r\n process.exit(code ?? 0);\r\n });\r\n\r\n // Forward signals — proc.kill() with no argument uses SIGTERM on Unix\r\n // and TerminateProcess on Windows (correct cross-platform behavior).\r\n // On Windows SIGTERM is not emitted by the OS, but SIGINT (Ctrl+C) works.\r\n // Both are listed for Unix compatibility.\r\n for (const sig of [\"SIGINT\", \"SIGTERM\"] as const) {\r\n process.once(sig, () => proc.kill());\r\n }\r\n}\r\n","/**\r\n * Tandem CLI — entry point for the `tandem` global command.\r\n * Shebang is added by tsup banner at build time.\r\n *\r\n * Usage:\r\n * tandem Start the Tandem server and open the browser\r\n * tandem setup Register Tandem MCP tools with Claude Code / Claude Desktop\r\n * tandem setup --force Register even if no Claude install is auto-detected\r\n * tandem --help Show this help\r\n * tandem --version Show version\r\n */\r\n\r\nimport updateNotifier from \"update-notifier\";\r\n\r\n// Injected at build time by tsup define; declared here for TypeScript\r\ndeclare const __TANDEM_VERSION__: string;\r\nconst version = typeof __TANDEM_VERSION__ !== \"undefined\" ? __TANDEM_VERSION__ : \"0.0.0-dev\";\r\n\r\n// Check for updates in background (non-blocking, throttled to once/day)\r\nupdateNotifier({ pkg: { name: \"tandem-editor\", version } }).notify();\r\n\r\nconst args = process.argv.slice(2);\r\n\r\nif (args.includes(\"--help\") || args.includes(\"-h\")) {\r\n console.log(`tandem v${version}\r\n\r\nUsage:\r\n tandem Start Tandem server and open the browser\r\n tandem setup Register MCP tools with Claude Code / Claude Desktop\r\n tandem setup --force Register to default paths regardless of detection\r\n tandem --version\r\n tandem --help\r\n`);\r\n process.exit(0);\r\n}\r\n\r\nif (args.includes(\"--version\") || args.includes(\"-v\")) {\r\n console.log(version);\r\n process.exit(0);\r\n}\r\n\r\ntry {\r\n if (args[0] === \"setup\") {\r\n const { runSetup } = await import(\"./setup.js\");\r\n await runSetup({ force: args.includes(\"--force\") });\r\n } else if (!args[0] || args[0] === \"start\") {\r\n const { runStart } = await import(\"./start.js\");\r\n runStart();\r\n } else {\r\n console.error(`Unknown command: ${args[0]}`);\r\n console.error(\"Run 'tandem --help' for usage.\");\r\n process.exit(1);\r\n }\r\n} catch (err) {\r\n console.error(`\\n[Tandem] Fatal error: ${err instanceof Error ? err.message : String(err)}`);\r\n console.error(\"If this persists, try reinstalling: npm install -g tandem-editor\\n\");\r\n process.exit(1);\r\n}\r\n"],"mappings":";;;;;;;;;;;;AAAA,IACa,kBAIA,eACA,gBAEA,cACA;AATb;AAAA;AAAA;AACO,IAAM,mBAAmB;AAIzB,IAAM,gBAAgB,KAAK,OAAO;AAClC,IAAM,iBAAiB,KAAK,OAAO;AAEnC,IAAM,eAAe,KAAK,KAAK;AAC/B,IAAM,kBAAkB,KAAK,KAAK,KAAK,KAAK;AAAA;AAAA;;;ACTnD,IAIa;AAJb;AAAA;AAAA;AAI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