@rbbtsn0w/adg 0.6.0 → 0.7.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 +41 -9
- package/dist/bin/adg.js +4 -4
- package/dist/src/adapters/codex.js +12 -0
- package/dist/src/adapters/reverse.js +22 -1
- package/dist/src/agents/base.js +2 -1
- package/dist/src/agents/claude.js +52 -6
- package/dist/src/agents/codex.js +94 -14
- package/dist/src/cli/core-plugin-handlers.js +97 -0
- package/dist/src/cli/handlers.js +155 -210
- package/dist/src/cli/index.js +14 -4
- package/dist/src/codex-marketplace-migration.js +139 -0
- package/dist/src/commands/cache.js +92 -15
- package/dist/src/commands/inspect.js +41 -0
- package/dist/src/commands/install.js +140 -73
- package/dist/src/commands/link.js +4 -16
- package/dist/src/commands/marketplace.js +74 -20
- package/dist/src/commands/migrate.js +15 -3
- package/dist/src/commands/projection.js +15 -0
- package/dist/src/commands/select-components.js +12 -0
- package/dist/src/commands/state.js +4 -2
- package/dist/src/commands/sync.js +9 -15
- package/dist/src/commands/update.js +51 -10
- package/dist/src/commands/validate.js +9 -2
- package/dist/src/components.js +3 -0
- package/dist/src/default-dsl.js +142 -0
- package/dist/src/lock.js +25 -7
- package/dist/src/manifest.js +85 -4
- package/dist/src/materialize.js +5 -1
- package/dist/src/mcp.js +59 -0
- package/dist/src/paths.js +31 -4
- package/dist/src/render/plugins.js +7 -1
- package/dist/src/source-cache.js +140 -0
- package/dist/src/sources.js +76 -5
- package/dist/src/subprocess.js +53 -0
- package/dist/src/telemetry.js +28 -21
- package/dist/src/types.js +5 -1
- package/dist/vendor/skills/src/add.js +0 -15
- package/dist/vendor/skills/src/cli.js +6 -1
- package/dist/vendor/skills/src/git-tree.js +4 -4
- package/dist/vendor/skills/src/skill-lock.js +4 -3
- package/dist/vendor/skills/src/update.js +38 -77
- package/dist/vendor/skills/src/use.js +28 -4
- package/docs/agents-spec.md +27 -4
- package/docs/authoring.md +19 -2
- package/docs/branching-and-release.md +52 -0
- package/package.json +14 -3
- package/schemas/adg-plugin.schema.json +2 -0
- package/schemas/plugin-lock.schema.json +23 -1
- package/vendor/skills/PROVENANCE.md +2 -0
- package/vendor/skills/package.json +0 -144
- package/vendor/skills/src/add.ts +0 -2213
- package/vendor/skills/src/agents.ts +0 -811
- package/vendor/skills/src/blob.ts +0 -588
- package/vendor/skills/src/cli.ts +0 -391
- package/vendor/skills/src/constants.ts +0 -3
- package/vendor/skills/src/detect-agent.ts +0 -62
- package/vendor/skills/src/find.ts +0 -419
- package/vendor/skills/src/frontmatter.ts +0 -16
- package/vendor/skills/src/git-tree.ts +0 -36
- package/vendor/skills/src/git.ts +0 -277
- package/vendor/skills/src/install.ts +0 -91
- package/vendor/skills/src/installer.ts +0 -1307
- package/vendor/skills/src/list.ts +0 -231
- package/vendor/skills/src/local-lock.ts +0 -189
- package/vendor/skills/src/plugin-manifest.ts +0 -183
- package/vendor/skills/src/prompts/search-multiselect.ts +0 -387
- package/vendor/skills/src/providers/index.ts +0 -14
- package/vendor/skills/src/providers/registry.ts +0 -51
- package/vendor/skills/src/providers/types.ts +0 -97
- package/vendor/skills/src/providers/wellknown.ts +0 -812
- package/vendor/skills/src/remove.ts +0 -335
- package/vendor/skills/src/sanitize.ts +0 -65
- package/vendor/skills/src/self-cli.ts +0 -20
- package/vendor/skills/src/skill-lock.ts +0 -329
- package/vendor/skills/src/skills.ts +0 -316
- package/vendor/skills/src/source-parser.ts +0 -449
- package/vendor/skills/src/sync.ts +0 -478
- package/vendor/skills/src/telemetry.ts +0 -226
- package/vendor/skills/src/test-utils.ts +0 -73
- package/vendor/skills/src/types.ts +0 -129
- package/vendor/skills/src/update-source.ts +0 -90
- package/vendor/skills/src/update.ts +0 -821
- package/vendor/skills/src/use.ts +0 -682
package/README.md
CHANGED
|
@@ -31,6 +31,21 @@ See [docs/authoring.md](docs/authoring.md) to author a plugin, and
|
|
|
31
31
|
- **Reproducibility** — `.plugin-lock.json` records source, version and a content
|
|
32
32
|
hash for every installed plugin.
|
|
33
33
|
|
|
34
|
+
## Default plugin layout
|
|
35
|
+
|
|
36
|
+
A repository without a manifest is also installable when it uses the standard
|
|
37
|
+
plugin locations: `skills/<name>/SKILL.md`, `hooks/hooks.json`, or `.mcp.json`.
|
|
38
|
+
ADG derives a default manifest from the locations that exist. Add
|
|
39
|
+
`.agents/.plugin.json` only when a source needs custom component paths or other
|
|
40
|
+
plugin metadata; its `skills`, `hooks`, and `mcpServers` fields override only
|
|
41
|
+
their matching defaults, while omitted fields inherit valid standard locations.
|
|
42
|
+
For structural sources, `--as` sets a stable installed identity and `--only`
|
|
43
|
+
limits both the stored payload and runtime exposure. In non-interactive runs,
|
|
44
|
+
discovered hooks or MCP require explicit `--only`. Default DSL applies only to
|
|
45
|
+
the source root. It is not a monorepo convention: every member of a
|
|
46
|
+
multi-plugin repository must declare its own `.agents/.plugin.json` and be
|
|
47
|
+
selected with `--plugin` or `--all`.
|
|
48
|
+
|
|
34
49
|
---
|
|
35
50
|
|
|
36
51
|
# Install and quick start
|
|
@@ -156,6 +171,20 @@ adg plugins update --global
|
|
|
156
171
|
adg plugins link --target claude --global
|
|
157
172
|
```
|
|
158
173
|
|
|
174
|
+
### Example 3 — `cloudflare/skills` (auto-discovery and selective installation)
|
|
175
|
+
|
|
176
|
+
A repository containing skills for the Cloudflare Developer Platform. Although the repository doesn't explicitly declare an MCP configuration in its native `.claude-plugin/plugin.json` manifest, it includes a `.mcp.json` file in its root. ADG auto-discovers this file, allowing you to selectively choose which components, skills, or MCP servers to install:
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
# Add the cloudflare plugin globally (interactive guide asks which skills/MCP servers to install)
|
|
180
|
+
adg plugins add https://github.com/cloudflare/skills --global
|
|
181
|
+
|
|
182
|
+
# Or install it non-interactively, limiting to specific skills and MCP servers:
|
|
183
|
+
adg plugins add https://github.com/cloudflare/skills --global \
|
|
184
|
+
--skill agents-sdk --skill cloudflare --skill durable-objects \
|
|
185
|
+
--mcp wrangler-mcp --mcp d1-mcp
|
|
186
|
+
```
|
|
187
|
+
|
|
159
188
|
> Both repos are pulled by `owner/repo` shorthand over a shallow clone (sparse
|
|
160
189
|
> checkout when `--sparse` is given). Provenance — `{type:"github",repo,ref,path}`
|
|
161
190
|
> — plus a `sha256` integrity hash land in `.plugin-lock.json`, so the install is
|
|
@@ -252,9 +281,9 @@ adg plugins add plugins/my-plugin --project # <repo>/.agents/plugins
|
|
|
252
281
|
adg plugins add plugins/my-plugin --global # ~/.agents/plugins
|
|
253
282
|
adg plugins add plugins/asc --dir plugins # explicit target dir
|
|
254
283
|
|
|
255
|
-
# add from GitHub (shorthand, @ref, or full URL)
|
|
284
|
+
# add from GitHub (shorthand, @ref, or full URL)
|
|
256
285
|
adg plugins add owner/repo --dir plugins
|
|
257
|
-
adg plugins add owner/repo@v0.1.0 --
|
|
286
|
+
adg plugins add owner/repo@v0.1.0 --plugin asc --dir plugins
|
|
258
287
|
adg plugins add https://github.com/owner/repo.git --ref main --dir plugins
|
|
259
288
|
adg plugins add plugins/asc --dir plugins --no-deps # skip transitive deps
|
|
260
289
|
|
|
@@ -394,7 +423,7 @@ private discovery path:
|
|
|
394
423
|
# Developing from source
|
|
395
424
|
|
|
396
425
|
For working on the CLI itself, or testing a plugin before release. The CLI runs
|
|
397
|
-
directly on **Node ≥ 22.
|
|
426
|
+
directly on **Node ≥ 22.18** via native TypeScript type-stripping — **no build
|
|
398
427
|
step**.
|
|
399
428
|
|
|
400
429
|
```bash
|
|
@@ -406,8 +435,11 @@ node bin/adg.ts --help
|
|
|
406
435
|
node bin/adg.ts plugins validate plugins/asc
|
|
407
436
|
|
|
408
437
|
# quality gates
|
|
409
|
-
npm test # node --test
|
|
438
|
+
npm test # node --test
|
|
410
439
|
npm run typecheck # tsc --noEmit
|
|
440
|
+
npm run check:docs # internal Markdown links
|
|
441
|
+
npm run build
|
|
442
|
+
npm run check:package-smoke # install and exercise the packed CLI
|
|
411
443
|
```
|
|
412
444
|
|
|
413
445
|
Debugging tips:
|
|
@@ -419,11 +451,11 @@ Debugging tips:
|
|
|
419
451
|
node bin/adg.ts plugins add ./some/repo --dir /tmp/adg-store
|
|
420
452
|
node bin/adg.ts plugins list --dir /tmp/adg-store
|
|
421
453
|
```
|
|
422
|
-
- **Refreshing
|
|
423
|
-
`
|
|
424
|
-
`node bin/adg.ts plugins update --dir
|
|
425
|
-
- **Inspect generated manifests**
|
|
426
|
-
|
|
454
|
+
- **Refreshing scratch artifacts:** `.plugin-lock.json` and `marketplace.json`
|
|
455
|
+
inside your chosen `--dir` store are generated. Re-sync that store with
|
|
456
|
+
`node bin/adg.ts plugins update --dir /tmp/adg-store`.
|
|
457
|
+
- **Inspect generated manifests** inside the scratch store to confirm adaptation
|
|
458
|
+
output without relying on ignored repository-local artifacts.
|
|
427
459
|
- GitHub clone/sparse logic is injectable (`gitRunner`) and covered offline by
|
|
428
460
|
the test suite; live network clones are exercised by `import owner/repo`.
|
|
429
461
|
|
package/dist/bin/adg.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { spawnSync } from "node:child_process";
|
|
3
2
|
import { readFileSync, realpathSync } from "node:fs";
|
|
4
3
|
import { dirname, join, resolve } from "node:path";
|
|
5
4
|
import { fileURLToPath } from "node:url";
|
|
@@ -10,6 +9,7 @@ import { TOP_USAGE, fail } from "../src/cli/index.js";
|
|
|
10
9
|
import { runPlugins } from "../src/cli/handlers.js";
|
|
11
10
|
import { getTracer, shutdownTelemetry, sanitizeArgs } from "../src/telemetry.js";
|
|
12
11
|
import { SpanKind, SpanStatusCode, propagation, context } from "@opentelemetry/api";
|
|
12
|
+
import { runSubprocessSync } from "../src/subprocess.js";
|
|
13
13
|
// ---------------------------------------------------------------------------
|
|
14
14
|
// `adg` entry point: thin wire-up only.
|
|
15
15
|
//
|
|
@@ -47,7 +47,8 @@ function runSkills(verb, rest) {
|
|
|
47
47
|
// Inject current active OpenTelemetry context into environment variables
|
|
48
48
|
const envCarrier = {};
|
|
49
49
|
propagation.inject(context.active(), envCarrier);
|
|
50
|
-
const
|
|
50
|
+
const childArgs = skillsChildArgv(entry, args);
|
|
51
|
+
const r = runSubprocessSync(process.execPath, childArgs, {
|
|
51
52
|
stdio: "inherit",
|
|
52
53
|
env: {
|
|
53
54
|
...process.env,
|
|
@@ -63,7 +64,7 @@ function runSelfUpdate(args) {
|
|
|
63
64
|
return 0;
|
|
64
65
|
}
|
|
65
66
|
const command = selfUpdateCommand(options.beta);
|
|
66
|
-
const r =
|
|
67
|
+
const r = runSubprocessSync(command.command, command.args, selfUpdateSpawnOptions());
|
|
67
68
|
if (r.error) {
|
|
68
69
|
console.error(r.error.message);
|
|
69
70
|
return 1;
|
|
@@ -104,7 +105,6 @@ async function main(argv) {
|
|
|
104
105
|
let status = 0;
|
|
105
106
|
try {
|
|
106
107
|
span.setAttribute("process.executable.name", "adg");
|
|
107
|
-
span.setAttribute("process.executable.path", process.argv[1] || process.execPath);
|
|
108
108
|
span.setAttribute("process.pid", process.pid);
|
|
109
109
|
span.setAttribute("process.command_args", sanitizeArgs(["adg", ...argv]));
|
|
110
110
|
// Check for an available update (reads local cache; schedules a background
|
|
@@ -3,6 +3,7 @@ import { join } from "node:path";
|
|
|
3
3
|
import { resolveProjectedSkills } from "../skills.js";
|
|
4
4
|
import { isExposed } from "../components.js";
|
|
5
5
|
import { mcpConfigPath } from "../mcp.js";
|
|
6
|
+
import { recordTelemetryEvent } from "../telemetry.js";
|
|
6
7
|
/**
|
|
7
8
|
* Resolve the hooks config *file* Codex should reference. ADG declares `hooks` as
|
|
8
9
|
* a directory, but Codex (unlike Claude) has no auto-load — it needs an explicit
|
|
@@ -52,6 +53,17 @@ export function toCodexManifest(pluginDir, manifest, selection) {
|
|
|
52
53
|
description: manifest.description,
|
|
53
54
|
skills,
|
|
54
55
|
};
|
|
56
|
+
const displayName = typeof manifest.interface?.displayName === "string" ? manifest.interface.displayName : undefined;
|
|
57
|
+
const explicitShortDescription = typeof manifest.interface?.shortDescription === "string" && manifest.interface.shortDescription.trim()
|
|
58
|
+
? manifest.interface.shortDescription.trim()
|
|
59
|
+
: undefined;
|
|
60
|
+
out.interface = {
|
|
61
|
+
...(displayName ? { displayName } : {}),
|
|
62
|
+
shortDescription: explicitShortDescription ?? manifest.description,
|
|
63
|
+
};
|
|
64
|
+
recordTelemetryEvent("adg.codex.interface", {
|
|
65
|
+
"interface.short_description_source": explicitShortDescription ? "explicit" : "manifest",
|
|
66
|
+
});
|
|
55
67
|
if (manifest.author)
|
|
56
68
|
out.author = manifest.author;
|
|
57
69
|
if (manifest.homepage)
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { existsSync, statSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
1
3
|
import { ADG_SCHEMA_VERSION } from "../types.js";
|
|
2
4
|
import { validateManifest } from "../manifest.js";
|
|
3
5
|
import { toPosix } from "../fsutil.js";
|
|
@@ -15,7 +17,7 @@ import { toPosix } from "../fsutil.js";
|
|
|
15
17
|
* emits valid `./skills/<id>` entries instead of leaking bare ids into a Claude
|
|
16
18
|
* manifest.
|
|
17
19
|
*/
|
|
18
|
-
export function fromNativeManifest(raw, kind) {
|
|
20
|
+
export function fromNativeManifest(raw, kind, pluginDir) {
|
|
19
21
|
if (typeof raw !== "object" || raw === null) {
|
|
20
22
|
throw new Error("native manifest must be a JSON object");
|
|
21
23
|
}
|
|
@@ -36,6 +38,14 @@ export function fromNativeManifest(raw, kind) {
|
|
|
36
38
|
copyIfString(n, out, "agents");
|
|
37
39
|
copyIfString(n, out, "hooks");
|
|
38
40
|
copyIfString(n, out, "mcpServers");
|
|
41
|
+
if (typeof out.mcpServers !== "string") {
|
|
42
|
+
if (typeof n.mcp === "string") {
|
|
43
|
+
out.mcpServers = n.mcp;
|
|
44
|
+
}
|
|
45
|
+
else if (pluginDir && existsSync(join(pluginDir, ".mcp.json"))) {
|
|
46
|
+
out.mcpServers = "./.mcp.json";
|
|
47
|
+
}
|
|
48
|
+
}
|
|
39
49
|
copyIfString(n, out, "apps");
|
|
40
50
|
if (typeof n.author === "object" && n.author !== null) {
|
|
41
51
|
manifest.author = n.author;
|
|
@@ -57,6 +67,17 @@ export function fromNativeManifest(raw, kind) {
|
|
|
57
67
|
manifest.skills = "./skills/";
|
|
58
68
|
}
|
|
59
69
|
manifest.strict = typeof n.strict === "boolean" ? n.strict : true;
|
|
70
|
+
if (!manifest.hooks && pluginDir) {
|
|
71
|
+
const hooksDir = join(pluginDir, "hooks");
|
|
72
|
+
try {
|
|
73
|
+
if (existsSync(hooksDir) && statSync(hooksDir).isDirectory())
|
|
74
|
+
manifest.hooks = "./hooks/";
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
// hooks inference is best-effort; unreadable or concurrently removed dirs
|
|
78
|
+
// must not abort reverse-adaptation.
|
|
79
|
+
}
|
|
80
|
+
}
|
|
60
81
|
return validateManifest(manifest);
|
|
61
82
|
}
|
|
62
83
|
function copyIfString(src, dst, key) {
|
package/dist/src/agents/base.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { spawnSync } from "node:child_process";
|
|
2
2
|
import { SpanKind, SpanStatusCode } from "@opentelemetry/api";
|
|
3
3
|
import { getTracer, sanitizeArgs } from "../telemetry.js";
|
|
4
|
+
import { runSubprocessSync } from "../subprocess.js";
|
|
4
5
|
/**
|
|
5
6
|
* The canonical "CLI absent, so nothing was touched" lifecycle result. Every
|
|
6
7
|
* agent's activate/deactivate guard returns this shape; centralizing it keeps
|
|
@@ -99,7 +100,7 @@ export function makeCli(bin, opts) {
|
|
|
99
100
|
// so importing an agent module never spawns a subprocess.
|
|
100
101
|
let probed;
|
|
101
102
|
return {
|
|
102
|
-
available: () => (probed ??=
|
|
103
|
+
available: () => (probed ??= runSubprocessSync(bin, opts.probeArgs, { stdio: "ignore" }).status === 0),
|
|
103
104
|
run: (args) => {
|
|
104
105
|
const tracer = getTracer();
|
|
105
106
|
return tracer.startActiveSpan(bin, { kind: SpanKind.CLIENT }, (span) => {
|
|
@@ -16,6 +16,7 @@ import { makeCli, skippedResult } from "./base.js";
|
|
|
16
16
|
* versions) rather than hand-editing Claude's internal state.
|
|
17
17
|
*/
|
|
18
18
|
const MARKETPLACE = "adg";
|
|
19
|
+
const UNRECOGNIZED_PLUGIN_LIST = "claude plugin list returned unrecognized output";
|
|
19
20
|
function claudeHome(env) {
|
|
20
21
|
return env.CLAUDE_CONFIG_DIR?.trim() || join(homedir(), ".claude");
|
|
21
22
|
}
|
|
@@ -94,7 +95,7 @@ export function parseClaudeMarketplaceList(out) {
|
|
|
94
95
|
}
|
|
95
96
|
}
|
|
96
97
|
/** Register or refresh the ADG store as a Claude marketplace, failing open. */
|
|
97
|
-
export function syncMarketplace(pluginsDir, name, runner = run) {
|
|
98
|
+
export function syncMarketplace(pluginsDir, name, runner = run, warn = console.warn) {
|
|
98
99
|
const listed = runner(["plugin", "marketplace", "list", "--json"]);
|
|
99
100
|
if (listed.ok && parseClaudeMarketplaceList(listed.out).includes(name)) {
|
|
100
101
|
// Claude's marketplace update path can fail on existing installs (for
|
|
@@ -104,7 +105,10 @@ export function syncMarketplace(pluginsDir, name, runner = run) {
|
|
|
104
105
|
if (runner(["plugin", "marketplace", "update", name]).ok)
|
|
105
106
|
return;
|
|
106
107
|
}
|
|
107
|
-
runner(["plugin", "marketplace", "add", pluginsDir]);
|
|
108
|
+
const added = runner(["plugin", "marketplace", "add", pluginsDir]);
|
|
109
|
+
if (!added.ok) {
|
|
110
|
+
warn(`failed to sync Claude marketplace (${name}): ${added.out.trim() || "claude plugin marketplace add failed without an error message"}`);
|
|
111
|
+
}
|
|
108
112
|
}
|
|
109
113
|
export const claudeAgent = {
|
|
110
114
|
id: "claude",
|
|
@@ -156,12 +160,54 @@ export const claudeAgent = {
|
|
|
156
160
|
listInstalled(ctx) {
|
|
157
161
|
if (!available())
|
|
158
162
|
return undefined;
|
|
159
|
-
const
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
+
const marketplace = claudeMarketplaceName(ctx.pluginsDir);
|
|
164
|
+
const jsonRes = run(["plugin", "list", "--json"]);
|
|
165
|
+
if (jsonRes.ok) {
|
|
166
|
+
const parsed = parseClaudePluginListJson(jsonRes.out, marketplace, ctx.scope);
|
|
167
|
+
if (parsed !== undefined)
|
|
168
|
+
return parsed;
|
|
169
|
+
return claudeListFailure(jsonRes.out);
|
|
170
|
+
}
|
|
171
|
+
const textRes = run(["plugin", "list"]);
|
|
172
|
+
if (!textRes.ok)
|
|
173
|
+
return { error: textRes.out.trim() || jsonRes.out.trim() || "claude plugin list failed without an error message" };
|
|
174
|
+
const fallback = parseClaudePluginList(textRes.out, marketplace, ctx.scope);
|
|
175
|
+
if (fallback.length > 0 || textRes.out.trim() === "")
|
|
176
|
+
return fallback;
|
|
177
|
+
return claudeListFailure(textRes.out);
|
|
163
178
|
},
|
|
164
179
|
};
|
|
180
|
+
export function claudeListFailure(out) {
|
|
181
|
+
const detail = out.trim() || "claude plugin list failed without an error message";
|
|
182
|
+
return { error: `${UNRECOGNIZED_PLUGIN_LIST}: ${detail}` };
|
|
183
|
+
}
|
|
184
|
+
/** Parse `claude plugin list --json` into enabled plugin names for a marketplace + scope. */
|
|
185
|
+
export function parseClaudePluginListJson(out, marketplace, scope) {
|
|
186
|
+
try {
|
|
187
|
+
const parsed = JSON.parse(out);
|
|
188
|
+
if (!Array.isArray(parsed))
|
|
189
|
+
return undefined;
|
|
190
|
+
const names = [];
|
|
191
|
+
const seen = new Set();
|
|
192
|
+
for (const entry of parsed) {
|
|
193
|
+
if (typeof entry !== "object" || entry === null)
|
|
194
|
+
continue;
|
|
195
|
+
const record = entry;
|
|
196
|
+
const id = typeof record.id === "string" ? record.id : undefined;
|
|
197
|
+
const entryScope = typeof record.scope === "string" ? record.scope.toLowerCase() : undefined;
|
|
198
|
+
const enabled = record.enabled === true;
|
|
199
|
+
const head = id?.match(/^(\S+?)@([\w.-]+)$/);
|
|
200
|
+
if (!head || head[2] !== marketplace || entryScope !== scope || !enabled || seen.has(head[1]))
|
|
201
|
+
continue;
|
|
202
|
+
seen.add(head[1]);
|
|
203
|
+
names.push(head[1]);
|
|
204
|
+
}
|
|
205
|
+
return names;
|
|
206
|
+
}
|
|
207
|
+
catch {
|
|
208
|
+
return undefined;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
165
211
|
/**
|
|
166
212
|
* Parse `claude plugin list` output into the *enabled* plugin names from a given
|
|
167
213
|
* marketplace and install scope. The listing groups each plugin as a
|
package/dist/src/agents/codex.js
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
-
import { existsSync } from "node:fs";
|
|
2
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
3
3
|
import { homedir } from "node:os";
|
|
4
4
|
import { join, resolve } from "node:path";
|
|
5
|
+
import { SpanKind } from "@opentelemetry/api";
|
|
5
6
|
import { codexMarketplaceRoot, globalPluginsDir, marketplacePath } from "../paths.js";
|
|
6
7
|
import { readMarketplace, writeMarketplace } from "../marketplace.js";
|
|
7
8
|
import { makeCli, skippedResult } from "./base.js";
|
|
9
|
+
import { reconcileCodexMarketplaceAliases } from "../codex-marketplace-migration.js";
|
|
10
|
+
import { getTracer, recordTelemetryEvent } from "../telemetry.js";
|
|
11
|
+
const UNRECOGNIZED_PLUGIN_LIST = "codex plugin list returned unrecognized output";
|
|
12
|
+
const MARKETPLACE = "adg";
|
|
8
13
|
/**
|
|
9
14
|
* Codex agent.
|
|
10
15
|
*
|
|
@@ -18,16 +23,16 @@ function codexHome(env) {
|
|
|
18
23
|
}
|
|
19
24
|
const { available, run } = makeCli("codex", { probeArgs: ["plugin", "--help"] });
|
|
20
25
|
/**
|
|
21
|
-
* Codex's
|
|
22
|
-
* and explicit stores get a store-scoped name to avoid colliding with
|
|
23
|
-
* or another project's configured marketplace.
|
|
26
|
+
* Keep Codex's global marketplace identity aligned with the Claude projection.
|
|
27
|
+
* Project and explicit stores get a store-scoped name to avoid colliding with
|
|
28
|
+
* the global store or another project's configured marketplace.
|
|
24
29
|
*/
|
|
25
30
|
export function codexMarketplaceName(pluginsDir) {
|
|
26
31
|
const normalized = resolve(pluginsDir);
|
|
27
32
|
if (normalized === resolve(globalPluginsDir()))
|
|
28
|
-
return
|
|
33
|
+
return MARKETPLACE;
|
|
29
34
|
const hash = createHash("sha1").update(normalized.split("\\").join("/")).digest("hex").slice(0, 8);
|
|
30
|
-
return
|
|
35
|
+
return `${MARKETPLACE}-${hash}`;
|
|
31
36
|
}
|
|
32
37
|
/** Ensure the generated Codex marketplace export uses this store's scoped name. */
|
|
33
38
|
export function writeCodexMarketplaceName(pluginsDir) {
|
|
@@ -41,11 +46,40 @@ export function writeCodexMarketplaceName(pluginsDir) {
|
|
|
41
46
|
return name;
|
|
42
47
|
}
|
|
43
48
|
/** Register the local marketplace root Codex expects for this store. */
|
|
44
|
-
function syncMarketplace(pluginsDir, marketplace) {
|
|
49
|
+
export function syncMarketplace(pluginsDir, marketplace, runner = run, warn = console.warn) {
|
|
45
50
|
const root = codexMarketplaceRoot(pluginsDir);
|
|
46
|
-
const add =
|
|
47
|
-
if (
|
|
48
|
-
|
|
51
|
+
const add = runner(["plugin", "marketplace", "add", root]);
|
|
52
|
+
if (add.ok)
|
|
53
|
+
return;
|
|
54
|
+
const upgraded = runner(["plugin", "marketplace", "upgrade", marketplace]);
|
|
55
|
+
if (!upgraded.ok) {
|
|
56
|
+
warn(`failed to sync Codex marketplace (${marketplace}): ${upgraded.out.trim() || add.out.trim() || "codex plugin marketplace sync failed without an error message"}`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Best-effort retirement of historical aliases after canonical installs succeed.
|
|
61
|
+
* Keep this compatibility path only until telemetry reports no legacy aliases for
|
|
62
|
+
* two release cycles.
|
|
63
|
+
*/
|
|
64
|
+
function reconcileLegacyAliases(pluginsDir, marketplace, plugins) {
|
|
65
|
+
getTracer().startActiveSpan("adg.codex.marketplace_alias_migration", { kind: SpanKind.INTERNAL }, (span) => {
|
|
66
|
+
try {
|
|
67
|
+
const result = reconcileCodexMarketplaceAliases({
|
|
68
|
+
pluginsDir,
|
|
69
|
+
marketplace,
|
|
70
|
+
plugins,
|
|
71
|
+
readConfig: () => readFileSync(join(codexHome(process.env), "config.toml"), "utf8"),
|
|
72
|
+
run,
|
|
73
|
+
report: (attributes) => recordTelemetryEvent("adg.codex.marketplace_alias_migration", attributes, span),
|
|
74
|
+
});
|
|
75
|
+
if (result.outcome === "partial") {
|
|
76
|
+
console.warn("Codex legacy marketplace alias cleanup was only partially completed; rerun `adg plugins sync --target codex` to retry.");
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
finally {
|
|
80
|
+
span.end();
|
|
81
|
+
}
|
|
82
|
+
});
|
|
49
83
|
}
|
|
50
84
|
export const codexAgent = {
|
|
51
85
|
id: "codex",
|
|
@@ -63,6 +97,8 @@ export const codexAgent = {
|
|
|
63
97
|
if (run(["plugin", "add", `${p}@${mp}`]).ok)
|
|
64
98
|
affected.push(p);
|
|
65
99
|
}
|
|
100
|
+
if (ctx.reconcileLegacyAliases && affected.length > 0)
|
|
101
|
+
reconcileLegacyAliases(ctx.pluginsDir, mp, affected);
|
|
66
102
|
return { agent: "codex", affected, skipped: false };
|
|
67
103
|
},
|
|
68
104
|
deactivate(ctx) {
|
|
@@ -92,10 +128,20 @@ export const codexAgent = {
|
|
|
92
128
|
const mp = writeCodexMarketplaceName(ctx.pluginsDir);
|
|
93
129
|
if (!mp)
|
|
94
130
|
return undefined; // no generated marketplace → can't scope the query
|
|
95
|
-
const
|
|
96
|
-
if (
|
|
97
|
-
|
|
98
|
-
|
|
131
|
+
const jsonRes = run(["plugin", "list", "--json"]);
|
|
132
|
+
if (jsonRes.ok) {
|
|
133
|
+
const parsed = parseCodexPluginListJson(jsonRes.out, mp);
|
|
134
|
+
if (parsed !== undefined)
|
|
135
|
+
return parsed;
|
|
136
|
+
return codexUnrecognizedListFailure(jsonRes.out);
|
|
137
|
+
}
|
|
138
|
+
const textRes = run(["plugin", "list"]);
|
|
139
|
+
if (!textRes.ok)
|
|
140
|
+
return codexListFailure(textRes.out || jsonRes.out);
|
|
141
|
+
const fallback = parseCodexPluginList(textRes.out, mp);
|
|
142
|
+
if (fallback.length > 0 || textRes.out.trim() === "")
|
|
143
|
+
return fallback;
|
|
144
|
+
return codexUnrecognizedListFailure(textRes.out);
|
|
99
145
|
},
|
|
100
146
|
};
|
|
101
147
|
/** Preserve Codex's diagnostic and offer cleanup for a stale ADG project marketplace. */
|
|
@@ -107,6 +153,40 @@ export function codexListFailure(out) {
|
|
|
107
153
|
...(staleMarketplace ? { recoveryCommand: `codex plugin marketplace remove ${staleMarketplace[1]}` } : {}),
|
|
108
154
|
};
|
|
109
155
|
}
|
|
156
|
+
export function codexUnrecognizedListFailure(out) {
|
|
157
|
+
const detail = out.trim() || "codex plugin list failed without an error message";
|
|
158
|
+
return { error: `${UNRECOGNIZED_PLUGIN_LIST}: ${detail}` };
|
|
159
|
+
}
|
|
160
|
+
/** Parse `codex plugin list --json` into installed and enabled plugin names for one marketplace. */
|
|
161
|
+
export function parseCodexPluginListJson(out, marketplace) {
|
|
162
|
+
try {
|
|
163
|
+
const parsed = JSON.parse(out);
|
|
164
|
+
if (typeof parsed !== "object" || parsed === null)
|
|
165
|
+
return undefined;
|
|
166
|
+
const installed = parsed.installed;
|
|
167
|
+
if (!Array.isArray(installed))
|
|
168
|
+
return undefined;
|
|
169
|
+
const names = [];
|
|
170
|
+
const seen = new Set();
|
|
171
|
+
for (const entry of installed) {
|
|
172
|
+
if (typeof entry !== "object" || entry === null)
|
|
173
|
+
continue;
|
|
174
|
+
const record = entry;
|
|
175
|
+
const name = typeof record.name === "string" ? record.name : undefined;
|
|
176
|
+
const mp = typeof record.marketplaceName === "string" ? record.marketplaceName : undefined;
|
|
177
|
+
const isInstalled = record.installed === true;
|
|
178
|
+
const enabled = record.enabled === true;
|
|
179
|
+
if (!name || mp !== marketplace || !isInstalled || !enabled || seen.has(name))
|
|
180
|
+
continue;
|
|
181
|
+
seen.add(name);
|
|
182
|
+
names.push(name);
|
|
183
|
+
}
|
|
184
|
+
return names;
|
|
185
|
+
}
|
|
186
|
+
catch {
|
|
187
|
+
return undefined;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
110
190
|
/**
|
|
111
191
|
* Parse `codex plugin list` output into the *installed and enabled* plugin names
|
|
112
192
|
* from a given marketplace. The listing is a whitespace-aligned table whose
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
import { adaptPlugin } from "../commands/adapt.js";
|
|
3
|
+
import { initScaffold } from "../commands/init.js";
|
|
4
|
+
import { inspectSource } from "../commands/inspect.js";
|
|
5
|
+
import { listPlugins } from "../commands/list.js";
|
|
6
|
+
import { pluginStatus } from "../commands/status.js";
|
|
7
|
+
import { validatePlugin } from "../commands/validate.js";
|
|
8
|
+
import { ui } from "../render/ui.js";
|
|
9
|
+
import { pluginsListJson, pluginsStatusJson, printJson } from "../render/json.js";
|
|
10
|
+
import { renderPluginList, renderStatus } from "../render/plugins.js";
|
|
11
|
+
import { fail, parseVerb, resolveScopeDir, resolveTargets, scopeOf, } from "./index.js";
|
|
12
|
+
const CORE_PLUGIN_VERBS = new Set(["init", "adapt", "validate", "inspect", "list", "status"]);
|
|
13
|
+
export async function handleCorePluginVerb(verb, rest, cmd) {
|
|
14
|
+
if (!CORE_PLUGIN_VERBS.has(verb))
|
|
15
|
+
return false;
|
|
16
|
+
switch (verb) {
|
|
17
|
+
case "init": {
|
|
18
|
+
const { values, positionals } = parseVerb(verb, cmd.flags, rest);
|
|
19
|
+
const name = positionals[0];
|
|
20
|
+
if (!name)
|
|
21
|
+
fail("plugins init requires a <name>");
|
|
22
|
+
const dir = values.dir ? resolve(values.dir) : resolve(process.cwd(), "plugins");
|
|
23
|
+
const type = (values.type ?? "plugin");
|
|
24
|
+
if (type !== "plugin" && type !== "marketplace" && type !== "all") {
|
|
25
|
+
fail(`invalid --type "${values.type}" (expected plugin|marketplace|all)`);
|
|
26
|
+
}
|
|
27
|
+
const res = initScaffold({
|
|
28
|
+
name,
|
|
29
|
+
dir,
|
|
30
|
+
type,
|
|
31
|
+
description: values.description,
|
|
32
|
+
author: values.author,
|
|
33
|
+
skill: values.skill?.[0],
|
|
34
|
+
});
|
|
35
|
+
console.log(`${ui.ok(`created ${type}`)} at ${ui.name(res.pluginDir)}`);
|
|
36
|
+
for (const file of res.created)
|
|
37
|
+
console.log(ui.meta(` + ${file}`));
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
case "adapt": {
|
|
41
|
+
const { values, positionals } = parseVerb(verb, cmd.flags, rest);
|
|
42
|
+
const pluginDir = resolve(positionals[0] ?? process.cwd());
|
|
43
|
+
for (const result of adaptPlugin(pluginDir, resolveTargets(values.target))) {
|
|
44
|
+
console.log(`${ui.ok("adapted")} ${ui.name(result.target)} ${ui.meta(`-> ${result.file}`)}`);
|
|
45
|
+
}
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
case "validate": {
|
|
49
|
+
const { positionals } = parseVerb(verb, cmd.flags, rest);
|
|
50
|
+
const pluginDir = resolve(positionals[0] ?? process.cwd());
|
|
51
|
+
const result = validatePlugin(pluginDir);
|
|
52
|
+
if (result.ok) {
|
|
53
|
+
console.log(`${ui.ok("ok:")} ${ui.name(pluginDir)} is a valid ADG plugin`);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
console.error(`${ui.err("invalid:")} ${ui.name(pluginDir)}`);
|
|
57
|
+
for (const issue of result.issues)
|
|
58
|
+
console.error(ui.warn(` - ${issue}`));
|
|
59
|
+
process.exit(1);
|
|
60
|
+
}
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
case "inspect": {
|
|
64
|
+
const { values, positionals } = parseVerb(verb, cmd.flags, rest);
|
|
65
|
+
const result = await inspectSource({ spec: positionals[0] ?? process.cwd(), ref: values.ref });
|
|
66
|
+
if (values.json)
|
|
67
|
+
console.log(JSON.stringify(result, null, 2));
|
|
68
|
+
else
|
|
69
|
+
console.log(`${ui.ok("inspected")} ${ui.name(result.manifest.name)} ${ui.meta(`[${result.kind}] ${result.components.join(", ") || "no components"}`)}`);
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
case "list": {
|
|
73
|
+
const { values } = parseVerb(verb, cmd.flags, rest);
|
|
74
|
+
const pluginsDir = resolveScopeDir(values);
|
|
75
|
+
const plugins = listPlugins(pluginsDir);
|
|
76
|
+
if (values.json)
|
|
77
|
+
printJson(pluginsListJson(plugins, pluginsDir));
|
|
78
|
+
else
|
|
79
|
+
for (const line of renderPluginList(plugins, pluginsDir, { verbose: values.verbose }))
|
|
80
|
+
console.log(line);
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
case "status": {
|
|
84
|
+
const { values } = parseVerb(verb, cmd.flags, rest);
|
|
85
|
+
const targets = resolveTargets(values.target);
|
|
86
|
+
const pluginsDir = resolveScopeDir(values);
|
|
87
|
+
const scope = scopeOf(values);
|
|
88
|
+
const statuses = pluginStatus({ pluginsDir, scope, targets });
|
|
89
|
+
if (values.json)
|
|
90
|
+
printJson(pluginsStatusJson(statuses, pluginsDir, scope, targets));
|
|
91
|
+
else
|
|
92
|
+
for (const line of renderStatus(statuses))
|
|
93
|
+
console.log(line);
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|