hippo-memory 1.26.4 → 1.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -5245,14 +5245,17 @@ function autoDetectContext() {
5245
5245
  // Embed command
5246
5246
  // ---------------------------------------------------------------------------
5247
5247
  async function cmdEmbed(hippoRoot, flags) {
5248
- requireInit(hippoRoot);
5248
+ // --global mirrors resolveAuthRoot (cli.ts:6900): initGlobal() + the global
5249
+ // root, skipping the local requireInit entirely, so this is the healing
5250
+ // path for pre-1.27.0 global stores from a directory with no local .hippo.
5251
+ const root = resolveAuthRoot(hippoRoot, flags);
5249
5252
  // --status and --reset-physics only read cached state, so they must work even
5250
5253
  // when no provider key is present (e.g. embedded earlier with a key that was
5251
5254
  // later removed). The provider-availability gate is deferred to the embed path.
5252
5255
  if (flags['reset-physics']) {
5253
- const entries = loadAllEntries(hippoRoot);
5254
- const embIndex = loadEmbeddingIndex(hippoRoot);
5255
- const db = openHippoDb(hippoRoot);
5256
+ const entries = loadAllEntries(root);
5257
+ const embIndex = loadEmbeddingIndex(root);
5258
+ const db = openHippoDb(root);
5256
5259
  try {
5257
5260
  const count = resetAllPhysicsState(db, entries, embIndex);
5258
5261
  console.log(`Reset physics state: ${count} particles re-initialized from embeddings.`);
@@ -5263,8 +5266,8 @@ async function cmdEmbed(hippoRoot, flags) {
5263
5266
  return;
5264
5267
  }
5265
5268
  if (flags['status']) {
5266
- const entries = loadAllEntries(hippoRoot);
5267
- const embIndex = loadEmbeddingIndex(hippoRoot);
5269
+ const entries = loadAllEntries(root);
5270
+ const embIndex = loadEmbeddingIndex(root);
5268
5271
  const activeIds = new Set(entries.map((e) => e.id));
5269
5272
  const activeEmbedded = Object.keys(embIndex).filter((id) => activeIds.has(id)).length;
5270
5273
  const orphaned = Object.keys(embIndex).length - activeEmbedded;
@@ -5281,7 +5284,7 @@ async function cmdEmbed(hippoRoot, flags) {
5281
5284
  // Embedding (unlike status/reset) needs an available provider.
5282
5285
  const embedProvider = (() => {
5283
5286
  try {
5284
- return resolveEmbeddingProvider(hippoRoot);
5287
+ return resolveEmbeddingProvider(root);
5285
5288
  }
5286
5289
  catch (err) {
5287
5290
  console.error(err instanceof Error ? err.message : String(err));
@@ -5293,7 +5296,7 @@ async function cmdEmbed(hippoRoot, flags) {
5293
5296
  return;
5294
5297
  }
5295
5298
  if (!embedProvider.isAvailable()) {
5296
- if (loadConfig(hippoRoot).embeddings.enabled === false) {
5299
+ if (loadConfig(root).embeddings.enabled === false) {
5297
5300
  console.log('Embeddings are disabled in config (embeddings.enabled = false). Set it to true or "auto" to enable.');
5298
5301
  return;
5299
5302
  }
@@ -5311,17 +5314,17 @@ async function cmdEmbed(hippoRoot, flags) {
5311
5314
  console.log('Embedding all memories (this may take a moment on first run to download model)...');
5312
5315
  let count;
5313
5316
  try {
5314
- count = await embedAll(hippoRoot, resolveEmbeddingModel(hippoRoot));
5317
+ count = await embedAll(root, resolveEmbeddingModel(root));
5315
5318
  }
5316
5319
  catch (err) {
5317
5320
  console.error(`Embedding failed: ${err instanceof Error ? err.message : String(err)}`);
5318
- const partial = loadEmbeddingIndex(hippoRoot);
5321
+ const partial = loadEmbeddingIndex(root);
5319
5322
  console.error(`Partial progress saved: ${Object.keys(partial).length} embeddings on disk. Re-run \`hippo embed\` to resume.`);
5320
5323
  process.exitCode = 1;
5321
5324
  return;
5322
5325
  }
5323
- const entriesAfter = loadAllEntries(hippoRoot);
5324
- const embIndexAfter = loadEmbeddingIndex(hippoRoot);
5326
+ const entriesAfter = loadAllEntries(root);
5327
+ const embIndexAfter = loadEmbeddingIndex(root);
5325
5328
  console.log(`Done. ${count} new embeddings created. ${Object.keys(embIndexAfter).length}/${entriesAfter.length} total.`);
5326
5329
  }
5327
5330
  // ---------------------------------------------------------------------------
@@ -5519,6 +5522,12 @@ function cmdImport(hippoRoot, args, flags) {
5519
5522
  console.log(` Skipped (unchanged): ${vaultResult.skipped}`);
5520
5523
  console.log(` ${dryRun ? 'Would archive: ' : 'Archived (removed): '}${vaultResult.archived ?? 0}`);
5521
5524
  console.log(` Store: ${hippoRoot}`);
5525
+ // Batch producer, same contract as the single-file import below: vault rows
5526
+ // write through api.remember (which never embeds), so backfill them here.
5527
+ // Floating promise is deliberate; see the comment at the single-file site.
5528
+ if (!dryRun && vaultResult.imported >= 1) {
5529
+ void embedAll(hippoRoot).catch(() => { });
5530
+ }
5522
5531
  return;
5523
5532
  }
5524
5533
  // Determine which importer to use based on flag
@@ -5565,6 +5574,15 @@ function cmdImport(hippoRoot, args, flags) {
5565
5574
  process.exit(1);
5566
5575
  }
5567
5576
  const result = importer(filePath, importOptions);
5577
+ // Batch producer: embed newly-imported rows on targetRoot in one pass
5578
+ // rather than per-row (importers.ts writeEntry sites don't embed). The
5579
+ // floating promise is deliberate: libuv keeps the process alive until it
5580
+ // settles, so it is not dropped on process exit; `hippo embed --global` (or
5581
+ // a local `hippo embed`) is the backstop if it does get interrupted. Do not
5582
+ // "fix" this by awaiting it, that would block the CLI on model load/backfill.
5583
+ if (!dryRun && result.imported >= 1) {
5584
+ void embedAll(targetRoot).catch(() => { });
5585
+ }
5568
5586
  const storeLabel = useGlobal ? `global (${getGlobalRoot()})` : targetRoot;
5569
5587
  console.log(`\nImport ${importerName}: ${filePath}`);
5570
5588
  console.log(` Source entries found: ${result.total}`);