@rbbtsn0w/adg 0.9.1-beta.1 → 0.9.1-beta.3
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.
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { existsSync, statSync } from "node:fs";
|
|
1
|
+
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { ADG_SCHEMA_VERSION } from "../types.js";
|
|
4
|
-
import { validateManifest } from "../manifest.js";
|
|
5
|
-
import { toPosix } from "../fsutil.js";
|
|
4
|
+
import { ADG_MANIFEST_PATH, validateManifest } from "../manifest.js";
|
|
5
|
+
import { toPosix, writeJson } from "../fsutil.js";
|
|
6
|
+
import { scanNativePlugins } from "../sources.js";
|
|
6
7
|
/**
|
|
7
8
|
* Reverse-adapt a runtime-native manifest (.claude-plugin/plugin.json or
|
|
8
9
|
* .codex-plugin/plugin.json) into a canonical ADG manifest. This is the inverse
|
|
@@ -96,3 +97,20 @@ function toSkillPath(ref) {
|
|
|
96
97
|
const name = ref.replace(/[\\/]+$/, "").split(/[\\/]/).pop() || ref;
|
|
97
98
|
return `./skills/${name}`;
|
|
98
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* Reverse-adapt all native (Claude/Codex) manifests found under `root` into
|
|
102
|
+
* canonical `.agents/.plugin.json` manifests in place. Returns the list of
|
|
103
|
+
* converted plugin names.
|
|
104
|
+
*/
|
|
105
|
+
export function adaptNativePlugins(root) {
|
|
106
|
+
const converted = [];
|
|
107
|
+
for (const native of scanNativePlugins(root)) {
|
|
108
|
+
if (native.kind === "adg")
|
|
109
|
+
continue;
|
|
110
|
+
const raw = JSON.parse(readFileSync(native.manifestFile, "utf8"));
|
|
111
|
+
const manifest = fromNativeManifest(raw, native.kind, native.dir);
|
|
112
|
+
writeJson(join(native.dir, ADG_MANIFEST_PATH), manifest);
|
|
113
|
+
converted.push(manifest.name);
|
|
114
|
+
}
|
|
115
|
+
return converted;
|
|
116
|
+
}
|
|
@@ -95,7 +95,8 @@ export function syncAntigravityPluginConfig(name, enabled, env = process.env) {
|
|
|
95
95
|
typeof parsed.plugins === "object" &&
|
|
96
96
|
!Array.isArray(parsed.plugins)) {
|
|
97
97
|
const plugins = parsed.plugins;
|
|
98
|
-
|
|
98
|
+
const isCurrentlyEnabled = plugins[name]?.enabled ?? false;
|
|
99
|
+
if (isCurrentlyEnabled !== enabled) {
|
|
99
100
|
plugins[name] = { ...plugins[name], enabled };
|
|
100
101
|
writeFileSync(configPath, `${JSON.stringify(parsed, null, 2)}\n`);
|
|
101
102
|
}
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { join } from "node:path";
|
|
3
|
-
import { fromNativeManifest } from "../../adapters/reverse.js";
|
|
4
|
-
import { writeJson } from "../../fsutil.js";
|
|
1
|
+
import { normalizePluginSource } from "../../normalizer.js";
|
|
5
2
|
import { lockPath } from "../../paths.js";
|
|
6
3
|
import { readLock } from "../../lock.js";
|
|
7
|
-
import { ADG_MANIFEST_PATH } from "../../manifest.js";
|
|
8
|
-
import { scanNativePlugins, scanPlugins } from "../../sources.js";
|
|
9
4
|
import { COMPONENT_TYPES, } from "../../types.js";
|
|
10
5
|
import { pluginContents, presentComponents } from "../../components.js";
|
|
11
6
|
import { skillDescriptionLoader } from "../../skills.js";
|
|
@@ -17,16 +12,8 @@ import { removePlugin } from "../remove.js";
|
|
|
17
12
|
* whole source speaks ADG, so selection and install treat all plugins uniformly.
|
|
18
13
|
*/
|
|
19
14
|
export function discoverPlugins(root) {
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
if (native.kind === "adg")
|
|
23
|
-
continue;
|
|
24
|
-
const raw = JSON.parse(readFileSync(native.manifestFile, "utf8"));
|
|
25
|
-
const manifest = fromNativeManifest(raw, native.kind, native.dir);
|
|
26
|
-
writeJson(join(native.dir, ADG_MANIFEST_PATH), manifest);
|
|
27
|
-
converted.push(manifest.name);
|
|
28
|
-
}
|
|
29
|
-
return { candidates: scanPlugins(root), converted };
|
|
15
|
+
const normalized = normalizePluginSource(root);
|
|
16
|
+
return { candidates: normalized.candidates, converted: normalized.adaptedPlugins };
|
|
30
17
|
}
|
|
31
18
|
/** Resolve which discovered plugins to install from the selection options. */
|
|
32
19
|
export async function selectPluginNames(opts, candidates, converted) {
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import { adaptNativePlugins } from "./adapters/reverse.js";
|
|
3
|
+
import { resolveDefaultDsl } from "./default-dsl.js";
|
|
4
|
+
import { writeJson } from "./fsutil.js";
|
|
5
|
+
import { ADG_MANIFEST_PATH, findManifestFile } from "./manifest.js";
|
|
6
|
+
import { scanPlugins } from "./sources.js";
|
|
7
|
+
/**
|
|
8
|
+
* Normalizes a source directory into canonical ADG plugins.
|
|
9
|
+
*
|
|
10
|
+
* If no authoritative ADG manifest is found, attempts to adapt native runtime
|
|
11
|
+
* manifests (Claude/Codex). If still no manifest is found and the plugin matches
|
|
12
|
+
* or is declared as Default DSL, synthesizes `.agents/.plugin.json`.
|
|
13
|
+
*
|
|
14
|
+
* This ensures discovery, installation, updates, and cache restoration all
|
|
15
|
+
* share the exact same manifest synthesis and adaptation state machine.
|
|
16
|
+
*/
|
|
17
|
+
export function normalizePluginSource(sourceDir, options = {}) {
|
|
18
|
+
const existingManifest = findManifestFile(sourceDir);
|
|
19
|
+
if (existingManifest) {
|
|
20
|
+
return {
|
|
21
|
+
alreadyAdg: true,
|
|
22
|
+
adaptedPlugins: [],
|
|
23
|
+
synthesizedDefaultDsl: false,
|
|
24
|
+
candidates: scanPlugins(sourceDir),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
// 1. Try adapting native plugins (Claude / Codex)
|
|
28
|
+
const adapted = adaptNativePlugins(sourceDir);
|
|
29
|
+
if (findManifestFile(sourceDir) || adapted.length > 0) {
|
|
30
|
+
return {
|
|
31
|
+
alreadyAdg: false,
|
|
32
|
+
adaptedPlugins: adapted,
|
|
33
|
+
synthesizedDefaultDsl: false,
|
|
34
|
+
candidates: scanPlugins(sourceDir),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
// 2. Synthesize Default DSL manifest only when the lock entry explicitly records
|
|
38
|
+
// the plugin as having been installed via the Default DSL path.
|
|
39
|
+
if (options.definition?.kind === "default-dsl/v1") {
|
|
40
|
+
const pluginName = options.definition.as ?? options.name;
|
|
41
|
+
if (!pluginName) {
|
|
42
|
+
throw new Error("Default DSL plugin definition requires a plugin name");
|
|
43
|
+
}
|
|
44
|
+
const generated = resolveDefaultDsl(sourceDir, {
|
|
45
|
+
name: pluginName,
|
|
46
|
+
description: options.definition.description ?? pluginName,
|
|
47
|
+
}, {
|
|
48
|
+
...(options.resolvedRevision ? { resolvedRevision: options.resolvedRevision } : {}),
|
|
49
|
+
recordTelemetry: options.recordTelemetry ?? true,
|
|
50
|
+
});
|
|
51
|
+
writeJson(join(sourceDir, ADG_MANIFEST_PATH), generated.manifest);
|
|
52
|
+
return {
|
|
53
|
+
alreadyAdg: false,
|
|
54
|
+
adaptedPlugins: [],
|
|
55
|
+
synthesizedDefaultDsl: true,
|
|
56
|
+
candidates: scanPlugins(sourceDir),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
alreadyAdg: false,
|
|
61
|
+
adaptedPlugins: [],
|
|
62
|
+
synthesizedDefaultDsl: false,
|
|
63
|
+
candidates: scanPlugins(sourceDir),
|
|
64
|
+
};
|
|
65
|
+
}
|
package/dist/src/source-cache.js
CHANGED
|
@@ -6,6 +6,7 @@ import { readManifest } from "./manifest.js";
|
|
|
6
6
|
import { withPluginSourceCache } from "./materialize.js";
|
|
7
7
|
import { PROJECTION_DIRS, packageFilter } from "./package.js";
|
|
8
8
|
import { legacyPluginSourceCacheDir, pluginSourceCacheDir } from "./paths.js";
|
|
9
|
+
import { normalizePluginSource } from "./normalizer.js";
|
|
9
10
|
import { recordTelemetryEvent } from "./telemetry.js";
|
|
10
11
|
import { runGit, GIT_CLONE_TIMEOUT_MS } from "./sources.js";
|
|
11
12
|
class SourceCacheIntegrityError extends Error {
|
|
@@ -40,6 +41,8 @@ function restoreExactRemoteSnapshot(pluginsDir, name, entry) {
|
|
|
40
41
|
try {
|
|
41
42
|
// Do not check out origin/ref: it is user update intent and can move. Fetch
|
|
42
43
|
// only the exact commit persisted by the v4 lock instead.
|
|
44
|
+
// Note: core.autocrlf/core.eol are enforced globally by runGit's
|
|
45
|
+
// DEFAULT_GIT_CONFIG_ARGS; no per-repo config is needed here.
|
|
43
46
|
runGit(["-C", temp, "init"]);
|
|
44
47
|
runGit(["-C", temp, "remote", "add", "origin", url]);
|
|
45
48
|
// Bounded like every other network git call: an unbounded fetch is an
|
|
@@ -53,6 +56,12 @@ function restoreExactRemoteSnapshot(pluginsDir, name, entry) {
|
|
|
53
56
|
}
|
|
54
57
|
if (!existsSync(source))
|
|
55
58
|
throw new Error(`locked source path is missing for "${name}"`);
|
|
59
|
+
normalizePluginSource(source, {
|
|
60
|
+
name,
|
|
61
|
+
definition: entry.definition,
|
|
62
|
+
resolvedRevision: entry.resolvedRevision,
|
|
63
|
+
recordTelemetry: false,
|
|
64
|
+
});
|
|
56
65
|
assertSourceHash(source, name, entry.sourceHash);
|
|
57
66
|
const manifest = readManifest(source);
|
|
58
67
|
return withPluginSourceCache(source, pluginSourceCacheDir(pluginsDir, name), manifest, (snapshot) => {
|
package/dist/src/sources.js
CHANGED
|
@@ -162,14 +162,24 @@ export function gitEnv() {
|
|
|
162
162
|
env.GIT_TERMINAL_PROMPT = "0";
|
|
163
163
|
return env;
|
|
164
164
|
}
|
|
165
|
+
/**
|
|
166
|
+
* Default global git configuration arguments ensuring cross-platform line-ending determinism.
|
|
167
|
+
* Prevents host autocrlf/eol conversions from mutating checkout bytes and corrupting
|
|
168
|
+
* folder content hashes.
|
|
169
|
+
*/
|
|
170
|
+
export const DEFAULT_GIT_CONFIG_ARGS = [
|
|
171
|
+
"-c", "core.autocrlf=false",
|
|
172
|
+
"-c", "core.eol=lf",
|
|
173
|
+
];
|
|
165
174
|
/** Run git under the shared CLI semantic-convention instrumentation. */
|
|
166
175
|
export function runGit(args, captureOutput = false, timeoutMs) {
|
|
167
176
|
const tracer = getTracer();
|
|
168
177
|
return tracer.startActiveSpan("git", { kind: SpanKind.CLIENT }, (span) => {
|
|
169
178
|
try {
|
|
179
|
+
const fullArgs = [...DEFAULT_GIT_CONFIG_ARGS, ...args];
|
|
170
180
|
span.setAttribute("process.executable.name", "git");
|
|
171
|
-
span.setAttribute("process.command_args", sanitizeArgs(["git", ...
|
|
172
|
-
const output = execFileSync("git",
|
|
181
|
+
span.setAttribute("process.command_args", sanitizeArgs(["git", ...fullArgs]));
|
|
182
|
+
const output = execFileSync("git", fullArgs, {
|
|
173
183
|
...(captureOutput
|
|
174
184
|
? { stdio: "pipe", encoding: "utf8" }
|
|
175
185
|
: { stdio: "ignore" }),
|