opencode-skill-autodiscovery 1.6.1 → 2.0.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/README.md +253 -45
- package/dist/agents.d.ts.map +1 -1
- package/dist/agents.js +25 -0
- package/dist/agents.js.map +1 -1
- package/dist/discovery.d.ts +19 -9
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +185 -107
- package/dist/discovery.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -7
- package/dist/index.js.map +1 -1
- package/dist/mcp.d.ts.map +1 -1
- package/dist/mcp.js +7 -1
- package/dist/mcp.js.map +1 -1
- package/dist/schema.d.ts +1 -0
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +10 -0
- package/dist/schema.js.map +1 -1
- package/package.json +47 -47
package/README.md
CHANGED
|
@@ -1,22 +1,53 @@
|
|
|
1
1
|
# opencode-skill-autodiscovery
|
|
2
2
|
|
|
3
|
-
An [opencode](https://opencode.ai) plugin that auto-discovers skills
|
|
3
|
+
An [opencode](https://opencode.ai) plugin that auto-discovers skills installed by
|
|
4
|
+
VS Code agent plugins, Claude Code plugins, and [Agent Plugins
|
|
5
|
+
1.0.0](https://agent-plugins.org) conformant packages on the current machine,
|
|
6
|
+
and registers them with opencode's `skills.paths` so they appear in every
|
|
7
|
+
session. Each discovered skill is also exposed as a `/skill-name` slash command
|
|
8
|
+
that loads the skill and routes the rest of your message through it.
|
|
4
9
|
|
|
5
10
|
## Why
|
|
6
11
|
|
|
7
|
-
Skills live in different places depending on the tool, OS, and local vs remote
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
- VS Code agent plugins
|
|
12
|
+
Skills live in different places depending on the tool, OS, and local vs remote
|
|
13
|
+
setup:
|
|
14
|
+
|
|
15
|
+
- VS Code agent plugins, local client: `~/.vscode/agent-plugins` (Windows /
|
|
16
|
+
older builds), `~/.config/Code/agentPlugins` (Linux),
|
|
17
|
+
`~/Library/Application Support/Code/agentPlugins` (macOS), and
|
|
18
|
+
`%APPDATA%\Code\agentPlugins` (Windows), plus `Code - Insiders` variants.
|
|
19
|
+
The install layout is `{host}/{org}/{repo}`, with optional `installed.json`
|
|
20
|
+
and `cache.json` manifests alongside.
|
|
21
|
+
- VS Code agent plugins on a remote host (Remote-SSH, Codespaces, Dev
|
|
22
|
+
Containers, WSL): `~/.vscode-server/data/agentPlugins`. VS Code syncs the
|
|
23
|
+
enabled skills from your local client into a synthetic "VS Code Synced
|
|
24
|
+
Data" plugin materialized at
|
|
25
|
+
`~/.vscode-server/data/agentPlugins/{sanitizedUri}/{nonce}/skills/...`, and
|
|
26
|
+
records each synced bundle in `~/.vscode-server/data/agentPlugins/cache.json`.
|
|
11
27
|
- Claude Code plugins: `~/.claude/plugins/installed_plugins.json`
|
|
12
|
-
- Claude Code plugins on a remote host (SSH/remote sessions):
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
28
|
+
- Claude Code plugins on a remote host (SSH/remote sessions):
|
|
29
|
+
`~/.claude/remote/plugins/installed_plugins.json`
|
|
30
|
+
- **Agent Plugins 1.0.0 packages** distributed via npm. opencode installs npm
|
|
31
|
+
plugins into its own cache (`~/.cache/opencode/packages/...`), not the
|
|
32
|
+
project's `node_modules`, and a `skills.paths` entry relative to the project
|
|
33
|
+
dir silently resolves to nothing. This plugin scans both the opencode plugin
|
|
34
|
+
cache and the project's `node_modules` for packages carrying a root
|
|
35
|
+
`plugin.json` whose `$schema` is `https://agent-plugins.org/schemas/...`,
|
|
36
|
+
and registers their `skills/` with **absolute** paths — so an npm-distributed
|
|
37
|
+
Agent Plugins package (e.g. `@dodopayments/opencode-plugin`) just works with
|
|
38
|
+
`"plugin": ["opencode-skill-autodiscovery"]` and nothing else.
|
|
39
|
+
|
|
40
|
+
Each points at plugin directories that contain `SKILL.md` files. This plugin
|
|
41
|
+
reads the manifests (including the remote `cache.json` LRU), resolves each
|
|
42
|
+
entry to its on-disk skill directories, and registers them with opencode.
|
|
43
|
+
When a discovered package carries a conformant root `plugin.json`, that manifest
|
|
44
|
+
is preferred (its `skills/` children are registered as-is); otherwise the plugin
|
|
45
|
+
falls back to a tree walk so legacy layouts keep working.
|
|
16
46
|
|
|
17
47
|
### MCP servers (opt-in)
|
|
18
48
|
|
|
19
|
-
With the `mcp` option, the plugin also reads each discovered package's `mcp.json`
|
|
49
|
+
With the `mcp` option, the plugin also reads each discovered package's `mcp.json`
|
|
50
|
+
and maps it onto opencode's `config.mcp`:
|
|
20
51
|
|
|
21
52
|
| Agent Plugins server | opencode entry |
|
|
22
53
|
|---|---|
|
|
@@ -24,39 +55,66 @@ With the `mcp` option, the plugin also reads each discovered package's `mcp.json
|
|
|
24
55
|
| `{ "type": "streamable-http", "url" }` | `{ "type": "remote", "url" }` |
|
|
25
56
|
| `{ "type": "sse" }` | skipped (opencode has no SSE transport) |
|
|
26
57
|
|
|
27
|
-
`${PLUGIN_ROOT}` and `${PLUGIN_DATA}` placeholders are expanded in `args`/`env`,
|
|
58
|
+
`${PLUGIN_ROOT}` and `${PLUGIN_DATA}` placeholders are expanded in `args`/`env`,
|
|
59
|
+
and both variables are injected into each stdio server's environment
|
|
60
|
+
(`PLUGIN_DATA` points at
|
|
61
|
+
`{opencode state}/plugin-data/{packageName}`). Invalid entries are skipped
|
|
62
|
+
per-entry, never fatally. `sse` servers and stdio `cwd` (which opencode cannot
|
|
63
|
+
represent) are dropped with a log line.
|
|
28
64
|
|
|
29
65
|
### Agents (opt-in)
|
|
30
66
|
|
|
31
|
-
Agent Plugins 1.0.0 has no portable "agents" component type (only skills and
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
67
|
+
Agent Plugins 1.0.0 has no portable "agents" component type (only skills and
|
|
68
|
+
MCP servers), so agents are contributed through the spec's client-extension
|
|
69
|
+
mechanism. With the `agents` option, the plugin reads agents from four
|
|
70
|
+
sources, in order:
|
|
71
|
+
|
|
72
|
+
1. `plugin.json` → `extensions["dev.opencode"].agents` (a map of agent name →
|
|
73
|
+
opencode `agent` config).
|
|
74
|
+
2. A `dev.opencode/agents/<name>.json` extension directory (one opencode agent
|
|
75
|
+
config per file).
|
|
76
|
+
3. A legacy Claude Code plugin shim: `.claude-plugin/plugin.json` `agents`,
|
|
77
|
+
mapping `description` and `systemPrompt` (or the `agents/<name>/AGENTS.md`
|
|
78
|
+
body) onto an opencode agent.
|
|
79
|
+
4. Flat `agents/<name>.md` files (the agency-agents layout) — one agent per
|
|
80
|
+
file, keyed by filename, with `description`/`color` from frontmatter and the
|
|
81
|
+
markdown body as the prompt.
|
|
82
|
+
|
|
83
|
+
Agents discovered without an explicit `mode` default to opencode's `all`, so
|
|
84
|
+
they are both Tab-selectable and spawnable as subagents.
|
|
85
|
+
|
|
86
|
+
Discovered agents are registered as `config.agent.<name>` with the same rules
|
|
87
|
+
as commands: user-defined agents are never overwritten, same-source mirrors are
|
|
88
|
+
collapsed, and cross-source collisions become `<package>-<agent>`.
|
|
89
|
+
|
|
90
|
+
**Trust note:** a package-supplied `permission` block is always dropped — agent
|
|
91
|
+
permissions are too powerful to inherit from a package by default. If you need
|
|
92
|
+
one, define the agent yourself in `opencode.json` (which always wins).
|
|
45
93
|
|
|
46
94
|
### Slash commands
|
|
47
95
|
|
|
48
|
-
opencode treats skills and slash commands as separate mechanisms: skills are
|
|
96
|
+
opencode treats skills and slash commands as separate mechanisms: skills are
|
|
97
|
+
only loaded on demand via the `skill` tool. To make a discovered skill
|
|
98
|
+
invocable as `/name`, the plugin also registers a command for it (via
|
|
99
|
+
`config.command`) whose template loads the skill and forwards your arguments:
|
|
49
100
|
|
|
50
101
|
```markdown
|
|
51
|
-
Load the
|
|
102
|
+
Load the "spec" skill and follow its instructions.
|
|
52
103
|
Context: $ARGUMENTS
|
|
53
104
|
```
|
|
54
105
|
|
|
55
|
-
|
|
106
|
+
The skill name is rendered only as a quoted data value in the template — never
|
|
107
|
+
inside backticks — so a hostile name cannot break out into surrounding
|
|
108
|
+
instruction text.
|
|
109
|
+
|
|
110
|
+
So `/spec plan the migration` loads the `spec` skill and runs it against
|
|
111
|
+
`plan the migration`. The command's description is taken from the skill's
|
|
112
|
+
frontmatter; existing commands with the same name are never overwritten (a
|
|
113
|
+
colliding skill from a different source is registered as `/package-skill`).
|
|
56
114
|
|
|
57
115
|
## Install
|
|
58
116
|
|
|
59
|
-
Add the package name to the `plugin` array in your `opencode.json
|
|
117
|
+
Add the package name to the `plugin` array in your `opencode.json`:
|
|
60
118
|
|
|
61
119
|
```json
|
|
62
120
|
{
|
|
@@ -75,6 +133,7 @@ Use the tuple form to configure options:
|
|
|
75
133
|
"extraRoots": ["/home/user/.vscode-server"],
|
|
76
134
|
"scanCache": true,
|
|
77
135
|
"scanNodeModules": true,
|
|
136
|
+
"exclude": ["unwanted-plugin"],
|
|
78
137
|
"mcp": false,
|
|
79
138
|
"agents": false
|
|
80
139
|
}
|
|
@@ -86,14 +145,134 @@ Use the tuple form to configure options:
|
|
|
86
145
|
| Option | Default | Meaning |
|
|
87
146
|
|---|---|---|
|
|
88
147
|
| `extraRoots` | `[]` | Extra root directories to scan (e.g. a non-standard VS Code data location on a remote host). |
|
|
89
|
-
| `scanCache` | `
|
|
90
|
-
| `scanNodeModules` | `
|
|
148
|
+
| `scanCache` | `false` | Scan opencode's plugin cache (`~/.cache/opencode/packages/*`) for Agent Plugins packages. |
|
|
149
|
+
| `scanNodeModules` | `false` | Scan the project's `node_modules` (incl. `@scope/*`) for Agent Plugins packages. |
|
|
150
|
+
| `exclude` | `[]` | Package names to skip during discovery, regardless of trust tier. Matches the conformant package's `plugin.json` name, or the directory basename when there is no manifest. |
|
|
91
151
|
| `mcp` | `false` | Also register MCP servers from discovered packages' `mcp.json`. |
|
|
92
152
|
| `agents` | `false` | Also register agents from packages (see "Agents" above). |
|
|
93
153
|
|
|
154
|
+
Both scan flags default to `false` for supply-chain reasons: a discovered
|
|
155
|
+
skill's `SKILL.md` becomes prompt material in your sessions, so anything that
|
|
156
|
+
plants a skill plants model-facing instructions — and neither transitive npm
|
|
157
|
+
dependencies (which land in `node_modules` without any install script running)
|
|
158
|
+
nor the shared `~/.cache/opencode/packages` directory (populated by every
|
|
159
|
+
project on the machine) requires a manifest you ever reviewed. This is the
|
|
160
|
+
OWASP LLM01 risk arriving via the software supply chain; both sources are
|
|
161
|
+
therefore opt-in, while manifest-mediated sources (Claude Code plugins, VS
|
|
162
|
+
Code agent plugins) stay default-on because their manifests record deliberate,
|
|
163
|
+
host-vouched installs.
|
|
164
|
+
|
|
165
|
+
## Threat model
|
|
166
|
+
|
|
167
|
+
Discovery reads manifests from well-known locations and registers what it finds
|
|
168
|
+
into your session config. Not all sources are equally trustworthy, so they are
|
|
169
|
+
split into two tiers:
|
|
170
|
+
|
|
171
|
+
**Trusted by default** — content a host tool or opencode itself installed
|
|
172
|
+
deliberately, vouched for by a manifest:
|
|
173
|
+
|
|
174
|
+
- Claude Code plugins (`installed_plugins.json`, local and remote)
|
|
175
|
+
- VS Code agent plugins recorded in `installed.json` / `cache.json`
|
|
176
|
+
- packages in opencode's own plugin cache (`~/.cache/opencode/packages/*`),
|
|
177
|
+
which exist because your config asked opencode to fetch them
|
|
178
|
+
|
|
179
|
+
**Untrusted by default** — content present merely as a side effect:
|
|
180
|
+
|
|
181
|
+
- the project's `node_modules`: dependencies install transitively, so anything
|
|
182
|
+
in the tree can ship skills, MCP servers, or agents. Scanning it is **off by
|
|
183
|
+
default**; restore it explicitly with `"scanNodeModules": true`.
|
|
184
|
+
- user-supplied `extraRoots`: the plugin cannot vouch for whatever you point it at.
|
|
185
|
+
- manifest-less directory walks (e.g. cloned-but-uninstalled marketplace folders).
|
|
186
|
+
|
|
187
|
+
Trust decides whether content gets *registered*, not whether it is safe: a
|
|
188
|
+
registered skill's `SKILL.md` becomes prompt material in your sessions. The
|
|
189
|
+
`$schema` check identifies format only — never provenance or safety. Any package
|
|
190
|
+
can copy the literal schema URL, so a conformant manifest proves nothing about
|
|
191
|
+
who wrote it.
|
|
192
|
+
|
|
193
|
+
### `mcp` and `agents` trust everything they find
|
|
194
|
+
|
|
195
|
+
Both flags are single global switches: enabling one trusts **every** discovered
|
|
196
|
+
package that ships the matching config. There is no per-package consent step.
|
|
197
|
+
|
|
198
|
+
- `mcp: true` registers every conformant package's `mcp.json`; stdio entries
|
|
199
|
+
execute commands on your machine.
|
|
200
|
+
- `agents: true` registers package-supplied agents essentially verbatim within
|
|
201
|
+
the schema: a package can set `mode: "primary"` (making itself a primary
|
|
202
|
+
agent) and arbitrary `tools` booleans such as `"write": true`. Only
|
|
203
|
+
`permission` blocks are dropped.
|
|
204
|
+
|
|
205
|
+
Pair these flags with `exclude` to carve out packages you do not want
|
|
206
|
+
registered:
|
|
207
|
+
|
|
208
|
+
```json
|
|
209
|
+
{
|
|
210
|
+
"plugin": [
|
|
211
|
+
["opencode-skill-autodiscovery", { "mcp": true, "agents": true, "exclude": ["unwanted-package"] }]
|
|
212
|
+
]
|
|
213
|
+
}
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
Residual risk, stated plainly: approving or rejecting an individual package's
|
|
217
|
+
MCP servers or agents would require an interactive consent surface, which
|
|
218
|
+
opencode's synchronous `config` hook cannot provide. The granularity available
|
|
219
|
+
today is all-or-nothing per component type, narrowed by `exclude`.
|
|
220
|
+
|
|
221
|
+
### Identifier rules
|
|
222
|
+
|
|
223
|
+
Every package-supplied identifier that becomes a config key must match the
|
|
224
|
+
same pattern: lowercase letters, digits, `-`, and `.` only (`[a-z0-9.-]`),
|
|
225
|
+
starting and ending with an alphanumeric character, with no `--` or `..`
|
|
226
|
+
runs. The prototype-chain keys `__proto__` and `constructor` are rejected
|
|
227
|
+
outright even though they satisfy the character pattern. This applies to:
|
|
228
|
+
|
|
229
|
+
- the `plugin.json` manifest `name` (collision namespaces and `exclude`
|
|
230
|
+
matching)
|
|
231
|
+
- `SKILL.md` frontmatter `name` (slash-command keys)
|
|
232
|
+
- `mcp.json` server keys (`config.mcp` keys)
|
|
233
|
+
- agent manifest keys, `dev.opencode/agents/*.json` filenames, legacy shim
|
|
234
|
+
agent names, and flat `agents/<name>.md` filenames (`config.agent` keys)
|
|
235
|
+
|
|
236
|
+
An invalid identifier never aborts discovery: the offending entry is skipped
|
|
237
|
+
with a log line naming the package, its source, and a reason, and legitimate
|
|
238
|
+
entries from the same package still register.
|
|
239
|
+
|
|
240
|
+
Defense-in-depth at the write sites holds even if a future call site skips
|
|
241
|
+
those checks:
|
|
242
|
+
|
|
243
|
+
- The `config.command`, `config.mcp`, and `config.agent` containers are built
|
|
244
|
+
prototype-free (`Object.create(null)`), so no key can ever resolve to an
|
|
245
|
+
inherited member such as `toString`, and `__proto__`/`constructor` can
|
|
246
|
+
never take effect through inheritance.
|
|
247
|
+
- The skill name inside a slash-command template is rendered as a quoted data
|
|
248
|
+
value (JSON string encoding), never wrapped in backticks, so it cannot
|
|
249
|
+
break out into surrounding instruction text.
|
|
250
|
+
- Frontmatter `description` strings pass through the same control-character
|
|
251
|
+
sanitizer used for log lines before they enter config.
|
|
252
|
+
|
|
253
|
+
### Migrating from 1.x
|
|
254
|
+
|
|
255
|
+
`scanNodeModules` used to default to `true`; it now defaults to `false`. If you
|
|
256
|
+
distribute an Agent Plugins package via npm and consumers relied on it being
|
|
257
|
+
picked up from the project's `node_modules`, they must now opt in explicitly:
|
|
258
|
+
|
|
259
|
+
```json
|
|
260
|
+
{
|
|
261
|
+
"plugin": [["opencode-skill-autodiscovery", { "scanNodeModules": true }]]
|
|
262
|
+
}
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
Prefer shipping your package as a regular opencode plugin
|
|
266
|
+
(`"plugin": ["your-package"]`) instead: opencode installs it into its own cache,
|
|
267
|
+
where you can pick it up explicitly with `"scanCache": true` — no
|
|
268
|
+
scan of the dependency tree required.
|
|
269
|
+
|
|
94
270
|
## VPS / remote hosts (SSH sessions)
|
|
95
271
|
|
|
96
|
-
Discovery is **machine-local**: a remote session only sees the skills, agents,
|
|
272
|
+
Discovery is **machine-local**: a remote session only sees the skills, agents,
|
|
273
|
+
and packages installed **on that host**. So opencode (and this plugin) must be
|
|
274
|
+
installed on each remote machine, and you run opencode inside the SSH session —
|
|
275
|
+
not from a local client terminal.
|
|
97
276
|
|
|
98
277
|
**On each remote host:**
|
|
99
278
|
|
|
@@ -120,27 +299,57 @@ Or hand-edit the remote's global config (`~/.config/opencode/opencode.json`):
|
|
|
120
299
|
```
|
|
121
300
|
|
|
122
301
|
**What a remote session discovers** (that host's own installs):
|
|
123
|
-
- VS Code Remote-SSH synced skills from `~/.vscode-server/data/agentPlugins/`
|
|
302
|
+
- VS Code Remote-SSH synced skills from `~/.vscode-server/data/agentPlugins/`
|
|
303
|
+
(read via the `cache.json` LRU).
|
|
124
304
|
- Claude Code remote plugins from `~/.claude/remote/plugins/`.
|
|
125
|
-
- Agent Plugins packages in the remote's opencode cache
|
|
305
|
+
- Agent Plugins packages in the remote's opencode cache
|
|
306
|
+
(`~/.cache/opencode/packages/*`) and the project's `node_modules`.
|
|
126
307
|
|
|
127
308
|
**Caveats:**
|
|
128
|
-
- Run opencode **on the remote**. A local client terminal reads the local
|
|
129
|
-
|
|
130
|
-
-
|
|
309
|
+
- Run opencode **on the remote**. A local client terminal reads the local
|
|
310
|
+
machine's manifests, not the remote's.
|
|
311
|
+
- VS Code only syncs **enabled** skills to the server as a flattened "VS Code
|
|
312
|
+
Synced Data" bundle; marketplace clones (including their `agents/*.md`
|
|
313
|
+
files) are generally not copied. Install the pack on the remote too if you
|
|
314
|
+
want its agents there.
|
|
315
|
+
- To force a re-fetch of a new release on a remote, clear the cached copy and
|
|
316
|
+
restart (opencode re-downloads the latest):
|
|
131
317
|
```sh
|
|
132
318
|
rm -rf ~/.cache/opencode/packages/opencode-skill-autodiscovery*
|
|
133
319
|
```
|
|
134
320
|
|
|
135
321
|
## Notes
|
|
136
322
|
|
|
137
|
-
- Discovery is inherently **machine-local**: it reads manifests from the home
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
- VS Code
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
-
|
|
323
|
+
- Discovery is inherently **machine-local**: it reads manifests from the home
|
|
324
|
+
directory of the machine opencode is running on. Remote sessions on a
|
|
325
|
+
different machine will discover that machine's skills.
|
|
326
|
+
- On a remote host, VS Code does **not** copy your marketplace plugins over.
|
|
327
|
+
It syncs only the enabled skills/agents/etc. from your client as a single
|
|
328
|
+
flattened "VS Code Synced Data" bundle under
|
|
329
|
+
`~/.vscode-server/data/agentPlugins/`. That is why you won't see the
|
|
330
|
+
original `{org}/{repo}` layout on the remote — the skill directories are
|
|
331
|
+
named after the skills instead. This plugin reads `cache.json` to locate
|
|
332
|
+
those materialized bundles.
|
|
333
|
+
- Newer VS Code layouts have no `installed.json` at all; marketplaces are
|
|
334
|
+
cloned directly under the agent plugin dir. The plugin falls back to a tree
|
|
335
|
+
walk only when no manifest is present, so it never surfaces skills from
|
|
336
|
+
cloned-but-uninstalled marketplaces on setups that do have a manifest.
|
|
337
|
+
- VS Code account sync only syncs your marketplace extension list; each machine
|
|
338
|
+
still has its own `installed.json`/`cache.json` that this plugin reads.
|
|
339
|
+
- A package is only treated as an Agent Plugins package when its root
|
|
340
|
+
`plugin.json` declares a `$schema` under `https://agent-plugins.org/schemas/`.
|
|
341
|
+
Everything else is ignored by the cache/node_modules scanners and falls back
|
|
342
|
+
to the tree walk elsewhere. This check identifies format only — never
|
|
343
|
+
provenance or safety: any package can copy the literal schema URL, so a
|
|
344
|
+
conformant manifest does not make scanning an untrusted directory safe.
|
|
345
|
+
Content is trusted based on where it came from (host-installed manifests vs.
|
|
346
|
+
side-effect locations), not on its shape.
|
|
347
|
+
- The same plugin can be materialised in several VS Code layouts at once
|
|
348
|
+
(local clone + synced bundle + marketplace clone). `skills.paths` keeps all
|
|
349
|
+
paths; slash commands and MCP servers are de-duplicated so mirrors don't
|
|
350
|
+
create a wall of `/mirror-of-...` junk.
|
|
351
|
+
- The plugin is a no-op when no manifests or conformant packages exist, or when
|
|
352
|
+
they contain no skills.
|
|
144
353
|
|
|
145
354
|
## Development
|
|
146
355
|
|
|
@@ -153,6 +362,5 @@ npm test # build + node --test (fixture-based unit tests)
|
|
|
153
362
|
Publish:
|
|
154
363
|
|
|
155
364
|
```sh
|
|
156
|
-
npm pack # local tarball (no publish needed for testing)
|
|
157
365
|
npm publish --access public
|
|
158
366
|
```
|
package/dist/agents.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../src/agents.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../src/agents.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAIpD,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,UAAU,GAAG,SAAS,GAAG,KAAK,CAAC;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAmJF,wBAAgB,UAAU,CACxB,GAAG,EAAE,aAAa,GACjB,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,WAAW,CAAA;CAAE,CAAC,CA8H7C"}
|
package/dist/agents.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { readFileSync, readdirSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { log } from "./log.js";
|
|
4
|
+
import { validateName } from "./schema.js";
|
|
4
5
|
// Reverse-DNS namespace this plugin (and opencode, by convention) owns for
|
|
5
6
|
// client-specific manifest data and extension directories (Agent Plugins 5.6/8).
|
|
6
7
|
const OPENCODE_NS = "dev.opencode";
|
|
@@ -158,6 +159,12 @@ export function readAgents(pkg) {
|
|
|
158
159
|
const manifestAgents = asRecord(opencodeExt?.agents);
|
|
159
160
|
if (manifestAgents) {
|
|
160
161
|
for (const [name, raw] of Object.entries(manifestAgents)) {
|
|
162
|
+
// Manifest agent keys are package-supplied input: gate the name before
|
|
163
|
+
// it becomes any config key (applyConfigPatch writes config.agent[name]).
|
|
164
|
+
if (!validateName(name)) {
|
|
165
|
+
log(`skipping manifest agent key for package "${pkg.name}" (${pkg.source}): invalid name "${name}" (must match the identifier pattern and not be a prototype-chain key)`);
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
161
168
|
if (out.has(name))
|
|
162
169
|
continue;
|
|
163
170
|
const agent = toAgentConfig(raw);
|
|
@@ -177,6 +184,12 @@ export function readAgents(pkg) {
|
|
|
177
184
|
if (!entry.endsWith(".json"))
|
|
178
185
|
continue;
|
|
179
186
|
const name = entry.slice(0, -".json".length);
|
|
187
|
+
// Extension-dir filenames are package-supplied input: gate the name before
|
|
188
|
+
// it becomes any config key.
|
|
189
|
+
if (!validateName(name)) {
|
|
190
|
+
log(`skipping extension-dir agent file for package "${pkg.name}" (${pkg.source}): invalid name "${name}" (must match the identifier pattern and not be a prototype-chain key)`);
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
180
193
|
if (out.has(name))
|
|
181
194
|
continue;
|
|
182
195
|
const agent = toAgentConfig(readJson(join(extDir, entry)));
|
|
@@ -187,6 +200,12 @@ export function readAgents(pkg) {
|
|
|
187
200
|
const claudeAgents = asRecord(claudeManifest?.agents);
|
|
188
201
|
if (claudeAgents) {
|
|
189
202
|
for (const [name, raw] of Object.entries(claudeAgents)) {
|
|
203
|
+
// Shim manifest agent names are package-supplied legacy input: gate them
|
|
204
|
+
// before they become config keys or path segments (agents/<name>/AGENTS.md).
|
|
205
|
+
if (!validateName(name)) {
|
|
206
|
+
log(`skipping shimmed agent key for package "${pkg.name}" (${pkg.source}): invalid name "${name}" (must match the identifier pattern and not be a prototype-chain key)`);
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
190
209
|
if (out.has(name))
|
|
191
210
|
continue;
|
|
192
211
|
const src = asRecord(raw);
|
|
@@ -228,6 +247,12 @@ export function readAgents(pkg) {
|
|
|
228
247
|
if (!entry.endsWith(".md"))
|
|
229
248
|
continue;
|
|
230
249
|
const name = entry.slice(0, -".md".length);
|
|
250
|
+
// Flat agent filenames are package-supplied input: gate the name before
|
|
251
|
+
// it becomes any config key.
|
|
252
|
+
if (!validateName(name)) {
|
|
253
|
+
log(`skipping flat agent file for package "${pkg.name}" (${pkg.source}): invalid name "${name}" (must match the identifier pattern and not be a prototype-chain key)`);
|
|
254
|
+
continue;
|
|
255
|
+
}
|
|
231
256
|
if (out.has(name))
|
|
232
257
|
continue;
|
|
233
258
|
let content;
|
package/dist/agents.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.js","sourceRoot":"","sources":["../src/agents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"agents.js","sourceRoot":"","sources":["../src/agents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,GAAG,EAAE,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IAAI,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAChE,CAAC"}
|
package/dist/discovery.d.ts
CHANGED
|
@@ -7,6 +7,13 @@ export type { McpEntry } from "./mcp.js";
|
|
|
7
7
|
export type PackageSource = "claude" | "vscode" | "opencode-cache" | "node_modules" | "extra";
|
|
8
8
|
export type PluginPackage = {
|
|
9
9
|
source: PackageSource;
|
|
10
|
+
/**
|
|
11
|
+
* Two-tier trust model. True when the content was installed or fetched
|
|
12
|
+
* deliberately via a host tool or opencode itself (claude/vscode manifests,
|
|
13
|
+
* opencode's package cache). False when present merely as a side effect
|
|
14
|
+
* (project node_modules, manifest-less walks over user-supplied extra roots).
|
|
15
|
+
*/
|
|
16
|
+
trusted: boolean;
|
|
10
17
|
name: string;
|
|
11
18
|
root: string;
|
|
12
19
|
skillDirs: string[];
|
|
@@ -48,22 +55,25 @@ export type ConfigLike = {
|
|
|
48
55
|
};
|
|
49
56
|
export declare function contains(parent: string, child: string): boolean;
|
|
50
57
|
export declare function readSkillInfo(dir: string): SkillInfo | null;
|
|
51
|
-
export declare function readPackage(root: string, source: PackageSource): PluginPackage | null;
|
|
58
|
+
export declare function readPackage(root: string, source: PackageSource, trusted?: boolean): PluginPackage | null;
|
|
52
59
|
export declare function findSkillDirs(root: string, out: Set<string>, seen: Set<string>): void;
|
|
53
60
|
export declare function findPluginRoots(root: string, out: string[]): void;
|
|
54
|
-
export declare function packageFromDir(root: string, source: PackageSource): PluginPackage | null;
|
|
55
|
-
export declare function collectVscodeManifest(out: PluginPackage[], installedJson: string): void;
|
|
56
|
-
export declare function collectVscodeCache(out: PluginPackage[], cacheJson: string): void;
|
|
57
|
-
export declare function collectVscode(out: PluginPackage[], extra: string[]): void;
|
|
58
|
-
export declare function collectClaudeManifest(out: PluginPackage[], installedJson: string): void;
|
|
59
|
-
export declare function collectClaude(out: PluginPackage[]): void;
|
|
61
|
+
export declare function packageFromDir(root: string, source: PackageSource, trusted?: boolean): PluginPackage | null;
|
|
62
|
+
export declare function collectVscodeManifest(out: PluginPackage[], installedJson: string, exclude?: string[]): void;
|
|
63
|
+
export declare function collectVscodeCache(out: PluginPackage[], cacheJson: string, exclude?: string[]): void;
|
|
64
|
+
export declare function collectVscode(out: PluginPackage[], extra: string[], exclude?: string[]): void;
|
|
65
|
+
export declare function collectClaudeManifest(out: PluginPackage[], installedJson: string, exclude?: string[]): void;
|
|
66
|
+
export declare function collectClaude(out: PluginPackage[], exclude?: string[]): void;
|
|
60
67
|
export declare function opencodeCacheRoot(): string;
|
|
61
|
-
export declare function collectOpencodeCache(packagesRoot: string, out: PluginPackage[]): void;
|
|
62
|
-
export declare function collectNodeModules(nodeModulesRoot: string, out: PluginPackage[]): void;
|
|
68
|
+
export declare function collectOpencodeCache(packagesRoot: string, out: PluginPackage[], exclude?: string[]): void;
|
|
69
|
+
export declare function collectNodeModules(nodeModulesRoot: string, out: PluginPackage[], trusted?: boolean, exclude?: string[]): void;
|
|
63
70
|
export declare function planConfig(packages: PluginPackage[], taken?: {
|
|
64
71
|
commands?: Iterable<string>;
|
|
65
72
|
mcp?: Iterable<string>;
|
|
66
73
|
agents?: Iterable<string>;
|
|
74
|
+
}, enabled?: {
|
|
75
|
+
mcp?: boolean;
|
|
76
|
+
agents?: boolean;
|
|
67
77
|
}): ConfigPatch;
|
|
68
78
|
export declare function applyConfigPatch(config: ConfigLike, plan: ConfigPatch, enabled: {
|
|
69
79
|
mcp: boolean;
|
package/dist/discovery.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/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