@wrongstack/techstack 0.295.1 → 0.296.2
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/index.js +31 -27
- package/dist/index.js.map +2 -2
- package/dist/registry/client.d.ts.map +1 -1
- package/dist/store/sqlite.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -2618,12 +2618,26 @@ function getCached(key) {
|
|
|
2618
2618
|
}
|
|
2619
2619
|
return entry.data;
|
|
2620
2620
|
}
|
|
2621
|
+
var MAX_CACHE_ENTRIES = 512;
|
|
2622
|
+
function trimCache(now) {
|
|
2623
|
+
if (registryCache.size <= MAX_CACHE_ENTRIES) return;
|
|
2624
|
+
for (const [key, entry] of registryCache) {
|
|
2625
|
+
if (now > entry.expiresAt) registryCache.delete(key);
|
|
2626
|
+
}
|
|
2627
|
+
while (registryCache.size > MAX_CACHE_ENTRIES) {
|
|
2628
|
+
const oldest = registryCache.keys().next().value;
|
|
2629
|
+
if (oldest === void 0) break;
|
|
2630
|
+
registryCache.delete(oldest);
|
|
2631
|
+
}
|
|
2632
|
+
}
|
|
2621
2633
|
function setCache(key, data, etag, ttlMs = DEFAULT_TTL_MS) {
|
|
2634
|
+
const now = Date.now();
|
|
2622
2635
|
registryCache.set(key, {
|
|
2623
2636
|
data,
|
|
2624
2637
|
etag,
|
|
2625
|
-
expiresAt:
|
|
2638
|
+
expiresAt: now + ttlMs
|
|
2626
2639
|
});
|
|
2640
|
+
trimCache(now);
|
|
2627
2641
|
}
|
|
2628
2642
|
function acquireHostSlot(host) {
|
|
2629
2643
|
let concurrency = hostConcurrency.get(host);
|
|
@@ -4277,7 +4291,11 @@ function createToolSearch(options = {}) {
|
|
|
4277
4291
|
import { createRequire } from "node:module";
|
|
4278
4292
|
import { mkdirSync, existsSync as existsSync2 } from "node:fs";
|
|
4279
4293
|
import { dirname as dirname2, join as join9 } from "node:path";
|
|
4280
|
-
import {
|
|
4294
|
+
import {
|
|
4295
|
+
SageCachePragmas,
|
|
4296
|
+
withSqliteExperimentalWarningSuppressed,
|
|
4297
|
+
wstackGlobalRoot
|
|
4298
|
+
} from "@wrongstack/core/utils";
|
|
4281
4299
|
|
|
4282
4300
|
// src/store/schema.ts
|
|
4283
4301
|
var SCHEMA_VERSION = 1;
|
|
@@ -4348,23 +4366,10 @@ function applySchema(db) {
|
|
|
4348
4366
|
|
|
4349
4367
|
// src/store/sqlite.ts
|
|
4350
4368
|
var DatabaseSyncCtor;
|
|
4351
|
-
var SQLITE_EXPERIMENTAL_WARNING = "SQLite is an experimental feature and might change at any time";
|
|
4352
4369
|
function loadDatabaseSync() {
|
|
4353
4370
|
if (DatabaseSyncCtor) return DatabaseSyncCtor;
|
|
4354
|
-
const originalEmitWarning = process.emitWarning;
|
|
4355
|
-
const forwardWarning = originalEmitWarning.bind(process);
|
|
4356
|
-
process.emitWarning = ((warning, ...rest) => {
|
|
4357
|
-
const message = typeof warning === "string" ? warning : warning instanceof Error ? warning.message : "";
|
|
4358
|
-
const typeOrOptions = rest[0];
|
|
4359
|
-
const warningType = typeof warning === "string" ? typeof typeOrOptions === "string" ? typeOrOptions : typeof typeOrOptions === "object" && typeOrOptions !== null && "type" in typeOrOptions && typeof typeOrOptions.type === "string" ? typeOrOptions.type : "" : warning instanceof Error ? warning.name : "";
|
|
4360
|
-
const warningCode = typeof warning === "string" ? typeof typeOrOptions === "object" && typeOrOptions !== null && "code" in typeOrOptions && typeof typeOrOptions.code === "string" ? typeOrOptions.code : typeof rest[1] === "string" ? rest[1] : "" : warning instanceof Error && "code" in warning && typeof warning.code === "string" ? warning.code : "";
|
|
4361
|
-
if (message === SQLITE_EXPERIMENTAL_WARNING && (warningType === "ExperimentalWarning" || warningCode === "ExperimentalWarning")) {
|
|
4362
|
-
return;
|
|
4363
|
-
}
|
|
4364
|
-
forwardWarning(warning, ...rest);
|
|
4365
|
-
});
|
|
4366
4371
|
try {
|
|
4367
|
-
|
|
4372
|
+
return withSqliteExperimentalWarningSuppressed(() => {
|
|
4368
4373
|
const require2 = createRequire(import.meta.url);
|
|
4369
4374
|
const sqliteModule = require2("node:sqlite");
|
|
4370
4375
|
if (typeof sqliteModule !== "object" || sqliteModule === null || !("DatabaseSync" in sqliteModule) || typeof sqliteModule.DatabaseSync !== "function") {
|
|
@@ -4372,15 +4377,13 @@ function loadDatabaseSync() {
|
|
|
4372
4377
|
}
|
|
4373
4378
|
DatabaseSyncCtor = sqliteModule.DatabaseSync;
|
|
4374
4379
|
return DatabaseSyncCtor;
|
|
4375
|
-
}
|
|
4376
|
-
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
|
|
4382
|
-
} finally {
|
|
4383
|
-
process.emitWarning = originalEmitWarning;
|
|
4380
|
+
});
|
|
4381
|
+
} catch (error) {
|
|
4382
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
4383
|
+
throw new Error(
|
|
4384
|
+
`TechStack SQLite store needs Node's built-in SQLite (node:sqlite), available since Node 22.5. This runtime doesn't provide it: ${message}`,
|
|
4385
|
+
{ cause: error }
|
|
4386
|
+
);
|
|
4384
4387
|
}
|
|
4385
4388
|
}
|
|
4386
4389
|
var TechStackStore = class {
|
|
@@ -4400,8 +4403,9 @@ var TechStackStore = class {
|
|
|
4400
4403
|
this.db.exec("PRAGMA synchronous = NORMAL;");
|
|
4401
4404
|
this.db.exec("PRAGMA busy_timeout = 10000;");
|
|
4402
4405
|
this.db.exec("PRAGMA temp_store = MEMORY;");
|
|
4403
|
-
|
|
4404
|
-
this.db.exec(
|
|
4406
|
+
const cache = SageCachePragmas();
|
|
4407
|
+
this.db.exec(`PRAGMA cache_size = -${cache.cacheSizeKiB};`);
|
|
4408
|
+
this.db.exec(`PRAGMA mmap_size = ${cache.mmapBytes};`);
|
|
4405
4409
|
this.db.exec("PRAGMA foreign_keys = ON;");
|
|
4406
4410
|
applySchema(this.db);
|
|
4407
4411
|
}
|