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
@@ -1,665 +0,0 @@
1
- import { spawn as O, execSync as R } from "node:child_process";
2
- import u, { mkdirSync as F, readFileSync as $, existsSync as M } from "node:fs";
3
- import m, { resolve as d, dirname as G, join as P } from "node:path";
4
- import { platform as b, homedir as k } from "node:os";
5
- import { fileURLToPath as T } from "node:url";
6
- import { l as w } from "./services-CaLOhuLV.js";
7
- const I = 864e5, W = 3e3, U = "update-check-worker.ts", H = "update-check-cache.json";
8
- function V(r) {
9
- return b() === "win32" ? d(process.env.LOCALAPPDATA ?? d(k(), "AppData", "Local"), "gennady") : b() === "darwin" ? d(k(), "Library", "Caches", "gennady") : d(k(), ".cache", "gennady");
10
- }
11
- function Y(r) {
12
- try {
13
- const s = $(r, "utf-8"), n = JSON.parse(s);
14
- return typeof n?.lastCheck != "string" || typeof n?.latestVersion != "string" ? null : n;
15
- } catch {
16
- return null;
17
- }
18
- }
19
- function K(r, s) {
20
- return Date.now() - new Date(r.lastCheck).getTime() < s;
21
- }
22
- function C(r, s) {
23
- let n = !1;
24
- process.on("beforeExit", () => {
25
- n || (n = !0, process.stderr.write(`
26
- Update available: ${r} → ${s}
27
- `), process.stderr.write(`Run: npm i -g gennady@latest
28
-
29
- `));
30
- });
31
- }
32
- function ye(r, s) {
33
- if (process.env.GENNADY_NO_UPDATE_CHECK === "1" || process.argv.includes("--no-update-check")) {
34
- process.env.GENNADY_DEBUG === "1" && process.stderr.write(
35
- `[update-check] skipped: opt-out (GENNADY_NO_UPDATE_CHECK or --no-update-check)
36
- `
37
- );
38
- return;
39
- }
40
- if (process.env.CI === "true" || process.env.CONTINUOUS_INTEGRATION === "true" || process.env.NODE_ENV === "test") {
41
- process.env.GENNADY_DEBUG === "1" && process.stderr.write(`[update-check] skipped: CI/test environment
42
- `);
43
- return;
44
- }
45
- const n = Number(process.env.GENNADY_UPDATE_CHECK_INTERVAL) || I, e = V(), a = d(e, H);
46
- F(e, { recursive: !0 });
47
- const t = Y(a);
48
- if (t && K(t, n)) {
49
- t.latestVersion && t.latestVersion !== r.version && (process.stderr.isTTY || s?.skipNotificationIfNoTty === !1) && C(r.version, t.latestVersion);
50
- return;
51
- }
52
- const i = d(G(T(import.meta.url)), U);
53
- O(
54
- process.execPath,
55
- [i, r.name, r.version, a, String(W)],
56
- {
57
- stdio: "ignore"
58
- }
59
- ).unref(), t?.latestVersion && t.latestVersion !== r.version && (process.stderr.isTTY || s?.skipNotificationIfNoTty === !1) && C(r.version, t.latestVersion);
60
- }
61
- const h = ["plain", "nocolor", "noColor", "no-color", "color=no", "color=never"].some(
62
- (r) => process.argv.includes(`-${r}`) || process.argv.includes(`--${r}`)
63
- ), p = {
64
- // Modifiers
65
- reset: "\x1B[0m",
66
- bold: "\x1B[1m",
67
- dim: "\x1B[2m",
68
- italic: "\x1B[3m",
69
- underline: "\x1B[4m",
70
- overline: "\x1B[53m",
71
- inverse: "\x1B[7m",
72
- hidden: "\x1B[8m",
73
- strikethrough: "\x1B[9m",
74
- // Colors (foreground)
75
- black: "\x1B[30m",
76
- red: "\x1B[31m",
77
- green: "\x1B[32m",
78
- yellow: "\x1B[33m",
79
- blue: "\x1B[34m",
80
- magenta: "\x1B[35m",
81
- cyan: "\x1B[36m",
82
- white: "\x1B[37m",
83
- gray: "\x1B[90m",
84
- redBright: "\x1B[91m",
85
- greenBright: "\x1B[92m",
86
- yellowBright: "\x1B[93m",
87
- blueBright: "\x1B[94m",
88
- magentaBright: "\x1B[95m",
89
- cyanBright: "\x1B[96m",
90
- whiteBright: "\x1B[97m",
91
- // Background colors
92
- bgBlack: "\x1B[40m",
93
- bgRed: "\x1B[41m",
94
- bgGreen: "\x1B[42m",
95
- bgYellow: "\x1B[43m",
96
- bgBlue: "\x1B[44m",
97
- bgMagenta: "\x1B[45m",
98
- bgCyan: "\x1B[46m",
99
- bgWhite: "\x1B[47m",
100
- bgGray: "\x1B[100m",
101
- bgRedBright: "\x1B[101m",
102
- bgGreenBright: "\x1B[102m",
103
- bgYellowBright: "\x1B[103m",
104
- bgBlueBright: "\x1B[104m",
105
- bgMagentaBright: "\x1B[105m",
106
- bgCyanBright: "\x1B[106m",
107
- bgWhiteBright: "\x1B[107m"
108
- };
109
- function D(r = []) {
110
- const s = (n) => h ? n : r.join("") + n + p.reset;
111
- return new Proxy(s, {
112
- get(n, e) {
113
- if (e === "toString")
114
- return () => h ? "%s" : r.join("") + "%s" + p.reset;
115
- if (e in p) {
116
- const a = p[e];
117
- return D(h ? [] : [...r, a].filter(Boolean));
118
- }
119
- },
120
- apply(n, e, a) {
121
- const t = a[0] ?? "";
122
- return h ? t : r.join("") + t + p.reset;
123
- }
124
- });
125
- }
126
- const ke = D(), xe = (r, s = {}) => {
127
- const n = { _: [] };
128
- return r.slice(2).forEach((a) => {
129
- if (a.startsWith("-")) {
130
- const t = a.replace(/^-+/, ""), [i, o] = t.split("=");
131
- for (const [c, l] of Object.entries(s))
132
- if (Array.isArray(l) && i && l.includes(i)) {
133
- const g = o ? o.replace(/^"|"$/g, "") : !0;
134
- c in n ? (Array.isArray(n[c]) || (n[c] = [n[c]]), n[c].push(g)) : n[c] = g;
135
- break;
136
- }
137
- } else
138
- n._.push(a);
139
- }), n;
140
- }, J = {
141
- js: "JavaScript",
142
- jsx: "JavaScript",
143
- ts: "TypeScript",
144
- tsx: "TypeScript",
145
- java: "Java",
146
- py: "Python",
147
- c: "C",
148
- cpp: "C++",
149
- cs: "C#",
150
- rb: "Ruby",
151
- php: "PHP",
152
- go: "Go",
153
- swift: "Swift",
154
- m: "Objective-C",
155
- mm: "Objective-C++",
156
- kt: "Kotlin",
157
- sh: "Shell",
158
- bash: "Shell",
159
- html: "HTML",
160
- css: "CSS",
161
- less: "Less",
162
- scss: "SCSS",
163
- sass: "Sass",
164
- md: "Markdown",
165
- mdc: "Markdown"
166
- }, A = (r) => J[r] ?? void 0, Ee = () => {
167
- try {
168
- return R("osascript -e 'user locale of (get system info)'").toString().trim().toLowerCase().split("_").filter((n) => n !== "en" && n !== "us")[0] ?? "en";
169
- } catch {
170
- return "en";
171
- }
172
- }, _ = (r) => {
173
- const s = r.match(/[\p{L}\p{N}_]+|[^\s\p{L}\p{N}_]/gu);
174
- return s ? s.length : 0;
175
- }, X = [
176
- "^package\\.json",
177
- "^tsconfig\\.json",
178
- "^babel\\.config\\.json",
179
- "^\\.pnpmfile\\.cjs",
180
- "^\\.yarnrc(?:\\.(?:yml|yaml))?",
181
- "^go\\.(?:mod|sum)",
182
- "^\\.env(?:\\.[\\w]+)?",
183
- "^\\..+",
184
- ".*\\.(?:yml|yaml|rc|ini|conf)"
185
- ], z = [
186
- "^package-lock\\.json",
187
- "^npm-shrinkwrap\\.json",
188
- "^yarn(?:-lock)?\\.(?:yaml|yml|toml)",
189
- "^pnpm-lock\\.yaml",
190
- "^composer\\.lock",
191
- "^podfile\\.lock",
192
- "^go\\.sum",
193
- "^gemfile\\.lock"
194
- ], q = {
195
- doc: /\.(md|markdown|txt|rst)$/i,
196
- cfg: new RegExp(X.join("|"), "i"),
197
- img: /\.(png|jpe?g|gif|svg|bmp|tiff|ico)$/i,
198
- css: /\.(css|less|scss|sass|styl)$/i,
199
- html: /\.(html?)$/i,
200
- code: /\.(js|jsx|ts|tsx|java|py|c|cpp|cs|rb|php|go|swift|m|mm|kt|sh|bash)$/i,
201
- bin: /^(exe|dll|so|bin)\b/i,
202
- lock: new RegExp(z.join("|"), "i"),
203
- json: /\.json$/i
204
- }, B = (r, s) => {
205
- if (s?.extra && Array.isArray(s.extra)) {
206
- for (const e of s.extra)
207
- if (/^Binary files? /i.test(e) || /GIT binary patch/i.test(e))
208
- return "bin";
209
- }
210
- return Object.entries(q).find(([, e]) => e.test(r))?.[0] ?? "other";
211
- }, Q = (r) => {
212
- const s = r.split(`
213
- `), n = [];
214
- let e = null, a = null;
215
- if (s.forEach((t) => {
216
- if (t.startsWith("diff --git")) {
217
- if (e) {
218
- e.diff.tokens = e.diff.hunks.reduce(
219
- (g, L) => g + L.tokens,
220
- 0
221
- ), e.tokens = e.diff.tokens;
222
- const l = e.filename.match(/\.([^.]+)$/);
223
- e.ext = l?.[1]?.toLowerCase() ?? "", e.category = B(
224
- e.filename,
225
- e.metadata
226
- ), e.programmingLanguage = A(e.ext), n.push(e);
227
- }
228
- const i = t.match(/^diff --git a\/(.+?) b\/(.+)$/), o = i?.[1] ?? null;
229
- e = {
230
- isNew: !1,
231
- isDeleted: !1,
232
- isRenamed: !1,
233
- filename: i?.[2] ?? null ?? "",
234
- oldFilename: o ?? null,
235
- newFileMode: null,
236
- deletedFileMode: null,
237
- diff: {
238
- tokens: 0,
239
- hunks: []
240
- },
241
- tokens: 0,
242
- metadata: {},
243
- ext: "",
244
- category: "other",
245
- programmingLanguage: void 0
246
- }, a = null;
247
- } else if (e && t.startsWith("new file mode")) {
248
- const i = t.split(" ");
249
- e.isNew = !0, e.newFileMode = i[3] ?? null, e.metadata.newFileMode = e.newFileMode;
250
- } else if (e && t.startsWith("deleted file mode")) {
251
- const i = t.split(" ");
252
- e.isDeleted = !0, e.deletedFileMode = i[3] ?? null, e.metadata.deletedFileMode = e.deletedFileMode;
253
- } else if (e && t.startsWith("old mode")) {
254
- const i = t.split(" ");
255
- e.metadata.oldMode = i[2] ?? null;
256
- } else if (e && t.startsWith("new mode")) {
257
- const i = t.split(" ");
258
- e.metadata.newMode = i[2] ?? null;
259
- } else if (e && t.startsWith("similarity index")) {
260
- const i = t.split(" ");
261
- e.metadata.similarityIndex = i[2] ?? null;
262
- } else if (e && t.startsWith("rename from")) {
263
- const i = t.substring(11).trim();
264
- e.isRenamed = !0, e.oldFilename = i, e.metadata.renameFrom = i;
265
- } else if (e && t.startsWith("rename to")) {
266
- const i = t.substring(9).trim();
267
- e.isRenamed = !0, e.filename = i, e.metadata.renameTo = i;
268
- } else e && t.startsWith("index") ? e.metadata.index = t.substring(5).trim() : e && (t.startsWith("--- ") || t.startsWith("+++ ")) ? t.startsWith("--- ") ? e.metadata.oldFileMarker = t : e.metadata.newFileMarker = t : e && t.startsWith("@@") ? (a = {
269
- header: t,
270
- changes: [t],
271
- tokens: _(t)
272
- }, e.diff.hunks.push(a)) : a && (t.startsWith("+") || t.startsWith("-") || t.startsWith(" ")) ? (a.changes.push(t), a.tokens += _(t)) : e && (Array.isArray(e.metadata.extra) || (e.metadata.extra = []), e.metadata.extra.push(t));
273
- }), e) {
274
- const t = e, i = t.filename.match(/\.([^.]+)$/);
275
- t.diff.tokens = t.diff.hunks.reduce(
276
- (o, c) => o + c.tokens,
277
- 0
278
- ), t.tokens = t.diff.tokens, t.ext = i?.[1]?.toLowerCase() ?? "", t.category = B(t.filename, t.metadata), t.programmingLanguage = A(t.ext), n.push(t);
279
- }
280
- return n;
281
- }, f = (r) => {
282
- try {
283
- return R(r, { encoding: "utf-8" });
284
- } catch (s) {
285
- return w.error("[execSyncSafe] [running → failed] Command failed", { cause: s }), "";
286
- }
287
- }, S = (r) => /\.(test|spec)s?\./.test(r), Z = () => f("git branch --list 2>/dev/null")?.match(/\s*\*?\s*(master|main)$/m)?.[1] ?? "master", we = () => f("git rev-parse --abbrev-ref HEAD 2>/dev/null").trim() || "HEAD", be = () => {
288
- const s = (f("git config --get remote.origin.url 2>/dev/null").trim() || f("git remote get-url origin 2>/dev/null").trim() || "").trim();
289
- if (!s) return null;
290
- if (/^[a-z]+:\/\//i.test(s))
291
- try {
292
- const e = new URL(s), a = (e.hostname || "").toLowerCase(), t = (e.protocol || "").replace(/:$/, "").toLowerCase(), i = (e.pathname || "").replace(/^\/+/, "").replace(/\.git$/i, "");
293
- return !a || !i ? null : { host: a, project: i, scheme: t };
294
- } catch (e) {
295
- w.debug("[getGitRemote] [parsing → skip] URL parse failed", { cause: e });
296
- }
297
- const n = s.match(/^[\w.-]+@([^:\/]+)[:\/](.+)$/);
298
- if (n) {
299
- const e = (n[1] || "").toLowerCase(), a = (n[2] || "").replace(/^\/+/, "").replace(/\.git$/i, ""), t = "ssh";
300
- return !e || !a ? null : { host: e, project: a, scheme: t };
301
- }
302
- return null;
303
- }, ee = () => {
304
- try {
305
- const r = f(`git rev-list --count HEAD ^${Z()} 2>/dev/null`);
306
- return parseInt(r, 10) || 0;
307
- } catch (r) {
308
- return w.debug("[getGitCommitCount] [counting → fallback] Using 0", { cause: r }), 0;
309
- }
310
- }, te = (r) => f(r ? `git diff ${r}` : "git diff HEAD"), Ce = (r) => {
311
- const s = te(r), n = Q(s).sort((o, c) => o.tokens - c.tokens), e = n.filter(
312
- (o) => !o.isDeleted && !o.isRenamed && !S(o.filename) && (o.category === "config" || o.programmingLanguage)
313
- );
314
- e.length || e.push(
315
- ...n.filter(
316
- (o) => !o.isDeleted && !o.isRenamed && (o.category === "doc" || S(o.filename))
317
- )
318
- );
319
- const a = e.reduce((o, c) => o + c.tokens, 0), t = e.at(-1)?.tokens ?? 0, i = [
320
- ...new Set(e.map((o) => o.programmingLanguage).filter(Boolean))
321
- ];
322
- return {
323
- diff: s,
324
- parsedDiff: n,
325
- parsedCodeDiff: e,
326
- parsedCodeTokens: a,
327
- parsedCodeChunkMaxTokens: t,
328
- programmingLanguages: i,
329
- commitCount: ee()
330
- };
331
- }, re = (r) => {
332
- if (Array.isArray(r) && r.length === 2) {
333
- const s = r[1];
334
- if (s === null)
335
- return r[0];
336
- throw s instanceof Error ? s : new TypeError(`[UNGUARD_ERROR_TYPE] Error "${s}"`, { cause: s });
337
- }
338
- throw new SyntaxError(
339
- "[UNGUARD_ERROR_SYNTAX] Invalid input: not a valid [result, error] tuple.",
340
- { cause: r }
341
- );
342
- }, Ae = async (r) => {
343
- const s = await r;
344
- return re(s);
345
- }, v = "</think>", _e = (r) => {
346
- const s = String(r ?? "").split(v).slice(-1).join(v).trim();
347
- return /^(Хорошо,|Okay,)/.test(s) ? s.split(`
348
-
349
-
350
- `).slice(-1).join(`
351
-
352
-
353
- `).trim() : s;
354
- };
355
- class E {
356
- /** @purpose Default configuration filename. */
357
- static DEFAULT_FILENAME = ".gennadyrc";
358
- /**
359
- * @purpose Create GennadyRc instances for current directory and HOME (lookup priority).
360
- * @returns Array of two instances: [cwd, HOME].
361
- * @sideEffect IO: file read at constructor.
362
- */
363
- static getDefaults() {
364
- return [process.cwd(), process.env.HOME].map((s) => new E(s));
365
- }
366
- /** @purpose Full path to the loaded rc config file. */
367
- _filename = "";
368
- /** @purpose Parsed configuration data with model list. */
369
- _data = {
370
- models: []
371
- };
372
- /** @purpose Load/parse error if config is invalid, null otherwise. */
373
- _error = null;
374
- /**
375
- * @purpose Load and parse Gennady RC config file from a directory.
376
- * @param [dir] Directory to look for the rc file in (defaults to cwd).
377
- * @param [name] Config filename (defaults to .gennadyrc).
378
- */
379
- constructor(s = process.cwd(), n = E.DEFAULT_FILENAME) {
380
- this._filename = P(s, n);
381
- try {
382
- if (M(this._filename)) {
383
- const e = JSON.parse($(this._filename).toString());
384
- Array.isArray(e) ? this._data.models = e : e && typeof e == "object" && Array.isArray(e.models) ? this._data = {
385
- ...this._data,
386
- ...e
387
- } : this._error = new Error(
388
- `[GENNADY_RC_ERROR_CONFIG] Invalid "${this._filename}" config data`,
389
- { cause: e }
390
- );
391
- }
392
- } catch (e) {
393
- this._error = new Error(`[GENNADY_RC_ERROR_PARSE] Read "${this._filename}" config failed`, {
394
- cause: e
395
- });
396
- }
397
- }
398
- /**
399
- * @purpose Check that configuration was successfully loaded and recognized.
400
- * @returns true if no error; false on parse error or invalid data.
401
- */
402
- isValid() {
403
- return !this._error;
404
- }
405
- /**
406
- * @purpose Get list of models from loaded rc.
407
- * @returns Array of RcModel (empty on error or missing file).
408
- */
409
- getModels() {
410
- return this._data.models;
411
- }
412
- /**
413
- * @purpose Get load/parse error if one occurred.
414
- * @returns Error or null on successful load.
415
- */
416
- getError() {
417
- return this._error;
418
- }
419
- }
420
- function Be(r) {
421
- const s = String(r).match(/<message[\s\S]*?>[\s\S]*?<\/message>/)?.[0];
422
- if (!s)
423
- return null;
424
- const n = (o) => s.match(o)?.[1] ?? "", e = n(/type="([^"]+)"/), a = n(/icon="([^"]+)"/), t = n(/<subject>([\s\S]*?)<\/subject>/), i = n(/<description>([\s\S]*?)<\/description>/).replace(/\n\s+-/g, `
425
- -`);
426
- return {
427
- type: e,
428
- icon: a,
429
- subject: t?.trim() || null,
430
- description: i?.trim() || null
431
- };
432
- }
433
- function x(r) {
434
- return r ? String(r).replace(/[<>&'"]/g, (s) => {
435
- switch (s) {
436
- case "<":
437
- return "&lt;";
438
- case ">":
439
- return "&gt;";
440
- case "&":
441
- return "&amp;";
442
- case "'":
443
- return "&apos;";
444
- case '"':
445
- return "&quot;";
446
- default:
447
- return s;
448
- }
449
- }) : "";
450
- }
451
- function N(r, s = 0) {
452
- const n = " ".repeat(s), { tag: e, attrs: a, children: t } = r;
453
- let i = "";
454
- if (a && (i = Object.entries(a).filter(([, c]) => c != null).map(([c, l]) => ` ${c}="${x(String(l))}"`).join("")), t == null)
455
- return `${n}<${e}${i} />`;
456
- if (Array.isArray(t) && t.length === 0)
457
- return `${n}<${e}${i} />`;
458
- let o = "";
459
- return Array.isArray(t) ? t.length > 0 && typeof t[0] == "string" ? o = t.map((l) => x(l)).join(`
460
- `) : o = `
461
- ` + t.map((l) => N(l, s + 1)).join(`
462
- `) + `
463
- ` + n : typeof t == "string" ? o = x(t) : "cdata" in t ? o = `<![CDATA[${String(t.cdata).replaceAll("]]>", "]]]]><![CDATA[>")}]]>` : o = `
464
- ` + N(t, s + 1) + `
465
- ` + n, `${n}<${e}${i}>${o}</${e}>`;
466
- }
467
- function Se(r) {
468
- const s = [
469
- "ai.knowledge.md",
470
- "ai/ai.knowledge.md"
471
- ], n = [];
472
- for (const e of s) {
473
- const a = m.join(r, e);
474
- try {
475
- u.existsSync(a) && u.statSync(a).isFile() && n.push(e);
476
- } catch {
477
- }
478
- }
479
- return n.length === 0 ? "" : `**MUST READ PROJECT KNOWLEDGE FILES**: ${n.join(", ")}.`;
480
- }
481
- const se = [
482
- {
483
- kind: "marker",
484
- relativePath: "go.mod",
485
- commands: ["go test ./...", "go vet ./...", "go fmt ./..."]
486
- },
487
- {
488
- kind: "npm-package-json",
489
- scriptGroups: [
490
- {
491
- preferredNames: [
492
- "test",
493
- "test:run",
494
- "test:ci",
495
- "test:app",
496
- "mc:test",
497
- "unit",
498
- "jest",
499
- "vitest"
500
- ],
501
- fallbackPatterns: [/(^|:)test($|:)/i, /(^|:)unit($|:)/i, /(^|:)spec($|:)/i]
502
- },
503
- {
504
- preferredNames: ["lint:ci", "lint", "eslint", "stylelint", "format:check"],
505
- fallbackPatterns: [/(^|:)(lint|eslint|stylelint)($|:)/i]
506
- },
507
- {
508
- preferredNames: ["type-check", "typecheck", "check"],
509
- fallbackPatterns: [/(^|:)(typecheck|type-check|check)($|:)/i]
510
- }
511
- ],
512
- maxCommands: 5
513
- },
514
- {
515
- kind: "marker",
516
- relativePath: "Cargo.toml",
517
- commands: ["cargo test", "cargo clippy"]
518
- }
519
- ];
520
- function ne(r, s) {
521
- const n = m.join(r, s);
522
- try {
523
- return u.existsSync(n) && u.statSync(n).isFile();
524
- } catch {
525
- return !1;
526
- }
527
- }
528
- function ae(r, s) {
529
- const n = r.toLowerCase(), e = s.toLowerCase();
530
- return /(^|:|-)watch($|:|-)/i.test(n) ? !0 : [
531
- /(^|\s)--watch(?:[=\s]|$)/i,
532
- /(^|\s)--watchall(?:[=\s]|$)/i,
533
- /(^|\s)watch(?:\s|$)/i,
534
- /(^|\s)nodemon(?:\s|$)/i
535
- ].some((t) => t.test(e));
536
- }
537
- function ie(r, s, n) {
538
- const e = Object.entries(r).filter(
539
- ([a, t]) => !n.has(a) && !ae(a, t)
540
- );
541
- for (const a of s.preferredNames)
542
- if (e.some(([t]) => t === a))
543
- return a;
544
- for (const [a] of e)
545
- if (s.fallbackPatterns.some((t) => t.test(a)))
546
- return a;
547
- return null;
548
- }
549
- function oe(r, s) {
550
- const n = m.join(r, "package.json");
551
- let e;
552
- try {
553
- if (!u.existsSync(n) || !u.statSync(n).isFile())
554
- return null;
555
- e = u.readFileSync(n, "utf-8");
556
- } catch {
557
- return null;
558
- }
559
- let a;
560
- try {
561
- a = JSON.parse(e);
562
- } catch {
563
- return null;
564
- }
565
- const t = a.scripts;
566
- if (!t || typeof t != "object")
567
- return null;
568
- const i = [], o = /* @__PURE__ */ new Set();
569
- for (const c of s.scriptGroups) {
570
- const l = ie(t, c, o);
571
- if (l && (i.push(`npm run ${l}`), o.add(l)), i.length >= s.maxCommands)
572
- break;
573
- }
574
- return i.length === 0 ? null : i.slice(0, s.maxCommands);
575
- }
576
- function ce(r) {
577
- for (const s of se) {
578
- if (s.kind === "marker") {
579
- if (ne(r, s.relativePath))
580
- return [...s.commands];
581
- continue;
582
- }
583
- if (s.kind === "npm-package-json") {
584
- const n = oe(r, s);
585
- if (n != null && n.length > 0)
586
- return n;
587
- }
588
- }
589
- return [];
590
- }
591
- function le(r) {
592
- return r.map((s) => `\`${s}\``).join(", ");
593
- }
594
- function ve(r) {
595
- const s = ce(r);
596
- if (s.length === 0)
597
- return {
598
- axiomHint: "как в README или CI принято проверять код (тесты, линтер, типы). Не подменяй это тяжёлой production-сборкой или публикацией, если это явно не описано как проверка",
599
- toolsExample: "команды из `package.json` → `scripts`, из Makefile или из CI-шагов, которые относятся к качеству кода; сначала прочитай README",
600
- verifyStep: "Прочитай README и при наличии — конфиг CI: какие команды запускают тесты, линтер и проверку типов. Выполни их из корня репозитория. Не запускай `build`/`publish`/полный `ci`, если не уверен, что это нужно для проверки изменений; при сомнении спроси пользователя."
601
- };
602
- const n = le(s);
603
- return {
604
- axiomHint: `\`${s[0]}\` или следующую команду из того же набора проверок`,
605
- toolsExample: n,
606
- verifyStep: `Из корня репозитория выполни: ${n}. Не добавляй \`build\`, полный \`ci\` или публикацию, если они не перечислены здесь и не описаны в README как обязательная проверка.`
607
- };
608
- }
609
- const y = "ai/agents";
610
- function j(r) {
611
- return u.existsSync(r) ? u.promises.readFile(r, "utf-8") : null;
612
- }
613
- function me(r) {
614
- let s = r;
615
- for (; ; ) {
616
- const n = m.join(s, "package.json");
617
- if (u.existsSync(n))
618
- return s;
619
- const e = m.dirname(s);
620
- if (e === s)
621
- return null;
622
- s = e;
623
- }
624
- }
625
- async function Ne(r) {
626
- const s = m.dirname(T(import.meta.url)), n = m.join(process.cwd(), y, r), e = j(n);
627
- if (e)
628
- return e;
629
- const a = me(s), t = [];
630
- a ? (t.push(m.join(a, y, r)), t.push(m.join(a, "dist", y, r))) : t.push(
631
- m.join(s, "../../../../../../dist", y, r)
632
- );
633
- for (const i of t) {
634
- const o = j(i);
635
- if (o)
636
- return o;
637
- }
638
- throw new Error(`Не найден файл шаблона ${r}.`, {
639
- cause: {
640
- projectOverridePath: n,
641
- packageCandidates: t
642
- }
643
- });
644
- }
645
- export {
646
- E as G,
647
- be as a,
648
- we as b,
649
- ye as c,
650
- N as d,
651
- f as e,
652
- ve as f,
653
- Ce as g,
654
- Se as h,
655
- A as i,
656
- Ee as j,
657
- Q as k,
658
- Ne as l,
659
- re as m,
660
- xe as p,
661
- _e as r,
662
- ke as s,
663
- Ae as u,
664
- Be as x
665
- };