@different-ai/opencode-browser 1.0.3 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/bin/cli.js +60 -3
  2. package/package.json +1 -1
package/bin/cli.js CHANGED
@@ -217,7 +217,49 @@ exec "${nodePath}" "${hostScriptPath}" "$@"
217
217
  const logsDir = join(homedir(), ".opencode-browser", "logs");
218
218
  mkdirSync(logsDir, { recursive: true });
219
219
 
220
- header("Step 5: Configure OpenCode");
220
+ header("Step 5: Install Background Daemon");
221
+
222
+ if (os === "darwin") {
223
+ const daemonPath = join(PACKAGE_ROOT, "src", "daemon.js");
224
+
225
+ const plist = `<?xml version="1.0" encoding="UTF-8"?>
226
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
227
+ <plist version="1.0">
228
+ <dict>
229
+ <key>Label</key>
230
+ <string>com.opencode.browser-daemon</string>
231
+ <key>ProgramArguments</key>
232
+ <array>
233
+ <string>${nodePath}</string>
234
+ <string>${daemonPath}</string>
235
+ </array>
236
+ <key>RunAtLoad</key>
237
+ <true/>
238
+ <key>KeepAlive</key>
239
+ <true/>
240
+ <key>StandardOutPath</key>
241
+ <string>${logsDir}/daemon.log</string>
242
+ <key>StandardErrorPath</key>
243
+ <string>${logsDir}/daemon.log</string>
244
+ </dict>
245
+ </plist>`;
246
+
247
+ const plistPath = join(homedir(), "Library", "LaunchAgents", "com.opencode.browser-daemon.plist");
248
+ writeFileSync(plistPath, plist);
249
+
250
+ try {
251
+ execSync(`launchctl unload "${plistPath}" 2>/dev/null || true`, { stdio: "ignore" });
252
+ execSync(`launchctl load "${plistPath}"`, { stdio: "ignore" });
253
+ success("Daemon installed and started");
254
+ } catch (e) {
255
+ warn("Could not start daemon automatically. Run: launchctl load " + plistPath);
256
+ }
257
+ } else {
258
+ warn("On Linux, create a systemd service for the daemon manually.");
259
+ log(`Daemon script: ${join(PACKAGE_ROOT, "src", "daemon.js")}`);
260
+ }
261
+
262
+ header("Step 6: Configure OpenCode");
221
263
 
222
264
  const serverPath = join(PACKAGE_ROOT, "src", "server.js");
223
265
  const mcpConfig = {
@@ -253,8 +295,20 @@ ${color("bright", JSON.stringify(mcpConfig, null, 2))}
253
295
  }
254
296
  }
255
297
  } else {
256
- log(`No opencode.json found in current directory.`);
257
- log(`Add the config above to your project's opencode.json manually.`);
298
+ const shouldCreate = await confirm(`No opencode.json found. Create one with browser config?`);
299
+
300
+ if (shouldCreate) {
301
+ try {
302
+ const config = { "$schema": "https://opencode.ai/config.json", mcp: mcpConfig };
303
+ writeFileSync(opencodeJsonPath, JSON.stringify(config, null, 2) + "\n");
304
+ success("Created opencode.json with browser MCP config");
305
+ shouldUpdateConfig = true;
306
+ } catch (e) {
307
+ error(`Failed to create opencode.json: ${e.message}`);
308
+ }
309
+ } else {
310
+ log(`Add the config above to your project's opencode.json manually.`);
311
+ }
258
312
  }
259
313
 
260
314
  header("Installation Complete!");
@@ -281,6 +335,9 @@ ${color("bright", "Available tools:")}
281
335
  browser_execute - Run JavaScript
282
336
 
283
337
  ${color("bright", "Logs:")} ~/.opencode-browser/logs/
338
+
339
+ ${color("bright", "Test it out:")}
340
+ Open OpenCode and try: ${color("cyan", '"Navigate to google.com and take a snapshot"')}
284
341
  `);
285
342
  }
286
343
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@different-ai/opencode-browser",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "Browser automation for OpenCode via Chrome extension + Native Messaging. Inspired by Claude in Chrome.",
5
5
  "type": "module",
6
6
  "bin": {