MCPcopy Create free account
hub / github.com/different-ai/opencode-browser / install

Function install

bin/cli.js:377–658  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

375}
376
377async 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(`
398To load the extension:
399
4001. Open ${color("cyan", "chrome://extensions")}
4012. Enable ${color("bright", "Developer mode")}
4023. Click ${color("bright", "Load unpacked")}
4034. Select:
404 ${color("cyan", EXTENSION_DIR)}
405
406After 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(`
418We need the extension ID to register the native messaging host.
419
420Find 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}`);

Callers 1

mainFunction · 0.85

Calls 15

headerFunction · 0.85
errorFunction · 0.85
successFunction · 0.85
ensureDirFunction · 0.85
copyDirRecursiveFunction · 0.85
logFunction · 0.85
colorFunction · 0.85
askFunction · 0.85
resolveExtensionIdFunction · 0.85
warnFunction · 0.85
resolveNodePathFunction · 0.85
writeHostWrapperFunction · 0.85

Tested by

no test coverage detected