dsh-remote-vs 0.15.1 → 0.17.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/README.en.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  SSH host management inside the DSH Host process + helper push pipeline + a **VS Code-style remote
8
8
  workbench** (explorer / search / source control / commit graph with its commit-details pane / multi-tab editor / floating editor /
9
- side-by-side diff / multiple terminals). Hosts live in DSH Settings ("Remote hosts"); with `dsh-better-sidebar` installed
9
+ side-by-side diff / multiple terminals / port forwarding). Hosts live in DSH Settings ("Remote hosts"); with `dsh-better-sidebar` installed
10
10
  there is an extra standalone "Remote" tab, otherwise it falls back to a native right-Sidebar "Remote"
11
11
  page (same content, self-opened from the guide, per-session instances). The editor is ALSO mounted into
12
12
  the conversation view slot as a "远程编辑器" (remote editor) tab next to "对话 / 轨迹", so the code area is
@@ -91,7 +91,7 @@ extra configuration is needed.
91
91
 
92
92
  | Capability | Notes |
93
93
  | --- | --- |
94
- | Explorer | Lazy tree + one click expands/collapses a directory + hidden-files toggle; **new: a 150 ms hover prefetches** that folder's listing (the expand paints from cache and revalidates in the background; if the prefetch is still in flight, the click waits for it and shows the loading line like a cold directory). On the Host every browse request shares **one long-lived SFTP session**, cutting a listing from two round trips to one (**the first one after a cold start or after the 2 idle minutes still pays the channel open**); context menu: new / rename / delete / copy / move / paste / find in folder / insert `@` reference / **download to local** (files stream to this machine; a directory **or a multi-selection** is archived on the remote host as one `.tar.gz` and streamed, so nothing is buffered in Host memory; a native **Save as** dialog picks the destination when the browser supports it, otherwise the browser's download folder; a bottom-right **download panel** shows live progress, allows cancel, and reports completion/failure; the search-hit menu offers it too; a download ends in one of three honest states — **saved / handed to the browser / failed** — and a hand-off never reads as "done", nor does a Host failure get saved as a file; the tree's empty area has its own context menu (new / upload / paste) and uploads, pastes and drops are **serialized** (a second transfer is refused with an explanation); the tree is keyboard-operable (`↑↓` move, `←→` collapse/expand, `Enter` open, `Shift+F10` menu) and dialogs trap focus and close on `Esc`); git status colours and folder roll-up marks |
94
+ | Explorer | Lazy tree + one click expands/collapses a directory + hidden-files toggle; **new: a 150 ms hover prefetches** that folder's listing (the expand paints from cache and revalidates in the background; if the prefetch is still in flight, the click waits for it and shows the loading line like a cold directory). On the Host every browse request shares **one long-lived SFTP session**, cutting a listing from two round trips to one (**the first one after a cold start or after the 2 idle minutes still pays the channel open**); context menu: new / rename / delete / copy / move / paste / find in folder / insert `@` reference / **download to local** (files stream to this machine; a directory **or a multi-selection** is archived on the remote host as one `.tar.gz` and streamed, so nothing is buffered in Host memory; a native **Save as** dialog picks the destination when the browser supports it, otherwise the browser's download folder; a bottom-right **download panel** shows live progress, allows cancel, and reports completion/failure; the search-hit menu offers it too; a download ends in one of three honest states — **saved / handed to the browser / failed** — and a hand-off never reads as "done", nor does a Host failure get saved as a file; the tree's empty area has its own context menu (new / upload / paste) and uploads, pastes and drops are **serialized** (a second transfer is refused with an explanation); the tree is keyboard-operable (`↑↓` move, `←→` collapse/expand, `Enter` open, `Shift+F10` menu) and dialogs trap focus and close on `Esc`); git status colours and folder roll-up marks; **drag-hover expand**: while dragging a row or dropping OS files, resting the pointer on a collapsed directory for ~650 ms opens it (spring-loaded folder, so the drop lands inside the folder you just revealed; cancelling the drag leaves nothing half-open) |
95
95
  | Transfer speed | Uploads/downloads use a **256 KiB × 32 in-flight window** over SSH (pipelined SFTP): single-file downloads and drag-and-drop uploads run ~8× faster than one stream, and the helper push (45 MB) uses parallel `fastPut` too; large uploads are no longer killed by a 60 s deadline (progress watchdog instead). A **download above 4 MiB gets a second dedicated SFTP channel** (one SSH channel caps its window at 2 MiB, so each extra channel adds a window): an interleaved same-process A/B measured **about 1.1–1.4×** (medians of 1.08–1.43× across samples, link-dependent; raw read probes 1.6–1.8× — the product opens two channels, not four); small files keep one channel and one less channel slot, and uploads stay single-channel (the remote write path is the bound, extra channels gain nothing) |
96
96
  | Search | Two modes: **file names** (remote `find`) and **contents** (remote `grep`). Content mode has a scope folder, `Aa` (case) / `ab_` (whole word) / `.*` (regex), results grouped per file with match highlights, and clicking a hit jumps to that line; **content mode can be aborted** (changing or clearing the query kills the running remote `grep`; an older Host without the streaming route degrades to a one-shot, non-cancellable query), success with stderr warnings is reported above the results, and a **directory** hit in name mode is revealed in the tree instead of being opened as a file |
97
97
  | Connection status and offline read-only | The top bar and the editor info bar show the current workspace's SSH link state (**connection OK / connection issue / ready, connects on demand**): a drop is no longer silent — open editor tabs keep their cached content and turn **read-only** (saves are blocked with an explanation), the tree keeps showing cached directories while background refreshes stay quiet, and uncached directories say they are offline. When the link recovers, directories, git status, **unmodified file tabs and read-only diff tabs** refresh automatically (tabs with unsaved edits are left alone and the user is told). An errored link is retried at most three times, 30 s apart, then the chip is a manual retry control. While the link is down, "Undo this change" and the diff's hunk actions are blocked too; **a single operation's deadline is NOT treated as a broken link** — the chip stays ok and only that operation fails, with the real reason; when the link is down and the workspace has no cache, the SCM panel says it cannot read instead of sitting on "loading". **No cross-reload persistent cache** (remote source never lands on disk) — a deliberate privacy trade-off |
@@ -99,6 +99,7 @@ extra configuration is needed.
99
99
  | Session change review | The **collapsible** panel above the composer: what THIS SESSION changed (one row per file, file-type icon, `+a −b` on the right); clicking a file opens it in the remote editor with **line shading plus character-level inline diff**, `n/N ↑↓` jumps between change points, and hovering a changed line offers **Undo this change** (remote `git apply -R`). See "Session change review" below |
100
100
  | Side-by-side diff | Panes stay **exactly equal** + per-hunk buttons in the middle gutter + a **top horizontal scrollbar** (a very long line can no longer break the symmetry) + pinned line numbers, **rendering only the rows inside the viewport** (a 3000-line file goes from 9000 row containers to ~174, with exactly the same scroll range as a full render); switch between "before / after", and the after side is editable and savable (the save writes the working-tree file back; a diff above 8MiB is read-only, so a truncated prefix can never be written over the real file) |
101
101
  | Commit graph | SVG branch/merge graph; selecting a commit opens the **resizable / expandable commit-details pane** below it with three views: **Commit details** (subject, author, time, full hash + copy, parents, refs, message body, checkout), **Contents** (changed files grouped by directory, collapsible and path-filterable; click for the diff, right-click or the row button to open in the editor), **Diff** (only the first ~1500 rows start expanded, later files start folded; both line numbers, `+/−` counts, line wrapping, previous/next-file navigation, and copy of one file's patch or the whole patch). Merge commits are shown against their **first parent** (git lists no files for a merge otherwise) |
102
+ | AI review | A single-file diff OR a **whole commit** can be handed to the conversation with one click — the request is **appended to the composer draft only** (nothing is sent automatically, and you can edit it first): a diff up to 32 KiB is inlined verbatim; a larger one (or one silently truncated at the 2 MB cap) becomes a summary request — file/commit facts + hunk headers + "fetch it yourself with `git show`" (a 2 MB diff is hundreds of thousands of tokens, so inlining it is pointless); an untracked or binary file is passed by path and the model reads it. Entries: the side-by-side diff toolbar and the commit pane's Diff toolbar; the button is disabled with the reason when the current session is not bound to this remote workspace, or the host exposes no conversation input channel |
102
103
  | Multi-tab editor | Open/save/reload, dirty marks, several files at once; **saves are atomic** (side file + rename, writing through symlinks and keeping the mode bits); **a save is checked against the remote baseline** — when the file was written by someone else (an agent through the transparent route, a terminal, another editor) since it was opened, the save is refused and offers "overwrite / load remote version / show difference" instead of overwriting silently; image preview, Markdown/HTML preview (source vs preview); closing a tab, reloading and switching workspace all **ask first** when there are unsaved edits (a workspace switch clears every tab, so it asks); `Ctrl+S` works globally, even when the editor is not focused; **a page reload reopens the file tabs you had** (per workspace, at most 12; paths only, never contents; tabs that no longer open are skipped and counted; caret and scroll position are not restored) |
103
104
  | Floating editor | Three entries: "Open in floating editor" in the file-tree / search-hit / source-control context menus, plus **double-clicking the "remote editor" tab** to float the editor as it stands (same tabs, previews, diff, find and change marks — not a second, thinner editor). Drag the title bar to move, drag any of the eight edges/corners to resize, maximize/restore (or double-click the title bar); **minimize to a draggable floating ball** (dirty dot on it, click or press Enter to restore, drag to park it anywhere); `Ctrl+wheel` zooms the editor text. Position, size, font size and the ball's spot survive a page refresh |
104
105
  | Syntax highlighting | VS Code **Dark+ / Light+** palettes; covers java/aidl/smali, c/c++, go, rust, js/ts, json, py, yaml, xml, html/css, md, sh, properties/rc/toml, diff …; a **fallback colorer** takes over when no grammar matches, so a file is never left monochrome. Honest caveat: kotlin / gradle / smali are coloured by the Java grammar (no dedicated package), which gets keywords, strings and comments right but does not split their own syntax |
@@ -107,6 +108,7 @@ extra configuration is needed.
107
108
  | Jump | Clicking a search hit opens the file at that line, centres it and **lights the landing line** (fades after ~2.6s); repeat jumps in the same file work |
108
109
  | Terminals | Tabbed multi-terminal (`+` to create, `✕`/middle-click to close behind a confirm), across hosts; session ids are persisted so a page refresh reattaches to the running shells, and a session is kept for **10 minutes after its last socket goes away** (enough for a refresh or a browser-tab switch) before the remote shell is closed; **a socket drop (as opposed to a shell exit) keeps the session and offers a one-click reattach** (the same session id reattaches, and the Host still reclaims it after the 10-minute TTL above), and only a real exit clears it |
109
110
  | Workspaces | Binding list + routing-mode dropdown + the dual-mode (local / remote) new-workspace wizard; **unbinding asks first** (sessions and history stay readable, new remote calls are refused) |
111
+ | Port forwarding | A sidebar **"Ports"** page: lists the remote host's listening TCP ports (`ss`, falling back to `netstat`) and forwards any of them to a local port in one click, with the local URL for copying/opening. Manual rules ("remote address:port → local port, which may be auto-assigned") are supported too. **The local listener binds `127.0.0.1` only** (`ssh -L` semantics — never exposed to the LAN); each rule has its own channel budget and never consumes one of the six exec/SFTP slots. An SSH drop or the idle eviction does not kill the listener: the next local connection simply re-dials. Rules live in the browser (restored after a reload) and every one can be stopped; disabling the plugin, deleting the host, or unloading it releases the local ports. When the remote has neither `ss` nor `netstat`, or the probe times out or is interrupted, the panel says "cannot enumerate" instead of showing an empty list |
110
112
 
111
113
  ### Hosts and transport
112
114
 
@@ -148,6 +150,8 @@ dsh_remote_vs/
148
150
  │ ├── importers.ts # ssh_config / dsh-ssh.json parsing importers
149
151
  │ ├── routes.ts # /api/dsh-remote/* route table + terminal WebSocket upgrade
150
152
  │ ├── terminal.ts # PTY session registry (reconnect-on-refresh/disconnect cleanup)
153
+ │ ├── forward.ts # local port-forward manager (direct-tcpip channels / one listener per rule / budgets)
154
+ │ ├── listen-ports.ts # remote listening-port probe (ss/netstat command + pure parser)
151
155
  │ ├── tools.ts # the 5 Agent tool definitions
152
156
  │ ├── http.ts / loopback.ts # JSON body IO + loopback trust fence
153
157
  │ ├── git-format.ts # git command builders + pure frontend parsing (zero Host additions)
@@ -172,6 +176,7 @@ dsh_remote_vs/
172
176
  │ ├── RemoteRoot.tsx # sidebar surface: VS Code activity rail (explorer/search/SCM/history/editor/terminal/workspaces)
173
177
  │ ├── RemoteEditorView.tsx # conversation-view surface (the "remote editor" tab next to 对话/轨迹, full width)
174
178
  │ ├── RemoteExplorer.tsx # explorer: tree + context menu + file ops + @ references + status marks
179
+ │ ├── drag-expand.ts # drag-hover auto-expand (pure state machine, shared by both drag paths)
175
180
  │ ├── SearchView.tsx # search panel: name / content modes + Aa/ab_/.* + grouped hits + jump
176
181
  │ ├── EditorPane.tsx # editor pane: tabs + info bar (build stamp / tok count) + image/MD/HTML preview
177
182
  │ ├── FloatingEditorWindow.tsx # floating window frame (title-bar drag/8-way resize/maximize/ball minimize/font zoom)
@@ -200,18 +205,20 @@ dsh_remote_vs/
200
205
  │ │ ├── tokenize.ts / markdown.tsx # read-only pane tokenizer / dependency-free markdown renderer
201
206
  │ ├── NativeExplorer.tsx# native page type definition + seat body (no-sidebar fallback)
202
207
  │ ├── composer.ts / use-remote-chat-target.ts / selection-popup.ts # remote @refs/selection-to-chat
208
+ │ ├── ai-review.ts # AI review prompt builder (single diff / whole commit, byte tiers, pure)
203
209
  │ ├── api.ts # typed fetch wrapper over /api/dsh-remote
204
- │ ├── HostsView / WorkspacesView / WorkspaceWizard / TerminalView / XTerm / Dialog
210
+ │ ├── HostsView / WorkspacesView / WorkspaceWizard / TerminalView / XTerm / PortsView / Dialog
205
211
  │ ├── SettingsHosts.tsx # settings occupants (host mgmt/binding list, self-fetching)
206
212
  │ ├── DirectoryFlow.tsx # native entry occupant (local dual-mode/remote wizard)
207
213
  │ ├── RemoteDirectoryPicker.tsx# remote directory browser dialog
208
214
  │ └── i18n.ts / theme.ts / ui.tsx # bilingual dictionary/theme signal/shared styles
209
215
  ├── vendor/dsh-remote-helpers/ # helper seeds (shipped, seeded into cache at startup, see below)
210
- ├── docs/ # local-only working docs (never pushed to GitHub)
211
- │ ├── P2-PLAN.md # P2 architecture/phases/acceptance matrix (with per-item status)
212
- │ └── MAINTENANCE.md # local-only (.gitignore), not shipped: DSH upgrade impact + helper procedure
216
+ ├── docs/ # local-only working docs (only docs/media/ screenshots ship)
217
+ │ ├── MAINTENANCE.md # local-only (.gitignore), not shipped: upgrade impact, checklist, pitfalls, release
218
+ │ ├── VERSION-HISTORY.md # local-only: per-release change log (0.7.1 → 0.17.0)
219
+ │ └── GATES.md # local-only: local gate inventory and measured assertion counts
213
220
  ├── locale/ # bilingual plugin metadata
214
- └── lib/ # build output (gitignored, restart after link install to take effect)
221
+ └── lib/ # build output (**must be committed**; only .map is ignored; restart after link install)
215
222
  ```
216
223
 
217
224
  `vendor/dsh-remote-helpers/` (committed) holds helper seeds: at startup the plugin spreads them into
@@ -355,7 +362,7 @@ over helper RPC (fs) / ssh2 (processes), local stays untouched; both share one H
355
362
  - Disconnects: in-flight calls are not replayed; new calls reconnect automatically; the link state is shown explicitly in the top bar / editor info bar, and while it is down the editor and cached directories stay **read-only visible** (see "Connection status and offline read-only")
356
363
  - Verify: `npx tsc -p tsconfig.scratch.json && node .spike/build/.spike/p2-router.js`
357
364
  (real remote + real Cordis + real router classes, 61/61; P0 routing and GUI need a Host restart + smoke pass)
358
- - Details: `docs/P2-PLAN.md` (§8 acceptance matrix with per-item status)
365
+ - Details: the local-only `docs/MAINTENANCE.md` (§2 coupling points, §3 checklist)
359
366
 
360
367
  ## Self-built helper (P1)
361
368
 
@@ -377,7 +384,8 @@ Upstream never published helper binaries (all Release assets are empty), so this
377
384
  - Passwords / key passphrases are stored in plaintext in `dsh-remote.json` (0600) — same trust model as the existing SSH plugin.
378
385
  - Pushed artifacts are sha256-verified both ways (tarball in, binary out); the helper install dir is separate from workspaces; the sidecar's `version`, platform and tarball path are whitelist-validated (no unvalidated string is interpolated into a remote shell line), and a failed install keeps the previous version.
379
386
  - Host config writes are fsync'd and re-checked against a stamp (a concurrent Desktop/Web edit inside the read-modify-write window is replayed instead of silently overwritten).
380
- - Remote sessions may read explicit local absolute paths (the tool spill-file contract requires it); acceptable under the same model trust — see `docs/P2-PLAN.md` §4 note.
387
+ - Remote sessions may read explicit local absolute paths (the tool spill-file contract requires it); acceptable under the same model trust — a known trade-off recorded in the local maintenance notes.
388
+ - **Port forwards bind `127.0.0.1` only**: another local process can reach one, which is exactly the `ssh -L` trust boundary (the local user account). The target is dialed **from the remote host**, so it can reach that host's private network; "open in browser" always builds an `http://` URL — a forwarded HTTPS service needs the scheme edited by hand.
381
389
 
382
390
  ## Development
383
391
 
@@ -444,7 +452,7 @@ tsc, to the bundler and to jsdom — this fixture is the only place they reprodu
444
452
  > exactly why "57 call sites" and "55 checks run" differ by 2).
445
453
 
446
454
  The live-host regression is still `npx tsc -p tsconfig.scratch.json && node .spike/build/.spike/p2-router.js`.
447
- Before touching anything for a new DSH release, read the local-only `docs/MAINTENANCE.md` (§2 coupling points, §3 checklist) — it is gitignored, so a clone will not have it. After any change (host half or client half) the mandatory steps are: `pnpm run build` → `node scripts/verify-lib.mjs` (entries present, committed and loadable) → restart `dsh web`; and before committing, run every local gate under `scripts/` (`node scripts/check-*.mjs`, 45 of them at the time of writing, plus `verify-lib.mjs` and the shared TS loader `_ts-hook.mjs`).
455
+ Before touching anything for a new DSH release, read the local-only `docs/MAINTENANCE.md` (§2 coupling points, §3 checklist) — it is gitignored, so a clone will not have it. After any change (host half or client half) the mandatory steps are: `pnpm run build` → `node scripts/verify-lib.mjs` (entries present, committed and loadable) → restart `dsh web`; and before committing, run every local gate under `scripts/` (`node scripts/check-*.mjs`, 49 of them at the time of writing, plus `verify-lib.mjs` and the shared TS loader `_ts-hook.mjs`).
448
456
 
449
457
  ## License
450
458
 
package/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  中文 | [English](./README.en.md)
6
6
 
7
7
  Host 进程内的 SSH 主机管理 + helper 推送流水线 + **VS Code 式远端工作台**
8
- (资源管理器 / 搜索 / 源代码管理 / 提交图与提交详情面板 / 多标签编辑器 / 悬浮编辑器 / 并排 Diff / 多终端)。
8
+ (资源管理器 / 搜索 / 源代码管理 / 提交图与提交详情面板 / 多标签编辑器 / 悬浮编辑器 / 并排 Diff / 多终端 / 端口转发)。
9
9
  主机配在 DSH 设置里(“远程主机”项);装了 `dsh-better-sidebar` 时另有
10
10
  独立“远程”tab,没装则退到原生右侧栏“远程”页(同内容,引导页自助开,per-session 实例)。
11
11
  编辑器还额外挂到会话视图槽,与“对话 / 轨迹”并列成一个**远程编辑器**标签,
@@ -76,7 +76,7 @@ Host 转发(终端按 `__DSH_TRANSPORT__.streamBaseUrl` 解析地址),无
76
76
 
77
77
  | 能力 | 说明 |
78
78
  | --- | --- |
79
- | 资源管理器 | 懒加载目录树 + 单击目录即展开/折叠 + 隐藏文件开关;**新增悬停 150 ms 预取**下一层列表(展开时先用缓存上屏、后台再校验;预取仍未返回时点开会等它,与冷启动一样显示加载行);Host 侧浏览请求复用**一条常驻 SFTP 会话**,一次列目录的往返从 2 个降到 1 个(**冷启动或空闲 2 分钟关闭后的第一次仍要开会话**);右键菜单:新建/改名/删除/复制/移动/粘贴/在此文件夹查找/插入 `@` 引用/**下载到本地**(文件流式下载、目录或**多选**在远端打包成 `.tar.gz` 流式下载,不占 Host 内存;浏览器支持时先弹**另存为**对话框选保存路径,不支持时落到默认下载目录;右下角**下载面板**显示实时进度、可取消,并提示完成/失败;搜索结果右键同样支持;下载结果分「已保存 / 已交给浏览器 / 失败」三态,交给浏览器后**不再显示成已完成**,Host 失败也不会被当成文件存下;树空白区也有右键菜单(新建/上传/粘贴),上传、粘贴、拖放等写操作**串行**(另一个传输进行中会拒绝并提示);键盘可用(`↑↓` 选择、`←→` 折叠/展开、`Enter` 打开、`Shift+F10` 菜单),对话框有焦点陷阱与 `Esc` 关闭);git 状态色与文件夹聚合标记 |
79
+ | 资源管理器 | 懒加载目录树 + 单击目录即展开/折叠 + 隐藏文件开关;**新增悬停 150 ms 预取**下一层列表(展开时先用缓存上屏、后台再校验;预取仍未返回时点开会等它,与冷启动一样显示加载行);Host 侧浏览请求复用**一条常驻 SFTP 会话**,一次列目录的往返从 2 个降到 1 个(**冷启动或空闲 2 分钟关闭后的第一次仍要开会话**);右键菜单:新建/改名/删除/复制/移动/粘贴/在此文件夹查找/插入 `@` 引用/**下载到本地**(文件流式下载、目录或**多选**在远端打包成 `.tar.gz` 流式下载,不占 Host 内存;浏览器支持时先弹**另存为**对话框选保存路径,不支持时落到默认下载目录;右下角**下载面板**显示实时进度、可取消,并提示完成/失败;搜索结果右键同样支持;下载结果分「已保存 / 已交给浏览器 / 失败」三态,交给浏览器后**不再显示成已完成**,Host 失败也不会被当成文件存下;树空白区也有右键菜单(新建/上传/粘贴),上传、粘贴、拖放等写操作**串行**(另一个传输进行中会拒绝并提示);键盘可用(`↑↓` 选择、`←→` 折叠/展开、`Enter` 打开、`Shift+F10` 菜单),对话框有焦点陷阱与 `Esc` 关闭);git 状态色与文件夹聚合标记;**拖拽悬停展开**:拖动行或拖入系统文件时,指针在收起目录上停留约 650 ms 就自动展开该目录(spring-loaded folder,松手即落在已展开的目标里;中途取消不会留下自动展开) |
80
80
  | 传输性能 | 上传/下载走 SSH 的 **256 KiB × 32 并发窗口**(ssh2 pipelined SFTP):单文件下载与拖放上传比单流快约 8 倍,helper 推送(45 MB 包)同样走并行 `fastPut`;大文件上传不再被 60 秒期限误杀(改用进度看门狗)。**大于 4 MiB 的下载再开一条专用 SFTP 通道**(单条 SSH 通道的窗口上限是 2 MiB,多一条通道多一个窗口):同进程交错 A/B 实测**约 1.1–1.4×**(多次采样中位 1.08–1.43×,随链路波动;原始读探针 1.6–1.8×,产品只开两条通道,不开四条);小文件不开第二条,省一个通道槽。上传保持单通道(服务端写入是瓶颈,多通道无收益) |
81
81
  | 搜索 | 两档:**文件名**(远端 `find`)与**内容**(远端 `grep`)。内容档带范围目录、`Aa`(大小写)/`ab_`(全字)/`.*`(正则)、结果按文件分组、命中高亮,点条目跳到该行;**内容档可中止**(改写或清空查询会终止正在跑的远端 `grep`;老 Host 无流式路由时退化为不可取消的一次性查询),成功但远端给了 stderr 警告时在结果上方提示;文件名档里命中**目录**时在树中定位,而不是当文件打开 |
82
82
  | 连接状态与离线只读 | 顶部栏与编辑器信息栏显示当前工作区的 SSH 连接状态(**连接正常 / 连接异常 / 就绪·按需连接**):断线不再静默——已打开的编辑器标签保留缓存内容并切为**只读**(保存被拦截并说明原因),目录树继续显示已缓存目录、后台刷新静默,未缓存目录显示离线提示;连接恢复后自动刷新目录、Git 状态、**未修改的文件标签和只读 diff 标签**(有未保存改动的标签不动并提示)。错误态不会无限重连:每 30 秒最多自动重试 3 次,之后点状态图标手动重试。断线时「撤销这处改动」和 diff 的 hunk 操作同样被拦截;**单次操作的超时(deadline)不当作链路故障**——chip 保持正常,只有该次操作失败并说明原因;断线且该工作区没有缓存时,SCM 面板直接说明无法读取,而不是停在「加载中」。**不做**跨页面刷新的持久化缓存(远端源码不落盘),这是有意的隐私取舍 |
@@ -84,6 +84,7 @@ Host 转发(终端按 `__DSH_TRANSPORT__.streamBaseUrl` 解析地址),无
84
84
  | 会话改动审阅 | 输入框上方的**可收纳**面板,按**会话**列出改了什么(一行一个文件、文件类型图标、右侧 `+a −b`);点文件在远程编辑器里打开并画**整行着色 + 行内字符级差异**,右上角 `n/N ↑↓` 跳改动点,悬浮改动行可**撤销**这处改动(远端 `git apply -R`)。详见下文「会话改动审阅」 |
85
85
  | 并排 Diff | 左右**严格等分** + 中间 gutter 逐 hunk 按钮 + **顶部横向滚动条**(一行很长也不会破坏对称)+ 行号钉在左侧,**只渲染视口内的行**(3000 行文件从 9000 个行容器降到约 174 个,滚动范围与整篇渲染完全一致);可切「变更前 / 变更后」,变更后可编辑并保存(保存写回工作树文件;超过 8MiB 的差异只读,避免把截断内容写回去) |
86
86
  | 提交图 | SVG 分支/合并图;点选提交后,下方**可调高度 / 可全屏**的提交详情面板给出三个视图:**提交详情**(标题、作者、时间、完整哈希+复制、父提交、ref、正文、检出)、**内容**(改动文件按目录分组、可折叠、可过滤,单击看差异、右键或行尾按钮在编辑器中打开)、**差异**(默认只展开前约 1500 行、其余文件折叠;双行号、`+/−` 计数、自动换行、上一/下一个文件、复制文件补丁或整个补丁)。合并提交按**首父**展示(git 对 merge 默认不给文件列表) |
87
+ | AI 审查 | 单文件 diff 与**整个提交**都能一键把审查请求追加到对话草稿(**只预填,不自动发送**,发送前可自行修改):≤32 KiB 内嵌完整 diff;更大或被 2 MB 静默截断时改为「文件/提交信息 + 变更块头 + 自行 `git show`」的摘要式请求(2 MB diff 约几十万 token,硬塞没有意义);未跟踪/二进制文件只给路径让 AI 自行读取。入口:并排 diff 工具栏、提交详情「差异」工具栏;当前会话不在该远端工作区、或宿主没有可用的对话输入通道时按钮禁用并写明原因 |
87
88
  | 多标签编辑器 | 打开/保存/重载、脏标记、多文件标签并存;**保存是原子的**(侧文件 + 重命名,写穿符号链接并保留权限位);**保存前校验远端基线**:文件在打开之后被别人(Agent 的透明路由、终端、另一个编辑器)改过时保存被拒绝,并给出「覆盖 / 载入远端版本 / 查看差异」,不再静默覆盖;图片预览、Markdown/HTML 预览(源码/预览切换);关闭标签、重载、切工作区遇到未保存改动都会**先确认**(切工作区会清空全部标签,所以先问);`Ctrl+S` 全局生效,焦点不在编辑器里也能保存;**刷新页面后自动恢复上次打开的文件标签**(按工作区记,最多 12 个;只存路径不存内容,打不开的会跳过并提示数量;光标与滚动位置不恢复) |
88
89
  | 悬浮编辑器 | 三个入口:文件树 / 搜索结果 / 源代码管理右键「在悬浮编辑器中打开」,以及**双击会话视图的「远程编辑器」标签**把当前编辑器整体浮出(同一套标签、预览、Diff、查找、改动标记,不是另写一个编辑器)。窗口可拖标题栏移动、拖八个边角缩放、最大化/还原、双击标题栏切换最大化;**最小化成一个可拖动的悬浮球**(球上有未保存脏点,点一下或按 Enter 恢复,拖动可换位置);`Ctrl+滚轮` 缩放编辑器字号;位置、大小、字号和球的位置跨刷新记住 |
89
90
  | 语法高亮 | VS Code **Dark+ / Light+** 配色;覆盖 java/aidl/smali、c/c++、go、rust、js/ts、json、py、yaml、xml、html/css、md、sh、properties/rc/toml、diff 等;**兜底着色器**在语法包没命中时自动接管,不会出现整篇无色。诚实说明:kotlin / gradle / smali 用 Java 语法着色(没有专用语法包),效果是关键字/字符串/注释正确、专有语法不细分 |
@@ -92,6 +93,7 @@ Host 转发(终端按 `__DSH_TRANSPORT__.streamBaseUrl` 解析地址),无
92
93
  | 跳转 | 从搜索结果点进文件 → 跳到该行 + 垂直居中 + **落地行高亮**(约 2.6 秒后淡出);同文件反复跳都生效 |
93
94
  | 多终端 | 标签式多终端(`+` 新建、`✕`/中键关闭带确认)、可跨主机;刷新页面按 session id 自动重连回原会话,**socket 全断开后会话保留 10 分钟**(够刷新、够切浏览器标签页接回),超时才关闭远端 shell;**socket 断开(而不是 shell 退出)时会话保留、可一键接回**(同一 session id 重连,Host 侧仍按上面 10 分钟 TTL 回收),只有真正退出才清会话 |
94
95
  | 工作区 | 绑定列表 + 路由档位下拉 + 新建工作区双模向导(本地 / 远端);**解绑前确认**(会话与历史仍可读,新的远端调用会被拒绝) |
96
+ | 端口转发 | 侧边栏「端口」页:列出远端监听端口(`ss`,没有则 `netstat`),对任一端口**一键转发到本地**、复制本地 URL、在浏览器打开;也支持手动「远端地址:端口 → 本地端口(可自动分配)」规则。**本地只监听 `127.0.0.1`**(`ssh -L` 语义,不暴露到局域网);每条转发有自己的通道预算,不占池里的 6 个执行/SFTP 通道;SSH 掉线或闲置回收后,下一条本地连接自动重拨而不影响监听;规则存浏览器(刷新后恢复),可逐条停止;关闭插件、删除主机、卸载插件都会释放本地端口。远端既没有 `ss` 也没有 `netstat`、或探测超时/中断时,明确显示「无法枚举」而不是空列表 |
95
97
 
96
98
  ### 主机与通道
97
99
 
@@ -133,6 +135,8 @@ dsh_remote_vs/
133
135
  │ ├── importers.ts # ssh_config / dsh-ssh.json 解析导入
134
136
  │ ├── routes.ts # /api/dsh-remote/* 路由表 + 终端 WebSocket 升级
135
137
  │ ├── terminal.ts # PTY 会话注册表(刷新重连/断开清理)
138
+ │ ├── forward.ts # 本地端口转发管理器(direct-tcpip 通道/每规则监听器/连接预算)
139
+ │ ├── listen-ports.ts # 远端监听端口探测(ss/netstat 命令 + 纯解析器)
136
140
  │ ├── tools.ts # 5 个 Agent 工具定义
137
141
  │ ├── http.ts / loopback.ts # JSON 体读写 + 回环信任围栏
138
142
  │ ├── git-format.ts # git 命令构造 + 纯前端解析(Host 零增量)
@@ -157,6 +161,7 @@ dsh_remote_vs/
157
161
  │ ├── RemoteRoot.tsx # 右侧栏挂载面:VS Code 式活动栏(资源管理器/搜索/SCM/提交图/编辑器/终端/工作区)
158
162
  │ ├── RemoteEditorView.tsx # 会话视图挂载面(与 对话/轨迹 并列的「远程编辑器」标签,整屏宽)
159
163
  │ ├── RemoteExplorer.tsx # 资源管理器:树 + 右键菜单 + 文件操作 + @ 引用 + 状态标记
164
+ │ ├── drag-expand.ts # 拖拽悬停自动展开目录(纯状态机,两条拖拽路径共用)
160
165
  │ ├── SearchView.tsx # 搜索面板:文件名 / 内容 两档 + Aa/ab_/.* + 分组结果 + 跳转
161
166
  │ ├── EditorPane.tsx # 编辑器面板:多标签 + 信息栏(构建戳/tok 计数)+ 图片/MD/HTML 预览
162
167
  │ ├── FloatingEditorWindow.tsx # 悬浮编辑器窗口(标题栏拖动/八向缩放/最大化/最小化悬浮球/字号缩放)
@@ -185,18 +190,20 @@ dsh_remote_vs/
185
190
  │ │ ├── tokenize.ts / markdown.tsx # 只读面板分词器 / 零依赖 Markdown 渲染
186
191
  │ ├── NativeExplorer.tsx# 原生页类型定义 + seat 正文(无 sidebar 兜底)
187
192
  │ ├── composer.ts / use-remote-chat-target.ts / selection-popup.ts # 远端 @引用/选中加对话
193
+ │ ├── ai-review.ts # AI 审查 prompt 构造(单文件 diff / 整提交,按字节分级,纯函数)
188
194
  │ ├── api.ts # /api/dsh-remote 类型化 fetch 封装
189
- │ ├── HostsView / WorkspacesView / WorkspaceWizard / TerminalView / XTerm / Dialog
195
+ │ ├── HostsView / WorkspacesView / WorkspaceWizard / TerminalView / XTerm / PortsView / Dialog
190
196
  │ ├── SettingsHosts.tsx # 设置两节 occupant(主机管理/绑定列表,自取数)
191
197
  │ ├── DirectoryFlow.tsx # 原生入口 occupant(本地双模/远端向导)
192
198
  │ ├── RemoteDirectoryPicker.tsx# 远端目录浏览弹窗
193
199
  │ └── i18n.ts / theme.ts / ui.tsx # 双语词典/主题信号/共享样式
194
200
  ├── vendor/dsh-remote-helpers/ # helper 种子(随包发布,启动铺缓存,见下)
195
- ├── docs/ # 本地工作文档(不推送 GitHub)
196
- │ ├── P2-PLAN.md # P2 架构/分期/验收矩阵(含逐项状态)
197
- │ └── MAINTENANCE.md # 本地私有(.gitignore),不入库:DSH 升级影响面 + helper 升级流程
201
+ ├── docs/ # 本地工作文档(不推送 GitHub;只有 docs/media/ 的截图随仓库公开)
202
+ │ ├── MAINTENANCE.md # 本地私有(.gitignore,不入库):升级影响面/检查清单/踩坑/发布流程
203
+ │ ├── VERSION-HISTORY.md # 本地私有:逐版本变更纪要(0.7.1 → 0.17.0)
204
+ │ └── GATES.md # 本地私有:本地门禁清单与实跑条数
198
205
  ├── locale/ # 插件元信息双语
199
- └── lib/ # 构建产物(gitignored,link 安装后重启即生效)
206
+ └── lib/ # 构建产物(**必须入库**,只有 .map 忽略;link 安装后重启即生效)
200
207
  ```
201
208
 
202
209
  `vendor/dsh-remote-helpers/`(入库)是 helper 种子:插件启动时自动铺到
@@ -314,7 +321,7 @@ helper RPC(fs)/ ssh2(进程),本地一切不变;两者同 Host、共
314
321
  - 断线:在途不重放;新调用自动重连;连接状态由顶部栏/编辑器信息栏指示器显式显示,断线期间编辑器与已缓存目录**只读可见**(见「连接状态与离线只读」)
315
322
  - 验证:`npx tsc -p tsconfig.scratch.json && node .spike/build/.spike/p2-router.js`
316
323
  (真远端 + 真 Cordis + 真路由类,61/61;P0 路由与 GUI 需重启 Host 后冒烟)
317
- - 详见 `docs/P2-PLAN.md`(§8 验收矩阵逐项状态)
324
+ - 详见本地维护文档 `docs/MAINTENANCE.md`(§2 逐项耦合点 + §3 升级清单)
318
325
 
319
326
  ## Helper 自编译(P1)
320
327
 
@@ -338,7 +345,8 @@ helper RPC(fs)/ ssh2(进程),本地一切不变;两者同 Host、共
338
345
  - 密码 / 私钥口令以明文保存在 `dsh-remote.json`(0600),与现有 SSH 插件同一信任模型。
339
346
  - 推送物逐包验 sha256(tarball 进、binary 出,双重校验);helper 安装目录与工作区分开;sidecar 的 `version`、平台与 tarball 路径都走白名单校验(不内插未校验字符串到远端 shell 行),安装失败会保留上一版。
340
347
  - 主机配置写入走 fsync + 变更戳复核(读-改-写窗口内被别的进程改过会重放,而不是静默覆盖)。
341
- - 远端会话可读显式本机绝对路径(工具 spill 文件契约要求);同模型信任下可接受,见 `docs/P2-PLAN.md` §4 备注。
348
+ - 远端会话可读显式本机绝对路径(工具 spill 文件契约要求);同模型信任下可接受,属已知取舍,本地维护文档有记录。
349
+ - **端口转发只绑 `127.0.0.1`**:本机其他进程能连它是 `ssh -L` 的既定语义(信任边界是本机用户账户)。目标地址由**远端主机**拨号,因此可访问远端内网;「在浏览器中打开」固定按 `http://` 生成,转发 HTTPS 服务需手工改成 `https://`。
342
350
 
343
351
  ## 开发
344
352
 
@@ -397,7 +405,7 @@ node .spike/letter-check.mjs # 状态字母:未跟踪 ? 与冲突 U 不再
397
405
  > 失败时才触发,所以「调用点 57」与「跑出来 55」本来就该差 2)。
398
406
 
399
407
  真机回归仍是 `npx tsc -p tsconfig.scratch.json && node .spike/build/.spike/p2-router.js`。
400
- DSH 发新版时先读本地维护文档 `docs/MAINTENANCE.md`(§2 逐项耦合点 + §3 升级清单)再动手;该文件被 .gitignore,克隆仓库的人看不到。改动后(无论 host 半还是 client 半)的必做动作是:`pnpm run build` → `node scripts/verify-lib.mjs`(核对 `lib/` 齐全、已入库、能加载)→ 重启 `dsh web`,提交前把 `scripts/` 下的本地门禁逐个跑一遍(`node scripts/check-*.mjs`,当前 45 个;另有 `verify-lib.mjs` 与共享 TS 加载器 `_ts-hook.mjs`)。
408
+ DSH 发新版时先读本地维护文档 `docs/MAINTENANCE.md`(§2 逐项耦合点 + §3 升级清单)再动手;该文件被 .gitignore,克隆仓库的人看不到。改动后(无论 host 半还是 client 半)的必做动作是:`pnpm run build` → `node scripts/verify-lib.mjs`(核对 `lib/` 齐全、已入库、能加载)→ 重启 `dsh web`,提交前把 `scripts/` 下的本地门禁逐个跑一遍(`node scripts/check-*.mjs`,当前 49 个;另有 `verify-lib.mjs` 与共享 TS 加载器 `_ts-hook.mjs`)。
401
409
 
402
410
  ## 开源许可
403
411