From 91a2fdeff796bae8e87d9146e2d540550f54dd74 Mon Sep 17 00:00:00 2001 From: amankumarsingh77 Date: Tue, 28 Jul 2026 20:31:40 +0530 Subject: refactor: strip comment noise from the root modules Removes install/command banners and comments restating the code. Keeps one-line notes for the per-session profile-pin re-read, the deliberately surviving transport on shutdown, seed-before-attach under a pin, and the starts-with-return wrap rule. src/prompt.ts is untouched. Co-Authored-By: Claude Opus 5 (1M context) --- src/setup.ts | 21 --------------------- 1 file changed, 21 deletions(-) (limited to 'src/setup.ts') diff --git a/src/setup.ts b/src/setup.ts index 8c04030..d2ab7ac 100644 --- a/src/setup.ts +++ b/src/setup.ts @@ -1,8 +1,3 @@ -/** - * Setup — verifies Chrome is running with remote debugging and connects - * the pi agent to it. Exposed as both a slash command (/browser-setup) for - * users and a tool (browser_setup) for the agent to self-recover. - */ import type { ExtensionAPI, ExtensionContext } from "@mariozechner/pi-coding-agent"; import type { BrowserClient } from "./client"; @@ -11,7 +6,6 @@ import { DAEMON_SOCKET_PATH } from "./daemon/protocol"; import { isBrowserRunning } from "./profile/browser-process"; import { promptForProfileIfUnset } from "./profile/command"; -// ── Public: register the /browser-setup slash command ────────────────────── export function registerSetupCommand(pi: ExtensionAPI, client: BrowserClient): void { pi.registerCommand("browser-setup", { @@ -27,32 +21,23 @@ export function registerSetupCommand(pi: ExtensionAPI, client: BrowserClient): v }); } -// ── Shared setup result ──────────────────────────────────────────────────── export type SetupResult = { success: true; data: string } | { success: false; error: string }; -// ── Shared setup logic (used by both the command and the tool) ───────────── export async function performSetup(client: BrowserClient, ctx?: ExtensionContext): Promise { - // Step 1: Check Chrome is running const chromeRunning = await isBrowserRunning(); if (!chromeRunning) { return { success: false, error: "No browser instance running. Please open your browser and then run /browser-setup." }; } - // Step 2: Start the browser daemon (spawns if not running, silently reuses if alive) const daemonReady = await ensureDaemon(); if (!daemonReady) { return { success: false, error: `Could not start the browser daemon. Check ${DAEMON_SOCKET_PATH}.` }; } - // Step 3: Ask which profile to work in, the first time only. Enumeration - // reads DevToolsActivePort + Local State from disk, so it works before the - // connection exists. Declining leaves the pre-profile behavior untouched — - // this must never block setup. const profileNote = await promptForProfileIfUnset(client, ctx); - // Step 4: Connect to Chrome DevTools const startResult = await client.start(); if (!startResult.success) { const msg = startResult.error.message; @@ -80,7 +65,6 @@ export async function performSetup(client: BrowserClient, ctx?: ExtensionContext return { success: false, error: `Connection failed: ${msg}` }; } - // Step 5: Verify with test navigation const tabResult = await client.newTab("https://github.com"); if (!tabResult.success) { return { success: false, error: `Browser connected but test navigation failed: ${tabResult.error.message}` }; @@ -97,8 +81,3 @@ export async function performSetup(client: BrowserClient, ctx?: ExtensionContext return { success: true, data: lines.join("\n") }; } -// ── Chrome process detection ─────────────────────────────────────────────── -// -// Detection moved to src/profile/browser-process.ts, which answers the same -// "is a browser running?" question per platform and additionally reports the -// executable path and any explicit --user-data-dir that profile selection needs. -- cgit v1.2.3