@rbbtsn0w/adg 0.9.1-dev.pr118.d5a8417 → 0.10.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.
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { normalizePluginSource } from "../../normalizer.js";
|
|
2
2
|
import { lockPath } from "../../paths.js";
|
|
3
3
|
import { readLock } from "../../lock.js";
|
|
4
|
-
import { scanPlugins } from "../../sources.js";
|
|
5
4
|
import { COMPONENT_TYPES, } from "../../types.js";
|
|
6
5
|
import { pluginContents, presentComponents } from "../../components.js";
|
|
7
6
|
import { skillDescriptionLoader } from "../../skills.js";
|
|
@@ -13,8 +12,8 @@ import { removePlugin } from "../remove.js";
|
|
|
13
12
|
* whole source speaks ADG, so selection and install treat all plugins uniformly.
|
|
14
13
|
*/
|
|
15
14
|
export function discoverPlugins(root) {
|
|
16
|
-
const
|
|
17
|
-
return { candidates:
|
|
15
|
+
const normalized = normalizePluginSource(root);
|
|
16
|
+
return { candidates: normalized.candidates, converted: normalized.adaptedPlugins };
|
|
18
17
|
}
|
|
19
18
|
/** Resolve which discovered plugins to install from the selection options. */
|
|
20
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
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { existsSync, mkdtempSync, rmSync } from "node:fs";
|
|
2
2
|
import { tmpdir } from "node:os";
|
|
3
3
|
import { isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
4
|
-
import { adaptNativePlugins } from "./adapters/reverse.js";
|
|
5
|
-
import { resolveDefaultDsl } from "./default-dsl.js";
|
|
6
|
-
import { writeJson } from "./fsutil.js";
|
|
7
4
|
import { folderHash } from "./hash.js";
|
|
8
|
-
import {
|
|
5
|
+
import { readManifest } from "./manifest.js";
|
|
9
6
|
import { withPluginSourceCache } from "./materialize.js";
|
|
10
7
|
import { PROJECTION_DIRS, packageFilter } from "./package.js";
|
|
11
8
|
import { legacyPluginSourceCacheDir, pluginSourceCacheDir } from "./paths.js";
|
|
9
|
+
import { normalizePluginSource } from "./normalizer.js";
|
|
12
10
|
import { recordTelemetryEvent } from "./telemetry.js";
|
|
13
11
|
import { runGit, GIT_CLONE_TIMEOUT_MS } from "./sources.js";
|
|
14
12
|
class SourceCacheIntegrityError extends Error {
|
|
@@ -43,9 +41,9 @@ function restoreExactRemoteSnapshot(pluginsDir, name, entry) {
|
|
|
43
41
|
try {
|
|
44
42
|
// Do not check out origin/ref: it is user update intent and can move. Fetch
|
|
45
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.
|
|
46
46
|
runGit(["-C", temp, "init"]);
|
|
47
|
-
runGit(["-C", temp, "config", "core.autocrlf", "false"]);
|
|
48
|
-
runGit(["-C", temp, "config", "core.eol", "lf"]);
|
|
49
47
|
runGit(["-C", temp, "remote", "add", "origin", url]);
|
|
50
48
|
// Bounded like every other network git call: an unbounded fetch is an
|
|
51
49
|
// indefinite, output-free hang.
|
|
@@ -58,19 +56,12 @@ function restoreExactRemoteSnapshot(pluginsDir, name, entry) {
|
|
|
58
56
|
}
|
|
59
57
|
if (!existsSync(source))
|
|
60
58
|
throw new Error(`locked source path is missing for "${name}"`);
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}, {
|
|
68
|
-
...(entry.resolvedRevision ? { resolvedRevision: entry.resolvedRevision } : {}),
|
|
69
|
-
recordTelemetry: false,
|
|
70
|
-
});
|
|
71
|
-
writeJson(join(source, ADG_MANIFEST_PATH), generated.manifest);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
59
|
+
normalizePluginSource(source, {
|
|
60
|
+
name,
|
|
61
|
+
definition: entry.definition,
|
|
62
|
+
resolvedRevision: entry.resolvedRevision,
|
|
63
|
+
recordTelemetry: false,
|
|
64
|
+
});
|
|
74
65
|
assertSourceHash(source, name, entry.sourceHash);
|
|
75
66
|
const manifest = readManifest(source);
|
|
76
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" }),
|