@event4u/agent-config 9.10.0 → 9.12.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.
Files changed (142) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/CHANGELOG.md +111 -0
  3. package/README.md +20 -16
  4. package/agents/templates/.ai-council.yml.example +481 -0
  5. package/agents/templates/.ai-video.xml.example +247 -0
  6. package/dist/agent-src/commands/fix/ci.md +29 -0
  7. package/dist/agent-src/commands/pr/create.md +60 -0
  8. package/dist/agent-src/contexts/authority/kernel-rule-edits.md +18 -2
  9. package/dist/agent-src/rules/design-fidelity.md +2 -2
  10. package/dist/agent-src/skills/ai-code-blindspots/SKILL.md +1 -0
  11. package/dist/agent-src/skills/design-intelligence/SKILL.md +27 -1
  12. package/dist/agent-src/skills/design-intelligence/data/font-pairings-reference.csv +74 -74
  13. package/dist/agent-src/skills/design-intelligence/data/manifest.json +2 -0
  14. package/dist/agent-src/skills/design-tokens/scripts/tokens.ts +0 -7
  15. package/dist/agent-src/skills/existing-ui-audit/SKILL.md +15 -2
  16. package/dist/agent-src/skills/fe-design/SKILL.md +10 -0
  17. package/dist/agent-src/skills/typography-system/SKILL.md +55 -11
  18. package/dist/agent-src/skills/ui-apply-generic/SKILL.md +180 -0
  19. package/dist/agent-src/templates/agents/agent-project-settings.example.yml +1 -1
  20. package/dist/agent-src/templates/scripts/work_engine/directives/ui/apply.ts +34 -30
  21. package/dist/agent-src/templates/scripts/work_engine/directives/ui/design.ts +88 -33
  22. package/dist/agent-src/templates/scripts/work_engine/directives/ui/polish.ts +23 -0
  23. package/dist/agent-src/templates/scripts/work_engine/directives/ui/review.ts +24 -1
  24. package/dist/agent-src/templates/scripts/work_engine/directives/ui/stack_bundles.ts +332 -0
  25. package/dist/agent-src/templates/scripts/work_engine/stack/detect.ts +449 -11
  26. package/dist/agent-src/templates/scripts/work_engine/state.ts +21 -4
  27. package/dist/cli/initRouting.js +74 -11
  28. package/dist/cli/initRouting.js.map +1 -1
  29. package/dist/cli/main.js +14 -3
  30. package/dist/cli/main.js.map +1 -1
  31. package/dist/cli-delegate/chunk-523HCFYO.js +90 -0
  32. package/dist/cli-delegate/chunk-736JCWLM.js +1104 -0
  33. package/dist/cli-delegate/chunk-7HQ52DHU.js +74 -0
  34. package/dist/cli-delegate/chunk-A3HJ6NTI.js +1084 -0
  35. package/dist/cli-delegate/chunk-EJYIGZ3T.js +125 -0
  36. package/dist/cli-delegate/chunk-FTAISGDQ.js +117 -0
  37. package/dist/cli-delegate/chunk-GME3Q44L.js +82 -0
  38. package/dist/cli-delegate/chunk-GRRPEPRN.js +336 -0
  39. package/dist/cli-delegate/chunk-HJ6DAJHR.js +502 -0
  40. package/dist/cli-delegate/chunk-HYWSRNUX.js +179 -0
  41. package/dist/cli-delegate/chunk-J55WI3RR.js +47 -0
  42. package/dist/cli-delegate/chunk-MCJYCQPF.js +35 -0
  43. package/dist/cli-delegate/chunk-NDJLNC6Q.js +169 -0
  44. package/dist/cli-delegate/chunk-OMIVVCG2.js +26 -0
  45. package/dist/cli-delegate/chunk-OY53J6II.js +7336 -0
  46. package/dist/cli-delegate/chunk-QFKQLQ7X.js +10835 -0
  47. package/dist/cli-delegate/chunk-TEGJU2JX.js +6908 -0
  48. package/dist/cli-delegate/chunk-TJIAM5FW.js +133 -0
  49. package/dist/cli-delegate/chunk-XX6TOPD7.js +715 -0
  50. package/dist/cli-delegate/cmd_analyze_session.js +294 -0
  51. package/dist/cli-delegate/cmd_conformance.js +643 -0
  52. package/dist/cli-delegate/cmd_converge.js +326 -0
  53. package/dist/cli-delegate/cmd_doctor.js +142 -0
  54. package/dist/cli-delegate/cmd_explain.js +2576 -0
  55. package/dist/cli-delegate/cmd_export.js +298 -0
  56. package/dist/cli-delegate/cmd_fleet.js +333 -0
  57. package/dist/cli-delegate/cmd_memory_get.js +3878 -0
  58. package/dist/cli-delegate/cmd_migrate.js +11 -0
  59. package/dist/cli-delegate/cmd_preflight.js +153 -0
  60. package/dist/cli-delegate/cmd_prune.js +446 -0
  61. package/dist/cli-delegate/cmd_refresh.js +28 -0
  62. package/dist/cli-delegate/cmd_settings_check.js +574 -0
  63. package/dist/cli-delegate/cmd_settings_migrate.js +225 -0
  64. package/dist/cli-delegate/cmd_sync.js +266 -0
  65. package/dist/cli-delegate/cmd_uninstall.js +657 -0
  66. package/dist/cli-delegate/cmd_update.js +425 -0
  67. package/dist/cli-delegate/cmd_upgrade.js +444 -0
  68. package/dist/cli-delegate/cmd_validate.js +307 -0
  69. package/dist/cli-delegate/cmd_versions.js +370 -0
  70. package/dist/discovery/deprecation-report.md +1 -1
  71. package/dist/discovery/discovery-manifest.json +45 -16
  72. package/dist/discovery/discovery-manifest.json.sha256 +1 -1
  73. package/dist/discovery/discovery-manifest.summary.md +3 -3
  74. package/dist/discovery/orphan-report.md +1 -1
  75. package/dist/discovery/packs.json +13 -7
  76. package/dist/discovery/trust-report.md +2 -2
  77. package/dist/discovery/workspaces.json +6 -4
  78. package/dist/install/emit_host_rules_cli.js +2 -1
  79. package/dist/install/emit_host_rules_cli.js.map +1 -1
  80. package/dist/install/install.mjs +634 -409
  81. package/dist/install/ruleInScope.js +123 -0
  82. package/dist/install/ruleInScope.js.map +1 -0
  83. package/dist/install/rule_scope.js +7 -3
  84. package/dist/install/rule_scope.js.map +1 -1
  85. package/dist/install/toolDetection.js +40 -12
  86. package/dist/install/toolDetection.js.map +1 -1
  87. package/dist/install/wizard-plan.js +12 -3
  88. package/dist/install/wizard-plan.js.map +1 -1
  89. package/dist/mcp/registry-manifest.json +3 -3
  90. package/dist/mcp/server.json +2 -2
  91. package/dist/mcp/server.mjs +1553 -2728
  92. package/dist/router.json +1 -1
  93. package/dist/scripts/condense.js +6 -22
  94. package/dist/scripts/condense.js.map +1 -1
  95. package/docs/guidelines/design-fidelity-mechanics.md +14 -0
  96. package/package.json +4 -2
  97. package/src/agent-src/templates/scripts/work_engine/directives/ui/apply.ts +34 -30
  98. package/src/agent-src/templates/scripts/work_engine/directives/ui/design.ts +88 -33
  99. package/src/agent-src/templates/scripts/work_engine/directives/ui/polish.ts +23 -0
  100. package/src/agent-src/templates/scripts/work_engine/directives/ui/review.ts +24 -1
  101. package/src/agent-src/templates/scripts/work_engine/directives/ui/stack_bundles.ts +332 -0
  102. package/src/agent-src/templates/scripts/work_engine/stack/detect.ts +449 -11
  103. package/src/agent-src/templates/scripts/work_engine/state.ts +21 -4
  104. package/src/config/discovery/packs.yml +7 -0
  105. package/src/config/evaluator-budgets.json +1 -1
  106. package/src/config/pack-size-budget.json +27 -0
  107. package/src/install/emit_host_rules_cli.ts +2 -1
  108. package/src/install/ruleInScope.ts +133 -0
  109. package/src/install/rule_scope.ts +7 -3
  110. package/src/install/toolDetection.ts +39 -8
  111. package/src/install/wizard-plan.ts +13 -3
  112. package/src/scripts/_cli/cmd_conformance.ts +2 -1
  113. package/src/scripts/_cli/cmd_converge.ts +2 -1
  114. package/src/scripts/_cli/cmd_doctor.ts +214 -13
  115. package/src/scripts/_cli/cmd_export.ts +2 -1
  116. package/src/scripts/_cli/cmd_fleet.ts +2 -1
  117. package/src/scripts/_cli/cmd_migrate.ts +2 -1
  118. package/src/scripts/_cli/cmd_preflight.ts +2 -1
  119. package/src/scripts/_cli/cmd_refresh.ts +2 -1
  120. package/src/scripts/_cli/cmd_update.ts +2 -1
  121. package/src/scripts/_cli/cmd_upgrade.ts +2 -1
  122. package/src/scripts/_cli/cmd_versions.ts +2 -1
  123. package/src/scripts/_cli/detection_report.ts +480 -0
  124. package/src/scripts/_dispatch.bash +52 -14
  125. package/src/scripts/_lib/changelog_eras.ts +103 -9
  126. package/src/scripts/_lib/environment_detector.ts +441 -0
  127. package/src/scripts/_lib/global_deploy_inventory.ts +38 -2
  128. package/src/scripts/_lib/package_root.ts +72 -0
  129. package/src/scripts/ai_council/config.ts +15 -7
  130. package/src/scripts/ai_council/modes.ts +68 -2
  131. package/src/scripts/ai_council/transport_resolver.ts +331 -0
  132. package/src/scripts/check_bundle_path_leakage.ts +10 -4
  133. package/src/scripts/check_dependency_floors.ts +153 -0
  134. package/src/scripts/check_installer_import_purity.ts +295 -0
  135. package/src/scripts/check_pack_size.ts +188 -0
  136. package/src/scripts/condense.ts +7 -28
  137. package/src/scripts/council_cli.ts +6 -2
  138. package/src/scripts/evaluator_umbrella.sh +34 -1
  139. package/src/scripts/install-hooks.sh +36 -4
  140. package/src/scripts/install.ts +210 -5
  141. package/src/scripts/lint_eval_fixture_citations.ts +113 -0
  142. package/src/scripts/lint_ui_stack_bundles.ts +201 -0
@@ -0,0 +1,425 @@
1
+ import { createRequire as __acCreateRequire } from 'node:module'; const require = globalThis.require ?? __acCreateRequire(import.meta.url);
2
+ import {
3
+ DEFAULT_STATE_PATH,
4
+ _is_newer,
5
+ fetch_latest_from_npm
6
+ } from "./chunk-7HQ52DHU.js";
7
+ import {
8
+ lockfile_path,
9
+ lockfile_write_path,
10
+ read_lockfile,
11
+ write_lockfile
12
+ } from "./chunk-GRRPEPRN.js";
13
+ import {
14
+ DEFAULT_PROJECT_FILE,
15
+ LOCAL_PROJECT_FILE,
16
+ LOCAL_PROJECT_SUBDIR,
17
+ find_project_root,
18
+ resolve_project_root
19
+ } from "./chunk-HJ6DAJHR.js";
20
+ import "./chunk-NDJLNC6Q.js";
21
+ import {
22
+ resolvePackageRoot
23
+ } from "./chunk-MCJYCQPF.js";
24
+ import "./chunk-J55WI3RR.js";
25
+
26
+ // src/scripts/_cli/cmd_update.ts
27
+ import { spawnSync } from "node:child_process";
28
+ import { randomBytes } from "node:crypto";
29
+ import * as fs from "node:fs";
30
+ import * as path from "node:path";
31
+ import process from "node:process";
32
+ import { fileURLToPath, pathToFileURL } from "node:url";
33
+ var PACKAGE_NAME = "@event4u/agent-config";
34
+ var PIN_KEY = "agent_config_version";
35
+ var REGISTRY_VERSION_URL = `https://registry.npmjs.org/${PACKAGE_NAME}/{version}`;
36
+ var PIN_LINE_RE = /^(\s*agent_config_version\s*:\s*)(.*)$/m;
37
+ var _HERE = fileURLToPath(import.meta.url);
38
+ var _HERE_DIR = path.dirname(_HERE);
39
+ var ArgparseExit = class extends Error {
40
+ code;
41
+ constructor(code) {
42
+ super(`ArgparseExit(${code})`);
43
+ this.name = "ArgparseExit";
44
+ this.code = code;
45
+ }
46
+ };
47
+ var _stdout = { write: (t) => process.stdout.write(t) };
48
+ var _stderr = { write: (t) => process.stderr.write(t) };
49
+ function _print(out, line = "") {
50
+ out.write(line + "\n");
51
+ }
52
+ function _isFile(p) {
53
+ try {
54
+ return fs.statSync(p).isFile();
55
+ } catch {
56
+ return false;
57
+ }
58
+ }
59
+ function _splitlinesKeepends(text) {
60
+ const out = [];
61
+ let buf = "";
62
+ for (let i = 0; i < text.length; i++) {
63
+ const ch = text[i];
64
+ buf += ch;
65
+ if (ch === "\n") {
66
+ out.push(buf);
67
+ buf = "";
68
+ }
69
+ }
70
+ if (buf) {
71
+ out.push(buf);
72
+ }
73
+ return out;
74
+ }
75
+ function _canonical_settings_path(project_root) {
76
+ return path.join(project_root, ...LOCAL_PROJECT_SUBDIR, DEFAULT_PROJECT_FILE);
77
+ }
78
+ function _local_settings_path(project_root) {
79
+ return path.join(project_root, ...LOCAL_PROJECT_SUBDIR, LOCAL_PROJECT_FILE);
80
+ }
81
+ function _resolve(p) {
82
+ return path.resolve(p);
83
+ }
84
+ function _resolve_cascade_paths(cwd, project_path) {
85
+ if (cwd === null) {
86
+ const legacy = project_path ? project_path : DEFAULT_PROJECT_FILE;
87
+ const parent = path.dirname(legacy);
88
+ return [legacy, _canonical_settings_path(parent), _local_settings_path(parent)];
89
+ }
90
+ const root = find_project_root(cwd);
91
+ if (root === null) {
92
+ const legacy = project_path ? project_path : DEFAULT_PROJECT_FILE;
93
+ const parent = path.dirname(legacy);
94
+ return [legacy, _canonical_settings_path(parent), _local_settings_path(parent)];
95
+ }
96
+ const cwd_resolved = _resolve(cwd);
97
+ const chain = [];
98
+ let cursor = cwd_resolved;
99
+ for (; ; ) {
100
+ chain.push(cursor);
101
+ if (cursor === root) {
102
+ break;
103
+ }
104
+ const parent = path.dirname(cursor);
105
+ if (parent === cursor) {
106
+ break;
107
+ }
108
+ cursor = parent;
109
+ }
110
+ chain.reverse();
111
+ const out = [];
112
+ for (const dir of chain) {
113
+ out.push(path.join(dir, DEFAULT_PROJECT_FILE));
114
+ out.push(_canonical_settings_path(dir));
115
+ out.push(_local_settings_path(dir));
116
+ }
117
+ return out;
118
+ }
119
+ function _read_state(state_path) {
120
+ try {
121
+ const raw = fs.readFileSync(state_path, "utf-8");
122
+ const data = JSON.parse(raw);
123
+ if (data !== null && typeof data === "object" && !Array.isArray(data)) {
124
+ return data;
125
+ }
126
+ } catch {
127
+ }
128
+ return {};
129
+ }
130
+ function _write_state(state_path, payload) {
131
+ const parent = path.dirname(state_path);
132
+ fs.mkdirSync(parent, { recursive: true });
133
+ const tmp = path.join(parent, `.update-check-${randomBytes(8).toString("hex")}`);
134
+ try {
135
+ const sorted = {};
136
+ for (const key of Object.keys(payload).sort()) {
137
+ sorted[key] = payload[key];
138
+ }
139
+ fs.writeFileSync(tmp, JSON.stringify(sorted, null, 2), { encoding: "utf-8", mode: 384 });
140
+ fs.chmodSync(tmp, 384);
141
+ fs.renameSync(tmp, state_path);
142
+ } catch (err) {
143
+ try {
144
+ fs.unlinkSync(tmp);
145
+ } catch {
146
+ }
147
+ throw err;
148
+ }
149
+ }
150
+ function _normalize(version) {
151
+ return version.trim().replace(/^v+/, "");
152
+ }
153
+ async function _registry_has_version(version, timeout = 1) {
154
+ const url = REGISTRY_VERSION_URL.replace("{version}", _normalize(version));
155
+ try {
156
+ const resp = await fetch(url, {
157
+ headers: { Accept: "application/json" },
158
+ signal: AbortSignal.timeout(timeout * 1e3)
159
+ });
160
+ return resp.status === 200;
161
+ } catch {
162
+ return false;
163
+ }
164
+ }
165
+ function _find_pin_file(cwd) {
166
+ const cascade = _resolve_cascade_paths(cwd, null);
167
+ for (const p of [...cascade].reverse()) {
168
+ if (_isFile(p) && _read_pin_line(p) !== null) {
169
+ return p;
170
+ }
171
+ }
172
+ if (cascade.length) {
173
+ return cascade[0];
174
+ }
175
+ return path.join(cwd, DEFAULT_PROJECT_FILE);
176
+ }
177
+ function _read_pin_line(p) {
178
+ let text;
179
+ try {
180
+ text = fs.readFileSync(p, { encoding: "utf-8" });
181
+ } catch {
182
+ return null;
183
+ }
184
+ const lines = _splitlinesKeepends(text);
185
+ for (let idx = 0; idx < lines.length; idx++) {
186
+ if (PIN_LINE_RE.test(lines[idx])) {
187
+ return idx;
188
+ }
189
+ }
190
+ return null;
191
+ }
192
+ function _write_pin(p, new_version) {
193
+ const target = `agent_config_version: "${_normalize(new_version)}"
194
+ `;
195
+ let lines;
196
+ try {
197
+ lines = _splitlinesKeepends(fs.readFileSync(p, { encoding: "utf-8" }));
198
+ } catch (err) {
199
+ const e = err;
200
+ if (e && e.code === "ENOENT") {
201
+ fs.mkdirSync(path.dirname(p), { recursive: true });
202
+ fs.writeFileSync(p, target, { encoding: "utf-8" });
203
+ return true;
204
+ }
205
+ throw err;
206
+ }
207
+ for (let idx = 0; idx < lines.length; idx++) {
208
+ if (PIN_LINE_RE.test(lines[idx])) {
209
+ if (lines[idx] === target) {
210
+ return false;
211
+ }
212
+ lines[idx] = target;
213
+ fs.writeFileSync(p, lines.join(""), { encoding: "utf-8" });
214
+ return true;
215
+ }
216
+ }
217
+ if (lines.length && !lines[lines.length - 1].endsWith("\n")) {
218
+ lines.push("\n");
219
+ }
220
+ lines.push(target);
221
+ fs.writeFileSync(p, lines.join(""), { encoding: "utf-8" });
222
+ return true;
223
+ }
224
+ function _warm_npx_cache(version, runner) {
225
+ const run = runner ?? ((argv) => {
226
+ spawnSync(argv[0], argv.slice(1), {
227
+ stdio: "ignore",
228
+ timeout: 120 * 1e3
229
+ });
230
+ });
231
+ try {
232
+ run(["npx", "--yes", `${PACKAGE_NAME}@${_normalize(version)}`, "--version"]);
233
+ } catch {
234
+ }
235
+ }
236
+ function _refresh_state(installed, latest, state_path) {
237
+ const state = _read_state(state_path);
238
+ const payload = {
239
+ last_check_utc: _isoNowZ(),
240
+ last_seen_version: latest,
241
+ installed_version: installed
242
+ };
243
+ Object.assign(state, payload);
244
+ try {
245
+ _write_state(state_path, state);
246
+ } catch {
247
+ }
248
+ }
249
+ function _isoNowZ() {
250
+ const d = /* @__PURE__ */ new Date();
251
+ const p = (n, w = 2) => String(n).padStart(w, "0");
252
+ return `${p(d.getUTCFullYear(), 4)}-${p(d.getUTCMonth() + 1)}-${p(d.getUTCDate())}T${p(d.getUTCHours())}:${p(d.getUTCMinutes())}:${p(d.getUTCSeconds())}Z`;
253
+ }
254
+ function _parse(argv) {
255
+ const prog = "agent-config update";
256
+ const usage = "usage: agent-config update [-h] [--check] [--to VERSION] [--offline]\n";
257
+ const emitError = (msg) => {
258
+ _stderr.write(usage);
259
+ _stderr.write(`${prog}: error: ${msg}
260
+ `);
261
+ throw new ArgparseExit(2);
262
+ };
263
+ const args = { check: false, to: null, offline: false };
264
+ let i = 0;
265
+ while (i < argv.length) {
266
+ const tok = argv[i];
267
+ const flag = tok.includes("=") ? tok.slice(0, tok.indexOf("=")) : tok;
268
+ if (flag === "-h" || flag === "--help") {
269
+ _stdout.write(usage);
270
+ throw new ArgparseExit(0);
271
+ } else if (flag === "--check") {
272
+ args.check = true;
273
+ i += 1;
274
+ } else if (flag === "--offline") {
275
+ args.offline = true;
276
+ i += 1;
277
+ } else if (flag === "--to") {
278
+ const eq = tok.indexOf("=");
279
+ if (eq >= 0) {
280
+ args.to = tok.slice(eq + 1);
281
+ i += 1;
282
+ } else {
283
+ const val = argv[i + 1];
284
+ if (val === void 0) {
285
+ emitError("argument --to: expected one argument");
286
+ }
287
+ args.to = val;
288
+ i += 2;
289
+ }
290
+ } else {
291
+ emitError(`unrecognized arguments: ${tok}`);
292
+ }
293
+ }
294
+ return args;
295
+ }
296
+ async function main(argv = null, options = {}) {
297
+ const out = options.out ?? _stdout;
298
+ const err = options.err ?? _stderr;
299
+ const fetcher = options.fetcher ?? (() => fetch_latest_from_npm());
300
+ const version_checker = options.version_checker ?? _registry_has_version;
301
+ const cache_warmer = options.cache_warmer ?? ((v) => _warm_npx_cache(v));
302
+ const args = _parse(argv ?? process.argv.slice(2));
303
+ const [cwd] = resolve_project_root(null, { cwd: options.cwd ?? null });
304
+ const installed_version = options.installed_version || _detect_installed_version();
305
+ const state_path = options.state_path || DEFAULT_STATE_PATH;
306
+ const offline = args.offline || process.env["AGENT_CONFIG_OFFLINE"] === "1";
307
+ if (offline && !args.to) {
308
+ _print(
309
+ err,
310
+ "\u274C agent-config: --offline requires --to <version> (no registry, no 'latest' to fetch)."
311
+ );
312
+ return 1;
313
+ }
314
+ let latest;
315
+ if (args.to) {
316
+ const target = _normalize(args.to);
317
+ if (offline) {
318
+ latest = target;
319
+ } else if (!await version_checker(target)) {
320
+ _print(err, `\u274C agent-config: version ${target} not found on the npm registry.`);
321
+ return 1;
322
+ } else {
323
+ latest = target;
324
+ }
325
+ } else {
326
+ const fetched = await fetcher();
327
+ if (!fetched) {
328
+ _print(
329
+ err,
330
+ "\u274C agent-config: failed to fetch latest version from the npm registry."
331
+ );
332
+ return 1;
333
+ }
334
+ latest = _normalize(fetched);
335
+ }
336
+ if (args.check) {
337
+ if (_is_newer(latest, installed_version)) {
338
+ _print(out, `agent-config ${latest} available (you have ${installed_version}).`);
339
+ _print(out, `Update: npx ${PACKAGE_NAME} update`);
340
+ } else {
341
+ _print(out, `agent-config is up to date (${installed_version}).`);
342
+ }
343
+ return 0;
344
+ }
345
+ const pin_file = _find_pin_file(cwd);
346
+ const changed = _write_pin(pin_file, latest);
347
+ const rel = _relativeToOr(pin_file, cwd);
348
+ if (changed) {
349
+ _print(out, `\u2705 Pinned ${PACKAGE_NAME} to ${latest} in ${rel}.`);
350
+ } else {
351
+ _print(out, `\u2139\uFE0F ${rel} already pins to ${latest}.`);
352
+ }
353
+ if (!offline) {
354
+ cache_warmer(latest);
355
+ }
356
+ _refresh_state(latest, latest, state_path);
357
+ _refresh_global_lockfile(latest, out);
358
+ return 0;
359
+ }
360
+ function _relativeToOr(target, base) {
361
+ const rel = path.relative(base, target);
362
+ if (rel.startsWith("..") || path.isAbsolute(rel)) {
363
+ return target;
364
+ }
365
+ return rel;
366
+ }
367
+ function _refresh_global_lockfile(version, out) {
368
+ const read_path = lockfile_path();
369
+ const write_path = lockfile_write_path();
370
+ const existing = read_lockfile(read_path);
371
+ if (existing === null) {
372
+ return;
373
+ }
374
+ const recorded = existing["agent_config_version"];
375
+ const tools = [...existing.tools ?? []];
376
+ if (recorded === version && read_path === write_path) {
377
+ _print(out, `\u2139\uFE0F ${write_path} already records ${version}.`);
378
+ return;
379
+ }
380
+ write_lockfile(version, tools, { path: write_path });
381
+ _print(out, `\u2705 Refreshed global lockfile at ${write_path}.`);
382
+ }
383
+ function _detect_installed_version() {
384
+ const pkg_json = path.join(resolvePackageRoot(import.meta.url), "package.json");
385
+ try {
386
+ const data = JSON.parse(fs.readFileSync(pkg_json, { encoding: "utf-8" }));
387
+ const version = data["version"];
388
+ if (typeof version === "string" && version.trim()) {
389
+ return version.trim();
390
+ }
391
+ } catch {
392
+ }
393
+ return "0.0.0";
394
+ }
395
+ function _isCliEntry() {
396
+ if (process.argv[1] === void 0) {
397
+ return false;
398
+ }
399
+ const argvUrl = pathToFileURL(path.resolve(process.argv[1])).href;
400
+ if (import.meta.url === argvUrl) {
401
+ return true;
402
+ }
403
+ try {
404
+ const here = fs.realpathSync(fileURLToPath(import.meta.url));
405
+ const argv = fs.realpathSync(path.resolve(process.argv[1]));
406
+ return here === argv;
407
+ } catch {
408
+ return false;
409
+ }
410
+ }
411
+ if (_isCliEntry() || process.argv[1] === _HERE) {
412
+ main(process.argv.slice(2)).then((code) => {
413
+ process.exitCode = code;
414
+ }).catch((exc) => {
415
+ if (exc instanceof ArgparseExit) {
416
+ process.exitCode = exc.code;
417
+ } else {
418
+ throw exc;
419
+ }
420
+ });
421
+ }
422
+ export {
423
+ PIN_KEY,
424
+ main
425
+ };