@wrongstack/tools 0.298.3 → 0.300.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 (42) hide show
  1. package/dist/audit.js +6 -2
  2. package/dist/bash.js +20 -2
  3. package/dist/builtin.js +1901 -327
  4. package/dist/codebase-index/background-indexer.d.ts +6 -1
  5. package/dist/codebase-index/codebase-incoming-calls-tool.d.ts +34 -0
  6. package/dist/codebase-index/codebase-outgoing-calls-tool.d.ts +34 -0
  7. package/dist/codebase-index/import-extractor.d.ts +39 -0
  8. package/dist/codebase-index/index-service.d.ts +24 -2
  9. package/dist/codebase-index/index.d.ts +4 -2
  10. package/dist/codebase-index/index.js +1779 -256
  11. package/dist/codebase-index/languages.d.ts +24 -0
  12. package/dist/codebase-index/module-resolver.d.ts +78 -0
  13. package/dist/codebase-index/module-roots.d.ts +81 -0
  14. package/dist/codebase-index/parser-output.d.ts +29 -0
  15. package/dist/codebase-index/project-server.js +1556 -237
  16. package/dist/codebase-index/rs-parser.d.ts +22 -0
  17. package/dist/codebase-index/schema.d.ts +47 -1
  18. package/dist/codebase-index/worker-protocol.d.ts +14 -0
  19. package/dist/codebase-index/worker.js +1545 -238
  20. package/dist/codebase-index/writer-graph-helpers.d.ts +17 -5
  21. package/dist/codebase-index/writer-graph-reader.d.ts +24 -1
  22. package/dist/codebase-index/writer-ref-mapper.d.ts +3 -0
  23. package/dist/codebase-index/writer-schema.d.ts +15 -3
  24. package/dist/codebase-index/writer.d.ts +97 -4
  25. package/dist/exec.js +39 -2
  26. package/dist/format.js +6 -2
  27. package/dist/index.js +1901 -327
  28. package/dist/install.js +6 -2
  29. package/dist/json.js +51 -2
  30. package/dist/languages/index.js +6 -2
  31. package/dist/lint.js +6 -2
  32. package/dist/outdated.js +6 -2
  33. package/dist/pack.js +1899 -327
  34. package/dist/process-registry.d.ts +6 -0
  35. package/dist/process-registry.js +6 -2
  36. package/dist/ps-slash.js +10 -2
  37. package/dist/read.js +1551 -244
  38. package/dist/test.js +6 -2
  39. package/dist/tool-tier.js +1901 -327
  40. package/dist/typecheck.js +6 -2
  41. package/package.json +3 -3
  42. package/dist/codebase-index/refs-extractor.d.ts +0 -11
package/dist/install.js CHANGED
@@ -673,7 +673,7 @@ var ProcessRegistryImpl = class {
673
673
  const p = this.processes.get(pid);
674
674
  if (!p) return false;
675
675
  if (p.killed) return true;
676
- if (p.protected) return false;
676
+ if (p.protected && opts.includeProtected !== true) return false;
677
677
  if (opts.preserveBackground && p.background) return false;
678
678
  const { force = false, graceMs = DEFAULT_GRACE_MS } = opts;
679
679
  const isWin2 = os.platform() === "win32";
@@ -724,9 +724,13 @@ var ProcessRegistryImpl = class {
724
724
  killAll(opts = {}) {
725
725
  const pids = Array.from(this.processes.keys());
726
726
  const killed = [];
727
+ const includeProtected = opts.includeProtected === true;
727
728
  for (const pid of pids) {
728
729
  const p = this.processes.get(pid);
729
- if (p && !p.protected && this.kill(pid, opts)) killed.push(pid);
730
+ if (!p) continue;
731
+ if (p.protected && !includeProtected) continue;
732
+ if (opts.preserveBackground && p.background) continue;
733
+ if (this.kill(pid, opts)) killed.push(pid);
730
734
  }
731
735
  return killed;
732
736
  }
package/dist/json.js CHANGED
@@ -2,6 +2,51 @@
2
2
  import * as fs from "node:fs/promises";
3
3
  import { deepMerge as deepMergeCore } from "@wrongstack/core/utils";
4
4
 
5
+ // src/_regex.ts
6
+ var MAX_PATTERN_LEN = 256;
7
+ var DANGEROUS_PATTERNS = [
8
+ // (a+)+, (.*)+, etc — nested quantifier on a group with internal quantifier
9
+ /(\([^)]*[+*][^)]*\))[+*]/,
10
+ /(\(\?:[^)]*[+*][^)]*\))[+*]/,
11
+ // Adjacent quantifiers: a++ a*+
12
+ /[+*]{2,}/,
13
+ // Quantifier on alternation with length 2+
14
+ /\([^|)]+\|[^)]+\)[+*][+*]/,
15
+ // Greedy quantifier inside lookahead/lookbehind — (?!.*a+)
16
+ /[([][^)\]]*[+*][^)\]]*[)\]][^)]*\?\??/
17
+ ];
18
+ function compileUserRegex(pattern, flags) {
19
+ if (typeof pattern !== "string") {
20
+ return { ok: false, reason: "pattern must be a string" };
21
+ }
22
+ if (pattern.length === 0) {
23
+ return { ok: false, reason: "pattern is empty" };
24
+ }
25
+ if (pattern.length > MAX_PATTERN_LEN) {
26
+ return { ok: false, reason: `pattern exceeds ${MAX_PATTERN_LEN} characters` };
27
+ }
28
+ for (const rx of DANGEROUS_PATTERNS) {
29
+ if (rx.test(pattern)) {
30
+ return {
31
+ ok: false,
32
+ reason: "pattern looks vulnerable to catastrophic backtracking \u2014 rewrite without nested quantifiers"
33
+ };
34
+ }
35
+ }
36
+ try {
37
+ return { ok: true, regex: new RegExp(pattern, flags) };
38
+ } catch (err) {
39
+ return {
40
+ ok: false,
41
+ reason: err instanceof Error ? err.message : "invalid regex"
42
+ };
43
+ }
44
+ }
45
+ var MAX_SUBJECT_LEN = 64 * 1024;
46
+ function capSubject(line) {
47
+ return line.length > MAX_SUBJECT_LEN ? line.slice(0, MAX_SUBJECT_LEN) : line;
48
+ }
49
+
5
50
  // src/_util.ts
6
51
  import * as fsp from "node:fs/promises";
7
52
  import * as path from "node:path";
@@ -500,8 +545,12 @@ function validateJsonSchema(data, schema) {
500
545
  }
501
546
  }
502
547
  if (typeof value === "string" && s["pattern"]) {
503
- const re = new RegExp(s["pattern"]);
504
- if (!re.test(value)) errors.push(`${path2}: does not match pattern ${s["pattern"]}`);
548
+ const compiled = compileUserRegex(s["pattern"], "");
549
+ if (!compiled.ok) {
550
+ errors.push(`${path2}: invalid schema pattern \u2014 ${compiled.reason}`);
551
+ } else if (!compiled.regex.test(capSubject(value))) {
552
+ errors.push(`${path2}: does not match pattern ${s["pattern"]}`);
553
+ }
505
554
  }
506
555
  if (typeof value === "string" && s["minLength"] !== void 0 && value.length < s["minLength"]) {
507
556
  errors.push(`${path2}: string too short (min ${s["minLength"]})`);
@@ -2794,7 +2794,7 @@ var ProcessRegistryImpl = class {
2794
2794
  const p = this.processes.get(pid);
2795
2795
  if (!p) return false;
2796
2796
  if (p.killed) return true;
2797
- if (p.protected) return false;
2797
+ if (p.protected && opts.includeProtected !== true) return false;
2798
2798
  if (opts.preserveBackground && p.background) return false;
2799
2799
  const { force = false, graceMs = DEFAULT_GRACE_MS } = opts;
2800
2800
  const isWin2 = os.platform() === "win32";
@@ -2845,9 +2845,13 @@ var ProcessRegistryImpl = class {
2845
2845
  killAll(opts = {}) {
2846
2846
  const pids = Array.from(this.processes.keys());
2847
2847
  const killed = [];
2848
+ const includeProtected = opts.includeProtected === true;
2848
2849
  for (const pid of pids) {
2849
2850
  const p = this.processes.get(pid);
2850
- if (p && !p.protected && this.kill(pid, opts)) killed.push(pid);
2851
+ if (!p) continue;
2852
+ if (p.protected && !includeProtected) continue;
2853
+ if (opts.preserveBackground && p.background) continue;
2854
+ if (this.kill(pid, opts)) killed.push(pid);
2851
2855
  }
2852
2856
  return killed;
2853
2857
  }
package/dist/lint.js CHANGED
@@ -666,7 +666,7 @@ var ProcessRegistryImpl = class {
666
666
  const p = this.processes.get(pid);
667
667
  if (!p) return false;
668
668
  if (p.killed) return true;
669
- if (p.protected) return false;
669
+ if (p.protected && opts.includeProtected !== true) return false;
670
670
  if (opts.preserveBackground && p.background) return false;
671
671
  const { force = false, graceMs = DEFAULT_GRACE_MS } = opts;
672
672
  const isWin2 = os.platform() === "win32";
@@ -717,9 +717,13 @@ var ProcessRegistryImpl = class {
717
717
  killAll(opts = {}) {
718
718
  const pids = Array.from(this.processes.keys());
719
719
  const killed = [];
720
+ const includeProtected = opts.includeProtected === true;
720
721
  for (const pid of pids) {
721
722
  const p = this.processes.get(pid);
722
- if (p && !p.protected && this.kill(pid, opts)) killed.push(pid);
723
+ if (!p) continue;
724
+ if (p.protected && !includeProtected) continue;
725
+ if (opts.preserveBackground && p.background) continue;
726
+ if (this.kill(pid, opts)) killed.push(pid);
723
727
  }
724
728
  return killed;
725
729
  }
package/dist/outdated.js CHANGED
@@ -3018,7 +3018,7 @@ var init_process_registry = __esm({
3018
3018
  const p = this.processes.get(pid);
3019
3019
  if (!p) return false;
3020
3020
  if (p.killed) return true;
3021
- if (p.protected) return false;
3021
+ if (p.protected && opts.includeProtected !== true) return false;
3022
3022
  if (opts.preserveBackground && p.background) return false;
3023
3023
  const { force = false, graceMs = DEFAULT_GRACE_MS } = opts;
3024
3024
  const isWin2 = os.platform() === "win32";
@@ -3069,9 +3069,13 @@ var init_process_registry = __esm({
3069
3069
  killAll(opts = {}) {
3070
3070
  const pids = Array.from(this.processes.keys());
3071
3071
  const killed = [];
3072
+ const includeProtected = opts.includeProtected === true;
3072
3073
  for (const pid of pids) {
3073
3074
  const p = this.processes.get(pid);
3074
- if (p && !p.protected && this.kill(pid, opts)) killed.push(pid);
3075
+ if (!p) continue;
3076
+ if (p.protected && !includeProtected) continue;
3077
+ if (opts.preserveBackground && p.background) continue;
3078
+ if (this.kill(pid, opts)) killed.push(pid);
3075
3079
  }
3076
3080
  return killed;
3077
3081
  }