@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.
- package/dist/_fetch-guard.d.ts.map +1 -1
- package/dist/_redact-command.d.ts.map +1 -1
- package/dist/_spawn-stream.d.ts.map +1 -1
- package/dist/audit.js +61 -14
- package/dist/audit.js.map +3 -3
- package/dist/bash.d.ts +1 -1
- package/dist/bash.d.ts.map +1 -1
- package/dist/bash.js +97 -19
- package/dist/bash.js.map +3 -3
- package/dist/builtin.d.ts +12 -10
- package/dist/builtin.d.ts.map +1 -1
- package/dist/builtin.js +1620 -803
- package/dist/builtin.js.map +3 -3
- package/dist/codebase-index/background-indexer.d.ts.map +1 -1
- package/dist/codebase-index/bm25.d.ts +1 -2
- package/dist/codebase-index/bm25.d.ts.map +1 -1
- package/dist/codebase-index/codebase-index-tool.d.ts.map +1 -1
- package/dist/codebase-index/codebase-search-tool.d.ts.map +1 -1
- package/dist/codebase-index/codebase-stats-tool.d.ts +7 -0
- package/dist/codebase-index/codebase-stats-tool.d.ts.map +1 -1
- package/dist/codebase-index/index-service.d.ts +11 -1
- package/dist/codebase-index/index-service.d.ts.map +1 -1
- package/dist/codebase-index/index.d.ts +2 -1
- package/dist/codebase-index/index.d.ts.map +1 -1
- package/dist/codebase-index/index.js +749 -192
- package/dist/codebase-index/index.js.map +3 -3
- package/dist/codebase-index/indexer.d.ts.map +1 -1
- package/dist/codebase-index/schema.d.ts +43 -1
- package/dist/codebase-index/schema.d.ts.map +1 -1
- package/dist/codebase-index/ts-parser.d.ts.map +1 -1
- package/dist/codebase-index/worker-protocol.d.ts +1 -0
- package/dist/codebase-index/worker-protocol.d.ts.map +1 -1
- package/dist/codebase-index/worker.js +610 -152
- package/dist/codebase-index/worker.js.map +3 -3
- package/dist/codebase-index/writer.d.ts +27 -1
- package/dist/codebase-index/writer.d.ts.map +1 -1
- package/dist/e2e.js +477 -0
- package/dist/e2e.js.map +7 -0
- package/dist/exec.d.ts +1 -1
- package/dist/exec.d.ts.map +1 -1
- package/dist/exec.js +60 -5
- package/dist/exec.js.map +3 -3
- package/dist/fetch.js +2 -2
- package/dist/fetch.js.map +2 -2
- package/dist/format.js +61 -14
- package/dist/format.js.map +3 -3
- package/dist/glob.js +2 -2
- package/dist/glob.js.map +1 -1
- package/dist/grep.d.ts.map +1 -1
- package/dist/grep.js +2 -2
- package/dist/grep.js.map +2 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1786 -809
- package/dist/index.js.map +3 -3
- package/dist/install.js +61 -14
- package/dist/install.js.map +3 -3
- package/dist/kanban.d.ts +11 -2
- package/dist/kanban.d.ts.map +1 -1
- package/dist/kanban.js +695 -571
- package/dist/kanban.js.map +3 -3
- package/dist/languages/detect.d.ts.map +1 -1
- package/dist/languages/index.js +61 -14
- package/dist/languages/index.js.map +3 -3
- package/dist/languages/types.d.ts +7 -0
- package/dist/languages/types.d.ts.map +1 -1
- package/dist/lint.js +61 -14
- package/dist/lint.js.map +3 -3
- package/dist/outdated.js +61 -14
- package/dist/outdated.js.map +3 -3
- package/dist/pack.js +1617 -800
- package/dist/pack.js.map +3 -3
- package/dist/plan.js +4 -0
- package/dist/plan.js.map +2 -2
- package/dist/process-registry.js +12 -5
- package/dist/process-registry.js.map +2 -2
- package/dist/search.js +2 -2
- package/dist/search.js.map +2 -2
- package/dist/session-kanban.d.ts +9 -0
- package/dist/session-kanban.d.ts.map +1 -1
- package/dist/session-kanban.js +137 -0
- package/dist/session-kanban.js.map +2 -2
- package/dist/task.js +4 -0
- package/dist/task.js.map +2 -2
- package/dist/test.js +61 -14
- package/dist/test.js.map +3 -3
- package/dist/todo.js +4 -0
- package/dist/todo.js.map +2 -2
- package/dist/tree.js +2 -2
- package/dist/tree.js.map +1 -1
- package/dist/typecheck.js +61 -14
- package/dist/typecheck.js.map +3 -3
- package/package.json +7 -3
package/dist/test.js
CHANGED
|
@@ -3,7 +3,12 @@ import * as path9 from "node:path";
|
|
|
3
3
|
|
|
4
4
|
// src/_spawn-stream.ts
|
|
5
5
|
import { spawn as spawn2 } from "node:child_process";
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
buildChildEnv,
|
|
8
|
+
emitProcessCompleted,
|
|
9
|
+
emitProcessOutput,
|
|
10
|
+
emitProcessStarted
|
|
11
|
+
} from "@wrongstack/core";
|
|
7
12
|
|
|
8
13
|
// src/_output-spool.ts
|
|
9
14
|
import { createWriteStream, mkdirSync } from "node:fs";
|
|
@@ -313,9 +318,14 @@ import { expectDefined } from "@wrongstack/core";
|
|
|
313
318
|
var SENSITIVE_FLAG_PATTERNS = [
|
|
314
319
|
// --flag=value or --flag "value" (value captured up to next space or comma)
|
|
315
320
|
/--(?: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,
|
|
316
|
-
// -
|
|
317
|
-
|
|
318
|
-
/
|
|
321
|
+
// -t short flag (token): attached (-tVALUE), separated (-t VALUE), or -t=VALUE.
|
|
322
|
+
// (?<![-\w]) anchors to a token start so we don't match the `-t` inside `--token`.
|
|
323
|
+
// NOTE: synced with @wrongstack/core observability/redact-command.ts.
|
|
324
|
+
/(?<![-\w])-t(?:[=\s]+)?[^\s,-]+/,
|
|
325
|
+
// -p|-password|-a (redis auth) short flags: attached + separated + =value.
|
|
326
|
+
// Same token-start anchor; over-redaction is an accepted tradeoff for a
|
|
327
|
+
// redaction function. Synced with core copy.
|
|
328
|
+
/(?<![-\w])-(?:password|p|a)(?:[=\s]+)?[^\s,-]+/gi,
|
|
319
329
|
// env var–style secrets: TOKEN=x, API_KEY=y, etc.
|
|
320
330
|
/(?:TOKEN|API_KEY|API_SECRET|AUTH_TOKEN|GITHUB_TOKEN|GH_TOKEN|BEARER|JWT|OAUTH|CREDENTIAL|SECRET|PRIVATE_KEY|PASSWORD|PASSWD)\s*[=:]\s*[^\s,]+/gi,
|
|
321
331
|
// Generic high-entropy look: base64 strings >32 chars or hex strings >32 digits — but only
|
|
@@ -333,8 +343,10 @@ function redactCommand(cmd) {
|
|
|
333
343
|
const flag = match.slice(0, match.indexOf(expectDefined(delim)) + 1);
|
|
334
344
|
return `${flag}[REDACTED]`;
|
|
335
345
|
}
|
|
336
|
-
|
|
337
|
-
|
|
346
|
+
if (match.startsWith("--")) {
|
|
347
|
+
return match;
|
|
348
|
+
}
|
|
349
|
+
return `${match.slice(0, 2)}[REDACTED]`;
|
|
338
350
|
});
|
|
339
351
|
}
|
|
340
352
|
return result;
|
|
@@ -771,6 +783,19 @@ async function* spawnStream(opts) {
|
|
|
771
783
|
});
|
|
772
784
|
const registry = getProcessRegistry();
|
|
773
785
|
const pid = child.pid;
|
|
786
|
+
const processStartedAt = Date.now();
|
|
787
|
+
let stdoutBytes = 0;
|
|
788
|
+
let stderrBytes = 0;
|
|
789
|
+
let telemetryCompleted = false;
|
|
790
|
+
emitProcessStarted({
|
|
791
|
+
...pid !== void 0 ? { pid } : {},
|
|
792
|
+
parentPid: process.pid,
|
|
793
|
+
command: redactCommand(`${opts.cmd} ${opts.args.join(" ")}`),
|
|
794
|
+
args: redactCommand(opts.args.join(" ")).split(" ").filter(Boolean),
|
|
795
|
+
cwd: opts.cwd,
|
|
796
|
+
background: false,
|
|
797
|
+
startedAt: new Date(processStartedAt).toISOString()
|
|
798
|
+
});
|
|
774
799
|
if (typeof pid === "number") {
|
|
775
800
|
registry.register({
|
|
776
801
|
pid,
|
|
@@ -799,6 +824,8 @@ async function* spawnStream(opts) {
|
|
|
799
824
|
};
|
|
800
825
|
const onOut = (c) => {
|
|
801
826
|
const s = c.toString();
|
|
827
|
+
stdoutBytes += c.byteLength;
|
|
828
|
+
emitProcessOutput({ pid, stream: "stdout", chunk: c });
|
|
802
829
|
if (stdout.length < max) stdout += s;
|
|
803
830
|
spool.write(s);
|
|
804
831
|
queue.push({ kind: "out", data: s });
|
|
@@ -811,6 +838,8 @@ async function* spawnStream(opts) {
|
|
|
811
838
|
};
|
|
812
839
|
const onErr = (c) => {
|
|
813
840
|
const s = c.toString();
|
|
841
|
+
stderrBytes += c.byteLength;
|
|
842
|
+
emitProcessOutput({ pid, stream: "stderr", chunk: c });
|
|
814
843
|
if (stderr.length < max) stderr += s;
|
|
815
844
|
spool.write(s);
|
|
816
845
|
queue.push({ kind: "err", data: s });
|
|
@@ -828,9 +857,25 @@ async function* spawnStream(opts) {
|
|
|
828
857
|
queue.push({ kind: "error", data: e.message });
|
|
829
858
|
wake();
|
|
830
859
|
});
|
|
831
|
-
|
|
860
|
+
const completeTelemetry = (code, signal, timedOut = false) => {
|
|
861
|
+
if (telemetryCompleted) return;
|
|
862
|
+
telemetryCompleted = true;
|
|
863
|
+
emitProcessCompleted({
|
|
864
|
+
...pid !== void 0 ? { pid } : {},
|
|
865
|
+
exitCode: code,
|
|
866
|
+
...signal ? { signal } : {},
|
|
867
|
+
durationMs: Date.now() - processStartedAt,
|
|
868
|
+
stdoutBytes,
|
|
869
|
+
stderrBytes,
|
|
870
|
+
timedOut,
|
|
871
|
+
endedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
872
|
+
});
|
|
873
|
+
};
|
|
874
|
+
child.on("close", (code, signal) => {
|
|
832
875
|
if (typeof pid === "number") registry.unregister(pid);
|
|
833
|
-
|
|
876
|
+
const exitCode2 = code ?? (signal ? 1 : 0);
|
|
877
|
+
completeTelemetry(exitCode2, signal ?? void 0);
|
|
878
|
+
queue.push({ kind: "close", data: "", code: exitCode2, ...signal ? { signal } : {} });
|
|
834
879
|
wake();
|
|
835
880
|
});
|
|
836
881
|
const onAbort = () => {
|
|
@@ -843,6 +888,7 @@ async function* spawnStream(opts) {
|
|
|
843
888
|
}
|
|
844
889
|
}
|
|
845
890
|
queue.push({ kind: "close", data: "", code: 124 });
|
|
891
|
+
completeTelemetry(124, "SIGKILL", true);
|
|
846
892
|
wake();
|
|
847
893
|
};
|
|
848
894
|
if (isWin) {
|
|
@@ -2371,13 +2417,14 @@ async function detectLanguageWorkspaces(options) {
|
|
|
2371
2417
|
const target = options.target ? await canonicalInside(resolveFrom(cwd, options.target), projectRoot, "target") : void 0;
|
|
2372
2418
|
const profiles = (options.profiles ?? languageProfileRegistry.list()).filter((profile) => !options.language || profile.id === options.language).slice().sort((a, b) => a.id.localeCompare(b.id));
|
|
2373
2419
|
const limits = normalizeLimits(options.limits);
|
|
2420
|
+
const extraIgnores = new Set(options.ignoredDirectories ?? []);
|
|
2374
2421
|
const state = {
|
|
2375
2422
|
entries: 0,
|
|
2376
2423
|
truncated: false,
|
|
2377
2424
|
sourcePaths: /* @__PURE__ */ new Map(),
|
|
2378
2425
|
candidates: /* @__PURE__ */ new Map()
|
|
2379
2426
|
};
|
|
2380
|
-
await scanDirectory(projectRoot, 0, profiles, limits, state, options.signal);
|
|
2427
|
+
await scanDirectory(projectRoot, 0, profiles, limits, state, extraIgnores, options.signal);
|
|
2381
2428
|
addSourceFallbacks(projectRoot, profiles, state);
|
|
2382
2429
|
if (target) addTargetEvidence(target, projectRoot, profiles, state);
|
|
2383
2430
|
const workspaces = await Promise.all(
|
|
@@ -2391,7 +2438,7 @@ async function detectLanguageWorkspaces(options) {
|
|
|
2391
2438
|
workspaces
|
|
2392
2439
|
};
|
|
2393
2440
|
}
|
|
2394
|
-
async function scanDirectory(directory, depth, profiles, limits, state, signal) {
|
|
2441
|
+
async function scanDirectory(directory, depth, profiles, limits, state, extraIgnores, signal) {
|
|
2395
2442
|
signal?.throwIfAborted();
|
|
2396
2443
|
if (depth > limits.maxDepth || state.entries >= limits.maxEntries) {
|
|
2397
2444
|
state.truncated = true;
|
|
@@ -2414,12 +2461,12 @@ async function scanDirectory(directory, depth, profiles, limits, state, signal)
|
|
|
2414
2461
|
const fullPath = path4.join(directory, entry.name);
|
|
2415
2462
|
if (entry.isSymbolicLink()) continue;
|
|
2416
2463
|
if (entry.isDirectory()) {
|
|
2417
|
-
if (shouldIgnoreDirectory(entry.name, profiles)) continue;
|
|
2464
|
+
if (shouldIgnoreDirectory(entry.name, profiles, extraIgnores)) continue;
|
|
2418
2465
|
if (depth >= limits.maxDepth) {
|
|
2419
2466
|
state.truncated = true;
|
|
2420
2467
|
continue;
|
|
2421
2468
|
}
|
|
2422
|
-
await scanDirectory(fullPath, depth + 1, profiles, limits, state, signal);
|
|
2469
|
+
await scanDirectory(fullPath, depth + 1, profiles, limits, state, extraIgnores, signal);
|
|
2423
2470
|
continue;
|
|
2424
2471
|
}
|
|
2425
2472
|
if (!entry.isFile()) continue;
|
|
@@ -2548,8 +2595,8 @@ function getCandidate(state, profile, root) {
|
|
|
2548
2595
|
}
|
|
2549
2596
|
return candidate;
|
|
2550
2597
|
}
|
|
2551
|
-
function shouldIgnoreDirectory(name, profiles) {
|
|
2552
|
-
if (GLOBAL_IGNORES.has(name) || name.startsWith(".")) return true;
|
|
2598
|
+
function shouldIgnoreDirectory(name, profiles, extraIgnores) {
|
|
2599
|
+
if (GLOBAL_IGNORES.has(name) || extraIgnores.has(name) || name.startsWith(".")) return true;
|
|
2553
2600
|
return profiles.some((profile) => profile.ignoredDirectories.includes(name));
|
|
2554
2601
|
}
|
|
2555
2602
|
function normalizeLimits(input) {
|