@rbbtsn0w/adg 0.9.1-dev.pr117.dde41a1 → 0.9.1-dev.pr118.d5a8417
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 +8 -0
- package/dist/src/commands/install/discovery.js +3 -3
- package/dist/src/source-cache.js +19 -10
- package/dist/src/sources.js +2 -13
- package/dist/src/telemetry.js +26 -5
- package/package.json +1 -1
- package/dist/src/normalizer.js +0 -67
package/README.md
CHANGED
|
@@ -472,6 +472,14 @@ every positional value, including file paths, to `[VALUE]`. The literal
|
|
|
472
472
|
argument values themselves — plugin names, sources, paths — are never
|
|
473
473
|
included.
|
|
474
474
|
|
|
475
|
+
Dev and PR-preview builds (a `-dev.*` prerelease or build metadata such as
|
|
476
|
+
`+local`) send the same spans to the development gateway,
|
|
477
|
+
`https://telemetry-gateway-development.hamiltonsnow.workers.dev/v1/traces`,
|
|
478
|
+
so pre-merge traffic stays out of the production dataset. Published releases,
|
|
479
|
+
including `beta` and `rc` prereleases, use the production gateway.
|
|
480
|
+
`OTEL_EXPORTER_OTLP_TRACES_ENDPOINT` and `OTEL_EXPORTER_OTLP_ENDPOINT` still
|
|
481
|
+
override either default.
|
|
482
|
+
|
|
475
483
|
Opt out with any of:
|
|
476
484
|
|
|
477
485
|
```bash
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { adaptNativePlugins } from "../../adapters/reverse.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
|
|
17
|
-
return { candidates:
|
|
16
|
+
const converted = adaptNativePlugins(root);
|
|
17
|
+
return { candidates: scanPlugins(root), converted };
|
|
18
18
|
}
|
|
19
19
|
/** Resolve which discovered plugins to install from the selection options. */
|
|
20
20
|
export async function selectPluginNames(opts, candidates, converted) {
|
package/dist/src/source-cache.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
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";
|
|
4
7
|
import { folderHash } from "./hash.js";
|
|
5
|
-
import { readManifest } from "./manifest.js";
|
|
8
|
+
import { ADG_MANIFEST_PATH, findManifestFile, readManifest } from "./manifest.js";
|
|
6
9
|
import { withPluginSourceCache } from "./materialize.js";
|
|
7
10
|
import { PROJECTION_DIRS, packageFilter } from "./package.js";
|
|
8
11
|
import { legacyPluginSourceCacheDir, pluginSourceCacheDir } from "./paths.js";
|
|
9
|
-
import { normalizePluginSource } from "./normalizer.js";
|
|
10
12
|
import { recordTelemetryEvent } from "./telemetry.js";
|
|
11
13
|
import { runGit, GIT_CLONE_TIMEOUT_MS } from "./sources.js";
|
|
12
14
|
class SourceCacheIntegrityError extends Error {
|
|
@@ -41,9 +43,9 @@ function restoreExactRemoteSnapshot(pluginsDir, name, entry) {
|
|
|
41
43
|
try {
|
|
42
44
|
// Do not check out origin/ref: it is user update intent and can move. Fetch
|
|
43
45
|
// 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"]);
|
|
47
49
|
runGit(["-C", temp, "remote", "add", "origin", url]);
|
|
48
50
|
// Bounded like every other network git call: an unbounded fetch is an
|
|
49
51
|
// indefinite, output-free hang.
|
|
@@ -56,12 +58,19 @@ function restoreExactRemoteSnapshot(pluginsDir, name, entry) {
|
|
|
56
58
|
}
|
|
57
59
|
if (!existsSync(source))
|
|
58
60
|
throw new Error(`locked source path is missing for "${name}"`);
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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
|
+
}
|
|
65
74
|
assertSourceHash(source, name, entry.sourceHash);
|
|
66
75
|
const manifest = readManifest(source);
|
|
67
76
|
return withPluginSourceCache(source, pluginSourceCacheDir(pluginsDir, name), manifest, (snapshot) => {
|
package/dist/src/sources.js
CHANGED
|
@@ -162,25 +162,14 @@ 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
|
-
];
|
|
175
165
|
/** Run git under the shared CLI semantic-convention instrumentation. */
|
|
176
166
|
export function runGit(args, captureOutput = false, timeoutMs) {
|
|
177
167
|
const tracer = getTracer();
|
|
178
168
|
return tracer.startActiveSpan("git", { kind: SpanKind.CLIENT }, (span) => {
|
|
179
169
|
try {
|
|
180
|
-
const fullArgs = [...DEFAULT_GIT_CONFIG_ARGS, ...args];
|
|
181
170
|
span.setAttribute("process.executable.name", "git");
|
|
182
|
-
span.setAttribute("process.command_args", sanitizeArgs(["git", ...
|
|
183
|
-
const output = execFileSync("git",
|
|
171
|
+
span.setAttribute("process.command_args", sanitizeArgs(["git", ...args]));
|
|
172
|
+
const output = execFileSync("git", args, {
|
|
184
173
|
...(captureOutput
|
|
185
174
|
? { stdio: "pipe", encoding: "utf8" }
|
|
186
175
|
: { stdio: "ignore" }),
|
package/dist/src/telemetry.js
CHANGED
|
@@ -23,6 +23,26 @@ export function normalizeTraceEndpoint(endpoint) {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
const DEFAULT_TRACE_ENDPOINT = "https://telemetry-gateway.hamiltonsnow.workers.dev/v1/traces";
|
|
26
|
+
// Dev and PR-preview builds report here by default so pre-merge traffic never reaches
|
|
27
|
+
// the production dataset. The client cannot declare an environment, so the endpoint
|
|
28
|
+
// is the only isolation boundary.
|
|
29
|
+
const DEVELOPMENT_TRACE_ENDPOINT = "https://telemetry-gateway-development.hamiltonsnow.workers.dev/v1/traces";
|
|
30
|
+
const SEMVER_RE = /^v?\d+\.\d+\.\d+(?:-([0-9A-Za-z.-]+))?(?:\+([0-9A-Za-z.-]+))?$/;
|
|
31
|
+
/**
|
|
32
|
+
* Classify a build as `development` or `production` from its semver version.
|
|
33
|
+
* Only a `dev` prerelease (`0.9.1-dev.pr115.<sha>`) or build metadata (`+local`)
|
|
34
|
+
* leaves production; published `beta`/`rc` builds are user-facing and stay on
|
|
35
|
+
* production. An unparseable version falls back to production so a parsing defect
|
|
36
|
+
* can never silently drop stable-release telemetry.
|
|
37
|
+
*/
|
|
38
|
+
export function releaseChannel(version) {
|
|
39
|
+
const match = SEMVER_RE.exec(version);
|
|
40
|
+
if (!match)
|
|
41
|
+
return "production";
|
|
42
|
+
const [, prerelease, build] = match;
|
|
43
|
+
const isDev = prerelease?.split(".")[0]?.toLowerCase() === "dev";
|
|
44
|
+
return isDev || build !== undefined ? "development" : "production";
|
|
45
|
+
}
|
|
26
46
|
const GATEWAY_ORIGINS = new Set([
|
|
27
47
|
"https://telemetry-gateway-development.hamiltonsnow.workers.dev",
|
|
28
48
|
"https://telemetry-gateway-staging.hamiltonsnow.workers.dev",
|
|
@@ -63,18 +83,19 @@ export function withoutAmbientOtlpHeaders(operation) {
|
|
|
63
83
|
}
|
|
64
84
|
}
|
|
65
85
|
}
|
|
66
|
-
export function defaultTelemetryConfig(env) {
|
|
86
|
+
export function defaultTelemetryConfig(env, version = serviceVersion()) {
|
|
67
87
|
const explicitTraceEndpoint = env.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT;
|
|
68
88
|
const explicitBaseEndpoint = env.OTEL_EXPORTER_OTLP_ENDPOINT;
|
|
89
|
+
const defaultEndpoint = releaseChannel(version) === "development" ? DEVELOPMENT_TRACE_ENDPOINT : DEFAULT_TRACE_ENDPOINT;
|
|
90
|
+
const traceEndpoint = explicitTraceEndpoint ??
|
|
91
|
+
(explicitBaseEndpoint ? normalizeTraceEndpoint(explicitBaseEndpoint) : defaultEndpoint);
|
|
69
92
|
return {
|
|
70
93
|
enabled: env.OTEL_SDK_DISABLED?.toLowerCase() !== "true" &&
|
|
71
94
|
!env.DISABLE_TELEMETRY &&
|
|
72
95
|
!env.DO_NOT_TRACK &&
|
|
73
96
|
!env.NODE_TEST_CONTEXT,
|
|
74
|
-
traceEndpoint
|
|
75
|
-
|
|
76
|
-
headers: gatewayHeaders(explicitTraceEndpoint ??
|
|
77
|
-
(explicitBaseEndpoint ? normalizeTraceEndpoint(explicitBaseEndpoint) : DEFAULT_TRACE_ENDPOINT)),
|
|
97
|
+
traceEndpoint,
|
|
98
|
+
headers: gatewayHeaders(traceEndpoint),
|
|
78
99
|
batch: {
|
|
79
100
|
maxQueueSize: 256,
|
|
80
101
|
maxExportBatchSize: 64,
|
package/package.json
CHANGED
package/dist/src/normalizer.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
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
|
-
}
|