dsh-fact-memory
跨会话事实记忆:SQLite 权威事实库 + 三工具(memory_search / memory_write / memory_forget)+ 常驻目录与会话首轮提醒 + 提案队列 + 向量/重排通道 + 事实图谱 + JSONL 导出导入。只记「下次会话仍成立」的事实,带来源与时间。
Install
$
npx -p @deepseek-ai/dsh dsh plugin --profile web add github:runfali/dsh-fact-memoryREADME
Read the full README ↗Configuration
Every key is live: the settings card writes through the host's config service and the next request uses the new value; editing the profile file is just as live, no restart. The card renders every configuration key: enabled sits on its own at the top as the master switch, and the tuning knobs — budgets, timeouts, the time zone, backup rotation and the duplicate check — live under a folded “Advanced” section at the bottom, so the card opens on the everyday settings and unfolds the rest on demand.
| Key | Default | Meaning |
|---|---|---|
dataDir | "" | Store directory; empty means /fact-memory. Pointing it elsewhere switches to another store (no migration). |
injectDirectory | true | Put the budgeted directory into every request's dynamic context. |
directoryBudget | 800 | Directory budget in tokens, converted at 2 characters per token; overflow is truncated with a count. |
injectReminder | true | One notice per session (first turn, or a turn mentioning memory). |
autoCapture | false | Rule-based capture of user statements. Credentials and personal data are still skipped. |
refuseCredentials | true | Refuse writes that look like a credential. Turn it off and such a value is stored as a sensitive fact instead — still never model-visible. |
sensitiveModelVisible | false | Let sensitive facts (phone, ID, email) enter the directory and model-facing search results. Off by default: they are stored but never shown to the model. It governs model context only — the library and graph pages always show your own data (a credential stays masked everywhere). |
searchLimit | 5 | Default memory_search result count (1–10). |
backupBeforeExport | true | Copy a consistent SQLite backup into /backups before each export. |
backupBeforeWipe | true | Take the same backup before “Clear everything”; turning it off makes the wipe immediate. |
enabled | true | Master switch for this store's tools, directory, extraction and time maintenance. |
reminderBudgetTokens | 300 | Character budget for the per-session notice (2 characters per token); 0 injects no notice at all. |
searchBudgetTokens | 1200 | Character budget for the rendered memory_search result. |
queryTimeoutMs | 2500 | Whole-query deadline, including the optional embedding and rerank hops. |
storeTimezone | "" | IANA zone for display; empty means the host's local zone. Stored dates stay ISO UTC. |
backupKeep | 7 | Keep this many export backups, deleting the oldest first. 0 keeps everything. |
advanceIntervalMs | 60000 | How often scheduled facts are promoted and expired ones retired. 0 disables the timer; opening the store always advances once. |
embeddingSource | "none" | none or openai (an OpenAI-compatible /embeddings endpoint). The host supplies no embedding model, so this stays off unless you configure it. |
embeddingBaseUrl | "" | Base URL of the embedding endpoint, e.g. https://api.example.com/v1. |
embeddingModel | "" | Embedding model id; indexing and querying must use the same one. |
embeddingDim | 0 | Expected vector dimension; 0 accepts whatever the provider returns. |
embeddingApiKeyEnv | "FACT_MEMORY_EMBEDDING_KEY" | Name the key is stored under. Paste the secret in the settings card and it goes to the host credential store; an environment variable with this name is still honoured as a fallback. |
rerankSource | "none" | none or json (a Cohere/Jina style POST /rerank). |
rerankBaseUrl | "" | Base URL of the rerank endpoint. |
rerankModel | "" | Rerank model id; changing it requires recalibration. |
rerankApiKeyEnv | "FACT_MEMORY_RERANK_KEY" | Same as above, for the rerank endpoint. |
rerankScoreMode | "unit_interval" | unit_interval (0–1), logit, or native; scores outside the declared range invalidate the rerank. |
autoExtract | false | Extract facts with a model after every turn. Off by default: each extraction is one model call. |
llmSource | "host" | host reuses the model this session already runs (no new credential); custom is a separate OpenAI-compatible endpoint, so the turn's text leaves the machine for that address. |
llmBaseUrl | "" | custom only: e.g. https://api.example.com/v1; requests go to /chat/completions. |
llmModel | "" | custom only: model id. |
llmApiKeyEnv | "FACT_MEMORY_LLM_KEY" | custom only: same as above, for the extraction endpoint. |
extractDelayMs | 5000 | Merge window after a turn ends: another turn/end inside it folds into one pass (still FIFO). 0 runs immediately; prefer 0 for one-shot CLI sessions. |
extractConfidenceMin | 0.6 | Below this confidence a candidate becomes a proposal instead of a fact. |
extractMaxChars | 24000 | Characters per extraction (about 8000 tokens); longer text is split into segments. |
extractThinking | false | Let the extraction model think before answering. Off by default: reasoning consumes the output budget and extraction needs none. |
extractMerge | true | When segments repeat or disagree, make one extra model call to consolidate them. The answer may only recombine the given candidates; an invented value discards it. |
extractChunksPerPass | 2 | How many segments one pass covers (1–4). |
extractFallbackTurns | 3 | Signal-free text is kept this many turns (the cursor does not move); then the model reads it anyway. 0 = prefilter only. |
extractFallbackChars | 800 | Signal-free text this long goes to the model at once. |
extractIncludeAssistant | true | Read the assistant's replies too: facts often land in the reply after the work; off = only the user's own words. |
vectorIndexIntervalMs | 600000 | With an embedding model configured, rebuild vectors for new/changed facts this often; 0 keeps it manual. A new fact triggers one sweep immediately. |
autoConsolidate | true | Look for near-duplicate facts in the background: recall is the union of IDF cosine and embeddings, the verdict comes from the model, and every merge becomes a pending proposal. Safe by default because nothing is applied without a person accepting it. |
consolidateIntervalMs | 21600000 | How often to look for new near-duplicate pairs (6 hours); 0 keeps it to the button and the route. |
consolidateCosineFloor | 0.85 | Vector cosine at or above which a pair is worth asking the model about. Lower catches more re-phrasings and spends more calls. |
consolidateMaxPairs | 8 | Model calls one sweep may spend. Each pair is judged once per vector generation, so a sweep mostly costs nothing. |
autoAudit | true | Audit the library in the background for self-referential facts, unfolded pipelines and split entities. Each class becomes one aggregated proposal; nothing is applied without acceptance. |
auditIntervalMs | 21600000 | How often the health check runs (6 hours); 0 keeps it to the button and the route. |
Override example (a profile patch layer):
- id: dsh-fact-memory
name: 'dsh-fact-memory'
config:
directoryBudget: 1200
autoCapture: true