@link-assistant/agent 0.0.8

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 (133) hide show
  1. package/EXAMPLES.md +383 -0
  2. package/LICENSE +24 -0
  3. package/MODELS.md +95 -0
  4. package/README.md +388 -0
  5. package/TOOLS.md +134 -0
  6. package/package.json +89 -0
  7. package/src/agent/agent.ts +150 -0
  8. package/src/agent/generate.txt +75 -0
  9. package/src/auth/index.ts +64 -0
  10. package/src/bun/index.ts +96 -0
  11. package/src/bus/global.ts +10 -0
  12. package/src/bus/index.ts +119 -0
  13. package/src/cli/bootstrap.js +41 -0
  14. package/src/cli/bootstrap.ts +17 -0
  15. package/src/cli/cmd/agent.ts +165 -0
  16. package/src/cli/cmd/cmd.ts +5 -0
  17. package/src/cli/cmd/export.ts +88 -0
  18. package/src/cli/cmd/mcp.ts +80 -0
  19. package/src/cli/cmd/models.ts +58 -0
  20. package/src/cli/cmd/run.ts +359 -0
  21. package/src/cli/cmd/stats.ts +276 -0
  22. package/src/cli/error.ts +27 -0
  23. package/src/command/index.ts +73 -0
  24. package/src/command/template/initialize.txt +10 -0
  25. package/src/config/config.ts +705 -0
  26. package/src/config/markdown.ts +41 -0
  27. package/src/file/ripgrep.ts +391 -0
  28. package/src/file/time.ts +38 -0
  29. package/src/file/watcher.ts +75 -0
  30. package/src/file.ts +6 -0
  31. package/src/flag/flag.ts +19 -0
  32. package/src/format/formatter.ts +248 -0
  33. package/src/format/index.ts +137 -0
  34. package/src/global/index.ts +52 -0
  35. package/src/id/id.ts +72 -0
  36. package/src/index.js +371 -0
  37. package/src/mcp/index.ts +289 -0
  38. package/src/patch/index.ts +622 -0
  39. package/src/project/bootstrap.ts +22 -0
  40. package/src/project/instance.ts +67 -0
  41. package/src/project/project.ts +105 -0
  42. package/src/project/state.ts +65 -0
  43. package/src/provider/models-macro.ts +11 -0
  44. package/src/provider/models.ts +98 -0
  45. package/src/provider/opencode.js +47 -0
  46. package/src/provider/provider.ts +636 -0
  47. package/src/provider/transform.ts +241 -0
  48. package/src/server/project.ts +48 -0
  49. package/src/server/server.ts +249 -0
  50. package/src/session/agent.js +204 -0
  51. package/src/session/compaction.ts +249 -0
  52. package/src/session/index.ts +380 -0
  53. package/src/session/message-v2.ts +758 -0
  54. package/src/session/message.ts +189 -0
  55. package/src/session/processor.ts +356 -0
  56. package/src/session/prompt/anthropic-20250930.txt +166 -0
  57. package/src/session/prompt/anthropic.txt +105 -0
  58. package/src/session/prompt/anthropic_spoof.txt +1 -0
  59. package/src/session/prompt/beast.txt +147 -0
  60. package/src/session/prompt/build-switch.txt +5 -0
  61. package/src/session/prompt/codex.txt +318 -0
  62. package/src/session/prompt/copilot-gpt-5.txt +143 -0
  63. package/src/session/prompt/gemini.txt +155 -0
  64. package/src/session/prompt/grok-code.txt +1 -0
  65. package/src/session/prompt/plan.txt +8 -0
  66. package/src/session/prompt/polaris.txt +107 -0
  67. package/src/session/prompt/qwen.txt +109 -0
  68. package/src/session/prompt/summarize-turn.txt +5 -0
  69. package/src/session/prompt/summarize.txt +10 -0
  70. package/src/session/prompt/title.txt +25 -0
  71. package/src/session/prompt.ts +1390 -0
  72. package/src/session/retry.ts +53 -0
  73. package/src/session/revert.ts +108 -0
  74. package/src/session/status.ts +75 -0
  75. package/src/session/summary.ts +179 -0
  76. package/src/session/system.ts +138 -0
  77. package/src/session/todo.ts +36 -0
  78. package/src/snapshot/index.ts +197 -0
  79. package/src/storage/storage.ts +226 -0
  80. package/src/tool/bash.ts +193 -0
  81. package/src/tool/bash.txt +121 -0
  82. package/src/tool/batch.ts +173 -0
  83. package/src/tool/batch.txt +28 -0
  84. package/src/tool/codesearch.ts +123 -0
  85. package/src/tool/codesearch.txt +12 -0
  86. package/src/tool/edit.ts +604 -0
  87. package/src/tool/edit.txt +10 -0
  88. package/src/tool/glob.ts +65 -0
  89. package/src/tool/glob.txt +6 -0
  90. package/src/tool/grep.ts +116 -0
  91. package/src/tool/grep.txt +8 -0
  92. package/src/tool/invalid.ts +17 -0
  93. package/src/tool/ls.ts +110 -0
  94. package/src/tool/ls.txt +1 -0
  95. package/src/tool/multiedit.ts +46 -0
  96. package/src/tool/multiedit.txt +41 -0
  97. package/src/tool/patch.ts +188 -0
  98. package/src/tool/patch.txt +1 -0
  99. package/src/tool/read.ts +201 -0
  100. package/src/tool/read.txt +12 -0
  101. package/src/tool/registry.ts +87 -0
  102. package/src/tool/task.ts +126 -0
  103. package/src/tool/task.txt +60 -0
  104. package/src/tool/todo.ts +39 -0
  105. package/src/tool/todoread.txt +14 -0
  106. package/src/tool/todowrite.txt +167 -0
  107. package/src/tool/tool.ts +66 -0
  108. package/src/tool/webfetch.ts +171 -0
  109. package/src/tool/webfetch.txt +14 -0
  110. package/src/tool/websearch.ts +133 -0
  111. package/src/tool/websearch.txt +11 -0
  112. package/src/tool/write.ts +33 -0
  113. package/src/tool/write.txt +8 -0
  114. package/src/util/binary.ts +41 -0
  115. package/src/util/context.ts +25 -0
  116. package/src/util/defer.ts +12 -0
  117. package/src/util/error.ts +54 -0
  118. package/src/util/eventloop.ts +20 -0
  119. package/src/util/filesystem.ts +69 -0
  120. package/src/util/fn.ts +11 -0
  121. package/src/util/iife.ts +3 -0
  122. package/src/util/keybind.ts +79 -0
  123. package/src/util/lazy.ts +11 -0
  124. package/src/util/locale.ts +39 -0
  125. package/src/util/lock.ts +98 -0
  126. package/src/util/log.ts +177 -0
  127. package/src/util/queue.ts +19 -0
  128. package/src/util/rpc.ts +42 -0
  129. package/src/util/scrap.ts +10 -0
  130. package/src/util/signal.ts +12 -0
  131. package/src/util/timeout.ts +14 -0
  132. package/src/util/token.ts +7 -0
  133. package/src/util/wildcard.ts +54 -0
package/EXAMPLES.md ADDED
@@ -0,0 +1,383 @@
1
+ # Usage Examples
2
+
3
+ This document provides practical examples for using each tool with both `@link-assistant/agent` and `opencode` commands.
4
+
5
+ > ⚠️ **Bun-only** - `@link-assistant/agent` requires [Bun](https://bun.sh) and does NOT support Node.js or Deno.
6
+
7
+ ## Table of Contents
8
+
9
+ - [Basic Usage](#basic-usage)
10
+ - [File Operations](#file-operations)
11
+ - [Search Tools](#search-tools)
12
+ - [Execution Tools](#execution-tools)
13
+ - [Utility Tools](#utility-tools)
14
+
15
+ ## Basic Usage
16
+
17
+ ### Simplest Examples - Start Here!
18
+
19
+ **Plain text (@link-assistant/agent only, easiest!):**
20
+ ```bash
21
+ echo "hi" | agent
22
+ ```
23
+
24
+ **Simple JSON message (both @link-assistant/agent and opencode):**
25
+
26
+ @link-assistant/agent:
27
+ ```bash
28
+ echo '{"message":"hi"}' | agent
29
+ ```
30
+
31
+ opencode:
32
+ ```bash
33
+ echo '{"message":"hi"}' | opencode run --format json --model opencode/grok-code
34
+ ```
35
+
36
+ ### Plain Text Input (@link-assistant/agent only)
37
+
38
+ ```bash
39
+ # Simple message
40
+ echo "hello world" | agent
41
+
42
+ # Ask a question
43
+ echo "what is TypeScript?" | agent
44
+
45
+ # Request web search
46
+ echo "search the web for latest React news" | agent
47
+ ```
48
+
49
+ ### JSON Input Examples
50
+
51
+ **@link-assistant/agent:**
52
+ ```bash
53
+ echo '{"message":"hello world"}' | agent
54
+ ```
55
+
56
+ **opencode:**
57
+ ```bash
58
+ echo '{"message":"hello world"}' | opencode run --format json --model opencode/grok-code
59
+ ```
60
+
61
+ ## File Operations
62
+
63
+ ### bash Tool
64
+
65
+ Execute shell commands.
66
+
67
+ **@link-assistant/agent:**
68
+ ```bash
69
+ echo '{"message":"run command","tools":[{"name":"bash","params":{"command":"echo hello world"}}]}' | agent
70
+ ```
71
+
72
+ **opencode:**
73
+ ```bash
74
+ echo '{"message":"run command","tools":[{"name":"bash","params":{"command":"echo hello world"}}]}' | opencode run --format json --model opencode/grok-code
75
+ ```
76
+
77
+ **Example with description:**
78
+ ```bash
79
+ echo '{"message":"list files","tools":[{"name":"bash","params":{"command":"ls -la","description":"List all files in current directory"}}]}' | agent
80
+ ```
81
+
82
+ ### read Tool
83
+
84
+ Read file contents.
85
+
86
+ **@link-assistant/agent:**
87
+ ```bash
88
+ echo '{"message":"read file","tools":[{"name":"read","params":{"file_path":"/path/to/file.txt"}}]}' | agent
89
+ ```
90
+
91
+ **opencode:**
92
+ ```bash
93
+ echo '{"message":"read file","tools":[{"name":"read","params":{"file_path":"/path/to/file.txt"}}]}' | opencode run --format json --model opencode/grok-code
94
+ ```
95
+
96
+ ### write Tool
97
+
98
+ Write content to a file.
99
+
100
+ **@link-assistant/agent:**
101
+ ```bash
102
+ echo '{"message":"write file","tools":[{"name":"write","params":{"file_path":"/tmp/test.txt","content":"Hello World"}}]}' | agent
103
+ ```
104
+
105
+ **opencode:**
106
+ ```bash
107
+ echo '{"message":"write file","tools":[{"name":"write","params":{"file_path":"/tmp/test.txt","content":"Hello World"}}]}' | opencode run --format json --model opencode/grok-code
108
+ ```
109
+
110
+ ### edit Tool
111
+
112
+ Edit file with string replacement.
113
+
114
+ **@link-assistant/agent:**
115
+ ```bash
116
+ echo '{"message":"edit file","tools":[{"name":"edit","params":{"file_path":"/tmp/test.txt","old_string":"Hello","new_string":"Hi"}}]}' | agent
117
+ ```
118
+
119
+ **opencode:**
120
+ ```bash
121
+ 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/grok-code
122
+ ```
123
+
124
+ ### list Tool
125
+
126
+ List directory contents.
127
+
128
+ **@link-assistant/agent:**
129
+ ```bash
130
+ echo '{"message":"list directory","tools":[{"name":"list","params":{"path":"."}}]}' | agent
131
+ ```
132
+
133
+ **opencode:**
134
+ ```bash
135
+ echo '{"message":"list directory","tools":[{"name":"list","params":{"path":"."}}]}' | opencode run --format json --model opencode/grok-code
136
+ ```
137
+
138
+ ## Search Tools
139
+
140
+ ### glob Tool
141
+
142
+ Find files using glob patterns.
143
+
144
+ **@link-assistant/agent:**
145
+ ```bash
146
+ # Find all JavaScript files
147
+ echo '{"message":"find js files","tools":[{"name":"glob","params":{"pattern":"**/*.js"}}]}' | agent
148
+
149
+ # Find TypeScript files in src directory
150
+ echo '{"message":"find ts files","tools":[{"name":"glob","params":{"pattern":"src/**/*.ts"}}]}' | agent
151
+ ```
152
+
153
+ **opencode:**
154
+ ```bash
155
+ echo '{"message":"find js files","tools":[{"name":"glob","params":{"pattern":"**/*.js"}}]}' | opencode run --format json --model opencode/grok-code
156
+ ```
157
+
158
+ ### grep Tool
159
+
160
+ Search text in files with regex.
161
+
162
+ **@link-assistant/agent:**
163
+ ```bash
164
+ # Search for pattern in files
165
+ echo '{"message":"search pattern","tools":[{"name":"grep","params":{"pattern":"function","output_mode":"files_with_matches"}}]}' | agent
166
+
167
+ # Search with content display
168
+ echo '{"message":"search TODO","tools":[{"name":"grep","params":{"pattern":"TODO","output_mode":"content"}}]}' | agent
169
+
170
+ # Case-insensitive search in JavaScript files
171
+ echo '{"message":"search error","tools":[{"name":"grep","params":{"pattern":"error","-i":true,"type":"js","output_mode":"content"}}]}' | agent
172
+ ```
173
+
174
+ **opencode:**
175
+ ```bash
176
+ echo '{"message":"search pattern","tools":[{"name":"grep","params":{"pattern":"TODO","output_mode":"content"}}]}' | opencode run --format json --model opencode/grok-code
177
+ ```
178
+
179
+ ### websearch Tool
180
+
181
+ Search the web using Exa API.
182
+
183
+ **@link-assistant/agent (no environment variable needed!):**
184
+ ```bash
185
+ echo '{"message":"search web","tools":[{"name":"websearch","params":{"query":"TypeScript latest features"}}]}' | agent
186
+
187
+ echo '{"message":"search web","tools":[{"name":"websearch","params":{"query":"React hooks best practices"}}]}' | agent
188
+ ```
189
+
190
+ **opencode (requires OPENCODE_EXPERIMENTAL_EXA=true):**
191
+ ```bash
192
+ echo '{"message":"search web","tools":[{"name":"websearch","params":{"query":"TypeScript latest features"}}]}' | OPENCODE_EXPERIMENTAL_EXA=true opencode run --format json --model opencode/grok-code
193
+ ```
194
+
195
+ ### codesearch Tool
196
+
197
+ Search code repositories and documentation.
198
+
199
+ **@link-assistant/agent (no environment variable needed!):**
200
+ ```bash
201
+ echo '{"message":"search code","tools":[{"name":"codesearch","params":{"query":"React hooks implementation"}}]}' | agent
202
+
203
+ echo '{"message":"search code","tools":[{"name":"codesearch","params":{"query":"async/await patterns"}}]}' | agent
204
+ ```
205
+
206
+ **opencode (requires OPENCODE_EXPERIMENTAL_EXA=true):**
207
+ ```bash
208
+ echo '{"message":"search code","tools":[{"name":"codesearch","params":{"query":"React hooks implementation"}}]}' | OPENCODE_EXPERIMENTAL_EXA=true opencode run --format json --model opencode/grok-code
209
+ ```
210
+
211
+ ## Execution Tools
212
+
213
+ ### batch Tool
214
+
215
+ Batch multiple tool calls together for optimal performance.
216
+
217
+ **@link-assistant/agent (no configuration needed!):**
218
+ ```bash
219
+ echo '{"message":"run batch","tools":[{"name":"batch","params":{"tool_calls":[{"tool":"bash","parameters":{"command":"echo hello"}},{"tool":"bash","parameters":{"command":"echo world"}}]}}]}' | agent
220
+ ```
221
+
222
+ **opencode (requires experimental config):**
223
+ ```bash
224
+ # Create config file first
225
+ mkdir -p .opencode
226
+ echo '{"experimental":{"batch_tool":true}}' > .opencode/config.json
227
+
228
+ # Then run
229
+ 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/grok-code
230
+ ```
231
+
232
+ ### task Tool
233
+
234
+ Launch specialized agents for complex tasks.
235
+
236
+ **@link-assistant/agent:**
237
+ ```bash
238
+ echo '{"message":"launch task","tools":[{"name":"task","params":{"description":"Analyze codebase","prompt":"Find all TODO comments in JavaScript files","subagent_type":"general-purpose"}}]}' | agent
239
+ ```
240
+
241
+ **opencode:**
242
+ ```bash
243
+ 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/grok-code
244
+ ```
245
+
246
+ ## Utility Tools
247
+
248
+ ### todo Tool
249
+
250
+ Read and write TODO items for task tracking.
251
+
252
+ **@link-assistant/agent:**
253
+ ```bash
254
+ # Write todos
255
+ 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
256
+
257
+ # Read todos
258
+ echo '{"message":"read todos","tools":[{"name":"todoread","params":{}}]}' | agent
259
+ ```
260
+
261
+ **opencode:**
262
+ ```bash
263
+ 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/grok-code
264
+ ```
265
+
266
+ ### webfetch Tool
267
+
268
+ Fetch and process web content.
269
+
270
+ **@link-assistant/agent:**
271
+ ```bash
272
+ echo '{"message":"fetch url","tools":[{"name":"webfetch","params":{"url":"https://example.com","prompt":"Summarize the content"}}]}' | agent
273
+ ```
274
+
275
+ **opencode:**
276
+ ```bash
277
+ echo '{"message":"fetch url","tools":[{"name":"webfetch","params":{"url":"https://example.com","prompt":"Summarize the content"}}]}' | opencode run --format json --model opencode/grok-code
278
+ ```
279
+
280
+ ## Output Format
281
+
282
+ ### JSON Event Streaming (Pretty-Printed)
283
+
284
+ @link-assistant/agent outputs JSON events in pretty-printed streaming format for easy readability, 100% compatible with OpenCode's event structure:
285
+
286
+ ```bash
287
+ echo "hi" | agent
288
+ ```
289
+
290
+ Output (pretty-printed JSON events):
291
+ ```json
292
+ {
293
+ "type": "step_start",
294
+ "timestamp": 1763618628840,
295
+ "sessionID": "ses_560236487ffe3ROK1ThWvPwTEF",
296
+ "part": {
297
+ "id": "prt_a9fdca4e8001APEs6AriJx67me",
298
+ "type": "step-start",
299
+ ...
300
+ }
301
+ }
302
+ {
303
+ "type": "text",
304
+ "timestamp": 1763618629886,
305
+ "sessionID": "ses_560236487ffe3ROK1ThWvPwTEF",
306
+ "part": {
307
+ "type": "text",
308
+ "text": "Hi! How can I help with your coding tasks today?",
309
+ ...
310
+ }
311
+ }
312
+ {
313
+ "type": "step_finish",
314
+ "timestamp": 1763618629916,
315
+ "sessionID": "ses_560236487ffe3ROK1ThWvPwTEF",
316
+ "part": {
317
+ "type": "step-finish",
318
+ "reason": "stop",
319
+ ...
320
+ }
321
+ }
322
+ ```
323
+
324
+ This format is designed for:
325
+ - **Readability**: Pretty-printed JSON is easy to read and debug
326
+ - **Streaming**: Events output in real-time as they occur
327
+ - **Compatibility**: 100% compatible with OpenCode's event structure
328
+ - **Automation**: Can be parsed using standard JSON tools (see filtering examples below)
329
+
330
+ ### Filtering Output
331
+
332
+ Extract specific event types using `jq`:
333
+
334
+ ```bash
335
+ # Get only text responses
336
+ echo '{"message":"hello"}' | agent | jq -r 'select(.type=="text") | .part.text'
337
+
338
+ # Get tool use events
339
+ echo '{"message":"run","tools":[{"name":"bash","params":{"command":"ls"}}]}' | agent | jq 'select(.type=="tool_use")'
340
+
341
+ # Get bash tool output
342
+ echo '{"message":"run","tools":[{"name":"bash","params":{"command":"echo test"}}]}' | agent | jq -r 'select(.type=="tool_use" and .part.tool=="bash") | .part.state.output'
343
+
344
+ # Pretty print all events
345
+ echo "hello" | agent | jq
346
+ ```
347
+
348
+ ## Tips
349
+
350
+ ### @link-assistant/agent Advantages
351
+
352
+ 1. **No Configuration**: WebSearch, CodeSearch, and Batch tools work without any setup
353
+ 2. **Plain Text Input**: Can use simple text instead of JSON
354
+ 3. **Always Enabled**: All tools available by default
355
+ 4. **Bun-only**: Optimized for Bun runtime (no Node.js/Deno overhead)
356
+
357
+ ### Working with JSON
358
+
359
+ Use single quotes for the outer shell command and double quotes inside JSON:
360
+
361
+ ```bash
362
+ echo '{"message":"test","tools":[{"name":"bash","params":{"command":"echo hello"}}]}' | agent
363
+ ```
364
+
365
+ ### Debugging
366
+
367
+ Add `| jq` to prettify JSON output:
368
+
369
+ ```bash
370
+ echo "hello" | agent | jq
371
+ ```
372
+
373
+ ### Chaining Commands
374
+
375
+ Process output with standard Unix tools:
376
+
377
+ ```bash
378
+ # Count events
379
+ echo "hello" | agent | wc -l
380
+
381
+ # Filter and format
382
+ echo "hello" | agent | jq -r 'select(.type=="text") | .part.text'
383
+ ```
package/LICENSE ADDED
@@ -0,0 +1,24 @@
1
+ This is free and unencumbered software released into the public domain.
2
+
3
+ Anyone is free to copy, modify, publish, use, compile, sell, or
4
+ distribute this software, either in source code form or as a compiled
5
+ binary, for any purpose, commercial or non-commercial, and by any
6
+ means.
7
+
8
+ In jurisdictions that recognize copyright laws, the author or authors
9
+ of this software dedicate any and all copyright interest in the
10
+ software to the public domain. We make this dedication for the benefit
11
+ of the public at large and to the detriment of our heirs and
12
+ successors. We intend this dedication to be an overt act of
13
+ relinquishment in perpetuity of all present and future rights to this
14
+ software under copyright law.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
23
+
24
+ For more information, please refer to <https://unlicense.org>
package/MODELS.md ADDED
@@ -0,0 +1,95 @@
1
+ # Models
2
+
3
+ This agent uses models from the [OpenCode Zen](https://opencode.ai/docs/zen/) subscription service. OpenCode Zen provides access to a wide variety of AI models through a unified API.
4
+
5
+ ## Available Models
6
+
7
+ All models are accessed using the format `opencode/<model-id>`. Use the `--model` option to specify which model to use:
8
+
9
+ ```bash
10
+ echo "hi" | agent --model opencode/grok-code
11
+ ```
12
+
13
+ ## OpenCode Zen Pricing
14
+
15
+ Below are the prices per 1M tokens for OpenCode Zen models. Models are sorted by output price (lowest first) for best pricing visibility.
16
+
17
+ | Model | Model ID | Input | Output | Cached Read | Cached Write |
18
+ |-------|----------|-------|--------|-------------|--------------|
19
+ | **Free Models (Output: $0.00)** |
20
+ | Grok Code Fast 1 | `opencode/grok-code` | Free | Free | Free | - |
21
+ | GPT 5 Nano | `opencode/gpt-5-nano` | Free | Free | Free | - |
22
+ | Big Pickle | `opencode/big-pickle` | Free | Free | Free | - |
23
+ | **Paid Models (sorted by output price)** |
24
+ | Qwen3 Coder 480B | `opencode/qwen3-coder-480b` | $0.45 | $1.50 | - | - |
25
+ | GLM 4.6 | `opencode/glm-4-6` | $0.60 | $2.20 | $0.10 | - |
26
+ | Kimi K2 | `opencode/kimi-k2` | $0.60 | $2.50 | $0.36 | - |
27
+ | Claude Haiku 3.5 | `opencode/claude-haiku-3-5` | $0.80 | $4.00 | $0.08 | $1.00 |
28
+ | Claude Haiku 4.5 | `opencode/haiku` | $1.00 | $5.00 | $0.10 | $1.25 |
29
+ | GPT 5.1 | `opencode/gpt-5-1` | $1.25 | $10.00 | $0.125 | - |
30
+ | GPT 5.1 Codex | `opencode/gpt-5-1-codex` | $1.25 | $10.00 | $0.125 | - |
31
+ | GPT 5 | `opencode/gpt-5` | $1.25 | $10.00 | $0.125 | - |
32
+ | GPT 5 Codex | `opencode/gpt-5-codex` | $1.25 | $10.00 | $0.125 | - |
33
+ | Gemini 3 Pro (≤ 200K tokens) | `opencode/gemini-3-pro` | $2.00 | $12.00 | $0.20 | - |
34
+ | Claude Sonnet 4.5 (≤ 200K tokens) | `opencode/sonnet` | $3.00 | $15.00 | $0.30 | $3.75 |
35
+ | Claude Sonnet 4 (≤ 200K tokens) | `opencode/claude-sonnet-4` | $3.00 | $15.00 | $0.30 | $3.75 |
36
+ | Gemini 3 Pro (> 200K tokens) | `opencode/gemini-3-pro` | $4.00 | $18.00 | $0.40 | - |
37
+ | Claude Sonnet 4.5 (> 200K tokens) | `opencode/sonnet` | $6.00 | $22.50 | $0.60 | $7.50 |
38
+ | Claude Sonnet 4 (> 200K tokens) | `opencode/claude-sonnet-4` | $6.00 | $22.50 | $0.60 | $7.50 |
39
+ | Claude Opus 4.1 | `opencode/opus` | $15.00 | $75.00 | $1.50 | $18.75 |
40
+
41
+ ## Default Model
42
+
43
+ The default model is **Grok Code Fast 1** (`opencode/grok-code`), which is completely free. This model provides excellent performance for coding tasks with no cost.
44
+
45
+ ## Usage Examples
46
+
47
+ ### Using the Default Model (Free)
48
+
49
+ ```bash
50
+ # Uses opencode/grok-code by default
51
+ echo "hello" | agent
52
+ ```
53
+
54
+ ### Using Other Free Models
55
+
56
+ ```bash
57
+ # Big Pickle (free)
58
+ echo "hello" | agent --model opencode/big-pickle
59
+
60
+ # GPT 5 Nano (free)
61
+ echo "hello" | agent --model opencode/gpt-5-nano
62
+ ```
63
+
64
+ ### Using Paid Models
65
+
66
+ ```bash
67
+ # Claude Sonnet 4.5 (best quality)
68
+ echo "hello" | agent --model opencode/sonnet
69
+
70
+ # Claude Haiku 4.5 (fast and affordable)
71
+ echo "hello" | agent --model opencode/haiku
72
+
73
+ # Claude Opus 4.1 (most capable)
74
+ echo "hello" | agent --model opencode/opus
75
+
76
+ # Gemini 3 Pro
77
+ echo "hello" | agent --model opencode/gemini-3-pro
78
+
79
+ # GPT 5.1
80
+ echo "hello" | agent --model opencode/gpt-5-1
81
+
82
+ # Qwen3 Coder (specialized for coding)
83
+ echo "hello" | agent --model opencode/qwen3-coder-480b
84
+ ```
85
+
86
+ ## More Information
87
+
88
+ For complete details about OpenCode Zen subscription and pricing, visit the [OpenCode Zen Documentation](https://opencode.ai/docs/zen/).
89
+
90
+ ## Notes
91
+
92
+ - All prices are per 1 million tokens
93
+ - Cache pricing applies when using prompt caching features
94
+ - Token context limits vary by model
95
+ - Free models have no token costs but may have rate limits