@wrongstack/tools 0.296.3 → 0.297.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/audit.js +15 -0
- package/dist/audit.js.map +2 -2
- package/dist/bash.js +15 -0
- package/dist/bash.js.map +2 -2
- package/dist/builtin.js +1291 -1216
- package/dist/builtin.js.map +4 -4
- package/dist/codebase-index/background-indexer.d.ts.map +1 -1
- package/dist/codebase-index/index.d.ts +1 -0
- package/dist/codebase-index/index.d.ts.map +1 -1
- package/dist/codebase-index/index.js +1259 -1196
- package/dist/codebase-index/index.js.map +4 -4
- package/dist/codebase-index/project-server-client.d.ts +13 -1
- package/dist/codebase-index/project-server-client.d.ts.map +1 -1
- package/dist/codebase-index/project-server-endpoint.d.ts +29 -1
- package/dist/codebase-index/project-server-endpoint.d.ts.map +1 -1
- package/dist/codebase-index/project-server.js +20 -5
- package/dist/codebase-index/project-server.js.map +2 -2
- package/dist/codebase-index/refs-extractor.d.ts.map +1 -1
- package/dist/exec.js +15 -0
- package/dist/exec.js.map +2 -2
- package/dist/format.js +15 -0
- package/dist/format.js.map +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1260 -1182
- package/dist/index.js.map +4 -4
- package/dist/install.js +15 -0
- package/dist/install.js.map +2 -2
- package/dist/languages/index.js +15 -0
- package/dist/languages/index.js.map +2 -2
- package/dist/lint.js +15 -0
- package/dist/lint.js.map +2 -2
- package/dist/next-steps.d.ts +23 -0
- package/dist/next-steps.d.ts.map +1 -1
- package/dist/next-steps.js +4 -0
- package/dist/next-steps.js.map +2 -2
- package/dist/outdated.js +15 -0
- package/dist/outdated.js.map +2 -2
- package/dist/pack.js +1291 -1216
- package/dist/pack.js.map +4 -4
- package/dist/process-registry.d.ts +9 -0
- package/dist/process-registry.d.ts.map +1 -1
- package/dist/process-registry.js +15 -0
- package/dist/process-registry.js.map +2 -2
- package/dist/ps-slash.js +15 -0
- package/dist/ps-slash.js.map +2 -2
- package/dist/read.js +67 -9
- package/dist/read.js.map +2 -2
- package/dist/test.js +15 -0
- package/dist/test.js.map +2 -2
- package/dist/tool-tier.js +1291 -1216
- package/dist/tool-tier.js.map +4 -4
- package/dist/typecheck.js +15 -0
- package/dist/typecheck.js.map +2 -2
- package/package.json +3 -3
package/dist/read.js
CHANGED
|
@@ -4535,6 +4535,7 @@ import { spawn as spawn4 } from "node:child_process";
|
|
|
4535
4535
|
import * as fs10 from "node:fs";
|
|
4536
4536
|
import * as net from "node:net";
|
|
4537
4537
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
4538
|
+
import { checkUnixSocketPath } from "@wrongstack/core/utils";
|
|
4538
4539
|
|
|
4539
4540
|
// src/codebase-index/project-server-endpoint.ts
|
|
4540
4541
|
import { createHash as createHash2 } from "node:crypto";
|
|
@@ -4542,8 +4543,10 @@ import * as fs9 from "node:fs";
|
|
|
4542
4543
|
import * as os3 from "node:os";
|
|
4543
4544
|
import * as path13 from "node:path";
|
|
4544
4545
|
import { fileURLToPath } from "node:url";
|
|
4546
|
+
import { assertUnixSocketPathWithinLimit } from "@wrongstack/core/utils";
|
|
4545
4547
|
var PROJECT_INDEX_SERVER_PROTOCOL_VERSION = 1;
|
|
4546
4548
|
var PROJECT_INDEX_SERVER_METADATA_FILE = "server.json";
|
|
4549
|
+
var PROJECT_INDEX_SERVER_SOCKET_DIR = `wsci-v${PROJECT_INDEX_SERVER_PROTOCOL_VERSION}`;
|
|
4547
4550
|
var buildIdCache;
|
|
4548
4551
|
function projectIndexServerBuildId(entrypoint) {
|
|
4549
4552
|
const file = entrypoint instanceof URL || entrypoint.startsWith("file:") ? fileURLToPath(entrypoint) : path13.resolve(entrypoint);
|
|
@@ -4572,11 +4575,7 @@ function projectIndexServerEndpoint(projectRoot, indexDir) {
|
|
|
4572
4575
|
if (process.platform === "win32") {
|
|
4573
4576
|
return `\\\\.\\pipe\\wrongstack-codebase-index-v${PROJECT_INDEX_SERVER_PROTOCOL_VERSION}-${key}`;
|
|
4574
4577
|
}
|
|
4575
|
-
return path13.join(
|
|
4576
|
-
os3.tmpdir(),
|
|
4577
|
-
`wrongstack-codebase-index-v${PROJECT_INDEX_SERVER_PROTOCOL_VERSION}`,
|
|
4578
|
-
`${key}.sock`
|
|
4579
|
-
);
|
|
4578
|
+
return path13.join(os3.tmpdir(), PROJECT_INDEX_SERVER_SOCKET_DIR, `${key}.sock`);
|
|
4580
4579
|
}
|
|
4581
4580
|
function projectIndexServerMetadataPath(projectRoot, indexDir) {
|
|
4582
4581
|
return path13.join(
|
|
@@ -4612,20 +4611,35 @@ var latestConnectionState = {
|
|
|
4612
4611
|
status: "offline",
|
|
4613
4612
|
connected: false
|
|
4614
4613
|
};
|
|
4615
|
-
function resolveProjectIndexDaemonAvailability() {
|
|
4614
|
+
function resolveProjectIndexDaemonAvailability(projectRoot, indexDir) {
|
|
4616
4615
|
if (process.env["WRONGSTACK_INDEX_INLINE"] || process.env["WRONGSTACK_INDEX_SERVER"] === "0") {
|
|
4617
4616
|
return { kind: "inline-requested" };
|
|
4618
4617
|
}
|
|
4618
|
+
let builtUrl = null;
|
|
4619
4619
|
for (const rel of ["./project-server.js", "./codebase-index/project-server.js"]) {
|
|
4620
4620
|
try {
|
|
4621
4621
|
const url = new URL(rel, import.meta.url);
|
|
4622
4622
|
if (url.protocol === "file:" && fs10.existsSync(fileURLToPath2(url))) {
|
|
4623
|
-
|
|
4623
|
+
builtUrl = url;
|
|
4624
|
+
break;
|
|
4624
4625
|
}
|
|
4625
4626
|
} catch {
|
|
4626
4627
|
}
|
|
4627
4628
|
}
|
|
4628
|
-
return { kind: "missing-build" };
|
|
4629
|
+
if (builtUrl === null) return { kind: "missing-build" };
|
|
4630
|
+
if (projectRoot !== void 0) {
|
|
4631
|
+
const endpoint = projectIndexServerEndpoint(projectRoot, indexDir);
|
|
4632
|
+
const check = checkUnixSocketPath(endpoint);
|
|
4633
|
+
if (!check.ok) {
|
|
4634
|
+
return {
|
|
4635
|
+
kind: "endpoint-invalid",
|
|
4636
|
+
endpoint,
|
|
4637
|
+
byteLength: check.byteLength,
|
|
4638
|
+
maxBytes: check.maxBytes
|
|
4639
|
+
};
|
|
4640
|
+
}
|
|
4641
|
+
}
|
|
4642
|
+
return { kind: "available", url: builtUrl };
|
|
4629
4643
|
}
|
|
4630
4644
|
function resolveProjectServerUrl() {
|
|
4631
4645
|
const availability = resolveProjectIndexDaemonAvailability();
|
|
@@ -4732,6 +4746,10 @@ var ProjectServerConnection = class {
|
|
|
4732
4746
|
isConnected() {
|
|
4733
4747
|
return this.socket !== null && !this.socket.destroyed && this.info !== null;
|
|
4734
4748
|
}
|
|
4749
|
+
/** Safe LRU candidate: no request, connect, or health probe is in flight. */
|
|
4750
|
+
isEvictable() {
|
|
4751
|
+
return this.pending.size === 0 && this.connecting === null && this.healthCheck === null;
|
|
4752
|
+
}
|
|
4735
4753
|
async checkHealth(spawnIfMissing = false, timeoutMs = SERVER_HEALTH_TIMEOUT_MS) {
|
|
4736
4754
|
await this.ensureConnected(spawnIfMissing);
|
|
4737
4755
|
if (this.healthCheck) return this.healthCheck;
|
|
@@ -5130,7 +5148,26 @@ var ProjectServerConnection = class {
|
|
|
5130
5148
|
}
|
|
5131
5149
|
};
|
|
5132
5150
|
var connections = /* @__PURE__ */ new Map();
|
|
5151
|
+
var MAX_CACHED_CONNECTIONS = 8;
|
|
5133
5152
|
var heartbeatTimer;
|
|
5153
|
+
function forgetConnection(endpoint, connection) {
|
|
5154
|
+
if (connections.get(endpoint) === connection) connections.delete(endpoint);
|
|
5155
|
+
connection.close();
|
|
5156
|
+
connectionStates.delete(endpoint);
|
|
5157
|
+
if (latestConnectionState.endpoint !== endpoint) return;
|
|
5158
|
+
latestConnectionState = [...connectionStates.values()].at(-1) ?? {
|
|
5159
|
+
status: isProjectIndexServerAvailable() ? "offline" : "unavailable",
|
|
5160
|
+
connected: false
|
|
5161
|
+
};
|
|
5162
|
+
}
|
|
5163
|
+
function trimConnectionCache(protectedConnection) {
|
|
5164
|
+
if (connections.size <= MAX_CACHED_CONNECTIONS) return;
|
|
5165
|
+
for (const [endpoint, connection] of connections) {
|
|
5166
|
+
if (connections.size <= MAX_CACHED_CONNECTIONS) break;
|
|
5167
|
+
if (connection === protectedConnection || !connection.isEvictable()) continue;
|
|
5168
|
+
forgetConnection(endpoint, connection);
|
|
5169
|
+
}
|
|
5170
|
+
}
|
|
5134
5171
|
function ensureHeartbeatLoop() {
|
|
5135
5172
|
if (heartbeatTimer) return;
|
|
5136
5173
|
heartbeatTimer = setInterval(() => {
|
|
@@ -5153,7 +5190,11 @@ function connectionFor(projectRoot, indexDir) {
|
|
|
5153
5190
|
if (!connection) {
|
|
5154
5191
|
connection = new ProjectServerConnection(projectRoot, indexDir, endpoint);
|
|
5155
5192
|
connections.set(endpoint, connection);
|
|
5193
|
+
} else {
|
|
5194
|
+
connections.delete(endpoint);
|
|
5195
|
+
connections.set(endpoint, connection);
|
|
5156
5196
|
}
|
|
5197
|
+
trimConnectionCache(connection);
|
|
5157
5198
|
return connection;
|
|
5158
5199
|
}
|
|
5159
5200
|
function callProjectIndexServer(op, args, options) {
|
|
@@ -5259,8 +5300,17 @@ function terminateWorker(reason) {
|
|
|
5259
5300
|
if (w) void w.terminate().catch(() => {
|
|
5260
5301
|
});
|
|
5261
5302
|
}
|
|
5303
|
+
var warnedInvalidEndpoints = /* @__PURE__ */ new Set();
|
|
5304
|
+
function warnEndpointInvalidOnce(availability) {
|
|
5305
|
+
if (warnedInvalidEndpoints.has(availability.endpoint)) return;
|
|
5306
|
+
warnedInvalidEndpoints.add(availability.endpoint);
|
|
5307
|
+
process.stderr.write(
|
|
5308
|
+
`codebase-index: socket path is ${availability.byteLength} bytes, over this platform's ${availability.maxBytes}-byte sun_path limit (${availability.endpoint}). Subsequent calls will reject until TMPDIR is shortened to restore the shared daemon.
|
|
5309
|
+
`
|
|
5310
|
+
);
|
|
5311
|
+
}
|
|
5262
5312
|
function callIndexOp(op, args, opts) {
|
|
5263
|
-
const availability = resolveProjectIndexDaemonAvailability();
|
|
5313
|
+
const availability = resolveProjectIndexDaemonAvailability(args.projectRoot, args.indexDir);
|
|
5264
5314
|
if (availability.kind === "available") {
|
|
5265
5315
|
return callProjectIndexServer(op, args, opts);
|
|
5266
5316
|
}
|
|
@@ -5271,6 +5321,14 @@ function callIndexOp(op, args, opts) {
|
|
|
5271
5321
|
)
|
|
5272
5322
|
);
|
|
5273
5323
|
}
|
|
5324
|
+
if (availability.kind === "endpoint-invalid") {
|
|
5325
|
+
warnEndpointInvalidOnce(availability);
|
|
5326
|
+
return Promise.reject(
|
|
5327
|
+
new Error(
|
|
5328
|
+
`codebase-index: socket path is ${availability.byteLength} bytes, over this platform's ${availability.maxBytes}-byte sun_path limit (${availability.endpoint}). Set a shorter TMPDIR to relocate the shared daemon, or set WRONGSTACK_INDEX_INLINE=1 to explicitly opt into a process-local index.`
|
|
5329
|
+
)
|
|
5330
|
+
);
|
|
5331
|
+
}
|
|
5274
5332
|
const w = ensureWorker();
|
|
5275
5333
|
if (!w) return callInline(op, args, opts);
|
|
5276
5334
|
if (opts.signal?.aborted) {
|