dsh-connectome 0.0.0-stage → 1.0.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/CHANGELOG.md ADDED
@@ -0,0 +1,38 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented here. The format follows
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the project uses
5
+ [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [1.0.0] — 2026-10-30
8
+
9
+ First public release.
10
+
11
+ ### Added
12
+
13
+ - **Connectome overlay** — a frame-wide dialog (slot `shell.overlay`) that renders a
14
+ force-directed graph of the current workspace on a single `<canvas>`.
15
+ - **Relationship edges** — directed dependency links with arrowheads at the imported
16
+ file: solid for `import` / `export … from` / dynamic `import()` / `require` /
17
+ CSS `@import`, dashed for HTML and Markdown references. Hovering a link names both
18
+ endpoints and the relation kind.
19
+ - **Relationship inspector** — hovering a node highlights its neighbourhood and lists
20
+ its direct relationships (`→` imports, `←` imported by), each row clickable; `+N`
21
+ summarises the remaining ones.
22
+ - **Click to code** — clicking a neuron opens that file in the harness' right-Sidebar
23
+ document preview (`ctx.sidebarRight` + `dsh-resource://file/session/…`), with line
24
+ numbers, copy and automatic reload. A missing preview/session is explained in the
25
+ dialog footer instead of failing silently.
26
+ - **Sidebar entry** — a `🧠 Connectome` row in the sidebar panel list's **More** menu
27
+ (slot `sidebar.panellist.actions`).
28
+ - **Workspace switcher, rescan, fit, zoom, pan, node drag** and `Esc` to close.
29
+ - **Theme-aware canvas** — colors read from live `--dsw-alias-*` tokens; light/dark
30
+ switches recolor the graph.
31
+ - **Host scanner** — bounded recursive workspace scan with regex-based dependency
32
+ extraction for JS/TS/Vue/Svelte, CSS/SCSS/Sass/Less/Stylus, HTML, Markdown and
33
+ Python, served over a same-origin, connection-fenced `POST /connectome/api/graph`
34
+ route.
35
+ - **Tests** — dependency-free scanner/route tests, artifact structure tests and a
36
+ package/release contract test (`node test/*.test.mjs`).
37
+
38
+ [1.0.0]: https://github.com/elalamiimed/dsh-connectome/releases/tag/v1.0.0
@@ -0,0 +1,53 @@
1
+ # Contributing
2
+
3
+ Thanks for taking a look! Issues and pull requests are welcome.
4
+
5
+ ## Development setup
6
+
7
+ The plugin is plain JavaScript with **no dev dependencies**: the d3 distributions it
8
+ inlines are committed under `vendor/`, and the tests use Node builtins only.
9
+
10
+ ```bash
11
+ git clone https://github.com/elalamiimed/dsh-connectome.git
12
+ cd dsh-connectome
13
+
14
+ node build.mjs # regenerate client.js from client.source.js + vendor/
15
+ npm test # scanner, artifact and package contract tests
16
+ npm run check # node --check on host and generated client
17
+ ```
18
+
19
+ You only need `npm install` if you want to rebuild `client.js` from a different
20
+ d3-force copy: `node build.mjs --modules <node_modules dir>` looks there after
21
+ `vendor/`.
22
+
23
+ ## Project layout
24
+
25
+ | Path | Role |
26
+ | --- | --- |
27
+ | `index.js` | Host half: workspace scanner, dependency parser, fenced graph route. |
28
+ | `client.source.js` | Readable Client half: slots, overlay, canvas engine. Build input. |
29
+ | `client.js` | Generated browser artifact. **Never edit by hand** — run `node build.mjs`. |
30
+ | `build.mjs` | Dependency-free build: inlines `vendor/d3-*.min.js`, emits the loader. |
31
+ | `test/` | Node-builtin test suites. |
32
+ | `locale/` | Plugin display metadata (English/Chinese). |
33
+
34
+ ## Rules of thumb
35
+
36
+ - Keep the UI free of JSX (the client is authored as plain `React.createElement`) and
37
+ keep `client.source.js` free of `import`/`export` lines and non-baseline `require`
38
+ calls; the build validates both.
39
+ - UI colors must come from the host `--dsw-alias-*` theme tokens, and spacing/type
40
+ geometry from the local `--ds-*` layer in the overlay stylesheet — do not invent
41
+ one-off colors or spacing values.
42
+ - Never edit `client.js` directly: the build banner says so.
43
+ - Add a regression check to `test/` when you fix a rendering or interaction bug.
44
+ - Keep the first render path cheap: the canvas engine must retain its synchronous
45
+ first paint and its stopped/rAF-driven simulation.
46
+ - Run `npm test` before opening a PR; CI runs the same suite on Node 18/20/22 and
47
+ verifies that `client.js` is reproducible.
48
+
49
+ ## Reporting bugs
50
+
51
+ Include your DSH version (`dsh --version` or the desktop build), OS, the workspace
52
+ shape (approximate file count), and what you expected to see. A screenshot or screen
53
+ recording of the canvas is very helpful.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 elalamiimed
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,217 @@
1
- # Temporary Holding Version
1
+ # Connectome
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
+ [![CI](https://github.com/elalamiimed/dsh-connectome/actions/workflows/ci.yml/badge.svg)](https://github.com/elalamiimed/dsh-connectome/actions/workflows/ci.yml)
4
+ [![License: MIT](https://img.shields.io/badge/license-MIT-16A34A.svg)](LICENSE)
5
+ [![DSH](https://img.shields.io/badge/DSH-%E2%89%A50.2.1--rc.2-3B82F6.svg)](https://github.com/deepseek-ai/deepseek-harness)
6
+
7
+ **A living map of your workspace for the DeepSeek Harness Web UI** — every file is a
8
+ neuron, every import is a synapse. Connectome scans the current workspace, draws the
9
+ file/dependency graph on a single `<canvas>` with `d3-force` physics, lets you trace
10
+ any relationship, and turns a click on a neuron into the file's code in the
11
+ harness' own right-sidebar preview.
12
+
13
+ ![Connectome illustration](docs/preview.svg)
14
+
15
+ <sub>The banner is an illustration of the canvas graph, not a screenshot.</sub>
16
+
17
+ ## Features
18
+
19
+ - **One canvas, hundreds of nodes, 60 fps.** Nodes and links are painted into a single
20
+ `<canvas>`; there is no DOM node per file. `d3-force` runs the layout, the plugin's
21
+ own `requestAnimationFrame` loop ticks it, and the simulation stops when idle.
22
+ - **Relationships you can read.** Dependency edges carry an arrowhead at the imported
23
+ file: **solid** for `import` / `export … from` / dynamic `import()` / `require` / CSS
24
+ `@import`, **dashed** for HTML and Markdown references. Hover a link to see both
25
+ endpoints and the relation kind.
26
+ - **Neighbourhood inspection.** Hovering a node highlights its neighbourhood and lists
27
+ its direct ties (`→` imports, `←` imported by), each clickable, with a `+N` summary
28
+ for the rest. Great for seeing how two modules — or two "engine" files — meet.
29
+ - **Click to read code.** Clicking a neuron opens that file in the harness'
30
+ right-Sidebar document preview (`ctx.sidebarRight.openResource` with a
31
+ `dsh-resource://file/session/…` address): line numbers, language label, copy, and
32
+ automatic reload, all inside DSH. A missing preview or selected session is explained
33
+ in the footer.
34
+ - **Theme-aware.** The canvas reads its colors from the live `--dsw-alias-*` theme
35
+ tokens at runtime, so light/dark switches recolor the graph.
36
+ - **Workspace switcher, rescan, fit, zoom, pan, node drag, `Esc` to close.**
37
+ - **Local by design.** No telemetry, no network calls, no workspace data leaves your
38
+ machine.
39
+
40
+ ## Install
41
+
42
+ Connectome is a DSH **bundle** plugin: installing it adds a Host row (workspace scanner
43
+ + HTTP route) and a lazy browser module (the canvas UI).
44
+
45
+ ### Requirements
46
+
47
+ - DeepSeek Harness **0.2.1-rc.2 or newer** (Desktop or a `dsh web` deployment with the
48
+ standard Web bundle).
49
+ - Node.js 18+ only if you build from source; the release ships `client.js` prebuilt.
50
+
51
+ ### From the Web UI (recommended)
52
+
53
+ Open the sidebar's **Plugins** page, choose **Install**, and enter one of:
54
+
55
+ ```text
56
+ dsh-connectome # once published on npm
57
+ github:elalamiimed/dsh-connectome # straight from GitHub (works now)
58
+ ```
59
+
60
+ The plugin manager enables the bundle after a successful install. Open the sidebar
61
+ panel list's **More** menu and pick **🧠 Connectome**.
62
+
63
+ ### From a terminal
64
+
65
+ The DSH CLI forwards package operations to the profile; then enable the bundle in
66
+ **Plugins** (or keep using the Web UI above, which does both steps):
67
+
68
+ ```bash
69
+ dsh plugin --profile desktop add github:elalamiimed/dsh-connectome
70
+ # once published on npm:
71
+ dsh plugin --profile desktop add dsh-connectome
72
+ ```
73
+
74
+ ### Manual / development install
75
+
76
+ ```bash
77
+ git clone https://github.com/elalamiimed/dsh-connectome.git
78
+ cd dsh-connectome
79
+ # then install the folder as a bundle in the running profile, e.g. with
80
+ # plugin_manager install_bundle <absolute-path>, or `dsh plugin add link:<absolute-path>`
81
+ ```
82
+
83
+ > Note: the npm name `dsh-project-brain` belongs to an unrelated DSH plugin. This
84
+ > project is published as **`dsh-connectome`**; the GitHub repository still uses the
85
+ > "project brain" working title in its history only.
86
+
87
+ ## Usage
88
+
89
+ 1. Open the sidebar panel list's **More** menu → **🧠 Connectome**.
90
+ 2. The dialog scans the current workspace and fits the graph to view.
91
+ 3. Use the header to switch workspace (when several are registered), rescan, fit or
92
+ zoom; drag the background to pan; scroll to zoom around the pointer; drag a node to
93
+ pull it.
94
+ 4. Hover a node or a link for the relationship tooltip. Click a neuron to open the file
95
+ in the right sidebar. `Esc` / the ✕ button closes the dialog.
96
+
97
+ ## Supported dependency syntax
98
+
99
+ The Host extracts links with small, dependency-free regexes (bare package names are
100
+ deliberately **not** expanded into `node_modules`):
101
+
102
+ | Files | Relationships |
103
+ | --- | --- |
104
+ | JS / TS / JSX / TSX / Vue / Svelte | `import … from`, `export … from`, dynamic `import()`, `require()` |
105
+ | CSS / SCSS / Sass / Less / Stylus | `@import`, `@use`, `@forward` |
106
+ | HTML | `<script src>`, `<link href>` |
107
+ | Markdown | relative links and images |
108
+ | Python | `import x`, `from . import y` |
109
+
110
+ Only relative, root-relative and `@/` / `~/` specifiers resolve to workspace files.
111
+ `node_modules`, `.git`, build outputs, caches and dot-directories are skipped.
112
+
113
+ ## How it works
114
+
115
+ ### Host half (`index.js`)
116
+
117
+ - `POST /connectome/api/graph` — same-origin route fenced through
118
+ `ctx.connection.requestRejection(req)`; optional JSON body `{ "root": "<workspace>" }`.
119
+ - Resolves the workspace root from the registered workspaces (or the current working
120
+ directory) and scans it under hard caps: 2,000 file nodes, 12,000 directory entries,
121
+ 1,500 parsed files, 512 KiB read per file, an 8 s soft time budget.
122
+ - Returns the graph:
123
+
124
+ ```json
125
+ {
126
+ "ok": true,
127
+ "root": "C:\\path\\workspace",
128
+ "roots": [{ "path": "C:\\path\\workspace", "title": "my-project" }],
129
+ "nodes": [{ "id": "src/index.js", "label": "index.js", "ext": ".js", "size": 1234, "dir": "src" }],
130
+ "links": [{ "source": "src/index.js", "target": "src/util.js", "kind": "import" }],
131
+ "stats": { "files": 2, "scanned": 2, "links": 1, "truncated": false, "durationMs": 4 }
132
+ }
133
+ ```
134
+
135
+ ### Client half (`client.source.js` → `client.js`)
136
+
137
+ - Registers `sidebar.panellist.actions` (the menu row) and `shell.overlay` (the dialog),
138
+ both through `ctx.slots.inject` / `ctx.slots.register`.
139
+ - Builds the d3 simulation once per loaded graph with `simulation.stop()`, then ticks it
140
+ from the plugin's `requestAnimationFrame` loop; hover changes update React state, but
141
+ pointer moves only mutate transforms, and frames are requested only while needed.
142
+ - Batches all solid edges into one stroke, all documentation edges into a dashed
143
+ stroke, all arrowheads into one fill, and all nodes into one fill per color group.
144
+ Link hit-testing is a screen-space segment-distance pass — no DOM.
145
+ - Layout seeds d3's phyllotaxis spiral and uses weak `forceX`/`forceY` centering, so
146
+ disconnected files stay in one cloud and fit-to-view never zooms to sub-pixel dots.
147
+ - `ResizeObserver` keeps the backing store matched to CSS size (DPR clamped to 2);
148
+ `MutationObserver` re-reads theme tokens when the app theme changes.
149
+ - `d3-force` (plus its UMD dependencies) is inlined into `client.js` by `build.mjs`:
150
+ the browser module table has no runtime npm resolution, so the bundle is
151
+ self-contained. `vendor/` pins the exact ISC-licensed distributions.
152
+ - Clicking a node builds the harness' own file address
153
+ (`dsh-resource://file/session/<session>/<path>`) and calls
154
+ `ctx.get('sidebarRight').openResource(...)`; the on-screen session comes from
155
+ `sidebarRight.mounted`, with the UI Session adapter as fallback.
156
+
157
+ ## Privacy
158
+
159
+ Connectome reads the workspace through the Host process, exactly like the rest of DSH.
160
+ It sends **nothing** to the network: no analytics, no remote API calls, no file
161
+ contents uploaded. The graph response stays between the Host and your local page; open
162
+ files are displayed by DSH's built-in preview, and Connectome itself never keeps or
163
+ transmits file contents.
164
+
165
+ ## Performance
166
+
167
+ - Canvas painting, one path per color group; only the hovered neighbourhood gets labels.
168
+ - The simulation stops at `alphaMin`; an interaction kicks it again.
169
+ - Measured layout cost on a development machine: ~1.1 ms/tick at 300 nodes, ~8 ms/tick
170
+ at 2,000 nodes; a 2,000-node / ~3,300-link scan runs in about half a second warm.
171
+ - Large workspaces are capped and report `stats.truncated`; the dialog shows a
172
+ "partial scan" marker.
173
+
174
+ ## Development
175
+
176
+ No dev dependencies are needed — `vendor/` is committed and the tests use Node builtins.
177
+
178
+ ```bash
179
+ node build.mjs # regenerate client.js from client.source.js + vendor/
180
+ npm test # scanner + artifact + package/release contract tests
181
+ npm run check # node --check on index.js and the generated client
182
+ npm pack --dry-run # inspect exactly what npm would publish
183
+ ```
184
+
185
+ `npm install` is only needed to rebuild `client.js` from a different d3-force copy:
186
+ `node build.mjs --modules <node_modules dir>` looks there after `vendor/`.
187
+ See [`CONTRIBUTING.md`](CONTRIBUTING.md) for the project layout and review rules, and
188
+ [`PUBLISHING.md`](PUBLISHING.md) for the maintainer release flow.
189
+
190
+ ## Styling note
191
+
192
+ The project-wide design-token rule asks frontend artifacts to use the `--ds-*` scale.
193
+ This plugin is a Harness UI surface, so it deliberately splits the two systems:
194
+
195
+ - **Colors** come only from the host's live `--dsw-alias-*` theme tokens (this is what
196
+ keeps the graph legible in both light and dark mode).
197
+ - **Spacing / radii / shadows / font sizes** use a locally declared `--ds-*` token
198
+ layer (4px rhythm, 4/8/12/16/20/24 px spacing, 4/8/12/16 px radii, the shadow scale
199
+ and the caption/body-sm/body/h3 type scale) — no off-scale numeric styling.
200
+
201
+ ## Limitations
202
+
203
+ - Regex-based parsing: aliases beyond `@/`/`~/`, `tsconfig` path maps and bundler
204
+ resolution rules are not modeled; bare package names do not become nodes.
205
+ - Files are only previewed as code when the harness' right-Sidebar document preview is
206
+ available; unsupported extensions fall back to plain text, and binary files are not
207
+ indexed at all.
208
+ - Very large repositories hit the scanner caps (see above) and show a partial graph.
209
+ - The graph is a viewer, not an editor: there is no refactoring, search or saved layout.
210
+
211
+ ## License
212
+
213
+ [MIT](LICENSE) © 2026 elalamiimed.
214
+
215
+ Bundled d3 distributions (`vendor/`) are ISC licensed, Copyright 2010–2021 Mike
216
+ Bostock; see [`vendor/LICENSE-d3.txt`](vendor/LICENSE-d3.txt). DeepSeek Harness and its
217
+ packages are separate projects with their own licenses.
package/SECURITY.md ADDED
@@ -0,0 +1,33 @@
1
+ # Security policy
2
+
3
+ Connectome is a local visualization plugin: it scans the current workspace on the
4
+ Host, serves the result over a same-origin HTTP route fenced by
5
+ `ctx.connection.requestRejection`, and renders it in the browser. It sends no
6
+ workspace data or telemetry to any third-party service.
7
+
8
+ ## Supported versions
9
+
10
+ | Version | Supported |
11
+ | --- | --- |
12
+ | 1.x | Yes |
13
+
14
+ ## Reporting a vulnerability
15
+
16
+ Please do **not** open a public issue for a security problem. Use GitHub's private
17
+ vulnerability reporting on this repository (**Security → Advisories → Report a
18
+ vulnerability**) or email the maintainer listed in `package.json`. You should get a
19
+ response within a few days.
20
+
21
+ Useful details: the affected version, the DSH version, the workspace shape, and the
22
+ steps needed to reproduce the issue.
23
+
24
+ ## Scope notes
25
+
26
+ - The scanner only reads text/source files under the selected workspace root, skips
27
+ symlinks, `node_modules`, `.git`, build outputs and dot-directories, and applies
28
+ file/duration/entry caps.
29
+ - File opening uses the harness' own right-Sidebar document preview and the
30
+ authenticated `dsh-resource://file/session/…` address; Connectome itself never
31
+ reads a file into its own UI or stores file contents.
32
+ - The generated browser bundle inlines d3 under its ISC license; see
33
+ `vendor/LICENSE-d3.txt`.