@link-assistant/agent 0.7.0 → 0.8.1
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/package.json +9 -9
- package/src/cli/continuous-mode.js +188 -18
- package/src/cli/event-handler.js +99 -0
- package/src/config/config.ts +51 -0
- package/src/index.js +82 -157
- package/src/mcp/index.ts +125 -0
- package/src/session/message-v2.ts +30 -1
- package/src/session/processor.ts +21 -2
- package/src/session/prompt.ts +23 -1
- package/src/session/retry.ts +18 -0
- package/EXAMPLES.md +0 -462
- package/LICENSE +0 -24
- package/MODELS.md +0 -143
- package/README.md +0 -616
- package/TOOLS.md +0 -154
package/README.md
DELETED
|
@@ -1,616 +0,0 @@
|
|
|
1
|
-
# @link-assistant/agent
|
|
2
|
-
|
|
3
|
-
**A minimal, public domain AI CLI agent compatible with OpenCode's JSON interface**
|
|
4
|
-
|
|
5
|
-
[](https://www.npmjs.com/package/@link-assistant/agent)
|
|
6
|
-
[](http://unlicense.org/)
|
|
7
|
-
|
|
8
|
-
> 🚨 **SECURITY WARNING: 100% UNSAFE AND AUTONOMOUS** 🚨
|
|
9
|
-
>
|
|
10
|
-
> This agent operates with **ZERO RESTRICTIONS** and **FULL AUTONOMY**:
|
|
11
|
-
>
|
|
12
|
-
> - ❌ **No Sandbox** - Complete unrestricted file system access
|
|
13
|
-
> - ❌ **No Permissions System** - No approval required for any actions
|
|
14
|
-
> - ❌ **No Safety Guardrails** - Can execute ANY command with full privileges
|
|
15
|
-
> - ⚠️ **Autonomous Execution** - Makes decisions and executes actions independently
|
|
16
|
-
>
|
|
17
|
-
> **ONLY use in isolated environments** (VMs, Docker containers) where AI agents can have unrestricted access. **NOT SAFE** for personal computers, production servers, or systems with sensitive data.
|
|
18
|
-
|
|
19
|
-
> ⚠️ **Bun-only runtime** - This package requires [Bun](https://bun.sh) and does NOT support Node.js or Deno.
|
|
20
|
-
|
|
21
|
-
This is an MVP implementation of an OpenCode-compatible CLI agent, focused on maximum efficiency and unrestricted execution. We reproduce OpenCode's `run --format json --model opencode/grok-code` mode with:
|
|
22
|
-
|
|
23
|
-
- ✅ **JSON Input/Output**: Compatible with `opencode run --format json --model opencode/grok-code`
|
|
24
|
-
- ✅ **Plain Text Input**: Also accepts plain text messages (auto-converted to JSON format)
|
|
25
|
-
- ✅ **Flexible Model Selection**: Defaults to free OpenCode Zen Grok Code Fast 1, supports [OpenCode Zen](https://opencode.ai/docs/zen/), [Claude OAuth](docs/claude-oauth.md), and [Groq](docs/groq.md) providers
|
|
26
|
-
- ✅ **No Restrictions**: Fully unrestricted file system and command execution access (no sandbox)
|
|
27
|
-
- ✅ **Minimal Footprint**: Built with Bun.sh for maximum efficiency
|
|
28
|
-
- ✅ **Full Tool Support**: 13 tools including websearch, codesearch, batch - all enabled by default
|
|
29
|
-
- ✅ **100% OpenCode Compatible**: All tool outputs match OpenCode's JSON format exactly
|
|
30
|
-
- ✅ **Internal HTTP Server**: Uses local HTTP server for session management (not exposed externally)
|
|
31
|
-
- ❌ **No TUI**: Pure JSON CLI interface only
|
|
32
|
-
- ❌ **No Sandbox**: Designed for VMs/containers where full access is acceptable
|
|
33
|
-
- ❌ **No LSP**: No Language Server Protocol support for diagnostics
|
|
34
|
-
- ❌ **No Permissions**: No permission system - full unrestricted access
|
|
35
|
-
- ❌ **No IDE Integration**: No IDE/editor integration features
|
|
36
|
-
- ❌ **No Plugins**: No plugin system
|
|
37
|
-
- ❌ **No Share**: No session sharing functionality
|
|
38
|
-
- ❌ **No External API**: Server runs only internally, not exposed to network
|
|
39
|
-
- ❌ **No ACP**: No Agent Client Protocol support
|
|
40
|
-
|
|
41
|
-
## Project Vision
|
|
42
|
-
|
|
43
|
-
We're creating a slimmed-down, public domain version of OpenCode CLI focused on the "agentic run mode" for use in virtual machines, Docker containers, and other environments where unrestricted AI agent access is acceptable. This is **not** for general desktop use - it's for isolated environments where you want maximum AI agent freedom.
|
|
44
|
-
|
|
45
|
-
**OpenCode Compatibility**: We maintain 100% compatibility with OpenCode's JSON event streaming format, so tools expecting `opencode run --format json --model opencode/grok-code` output will work with our agent-cli.
|
|
46
|
-
|
|
47
|
-
## Design Choices
|
|
48
|
-
|
|
49
|
-
### Why Bun-only? No Node.js or Deno support?
|
|
50
|
-
|
|
51
|
-
This agent is **exclusively built for Bun** for the following reasons:
|
|
52
|
-
|
|
53
|
-
1. **Faster Development**: No compilation step - direct execution with `bun run`
|
|
54
|
-
2. **Simpler Dependencies**: Fewer dev dependencies, no TypeScript compiler overhead
|
|
55
|
-
3. **Performance**: Bun's fast runtime and native ESM support
|
|
56
|
-
4. **Minimalism**: Single runtime target keeps the codebase simple
|
|
57
|
-
5. **Bun Ecosystem**: Leverages Bun-specific features and optimizations
|
|
58
|
-
|
|
59
|
-
**Not supporting Node.js or Deno is intentional** to keep the project focused and minimal. If you need Node.js/Deno compatibility, consider using [OpenCode](https://github.com/sst/opencode) instead.
|
|
60
|
-
|
|
61
|
-
### Architecture: Reproducing OpenCode's JSON Event Streaming
|
|
62
|
-
|
|
63
|
-
This agent-cli reproduces the core architecture of [OpenCode](https://github.com/sst/opencode)'s `run --format json` command:
|
|
64
|
-
|
|
65
|
-
- **Streaming JSON Events**: Instead of single responses, outputs real-time event stream
|
|
66
|
-
- **Event Types**: `tool_use`, `text`, `step_start`, `step_finish`, `error`
|
|
67
|
-
- **Session Management**: Each request gets a unique session ID
|
|
68
|
-
- **Tool Execution**: 13 tools with unrestricted access (bash, read, write, edit, list, glob, grep, websearch, codesearch, batch, task, todo, webfetch)
|
|
69
|
-
- **Compatible Format**: Events match OpenCode's JSON schema for interoperability
|
|
70
|
-
|
|
71
|
-
The agent streams events as they occur, providing the same real-time experience as OpenCode's JSON mode.
|
|
72
|
-
|
|
73
|
-
## Features
|
|
74
|
-
|
|
75
|
-
- **JSON Input/Output**: Accepts JSON via stdin, outputs JSON event streams (OpenCode-compatible)
|
|
76
|
-
- **Plain Text Input**: Also accepts plain text messages (auto-converted to JSON format)
|
|
77
|
-
- **Unrestricted Access**: Full file system and command execution access (no sandbox, no restrictions)
|
|
78
|
-
- **Tool Support**: 13 tools including websearch, codesearch, batch - all enabled by default
|
|
79
|
-
- **Flexible Model Selection**: Defaults to free Grok Code Fast 1, supports [OpenCode Zen](https://opencode.ai/docs/zen/), [Claude OAuth](docs/claude-oauth.md), and [Groq](docs/groq.md) - see [MODELS.md](MODELS.md)
|
|
80
|
-
- **Bun.sh First**: Built with Bun for maximum efficiency and minimal resource usage
|
|
81
|
-
- **No TUI**: Pure JSON CLI interface for automation and integration
|
|
82
|
-
- **Public Domain**: Unlicense - use it however you want
|
|
83
|
-
|
|
84
|
-
## Installation
|
|
85
|
-
|
|
86
|
-
**Requirements:**
|
|
87
|
-
|
|
88
|
-
- [Bun](https://bun.sh) >= 1.0.0 (Node.js and Deno are NOT supported)
|
|
89
|
-
|
|
90
|
-
```bash
|
|
91
|
-
# Install Bun first if you haven't already
|
|
92
|
-
curl -fsSL https://bun.sh/install | bash
|
|
93
|
-
|
|
94
|
-
# Install the package globally
|
|
95
|
-
bun install -g @link-assistant/agent
|
|
96
|
-
|
|
97
|
-
# Or install locally in your project
|
|
98
|
-
bun add @link-assistant/agent
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
After installation, the `agent` command will be available globally.
|
|
102
|
-
|
|
103
|
-
## Usage
|
|
104
|
-
|
|
105
|
-
### Simplest Examples
|
|
106
|
-
|
|
107
|
-
**Plain text (easiest):**
|
|
108
|
-
|
|
109
|
-
```bash
|
|
110
|
-
echo "hi" | agent
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
**Simple JSON message:**
|
|
114
|
-
|
|
115
|
-
```bash
|
|
116
|
-
echo '{"message":"hi"}' | agent
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
**With custom model:**
|
|
120
|
-
|
|
121
|
-
```bash
|
|
122
|
-
echo "hi" | agent --model opencode/grok-code
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
### More Examples
|
|
126
|
-
|
|
127
|
-
**Plain Text Input:**
|
|
128
|
-
|
|
129
|
-
```bash
|
|
130
|
-
echo "hello world" | agent
|
|
131
|
-
echo "search the web for TypeScript news" | agent
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
**JSON Input with tool calls:**
|
|
135
|
-
|
|
136
|
-
```bash
|
|
137
|
-
echo '{"message":"run command","tools":[{"name":"bash","params":{"command":"ls -la"}}]}' | agent
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
**Using different models:**
|
|
141
|
-
|
|
142
|
-
```bash
|
|
143
|
-
# Default model (free Grok Code Fast 1)
|
|
144
|
-
echo "hi" | agent
|
|
145
|
-
|
|
146
|
-
# Other free models
|
|
147
|
-
echo "hi" | agent --model opencode/big-pickle
|
|
148
|
-
echo "hi" | agent --model opencode/gpt-5-nano
|
|
149
|
-
|
|
150
|
-
# Premium models (OpenCode Zen subscription)
|
|
151
|
-
echo "hi" | agent --model opencode/sonnet # Claude Sonnet 4.5
|
|
152
|
-
echo "hi" | agent --model opencode/haiku # Claude Haiku 4.5
|
|
153
|
-
echo "hi" | agent --model opencode/opus # Claude Opus 4.1
|
|
154
|
-
echo "hi" | agent --model opencode/gemini-3-pro # Gemini 3 Pro
|
|
155
|
-
|
|
156
|
-
# Groq models (requires GROQ_API_KEY)
|
|
157
|
-
echo "hi" | agent --model groq/llama-3.3-70b-versatile # Llama 3.3 70B
|
|
158
|
-
echo "hi" | agent --model groq/llama-3.1-8b-instant # Llama 3.1 8B (fast)
|
|
159
|
-
|
|
160
|
-
# Anthropic direct (requires ANTHROPIC_API_KEY)
|
|
161
|
-
echo "hi" | agent --model anthropic/claude-sonnet-4-5 # Claude Sonnet 4.5
|
|
162
|
-
echo "hi" | agent --model anthropic/claude-opus-4-1 # Claude Opus 4.1
|
|
163
|
-
|
|
164
|
-
# Anthropic OAuth (requires Claude Pro/Max subscription)
|
|
165
|
-
agent auth login # Select Anthropic > Claude Pro/Max
|
|
166
|
-
echo "hi" | agent --model anthropic/claude-sonnet-4-5 # Uses OAuth credentials
|
|
167
|
-
|
|
168
|
-
# Use existing Claude Code CLI credentials
|
|
169
|
-
echo "hi" | agent --use-existing-claude-oauth # Reads from ~/.claude/.credentials.json
|
|
170
|
-
|
|
171
|
-
# Google Gemini (requires GOOGLE_API_KEY)
|
|
172
|
-
echo "hi" | agent --model google/gemini-3-pro # Gemini 3 Pro
|
|
173
|
-
echo "hi" | agent --model google/gemini-2.5-flash # Gemini 2.5 Flash
|
|
174
|
-
|
|
175
|
-
# GitHub Copilot (requires Copilot subscription)
|
|
176
|
-
agent auth login # Select GitHub Copilot
|
|
177
|
-
echo "hi" | agent --model github-copilot/gpt-4o # Uses Copilot
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
See [MODELS.md](MODELS.md) for complete list of available models and pricing.
|
|
181
|
-
See [docs/groq.md](docs/groq.md) for Groq provider documentation.
|
|
182
|
-
See [docs/claude-oauth.md](docs/claude-oauth.md) for Claude OAuth provider documentation.
|
|
183
|
-
|
|
184
|
-
### Direct Prompt Mode
|
|
185
|
-
|
|
186
|
-
Use `-p`/`--prompt` to send a prompt directly without reading from stdin:
|
|
187
|
-
|
|
188
|
-
```bash
|
|
189
|
-
# Direct prompt (bypasses stdin)
|
|
190
|
-
agent -p "What is 2+2?"
|
|
191
|
-
|
|
192
|
-
# Useful in scripts
|
|
193
|
-
result=$(agent -p "Summarize: $(cat file.txt)")
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
### CLI Options
|
|
197
|
-
|
|
198
|
-
```bash
|
|
199
|
-
agent [options]
|
|
200
|
-
|
|
201
|
-
Options:
|
|
202
|
-
--model Model to use in format providerID/modelID
|
|
203
|
-
Default: opencode/grok-code
|
|
204
|
-
--json-standard JSON output format standard
|
|
205
|
-
Choices: "opencode" (default), "claude" (experimental)
|
|
206
|
-
--use-existing-claude-oauth Use existing Claude OAuth credentials
|
|
207
|
-
from ~/.claude/.credentials.json
|
|
208
|
-
--system-message Full override of the system message
|
|
209
|
-
--system-message-file Full override of the system message from file
|
|
210
|
-
--append-system-message Append to the default system message
|
|
211
|
-
--append-system-message-file Append to the default system message from file
|
|
212
|
-
|
|
213
|
-
Stdin Mode Options:
|
|
214
|
-
-p, --prompt Direct prompt (bypasses stdin reading)
|
|
215
|
-
--disable-stdin Disable stdin streaming (requires --prompt)
|
|
216
|
-
--stdin-stream-timeout Timeout in ms for stdin reading (default: none)
|
|
217
|
-
--interactive Accept plain text input (default: true)
|
|
218
|
-
--no-interactive Only accept JSON input
|
|
219
|
-
--auto-merge-queued-messages Merge rapidly arriving lines (default: true)
|
|
220
|
-
--no-auto-merge-queued-messages Treat each line as separate message
|
|
221
|
-
--always-accept-stdin Keep accepting input after agent finishes (default: true)
|
|
222
|
-
--no-always-accept-stdin Single-message mode - exit after first response
|
|
223
|
-
--compact-json Output compact JSON for program-to-program use
|
|
224
|
-
|
|
225
|
-
--help Show help
|
|
226
|
-
--version Show version number
|
|
227
|
-
|
|
228
|
-
Commands:
|
|
229
|
-
auth login Authenticate with a provider (Anthropic, GitHub Copilot, etc.)
|
|
230
|
-
auth logout Remove credentials for a provider
|
|
231
|
-
auth list List configured credentials
|
|
232
|
-
auth status Check authentication status (experimental)
|
|
233
|
-
mcp MCP server commands
|
|
234
|
-
```
|
|
235
|
-
|
|
236
|
-
See [docs/stdin-mode.md](docs/stdin-mode.md) for comprehensive stdin mode documentation.
|
|
237
|
-
|
|
238
|
-
### JSON Output Standards
|
|
239
|
-
|
|
240
|
-
The agent supports two JSON output format standards via the `--json-standard` option:
|
|
241
|
-
|
|
242
|
-
#### OpenCode Standard (default)
|
|
243
|
-
|
|
244
|
-
The OpenCode format is the default JSON output format, compatible with `opencode run --format json`:
|
|
245
|
-
|
|
246
|
-
```bash
|
|
247
|
-
echo "hi" | agent --json-standard opencode
|
|
248
|
-
```
|
|
249
|
-
|
|
250
|
-
- **Format**: Pretty-printed JSON (human-readable with indentation)
|
|
251
|
-
- **Event Types**: `step_start`, `step_finish`, `text`, `tool_use`, `error`
|
|
252
|
-
- **Timestamps**: Unix milliseconds (number)
|
|
253
|
-
- **Session ID**: `sessionID` (camelCase)
|
|
254
|
-
|
|
255
|
-
#### Claude Standard (experimental)
|
|
256
|
-
|
|
257
|
-
The Claude format provides compatibility with Anthropic's Claude CLI `--output-format stream-json`:
|
|
258
|
-
|
|
259
|
-
```bash
|
|
260
|
-
echo "hi" | agent --json-standard claude
|
|
261
|
-
```
|
|
262
|
-
|
|
263
|
-
- **Format**: NDJSON (Newline-Delimited JSON - compact, one JSON per line)
|
|
264
|
-
- **Event Types**: `init`, `message`, `tool_use`, `tool_result`, `result`
|
|
265
|
-
- **Timestamps**: ISO 8601 strings
|
|
266
|
-
- **Session ID**: `session_id` (snake_case)
|
|
267
|
-
|
|
268
|
-
### Input Formats
|
|
269
|
-
|
|
270
|
-
**Plain Text (auto-converted):**
|
|
271
|
-
|
|
272
|
-
```bash
|
|
273
|
-
echo "your message here" | agent
|
|
274
|
-
```
|
|
275
|
-
|
|
276
|
-
**JSON Format:**
|
|
277
|
-
|
|
278
|
-
```json
|
|
279
|
-
{
|
|
280
|
-
"message": "Your message here",
|
|
281
|
-
"tools": [
|
|
282
|
-
{
|
|
283
|
-
"name": "bash",
|
|
284
|
-
"params": { "command": "ls -la" }
|
|
285
|
-
}
|
|
286
|
-
]
|
|
287
|
-
}
|
|
288
|
-
```
|
|
289
|
-
|
|
290
|
-
## Supported Tools
|
|
291
|
-
|
|
292
|
-
All 13 tools are **enabled by default** with **no configuration required**. See [TOOLS.md](TOOLS.md) for complete documentation.
|
|
293
|
-
|
|
294
|
-
### File Operations
|
|
295
|
-
|
|
296
|
-
- **`read`** - Read file contents
|
|
297
|
-
- **`write`** - Write files
|
|
298
|
-
- **`edit`** - Edit files with string replacement
|
|
299
|
-
- **`list`** - List directory contents
|
|
300
|
-
|
|
301
|
-
### Search Tools
|
|
302
|
-
|
|
303
|
-
- **`glob`** - File pattern matching (`**/*.js`)
|
|
304
|
-
- **`grep`** - Text search with regex support
|
|
305
|
-
- **`websearch`** ✨ - Web search via Exa API (no config needed!)
|
|
306
|
-
- **`codesearch`** ✨ - Code search via Exa API (no config needed!)
|
|
307
|
-
|
|
308
|
-
### Execution Tools
|
|
309
|
-
|
|
310
|
-
- **`bash`** - Execute shell commands
|
|
311
|
-
- **`batch`** ✨ - Batch multiple tool calls (no config needed!)
|
|
312
|
-
- **`task`** - Launch subagent tasks
|
|
313
|
-
|
|
314
|
-
### Utility Tools
|
|
315
|
-
|
|
316
|
-
- **`todo`** - Task tracking
|
|
317
|
-
- **`webfetch`** - Fetch and process URLs
|
|
318
|
-
|
|
319
|
-
✨ = Always enabled (no experimental flags or environment variables needed)
|
|
320
|
-
|
|
321
|
-
## MCP (Model Context Protocol) Support
|
|
322
|
-
|
|
323
|
-
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.
|
|
324
|
-
|
|
325
|
-
### Installing Playwright MCP
|
|
326
|
-
|
|
327
|
-
Microsoft's Playwright MCP server provides browser automation capabilities using Playwright. This enables the agent to interact with web pages through structured accessibility snapshots.
|
|
328
|
-
|
|
329
|
-
**Requirements:**
|
|
330
|
-
|
|
331
|
-
- Node.js 18 or newer (for running the Playwright MCP server)
|
|
332
|
-
- Bun (for running the agent itself)
|
|
333
|
-
|
|
334
|
-
**Installation:**
|
|
335
|
-
|
|
336
|
-
```bash
|
|
337
|
-
# Add Playwright MCP server to your agent configuration
|
|
338
|
-
agent mcp add playwright npx @playwright/mcp@latest
|
|
339
|
-
|
|
340
|
-
# Verify the configuration
|
|
341
|
-
agent mcp list
|
|
342
|
-
```
|
|
343
|
-
|
|
344
|
-
This will create a configuration file at `~/.config/link-assistant-agent/opencode.json` (or your system's config directory) with:
|
|
345
|
-
|
|
346
|
-
```json
|
|
347
|
-
{
|
|
348
|
-
"$schema": "https://opencode.ai/config.json",
|
|
349
|
-
"mcp": {
|
|
350
|
-
"playwright": {
|
|
351
|
-
"type": "local",
|
|
352
|
-
"command": ["npx", "@playwright/mcp@latest"],
|
|
353
|
-
"enabled": true
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
```
|
|
358
|
-
|
|
359
|
-
**Available Playwright Tools:**
|
|
360
|
-
|
|
361
|
-
Once configured, the agent gains access to 22+ browser automation tools:
|
|
362
|
-
|
|
363
|
-
- `browser_navigate` - Navigate to a URL
|
|
364
|
-
- `browser_click` - Click on an element
|
|
365
|
-
- `browser_type` - Type text into an element
|
|
366
|
-
- `browser_snapshot` - Capture accessibility snapshot
|
|
367
|
-
- `browser_take_screenshot` - Take a screenshot
|
|
368
|
-
- `browser_fill_form` - Fill multiple form fields
|
|
369
|
-
- `browser_select_option` - Select dropdown option
|
|
370
|
-
- `browser_hover` - Hover over element
|
|
371
|
-
- `browser_drag` - Drag and drop
|
|
372
|
-
- `browser_evaluate` - Execute JavaScript
|
|
373
|
-
- `browser_tabs` - Manage browser tabs
|
|
374
|
-
- `browser_close` - Close the browser
|
|
375
|
-
- `browser_wait_for` - Wait for text/element
|
|
376
|
-
- `browser_press_key` - Press keyboard key
|
|
377
|
-
- `browser_handle_dialog` - Handle browser dialogs
|
|
378
|
-
- `browser_network_requests` - Get network requests
|
|
379
|
-
- `browser_console_messages` - Get console messages
|
|
380
|
-
- `browser_file_upload` - Upload files
|
|
381
|
-
- `browser_resize` - Resize browser window
|
|
382
|
-
- `browser_navigate_back` - Navigate back
|
|
383
|
-
- `browser_install` - Install browser
|
|
384
|
-
- `browser_run_code` - Run Playwright code
|
|
385
|
-
|
|
386
|
-
**Usage Example:**
|
|
387
|
-
|
|
388
|
-
```bash
|
|
389
|
-
# Tell the agent to navigate to a website and take a screenshot
|
|
390
|
-
echo "Navigate to https://example.com and take a screenshot" | agent
|
|
391
|
-
```
|
|
392
|
-
|
|
393
|
-
The agent will automatically use the Playwright MCP tools when browser automation is needed.
|
|
394
|
-
|
|
395
|
-
**Learn More:**
|
|
396
|
-
|
|
397
|
-
- [Playwright MCP GitHub Repository](https://github.com/microsoft/playwright-mcp)
|
|
398
|
-
- [Using Playwright MCP with Claude Code](https://til.simonwillison.net/claude-code/playwright-mcp-claude-code)
|
|
399
|
-
- [Playwright MCP Case Study](docs/case-studies/playwright-mcp-support/case-study.md)
|
|
400
|
-
|
|
401
|
-
### Managing MCP Servers
|
|
402
|
-
|
|
403
|
-
**List configured servers:**
|
|
404
|
-
|
|
405
|
-
```bash
|
|
406
|
-
agent mcp list
|
|
407
|
-
```
|
|
408
|
-
|
|
409
|
-
**Add a remote MCP server:**
|
|
410
|
-
|
|
411
|
-
```bash
|
|
412
|
-
agent mcp add myserver --url https://example.com/mcp
|
|
413
|
-
```
|
|
414
|
-
|
|
415
|
-
**Interactive mode:**
|
|
416
|
-
|
|
417
|
-
If you prefer an interactive setup, just run:
|
|
418
|
-
|
|
419
|
-
```bash
|
|
420
|
-
agent mcp add
|
|
421
|
-
```
|
|
422
|
-
|
|
423
|
-
The interactive prompt will guide you through configuring local or remote MCP servers.
|
|
424
|
-
|
|
425
|
-
## Examples
|
|
426
|
-
|
|
427
|
-
See [EXAMPLES.md](EXAMPLES.md) for detailed usage examples of each tool with both agent-cli and opencode commands.
|
|
428
|
-
|
|
429
|
-
## Testing
|
|
430
|
-
|
|
431
|
-
```bash
|
|
432
|
-
# Run all tests
|
|
433
|
-
bun test
|
|
434
|
-
|
|
435
|
-
# Run specific test file
|
|
436
|
-
bun test tests/mcp.test.js
|
|
437
|
-
bun test tests/websearch.tools.test.js
|
|
438
|
-
bun test tests/batch.tools.test.js
|
|
439
|
-
bun test tests/plaintext.input.test.js
|
|
440
|
-
```
|
|
441
|
-
|
|
442
|
-
For detailed testing information including how to run tests manually and trigger CI tests, see [TESTING.md](TESTING.md).
|
|
443
|
-
|
|
444
|
-
## Maintenance
|
|
445
|
-
|
|
446
|
-
### Development
|
|
447
|
-
|
|
448
|
-
Run the agent in development mode:
|
|
449
|
-
|
|
450
|
-
```bash
|
|
451
|
-
bun run dev
|
|
452
|
-
```
|
|
453
|
-
|
|
454
|
-
Or run directly:
|
|
455
|
-
|
|
456
|
-
```bash
|
|
457
|
-
bun run src/index.js
|
|
458
|
-
```
|
|
459
|
-
|
|
460
|
-
### Testing
|
|
461
|
-
|
|
462
|
-
Simply run:
|
|
463
|
-
|
|
464
|
-
```bash
|
|
465
|
-
bun test
|
|
466
|
-
```
|
|
467
|
-
|
|
468
|
-
Bun automatically discovers and runs all `*.test.js` files in the project.
|
|
469
|
-
|
|
470
|
-
### Test Coverage
|
|
471
|
-
|
|
472
|
-
- ✅ 13 tool implementation tests
|
|
473
|
-
- ✅ Plain text input support test
|
|
474
|
-
- ✅ OpenCode compatibility tests for websearch/codesearch
|
|
475
|
-
- ✅ JSON standard unit tests (opencode and claude formats)
|
|
476
|
-
- ✅ All tests pass with 100% OpenCode JSON format compatibility
|
|
477
|
-
|
|
478
|
-
### Publishing
|
|
479
|
-
|
|
480
|
-
To publish a new version to npm:
|
|
481
|
-
|
|
482
|
-
1. **Update version** in `package.json`:
|
|
483
|
-
|
|
484
|
-
```bash
|
|
485
|
-
# Update version field manually (e.g., 0.0.3 -> 0.0.4)
|
|
486
|
-
```
|
|
487
|
-
|
|
488
|
-
2. **Commit changes**:
|
|
489
|
-
|
|
490
|
-
```bash
|
|
491
|
-
git add .
|
|
492
|
-
git commit -m "Release v0.0.4"
|
|
493
|
-
git push
|
|
494
|
-
```
|
|
495
|
-
|
|
496
|
-
3. **Publish to npm**:
|
|
497
|
-
```bash
|
|
498
|
-
npm publish
|
|
499
|
-
```
|
|
500
|
-
|
|
501
|
-
The package publishes source files directly (no build step required). Bun handles TypeScript execution natively.
|
|
502
|
-
|
|
503
|
-
## Key Features
|
|
504
|
-
|
|
505
|
-
### No Configuration Required
|
|
506
|
-
|
|
507
|
-
- **WebSearch/CodeSearch**: Work without `LINK_ASSISTANT_AGENT_EXPERIMENTAL_EXA` environment variable (legacy `OPENCODE_EXPERIMENTAL_EXA` still supported)
|
|
508
|
-
- **Batch Tool**: Always enabled, no experimental flag needed
|
|
509
|
-
- **All Tools**: No config files, API keys handled automatically
|
|
510
|
-
|
|
511
|
-
### OpenCode 100% Compatible
|
|
512
|
-
|
|
513
|
-
- All tools produce JSON output matching OpenCode's exact format
|
|
514
|
-
- WebSearch and CodeSearch tools are verified 100% compatible
|
|
515
|
-
- Tool event structure matches OpenCode specifications
|
|
516
|
-
- Can be used as drop-in replacement for `opencode run --format json`
|
|
517
|
-
|
|
518
|
-
### Plain Text Support
|
|
519
|
-
|
|
520
|
-
Both plain text and JSON input work:
|
|
521
|
-
|
|
522
|
-
```bash
|
|
523
|
-
# Plain text
|
|
524
|
-
echo "hello" | bun run src/index.js
|
|
525
|
-
|
|
526
|
-
# JSON
|
|
527
|
-
echo '{"message":"hello"}' | bun run src/index.js
|
|
528
|
-
```
|
|
529
|
-
|
|
530
|
-
Plain text is automatically converted to `{"message":"your text"}` format.
|
|
531
|
-
|
|
532
|
-
### JSON Event Streaming Output
|
|
533
|
-
|
|
534
|
-
JSON output is pretty-printed for easy readability while maintaining OpenCode compatibility:
|
|
535
|
-
|
|
536
|
-
```bash
|
|
537
|
-
echo "hi" | agent
|
|
538
|
-
```
|
|
539
|
-
|
|
540
|
-
Output (pretty-printed JSON events):
|
|
541
|
-
|
|
542
|
-
```json
|
|
543
|
-
{
|
|
544
|
-
"type": "step_start",
|
|
545
|
-
"timestamp": 1763618628840,
|
|
546
|
-
"sessionID": "ses_560236487ffe3ROK1ThWvPwTEF",
|
|
547
|
-
"part": {
|
|
548
|
-
"id": "prt_a9fdca4e8001APEs6AriJx67me",
|
|
549
|
-
"type": "step-start",
|
|
550
|
-
...
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
{
|
|
554
|
-
"type": "text",
|
|
555
|
-
"timestamp": 1763618629886,
|
|
556
|
-
"sessionID": "ses_560236487ffe3ROK1ThWvPwTEF",
|
|
557
|
-
"part": {
|
|
558
|
-
"id": "prt_a9fdca85c001bVEimWb9L3ya6T",
|
|
559
|
-
"type": "text",
|
|
560
|
-
"text": "Hi! How can I help with your coding tasks today?",
|
|
561
|
-
...
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
{
|
|
565
|
-
"type": "step_finish",
|
|
566
|
-
"timestamp": 1763618629916,
|
|
567
|
-
"sessionID": "ses_560236487ffe3ROK1ThWvPwTEF",
|
|
568
|
-
"part": {
|
|
569
|
-
"id": "prt_a9fdca8ff0015cBrNxckAXI3aE",
|
|
570
|
-
"type": "step-finish",
|
|
571
|
-
"reason": "stop",
|
|
572
|
-
...
|
|
573
|
-
}
|
|
574
|
-
}
|
|
575
|
-
```
|
|
576
|
-
|
|
577
|
-
## Architecture
|
|
578
|
-
|
|
579
|
-
This agent-cli reproduces OpenCode's `run --format json` command architecture:
|
|
580
|
-
|
|
581
|
-
- **Streaming JSON Events**: Real-time event stream output
|
|
582
|
-
- **Event Types**: `tool_use`, `text`, `step_start`, `step_finish`, `error`
|
|
583
|
-
- **Session Management**: Unique session IDs for each request
|
|
584
|
-
- **Tool Execution**: 13 tools with unrestricted access
|
|
585
|
-
- **Compatible Format**: Events match OpenCode's JSON schema exactly
|
|
586
|
-
|
|
587
|
-
## Files
|
|
588
|
-
|
|
589
|
-
- `src/index.js` - Main entry point with JSON/plain text input support
|
|
590
|
-
- `src/session/agent.js` - Agent implementation
|
|
591
|
-
- `src/tool/` - Tool implementations
|
|
592
|
-
- `tests/` - Comprehensive test suite
|
|
593
|
-
- [MODELS.md](MODELS.md) - Available models and pricing
|
|
594
|
-
- [TOOLS.md](TOOLS.md) - Complete tool documentation
|
|
595
|
-
- [EXAMPLES.md](EXAMPLES.md) - Usage examples for each tool
|
|
596
|
-
|
|
597
|
-
## Reference Implementations
|
|
598
|
-
|
|
599
|
-
This repository includes official reference implementations as git submodules to provide best-in-class examples:
|
|
600
|
-
|
|
601
|
-
- **original-opencode** - [OpenCode](https://github.com/sst/opencode) - The original OpenCode implementation we maintain compatibility with
|
|
602
|
-
- **reference-gemini-cookbook** - [Google Gemini Cookbook](https://github.com/google-gemini/cookbook) - Official examples and guides for using the Gemini API
|
|
603
|
-
- **reference-gemini-cli** - [Google Gemini CLI](https://github.com/google-gemini/gemini-cli) - Official AI agent bringing Gemini directly to the terminal
|
|
604
|
-
- **reference-qwen3-coder** - [Qwen3-Coder](https://github.com/QwenLM/Qwen3-Coder) - Official Qwen3 code model from Alibaba Cloud
|
|
605
|
-
|
|
606
|
-
To initialize all submodules:
|
|
607
|
-
|
|
608
|
-
```bash
|
|
609
|
-
git submodule update --init --recursive
|
|
610
|
-
```
|
|
611
|
-
|
|
612
|
-
These reference implementations provide valuable insights into different approaches for building AI agents and can serve as learning resources for developers working with this codebase.
|
|
613
|
-
|
|
614
|
-
## License
|
|
615
|
-
|
|
616
|
-
Unlicense (Public Domain)
|