/** * `peaks playwright start | ls | stop` — slice 2.5.0 sub-fix C (Prob 3). * * Multi-terminal resolution for the Playwright MCP. When two or more * terminals / IDE sessions each spawn a `playwright` MCP server, they * fight over the same default port (8931) and the same user data * dir. This command: * * 1. `peaks playwright start [--port N] [--browser ]` * Allocates a unique port (default 8931; walks 8931→8949 if busy), * spawns `npx playwright-mcp@latest` with the chosen port, and * writes a session file at * `/.peaks/_runtime/playwright-sessions/.json` * with `{ port, userDataDir, startedAt, pid }`. * * 2. `peaks playwright ls` — lists all running sessions (reads * `.peaks/_runtime/playwright-sessions/*.json`). * * 3. `peaks playwright stop [--terminal ]` — best-effort kills * the server process and removes the session file. * * Terminal ID derivation (R4): * 1. process.env.TERM_SESSION_ID (macOS Terminal / iTerm2) * 2. process.env.WT_SESSION (Windows Terminal) * 3. hash(process.ppid + process.env.SSH_TTY || 'no-tty') * * The CLI does NOT bundle `playwright-mcp`; it shells out to * `npx playwright-mcp@latest` (G22 / NG3). peaks-loop is the lifecycle * orchestrator, not the install medium. * * The verb implementations live beside this file: `playwright-session-store.ts` * (port range, terminal-id derivation, session records, spawn), * `playwright-ls-stop-commands.ts` (`ls` / `stop`) and * `playwright-browser-command.ts` (`peaks browser action`). Every symbol this * path used to export is still exported from it, so importers are unaffected. */ import type { Command } from 'commander'; import { type ProgramIO } from '../cli-helpers.js'; export { DEFAULT_PORT, MAX_PORT, PLAYWRIGHT_SESSIONS_DIR, playwrightSessionsDir, sessionFilePath, deriveTerminalId, findFreePort, listSessions, readSession, writeSession, removeSession, spawnPlaywrightMcp, resolveUserDataDir } from './playwright-session-store.js'; export type { PlaywrightSession } from './playwright-session-store.js'; export { registerBrowserActionCommand } from './playwright-browser-command.js'; export declare function registerPlaywrightCommands(program: Command, io: ProgramIO): void;