()
| 658 | } |
| 659 | |
| 660 | async function update() { |
| 661 | header("Update: Check Platform"); |
| 662 | |
| 663 | const osName = platform(); |
| 664 | if (osName !== "darwin" && osName !== "linux") { |
| 665 | error(`Unsupported platform: ${osName}`); |
| 666 | error("OpenCode Browser currently supports macOS and Linux only."); |
| 667 | process.exit(1); |
| 668 | } |
| 669 | success(`Platform: ${osName === "darwin" ? "macOS" : "Linux"}`); |
| 670 | |
| 671 | header("Step 1: Copy Extension Files"); |
| 672 | |
| 673 | ensureDir(BASE_DIR); |
| 674 | const srcExtensionDir = join(PACKAGE_ROOT, "extension"); |
| 675 | copyDirRecursive(srcExtensionDir, EXTENSION_DIR); |
| 676 | success(`Extension files copied to: ${EXTENSION_DIR}`); |
| 677 | |
| 678 | header("Step 2: Resolve Extension ID"); |
| 679 | |
| 680 | let resolved = await resolveExtensionId({ allowPrompt: false, preferConfig: true }); |
| 681 | let extensionId = resolved.id; |
| 682 | |
| 683 | if (!extensionId) { |
| 684 | log(` |
| 685 | We need the extension ID to register the native messaging host. |
| 686 | |
| 687 | Find it at ${color("cyan", "chrome://extensions")}: |
| 688 | - Locate ${color("bright", "OpenCode Browser Automation")} |
| 689 | - Click ${color("bright", "Details")} |
| 690 | - Copy the ${color("bright", "ID")} |
| 691 | `); |
| 692 | |
| 693 | resolved = await resolveExtensionId({ allowPrompt: true, preferConfig: false }); |
| 694 | extensionId = resolved.id; |
| 695 | } else if (resolved.source === "manifest") { |
| 696 | success(`Using fixed extension ID from manifest: ${extensionId}`); |
| 697 | } else if (resolved.source === "config") { |
| 698 | success(`Using extension ID from config.json: ${extensionId}`); |
| 699 | } else if (resolved.source === "override") { |
| 700 | success(`Using extension ID override: ${extensionId}`); |
| 701 | } |
| 702 | |
| 703 | if (!extensionId) { |
| 704 | error("Extension ID is required to continue."); |
| 705 | process.exit(1); |
| 706 | } |
| 707 | |
| 708 | if (!/^[a-p]{32}$/i.test(extensionId)) { |
| 709 | warn("That doesn't look like a Chrome extension ID (expected 32 chars a-p). Continuing anyway."); |
| 710 | } |
| 711 | |
| 712 | const manifestId = getExtensionIdFromManifest(); |
| 713 | if (resolved.source === "config" && manifestId && manifestId !== extensionId) { |
| 714 | warn(`Manifest key implies ${manifestId}, but config.json uses ${extensionId}. Run update with --extension-id ${manifestId} to switch.`); |
| 715 | } |
| 716 | |
| 717 | header("Step 3: Install Local Host + Broker"); |
no test coverage detected