{"versions":{"0.1.0":{"name":"dsh-mem","version":"0.1.0","description":"Cross-session memory capability seam for DeepSeek Harness: a ctx.memory Service Definition, a durable file-backed provider, and the model-facing memory_save / memory_recall / memory_forget / memory_list tools, distributed as an installable dsh bundle.","type":"module","main":"lib/provider.js","types":"lib/provider.d.ts","exports":{".":{"types":"./lib/provider.d.ts","default":"./lib/provider.js"},"./provider":{"types":"./lib/provider.d.ts","default":"./lib/provider.js"},"./memory":{"types":"./lib/memory.d.ts","default":"./lib/memory.js"},"./tool":{"types":"./lib/tool.d.ts","default":"./lib/tool.js"},"./package.json":"./package.json"},"scripts":{"build":"tsc -p tsconfig.json","prepare":"tsc -p tsconfig.json","typecheck":"tsc -p tsconfig.check.json"},"keywords":["deepseek-harness","dsh","dsh-plugin","deepseek-harness-plugin","plugin","bundle","memory","cross-session"],"license":"MIT","publishConfig":{"access":"public"},"dependencies":{"@deepseek-ai/cordis":"^4.0.1","@deepseek-ai/dsh-atomic-write":"^0.1.0-rc.6","@deepseek-ai/dsh-brand":"^0.1.0-rc.6","@deepseek-ai/dsh-tools":"^0.1.0-rc.6","@deepseek-ai/schemastery":"^3.18.1"},"devDependencies":{"@types/node":"^22.0.0","typescript":"^6.0.3"},"dsh":{"bundle":{"patch":"./cordis.patch.yml"}},"gitHead":"18b635f9b4c75a15ad2fba1f6246b4d781a74d3f","_id":"dsh-mem@0.1.0","_nodeVersion":"24.13.0","_npmVersion":"11.6.2","dist":{"integrity":"sha512-JmoPb+T5f2VvG/2eEx5JLBNCEdWNA4OTozZkCPg7kYDYqFIJBahkkIlL1nx03yDZvc7fNd21VUhA0QnvW0HZsQ==","shasum":"e7a1ef28c31cb47e923fdfd921316e5a3e5dc20a","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/dsh-mem/-/dsh-mem-0.1.0.tgz","fileCount":15,"unpackedSize":66460,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIFgw2O8NUUUIZyGfkbUzuQWrF7r8eoV95LgzPTKO5cHEAiBxMfYFS+rb9j2GCCXGbax2rgqJKomdA92wCN6uiYwvXQ=="}],"size":19386},"_npmUser":{"name":"anonymous","email":"3599246336@qq.com"},"directories":{},"maintainers":[{"name":"anonymous","email":"3599246336@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/dsh-mem_0.1.0_1786674508116_0.6972251776986651"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2026-08-14T02:28:28.430Z","publish_time":1786674508430,"_source_registry_name":"default","contributors":[]},"0.1.1":{"name":"dsh-mem","version":"0.1.1","description":"Cross-session long-term memory for DeepSeek Harness (dsh): durable JSON-file memory store with memory_save / memory_recall / memory_forget / memory_list model tools, installable as a dsh bundle.","type":"module","main":"lib/provider.js","types":"lib/provider.d.ts","exports":{".":{"types":"./lib/provider.d.ts","default":"./lib/provider.js"},"./provider":{"types":"./lib/provider.d.ts","default":"./lib/provider.js"},"./memory":{"types":"./lib/memory.d.ts","default":"./lib/memory.js"},"./tool":{"types":"./lib/tool.d.ts","default":"./lib/tool.js"},"./package.json":"./package.json"},"scripts":{"build":"tsc -p tsconfig.json","prepare":"tsc -p tsconfig.json","typecheck":"tsc -p tsconfig.check.json"},"keywords":["deepseek-harness","dsh","dsh-plugin","deepseek-harness-plugin","plugin","bundle","memory","cross-session"],"license":"MIT","publishConfig":{"access":"public"},"dependencies":{"@deepseek-ai/cordis":"^4.0.1","@deepseek-ai/dsh-atomic-write":"^0.1.0-rc.6","@deepseek-ai/dsh-brand":"^0.1.0-rc.6","@deepseek-ai/dsh-tools":"^0.1.0-rc.6","@deepseek-ai/schemastery":"^3.18.1"},"devDependencies":{"@types/node":"^22.0.0","typescript":"^6.0.3"},"dsh":{"bundle":{"patch":"./cordis.patch.yml"}},"gitHead":"38e7d2e4151eb86acab035d7c71e7bde1bc6f3b7","_id":"dsh-mem@0.1.1","_nodeVersion":"24.13.0","_npmVersion":"11.6.2","dist":{"integrity":"sha512-7xmYZxp9Mr53LvYedqZkM19Qbe/+J4EpntlDaG4wTVtmNKZBE4G9HQCuzI2xHgrLrVKFkeB6gct8LK2pCuR8nA==","shasum":"d11cf35787b9ba1eea68b55f5d80f254ac98e50e","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/dsh-mem/-/dsh-mem-0.1.1.tgz","fileCount":16,"unpackedSize":74163,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDe1Yo5ZjEeD3+inemoLP06vT/SJ5IgrRlLubnNAZFHQAIgM3AekNzfsdf23lkPpMsTrxaK2rKvpv6HTEw5HWcZmqQ="}],"size":21634},"_npmUser":{"name":"anonymous","email":"3599246336@qq.com"},"directories":{},"maintainers":[{"name":"anonymous","email":"3599246336@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/dsh-mem_0.1.1_1786674897566_0.35579748397520916"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2026-08-14T02:34:57.703Z","publish_time":1786674897703,"_source_registry_name":"default","contributors":[]}},"dist-tags":{"latest":"0.1.1"},"name":"dsh-mem","time":{"created":"2026-08-14T02:28:42.888Z","modified":"2026-08-14T02:35:15.776Z","0.1.0":"2026-08-14T02:28:28.430Z","0.1.1":"2026-08-14T02:34:57.703Z"},"readme":"# dsh-mem — cross-session memory for DeepSeek Harness\n\nEnglish | [中文](README.zh.md)\n\nAn out-of-tree **bundle** plugin for [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) (dsh) that implements a complete **capability seam** — Service Definition + Service Provider + Consumer. It gives agents durable long-term memory shared across every session: the `memory_save` / `memory_recall` / `memory_forget` / `memory_list` tools persist facts, preferences, and decisions to `$DSH_HOME/memory/memory.json`.\n\n## Install\n\nInstall the published npm package into any profile:\n\n```sh\ndsh plugin --profile <name> add dsh-mem\n```\n\nFrom git instead (runs the package's self-contained `prepare` build; the first install asks you to allow the build in the profile's `pnpm-workspace.yaml`):\n\n```sh\ndsh plugin --profile demo add github:Jelee0145/dsh-mem\n```\n\nOr from a local checkout:\n\n```sh\ndsh plugin --profile demo add ./dsh-memory\n```\n\nVerify the composed layer without booting, then boot:\n\n```sh\ndsh --profile demo --dump-config   # expect a \"# == dsh-mem\" layer with memory / tool-memory rows\ndsh --profile demo                 # new sessions can call the memory_* tools\n```\n\nUninstall: `dsh plugin --profile demo remove dsh-mem`.\n\nTo disable without uninstalling (hot-reloaded, no restart), disable the rows in the profile's own `cordis.patch.yml`:\n\n```yaml\n- id: memory\n  disabled: true\n- id: tool-memory\n  disabled: true\n```\n\nMemory data is never touched by uninstall; it lives in `$DSH_HOME/memory/memory.json` (default `~/.dsh/memory/`). Back it up or delete it separately if you want to clear it.\n\n## The capability seam\n\n| Role | Module | Mounted row | Notes |\n|---|---|---|---|\n| Service Definition | `src/memory.ts` (`dsh-mem/memory`) | — | abstract `MemoryService` declaring the `ctx.memory` contract and types; loading it directly fails loud |\n| Service Provider | `src/provider.ts` (`dsh-mem/provider`) | `memory` | `MemoryFile extends MemoryService`; atomic JSON-file persistence |\n| Consumer | `src/tool.ts` (`dsh-mem/tool`) | `tool-memory` | function plugin registering the four tools; resolves the service via `ctx.get('memory')` per call |\n\nThis mirrors the in-repo `ctx.jobs` seam (Definition in `packages/jobs/jobs`, provider in `jobs-local`, consumer in `tool-jobs`).\n\n## Repository layout\n\n```\ndsh-mem/\n├── package.json          # declares dsh.bundle.patch → ./cordis.patch.yml\n├── cordis.patch.yml      # bundle layer: inserts memory + tool-memory rows\n├── tsconfig.json         # standalone build config (types from npm deps)\n├── tsconfig.check.json   # local typecheck against a dsh checkout (optional)\n├── README.md             # this file\n├── README.zh.md\n└── src/\n    ├── memory.ts         # Service Definition (default-exports the service class)\n    ├── provider.ts       # Provider (default-exports the service class + static Config)\n    └── tool.ts           # Consumer (named exports only: name/inject/Config/apply)\n```\n\n## Build\n\n```sh\nnpm install      # pulls the dependencies (runtime and compile-time types both come from npm)\nnpm run build    # tsc emits lib/ (same as the prepare script, run automatically on git installs)\n```\n\nWorking beside a dsh checkout, `dsh-memory/node_modules/@deepseek-ai/*` can be junctioned to the repo packages so local typechecking works without `npm install`:\n\n```sh\npnpm exec tsc -p dsh-memory/tsconfig.check.json   # typecheck only (no emit)\npnpm exec tsc -p dsh-memory/tsconfig.json         # emit lib/\n```\n\nSmoke tests (build first):\n\n```sh\nnode dsh-memory/tests/patch-smoke.mjs     # patch composition over empty and web-like bases\nnode dsh-memory/tests/provider-smoke.mjs  # provider round-trip: persistence/search/bounds/corruption\n```\n\n## Memory entries and storage\n\nEach note is an immutable record of 5–6 fields:\n\n| Field | Source | Meaning |\n|---|---|---|\n| `id` | provider | `m-<n>`; keeps counting across restarts |\n| `content` | model | the durable fact as a complete standalone sentence or short paragraph |\n| `tags` | model | keywords for filtering; empty strings are dropped |\n| `project` | model | the owning project/workspace (e.g. repository name); absent means a global fact that applies everywhere |\n| `createdAt` / `updatedAt` | provider, stamped automatically | epoch milliseconds; the model never supplies the timestamp, and the tool output includes a human-readable `createdAtText` (ISO 8601) |\n\nStored at `$DSH_HOME/memory/memory.json` (default `~/.dsh/memory/`), e.g.:\n\n```json\n{\n  \"version\": 1,\n  \"nextId\": 3,\n  \"entries\": [\n    {\n      \"id\": \"m-1\",\n      \"content\": \"Project X uses pnpm workspaces and rejects yarn.\",\n      \"tags\": [\"project\", \"tooling\"],\n      \"project\": \"project-x\",\n      \"createdAt\": 1753000000000,\n      \"updatedAt\": 1753000000000\n    }\n  ]\n}\n```\n\n## Design notes\n\n- **Why the provider owns a JSON file instead of the `ctx.storage` seam**: dsh's storage rows (`storage` / `storage-json` / `storage-domain`) are mounted by the `dsh-web-app` bundle, not by `dsh-base`; an out-of-tree bundle that inserts the same row ids would duplicate them in web profiles, while omitting them leaves `ctx.storage` absent in headless ones. One self-managed JSON document keeps this plugin zero-dependency on every profile (web / headless / custom). To swap in a `ctx.storage.domain` backend, subclass `MemoryService` and point the `memory` row at it — the tools and contract stay untouched. That is the point of the seam.\n- **Durability**: every mutation writes memory first, then commits via `writeFileAtomic` (temp file + atomic rename, `0o600`/`0o700`); nothing is visible before it is durable. All operations (reads included) serialize on one in-process queue, so a read never observes an uncommitted write. Concurrent dsh processes sharing one `root` are not supported.\n- **Document format**: `{ version, nextId, entries }`; `nextId` is persisted so ids stay unique across restarts. A wrong version or a corrupt file fails loud at load — never a silent reset.\n- **Model tool contract**: search is a case-insensitive substring match on content plus exact tag match; an empty query returns the newest notes. `recall`/`list` accept a `project` filter (case-insensitive exact; global notes never match). Result caps are clamped to the deployment's `maxRecallLimit`. Oversized content, illegal limits, and malformed ids are rejected at the tool boundary. When to save and what to save is guided by the tool descriptions: project-specific facts must carry `project`; global facts (e.g. user preferences) omit it; timestamps are provider-stamped and cannot be forged by the model.\n- **Dependencies**: `@deepseek-ai/cordis@^4.0.1` and `@deepseek-ai/dsh-*@^0.1.0-rc.6` are published on npm; `dsh plugin add` installs them into the profile.\n\n## Extending\n\n- **Swap the provider**: subclass `MemoryService`, then point the `memory` row's `name` at your class in `cordis.patch.yml`.\n- **Add a human command**: inject `ctx.commands` (present in base) and register a `/memory`-style slash command.\n- **Inject memory into a turn**: in an `agent/pre-step` or `tools/post-execute` listener, call `agent.inject()` with relevant notes for the next request.\n- **Move the storage root**: override the whole `memory` row's `config.root` in the profile's `cordis.patch.yml` (a patch replaces the whole config, so restate the keys you keep).\n\n## Known limitations\n\n- Single-process writer: no cross-process lock when two dsh processes share one `root`.\n- No edit API: `updatedAt` equals `createdAt` today; to overwrite a fact, `memory_forget` then `memory_save`.\n- No structured schema: content is free text; for fielded facts, agree on a fixed text format with the model.","users":{}}