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,6 +1,6 @@
1
1
  import { AiLegacyModel as h } from "../index.js";
2
- import { G as f, u as c } from "./shared-Bjy30TeM.js";
3
- import { l as p } from "./services-CaLOhuLV.js";
2
+ import { G as f, u as c } from "./shared-DL_1LG0K.js";
3
+ import { l as p } from "./services-IgZptnTi.js";
4
4
  import { readFileSync as l } from "node:fs";
5
5
  import { dirname as _, join as m } from "node:path";
6
6
  import { fileURLToPath as k } from "node:url";
@@ -1,4 +1,4 @@
1
- import { p as D, e as o, b as M, a as H, d as B, l as U, f as O, h as k, s as F } from "./shared-Bjy30TeM.js";
1
+ import { p as D, e as o, h as M, a as H, i as B, l as U, j as k, k as O, s as F } from "./shared-DL_1LG0K.js";
2
2
  import a from "node:fs";
3
3
  import P from "node:path";
4
4
  function C(e) {
@@ -86,7 +86,7 @@ function X(e) {
86
86
  }
87
87
  return t;
88
88
  }
89
- function z(e, t) {
89
+ function j(e, t) {
90
90
  const n = P.join(process.cwd(), e), i = h[t] ?? "unknown";
91
91
  try {
92
92
  if (!a.statSync(n).isFile())
@@ -118,7 +118,7 @@ function z(e, t) {
118
118
  };
119
119
  }
120
120
  }
121
- function G(e) {
121
+ function z(e) {
122
122
  if (!o("git rev-parse --git-dir 2>/dev/null").trim())
123
123
  throw new Error("Текущая директория не является git-репозиторием.");
124
124
  const n = y("MERGE_HEAD");
@@ -147,12 +147,12 @@ function G(e) {
147
147
  `).map((s) => s.trim()).filter(Boolean);
148
148
  if (m.length === 0)
149
149
  throw new Error("Конфликтующие файлы не найдены (`git diff --diff-filter=U` пуст).");
150
- const b = o("git status --porcelain --untracked-files=no 2>/dev/null"), E = X(b), g = x("MERGE_MSG").trim(), v = e.incoming?.trim() || T(g) || $(r) || r, w = e.branch?.trim() || M(), _ = H(), A = d(
150
+ const E = o("git status --porcelain --untracked-files=no 2>/dev/null"), b = X(E), g = x("MERGE_MSG").trim(), v = e.incoming?.trim() || T(g) || $(r) || r, w = e.branch?.trim() || M(), _ = H(), A = d(
151
151
  o(`git rev-list --count ${r}..HEAD 2>/dev/null`)
152
152
  ), S = d(
153
153
  o(`git rev-list --count HEAD..${r} 2>/dev/null`)
154
154
  ), R = m.map(
155
- (s) => z(s, E.get(s) ?? "UU")
155
+ (s) => j(s, b.get(s) ?? "UU")
156
156
  );
157
157
  return {
158
158
  currentBranch: w,
@@ -170,7 +170,7 @@ function G(e) {
170
170
  function u(e) {
171
171
  return e ? e.slice(0, 12) : "";
172
172
  }
173
- function j(e) {
173
+ function G(e) {
174
174
  const t = e.conflictFiles.map(
175
175
  (n) => ({
176
176
  tag: "File",
@@ -227,20 +227,20 @@ function j(e) {
227
227
  };
228
228
  }
229
229
  function L(e) {
230
- const t = j(e);
230
+ const t = G(e);
231
231
  return B(t);
232
232
  }
233
233
  async function K() {
234
234
  return U("agent-resolve-conflicts.xml");
235
235
  }
236
236
  async function W(e, t = process.cwd()) {
237
- const n = await K(), i = O(t);
237
+ const n = await K(), i = k(t);
238
238
  let r = n.replace("<!--Resolve_Conflicts_Artifact-->", e);
239
- return r = r.replace("<!--ai:first-->", k(t)), r = r.replace("<!--ai:verify-axiom-hint-->", i.axiomHint), r = r.replace("<!--ai:verify-tools-example-->", i.toolsExample), r = r.replace("<!--ai:verify-step-commands-->", i.verifyStep), r;
239
+ return r = r.replace("<!--ai:first-->", O(t)), r = r.replace("<!--ai:verify-axiom-hint-->", i.axiomHint), r = r.replace("<!--ai:verify-tools-example-->", i.toolsExample), r = r.replace("<!--ai:verify-step-commands-->", i.verifyStep), r;
240
240
  }
241
241
  async function q(e) {
242
242
  try {
243
- const t = G(e), n = L(
243
+ const t = z(e), n = L(
244
244
  t
245
245
  );
246
246
  return {
@@ -0,0 +1,21 @@
1
+ import { existsSync as t, readFileSync as d } from "node:fs";
2
+ import { resolve as n, dirname as a } from "node:path";
3
+ import { fileURLToPath as m } from "node:url";
4
+ async function g(p) {
5
+ const s = n(".");
6
+ t(n(s, "node_modules/gennady")) || (console.error("gennady package not found. Install it locally: npm i -D gennady"), process.exit(1));
7
+ const c = import.meta.resolve("gennady"), i = m(c);
8
+ let o = a(i);
9
+ for (; !t(n(o, "package.json")); )
10
+ o = a(o);
11
+ const r = n(o, "cli/cmd/orient/README.md");
12
+ t(r) || (console.error(`README.md not found at ${r}`), process.exit(1));
13
+ try {
14
+ const e = d(r, "utf-8");
15
+ console.log(e);
16
+ } catch (e) {
17
+ const l = e instanceof Error ? e.message : String(e);
18
+ console.error(`Cannot read README.md: ${l}`), process.exit(1);
19
+ }
20
+ }
21
+ await g(process.argv);
@@ -0,0 +1,369 @@
1
+ import { readdirSync as $, statSync as v, readFileSync as N, rmdirSync as U, unlinkSync as O, mkdirSync as x, writeFileSync as T } from "node:fs";
2
+ import { join as k, sep as W } from "node:path";
3
+ import { fileURLToPath as K } from "node:url";
4
+ import { l as I } from "./services-IgZptnTi.js";
5
+ import { n as z, d as b, b as B, p as M, r as G } from "./shared-DL_1LG0K.js";
6
+ class j {
7
+ /** @purpose List of all synced file entries, sorted lexicographically by skillName then relativePath. */
8
+ entries;
9
+ /**
10
+ * @purpose Construct a SyncSkillsResult from a list of entries.
11
+ * @param entries File entries.
12
+ */
13
+ constructor(e) {
14
+ this.entries = e;
15
+ }
16
+ /** @purpose Files with status "added". | @returns Array of added entries. */
17
+ get added() {
18
+ return this.entries.filter((e) => e.status === "added");
19
+ }
20
+ /** @purpose Files with status "updated". | @returns Array of updated entries. */
21
+ get updated() {
22
+ return this.entries.filter((e) => e.status === "updated");
23
+ }
24
+ /** @purpose Files with status "deleted". | @returns Array of deleted entries. */
25
+ get deleted() {
26
+ return this.entries.filter((e) => e.status === "deleted");
27
+ }
28
+ /** @purpose Files with status "unchanged". | @returns Array of unchanged entries. */
29
+ get unchanged() {
30
+ return this.entries.filter((e) => e.status === "unchanged");
31
+ }
32
+ /** @purpose Files with status "deleteFailed". | @returns Array of delete-failed entries. */
33
+ get deleteFailed() {
34
+ return this.entries.filter((e) => e.status === "deleteFailed");
35
+ }
36
+ /** @purpose Human-readable summary of sync counts. | @returns Summary string. */
37
+ get summary() {
38
+ const e = this.added.length, r = this.updated.length, a = this.unchanged.length, c = this.deleted.length, i = this.deleteFailed.length;
39
+ let l = `Synced: ${e} added, ${r} updated, ${a} skipped, ${c} deleted`;
40
+ return i > 0 && (l += `, ${i} delete failed`), l;
41
+ }
42
+ /** @purpose Dry-run summary message. | @returns Dry-run message. */
43
+ get dryRunSummary() {
44
+ return "Dry-run: no files written.";
45
+ }
46
+ }
47
+ const P = "ERR_SKILLS_SOURCE_NOT_FOUND", C = "ERR_SKILLS_SKILL_NOT_FOUND", w = /* @__PURE__ */ new Set([".DS_Store"]);
48
+ function H(t, e) {
49
+ const r = $(t).filter((i) => {
50
+ if (i.startsWith(".") || w.has(i)) return !1;
51
+ try {
52
+ return v(k(t, i)).isDirectory();
53
+ } catch {
54
+ return !1;
55
+ }
56
+ }), a = e && e.length > 0 ? e : r;
57
+ for (const i of a)
58
+ if (!r.includes(i)) {
59
+ const l = `[scanSkills] Skill "${i}" not found in source.
60
+ Available: ${r.join(", ")}`, s = new Error(l);
61
+ throw s.code = C, s;
62
+ }
63
+ const c = /* @__PURE__ */ new Map();
64
+ for (const i of a) {
65
+ const l = k(t, i), s = /* @__PURE__ */ new Map();
66
+ L(l, "", void 0, s), c.set(i, s);
67
+ }
68
+ return c;
69
+ }
70
+ function L(t, e, r, a) {
71
+ const c = r ? r.readdir : $, i = r ? r.stat : v, l = r ? r.readFile : N;
72
+ let s;
73
+ try {
74
+ s = c(t);
75
+ } catch {
76
+ return;
77
+ }
78
+ for (const d of s) {
79
+ if (d.startsWith(".") || w.has(d)) continue;
80
+ const g = k(t, d), y = e ? k(e, d) : d;
81
+ let n;
82
+ try {
83
+ n = i(g);
84
+ } catch {
85
+ continue;
86
+ }
87
+ if (n) {
88
+ if (n.isDirectory())
89
+ L(g, y, r, a);
90
+ else if (n.isFile()) {
91
+ const f = y.split(W).join("/");
92
+ a.set(f, l(g));
93
+ }
94
+ }
95
+ }
96
+ }
97
+ function X(t, e, r, a, c, i, l, s) {
98
+ let d;
99
+ if (a ? B(r, a) ? d = "updated" : d = "unchanged" : d = "added", !i && d !== "unchanged") {
100
+ const g = k(c, e);
101
+ s(k(g, ".."), { recursive: !0 }), l(g, r);
102
+ }
103
+ return {
104
+ skillName: t,
105
+ relativePath: e,
106
+ status: d,
107
+ sourceSize: r.length,
108
+ targetSize: a?.length
109
+ };
110
+ }
111
+ function F(t, e) {
112
+ const r = [];
113
+ let a;
114
+ try {
115
+ a = e.readdir(t);
116
+ } catch {
117
+ return r;
118
+ }
119
+ for (const c of a) {
120
+ if (c.startsWith(".") || w.has(c)) continue;
121
+ const i = k(t, c);
122
+ try {
123
+ const l = e.stat(i);
124
+ l.isDirectory() ? r.push(...F(i, e).map((s) => k(c, s))) : l.isFile() && r.push(c);
125
+ } catch {
126
+ }
127
+ }
128
+ return r;
129
+ }
130
+ function Y(t, e, r, a) {
131
+ const c = k(e, t);
132
+ let i = [];
133
+ try {
134
+ i = F(c, a);
135
+ } catch {
136
+ }
137
+ if (r) {
138
+ const y = [
139
+ {
140
+ skillName: t,
141
+ relativePath: "",
142
+ status: "deleted",
143
+ sourceSize: void 0,
144
+ targetSize: void 0
145
+ }
146
+ ];
147
+ for (const n of i.sort())
148
+ y.push({
149
+ skillName: t,
150
+ relativePath: n,
151
+ status: "deleted",
152
+ sourceSize: void 0,
153
+ targetSize: void 0
154
+ });
155
+ return y;
156
+ }
157
+ const l = a.unlink ?? (() => {
158
+ }), s = a.rmdir ?? (() => {
159
+ });
160
+ let d = !1, g;
161
+ for (const y of i) {
162
+ const n = k(c, y);
163
+ try {
164
+ l(n);
165
+ } catch (f) {
166
+ d = !0, g = f.code ?? "UNKNOWN";
167
+ }
168
+ }
169
+ try {
170
+ s(c, { recursive: !0 });
171
+ } catch (y) {
172
+ d = !0, g = y.code ?? "UNKNOWN";
173
+ }
174
+ return d ? [
175
+ {
176
+ skillName: t,
177
+ relativePath: "",
178
+ status: "deleteFailed",
179
+ errorCode: g
180
+ }
181
+ ] : [
182
+ {
183
+ skillName: t,
184
+ relativePath: "",
185
+ status: "deleted"
186
+ }
187
+ ];
188
+ }
189
+ function q(t, e) {
190
+ let r;
191
+ try {
192
+ r = t.stat(e.sourceDir);
193
+ } catch {
194
+ const n = `[collectAndCompareSkills] Source directory not found: ${e.sourceDir}`, f = new Error(n);
195
+ throw f.code = P, f;
196
+ }
197
+ if (!r.isDirectory())
198
+ throw new Error(`[collectAndCompareSkills] sourceDir is not a directory: ${e.sourceDir}`);
199
+ const a = k(e.targetDir, "..");
200
+ try {
201
+ if (t.stat(a).isFile())
202
+ throw new Error("[collectAndCompareSkills] .claude exists but is not a directory");
203
+ } catch (n) {
204
+ if (n.code !== "ENOENT") throw n;
205
+ }
206
+ try {
207
+ t.mkdir(e.targetDir, { recursive: !0 });
208
+ } catch (n) {
209
+ const f = n;
210
+ throw f.code === "EACCES" ? new Error(`[collectAndCompareSkills] cannot write to ${e.targetDir}: ${f.code}`, {
211
+ cause: n
212
+ }) : f.code === "ENOTDIR" ? new Error("[collectAndCompareSkills] .claude exists but is not a directory", {
213
+ cause: n
214
+ }) : n;
215
+ }
216
+ const c = t.writeFile, i = t.mkdir, l = H(e.sourceDir, e.skillNames);
217
+ let s = [];
218
+ try {
219
+ s = t.readdir(e.targetDir).filter((n) => {
220
+ if (n.startsWith(".") || w.has(n)) return !1;
221
+ try {
222
+ return t.stat(k(e.targetDir, n)).isDirectory();
223
+ } catch {
224
+ return !1;
225
+ }
226
+ });
227
+ } catch {
228
+ }
229
+ const d = [];
230
+ for (const n of [...l.keys()].sort()) {
231
+ const f = l.get(n), o = k(e.targetDir, n);
232
+ let h = /* @__PURE__ */ new Map();
233
+ L(o, "", t, h);
234
+ for (const [p, D] of [...f.entries()].sort(
235
+ ([m], [S]) => m.localeCompare(S)
236
+ )) {
237
+ const m = z(D.toString("utf-8"), b), S = Buffer.from(m, "utf-8"), u = h.get(p);
238
+ d.push(
239
+ X(
240
+ n,
241
+ p,
242
+ S,
243
+ u,
244
+ o,
245
+ e.dryRun ?? !1,
246
+ c,
247
+ i
248
+ )
249
+ );
250
+ }
251
+ s = s.filter((p) => p !== n);
252
+ }
253
+ const g = e.skillNames, y = g ? s.filter((n) => g.includes(n)) : s;
254
+ for (const n of y.sort())
255
+ d.push(...Y(n, e.targetDir, e.dryRun ?? !1, t));
256
+ return new j(d);
257
+ }
258
+ const J = "(would add)", Q = "(would update)", V = "(would delete)", Z = "(unchanged, skip)", ee = "(unchanged)", E = {
259
+ added: 0,
260
+ updated: 1,
261
+ deleted: 2,
262
+ deleteFailed: 3,
263
+ unchanged: 4
264
+ };
265
+ function te(t, e = {}) {
266
+ const r = e.dryRun === !0;
267
+ if (t.length === 0)
268
+ return r ? ["Dry-run: no files written."] : ["Synced: 0 added, 0 updated, 0 skipped, 0 deleted"];
269
+ const a = /* @__PURE__ */ new Map();
270
+ for (const o of t) {
271
+ let h = a.get(o.skillName);
272
+ h || (h = { entries: [], dominantStatus: "unchanged" }, a.set(o.skillName, h)), h.entries.push(o);
273
+ const p = E[o.status], D = E[h.dominantStatus];
274
+ p < D && (h.dominantStatus = o.status);
275
+ }
276
+ const c = [...a.entries()].sort(([o, h], [p, D]) => {
277
+ const m = E[h.dominantStatus] - E[D.dominantStatus];
278
+ return m !== 0 ? m : o.localeCompare(p);
279
+ }), l = Math.max(...c.map(([o]) => ` _ ${o}/`.length)) + 4, s = [];
280
+ for (const [o, h] of c) {
281
+ const p = h.dominantStatus;
282
+ if (p === "added") {
283
+ const m = ` + ${o}/`;
284
+ s.push(m);
285
+ for (const S of h.entries.sort((u, _) => u.relativePath.localeCompare(_.relativePath)))
286
+ r ? s.push(` ${S.relativePath}`.padEnd(l) + J) : s.push(` ${S.relativePath}`);
287
+ } else if (p === "updated") {
288
+ const m = ` ~ ${o}/`;
289
+ s.push(m);
290
+ const S = h.entries.filter((u) => u.status === "added" || u.status === "updated").sort((u, _) => u.relativePath.localeCompare(_.relativePath));
291
+ for (const u of S)
292
+ r ? s.push(` ${u.relativePath}`.padEnd(l) + Q) : s.push(` ${u.relativePath}`);
293
+ } else if (p === "deleted") {
294
+ const m = ` - ${o}/`;
295
+ r ? s.push(m.padEnd(l) + V) : s.push(m);
296
+ for (const S of h.entries.filter((u) => u.relativePath !== "").sort((u, _) => u.relativePath.localeCompare(_.relativePath)))
297
+ s.push(` ${S.relativePath}`);
298
+ } else if (p === "deleteFailed") {
299
+ const m = h.entries.find((u) => u.errorCode)?.errorCode ?? "UNKNOWN", S = ` ! ${o}/`;
300
+ s.push(S.padEnd(l) + `(delete failed: ${m})`);
301
+ } else {
302
+ const m = ` = ${o}/`, S = r ? Z : ee;
303
+ s.push(m.padEnd(l) + S);
304
+ }
305
+ }
306
+ const d = t.filter((o) => o.status === "added").length, g = t.filter((o) => o.status === "updated").length, y = t.filter((o) => o.status === "unchanged").length, n = t.filter((o) => o.status === "deleted").length, f = t.filter((o) => o.status === "deleteFailed").length;
307
+ if (r)
308
+ s.push("Dry-run: no files written.");
309
+ else {
310
+ let o = `Synced: ${d} added, ${g} updated, ${y} skipped, ${n} deleted`;
311
+ f > 0 && (o += `, ${f} delete failed`), s.push(o);
312
+ }
313
+ return s;
314
+ }
315
+ function re(t, e, r, a) {
316
+ r.write(`Sync skills${e ? " (dry-run)" : ""}: ${a}
317
+ `);
318
+ const c = te(t, { dryRun: e });
319
+ for (const i of c)
320
+ r.write(i + `
321
+ `);
322
+ }
323
+ function R(t, e) {
324
+ const r = N, a = T, c = x, i = v, l = $, s = O, d = U, g = G, y = process.stdout, n = process.stderr, f = M(t, {
325
+ dryRun: ["dry-run"]
326
+ }), o = f.dryRun === !0 || f.dryRun === "true", h = f._.filter(
327
+ (u) => typeof u == "string" && u !== "sync-skills"
328
+ ), p = process.cwd(), D = g(p, "ai/skills");
329
+ if (!D)
330
+ return n.write(`Error: gennady package not found. Install it locally: npm i -D gennady
331
+ `), 1;
332
+ const m = k(p, ".claude", "skills"), S = {
333
+ sourceDir: D,
334
+ targetDir: m,
335
+ skillNames: h.length > 0 ? h : void 0,
336
+ dryRun: o
337
+ };
338
+ try {
339
+ const _ = q({
340
+ readFile: r,
341
+ writeFile: a,
342
+ mkdir: c,
343
+ stat: (A) => i(A),
344
+ readdir: l,
345
+ unlink: s,
346
+ rmdir: d,
347
+ resolvePackageDir: g
348
+ }, S);
349
+ return re(_.entries, o, y, p), 0;
350
+ } catch (u) {
351
+ const _ = u;
352
+ if (_.code === C || _.code === P)
353
+ return n.write(`Error: ${_.message}
354
+ `), 1;
355
+ throw _;
356
+ }
357
+ }
358
+ if (process.argv[1]) {
359
+ const t = K(import.meta.url);
360
+ if (t === process.argv[1] || t.endsWith(process.argv[1]))
361
+ try {
362
+ const e = R(process.argv);
363
+ process.exit(e);
364
+ } catch (e) {
365
+ const r = new Error("[syncSkillsCmd] Self-execution failed", { cause: e });
366
+ I.error("[syncSkillsCmd#run] [self-executing → failed]", { error: r }), process.exit(1);
367
+ }
368
+ }
369
+ process.exit(R(process.argv));