@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,225 @@
1
+ import { createRequire as __acCreateRequire } from 'node:module'; const require = globalThis.require ?? __acCreateRequire(import.meta.url);
2
+ import {
3
+ GLOBAL_AGENT_SETTINGS_PATH,
4
+ GLOBAL_USER_SETTINGS_PATH,
5
+ SETTINGS_FILE
6
+ } from "./chunk-QFKQLQ7X.js";
7
+ import "./chunk-XX6TOPD7.js";
8
+ import "./chunk-EJYIGZ3T.js";
9
+ import "./chunk-A3HJ6NTI.js";
10
+ import "./chunk-GRRPEPRN.js";
11
+ import "./chunk-TJIAM5FW.js";
12
+ import "./chunk-HJ6DAJHR.js";
13
+ import "./chunk-NDJLNC6Q.js";
14
+ import "./chunk-523HCFYO.js";
15
+ import "./chunk-MCJYCQPF.js";
16
+ import "./chunk-OY53J6II.js";
17
+ import "./chunk-J55WI3RR.js";
18
+
19
+ // src/scripts/_cli/cmd_settings_migrate.ts
20
+ import process from "node:process";
21
+ import * as fs from "node:fs";
22
+ import * as path from "node:path";
23
+ import { fileURLToPath, pathToFileURL } from "node:url";
24
+ var ArgparseExit = class extends Error {
25
+ code;
26
+ constructor(code) {
27
+ super(`ArgparseExit(${code})`);
28
+ this.name = "ArgparseExit";
29
+ this.code = code;
30
+ }
31
+ };
32
+ function _stdoutSink() {
33
+ return { write: (t) => process.stdout.write(t) };
34
+ }
35
+ function _stderrSink() {
36
+ return { write: (t) => process.stderr.write(t) };
37
+ }
38
+ function _print(out, line = "") {
39
+ out.write(line + "\n");
40
+ }
41
+ function _resolve(p) {
42
+ const abs = path.resolve(p);
43
+ try {
44
+ return fs.realpathSync(abs);
45
+ } catch {
46
+ return abs;
47
+ }
48
+ }
49
+ function _isFile(p) {
50
+ try {
51
+ return fs.statSync(p).isFile();
52
+ } catch {
53
+ return false;
54
+ }
55
+ }
56
+ function _isPyWs(code) {
57
+ return code === 9 || code === 10 || code === 11 || code === 12 || code === 13 || code === 28 || code === 29 || code === 30 || code === 31 || code === 32 || code === 133 || code === 160 || code === 5760 || code >= 8192 && code <= 8202 || code === 8232 || code === 8233 || code === 8239 || code === 8287 || code === 12288;
58
+ }
59
+ function _pyStrip(s) {
60
+ let start = 0;
61
+ let end = s.length;
62
+ while (start < end && _isPyWs(s.charCodeAt(start))) start += 1;
63
+ while (end > start && _isPyWs(s.charCodeAt(end - 1))) end -= 1;
64
+ return s.slice(start, end);
65
+ }
66
+ function _is_non_empty_yaml(p) {
67
+ if (!_isFile(p)) {
68
+ return false;
69
+ }
70
+ let text;
71
+ try {
72
+ text = fs.readFileSync(p, { encoding: "utf-8" });
73
+ } catch {
74
+ return false;
75
+ }
76
+ return _pyStrip(text) !== "";
77
+ }
78
+ function _parse_yaml_or_fail(_p, _out) {
79
+ return true;
80
+ }
81
+ function _copy(src, dst, opts) {
82
+ if (opts.dry_run) {
83
+ return `would copy ${src} \u2192 ${dst}`;
84
+ }
85
+ fs.mkdirSync(path.dirname(dst), { recursive: true, mode: 448 });
86
+ fs.copyFileSync(src, dst);
87
+ try {
88
+ const st = fs.statSync(src);
89
+ fs.utimesSync(dst, st.atime, st.mtime);
90
+ } catch {
91
+ }
92
+ try {
93
+ fs.chmodSync(dst, 384);
94
+ } catch {
95
+ }
96
+ return `copied ${src} \u2192 ${dst}`;
97
+ }
98
+ function _parse(argv, out, err) {
99
+ const prog = "agent-config settings:migrate";
100
+ const usage = `usage: ${prog} [-h] [--from FROM_DIR] [--force]
101
+ ${" ".repeat(37)}[--dry-run]
102
+ `;
103
+ const emitError = (msg) => {
104
+ err.write(usage);
105
+ err.write(`${prog}: error: ${msg}
106
+ `);
107
+ throw new ArgparseExit(2);
108
+ };
109
+ const opts = { from_dir: null, force: false, dry_run: false };
110
+ let i = 0;
111
+ while (i < argv.length) {
112
+ const tok = argv[i];
113
+ if (tok === "-h" || tok === "--help") {
114
+ out.write(usage);
115
+ throw new ArgparseExit(0);
116
+ } else if (tok === "--from") {
117
+ const val = argv[i + 1];
118
+ if (val === void 0) emitError("argument --from: expected one argument");
119
+ opts.from_dir = val;
120
+ i += 2;
121
+ } else if (tok.startsWith("--from=")) {
122
+ opts.from_dir = tok.slice("--from=".length);
123
+ i += 1;
124
+ } else if (tok === "--force") {
125
+ opts.force = true;
126
+ i += 1;
127
+ } else if (tok === "--dry-run") {
128
+ opts.dry_run = true;
129
+ i += 1;
130
+ } else {
131
+ emitError(`unrecognized arguments: ${tok}`);
132
+ }
133
+ }
134
+ return opts;
135
+ }
136
+ function main(argv = null, options = {}) {
137
+ const out = options.out ?? _stdoutSink();
138
+ const err = options.err ?? _stderrSink();
139
+ const opts = _parse(argv ?? process.argv.slice(2), out, err);
140
+ const project = opts.from_dir ? _resolve(opts.from_dir) : process.cwd();
141
+ let src_settings = path.join(project, "settings", SETTINGS_FILE);
142
+ if (!_isFile(src_settings)) {
143
+ src_settings = path.join(project, SETTINGS_FILE);
144
+ }
145
+ let src_user = path.join(project, "settings", ".agent-user.yml");
146
+ if (!_isFile(src_user)) {
147
+ src_user = path.join(project, ".agent-user.yml");
148
+ }
149
+ const dst_settings = GLOBAL_AGENT_SETTINGS_PATH;
150
+ const dst_user = GLOBAL_USER_SETTINGS_PATH;
151
+ const plan = [];
152
+ const skipped = [];
153
+ const triples = [
154
+ [src_settings, dst_settings, "settings"],
155
+ [src_user, dst_user, "user"]
156
+ ];
157
+ for (const [src, dst, label] of triples) {
158
+ if (!_isFile(src)) {
159
+ skipped.push(`${label}: source absent (${src})`);
160
+ continue;
161
+ }
162
+ if (_is_non_empty_yaml(dst) && !opts.force) {
163
+ _print(err, `\u274C ${dst} is non-empty \u2014 pass --force to overwrite.`);
164
+ return 1;
165
+ }
166
+ if (!_parse_yaml_or_fail(src, err)) {
167
+ return 1;
168
+ }
169
+ plan.push([src, dst]);
170
+ }
171
+ if (plan.length === 0) {
172
+ _print(out, "\u2705 nothing to migrate \u2014 no project-local settings detected.");
173
+ for (const line of skipped) {
174
+ _print(out, ` - ${line}`);
175
+ }
176
+ return 0;
177
+ }
178
+ const summary = [];
179
+ for (const [src, dst] of plan) {
180
+ summary.push(_copy(src, dst, { dry_run: opts.dry_run }));
181
+ }
182
+ const verb = opts.dry_run ? "would migrate" : "migrated";
183
+ _print(out, `\u2705 ${verb} ${plan.length} file(s):`);
184
+ for (const line of summary) {
185
+ _print(out, ` - ${line}`);
186
+ }
187
+ for (const line of skipped) {
188
+ _print(out, ` - ${line}`);
189
+ }
190
+ if (opts.dry_run) {
191
+ _print(out, "\n Re-run without --dry-run to apply.");
192
+ }
193
+ return 0;
194
+ }
195
+ var _HERE = fileURLToPath(import.meta.url);
196
+ function _isCliEntry() {
197
+ if (process.argv[1] === void 0) {
198
+ return false;
199
+ }
200
+ const argvUrl = pathToFileURL(path.resolve(process.argv[1])).href;
201
+ if (import.meta.url === argvUrl) {
202
+ return true;
203
+ }
204
+ try {
205
+ const here = fs.realpathSync(fileURLToPath(import.meta.url));
206
+ const argv = fs.realpathSync(path.resolve(process.argv[1]));
207
+ return here === argv;
208
+ } catch {
209
+ return false;
210
+ }
211
+ }
212
+ if (_isCliEntry() || process.argv[1] === _HERE) {
213
+ try {
214
+ process.exitCode = main();
215
+ } catch (exc) {
216
+ if (exc instanceof ArgparseExit) {
217
+ process.exitCode = exc.code;
218
+ } else {
219
+ throw exc;
220
+ }
221
+ }
222
+ }
223
+ export {
224
+ main
225
+ };
@@ -0,0 +1,266 @@
1
+ import { createRequire as __acCreateRequire } from 'node:module'; const require = globalThis.require ?? __acCreateRequire(import.meta.url);
2
+ import {
3
+ main
4
+ } from "./chunk-QFKQLQ7X.js";
5
+ import "./chunk-XX6TOPD7.js";
6
+ import "./chunk-EJYIGZ3T.js";
7
+ import {
8
+ manifest_path,
9
+ read_manifest
10
+ } from "./chunk-A3HJ6NTI.js";
11
+ import "./chunk-GRRPEPRN.js";
12
+ import "./chunk-TJIAM5FW.js";
13
+ import {
14
+ resolve_project_root
15
+ } from "./chunk-HJ6DAJHR.js";
16
+ import "./chunk-NDJLNC6Q.js";
17
+ import "./chunk-523HCFYO.js";
18
+ import "./chunk-MCJYCQPF.js";
19
+ import "./chunk-OY53J6II.js";
20
+ import "./chunk-J55WI3RR.js";
21
+
22
+ // src/scripts/_cli/cmd_sync.ts
23
+ import process from "node:process";
24
+ import * as fs from "node:fs";
25
+ import { fileURLToPath, pathToFileURL } from "node:url";
26
+ import * as path from "node:path";
27
+ var ArgparseExit = class extends Error {
28
+ code;
29
+ constructor(code) {
30
+ super(`ArgparseExit(${code})`);
31
+ this.name = "ArgparseExit";
32
+ this.code = code;
33
+ }
34
+ };
35
+ function _stdoutSink() {
36
+ return { write: (t) => process.stdout.write(t) };
37
+ }
38
+ function _stderrSink() {
39
+ return { write: (t) => process.stderr.write(t) };
40
+ }
41
+ function _print(out, line = "") {
42
+ out.write(line + "\n");
43
+ }
44
+ function _ljust(s, width) {
45
+ const len = [...s].length;
46
+ if (len >= width) return s;
47
+ return s + " ".repeat(width - len);
48
+ }
49
+ function _isPlainObject(value) {
50
+ return typeof value === "object" && value !== null && !Array.isArray(value);
51
+ }
52
+ function _strField(value) {
53
+ if (value === void 0 || value === null) {
54
+ return _pyStrip("None");
55
+ }
56
+ if (typeof value === "boolean") {
57
+ return value ? "True" : "False";
58
+ }
59
+ return _pyStrip(String(value));
60
+ }
61
+ function _isPyWs(code) {
62
+ return code === 9 || code === 10 || code === 11 || code === 12 || code === 13 || code === 28 || code === 29 || code === 30 || code === 31 || code === 32 || code === 133 || code === 160 || code === 5760 || code >= 8192 && code <= 8202 || code === 8232 || code === 8233 || code === 8239 || code === 8287 || code === 12288;
63
+ }
64
+ function _pyStrip(s) {
65
+ let start = 0;
66
+ let end = s.length;
67
+ while (start < end && _isPyWs(s.charCodeAt(start))) start += 1;
68
+ while (end > start && _isPyWs(s.charCodeAt(end - 1))) end -= 1;
69
+ return s.slice(start, end);
70
+ }
71
+ function _expanduser(p) {
72
+ if (p === "~" || p.startsWith("~/") || p.startsWith("~" + path.sep)) {
73
+ const home = process.env["HOME"] ?? "";
74
+ return path.join(home, p.slice(1));
75
+ }
76
+ return p;
77
+ }
78
+ function _marker_exists(project_root, bridge_marker, scope) {
79
+ if (!bridge_marker) {
80
+ return true;
81
+ }
82
+ let target;
83
+ if (scope === "global") {
84
+ target = _expanduser(bridge_marker);
85
+ } else {
86
+ target = path.isAbsolute(bridge_marker) ? bridge_marker : path.join(project_root, bridge_marker);
87
+ }
88
+ return fs.existsSync(target);
89
+ }
90
+ function _group_by_scope(entries, project_root) {
91
+ const missing = { project: [], global: [] };
92
+ const surfaced = [];
93
+ for (const entry of entries) {
94
+ const name = _strField(entry["name"]);
95
+ const scope = _strField(entry["scope"]);
96
+ const bridge_marker = _strField(entry["bridge_marker"]);
97
+ if (!name || scope !== "project" && scope !== "global") {
98
+ continue;
99
+ }
100
+ if (_marker_exists(project_root, bridge_marker, scope)) {
101
+ continue;
102
+ }
103
+ missing[scope].push(name);
104
+ surfaced.push([name, bridge_marker]);
105
+ }
106
+ return [missing, surfaced];
107
+ }
108
+ function _run_install(scope, tools, project_root, opts) {
109
+ if (!tools.length) {
110
+ return 0;
111
+ }
112
+ const uniqSorted = Array.from(new Set(tools)).sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
113
+ const argv = [`--scope=${scope}`, `--tools=${uniqSorted.join(",")}`];
114
+ if (scope === "project") {
115
+ argv.push(`--project=${project_root}`, "--no-smoke");
116
+ }
117
+ if (opts.force) {
118
+ argv.push("--force");
119
+ }
120
+ if (opts.dry_run) {
121
+ argv.push("--skip-bridges");
122
+ }
123
+ return main(argv);
124
+ }
125
+ function _parse(argv, out, err) {
126
+ const prog = "agent-config sync";
127
+ const usage = `usage: ${prog} [-h] [--project PROJECT] [--dry-run] [--force]
128
+ ${" ".repeat(25)}[--quiet]
129
+ `;
130
+ const emitError = (msg) => {
131
+ err.write(usage);
132
+ err.write(`${prog}: error: ${msg}
133
+ `);
134
+ throw new ArgparseExit(2);
135
+ };
136
+ const opts = { project: null, dry_run: false, force: false, quiet: false };
137
+ let i = 0;
138
+ while (i < argv.length) {
139
+ const tok = argv[i];
140
+ if (tok === "-h" || tok === "--help") {
141
+ out.write(usage);
142
+ throw new ArgparseExit(0);
143
+ } else if (tok === "--project") {
144
+ const val = argv[i + 1];
145
+ if (val === void 0) emitError("argument --project: expected one argument");
146
+ opts.project = val;
147
+ i += 2;
148
+ } else if (tok.startsWith("--project=")) {
149
+ opts.project = tok.slice("--project=".length);
150
+ i += 1;
151
+ } else if (tok === "--dry-run") {
152
+ opts.dry_run = true;
153
+ i += 1;
154
+ } else if (tok === "--force") {
155
+ opts.force = true;
156
+ i += 1;
157
+ } else if (tok === "--quiet") {
158
+ opts.quiet = true;
159
+ i += 1;
160
+ } else {
161
+ emitError(`unrecognized arguments: ${tok}`);
162
+ }
163
+ }
164
+ return opts;
165
+ }
166
+ function _emit(quiet, out, msg) {
167
+ if (!quiet) {
168
+ _print(out, msg);
169
+ }
170
+ }
171
+ function main2(argv = null, options = {}) {
172
+ const out = options.out ?? _stdoutSink();
173
+ const err = options.err ?? _stderrSink();
174
+ const opts = _parse(argv ?? process.argv.slice(2), out, err);
175
+ const envProjectRoot = process.env["PROJECT_ROOT"];
176
+ const arg = opts.project || (envProjectRoot ? envProjectRoot : null);
177
+ const [project_root] = resolve_project_root(arg);
178
+ const manifest = manifest_path(project_root);
179
+ const data = read_manifest(manifest);
180
+ if (data === null) {
181
+ _emit(opts.quiet, out, `\u274C No manifest found at ${manifest}`);
182
+ _emit(opts.quiet, out, " Run `./agent-config init --tools=<id>` to create one.");
183
+ return 1;
184
+ }
185
+ const rawTools = data["tools"];
186
+ const entries = (Array.isArray(rawTools) ? rawTools : []).filter(
187
+ (e) => _isPlainObject(e)
188
+ );
189
+ const totalEntries = Array.isArray(rawTools) ? rawTools.length : 0;
190
+ if (totalEntries === 0) {
191
+ _emit(opts.quiet, out, `\u2139\uFE0F Manifest is empty: ${manifest}`);
192
+ return 0;
193
+ }
194
+ const [missing, surfaced] = _group_by_scope(entries, project_root);
195
+ const total_missing = missing.project.length + missing.global.length;
196
+ const total_present = totalEntries - total_missing;
197
+ _emit(opts.quiet, out, `Manifest: ${manifest}`);
198
+ _emit(
199
+ opts.quiet,
200
+ out,
201
+ `Tools: ${totalEntries} listed, ${total_present} present, ${total_missing} missing`
202
+ );
203
+ if (total_missing === 0) {
204
+ _emit(opts.quiet, out, "\u2705 All bridges already installed. Nothing to do.");
205
+ return 0;
206
+ }
207
+ for (const [name, marker] of surfaced) {
208
+ _emit(opts.quiet, out, ` \u2022 ${_ljust(name, 15)} \u2192 ${marker} (missing)`);
209
+ }
210
+ if (opts.dry_run) {
211
+ _emit(opts.quiet, out, "");
212
+ _emit(opts.quiet, out, "Dry-run: no bridges written.");
213
+ return 0;
214
+ }
215
+ _emit(opts.quiet, out, "");
216
+ for (const scope of ["project", "global"]) {
217
+ const tools = missing[scope];
218
+ if (!tools.length) {
219
+ continue;
220
+ }
221
+ const sorted = [...tools].sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
222
+ _emit(opts.quiet, out, `Replaying scope=${scope}: ${sorted.join(", ")}`);
223
+ const rc = _run_install(scope, tools, project_root, {
224
+ force: opts.force,
225
+ dry_run: false
226
+ });
227
+ if (rc !== 0) {
228
+ _emit(opts.quiet, out, `\u274C Installer failed for scope=${scope} (rc=${rc}); aborting.`);
229
+ return rc;
230
+ }
231
+ }
232
+ _emit(opts.quiet, out, "");
233
+ _emit(opts.quiet, out, "\u2705 Sync complete.");
234
+ return 0;
235
+ }
236
+ var _HERE = fileURLToPath(import.meta.url);
237
+ function _isCliEntry() {
238
+ if (process.argv[1] === void 0) {
239
+ return false;
240
+ }
241
+ const argvUrl = pathToFileURL(path.resolve(process.argv[1])).href;
242
+ if (import.meta.url === argvUrl) {
243
+ return true;
244
+ }
245
+ try {
246
+ const here = fs.realpathSync(fileURLToPath(import.meta.url));
247
+ const argv = fs.realpathSync(path.resolve(process.argv[1]));
248
+ return here === argv;
249
+ } catch {
250
+ return false;
251
+ }
252
+ }
253
+ if (_isCliEntry() || process.argv[1] === _HERE) {
254
+ try {
255
+ process.exitCode = main2(process.argv.slice(2));
256
+ } catch (exc) {
257
+ if (exc instanceof ArgparseExit) {
258
+ process.exitCode = exc.code;
259
+ } else {
260
+ throw exc;
261
+ }
262
+ }
263
+ }
264
+ export {
265
+ main2 as main
266
+ };