Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ node_modules/
*.tgz
coverage/
.memdb/
.memtrace-workspace
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ npx -y @deepseek-ai/dsh plugin --profile web add github:syncable-dev/dsh-plugin-
dsh --profile web --dump-config | grep -A4 'id: dsh-plugin-memtrace'
```

The row pins `command: memtrace` (override with `MEMTRACE_BIN`; for a zero-install fetch restate the row with `command: npx` and `args: ['-y', 'memtrace', 'mcp']`). One child serves the whole profile — give a project its own graph by restating the `mcp-memtrace` row in the profile's `cordis.patch.yml` with `cwd: <repo root>` (restate the whole row, DSH does not deep-merge).
The row pins `command: memtrace` (override with `MEMTRACE_BIN`; for a zero-install fetch restate the row with `command: npx` and `args: ['-y', 'memtrace', 'mcp']`). With `perWorkingDirectory`, each tool call runs in the Session's working directory — see [How it works](#how-it-works) for the stock-dsh fallback.

Then open the Web UI and index the workspace:

Expand Down Expand Up @@ -96,7 +96,7 @@ flowchart LR
Two Cordis rows, both owned by this bundle:

1. **`dsh-plugin-memtrace`** — reads `skills/*/SKILL.md` and registers each skill at apply time. Unload disposes them.
2. **`mcp-memtrace`** — official MCP client, `serverName: memtrace`, stdio, `memtrace mcp` with the command pinned (`MEMTRACE_BIN`, else `memtrace` on PATH — no per-child npx fetch). No workspace flag: `memtrace mcp` anchors on its working directory and opens the repository's own `.memdb` — per project once the host keys MCP children per session workspace; per restated row today.
2. **`mcp-memtrace`** — official MCP client, `serverName: memtrace`, stdio, `memtrace mcp` with the command pinned (`MEMTRACE_BIN`, else `memtrace` on PATH — no per-child npx fetch). No workspace flag: `memtrace mcp` anchors on its working directory and opens the repository's own `.memdb`. A listing child runs in the row's `cwd`; with `perWorkingDirectory: true`, each tool call runs in a child started in the calling Session's working directory, so each project gets its own store, and a Session on a git worktree resolves to the main repository's store. This needs a dsh-mcp-client with the option; a stock dsh ignores the key, so restate the row with `cwd: <repo root>`.

We do **not** patch the filesystem skill provider's config. That row is last-write-wins; runtime registration does not collide with other skill packs.

Expand Down Expand Up @@ -136,25 +136,26 @@ All 27 bundles live under [`skills/`](skills/).

| Variable | Effect |
| --- | --- |
| `MEMTRACE_BIN` | Absolute path or command the MCP row launches instead of the `memtrace` on PATH (also the shipped launcher's preference) |
| `MEMTRACE_BIN` | Absolute path or command the MCP row launches instead of the `memtrace` on PATH |

Override the MCP row in the profile's `cordis.patch.yml` if you already run a Streamable HTTP Memtrace endpoint — restate the whole `mcp-memtrace` config (DSH does not deep-merge).

MCP stdio carries no per-call session identity: one child receives every session's calls, so repository identity must travel with the process — `memtrace mcp` with no flags opens the `.memdb` anchored by its working directory (the project-editor pattern from `memtrace mcp --help`). dsh-mcp-client (0.2.2-rc.5) mounts one child per row with a static `cwd`, so per-session keying needs a host-side change; until then, restating the `mcp-memtrace` row with `cwd: <repo root>` gives that project its own child, its own store, and no split-brain refusal (memtrace still refuses to index a repo into a store other than the one that path resolves to).
On a stock dsh, `perWorkingDirectory` is ignored: restate the `mcp-memtrace` row in the profile's `cordis.patch.yml` with `cwd: <repo root>` (restate the whole row, DSH does not deep-merge).

## Compatibility

| Surface | Status |
| --- | --- |
| Harness | DeepSeek Harness `>=0.1.0-rc.6 <0.3.0` — verified against `0.2.2-rc.5` (current release) |
| Per-Session routing | Needs a dsh-mcp-client with `perWorkingDirectory`; stock `0.2.2-rc.5` needs the row restated with `cwd` |
| Compat check | `engines.dsh` decides on DSH `0.2.1-alpha.3`+; older DSH reads the `@deepseek-ai/dsh` peer range |
| Node | `>=22.19.0` (DSH `0.2.x` itself requires Node `>=24.9`; the desktop app bundles its own runtime) |
| Platforms | macOS, Linux, Windows (Memtrace native binary via npm optional deps) |
| Network | None required after the Memtrace binary is present |

## Permissions & data

- Spawns `memtrace mcp` (`MEMTRACE_BIN` overrides the command); the per-project working directory comes from the session-workspace keying described above, or your restated row's `cwd` (reads the repo to index; writes `.memdb` next to the project).
- Spawns `memtrace mcp` (`MEMTRACE_BIN` overrides the command) as described under How it works (reads the repo to index; writes `.memdb` next to the project).
- Registers skills from this package only.
- Does not send code to Memtrace cloud. Local graph.

Expand Down
15 changes: 12 additions & 3 deletions README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ npx -y @deepseek-ai/dsh plugin --profile web add github:syncable-dev/dsh-plugin-
dsh --profile web --dump-config | grep -A4 'id: dsh-plugin-memtrace'
```

row 固定 `command: memtrace`(用 `MEMTRACE_BIN` 覆盖;零安装可整行重述为 `command: npx`、`args: ['-y', 'memtrace', 'mcp']`)。一个 child 服务整个 profile —— 想让某个项目有自己的图谱,在 profile 的 `cordis.patch.yml` 里整行重述 `mcp-memtrace` 并设 `cwd: <仓库根目录>`(DSH 不做深度合并,需重述整行)。
row 固定 `command: memtrace`(用 `MEMTRACE_BIN` 覆盖;零安装可整行重述为 `command: npx`、`args: ['-y', 'memtrace', 'mcp']`)。`perWorkingDirectory` 让每次工具调用都在 Session 的工作目录里运行 —— 原版 dsh 的 `cwd` 回退见「工作原理」。

然后在 Web UI 里:

Expand All @@ -79,6 +79,7 @@ row 固定 `command: memtrace`(用 `MEMTRACE_BIN` 覆盖;零安装可整行
## 兼容性

- DeepSeek Harness `>=0.1.0-rc.6 <0.3.0`(已对照当前版本 `0.2.2-rc.5` 验证)。
- 按 Session 路由需要带 `perWorkingDirectory` 的 dsh-mcp-client;原版 `0.2.2-rc.5` 需整行重述并设 `cwd`。
- DSH `0.2.1-alpha.3+` 以 `engines.dsh` 判定兼容;更早的 DSH 读取 `@deepseek-ai/dsh` peer 范围。
- Node `>=22.19.0`(DSH `0.2.x` 自身要求 Node `>=24.9`;桌面应用自带运行时)。

Expand All @@ -87,11 +88,19 @@ row 固定 `command: memtrace`(用 `MEMTRACE_BIN` 覆盖;零安装可整行
两条 Cordis 行,都由本包拥有:

1. **`dsh-plugin-memtrace`** — 读取 `skills/*/SKILL.md`,在 `apply` 时注册;卸载即注销。
2. **`mcp-memtrace`** — 官方 MCP 客户端,`serverName: memtrace`,`memtrace mcp`,命令固定(`MEMTRACE_BIN`,否则 PATH 上的 `memtrace` —— 不会按 child 重复拉取 npx)。不带 workspace 旗标:`memtrace mcp` 以其工作目录为锚,打开仓库自己的 `.memdb` —— 等 host 按会话 workspace 启动 child 后即为按项目;当前则靠整行重述本 row。
2. **`mcp-memtrace`** — 官方 MCP 客户端,`serverName: memtrace`,`memtrace mcp`,命令固定(`MEMTRACE_BIN`,否则 PATH 上的 `memtrace` —— 不会按 child 重复拉取 npx)。不带 workspace 旗标:`memtrace mcp` 以其工作目录为锚,打开仓库自己的 `.memdb`。用于列工具的 child 运行在 row 的 `cwd`;`perWorkingDirectory: true` 让每次工具调用都在发起调用的 Session 工作目录里启动 child,每个项目因此有自己的 store,git worktree 上的 Session 也会解析到主仓库的 store。这需要实现了该选项的 dsh-mcp-client;原版 dsh 会忽略该键,此时整行重述本 row 并设 `cwd: <仓库根目录>`。

不会去改文件系统 skill provider 的 `config`(整行覆盖、后写赢)。运行时注册不会和其他 skill 包打架。

MCP stdio 不携带每次调用的会话身份:一个 child 收到所有会话的调用,仓库身份必须随进程传递 —— 不带旗标的 `memtrace mcp` 打开由其工作目录锚定的 `.memdb`(`memtrace mcp --help` 的 project-editor 模式)。dsh-mcp-client(0.2.2-rc.5)按 row 挂一个静态 `cwd` 的 child,按会话 keying 需要 host 侧改动;在此之前,整行重述 `mcp-memtrace` 并设 `cwd: <仓库根目录>` 即可让该项目拥有自己的 child、自己的 store,也不会触发防脑裂拒绝。
原版 dsh 会忽略 `perWorkingDirectory`:在 profile 的 `cordis.patch.yml` 里整行重述 `mcp-memtrace` 并设 `cwd: <仓库根目录>`(DSH 不做深度合并)。

## 配置与权限

| 变量 | 作用 |
| --- | --- |
| `MEMTRACE_BIN` | MCP 行使用的命令(绝对路径或命令),覆盖 PATH 上的 `memtrace` |

`MEMTRACE_BIN` 与 `perWorkingDirectory` 见「工作原理」;启动的 `memtrace mcp` 读取仓库建索引,`.memdb` 写在项目旁。本包只注册自己的 skill,不向 Memtrace 云端发送代码,图谱保存在本机。

## 许可证

Expand Down
20 changes: 0 additions & 20 deletions bin/memtrace-mcp.js

This file was deleted.

26 changes: 8 additions & 18 deletions cordis.patch.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
# Memtrace bundle layer for DeepSeek Harness.
#
# Two rows, both owned by this package:
# Memtrace bundle layer for DeepSeek Harness: two rows owned by this package.
# - dsh-plugin-memtrace registers the Memtrace agent skills at apply time.
# - mcp-memtrace is the official DSH MCP client pointed at `memtrace mcp`.
#
# Per-project model: `memtrace mcp` with no workspace flag anchors on its
# working directory and opens the repository's own .memdb — the
# project-editor pattern from `memtrace mcp --help`. MCP stdio carries no
# per-call session identity, so the child must be keyed per session
# workspace by the host; dsh-mcp-client (0.2.2-rc.5) mounts one child per
# row with a static cwd, so per-session keying needs a host-side change.
# Until then, restate this row in the profile's cordis.patch.yml with
# `cwd: <repo root>` to give one project its own child and store; without
# a cwd the child inherits the app profile directory, which has no
# repository scope. The command is pinned (MEMTRACE_BIN, else `memtrace`
# on PATH) so per-project children never multiply npx fetches. Values stay
# literal except the scalar command expression: the 0.2.x patch composer
# mangles evaluated !!js values that return arrays.
# - mcp-memtrace is the official DSH MCP client running `memtrace mcp`.
# `memtrace mcp` anchors on its working directory. `perWorkingDirectory`
# routes each tool call to a child in the calling Session's directory; a
# dsh-mcp-client without it ignores the key, so restate this row with
# `cwd: <repo root>`. Values stay literal except the scalar command: the
# 0.2.x composer mangles `!!js` values that return arrays.
- insert:
- id: dsh-plugin-memtrace
name: dsh-plugin-memtrace
Expand All @@ -25,6 +14,7 @@
config:
serverName: memtrace
transport: stdio
perWorkingDirectory: true
command: !!js process.env.MEMTRACE_BIN || 'memtrace'
args:
- mcp
Expand Down
4 changes: 2 additions & 2 deletions docs/02_architecture_constraints.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
- Official `@deepseek-ai/*` packages are peer dependencies, never bundled.
- DSH compatibility declared via `engines.dsh` `>=0.1.0-rc.6 <0.3.0-0` (decides on DSH `0.2.1-alpha.3+`); the `@deepseek-ai/dsh` peer range mirrors it for older DSH.
- Patch rows must not overwrite another plugin's `config` (no deep merge).
- Bundle patch config stays literal: the 0.2.x patch composer mangles evaluated `!!js` values that return arrays (the mcp-memtrace row is static for this reason).
- MCP child store identity: `memtrace mcp` anchors on its working directory and opens the repo's own `.memdb` (per project); per-session keying of MCP children by workspace is a pending host-side change — until then a restated row's `cwd` sets the project. No shared named-workspace store; memtrace refuses cross-store indexing.
- Bundle patch config stays literal: the 0.2.x patch composer mangles evaluated `!!js` values that return arrays (values stay literal except the scalar command for this reason).
- MCP child store identity: `memtrace mcp` anchors on its working directory and opens the repo's own `.memdb`; the `mcp-memtrace` row sets `perWorkingDirectory: true`, so each tool call runs in a child started in the calling Session's working directory (a git worktree resolves to the main repo's store). This needs a dsh-mcp-client that implements the option; a stock dsh ignores it, and a restated row's `cwd` sets the project. No shared named-workspace store; memtrace refuses cross-store indexing.
- Node `>=22.19` (plugin floor; Harness `0.2.x` hosts themselves require `>=24.9`).
2 changes: 1 addition & 1 deletion docs/03_context_and_scope.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ C4Context
System_Ext(memtrace, "Memtrace MCP", "Local code-intelligence graph server")
Rel(dev, dsh, "asks the agent about the codebase")
Rel(dsh, plugin, "loads bundle layer", "Cordis")
Rel(plugin, memtrace, "stdio MCP", "memtrace mcp / npx memtrace mcp")
Rel(plugin, memtrace, "stdio MCP", "memtrace mcp")
```

Scope: this package. It does not index code itself; Memtrace does.
1 change: 0 additions & 1 deletion docs/04_solution_strategy.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
1. **Compose, don't reimplement.** MCP tools come from `@deepseek-ai/dsh-mcp-client` pointed at `memtrace mcp`.
2. **Register skills at runtime.** `ctx.skills.register()` avoids the wholesale-config trap on the filesystem skill provider.
3. **Plain ESM, no build.** Git installs work without a `prepare` script.
4. **npx fallback.** A machine without a global `memtrace` still gets the server via `npx -y memtrace mcp`.
4 changes: 1 addition & 3 deletions docs/05_building_block_view.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ C4Container
title Container diagram — dsh-plugin-memtrace
Container(skills, "Skill registrar", "index.js", "Registers every bundled SKILL.md on ctx.skills")
Container(patch, "Bundle patch", "cordis.patch.yml", "Inserts skill row + MCP client row")
Container(launcher, "MCP launcher", "bin/memtrace-mcp.js", "Resolves memtrace binary vs npx")
Container_Ext(mcpClient, "dsh-mcp-client", "Official DSH plugin", "Discovers tools as mcp__memtrace__*")
Container_Ext(server, "memtrace mcp", "stdio", "Graph tools")
Rel(patch, skills, "loads", "Cordis row")
Expand All @@ -19,10 +18,9 @@ C4 Level 3 — folders in this package, matching screaming architecture:

| Folder | Responsibility |
| --- | --- |
| `lib/` | Skill parse/load, MCP launch resolution, Cordis apply factory |
| `lib/` | Skill parse/load, Cordis apply factory |
| `skills/` | One Memtrace workflow per directory |
| `references/` | Shared MCP parameter spec for skill bodies |
| `bin/` | stdio launcher used when users point DSH at this package |
| `assets/` | Icon, hero, social preview |
| `docs/` | arc42 |
| `test/` | Fast node:test suite |
2 changes: 1 addition & 1 deletion docs/06_runtime_view.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
1. Profile lists `dsh-plugin-memtrace` in `dsh.profile.bundles`.
2. Cordis applies `cordis.patch.yml`.
3. Skill plugin `apply()` registers every `skills/*/SKILL.md`.
4. MCP client spawns `npx -y memtrace mcp` (or `MEMTRACE_BIN mcp`).
4. The MCP client runs `MEMTRACE_BIN`, else `memtrace` from PATH; the listing child runs in the row `cwd`, and each tool call runs in a child in the Session's working directory (`perWorkingDirectory`). On a stock dsh, restate the row with `cwd: <repo root>`.
5. Tools appear as `mcp__memtrace__find_symbol`, `mcp__memtrace__get_impact`, …

## Unload
Expand Down
2 changes: 1 addition & 1 deletion docs/07_deployment_view.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ dsh plugin --profile web add github:syncable-dev/dsh-plugin-memtrace

or `dsh plugin --profile web add dsh-plugin-memtrace` from npm.

The MCP child runs in the session working directory so Memtrace sees the repo the agent is editing.
Per-Session cwd needs a dsh-mcp-client with `perWorkingDirectory`; each tool call then runs in the Session's working directory so Memtrace sees the repo the agent is editing. A stock dsh needs the row restated with `cwd`.
2 changes: 2 additions & 0 deletions docs/09_architecture_decisions/0001-official-mcp-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Memtrace already speaks MCP (stdio `memtrace mcp`) for Claude, Cursor, Codex, an

We will insert `@deepseek-ai/dsh-mcp-client` with `serverName: memtrace` and spawn `memtrace mcp` (npx fallback). Skills are a separate Cordis row registered via `ctx.skills.register`.

Note (0.3.0): the npx fallback was superseded — the row now runs `MEMTRACE_BIN`, else `memtrace` from PATH.

## Consequences

Tools show up as `mcp__memtrace__*`. We inherit DSH MCP reconnect and naming rules. We cannot rename tools to bare names without a second native registrar.
3 changes: 2 additions & 1 deletion docs/11_risks_and_technical_debt.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
| Priority | Risk | Mitigation |
| --- | --- | --- |
| P1 | First DSH turn can race MCP discovery | `failOnStartupError: false` + reconnect; README tells users to wait or send a second prompt |
| P2 | `npx -y memtrace mcp` is slow cold | Document `npm i -g memtrace` and `MEMTRACE_BIN` |
| P2 | `memtrace` missing from PATH: the MCP server never starts and its tools silently don't appear (`failOnStartupError: false`) | Document `npm i -g memtrace` and `MEMTRACE_BIN` |
| P2 | A stock dsh ignores `perWorkingDirectory`, so calls fail with "no workspace owner" | Restate the `mcp-memtrace` row with `cwd: <repo root>`; ship the option upstream in dsh-mcp-client |
| P3 | Skills snapshot can drift from the Memtrace installer | `npm run sync-skills` from the product monorepo |
2 changes: 0 additions & 2 deletions lib/load-skills.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ export function loadSkillsFrom(packageRoot) {
skills.push({
...parsed,
path: skillPath,
directory,
resourceDirectory: directory,
})
}

Expand Down
31 changes: 0 additions & 31 deletions lib/resolve-memtrace-mcp.js

This file was deleted.

6 changes: 1 addition & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
{
"name": "dsh-plugin-memtrace",
"version": "0.2.3",
"version": "0.3.0",
"description": "Local-first code intelligence graph for DeepSeek Harness: structural search, blast radius, temporal memory, and 27 agent skills over Memtrace MCP.",
"icon": "./assets/icon.svg",
"type": "module",
"main": "index.js",
"bin": {
"dsh-plugin-memtrace-mcp": "./bin/memtrace-mcp.js"
},
"files": [
"index.js",
"lib/",
"bin/",
"skills/",
"references/",
"assets/",
Expand Down
3 changes: 1 addition & 2 deletions test/bundled-skills.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import assert from 'node:assert/strict'
import { dirname, join } from 'node:path'
import { dirname } from 'node:path'
import { describe, it } from 'node:test'
import { fileURLToPath } from 'node:url'
import { loadSkillsFrom } from '../lib/load-skills.js'
Expand All @@ -19,7 +19,6 @@ describe('bundled Memtrace skills', () => {
for (const skill of skills) {
assert.ok(skill.description.length > 20, skill.name)
assert.ok(skill.body.includes('\n'), skill.name)
assert.equal(skill.directory, join(packageRoot, 'skills', skill.name))
}
})
})
Loading
Loading