runfali/dsh-fact-memory ↗★ 0

dsh-fact-memory

跨会话事实记忆:SQLite 权威事实库 + 三工具(memory_search / memory_write / memory_forget)+ 常驻目录与会话首轮提醒 + 提案队列 + 向量/重排通道 + 事实图谱 + JSONL 导出导入。只记「下次会话仍成立」的事实,带来源与时间。

Package
dsh-fact-memory
Compatibility
Unverified
Version
0.7.1
License
MIT
Last updated
Nov 14, 2026

Install

$npx -p @deepseek-ai/dsh dsh plugin --profile web add github:runfali/dsh-fact-memory

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.

KeyDefaultMeaning
dataDir""Store directory; empty means /fact-memory. Pointing it elsewhere switches to another store (no migration).
injectDirectorytruePut the budgeted directory into every request's dynamic context.
directoryBudget800Directory budget in tokens, converted at 2 characters per token; overflow is truncated with a count.
injectRemindertrueOne notice per session (first turn, or a turn mentioning memory).
autoCapturefalseRule-based capture of user statements. Credentials and personal data are still skipped.
refuseCredentialstrueRefuse writes that look like a credential. Turn it off and such a value is stored as a sensitive fact instead — still never model-visible.
sensitiveModelVisiblefalseLet 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).
searchLimit5Default memory_search result count (1–10).
backupBeforeExporttrueCopy a consistent SQLite backup into /backups before each export.
backupBeforeWipetrueTake the same backup before “Clear everything”; turning it off makes the wipe immediate.
enabledtrueMaster switch for this store's tools, directory, extraction and time maintenance.
reminderBudgetTokens300Character budget for the per-session notice (2 characters per token); 0 injects no notice at all.
searchBudgetTokens1200Character budget for the rendered memory_search result.
queryTimeoutMs2500Whole-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.
backupKeep7Keep this many export backups, deleting the oldest first. 0 keeps everything.
advanceIntervalMs60000How 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.
embeddingDim0Expected 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.
autoExtractfalseExtract 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.
extractDelayMs5000Merge 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.
extractConfidenceMin0.6Below this confidence a candidate becomes a proposal instead of a fact.
extractMaxChars24000Characters per extraction (about 8000 tokens); longer text is split into segments.
extractThinkingfalseLet the extraction model think before answering. Off by default: reasoning consumes the output budget and extraction needs none.
extractMergetrueWhen 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.
extractChunksPerPass2How many segments one pass covers (1–4).
extractFallbackTurns3Signal-free text is kept this many turns (the cursor does not move); then the model reads it anyway. 0 = prefilter only.
extractFallbackChars800Signal-free text this long goes to the model at once.
extractIncludeAssistanttrueRead the assistant's replies too: facts often land in the reply after the work; off = only the user's own words.
vectorIndexIntervalMs600000With an embedding model configured, rebuild vectors for new/changed facts this often; 0 keeps it manual. A new fact triggers one sweep immediately.
autoConsolidatetrueLook 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.
consolidateIntervalMs21600000How often to look for new near-duplicate pairs (6 hours); 0 keeps it to the button and the route.
consolidateCosineFloor0.85Vector cosine at or above which a pair is worth asking the model about. Lower catches more re-phrasings and spends more calls.
consolidateMaxPairs8Model calls one sweep may spend. Each pair is judged once per vector generation, so a sweep mostly costs nothing.
autoAudittrueAudit 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.
auditIntervalMs21600000How 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