@oh-my-pi/pi-mnemopi 18.10.4 → 18.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,18 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [18.11.1] - 2026-10-15
6
+
7
+ ### Fixed
8
+
9
+ - Fixed a failing `mnemopi` CLI command or MCP memory call dropping the embeddings of memories it had just stored ([#15804](https://github.com/can1357/oh-my-pi/pull/15804) by [@yuzu-octopus](https://github.com/yuzu-octopus))
10
+
11
+ ## [18.11.0] - 2026-10-14
12
+
13
+ ### Fixed
14
+
15
+ - Fixed polyphonic recall ranking unrelated memories above relevant ones when the query shared only a common word such as "that" with an extracted fact subject ([#15512](https://github.com/can1357/oh-my-pi/issues/15512)).
16
+
5
17
  ## [18.9.0] - 2026-10-11
6
18
 
7
19
  ### Added
@@ -16,6 +16,7 @@ export declare class CliError extends Error {
16
16
  constructor(message: string, exitCode?: number);
17
17
  }
18
18
  type CommandHandler = (args: readonly string[], context?: CliContext) => number | Promise<number>;
19
+ export declare function withMemory<T>(context: CliContext | undefined, fn: (memory: BeamMemory) => T | Promise<T>): Promise<T>;
19
20
  export declare function memoryStats(memory: BeamMemory, dataDir?: string): Record<string, unknown>;
20
21
  export declare const cmdExport: CommandHandler;
21
22
  export declare const cmdImport: CommandHandler;
@@ -1,3 +1,4 @@
1
+ import { BeamMemory } from "./core/beam/index.js";
1
2
  export type JsonPrimitive = string | number | boolean | null;
2
3
  export type JsonValue = JsonPrimitive | JsonValue[] | {
3
4
  [key: string]: JsonValue;
@@ -480,5 +481,6 @@ export declare const GRAPH_LINK_SCHEMA: {
480
481
  readonly required: readonly ["source_id", "target_id", "relationship"];
481
482
  };
482
483
  export declare const TOOLS: readonly ToolDefinition[];
484
+ export declare function withBeam<T>(args: ToolArguments, fn: (beam: BeamMemory, bank: string) => T | Promise<T>): Promise<T>;
483
485
  export declare function handleToolCall(name: string, args?: ToolArguments): Promise<ToolResult>;
484
486
  export declare function getToolDefinitions(): readonly ToolDefinition[];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@oh-my-pi/pi-mnemopi",
4
- "version": "18.10.4",
4
+ "version": "18.11.1",
5
5
  "description": "Local SQLite memory engine for omp agents",
6
6
  "homepage": "https://omp.sh",
7
7
  "author": {
@@ -42,10 +42,10 @@
42
42
  "fmt": "oxfmt --no-error-on-unmatched-pattern 'src/**/*.{ts,tsx}' '{test,bench,examples,scripts}/**/*.ts' '*.ts'"
43
43
  },
44
44
  "dependencies": {
45
- "@oh-my-pi/pi-ai": "18.10.4",
46
- "@oh-my-pi/pi-catalog": "18.10.4",
47
- "@oh-my-pi/pi-natives": "18.10.4",
48
- "@oh-my-pi/pi-utils": "18.10.4"
45
+ "@oh-my-pi/pi-ai": "18.11.1",
46
+ "@oh-my-pi/pi-catalog": "18.11.1",
47
+ "@oh-my-pi/pi-natives": "18.11.1",
48
+ "@oh-my-pi/pi-utils": "18.11.1"
49
49
  },
50
50
  "peerDependencies": {
51
51
  "fastembed": "3.0.0",
package/src/cli.ts CHANGED
@@ -77,17 +77,22 @@ function getMemory(context?: CliContext): { memory: BeamMemory; owned: boolean }
77
77
  return { memory: new BeamMemory({ dbPath: resolveDbPath(context) }), owned: true };
78
78
  }
79
79
 
80
- async function withMemory<T>(context: CliContext | undefined, fn: (memory: BeamMemory) => T | Promise<T>): Promise<T> {
80
+ export async function withMemory<T>(
81
+ context: CliContext | undefined,
82
+ fn: (memory: BeamMemory) => T | Promise<T>,
83
+ ): Promise<T> {
81
84
  const { memory, owned } = getMemory(context);
82
85
  try {
83
- const result = await fn(memory);
86
+ return await fn(memory);
87
+ } finally {
84
88
  // Drain background fact-extraction and embedding tasks before close so
85
89
  // short-lived owners (e.g. `mnemopi store …` / `mnemopi sleep …`) don't
86
90
  // race the SQLite handle shut from under in-flight `embed()` writes.
87
- if (owned) await memory.flushExtractions();
88
- return result;
89
- } finally {
90
- if (owned) memory.close();
91
+ // Runs on both success and throw paths.
92
+ if (owned) {
93
+ await memory.flushExtractions();
94
+ memory.close();
95
+ }
91
96
  }
92
97
  }
93
98
 
@@ -5,6 +5,7 @@ import { closeQuietly, type DatabasePath, openDatabase } from "../db";
5
5
  import { backfillConsolidatedFacts, ensureVeracityConsolidator } from "./beam/consolidate";
6
6
  import type { BeamMemoryState, JsonValue, Metadata, RecallResult, RecallTierLabel } from "./beam/types";
7
7
  import { EpisodicGraph } from "./episodic-graph";
8
+ import { STOP_WORDS } from "./synonyms";
8
9
  import { VeracityConsolidator } from "./veracity-consolidation";
9
10
 
10
11
  export type PolyphonicVoice = "hybrid" | "vector" | "graph" | "fact" | "temporal";
@@ -229,15 +230,20 @@ function queryTokens(query: string): string[] {
229
230
  return tokens;
230
231
  }
231
232
 
232
- /** Subject candidates for the fact voice: every 3+ char query word plus adjacent word pairs. */
233
+ /**
234
+ * Subject candidates for the fact voice: every 3+ char query word plus adjacent word pairs.
235
+ * Stopwords never anchor a subject on their own — the regex extractor stores sentence-initial
236
+ * words like `That` as subjects, so a bare `that` in the query would pull in unrelated memories.
237
+ */
233
238
  function factSubjectCandidates(query: string): string[] {
234
239
  const tokens = queryTokens(query);
235
240
  const seen = new Set<string>();
236
241
  for (let i = 0; i < tokens.length; i++) {
237
242
  const word = tokens[i] as string;
238
- if (word.length >= 3) seen.add(word);
243
+ const isContent = !STOP_WORDS.has(word);
244
+ if (isContent && word.length >= 3) seen.add(word);
239
245
  const next = tokens[i + 1];
240
- if (next !== undefined) seen.add(`${word} ${next}`);
246
+ if (next !== undefined && (isContent || !STOP_WORDS.has(next))) seen.add(`${word} ${next}`);
241
247
  }
242
248
  return [...seen];
243
249
  }
package/src/mcp-tools.ts CHANGED
@@ -447,20 +447,24 @@ function sharedBeam(): BeamMemory {
447
447
  return new BeamMemory({ sessionId: "mcp_shared_surface", dbPath });
448
448
  }
449
449
 
450
- async function withBeam<T>(args: ToolArguments, fn: (beam: BeamMemory, bank: string) => T | Promise<T>): Promise<T> {
450
+ export async function withBeam<T>(
451
+ args: ToolArguments,
452
+ fn: (beam: BeamMemory, bank: string) => T | Promise<T>,
453
+ ): Promise<T> {
451
454
  const bank = resolveBank(args);
452
455
  const beam = createBeam(args, bank);
456
+ let result: T;
453
457
  try {
454
- const result = await fn(beam, bank);
458
+ result = await fn(beam, bank);
459
+ } finally {
455
460
  // Drain background fact-extraction and embedding tasks before close so
456
461
  // the SQLite handle stays open until in-flight `embed()` writes commit;
457
462
  // otherwise the short-lived MCP `remember`/`update`/`sleep` paths race
458
463
  // the close and silently drop the new dense-recall rows.
459
464
  await beam.flushExtractions();
460
- return result;
461
- } finally {
462
465
  beam.close();
463
466
  }
467
+ return result;
464
468
  }
465
469
  function serialize(value: unknown): unknown {
466
470
  if (value instanceof Date) return value.toISOString();
@@ -739,13 +743,14 @@ function surfaceLabel(content: string, kind: string): string {
739
743
 
740
744
  async function withSharedBeam<T>(fn: (beam: BeamMemory) => T | Promise<T>): Promise<T> {
741
745
  const beam = sharedBeam();
746
+ let result: T;
742
747
  try {
743
- const result = await fn(beam);
744
- await beam.flushExtractions();
745
- return result;
748
+ result = await fn(beam);
746
749
  } finally {
750
+ await beam.flushExtractions();
747
751
  beam.close();
748
752
  }
753
+ return result;
749
754
  }
750
755
 
751
756
  async function handleSharedRemember(args: ToolArguments): Promise<ToolResult> {