@wrongstack/tools 0.309.1 → 0.310.1

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 (58) hide show
  1. package/dist/_regex.d.ts +6 -34
  2. package/dist/bash.js +3 -3
  3. package/dist/builtin.d.ts +17 -14
  4. package/dist/builtin.js +3028 -1675
  5. package/dist/codebase-index/binary-frame.d.ts +57 -8
  6. package/dist/codebase-index/codebase-incoming-calls-tool.d.ts +6 -0
  7. package/dist/codebase-index/codebase-outgoing-calls-tool.d.ts +6 -0
  8. package/dist/codebase-index/codebase-search-tool.d.ts +15 -5
  9. package/dist/codebase-index/index-service.d.ts +3 -19
  10. package/dist/codebase-index/index.js +2735 -1415
  11. package/dist/codebase-index/indexer.d.ts +3 -0
  12. package/dist/codebase-index/parser-batch.d.ts +53 -0
  13. package/dist/codebase-index/parser-dispatch.d.ts +32 -0
  14. package/dist/codebase-index/parser-output.d.ts +14 -0
  15. package/dist/codebase-index/parser-worker-pool.d.ts +57 -4
  16. package/dist/codebase-index/parser-worker-script.d.ts +5 -2
  17. package/dist/codebase-index/parser-worker-script.js +4042 -0
  18. package/dist/codebase-index/project-server-cache.d.ts +16 -0
  19. package/dist/codebase-index/project-server-client.d.ts +2 -2
  20. package/dist/codebase-index/project-server-query-cache.d.ts +88 -0
  21. package/dist/codebase-index/project-server.js +2846 -1308
  22. package/dist/codebase-index/py-parser.d.ts +5 -0
  23. package/dist/codebase-index/schema.d.ts +14 -1
  24. package/dist/codebase-index/sqlite-runtime.d.ts +2 -2
  25. package/dist/codebase-index/tree-sitter/queries.d.ts +30 -3
  26. package/dist/codebase-index/tree-sitter/visitor.d.ts +2 -1
  27. package/dist/codebase-index/vector-search.d.ts +12 -0
  28. package/dist/codebase-index/wal-maintenance.d.ts +58 -0
  29. package/dist/codebase-index/worker-protocol/contracts.d.ts +44 -0
  30. package/dist/codebase-index/worker-protocol.d.ts +17 -1
  31. package/dist/codebase-index/worker.js +2300 -1020
  32. package/dist/codebase-index/writer-admin.d.ts +11 -0
  33. package/dist/codebase-index/writer-helpers.d.ts +31 -1
  34. package/dist/codebase-index/writer-mutations.d.ts +0 -6
  35. package/dist/codebase-index/writer-schema.d.ts +2 -2
  36. package/dist/codebase-index/writer.d.ts +15 -0
  37. package/dist/edit.js +2511 -1203
  38. package/dist/exec.js +5 -3
  39. package/dist/grep.js +5 -124
  40. package/dist/index.js +3028 -1738
  41. package/dist/json.js +5 -124
  42. package/dist/kanban.js +130 -0
  43. package/dist/logs.js +5 -121
  44. package/dist/pack.js +3028 -1675
  45. package/dist/patch.js +2524 -1216
  46. package/dist/plan.js +106 -0
  47. package/dist/read.js +2506 -1198
  48. package/dist/replace.js +2487 -1295
  49. package/dist/search.js +6 -2
  50. package/dist/session-kanban.js +24 -16
  51. package/dist/task.js +106 -0
  52. package/dist/todo.js +106 -0
  53. package/dist/tool-tier.d.ts +11 -0
  54. package/dist/tool-tier.js +3040 -1679
  55. package/dist/tree.js +14 -3
  56. package/dist/win32.js +3 -3
  57. package/dist/write.js +2513 -1205
  58. package/package.json +5 -4
package/dist/exec.js CHANGED
@@ -13,8 +13,8 @@ var argMatches = (args, re) => args.some((a) => re.test(a));
13
13
  var hasShortFlags = (args, letters) => {
14
14
  const seen = /* @__PURE__ */ new Set();
15
15
  for (const a of args) {
16
- if (!a.startsWith("-") || a.startsWith("--")) continue;
17
- for (const ch of a.replace(/^-+/, "")) seen.add(ch);
16
+ if (!/^-[a-zA-Z]+$/.test(a)) continue;
17
+ for (const ch of a.slice(1)) seen.add(ch);
18
18
  }
19
19
  return letters.split("").every((l) => seen.has(l));
20
20
  };
@@ -367,7 +367,9 @@ function detectDanger(cmd, args, bypass) {
367
367
  if (bypass?.has(rule.id)) continue;
368
368
  if (!rule.test(cmd, args)) continue;
369
369
  reasons.push(rule.reason);
370
- matchedRule = rule.id;
370
+ if (matchedRule === void 0 || levelRank(rule.level) >= levelRank(level)) {
371
+ matchedRule = rule.id;
372
+ }
371
373
  if (levelRank(rule.level) > levelRank(level)) {
372
374
  level = rule.level;
373
375
  }
package/dist/grep.js CHANGED
@@ -28,130 +28,11 @@ async function mapWithConcurrency(items, limit, fn) {
28
28
  }
29
29
 
30
30
  // src/_regex.ts
31
- var MAX_PATTERN_LEN = 256;
32
- var DANGEROUS_PATTERNS = [
33
- // (a+)+, (.*)+, etc — nested quantifier on a group with internal quantifier
34
- /(\([^)]*[+*][^)]*\))[+*]/,
35
- /(\(\?:[^)]*[+*][^)]*\))[+*]/,
36
- // Adjacent quantifiers: a++ a*+
37
- /[+*]{2,}/,
38
- // Quantifier on alternation with length 2+
39
- /\([^|)]+\|[^)]+\)[+*][+*]/,
40
- // Greedy quantifier inside lookahead/lookbehind — (?!.*a+)
41
- /[([][^)\]]*[+*][^)\]]*[)\]][^)]*\?\??/
42
- ];
43
- function hasAmbiguousQuantifiedAlternation(pattern) {
44
- for (let i = 0; i < pattern.length; i++) {
45
- if (pattern[i] !== "(") continue;
46
- if (i > 0 && pattern[i - 1] === "\\") continue;
47
- let depth = 0;
48
- let inClass = false;
49
- let j = i;
50
- for (; j < pattern.length; j++) {
51
- const ch = pattern[j];
52
- if (ch === "\\") {
53
- j++;
54
- continue;
55
- }
56
- if (inClass) {
57
- if (ch === "]") inClass = false;
58
- continue;
59
- }
60
- if (ch === "[") {
61
- inClass = true;
62
- continue;
63
- }
64
- if (ch === "(") depth++;
65
- else if (ch === ")") {
66
- depth--;
67
- if (depth === 0) break;
68
- }
69
- }
70
- if (j >= pattern.length) return false;
71
- const next = pattern[j + 1];
72
- if (next !== "+" && next !== "*" && next !== "{") continue;
73
- let inner = pattern.slice(i + 1, j);
74
- inner = inner.replace(/^\?(?::|<?[=!])/u, "");
75
- const branches = [];
76
- let current = "";
77
- let d = 0;
78
- let cls = false;
79
- for (let k = 0; k < inner.length; k++) {
80
- const ch = inner[k];
81
- if (ch === "\\") {
82
- current += ch + (inner[k + 1] ?? "");
83
- k++;
84
- continue;
85
- }
86
- if (cls) {
87
- if (ch === "]") cls = false;
88
- current += ch;
89
- continue;
90
- }
91
- if (ch === "[") {
92
- cls = true;
93
- current += ch;
94
- continue;
95
- }
96
- if (ch === "(") d++;
97
- if (ch === ")") d--;
98
- if (ch === "|" && d === 0) {
99
- branches.push(current);
100
- current = "";
101
- continue;
102
- }
103
- current += ch;
104
- }
105
- branches.push(current);
106
- if (branches.length < 2) continue;
107
- for (let a = 0; a < branches.length; a++) {
108
- for (let b = a + 1; b < branches.length; b++) {
109
- const x = branches[a];
110
- const y = branches[b];
111
- if (x === "" || y === "") return true;
112
- if (x === y || x.startsWith(y) || y.startsWith(x)) return true;
113
- }
114
- }
115
- }
116
- return false;
117
- }
118
- function compileUserRegex(pattern, flags) {
119
- if (typeof pattern !== "string") {
120
- return { ok: false, reason: "pattern must be a string" };
121
- }
122
- if (pattern.length === 0) {
123
- return { ok: false, reason: "pattern is empty" };
124
- }
125
- if (pattern.length > MAX_PATTERN_LEN) {
126
- return { ok: false, reason: `pattern exceeds ${MAX_PATTERN_LEN} characters` };
127
- }
128
- for (const rx of DANGEROUS_PATTERNS) {
129
- if (rx.test(pattern)) {
130
- return {
131
- ok: false,
132
- reason: "pattern looks vulnerable to catastrophic backtracking \u2014 rewrite without nested quantifiers"
133
- };
134
- }
135
- }
136
- if (hasAmbiguousQuantifiedAlternation(pattern)) {
137
- return {
138
- ok: false,
139
- reason: "pattern quantifies an alternation with overlapping branches \u2014 rewrite so no two branches can match the same text"
140
- };
141
- }
142
- try {
143
- return { ok: true, regex: new RegExp(pattern, flags) };
144
- } catch (err) {
145
- return {
146
- ok: false,
147
- reason: err instanceof Error ? err.message : "invalid regex"
148
- };
149
- }
150
- }
151
- var MAX_SUBJECT_LEN = 64 * 1024;
152
- function capSubject(line) {
153
- return line.length > MAX_SUBJECT_LEN ? line.slice(0, MAX_SUBJECT_LEN) : line;
154
- }
31
+ import {
32
+ capSubject,
33
+ compileUserRegex,
34
+ MAX_SUBJECT_LEN
35
+ } from "@wrongstack/primitives";
155
36
 
156
37
  // src/_util.ts
157
38
  import * as fsp from "node:fs/promises";