opencode-agent-variants 0.1.0
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/LICENSE +21 -0
- package/README.md +257 -0
- package/agent-variants.example.jsonc +96 -0
- package/dist/config.d.ts +211 -0
- package/dist/config.js +227 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +406 -0
- package/dist/server.d.ts +5 -0
- package/dist/server.js +5 -0
- package/dist/tui.d.ts +6 -0
- package/dist/tui.js +849 -0
- package/docs/CONFIG.md +134 -0
- package/package.json +75 -0
package/docs/CONFIG.md
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# Agent Variants Config
|
|
2
|
+
|
|
3
|
+
The plugin reads `~/.config/opencode/agent-variants.jsonc`. This sidecar file is separate from `opencode.json`; OpenCode config remains the source of truth for providers, base agents, permissions, and built-in behavior.
|
|
4
|
+
|
|
5
|
+
See `agent-variants.example.jsonc` for a fully commented starter file.
|
|
6
|
+
|
|
7
|
+
## Top-Level Fields
|
|
8
|
+
|
|
9
|
+
- `debug`: boolean. Enables routing/model diagnostic toasts and file logging. This is hot-read by the server plugin, so toggling it from the wizard takes effect immediately for future variant calls.
|
|
10
|
+
- `models`: named model shortcuts. Each shortcut has `model` and optional `label`.
|
|
11
|
+
- `agents`: parent-agent entries. Each key is a built-in or configured OpenCode agent name.
|
|
12
|
+
|
|
13
|
+
## Model Shortcuts
|
|
14
|
+
|
|
15
|
+
```jsonc
|
|
16
|
+
"models": {
|
|
17
|
+
"light": {
|
|
18
|
+
"model": "zai-coding-plan/glm-5.1",
|
|
19
|
+
"label": "GLM 5.1"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Variant `model` fields can use either `"light"` or the full `"provider/model"` reference.
|
|
25
|
+
|
|
26
|
+
If a variant resolves to a model that is definitely missing, the plugin skips that variant at startup and shows a warning toast. The sidecar is not modified automatically.
|
|
27
|
+
|
|
28
|
+
## Parent Entries
|
|
29
|
+
|
|
30
|
+
```jsonc
|
|
31
|
+
"agents": {
|
|
32
|
+
"general": {
|
|
33
|
+
"disable": false,
|
|
34
|
+
"parent": {},
|
|
35
|
+
"variants": {}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
- `disable`: disables this sidecar parent and all its variants.
|
|
41
|
+
- `parent`: optional field overrides for the parent agent.
|
|
42
|
+
- `variants`: generated variants grouped under this parent.
|
|
43
|
+
|
|
44
|
+
Parent overrides apply only when the parent has at least one enabled variant.
|
|
45
|
+
|
|
46
|
+
## Supported Override Fields
|
|
47
|
+
|
|
48
|
+
Parents and variants support:
|
|
49
|
+
|
|
50
|
+
- `model`
|
|
51
|
+
- `variant`
|
|
52
|
+
- `temperature`
|
|
53
|
+
- `top_p`
|
|
54
|
+
- `prompt`
|
|
55
|
+
- `prompt_prepend`
|
|
56
|
+
- `prompt_append`
|
|
57
|
+
- `description`
|
|
58
|
+
- `description_prepend`
|
|
59
|
+
- `description_append`
|
|
60
|
+
- `options`
|
|
61
|
+
- `color`
|
|
62
|
+
- `disable`
|
|
63
|
+
|
|
64
|
+
Variants also support:
|
|
65
|
+
|
|
66
|
+
- `name`: custom generated agent name. Defaults to `${parent}-${variantKey}`.
|
|
67
|
+
|
|
68
|
+
The sidecar intentionally does not configure `permission`, `tools`, or `mode`. Those come from the parent.
|
|
69
|
+
|
|
70
|
+
## Description Generation
|
|
71
|
+
|
|
72
|
+
If a variant does not set `description`, the plugin generates:
|
|
73
|
+
|
|
74
|
+
```txt
|
|
75
|
+
Copy of the <parent> agent using <model label>.
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Then it applies `description_prepend` and `description_append`.
|
|
79
|
+
|
|
80
|
+
## Template Variables
|
|
81
|
+
|
|
82
|
+
The following variables work in description and prompt fields:
|
|
83
|
+
|
|
84
|
+
- `{parent}`: parent agent name, such as `general`
|
|
85
|
+
- `{alias}`: generated variant name, such as `general-light`
|
|
86
|
+
- `{variant_key}`: variant key, such as `light`
|
|
87
|
+
- `{model}`: resolved provider/model reference
|
|
88
|
+
- `{model_label}`: model shortcut label or resolved model reference
|
|
89
|
+
- `{routed_agent}`: native routed agent for built-ins, usually the parent
|
|
90
|
+
|
|
91
|
+
Example:
|
|
92
|
+
|
|
93
|
+
```jsonc
|
|
94
|
+
"description_append": "Use {alias} when {parent} does not need the strongest model. Runs on {model_label}."
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Built-In Agents
|
|
98
|
+
|
|
99
|
+
Built-in agents such as `general` and `explore` cannot be externally copied without vendoring OpenCode internals. Their variants are virtual aliases:
|
|
100
|
+
|
|
101
|
+
- the variant appears in the task tool list,
|
|
102
|
+
- the main model calls `task` once with the variant name,
|
|
103
|
+
- the plugin routes execution to the native parent,
|
|
104
|
+
- model/request/prompt overrides are applied,
|
|
105
|
+
- task output is annotated with `agent_variant`, `routed_agent`, and `effective_model`.
|
|
106
|
+
|
|
107
|
+
This preserves native prompts and permissions while making variant selection clear in the transcript.
|
|
108
|
+
|
|
109
|
+
## Config Or Markdown Agents
|
|
110
|
+
|
|
111
|
+
Agents defined in OpenCode config or agent markdown can be copied directly. Their variants are real generated config agents with supported overrides applied.
|
|
112
|
+
|
|
113
|
+
## Conflict And Validation Rules
|
|
114
|
+
|
|
115
|
+
The plugin skips problematic variants instead of producing ambiguous agents:
|
|
116
|
+
|
|
117
|
+
- parent is disabled in sidecar or OpenCode config,
|
|
118
|
+
- parent is unknown,
|
|
119
|
+
- variant alias equals parent name,
|
|
120
|
+
- two variants generate the same alias,
|
|
121
|
+
- generated alias conflicts with an existing agent,
|
|
122
|
+
- variant model is definitely missing.
|
|
123
|
+
|
|
124
|
+
Run `Agent Variants: Configure` -> `Run diagnostics` to inspect these issues.
|
|
125
|
+
|
|
126
|
+
## Debug Log
|
|
127
|
+
|
|
128
|
+
Debug logs are written to:
|
|
129
|
+
|
|
130
|
+
```txt
|
|
131
|
+
~/.config/opencode/agent-variants.debug.log
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
The wizard can view or clear this log.
|
package/package.json
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "opencode-agent-variants",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "OpenCode plugin for creating and managing model variants of agents",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "Mirrowel",
|
|
8
|
+
"homepage": "https://github.com/Mirrowel/opencode-agent-variants#readme",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/Mirrowel/opencode-agent-variants.git"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/Mirrowel/opencode-agent-variants/issues"
|
|
15
|
+
},
|
|
16
|
+
"main": "dist/server.js",
|
|
17
|
+
"types": "dist/server.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/server.d.ts",
|
|
21
|
+
"import": "./dist/server.js"
|
|
22
|
+
},
|
|
23
|
+
"./server": {
|
|
24
|
+
"types": "./dist/server.d.ts",
|
|
25
|
+
"import": "./dist/server.js"
|
|
26
|
+
},
|
|
27
|
+
"./tui": {
|
|
28
|
+
"types": "./dist/tui.d.ts",
|
|
29
|
+
"import": "./dist/tui.js"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"dist",
|
|
34
|
+
"docs/CONFIG.md",
|
|
35
|
+
"agent-variants.example.jsonc",
|
|
36
|
+
"README.md",
|
|
37
|
+
"LICENSE"
|
|
38
|
+
],
|
|
39
|
+
"keywords": [
|
|
40
|
+
"opencode",
|
|
41
|
+
"opencode-plugin",
|
|
42
|
+
"agent",
|
|
43
|
+
"subagent",
|
|
44
|
+
"model",
|
|
45
|
+
"variants"
|
|
46
|
+
],
|
|
47
|
+
"oc-plugin": [
|
|
48
|
+
"server",
|
|
49
|
+
"tui"
|
|
50
|
+
],
|
|
51
|
+
"publishConfig": {
|
|
52
|
+
"registry": "https://registry.npmjs.org/",
|
|
53
|
+
"access": "public"
|
|
54
|
+
},
|
|
55
|
+
"scripts": {
|
|
56
|
+
"clean": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
|
|
57
|
+
"build": "npm run clean && tsc --outDir dist --declaration",
|
|
58
|
+
"ci": "npm run typecheck && npm run build && npm pack --dry-run",
|
|
59
|
+
"pack:dry-run": "npm pack --dry-run",
|
|
60
|
+
"typecheck": "tsc --noEmit",
|
|
61
|
+
"prepublishOnly": "npm run typecheck && npm run build"
|
|
62
|
+
},
|
|
63
|
+
"dependencies": {
|
|
64
|
+
"@opencode-ai/plugin": "^1.14.39",
|
|
65
|
+
"comment-json": "^4.2.5",
|
|
66
|
+
"zod": "^4.1.8"
|
|
67
|
+
},
|
|
68
|
+
"devDependencies": {
|
|
69
|
+
"@types/node": "^22.0.0",
|
|
70
|
+
"typescript": "^5.8.0"
|
|
71
|
+
},
|
|
72
|
+
"peerDependencies": {
|
|
73
|
+
"@opencode-ai/plugin": ">=1.14.0"
|
|
74
|
+
}
|
|
75
|
+
}
|