gennady 0.8.4-draft.2 → 0.8.4-draft.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.
Files changed (146) hide show
  1. package/ai/directives/sdd-v2/root.directive.xml +36 -3
  2. package/ai/directives/sdd-v2/router.directive.xml +22 -1
  3. package/ai/kit/templates/sdd-v2/root.directive.hbs +11 -3
  4. package/ai/kit/templates/sdd-v2/router.directive.hbs +22 -1
  5. package/ai/skills/agent-inbox/SKILL.md +1 -1
  6. package/ai/skills/sdd/SKILL.md +5 -3
  7. package/ai/skills/sdd-audit/SKILL.md +5 -2
  8. package/ai/skills/sdd-check/SKILL.md +2 -2
  9. package/ai/skills/sdd-code-review/SKILL.md +4 -1
  10. package/ai/skills/sdd-critic/SKILL.md +5 -2
  11. package/ai/skills/sdd-execute/SKILL.md +5 -2
  12. package/ai/skills/sdd-reconcile/SKILL.md +5 -2
  13. package/ai/skills/sdd-scaffold/SKILL.md +5 -2
  14. package/dist/ai/directives/sdd-v2/root.directive.xml +36 -3
  15. package/dist/ai/directives/sdd-v2/router.directive.xml +22 -1
  16. package/dist/ai/kit/templates/sdd-v2/root.directive.hbs +11 -3
  17. package/dist/ai/kit/templates/sdd-v2/router.directive.hbs +22 -1
  18. package/dist/ai/skills/agent-inbox/SKILL.md +1 -1
  19. package/dist/ai/skills/sdd/SKILL.md +5 -3
  20. package/dist/ai/skills/sdd-audit/SKILL.md +5 -2
  21. package/dist/ai/skills/sdd-check/SKILL.md +2 -2
  22. package/dist/ai/skills/sdd-code-review/SKILL.md +4 -1
  23. package/dist/ai/skills/sdd-critic/SKILL.md +5 -2
  24. package/dist/ai/skills/sdd-execute/SKILL.md +5 -2
  25. package/dist/ai/skills/sdd-reconcile/SKILL.md +5 -2
  26. package/dist/ai/skills/sdd-scaffold/SKILL.md +5 -2
  27. package/dist/chunks/{classify-mr-stage.logic-BiCHTmPp.js → classify-mr-stage.logic-CazmQDwZ.js} +2 -2
  28. package/dist/chunks/{config-index-9VHWSDQD.js → config-index-DU8-FEjq.js} +1 -1
  29. package/dist/chunks/{devtools-b0DwO1x_.js → devtools-1JmXJjUG.js} +1 -1
  30. package/dist/chunks/{eval.cmd-CwNPaNJd.js → eval.cmd-CBANnOFG.js} +1 -1
  31. package/dist/chunks/{help-D5cXtdMI.js → help-DVloaFF5.js} +1 -1
  32. package/dist/chunks/{index-BVnJEutp.js → index-2xhpqJtd.js} +2 -2
  33. package/dist/chunks/{index-RR5OUxje.js → index-AxsLBUAx.js} +14 -14
  34. package/dist/chunks/{index-CUkeTGqM.js → index-B7sydB0W.js} +2 -2
  35. package/dist/chunks/{index-CMCn9ErF.js → index-BKxk4zOz.js} +2 -2
  36. package/dist/chunks/{index-Db13NlHh.js → index-BNMmX_Mv.js} +21 -21
  37. package/dist/chunks/{index-CmQO-RmM.js → index-BPzldG3a.js} +2 -2
  38. package/dist/chunks/{index-BOQl7F_Z.js → index-BQlFDvKW.js} +2 -2
  39. package/dist/chunks/{index-RzkvIfJQ.js → index-Baq7RL1L.js} +3 -3
  40. package/dist/chunks/index-BbPiwvY9.js +2 -0
  41. package/dist/chunks/{index-ClJLPEUB.js → index-BreGNLJ_.js} +1 -1
  42. package/dist/chunks/{index-DjSafAkN.js → index-BslPwGtM.js} +2 -2
  43. package/dist/chunks/{index-DiMFxS0z.js → index-BtCUN2fZ.js} +16 -16
  44. package/dist/chunks/{index-CS0VbiLD.js → index-C10-EOdB.js} +1 -1
  45. package/dist/chunks/{index-2BOEcJIa.js → index-C4JmZLaj.js} +2 -2
  46. package/dist/chunks/index-CA-JKLr4.js +2 -0
  47. package/dist/chunks/{index-43GiH--T.js → index-CG_jJZVu.js} +2 -2
  48. package/dist/chunks/{index-BdkFKsMm.js → index-CGyP2uDE.js} +3 -3
  49. package/dist/chunks/{index-BOKv0b01.js → index-CPl1s9XJ.js} +2 -2
  50. package/dist/chunks/{index-DIPrBH-4.js → index-CSxE4cEm.js} +9 -9
  51. package/dist/chunks/{index-Cm7U1-fU.js → index-CWR5EzXx.js} +2 -2
  52. package/dist/chunks/{index-BwN5llCR.js → index-Camql5kL.js} +2 -2
  53. package/dist/chunks/{index-Drh-J9O7.js → index-CdUiTipO.js} +7 -7
  54. package/dist/chunks/{index-Cn029KTN.js → index-Crg61pK5.js} +2 -2
  55. package/dist/chunks/{index-Dja2O-hV.js → index-Cv9ZYXso.js} +1 -1
  56. package/dist/chunks/{index-Ck8v_Gv7.js → index-D7ADMlG3.js} +1 -1
  57. package/dist/chunks/index-DNl2gC8l.js +158 -0
  58. package/dist/chunks/{index-BYIzl-Ut.js → index-DVJA0qVm.js} +36 -36
  59. package/dist/chunks/{index-BAEIZVx0.js → index-DcFJhkY1.js} +2 -2
  60. package/dist/chunks/{index-Dx5_CB2E.js → index-DdEd-L3x.js} +2 -2
  61. package/dist/chunks/{index-DVmqMmgb.js → index-DkGA1eW_.js} +32 -32
  62. package/dist/chunks/{index-3k7mPX1e.js → index-Dnwxlti3.js} +1 -1
  63. package/dist/chunks/{index-CrizvxOJ.js → index-DqdEJDi2.js} +2 -2
  64. package/dist/chunks/{index-BIPebtDl.js → index-DqiwmBt4.js} +1 -1
  65. package/dist/chunks/{index-DS4MhAw-.js → index-PfuqBWjY.js} +2 -2
  66. package/dist/chunks/{index-BmFT1Kx2.js → index-SVP6RfVl.js} +2 -2
  67. package/dist/chunks/{index-CDxV4b81.js → index-Y8wu48Q0.js} +1 -1
  68. package/dist/chunks/index-_ewSKppm.js +2 -0
  69. package/dist/chunks/{index-Ctcr_Qeu.js → index-aBVtCLIJ.js} +2 -2
  70. package/dist/chunks/index-dNdz9j6d.js +2 -0
  71. package/dist/chunks/{index-BFUkVkSo.js → index-gskOpu3H.js} +16 -16
  72. package/dist/chunks/{index-CXpkT25O.js → index-pBSLMn5Q.js} +3 -3
  73. package/dist/chunks/index-sqPhX5Io.js +2 -0
  74. package/dist/chunks/{index-BzmR4Es2.js → index-vfrjhUD1.js} +39 -39
  75. package/dist/chunks/{index-J2NvjjDV.js → index-xGF5XC_i.js} +2 -2
  76. package/dist/chunks/{run-review-command.logic-CA2Rjymb.js → run-review-command.logic-B9GoCxh-.js} +24 -24
  77. package/dist/chunks/{serve.cmd-RxYS6WoN.js → serve.cmd-UXkaeaPI.js} +2 -2
  78. package/dist/chunks/{services-Csd556Tv.js → services-BYCeGBlO.js} +4 -4
  79. package/dist/chunks/{shared-B5CTGvpG.js → shared-B3cXL2Np.js} +1178 -1117
  80. package/dist/chunks/{stats-index-BLztvK69.js → stats-index-AIAnnp9S.js} +2 -2
  81. package/dist/gennady.js +46 -46
  82. package/dist/index.js +4 -4
  83. package/dist/shared/sdd/ladder.d.ts +42 -0
  84. package/dist/shared/sdd/module-specs.d.ts +7 -0
  85. package/dist/shared/sdd/tracker.d.ts +9 -0
  86. package/package.json +1 -1
  87. package/dist/chunks/classify-mr-stage.logic-ClmhzQPQ.js +0 -53
  88. package/dist/chunks/config-index-RFeqlDWs.js +0 -104
  89. package/dist/chunks/devtools-p8tmPuLn.js +0 -79
  90. package/dist/chunks/eval.cmd-ewU5lcUY.js +0 -34
  91. package/dist/chunks/help-DzGnMNi2.js +0 -7
  92. package/dist/chunks/index--AXFi0ty.js +0 -89
  93. package/dist/chunks/index-64TSesTc.js +0 -186
  94. package/dist/chunks/index-9Gv5trS_.js +0 -125
  95. package/dist/chunks/index-B1DQIryA.js +0 -2
  96. package/dist/chunks/index-B1PiBeQ3.js +0 -2
  97. package/dist/chunks/index-B4rzuhkt.js +0 -183
  98. package/dist/chunks/index-B97HJjkg.js +0 -159
  99. package/dist/chunks/index-BF6qypm0.js +0 -131
  100. package/dist/chunks/index-BK84ZQsh.js +0 -128
  101. package/dist/chunks/index-BRVIirjj.js +0 -141
  102. package/dist/chunks/index-BXnryCGW.js +0 -96
  103. package/dist/chunks/index-BaZm7Otb.js +0 -2
  104. package/dist/chunks/index-Bhk746A2.js +0 -129
  105. package/dist/chunks/index-Bi-eY_dY.js +0 -164
  106. package/dist/chunks/index-BjumU69g.js +0 -2
  107. package/dist/chunks/index-BkWXcpXU.js +0 -16979
  108. package/dist/chunks/index-BlY4jQIA.js +0 -168
  109. package/dist/chunks/index-C0iy7GxD.js +0 -140
  110. package/dist/chunks/index-CCBTXczb.js +0 -56
  111. package/dist/chunks/index-CDAfkSrr.js +0 -2
  112. package/dist/chunks/index-CDHymWzC.js +0 -102
  113. package/dist/chunks/index-CNfXJAao.js +0 -2
  114. package/dist/chunks/index-CQsae1nq.js +0 -207
  115. package/dist/chunks/index-CVmd0prf.js +0 -2
  116. package/dist/chunks/index-CZuTNeNm.js +0 -2
  117. package/dist/chunks/index-CasNhhrL.js +0 -96
  118. package/dist/chunks/index-Ce7GWENF.js +0 -377
  119. package/dist/chunks/index-Cf-02TAg.js +0 -265
  120. package/dist/chunks/index-CfjQWSrh.js +0 -52
  121. package/dist/chunks/index-Chr7gBBz.js +0 -443
  122. package/dist/chunks/index-Ci875Zlg.js +0 -346
  123. package/dist/chunks/index-CwA6RzIB.js +0 -3793
  124. package/dist/chunks/index-D1dI63ej.js +0 -46
  125. package/dist/chunks/index-DCS32A2i.js +0 -663
  126. package/dist/chunks/index-DOFoNxvb.js +0 -131
  127. package/dist/chunks/index-DVkCEuws.js +0 -136
  128. package/dist/chunks/index-DkadaaXq.js +0 -658
  129. package/dist/chunks/index-Dn11CLtk.js +0 -7
  130. package/dist/chunks/index-Do3spFJT.js +0 -340
  131. package/dist/chunks/index-DrFRZ0Yg.js +0 -2
  132. package/dist/chunks/index-DvEQhXi2.js +0 -1054
  133. package/dist/chunks/index-GiS0x6jg.js +0 -90
  134. package/dist/chunks/index-NacvqeQ5.js +0 -69
  135. package/dist/chunks/index-RNJhFzdr.js +0 -227
  136. package/dist/chunks/index-R_vUB6CL.js +0 -2
  137. package/dist/chunks/index-TQft1s5H.js +0 -20
  138. package/dist/chunks/index-ZmQRP38W.js +0 -26969
  139. package/dist/chunks/index-jdOZ4AkD.js +0 -143
  140. package/dist/chunks/index-kNa21kUI.js +0 -279
  141. package/dist/chunks/index-v4AV9kAc.js +0 -108
  142. package/dist/chunks/run-review-command.logic-CU1Slmc_.js +0 -331
  143. package/dist/chunks/serve.cmd-dWu_k_G_.js +0 -162
  144. package/dist/chunks/services-CwvXl2MB.js +0 -46832
  145. package/dist/chunks/shared-DSZTUx5b.js +0 -4509
  146. package/dist/chunks/stats-index-H6ALcjxy.js +0 -66
@@ -1,89 +0,0 @@
1
- import { p as N, V as A, c as w, r as M } from "./shared-B5CTGvpG.js";
2
- import { l as q } from "./services-Csd556Tv.js";
3
- function L() {
4
- return {
5
- resolveVcsContext: M,
6
- stdout: process.stdout,
7
- stderr: process.stderr,
8
- exit: (n) => process.exit(n)
9
- };
10
- }
11
- async function C(n, e = L()) {
12
- const t = N(n, {
13
- ref: { aliases: ["ref"], takesValue: !0 },
14
- project: { aliases: ["project"], takesValue: !0 },
15
- iid: { aliases: ["iid"], takesValue: !0 },
16
- title: { aliases: ["title"], takesValue: !0 },
17
- description: { aliases: ["description"], takesValue: !0 },
18
- "target-branch": { aliases: ["target-branch"], takesValue: !0 },
19
- host: { aliases: ["host", "vcs-host"], takesValue: !0 },
20
- url: { aliases: ["url"], takesValue: !0 },
21
- label: { aliases: ["label"], takesValue: !0 },
22
- unlabel: { aliases: ["unlabel"], takesValue: !0 },
23
- assignee: { aliases: ["assignee"], takesValue: !0 },
24
- reviewer: { aliases: ["reviewer"], takesValue: !0 },
25
- milestone: { aliases: ["milestone"], takesValue: !0 },
26
- draft: ["draft"],
27
- ready: ["ready"],
28
- "dry-run": ["dry-run", "dry"]
29
- }), o = t.ref, m = t.project, c = t.iid, b = !!t["dry-run"], u = !!t.draft, d = !!t.ready;
30
- u && d && (e.stderr.write(`✖ --draft and --ready are mutually exclusive
31
- `), e.exit(1)), o && !/^.+\!\d+$/.test(o) && (e.stderr.write(`✖ Invalid ref format. Expected: <group/repo>!<iid>
32
- `), e.exit(1));
33
- const y = t.host, l = o ? Number(o.split("!").pop()) : c ? Number(c) : void 0, f = l !== void 0 && !isNaN(l) && l > 0 ? l : void 0, V = {
34
- host: y,
35
- ref: o,
36
- project: m,
37
- iid: f,
38
- url: t.url
39
- };
40
- let s;
41
- try {
42
- s = await e.resolveVcsContext(V);
43
- } catch (r) {
44
- throw r instanceof A && (e.stderr.write(`✖ Ошибка: ${r.message}
45
- `), e.exit(1)), r;
46
- }
47
- let a = s.iid ?? f;
48
- if ((!a || isNaN(a) || a <= 0) && s.branch) {
49
- const i = await w(s).MergeRequests.getOne({
50
- project: s.project,
51
- sourceBranch: s.branch
52
- });
53
- i?.iid && (a = i.iid);
54
- }
55
- (!a || isNaN(a) || a <= 0) && (e.stderr.write(
56
- `✖ Specify --url <mr-url> (preferred) or --ref <group/repo>!<iid> with --host
57
- `
58
- ), e.exit(1));
59
- const x = t.title, k = t.description, j = t["target-branch"], g = [t.label].flat().filter((r) => typeof r == "string"), v = [t.unlabel].flat().filter((r) => typeof r == "string"), p = t.assignee, h = t.reviewer, I = t.milestone, R = w(s), $ = {
60
- project: s.project,
61
- iid: a,
62
- title: x,
63
- description: k,
64
- draft: u ? !0 : d ? !1 : void 0,
65
- addLabels: g.length > 0 ? g : void 0,
66
- removeLabels: v.length > 0 ? v : void 0,
67
- assigneeIds: p ? [p] : void 0,
68
- reviewerIds: h ? [h] : void 0,
69
- targetBranch: j,
70
- milestoneId: I
71
- };
72
- b && (e.stdout.write(
73
- `Would update MR: ${s.project}!${a} host=${s.host} [DRY-RUN] no request sent
74
- `
75
- ), e.exit(0));
76
- try {
77
- const r = await R.MergeRequests.update($);
78
- e.stdout.write(`✓ MR !${r.iid} updated: ${r.webUrl}
79
- `);
80
- } catch (r) {
81
- const i = r.message ?? "неизвестная ошибка";
82
- q.error("[vcs-mr-edit] API error", { cause: r }), i.includes("404") ? e.stderr.write(`✖ MR ${s.project}!${a} не найден.
83
- `) : i.includes("At least one field") ? e.stderr.write(`✖ At least one field to update is required
84
- `) : e.stderr.write(`✖ API error: ${i}
85
- `), e.exit(1);
86
- }
87
- e.exit(0);
88
- }
89
- C(process.argv);
@@ -1,186 +0,0 @@
1
- import { existsSync as h, mkdirSync as I, writeFileSync as S } from "node:fs";
2
- import { resolve as D, dirname as R } from "node:path";
3
- import { l as d } from "./services-Csd556Tv.js";
4
- import { p as C, A as E, T as l } from "./shared-B5CTGvpG.js";
5
- const g = "ERR_CLI_SDD_NEW_BAD_INVOCATION", $ = "ERR_CLI_SDD_NEW_UNKNOWN_KIND", _ = "ERR_CLI_SDD_NEW_FILE_EXISTS", w = "ERR_CLI_SDD_NEW_WRITE_FAILED", N = [
6
- "product",
7
- "library",
8
- "infrastructure",
9
- "interface",
10
- "module",
11
- "task",
12
- "module-index",
13
- "scope-index",
14
- "project-index",
15
- "portal"
16
- ];
17
- function f(n) {
18
- return {
19
- ok: !1,
20
- code: g,
21
- exitCode: 4,
22
- message: [
23
- `[sdd-new] ${g}: ${n}`,
24
- " expected: gennady sdd-new <kind> --scope <s> [--module <m[/sub/sub]>] [--id <ACR-slug>] [--out <path>]",
25
- " or: gennady sdd-new --list",
26
- ` <kind> ∈ ${N.join(" | ")}`
27
- ].join(`
28
- `)
29
- };
30
- }
31
- function x(n) {
32
- return {
33
- ok: !1,
34
- code: $,
35
- exitCode: 4,
36
- message: [
37
- `[sdd-new] ${$}: "${n}"`,
38
- ` Known kinds: ${N.join(", ")}.`,
39
- " Run `gennady sdd-new --list` to see every kind with its path pattern."
40
- ].join(`
41
- `)
42
- };
43
- }
44
- function y(n) {
45
- return {
46
- ok: !1,
47
- code: _,
48
- exitCode: 1,
49
- message: [
50
- `[sdd-new] ${_}: ${n}`,
51
- " sdd-new never overwrites an existing artifact. Edit it directly, or pass --out with a fresh path."
52
- ].join(`
53
- `)
54
- };
55
- }
56
- function L(n, e) {
57
- const t = e instanceof Error ? e.message : String(e);
58
- return {
59
- ok: !1,
60
- code: w,
61
- exitCode: 1,
62
- message: [`[sdd-new] ${w}: ${n}`, ` ${t}`].join(`
63
- `)
64
- };
65
- }
66
- function k(n) {
67
- const e = n.map((s) => [
68
- s.name,
69
- s.required ? "REQUIRED" : "OPTIONAL",
70
- s.fold ? "FOLD" : "-",
71
- s.fill
72
- ]), t = ["Section", "Required", "Fold", "Fill"], i = t.map(
73
- (s, u) => Math.max(s.length, ...e.map((o) => o[u].length))
74
- ), r = (s) => s.map((u, o) => u.padEnd(i[o])).join(" ");
75
- return [
76
- r(t),
77
- r(i.map((s) => "-".repeat(s))),
78
- ...e.map((s) => r(s))
79
- ].join(`
80
- `);
81
- }
82
- function j(n, e, t) {
83
- return [`[sdd-new] created ${n} skeleton: ${e}`, "", k(t)].join(
84
- `
85
- `
86
- );
87
- }
88
- function v(n, e) {
89
- return [`[sdd-new] manifest for ${n}:`, "", k(e)].join(`
90
- `);
91
- }
92
- function A() {
93
- return ["[sdd-new] known kinds:", ...E.map((e) => ` ${e.padEnd(14)} ${l[e].pathPattern}`)].join(`
94
- `);
95
- }
96
- function p(n) {
97
- const e = n.split("/").filter((t) => t.length > 0);
98
- return e[e.length - 1] ?? n;
99
- }
100
- function b(n, e) {
101
- if (e.out) return e.out;
102
- switch (n) {
103
- case "product":
104
- case "library":
105
- case "infrastructure":
106
- case "interface":
107
- return `specs/${e.scope}/${e.scope}.spec.md`;
108
- case "module":
109
- return `specs/${e.scope}/${e.module}/${p(e.module)}.spec.md`;
110
- case "task":
111
- return `specs/${e.scope}/${e.module}/${p(e.module)}.task.${e.id}.md`;
112
- case "module-index":
113
- return `specs/${e.scope}/${e.module}/${p(e.module)}.3-tasks.md`;
114
- case "scope-index":
115
- return `specs/${e.scope}/${e.scope}.3-tasks.md`;
116
- case "project-index":
117
- return "specs/3-tasks.md";
118
- case "portal":
119
- return "specs/README.md";
120
- }
121
- }
122
- function T(n, e) {
123
- if (e.out) return [];
124
- const t = [];
125
- return n !== "portal" && n !== "project-index" && !e.scope && t.push("--scope"), (n === "module" || n === "task" || n === "module-index") && !e.module && t.push("--module"), n === "task" && !e.id && t.push("--id"), t;
126
- }
127
- const W = /^[a-z0-9]+(-[a-z0-9]+)*$/;
128
- function O(n) {
129
- if (n.startsWith("/")) return `--module must be a relative path, got "${n}"`;
130
- const e = n.split("/");
131
- for (const t of e) {
132
- if (t.length === 0) return `--module has an empty path segment: "${n}"`;
133
- if (t === "." || t === "..")
134
- return `--module must not contain "." or ".." segments: "${n}"`;
135
- if (!W.test(t))
136
- return `--module segment "${t}" is not kebab-case (lowercase, hyphen-separated): "${n}"`;
137
- }
138
- return null;
139
- }
140
- async function F(n) {
141
- const e = C(n, {
142
- scope: { aliases: ["scope"], takesValue: !0 },
143
- module: { aliases: ["module"], takesValue: !0 },
144
- id: { aliases: ["id"], takesValue: !0 },
145
- out: { aliases: ["out"], takesValue: !0 },
146
- list: { aliases: ["list"] },
147
- manifest: { aliases: ["manifest"] }
148
- });
149
- if (e.list)
150
- return { ok: !0, text: A(), path: "" };
151
- const i = e._.filter(
152
- (a) => typeof a == "string" && a !== "sdd-new"
153
- )[0];
154
- if (!i)
155
- return d.warn("[SddNewCommand#run] bad invocation — missing <kind>"), f("missing <kind>");
156
- if (!E.includes(i))
157
- return d.warn(`[SddNewCommand#run] unknown kind: ${i}`), x(i);
158
- const r = i;
159
- if (e.manifest)
160
- return d.debug(`[SddNewCommand#run] manifest for ${r}`), { ok: !0, text: v(r, l[r].sections), path: "" };
161
- const s = {
162
- scope: typeof e.scope == "string" ? e.scope : void 0,
163
- module: typeof e.module == "string" ? e.module : void 0,
164
- id: typeof e.id == "string" ? e.id : void 0,
165
- out: typeof e.out == "string" ? e.out : void 0
166
- }, u = T(r, s);
167
- if (u.length > 0)
168
- return f(`${r} requires ${u.join(", ")}`);
169
- if (s.module) {
170
- const a = O(s.module);
171
- if (a)
172
- return d.warn(`[SddNewCommand#run] bad --module: ${a}`), f(a);
173
- }
174
- const o = b(r, s), m = D(o);
175
- if (h(m))
176
- return d.warn(`[SddNewCommand#run] target already exists: ${o}`), y(o);
177
- try {
178
- I(R(m), { recursive: !0 }), S(m, l[r].skeleton, "utf-8");
179
- } catch (a) {
180
- return d.warn(`[SddNewCommand#run] write failed: ${o}`), L(o, a);
181
- }
182
- return d.debug(`[SddNewCommand#run] created ${r} skeleton at ${o}`), { ok: !0, text: j(r, o, l[r].sections), path: o };
183
- }
184
- const c = await F(process.argv);
185
- console.log(c.ok ? c.text : c.message);
186
- process.exit(c.ok ? 0 : c.exitCode);
@@ -1,125 +0,0 @@
1
- import { AiLegacyModel as h } from "../index.js";
2
- import { G as f, u as c } from "./shared-B5CTGvpG.js";
3
- import { l as p } from "./services-Csd556Tv.js";
4
- import { readFileSync as l } from "node:fs";
5
- import { dirname as _, join as m } from "node:path";
6
- import { fileURLToPath as k } from "node:url";
7
- class M {
8
- /** @purpose Loaded AI model list from gennadyrc. */
9
- _models = [];
10
- /** @purpose Currently active model that passed ping check. */
11
- _activeModel = null;
12
- /** @purpose Configuration and dependencies for the core. */
13
- init;
14
- /**
15
- * @purpose Initialize AiLegacyCore with loaded models from gennadyrc.
16
- * @param [init] Configuration (logger, timeout, maxInputTokens).
17
- */
18
- constructor(e = {}) {
19
- this.init = {
20
- logger: p,
21
- timeout: 120,
22
- maxInputTokens: e.maxInputTokens ?? 4e3,
23
- ...e
24
- }, f.getDefaults().forEach((o) => {
25
- o.isValid() && this._models.push(...o.getModels().map((t) => new h(t)));
26
- }), this._models.length || this._models.push(h.getDefault());
27
- }
28
- /**
29
- * @purpose Name of the first loaded model (for CLI display).
30
- * @returns Model name string or undefined.
31
- */
32
- get model() {
33
- return this._models[0]?.name;
34
- }
35
- /**
36
- * @purpose URL of the first loaded model.
37
- * @returns API URL string or undefined.
38
- */
39
- get apiUrl() {
40
- return this._models[0]?.url;
41
- }
42
- /**
43
- * @purpose Token limit per batch when splitting diff.
44
- * @returns Max input tokens count.
45
- */
46
- get maxInputTokens() {
47
- return this.init.maxInputTokens;
48
- }
49
- /**
50
- * @purpose Split parsed diff into batches by maxInputTokens for sequential LLM requests.
51
- * @param parseDiff Array of ParsedDiffFile (usually parsedCodeDiff from getGitDiffInfo).
52
- * @returns Array of batches { tokens, diff, languages }.
53
- */
54
- createPromptsBatchesByDiff(e) {
55
- let o = e;
56
- const t = e.at(-1)?.tokens ?? 0;
57
- return t > this.maxInputTokens && (this.init.logger.error(`Diff is too large: ${t} > ${this.maxInputTokens}`), o = e.slice(0, this.maxInputTokens)), o.reduce(
58
- (a, r) => {
59
- let n = a[0];
60
- (!n || n.tokens + r.tokens > this.maxInputTokens) && (a.unshift({ tokens: 0, diff: "", languages: [] }), n = a[0]);
61
- const g = r.diff.hunks.flatMap((s) => s.changes).join(`
62
- `);
63
- if (g.trim()) {
64
- n.tokens += r.tokens, n.diff += `### File **${r.filename}**:
65
- ${g}
66
-
67
- `;
68
- const s = r.programmingLanguage;
69
- s && !n.languages.includes(s) && n.languages.push(s);
70
- }
71
- return a;
72
- },
73
- []
74
- );
75
- }
76
- /**
77
- * @purpose Call the first available model (ping) and generate a response from the prompt.
78
- * @param prompt Prompt text.
79
- * @param [systemPrompt] Optional system prompt.
80
- * @returns Model response text or empty string on error.
81
- * @sideEffect Network: ping then generate; Logs: error/warn on model failure.
82
- */
83
- async generate(e, o) {
84
- try {
85
- const t = await c(this._choiceModel());
86
- return await c(t.generate(e, o));
87
- } catch (t) {
88
- return this.init.logger.error(
89
- "[AI_LEGACY_CORE_ERROR_GENERATE] Failed to generate LLM response:",
90
- t
91
- ), "";
92
- }
93
- }
94
- /**
95
- * @purpose Select the first model that successfully responded to ping; caches in _activeModel.
96
- * @returns Tuple [model, null] or [null, Error] if no model is available.
97
- * @sideEffect Network: ping each model until first success.
98
- */
99
- async _choiceModel() {
100
- if (this._activeModel)
101
- return [this._activeModel, null];
102
- for (const e of this._models) {
103
- const [o, t] = await e.ping();
104
- if (o)
105
- return this._activeModel = e, [e, null];
106
- t && this.init.logger.warn(
107
- `[AI_LEGACY_CORE_ERROR_PING_MODEL_FAIL] [${e.name}] Ping failed:`,
108
- t
109
- );
110
- }
111
- return [null, new Error("[AI_LEGACY_CORE_ERROR_PING_FAIL] No available models")];
112
- }
113
- }
114
- const u = _(k(import.meta.url)), w = {
115
- /** @purpose Load agent prompt by name (e.g. 'keywords'). */
116
- agent: (i) => l(m(u, "agent", `agent-${i}-prompt.md`)).toString(),
117
- /** @purpose Load commit prompt by name ('message' | 'changeset'). */
118
- commit: (i) => l(m(u, "commit", `commit-${i}-prompt.md`)).toString(),
119
- /** @purpose Load review prompt by name (e.g. 'base'). */
120
- review: (i) => l(m(u, "review", `review-${i}-prompt.md`)).toString()
121
- };
122
- export {
123
- M as A,
124
- w as p
125
- };
@@ -1,2 +0,0 @@
1
- import { U as r } from "./services-CwvXl2MB.js";
2
- await r(process.argv);
@@ -1,2 +0,0 @@
1
- import { T as r } from "./services-CwvXl2MB.js";
2
- await r(process.argv);
@@ -1,183 +0,0 @@
1
- import u from "node:fs";
2
- import S from "node:os";
3
- import v from "node:path";
4
- import { execSync as P } from "node:child_process";
5
- import { p as d, A as E } from "./index-2BOEcJIa.js";
6
- import { g as H, s as t, x as D, p as F } from "./shared-DSZTUx5b.js";
7
- import { l as N } from "./services-CwvXl2MB.js";
8
- class U {
9
- /** @purpose Configuration with defaults for mode, prompts, timeout. */
10
- init;
11
- /** @purpose AI core instance for LLM requests. */
12
- ai;
13
- /**
14
- * @purpose Initialize CommitGen with configuration and AI core.
15
- * @param [init] Configuration overrides (mode, oneline, targetBranch, task, timeout).
16
- */
17
- constructor(n = {}) {
18
- this.init = {
19
- mode: "auto",
20
- oneline: !1,
21
- targetBranch: void 0,
22
- task: void 0,
23
- logger: N,
24
- promptCommitMessage: d.commit("message"),
25
- promptCommitChangeset: d.commit("changeset"),
26
- timeout: 120,
27
- ...n
28
- }, this.ai = new E({
29
- logger: this.init.logger,
30
- timeout: this.init.timeout
31
- });
32
- }
33
- /**
34
- * @purpose Get the logger instance used during generation.
35
- * @returns Logger instance.
36
- */
37
- get logger() {
38
- return this.init.logger;
39
- }
40
- /**
41
- * @purpose Commit output mode: auto | oneline | detailed.
42
- * @returns Mode string.
43
- */
44
- get mode() {
45
- return this.init.mode;
46
- }
47
- /**
48
- * @purpose Active AI model name (from the first available rc).
49
- * @returns Model name string or undefined.
50
- */
51
- get model() {
52
- return this.ai.model;
53
- }
54
- /**
55
- * @purpose Active model API URL.
56
- * @returns API URL string or undefined.
57
- */
58
- get apiUrl() {
59
- return this.ai.apiUrl;
60
- }
61
- /**
62
- * @purpose Branch against which the diff is built (if specified).
63
- * @returns Target branch name or undefined.
64
- */
65
- get targetBranch() {
66
- return this.init.targetBranch;
67
- }
68
- /**
69
- * @purpose Task identifier for substitution in subject (optional).
70
- * @returns Task ID string or number, or undefined.
71
- */
72
- get task() {
73
- return this.init.task;
74
- }
75
- /**
76
- * @purpose Call LLM with a single prompt without think blocks (for tests or custom input).
77
- * @param input Prompt text.
78
- * @returns Model response as string.
79
- * @sideEffect Network: request to AI API.
80
- */
81
- async fetchPrompt(n) {
82
- return this.ai.generate(`/no_think ${n} /no_think`);
83
- }
84
- /**
85
- * @purpose Generate commit message from staged diff (batches → changeset → message).
86
- * @returns Message string (oneline or with description) or undefined on empty diff/error.
87
- * @sideEffect Network: requests to AI; Logs: info/warn/debug.
88
- */
89
- async generate() {
90
- const n = performance.now();
91
- this.init.logger.info(
92
- `[CommitGen#generate] [idle → loading] targetBranch=${this.init.targetBranch ?? "HEAD"}`
93
- );
94
- const {
95
- commitCount: y,
96
- parsedCodeDiff: g,
97
- parsedCodeTokens: k,
98
- parsedCodeChunkMaxTokens: w,
99
- programmingLanguages: B
100
- } = H(this.init.targetBranch);
101
- if (g.length === 0) {
102
- this.init.logger.warn("[CommitGen#generate] [loading → skipped] No staged changes"), this.init.logger.info(t.italic.gray("Hint: git add ."));
103
- return;
104
- }
105
- const h = this.init.oneline ? "oneline" : this.init.mode === "auto" ? this.init.targetBranch ? "detailed" : y > 1 && g.length < 5 ? "oneline" : "detailed" : this.init.mode;
106
- this.init.logger.info(
107
- `[CommitGen#generate] [loading → batching] mode=${t.bold.magentaBright(h)} languages=${B.join(", ")} tokens=${k} (max per file: ${w})`
108
- );
109
- const p = this.ai.createPromptsBatchesByDiff(g);
110
- this.init.logger.debug(`[CommitGen#generate] [batching → ready] queue=${p.length}`);
111
- const G = performance.now(), _ = await Promise.all(
112
- p.map(async (e) => {
113
- this.init.logger.debug(
114
- `[CommitGen#generate] [batching → task] ${e.tokens} tokens, ${e.languages?.join("/")}`
115
- );
116
- const a = this.init.promptCommitChangeset.replaceAll("{languages}", e.languages.join("/")).replaceAll("{input}", e.diff);
117
- return this.fetchPrompt(a);
118
- })
119
- ), A = performance.now() - G;
120
- this.init.logger.info(
121
- `[CommitGen#generate] [batching → changeset] (${(A / 1e3).toFixed(2)}s)`
122
- );
123
- const T = performance.now(), b = `<changeset>
124
- ${_.flatMap((e) => e.match(/<changeset>([\s\S]*?)<\/changeset>/)?.[1]?.match(/<change.*?>.*?<\/change>/g) ?? []).join(`
125
- `)}
126
- </changeset>`, x = await this.fetchPrompt(
127
- this.init.promptCommitMessage.replaceAll("{input}", b)
128
- ), M = performance.now() - T;
129
- this.init.logger.info(
130
- `[CommitGen#generate] [changeset → message] (${(M / 1e3).toFixed(2)}s)`
131
- );
132
- const i = D(x);
133
- if (!i) return;
134
- let o = i.subject;
135
- if (this.init.task) {
136
- const e = this.init.task.toString(), a = /^\d+$/.test(e) ? `#${e}` : e;
137
- o = `${o} (${a})`;
138
- }
139
- const j = performance.now() - n;
140
- return this.init.logger.info(
141
- `[CommitGen#generate] [message → completed] (${(j / 1e3).toFixed(2)}ms)`
142
- ), h === "oneline" ? `${i.type}: ${o} ${i.icon}` : `${i.type}: ${o} ${i.icon}
143
-
144
- ${i.description}`;
145
- }
146
- }
147
- const C = v.join(S.homedir(), ".gennady_commit_cache.json"), c = process.cwd(), $ = I(), m = F(process.argv, {
148
- apply: ["apply"],
149
- mode: ["mode", "m"],
150
- oneline: ["short", "one", "o"],
151
- model: ["model"],
152
- targetBranch: ["branch", "b"],
153
- apiUrl: ["api", "apiUrl"],
154
- task: ["task", "t"]
155
- }), r = new U(m);
156
- console.info(
157
- "🤖",
158
- t.whiteBright.bold("GENNADY"),
159
- `(${t.cyan(r.model ?? "")} → ${t.yellow(r.mode)})`,
160
- "🗯️"
161
- );
162
- console.info(t.gray("-".repeat(40)));
163
- console.info(`- url: ${t.blue(r.apiUrl ?? "")}`);
164
- console.info(t.gray("-".repeat(40)));
165
- const s = (m.apply && $[c]) ?? await r.generate();
166
- s || process.exit(0);
167
- m.apply ? (P(`git commit -am "${String(s).replace(/(["`])/g, "\\$1")}"`, {
168
- stdio: "inherit"
169
- }), f({ [c]: void 0 })) : (console.info("-".repeat(40), `
170
- `), console.info(t.whiteBright(String(s)), `
171
- `), console.info("^".repeat(40), `
172
- `), console.log(t.italic.gray(`Hint: npx gennady ${process.argv.slice(3).join(" ")} --apply`)), console.log(""), f({ [c]: s }));
173
- function I() {
174
- try {
175
- return JSON.parse(u.readFileSync(C, "utf8"));
176
- } catch {
177
- return {};
178
- }
179
- }
180
- function f(l) {
181
- const n = { ...$, ...l };
182
- u.writeFileSync(C, JSON.stringify(n, null, 2));
183
- }