memorix 1.10.0 → 1.10.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/CHANGELOG.md +25 -0
- package/README.md +2 -0
- package/README.zh-CN.md +2 -0
- package/dist/cli/index.js +575 -196
- package/dist/index.js +375 -134
- package/dist/maintenance-runner.js +210 -46
- package/dist/media-audio-runner.js +182 -18
- package/dist/media-video-runner.js +209 -45
- package/dist/memcode-runtime/CHANGELOG.md +25 -0
- package/dist/sdk.js +426 -134
- package/dist/vector-backfill-runner.js +209 -45
- package/docs/1.2.0-EVALUATION-HARNESS.md +18 -0
- package/docs/CONFIGURATION.md +25 -0
- package/docs/DEVELOPMENT.md +3 -3
- package/docs/PERFORMANCE.md +23 -0
- package/docs/README.md +2 -2
- package/docs/ROADMAP-1.9.12-2.0.md +13 -6
- package/package.json +1 -1
- package/plugins/antigravity/memorix/plugin.json +1 -1
- package/plugins/claude/memorix/.claude-plugin/plugin.json +1 -1
- package/plugins/codebuddy/memorix/.codebuddy-plugin/plugin.json +1 -1
- package/plugins/codex/memorix/.codex-plugin/plugin.json +1 -1
- package/plugins/copilot/memorix/plugin.json +1 -1
- package/plugins/gemini/memorix/gemini-extension.json +1 -1
- package/plugins/hermes/memorix/__init__.py +1 -2
- package/plugins/hermes/memorix/plugin.yaml +1 -1
- package/plugins/omp/memorix/package.json +1 -1
- package/plugins/openclaw/memorix/.codex-plugin/plugin.json +1 -1
- package/plugins/pi/memorix/package.json +1 -1
- package/server.json +2 -2
- package/src/cli/commands/init.ts +6 -2
- package/src/cli/commands/repair.ts +17 -3
- package/src/cli/tui/ConfigureView.tsx +2 -0
- package/src/codegraph/auto-context.ts +17 -0
- package/src/codegraph/context-pack.ts +15 -0
- package/src/compact/engine.ts +11 -0
- package/src/compact/index-format.ts +1 -1
- package/src/config/dotenv-loader.ts +1 -0
- package/src/config/resolved-config.ts +5 -2
- package/src/config/yaml-loader.ts +2 -2
- package/src/dashboard/server.ts +3 -0
- package/src/knowledge/context-assembly.ts +13 -0
- package/src/knowledge/context-receipt.ts +35 -0
- package/src/knowledge/workset.ts +8 -0
- package/src/llm/provider.ts +2 -1
- package/src/memory/observations.ts +7 -5
- package/src/multimodal/image-loader.ts +2 -2
- package/src/search/derived-view-receipt.ts +62 -0
- package/src/search/semantic-index.ts +149 -1
- package/src/server.ts +18 -3
- package/src/store/orama-store.ts +80 -2
package/dist/cli/index.js
CHANGED
|
@@ -3232,7 +3232,7 @@ ${import_picocolors.default.gray(m3)} ${s4}
|
|
|
3232
3232
|
|
|
3233
3233
|
// src/cli/version.ts
|
|
3234
3234
|
function getCliVersion() {
|
|
3235
|
-
return true ? "1.10.
|
|
3235
|
+
return true ? "1.10.2" : pkg.version;
|
|
3236
3236
|
}
|
|
3237
3237
|
var init_version = __esm({
|
|
3238
3238
|
"src/cli/version.ts"() {
|
|
@@ -22145,7 +22145,8 @@ function getResolvedConfig(options = {}) {
|
|
|
22145
22145
|
const isAtlasCloud = memoryLlmProvider === "atlascloud";
|
|
22146
22146
|
const isRequesty = memoryLlmProvider === "requesty";
|
|
22147
22147
|
const isApiRoute = memoryLlmProvider === "apiroute";
|
|
22148
|
-
const
|
|
22148
|
+
const isCheaperInference = memoryLlmProvider === "cheaperinference";
|
|
22149
|
+
const usesPresetKeyOnly = isAtlasCloud || isRequesty || isApiRoute || isCheaperInference;
|
|
22149
22150
|
const memoryLlmApiKey = first(
|
|
22150
22151
|
process.env.MEMORIX_LLM_API_KEY,
|
|
22151
22152
|
process.env.MEMORIX_API_KEY,
|
|
@@ -22153,7 +22154,7 @@ function getResolvedConfig(options = {}) {
|
|
|
22153
22154
|
yaml.llm?.apiKey,
|
|
22154
22155
|
legacy.llm?.apiKey,
|
|
22155
22156
|
// Never borrow another provider's credentials for these gateway presets.
|
|
22156
|
-
isAtlasCloud ? process.env.ATLASCLOUD_API_KEY : isRequesty ? process.env.REQUESTY_API_KEY : isApiRoute ? process.env.API_ROUTE_API_KEY : process.env.OPENAI_API_KEY,
|
|
22157
|
+
isAtlasCloud ? process.env.ATLASCLOUD_API_KEY : isRequesty ? process.env.REQUESTY_API_KEY : isApiRoute ? process.env.API_ROUTE_API_KEY : isCheaperInference ? process.env.CHEAPER_INFERENCE_API_KEY : process.env.OPENAI_API_KEY,
|
|
22157
22158
|
usesPresetKeyOnly ? void 0 : process.env.ANTHROPIC_API_KEY,
|
|
22158
22159
|
usesPresetKeyOnly ? void 0 : openRouterMemoryLlmApiKey
|
|
22159
22160
|
);
|
|
@@ -22337,6 +22338,7 @@ function getEnvSourceNames() {
|
|
|
22337
22338
|
"OPENROUTER_API_KEY",
|
|
22338
22339
|
"REQUESTY_API_KEY",
|
|
22339
22340
|
"API_ROUTE_API_KEY",
|
|
22341
|
+
"CHEAPER_INFERENCE_API_KEY",
|
|
22340
22342
|
"ATLASCLOUD_API_KEY"
|
|
22341
22343
|
].filter((name) => process.env[name]);
|
|
22342
22344
|
}
|
|
@@ -25331,6 +25333,7 @@ var init_provider2 = __esm({
|
|
|
25331
25333
|
openrouter: { baseUrl: "https://openrouter.ai/api/v1", model: "openai/gpt-4.1-nano" },
|
|
25332
25334
|
requesty: { baseUrl: "https://router.requesty.ai/v1", model: "openai/gpt-4.1-nano" },
|
|
25333
25335
|
apiroute: { baseUrl: "https://global.api-route.com/v1", model: "deepseek-v4.1-flash" },
|
|
25336
|
+
cheaperinference: { baseUrl: "https://api.cheaperinference.com/v1", model: "gpt-5.4-mini" },
|
|
25334
25337
|
atlascloud: { baseUrl: "https://api.atlascloud.ai/v1", model: "deepseek-ai/deepseek-v3.2" },
|
|
25335
25338
|
custom: { baseUrl: "http://localhost:11434/v1", model: "llama3" }
|
|
25336
25339
|
};
|
|
@@ -26108,7 +26111,25 @@ var init_obs_store = __esm({
|
|
|
26108
26111
|
});
|
|
26109
26112
|
|
|
26110
26113
|
// src/search/semantic-index.ts
|
|
26114
|
+
var semantic_index_exports = {};
|
|
26115
|
+
__export(semantic_index_exports, {
|
|
26116
|
+
closeSemanticIndex: () => closeSemanticIndex,
|
|
26117
|
+
closeSemanticIndexes: () => closeSemanticIndexes,
|
|
26118
|
+
createSemanticIndexProfile: () => createSemanticIndexProfile,
|
|
26119
|
+
deleteSemanticVector: () => deleteSemanticVector,
|
|
26120
|
+
ensureSemanticIndex: () => ensureSemanticIndex,
|
|
26121
|
+
getSemanticIndexStats: () => getSemanticIndexStats,
|
|
26122
|
+
isSemanticIndexAvailable: () => isSemanticIndexAvailable,
|
|
26123
|
+
listSemanticVectorIds: () => listSemanticVectorIds,
|
|
26124
|
+
optimizeSemanticIndex: () => optimizeSemanticIndex,
|
|
26125
|
+
optimizeSemanticIndexes: () => optimizeSemanticIndexes,
|
|
26126
|
+
resetSemanticIndexRuntime: () => resetSemanticIndexRuntime,
|
|
26127
|
+
searchSemanticVectors: () => searchSemanticVectors,
|
|
26128
|
+
upsertSemanticVector: () => upsertSemanticVector,
|
|
26129
|
+
upsertSemanticVectors: () => upsertSemanticVectors
|
|
26130
|
+
});
|
|
26111
26131
|
import { createHash as createHash4 } from "crypto";
|
|
26132
|
+
import { existsSync as existsSync10 } from "fs";
|
|
26112
26133
|
import { createRequire as createRequire3 } from "module";
|
|
26113
26134
|
import path10 from "path";
|
|
26114
26135
|
function createSemanticIndexProfile(provider2) {
|
|
@@ -26152,6 +26173,9 @@ async function loadLanceDb() {
|
|
|
26152
26173
|
return null;
|
|
26153
26174
|
}
|
|
26154
26175
|
}
|
|
26176
|
+
async function isSemanticIndexAvailable() {
|
|
26177
|
+
return await loadLanceDb() !== null;
|
|
26178
|
+
}
|
|
26155
26179
|
function semanticIndexEnabled() {
|
|
26156
26180
|
return process.env.MEMORIX_SEMANTIC_INDEX !== "off" && process.env.MEMORIX_SEMANTIC_INDEX !== "orama";
|
|
26157
26181
|
}
|
|
@@ -26207,17 +26231,127 @@ function queueOperation(key, operation) {
|
|
|
26207
26231
|
writeQueues.set(key, run.catch(() => void 0));
|
|
26208
26232
|
return run;
|
|
26209
26233
|
}
|
|
26234
|
+
function positiveEnvInt(name, fallback) {
|
|
26235
|
+
const value = Number.parseInt(process.env[name] ?? "", 10);
|
|
26236
|
+
return Number.isSafeInteger(value) && value > 0 ? value : fallback;
|
|
26237
|
+
}
|
|
26238
|
+
function semanticWriteBatchSize() {
|
|
26239
|
+
return positiveEnvInt("MEMORIX_SEMANTIC_WRITE_BATCH_SIZE", DEFAULT_WRITE_BATCH_SIZE);
|
|
26240
|
+
}
|
|
26241
|
+
function semanticWriteFlushMs() {
|
|
26242
|
+
return positiveEnvInt("MEMORIX_SEMANTIC_WRITE_FLUSH_MS", DEFAULT_WRITE_FLUSH_MS);
|
|
26243
|
+
}
|
|
26244
|
+
function semanticOptimizeEvery() {
|
|
26245
|
+
return positiveEnvInt("MEMORIX_SEMANTIC_OPTIMIZE_EVERY", DEFAULT_OPTIMIZE_EVERY);
|
|
26246
|
+
}
|
|
26247
|
+
function semanticVersionRetentionMs() {
|
|
26248
|
+
return positiveEnvInt("MEMORIX_SEMANTIC_VERSION_RETENTION_MS", DEFAULT_VERSION_RETENTION_MS);
|
|
26249
|
+
}
|
|
26250
|
+
async function optimizeState(state) {
|
|
26251
|
+
if (!state.table || typeof state.table.optimize !== "function") return;
|
|
26252
|
+
await state.table.optimize({
|
|
26253
|
+
cleanupOlderThan: new Date(Date.now() - semanticVersionRetentionMs()),
|
|
26254
|
+
deleteUnverified: false
|
|
26255
|
+
});
|
|
26256
|
+
}
|
|
26210
26257
|
async function mergeVectors(dataDir, profile, records) {
|
|
26211
26258
|
if (records.length === 0) return;
|
|
26212
26259
|
const state = await getState(dataDir, profile, records);
|
|
26213
26260
|
if (!state?.table) return;
|
|
26214
26261
|
const rows = records.map(toLanceRow);
|
|
26215
26262
|
await state.table.mergeInsert("observation_id").whenMatchedUpdateAll().whenNotMatchedInsertAll().execute(rows);
|
|
26263
|
+
const key = stateKey(dataDir, profile);
|
|
26264
|
+
const mutationCount = (mutationCounts.get(key) ?? 0) + 1;
|
|
26265
|
+
if (mutationCount >= semanticOptimizeEvery()) {
|
|
26266
|
+
mutationCounts.set(key, 0);
|
|
26267
|
+
await optimizeState(state).catch(() => void 0);
|
|
26268
|
+
} else {
|
|
26269
|
+
mutationCounts.set(key, mutationCount);
|
|
26270
|
+
}
|
|
26216
26271
|
void ensureSemanticIndex(dataDir, profile);
|
|
26217
26272
|
}
|
|
26273
|
+
function flushPendingVectorBatch(key) {
|
|
26274
|
+
const pending = pendingVectorBatches.get(key);
|
|
26275
|
+
if (!pending) return Promise.resolve();
|
|
26276
|
+
if (pending.timer) clearTimeout(pending.timer);
|
|
26277
|
+
pendingVectorBatches.delete(key);
|
|
26278
|
+
const records = [...pending.records.values()];
|
|
26279
|
+
const waiters = pending.waiters.splice(0);
|
|
26280
|
+
return queueOperation(key, () => mergeVectors(pending.dataDir, pending.profile, records)).then(() => waiters.forEach((waiter) => waiter.resolve())).catch((error40) => {
|
|
26281
|
+
waiters.forEach((waiter) => waiter.reject(error40));
|
|
26282
|
+
});
|
|
26283
|
+
}
|
|
26284
|
+
function upsertSemanticVector(dataDir, profile, record2) {
|
|
26285
|
+
const key = stateKey(dataDir, profile);
|
|
26286
|
+
let pending = pendingVectorBatches.get(key);
|
|
26287
|
+
if (!pending) {
|
|
26288
|
+
pending = { dataDir, profile, records: /* @__PURE__ */ new Map(), waiters: [] };
|
|
26289
|
+
pendingVectorBatches.set(key, pending);
|
|
26290
|
+
}
|
|
26291
|
+
pending.records.set(`${record2.projectId}:${record2.observationId}`, record2);
|
|
26292
|
+
const promise2 = new Promise((resolve9, reject) => pending.waiters.push({ resolve: resolve9, reject }));
|
|
26293
|
+
if (pending.records.size >= semanticWriteBatchSize()) void flushPendingVectorBatch(key);
|
|
26294
|
+
else if (!pending.timer) pending.timer = setTimeout(() => {
|
|
26295
|
+
void flushPendingVectorBatch(key);
|
|
26296
|
+
}, semanticWriteFlushMs());
|
|
26297
|
+
return promise2;
|
|
26298
|
+
}
|
|
26218
26299
|
function upsertSemanticVectors(dataDir, profile, records) {
|
|
26219
26300
|
return queueOperation(stateKey(dataDir, profile), () => mergeVectors(dataDir, profile, records));
|
|
26220
26301
|
}
|
|
26302
|
+
async function listSemanticVectorIds(dataDir, profile) {
|
|
26303
|
+
const state = await getState(dataDir, profile);
|
|
26304
|
+
if (!state?.table) return null;
|
|
26305
|
+
const rows = await state.table.query().select(["observation_id"]).toArray();
|
|
26306
|
+
return new Set(rows.map((row) => Number(row.observation_id)).filter(Number.isSafeInteger));
|
|
26307
|
+
}
|
|
26308
|
+
async function getSemanticIndexStats(dataDir, profile) {
|
|
26309
|
+
const state = await getState(dataDir, profile);
|
|
26310
|
+
if (!state?.table) return null;
|
|
26311
|
+
return {
|
|
26312
|
+
rowCount: await state.table.countRows(),
|
|
26313
|
+
version: typeof state.table.version === "function" ? await state.table.version() : 0
|
|
26314
|
+
};
|
|
26315
|
+
}
|
|
26316
|
+
function optimizeSemanticIndex(dataDir, profile) {
|
|
26317
|
+
const key = stateKey(dataDir, profile);
|
|
26318
|
+
return queueOperation(key, async () => {
|
|
26319
|
+
const state = await getState(dataDir, profile);
|
|
26320
|
+
if (state) await optimizeState(state);
|
|
26321
|
+
mutationCounts.set(key, 0);
|
|
26322
|
+
});
|
|
26323
|
+
}
|
|
26324
|
+
async function optimizeSemanticIndexes(dataDir) {
|
|
26325
|
+
if (!existsSync10(indexRoot(dataDir))) return [];
|
|
26326
|
+
const lance = await loadLanceDb();
|
|
26327
|
+
if (!lance) throw new Error("LanceDB is unavailable; install the optional @lancedb/lancedb package");
|
|
26328
|
+
const connection = await lance.connect(indexRoot(dataDir));
|
|
26329
|
+
try {
|
|
26330
|
+
const names = typeof connection.tableNames === "function" ? await connection.tableNames() : (await connection.listTables()).tables;
|
|
26331
|
+
const optimized = [];
|
|
26332
|
+
for (const name of names.filter((value) => value.startsWith(TABLE_PREFIX))) {
|
|
26333
|
+
const table = await connection.openTable(name);
|
|
26334
|
+
await table.optimize({
|
|
26335
|
+
cleanupOlderThan: new Date(Date.now() - semanticVersionRetentionMs()),
|
|
26336
|
+
deleteUnverified: false
|
|
26337
|
+
});
|
|
26338
|
+
optimized.push(name);
|
|
26339
|
+
}
|
|
26340
|
+
return optimized;
|
|
26341
|
+
} finally {
|
|
26342
|
+
try {
|
|
26343
|
+
connection.close?.();
|
|
26344
|
+
} catch {
|
|
26345
|
+
}
|
|
26346
|
+
}
|
|
26347
|
+
}
|
|
26348
|
+
function deleteSemanticVector(dataDir, profile, observationId2) {
|
|
26349
|
+
return queueOperation(stateKey(dataDir, profile), async () => {
|
|
26350
|
+
const state = await getState(dataDir, profile);
|
|
26351
|
+
if (!state?.table) return;
|
|
26352
|
+
await state.table.delete(`observation_id = ${Math.trunc(observationId2)}`);
|
|
26353
|
+
});
|
|
26354
|
+
}
|
|
26221
26355
|
function resolveIndexThreshold() {
|
|
26222
26356
|
const raw = Number.parseInt(process.env.MEMORIX_SEMANTIC_INDEX_THRESHOLD ?? "", 10);
|
|
26223
26357
|
return Number.isSafeInteger(raw) && raw > 0 ? raw : DEFAULT_INDEX_THRESHOLD;
|
|
@@ -26269,7 +26403,50 @@ async function searchSemanticVectors(options) {
|
|
|
26269
26403
|
distance: Number(row._distance ?? Number.POSITIVE_INFINITY)
|
|
26270
26404
|
})).filter((row) => Number.isFinite(row.distance));
|
|
26271
26405
|
}
|
|
26272
|
-
|
|
26406
|
+
async function closeSemanticIndexes() {
|
|
26407
|
+
await Promise.all([...pendingVectorBatches.keys()].map((key) => flushPendingVectorBatch(key)));
|
|
26408
|
+
await Promise.all([...writeQueues.values()]);
|
|
26409
|
+
for (const statePromise of statePromises.values()) {
|
|
26410
|
+
const state = await statePromise.catch(() => null);
|
|
26411
|
+
try {
|
|
26412
|
+
state?.connection?.close?.();
|
|
26413
|
+
} catch {
|
|
26414
|
+
}
|
|
26415
|
+
}
|
|
26416
|
+
statePromises.clear();
|
|
26417
|
+
writeQueues.clear();
|
|
26418
|
+
indexBuilds.clear();
|
|
26419
|
+
mutationCounts.clear();
|
|
26420
|
+
}
|
|
26421
|
+
async function closeSemanticIndex(dataDir) {
|
|
26422
|
+
const prefix = `${path10.resolve(dataDir)}::`;
|
|
26423
|
+
await Promise.all([...pendingVectorBatches.keys()].filter((key) => key.startsWith(prefix)).map(flushPendingVectorBatch));
|
|
26424
|
+
await Promise.all([...writeQueues.entries()].filter(([key]) => key.startsWith(prefix)).map(([, queue2]) => queue2));
|
|
26425
|
+
for (const [key, statePromise] of statePromises.entries()) {
|
|
26426
|
+
if (!key.startsWith(prefix)) continue;
|
|
26427
|
+
const state = await statePromise.catch(() => null);
|
|
26428
|
+
try {
|
|
26429
|
+
state?.connection?.close?.();
|
|
26430
|
+
} catch {
|
|
26431
|
+
}
|
|
26432
|
+
statePromises.delete(key);
|
|
26433
|
+
writeQueues.delete(key);
|
|
26434
|
+
indexBuilds.delete(key);
|
|
26435
|
+
mutationCounts.delete(key);
|
|
26436
|
+
}
|
|
26437
|
+
}
|
|
26438
|
+
function resetSemanticIndexRuntime() {
|
|
26439
|
+
for (const pending of pendingVectorBatches.values()) {
|
|
26440
|
+
if (pending.timer) clearTimeout(pending.timer);
|
|
26441
|
+
}
|
|
26442
|
+
pendingVectorBatches.clear();
|
|
26443
|
+
statePromises.clear();
|
|
26444
|
+
writeQueues.clear();
|
|
26445
|
+
indexBuilds.clear();
|
|
26446
|
+
mutationCounts.clear();
|
|
26447
|
+
availability = void 0;
|
|
26448
|
+
}
|
|
26449
|
+
var SEMANTIC_INDEX_DIR, TABLE_PREFIX, DEFAULT_INDEX_THRESHOLD, MAX_INDEX_PARTITIONS, DEFAULT_WRITE_BATCH_SIZE, DEFAULT_WRITE_FLUSH_MS, DEFAULT_OPTIMIZE_EVERY, DEFAULT_VERSION_RETENTION_MS, statePromises, writeQueues, indexBuilds, mutationCounts, pendingVectorBatches, availability, requireFromHere2;
|
|
26273
26450
|
var init_semantic_index = __esm({
|
|
26274
26451
|
"src/search/semantic-index.ts"() {
|
|
26275
26452
|
"use strict";
|
|
@@ -26278,13 +26455,84 @@ var init_semantic_index = __esm({
|
|
|
26278
26455
|
TABLE_PREFIX = "observations_";
|
|
26279
26456
|
DEFAULT_INDEX_THRESHOLD = 1e4;
|
|
26280
26457
|
MAX_INDEX_PARTITIONS = 32;
|
|
26458
|
+
DEFAULT_WRITE_BATCH_SIZE = 100;
|
|
26459
|
+
DEFAULT_WRITE_FLUSH_MS = 50;
|
|
26460
|
+
DEFAULT_OPTIMIZE_EVERY = 20;
|
|
26461
|
+
DEFAULT_VERSION_RETENTION_MS = 24 * 60 * 60 * 1e3;
|
|
26281
26462
|
statePromises = /* @__PURE__ */ new Map();
|
|
26282
26463
|
writeQueues = /* @__PURE__ */ new Map();
|
|
26283
26464
|
indexBuilds = /* @__PURE__ */ new Map();
|
|
26465
|
+
mutationCounts = /* @__PURE__ */ new Map();
|
|
26466
|
+
pendingVectorBatches = /* @__PURE__ */ new Map();
|
|
26284
26467
|
requireFromHere2 = createRequire3(import.meta.url);
|
|
26285
26468
|
}
|
|
26286
26469
|
});
|
|
26287
26470
|
|
|
26471
|
+
// src/memory/secret-filter.ts
|
|
26472
|
+
function applyRedaction(text3) {
|
|
26473
|
+
if (!text3) return text3;
|
|
26474
|
+
let out = text3;
|
|
26475
|
+
out = out.replace(
|
|
26476
|
+
/((?:password|passwd|pwd|secret|token|api[_-]?key|auth[_-]?key|access[_-]?key|private[_-]?key|client[_-]?secret)\s*[:=]\s*["']?)([^\s"',;\n]{6,})/gi,
|
|
26477
|
+
"$1[REDACTED]"
|
|
26478
|
+
);
|
|
26479
|
+
out = out.replace(
|
|
26480
|
+
/(Bearer\s+)([A-Za-z0-9._\-/+]{20,})/g,
|
|
26481
|
+
"$1[REDACTED]"
|
|
26482
|
+
);
|
|
26483
|
+
out = out.replace(/\b(?:ghp|ghs|gho|github_pat)_[A-Za-z0-9]{36,}\b/g, "[REDACTED]");
|
|
26484
|
+
out = out.replace(/\bsk-[A-Za-z0-9T-]{20,}\b/g, "[REDACTED]");
|
|
26485
|
+
out = out.replace(/\beyJ[A-Za-z0-9._-]{40,}\b/g, "[REDACTED]");
|
|
26486
|
+
return out;
|
|
26487
|
+
}
|
|
26488
|
+
function sanitizeCredentials(text3) {
|
|
26489
|
+
return applyRedaction(text3);
|
|
26490
|
+
}
|
|
26491
|
+
function redactCredentials(text3) {
|
|
26492
|
+
return applyRedaction(text3);
|
|
26493
|
+
}
|
|
26494
|
+
var init_secret_filter = __esm({
|
|
26495
|
+
"src/memory/secret-filter.ts"() {
|
|
26496
|
+
"use strict";
|
|
26497
|
+
init_esm_shims();
|
|
26498
|
+
}
|
|
26499
|
+
});
|
|
26500
|
+
|
|
26501
|
+
// src/search/derived-view-receipt.ts
|
|
26502
|
+
function sanitizeDerivedViewFailureReason(reason) {
|
|
26503
|
+
const safe = sanitizeCredentials(reason).replace(/(?:[A-Za-z]:[\\/]|\\\\[^\\/\s]+[\\/]|\/(?:home|Users|tmp|var|private|mnt|workspace|workspaces)\/)[^\s"'<>|]*/gi, "[path]").replace(/\s+/g, " ").trim();
|
|
26504
|
+
return safe.slice(0, 240) || "derived view failed";
|
|
26505
|
+
}
|
|
26506
|
+
function embeddingHealthReceipt(health, embeddingEnabled2) {
|
|
26507
|
+
if (health?.status === "disabled") {
|
|
26508
|
+
return { freshness: "current", rebuildStatus: "disabled" };
|
|
26509
|
+
}
|
|
26510
|
+
if (health?.status === "ready" || embeddingEnabled2) {
|
|
26511
|
+
return { freshness: "current", rebuildStatus: "idle" };
|
|
26512
|
+
}
|
|
26513
|
+
if (health?.status === "degraded") {
|
|
26514
|
+
return {
|
|
26515
|
+
freshness: "stale",
|
|
26516
|
+
rebuildStatus: "failed",
|
|
26517
|
+
...health.failure ? {
|
|
26518
|
+
failureReason: `embedding ${health.failure.kind}; retry in ${health.failure.retryAfterMs}ms`
|
|
26519
|
+
} : { failureReason: "embedding provider degraded" }
|
|
26520
|
+
};
|
|
26521
|
+
}
|
|
26522
|
+
return {
|
|
26523
|
+
freshness: "unknown",
|
|
26524
|
+
rebuildStatus: "unavailable",
|
|
26525
|
+
failureReason: "embedding provider is not initialized"
|
|
26526
|
+
};
|
|
26527
|
+
}
|
|
26528
|
+
var init_derived_view_receipt = __esm({
|
|
26529
|
+
"src/search/derived-view-receipt.ts"() {
|
|
26530
|
+
"use strict";
|
|
26531
|
+
init_esm_shims();
|
|
26532
|
+
init_secret_filter();
|
|
26533
|
+
}
|
|
26534
|
+
});
|
|
26535
|
+
|
|
26288
26536
|
// src/memory/entity-extractor.ts
|
|
26289
26537
|
function extractEntities(content) {
|
|
26290
26538
|
const result = {
|
|
@@ -26388,36 +26636,6 @@ var init_entity_extractor = __esm({
|
|
|
26388
26636
|
}
|
|
26389
26637
|
});
|
|
26390
26638
|
|
|
26391
|
-
// src/memory/secret-filter.ts
|
|
26392
|
-
function applyRedaction(text3) {
|
|
26393
|
-
if (!text3) return text3;
|
|
26394
|
-
let out = text3;
|
|
26395
|
-
out = out.replace(
|
|
26396
|
-
/((?:password|passwd|pwd|secret|token|api[_-]?key|auth[_-]?key|access[_-]?key|private[_-]?key|client[_-]?secret)\s*[:=]\s*["']?)([^\s"',;\n]{6,})/gi,
|
|
26397
|
-
"$1[REDACTED]"
|
|
26398
|
-
);
|
|
26399
|
-
out = out.replace(
|
|
26400
|
-
/(Bearer\s+)([A-Za-z0-9._\-/+]{20,})/g,
|
|
26401
|
-
"$1[REDACTED]"
|
|
26402
|
-
);
|
|
26403
|
-
out = out.replace(/\b(?:ghp|ghs|gho|github_pat)_[A-Za-z0-9]{36,}\b/g, "[REDACTED]");
|
|
26404
|
-
out = out.replace(/\bsk-[A-Za-z0-9T-]{20,}\b/g, "[REDACTED]");
|
|
26405
|
-
out = out.replace(/\beyJ[A-Za-z0-9._-]{40,}\b/g, "[REDACTED]");
|
|
26406
|
-
return out;
|
|
26407
|
-
}
|
|
26408
|
-
function sanitizeCredentials(text3) {
|
|
26409
|
-
return applyRedaction(text3);
|
|
26410
|
-
}
|
|
26411
|
-
function redactCredentials(text3) {
|
|
26412
|
-
return applyRedaction(text3);
|
|
26413
|
-
}
|
|
26414
|
-
var init_secret_filter = __esm({
|
|
26415
|
-
"src/memory/secret-filter.ts"() {
|
|
26416
|
-
"use strict";
|
|
26417
|
-
init_esm_shims();
|
|
26418
|
-
}
|
|
26419
|
-
});
|
|
26420
|
-
|
|
26421
26639
|
// src/runtime/maintenance-jobs.ts
|
|
26422
26640
|
var maintenance_jobs_exports = {};
|
|
26423
26641
|
__export(maintenance_jobs_exports, {
|
|
@@ -27276,7 +27494,7 @@ var init_maintenance_targets = __esm({
|
|
|
27276
27494
|
|
|
27277
27495
|
// src/runtime/isolated-maintenance.ts
|
|
27278
27496
|
import { spawn } from "child_process";
|
|
27279
|
-
import { existsSync as
|
|
27497
|
+
import { existsSync as existsSync11 } from "fs";
|
|
27280
27498
|
import os3 from "os";
|
|
27281
27499
|
import path11 from "path";
|
|
27282
27500
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
@@ -27294,7 +27512,7 @@ function childError(prefix, detail) {
|
|
|
27294
27512
|
}
|
|
27295
27513
|
function isolatedMaintenanceCwd() {
|
|
27296
27514
|
const tmp = os3.tmpdir();
|
|
27297
|
-
return
|
|
27515
|
+
return existsSync11(tmp) ? tmp : process.cwd();
|
|
27298
27516
|
}
|
|
27299
27517
|
function resolveMaintenanceRunnerPath(moduleUrl = import.meta.url) {
|
|
27300
27518
|
const moduleDir = path11.dirname(fileURLToPath3(moduleUrl));
|
|
@@ -27351,7 +27569,7 @@ function collectOutput(stream2, limit2, onOverflow) {
|
|
|
27351
27569
|
async function runMaintenanceInChildProcess(request, options = {}) {
|
|
27352
27570
|
validateRequest(request);
|
|
27353
27571
|
const runnerPath = options.runnerPath ?? resolveMaintenanceRunnerPath();
|
|
27354
|
-
if (!
|
|
27572
|
+
if (!existsSync11(runnerPath)) {
|
|
27355
27573
|
throw new Error(`Maintenance runner is unavailable at ${runnerPath}. Reinstall or rebuild Memorix.`);
|
|
27356
27574
|
}
|
|
27357
27575
|
const timeoutMs = Number.isFinite(options.timeoutMs) ? Math.max(1e3, Math.floor(options.timeoutMs)) : DEFAULT_TIMEOUT_MS;
|
|
@@ -178369,7 +178587,7 @@ __export(video_jobs_exports, {
|
|
|
178369
178587
|
runMiniMaxVideoGenerationJob: () => runMiniMaxVideoGenerationJob
|
|
178370
178588
|
});
|
|
178371
178589
|
import { spawn as spawn2 } from "child_process";
|
|
178372
|
-
import { existsSync as
|
|
178590
|
+
import { existsSync as existsSync12 } from "fs";
|
|
178373
178591
|
import path17 from "path";
|
|
178374
178592
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
178375
178593
|
function safeError2(error40) {
|
|
@@ -178617,7 +178835,7 @@ function resolveMediaVideoRunnerPath(moduleUrl = import.meta.url) {
|
|
|
178617
178835
|
}
|
|
178618
178836
|
function launchMediaVideoRunner(request, options = {}) {
|
|
178619
178837
|
const runnerPath = options.runnerPath ?? resolveMediaVideoRunnerPath();
|
|
178620
|
-
if (!
|
|
178838
|
+
if (!existsSync12(runnerPath)) {
|
|
178621
178839
|
return { launched: false, reason: "Media video runner is unavailable until Memorix is built or reinstalled." };
|
|
178622
178840
|
}
|
|
178623
178841
|
try {
|
|
@@ -178662,7 +178880,7 @@ __export(audio_jobs_exports, {
|
|
|
178662
178880
|
transcribeAudio: () => transcribeAudio
|
|
178663
178881
|
});
|
|
178664
178882
|
import { spawn as spawn3 } from "child_process";
|
|
178665
|
-
import { existsSync as
|
|
178883
|
+
import { existsSync as existsSync13 } from "fs";
|
|
178666
178884
|
import path18 from "path";
|
|
178667
178885
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
178668
178886
|
function safeError3(error40) {
|
|
@@ -178913,7 +179131,7 @@ function resolveMediaAudioRunnerPath(moduleUrl = import.meta.url) {
|
|
|
178913
179131
|
}
|
|
178914
179132
|
function launchMediaAudioRunner(request, options = {}) {
|
|
178915
179133
|
const runnerPath = options.runnerPath ?? resolveMediaAudioRunnerPath();
|
|
178916
|
-
if (!
|
|
179134
|
+
if (!existsSync13(runnerPath)) return { launched: false, reason: "Audio runner is unavailable until Memorix is built or reinstalled." };
|
|
178917
179135
|
try {
|
|
178918
179136
|
const child = spawn3(process.execPath, [runnerPath, JSON.stringify(request)], {
|
|
178919
179137
|
cwd: request.projectRoot,
|
|
@@ -181886,7 +182104,7 @@ __export(lite_provider_exports, {
|
|
|
181886
182104
|
refreshProjectLite: () => refreshProjectLite
|
|
181887
182105
|
});
|
|
181888
182106
|
import { createHash as createHash11 } from "crypto";
|
|
181889
|
-
import { existsSync as
|
|
182107
|
+
import { existsSync as existsSync15, readdirSync as readdirSync2, readFileSync as readFileSync9, statSync as statSync4 } from "fs";
|
|
181890
182108
|
import { join as join5, relative as relative2 } from "path";
|
|
181891
182109
|
function hashText2(text3) {
|
|
181892
182110
|
return createHash11("sha256").update(text3).digest("hex");
|
|
@@ -181904,7 +182122,7 @@ function resolveMaxFileBytes(value) {
|
|
|
181904
182122
|
return Math.max(1, Math.floor(value));
|
|
181905
182123
|
}
|
|
181906
182124
|
function isPythonVirtualenvDir(dir) {
|
|
181907
|
-
return
|
|
182125
|
+
return existsSync15(join5(dir, "pyvenv.cfg"));
|
|
181908
182126
|
}
|
|
181909
182127
|
function walk(root, exclude, maxFiles) {
|
|
181910
182128
|
const out = [];
|
|
@@ -185820,7 +186038,7 @@ __export(vector_backfill_runner_exports, {
|
|
|
185820
186038
|
import { spawn as spawn4 } from "child_process";
|
|
185821
186039
|
import {
|
|
185822
186040
|
closeSync,
|
|
185823
|
-
existsSync as
|
|
186041
|
+
existsSync as existsSync16,
|
|
185824
186042
|
mkdirSync as mkdirSync2,
|
|
185825
186043
|
openSync,
|
|
185826
186044
|
readFileSync as readFileSync10,
|
|
@@ -185948,7 +186166,7 @@ function releaseVectorBackfillLock(lockPath = process.env.MEMORIX_VECTOR_BACKFIL
|
|
|
185948
186166
|
}
|
|
185949
186167
|
function launchDetachedVectorBackfill(request, options = {}) {
|
|
185950
186168
|
const runnerPath = options.runnerPath ?? resolveVectorBackfillRunnerPath();
|
|
185951
|
-
const exists3 = options.exists ??
|
|
186169
|
+
const exists3 = options.exists ?? existsSync16;
|
|
185952
186170
|
if (!exists3(runnerPath)) return false;
|
|
185953
186171
|
const lock = acquireVectorBackfillLock(request.dataDir, request.projectId, options.lockPath);
|
|
185954
186172
|
if (!lock) return false;
|
|
@@ -186967,13 +187185,14 @@ async function prepareSearchIndex(options = {}) {
|
|
|
186967
187185
|
return 0;
|
|
186968
187186
|
}
|
|
186969
187187
|
const hydratedProjectDir = projectDir;
|
|
186970
|
-
const queueMissingVectors = () => {
|
|
186971
|
-
if (projectDir !== hydratedProjectDir) return;
|
|
187188
|
+
const queueMissingVectors = async () => {
|
|
187189
|
+
if (!hydratedProjectDir || projectDir !== hydratedProjectDir) return;
|
|
186972
187190
|
vectorMissingIds.clear();
|
|
186973
187191
|
if (!isEmbeddingExplicitlyDisabled()) {
|
|
187192
|
+
const persistedSemanticIds = await getPersistentSemanticVectorIds(hydratedProjectDir).catch(() => null);
|
|
186974
187193
|
const projectsWithMissingVectors = /* @__PURE__ */ new Set();
|
|
186975
187194
|
for (const obs of observations) {
|
|
186976
|
-
if (!hasObservationVector(obs.projectId, obs.id)) {
|
|
187195
|
+
if (!hasObservationVector(obs.projectId, obs.id) && !persistedSemanticIds?.has(obs.id)) {
|
|
186977
187196
|
vectorMissingIds.add(obs.id);
|
|
186978
187197
|
projectsWithMissingVectors.add(obs.projectId);
|
|
186979
187198
|
}
|
|
@@ -186983,9 +187202,9 @@ async function prepareSearchIndex(options = {}) {
|
|
|
186983
187202
|
};
|
|
186984
187203
|
const cacheHydration = getDeferredCachedVectorHydration();
|
|
186985
187204
|
if (cacheHydration) {
|
|
186986
|
-
void cacheHydration.
|
|
187205
|
+
void cacheHydration.then(queueMissingVectors, queueMissingVectors).catch(() => void 0);
|
|
186987
187206
|
} else {
|
|
186988
|
-
queueMissingVectors();
|
|
187207
|
+
await queueMissingVectors();
|
|
186989
187208
|
}
|
|
186990
187209
|
searchIndexPrepared = true;
|
|
186991
187210
|
return count3;
|
|
@@ -187804,6 +188023,8 @@ __export(orama_store_exports, {
|
|
|
187804
188023
|
getLastSearchMode: () => getLastSearchMode,
|
|
187805
188024
|
getObservationCount: () => getObservationCount2,
|
|
187806
188025
|
getObservationsByIds: () => getObservationsByIds,
|
|
188026
|
+
getPersistentSemanticVectorIds: () => getPersistentSemanticVectorIds,
|
|
188027
|
+
getSearchDerivedViews: () => getSearchDerivedViews,
|
|
187807
188028
|
getTimeline: () => getTimeline,
|
|
187808
188029
|
getVectorDimensions: () => getVectorDimensions,
|
|
187809
188030
|
hasObservationVector: () => hasObservationVector,
|
|
@@ -187833,6 +188054,52 @@ function getLastSearchDiagnostics(projectId) {
|
|
|
187833
188054
|
const diagnostics = lastSearchDiagnosticsByProject.get(projectId ?? SEARCH_MODE_DEFAULT_KEY);
|
|
187834
188055
|
return diagnostics ? { ...diagnostics } : void 0;
|
|
187835
188056
|
}
|
|
188057
|
+
function getSearchDerivedViews() {
|
|
188058
|
+
const views = {};
|
|
188059
|
+
const store2 = getOptionalObservationStore();
|
|
188060
|
+
if (store2) {
|
|
188061
|
+
try {
|
|
188062
|
+
const generation = store2.getGeneration();
|
|
188063
|
+
if (store2.hasLexicalIndex?.()) {
|
|
188064
|
+
views.fts = { generation, freshness: "current", rebuildStatus: "idle" };
|
|
188065
|
+
} else {
|
|
188066
|
+
views.fts = {
|
|
188067
|
+
generation,
|
|
188068
|
+
freshness: "unknown",
|
|
188069
|
+
rebuildStatus: "unavailable",
|
|
188070
|
+
failureReason: sanitizeDerivedViewFailureReason(
|
|
188071
|
+
store2.getBackendReason?.() ?? "persistent lexical index unavailable"
|
|
188072
|
+
)
|
|
188073
|
+
};
|
|
188074
|
+
}
|
|
188075
|
+
} catch (error40) {
|
|
188076
|
+
views.fts = {
|
|
188077
|
+
freshness: "unknown",
|
|
188078
|
+
rebuildStatus: "failed",
|
|
188079
|
+
failureReason: sanitizeDerivedViewFailureReason(error40 instanceof Error ? error40.message : String(error40))
|
|
188080
|
+
};
|
|
188081
|
+
}
|
|
188082
|
+
} else {
|
|
188083
|
+
views.fts = {
|
|
188084
|
+
freshness: "unknown",
|
|
188085
|
+
rebuildStatus: "unavailable",
|
|
188086
|
+
failureReason: "observation store is not initialized"
|
|
188087
|
+
};
|
|
188088
|
+
}
|
|
188089
|
+
views.orama = db ? { generation: dbGeneration, freshness: "current", rebuildStatus: "idle" } : {
|
|
188090
|
+
generation: dbGeneration,
|
|
188091
|
+
freshness: "unknown",
|
|
188092
|
+
rebuildStatus: "unavailable",
|
|
188093
|
+
failureReason: "Orama index is not initialized"
|
|
188094
|
+
};
|
|
188095
|
+
let embeddingHealth;
|
|
188096
|
+
try {
|
|
188097
|
+
embeddingHealth = getEmbeddingRuntimeHealth?.();
|
|
188098
|
+
} catch {
|
|
188099
|
+
}
|
|
188100
|
+
views.embedding = embeddingHealthReceipt(embeddingHealth, embeddingEnabled);
|
|
188101
|
+
return views;
|
|
188102
|
+
}
|
|
187836
188103
|
function rememberSearchDiagnostics(key, value) {
|
|
187837
188104
|
if (!lastSearchDiagnosticsByProject.has(key) && lastSearchDiagnosticsByProject.size >= MAX_SEARCH_MODE_KEYS) {
|
|
187838
188105
|
const oldest = lastSearchDiagnosticsByProject.keys().next().value;
|
|
@@ -188134,12 +188401,16 @@ function getVectorDimensions() {
|
|
|
188134
188401
|
function getActiveSemanticIndexProfile() {
|
|
188135
188402
|
return indexEmbeddingProvider ? createSemanticIndexProfile(indexEmbeddingProvider) : null;
|
|
188136
188403
|
}
|
|
188404
|
+
async function getPersistentSemanticVectorIds(dataDir) {
|
|
188405
|
+
if (!indexEmbeddingProvider) return null;
|
|
188406
|
+
return listSemanticVectorIds(dataDir, createSemanticIndexProfile(indexEmbeddingProvider));
|
|
188407
|
+
}
|
|
188137
188408
|
async function queueSemanticVector(dataDir, record2) {
|
|
188138
188409
|
const provider2 = indexEmbeddingProvider ?? await getEmbeddingProvider();
|
|
188139
188410
|
const profile = provider2 ? createSemanticIndexProfile(provider2) : null;
|
|
188140
188411
|
if (!profile) return;
|
|
188141
188412
|
try {
|
|
188142
|
-
await
|
|
188413
|
+
await upsertSemanticVector(dataDir, profile, record2);
|
|
188143
188414
|
} catch {
|
|
188144
188415
|
}
|
|
188145
188416
|
}
|
|
@@ -188201,6 +188472,7 @@ function isCompatibleCachedVector(vector) {
|
|
|
188201
188472
|
async function attachCachedVectors(database, observations2) {
|
|
188202
188473
|
const semanticDataDir = (await Promise.resolve().then(() => (init_observations(), observations_exports))).getObservationDataDir();
|
|
188203
188474
|
const semanticProfile = getActiveSemanticIndexProfile();
|
|
188475
|
+
const persistedSemanticIds = semanticDataDir && semanticProfile ? await listSemanticVectorIds(semanticDataDir, semanticProfile).catch(() => null) : null;
|
|
188204
188476
|
const batchSize = 200;
|
|
188205
188477
|
for (let start = 0; start < observations2.length; start += batchSize) {
|
|
188206
188478
|
const batch = observations2.slice(start, start + batchSize);
|
|
@@ -188211,7 +188483,7 @@ async function attachCachedVectors(database, observations2) {
|
|
|
188211
188483
|
const vector = cachedVectors[index];
|
|
188212
188484
|
if (!isCompatibleCachedVector(vector)) continue;
|
|
188213
188485
|
const observation = batch[index];
|
|
188214
|
-
if (semanticDataDir && semanticProfile) {
|
|
188486
|
+
if (semanticDataDir && semanticProfile && !persistedSemanticIds?.has(observation.id)) {
|
|
188215
188487
|
semanticRecords.push({
|
|
188216
188488
|
observationId: observation.id,
|
|
188217
188489
|
projectId: observation.projectId,
|
|
@@ -188985,6 +189257,7 @@ var init_orama_store = __esm({
|
|
|
188985
189257
|
init_mini_skills();
|
|
188986
189258
|
init_visibility();
|
|
188987
189259
|
init_provider();
|
|
189260
|
+
init_provider();
|
|
188988
189261
|
init_project_affinity();
|
|
188989
189262
|
init_intent_detector();
|
|
188990
189263
|
init_query_expansion();
|
|
@@ -188992,6 +189265,7 @@ var init_orama_store = __esm({
|
|
|
188992
189265
|
init_timeout();
|
|
188993
189266
|
init_obs_store();
|
|
188994
189267
|
init_semantic_index();
|
|
189268
|
+
init_derived_view_receipt();
|
|
188995
189269
|
db = null;
|
|
188996
189270
|
dbInitPromise = null;
|
|
188997
189271
|
dbGeneration = 0;
|
|
@@ -189435,6 +189709,14 @@ This project does have stored Memorix memories, but none matched the current que
|
|
|
189435
189709
|
}
|
|
189436
189710
|
const totalTokens = countTextTokens(formatted);
|
|
189437
189711
|
const diagnostics = getLastSearchDiagnostics(options.projectId);
|
|
189712
|
+
const derivedViews = getSearchDerivedViews();
|
|
189713
|
+
if (diagnostics?.fallbackUsed && diagnostics.fallbackReason) {
|
|
189714
|
+
derivedViews.embedding = {
|
|
189715
|
+
freshness: "stale",
|
|
189716
|
+
rebuildStatus: "failed",
|
|
189717
|
+
failureReason: diagnostics.fallbackReason
|
|
189718
|
+
};
|
|
189719
|
+
}
|
|
189438
189720
|
return {
|
|
189439
189721
|
entries,
|
|
189440
189722
|
formatted,
|
|
@@ -189449,6 +189731,7 @@ This project does have stored Memorix memories, but none matched the current que
|
|
|
189449
189731
|
omittedByTokenBudget: diagnostics?.omittedByTokenBudget ?? 0,
|
|
189450
189732
|
fallbackUsed: diagnostics?.fallbackUsed ?? false,
|
|
189451
189733
|
...diagnostics?.fallbackReason ? { fallbackReason: diagnostics.fallbackReason } : {},
|
|
189734
|
+
derivedViews,
|
|
189452
189735
|
tokenCount: totalTokens,
|
|
189453
189736
|
elapsedMs: Math.max(0, Date.now() - startedAt)
|
|
189454
189737
|
}
|
|
@@ -193289,7 +193572,7 @@ __export(init_exports, {
|
|
|
193289
193572
|
buildInitTomlConfig: () => buildInitTomlConfig,
|
|
193290
193573
|
default: () => init_default5
|
|
193291
193574
|
});
|
|
193292
|
-
import { existsSync as
|
|
193575
|
+
import { existsSync as existsSync17, mkdirSync as mkdirSync3, writeFileSync as writeFileSync3 } from "fs";
|
|
193293
193576
|
import { homedir as homedir8 } from "os";
|
|
193294
193577
|
import path29 from "path";
|
|
193295
193578
|
function buildInitTomlConfig(options) {
|
|
@@ -193327,6 +193610,8 @@ function buildInitTomlConfig(options) {
|
|
|
193327
193610
|
lines.push('# model = "openai/gpt-4o-mini"');
|
|
193328
193611
|
} else if (options.llmProvider === "apiroute") {
|
|
193329
193612
|
lines.push('model = "deepseek-v4.1-flash"');
|
|
193613
|
+
} else if (options.llmProvider === "cheaperinference") {
|
|
193614
|
+
lines.push('model = "gpt-5.4-mini"');
|
|
193330
193615
|
} else if (options.llmProvider === "atlascloud") {
|
|
193331
193616
|
lines.push('model = "deepseek-ai/deepseek-v3.2"');
|
|
193332
193617
|
}
|
|
@@ -193444,7 +193729,7 @@ var init_init = __esm({
|
|
|
193444
193729
|
const targetPath = path29.join(targetDir, isGlobal ? getInitConfigFilename() : getInitProjectConfigFilename());
|
|
193445
193730
|
const envPath = path29.join(targetDir, ".env");
|
|
193446
193731
|
v3.info(getInitScopeDescription(scope));
|
|
193447
|
-
if (
|
|
193732
|
+
if (existsSync17(targetPath)) {
|
|
193448
193733
|
const overwrite = await me({
|
|
193449
193734
|
message: `${targetPath} already exists. Overwrite it?`,
|
|
193450
193735
|
initialValue: false
|
|
@@ -193463,6 +193748,7 @@ var init_init = __esm({
|
|
|
193463
193748
|
{ value: "openrouter", label: "OpenRouter", hint: "multi-provider" },
|
|
193464
193749
|
{ value: "requesty", label: "Requesty", hint: "multi-provider" },
|
|
193465
193750
|
{ value: "apiroute", label: "API Route", hint: "multi-provider" },
|
|
193751
|
+
{ value: "cheaperinference", label: "Cheaper Inference", hint: "multi-provider" },
|
|
193466
193752
|
{ value: "atlascloud", label: "Atlas Cloud", hint: "DeepSeek V3.2" },
|
|
193467
193753
|
{ value: "custom", label: "Custom", hint: "OpenAI-compatible endpoint" }
|
|
193468
193754
|
]
|
|
@@ -193517,7 +193803,7 @@ var init_init = __esm({
|
|
|
193517
193803
|
];
|
|
193518
193804
|
if (llmProvider !== "none") {
|
|
193519
193805
|
envLines.push("# LLM API key");
|
|
193520
|
-
if (llmProvider === "openai" || llmProvider === "custom" || llmProvider === "atlascloud" || llmProvider === "apiroute") {
|
|
193806
|
+
if (llmProvider === "openai" || llmProvider === "custom" || llmProvider === "atlascloud" || llmProvider === "apiroute" || llmProvider === "cheaperinference") {
|
|
193521
193807
|
envLines.push("MEMORIX_LLM_API_KEY=sk-your-key-here");
|
|
193522
193808
|
} else if (llmProvider === "anthropic") {
|
|
193523
193809
|
envLines.push("MEMORIX_LLM_API_KEY=sk-ant-your-key-here");
|
|
@@ -193553,16 +193839,17 @@ var init_init = __esm({
|
|
|
193553
193839
|
envLines.push("# OPENROUTER_API_KEY=sk-or-...");
|
|
193554
193840
|
envLines.push("# REQUESTY_API_KEY=rqsty-...");
|
|
193555
193841
|
envLines.push("# API_ROUTE_API_KEY=sk-...");
|
|
193842
|
+
envLines.push("# CHEAPER_INFERENCE_API_KEY=ci_live_...");
|
|
193556
193843
|
envLines.push("");
|
|
193557
193844
|
mkdirSync3(targetDir, { recursive: true });
|
|
193558
193845
|
writeFileSync3(targetPath, tomlContent, "utf-8");
|
|
193559
193846
|
v3.success(`Created ${targetPath}`);
|
|
193560
193847
|
if (shouldOfferDotenv(scope)) {
|
|
193561
193848
|
const envExamplePath = getEnvTemplateTarget(targetDir, {
|
|
193562
|
-
hasDotenvExample:
|
|
193849
|
+
hasDotenvExample: existsSync17(path29.join(targetDir, ".env.example"))
|
|
193563
193850
|
});
|
|
193564
193851
|
const envContent = envLines.join("\n");
|
|
193565
|
-
if (
|
|
193852
|
+
if (existsSync17(envExamplePath)) {
|
|
193566
193853
|
const overwriteEnvTemplate = await me({
|
|
193567
193854
|
message: `${envExamplePath} already exists. Overwrite it?`,
|
|
193568
193855
|
initialValue: false
|
|
@@ -193574,7 +193861,7 @@ var init_init = __esm({
|
|
|
193574
193861
|
}
|
|
193575
193862
|
writeFileSync3(envExamplePath, envContent, "utf-8");
|
|
193576
193863
|
v3.success(`Created ${envExamplePath}`);
|
|
193577
|
-
const createEnv = !
|
|
193864
|
+
const createEnv = !existsSync17(envPath) ? await me({
|
|
193578
193865
|
message: `Create .env from ${path29.basename(envExamplePath)} now? (you can fill in keys later)`,
|
|
193579
193866
|
initialValue: true
|
|
193580
193867
|
}) : false;
|
|
@@ -197180,7 +197467,7 @@ __export(setup_exports, {
|
|
|
197180
197467
|
tryInstallCodexPlugin: () => tryInstallCodexPlugin
|
|
197181
197468
|
});
|
|
197182
197469
|
import { spawnSync } from "child_process";
|
|
197183
|
-
import { existsSync as
|
|
197470
|
+
import { existsSync as existsSync18 } from "fs";
|
|
197184
197471
|
import { copyFile as copyFile2, mkdir as mkdir6, readFile as readFile6, readdir as readdir3, rm as rm2, writeFile as writeFile7 } from "fs/promises";
|
|
197185
197472
|
import { homedir as homedir28 } from "os";
|
|
197186
197473
|
import path32 from "path";
|
|
@@ -197225,7 +197512,7 @@ function buildSetupPlan(options) {
|
|
|
197225
197512
|
function findPackageRoot(start = path32.dirname(fileURLToPath7(import.meta.url))) {
|
|
197226
197513
|
let dir = start;
|
|
197227
197514
|
for (let i4 = 0; i4 < 8; i4++) {
|
|
197228
|
-
if (
|
|
197515
|
+
if (existsSync18(path32.join(dir, "package.json")) && existsSync18(path32.join(dir, "plugins"))) {
|
|
197229
197516
|
return dir;
|
|
197230
197517
|
}
|
|
197231
197518
|
const parent = path32.dirname(dir);
|
|
@@ -197377,7 +197664,7 @@ async function rewriteBundledMemorixMcpToHttp(root) {
|
|
|
197377
197664
|
const candidates = [".mcp.json", "mcp_config.json", "gemini-extension.json"].map((name) => path32.join(root, name));
|
|
197378
197665
|
const rewritten = [];
|
|
197379
197666
|
for (const filePath of candidates) {
|
|
197380
|
-
if (!
|
|
197667
|
+
if (!existsSync18(filePath)) continue;
|
|
197381
197668
|
let doc;
|
|
197382
197669
|
try {
|
|
197383
197670
|
doc = JSON.parse(await readFile6(filePath, "utf-8"));
|
|
@@ -197542,8 +197829,8 @@ function isOwnedLegacyCodexHooks(content) {
|
|
|
197542
197829
|
async function removeOwnedLegacyCodexPluginFolder(homeDir) {
|
|
197543
197830
|
const canonicalPath2 = path32.join(homeDir, "plugins", "memorix");
|
|
197544
197831
|
const legacyPath = path32.join(homeDir, ".codex", "plugins", "memorix");
|
|
197545
|
-
if (!
|
|
197546
|
-
if (!
|
|
197832
|
+
if (!existsSync18(legacyPath)) return "missing";
|
|
197833
|
+
if (!existsSync18(canonicalPath2)) return "preserved";
|
|
197547
197834
|
try {
|
|
197548
197835
|
const manifest = JSON.parse(await readFile6(path32.join(legacyPath, ".codex-plugin", "plugin.json"), "utf-8"));
|
|
197549
197836
|
const repository = String(manifest.repository ?? "");
|
|
@@ -197759,7 +198046,7 @@ async function installCodeBuddyPluginPackage(options = {}) {
|
|
|
197759
198046
|
const home = options.homeDir ?? homedir28();
|
|
197760
198047
|
const packageRoot2 = findPackageRoot();
|
|
197761
198048
|
const source = path32.join(packageRoot2, "plugins", "codebuddy", "memorix");
|
|
197762
|
-
if (!
|
|
198049
|
+
if (!existsSync18(source)) throw new Error(`CodeBuddy plugin template not found: ${source}`);
|
|
197763
198050
|
const marketplaceRoot = path32.join(home, ".codebuddy", "memorix-local");
|
|
197764
198051
|
const marketplacePath = path32.join(marketplaceRoot, ".codebuddy-plugin", "marketplace.json");
|
|
197765
198052
|
const pluginPath = path32.join(marketplaceRoot, "plugins", "memorix");
|
|
@@ -197780,7 +198067,7 @@ async function installPluginPackage(options) {
|
|
|
197780
198067
|
const packageRoot2 = findPackageRoot();
|
|
197781
198068
|
const source = path32.join(packageRoot2, "plugins", options.agent, "memorix");
|
|
197782
198069
|
const includeHooks = options.includeHooks ?? true;
|
|
197783
|
-
if (!
|
|
198070
|
+
if (!existsSync18(source)) {
|
|
197784
198071
|
throw new Error(`Plugin package template not found: ${source}`);
|
|
197785
198072
|
}
|
|
197786
198073
|
if (options.agent === "codex") {
|
|
@@ -197828,7 +198115,7 @@ async function installGeminiExtensionPackage(options = {}) {
|
|
|
197828
198115
|
const home = options.homeDir ?? homedir28();
|
|
197829
198116
|
const packageRoot2 = findPackageRoot();
|
|
197830
198117
|
const source = path32.join(packageRoot2, "plugins", "gemini", "memorix");
|
|
197831
|
-
if (!
|
|
198118
|
+
if (!existsSync18(source)) {
|
|
197832
198119
|
throw new Error(`Gemini extension template not found: ${source}`);
|
|
197833
198120
|
}
|
|
197834
198121
|
const extensionPath = path32.join(home, ".gemini", "extensions", "memorix");
|
|
@@ -197842,7 +198129,7 @@ async function installGeminiExtensionPackage(options = {}) {
|
|
|
197842
198129
|
async function installAntigravityPluginPackage(options = {}) {
|
|
197843
198130
|
const packageRoot2 = findPackageRoot();
|
|
197844
198131
|
const source = path32.join(packageRoot2, "plugins", "antigravity", "memorix");
|
|
197845
|
-
if (!
|
|
198132
|
+
if (!existsSync18(source)) {
|
|
197846
198133
|
throw new Error(`Antigravity plugin template not found: ${source}`);
|
|
197847
198134
|
}
|
|
197848
198135
|
const pluginPath = options.global === false ? path32.join(options.projectRoot ?? process.cwd(), ".agents", "plugins", "memorix") : path32.join(options.homeDir ?? homedir28(), ".gemini", "config", "plugins", "memorix");
|
|
@@ -197860,7 +198147,7 @@ async function installAntigravityPluginPackage(options = {}) {
|
|
|
197860
198147
|
async function installPiPackage(options = {}) {
|
|
197861
198148
|
const packageRoot2 = findPackageRoot();
|
|
197862
198149
|
const source = path32.join(packageRoot2, "plugins", "pi", "memorix");
|
|
197863
|
-
if (!
|
|
198150
|
+
if (!existsSync18(source)) {
|
|
197864
198151
|
throw new Error(`Pi package template not found: ${source}`);
|
|
197865
198152
|
}
|
|
197866
198153
|
const defaultRoot = options.global ? path32.join(options.homeDir ?? homedir28(), ".pi", "agent", "packages") : path32.join(process.cwd(), ".pi", "packages");
|
|
@@ -197878,7 +198165,7 @@ async function installOpenClawBundlePackage(options = {}) {
|
|
|
197878
198165
|
const home = options.homeDir ?? homedir28();
|
|
197879
198166
|
const packageRoot2 = findPackageRoot();
|
|
197880
198167
|
const source = path32.join(packageRoot2, "plugins", "openclaw", "memorix");
|
|
197881
|
-
if (!
|
|
198168
|
+
if (!existsSync18(source)) {
|
|
197882
198169
|
throw new Error(`OpenClaw bundle template not found: ${source}`);
|
|
197883
198170
|
}
|
|
197884
198171
|
const bundlePath = path32.join(home, ".openclaw", "extensions", "memorix");
|
|
@@ -197894,7 +198181,7 @@ async function installOpenClawBundlePackage(options = {}) {
|
|
|
197894
198181
|
async function installHermesPluginPackage(options = {}) {
|
|
197895
198182
|
const packageRoot2 = findPackageRoot();
|
|
197896
198183
|
const source = path32.join(packageRoot2, "plugins", "hermes", "memorix");
|
|
197897
|
-
if (!
|
|
198184
|
+
if (!existsSync18(source)) {
|
|
197898
198185
|
throw new Error(`Hermes plugin template not found: ${source}`);
|
|
197899
198186
|
}
|
|
197900
198187
|
const hermesHome = resolveHermesHome(options.homeDir);
|
|
@@ -197921,7 +198208,7 @@ async function installHermesPluginPackage(options = {}) {
|
|
|
197921
198208
|
async function installOmpPackage(options = {}) {
|
|
197922
198209
|
const packageRoot2 = findPackageRoot();
|
|
197923
198210
|
const source = path32.join(packageRoot2, "plugins", "omp", "memorix");
|
|
197924
|
-
if (!
|
|
198211
|
+
if (!existsSync18(source)) {
|
|
197925
198212
|
throw new Error(`Oh-my-Pi package template not found: ${source}`);
|
|
197926
198213
|
}
|
|
197927
198214
|
const defaultRoot = options.global ? path32.join(options.homeDir ?? homedir28(), ".omp", "agent", "packages") : path32.join(process.cwd(), ".omp", "packages");
|
|
@@ -198148,7 +198435,7 @@ ${hook.stdout || ""}`.toLowerCase();
|
|
|
198148
198435
|
function resolveHermesCommand(hermesHome) {
|
|
198149
198436
|
if (process.platform === "win32") {
|
|
198150
198437
|
const localHermes = path32.join(hermesHome, "hermes-agent", "venv", "Scripts", "hermes.exe");
|
|
198151
|
-
if (
|
|
198438
|
+
if (existsSync18(localHermes)) return localHermes;
|
|
198152
198439
|
}
|
|
198153
198440
|
return "hermes";
|
|
198154
198441
|
}
|
|
@@ -199787,6 +200074,10 @@ async function buildTaskWorkset(input) {
|
|
|
199787
200074
|
budget: { maxTokens }
|
|
199788
200075
|
});
|
|
199789
200076
|
const omittedReceipt = receiptOmissions(rendered.omittedItems, base.hiddenCautionMemoryCount);
|
|
200077
|
+
const derivedViews = {
|
|
200078
|
+
...getSearchDerivedViews(),
|
|
200079
|
+
...input.retrieval?.derivedViews ?? {}
|
|
200080
|
+
};
|
|
199790
200081
|
const retrieval = {
|
|
199791
200082
|
mode: input.retrieval?.mode ?? (input.semanticCode ? "hybrid" : "unknown"),
|
|
199792
200083
|
...input.retrieval?.codeProvider || input.providerQuality?.selected ? { codeProvider: input.retrieval?.codeProvider ?? input.providerQuality?.selected } : {},
|
|
@@ -199794,7 +200085,8 @@ async function buildTaskWorkset(input) {
|
|
|
199794
200085
|
...input.retrieval?.fallbackReason ? { fallbackReason: input.retrieval.fallbackReason } : {},
|
|
199795
200086
|
candidateCount: governed.plan.decisions.length,
|
|
199796
200087
|
selectedCount: rendered.selected.length,
|
|
199797
|
-
omittedCount: omittedReceipt.reduce((total, omission) => total + omission.count, 0)
|
|
200088
|
+
omittedCount: omittedReceipt.reduce((total, omission) => total + omission.count, 0),
|
|
200089
|
+
derivedViews
|
|
199798
200090
|
};
|
|
199799
200091
|
const receipt = {
|
|
199800
200092
|
version: "1.3",
|
|
@@ -199853,6 +200145,7 @@ var init_workset = __esm({
|
|
|
199853
200145
|
init_workflows2();
|
|
199854
200146
|
init_long_term();
|
|
199855
200147
|
init_governor();
|
|
200148
|
+
init_orama_store();
|
|
199856
200149
|
CONTINUATION_DETAIL_TOKEN_BUDGET = 20;
|
|
199857
200150
|
}
|
|
199858
200151
|
});
|
|
@@ -199864,11 +200157,11 @@ __export(current_facts_exports, {
|
|
|
199864
200157
|
formatGitFact: () => formatGitFact
|
|
199865
200158
|
});
|
|
199866
200159
|
import { execFileSync } from "child_process";
|
|
199867
|
-
import { existsSync as
|
|
200160
|
+
import { existsSync as existsSync19, readFileSync as readFileSync11 } from "fs";
|
|
199868
200161
|
import path33 from "path";
|
|
199869
200162
|
function readTextIfExists(filePath) {
|
|
199870
200163
|
try {
|
|
199871
|
-
if (!
|
|
200164
|
+
if (!existsSync19(filePath)) return null;
|
|
199872
200165
|
return readFileSync11(filePath, "utf8");
|
|
199873
200166
|
} catch {
|
|
199874
200167
|
return null;
|
|
@@ -200159,7 +200452,7 @@ __export(external_provider_exports, {
|
|
|
200159
200452
|
runExternalCodeGraphLifecycle: () => runExternalCodeGraphLifecycle
|
|
200160
200453
|
});
|
|
200161
200454
|
import { spawn as spawn5 } from "child_process";
|
|
200162
|
-
import { existsSync as
|
|
200455
|
+
import { existsSync as existsSync20, readFileSync as readFileSync12 } from "fs";
|
|
200163
200456
|
import { delimiter, dirname as dirname5, extname, isAbsolute as isAbsolute4, join as join25, relative as relative4, resolve as resolve6, sep as sep2 } from "path";
|
|
200164
200457
|
function boundedTimeout(value) {
|
|
200165
200458
|
if (!Number.isFinite(value)) return DEFAULT_EXTERNAL_CODEGRAPH_TIMEOUT_MS;
|
|
@@ -200196,13 +200489,13 @@ function resolveCommandCandidates(command) {
|
|
|
200196
200489
|
}
|
|
200197
200490
|
function resolveLaunch(command) {
|
|
200198
200491
|
for (const candidate2 of resolveCommandCandidates(command)) {
|
|
200199
|
-
if (!
|
|
200492
|
+
if (!existsSync20(candidate2)) continue;
|
|
200200
200493
|
const extension3 = extname(candidate2).toLowerCase();
|
|
200201
200494
|
if (extension3 === ".cmd") {
|
|
200202
200495
|
const bundleRoot = resolve6(dirname5(candidate2), "..");
|
|
200203
200496
|
const node = join25(bundleRoot, "node.exe");
|
|
200204
200497
|
const entry = join25(bundleRoot, "lib", "dist", "bin", "codegraph.js");
|
|
200205
|
-
if (
|
|
200498
|
+
if (existsSync20(node) && existsSync20(entry)) {
|
|
200206
200499
|
return { executable: node, prefixArgs: ["--liftoff-only", entry] };
|
|
200207
200500
|
}
|
|
200208
200501
|
try {
|
|
@@ -200211,7 +200504,7 @@ function resolveLaunch(command) {
|
|
|
200211
200504
|
if (match2?.[1]) {
|
|
200212
200505
|
const base = dirname5(candidate2).endsWith(sep2) ? dirname5(candidate2) : dirname5(candidate2) + sep2;
|
|
200213
200506
|
const entry2 = resolve6(match2[1].replace(/%(?:~)?dp0%?/gi, base));
|
|
200214
|
-
if (
|
|
200507
|
+
if (existsSync20(entry2)) return { executable: process.execPath, prefixArgs: [entry2] };
|
|
200215
200508
|
}
|
|
200216
200509
|
} catch {
|
|
200217
200510
|
}
|
|
@@ -200359,7 +200652,7 @@ async function inspectExternalCodeGraph(input) {
|
|
|
200359
200652
|
const health2 = { state: "disabled", reason: "External CodeGraph is disabled by configuration." };
|
|
200360
200653
|
return { health: health2, quality: providerQuality({ mode, health: health2 }) };
|
|
200361
200654
|
}
|
|
200362
|
-
if (!
|
|
200655
|
+
if (!existsSync20(join25(input.projectRoot, ".codegraph"))) {
|
|
200363
200656
|
const health2 = { state: "not-detected", reason: "No local .codegraph index is present for this project." };
|
|
200364
200657
|
return { health: health2, quality: providerQuality({ mode, health: health2 }) };
|
|
200365
200658
|
}
|
|
@@ -200395,7 +200688,7 @@ async function runExternalCodeGraphLifecycle(input) {
|
|
|
200395
200688
|
};
|
|
200396
200689
|
}
|
|
200397
200690
|
const indexPath = join25(input.projectRoot, ".codegraph");
|
|
200398
|
-
if (input.action === "sync" && !
|
|
200691
|
+
if (input.action === "sync" && !existsSync20(indexPath)) {
|
|
200399
200692
|
const health = { state: "not-detected", reason: "No local .codegraph index is present for this project." };
|
|
200400
200693
|
return {
|
|
200401
200694
|
action: input.action,
|
|
@@ -200405,7 +200698,7 @@ async function runExternalCodeGraphLifecycle(input) {
|
|
|
200405
200698
|
quality: providerQuality({ mode, health })
|
|
200406
200699
|
};
|
|
200407
200700
|
}
|
|
200408
|
-
if (input.action === "init" &&
|
|
200701
|
+
if (input.action === "init" && existsSync20(indexPath)) {
|
|
200409
200702
|
const inspected2 = await inspectExternalCodeGraph(input);
|
|
200410
200703
|
return {
|
|
200411
200704
|
action: input.action,
|
|
@@ -202165,6 +202458,61 @@ var init_session = __esm({
|
|
|
202165
202458
|
}
|
|
202166
202459
|
});
|
|
202167
202460
|
|
|
202461
|
+
// src/knowledge/context-receipt.ts
|
|
202462
|
+
var context_receipt_exports = {};
|
|
202463
|
+
__export(context_receipt_exports, {
|
|
202464
|
+
buildBoundedContextReceipt: () => buildBoundedContextReceipt,
|
|
202465
|
+
buildCodeGraphDerivedView: () => buildCodeGraphDerivedView
|
|
202466
|
+
});
|
|
202467
|
+
function buildCodeGraphDerivedView(input) {
|
|
202468
|
+
const provider2 = input.providerQuality;
|
|
202469
|
+
const snapshot = input.snapshot;
|
|
202470
|
+
const externalFailure = provider2?.external.state !== void 0 && !["ready", "disabled", "not-detected"].includes(provider2.external.state);
|
|
202471
|
+
if (snapshot?.id) {
|
|
202472
|
+
return {
|
|
202473
|
+
...snapshot.sourceEpoch !== void 0 ? { generation: snapshot.sourceEpoch } : {},
|
|
202474
|
+
freshness: snapshot.incomplete ? "stale" : "current",
|
|
202475
|
+
rebuildStatus: snapshot.incomplete ? "failed" : "idle",
|
|
202476
|
+
...snapshot.incomplete ? { failureReason: "latest CodeGraph snapshot is incomplete" } : externalFailure && provider2?.external.reason ? { failureReason: sanitizeDerivedViewFailureReason(provider2.external.reason) } : {}
|
|
202477
|
+
};
|
|
202478
|
+
}
|
|
202479
|
+
return {
|
|
202480
|
+
freshness: "unknown",
|
|
202481
|
+
rebuildStatus: externalFailure ? "failed" : "unavailable",
|
|
202482
|
+
...provider2?.external.reason ? { failureReason: sanitizeDerivedViewFailureReason(provider2.external.reason) } : { failureReason: "CodeGraph snapshot is not initialized" }
|
|
202483
|
+
};
|
|
202484
|
+
}
|
|
202485
|
+
function buildBoundedContextReceipt(input) {
|
|
202486
|
+
const provider2 = input.providerQuality ?? input.workset.provenance.codeProvider;
|
|
202487
|
+
return {
|
|
202488
|
+
schemaVersion: "1",
|
|
202489
|
+
task: input.workset.task,
|
|
202490
|
+
brief: input.workset.prompt,
|
|
202491
|
+
receipt: input.workset.receipt,
|
|
202492
|
+
code: {
|
|
202493
|
+
selected: provider2?.selected ?? "lite",
|
|
202494
|
+
quality: provider2?.selectedQuality ?? "heuristic",
|
|
202495
|
+
externalState: provider2?.external.state ?? "not-detected",
|
|
202496
|
+
...input.workset.provenance.snapshotId ? { snapshotId: input.workset.provenance.snapshotId } : {}
|
|
202497
|
+
},
|
|
202498
|
+
...input.workset.agentLoadout ? { loadout: input.workset.agentLoadout } : {},
|
|
202499
|
+
...input.workset.continuity ? {
|
|
202500
|
+
continuity: {
|
|
202501
|
+
taskId: input.workset.continuity.taskId,
|
|
202502
|
+
status: input.workset.continuity.status,
|
|
202503
|
+
outcome: input.workset.continuity.outcome
|
|
202504
|
+
}
|
|
202505
|
+
} : {}
|
|
202506
|
+
};
|
|
202507
|
+
}
|
|
202508
|
+
var init_context_receipt = __esm({
|
|
202509
|
+
"src/knowledge/context-receipt.ts"() {
|
|
202510
|
+
"use strict";
|
|
202511
|
+
init_esm_shims();
|
|
202512
|
+
init_derived_view_receipt();
|
|
202513
|
+
}
|
|
202514
|
+
});
|
|
202515
|
+
|
|
202168
202516
|
// src/store/compaction-checkpoint-store.ts
|
|
202169
202517
|
var compaction_checkpoint_store_exports = {};
|
|
202170
202518
|
__export(compaction_checkpoint_store_exports, {
|
|
@@ -202778,7 +203126,7 @@ __export(auto_context_exports, {
|
|
|
202778
203126
|
formatAutoProjectContextSummary: () => formatAutoProjectContextSummary,
|
|
202779
203127
|
formatLegacyAutoProjectContextPrompt: () => formatLegacyAutoProjectContextPrompt
|
|
202780
203128
|
});
|
|
202781
|
-
import { existsSync as
|
|
203129
|
+
import { existsSync as existsSync21, statSync as statSync6 } from "fs";
|
|
202782
203130
|
import path35 from "path";
|
|
202783
203131
|
function activeProjectObservations(observations2, projectId) {
|
|
202784
203132
|
return observations2.filter((obs) => obs.projectId === projectId && (obs.status ?? "active") === "active");
|
|
@@ -203054,7 +203402,19 @@ async function buildAutoProjectContext(input) {
|
|
|
203054
203402
|
retrieval: {
|
|
203055
203403
|
mode: semanticOutline ? "hybrid" : "lexical",
|
|
203056
203404
|
codeProvider: providerQuality2.selected,
|
|
203057
|
-
...externalCaution ? { fallbackReason: externalCaution } : {}
|
|
203405
|
+
...externalCaution ? { fallbackReason: externalCaution } : {},
|
|
203406
|
+
derivedViews: {
|
|
203407
|
+
graph: buildCodeGraphDerivedView({
|
|
203408
|
+
providerQuality: providerQuality2,
|
|
203409
|
+
...latestSnapshot ? {
|
|
203410
|
+
snapshot: {
|
|
203411
|
+
id: latestSnapshot.id,
|
|
203412
|
+
sourceEpoch: latestSnapshot.sourceEpoch,
|
|
203413
|
+
incomplete: latestSnapshot.completeness.skippedOversizedFiles > 0 || (latestSnapshot.completeness.unreadableFiles ?? 0) > 0 || latestSnapshot.completeness.removalScanDeferred
|
|
203414
|
+
}
|
|
203415
|
+
} : {}
|
|
203416
|
+
})
|
|
203417
|
+
}
|
|
203058
203418
|
},
|
|
203059
203419
|
currentFacts: worksetFactLines(currentFacts),
|
|
203060
203420
|
...continuation ? { continuation } : {},
|
|
@@ -203141,7 +203501,7 @@ function existingLensCandidates(rootPath, lens) {
|
|
|
203141
203501
|
for (const candidate2 of lensPathCandidates(lens)) {
|
|
203142
203502
|
const absolute = path35.join(rootPath, candidate2);
|
|
203143
203503
|
try {
|
|
203144
|
-
if (!
|
|
203504
|
+
if (!existsSync21(absolute)) continue;
|
|
203145
203505
|
const stat6 = statSync6(absolute);
|
|
203146
203506
|
if (stat6.isFile()) out.push(candidate2);
|
|
203147
203507
|
if (stat6.isDirectory()) out.push(candidate2.replace(/\\/g, "/"));
|
|
@@ -203384,47 +203744,13 @@ var init_auto_context = __esm({
|
|
|
203384
203744
|
init_long_term();
|
|
203385
203745
|
init_visibility();
|
|
203386
203746
|
init_session_store();
|
|
203747
|
+
init_context_receipt();
|
|
203387
203748
|
init_task_lens();
|
|
203388
203749
|
DEFAULT_MAX_AGE_MS = 10 * 60 * 1e3;
|
|
203389
203750
|
COMPACT_CHECKPOINT_MAX_AGE_MS = 24 * 60 * 60 * 1e3;
|
|
203390
203751
|
}
|
|
203391
203752
|
});
|
|
203392
203753
|
|
|
203393
|
-
// src/knowledge/context-receipt.ts
|
|
203394
|
-
var context_receipt_exports = {};
|
|
203395
|
-
__export(context_receipt_exports, {
|
|
203396
|
-
buildBoundedContextReceipt: () => buildBoundedContextReceipt
|
|
203397
|
-
});
|
|
203398
|
-
function buildBoundedContextReceipt(input) {
|
|
203399
|
-
const provider2 = input.providerQuality ?? input.workset.provenance.codeProvider;
|
|
203400
|
-
return {
|
|
203401
|
-
schemaVersion: "1",
|
|
203402
|
-
task: input.workset.task,
|
|
203403
|
-
brief: input.workset.prompt,
|
|
203404
|
-
receipt: input.workset.receipt,
|
|
203405
|
-
code: {
|
|
203406
|
-
selected: provider2?.selected ?? "lite",
|
|
203407
|
-
quality: provider2?.selectedQuality ?? "heuristic",
|
|
203408
|
-
externalState: provider2?.external.state ?? "not-detected",
|
|
203409
|
-
...input.workset.provenance.snapshotId ? { snapshotId: input.workset.provenance.snapshotId } : {}
|
|
203410
|
-
},
|
|
203411
|
-
...input.workset.agentLoadout ? { loadout: input.workset.agentLoadout } : {},
|
|
203412
|
-
...input.workset.continuity ? {
|
|
203413
|
-
continuity: {
|
|
203414
|
-
taskId: input.workset.continuity.taskId,
|
|
203415
|
-
status: input.workset.continuity.status,
|
|
203416
|
-
outcome: input.workset.continuity.outcome
|
|
203417
|
-
}
|
|
203418
|
-
} : {}
|
|
203419
|
-
};
|
|
203420
|
-
}
|
|
203421
|
-
var init_context_receipt = __esm({
|
|
203422
|
-
"src/knowledge/context-receipt.ts"() {
|
|
203423
|
-
"use strict";
|
|
203424
|
-
init_esm_shims();
|
|
203425
|
-
}
|
|
203426
|
-
});
|
|
203427
|
-
|
|
203428
203754
|
// src/cli/fallback-budget.ts
|
|
203429
203755
|
import { createHash as createHash18 } from "crypto";
|
|
203430
203756
|
function fallbackRequestKey(projectId, task) {
|
|
@@ -203649,6 +203975,15 @@ function formatContextReceipt(receipt) {
|
|
|
203649
203975
|
if (receipt.retrieval.fallbackUsed) {
|
|
203650
203976
|
lines.push(`- Fallback: ${receipt.retrieval.fallbackReason ?? "retrieval fallback used"}`);
|
|
203651
203977
|
}
|
|
203978
|
+
if (receipt.retrieval.derivedViews) {
|
|
203979
|
+
lines.push("", "Derived views");
|
|
203980
|
+
for (const [name, view] of Object.entries(receipt.retrieval.derivedViews)) {
|
|
203981
|
+
if (!view) continue;
|
|
203982
|
+
const generation = view.generation === void 0 ? "" : `, generation=${view.generation}`;
|
|
203983
|
+
const reason = view.failureReason ? `, reason=${view.failureReason}` : "";
|
|
203984
|
+
lines.push(`- ${name}: ${view.freshness}/${view.rebuildStatus}${generation}${reason}`);
|
|
203985
|
+
}
|
|
203986
|
+
}
|
|
203652
203987
|
if (receipt.selected.length > 0) {
|
|
203653
203988
|
lines.push("", "Selected evidence");
|
|
203654
203989
|
for (const item of receipt.selected.slice(0, 20)) {
|
|
@@ -203918,7 +204253,19 @@ async function attachTaskWorkset(input) {
|
|
|
203918
204253
|
...input.providerQuality ? { providerQuality: input.providerQuality } : {},
|
|
203919
204254
|
retrieval: {
|
|
203920
204255
|
mode: semanticCode ? "hybrid" : "unknown",
|
|
203921
|
-
...input.providerQuality?.selected ? { codeProvider: input.providerQuality.selected } : {}
|
|
204256
|
+
...input.providerQuality?.selected ? { codeProvider: input.providerQuality.selected } : {},
|
|
204257
|
+
derivedViews: {
|
|
204258
|
+
graph: buildCodeGraphDerivedView({
|
|
204259
|
+
providerQuality: input.providerQuality,
|
|
204260
|
+
...input.snapshot ? {
|
|
204261
|
+
snapshot: {
|
|
204262
|
+
id: input.snapshot.id,
|
|
204263
|
+
sourceEpoch: input.snapshot.sourceEpoch,
|
|
204264
|
+
incomplete: input.snapshot.incomplete
|
|
204265
|
+
}
|
|
204266
|
+
} : {}
|
|
204267
|
+
})
|
|
204268
|
+
}
|
|
203922
204269
|
},
|
|
203923
204270
|
reliableMemory: input.pack.memories.filter((memory) => memory.status === "current").map((memory) => ({
|
|
203924
204271
|
id: memory.id,
|
|
@@ -203990,6 +204337,7 @@ var init_context_pack = __esm({
|
|
|
203990
204337
|
"use strict";
|
|
203991
204338
|
init_esm_shims();
|
|
203992
204339
|
init_freshness2();
|
|
204340
|
+
init_context_receipt();
|
|
203993
204341
|
init_workset();
|
|
203994
204342
|
init_exclude3();
|
|
203995
204343
|
init_semantic_context();
|
|
@@ -206952,7 +207300,7 @@ var engine_exports2 = {};
|
|
|
206952
207300
|
__export(engine_exports2, {
|
|
206953
207301
|
SkillsEngine: () => SkillsEngine
|
|
206954
207302
|
});
|
|
206955
|
-
import { existsSync as
|
|
207303
|
+
import { existsSync as existsSync22, readFileSync as readFileSync13, writeFileSync as writeFileSync5, mkdirSync as mkdirSync5, readdirSync as readdirSync3 } from "fs";
|
|
206956
207304
|
import { join as join26 } from "path";
|
|
206957
207305
|
import { homedir as homedir32 } from "os";
|
|
206958
207306
|
var SKILLS_DIRS, SKILL_WORTHY_TYPES, MIN_OBS_FOR_SKILL, MIN_SCORE_FOR_SKILL, LOW_SIGNAL_TITLE_PATTERNS, LOW_SIGNAL_ENTITY_PATTERNS, COMMAND_TRACE_PATTERNS2, SkillsEngine;
|
|
@@ -207033,7 +207381,7 @@ var init_engine4 = __esm({
|
|
|
207033
207381
|
paths.push(join26(home, dir));
|
|
207034
207382
|
}
|
|
207035
207383
|
for (const skillsRoot of paths) {
|
|
207036
|
-
if (!
|
|
207384
|
+
if (!existsSync22(skillsRoot)) continue;
|
|
207037
207385
|
try {
|
|
207038
207386
|
const entries = readdirSync3(skillsRoot, { withFileTypes: true });
|
|
207039
207387
|
for (const entry of entries) {
|
|
@@ -207041,7 +207389,7 @@ var init_engine4 = __esm({
|
|
|
207041
207389
|
const name = entry.name;
|
|
207042
207390
|
if (seen.has(name)) continue;
|
|
207043
207391
|
const skillMd = join26(skillsRoot, name, "SKILL.md");
|
|
207044
|
-
if (!
|
|
207392
|
+
if (!existsSync22(skillMd)) continue;
|
|
207045
207393
|
try {
|
|
207046
207394
|
const content = readFileSync13(skillMd, "utf-8");
|
|
207047
207395
|
const description = this.parseDescription(content);
|
|
@@ -208263,7 +208611,7 @@ var init_task_graph = __esm({
|
|
|
208263
208611
|
|
|
208264
208612
|
// src/orchestrate/context-collector.ts
|
|
208265
208613
|
import { execFileSync as execFileSync2 } from "child_process";
|
|
208266
|
-
import { readFileSync as readFileSync14, existsSync as
|
|
208614
|
+
import { readFileSync as readFileSync14, existsSync as existsSync23 } from "fs";
|
|
208267
208615
|
import { join as join27 } from "path";
|
|
208268
208616
|
function normalizeEntryLimit(value, fallback) {
|
|
208269
208617
|
if (!Number.isSafeInteger(value) || value < 1) return fallback;
|
|
@@ -208340,7 +208688,7 @@ function collectFileTree(projectDir2, maxEntries) {
|
|
|
208340
208688
|
function collectDependencies(projectDir2) {
|
|
208341
208689
|
try {
|
|
208342
208690
|
const pkgPath = join27(projectDir2, "package.json");
|
|
208343
|
-
if (!
|
|
208691
|
+
if (!existsSync23(pkgPath)) return "";
|
|
208344
208692
|
const pkg = JSON.parse(readFileSync14(pkgPath, "utf-8"));
|
|
208345
208693
|
const parts = [];
|
|
208346
208694
|
if (pkg.dependencies && Object.keys(pkg.dependencies).length > 0) {
|
|
@@ -209390,7 +209738,7 @@ __export(receipt_service_exports, {
|
|
|
209390
209738
|
formatHandoffReceipt: () => formatHandoffReceipt
|
|
209391
209739
|
});
|
|
209392
209740
|
import { createHash as createHash19 } from "crypto";
|
|
209393
|
-
import { existsSync as
|
|
209741
|
+
import { existsSync as existsSync24, readFileSync as readFileSync15 } from "fs";
|
|
209394
209742
|
import path37 from "path";
|
|
209395
209743
|
function sha256(value) {
|
|
209396
209744
|
return `sha256:${createHash19("sha256").update(value).digest("hex")}`;
|
|
@@ -209421,7 +209769,7 @@ function safeJsonArray(value) {
|
|
|
209421
209769
|
}
|
|
209422
209770
|
async function loadReceiptObservations(dataDir, projectId) {
|
|
209423
209771
|
const dbPath = path37.join(dataDir, "memorix.db");
|
|
209424
|
-
if (
|
|
209772
|
+
if (existsSync24(dbPath)) {
|
|
209425
209773
|
try {
|
|
209426
209774
|
const DB = loadBetterSqlite3();
|
|
209427
209775
|
const db2 = new DB(dbPath, { readonly: true, fileMustExist: true });
|
|
@@ -209438,7 +209786,7 @@ async function loadReceiptObservations(dataDir, projectId) {
|
|
|
209438
209786
|
}
|
|
209439
209787
|
}
|
|
209440
209788
|
const jsonPath = path37.join(dataDir, "observations.json");
|
|
209441
|
-
if (!
|
|
209789
|
+
if (!existsSync24(jsonPath)) return [];
|
|
209442
209790
|
try {
|
|
209443
209791
|
const parsed = JSON.parse(readFileSync15(jsonPath, "utf-8"));
|
|
209444
209792
|
if (!Array.isArray(parsed)) return [];
|
|
@@ -209677,7 +210025,7 @@ var init_tool_profile = __esm({
|
|
|
209677
210025
|
function getMcpServerInfo() {
|
|
209678
210026
|
return {
|
|
209679
210027
|
name: "memorix",
|
|
209680
|
-
version: true ? "1.10.
|
|
210028
|
+
version: true ? "1.10.2" : "1.0.1"
|
|
209681
210029
|
};
|
|
209682
210030
|
}
|
|
209683
210031
|
function createMcpDiscoverResult(capabilities, serverInfo) {
|
|
@@ -223722,7 +224070,7 @@ var init_sanitizer = __esm({
|
|
|
223722
224070
|
});
|
|
223723
224071
|
|
|
223724
224072
|
// src/workspace/applier.ts
|
|
223725
|
-
import { existsSync as
|
|
224073
|
+
import { existsSync as existsSync25, mkdirSync as mkdirSync6, copyFileSync, writeFileSync as writeFileSync6, unlinkSync as unlinkSync2, renameSync } from "fs";
|
|
223726
224074
|
import { dirname as dirname6 } from "path";
|
|
223727
224075
|
var WorkspaceSyncApplier;
|
|
223728
224076
|
var init_applier = __esm({
|
|
@@ -223753,7 +224101,7 @@ var init_applier = __esm({
|
|
|
223753
224101
|
for (const file2 of files) {
|
|
223754
224102
|
try {
|
|
223755
224103
|
const dir = dirname6(file2.filePath);
|
|
223756
|
-
if (!
|
|
224104
|
+
if (!existsSync25(dir)) {
|
|
223757
224105
|
mkdirSync6(dir, { recursive: true });
|
|
223758
224106
|
}
|
|
223759
224107
|
} catch (err) {
|
|
@@ -223762,7 +224110,7 @@ var init_applier = __esm({
|
|
|
223762
224110
|
}
|
|
223763
224111
|
}
|
|
223764
224112
|
for (const file2 of files) {
|
|
223765
|
-
if (
|
|
224113
|
+
if (existsSync25(file2.filePath)) {
|
|
223766
224114
|
try {
|
|
223767
224115
|
const backupPath = file2.filePath + `.backup-${Date.now()}`;
|
|
223768
224116
|
copyFileSync(file2.filePath, backupPath);
|
|
@@ -223813,7 +224161,7 @@ var init_applier = __esm({
|
|
|
223813
224161
|
cleanBackups(backups) {
|
|
223814
224162
|
for (const backup of backups) {
|
|
223815
224163
|
try {
|
|
223816
|
-
if (
|
|
224164
|
+
if (existsSync25(backup.backupPath)) {
|
|
223817
224165
|
unlinkSync2(backup.backupPath);
|
|
223818
224166
|
}
|
|
223819
224167
|
} catch {
|
|
@@ -223829,7 +224177,7 @@ var engine_exports3 = {};
|
|
|
223829
224177
|
__export(engine_exports3, {
|
|
223830
224178
|
WorkspaceSyncEngine: () => WorkspaceSyncEngine
|
|
223831
224179
|
});
|
|
223832
|
-
import { readFileSync as readFileSync16, readdirSync as readdirSync4, existsSync as
|
|
224180
|
+
import { readFileSync as readFileSync16, readdirSync as readdirSync4, existsSync as existsSync26, cpSync, mkdirSync as mkdirSync7 } from "fs";
|
|
223833
224181
|
import { join as join29 } from "path";
|
|
223834
224182
|
import { homedir as homedir33 } from "os";
|
|
223835
224183
|
var WorkspaceSyncEngine;
|
|
@@ -223909,7 +224257,7 @@ var init_engine5 = __esm({
|
|
|
223909
224257
|
}
|
|
223910
224258
|
const merged = /* @__PURE__ */ new Map();
|
|
223911
224259
|
for (const path50 of pathsToCheck) {
|
|
223912
|
-
if (
|
|
224260
|
+
if (existsSync26(path50)) {
|
|
223913
224261
|
try {
|
|
223914
224262
|
const content = readFileSync16(path50, "utf-8");
|
|
223915
224263
|
const servers = adapter.parse(content);
|
|
@@ -223963,7 +224311,7 @@ var init_engine5 = __esm({
|
|
|
223963
224311
|
const adapter = this.adapters.get(target);
|
|
223964
224312
|
const configPath = adapter.getConfigPath(this.projectRoot);
|
|
223965
224313
|
let configContent;
|
|
223966
|
-
if (target === "antigravity" &&
|
|
224314
|
+
if (target === "antigravity" && existsSync26(configPath)) {
|
|
223967
224315
|
try {
|
|
223968
224316
|
const existing = JSON.parse(readFileSync16(configPath, "utf-8"));
|
|
223969
224317
|
const generated = JSON.parse(adapter.generate(result.mcpServers.scanned));
|
|
@@ -224039,13 +224387,13 @@ var init_engine5 = __esm({
|
|
|
224039
224387
|
join29(home, dir)
|
|
224040
224388
|
];
|
|
224041
224389
|
for (const skillsRoot of paths) {
|
|
224042
|
-
if (!
|
|
224390
|
+
if (!existsSync26(skillsRoot)) continue;
|
|
224043
224391
|
try {
|
|
224044
224392
|
const entries = readdirSync4(skillsRoot, { withFileTypes: true });
|
|
224045
224393
|
for (const entry of entries) {
|
|
224046
224394
|
if (!entry.isDirectory()) continue;
|
|
224047
224395
|
const skillMd = join29(skillsRoot, entry.name, "SKILL.md");
|
|
224048
|
-
if (!
|
|
224396
|
+
if (!existsSync26(skillMd)) continue;
|
|
224049
224397
|
let description = "";
|
|
224050
224398
|
try {
|
|
224051
224399
|
const content = readFileSync16(skillMd, "utf-8");
|
|
@@ -224094,7 +224442,7 @@ var init_engine5 = __esm({
|
|
|
224094
224442
|
for (const skill2 of skills) {
|
|
224095
224443
|
if (skill2.sourceAgent === target) continue;
|
|
224096
224444
|
const dest = join29(targetDir, skill2.name);
|
|
224097
|
-
if (
|
|
224445
|
+
if (existsSync26(dest)) {
|
|
224098
224446
|
skipped.push(`${skill2.name} (already exists in ${target})`);
|
|
224099
224447
|
continue;
|
|
224100
224448
|
}
|
|
@@ -224110,7 +224458,7 @@ var init_engine5 = __esm({
|
|
|
224110
224458
|
scanWorkflows() {
|
|
224111
224459
|
const workflows = [];
|
|
224112
224460
|
const wfDir = join29(this.projectRoot, ".windsurf", "workflows");
|
|
224113
|
-
if (!
|
|
224461
|
+
if (!existsSync26(wfDir)) return workflows;
|
|
224114
224462
|
try {
|
|
224115
224463
|
const files = readdirSync4(wfDir).filter((f7) => f7.endsWith(".md"));
|
|
224116
224464
|
for (const file2 of files) {
|
|
@@ -224436,7 +224784,7 @@ __export(behavior_exports, {
|
|
|
224436
224784
|
getBehaviorConfig: () => getBehaviorConfig,
|
|
224437
224785
|
resetBehaviorConfigCache: () => resetBehaviorConfigCache
|
|
224438
224786
|
});
|
|
224439
|
-
import { existsSync as
|
|
224787
|
+
import { existsSync as existsSync27, readFileSync as readFileSync17 } from "fs";
|
|
224440
224788
|
import { homedir as homedir34 } from "os";
|
|
224441
224789
|
function isSessionInject(value) {
|
|
224442
224790
|
return value === "full" || value === "minimal" || value === "silent";
|
|
@@ -224447,7 +224795,7 @@ function isFormationMode(value) {
|
|
|
224447
224795
|
function legacyBehavior(homeDir) {
|
|
224448
224796
|
const configPath = getLegacyConfigJsonPath(homeDir);
|
|
224449
224797
|
try {
|
|
224450
|
-
if (!
|
|
224798
|
+
if (!existsSync27(configPath)) return {};
|
|
224451
224799
|
const parsed = JSON.parse(readFileSync17(configPath, "utf-8"));
|
|
224452
224800
|
return parsed.behavior && typeof parsed.behavior === "object" && !Array.isArray(parsed.behavior) ? parsed.behavior : {};
|
|
224453
224801
|
} catch {
|
|
@@ -225953,7 +226301,7 @@ async function handleApi(req, res, dataDir, projectId, projectName, baseDir, pro
|
|
|
225953
226301
|
}
|
|
225954
226302
|
case "/config": {
|
|
225955
226303
|
const os10 = await import("os");
|
|
225956
|
-
const { existsSync:
|
|
226304
|
+
const { existsSync: existsSync37 } = await import("fs");
|
|
225957
226305
|
const { join: join36 } = await import("path");
|
|
225958
226306
|
const configProjectRoot = effectiveProjectRoot;
|
|
225959
226307
|
const resolved = getResolvedConfig({ projectRoot: configProjectRoot });
|
|
@@ -225981,7 +226329,7 @@ async function handleApi(req, res, dataDir, projectId, projectName, baseDir, pro
|
|
|
225981
226329
|
if (fpath === null) {
|
|
225982
226330
|
files[key] = { exists: false, path: "unavailable", unavailable: true };
|
|
225983
226331
|
} else {
|
|
225984
|
-
files[key] = { exists:
|
|
226332
|
+
files[key] = { exists: existsSync37(fpath), path: fpath };
|
|
225985
226333
|
}
|
|
225986
226334
|
}
|
|
225987
226335
|
} catch {
|
|
@@ -226005,7 +226353,8 @@ async function handleApi(req, res, dataDir, projectId, projectName, baseDir, pro
|
|
|
226005
226353
|
"ANTHROPIC_API_KEY",
|
|
226006
226354
|
...resolved.memory.llm.provider === "openrouter" || resolved.memory.llm.baseUrl?.includes("openrouter.ai") ? ["OPENROUTER_API_KEY"] : [],
|
|
226007
226355
|
...resolved.memory.llm.provider === "requesty" ? ["REQUESTY_API_KEY"] : [],
|
|
226008
|
-
...resolved.memory.llm.provider === "apiroute" ? ["API_ROUTE_API_KEY"] : []
|
|
226356
|
+
...resolved.memory.llm.provider === "apiroute" ? ["API_ROUTE_API_KEY"] : [],
|
|
226357
|
+
...resolved.memory.llm.provider === "cheaperinference" ? ["CHEAPER_INFERENCE_API_KEY"] : []
|
|
226009
226358
|
];
|
|
226010
226359
|
if (llmKey) {
|
|
226011
226360
|
const src2 = resolveDashboardKeySource({ value: llmKey, envKeys: memoryKeyEnv, configSource });
|
|
@@ -266397,7 +266746,7 @@ async function analyzeImage(input) {
|
|
|
266397
266746
|
const config2 = getLLMConfig();
|
|
266398
266747
|
if (!OPENAI_COMPATIBLE_PROVIDERS.has(config2.provider)) {
|
|
266399
266748
|
throw new Error(
|
|
266400
|
-
`Image analysis requires an OpenAI-compatible provider (openai, openrouter, requesty, apiroute, or custom). Current provider "${config2.provider}" uses a different API shape. Set MEMORIX_LLM_PROVIDER=openai or configure an OpenAI-compatible base URL.`
|
|
266749
|
+
`Image analysis requires an OpenAI-compatible provider (openai, openrouter, requesty, apiroute, cheaperinference, or custom). Current provider "${config2.provider}" uses a different API shape. Set MEMORIX_LLM_PROVIDER=openai or configure an OpenAI-compatible base URL.`
|
|
266401
266750
|
);
|
|
266402
266751
|
}
|
|
266403
266752
|
const bytes = decodeBase64ImagePayload(input.base64, MAX_VISION_IMAGE_BYTES);
|
|
@@ -266436,7 +266785,7 @@ var init_image_loader = __esm({
|
|
|
266436
266785
|
init_provider2();
|
|
266437
266786
|
init_secret_filter();
|
|
266438
266787
|
init_image_payload();
|
|
266439
|
-
OPENAI_COMPATIBLE_PROVIDERS = /* @__PURE__ */ new Set(["openai", "openrouter", "requesty", "apiroute", "custom"]);
|
|
266788
|
+
OPENAI_COMPATIBLE_PROVIDERS = /* @__PURE__ */ new Set(["openai", "openrouter", "requesty", "apiroute", "cheaperinference", "custom"]);
|
|
266440
266789
|
MAX_VISION_PROMPT_CHARS = 12e3;
|
|
266441
266790
|
MAX_VISION_DESCRIPTION_CHARS = 12e3;
|
|
266442
266791
|
MAX_VISION_LABELS = 50;
|
|
@@ -266452,11 +266801,11 @@ __export(hooks_path_exports, {
|
|
|
266452
266801
|
resolveGitDir: () => resolveGitDir,
|
|
266453
266802
|
resolveHooksDir: () => resolveHooksDir
|
|
266454
266803
|
});
|
|
266455
|
-
import { existsSync as
|
|
266804
|
+
import { existsSync as existsSync28, readFileSync as readFileSync18, statSync as statSync7, mkdirSync as mkdirSync8 } from "fs";
|
|
266456
266805
|
import path42 from "path";
|
|
266457
266806
|
function resolveGitDir(projectRoot) {
|
|
266458
266807
|
const dotGit = path42.join(projectRoot, ".git");
|
|
266459
|
-
if (!
|
|
266808
|
+
if (!existsSync28(dotGit)) return null;
|
|
266460
266809
|
const stat6 = statSync7(dotGit);
|
|
266461
266810
|
if (stat6.isDirectory()) {
|
|
266462
266811
|
return dotGit;
|
|
@@ -266468,7 +266817,7 @@ function resolveGitDir(projectRoot) {
|
|
|
266468
266817
|
if (match2) {
|
|
266469
266818
|
const gitdir = match2[1].trim();
|
|
266470
266819
|
const resolved = path42.isAbsolute(gitdir) ? gitdir : path42.resolve(projectRoot, gitdir);
|
|
266471
|
-
if (
|
|
266820
|
+
if (existsSync28(resolved)) {
|
|
266472
266821
|
return resolved;
|
|
266473
266822
|
}
|
|
266474
266823
|
}
|
|
@@ -267674,7 +268023,18 @@ _Search mode: ${result.receipt.mode}_`;
|
|
|
267674
268023
|
text: text3
|
|
267675
268024
|
}
|
|
267676
268025
|
],
|
|
267677
|
-
|
|
268026
|
+
// Clients that surface only structuredContent (e.g. Claude Code) must
|
|
268027
|
+
// still see the results, not just the retrieval diagnostics.
|
|
268028
|
+
structuredContent: {
|
|
268029
|
+
results: result.entries.map((entry) => ({
|
|
268030
|
+
ref: formatEntryRef(entry),
|
|
268031
|
+
title: entry.title,
|
|
268032
|
+
type: entry.type,
|
|
268033
|
+
time: entry.time,
|
|
268034
|
+
tokens: entry.tokens
|
|
268035
|
+
})),
|
|
268036
|
+
retrieval: result.receipt
|
|
268037
|
+
}
|
|
267678
268038
|
};
|
|
267679
268039
|
}, { loadCorpus: false });
|
|
267680
268040
|
}
|
|
@@ -269742,9 +270102,12 @@ ${s4.instruction}`.toLowerCase();
|
|
|
269742
270102
|
}
|
|
269743
270103
|
} catch {
|
|
269744
270104
|
}
|
|
270105
|
+
const card = lines.filter(Boolean).join("\n");
|
|
269745
270106
|
return {
|
|
269746
|
-
content: [{ type: "text", text:
|
|
269747
|
-
structuredContent
|
|
270107
|
+
content: [{ type: "text", text: card }],
|
|
270108
|
+
// Clients that surface only structuredContent (e.g. Claude Code) must
|
|
270109
|
+
// still see the session card, not just the binding receipt.
|
|
270110
|
+
structuredContent: { card, binding: bindingReceipt }
|
|
269748
270111
|
};
|
|
269749
270112
|
}
|
|
269750
270113
|
);
|
|
@@ -271174,10 +271537,10 @@ Preview: ${analysis.description.slice(0, 300)}${analysis.description.length > 30
|
|
|
271174
271537
|
const { ensureHooksDir: ensureHooksDir2 } = await Promise.resolve().then(() => (init_hooks_path(), hooks_path_exports));
|
|
271175
271538
|
const resolved = ensureHooksDir2(project.rootPath);
|
|
271176
271539
|
if (resolved) {
|
|
271177
|
-
const { existsSync:
|
|
271540
|
+
const { existsSync: existsSync37, readFileSync: readFileSync25, writeFileSync: writeFileSync13, chmodSync: chmodSync2 } = await import("fs");
|
|
271178
271541
|
const { hookPath } = resolved;
|
|
271179
271542
|
const HOOK_MARKER3 = "# [memorix-git-hook]";
|
|
271180
|
-
const needsInstall = !
|
|
271543
|
+
const needsInstall = !existsSync37(hookPath) || !readFileSync25(hookPath, "utf-8").includes(HOOK_MARKER3);
|
|
271181
271544
|
if (needsInstall) {
|
|
271182
271545
|
const hookScript = `#!/bin/sh
|
|
271183
271546
|
${HOOK_MARKER3}
|
|
@@ -271186,7 +271549,7 @@ if command -v memorix >/dev/null 2>&1; then
|
|
|
271186
271549
|
memorix ingest commit --auto >/dev/null 2>&1 &
|
|
271187
271550
|
fi
|
|
271188
271551
|
`;
|
|
271189
|
-
if (
|
|
271552
|
+
if (existsSync37(hookPath)) {
|
|
271190
271553
|
const existing = readFileSync25(hookPath, "utf-8");
|
|
271191
271554
|
writeFileSync13(hookPath, existing.trimEnd() + `
|
|
271192
271555
|
|
|
@@ -271354,6 +271717,7 @@ var init_server4 = __esm({
|
|
|
271354
271717
|
init_graph_scope();
|
|
271355
271718
|
init_visibility();
|
|
271356
271719
|
init_engine3();
|
|
271720
|
+
init_index_format();
|
|
271357
271721
|
init_graph_context();
|
|
271358
271722
|
init_detector();
|
|
271359
271723
|
init_launch_root();
|
|
@@ -275685,7 +276049,7 @@ ${stack}` : ""}`);
|
|
|
275685
276049
|
if (apiPath === "/config") {
|
|
275686
276050
|
const { projectId: configProjectId } = await resolveRequestProject(url2);
|
|
275687
276051
|
const os10 = await import("os");
|
|
275688
|
-
const { existsSync:
|
|
276052
|
+
const { existsSync: existsSync37 } = await import("fs");
|
|
275689
276053
|
const { join: join36 } = await import("path");
|
|
275690
276054
|
const { loadYamlConfig: loadYamlConfig2 } = await Promise.resolve().then(() => (init_yaml_loader(), yaml_loader_exports));
|
|
275691
276055
|
const { loadFileConfig: loadFileConfig2, loadDotenv: loadDotenv2, getLoadedEnvFiles: getLoadedEnvFiles2 } = await Promise.resolve().then(() => (init_config(), config_exports));
|
|
@@ -275707,7 +276071,7 @@ ${stack}` : ""}`);
|
|
|
275707
276071
|
"legacy config.json": join36(home, ".memorix", "config.json")
|
|
275708
276072
|
};
|
|
275709
276073
|
for (const [key, fpath] of Object.entries(paths)) {
|
|
275710
|
-
files[key] = { exists:
|
|
276074
|
+
files[key] = { exists: existsSync37(fpath), path: fpath };
|
|
275711
276075
|
}
|
|
275712
276076
|
} else {
|
|
275713
276077
|
files["project memorix.yml"] = { exists: false, path: "unavailable", unavailable: true };
|
|
@@ -275718,7 +276082,7 @@ ${stack}` : ""}`);
|
|
|
275718
276082
|
"legacy config.json": join36(home, ".memorix", "config.json")
|
|
275719
276083
|
};
|
|
275720
276084
|
for (const [key, fpath] of Object.entries(userPaths)) {
|
|
275721
|
-
files[key] = { exists:
|
|
276085
|
+
files[key] = { exists: existsSync37(fpath), path: fpath };
|
|
275722
276086
|
}
|
|
275723
276087
|
}
|
|
275724
276088
|
const values = [];
|
|
@@ -276347,7 +276711,7 @@ var init_status = __esm({
|
|
|
276347
276711
|
const { getProjectDataDir: getProjectDataDir2 } = await Promise.resolve().then(() => (init_persistence(), persistence_exports));
|
|
276348
276712
|
const { getEmbeddingProvider: getEmbeddingProvider2 } = await Promise.resolve().then(() => (init_provider(), provider_exports));
|
|
276349
276713
|
const { getResolvedConfig: getResolvedConfig2, getResolvedAgentLane: getResolvedAgentLane2 } = await Promise.resolve().then(() => (init_resolved_config(), resolved_config_exports));
|
|
276350
|
-
const { existsSync:
|
|
276714
|
+
const { existsSync: existsSync37, readFileSync: readFileSync25 } = await import("fs");
|
|
276351
276715
|
const project = detectProject2();
|
|
276352
276716
|
if (!project) {
|
|
276353
276717
|
const message = "Memorix requires a git repo to establish project identity. Run `git init` in this workspace first.";
|
|
@@ -276430,7 +276794,7 @@ var init_status = __esm({
|
|
|
276430
276794
|
try {
|
|
276431
276795
|
const { resolveHooksDir: resolveHooksDir2 } = await Promise.resolve().then(() => (init_hooks_path(), hooks_path_exports));
|
|
276432
276796
|
const resolved2 = resolveHooksDir2(project.rootPath);
|
|
276433
|
-
if (resolved2 &&
|
|
276797
|
+
if (resolved2 && existsSync37(resolved2.hookPath)) {
|
|
276434
276798
|
const hookContent = readFileSync25(resolved2.hookPath, "utf-8");
|
|
276435
276799
|
if (hookContent.includes("# [memorix-git-hook]")) {
|
|
276436
276800
|
diagLines.push(` Git hook: installed [OK]`);
|
|
@@ -282502,7 +282866,7 @@ var git_hook_install_exports = {};
|
|
|
282502
282866
|
__export(git_hook_install_exports, {
|
|
282503
282867
|
default: () => git_hook_install_default
|
|
282504
282868
|
});
|
|
282505
|
-
import { existsSync as
|
|
282869
|
+
import { existsSync as existsSync29, readFileSync as readFileSync19, writeFileSync as writeFileSync7, chmodSync } from "fs";
|
|
282506
282870
|
function generateHookScript() {
|
|
282507
282871
|
return `${HOOK_MARKER}
|
|
282508
282872
|
# Memorix: Auto-ingest git commits as memories
|
|
@@ -282549,7 +282913,7 @@ var init_git_hook_install = __esm({
|
|
|
282549
282913
|
return;
|
|
282550
282914
|
}
|
|
282551
282915
|
const { hookPath } = resolved;
|
|
282552
|
-
if (
|
|
282916
|
+
if (existsSync29(hookPath)) {
|
|
282553
282917
|
const existing = readFileSync19(hookPath, "utf-8");
|
|
282554
282918
|
if (existing.includes(HOOK_MARKER)) {
|
|
282555
282919
|
v3.warn("Memorix git hook is already installed.");
|
|
@@ -282599,7 +282963,7 @@ var git_hook_uninstall_exports = {};
|
|
|
282599
282963
|
__export(git_hook_uninstall_exports, {
|
|
282600
282964
|
default: () => git_hook_uninstall_default
|
|
282601
282965
|
});
|
|
282602
|
-
import { existsSync as
|
|
282966
|
+
import { existsSync as existsSync30, readFileSync as readFileSync20, writeFileSync as writeFileSync8, unlinkSync as unlinkSync3 } from "fs";
|
|
282603
282967
|
var HOOK_MARKER2, git_hook_uninstall_default;
|
|
282604
282968
|
var init_git_hook_uninstall = __esm({
|
|
282605
282969
|
"src/cli/commands/git-hook-uninstall.ts"() {
|
|
@@ -282631,7 +282995,7 @@ var init_git_hook_uninstall = __esm({
|
|
|
282631
282995
|
return;
|
|
282632
282996
|
}
|
|
282633
282997
|
const { hookPath } = resolved;
|
|
282634
|
-
if (!
|
|
282998
|
+
if (!existsSync30(hookPath)) {
|
|
282635
282999
|
v3.warn("No post-commit hook found.");
|
|
282636
283000
|
fe2("Nothing to uninstall.");
|
|
282637
283001
|
return;
|
|
@@ -283490,7 +283854,7 @@ __export(agent_integrations_exports, {
|
|
|
283490
283854
|
repairAgentIntegrations: () => repairAgentIntegrations
|
|
283491
283855
|
});
|
|
283492
283856
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
283493
|
-
import { existsSync as
|
|
283857
|
+
import { existsSync as existsSync32, realpathSync as realpathSync2 } from "fs";
|
|
283494
283858
|
import { mkdir as mkdir9, readFile as readFile10, writeFile as writeFile10 } from "fs/promises";
|
|
283495
283859
|
import { basename as basename5, dirname as dirname8, resolve as resolve7 } from "path";
|
|
283496
283860
|
import { homedir as homedir36 } from "os";
|
|
@@ -283575,7 +283939,7 @@ function capabilityParity(agent, projectRoot, scope, mcp, guidance, plugin) {
|
|
|
283575
283939
|
for (const artifactScope of artifactScopes) {
|
|
283576
283940
|
const path50 = artifactScope === "project" ? getProjectConfigPath(agent, projectRoot) : getGlobalConfigPath(agent);
|
|
283577
283941
|
if (!path50) continue;
|
|
283578
|
-
const exists3 =
|
|
283942
|
+
const exists3 = existsSync32(path50);
|
|
283579
283943
|
artifactChecks.push({
|
|
283580
283944
|
kind: "hooks",
|
|
283581
283945
|
scope: artifactScope,
|
|
@@ -283703,7 +284067,7 @@ async function inspectCodexPluginBundle() {
|
|
|
283703
284067
|
const manifestPath = `${pluginPath}/.codex-plugin/plugin.json`;
|
|
283704
284068
|
const hooksPath = `${pluginPath}/hooks/hooks.json`;
|
|
283705
284069
|
const mcpPath = codexPluginMcpPath();
|
|
283706
|
-
if (!
|
|
284070
|
+
if (!existsSync32(pluginPath)) {
|
|
283707
284071
|
return {
|
|
283708
284072
|
scope: "global",
|
|
283709
284073
|
kind: "bundle",
|
|
@@ -283713,7 +284077,7 @@ async function inspectCodexPluginBundle() {
|
|
|
283713
284077
|
issues: ["codex-plugin-bundle-missing"]
|
|
283714
284078
|
};
|
|
283715
284079
|
}
|
|
283716
|
-
if (!
|
|
284080
|
+
if (!existsSync32(manifestPath)) {
|
|
283717
284081
|
return {
|
|
283718
284082
|
scope: "global",
|
|
283719
284083
|
kind: "bundle",
|
|
@@ -283750,7 +284114,7 @@ async function inspectCodexPluginBundle() {
|
|
|
283750
284114
|
const issues = [];
|
|
283751
284115
|
if (version2 !== getCliVersion()) issues.push("codex-plugin-version-mismatch");
|
|
283752
284116
|
if (manifest.hooks !== "./hooks/hooks.json") issues.push("codex-hook-manifest-missing");
|
|
283753
|
-
if (!
|
|
284117
|
+
if (!existsSync32(mcpPath)) {
|
|
283754
284118
|
issues.push("codex-plugin-mcp-manifest-missing");
|
|
283755
284119
|
} else {
|
|
283756
284120
|
try {
|
|
@@ -283764,7 +284128,7 @@ async function inspectCodexPluginBundle() {
|
|
|
283764
284128
|
}
|
|
283765
284129
|
}
|
|
283766
284130
|
let declared = [];
|
|
283767
|
-
if (!
|
|
284131
|
+
if (!existsSync32(hooksPath)) {
|
|
283768
284132
|
issues.push("codex-hook-manifest-missing");
|
|
283769
284133
|
} else {
|
|
283770
284134
|
try {
|
|
@@ -283791,7 +284155,7 @@ async function inspectCodexPluginBundle() {
|
|
|
283791
284155
|
}
|
|
283792
284156
|
async function inspectCodexMarketplace() {
|
|
283793
284157
|
const marketplacePath = codexMarketplacePath();
|
|
283794
|
-
if (!
|
|
284158
|
+
if (!existsSync32(marketplacePath)) {
|
|
283795
284159
|
return {
|
|
283796
284160
|
scope: "global",
|
|
283797
284161
|
kind: "marketplace",
|
|
@@ -283881,7 +284245,7 @@ function inspectCodexPluginRuntime() {
|
|
|
283881
284245
|
}
|
|
283882
284246
|
async function inspectCodexHookTrust() {
|
|
283883
284247
|
const configPath = codexConfigPath();
|
|
283884
|
-
if (!
|
|
284248
|
+
if (!existsSync32(configPath)) {
|
|
283885
284249
|
return {
|
|
283886
284250
|
scope: "global",
|
|
283887
284251
|
kind: "hook-trust",
|
|
@@ -283982,7 +284346,7 @@ function defaultClaudeProjectKey(projectRoot) {
|
|
|
283982
284346
|
}
|
|
283983
284347
|
function canonicalProjectPath(projectRoot) {
|
|
283984
284348
|
const resolved = resolve7(projectRoot);
|
|
283985
|
-
const canonical =
|
|
284349
|
+
const canonical = existsSync32(resolved) ? realpathSync2(resolved) : resolved;
|
|
283986
284350
|
return canonical.replace(/\\/g, "/");
|
|
283987
284351
|
}
|
|
283988
284352
|
function getClaudeLocalConfigPath() {
|
|
@@ -284014,7 +284378,7 @@ function findClaudeLocalProject(config2, projectRoot) {
|
|
|
284014
284378
|
}
|
|
284015
284379
|
async function inspectClaudeLocalMcp(projectRoot) {
|
|
284016
284380
|
const configPath = getClaudeLocalConfigPath();
|
|
284017
|
-
if (!
|
|
284381
|
+
if (!existsSync32(configPath)) {
|
|
284018
284382
|
return {
|
|
284019
284383
|
scope: "local",
|
|
284020
284384
|
path: configPath,
|
|
@@ -284102,7 +284466,7 @@ async function inspectCodexPluginMcp() {
|
|
|
284102
284466
|
const runtime = inspectCodexPluginRuntime();
|
|
284103
284467
|
if (!runtime.runtime?.installed || !runtime.runtime.enabled) return null;
|
|
284104
284468
|
const mcpPath = codexPluginMcpPath();
|
|
284105
|
-
if (!
|
|
284469
|
+
if (!existsSync32(mcpPath)) {
|
|
284106
284470
|
return {
|
|
284107
284471
|
scope: "global",
|
|
284108
284472
|
path: mcpPath,
|
|
@@ -284154,7 +284518,7 @@ async function inspectOptionalGrokMcp(scope) {
|
|
|
284154
284518
|
}
|
|
284155
284519
|
const adapter = getMcpAdapter("grok");
|
|
284156
284520
|
const configPath = adapter.getConfigPath();
|
|
284157
|
-
if (!
|
|
284521
|
+
if (!existsSync32(configPath)) {
|
|
284158
284522
|
return {
|
|
284159
284523
|
status: "skipped",
|
|
284160
284524
|
issues: ["mcp-host-owned"],
|
|
@@ -284221,7 +284585,7 @@ async function inspectMcp(agent, projectRoot, scope) {
|
|
|
284221
284585
|
if (targetScope === "global" && configPath === adapter.getConfigPath(projectRoot) && scope === "all") {
|
|
284222
284586
|
continue;
|
|
284223
284587
|
}
|
|
284224
|
-
if (!
|
|
284588
|
+
if (!existsSync32(configPath)) {
|
|
284225
284589
|
checks.push({
|
|
284226
284590
|
scope: targetScope,
|
|
284227
284591
|
path: configPath,
|
|
@@ -284298,7 +284662,7 @@ async function inspectGuidance(agent, projectRoot, scope) {
|
|
|
284298
284662
|
for (const targetScope of requestedGuidanceScopes(scope)) {
|
|
284299
284663
|
const root = targetScope === "project" ? projectRoot : homedir36();
|
|
284300
284664
|
const rulesPath = getAgentRulesPath(agent, root, targetScope === "global");
|
|
284301
|
-
if (!
|
|
284665
|
+
if (!existsSync32(rulesPath)) {
|
|
284302
284666
|
checks.push({
|
|
284303
284667
|
scope: targetScope,
|
|
284304
284668
|
path: rulesPath,
|
|
@@ -284585,7 +284949,7 @@ var init_doctor = __esm({
|
|
|
284585
284949
|
}
|
|
284586
284950
|
return;
|
|
284587
284951
|
}
|
|
284588
|
-
const { existsSync:
|
|
284952
|
+
const { existsSync: existsSync37, readFileSync: readFileSync25 } = await import("fs");
|
|
284589
284953
|
const { join: join36, basename: basename7 } = await import("path");
|
|
284590
284954
|
const { homedir: homedir38 } = await import("os");
|
|
284591
284955
|
const { execSync: execSync5 } = await import("child_process");
|
|
@@ -284656,7 +285020,7 @@ var init_doctor = __esm({
|
|
|
284656
285020
|
let bgPid = 0;
|
|
284657
285021
|
let backgroundHealthy = false;
|
|
284658
285022
|
try {
|
|
284659
|
-
if (
|
|
285023
|
+
if (existsSync37(bgStatePath)) {
|
|
284660
285024
|
const bgState = JSON.parse(readFileSync25(bgStatePath, "utf-8"));
|
|
284661
285025
|
bgPid = bgState.pid;
|
|
284662
285026
|
bgPort = bgState.port;
|
|
@@ -284771,7 +285135,7 @@ var init_doctor = __esm({
|
|
|
284771
285135
|
}
|
|
284772
285136
|
try {
|
|
284773
285137
|
const cachePath = join36(memorixDir, "embedding-cache.json");
|
|
284774
|
-
if (
|
|
285138
|
+
if (existsSync37(cachePath)) {
|
|
284775
285139
|
const cache5 = JSON.parse(readFileSync25(cachePath, "utf-8"));
|
|
284776
285140
|
const cacheCount = Object.keys(cache5).length;
|
|
284777
285141
|
lines.push(info2(`Cached embeddings: ${cacheCount}`));
|
|
@@ -284786,7 +285150,7 @@ var init_doctor = __esm({
|
|
|
284786
285150
|
}
|
|
284787
285151
|
lines.push("");
|
|
284788
285152
|
lines.push("\u250C\u2500 Data Status \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500");
|
|
284789
|
-
if (dataDir &&
|
|
285153
|
+
if (dataDir && existsSync37(dataDir)) {
|
|
284790
285154
|
let obsCount = 0;
|
|
284791
285155
|
let activeCount = 0;
|
|
284792
285156
|
let ranCount = 0;
|
|
@@ -285025,7 +285389,7 @@ var init_doctor = __esm({
|
|
|
285025
285389
|
let conflictsFound = false;
|
|
285026
285390
|
if (dataDir) {
|
|
285027
285391
|
const lockFile = join36(dataDir, ".memorix.lock");
|
|
285028
|
-
if (
|
|
285392
|
+
if (existsSync37(lockFile)) {
|
|
285029
285393
|
try {
|
|
285030
285394
|
const lockData = JSON.parse(readFileSync25(lockFile, "utf-8"));
|
|
285031
285395
|
const lockAge = Date.now() - lockData.time;
|
|
@@ -285159,7 +285523,7 @@ var init_repair3 = __esm({
|
|
|
285159
285523
|
repair_default = defineCommand({
|
|
285160
285524
|
meta: {
|
|
285161
285525
|
name: "repair",
|
|
285162
|
-
description: "Repair
|
|
285526
|
+
description: "Repair agent integrations or compact the semantic index"
|
|
285163
285527
|
},
|
|
285164
285528
|
args: {
|
|
285165
285529
|
agent: {
|
|
@@ -285184,8 +285548,21 @@ var init_repair3 = __esm({
|
|
|
285184
285548
|
run: async ({ args }) => {
|
|
285185
285549
|
const positional = args._ ?? [];
|
|
285186
285550
|
const action = positional[0] || "agents";
|
|
285551
|
+
if (action === "index") {
|
|
285552
|
+
if (args.dry) throw new Error("`memorix repair index` does not support --dry");
|
|
285553
|
+
const { detectProject: detectProject2 } = await Promise.resolve().then(() => (init_detector(), detector_exports));
|
|
285554
|
+
const { getProjectDataDir: getProjectDataDir2 } = await Promise.resolve().then(() => (init_persistence(), persistence_exports));
|
|
285555
|
+
const { optimizeSemanticIndexes: optimizeSemanticIndexes2 } = await Promise.resolve().then(() => (init_semantic_index(), semantic_index_exports));
|
|
285556
|
+
const project = detectProject2(process.cwd());
|
|
285557
|
+
if (!project) throw new Error("Run `memorix repair index` inside a Git project");
|
|
285558
|
+
const dataDir = await getProjectDataDir2(project.id);
|
|
285559
|
+
const tables = await optimizeSemanticIndexes2(dataDir);
|
|
285560
|
+
if (args.json) console.log(JSON.stringify({ dataDir, optimizedTables: tables }, null, 2));
|
|
285561
|
+
else console.log(`Optimized ${tables.length} semantic table(s) in ${dataDir}`);
|
|
285562
|
+
return;
|
|
285563
|
+
}
|
|
285187
285564
|
if (action !== "agents") {
|
|
285188
|
-
const message = "Usage: memorix repair agents [--agent <agent>] [--scope local|project|global|all] [--dry]";
|
|
285565
|
+
const message = "Usage: memorix repair agents [--agent <agent>] [--scope local|project|global|all] [--dry] | memorix repair index [--json]";
|
|
285189
285566
|
if (args.json) {
|
|
285190
285567
|
console.log(JSON.stringify({ error: message }, null, 2));
|
|
285191
285568
|
} else {
|
|
@@ -287252,7 +287629,7 @@ var init_pipeline_trace = __esm({
|
|
|
287252
287629
|
|
|
287253
287630
|
// src/orchestrate/worktree.ts
|
|
287254
287631
|
import { execFileSync as execFileSync5 } from "child_process";
|
|
287255
|
-
import { existsSync as
|
|
287632
|
+
import { existsSync as existsSync34, rmSync as rmSync2 } from "fs";
|
|
287256
287633
|
import { join as join34, basename as basename6 } from "path";
|
|
287257
287634
|
function runGit4(cwd, args, timeout = 5e3) {
|
|
287258
287635
|
return String(execFileSync5("git", args, {
|
|
@@ -287298,7 +287675,7 @@ function createWorktree(projectDir2, taskId, pipelineId) {
|
|
|
287298
287675
|
const suffix = attempt === 1 ? "" : `-${attempt}`;
|
|
287299
287676
|
const worktreePath = `${worktreeBase}${suffix}`;
|
|
287300
287677
|
const branch = `${branchBase}${suffix}`;
|
|
287301
|
-
if (
|
|
287678
|
+
if (existsSync34(worktreePath)) continue;
|
|
287302
287679
|
if (!isBranchAvailable(projectDir2, branch)) continue;
|
|
287303
287680
|
runGit4(projectDir2, ["worktree", "add", "-b", branch, worktreePath], 3e4);
|
|
287304
287681
|
return { worktreePath, branch };
|
|
@@ -287349,7 +287726,7 @@ function removeWorktree(projectDir2, worktreePath, branch) {
|
|
|
287349
287726
|
try {
|
|
287350
287727
|
runGit4(projectDir2, ["worktree", "remove", worktreePath, "--force"], 1e4);
|
|
287351
287728
|
} catch {
|
|
287352
|
-
if (
|
|
287729
|
+
if (existsSync34(worktreePath)) {
|
|
287353
287730
|
try {
|
|
287354
287731
|
rmSync2(worktreePath, { recursive: true, force: true });
|
|
287355
287732
|
} catch {
|
|
@@ -290778,6 +291155,7 @@ function ConfigureView({ onBack }) {
|
|
|
290778
291155
|
{ key: "openrouter", label: "OpenRouter", hint: "multi-provider" },
|
|
290779
291156
|
{ key: "requesty", label: "Requesty", hint: "multi-provider" },
|
|
290780
291157
|
{ key: "apiroute", label: "API Route", hint: "multi-provider" },
|
|
291158
|
+
{ key: "cheaperinference", label: "Cheaper Inference", hint: "multi-provider" },
|
|
290781
291159
|
{ key: "atlascloud", label: "Atlas Cloud", hint: "DeepSeek V3.2" },
|
|
290782
291160
|
{ key: "custom", label: "Custom endpoint", hint: "OpenAI-compatible" },
|
|
290783
291161
|
{ key: "disable", label: "Disable LLM", hint: "free heuristic mode", color: COLORS.warning },
|
|
@@ -291073,6 +291451,7 @@ function getDefaultModel(provider2) {
|
|
|
291073
291451
|
if (provider2 === "openrouter") return "openai/gpt-4o-mini";
|
|
291074
291452
|
if (provider2 === "requesty") return "openai/gpt-4o-mini";
|
|
291075
291453
|
if (provider2 === "apiroute") return "deepseek-v4.1-flash";
|
|
291454
|
+
if (provider2 === "cheaperinference") return "gpt-5.4-mini";
|
|
291076
291455
|
if (provider2 === "atlascloud") return "deepseek-ai/deepseek-v3.2";
|
|
291077
291456
|
return "gpt-4o-mini";
|
|
291078
291457
|
}
|
|
@@ -293489,10 +293868,10 @@ function WorkbenchApp({ version: version2, onExitForInteractive }) {
|
|
|
293489
293868
|
}
|
|
293490
293869
|
try {
|
|
293491
293870
|
const { resolveHooksDir: resolveHooksDir2 } = await Promise.resolve().then(() => (init_hooks_path(), hooks_path_exports));
|
|
293492
|
-
const { existsSync:
|
|
293871
|
+
const { existsSync: existsSync37, readFileSync: readFileSync25, writeFileSync: writeFileSync13, unlinkSync: unlinkSync5 } = await import("fs");
|
|
293493
293872
|
const resolved = resolveHooksDir2(proj.rootPath);
|
|
293494
293873
|
const hookMarker = "# [memorix-git-hook]";
|
|
293495
|
-
if (!resolved || !
|
|
293874
|
+
if (!resolved || !existsSync37(resolved.hookPath)) {
|
|
293496
293875
|
setActionStatus("No post-commit hook found.");
|
|
293497
293876
|
return;
|
|
293498
293877
|
}
|
|
@@ -293647,7 +294026,7 @@ function WorkbenchApp({ version: version2, onExitForInteractive }) {
|
|
|
293647
294026
|
break;
|
|
293648
294027
|
}
|
|
293649
294028
|
case "3": {
|
|
293650
|
-
const { existsSync:
|
|
294029
|
+
const { existsSync: existsSync37, readFileSync: readFileSync25, writeFileSync: writeFileSync13, chmodSync: chmodSync2 } = await import("fs");
|
|
293651
294030
|
const { ensureHooksDir: ensureHooksDir2 } = await Promise.resolve().then(() => (init_hooks_path(), hooks_path_exports));
|
|
293652
294031
|
const hookMarker = "# [memorix-git-hook]";
|
|
293653
294032
|
const resolved = ensureHooksDir2(cwd);
|
|
@@ -293661,7 +294040,7 @@ if command -v memorix >/dev/null 2>&1; then
|
|
|
293661
294040
|
memorix ingest commit --auto >/dev/null 2>&1 &
|
|
293662
294041
|
fi
|
|
293663
294042
|
`;
|
|
293664
|
-
if (
|
|
294043
|
+
if (existsSync37(resolved.hookPath)) {
|
|
293665
294044
|
if (readFileSync25(resolved.hookPath, "utf-8").includes(hookMarker)) {
|
|
293666
294045
|
setActionStatus("Post-commit hook already installed.");
|
|
293667
294046
|
break;
|
|
@@ -293681,11 +294060,11 @@ ${hookScript}`, "utf-8");
|
|
|
293681
294060
|
break;
|
|
293682
294061
|
}
|
|
293683
294062
|
case "4": {
|
|
293684
|
-
const { existsSync:
|
|
294063
|
+
const { existsSync: existsSync37, readFileSync: readFileSync25, writeFileSync: writeFileSync13, unlinkSync: unlinkSync5 } = await import("fs");
|
|
293685
294064
|
const { resolveHooksDir: resolveHooksDir2 } = await Promise.resolve().then(() => (init_hooks_path(), hooks_path_exports));
|
|
293686
294065
|
const hookMarker = "# [memorix-git-hook]";
|
|
293687
294066
|
const resolved = resolveHooksDir2(cwd);
|
|
293688
|
-
if (!resolved || !
|
|
294067
|
+
if (!resolved || !existsSync37(resolved.hookPath)) {
|
|
293689
294068
|
setActionStatus("No post-commit hook found.");
|
|
293690
294069
|
break;
|
|
293691
294070
|
}
|