@wrongstack/tools 0.287.0 → 0.289.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 (93) hide show
  1. package/dist/_fetch-guard.d.ts.map +1 -1
  2. package/dist/_redact-command.d.ts.map +1 -1
  3. package/dist/_spawn-stream.d.ts.map +1 -1
  4. package/dist/audit.js +61 -14
  5. package/dist/audit.js.map +3 -3
  6. package/dist/bash.d.ts +1 -1
  7. package/dist/bash.d.ts.map +1 -1
  8. package/dist/bash.js +97 -19
  9. package/dist/bash.js.map +3 -3
  10. package/dist/builtin.d.ts +12 -10
  11. package/dist/builtin.d.ts.map +1 -1
  12. package/dist/builtin.js +1620 -803
  13. package/dist/builtin.js.map +3 -3
  14. package/dist/codebase-index/background-indexer.d.ts.map +1 -1
  15. package/dist/codebase-index/bm25.d.ts +1 -2
  16. package/dist/codebase-index/bm25.d.ts.map +1 -1
  17. package/dist/codebase-index/codebase-index-tool.d.ts.map +1 -1
  18. package/dist/codebase-index/codebase-search-tool.d.ts.map +1 -1
  19. package/dist/codebase-index/codebase-stats-tool.d.ts +7 -0
  20. package/dist/codebase-index/codebase-stats-tool.d.ts.map +1 -1
  21. package/dist/codebase-index/index-service.d.ts +11 -1
  22. package/dist/codebase-index/index-service.d.ts.map +1 -1
  23. package/dist/codebase-index/index.d.ts +2 -1
  24. package/dist/codebase-index/index.d.ts.map +1 -1
  25. package/dist/codebase-index/index.js +749 -192
  26. package/dist/codebase-index/index.js.map +3 -3
  27. package/dist/codebase-index/indexer.d.ts.map +1 -1
  28. package/dist/codebase-index/schema.d.ts +43 -1
  29. package/dist/codebase-index/schema.d.ts.map +1 -1
  30. package/dist/codebase-index/ts-parser.d.ts.map +1 -1
  31. package/dist/codebase-index/worker-protocol.d.ts +1 -0
  32. package/dist/codebase-index/worker-protocol.d.ts.map +1 -1
  33. package/dist/codebase-index/worker.js +610 -152
  34. package/dist/codebase-index/worker.js.map +3 -3
  35. package/dist/codebase-index/writer.d.ts +27 -1
  36. package/dist/codebase-index/writer.d.ts.map +1 -1
  37. package/dist/e2e.js +477 -0
  38. package/dist/e2e.js.map +7 -0
  39. package/dist/exec.d.ts +1 -1
  40. package/dist/exec.d.ts.map +1 -1
  41. package/dist/exec.js +60 -5
  42. package/dist/exec.js.map +3 -3
  43. package/dist/fetch.js +2 -2
  44. package/dist/fetch.js.map +2 -2
  45. package/dist/format.js +61 -14
  46. package/dist/format.js.map +3 -3
  47. package/dist/glob.js +2 -2
  48. package/dist/glob.js.map +1 -1
  49. package/dist/grep.d.ts.map +1 -1
  50. package/dist/grep.js +2 -2
  51. package/dist/grep.js.map +2 -2
  52. package/dist/index.d.ts +3 -2
  53. package/dist/index.d.ts.map +1 -1
  54. package/dist/index.js +1786 -809
  55. package/dist/index.js.map +3 -3
  56. package/dist/install.js +61 -14
  57. package/dist/install.js.map +3 -3
  58. package/dist/kanban.d.ts +11 -2
  59. package/dist/kanban.d.ts.map +1 -1
  60. package/dist/kanban.js +695 -571
  61. package/dist/kanban.js.map +3 -3
  62. package/dist/languages/detect.d.ts.map +1 -1
  63. package/dist/languages/index.js +61 -14
  64. package/dist/languages/index.js.map +3 -3
  65. package/dist/languages/types.d.ts +7 -0
  66. package/dist/languages/types.d.ts.map +1 -1
  67. package/dist/lint.js +61 -14
  68. package/dist/lint.js.map +3 -3
  69. package/dist/outdated.js +61 -14
  70. package/dist/outdated.js.map +3 -3
  71. package/dist/pack.js +1617 -800
  72. package/dist/pack.js.map +3 -3
  73. package/dist/plan.js +4 -0
  74. package/dist/plan.js.map +2 -2
  75. package/dist/process-registry.js +12 -5
  76. package/dist/process-registry.js.map +2 -2
  77. package/dist/search.js +2 -2
  78. package/dist/search.js.map +2 -2
  79. package/dist/session-kanban.d.ts +9 -0
  80. package/dist/session-kanban.d.ts.map +1 -1
  81. package/dist/session-kanban.js +137 -0
  82. package/dist/session-kanban.js.map +2 -2
  83. package/dist/task.js +4 -0
  84. package/dist/task.js.map +2 -2
  85. package/dist/test.js +61 -14
  86. package/dist/test.js.map +3 -3
  87. package/dist/todo.js +4 -0
  88. package/dist/todo.js.map +2 -2
  89. package/dist/tree.js +2 -2
  90. package/dist/tree.js.map +1 -1
  91. package/dist/typecheck.js +61 -14
  92. package/dist/typecheck.js.map +3 -3
  93. package/package.json +7 -3
package/dist/outdated.js CHANGED
@@ -1577,13 +1577,14 @@ async function detectLanguageWorkspaces(options) {
1577
1577
  const target = options.target ? await canonicalInside(resolveFrom(cwd, options.target), projectRoot, "target") : void 0;
1578
1578
  const profiles = (options.profiles ?? languageProfileRegistry.list()).filter((profile) => !options.language || profile.id === options.language).slice().sort((a, b) => a.id.localeCompare(b.id));
1579
1579
  const limits = normalizeLimits(options.limits);
1580
+ const extraIgnores = new Set(options.ignoredDirectories ?? []);
1580
1581
  const state = {
1581
1582
  entries: 0,
1582
1583
  truncated: false,
1583
1584
  sourcePaths: /* @__PURE__ */ new Map(),
1584
1585
  candidates: /* @__PURE__ */ new Map()
1585
1586
  };
1586
- await scanDirectory(projectRoot, 0, profiles, limits, state, options.signal);
1587
+ await scanDirectory(projectRoot, 0, profiles, limits, state, extraIgnores, options.signal);
1587
1588
  addSourceFallbacks(projectRoot, profiles, state);
1588
1589
  if (target) addTargetEvidence(target, projectRoot, profiles, state);
1589
1590
  const workspaces = await Promise.all(
@@ -1597,7 +1598,7 @@ async function detectLanguageWorkspaces(options) {
1597
1598
  workspaces
1598
1599
  };
1599
1600
  }
1600
- async function scanDirectory(directory, depth, profiles, limits, state, signal) {
1601
+ async function scanDirectory(directory, depth, profiles, limits, state, extraIgnores, signal) {
1601
1602
  signal?.throwIfAborted();
1602
1603
  if (depth > limits.maxDepth || state.entries >= limits.maxEntries) {
1603
1604
  state.truncated = true;
@@ -1620,12 +1621,12 @@ async function scanDirectory(directory, depth, profiles, limits, state, signal)
1620
1621
  const fullPath = path3.join(directory, entry.name);
1621
1622
  if (entry.isSymbolicLink()) continue;
1622
1623
  if (entry.isDirectory()) {
1623
- if (shouldIgnoreDirectory(entry.name, profiles)) continue;
1624
+ if (shouldIgnoreDirectory(entry.name, profiles, extraIgnores)) continue;
1624
1625
  if (depth >= limits.maxDepth) {
1625
1626
  state.truncated = true;
1626
1627
  continue;
1627
1628
  }
1628
- await scanDirectory(fullPath, depth + 1, profiles, limits, state, signal);
1629
+ await scanDirectory(fullPath, depth + 1, profiles, limits, state, extraIgnores, signal);
1629
1630
  continue;
1630
1631
  }
1631
1632
  if (!entry.isFile()) continue;
@@ -1754,8 +1755,8 @@ function getCandidate(state, profile, root) {
1754
1755
  }
1755
1756
  return candidate;
1756
1757
  }
1757
- function shouldIgnoreDirectory(name, profiles) {
1758
- if (GLOBAL_IGNORES.has(name) || name.startsWith(".")) return true;
1758
+ function shouldIgnoreDirectory(name, profiles, extraIgnores) {
1759
+ if (GLOBAL_IGNORES.has(name) || extraIgnores.has(name) || name.startsWith(".")) return true;
1759
1760
  return profiles.some((profile) => profile.ignoredDirectories.includes(name));
1760
1761
  }
1761
1762
  function normalizeLimits(input) {
@@ -2648,8 +2649,10 @@ function redactCommand(cmd) {
2648
2649
  const flag = match.slice(0, match.indexOf(expectDefined(delim)) + 1);
2649
2650
  return `${flag}[REDACTED]`;
2650
2651
  }
2651
- const flagEnd = match.match(/^--?[a-zA-Z][a-zA-Z0-9_-]*/)?.[0] ?? match;
2652
- return `${flagEnd}=**redacted**`;
2652
+ if (match.startsWith("--")) {
2653
+ return match;
2654
+ }
2655
+ return `${match.slice(0, 2)}[REDACTED]`;
2653
2656
  });
2654
2657
  }
2655
2658
  return result;
@@ -2661,9 +2664,14 @@ var init_redact_command = __esm({
2661
2664
  SENSITIVE_FLAG_PATTERNS = [
2662
2665
  // --flag=value or --flag "value" (value captured up to next space or comma)
2663
2666
  /--(?:token|password|passwd|pwd|secret|api[-_]?key|api[-_]?secret|auth|credential|private[-_]?key|access[-_]?key|github[-_]?token|gh[-_]?token|bearer|jwt|oauth|pin|pincode|passphrase|access[-_]?token)(?:[=\s,][^\s]*)?/gi,
2664
- // -f "value" style short flags
2665
- /(?<!\w)-t(?:\s+|\s*=\s*)[^\s,]+/,
2666
- /(?<!\w)-(?:p|password)(?:\s+|\s*=\s*)[^\s,]+/gi,
2667
+ // -t short flag (token): attached (-tVALUE), separated (-t VALUE), or -t=VALUE.
2668
+ // (?<![-\w]) anchors to a token start so we don't match the `-t` inside `--token`.
2669
+ // NOTE: synced with @wrongstack/core observability/redact-command.ts.
2670
+ /(?<![-\w])-t(?:[=\s]+)?[^\s,-]+/,
2671
+ // -p|-password|-a (redis auth) short flags: attached + separated + =value.
2672
+ // Same token-start anchor; over-redaction is an accepted tradeoff for a
2673
+ // redaction function. Synced with core copy.
2674
+ /(?<![-\w])-(?:password|p|a)(?:[=\s]+)?[^\s,-]+/gi,
2667
2675
  // env var–style secrets: TOKEN=x, API_KEY=y, etc.
2668
2676
  /(?:TOKEN|API_KEY|API_SECRET|AUTH_TOKEN|GITHUB_TOKEN|GH_TOKEN|BEARER|JWT|OAUTH|CREDENTIAL|SECRET|PRIVATE_KEY|PASSWORD|PASSWD)\s*[=:]\s*[^\s,]+/gi,
2669
2677
  // Generic high-entropy look: base64 strings >32 chars or hex strings >32 digits — but only
@@ -3043,7 +3051,12 @@ var init_process_registry = __esm({
3043
3051
 
3044
3052
  // src/_spawn-stream.ts
3045
3053
  import { spawn as spawn2 } from "node:child_process";
3046
- import { buildChildEnv } from "@wrongstack/core";
3054
+ import {
3055
+ buildChildEnv,
3056
+ emitProcessCompleted,
3057
+ emitProcessOutput,
3058
+ emitProcessStarted
3059
+ } from "@wrongstack/core";
3047
3060
  async function* spawnStream(opts) {
3048
3061
  const max = opts.maxBytes ?? 2e5;
3049
3062
  const flushAt = opts.flushBytes ?? 4 * 1024;
@@ -3068,6 +3081,19 @@ async function* spawnStream(opts) {
3068
3081
  });
3069
3082
  const registry = getProcessRegistry();
3070
3083
  const pid = child.pid;
3084
+ const processStartedAt = Date.now();
3085
+ let stdoutBytes = 0;
3086
+ let stderrBytes = 0;
3087
+ let telemetryCompleted = false;
3088
+ emitProcessStarted({
3089
+ ...pid !== void 0 ? { pid } : {},
3090
+ parentPid: process.pid,
3091
+ command: redactCommand(`${opts.cmd} ${opts.args.join(" ")}`),
3092
+ args: redactCommand(opts.args.join(" ")).split(" ").filter(Boolean),
3093
+ cwd: opts.cwd,
3094
+ background: false,
3095
+ startedAt: new Date(processStartedAt).toISOString()
3096
+ });
3071
3097
  if (typeof pid === "number") {
3072
3098
  registry.register({
3073
3099
  pid,
@@ -3096,6 +3122,8 @@ async function* spawnStream(opts) {
3096
3122
  };
3097
3123
  const onOut = (c) => {
3098
3124
  const s = c.toString();
3125
+ stdoutBytes += c.byteLength;
3126
+ emitProcessOutput({ pid, stream: "stdout", chunk: c });
3099
3127
  if (stdout.length < max) stdout += s;
3100
3128
  spool.write(s);
3101
3129
  queue.push({ kind: "out", data: s });
@@ -3108,6 +3136,8 @@ async function* spawnStream(opts) {
3108
3136
  };
3109
3137
  const onErr = (c) => {
3110
3138
  const s = c.toString();
3139
+ stderrBytes += c.byteLength;
3140
+ emitProcessOutput({ pid, stream: "stderr", chunk: c });
3111
3141
  if (stderr.length < max) stderr += s;
3112
3142
  spool.write(s);
3113
3143
  queue.push({ kind: "err", data: s });
@@ -3125,9 +3155,25 @@ async function* spawnStream(opts) {
3125
3155
  queue.push({ kind: "error", data: e.message });
3126
3156
  wake();
3127
3157
  });
3128
- child.on("close", (code) => {
3158
+ const completeTelemetry = (code, signal, timedOut = false) => {
3159
+ if (telemetryCompleted) return;
3160
+ telemetryCompleted = true;
3161
+ emitProcessCompleted({
3162
+ ...pid !== void 0 ? { pid } : {},
3163
+ exitCode: code,
3164
+ ...signal ? { signal } : {},
3165
+ durationMs: Date.now() - processStartedAt,
3166
+ stdoutBytes,
3167
+ stderrBytes,
3168
+ timedOut,
3169
+ endedAt: (/* @__PURE__ */ new Date()).toISOString()
3170
+ });
3171
+ };
3172
+ child.on("close", (code, signal) => {
3129
3173
  if (typeof pid === "number") registry.unregister(pid);
3130
- queue.push({ kind: "close", data: "", code: code ?? 0 });
3174
+ const exitCode2 = code ?? (signal ? 1 : 0);
3175
+ completeTelemetry(exitCode2, signal ?? void 0);
3176
+ queue.push({ kind: "close", data: "", code: exitCode2, ...signal ? { signal } : {} });
3131
3177
  wake();
3132
3178
  });
3133
3179
  const onAbort = () => {
@@ -3140,6 +3186,7 @@ async function* spawnStream(opts) {
3140
3186
  }
3141
3187
  }
3142
3188
  queue.push({ kind: "close", data: "", code: 124 });
3189
+ completeTelemetry(124, "SIGKILL", true);
3143
3190
  wake();
3144
3191
  };
3145
3192
  if (isWin) {