@rbbtsn0w/adg 0.9.1-dev.pr115.46d7c06 → 0.9.1-dev.pr117.dde41a1

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,4 +1,4 @@
1
- import { adaptNativePlugins } from "../../adapters/reverse.js";
1
+ import { normalizePluginSource } from "../../normalizer.js";
2
2
  import { lockPath } from "../../paths.js";
3
3
  import { readLock } from "../../lock.js";
4
4
  import { scanPlugins } from "../../sources.js";
@@ -13,8 +13,8 @@ import { removePlugin } from "../remove.js";
13
13
  * whole source speaks ADG, so selection and install treat all plugins uniformly.
14
14
  */
15
15
  export function discoverPlugins(root) {
16
- const converted = adaptNativePlugins(root);
17
- return { candidates: scanPlugins(root), converted };
16
+ const normalized = normalizePluginSource(root);
17
+ return { candidates: normalized.candidates, converted: normalized.adaptedPlugins };
18
18
  }
19
19
  /** Resolve which discovered plugins to install from the selection options. */
20
20
  export async function selectPluginNames(opts, candidates, converted) {
@@ -0,0 +1,67 @@
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
+ const shouldSynthesizeDefaultDsl = options.definition?.kind === "default-dsl/v1";
40
+ if (shouldSynthesizeDefaultDsl && options.name) {
41
+ try {
42
+ const generated = resolveDefaultDsl(sourceDir, {
43
+ name: options.definition?.as ?? options.name,
44
+ description: options.definition?.description ?? options.name,
45
+ }, {
46
+ ...(options.resolvedRevision ? { resolvedRevision: options.resolvedRevision } : {}),
47
+ recordTelemetry: options.recordTelemetry ?? true,
48
+ });
49
+ writeJson(join(sourceDir, ADG_MANIFEST_PATH), generated.manifest);
50
+ return {
51
+ alreadyAdg: false,
52
+ adaptedPlugins: [],
53
+ synthesizedDefaultDsl: true,
54
+ candidates: scanPlugins(sourceDir),
55
+ };
56
+ }
57
+ catch {
58
+ // Not a valid Default DSL source; fall through to return un-synthesized candidates
59
+ }
60
+ }
61
+ return {
62
+ alreadyAdg: false,
63
+ adaptedPlugins: [],
64
+ synthesizedDefaultDsl: false,
65
+ candidates: scanPlugins(sourceDir),
66
+ };
67
+ }
@@ -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 { ADG_MANIFEST_PATH, findManifestFile, readManifest } from "./manifest.js";
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
- if (!findManifestFile(source)) {
62
- adaptNativePlugins(source);
63
- if (!findManifestFile(source) && entry.definition?.kind === "default-dsl/v1") {
64
- const generated = resolveDefaultDsl(source, {
65
- name: entry.definition.as ?? name,
66
- description: entry.definition.description,
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) => {
@@ -162,14 +162,25 @@ 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 hash determinism.
167
+ * Prevents host autocrlf/eol conversions and filemode differences from corrupting
168
+ * snapshot payloads and folder hashes.
169
+ */
170
+ export const DEFAULT_GIT_CONFIG_ARGS = [
171
+ "-c", "core.autocrlf=false",
172
+ "-c", "core.eol=lf",
173
+ "-c", "core.filemode=false",
174
+ ];
165
175
  /** Run git under the shared CLI semantic-convention instrumentation. */
166
176
  export function runGit(args, captureOutput = false, timeoutMs) {
167
177
  const tracer = getTracer();
168
178
  return tracer.startActiveSpan("git", { kind: SpanKind.CLIENT }, (span) => {
169
179
  try {
180
+ const fullArgs = [...DEFAULT_GIT_CONFIG_ARGS, ...args];
170
181
  span.setAttribute("process.executable.name", "git");
171
- span.setAttribute("process.command_args", sanitizeArgs(["git", ...args]));
172
- const output = execFileSync("git", args, {
182
+ span.setAttribute("process.command_args", sanitizeArgs(["git", ...fullArgs]));
183
+ const output = execFileSync("git", fullArgs, {
173
184
  ...(captureOutput
174
185
  ? { stdio: "pipe", encoding: "utf8" }
175
186
  : { stdio: "ignore" }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rbbtsn0w/adg",
3
- "version": "0.9.1-dev.pr115.46d7c06",
3
+ "version": "0.9.1-dev.pr117.dde41a1",
4
4
  "description": "Agent Directory Group (ADG) toolkit — two domains: plugins and skills.",
5
5
  "type": "module",
6
6
  "license": "MIT",