()
| 375 | } |
| 376 | |
| 377 | async function install() { |
| 378 | header("Step 1: Check Platform"); |
| 379 | |
| 380 | const osName = platform(); |
| 381 | if (osName !== "darwin" && osName !== "linux") { |
| 382 | error(`Unsupported platform: ${osName}`); |
| 383 | error("OpenCode Browser currently supports macOS and Linux only."); |
| 384 | process.exit(1); |
| 385 | } |
| 386 | success(`Platform: ${osName === "darwin" ? "macOS" : "Linux"}`); |
| 387 | |
| 388 | header("Step 2: Copy Extension Files"); |
| 389 | |
| 390 | ensureDir(BASE_DIR); |
| 391 | const srcExtensionDir = join(PACKAGE_ROOT, "extension"); |
| 392 | copyDirRecursive(srcExtensionDir, EXTENSION_DIR); |
| 393 | success(`Extension files copied to: ${EXTENSION_DIR}`); |
| 394 | |
| 395 | header("Step 3: Load & Pin Extension"); |
| 396 | |
| 397 | log(` |
| 398 | To load the extension: |
| 399 | |
| 400 | 1. Open ${color("cyan", "chrome://extensions")} |
| 401 | 2. Enable ${color("bright", "Developer mode")} |
| 402 | 3. Click ${color("bright", "Load unpacked")} |
| 403 | 4. Select: |
| 404 | ${color("cyan", EXTENSION_DIR)} |
| 405 | |
| 406 | After loading, ${color("bright", "pin the extension")}: open the Extensions menu (puzzle icon) and click the pin. |
| 407 | `); |
| 408 | |
| 409 | await ask(color("bright", "Press Enter when you've loaded and pinned the extension...")); |
| 410 | |
| 411 | header("Step 4: Extension ID"); |
| 412 | |
| 413 | let resolved = await resolveExtensionId({ allowPrompt: false, preferConfig: true }); |
| 414 | let extensionId = resolved.id; |
| 415 | |
| 416 | if (!extensionId) { |
| 417 | log(` |
| 418 | We need the extension ID to register the native messaging host. |
| 419 | |
| 420 | Find it at ${color("cyan", "chrome://extensions")}: |
| 421 | - Locate ${color("bright", "OpenCode Browser Automation")} |
| 422 | - Click ${color("bright", "Details")} |
| 423 | - Copy the ${color("bright", "ID")} |
| 424 | `); |
| 425 | |
| 426 | resolved = await resolveExtensionId({ allowPrompt: true, preferConfig: false }); |
| 427 | extensionId = resolved.id; |
| 428 | } else if (resolved.source === "manifest") { |
| 429 | success(`Using fixed extension ID from manifest: ${extensionId}`); |
| 430 | log(`If you already loaded a different ID, rerun with --extension-id to override.`); |
| 431 | } else if (resolved.source === "config") { |
| 432 | success(`Using extension ID from config.json: ${extensionId}`); |
| 433 | } else if (resolved.source === "override") { |
| 434 | success(`Using extension ID override: ${extensionId}`); |
no test coverage detected