gennady 0.7.0 → 0.8.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 (154) hide show
  1. package/ai/directives/coding/result-conventions.xml +25 -7
  2. package/ai/directives/sdd/audit.directive.xml +1 -1
  3. package/ai/directives/sdd/critic-protocol.xml +78 -0
  4. package/ai/directives/sdd/critic.directive.xml +158 -0
  5. package/ai/directives/sdd/phase-execution-protocol.xml +11 -9
  6. package/ai/skills/alt-opinion/SKILL.md +79 -0
  7. package/ai/skills/alt-opinion/opinion.prompt.md +11 -0
  8. package/ai/skills/alt-opinion/synth.prompt.md +8 -0
  9. package/ai/skills/sdd-audit/SKILL.md +13 -0
  10. package/ai/skills/sdd-check/SKILL.md +139 -0
  11. package/ai/skills/sdd-continue/SKILL.md +13 -0
  12. package/ai/skills/sdd-critic/SKILL.md +12 -0
  13. package/ai/skills/sdd-discover/SKILL.md +13 -0
  14. package/ai/skills/sdd-execute/SKILL.md +205 -0
  15. package/ai/skills/sdd-execute/scripts/README.md +84 -0
  16. package/ai/skills/sdd-execute/scripts/check-blockers.sh +158 -0
  17. package/ai/skills/sdd-execute/scripts/classify-scripts.js +111 -0
  18. package/ai/skills/sdd-execute/scripts/classify-scripts.ts +133 -0
  19. package/ai/skills/sdd-execute/scripts/extract-section.sh +219 -0
  20. package/ai/skills/sdd-execute/scripts/lint-artifacts.sh +143 -0
  21. package/ai/skills/sdd-execute/scripts/scan.sh +385 -0
  22. package/ai/skills/sdd-execute/scripts/sdd +114 -0
  23. package/ai/skills/sdd-execute/scripts/verify.sh +139 -0
  24. package/ai/skills/sdd-execute-batch/SKILL.md +213 -0
  25. package/ai/skills/sdd-fix/SKILL.md +13 -0
  26. package/ai/skills/sdd-infra/SKILL.md +13 -0
  27. package/ai/skills/sdd-module-decomposition/SKILL.md +13 -0
  28. package/ai/skills/sdd-scaffold/SKILL.md +13 -0
  29. package/ai/skills/sdd-setup/SKILL.md +13 -0
  30. package/dist/ai/directives/coding/result-conventions.xml +25 -7
  31. package/dist/ai/directives/sdd/audit.directive.xml +1 -1
  32. package/dist/ai/directives/sdd/critic-protocol.xml +78 -0
  33. package/dist/ai/directives/sdd/critic.directive.xml +158 -0
  34. package/dist/ai/directives/sdd/phase-execution-protocol.xml +11 -9
  35. package/dist/ai/skills/alt-opinion/SKILL.md +79 -0
  36. package/dist/ai/skills/alt-opinion/opinion.prompt.md +11 -0
  37. package/dist/ai/skills/alt-opinion/synth.prompt.md +8 -0
  38. package/dist/ai/skills/sdd-audit/SKILL.md +13 -0
  39. package/dist/ai/skills/sdd-check/SKILL.md +139 -0
  40. package/dist/ai/skills/sdd-continue/SKILL.md +13 -0
  41. package/dist/ai/skills/sdd-critic/SKILL.md +12 -0
  42. package/dist/ai/skills/sdd-discover/SKILL.md +13 -0
  43. package/dist/ai/skills/sdd-execute/SKILL.md +205 -0
  44. package/dist/ai/skills/sdd-execute/scripts/README.md +84 -0
  45. package/dist/ai/skills/sdd-execute/scripts/check-blockers.sh +158 -0
  46. package/dist/ai/skills/sdd-execute/scripts/classify-scripts.js +111 -0
  47. package/dist/ai/skills/sdd-execute/scripts/classify-scripts.ts +133 -0
  48. package/dist/ai/skills/sdd-execute/scripts/extract-section.sh +219 -0
  49. package/dist/ai/skills/sdd-execute/scripts/lint-artifacts.sh +143 -0
  50. package/dist/ai/skills/sdd-execute/scripts/scan.sh +385 -0
  51. package/dist/ai/skills/sdd-execute/scripts/sdd +114 -0
  52. package/dist/ai/skills/sdd-execute/scripts/verify.sh +139 -0
  53. package/dist/ai/skills/sdd-execute-batch/SKILL.md +213 -0
  54. package/dist/ai/skills/sdd-fix/SKILL.md +13 -0
  55. package/dist/ai/skills/sdd-infra/SKILL.md +13 -0
  56. package/dist/ai/skills/sdd-module-decomposition/SKILL.md +13 -0
  57. package/dist/ai/skills/sdd-scaffold/SKILL.md +13 -0
  58. package/dist/ai/skills/sdd-setup/SKILL.md +13 -0
  59. package/dist/chunks/_commonjsHelpers-DaMA6jEr.js +8 -0
  60. package/dist/chunks/{devtools-B-7ugZhF.js → devtools-CPZ0IUNM.js} +1 -1
  61. package/dist/chunks/help-5qCaicff.js +6 -0
  62. package/dist/chunks/help-B2ETH0j6.js +6 -0
  63. package/dist/chunks/help-BCDURaCQ.js +6 -0
  64. package/dist/chunks/help-BvgYOSyQ.js +6 -0
  65. package/dist/chunks/help-CSPhOoI9.js +8 -0
  66. package/dist/chunks/help-CV1vpwrh.js +6 -0
  67. package/dist/chunks/help-CaBNA6Qr.js +12 -0
  68. package/dist/chunks/help-CjkR6SB9.js +6 -0
  69. package/dist/chunks/help-Coi1l5u9.js +8 -0
  70. package/dist/chunks/help-CsuLpZn-.js +8 -0
  71. package/dist/chunks/help-DL_QBMwy.js +8 -0
  72. package/dist/chunks/help-DqBZ2xcp.js +6 -0
  73. package/dist/chunks/help-_Y_TN4DZ.js +6 -0
  74. package/dist/chunks/{help.cmd-B_G7EWzF.js → help.cmd-BseRtoBF.js} +10 -2
  75. package/dist/chunks/{index-zBnnuvLA.js → index-BU1AXJGA.js} +12 -7
  76. package/dist/chunks/{index-CXuhZzS3.js → index-BXWDYM_9.js} +1 -1
  77. package/dist/chunks/index-BgKyH0dB.js +658 -0
  78. package/dist/chunks/{index-CaahtXiM.js → index-BghL1-Nk.js} +2 -2
  79. package/dist/chunks/{index-BeL1Zcbg.js → index-BlqEQEGy.js} +1 -1
  80. package/dist/chunks/{index-D1qsi0Uc.js → index-CDM74qdR.js} +3 -3
  81. package/dist/chunks/{index-D9ceRUyB.js → index-CGsIRefC.js} +2 -2
  82. package/dist/chunks/{index-CiEM-8nJ.js → index-CIvkaAQ3.js} +2 -2
  83. package/dist/chunks/{index-UbHoePfr.js → index-CkczJ__m.js} +10 -10
  84. package/dist/chunks/index-CtJKSOL0.js +21 -0
  85. package/dist/chunks/index-DEzym4Ae.js +369 -0
  86. package/dist/chunks/{index-CVR66voe.js → index-DoaxOhQ8.js} +401 -393
  87. package/dist/chunks/index-Du1xR-qO.js +752 -0
  88. package/dist/chunks/{index-DU6jD7SS.js → index-OtehG7uM.js} +1 -1
  89. package/dist/chunks/index-ZM_FonZj.js +156 -0
  90. package/dist/chunks/{index-g1LXlp77.js → index-k0nToACp.js} +2 -2
  91. package/dist/chunks/{run-review-command.logic-DpkRoEi8.js → run-review-command.logic-BeYQin-I.js} +9 -9
  92. package/dist/chunks/services-IgZptnTi.js +2732 -0
  93. package/dist/chunks/shared-DL_1LG0K.js +753 -0
  94. package/dist/cli/cmd/agent-mon/help.d.ts +4 -0
  95. package/dist/cli/cmd/agents-rules/agents-rules.cmd.d.ts +8 -0
  96. package/dist/cli/cmd/agents-rules/index.d.ts +1 -0
  97. package/dist/cli/cmd/alt-opinion/help.d.ts +4 -0
  98. package/dist/cli/cmd/cat/help.d.ts +4 -0
  99. package/dist/cli/cmd/commit/help.d.ts +4 -0
  100. package/dist/cli/cmd/lint/checks/anchor-class-body.check.d.ts +11 -0
  101. package/dist/cli/cmd/lint/checks/invariant-count.check.d.ts +11 -0
  102. package/dist/cli/cmd/lint/checks/utils/glob-match.d.ts +15 -0
  103. package/dist/cli/cmd/lint/checks/utils/strip-strings-comments.d.ts +7 -0
  104. package/dist/cli/cmd/lint/help.d.ts +4 -0
  105. package/dist/cli/cmd/lint/lint.cmd.d.ts +1 -1
  106. package/dist/cli/cmd/lint/lint.types.d.ts +6 -0
  107. package/dist/cli/cmd/orient/core/build-index.d.ts +8 -0
  108. package/dist/cli/cmd/orient/core/damerau-levenshtein.d.ts +26 -0
  109. package/dist/cli/cmd/orient/core/extract-header.d.ts +8 -0
  110. package/dist/cli/cmd/orient/core/hints.d.ts +9 -0
  111. package/dist/cli/cmd/orient/core/query-consumer.d.ts +10 -0
  112. package/dist/cli/cmd/orient/core/query-entity.d.ts +11 -0
  113. package/dist/cli/cmd/orient/core/query-graph.d.ts +18 -0
  114. package/dist/cli/cmd/orient/core/query-keyword.d.ts +10 -0
  115. package/dist/cli/cmd/orient/core/query-spec.d.ts +15 -0
  116. package/dist/cli/cmd/orient/core/query-task.d.ts +8 -0
  117. package/dist/cli/cmd/orient/core/scan-files.d.ts +8 -0
  118. package/dist/cli/cmd/orient/help.d.ts +5 -0
  119. package/dist/cli/cmd/orient/index.d.ts +1 -0
  120. package/dist/cli/cmd/orient/orient.cmd.d.ts +7 -0
  121. package/dist/cli/cmd/orient/orient.types.d.ts +136 -0
  122. package/dist/cli/cmd/orient/render/render-detail.d.ts +10 -0
  123. package/dist/cli/cmd/orient/render/render-file-list.d.ts +15 -0
  124. package/dist/cli/cmd/orient/render/render-graph.d.ts +13 -0
  125. package/dist/cli/cmd/orient/render/render-search.d.ts +8 -0
  126. package/dist/cli/cmd/orient/render/render-specs.d.ts +13 -0
  127. package/dist/cli/cmd/orient/render/render-tree.d.ts +13 -0
  128. package/dist/cli/cmd/remote-console/help.d.ts +4 -0
  129. package/dist/cli/cmd/resolve-conflicts/help.d.ts +4 -0
  130. package/dist/cli/cmd/review/help.d.ts +4 -0
  131. package/dist/cli/cmd/review-issues/help.d.ts +4 -0
  132. package/dist/cli/cmd/review-verify/help.d.ts +4 -0
  133. package/dist/cli/cmd/sync/help.d.ts +4 -0
  134. package/dist/cli/cmd/sync/sync-core.d.ts +3 -2
  135. package/dist/cli/cmd/sync/sync-formatter.d.ts +8 -9
  136. package/dist/cli/cmd/sync/sync.cmd.d.ts +2 -21
  137. package/dist/cli/cmd/sync-skills/index.d.ts +1 -0
  138. package/dist/cli/cmd/sync-skills/sync-skills-core.d.ts +50 -0
  139. package/dist/cli/cmd/sync-skills/sync-skills-formatter.d.ts +13 -0
  140. package/dist/cli/cmd/sync-skills/sync-skills.cmd.d.ts +14 -0
  141. package/dist/cli/cmd/sync-skills/sync-skills.types.d.ts +56 -0
  142. package/dist/cli/cmd/vcs-reply/help.d.ts +4 -0
  143. package/dist/gennady.js +73 -18
  144. package/dist/index.js +5 -5
  145. package/dist/services/dbc/linter/implementations/ts/dbc-ts-ast-adapter.d.ts +3 -2
  146. package/dist/shared/common/sync/path-normalizer.d.ts +22 -0
  147. package/dist/shared/common/sync/sync-core.shared.d.ts +14 -0
  148. package/dist/shared/common/sync/sync-deps.type.d.ts +66 -0
  149. package/dist/shared/common/sync/sync-formatter.shared.d.ts +19 -0
  150. package/package.json +6 -5
  151. package/dist/chunks/index-DJpVmyp2.js +0 -176
  152. package/dist/chunks/index-KxSZKmZn.js +0 -540
  153. package/dist/chunks/services-CaLOhuLV.js +0 -2889
  154. package/dist/chunks/shared-Bjy30TeM.js +0 -665
@@ -0,0 +1,658 @@
1
+ import { readdirSync as T, lstatSync as P, existsSync as z, readFileSync as D, statSync as q } from "node:fs";
2
+ import { resolve as w, join as R, extname as H, basename as N, relative as x, sep as E } from "node:path";
3
+ import { l as S, a as G } from "./services-IgZptnTi.js";
4
+ const U = [".ts", ".tsx"], J = /* @__PURE__ */ new Set([
5
+ "node_modules",
6
+ ".git",
7
+ "dist",
8
+ "coverage",
9
+ "build",
10
+ "out",
11
+ "__tests__"
12
+ ]), Q = /\.(test|spec)\.(ts|tsx)$/;
13
+ function F(i) {
14
+ const e = /* @__PURE__ */ new Set(), n = w(i);
15
+ return _(n, e), [...e].sort();
16
+ }
17
+ function _(i, e) {
18
+ let n;
19
+ try {
20
+ n = T(i, { withFileTypes: !0 });
21
+ } catch {
22
+ return;
23
+ }
24
+ for (const t of n) {
25
+ if (t.name.startsWith(".") || J.has(t.name)) continue;
26
+ const o = R(i, t.name);
27
+ let s;
28
+ try {
29
+ s = P(o);
30
+ } catch {
31
+ continue;
32
+ }
33
+ if (!s.isSymbolicLink()) {
34
+ if (s.isDirectory())
35
+ _(o, e);
36
+ else if (s.isFile()) {
37
+ if (Q.test(t.name)) continue;
38
+ const r = H(t.name).toLowerCase();
39
+ U.includes(r) && e.add(o);
40
+ }
41
+ }
42
+ }
43
+ }
44
+ function V(i) {
45
+ const e = { file: "", tasks: [], consumers: [] };
46
+ if (i.length === 0) return e;
47
+ const n = i.split(`
48
+ `);
49
+ for (const t of n) {
50
+ const o = t.trim();
51
+ if (o.startsWith("import ")) break;
52
+ if (o.startsWith("// @file:") && (e.file = o.slice(9).trim()), o.startsWith("// @tasks:")) {
53
+ const s = o.slice(10);
54
+ e.tasks = s.split(/[,;\s]+/).map((r) => r.trim()).filter((r) => /^TSK-\d+$/.test(r));
55
+ }
56
+ if (o.startsWith("// @consumers:")) {
57
+ const s = o.slice(14);
58
+ e.consumers = s.split(/[,;]+/).map((r) => r.trim()).filter(Boolean);
59
+ }
60
+ }
61
+ return e;
62
+ }
63
+ function Y(i) {
64
+ const e = /* @__PURE__ */ new Map();
65
+ for (const n of i) {
66
+ const t = I(n.header.file);
67
+ for (const o of t)
68
+ L(e, o, { file: n.absPath, source: "file" });
69
+ for (const o of n.exports) {
70
+ const s = o.contract.entries.find(
71
+ (c) => c.type === "purpose" || c.type === "description"
72
+ );
73
+ if (!s) continue;
74
+ const r = I(s.value);
75
+ for (const c of r)
76
+ L(e, c, { file: n.absPath, source: "entity", entity: o.name });
77
+ }
78
+ }
79
+ return e;
80
+ }
81
+ function I(i) {
82
+ return i.toLowerCase().split(/[^a-z0-9_]+/).filter((e) => e.length > 1);
83
+ }
84
+ function L(i, e, n) {
85
+ let t = i.get(e);
86
+ t || (t = /* @__PURE__ */ new Set(), i.set(e, t)), t.add(n);
87
+ }
88
+ function Z(i, e) {
89
+ if (e.length === 0) return [];
90
+ const n = [];
91
+ for (const t of e) {
92
+ const o = i.filter((s) => s.header.tasks.includes(t));
93
+ n.push({ taskId: t, files: o });
94
+ }
95
+ return n;
96
+ }
97
+ function W(i, e) {
98
+ const n = i.length, t = e.length, o = [];
99
+ for (let s = 0; s <= n; s++)
100
+ o[s] = [], o[s][0] = s;
101
+ for (let s = 0; s <= t; s++)
102
+ o[0][s] = s;
103
+ for (let s = 1; s <= n; s++)
104
+ for (let r = 1; r <= t; r++) {
105
+ const c = i[s - 1] === e[r - 1] ? 0 : 1;
106
+ o[s][r] = Math.min(
107
+ o[s - 1][r] + 1,
108
+ // deletion
109
+ o[s][r - 1] + 1,
110
+ // insertion
111
+ o[s - 1][r - 1] + c
112
+ // substitution
113
+ ), s > 1 && r > 1 && i[s - 1] === e[r - 2] && i[s - 2] === e[r - 1] && (o[s][r] = Math.min(o[s][r], o[s - 2][r - 2] + c));
114
+ }
115
+ return o[n][t];
116
+ }
117
+ function A(i, e, n) {
118
+ if (e.length === 0) return [];
119
+ const t = [];
120
+ for (const o of e) {
121
+ const s = i.filter((r) => n ? r.header.consumers.some((c) => {
122
+ const f = o.length <= 5 ? 2 : 3;
123
+ return W(o.toLowerCase(), c.toLowerCase()) <= f;
124
+ }) : r.header.consumers.some((c) => c.toLowerCase().includes(o.toLowerCase())));
125
+ t.push({ consumerName: o, files: s });
126
+ }
127
+ return t;
128
+ }
129
+ function ee(i, e, n) {
130
+ const t = n.trim();
131
+ if (t.length === 0) return [];
132
+ const o = t.toLowerCase().split(/\s+/).filter(Boolean), s = /* @__PURE__ */ new Map();
133
+ for (const l of i)
134
+ s.set(l.absPath, l);
135
+ const r = /* @__PURE__ */ new Map(), c = [];
136
+ for (const l of o) {
137
+ const p = /* @__PURE__ */ new Set(), m = e.get(l);
138
+ if (m)
139
+ for (const u of m) {
140
+ p.add(u.file);
141
+ const g = r.get(u.file) ?? { score: 0 };
142
+ g.score += 10, u.source === "entity" && u.entity && (g.entityName = u.entity), r.set(u.file, g);
143
+ }
144
+ for (const [u, g] of e)
145
+ if (u !== l && u.startsWith(l))
146
+ for (const d of g) {
147
+ p.add(d.file);
148
+ const h = r.get(d.file) ?? { score: 0 };
149
+ h.score += 5, d.source === "entity" && d.entity && !h.entityName && (h.entityName = d.entity), r.set(d.file, h);
150
+ }
151
+ for (const [u, g] of e) {
152
+ const d = l.length <= 5 ? 2 : 3;
153
+ if (W(l, u) <= d && u !== l && !u.startsWith(l))
154
+ for (const h of g) {
155
+ p.add(h.file);
156
+ const y = r.get(h.file) ?? { score: 0 };
157
+ y.score += 3, h.source === "entity" && h.entity && !y.entityName && (y.entityName = h.entity), r.set(h.file, y);
158
+ }
159
+ }
160
+ c.push(p);
161
+ }
162
+ let f = /* @__PURE__ */ new Set();
163
+ if (c.length > 0) {
164
+ f = c[0];
165
+ for (let l = 1; l < c.length; l++)
166
+ f = new Set([...f].filter((p) => c[l].has(p)));
167
+ }
168
+ const a = [];
169
+ for (const l of f) {
170
+ const p = s.get(l);
171
+ if (!p) continue;
172
+ const m = r.get(l);
173
+ a.push({
174
+ file: p,
175
+ score: m?.score ?? 0,
176
+ entityName: m?.entityName
177
+ });
178
+ }
179
+ return a.sort((l, p) => p.score - l.score), a;
180
+ }
181
+ function te(i, e, n) {
182
+ if (e.length === 0) return [];
183
+ const t = [];
184
+ for (const o of i)
185
+ for (const s of o.exports)
186
+ for (const r of e) {
187
+ if (!n && s.name === r) {
188
+ t.push({
189
+ name: s.name,
190
+ kind: s.kind,
191
+ filePath: o.absPath,
192
+ contract: s.contract,
193
+ fuzzy: !1
194
+ });
195
+ continue;
196
+ }
197
+ if (n) {
198
+ const c = r.length <= 5 ? 2 : 3, f = W(r.toLowerCase(), s.name.toLowerCase());
199
+ f <= c && t.push({
200
+ name: s.name,
201
+ kind: s.kind,
202
+ filePath: o.absPath,
203
+ contract: s.contract,
204
+ fuzzy: !0,
205
+ distance: f
206
+ });
207
+ }
208
+ }
209
+ return t;
210
+ }
211
+ function ne(i) {
212
+ const e = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
213
+ for (const t of i) {
214
+ const o = N(t.absPath, ".ts");
215
+ n.set(o, t.absPath);
216
+ }
217
+ for (const t of i)
218
+ for (const o of t.header.consumers) {
219
+ let s = e.get(o);
220
+ if (!s) {
221
+ const r = n.has(o);
222
+ s = {
223
+ consumer: o,
224
+ files: r ? [n.get(o)] : [],
225
+ consumedBy: [],
226
+ unresolved: !r
227
+ }, e.set(o, s);
228
+ }
229
+ s.files.push(t.absPath);
230
+ }
231
+ for (const t of i)
232
+ for (const o of t.header.consumers) {
233
+ const s = e.get(o);
234
+ if (!s) continue;
235
+ const r = N(t.absPath, ".ts");
236
+ s.consumer !== r && (s.consumedBy.includes(r) || s.consumedBy.push(r));
237
+ }
238
+ return e;
239
+ }
240
+ function se(i, e, n) {
241
+ const t = /* @__PURE__ */ new Set(), o = [];
242
+ function s(r, c, f) {
243
+ if (c > n) {
244
+ o.push(`${f}... more`);
245
+ return;
246
+ }
247
+ if (t.has(r)) {
248
+ o.push(`${f}${r} [circular]`);
249
+ return;
250
+ }
251
+ t.add(r);
252
+ const a = i.get(r);
253
+ if (!a) {
254
+ o.push(`${f}${r} (unresolved)`);
255
+ return;
256
+ }
257
+ o.push(`${f}${r}`);
258
+ for (const l of a.consumedBy)
259
+ s(l, c + 1, `${f} `);
260
+ }
261
+ return s(e, 0, ""), o;
262
+ }
263
+ function M(i) {
264
+ const e = w(i, "specs");
265
+ if (!z(e)) return [];
266
+ const n = oe(e), t = [];
267
+ for (const o of n) {
268
+ const s = x(i, o);
269
+ let r;
270
+ try {
271
+ r = D(o, "utf-8");
272
+ } catch {
273
+ continue;
274
+ }
275
+ const c = ie(r), f = c.length === 0, a = {
276
+ specPath: s,
277
+ taskIds: c,
278
+ isLibraryLevel: f,
279
+ subSpecs: []
280
+ };
281
+ f && (a.subSpecs = re(o, e)), t.push(a);
282
+ }
283
+ return t;
284
+ }
285
+ function oe(i) {
286
+ const e = [], n = [i];
287
+ for (; n.length > 0; ) {
288
+ const t = n.pop();
289
+ let o;
290
+ try {
291
+ o = T(t);
292
+ } catch {
293
+ continue;
294
+ }
295
+ for (const s of o) {
296
+ if (s.startsWith(".")) continue;
297
+ const r = w(t, s);
298
+ let c;
299
+ try {
300
+ c = q(r);
301
+ } catch {
302
+ continue;
303
+ }
304
+ c.isDirectory() ? n.push(r) : s.endsWith(".spec.md") && e.push(r);
305
+ }
306
+ }
307
+ return e;
308
+ }
309
+ function ie(i) {
310
+ const e = /* @__PURE__ */ new Set(), n = /TSK-\d+/g;
311
+ let t;
312
+ for (; (t = n.exec(i)) !== null; )
313
+ e.add(t[0]);
314
+ return [...e].sort();
315
+ }
316
+ function re(i, e) {
317
+ const n = w(i, "..");
318
+ if (!n.startsWith(e)) return [];
319
+ let t;
320
+ try {
321
+ t = T(n);
322
+ } catch {
323
+ return [];
324
+ }
325
+ return t.filter((o) => o !== N(i) && o.endsWith(".spec.md")).map((o) => w(n, o)).filter((o) => o !== i).sort();
326
+ }
327
+ function ce(i, e) {
328
+ return M(i).find((t) => t.specPath.endsWith(e)) ?? null;
329
+ }
330
+ function le(i) {
331
+ const e = [];
332
+ return i.file.length > 0 ? [
333
+ "orient --detail show DBC contracts for each entity in this file",
334
+ "orient --task=TSK-XX --detail find files by task, then show their contracts"
335
+ ] : i.task.length > 0 ? (e.push("orient --task=<TID> --detail show DBC contracts for matched files"), e.push("orient --consumer=<name> find files by consumer name"), e.push("orient --entity=<name> search for a specific exported entity"), e.push("orient --specs see all specs and their task files"), e.slice(0, 4)) : i.consumer.length > 0 ? (e.push("orient --consumer=<name> --detail show contracts"), e.push("orient --graph show the full dependency graph"), e.push("orient --graph --recursive show transitive dependencies"), e) : i.entity.length > 0 ? (e.push("orient --entity=<name> --fuzzy fuzzy match entity names"), e.push("orient --file=<path> inspect a specific file in detail"), e) : i.graph ? (e.push("orient --graph --recursive expand transitive dependencies"), e.push("orient --graph --recursive --depth=<N> limit recursion depth"), e.push("orient --consumer=<name> find files by consumer"), e) : i.specs || i.spec ? (e.push("orient --task=TSK-XX find files for a specific task"), e.push("orient --file=<path> detailed view of a file"), e) : i._.length > 0 ? (e.push("orient --detail include DBC contract details"), e.push("orient --task=TSK-XX find all files for a task"), e.push("orient --entity=<name> search exported entities"), e.push("orient --file=<path> detailed view of a single file"), e.slice(0, 4)) : (e.push("orient --depth=<N> limit tree depth"), e.push("orient --detail show DBC contracts per file"), e.push("orient --task=TSK-XX find files by task ID"), e.push("orient <keyword> search across all @file: and @purpose"), e.slice(0, 4));
336
+ }
337
+ function fe(i, e, n, t, o) {
338
+ const s = [], r = ae(i, e);
339
+ if (O(r, "", e, n, 0, t, s), o < i.length) {
340
+ const c = i.length - o;
341
+ s.push(`... ${c} more file${c === 1 ? "" : "s"}`);
342
+ }
343
+ return s;
344
+ }
345
+ function ae(i, e) {
346
+ const n = /* @__PURE__ */ new Map();
347
+ for (const t of i) {
348
+ const s = x(e, t.absPath).split(E);
349
+ let r = n;
350
+ for (let c = 0; c < s.length - 1; c++) {
351
+ const f = s[c];
352
+ let a = r.get(f);
353
+ (!a || !(a instanceof Map)) && (a = /* @__PURE__ */ new Map(), r.set(f, a)), r = a;
354
+ }
355
+ r.set(s[s.length - 1], t);
356
+ }
357
+ return n;
358
+ }
359
+ function O(i, e, n, t, o, s, r) {
360
+ if (i instanceof Map) {
361
+ const d = [...i.entries()].sort(([$], [k]) => $.localeCompare(k)), h = [], y = [];
362
+ for (const [$, k] of d)
363
+ k instanceof Map ? h.push([$, k]) : y.push([$, k]);
364
+ if (o >= t) {
365
+ const $ = h.length, k = y.length, j = $ === 1 ? "dir" : "dirs", K = k === 1 ? "file" : "files";
366
+ r.push(`${e}... ${$} more ${j}, ${k} ${K}`);
367
+ return;
368
+ }
369
+ for (const [$, k] of h)
370
+ r.push(`${e}${$}/`), O(k, `${e} `, n, t, o + 1, s, r);
371
+ for (const [, $] of y)
372
+ O($, e, n, t, o, s, r);
373
+ return;
374
+ }
375
+ const c = i, f = c.header.file || "(missing)", a = c.header.tasks.length > 0 ? c.header.tasks.join(", ") : "", l = c.header.consumers.join(", "), p = c.exports.length.toString(), m = x(n, c.absPath), u = m.split(E).pop() ?? m;
376
+ let g = `${e}${u} — @file: ${f}`;
377
+ if (a && (g += ` | @tasks: ${a}`), l && (g += ` | @consumers: ${l}`), g += ` | @exports: ${p}`, r.push(g), s && c.exports.length > 0)
378
+ for (const d of c.exports) {
379
+ const h = d.contract.entries.find(
380
+ (y) => y.type === "purpose" || y.type === "description"
381
+ );
382
+ h && r.push(`${e} - ${d.name}(${d.kind}) ${h.value}`);
383
+ }
384
+ }
385
+ function b(i, e) {
386
+ const n = [];
387
+ for (const t of i) {
388
+ const o = x(e, t.absPath);
389
+ if (n.push(o), n.push(` @file: ${t.header.file || "(missing)"}`), t.header.tasks.length > 0 && n.push(` @tasks: ${t.header.tasks.join(", ")}`), t.header.consumers.length > 0 && n.push(` @consumers: ${t.header.consumers.join(", ")}`), n.push(` @exports: ${t.exports.length}`), t.exports.length > 0) {
390
+ n.push("");
391
+ for (const s of t.exports) {
392
+ const r = ue(s.name, s.kind, s.contract);
393
+ n.push(` ${r}`), he(s.contract.entries, n, " "), n.push("");
394
+ }
395
+ }
396
+ }
397
+ return n;
398
+ }
399
+ function ue(i, e, n) {
400
+ if (e === "function") {
401
+ const t = n.entries.filter((r) => r.type === "param").map((r) => r.specifier ?? "?").join(", "), o = n.entries.find((r) => r.type === "returns"), s = o ? `: ${o.dataType ?? o.value}` : ": void";
402
+ return `${i}(${t})${s}`;
403
+ }
404
+ return `${i}: ${e}`;
405
+ }
406
+ function he(i, e, n) {
407
+ for (const t of i) {
408
+ if (t.type === "description") continue;
409
+ let o = `${n}@${t.type}`;
410
+ if (t.specifier && (o += ` {${t.specifier}}`), t.dataType && (o += ` {${t.dataType}}`), t.value && (o += ` ${t.value}`), e.push(o), t.inline)
411
+ for (const s of t.inline) {
412
+ let r = `${n} @${s.type}`;
413
+ s.specifier && (r += ` {${s.specifier}}`), s.dataType && (r += ` {${s.dataType}}`), s.value && (r += ` ${s.value}`), e.push(r);
414
+ }
415
+ }
416
+ }
417
+ function pe(i, e) {
418
+ const n = x(e, i.absPath), t = i.header.file || "(missing)", o = i.header.tasks.length > 0 ? i.header.tasks.join(", ") : "", s = i.header.consumers.join(", "), r = i.exports.length.toString();
419
+ let c = `${n} — @file: ${t}`;
420
+ return o && (c += ` | @tasks: ${o}`), s && (c += ` | @consumers: ${s}`), c += ` | @exports: ${r}`, c;
421
+ }
422
+ function B(i, e) {
423
+ return i.map((n) => pe(n, e));
424
+ }
425
+ function de(i) {
426
+ const e = [];
427
+ if (i.size === 0)
428
+ return e.push("No consumer dependencies found"), e;
429
+ e.push("Project dependencies:");
430
+ for (const [n, t] of [...i.entries()].sort(([o], [s]) => o.localeCompare(s))) {
431
+ e.push(` ${n} consumes:`);
432
+ const o = [...new Set(t.files)].sort();
433
+ for (const s of o)
434
+ e.push(` ${s}`);
435
+ t.unresolved && e.push(" (unresolved — text-only reference)");
436
+ }
437
+ return e;
438
+ }
439
+ function me(i) {
440
+ const e = [];
441
+ if (i.length === 0)
442
+ return e.push("No specs found"), e;
443
+ for (const n of i)
444
+ if (n.isLibraryLevel) {
445
+ const t = n.subSpecs.length;
446
+ e.push(
447
+ `${n.specPath} (library-level spec — ${t} sub-spec${t === 1 ? "" : "s"} below)`
448
+ );
449
+ } else
450
+ e.push(`${n.specPath} → ${n.taskIds.join(", ")}`);
451
+ return e;
452
+ }
453
+ function ge(i) {
454
+ const e = [];
455
+ e.push(`${i.specPath}:`);
456
+ for (const n of i.taskIds)
457
+ e.push(` ${n}`);
458
+ return e;
459
+ }
460
+ function ye(i, e) {
461
+ const n = [];
462
+ for (const t of i) {
463
+ let s = `${x(e, t.file.absPath)} — @file: ${t.file.header.file || "(missing)"}`;
464
+ t.entityName && (s += ` - ${t.entityName}() @purpose: found via entity match`), n.push(s);
465
+ }
466
+ return n;
467
+ }
468
+ function $e(i) {
469
+ const e = {
470
+ _: [],
471
+ file: [],
472
+ dir: "",
473
+ task: [],
474
+ consumer: [],
475
+ entity: [],
476
+ graph: !1,
477
+ recursive: !1,
478
+ specs: !1,
479
+ spec: "",
480
+ detail: !1,
481
+ fuzzy: !1,
482
+ depth: 1 / 0,
483
+ maxResults: 1 / 0
484
+ };
485
+ for (let n = 2; n < i.length; n++) {
486
+ const t = i[n];
487
+ t === "--file" ? e.file.push(i[++n] ?? "") : t.startsWith("--file=") ? e.file.push(t.slice(7)) : t === "--dir" ? e.dir = i[++n] ?? "" : t.startsWith("--dir=") ? e.dir = t.slice(6) : t === "--task" ? e.task.push(i[++n] ?? "") : t.startsWith("--task=") ? e.task.push(t.slice(7)) : t === "--consumer" ? e.consumer.push(i[++n] ?? "") : t.startsWith("--consumer=") ? e.consumer.push(t.slice(11)) : t === "--entity" ? e.entity.push(i[++n] ?? "") : t.startsWith("--entity=") ? e.entity.push(t.slice(9)) : t === "--graph" ? e.graph = !0 : t === "--recursive" ? e.recursive = !0 : t === "--specs" ? e.specs = !0 : t === "--spec" ? e.spec = i[++n] ?? "" : t.startsWith("--spec=") ? e.spec = t.slice(7) : t === "--detail" ? e.detail = !0 : t === "--fuzzy" ? e.fuzzy = !0 : t === "--depth" ? e.depth = parseInt(i[++n] ?? "", 10) || 1 / 0 : t.startsWith("--depth=") ? e.depth = parseInt(t.slice(8), 10) || 1 / 0 : t === "--max-results" ? e.maxResults = parseInt(i[++n] ?? "", 10) || 1 / 0 : t.startsWith("--max-results=") ? e.maxResults = parseInt(t.slice(14), 10) || 1 / 0 : t && !t.startsWith("-") && t !== "orient" && e._.push(t);
488
+ }
489
+ return e;
490
+ }
491
+ async function Se(i) {
492
+ S.debug("[OrientCommand#run] [idle → parsing]");
493
+ const e = $e(i), n = w(".");
494
+ let t;
495
+ if (e.file.length > 0)
496
+ t = e.file.filter((o) => {
497
+ const s = w(o);
498
+ return !z(s) || !P(s).isFile() ? (console.error(`[OrientCommand#run] File not found: ${o}`), !1) : !0;
499
+ }).map((o) => C(w(o)));
500
+ else if (e.dir) {
501
+ const o = w(e.dir);
502
+ (!z(o) || !P(o).isDirectory()) && (console.error(`[OrientCommand#run] Directory not found: ${e.dir}`), process.exit(1)), t = F(o).map((r) => C(r));
503
+ } else
504
+ t = F(n).map((s) => C(s)).slice(0, e.maxResults);
505
+ if (t.length === 0) {
506
+ console.log("No .ts files found in the project.");
507
+ return;
508
+ }
509
+ S.debug(`[OrientCommand#run] [parsing → loaded] ${t.length} file(s)`), e.file.length > 0 && e.dir && (console.error("[OrientCommand#run] --file and --dir are mutually exclusive"), process.exit(1)), e.specs && e.file.length > 0 && (console.error("[OrientCommand#run] --specs and --file are mutually exclusive"), process.exit(1)), e.specs && (e.task.length > 0 || e.consumer.length > 0 || e.entity.length > 0 || e.graph) && (console.error(
510
+ "[OrientCommand#run] --specs is incompatible with --task/--consumer/--entity/--graph"
511
+ ), process.exit(1)), e.spec && (e.file.length > 0 || e.task.length > 0 || e.consumer.length > 0 || e.entity.length > 0 || e.graph) && (console.error(
512
+ "[OrientCommand#run] --spec is incompatible with --file/--task/--consumer/--entity/--graph"
513
+ ), process.exit(1)), e.graph && e._.length > 0 && (console.error("[OrientCommand#run] --graph and positional keyword are mutually exclusive"), process.exit(1)), e.file.length > 0 ? xe(t, e, n) : e.task.length > 0 ? ke(t, e, n) : e.consumer.length > 0 ? ve(t, e, n) : e.entity.length > 0 ? be(t, e, n) : e.graph ? Ce(t, e) : e.specs ? Pe(e, n) : e.spec ? ze(e, n) : e._.length > 0 ? we(t, e, n) : X(t, e, n);
514
+ }
515
+ function X(i, e, n) {
516
+ S.debug("[OrientCommand#run] [routing → S1] map");
517
+ const t = fe(i, n, e.depth, e.detail, e.maxResults);
518
+ for (const o of t) console.log(o);
519
+ v(e);
520
+ }
521
+ function ke(i, e, n) {
522
+ S.debug("[OrientCommand#run] [routing → S2] task");
523
+ const t = Z(i, e.task);
524
+ for (const o of t) {
525
+ if (o.files.length === 0) {
526
+ console.log(`No files found for ${o.taskId}`);
527
+ continue;
528
+ }
529
+ if (console.log(`${o.taskId} — ${o.files.length} file${o.files.length === 1 ? "" : "s"}:`), e.detail)
530
+ for (const s of b(o.files, n)) console.log(` ${s}`);
531
+ else
532
+ for (const s of B(o.files, n)) console.log(` ${s}`);
533
+ }
534
+ v(e);
535
+ }
536
+ function ve(i, e, n) {
537
+ S.debug("[OrientCommand#run] [routing → S3] consumer");
538
+ const t = A(i, e.consumer, e.fuzzy);
539
+ for (const o of t) {
540
+ if (o.files.length === 0) {
541
+ console.log(`"${o.consumerName}" not found as consumer`);
542
+ continue;
543
+ }
544
+ if (console.log(
545
+ `"${o.consumerName}" referenced as consumer by ${o.files.length} file${o.files.length === 1 ? "" : "s"}:`
546
+ ), e.detail)
547
+ for (const s of b(o.files, n)) console.log(` ${s}`);
548
+ else
549
+ for (const s of B(o.files, n)) console.log(` ${s}`);
550
+ }
551
+ v(e);
552
+ }
553
+ function we(i, e, n) {
554
+ const t = e._.join(" ").trim();
555
+ if (!t) {
556
+ X(i, e, n);
557
+ return;
558
+ }
559
+ S.debug(`[OrientCommand#run] [routing → S4] keyword "${t}"`);
560
+ const o = Y(i), s = ee(i, o, t);
561
+ if (s.length === 0) {
562
+ console.log(`"${t}" not found`), v(e);
563
+ return;
564
+ }
565
+ if (console.log(`"${t}" found in ${s.length} file${s.length === 1 ? "" : "s"}:`), e.detail) {
566
+ const r = s.map((c) => c.file);
567
+ for (const c of b(r, n)) console.log(` ${c}`);
568
+ } else
569
+ for (const r of ye(s, n)) console.log(` ${r}`);
570
+ v(e);
571
+ }
572
+ function xe(i, e, n) {
573
+ S.debug("[OrientCommand#run] [routing → S5] detail"), i.length === 0 && (console.error("[OrientCommand#run] No valid files to display"), process.exit(1));
574
+ for (const t of b(i, n)) console.log(t);
575
+ v(e);
576
+ }
577
+ function be(i, e, n) {
578
+ S.debug("[OrientCommand#run] [routing → S6] entity");
579
+ const t = te(i, e.entity, e.fuzzy);
580
+ for (const o of e.entity) {
581
+ const s = t.filter((c) => c.name === o || e.fuzzy && c.fuzzy);
582
+ if (s.length === 0) {
583
+ console.log(`"${o}" not found`);
584
+ continue;
585
+ }
586
+ const r = new Set(s.map((c) => c.filePath));
587
+ console.log(`"${o}" found in ${r.size} file${r.size === 1 ? "" : "s"}:`);
588
+ for (const c of r) {
589
+ const f = x(n, c);
590
+ console.log(` ${f}`);
591
+ const a = s.filter((l) => l.filePath === c);
592
+ for (const l of a) {
593
+ const p = l.contract.entries.find(
594
+ (u) => u.type === "purpose" || u.type === "description"
595
+ );
596
+ console.log(p ? ` ${l.name}: ${l.kind} — ${p.value}` : ` ${l.name}: ${l.kind}`);
597
+ const m = l.contract.entries.find((u) => u.type === "implements");
598
+ m && console.log(` @implements ${m.specifier ?? m.value}`);
599
+ }
600
+ }
601
+ }
602
+ v(e);
603
+ }
604
+ function Ce(i, e) {
605
+ S.debug("[OrientCommand#run] [routing → S7] graph");
606
+ const n = ne(i);
607
+ if (e.recursive) {
608
+ const t = [...n.keys()].filter((o) => {
609
+ const s = n.get(o);
610
+ return s && !s.unresolved;
611
+ });
612
+ for (const o of t) {
613
+ const s = se(n, o, e.depth);
614
+ for (const r of s) console.log(r);
615
+ }
616
+ } else
617
+ for (const t of de(n)) console.log(t);
618
+ v(e);
619
+ }
620
+ function Pe(i, e) {
621
+ S.debug("[OrientCommand#run] [routing → S8] specs overview");
622
+ const n = M(e);
623
+ for (const t of me(n)) console.log(t);
624
+ v(i);
625
+ }
626
+ function ze(i, e) {
627
+ S.debug(`[OrientCommand#run] [routing → S9] spec "${i.spec}"`);
628
+ const n = ce(e, i.spec);
629
+ n || (console.error(`spec "${i.spec}" not found. Use orient --specs for available specs.`), process.exit(1));
630
+ for (const t of ge(n)) console.log(t);
631
+ v(i);
632
+ }
633
+ function v(i) {
634
+ console.log(""), console.log("Hints:");
635
+ const e = le(i);
636
+ for (const n of e) console.log(` ${n}`);
637
+ }
638
+ function C(i) {
639
+ let e;
640
+ try {
641
+ e = D(i, "utf-8");
642
+ } catch {
643
+ return { absPath: i, header: { file: "", tasks: [], consumers: [] }, exports: [] };
644
+ }
645
+ const n = V(e), t = Ne(e);
646
+ return { absPath: i, header: n, exports: t };
647
+ }
648
+ function Ne(i) {
649
+ const e = [], n = new G(), t = /((?:\/\*\*[\s\S]*?\*\/\s*))?export\s+(class|function|const|type|interface|enum)\s+(\w+)/g;
650
+ let o;
651
+ for (; (o = t.exec(i)) !== null; ) {
652
+ const s = o[1]?.trim() ?? "", r = o[2], c = o[3];
653
+ let f, a = "";
654
+ s ? (a = s, f = n.parse(s)) : f = { entries: [], format: "single-line" }, e.push({ name: c, kind: r, contract: f, rawJsdoc: a });
655
+ }
656
+ return e;
657
+ }
658
+ await Se(process.argv);
@@ -1,5 +1,5 @@
1
- import { p as j, s as e, g as x } from "./shared-Bjy30TeM.js";
2
- import { p as T, A as E } from "./index-CiEM-8nJ.js";
1
+ import { p as j, s as e, g as x } from "./shared-DL_1LG0K.js";
2
+ import { p as T, A as E } from "./index-CIvkaAQ3.js";
3
3
  import { readdirSync as G, readFileSync as P } from "node:fs";
4
4
  import { join as h, dirname as k } from "node:path";
5
5
  import { fileURLToPath as N } from "node:url";
@@ -1,4 +1,4 @@
1
- import { p as s, r as e } from "./run-review-command.logic-DpkRoEi8.js";
1
+ import { p as s, r as e } from "./run-review-command.logic-BeYQin-I.js";
2
2
  const r = s(process.argv), o = await e({
3
3
  mode: "issues",
4
4
  args: r
@@ -2,9 +2,9 @@ import u from "node:fs";
2
2
  import S from "node:os";
3
3
  import v from "node:path";
4
4
  import { execSync as P } from "node:child_process";
5
- import { p as d, A as E } from "./index-CiEM-8nJ.js";
6
- import { g as H, s as t, x as D, p as F } from "./shared-Bjy30TeM.js";
7
- import { l as N } from "./services-CaLOhuLV.js";
5
+ import { p as d, A as E } from "./index-CIvkaAQ3.js";
6
+ import { g as H, s as t, x as D, p as F } from "./shared-DL_1LG0K.js";
7
+ import { l as N } from "./services-IgZptnTi.js";
8
8
  class U {
9
9
  /** @purpose Configuration with defaults for mode, prompts, timeout. */
10
10
  init;
@@ -7,8 +7,8 @@ import { promisify as h } from "node:util";
7
7
  import z from "node:os";
8
8
  import g from "node:fs";
9
9
  import { Buffer as X } from "node:buffer";
10
- import { p as G } from "./shared-Bjy30TeM.js";
11
- import { c as K } from "./services-CaLOhuLV.js";
10
+ import { p as G } from "./shared-DL_1LG0K.js";
11
+ import { c as K } from "./services-IgZptnTi.js";
12
12
  let F;
13
13
  function q() {
14
14
  try {