opencode-browser 1.0.0 → 1.0.2

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 (3) hide show
  1. package/README.md +11 -19
  2. package/index.ts +6 -14
  3. package/package.json +4 -4
package/README.md CHANGED
@@ -26,28 +26,16 @@ Before using this plugin, you need:
26
26
  2. Install the Browser MCP extension for your browser (Chrome or Edge)
27
27
  3. Follow the extension setup instructions
28
28
 
29
- ### Step 2: Configure Browser MCP Server in OpenCode
29
+ ### Step 2: Configure OpenCode
30
30
 
31
- Add the Browser MCP server configuration to your `opencode.json`:
31
+ Create or update your `opencode.json` configuration file. You can create this file in one of two locations:
32
32
 
33
- ```json
34
- {
35
- "$schema": "https://opencode.ai/config.json",
36
- "mcp": {
37
- "browsermcp": {
38
- "type": "local",
39
- "command": ["npx", "-y", "@browsermcp/mcp@latest"],
40
- "enabled": true
41
- }
42
- }
43
- }
44
- ```
45
-
46
- ### Step 3: Install the Plugin
33
+ - **Global configuration** (applies to all projects): `~/.config/opencode/opencode.json`
34
+ - **Project-specific configuration** (applies to current project only): `./opencode.json` (in your project root)
47
35
 
48
- #### Recommended: Install from npm
36
+ Learn more about OpenCode configuration at [https://opencode.ai/docs/config](https://opencode.ai/docs/config)
49
37
 
50
- Simply add the plugin to your `opencode.json`:
38
+ Add this configuration to your `opencode.json`:
51
39
 
52
40
  ```json
53
41
  {
@@ -63,7 +51,11 @@ Simply add the plugin to your `opencode.json`:
63
51
  }
64
52
  ```
65
53
 
66
- OpenCode will automatically download and install the plugin from npm when it starts. No manual file copying required!
54
+ This configuration does two things:
55
+ 1. **Installs the plugin** - OpenCode automatically downloads `opencode-browser` from npm
56
+ 2. **Configures Browser MCP** - Sets up the MCP server that actually controls the browser
57
+
58
+ That's it! No manual file copying required. OpenCode handles everything automatically.
67
59
 
68
60
  #### Alternative: Install Locally (for development/testing)
69
61
 
package/index.ts CHANGED
@@ -18,8 +18,6 @@ import type { Plugin } from "@opencode-ai/plugin"
18
18
  export const BrowserMCPPlugin: Plugin = async (ctx) => {
19
19
  const { client, project } = ctx
20
20
 
21
- console.log("Browser MCP Plugin initialized!")
22
-
23
21
  // Track if we've informed the user about browser automation capabilities
24
22
  let browserCapabilitiesShown = false
25
23
 
@@ -28,7 +26,7 @@ export const BrowserMCPPlugin: Plugin = async (ctx) => {
28
26
  * Hook into session creation to inject browser automation context
29
27
  */
30
28
  "session.created": async ({ session }) => {
31
- console.log(`Browser MCP Plugin: Session ${session.id} created`)
29
+ // Session created - ready for browser automation
32
30
  },
33
31
 
34
32
  /**
@@ -37,12 +35,7 @@ export const BrowserMCPPlugin: Plugin = async (ctx) => {
37
35
  "tool.execute.before": async (input, output) => {
38
36
  // Detect if a browser-related MCP tool is being called
39
37
  if (input.tool.startsWith("browsermcp_")) {
40
- console.log(`Browser MCP Plugin: Executing browser tool: ${input.tool}`)
41
-
42
- // Log the tool execution for debugging
43
- if (output.args) {
44
- console.log(`Browser MCP Plugin: Tool arguments:`, JSON.stringify(output.args, null, 2))
45
- }
38
+ // Browser tool execution starting
46
39
  }
47
40
  },
48
41
 
@@ -51,8 +44,6 @@ export const BrowserMCPPlugin: Plugin = async (ctx) => {
51
44
  */
52
45
  "tool.execute.after": async (input, output) => {
53
46
  if (input.tool.startsWith("browsermcp_")) {
54
- console.log(`Browser MCP Plugin: Completed browser tool: ${input.tool}`)
55
-
56
47
  // You can add custom post-processing here, such as:
57
48
  // - Logging results to a file
58
49
  // - Sending notifications
@@ -66,7 +57,8 @@ export const BrowserMCPPlugin: Plugin = async (ctx) => {
66
57
  */
67
58
  "experimental.session.compacting": async (input, output) => {
68
59
  // Check if any browser automation was performed in this session
69
- const hasBrowserTools = input.messages.some(msg =>
60
+ // Guard against input.messages being undefined
61
+ const hasBrowserTools = input.messages?.some(msg =>
70
62
  msg.content?.some(part =>
71
63
  part.type === "tool_use" && part.name?.startsWith("browsermcp_")
72
64
  )
@@ -96,12 +88,12 @@ The Browser MCP integration has been used in this session. When resuming:
96
88
  event: async ({ event }) => {
97
89
  // Handle session idle - could be used to close browser tabs
98
90
  if (event.type === "session.idle") {
99
- console.log("Browser MCP Plugin: Session is idle")
91
+ // Session is idle
100
92
  }
101
93
 
102
94
  // Handle session errors - could help debug browser automation issues
103
95
  if (event.type === "session.error") {
104
- console.log("Browser MCP Plugin: Session error occurred")
96
+ // Session error occurred
105
97
  }
106
98
  }
107
99
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-browser",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "OpenCode plugin that integrates Browser MCP for browser automation",
5
5
  "type": "module",
6
6
  "main": "index.ts",
@@ -24,11 +24,11 @@
24
24
  },
25
25
  "repository": {
26
26
  "type": "git",
27
- "url": "git+https://github.com/jach/opencode-browser.git"
27
+ "url": "git+https://github.com/michaljach/opencode-browser.git"
28
28
  },
29
- "homepage": "https://github.com/jach/opencode-browser#readme",
29
+ "homepage": "https://github.com/michaljach/opencode-browser#readme",
30
30
  "bugs": {
31
- "url": "https://github.com/jach/opencode-browser/issues"
31
+ "url": "https://github.com/michaljach/opencode-browser/issues"
32
32
  },
33
33
  "files": [
34
34
  "index.ts",