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.
Files changed (73) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +3 -1
  3. package/README.zh-CN.md +3 -1
  4. package/dist/cli/index.js +810 -379
  5. package/dist/cli/memcode.js +0 -0
  6. package/dist/index.js +380 -142
  7. package/dist/maintenance-runner.js +275 -79
  8. package/dist/media-audio-runner.js +247 -51
  9. package/dist/media-video-runner.js +274 -78
  10. package/dist/memcode-runtime/CHANGELOG.md +34 -0
  11. package/dist/sdk.js +431 -142
  12. package/dist/types.d.ts +1 -1
  13. package/dist/vector-backfill-runner.js +274 -78
  14. package/docs/CONFIGURATION.md +34 -0
  15. package/docs/DEVELOPMENT.md +3 -4
  16. package/docs/INTEGRATIONS.md +1 -1
  17. package/docs/PERFORMANCE.md +23 -0
  18. package/docs/README.md +3 -2
  19. package/docs/ROADMAP-1.9.12-2.0.md +2 -2
  20. package/docs/SETUP.md +19 -4
  21. package/package.json +1 -1
  22. package/plugins/antigravity/memorix/plugin.json +1 -1
  23. package/plugins/claude/memorix/.claude-plugin/plugin.json +1 -1
  24. package/plugins/codebuddy/memorix/.codebuddy-plugin/plugin.json +1 -1
  25. package/plugins/codex/memorix/.codex-plugin/plugin.json +1 -1
  26. package/plugins/copilot/memorix/plugin.json +1 -1
  27. package/plugins/gemini/memorix/gemini-extension.json +1 -1
  28. package/plugins/hermes/memorix/__init__.py +1 -2
  29. package/plugins/hermes/memorix/plugin.yaml +1 -1
  30. package/plugins/omp/memorix/package.json +1 -1
  31. package/plugins/openclaw/memorix/.codex-plugin/plugin.json +1 -1
  32. package/plugins/pi/memorix/package.json +1 -1
  33. package/server.json +2 -2
  34. package/src/cli/commands/agent-integrations.ts +1 -1
  35. package/src/cli/commands/background.ts +1 -1
  36. package/src/cli/commands/context.ts +3 -2
  37. package/src/cli/commands/doctor.ts +9 -0
  38. package/src/cli/commands/explain.ts +3 -2
  39. package/src/cli/commands/init.ts +6 -2
  40. package/src/cli/commands/repair.ts +17 -3
  41. package/src/cli/commands/setup.ts +9 -6
  42. package/src/cli/commands/uninstall.ts +15 -0
  43. package/src/cli/tui/App.tsx +9 -16
  44. package/src/cli/tui/ConfigureView.tsx +2 -0
  45. package/src/codegraph/auto-context.ts +1 -1
  46. package/src/codegraph/store.ts +37 -0
  47. package/src/codegraph/types.ts +3 -0
  48. package/src/compact/index-format.ts +1 -1
  49. package/src/config/dotenv-loader.ts +1 -0
  50. package/src/config/resolved-config.ts +7 -2
  51. package/src/config/toml-loader.ts +1 -0
  52. package/src/config/yaml-loader.ts +4 -2
  53. package/src/dashboard/server.ts +5 -6
  54. package/src/hooks/handler.ts +0 -1
  55. package/src/integrations/registry.ts +2 -1
  56. package/src/knowledge/context-receipt.ts +6 -3
  57. package/src/llm/provider.ts +2 -1
  58. package/src/memory/observations.ts +68 -22
  59. package/src/multimodal/image-loader.ts +2 -2
  60. package/src/runtime/open-browser.ts +25 -0
  61. package/src/search/derived-view-receipt.ts +40 -0
  62. package/src/search/semantic-index.ts +149 -1
  63. package/src/server.ts +20 -5
  64. package/src/store/orama-store.ts +59 -19
  65. package/src/types.ts +1 -1
  66. package/src/workspace/mcp-adapters/pi.ts +58 -0
  67. package/plugins/pi/memorix/skills/memorix-git-memory/SKILL.md +0 -26
  68. package/plugins/pi/memorix/skills/memorix-memory/SKILL.md +0 -51
  69. package/plugins/pi/memorix/skills/memorix-mini-skills/SKILL.md +0 -31
  70. package/plugins/pi/memorix/skills/memorix-orchestrate/SKILL.md +0 -28
  71. package/plugins/pi/memorix/skills/memorix-reasoning/SKILL.md +0 -30
  72. package/plugins/pi/memorix/skills/memorix-sessions/SKILL.md +0 -25
  73. package/plugins/pi/memorix/skills/memorix-troubleshooting/SKILL.md +0 -27
package/dist/cli/index.js CHANGED
@@ -3232,7 +3232,7 @@ ${import_picocolors.default.gray(m3)} ${s4}
3232
3232
 
3233
3233
  // src/cli/version.ts
3234
3234
  function getCliVersion() {
3235
- return true ? "1.10.1" : pkg.version;
3235
+ return true ? "1.10.3" : pkg.version;
3236
3236
  }
3237
3237
  var init_version = __esm({
3238
3238
  "src/cli/version.ts"() {
@@ -22146,7 +22146,8 @@ function getResolvedConfig(options = {}) {
22146
22146
  const isRequesty = memoryLlmProvider === "requesty";
22147
22147
  const isApiRoute = memoryLlmProvider === "apiroute";
22148
22148
  const isCheaperInference = memoryLlmProvider === "cheaperinference";
22149
- const usesPresetKeyOnly = isAtlasCloud || isRequesty || isApiRoute || isCheaperInference;
22149
+ const isRuncrate = memoryLlmProvider === "runcrate";
22150
+ const usesPresetKeyOnly = isAtlasCloud || isRequesty || isApiRoute || isCheaperInference || isRuncrate;
22150
22151
  const memoryLlmApiKey = first(
22151
22152
  process.env.MEMORIX_LLM_API_KEY,
22152
22153
  process.env.MEMORIX_API_KEY,
@@ -22154,7 +22155,7 @@ function getResolvedConfig(options = {}) {
22154
22155
  yaml.llm?.apiKey,
22155
22156
  legacy.llm?.apiKey,
22156
22157
  // Never borrow another provider's credentials for these gateway presets.
22157
- isAtlasCloud ? process.env.ATLASCLOUD_API_KEY : isRequesty ? process.env.REQUESTY_API_KEY : isApiRoute ? process.env.API_ROUTE_API_KEY : isCheaperInference ? process.env.CHEAPER_INFERENCE_API_KEY : process.env.OPENAI_API_KEY,
22158
+ 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,
22158
22159
  usesPresetKeyOnly ? void 0 : process.env.ANTHROPIC_API_KEY,
22159
22160
  usesPresetKeyOnly ? void 0 : openRouterMemoryLlmApiKey
22160
22161
  );
@@ -22225,6 +22226,7 @@ function getResolvedConfig(options = {}) {
22225
22226
  codegraph: {
22226
22227
  excludePatterns: firstArray(toml.codegraph?.exclude_patterns, yaml.codegraph?.excludePatterns),
22227
22228
  maxFileBytes: firstNumber(toml.codegraph?.max_file_bytes, yaml.codegraph?.maxFileBytes),
22229
+ autoRefresh: first(toml.codegraph?.auto_refresh, yaml.codegraph?.autoRefresh, "auto"),
22228
22230
  externalContext: first(
22229
22231
  normalizeExternalContext(process.env.MEMORIX_CODEGRAPH_EXTERNAL_CONTEXT),
22230
22232
  toml.codegraph?.external_context,
@@ -22339,6 +22341,7 @@ function getEnvSourceNames() {
22339
22341
  "REQUESTY_API_KEY",
22340
22342
  "API_ROUTE_API_KEY",
22341
22343
  "CHEAPER_INFERENCE_API_KEY",
22344
+ "RUNCRATE_API_KEY",
22342
22345
  "ATLASCLOUD_API_KEY"
22343
22346
  ].filter((name) => process.env[name]);
22344
22347
  }
@@ -25334,6 +25337,7 @@ var init_provider2 = __esm({
25334
25337
  requesty: { baseUrl: "https://router.requesty.ai/v1", model: "openai/gpt-4.1-nano" },
25335
25338
  apiroute: { baseUrl: "https://global.api-route.com/v1", model: "deepseek-v4.1-flash" },
25336
25339
  cheaperinference: { baseUrl: "https://api.cheaperinference.com/v1", model: "gpt-5.4-mini" },
25340
+ runcrate: { baseUrl: "https://api.runcrate.ai/v1", model: "deepseek-ai/DeepSeek-V4.1-Flash" },
25337
25341
  atlascloud: { baseUrl: "https://api.atlascloud.ai/v1", model: "deepseek-ai/deepseek-v3.2" },
25338
25342
  custom: { baseUrl: "http://localhost:11434/v1", model: "llama3" }
25339
25343
  };
@@ -26111,7 +26115,25 @@ var init_obs_store = __esm({
26111
26115
  });
26112
26116
 
26113
26117
  // src/search/semantic-index.ts
26118
+ var semantic_index_exports = {};
26119
+ __export(semantic_index_exports, {
26120
+ closeSemanticIndex: () => closeSemanticIndex,
26121
+ closeSemanticIndexes: () => closeSemanticIndexes,
26122
+ createSemanticIndexProfile: () => createSemanticIndexProfile,
26123
+ deleteSemanticVector: () => deleteSemanticVector,
26124
+ ensureSemanticIndex: () => ensureSemanticIndex,
26125
+ getSemanticIndexStats: () => getSemanticIndexStats,
26126
+ isSemanticIndexAvailable: () => isSemanticIndexAvailable,
26127
+ listSemanticVectorIds: () => listSemanticVectorIds,
26128
+ optimizeSemanticIndex: () => optimizeSemanticIndex,
26129
+ optimizeSemanticIndexes: () => optimizeSemanticIndexes,
26130
+ resetSemanticIndexRuntime: () => resetSemanticIndexRuntime,
26131
+ searchSemanticVectors: () => searchSemanticVectors,
26132
+ upsertSemanticVector: () => upsertSemanticVector,
26133
+ upsertSemanticVectors: () => upsertSemanticVectors
26134
+ });
26114
26135
  import { createHash as createHash4 } from "crypto";
26136
+ import { existsSync as existsSync10 } from "fs";
26115
26137
  import { createRequire as createRequire3 } from "module";
26116
26138
  import path10 from "path";
26117
26139
  function createSemanticIndexProfile(provider2) {
@@ -26155,6 +26177,9 @@ async function loadLanceDb() {
26155
26177
  return null;
26156
26178
  }
26157
26179
  }
26180
+ async function isSemanticIndexAvailable() {
26181
+ return await loadLanceDb() !== null;
26182
+ }
26158
26183
  function semanticIndexEnabled() {
26159
26184
  return process.env.MEMORIX_SEMANTIC_INDEX !== "off" && process.env.MEMORIX_SEMANTIC_INDEX !== "orama";
26160
26185
  }
@@ -26210,17 +26235,127 @@ function queueOperation(key, operation) {
26210
26235
  writeQueues.set(key, run.catch(() => void 0));
26211
26236
  return run;
26212
26237
  }
26238
+ function positiveEnvInt(name, fallback) {
26239
+ const value = Number.parseInt(process.env[name] ?? "", 10);
26240
+ return Number.isSafeInteger(value) && value > 0 ? value : fallback;
26241
+ }
26242
+ function semanticWriteBatchSize() {
26243
+ return positiveEnvInt("MEMORIX_SEMANTIC_WRITE_BATCH_SIZE", DEFAULT_WRITE_BATCH_SIZE);
26244
+ }
26245
+ function semanticWriteFlushMs() {
26246
+ return positiveEnvInt("MEMORIX_SEMANTIC_WRITE_FLUSH_MS", DEFAULT_WRITE_FLUSH_MS);
26247
+ }
26248
+ function semanticOptimizeEvery() {
26249
+ return positiveEnvInt("MEMORIX_SEMANTIC_OPTIMIZE_EVERY", DEFAULT_OPTIMIZE_EVERY);
26250
+ }
26251
+ function semanticVersionRetentionMs() {
26252
+ return positiveEnvInt("MEMORIX_SEMANTIC_VERSION_RETENTION_MS", DEFAULT_VERSION_RETENTION_MS);
26253
+ }
26254
+ async function optimizeState(state) {
26255
+ if (!state.table || typeof state.table.optimize !== "function") return;
26256
+ await state.table.optimize({
26257
+ cleanupOlderThan: new Date(Date.now() - semanticVersionRetentionMs()),
26258
+ deleteUnverified: false
26259
+ });
26260
+ }
26213
26261
  async function mergeVectors(dataDir, profile, records) {
26214
26262
  if (records.length === 0) return;
26215
26263
  const state = await getState(dataDir, profile, records);
26216
26264
  if (!state?.table) return;
26217
26265
  const rows = records.map(toLanceRow);
26218
26266
  await state.table.mergeInsert("observation_id").whenMatchedUpdateAll().whenNotMatchedInsertAll().execute(rows);
26267
+ const key = stateKey(dataDir, profile);
26268
+ const mutationCount = (mutationCounts.get(key) ?? 0) + 1;
26269
+ if (mutationCount >= semanticOptimizeEvery()) {
26270
+ mutationCounts.set(key, 0);
26271
+ await optimizeState(state).catch(() => void 0);
26272
+ } else {
26273
+ mutationCounts.set(key, mutationCount);
26274
+ }
26219
26275
  void ensureSemanticIndex(dataDir, profile);
26220
26276
  }
26277
+ function flushPendingVectorBatch(key) {
26278
+ const pending = pendingVectorBatches.get(key);
26279
+ if (!pending) return Promise.resolve();
26280
+ if (pending.timer) clearTimeout(pending.timer);
26281
+ pendingVectorBatches.delete(key);
26282
+ const records = [...pending.records.values()];
26283
+ const waiters = pending.waiters.splice(0);
26284
+ return queueOperation(key, () => mergeVectors(pending.dataDir, pending.profile, records)).then(() => waiters.forEach((waiter) => waiter.resolve())).catch((error40) => {
26285
+ waiters.forEach((waiter) => waiter.reject(error40));
26286
+ });
26287
+ }
26288
+ function upsertSemanticVector(dataDir, profile, record2) {
26289
+ const key = stateKey(dataDir, profile);
26290
+ let pending = pendingVectorBatches.get(key);
26291
+ if (!pending) {
26292
+ pending = { dataDir, profile, records: /* @__PURE__ */ new Map(), waiters: [] };
26293
+ pendingVectorBatches.set(key, pending);
26294
+ }
26295
+ pending.records.set(`${record2.projectId}:${record2.observationId}`, record2);
26296
+ const promise2 = new Promise((resolve9, reject) => pending.waiters.push({ resolve: resolve9, reject }));
26297
+ if (pending.records.size >= semanticWriteBatchSize()) void flushPendingVectorBatch(key);
26298
+ else if (!pending.timer) pending.timer = setTimeout(() => {
26299
+ void flushPendingVectorBatch(key);
26300
+ }, semanticWriteFlushMs());
26301
+ return promise2;
26302
+ }
26221
26303
  function upsertSemanticVectors(dataDir, profile, records) {
26222
26304
  return queueOperation(stateKey(dataDir, profile), () => mergeVectors(dataDir, profile, records));
26223
26305
  }
26306
+ async function listSemanticVectorIds(dataDir, profile) {
26307
+ const state = await getState(dataDir, profile);
26308
+ if (!state?.table) return null;
26309
+ const rows = await state.table.query().select(["observation_id"]).toArray();
26310
+ return new Set(rows.map((row) => Number(row.observation_id)).filter(Number.isSafeInteger));
26311
+ }
26312
+ async function getSemanticIndexStats(dataDir, profile) {
26313
+ const state = await getState(dataDir, profile);
26314
+ if (!state?.table) return null;
26315
+ return {
26316
+ rowCount: await state.table.countRows(),
26317
+ version: typeof state.table.version === "function" ? await state.table.version() : 0
26318
+ };
26319
+ }
26320
+ function optimizeSemanticIndex(dataDir, profile) {
26321
+ const key = stateKey(dataDir, profile);
26322
+ return queueOperation(key, async () => {
26323
+ const state = await getState(dataDir, profile);
26324
+ if (state) await optimizeState(state);
26325
+ mutationCounts.set(key, 0);
26326
+ });
26327
+ }
26328
+ async function optimizeSemanticIndexes(dataDir) {
26329
+ if (!existsSync10(indexRoot(dataDir))) return [];
26330
+ const lance = await loadLanceDb();
26331
+ if (!lance) throw new Error("LanceDB is unavailable; install the optional @lancedb/lancedb package");
26332
+ const connection = await lance.connect(indexRoot(dataDir));
26333
+ try {
26334
+ const names = typeof connection.tableNames === "function" ? await connection.tableNames() : (await connection.listTables()).tables;
26335
+ const optimized = [];
26336
+ for (const name of names.filter((value) => value.startsWith(TABLE_PREFIX))) {
26337
+ const table = await connection.openTable(name);
26338
+ await table.optimize({
26339
+ cleanupOlderThan: new Date(Date.now() - semanticVersionRetentionMs()),
26340
+ deleteUnverified: false
26341
+ });
26342
+ optimized.push(name);
26343
+ }
26344
+ return optimized;
26345
+ } finally {
26346
+ try {
26347
+ connection.close?.();
26348
+ } catch {
26349
+ }
26350
+ }
26351
+ }
26352
+ function deleteSemanticVector(dataDir, profile, observationId2) {
26353
+ return queueOperation(stateKey(dataDir, profile), async () => {
26354
+ const state = await getState(dataDir, profile);
26355
+ if (!state?.table) return;
26356
+ await state.table.delete(`observation_id = ${Math.trunc(observationId2)}`);
26357
+ });
26358
+ }
26224
26359
  function resolveIndexThreshold() {
26225
26360
  const raw = Number.parseInt(process.env.MEMORIX_SEMANTIC_INDEX_THRESHOLD ?? "", 10);
26226
26361
  return Number.isSafeInteger(raw) && raw > 0 ? raw : DEFAULT_INDEX_THRESHOLD;
@@ -26272,7 +26407,50 @@ async function searchSemanticVectors(options) {
26272
26407
  distance: Number(row._distance ?? Number.POSITIVE_INFINITY)
26273
26408
  })).filter((row) => Number.isFinite(row.distance));
26274
26409
  }
26275
- var SEMANTIC_INDEX_DIR, TABLE_PREFIX, DEFAULT_INDEX_THRESHOLD, MAX_INDEX_PARTITIONS, statePromises, writeQueues, indexBuilds, availability, requireFromHere2;
26410
+ async function closeSemanticIndexes() {
26411
+ await Promise.all([...pendingVectorBatches.keys()].map((key) => flushPendingVectorBatch(key)));
26412
+ await Promise.all([...writeQueues.values()]);
26413
+ for (const statePromise of statePromises.values()) {
26414
+ const state = await statePromise.catch(() => null);
26415
+ try {
26416
+ state?.connection?.close?.();
26417
+ } catch {
26418
+ }
26419
+ }
26420
+ statePromises.clear();
26421
+ writeQueues.clear();
26422
+ indexBuilds.clear();
26423
+ mutationCounts.clear();
26424
+ }
26425
+ async function closeSemanticIndex(dataDir) {
26426
+ const prefix = `${path10.resolve(dataDir)}::`;
26427
+ await Promise.all([...pendingVectorBatches.keys()].filter((key) => key.startsWith(prefix)).map(flushPendingVectorBatch));
26428
+ await Promise.all([...writeQueues.entries()].filter(([key]) => key.startsWith(prefix)).map(([, queue2]) => queue2));
26429
+ for (const [key, statePromise] of statePromises.entries()) {
26430
+ if (!key.startsWith(prefix)) continue;
26431
+ const state = await statePromise.catch(() => null);
26432
+ try {
26433
+ state?.connection?.close?.();
26434
+ } catch {
26435
+ }
26436
+ statePromises.delete(key);
26437
+ writeQueues.delete(key);
26438
+ indexBuilds.delete(key);
26439
+ mutationCounts.delete(key);
26440
+ }
26441
+ }
26442
+ function resetSemanticIndexRuntime() {
26443
+ for (const pending of pendingVectorBatches.values()) {
26444
+ if (pending.timer) clearTimeout(pending.timer);
26445
+ }
26446
+ pendingVectorBatches.clear();
26447
+ statePromises.clear();
26448
+ writeQueues.clear();
26449
+ indexBuilds.clear();
26450
+ mutationCounts.clear();
26451
+ availability = void 0;
26452
+ }
26453
+ 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;
26276
26454
  var init_semantic_index = __esm({
26277
26455
  "src/search/semantic-index.ts"() {
26278
26456
  "use strict";
@@ -26281,13 +26459,84 @@ var init_semantic_index = __esm({
26281
26459
  TABLE_PREFIX = "observations_";
26282
26460
  DEFAULT_INDEX_THRESHOLD = 1e4;
26283
26461
  MAX_INDEX_PARTITIONS = 32;
26462
+ DEFAULT_WRITE_BATCH_SIZE = 100;
26463
+ DEFAULT_WRITE_FLUSH_MS = 50;
26464
+ DEFAULT_OPTIMIZE_EVERY = 20;
26465
+ DEFAULT_VERSION_RETENTION_MS = 24 * 60 * 60 * 1e3;
26284
26466
  statePromises = /* @__PURE__ */ new Map();
26285
26467
  writeQueues = /* @__PURE__ */ new Map();
26286
26468
  indexBuilds = /* @__PURE__ */ new Map();
26469
+ mutationCounts = /* @__PURE__ */ new Map();
26470
+ pendingVectorBatches = /* @__PURE__ */ new Map();
26287
26471
  requireFromHere2 = createRequire3(import.meta.url);
26288
26472
  }
26289
26473
  });
26290
26474
 
26475
+ // src/memory/secret-filter.ts
26476
+ function applyRedaction(text3) {
26477
+ if (!text3) return text3;
26478
+ let out = text3;
26479
+ out = out.replace(
26480
+ /((?:password|passwd|pwd|secret|token|api[_-]?key|auth[_-]?key|access[_-]?key|private[_-]?key|client[_-]?secret)\s*[:=]\s*["']?)([^\s"',;\n]{6,})/gi,
26481
+ "$1[REDACTED]"
26482
+ );
26483
+ out = out.replace(
26484
+ /(Bearer\s+)([A-Za-z0-9._\-/+]{20,})/g,
26485
+ "$1[REDACTED]"
26486
+ );
26487
+ out = out.replace(/\b(?:ghp|ghs|gho|github_pat)_[A-Za-z0-9]{36,}\b/g, "[REDACTED]");
26488
+ out = out.replace(/\bsk-[A-Za-z0-9T-]{20,}\b/g, "[REDACTED]");
26489
+ out = out.replace(/\beyJ[A-Za-z0-9._-]{40,}\b/g, "[REDACTED]");
26490
+ return out;
26491
+ }
26492
+ function sanitizeCredentials(text3) {
26493
+ return applyRedaction(text3);
26494
+ }
26495
+ function redactCredentials(text3) {
26496
+ return applyRedaction(text3);
26497
+ }
26498
+ var init_secret_filter = __esm({
26499
+ "src/memory/secret-filter.ts"() {
26500
+ "use strict";
26501
+ init_esm_shims();
26502
+ }
26503
+ });
26504
+
26505
+ // src/search/derived-view-receipt.ts
26506
+ function sanitizeDerivedViewFailureReason(reason) {
26507
+ const safe = sanitizeCredentials(reason).replace(/(?:[A-Za-z]:[\\/]|\\\\[^\\/\s]+[\\/]|\/(?:home|Users|tmp|var|private|mnt|workspace|workspaces)\/)[^\s"'<>|]*/gi, "[path]").replace(/\s+/g, " ").trim();
26508
+ return safe.slice(0, 240) || "derived view failed";
26509
+ }
26510
+ function embeddingHealthReceipt(health, embeddingEnabled2) {
26511
+ if (health?.status === "disabled") {
26512
+ return { freshness: "current", rebuildStatus: "disabled" };
26513
+ }
26514
+ if (health?.status === "ready" || embeddingEnabled2) {
26515
+ return { freshness: "current", rebuildStatus: "idle" };
26516
+ }
26517
+ if (health?.status === "degraded") {
26518
+ return {
26519
+ freshness: "stale",
26520
+ rebuildStatus: "failed",
26521
+ ...health.failure ? {
26522
+ failureReason: `embedding ${health.failure.kind}; retry in ${health.failure.retryAfterMs}ms`
26523
+ } : { failureReason: "embedding provider degraded" }
26524
+ };
26525
+ }
26526
+ return {
26527
+ freshness: "unknown",
26528
+ rebuildStatus: "unavailable",
26529
+ failureReason: "embedding provider is not initialized"
26530
+ };
26531
+ }
26532
+ var init_derived_view_receipt = __esm({
26533
+ "src/search/derived-view-receipt.ts"() {
26534
+ "use strict";
26535
+ init_esm_shims();
26536
+ init_secret_filter();
26537
+ }
26538
+ });
26539
+
26291
26540
  // src/memory/entity-extractor.ts
26292
26541
  function extractEntities(content) {
26293
26542
  const result = {
@@ -26391,36 +26640,6 @@ var init_entity_extractor = __esm({
26391
26640
  }
26392
26641
  });
26393
26642
 
26394
- // src/memory/secret-filter.ts
26395
- function applyRedaction(text3) {
26396
- if (!text3) return text3;
26397
- let out = text3;
26398
- out = out.replace(
26399
- /((?:password|passwd|pwd|secret|token|api[_-]?key|auth[_-]?key|access[_-]?key|private[_-]?key|client[_-]?secret)\s*[:=]\s*["']?)([^\s"',;\n]{6,})/gi,
26400
- "$1[REDACTED]"
26401
- );
26402
- out = out.replace(
26403
- /(Bearer\s+)([A-Za-z0-9._\-/+]{20,})/g,
26404
- "$1[REDACTED]"
26405
- );
26406
- out = out.replace(/\b(?:ghp|ghs|gho|github_pat)_[A-Za-z0-9]{36,}\b/g, "[REDACTED]");
26407
- out = out.replace(/\bsk-[A-Za-z0-9T-]{20,}\b/g, "[REDACTED]");
26408
- out = out.replace(/\beyJ[A-Za-z0-9._-]{40,}\b/g, "[REDACTED]");
26409
- return out;
26410
- }
26411
- function sanitizeCredentials(text3) {
26412
- return applyRedaction(text3);
26413
- }
26414
- function redactCredentials(text3) {
26415
- return applyRedaction(text3);
26416
- }
26417
- var init_secret_filter = __esm({
26418
- "src/memory/secret-filter.ts"() {
26419
- "use strict";
26420
- init_esm_shims();
26421
- }
26422
- });
26423
-
26424
26643
  // src/runtime/maintenance-jobs.ts
26425
26644
  var maintenance_jobs_exports = {};
26426
26645
  __export(maintenance_jobs_exports, {
@@ -27279,7 +27498,7 @@ var init_maintenance_targets = __esm({
27279
27498
 
27280
27499
  // src/runtime/isolated-maintenance.ts
27281
27500
  import { spawn } from "child_process";
27282
- import { existsSync as existsSync10 } from "fs";
27501
+ import { existsSync as existsSync11 } from "fs";
27283
27502
  import os3 from "os";
27284
27503
  import path11 from "path";
27285
27504
  import { fileURLToPath as fileURLToPath3 } from "url";
@@ -27297,7 +27516,7 @@ function childError(prefix, detail) {
27297
27516
  }
27298
27517
  function isolatedMaintenanceCwd() {
27299
27518
  const tmp = os3.tmpdir();
27300
- return existsSync10(tmp) ? tmp : process.cwd();
27519
+ return existsSync11(tmp) ? tmp : process.cwd();
27301
27520
  }
27302
27521
  function resolveMaintenanceRunnerPath(moduleUrl = import.meta.url) {
27303
27522
  const moduleDir = path11.dirname(fileURLToPath3(moduleUrl));
@@ -27354,7 +27573,7 @@ function collectOutput(stream2, limit2, onOverflow) {
27354
27573
  async function runMaintenanceInChildProcess(request, options = {}) {
27355
27574
  validateRequest(request);
27356
27575
  const runnerPath = options.runnerPath ?? resolveMaintenanceRunnerPath();
27357
- if (!existsSync10(runnerPath)) {
27576
+ if (!existsSync11(runnerPath)) {
27358
27577
  throw new Error(`Maintenance runner is unavailable at ${runnerPath}. Reinstall or rebuild Memorix.`);
27359
27578
  }
27360
27579
  const timeoutMs = Number.isFinite(options.timeoutMs) ? Math.max(1e3, Math.floor(options.timeoutMs)) : DEFAULT_TIMEOUT_MS;
@@ -178372,7 +178591,7 @@ __export(video_jobs_exports, {
178372
178591
  runMiniMaxVideoGenerationJob: () => runMiniMaxVideoGenerationJob
178373
178592
  });
178374
178593
  import { spawn as spawn2 } from "child_process";
178375
- import { existsSync as existsSync11 } from "fs";
178594
+ import { existsSync as existsSync12 } from "fs";
178376
178595
  import path17 from "path";
178377
178596
  import { fileURLToPath as fileURLToPath4 } from "url";
178378
178597
  function safeError2(error40) {
@@ -178620,7 +178839,7 @@ function resolveMediaVideoRunnerPath(moduleUrl = import.meta.url) {
178620
178839
  }
178621
178840
  function launchMediaVideoRunner(request, options = {}) {
178622
178841
  const runnerPath = options.runnerPath ?? resolveMediaVideoRunnerPath();
178623
- if (!existsSync11(runnerPath)) {
178842
+ if (!existsSync12(runnerPath)) {
178624
178843
  return { launched: false, reason: "Media video runner is unavailable until Memorix is built or reinstalled." };
178625
178844
  }
178626
178845
  try {
@@ -178665,7 +178884,7 @@ __export(audio_jobs_exports, {
178665
178884
  transcribeAudio: () => transcribeAudio
178666
178885
  });
178667
178886
  import { spawn as spawn3 } from "child_process";
178668
- import { existsSync as existsSync12 } from "fs";
178887
+ import { existsSync as existsSync13 } from "fs";
178669
178888
  import path18 from "path";
178670
178889
  import { fileURLToPath as fileURLToPath5 } from "url";
178671
178890
  function safeError3(error40) {
@@ -178916,7 +179135,7 @@ function resolveMediaAudioRunnerPath(moduleUrl = import.meta.url) {
178916
179135
  }
178917
179136
  function launchMediaAudioRunner(request, options = {}) {
178918
179137
  const runnerPath = options.runnerPath ?? resolveMediaAudioRunnerPath();
178919
- if (!existsSync12(runnerPath)) return { launched: false, reason: "Audio runner is unavailable until Memorix is built or reinstalled." };
179138
+ if (!existsSync13(runnerPath)) return { launched: false, reason: "Audio runner is unavailable until Memorix is built or reinstalled." };
178920
179139
  try {
178921
179140
  const child = spawn3(process.execPath, [runnerPath, JSON.stringify(request)], {
178922
179141
  cwd: request.projectRoot,
@@ -181333,6 +181552,7 @@ var init_store = __esm({
181333
181552
  recordCodeStateSnapshot(input) {
181334
181553
  const id = randomUUID11();
181335
181554
  let snapshot;
181555
+ let compactNeeded = false;
181336
181556
  const tx = this.db.transaction(() => {
181337
181557
  const previous = this.db.prepare(
181338
181558
  "SELECT id, sourceEpoch FROM code_state_snapshots WHERE projectId = ? ORDER BY sourceEpoch DESC LIMIT 1"
@@ -181376,6 +181596,26 @@ var init_store = __esm({
181376
181596
  for (const file2 of snapshotFileRows) {
181377
181597
  insertSnapshotFile.run(id, file2.projectId, file2.id, file2.path, file2.contentHash);
181378
181598
  }
181599
+ const staleSymbolIds = this.db.prepare(
181600
+ "SELECT id FROM code_symbols WHERE projectId = ? AND stale = 1"
181601
+ ).all(input.projectId).map((row) => row.id);
181602
+ if (staleSymbolIds.length > 0) {
181603
+ const placeholders = staleSymbolIds.map(() => "?").join(", ");
181604
+ this.db.prepare(
181605
+ `DELETE FROM code_edges WHERE projectId = ? AND (fromSymbolId IN (${placeholders}) OR toSymbolId IN (${placeholders}))`
181606
+ ).run(input.projectId, ...staleSymbolIds, ...staleSymbolIds);
181607
+ this.db.prepare("DELETE FROM code_symbols WHERE projectId = ? AND stale = 1").run(input.projectId);
181608
+ compactNeeded = true;
181609
+ }
181610
+ const oldSnapshots = this.db.prepare(
181611
+ "SELECT id FROM code_state_snapshots WHERE projectId = ? ORDER BY sourceEpoch DESC LIMIT -1 OFFSET 2"
181612
+ ).all(input.projectId).map((row) => row.id);
181613
+ if (oldSnapshots.length > 0) {
181614
+ const placeholders = oldSnapshots.map(() => "?").join(", ");
181615
+ this.db.prepare(`DELETE FROM code_state_snapshot_files WHERE snapshotId IN (${placeholders})`).run(...oldSnapshots);
181616
+ this.db.prepare(`DELETE FROM code_state_snapshots WHERE id IN (${placeholders})`).run(...oldSnapshots);
181617
+ compactNeeded = true;
181618
+ }
181379
181619
  snapshot = {
181380
181620
  ...input,
181381
181621
  id,
@@ -181384,11 +181624,24 @@ var init_store = __esm({
181384
181624
  };
181385
181625
  });
181386
181626
  tx();
181627
+ if (compactNeeded) this.compactStorage();
181387
181628
  return snapshot;
181388
181629
  }
181630
+ /** Reclaim WAL/free pages after a derived codegraph sweep. */
181631
+ compactStorage() {
181632
+ try {
181633
+ this.db.pragma("wal_checkpoint(TRUNCATE)");
181634
+ } catch {
181635
+ }
181636
+ try {
181637
+ this.db.exec("VACUUM");
181638
+ } catch {
181639
+ }
181640
+ }
181389
181641
  status(projectId) {
181390
181642
  const files = this.db.prepare(`SELECT COUNT(*) AS count FROM code_files WHERE projectId = ?`).get(projectId).count;
181391
181643
  const symbols = this.db.prepare(`SELECT COUNT(*) AS count FROM code_symbols WHERE projectId = ? AND stale = 0`).get(projectId).count;
181644
+ const staleSymbols = this.db.prepare(`SELECT COUNT(*) AS count FROM code_symbols WHERE projectId = ? AND stale = 1`).get(projectId).count;
181392
181645
  const edges = this.db.prepare(`SELECT COUNT(*) AS count FROM code_edges WHERE projectId = ?`).get(projectId).count;
181393
181646
  const refs = this.db.prepare(`SELECT COUNT(*) AS count FROM observation_code_refs WHERE projectId = ?`).get(projectId).count;
181394
181647
  const semanticSymbols = this.db.prepare(`SELECT COUNT(*) AS count FROM code_symbols WHERE projectId = ? AND stale = 0 AND source = 'typescript-compiler'`).get(projectId).count;
@@ -181396,6 +181649,8 @@ var init_store = __esm({
181396
181649
  const parserErrors = this.db.prepare(`SELECT COUNT(*) AS count FROM code_files WHERE projectId = ? AND parserError IS NOT NULL`).get(projectId).count;
181397
181650
  const latest = this.db.prepare(`SELECT MAX(indexedAt) AS indexedAt FROM code_files WHERE projectId = ?`).get(projectId);
181398
181651
  const latestSnapshot = this.latestSnapshot(projectId);
181652
+ const snapshots = this.db.prepare(`SELECT COUNT(*) AS count FROM code_state_snapshots WHERE projectId = ?`).get(projectId).count;
181653
+ const snapshotFiles = this.db.prepare(`SELECT COUNT(*) AS count FROM code_state_snapshot_files WHERE projectId = ?`).get(projectId).count;
181399
181654
  return {
181400
181655
  provider: "lite",
181401
181656
  files,
@@ -181405,6 +181660,9 @@ var init_store = __esm({
181405
181660
  semanticSymbols,
181406
181661
  semanticEdges,
181407
181662
  parserErrors,
181663
+ staleSymbols,
181664
+ snapshots,
181665
+ snapshotFiles,
181408
181666
  ...latest?.indexedAt ? { indexedAt: latest.indexedAt } : {},
181409
181667
  ...latestSnapshot ? { latestSnapshot } : {}
181410
181668
  };
@@ -181889,7 +182147,7 @@ __export(lite_provider_exports, {
181889
182147
  refreshProjectLite: () => refreshProjectLite
181890
182148
  });
181891
182149
  import { createHash as createHash11 } from "crypto";
181892
- import { existsSync as existsSync14, readdirSync as readdirSync2, readFileSync as readFileSync9, statSync as statSync4 } from "fs";
182150
+ import { existsSync as existsSync15, readdirSync as readdirSync2, readFileSync as readFileSync9, statSync as statSync4 } from "fs";
181893
182151
  import { join as join5, relative as relative2 } from "path";
181894
182152
  function hashText2(text3) {
181895
182153
  return createHash11("sha256").update(text3).digest("hex");
@@ -181907,7 +182165,7 @@ function resolveMaxFileBytes(value) {
181907
182165
  return Math.max(1, Math.floor(value));
181908
182166
  }
181909
182167
  function isPythonVirtualenvDir(dir) {
181910
- return existsSync14(join5(dir, "pyvenv.cfg"));
182168
+ return existsSync15(join5(dir, "pyvenv.cfg"));
181911
182169
  }
181912
182170
  function walk(root, exclude, maxFiles) {
181913
182171
  const out = [];
@@ -185823,7 +186081,7 @@ __export(vector_backfill_runner_exports, {
185823
186081
  import { spawn as spawn4 } from "child_process";
185824
186082
  import {
185825
186083
  closeSync,
185826
- existsSync as existsSync15,
186084
+ existsSync as existsSync16,
185827
186085
  mkdirSync as mkdirSync2,
185828
186086
  openSync,
185829
186087
  readFileSync as readFileSync10,
@@ -185951,7 +186209,7 @@ function releaseVectorBackfillLock(lockPath = process.env.MEMORIX_VECTOR_BACKFIL
185951
186209
  }
185952
186210
  function launchDetachedVectorBackfill(request, options = {}) {
185953
186211
  const runnerPath = options.runnerPath ?? resolveVectorBackfillRunnerPath();
185954
- const exists3 = options.exists ?? existsSync15;
186212
+ const exists3 = options.exists ?? existsSync16;
185955
186213
  if (!exists3(runnerPath)) return false;
185956
186214
  const lock = acquireVectorBackfillLock(request.dataDir, request.projectId, options.lockPath);
185957
186215
  if (!lock) return false;
@@ -186107,10 +186365,22 @@ function resetObservationRuntime() {
186107
186365
  loadedObservationStore = null;
186108
186366
  embeddingWriteMode = "background";
186109
186367
  embeddingWorkerProjectRoot = void 0;
186110
- vectorMissingIds.clear();
186368
+ clearVectorMissingIds();
186111
186369
  vectorSchemaUpgradePromise = null;
186112
186370
  embeddingFailureLogTimestamps.clear();
186113
186371
  }
186372
+ function markVectorMissing(observationId2, projectId) {
186373
+ vectorMissingIds.add(observationId2);
186374
+ vectorMissingProjectIds.set(observationId2, projectId);
186375
+ }
186376
+ function clearVectorMissing(observationId2) {
186377
+ vectorMissingIds.delete(observationId2);
186378
+ vectorMissingProjectIds.delete(observationId2);
186379
+ }
186380
+ function clearVectorMissingIds() {
186381
+ vectorMissingIds.clear();
186382
+ vectorMissingProjectIds.clear();
186383
+ }
186114
186384
  function logEmbeddingFailureOnce(key, message) {
186115
186385
  const now3 = Date.now();
186116
186386
  const last = embeddingFailureLogTimestamps.get(key) ?? 0;
@@ -186230,10 +186500,13 @@ function isVectorCompatibleWithCurrentIndex(embedding) {
186230
186500
  }
186231
186501
  async function upgradeVectorSchemaAfterFirstEmbedding(embedding) {
186232
186502
  if (isVectorCompatibleWithCurrentIndex(embedding)) return true;
186233
- if (getVectorDimensions() !== null || !embedding.every(Number.isFinite)) return false;
186503
+ if (!embedding.every(Number.isFinite)) return false;
186234
186504
  const targetProjectDir = projectDir;
186235
186505
  if (!vectorSchemaUpgradePromise) {
186236
- vectorSchemaUpgradePromise = reindexObservations().then(() => projectDir === targetProjectDir && isVectorCompatibleWithCurrentIndex(embedding)).catch(() => false).finally(() => {
186506
+ vectorSchemaUpgradePromise = getDb().then(async () => {
186507
+ if (getVectorDimensions() === null && observations.length > 0) await reindexObservations();
186508
+ return projectDir === targetProjectDir && isVectorCompatibleWithCurrentIndex(embedding);
186509
+ }).catch(() => false).finally(() => {
186237
186510
  vectorSchemaUpgradePromise = null;
186238
186511
  });
186239
186512
  }
@@ -186273,9 +186546,9 @@ async function initObservations(dir, options = {}) {
186273
186546
  }
186274
186547
  function scheduleObservationEmbedding(input) {
186275
186548
  const { observationId: observationId2, projectId, searchableText, doc } = input;
186276
- vectorMissingIds.add(observationId2);
186549
+ markVectorMissing(observationId2, projectId);
186277
186550
  if (isEmbeddingExplicitlyDisabled()) {
186278
- vectorMissingIds.delete(observationId2);
186551
+ clearVectorMissing(observationId2);
186279
186552
  return;
186280
186553
  }
186281
186554
  if (embeddingWriteMode === "deferred") {
@@ -186310,13 +186583,13 @@ function scheduleObservationEmbedding(input) {
186310
186583
  vector: embedding
186311
186584
  });
186312
186585
  }
186313
- vectorMissingIds.delete(observationId2);
186586
+ clearVectorMissing(observationId2);
186314
186587
  } catch {
186315
186588
  console.error(`[memorix] Embedding index update failed for obs-${observationId2} (kept in backfill queue)`);
186316
186589
  queueVectorBackfill(projectId);
186317
186590
  }
186318
186591
  } else if (isEmbeddingExplicitlyDisabled()) {
186319
- vectorMissingIds.delete(observationId2);
186592
+ clearVectorMissing(observationId2);
186320
186593
  } else {
186321
186594
  queueVectorBackfill(projectId);
186322
186595
  logEmbeddingFailureOnce(
@@ -186876,7 +187149,7 @@ async function reindexObservations() {
186876
187149
  if (observations.length === 0) return 0;
186877
187150
  await resetDb();
186878
187151
  searchIndexPrepared = false;
186879
- vectorMissingIds.clear();
187152
+ clearVectorMissingIds();
186880
187153
  let embeddings = observations.map(() => null);
186881
187154
  const provider2 = await getEmbeddingProvider();
186882
187155
  const canBatchEmbedAtStartup = provider2 !== null && !provider2.name.startsWith("api-");
@@ -186941,7 +187214,7 @@ async function reindexObservations() {
186941
187214
  };
186942
187215
  await insertObservation(doc);
186943
187216
  if (!compatibleEmbedding && !isEmbeddingExplicitlyDisabled()) {
186944
- vectorMissingIds.add(obs.id);
187217
+ markVectorMissing(obs.id, obs.projectId);
186945
187218
  }
186946
187219
  count3++;
186947
187220
  } catch (err) {
@@ -186958,7 +187231,17 @@ async function prepareSearchIndex(options = {}) {
186958
187231
  if (!isEmbeddingExplicitlyDisabled()) {
186959
187232
  const store2 = getObservationStore();
186960
187233
  const projects = await store2.listProjectIds?.() ?? [];
186961
- for (const projectId of projects) queueVectorBackfill(projectId);
187234
+ await getDb({ allowNetworkProbe: false }).catch(() => void 0);
187235
+ const persistedIds = projectDir ? await getPersistentSemanticVectorIds(projectDir).catch(() => null) : null;
187236
+ for (const projectId of projects) {
187237
+ const projectObservations = await store2.loadByProject(projectId);
187238
+ for (const observation of projectObservations) {
187239
+ if (!persistedIds?.has(observation.id)) markVectorMissing(observation.id, observation.projectId);
187240
+ }
187241
+ if (projectObservations.some((observation) => !persistedIds?.has(observation.id))) {
187242
+ queueVectorBackfill(projectId);
187243
+ }
187244
+ }
186962
187245
  }
186963
187246
  return 0;
186964
187247
  }
@@ -186970,14 +187253,15 @@ async function prepareSearchIndex(options = {}) {
186970
187253
  return 0;
186971
187254
  }
186972
187255
  const hydratedProjectDir = projectDir;
186973
- const queueMissingVectors = () => {
186974
- if (projectDir !== hydratedProjectDir) return;
186975
- vectorMissingIds.clear();
187256
+ const queueMissingVectors = async () => {
187257
+ if (!hydratedProjectDir || projectDir !== hydratedProjectDir) return;
187258
+ clearVectorMissingIds();
186976
187259
  if (!isEmbeddingExplicitlyDisabled()) {
187260
+ const persistedSemanticIds = await getPersistentSemanticVectorIds(hydratedProjectDir).catch(() => null);
186977
187261
  const projectsWithMissingVectors = /* @__PURE__ */ new Set();
186978
187262
  for (const obs of observations) {
186979
- if (!hasObservationVector(obs.projectId, obs.id)) {
186980
- vectorMissingIds.add(obs.id);
187263
+ if (!hasObservationVector(obs.projectId, obs.id) && !persistedSemanticIds?.has(obs.id)) {
187264
+ markVectorMissing(obs.id, obs.projectId);
186981
187265
  projectsWithMissingVectors.add(obs.projectId);
186982
187266
  }
186983
187267
  }
@@ -186986,15 +187270,18 @@ async function prepareSearchIndex(options = {}) {
186986
187270
  };
186987
187271
  const cacheHydration = getDeferredCachedVectorHydration();
186988
187272
  if (cacheHydration) {
186989
- void cacheHydration.finally(queueMissingVectors);
187273
+ void cacheHydration.then(queueMissingVectors, queueMissingVectors).catch(() => void 0);
186990
187274
  } else {
186991
- queueMissingVectors();
187275
+ await queueMissingVectors();
186992
187276
  }
186993
187277
  searchIndexPrepared = true;
186994
187278
  return count3;
186995
187279
  }
186996
187280
  function getVectorMissingIds(projectId) {
186997
187281
  if (!projectId) return [...vectorMissingIds];
187282
+ if (!corpusLoaded) {
187283
+ return [...vectorMissingIds].filter((id) => vectorMissingProjectIds.get(id) === projectId);
187284
+ }
186998
187285
  const observationById = new Map(observations.map((observation) => [observation.id, observation]));
186999
187286
  return [...vectorMissingIds].filter((id) => observationById.get(id)?.projectId === projectId);
187000
187287
  }
@@ -187032,7 +187319,8 @@ async function backfillVectorEmbeddings(options = {}) {
187032
187319
  return { attempted: 0, succeeded: 0, failed: 0 };
187033
187320
  }
187034
187321
  vectorBackfillRunning = true;
187035
- const observationById = new Map(observations.map((observation) => [observation.id, observation]));
187322
+ const sourceObservations = corpusLoaded ? observations : options.projectId ? await getObservationStore().loadByProject(options.projectId, { status: "active" }) : await getObservationStore().loadAll();
187323
+ const observationById = new Map(sourceObservations.map((observation) => [observation.id, observation]));
187036
187324
  const limit2 = Number.isFinite(options.limit) ? Math.max(1, Math.floor(options.limit)) : Number.POSITIVE_INFINITY;
187037
187325
  const ids = [...vectorMissingIds].filter((id) => !options.projectId || observationById.get(id)?.projectId === options.projectId).slice(0, limit2);
187038
187326
  let succeeded = 0;
@@ -187045,7 +187333,7 @@ async function backfillVectorEmbeddings(options = {}) {
187045
187333
  for (const id of ids) {
187046
187334
  const observation = observationById.get(id);
187047
187335
  if (!observation) {
187048
- vectorMissingIds.delete(id);
187336
+ clearVectorMissing(id);
187049
187337
  continue;
187050
187338
  }
187051
187339
  candidates.push({
@@ -187063,7 +187351,7 @@ async function backfillVectorEmbeddings(options = {}) {
187063
187351
  const provider2 = await getEmbeddingProvider();
187064
187352
  if (!provider2) {
187065
187353
  if (isEmbeddingExplicitlyDisabled()) {
187066
- for (const candidate2 of candidates) vectorMissingIds.delete(candidate2.id);
187354
+ for (const candidate2 of candidates) clearVectorMissing(candidate2.id);
187067
187355
  } else {
187068
187356
  recordFailure("embedding provider unavailable");
187069
187357
  failed += candidates.length;
@@ -187140,7 +187428,7 @@ async function backfillVectorEmbeddings(options = {}) {
187140
187428
  vector: embedding
187141
187429
  });
187142
187430
  }
187143
- vectorMissingIds.delete(id);
187431
+ clearVectorMissing(id);
187144
187432
  succeeded++;
187145
187433
  } catch (error40) {
187146
187434
  recordFailure(vectorBackfillError(error40));
@@ -187165,7 +187453,7 @@ async function backfillVectorEmbeddings(options = {}) {
187165
187453
  ...lastFailure ? { lastError: lastFailure } : {}
187166
187454
  };
187167
187455
  }
187168
- 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;
187456
+ 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;
187169
187457
  var init_observations = __esm({
187170
187458
  "src/memory/observations.ts"() {
187171
187459
  "use strict";
@@ -187190,6 +187478,7 @@ var init_observations = __esm({
187190
187478
  loadedObservationStore = null;
187191
187479
  DEFAULT_ORAMA_HYDRATION_THRESHOLD = 1e4;
187192
187480
  vectorMissingIds = /* @__PURE__ */ new Set();
187481
+ vectorMissingProjectIds = /* @__PURE__ */ new Map();
187193
187482
  vectorBackfillRunning = false;
187194
187483
  vectorSchemaUpgradePromise = null;
187195
187484
  lastVectorBackfill = null;
@@ -187807,6 +188096,7 @@ __export(orama_store_exports, {
187807
188096
  getLastSearchMode: () => getLastSearchMode,
187808
188097
  getObservationCount: () => getObservationCount2,
187809
188098
  getObservationsByIds: () => getObservationsByIds,
188099
+ getPersistentSemanticVectorIds: () => getPersistentSemanticVectorIds,
187810
188100
  getSearchDerivedViews: () => getSearchDerivedViews,
187811
188101
  getTimeline: () => getTimeline,
187812
188102
  getVectorDimensions: () => getVectorDimensions,
@@ -187819,9 +188109,17 @@ __export(orama_store_exports, {
187819
188109
  queueSemanticVector: () => queueSemanticVector,
187820
188110
  removeObservation: () => removeObservation,
187821
188111
  resetDb: () => resetDb,
188112
+ resolveSearchFuzzyTolerance: () => resolveSearchFuzzyTolerance,
187822
188113
  searchObservations: () => searchObservations,
187823
188114
  updateObservationMetadata: () => updateObservationMetadata
187824
188115
  });
188116
+ function resolveSearchFuzzyTolerance(query, quality) {
188117
+ if (quality === "fast") return void 0;
188118
+ const characters = [...query];
188119
+ const cjkCount = characters.filter((char) => /[\u3400-\u4dbf\u4e00-\u9fff\u3040-\u30ff\uac00-\ud7af]/u.test(char)).length;
188120
+ if (characters.length > 0 && cjkCount / characters.length > 0.3) return void 0;
188121
+ return query.length > 6 ? 2 : 1;
188122
+ }
187825
188123
  function rememberSearchMode(key, value) {
187826
188124
  if (!lastSearchModeByProject.has(key) && lastSearchModeByProject.size >= MAX_SEARCH_MODE_KEYS) {
187827
188125
  const oldest = lastSearchModeByProject.keys().next().value;
@@ -187850,14 +188148,16 @@ function getSearchDerivedViews() {
187850
188148
  generation,
187851
188149
  freshness: "unknown",
187852
188150
  rebuildStatus: "unavailable",
187853
- failureReason: store2.getBackendReason?.() ?? "persistent lexical index unavailable"
188151
+ failureReason: sanitizeDerivedViewFailureReason(
188152
+ store2.getBackendReason?.() ?? "persistent lexical index unavailable"
188153
+ )
187854
188154
  };
187855
188155
  }
187856
188156
  } catch (error40) {
187857
188157
  views.fts = {
187858
188158
  freshness: "unknown",
187859
188159
  rebuildStatus: "failed",
187860
- failureReason: error40 instanceof Error ? error40.message.slice(0, 240) : String(error40).slice(0, 240)
188160
+ failureReason: sanitizeDerivedViewFailureReason(error40 instanceof Error ? error40.message : String(error40))
187861
188161
  };
187862
188162
  }
187863
188163
  } else {
@@ -187873,18 +188173,12 @@ function getSearchDerivedViews() {
187873
188173
  rebuildStatus: "unavailable",
187874
188174
  failureReason: "Orama index is not initialized"
187875
188175
  };
187876
- const configuredEmbeddingMode = process.env.MEMORIX_EMBEDDING?.trim().toLowerCase();
187877
- if (configuredEmbeddingMode === "off") {
187878
- views.embedding = { freshness: "current", rebuildStatus: "disabled" };
187879
- } else if (embeddingEnabled) {
187880
- views.embedding = { freshness: "current", rebuildStatus: "idle" };
187881
- } else {
187882
- views.embedding = {
187883
- freshness: "unknown",
187884
- rebuildStatus: "unavailable",
187885
- failureReason: "embedding provider is not initialized"
187886
- };
188176
+ let embeddingHealth;
188177
+ try {
188178
+ embeddingHealth = getEmbeddingRuntimeHealth?.();
188179
+ } catch {
187887
188180
  }
188181
+ views.embedding = embeddingHealthReceipt(embeddingHealth, embeddingEnabled);
187888
188182
  return views;
187889
188183
  }
187890
188184
  function rememberSearchDiagnostics(key, value) {
@@ -188188,12 +188482,16 @@ function getVectorDimensions() {
188188
188482
  function getActiveSemanticIndexProfile() {
188189
188483
  return indexEmbeddingProvider ? createSemanticIndexProfile(indexEmbeddingProvider) : null;
188190
188484
  }
188485
+ async function getPersistentSemanticVectorIds(dataDir) {
188486
+ if (!indexEmbeddingProvider) return null;
188487
+ return listSemanticVectorIds(dataDir, createSemanticIndexProfile(indexEmbeddingProvider));
188488
+ }
188191
188489
  async function queueSemanticVector(dataDir, record2) {
188192
188490
  const provider2 = indexEmbeddingProvider ?? await getEmbeddingProvider();
188193
188491
  const profile = provider2 ? createSemanticIndexProfile(provider2) : null;
188194
188492
  if (!profile) return;
188195
188493
  try {
188196
- await upsertSemanticVectors(dataDir, profile, [record2]);
188494
+ await upsertSemanticVector(dataDir, profile, record2);
188197
188495
  } catch {
188198
188496
  }
188199
188497
  }
@@ -188255,6 +188553,7 @@ function isCompatibleCachedVector(vector) {
188255
188553
  async function attachCachedVectors(database, observations2) {
188256
188554
  const semanticDataDir = (await Promise.resolve().then(() => (init_observations(), observations_exports))).getObservationDataDir();
188257
188555
  const semanticProfile = getActiveSemanticIndexProfile();
188556
+ const persistedSemanticIds = semanticDataDir && semanticProfile ? await listSemanticVectorIds(semanticDataDir, semanticProfile).catch(() => null) : null;
188258
188557
  const batchSize = 200;
188259
188558
  for (let start = 0; start < observations2.length; start += batchSize) {
188260
188559
  const batch = observations2.slice(start, start + batchSize);
@@ -188265,7 +188564,7 @@ async function attachCachedVectors(database, observations2) {
188265
188564
  const vector = cachedVectors[index];
188266
188565
  if (!isCompatibleCachedVector(vector)) continue;
188267
188566
  const observation = batch[index];
188268
- if (semanticDataDir && semanticProfile) {
188567
+ if (semanticDataDir && semanticProfile && !persistedSemanticIds?.has(observation.id)) {
188269
188568
  semanticRecords.push({
188270
188569
  observationId: observation.id,
188271
188570
  projectId: observation.projectId,
@@ -188466,7 +188765,10 @@ async function searchObservations(options) {
188466
188765
  // Fuzzy tolerance: allow 1-char typos for short queries, 2 for longer
188467
188766
  // Fuzzy matching is useful for ordinary recall, but grows sharply with
188468
188767
  // corpus size. The fast profile deliberately uses exact lexical matching.
188469
- ...hasQuery && quality !== "fast" ? { tolerance: originalQuery.length > 6 ? 2 : 1 } : {}
188768
+ ...hasQuery ? (() => {
188769
+ const tolerance = resolveSearchFuzzyTolerance(originalQuery, quality);
188770
+ return tolerance === void 0 ? {} : { tolerance };
188771
+ })() : {}
188470
188772
  };
188471
188773
  let queryVector = null;
188472
188774
  let embeddingProviderForSearch = null;
@@ -188697,14 +188999,16 @@ async function searchObservations(options) {
188697
188999
  filesModified: doc.filesModified?.split?.("\n") ?? (Array.isArray(doc.filesModified) ? doc.filesModified : [])
188698
189000
  });
188699
189001
  }
189002
+ const topScore = Math.max(...intermediate.map((entry) => entry.score));
189003
+ const affinityTieWindow = topScore * 0.92;
188700
189004
  intermediate = intermediate.map((entry) => {
188701
189005
  const memory = memoryContentMap.get(entry.id);
188702
189006
  if (!memory) return entry;
188703
189007
  const { score: affinityScore } = calculateProjectAffinity(memory, affinityContext);
189008
+ if (entry.score < affinityTieWindow) return entry;
188704
189009
  return {
188705
189010
  ...entry,
188706
- score: entry.score * affinityScore
188707
- // Apply affinity as multiplier
189011
+ score: entry.score * (0.98 + affinityScore * 0.02)
188708
189012
  };
188709
189013
  });
188710
189014
  intermediate.sort((a4, b4) => b4.score - a4.score);
@@ -189039,6 +189343,7 @@ var init_orama_store = __esm({
189039
189343
  init_mini_skills();
189040
189344
  init_visibility();
189041
189345
  init_provider();
189346
+ init_provider();
189042
189347
  init_project_affinity();
189043
189348
  init_intent_detector();
189044
189349
  init_query_expansion();
@@ -189046,6 +189351,7 @@ var init_orama_store = __esm({
189046
189351
  init_timeout();
189047
189352
  init_obs_store();
189048
189353
  init_semantic_index();
189354
+ init_derived_view_receipt();
189049
189355
  db = null;
189050
189356
  dbInitPromise = null;
189051
189357
  dbGeneration = 0;
@@ -193352,7 +193658,7 @@ __export(init_exports, {
193352
193658
  buildInitTomlConfig: () => buildInitTomlConfig,
193353
193659
  default: () => init_default5
193354
193660
  });
193355
- import { existsSync as existsSync16, mkdirSync as mkdirSync3, writeFileSync as writeFileSync3 } from "fs";
193661
+ import { existsSync as existsSync17, mkdirSync as mkdirSync3, writeFileSync as writeFileSync3 } from "fs";
193356
193662
  import { homedir as homedir8 } from "os";
193357
193663
  import path29 from "path";
193358
193664
  function buildInitTomlConfig(options) {
@@ -193392,6 +193698,8 @@ function buildInitTomlConfig(options) {
193392
193698
  lines.push('model = "deepseek-v4.1-flash"');
193393
193699
  } else if (options.llmProvider === "cheaperinference") {
193394
193700
  lines.push('model = "gpt-5.4-mini"');
193701
+ } else if (options.llmProvider === "runcrate") {
193702
+ lines.push('model = "deepseek-ai/DeepSeek-V4.1-Flash"');
193395
193703
  } else if (options.llmProvider === "atlascloud") {
193396
193704
  lines.push('model = "deepseek-ai/deepseek-v3.2"');
193397
193705
  }
@@ -193509,7 +193817,7 @@ var init_init = __esm({
193509
193817
  const targetPath = path29.join(targetDir, isGlobal ? getInitConfigFilename() : getInitProjectConfigFilename());
193510
193818
  const envPath = path29.join(targetDir, ".env");
193511
193819
  v3.info(getInitScopeDescription(scope));
193512
- if (existsSync16(targetPath)) {
193820
+ if (existsSync17(targetPath)) {
193513
193821
  const overwrite = await me({
193514
193822
  message: `${targetPath} already exists. Overwrite it?`,
193515
193823
  initialValue: false
@@ -193529,6 +193837,7 @@ var init_init = __esm({
193529
193837
  { value: "requesty", label: "Requesty", hint: "multi-provider" },
193530
193838
  { value: "apiroute", label: "API Route", hint: "multi-provider" },
193531
193839
  { value: "cheaperinference", label: "Cheaper Inference", hint: "multi-provider" },
193840
+ { value: "runcrate", label: "Runcrate", hint: "open-weight models" },
193532
193841
  { value: "atlascloud", label: "Atlas Cloud", hint: "DeepSeek V3.2" },
193533
193842
  { value: "custom", label: "Custom", hint: "OpenAI-compatible endpoint" }
193534
193843
  ]
@@ -193583,7 +193892,7 @@ var init_init = __esm({
193583
193892
  ];
193584
193893
  if (llmProvider !== "none") {
193585
193894
  envLines.push("# LLM API key");
193586
- if (llmProvider === "openai" || llmProvider === "custom" || llmProvider === "atlascloud" || llmProvider === "apiroute" || llmProvider === "cheaperinference") {
193895
+ if (llmProvider === "openai" || llmProvider === "custom" || llmProvider === "atlascloud" || llmProvider === "apiroute" || llmProvider === "cheaperinference" || llmProvider === "runcrate") {
193587
193896
  envLines.push("MEMORIX_LLM_API_KEY=sk-your-key-here");
193588
193897
  } else if (llmProvider === "anthropic") {
193589
193898
  envLines.push("MEMORIX_LLM_API_KEY=sk-ant-your-key-here");
@@ -193620,16 +193929,17 @@ var init_init = __esm({
193620
193929
  envLines.push("# REQUESTY_API_KEY=rqsty-...");
193621
193930
  envLines.push("# API_ROUTE_API_KEY=sk-...");
193622
193931
  envLines.push("# CHEAPER_INFERENCE_API_KEY=ci_live_...");
193932
+ envLines.push("# RUNCRATE_API_KEY=...");
193623
193933
  envLines.push("");
193624
193934
  mkdirSync3(targetDir, { recursive: true });
193625
193935
  writeFileSync3(targetPath, tomlContent, "utf-8");
193626
193936
  v3.success(`Created ${targetPath}`);
193627
193937
  if (shouldOfferDotenv(scope)) {
193628
193938
  const envExamplePath = getEnvTemplateTarget(targetDir, {
193629
- hasDotenvExample: existsSync16(path29.join(targetDir, ".env.example"))
193939
+ hasDotenvExample: existsSync17(path29.join(targetDir, ".env.example"))
193630
193940
  });
193631
193941
  const envContent = envLines.join("\n");
193632
- if (existsSync16(envExamplePath)) {
193942
+ if (existsSync17(envExamplePath)) {
193633
193943
  const overwriteEnvTemplate = await me({
193634
193944
  message: `${envExamplePath} already exists. Overwrite it?`,
193635
193945
  initialValue: false
@@ -193641,7 +193951,7 @@ var init_init = __esm({
193641
193951
  }
193642
193952
  writeFileSync3(envExamplePath, envContent, "utf-8");
193643
193953
  v3.success(`Created ${envExamplePath}`);
193644
- const createEnv = !existsSync16(envPath) ? await me({
193954
+ const createEnv = !existsSync17(envPath) ? await me({
193645
193955
  message: `Create .env from ${path29.basename(envExamplePath)} now? (you can fill in keys later)`,
193646
193956
  initialValue: true
193647
193957
  }) : false;
@@ -194445,9 +194755,60 @@ var init_omp = __esm({
194445
194755
  }
194446
194756
  });
194447
194757
 
194448
- // src/workspace/mcp-adapters/kiro.ts
194758
+ // src/workspace/mcp-adapters/pi.ts
194449
194759
  import { homedir as homedir19 } from "os";
194450
194760
  import { join as join16 } from "path";
194761
+ var PiMCPAdapter;
194762
+ var init_pi = __esm({
194763
+ "src/workspace/mcp-adapters/pi.ts"() {
194764
+ "use strict";
194765
+ init_esm_shims();
194766
+ PiMCPAdapter = class {
194767
+ source = "pi";
194768
+ parse(content) {
194769
+ try {
194770
+ const config2 = JSON.parse(content);
194771
+ const servers = config2.mcpServers;
194772
+ if (!servers || typeof servers !== "object" || Array.isArray(servers)) return [];
194773
+ return Object.entries(servers).flatMap(([name, entry]) => {
194774
+ if (!entry || typeof entry !== "object" || Array.isArray(entry)) return [];
194775
+ return [{
194776
+ name,
194777
+ command: entry.command ?? "",
194778
+ args: Array.isArray(entry.args) ? entry.args : [],
194779
+ ...entry.env && Object.keys(entry.env).length > 0 ? { env: entry.env } : {},
194780
+ ...entry.url ? { url: entry.url } : {},
194781
+ ...entry.headers && Object.keys(entry.headers).length > 0 ? { headers: entry.headers } : {},
194782
+ ...entry.enabled === false ? { disabled: true } : {}
194783
+ }];
194784
+ });
194785
+ } catch {
194786
+ return [];
194787
+ }
194788
+ }
194789
+ generate(servers) {
194790
+ const mcpServers = {};
194791
+ for (const server of servers) {
194792
+ const entry = server.url ? { url: server.url } : { command: server.command, args: server.args };
194793
+ if (server.url && server.headers && Object.keys(server.headers).length > 0) {
194794
+ entry.headers = server.headers;
194795
+ }
194796
+ if (server.env && Object.keys(server.env).length > 0) entry.env = server.env;
194797
+ if (server.disabled === true) entry.enabled = false;
194798
+ mcpServers[server.name] = entry;
194799
+ }
194800
+ return JSON.stringify({ mcpServers }, null, 2) + "\n";
194801
+ }
194802
+ getConfigPath(projectRoot) {
194803
+ return projectRoot ? join16(projectRoot, ".pi", "mcp.json") : join16(homedir19(), ".pi", "agent", "mcp.json");
194804
+ }
194805
+ };
194806
+ }
194807
+ });
194808
+
194809
+ // src/workspace/mcp-adapters/kiro.ts
194810
+ import { homedir as homedir20 } from "os";
194811
+ import { join as join17 } from "path";
194451
194812
  var KiroMCPAdapter;
194452
194813
  var init_kiro = __esm({
194453
194814
  "src/workspace/mcp-adapters/kiro.ts"() {
@@ -194492,17 +194853,17 @@ var init_kiro = __esm({
194492
194853
  }
194493
194854
  getConfigPath(projectRoot) {
194494
194855
  if (projectRoot) {
194495
- return join16(projectRoot, ".kiro", "settings", "mcp.json");
194856
+ return join17(projectRoot, ".kiro", "settings", "mcp.json");
194496
194857
  }
194497
- return join16(homedir19(), ".kiro", "settings", "mcp.json");
194858
+ return join17(homedir20(), ".kiro", "settings", "mcp.json");
194498
194859
  }
194499
194860
  };
194500
194861
  }
194501
194862
  });
194502
194863
 
194503
194864
  // src/workspace/mcp-adapters/opencode.ts
194504
- import { homedir as homedir20 } from "os";
194505
- import { join as join17 } from "path";
194865
+ import { homedir as homedir21 } from "os";
194866
+ import { join as join18 } from "path";
194506
194867
  var OpenCodeMCPAdapter;
194507
194868
  var init_opencode = __esm({
194508
194869
  "src/workspace/mcp-adapters/opencode.ts"() {
@@ -194572,17 +194933,17 @@ var init_opencode = __esm({
194572
194933
  }
194573
194934
  getConfigPath(projectRoot) {
194574
194935
  if (projectRoot) {
194575
- return join17(projectRoot, "opencode.json");
194936
+ return join18(projectRoot, "opencode.json");
194576
194937
  }
194577
- return join17(homedir20(), ".config", "opencode", "opencode.json");
194938
+ return join18(homedir21(), ".config", "opencode", "opencode.json");
194578
194939
  }
194579
194940
  };
194580
194941
  }
194581
194942
  });
194582
194943
 
194583
194944
  // src/workspace/mcp-adapters/trae.ts
194584
- import { join as join18 } from "path";
194585
- import { homedir as homedir21 } from "os";
194945
+ import { join as join19 } from "path";
194946
+ import { homedir as homedir22 } from "os";
194586
194947
  var TraeMCPAdapter;
194587
194948
  var init_trae = __esm({
194588
194949
  "src/workspace/mcp-adapters/trae.ts"() {
@@ -194651,26 +195012,26 @@ var init_trae = __esm({
194651
195012
  return JSON.stringify({ mcpServers }, null, 2);
194652
195013
  }
194653
195014
  getConfigPath(_projectRoot) {
194654
- const home = homedir21();
195015
+ const home = homedir22();
194655
195016
  if (process.platform === "win32") {
194656
- return join18(process.env.APPDATA || join18(home, "AppData", "Roaming"), "Trae", "User", "mcp.json");
195017
+ return join19(process.env.APPDATA || join19(home, "AppData", "Roaming"), "Trae", "User", "mcp.json");
194657
195018
  }
194658
195019
  if (process.platform === "darwin") {
194659
- return join18(home, "Library", "Application Support", "Trae", "User", "mcp.json");
195020
+ return join19(home, "Library", "Application Support", "Trae", "User", "mcp.json");
194660
195021
  }
194661
- return join18(home, ".config", "Trae", "User", "mcp.json");
195022
+ return join19(home, ".config", "Trae", "User", "mcp.json");
194662
195023
  }
194663
195024
  };
194664
195025
  }
194665
195026
  });
194666
195027
 
194667
195028
  // src/workspace/mcp-adapters/dsh.ts
194668
- import { homedir as homedir22 } from "os";
194669
- import { join as join19 } from "path";
195029
+ import { homedir as homedir23 } from "os";
195030
+ import { join as join20 } from "path";
194670
195031
  function resolveDshHome() {
194671
195032
  const configured = process.env.DSH_HOME?.trim();
194672
195033
  if (configured) return configured;
194673
- return join19(homedir22(), ".dsh");
195034
+ return join20(homedir23(), ".dsh");
194674
195035
  }
194675
195036
  function isMemorixRow(row) {
194676
195037
  if (!row || typeof row !== "object" || Array.isArray(row)) return false;
@@ -194765,15 +195126,15 @@ var init_dsh = __esm({
194765
195126
  return (0, import_yaml4.stringify)([{ insert: rows }], { lineWidth: 0 }) + "\n";
194766
195127
  }
194767
195128
  getConfigPath(_projectRoot) {
194768
- return join19(resolveDshHome(), "cordis.patch.yml");
195129
+ return join20(resolveDshHome(), "cordis.patch.yml");
194769
195130
  }
194770
195131
  };
194771
195132
  }
194772
195133
  });
194773
195134
 
194774
195135
  // src/workspace/mcp-adapters/workbuddy.ts
194775
- import { homedir as homedir23 } from "os";
194776
- import { join as join20 } from "path";
195136
+ import { homedir as homedir24 } from "os";
195137
+ import { join as join21 } from "path";
194777
195138
  var WorkbuddyMCPAdapter;
194778
195139
  var init_workbuddy = __esm({
194779
195140
  "src/workspace/mcp-adapters/workbuddy.ts"() {
@@ -194823,17 +195184,17 @@ var init_workbuddy = __esm({
194823
195184
  }
194824
195185
  getConfigPath(projectRoot) {
194825
195186
  if (projectRoot) {
194826
- return join20(projectRoot, ".workbuddy", "mcp.json");
195187
+ return join21(projectRoot, ".workbuddy", "mcp.json");
194827
195188
  }
194828
- return join20(homedir23(), ".workbuddy", "mcp.json");
195189
+ return join21(homedir24(), ".workbuddy", "mcp.json");
194829
195190
  }
194830
195191
  };
194831
195192
  }
194832
195193
  });
194833
195194
 
194834
195195
  // src/workspace/mcp-adapters/codebuddy.ts
194835
- import { homedir as homedir24 } from "os";
194836
- import { join as join21 } from "path";
195196
+ import { homedir as homedir25 } from "os";
195197
+ import { join as join22 } from "path";
194837
195198
  var CodeBuddyMCPAdapter;
194838
195199
  var init_codebuddy = __esm({
194839
195200
  "src/workspace/mcp-adapters/codebuddy.ts"() {
@@ -194865,15 +195226,15 @@ var init_codebuddy = __esm({
194865
195226
  return JSON.stringify({ mcpServers }, null, 2);
194866
195227
  }
194867
195228
  getConfigPath(projectRoot) {
194868
- return projectRoot ? join21(projectRoot, ".mcp.json") : join21(homedir24(), ".codebuddy", ".mcp.json");
195229
+ return projectRoot ? join22(projectRoot, ".mcp.json") : join22(homedir25(), ".codebuddy", ".mcp.json");
194869
195230
  }
194870
195231
  };
194871
195232
  }
194872
195233
  });
194873
195234
 
194874
195235
  // src/workspace/mcp-adapters/grok.ts
194875
- import { homedir as homedir25 } from "os";
194876
- import { join as join22 } from "path";
195236
+ import { homedir as homedir26 } from "os";
195237
+ import { join as join23 } from "path";
194877
195238
  var GrokMCPAdapter;
194878
195239
  var init_grok = __esm({
194879
195240
  "src/workspace/mcp-adapters/grok.ts"() {
@@ -194890,8 +195251,8 @@ var init_grok = __esm({
194890
195251
  return this.toml.generate(servers);
194891
195252
  }
194892
195253
  getConfigPath(_projectRoot) {
194893
- const grokHome = process.env.GROK_HOME?.trim() || join22(homedir25(), ".grok");
194894
- return join22(grokHome, "config.toml");
195254
+ const grokHome = process.env.GROK_HOME?.trim() || join23(homedir26(), ".grok");
195255
+ return join23(grokHome, "config.toml");
194895
195256
  }
194896
195257
  };
194897
195258
  }
@@ -195150,7 +195511,8 @@ var init_registry2 = __esm({
195150
195511
  entry: "official-package",
195151
195512
  status: "ready",
195152
195513
  install: "memorix setup --agent pi",
195153
- surfaces: ["Pi package", "extension API", "skills", "hooks"]
195514
+ surfaces: ["MCP", "Pi package", "extension API", "skills", "hooks"],
195515
+ note: "Requires Pi 1.0+. Uses native .pi/mcp.json or ~/.pi/agent/mcp.json alongside the extension/skills package."
195154
195516
  },
195155
195517
  {
195156
195518
  agent: "any-mcp",
@@ -195450,9 +195812,9 @@ __export(audit_exports, {
195450
195812
  });
195451
195813
  import * as fs18 from "fs/promises";
195452
195814
  import * as path30 from "path";
195453
- import { homedir as homedir26 } from "os";
195815
+ import { homedir as homedir27 } from "os";
195454
195816
  function getAuditFilePath() {
195455
- return process.env.MEMORIX_AUDIT_FILE || path30.join(homedir26(), ".memorix", "audit.json");
195817
+ return process.env.MEMORIX_AUDIT_FILE || path30.join(homedir27(), ".memorix", "audit.json");
195456
195818
  }
195457
195819
  async function loadAudit() {
195458
195820
  try {
@@ -197247,9 +197609,9 @@ __export(setup_exports, {
197247
197609
  tryInstallCodexPlugin: () => tryInstallCodexPlugin
197248
197610
  });
197249
197611
  import { spawnSync } from "child_process";
197250
- import { existsSync as existsSync17 } from "fs";
197612
+ import { existsSync as existsSync18 } from "fs";
197251
197613
  import { copyFile as copyFile2, mkdir as mkdir6, readFile as readFile6, readdir as readdir3, rm as rm2, writeFile as writeFile7 } from "fs/promises";
197252
- import { homedir as homedir28 } from "os";
197614
+ import { homedir as homedir29 } from "os";
197253
197615
  import path32 from "path";
197254
197616
  import { fileURLToPath as fileURLToPath7 } from "url";
197255
197617
  function getSetupAgentTargets2() {
@@ -197292,7 +197654,7 @@ function buildSetupPlan(options) {
197292
197654
  function findPackageRoot(start = path32.dirname(fileURLToPath7(import.meta.url))) {
197293
197655
  let dir = start;
197294
197656
  for (let i4 = 0; i4 < 8; i4++) {
197295
- if (existsSync17(path32.join(dir, "package.json")) && existsSync17(path32.join(dir, "plugins"))) {
197657
+ if (existsSync18(path32.join(dir, "package.json")) && existsSync18(path32.join(dir, "plugins"))) {
197296
197658
  return dir;
197297
197659
  }
197298
197660
  const parent = path32.dirname(dir);
@@ -197408,6 +197770,7 @@ function getMcpAdapter(agent) {
197408
197770
  openclaw: new OpenClawMCPAdapter(),
197409
197771
  hermes: new HermesMCPAdapter(),
197410
197772
  omp: new OmpMCPAdapter(),
197773
+ pi: new PiMCPAdapter(),
197411
197774
  kiro: new KiroMCPAdapter(),
197412
197775
  opencode: new OpenCodeMCPAdapter(),
197413
197776
  trae: new TraeMCPAdapter(),
@@ -197444,7 +197807,7 @@ async function rewriteBundledMemorixMcpToHttp(root) {
197444
197807
  const candidates = [".mcp.json", "mcp_config.json", "gemini-extension.json"].map((name) => path32.join(root, name));
197445
197808
  const rewritten = [];
197446
197809
  for (const filePath of candidates) {
197447
- if (!existsSync17(filePath)) continue;
197810
+ if (!existsSync18(filePath)) continue;
197448
197811
  let doc;
197449
197812
  try {
197450
197813
  doc = JSON.parse(await readFile6(filePath, "utf-8"));
@@ -197565,7 +197928,7 @@ function isOwnedLegacyCodexMcp(content) {
197565
197928
  const server = new CodexMCPAdapter().parse(content).find((entry) => entry.name === "memorix");
197566
197929
  return Boolean(server && isLegacyCodexMemorixNodeServer(server));
197567
197930
  }
197568
- async function removeLegacyCodexMemorixMcpConfig(configPath = path32.join(homedir28(), ".codex", "config.toml")) {
197931
+ async function removeLegacyCodexMemorixMcpConfig(configPath = path32.join(homedir29(), ".codex", "config.toml")) {
197569
197932
  let existingContent;
197570
197933
  try {
197571
197934
  existingContent = await readFile6(configPath, "utf-8");
@@ -197609,8 +197972,8 @@ function isOwnedLegacyCodexHooks(content) {
197609
197972
  async function removeOwnedLegacyCodexPluginFolder(homeDir) {
197610
197973
  const canonicalPath2 = path32.join(homeDir, "plugins", "memorix");
197611
197974
  const legacyPath = path32.join(homeDir, ".codex", "plugins", "memorix");
197612
- if (!existsSync17(legacyPath)) return "missing";
197613
- if (!existsSync17(canonicalPath2)) return "preserved";
197975
+ if (!existsSync18(legacyPath)) return "missing";
197976
+ if (!existsSync18(canonicalPath2)) return "preserved";
197614
197977
  try {
197615
197978
  const manifest = JSON.parse(await readFile6(path32.join(legacyPath, ".codex-plugin", "plugin.json"), "utf-8"));
197616
197979
  const repository = String(manifest.repository ?? "");
@@ -197622,7 +197985,7 @@ async function removeOwnedLegacyCodexPluginFolder(homeDir) {
197622
197985
  }
197623
197986
  }
197624
197987
  async function migrateLegacyCodexIntegration(options = {}) {
197625
- const homeDir = options.homeDir ?? homedir28();
197988
+ const homeDir = options.homeDir ?? homedir29();
197626
197989
  const projectRoot = options.projectRoot ?? process.cwd();
197627
197990
  const configPath = path32.join(homeDir, ".codex", "config.toml");
197628
197991
  let mcp = "missing";
@@ -197823,10 +198186,10 @@ async function stripCodeBuddyHookCapture(pluginPath) {
197823
198186
  await writeFile7(manifestPath, JSON.stringify(manifest, null, 2) + "\n", "utf-8");
197824
198187
  }
197825
198188
  async function installCodeBuddyPluginPackage(options = {}) {
197826
- const home = options.homeDir ?? homedir28();
198189
+ const home = options.homeDir ?? homedir29();
197827
198190
  const packageRoot2 = findPackageRoot();
197828
198191
  const source = path32.join(packageRoot2, "plugins", "codebuddy", "memorix");
197829
- if (!existsSync17(source)) throw new Error(`CodeBuddy plugin template not found: ${source}`);
198192
+ if (!existsSync18(source)) throw new Error(`CodeBuddy plugin template not found: ${source}`);
197830
198193
  const marketplaceRoot = path32.join(home, ".codebuddy", "memorix-local");
197831
198194
  const marketplacePath = path32.join(marketplaceRoot, ".codebuddy-plugin", "marketplace.json");
197832
198195
  const pluginPath = path32.join(marketplaceRoot, "plugins", "memorix");
@@ -197843,11 +198206,11 @@ async function installCodeBuddyPluginPackage(options = {}) {
197843
198206
  };
197844
198207
  }
197845
198208
  async function installPluginPackage(options) {
197846
- const home = options.homeDir ?? homedir28();
198209
+ const home = options.homeDir ?? homedir29();
197847
198210
  const packageRoot2 = findPackageRoot();
197848
198211
  const source = path32.join(packageRoot2, "plugins", options.agent, "memorix");
197849
198212
  const includeHooks = options.includeHooks ?? true;
197850
- if (!existsSync17(source)) {
198213
+ if (!existsSync18(source)) {
197851
198214
  throw new Error(`Plugin package template not found: ${source}`);
197852
198215
  }
197853
198216
  if (options.agent === "codex") {
@@ -197892,10 +198255,10 @@ async function installPluginPackage(options) {
197892
198255
  };
197893
198256
  }
197894
198257
  async function installGeminiExtensionPackage(options = {}) {
197895
- const home = options.homeDir ?? homedir28();
198258
+ const home = options.homeDir ?? homedir29();
197896
198259
  const packageRoot2 = findPackageRoot();
197897
198260
  const source = path32.join(packageRoot2, "plugins", "gemini", "memorix");
197898
- if (!existsSync17(source)) {
198261
+ if (!existsSync18(source)) {
197899
198262
  throw new Error(`Gemini extension template not found: ${source}`);
197900
198263
  }
197901
198264
  const extensionPath = path32.join(home, ".gemini", "extensions", "memorix");
@@ -197909,10 +198272,10 @@ async function installGeminiExtensionPackage(options = {}) {
197909
198272
  async function installAntigravityPluginPackage(options = {}) {
197910
198273
  const packageRoot2 = findPackageRoot();
197911
198274
  const source = path32.join(packageRoot2, "plugins", "antigravity", "memorix");
197912
- if (!existsSync17(source)) {
198275
+ if (!existsSync18(source)) {
197913
198276
  throw new Error(`Antigravity plugin template not found: ${source}`);
197914
198277
  }
197915
- const pluginPath = options.global === false ? path32.join(options.projectRoot ?? process.cwd(), ".agents", "plugins", "memorix") : path32.join(options.homeDir ?? homedir28(), ".gemini", "config", "plugins", "memorix");
198278
+ const pluginPath = options.global === false ? path32.join(options.projectRoot ?? process.cwd(), ".agents", "plugins", "memorix") : path32.join(options.homeDir ?? homedir29(), ".gemini", "config", "plugins", "memorix");
197916
198279
  await copyDir(source, pluginPath);
197917
198280
  if (options.includeHooks === false) {
197918
198281
  await rm2(path32.join(pluginPath, "hooks.json"), { force: true });
@@ -197927,10 +198290,10 @@ async function installAntigravityPluginPackage(options = {}) {
197927
198290
  async function installPiPackage(options = {}) {
197928
198291
  const packageRoot2 = findPackageRoot();
197929
198292
  const source = path32.join(packageRoot2, "plugins", "pi", "memorix");
197930
- if (!existsSync17(source)) {
198293
+ if (!existsSync18(source)) {
197931
198294
  throw new Error(`Pi package template not found: ${source}`);
197932
198295
  }
197933
- const defaultRoot = options.global ? path32.join(options.homeDir ?? homedir28(), ".pi", "agent", "packages") : path32.join(process.cwd(), ".pi", "packages");
198296
+ const defaultRoot = options.global ? path32.join(options.homeDir ?? homedir29(), ".pi", "agent", "packages") : path32.join(process.cwd(), ".pi", "packages");
197934
198297
  const packagePath = options.packageDir ?? path32.join(defaultRoot, "memorix");
197935
198298
  await copyDir(source, packagePath);
197936
198299
  await writeOfficialSkills(path32.join(packagePath, "skills"));
@@ -197942,10 +198305,10 @@ async function installPiPackage(options = {}) {
197942
198305
  };
197943
198306
  }
197944
198307
  async function installOpenClawBundlePackage(options = {}) {
197945
- const home = options.homeDir ?? homedir28();
198308
+ const home = options.homeDir ?? homedir29();
197946
198309
  const packageRoot2 = findPackageRoot();
197947
198310
  const source = path32.join(packageRoot2, "plugins", "openclaw", "memorix");
197948
- if (!existsSync17(source)) {
198311
+ if (!existsSync18(source)) {
197949
198312
  throw new Error(`OpenClaw bundle template not found: ${source}`);
197950
198313
  }
197951
198314
  const bundlePath = path32.join(home, ".openclaw", "extensions", "memorix");
@@ -197961,7 +198324,7 @@ async function installOpenClawBundlePackage(options = {}) {
197961
198324
  async function installHermesPluginPackage(options = {}) {
197962
198325
  const packageRoot2 = findPackageRoot();
197963
198326
  const source = path32.join(packageRoot2, "plugins", "hermes", "memorix");
197964
- if (!existsSync17(source)) {
198327
+ if (!existsSync18(source)) {
197965
198328
  throw new Error(`Hermes plugin template not found: ${source}`);
197966
198329
  }
197967
198330
  const hermesHome = resolveHermesHome(options.homeDir);
@@ -197988,10 +198351,10 @@ async function installHermesPluginPackage(options = {}) {
197988
198351
  async function installOmpPackage(options = {}) {
197989
198352
  const packageRoot2 = findPackageRoot();
197990
198353
  const source = path32.join(packageRoot2, "plugins", "omp", "memorix");
197991
- if (!existsSync17(source)) {
198354
+ if (!existsSync18(source)) {
197992
198355
  throw new Error(`Oh-my-Pi package template not found: ${source}`);
197993
198356
  }
197994
- const defaultRoot = options.global ? path32.join(options.homeDir ?? homedir28(), ".omp", "agent", "packages") : path32.join(process.cwd(), ".omp", "packages");
198357
+ const defaultRoot = options.global ? path32.join(options.homeDir ?? homedir29(), ".omp", "agent", "packages") : path32.join(process.cwd(), ".omp", "packages");
197995
198358
  const packagePath = options.packageDir ?? path32.join(defaultRoot, "memorix");
197996
198359
  await copyDir(source, packagePath);
197997
198360
  await writeOfficialSkills(path32.join(packagePath, "skills"));
@@ -198215,7 +198578,7 @@ ${hook.stdout || ""}`.toLowerCase();
198215
198578
  function resolveHermesCommand(hermesHome) {
198216
198579
  if (process.platform === "win32") {
198217
198580
  const localHermes = path32.join(hermesHome, "hermes-agent", "venv", "Scripts", "hermes.exe");
198218
- if (existsSync17(localHermes)) return localHermes;
198581
+ if (existsSync18(localHermes)) return localHermes;
198219
198582
  }
198220
198583
  return "hermes";
198221
198584
  }
@@ -198265,7 +198628,7 @@ ${result.stdout || ""}`.toLowerCase();
198265
198628
  }
198266
198629
  async function installAgentSetup(agent, plan, global2) {
198267
198630
  const { installAgentGuidance: installAgentGuidance2, installHooks: installHooks2 } = await Promise.resolve().then(() => (init_installers(), installers_exports));
198268
- const targetRoot = global2 ? homedir28() : process.cwd();
198631
+ const targetRoot = global2 ? homedir29() : process.cwd();
198269
198632
  const hasPluginPackage = plan.actions.includes("plugin-package") && PLUGIN_PACKAGE_AGENTS.has(agent);
198270
198633
  const hasExtensionPackage = plan.actions.includes("extension-package") && agent === "gemini-cli";
198271
198634
  const hasPiPackage = plan.actions.includes("pi-package") && agent === "pi";
@@ -198274,7 +198637,7 @@ async function installAgentSetup(agent, plan, global2) {
198274
198637
  const hasHermesPlugin = plan.actions.includes("hermes-plugin") && agent === "hermes";
198275
198638
  const hasOmpPackage = plan.actions.includes("omp-package") && agent === "omp";
198276
198639
  const hasCodeBuddyPlugin = plan.actions.includes("codebuddy-plugin") && agent === "codebuddy";
198277
- const wantsMcpConfig = plan.mcp !== "none" && agent !== "pi" && !(agent === "codex" && !global2) && !(agent === "grok" && plan.mcp !== "http");
198640
+ const wantsMcpConfig = plan.mcp !== "none" && !(agent === "codex" && !global2) && !(agent === "grok" && plan.mcp !== "http");
198278
198641
  const bundledMcpRoots = [];
198279
198642
  if (PLUGIN_PACKAGE_AGENTS.has(agent) && plan.includePlugin && !global2) {
198280
198643
  v3.info(`${agent}: project setup leaves user-level plugins untouched. Run \`memorix setup --agent ${agent} --global\` to install its plugin, skills, and lifecycle hooks.`);
@@ -198445,9 +198808,10 @@ async function installAgentSetup(agent, plan, global2) {
198445
198808
  if (hasCodeBuddyPlugin) {
198446
198809
  v3.info(`${agent}: MCP, skills, and hooks are bundled in the official CodeBuddy plugin package`);
198447
198810
  }
198448
- if (agent === "pi") {
198449
- v3.info("pi: Pi has no MCP config lane in the current CLI; use the installed package extension and skill.");
198450
- } else if (agent === "grok") {
198811
+ if (agent === "pi" && plan.mcp !== "none") {
198812
+ v3.info("pi: run `pi mcp list` to check connections, then `/reload` in Pi. Trust the project to load project-local MCP config.");
198813
+ }
198814
+ if (agent === "grok") {
198451
198815
  if (plan.mcp === "http") {
198452
198816
  v3.info("grok: wrote [mcp_servers.memorix] HTTP URL in Grok config.toml. Start the control plane with `memorix background start`.");
198453
198817
  } else {
@@ -198497,6 +198861,7 @@ var init_setup = __esm({
198497
198861
  init_openclaw();
198498
198862
  init_hermes();
198499
198863
  init_omp();
198864
+ init_pi();
198500
198865
  init_kiro();
198501
198866
  init_opencode();
198502
198867
  init_trae();
@@ -198599,7 +198964,7 @@ var init_setup = __esm({
198599
198964
  { value: "openclaw", label: "OpenClaw", hint: "bundle + hook pack + skills + MCP" },
198600
198965
  { value: "hermes", label: "Hermes Agent", hint: "plugin + hooks + commands + skills + MCP" },
198601
198966
  { value: "omp", label: "Oh-my-Pi", hint: "package + extension + command + MCP" },
198602
- { value: "pi", label: "Pi coding agent", hint: "package + extension + skill" },
198967
+ { value: "pi", label: "Pi coding agent", hint: "package + extension + skills + MCP (Pi 1.0+)" },
198603
198968
  { value: "dsh", label: "DeepSeek Harness", hint: "MCP patch + AGENTS.md + skills" },
198604
198969
  { value: "opencode", label: "OpenCode", hint: "local plugin + AGENTS.md + MCP" },
198605
198970
  { value: "windsurf", label: "Windsurf", hint: "rules + hooks + MCP" },
@@ -198660,7 +199025,7 @@ var config_path_exports = {};
198660
199025
  __export(config_path_exports, {
198661
199026
  default: () => config_path_default
198662
199027
  });
198663
- import { homedir as homedir29 } from "os";
199028
+ import { homedir as homedir30 } from "os";
198664
199029
  var config_path_default;
198665
199030
  var init_config_path = __esm({
198666
199031
  "src/cli/commands/config-path.ts"() {
@@ -198678,7 +199043,7 @@ var init_config_path = __esm({
198678
199043
  run: async () => {
198679
199044
  const project = detectProject(process.cwd());
198680
199045
  ye2([
198681
- `Global: ${getGlobalConfigTomlPath(homedir29())}`,
199046
+ `Global: ${getGlobalConfigTomlPath(homedir30())}`,
198682
199047
  `Project: ${project ? getProjectConfigTomlPath(project.rootPath) : "not inside a git project"}`
198683
199048
  ].join("\n"), "Memorix config");
198684
199049
  }
@@ -198754,7 +199119,7 @@ __export(config_migrate_exports, {
198754
199119
  serializeResolvedConfigToToml: () => serializeResolvedConfigToToml
198755
199120
  });
198756
199121
  import { mkdirSync as mkdirSync4, writeFileSync as writeFileSync4 } from "fs";
198757
- import { homedir as homedir30 } from "os";
199122
+ import { homedir as homedir31 } from "os";
198758
199123
  import { dirname as dirname4 } from "path";
198759
199124
  function serializeResolvedConfigToToml(config2, options = {}) {
198760
199125
  const includeSecrets = options.includeSecrets === true;
@@ -198853,7 +199218,7 @@ var init_config_migrate = __esm({
198853
199218
  v3.error("Not inside a git project. Use `memorix config migrate --global` for global config.");
198854
199219
  return;
198855
199220
  }
198856
- const target = isGlobal ? getGlobalConfigTomlPath(homedir30()) : getProjectConfigTomlPath(project.rootPath);
199221
+ const target = isGlobal ? getGlobalConfigTomlPath(homedir31()) : getProjectConfigTomlPath(project.rootPath);
198857
199222
  const resolved = getResolvedConfig({ projectRoot: project?.rootPath ?? null });
198858
199223
  const content = serializeResolvedConfigToToml(resolved, { includeSecrets: isGlobal });
198859
199224
  mkdirSync4(dirname4(target), { recursive: true });
@@ -198865,8 +199230,8 @@ var init_config_migrate = __esm({
198865
199230
  });
198866
199231
 
198867
199232
  // src/cli/commands/integrate-shared.ts
198868
- import { homedir as homedir31 } from "os";
198869
- function getIntegrationTargetRoot(useGlobalDefaults, cwd, homeDir = homedir31()) {
199233
+ import { homedir as homedir32 } from "os";
199234
+ function getIntegrationTargetRoot(useGlobalDefaults, cwd, homeDir = homedir32()) {
198870
199235
  return useGlobalDefaults ? homeDir : cwd;
198871
199236
  }
198872
199237
  function getIntegrationScopeLabel(useGlobalDefaults) {
@@ -199937,11 +200302,11 @@ __export(current_facts_exports, {
199937
200302
  formatGitFact: () => formatGitFact
199938
200303
  });
199939
200304
  import { execFileSync } from "child_process";
199940
- import { existsSync as existsSync18, readFileSync as readFileSync11 } from "fs";
200305
+ import { existsSync as existsSync19, readFileSync as readFileSync11 } from "fs";
199941
200306
  import path33 from "path";
199942
200307
  function readTextIfExists(filePath) {
199943
200308
  try {
199944
- if (!existsSync18(filePath)) return null;
200309
+ if (!existsSync19(filePath)) return null;
199945
200310
  return readFileSync11(filePath, "utf8");
199946
200311
  } catch {
199947
200312
  return null;
@@ -200232,8 +200597,8 @@ __export(external_provider_exports, {
200232
200597
  runExternalCodeGraphLifecycle: () => runExternalCodeGraphLifecycle
200233
200598
  });
200234
200599
  import { spawn as spawn5 } from "child_process";
200235
- import { existsSync as existsSync19, readFileSync as readFileSync12 } from "fs";
200236
- import { delimiter, dirname as dirname5, extname, isAbsolute as isAbsolute4, join as join25, relative as relative4, resolve as resolve6, sep as sep2 } from "path";
200600
+ import { existsSync as existsSync20, readFileSync as readFileSync12 } from "fs";
200601
+ import { delimiter, dirname as dirname5, extname, isAbsolute as isAbsolute4, join as join26, relative as relative4, resolve as resolve6, sep as sep2 } from "path";
200237
200602
  function boundedTimeout(value) {
200238
200603
  if (!Number.isFinite(value)) return DEFAULT_EXTERNAL_CODEGRAPH_TIMEOUT_MS;
200239
200604
  return Math.max(100, Math.min(Math.floor(value), MAX_EXTERNAL_CODEGRAPH_TIMEOUT_MS));
@@ -200262,20 +200627,20 @@ function resolveCommandCandidates(command) {
200262
200627
  }
200263
200628
  const names = extname(requested) ? [requested] : process.platform === "win32" ? [requested + ".exe", requested + ".cmd", requested + ".js", requested] : [requested];
200264
200629
  const directories = [
200265
- ...process.platform === "win32" && process.env.LOCALAPPDATA ? [join25(process.env.LOCALAPPDATA, "codegraph", "current", "bin")] : [],
200630
+ ...process.platform === "win32" && process.env.LOCALAPPDATA ? [join26(process.env.LOCALAPPDATA, "codegraph", "current", "bin")] : [],
200266
200631
  ...(process.env.PATH ?? "").split(delimiter).filter(Boolean)
200267
200632
  ];
200268
- return [...new Set(directories.flatMap((directory) => names.map((name) => join25(directory, name))))];
200633
+ return [...new Set(directories.flatMap((directory) => names.map((name) => join26(directory, name))))];
200269
200634
  }
200270
200635
  function resolveLaunch(command) {
200271
200636
  for (const candidate2 of resolveCommandCandidates(command)) {
200272
- if (!existsSync19(candidate2)) continue;
200637
+ if (!existsSync20(candidate2)) continue;
200273
200638
  const extension3 = extname(candidate2).toLowerCase();
200274
200639
  if (extension3 === ".cmd") {
200275
200640
  const bundleRoot = resolve6(dirname5(candidate2), "..");
200276
- const node = join25(bundleRoot, "node.exe");
200277
- const entry = join25(bundleRoot, "lib", "dist", "bin", "codegraph.js");
200278
- if (existsSync19(node) && existsSync19(entry)) {
200641
+ const node = join26(bundleRoot, "node.exe");
200642
+ const entry = join26(bundleRoot, "lib", "dist", "bin", "codegraph.js");
200643
+ if (existsSync20(node) && existsSync20(entry)) {
200279
200644
  return { executable: node, prefixArgs: ["--liftoff-only", entry] };
200280
200645
  }
200281
200646
  try {
@@ -200284,7 +200649,7 @@ function resolveLaunch(command) {
200284
200649
  if (match2?.[1]) {
200285
200650
  const base = dirname5(candidate2).endsWith(sep2) ? dirname5(candidate2) : dirname5(candidate2) + sep2;
200286
200651
  const entry2 = resolve6(match2[1].replace(/%(?:~)?dp0%?/gi, base));
200287
- if (existsSync19(entry2)) return { executable: process.execPath, prefixArgs: [entry2] };
200652
+ if (existsSync20(entry2)) return { executable: process.execPath, prefixArgs: [entry2] };
200288
200653
  }
200289
200654
  } catch {
200290
200655
  }
@@ -200432,7 +200797,7 @@ async function inspectExternalCodeGraph(input) {
200432
200797
  const health2 = { state: "disabled", reason: "External CodeGraph is disabled by configuration." };
200433
200798
  return { health: health2, quality: providerQuality({ mode, health: health2 }) };
200434
200799
  }
200435
- if (!existsSync19(join25(input.projectRoot, ".codegraph"))) {
200800
+ if (!existsSync20(join26(input.projectRoot, ".codegraph"))) {
200436
200801
  const health2 = { state: "not-detected", reason: "No local .codegraph index is present for this project." };
200437
200802
  return { health: health2, quality: providerQuality({ mode, health: health2 }) };
200438
200803
  }
@@ -200467,8 +200832,8 @@ async function runExternalCodeGraphLifecycle(input) {
200467
200832
  quality: providerQuality({ mode, health })
200468
200833
  };
200469
200834
  }
200470
- const indexPath = join25(input.projectRoot, ".codegraph");
200471
- if (input.action === "sync" && !existsSync19(indexPath)) {
200835
+ const indexPath = join26(input.projectRoot, ".codegraph");
200836
+ if (input.action === "sync" && !existsSync20(indexPath)) {
200472
200837
  const health = { state: "not-detected", reason: "No local .codegraph index is present for this project." };
200473
200838
  return {
200474
200839
  action: input.action,
@@ -200478,7 +200843,7 @@ async function runExternalCodeGraphLifecycle(input) {
200478
200843
  quality: providerQuality({ mode, health })
200479
200844
  };
200480
200845
  }
200481
- if (input.action === "init" && existsSync19(indexPath)) {
200846
+ if (input.action === "init" && existsSync20(indexPath)) {
200482
200847
  const inspected2 = await inspectExternalCodeGraph(input);
200483
200848
  return {
200484
200849
  action: input.action,
@@ -202253,13 +202618,13 @@ function buildCodeGraphDerivedView(input) {
202253
202618
  ...snapshot.sourceEpoch !== void 0 ? { generation: snapshot.sourceEpoch } : {},
202254
202619
  freshness: snapshot.incomplete ? "stale" : "current",
202255
202620
  rebuildStatus: snapshot.incomplete ? "failed" : "idle",
202256
- ...snapshot.incomplete ? { failureReason: "latest CodeGraph snapshot is incomplete" } : externalFailure && provider2?.external.reason ? { failureReason: provider2.external.reason.slice(0, 240) } : {}
202621
+ ...snapshot.incomplete ? { failureReason: "latest CodeGraph snapshot is incomplete" } : externalFailure && provider2?.external.reason ? { failureReason: sanitizeDerivedViewFailureReason(provider2.external.reason) } : {}
202257
202622
  };
202258
202623
  }
202259
202624
  return {
202260
202625
  freshness: "unknown",
202261
202626
  rebuildStatus: externalFailure ? "failed" : "unavailable",
202262
- ...provider2?.external.reason ? { failureReason: provider2.external.reason.slice(0, 240) } : { failureReason: "CodeGraph snapshot is not initialized" }
202627
+ ...provider2?.external.reason ? { failureReason: sanitizeDerivedViewFailureReason(provider2.external.reason) } : { failureReason: "CodeGraph snapshot is not initialized" }
202263
202628
  };
202264
202629
  }
202265
202630
  function buildBoundedContextReceipt(input) {
@@ -202289,6 +202654,7 @@ var init_context_receipt = __esm({
202289
202654
  "src/knowledge/context-receipt.ts"() {
202290
202655
  "use strict";
202291
202656
  init_esm_shims();
202657
+ init_derived_view_receipt();
202292
202658
  }
202293
202659
  });
202294
202660
 
@@ -202905,7 +203271,7 @@ __export(auto_context_exports, {
202905
203271
  formatAutoProjectContextSummary: () => formatAutoProjectContextSummary,
202906
203272
  formatLegacyAutoProjectContextPrompt: () => formatLegacyAutoProjectContextPrompt
202907
203273
  });
202908
- import { existsSync as existsSync20, statSync as statSync6 } from "fs";
203274
+ import { existsSync as existsSync21, statSync as statSync6 } from "fs";
202909
203275
  import path35 from "path";
202910
203276
  function activeProjectObservations(observations2, projectId) {
202911
203277
  return observations2.filter((obs) => obs.projectId === projectId && (obs.status ?? "active") === "active");
@@ -202963,12 +203329,12 @@ function decideRefresh(input) {
202963
203329
  return { performed: false, reason: "fresh-enough", message: "Existing project scan is fresh enough." };
202964
203330
  }
202965
203331
  async function buildAutoProjectContext(input) {
202966
- const refreshMode = input.refresh ?? "auto";
202967
203332
  const now3 = input.now ?? /* @__PURE__ */ new Date();
202968
203333
  const task = input.task?.trim();
202969
203334
  const lens = resolveTaskLens(task);
202970
203335
  const continuationRequested = input.continuation === "always" || input.continuation !== "never" && isContinuationTask(task);
202971
203336
  const codegraphConfig = getResolvedConfig({ projectRoot: input.project.rootPath }).codegraph;
203337
+ const refreshMode = input.refresh ?? codegraphConfig.autoRefresh ?? "auto";
202972
203338
  const exclude = input.exclude ?? codegraphConfig.excludePatterns;
202973
203339
  const maxFileBytes = input.maxFileBytes ?? codegraphConfig.maxFileBytes;
202974
203340
  const store2 = new CodeGraphStore();
@@ -203280,7 +203646,7 @@ function existingLensCandidates(rootPath, lens) {
203280
203646
  for (const candidate2 of lensPathCandidates(lens)) {
203281
203647
  const absolute = path35.join(rootPath, candidate2);
203282
203648
  try {
203283
- if (!existsSync20(absolute)) continue;
203649
+ if (!existsSync21(absolute)) continue;
203284
203650
  const stat6 = statSync6(absolute);
203285
203651
  if (stat6.isFile()) out.push(candidate2);
203286
203652
  if (stat6.isDirectory()) out.push(candidate2.replace(/\\/g, "/"));
@@ -203589,7 +203955,8 @@ __export(context_exports, {
203589
203955
  default: () => context_default
203590
203956
  });
203591
203957
  function coerceRefreshMode(input) {
203592
- const value = (input ?? "auto").trim().toLowerCase();
203958
+ if (!input?.trim()) return void 0;
203959
+ const value = input.trim().toLowerCase();
203593
203960
  if (value === "always" || value === "never" || value === "auto") return value;
203594
203961
  throw new Error("refresh must be one of: auto, always, never");
203595
203962
  }
@@ -203806,7 +204173,8 @@ __export(explain_exports, {
203806
204173
  default: () => explain_default
203807
204174
  });
203808
204175
  function coerceRefreshMode2(input) {
203809
- const value = (input ?? "auto").trim().toLowerCase();
204176
+ if (!input?.trim()) return void 0;
204177
+ const value = input.trim().toLowerCase();
203810
204178
  if (value === "always" || value === "never" || value === "auto") return value;
203811
204179
  throw new Error("refresh must be one of: auto, always, never");
203812
204180
  }
@@ -207079,9 +207447,9 @@ var engine_exports2 = {};
207079
207447
  __export(engine_exports2, {
207080
207448
  SkillsEngine: () => SkillsEngine
207081
207449
  });
207082
- import { existsSync as existsSync21, readFileSync as readFileSync13, writeFileSync as writeFileSync5, mkdirSync as mkdirSync5, readdirSync as readdirSync3 } from "fs";
207083
- import { join as join26 } from "path";
207084
- import { homedir as homedir32 } from "os";
207450
+ import { existsSync as existsSync22, readFileSync as readFileSync13, writeFileSync as writeFileSync5, mkdirSync as mkdirSync5, readdirSync as readdirSync3 } from "fs";
207451
+ import { join as join27 } from "path";
207452
+ import { homedir as homedir33 } from "os";
207085
207453
  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;
207086
207454
  var init_engine4 = __esm({
207087
207455
  "src/skills/engine.ts"() {
@@ -207152,30 +207520,30 @@ var init_engine4 = __esm({
207152
207520
  listSkills() {
207153
207521
  const skills = [];
207154
207522
  const seen = /* @__PURE__ */ new Set();
207155
- const home = homedir32();
207523
+ const home = homedir33();
207156
207524
  for (const [agent, dirs] of Object.entries(SKILLS_DIRS)) {
207157
207525
  for (const dir of dirs) {
207158
- const paths = [join26(this.projectRoot, dir)];
207526
+ const paths = [join27(this.projectRoot, dir)];
207159
207527
  if (!this.skipGlobal) {
207160
- paths.push(join26(home, dir));
207528
+ paths.push(join27(home, dir));
207161
207529
  }
207162
207530
  for (const skillsRoot of paths) {
207163
- if (!existsSync21(skillsRoot)) continue;
207531
+ if (!existsSync22(skillsRoot)) continue;
207164
207532
  try {
207165
207533
  const entries = readdirSync3(skillsRoot, { withFileTypes: true });
207166
207534
  for (const entry of entries) {
207167
207535
  if (!entry.isDirectory()) continue;
207168
207536
  const name = entry.name;
207169
207537
  if (seen.has(name)) continue;
207170
- const skillMd = join26(skillsRoot, name, "SKILL.md");
207171
- if (!existsSync21(skillMd)) continue;
207538
+ const skillMd = join27(skillsRoot, name, "SKILL.md");
207539
+ if (!existsSync22(skillMd)) continue;
207172
207540
  try {
207173
207541
  const content = readFileSync13(skillMd, "utf-8");
207174
207542
  const description = this.parseDescription(content);
207175
207543
  skills.push({
207176
207544
  name,
207177
207545
  description,
207178
- sourcePath: join26(skillsRoot, name),
207546
+ sourcePath: join27(skillsRoot, name),
207179
207547
  sourceAgent: agent,
207180
207548
  content,
207181
207549
  generated: false
@@ -207218,11 +207586,11 @@ var init_engine4 = __esm({
207218
207586
  writeSkill(skill2, target) {
207219
207587
  const dirs = SKILLS_DIRS[target];
207220
207588
  if (!dirs || dirs.length === 0) return null;
207221
- const targetDir = join26(this.projectRoot, dirs[0], skill2.name);
207589
+ const targetDir = join27(this.projectRoot, dirs[0], skill2.name);
207222
207590
  try {
207223
207591
  mkdirSync5(targetDir, { recursive: true });
207224
- writeFileSync5(join26(targetDir, "SKILL.md"), skill2.content, "utf-8");
207225
- return join26(dirs[0], skill2.name, "SKILL.md");
207592
+ writeFileSync5(join27(targetDir, "SKILL.md"), skill2.content, "utf-8");
207593
+ return join27(dirs[0], skill2.name, "SKILL.md");
207226
207594
  } catch {
207227
207595
  return null;
207228
207596
  }
@@ -208390,8 +208758,8 @@ var init_task_graph = __esm({
208390
208758
 
208391
208759
  // src/orchestrate/context-collector.ts
208392
208760
  import { execFileSync as execFileSync2 } from "child_process";
208393
- import { readFileSync as readFileSync14, existsSync as existsSync22 } from "fs";
208394
- import { join as join27 } from "path";
208761
+ import { readFileSync as readFileSync14, existsSync as existsSync23 } from "fs";
208762
+ import { join as join28 } from "path";
208395
208763
  function normalizeEntryLimit(value, fallback) {
208396
208764
  if (!Number.isSafeInteger(value) || value < 1) return fallback;
208397
208765
  return Math.min(value, 500);
@@ -208466,8 +208834,8 @@ function collectFileTree(projectDir2, maxEntries) {
208466
208834
  }
208467
208835
  function collectDependencies(projectDir2) {
208468
208836
  try {
208469
- const pkgPath = join27(projectDir2, "package.json");
208470
- if (!existsSync22(pkgPath)) return "";
208837
+ const pkgPath = join28(projectDir2, "package.json");
208838
+ if (!existsSync23(pkgPath)) return "";
208471
208839
  const pkg = JSON.parse(readFileSync14(pkgPath, "utf-8"));
208472
208840
  const parts = [];
208473
208841
  if (pkg.dependencies && Object.keys(pkg.dependencies).length > 0) {
@@ -209517,7 +209885,7 @@ __export(receipt_service_exports, {
209517
209885
  formatHandoffReceipt: () => formatHandoffReceipt
209518
209886
  });
209519
209887
  import { createHash as createHash19 } from "crypto";
209520
- import { existsSync as existsSync23, readFileSync as readFileSync15 } from "fs";
209888
+ import { existsSync as existsSync24, readFileSync as readFileSync15 } from "fs";
209521
209889
  import path37 from "path";
209522
209890
  function sha256(value) {
209523
209891
  return `sha256:${createHash19("sha256").update(value).digest("hex")}`;
@@ -209548,7 +209916,7 @@ function safeJsonArray(value) {
209548
209916
  }
209549
209917
  async function loadReceiptObservations(dataDir, projectId) {
209550
209918
  const dbPath = path37.join(dataDir, "memorix.db");
209551
- if (existsSync23(dbPath)) {
209919
+ if (existsSync24(dbPath)) {
209552
209920
  try {
209553
209921
  const DB = loadBetterSqlite3();
209554
209922
  const db2 = new DB(dbPath, { readonly: true, fileMustExist: true });
@@ -209565,7 +209933,7 @@ async function loadReceiptObservations(dataDir, projectId) {
209565
209933
  }
209566
209934
  }
209567
209935
  const jsonPath = path37.join(dataDir, "observations.json");
209568
- if (!existsSync23(jsonPath)) return [];
209936
+ if (!existsSync24(jsonPath)) return [];
209569
209937
  try {
209570
209938
  const parsed = JSON.parse(readFileSync15(jsonPath, "utf-8"));
209571
209939
  if (!Array.isArray(parsed)) return [];
@@ -209804,7 +210172,7 @@ var init_tool_profile = __esm({
209804
210172
  function getMcpServerInfo() {
209805
210173
  return {
209806
210174
  name: "memorix",
209807
- version: true ? "1.10.1" : "1.0.1"
210175
+ version: true ? "1.10.3" : "1.0.1"
209808
210176
  };
209809
210177
  }
209810
210178
  function createMcpDiscoverResult(capabilities, serverInfo) {
@@ -223849,7 +224217,7 @@ var init_sanitizer = __esm({
223849
224217
  });
223850
224218
 
223851
224219
  // src/workspace/applier.ts
223852
- import { existsSync as existsSync24, mkdirSync as mkdirSync6, copyFileSync, writeFileSync as writeFileSync6, unlinkSync as unlinkSync2, renameSync } from "fs";
224220
+ import { existsSync as existsSync25, mkdirSync as mkdirSync6, copyFileSync, writeFileSync as writeFileSync6, unlinkSync as unlinkSync2, renameSync } from "fs";
223853
224221
  import { dirname as dirname6 } from "path";
223854
224222
  var WorkspaceSyncApplier;
223855
224223
  var init_applier = __esm({
@@ -223880,7 +224248,7 @@ var init_applier = __esm({
223880
224248
  for (const file2 of files) {
223881
224249
  try {
223882
224250
  const dir = dirname6(file2.filePath);
223883
- if (!existsSync24(dir)) {
224251
+ if (!existsSync25(dir)) {
223884
224252
  mkdirSync6(dir, { recursive: true });
223885
224253
  }
223886
224254
  } catch (err) {
@@ -223889,7 +224257,7 @@ var init_applier = __esm({
223889
224257
  }
223890
224258
  }
223891
224259
  for (const file2 of files) {
223892
- if (existsSync24(file2.filePath)) {
224260
+ if (existsSync25(file2.filePath)) {
223893
224261
  try {
223894
224262
  const backupPath = file2.filePath + `.backup-${Date.now()}`;
223895
224263
  copyFileSync(file2.filePath, backupPath);
@@ -223940,7 +224308,7 @@ var init_applier = __esm({
223940
224308
  cleanBackups(backups) {
223941
224309
  for (const backup of backups) {
223942
224310
  try {
223943
- if (existsSync24(backup.backupPath)) {
224311
+ if (existsSync25(backup.backupPath)) {
223944
224312
  unlinkSync2(backup.backupPath);
223945
224313
  }
223946
224314
  } catch {
@@ -223956,9 +224324,9 @@ var engine_exports3 = {};
223956
224324
  __export(engine_exports3, {
223957
224325
  WorkspaceSyncEngine: () => WorkspaceSyncEngine
223958
224326
  });
223959
- import { readFileSync as readFileSync16, readdirSync as readdirSync4, existsSync as existsSync25, cpSync, mkdirSync as mkdirSync7 } from "fs";
223960
- import { join as join29 } from "path";
223961
- import { homedir as homedir33 } from "os";
224327
+ import { readFileSync as readFileSync16, readdirSync as readdirSync4, existsSync as existsSync26, cpSync, mkdirSync as mkdirSync7 } from "fs";
224328
+ import { join as join30 } from "path";
224329
+ import { homedir as homedir34 } from "os";
223962
224330
  var WorkspaceSyncEngine;
223963
224331
  var init_engine5 = __esm({
223964
224332
  "src/workspace/engine.ts"() {
@@ -224030,13 +224398,13 @@ var init_engine5 = __esm({
224030
224398
  const globalPath = adapter.getConfigPath();
224031
224399
  const pathsToCheck = [configPath, globalPath];
224032
224400
  if (target === "antigravity") {
224033
- pathsToCheck.push(join29(this.projectRoot, ".gemini", "settings.json"));
224034
- pathsToCheck.push(join29(homedir33(), ".gemini", "settings.json"));
224035
- pathsToCheck.push(join29(homedir33(), ".gemini", "antigravity", "mcp_config.json"));
224401
+ pathsToCheck.push(join30(this.projectRoot, ".gemini", "settings.json"));
224402
+ pathsToCheck.push(join30(homedir34(), ".gemini", "settings.json"));
224403
+ pathsToCheck.push(join30(homedir34(), ".gemini", "antigravity", "mcp_config.json"));
224036
224404
  }
224037
224405
  const merged = /* @__PURE__ */ new Map();
224038
224406
  for (const path50 of pathsToCheck) {
224039
- if (existsSync25(path50)) {
224407
+ if (existsSync26(path50)) {
224040
224408
  try {
224041
224409
  const content = readFileSync16(path50, "utf-8");
224042
224410
  const servers = adapter.parse(content);
@@ -224090,7 +224458,7 @@ var init_engine5 = __esm({
224090
224458
  const adapter = this.adapters.get(target);
224091
224459
  const configPath = adapter.getConfigPath(this.projectRoot);
224092
224460
  let configContent;
224093
- if (target === "antigravity" && existsSync25(configPath)) {
224461
+ if (target === "antigravity" && existsSync26(configPath)) {
224094
224462
  try {
224095
224463
  const existing = JSON.parse(readFileSync16(configPath, "utf-8"));
224096
224464
  const generated = JSON.parse(adapter.generate(result.mcpServers.scanned));
@@ -224149,7 +224517,7 @@ var init_engine5 = __esm({
224149
224517
  getTargetSkillsDir(target) {
224150
224518
  const dirs = _WorkspaceSyncEngine.SKILLS_DIRS[target];
224151
224519
  if (!dirs || dirs.length === 0) return null;
224152
- return join29(this.projectRoot, dirs[0]);
224520
+ return join30(this.projectRoot, dirs[0]);
224153
224521
  }
224154
224522
  /**
224155
224523
  * Scan all agent skills directories and collect unique skills.
@@ -224158,21 +224526,21 @@ var init_engine5 = __esm({
224158
224526
  const skills = [];
224159
224527
  const conflicts = [];
224160
224528
  const seen = /* @__PURE__ */ new Map();
224161
- const home = homedir33();
224529
+ const home = homedir34();
224162
224530
  for (const [agent, dirs] of Object.entries(_WorkspaceSyncEngine.SKILLS_DIRS)) {
224163
224531
  for (const dir of dirs) {
224164
224532
  const paths = [
224165
- join29(this.projectRoot, dir),
224166
- join29(home, dir)
224533
+ join30(this.projectRoot, dir),
224534
+ join30(home, dir)
224167
224535
  ];
224168
224536
  for (const skillsRoot of paths) {
224169
- if (!existsSync25(skillsRoot)) continue;
224537
+ if (!existsSync26(skillsRoot)) continue;
224170
224538
  try {
224171
224539
  const entries = readdirSync4(skillsRoot, { withFileTypes: true });
224172
224540
  for (const entry of entries) {
224173
224541
  if (!entry.isDirectory()) continue;
224174
- const skillMd = join29(skillsRoot, entry.name, "SKILL.md");
224175
- if (!existsSync25(skillMd)) continue;
224542
+ const skillMd = join30(skillsRoot, entry.name, "SKILL.md");
224543
+ if (!existsSync26(skillMd)) continue;
224176
224544
  let description = "";
224177
224545
  try {
224178
224546
  const content = readFileSync16(skillMd, "utf-8");
@@ -224183,7 +224551,7 @@ var init_engine5 = __esm({
224183
224551
  const newEntry = {
224184
224552
  name: entry.name,
224185
224553
  description,
224186
- sourcePath: join29(skillsRoot, entry.name),
224554
+ sourcePath: join30(skillsRoot, entry.name),
224187
224555
  sourceAgent: agent
224188
224556
  };
224189
224557
  const existing = seen.get(entry.name);
@@ -224220,8 +224588,8 @@ var init_engine5 = __esm({
224220
224588
  }
224221
224589
  for (const skill2 of skills) {
224222
224590
  if (skill2.sourceAgent === target) continue;
224223
- const dest = join29(targetDir, skill2.name);
224224
- if (existsSync25(dest)) {
224591
+ const dest = join30(targetDir, skill2.name);
224592
+ if (existsSync26(dest)) {
224225
224593
  skipped.push(`${skill2.name} (already exists in ${target})`);
224226
224594
  continue;
224227
224595
  }
@@ -224236,13 +224604,13 @@ var init_engine5 = __esm({
224236
224604
  }
224237
224605
  scanWorkflows() {
224238
224606
  const workflows = [];
224239
- const wfDir = join29(this.projectRoot, ".windsurf", "workflows");
224240
- if (!existsSync25(wfDir)) return workflows;
224607
+ const wfDir = join30(this.projectRoot, ".windsurf", "workflows");
224608
+ if (!existsSync26(wfDir)) return workflows;
224241
224609
  try {
224242
224610
  const files = readdirSync4(wfDir).filter((f7) => f7.endsWith(".md"));
224243
224611
  for (const file2 of files) {
224244
224612
  try {
224245
- const content = readFileSync16(join29(wfDir, file2), "utf-8");
224613
+ const content = readFileSync16(join30(wfDir, file2), "utf-8");
224246
224614
  workflows.push(this.workflowSyncer.parseWindsurfWorkflow(file2, content));
224247
224615
  } catch {
224248
224616
  }
@@ -224563,8 +224931,8 @@ __export(behavior_exports, {
224563
224931
  getBehaviorConfig: () => getBehaviorConfig,
224564
224932
  resetBehaviorConfigCache: () => resetBehaviorConfigCache
224565
224933
  });
224566
- import { existsSync as existsSync26, readFileSync as readFileSync17 } from "fs";
224567
- import { homedir as homedir34 } from "os";
224934
+ import { existsSync as existsSync27, readFileSync as readFileSync17 } from "fs";
224935
+ import { homedir as homedir35 } from "os";
224568
224936
  function isSessionInject(value) {
224569
224937
  return value === "full" || value === "minimal" || value === "silent";
224570
224938
  }
@@ -224574,7 +224942,7 @@ function isFormationMode(value) {
224574
224942
  function legacyBehavior(homeDir) {
224575
224943
  const configPath = getLegacyConfigJsonPath(homeDir);
224576
224944
  try {
224577
- if (!existsSync26(configPath)) return {};
224945
+ if (!existsSync27(configPath)) return {};
224578
224946
  const parsed = JSON.parse(readFileSync17(configPath, "utf-8"));
224579
224947
  return parsed.behavior && typeof parsed.behavior === "object" && !Array.isArray(parsed.behavior) ? parsed.behavior : {};
224580
224948
  } catch {
@@ -224582,7 +224950,7 @@ function legacyBehavior(homeDir) {
224582
224950
  }
224583
224951
  }
224584
224952
  function getBehaviorConfig(options = {}) {
224585
- const homeDir = options.homeDir ?? homedir34();
224953
+ const homeDir = options.homeDir ?? homedir35();
224586
224954
  const projectRoot = options.projectRoot === void 0 ? detectProject()?.rootPath ?? null : options.projectRoot;
224587
224955
  const cacheKey4 = `${homeDir}\0${projectRoot ?? ""}`;
224588
224956
  const cached2 = cache4.get(cacheKey4);
@@ -224623,6 +224991,30 @@ var init_behavior = __esm({
224623
224991
  }
224624
224992
  });
224625
224993
 
224994
+ // src/runtime/open-browser.ts
224995
+ import { spawn as spawn6 } from "child_process";
224996
+ function resolveLocalBrowserCommand(target, platform2 = process.platform) {
224997
+ const url2 = new URL(target);
224998
+ if (url2.protocol !== "http:" || !LOCAL_HTTP_HOSTS.has(url2.hostname) || !url2.port || url2.username || url2.password) {
224999
+ throw new Error("Only unauthenticated loopback HTTP URLs can be opened automatically");
225000
+ }
225001
+ return platform2 === "win32" ? { command: "explorer.exe", args: [url2.toString()] } : platform2 === "darwin" ? { command: "open", args: [url2.toString()] } : { command: "xdg-open", args: [url2.toString()] };
225002
+ }
225003
+ function openLocalBrowser(target) {
225004
+ const { command, args } = resolveLocalBrowserCommand(target);
225005
+ const child = spawn6(command, args, { detached: true, stdio: "ignore", windowsHide: true });
225006
+ child.once("error", () => void 0);
225007
+ child.unref();
225008
+ }
225009
+ var LOCAL_HTTP_HOSTS;
225010
+ var init_open_browser = __esm({
225011
+ "src/runtime/open-browser.ts"() {
225012
+ "use strict";
225013
+ init_esm_shims();
225014
+ LOCAL_HTTP_HOSTS = /* @__PURE__ */ new Set(["127.0.0.1", "localhost", "[::1]"]);
225015
+ }
225016
+ });
225017
+
224626
225018
  // src/memory/cleanup.ts
224627
225019
  function isLowQualityObservation(title) {
224628
225020
  return LOW_QUALITY_PATTERNS.some((pattern) => pattern.test(title.trim()));
@@ -225643,7 +226035,6 @@ __export(server_exports, {
225643
226035
  import { createServer } from "http";
225644
226036
  import { promises as fs23 } from "fs";
225645
226037
  import path41 from "path";
225646
- import { exec } from "child_process";
225647
226038
  function sendJson(res, data, status = 200) {
225648
226039
  res.writeHead(status, {
225649
226040
  "Content-Type": "application/json; charset=utf-8"
@@ -226080,8 +226471,8 @@ async function handleApi(req, res, dataDir, projectId, projectName, baseDir, pro
226080
226471
  }
226081
226472
  case "/config": {
226082
226473
  const os10 = await import("os");
226083
- const { existsSync: existsSync36 } = await import("fs");
226084
- const { join: join36 } = await import("path");
226474
+ const { existsSync: existsSync37 } = await import("fs");
226475
+ const { join: join37 } = await import("path");
226085
226476
  const configProjectRoot = effectiveProjectRoot;
226086
226477
  const resolved = getResolvedConfig({ projectRoot: configProjectRoot });
226087
226478
  const files = {
@@ -226096,19 +226487,19 @@ async function handleApi(req, res, dataDir, projectId, projectName, baseDir, pro
226096
226487
  try {
226097
226488
  const home = os10.homedir();
226098
226489
  const paths = {
226099
- "project memorix.yml": configProjectRoot ? join36(configProjectRoot, "memorix.yml") : null,
226100
- "user memorix.yml": join36(home, ".memorix", "memorix.yml"),
226101
- "project memorix.toml": configProjectRoot ? join36(configProjectRoot, "memorix.toml") : null,
226102
- "user config.toml": join36(home, ".memorix", "config.toml"),
226103
- "project .env": configProjectRoot ? join36(configProjectRoot, ".env") : null,
226104
- "user .env": join36(home, ".memorix", ".env"),
226105
- "legacy config.json": join36(home, ".memorix", "config.json")
226490
+ "project memorix.yml": configProjectRoot ? join37(configProjectRoot, "memorix.yml") : null,
226491
+ "user memorix.yml": join37(home, ".memorix", "memorix.yml"),
226492
+ "project memorix.toml": configProjectRoot ? join37(configProjectRoot, "memorix.toml") : null,
226493
+ "user config.toml": join37(home, ".memorix", "config.toml"),
226494
+ "project .env": configProjectRoot ? join37(configProjectRoot, ".env") : null,
226495
+ "user .env": join37(home, ".memorix", ".env"),
226496
+ "legacy config.json": join37(home, ".memorix", "config.json")
226106
226497
  };
226107
226498
  for (const [key, fpath] of Object.entries(paths)) {
226108
226499
  if (fpath === null) {
226109
226500
  files[key] = { exists: false, path: "unavailable", unavailable: true };
226110
226501
  } else {
226111
- files[key] = { exists: existsSync36(fpath), path: fpath };
226502
+ files[key] = { exists: existsSync37(fpath), path: fpath };
226112
226503
  }
226113
226504
  }
226114
226505
  } catch {
@@ -226133,7 +226524,8 @@ async function handleApi(req, res, dataDir, projectId, projectName, baseDir, pro
226133
226524
  ...resolved.memory.llm.provider === "openrouter" || resolved.memory.llm.baseUrl?.includes("openrouter.ai") ? ["OPENROUTER_API_KEY"] : [],
226134
226525
  ...resolved.memory.llm.provider === "requesty" ? ["REQUESTY_API_KEY"] : [],
226135
226526
  ...resolved.memory.llm.provider === "apiroute" ? ["API_ROUTE_API_KEY"] : [],
226136
- ...resolved.memory.llm.provider === "cheaperinference" ? ["CHEAPER_INFERENCE_API_KEY"] : []
226527
+ ...resolved.memory.llm.provider === "cheaperinference" ? ["CHEAPER_INFERENCE_API_KEY"] : [],
226528
+ ...resolved.memory.llm.provider === "runcrate" ? ["RUNCRATE_API_KEY"] : []
226137
226529
  ];
226138
226530
  if (llmKey) {
226139
226531
  const src2 = resolveDashboardKeySource({ value: llmKey, envKeys: memoryKeyEnv, configSource });
@@ -226348,9 +226740,10 @@ async function serveStatic(req, res, staticDir) {
226348
226740
  }
226349
226741
  }
226350
226742
  function openBrowser(url2) {
226351
- const cmd = process.platform === "win32" ? `start "" "${url2}"` : process.platform === "darwin" ? `open "${url2}"` : `xdg-open "${url2}"`;
226352
- exec(cmd, { windowsHide: true }, () => {
226353
- });
226743
+ try {
226744
+ openLocalBrowser(url2);
226745
+ } catch {
226746
+ }
226354
226747
  }
226355
226748
  function parseJsonField(value, fallback) {
226356
226749
  if (typeof value !== "string") return value ?? fallback;
@@ -226586,6 +226979,7 @@ var init_server3 = __esm({
226586
226979
  "src/dashboard/server.ts"() {
226587
226980
  "use strict";
226588
226981
  init_esm_shims();
226982
+ init_open_browser();
226589
226983
  init_persistence();
226590
226984
  init_obs_store();
226591
226985
  init_session_store();
@@ -266525,7 +266919,7 @@ async function analyzeImage(input) {
266525
266919
  const config2 = getLLMConfig();
266526
266920
  if (!OPENAI_COMPATIBLE_PROVIDERS.has(config2.provider)) {
266527
266921
  throw new Error(
266528
- `Image analysis requires an OpenAI-compatible provider (openai, openrouter, requesty, apiroute, cheaperinference, or custom). Current provider "${config2.provider}" uses a different API shape. Set MEMORIX_LLM_PROVIDER=openai or configure an OpenAI-compatible base URL.`
266922
+ `Image analysis requires an OpenAI-compatible provider (openai, openrouter, requesty, apiroute, cheaperinference, runcrate, or custom). Current provider "${config2.provider}" uses a different API shape. Set MEMORIX_LLM_PROVIDER=openai or configure an OpenAI-compatible base URL.`
266529
266923
  );
266530
266924
  }
266531
266925
  const bytes = decodeBase64ImagePayload(input.base64, MAX_VISION_IMAGE_BYTES);
@@ -266564,7 +266958,7 @@ var init_image_loader = __esm({
266564
266958
  init_provider2();
266565
266959
  init_secret_filter();
266566
266960
  init_image_payload();
266567
- OPENAI_COMPATIBLE_PROVIDERS = /* @__PURE__ */ new Set(["openai", "openrouter", "requesty", "apiroute", "cheaperinference", "custom"]);
266961
+ OPENAI_COMPATIBLE_PROVIDERS = /* @__PURE__ */ new Set(["openai", "openrouter", "requesty", "apiroute", "cheaperinference", "runcrate", "custom"]);
266568
266962
  MAX_VISION_PROMPT_CHARS = 12e3;
266569
266963
  MAX_VISION_DESCRIPTION_CHARS = 12e3;
266570
266964
  MAX_VISION_LABELS = 50;
@@ -266580,11 +266974,11 @@ __export(hooks_path_exports, {
266580
266974
  resolveGitDir: () => resolveGitDir,
266581
266975
  resolveHooksDir: () => resolveHooksDir
266582
266976
  });
266583
- import { existsSync as existsSync27, readFileSync as readFileSync18, statSync as statSync7, mkdirSync as mkdirSync8 } from "fs";
266977
+ import { existsSync as existsSync28, readFileSync as readFileSync18, statSync as statSync7, mkdirSync as mkdirSync8 } from "fs";
266584
266978
  import path42 from "path";
266585
266979
  function resolveGitDir(projectRoot) {
266586
266980
  const dotGit = path42.join(projectRoot, ".git");
266587
- if (!existsSync27(dotGit)) return null;
266981
+ if (!existsSync28(dotGit)) return null;
266588
266982
  const stat6 = statSync7(dotGit);
266589
266983
  if (stat6.isDirectory()) {
266590
266984
  return dotGit;
@@ -266596,7 +266990,7 @@ function resolveGitDir(projectRoot) {
266596
266990
  if (match2) {
266597
266991
  const gitdir = match2[1].trim();
266598
266992
  const resolved = path42.isAbsolute(gitdir) ? gitdir : path42.resolve(projectRoot, gitdir);
266599
- if (existsSync27(resolved)) {
266993
+ if (existsSync28(resolved)) {
266600
266994
  return resolved;
266601
266995
  }
266602
266996
  }
@@ -267802,7 +268196,18 @@ _Search mode: ${result.receipt.mode}_`;
267802
268196
  text: text3
267803
268197
  }
267804
268198
  ],
267805
- structuredContent: { retrieval: result.receipt }
268199
+ // Clients that surface only structuredContent (e.g. Claude Code) must
268200
+ // still see the results, not just the retrieval diagnostics.
268201
+ structuredContent: {
268202
+ results: result.entries.map((entry) => ({
268203
+ ref: formatEntryRef(entry),
268204
+ title: entry.title,
268205
+ type: entry.type,
268206
+ time: entry.time,
268207
+ tokens: entry.tokens
268208
+ })),
268209
+ retrieval: result.receipt
268210
+ }
267806
268211
  };
267807
268212
  }, { loadCorpus: false });
267808
268213
  }
@@ -267852,7 +268257,7 @@ _Search mode: ${result.receipt.mode}_`;
267852
268257
  inputSchema: {
267853
268258
  task: external_exports2.string().optional().describe("Current coding task or question"),
267854
268259
  taskId: external_exports2.string().max(120).optional().describe("Optional task continuity ledger id to include in the brief"),
267855
- refresh: external_exports2.enum(["auto", "always", "never"]).optional().default("auto").describe(
268260
+ refresh: external_exports2.enum(["auto", "always", "never"]).optional().describe(
267856
268261
  "Code Memory refresh policy. auto refreshes only when missing or stale."
267857
268262
  ),
267858
268263
  format: external_exports2.enum(["prompt", "summary", "json", "receipt"]).optional().default("prompt").describe(
@@ -267908,7 +268313,7 @@ _Search mode: ${result.receipt.mode}_`;
267908
268313
  task,
267909
268314
  taskId,
267910
268315
  agent,
267911
- refresh: refresh ?? "auto",
268316
+ ...refresh ? { refresh } : {},
267912
268317
  reader: getObservationReader(),
267913
268318
  enqueueRefresh: () => {
267914
268319
  enqueueCodegraphRefresh2({
@@ -269046,10 +269451,10 @@ ${Math.max(0, managedIds.size - result.resolved.length)} visible writable observ
269046
269451
  );
269047
269452
  let enableKG = isToolInProfile("create_entities", toolProfile);
269048
269453
  try {
269049
- const { homedir: homedir38 } = await import("os");
269050
- const { join: join36 } = await import("path");
269454
+ const { homedir: homedir39 } = await import("os");
269455
+ const { join: join37 } = await import("path");
269051
269456
  const { readFile: readFile11 } = await import("fs/promises");
269052
- const raw = await readFile11(join36(homedir38(), ".memorix", "settings.json"), "utf-8");
269457
+ const raw = await readFile11(join37(homedir39(), ".memorix", "settings.json"), "utf-8");
269053
269458
  const s4 = JSON.parse(raw);
269054
269459
  if (s4.knowledgeGraph === true) enableKG = true;
269055
269460
  } catch {
@@ -269870,9 +270275,12 @@ ${s4.instruction}`.toLowerCase();
269870
270275
  }
269871
270276
  } catch {
269872
270277
  }
270278
+ const card = lines.filter(Boolean).join("\n");
269873
270279
  return {
269874
- content: [{ type: "text", text: lines.filter(Boolean).join("\n") }],
269875
- structuredContent: { binding: bindingReceipt }
270280
+ content: [{ type: "text", text: card }],
270281
+ // Clients that surface only structuredContent (e.g. Claude Code) must
270282
+ // still see the session card, not just the binding receipt.
270283
+ structuredContent: { card, binding: bindingReceipt }
269876
270284
  };
269877
270285
  }
269878
270286
  );
@@ -270098,9 +270506,9 @@ ${json4}
270098
270506
  req.end();
270099
270507
  });
270100
270508
  const projectUrl = `${url2}?project=${encodeURIComponent(project.id)}`;
270101
- const { exec: exec2 } = await import("child_process");
270509
+ const { exec } = await import("child_process");
270102
270510
  const cmd = process.platform === "win32" ? `start "" "${projectUrl}"` : process.platform === "darwin" ? `open "${projectUrl}"` : `xdg-open "${projectUrl}"`;
270103
- exec2(cmd, { windowsHide: true }, () => {
270511
+ exec(cmd, { windowsHide: true }, () => {
270104
270512
  });
270105
270513
  return {
270106
270514
  content: [{
@@ -270149,9 +270557,9 @@ ${json4}
270149
270557
  req.end();
270150
270558
  });
270151
270559
  const projectUrl = `${url2}?project=${encodeURIComponent(project.id)}`;
270152
- const { exec: exec2 } = await import("child_process");
270560
+ const { exec } = await import("child_process");
270153
270561
  const cmd = process.platform === "win32" ? `start "" "${projectUrl}"` : process.platform === "darwin" ? `open "${projectUrl}"` : `xdg-open "${projectUrl}"`;
270154
- exec2(cmd, { windowsHide: true }, () => {
270562
+ exec(cmd, { windowsHide: true }, () => {
270155
270563
  });
270156
270564
  return {
270157
270565
  content: [{ type: "text", text: `Dashboard is already running at ${url2}. Switched to project: ${project.name} (${project.id}).` }]
@@ -271302,10 +271710,10 @@ Preview: ${analysis.description.slice(0, 300)}${analysis.description.length > 30
271302
271710
  const { ensureHooksDir: ensureHooksDir2 } = await Promise.resolve().then(() => (init_hooks_path(), hooks_path_exports));
271303
271711
  const resolved = ensureHooksDir2(project.rootPath);
271304
271712
  if (resolved) {
271305
- const { existsSync: existsSync36, readFileSync: readFileSync25, writeFileSync: writeFileSync13, chmodSync: chmodSync2 } = await import("fs");
271713
+ const { existsSync: existsSync37, readFileSync: readFileSync25, writeFileSync: writeFileSync13, chmodSync: chmodSync2 } = await import("fs");
271306
271714
  const { hookPath } = resolved;
271307
271715
  const HOOK_MARKER3 = "# [memorix-git-hook]";
271308
- const needsInstall = !existsSync36(hookPath) || !readFileSync25(hookPath, "utf-8").includes(HOOK_MARKER3);
271716
+ const needsInstall = !existsSync37(hookPath) || !readFileSync25(hookPath, "utf-8").includes(HOOK_MARKER3);
271309
271717
  if (needsInstall) {
271310
271718
  const hookScript = `#!/bin/sh
271311
271719
  ${HOOK_MARKER3}
@@ -271314,7 +271722,7 @@ if command -v memorix >/dev/null 2>&1; then
271314
271722
  memorix ingest commit --auto >/dev/null 2>&1 &
271315
271723
  fi
271316
271724
  `;
271317
- if (existsSync36(hookPath)) {
271725
+ if (existsSync37(hookPath)) {
271318
271726
  const existing = readFileSync25(hookPath, "utf-8");
271319
271727
  writeFileSync13(hookPath, existing.trimEnd() + `
271320
271728
 
@@ -271482,6 +271890,7 @@ var init_server4 = __esm({
271482
271890
  init_graph_scope();
271483
271891
  init_visibility();
271484
271892
  init_engine3();
271893
+ init_index_format();
271485
271894
  init_graph_context();
271486
271895
  init_detector();
271487
271896
  init_launch_root();
@@ -271819,8 +272228,8 @@ __export(update_checker_exports, {
271819
272228
  });
271820
272229
  import { execFile as execFile3 } from "child_process";
271821
272230
  import { readFile as readFile7, writeFile as writeFile8, mkdir as mkdir7 } from "fs/promises";
271822
- import { join as join30 } from "path";
271823
- import { homedir as homedir35 } from "os";
272231
+ import { join as join31 } from "path";
272232
+ import { homedir as homedir36 } from "os";
271824
272233
  function getCurrentVersion() {
271825
272234
  try {
271826
272235
  return getCliVersion();
@@ -271999,8 +272408,8 @@ var init_update_checker = __esm({
271999
272408
  MIN_AUTO_UPDATE_TIMEOUT_MS = 5e3;
272000
272409
  MAX_AUTO_UPDATE_TIMEOUT_MS = 30 * 60 * 1e3;
272001
272410
  REGISTRY_URL = `https://registry.npmjs.org/${PACKAGE_NAME}/latest`;
272002
- CACHE_DIR2 = join30(homedir35(), ".memorix");
272003
- CACHE_FILE2 = join30(CACHE_DIR2, "update-check.json");
272411
+ CACHE_DIR2 = join31(homedir36(), ".memorix");
272412
+ CACHE_FILE2 = join31(CACHE_DIR2, "update-check.json");
272004
272413
  _testing = {
272005
272414
  CACHE_FILE: CACHE_FILE2,
272006
272415
  CHECK_INTERVAL_MS,
@@ -272058,7 +272467,7 @@ var init_serve = __esm({
272058
272467
  const { serveStdio, StdioServerTransport } = await import("@modelcontextprotocol/server/stdio");
272059
272468
  const { createModernMcpBridge: createModernMcpBridge2 } = await Promise.resolve().then(() => (init_modern_mcp_bridge(), modern_mcp_bridge_exports));
272060
272469
  const { detectProject: detectProject2, findGitInSubdirs: findGitInSubdirs2, isSystemDirectory: isSystemDirectory2 } = await Promise.resolve().then(() => (init_detector(), detector_exports));
272061
- const { homedir: homedir38 } = await import("os");
272470
+ const { homedir: homedir39 } = await import("os");
272062
272471
  const { writeLastProjectRoot: writeLastProjectRoot2 } = await Promise.resolve().then(() => (init_launch_root(), launch_root_exports));
272063
272472
  const { resolveServeProject: resolveServeProject2 } = await Promise.resolve().then(() => (init_serve_shared(), serve_shared_exports));
272064
272473
  let stdioHandle;
@@ -272087,7 +272496,7 @@ var init_serve = __esm({
272087
272496
  try {
272088
272497
  safeCwd = process.cwd();
272089
272498
  } catch {
272090
- safeCwd = homedir38();
272499
+ safeCwd = homedir39();
272091
272500
  }
272092
272501
  const resolution = resolveServeProject2(
272093
272502
  {
@@ -272095,7 +272504,7 @@ var init_serve = __esm({
272095
272504
  envProjectRoot: process.env.MEMORIX_PROJECT_ROOT,
272096
272505
  initCwd: process.env.INIT_CWD,
272097
272506
  processCwd: safeCwd,
272098
- homeDir: homedir38()
272507
+ homeDir: homedir39()
272099
272508
  },
272100
272509
  { detectProject: detectProject2, findGitInSubdirs: findGitInSubdirs2, isSystemDirectory: isSystemDirectory2 }
272101
272510
  );
@@ -274725,7 +275134,7 @@ var init_serve_http = __esm({
274725
275134
  const { createProjectBindingController: createProjectBindingController2 } = await Promise.resolve().then(() => (init_request_context(), request_context_exports));
274726
275135
  const { findGitInSubdirs: findGitInSubdirs2 } = await Promise.resolve().then(() => (init_detector(), detector_exports));
274727
275136
  const { writeFileSync: writeFileSync13, mkdirSync: mkdirSync13 } = await import("fs");
274728
- const { homedir: homedir38 } = await import("os");
275137
+ const { homedir: homedir39 } = await import("os");
274729
275138
  const { McpBindingStore: McpBindingStore2 } = await Promise.resolve().then(() => (init_mcp_binding_store(), mcp_binding_store_exports));
274730
275139
  const { MemoryFeedbackStore: MemoryFeedbackStore2 } = await Promise.resolve().then(() => (init_feedback(), feedback_exports));
274731
275140
  const { createModernMcpRuntime: createModernMcpRuntime2, ModernMcpRuntimePool: ModernMcpRuntimePool2, withBusinessRuntimeQueue: withBusinessRuntimeQueue2 } = await Promise.resolve().then(() => (init_modern_mcp_bridge(), modern_mcp_bridge_exports));
@@ -274755,7 +275164,7 @@ var init_serve_http = __esm({
274755
275164
  try {
274756
275165
  safeCwd = process.cwd();
274757
275166
  } catch {
274758
- safeCwd = homedir38();
275167
+ safeCwd = homedir39();
274759
275168
  }
274760
275169
  const { resolveServeProject: resolveServeProject2 } = await Promise.resolve().then(() => (init_serve_shared(), serve_shared_exports));
274761
275170
  const { writeLastProjectRoot: writeLastProjectRoot2 } = await Promise.resolve().then(() => (init_launch_root(), launch_root_exports));
@@ -274766,7 +275175,7 @@ var init_serve_http = __esm({
274766
275175
  cwdArg: args.cwd,
274767
275176
  envProjectRoot: process.env.MEMORIX_PROJECT_ROOT,
274768
275177
  processCwd: safeCwd,
274769
- homeDir: homedir38()
275178
+ homeDir: homedir39()
274770
275179
  },
274771
275180
  { detectProject: detectorMod.detectProject, findGitInSubdirs: detectorMod.findGitInSubdirs, isSystemDirectory: detectorMod.isSystemDirectory }
274772
275181
  );
@@ -275813,8 +276222,8 @@ ${stack}` : ""}`);
275813
276222
  if (apiPath === "/config") {
275814
276223
  const { projectId: configProjectId } = await resolveRequestProject(url2);
275815
276224
  const os10 = await import("os");
275816
- const { existsSync: existsSync36 } = await import("fs");
275817
- const { join: join36 } = await import("path");
276225
+ const { existsSync: existsSync37 } = await import("fs");
276226
+ const { join: join37 } = await import("path");
275818
276227
  const { loadYamlConfig: loadYamlConfig2 } = await Promise.resolve().then(() => (init_yaml_loader(), yaml_loader_exports));
275819
276228
  const { loadFileConfig: loadFileConfig2, loadDotenv: loadDotenv2, getLoadedEnvFiles: getLoadedEnvFiles2 } = await Promise.resolve().then(() => (init_config(), config_exports));
275820
276229
  const isStartupProject = configProjectId === defaultProject.id;
@@ -275828,25 +276237,25 @@ ${stack}` : ""}`);
275828
276237
  const home = os10.homedir();
275829
276238
  if (effectiveRoot) {
275830
276239
  const paths = {
275831
- "project memorix.yml": join36(effectiveRoot, "memorix.yml"),
275832
- "user memorix.yml": join36(home, ".memorix", "memorix.yml"),
275833
- "project .env": join36(effectiveRoot, ".env"),
275834
- "user .env": join36(home, ".memorix", ".env"),
275835
- "legacy config.json": join36(home, ".memorix", "config.json")
276240
+ "project memorix.yml": join37(effectiveRoot, "memorix.yml"),
276241
+ "user memorix.yml": join37(home, ".memorix", "memorix.yml"),
276242
+ "project .env": join37(effectiveRoot, ".env"),
276243
+ "user .env": join37(home, ".memorix", ".env"),
276244
+ "legacy config.json": join37(home, ".memorix", "config.json")
275836
276245
  };
275837
276246
  for (const [key, fpath] of Object.entries(paths)) {
275838
- files[key] = { exists: existsSync36(fpath), path: fpath };
276247
+ files[key] = { exists: existsSync37(fpath), path: fpath };
275839
276248
  }
275840
276249
  } else {
275841
276250
  files["project memorix.yml"] = { exists: false, path: "unavailable", unavailable: true };
275842
276251
  files["project .env"] = { exists: false, path: "unavailable", unavailable: true };
275843
276252
  const userPaths = {
275844
- "user memorix.yml": join36(home, ".memorix", "memorix.yml"),
275845
- "user .env": join36(home, ".memorix", ".env"),
275846
- "legacy config.json": join36(home, ".memorix", "config.json")
276253
+ "user memorix.yml": join37(home, ".memorix", "memorix.yml"),
276254
+ "user .env": join37(home, ".memorix", ".env"),
276255
+ "legacy config.json": join37(home, ".memorix", "config.json")
275847
276256
  };
275848
276257
  for (const [key, fpath] of Object.entries(userPaths)) {
275849
- files[key] = { exists: existsSync36(fpath), path: fpath };
276258
+ files[key] = { exists: existsSync37(fpath), path: fpath };
275850
276259
  }
275851
276260
  }
275852
276261
  const values = [];
@@ -276475,7 +276884,7 @@ var init_status = __esm({
276475
276884
  const { getProjectDataDir: getProjectDataDir2 } = await Promise.resolve().then(() => (init_persistence(), persistence_exports));
276476
276885
  const { getEmbeddingProvider: getEmbeddingProvider2 } = await Promise.resolve().then(() => (init_provider(), provider_exports));
276477
276886
  const { getResolvedConfig: getResolvedConfig2, getResolvedAgentLane: getResolvedAgentLane2 } = await Promise.resolve().then(() => (init_resolved_config(), resolved_config_exports));
276478
- const { existsSync: existsSync36, readFileSync: readFileSync25 } = await import("fs");
276887
+ const { existsSync: existsSync37, readFileSync: readFileSync25 } = await import("fs");
276479
276888
  const project = detectProject2();
276480
276889
  if (!project) {
276481
276890
  const message = "Memorix requires a git repo to establish project identity. Run `git init` in this workspace first.";
@@ -276558,7 +276967,7 @@ var init_status = __esm({
276558
276967
  try {
276559
276968
  const { resolveHooksDir: resolveHooksDir2 } = await Promise.resolve().then(() => (init_hooks_path(), hooks_path_exports));
276560
276969
  const resolved2 = resolveHooksDir2(project.rootPath);
276561
- if (resolved2 && existsSync36(resolved2.hookPath)) {
276970
+ if (resolved2 && existsSync37(resolved2.hookPath)) {
276562
276971
  const hookContent = readFileSync25(resolved2.hookPath, "utf-8");
276563
276972
  if (hookContent.includes("# [memorix-git-hook]")) {
276564
276973
  diagLines.push(` Git hook: installed [OK]`);
@@ -280214,7 +280623,6 @@ async function buildHookProjectContext(input, task, target) {
280214
280623
  dataDir,
280215
280624
  observations: activeObservations2,
280216
280625
  task,
280217
- refresh: "auto",
280218
280626
  reader: { projectId: canonicalId },
280219
280627
  continuation: "always",
280220
280628
  ...input.sessionId ? {
@@ -282630,7 +283038,7 @@ var git_hook_install_exports = {};
282630
283038
  __export(git_hook_install_exports, {
282631
283039
  default: () => git_hook_install_default
282632
283040
  });
282633
- import { existsSync as existsSync28, readFileSync as readFileSync19, writeFileSync as writeFileSync7, chmodSync } from "fs";
283041
+ import { existsSync as existsSync29, readFileSync as readFileSync19, writeFileSync as writeFileSync7, chmodSync } from "fs";
282634
283042
  function generateHookScript() {
282635
283043
  return `${HOOK_MARKER}
282636
283044
  # Memorix: Auto-ingest git commits as memories
@@ -282677,7 +283085,7 @@ var init_git_hook_install = __esm({
282677
283085
  return;
282678
283086
  }
282679
283087
  const { hookPath } = resolved;
282680
- if (existsSync28(hookPath)) {
283088
+ if (existsSync29(hookPath)) {
282681
283089
  const existing = readFileSync19(hookPath, "utf-8");
282682
283090
  if (existing.includes(HOOK_MARKER)) {
282683
283091
  v3.warn("Memorix git hook is already installed.");
@@ -282727,7 +283135,7 @@ var git_hook_uninstall_exports = {};
282727
283135
  __export(git_hook_uninstall_exports, {
282728
283136
  default: () => git_hook_uninstall_default
282729
283137
  });
282730
- import { existsSync as existsSync29, readFileSync as readFileSync20, writeFileSync as writeFileSync8, unlinkSync as unlinkSync3 } from "fs";
283138
+ import { existsSync as existsSync30, readFileSync as readFileSync20, writeFileSync as writeFileSync8, unlinkSync as unlinkSync3 } from "fs";
282731
283139
  var HOOK_MARKER2, git_hook_uninstall_default;
282732
283140
  var init_git_hook_uninstall = __esm({
282733
283141
  "src/cli/commands/git-hook-uninstall.ts"() {
@@ -282759,7 +283167,7 @@ var init_git_hook_uninstall = __esm({
282759
283167
  return;
282760
283168
  }
282761
283169
  const { hookPath } = resolved;
282762
- if (!existsSync29(hookPath)) {
283170
+ if (!existsSync30(hookPath)) {
282763
283171
  v3.warn("No post-commit hook found.");
282764
283172
  fe2("Nothing to uninstall.");
282765
283173
  return;
@@ -282807,6 +283215,7 @@ var background_exports = {};
282807
283215
  __export(background_exports, {
282808
283216
  _testing: () => _testing3,
282809
283217
  default: () => background_default,
283218
+ doRestart: () => doRestart,
282810
283219
  doStart: () => doStart,
282811
283220
  doStop: () => doStop,
282812
283221
  resolveBackgroundCwd: () => resolveBackgroundCwd
@@ -282814,7 +283223,7 @@ __export(background_exports, {
282814
283223
  import * as fs26 from "fs";
282815
283224
  import path46 from "path";
282816
283225
  import { fileURLToPath as fileURLToPath8 } from "url";
282817
- import { spawn as spawn6, execFileSync as execFileSync4 } from "child_process";
283226
+ import { spawn as spawn7, execFileSync as execFileSync4 } from "child_process";
282818
283227
  import { randomBytes as randomBytes2 } from "crypto";
282819
283228
  import os8 from "os";
282820
283229
  function resolveBackgroundCwd(cwd, homeDir = os8.homedir()) {
@@ -282951,7 +283360,7 @@ function buildWindowsBackgroundStartScript(options) {
282951
283360
  async function startWindowsBackgroundService(options) {
282952
283361
  const script = buildWindowsBackgroundStartScript(options);
282953
283362
  return new Promise((resolve9, reject) => {
282954
- const launcher = spawn6("powershell.exe", [
283363
+ const launcher = spawn7("powershell.exe", [
282955
283364
  "-NoLogo",
282956
283365
  "-NoProfile",
282957
283366
  "-NonInteractive",
@@ -283164,7 +283573,7 @@ async function doStartUnlocked(port) {
283164
283573
  });
283165
283574
  } else {
283166
283575
  const logFd = fs26.openSync(logFile, "a");
283167
- const child = spawn6(process.execPath, [cliEntry, "serve-http", "--port", String(port)], {
283576
+ const child = spawn7(process.execPath, [cliEntry, "serve-http", "--port", String(port)], {
283168
283577
  detached: true,
283169
283578
  stdio: ["ignore", logFd, logFd],
283170
283579
  env: { ...process.env },
@@ -283618,10 +284027,10 @@ __export(agent_integrations_exports, {
283618
284027
  repairAgentIntegrations: () => repairAgentIntegrations
283619
284028
  });
283620
284029
  import { spawnSync as spawnSync2 } from "child_process";
283621
- import { existsSync as existsSync31, realpathSync as realpathSync2 } from "fs";
284030
+ import { existsSync as existsSync32, realpathSync as realpathSync2 } from "fs";
283622
284031
  import { mkdir as mkdir9, readFile as readFile10, writeFile as writeFile10 } from "fs/promises";
283623
284032
  import { basename as basename5, dirname as dirname8, resolve as resolve7 } from "path";
283624
- import { homedir as homedir36 } from "os";
284033
+ import { homedir as homedir37 } from "os";
283625
284034
  function requestedAgents(agent) {
283626
284035
  const all = getAgentIntegrationEntries().map((entry) => entry.agent);
283627
284036
  if (!agent || agent === "all") return all;
@@ -283703,7 +284112,7 @@ function capabilityParity(agent, projectRoot, scope, mcp, guidance, plugin) {
283703
284112
  for (const artifactScope of artifactScopes) {
283704
284113
  const path50 = artifactScope === "project" ? getProjectConfigPath(agent, projectRoot) : getGlobalConfigPath(agent);
283705
284114
  if (!path50) continue;
283706
- const exists3 = existsSync31(path50);
284115
+ const exists3 = existsSync32(path50);
283707
284116
  artifactChecks.push({
283708
284117
  kind: "hooks",
283709
284118
  scope: artifactScope,
@@ -283738,7 +284147,7 @@ function capabilityParity(agent, projectRoot, scope, mcp, guidance, plugin) {
283738
284147
  };
283739
284148
  }
283740
284149
  function isMcpConfigAgent(agent) {
283741
- return agent !== "pi" && agent !== "grok" && agent !== "qwen";
284150
+ return agent !== "grok" && agent !== "qwen";
283742
284151
  }
283743
284152
  function isActionableMcpRepairIssue(issue2) {
283744
284153
  return issue2 !== "memorix-server-missing";
@@ -283790,16 +284199,16 @@ function asRecordArray(value) {
283790
284199
  return Array.isArray(value) ? value.map(asRecord3).filter((entry) => entry !== null) : [];
283791
284200
  }
283792
284201
  function codexPluginPath() {
283793
- return `${homedir36()}/plugins/${CODEX_PLUGIN_NAME}`;
284202
+ return `${homedir37()}/plugins/${CODEX_PLUGIN_NAME}`;
283794
284203
  }
283795
284204
  function codexPluginMcpPath() {
283796
284205
  return `${codexPluginPath()}/.mcp.json`;
283797
284206
  }
283798
284207
  function codexMarketplacePath() {
283799
- return `${homedir36()}/.agents/plugins/marketplace.json`;
284208
+ return `${homedir37()}/.agents/plugins/marketplace.json`;
283800
284209
  }
283801
284210
  function codexConfigPath() {
283802
- return `${homedir36()}/.codex/config.toml`;
284211
+ return `${homedir37()}/.codex/config.toml`;
283803
284212
  }
283804
284213
  function normalizeMarketplacePath(value) {
283805
284214
  return value.replace(/\\/g, "/").replace(/^\.\//, "");
@@ -283831,7 +284240,7 @@ async function inspectCodexPluginBundle() {
283831
284240
  const manifestPath = `${pluginPath}/.codex-plugin/plugin.json`;
283832
284241
  const hooksPath = `${pluginPath}/hooks/hooks.json`;
283833
284242
  const mcpPath = codexPluginMcpPath();
283834
- if (!existsSync31(pluginPath)) {
284243
+ if (!existsSync32(pluginPath)) {
283835
284244
  return {
283836
284245
  scope: "global",
283837
284246
  kind: "bundle",
@@ -283841,7 +284250,7 @@ async function inspectCodexPluginBundle() {
283841
284250
  issues: ["codex-plugin-bundle-missing"]
283842
284251
  };
283843
284252
  }
283844
- if (!existsSync31(manifestPath)) {
284253
+ if (!existsSync32(manifestPath)) {
283845
284254
  return {
283846
284255
  scope: "global",
283847
284256
  kind: "bundle",
@@ -283878,7 +284287,7 @@ async function inspectCodexPluginBundle() {
283878
284287
  const issues = [];
283879
284288
  if (version2 !== getCliVersion()) issues.push("codex-plugin-version-mismatch");
283880
284289
  if (manifest.hooks !== "./hooks/hooks.json") issues.push("codex-hook-manifest-missing");
283881
- if (!existsSync31(mcpPath)) {
284290
+ if (!existsSync32(mcpPath)) {
283882
284291
  issues.push("codex-plugin-mcp-manifest-missing");
283883
284292
  } else {
283884
284293
  try {
@@ -283892,7 +284301,7 @@ async function inspectCodexPluginBundle() {
283892
284301
  }
283893
284302
  }
283894
284303
  let declared = [];
283895
- if (!existsSync31(hooksPath)) {
284304
+ if (!existsSync32(hooksPath)) {
283896
284305
  issues.push("codex-hook-manifest-missing");
283897
284306
  } else {
283898
284307
  try {
@@ -283919,7 +284328,7 @@ async function inspectCodexPluginBundle() {
283919
284328
  }
283920
284329
  async function inspectCodexMarketplace() {
283921
284330
  const marketplacePath = codexMarketplacePath();
283922
- if (!existsSync31(marketplacePath)) {
284331
+ if (!existsSync32(marketplacePath)) {
283923
284332
  return {
283924
284333
  scope: "global",
283925
284334
  kind: "marketplace",
@@ -284009,7 +284418,7 @@ function inspectCodexPluginRuntime() {
284009
284418
  }
284010
284419
  async function inspectCodexHookTrust() {
284011
284420
  const configPath = codexConfigPath();
284012
- if (!existsSync31(configPath)) {
284421
+ if (!existsSync32(configPath)) {
284013
284422
  return {
284014
284423
  scope: "global",
284015
284424
  kind: "hook-trust",
@@ -284110,11 +284519,11 @@ function defaultClaudeProjectKey(projectRoot) {
284110
284519
  }
284111
284520
  function canonicalProjectPath(projectRoot) {
284112
284521
  const resolved = resolve7(projectRoot);
284113
- const canonical = existsSync31(resolved) ? realpathSync2(resolved) : resolved;
284522
+ const canonical = existsSync32(resolved) ? realpathSync2(resolved) : resolved;
284114
284523
  return canonical.replace(/\\/g, "/");
284115
284524
  }
284116
284525
  function getClaudeLocalConfigPath() {
284117
- return `${homedir36()}/.claude.json`;
284526
+ return `${homedir37()}/.claude.json`;
284118
284527
  }
284119
284528
  function coerceMcpServer(name, value) {
284120
284529
  const entry = asRecord3(value);
@@ -284142,7 +284551,7 @@ function findClaudeLocalProject(config2, projectRoot) {
284142
284551
  }
284143
284552
  async function inspectClaudeLocalMcp(projectRoot) {
284144
284553
  const configPath = getClaudeLocalConfigPath();
284145
- if (!existsSync31(configPath)) {
284554
+ if (!existsSync32(configPath)) {
284146
284555
  return {
284147
284556
  scope: "local",
284148
284557
  path: configPath,
@@ -284230,7 +284639,7 @@ async function inspectCodexPluginMcp() {
284230
284639
  const runtime = inspectCodexPluginRuntime();
284231
284640
  if (!runtime.runtime?.installed || !runtime.runtime.enabled) return null;
284232
284641
  const mcpPath = codexPluginMcpPath();
284233
- if (!existsSync31(mcpPath)) {
284642
+ if (!existsSync32(mcpPath)) {
284234
284643
  return {
284235
284644
  scope: "global",
284236
284645
  path: mcpPath,
@@ -284282,7 +284691,7 @@ async function inspectOptionalGrokMcp(scope) {
284282
284691
  }
284283
284692
  const adapter = getMcpAdapter("grok");
284284
284693
  const configPath = adapter.getConfigPath();
284285
- if (!existsSync31(configPath)) {
284694
+ if (!existsSync32(configPath)) {
284286
284695
  return {
284287
284696
  status: "skipped",
284288
284697
  issues: ["mcp-host-owned"],
@@ -284349,7 +284758,7 @@ async function inspectMcp(agent, projectRoot, scope) {
284349
284758
  if (targetScope === "global" && configPath === adapter.getConfigPath(projectRoot) && scope === "all") {
284350
284759
  continue;
284351
284760
  }
284352
- if (!existsSync31(configPath)) {
284761
+ if (!existsSync32(configPath)) {
284353
284762
  checks.push({
284354
284763
  scope: targetScope,
284355
284764
  path: configPath,
@@ -284424,9 +284833,9 @@ async function inspectGuidance(agent, projectRoot, scope) {
284424
284833
  }
284425
284834
  const checks = [];
284426
284835
  for (const targetScope of requestedGuidanceScopes(scope)) {
284427
- const root = targetScope === "project" ? projectRoot : homedir36();
284836
+ const root = targetScope === "project" ? projectRoot : homedir37();
284428
284837
  const rulesPath = getAgentRulesPath(agent, root, targetScope === "global");
284429
- if (!existsSync31(rulesPath)) {
284838
+ if (!existsSync32(rulesPath)) {
284430
284839
  checks.push({
284431
284840
  scope: targetScope,
284432
284841
  path: rulesPath,
@@ -284713,9 +285122,9 @@ var init_doctor = __esm({
284713
285122
  }
284714
285123
  return;
284715
285124
  }
284716
- const { existsSync: existsSync36, readFileSync: readFileSync25 } = await import("fs");
284717
- const { join: join36, basename: basename7 } = await import("path");
284718
- const { homedir: homedir38 } = await import("os");
285125
+ const { existsSync: existsSync37, readFileSync: readFileSync25 } = await import("fs");
285126
+ const { join: join37, basename: basename7 } = await import("path");
285127
+ const { homedir: homedir39 } = await import("os");
284719
285128
  const { execSync: execSync5 } = await import("child_process");
284720
285129
  const report = {};
284721
285130
  const issues = [];
@@ -284777,14 +285186,14 @@ var init_doctor = __esm({
284777
285186
  }
284778
285187
  lines.push("");
284779
285188
  lines.push("\u250C\u2500 Runtime Mode \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500");
284780
- const memorixDir = join36(homedir38(), ".memorix");
284781
- const bgStatePath = join36(memorixDir, "background.json");
285189
+ const memorixDir = join37(homedir39(), ".memorix");
285190
+ const bgStatePath = join37(memorixDir, "background.json");
284782
285191
  let bgRunning = false;
284783
285192
  let bgPort = 0;
284784
285193
  let bgPid = 0;
284785
285194
  let backgroundHealthy = false;
284786
285195
  try {
284787
- if (existsSync36(bgStatePath)) {
285196
+ if (existsSync37(bgStatePath)) {
284788
285197
  const bgState = JSON.parse(readFileSync25(bgStatePath, "utf-8"));
284789
285198
  bgPid = bgState.pid;
284790
285199
  bgPort = bgState.port;
@@ -284898,8 +285307,8 @@ var init_doctor = __esm({
284898
285307
  }
284899
285308
  }
284900
285309
  try {
284901
- const cachePath = join36(memorixDir, "embedding-cache.json");
284902
- if (existsSync36(cachePath)) {
285310
+ const cachePath = join37(memorixDir, "embedding-cache.json");
285311
+ if (existsSync37(cachePath)) {
284903
285312
  const cache5 = JSON.parse(readFileSync25(cachePath, "utf-8"));
284904
285313
  const cacheCount = Object.keys(cache5).length;
284905
285314
  lines.push(info2(`Cached embeddings: ${cacheCount}`));
@@ -284914,7 +285323,7 @@ var init_doctor = __esm({
284914
285323
  }
284915
285324
  lines.push("");
284916
285325
  lines.push("\u250C\u2500 Data Status \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500");
284917
- if (dataDir && existsSync36(dataDir)) {
285326
+ if (dataDir && existsSync37(dataDir)) {
284918
285327
  let obsCount = 0;
284919
285328
  let activeCount = 0;
284920
285329
  let ranCount = 0;
@@ -285067,6 +285476,12 @@ var init_doctor = __esm({
285067
285476
  lines.push(info2(
285068
285477
  `Code provider: ${effectiveProviderQuality.semantic.state} semantic layer (${codeStatus.semanticSymbols} symbols, ${codeStatus.semanticEdges} edges); external graph ${providerQuality2.health.state}`
285069
285478
  ));
285479
+ if ((codeStatus.staleSymbols ?? 0) > 0) {
285480
+ lines.push(warn2(`CodeGraph derived storage: ${codeStatus.staleSymbols} stale symbols remain`));
285481
+ }
285482
+ if ((codeStatus.snapshots ?? 0) > 2) {
285483
+ lines.push(warn2(`CodeGraph snapshots: ${codeStatus.snapshots} retained; maintenance cleanup is pending`));
285484
+ }
285070
285485
  if (codeStatus.parserErrors > 0) {
285071
285486
  lines.push(warn2(`CodeGraph parser errors: ${codeStatus.parserErrors}; semantic context is partial until refresh succeeds.`));
285072
285487
  }
@@ -285092,6 +285507,9 @@ var init_doctor = __esm({
285092
285507
  semanticSymbols: codeStatus.semanticSymbols,
285093
285508
  semanticEdges: codeStatus.semanticEdges,
285094
285509
  parserErrors: codeStatus.parserErrors,
285510
+ ...codeStatus.staleSymbols !== void 0 ? { staleSymbols: codeStatus.staleSymbols } : {},
285511
+ ...codeStatus.snapshots !== void 0 ? { snapshots: codeStatus.snapshots } : {},
285512
+ ...codeStatus.snapshotFiles !== void 0 ? { snapshotFiles: codeStatus.snapshotFiles } : {},
285095
285513
  providerQuality: effectiveProviderQuality,
285096
285514
  ...overview.code.indexedAt ? { indexedAt: overview.code.indexedAt } : {}
285097
285515
  };
@@ -285152,8 +285570,8 @@ var init_doctor = __esm({
285152
285570
  lines.push("\u250C\u2500 Conflict Check \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500");
285153
285571
  let conflictsFound = false;
285154
285572
  if (dataDir) {
285155
- const lockFile = join36(dataDir, ".memorix.lock");
285156
- if (existsSync36(lockFile)) {
285573
+ const lockFile = join37(dataDir, ".memorix.lock");
285574
+ if (existsSync37(lockFile)) {
285157
285575
  try {
285158
285576
  const lockData = JSON.parse(readFileSync25(lockFile, "utf-8"));
285159
285577
  const lockAge = Date.now() - lockData.time;
@@ -285287,7 +285705,7 @@ var init_repair3 = __esm({
285287
285705
  repair_default = defineCommand({
285288
285706
  meta: {
285289
285707
  name: "repair",
285290
- description: "Repair Memorix-owned agent integration files"
285708
+ description: "Repair agent integrations or compact the semantic index"
285291
285709
  },
285292
285710
  args: {
285293
285711
  agent: {
@@ -285312,8 +285730,21 @@ var init_repair3 = __esm({
285312
285730
  run: async ({ args }) => {
285313
285731
  const positional = args._ ?? [];
285314
285732
  const action = positional[0] || "agents";
285733
+ if (action === "index") {
285734
+ if (args.dry) throw new Error("`memorix repair index` does not support --dry");
285735
+ const { detectProject: detectProject2 } = await Promise.resolve().then(() => (init_detector(), detector_exports));
285736
+ const { getProjectDataDir: getProjectDataDir2 } = await Promise.resolve().then(() => (init_persistence(), persistence_exports));
285737
+ const { optimizeSemanticIndexes: optimizeSemanticIndexes2 } = await Promise.resolve().then(() => (init_semantic_index(), semantic_index_exports));
285738
+ const project = detectProject2(process.cwd());
285739
+ if (!project) throw new Error("Run `memorix repair index` inside a Git project");
285740
+ const dataDir = await getProjectDataDir2(project.id);
285741
+ const tables = await optimizeSemanticIndexes2(dataDir);
285742
+ if (args.json) console.log(JSON.stringify({ dataDir, optimizedTables: tables }, null, 2));
285743
+ else console.log(`Optimized ${tables.length} semantic table(s) in ${dataDir}`);
285744
+ return;
285745
+ }
285315
285746
  if (action !== "agents") {
285316
- const message = "Usage: memorix repair agents [--agent <agent>] [--scope local|project|global|all] [--dry]";
285747
+ const message = "Usage: memorix repair agents [--agent <agent>] [--scope local|project|global|all] [--dry] | memorix repair index [--json]";
285317
285748
  if (args.json) {
285318
285749
  console.log(JSON.stringify({ error: message }, null, 2));
285319
285750
  } else {
@@ -285736,6 +286167,19 @@ function getMCPConfigEntries(home, cwd) {
285736
286167
  detected: checkJSON(path48.join(cwd, ".cursor", "mcp.json")),
285737
286168
  note: 'Remove the "memorix" key from mcpServers in this file.'
285738
286169
  });
286170
+ for (const [kind, configPath] of [
286171
+ ["global", path48.join(home, ".pi", "agent", "mcp.json")],
286172
+ ["project", path48.join(cwd, ".pi", "mcp.json")]
286173
+ ]) {
286174
+ entries.push({
286175
+ agent: "Pi",
286176
+ path: configPath,
286177
+ kind,
286178
+ format: "json",
286179
+ detected: checkJSON(configPath),
286180
+ note: 'Remove the "memorix" key from mcpServers in this file.'
286181
+ });
286182
+ }
285739
286183
  entries.push({
285740
286184
  agent: "Windsurf",
285741
286185
  path: path48.join(home, ".codeium", "windsurf", "mcp_config.json"),
@@ -287380,8 +287824,8 @@ var init_pipeline_trace = __esm({
287380
287824
 
287381
287825
  // src/orchestrate/worktree.ts
287382
287826
  import { execFileSync as execFileSync5 } from "child_process";
287383
- import { existsSync as existsSync33, rmSync as rmSync2 } from "fs";
287384
- import { join as join34, basename as basename6 } from "path";
287827
+ import { existsSync as existsSync34, rmSync as rmSync2 } from "fs";
287828
+ import { join as join35, basename as basename6 } from "path";
287385
287829
  function runGit4(cwd, args, timeout = 5e3) {
287386
287830
  return String(execFileSync5("git", args, {
287387
287831
  cwd,
@@ -287420,13 +287864,13 @@ function isManagedWorktreePath(worktreePath, worktreeBase) {
287420
287864
  function createWorktree(projectDir2, taskId, pipelineId) {
287421
287865
  const shortId2 = taskId.slice(0, 8);
287422
287866
  const shortPipeline = pipelineId.slice(0, 8);
287423
- const worktreeBase = join34(projectDir2, WORKTREE_DIR, `task-${shortId2}`);
287867
+ const worktreeBase = join35(projectDir2, WORKTREE_DIR, `task-${shortId2}`);
287424
287868
  const branchBase = `pipeline/${shortPipeline}/task-${shortId2}`;
287425
287869
  for (let attempt = 1; attempt <= 100; attempt++) {
287426
287870
  const suffix = attempt === 1 ? "" : `-${attempt}`;
287427
287871
  const worktreePath = `${worktreeBase}${suffix}`;
287428
287872
  const branch = `${branchBase}${suffix}`;
287429
- if (existsSync33(worktreePath)) continue;
287873
+ if (existsSync34(worktreePath)) continue;
287430
287874
  if (!isBranchAvailable(projectDir2, branch)) continue;
287431
287875
  runGit4(projectDir2, ["worktree", "add", "-b", branch, worktreePath], 3e4);
287432
287876
  return { worktreePath, branch };
@@ -287477,7 +287921,7 @@ function removeWorktree(projectDir2, worktreePath, branch) {
287477
287921
  try {
287478
287922
  runGit4(projectDir2, ["worktree", "remove", worktreePath, "--force"], 1e4);
287479
287923
  } catch {
287480
- if (existsSync33(worktreePath)) {
287924
+ if (existsSync34(worktreePath)) {
287481
287925
  try {
287482
287926
  rmSync2(worktreePath, { recursive: true, force: true });
287483
287927
  } catch {
@@ -287510,7 +287954,7 @@ function listWorktrees(projectDir2) {
287510
287954
  }
287511
287955
  }
287512
287956
  if (current) worktrees.push(current);
287513
- const worktreeBase = join34(projectDir2, WORKTREE_DIR);
287957
+ const worktreeBase = join35(projectDir2, WORKTREE_DIR);
287514
287958
  return worktrees.filter((w4) => isManagedWorktreePath(w4.path, worktreeBase));
287515
287959
  } catch {
287516
287960
  return [];
@@ -287547,7 +287991,7 @@ var init_worktree = __esm({
287547
287991
  });
287548
287992
 
287549
287993
  // src/orchestrate/verify-gate.ts
287550
- import { spawn as spawn7 } from "child_process";
287994
+ import { spawn as spawn8 } from "child_process";
287551
287995
  function runGate(gate, command, cwd, timeoutMs, outputBudget = DEFAULT_OUTPUT_BUDGET) {
287552
287996
  const start = Date.now();
287553
287997
  return new Promise((resolve9) => {
@@ -287561,7 +288005,7 @@ function runGate(gate, command, cwd, timeoutMs, outputBudget = DEFAULT_OUTPUT_BU
287561
288005
  if (timer) clearTimeout(timer);
287562
288006
  resolve9(result);
287563
288007
  };
287564
- const proc = spawn7(command, {
288008
+ const proc = spawn8(command, {
287565
288009
  cwd,
287566
288010
  shell: true,
287567
288011
  detached: process.platform !== "win32",
@@ -287582,7 +288026,7 @@ function runGate(gate, command, cwd, timeoutMs, outputBudget = DEFAULT_OUTPUT_BU
287582
288026
  const killTree = () => {
287583
288027
  try {
287584
288028
  if (process.platform === "win32" && proc.pid) {
287585
- const killer = spawn7("taskkill.exe", ["/F", "/T", "/PID", String(proc.pid)], {
288029
+ const killer = spawn8("taskkill.exe", ["/F", "/T", "/PID", String(proc.pid)], {
287586
288030
  stdio: "ignore",
287587
288031
  windowsHide: true
287588
288032
  });
@@ -287932,16 +288376,16 @@ var init_cost_tracker = __esm({
287932
288376
 
287933
288377
  // src/orchestrate/evidence.ts
287934
288378
  import { mkdirSync as mkdirSync11, writeFileSync as writeFileSync11 } from "fs";
287935
- import { join as join35 } from "path";
288379
+ import { join as join36 } from "path";
287936
288380
  function writeTaskEvidence(projectDir2, pipelineId, evidence) {
287937
288381
  try {
287938
- const dir = join35(projectDir2, ".pipeline", pipelineId, "evidence", evidence.taskId.slice(0, 12));
288382
+ const dir = join36(projectDir2, ".pipeline", pipelineId, "evidence", evidence.taskId.slice(0, 12));
287939
288383
  mkdirSync11(dir, { recursive: true });
287940
288384
  if (evidence.prompt) {
287941
- safeWrite(join35(dir, "prompt.md"), evidence.prompt);
288385
+ safeWrite(join36(dir, "prompt.md"), evidence.prompt);
287942
288386
  }
287943
288387
  if (evidence.tailOutput) {
287944
- safeWrite(join35(dir, "output.txt"), evidence.tailOutput);
288388
+ safeWrite(join36(dir, "output.txt"), evidence.tailOutput);
287945
288389
  }
287946
288390
  if (evidence.gateResults) {
287947
288391
  for (const g4 of evidence.gateResults) {
@@ -287950,7 +288394,7 @@ Status: ${g4.passed ? "PASS" : "FAIL"}
287950
288394
  Duration: ${(g4.durationMs / 1e3).toFixed(1)}s
287951
288395
 
287952
288396
  ${g4.output}`;
287953
- safeWrite(join35(dir, `${g4.gate}.txt`), content);
288397
+ safeWrite(join36(dir, `${g4.gate}.txt`), content);
287954
288398
  }
287955
288399
  }
287956
288400
  const resultJson = {
@@ -287964,7 +288408,7 @@ ${g4.output}`;
287964
288408
  tokenUsage: evidence.tokenUsage,
287965
288409
  costUSD: evidence.costUSD
287966
288410
  };
287967
- safeWrite(join35(dir, "result.json"), JSON.stringify(resultJson, null, 2));
288411
+ safeWrite(join36(dir, "result.json"), JSON.stringify(resultJson, null, 2));
287968
288412
  return dir;
287969
288413
  } catch {
287970
288414
  return null;
@@ -287972,7 +288416,7 @@ ${g4.output}`;
287972
288416
  }
287973
288417
  function writePipelineSummary(projectDir2, summary) {
287974
288418
  try {
287975
- const dir = join35(projectDir2, ".pipeline", summary.pipelineId);
288419
+ const dir = join36(projectDir2, ".pipeline", summary.pipelineId);
287976
288420
  mkdirSync11(dir, { recursive: true });
287977
288421
  const elapsed = (summary.elapsedMs / 1e3).toFixed(0);
287978
288422
  const lines = [
@@ -287993,8 +288437,8 @@ function writePipelineSummary(projectDir2, summary) {
287993
288437
  lines.push(`- [${status}] ${t4.taskDescription.slice(0, 80)} \u2014 ${t4.agentName}, ${dur}s${fixes}`);
287994
288438
  }
287995
288439
  const content = lines.join("\n") + "\n";
287996
- safeWrite(join35(dir, "summary.md"), content);
287997
- return join35(dir, "summary.md");
288440
+ safeWrite(join36(dir, "summary.md"), content);
288441
+ return join36(dir, "summary.md");
287998
288442
  } catch {
287999
288443
  return null;
288000
288444
  }
@@ -290907,6 +291351,7 @@ function ConfigureView({ onBack }) {
290907
291351
  { key: "requesty", label: "Requesty", hint: "multi-provider" },
290908
291352
  { key: "apiroute", label: "API Route", hint: "multi-provider" },
290909
291353
  { key: "cheaperinference", label: "Cheaper Inference", hint: "multi-provider" },
291354
+ { key: "runcrate", label: "Runcrate", hint: "open-weight models" },
290910
291355
  { key: "atlascloud", label: "Atlas Cloud", hint: "DeepSeek V3.2" },
290911
291356
  { key: "custom", label: "Custom endpoint", hint: "OpenAI-compatible" },
290912
291357
  { key: "disable", label: "Disable LLM", hint: "free heuristic mode", color: COLORS.warning },
@@ -291203,6 +291648,7 @@ function getDefaultModel(provider2) {
291203
291648
  if (provider2 === "requesty") return "openai/gpt-4o-mini";
291204
291649
  if (provider2 === "apiroute") return "deepseek-v4.1-flash";
291205
291650
  if (provider2 === "cheaperinference") return "gpt-5.4-mini";
291651
+ if (provider2 === "runcrate") return "deepseek-ai/DeepSeek-V4.1-Flash";
291206
291652
  if (provider2 === "atlascloud") return "deepseek-ai/deepseek-v3.2";
291207
291653
  return "gpt-4o-mini";
291208
291654
  }
@@ -293619,10 +294065,10 @@ function WorkbenchApp({ version: version2, onExitForInteractive }) {
293619
294065
  }
293620
294066
  try {
293621
294067
  const { resolveHooksDir: resolveHooksDir2 } = await Promise.resolve().then(() => (init_hooks_path(), hooks_path_exports));
293622
- const { existsSync: existsSync36, readFileSync: readFileSync25, writeFileSync: writeFileSync13, unlinkSync: unlinkSync5 } = await import("fs");
294068
+ const { existsSync: existsSync37, readFileSync: readFileSync25, writeFileSync: writeFileSync13, unlinkSync: unlinkSync5 } = await import("fs");
293623
294069
  const resolved = resolveHooksDir2(proj.rootPath);
293624
294070
  const hookMarker = "# [memorix-git-hook]";
293625
- if (!resolved || !existsSync36(resolved.hookPath)) {
294071
+ if (!resolved || !existsSync37(resolved.hookPath)) {
293626
294072
  setActionStatus("No post-commit hook found.");
293627
294073
  return;
293628
294074
  }
@@ -293777,7 +294223,7 @@ function WorkbenchApp({ version: version2, onExitForInteractive }) {
293777
294223
  break;
293778
294224
  }
293779
294225
  case "3": {
293780
- const { existsSync: existsSync36, readFileSync: readFileSync25, writeFileSync: writeFileSync13, chmodSync: chmodSync2 } = await import("fs");
294226
+ const { existsSync: existsSync37, readFileSync: readFileSync25, writeFileSync: writeFileSync13, chmodSync: chmodSync2 } = await import("fs");
293781
294227
  const { ensureHooksDir: ensureHooksDir2 } = await Promise.resolve().then(() => (init_hooks_path(), hooks_path_exports));
293782
294228
  const hookMarker = "# [memorix-git-hook]";
293783
294229
  const resolved = ensureHooksDir2(cwd);
@@ -293791,7 +294237,7 @@ if command -v memorix >/dev/null 2>&1; then
293791
294237
  memorix ingest commit --auto >/dev/null 2>&1 &
293792
294238
  fi
293793
294239
  `;
293794
- if (existsSync36(resolved.hookPath)) {
294240
+ if (existsSync37(resolved.hookPath)) {
293795
294241
  if (readFileSync25(resolved.hookPath, "utf-8").includes(hookMarker)) {
293796
294242
  setActionStatus("Post-commit hook already installed.");
293797
294243
  break;
@@ -293811,11 +294257,11 @@ ${hookScript}`, "utf-8");
293811
294257
  break;
293812
294258
  }
293813
294259
  case "4": {
293814
- const { existsSync: existsSync36, readFileSync: readFileSync25, writeFileSync: writeFileSync13, unlinkSync: unlinkSync5 } = await import("fs");
294260
+ const { existsSync: existsSync37, readFileSync: readFileSync25, writeFileSync: writeFileSync13, unlinkSync: unlinkSync5 } = await import("fs");
293815
294261
  const { resolveHooksDir: resolveHooksDir2 } = await Promise.resolve().then(() => (init_hooks_path(), hooks_path_exports));
293816
294262
  const hookMarker = "# [memorix-git-hook]";
293817
294263
  const resolved = resolveHooksDir2(cwd);
293818
- if (!resolved || !existsSync36(resolved.hookPath)) {
294264
+ if (!resolved || !existsSync37(resolved.hookPath)) {
293819
294265
  setActionStatus("No post-commit hook found.");
293820
294266
  break;
293821
294267
  }
@@ -293875,29 +294321,21 @@ ${hookScript}`, "utf-8");
293875
294321
  const handleBackgroundAction = useCallback5(async (action) => {
293876
294322
  setStatusMsg(null);
293877
294323
  try {
293878
- const { execSync: execSync5 } = await import("child_process");
294324
+ const { doStart: doStart2, doStop: doStop2, doRestart: doRestart2 } = await Promise.resolve().then(() => (init_background(), background_exports));
293879
294325
  if (background.running) {
293880
294326
  switch (action) {
293881
294327
  case "w":
293882
294328
  if (background.dashboard) {
293883
294329
  try {
293884
- execSync5(`start "" "${background.dashboard}"`, { stdio: "pipe", windowsHide: true });
294330
+ openLocalBrowser(background.dashboard);
293885
294331
  } catch {
293886
- try {
293887
- execSync5(`open "${background.dashboard}"`, { stdio: "pipe", windowsHide: true });
293888
- } catch {
293889
- try {
293890
- execSync5(`xdg-open "${background.dashboard}"`, { stdio: "pipe", windowsHide: true });
293891
- } catch {
293892
- }
293893
- }
293894
294332
  }
293895
294333
  setStatusMsg({ text: `Opening ${background.dashboard}`, type: "success" });
293896
294334
  }
293897
294335
  break;
293898
294336
  case "1":
293899
294337
  try {
293900
- execSync5("memorix background restart", { stdio: "pipe", timeout: 15e3, windowsHide: true });
294338
+ await doRestart2(background.port ?? 3211);
293901
294339
  setStatusMsg({ text: "Restarted.", type: "success" });
293902
294340
  } catch (e5) {
293903
294341
  setStatusMsg({ text: `Restart failed: ${e5}`, type: "error" });
@@ -293905,7 +294343,7 @@ ${hookScript}`, "utf-8");
293905
294343
  break;
293906
294344
  case "2":
293907
294345
  try {
293908
- execSync5("memorix background stop", { stdio: "pipe", timeout: 1e4, windowsHide: true });
294346
+ await doStop2();
293909
294347
  setStatusMsg({ text: "Stopped.", type: "success" });
293910
294348
  } catch (e5) {
293911
294349
  setStatusMsg({ text: `Stop failed: ${e5}`, type: "error" });
@@ -293919,7 +294357,7 @@ ${hookScript}`, "utf-8");
293919
294357
  switch (action) {
293920
294358
  case "1":
293921
294359
  try {
293922
- execSync5("memorix background start", { stdio: "pipe", timeout: 15e3, windowsHide: true });
294360
+ await doStart2(background.port ?? 3211);
293923
294361
  setStatusMsg({ text: "Started.", type: "success" });
293924
294362
  } catch (e5) {
293925
294363
  setStatusMsg({ text: `Start failed: ${e5}`, type: "error" });
@@ -293938,20 +294376,12 @@ ${hookScript}`, "utf-8");
293938
294376
  const handleDashboardAction = useCallback5(async (action) => {
293939
294377
  setStatusMsg(null);
293940
294378
  try {
293941
- const { execSync: execSync5 } = await import("child_process");
294379
+ const { doStart: doStart2 } = await Promise.resolve().then(() => (init_background(), background_exports));
293942
294380
  if (background.healthy && background.dashboard) {
293943
294381
  if (action === "1") {
293944
294382
  try {
293945
- execSync5(`start "" "${background.dashboard}"`, { stdio: "pipe", windowsHide: true });
294383
+ openLocalBrowser(background.dashboard);
293946
294384
  } catch {
293947
- try {
293948
- execSync5(`open "${background.dashboard}"`, { stdio: "pipe", windowsHide: true });
293949
- } catch {
293950
- try {
293951
- execSync5(`xdg-open "${background.dashboard}"`, { stdio: "pipe", windowsHide: true });
293952
- } catch {
293953
- }
293954
- }
293955
294385
  }
293956
294386
  setStatusMsg({ text: `Opening ${background.dashboard}`, type: "success" });
293957
294387
  } else if (action === "2") {
@@ -293960,7 +294390,7 @@ ${hookScript}`, "utf-8");
293960
294390
  } else {
293961
294391
  if (action === "1") {
293962
294392
  try {
293963
- execSync5("memorix background start", { stdio: "pipe", timeout: 15e3, windowsHide: true });
294393
+ await doStart2(background.port ?? 3211);
293964
294394
  setStatusMsg({ text: "Started.", type: "success" });
293965
294395
  setBackground(await getBackgroundStatus());
293966
294396
  } catch (e5) {
@@ -294225,6 +294655,7 @@ var init_App = __esm({
294225
294655
  init_ChatView();
294226
294656
  init_ContextRail();
294227
294657
  init_chat_service();
294658
+ init_open_browser();
294228
294659
  init_data();
294229
294660
  INPUT_BLOCKING_OVERLAYS = /* @__PURE__ */ new Set([
294230
294661
  "cleanup",