@link-assistant/agent 0.0.14 → 0.0.16
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.
- package/README.md +104 -0
- package/package.json +1 -1
- package/src/cli/cmd/run.ts +2 -5
- package/src/index.js +19 -11
package/README.md
CHANGED
|
@@ -287,6 +287,110 @@ All 13 tools are **enabled by default** with **no configuration required**. See
|
|
|
287
287
|
|
|
288
288
|
✨ = Always enabled (no experimental flags or environment variables needed)
|
|
289
289
|
|
|
290
|
+
## MCP (Model Context Protocol) Support
|
|
291
|
+
|
|
292
|
+
The agent supports the Model Context Protocol (MCP), allowing you to extend functionality with MCP servers. MCP enables the agent to interact with external tools and services, such as browser automation via Playwright.
|
|
293
|
+
|
|
294
|
+
### Installing Playwright MCP
|
|
295
|
+
|
|
296
|
+
Microsoft's Playwright MCP server provides browser automation capabilities using Playwright. This enables the agent to interact with web pages through structured accessibility snapshots.
|
|
297
|
+
|
|
298
|
+
**Requirements:**
|
|
299
|
+
|
|
300
|
+
- Node.js 18 or newer (for running the Playwright MCP server)
|
|
301
|
+
- Bun (for running the agent itself)
|
|
302
|
+
|
|
303
|
+
**Installation:**
|
|
304
|
+
|
|
305
|
+
```bash
|
|
306
|
+
# Add Playwright MCP server to your agent configuration
|
|
307
|
+
agent mcp add playwright npx @playwright/mcp@latest
|
|
308
|
+
|
|
309
|
+
# Verify the configuration
|
|
310
|
+
agent mcp list
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
This will create a configuration file at `~/.config/opencode/opencode.json` (or your system's config directory) with:
|
|
314
|
+
|
|
315
|
+
```json
|
|
316
|
+
{
|
|
317
|
+
"$schema": "https://opencode.ai/config.json",
|
|
318
|
+
"mcp": {
|
|
319
|
+
"playwright": {
|
|
320
|
+
"type": "local",
|
|
321
|
+
"command": ["npx", "@playwright/mcp@latest"],
|
|
322
|
+
"enabled": true
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
**Available Playwright Tools:**
|
|
329
|
+
|
|
330
|
+
Once configured, the agent gains access to 22+ browser automation tools:
|
|
331
|
+
|
|
332
|
+
- `browser_navigate` - Navigate to a URL
|
|
333
|
+
- `browser_click` - Click on an element
|
|
334
|
+
- `browser_type` - Type text into an element
|
|
335
|
+
- `browser_snapshot` - Capture accessibility snapshot
|
|
336
|
+
- `browser_take_screenshot` - Take a screenshot
|
|
337
|
+
- `browser_fill_form` - Fill multiple form fields
|
|
338
|
+
- `browser_select_option` - Select dropdown option
|
|
339
|
+
- `browser_hover` - Hover over element
|
|
340
|
+
- `browser_drag` - Drag and drop
|
|
341
|
+
- `browser_evaluate` - Execute JavaScript
|
|
342
|
+
- `browser_tabs` - Manage browser tabs
|
|
343
|
+
- `browser_close` - Close the browser
|
|
344
|
+
- `browser_wait_for` - Wait for text/element
|
|
345
|
+
- `browser_press_key` - Press keyboard key
|
|
346
|
+
- `browser_handle_dialog` - Handle browser dialogs
|
|
347
|
+
- `browser_network_requests` - Get network requests
|
|
348
|
+
- `browser_console_messages` - Get console messages
|
|
349
|
+
- `browser_file_upload` - Upload files
|
|
350
|
+
- `browser_resize` - Resize browser window
|
|
351
|
+
- `browser_navigate_back` - Navigate back
|
|
352
|
+
- `browser_install` - Install browser
|
|
353
|
+
- `browser_run_code` - Run Playwright code
|
|
354
|
+
|
|
355
|
+
**Usage Example:**
|
|
356
|
+
|
|
357
|
+
```bash
|
|
358
|
+
# Tell the agent to navigate to a website and take a screenshot
|
|
359
|
+
echo "Navigate to https://example.com and take a screenshot" | agent
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
The agent will automatically use the Playwright MCP tools when browser automation is needed.
|
|
363
|
+
|
|
364
|
+
**Learn More:**
|
|
365
|
+
|
|
366
|
+
- [Playwright MCP GitHub Repository](https://github.com/microsoft/playwright-mcp)
|
|
367
|
+
- [Using Playwright MCP with Claude Code](https://til.simonwillison.net/claude-code/playwright-mcp-claude-code)
|
|
368
|
+
- [Playwright MCP Case Study](docs/case-studies/playwright-mcp-support/case-study.md)
|
|
369
|
+
|
|
370
|
+
### Managing MCP Servers
|
|
371
|
+
|
|
372
|
+
**List configured servers:**
|
|
373
|
+
|
|
374
|
+
```bash
|
|
375
|
+
agent mcp list
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
**Add a remote MCP server:**
|
|
379
|
+
|
|
380
|
+
```bash
|
|
381
|
+
agent mcp add myserver --url https://example.com/mcp
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
**Interactive mode:**
|
|
385
|
+
|
|
386
|
+
If you prefer an interactive setup, just run:
|
|
387
|
+
|
|
388
|
+
```bash
|
|
389
|
+
agent mcp add
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
The interactive prompt will guide you through configuring local or remote MCP servers.
|
|
393
|
+
|
|
290
394
|
## Examples
|
|
291
395
|
|
|
292
396
|
See [EXAMPLES.md](EXAMPLES.md) for detailed usage examples of each tool with both agent-cli and opencode commands.
|
package/package.json
CHANGED
package/src/cli/cmd/run.ts
CHANGED
|
@@ -109,11 +109,8 @@ export const RunCommand = cmd({
|
|
|
109
109
|
});
|
|
110
110
|
},
|
|
111
111
|
handler: async (args) => {
|
|
112
|
-
//
|
|
113
|
-
|
|
114
|
-
Flag.setVerbose(true);
|
|
115
|
-
await Log.init({ print: true, level: 'DEBUG' });
|
|
116
|
-
}
|
|
112
|
+
// Note: verbose flag and logging are now initialized in middleware
|
|
113
|
+
// See src/index.js main() function for the middleware that sets up Flag and Log.init()
|
|
117
114
|
let message = args.message.join(' ');
|
|
118
115
|
|
|
119
116
|
const fileParts: any[] = [];
|
package/src/index.js
CHANGED
|
@@ -83,10 +83,8 @@ function readStdin() {
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
async function runAgentMode(argv) {
|
|
86
|
-
//
|
|
87
|
-
|
|
88
|
-
Flag.setVerbose(true);
|
|
89
|
-
}
|
|
86
|
+
// Note: verbose flag and logging are now initialized in middleware
|
|
87
|
+
// See main() function for the middleware that sets up Flag and Log.init()
|
|
90
88
|
|
|
91
89
|
// Parse model argument (handle model IDs with slashes like groq/qwen/qwen3-32b)
|
|
92
90
|
const modelParts = argv.model.split('/');
|
|
@@ -176,13 +174,7 @@ async function runAgentMode(argv) {
|
|
|
176
174
|
appendSystemMessage = await file.text();
|
|
177
175
|
}
|
|
178
176
|
|
|
179
|
-
//
|
|
180
|
-
// This prevents log messages from mixing with JSON output
|
|
181
|
-
// In verbose mode, print to stderr for debugging
|
|
182
|
-
await Log.init({
|
|
183
|
-
print: Flag.OPENCODE_VERBOSE, // Print to stderr only in verbose mode
|
|
184
|
-
level: Flag.OPENCODE_VERBOSE ? 'DEBUG' : 'INFO',
|
|
185
|
-
});
|
|
177
|
+
// Logging is already initialized in middleware, no need to call Log.init() again
|
|
186
178
|
|
|
187
179
|
// Read input from stdin
|
|
188
180
|
const input = await readStdin();
|
|
@@ -563,6 +555,22 @@ async function main() {
|
|
|
563
555
|
'Use existing Claude OAuth credentials from ~/.claude/.credentials.json (from Claude Code CLI)',
|
|
564
556
|
default: false,
|
|
565
557
|
})
|
|
558
|
+
// Initialize logging early for all CLI commands
|
|
559
|
+
// This prevents debug output from appearing in CLI unless --verbose is used
|
|
560
|
+
.middleware(async (argv) => {
|
|
561
|
+
// Set verbose flag if requested
|
|
562
|
+
if (argv.verbose) {
|
|
563
|
+
Flag.setVerbose(true);
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
// Initialize logging system
|
|
567
|
+
// - If verbose: print logs to stderr for debugging
|
|
568
|
+
// - Otherwise: write logs to file to keep CLI output clean
|
|
569
|
+
await Log.init({
|
|
570
|
+
print: Flag.OPENCODE_VERBOSE,
|
|
571
|
+
level: Flag.OPENCODE_VERBOSE ? 'DEBUG' : 'INFO',
|
|
572
|
+
});
|
|
573
|
+
})
|
|
566
574
|
.fail((msg, err, yargs) => {
|
|
567
575
|
// Handle errors from command handlers
|
|
568
576
|
if (err) {
|