memorix 1.10.2 → 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 (66) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +3 -1
  3. package/README.zh-CN.md +3 -1
  4. package/dist/cli/index.js +397 -215
  5. package/dist/cli/memcode.js +0 -0
  6. package/dist/index.js +150 -38
  7. package/dist/maintenance-runner.js +108 -22
  8. package/dist/media-audio-runner.js +108 -22
  9. package/dist/media-video-runner.js +108 -22
  10. package/dist/memcode-runtime/CHANGELOG.md +20 -0
  11. package/dist/sdk.js +149 -37
  12. package/dist/types.d.ts +1 -1
  13. package/dist/vector-backfill-runner.js +108 -22
  14. package/docs/CONFIGURATION.md +34 -0
  15. package/docs/DEVELOPMENT.md +1 -1
  16. package/docs/INTEGRATIONS.md +1 -1
  17. package/docs/README.md +2 -1
  18. package/docs/ROADMAP-1.9.12-2.0.md +1 -1
  19. package/docs/SETUP.md +19 -4
  20. package/package.json +1 -1
  21. package/plugins/antigravity/memorix/plugin.json +1 -1
  22. package/plugins/claude/memorix/.claude-plugin/plugin.json +1 -1
  23. package/plugins/codebuddy/memorix/.codebuddy-plugin/plugin.json +1 -1
  24. package/plugins/codex/memorix/.codex-plugin/plugin.json +1 -1
  25. package/plugins/copilot/memorix/plugin.json +1 -1
  26. package/plugins/gemini/memorix/gemini-extension.json +1 -1
  27. package/plugins/hermes/memorix/plugin.yaml +1 -1
  28. package/plugins/omp/memorix/package.json +1 -1
  29. package/plugins/openclaw/memorix/.codex-plugin/plugin.json +1 -1
  30. package/plugins/pi/memorix/package.json +1 -1
  31. package/server.json +2 -2
  32. package/src/cli/commands/agent-integrations.ts +1 -1
  33. package/src/cli/commands/background.ts +1 -1
  34. package/src/cli/commands/context.ts +3 -2
  35. package/src/cli/commands/doctor.ts +9 -0
  36. package/src/cli/commands/explain.ts +3 -2
  37. package/src/cli/commands/init.ts +6 -2
  38. package/src/cli/commands/setup.ts +9 -6
  39. package/src/cli/commands/uninstall.ts +15 -0
  40. package/src/cli/tui/App.tsx +9 -16
  41. package/src/cli/tui/ConfigureView.tsx +2 -0
  42. package/src/codegraph/auto-context.ts +1 -1
  43. package/src/codegraph/store.ts +37 -0
  44. package/src/codegraph/types.ts +3 -0
  45. package/src/config/dotenv-loader.ts +1 -0
  46. package/src/config/resolved-config.ts +7 -2
  47. package/src/config/toml-loader.ts +1 -0
  48. package/src/config/yaml-loader.ts +4 -2
  49. package/src/dashboard/server.ts +5 -6
  50. package/src/hooks/handler.ts +0 -1
  51. package/src/integrations/registry.ts +2 -1
  52. package/src/llm/provider.ts +2 -1
  53. package/src/memory/observations.ts +61 -17
  54. package/src/multimodal/image-loader.ts +2 -2
  55. package/src/runtime/open-browser.ts +25 -0
  56. package/src/server.ts +2 -2
  57. package/src/store/orama-store.ts +27 -3
  58. package/src/types.ts +1 -1
  59. package/src/workspace/mcp-adapters/pi.ts +58 -0
  60. package/plugins/pi/memorix/skills/memorix-git-memory/SKILL.md +0 -26
  61. package/plugins/pi/memorix/skills/memorix-memory/SKILL.md +0 -51
  62. package/plugins/pi/memorix/skills/memorix-mini-skills/SKILL.md +0 -31
  63. package/plugins/pi/memorix/skills/memorix-orchestrate/SKILL.md +0 -28
  64. package/plugins/pi/memorix/skills/memorix-reasoning/SKILL.md +0 -30
  65. package/plugins/pi/memorix/skills/memorix-sessions/SKILL.md +0 -25
  66. 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.2" : 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
  };
@@ -181548,6 +181552,7 @@ var init_store = __esm({
181548
181552
  recordCodeStateSnapshot(input) {
181549
181553
  const id = randomUUID11();
181550
181554
  let snapshot;
181555
+ let compactNeeded = false;
181551
181556
  const tx = this.db.transaction(() => {
181552
181557
  const previous = this.db.prepare(
181553
181558
  "SELECT id, sourceEpoch FROM code_state_snapshots WHERE projectId = ? ORDER BY sourceEpoch DESC LIMIT 1"
@@ -181591,6 +181596,26 @@ var init_store = __esm({
181591
181596
  for (const file2 of snapshotFileRows) {
181592
181597
  insertSnapshotFile.run(id, file2.projectId, file2.id, file2.path, file2.contentHash);
181593
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
+ }
181594
181619
  snapshot = {
181595
181620
  ...input,
181596
181621
  id,
@@ -181599,11 +181624,24 @@ var init_store = __esm({
181599
181624
  };
181600
181625
  });
181601
181626
  tx();
181627
+ if (compactNeeded) this.compactStorage();
181602
181628
  return snapshot;
181603
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
+ }
181604
181641
  status(projectId) {
181605
181642
  const files = this.db.prepare(`SELECT COUNT(*) AS count FROM code_files WHERE projectId = ?`).get(projectId).count;
181606
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;
181607
181645
  const edges = this.db.prepare(`SELECT COUNT(*) AS count FROM code_edges WHERE projectId = ?`).get(projectId).count;
181608
181646
  const refs = this.db.prepare(`SELECT COUNT(*) AS count FROM observation_code_refs WHERE projectId = ?`).get(projectId).count;
181609
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;
@@ -181611,6 +181649,8 @@ var init_store = __esm({
181611
181649
  const parserErrors = this.db.prepare(`SELECT COUNT(*) AS count FROM code_files WHERE projectId = ? AND parserError IS NOT NULL`).get(projectId).count;
181612
181650
  const latest = this.db.prepare(`SELECT MAX(indexedAt) AS indexedAt FROM code_files WHERE projectId = ?`).get(projectId);
181613
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;
181614
181654
  return {
181615
181655
  provider: "lite",
181616
181656
  files,
@@ -181620,6 +181660,9 @@ var init_store = __esm({
181620
181660
  semanticSymbols,
181621
181661
  semanticEdges,
181622
181662
  parserErrors,
181663
+ staleSymbols,
181664
+ snapshots,
181665
+ snapshotFiles,
181623
181666
  ...latest?.indexedAt ? { indexedAt: latest.indexedAt } : {},
181624
181667
  ...latestSnapshot ? { latestSnapshot } : {}
181625
181668
  };
@@ -186322,10 +186365,22 @@ function resetObservationRuntime() {
186322
186365
  loadedObservationStore = null;
186323
186366
  embeddingWriteMode = "background";
186324
186367
  embeddingWorkerProjectRoot = void 0;
186325
- vectorMissingIds.clear();
186368
+ clearVectorMissingIds();
186326
186369
  vectorSchemaUpgradePromise = null;
186327
186370
  embeddingFailureLogTimestamps.clear();
186328
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
+ }
186329
186384
  function logEmbeddingFailureOnce(key, message) {
186330
186385
  const now3 = Date.now();
186331
186386
  const last = embeddingFailureLogTimestamps.get(key) ?? 0;
@@ -186445,10 +186500,13 @@ function isVectorCompatibleWithCurrentIndex(embedding) {
186445
186500
  }
186446
186501
  async function upgradeVectorSchemaAfterFirstEmbedding(embedding) {
186447
186502
  if (isVectorCompatibleWithCurrentIndex(embedding)) return true;
186448
- if (getVectorDimensions() !== null || !embedding.every(Number.isFinite)) return false;
186503
+ if (!embedding.every(Number.isFinite)) return false;
186449
186504
  const targetProjectDir = projectDir;
186450
186505
  if (!vectorSchemaUpgradePromise) {
186451
- 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(() => {
186452
186510
  vectorSchemaUpgradePromise = null;
186453
186511
  });
186454
186512
  }
@@ -186488,9 +186546,9 @@ async function initObservations(dir, options = {}) {
186488
186546
  }
186489
186547
  function scheduleObservationEmbedding(input) {
186490
186548
  const { observationId: observationId2, projectId, searchableText, doc } = input;
186491
- vectorMissingIds.add(observationId2);
186549
+ markVectorMissing(observationId2, projectId);
186492
186550
  if (isEmbeddingExplicitlyDisabled()) {
186493
- vectorMissingIds.delete(observationId2);
186551
+ clearVectorMissing(observationId2);
186494
186552
  return;
186495
186553
  }
186496
186554
  if (embeddingWriteMode === "deferred") {
@@ -186525,13 +186583,13 @@ function scheduleObservationEmbedding(input) {
186525
186583
  vector: embedding
186526
186584
  });
186527
186585
  }
186528
- vectorMissingIds.delete(observationId2);
186586
+ clearVectorMissing(observationId2);
186529
186587
  } catch {
186530
186588
  console.error(`[memorix] Embedding index update failed for obs-${observationId2} (kept in backfill queue)`);
186531
186589
  queueVectorBackfill(projectId);
186532
186590
  }
186533
186591
  } else if (isEmbeddingExplicitlyDisabled()) {
186534
- vectorMissingIds.delete(observationId2);
186592
+ clearVectorMissing(observationId2);
186535
186593
  } else {
186536
186594
  queueVectorBackfill(projectId);
186537
186595
  logEmbeddingFailureOnce(
@@ -187091,7 +187149,7 @@ async function reindexObservations() {
187091
187149
  if (observations.length === 0) return 0;
187092
187150
  await resetDb();
187093
187151
  searchIndexPrepared = false;
187094
- vectorMissingIds.clear();
187152
+ clearVectorMissingIds();
187095
187153
  let embeddings = observations.map(() => null);
187096
187154
  const provider2 = await getEmbeddingProvider();
187097
187155
  const canBatchEmbedAtStartup = provider2 !== null && !provider2.name.startsWith("api-");
@@ -187156,7 +187214,7 @@ async function reindexObservations() {
187156
187214
  };
187157
187215
  await insertObservation(doc);
187158
187216
  if (!compatibleEmbedding && !isEmbeddingExplicitlyDisabled()) {
187159
- vectorMissingIds.add(obs.id);
187217
+ markVectorMissing(obs.id, obs.projectId);
187160
187218
  }
187161
187219
  count3++;
187162
187220
  } catch (err) {
@@ -187173,7 +187231,17 @@ async function prepareSearchIndex(options = {}) {
187173
187231
  if (!isEmbeddingExplicitlyDisabled()) {
187174
187232
  const store2 = getObservationStore();
187175
187233
  const projects = await store2.listProjectIds?.() ?? [];
187176
- 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
+ }
187177
187245
  }
187178
187246
  return 0;
187179
187247
  }
@@ -187187,13 +187255,13 @@ async function prepareSearchIndex(options = {}) {
187187
187255
  const hydratedProjectDir = projectDir;
187188
187256
  const queueMissingVectors = async () => {
187189
187257
  if (!hydratedProjectDir || projectDir !== hydratedProjectDir) return;
187190
- vectorMissingIds.clear();
187258
+ clearVectorMissingIds();
187191
187259
  if (!isEmbeddingExplicitlyDisabled()) {
187192
187260
  const persistedSemanticIds = await getPersistentSemanticVectorIds(hydratedProjectDir).catch(() => null);
187193
187261
  const projectsWithMissingVectors = /* @__PURE__ */ new Set();
187194
187262
  for (const obs of observations) {
187195
187263
  if (!hasObservationVector(obs.projectId, obs.id) && !persistedSemanticIds?.has(obs.id)) {
187196
- vectorMissingIds.add(obs.id);
187264
+ markVectorMissing(obs.id, obs.projectId);
187197
187265
  projectsWithMissingVectors.add(obs.projectId);
187198
187266
  }
187199
187267
  }
@@ -187211,6 +187279,9 @@ async function prepareSearchIndex(options = {}) {
187211
187279
  }
187212
187280
  function getVectorMissingIds(projectId) {
187213
187281
  if (!projectId) return [...vectorMissingIds];
187282
+ if (!corpusLoaded) {
187283
+ return [...vectorMissingIds].filter((id) => vectorMissingProjectIds.get(id) === projectId);
187284
+ }
187214
187285
  const observationById = new Map(observations.map((observation) => [observation.id, observation]));
187215
187286
  return [...vectorMissingIds].filter((id) => observationById.get(id)?.projectId === projectId);
187216
187287
  }
@@ -187248,7 +187319,8 @@ async function backfillVectorEmbeddings(options = {}) {
187248
187319
  return { attempted: 0, succeeded: 0, failed: 0 };
187249
187320
  }
187250
187321
  vectorBackfillRunning = true;
187251
- 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]));
187252
187324
  const limit2 = Number.isFinite(options.limit) ? Math.max(1, Math.floor(options.limit)) : Number.POSITIVE_INFINITY;
187253
187325
  const ids = [...vectorMissingIds].filter((id) => !options.projectId || observationById.get(id)?.projectId === options.projectId).slice(0, limit2);
187254
187326
  let succeeded = 0;
@@ -187261,7 +187333,7 @@ async function backfillVectorEmbeddings(options = {}) {
187261
187333
  for (const id of ids) {
187262
187334
  const observation = observationById.get(id);
187263
187335
  if (!observation) {
187264
- vectorMissingIds.delete(id);
187336
+ clearVectorMissing(id);
187265
187337
  continue;
187266
187338
  }
187267
187339
  candidates.push({
@@ -187279,7 +187351,7 @@ async function backfillVectorEmbeddings(options = {}) {
187279
187351
  const provider2 = await getEmbeddingProvider();
187280
187352
  if (!provider2) {
187281
187353
  if (isEmbeddingExplicitlyDisabled()) {
187282
- for (const candidate2 of candidates) vectorMissingIds.delete(candidate2.id);
187354
+ for (const candidate2 of candidates) clearVectorMissing(candidate2.id);
187283
187355
  } else {
187284
187356
  recordFailure("embedding provider unavailable");
187285
187357
  failed += candidates.length;
@@ -187356,7 +187428,7 @@ async function backfillVectorEmbeddings(options = {}) {
187356
187428
  vector: embedding
187357
187429
  });
187358
187430
  }
187359
- vectorMissingIds.delete(id);
187431
+ clearVectorMissing(id);
187360
187432
  succeeded++;
187361
187433
  } catch (error40) {
187362
187434
  recordFailure(vectorBackfillError(error40));
@@ -187381,7 +187453,7 @@ async function backfillVectorEmbeddings(options = {}) {
187381
187453
  ...lastFailure ? { lastError: lastFailure } : {}
187382
187454
  };
187383
187455
  }
187384
- 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;
187385
187457
  var init_observations = __esm({
187386
187458
  "src/memory/observations.ts"() {
187387
187459
  "use strict";
@@ -187406,6 +187478,7 @@ var init_observations = __esm({
187406
187478
  loadedObservationStore = null;
187407
187479
  DEFAULT_ORAMA_HYDRATION_THRESHOLD = 1e4;
187408
187480
  vectorMissingIds = /* @__PURE__ */ new Set();
187481
+ vectorMissingProjectIds = /* @__PURE__ */ new Map();
187409
187482
  vectorBackfillRunning = false;
187410
187483
  vectorSchemaUpgradePromise = null;
187411
187484
  lastVectorBackfill = null;
@@ -188036,9 +188109,17 @@ __export(orama_store_exports, {
188036
188109
  queueSemanticVector: () => queueSemanticVector,
188037
188110
  removeObservation: () => removeObservation,
188038
188111
  resetDb: () => resetDb,
188112
+ resolveSearchFuzzyTolerance: () => resolveSearchFuzzyTolerance,
188039
188113
  searchObservations: () => searchObservations,
188040
188114
  updateObservationMetadata: () => updateObservationMetadata
188041
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
+ }
188042
188123
  function rememberSearchMode(key, value) {
188043
188124
  if (!lastSearchModeByProject.has(key) && lastSearchModeByProject.size >= MAX_SEARCH_MODE_KEYS) {
188044
188125
  const oldest = lastSearchModeByProject.keys().next().value;
@@ -188684,7 +188765,10 @@ async function searchObservations(options) {
188684
188765
  // Fuzzy tolerance: allow 1-char typos for short queries, 2 for longer
188685
188766
  // Fuzzy matching is useful for ordinary recall, but grows sharply with
188686
188767
  // corpus size. The fast profile deliberately uses exact lexical matching.
188687
- ...hasQuery && quality !== "fast" ? { tolerance: originalQuery.length > 6 ? 2 : 1 } : {}
188768
+ ...hasQuery ? (() => {
188769
+ const tolerance = resolveSearchFuzzyTolerance(originalQuery, quality);
188770
+ return tolerance === void 0 ? {} : { tolerance };
188771
+ })() : {}
188688
188772
  };
188689
188773
  let queryVector = null;
188690
188774
  let embeddingProviderForSearch = null;
@@ -188915,14 +188999,16 @@ async function searchObservations(options) {
188915
188999
  filesModified: doc.filesModified?.split?.("\n") ?? (Array.isArray(doc.filesModified) ? doc.filesModified : [])
188916
189000
  });
188917
189001
  }
189002
+ const topScore = Math.max(...intermediate.map((entry) => entry.score));
189003
+ const affinityTieWindow = topScore * 0.92;
188918
189004
  intermediate = intermediate.map((entry) => {
188919
189005
  const memory = memoryContentMap.get(entry.id);
188920
189006
  if (!memory) return entry;
188921
189007
  const { score: affinityScore } = calculateProjectAffinity(memory, affinityContext);
189008
+ if (entry.score < affinityTieWindow) return entry;
188922
189009
  return {
188923
189010
  ...entry,
188924
- score: entry.score * affinityScore
188925
- // Apply affinity as multiplier
189011
+ score: entry.score * (0.98 + affinityScore * 0.02)
188926
189012
  };
188927
189013
  });
188928
189014
  intermediate.sort((a4, b4) => b4.score - a4.score);
@@ -193612,6 +193698,8 @@ function buildInitTomlConfig(options) {
193612
193698
  lines.push('model = "deepseek-v4.1-flash"');
193613
193699
  } else if (options.llmProvider === "cheaperinference") {
193614
193700
  lines.push('model = "gpt-5.4-mini"');
193701
+ } else if (options.llmProvider === "runcrate") {
193702
+ lines.push('model = "deepseek-ai/DeepSeek-V4.1-Flash"');
193615
193703
  } else if (options.llmProvider === "atlascloud") {
193616
193704
  lines.push('model = "deepseek-ai/deepseek-v3.2"');
193617
193705
  }
@@ -193749,6 +193837,7 @@ var init_init = __esm({
193749
193837
  { value: "requesty", label: "Requesty", hint: "multi-provider" },
193750
193838
  { value: "apiroute", label: "API Route", hint: "multi-provider" },
193751
193839
  { value: "cheaperinference", label: "Cheaper Inference", hint: "multi-provider" },
193840
+ { value: "runcrate", label: "Runcrate", hint: "open-weight models" },
193752
193841
  { value: "atlascloud", label: "Atlas Cloud", hint: "DeepSeek V3.2" },
193753
193842
  { value: "custom", label: "Custom", hint: "OpenAI-compatible endpoint" }
193754
193843
  ]
@@ -193803,7 +193892,7 @@ var init_init = __esm({
193803
193892
  ];
193804
193893
  if (llmProvider !== "none") {
193805
193894
  envLines.push("# LLM API key");
193806
- 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") {
193807
193896
  envLines.push("MEMORIX_LLM_API_KEY=sk-your-key-here");
193808
193897
  } else if (llmProvider === "anthropic") {
193809
193898
  envLines.push("MEMORIX_LLM_API_KEY=sk-ant-your-key-here");
@@ -193840,6 +193929,7 @@ var init_init = __esm({
193840
193929
  envLines.push("# REQUESTY_API_KEY=rqsty-...");
193841
193930
  envLines.push("# API_ROUTE_API_KEY=sk-...");
193842
193931
  envLines.push("# CHEAPER_INFERENCE_API_KEY=ci_live_...");
193932
+ envLines.push("# RUNCRATE_API_KEY=...");
193843
193933
  envLines.push("");
193844
193934
  mkdirSync3(targetDir, { recursive: true });
193845
193935
  writeFileSync3(targetPath, tomlContent, "utf-8");
@@ -194665,9 +194755,60 @@ var init_omp = __esm({
194665
194755
  }
194666
194756
  });
194667
194757
 
194668
- // src/workspace/mcp-adapters/kiro.ts
194758
+ // src/workspace/mcp-adapters/pi.ts
194669
194759
  import { homedir as homedir19 } from "os";
194670
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";
194671
194812
  var KiroMCPAdapter;
194672
194813
  var init_kiro = __esm({
194673
194814
  "src/workspace/mcp-adapters/kiro.ts"() {
@@ -194712,17 +194853,17 @@ var init_kiro = __esm({
194712
194853
  }
194713
194854
  getConfigPath(projectRoot) {
194714
194855
  if (projectRoot) {
194715
- return join16(projectRoot, ".kiro", "settings", "mcp.json");
194856
+ return join17(projectRoot, ".kiro", "settings", "mcp.json");
194716
194857
  }
194717
- return join16(homedir19(), ".kiro", "settings", "mcp.json");
194858
+ return join17(homedir20(), ".kiro", "settings", "mcp.json");
194718
194859
  }
194719
194860
  };
194720
194861
  }
194721
194862
  });
194722
194863
 
194723
194864
  // src/workspace/mcp-adapters/opencode.ts
194724
- import { homedir as homedir20 } from "os";
194725
- import { join as join17 } from "path";
194865
+ import { homedir as homedir21 } from "os";
194866
+ import { join as join18 } from "path";
194726
194867
  var OpenCodeMCPAdapter;
194727
194868
  var init_opencode = __esm({
194728
194869
  "src/workspace/mcp-adapters/opencode.ts"() {
@@ -194792,17 +194933,17 @@ var init_opencode = __esm({
194792
194933
  }
194793
194934
  getConfigPath(projectRoot) {
194794
194935
  if (projectRoot) {
194795
- return join17(projectRoot, "opencode.json");
194936
+ return join18(projectRoot, "opencode.json");
194796
194937
  }
194797
- return join17(homedir20(), ".config", "opencode", "opencode.json");
194938
+ return join18(homedir21(), ".config", "opencode", "opencode.json");
194798
194939
  }
194799
194940
  };
194800
194941
  }
194801
194942
  });
194802
194943
 
194803
194944
  // src/workspace/mcp-adapters/trae.ts
194804
- import { join as join18 } from "path";
194805
- import { homedir as homedir21 } from "os";
194945
+ import { join as join19 } from "path";
194946
+ import { homedir as homedir22 } from "os";
194806
194947
  var TraeMCPAdapter;
194807
194948
  var init_trae = __esm({
194808
194949
  "src/workspace/mcp-adapters/trae.ts"() {
@@ -194871,26 +195012,26 @@ var init_trae = __esm({
194871
195012
  return JSON.stringify({ mcpServers }, null, 2);
194872
195013
  }
194873
195014
  getConfigPath(_projectRoot) {
194874
- const home = homedir21();
195015
+ const home = homedir22();
194875
195016
  if (process.platform === "win32") {
194876
- 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");
194877
195018
  }
194878
195019
  if (process.platform === "darwin") {
194879
- return join18(home, "Library", "Application Support", "Trae", "User", "mcp.json");
195020
+ return join19(home, "Library", "Application Support", "Trae", "User", "mcp.json");
194880
195021
  }
194881
- return join18(home, ".config", "Trae", "User", "mcp.json");
195022
+ return join19(home, ".config", "Trae", "User", "mcp.json");
194882
195023
  }
194883
195024
  };
194884
195025
  }
194885
195026
  });
194886
195027
 
194887
195028
  // src/workspace/mcp-adapters/dsh.ts
194888
- import { homedir as homedir22 } from "os";
194889
- import { join as join19 } from "path";
195029
+ import { homedir as homedir23 } from "os";
195030
+ import { join as join20 } from "path";
194890
195031
  function resolveDshHome() {
194891
195032
  const configured = process.env.DSH_HOME?.trim();
194892
195033
  if (configured) return configured;
194893
- return join19(homedir22(), ".dsh");
195034
+ return join20(homedir23(), ".dsh");
194894
195035
  }
194895
195036
  function isMemorixRow(row) {
194896
195037
  if (!row || typeof row !== "object" || Array.isArray(row)) return false;
@@ -194985,15 +195126,15 @@ var init_dsh = __esm({
194985
195126
  return (0, import_yaml4.stringify)([{ insert: rows }], { lineWidth: 0 }) + "\n";
194986
195127
  }
194987
195128
  getConfigPath(_projectRoot) {
194988
- return join19(resolveDshHome(), "cordis.patch.yml");
195129
+ return join20(resolveDshHome(), "cordis.patch.yml");
194989
195130
  }
194990
195131
  };
194991
195132
  }
194992
195133
  });
194993
195134
 
194994
195135
  // src/workspace/mcp-adapters/workbuddy.ts
194995
- import { homedir as homedir23 } from "os";
194996
- import { join as join20 } from "path";
195136
+ import { homedir as homedir24 } from "os";
195137
+ import { join as join21 } from "path";
194997
195138
  var WorkbuddyMCPAdapter;
194998
195139
  var init_workbuddy = __esm({
194999
195140
  "src/workspace/mcp-adapters/workbuddy.ts"() {
@@ -195043,17 +195184,17 @@ var init_workbuddy = __esm({
195043
195184
  }
195044
195185
  getConfigPath(projectRoot) {
195045
195186
  if (projectRoot) {
195046
- return join20(projectRoot, ".workbuddy", "mcp.json");
195187
+ return join21(projectRoot, ".workbuddy", "mcp.json");
195047
195188
  }
195048
- return join20(homedir23(), ".workbuddy", "mcp.json");
195189
+ return join21(homedir24(), ".workbuddy", "mcp.json");
195049
195190
  }
195050
195191
  };
195051
195192
  }
195052
195193
  });
195053
195194
 
195054
195195
  // src/workspace/mcp-adapters/codebuddy.ts
195055
- import { homedir as homedir24 } from "os";
195056
- import { join as join21 } from "path";
195196
+ import { homedir as homedir25 } from "os";
195197
+ import { join as join22 } from "path";
195057
195198
  var CodeBuddyMCPAdapter;
195058
195199
  var init_codebuddy = __esm({
195059
195200
  "src/workspace/mcp-adapters/codebuddy.ts"() {
@@ -195085,15 +195226,15 @@ var init_codebuddy = __esm({
195085
195226
  return JSON.stringify({ mcpServers }, null, 2);
195086
195227
  }
195087
195228
  getConfigPath(projectRoot) {
195088
- return projectRoot ? join21(projectRoot, ".mcp.json") : join21(homedir24(), ".codebuddy", ".mcp.json");
195229
+ return projectRoot ? join22(projectRoot, ".mcp.json") : join22(homedir25(), ".codebuddy", ".mcp.json");
195089
195230
  }
195090
195231
  };
195091
195232
  }
195092
195233
  });
195093
195234
 
195094
195235
  // src/workspace/mcp-adapters/grok.ts
195095
- import { homedir as homedir25 } from "os";
195096
- import { join as join22 } from "path";
195236
+ import { homedir as homedir26 } from "os";
195237
+ import { join as join23 } from "path";
195097
195238
  var GrokMCPAdapter;
195098
195239
  var init_grok = __esm({
195099
195240
  "src/workspace/mcp-adapters/grok.ts"() {
@@ -195110,8 +195251,8 @@ var init_grok = __esm({
195110
195251
  return this.toml.generate(servers);
195111
195252
  }
195112
195253
  getConfigPath(_projectRoot) {
195113
- const grokHome = process.env.GROK_HOME?.trim() || join22(homedir25(), ".grok");
195114
- return join22(grokHome, "config.toml");
195254
+ const grokHome = process.env.GROK_HOME?.trim() || join23(homedir26(), ".grok");
195255
+ return join23(grokHome, "config.toml");
195115
195256
  }
195116
195257
  };
195117
195258
  }
@@ -195370,7 +195511,8 @@ var init_registry2 = __esm({
195370
195511
  entry: "official-package",
195371
195512
  status: "ready",
195372
195513
  install: "memorix setup --agent pi",
195373
- 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."
195374
195516
  },
195375
195517
  {
195376
195518
  agent: "any-mcp",
@@ -195670,9 +195812,9 @@ __export(audit_exports, {
195670
195812
  });
195671
195813
  import * as fs18 from "fs/promises";
195672
195814
  import * as path30 from "path";
195673
- import { homedir as homedir26 } from "os";
195815
+ import { homedir as homedir27 } from "os";
195674
195816
  function getAuditFilePath() {
195675
- 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");
195676
195818
  }
195677
195819
  async function loadAudit() {
195678
195820
  try {
@@ -197469,7 +197611,7 @@ __export(setup_exports, {
197469
197611
  import { spawnSync } from "child_process";
197470
197612
  import { existsSync as existsSync18 } from "fs";
197471
197613
  import { copyFile as copyFile2, mkdir as mkdir6, readFile as readFile6, readdir as readdir3, rm as rm2, writeFile as writeFile7 } from "fs/promises";
197472
- import { homedir as homedir28 } from "os";
197614
+ import { homedir as homedir29 } from "os";
197473
197615
  import path32 from "path";
197474
197616
  import { fileURLToPath as fileURLToPath7 } from "url";
197475
197617
  function getSetupAgentTargets2() {
@@ -197628,6 +197770,7 @@ function getMcpAdapter(agent) {
197628
197770
  openclaw: new OpenClawMCPAdapter(),
197629
197771
  hermes: new HermesMCPAdapter(),
197630
197772
  omp: new OmpMCPAdapter(),
197773
+ pi: new PiMCPAdapter(),
197631
197774
  kiro: new KiroMCPAdapter(),
197632
197775
  opencode: new OpenCodeMCPAdapter(),
197633
197776
  trae: new TraeMCPAdapter(),
@@ -197785,7 +197928,7 @@ function isOwnedLegacyCodexMcp(content) {
197785
197928
  const server = new CodexMCPAdapter().parse(content).find((entry) => entry.name === "memorix");
197786
197929
  return Boolean(server && isLegacyCodexMemorixNodeServer(server));
197787
197930
  }
197788
- async function removeLegacyCodexMemorixMcpConfig(configPath = path32.join(homedir28(), ".codex", "config.toml")) {
197931
+ async function removeLegacyCodexMemorixMcpConfig(configPath = path32.join(homedir29(), ".codex", "config.toml")) {
197789
197932
  let existingContent;
197790
197933
  try {
197791
197934
  existingContent = await readFile6(configPath, "utf-8");
@@ -197842,7 +197985,7 @@ async function removeOwnedLegacyCodexPluginFolder(homeDir) {
197842
197985
  }
197843
197986
  }
197844
197987
  async function migrateLegacyCodexIntegration(options = {}) {
197845
- const homeDir = options.homeDir ?? homedir28();
197988
+ const homeDir = options.homeDir ?? homedir29();
197846
197989
  const projectRoot = options.projectRoot ?? process.cwd();
197847
197990
  const configPath = path32.join(homeDir, ".codex", "config.toml");
197848
197991
  let mcp = "missing";
@@ -198043,7 +198186,7 @@ async function stripCodeBuddyHookCapture(pluginPath) {
198043
198186
  await writeFile7(manifestPath, JSON.stringify(manifest, null, 2) + "\n", "utf-8");
198044
198187
  }
198045
198188
  async function installCodeBuddyPluginPackage(options = {}) {
198046
- const home = options.homeDir ?? homedir28();
198189
+ const home = options.homeDir ?? homedir29();
198047
198190
  const packageRoot2 = findPackageRoot();
198048
198191
  const source = path32.join(packageRoot2, "plugins", "codebuddy", "memorix");
198049
198192
  if (!existsSync18(source)) throw new Error(`CodeBuddy plugin template not found: ${source}`);
@@ -198063,7 +198206,7 @@ async function installCodeBuddyPluginPackage(options = {}) {
198063
198206
  };
198064
198207
  }
198065
198208
  async function installPluginPackage(options) {
198066
- const home = options.homeDir ?? homedir28();
198209
+ const home = options.homeDir ?? homedir29();
198067
198210
  const packageRoot2 = findPackageRoot();
198068
198211
  const source = path32.join(packageRoot2, "plugins", options.agent, "memorix");
198069
198212
  const includeHooks = options.includeHooks ?? true;
@@ -198112,7 +198255,7 @@ async function installPluginPackage(options) {
198112
198255
  };
198113
198256
  }
198114
198257
  async function installGeminiExtensionPackage(options = {}) {
198115
- const home = options.homeDir ?? homedir28();
198258
+ const home = options.homeDir ?? homedir29();
198116
198259
  const packageRoot2 = findPackageRoot();
198117
198260
  const source = path32.join(packageRoot2, "plugins", "gemini", "memorix");
198118
198261
  if (!existsSync18(source)) {
@@ -198132,7 +198275,7 @@ async function installAntigravityPluginPackage(options = {}) {
198132
198275
  if (!existsSync18(source)) {
198133
198276
  throw new Error(`Antigravity plugin template not found: ${source}`);
198134
198277
  }
198135
- 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");
198136
198279
  await copyDir(source, pluginPath);
198137
198280
  if (options.includeHooks === false) {
198138
198281
  await rm2(path32.join(pluginPath, "hooks.json"), { force: true });
@@ -198150,7 +198293,7 @@ async function installPiPackage(options = {}) {
198150
198293
  if (!existsSync18(source)) {
198151
198294
  throw new Error(`Pi package template not found: ${source}`);
198152
198295
  }
198153
- 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");
198154
198297
  const packagePath = options.packageDir ?? path32.join(defaultRoot, "memorix");
198155
198298
  await copyDir(source, packagePath);
198156
198299
  await writeOfficialSkills(path32.join(packagePath, "skills"));
@@ -198162,7 +198305,7 @@ async function installPiPackage(options = {}) {
198162
198305
  };
198163
198306
  }
198164
198307
  async function installOpenClawBundlePackage(options = {}) {
198165
- const home = options.homeDir ?? homedir28();
198308
+ const home = options.homeDir ?? homedir29();
198166
198309
  const packageRoot2 = findPackageRoot();
198167
198310
  const source = path32.join(packageRoot2, "plugins", "openclaw", "memorix");
198168
198311
  if (!existsSync18(source)) {
@@ -198211,7 +198354,7 @@ async function installOmpPackage(options = {}) {
198211
198354
  if (!existsSync18(source)) {
198212
198355
  throw new Error(`Oh-my-Pi package template not found: ${source}`);
198213
198356
  }
198214
- 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");
198215
198358
  const packagePath = options.packageDir ?? path32.join(defaultRoot, "memorix");
198216
198359
  await copyDir(source, packagePath);
198217
198360
  await writeOfficialSkills(path32.join(packagePath, "skills"));
@@ -198485,7 +198628,7 @@ ${result.stdout || ""}`.toLowerCase();
198485
198628
  }
198486
198629
  async function installAgentSetup(agent, plan, global2) {
198487
198630
  const { installAgentGuidance: installAgentGuidance2, installHooks: installHooks2 } = await Promise.resolve().then(() => (init_installers(), installers_exports));
198488
- const targetRoot = global2 ? homedir28() : process.cwd();
198631
+ const targetRoot = global2 ? homedir29() : process.cwd();
198489
198632
  const hasPluginPackage = plan.actions.includes("plugin-package") && PLUGIN_PACKAGE_AGENTS.has(agent);
198490
198633
  const hasExtensionPackage = plan.actions.includes("extension-package") && agent === "gemini-cli";
198491
198634
  const hasPiPackage = plan.actions.includes("pi-package") && agent === "pi";
@@ -198494,7 +198637,7 @@ async function installAgentSetup(agent, plan, global2) {
198494
198637
  const hasHermesPlugin = plan.actions.includes("hermes-plugin") && agent === "hermes";
198495
198638
  const hasOmpPackage = plan.actions.includes("omp-package") && agent === "omp";
198496
198639
  const hasCodeBuddyPlugin = plan.actions.includes("codebuddy-plugin") && agent === "codebuddy";
198497
- 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");
198498
198641
  const bundledMcpRoots = [];
198499
198642
  if (PLUGIN_PACKAGE_AGENTS.has(agent) && plan.includePlugin && !global2) {
198500
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.`);
@@ -198665,9 +198808,10 @@ async function installAgentSetup(agent, plan, global2) {
198665
198808
  if (hasCodeBuddyPlugin) {
198666
198809
  v3.info(`${agent}: MCP, skills, and hooks are bundled in the official CodeBuddy plugin package`);
198667
198810
  }
198668
- if (agent === "pi") {
198669
- v3.info("pi: Pi has no MCP config lane in the current CLI; use the installed package extension and skill.");
198670
- } 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") {
198671
198815
  if (plan.mcp === "http") {
198672
198816
  v3.info("grok: wrote [mcp_servers.memorix] HTTP URL in Grok config.toml. Start the control plane with `memorix background start`.");
198673
198817
  } else {
@@ -198717,6 +198861,7 @@ var init_setup = __esm({
198717
198861
  init_openclaw();
198718
198862
  init_hermes();
198719
198863
  init_omp();
198864
+ init_pi();
198720
198865
  init_kiro();
198721
198866
  init_opencode();
198722
198867
  init_trae();
@@ -198819,7 +198964,7 @@ var init_setup = __esm({
198819
198964
  { value: "openclaw", label: "OpenClaw", hint: "bundle + hook pack + skills + MCP" },
198820
198965
  { value: "hermes", label: "Hermes Agent", hint: "plugin + hooks + commands + skills + MCP" },
198821
198966
  { value: "omp", label: "Oh-my-Pi", hint: "package + extension + command + MCP" },
198822
- { 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+)" },
198823
198968
  { value: "dsh", label: "DeepSeek Harness", hint: "MCP patch + AGENTS.md + skills" },
198824
198969
  { value: "opencode", label: "OpenCode", hint: "local plugin + AGENTS.md + MCP" },
198825
198970
  { value: "windsurf", label: "Windsurf", hint: "rules + hooks + MCP" },
@@ -198880,7 +199025,7 @@ var config_path_exports = {};
198880
199025
  __export(config_path_exports, {
198881
199026
  default: () => config_path_default
198882
199027
  });
198883
- import { homedir as homedir29 } from "os";
199028
+ import { homedir as homedir30 } from "os";
198884
199029
  var config_path_default;
198885
199030
  var init_config_path = __esm({
198886
199031
  "src/cli/commands/config-path.ts"() {
@@ -198898,7 +199043,7 @@ var init_config_path = __esm({
198898
199043
  run: async () => {
198899
199044
  const project = detectProject(process.cwd());
198900
199045
  ye2([
198901
- `Global: ${getGlobalConfigTomlPath(homedir29())}`,
199046
+ `Global: ${getGlobalConfigTomlPath(homedir30())}`,
198902
199047
  `Project: ${project ? getProjectConfigTomlPath(project.rootPath) : "not inside a git project"}`
198903
199048
  ].join("\n"), "Memorix config");
198904
199049
  }
@@ -198974,7 +199119,7 @@ __export(config_migrate_exports, {
198974
199119
  serializeResolvedConfigToToml: () => serializeResolvedConfigToToml
198975
199120
  });
198976
199121
  import { mkdirSync as mkdirSync4, writeFileSync as writeFileSync4 } from "fs";
198977
- import { homedir as homedir30 } from "os";
199122
+ import { homedir as homedir31 } from "os";
198978
199123
  import { dirname as dirname4 } from "path";
198979
199124
  function serializeResolvedConfigToToml(config2, options = {}) {
198980
199125
  const includeSecrets = options.includeSecrets === true;
@@ -199073,7 +199218,7 @@ var init_config_migrate = __esm({
199073
199218
  v3.error("Not inside a git project. Use `memorix config migrate --global` for global config.");
199074
199219
  return;
199075
199220
  }
199076
- const target = isGlobal ? getGlobalConfigTomlPath(homedir30()) : getProjectConfigTomlPath(project.rootPath);
199221
+ const target = isGlobal ? getGlobalConfigTomlPath(homedir31()) : getProjectConfigTomlPath(project.rootPath);
199077
199222
  const resolved = getResolvedConfig({ projectRoot: project?.rootPath ?? null });
199078
199223
  const content = serializeResolvedConfigToToml(resolved, { includeSecrets: isGlobal });
199079
199224
  mkdirSync4(dirname4(target), { recursive: true });
@@ -199085,8 +199230,8 @@ var init_config_migrate = __esm({
199085
199230
  });
199086
199231
 
199087
199232
  // src/cli/commands/integrate-shared.ts
199088
- import { homedir as homedir31 } from "os";
199089
- function getIntegrationTargetRoot(useGlobalDefaults, cwd, homeDir = homedir31()) {
199233
+ import { homedir as homedir32 } from "os";
199234
+ function getIntegrationTargetRoot(useGlobalDefaults, cwd, homeDir = homedir32()) {
199090
199235
  return useGlobalDefaults ? homeDir : cwd;
199091
199236
  }
199092
199237
  function getIntegrationScopeLabel(useGlobalDefaults) {
@@ -200453,7 +200598,7 @@ __export(external_provider_exports, {
200453
200598
  });
200454
200599
  import { spawn as spawn5 } from "child_process";
200455
200600
  import { existsSync as existsSync20, readFileSync as readFileSync12 } from "fs";
200456
- import { delimiter, dirname as dirname5, extname, isAbsolute as isAbsolute4, join as join25, relative as relative4, resolve as resolve6, sep as sep2 } from "path";
200601
+ import { delimiter, dirname as dirname5, extname, isAbsolute as isAbsolute4, join as join26, relative as relative4, resolve as resolve6, sep as sep2 } from "path";
200457
200602
  function boundedTimeout(value) {
200458
200603
  if (!Number.isFinite(value)) return DEFAULT_EXTERNAL_CODEGRAPH_TIMEOUT_MS;
200459
200604
  return Math.max(100, Math.min(Math.floor(value), MAX_EXTERNAL_CODEGRAPH_TIMEOUT_MS));
@@ -200482,10 +200627,10 @@ function resolveCommandCandidates(command) {
200482
200627
  }
200483
200628
  const names = extname(requested) ? [requested] : process.platform === "win32" ? [requested + ".exe", requested + ".cmd", requested + ".js", requested] : [requested];
200484
200629
  const directories = [
200485
- ...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")] : [],
200486
200631
  ...(process.env.PATH ?? "").split(delimiter).filter(Boolean)
200487
200632
  ];
200488
- 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))))];
200489
200634
  }
200490
200635
  function resolveLaunch(command) {
200491
200636
  for (const candidate2 of resolveCommandCandidates(command)) {
@@ -200493,8 +200638,8 @@ function resolveLaunch(command) {
200493
200638
  const extension3 = extname(candidate2).toLowerCase();
200494
200639
  if (extension3 === ".cmd") {
200495
200640
  const bundleRoot = resolve6(dirname5(candidate2), "..");
200496
- const node = join25(bundleRoot, "node.exe");
200497
- const entry = join25(bundleRoot, "lib", "dist", "bin", "codegraph.js");
200641
+ const node = join26(bundleRoot, "node.exe");
200642
+ const entry = join26(bundleRoot, "lib", "dist", "bin", "codegraph.js");
200498
200643
  if (existsSync20(node) && existsSync20(entry)) {
200499
200644
  return { executable: node, prefixArgs: ["--liftoff-only", entry] };
200500
200645
  }
@@ -200652,7 +200797,7 @@ async function inspectExternalCodeGraph(input) {
200652
200797
  const health2 = { state: "disabled", reason: "External CodeGraph is disabled by configuration." };
200653
200798
  return { health: health2, quality: providerQuality({ mode, health: health2 }) };
200654
200799
  }
200655
- if (!existsSync20(join25(input.projectRoot, ".codegraph"))) {
200800
+ if (!existsSync20(join26(input.projectRoot, ".codegraph"))) {
200656
200801
  const health2 = { state: "not-detected", reason: "No local .codegraph index is present for this project." };
200657
200802
  return { health: health2, quality: providerQuality({ mode, health: health2 }) };
200658
200803
  }
@@ -200687,7 +200832,7 @@ async function runExternalCodeGraphLifecycle(input) {
200687
200832
  quality: providerQuality({ mode, health })
200688
200833
  };
200689
200834
  }
200690
- const indexPath = join25(input.projectRoot, ".codegraph");
200835
+ const indexPath = join26(input.projectRoot, ".codegraph");
200691
200836
  if (input.action === "sync" && !existsSync20(indexPath)) {
200692
200837
  const health = { state: "not-detected", reason: "No local .codegraph index is present for this project." };
200693
200838
  return {
@@ -203184,12 +203329,12 @@ function decideRefresh(input) {
203184
203329
  return { performed: false, reason: "fresh-enough", message: "Existing project scan is fresh enough." };
203185
203330
  }
203186
203331
  async function buildAutoProjectContext(input) {
203187
- const refreshMode = input.refresh ?? "auto";
203188
203332
  const now3 = input.now ?? /* @__PURE__ */ new Date();
203189
203333
  const task = input.task?.trim();
203190
203334
  const lens = resolveTaskLens(task);
203191
203335
  const continuationRequested = input.continuation === "always" || input.continuation !== "never" && isContinuationTask(task);
203192
203336
  const codegraphConfig = getResolvedConfig({ projectRoot: input.project.rootPath }).codegraph;
203337
+ const refreshMode = input.refresh ?? codegraphConfig.autoRefresh ?? "auto";
203193
203338
  const exclude = input.exclude ?? codegraphConfig.excludePatterns;
203194
203339
  const maxFileBytes = input.maxFileBytes ?? codegraphConfig.maxFileBytes;
203195
203340
  const store2 = new CodeGraphStore();
@@ -203810,7 +203955,8 @@ __export(context_exports, {
203810
203955
  default: () => context_default
203811
203956
  });
203812
203957
  function coerceRefreshMode(input) {
203813
- const value = (input ?? "auto").trim().toLowerCase();
203958
+ if (!input?.trim()) return void 0;
203959
+ const value = input.trim().toLowerCase();
203814
203960
  if (value === "always" || value === "never" || value === "auto") return value;
203815
203961
  throw new Error("refresh must be one of: auto, always, never");
203816
203962
  }
@@ -204027,7 +204173,8 @@ __export(explain_exports, {
204027
204173
  default: () => explain_default
204028
204174
  });
204029
204175
  function coerceRefreshMode2(input) {
204030
- const value = (input ?? "auto").trim().toLowerCase();
204176
+ if (!input?.trim()) return void 0;
204177
+ const value = input.trim().toLowerCase();
204031
204178
  if (value === "always" || value === "never" || value === "auto") return value;
204032
204179
  throw new Error("refresh must be one of: auto, always, never");
204033
204180
  }
@@ -207301,8 +207448,8 @@ __export(engine_exports2, {
207301
207448
  SkillsEngine: () => SkillsEngine
207302
207449
  });
207303
207450
  import { existsSync as existsSync22, readFileSync as readFileSync13, writeFileSync as writeFileSync5, mkdirSync as mkdirSync5, readdirSync as readdirSync3 } from "fs";
207304
- import { join as join26 } from "path";
207305
- import { homedir as homedir32 } from "os";
207451
+ import { join as join27 } from "path";
207452
+ import { homedir as homedir33 } from "os";
207306
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;
207307
207454
  var init_engine4 = __esm({
207308
207455
  "src/skills/engine.ts"() {
@@ -207373,12 +207520,12 @@ var init_engine4 = __esm({
207373
207520
  listSkills() {
207374
207521
  const skills = [];
207375
207522
  const seen = /* @__PURE__ */ new Set();
207376
- const home = homedir32();
207523
+ const home = homedir33();
207377
207524
  for (const [agent, dirs] of Object.entries(SKILLS_DIRS)) {
207378
207525
  for (const dir of dirs) {
207379
- const paths = [join26(this.projectRoot, dir)];
207526
+ const paths = [join27(this.projectRoot, dir)];
207380
207527
  if (!this.skipGlobal) {
207381
- paths.push(join26(home, dir));
207528
+ paths.push(join27(home, dir));
207382
207529
  }
207383
207530
  for (const skillsRoot of paths) {
207384
207531
  if (!existsSync22(skillsRoot)) continue;
@@ -207388,7 +207535,7 @@ var init_engine4 = __esm({
207388
207535
  if (!entry.isDirectory()) continue;
207389
207536
  const name = entry.name;
207390
207537
  if (seen.has(name)) continue;
207391
- const skillMd = join26(skillsRoot, name, "SKILL.md");
207538
+ const skillMd = join27(skillsRoot, name, "SKILL.md");
207392
207539
  if (!existsSync22(skillMd)) continue;
207393
207540
  try {
207394
207541
  const content = readFileSync13(skillMd, "utf-8");
@@ -207396,7 +207543,7 @@ var init_engine4 = __esm({
207396
207543
  skills.push({
207397
207544
  name,
207398
207545
  description,
207399
- sourcePath: join26(skillsRoot, name),
207546
+ sourcePath: join27(skillsRoot, name),
207400
207547
  sourceAgent: agent,
207401
207548
  content,
207402
207549
  generated: false
@@ -207439,11 +207586,11 @@ var init_engine4 = __esm({
207439
207586
  writeSkill(skill2, target) {
207440
207587
  const dirs = SKILLS_DIRS[target];
207441
207588
  if (!dirs || dirs.length === 0) return null;
207442
- const targetDir = join26(this.projectRoot, dirs[0], skill2.name);
207589
+ const targetDir = join27(this.projectRoot, dirs[0], skill2.name);
207443
207590
  try {
207444
207591
  mkdirSync5(targetDir, { recursive: true });
207445
- writeFileSync5(join26(targetDir, "SKILL.md"), skill2.content, "utf-8");
207446
- 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");
207447
207594
  } catch {
207448
207595
  return null;
207449
207596
  }
@@ -208612,7 +208759,7 @@ var init_task_graph = __esm({
208612
208759
  // src/orchestrate/context-collector.ts
208613
208760
  import { execFileSync as execFileSync2 } from "child_process";
208614
208761
  import { readFileSync as readFileSync14, existsSync as existsSync23 } from "fs";
208615
- import { join as join27 } from "path";
208762
+ import { join as join28 } from "path";
208616
208763
  function normalizeEntryLimit(value, fallback) {
208617
208764
  if (!Number.isSafeInteger(value) || value < 1) return fallback;
208618
208765
  return Math.min(value, 500);
@@ -208687,7 +208834,7 @@ function collectFileTree(projectDir2, maxEntries) {
208687
208834
  }
208688
208835
  function collectDependencies(projectDir2) {
208689
208836
  try {
208690
- const pkgPath = join27(projectDir2, "package.json");
208837
+ const pkgPath = join28(projectDir2, "package.json");
208691
208838
  if (!existsSync23(pkgPath)) return "";
208692
208839
  const pkg = JSON.parse(readFileSync14(pkgPath, "utf-8"));
208693
208840
  const parts = [];
@@ -210025,7 +210172,7 @@ var init_tool_profile = __esm({
210025
210172
  function getMcpServerInfo() {
210026
210173
  return {
210027
210174
  name: "memorix",
210028
- version: true ? "1.10.2" : "1.0.1"
210175
+ version: true ? "1.10.3" : "1.0.1"
210029
210176
  };
210030
210177
  }
210031
210178
  function createMcpDiscoverResult(capabilities, serverInfo) {
@@ -224178,8 +224325,8 @@ __export(engine_exports3, {
224178
224325
  WorkspaceSyncEngine: () => WorkspaceSyncEngine
224179
224326
  });
224180
224327
  import { readFileSync as readFileSync16, readdirSync as readdirSync4, existsSync as existsSync26, cpSync, mkdirSync as mkdirSync7 } from "fs";
224181
- import { join as join29 } from "path";
224182
- import { homedir as homedir33 } from "os";
224328
+ import { join as join30 } from "path";
224329
+ import { homedir as homedir34 } from "os";
224183
224330
  var WorkspaceSyncEngine;
224184
224331
  var init_engine5 = __esm({
224185
224332
  "src/workspace/engine.ts"() {
@@ -224251,9 +224398,9 @@ var init_engine5 = __esm({
224251
224398
  const globalPath = adapter.getConfigPath();
224252
224399
  const pathsToCheck = [configPath, globalPath];
224253
224400
  if (target === "antigravity") {
224254
- pathsToCheck.push(join29(this.projectRoot, ".gemini", "settings.json"));
224255
- pathsToCheck.push(join29(homedir33(), ".gemini", "settings.json"));
224256
- 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"));
224257
224404
  }
224258
224405
  const merged = /* @__PURE__ */ new Map();
224259
224406
  for (const path50 of pathsToCheck) {
@@ -224370,7 +224517,7 @@ var init_engine5 = __esm({
224370
224517
  getTargetSkillsDir(target) {
224371
224518
  const dirs = _WorkspaceSyncEngine.SKILLS_DIRS[target];
224372
224519
  if (!dirs || dirs.length === 0) return null;
224373
- return join29(this.projectRoot, dirs[0]);
224520
+ return join30(this.projectRoot, dirs[0]);
224374
224521
  }
224375
224522
  /**
224376
224523
  * Scan all agent skills directories and collect unique skills.
@@ -224379,12 +224526,12 @@ var init_engine5 = __esm({
224379
224526
  const skills = [];
224380
224527
  const conflicts = [];
224381
224528
  const seen = /* @__PURE__ */ new Map();
224382
- const home = homedir33();
224529
+ const home = homedir34();
224383
224530
  for (const [agent, dirs] of Object.entries(_WorkspaceSyncEngine.SKILLS_DIRS)) {
224384
224531
  for (const dir of dirs) {
224385
224532
  const paths = [
224386
- join29(this.projectRoot, dir),
224387
- join29(home, dir)
224533
+ join30(this.projectRoot, dir),
224534
+ join30(home, dir)
224388
224535
  ];
224389
224536
  for (const skillsRoot of paths) {
224390
224537
  if (!existsSync26(skillsRoot)) continue;
@@ -224392,7 +224539,7 @@ var init_engine5 = __esm({
224392
224539
  const entries = readdirSync4(skillsRoot, { withFileTypes: true });
224393
224540
  for (const entry of entries) {
224394
224541
  if (!entry.isDirectory()) continue;
224395
- const skillMd = join29(skillsRoot, entry.name, "SKILL.md");
224542
+ const skillMd = join30(skillsRoot, entry.name, "SKILL.md");
224396
224543
  if (!existsSync26(skillMd)) continue;
224397
224544
  let description = "";
224398
224545
  try {
@@ -224404,7 +224551,7 @@ var init_engine5 = __esm({
224404
224551
  const newEntry = {
224405
224552
  name: entry.name,
224406
224553
  description,
224407
- sourcePath: join29(skillsRoot, entry.name),
224554
+ sourcePath: join30(skillsRoot, entry.name),
224408
224555
  sourceAgent: agent
224409
224556
  };
224410
224557
  const existing = seen.get(entry.name);
@@ -224441,7 +224588,7 @@ var init_engine5 = __esm({
224441
224588
  }
224442
224589
  for (const skill2 of skills) {
224443
224590
  if (skill2.sourceAgent === target) continue;
224444
- const dest = join29(targetDir, skill2.name);
224591
+ const dest = join30(targetDir, skill2.name);
224445
224592
  if (existsSync26(dest)) {
224446
224593
  skipped.push(`${skill2.name} (already exists in ${target})`);
224447
224594
  continue;
@@ -224457,13 +224604,13 @@ var init_engine5 = __esm({
224457
224604
  }
224458
224605
  scanWorkflows() {
224459
224606
  const workflows = [];
224460
- const wfDir = join29(this.projectRoot, ".windsurf", "workflows");
224607
+ const wfDir = join30(this.projectRoot, ".windsurf", "workflows");
224461
224608
  if (!existsSync26(wfDir)) return workflows;
224462
224609
  try {
224463
224610
  const files = readdirSync4(wfDir).filter((f7) => f7.endsWith(".md"));
224464
224611
  for (const file2 of files) {
224465
224612
  try {
224466
- const content = readFileSync16(join29(wfDir, file2), "utf-8");
224613
+ const content = readFileSync16(join30(wfDir, file2), "utf-8");
224467
224614
  workflows.push(this.workflowSyncer.parseWindsurfWorkflow(file2, content));
224468
224615
  } catch {
224469
224616
  }
@@ -224785,7 +224932,7 @@ __export(behavior_exports, {
224785
224932
  resetBehaviorConfigCache: () => resetBehaviorConfigCache
224786
224933
  });
224787
224934
  import { existsSync as existsSync27, readFileSync as readFileSync17 } from "fs";
224788
- import { homedir as homedir34 } from "os";
224935
+ import { homedir as homedir35 } from "os";
224789
224936
  function isSessionInject(value) {
224790
224937
  return value === "full" || value === "minimal" || value === "silent";
224791
224938
  }
@@ -224803,7 +224950,7 @@ function legacyBehavior(homeDir) {
224803
224950
  }
224804
224951
  }
224805
224952
  function getBehaviorConfig(options = {}) {
224806
- const homeDir = options.homeDir ?? homedir34();
224953
+ const homeDir = options.homeDir ?? homedir35();
224807
224954
  const projectRoot = options.projectRoot === void 0 ? detectProject()?.rootPath ?? null : options.projectRoot;
224808
224955
  const cacheKey4 = `${homeDir}\0${projectRoot ?? ""}`;
224809
224956
  const cached2 = cache4.get(cacheKey4);
@@ -224844,6 +224991,30 @@ var init_behavior = __esm({
224844
224991
  }
224845
224992
  });
224846
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
+
224847
225018
  // src/memory/cleanup.ts
224848
225019
  function isLowQualityObservation(title) {
224849
225020
  return LOW_QUALITY_PATTERNS.some((pattern) => pattern.test(title.trim()));
@@ -225864,7 +226035,6 @@ __export(server_exports, {
225864
226035
  import { createServer } from "http";
225865
226036
  import { promises as fs23 } from "fs";
225866
226037
  import path41 from "path";
225867
- import { exec } from "child_process";
225868
226038
  function sendJson(res, data, status = 200) {
225869
226039
  res.writeHead(status, {
225870
226040
  "Content-Type": "application/json; charset=utf-8"
@@ -226302,7 +226472,7 @@ async function handleApi(req, res, dataDir, projectId, projectName, baseDir, pro
226302
226472
  case "/config": {
226303
226473
  const os10 = await import("os");
226304
226474
  const { existsSync: existsSync37 } = await import("fs");
226305
- const { join: join36 } = await import("path");
226475
+ const { join: join37 } = await import("path");
226306
226476
  const configProjectRoot = effectiveProjectRoot;
226307
226477
  const resolved = getResolvedConfig({ projectRoot: configProjectRoot });
226308
226478
  const files = {
@@ -226317,13 +226487,13 @@ async function handleApi(req, res, dataDir, projectId, projectName, baseDir, pro
226317
226487
  try {
226318
226488
  const home = os10.homedir();
226319
226489
  const paths = {
226320
- "project memorix.yml": configProjectRoot ? join36(configProjectRoot, "memorix.yml") : null,
226321
- "user memorix.yml": join36(home, ".memorix", "memorix.yml"),
226322
- "project memorix.toml": configProjectRoot ? join36(configProjectRoot, "memorix.toml") : null,
226323
- "user config.toml": join36(home, ".memorix", "config.toml"),
226324
- "project .env": configProjectRoot ? join36(configProjectRoot, ".env") : null,
226325
- "user .env": join36(home, ".memorix", ".env"),
226326
- "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")
226327
226497
  };
226328
226498
  for (const [key, fpath] of Object.entries(paths)) {
226329
226499
  if (fpath === null) {
@@ -226354,7 +226524,8 @@ async function handleApi(req, res, dataDir, projectId, projectName, baseDir, pro
226354
226524
  ...resolved.memory.llm.provider === "openrouter" || resolved.memory.llm.baseUrl?.includes("openrouter.ai") ? ["OPENROUTER_API_KEY"] : [],
226355
226525
  ...resolved.memory.llm.provider === "requesty" ? ["REQUESTY_API_KEY"] : [],
226356
226526
  ...resolved.memory.llm.provider === "apiroute" ? ["API_ROUTE_API_KEY"] : [],
226357
- ...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"] : []
226358
226529
  ];
226359
226530
  if (llmKey) {
226360
226531
  const src2 = resolveDashboardKeySource({ value: llmKey, envKeys: memoryKeyEnv, configSource });
@@ -226569,9 +226740,10 @@ async function serveStatic(req, res, staticDir) {
226569
226740
  }
226570
226741
  }
226571
226742
  function openBrowser(url2) {
226572
- const cmd = process.platform === "win32" ? `start "" "${url2}"` : process.platform === "darwin" ? `open "${url2}"` : `xdg-open "${url2}"`;
226573
- exec(cmd, { windowsHide: true }, () => {
226574
- });
226743
+ try {
226744
+ openLocalBrowser(url2);
226745
+ } catch {
226746
+ }
226575
226747
  }
226576
226748
  function parseJsonField(value, fallback) {
226577
226749
  if (typeof value !== "string") return value ?? fallback;
@@ -226807,6 +226979,7 @@ var init_server3 = __esm({
226807
226979
  "src/dashboard/server.ts"() {
226808
226980
  "use strict";
226809
226981
  init_esm_shims();
226982
+ init_open_browser();
226810
226983
  init_persistence();
226811
226984
  init_obs_store();
226812
226985
  init_session_store();
@@ -266746,7 +266919,7 @@ async function analyzeImage(input) {
266746
266919
  const config2 = getLLMConfig();
266747
266920
  if (!OPENAI_COMPATIBLE_PROVIDERS.has(config2.provider)) {
266748
266921
  throw new Error(
266749
- `Image analysis requires an OpenAI-compatible provider (openai, openrouter, requesty, apiroute, cheaperinference, or custom). Current provider "${config2.provider}" uses a different API shape. Set MEMORIX_LLM_PROVIDER=openai or configure an OpenAI-compatible base URL.`
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.`
266750
266923
  );
266751
266924
  }
266752
266925
  const bytes = decodeBase64ImagePayload(input.base64, MAX_VISION_IMAGE_BYTES);
@@ -266785,7 +266958,7 @@ var init_image_loader = __esm({
266785
266958
  init_provider2();
266786
266959
  init_secret_filter();
266787
266960
  init_image_payload();
266788
- 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"]);
266789
266962
  MAX_VISION_PROMPT_CHARS = 12e3;
266790
266963
  MAX_VISION_DESCRIPTION_CHARS = 12e3;
266791
266964
  MAX_VISION_LABELS = 50;
@@ -268084,7 +268257,7 @@ _Search mode: ${result.receipt.mode}_`;
268084
268257
  inputSchema: {
268085
268258
  task: external_exports2.string().optional().describe("Current coding task or question"),
268086
268259
  taskId: external_exports2.string().max(120).optional().describe("Optional task continuity ledger id to include in the brief"),
268087
- refresh: external_exports2.enum(["auto", "always", "never"]).optional().default("auto").describe(
268260
+ refresh: external_exports2.enum(["auto", "always", "never"]).optional().describe(
268088
268261
  "Code Memory refresh policy. auto refreshes only when missing or stale."
268089
268262
  ),
268090
268263
  format: external_exports2.enum(["prompt", "summary", "json", "receipt"]).optional().default("prompt").describe(
@@ -268140,7 +268313,7 @@ _Search mode: ${result.receipt.mode}_`;
268140
268313
  task,
268141
268314
  taskId,
268142
268315
  agent,
268143
- refresh: refresh ?? "auto",
268316
+ ...refresh ? { refresh } : {},
268144
268317
  reader: getObservationReader(),
268145
268318
  enqueueRefresh: () => {
268146
268319
  enqueueCodegraphRefresh2({
@@ -269278,10 +269451,10 @@ ${Math.max(0, managedIds.size - result.resolved.length)} visible writable observ
269278
269451
  );
269279
269452
  let enableKG = isToolInProfile("create_entities", toolProfile);
269280
269453
  try {
269281
- const { homedir: homedir38 } = await import("os");
269282
- const { join: join36 } = await import("path");
269454
+ const { homedir: homedir39 } = await import("os");
269455
+ const { join: join37 } = await import("path");
269283
269456
  const { readFile: readFile11 } = await import("fs/promises");
269284
- const raw = await readFile11(join36(homedir38(), ".memorix", "settings.json"), "utf-8");
269457
+ const raw = await readFile11(join37(homedir39(), ".memorix", "settings.json"), "utf-8");
269285
269458
  const s4 = JSON.parse(raw);
269286
269459
  if (s4.knowledgeGraph === true) enableKG = true;
269287
269460
  } catch {
@@ -270333,9 +270506,9 @@ ${json4}
270333
270506
  req.end();
270334
270507
  });
270335
270508
  const projectUrl = `${url2}?project=${encodeURIComponent(project.id)}`;
270336
- const { exec: exec2 } = await import("child_process");
270509
+ const { exec } = await import("child_process");
270337
270510
  const cmd = process.platform === "win32" ? `start "" "${projectUrl}"` : process.platform === "darwin" ? `open "${projectUrl}"` : `xdg-open "${projectUrl}"`;
270338
- exec2(cmd, { windowsHide: true }, () => {
270511
+ exec(cmd, { windowsHide: true }, () => {
270339
270512
  });
270340
270513
  return {
270341
270514
  content: [{
@@ -270384,9 +270557,9 @@ ${json4}
270384
270557
  req.end();
270385
270558
  });
270386
270559
  const projectUrl = `${url2}?project=${encodeURIComponent(project.id)}`;
270387
- const { exec: exec2 } = await import("child_process");
270560
+ const { exec } = await import("child_process");
270388
270561
  const cmd = process.platform === "win32" ? `start "" "${projectUrl}"` : process.platform === "darwin" ? `open "${projectUrl}"` : `xdg-open "${projectUrl}"`;
270389
- exec2(cmd, { windowsHide: true }, () => {
270562
+ exec(cmd, { windowsHide: true }, () => {
270390
270563
  });
270391
270564
  return {
270392
270565
  content: [{ type: "text", text: `Dashboard is already running at ${url2}. Switched to project: ${project.name} (${project.id}).` }]
@@ -272055,8 +272228,8 @@ __export(update_checker_exports, {
272055
272228
  });
272056
272229
  import { execFile as execFile3 } from "child_process";
272057
272230
  import { readFile as readFile7, writeFile as writeFile8, mkdir as mkdir7 } from "fs/promises";
272058
- import { join as join30 } from "path";
272059
- import { homedir as homedir35 } from "os";
272231
+ import { join as join31 } from "path";
272232
+ import { homedir as homedir36 } from "os";
272060
272233
  function getCurrentVersion() {
272061
272234
  try {
272062
272235
  return getCliVersion();
@@ -272235,8 +272408,8 @@ var init_update_checker = __esm({
272235
272408
  MIN_AUTO_UPDATE_TIMEOUT_MS = 5e3;
272236
272409
  MAX_AUTO_UPDATE_TIMEOUT_MS = 30 * 60 * 1e3;
272237
272410
  REGISTRY_URL = `https://registry.npmjs.org/${PACKAGE_NAME}/latest`;
272238
- CACHE_DIR2 = join30(homedir35(), ".memorix");
272239
- CACHE_FILE2 = join30(CACHE_DIR2, "update-check.json");
272411
+ CACHE_DIR2 = join31(homedir36(), ".memorix");
272412
+ CACHE_FILE2 = join31(CACHE_DIR2, "update-check.json");
272240
272413
  _testing = {
272241
272414
  CACHE_FILE: CACHE_FILE2,
272242
272415
  CHECK_INTERVAL_MS,
@@ -272294,7 +272467,7 @@ var init_serve = __esm({
272294
272467
  const { serveStdio, StdioServerTransport } = await import("@modelcontextprotocol/server/stdio");
272295
272468
  const { createModernMcpBridge: createModernMcpBridge2 } = await Promise.resolve().then(() => (init_modern_mcp_bridge(), modern_mcp_bridge_exports));
272296
272469
  const { detectProject: detectProject2, findGitInSubdirs: findGitInSubdirs2, isSystemDirectory: isSystemDirectory2 } = await Promise.resolve().then(() => (init_detector(), detector_exports));
272297
- const { homedir: homedir38 } = await import("os");
272470
+ const { homedir: homedir39 } = await import("os");
272298
272471
  const { writeLastProjectRoot: writeLastProjectRoot2 } = await Promise.resolve().then(() => (init_launch_root(), launch_root_exports));
272299
272472
  const { resolveServeProject: resolveServeProject2 } = await Promise.resolve().then(() => (init_serve_shared(), serve_shared_exports));
272300
272473
  let stdioHandle;
@@ -272323,7 +272496,7 @@ var init_serve = __esm({
272323
272496
  try {
272324
272497
  safeCwd = process.cwd();
272325
272498
  } catch {
272326
- safeCwd = homedir38();
272499
+ safeCwd = homedir39();
272327
272500
  }
272328
272501
  const resolution = resolveServeProject2(
272329
272502
  {
@@ -272331,7 +272504,7 @@ var init_serve = __esm({
272331
272504
  envProjectRoot: process.env.MEMORIX_PROJECT_ROOT,
272332
272505
  initCwd: process.env.INIT_CWD,
272333
272506
  processCwd: safeCwd,
272334
- homeDir: homedir38()
272507
+ homeDir: homedir39()
272335
272508
  },
272336
272509
  { detectProject: detectProject2, findGitInSubdirs: findGitInSubdirs2, isSystemDirectory: isSystemDirectory2 }
272337
272510
  );
@@ -274961,7 +275134,7 @@ var init_serve_http = __esm({
274961
275134
  const { createProjectBindingController: createProjectBindingController2 } = await Promise.resolve().then(() => (init_request_context(), request_context_exports));
274962
275135
  const { findGitInSubdirs: findGitInSubdirs2 } = await Promise.resolve().then(() => (init_detector(), detector_exports));
274963
275136
  const { writeFileSync: writeFileSync13, mkdirSync: mkdirSync13 } = await import("fs");
274964
- const { homedir: homedir38 } = await import("os");
275137
+ const { homedir: homedir39 } = await import("os");
274965
275138
  const { McpBindingStore: McpBindingStore2 } = await Promise.resolve().then(() => (init_mcp_binding_store(), mcp_binding_store_exports));
274966
275139
  const { MemoryFeedbackStore: MemoryFeedbackStore2 } = await Promise.resolve().then(() => (init_feedback(), feedback_exports));
274967
275140
  const { createModernMcpRuntime: createModernMcpRuntime2, ModernMcpRuntimePool: ModernMcpRuntimePool2, withBusinessRuntimeQueue: withBusinessRuntimeQueue2 } = await Promise.resolve().then(() => (init_modern_mcp_bridge(), modern_mcp_bridge_exports));
@@ -274991,7 +275164,7 @@ var init_serve_http = __esm({
274991
275164
  try {
274992
275165
  safeCwd = process.cwd();
274993
275166
  } catch {
274994
- safeCwd = homedir38();
275167
+ safeCwd = homedir39();
274995
275168
  }
274996
275169
  const { resolveServeProject: resolveServeProject2 } = await Promise.resolve().then(() => (init_serve_shared(), serve_shared_exports));
274997
275170
  const { writeLastProjectRoot: writeLastProjectRoot2 } = await Promise.resolve().then(() => (init_launch_root(), launch_root_exports));
@@ -275002,7 +275175,7 @@ var init_serve_http = __esm({
275002
275175
  cwdArg: args.cwd,
275003
275176
  envProjectRoot: process.env.MEMORIX_PROJECT_ROOT,
275004
275177
  processCwd: safeCwd,
275005
- homeDir: homedir38()
275178
+ homeDir: homedir39()
275006
275179
  },
275007
275180
  { detectProject: detectorMod.detectProject, findGitInSubdirs: detectorMod.findGitInSubdirs, isSystemDirectory: detectorMod.isSystemDirectory }
275008
275181
  );
@@ -276050,7 +276223,7 @@ ${stack}` : ""}`);
276050
276223
  const { projectId: configProjectId } = await resolveRequestProject(url2);
276051
276224
  const os10 = await import("os");
276052
276225
  const { existsSync: existsSync37 } = await import("fs");
276053
- const { join: join36 } = await import("path");
276226
+ const { join: join37 } = await import("path");
276054
276227
  const { loadYamlConfig: loadYamlConfig2 } = await Promise.resolve().then(() => (init_yaml_loader(), yaml_loader_exports));
276055
276228
  const { loadFileConfig: loadFileConfig2, loadDotenv: loadDotenv2, getLoadedEnvFiles: getLoadedEnvFiles2 } = await Promise.resolve().then(() => (init_config(), config_exports));
276056
276229
  const isStartupProject = configProjectId === defaultProject.id;
@@ -276064,11 +276237,11 @@ ${stack}` : ""}`);
276064
276237
  const home = os10.homedir();
276065
276238
  if (effectiveRoot) {
276066
276239
  const paths = {
276067
- "project memorix.yml": join36(effectiveRoot, "memorix.yml"),
276068
- "user memorix.yml": join36(home, ".memorix", "memorix.yml"),
276069
- "project .env": join36(effectiveRoot, ".env"),
276070
- "user .env": join36(home, ".memorix", ".env"),
276071
- "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")
276072
276245
  };
276073
276246
  for (const [key, fpath] of Object.entries(paths)) {
276074
276247
  files[key] = { exists: existsSync37(fpath), path: fpath };
@@ -276077,9 +276250,9 @@ ${stack}` : ""}`);
276077
276250
  files["project memorix.yml"] = { exists: false, path: "unavailable", unavailable: true };
276078
276251
  files["project .env"] = { exists: false, path: "unavailable", unavailable: true };
276079
276252
  const userPaths = {
276080
- "user memorix.yml": join36(home, ".memorix", "memorix.yml"),
276081
- "user .env": join36(home, ".memorix", ".env"),
276082
- "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")
276083
276256
  };
276084
276257
  for (const [key, fpath] of Object.entries(userPaths)) {
276085
276258
  files[key] = { exists: existsSync37(fpath), path: fpath };
@@ -280450,7 +280623,6 @@ async function buildHookProjectContext(input, task, target) {
280450
280623
  dataDir,
280451
280624
  observations: activeObservations2,
280452
280625
  task,
280453
- refresh: "auto",
280454
280626
  reader: { projectId: canonicalId },
280455
280627
  continuation: "always",
280456
280628
  ...input.sessionId ? {
@@ -283043,6 +283215,7 @@ var background_exports = {};
283043
283215
  __export(background_exports, {
283044
283216
  _testing: () => _testing3,
283045
283217
  default: () => background_default,
283218
+ doRestart: () => doRestart,
283046
283219
  doStart: () => doStart,
283047
283220
  doStop: () => doStop,
283048
283221
  resolveBackgroundCwd: () => resolveBackgroundCwd
@@ -283050,7 +283223,7 @@ __export(background_exports, {
283050
283223
  import * as fs26 from "fs";
283051
283224
  import path46 from "path";
283052
283225
  import { fileURLToPath as fileURLToPath8 } from "url";
283053
- import { spawn as spawn6, execFileSync as execFileSync4 } from "child_process";
283226
+ import { spawn as spawn7, execFileSync as execFileSync4 } from "child_process";
283054
283227
  import { randomBytes as randomBytes2 } from "crypto";
283055
283228
  import os8 from "os";
283056
283229
  function resolveBackgroundCwd(cwd, homeDir = os8.homedir()) {
@@ -283187,7 +283360,7 @@ function buildWindowsBackgroundStartScript(options) {
283187
283360
  async function startWindowsBackgroundService(options) {
283188
283361
  const script = buildWindowsBackgroundStartScript(options);
283189
283362
  return new Promise((resolve9, reject) => {
283190
- const launcher = spawn6("powershell.exe", [
283363
+ const launcher = spawn7("powershell.exe", [
283191
283364
  "-NoLogo",
283192
283365
  "-NoProfile",
283193
283366
  "-NonInteractive",
@@ -283400,7 +283573,7 @@ async function doStartUnlocked(port) {
283400
283573
  });
283401
283574
  } else {
283402
283575
  const logFd = fs26.openSync(logFile, "a");
283403
- const child = spawn6(process.execPath, [cliEntry, "serve-http", "--port", String(port)], {
283576
+ const child = spawn7(process.execPath, [cliEntry, "serve-http", "--port", String(port)], {
283404
283577
  detached: true,
283405
283578
  stdio: ["ignore", logFd, logFd],
283406
283579
  env: { ...process.env },
@@ -283857,7 +284030,7 @@ import { spawnSync as spawnSync2 } from "child_process";
283857
284030
  import { existsSync as existsSync32, realpathSync as realpathSync2 } from "fs";
283858
284031
  import { mkdir as mkdir9, readFile as readFile10, writeFile as writeFile10 } from "fs/promises";
283859
284032
  import { basename as basename5, dirname as dirname8, resolve as resolve7 } from "path";
283860
- import { homedir as homedir36 } from "os";
284033
+ import { homedir as homedir37 } from "os";
283861
284034
  function requestedAgents(agent) {
283862
284035
  const all = getAgentIntegrationEntries().map((entry) => entry.agent);
283863
284036
  if (!agent || agent === "all") return all;
@@ -283974,7 +284147,7 @@ function capabilityParity(agent, projectRoot, scope, mcp, guidance, plugin) {
283974
284147
  };
283975
284148
  }
283976
284149
  function isMcpConfigAgent(agent) {
283977
- return agent !== "pi" && agent !== "grok" && agent !== "qwen";
284150
+ return agent !== "grok" && agent !== "qwen";
283978
284151
  }
283979
284152
  function isActionableMcpRepairIssue(issue2) {
283980
284153
  return issue2 !== "memorix-server-missing";
@@ -284026,16 +284199,16 @@ function asRecordArray(value) {
284026
284199
  return Array.isArray(value) ? value.map(asRecord3).filter((entry) => entry !== null) : [];
284027
284200
  }
284028
284201
  function codexPluginPath() {
284029
- return `${homedir36()}/plugins/${CODEX_PLUGIN_NAME}`;
284202
+ return `${homedir37()}/plugins/${CODEX_PLUGIN_NAME}`;
284030
284203
  }
284031
284204
  function codexPluginMcpPath() {
284032
284205
  return `${codexPluginPath()}/.mcp.json`;
284033
284206
  }
284034
284207
  function codexMarketplacePath() {
284035
- return `${homedir36()}/.agents/plugins/marketplace.json`;
284208
+ return `${homedir37()}/.agents/plugins/marketplace.json`;
284036
284209
  }
284037
284210
  function codexConfigPath() {
284038
- return `${homedir36()}/.codex/config.toml`;
284211
+ return `${homedir37()}/.codex/config.toml`;
284039
284212
  }
284040
284213
  function normalizeMarketplacePath(value) {
284041
284214
  return value.replace(/\\/g, "/").replace(/^\.\//, "");
@@ -284350,7 +284523,7 @@ function canonicalProjectPath(projectRoot) {
284350
284523
  return canonical.replace(/\\/g, "/");
284351
284524
  }
284352
284525
  function getClaudeLocalConfigPath() {
284353
- return `${homedir36()}/.claude.json`;
284526
+ return `${homedir37()}/.claude.json`;
284354
284527
  }
284355
284528
  function coerceMcpServer(name, value) {
284356
284529
  const entry = asRecord3(value);
@@ -284660,7 +284833,7 @@ async function inspectGuidance(agent, projectRoot, scope) {
284660
284833
  }
284661
284834
  const checks = [];
284662
284835
  for (const targetScope of requestedGuidanceScopes(scope)) {
284663
- const root = targetScope === "project" ? projectRoot : homedir36();
284836
+ const root = targetScope === "project" ? projectRoot : homedir37();
284664
284837
  const rulesPath = getAgentRulesPath(agent, root, targetScope === "global");
284665
284838
  if (!existsSync32(rulesPath)) {
284666
284839
  checks.push({
@@ -284950,8 +285123,8 @@ var init_doctor = __esm({
284950
285123
  return;
284951
285124
  }
284952
285125
  const { existsSync: existsSync37, readFileSync: readFileSync25 } = await import("fs");
284953
- const { join: join36, basename: basename7 } = await import("path");
284954
- const { homedir: homedir38 } = await import("os");
285126
+ const { join: join37, basename: basename7 } = await import("path");
285127
+ const { homedir: homedir39 } = await import("os");
284955
285128
  const { execSync: execSync5 } = await import("child_process");
284956
285129
  const report = {};
284957
285130
  const issues = [];
@@ -285013,8 +285186,8 @@ var init_doctor = __esm({
285013
285186
  }
285014
285187
  lines.push("");
285015
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");
285016
- const memorixDir = join36(homedir38(), ".memorix");
285017
- const bgStatePath = join36(memorixDir, "background.json");
285189
+ const memorixDir = join37(homedir39(), ".memorix");
285190
+ const bgStatePath = join37(memorixDir, "background.json");
285018
285191
  let bgRunning = false;
285019
285192
  let bgPort = 0;
285020
285193
  let bgPid = 0;
@@ -285134,7 +285307,7 @@ var init_doctor = __esm({
285134
285307
  }
285135
285308
  }
285136
285309
  try {
285137
- const cachePath = join36(memorixDir, "embedding-cache.json");
285310
+ const cachePath = join37(memorixDir, "embedding-cache.json");
285138
285311
  if (existsSync37(cachePath)) {
285139
285312
  const cache5 = JSON.parse(readFileSync25(cachePath, "utf-8"));
285140
285313
  const cacheCount = Object.keys(cache5).length;
@@ -285303,6 +285476,12 @@ var init_doctor = __esm({
285303
285476
  lines.push(info2(
285304
285477
  `Code provider: ${effectiveProviderQuality.semantic.state} semantic layer (${codeStatus.semanticSymbols} symbols, ${codeStatus.semanticEdges} edges); external graph ${providerQuality2.health.state}`
285305
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
+ }
285306
285485
  if (codeStatus.parserErrors > 0) {
285307
285486
  lines.push(warn2(`CodeGraph parser errors: ${codeStatus.parserErrors}; semantic context is partial until refresh succeeds.`));
285308
285487
  }
@@ -285328,6 +285507,9 @@ var init_doctor = __esm({
285328
285507
  semanticSymbols: codeStatus.semanticSymbols,
285329
285508
  semanticEdges: codeStatus.semanticEdges,
285330
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 } : {},
285331
285513
  providerQuality: effectiveProviderQuality,
285332
285514
  ...overview.code.indexedAt ? { indexedAt: overview.code.indexedAt } : {}
285333
285515
  };
@@ -285388,7 +285570,7 @@ var init_doctor = __esm({
285388
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");
285389
285571
  let conflictsFound = false;
285390
285572
  if (dataDir) {
285391
- const lockFile = join36(dataDir, ".memorix.lock");
285573
+ const lockFile = join37(dataDir, ".memorix.lock");
285392
285574
  if (existsSync37(lockFile)) {
285393
285575
  try {
285394
285576
  const lockData = JSON.parse(readFileSync25(lockFile, "utf-8"));
@@ -285985,6 +286167,19 @@ function getMCPConfigEntries(home, cwd) {
285985
286167
  detected: checkJSON(path48.join(cwd, ".cursor", "mcp.json")),
285986
286168
  note: 'Remove the "memorix" key from mcpServers in this file.'
285987
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
+ }
285988
286183
  entries.push({
285989
286184
  agent: "Windsurf",
285990
286185
  path: path48.join(home, ".codeium", "windsurf", "mcp_config.json"),
@@ -287630,7 +287825,7 @@ var init_pipeline_trace = __esm({
287630
287825
  // src/orchestrate/worktree.ts
287631
287826
  import { execFileSync as execFileSync5 } from "child_process";
287632
287827
  import { existsSync as existsSync34, rmSync as rmSync2 } from "fs";
287633
- import { join as join34, basename as basename6 } from "path";
287828
+ import { join as join35, basename as basename6 } from "path";
287634
287829
  function runGit4(cwd, args, timeout = 5e3) {
287635
287830
  return String(execFileSync5("git", args, {
287636
287831
  cwd,
@@ -287669,7 +287864,7 @@ function isManagedWorktreePath(worktreePath, worktreeBase) {
287669
287864
  function createWorktree(projectDir2, taskId, pipelineId) {
287670
287865
  const shortId2 = taskId.slice(0, 8);
287671
287866
  const shortPipeline = pipelineId.slice(0, 8);
287672
- const worktreeBase = join34(projectDir2, WORKTREE_DIR, `task-${shortId2}`);
287867
+ const worktreeBase = join35(projectDir2, WORKTREE_DIR, `task-${shortId2}`);
287673
287868
  const branchBase = `pipeline/${shortPipeline}/task-${shortId2}`;
287674
287869
  for (let attempt = 1; attempt <= 100; attempt++) {
287675
287870
  const suffix = attempt === 1 ? "" : `-${attempt}`;
@@ -287759,7 +287954,7 @@ function listWorktrees(projectDir2) {
287759
287954
  }
287760
287955
  }
287761
287956
  if (current) worktrees.push(current);
287762
- const worktreeBase = join34(projectDir2, WORKTREE_DIR);
287957
+ const worktreeBase = join35(projectDir2, WORKTREE_DIR);
287763
287958
  return worktrees.filter((w4) => isManagedWorktreePath(w4.path, worktreeBase));
287764
287959
  } catch {
287765
287960
  return [];
@@ -287796,7 +287991,7 @@ var init_worktree = __esm({
287796
287991
  });
287797
287992
 
287798
287993
  // src/orchestrate/verify-gate.ts
287799
- import { spawn as spawn7 } from "child_process";
287994
+ import { spawn as spawn8 } from "child_process";
287800
287995
  function runGate(gate, command, cwd, timeoutMs, outputBudget = DEFAULT_OUTPUT_BUDGET) {
287801
287996
  const start = Date.now();
287802
287997
  return new Promise((resolve9) => {
@@ -287810,7 +288005,7 @@ function runGate(gate, command, cwd, timeoutMs, outputBudget = DEFAULT_OUTPUT_BU
287810
288005
  if (timer) clearTimeout(timer);
287811
288006
  resolve9(result);
287812
288007
  };
287813
- const proc = spawn7(command, {
288008
+ const proc = spawn8(command, {
287814
288009
  cwd,
287815
288010
  shell: true,
287816
288011
  detached: process.platform !== "win32",
@@ -287831,7 +288026,7 @@ function runGate(gate, command, cwd, timeoutMs, outputBudget = DEFAULT_OUTPUT_BU
287831
288026
  const killTree = () => {
287832
288027
  try {
287833
288028
  if (process.platform === "win32" && proc.pid) {
287834
- const killer = spawn7("taskkill.exe", ["/F", "/T", "/PID", String(proc.pid)], {
288029
+ const killer = spawn8("taskkill.exe", ["/F", "/T", "/PID", String(proc.pid)], {
287835
288030
  stdio: "ignore",
287836
288031
  windowsHide: true
287837
288032
  });
@@ -288181,16 +288376,16 @@ var init_cost_tracker = __esm({
288181
288376
 
288182
288377
  // src/orchestrate/evidence.ts
288183
288378
  import { mkdirSync as mkdirSync11, writeFileSync as writeFileSync11 } from "fs";
288184
- import { join as join35 } from "path";
288379
+ import { join as join36 } from "path";
288185
288380
  function writeTaskEvidence(projectDir2, pipelineId, evidence) {
288186
288381
  try {
288187
- 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));
288188
288383
  mkdirSync11(dir, { recursive: true });
288189
288384
  if (evidence.prompt) {
288190
- safeWrite(join35(dir, "prompt.md"), evidence.prompt);
288385
+ safeWrite(join36(dir, "prompt.md"), evidence.prompt);
288191
288386
  }
288192
288387
  if (evidence.tailOutput) {
288193
- safeWrite(join35(dir, "output.txt"), evidence.tailOutput);
288388
+ safeWrite(join36(dir, "output.txt"), evidence.tailOutput);
288194
288389
  }
288195
288390
  if (evidence.gateResults) {
288196
288391
  for (const g4 of evidence.gateResults) {
@@ -288199,7 +288394,7 @@ Status: ${g4.passed ? "PASS" : "FAIL"}
288199
288394
  Duration: ${(g4.durationMs / 1e3).toFixed(1)}s
288200
288395
 
288201
288396
  ${g4.output}`;
288202
- safeWrite(join35(dir, `${g4.gate}.txt`), content);
288397
+ safeWrite(join36(dir, `${g4.gate}.txt`), content);
288203
288398
  }
288204
288399
  }
288205
288400
  const resultJson = {
@@ -288213,7 +288408,7 @@ ${g4.output}`;
288213
288408
  tokenUsage: evidence.tokenUsage,
288214
288409
  costUSD: evidence.costUSD
288215
288410
  };
288216
- safeWrite(join35(dir, "result.json"), JSON.stringify(resultJson, null, 2));
288411
+ safeWrite(join36(dir, "result.json"), JSON.stringify(resultJson, null, 2));
288217
288412
  return dir;
288218
288413
  } catch {
288219
288414
  return null;
@@ -288221,7 +288416,7 @@ ${g4.output}`;
288221
288416
  }
288222
288417
  function writePipelineSummary(projectDir2, summary) {
288223
288418
  try {
288224
- const dir = join35(projectDir2, ".pipeline", summary.pipelineId);
288419
+ const dir = join36(projectDir2, ".pipeline", summary.pipelineId);
288225
288420
  mkdirSync11(dir, { recursive: true });
288226
288421
  const elapsed = (summary.elapsedMs / 1e3).toFixed(0);
288227
288422
  const lines = [
@@ -288242,8 +288437,8 @@ function writePipelineSummary(projectDir2, summary) {
288242
288437
  lines.push(`- [${status}] ${t4.taskDescription.slice(0, 80)} \u2014 ${t4.agentName}, ${dur}s${fixes}`);
288243
288438
  }
288244
288439
  const content = lines.join("\n") + "\n";
288245
- safeWrite(join35(dir, "summary.md"), content);
288246
- return join35(dir, "summary.md");
288440
+ safeWrite(join36(dir, "summary.md"), content);
288441
+ return join36(dir, "summary.md");
288247
288442
  } catch {
288248
288443
  return null;
288249
288444
  }
@@ -291156,6 +291351,7 @@ function ConfigureView({ onBack }) {
291156
291351
  { key: "requesty", label: "Requesty", hint: "multi-provider" },
291157
291352
  { key: "apiroute", label: "API Route", hint: "multi-provider" },
291158
291353
  { key: "cheaperinference", label: "Cheaper Inference", hint: "multi-provider" },
291354
+ { key: "runcrate", label: "Runcrate", hint: "open-weight models" },
291159
291355
  { key: "atlascloud", label: "Atlas Cloud", hint: "DeepSeek V3.2" },
291160
291356
  { key: "custom", label: "Custom endpoint", hint: "OpenAI-compatible" },
291161
291357
  { key: "disable", label: "Disable LLM", hint: "free heuristic mode", color: COLORS.warning },
@@ -291452,6 +291648,7 @@ function getDefaultModel(provider2) {
291452
291648
  if (provider2 === "requesty") return "openai/gpt-4o-mini";
291453
291649
  if (provider2 === "apiroute") return "deepseek-v4.1-flash";
291454
291650
  if (provider2 === "cheaperinference") return "gpt-5.4-mini";
291651
+ if (provider2 === "runcrate") return "deepseek-ai/DeepSeek-V4.1-Flash";
291455
291652
  if (provider2 === "atlascloud") return "deepseek-ai/deepseek-v3.2";
291456
291653
  return "gpt-4o-mini";
291457
291654
  }
@@ -294124,29 +294321,21 @@ ${hookScript}`, "utf-8");
294124
294321
  const handleBackgroundAction = useCallback5(async (action) => {
294125
294322
  setStatusMsg(null);
294126
294323
  try {
294127
- const { execSync: execSync5 } = await import("child_process");
294324
+ const { doStart: doStart2, doStop: doStop2, doRestart: doRestart2 } = await Promise.resolve().then(() => (init_background(), background_exports));
294128
294325
  if (background.running) {
294129
294326
  switch (action) {
294130
294327
  case "w":
294131
294328
  if (background.dashboard) {
294132
294329
  try {
294133
- execSync5(`start "" "${background.dashboard}"`, { stdio: "pipe", windowsHide: true });
294330
+ openLocalBrowser(background.dashboard);
294134
294331
  } catch {
294135
- try {
294136
- execSync5(`open "${background.dashboard}"`, { stdio: "pipe", windowsHide: true });
294137
- } catch {
294138
- try {
294139
- execSync5(`xdg-open "${background.dashboard}"`, { stdio: "pipe", windowsHide: true });
294140
- } catch {
294141
- }
294142
- }
294143
294332
  }
294144
294333
  setStatusMsg({ text: `Opening ${background.dashboard}`, type: "success" });
294145
294334
  }
294146
294335
  break;
294147
294336
  case "1":
294148
294337
  try {
294149
- execSync5("memorix background restart", { stdio: "pipe", timeout: 15e3, windowsHide: true });
294338
+ await doRestart2(background.port ?? 3211);
294150
294339
  setStatusMsg({ text: "Restarted.", type: "success" });
294151
294340
  } catch (e5) {
294152
294341
  setStatusMsg({ text: `Restart failed: ${e5}`, type: "error" });
@@ -294154,7 +294343,7 @@ ${hookScript}`, "utf-8");
294154
294343
  break;
294155
294344
  case "2":
294156
294345
  try {
294157
- execSync5("memorix background stop", { stdio: "pipe", timeout: 1e4, windowsHide: true });
294346
+ await doStop2();
294158
294347
  setStatusMsg({ text: "Stopped.", type: "success" });
294159
294348
  } catch (e5) {
294160
294349
  setStatusMsg({ text: `Stop failed: ${e5}`, type: "error" });
@@ -294168,7 +294357,7 @@ ${hookScript}`, "utf-8");
294168
294357
  switch (action) {
294169
294358
  case "1":
294170
294359
  try {
294171
- execSync5("memorix background start", { stdio: "pipe", timeout: 15e3, windowsHide: true });
294360
+ await doStart2(background.port ?? 3211);
294172
294361
  setStatusMsg({ text: "Started.", type: "success" });
294173
294362
  } catch (e5) {
294174
294363
  setStatusMsg({ text: `Start failed: ${e5}`, type: "error" });
@@ -294187,20 +294376,12 @@ ${hookScript}`, "utf-8");
294187
294376
  const handleDashboardAction = useCallback5(async (action) => {
294188
294377
  setStatusMsg(null);
294189
294378
  try {
294190
- const { execSync: execSync5 } = await import("child_process");
294379
+ const { doStart: doStart2 } = await Promise.resolve().then(() => (init_background(), background_exports));
294191
294380
  if (background.healthy && background.dashboard) {
294192
294381
  if (action === "1") {
294193
294382
  try {
294194
- execSync5(`start "" "${background.dashboard}"`, { stdio: "pipe", windowsHide: true });
294383
+ openLocalBrowser(background.dashboard);
294195
294384
  } catch {
294196
- try {
294197
- execSync5(`open "${background.dashboard}"`, { stdio: "pipe", windowsHide: true });
294198
- } catch {
294199
- try {
294200
- execSync5(`xdg-open "${background.dashboard}"`, { stdio: "pipe", windowsHide: true });
294201
- } catch {
294202
- }
294203
- }
294204
294385
  }
294205
294386
  setStatusMsg({ text: `Opening ${background.dashboard}`, type: "success" });
294206
294387
  } else if (action === "2") {
@@ -294209,7 +294390,7 @@ ${hookScript}`, "utf-8");
294209
294390
  } else {
294210
294391
  if (action === "1") {
294211
294392
  try {
294212
- execSync5("memorix background start", { stdio: "pipe", timeout: 15e3, windowsHide: true });
294393
+ await doStart2(background.port ?? 3211);
294213
294394
  setStatusMsg({ text: "Started.", type: "success" });
294214
294395
  setBackground(await getBackgroundStatus());
294215
294396
  } catch (e5) {
@@ -294474,6 +294655,7 @@ var init_App = __esm({
294474
294655
  init_ChatView();
294475
294656
  init_ContextRail();
294476
294657
  init_chat_service();
294658
+ init_open_browser();
294477
294659
  init_data();
294478
294660
  INPUT_BLOCKING_OVERLAYS = /* @__PURE__ */ new Set([
294479
294661
  "cleanup",