opencode-skill-autodiscovery 2.0.0 → 2.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/README.md +117 -25
- package/dist/agents.d.ts +3 -1
- package/dist/agents.d.ts.map +1 -1
- package/dist/agents.js +86 -27
- package/dist/agents.js.map +1 -1
- package/dist/cache.d.ts +5 -0
- package/dist/cache.d.ts.map +1 -0
- package/dist/cache.js +94 -0
- package/dist/cache.js.map +1 -0
- package/dist/discovery-cache.d.ts +9 -0
- package/dist/discovery-cache.d.ts.map +1 -0
- package/dist/discovery-cache.js +161 -0
- package/dist/discovery-cache.js.map +1 -0
- package/dist/discovery.d.ts +18 -6
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +373 -98
- package/dist/discovery.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +62 -11
- package/dist/index.js.map +1 -1
- package/dist/mcp.d.ts +6 -2
- package/dist/mcp.d.ts.map +1 -1
- package/dist/mcp.js +97 -16
- package/dist/mcp.js.map +1 -1
- package/dist/schemas/mcp-schema-1.0.0.d.ts +117 -0
- package/dist/schemas/mcp-schema-1.0.0.d.ts.map +1 -0
- package/dist/schemas/mcp-schema-1.0.0.js +139 -0
- package/dist/schemas/mcp-schema-1.0.0.js.map +1 -0
- package/dist/schemas/plugin-schema-1.0.0.d.ts +66 -0
- package/dist/schemas/plugin-schema-1.0.0.d.ts.map +1 -0
- package/dist/schemas/plugin-schema-1.0.0.js +72 -0
- package/dist/schemas/plugin-schema-1.0.0.js.map +1 -0
- package/dist/spec-schema.d.ts +12 -0
- package/dist/spec-schema.d.ts.map +1 -0
- package/dist/spec-schema.js +71 -0
- package/dist/spec-schema.js.map +1 -0
- package/package.json +6 -3
package/README.md
CHANGED
|
@@ -62,6 +62,35 @@ and both variables are injected into each stdio server's environment
|
|
|
62
62
|
per-entry, never fatally. `sse` servers and stdio `cwd` (which opencode cannot
|
|
63
63
|
represent) are dropped with a log line.
|
|
64
64
|
|
|
65
|
+
### MCP credentials
|
|
66
|
+
|
|
67
|
+
Package-declared `mcp.json` servers are mirrored **verbatim** into your
|
|
68
|
+
opencode config: `headers`, `env` values, and server `url`s are copied exactly
|
|
69
|
+
as written (modulo `${PLUGIN_ROOT}` / `${PLUGIN_DATA}` expansion) into
|
|
70
|
+
`config.mcp.<server>`. opencode stores `config.mcp` in plaintext, so any
|
|
71
|
+
credential in those fields — an `Authorization` header, a token in `env`, an
|
|
72
|
+
`userinfo@` URL — is plaintext-at-rest and may appear in host config backups,
|
|
73
|
+
logs, or terminal output. Treat a server's headers/env/URL as a static
|
|
74
|
+
snapshot: once mirrored, the value has no rotation or revocation linkage back
|
|
75
|
+
to the package — updating the package does not rotate a copied token.
|
|
76
|
+
|
|
77
|
+
Guidance:
|
|
78
|
+
|
|
79
|
+
- **Use https-only remotes.** `streamable-http` servers must already be
|
|
80
|
+
`https://` to register (a plain `http://` URL would ship any `headers` in
|
|
81
|
+
cleartext), and that is the transport you want when a server carries
|
|
82
|
+
credentials.
|
|
83
|
+
- **Audit `config.mcp`** after discovery to confirm which servers and
|
|
84
|
+
credential fields entered your config, and remove anything you did not
|
|
85
|
+
intend to persist.
|
|
86
|
+
- **Use `consent` / `exclude`** to control admission: servers from untrusted
|
|
87
|
+
packages are skipped until the package is listed under `consent.mcp`, and
|
|
88
|
+
`exclude` drops a package entirely.
|
|
89
|
+
- The planning-time `mkdir` for a package stdio server's `PLUGIN_DATA`
|
|
90
|
+
directory is deferred: the directory is created only when the server is
|
|
91
|
+
actually applied to the config, never at plan time — so a
|
|
92
|
+
discovered-but-unapplied server leaves no filesystem trace.
|
|
93
|
+
|
|
65
94
|
### Agents (opt-in)
|
|
66
95
|
|
|
67
96
|
Agent Plugins 1.0.0 has no portable "agents" component type (only skills and
|
|
@@ -87,9 +116,11 @@ Discovered agents are registered as `config.agent.<name>` with the same rules
|
|
|
87
116
|
as commands: user-defined agents are never overwritten, same-source mirrors are
|
|
88
117
|
collapsed, and cross-source collisions become `<package>-<agent>`.
|
|
89
118
|
|
|
90
|
-
**Trust note:**
|
|
91
|
-
|
|
92
|
-
|
|
119
|
+
**Trust note:** package-supplied capability is clamped to the conservative
|
|
120
|
+
default: `permission` blocks and `tools` grants are always dropped, and any
|
|
121
|
+
declared `mode` other than `subagent` clamps to `subagent`. Each drop is logged
|
|
122
|
+
naming the package and the agent. If you need more, define the agent yourself
|
|
123
|
+
in `opencode.json` (which always wins).
|
|
93
124
|
|
|
94
125
|
### Slash commands
|
|
95
126
|
|
|
@@ -150,6 +181,7 @@ Use the tuple form to configure options:
|
|
|
150
181
|
| `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. |
|
|
151
182
|
| `mcp` | `false` | Also register MCP servers from discovered packages' `mcp.json`. |
|
|
152
183
|
| `agents` | `false` | Also register agents from packages (see "Agents" above). |
|
|
184
|
+
| `consent` | `{}` | Per-package consent map: `consent.mcp` / `consent.agents` list package names whose MCP servers / agents are wanted even when the package is discovered as untrusted. Refines the `mcp` / `agents` switches; `exclude` remains the deny side. |
|
|
153
185
|
|
|
154
186
|
Both scan flags default to `false` for supply-chain reasons: a discovered
|
|
155
187
|
skill's `SKILL.md` becomes prompt material in your sessions, so anything that
|
|
@@ -181,26 +213,52 @@ deliberately, vouched for by a manifest:
|
|
|
181
213
|
- the project's `node_modules`: dependencies install transitively, so anything
|
|
182
214
|
in the tree can ship skills, MCP servers, or agents. Scanning it is **off by
|
|
183
215
|
default**; restore it explicitly with `"scanNodeModules": true`.
|
|
184
|
-
- user-supplied `extraRoots`: the plugin cannot vouch for whatever you point
|
|
216
|
+
- user-supplied `extraRoots`: the plugin cannot vouch for whatever you point
|
|
217
|
+
it at. A manifest discovered under one of these roots is untrusted and may
|
|
218
|
+
only reference a package inside that root (a trusted VS Code home root may
|
|
219
|
+
still reference a global extension directory).
|
|
185
220
|
- manifest-less directory walks (e.g. cloned-but-uninstalled marketplace folders).
|
|
186
221
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
222
|
+
### Graduated default
|
|
223
|
+
|
|
224
|
+
Trust gates the two component tiers differently:
|
|
225
|
+
|
|
226
|
+
- **Skills and slash commands register for every tier.** Both are read-only
|
|
227
|
+
content registration — surfacing a package's skills is the plugin's job, so
|
|
228
|
+
trust never blocks them. An untrusted package's skills and commands are
|
|
229
|
+
registered exactly like a trusted one's, but each untrusted package emits a
|
|
230
|
+
one-line info log naming the package and its source, so side-effect content
|
|
231
|
+
entering the session stays visible. `exclude` remains the deny side.
|
|
232
|
+
- **MCP servers and agents are default-off for untrusted packages.** The
|
|
233
|
+
`mcp` / `agents` switches admit servers and agents from trusted packages
|
|
234
|
+
directly; an untrusted package contributes them only when the package is
|
|
235
|
+
listed under `consent.mcp` / `consent.agents`.
|
|
236
|
+
|
|
237
|
+
Trust never decides whether content is *safe*: a registered skill's
|
|
238
|
+
`SKILL.md` becomes prompt material in your sessions. The `$schema` check
|
|
239
|
+
identifies format only — never provenance or safety. Any package can copy the
|
|
240
|
+
literal schema URL, so a conformant manifest proves nothing about who wrote it.
|
|
241
|
+
|
|
242
|
+
### `mcp` and `agents` register package content
|
|
243
|
+
|
|
244
|
+
Both flags are global opt-in switches, narrowed by `exclude` and refined by
|
|
245
|
+
per-package `consent` (below). Trust decides admission: `mcp: true` /
|
|
246
|
+
`agents: true` admit servers or agents from trusted packages, and from
|
|
247
|
+
untrusted packages only when the package is listed under `consent.mcp` /
|
|
248
|
+
`consent.agents`.
|
|
249
|
+
|
|
250
|
+
- `mcp: true` admits MCP servers from packages that are trusted or listed in
|
|
251
|
+
`consent.mcp`. Every registered package-supplied server starts with
|
|
252
|
+
`enabled: false`: opencode will not spawn a package-declared binary or
|
|
253
|
+
connect to a package-chosen endpoint at startup on discovery alone.
|
|
254
|
+
Admittance is opt-in; the safe default is off.
|
|
255
|
+
- `agents: true` admits agents from packages that are trusted or listed in
|
|
256
|
+
`consent.agents`, then clamps each to the conservative default: a declared
|
|
257
|
+
`mode` other than `subagent` is dropped (a package cannot make itself a
|
|
258
|
+
primary agent), `tools` booleans such as `"write": true` are never
|
|
259
|
+
inherited, and `permission` blocks are dropped — each drop is logged naming
|
|
260
|
+
the package and the agent. An agent without an explicit `mode` still falls
|
|
261
|
+
through to opencode's `all` default.
|
|
204
262
|
|
|
205
263
|
Pair these flags with `exclude` to carve out packages you do not want
|
|
206
264
|
registered:
|
|
@@ -213,10 +271,44 @@ registered:
|
|
|
213
271
|
}
|
|
214
272
|
```
|
|
215
273
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
274
|
+
### Per-package consent (`consent`)
|
|
275
|
+
|
|
276
|
+
Consent is the per-package allow side for packages discovered as **untrusted**
|
|
277
|
+
(the project's `node_modules`, user-supplied `extraRoots`, manifest-less
|
|
278
|
+
walks). List a package's name under `consent.mcp` to admit its MCP servers, or
|
|
279
|
+
under `consent.agents` to admit its agents, even though the package is not
|
|
280
|
+
trusted by default:
|
|
281
|
+
|
|
282
|
+
```json
|
|
283
|
+
{
|
|
284
|
+
"plugin": [
|
|
285
|
+
[
|
|
286
|
+
"opencode-skill-autodiscovery",
|
|
287
|
+
{
|
|
288
|
+
"scanNodeModules": true,
|
|
289
|
+
"mcp": true,
|
|
290
|
+
"agents": true,
|
|
291
|
+
"consent": {
|
|
292
|
+
"mcp": ["community-tools"],
|
|
293
|
+
"agents": ["community-tools"]
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
]
|
|
297
|
+
]
|
|
298
|
+
}
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
- `consent` only refines the coarse switches: `mcp: true` / `agents: true`
|
|
302
|
+
stay the on-switch, and `consent.mcp` / `consent.agents` list which
|
|
303
|
+
untrusted packages are admitted when a switch is on.
|
|
304
|
+
- `exclude` remains the deny side and wins: a package listed in both
|
|
305
|
+
`exclude` and `consent` is never discovered.
|
|
306
|
+
- Trusted packages need no consent entry.
|
|
307
|
+
- The default — no `consent` option — grants nothing extra: untrusted
|
|
308
|
+
packages contribute no MCP servers or agents until admitted by name.
|
|
309
|
+
|
|
310
|
+
Consent is declarative (package names in `opencode.json`), so it works inside
|
|
311
|
+
opencode's synchronous `config` hook — no interactive prompt required.
|
|
220
312
|
|
|
221
313
|
### Identifier rules
|
|
222
314
|
|
package/dist/agents.d.ts
CHANGED
|
@@ -11,8 +11,10 @@ export type AgentConfig = {
|
|
|
11
11
|
color?: string;
|
|
12
12
|
maxSteps?: number;
|
|
13
13
|
};
|
|
14
|
-
|
|
14
|
+
type ReadAgentsResult = Array<{
|
|
15
15
|
name: string;
|
|
16
16
|
agent: AgentConfig;
|
|
17
17
|
}>;
|
|
18
|
+
export declare function readAgents(pkg: PluginPackage): ReadAgentsResult;
|
|
19
|
+
export {};
|
|
18
20
|
//# sourceMappingURL=agents.d.ts.map
|
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":"AAOA,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;AAwKF,KAAK,gBAAgB,GAAG,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,WAAW,CAAA;CAAE,CAAC,CAAC;AAkBpE,wBAAgB,UAAU,CAAC,GAAG,EAAE,aAAa,GAAG,gBAAgB,CAQ/D"}
|
package/dist/agents.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { readFileSync, readdirSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
+
import { cachedRead } from "./cache.js";
|
|
4
|
+
import { fingerprintTree, getCachedValue, setCachedValue } from "./discovery-cache.js";
|
|
3
5
|
import { log } from "./log.js";
|
|
4
6
|
import { validateName } from "./schema.js";
|
|
7
|
+
import { resolveContained } from "./discovery.js";
|
|
5
8
|
// Reverse-DNS namespace this plugin (and opencode, by convention) owns for
|
|
6
9
|
// client-specific manifest data and extension directories (Agent Plugins 5.6/8).
|
|
7
10
|
const OPENCODE_NS = "dev.opencode";
|
|
@@ -91,10 +94,25 @@ function readJson(path) {
|
|
|
91
94
|
return null;
|
|
92
95
|
}
|
|
93
96
|
}
|
|
97
|
+
// Package-supplied JSON that feeds agent config (the plugin manifests and the
|
|
98
|
+
// dev.opencode/agents/*.json extension files) is read only when it resolves
|
|
99
|
+
// inside the package root. A symlinked manifest would otherwise let an outside
|
|
100
|
+
// file's `description`/`prompt`/`systemPrompt` fields become model prompt
|
|
101
|
+
// material. Missing files resolve to null silently; an escaping symlink is
|
|
102
|
+
// logged once by resolveContained.
|
|
103
|
+
function readContainedJson(root, path) {
|
|
104
|
+
const contained = resolveContained(root, path);
|
|
105
|
+
if (!contained)
|
|
106
|
+
return null;
|
|
107
|
+
return readJson(contained);
|
|
108
|
+
}
|
|
94
109
|
// Converts a raw, package-supplied agent object into an opencode AgentConfig.
|
|
95
|
-
//
|
|
96
|
-
//
|
|
97
|
-
|
|
110
|
+
// Package-supplied capability is deliberately clamped: any declared `mode`
|
|
111
|
+
// other than the conservative "subagent" default is dropped, and `permission`
|
|
112
|
+
// blocks and `tools` grants are never inherited (both too powerful to inherit
|
|
113
|
+
// by default). Each drop is logged naming the package and the agent. Unknown
|
|
114
|
+
// or mistyped keys are ignored. Returns null when nothing usable is left.
|
|
115
|
+
function toAgentConfig(raw, pkgName, agentName) {
|
|
98
116
|
const src = asRecord(raw);
|
|
99
117
|
if (!src)
|
|
100
118
|
return null;
|
|
@@ -126,20 +144,25 @@ function toAgentConfig(raw) {
|
|
|
126
144
|
agent.maxSteps = maxSteps;
|
|
127
145
|
if (typeof src.disable === "boolean")
|
|
128
146
|
agent.disable = src.disable;
|
|
147
|
+
// A declared mode other than "subagent" requests capabilities (a primary
|
|
148
|
+
// agent, or opencode's full "all" surface) that a package should not grant
|
|
149
|
+
// itself. Drop it and clamp to the conservative default. An unset mode
|
|
150
|
+
// falls through to opencode's own "all" default, so it stays unset.
|
|
129
151
|
if (typeof src.mode === "string" && MODES.has(src.mode)) {
|
|
130
|
-
|
|
152
|
+
if (src.mode !== "subagent") {
|
|
153
|
+
log(`dropping mode "${src.mode}" from agent "${agentName}" supplied by package "${pkgName}": clamping to conservative "subagent"`);
|
|
154
|
+
}
|
|
155
|
+
agent.mode = "subagent";
|
|
131
156
|
}
|
|
157
|
+
// Tools booleans are capability grants and are never inherited from a
|
|
158
|
+
// package (agent.tools is intentionally left unset). The drop is logged so
|
|
159
|
+
// a package cannot silently pretend it carries write access.
|
|
132
160
|
const tools = asRecord(src.tools);
|
|
133
|
-
if (tools) {
|
|
134
|
-
|
|
135
|
-
for (const [name, value] of Object.entries(tools)) {
|
|
136
|
-
if (typeof value === "boolean")
|
|
137
|
-
filtered[name] = value;
|
|
138
|
-
}
|
|
139
|
-
agent.tools = filtered;
|
|
161
|
+
if (tools && Object.values(tools).some((value) => typeof value === "boolean")) {
|
|
162
|
+
log(`dropping tools from agent "${agentName}" supplied by package "${pkgName}": too powerful to inherit`);
|
|
140
163
|
}
|
|
141
164
|
if (src.permission !== undefined) {
|
|
142
|
-
log(
|
|
165
|
+
log(`dropping permission block from agent "${agentName}" supplied by package "${pkgName}": too powerful to inherit`);
|
|
143
166
|
}
|
|
144
167
|
if (!agent.description && !agent.prompt)
|
|
145
168
|
return null;
|
|
@@ -151,9 +174,29 @@ function toAgentConfig(raw) {
|
|
|
151
174
|
// 3. a legacy Claude Code plugin shim: `.claude-plugin/plugin.json` `agents`
|
|
152
175
|
// plus `agents/<name>/AGENTS.md` when no systemPrompt is declared.
|
|
153
176
|
// Returns a stable, de-duplicated list keyed by agent name.
|
|
177
|
+
//
|
|
178
|
+
// Cached as a whole per package, fingerprinted on pkg.root: this function's
|
|
179
|
+
// own per-file cachedRead calls (below) already skip re-parsing an unchanged
|
|
180
|
+
// *file*, but still pay a readdirSync + containment check (2x realpathSync)
|
|
181
|
+
// per candidate file on every call. A marketplace package that ships many
|
|
182
|
+
// flat agent .md files directly in its root (the agency-agents layout) makes
|
|
183
|
+
// that per-file overhead the dominant remaining cost even on an otherwise
|
|
184
|
+
// fully warm run — skipping the whole function on an unchanged package root
|
|
185
|
+
// avoids it entirely, the same way discovery-cache.ts's walk-skip avoids
|
|
186
|
+
// re-walking an unchanged marketplace tree.
|
|
154
187
|
export function readAgents(pkg) {
|
|
188
|
+
const fingerprint = fingerprintTree(pkg.root);
|
|
189
|
+
const key = JSON.stringify(["agents", pkg.root]);
|
|
190
|
+
const cached = getCachedValue(key, fingerprint);
|
|
191
|
+
if (cached)
|
|
192
|
+
return cached;
|
|
193
|
+
const result = readAgentsUncached(pkg);
|
|
194
|
+
setCachedValue(key, fingerprint, result);
|
|
195
|
+
return result;
|
|
196
|
+
}
|
|
197
|
+
function readAgentsUncached(pkg) {
|
|
155
198
|
const out = new Map();
|
|
156
|
-
const manifest = asRecord(
|
|
199
|
+
const manifest = asRecord(readContainedJson(pkg.root, join(pkg.root, "plugin.json")));
|
|
157
200
|
const extensions = asRecord(manifest?.extensions);
|
|
158
201
|
const opencodeExt = asRecord(extensions?.[OPENCODE_NS]);
|
|
159
202
|
const manifestAgents = asRecord(opencodeExt?.agents);
|
|
@@ -167,7 +210,7 @@ export function readAgents(pkg) {
|
|
|
167
210
|
}
|
|
168
211
|
if (out.has(name))
|
|
169
212
|
continue;
|
|
170
|
-
const agent = toAgentConfig(raw);
|
|
213
|
+
const agent = toAgentConfig(raw, pkg.name, name);
|
|
171
214
|
if (agent)
|
|
172
215
|
out.set(name, agent);
|
|
173
216
|
}
|
|
@@ -192,11 +235,11 @@ export function readAgents(pkg) {
|
|
|
192
235
|
}
|
|
193
236
|
if (out.has(name))
|
|
194
237
|
continue;
|
|
195
|
-
const agent = toAgentConfig(
|
|
238
|
+
const agent = toAgentConfig(readContainedJson(pkg.root, join(extDir, entry)), pkg.name, name);
|
|
196
239
|
if (agent)
|
|
197
240
|
out.set(name, agent);
|
|
198
241
|
}
|
|
199
|
-
const claudeManifest = asRecord(
|
|
242
|
+
const claudeManifest = asRecord(readContainedJson(pkg.root, join(pkg.root, ".claude-plugin", "plugin.json")));
|
|
200
243
|
const claudeAgents = asRecord(claudeManifest?.agents);
|
|
201
244
|
if (claudeAgents) {
|
|
202
245
|
for (const [name, raw] of Object.entries(claudeAgents)) {
|
|
@@ -216,11 +259,17 @@ export function readAgents(pkg) {
|
|
|
216
259
|
agent.prompt = src.systemPrompt;
|
|
217
260
|
}
|
|
218
261
|
else {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
262
|
+
// AGENTS.md is package-supplied prompt content: only read it when it
|
|
263
|
+
// resolves inside the package, so a symlinked shim cannot pull in an
|
|
264
|
+
// outside file's bytes.
|
|
265
|
+
const promptPath = resolveContained(pkg.root, join(pkg.root, "agents", name, "AGENTS.md"));
|
|
266
|
+
if (promptPath) {
|
|
267
|
+
try {
|
|
268
|
+
agent.prompt = readFileSync(promptPath, "utf8");
|
|
269
|
+
}
|
|
270
|
+
catch {
|
|
271
|
+
// No prompt file; the description alone is enough to register.
|
|
272
|
+
}
|
|
224
273
|
}
|
|
225
274
|
}
|
|
226
275
|
if (typeof src.model === "string")
|
|
@@ -255,18 +304,28 @@ export function readAgents(pkg) {
|
|
|
255
304
|
}
|
|
256
305
|
if (out.has(name))
|
|
257
306
|
continue;
|
|
258
|
-
|
|
307
|
+
// Flat agent files are package-supplied prompt content: only read one
|
|
308
|
+
// when it resolves inside the package, so a symlinked .md cannot pull in
|
|
309
|
+
// an outside file's bytes.
|
|
310
|
+
const contained = resolveContained(pkg.root, join(flatAgentsDir, entry));
|
|
311
|
+
if (!contained)
|
|
312
|
+
continue;
|
|
313
|
+
let parsed;
|
|
259
314
|
try {
|
|
260
|
-
|
|
315
|
+
parsed = cachedRead("flat-agent-md", contained, (content) => {
|
|
316
|
+
// Bare .md files in the package root may be docs (README.md); only
|
|
317
|
+
// treat them as agents when they carry a frontmatter block.
|
|
318
|
+
if (isRoot && !/^---\s*\n/.test(content))
|
|
319
|
+
return null;
|
|
320
|
+
return parseAgentMarkdown(content);
|
|
321
|
+
});
|
|
261
322
|
}
|
|
262
323
|
catch {
|
|
263
324
|
continue;
|
|
264
325
|
}
|
|
265
|
-
|
|
266
|
-
// them as agents when they carry a frontmatter block.
|
|
267
|
-
if (isRoot && !/^---\s*\n/.test(content))
|
|
326
|
+
if (!parsed)
|
|
268
327
|
continue;
|
|
269
|
-
const { description, color, body } =
|
|
328
|
+
const { description, color, body } = parsed;
|
|
270
329
|
if (!description && !body)
|
|
271
330
|
continue;
|
|
272
331
|
const agent = {};
|
package/dist/agents.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.js","sourceRoot":"","sources":["../src/agents.ts"],"names":[],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ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function pluginCacheRoot(): string;
|
|
2
|
+
export declare function _resetFileCacheForTests(): void;
|
|
3
|
+
export declare function cachedRead<T>(kind: string, path: string, parse: (content: string) => T): T;
|
|
4
|
+
export declare function flushFileCache(): void;
|
|
5
|
+
//# sourceMappingURL=cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AAqCA,wBAAgB,eAAe,IAAI,MAAM,CAGxC;AAyBD,wBAAgB,uBAAuB,IAAI,IAAI,CAG9C;AAgBD,wBAAgB,UAAU,CAAC,CAAC,EAC1B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,CAAC,GAC5B,CAAC,CAaH;AAMD,wBAAgB,cAAc,IAAI,IAAI,CAWrC"}
|
package/dist/cache.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { mkdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
const CACHE_FILE_NAME = "discovery-file-cache.json";
|
|
5
|
+
// Bump when the shape of a cached `value` changes, so an old on-disk cache
|
|
6
|
+
// from a prior plugin version is discarded instead of misread.
|
|
7
|
+
const CACHE_VERSION = 1;
|
|
8
|
+
let store = null;
|
|
9
|
+
let dirty = false;
|
|
10
|
+
// Deliberately its own root, separate from {state}/opencode/plugin-data/:
|
|
11
|
+
// that tree is reserved for *discovered* packages' own data (created only
|
|
12
|
+
// when a package's mcp.json is actually processed), and several tests assert
|
|
13
|
+
// it stays untouched when discovery finds nothing that needs it. This cache
|
|
14
|
+
// belongs to the plugin itself, not to anything it discovers. Exported so
|
|
15
|
+
// other plugin-owned caches (discovery-cache.ts) share one root instead of
|
|
16
|
+
// inventing their own convention.
|
|
17
|
+
export function pluginCacheRoot() {
|
|
18
|
+
const base = process.env.XDG_CACHE_HOME || join(homedir(), ".cache");
|
|
19
|
+
return join(base, "opencode-skill-autodiscovery");
|
|
20
|
+
}
|
|
21
|
+
function cacheFilePath() {
|
|
22
|
+
return join(pluginCacheRoot(), CACHE_FILE_NAME);
|
|
23
|
+
}
|
|
24
|
+
function loadStore() {
|
|
25
|
+
if (store)
|
|
26
|
+
return store;
|
|
27
|
+
try {
|
|
28
|
+
const raw = JSON.parse(readFileSync(cacheFilePath(), "utf8"));
|
|
29
|
+
store =
|
|
30
|
+
raw && raw.version === CACHE_VERSION && raw.entries && typeof raw.entries === "object"
|
|
31
|
+
? raw.entries
|
|
32
|
+
: {};
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
store = {};
|
|
36
|
+
}
|
|
37
|
+
return store;
|
|
38
|
+
}
|
|
39
|
+
// Test-only seam: drops the in-memory store so the next cachedRead/flush
|
|
40
|
+
// reloads from disk (or starts empty) instead of reusing state left over
|
|
41
|
+
// from a previous test's HOME. Production code never calls this: one
|
|
42
|
+
// opencode process makes exactly one config() call, so a process-lifetime
|
|
43
|
+
// singleton is the right scope there.
|
|
44
|
+
export function _resetFileCacheForTests() {
|
|
45
|
+
store = null;
|
|
46
|
+
dirty = false;
|
|
47
|
+
}
|
|
48
|
+
// Reads `path` and feeds its content to `parse`, reusing a previous result
|
|
49
|
+
// when the file's (mtimeMs, size) match the last successful cachedRead of the
|
|
50
|
+
// same (kind, path) pair. Throws exactly when `readFileSync`/`statSync` would
|
|
51
|
+
// have thrown (missing file, permission error, etc.) — existing callers
|
|
52
|
+
// already wrap those in try/catch, so behavior is unchanged when nothing is
|
|
53
|
+
// cached yet. `parse` must be pure and return a JSON-serializable value: it
|
|
54
|
+
// round-trips through the on-disk cache verbatim.
|
|
55
|
+
//
|
|
56
|
+
// `kind` namespaces the cache entry by what `parse` extracts, not just which
|
|
57
|
+
// file: the same file is read for different purposes at different call sites
|
|
58
|
+
// (e.g. "does this .md have agent frontmatter" vs. "the parsed agent from
|
|
59
|
+
// this .md"), and those must never share one cached value. The key is built
|
|
60
|
+
// with JSON.stringify (not string concatenation) so no separator choice can
|
|
61
|
+
// ever collide with a path or kind that happens to contain it.
|
|
62
|
+
export function cachedRead(kind, path, parse) {
|
|
63
|
+
const st = statSync(path);
|
|
64
|
+
const key = JSON.stringify([kind, path]);
|
|
65
|
+
const s = loadStore();
|
|
66
|
+
const cached = s[key];
|
|
67
|
+
if (cached && cached.mtimeMs === st.mtimeMs && cached.size === st.size) {
|
|
68
|
+
return cached.value;
|
|
69
|
+
}
|
|
70
|
+
const content = readFileSync(path, "utf8");
|
|
71
|
+
const value = parse(content);
|
|
72
|
+
s[key] = { mtimeMs: st.mtimeMs, size: st.size, value };
|
|
73
|
+
dirty = true;
|
|
74
|
+
return value;
|
|
75
|
+
}
|
|
76
|
+
// Persists the in-memory cache to disk when it changed. Best-effort, like
|
|
77
|
+
// every other filesystem side effect in this codebase: a failed write is
|
|
78
|
+
// swallowed rather than surfaced, since caching is an optimization and must
|
|
79
|
+
// never be able to break discovery.
|
|
80
|
+
export function flushFileCache() {
|
|
81
|
+
if (!dirty || !store)
|
|
82
|
+
return;
|
|
83
|
+
try {
|
|
84
|
+
const path = cacheFilePath();
|
|
85
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
86
|
+
const payload = { version: CACHE_VERSION, entries: store };
|
|
87
|
+
writeFileSync(path, JSON.stringify(payload));
|
|
88
|
+
dirty = false;
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
// Non-fatal: the next run just re-reads everything.
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,aAAa,EA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CAAC,KAAK,IAAI,CAAC,KAAK;QAAE,OAAO;IAC7B,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,aAAa,EAAE,CAAC;QAC7B,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC9C,MAAM,OAAO,GAAc,EAAE,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;QACtE,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;QAC7C,KAAK,GAAG,KAAK,CAAC;IAChB,CAAC;IAAC,MAAM,CAAC;QACP,oDAAoD;IACtD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { PluginPackage } from "./discovery.js";
|
|
2
|
+
export declare function _resetDiscoveryCacheForTests(): void;
|
|
3
|
+
export declare function fingerprintTree(root: string): string;
|
|
4
|
+
export declare function getCachedPackages(key: string, fingerprint: string): PluginPackage[] | null;
|
|
5
|
+
export declare function setCachedPackages(key: string, fingerprint: string, packages: PluginPackage[]): void;
|
|
6
|
+
export declare function getCachedValue<T>(key: string, fingerprint: string): T | null;
|
|
7
|
+
export declare function setCachedValue<T>(key: string, fingerprint: string, value: T): void;
|
|
8
|
+
export declare function flushDiscoveryCache(): void;
|
|
9
|
+
//# sourceMappingURL=discovery-cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery-cache.d.ts","sourceRoot":"","sources":["../src/discovery-cache.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AA+DpD,wBAAgB,4BAA4B,IAAI,IAAI,CAGnD;AAcD,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAOpD;AA2BD,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,aAAa,EAAE,GAAG,IAAI,CAE1F;AAKD,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,MAAM,EACX,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,aAAa,EAAE,GACxB,IAAI,CAEN;AAWD,wBAAgB,cAAc,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI,CAG5E;AAED,wBAAgB,cAAc,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAGlF;AAQD,wBAAgB,mBAAmB,IAAI,IAAI,CAa1C"}
|