@wrongstack/tools 0.309.0 → 0.310.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 (67) hide show
  1. package/dist/_regex.d.ts +6 -34
  2. package/dist/audit.js +3 -3
  3. package/dist/bash.js +4 -4
  4. package/dist/builtin.js +3020 -1680
  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 +2784 -1464
  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 +8 -6
  39. package/dist/format.js +3 -3
  40. package/dist/git.js +6 -0
  41. package/dist/grep.js +5 -124
  42. package/dist/index.js +3016 -1739
  43. package/dist/install.js +3 -3
  44. package/dist/json.js +5 -124
  45. package/dist/kanban.js +130 -0
  46. package/dist/languages/index.js +3 -3
  47. package/dist/lint.js +3 -3
  48. package/dist/logs.js +5 -121
  49. package/dist/outdated.js +3 -3
  50. package/dist/pack.js +3020 -1680
  51. package/dist/patch.js +2524 -1216
  52. package/dist/plan.js +106 -0
  53. package/dist/process-registry.js +1 -1
  54. package/dist/read.js +2506 -1198
  55. package/dist/replace.js +2487 -1295
  56. package/dist/search.js +6 -2
  57. package/dist/session-kanban.js +24 -16
  58. package/dist/task.js +106 -0
  59. package/dist/test.js +3 -3
  60. package/dist/todo.js +106 -0
  61. package/dist/tool-tier.d.ts +11 -0
  62. package/dist/tool-tier.js +3028 -1680
  63. package/dist/tree.js +14 -3
  64. package/dist/typecheck.js +3 -3
  65. package/dist/win32.js +5 -5
  66. package/dist/write.js +2513 -1205
  67. 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
  }
@@ -652,12 +654,12 @@ function resolveWin32Command(cmd) {
652
654
  }
653
655
  return cmd;
654
656
  }
655
- var WIN32_SHELL_META = /[&|<>"\r\n\0]/;
657
+ var WIN32_SHELL_META = /[&|<>"%\r\n\0]/;
656
658
  function assertSafeWin32ShellArgs(args) {
657
659
  for (const arg of args) {
658
660
  if (typeof arg === "string" && WIN32_SHELL_META.test(arg)) {
659
661
  throw new Error(
660
- 'win32 cmd shim spawn: argument contains a shell metacharacter (one of & | < > ", or a newline) that could enable command injection through the .cmd/.bat wrapper - refusing to run. Offending argument: ' + JSON.stringify(arg)
662
+ 'win32 cmd shim spawn: argument contains a shell metacharacter (one of & | < > " %, or a newline) that could enable command injection through the .cmd/.bat wrapper - refusing to run. Offending argument: ' + JSON.stringify(arg)
661
663
  );
662
664
  }
663
665
  }
@@ -898,7 +900,7 @@ var SENSITIVE_FLAG_PATTERNS = [
898
900
  // redaction function. Synced with core copy.
899
901
  /(?<![-\w])-(?:password|p|a)(?:[=\s]+)?[^\s,-]+/gi,
900
902
  // env var–style secrets: TOKEN=x, API_KEY=y, etc.
901
- /(?:TOKEN|API_KEY|API_SECRET|AUTH_TOKEN|GITHUB_TOKEN|GH_TOKEN|BEARER|JWT|OAUTH|CREDENTIAL|SECRET|PRIVATE_KEY|PASSWORD|PASSWD)\s*[=:]\s*[^\s,]+/gi,
903
+ /(?:TOKEN|API_KEY|API_SECRET|AUTH_TOKEN|GITHUB_TOKEN|GH_TOKEN|BEARER|JWT|OAUTH|CREDENTIAL|SECRET|PRIVATE_KEY|PASSWORD|PASSWD|PASSPHRASE)\s*[=:]\s*[^\s,]+/gi,
902
904
  // Generic high-entropy look: base64 strings >32 chars or hex strings >32 digits — but only
903
905
  // when preceded by a flag name (e.g. --github-token=EyJ...). Global flag so
904
906
  // every such flag in the command line is redacted, not just the first.
package/dist/format.js CHANGED
@@ -138,12 +138,12 @@ function resolveWin32Command(cmd) {
138
138
  }
139
139
  return cmd;
140
140
  }
141
- var WIN32_SHELL_META = /[&|<>"\r\n\0]/;
141
+ var WIN32_SHELL_META = /[&|<>"%\r\n\0]/;
142
142
  function assertSafeWin32ShellArgs(args) {
143
143
  for (const arg of args) {
144
144
  if (typeof arg === "string" && WIN32_SHELL_META.test(arg)) {
145
145
  throw new Error(
146
- 'win32 cmd shim spawn: argument contains a shell metacharacter (one of & | < > ", or a newline) that could enable command injection through the .cmd/.bat wrapper - refusing to run. Offending argument: ' + JSON.stringify(arg)
146
+ 'win32 cmd shim spawn: argument contains a shell metacharacter (one of & | < > " %, or a newline) that could enable command injection through the .cmd/.bat wrapper - refusing to run. Offending argument: ' + JSON.stringify(arg)
147
147
  );
148
148
  }
149
149
  }
@@ -374,7 +374,7 @@ var SENSITIVE_FLAG_PATTERNS = [
374
374
  // redaction function. Synced with core copy.
375
375
  /(?<![-\w])-(?:password|p|a)(?:[=\s]+)?[^\s,-]+/gi,
376
376
  // env var–style secrets: TOKEN=x, API_KEY=y, etc.
377
- /(?:TOKEN|API_KEY|API_SECRET|AUTH_TOKEN|GITHUB_TOKEN|GH_TOKEN|BEARER|JWT|OAUTH|CREDENTIAL|SECRET|PRIVATE_KEY|PASSWORD|PASSWD)\s*[=:]\s*[^\s,]+/gi,
377
+ /(?:TOKEN|API_KEY|API_SECRET|AUTH_TOKEN|GITHUB_TOKEN|GH_TOKEN|BEARER|JWT|OAUTH|CREDENTIAL|SECRET|PRIVATE_KEY|PASSWORD|PASSWD|PASSPHRASE)\s*[=:]\s*[^\s,]+/gi,
378
378
  // Generic high-entropy look: base64 strings >32 chars or hex strings >32 digits — but only
379
379
  // when preceded by a flag name (e.g. --github-token=EyJ...). Global flag so
380
380
  // every such flag in the command line is redacted, not just the first.
package/dist/git.js CHANGED
@@ -95,6 +95,12 @@ var gitTool = {
95
95
  // The git subcommand (status/commit/push) is what a trust rule needs to
96
96
  // distinguish; `git status` and `git push --force` must not share a subject.
97
97
  subjectKey: "command",
98
+ // `command` is an enum subcommand, so on its own it rendered the subject
99
+ // `"push"` — and one "always allow" then covered every push, to any branch,
100
+ // with or without `--force`. These are the fields that change what the call
101
+ // actually does, so the stored trust rule is as specific as the invocation
102
+ // the user approved.
103
+ subjectFields: ["branch", "force", "worktreeAction", "worktreePath", "newBranch"],
98
104
  mutating: true,
99
105
  capabilities: ["fs.write", "shell.restricted"],
100
106
  timeoutMs: TIMEOUT_MS,
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";