@anarchitects/governance-cli 0.0.1 → 0.0.3

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.
@@ -0,0 +1,1936 @@
1
+ import { readFileSync as G, writeFileSync as ve, existsSync as te, statSync as ne } from "node:fs";
2
+ import g from "node:path";
3
+ import { fileURLToPath as we } from "node:url";
4
+ import { buildGovernanceWorkspace as H, normalizeGovernanceProfile as ye, evaluateGovernancePolicies as Ie, buildGovernancePolicySignals as ke, calculateGovernanceMetrics as Ce, calculateGovernanceHealth as $e, buildTopIssues as Ae, buildGovernanceAssessment as be, buildGovernanceRecommendations as je } from "@anarchitects/governance-core";
5
+ import { parseDocument as Se } from "yaml";
6
+ function _e(e) {
7
+ return {
8
+ id: "capability:manual-workspace",
9
+ data: {
10
+ format: e.format,
11
+ schemaVersion: e.schemaVersion
12
+ }
13
+ };
14
+ }
15
+ const Ee = /* @__PURE__ */ new Set([
16
+ "schemaVersion",
17
+ "workspace",
18
+ "projects",
19
+ "dependencies"
20
+ ]), Pe = /* @__PURE__ */ new Set(["name", "root"]), Re = /* @__PURE__ */ new Set(["name", "root", "tags", "type", "metadata"]), xe = /* @__PURE__ */ new Set(["source", "target", "type"]), Ge = /* @__PURE__ */ new Set(["application", "library", "tool", "unknown"]), Le = /* @__PURE__ */ new Set(["static", "dynamic", "implicit", "unknown"]), Fe = /* @__PURE__ */ new Set(["name", "root", "tags", "type"]), We = ["domain", "scope", "layer"];
21
+ class L extends Error {
22
+ constructor(o, t, r) {
23
+ super(o), this.code = t, this.filePath = r, this.name = "GenericWorkspaceLoadError";
24
+ }
25
+ }
26
+ class I extends Error {
27
+ constructor(o, t) {
28
+ super(
29
+ `Generic workspace validation failed for "${o}" with ${t.length} issue${t.length === 1 ? "" : "s"}.`
30
+ ), this.filePath = o, this.issues = t, this.name = "GenericWorkspaceValidationError";
31
+ }
32
+ }
33
+ function Ve(e) {
34
+ const o = g.resolve(e), t = ie(o), r = ae(o), n = ce(r, o, t);
35
+ let a;
36
+ try {
37
+ a = re(n);
38
+ } catch (c) {
39
+ throw c instanceof I ? new I(o, c.issues) : c;
40
+ }
41
+ const i = Ue(a, t);
42
+ return {
43
+ filePath: o,
44
+ format: t,
45
+ adapterResult: i,
46
+ workspace: H(i)
47
+ };
48
+ }
49
+ function Oe(e) {
50
+ return Ve(e).adapterResult;
51
+ }
52
+ function re(e) {
53
+ const o = [], t = F(e);
54
+ t || B("<memory>", [
55
+ {
56
+ code: "governance.workspace_schema.invalid_root",
57
+ message: "Workspace document root must be an object.",
58
+ path: "/"
59
+ }
60
+ ]), T(t, Ee, "/", o);
61
+ const r = t.schemaVersion;
62
+ let n;
63
+ r === void 0 ? o.push(
64
+ S("/schemaVersion", "schemaVersion is required.")
65
+ ) : Number.isInteger(r) ? r !== 1 ? o.push({
66
+ code: "governance.workspace_schema.unsupported_schema_version",
67
+ message: "schemaVersion must equal 1.",
68
+ path: "/schemaVersion"
69
+ }) : n = 1 : o.push(
70
+ v("/schemaVersion", "schemaVersion must be an integer.")
71
+ );
72
+ const a = De(t.workspace, o), i = Ne(t.projects, o), c = Te(t.dependencies, o);
73
+ return Ze(i, o), Me(i, c, o), (o.length > 0 || !a || !n) && B("<memory>", o), {
74
+ schemaVersion: n,
75
+ workspace: a,
76
+ projects: i.map(Ke),
77
+ dependencies: c.map(Qe)
78
+ };
79
+ }
80
+ function pt(e) {
81
+ const o = g.resolve(e), t = ie(o), r = ae(o), n = ce(r, o, t);
82
+ try {
83
+ return re(n);
84
+ } catch (a) {
85
+ throw a instanceof I ? new I(o, a.issues) : a;
86
+ }
87
+ }
88
+ function ae(e) {
89
+ try {
90
+ return G(e, "utf8");
91
+ } catch {
92
+ throw new L(
93
+ `Failed to read workspace file "${e}".`,
94
+ "governance.workspace_loader.read_failed",
95
+ e
96
+ );
97
+ }
98
+ }
99
+ function ie(e) {
100
+ const o = g.extname(e).toLowerCase();
101
+ if (o === ".json")
102
+ return "json";
103
+ if (o === ".yaml" || o === ".yml")
104
+ return "yaml";
105
+ throw new L(
106
+ `Unsupported workspace file extension for "${e}". Expected .json, .yaml, or .yml.`,
107
+ "governance.workspace_loader.unsupported_extension",
108
+ e
109
+ );
110
+ }
111
+ function ce(e, o, t) {
112
+ try {
113
+ if (t === "json")
114
+ return JSON.parse(e);
115
+ const r = Se(e, {
116
+ merge: !1,
117
+ strict: !0,
118
+ uniqueKeys: !1
119
+ });
120
+ if (r.errors.length > 0)
121
+ throw new Error(r.errors[0]?.message ?? "Invalid YAML.");
122
+ return r.toJS();
123
+ } catch {
124
+ throw new L(
125
+ `Failed to parse ${t.toUpperCase()} workspace file "${o}".`,
126
+ "governance.workspace_loader.parse_error",
127
+ o
128
+ );
129
+ }
130
+ }
131
+ function De(e, o) {
132
+ const t = "/workspace";
133
+ if (e === void 0) {
134
+ o.push(S(t, "workspace is required."));
135
+ return;
136
+ }
137
+ const r = F(e);
138
+ if (!r) {
139
+ o.push(v(t, "workspace must be an object."));
140
+ return;
141
+ }
142
+ T(r, Pe, t, o);
143
+ const n = P(r.name, `${t}/name`, o, "name"), a = r.root ?? ".", i = qe(a, `${t}/root`, o, "root");
144
+ if (!(n === void 0 || i === void 0))
145
+ return n.trim().length === 0 && o.push(
146
+ D(`${t}/name`, "workspace.name must be non-empty.")
147
+ ), pe(i) || o.push(
148
+ se(
149
+ `${t}/root`,
150
+ "workspace.root must be a normalized relative path."
151
+ )
152
+ ), {
153
+ name: n,
154
+ root: i
155
+ };
156
+ }
157
+ function Ne(e, o) {
158
+ const t = "/projects";
159
+ if (e === void 0)
160
+ return o.push(S(t, "projects is required.")), [];
161
+ if (!Array.isArray(e))
162
+ return o.push(v(t, "projects must be an array.")), [];
163
+ e.length === 0 && o.push(
164
+ D(t, "projects must contain at least one project.")
165
+ );
166
+ const r = [];
167
+ return e.forEach((n, a) => {
168
+ const i = `${t}/${a}`, c = F(n);
169
+ if (!c) {
170
+ o.push(
171
+ v(i, "Each project must be an object.")
172
+ );
173
+ return;
174
+ }
175
+ T(c, Re, i, o);
176
+ const d = P(
177
+ c.name,
178
+ `${i}/name`,
179
+ o,
180
+ "name"
181
+ ), s = P(
182
+ c.root,
183
+ `${i}/root`,
184
+ o,
185
+ "root"
186
+ );
187
+ s !== void 0 && !pe(s) && o.push(
188
+ se(
189
+ `${i}/root`,
190
+ "Project root must be a normalized relative path."
191
+ )
192
+ );
193
+ const p = Je(c.tags, `${i}/tags`, o), l = Ye(
194
+ c.type,
195
+ `${i}/type`,
196
+ o
197
+ ), h = Xe(
198
+ c.metadata,
199
+ `${i}/metadata`,
200
+ o
201
+ );
202
+ d !== void 0 && d.trim().length === 0 && o.push(
203
+ D(
204
+ `${i}/name`,
205
+ "Project name must be non-empty."
206
+ )
207
+ ), !(d === void 0 || s === void 0 || p === void 0 || l === void 0 || h === void 0) && r.push({
208
+ index: a,
209
+ name: d,
210
+ root: s,
211
+ tags: p,
212
+ type: l,
213
+ metadata: h
214
+ });
215
+ }), r;
216
+ }
217
+ function Te(e, o) {
218
+ const t = "/dependencies";
219
+ if (e === void 0)
220
+ return o.push(S(t, "dependencies is required.")), [];
221
+ if (!Array.isArray(e))
222
+ return o.push(v(t, "dependencies must be an array.")), [];
223
+ const r = [];
224
+ return e.forEach((n, a) => {
225
+ const i = `${t}/${a}`, c = F(n);
226
+ if (!c) {
227
+ o.push(
228
+ v(
229
+ i,
230
+ "Each dependency must be an object."
231
+ )
232
+ );
233
+ return;
234
+ }
235
+ T(c, xe, i, o);
236
+ const d = P(
237
+ c.source,
238
+ `${i}/source`,
239
+ o,
240
+ "source"
241
+ ), s = P(
242
+ c.target,
243
+ `${i}/target`,
244
+ o,
245
+ "target"
246
+ ), p = He(
247
+ c.type,
248
+ `${i}/type`,
249
+ o
250
+ );
251
+ d !== void 0 && s !== void 0 && d === s && o.push({
252
+ code: "governance.workspace_schema.self_dependency",
253
+ message: "Dependency source and target must differ.",
254
+ path: i
255
+ }), !(d === void 0 || s === void 0 || p === void 0) && r.push({
256
+ index: a,
257
+ source: d,
258
+ target: s,
259
+ type: p
260
+ });
261
+ }), r;
262
+ }
263
+ function Ze(e, o) {
264
+ const t = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set();
265
+ e.forEach((n) => {
266
+ const a = `/projects/${n.index}`;
267
+ t.has(n.name) ? o.push({
268
+ code: "governance.workspace_schema.duplicate_project_name",
269
+ message: `Duplicate project name "${n.name}" is not allowed.`,
270
+ path: `${a}/name`
271
+ }) : t.add(n.name), r.has(n.root) ? o.push({
272
+ code: "governance.workspace_schema.duplicate_project_root",
273
+ message: `Duplicate project root "${n.root}" is not allowed.`,
274
+ path: `${a}/root`
275
+ }) : r.add(n.root);
276
+ });
277
+ }
278
+ function Me(e, o, t) {
279
+ const r = new Set(e.map((a) => a.name)), n = /* @__PURE__ */ new Set();
280
+ o.forEach((a) => {
281
+ const i = `/dependencies/${a.index}`;
282
+ r.has(a.source) || t.push({
283
+ code: "governance.workspace_schema.unknown_dependency_source",
284
+ message: `Dependency source "${a.source}" does not match a declared project.`,
285
+ path: `${i}/source`
286
+ }), r.has(a.target) || t.push({
287
+ code: "governance.workspace_schema.unknown_dependency_target",
288
+ message: `Dependency target "${a.target}" does not match a declared project.`,
289
+ path: `${i}/target`
290
+ });
291
+ const c = `${a.source}\0${a.target}\0${a.type}`;
292
+ n.has(c) ? t.push({
293
+ code: "governance.workspace_schema.duplicate_dependency",
294
+ message: `Duplicate dependency "${a.source}" -> "${a.target}" of type "${a.type}" is not allowed.`,
295
+ path: i
296
+ }) : n.add(c);
297
+ });
298
+ }
299
+ function Je(e, o, t) {
300
+ if (e === void 0) {
301
+ t.push(S(o, "tags is required."));
302
+ return;
303
+ }
304
+ if (!Array.isArray(e)) {
305
+ t.push(v(o, "tags must be an array of strings."));
306
+ return;
307
+ }
308
+ const r = [], n = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Map();
309
+ return e.forEach((i, c) => {
310
+ const d = `${o}/${c}`;
311
+ if (typeof i != "string") {
312
+ t.push(v(d, "Each tag must be a string."));
313
+ return;
314
+ }
315
+ if (i.length === 0 || i.trim() !== i) {
316
+ t.push(
317
+ Z(
318
+ d,
319
+ "Tags must be non-empty and may not contain leading or trailing whitespace."
320
+ )
321
+ );
322
+ return;
323
+ }
324
+ if (n.has(i)) {
325
+ t.push(
326
+ Z(d, `Duplicate tag "${i}" is not allowed.`)
327
+ );
328
+ return;
329
+ }
330
+ const s = Be(i);
331
+ if (s) {
332
+ if (a.get(s)) {
333
+ t.push(
334
+ Z(
335
+ d,
336
+ `Multiple "${s}:" tags are not allowed on the same project.`
337
+ )
338
+ );
339
+ return;
340
+ }
341
+ a.set(s, i);
342
+ }
343
+ n.add(i), r.push(i);
344
+ }), r;
345
+ }
346
+ function Ye(e, o, t) {
347
+ if (e === void 0)
348
+ return "unknown";
349
+ if (typeof e != "string") {
350
+ t.push(v(o, "Project type must be a string."));
351
+ return;
352
+ }
353
+ if (!Ge.has(e)) {
354
+ t.push(
355
+ de(
356
+ o,
357
+ "Project type must be one of application, library, tool, or unknown."
358
+ )
359
+ );
360
+ return;
361
+ }
362
+ return e;
363
+ }
364
+ function He(e, o, t) {
365
+ if (typeof e != "string") {
366
+ e === void 0 ? t.push(
367
+ S(o, "Dependency type is required.")
368
+ ) : t.push(
369
+ v(o, "Dependency type must be a string.")
370
+ );
371
+ return;
372
+ }
373
+ if (!Le.has(e)) {
374
+ t.push(
375
+ de(
376
+ o,
377
+ "Dependency type must be one of static, dynamic, implicit, or unknown."
378
+ )
379
+ );
380
+ return;
381
+ }
382
+ return e;
383
+ }
384
+ function Xe(e, o, t) {
385
+ if (e === void 0)
386
+ return {};
387
+ const r = F(e);
388
+ if (!r) {
389
+ t.push(v(o, "metadata must be an object."));
390
+ return;
391
+ }
392
+ return Object.keys(r).forEach((n) => {
393
+ Fe.has(n) && t.push(
394
+ D(
395
+ `${o}/${X(n)}`,
396
+ `metadata must not redefine first-class field "${n}".`
397
+ )
398
+ );
399
+ }), r;
400
+ }
401
+ function Ue(e, o) {
402
+ const t = [...e.projects].sort((n, a) => n.name.localeCompare(a.name)).map((n) => ({
403
+ id: n.name,
404
+ name: n.name,
405
+ root: n.root,
406
+ type: n.type,
407
+ tags: [...n.tags].sort((a, i) => a.localeCompare(i)),
408
+ metadata: { ...n.metadata }
409
+ })), r = [...e.dependencies].sort(ze).map((n) => ({
410
+ sourceProjectId: n.source,
411
+ targetProjectId: n.target,
412
+ type: n.type
413
+ }));
414
+ return {
415
+ workspaceId: e.workspace.name,
416
+ workspaceName: e.workspace.name,
417
+ workspaceRoot: e.workspace.root,
418
+ projects: t,
419
+ dependencies: r,
420
+ capabilities: [
421
+ _e({
422
+ format: o,
423
+ schemaVersion: e.schemaVersion
424
+ })
425
+ ]
426
+ };
427
+ }
428
+ function ze(e, o) {
429
+ return e.source.localeCompare(o.source) || e.target.localeCompare(o.target) || e.type.localeCompare(o.type);
430
+ }
431
+ function T(e, o, t, r) {
432
+ Object.keys(e).forEach((n) => {
433
+ o.has(n) || r.push({
434
+ code: "governance.workspace_schema.unknown_field",
435
+ message: `Unknown field "${n}" is not allowed.`,
436
+ path: t === "/" ? `/${X(n)}` : `${t}/${X(n)}`
437
+ });
438
+ });
439
+ }
440
+ function P(e, o, t, r) {
441
+ if (e === void 0) {
442
+ t.push(S(o, `${r} is required.`));
443
+ return;
444
+ }
445
+ if (typeof e != "string") {
446
+ t.push(v(o, `${r} must be a string.`));
447
+ return;
448
+ }
449
+ return e;
450
+ }
451
+ function qe(e, o, t, r) {
452
+ if (typeof e != "string") {
453
+ t.push(v(o, `${r} must be a string.`));
454
+ return;
455
+ }
456
+ return e;
457
+ }
458
+ function S(e, o) {
459
+ return {
460
+ code: "governance.workspace_schema.missing_required_field",
461
+ message: o,
462
+ path: e
463
+ };
464
+ }
465
+ function v(e, o) {
466
+ return {
467
+ code: "governance.workspace_schema.invalid_field_type",
468
+ message: o,
469
+ path: e
470
+ };
471
+ }
472
+ function D(e, o) {
473
+ return {
474
+ code: "governance.workspace_schema.invalid_value",
475
+ message: o,
476
+ path: e
477
+ };
478
+ }
479
+ function se(e, o) {
480
+ return {
481
+ code: "governance.workspace_schema.invalid_path",
482
+ message: o,
483
+ path: e
484
+ };
485
+ }
486
+ function de(e, o) {
487
+ return {
488
+ code: "governance.workspace_schema.invalid_enum_value",
489
+ message: o,
490
+ path: e
491
+ };
492
+ }
493
+ function Z(e, o) {
494
+ return {
495
+ code: "governance.workspace_schema.invalid_tag",
496
+ message: o,
497
+ path: e
498
+ };
499
+ }
500
+ function B(e, o) {
501
+ throw new I(e, o);
502
+ }
503
+ function Be(e) {
504
+ return We.find(
505
+ (o) => e.startsWith(`${o}:`)
506
+ );
507
+ }
508
+ function Ke(e) {
509
+ return {
510
+ name: e.name,
511
+ root: e.root,
512
+ tags: e.tags,
513
+ type: e.type,
514
+ metadata: e.metadata
515
+ };
516
+ }
517
+ function Qe(e) {
518
+ return {
519
+ source: e.source,
520
+ target: e.target,
521
+ type: e.type
522
+ };
523
+ }
524
+ function pe(e) {
525
+ return e.length === 0 || e.includes("\\") || e.startsWith("/") || e.startsWith("./") || e.endsWith("/") || /^[A-Za-z]:[\\/]/.test(e) || e.split("/").some((t) => t === ".." || t.length === 0) ? !1 : g.posix.normalize(e) === e;
526
+ }
527
+ function F(e) {
528
+ return e && typeof e == "object" && !Array.isArray(e) ? e : void 0;
529
+ }
530
+ function X(e) {
531
+ return e.replaceAll("~", "~0").replaceAll("/", "~1");
532
+ }
533
+ const eo = /* @__PURE__ */ new Set([
534
+ "name",
535
+ "description",
536
+ "boundaryPolicySource",
537
+ "layers",
538
+ "rules",
539
+ "allowedLayerDependencies",
540
+ "allowedDomainDependencies",
541
+ "ownership",
542
+ "health",
543
+ "metrics"
544
+ ]), oo = /* @__PURE__ */ new Set([
545
+ "projectOverrides",
546
+ "exceptions",
547
+ "eslint"
548
+ ]), to = /* @__PURE__ */ new Set([
549
+ "architecturalEntropyWeight",
550
+ "dependencyComplexityWeight",
551
+ "domainIntegrityWeight",
552
+ "ownershipCoverageWeight",
553
+ "documentationCompletenessWeight",
554
+ "layerIntegrityWeight"
555
+ ]), no = /* @__PURE__ */ new Set(["required", "metadataField"]), ro = /* @__PURE__ */ new Set(["statusThresholds"]), ao = /* @__PURE__ */ new Set([
556
+ "goodMinScore",
557
+ "warningMinScore"
558
+ ]), io = /* @__PURE__ */ new Set(["enabled", "severity", "options"]), co = /* @__PURE__ */ new Set(["error", "warning", "info"]);
559
+ class q extends Error {
560
+ constructor(o, t, r) {
561
+ super(o), this.code = t, this.filePath = r, this.name = "StandaloneGovernanceProfileLoadError";
562
+ }
563
+ }
564
+ class R extends Error {
565
+ constructor(o, t) {
566
+ super(
567
+ `Standalone governance profile validation failed for "${o}" with ${t.length} issue${t.length === 1 ? "" : "s"}.`
568
+ ), this.filePath = o, this.issues = t, this.name = "StandaloneGovernanceProfileValidationError";
569
+ }
570
+ }
571
+ function le(e) {
572
+ const o = g.resolve(e), t = lo(o), r = uo(t, o);
573
+ try {
574
+ const n = so(r);
575
+ return {
576
+ filePath: o,
577
+ profile: n,
578
+ normalizedProfile: ye(n)
579
+ };
580
+ } catch (n) {
581
+ throw n instanceof R ? new R(
582
+ o,
583
+ n.issues
584
+ ) : n;
585
+ }
586
+ }
587
+ function lt(e) {
588
+ return le(e).profile;
589
+ }
590
+ function so(e) {
591
+ const o = [], t = w(e);
592
+ t || K("<memory>", [
593
+ {
594
+ code: "governance.profile.invalid_root",
595
+ message: "Governance profile document root must be an object.",
596
+ path: "/"
597
+ }
598
+ ]);
599
+ const r = po(t);
600
+ r && o.push(r), x(t, eo, "/", o);
601
+ const n = k(
602
+ t.name,
603
+ "/name",
604
+ o,
605
+ "Profile name"
606
+ ), a = ko(
607
+ t.description,
608
+ "/description",
609
+ o,
610
+ "Profile description"
611
+ ), i = fo(
612
+ t.boundaryPolicySource,
613
+ "/boundaryPolicySource",
614
+ o
615
+ ), c = ho(t.layers, "/layers", o), d = go(t.rules, "/rules", o), s = mo(
616
+ t.allowedLayerDependencies,
617
+ "/allowedLayerDependencies",
618
+ c,
619
+ o
620
+ ), p = vo(
621
+ t.allowedDomainDependencies,
622
+ "/allowedDomainDependencies",
623
+ o
624
+ ), l = wo(t.ownership, "/ownership", o), h = yo(t.health, "/health", o), y = Io(t.metrics, "/metrics", o);
625
+ return (o.length > 0 || !n || !i || !c || !p || !l || !h || !y) && K("<memory>", o), {
626
+ name: n,
627
+ ...a ? { description: a } : {},
628
+ boundaryPolicySource: i,
629
+ layers: c,
630
+ ...d ? { rules: d } : {},
631
+ ...s ? { allowedLayerDependencies: s } : {},
632
+ allowedDomainDependencies: p,
633
+ ownership: l,
634
+ health: h,
635
+ metrics: y
636
+ };
637
+ }
638
+ function po(e) {
639
+ const o = Object.keys(e).some(
640
+ (n) => oo.has(n)
641
+ ), t = w(e.metrics), r = Object.keys(t ?? {}).some(
642
+ (n) => to.has(n)
643
+ );
644
+ if (!(!o && !r))
645
+ return {
646
+ code: "governance.profile.unsupported_nx_runtime_profile",
647
+ message: 'Nx Governance runtime profile files are not supported by the standalone CLI. Use a standalone profile with an explicit "name" field and without Nx-only override fields such as "projectOverrides", "exceptions", or legacy metric weight keys.',
648
+ path: "/"
649
+ };
650
+ }
651
+ function lo(e) {
652
+ try {
653
+ return G(e, "utf8");
654
+ } catch {
655
+ throw new q(
656
+ `Failed to read governance profile file "${e}".`,
657
+ "governance.profile_loader.read_failed",
658
+ e
659
+ );
660
+ }
661
+ }
662
+ function uo(e, o) {
663
+ try {
664
+ return JSON.parse(e);
665
+ } catch {
666
+ throw new q(
667
+ `Failed to parse JSON governance profile file "${o}".`,
668
+ "governance.profile_loader.parse_error",
669
+ o
670
+ );
671
+ }
672
+ }
673
+ function fo(e, o, t) {
674
+ if (e === void 0) {
675
+ t.push(
676
+ C(o, "boundaryPolicySource is required.")
677
+ );
678
+ return;
679
+ }
680
+ if (e !== "profile" && e !== "eslint") {
681
+ t.push(
682
+ ue(
683
+ o,
684
+ 'boundaryPolicySource must be "profile" or "eslint".'
685
+ )
686
+ );
687
+ return;
688
+ }
689
+ return e;
690
+ }
691
+ function ho(e, o, t) {
692
+ if (e === void 0) {
693
+ t.push(C(o, "layers is required."));
694
+ return;
695
+ }
696
+ if (!Array.isArray(e)) {
697
+ t.push(
698
+ u(o, "layers must be an array of strings.")
699
+ );
700
+ return;
701
+ }
702
+ e.length === 0 && t.push(
703
+ b(o, "layers must contain at least one layer.")
704
+ );
705
+ const r = [], n = /* @__PURE__ */ new Set();
706
+ return e.forEach((a, i) => {
707
+ const c = k(
708
+ a,
709
+ `${o}/${i}`,
710
+ t,
711
+ "Layer"
712
+ );
713
+ if (c) {
714
+ if (n.has(c)) {
715
+ t.push(
716
+ b(
717
+ `${o}/${i}`,
718
+ `Duplicate layer "${c}" is not allowed.`
719
+ )
720
+ );
721
+ return;
722
+ }
723
+ n.add(c), r.push(c);
724
+ }
725
+ }), r;
726
+ }
727
+ function go(e, o, t) {
728
+ if (e === void 0)
729
+ return;
730
+ const r = w(e);
731
+ if (!r) {
732
+ t.push(u(o, "rules must be an object."));
733
+ return;
734
+ }
735
+ const n = Object.keys(r).sort((a, i) => a.localeCompare(i)).flatMap((a) => {
736
+ const i = `${o}/${j(a)}`, c = k(
737
+ a,
738
+ i,
739
+ t,
740
+ "Rule id"
741
+ ), d = r[a], s = w(d);
742
+ if (!s)
743
+ return t.push(
744
+ u(i, "Rule config must be an object.")
745
+ ), [];
746
+ x(
747
+ s,
748
+ io,
749
+ i,
750
+ t
751
+ );
752
+ const p = {};
753
+ return s.enabled !== void 0 && (typeof s.enabled != "boolean" ? t.push(
754
+ u(
755
+ `${i}/enabled`,
756
+ "Rule enabled must be a boolean."
757
+ )
758
+ ) : p.enabled = s.enabled), s.severity !== void 0 && (typeof s.severity != "string" || !co.has(s.severity) ? t.push(
759
+ ue(
760
+ `${i}/severity`,
761
+ 'Rule severity must be "error", "warning", or "info".'
762
+ )
763
+ ) : p.severity = s.severity), s.options !== void 0 && (p.options = s.options), c ? [[c, p]] : [];
764
+ });
765
+ return n.length > 0 ? Object.fromEntries(n) : {};
766
+ }
767
+ function mo(e, o, t, r) {
768
+ if (e === void 0)
769
+ return;
770
+ const n = w(e);
771
+ if (!n) {
772
+ r.push(
773
+ u(o, "allowedLayerDependencies must be an object.")
774
+ );
775
+ return;
776
+ }
777
+ if (!t)
778
+ return;
779
+ const a = new Set(t);
780
+ Object.keys(n).forEach((d) => {
781
+ a.has(d) || r.push(
782
+ b(
783
+ `${o}/${j(d)}`,
784
+ `allowedLayerDependencies source layer "${d}" is not declared in layers.`
785
+ )
786
+ );
787
+ });
788
+ const c = {};
789
+ return t.forEach((d) => {
790
+ if (!Object.prototype.hasOwnProperty.call(n, d))
791
+ return;
792
+ const s = `${o}/${j(d)}`, p = n[d];
793
+ if (!Array.isArray(p)) {
794
+ r.push(
795
+ u(
796
+ s,
797
+ `allowedLayerDependencies target list for "${d}" must be an array of strings.`
798
+ )
799
+ );
800
+ return;
801
+ }
802
+ const l = /* @__PURE__ */ new Set(), h = [];
803
+ p.forEach((y, W) => {
804
+ const $ = `${s}/${W}`, f = k(
805
+ y,
806
+ $,
807
+ r,
808
+ "Layer dependency target"
809
+ );
810
+ if (f) {
811
+ if (!a.has(f)) {
812
+ r.push(
813
+ b(
814
+ $,
815
+ `allowedLayerDependencies target layer "${f}" for source layer "${d}" is not declared in layers.`
816
+ )
817
+ );
818
+ return;
819
+ }
820
+ l.has(f) || (l.add(f), h.push(f));
821
+ }
822
+ }), c[d] = t.filter(
823
+ (y) => h.includes(y)
824
+ );
825
+ }), c;
826
+ }
827
+ function vo(e, o, t) {
828
+ if (e === void 0) {
829
+ t.push(
830
+ C(o, "allowedDomainDependencies is required.")
831
+ );
832
+ return;
833
+ }
834
+ const r = w(e);
835
+ if (!r) {
836
+ t.push(
837
+ u(o, "allowedDomainDependencies must be an object.")
838
+ );
839
+ return;
840
+ }
841
+ const n = Object.keys(r).sort((a, i) => a.localeCompare(i)).map((a) => {
842
+ const i = `${o}/${j(a)}`, c = k(
843
+ a,
844
+ i,
845
+ t,
846
+ "Domain key"
847
+ ), d = r[a];
848
+ if (!Array.isArray(d))
849
+ return t.push(
850
+ u(
851
+ i,
852
+ `allowedDomainDependencies entry for "${a}" must be an array of strings.`
853
+ )
854
+ ), null;
855
+ const s = [
856
+ ...new Set(
857
+ d.map(
858
+ (p, l) => k(
859
+ p,
860
+ `${i}/${l}`,
861
+ t,
862
+ "Allowed domain dependency"
863
+ )
864
+ ).filter((p) => !!p)
865
+ )
866
+ ].sort((p, l) => p.localeCompare(l));
867
+ return c ? [c, s] : null;
868
+ }).filter((a) => a !== null);
869
+ return Object.fromEntries(n);
870
+ }
871
+ function wo(e, o, t) {
872
+ if (e === void 0) {
873
+ t.push(C(o, "ownership is required."));
874
+ return;
875
+ }
876
+ const r = w(e);
877
+ if (!r) {
878
+ t.push(u(o, "ownership must be an object."));
879
+ return;
880
+ }
881
+ x(r, no, o, t);
882
+ const n = r.required;
883
+ typeof n != "boolean" && t.push(
884
+ u(
885
+ `${o}/required`,
886
+ "ownership.required must be a boolean."
887
+ )
888
+ );
889
+ const a = k(
890
+ r.metadataField,
891
+ `${o}/metadataField`,
892
+ t,
893
+ "ownership.metadataField"
894
+ );
895
+ if (!(typeof n != "boolean" || !a))
896
+ return {
897
+ required: n,
898
+ metadataField: a
899
+ };
900
+ }
901
+ function yo(e, o, t) {
902
+ if (e === void 0) {
903
+ t.push(C(o, "health is required."));
904
+ return;
905
+ }
906
+ const r = w(e);
907
+ if (!r) {
908
+ t.push(u(o, "health must be an object."));
909
+ return;
910
+ }
911
+ x(r, ro, o, t);
912
+ const n = w(r.statusThresholds), a = `${o}/statusThresholds`;
913
+ if (!n) {
914
+ t.push(
915
+ u(
916
+ a,
917
+ "health.statusThresholds must be an object."
918
+ )
919
+ );
920
+ return;
921
+ }
922
+ x(
923
+ n,
924
+ ao,
925
+ a,
926
+ t
927
+ );
928
+ const i = U(
929
+ n.goodMinScore,
930
+ `${a}/goodMinScore`,
931
+ t,
932
+ "goodMinScore"
933
+ ), c = U(
934
+ n.warningMinScore,
935
+ `${a}/warningMinScore`,
936
+ t,
937
+ "warningMinScore"
938
+ );
939
+ if (i !== void 0 && c !== void 0 && c > i && t.push(
940
+ b(
941
+ a,
942
+ "health.statusThresholds.warningMinScore must be less than or equal to goodMinScore."
943
+ )
944
+ ), !(i === void 0 || c === void 0))
945
+ return {
946
+ statusThresholds: {
947
+ goodMinScore: i,
948
+ warningMinScore: c
949
+ }
950
+ };
951
+ }
952
+ function Io(e, o, t) {
953
+ if (e === void 0) {
954
+ t.push(C(o, "metrics is required."));
955
+ return;
956
+ }
957
+ const r = w(e);
958
+ if (!r) {
959
+ t.push(u(o, "metrics must be an object."));
960
+ return;
961
+ }
962
+ const n = Object.keys(r).sort((a, i) => a.localeCompare(i)).map((a) => {
963
+ const i = `${o}/${j(a)}`, c = k(
964
+ a,
965
+ i,
966
+ t,
967
+ "Metric id"
968
+ ), d = U(
969
+ r[a],
970
+ i,
971
+ t,
972
+ `Metric "${a}"`
973
+ );
974
+ return c && d !== void 0 ? [c, d] : null;
975
+ }).filter((a) => a !== null);
976
+ return Object.fromEntries(n);
977
+ }
978
+ function k(e, o, t, r) {
979
+ if (typeof e != "string") {
980
+ e === void 0 ? t.push(C(o, `${r} is required.`)) : t.push(u(o, `${r} must be a string.`));
981
+ return;
982
+ }
983
+ const n = e.trim();
984
+ if (n.length === 0) {
985
+ t.push(b(o, `${r} must be non-empty.`));
986
+ return;
987
+ }
988
+ return n;
989
+ }
990
+ function ko(e, o, t, r) {
991
+ if (e === void 0)
992
+ return;
993
+ if (typeof e != "string") {
994
+ t.push(u(o, `${r} must be a string.`));
995
+ return;
996
+ }
997
+ const n = e.trim();
998
+ if (n.length === 0) {
999
+ t.push(b(o, `${r} must be non-empty.`));
1000
+ return;
1001
+ }
1002
+ return n;
1003
+ }
1004
+ function U(e, o, t, r) {
1005
+ if (typeof e != "number" || !Number.isFinite(e)) {
1006
+ e === void 0 ? t.push(C(o, `${r} is required.`)) : t.push(
1007
+ u(o, `${r} must be a finite number.`)
1008
+ );
1009
+ return;
1010
+ }
1011
+ return e;
1012
+ }
1013
+ function x(e, o, t, r) {
1014
+ Object.keys(e).forEach((n) => {
1015
+ o.has(n) || r.push({
1016
+ code: "governance.profile.unknown_field",
1017
+ message: `Unknown field "${n}" is not allowed.`,
1018
+ path: t === "/" ? `/${j(n)}` : `${t}/${j(n)}`
1019
+ });
1020
+ });
1021
+ }
1022
+ function C(e, o) {
1023
+ return {
1024
+ code: "governance.profile.missing_required_field",
1025
+ message: o,
1026
+ path: e
1027
+ };
1028
+ }
1029
+ function u(e, o) {
1030
+ return {
1031
+ code: "governance.profile.invalid_field_type",
1032
+ message: o,
1033
+ path: e
1034
+ };
1035
+ }
1036
+ function b(e, o) {
1037
+ return {
1038
+ code: "governance.profile.invalid_value",
1039
+ message: o,
1040
+ path: e
1041
+ };
1042
+ }
1043
+ function ue(e, o) {
1044
+ return {
1045
+ code: "governance.profile.invalid_enum_value",
1046
+ message: o,
1047
+ path: e
1048
+ };
1049
+ }
1050
+ function K(e, o) {
1051
+ throw new R(e, o);
1052
+ }
1053
+ function w(e) {
1054
+ return e && typeof e == "object" && !Array.isArray(e) ? e : void 0;
1055
+ }
1056
+ function j(e) {
1057
+ return e.replaceAll("~", "~0").replaceAll("/", "~1");
1058
+ }
1059
+ const Co = {
1060
+ summary: {
1061
+ declaredCount: 0,
1062
+ matchedCount: 0,
1063
+ suppressedPolicyViolationCount: 0,
1064
+ suppressedConformanceFindingCount: 0,
1065
+ unusedExceptionCount: 0,
1066
+ activeExceptionCount: 0,
1067
+ staleExceptionCount: 0,
1068
+ expiredExceptionCount: 0,
1069
+ reactivatedPolicyViolationCount: 0,
1070
+ reactivatedConformanceFindingCount: 0
1071
+ },
1072
+ used: [],
1073
+ unused: [],
1074
+ suppressedFindings: [],
1075
+ reactivatedFindings: []
1076
+ }, $o = {
1077
+ id: "governance-cli:manual-workspace",
1078
+ loadWorkspace(e) {
1079
+ return Oe(e);
1080
+ }
1081
+ };
1082
+ function Ao(e) {
1083
+ const o = jo(e), t = le(e.profilePath).profile, r = bo({
1084
+ workspace: o,
1085
+ profile: t
1086
+ });
1087
+ return {
1088
+ command: "check",
1089
+ success: !r.violations.some(
1090
+ (n) => n.severity === "error"
1091
+ ),
1092
+ assessment: r
1093
+ };
1094
+ }
1095
+ function bo(e) {
1096
+ const o = Ie(e.workspace, e.profile), t = ke(o, {
1097
+ createdAt: "1970-01-01T00:00:00.000Z"
1098
+ }), r = Ce({
1099
+ workspace: e.workspace,
1100
+ signals: t
1101
+ }), n = $e(
1102
+ r,
1103
+ e.profile.metrics,
1104
+ e.profile.health.statusThresholds,
1105
+ {
1106
+ topIssues: Ae(t)
1107
+ }
1108
+ );
1109
+ return be({
1110
+ workspace: e.workspace,
1111
+ profile: e.profile.name,
1112
+ warnings: [],
1113
+ exceptions: Co,
1114
+ violations: o,
1115
+ signals: t,
1116
+ measurements: r,
1117
+ health: n,
1118
+ recommendations: je(o, r)
1119
+ });
1120
+ }
1121
+ function jo(e) {
1122
+ return "workspaceAdapter" in e && e.workspaceAdapter ? H(
1123
+ e.workspaceAdapter.loadWorkspace(e.workspaceAdapterInput)
1124
+ ) : H(
1125
+ $o.loadWorkspace(e.workspacePath)
1126
+ );
1127
+ }
1128
+ const So = 10;
1129
+ function fe(e) {
1130
+ const o = [];
1131
+ o.push(`Nx Governance - ${e.profile}`), o.push(""), o.push(
1132
+ `Health Score: ${e.health.score} (${_o(
1133
+ e.health.status
1134
+ )}, ${e.health.grade})`
1135
+ ), o.push(`Projects: ${e.workspace.projects.length}`), o.push(`Dependencies: ${e.workspace.dependencies.length}`), o.push(`Violations: ${e.violations.length}`), o.push(""), o.push("Signal Sources:");
1136
+ for (const t of e.signalBreakdown.bySource)
1137
+ o.push(`- ${t.source}: ${t.count}`);
1138
+ o.push(""), o.push("Signal Types:");
1139
+ for (const t of e.signalBreakdown.byType)
1140
+ o.push(`- ${t.type}: ${t.count}`);
1141
+ o.push(""), o.push("Signal Severity:");
1142
+ for (const t of e.signalBreakdown.bySeverity)
1143
+ o.push(`- ${t.severity}: ${t.count}`);
1144
+ if (e.warnings.length > 0) {
1145
+ o.push(""), o.push("Warnings:");
1146
+ for (const t of e.warnings)
1147
+ o.push(`- ${t}`);
1148
+ }
1149
+ if (o.push(""), o.push("Exceptions:"), o.push(`- declared: ${e.exceptions.summary.declaredCount}`), o.push(`- matched: ${e.exceptions.summary.matchedCount}`), o.push(`- unused: ${e.exceptions.summary.unusedExceptionCount}`), o.push(`- active: ${e.exceptions.summary.activeExceptionCount}`), o.push(`- stale: ${e.exceptions.summary.staleExceptionCount}`), o.push(
1150
+ `- expired: ${e.exceptions.summary.expiredExceptionCount}`
1151
+ ), o.push(
1152
+ `- suppressed policy findings: ${e.exceptions.summary.suppressedPolicyViolationCount}`
1153
+ ), o.push(
1154
+ `- suppressed conformance findings: ${e.exceptions.summary.suppressedConformanceFindingCount}`
1155
+ ), o.push(
1156
+ `- reactivated policy findings: ${e.exceptions.summary.reactivatedPolicyViolationCount}`
1157
+ ), o.push(
1158
+ `- reactivated conformance findings: ${e.exceptions.summary.reactivatedConformanceFindingCount}`
1159
+ ), e.exceptions.suppressedFindings.length > 0) {
1160
+ o.push("Suppressed Findings:");
1161
+ for (const t of e.exceptions.suppressedFindings) {
1162
+ const r = t.ruleId ? ` :: ${t.ruleId}` : "", n = [
1163
+ t.projectId,
1164
+ t.targetProjectId,
1165
+ t.relatedProjectIds.length > 0 ? `related=${t.relatedProjectIds.join(",")}` : void 0
1166
+ ].filter((i) => !!i).join(" -> "), a = n ? ` :: scope=${n}` : "";
1167
+ o.push(
1168
+ `- ${t.exceptionId} :: ${t.status} :: ${t.source}/${t.kind} :: [${t.severity}]${r}${a} :: ${t.message}`
1169
+ );
1170
+ }
1171
+ }
1172
+ if (e.exceptions.reactivatedFindings.length > 0) {
1173
+ o.push("Reactivated Findings:");
1174
+ for (const t of e.exceptions.reactivatedFindings) {
1175
+ const r = t.ruleId ? ` :: ${t.ruleId}` : "", n = [
1176
+ t.projectId,
1177
+ t.targetProjectId,
1178
+ t.relatedProjectIds.length > 0 ? `related=${t.relatedProjectIds.join(",")}` : void 0
1179
+ ].filter((i) => !!i).join(" -> "), a = n ? ` :: scope=${n}` : "";
1180
+ o.push(
1181
+ `- ${t.exceptionId} :: ${t.status} :: ${t.source}/${t.kind} :: [${t.severity}]${r}${a} :: ${t.message}`
1182
+ );
1183
+ }
1184
+ }
1185
+ o.push(""), o.push("Metrics:");
1186
+ for (const t of e.measurements)
1187
+ o.push(`- ${t.name}: ${t.score}/100`);
1188
+ if (e.metricBreakdown.families.length > 0) {
1189
+ o.push(""), o.push("Metric Families:");
1190
+ for (const t of e.metricBreakdown.families)
1191
+ o.push(`- ${t.family}: ${t.score}/100`), o.push(
1192
+ ` measurements: ${t.measurements.map((r) => `${r.name} (${r.score})`).join(", ")}`
1193
+ );
1194
+ }
1195
+ if (e.health.metricHotspots.length > 0) {
1196
+ o.push(""), o.push("Metric Hotspots:");
1197
+ for (const t of e.health.metricHotspots)
1198
+ o.push(`- ${t.name}: ${t.score}/100`);
1199
+ }
1200
+ if (e.health.projectHotspots.length > 0) {
1201
+ o.push(""), o.push("Project Hotspots:");
1202
+ for (const t of e.health.projectHotspots)
1203
+ o.push(
1204
+ `- ${t.project}: ${t.count} :: types=${t.dominantIssueTypes.join(",")}`
1205
+ );
1206
+ }
1207
+ if (o.push(""), o.push("Explainability:"), o.push(`- summary: ${e.health.explainability.summary}`), o.push(
1208
+ `- status reason: ${e.health.explainability.statusReason}`
1209
+ ), e.health.explainability.weakestMetrics.length > 0 && o.push(
1210
+ `- weakest metrics: ${e.health.explainability.weakestMetrics.map((t) => `${t.name} (${t.score})`).join(", ")}`
1211
+ ), e.health.explainability.dominantIssues.length > 0 && o.push(
1212
+ `- dominant issues: ${e.health.explainability.dominantIssues.map((t) => `${t.type} x${t.count}`).join(", ")}`
1213
+ ), e.topIssues.length > 0) {
1214
+ o.push(""), o.push("Top Issues:");
1215
+ for (const t of e.topIssues.slice(0, So)) {
1216
+ const r = t.ruleId ? ` :: ${t.ruleId}` : "", n = t.projects.length > 0 ? ` :: projects=${t.projects.join(",")}` : "";
1217
+ o.push(
1218
+ `- [${t.severity}] ${t.type} (${t.source}) x${t.count}${r}${n} :: ${t.message}`
1219
+ );
1220
+ }
1221
+ }
1222
+ if (e.recommendations.length > 0) {
1223
+ o.push(""), o.push("Recommendations:");
1224
+ for (const t of e.recommendations)
1225
+ o.push(
1226
+ `- (${t.priority}) ${t.title} - ${t.reason}`
1227
+ );
1228
+ }
1229
+ return o.join(`
1230
+ `);
1231
+ }
1232
+ function _o(e) {
1233
+ return `${e.charAt(0).toUpperCase()}${e.slice(1)}`;
1234
+ }
1235
+ function Eo(e) {
1236
+ return JSON.stringify(e, null, 2);
1237
+ }
1238
+ function Po(e, o) {
1239
+ switch (o) {
1240
+ case "json":
1241
+ return Ro(e);
1242
+ case "markdown":
1243
+ return Go(e);
1244
+ case "table":
1245
+ case "text":
1246
+ return xo(e);
1247
+ }
1248
+ }
1249
+ function Ro(e) {
1250
+ return JSON.stringify(
1251
+ {
1252
+ command: e.command,
1253
+ success: e.success,
1254
+ assessment: JSON.parse(Eo(e.assessment))
1255
+ },
1256
+ null,
1257
+ 2
1258
+ );
1259
+ }
1260
+ function xo(e) {
1261
+ const o = [], { assessment: t } = e, r = fe(t).split(`
1262
+ `);
1263
+ return r[0]?.startsWith("Nx Governance - ") && (r[0] = `Governance Check - ${t.profile}`), o.push("agov check"), o.push(""), o.push(
1264
+ ...Lo(
1265
+ ["Field", "Value"],
1266
+ [
1267
+ ["success", e.success ? "true" : "false"],
1268
+ ["workspace", t.workspace.name],
1269
+ ["profile", t.profile]
1270
+ ]
1271
+ )
1272
+ ), o.push(""), o.push(...r), o.join(`
1273
+ `);
1274
+ }
1275
+ function Go(e) {
1276
+ const { assessment: o } = e, t = [], r = fe(o).split(`
1277
+ `);
1278
+ r[0]?.startsWith("Nx Governance - ") && (r[0] = `Governance Check - ${o.profile}`), t.push("# agov check"), t.push(""), t.push("| Field | Value |"), t.push("| --- | --- |"), t.push(`| success | ${e.success ? "true" : "false"} |`), t.push(
1279
+ `| workspace | ${Q(o.workspace.name)} |`
1280
+ ), t.push(`| profile | ${Q(o.profile)} |`), t.push("");
1281
+ for (const n of r) {
1282
+ if (n.length === 0) {
1283
+ t.push("");
1284
+ continue;
1285
+ }
1286
+ if (!n.startsWith("- ")) {
1287
+ t.push(`## ${n}`);
1288
+ continue;
1289
+ }
1290
+ t.push(n);
1291
+ }
1292
+ return t.join(`
1293
+ `);
1294
+ }
1295
+ function Lo(e, o) {
1296
+ const t = Math.max(
1297
+ e[0].length,
1298
+ ...o.map((n) => n[0]?.length ?? 0)
1299
+ ), r = Math.max(
1300
+ e[1].length,
1301
+ ...o.map((n) => n[1]?.length ?? 0)
1302
+ );
1303
+ return [
1304
+ `${V(e[0], t)} ${V(e[1], r)}`,
1305
+ `${"-".repeat(t)} ${"-".repeat(r)}`,
1306
+ ...o.map(
1307
+ (n) => `${V(n[0] ?? "", t)} ${V(
1308
+ n[1] ?? "",
1309
+ r
1310
+ )}`
1311
+ )
1312
+ ];
1313
+ }
1314
+ function V(e, o) {
1315
+ return e.padEnd(o, " ");
1316
+ }
1317
+ function Q(e) {
1318
+ return e.replaceAll("|", "\\|");
1319
+ }
1320
+ const Fo = ["agov.config.json", "governance.config.json"], Wo = [
1321
+ "tools/governance/profiles/default.json",
1322
+ "tools/governance/profile.json",
1323
+ "governance.profile.json",
1324
+ "agov.profile.json"
1325
+ ], Vo = [
1326
+ "governance.workspace.json",
1327
+ "agov.workspace.json",
1328
+ "tools/governance/workspace.json"
1329
+ ], O = 0, Oo = 1, ee = 2, M = 3, Do = {
1330
+ runAgovCheck: Ao
1331
+ };
1332
+ class m extends Error {
1333
+ constructor(o, t) {
1334
+ super(o), this.code = t, this.name = "AgovCliUsageError";
1335
+ }
1336
+ }
1337
+ class he extends Error {
1338
+ constructor(o, t, r) {
1339
+ super(o), this.code = t, this.filePath = r, this.name = "AgovCliOutputError";
1340
+ }
1341
+ }
1342
+ class E extends Error {
1343
+ constructor(o, t, r) {
1344
+ super(o), this.code = t, this.details = r, this.name = "AgovCliRuntimeError";
1345
+ }
1346
+ }
1347
+ async function ut(e, o = tt(), t = Do, r = nt()) {
1348
+ try {
1349
+ const n = No(e);
1350
+ if (n.kind === "help")
1351
+ return o.stdout(et()), O;
1352
+ if (n.kind === "version")
1353
+ return o.stdout(r.packageVersion()), O;
1354
+ if (n.options.showHelp)
1355
+ return o.stdout(ot()), O;
1356
+ const a = Zo(n.options, r), i = await Mo(
1357
+ a,
1358
+ r
1359
+ ), c = await Promise.resolve(t.runAgovCheck(i)), d = Po(c, a.format);
1360
+ return a.outputPath ? rt(a.outputPath, d) : o.stdout(d), c.success ? O : Oo;
1361
+ } catch (n) {
1362
+ return n instanceof m ? (o.stderr(
1363
+ _({
1364
+ code: n.code,
1365
+ message: n.message
1366
+ })
1367
+ ), ee) : n instanceof he ? (o.stderr(
1368
+ _({
1369
+ code: n.code,
1370
+ message: n.message,
1371
+ details: {
1372
+ filePath: n.filePath
1373
+ }
1374
+ })
1375
+ ), ee) : n instanceof E ? (o.stderr(
1376
+ _({
1377
+ code: n.code,
1378
+ message: n.message,
1379
+ ...n.details ? { details: n.details } : {}
1380
+ })
1381
+ ), M) : n instanceof L || n instanceof I || n instanceof q || n instanceof R ? (o.stderr(Qo(n)), M) : (o.stderr(
1382
+ _({
1383
+ code: "agov.cli.unhandled_error",
1384
+ message: n instanceof Error ? n.message : "Unknown agov CLI error."
1385
+ })
1386
+ ), M);
1387
+ }
1388
+ }
1389
+ function No(e) {
1390
+ if (e.length === 0)
1391
+ return { kind: "help" };
1392
+ const [o, ...t] = e;
1393
+ if (o === "--help" || o === "-h" || o === "help")
1394
+ return { kind: "help" };
1395
+ if (o === "--version" || o === "-v" || o === "version")
1396
+ return { kind: "version" };
1397
+ if (o !== "check")
1398
+ throw new m(
1399
+ `Unsupported agov command "${o}". Supported commands are "check", "--help", and "--version".`,
1400
+ "agov.cli.unknown_command"
1401
+ );
1402
+ return {
1403
+ kind: "check",
1404
+ options: To(t)
1405
+ };
1406
+ }
1407
+ function To(e) {
1408
+ let o, t, r, n, a, i, c, d = !1;
1409
+ for (let s = 0; s < e.length; s += 1) {
1410
+ const p = e[s];
1411
+ if (p === "--help" || p === "-h") {
1412
+ d = !0;
1413
+ continue;
1414
+ }
1415
+ if (p === "--config") {
1416
+ o = A(e, s, "--config"), s += 1;
1417
+ continue;
1418
+ }
1419
+ if (p === "--profile") {
1420
+ t = A(e, s, "--profile"), s += 1;
1421
+ continue;
1422
+ }
1423
+ if (p === "--workspace") {
1424
+ r = A(e, s, "--workspace"), s += 1;
1425
+ continue;
1426
+ }
1427
+ if (p === "--adapter") {
1428
+ n = A(e, s, "--adapter"), s += 1;
1429
+ continue;
1430
+ }
1431
+ if (p === "--root") {
1432
+ a = A(e, s, "--root"), s += 1;
1433
+ continue;
1434
+ }
1435
+ if (p === "--format") {
1436
+ const l = A(e, s, "--format");
1437
+ if (s += 1, l !== "text" && l !== "json" && l !== "markdown" && l !== "table")
1438
+ throw new m(
1439
+ 'Unsupported agov check format. Supported formats are "table", "markdown", "text", and "json".',
1440
+ "agov.cli.unsupported_format"
1441
+ );
1442
+ i = l;
1443
+ continue;
1444
+ }
1445
+ if (p === "--output") {
1446
+ c = A(e, s, "--output"), s += 1;
1447
+ continue;
1448
+ }
1449
+ throw new m(
1450
+ `Unknown agov option "${p}".`,
1451
+ "agov.cli.unknown_option"
1452
+ );
1453
+ }
1454
+ return {
1455
+ command: "check",
1456
+ configPath: o,
1457
+ profilePath: t,
1458
+ workspacePath: r,
1459
+ adapterPackage: n,
1460
+ rootPath: a,
1461
+ format: i,
1462
+ outputPath: c,
1463
+ showHelp: d
1464
+ };
1465
+ }
1466
+ function A(e, o, t) {
1467
+ const r = e[o + 1];
1468
+ if (!r || r.startsWith("--"))
1469
+ throw new m(
1470
+ `Missing required value for "${t}".`,
1471
+ "agov.cli.missing_option_value"
1472
+ );
1473
+ return r;
1474
+ }
1475
+ function Zo(e, o) {
1476
+ const t = g.resolve(o.cwd()), r = e.rootPath ? g.resolve(t, e.rootPath) : void 0, n = Uo(
1477
+ t,
1478
+ r,
1479
+ e.configPath
1480
+ ), a = n ? zo(n) : {}, i = n ? g.dirname(n) : t;
1481
+ if ((a.adapter || N(a.adapters).length > 0) && a.workspace && !e.adapterPackage && !e.workspacePath)
1482
+ throw new m(
1483
+ "Config file cannot define both adapter-mode and workspace-mode inputs for agov check. Pass one mode only, or override explicitly with CLI flags.",
1484
+ "agov.cli.invalid_config"
1485
+ );
1486
+ if (e.workspacePath && e.adapterPackage)
1487
+ throw new m(
1488
+ 'agov check does not allow explicit "--workspace" and "--adapter" together. Use canonical workspace mode or adapter mode, not both.',
1489
+ "agov.cli.ambiguous_workspace_and_adapter"
1490
+ );
1491
+ const c = r ?? Y(a.root, i) ?? t, d = J(e.workspacePath, t), s = Y(
1492
+ a.workspace,
1493
+ i
1494
+ ), p = z(
1495
+ c,
1496
+ Vo
1497
+ ), l = d ?? s ?? p, h = J(e.profilePath, t) ?? Y(a.profile, i) ?? z(c, Wo), y = e.adapterPackage ?? me(a.adapter), W = Bo(c, a), $ = qo(e.format, a.format), f = J(e.outputPath, t);
1498
+ if (!h)
1499
+ throw new m(
1500
+ 'Could not resolve a governance profile. Pass "--profile <path>", set "profile" in agov.config.json or governance.config.json, or add a conventional profile file such as "governance.profile.json".',
1501
+ "agov.cli.missing_profile"
1502
+ );
1503
+ if (d || s)
1504
+ return {
1505
+ command: "check",
1506
+ rootPath: c,
1507
+ profilePath: h,
1508
+ workspacePath: l,
1509
+ format: $,
1510
+ ...f ? { outputPath: f } : {},
1511
+ ...n ? { configPath: n } : {},
1512
+ mode: "workspace"
1513
+ };
1514
+ if (y)
1515
+ return {
1516
+ command: "check",
1517
+ rootPath: c,
1518
+ profilePath: h,
1519
+ adapterPackage: y,
1520
+ format: $,
1521
+ ...f ? { outputPath: f } : {},
1522
+ ...n ? { configPath: n } : {},
1523
+ mode: "adapter"
1524
+ };
1525
+ if (W.length > 0)
1526
+ return {
1527
+ command: "check",
1528
+ rootPath: c,
1529
+ profilePath: h,
1530
+ adapterCandidates: W,
1531
+ format: $,
1532
+ ...f ? { outputPath: f } : {},
1533
+ ...n ? { configPath: n } : {},
1534
+ mode: "adapter-discovery"
1535
+ };
1536
+ if (l)
1537
+ return {
1538
+ command: "check",
1539
+ rootPath: c,
1540
+ profilePath: h,
1541
+ workspacePath: l,
1542
+ format: $,
1543
+ ...f ? { outputPath: f } : {},
1544
+ ...n ? { configPath: n } : {},
1545
+ mode: "workspace"
1546
+ };
1547
+ throw new m(
1548
+ 'Could not resolve Governance workspace input. Pass "--workspace <path>" for canonical workspace mode, pass "--adapter <package> --root <path>" for explicit adapter mode, or configure generic adapter candidates.',
1549
+ "agov.cli.missing_workspace_or_adapter"
1550
+ );
1551
+ }
1552
+ async function Mo(e, o) {
1553
+ if (e.mode === "workspace") {
1554
+ if (!e.workspacePath)
1555
+ throw new E(
1556
+ "Resolved workspace mode without a workspace path.",
1557
+ "agov.cli.unhandled_error"
1558
+ );
1559
+ return {
1560
+ profilePath: e.profilePath,
1561
+ workspacePath: e.workspacePath
1562
+ };
1563
+ }
1564
+ if (!e.adapterPackage) {
1565
+ if (e.mode !== "adapter-discovery" || !e.adapterCandidates)
1566
+ throw new E(
1567
+ "Resolved adapter mode without an adapter package.",
1568
+ "agov.cli.unhandled_error"
1569
+ );
1570
+ const r = await Yo(
1571
+ e.adapterCandidates,
1572
+ e.rootPath,
1573
+ o
1574
+ );
1575
+ return {
1576
+ profilePath: e.profilePath,
1577
+ workspaceAdapter: r.adapter,
1578
+ workspaceAdapterInput: e.rootPath
1579
+ };
1580
+ }
1581
+ const t = await Jo(
1582
+ e.adapterPackage,
1583
+ e.rootPath,
1584
+ o
1585
+ );
1586
+ return {
1587
+ profilePath: e.profilePath,
1588
+ workspaceAdapter: t,
1589
+ workspaceAdapterInput: e.rootPath
1590
+ };
1591
+ }
1592
+ async function Jo(e, o, t) {
1593
+ let r;
1594
+ try {
1595
+ r = await t.moduleLoader(e);
1596
+ } catch {
1597
+ throw new E(
1598
+ Ho(e),
1599
+ "agov.cli.adapter_not_found",
1600
+ {
1601
+ adapter: e,
1602
+ rootPath: o
1603
+ }
1604
+ );
1605
+ }
1606
+ const n = ge(r);
1607
+ if (!n)
1608
+ throw new E(
1609
+ `Package "${e}" was loaded, but it does not expose a compatible Governance workspace adapter.`,
1610
+ "agov.cli.adapter_contract_mismatch",
1611
+ {
1612
+ adapter: e,
1613
+ rootPath: o
1614
+ }
1615
+ );
1616
+ return n;
1617
+ }
1618
+ async function Yo(e, o, t) {
1619
+ const r = [];
1620
+ let n;
1621
+ for (const a of e) {
1622
+ let i;
1623
+ try {
1624
+ i = await t.moduleLoader(a);
1625
+ } catch {
1626
+ r.push({ packageName: a, status: "load-failed" });
1627
+ continue;
1628
+ }
1629
+ const c = ge(i);
1630
+ if (!c) {
1631
+ r.push({ packageName: a, status: "contract-mismatch" });
1632
+ continue;
1633
+ }
1634
+ if (typeof c.probe != "function") {
1635
+ r.push({ packageName: a, status: "missing-probe" });
1636
+ continue;
1637
+ }
1638
+ const d = c.probe(o);
1639
+ if (r.push({
1640
+ packageName: a,
1641
+ status: d.supported ? "supported" : "unsupported",
1642
+ confidence: d.confidence ?? "none",
1643
+ reasons: d.reasons ?? []
1644
+ }), !d.supported)
1645
+ continue;
1646
+ const s = Xo(d.confidence);
1647
+ (!n || s > n.rank) && (n = {
1648
+ adapter: c,
1649
+ packageName: a,
1650
+ probe: d,
1651
+ rank: s
1652
+ });
1653
+ }
1654
+ if (!n)
1655
+ throw new E(
1656
+ "Could not find a supported Governance adapter from the discovered candidate packages.",
1657
+ "agov.cli.no_supported_adapter",
1658
+ {
1659
+ rootPath: o,
1660
+ attemptedPackages: e,
1661
+ attempts: r
1662
+ }
1663
+ );
1664
+ return n;
1665
+ }
1666
+ function ge(e) {
1667
+ const o = typeof e == "object" && e !== null ? e : {};
1668
+ for (const r of [
1669
+ o.default,
1670
+ o.governanceWorkspaceAdapter,
1671
+ o.adapter
1672
+ ])
1673
+ if (oe(r))
1674
+ return r;
1675
+ const t = o.createGovernanceWorkspaceAdapter;
1676
+ if (typeof t == "function") {
1677
+ const r = t();
1678
+ if (oe(r))
1679
+ return r;
1680
+ }
1681
+ }
1682
+ function oe(e) {
1683
+ return typeof e == "object" && e !== null && typeof e.id == "string" && typeof e.loadWorkspace == "function";
1684
+ }
1685
+ function Ho(e) {
1686
+ const o = [`Could not load Governance adapter package "${e}".`];
1687
+ return o.push(
1688
+ `Install "${e}" in the consuming workspace to use adapter mode.`
1689
+ ), o.push(
1690
+ `You can also pass "--adapter ${e}" explicitly, or use "--workspace <path>" with a canonical Governance workspace document.`
1691
+ ), o.join(" ");
1692
+ }
1693
+ function Xo(e) {
1694
+ switch (e) {
1695
+ case "high":
1696
+ return 3;
1697
+ case "medium":
1698
+ return 2;
1699
+ case "low":
1700
+ return 1;
1701
+ default:
1702
+ return 0;
1703
+ }
1704
+ }
1705
+ function Uo(e, o, t) {
1706
+ if (t)
1707
+ return g.resolve(e, t);
1708
+ const r = o ? [o, e] : [e];
1709
+ for (const n of r) {
1710
+ const a = z(
1711
+ n,
1712
+ Fo
1713
+ );
1714
+ if (a)
1715
+ return a;
1716
+ }
1717
+ }
1718
+ function zo(e) {
1719
+ let o;
1720
+ try {
1721
+ o = G(e, "utf8");
1722
+ } catch {
1723
+ throw new m(
1724
+ `Failed to read agov config file "${e}".`,
1725
+ "agov.cli.invalid_config"
1726
+ );
1727
+ }
1728
+ let t;
1729
+ try {
1730
+ t = JSON.parse(o);
1731
+ } catch {
1732
+ throw new m(
1733
+ `Failed to parse agov config file "${e}" as JSON.`,
1734
+ "agov.cli.invalid_json"
1735
+ );
1736
+ }
1737
+ if (typeof t != "object" || t === null || Array.isArray(t))
1738
+ throw new m(
1739
+ `agov config file "${e}" must contain a JSON object.`,
1740
+ "agov.cli.invalid_config"
1741
+ );
1742
+ return t;
1743
+ }
1744
+ function qo(e, o) {
1745
+ const t = e ?? me(o) ?? "text";
1746
+ if (t !== "text" && t !== "json" && t !== "markdown" && t !== "table")
1747
+ throw new m(
1748
+ 'Unsupported agov check format. Supported formats are "table", "markdown", "text", and "json".',
1749
+ "agov.cli.unsupported_format"
1750
+ );
1751
+ return t;
1752
+ }
1753
+ function J(e, o) {
1754
+ if (e)
1755
+ return g.resolve(o, e);
1756
+ }
1757
+ function Y(e, o) {
1758
+ if (!(!e || e.trim().length === 0))
1759
+ return g.resolve(o, e);
1760
+ }
1761
+ function me(e) {
1762
+ return typeof e == "string" && e.trim().length > 0 ? e.trim() : void 0;
1763
+ }
1764
+ function N(e) {
1765
+ return Array.isArray(e) ? e.filter((o) => typeof o == "string").map((o) => o.trim()).filter((o) => o.length > 0) : [];
1766
+ }
1767
+ function z(e, o) {
1768
+ for (const t of o) {
1769
+ const r = g.resolve(e, t);
1770
+ if (te(r) && ne(r).isFile())
1771
+ return r;
1772
+ }
1773
+ }
1774
+ function Bo(e, o) {
1775
+ return [
1776
+ .../* @__PURE__ */ new Set([
1777
+ ...N(o.adapters),
1778
+ ...Ko(e)
1779
+ ])
1780
+ ];
1781
+ }
1782
+ function Ko(e) {
1783
+ const o = g.join(e, "package.json");
1784
+ if (!te(o) || !ne(o).isFile())
1785
+ return [];
1786
+ try {
1787
+ const t = JSON.parse(G(o, "utf8"));
1788
+ if (typeof t != "object" || t === null || Array.isArray(t))
1789
+ return [];
1790
+ const r = t, n = typeof r.agov == "object" && r.agov !== null && !Array.isArray(r.agov) ? r.agov : void 0, a = typeof r.governance == "object" && r.governance !== null && !Array.isArray(r.governance) ? r.governance : void 0;
1791
+ return [
1792
+ ...N(n?.adapters),
1793
+ ...N(a?.adapters)
1794
+ ];
1795
+ } catch {
1796
+ return [];
1797
+ }
1798
+ }
1799
+ function Qo(e) {
1800
+ return e instanceof I || e instanceof R ? _({
1801
+ code: e instanceof I ? "agov.cli.invalid_workspace" : "agov.cli.invalid_profile",
1802
+ message: e.message,
1803
+ details: {
1804
+ filePath: e.filePath,
1805
+ issues: e.issues
1806
+ }
1807
+ }) : _({
1808
+ code: e instanceof L ? "agov.cli.workspace_load_failed" : "agov.cli.profile_load_failed",
1809
+ message: e.message,
1810
+ details: {
1811
+ filePath: e.filePath,
1812
+ loaderCode: e.code
1813
+ }
1814
+ });
1815
+ }
1816
+ function _(e) {
1817
+ return JSON.stringify(
1818
+ {
1819
+ error: {
1820
+ code: e.code,
1821
+ message: e.message,
1822
+ ...e.details ? { details: e.details } : {}
1823
+ }
1824
+ },
1825
+ null,
1826
+ 2
1827
+ );
1828
+ }
1829
+ function et() {
1830
+ return [
1831
+ "agov",
1832
+ "",
1833
+ "Usage:",
1834
+ " agov --help",
1835
+ " agov --version",
1836
+ " agov check [options]",
1837
+ "",
1838
+ "Commands:",
1839
+ " check Run a Governance check using canonical workspace mode or adapter mode.",
1840
+ "",
1841
+ 'Run "agov check --help" for command-specific options.'
1842
+ ].join(`
1843
+ `);
1844
+ }
1845
+ function ot() {
1846
+ return [
1847
+ "agov check",
1848
+ "",
1849
+ "Usage:",
1850
+ " agov check --profile <path> --workspace <path> [--format table|markdown|text|json]",
1851
+ " agov check --profile <path> --adapter <package> --root <path> [--format table|markdown|text|json]",
1852
+ " agov check [--config <path>]",
1853
+ "",
1854
+ "Resolution order:",
1855
+ " explicit CLI flag -> config file -> conventional files -> generic adapter discovery and probe -> error",
1856
+ "",
1857
+ "Options:",
1858
+ " --help Show check command help.",
1859
+ " --config <path> Load agov.config.json or governance.config.json explicitly.",
1860
+ " --profile <path> Governance profile document.",
1861
+ " --workspace <path> Canonical Governance workspace document.",
1862
+ " --adapter <package> Dynamically load a concrete adapter package.",
1863
+ " --root <path> Adapter input root. Defaults to the current working directory.",
1864
+ " --format <value> Output format: table, markdown, text, or json. Defaults to text.",
1865
+ " --output <path> Write command output to a file instead of stdout.",
1866
+ "",
1867
+ "Conventions:",
1868
+ " Config: agov.config.json, governance.config.json",
1869
+ " Profile: tools/governance/profiles/default.json, tools/governance/profile.json, governance.profile.json, agov.profile.json",
1870
+ " Workspace: governance.workspace.json, agov.workspace.json, tools/governance/workspace.json"
1871
+ ].join(`
1872
+ `);
1873
+ }
1874
+ function tt() {
1875
+ return {
1876
+ stdout(e) {
1877
+ process.stdout.write(`${e}
1878
+ `);
1879
+ },
1880
+ stderr(e) {
1881
+ process.stderr.write(`${e}
1882
+ `);
1883
+ }
1884
+ };
1885
+ }
1886
+ function nt() {
1887
+ return {
1888
+ cwd() {
1889
+ return process.cwd();
1890
+ },
1891
+ async moduleLoader(e) {
1892
+ return import(e);
1893
+ },
1894
+ packageVersion() {
1895
+ const e = we(
1896
+ new URL("data:application/json;base64,ewogICJuYW1lIjogIkBhbmFyY2hpdGVjdHMvZ292ZXJuYW5jZS1jbGkiLAogICJ2ZXJzaW9uIjogIjAuMC4zIiwKICAiZGVzY3JpcHRpb24iOiAiUGxhdGZvcm0taW5kZXBlbmRlbnQgc3RhbmRhbG9uZSBHb3Zlcm5hbmNlIENMSSB0aGF0IG9yY2hlc3RyYXRlcyBBbmFyY2hpdGVjdHMgR292ZXJuYW5jZSBDb3JlIGNvbnRyYWN0cyBvdXRzaWRlIE54LiIsCiAgImxpY2Vuc2UiOiAiTUlUIiwKICAidHlwZSI6ICJtb2R1bGUiLAogICJtYWluIjogIi4vZGlzdC9pbmRleC5qcyIsCiAgIm1vZHVsZSI6ICIuL2Rpc3QvaW5kZXguanMiLAogICJ0eXBlcyI6ICIuL2Rpc3QvaW5kZXguZC50cyIsCiAgInJlcG9zaXRvcnkiOiB7CiAgICAidHlwZSI6ICJnaXQiLAogICAgInVybCI6ICJnaXQraHR0cHM6Ly9naXRodWIuY29tL2FuYXJjaGl0ZWN0cy9hbmFyY2hpdGVjdHVyZS1jb21tdW5pdHkuZ2l0IiwKICAgICJkaXJlY3RvcnkiOiAicGFja2FnZXMvZ292ZXJuYW5jZS9jbGkiCiAgfSwKICAiYnVncyI6IHsKICAgICJ1cmwiOiAiaHR0cHM6Ly9naXRodWIuY29tL2FuYXJjaGl0ZWN0cy9hbmFyY2hpdGVjdHVyZS1jb21tdW5pdHkvaXNzdWVzIgogIH0sCiAgImhvbWVwYWdlIjogImh0dHBzOi8vZ2l0aHViLmNvbS9hbmFyY2hpdGVjdHMvYW5hcmNoaXRlY3R1cmUtY29tbXVuaXR5L3RyZWUvbWFpbi9wYWNrYWdlcy9nb3Zlcm5hbmNlL2NsaSNyZWFkbWUiLAogICJrZXl3b3JkcyI6IFsKICAgICJnb3Zlcm5hbmNlIiwKICAgICJjbGkiCiAgXSwKICAiZXhwb3J0cyI6IHsKICAgICIuL3BhY2thZ2UuanNvbiI6ICIuL3BhY2thZ2UuanNvbiIsCiAgICAiLiI6IHsKICAgICAgIkBhbmFyY2hpdGVjdHVyZS1jb21tdW5pdHkvc291cmNlIjogIi4vc3JjL2luZGV4LnRzIiwKICAgICAgInR5cGVzIjogIi4vZGlzdC9pbmRleC5kLnRzIiwKICAgICAgImltcG9ydCI6ICIuL2Rpc3QvaW5kZXguanMiLAogICAgICAiZGVmYXVsdCI6ICIuL2Rpc3QvaW5kZXguanMiCiAgICB9CiAgfSwKICAiYmluIjogewogICAgImFnb3YiOiAiLi9kaXN0L2Jpbi9hZ292LmpzIgogIH0sCiAgImZpbGVzIjogWwogICAgImRpc3QiLAogICAgIiEqKi8qLnRzYnVpbGRpbmZvIgogIF0sCiAgInB1Ymxpc2hDb25maWciOiB7CiAgICAiYWNjZXNzIjogInB1YmxpYyIKICB9LAogICJueCI6IHsKICAgICJuYW1lIjogImdvdmVybmFuY2UtY2xpIiwKICAgICJ0YXJnZXRzIjogewogICAgICAidGVzdCI6IHsKICAgICAgICAiZXhlY3V0b3IiOiAiQG54L3ZpdGVzdDp0ZXN0IiwKICAgICAgICAib3V0cHV0cyI6IFsKICAgICAgICAgICJ7b3B0aW9ucy5yZXBvcnRzRGlyZWN0b3J5fSIKICAgICAgICBdLAogICAgICAgICJvcHRpb25zIjogewogICAgICAgICAgInJlcG9ydHNEaXJlY3RvcnkiOiAiY292ZXJhZ2UvcGFja2FnZXMvZ292ZXJuYW5jZS9jbGkiCiAgICAgICAgfQogICAgICB9CiAgICB9CiAgfSwKICAiZGVwZW5kZW5jaWVzIjogewogICAgIkBhbmFyY2hpdGVjdHMvZ292ZXJuYW5jZS1jb3JlIjogIl4wLjAuMyIsCiAgICAieWFtbCI6ICJeMi44LjEiCiAgfQp9Cg==", import.meta.url)
1897
+ );
1898
+ return JSON.parse(G(e, "utf8")).version ?? "0.0.0";
1899
+ }
1900
+ };
1901
+ }
1902
+ function rt(e, o) {
1903
+ const t = g.resolve(e);
1904
+ try {
1905
+ ve(t, o, "utf8");
1906
+ } catch {
1907
+ throw new he(
1908
+ `Failed to write agov report output to "${t}".`,
1909
+ "agov.cli.output_write_failed",
1910
+ t
1911
+ );
1912
+ }
1913
+ }
1914
+ export {
1915
+ ee as A,
1916
+ L as G,
1917
+ q as S,
1918
+ Oo as a,
1919
+ M as b,
1920
+ O as c,
1921
+ he as d,
1922
+ E as e,
1923
+ m as f,
1924
+ I as g,
1925
+ R as h,
1926
+ Ve as i,
1927
+ Oe as j,
1928
+ le as k,
1929
+ pt as l,
1930
+ lt as m,
1931
+ Ao as n,
1932
+ ut as o,
1933
+ No as p,
1934
+ Zo as r,
1935
+ so as v
1936
+ };