This document provides practical examples for using each tool with both @link-assistant/agent and opencode commands.
⚠️ Bun-only -@link-assistant/agentrequires Bun and does NOT support Node.js or Deno.
Plain text (@link-assistant/agent only, easiest!):
echo "hi" | agentSimple JSON message (both @link-assistant/agent and opencode):
@link-assistant/agent:
echo '{"message":"hi"}' | agentopencode:
echo '{"message":"hi"}' | opencode run --format json --model opencode/big-pickle# Simple message
echo "hello world" | agent
# Ask a question
echo "what is TypeScript?" | agent
# Request web search
echo "search the web for latest React news" | agent@link-assistant/agent:
echo '{"message":"hello world"}' | agentopencode:
echo '{"message":"hello world"}' | opencode run --format json --model opencode/big-pickleExecute shell commands.
@link-assistant/agent:
echo '{"message":"run command","tools":[{"name":"bash","params":{"command":"echo hello world"}}]}' | agentopencode:
echo '{"message":"run command","tools":[{"name":"bash","params":{"command":"echo hello world"}}]}' | opencode run --format json --model opencode/big-pickleExample with description:
echo '{"message":"list files","tools":[{"name":"bash","params":{"command":"ls -la","description":"List all files in current directory"}}]}' | agentRead file contents.
@link-assistant/agent:
echo '{"message":"read file","tools":[{"name":"read","params":{"file_path":"/path/to/file.txt"}}]}' | agentopencode:
echo '{"message":"read file","tools":[{"name":"read","params":{"file_path":"/path/to/file.txt"}}]}' | opencode run --format json --model opencode/big-pickleWrite content to a file.
@link-assistant/agent:
echo '{"message":"write file","tools":[{"name":"write","params":{"file_path":"/tmp/test.txt","content":"Hello World"}}]}' | agentopencode:
echo '{"message":"write file","tools":[{"name":"write","params":{"file_path":"/tmp/test.txt","content":"Hello World"}}]}' | opencode run --format json --model opencode/big-pickleEdit file with string replacement.
@link-assistant/agent:
echo '{"message":"edit file","tools":[{"name":"edit","params":{"file_path":"/tmp/test.txt","old_string":"Hello","new_string":"Hi"}}]}' | agentopencode:
echo '{"message":"edit file","tools":[{"name":"edit","params":{"file_path":"/tmp/test.txt","old_string":"Hello","new_string":"Hi"}}]}' | opencode run --format json --model opencode/big-pickleList directory contents.
@link-assistant/agent:
echo '{"message":"list directory","tools":[{"name":"list","params":{"path":"."}}]}' | agentopencode:
echo '{"message":"list directory","tools":[{"name":"list","params":{"path":"."}}]}' | opencode run --format json --model opencode/big-pickleFind files using glob patterns.
@link-assistant/agent:
# Find all JavaScript files
echo '{"message":"find js files","tools":[{"name":"glob","params":{"pattern":"**/*.js"}}]}' | agent
# Find TypeScript files in src directory
echo '{"message":"find ts files","tools":[{"name":"glob","params":{"pattern":"src/**/*.ts"}}]}' | agentopencode:
echo '{"message":"find js files","tools":[{"name":"glob","params":{"pattern":"**/*.js"}}]}' | opencode run --format json --model opencode/big-pickleSearch text in files with regex.
@link-assistant/agent:
# Search for pattern in files
echo '{"message":"search pattern","tools":[{"name":"grep","params":{"pattern":"function","output_mode":"files_with_matches"}}]}' | agent
# Search with content display
echo '{"message":"search TODO","tools":[{"name":"grep","params":{"pattern":"TODO","output_mode":"content"}}]}' | agent
# Case-insensitive search in JavaScript files
echo '{"message":"search error","tools":[{"name":"grep","params":{"pattern":"error","-i":true,"type":"js","output_mode":"content"}}]}' | agentopencode:
echo '{"message":"search pattern","tools":[{"name":"grep","params":{"pattern":"TODO","output_mode":"content"}}]}' | opencode run --format json --model opencode/big-pickleSearch the web using Exa API.
@link-assistant/agent (no environment variable needed!):
echo '{"message":"search web","tools":[{"name":"websearch","params":{"query":"TypeScript latest features"}}]}' | agent
echo '{"message":"search web","tools":[{"name":"websearch","params":{"query":"React hooks best practices"}}]}' | agentopencode (requires LINK_ASSISTANT_AGENT_EXPERIMENTAL_EXA=true):
echo '{"message":"search web","tools":[{"name":"websearch","params":{"query":"TypeScript latest features"}}]}' | opencode run --format json --model opencode/big-pickleSearch code repositories and documentation.
@link-assistant/agent (no environment variable needed!):
echo '{"message":"search code","tools":[{"name":"codesearch","params":{"query":"React hooks implementation"}}]}' | agent
echo '{"message":"search code","tools":[{"name":"codesearch","params":{"query":"async/await patterns"}}]}' | agentopencode (requires LINK_ASSISTANT_AGENT_EXPERIMENTAL_EXA=true):
echo '{"message":"search code","tools":[{"name":"codesearch","params":{"query":"React hooks implementation"}}]}' | opencode run --format json --model opencode/big-pickleBatch multiple tool calls together for optimal performance.
@link-assistant/agent (no configuration needed!):
echo '{"message":"run batch","tools":[{"name":"batch","params":{"tool_calls":[{"tool":"bash","parameters":{"command":"echo hello"}},{"tool":"bash","parameters":{"command":"echo world"}}]}}]}' | agentopencode (requires experimental config):
# Create config file first
mkdir -p .link-assistant-agent
echo '{"experimental":{"batch_tool":true}}' > .link-assistant-agent/opencode.json
# Then run
echo '{"message":"run batch","tools":[{"name":"batch","params":{"tool_calls":[{"tool":"bash","parameters":{"command":"echo hello"}},{"tool":"bash","parameters":{"command":"echo world"}}]}}]}' | opencode run --format json --model opencode/big-pickleLaunch specialized agents for complex tasks.
@link-assistant/agent:
echo '{"message":"launch task","tools":[{"name":"task","params":{"description":"Analyze codebase","prompt":"Find all TODO comments in JavaScript files","subagent_type":"general-purpose"}}]}' | agentopencode:
echo '{"message":"launch task","tools":[{"name":"task","params":{"description":"Analyze codebase","prompt":"Find all TODO comments in JavaScript files","subagent_type":"general-purpose"}}]}' | opencode run --format json --model opencode/big-pickleRead and write TODO items for task tracking.
@link-assistant/agent:
# Write todos
echo '{"message":"add todos","tools":[{"name":"todowrite","params":{"todos":[{"content":"Implement feature X","status":"pending","activeForm":"Implementing feature X"},{"content":"Write tests","status":"pending","activeForm":"Writing tests"}]}}]}' | agent
# Read todos
echo '{"message":"read todos","tools":[{"name":"todoread","params":{}}]}' | agentopencode:
echo '{"message":"add todos","tools":[{"name":"todowrite","params":{"todos":[{"content":"Implement feature X","status":"pending","activeForm":"Implementing feature X"}]}}]}' | opencode run --format json --model opencode/big-pickleFetch and process web content.
@link-assistant/agent:
echo '{"message":"fetch url","tools":[{"name":"webfetch","params":{"url":"https://example.com","prompt":"Summarize the content"}}]}' | agentopencode:
echo '{"message":"fetch url","tools":[{"name":"webfetch","params":{"url":"https://example.com","prompt":"Summarize the content"}}]}' | opencode run --format json --model opencode/big-pickle@link-assistant/agent supports two JSON output format standards via the --json-standard option:
# Default - same as --json-standard opencode
echo "hi" | agent
# Explicit opencode standard
echo "hi" | agent --json-standard opencode# Claude CLI compatible format (NDJSON)
echo "hi" | agent --json-standard claude@link-assistant/agent outputs JSON events in pretty-printed streaming format for easy readability, 100% compatible with OpenCode's event structure:
echo "hi" | agentOutput (pretty-printed JSON events):
{
"type": "step_start",
"timestamp": 1763618628840,
"sessionID": "ses_560236487ffe3ROK1ThWvPwTEF",
"part": {
"id": "prt_a9fdca4e8001APEs6AriJx67me",
"type": "step-start",
...
}
}
{
"type": "text",
"timestamp": 1763618629886,
"sessionID": "ses_560236487ffe3ROK1ThWvPwTEF",
"part": {
"type": "text",
"text": "Hi! How can I help with your coding tasks today?",
...
}
}
{
"type": "step_finish",
"timestamp": 1763618629916,
"sessionID": "ses_560236487ffe3ROK1ThWvPwTEF",
"part": {
"type": "step-finish",
"reason": "stop",
...
}
}This format is designed for:
- Readability: Pretty-printed JSON is easy to read and debug
- Streaming: Events output in real-time as they occur
- Compatibility: 100% compatible with OpenCode's event structure
- Automation: Can be parsed using standard JSON tools (see filtering examples below)
When using --json-standard claude, output is in NDJSON (Newline-Delimited JSON) format, compatible with Claude CLI:
echo "hi" | agent --json-standard claudeOutput (compact NDJSON):
{"type":"init","timestamp":"2025-01-01T00:00:00.000Z","session_id":"ses_560236487ffe3ROK1ThWvPwTEF"}
{"type":"message","timestamp":"2025-01-01T00:00:01.000Z","session_id":"ses_560236487ffe3ROK1ThWvPwTEF","role":"assistant","content":[{"type":"text","text":"Hi! How can I help with your coding tasks today?"}]}
{"type":"result","timestamp":"2025-01-01T00:00:01.100Z","session_id":"ses_560236487ffe3ROK1ThWvPwTEF","status":"success","duration_ms":1100}Key differences from OpenCode format:
- Compact: One JSON per line (no pretty-printing)
- Event Types:
init,message,tool_use,tool_result,result - Timestamps: ISO 8601 strings instead of Unix milliseconds
- Session ID:
session_id(snake_case) instead ofsessionID(camelCase) - Content: Message content in array format with
{type, text}objects
Extract specific event types using jq:
# Get only text responses
echo '{"message":"hello"}' | agent | jq -r 'select(.type=="text") | .part.text'
# Get tool use events
echo '{"message":"run","tools":[{"name":"bash","params":{"command":"ls"}}]}' | agent | jq 'select(.type=="tool_use")'
# Get bash tool output
echo '{"message":"run","tools":[{"name":"bash","params":{"command":"echo test"}}]}' | agent | jq -r 'select(.type=="tool_use" and .part.tool=="bash") | .part.state.output'
# Pretty print all events
echo "hello" | agent | jq- No Configuration: WebSearch, CodeSearch, and Batch tools work without any setup
- Plain Text Input: Can use simple text instead of JSON
- Always Enabled: All tools available by default
- Bun-only: Optimized for Bun runtime (no Node.js/Deno overhead)
Use single quotes for the outer shell command and double quotes inside JSON:
echo '{"message":"test","tools":[{"name":"bash","params":{"command":"echo hello"}}]}' | agentAdd | jq to prettify JSON output:
echo "hello" | agent | jqProcess output with standard Unix tools:
# Count events
echo "hello" | agent | wc -l
# Filter and format
echo "hello" | agent | jq -r 'select(.type=="text") | .part.text'