@danielmarbach/mnemonic-mcp 0.22.0 → 0.23.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/CHANGELOG.md +14 -0
- package/README.md +13 -3
- package/build/index.js +81 -28
- package/build/index.js.map +1 -1
- package/build/lexical.d.ts +36 -0
- package/build/lexical.d.ts.map +1 -1
- package/build/lexical.js +147 -0
- package/build/lexical.js.map +1 -1
- package/build/recall.d.ts +20 -4
- package/build/recall.d.ts.map +1 -1
- package/build/recall.js +37 -5
- package/build/recall.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,20 @@ All notable changes to `mnemonic` will be documented in this file.
|
|
|
4
4
|
|
|
5
5
|
The format is loosely based on Keep a Changelog and uses semver-style version headings.
|
|
6
6
|
|
|
7
|
+
## [0.23.0] - 2026-04-17
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- Lexical rescue now ranks candidates by TF-IDF similarity, improving recall for identifier-heavy and jargon queries without affecting semantic ranking.
|
|
12
|
+
- Recall now boosts notes that explain key decisions and concepts when you ask "why"-style questions, using structural signals like role, connections, and format rather than keyword matching.
|
|
13
|
+
- `run-dogfood-packs.mjs --isolated` copies notes into a temporary workspace for reproducible validation runs without polluting the live vault.
|
|
14
|
+
- Rescue candidates no longer appear when `minSimilarity` is set above the default, so explicit quality filters are respected.
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
|
|
18
|
+
- Decision and overview notes now surface more reliably for questions like "why are embeddings gitignored" instead of being outranked by incidental mentions.
|
|
19
|
+
- Lexical rescue now correctly activates when no semantic results are found at all.
|
|
20
|
+
|
|
7
21
|
## [0.22.0] - 2026-04-13
|
|
8
22
|
|
|
9
23
|
### Added
|
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@ For the high-level system map, see [`ARCHITECTURE.md`](ARCHITECTURE.md). For rel
|
|
|
17
17
|
|
|
18
18
|
## Stability
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
The storage format is stable with migration support for any future changes. Keep an eye on the changelog; `list_migrations` shows pending work per vault after each update.
|
|
21
21
|
|
|
22
22
|
**Scale:** Designed for simplicity and portability — not large-scale knowledge bases.
|
|
23
23
|
|
|
@@ -45,7 +45,7 @@ No code changes required — set `EMBED_MODEL=qwen3-embedding:0.6b` in your envi
|
|
|
45
45
|
|
|
46
46
|
## Setup
|
|
47
47
|
|
|
48
|
-
### Native (Node.js
|
|
48
|
+
### Native (Node.js 20+)
|
|
49
49
|
|
|
50
50
|
```bash
|
|
51
51
|
npm install
|
|
@@ -63,6 +63,8 @@ npm run mcp:local
|
|
|
63
63
|
|
|
64
64
|
This rebuilds first, then launches `build/index.js`, so MCP clients always point at the latest source.
|
|
65
65
|
|
|
66
|
+
For reproducible dogfooding of recency and relationship-navigation behavior, prefer the isolated dogfood runner over the live project vault. The isolated runner copies the current `.mnemonic` notes into a temporary workspace, runs the chosen pack there, and deletes the workspace afterward.
|
|
67
|
+
|
|
66
68
|
### Docker
|
|
67
69
|
|
|
68
70
|
```bash
|
|
@@ -308,7 +310,7 @@ Project identity derives from the **git remote URL**, normalized to a stable slu
|
|
|
308
310
|
|
|
309
311
|
`recall` with `cwd` searches both vaults. Project notes get a **+0.15 similarity boost** — a soft signal, not a hard filter — so global memories remain accessible while project context floats to the top.
|
|
310
312
|
|
|
311
|
-
**Hybrid recall** enhances semantic search with lightweight lexical reranking over note projections. When semantic results are weak, a bounded lexical rescue path scans projections for additional candidates, improving exact-match and
|
|
313
|
+
**Hybrid recall** enhances semantic search with lightweight lexical reranking over note projections. When semantic results are weak, a bounded lexical rescue path scans projections for additional candidates, improving exact-match and identifier-heavy recall without changing the storage model or adding new infrastructure. **Canonical explanation promotion** boosts notes that explain key decisions and concepts for "why"-style questions, using structural signals like role, connections, and format rather than keyword matching.
|
|
312
314
|
|
|
313
315
|
Temporal recall is opt-in via `mode: "temporal"`. It keeps semantic selection first, then enriches only the top matches with compact git-backed history so agents can inspect how a note evolved without turning recall into raw log or diff output.
|
|
314
316
|
|
|
@@ -572,6 +574,14 @@ This keeps early ideation reusable as personal/global knowledge while moving con
|
|
|
572
574
|
|
|
573
575
|
mnemonic and Beads address complementary concerns. mnemonic is a **knowledge graph**: it stores notes, relationships between them, and lets agents retrieve relevant context through semantic search. [Beads](https://github.com/steveyegge/beads) is a **task and dependency tracker**: it models work items and their dependencies so agents can determine what is ready to execute next. Both tools can coexist in the same workflow — mnemonic stores knowledge and reasoning while Beads manages execution.
|
|
574
576
|
|
|
577
|
+
**How does mnemonic differ from Memory Bank MCP?**
|
|
578
|
+
|
|
579
|
+
mnemonic and Memory Bank MCP both provide persistent memory for agents, but differ in hosting and scope. Memory Bank MCP is a **centralized service** — your memory lives in a remote MCP service and is accessed across projects through that single endpoint. mnemonic is **local-first** — your memories live as plain markdown files on your machine: project-scoped notes in `.mnemonic/` within each repo, and personal notes in a global vault under your home directory. There is no always-on server to configure or depend on; the MCP server spawns on demand per session.
|
|
580
|
+
|
|
581
|
+
**How does mnemonic differ from Basic Memory?**
|
|
582
|
+
|
|
583
|
+
Both tools are local-first and use markdown, but with different scoping models. [Basic Memory](https://github.com/basicmachines/basicmemory) maintains a **knowledge base per project** that agents can search and update, with optional cloud sync. mnemonic splits memory into **two distinct vaults**: a global personal vault (`~/mnemonic-vault/`) for cross-project knowledge, and a project-scoped vault (`.mnemonic/`) that travels with the repo and is shared via git. This lets you capture early ideas globally before a repo exists, then migrate only project-relevant notes into the shared vault once collaboration begins.
|
|
584
|
+
|
|
575
585
|
**What are temporary notes?**
|
|
576
586
|
|
|
577
587
|
mnemonic distinguishes between two lifecycle states. `temporary` notes capture evolving working-state: hypotheses, in-progress plans, experiment results, draft reasoning. `permanent` notes capture durable knowledge: decisions, root cause explanations, architectural guidance, lessons learned. As an investigation progresses, a cluster of temporary notes is typically `consolidate`d into one or more permanent notes, and the scaffolding is discarded. This two-phase lifecycle keeps exploratory thinking from polluting long-term memory while still giving agents a place to reason incrementally before committing to a conclusion.
|
package/build/index.js
CHANGED
|
@@ -14,8 +14,8 @@ import { invalidateActiveProjectCache, getOrBuildVaultEmbeddings, getOrBuildVaul
|
|
|
14
14
|
import { performance } from "perf_hooks";
|
|
15
15
|
import { filterRelationships, mergeRelationshipsFromNotes, normalizeMergePlanSourceIds, resolveEffectiveConsolidationMode, } from "./consolidate.js";
|
|
16
16
|
import { suggestAutoRelationships } from "./auto-relate.js";
|
|
17
|
-
import { computeRecallMetadataBoost, computeHybridScore, selectRecallResults, applyLexicalReranking } from "./recall.js";
|
|
18
|
-
import { shouldTriggerLexicalRescue,
|
|
17
|
+
import { computeRecallMetadataBoost, computeHybridScore, selectRecallResults, applyLexicalReranking, applyCanonicalExplanationPromotion, } from "./recall.js";
|
|
18
|
+
import { shouldTriggerLexicalRescue, rankDocumentsByTfIdf, LEXICAL_RESCUE_CANDIDATE_LIMIT, LEXICAL_RESCUE_THRESHOLD, LEXICAL_RESCUE_RESULT_LIMIT, } from "./lexical.js";
|
|
19
19
|
import { getRelationshipPreview } from "./relationships.js";
|
|
20
20
|
import { cleanMarkdown } from "./markdown.js";
|
|
21
21
|
import { MnemonicConfigStore, readVaultSchemaVersion } from "./config.js";
|
|
@@ -1757,9 +1757,25 @@ server.registerTool("get_project_memory_policy", {
|
|
|
1757
1757
|
};
|
|
1758
1758
|
});
|
|
1759
1759
|
// ── Lexical rescue helper ─────────────────────────────────────────────────────
|
|
1760
|
-
|
|
1760
|
+
function buildRecallCandidateContext(note) {
|
|
1761
|
+
const metadata = getEffectiveMetadata(note);
|
|
1762
|
+
const relatedCount = note.relatedTo?.length ?? 0;
|
|
1763
|
+
return {
|
|
1764
|
+
metadata,
|
|
1765
|
+
metadataBoost: computeRecallMetadataBoost(metadata),
|
|
1766
|
+
lifecycle: note.lifecycle,
|
|
1767
|
+
relatedCount,
|
|
1768
|
+
connectionDiversity: new Set((note.relatedTo ?? []).map((rel) => rel.type)).size,
|
|
1769
|
+
structureScore: Math.min(0.04, [
|
|
1770
|
+
note.content.includes("## ") ? 0.02 : 0,
|
|
1771
|
+
note.content.includes("- ") || note.content.includes("1. ") ? 0.01 : 0,
|
|
1772
|
+
note.content.length >= 400 ? 0.01 : 0,
|
|
1773
|
+
].reduce((sum, value) => sum + value, 0)),
|
|
1774
|
+
};
|
|
1775
|
+
}
|
|
1776
|
+
async function collectLexicalRescueCandidates(vaults, query, project, scope, tags, lifecycle, existingIds) {
|
|
1761
1777
|
const existingIdSet = new Set(existingIds.map((c) => c.id));
|
|
1762
|
-
const
|
|
1778
|
+
const rescuePool = [];
|
|
1763
1779
|
for (const vault of vaults) {
|
|
1764
1780
|
const notes = await vault.storage.listNotes().catch(() => []);
|
|
1765
1781
|
for (const note of notes) {
|
|
@@ -1770,6 +1786,8 @@ async function collectLexicalRescueCandidates(vaults, query, project, scope, tag
|
|
|
1770
1786
|
if (!tags.every((t) => noteTags.has(t)))
|
|
1771
1787
|
continue;
|
|
1772
1788
|
}
|
|
1789
|
+
if (lifecycle && note.lifecycle !== lifecycle)
|
|
1790
|
+
continue;
|
|
1773
1791
|
const isProjectNote = note.project !== undefined;
|
|
1774
1792
|
const isCurrentProject = project && note.project === project.id;
|
|
1775
1793
|
if (scope === "project" && !isCurrentProject)
|
|
@@ -1779,24 +1797,39 @@ async function collectLexicalRescueCandidates(vaults, query, project, scope, tag
|
|
|
1779
1797
|
const projection = await getOrBuildProjection(vault.storage, note).catch(() => undefined);
|
|
1780
1798
|
if (!projection)
|
|
1781
1799
|
continue;
|
|
1782
|
-
|
|
1783
|
-
if (lexicalScore < LEXICAL_RESCUE_THRESHOLD)
|
|
1784
|
-
continue;
|
|
1785
|
-
const metadataBoost = computeRecallMetadataBoost(getEffectiveMetadata(note));
|
|
1786
|
-
const boost = (isCurrentProject ? 0.15 : 0) + metadataBoost;
|
|
1787
|
-
candidates.push({
|
|
1800
|
+
rescuePool.push({
|
|
1788
1801
|
id: note.id,
|
|
1789
|
-
score: 0,
|
|
1790
|
-
boosted: boost,
|
|
1791
1802
|
vault,
|
|
1792
1803
|
isCurrentProject: Boolean(isCurrentProject),
|
|
1793
|
-
|
|
1804
|
+
projectionText: projection.projectionText,
|
|
1805
|
+
context: buildRecallCandidateContext(note),
|
|
1794
1806
|
});
|
|
1795
|
-
if (candidates.length >= LEXICAL_RESCUE_CANDIDATE_LIMIT)
|
|
1796
|
-
break;
|
|
1797
1807
|
}
|
|
1798
|
-
|
|
1799
|
-
|
|
1808
|
+
}
|
|
1809
|
+
const rankedRescueIds = new Map(rankDocumentsByTfIdf(query, rescuePool.map((candidate) => ({ id: candidate.id, text: candidate.projectionText })), LEXICAL_RESCUE_CANDIDATE_LIMIT).map((candidate) => [candidate.id, candidate.score]));
|
|
1810
|
+
const candidates = [];
|
|
1811
|
+
for (const candidate of rescuePool) {
|
|
1812
|
+
const tfIdfScore = rankedRescueIds.get(candidate.id);
|
|
1813
|
+
if (tfIdfScore === undefined || tfIdfScore <= 0)
|
|
1814
|
+
continue;
|
|
1815
|
+
const lexicalScore = tfIdfScore;
|
|
1816
|
+
if (lexicalScore < LEXICAL_RESCUE_THRESHOLD)
|
|
1817
|
+
continue;
|
|
1818
|
+
const boost = (candidate.isCurrentProject ? 0.15 : 0) + candidate.context.metadataBoost;
|
|
1819
|
+
candidates.push({
|
|
1820
|
+
id: candidate.id,
|
|
1821
|
+
score: lexicalScore,
|
|
1822
|
+
semanticScoreForPromotion: 0,
|
|
1823
|
+
boosted: boost,
|
|
1824
|
+
vault: candidate.vault,
|
|
1825
|
+
isCurrentProject: candidate.isCurrentProject,
|
|
1826
|
+
lexicalScore,
|
|
1827
|
+
lifecycle: candidate.context.lifecycle,
|
|
1828
|
+
relatedCount: candidate.context.relatedCount,
|
|
1829
|
+
connectionDiversity: candidate.context.connectionDiversity,
|
|
1830
|
+
structureScore: candidate.context.structureScore,
|
|
1831
|
+
metadata: candidate.context.metadata,
|
|
1832
|
+
});
|
|
1800
1833
|
}
|
|
1801
1834
|
return candidates
|
|
1802
1835
|
.sort((a, b) => computeHybridScore(b) - computeHybridScore(a))
|
|
@@ -1905,9 +1938,21 @@ server.registerTool("recall", {
|
|
|
1905
1938
|
if (isProjectNote)
|
|
1906
1939
|
continue;
|
|
1907
1940
|
}
|
|
1908
|
-
const
|
|
1909
|
-
const boost = (isCurrentProject ? 0.15 : 0) + metadataBoost;
|
|
1910
|
-
scored.push({
|
|
1941
|
+
const context = buildRecallCandidateContext(note);
|
|
1942
|
+
const boost = (isCurrentProject ? 0.15 : 0) + context.metadataBoost;
|
|
1943
|
+
scored.push({
|
|
1944
|
+
id: rec.id,
|
|
1945
|
+
score: rawScore,
|
|
1946
|
+
semanticScoreForPromotion: rawScore,
|
|
1947
|
+
boosted: rawScore + boost,
|
|
1948
|
+
vault,
|
|
1949
|
+
isCurrentProject: Boolean(isCurrentProject),
|
|
1950
|
+
lifecycle: context.lifecycle,
|
|
1951
|
+
relatedCount: context.relatedCount,
|
|
1952
|
+
connectionDiversity: context.connectionDiversity,
|
|
1953
|
+
structureScore: context.structureScore,
|
|
1954
|
+
metadata: context.metadata,
|
|
1955
|
+
});
|
|
1911
1956
|
}
|
|
1912
1957
|
}
|
|
1913
1958
|
const projectionTexts = new Map();
|
|
@@ -1938,14 +1983,19 @@ server.registerTool("recall", {
|
|
|
1938
1983
|
}
|
|
1939
1984
|
return undefined;
|
|
1940
1985
|
};
|
|
1986
|
+
const strongestSemanticScore = scored.reduce((max, candidate) => max === undefined ? candidate.score : Math.max(max, candidate.score), undefined);
|
|
1941
1987
|
const reranked = applyLexicalReranking(scored, query, getProjectionText);
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1988
|
+
let promoted = applyCanonicalExplanationPromotion(reranked);
|
|
1989
|
+
// Lexical rescue: when semantic results are weak, scan projections for additional candidates.
|
|
1990
|
+
// Skip rescue when the caller set a strict minSimilarity above the default,
|
|
1991
|
+
// because rescue candidates lack genuine semantic backing.
|
|
1992
|
+
const rescueAllowed = minSimilarity <= DEFAULT_MIN_SIMILARITY;
|
|
1993
|
+
if (rescueAllowed && shouldTriggerLexicalRescue(strongestSemanticScore, scored.length)) {
|
|
1994
|
+
const rescueCandidates = await collectLexicalRescueCandidates(vaults, query, project ?? undefined, scope, tags, lifecycle, promoted);
|
|
1995
|
+
promoted.push(...rescueCandidates);
|
|
1996
|
+
promoted = applyCanonicalExplanationPromotion(promoted);
|
|
1997
|
+
}
|
|
1998
|
+
const top = selectRecallResults(promoted, limit, scope);
|
|
1949
1999
|
if (top.length === 0) {
|
|
1950
2000
|
const structuredContent = { action: "recalled", query, scope: scope || "all", results: [] };
|
|
1951
2001
|
return { content: [{ type: "text", text: "No memories found matching that query." }], structuredContent };
|
|
@@ -1992,8 +2042,11 @@ server.registerTool("recall", {
|
|
|
1992
2042
|
const formattedRelationships = relationships !== undefined
|
|
1993
2043
|
? `\n\n${formatRelationshipPreview(relationships)}`
|
|
1994
2044
|
: "";
|
|
2045
|
+
const provenanceLine = provenance || confidence
|
|
2046
|
+
? `\n**confidence:** ${confidence ?? "medium"}${provenance?.recentlyChanged ? " | **recently changed**" : ""}`
|
|
2047
|
+
: "";
|
|
1995
2048
|
// Suppress raw related IDs when enriched preview is shown to avoid duplication
|
|
1996
|
-
sections.push(`${formatNote(note, score, relationships === undefined)}${formattedHistory}${formattedRelationships}`);
|
|
2049
|
+
sections.push(`${formatNote(note, score, relationships === undefined)}${provenanceLine}${formattedHistory}${formattedRelationships}`);
|
|
1997
2050
|
structuredResults.push({
|
|
1998
2051
|
id,
|
|
1999
2052
|
title: note.title,
|