@elvisw/dsh-magic-context 0.0.0-stage → 0.13.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/LICENSE +23 -0
- package/NOTICE +93 -0
- package/README.md +452 -2
- package/README.zh-CN.md +368 -0
- package/cordis.patch.yml +20 -0
- package/lib/client.js +2270 -0
- package/lib/core/compartments.js +424 -0
- package/lib/core/corpus-store.js +176 -0
- package/lib/core/directive-detect.js +147 -0
- package/lib/core/domain-reconcile.js +394 -0
- package/lib/core/domains.js +127 -0
- package/lib/core/embedding-local.js +247 -0
- package/lib/core/global-autostage.js +223 -0
- package/lib/core/global-domains.js +302 -0
- package/lib/core/journal.js +248 -0
- package/lib/core/llm-deadline.js +53 -0
- package/lib/core/machine-domain.js +106 -0
- package/lib/core/maintenance.js +380 -0
- package/lib/core/memory-bridge.js +818 -0
- package/lib/core/memory-categories.js +84 -0
- package/lib/core/memory-scoring.js +65 -0
- package/lib/core/memory-search.js +414 -0
- package/lib/core/memory-write.js +1176 -0
- package/lib/core/policy.js +111 -0
- package/lib/core/profile-confirmation.js +55 -0
- package/lib/core/profile-review.js +375 -0
- package/lib/core/profile-write.js +283 -0
- package/lib/core/reference-seeds.js +63 -0
- package/lib/core/route-health.js +106 -0
- package/lib/core/stores.js +1021 -0
- package/lib/core/tagger.js +7 -0
- package/lib/core/types.js +15 -0
- package/lib/core/vector-backfill.js +140 -0
- package/lib/core/vector-lane.js +184 -0
- package/lib/dsh/command-surface.js +376 -0
- package/lib/dsh/compaction-engine.js +231 -0
- package/lib/dsh/config-switches.js +56 -0
- package/lib/dsh/config.js +13 -0
- package/lib/dsh/context-pressure.js +36 -0
- package/lib/dsh/drop-landing.js +42 -0
- package/lib/dsh/emergency.js +89 -0
- package/lib/dsh/flush-command.js +148 -0
- package/lib/dsh/global-review.js +412 -0
- package/lib/dsh/historian.js +907 -0
- package/lib/dsh/live-journal.js +81 -0
- package/lib/dsh/maintenance-wiring.js +229 -0
- package/lib/dsh/management-pass.js +564 -0
- package/lib/dsh/memory-lane.js +535 -0
- package/lib/dsh/pre-step.js +675 -0
- package/lib/dsh/project-drift.js +116 -0
- package/lib/dsh/recomp.js +192 -0
- package/lib/dsh/reduce-guidance.js +188 -0
- package/lib/dsh/seams.js +588 -0
- package/lib/dsh/search-hint.js +186 -0
- package/lib/dsh/session-notice.js +100 -0
- package/lib/dsh/status-command.js +75 -0
- package/lib/dsh/telemetry.js +349 -0
- package/lib/dsh/tool-bridge.js +1009 -0
- package/lib/dsh/volatile.js +89 -0
- package/lib/index.js +931 -0
- package/package.json +108 -4
- package/tools/migrate-profile-package-name.mjs +317 -0
- package/vendor/onnx/LICENSE +27 -0
- package/vendor/onnx/ort-wasm-simd-threaded.mjs +59 -0
- package/vendor/onnx/ort-wasm-simd-threaded.wasm +0 -0
- package/vendor/onnx/ort.node.min.mjs +8 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Ufuk Altinok — magic-context (https://github.com/cortexkit/magic-context)
|
|
4
|
+
Copyright (c) 2026 wukai — the DeepSeek Harness adapter in this repository
|
|
5
|
+
Copyright (c) 2026 elvisw — fork modifications in this repository
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
in the Software without restriction, including without limitation the rights
|
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
SOFTWARE.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Notices
|
|
2
|
+
|
|
3
|
+
This repository is the DeepSeek Harness adapter extracted from **magic-context**.
|
|
4
|
+
It carries work from more than one project, under more than one copyright, and
|
|
5
|
+
MIT requires the notices to travel with it. This file records where each part
|
|
6
|
+
came from and the exact revisions it was taken at.
|
|
7
|
+
|
|
8
|
+
## This fork
|
|
9
|
+
|
|
10
|
+
The npm package `@elvisw/dsh-magic-context` is maintained by **elvisw**
|
|
11
|
+
(https://github.com/elvisw). It is a fork of the DSH adapter previously
|
|
12
|
+
published as `dsh-plugin-magic-context` by wukai; the fork used
|
|
13
|
+
`@elvisw/dsh-plugin-magic-context` for `0.12.x` and renamed to
|
|
14
|
+
`@elvisw/dsh-magic-context` in `0.13.0`. The upstream package and repository
|
|
15
|
+
are not modified by this fork; upstream credit and the notices below remain in
|
|
16
|
+
force. The loader row id (`magic-context-dsh`), settings namespace, and plugin
|
|
17
|
+
data directory are intentionally unchanged.
|
|
18
|
+
|
|
19
|
+
Upstream DSH adapter: `wk544863858/dsh-plugin-magic-context`, npm
|
|
20
|
+
`dsh-plugin-magic-context@0.11.2` (last public release, 2026-11-11), MIT,
|
|
21
|
+
Copyright (c) 2026 wukai — the DeepSeek Harness adapter in this repository.
|
|
22
|
+
Fork modifications are Copyright (c) 2026 elvisw, also under MIT.
|
|
23
|
+
|
|
24
|
+
Starting with 0.12.0 this fork differs from upstream 0.11.2 in its recovery
|
|
25
|
+
semantics (`ctx_expand` returns a new result and leaves the old placeholder and
|
|
26
|
+
tag dropped), the `message` locator for raw results shadowed by a Historian
|
|
27
|
+
compartment, manual `/ctx-flush`, durable drop-state decisions, and the removal
|
|
28
|
+
of the 30-day tag prune / `tags.retentionDays` / `pruneTags`. The plugin schema
|
|
29
|
+
moves to v11 (`pending_drops.flush_requested`). `0.13.0` renames the npm package
|
|
30
|
+
to `@elvisw/dsh-magic-context` and adds a one-time profile patch name migration;
|
|
31
|
+
the row id, settings namespace, data directory, schema and stored format stay
|
|
32
|
+
the same. Co-installing the upstream package, the 0.12.x fork package, or this
|
|
33
|
+
package is unsupported: the loader keeps one duplicate row id, so remove the old
|
|
34
|
+
package before installing this one.
|
|
35
|
+
|
|
36
|
+
## magic-context — https://github.com/cortexkit/magic-context
|
|
37
|
+
|
|
38
|
+
MIT License, Copyright (c) 2025 Ufuk Altinok.
|
|
39
|
+
|
|
40
|
+
The adapter is derived from this project: it shares its memory contracts, its
|
|
41
|
+
on-disk formats, and its design language. Extracted from upstream tag
|
|
42
|
+
**v0.46.0** (commit `651c105a9`). The adapter's own commits were replayed out of
|
|
43
|
+
the `dsh` branch of a local magic-context checkout at `e34eda955`
|
|
44
|
+
(2026-10-08) — 60 commits, authors and dates preserved.
|
|
45
|
+
|
|
46
|
+
The adapter's own database lives under the upstream project's directory
|
|
47
|
+
(`~/.local/share/cortexkit/magic-context-dsh-poc`) and reads the shared memory
|
|
48
|
+
bank at (`~/.local/share/cortexkit/magic-context/context.db`) on purpose: that
|
|
49
|
+
is the interoperability path with magic-context, so the namespace stays.
|
|
50
|
+
|
|
51
|
+
## DeepSeek Harness (DSH) — https://github.com/deepseek-ai/deepseek-harness
|
|
52
|
+
|
|
53
|
+
MIT License.
|
|
54
|
+
|
|
55
|
+
DSH is a separate project and is **not** included here; its packages are
|
|
56
|
+
consumed as dependencies. The adapter implements the DSH plugin seams
|
|
57
|
+
(`@deepseek-ai/cordis`, `@deepseek-ai/dsh-agent`, `-compaction`, `-llm`,
|
|
58
|
+
`-session`, `-tools`, and the client/session services). It is written against
|
|
59
|
+
DSH **0.2.1-rc.1** — checkout `1600d8a1e`, published on npm under the
|
|
60
|
+
coordinated dist-tag `next`.
|
|
61
|
+
|
|
62
|
+
Note that npm's `latest` tag on those packages is an *older* release line
|
|
63
|
+
(`0.0.1-rc.x` / `0.1.0-rc.6`); the pinned `devDependencies` are what the suite
|
|
64
|
+
is tested against. Individual `@deepseek-ai` packages are BSD-3-Clause rather
|
|
65
|
+
than MIT where their own metadata says so; that is their licence, not this
|
|
66
|
+
repository's.
|
|
67
|
+
|
|
68
|
+
## Vendored file: `tests/helpers/mock-adapter.ts`
|
|
69
|
+
|
|
70
|
+
MIT License, Copyright (c) 2026 DeepSeek.
|
|
71
|
+
|
|
72
|
+
Taken verbatim from DSH (`packages/core/agent-loop/tests/mock-adapter.ts`,
|
|
73
|
+
MIT) so that this repository's suite runs without a DSH checkout. The body is
|
|
74
|
+
byte-identical to upstream; only a provenance header was added.
|
|
75
|
+
|
|
76
|
+
## Vendored files: `vendor/onnx/` — onnxruntime-web (WASM backend subset)
|
|
77
|
+
|
|
78
|
+
MIT License, Copyright (c) Microsoft Corporation.
|
|
79
|
+
|
|
80
|
+
Three files taken verbatim from `onnxruntime-web`
|
|
81
|
+
**1.31.0-dev.20260914-8d85527a0** (`dist/ort.node.min.mjs`,
|
|
82
|
+
`dist/ort-wasm-simd-threaded.mjs`, `dist/ort-wasm-simd-threaded.wasm`)
|
|
83
|
+
so the local embedding lane runs on WebAssembly without the ~287 MB native
|
|
84
|
+
`onnxruntime-node` package. Verified against the native fp32 pipeline at
|
|
85
|
+
cosine 1.0000000 (2026-10-09). The upstream MIT license text travels with them
|
|
86
|
+
at `vendor/onnx/LICENSE`. The tokenizers binding (`@huggingface/tokenizers`,
|
|
87
|
+
Apache-2.0) is consumed as a normal npm dependency, not vendored.
|
|
88
|
+
|
|
89
|
+
## Everything else
|
|
90
|
+
|
|
91
|
+
No other third-party code is bundled. The build output (`lib/`) is compiled
|
|
92
|
+
from this repository's own `src/`, and the browser half is hand-written here;
|
|
93
|
+
`scripts/copy-client.mjs` copies it verbatim.
|
package/README.md
CHANGED
|
@@ -1,3 +1,453 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Magic Context for DeepSeek Harness — elvisw fork
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://github.com/elvisw/dsh-plugin-magic-context/actions/workflows/ci.yml)
|
|
4
|
+
[](https://www.npmjs.com/package/@elvisw/dsh-magic-context)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
[](package.json)
|
|
7
|
+
[](package.json)
|
|
8
|
+
|
|
9
|
+
> **English** | [简体中文](README.zh-CN.md)
|
|
10
|
+
|
|
11
|
+
> Anyone who has run long sessions knows the symptoms: the project details you worked out
|
|
12
|
+
> yesterday are gone today, so the same pit gets re-dug; tool outputs bloat the context
|
|
13
|
+
> window; and every compaction busts the cache prefix, so the expensive part re-runs.
|
|
14
|
+
>
|
|
15
|
+
> [Magic Context](https://github.com/cortexkit/magic-context)'s answer: **knowledge should
|
|
16
|
+
> persist, context should be managed.** This plugin gives **DeepSeek Harness (DSH)**
|
|
17
|
+
> sessions a **persistent, project-aware memory** — knowledge distilled from your sessions
|
|
18
|
+
> survives restarts, is searchable with hybrid full-text + local vector search, and is
|
|
19
|
+
> re-injected right where the model reads it — while the context window itself is run as
|
|
20
|
+
> an asset: tool results become tagged, reclaimable history, digests come back as
|
|
21
|
+
> four-level summaries, and none of it ever breaks the live KV-cache prefix.
|
|
22
|
+
|
|
23
|
+
- **Memory that outlives the session** — a project corpus in the plugin's own SQLite store;
|
|
24
|
+
historian facts auto-promote into it, `ctx_memory` reads/writes/maintains it, and project
|
|
25
|
+
identity is auto-derived (git root or directory).
|
|
26
|
+
- **Local-first retrieval** — MiniLM embeddings via WebAssembly (no native build, no API
|
|
27
|
+
keys), hybrid full-text 0.7 / vector 0.3 ranking, fail-open to full-text on any failure.
|
|
28
|
+
- **Sharing with a human gate** — machine/org global domains: staging can be automated,
|
|
29
|
+
publishing is always yours (approval cards, `/ctx-global approve`); a user-profile layer
|
|
30
|
+
rides on top with read / collect / review as separate switches.
|
|
31
|
+
- **Reversible reclaim, cache-aware compaction** — `ctx_reduce` only queues; drops land as
|
|
32
|
+
`[dropped §N§]` placeholders and `ctx_expand` returns the original as a new result; history digests into
|
|
33
|
+
p1–p4 summaries published as range replacements — never a spontaneous prefix bust.
|
|
34
|
+
- **Conservative by default** — the host `compaction-basic` engine stays in place unless
|
|
35
|
+
you explicitly opt in.
|
|
36
|
+
|
|
37
|
+
Requires **Node ≥ 22.19** and a **DSH 0.2.x host with the Web client** (the desktop app or
|
|
38
|
+
a `web` profile). The package ships compiled — install straight from the npm registry:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
dsh plugin --profile web add @elvisw/dsh-magic-context
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
`0.13.0` is the first release under this package name. If you installed
|
|
45
|
+
`@elvisw/dsh-plugin-magic-context` (0.12.x) or the upstream
|
|
46
|
+
`dsh-plugin-magic-context`, remove it first: all three use the same loader row id
|
|
47
|
+
(`magic-context-dsh`), so co-install is unsupported: the loader keeps one row and
|
|
48
|
+
settings may disappear. Upgrading from 0.12.x also
|
|
49
|
+
needs the one-time profile patch migration described in
|
|
50
|
+
[docs/independent-package-release.md](docs/independent-package-release.md); the helper is
|
|
51
|
+
shipped in the npm tarball and the hand-out bundle.
|
|
52
|
+
|
|
53
|
+
New to the plugin? A five-minute tour follows in [Quick start](#quick-start);
|
|
54
|
+
configuration, tools and architecture are covered in full below. A complete Chinese
|
|
55
|
+
translation is at [README.zh-CN.md](README.zh-CN.md). Contributions are welcome — see
|
|
56
|
+
[CONTRIBUTING.md](CONTRIBUTING.md) and [SECURITY.md](SECURITY.md).
|
|
57
|
+
|
|
58
|
+
## Quick start
|
|
59
|
+
|
|
60
|
+
After installing, restart the profile unless it has HMR enabled; with HMR the new
|
|
61
|
+
version hot-loads. In your next session:
|
|
62
|
+
|
|
63
|
+
- Tool results carry `§N§` tags; a **telemetry badge** appears in the overlay showing live
|
|
64
|
+
context occupancy, with a panel of live metrics and an operation record behind it.
|
|
65
|
+
- A **settings card** for the plugin shows up on the GUI Plugins page.
|
|
66
|
+
- The `ctx_reduce` / `ctx_expand` / `ctx_memory` tools are registered for the agent;
|
|
67
|
+
project memory is **on by default** — facts distilled by the historian persist across
|
|
68
|
+
sessions and surface where the model reads them.
|
|
69
|
+
|
|
70
|
+
Context reclaim, in one exchange (real parameter names):
|
|
71
|
+
|
|
72
|
+
```text
|
|
73
|
+
you: ctx_reduce {"drop": "4-7"} # four tool outputs are no longer worth the tokens
|
|
74
|
+
agent: queued 4 item(s) — the drops land as placeholders in the next reclaim band
|
|
75
|
+
…later in the transcript…
|
|
76
|
+
[dropped §4§] [dropped §5§] [dropped §6§] [dropped §7§]
|
|
77
|
+
you: ctx_expand {"tag": "5"} # wait — what was in §5 again?
|
|
78
|
+
tool: the original text of §5, as a new result — the §5 placeholder stays dropped
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
The only opt-in surface is the compaction takeover (`registerCompactionEngine`, off by
|
|
82
|
+
default — see [Configuration](#configuration)).
|
|
83
|
+
|
|
84
|
+
## What it does
|
|
85
|
+
|
|
86
|
+
Memory first, context management second — the first five rows are the memory system, the
|
|
87
|
+
last five manage the context window (full design in [Architecture](#architecture) and
|
|
88
|
+
[PARITY.md](PARITY.md)):
|
|
89
|
+
|
|
90
|
+
| Capability | Mechanism |
|
|
91
|
+
|---|---|
|
|
92
|
+
| **Project memory (own corpus)** | Plugin's own SQLite store (`memories.db`), hard-split from upstream — no shared storage, no compatibility duty. Project identity auto-derived (`git:<root-sha>` / `dir:<hash>`); injected into the m[0] baseline and served to `ctx_memory` for read/write; historian facts auto-promote; FTS 0.7 / vector 0.3 hybrid retrieval |
|
|
93
|
+
| **Local vector lane** | MiniLM embeddings run locally via the bundled onnxruntime-web WASM backend — no native build, no API keys; the model download is pinned by revision + sha256 (mirror fallback), cached in the plugin data dir; retrieval candidates get inline + maintenance-tick backfill; any failure fails open to full-text search |
|
|
94
|
+
| **m[0]/m[1] memory baseline** | A synthetic notice node carries the frozen baseline plus incremental lanes (`<new-memories>` / `<memory-updates>` / `<user-profile>`); each lane keeps its own watermark, so new memory never rebuilds the cached prefix — unchanged content produces zero diff |
|
|
95
|
+
| **Global domains + user profile** | machine/org domains: **staging can be automated** (maintenance tick, LLM classification), **publishing is always human** (approval cards, `/ctx-global approve`); the user profile's render / collect / review are separate switches |
|
|
96
|
+
| **Maintenance tick (MC dreamer slice)** | Every 30 min: TTL archiving → batched LLM verify (keep / update / archive) → vector backfill → global-domain candidate staging |
|
|
97
|
+
| **Reversible context reclaim** | Tool results get `§N§` tags; `ctx_reduce` **only queues** — drops land in the execute band as `[dropped §N§]` placeholders referencing the originals; `ctx_expand` returns the original text as a new result while the placeholder stays dropped. The cached prefix is never busted spontaneously |
|
|
98
|
+
| **Pressure scheduling** | Persistent usage (incl. cache reads/writes) → pressure score → execute/defer decisions (65% threshold, 5 min cache TTL, 85% force band); `CONTEXT_WINDOW_EXCEEDED` triggers emergency reclaim + retry; tiered reduce-guidance nudges |
|
|
99
|
+
| **Historian (out-of-band digest)** | One LLM call replays the real prefix (KV cache preserved) → four-tier p1–p4 summary + facts/events, **writes the store only, never touches the wire**; published in the execute band as a `[compacted §C<n>§]` range replacement; `/ctx-recomp` redoes compacted history in place |
|
|
100
|
+
| **Compaction seam** | `registerCompactionEngine` can take over `ctx.compaction` (real `compaction/start\|summary\|replace\|end` protocol); **off by default** — the host compaction-basic stays in place |
|
|
101
|
+
| **UI integration** | Settings card on the Plugins page (volatile fields, save = live); `shell.overlay` telemetry badge + capsule panel (live metrics + operation record); `session-notice` rows in the session stream; Chinese/English instant switching |
|
|
102
|
+
|
|
103
|
+
## Installation
|
|
104
|
+
|
|
105
|
+
From the npm registry — recommended; the package ships compiled `lib/` and `vendor/`, no
|
|
106
|
+
local build needed:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
dsh plugin --profile web add @elvisw/dsh-magic-context
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Registry versions are published automatically by tag pushes (with npm provenance
|
|
113
|
+
signatures); see the "Releasing" section of [CONTRIBUTING](CONTRIBUTING.md).
|
|
114
|
+
|
|
115
|
+
### From source (development)
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
git clone https://github.com/elvisw/dsh-plugin-magic-context
|
|
119
|
+
cd dsh-plugin-magic-context
|
|
120
|
+
npm install
|
|
121
|
+
npm run build # tsc → lib/ (multi-file ESM) + browser half copied to lib/client.js
|
|
122
|
+
dsh plugin --profile web add <path to this repo> # the CLI ships with the app; the spec can be a Git URL, a local path, or a registry version
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Installing does three things: `pnpm add` into the profile (`link:` for local paths),
|
|
126
|
+
appends the package name to `dsh.profile.bundles`, and the loader composes it. When the
|
|
127
|
+
profile has HMR enabled, changes take effect immediately (no restart; running sessions
|
|
128
|
+
start tagging right away); otherwise reload the page or restart the profile.
|
|
129
|
+
|
|
130
|
+
- All `@deepseek-ai/*` in `peerDependencies` are declared `"*"` — the compatibility
|
|
131
|
+
precheck passes on any DSH 0.2.x; the host packages actually imported at runtime are
|
|
132
|
+
also listed as **exact-version dependencies** (resolved with the package; `link:` dev
|
|
133
|
+
installs are served by this repo's own node_modules).
|
|
134
|
+
- **Node ≥ 22.19** required: the stores build on the built-in `node:sqlite`, no native
|
|
135
|
+
modules. A CLI/`web` profile runs on Node; the desktop app supplies an Electron
|
|
136
|
+
RunAsNode runtime; both need the `node:sqlite` version that Node 22.19 provides.
|
|
137
|
+
- **Tool-constructor resolution**: `config.defineTool` (host-injected, used by in-tree
|
|
138
|
+
glue) first, then dynamic `import('@deepseek-ai/dsh-tools')` (a hard dependency,
|
|
139
|
+
physically resolvable in every install shape). If both are unavailable the mount **fails
|
|
140
|
+
loudly** — the ctx_* tools are the only entry point for reclaim tags; no silent
|
|
141
|
+
half-boot.
|
|
142
|
+
- Two loading modes: **patch-overlay / file URL** (development: overlay yml +
|
|
143
|
+
`config.defineTool` injection) and **profile install** (production: package-name line +
|
|
144
|
+
link dependency). The production path is the `dsh plugin add` above.
|
|
145
|
+
|
|
146
|
+
Uninstall / disable: disable the bundle on the GUI Plugins page (writes `disabled` into
|
|
147
|
+
the profile patch), or `dsh plugin --profile web remove @elvisw/dsh-magic-context`.
|
|
148
|
+
|
|
149
|
+
## Configuration
|
|
150
|
+
|
|
151
|
+
Two ways to change configuration, with different semantics (see the
|
|
152
|
+
[config UI contract](docs/dsh-plugin-config-ui-contract.md)):
|
|
153
|
+
|
|
154
|
+
- **GUI settings card**: exposes `policy.*` (incl. historian generation cap / ceiling /
|
|
155
|
+
timeout), `historianEnabled`, `registerCompactionEngine`, `journal.*`, `maintenance.*`,
|
|
156
|
+
`historian.*` and other volatile fields. The two provider/model **route pins**
|
|
157
|
+
(maintenance verify, historian generation) prefer a dropdown fed by the **host's
|
|
158
|
+
configured model catalog** (client `remote.session.modelCatalog()`), with
|
|
159
|
+
"Auto = follow the session route" and clearing; shells without that RPC fall back to
|
|
160
|
+
plain text (values remain hand-editable). Writes go through the settings chain:
|
|
161
|
+
non-volatile keys are preserved untouched, untouched fields never materialize into
|
|
162
|
+
override rows — **saving takes effect immediately** (the host side always reads through
|
|
163
|
+
`liveNumber/liveBoolean/liveString/liveRoute` at the decision point).
|
|
164
|
+
- **Hand-written profile override rows**: `config` **replaces** the package patch's config
|
|
165
|
+
wholesale — it is **not** a deep merge. Writing only `memory:` erases
|
|
166
|
+
`registerCompactionEngine: false`. When hand-writing overrides you must spell out every
|
|
167
|
+
key you want to keep.
|
|
168
|
+
|
|
169
|
+
The bundle's built-in config is one line: `registerCompactionEngine: false` — a
|
|
170
|
+
conservative first install that keeps the host compaction engine in place (memory, reclaim
|
|
171
|
+
and historian are on by default). To take over compaction:
|
|
172
|
+
|
|
173
|
+
```yaml
|
|
174
|
+
- id: magic-context-dsh
|
|
175
|
+
name: '@elvisw/dsh-magic-context'
|
|
176
|
+
config:
|
|
177
|
+
registerCompactionEngine: true
|
|
178
|
+
- id: compaction-basic
|
|
179
|
+
name: '@deepseek-ai/dsh-compaction-basic'
|
|
180
|
+
disabled: true # mutually exclusive; taking over requires disabling the host engine too
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
Configuration reference (full types in [src/dsh/config.ts](src/dsh/config.ts); all keys
|
|
184
|
+
writable as profile override rows unless noted):
|
|
185
|
+
|
|
186
|
+
| Group | Keys (defaults) | Notes |
|
|
187
|
+
|---|---|---|
|
|
188
|
+
| Master switches | `enabled` (true) · `registerTools` (true) · `registerStatusCommand` (true) · `sessionNotices` (true) · `reduceGuidance` (true) · `searchHint` (true) | `enabled: false` stays loaded but fully inert; `sessionNotices` controls the management notice rows in the session stream |
|
|
189
|
+
| Compaction seam | `registerCompactionEngine` (code default: mount when resolvable; **ships false in the bundle**) · `compactionBase` (host-injected base class) | Taking over requires disabling compaction-basic too; pre-step `reconcileEngine` mounts/unmounts dynamically every step |
|
|
190
|
+
| Pressure policy | `policy.*`: `executeThreshold` (65) · `forceThreshold` (85) · `ttlMs` (5 min) · `assumedContextWindow` (256k) · `protectedToolResults` (8) · `historianTimeoutMs` (120 s) · `historianMaxTokens` (8192, raised to 8192 if set lower) · `historianMaxTokensCeiling` (32768) · `baselineTokens` (2000) · `memoryBudgetTokens` (8000) · `memoryLimit` (40) · `forceWaitReadyMs` (0) | Thresholds take effect at the next decision point (incl. `/ctx-status` and the compaction-engine paths). `compartmentGuardMode` / `compartmentEntrantTokens` (publish guards) were retired and are no longer configurable |
|
|
191
|
+
| historian | `historianEnabled` (true) · `historian.{provider, model}` (**pinned as a pair**; empty = follow the session's last route) · `historian.reasoningEffort` (optional, blank = model default) | Generation route for out-of-band digests and `/compact` summaries; the GUI card has "Historian provider/model" dropdowns (Auto = follow session, recommended) and a free-text reasoning-effort field for models that expose effort ids (it also applies while the route is Auto). A provider-level `OUTPUT_TOKEN_LIMIT` empty completion is retried with the normal cap escalation. The only LLM spend besides verify |
|
|
192
|
+
| Project memory | `memory.{}`: `enabled` (true, on by default since 0.9.0 — opt out with `enabled: false`) · `dbPath` · `project` (omitted = session cwd) · `domainProjects` · `shareCategories` · `autoPromote` (true) · `write` (true) | `write: false` makes `ctx_memory` read-only |
|
|
193
|
+
| Retrieval / vectors | `memory.embedBackfill` (true, query-side inline backfill) · `memory.vectorBackfill` (true, maintenance-tick backfill) · `memory.vectorBackfillLimit` (24 rows/tick) | Any vector-lane failure fails open to FTS |
|
|
194
|
+
| S(t) decay | `memory.scoring.{enabled (true), alpha (0.4), beta (0.2), archiveThreshold (2), halfLives}` | Stats are always collected; the distribution default enabled=true takes over ranking; profile-JSON only, not on the settings card |
|
|
195
|
+
| Global domains | `memory.global.machine.{enabled (true), excludeProjects, autoStage (true)}` · `memory.global.user.{render (true), collect (true), review (true)}` · `memory.global.review.batchLimit` (50) | Defaults all on: staging can be automated (≤3/pass, paused at ≥10 pending candidates), **publishing is always human**; LLM classification failure is fail-closed |
|
|
196
|
+
| User profile | `memory.global.user.{render (true), collect (false), review (false)}` | Read / collect / review are independent halves; the two halves that write to the shared store are off by default |
|
|
197
|
+
| Domain resolution | `memory.domains.source` (`adapter` \| `contract`) | `contract` is a fallback pole for comparison, not a supported end state |
|
|
198
|
+
| Maintenance | `maintenance.{enabled, intervalMs (30 min), verifyProvider, verifyModel}` | LLM verify needs an explicit route (unpinned = follow the conversation's latest route); the GUI card offers host-catalog dropdowns, Auto = unpinned (same picker for both pins) |
|
|
199
|
+
| Observability | `journal.{enabled (true), level (info), retentionDays (30), mirror (true)}` | level/mirror apply to the next write; a journal that was off at mount needs a restart to turn on at runtime; `retentionDays` has a `min(1)` floor against accidental pruning. §N§ tag rows have no age-based TTL; this adapter has no automatic message/session deletion path today |
|
|
200
|
+
|
|
201
|
+
## Tools & commands
|
|
202
|
+
|
|
203
|
+
Agent tools (registered at mount; `registerTools: false` turns them off):
|
|
204
|
+
|
|
205
|
+
| Tool | What it does |
|
|
206
|
+
|---|---|
|
|
207
|
+
| `ctx_reduce` | Parses MC range syntax (`"3-5,8"`) → **queues only**; landing is a priced bust that waits for the reclaim band, never spontaneous |
|
|
208
|
+
| `ctx_expand` | **Returns the original text as a new result**, read from the persisted log by `tag` (single), the deprecated `tags` alias, or `message` (a DSH log event seq in the current session for an already dropped item; `[compacted §C…§]` nodes are not accepted) — the old placeholder and its spent tag stay in place. Tag is primary; message is a fallback, not a general history browser. `start`/`end` (inclusive DSH log event seq, not upstream message ordinals) read a read-only `user`/`assistant`/`tool/result` transcript without requiring a drop; `verbose` previews 200 characters per part under the shared 15k budget. `[compacted §C…§]` bookkeeping is excluded while `[dropped §N§]` stays literal when the range reads raw history; a range whose readable events are all still live returns a live-surface sentence instead of duplicating them. No recovery is promised once the raw event is gone |
|
|
209
|
+
| `ctx_memory` | The shared memory store's read/write port. Reads: `list` / `search` / `get`; writes: `write` / `update` / `archive` / `merge` (with MC's normalized content hashing, mutation log and authority guards in the loop throughout); `review_global` (surfaces machine/org domain candidates one by one as approval cards; publishes only on approval); `promote` (stages a single project memory instantly — a manual lane with no recurrence gate). Every action accepts `project` (absolute path or git root) to operate on another project |
|
|
210
|
+
|
|
211
|
+
Slash commands (`registerStatusCommand: false` disables this command surface):
|
|
212
|
+
|
|
213
|
+
| Command | What it does |
|
|
214
|
+
|---|---|
|
|
215
|
+
| `/ctx-status` | pressure / decisions / reclaim ledger / compartments / baseline / policy |
|
|
216
|
+
| `/ctx-flush` | mark this session's pending `ctx_reduce` drops for landing on the next message; reports requested/already/pending counts; when the queue is empty, reports the last landed drop count/time for this session; starts no historian, recomp, summary, or model call |
|
|
217
|
+
| `/ctx-recomp` `all` \| `last:<n>` \| `<startSeq>-<endSeq>` | re-runs the historian and **replaces the stored digest in place** (ranges snap to compartments, never split; identity and landed placeholders unchanged, the next pre-step rebuilds the baseline) |
|
|
218
|
+
| `/ctx-profile` `confirm` \| `reject` \| `retire` | confirm / reject / retire user-profile candidates; promotion into the shared profile happens at the next maintenance tick |
|
|
219
|
+
| `/ctx-global` `add` \| `remove` \| `status` \| `promote` \| `approve` \| `reject` | the manual lane for global-domain membership and candidate approval (same gate→publish path as the approval cards, `source_type=user`) |
|
|
220
|
+
|
|
221
|
+
## UI & telemetry
|
|
222
|
+
|
|
223
|
+
Both UI capabilities ride the same browser half (`src/client/index.js`, copied verbatim to
|
|
224
|
+
`lib/client.js` at build time):
|
|
225
|
+
|
|
226
|
+
- **Settings card on the Plugins page**: visual editing of the volatile config above;
|
|
227
|
+
saving takes effect immediately (see "Configuration").
|
|
228
|
+
|
|
229
|
+

|
|
230
|
+
|
|
231
|
+

|
|
232
|
+
|
|
233
|
+
- **`shell.overlay` telemetry badge + capsule panel**: collapsed state shows the occupancy
|
|
234
|
+
percentage; the panel holds two metric rows, the beat, and a **live operation record**
|
|
235
|
+
(up to 12 entries, adjacent identical operations folded as `×N`): 🧠 memory write ·
|
|
236
|
+
🔎 memory load · 🗑️ reclaim queued · 🧭 original restored · ✂️ context compacted ·
|
|
237
|
+
🗑️ context dropped · 🧭 archived-stored · 🧰 maintenance sweep · ⚠️ failure. Clicking
|
|
238
|
+
outside the panel/badge, Esc, or window blur closes it.
|
|
239
|
+
|
|
240
|
+

|
|
241
|
+
- Data comes from the plugin's own HTTP routes (the harness's Remote event whitelist is a
|
|
242
|
+
compile-time constant; the supported seam for third-party bundles is
|
|
243
|
+
`ctx.webServer.register`):
|
|
244
|
+
- `GET /mc-telemetry/summary` — one-shot snapshot (adapter / project / health + recent
|
|
245
|
+
events)
|
|
246
|
+
- `GET /mc-telemetry/events` — SSE live tail
|
|
247
|
+
- **Security**: the routes are loopback-only with no token auth, so they **emit counts and
|
|
248
|
+
one-line summaries only** — no message bodies, no file paths, no credentials.
|
|
249
|
+
- **Languages**: browser-side `magic-context` namespace dictionaries (zh/en); Settings →
|
|
250
|
+
General switches instantly without a refresh; the `session-notice` rows written into the
|
|
251
|
+
session stream (model-visible) stay English constants (to avoid cached-prefix churn from
|
|
252
|
+
mid-session language switches). Mechanics in the
|
|
253
|
+
[UI telemetry contract](docs/dsh-plugin-ui-telemetry-contract.md).
|
|
254
|
+
|
|
255
|
+
## Observability & operations
|
|
256
|
+
|
|
257
|
+
Desktop **does not persist `ctx.logger` output**, so the plugin writes its decisions and
|
|
258
|
+
outcomes into its own append-only journal:
|
|
259
|
+
|
|
260
|
+
- `~/.local/share/cortexkit/magic-context-dsh-poc/dsh-magic-context.db` → `journal` table
|
|
261
|
+
(structured, SQL-queryable)
|
|
262
|
+
- `~/.local/share/cortexkit/magic-context-dsh-poc/activity.log` → single-line text mirror
|
|
263
|
+
(`tail`/grep friendly, auto-rotates to `.1` past 5 MiB)
|
|
264
|
+
|
|
265
|
+
**Privacy**: message bodies are **never logged**. Only counts, tag numbers, token
|
|
266
|
+
estimates, reasons and durations; strings truncate at 300 chars, arrays cap at 20 items
|
|
267
|
+
(`redactData` as the backstop).
|
|
268
|
+
|
|
269
|
+
Journal coverage (by group): lifecycle (`boot` / `config-drift` / `session-first-seen`);
|
|
270
|
+
reclaim & compaction (`pass` — every execute recorded, with **tokensBefore→After
|
|
271
|
+
net-reclaim proof** and defer reasons, `drop-landed`, `compartment-published`/`-recomp`/
|
|
272
|
+
`-guard`, `force-path`, `emergency-reclaim`, `context-pressure`); historian & baseline
|
|
273
|
+
(`historian` — start/done/failed pairs with LLM usage, `baseline`, `session-notice`,
|
|
274
|
+
`wire-repair`); memory (`memory-recall` / `profile-recall` / `memory-promote` /
|
|
275
|
+
`memory-stats` / `vector-lane` / `search-hint` / `project-drift` / `global-review`);
|
|
276
|
+
maintenance (`maintenance`); tools & engine (`tool-call` / `engine` / `error` — every
|
|
277
|
+
exception swallowed fail-open).
|
|
278
|
+
|
|
279
|
+
### Operations commands
|
|
280
|
+
|
|
281
|
+
```sh
|
|
282
|
+
npm test # vitest run
|
|
283
|
+
npm run gate # full gate: typecheck + suite + build + acceptance + memory audit + records
|
|
284
|
+
npm run doctor # read-only health report: corpus fence / event-lane heartbeat / dangling runs / embedding lane
|
|
285
|
+
|
|
286
|
+
node scripts/mc-report.mjs --days 7 [--json] [--session <id>] # journal retrospective report
|
|
287
|
+
node scripts/mc-acceptance.mjs [--hours 72 --json] # corpus acceptance, exit 1 on failure
|
|
288
|
+
npm run phase # phase gate: run one phase's suite with verdict and blind spots
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
The retrospective report includes: stores and status, per-kind/per-day counts, key metrics
|
|
292
|
+
(execute/defer ratio and reason distribution, net reclaim, historian failure rate and
|
|
293
|
+
duration, emergency reclaims, tool calls), recent event details and health hints ("no
|
|
294
|
+
execute pass in the window" / "historian never ran" / "errors present" / "latest journal
|
|
295
|
+
event older than 24h", …).
|
|
296
|
+
|
|
297
|
+
`scripts/` specialists: retrieval-weight A/B (`retrieval-eval`), S(t) ranking offline diff
|
|
298
|
+
(`score-diff`), dilution & fold dashboard (`report-dilution`), domain-hit stats
|
|
299
|
+
(`report-hits`), historian failure classification (`report-classify`), embedding-model
|
|
300
|
+
precheck (`embedder-precheck`), reference-seed rebuild (`npm run build:seeds`),
|
|
301
|
+
panel-category validation (`mc-records-check`), i18n check (`npm run check:i18n`).
|
|
302
|
+
|
|
303
|
+
## Architecture
|
|
304
|
+
|
|
305
|
+
```
|
|
306
|
+
src/
|
|
307
|
+
dsh/ # ← the ONLY directory allowed to import @deepseek-ai/* (the
|
|
308
|
+
# anti-corruption layer). Event names, payload shapes and the
|
|
309
|
+
# surface vocabulary all live here; a DSH upgrade touches this
|
|
310
|
+
# directory only.
|
|
311
|
+
core/ # Neutral logic and storage: policy/stores/journal/memory-*/domains.
|
|
312
|
+
# No DSH dependency.
|
|
313
|
+
client/ # Browser half (settings card + telemetry badge), plain JS,
|
|
314
|
+
# copied verbatim to lib/client.js at build time.
|
|
315
|
+
index.ts # Composition root: boot probe (fail-loud) → seam listeners →
|
|
316
|
+
# neutral stores.
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
Isolation discipline (DSH is in developer preview; breaking changes are expected — this
|
|
320
|
+
package's structural answer):
|
|
321
|
+
|
|
322
|
+
- **Fail-loud capability probing**: `probeDshSeams` validates seam availability at boot and
|
|
323
|
+
throws when absent — never silently pretends to manage context;
|
|
324
|
+
- **Version fences**: the adapter DB schema chain is at **v11** (forward migrations; a
|
|
325
|
+
newer DB refuses to open); the **own corpus** `memories.db` inherits the **v95** starting
|
|
326
|
+
point (switched 2026-10-13, numbering owned by this plugin; `MEMORY_SCHEMA_MAX_VERSION`
|
|
327
|
+
guards the migration line) — beyond it, reads refuse and writes degrade to read-only
|
|
328
|
+
with a loud warning;
|
|
329
|
+
- **Tests as probes**: the integration tests double as seam-contract tests — rerun after a
|
|
330
|
+
DSH upgrade and breakage localizes to `src/dsh/`;
|
|
331
|
+
- **Two-database layout**:
|
|
332
|
+
- **Adapter DB** `~/.local/share/cortexkit/magic-context-dsh-poc/dsh-magic-context.db`
|
|
333
|
+
(tags / usage / pending_drops / compartments / baseline / domains / queues / journal…,
|
|
334
|
+
schema v11);
|
|
335
|
+
- **Own corpus** `~/.local/share/cortexkit/magic-context-dsh-poc/memories.db` (project
|
|
336
|
+
memories + global-domain rows + profile + vectors; the legacy `context.db` is sealed
|
|
337
|
+
and unread — the 2026-10-13 hard split; the upstream relationship is feature-following
|
|
338
|
+
only, no storage-compat duty);
|
|
339
|
+
- **Upstream parity ledger**: effective-behavior alignment and deliberate differences
|
|
340
|
+
against the OpenCode / Pi adapters are tracked in [PARITY.md](PARITY.md) (aligned /
|
|
341
|
+
host-imposed / intentional verdicts, each citing host files).
|
|
342
|
+
|
|
343
|
+
## Documentation index
|
|
344
|
+
|
|
345
|
+
(The linked documents are written in Chinese.)
|
|
346
|
+
|
|
347
|
+
**Contracts**: [memory write](docs/dsh-plugin-memory-write-contract.md) ·
|
|
348
|
+
[memory promotion](docs/dsh-plugin-memory-promotion-contract.md) ·
|
|
349
|
+
[memory acceptance](docs/dsh-plugin-memory-acceptance.md) ·
|
|
350
|
+
[config UI](docs/dsh-plugin-config-ui-contract.md) ·
|
|
351
|
+
[UI telemetry](docs/dsh-plugin-ui-telemetry-contract.md) ·
|
|
352
|
+
[upgrade follow-up](docs/dsh-plugin-upgrade-followup.md) ·
|
|
353
|
+
[hooks coverage](docs/dsh-plugin-hooks-coverage-2026-10-08.md)
|
|
354
|
+
|
|
355
|
+
**Design decisions**: [port feasibility (seam map)](docs/dsh-port-feasibility-2026-10-06.md) ·
|
|
356
|
+
[platform takeover & global domains](docs/dsh-plugin-platform-takeover-and-global-domains-2026-10-09.md) ·
|
|
357
|
+
[dreamer vector decision](docs/dsh-plugin-dreamer-vector-decision-2026-10-08.md) ·
|
|
358
|
+
[memory mechanisms inventory](docs/memory-mechanisms-inventory-2026-10-09.md) ·
|
|
359
|
+
[upstream source analysis](docs/upstream-source-analysis-2026-10-09.md) ·
|
|
360
|
+
[global-domain source finding](docs/global-domain-source-finding-2026-10-10.md) ·
|
|
361
|
+
[memory architecture challenge](docs/memory-architecture-challenge-2026-10-10.md)
|
|
362
|
+
|
|
363
|
+
**Retrospectives & runbooks**: [test design audit](docs/dsh-plugin-test-design-audit-2026-10-07.md) ·
|
|
364
|
+
[operations runbook](docs/dsh-plugin-operations-runbook-2026-10-10.md) ·
|
|
365
|
+
[surface write audit](docs/dsh-surface-write-audit-2026-10-09.md) ·
|
|
366
|
+
[local embedding runtime audit](docs/local-embedding-runtime-audit-2026-10-15.md)
|
|
367
|
+
|
|
368
|
+
**Reports**: [dreamer token usage](docs/reports/dreamer-token-usage.md) ·
|
|
369
|
+
[memory solutions comparison](docs/reports/memory-solutions-comparison.md)
|
|
370
|
+
|
|
371
|
+
## Known limits
|
|
372
|
+
|
|
373
|
+
- Historian triggering and budgeting use **chars/4 estimates**, not a real tokenizer
|
|
374
|
+
(retrieval vectorization does use a real one); the four-tier digest is produced in **one
|
|
375
|
+
call** (MC accumulates across calls);
|
|
376
|
+
- `review_global` approval cards must be raised inside an agent turn; headless without a
|
|
377
|
+
responder it refuses explicitly with zero state change;
|
|
378
|
+
- A journal that was off at mount needs a restart to turn on at runtime (all other
|
|
379
|
+
journal / threshold changes apply immediately);
|
|
380
|
+
- Desktop does not persist the harness logger — observability rests entirely on the
|
|
381
|
+
self-kept journal.
|
|
382
|
+
|
|
383
|
+
## Contributing
|
|
384
|
+
|
|
385
|
+
- Contributing guide: [CONTRIBUTING.md](CONTRIBUTING.md) (environment, code conventions,
|
|
386
|
+
PR flow)
|
|
387
|
+
- Security reports go through the private channel: [SECURITY.md](SECURITY.md)
|
|
388
|
+
- Code of conduct: [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md)
|
|
389
|
+
- Changelog: [CHANGELOG.md](CHANGELOG.md)
|
|
390
|
+
|
|
391
|
+
This repo uses npm as its only package manager (`package-lock.json` is the truth); CI runs
|
|
392
|
+
typecheck → test → build → check:i18n on Node 22.x / 24.x.
|
|
393
|
+
|
|
394
|
+
## Provenance & license
|
|
395
|
+
|
|
396
|
+
### Difference from the upstream DSH adapter
|
|
397
|
+
|
|
398
|
+
This repository is a fork of [`wk544863858/dsh-plugin-magic-context`](https://github.com/wk544863858/dsh-plugin-magic-context)
|
|
399
|
+
(npm `dsh-plugin-magic-context`). The upstream's last public release is `dsh-plugin-magic-context@0.11.2`
|
|
400
|
+
(2026-11-11); this fork published as `@elvisw/dsh-plugin-magic-context` from `0.12.0` through `0.12.3`,
|
|
401
|
+
and publishes as **`@elvisw/dsh-magic-context`** from `0.13.0`. Its versions and tags belong to the
|
|
402
|
+
fork. The upstream repository and npm package remain under their original maintainer; this fork does
|
|
403
|
+
not modify them.
|
|
404
|
+
|
|
405
|
+
Differences from upstream `0.11.2`, accumulated through `0.13.0`:
|
|
406
|
+
|
|
407
|
+
- **Recovery semantics**: `ctx_expand` no longer rewrites placeholders in place. It reads the persisted
|
|
408
|
+
original `tool/result`, returns it as a new tool result, and assigns a new tag. The old placeholder is
|
|
409
|
+
unchanged, the old tag stays dropped, and reducing it again is a no-op (`already dropped`). This is a
|
|
410
|
+
breaking change.
|
|
411
|
+
- **Raw reads after Historian**: `ctx_expand` accepts a `message` locator (the current session's DSH log
|
|
412
|
+
event seq, including an original `tool/result` shadowed by a Historian compartment). It does not rerun
|
|
413
|
+
the original tool and does not rewrite summaries or compartments.
|
|
414
|
+
- **Manual flush**: `/ctx-flush` marks the current session's pending drops for the next pre-step to land;
|
|
415
|
+
it does not start Historian, recomp, summarization, or a model call.
|
|
416
|
+
- **Durable drop state**: `ctx_reduce`/`ctx_expand` decide from the `pending_drops` `none`/`pending`/
|
|
417
|
+
`landed` state instead of whether a placeholder is still on the current surface; a restored old tag no
|
|
418
|
+
longer produces a fake “Queued” receipt.
|
|
419
|
+
- **Tag retention**: the mount-time 30-day tag prune, the `tags.retentionDays` config, and
|
|
420
|
+
`AdapterStores.pruneTags` are removed. An old profile's key is kept but ignored, with at most one warning
|
|
421
|
+
per process.
|
|
422
|
+
- **Schema and package name**: the plugin DB moves to v11 (`pending_drops.flush_requested`, automatic v10
|
|
423
|
+
migration). The npm package was `@elvisw/dsh-plugin-magic-context` in `0.12.x`; `0.13.0` renames it to
|
|
424
|
+
`@elvisw/dsh-magic-context` without changing the loader row id `magic-context-dsh`, the settings
|
|
425
|
+
namespace, the plugin data directory `magic-context-dsh-poc`, the schema, or the stored format.
|
|
426
|
+
- **Upgrade migration**: a `0.12.x` profile patch row still says the old package name; the DSH loader
|
|
427
|
+
matches by both `id` and `name` and skips a mismatched row, so run
|
|
428
|
+
`tools/migrate-profile-package-name.mjs --patch <cordis.patch.yml>` once before opening Settings.
|
|
429
|
+
Plugin memories, journal, schema and a custom `dataDir` stay at the same paths; the rename performs no
|
|
430
|
+
data migration. The `0.13.0` host gate is config-effective only and did not open the old database.
|
|
431
|
+
|
|
432
|
+
Because the row id is shared, co-installing upstream `dsh-plugin-magic-context`, the `0.12.x` fork
|
|
433
|
+
package, and this package is **unsupported**; remove the old package before installing the new one. The
|
|
434
|
+
gate observed only that a config dump accepts both rows and keeps both names. The loader keeping one
|
|
435
|
+
duplicate-id row and the settings editor hiding duplicate ids are source-level inferences, not
|
|
436
|
+
gate observations. This fork guarantees its own plugin behavior and data migration, not long-term
|
|
437
|
+
UX/API compatibility with upstream 0.11.x; compatibility semantics target the original
|
|
438
|
+
`cortexkit/magic-context`, with DSH as the host.
|
|
439
|
+
|
|
440
|
+
### Copyright and third parties
|
|
441
|
+
|
|
442
|
+
- **Upstream DSH adapter** (`wk544863858/dsh-plugin-magic-context`, npm `dsh-plugin-magic-context@0.11.2`,
|
|
443
|
+
MIT, Copyright (c) 2026 wukai — the DeepSeek Harness adapter in this repository): the direct upstream of
|
|
444
|
+
this fork. Fork modifications are Copyright (c) 2026 elvisw, also under MIT.
|
|
445
|
+
- **magic-context** (MIT, Copyright (c) 2025 Ufuk Altinok — magic-context): the derivative origin of this
|
|
446
|
+
repo. Extracted from upstream tag v0.46.0 (`651c105a9`); the adapter's own commits were replayed verbatim
|
|
447
|
+
from `e34eda955` (2026-10-08) on the local `dsh` branch.
|
|
448
|
+
- **DeepSeek Harness** (MIT): consumed as a dependency, not vendored. Code written against 0.2.1-rc.1
|
|
449
|
+
(checkout `1600d8a1e`, npm dist-tag `next`; note their `latest` tag trails a release line — exact pins are
|
|
450
|
+
the devDependencies).
|
|
451
|
+
- Vendored third-party: `vendor/onnx/` (onnxruntime-web WASM subset, MIT © Microsoft),
|
|
452
|
+
`tests/helpers/mock-adapter.ts` (DSH test tree, verbatim). Details in [NOTICE](NOTICE);
|
|
453
|
+
license in [LICENSE](LICENSE).
|