memorix 1.10.1 → 1.10.3
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 +34 -0
- package/README.md +3 -1
- package/README.zh-CN.md +3 -1
- package/dist/cli/index.js +810 -379
- package/dist/cli/memcode.js +0 -0
- package/dist/index.js +380 -142
- package/dist/maintenance-runner.js +275 -79
- package/dist/media-audio-runner.js +247 -51
- package/dist/media-video-runner.js +274 -78
- package/dist/memcode-runtime/CHANGELOG.md +34 -0
- package/dist/sdk.js +431 -142
- package/dist/types.d.ts +1 -1
- package/dist/vector-backfill-runner.js +274 -78
- package/docs/CONFIGURATION.md +34 -0
- package/docs/DEVELOPMENT.md +3 -4
- package/docs/INTEGRATIONS.md +1 -1
- package/docs/PERFORMANCE.md +23 -0
- package/docs/README.md +3 -2
- package/docs/ROADMAP-1.9.12-2.0.md +2 -2
- package/docs/SETUP.md +19 -4
- 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/agent-integrations.ts +1 -1
- package/src/cli/commands/background.ts +1 -1
- package/src/cli/commands/context.ts +3 -2
- package/src/cli/commands/doctor.ts +9 -0
- package/src/cli/commands/explain.ts +3 -2
- package/src/cli/commands/init.ts +6 -2
- package/src/cli/commands/repair.ts +17 -3
- package/src/cli/commands/setup.ts +9 -6
- package/src/cli/commands/uninstall.ts +15 -0
- package/src/cli/tui/App.tsx +9 -16
- package/src/cli/tui/ConfigureView.tsx +2 -0
- package/src/codegraph/auto-context.ts +1 -1
- package/src/codegraph/store.ts +37 -0
- package/src/codegraph/types.ts +3 -0
- package/src/compact/index-format.ts +1 -1
- package/src/config/dotenv-loader.ts +1 -0
- package/src/config/resolved-config.ts +7 -2
- package/src/config/toml-loader.ts +1 -0
- package/src/config/yaml-loader.ts +4 -2
- package/src/dashboard/server.ts +5 -6
- package/src/hooks/handler.ts +0 -1
- package/src/integrations/registry.ts +2 -1
- package/src/knowledge/context-receipt.ts +6 -3
- package/src/llm/provider.ts +2 -1
- package/src/memory/observations.ts +68 -22
- package/src/multimodal/image-loader.ts +2 -2
- package/src/runtime/open-browser.ts +25 -0
- package/src/search/derived-view-receipt.ts +40 -0
- package/src/search/semantic-index.ts +149 -1
- package/src/server.ts +20 -5
- package/src/store/orama-store.ts +59 -19
- package/src/types.ts +1 -1
- package/src/workspace/mcp-adapters/pi.ts +58 -0
- package/plugins/pi/memorix/skills/memorix-git-memory/SKILL.md +0 -26
- package/plugins/pi/memorix/skills/memorix-memory/SKILL.md +0 -51
- package/plugins/pi/memorix/skills/memorix-mini-skills/SKILL.md +0 -31
- package/plugins/pi/memorix/skills/memorix-orchestrate/SKILL.md +0 -28
- package/plugins/pi/memorix/skills/memorix-reasoning/SKILL.md +0 -30
- package/plugins/pi/memorix/skills/memorix-sessions/SKILL.md +0 -25
- package/plugins/pi/memorix/skills/memorix-troubleshooting/SKILL.md +0 -27
package/dist/sdk.js
CHANGED
|
@@ -3871,7 +3871,8 @@ function getResolvedConfig(options = {}) {
|
|
|
3871
3871
|
const isRequesty = memoryLlmProvider === "requesty";
|
|
3872
3872
|
const isApiRoute = memoryLlmProvider === "apiroute";
|
|
3873
3873
|
const isCheaperInference = memoryLlmProvider === "cheaperinference";
|
|
3874
|
-
const
|
|
3874
|
+
const isRuncrate = memoryLlmProvider === "runcrate";
|
|
3875
|
+
const usesPresetKeyOnly = isAtlasCloud || isRequesty || isApiRoute || isCheaperInference || isRuncrate;
|
|
3875
3876
|
const memoryLlmApiKey = first(
|
|
3876
3877
|
process.env.MEMORIX_LLM_API_KEY,
|
|
3877
3878
|
process.env.MEMORIX_API_KEY,
|
|
@@ -3879,7 +3880,7 @@ function getResolvedConfig(options = {}) {
|
|
|
3879
3880
|
yaml.llm?.apiKey,
|
|
3880
3881
|
legacy.llm?.apiKey,
|
|
3881
3882
|
// Never borrow another provider's credentials for these gateway presets.
|
|
3882
|
-
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,
|
|
3883
|
+
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 : isRuncrate ? process.env.RUNCRATE_API_KEY : process.env.OPENAI_API_KEY,
|
|
3883
3884
|
usesPresetKeyOnly ? void 0 : process.env.ANTHROPIC_API_KEY,
|
|
3884
3885
|
usesPresetKeyOnly ? void 0 : openRouterMemoryLlmApiKey
|
|
3885
3886
|
);
|
|
@@ -3950,6 +3951,7 @@ function getResolvedConfig(options = {}) {
|
|
|
3950
3951
|
codegraph: {
|
|
3951
3952
|
excludePatterns: firstArray(toml.codegraph?.exclude_patterns, yaml.codegraph?.excludePatterns),
|
|
3952
3953
|
maxFileBytes: firstNumber(toml.codegraph?.max_file_bytes, yaml.codegraph?.maxFileBytes),
|
|
3954
|
+
autoRefresh: first(toml.codegraph?.auto_refresh, yaml.codegraph?.autoRefresh, "auto"),
|
|
3953
3955
|
externalContext: first(
|
|
3954
3956
|
normalizeExternalContext(process.env.MEMORIX_CODEGRAPH_EXTERNAL_CONTEXT),
|
|
3955
3957
|
toml.codegraph?.external_context,
|
|
@@ -4064,6 +4066,7 @@ function getEnvSourceNames() {
|
|
|
4064
4066
|
"REQUESTY_API_KEY",
|
|
4065
4067
|
"API_ROUTE_API_KEY",
|
|
4066
4068
|
"CHEAPER_INFERENCE_API_KEY",
|
|
4069
|
+
"RUNCRATE_API_KEY",
|
|
4067
4070
|
"ATLASCLOUD_API_KEY"
|
|
4068
4071
|
].filter((name) => process.env[name]);
|
|
4069
4072
|
}
|
|
@@ -7059,6 +7062,7 @@ var init_provider2 = __esm({
|
|
|
7059
7062
|
requesty: { baseUrl: "https://router.requesty.ai/v1", model: "openai/gpt-4.1-nano" },
|
|
7060
7063
|
apiroute: { baseUrl: "https://global.api-route.com/v1", model: "deepseek-v4.1-flash" },
|
|
7061
7064
|
cheaperinference: { baseUrl: "https://api.cheaperinference.com/v1", model: "gpt-5.4-mini" },
|
|
7065
|
+
runcrate: { baseUrl: "https://api.runcrate.ai/v1", model: "deepseek-ai/DeepSeek-V4.1-Flash" },
|
|
7062
7066
|
atlascloud: { baseUrl: "https://api.atlascloud.ai/v1", model: "deepseek-ai/deepseek-v3.2" },
|
|
7063
7067
|
custom: { baseUrl: "http://localhost:11434/v1", model: "llama3" }
|
|
7064
7068
|
};
|
|
@@ -7843,13 +7847,18 @@ __export(semantic_index_exports, {
|
|
|
7843
7847
|
createSemanticIndexProfile: () => createSemanticIndexProfile,
|
|
7844
7848
|
deleteSemanticVector: () => deleteSemanticVector,
|
|
7845
7849
|
ensureSemanticIndex: () => ensureSemanticIndex,
|
|
7850
|
+
getSemanticIndexStats: () => getSemanticIndexStats,
|
|
7846
7851
|
isSemanticIndexAvailable: () => isSemanticIndexAvailable,
|
|
7852
|
+
listSemanticVectorIds: () => listSemanticVectorIds,
|
|
7853
|
+
optimizeSemanticIndex: () => optimizeSemanticIndex,
|
|
7854
|
+
optimizeSemanticIndexes: () => optimizeSemanticIndexes,
|
|
7847
7855
|
resetSemanticIndexRuntime: () => resetSemanticIndexRuntime,
|
|
7848
7856
|
searchSemanticVectors: () => searchSemanticVectors,
|
|
7849
7857
|
upsertSemanticVector: () => upsertSemanticVector,
|
|
7850
7858
|
upsertSemanticVectors: () => upsertSemanticVectors
|
|
7851
7859
|
});
|
|
7852
7860
|
import { createHash as createHash4 } from "crypto";
|
|
7861
|
+
import { existsSync as existsSync8 } from "fs";
|
|
7853
7862
|
import { createRequire as createRequire3 } from "module";
|
|
7854
7863
|
import path11 from "path";
|
|
7855
7864
|
function createSemanticIndexProfile(provider2) {
|
|
@@ -7951,20 +7960,120 @@ function queueOperation(key, operation) {
|
|
|
7951
7960
|
writeQueues.set(key, run.catch(() => void 0));
|
|
7952
7961
|
return run;
|
|
7953
7962
|
}
|
|
7963
|
+
function positiveEnvInt(name, fallback) {
|
|
7964
|
+
const value = Number.parseInt(process.env[name] ?? "", 10);
|
|
7965
|
+
return Number.isSafeInteger(value) && value > 0 ? value : fallback;
|
|
7966
|
+
}
|
|
7967
|
+
function semanticWriteBatchSize() {
|
|
7968
|
+
return positiveEnvInt("MEMORIX_SEMANTIC_WRITE_BATCH_SIZE", DEFAULT_WRITE_BATCH_SIZE);
|
|
7969
|
+
}
|
|
7970
|
+
function semanticWriteFlushMs() {
|
|
7971
|
+
return positiveEnvInt("MEMORIX_SEMANTIC_WRITE_FLUSH_MS", DEFAULT_WRITE_FLUSH_MS);
|
|
7972
|
+
}
|
|
7973
|
+
function semanticOptimizeEvery() {
|
|
7974
|
+
return positiveEnvInt("MEMORIX_SEMANTIC_OPTIMIZE_EVERY", DEFAULT_OPTIMIZE_EVERY);
|
|
7975
|
+
}
|
|
7976
|
+
function semanticVersionRetentionMs() {
|
|
7977
|
+
return positiveEnvInt("MEMORIX_SEMANTIC_VERSION_RETENTION_MS", DEFAULT_VERSION_RETENTION_MS);
|
|
7978
|
+
}
|
|
7979
|
+
async function optimizeState(state) {
|
|
7980
|
+
if (!state.table || typeof state.table.optimize !== "function") return;
|
|
7981
|
+
await state.table.optimize({
|
|
7982
|
+
cleanupOlderThan: new Date(Date.now() - semanticVersionRetentionMs()),
|
|
7983
|
+
deleteUnverified: false
|
|
7984
|
+
});
|
|
7985
|
+
}
|
|
7954
7986
|
async function mergeVectors(dataDir, profile, records) {
|
|
7955
7987
|
if (records.length === 0) return;
|
|
7956
7988
|
const state = await getState(dataDir, profile, records);
|
|
7957
7989
|
if (!state?.table) return;
|
|
7958
7990
|
const rows = records.map(toLanceRow);
|
|
7959
7991
|
await state.table.mergeInsert("observation_id").whenMatchedUpdateAll().whenNotMatchedInsertAll().execute(rows);
|
|
7992
|
+
const key = stateKey(dataDir, profile);
|
|
7993
|
+
const mutationCount = (mutationCounts.get(key) ?? 0) + 1;
|
|
7994
|
+
if (mutationCount >= semanticOptimizeEvery()) {
|
|
7995
|
+
mutationCounts.set(key, 0);
|
|
7996
|
+
await optimizeState(state).catch(() => void 0);
|
|
7997
|
+
} else {
|
|
7998
|
+
mutationCounts.set(key, mutationCount);
|
|
7999
|
+
}
|
|
7960
8000
|
void ensureSemanticIndex(dataDir, profile);
|
|
7961
8001
|
}
|
|
8002
|
+
function flushPendingVectorBatch(key) {
|
|
8003
|
+
const pending = pendingVectorBatches.get(key);
|
|
8004
|
+
if (!pending) return Promise.resolve();
|
|
8005
|
+
if (pending.timer) clearTimeout(pending.timer);
|
|
8006
|
+
pendingVectorBatches.delete(key);
|
|
8007
|
+
const records = [...pending.records.values()];
|
|
8008
|
+
const waiters = pending.waiters.splice(0);
|
|
8009
|
+
return queueOperation(key, () => mergeVectors(pending.dataDir, pending.profile, records)).then(() => waiters.forEach((waiter) => waiter.resolve())).catch((error) => {
|
|
8010
|
+
waiters.forEach((waiter) => waiter.reject(error));
|
|
8011
|
+
});
|
|
8012
|
+
}
|
|
7962
8013
|
function upsertSemanticVector(dataDir, profile, record80) {
|
|
7963
|
-
|
|
8014
|
+
const key = stateKey(dataDir, profile);
|
|
8015
|
+
let pending = pendingVectorBatches.get(key);
|
|
8016
|
+
if (!pending) {
|
|
8017
|
+
pending = { dataDir, profile, records: /* @__PURE__ */ new Map(), waiters: [] };
|
|
8018
|
+
pendingVectorBatches.set(key, pending);
|
|
8019
|
+
}
|
|
8020
|
+
pending.records.set(`${record80.projectId}:${record80.observationId}`, record80);
|
|
8021
|
+
const promise = new Promise((resolve5, reject) => pending.waiters.push({ resolve: resolve5, reject }));
|
|
8022
|
+
if (pending.records.size >= semanticWriteBatchSize()) void flushPendingVectorBatch(key);
|
|
8023
|
+
else if (!pending.timer) pending.timer = setTimeout(() => {
|
|
8024
|
+
void flushPendingVectorBatch(key);
|
|
8025
|
+
}, semanticWriteFlushMs());
|
|
8026
|
+
return promise;
|
|
7964
8027
|
}
|
|
7965
8028
|
function upsertSemanticVectors(dataDir, profile, records) {
|
|
7966
8029
|
return queueOperation(stateKey(dataDir, profile), () => mergeVectors(dataDir, profile, records));
|
|
7967
8030
|
}
|
|
8031
|
+
async function listSemanticVectorIds(dataDir, profile) {
|
|
8032
|
+
const state = await getState(dataDir, profile);
|
|
8033
|
+
if (!state?.table) return null;
|
|
8034
|
+
const rows = await state.table.query().select(["observation_id"]).toArray();
|
|
8035
|
+
return new Set(rows.map((row) => Number(row.observation_id)).filter(Number.isSafeInteger));
|
|
8036
|
+
}
|
|
8037
|
+
async function getSemanticIndexStats(dataDir, profile) {
|
|
8038
|
+
const state = await getState(dataDir, profile);
|
|
8039
|
+
if (!state?.table) return null;
|
|
8040
|
+
return {
|
|
8041
|
+
rowCount: await state.table.countRows(),
|
|
8042
|
+
version: typeof state.table.version === "function" ? await state.table.version() : 0
|
|
8043
|
+
};
|
|
8044
|
+
}
|
|
8045
|
+
function optimizeSemanticIndex(dataDir, profile) {
|
|
8046
|
+
const key = stateKey(dataDir, profile);
|
|
8047
|
+
return queueOperation(key, async () => {
|
|
8048
|
+
const state = await getState(dataDir, profile);
|
|
8049
|
+
if (state) await optimizeState(state);
|
|
8050
|
+
mutationCounts.set(key, 0);
|
|
8051
|
+
});
|
|
8052
|
+
}
|
|
8053
|
+
async function optimizeSemanticIndexes(dataDir) {
|
|
8054
|
+
if (!existsSync8(indexRoot(dataDir))) return [];
|
|
8055
|
+
const lance = await loadLanceDb();
|
|
8056
|
+
if (!lance) throw new Error("LanceDB is unavailable; install the optional @lancedb/lancedb package");
|
|
8057
|
+
const connection = await lance.connect(indexRoot(dataDir));
|
|
8058
|
+
try {
|
|
8059
|
+
const names = typeof connection.tableNames === "function" ? await connection.tableNames() : (await connection.listTables()).tables;
|
|
8060
|
+
const optimized = [];
|
|
8061
|
+
for (const name of names.filter((value) => value.startsWith(TABLE_PREFIX))) {
|
|
8062
|
+
const table = await connection.openTable(name);
|
|
8063
|
+
await table.optimize({
|
|
8064
|
+
cleanupOlderThan: new Date(Date.now() - semanticVersionRetentionMs()),
|
|
8065
|
+
deleteUnverified: false
|
|
8066
|
+
});
|
|
8067
|
+
optimized.push(name);
|
|
8068
|
+
}
|
|
8069
|
+
return optimized;
|
|
8070
|
+
} finally {
|
|
8071
|
+
try {
|
|
8072
|
+
connection.close?.();
|
|
8073
|
+
} catch {
|
|
8074
|
+
}
|
|
8075
|
+
}
|
|
8076
|
+
}
|
|
7968
8077
|
function deleteSemanticVector(dataDir, profile, observationId2) {
|
|
7969
8078
|
return queueOperation(stateKey(dataDir, profile), async () => {
|
|
7970
8079
|
const state = await getState(dataDir, profile);
|
|
@@ -8024,6 +8133,8 @@ async function searchSemanticVectors(options) {
|
|
|
8024
8133
|
})).filter((row) => Number.isFinite(row.distance));
|
|
8025
8134
|
}
|
|
8026
8135
|
async function closeSemanticIndexes() {
|
|
8136
|
+
await Promise.all([...pendingVectorBatches.keys()].map((key) => flushPendingVectorBatch(key)));
|
|
8137
|
+
await Promise.all([...writeQueues.values()]);
|
|
8027
8138
|
for (const statePromise of statePromises.values()) {
|
|
8028
8139
|
const state = await statePromise.catch(() => null);
|
|
8029
8140
|
try {
|
|
@@ -8034,9 +8145,12 @@ async function closeSemanticIndexes() {
|
|
|
8034
8145
|
statePromises.clear();
|
|
8035
8146
|
writeQueues.clear();
|
|
8036
8147
|
indexBuilds.clear();
|
|
8148
|
+
mutationCounts.clear();
|
|
8037
8149
|
}
|
|
8038
8150
|
async function closeSemanticIndex(dataDir) {
|
|
8039
8151
|
const prefix = `${path11.resolve(dataDir)}::`;
|
|
8152
|
+
await Promise.all([...pendingVectorBatches.keys()].filter((key) => key.startsWith(prefix)).map(flushPendingVectorBatch));
|
|
8153
|
+
await Promise.all([...writeQueues.entries()].filter(([key]) => key.startsWith(prefix)).map(([, queue]) => queue));
|
|
8040
8154
|
for (const [key, statePromise] of statePromises.entries()) {
|
|
8041
8155
|
if (!key.startsWith(prefix)) continue;
|
|
8042
8156
|
const state = await statePromise.catch(() => null);
|
|
@@ -8047,15 +8161,21 @@ async function closeSemanticIndex(dataDir) {
|
|
|
8047
8161
|
statePromises.delete(key);
|
|
8048
8162
|
writeQueues.delete(key);
|
|
8049
8163
|
indexBuilds.delete(key);
|
|
8164
|
+
mutationCounts.delete(key);
|
|
8050
8165
|
}
|
|
8051
8166
|
}
|
|
8052
8167
|
function resetSemanticIndexRuntime() {
|
|
8168
|
+
for (const pending of pendingVectorBatches.values()) {
|
|
8169
|
+
if (pending.timer) clearTimeout(pending.timer);
|
|
8170
|
+
}
|
|
8171
|
+
pendingVectorBatches.clear();
|
|
8053
8172
|
statePromises.clear();
|
|
8054
8173
|
writeQueues.clear();
|
|
8055
8174
|
indexBuilds.clear();
|
|
8175
|
+
mutationCounts.clear();
|
|
8056
8176
|
availability = void 0;
|
|
8057
8177
|
}
|
|
8058
|
-
var SEMANTIC_INDEX_DIR, TABLE_PREFIX, DEFAULT_INDEX_THRESHOLD, MAX_INDEX_PARTITIONS, statePromises, writeQueues, indexBuilds, availability, requireFromHere2;
|
|
8178
|
+
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
8179
|
var init_semantic_index = __esm({
|
|
8060
8180
|
"src/search/semantic-index.ts"() {
|
|
8061
8181
|
"use strict";
|
|
@@ -8064,13 +8184,84 @@ var init_semantic_index = __esm({
|
|
|
8064
8184
|
TABLE_PREFIX = "observations_";
|
|
8065
8185
|
DEFAULT_INDEX_THRESHOLD = 1e4;
|
|
8066
8186
|
MAX_INDEX_PARTITIONS = 32;
|
|
8187
|
+
DEFAULT_WRITE_BATCH_SIZE = 100;
|
|
8188
|
+
DEFAULT_WRITE_FLUSH_MS = 50;
|
|
8189
|
+
DEFAULT_OPTIMIZE_EVERY = 20;
|
|
8190
|
+
DEFAULT_VERSION_RETENTION_MS = 24 * 60 * 60 * 1e3;
|
|
8067
8191
|
statePromises = /* @__PURE__ */ new Map();
|
|
8068
8192
|
writeQueues = /* @__PURE__ */ new Map();
|
|
8069
8193
|
indexBuilds = /* @__PURE__ */ new Map();
|
|
8194
|
+
mutationCounts = /* @__PURE__ */ new Map();
|
|
8195
|
+
pendingVectorBatches = /* @__PURE__ */ new Map();
|
|
8070
8196
|
requireFromHere2 = createRequire3(import.meta.url);
|
|
8071
8197
|
}
|
|
8072
8198
|
});
|
|
8073
8199
|
|
|
8200
|
+
// src/memory/secret-filter.ts
|
|
8201
|
+
function applyRedaction(text3) {
|
|
8202
|
+
if (!text3) return text3;
|
|
8203
|
+
let out = text3;
|
|
8204
|
+
out = out.replace(
|
|
8205
|
+
/((?:password|passwd|pwd|secret|token|api[_-]?key|auth[_-]?key|access[_-]?key|private[_-]?key|client[_-]?secret)\s*[:=]\s*["']?)([^\s"',;\n]{6,})/gi,
|
|
8206
|
+
"$1[REDACTED]"
|
|
8207
|
+
);
|
|
8208
|
+
out = out.replace(
|
|
8209
|
+
/(Bearer\s+)([A-Za-z0-9._\-/+]{20,})/g,
|
|
8210
|
+
"$1[REDACTED]"
|
|
8211
|
+
);
|
|
8212
|
+
out = out.replace(/\b(?:ghp|ghs|gho|github_pat)_[A-Za-z0-9]{36,}\b/g, "[REDACTED]");
|
|
8213
|
+
out = out.replace(/\bsk-[A-Za-z0-9T-]{20,}\b/g, "[REDACTED]");
|
|
8214
|
+
out = out.replace(/\beyJ[A-Za-z0-9._-]{40,}\b/g, "[REDACTED]");
|
|
8215
|
+
return out;
|
|
8216
|
+
}
|
|
8217
|
+
function sanitizeCredentials(text3) {
|
|
8218
|
+
return applyRedaction(text3);
|
|
8219
|
+
}
|
|
8220
|
+
function redactCredentials(text3) {
|
|
8221
|
+
return applyRedaction(text3);
|
|
8222
|
+
}
|
|
8223
|
+
var init_secret_filter = __esm({
|
|
8224
|
+
"src/memory/secret-filter.ts"() {
|
|
8225
|
+
"use strict";
|
|
8226
|
+
init_esm_shims();
|
|
8227
|
+
}
|
|
8228
|
+
});
|
|
8229
|
+
|
|
8230
|
+
// src/search/derived-view-receipt.ts
|
|
8231
|
+
function sanitizeDerivedViewFailureReason(reason) {
|
|
8232
|
+
const safe = sanitizeCredentials(reason).replace(/(?:[A-Za-z]:[\\/]|\\\\[^\\/\s]+[\\/]|\/(?:home|Users|tmp|var|private|mnt|workspace|workspaces)\/)[^\s"'<>|]*/gi, "[path]").replace(/\s+/g, " ").trim();
|
|
8233
|
+
return safe.slice(0, 240) || "derived view failed";
|
|
8234
|
+
}
|
|
8235
|
+
function embeddingHealthReceipt(health, embeddingEnabled2) {
|
|
8236
|
+
if (health?.status === "disabled") {
|
|
8237
|
+
return { freshness: "current", rebuildStatus: "disabled" };
|
|
8238
|
+
}
|
|
8239
|
+
if (health?.status === "ready" || embeddingEnabled2) {
|
|
8240
|
+
return { freshness: "current", rebuildStatus: "idle" };
|
|
8241
|
+
}
|
|
8242
|
+
if (health?.status === "degraded") {
|
|
8243
|
+
return {
|
|
8244
|
+
freshness: "stale",
|
|
8245
|
+
rebuildStatus: "failed",
|
|
8246
|
+
...health.failure ? {
|
|
8247
|
+
failureReason: `embedding ${health.failure.kind}; retry in ${health.failure.retryAfterMs}ms`
|
|
8248
|
+
} : { failureReason: "embedding provider degraded" }
|
|
8249
|
+
};
|
|
8250
|
+
}
|
|
8251
|
+
return {
|
|
8252
|
+
freshness: "unknown",
|
|
8253
|
+
rebuildStatus: "unavailable",
|
|
8254
|
+
failureReason: "embedding provider is not initialized"
|
|
8255
|
+
};
|
|
8256
|
+
}
|
|
8257
|
+
var init_derived_view_receipt = __esm({
|
|
8258
|
+
"src/search/derived-view-receipt.ts"() {
|
|
8259
|
+
"use strict";
|
|
8260
|
+
init_esm_shims();
|
|
8261
|
+
init_secret_filter();
|
|
8262
|
+
}
|
|
8263
|
+
});
|
|
8264
|
+
|
|
8074
8265
|
// src/project/aliases.ts
|
|
8075
8266
|
var aliases_exports = {};
|
|
8076
8267
|
__export(aliases_exports, {
|
|
@@ -8679,6 +8870,7 @@ __export(orama_store_exports, {
|
|
|
8679
8870
|
getLastSearchMode: () => getLastSearchMode,
|
|
8680
8871
|
getObservationCount: () => getObservationCount,
|
|
8681
8872
|
getObservationsByIds: () => getObservationsByIds,
|
|
8873
|
+
getPersistentSemanticVectorIds: () => getPersistentSemanticVectorIds,
|
|
8682
8874
|
getSearchDerivedViews: () => getSearchDerivedViews,
|
|
8683
8875
|
getTimeline: () => getTimeline,
|
|
8684
8876
|
getVectorDimensions: () => getVectorDimensions,
|
|
@@ -8691,10 +8883,18 @@ __export(orama_store_exports, {
|
|
|
8691
8883
|
queueSemanticVector: () => queueSemanticVector,
|
|
8692
8884
|
removeObservation: () => removeObservation,
|
|
8693
8885
|
resetDb: () => resetDb,
|
|
8886
|
+
resolveSearchFuzzyTolerance: () => resolveSearchFuzzyTolerance,
|
|
8694
8887
|
searchObservations: () => searchObservations,
|
|
8695
8888
|
updateObservationMetadata: () => updateObservationMetadata
|
|
8696
8889
|
});
|
|
8697
8890
|
import { components, create, insert as insert2, insertMultiple, search, remove as remove2, update, count, getByID } from "@orama/orama";
|
|
8891
|
+
function resolveSearchFuzzyTolerance(query, quality) {
|
|
8892
|
+
if (quality === "fast") return void 0;
|
|
8893
|
+
const characters = [...query];
|
|
8894
|
+
const cjkCount = characters.filter((char) => /[\u3400-\u4dbf\u4e00-\u9fff\u3040-\u30ff\uac00-\ud7af]/u.test(char)).length;
|
|
8895
|
+
if (characters.length > 0 && cjkCount / characters.length > 0.3) return void 0;
|
|
8896
|
+
return query.length > 6 ? 2 : 1;
|
|
8897
|
+
}
|
|
8698
8898
|
function rememberSearchMode(key, value) {
|
|
8699
8899
|
if (!lastSearchModeByProject.has(key) && lastSearchModeByProject.size >= MAX_SEARCH_MODE_KEYS) {
|
|
8700
8900
|
const oldest = lastSearchModeByProject.keys().next().value;
|
|
@@ -8723,14 +8923,16 @@ function getSearchDerivedViews() {
|
|
|
8723
8923
|
generation,
|
|
8724
8924
|
freshness: "unknown",
|
|
8725
8925
|
rebuildStatus: "unavailable",
|
|
8726
|
-
failureReason:
|
|
8926
|
+
failureReason: sanitizeDerivedViewFailureReason(
|
|
8927
|
+
store.getBackendReason?.() ?? "persistent lexical index unavailable"
|
|
8928
|
+
)
|
|
8727
8929
|
};
|
|
8728
8930
|
}
|
|
8729
8931
|
} catch (error) {
|
|
8730
8932
|
views.fts = {
|
|
8731
8933
|
freshness: "unknown",
|
|
8732
8934
|
rebuildStatus: "failed",
|
|
8733
|
-
failureReason: error instanceof Error ? error.message
|
|
8935
|
+
failureReason: sanitizeDerivedViewFailureReason(error instanceof Error ? error.message : String(error))
|
|
8734
8936
|
};
|
|
8735
8937
|
}
|
|
8736
8938
|
} else {
|
|
@@ -8746,18 +8948,12 @@ function getSearchDerivedViews() {
|
|
|
8746
8948
|
rebuildStatus: "unavailable",
|
|
8747
8949
|
failureReason: "Orama index is not initialized"
|
|
8748
8950
|
};
|
|
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
|
-
};
|
|
8951
|
+
let embeddingHealth;
|
|
8952
|
+
try {
|
|
8953
|
+
embeddingHealth = getEmbeddingRuntimeHealth?.();
|
|
8954
|
+
} catch {
|
|
8760
8955
|
}
|
|
8956
|
+
views.embedding = embeddingHealthReceipt(embeddingHealth, embeddingEnabled);
|
|
8761
8957
|
return views;
|
|
8762
8958
|
}
|
|
8763
8959
|
function rememberSearchDiagnostics(key, value) {
|
|
@@ -9061,12 +9257,16 @@ function getVectorDimensions() {
|
|
|
9061
9257
|
function getActiveSemanticIndexProfile() {
|
|
9062
9258
|
return indexEmbeddingProvider ? createSemanticIndexProfile(indexEmbeddingProvider) : null;
|
|
9063
9259
|
}
|
|
9260
|
+
async function getPersistentSemanticVectorIds(dataDir) {
|
|
9261
|
+
if (!indexEmbeddingProvider) return null;
|
|
9262
|
+
return listSemanticVectorIds(dataDir, createSemanticIndexProfile(indexEmbeddingProvider));
|
|
9263
|
+
}
|
|
9064
9264
|
async function queueSemanticVector(dataDir, record80) {
|
|
9065
9265
|
const provider2 = indexEmbeddingProvider ?? await getEmbeddingProvider();
|
|
9066
9266
|
const profile = provider2 ? createSemanticIndexProfile(provider2) : null;
|
|
9067
9267
|
if (!profile) return;
|
|
9068
9268
|
try {
|
|
9069
|
-
await
|
|
9269
|
+
await upsertSemanticVector(dataDir, profile, record80);
|
|
9070
9270
|
} catch {
|
|
9071
9271
|
}
|
|
9072
9272
|
}
|
|
@@ -9128,6 +9328,7 @@ function isCompatibleCachedVector(vector) {
|
|
|
9128
9328
|
async function attachCachedVectors(database, observations2) {
|
|
9129
9329
|
const semanticDataDir = (await Promise.resolve().then(() => (init_observations(), observations_exports))).getObservationDataDir();
|
|
9130
9330
|
const semanticProfile = getActiveSemanticIndexProfile();
|
|
9331
|
+
const persistedSemanticIds = semanticDataDir && semanticProfile ? await listSemanticVectorIds(semanticDataDir, semanticProfile).catch(() => null) : null;
|
|
9131
9332
|
const batchSize = 200;
|
|
9132
9333
|
for (let start = 0; start < observations2.length; start += batchSize) {
|
|
9133
9334
|
const batch = observations2.slice(start, start + batchSize);
|
|
@@ -9138,7 +9339,7 @@ async function attachCachedVectors(database, observations2) {
|
|
|
9138
9339
|
const vector = cachedVectors[index];
|
|
9139
9340
|
if (!isCompatibleCachedVector(vector)) continue;
|
|
9140
9341
|
const observation = batch[index];
|
|
9141
|
-
if (semanticDataDir && semanticProfile) {
|
|
9342
|
+
if (semanticDataDir && semanticProfile && !persistedSemanticIds?.has(observation.id)) {
|
|
9142
9343
|
semanticRecords.push({
|
|
9143
9344
|
observationId: observation.id,
|
|
9144
9345
|
projectId: observation.projectId,
|
|
@@ -9339,7 +9540,10 @@ async function searchObservations(options) {
|
|
|
9339
9540
|
// Fuzzy tolerance: allow 1-char typos for short queries, 2 for longer
|
|
9340
9541
|
// Fuzzy matching is useful for ordinary recall, but grows sharply with
|
|
9341
9542
|
// corpus size. The fast profile deliberately uses exact lexical matching.
|
|
9342
|
-
...hasQuery
|
|
9543
|
+
...hasQuery ? (() => {
|
|
9544
|
+
const tolerance = resolveSearchFuzzyTolerance(originalQuery, quality);
|
|
9545
|
+
return tolerance === void 0 ? {} : { tolerance };
|
|
9546
|
+
})() : {}
|
|
9343
9547
|
};
|
|
9344
9548
|
let queryVector = null;
|
|
9345
9549
|
let embeddingProviderForSearch = null;
|
|
@@ -9570,14 +9774,16 @@ async function searchObservations(options) {
|
|
|
9570
9774
|
filesModified: doc.filesModified?.split?.("\n") ?? (Array.isArray(doc.filesModified) ? doc.filesModified : [])
|
|
9571
9775
|
});
|
|
9572
9776
|
}
|
|
9777
|
+
const topScore = Math.max(...intermediate.map((entry) => entry.score));
|
|
9778
|
+
const affinityTieWindow = topScore * 0.92;
|
|
9573
9779
|
intermediate = intermediate.map((entry) => {
|
|
9574
9780
|
const memory = memoryContentMap.get(entry.id);
|
|
9575
9781
|
if (!memory) return entry;
|
|
9576
9782
|
const { score: affinityScore } = calculateProjectAffinity(memory, affinityContext);
|
|
9783
|
+
if (entry.score < affinityTieWindow) return entry;
|
|
9577
9784
|
return {
|
|
9578
9785
|
...entry,
|
|
9579
|
-
score: entry.score * affinityScore
|
|
9580
|
-
// Apply affinity as multiplier
|
|
9786
|
+
score: entry.score * (0.98 + affinityScore * 0.02)
|
|
9581
9787
|
};
|
|
9582
9788
|
});
|
|
9583
9789
|
intermediate.sort((a, b) => b.score - a.score);
|
|
@@ -9911,6 +10117,7 @@ var init_orama_store = __esm({
|
|
|
9911
10117
|
init_mini_skills();
|
|
9912
10118
|
init_visibility();
|
|
9913
10119
|
init_provider();
|
|
10120
|
+
init_provider();
|
|
9914
10121
|
init_project_affinity();
|
|
9915
10122
|
init_intent_detector();
|
|
9916
10123
|
init_query_expansion();
|
|
@@ -9918,6 +10125,7 @@ var init_orama_store = __esm({
|
|
|
9918
10125
|
init_timeout();
|
|
9919
10126
|
init_obs_store();
|
|
9920
10127
|
init_semantic_index();
|
|
10128
|
+
init_derived_view_receipt();
|
|
9921
10129
|
db = null;
|
|
9922
10130
|
dbInitPromise = null;
|
|
9923
10131
|
dbGeneration = 0;
|
|
@@ -10042,36 +10250,6 @@ var init_entity_extractor = __esm({
|
|
|
10042
10250
|
}
|
|
10043
10251
|
});
|
|
10044
10252
|
|
|
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
10253
|
// src/runtime/maintenance-jobs.ts
|
|
10076
10254
|
var maintenance_jobs_exports = {};
|
|
10077
10255
|
__export(maintenance_jobs_exports, {
|
|
@@ -10922,7 +11100,7 @@ var init_maintenance_targets = __esm({
|
|
|
10922
11100
|
|
|
10923
11101
|
// src/runtime/isolated-maintenance.ts
|
|
10924
11102
|
import { spawn } from "child_process";
|
|
10925
|
-
import { existsSync as
|
|
11103
|
+
import { existsSync as existsSync9 } from "fs";
|
|
10926
11104
|
import os4 from "os";
|
|
10927
11105
|
import path13 from "path";
|
|
10928
11106
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
@@ -10940,7 +11118,7 @@ function childError(prefix, detail) {
|
|
|
10940
11118
|
}
|
|
10941
11119
|
function isolatedMaintenanceCwd() {
|
|
10942
11120
|
const tmp = os4.tmpdir();
|
|
10943
|
-
return
|
|
11121
|
+
return existsSync9(tmp) ? tmp : process.cwd();
|
|
10944
11122
|
}
|
|
10945
11123
|
function resolveMaintenanceRunnerPath(moduleUrl = import.meta.url) {
|
|
10946
11124
|
const moduleDir = path13.dirname(fileURLToPath2(moduleUrl));
|
|
@@ -10997,7 +11175,7 @@ function collectOutput(stream2, limit2, onOverflow) {
|
|
|
10997
11175
|
async function runMaintenanceInChildProcess(request, options = {}) {
|
|
10998
11176
|
validateRequest(request);
|
|
10999
11177
|
const runnerPath = options.runnerPath ?? resolveMaintenanceRunnerPath();
|
|
11000
|
-
if (!
|
|
11178
|
+
if (!existsSync9(runnerPath)) {
|
|
11001
11179
|
throw new Error(`Maintenance runner is unavailable at ${runnerPath}. Reinstall or rebuild Memorix.`);
|
|
11002
11180
|
}
|
|
11003
11181
|
const timeoutMs = Number.isFinite(options.timeoutMs) ? Math.max(1e3, Math.floor(options.timeoutMs)) : DEFAULT_TIMEOUT_MS;
|
|
@@ -146152,7 +146330,7 @@ __export(video_jobs_exports, {
|
|
|
146152
146330
|
runMiniMaxVideoGenerationJob: () => runMiniMaxVideoGenerationJob
|
|
146153
146331
|
});
|
|
146154
146332
|
import { spawn as spawn2 } from "child_process";
|
|
146155
|
-
import { existsSync as
|
|
146333
|
+
import { existsSync as existsSync10 } from "fs";
|
|
146156
146334
|
import path19 from "path";
|
|
146157
146335
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
146158
146336
|
function safeError2(error) {
|
|
@@ -146400,7 +146578,7 @@ function resolveMediaVideoRunnerPath(moduleUrl = import.meta.url) {
|
|
|
146400
146578
|
}
|
|
146401
146579
|
function launchMediaVideoRunner(request, options = {}) {
|
|
146402
146580
|
const runnerPath = options.runnerPath ?? resolveMediaVideoRunnerPath();
|
|
146403
|
-
if (!
|
|
146581
|
+
if (!existsSync10(runnerPath)) {
|
|
146404
146582
|
return { launched: false, reason: "Media video runner is unavailable until Memorix is built or reinstalled." };
|
|
146405
146583
|
}
|
|
146406
146584
|
try {
|
|
@@ -146445,7 +146623,7 @@ __export(audio_jobs_exports, {
|
|
|
146445
146623
|
transcribeAudio: () => transcribeAudio
|
|
146446
146624
|
});
|
|
146447
146625
|
import { spawn as spawn3 } from "child_process";
|
|
146448
|
-
import { existsSync as
|
|
146626
|
+
import { existsSync as existsSync11 } from "fs";
|
|
146449
146627
|
import path20 from "path";
|
|
146450
146628
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
146451
146629
|
function safeError3(error) {
|
|
@@ -146696,7 +146874,7 @@ function resolveMediaAudioRunnerPath(moduleUrl = import.meta.url) {
|
|
|
146696
146874
|
}
|
|
146697
146875
|
function launchMediaAudioRunner(request, options = {}) {
|
|
146698
146876
|
const runnerPath = options.runnerPath ?? resolveMediaAudioRunnerPath();
|
|
146699
|
-
if (!
|
|
146877
|
+
if (!existsSync11(runnerPath)) return { launched: false, reason: "Audio runner is unavailable until Memorix is built or reinstalled." };
|
|
146700
146878
|
try {
|
|
146701
146879
|
const child = spawn3(process.execPath, [runnerPath, JSON.stringify(request)], {
|
|
146702
146880
|
cwd: request.projectRoot,
|
|
@@ -149109,6 +149287,7 @@ var init_store = __esm({
|
|
|
149109
149287
|
recordCodeStateSnapshot(input) {
|
|
149110
149288
|
const id = randomUUID11();
|
|
149111
149289
|
let snapshot;
|
|
149290
|
+
let compactNeeded = false;
|
|
149112
149291
|
const tx = this.db.transaction(() => {
|
|
149113
149292
|
const previous = this.db.prepare(
|
|
149114
149293
|
"SELECT id, sourceEpoch FROM code_state_snapshots WHERE projectId = ? ORDER BY sourceEpoch DESC LIMIT 1"
|
|
@@ -149152,6 +149331,26 @@ var init_store = __esm({
|
|
|
149152
149331
|
for (const file of snapshotFileRows) {
|
|
149153
149332
|
insertSnapshotFile.run(id, file.projectId, file.id, file.path, file.contentHash);
|
|
149154
149333
|
}
|
|
149334
|
+
const staleSymbolIds = this.db.prepare(
|
|
149335
|
+
"SELECT id FROM code_symbols WHERE projectId = ? AND stale = 1"
|
|
149336
|
+
).all(input.projectId).map((row) => row.id);
|
|
149337
|
+
if (staleSymbolIds.length > 0) {
|
|
149338
|
+
const placeholders = staleSymbolIds.map(() => "?").join(", ");
|
|
149339
|
+
this.db.prepare(
|
|
149340
|
+
`DELETE FROM code_edges WHERE projectId = ? AND (fromSymbolId IN (${placeholders}) OR toSymbolId IN (${placeholders}))`
|
|
149341
|
+
).run(input.projectId, ...staleSymbolIds, ...staleSymbolIds);
|
|
149342
|
+
this.db.prepare("DELETE FROM code_symbols WHERE projectId = ? AND stale = 1").run(input.projectId);
|
|
149343
|
+
compactNeeded = true;
|
|
149344
|
+
}
|
|
149345
|
+
const oldSnapshots = this.db.prepare(
|
|
149346
|
+
"SELECT id FROM code_state_snapshots WHERE projectId = ? ORDER BY sourceEpoch DESC LIMIT -1 OFFSET 2"
|
|
149347
|
+
).all(input.projectId).map((row) => row.id);
|
|
149348
|
+
if (oldSnapshots.length > 0) {
|
|
149349
|
+
const placeholders = oldSnapshots.map(() => "?").join(", ");
|
|
149350
|
+
this.db.prepare(`DELETE FROM code_state_snapshot_files WHERE snapshotId IN (${placeholders})`).run(...oldSnapshots);
|
|
149351
|
+
this.db.prepare(`DELETE FROM code_state_snapshots WHERE id IN (${placeholders})`).run(...oldSnapshots);
|
|
149352
|
+
compactNeeded = true;
|
|
149353
|
+
}
|
|
149155
149354
|
snapshot = {
|
|
149156
149355
|
...input,
|
|
149157
149356
|
id,
|
|
@@ -149160,11 +149359,24 @@ var init_store = __esm({
|
|
|
149160
149359
|
};
|
|
149161
149360
|
});
|
|
149162
149361
|
tx();
|
|
149362
|
+
if (compactNeeded) this.compactStorage();
|
|
149163
149363
|
return snapshot;
|
|
149164
149364
|
}
|
|
149365
|
+
/** Reclaim WAL/free pages after a derived codegraph sweep. */
|
|
149366
|
+
compactStorage() {
|
|
149367
|
+
try {
|
|
149368
|
+
this.db.pragma("wal_checkpoint(TRUNCATE)");
|
|
149369
|
+
} catch {
|
|
149370
|
+
}
|
|
149371
|
+
try {
|
|
149372
|
+
this.db.exec("VACUUM");
|
|
149373
|
+
} catch {
|
|
149374
|
+
}
|
|
149375
|
+
}
|
|
149165
149376
|
status(projectId) {
|
|
149166
149377
|
const files = this.db.prepare(`SELECT COUNT(*) AS count FROM code_files WHERE projectId = ?`).get(projectId).count;
|
|
149167
149378
|
const symbols = this.db.prepare(`SELECT COUNT(*) AS count FROM code_symbols WHERE projectId = ? AND stale = 0`).get(projectId).count;
|
|
149379
|
+
const staleSymbols = this.db.prepare(`SELECT COUNT(*) AS count FROM code_symbols WHERE projectId = ? AND stale = 1`).get(projectId).count;
|
|
149168
149380
|
const edges = this.db.prepare(`SELECT COUNT(*) AS count FROM code_edges WHERE projectId = ?`).get(projectId).count;
|
|
149169
149381
|
const refs = this.db.prepare(`SELECT COUNT(*) AS count FROM observation_code_refs WHERE projectId = ?`).get(projectId).count;
|
|
149170
149382
|
const semanticSymbols = this.db.prepare(`SELECT COUNT(*) AS count FROM code_symbols WHERE projectId = ? AND stale = 0 AND source = 'typescript-compiler'`).get(projectId).count;
|
|
@@ -149172,6 +149384,8 @@ var init_store = __esm({
|
|
|
149172
149384
|
const parserErrors = this.db.prepare(`SELECT COUNT(*) AS count FROM code_files WHERE projectId = ? AND parserError IS NOT NULL`).get(projectId).count;
|
|
149173
149385
|
const latest = this.db.prepare(`SELECT MAX(indexedAt) AS indexedAt FROM code_files WHERE projectId = ?`).get(projectId);
|
|
149174
149386
|
const latestSnapshot = this.latestSnapshot(projectId);
|
|
149387
|
+
const snapshots = this.db.prepare(`SELECT COUNT(*) AS count FROM code_state_snapshots WHERE projectId = ?`).get(projectId).count;
|
|
149388
|
+
const snapshotFiles = this.db.prepare(`SELECT COUNT(*) AS count FROM code_state_snapshot_files WHERE projectId = ?`).get(projectId).count;
|
|
149175
149389
|
return {
|
|
149176
149390
|
provider: "lite",
|
|
149177
149391
|
files,
|
|
@@ -149181,6 +149395,9 @@ var init_store = __esm({
|
|
|
149181
149395
|
semanticSymbols,
|
|
149182
149396
|
semanticEdges,
|
|
149183
149397
|
parserErrors,
|
|
149398
|
+
staleSymbols,
|
|
149399
|
+
snapshots,
|
|
149400
|
+
snapshotFiles,
|
|
149184
149401
|
...latest?.indexedAt ? { indexedAt: latest.indexedAt } : {},
|
|
149185
149402
|
...latestSnapshot ? { latestSnapshot } : {}
|
|
149186
149403
|
};
|
|
@@ -149665,7 +149882,7 @@ __export(lite_provider_exports, {
|
|
|
149665
149882
|
refreshProjectLite: () => refreshProjectLite
|
|
149666
149883
|
});
|
|
149667
149884
|
import { createHash as createHash11 } from "crypto";
|
|
149668
|
-
import { existsSync as
|
|
149885
|
+
import { existsSync as existsSync13, readdirSync as readdirSync2, readFileSync as readFileSync8, statSync as statSync3 } from "fs";
|
|
149669
149886
|
import { join as join4, relative as relative2 } from "path";
|
|
149670
149887
|
function hashText2(text3) {
|
|
149671
149888
|
return createHash11("sha256").update(text3).digest("hex");
|
|
@@ -149683,7 +149900,7 @@ function resolveMaxFileBytes(value) {
|
|
|
149683
149900
|
return Math.max(1, Math.floor(value));
|
|
149684
149901
|
}
|
|
149685
149902
|
function isPythonVirtualenvDir(dir) {
|
|
149686
|
-
return
|
|
149903
|
+
return existsSync13(join4(dir, "pyvenv.cfg"));
|
|
149687
149904
|
}
|
|
149688
149905
|
function walk(root, exclude, maxFiles) {
|
|
149689
149906
|
const out = [];
|
|
@@ -153599,7 +153816,7 @@ __export(vector_backfill_runner_exports, {
|
|
|
153599
153816
|
import { spawn as spawn4 } from "child_process";
|
|
153600
153817
|
import {
|
|
153601
153818
|
closeSync,
|
|
153602
|
-
existsSync as
|
|
153819
|
+
existsSync as existsSync14,
|
|
153603
153820
|
mkdirSync as mkdirSync2,
|
|
153604
153821
|
openSync,
|
|
153605
153822
|
readFileSync as readFileSync9,
|
|
@@ -153727,7 +153944,7 @@ function releaseVectorBackfillLock(lockPath = process.env.MEMORIX_VECTOR_BACKFIL
|
|
|
153727
153944
|
}
|
|
153728
153945
|
function launchDetachedVectorBackfill(request, options = {}) {
|
|
153729
153946
|
const runnerPath = options.runnerPath ?? resolveVectorBackfillRunnerPath();
|
|
153730
|
-
const exists = options.exists ??
|
|
153947
|
+
const exists = options.exists ?? existsSync14;
|
|
153731
153948
|
if (!exists(runnerPath)) return false;
|
|
153732
153949
|
const lock = acquireVectorBackfillLock(request.dataDir, request.projectId, options.lockPath);
|
|
153733
153950
|
if (!lock) return false;
|
|
@@ -153883,10 +154100,22 @@ function resetObservationRuntime() {
|
|
|
153883
154100
|
loadedObservationStore = null;
|
|
153884
154101
|
embeddingWriteMode = "background";
|
|
153885
154102
|
embeddingWorkerProjectRoot = void 0;
|
|
153886
|
-
|
|
154103
|
+
clearVectorMissingIds();
|
|
153887
154104
|
vectorSchemaUpgradePromise = null;
|
|
153888
154105
|
embeddingFailureLogTimestamps.clear();
|
|
153889
154106
|
}
|
|
154107
|
+
function markVectorMissing(observationId2, projectId) {
|
|
154108
|
+
vectorMissingIds.add(observationId2);
|
|
154109
|
+
vectorMissingProjectIds.set(observationId2, projectId);
|
|
154110
|
+
}
|
|
154111
|
+
function clearVectorMissing(observationId2) {
|
|
154112
|
+
vectorMissingIds.delete(observationId2);
|
|
154113
|
+
vectorMissingProjectIds.delete(observationId2);
|
|
154114
|
+
}
|
|
154115
|
+
function clearVectorMissingIds() {
|
|
154116
|
+
vectorMissingIds.clear();
|
|
154117
|
+
vectorMissingProjectIds.clear();
|
|
154118
|
+
}
|
|
153890
154119
|
function logEmbeddingFailureOnce(key, message) {
|
|
153891
154120
|
const now3 = Date.now();
|
|
153892
154121
|
const last = embeddingFailureLogTimestamps.get(key) ?? 0;
|
|
@@ -154006,10 +154235,13 @@ function isVectorCompatibleWithCurrentIndex(embedding) {
|
|
|
154006
154235
|
}
|
|
154007
154236
|
async function upgradeVectorSchemaAfterFirstEmbedding(embedding) {
|
|
154008
154237
|
if (isVectorCompatibleWithCurrentIndex(embedding)) return true;
|
|
154009
|
-
if (
|
|
154238
|
+
if (!embedding.every(Number.isFinite)) return false;
|
|
154010
154239
|
const targetProjectDir = projectDir;
|
|
154011
154240
|
if (!vectorSchemaUpgradePromise) {
|
|
154012
|
-
vectorSchemaUpgradePromise =
|
|
154241
|
+
vectorSchemaUpgradePromise = getDb().then(async () => {
|
|
154242
|
+
if (getVectorDimensions() === null && observations.length > 0) await reindexObservations();
|
|
154243
|
+
return projectDir === targetProjectDir && isVectorCompatibleWithCurrentIndex(embedding);
|
|
154244
|
+
}).catch(() => false).finally(() => {
|
|
154013
154245
|
vectorSchemaUpgradePromise = null;
|
|
154014
154246
|
});
|
|
154015
154247
|
}
|
|
@@ -154049,9 +154281,9 @@ async function initObservations(dir, options = {}) {
|
|
|
154049
154281
|
}
|
|
154050
154282
|
function scheduleObservationEmbedding(input) {
|
|
154051
154283
|
const { observationId: observationId2, projectId, searchableText, doc } = input;
|
|
154052
|
-
|
|
154284
|
+
markVectorMissing(observationId2, projectId);
|
|
154053
154285
|
if (isEmbeddingExplicitlyDisabled()) {
|
|
154054
|
-
|
|
154286
|
+
clearVectorMissing(observationId2);
|
|
154055
154287
|
return;
|
|
154056
154288
|
}
|
|
154057
154289
|
if (embeddingWriteMode === "deferred") {
|
|
@@ -154086,13 +154318,13 @@ function scheduleObservationEmbedding(input) {
|
|
|
154086
154318
|
vector: embedding
|
|
154087
154319
|
});
|
|
154088
154320
|
}
|
|
154089
|
-
|
|
154321
|
+
clearVectorMissing(observationId2);
|
|
154090
154322
|
} catch {
|
|
154091
154323
|
console.error(`[memorix] Embedding index update failed for obs-${observationId2} (kept in backfill queue)`);
|
|
154092
154324
|
queueVectorBackfill(projectId);
|
|
154093
154325
|
}
|
|
154094
154326
|
} else if (isEmbeddingExplicitlyDisabled()) {
|
|
154095
|
-
|
|
154327
|
+
clearVectorMissing(observationId2);
|
|
154096
154328
|
} else {
|
|
154097
154329
|
queueVectorBackfill(projectId);
|
|
154098
154330
|
logEmbeddingFailureOnce(
|
|
@@ -154652,7 +154884,7 @@ async function reindexObservations() {
|
|
|
154652
154884
|
if (observations.length === 0) return 0;
|
|
154653
154885
|
await resetDb();
|
|
154654
154886
|
searchIndexPrepared = false;
|
|
154655
|
-
|
|
154887
|
+
clearVectorMissingIds();
|
|
154656
154888
|
let embeddings = observations.map(() => null);
|
|
154657
154889
|
const provider2 = await getEmbeddingProvider();
|
|
154658
154890
|
const canBatchEmbedAtStartup = provider2 !== null && !provider2.name.startsWith("api-");
|
|
@@ -154717,7 +154949,7 @@ async function reindexObservations() {
|
|
|
154717
154949
|
};
|
|
154718
154950
|
await insertObservation(doc);
|
|
154719
154951
|
if (!compatibleEmbedding && !isEmbeddingExplicitlyDisabled()) {
|
|
154720
|
-
|
|
154952
|
+
markVectorMissing(obs.id, obs.projectId);
|
|
154721
154953
|
}
|
|
154722
154954
|
count2++;
|
|
154723
154955
|
} catch (err) {
|
|
@@ -154734,7 +154966,17 @@ async function prepareSearchIndex(options = {}) {
|
|
|
154734
154966
|
if (!isEmbeddingExplicitlyDisabled()) {
|
|
154735
154967
|
const store = getObservationStore();
|
|
154736
154968
|
const projects = await store.listProjectIds?.() ?? [];
|
|
154737
|
-
|
|
154969
|
+
await getDb({ allowNetworkProbe: false }).catch(() => void 0);
|
|
154970
|
+
const persistedIds = projectDir ? await getPersistentSemanticVectorIds(projectDir).catch(() => null) : null;
|
|
154971
|
+
for (const projectId of projects) {
|
|
154972
|
+
const projectObservations = await store.loadByProject(projectId);
|
|
154973
|
+
for (const observation of projectObservations) {
|
|
154974
|
+
if (!persistedIds?.has(observation.id)) markVectorMissing(observation.id, observation.projectId);
|
|
154975
|
+
}
|
|
154976
|
+
if (projectObservations.some((observation) => !persistedIds?.has(observation.id))) {
|
|
154977
|
+
queueVectorBackfill(projectId);
|
|
154978
|
+
}
|
|
154979
|
+
}
|
|
154738
154980
|
}
|
|
154739
154981
|
return 0;
|
|
154740
154982
|
}
|
|
@@ -154746,14 +154988,15 @@ async function prepareSearchIndex(options = {}) {
|
|
|
154746
154988
|
return 0;
|
|
154747
154989
|
}
|
|
154748
154990
|
const hydratedProjectDir = projectDir;
|
|
154749
|
-
const queueMissingVectors = () => {
|
|
154750
|
-
if (projectDir !== hydratedProjectDir) return;
|
|
154751
|
-
|
|
154991
|
+
const queueMissingVectors = async () => {
|
|
154992
|
+
if (!hydratedProjectDir || projectDir !== hydratedProjectDir) return;
|
|
154993
|
+
clearVectorMissingIds();
|
|
154752
154994
|
if (!isEmbeddingExplicitlyDisabled()) {
|
|
154995
|
+
const persistedSemanticIds = await getPersistentSemanticVectorIds(hydratedProjectDir).catch(() => null);
|
|
154753
154996
|
const projectsWithMissingVectors = /* @__PURE__ */ new Set();
|
|
154754
154997
|
for (const obs of observations) {
|
|
154755
|
-
if (!hasObservationVector(obs.projectId, obs.id)) {
|
|
154756
|
-
|
|
154998
|
+
if (!hasObservationVector(obs.projectId, obs.id) && !persistedSemanticIds?.has(obs.id)) {
|
|
154999
|
+
markVectorMissing(obs.id, obs.projectId);
|
|
154757
155000
|
projectsWithMissingVectors.add(obs.projectId);
|
|
154758
155001
|
}
|
|
154759
155002
|
}
|
|
@@ -154762,15 +155005,18 @@ async function prepareSearchIndex(options = {}) {
|
|
|
154762
155005
|
};
|
|
154763
155006
|
const cacheHydration = getDeferredCachedVectorHydration();
|
|
154764
155007
|
if (cacheHydration) {
|
|
154765
|
-
void cacheHydration.
|
|
155008
|
+
void cacheHydration.then(queueMissingVectors, queueMissingVectors).catch(() => void 0);
|
|
154766
155009
|
} else {
|
|
154767
|
-
queueMissingVectors();
|
|
155010
|
+
await queueMissingVectors();
|
|
154768
155011
|
}
|
|
154769
155012
|
searchIndexPrepared = true;
|
|
154770
155013
|
return count2;
|
|
154771
155014
|
}
|
|
154772
155015
|
function getVectorMissingIds(projectId) {
|
|
154773
155016
|
if (!projectId) return [...vectorMissingIds];
|
|
155017
|
+
if (!corpusLoaded) {
|
|
155018
|
+
return [...vectorMissingIds].filter((id) => vectorMissingProjectIds.get(id) === projectId);
|
|
155019
|
+
}
|
|
154774
155020
|
const observationById = new Map(observations.map((observation) => [observation.id, observation]));
|
|
154775
155021
|
return [...vectorMissingIds].filter((id) => observationById.get(id)?.projectId === projectId);
|
|
154776
155022
|
}
|
|
@@ -154808,7 +155054,8 @@ async function backfillVectorEmbeddings(options = {}) {
|
|
|
154808
155054
|
return { attempted: 0, succeeded: 0, failed: 0 };
|
|
154809
155055
|
}
|
|
154810
155056
|
vectorBackfillRunning = true;
|
|
154811
|
-
const
|
|
155057
|
+
const sourceObservations = corpusLoaded ? observations : options.projectId ? await getObservationStore().loadByProject(options.projectId, { status: "active" }) : await getObservationStore().loadAll();
|
|
155058
|
+
const observationById = new Map(sourceObservations.map((observation) => [observation.id, observation]));
|
|
154812
155059
|
const limit2 = Number.isFinite(options.limit) ? Math.max(1, Math.floor(options.limit)) : Number.POSITIVE_INFINITY;
|
|
154813
155060
|
const ids = [...vectorMissingIds].filter((id) => !options.projectId || observationById.get(id)?.projectId === options.projectId).slice(0, limit2);
|
|
154814
155061
|
let succeeded = 0;
|
|
@@ -154821,7 +155068,7 @@ async function backfillVectorEmbeddings(options = {}) {
|
|
|
154821
155068
|
for (const id of ids) {
|
|
154822
155069
|
const observation = observationById.get(id);
|
|
154823
155070
|
if (!observation) {
|
|
154824
|
-
|
|
155071
|
+
clearVectorMissing(id);
|
|
154825
155072
|
continue;
|
|
154826
155073
|
}
|
|
154827
155074
|
candidates.push({
|
|
@@ -154839,7 +155086,7 @@ async function backfillVectorEmbeddings(options = {}) {
|
|
|
154839
155086
|
const provider2 = await getEmbeddingProvider();
|
|
154840
155087
|
if (!provider2) {
|
|
154841
155088
|
if (isEmbeddingExplicitlyDisabled()) {
|
|
154842
|
-
for (const candidate of candidates)
|
|
155089
|
+
for (const candidate of candidates) clearVectorMissing(candidate.id);
|
|
154843
155090
|
} else {
|
|
154844
155091
|
recordFailure("embedding provider unavailable");
|
|
154845
155092
|
failed += candidates.length;
|
|
@@ -154916,7 +155163,7 @@ async function backfillVectorEmbeddings(options = {}) {
|
|
|
154916
155163
|
vector: embedding
|
|
154917
155164
|
});
|
|
154918
155165
|
}
|
|
154919
|
-
|
|
155166
|
+
clearVectorMissing(id);
|
|
154920
155167
|
succeeded++;
|
|
154921
155168
|
} catch (error) {
|
|
154922
155169
|
recordFailure(vectorBackfillError(error));
|
|
@@ -154941,7 +155188,7 @@ async function backfillVectorEmbeddings(options = {}) {
|
|
|
154941
155188
|
...lastFailure ? { lastError: lastFailure } : {}
|
|
154942
155189
|
};
|
|
154943
155190
|
}
|
|
154944
|
-
var observations, nextId, projectDir, searchIndexPrepared, embeddingWriteMode, embeddingWorkerProjectRoot, corpusLoaded, largeCorpusLazyMode, loadedObservationStore, DEFAULT_ORAMA_HYDRATION_THRESHOLD, vectorMissingIds, vectorBackfillRunning, vectorSchemaUpgradePromise, lastVectorBackfill, embeddingFailureLogTimestamps, EMBEDDING_FAILURE_LOG_COOLDOWN_MS, MAX_EMBEDDING_FAILURE_KEYS;
|
|
155191
|
+
var observations, nextId, projectDir, searchIndexPrepared, embeddingWriteMode, embeddingWorkerProjectRoot, corpusLoaded, largeCorpusLazyMode, loadedObservationStore, DEFAULT_ORAMA_HYDRATION_THRESHOLD, vectorMissingIds, vectorMissingProjectIds, vectorBackfillRunning, vectorSchemaUpgradePromise, lastVectorBackfill, embeddingFailureLogTimestamps, EMBEDDING_FAILURE_LOG_COOLDOWN_MS, MAX_EMBEDDING_FAILURE_KEYS;
|
|
154945
155192
|
var init_observations = __esm({
|
|
154946
155193
|
"src/memory/observations.ts"() {
|
|
154947
155194
|
"use strict";
|
|
@@ -154966,6 +155213,7 @@ var init_observations = __esm({
|
|
|
154966
155213
|
loadedObservationStore = null;
|
|
154967
155214
|
DEFAULT_ORAMA_HYDRATION_THRESHOLD = 1e4;
|
|
154968
155215
|
vectorMissingIds = /* @__PURE__ */ new Set();
|
|
155216
|
+
vectorMissingProjectIds = /* @__PURE__ */ new Map();
|
|
154969
155217
|
vectorBackfillRunning = false;
|
|
154970
155218
|
vectorSchemaUpgradePromise = null;
|
|
154971
155219
|
lastVectorBackfill = null;
|
|
@@ -156430,7 +156678,7 @@ __export(behavior_exports, {
|
|
|
156430
156678
|
getBehaviorConfig: () => getBehaviorConfig,
|
|
156431
156679
|
resetBehaviorConfigCache: () => resetBehaviorConfigCache
|
|
156432
156680
|
});
|
|
156433
|
-
import { existsSync as
|
|
156681
|
+
import { existsSync as existsSync17, readFileSync as readFileSync11 } from "fs";
|
|
156434
156682
|
import { homedir as homedir22 } from "os";
|
|
156435
156683
|
function isSessionInject(value) {
|
|
156436
156684
|
return value === "full" || value === "minimal" || value === "silent";
|
|
@@ -156441,7 +156689,7 @@ function isFormationMode(value) {
|
|
|
156441
156689
|
function legacyBehavior(homeDir) {
|
|
156442
156690
|
const configPath = getLegacyConfigJsonPath(homeDir);
|
|
156443
156691
|
try {
|
|
156444
|
-
if (!
|
|
156692
|
+
if (!existsSync17(configPath)) return {};
|
|
156445
156693
|
const parsed = JSON.parse(readFileSync11(configPath, "utf-8"));
|
|
156446
156694
|
return parsed.behavior && typeof parsed.behavior === "object" && !Array.isArray(parsed.behavior) ? parsed.behavior : {};
|
|
156447
156695
|
} catch {
|
|
@@ -157887,11 +158135,11 @@ __export(current_facts_exports, {
|
|
|
157887
158135
|
formatGitFact: () => formatGitFact
|
|
157888
158136
|
});
|
|
157889
158137
|
import { execFileSync } from "child_process";
|
|
157890
|
-
import { existsSync as
|
|
158138
|
+
import { existsSync as existsSync18, readFileSync as readFileSync12 } from "fs";
|
|
157891
158139
|
import path29 from "path";
|
|
157892
158140
|
function readTextIfExists(filePath) {
|
|
157893
158141
|
try {
|
|
157894
|
-
if (!
|
|
158142
|
+
if (!existsSync18(filePath)) return null;
|
|
157895
158143
|
return readFileSync12(filePath, "utf8");
|
|
157896
158144
|
} catch {
|
|
157897
158145
|
return null;
|
|
@@ -158182,7 +158430,7 @@ __export(external_provider_exports, {
|
|
|
158182
158430
|
runExternalCodeGraphLifecycle: () => runExternalCodeGraphLifecycle
|
|
158183
158431
|
});
|
|
158184
158432
|
import { spawn as spawn5 } from "child_process";
|
|
158185
|
-
import { existsSync as
|
|
158433
|
+
import { existsSync as existsSync19, readFileSync as readFileSync13 } from "fs";
|
|
158186
158434
|
import { delimiter, dirname as dirname2, extname, isAbsolute as isAbsolute3, join as join20, relative as relative4, resolve as resolve3, sep } from "path";
|
|
158187
158435
|
function boundedTimeout(value) {
|
|
158188
158436
|
if (!Number.isFinite(value)) return DEFAULT_EXTERNAL_CODEGRAPH_TIMEOUT_MS;
|
|
@@ -158219,13 +158467,13 @@ function resolveCommandCandidates(command) {
|
|
|
158219
158467
|
}
|
|
158220
158468
|
function resolveLaunch(command) {
|
|
158221
158469
|
for (const candidate of resolveCommandCandidates(command)) {
|
|
158222
|
-
if (!
|
|
158470
|
+
if (!existsSync19(candidate)) continue;
|
|
158223
158471
|
const extension3 = extname(candidate).toLowerCase();
|
|
158224
158472
|
if (extension3 === ".cmd") {
|
|
158225
158473
|
const bundleRoot = resolve3(dirname2(candidate), "..");
|
|
158226
158474
|
const node = join20(bundleRoot, "node.exe");
|
|
158227
158475
|
const entry = join20(bundleRoot, "lib", "dist", "bin", "codegraph.js");
|
|
158228
|
-
if (
|
|
158476
|
+
if (existsSync19(node) && existsSync19(entry)) {
|
|
158229
158477
|
return { executable: node, prefixArgs: ["--liftoff-only", entry] };
|
|
158230
158478
|
}
|
|
158231
158479
|
try {
|
|
@@ -158234,7 +158482,7 @@ function resolveLaunch(command) {
|
|
|
158234
158482
|
if (match2?.[1]) {
|
|
158235
158483
|
const base = dirname2(candidate).endsWith(sep) ? dirname2(candidate) : dirname2(candidate) + sep;
|
|
158236
158484
|
const entry2 = resolve3(match2[1].replace(/%(?:~)?dp0%?/gi, base));
|
|
158237
|
-
if (
|
|
158485
|
+
if (existsSync19(entry2)) return { executable: process.execPath, prefixArgs: [entry2] };
|
|
158238
158486
|
}
|
|
158239
158487
|
} catch {
|
|
158240
158488
|
}
|
|
@@ -158382,7 +158630,7 @@ async function inspectExternalCodeGraph(input) {
|
|
|
158382
158630
|
const health2 = { state: "disabled", reason: "External CodeGraph is disabled by configuration." };
|
|
158383
158631
|
return { health: health2, quality: providerQuality({ mode, health: health2 }) };
|
|
158384
158632
|
}
|
|
158385
|
-
if (!
|
|
158633
|
+
if (!existsSync19(join20(input.projectRoot, ".codegraph"))) {
|
|
158386
158634
|
const health2 = { state: "not-detected", reason: "No local .codegraph index is present for this project." };
|
|
158387
158635
|
return { health: health2, quality: providerQuality({ mode, health: health2 }) };
|
|
158388
158636
|
}
|
|
@@ -158418,7 +158666,7 @@ async function runExternalCodeGraphLifecycle(input) {
|
|
|
158418
158666
|
};
|
|
158419
158667
|
}
|
|
158420
158668
|
const indexPath = join20(input.projectRoot, ".codegraph");
|
|
158421
|
-
if (input.action === "sync" && !
|
|
158669
|
+
if (input.action === "sync" && !existsSync19(indexPath)) {
|
|
158422
158670
|
const health = { state: "not-detected", reason: "No local .codegraph index is present for this project." };
|
|
158423
158671
|
return {
|
|
158424
158672
|
action: input.action,
|
|
@@ -158428,7 +158676,7 @@ async function runExternalCodeGraphLifecycle(input) {
|
|
|
158428
158676
|
quality: providerQuality({ mode, health })
|
|
158429
158677
|
};
|
|
158430
158678
|
}
|
|
158431
|
-
if (input.action === "init" &&
|
|
158679
|
+
if (input.action === "init" && existsSync19(indexPath)) {
|
|
158432
158680
|
const inspected2 = await inspectExternalCodeGraph(input);
|
|
158433
158681
|
return {
|
|
158434
158682
|
action: input.action,
|
|
@@ -159190,13 +159438,13 @@ function buildCodeGraphDerivedView(input) {
|
|
|
159190
159438
|
...snapshot.sourceEpoch !== void 0 ? { generation: snapshot.sourceEpoch } : {},
|
|
159191
159439
|
freshness: snapshot.incomplete ? "stale" : "current",
|
|
159192
159440
|
rebuildStatus: snapshot.incomplete ? "failed" : "idle",
|
|
159193
|
-
...snapshot.incomplete ? { failureReason: "latest CodeGraph snapshot is incomplete" } : externalFailure && provider2?.external.reason ? { failureReason: provider2.external.reason
|
|
159441
|
+
...snapshot.incomplete ? { failureReason: "latest CodeGraph snapshot is incomplete" } : externalFailure && provider2?.external.reason ? { failureReason: sanitizeDerivedViewFailureReason(provider2.external.reason) } : {}
|
|
159194
159442
|
};
|
|
159195
159443
|
}
|
|
159196
159444
|
return {
|
|
159197
159445
|
freshness: "unknown",
|
|
159198
159446
|
rebuildStatus: externalFailure ? "failed" : "unavailable",
|
|
159199
|
-
...provider2?.external.reason ? { failureReason: provider2.external.reason
|
|
159447
|
+
...provider2?.external.reason ? { failureReason: sanitizeDerivedViewFailureReason(provider2.external.reason) } : { failureReason: "CodeGraph snapshot is not initialized" }
|
|
159200
159448
|
};
|
|
159201
159449
|
}
|
|
159202
159450
|
function buildBoundedContextReceipt(input) {
|
|
@@ -159226,6 +159474,7 @@ var init_context_receipt = __esm({
|
|
|
159226
159474
|
"src/knowledge/context-receipt.ts"() {
|
|
159227
159475
|
"use strict";
|
|
159228
159476
|
init_esm_shims();
|
|
159477
|
+
init_derived_view_receipt();
|
|
159229
159478
|
}
|
|
159230
159479
|
});
|
|
159231
159480
|
|
|
@@ -159842,7 +160091,7 @@ __export(auto_context_exports, {
|
|
|
159842
160091
|
formatAutoProjectContextSummary: () => formatAutoProjectContextSummary,
|
|
159843
160092
|
formatLegacyAutoProjectContextPrompt: () => formatLegacyAutoProjectContextPrompt
|
|
159844
160093
|
});
|
|
159845
|
-
import { existsSync as
|
|
160094
|
+
import { existsSync as existsSync20, statSync as statSync5 } from "fs";
|
|
159846
160095
|
import path30 from "path";
|
|
159847
160096
|
function activeProjectObservations(observations2, projectId) {
|
|
159848
160097
|
return observations2.filter((obs) => obs.projectId === projectId && (obs.status ?? "active") === "active");
|
|
@@ -159900,12 +160149,12 @@ function decideRefresh(input) {
|
|
|
159900
160149
|
return { performed: false, reason: "fresh-enough", message: "Existing project scan is fresh enough." };
|
|
159901
160150
|
}
|
|
159902
160151
|
async function buildAutoProjectContext(input) {
|
|
159903
|
-
const refreshMode = input.refresh ?? "auto";
|
|
159904
160152
|
const now3 = input.now ?? /* @__PURE__ */ new Date();
|
|
159905
160153
|
const task = input.task?.trim();
|
|
159906
160154
|
const lens = resolveTaskLens(task);
|
|
159907
160155
|
const continuationRequested = input.continuation === "always" || input.continuation !== "never" && isContinuationTask(task);
|
|
159908
160156
|
const codegraphConfig = getResolvedConfig({ projectRoot: input.project.rootPath }).codegraph;
|
|
160157
|
+
const refreshMode = input.refresh ?? codegraphConfig.autoRefresh ?? "auto";
|
|
159909
160158
|
const exclude = input.exclude ?? codegraphConfig.excludePatterns;
|
|
159910
160159
|
const maxFileBytes = input.maxFileBytes ?? codegraphConfig.maxFileBytes;
|
|
159911
160160
|
const store = new CodeGraphStore();
|
|
@@ -160217,7 +160466,7 @@ function existingLensCandidates(rootPath, lens) {
|
|
|
160217
160466
|
for (const candidate of lensPathCandidates(lens)) {
|
|
160218
160467
|
const absolute = path30.join(rootPath, candidate);
|
|
160219
160468
|
try {
|
|
160220
|
-
if (!
|
|
160469
|
+
if (!existsSync20(absolute)) continue;
|
|
160221
160470
|
const stat5 = statSync5(absolute);
|
|
160222
160471
|
if (stat5.isFile()) out.push(candidate);
|
|
160223
160472
|
if (stat5.isDirectory()) out.push(candidate.replace(/\\/g, "/"));
|
|
@@ -160741,7 +160990,7 @@ var engine_exports2 = {};
|
|
|
160741
160990
|
__export(engine_exports2, {
|
|
160742
160991
|
SkillsEngine: () => SkillsEngine
|
|
160743
160992
|
});
|
|
160744
|
-
import { existsSync as
|
|
160993
|
+
import { existsSync as existsSync21, readFileSync as readFileSync14, writeFileSync as writeFileSync4, mkdirSync as mkdirSync5, readdirSync as readdirSync4 } from "fs";
|
|
160745
160994
|
import { join as join21 } from "path";
|
|
160746
160995
|
import { homedir as homedir23 } from "os";
|
|
160747
160996
|
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 +161071,7 @@ var init_engine3 = __esm({
|
|
|
160822
161071
|
paths.push(join21(home, dir));
|
|
160823
161072
|
}
|
|
160824
161073
|
for (const skillsRoot of paths) {
|
|
160825
|
-
if (!
|
|
161074
|
+
if (!existsSync21(skillsRoot)) continue;
|
|
160826
161075
|
try {
|
|
160827
161076
|
const entries = readdirSync4(skillsRoot, { withFileTypes: true });
|
|
160828
161077
|
for (const entry of entries) {
|
|
@@ -160830,7 +161079,7 @@ var init_engine3 = __esm({
|
|
|
160830
161079
|
const name = entry.name;
|
|
160831
161080
|
if (seen.has(name)) continue;
|
|
160832
161081
|
const skillMd = join21(skillsRoot, name, "SKILL.md");
|
|
160833
|
-
if (!
|
|
161082
|
+
if (!existsSync21(skillMd)) continue;
|
|
160834
161083
|
try {
|
|
160835
161084
|
const content = readFileSync14(skillMd, "utf-8");
|
|
160836
161085
|
const description = this.parseDescription(content);
|
|
@@ -162409,6 +162658,30 @@ var init_export_import = __esm({
|
|
|
162409
162658
|
}
|
|
162410
162659
|
});
|
|
162411
162660
|
|
|
162661
|
+
// src/runtime/open-browser.ts
|
|
162662
|
+
import { spawn as spawn6 } from "child_process";
|
|
162663
|
+
function resolveLocalBrowserCommand(target, platform = process.platform) {
|
|
162664
|
+
const url = new URL(target);
|
|
162665
|
+
if (url.protocol !== "http:" || !LOCAL_HTTP_HOSTS.has(url.hostname) || !url.port || url.username || url.password) {
|
|
162666
|
+
throw new Error("Only unauthenticated loopback HTTP URLs can be opened automatically");
|
|
162667
|
+
}
|
|
162668
|
+
return platform === "win32" ? { command: "explorer.exe", args: [url.toString()] } : platform === "darwin" ? { command: "open", args: [url.toString()] } : { command: "xdg-open", args: [url.toString()] };
|
|
162669
|
+
}
|
|
162670
|
+
function openLocalBrowser(target) {
|
|
162671
|
+
const { command, args } = resolveLocalBrowserCommand(target);
|
|
162672
|
+
const child = spawn6(command, args, { detached: true, stdio: "ignore", windowsHide: true });
|
|
162673
|
+
child.once("error", () => void 0);
|
|
162674
|
+
child.unref();
|
|
162675
|
+
}
|
|
162676
|
+
var LOCAL_HTTP_HOSTS;
|
|
162677
|
+
var init_open_browser = __esm({
|
|
162678
|
+
"src/runtime/open-browser.ts"() {
|
|
162679
|
+
"use strict";
|
|
162680
|
+
init_esm_shims();
|
|
162681
|
+
LOCAL_HTTP_HOSTS = /* @__PURE__ */ new Set(["127.0.0.1", "localhost", "[::1]"]);
|
|
162682
|
+
}
|
|
162683
|
+
});
|
|
162684
|
+
|
|
162412
162685
|
// src/memory/cleanup.ts
|
|
162413
162686
|
function isLowQualityObservation(title) {
|
|
162414
162687
|
return LOW_QUALITY_PATTERNS.some((pattern) => pattern.test(title.trim()));
|
|
@@ -163417,7 +163690,6 @@ __export(server_exports, {
|
|
|
163417
163690
|
import { createServer } from "http";
|
|
163418
163691
|
import { promises as fs19 } from "fs";
|
|
163419
163692
|
import path32 from "path";
|
|
163420
|
-
import { exec } from "child_process";
|
|
163421
163693
|
function sendJson(res, data, status = 200) {
|
|
163422
163694
|
res.writeHead(status, {
|
|
163423
163695
|
"Content-Type": "application/json; charset=utf-8"
|
|
@@ -163854,7 +164126,7 @@ async function handleApi(req, res, dataDir, projectId, projectName, baseDir, pro
|
|
|
163854
164126
|
}
|
|
163855
164127
|
case "/config": {
|
|
163856
164128
|
const os6 = await import("os");
|
|
163857
|
-
const { existsSync:
|
|
164129
|
+
const { existsSync: existsSync24 } = await import("fs");
|
|
163858
164130
|
const { join: join25 } = await import("path");
|
|
163859
164131
|
const configProjectRoot = effectiveProjectRoot;
|
|
163860
164132
|
const resolved = getResolvedConfig({ projectRoot: configProjectRoot });
|
|
@@ -163882,7 +164154,7 @@ async function handleApi(req, res, dataDir, projectId, projectName, baseDir, pro
|
|
|
163882
164154
|
if (fpath === null) {
|
|
163883
164155
|
files[key] = { exists: false, path: "unavailable", unavailable: true };
|
|
163884
164156
|
} else {
|
|
163885
|
-
files[key] = { exists:
|
|
164157
|
+
files[key] = { exists: existsSync24(fpath), path: fpath };
|
|
163886
164158
|
}
|
|
163887
164159
|
}
|
|
163888
164160
|
} catch {
|
|
@@ -163907,7 +164179,8 @@ async function handleApi(req, res, dataDir, projectId, projectName, baseDir, pro
|
|
|
163907
164179
|
...resolved.memory.llm.provider === "openrouter" || resolved.memory.llm.baseUrl?.includes("openrouter.ai") ? ["OPENROUTER_API_KEY"] : [],
|
|
163908
164180
|
...resolved.memory.llm.provider === "requesty" ? ["REQUESTY_API_KEY"] : [],
|
|
163909
164181
|
...resolved.memory.llm.provider === "apiroute" ? ["API_ROUTE_API_KEY"] : [],
|
|
163910
|
-
...resolved.memory.llm.provider === "cheaperinference" ? ["CHEAPER_INFERENCE_API_KEY"] : []
|
|
164182
|
+
...resolved.memory.llm.provider === "cheaperinference" ? ["CHEAPER_INFERENCE_API_KEY"] : [],
|
|
164183
|
+
...resolved.memory.llm.provider === "runcrate" ? ["RUNCRATE_API_KEY"] : []
|
|
163911
164184
|
];
|
|
163912
164185
|
if (llmKey) {
|
|
163913
164186
|
const src = resolveDashboardKeySource({ value: llmKey, envKeys: memoryKeyEnv, configSource });
|
|
@@ -164122,9 +164395,10 @@ async function serveStatic(req, res, staticDir) {
|
|
|
164122
164395
|
}
|
|
164123
164396
|
}
|
|
164124
164397
|
function openBrowser(url) {
|
|
164125
|
-
|
|
164126
|
-
|
|
164127
|
-
}
|
|
164398
|
+
try {
|
|
164399
|
+
openLocalBrowser(url);
|
|
164400
|
+
} catch {
|
|
164401
|
+
}
|
|
164128
164402
|
}
|
|
164129
164403
|
function parseJsonField(value, fallback) {
|
|
164130
164404
|
if (typeof value !== "string") return value ?? fallback;
|
|
@@ -164360,6 +164634,7 @@ var init_server = __esm({
|
|
|
164360
164634
|
"src/dashboard/server.ts"() {
|
|
164361
164635
|
"use strict";
|
|
164362
164636
|
init_esm_shims();
|
|
164637
|
+
init_open_browser();
|
|
164363
164638
|
init_persistence();
|
|
164364
164639
|
init_obs_store();
|
|
164365
164640
|
init_session_store();
|
|
@@ -164694,7 +164969,7 @@ var init_task_graph = __esm({
|
|
|
164694
164969
|
|
|
164695
164970
|
// src/orchestrate/context-collector.ts
|
|
164696
164971
|
import { execFileSync as execFileSync2 } from "child_process";
|
|
164697
|
-
import { readFileSync as readFileSync15, existsSync as
|
|
164972
|
+
import { readFileSync as readFileSync15, existsSync as existsSync22 } from "fs";
|
|
164698
164973
|
import { join as join22 } from "path";
|
|
164699
164974
|
function normalizeEntryLimit(value, fallback) {
|
|
164700
164975
|
if (!Number.isSafeInteger(value) || value < 1) return fallback;
|
|
@@ -164771,7 +165046,7 @@ function collectFileTree(projectDir2, maxEntries) {
|
|
|
164771
165046
|
function collectDependencies(projectDir2) {
|
|
164772
165047
|
try {
|
|
164773
165048
|
const pkgPath = join22(projectDir2, "package.json");
|
|
164774
|
-
if (!
|
|
165049
|
+
if (!existsSync22(pkgPath)) return "";
|
|
164775
165050
|
const pkg = JSON.parse(readFileSync15(pkgPath, "utf-8"));
|
|
164776
165051
|
const parts = [];
|
|
164777
165052
|
if (pkg.dependencies && Object.keys(pkg.dependencies).length > 0) {
|
|
@@ -165493,7 +165768,7 @@ async function analyzeImage(input) {
|
|
|
165493
165768
|
const config = getLLMConfig();
|
|
165494
165769
|
if (!OPENAI_COMPATIBLE_PROVIDERS.has(config.provider)) {
|
|
165495
165770
|
throw new Error(
|
|
165496
|
-
`Image analysis requires an OpenAI-compatible provider (openai, openrouter, requesty, apiroute, cheaperinference, or custom). Current provider "${config.provider}" uses a different API shape. Set MEMORIX_LLM_PROVIDER=openai or configure an OpenAI-compatible base URL.`
|
|
165771
|
+
`Image analysis requires an OpenAI-compatible provider (openai, openrouter, requesty, apiroute, cheaperinference, runcrate, or custom). Current provider "${config.provider}" uses a different API shape. Set MEMORIX_LLM_PROVIDER=openai or configure an OpenAI-compatible base URL.`
|
|
165497
165772
|
);
|
|
165498
165773
|
}
|
|
165499
165774
|
const bytes = decodeBase64ImagePayload(input.base64, MAX_VISION_IMAGE_BYTES);
|
|
@@ -165532,7 +165807,7 @@ var init_image_loader = __esm({
|
|
|
165532
165807
|
init_provider2();
|
|
165533
165808
|
init_secret_filter();
|
|
165534
165809
|
init_image_payload();
|
|
165535
|
-
OPENAI_COMPATIBLE_PROVIDERS = /* @__PURE__ */ new Set(["openai", "openrouter", "requesty", "apiroute", "cheaperinference", "custom"]);
|
|
165810
|
+
OPENAI_COMPATIBLE_PROVIDERS = /* @__PURE__ */ new Set(["openai", "openrouter", "requesty", "apiroute", "cheaperinference", "runcrate", "custom"]);
|
|
165536
165811
|
MAX_VISION_PROMPT_CHARS = 12e3;
|
|
165537
165812
|
MAX_VISION_DESCRIPTION_CHARS = 12e3;
|
|
165538
165813
|
MAX_VISION_LABELS = 50;
|
|
@@ -167592,11 +167867,11 @@ __export(hooks_path_exports, {
|
|
|
167592
167867
|
resolveGitDir: () => resolveGitDir,
|
|
167593
167868
|
resolveHooksDir: () => resolveHooksDir
|
|
167594
167869
|
});
|
|
167595
|
-
import { existsSync as
|
|
167870
|
+
import { existsSync as existsSync23, readFileSync as readFileSync16, statSync as statSync6, mkdirSync as mkdirSync6 } from "fs";
|
|
167596
167871
|
import path35 from "path";
|
|
167597
167872
|
function resolveGitDir(projectRoot) {
|
|
167598
167873
|
const dotGit = path35.join(projectRoot, ".git");
|
|
167599
|
-
if (!
|
|
167874
|
+
if (!existsSync23(dotGit)) return null;
|
|
167600
167875
|
const stat5 = statSync6(dotGit);
|
|
167601
167876
|
if (stat5.isDirectory()) {
|
|
167602
167877
|
return dotGit;
|
|
@@ -167608,7 +167883,7 @@ function resolveGitDir(projectRoot) {
|
|
|
167608
167883
|
if (match2) {
|
|
167609
167884
|
const gitdir = match2[1].trim();
|
|
167610
167885
|
const resolved = path35.isAbsolute(gitdir) ? gitdir : path35.resolve(projectRoot, gitdir);
|
|
167611
|
-
if (
|
|
167886
|
+
if (existsSync23(resolved)) {
|
|
167612
167887
|
return resolved;
|
|
167613
167888
|
}
|
|
167614
167889
|
}
|
|
@@ -169853,7 +170128,7 @@ var RulesSyncer = class {
|
|
|
169853
170128
|
|
|
169854
170129
|
// src/workspace/engine.ts
|
|
169855
170130
|
init_esm_shims();
|
|
169856
|
-
import { readFileSync as readFileSync10, readdirSync as readdirSync3, existsSync as
|
|
170131
|
+
import { readFileSync as readFileSync10, readdirSync as readdirSync3, existsSync as existsSync16, cpSync, mkdirSync as mkdirSync4 } from "fs";
|
|
169857
170132
|
import { join as join19 } from "path";
|
|
169858
170133
|
import { homedir as homedir21 } from "os";
|
|
169859
170134
|
|
|
@@ -170805,7 +171080,7 @@ function sanitize(input) {
|
|
|
170805
171080
|
|
|
170806
171081
|
// src/workspace/applier.ts
|
|
170807
171082
|
init_esm_shims();
|
|
170808
|
-
import { existsSync as
|
|
171083
|
+
import { existsSync as existsSync15, mkdirSync as mkdirSync3, copyFileSync, writeFileSync as writeFileSync3, unlinkSync as unlinkSync2, renameSync } from "fs";
|
|
170809
171084
|
import { dirname } from "path";
|
|
170810
171085
|
var WorkspaceSyncApplier = class {
|
|
170811
171086
|
/**
|
|
@@ -170831,7 +171106,7 @@ var WorkspaceSyncApplier = class {
|
|
|
170831
171106
|
for (const file of files) {
|
|
170832
171107
|
try {
|
|
170833
171108
|
const dir = dirname(file.filePath);
|
|
170834
|
-
if (!
|
|
171109
|
+
if (!existsSync15(dir)) {
|
|
170835
171110
|
mkdirSync3(dir, { recursive: true });
|
|
170836
171111
|
}
|
|
170837
171112
|
} catch (err) {
|
|
@@ -170840,7 +171115,7 @@ var WorkspaceSyncApplier = class {
|
|
|
170840
171115
|
}
|
|
170841
171116
|
}
|
|
170842
171117
|
for (const file of files) {
|
|
170843
|
-
if (
|
|
171118
|
+
if (existsSync15(file.filePath)) {
|
|
170844
171119
|
try {
|
|
170845
171120
|
const backupPath = file.filePath + `.backup-${Date.now()}`;
|
|
170846
171121
|
copyFileSync(file.filePath, backupPath);
|
|
@@ -170891,7 +171166,7 @@ var WorkspaceSyncApplier = class {
|
|
|
170891
171166
|
cleanBackups(backups) {
|
|
170892
171167
|
for (const backup of backups) {
|
|
170893
171168
|
try {
|
|
170894
|
-
if (
|
|
171169
|
+
if (existsSync15(backup.backupPath)) {
|
|
170895
171170
|
unlinkSync2(backup.backupPath);
|
|
170896
171171
|
}
|
|
170897
171172
|
} catch {
|
|
@@ -170956,7 +171231,7 @@ var WorkspaceSyncEngine = class _WorkspaceSyncEngine {
|
|
|
170956
171231
|
}
|
|
170957
171232
|
const merged = /* @__PURE__ */ new Map();
|
|
170958
171233
|
for (const path37 of pathsToCheck) {
|
|
170959
|
-
if (
|
|
171234
|
+
if (existsSync16(path37)) {
|
|
170960
171235
|
try {
|
|
170961
171236
|
const content = readFileSync10(path37, "utf-8");
|
|
170962
171237
|
const servers = adapter.parse(content);
|
|
@@ -171010,7 +171285,7 @@ var WorkspaceSyncEngine = class _WorkspaceSyncEngine {
|
|
|
171010
171285
|
const adapter = this.adapters.get(target);
|
|
171011
171286
|
const configPath = adapter.getConfigPath(this.projectRoot);
|
|
171012
171287
|
let configContent;
|
|
171013
|
-
if (target === "antigravity" &&
|
|
171288
|
+
if (target === "antigravity" && existsSync16(configPath)) {
|
|
171014
171289
|
try {
|
|
171015
171290
|
const existing = JSON.parse(readFileSync10(configPath, "utf-8"));
|
|
171016
171291
|
const generated = JSON.parse(adapter.generate(result.mcpServers.scanned));
|
|
@@ -171086,13 +171361,13 @@ var WorkspaceSyncEngine = class _WorkspaceSyncEngine {
|
|
|
171086
171361
|
join19(home, dir)
|
|
171087
171362
|
];
|
|
171088
171363
|
for (const skillsRoot of paths) {
|
|
171089
|
-
if (!
|
|
171364
|
+
if (!existsSync16(skillsRoot)) continue;
|
|
171090
171365
|
try {
|
|
171091
171366
|
const entries = readdirSync3(skillsRoot, { withFileTypes: true });
|
|
171092
171367
|
for (const entry of entries) {
|
|
171093
171368
|
if (!entry.isDirectory()) continue;
|
|
171094
171369
|
const skillMd = join19(skillsRoot, entry.name, "SKILL.md");
|
|
171095
|
-
if (!
|
|
171370
|
+
if (!existsSync16(skillMd)) continue;
|
|
171096
171371
|
let description = "";
|
|
171097
171372
|
try {
|
|
171098
171373
|
const content = readFileSync10(skillMd, "utf-8");
|
|
@@ -171141,7 +171416,7 @@ var WorkspaceSyncEngine = class _WorkspaceSyncEngine {
|
|
|
171141
171416
|
for (const skill2 of skills) {
|
|
171142
171417
|
if (skill2.sourceAgent === target) continue;
|
|
171143
171418
|
const dest = join19(targetDir, skill2.name);
|
|
171144
|
-
if (
|
|
171419
|
+
if (existsSync16(dest)) {
|
|
171145
171420
|
skipped.push(`${skill2.name} (already exists in ${target})`);
|
|
171146
171421
|
continue;
|
|
171147
171422
|
}
|
|
@@ -171157,7 +171432,7 @@ var WorkspaceSyncEngine = class _WorkspaceSyncEngine {
|
|
|
171157
171432
|
scanWorkflows() {
|
|
171158
171433
|
const workflows = [];
|
|
171159
171434
|
const wfDir = join19(this.projectRoot, ".windsurf", "workflows");
|
|
171160
|
-
if (!
|
|
171435
|
+
if (!existsSync16(wfDir)) return workflows;
|
|
171161
171436
|
try {
|
|
171162
171437
|
const files = readdirSync3(wfDir).filter((f3) => f3.endsWith(".md"));
|
|
171163
171438
|
for (const file of files) {
|
|
@@ -171550,7 +171825,7 @@ var MCP_SERVER_INFO_META_KEY = "io.modelcontextprotocol/serverInfo";
|
|
|
171550
171825
|
function getMcpServerInfo() {
|
|
171551
171826
|
return {
|
|
171552
171827
|
name: "memorix",
|
|
171553
|
-
version: true ? "1.10.
|
|
171828
|
+
version: true ? "1.10.3" : "1.0.1"
|
|
171554
171829
|
};
|
|
171555
171830
|
}
|
|
171556
171831
|
function createMcpDiscoverResult(capabilities, serverInfo) {
|
|
@@ -172780,7 +173055,18 @@ _Search mode: ${result.receipt.mode}_`;
|
|
|
172780
173055
|
text: text3
|
|
172781
173056
|
}
|
|
172782
173057
|
],
|
|
172783
|
-
|
|
173058
|
+
// Clients that surface only structuredContent (e.g. Claude Code) must
|
|
173059
|
+
// still see the results, not just the retrieval diagnostics.
|
|
173060
|
+
structuredContent: {
|
|
173061
|
+
results: result.entries.map((entry) => ({
|
|
173062
|
+
ref: formatEntryRef(entry),
|
|
173063
|
+
title: entry.title,
|
|
173064
|
+
type: entry.type,
|
|
173065
|
+
time: entry.time,
|
|
173066
|
+
tokens: entry.tokens
|
|
173067
|
+
})),
|
|
173068
|
+
retrieval: result.receipt
|
|
173069
|
+
}
|
|
172784
173070
|
};
|
|
172785
173071
|
}, { loadCorpus: false });
|
|
172786
173072
|
}
|
|
@@ -172830,7 +173116,7 @@ _Search mode: ${result.receipt.mode}_`;
|
|
|
172830
173116
|
inputSchema: {
|
|
172831
173117
|
task: z627.string().optional().describe("Current coding task or question"),
|
|
172832
173118
|
taskId: z627.string().max(120).optional().describe("Optional task continuity ledger id to include in the brief"),
|
|
172833
|
-
refresh: z627.enum(["auto", "always", "never"]).optional().
|
|
173119
|
+
refresh: z627.enum(["auto", "always", "never"]).optional().describe(
|
|
172834
173120
|
"Code Memory refresh policy. auto refreshes only when missing or stale."
|
|
172835
173121
|
),
|
|
172836
173122
|
format: z627.enum(["prompt", "summary", "json", "receipt"]).optional().default("prompt").describe(
|
|
@@ -172886,7 +173172,7 @@ _Search mode: ${result.receipt.mode}_`;
|
|
|
172886
173172
|
task,
|
|
172887
173173
|
taskId,
|
|
172888
173174
|
agent,
|
|
172889
|
-
refresh
|
|
173175
|
+
...refresh ? { refresh } : {},
|
|
172890
173176
|
reader: getObservationReader(),
|
|
172891
173177
|
enqueueRefresh: () => {
|
|
172892
173178
|
enqueueCodegraphRefresh2({
|
|
@@ -174848,9 +175134,12 @@ ${s2.instruction}`.toLowerCase();
|
|
|
174848
175134
|
}
|
|
174849
175135
|
} catch {
|
|
174850
175136
|
}
|
|
175137
|
+
const card = lines.filter(Boolean).join("\n");
|
|
174851
175138
|
return {
|
|
174852
|
-
content: [{ type: "text", text:
|
|
174853
|
-
structuredContent
|
|
175139
|
+
content: [{ type: "text", text: card }],
|
|
175140
|
+
// Clients that surface only structuredContent (e.g. Claude Code) must
|
|
175141
|
+
// still see the session card, not just the binding receipt.
|
|
175142
|
+
structuredContent: { card, binding: bindingReceipt }
|
|
174854
175143
|
};
|
|
174855
175144
|
}
|
|
174856
175145
|
);
|
|
@@ -175076,9 +175365,9 @@ ${json2}
|
|
|
175076
175365
|
req.end();
|
|
175077
175366
|
});
|
|
175078
175367
|
const projectUrl = `${url}?project=${encodeURIComponent(project.id)}`;
|
|
175079
|
-
const { exec
|
|
175368
|
+
const { exec } = await import("child_process");
|
|
175080
175369
|
const cmd = process.platform === "win32" ? `start "" "${projectUrl}"` : process.platform === "darwin" ? `open "${projectUrl}"` : `xdg-open "${projectUrl}"`;
|
|
175081
|
-
|
|
175370
|
+
exec(cmd, { windowsHide: true }, () => {
|
|
175082
175371
|
});
|
|
175083
175372
|
return {
|
|
175084
175373
|
content: [{
|
|
@@ -175127,9 +175416,9 @@ ${json2}
|
|
|
175127
175416
|
req.end();
|
|
175128
175417
|
});
|
|
175129
175418
|
const projectUrl = `${url}?project=${encodeURIComponent(project.id)}`;
|
|
175130
|
-
const { exec
|
|
175419
|
+
const { exec } = await import("child_process");
|
|
175131
175420
|
const cmd = process.platform === "win32" ? `start "" "${projectUrl}"` : process.platform === "darwin" ? `open "${projectUrl}"` : `xdg-open "${projectUrl}"`;
|
|
175132
|
-
|
|
175421
|
+
exec(cmd, { windowsHide: true }, () => {
|
|
175133
175422
|
});
|
|
175134
175423
|
return {
|
|
175135
175424
|
content: [{ type: "text", text: `Dashboard is already running at ${url}. Switched to project: ${project.name} (${project.id}).` }]
|
|
@@ -176280,10 +176569,10 @@ Preview: ${analysis.description.slice(0, 300)}${analysis.description.length > 30
|
|
|
176280
176569
|
const { ensureHooksDir: ensureHooksDir2 } = await Promise.resolve().then(() => (init_hooks_path(), hooks_path_exports));
|
|
176281
176570
|
const resolved = ensureHooksDir2(project.rootPath);
|
|
176282
176571
|
if (resolved) {
|
|
176283
|
-
const { existsSync:
|
|
176572
|
+
const { existsSync: existsSync24, readFileSync: readFileSync17, writeFileSync: writeFileSync5, chmodSync } = await import("fs");
|
|
176284
176573
|
const { hookPath } = resolved;
|
|
176285
176574
|
const HOOK_MARKER = "# [memorix-git-hook]";
|
|
176286
|
-
const needsInstall = !
|
|
176575
|
+
const needsInstall = !existsSync24(hookPath) || !readFileSync17(hookPath, "utf-8").includes(HOOK_MARKER);
|
|
176287
176576
|
if (needsInstall) {
|
|
176288
176577
|
const hookScript = `#!/bin/sh
|
|
176289
176578
|
${HOOK_MARKER}
|
|
@@ -176292,7 +176581,7 @@ if command -v memorix >/dev/null 2>&1; then
|
|
|
176292
176581
|
memorix ingest commit --auto >/dev/null 2>&1 &
|
|
176293
176582
|
fi
|
|
176294
176583
|
`;
|
|
176295
|
-
if (
|
|
176584
|
+
if (existsSync24(hookPath)) {
|
|
176296
176585
|
const existing = readFileSync17(hookPath, "utf-8");
|
|
176297
176586
|
writeFileSync5(hookPath, existing.trimEnd() + `
|
|
176298
176587
|
|