Skip to content

dsh-session-memory

Verified

@shengxiao04/dsh-session-memory · v0.1.5 · MIT · Web UI

Native DSH history search/read, optional local Jev audit and Obsidian export. / 原生历史检索、本地 Jev 审计及 Obsidian 导出。

Install

dsh plugin add @shengxiao04/dsh-session-memory

Confirm the layer applied with dsh --profile default --dump-config — see the install guide.

Source

Published to npm without a public repository. Inspect the package contents before installing.

Tags

Creators

Readme

dsh-session-memory

中文 · Version 0.1.5 · MIT

A DSH-only fork of pi-session-memory, rebuilt as a Cordis Host bundle. Search native DSH history, read exact event context, optionally filter/audit bounded evidence with local Jev, and export completed searches to Obsidian.

Scope and workflow

recall_memory / memory-search
  → DSH sessionQuery native literal search
  → authoritative main-session header checks
  → optional local Jev snippet filtering
  → optional Obsidian Markdown note
  → shared result renderer
review_jev_filtered / memory-review
  → rerun the same native page and local Jev judgment
  → return only filtered-out hits → optional note → same renderer
fetch_session / memory-read
  → bounded native event read → shared read renderer
  • Only the active DSH service's main-session corpus, including live/persisted sessions and ordinary main-session forks. Headers marked origin: subagent or positive delegationDepth are excluded.
  • ctx.sessionQuery is the only query engine; its existing local derived index remains the only search index. No second transcript database, filesystem transcript scans or session-log writes.
  • No foreign-runtime import/parser, migration/resume, cross-agent/provider discovery or messaging, or remote relevance filtering.
  • Search is global within the active corpus unless you explicitly pass exact cwd or session_id. This is not a workspace isolation/access-control boundary. Use a trusted local profile.
  • Jev and Obsidian default off. Enabled failures propagate: there is no silent unfiltered fallback, hidden retry, page refill or ranking change.

Install and configure

Use DSH Plugin Manager's Install bundle action. For local development (including this unreleased checkout), supply its absolute directory:

{"action":"install_bundle","target":"/absolute/path/to/dsh-session-memory","enabled":true}

After 0.1.5 is published, the target can instead be @shengxiao04/[email protected]. The scoped package is this project; the unscoped npm name belongs to another project. Repository: shengxiao20/dsh-session-memory. A version in this README is not proof of publication or active-profile installation.

Installation requires profile-management approval and affects all sessions in the current profile. The package depends on @deepseek-ai/schemastery, @deepseek-ai/cosmokit and @typesafe-ai/sdk. Its prebuilt browser artifact is included; no install-time build or lifecycle script runs. The bundle inserts its Host row with optional features disabled and overrides the shipped session-query-sqlite row to path: ':memory:', openAt: first-search. Removing/disabling the bundle removes that override. If your profile needs a custom disk index or query settings, restate the whole backend config in its higher-priority patch with openAt: first-search; Loader replaces config rather than deep-merging it.

Runtime: Node 22+ and DSH 0.2.1-rc.3, pinned to the inspected/native-tested contract. Your profile must provide tools, commands and searchable sessionQuery, normally @deepseek-ai/dsh-session-query-sqlite. Persistence is needed for history after restarts. Missing services leave the plugin inactive; disabled/broken search throws rather than scanning files or creating another backend.

Plugin Manager configuration page

Open Plugins → DSH Session Memory bundle → dsh-session-memory row → Configure. The English/Chinese page edits all seven fields below. It needs the profile's shipped Settings/config-editor and browser locale/slots/Plugin Manager services; Host search remains usable without Settings or a browser.

ConfigPage
└─ Editor (unsaved draft + revision)
   ├─ Local Jev: enabled / model / baseURL / manageOllama / contextWindow
   ├─ Obsidian: enabled / vaultPath
   └─ Save / Discard edits / Stage inherited defaults
Save → owner form.mutate(path operations, read revision)
     → DSH Settings validation → profile config-editor → Loader live update
     → cancel and await old MemoryWorkflow → create new idle/disabled workflow
  • Only Save writes. Leaving the page drops staged edits; Discard edits reloads accepted values. Stage inherited defaults stages removal of both user group overrides, and needs Save. Blank optional fields restore inherited values, which may differ from package defaults.
  • Save carries the revision the draft read. Conflicts/transport failures display errors and retain the draft, without retrying or overwriting other edits. Read-only/unavailable forms cannot write.
  • Browser validation reuses the pure configuration core; authoritative Host validation additionally uses its native path rules. Vault existence is checked on export, not by the browser/save operation.
  • Parameters are schema-declared .volatile() groups. Accepted changes apply live without remounting registrations, cancel outstanding queries/classifier/export work and wait for owned cleanup before new requests proceed. Saving does not start Ollama, pull a model or create a note. /memory-status reports effective settings/runtime state without these effects.
  • Persistence is owned by DSH in the active profile's cordis.patch.yml, normally ~/.dsh/profiles/<profile>/cordis.patch.yml; do not change package defaults to configure a profile.
  • Upgrading a previously running Host-only package needs a profile restart and browser reload to discover the new dsh.client metadata. Ordinary subsequent form saves apply live.

Example complete plugin config:

{
  "jev": {
    "enabled": true,
    "model": "nimble",
    "baseURL": "http://127.0.0.1:11434",
    "manageOllama": false,
    "contextWindow": 8192
  },
  "obsidian": {
    "enabled": true,
    "vaultPath": "/absolute/path/to/existing/vault"
  }
}

Local Jev

  • enabled: default false; model: default nimble, nonempty model name, at most 200 characters.
  • baseURL: default http://127.0.0.1:11434; only HTTP roots on 127.0.0.1, localhost or [::1]. Credentials, non-root paths, query strings, fragments and redirects are rejected. No remote credentials/config are supported.
  • manageOllama: default false. Unmanaged mode requires a pre-existing local System One endpoint and explicit integer contextWindow (1024–1048576). No process/model management or metadata discovery occurs.
  • Explicit manageOllama: true permits local health checks, ollama serve when connection is refused, version checks (>=0.35.0), ollama pull <model>, and /api/show inspection. The model must declare num_ctx >= 1024; effective budget is that value capped by configured contextWindow, if supplied. A failed HTTP health probe throws, not a signal to start another service.
  • SDK requests use /v1/systemone, explicit local URL/model and Bearer ollama, a 30-second timeout, no retries, and logging off; ambient SDK remote defaults are overridden.
  • The complete user question is required for enabled search and every audit. Historical snippets are explicitly untrusted data in classifier requests.
  • Only the native current page's bounded snippets are judged. JSON UTF-8 byte budgeting (including escaping/model) conservatively approximates context usage, reserving 256 units; it is not a tokenizer measurement. Segments are at most 1024 encoded bytes and batches at most 64 questions. Oversized questions/budgets fail explicitly.
  • Each candidate's score is the maximum noul across its segments. >= 0.5 is retained; < 0.5 is filtered. Native order and continuation cursor are unchanged; removed hits are not refilled. Scores are snippet-model probabilities, not native search scores or full-transcript relevance guarantees.
  • Initialization is lazy and shared per plugin instance. Failed/cancelled initialization remains failed until a configuration change or plugin reload creates a new workflow. Only owned child processes are stopped; pre-existing Ollama is never shut down. Cancellation/unload waits for owned work, escalating owned processes that ignore termination after two seconds.

Obsidian

  • enabled: default false; vaultPath: existing absolute directory, required when enabled. No vault/folder creation or Obsidian app integration is performed.
  • Every completed recall/audit page creates a uniquely named Markdown note by exclusive creation (wx, permissions 0600). Notes contain timestamp/title/source metadata, rendered history and the exact structured page result including IDs, sequences, truncation flags, scores and continuation cursor.
  • No read/status/help export. Export failure rejects the search; failed/cancelled writes remove their own partial file. Completed notes persist after plugin unload. Each audit rerun creates a new note, not an overwrite or cached lookup.
  • Vaults can sync sensitive history through other software. Opt in only to a trusted vault; this plugin itself does not initiate vault sync.

Agent tools

recall_memory

Use for questions about prior work, decisions or conversations:

{"query":"database"}
{"query":"database","cwd":"/absolute/project/path","limit":20}
{"query":"database","question":"What database decision did we make?","session_id":"session-exact-id"}
Parameter Behavior
query Required nonempty literal word/phrase, at most 1000 characters; whitespace normalized.
question Complete user question, at most 1000 characters; required with enabled Jev, otherwise optional.
cwd Optional exact recorded directory, not basename/fuzzy matching. Mutually exclusive with session_id.
session_id Optional exact DSH session ID; searches its events.
limit Native page size 1–50, default 20; keep unchanged for pagination/audit.
cursor Input page cursor from a previous next_cursor; repeat identical query/question/scope/limit.

Optional tool fields may be omitted or null (strict function callers can fill every field with null for defaults). A required question in Jev mode/audit cannot be null. Other required fields cannot be null; empty strings are rejected.

Global search returns one strongest event per matching session; exact-session search returns matching events. Results include exact session_id, zero-based seq, type/time/surface and bounded snippets with explicit truncation. Global indexed hits are checked using authoritative headers before exposure. Subagent exclusion and Jev can yield a short/empty page with a valid next_cursor; no extra search fills the gaps.

DSH native token/phrase search differs from Pi substring/entity-OR recall: AI does not match BRAID. Quotes, OR, NEAR and * are literal data, not executable FTS syntax. Chinese partial-word behavior depends on the native tokenizer. All native current, shadowed and log-only event surfaces are eligible, including compacted history. Backend errors/cancellation propagate; a stale generation-bound cursor (SESSION_QUERY_STALE_CURSOR) requires restarting without a cursor. Do not silently broaden scope.

review_jev_filtered

Audit possible false negatives by rerunning the same query, complete question, scope, limit and input cursor used for the original page:

{"query":"database","question":"What database decision did we make?","session_id":"session-exact-id","limit":20}

Requires enabled local Jev. Returns only hits with maximum segment noul < 0.5, exact IDs/seq, scores and original native next cursor. No cache, full-history semantic search, second database, deduplication across external agents or page refill. Reruns can differ if the corpus/model changes; stale cursors still throw.

fetch_session

Verify a hit by reading its exact event context:

{"session_id":"session-exact-id","seq":12,"before":4,"after":4,"max_chars":12000}
  • Required exact session_id and nonnegative integer seq: event sequence, not conversation turn number.
  • before/after: 0–20 raw events, defaults 4 each; lifecycle events count toward the window.
  • max_chars: 100–24000 UTF-16 code units, default 12000; target-first then nearest-neighbor budget, chronological output, no split surrogate pairs.
  • Reports metadata, inherited-event count, target/range, text and explicit omission/truncation notices. Narrow the window or increase budget to verify truncated text.
  • Returns text, tool-call descriptions and attachment labels, not reasoning, binary data, replay/token streams or lifecycle/control payloads. Not a full transcript export; never resumes, forks, imports or modifies a session.

History may contain obsolete instructions, private strings or malicious text. Output marks it as historical data, not current instructions. Native search/read is local; optional Jev sends only the complete question and current-page evidence to the configured loopback classifier. Managed model pulling can contact Ollama's registry. DSH can independently send tool output to its conversational model.

Manual commands

/memory-search database
/memory-search {"query":"database","question":"What database decision did we make?","limit":20}
/memory-review {"query":"database","question":"What database decision did we make?","limit":20}
/memory-read {"session_id":"session-exact-id","seq":12,"before":4,"after":4}
/memory-status
/memory-help

Search accepts a phrase or JSON; with Jev enabled use JSON to provide question. A phrase starting with { must be inside JSON's query. Review/read take JSON. All commands have discovery descriptions; search/read/review share core and rendering with their agent tools. They bypass the conversational model, but enabled Jev still runs the local classifier.

Development, verification and provenance

npm ci
npm run build
npm run test:all
DSH_CHECKOUT=/absolute/path/to/installed/dsh npm run test:native
DSH_BROWSER=/absolute/path/to/chrome npm run test:browser
npm pack --dry-run

Build the client artifact before local installation or after editing client/, locales or the pure validation core. The build wraps browser-pure code in DSH's lazy module factory and leaves React external to preserve its platform identity; it rejects runtime/SDK/Node imports. The published package includes dist/client.js and needs no install-time compilation.

Node tests use fake native services, real-SDK loopback classifier fixtures, filesystem/child-process fixtures, React rendering and client-factory checks. Native smokes use installed DSH, an isolated Cordis context and in-memory sessions/index; a second smoke exercises real Loader/Settings revisioned writes and client artifact discovery with an in-memory profile-editor adapter. Headless browser smoke exercises the built page with a form/layout fixture, not the active profile. None accesses user history or starts a real model. See verification for measured checks and boundaries.

Code: configuration page, draft/atomic edits, client registration, live workflow owner, registration, native adapter, workflow, configuration, local runtime, filter, exporter, schemas, bundle patch. Localized metadata and an original MIT SVG icon are included.

Upstream Git history and MIT attribution are retained. origin points to the independent DSH repository and upstream to Pi. The original Pi checkout is untouched; no Pi runtime or external transcript parser is required.

0.1.5

  • Add the bilingual Plugin Manager row configuration page, lazy browser bundle and staged revision-fenced Save/Discard/inherited reset.
  • Expose volatile config groups and live workflow replacement with pre-write validation and cancellation/cleanup; keep Host services independent of the optional GUI.
  • Add React/client, real Loader/Settings contract and headless browser fixture checks.
  • Correct the 0.1.4 claim: exporting Config alone did not provide a configuration page or Settings-editable fields.

0.1.4

  • Add opt-in local-only Jev filtering and review_jev_filtered / /memory-review, preserving native page order/cursors.
  • Add opt-in Obsidian notes for completed recall/audit pages.
  • Add strict Host Config schema, /memory-status, shared lifecycle-owned workflow, cancellation and explicit failure propagation; this version did not yet provide a GUI page.
  • Add configuration/runtime/filter/export and configured native integration tests. No remote relevance service or second transcript database.

Earlier releases

  • 0.1.3: pin DSH compatibility to inspected/tested 0.2.1-rc.3; native search/read logic and patch unchanged.
  • 0.1.2: replace Pi multi-runtime indexing with native DSH search/read; enable existing in-memory backend on first search; support null optional tool arguments, bounded output/cursors and subagent exclusion. Optional Jev/export were not included in that baseline.