@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,657 @@
1
+ import { createRequire as __acCreateRequire } from 'node:module'; const require = globalThis.require ?? __acCreateRequire(import.meta.url);
2
+ import {
3
+ PROJECT_BRIDGE_MARKERS,
4
+ USER_SCOPE_PATHS,
5
+ subtract_pointers
6
+ } from "./chunk-QFKQLQ7X.js";
7
+ import "./chunk-XX6TOPD7.js";
8
+ import "./chunk-EJYIGZ3T.js";
9
+ import {
10
+ manifest_path,
11
+ read_manifest,
12
+ remove_managed_hooks,
13
+ write_atomic,
14
+ write_manifest
15
+ } from "./chunk-A3HJ6NTI.js";
16
+ import {
17
+ lockfile_path,
18
+ lockfile_write_path,
19
+ read_lockfile,
20
+ write_lockfile
21
+ } from "./chunk-GRRPEPRN.js";
22
+ import "./chunk-TJIAM5FW.js";
23
+ import {
24
+ resolve_project_root
25
+ } from "./chunk-HJ6DAJHR.js";
26
+ import "./chunk-NDJLNC6Q.js";
27
+ import "./chunk-523HCFYO.js";
28
+ import "./chunk-MCJYCQPF.js";
29
+ import "./chunk-OY53J6II.js";
30
+ import "./chunk-J55WI3RR.js";
31
+
32
+ // src/scripts/_cli/cmd_uninstall.ts
33
+ import * as fs from "node:fs";
34
+ import * as os from "node:os";
35
+ import * as path from "node:path";
36
+ import process from "node:process";
37
+ import { fileURLToPath, pathToFileURL } from "node:url";
38
+ var ArgparseExit = class extends Error {
39
+ code;
40
+ constructor(code) {
41
+ super(`ArgparseExit(${code})`);
42
+ this.name = "ArgparseExit";
43
+ this.code = code;
44
+ }
45
+ };
46
+ var _stdout = { write: (t) => process.stdout.write(t) };
47
+ var _stderr = { write: (t) => process.stderr.write(t) };
48
+ function _print(out, line = "") {
49
+ out.write(line + "\n");
50
+ }
51
+ function expanduser(p) {
52
+ if (p === "~" || p.startsWith("~/")) {
53
+ const home = process.env["HOME"] ?? process.env["USERPROFILE"] ?? "";
54
+ return home + p.slice(1);
55
+ }
56
+ return p;
57
+ }
58
+ function _isDir(p) {
59
+ try {
60
+ return fs.statSync(p).isDirectory();
61
+ } catch {
62
+ return false;
63
+ }
64
+ }
65
+ function _exists(p) {
66
+ try {
67
+ fs.lstatSync(p);
68
+ return true;
69
+ } catch {
70
+ return false;
71
+ }
72
+ }
73
+ function _isPlainObject(value) {
74
+ return typeof value === "object" && value !== null && !Array.isArray(value);
75
+ }
76
+ function _jsonStrAscii(s) {
77
+ let out = '"';
78
+ for (let i = 0; i < s.length; i++) {
79
+ const code = s.charCodeAt(i);
80
+ const ch = s[i];
81
+ switch (ch) {
82
+ case '"':
83
+ out += '\\"';
84
+ break;
85
+ case "\\":
86
+ out += "\\\\";
87
+ break;
88
+ case "\n":
89
+ out += "\\n";
90
+ break;
91
+ case "\r":
92
+ out += "\\r";
93
+ break;
94
+ case " ":
95
+ out += "\\t";
96
+ break;
97
+ case "\b":
98
+ out += "\\b";
99
+ break;
100
+ case "\f":
101
+ out += "\\f";
102
+ break;
103
+ default:
104
+ if (code < 32 || code > 126) {
105
+ out += "\\u" + code.toString(16).padStart(4, "0");
106
+ } else {
107
+ out += ch;
108
+ }
109
+ }
110
+ }
111
+ return out + '"';
112
+ }
113
+ function _jsonScalarAscii(value) {
114
+ if (value === null || value === void 0) return "null";
115
+ if (typeof value === "boolean") return value ? "true" : "false";
116
+ if (typeof value === "number") {
117
+ if (!Number.isFinite(value)) {
118
+ if (Number.isNaN(value)) return "NaN";
119
+ return value > 0 ? "Infinity" : "-Infinity";
120
+ }
121
+ return String(value);
122
+ }
123
+ if (typeof value === "string") return _jsonStrAscii(value);
124
+ return null;
125
+ }
126
+ function _dumpIndentAscii(value, indent, depth) {
127
+ const scalar = _jsonScalarAscii(value);
128
+ if (scalar !== null) return scalar;
129
+ const pad = " ".repeat(indent * (depth + 1));
130
+ const closePad = " ".repeat(indent * depth);
131
+ if (Array.isArray(value)) {
132
+ if (value.length === 0) return "[]";
133
+ const items = value.map((v) => pad + _dumpIndentAscii(v, indent, depth + 1));
134
+ return `[
135
+ ${items.join(",\n")}
136
+ ${closePad}]`;
137
+ }
138
+ if (typeof value === "object" && value !== null) {
139
+ const obj = value;
140
+ const keys = Object.keys(obj);
141
+ if (keys.length === 0) return "{}";
142
+ const items = keys.map(
143
+ (k) => `${pad}${_jsonStrAscii(k)}: ${_dumpIndentAscii(obj[k], indent, depth + 1)}`
144
+ );
145
+ return `{
146
+ ${items.join(",\n")}
147
+ ${closePad}}`;
148
+ }
149
+ return _jsonStrAscii(String(value));
150
+ }
151
+ function _jsonDumpsIndentAscii(value, indent) {
152
+ return _dumpIndentAscii(value, indent, 0);
153
+ }
154
+ function _resolve_project_root(arg) {
155
+ const [root] = resolve_project_root(arg);
156
+ return root;
157
+ }
158
+ function _filter_tools(all_tools, requested) {
159
+ const pool = [...all_tools];
160
+ if (!requested || requested.trim() === "all") {
161
+ return pool;
162
+ }
163
+ const wanted = new Set(
164
+ requested.split(",").map((t) => t.trim()).filter((t) => t)
165
+ );
166
+ return pool.filter((t) => wanted.has(t));
167
+ }
168
+ function _remove_project_marker(project_root, tool, opts) {
169
+ const rel = PROJECT_BRIDGE_MARKERS[tool];
170
+ if (!rel) {
171
+ return [`${tool}: no project marker registered (skipped)`, false];
172
+ }
173
+ const target = path.join(project_root, rel);
174
+ if (!_exists(target)) {
175
+ return [`${tool}: ${rel} already absent`, false];
176
+ }
177
+ if (opts.dry_run) {
178
+ return [`${tool}: would remove ${rel}`, true];
179
+ }
180
+ try {
181
+ fs.unlinkSync(target);
182
+ return [`${tool}: removed ${rel}`, true];
183
+ } catch (exc) {
184
+ return [`${tool}: \u274C failed to remove ${rel} (${_osErr(exc)})`, false];
185
+ }
186
+ }
187
+ function _remove_global_content(tool, opts) {
188
+ const anchor = USER_SCOPE_PATHS[tool];
189
+ if (!anchor) {
190
+ return [`${tool}: no global anchor registered (skipped)`, false];
191
+ }
192
+ const target = expanduser(anchor);
193
+ if (!_exists(target)) {
194
+ return [`${tool}: ${anchor} already absent`, false];
195
+ }
196
+ if (!opts.purge) {
197
+ return [`${tool}: ${anchor} preserved (pass --purge to delete)`, false];
198
+ }
199
+ if (opts.dry_run) {
200
+ return [`${tool}: would purge ${anchor}`, true];
201
+ }
202
+ try {
203
+ if (_isDir(target)) {
204
+ fs.rmSync(target, { recursive: true, force: false });
205
+ } else {
206
+ fs.unlinkSync(target);
207
+ }
208
+ return [`${tool}: purged ${anchor}`, true];
209
+ } catch (exc) {
210
+ return [`${tool}: \u274C failed to purge ${anchor} (${_osErr(exc)})`, false];
211
+ }
212
+ }
213
+ function _osErr(exc) {
214
+ const e = exc;
215
+ return e && e.message ? e.message : String(exc);
216
+ }
217
+ function _is_v2_entry(entry) {
218
+ return Boolean(_listOf(entry["files"]).length) || Boolean(_listOf(entry["merged_keys"]).length);
219
+ }
220
+ function _listOf(value) {
221
+ return Array.isArray(value) ? value : [];
222
+ }
223
+ function _resolve_recorded_path(project_root, recorded) {
224
+ if (path.isAbsolute(recorded)) {
225
+ return recorded;
226
+ }
227
+ return path.resolve(project_root, recorded);
228
+ }
229
+ function _set_tool_status(manifest_path2, version, tools, name, status, opts) {
230
+ const new_tools = [];
231
+ for (let entry of tools) {
232
+ if (entry["name"] === name) {
233
+ entry = { ...entry, status };
234
+ }
235
+ new_tools.push(entry);
236
+ }
237
+ write_manifest(manifest_path2, version, new_tools, {
238
+ deploy_roots: opts.deploy_roots
239
+ });
240
+ return new_tools;
241
+ }
242
+ function _subtract_merged_keys(entry, project_root, opts) {
243
+ const warnings = [];
244
+ const emptied = /* @__PURE__ */ new Set();
245
+ const touched = /* @__PURE__ */ new Set();
246
+ const merged_keys = _listOf(entry["merged_keys"]);
247
+ if (!merged_keys.length) {
248
+ return [warnings, emptied, touched];
249
+ }
250
+ const by_file = /* @__PURE__ */ new Map();
251
+ for (const record of merged_keys) {
252
+ const file = String(record["file"]);
253
+ if (!by_file.has(file)) {
254
+ by_file.set(file, []);
255
+ }
256
+ by_file.get(file).push(record);
257
+ }
258
+ for (const [file_label, records] of by_file) {
259
+ const target = _resolve_recorded_path(project_root, file_label);
260
+ touched.add(target);
261
+ if (!_exists(target)) {
262
+ warnings.push(`${file_label}: absent \u2014 skipping ${records.length} pointer(s)`);
263
+ continue;
264
+ }
265
+ let doc;
266
+ try {
267
+ doc = JSON.parse(fs.readFileSync(target, { encoding: "utf-8" }));
268
+ } catch (exc) {
269
+ warnings.push(`${file_label}: unparseable JSON (${_jsonExc(exc, target)}); skipped`);
270
+ continue;
271
+ }
272
+ if (!_isPlainObject(doc)) {
273
+ warnings.push(`${file_label}: not a JSON object; skipped`);
274
+ continue;
275
+ }
276
+ const [new_doc, sub_warnings] = subtract_pointers(
277
+ doc,
278
+ records.map((r) => ({
279
+ json_pointer: String(r["json_pointer"]),
280
+ value_hash: r["value_hash"] ?? null
281
+ }))
282
+ );
283
+ for (const w of sub_warnings) {
284
+ warnings.push(`${file_label}${w.pointer}: ${w.reason}`);
285
+ }
286
+ if (opts.dry_run) {
287
+ if (Object.keys(new_doc).length === 0) {
288
+ emptied.add(target);
289
+ }
290
+ continue;
291
+ }
292
+ if (Object.keys(new_doc).length > 0) {
293
+ write_atomic(target, _jsonDumpsIndentAscii(new_doc, 2) + "\n");
294
+ } else {
295
+ emptied.add(target);
296
+ }
297
+ }
298
+ return [warnings, emptied, touched];
299
+ }
300
+ function _jsonExc(exc, _target) {
301
+ return _osErr(exc);
302
+ }
303
+ function _delete_tool_files(entry, project_root, opts) {
304
+ const deleted = [];
305
+ const skipped = [];
306
+ for (const record of _listOf(entry["files"])) {
307
+ const target = _resolve_recorded_path(project_root, String(record["path"]));
308
+ const kind = record["kind"];
309
+ const label = target;
310
+ if (kind === "bridge") {
311
+ const is_shared_json = _exists(label) && path.extname(label) === ".json" && opts.touched_files.has(label) && !opts.emptied_files.has(label);
312
+ if (is_shared_json) {
313
+ skipped.push(`bridge ${label}: foreign keys preserved`);
314
+ continue;
315
+ }
316
+ if (!_exists(label)) {
317
+ skipped.push(`bridge ${label}: already absent`);
318
+ continue;
319
+ }
320
+ if (opts.dry_run) {
321
+ deleted.push(`would remove bridge ${label}`);
322
+ continue;
323
+ }
324
+ try {
325
+ fs.unlinkSync(label);
326
+ deleted.push(`removed bridge ${label}`);
327
+ } catch (exc) {
328
+ skipped.push(`bridge ${label}: \u274C ${_osErr(exc)}`);
329
+ }
330
+ } else if (kind === "marker") {
331
+ if (!_exists(label)) {
332
+ skipped.push(`marker ${label}: already absent`);
333
+ continue;
334
+ }
335
+ if (opts.dry_run) {
336
+ deleted.push(`would remove marker ${label}`);
337
+ continue;
338
+ }
339
+ try {
340
+ fs.unlinkSync(label);
341
+ deleted.push(`removed marker ${label}`);
342
+ } catch (exc) {
343
+ skipped.push(`marker ${label}: \u274C ${_osErr(exc)}`);
344
+ }
345
+ } else if (kind === "deployed") {
346
+ if (!opts.purge) {
347
+ skipped.push(`deployed ${label}: preserved (pass --purge)`);
348
+ continue;
349
+ }
350
+ if (!_exists(label)) {
351
+ skipped.push(`deployed ${label}: already absent`);
352
+ continue;
353
+ }
354
+ if (opts.dry_run) {
355
+ deleted.push(`would purge deployed ${label}`);
356
+ continue;
357
+ }
358
+ try {
359
+ if (_isDir(label)) {
360
+ fs.rmSync(label, { recursive: true, force: false });
361
+ } else {
362
+ fs.unlinkSync(label);
363
+ }
364
+ deleted.push(`purged deployed ${label}`);
365
+ } catch (exc) {
366
+ skipped.push(`deployed ${label}: \u274C ${_osErr(exc)}`);
367
+ }
368
+ } else {
369
+ skipped.push(`${label}: unknown kind=${_pyRepr(kind)}`);
370
+ }
371
+ }
372
+ return [deleted, skipped];
373
+ }
374
+ function _pyRepr(value) {
375
+ if (value === null || value === void 0) return "None";
376
+ if (typeof value === "string") return `'${value.replace(/\\/g, "\\\\").replace(/'/g, "\\'")}'`;
377
+ if (typeof value === "boolean") return value ? "True" : "False";
378
+ return String(value);
379
+ }
380
+ function _parse(argv) {
381
+ const prog = "agent-config uninstall";
382
+ const usage = "usage: agent-config uninstall [-h] [--global] [--tools TOOLS]\n [--project PROJECT] [--dry-run] [--purge]\n [--force]\n";
383
+ const emitError = (msg) => {
384
+ _stderr.write(usage);
385
+ _stderr.write(`${prog}: error: ${msg}
386
+ `);
387
+ throw new ArgparseExit(2);
388
+ };
389
+ const opts = {
390
+ global_mode: false,
391
+ tools: null,
392
+ project: null,
393
+ dry_run: false,
394
+ purge: false,
395
+ force: false
396
+ };
397
+ const takeValue = (tok, i2) => {
398
+ const eq = tok.indexOf("=");
399
+ if (eq >= 0) {
400
+ return [tok.slice(eq + 1), i2 + 1];
401
+ }
402
+ const val = argv[i2 + 1];
403
+ if (val === void 0) {
404
+ emitError(`argument ${tok}: expected one argument`);
405
+ }
406
+ return [val, i2 + 2];
407
+ };
408
+ let i = 0;
409
+ while (i < argv.length) {
410
+ const tok = argv[i];
411
+ const flag = tok.includes("=") ? tok.slice(0, tok.indexOf("=")) : tok;
412
+ if (flag === "-h" || flag === "--help") {
413
+ _stdout.write(usage);
414
+ throw new ArgparseExit(0);
415
+ } else if (flag === "--global") {
416
+ opts.global_mode = true;
417
+ i += 1;
418
+ } else if (flag === "--tools") {
419
+ const [v, ni] = takeValue(tok, i);
420
+ opts.tools = v;
421
+ i = ni;
422
+ } else if (flag === "--project") {
423
+ const [v, ni] = takeValue(tok, i);
424
+ opts.project = v;
425
+ i = ni;
426
+ } else if (flag === "--dry-run") {
427
+ opts.dry_run = true;
428
+ i += 1;
429
+ } else if (flag === "--purge") {
430
+ opts.purge = true;
431
+ i += 1;
432
+ } else if (flag === "--force") {
433
+ opts.force = true;
434
+ i += 1;
435
+ } else {
436
+ emitError(`unrecognized arguments: ${tok}`);
437
+ }
438
+ }
439
+ return opts;
440
+ }
441
+ function _uninstall_project(opts) {
442
+ const project_root = _resolve_project_root(opts.project);
443
+ const manifest_path2 = manifest_path(project_root);
444
+ const manifest = read_manifest(manifest_path2);
445
+ if (manifest === null && !opts.force) {
446
+ _print(_stderr, `\u274C no project lockfile at ${manifest_path2}`);
447
+ _print(_stderr, " pass --force to uninstall by --tools=<list> without manifest");
448
+ return 1;
449
+ }
450
+ let pool = (manifest ? _listOf(manifest["tools"]) : []).map((e) => String(e["name"] ?? ""));
451
+ if (!pool.length && opts.tools) {
452
+ pool = opts.tools.split(",").map((t) => t.trim()).filter((t) => t);
453
+ }
454
+ const tools = _filter_tools(pool, opts.tools);
455
+ if (!tools.length) {
456
+ _print(_stdout, "\u2139\uFE0F no tools to uninstall");
457
+ return 0;
458
+ }
459
+ _print(
460
+ _stdout,
461
+ `${opts.dry_run ? "[dry-run] " : ""}uninstalling ${tools.length} tool(s) from ${project_root}:`
462
+ );
463
+ if (manifest === null) {
464
+ for (const tool of tools) {
465
+ const [line] = _remove_project_marker(project_root, tool, { dry_run: opts.dry_run });
466
+ _print(_stdout, ` \xB7 ${line}`);
467
+ }
468
+ return 0;
469
+ }
470
+ const version = String(manifest["agent_config_version"] ?? "");
471
+ const deploy_roots = manifest["deploy_roots"] || null;
472
+ let tool_entries = [..._listOf(manifest["tools"])];
473
+ const removed_names = [];
474
+ for (const tool of tools) {
475
+ let entry = tool_entries.find((e) => e["name"] === tool) ?? null;
476
+ if (entry === null) {
477
+ const [line, removed] = _remove_project_marker(project_root, tool, {
478
+ dry_run: opts.dry_run
479
+ });
480
+ _print(_stdout, ` \xB7 ${line}`);
481
+ if (removed && !opts.dry_run) {
482
+ removed_names.push(tool);
483
+ }
484
+ continue;
485
+ }
486
+ if (!_is_v2_entry(entry)) {
487
+ const [line, removed] = _remove_project_marker(project_root, tool, {
488
+ dry_run: opts.dry_run
489
+ });
490
+ _print(_stdout, ` \xB7 ${line}`);
491
+ if (removed && !opts.dry_run) {
492
+ removed_names.push(tool);
493
+ }
494
+ continue;
495
+ }
496
+ const files_n = _listOf(entry["files"]).length;
497
+ const merges_n = _listOf(entry["merged_keys"]).length;
498
+ _print(
499
+ _stdout,
500
+ ` \xB7 ${tool}: v2 uninstall (${files_n} file(s), ${merges_n} merge pointer(s))`
501
+ );
502
+ if (!opts.dry_run) {
503
+ tool_entries = _set_tool_status(
504
+ manifest_path2,
505
+ version,
506
+ tool_entries,
507
+ tool,
508
+ "uninstalling",
509
+ { deploy_roots }
510
+ );
511
+ entry = tool_entries.find((e) => e["name"] === tool) ?? entry;
512
+ }
513
+ const [warnings, emptied, touched] = _subtract_merged_keys(entry, project_root, {
514
+ dry_run: opts.dry_run
515
+ });
516
+ for (const w of warnings) {
517
+ _print(_stdout, ` \u26A0\uFE0F ${w}`);
518
+ }
519
+ const [deleted, skipped] = _delete_tool_files(entry, project_root, {
520
+ dry_run: opts.dry_run,
521
+ purge: opts.purge,
522
+ emptied_files: emptied,
523
+ touched_files: touched
524
+ });
525
+ for (const d of deleted) {
526
+ _print(_stdout, ` \u2713 ${d}`);
527
+ }
528
+ for (const s of skipped) {
529
+ _print(_stdout, ` \u21B7 ${s}`);
530
+ }
531
+ if (!opts.dry_run) {
532
+ removed_names.push(tool);
533
+ }
534
+ }
535
+ if (removed_names.length && !opts.dry_run) {
536
+ const remaining = tool_entries.filter((e) => !removed_names.includes(String(e["name"])));
537
+ write_manifest(manifest_path2, version, remaining, { deploy_roots });
538
+ _print(_stdout, `\u2705 manifest updated (${removed_names.length} entries removed)`);
539
+ }
540
+ return 0;
541
+ }
542
+ function _uninstall_global(opts) {
543
+ const lock_path = lockfile_path();
544
+ const write_path = lockfile_write_path();
545
+ const lock = read_lockfile(lock_path);
546
+ if (lock === null && !opts.force) {
547
+ _print(_stderr, `\u274C no global lockfile at ${lock_path}`);
548
+ return 1;
549
+ }
550
+ let pool = lock ? [...lock.tools ?? []] : [];
551
+ if (!pool.length && opts.tools) {
552
+ pool = opts.tools.split(",").map((t) => t.trim()).filter((t) => t);
553
+ }
554
+ const tools = _filter_tools(pool, opts.tools);
555
+ if (!tools.length) {
556
+ _print(_stdout, "\u2139\uFE0F no tools to uninstall");
557
+ return 0;
558
+ }
559
+ _print(
560
+ _stdout,
561
+ `${opts.dry_run ? "[dry-run] " : ""}uninstalling ${tools.length} tool(s) from global scope:`
562
+ );
563
+ const removed_names = [];
564
+ for (const tool of tools) {
565
+ const [line, removed] = _remove_global_content(tool, {
566
+ dry_run: opts.dry_run,
567
+ purge: opts.purge
568
+ });
569
+ _print(_stdout, ` \xB7 ${line}`);
570
+ if (removed && !opts.dry_run) {
571
+ removed_names.push(tool);
572
+ }
573
+ }
574
+ if (tools.includes("claude-code")) {
575
+ const settings_path = path.join(os.homedir(), ".claude", "settings.json");
576
+ if (opts.dry_run) {
577
+ _print(_stdout, ` \xB7 claude-code: would remove managed hooks from ${settings_path}`);
578
+ } else {
579
+ try {
580
+ const res = remove_managed_hooks(settings_path);
581
+ if (res.changed) {
582
+ _print(
583
+ _stdout,
584
+ ` \xB7 claude-code: removed managed hooks (${res.events.join(", ")})`
585
+ );
586
+ }
587
+ } catch (e) {
588
+ _print(_stderr, `\u26A0\uFE0F claude-code: managed-hook removal skipped \u2014 ${String(e)}`);
589
+ }
590
+ }
591
+ }
592
+ if (lock !== null && !opts.dry_run) {
593
+ const remaining = (lock.tools ?? []).filter((t) => !tools.includes(t));
594
+ const version = String(lock["agent_config_version"] ?? "");
595
+ if (remaining.length) {
596
+ write_lockfile(version, remaining, { path: write_path });
597
+ if (lock_path !== write_path) {
598
+ try {
599
+ fs.unlinkSync(lock_path);
600
+ } catch {
601
+ }
602
+ }
603
+ _print(
604
+ _stdout,
605
+ `\u2705 lockfile updated (${tools.length} entries removed, ${remaining.length} kept)`
606
+ );
607
+ } else {
608
+ const targets = lock_path === write_path ? [write_path] : [lock_path, write_path];
609
+ for (const target of targets) {
610
+ try {
611
+ fs.unlinkSync(target);
612
+ } catch {
613
+ }
614
+ }
615
+ _print(_stdout, `\u2705 lockfile deleted (${write_path})`);
616
+ }
617
+ }
618
+ return 0;
619
+ }
620
+ function main(argv = null) {
621
+ const opts = _parse(argv !== null ? [...argv] : process.argv.slice(2));
622
+ if (opts.global_mode) {
623
+ return _uninstall_global(opts);
624
+ }
625
+ return _uninstall_project(opts);
626
+ }
627
+ var _HERE = fileURLToPath(import.meta.url);
628
+ function _isCliEntry() {
629
+ if (process.argv[1] === void 0) {
630
+ return false;
631
+ }
632
+ const argvUrl = pathToFileURL(path.resolve(process.argv[1])).href;
633
+ if (import.meta.url === argvUrl) {
634
+ return true;
635
+ }
636
+ try {
637
+ const here = fs.realpathSync(fileURLToPath(import.meta.url));
638
+ const argv = fs.realpathSync(path.resolve(process.argv[1]));
639
+ return here === argv;
640
+ } catch {
641
+ return false;
642
+ }
643
+ }
644
+ if (_isCliEntry() || process.argv[1] === _HERE) {
645
+ try {
646
+ process.exitCode = main(process.argv.slice(2));
647
+ } catch (exc) {
648
+ if (exc instanceof ArgparseExit) {
649
+ process.exitCode = exc.code;
650
+ } else {
651
+ throw exc;
652
+ }
653
+ }
654
+ }
655
+ export {
656
+ main
657
+ };