memorix 1.10.1 → 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 +14 -0
- package/dist/cli/index.js +416 -167
- package/dist/index.js +232 -106
- package/dist/maintenance-runner.js +167 -57
- package/dist/media-audio-runner.js +139 -29
- package/dist/media-video-runner.js +166 -56
- package/dist/memcode-runtime/CHANGELOG.md +14 -0
- package/dist/sdk.js +283 -106
- package/dist/vector-backfill-runner.js +166 -56
- package/docs/DEVELOPMENT.md +3 -4
- package/docs/PERFORMANCE.md +23 -0
- package/docs/README.md +2 -2
- package/docs/ROADMAP-1.9.12-2.0.md +2 -2
- 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/repair.ts +17 -3
- package/src/compact/index-format.ts +1 -1
- package/src/knowledge/context-receipt.ts +6 -3
- package/src/memory/observations.ts +7 -5
- package/src/search/derived-view-receipt.ts +40 -0
- package/src/search/semantic-index.ts +149 -1
- package/src/server.ts +18 -3
- package/src/store/orama-store.ts +32 -16
package/dist/sdk.js
CHANGED
|
@@ -7843,13 +7843,18 @@ __export(semantic_index_exports, {
|
|
|
7843
7843
|
createSemanticIndexProfile: () => createSemanticIndexProfile,
|
|
7844
7844
|
deleteSemanticVector: () => deleteSemanticVector,
|
|
7845
7845
|
ensureSemanticIndex: () => ensureSemanticIndex,
|
|
7846
|
+
getSemanticIndexStats: () => getSemanticIndexStats,
|
|
7846
7847
|
isSemanticIndexAvailable: () => isSemanticIndexAvailable,
|
|
7848
|
+
listSemanticVectorIds: () => listSemanticVectorIds,
|
|
7849
|
+
optimizeSemanticIndex: () => optimizeSemanticIndex,
|
|
7850
|
+
optimizeSemanticIndexes: () => optimizeSemanticIndexes,
|
|
7847
7851
|
resetSemanticIndexRuntime: () => resetSemanticIndexRuntime,
|
|
7848
7852
|
searchSemanticVectors: () => searchSemanticVectors,
|
|
7849
7853
|
upsertSemanticVector: () => upsertSemanticVector,
|
|
7850
7854
|
upsertSemanticVectors: () => upsertSemanticVectors
|
|
7851
7855
|
});
|
|
7852
7856
|
import { createHash as createHash4 } from "crypto";
|
|
7857
|
+
import { existsSync as existsSync8 } from "fs";
|
|
7853
7858
|
import { createRequire as createRequire3 } from "module";
|
|
7854
7859
|
import path11 from "path";
|
|
7855
7860
|
function createSemanticIndexProfile(provider2) {
|
|
@@ -7951,20 +7956,120 @@ function queueOperation(key, operation) {
|
|
|
7951
7956
|
writeQueues.set(key, run.catch(() => void 0));
|
|
7952
7957
|
return run;
|
|
7953
7958
|
}
|
|
7959
|
+
function positiveEnvInt(name, fallback) {
|
|
7960
|
+
const value = Number.parseInt(process.env[name] ?? "", 10);
|
|
7961
|
+
return Number.isSafeInteger(value) && value > 0 ? value : fallback;
|
|
7962
|
+
}
|
|
7963
|
+
function semanticWriteBatchSize() {
|
|
7964
|
+
return positiveEnvInt("MEMORIX_SEMANTIC_WRITE_BATCH_SIZE", DEFAULT_WRITE_BATCH_SIZE);
|
|
7965
|
+
}
|
|
7966
|
+
function semanticWriteFlushMs() {
|
|
7967
|
+
return positiveEnvInt("MEMORIX_SEMANTIC_WRITE_FLUSH_MS", DEFAULT_WRITE_FLUSH_MS);
|
|
7968
|
+
}
|
|
7969
|
+
function semanticOptimizeEvery() {
|
|
7970
|
+
return positiveEnvInt("MEMORIX_SEMANTIC_OPTIMIZE_EVERY", DEFAULT_OPTIMIZE_EVERY);
|
|
7971
|
+
}
|
|
7972
|
+
function semanticVersionRetentionMs() {
|
|
7973
|
+
return positiveEnvInt("MEMORIX_SEMANTIC_VERSION_RETENTION_MS", DEFAULT_VERSION_RETENTION_MS);
|
|
7974
|
+
}
|
|
7975
|
+
async function optimizeState(state) {
|
|
7976
|
+
if (!state.table || typeof state.table.optimize !== "function") return;
|
|
7977
|
+
await state.table.optimize({
|
|
7978
|
+
cleanupOlderThan: new Date(Date.now() - semanticVersionRetentionMs()),
|
|
7979
|
+
deleteUnverified: false
|
|
7980
|
+
});
|
|
7981
|
+
}
|
|
7954
7982
|
async function mergeVectors(dataDir, profile, records) {
|
|
7955
7983
|
if (records.length === 0) return;
|
|
7956
7984
|
const state = await getState(dataDir, profile, records);
|
|
7957
7985
|
if (!state?.table) return;
|
|
7958
7986
|
const rows = records.map(toLanceRow);
|
|
7959
7987
|
await state.table.mergeInsert("observation_id").whenMatchedUpdateAll().whenNotMatchedInsertAll().execute(rows);
|
|
7988
|
+
const key = stateKey(dataDir, profile);
|
|
7989
|
+
const mutationCount = (mutationCounts.get(key) ?? 0) + 1;
|
|
7990
|
+
if (mutationCount >= semanticOptimizeEvery()) {
|
|
7991
|
+
mutationCounts.set(key, 0);
|
|
7992
|
+
await optimizeState(state).catch(() => void 0);
|
|
7993
|
+
} else {
|
|
7994
|
+
mutationCounts.set(key, mutationCount);
|
|
7995
|
+
}
|
|
7960
7996
|
void ensureSemanticIndex(dataDir, profile);
|
|
7961
7997
|
}
|
|
7998
|
+
function flushPendingVectorBatch(key) {
|
|
7999
|
+
const pending = pendingVectorBatches.get(key);
|
|
8000
|
+
if (!pending) return Promise.resolve();
|
|
8001
|
+
if (pending.timer) clearTimeout(pending.timer);
|
|
8002
|
+
pendingVectorBatches.delete(key);
|
|
8003
|
+
const records = [...pending.records.values()];
|
|
8004
|
+
const waiters = pending.waiters.splice(0);
|
|
8005
|
+
return queueOperation(key, () => mergeVectors(pending.dataDir, pending.profile, records)).then(() => waiters.forEach((waiter) => waiter.resolve())).catch((error) => {
|
|
8006
|
+
waiters.forEach((waiter) => waiter.reject(error));
|
|
8007
|
+
});
|
|
8008
|
+
}
|
|
7962
8009
|
function upsertSemanticVector(dataDir, profile, record80) {
|
|
7963
|
-
|
|
8010
|
+
const key = stateKey(dataDir, profile);
|
|
8011
|
+
let pending = pendingVectorBatches.get(key);
|
|
8012
|
+
if (!pending) {
|
|
8013
|
+
pending = { dataDir, profile, records: /* @__PURE__ */ new Map(), waiters: [] };
|
|
8014
|
+
pendingVectorBatches.set(key, pending);
|
|
8015
|
+
}
|
|
8016
|
+
pending.records.set(`${record80.projectId}:${record80.observationId}`, record80);
|
|
8017
|
+
const promise = new Promise((resolve5, reject) => pending.waiters.push({ resolve: resolve5, reject }));
|
|
8018
|
+
if (pending.records.size >= semanticWriteBatchSize()) void flushPendingVectorBatch(key);
|
|
8019
|
+
else if (!pending.timer) pending.timer = setTimeout(() => {
|
|
8020
|
+
void flushPendingVectorBatch(key);
|
|
8021
|
+
}, semanticWriteFlushMs());
|
|
8022
|
+
return promise;
|
|
7964
8023
|
}
|
|
7965
8024
|
function upsertSemanticVectors(dataDir, profile, records) {
|
|
7966
8025
|
return queueOperation(stateKey(dataDir, profile), () => mergeVectors(dataDir, profile, records));
|
|
7967
8026
|
}
|
|
8027
|
+
async function listSemanticVectorIds(dataDir, profile) {
|
|
8028
|
+
const state = await getState(dataDir, profile);
|
|
8029
|
+
if (!state?.table) return null;
|
|
8030
|
+
const rows = await state.table.query().select(["observation_id"]).toArray();
|
|
8031
|
+
return new Set(rows.map((row) => Number(row.observation_id)).filter(Number.isSafeInteger));
|
|
8032
|
+
}
|
|
8033
|
+
async function getSemanticIndexStats(dataDir, profile) {
|
|
8034
|
+
const state = await getState(dataDir, profile);
|
|
8035
|
+
if (!state?.table) return null;
|
|
8036
|
+
return {
|
|
8037
|
+
rowCount: await state.table.countRows(),
|
|
8038
|
+
version: typeof state.table.version === "function" ? await state.table.version() : 0
|
|
8039
|
+
};
|
|
8040
|
+
}
|
|
8041
|
+
function optimizeSemanticIndex(dataDir, profile) {
|
|
8042
|
+
const key = stateKey(dataDir, profile);
|
|
8043
|
+
return queueOperation(key, async () => {
|
|
8044
|
+
const state = await getState(dataDir, profile);
|
|
8045
|
+
if (state) await optimizeState(state);
|
|
8046
|
+
mutationCounts.set(key, 0);
|
|
8047
|
+
});
|
|
8048
|
+
}
|
|
8049
|
+
async function optimizeSemanticIndexes(dataDir) {
|
|
8050
|
+
if (!existsSync8(indexRoot(dataDir))) return [];
|
|
8051
|
+
const lance = await loadLanceDb();
|
|
8052
|
+
if (!lance) throw new Error("LanceDB is unavailable; install the optional @lancedb/lancedb package");
|
|
8053
|
+
const connection = await lance.connect(indexRoot(dataDir));
|
|
8054
|
+
try {
|
|
8055
|
+
const names = typeof connection.tableNames === "function" ? await connection.tableNames() : (await connection.listTables()).tables;
|
|
8056
|
+
const optimized = [];
|
|
8057
|
+
for (const name of names.filter((value) => value.startsWith(TABLE_PREFIX))) {
|
|
8058
|
+
const table = await connection.openTable(name);
|
|
8059
|
+
await table.optimize({
|
|
8060
|
+
cleanupOlderThan: new Date(Date.now() - semanticVersionRetentionMs()),
|
|
8061
|
+
deleteUnverified: false
|
|
8062
|
+
});
|
|
8063
|
+
optimized.push(name);
|
|
8064
|
+
}
|
|
8065
|
+
return optimized;
|
|
8066
|
+
} finally {
|
|
8067
|
+
try {
|
|
8068
|
+
connection.close?.();
|
|
8069
|
+
} catch {
|
|
8070
|
+
}
|
|
8071
|
+
}
|
|
8072
|
+
}
|
|
7968
8073
|
function deleteSemanticVector(dataDir, profile, observationId2) {
|
|
7969
8074
|
return queueOperation(stateKey(dataDir, profile), async () => {
|
|
7970
8075
|
const state = await getState(dataDir, profile);
|
|
@@ -8024,6 +8129,8 @@ async function searchSemanticVectors(options) {
|
|
|
8024
8129
|
})).filter((row) => Number.isFinite(row.distance));
|
|
8025
8130
|
}
|
|
8026
8131
|
async function closeSemanticIndexes() {
|
|
8132
|
+
await Promise.all([...pendingVectorBatches.keys()].map((key) => flushPendingVectorBatch(key)));
|
|
8133
|
+
await Promise.all([...writeQueues.values()]);
|
|
8027
8134
|
for (const statePromise of statePromises.values()) {
|
|
8028
8135
|
const state = await statePromise.catch(() => null);
|
|
8029
8136
|
try {
|
|
@@ -8034,9 +8141,12 @@ async function closeSemanticIndexes() {
|
|
|
8034
8141
|
statePromises.clear();
|
|
8035
8142
|
writeQueues.clear();
|
|
8036
8143
|
indexBuilds.clear();
|
|
8144
|
+
mutationCounts.clear();
|
|
8037
8145
|
}
|
|
8038
8146
|
async function closeSemanticIndex(dataDir) {
|
|
8039
8147
|
const prefix = `${path11.resolve(dataDir)}::`;
|
|
8148
|
+
await Promise.all([...pendingVectorBatches.keys()].filter((key) => key.startsWith(prefix)).map(flushPendingVectorBatch));
|
|
8149
|
+
await Promise.all([...writeQueues.entries()].filter(([key]) => key.startsWith(prefix)).map(([, queue]) => queue));
|
|
8040
8150
|
for (const [key, statePromise] of statePromises.entries()) {
|
|
8041
8151
|
if (!key.startsWith(prefix)) continue;
|
|
8042
8152
|
const state = await statePromise.catch(() => null);
|
|
@@ -8047,15 +8157,21 @@ async function closeSemanticIndex(dataDir) {
|
|
|
8047
8157
|
statePromises.delete(key);
|
|
8048
8158
|
writeQueues.delete(key);
|
|
8049
8159
|
indexBuilds.delete(key);
|
|
8160
|
+
mutationCounts.delete(key);
|
|
8050
8161
|
}
|
|
8051
8162
|
}
|
|
8052
8163
|
function resetSemanticIndexRuntime() {
|
|
8164
|
+
for (const pending of pendingVectorBatches.values()) {
|
|
8165
|
+
if (pending.timer) clearTimeout(pending.timer);
|
|
8166
|
+
}
|
|
8167
|
+
pendingVectorBatches.clear();
|
|
8053
8168
|
statePromises.clear();
|
|
8054
8169
|
writeQueues.clear();
|
|
8055
8170
|
indexBuilds.clear();
|
|
8171
|
+
mutationCounts.clear();
|
|
8056
8172
|
availability = void 0;
|
|
8057
8173
|
}
|
|
8058
|
-
var SEMANTIC_INDEX_DIR, TABLE_PREFIX, DEFAULT_INDEX_THRESHOLD, MAX_INDEX_PARTITIONS, statePromises, writeQueues, indexBuilds, availability, requireFromHere2;
|
|
8174
|
+
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;
|
|
8059
8175
|
var init_semantic_index = __esm({
|
|
8060
8176
|
"src/search/semantic-index.ts"() {
|
|
8061
8177
|
"use strict";
|
|
@@ -8064,13 +8180,84 @@ var init_semantic_index = __esm({
|
|
|
8064
8180
|
TABLE_PREFIX = "observations_";
|
|
8065
8181
|
DEFAULT_INDEX_THRESHOLD = 1e4;
|
|
8066
8182
|
MAX_INDEX_PARTITIONS = 32;
|
|
8183
|
+
DEFAULT_WRITE_BATCH_SIZE = 100;
|
|
8184
|
+
DEFAULT_WRITE_FLUSH_MS = 50;
|
|
8185
|
+
DEFAULT_OPTIMIZE_EVERY = 20;
|
|
8186
|
+
DEFAULT_VERSION_RETENTION_MS = 24 * 60 * 60 * 1e3;
|
|
8067
8187
|
statePromises = /* @__PURE__ */ new Map();
|
|
8068
8188
|
writeQueues = /* @__PURE__ */ new Map();
|
|
8069
8189
|
indexBuilds = /* @__PURE__ */ new Map();
|
|
8190
|
+
mutationCounts = /* @__PURE__ */ new Map();
|
|
8191
|
+
pendingVectorBatches = /* @__PURE__ */ new Map();
|
|
8070
8192
|
requireFromHere2 = createRequire3(import.meta.url);
|
|
8071
8193
|
}
|
|
8072
8194
|
});
|
|
8073
8195
|
|
|
8196
|
+
// src/memory/secret-filter.ts
|
|
8197
|
+
function applyRedaction(text3) {
|
|
8198
|
+
if (!text3) return text3;
|
|
8199
|
+
let out = text3;
|
|
8200
|
+
out = out.replace(
|
|
8201
|
+
/((?:password|passwd|pwd|secret|token|api[_-]?key|auth[_-]?key|access[_-]?key|private[_-]?key|client[_-]?secret)\s*[:=]\s*["']?)([^\s"',;\n]{6,})/gi,
|
|
8202
|
+
"$1[REDACTED]"
|
|
8203
|
+
);
|
|
8204
|
+
out = out.replace(
|
|
8205
|
+
/(Bearer\s+)([A-Za-z0-9._\-/+]{20,})/g,
|
|
8206
|
+
"$1[REDACTED]"
|
|
8207
|
+
);
|
|
8208
|
+
out = out.replace(/\b(?:ghp|ghs|gho|github_pat)_[A-Za-z0-9]{36,}\b/g, "[REDACTED]");
|
|
8209
|
+
out = out.replace(/\bsk-[A-Za-z0-9T-]{20,}\b/g, "[REDACTED]");
|
|
8210
|
+
out = out.replace(/\beyJ[A-Za-z0-9._-]{40,}\b/g, "[REDACTED]");
|
|
8211
|
+
return out;
|
|
8212
|
+
}
|
|
8213
|
+
function sanitizeCredentials(text3) {
|
|
8214
|
+
return applyRedaction(text3);
|
|
8215
|
+
}
|
|
8216
|
+
function redactCredentials(text3) {
|
|
8217
|
+
return applyRedaction(text3);
|
|
8218
|
+
}
|
|
8219
|
+
var init_secret_filter = __esm({
|
|
8220
|
+
"src/memory/secret-filter.ts"() {
|
|
8221
|
+
"use strict";
|
|
8222
|
+
init_esm_shims();
|
|
8223
|
+
}
|
|
8224
|
+
});
|
|
8225
|
+
|
|
8226
|
+
// src/search/derived-view-receipt.ts
|
|
8227
|
+
function sanitizeDerivedViewFailureReason(reason) {
|
|
8228
|
+
const safe = sanitizeCredentials(reason).replace(/(?:[A-Za-z]:[\\/]|\\\\[^\\/\s]+[\\/]|\/(?:home|Users|tmp|var|private|mnt|workspace|workspaces)\/)[^\s"'<>|]*/gi, "[path]").replace(/\s+/g, " ").trim();
|
|
8229
|
+
return safe.slice(0, 240) || "derived view failed";
|
|
8230
|
+
}
|
|
8231
|
+
function embeddingHealthReceipt(health, embeddingEnabled2) {
|
|
8232
|
+
if (health?.status === "disabled") {
|
|
8233
|
+
return { freshness: "current", rebuildStatus: "disabled" };
|
|
8234
|
+
}
|
|
8235
|
+
if (health?.status === "ready" || embeddingEnabled2) {
|
|
8236
|
+
return { freshness: "current", rebuildStatus: "idle" };
|
|
8237
|
+
}
|
|
8238
|
+
if (health?.status === "degraded") {
|
|
8239
|
+
return {
|
|
8240
|
+
freshness: "stale",
|
|
8241
|
+
rebuildStatus: "failed",
|
|
8242
|
+
...health.failure ? {
|
|
8243
|
+
failureReason: `embedding ${health.failure.kind}; retry in ${health.failure.retryAfterMs}ms`
|
|
8244
|
+
} : { failureReason: "embedding provider degraded" }
|
|
8245
|
+
};
|
|
8246
|
+
}
|
|
8247
|
+
return {
|
|
8248
|
+
freshness: "unknown",
|
|
8249
|
+
rebuildStatus: "unavailable",
|
|
8250
|
+
failureReason: "embedding provider is not initialized"
|
|
8251
|
+
};
|
|
8252
|
+
}
|
|
8253
|
+
var init_derived_view_receipt = __esm({
|
|
8254
|
+
"src/search/derived-view-receipt.ts"() {
|
|
8255
|
+
"use strict";
|
|
8256
|
+
init_esm_shims();
|
|
8257
|
+
init_secret_filter();
|
|
8258
|
+
}
|
|
8259
|
+
});
|
|
8260
|
+
|
|
8074
8261
|
// src/project/aliases.ts
|
|
8075
8262
|
var aliases_exports = {};
|
|
8076
8263
|
__export(aliases_exports, {
|
|
@@ -8679,6 +8866,7 @@ __export(orama_store_exports, {
|
|
|
8679
8866
|
getLastSearchMode: () => getLastSearchMode,
|
|
8680
8867
|
getObservationCount: () => getObservationCount,
|
|
8681
8868
|
getObservationsByIds: () => getObservationsByIds,
|
|
8869
|
+
getPersistentSemanticVectorIds: () => getPersistentSemanticVectorIds,
|
|
8682
8870
|
getSearchDerivedViews: () => getSearchDerivedViews,
|
|
8683
8871
|
getTimeline: () => getTimeline,
|
|
8684
8872
|
getVectorDimensions: () => getVectorDimensions,
|
|
@@ -8723,14 +8911,16 @@ function getSearchDerivedViews() {
|
|
|
8723
8911
|
generation,
|
|
8724
8912
|
freshness: "unknown",
|
|
8725
8913
|
rebuildStatus: "unavailable",
|
|
8726
|
-
failureReason:
|
|
8914
|
+
failureReason: sanitizeDerivedViewFailureReason(
|
|
8915
|
+
store.getBackendReason?.() ?? "persistent lexical index unavailable"
|
|
8916
|
+
)
|
|
8727
8917
|
};
|
|
8728
8918
|
}
|
|
8729
8919
|
} catch (error) {
|
|
8730
8920
|
views.fts = {
|
|
8731
8921
|
freshness: "unknown",
|
|
8732
8922
|
rebuildStatus: "failed",
|
|
8733
|
-
failureReason: error instanceof Error ? error.message
|
|
8923
|
+
failureReason: sanitizeDerivedViewFailureReason(error instanceof Error ? error.message : String(error))
|
|
8734
8924
|
};
|
|
8735
8925
|
}
|
|
8736
8926
|
} else {
|
|
@@ -8746,18 +8936,12 @@ function getSearchDerivedViews() {
|
|
|
8746
8936
|
rebuildStatus: "unavailable",
|
|
8747
8937
|
failureReason: "Orama index is not initialized"
|
|
8748
8938
|
};
|
|
8749
|
-
|
|
8750
|
-
|
|
8751
|
-
|
|
8752
|
-
}
|
|
8753
|
-
views.embedding = { freshness: "current", rebuildStatus: "idle" };
|
|
8754
|
-
} else {
|
|
8755
|
-
views.embedding = {
|
|
8756
|
-
freshness: "unknown",
|
|
8757
|
-
rebuildStatus: "unavailable",
|
|
8758
|
-
failureReason: "embedding provider is not initialized"
|
|
8759
|
-
};
|
|
8939
|
+
let embeddingHealth;
|
|
8940
|
+
try {
|
|
8941
|
+
embeddingHealth = getEmbeddingRuntimeHealth?.();
|
|
8942
|
+
} catch {
|
|
8760
8943
|
}
|
|
8944
|
+
views.embedding = embeddingHealthReceipt(embeddingHealth, embeddingEnabled);
|
|
8761
8945
|
return views;
|
|
8762
8946
|
}
|
|
8763
8947
|
function rememberSearchDiagnostics(key, value) {
|
|
@@ -9061,12 +9245,16 @@ function getVectorDimensions() {
|
|
|
9061
9245
|
function getActiveSemanticIndexProfile() {
|
|
9062
9246
|
return indexEmbeddingProvider ? createSemanticIndexProfile(indexEmbeddingProvider) : null;
|
|
9063
9247
|
}
|
|
9248
|
+
async function getPersistentSemanticVectorIds(dataDir) {
|
|
9249
|
+
if (!indexEmbeddingProvider) return null;
|
|
9250
|
+
return listSemanticVectorIds(dataDir, createSemanticIndexProfile(indexEmbeddingProvider));
|
|
9251
|
+
}
|
|
9064
9252
|
async function queueSemanticVector(dataDir, record80) {
|
|
9065
9253
|
const provider2 = indexEmbeddingProvider ?? await getEmbeddingProvider();
|
|
9066
9254
|
const profile = provider2 ? createSemanticIndexProfile(provider2) : null;
|
|
9067
9255
|
if (!profile) return;
|
|
9068
9256
|
try {
|
|
9069
|
-
await
|
|
9257
|
+
await upsertSemanticVector(dataDir, profile, record80);
|
|
9070
9258
|
} catch {
|
|
9071
9259
|
}
|
|
9072
9260
|
}
|
|
@@ -9128,6 +9316,7 @@ function isCompatibleCachedVector(vector) {
|
|
|
9128
9316
|
async function attachCachedVectors(database, observations2) {
|
|
9129
9317
|
const semanticDataDir = (await Promise.resolve().then(() => (init_observations(), observations_exports))).getObservationDataDir();
|
|
9130
9318
|
const semanticProfile = getActiveSemanticIndexProfile();
|
|
9319
|
+
const persistedSemanticIds = semanticDataDir && semanticProfile ? await listSemanticVectorIds(semanticDataDir, semanticProfile).catch(() => null) : null;
|
|
9131
9320
|
const batchSize = 200;
|
|
9132
9321
|
for (let start = 0; start < observations2.length; start += batchSize) {
|
|
9133
9322
|
const batch = observations2.slice(start, start + batchSize);
|
|
@@ -9138,7 +9327,7 @@ async function attachCachedVectors(database, observations2) {
|
|
|
9138
9327
|
const vector = cachedVectors[index];
|
|
9139
9328
|
if (!isCompatibleCachedVector(vector)) continue;
|
|
9140
9329
|
const observation = batch[index];
|
|
9141
|
-
if (semanticDataDir && semanticProfile) {
|
|
9330
|
+
if (semanticDataDir && semanticProfile && !persistedSemanticIds?.has(observation.id)) {
|
|
9142
9331
|
semanticRecords.push({
|
|
9143
9332
|
observationId: observation.id,
|
|
9144
9333
|
projectId: observation.projectId,
|
|
@@ -9911,6 +10100,7 @@ var init_orama_store = __esm({
|
|
|
9911
10100
|
init_mini_skills();
|
|
9912
10101
|
init_visibility();
|
|
9913
10102
|
init_provider();
|
|
10103
|
+
init_provider();
|
|
9914
10104
|
init_project_affinity();
|
|
9915
10105
|
init_intent_detector();
|
|
9916
10106
|
init_query_expansion();
|
|
@@ -9918,6 +10108,7 @@ var init_orama_store = __esm({
|
|
|
9918
10108
|
init_timeout();
|
|
9919
10109
|
init_obs_store();
|
|
9920
10110
|
init_semantic_index();
|
|
10111
|
+
init_derived_view_receipt();
|
|
9921
10112
|
db = null;
|
|
9922
10113
|
dbInitPromise = null;
|
|
9923
10114
|
dbGeneration = 0;
|
|
@@ -10042,36 +10233,6 @@ var init_entity_extractor = __esm({
|
|
|
10042
10233
|
}
|
|
10043
10234
|
});
|
|
10044
10235
|
|
|
10045
|
-
// src/memory/secret-filter.ts
|
|
10046
|
-
function applyRedaction(text3) {
|
|
10047
|
-
if (!text3) return text3;
|
|
10048
|
-
let out = text3;
|
|
10049
|
-
out = out.replace(
|
|
10050
|
-
/((?:password|passwd|pwd|secret|token|api[_-]?key|auth[_-]?key|access[_-]?key|private[_-]?key|client[_-]?secret)\s*[:=]\s*["']?)([^\s"',;\n]{6,})/gi,
|
|
10051
|
-
"$1[REDACTED]"
|
|
10052
|
-
);
|
|
10053
|
-
out = out.replace(
|
|
10054
|
-
/(Bearer\s+)([A-Za-z0-9._\-/+]{20,})/g,
|
|
10055
|
-
"$1[REDACTED]"
|
|
10056
|
-
);
|
|
10057
|
-
out = out.replace(/\b(?:ghp|ghs|gho|github_pat)_[A-Za-z0-9]{36,}\b/g, "[REDACTED]");
|
|
10058
|
-
out = out.replace(/\bsk-[A-Za-z0-9T-]{20,}\b/g, "[REDACTED]");
|
|
10059
|
-
out = out.replace(/\beyJ[A-Za-z0-9._-]{40,}\b/g, "[REDACTED]");
|
|
10060
|
-
return out;
|
|
10061
|
-
}
|
|
10062
|
-
function sanitizeCredentials(text3) {
|
|
10063
|
-
return applyRedaction(text3);
|
|
10064
|
-
}
|
|
10065
|
-
function redactCredentials(text3) {
|
|
10066
|
-
return applyRedaction(text3);
|
|
10067
|
-
}
|
|
10068
|
-
var init_secret_filter = __esm({
|
|
10069
|
-
"src/memory/secret-filter.ts"() {
|
|
10070
|
-
"use strict";
|
|
10071
|
-
init_esm_shims();
|
|
10072
|
-
}
|
|
10073
|
-
});
|
|
10074
|
-
|
|
10075
10236
|
// src/runtime/maintenance-jobs.ts
|
|
10076
10237
|
var maintenance_jobs_exports = {};
|
|
10077
10238
|
__export(maintenance_jobs_exports, {
|
|
@@ -10922,7 +11083,7 @@ var init_maintenance_targets = __esm({
|
|
|
10922
11083
|
|
|
10923
11084
|
// src/runtime/isolated-maintenance.ts
|
|
10924
11085
|
import { spawn } from "child_process";
|
|
10925
|
-
import { existsSync as
|
|
11086
|
+
import { existsSync as existsSync9 } from "fs";
|
|
10926
11087
|
import os4 from "os";
|
|
10927
11088
|
import path13 from "path";
|
|
10928
11089
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
@@ -10940,7 +11101,7 @@ function childError(prefix, detail) {
|
|
|
10940
11101
|
}
|
|
10941
11102
|
function isolatedMaintenanceCwd() {
|
|
10942
11103
|
const tmp = os4.tmpdir();
|
|
10943
|
-
return
|
|
11104
|
+
return existsSync9(tmp) ? tmp : process.cwd();
|
|
10944
11105
|
}
|
|
10945
11106
|
function resolveMaintenanceRunnerPath(moduleUrl = import.meta.url) {
|
|
10946
11107
|
const moduleDir = path13.dirname(fileURLToPath2(moduleUrl));
|
|
@@ -10997,7 +11158,7 @@ function collectOutput(stream2, limit2, onOverflow) {
|
|
|
10997
11158
|
async function runMaintenanceInChildProcess(request, options = {}) {
|
|
10998
11159
|
validateRequest(request);
|
|
10999
11160
|
const runnerPath = options.runnerPath ?? resolveMaintenanceRunnerPath();
|
|
11000
|
-
if (!
|
|
11161
|
+
if (!existsSync9(runnerPath)) {
|
|
11001
11162
|
throw new Error(`Maintenance runner is unavailable at ${runnerPath}. Reinstall or rebuild Memorix.`);
|
|
11002
11163
|
}
|
|
11003
11164
|
const timeoutMs = Number.isFinite(options.timeoutMs) ? Math.max(1e3, Math.floor(options.timeoutMs)) : DEFAULT_TIMEOUT_MS;
|
|
@@ -146152,7 +146313,7 @@ __export(video_jobs_exports, {
|
|
|
146152
146313
|
runMiniMaxVideoGenerationJob: () => runMiniMaxVideoGenerationJob
|
|
146153
146314
|
});
|
|
146154
146315
|
import { spawn as spawn2 } from "child_process";
|
|
146155
|
-
import { existsSync as
|
|
146316
|
+
import { existsSync as existsSync10 } from "fs";
|
|
146156
146317
|
import path19 from "path";
|
|
146157
146318
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
146158
146319
|
function safeError2(error) {
|
|
@@ -146400,7 +146561,7 @@ function resolveMediaVideoRunnerPath(moduleUrl = import.meta.url) {
|
|
|
146400
146561
|
}
|
|
146401
146562
|
function launchMediaVideoRunner(request, options = {}) {
|
|
146402
146563
|
const runnerPath = options.runnerPath ?? resolveMediaVideoRunnerPath();
|
|
146403
|
-
if (!
|
|
146564
|
+
if (!existsSync10(runnerPath)) {
|
|
146404
146565
|
return { launched: false, reason: "Media video runner is unavailable until Memorix is built or reinstalled." };
|
|
146405
146566
|
}
|
|
146406
146567
|
try {
|
|
@@ -146445,7 +146606,7 @@ __export(audio_jobs_exports, {
|
|
|
146445
146606
|
transcribeAudio: () => transcribeAudio
|
|
146446
146607
|
});
|
|
146447
146608
|
import { spawn as spawn3 } from "child_process";
|
|
146448
|
-
import { existsSync as
|
|
146609
|
+
import { existsSync as existsSync11 } from "fs";
|
|
146449
146610
|
import path20 from "path";
|
|
146450
146611
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
146451
146612
|
function safeError3(error) {
|
|
@@ -146696,7 +146857,7 @@ function resolveMediaAudioRunnerPath(moduleUrl = import.meta.url) {
|
|
|
146696
146857
|
}
|
|
146697
146858
|
function launchMediaAudioRunner(request, options = {}) {
|
|
146698
146859
|
const runnerPath = options.runnerPath ?? resolveMediaAudioRunnerPath();
|
|
146699
|
-
if (!
|
|
146860
|
+
if (!existsSync11(runnerPath)) return { launched: false, reason: "Audio runner is unavailable until Memorix is built or reinstalled." };
|
|
146700
146861
|
try {
|
|
146701
146862
|
const child = spawn3(process.execPath, [runnerPath, JSON.stringify(request)], {
|
|
146702
146863
|
cwd: request.projectRoot,
|
|
@@ -149665,7 +149826,7 @@ __export(lite_provider_exports, {
|
|
|
149665
149826
|
refreshProjectLite: () => refreshProjectLite
|
|
149666
149827
|
});
|
|
149667
149828
|
import { createHash as createHash11 } from "crypto";
|
|
149668
|
-
import { existsSync as
|
|
149829
|
+
import { existsSync as existsSync13, readdirSync as readdirSync2, readFileSync as readFileSync8, statSync as statSync3 } from "fs";
|
|
149669
149830
|
import { join as join4, relative as relative2 } from "path";
|
|
149670
149831
|
function hashText2(text3) {
|
|
149671
149832
|
return createHash11("sha256").update(text3).digest("hex");
|
|
@@ -149683,7 +149844,7 @@ function resolveMaxFileBytes(value) {
|
|
|
149683
149844
|
return Math.max(1, Math.floor(value));
|
|
149684
149845
|
}
|
|
149685
149846
|
function isPythonVirtualenvDir(dir) {
|
|
149686
|
-
return
|
|
149847
|
+
return existsSync13(join4(dir, "pyvenv.cfg"));
|
|
149687
149848
|
}
|
|
149688
149849
|
function walk(root, exclude, maxFiles) {
|
|
149689
149850
|
const out = [];
|
|
@@ -153599,7 +153760,7 @@ __export(vector_backfill_runner_exports, {
|
|
|
153599
153760
|
import { spawn as spawn4 } from "child_process";
|
|
153600
153761
|
import {
|
|
153601
153762
|
closeSync,
|
|
153602
|
-
existsSync as
|
|
153763
|
+
existsSync as existsSync14,
|
|
153603
153764
|
mkdirSync as mkdirSync2,
|
|
153604
153765
|
openSync,
|
|
153605
153766
|
readFileSync as readFileSync9,
|
|
@@ -153727,7 +153888,7 @@ function releaseVectorBackfillLock(lockPath = process.env.MEMORIX_VECTOR_BACKFIL
|
|
|
153727
153888
|
}
|
|
153728
153889
|
function launchDetachedVectorBackfill(request, options = {}) {
|
|
153729
153890
|
const runnerPath = options.runnerPath ?? resolveVectorBackfillRunnerPath();
|
|
153730
|
-
const exists = options.exists ??
|
|
153891
|
+
const exists = options.exists ?? existsSync14;
|
|
153731
153892
|
if (!exists(runnerPath)) return false;
|
|
153732
153893
|
const lock = acquireVectorBackfillLock(request.dataDir, request.projectId, options.lockPath);
|
|
153733
153894
|
if (!lock) return false;
|
|
@@ -154746,13 +154907,14 @@ async function prepareSearchIndex(options = {}) {
|
|
|
154746
154907
|
return 0;
|
|
154747
154908
|
}
|
|
154748
154909
|
const hydratedProjectDir = projectDir;
|
|
154749
|
-
const queueMissingVectors = () => {
|
|
154750
|
-
if (projectDir !== hydratedProjectDir) return;
|
|
154910
|
+
const queueMissingVectors = async () => {
|
|
154911
|
+
if (!hydratedProjectDir || projectDir !== hydratedProjectDir) return;
|
|
154751
154912
|
vectorMissingIds.clear();
|
|
154752
154913
|
if (!isEmbeddingExplicitlyDisabled()) {
|
|
154914
|
+
const persistedSemanticIds = await getPersistentSemanticVectorIds(hydratedProjectDir).catch(() => null);
|
|
154753
154915
|
const projectsWithMissingVectors = /* @__PURE__ */ new Set();
|
|
154754
154916
|
for (const obs of observations) {
|
|
154755
|
-
if (!hasObservationVector(obs.projectId, obs.id)) {
|
|
154917
|
+
if (!hasObservationVector(obs.projectId, obs.id) && !persistedSemanticIds?.has(obs.id)) {
|
|
154756
154918
|
vectorMissingIds.add(obs.id);
|
|
154757
154919
|
projectsWithMissingVectors.add(obs.projectId);
|
|
154758
154920
|
}
|
|
@@ -154762,9 +154924,9 @@ async function prepareSearchIndex(options = {}) {
|
|
|
154762
154924
|
};
|
|
154763
154925
|
const cacheHydration = getDeferredCachedVectorHydration();
|
|
154764
154926
|
if (cacheHydration) {
|
|
154765
|
-
void cacheHydration.
|
|
154927
|
+
void cacheHydration.then(queueMissingVectors, queueMissingVectors).catch(() => void 0);
|
|
154766
154928
|
} else {
|
|
154767
|
-
queueMissingVectors();
|
|
154929
|
+
await queueMissingVectors();
|
|
154768
154930
|
}
|
|
154769
154931
|
searchIndexPrepared = true;
|
|
154770
154932
|
return count2;
|
|
@@ -156430,7 +156592,7 @@ __export(behavior_exports, {
|
|
|
156430
156592
|
getBehaviorConfig: () => getBehaviorConfig,
|
|
156431
156593
|
resetBehaviorConfigCache: () => resetBehaviorConfigCache
|
|
156432
156594
|
});
|
|
156433
|
-
import { existsSync as
|
|
156595
|
+
import { existsSync as existsSync17, readFileSync as readFileSync11 } from "fs";
|
|
156434
156596
|
import { homedir as homedir22 } from "os";
|
|
156435
156597
|
function isSessionInject(value) {
|
|
156436
156598
|
return value === "full" || value === "minimal" || value === "silent";
|
|
@@ -156441,7 +156603,7 @@ function isFormationMode(value) {
|
|
|
156441
156603
|
function legacyBehavior(homeDir) {
|
|
156442
156604
|
const configPath = getLegacyConfigJsonPath(homeDir);
|
|
156443
156605
|
try {
|
|
156444
|
-
if (!
|
|
156606
|
+
if (!existsSync17(configPath)) return {};
|
|
156445
156607
|
const parsed = JSON.parse(readFileSync11(configPath, "utf-8"));
|
|
156446
156608
|
return parsed.behavior && typeof parsed.behavior === "object" && !Array.isArray(parsed.behavior) ? parsed.behavior : {};
|
|
156447
156609
|
} catch {
|
|
@@ -157887,11 +158049,11 @@ __export(current_facts_exports, {
|
|
|
157887
158049
|
formatGitFact: () => formatGitFact
|
|
157888
158050
|
});
|
|
157889
158051
|
import { execFileSync } from "child_process";
|
|
157890
|
-
import { existsSync as
|
|
158052
|
+
import { existsSync as existsSync18, readFileSync as readFileSync12 } from "fs";
|
|
157891
158053
|
import path29 from "path";
|
|
157892
158054
|
function readTextIfExists(filePath) {
|
|
157893
158055
|
try {
|
|
157894
|
-
if (!
|
|
158056
|
+
if (!existsSync18(filePath)) return null;
|
|
157895
158057
|
return readFileSync12(filePath, "utf8");
|
|
157896
158058
|
} catch {
|
|
157897
158059
|
return null;
|
|
@@ -158182,7 +158344,7 @@ __export(external_provider_exports, {
|
|
|
158182
158344
|
runExternalCodeGraphLifecycle: () => runExternalCodeGraphLifecycle
|
|
158183
158345
|
});
|
|
158184
158346
|
import { spawn as spawn5 } from "child_process";
|
|
158185
|
-
import { existsSync as
|
|
158347
|
+
import { existsSync as existsSync19, readFileSync as readFileSync13 } from "fs";
|
|
158186
158348
|
import { delimiter, dirname as dirname2, extname, isAbsolute as isAbsolute3, join as join20, relative as relative4, resolve as resolve3, sep } from "path";
|
|
158187
158349
|
function boundedTimeout(value) {
|
|
158188
158350
|
if (!Number.isFinite(value)) return DEFAULT_EXTERNAL_CODEGRAPH_TIMEOUT_MS;
|
|
@@ -158219,13 +158381,13 @@ function resolveCommandCandidates(command) {
|
|
|
158219
158381
|
}
|
|
158220
158382
|
function resolveLaunch(command) {
|
|
158221
158383
|
for (const candidate of resolveCommandCandidates(command)) {
|
|
158222
|
-
if (!
|
|
158384
|
+
if (!existsSync19(candidate)) continue;
|
|
158223
158385
|
const extension3 = extname(candidate).toLowerCase();
|
|
158224
158386
|
if (extension3 === ".cmd") {
|
|
158225
158387
|
const bundleRoot = resolve3(dirname2(candidate), "..");
|
|
158226
158388
|
const node = join20(bundleRoot, "node.exe");
|
|
158227
158389
|
const entry = join20(bundleRoot, "lib", "dist", "bin", "codegraph.js");
|
|
158228
|
-
if (
|
|
158390
|
+
if (existsSync19(node) && existsSync19(entry)) {
|
|
158229
158391
|
return { executable: node, prefixArgs: ["--liftoff-only", entry] };
|
|
158230
158392
|
}
|
|
158231
158393
|
try {
|
|
@@ -158234,7 +158396,7 @@ function resolveLaunch(command) {
|
|
|
158234
158396
|
if (match2?.[1]) {
|
|
158235
158397
|
const base = dirname2(candidate).endsWith(sep) ? dirname2(candidate) : dirname2(candidate) + sep;
|
|
158236
158398
|
const entry2 = resolve3(match2[1].replace(/%(?:~)?dp0%?/gi, base));
|
|
158237
|
-
if (
|
|
158399
|
+
if (existsSync19(entry2)) return { executable: process.execPath, prefixArgs: [entry2] };
|
|
158238
158400
|
}
|
|
158239
158401
|
} catch {
|
|
158240
158402
|
}
|
|
@@ -158382,7 +158544,7 @@ async function inspectExternalCodeGraph(input) {
|
|
|
158382
158544
|
const health2 = { state: "disabled", reason: "External CodeGraph is disabled by configuration." };
|
|
158383
158545
|
return { health: health2, quality: providerQuality({ mode, health: health2 }) };
|
|
158384
158546
|
}
|
|
158385
|
-
if (!
|
|
158547
|
+
if (!existsSync19(join20(input.projectRoot, ".codegraph"))) {
|
|
158386
158548
|
const health2 = { state: "not-detected", reason: "No local .codegraph index is present for this project." };
|
|
158387
158549
|
return { health: health2, quality: providerQuality({ mode, health: health2 }) };
|
|
158388
158550
|
}
|
|
@@ -158418,7 +158580,7 @@ async function runExternalCodeGraphLifecycle(input) {
|
|
|
158418
158580
|
};
|
|
158419
158581
|
}
|
|
158420
158582
|
const indexPath = join20(input.projectRoot, ".codegraph");
|
|
158421
|
-
if (input.action === "sync" && !
|
|
158583
|
+
if (input.action === "sync" && !existsSync19(indexPath)) {
|
|
158422
158584
|
const health = { state: "not-detected", reason: "No local .codegraph index is present for this project." };
|
|
158423
158585
|
return {
|
|
158424
158586
|
action: input.action,
|
|
@@ -158428,7 +158590,7 @@ async function runExternalCodeGraphLifecycle(input) {
|
|
|
158428
158590
|
quality: providerQuality({ mode, health })
|
|
158429
158591
|
};
|
|
158430
158592
|
}
|
|
158431
|
-
if (input.action === "init" &&
|
|
158593
|
+
if (input.action === "init" && existsSync19(indexPath)) {
|
|
158432
158594
|
const inspected2 = await inspectExternalCodeGraph(input);
|
|
158433
158595
|
return {
|
|
158434
158596
|
action: input.action,
|
|
@@ -159190,13 +159352,13 @@ function buildCodeGraphDerivedView(input) {
|
|
|
159190
159352
|
...snapshot.sourceEpoch !== void 0 ? { generation: snapshot.sourceEpoch } : {},
|
|
159191
159353
|
freshness: snapshot.incomplete ? "stale" : "current",
|
|
159192
159354
|
rebuildStatus: snapshot.incomplete ? "failed" : "idle",
|
|
159193
|
-
...snapshot.incomplete ? { failureReason: "latest CodeGraph snapshot is incomplete" } : externalFailure && provider2?.external.reason ? { failureReason: provider2.external.reason
|
|
159355
|
+
...snapshot.incomplete ? { failureReason: "latest CodeGraph snapshot is incomplete" } : externalFailure && provider2?.external.reason ? { failureReason: sanitizeDerivedViewFailureReason(provider2.external.reason) } : {}
|
|
159194
159356
|
};
|
|
159195
159357
|
}
|
|
159196
159358
|
return {
|
|
159197
159359
|
freshness: "unknown",
|
|
159198
159360
|
rebuildStatus: externalFailure ? "failed" : "unavailable",
|
|
159199
|
-
...provider2?.external.reason ? { failureReason: provider2.external.reason
|
|
159361
|
+
...provider2?.external.reason ? { failureReason: sanitizeDerivedViewFailureReason(provider2.external.reason) } : { failureReason: "CodeGraph snapshot is not initialized" }
|
|
159200
159362
|
};
|
|
159201
159363
|
}
|
|
159202
159364
|
function buildBoundedContextReceipt(input) {
|
|
@@ -159226,6 +159388,7 @@ var init_context_receipt = __esm({
|
|
|
159226
159388
|
"src/knowledge/context-receipt.ts"() {
|
|
159227
159389
|
"use strict";
|
|
159228
159390
|
init_esm_shims();
|
|
159391
|
+
init_derived_view_receipt();
|
|
159229
159392
|
}
|
|
159230
159393
|
});
|
|
159231
159394
|
|
|
@@ -159842,7 +160005,7 @@ __export(auto_context_exports, {
|
|
|
159842
160005
|
formatAutoProjectContextSummary: () => formatAutoProjectContextSummary,
|
|
159843
160006
|
formatLegacyAutoProjectContextPrompt: () => formatLegacyAutoProjectContextPrompt
|
|
159844
160007
|
});
|
|
159845
|
-
import { existsSync as
|
|
160008
|
+
import { existsSync as existsSync20, statSync as statSync5 } from "fs";
|
|
159846
160009
|
import path30 from "path";
|
|
159847
160010
|
function activeProjectObservations(observations2, projectId) {
|
|
159848
160011
|
return observations2.filter((obs) => obs.projectId === projectId && (obs.status ?? "active") === "active");
|
|
@@ -160217,7 +160380,7 @@ function existingLensCandidates(rootPath, lens) {
|
|
|
160217
160380
|
for (const candidate of lensPathCandidates(lens)) {
|
|
160218
160381
|
const absolute = path30.join(rootPath, candidate);
|
|
160219
160382
|
try {
|
|
160220
|
-
if (!
|
|
160383
|
+
if (!existsSync20(absolute)) continue;
|
|
160221
160384
|
const stat5 = statSync5(absolute);
|
|
160222
160385
|
if (stat5.isFile()) out.push(candidate);
|
|
160223
160386
|
if (stat5.isDirectory()) out.push(candidate.replace(/\\/g, "/"));
|
|
@@ -160741,7 +160904,7 @@ var engine_exports2 = {};
|
|
|
160741
160904
|
__export(engine_exports2, {
|
|
160742
160905
|
SkillsEngine: () => SkillsEngine
|
|
160743
160906
|
});
|
|
160744
|
-
import { existsSync as
|
|
160907
|
+
import { existsSync as existsSync21, readFileSync as readFileSync14, writeFileSync as writeFileSync4, mkdirSync as mkdirSync5, readdirSync as readdirSync4 } from "fs";
|
|
160745
160908
|
import { join as join21 } from "path";
|
|
160746
160909
|
import { homedir as homedir23 } from "os";
|
|
160747
160910
|
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;
|
|
@@ -160822,7 +160985,7 @@ var init_engine3 = __esm({
|
|
|
160822
160985
|
paths.push(join21(home, dir));
|
|
160823
160986
|
}
|
|
160824
160987
|
for (const skillsRoot of paths) {
|
|
160825
|
-
if (!
|
|
160988
|
+
if (!existsSync21(skillsRoot)) continue;
|
|
160826
160989
|
try {
|
|
160827
160990
|
const entries = readdirSync4(skillsRoot, { withFileTypes: true });
|
|
160828
160991
|
for (const entry of entries) {
|
|
@@ -160830,7 +160993,7 @@ var init_engine3 = __esm({
|
|
|
160830
160993
|
const name = entry.name;
|
|
160831
160994
|
if (seen.has(name)) continue;
|
|
160832
160995
|
const skillMd = join21(skillsRoot, name, "SKILL.md");
|
|
160833
|
-
if (!
|
|
160996
|
+
if (!existsSync21(skillMd)) continue;
|
|
160834
160997
|
try {
|
|
160835
160998
|
const content = readFileSync14(skillMd, "utf-8");
|
|
160836
160999
|
const description = this.parseDescription(content);
|
|
@@ -163854,7 +164017,7 @@ async function handleApi(req, res, dataDir, projectId, projectName, baseDir, pro
|
|
|
163854
164017
|
}
|
|
163855
164018
|
case "/config": {
|
|
163856
164019
|
const os6 = await import("os");
|
|
163857
|
-
const { existsSync:
|
|
164020
|
+
const { existsSync: existsSync24 } = await import("fs");
|
|
163858
164021
|
const { join: join25 } = await import("path");
|
|
163859
164022
|
const configProjectRoot = effectiveProjectRoot;
|
|
163860
164023
|
const resolved = getResolvedConfig({ projectRoot: configProjectRoot });
|
|
@@ -163882,7 +164045,7 @@ async function handleApi(req, res, dataDir, projectId, projectName, baseDir, pro
|
|
|
163882
164045
|
if (fpath === null) {
|
|
163883
164046
|
files[key] = { exists: false, path: "unavailable", unavailable: true };
|
|
163884
164047
|
} else {
|
|
163885
|
-
files[key] = { exists:
|
|
164048
|
+
files[key] = { exists: existsSync24(fpath), path: fpath };
|
|
163886
164049
|
}
|
|
163887
164050
|
}
|
|
163888
164051
|
} catch {
|
|
@@ -164694,7 +164857,7 @@ var init_task_graph = __esm({
|
|
|
164694
164857
|
|
|
164695
164858
|
// src/orchestrate/context-collector.ts
|
|
164696
164859
|
import { execFileSync as execFileSync2 } from "child_process";
|
|
164697
|
-
import { readFileSync as readFileSync15, existsSync as
|
|
164860
|
+
import { readFileSync as readFileSync15, existsSync as existsSync22 } from "fs";
|
|
164698
164861
|
import { join as join22 } from "path";
|
|
164699
164862
|
function normalizeEntryLimit(value, fallback) {
|
|
164700
164863
|
if (!Number.isSafeInteger(value) || value < 1) return fallback;
|
|
@@ -164771,7 +164934,7 @@ function collectFileTree(projectDir2, maxEntries) {
|
|
|
164771
164934
|
function collectDependencies(projectDir2) {
|
|
164772
164935
|
try {
|
|
164773
164936
|
const pkgPath = join22(projectDir2, "package.json");
|
|
164774
|
-
if (!
|
|
164937
|
+
if (!existsSync22(pkgPath)) return "";
|
|
164775
164938
|
const pkg = JSON.parse(readFileSync15(pkgPath, "utf-8"));
|
|
164776
164939
|
const parts = [];
|
|
164777
164940
|
if (pkg.dependencies && Object.keys(pkg.dependencies).length > 0) {
|
|
@@ -167592,11 +167755,11 @@ __export(hooks_path_exports, {
|
|
|
167592
167755
|
resolveGitDir: () => resolveGitDir,
|
|
167593
167756
|
resolveHooksDir: () => resolveHooksDir
|
|
167594
167757
|
});
|
|
167595
|
-
import { existsSync as
|
|
167758
|
+
import { existsSync as existsSync23, readFileSync as readFileSync16, statSync as statSync6, mkdirSync as mkdirSync6 } from "fs";
|
|
167596
167759
|
import path35 from "path";
|
|
167597
167760
|
function resolveGitDir(projectRoot) {
|
|
167598
167761
|
const dotGit = path35.join(projectRoot, ".git");
|
|
167599
|
-
if (!
|
|
167762
|
+
if (!existsSync23(dotGit)) return null;
|
|
167600
167763
|
const stat5 = statSync6(dotGit);
|
|
167601
167764
|
if (stat5.isDirectory()) {
|
|
167602
167765
|
return dotGit;
|
|
@@ -167608,7 +167771,7 @@ function resolveGitDir(projectRoot) {
|
|
|
167608
167771
|
if (match2) {
|
|
167609
167772
|
const gitdir = match2[1].trim();
|
|
167610
167773
|
const resolved = path35.isAbsolute(gitdir) ? gitdir : path35.resolve(projectRoot, gitdir);
|
|
167611
|
-
if (
|
|
167774
|
+
if (existsSync23(resolved)) {
|
|
167612
167775
|
return resolved;
|
|
167613
167776
|
}
|
|
167614
167777
|
}
|
|
@@ -169853,7 +170016,7 @@ var RulesSyncer = class {
|
|
|
169853
170016
|
|
|
169854
170017
|
// src/workspace/engine.ts
|
|
169855
170018
|
init_esm_shims();
|
|
169856
|
-
import { readFileSync as readFileSync10, readdirSync as readdirSync3, existsSync as
|
|
170019
|
+
import { readFileSync as readFileSync10, readdirSync as readdirSync3, existsSync as existsSync16, cpSync, mkdirSync as mkdirSync4 } from "fs";
|
|
169857
170020
|
import { join as join19 } from "path";
|
|
169858
170021
|
import { homedir as homedir21 } from "os";
|
|
169859
170022
|
|
|
@@ -170805,7 +170968,7 @@ function sanitize(input) {
|
|
|
170805
170968
|
|
|
170806
170969
|
// src/workspace/applier.ts
|
|
170807
170970
|
init_esm_shims();
|
|
170808
|
-
import { existsSync as
|
|
170971
|
+
import { existsSync as existsSync15, mkdirSync as mkdirSync3, copyFileSync, writeFileSync as writeFileSync3, unlinkSync as unlinkSync2, renameSync } from "fs";
|
|
170809
170972
|
import { dirname } from "path";
|
|
170810
170973
|
var WorkspaceSyncApplier = class {
|
|
170811
170974
|
/**
|
|
@@ -170831,7 +170994,7 @@ var WorkspaceSyncApplier = class {
|
|
|
170831
170994
|
for (const file of files) {
|
|
170832
170995
|
try {
|
|
170833
170996
|
const dir = dirname(file.filePath);
|
|
170834
|
-
if (!
|
|
170997
|
+
if (!existsSync15(dir)) {
|
|
170835
170998
|
mkdirSync3(dir, { recursive: true });
|
|
170836
170999
|
}
|
|
170837
171000
|
} catch (err) {
|
|
@@ -170840,7 +171003,7 @@ var WorkspaceSyncApplier = class {
|
|
|
170840
171003
|
}
|
|
170841
171004
|
}
|
|
170842
171005
|
for (const file of files) {
|
|
170843
|
-
if (
|
|
171006
|
+
if (existsSync15(file.filePath)) {
|
|
170844
171007
|
try {
|
|
170845
171008
|
const backupPath = file.filePath + `.backup-${Date.now()}`;
|
|
170846
171009
|
copyFileSync(file.filePath, backupPath);
|
|
@@ -170891,7 +171054,7 @@ var WorkspaceSyncApplier = class {
|
|
|
170891
171054
|
cleanBackups(backups) {
|
|
170892
171055
|
for (const backup of backups) {
|
|
170893
171056
|
try {
|
|
170894
|
-
if (
|
|
171057
|
+
if (existsSync15(backup.backupPath)) {
|
|
170895
171058
|
unlinkSync2(backup.backupPath);
|
|
170896
171059
|
}
|
|
170897
171060
|
} catch {
|
|
@@ -170956,7 +171119,7 @@ var WorkspaceSyncEngine = class _WorkspaceSyncEngine {
|
|
|
170956
171119
|
}
|
|
170957
171120
|
const merged = /* @__PURE__ */ new Map();
|
|
170958
171121
|
for (const path37 of pathsToCheck) {
|
|
170959
|
-
if (
|
|
171122
|
+
if (existsSync16(path37)) {
|
|
170960
171123
|
try {
|
|
170961
171124
|
const content = readFileSync10(path37, "utf-8");
|
|
170962
171125
|
const servers = adapter.parse(content);
|
|
@@ -171010,7 +171173,7 @@ var WorkspaceSyncEngine = class _WorkspaceSyncEngine {
|
|
|
171010
171173
|
const adapter = this.adapters.get(target);
|
|
171011
171174
|
const configPath = adapter.getConfigPath(this.projectRoot);
|
|
171012
171175
|
let configContent;
|
|
171013
|
-
if (target === "antigravity" &&
|
|
171176
|
+
if (target === "antigravity" && existsSync16(configPath)) {
|
|
171014
171177
|
try {
|
|
171015
171178
|
const existing = JSON.parse(readFileSync10(configPath, "utf-8"));
|
|
171016
171179
|
const generated = JSON.parse(adapter.generate(result.mcpServers.scanned));
|
|
@@ -171086,13 +171249,13 @@ var WorkspaceSyncEngine = class _WorkspaceSyncEngine {
|
|
|
171086
171249
|
join19(home, dir)
|
|
171087
171250
|
];
|
|
171088
171251
|
for (const skillsRoot of paths) {
|
|
171089
|
-
if (!
|
|
171252
|
+
if (!existsSync16(skillsRoot)) continue;
|
|
171090
171253
|
try {
|
|
171091
171254
|
const entries = readdirSync3(skillsRoot, { withFileTypes: true });
|
|
171092
171255
|
for (const entry of entries) {
|
|
171093
171256
|
if (!entry.isDirectory()) continue;
|
|
171094
171257
|
const skillMd = join19(skillsRoot, entry.name, "SKILL.md");
|
|
171095
|
-
if (!
|
|
171258
|
+
if (!existsSync16(skillMd)) continue;
|
|
171096
171259
|
let description = "";
|
|
171097
171260
|
try {
|
|
171098
171261
|
const content = readFileSync10(skillMd, "utf-8");
|
|
@@ -171141,7 +171304,7 @@ var WorkspaceSyncEngine = class _WorkspaceSyncEngine {
|
|
|
171141
171304
|
for (const skill2 of skills) {
|
|
171142
171305
|
if (skill2.sourceAgent === target) continue;
|
|
171143
171306
|
const dest = join19(targetDir, skill2.name);
|
|
171144
|
-
if (
|
|
171307
|
+
if (existsSync16(dest)) {
|
|
171145
171308
|
skipped.push(`${skill2.name} (already exists in ${target})`);
|
|
171146
171309
|
continue;
|
|
171147
171310
|
}
|
|
@@ -171157,7 +171320,7 @@ var WorkspaceSyncEngine = class _WorkspaceSyncEngine {
|
|
|
171157
171320
|
scanWorkflows() {
|
|
171158
171321
|
const workflows = [];
|
|
171159
171322
|
const wfDir = join19(this.projectRoot, ".windsurf", "workflows");
|
|
171160
|
-
if (!
|
|
171323
|
+
if (!existsSync16(wfDir)) return workflows;
|
|
171161
171324
|
try {
|
|
171162
171325
|
const files = readdirSync3(wfDir).filter((f3) => f3.endsWith(".md"));
|
|
171163
171326
|
for (const file of files) {
|
|
@@ -171550,7 +171713,7 @@ var MCP_SERVER_INFO_META_KEY = "io.modelcontextprotocol/serverInfo";
|
|
|
171550
171713
|
function getMcpServerInfo() {
|
|
171551
171714
|
return {
|
|
171552
171715
|
name: "memorix",
|
|
171553
|
-
version: true ? "1.10.
|
|
171716
|
+
version: true ? "1.10.2" : "1.0.1"
|
|
171554
171717
|
};
|
|
171555
171718
|
}
|
|
171556
171719
|
function createMcpDiscoverResult(capabilities, serverInfo) {
|
|
@@ -172780,7 +172943,18 @@ _Search mode: ${result.receipt.mode}_`;
|
|
|
172780
172943
|
text: text3
|
|
172781
172944
|
}
|
|
172782
172945
|
],
|
|
172783
|
-
|
|
172946
|
+
// Clients that surface only structuredContent (e.g. Claude Code) must
|
|
172947
|
+
// still see the results, not just the retrieval diagnostics.
|
|
172948
|
+
structuredContent: {
|
|
172949
|
+
results: result.entries.map((entry) => ({
|
|
172950
|
+
ref: formatEntryRef(entry),
|
|
172951
|
+
title: entry.title,
|
|
172952
|
+
type: entry.type,
|
|
172953
|
+
time: entry.time,
|
|
172954
|
+
tokens: entry.tokens
|
|
172955
|
+
})),
|
|
172956
|
+
retrieval: result.receipt
|
|
172957
|
+
}
|
|
172784
172958
|
};
|
|
172785
172959
|
}, { loadCorpus: false });
|
|
172786
172960
|
}
|
|
@@ -174848,9 +175022,12 @@ ${s2.instruction}`.toLowerCase();
|
|
|
174848
175022
|
}
|
|
174849
175023
|
} catch {
|
|
174850
175024
|
}
|
|
175025
|
+
const card = lines.filter(Boolean).join("\n");
|
|
174851
175026
|
return {
|
|
174852
|
-
content: [{ type: "text", text:
|
|
174853
|
-
structuredContent
|
|
175027
|
+
content: [{ type: "text", text: card }],
|
|
175028
|
+
// Clients that surface only structuredContent (e.g. Claude Code) must
|
|
175029
|
+
// still see the session card, not just the binding receipt.
|
|
175030
|
+
structuredContent: { card, binding: bindingReceipt }
|
|
174854
175031
|
};
|
|
174855
175032
|
}
|
|
174856
175033
|
);
|
|
@@ -176280,10 +176457,10 @@ Preview: ${analysis.description.slice(0, 300)}${analysis.description.length > 30
|
|
|
176280
176457
|
const { ensureHooksDir: ensureHooksDir2 } = await Promise.resolve().then(() => (init_hooks_path(), hooks_path_exports));
|
|
176281
176458
|
const resolved = ensureHooksDir2(project.rootPath);
|
|
176282
176459
|
if (resolved) {
|
|
176283
|
-
const { existsSync:
|
|
176460
|
+
const { existsSync: existsSync24, readFileSync: readFileSync17, writeFileSync: writeFileSync5, chmodSync } = await import("fs");
|
|
176284
176461
|
const { hookPath } = resolved;
|
|
176285
176462
|
const HOOK_MARKER = "# [memorix-git-hook]";
|
|
176286
|
-
const needsInstall = !
|
|
176463
|
+
const needsInstall = !existsSync24(hookPath) || !readFileSync17(hookPath, "utf-8").includes(HOOK_MARKER);
|
|
176287
176464
|
if (needsInstall) {
|
|
176288
176465
|
const hookScript = `#!/bin/sh
|
|
176289
176466
|
${HOOK_MARKER}
|
|
@@ -176292,7 +176469,7 @@ if command -v memorix >/dev/null 2>&1; then
|
|
|
176292
176469
|
memorix ingest commit --auto >/dev/null 2>&1 &
|
|
176293
176470
|
fi
|
|
176294
176471
|
`;
|
|
176295
|
-
if (
|
|
176472
|
+
if (existsSync24(hookPath)) {
|
|
176296
176473
|
const existing = readFileSync17(hookPath, "utf-8");
|
|
176297
176474
|
writeFileSync5(hookPath, existing.trimEnd() + `
|
|
176298
176475
|
|