@wrongstack/plugins 0.293.0 → 0.295.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 (189) hide show
  1. package/README.md +7 -71
  2. package/dist/accessibility-auditor/index.d.ts +1 -1
  3. package/dist/accessibility-auditor/index.d.ts.map +1 -1
  4. package/dist/accessibility-auditor.js +31 -31
  5. package/dist/agent-handoff/index.d.ts +1 -1
  6. package/dist/agent-handoff/index.d.ts.map +1 -1
  7. package/dist/api-compatibility-gate/index.d.ts +1 -1
  8. package/dist/api-compatibility-gate/index.d.ts.map +1 -1
  9. package/dist/api-compatibility-gate.js +21 -16
  10. package/dist/audit/index.d.ts +386 -0
  11. package/dist/audit/index.d.ts.map +1 -0
  12. package/dist/audit.d.ts +1 -0
  13. package/dist/audit.js +454 -0
  14. package/dist/auto-doc/index.d.ts +1 -1
  15. package/dist/auto-doc/index.d.ts.map +1 -1
  16. package/dist/auto-escalate/index.d.ts +1 -1
  17. package/dist/auto-escalate/index.d.ts.map +1 -1
  18. package/dist/auto-i18n-extractor/index.d.ts +1 -1
  19. package/dist/auto-i18n-extractor/index.d.ts.map +1 -1
  20. package/dist/auto-i18n-extractor.js +2 -1
  21. package/dist/branch-guard/index.d.ts +1 -1
  22. package/dist/branch-guard/index.d.ts.map +1 -1
  23. package/dist/branch-guard.js +9 -1
  24. package/dist/catalog.d.ts +5 -30
  25. package/dist/catalog.d.ts.map +1 -1
  26. package/dist/changelog-writer/index.d.ts +1 -1
  27. package/dist/changelog-writer/index.d.ts.map +1 -1
  28. package/dist/checkpoint/index.d.ts +1 -1
  29. package/dist/checkpoint/index.d.ts.map +1 -1
  30. package/dist/checkpoint.js +7 -8
  31. package/dist/code-metrics/index.d.ts +1 -1
  32. package/dist/code-metrics/index.d.ts.map +1 -1
  33. package/dist/code-metrics.js +29 -29
  34. package/dist/commit-validator/index.d.ts +1 -1
  35. package/dist/commit-validator/index.d.ts.map +1 -1
  36. package/dist/config-validator/index.d.ts +1 -1
  37. package/dist/config-validator/index.d.ts.map +1 -1
  38. package/dist/context-pins/index.d.ts +1 -1
  39. package/dist/context-pins/index.d.ts.map +1 -1
  40. package/dist/cost-tracker/index.d.ts +1 -1
  41. package/dist/cost-tracker/index.d.ts.map +1 -1
  42. package/dist/cost-tracker.js +9 -2
  43. package/dist/cron/index.d.ts +1 -1
  44. package/dist/cron/index.d.ts.map +1 -1
  45. package/dist/dead-code-detector/index.d.ts +1 -1
  46. package/dist/dead-code-detector/index.d.ts.map +1 -1
  47. package/dist/dead-code-detector.js +26 -18
  48. package/dist/dep-guard/index.d.ts +1 -1
  49. package/dist/dep-guard/index.d.ts.map +1 -1
  50. package/dist/dependency-vulnerability-gate/index.d.ts +1 -1
  51. package/dist/dependency-vulnerability-gate/index.d.ts.map +1 -1
  52. package/dist/dependency-vulnerability-gate.js +34 -22
  53. package/dist/diff-summary/index.d.ts +1 -1
  54. package/dist/diff-summary/index.d.ts.map +1 -1
  55. package/dist/diff-summary.js +28 -29
  56. package/dist/doc-sync-guard/index.d.ts +1 -1
  57. package/dist/doc-sync-guard/index.d.ts.map +1 -1
  58. package/dist/doc-sync-guard.js +2 -1
  59. package/dist/duplicate-code-detector/index.d.ts +26 -1
  60. package/dist/duplicate-code-detector/index.d.ts.map +1 -1
  61. package/dist/duplicate-code-detector.js +178 -67
  62. package/dist/error-lens/index.d.ts +1 -1
  63. package/dist/error-lens/index.d.ts.map +1 -1
  64. package/dist/factories/index.d.ts +4 -0
  65. package/dist/factories/index.d.ts.map +1 -0
  66. package/dist/factories.d.ts +1 -0
  67. package/dist/factories.js +74 -0
  68. package/dist/feature-flag-tracker/index.d.ts +1 -1
  69. package/dist/feature-flag-tracker/index.d.ts.map +1 -1
  70. package/dist/feature-flag-tracker.js +29 -29
  71. package/dist/file-watcher/index.d.ts +1 -1
  72. package/dist/file-watcher/index.d.ts.map +1 -1
  73. package/dist/format-on-save/index.d.ts +1 -1
  74. package/dist/format-on-save/index.d.ts.map +1 -1
  75. package/dist/format-on-save.js +2 -1
  76. package/dist/generated-plugin-exports.d.ts +65 -0
  77. package/dist/generated-plugin-exports.d.ts.map +1 -0
  78. package/dist/git-autocommit/index.d.ts +1 -1
  79. package/dist/git-autocommit/index.d.ts.map +1 -1
  80. package/dist/import-organizer/index.d.ts +1 -1
  81. package/dist/import-organizer/index.d.ts.map +1 -1
  82. package/dist/import-organizer.js +2 -1
  83. package/dist/index.d.ts +4 -183
  84. package/dist/index.d.ts.map +1 -1
  85. package/dist/index.js +17675 -17377
  86. package/dist/injection-shield/index.d.ts +1 -1
  87. package/dist/injection-shield/index.d.ts.map +1 -1
  88. package/dist/interface-contract-guard/index.d.ts +1 -1
  89. package/dist/interface-contract-guard/index.d.ts.map +1 -1
  90. package/dist/interface-contract-guard.js +29 -29
  91. package/dist/knowledge-graph/index.d.ts +1 -1
  92. package/dist/knowledge-graph/index.d.ts.map +1 -1
  93. package/dist/license-audit-gate/index.d.ts +1 -1
  94. package/dist/license-audit-gate/index.d.ts.map +1 -1
  95. package/dist/lint-gate/index.d.ts +1 -1
  96. package/dist/lint-gate/index.d.ts.map +1 -1
  97. package/dist/lint-gate.js +10 -1
  98. package/dist/llm-cache/index.d.ts +5 -1
  99. package/dist/llm-cache/index.d.ts.map +1 -1
  100. package/dist/llm-cache.js +16 -8
  101. package/dist/loop-breaker/index.d.ts +1 -1
  102. package/dist/loop-breaker/index.d.ts.map +1 -1
  103. package/dist/loop-breaker.js +10 -4
  104. package/dist/manifest/index.d.ts +16 -0
  105. package/dist/manifest/index.d.ts.map +1 -0
  106. package/dist/manifest.d.ts +1 -0
  107. package/dist/manifest.js +152 -0
  108. package/dist/migration-planner/index.d.ts +1 -1
  109. package/dist/migration-planner/index.d.ts.map +1 -1
  110. package/dist/migration-planner.js +2 -1
  111. package/dist/model-router/index.d.ts +1 -1
  112. package/dist/model-router/index.d.ts.map +1 -1
  113. package/dist/notify-hub/index.d.ts +1 -1
  114. package/dist/notify-hub/index.d.ts.map +1 -1
  115. package/dist/notify-hub/webhook-channel.d.ts +1 -1
  116. package/dist/notify-hub/webhook-channel.d.ts.map +1 -1
  117. package/dist/path-guard/index.d.ts +1 -1
  118. package/dist/path-guard/index.d.ts.map +1 -1
  119. package/dist/performance-regression-gate/index.d.ts +1 -1
  120. package/dist/performance-regression-gate/index.d.ts.map +1 -1
  121. package/dist/plugin-stack-observer/index.d.ts +1 -1
  122. package/dist/plugin-stack-observer/index.d.ts.map +1 -1
  123. package/dist/pr-drafter/index.d.ts +1 -1
  124. package/dist/pr-drafter/index.d.ts.map +1 -1
  125. package/dist/pr-drafter.js +28 -29
  126. package/dist/process-guard/index.d.ts +1 -1
  127. package/dist/process-guard/index.d.ts.map +1 -1
  128. package/dist/prompt-firewall/index.d.ts +1 -1
  129. package/dist/prompt-firewall/index.d.ts.map +1 -1
  130. package/dist/refactor-suggester/index.d.ts +1 -1
  131. package/dist/refactor-suggester/index.d.ts.map +1 -1
  132. package/dist/refactor-suggester.js +29 -29
  133. package/dist/release-notes-generator/index.d.ts +1 -1
  134. package/dist/release-notes-generator/index.d.ts.map +1 -1
  135. package/dist/release-notes-generator.js +29 -22
  136. package/dist/runtime/index.d.ts +15 -0
  137. package/dist/runtime/index.d.ts.map +1 -1
  138. package/dist/runtime/llm.d.ts +1 -1
  139. package/dist/runtime/llm.d.ts.map +1 -1
  140. package/dist/runtime.js +43 -2
  141. package/dist/schema-evolution-guard/index.d.ts +1 -1
  142. package/dist/schema-evolution-guard/index.d.ts.map +1 -1
  143. package/dist/schema-evolution-guard.js +2 -1
  144. package/dist/secret-scanner/index.d.ts +1 -1
  145. package/dist/secret-scanner/index.d.ts.map +1 -1
  146. package/dist/secret-scanner.js +7 -1
  147. package/dist/security-hotspot-scanner/index.d.ts +1 -1
  148. package/dist/security-hotspot-scanner/index.d.ts.map +1 -1
  149. package/dist/security-hotspot-scanner.js +26 -19
  150. package/dist/semantic-search-indexer/index.d.ts +1 -1
  151. package/dist/semantic-search-indexer/index.d.ts.map +1 -1
  152. package/dist/semver-bump/index.d.ts +1 -1
  153. package/dist/semver-bump/index.d.ts.map +1 -1
  154. package/dist/semver-bump.js +78 -43
  155. package/dist/session-recap/index.d.ts +1 -1
  156. package/dist/session-recap/index.d.ts.map +1 -1
  157. package/dist/shell-check/index.d.ts +1 -1
  158. package/dist/shell-check/index.d.ts.map +1 -1
  159. package/dist/smart-rename/index.d.ts +1 -1
  160. package/dist/smart-rename/index.d.ts.map +1 -1
  161. package/dist/spec-linker/index.d.ts +1 -1
  162. package/dist/spec-linker/index.d.ts.map +1 -1
  163. package/dist/spec-linker.js +222 -20772
  164. package/dist/template-engine/index.d.ts +1 -1
  165. package/dist/template-engine/index.d.ts.map +1 -1
  166. package/dist/template-engine.js +4 -6
  167. package/dist/test-coverage-gate/index.d.ts +1 -1
  168. package/dist/test-coverage-gate/index.d.ts.map +1 -1
  169. package/dist/test-coverage-gate.js +29 -14
  170. package/dist/test-flake-detector/index.d.ts +1 -1
  171. package/dist/test-flake-detector/index.d.ts.map +1 -1
  172. package/dist/test-flake-detector.js +31 -20
  173. package/dist/test-generator/index.d.ts +1 -1
  174. package/dist/test-generator/index.d.ts.map +1 -1
  175. package/dist/test-runner-gate/index.d.ts +1 -1
  176. package/dist/test-runner-gate/index.d.ts.map +1 -1
  177. package/dist/test-runner-gate.js +2 -1
  178. package/dist/todo-listener/index.d.ts +1 -32
  179. package/dist/todo-listener/index.d.ts.map +1 -1
  180. package/dist/todo-tracker/index.d.ts +1 -1
  181. package/dist/todo-tracker/index.d.ts.map +1 -1
  182. package/dist/token-budget/index.d.ts +1 -1
  183. package/dist/token-budget/index.d.ts.map +1 -1
  184. package/dist/token-throttle/index.d.ts +1 -1
  185. package/dist/token-throttle/index.d.ts.map +1 -1
  186. package/dist/type-gate/index.d.ts +1 -1
  187. package/dist/type-gate/index.d.ts.map +1 -1
  188. package/dist/type-gate.js +11 -4
  189. package/package.json +80 -68
@@ -1,5 +1,5 @@
1
1
  // src/security-hotspot-scanner/index.ts
2
- import { readdirSync, readFileSync, statSync } from "node:fs";
2
+ import { readdir, readFile, stat } from "node:fs/promises";
3
3
  import { isAbsolute as isAbsolute2, relative as relative2, resolve as resolve2 } from "node:path";
4
4
 
5
5
  // src/runtime/index.ts
@@ -16,7 +16,8 @@ function withinProjectPath(projectRoot, candidate) {
16
16
  return rel === "" || !rel.startsWith("..") && !isAbsolute(rel);
17
17
  }
18
18
  function withinProject(p) {
19
- return withinProjectPath(process.cwd(), p) || relative(process.cwd(), p) === ".";
19
+ const cwd = process.cwd();
20
+ return withinProjectPath(cwd, p) || relative(cwd, p) === ".";
20
21
  }
21
22
 
22
23
  // src/security-hotspot-scanner/index.ts
@@ -38,14 +39,20 @@ var DEFAULTS = {
38
39
  maxFindings: 10,
39
40
  scanOnChange: [".js", ".jsx", ".ts", ".tsx", ".mjs", ".cjs", ".py", ".java", ".go", ".rb", ".php"]
40
41
  };
42
+ var scanOnChangeSet = new Set(DEFAULTS.scanOnChange);
41
43
  function readConfig(raw) {
42
- if (!raw || typeof raw !== "object") return { ...DEFAULTS };
44
+ if (!raw || typeof raw !== "object") {
45
+ scanOnChangeSet = new Set(DEFAULTS.scanOnChange);
46
+ return { ...DEFAULTS };
47
+ }
43
48
  const r = raw;
49
+ const scanOnChange = Array.isArray(r["scanOnChange"]) ? r["scanOnChange"].filter((x) => typeof x === "string") : DEFAULTS.scanOnChange;
50
+ scanOnChangeSet = new Set(scanOnChange);
44
51
  return {
45
52
  enabled: r["enabled"] === true,
46
53
  severity: r["severity"] === "block" ? "block" : DEFAULTS.severity,
47
54
  maxFindings: typeof r["maxFindings"] === "number" && r["maxFindings"] >= 1 && r["maxFindings"] <= 100 ? r["maxFindings"] : DEFAULTS.maxFindings,
48
- scanOnChange: Array.isArray(r["scanOnChange"]) ? r["scanOnChange"].filter((x) => typeof x === "string") : DEFAULTS.scanOnChange
55
+ scanOnChange
49
56
  };
50
57
  }
51
58
  var PATTERNS = [
@@ -101,7 +108,7 @@ function isSourceFile(filePath, extensions) {
101
108
  const lower = filePath.toLowerCase();
102
109
  return extensions.some((ext) => lower.endsWith(ext));
103
110
  }
104
- function scanPath(inputPath, cfg) {
111
+ async function scanPath(inputPath, cfg) {
105
112
  const start = Date.now();
106
113
  const root = process.cwd();
107
114
  const resolved = isAbsolute2(inputPath) ? resolve2(inputPath) : resolve2(root, inputPath);
@@ -118,10 +125,10 @@ function scanPath(inputPath, cfg) {
118
125
  let filesScanned = 0;
119
126
  const allFindings = [];
120
127
  const maxPerFile = Math.max(1, Math.floor(cfg.maxFindings / 2));
121
- const scanFile = (filePath) => {
128
+ const scanFile = async (filePath) => {
122
129
  if (!isSourceFile(filePath, cfg.scanOnChange)) return;
123
130
  try {
124
- const content = readFileSync(filePath, "utf-8");
131
+ const content = await readFile(filePath, "utf-8");
125
132
  filesScanned += 1;
126
133
  const findings = scanSource(content, maxPerFile);
127
134
  for (const f of findings) {
@@ -131,10 +138,10 @@ function scanPath(inputPath, cfg) {
131
138
  } catch {
132
139
  }
133
140
  };
134
- const walk = (dir) => {
141
+ const walk = async (dir) => {
135
142
  let entries;
136
143
  try {
137
- entries = readdirSync(dir);
144
+ entries = await readdir(dir);
138
145
  } catch {
139
146
  return;
140
147
  }
@@ -142,25 +149,25 @@ function scanPath(inputPath, cfg) {
142
149
  if (allFindings.length >= cfg.maxFindings) return;
143
150
  const full = resolve2(dir, entry);
144
151
  try {
145
- const st = statSync(full);
152
+ const st = await stat(full);
146
153
  if (st.isDirectory()) {
147
154
  if (entry.startsWith(".") || entry === "node_modules" || entry === "dist" || entry === "coverage") {
148
155
  continue;
149
156
  }
150
- walk(full);
157
+ await walk(full);
151
158
  } else if (st.isFile()) {
152
- scanFile(full);
159
+ await scanFile(full);
153
160
  }
154
161
  } catch {
155
162
  }
156
163
  }
157
164
  };
158
165
  try {
159
- const st = statSync(resolved);
166
+ const st = await stat(resolved);
160
167
  if (st.isDirectory()) {
161
- walk(resolved);
168
+ await walk(resolved);
162
169
  } else if (st.isFile()) {
163
- scanFile(resolved);
170
+ await scanFile(resolved);
164
171
  } else {
165
172
  return {
166
173
  path: inputPath,
@@ -238,7 +245,7 @@ var plugin = {
238
245
  state.hookUnregister = null;
239
246
  }
240
247
  const cfg = readConfig(api.config.extensions?.["security-hotspot-scanner"]);
241
- const hook = (input) => {
248
+ const hook = async (input) => {
242
249
  if (!cfg.enabled) return;
243
250
  if (input.toolResult?.isError) return;
244
251
  const inp = input.toolInput ?? {};
@@ -246,12 +253,12 @@ var plugin = {
246
253
  if (!sourcePath || typeof sourcePath !== "string") return;
247
254
  if (!withinProject(sourcePath)) return;
248
255
  const ext = sourcePath.includes(".") ? sourcePath.slice(sourcePath.lastIndexOf(".")).toLowerCase() : "";
249
- if (!cfg.scanOnChange.includes(ext)) {
256
+ if (!scanOnChangeSet.has(ext)) {
250
257
  state.skippedCount += 1;
251
258
  return;
252
259
  }
253
260
  state.hookInvocationCount += 1;
254
- const result = scanPath(sourcePath, cfg);
261
+ const result = await scanPath(sourcePath, cfg);
255
262
  state.scanCount += 1;
256
263
  state.fileScanCount += result.filesScanned;
257
264
  if (!result.scanned) {
@@ -307,7 +314,7 @@ Review or remove the risky pattern(s).`;
307
314
  mutating: false,
308
315
  async execute(input) {
309
316
  if (!cfg.enabled) return { ok: false, error: "security-hotspot-scanner is disabled" };
310
- const result = scanPath(input.path, cfg);
317
+ const result = await scanPath(input.path, cfg);
311
318
  state.scanCount += 1;
312
319
  state.fileScanCount += result.filesScanned;
313
320
  state.findingCount += result.findings.length;
@@ -30,7 +30,7 @@
30
30
  *
31
31
  * @public
32
32
  */
33
- import type { Plugin } from '@wrongstack/core';
33
+ import type { Plugin } from '@wrongstack/core/types';
34
34
  declare const plugin: Plugin;
35
35
  export default plugin;
36
36
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/semantic-search-indexer/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAKH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AA6b/C,QAAA,MAAM,MAAM,EAAE,MA6Nb,CAAC;eAEa,MAAM"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/semantic-search-indexer/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAKH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AA6brD,QAAA,MAAM,MAAM,EAAE,MA6Nb,CAAC;eAEa,MAAM"}
@@ -6,7 +6,7 @@
6
6
  * - semver_current: Show the current version from package.json
7
7
  * - semver_changelog: Generate a changelog between two versions
8
8
  */
9
- import type { Plugin } from '@wrongstack/core';
9
+ import type { Plugin } from '@wrongstack/core/types';
10
10
  type BumpType = 'major' | 'minor' | 'patch' | 'auto';
11
11
  interface ConventionalCommit {
12
12
  hash: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/semver-bump/index.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAuC/C,KAAK,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC;AAErD,UAAU,kBAAkB;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAoFD;+DAC+D;AAC/D,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAQnF;AAmBD,wBAAgB,aAAa,CAAC,OAAO,EAAE,kBAAkB,EAAE,GAAG,QAAQ,CAIrE;AAmED,QAAA,MAAM,MAAM,EAAE,MA6bb,CAAC;eAEa,MAAM"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/semver-bump/index.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAuCrD,KAAK,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC;AAErD,UAAU,kBAAkB;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAqGD;+DAC+D;AAC/D,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAQnF;AAmBD,wBAAgB,aAAa,CAAC,OAAO,EAAE,kBAAkB,EAAE,GAAG,QAAQ,CAIrE;AAmED,QAAA,MAAM,MAAM,EAAE,MAgcb,CAAC;eAEa,MAAM"}
@@ -1,8 +1,8 @@
1
1
  // src/semver-bump/index.ts
2
- import { expectDefined } from "@wrongstack/core";
2
+ import { expectDefined } from "@wrongstack/core/utils";
3
3
  import { toErrorMessage } from "@wrongstack/core/utils";
4
- import { execFileSync } from "node:child_process";
5
- import { existsSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
4
+ import { execFile } from "node:child_process";
5
+ import { access, readFile, readdir, writeFile } from "node:fs/promises";
6
6
  import { isAbsolute, join, relative, resolve } from "node:path";
7
7
  var API_VERSION = "^0.1.10";
8
8
  function resolveProjectRoot(rawCwd, root = process.cwd()) {
@@ -21,41 +21,65 @@ var state = {
21
21
  /** Most recent bump result, surfaced by health() (null until first call). */
22
22
  lastBump: null
23
23
  };
24
- function runGit(args, cwd) {
25
- try {
26
- return execFileSync("git", args, {
24
+ function runCommand(command, args, cwd) {
25
+ return new Promise((resolve2, reject) => {
26
+ execFile(command, args, {
27
27
  encoding: "utf-8",
28
28
  cwd,
29
- stdio: ["pipe", "pipe", "pipe"],
30
29
  timeout: 3e4,
31
30
  windowsHide: true
32
- }).trim();
31
+ }, (err, stdout, stderr) => {
32
+ if (!err) {
33
+ resolve2(stdout.trim());
34
+ return;
35
+ }
36
+ const failure = err;
37
+ reject(Object.assign(failure, { stderr: stderr || void 0 }));
38
+ });
39
+ });
40
+ }
41
+ async function runGit(args, cwd) {
42
+ try {
43
+ return await runCommand("git", args, cwd);
33
44
  } catch (err) {
34
45
  const e = err;
35
- if (e.status === 128) throw new Error("Not a git repository");
46
+ if (e.status === 128 || e.code === 128) throw new Error("Not a git repository");
36
47
  throw new Error(`git failed: ${e.message ?? e.stderr ?? String(err)}`);
37
48
  }
38
49
  }
39
- function getPackageJson(cwd) {
50
+ async function getPackageJson(cwd) {
40
51
  const path = cwd ? `${cwd}/package.json` : "package.json";
41
- if (!existsSync(path)) return null;
42
52
  try {
43
- return JSON.parse(readFileSync(path, "utf-8"));
53
+ await access(path);
54
+ return JSON.parse(await readFile(path, "utf-8"));
44
55
  } catch {
45
56
  return null;
46
57
  }
47
58
  }
48
- function collectManifests(root) {
59
+ async function collectManifests(root) {
49
60
  const paths = [];
50
61
  const rootPkg = join(root, "package.json");
51
- if (existsSync(rootPkg)) paths.push(rootPkg);
62
+ try {
63
+ await access(rootPkg);
64
+ paths.push(rootPkg);
65
+ } catch {
66
+ }
52
67
  for (const group of ["packages", "apps"]) {
53
68
  const groupDir = join(root, group);
54
- if (!existsSync(groupDir)) continue;
55
- for (const entry of readdirSync(groupDir, { withFileTypes: true })) {
69
+ let entries;
70
+ try {
71
+ entries = await readdir(groupDir, { withFileTypes: true });
72
+ } catch {
73
+ continue;
74
+ }
75
+ for (const entry of entries) {
56
76
  if (!entry.isDirectory()) continue;
57
77
  const candidate = join(groupDir, entry.name, "package.json");
58
- if (existsSync(candidate)) paths.push(candidate);
78
+ try {
79
+ await access(candidate);
80
+ paths.push(candidate);
81
+ } catch {
82
+ }
59
83
  }
60
84
  }
61
85
  return paths;
@@ -94,9 +118,9 @@ function parseConventional(subject) {
94
118
  message: m?.[5] ?? subject
95
119
  };
96
120
  }
97
- function getRecentCommits(sinceTag, cwd) {
121
+ async function getRecentCommits(sinceTag, cwd) {
98
122
  const range = sinceTag ? `${sinceTag}..HEAD` : "-30";
99
- const output = runGit(["log", range, "--format=%H %s"], cwd);
123
+ const output = await runGit(["log", range, "--format=%H %s"], cwd);
100
124
  if (!output) return [];
101
125
  return output.split("\n").filter(Boolean).map((line) => {
102
126
  const spaceIdx = line.indexOf(" ");
@@ -208,7 +232,7 @@ var plugin = {
208
232
  return { ok: false, error: "cwd must stay within the current project directory" };
209
233
  }
210
234
  cwd = safeCwd;
211
- const pkg = getPackageJson(cwd);
235
+ const pkg = await getPackageJson(cwd);
212
236
  if (!pkg) {
213
237
  return { ok: false, error: "No package.json found" };
214
238
  }
@@ -218,12 +242,12 @@ var plugin = {
218
242
  if (part === "auto") {
219
243
  let lastTag;
220
244
  try {
221
- const tagsOutput = runGit(["describe", "--tags", "--abbrev=0"], cwd);
245
+ const tagsOutput = await runGit(["describe", "--tags", "--abbrev=0"], cwd);
222
246
  lastTag = tagsOutput || void 0;
223
247
  } catch {
224
248
  }
225
249
  try {
226
- commits = getRecentCommits(lastTag, cwd);
250
+ commits = await getRecentCommits(lastTag, cwd);
227
251
  } catch (err) {
228
252
  const msg = toErrorMessage(err);
229
253
  return { ok: false, error: `Git error: ${msg}`, bumpPart: "patch" };
@@ -246,38 +270,43 @@ var plugin = {
246
270
  }
247
271
  const root = cwd ?? process.cwd();
248
272
  const bumpScript = join(root, "scripts", "bump-version.mjs");
249
- const changed = collectManifests(root);
250
- if (existsSync(bumpScript)) {
273
+ const changed = await collectManifests(root);
274
+ let hasBumpScript = true;
275
+ try {
276
+ await access(bumpScript);
277
+ } catch {
278
+ hasBumpScript = false;
279
+ }
280
+ if (hasBumpScript) {
251
281
  try {
252
- execFileSync(process.execPath, [bumpScript, "set", newVersion], {
253
- cwd: root,
254
- stdio: ["pipe", "pipe", "pipe"],
255
- timeout: 3e4,
256
- windowsHide: true
257
- });
282
+ await runCommand(process.execPath, [bumpScript, "set", newVersion], root);
258
283
  } catch (err) {
259
284
  const msg = toErrorMessage(err);
260
285
  return { ok: false, error: `bump script failed: ${msg}` };
261
286
  }
262
287
  for (const rel of ["package.json", "package-lock.json", "src/lib/utils.ts", "index.html"]) {
263
288
  const p = join(root, "website", rel);
264
- if (existsSync(p)) changed.push(p);
289
+ try {
290
+ await access(p);
291
+ changed.push(p);
292
+ } catch {
293
+ }
265
294
  }
266
295
  } else {
267
296
  for (const manifest of changed) {
268
- const pkgData = JSON.parse(readFileSync(manifest, "utf-8"));
297
+ const pkgData = JSON.parse(await readFile(manifest, "utf-8"));
269
298
  pkgData.version = newVersion;
270
- writeFileSync(manifest, JSON.stringify(pkgData, null, 2) + "\n", "utf-8");
299
+ await writeFile(manifest, JSON.stringify(pkgData, null, 2) + "\n", "utf-8");
271
300
  }
272
301
  }
273
302
  try {
274
- runGit(["add", "--", ...changed], cwd);
275
- runGit(["commit", "-m", `chore: bump version to ${newVersion}`], cwd);
303
+ await runGit(["add", "--", ...changed], cwd);
304
+ await runGit(["commit", "-m", `chore: bump version to ${newVersion}`], cwd);
276
305
  } catch {
277
306
  }
278
307
  if (autoTag) {
279
308
  try {
280
- runGit(["tag", "-a", `${tagPrefix}${newVersion}`, "-m", `Release ${newVersion}`], cwd);
309
+ await runGit(["tag", "-a", `${tagPrefix}${newVersion}`, "-m", `Release ${newVersion}`], cwd);
281
310
  } catch {
282
311
  }
283
312
  }
@@ -354,17 +383,17 @@ var plugin = {
354
383
  const mode = tokens.find((t) => !t.startsWith("--")) ?? "status";
355
384
  const cwd = ctx?.cwd;
356
385
  if (mode === "status") {
357
- const pkg = getPackageJson(cwd);
386
+ const pkg = await getPackageJson(cwd);
358
387
  if (!pkg) return { message: "No package.json found" };
359
388
  let lastTag;
360
389
  try {
361
- lastTag = runGit(["describe", "--tags", "--abbrev=0"], cwd) || void 0;
390
+ lastTag = await runGit(["describe", "--tags", "--abbrev=0"], cwd) || void 0;
362
391
  } catch {
363
392
  }
364
393
  let suggestion = "patch";
365
394
  let commitCount = 0;
366
395
  try {
367
- const commits = getRecentCommits(lastTag, cwd);
396
+ const commits = await getRecentCommits(lastTag, cwd);
368
397
  commitCount = commits.length;
369
398
  suggestion = determineBump(commits);
370
399
  } catch {
@@ -411,15 +440,18 @@ var plugin = {
411
440
  if (!safeCwd) {
412
441
  return { ok: false, error: "cwd must stay within the current project directory" };
413
442
  }
414
- const pkg = getPackageJson(safeCwd);
443
+ const pkg = await getPackageJson(safeCwd);
415
444
  const currentVersion = pkg?.version ?? "unknown";
416
445
  let latestTag = null;
417
446
  let commitsSinceTag = 0;
418
447
  try {
419
- const tagsOutput = runGit(["describe", "--tags", "--abbrev=0"], safeCwd);
448
+ const tagsOutput = await runGit(["describe", "--tags", "--abbrev=0"], safeCwd);
420
449
  latestTag = tagsOutput || null;
421
450
  if (latestTag) {
422
- const countOutput = runGit(["rev-list", "--count", `${latestTag}..HEAD`], safeCwd);
451
+ const countOutput = await runGit(
452
+ ["rev-list", "--count", `${latestTag}..HEAD`],
453
+ safeCwd
454
+ );
423
455
  commitsSinceTag = Number.parseInt(countOutput, 10) || 0;
424
456
  }
425
457
  } catch {
@@ -462,7 +494,10 @@ var plugin = {
462
494
  const range = from ? `${from}..${to}` : to;
463
495
  let commits;
464
496
  try {
465
- const output = runGit(["log", range === to ? "-30" : range, "--format=%H %s"], safeCwd);
497
+ const output = await runGit(
498
+ ["log", range === to ? "-30" : range, "--format=%H %s"],
499
+ safeCwd
500
+ );
466
501
  commits = output.split("\n").filter(Boolean).map((line) => {
467
502
  const spaceIdx = line.indexOf(" ");
468
503
  const hash = line.slice(0, spaceIdx);
@@ -42,7 +42,7 @@
42
42
  *
43
43
  * @public
44
44
  */
45
- import type { Plugin } from '@wrongstack/core';
45
+ import type { Plugin } from '@wrongstack/core/types';
46
46
  declare const plugin: Plugin;
47
47
  export default plugin;
48
48
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/session-recap/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AA4M/C,QAAA,MAAM,MAAM,EAAE,MA4Yb,CAAC;eAEa,MAAM"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/session-recap/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AA4MrD,QAAA,MAAM,MAAM,EAAE,MA4Yb,CAAC;eAEa,MAAM"}
@@ -8,7 +8,7 @@
8
8
  * via the `directory` + `pattern` parameters. Pass `files` for specific
9
9
  * files, or `directory` (optionally with `pattern`) for recursive scanning.
10
10
  */
11
- import type { Plugin } from '@wrongstack/core';
11
+ import type { Plugin } from '@wrongstack/core/types';
12
12
  declare const plugin: Plugin;
13
13
  export default plugin;
14
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/shell-check/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AA0M/C,QAAA,MAAM,MAAM,EAAE,MAgPb,CAAC;eAEa,MAAM"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/shell-check/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AA0MrD,QAAA,MAAM,MAAM,EAAE,MAgPb,CAAC;eAEa,MAAM"}
@@ -18,7 +18,7 @@
18
18
  *
19
19
  * @public
20
20
  */
21
- import type { Plugin } from '@wrongstack/core';
21
+ import type { Plugin } from '@wrongstack/core/types';
22
22
  declare const plugin: Plugin;
23
23
  export default plugin;
24
24
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/smart-rename/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AA0F/C,QAAA,MAAM,MAAM,EAAE,MAqIb,CAAC;eAEa,MAAM"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/smart-rename/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AA0FrD,QAAA,MAAM,MAAM,EAAE,MAqIb,CAAC;eAEa,MAAM"}
@@ -43,7 +43,7 @@
43
43
  *
44
44
  * @public
45
45
  */
46
- import type { Plugin } from '@wrongstack/core';
46
+ import type { Plugin } from '@wrongstack/core/types';
47
47
  declare const plugin: Plugin;
48
48
  export default plugin;
49
49
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/spec-linker/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAwP/C,QAAA,MAAM,MAAM,EAAE,MAuOb,CAAC;eAEa,MAAM"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/spec-linker/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAwPrD,QAAA,MAAM,MAAM,EAAE,MAuOb,CAAC;eAEa,MAAM"}