dsh-architecture-map 0.0.0-stage → 0.2.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.
Files changed (43) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/CODE_OF_CONDUCT.md +7 -0
  3. package/CONTRIBUTING.md +24 -0
  4. package/LICENSE +21 -0
  5. package/README.md +264 -2
  6. package/README.zh.md +247 -0
  7. package/THIRD_PARTY_NOTICES.md +36 -0
  8. package/client.js +1171 -0
  9. package/cordis.patch.yml +5 -0
  10. package/docs/DETAIL.md +76 -0
  11. package/docs/DETAIL.zh.md +76 -0
  12. package/docs/preview.svg +50 -0
  13. package/icon.svg +9 -0
  14. package/index.js +1 -0
  15. package/locale/en.json +7 -0
  16. package/locale/zh.json +7 -0
  17. package/package.json +68 -4
  18. package/skills/architecture-map/SKILL.md +75 -0
  19. package/skills/architecture-map/references/bootstrap.md +100 -0
  20. package/skills/architecture-map/references/discussion.md +71 -0
  21. package/skills/architecture-map/references/incremental.md +80 -0
  22. package/skills/architecture-map/references/schema.md +94 -0
  23. package/src/README.md +34 -0
  24. package/src/host/content/index.js +20 -0
  25. package/src/host/content/local.js +250 -0
  26. package/src/host/export.js +228 -0
  27. package/src/host/graph.js +707 -0
  28. package/src/host/memory.js +364 -0
  29. package/src/host/plugin.js +1125 -0
  30. package/src/host/projects.js +241 -0
  31. package/src/host/remote/commands.js +227 -0
  32. package/src/host/remote/consent.js +216 -0
  33. package/src/host/remote/content.js +391 -0
  34. package/src/host/remote/indexer.js +180 -0
  35. package/src/host/remote/maintainer.js +85 -0
  36. package/src/host/remote/ssh.js +287 -0
  37. package/src/host/remote/state.js +65 -0
  38. package/src/host/remote/tools.js +162 -0
  39. package/src/host/signature.js +42 -0
  40. package/src/host/workspace.js +131 -0
  41. package/vendor/elkjs.LICENSE +264 -0
  42. package/vendor/mermaid.LICENSE +21 -0
  43. package/vendor/mermaid.esm.min.mjs +4343 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,31 @@
1
+ ## 0.2.0 — 2026-11-22
2
+
3
+ ### Added
4
+
5
+ - Read-only remote Linux repositories over SSH: `.archmap/index.json` projects, `remote:<id>` workspaces, a project source picker and a remote status line.
6
+ - `arch_remote_list/status/tree/read/grep` tools, a blocking consent card (session / always / reject), and durable workspace consent.
7
+ - `/arch remote add/list/select/sync/update/grant/revoke/remove` commands.
8
+ - Fingerprint polling, `remote-state.json`, manifest-only incremental sync, stale marking and maintenance handoff.
9
+ - Non-git metadata fingerprints, root-containment checks for escapes/symlink escapes, and a read-only remote smoke script.
10
+
11
+ ### Fixed
12
+
13
+ - `readRange` no longer treats SSH connection diagnostics as the file size.
14
+ - Repeated edits to an already-dirty git file now move the fingerprint.
15
+
16
+ ### Developer preview notes
17
+
18
+ - A maintenance run does not clear the local `remote-state.pending` counter yet.
19
+ - Auto maintenance does not start from an idle parent session; `/arch remote update <id>` is the manual fallback.
20
+ - 65 tests pass; real SSH/host/tool/consent flows were verified on a non-production Linux host.
21
+
22
+ ## 0.1.0 — 2026-11-21
23
+
24
+ - Canonical `.archmap/graph.json` with revision, validation, atomic writes and backup.
25
+ - Sidebar SVG canvas with layered layout, pan/zoom/Fit, node dragging and local position memory.
26
+ - Architecture memory: manifest, incremental `arch_sync`, cosmetic detection, anchor-hash stale marking, dossier documents.
27
+ - Per-node `arch_discuss` fork/lite conversations, sidebar buttons and notes.
28
+ - Deterministic `arch_export` to Mermaid, SVG and Markdown.
29
+ - Built-in Mermaid fence rendering with a vendored runtime and `auto/on/off` configuration.
30
+ - Bundled `architecture-map` skill and localized panel strings.
31
+ - `node --test` suite and GitHub Actions CI.
@@ -0,0 +1,7 @@
1
+ # Code of conduct
2
+
3
+ This project follows the spirit of the Contributor Covenant: be respectful, assume good faith, and keep criticism about the work rather than the person.
4
+
5
+ Unacceptable behavior includes harassment, discrimination, personal attacks, and publishing private information. Maintainers may remove comments or contributions that violate these expectations.
6
+
7
+ Report concerns to the repository maintainer. Reports are handled confidentially.
@@ -0,0 +1,24 @@
1
+ # Contributing
2
+
3
+ Thanks for taking a look. This is a 0.2.0 developer-preview bundle; small, focused changes with tests are easiest to review.
4
+
5
+ ## Development
6
+
7
+ ```bash
8
+ npm run check # syntax check the Host/Client entry points
9
+ npm test # node --test
10
+ npm pack --dry-run
11
+ ```
12
+
13
+ The client is hand-written (`client.js`); there is no build step for it. Host code is plain ESM under `src/host/`.
14
+
15
+ ## What to change
16
+
17
+ - Keep the canonical graph schema backward-compatible unless the change explicitly bumps it.
18
+ - Add or update tests for graph validation, patching, memory sync, stale detection or exports.
19
+ - Do not commit `.archmap/` data, local design notes under `docs/DESIGN.md` / `PLAN.md` / `M0-FINDINGS.md`, or `vendor/` modifications without updating `THIRD_PARTY_NOTICES.md`.
20
+ - If you copy third-party code, keep its license header and add it to `THIRD_PARTY_NOTICES.md`.
21
+
22
+ ## Reporting issues
23
+
24
+ Include the DSH version, the workspace layout, the exact tool call, and the raw tool result or browser console error. Do not include credentials.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 The Architecture map contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,265 @@
1
- # Temporary Holding Version
1
+ # Architecture map
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ English | [中文](README.zh.md)
4
+
5
+ **中文名:架构地图** · An architecture workbench for DeepSeek Harness: a live semantic architecture graph, per-node side conversations, and incremental architecture memory.
6
+
7
+ > Status: **0.2.0 developer preview.** The Host tools, sidebar canvas, architecture memory, per-node discussions, deterministic exports, built-in Mermaid rendering and read-only remote Linux repositories over SSH work today. Shared positions remain planned; remote auto-maintenance on an idle parent and pending-counter clearing are the known rough edges.
8
+
9
+ ---
10
+
11
+ ## Why
12
+
13
+ Agents can already read a repository and draw a diagram. The diagram is dead:
14
+
15
+ - you cannot click a node and ask about it;
16
+ - every regeneration renames and re-lays-out everything, so last week's "N3" is gone;
17
+ - discussing one module means polluting the main conversation or starting a fresh session that forgot everything;
18
+ - the next session re-reads the whole repository because nothing was remembered.
19
+
20
+ Architecture map makes the architecture a **first-class, addressable object** in the harness:
21
+
22
+ - the agent builds a **semantic graph** (stable ids, code anchors, status);
23
+ - you view it on an interactive canvas in the right sidebar;
24
+ - each node can open an **isolated side conversation** that inherits the main conversation's memory;
25
+ - side conversations merge their edits back into the one canonical graph;
26
+ - an **architecture dossier** makes later analysis incremental — only changed files are re-read.
27
+
28
+ ## What it looks like
29
+
30
+ ![Architecture map panel](docs/preview.svg)
31
+
32
+ A static feature preview is included. A recorded 30-second demo GIF is not part of this repository yet.
33
+
34
+ ```
35
+ ┌──────────────── main conversation ────────────────┬──────── right sidebar ────────┐
36
+ │ you: draw the architecture of this project │ [Graph] [n3 · discuss] [+] │
37
+ │ agent: 14 nodes, 19 edges — see the map │ ┌────┐ ┌────┐ │
38
+ │ │ │ n1 │─────▶│ n3 │ │
39
+ │ (conversation stays clean while you discuss) │ └────┘ └────┘ │
40
+ │ │ n3 · Session Store │
41
+ │ │ summary / anchors / edges │
42
+ │ │ [lite] [fork] │
43
+ └───────────────────────────────────────────────────┴───────────────────────────────┘
44
+ ```
45
+
46
+ ## Features (implemented today)
47
+
48
+ - **Canonical architecture graph** — `.archmap/graph.json` with a revision number, schema validation, atomic writes and a one-step backup. The model reads and edits it through `arch_graph_get` / `arch_graph_patch`; `apply:false` previews without writing.
49
+ - **Right-sidebar canvas** — reads the graph from the session workspace, renders nodes/edges as SVG with a layered (longest-path) layout, supports pan, wheel zoom, `Fit`, node dragging and `Reset layout`, and shows node details on click.
50
+ - **Local layout memory** — dragged node positions are kept per workspace in browser storage, so a refresh or a new session on the same machine keeps the layout. `Reset layout` clears it. Shared positions are planned.
51
+ - **Incremental architecture memory with cosmetic detection** — `.archmap/manifest.json` records content hashes plus a normalized code signature; `arch_sync` reports only added/changed/deleted files, distinguishes code changes from format/comment-only changes, and lists the nodes whose anchors are affected. `markStale:true` marks those nodes stale (and bumps the graph rev); the default is report-only. Anchors may also store the file's normalized content signature; sync reports a node whose anchor hash no longer matches, and `arch_graph_patch` fills missing hashes or refreshes them with `refreshAnchors:true` after review. `arch_manifest_commit` records analyzed files, and `arch_doc_get` / `arch_doc_put` read and write `overview`, `modules/<id>` and `notes/<id>`.
52
+ - **Deterministic exports** — `arch_export` writes Mermaid flowchart source, a standalone SVG, or a Markdown dossier digest to `.archmap/export/`; graph revision and files stay unchanged.
53
+ - **Built-in Mermaid rendering** — assistant ` ```mermaid ` fences render with a vendored Mermaid 12.2.0 runtime served from the plugin's own Host route. No CDN and no `dsh-mermaid-plus` dependency. Streaming keeps the code block; parse errors fall back to code plus an error line. `renderMermaid: false` disables it.
54
+ - **Per-node side conversations** — `arch_discuss` starts a child for `node:<id>` or `edge:<id>`: `fork` inherits the main conversation's completed turns; `lite` starts fresh with the graph and dossier. Delivery is caller-only, so the main conversation is not polluted; conclusions go to `notes/<id>`. The node detail also has `Discuss (fork)` / `Lite` buttons that open the child in the right sidebar through the `subagentchat` resource. Discussion children are prompt-constrained; shell and generic source-write calls are denied at execution (inherited tool schemas may remain visible in a fork). Graph changes still require approval.
55
+ - **Remote Linux repositories (developer preview)** — `arch_remote_list/status/tree/read/grep` inspect a registered repository over SSH without cloning it. Content reads are consent-gated; remote `arch_sync`/`arch_manifest_commit` hash only analyzed files; change polling and `/arch remote ...` commands work; the panel switches local/remote sources; graph/dossier stay under `.archmap/projects/<id>/`; remote files are never modified.
56
+
57
+ ## Planned next
58
+
59
+ - Shared/persisted positions, direct export buttons in the panel, and a short animated demo (GIF).
60
+ - Remote maintenance polish: start from an idle parent and clear the local pending counter after a run.
61
+
62
+ ## What it is not
63
+
64
+ - Not a general whiteboard (Excalidraw-style). No freehand pixels; every element is addressable.
65
+ - Not a general memory plugin. The dossier exists to complete the architecture graph, not to store all conversation memory.
66
+ - Not just a diagram generator. The graph, discussions, merges, and memory are one loop.
67
+
68
+ ## Dependencies
69
+
70
+ No runtime plugin dependencies beyond DSH itself:
71
+
72
+ | Feature | Extra plugin? |
73
+ |---|---|
74
+ | Canvas, graph storage, local positions | No — implemented in this bundle |
75
+ | Skill / bootstrap guidance | No — bundled `architecture-map` skill |
76
+ | Architecture memory (`arch_sync` + dossier) | No — workspace files managed by this plugin |
77
+ | Mermaid rendering | No — Mermaid 12.2.0 is vendored and served locally; `renderMermaid: auto/on/off` |
78
+ | Side conversations | No — `arch_discuss` plus sidebar `Discuss` buttons |
79
+ | Stale detection | No — `arch_sync` with `markStale:true` |
80
+ | Export (Mermaid/SVG/Markdown) | No — `arch_export` |
81
+ | Sharper call/impact edges | Optional: `dsh-plugin-codegraph` (recommended, **not installed automatically**) |
82
+
83
+ ## Mermaid rendering
84
+
85
+ Assistant messages with a ` ```mermaid ` fence render as diagrams. The runtime is vendored at
86
+ `vendor/mermaid.esm.min.mjs` (Mermaid 12.2.0, MIT; ELK is EPL-2.0) and served by the Host at
87
+ `/x-dsh-architecture-map/vendor/mermaid.esm.min.mjs`; the browser never fetches a CDN. The client
88
+ checks `/x-dsh-architecture-map/config` first, so with `renderMermaid: off` fences stay plain
89
+ code blocks and the 5.2 MB runtime is not loaded. The default `auto` disables our renderer when
90
+ `dsh-mermaid-plus` (a known conflicting fence provider) is enabled; `on` forces it, `off` disables it.
91
+
92
+ ```yaml
93
+ - insert:
94
+ - id: architecture-map
95
+ name: dsh-architecture-map
96
+ config:
97
+ renderMermaid: off
98
+ ```
99
+
100
+ ## Where data lives
101
+
102
+ All graph, manifest, dossier and export data lives in `<workspace>/.archmap/`. The plugin installation
103
+ directory contains only code, skill, vendor, docs and locale. The plugin does not modify a user project's
104
+ `.gitignore`; commit `.archmap/` to share the map, or ignore it for local-only data. Uninstalling the plugin
105
+ does not delete `.archmap/`. Node positions are browser-local and are not part of the graph.
106
+
107
+ ## Remote repositories (developer preview)
108
+
109
+ The plugin can map a repository on a remote Linux host over your existing SSH config **without cloning it**. Reads are read-only, and the graph/dossier stay in the local workspace.
110
+
111
+ 1. Register the remote with `/arch remote add staging build-01 /srv/app` (or add an entry to `<workspace>/.archmap/index.json`):
112
+
113
+ ```json
114
+ {
115
+ "schema": 1,
116
+ "projects": [
117
+ { "id": "local", "kind": "local", "dir": "." },
118
+ {
119
+ "id": "staging", "kind": "remote", "dir": "projects/staging",
120
+ "transport": "ssh", "host": "build-01", "root": "/srv/app",
121
+ "vcs": "git", "autoRefresh": true
122
+ }
123
+ ]
124
+ }
125
+ ```
126
+
127
+ `host` is an OpenSSH destination from your SSH config; `root` must be an absolute remote path; use `"vcs": "none"` for a non-git directory.
128
+
129
+ 2. Ask the agent to use `arch_remote_list`, `arch_remote_status`, then `arch_remote_tree` / `arch_remote_read` / `arch_remote_grep`. The first content access shows an approval card (session / always / reject); nothing is read before you answer.
130
+
131
+ 3. Graph tools use `workspace: "remote:staging"`; state is written under `.archmap/projects/staging/`. Remote files are never modified.
132
+ 4. Open `/arch` and pick **Local** or **staging** in the source selector in the panel header. The status line shows host/root/vcs/consent; a remote project without a graph shows its own empty state.
133
+ 5. Picking a remote source starts polling. `/arch remote sync staging` checks immediately, `/arch remote update staging` starts a maintenance child, `/arch remote list` lists projects, and `/arch remote grant/revoke/remove` manage consent and registration.
134
+
135
+ Auto maintenance runs only after a durable “always allow”, for at most 50 changed files, at most once per 10 minutes. Larger changes only mark affected nodes stale. Real remote end-to-end verification was completed on a Linux host; auto maintenance still skips an idle parent (use `/arch remote update` to force it), and a maintenance run does not yet clear the local pending counter.
136
+
137
+ Remote reads are confined to the registered root: `..`, absolute escapes, and symlinks pointing outside are rejected. Git projects use HEAD plus `git status`, and hash changed/untracked paths so a second edit to an already-dirty file still moves the fingerprint; non-git projects use path/size/mtime metadata, and only analyzed files are hashed.
138
+
139
+ ## How memory works (no extra plugin)
140
+
141
+ Architecture map keeps an architecture-specific dossier in the workspace, managed by the plugin itself:
142
+
143
+ ```
144
+ .archmap/
145
+ ├── graph.json # canonical graph + rev
146
+ ├── manifest.json # path -> sha256 of analyzed files
147
+ ├── overview.md # one-page overview
148
+ ├── modules/<id>.md # per-module dossier
149
+ └── notes/<node>.md # per-node discussion conclusions
150
+ ```
151
+
152
+ - The first pass reads the repository once and writes the dossier + graph.
153
+ - Later, `arch_sync` hashes the workspace and returns only changed/added/deleted files and affected nodes. The agent reads only those, updates the dossier, then `arch_manifest_commit` records them.
154
+ - Conversation memory is separate: a `fork` side chat inherits the main conversation's completed turns through DSH's native fork; `lite` gets a dossier digest.
155
+ - This is **not** a general memory system and does **not** depend on `dsh-project-brain`, `dsh-living-memory`, or `dsh-memex`. Uninstall those and it still works.
156
+
157
+ ## Optional companion (recommended)
158
+
159
+ - [dsh-plugin-codegraph](https://github.com/CC19990113/dsh-plugin-codegraph) — tree-sitter code intelligence (symbols, callers, impact). Recommended if you want sharper edges; **not required**. Upstream reports ~1s first index and ~45ms re-index on a 337-file workspace, so structural queries are cheap after the first build. It is type-free, so dynamic dispatch and member calls may stay unresolved and fall back to text search. On a small repo the first index can cost more than a few greps.
160
+
161
+ ## Development
162
+
163
+ ```bash
164
+ npm run check # node --check for the Host/Client entry points
165
+ npm test # node --test
166
+ npm pack --dry-run
167
+ ```
168
+
169
+ ## Installation
170
+
171
+ Developer preview; install the local bundle now, or from npm once the 0.2.0 release is published:
172
+
173
+ 1. Install the bundle via **Plugins → Add plugin** (local directory) or add it as a `link:` dependency in the profile.
174
+ 2. Restart DSH once after installing so the client half joins the browser boot graph.
175
+ 3. Open a conversation.
176
+ 4. Optional but recommended: install `dsh-plugin-codegraph` separately (`dsh plugin add dsh-plugin-codegraph`). It is **not bundled and not installed automatically**.
177
+
178
+ ### Where to find it
179
+
180
+ There is no separate "start" button or left-sidebar icon. The plugin adds a right-sidebar panel and a slash command:
181
+
182
+ - Open the right sidebar and click **+** (add tab) → **Architecture map**.
183
+ - Or type `/arch` in the composer and pick **Architecture map**.
184
+ - To check the Host half, ask the agent to call `arch_hello`.
185
+
186
+ ## Quick start
187
+
188
+ 1. In a new conversation, ask: *"Use the architecture-map skill: sync this workspace, build or update the graph, and write the dossier."*
189
+ 2. Open `/arch` and click **Reset layout** if the saved layout hides the new graph.
190
+ 3. Click a node → **Discuss (fork)** for a context-aware discussion, or **Lite** for a cheap one.
191
+ 4. After changing code, ask for `arch_sync`; review only the changed files, update the node/doc, then `arch_manifest_commit`.
192
+ 5. Use `arch_export` for Mermaid/SVG/Markdown, or the **Mermaid** fence renderer for chat diagrams.
193
+
194
+ ## Limitations
195
+
196
+ - The sidebar follows the **session workspace**; an explicit tool `workspace` can point at a different graph than the panel shows.
197
+ - Node positions are stored in the browser locally, not in `graph.json`.
198
+ - Fork discussions inherit the parent request prefix, so their tool schemas may still show `bash`/`write` even though calls are denied.
199
+ - A parent-initiated `send_message` to a discussion child produces DSH's native settlement notice (including the child's closing text) in the parent conversation. The initial `arch_discuss` is caller-only and the child's full transcript never enters the main log; use the child's sidebar chat for narrative follow-ups.
200
+ - The canvas is hand-written SVG with a layered layout, not React Flow.
201
+ - Mermaid rendering is on by default (`auto`) but can be disabled with `renderMermaid: off`; a known `dsh-mermaid-plus` installation makes `auto` disable ours.
202
+ - This is a 0.2.0 developer preview; the API and file schema can still change.
203
+ - Remote repositories are a developer preview: register, read, sync, polling, commands and maintenance are wired and were verified on a real Linux host; auto maintenance on an idle parent and pending-counter clearing remain rough edges.
204
+
205
+ ## FAQ
206
+
207
+ **Do I need `dsh-mermaid-plus`?** No. Mermaid 12.2.0 is vendored. With `dsh-mermaid-plus` enabled,
208
+ `renderMermaid: auto` disables our renderer to avoid the shared `mermaid` fence key; `on` forces ours.
209
+
210
+ **Why hand-written SVG instead of React Flow?** It keeps the client bundle self-contained and avoids a
211
+ build/dependency chain. The layered layout covers the current graph sizes; React Flow remains an optional upgrade.
212
+
213
+ **Why does the sidebar show a different graph than a tool's `workspace` argument?** The panel follows the
214
+ session workspace by design. Open a session whose workspace is the graph you want to see.
215
+
216
+ **fork or lite?** `fork` inherits the parent's completed turns; `lite` starts from the graph and dossier only.
217
+
218
+ **Is this a general memory plugin?** No. The dossier is only for this architecture graph.
219
+
220
+ **How do I disable Mermaid?** Set `renderMermaid: off` in the bundle config; fences remain code blocks and the runtime is not loaded.
221
+
222
+ **Do I need codegraph?** No. `dsh-plugin-codegraph` is an optional companion for sharper call/impact edges.
223
+
224
+ ## Requirements
225
+
226
+ - DeepSeek Harness with a Web/Desktop host. Verified with DSH `0.2.2-rc.5` on macOS; the Host/client APIs may change in later releases.
227
+ - Node.js 22+ for the test suite and CI.
228
+ - A workspace the agent can read.
229
+ - Mermaid is vendored; no separate Mermaid plugin is required.
230
+
231
+ ## Roadmap
232
+
233
+ | Version | Scope |
234
+ |---|---|
235
+ | 0.1 | graph core and tools, sidebar canvas, node dragging, local position memory, `arch_sync` + manifest + dossier docs, cosmetic diff + stale marking, bundled architecture skill, `arch_discuss`, sidebar discussion buttons, `arch_export`, built-in Mermaid fence rendering |
236
+ | 0.2 | read-only remote Linux repositories over SSH (source picker, consent, 60s polling, sync/commands, maintenance), release polish |
237
+ | 0.3 | direct node→discussion bridge, shared/persisted positions, proposals, graph diff |
238
+ | 0.4 | edge discussions, group collapse, Mermaid import, Office export |
239
+ | 0.5 | multiple graphs, PR links, shared team maps |
240
+ | 0.6 | multiple remote repositories in parallel, remote sharing/export polish |
241
+
242
+ ## Prior art & acknowledgements
243
+
244
+ This space already has excellent DSH plugins. Architecture map builds on their ideas and, where stated, their MIT-licensed code:
245
+
246
+ | Project | What we take |
247
+ |---|---|
248
+ | [dsh-mermaid-plus](https://github.com/pidongqianqian/dsh-mermaid-plus) (MIT) | The built-in Mermaid fence renderer and vendored runtime are adapted from it; original copyright notices are retained. |
249
+ | [@eduwork/dsh-side-chat](https://github.com/ECNU/EduWork/tree/main/packages/dsh-side-chat) (MIT/MulanPSL-2.0) | UX reference for native seed-fork side chats and hiding inherited messages. |
250
+ | [@ahggg/dsh-side-chat](https://github.com/AHGGG/dsh-side-chat) (MIT) | Codex-style side-chat interaction reference. |
251
+ | [dsh-project-brain](https://github.com/yj-liuzepeng/dsh-project-brain) (MIT) | Prior art for project memory; our dossier is architecture-specific, not a general memory. |
252
+ | [dsh-anatomy](https://github.com/h2298511604-ops/dsh-anatomy) (MIT) | Live architecture-map UI reference (targets DSH itself). |
253
+ | [dsh-diagram-gallery](https://www.npmjs.com/package/dsh-diagram-gallery) (MIT) | Diagram generation/gallery reference. |
254
+ | [dsh-mindmap-live](https://github.com/SSShooter/dsh-mindmap-live) (MIT) | Bidirectional agent/user editing reference. |
255
+ | [dsh-plugin-codegraph](https://github.com/CC19990113/dsh-plugin-codegraph) (MIT) | Optional code-fact companion. |
256
+
257
+ Copied or adapted code keeps its original license header and is listed in [`THIRD_PARTY_NOTICES.md`](THIRD_PARTY_NOTICES.md).
258
+
259
+ ## Design notes
260
+
261
+ Remote design and construction notes live under `docs/`; early design/planning notes are kept locally and intentionally ignored. The README is the public overview.
262
+
263
+ ## License
264
+
265
+ MIT.
package/README.zh.md ADDED
@@ -0,0 +1,247 @@
1
+ # Architecture map · 架构地图
2
+
3
+ [English](README.md) | 中文
4
+
5
+ **DeepSeek Harness 的架构工作台:可交互的语义架构图、按节点开启的侧栏子对话、增量架构记忆。**
6
+
7
+ > 状态:**0.2.0 开发者预览**。Host 工具、右侧栏画布、架构记忆、按节点子对话、确定性导出、内置 Mermaid 渲染和通过 SSH 只读查看远程 Linux 仓库都已可用;共享位置仍待实现,空闲父会话自动维护和 pending 清零是已知粗糙边缘。
8
+
9
+ ---
10
+
11
+ ## 为什么
12
+
13
+ agent 已经能读仓库、画图,但那张图是死的:
14
+
15
+ - 不能点节点追问;
16
+ - 每次重新生成,命名和布局都会漂移,上次的「N3」找不到了;
17
+ - 讨论一个模块,要么污染主对话,要么开新会话把上下文全丢掉;
18
+ - 下一个会话又把代码从头读一遍,什么都没有沉淀。
19
+
20
+ Architecture map 把「项目架构」变成 harness 里**可寻址的一等对象**:
21
+
22
+ - agent 建**语义图**(稳定 id、代码锚点、状态);
23
+ - 用户在右侧栏的交互画布上看图;
24
+ - 每个节点可以开一个**隔离的侧栏子对话**,继承主对话的记忆;
25
+ - 子对话的修改合并回唯一的图;
26
+ - **架构档案**让后续分析只处理变更文件。
27
+
28
+ ## 界面示意
29
+
30
+ ![架构地图面板](docs/preview.svg)
31
+
32
+ 仓库包含静态功能预览;30 秒演示 GIF 尚未录制。
33
+
34
+ ```
35
+ ┌──────────────── 主对话 ───────────────────────────┬──────── 右侧栏 ──────────────┐
36
+ │ 你:画一下这个项目的架构图 │ [架构图] [n3 · 讨论] [+] │
37
+ │ agent:14 个节点、19 条边,看右侧 │ ┌────┐ ┌────┐ │
38
+ │ │ │ n1 │─────▶│ n3 │ │
39
+ │ (你讨论时,主对话保持干净) │ └────┘ └────┘ │
40
+ │ │ n3 · Session Store │
41
+ │ │ 摘要 / 锚点 / 上下游 │
42
+ │ │ [轻讨论] [深讨论] │
43
+ └───────────────────────────────────────────────────┴──────────────────────────────┘
44
+ ```
45
+
46
+ ## 已实现
47
+
48
+ - **Canonical 架构图**:`.archmap/graph.json`,带 rev、schema 校验、原子写入和单步备份。模型通过 `arch_graph_get` / `arch_graph_patch` 读写;`apply:false` 只预览不写入。
49
+ - **右侧栏画布**:从当前会话 workspace 读取图,SVG 渲染节点/边,使用 longest-path 分层布局,支持平移、滚轮缩放、`Fit`、节点拖拽、`Reset layout`,点击节点看详情。
50
+ - **位置本地记忆**:拖动的节点位置按 workspace 存在浏览器本地,刷新或同机新会话会保留;`Reset layout` 清掉。共享位置是后续计划。
51
+ - **增量架构记忆 + 格式改动识别**:`.archmap/manifest.json` 记录 hash 和归一化代码签名;`arch_sync` 只报告新增/修改/删除文件,区分代码改动和仅格式/注释改动,并列出受影响节点;`markStale:true` 会把这些节点标成 stale 并递增 graph rev,默认只报告不写图;anchor 还可以存文件的归一化内容签名,sync 会发现 hash 不匹配的节点,复盘后用 `arch_graph_patch` 的 `refreshAnchors:true` 刷新;`arch_manifest_commit` 记录已分析文件;`arch_doc_get` / `arch_doc_put` 读写 `overview`、`modules/<id>`、`notes/<id>`。
52
+ - **确定性导出**:`arch_export` 把 Mermaid flowchart、独立 SVG 或 Markdown 档案摘要写到 `.archmap/export/`;不改变 graph rev,也不改源文件。
53
+ - **内置 Mermaid 渲染**:assistant 消息里的 ` ```mermaid ` 块用 vendored Mermaid 12.2.0 渲染,runtime 由本插件 Host 路由提供,不依赖 CDN,也不依赖 `dsh-mermaid-plus`。流式时保留代码块,语法错误回退代码块 + 错误行;`renderMermaid:false` 可关闭。
54
+ - **按节点子对话**:`arch_discuss` 为 `node:<id>` 或 `edge:<id>` 开子会话;`fork` 继承主对话已完成轮次,`lite` 只靠图和档案。结果只走 caller,不污染主对话;结论写进 `notes/<id>`。节点详情里还有 `Discuss (fork)` / `Lite` 按钮,通过 `subagentchat` resource 在右侧栏打开子会话。子会话受提示词约束;shell 和通用源码写调用在执行时会被拒绝(fork 可能仍显示继承的工具 schema);改图仍需你确认。
55
+ - **远程 Linux 仓库(开发者预览)**:`arch_remote_list/status/tree/read/grep` 通过 SSH 查看已登记仓库,不 clone;读内容前要授权,远程 `arch_sync`/`arch_manifest_commit` 只哈希已分析文件,变更轮询和 `/arch remote ...` 命令可用,面板可切换本地/远程来源,图和档案留在 `.archmap/projects/<id>/`,远程文件不被修改。
56
+
57
+ ## 下一步计划
58
+
59
+ - 位置共享/写回图数据、右侧栏导出按钮、短视频演示(GIF)。
60
+ - 远程维护打磨:空闲父会话自动启动,维护后清零本地 pending。
61
+
62
+ ## 不是什么
63
+
64
+ - 不是通用白板(Excalidraw 型):没有自由像素,每个元素都可寻址。
65
+ - 不是通用记忆插件:档案是为了完善这张架构图,不是保存所有对话记忆。
66
+ - 不只是画图工具:图、讨论、合并、记忆是一个闭环。
67
+
68
+ ## 依赖
69
+
70
+ 除 DSH 本身外,没有运行时插件依赖:
71
+
72
+ | 功能 | 需要额外插件? |
73
+ |---|---|
74
+ | 画布、图存储、位置本地记忆 | 不需要——本 bundle 已实现 |
75
+ | Skill / bootstrap 指导 | 不需要——随包提供 `architecture-map` skill |
76
+ | 架构记忆(`arch_sync` + dossier) | 不需要——本插件管理的 workspace 文件 |
77
+ | Mermaid 渲染 | 不需要——Mermaid 12.2.0 已 vendored 并由本机路由提供;`renderMermaid: auto/on/off` |
78
+ | 侧栏子对话 | 不需要——`arch_discuss` + 右侧栏 `Discuss` 按钮 |
79
+ | Stale 检测 | 不需要——`arch_sync` 的 `markStale:true` |
80
+ | 导出(Mermaid/SVG/Markdown) | 不需要——`arch_export` |
81
+ | 更准的调用/影响边 | 可选:`dsh-plugin-codegraph`(推荐,**不默认安装**) |
82
+
83
+ ## 数据存在哪里
84
+
85
+ 架构图、manifest、档案和导出都在 `<workspace>/.archmap/`;插件安装目录只有代码、skill、vendor、文档和 locale。
86
+ 插件不会修改用户项目的 `.gitignore`;想共享就提交 `.archmap/`,想只留本地就自己忽略。卸载插件不会删除
87
+ `.archmap/`。节点位置只存在浏览器本地,不属于图数据。
88
+
89
+ ## 远程仓库(开发者预览)
90
+
91
+ 插件可以通过你现有的 SSH 配置,映射一台远程 Linux 上的仓库,**不需要 clone**。读取是只读的,图和档案保存在本地工作区。
92
+
93
+ 1. 用 `/arch remote add staging build-01 /srv/app` 登记远程项目(也可以手工写 `<workspace>/.archmap/index.json`):
94
+
95
+ ```json
96
+ {
97
+ "schema": 1,
98
+ "projects": [
99
+ { "id": "local", "kind": "local", "dir": "." },
100
+ {
101
+ "id": "staging", "kind": "remote", "dir": "projects/staging",
102
+ "transport": "ssh", "host": "build-01", "root": "/srv/app",
103
+ "vcs": "git", "autoRefresh": true
104
+ }
105
+ ]
106
+ }
107
+ ```
108
+
109
+ `host` 是你 SSH 配置里的 OpenSSH 目标;`root` 必须是远程绝对路径;非 git 目录把 `"vcs"` 设为 `"none"`。
110
+
111
+ 2. 让 agent 用 `arch_remote_list`、`arch_remote_status`,再用 `arch_remote_tree` / `arch_remote_read` / `arch_remote_grep`。第一次读取内容会弹授权卡(本次会话 / 始终允许 / 拒绝);回答前不会读取任何内容。
112
+
113
+ 3. 图工具用 `workspace: "remote:staging"`;数据写在 `.archmap/projects/staging/` 下。远程文件永远不会被修改。
114
+ 4. 打开 `/arch`,在面板顶部的来源选择器里切换 **本地 / staging**。状态条显示 host/root/vcs/授权;远程项目没有图时会显示对应的空状态。
115
+ 5. 选中远程来源会开始轮询。`/arch remote sync staging` 立即检查一次,`/arch remote update staging` 启维护子会话,`/arch remote list` 列项目,`/arch remote grant/revoke/remove` 管理授权和登记。
116
+
117
+ 自动维护只在“始终允许”后运行,最多 50 个变更文件、最多每 10 分钟一次;超限只标 stale。真远程端到端验收已在 Linux 主机上完成;父会话空闲时自动维护会跳过(可用 `/arch remote update` 强制),维护后本地 pending 计数暂未清零。
118
+
119
+ 远程读取被限制在登记的 root 内:`..`、绝对路径逃逸和指向 root 外的符号链接都会被拒绝。git 项目用 HEAD + `git status`,并哈希已修改/未跟踪路径,保证脏文件再次编辑也能被检测到;非 git 项目用 path/size/mtime 元数据,只有已分析文件才会被哈希。
120
+
121
+ ## 记忆是怎么做的(不需要其他插件)
122
+
123
+ Architecture map 在 workspace 里维护一份**架构专用档案**,由插件自己管理:
124
+
125
+ ```
126
+ .archmap/
127
+ ├── graph.json # canonical 图 + rev
128
+ ├── manifest.json # 已分析文件的 path -> sha256
129
+ ├── overview.md # 1 页总览
130
+ ├── modules/<id>.md # 每模块档案
131
+ └── notes/<node>.md # 每节点讨论结论
132
+ ```
133
+
134
+ - 首次分析读一遍仓库,写出档案 + 图。
135
+ - 之后 `arch_sync` 对 workspace 做 hash 对比,只返回新增/修改/删除的文件和受影响节点;agent 只读这些文件,更新档案,再用 `arch_manifest_commit` 提交。
136
+ - 对话记忆是另一层:`fork` 子对话通过 DSH 原生 fork 继承主对话已完成轮次;`lite` 只拿档案摘要。
137
+ - 这**不是**通用记忆系统,也**不依赖** `dsh-project-brain`、`dsh-living-memory`、`dsh-memex`;卸掉它们照样工作。
138
+
139
+ ## 可选增强(推荐)
140
+
141
+ - [dsh-plugin-codegraph](https://github.com/CC19990113/dsh-plugin-codegraph):tree-sitter 代码智能(符号、调用、影响面)。想让连线更准可以装;**不装也能用**。上游报告 337 文件仓库首次索引约 1s、增量约 45ms,建好之后结构查询很便宜;但它是 type-free 解析,动态派发和成员调用可能解析不到,仍要 grep 兜底。小仓库首次索引可能比几次 grep 更贵。
142
+
143
+ ## 开发
144
+
145
+ ```bash
146
+ npm run check # Host/Client 入口语法检查
147
+ npm test # node --test
148
+ npm pack --dry-run
149
+ ```
150
+
151
+ ## 快速开始
152
+
153
+ 1. 新会话里说:*“用 architecture-map skill 扫一遍这个 workspace,建/更新图并写档案。”*
154
+ 2. 打开 `/arch`;如果保存的布局遮住了新节点,点 **重置布局**。
155
+ 3. 点节点 → **讨论(fork)** 开继承上下文的讨论,或 **轻讨论** 开便宜版本。
156
+ 4. 改代码后让 agent 调 `arch_sync`;只读变更文件,更新节点/档案,再 `arch_manifest_commit`。
157
+ 5. 用 `arch_export` 导出 Mermaid/SVG/Markdown,或直接用聊天里的 Mermaid fence。
158
+
159
+ ## 限制
160
+
161
+ - 右侧栏跟随**会话 workspace**;工具参数里的显式 `workspace` 可能和面板显示的图不同。
162
+ - 节点位置只存在浏览器本地,不在 `graph.json`。
163
+ - fork 讨论继承父对话 request prefix,工具列表里可能仍显示 `bash`/`write`,但执行层会拒绝。
164
+ - 父对话主动 `send_message` 给讨论子会话时,DSH 会在主对话里投递 native settlement notice(含子会话 closing text)。初次 `arch_discuss` 是 caller-only,子会话完整 transcript 不会进主日志;需要继续聊请在子会话侧栏里发。
165
+ - 画布是手写 SVG + 分层布局,不是 React Flow。
166
+ - Mermaid 默认 `auto` 开启;`renderMermaid: off` 可关;检测到已知的 `dsh-mermaid-plus` 时 `auto` 会关闭本插件渲染。
167
+ - 这是 0.2.0 开发者预览,API 和文件 schema 仍可能变化。
168
+ - 远程仓库是开发者预览:登记、读取、同步、轮询、命令和维护都已接上,并在真实 Linux 主机上验收;空闲父会话的自动维护和 pending 清零仍是粗糙边缘。
169
+
170
+ ## 安装
171
+
172
+ 开发者预览;现在可安装本地 bundle,0.2.0 发布到 npm 后也可直接安装:
173
+
174
+ 1. 通过 **Plugins → Add plugin**(本地目录)或插件管理器安装 bundle。
175
+ 2. 安装后**重启一次 DSH**,让 Client 半进入浏览器 boot graph。
176
+ 3. 打开一个会话。
177
+ 4. 可选但推荐:单独安装 `dsh-plugin-codegraph`(`dsh plugin add dsh-plugin-codegraph`)。它**不随本插件打包,也不会自动安装**。
178
+
179
+ ### 在哪里打开
180
+
181
+ 它没有独立的“启动”按钮,也没有左侧栏图标;入口是右侧栏面板和斜杠命令:
182
+
183
+ - 打开右侧栏,点 **+**(添加 tab)→ **Architecture map**。
184
+ - 或者在输入框输入 `/arch`,选 **Architecture map**。
185
+ - 想单独验证 Host 半,让 agent 调用 `arch_hello`。
186
+
187
+ ## 常见问题
188
+
189
+ **需要 `dsh-mermaid-plus` 吗?** 不需要,Mermaid 12.2.0 已 vendored。如果启用了 `dsh-mermaid-plus`,
190
+ `renderMermaid: auto` 会关闭本插件渲染,避免共用 `mermaid` fence key;`on` 强制开启本插件。
191
+
192
+ **为什么手写 SVG,不用 React Flow?** 保持 client bundle 自包含,不引入构建/依赖链。分层布局覆盖当前规模;
193
+ React Flow 仍可作为后续可选升级。
194
+
195
+ **为什么侧栏显示的图和工具 `workspace` 参数里的图不一样?** 面板按设计跟随会话 workspace。要看哪张图,
196
+ 就打开 workspace 指向那个目录的会话。
197
+
198
+ **fork 和 lite 怎么选?** fork 继承主对话已完成轮次;lite 只从图和档案开始。
199
+
200
+ **这是通用记忆插件吗?** 不是,档案只服务这张架构图。
201
+
202
+ **怎么关闭 Mermaid?** 配置 `renderMermaid: off`;代码块保持不变,也不会加载 runtime。
203
+
204
+ **需要 codegraph 吗?** 不需要;`dsh-plugin-codegraph` 是可选的调用/影响边增强。
205
+
206
+ ## 要求
207
+
208
+ - 带 Web/Desktop Host 的 DeepSeek Harness;在 macOS + DSH `0.2.2-rc.5` 上验证,后续版本 API 可能变化。
209
+ - 测试套件和 CI 需要 Node.js 22+。
210
+ - agent 可读的 workspace。
211
+ - Mermaid 已 vendored,不需要额外 Mermaid 插件。
212
+
213
+ ## 路线图
214
+
215
+ | 版本 | 内容 |
216
+ |---|---|
217
+ | 0.1 | 图核心与工具、右侧栏画布、节点拖拽、位置本地记忆、`arch_sync` + manifest + dossier、格式改动识别 + stale、内置 architecture skill、`arch_discuss`、右侧栏讨论按钮、`arch_export`、内置 Mermaid fence 渲染 |
218
+ | 0.2 | 通过 SSH 只读查看远程 Linux 仓库(来源选择、授权、60 秒轮询、sync/命令、维护)+ 发布打磨 |
219
+ | 0.3 | 节点直连讨论、位置共享/写回图、提案、图 diff |
220
+ | 0.4 | 边讨论、分组折叠、Mermaid 导入、Office 导出 |
221
+ | 0.5 | 多图、PR 关联、团队共享 |
222
+ | 0.6 | 多远程仓库并行、远程共享/导出打磨 |
223
+
224
+ ## 先例与致谢
225
+
226
+ 这个方向已经有不少优秀的 DSH 插件。Architecture map 建立在它们的想法之上,并在注明的地方复用其 MIT 代码:
227
+
228
+ | 项目 | 我们借鉴/复用什么 |
229
+ |---|---|
230
+ | [dsh-mermaid-plus](https://github.com/pidongqianqian/dsh-mermaid-plus)(MIT) | 内置 Mermaid fence 渲染将参考它实现;保留原始版权声明。 |
231
+ | [@eduwork/dsh-side-chat](https://github.com/ECNU/EduWork/tree/main/packages/dsh-side-chat)(MIT/MulanPSL-2.0) | 原生 seed fork 侧聊、隐藏继承消息的 UX 参考。 |
232
+ | [@ahggg/dsh-side-chat](https://github.com/AHGGG/dsh-side-chat)(MIT) | Codex 式侧聊交互参考。 |
233
+ | [dsh-project-brain](https://github.com/yj-liuzepeng/dsh-project-brain)(MIT) | 项目记忆的先例;我们的档案只做架构专用,不做通用记忆。 |
234
+ | [dsh-anatomy](https://github.com/h2298511604-ops/dsh-anatomy)(MIT) | 实时架构图 UI 参考(对象是 DSH 本身)。 |
235
+ | [dsh-diagram-gallery](https://www.npmjs.com/package/dsh-diagram-gallery)(MIT) | 图生成/图表廊参考。 |
236
+ | [dsh-mindmap-live](https://github.com/SSShooter/dsh-mindmap-live)(MIT) | agent/用户双向编辑参考。 |
237
+ | [dsh-plugin-codegraph](https://github.com/CC19990113/dsh-plugin-codegraph)(MIT) | 可选的代码事实增强。 |
238
+
239
+ 复制或改编的代码会保留原版权头,并在实现落地后登记到 [`THIRD_PARTY_NOTICES.md`](THIRD_PARTY_NOTICES.md)。
240
+
241
+ ## 设计文档
242
+
243
+ 远程设计与施工记录在 `docs/`;早期设计与施工笔记保留在本地并有意忽略。README 是公开概览。
244
+
245
+ ## 许可
246
+
247
+ MIT。
@@ -0,0 +1,36 @@
1
+ # Third-party notices
2
+
3
+ Architecture map is MIT-licensed. Some of its implementation is inspired by, adapted from, or copied from MIT-licensed DSH plugins and libraries. When code is copied, the original copyright and permission notice is retained in the source file and reproduced here, as the MIT license requires.
4
+
5
+ This file is populated as the implementation lands. Until then it records the planned sources.
6
+
7
+ ## Mermaid rendering
8
+
9
+ - **dsh-mermaid-plus 0.6.2** — https://github.com/pidongqianqian/dsh-mermaid-plus (MIT)
10
+ Reference/adaptation for the built-in `mermaid` chat fence renderer. Its vendored Mermaid
11
+ bundle (`vendor/mermaid.esm.min.mjs`), license files and the static-route approach were
12
+ copied from this MIT project; the original license texts are retained under `vendor/`.
13
+ - **mermaid 12.2.0** — https://github.com/mermaid-js/mermaid (MIT)
14
+ Bundled as `vendor/mermaid.esm.min.mjs`; MIT text in `vendor/mermaid.LICENSE`.
15
+ - **ELK (elkjs) 0.9.3** — https://github.com/kieler/elkjs (EPL-2.0)
16
+ Inlined into the vendored Mermaid bundle as an unmodified dependency. EPL text in
17
+ `vendor/elkjs.LICENSE`; the source is available at the URL above. Do not describe the
18
+ whole package as MIT-only when redistributing the vendored runtime.
19
+
20
+ ## Side chat UX references (no code copied at design time)
21
+
22
+ - **@eduwork/dsh-side-chat** — https://github.com/ECNU/EduWork/tree/main/packages/dsh-side-chat (MIT / MulanPSL-2.0)
23
+ Reference for native seed-fork side chats and hiding inherited messages.
24
+ - **@ahggg/dsh-side-chat** — https://github.com/AHGGG/dsh-side-chat (MIT)
25
+ Reference for Codex-style side-chat interaction.
26
+
27
+ ## Optional companion (not bundled)
28
+
29
+ - **dsh-plugin-codegraph** — https://github.com/CC19990113/dsh-plugin-codegraph (MIT)
30
+ Not a dependency; only recommended in the README.
31
+
32
+ ## Libraries bundled into the client artifact
33
+
34
+ - **mermaid 12.2.0** — MIT, served on demand from `vendor/mermaid.esm.min.mjs`
35
+ - **ELK (elkjs) 0.9.3** — EPL-2.0, inlined into the Mermaid bundle
36
+ - The hand-written canvas uses no React Flow or dagre dependency.