dsh-linked-workspace 0.18.0 → 0.20.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 +16 -0
- package/README.en.md +6 -0
- package/README.md +6 -0
- package/docs/API.md +14 -6
- package/docs/VERIFY.md +16 -0
- package/lib/client.js +490 -1
- package/lib/index.js +613 -16
- package/lib/ssh.js +108 -15
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
English · [简体中文](CHANGELOG.zh.md)
|
|
4
4
|
|
|
5
|
+
## 0.20.0 — 2026-11-19
|
|
6
|
+
|
|
7
|
+
- **Host key policy**: new `hostKeyPolicy` setting — `tofu` (default: trust and remember the first key) or `strict` (refuse any key we have never seen, which also covers a man-in-the-middle on the very first connection).
|
|
8
|
+
- **Forget a host key**: `hosts.hostKeys` and `hosts.forgetHostKey` list the remembered authorities with their fingerprints and let you forget one so it is trusted again on the next connect.
|
|
9
|
+
- **Command output encoding**: new `outputEncoding` setting — `utf8` (default) or `gbk`, so `hosts.exec` on a Chinese Windows remote no longer returns mojibake (`TextDecoder`, no new dependency).
|
|
10
|
+
- `HOST_KEY_UNKNOWN` (409): a strict refusal now has its own error code and message instead of a generic `INTERNAL`.
|
|
11
|
+
- `apiRevision` 5 → 6.
|
|
12
|
+
## 0.19.0 — 2026-11-19
|
|
13
|
+
|
|
14
|
+
- **Push local edits back.** `linked.plan` compares the local directory with the remote one file by file against the hash remembered from the last push, and classifies each file as added / changed / conflict / gone-upstream; the tree toolbar gained a sync button with a diff preview, and the row menu gained "push this to the remote side".
|
|
15
|
+
- `linked.push` writes the planned files back with a temporary file + rename per file, a `dryRun` switch, and `conflict: 'skip' | 'overwrite' | 'newer'`; a file that moved on both sides is never clobbered unless you ask for it. `linked.pushCancel { jobId }` stops a running push after the current file.
|
|
16
|
+
- **Opt-in autoPush**: `autoPushEnabled` (off by default, first enable asks for confirmation in place), `autoPushDebounceMs` (default 1500, 300–60000), plus `autoPushInclude`/`autoPushExclude` globs. It always pushes with `conflict: 'skip'`, so a formatter on this side never overwrites a remote edit.
|
|
17
|
+
- `fs.transfer` accepts `paths: string[]`, so a multi-selection becomes one request instead of N.
|
|
18
|
+
- `transfer.history` returns the last 50 transfers and pushes (`transfer-history.json`).
|
|
19
|
+
- `apiRevision` 4 → 5.
|
|
20
|
+
|
|
5
21
|
## 0.18.0 — 2026-11-19
|
|
6
22
|
|
|
7
23
|
- New `fs.references` and a `references` action on `linked_workspace`: case-insensitive path completion with the **best match first** (exact name → prefix → substring) and directories flagged `dir`; it stops after 20000 entries or 3 s and reports `truncated`. The model can now resolve a remote path you mention by name.
|
package/README.en.md
CHANGED
|
@@ -148,6 +148,12 @@ Every attempt — including refused ones — appends a line to `$DSH_HOME/linked
|
|
|
148
148
|
.remote/ # optional: mirrored remote files (written on read/save, full sync on demand)
|
|
149
149
|
```
|
|
150
150
|
|
|
151
|
+
### Push local edits back (0.19.0)
|
|
152
|
+
|
|
153
|
+
The sync button in the tree toolbar compares the local directory with the remote one and lists what is added, changed, in conflict, or gone upstream. "Push (skip conflicts)" writes back only the files you changed locally while the remote side left them alone; a file that moved on both sides stays under conflict until you explicitly choose "Push and overwrite conflicts".
|
|
154
|
+
|
|
155
|
+
To let it happen on its own, enable Settings → "Linked workspaces" → "Push back automatically": the switch asks for confirmation first, and once on, saving locally writes back after about 1.5 s while always skipping conflicts.
|
|
156
|
+
|
|
151
157
|
## Screenshots
|
|
152
158
|
|
|
153
159
|
Settings → “Linked workspaces”: the upper half lists **linked workspaces** (local folder ⇄ remote folder), the lower half lists **remote workspaces** (the session runs inside the remote folder). Each card shows the connection state; linked workspaces also have the mirror switch and the sync button. The host name and the local placeholder path are blurred in this shot.
|
package/README.md
CHANGED
|
@@ -148,6 +148,12 @@
|
|
|
148
148
|
.remote/ # 可选:远端文件镜像存档(读取/保存时自动归档,可手动全量同步)
|
|
149
149
|
```
|
|
150
150
|
|
|
151
|
+
### 把本地改动推回远端(0.19.0)
|
|
152
|
+
|
|
153
|
+
目录栏的同步按钮会比较本地与远端:新增、修改、冲突、远端已删四类都会列出来。点「推送(跳过冲突)」只写回本地改过、远端没动过的文件;两边都改过的会留在「冲突」里,只有明确选「推送并覆盖冲突」才会用本地版本覆盖。
|
|
154
|
+
|
|
155
|
+
想让它自动发生,可以在设置 →「联动工作区」→「自动推回远端」里开启:开关会先弹一段说明要你确认,开启后本地保存约 1.5 秒就会写回远端,而且始终跳过冲突。
|
|
156
|
+
|
|
151
157
|
## 界面
|
|
152
158
|
|
|
153
159
|
设置 →「联动工作区」:上半部分是**联动工作区**(本地目录 ⇄ 远端目录),下半部分是**远程工作区**(会话直接运行在远端目录)。卡片里能看到连接状态,联动工作区还有镜像开关和同步按钮。图中的主机名与本地占位目录做了模糊处理。
|
package/docs/API.md
CHANGED
|
@@ -55,9 +55,11 @@ scope root, or absolute inside it.
|
|
|
55
55
|
| `hosts.credentials` | `{ hostId, password?, passphrase?, privateKey?, clear? }` | `{ hostId, authType, hasCredential, hasStoredPassword }` (stores the secret in the plugin's own `ssh-credentials.json`; `clear: true` deletes it) |
|
|
56
56
|
| `hosts.browse` | `{ hostId, path? }` | `{ path, parent, home, entries }` (dirs + files) |
|
|
57
57
|
| `hosts.df` | `{ hostId, path? }` | `{ disk: { path, size, used, avail, percent } \| null }` (free space of the volume holding `path`; defaults to the login home) |
|
|
58
|
+
| `hosts.hostKeys` | `{}` | `{ entries: [{ authority, fingerprint, firstSeen, hostId?, hostName? }] }` — the keys remembered in `known_hosts.json`; `hostId` is filled in when the authority still matches a configured host |
|
|
59
|
+
| `hosts.forgetHostKey` | `{ hostId?/authority? }` | `{ authority, removed }` — drops the stored key (and the live connection) so the next connect trusts the host again; `settings.hostKeyPolicy` decides whether an unknown key is accepted (`tofu`, default) or refused (`strict`) |
|
|
58
60
|
| `hosts.status` | `{ hostIds? }` | `{ statuses: { [hostId]: { state, reason?, message?, latencyMs?, checkedAt? } } }` (in-memory snapshot of the pool, never dials; an `error` older than 60 s is reported as `idle`; defaults to every known host of the host list plus every workspace's host id) |
|
|
59
61
|
| `hosts.mkdir` | `{ hostId, path?, name }` | `{ path }` (creates `name` inside `path`; defaults to the login home; `409`/`FS_EXISTS` when it already exists) |
|
|
60
|
-
| `hosts.exec` | `{ hostId?/linkedId?/remoteId?, command, cwd?, timeoutMs? }` | `{ hostId, hostName, workspaceId, kind, command, cwd, exitCode, stdout, stderr, stdoutBytes, stderrBytes, truncated, durationMs, startedAt, auditId }` — runs **one** non-interactive command on the remote host. Three gates: `settings.execEnabled` must be `true`, the host must be in `settings.execHostIds`, and — when `settings.execWorkspaceIds` is non-empty — the workspace must be in it. Refusals are audited too and answer `403` (`EXEC_DISABLED` / `EXEC_HOST_NOT_ALLOWED` / `EXEC_WORKSPACE_NOT_ALLOWED`); a timeout answers `504` `EXEC_TIMEOUT`, other failures `502` `EXEC_FAILED`. Output is clipped to `settings.execMaxOutputChars` per stream (default 200000, head+tail). `cwd` is resolved inside the workspace root and may not escape it. |
|
|
62
|
+
| `hosts.exec` | `{ hostId?/linkedId?/remoteId?, command, cwd?, timeoutMs? }` | `{ hostId, hostName, workspaceId, kind, command, cwd, exitCode, stdout, stderr, stdoutBytes, stderrBytes, truncated, durationMs, startedAt, auditId }` — runs **one** non-interactive command on the remote host. Three gates: `settings.execEnabled` must be `true`, the host must be in `settings.execHostIds`, and — when `settings.execWorkspaceIds` is non-empty — the workspace must be in it. Refusals are audited too and answer `403` (`EXEC_DISABLED` / `EXEC_HOST_NOT_ALLOWED` / `EXEC_WORKSPACE_NOT_ALLOWED`); a timeout answers `504` `EXEC_TIMEOUT`, other failures `502` `EXEC_FAILED`. Output is clipped to `settings.execMaxOutputChars` per stream (default 200000, head+tail). `cwd` is resolved inside the workspace root and may not escape it. Output is decoded with `settings.outputEncoding` (`utf8` by default, `gbk` for Chinese Windows remotes). |
|
|
61
63
|
| `remote_workspaces.list` | `{}` | `{ workspaces: RemoteWorkspaceInfo[] }` |
|
|
62
64
|
| `remote_workspaces.create` | `{ hostId, remotePath, name? }` | `{ workspace }` |
|
|
63
65
|
| `remote_workspaces.get` | `{ id }` | `{ workspace }` |
|
|
@@ -98,11 +100,15 @@ scope root, or absolute inside it.
|
|
|
98
100
|
| `fs.search` | `{ linkedId?/remoteId?, side, query, maxResults? }` | `{ ok, query, entries, truncated }` (matches **file names**, not contents; use `fs.grep` for contents) |
|
|
99
101
|
| `fs.grep` | `{ linkedId?/remoteId?, side, query, maxResults?, path?, ignoreCase?, regex?, includeIgnored?, resultMode?, maxFiles?, maxFileBytes?, timeoutMs?, jobId? }` | `{ ok, query, entries: [{ path, relative, size, line, preview, matches }], truncated, truncatedReason, scannedFiles, scannedBytes, skippedFiles }` (searches file **contents**; `path` narrows the scan to a sub-folder; `ignoreCase` defaults to `true`; `regex` treats `query` as a regular expression; `includeIgnored: true` also walks usually ignored folders such as `node_modules`/`.venv`/`dist` (`.git`/`.hg`/`.svn` always stay out); `resultMode: 'files'` lists file names only (`line: 0`, empty `preview`, `matches` = hit count); `maxFiles` (default 2000), `maxFileBytes` (default 1 MB) and `timeoutMs` (default 5 s, max 10 s) raise or lower the sweep; limits are 1 MB per file, 2000 files, 8 MB and 5 s for both sides, and `truncatedReason` is one of `files`, `bytes`, `deadline`, `results`, `cancelled`; max 1000 rows) |
|
|
100
102
|
| `fs.grepCancel` | `{ jobId }` | `{ cancelled }` (marks the job started by `fs.grep`'s `jobId`; the Host checks it between files and answers `truncatedReason: 'cancelled'`) |
|
|
103
|
+
| `linked.plan` | `{ id, maxFiles? }` | `{ linkedId, localPath, remotePath, added, changed, conflict, removed, unchanged, pending, truncated, skipped, maxFiles }` (each entry carries `relative`, `size`, `localHash`, `remoteHash`; a file that moved on both sides since the last push lands in `conflict`) |
|
|
104
|
+
| `linked.push` | `{ id, paths?, dryRun?, conflict?, jobId? }` | `{ linkedId, dryRun, conflict, files, pushed, skipped, conflictsLeft, bytes, cancelled }` (`conflict` is `skip` by default; every file is written as a temporary file and renamed into place) |
|
|
105
|
+
| `linked.pushCancel` | `{ jobId }` | `{ cancelled }` (stops after the file being written) |
|
|
106
|
+
| `transfer.history` | `{}` | `{ entries: [{ kind: "transfer" \| "push", direction?, linkedId?, files, bytes, skipped, truncated?, at }] }` (newest first, at most 50) |
|
|
101
107
|
| `fs.references` | `{ linkedId?/remoteId?, query, limit?, includeIgnored?, side? }` | `{ ok, query, candidates: [{ path, relative, name, kind }], total, truncated, scannedEntries }` (path completion for `@`-style references: matches the **path**, case-insensitive, best match first — exact name, then prefix, then substring; `limit` defaults to 50 and caps at 200; walking stops after 20000 entries or 3 s; `side: 'local'` searches the local tree of a linked workspace) |
|
|
102
108
|
| `fs.compare` | `{ linkedId?, path? }` | `{ path, relative, localPath, localMissing, counts: { onlyLocal, onlyRemote, changed, same }, onlyLocal, onlyRemote, changed, truncated, remoteTruncated, localTruncated, skippedLinks }` (linked workspaces only; excludes `.git`, `node_modules`, `.local`, `.remote`; 4000 files and depth 12 **per side**, 200 rows per group; `skippedLinks` counts symlinks and non-regular files) |
|
|
103
109
|
| `fs.pullToLocal` | `{ linkedId?, path, targetDir?, conflict? }` | `{ path, relative, size, mtime }` (linked workspaces only; single file, ≤64 MB; `targetDir` must stay inside the local root; `conflict` is `error` (default), `overwrite` or `unique`) |
|
|
104
110
|
| `fs.upload` | `{ linkedId?/remoteId?, path, paths, conflict? }` | `{ side: 'remote', target, files, bytes, skipped }` (≤50 local files, 64 MB each; `conflict` is `error` (default), `overwrite` or `unique`; a missing target directory is created) |
|
|
105
|
-
| `fs.transfer` | `{ linkedId?/remoteId?, path, jobId? }` | `{ files, bytes, skipped, truncated, dest }` (with `jobId` the run is tracked and can be polled/cancelled) |
|
|
111
|
+
| `fs.transfer` | `{ linkedId?/remoteId?, path, paths?, jobId? }` | `{ files, bytes, skipped, truncated, dest }` (with `jobId` the run is tracked and can be polled/cancelled) |
|
|
106
112
|
| `fs.transferProgress` | `{ jobId }` | `{ job: { id, files, bytes, skipped, state, cancelled, reason } \| null }` (`state` is `running`, `done`, `cancelled` or `failed`; jobs are dropped after 5 minutes) |
|
|
107
113
|
| `fs.transferCancel` | `{ jobId }` | `{ cancelled }` (asks the running transfer to stop; it finishes the file in flight, then reports `CANCELLED`) |
|
|
108
114
|
| `fs.download` | `{ linkedId?/remoteId?, path }` | `{ path, files, bytes, skipped, truncated }` |
|
|
@@ -133,18 +139,20 @@ Under `$DSH_HOME/linked-workspace/`:
|
|
|
133
139
|
|
|
134
140
|
- `linked.json` — linked workspaces (no credentials).
|
|
135
141
|
- `remote-workspaces.json` — remote workspaces (no credentials).
|
|
136
|
-
- `settings.json` — `{ editorTheme, editorThemeFamily, editorThemeMode, fileOpenMode, autoSave, execEnabled, execHostIds, execWorkspaceIds, execTimeoutMs, execMaxOutputChars, execShell }`.
|
|
142
|
+
- `settings.json` — `{ editorTheme, editorThemeFamily, editorThemeMode, fileOpenMode, autoSave, execEnabled, execHostIds, execWorkspaceIds, execTimeoutMs, execMaxOutputChars, execShell, autoPushEnabled, autoPushDebounceMs, autoPushInclude, autoPushExclude, hostKeyPolicy, outputEncoding }`.
|
|
137
143
|
The exec keys are off unless you turn them on: `execEnabled` defaults to
|
|
138
144
|
`false`, `execHostIds` (host allow-list) starts empty, and
|
|
139
145
|
`execWorkspaceIds` is an optional second layer where an empty list means
|
|
140
146
|
"every workspace on an allowed host".
|
|
141
|
-
- `exec-audit.jsonl` — one JSON line per `hosts.exec` attempt (accepted or
|
|
142
|
-
refused): `{ ts, auditId, hostId, hostName, workspaceId, kind, command, cwd?,
|
|
147
|
+
- `exec-audit.jsonl` — one JSON line per `hosts.exec` attempt (accepted or refused): `{ ts, auditId, hostId, hostName, workspaceId, kind, command, cwd?,
|
|
143
148
|
exitCode?, durationMs?, stdoutBytes?, stderrBytes?, truncated?, stdoutHead?,
|
|
144
149
|
stderrHead?, refusal?, message? }`. Rotated to `exec-audit.jsonl.1` past 5 MB.
|
|
145
150
|
`meta.info` returns its absolute path as `execAuditFile` so the settings page
|
|
146
151
|
can open it.
|
|
147
|
-
- `known_hosts.json` — trust-on-first-use host key fingerprints
|
|
152
|
+
- `known_hosts.json` — trust-on-first-use host key fingerprints, readable through
|
|
153
|
+
`hosts.hostKeys` and prunable one authority at a time with `hosts.forgetHostKey`.
|
|
154
|
+
With `settings.hostKeyPolicy: "strict"` an unknown key is refused instead of
|
|
155
|
+
trusted (`409` `HOST_KEY_UNKNOWN`) — see the SSH trust section in the settings page.
|
|
148
156
|
- `ssh-credentials.json` — `{ version, byHostId: { <hostId>: { password?, privateKey?, passphrase? } } }`,
|
|
149
157
|
written by `hosts.credentials` with mode `0600`. Hosts listed in `~/.ssh/config`
|
|
150
158
|
without an `IdentityFile` can be paired with a password here, so the plugin does
|
package/docs/VERIFY.md
CHANGED
|
@@ -2,6 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
Host code (lib/) reloads live with `plugin_manager set_plugin include:linked-workspace-ui`; client changes load with **应用 → 重新加载界面** (a full restart is only needed after re-installing the package). Then verify:
|
|
4
4
|
|
|
5
|
+
## 主机密钥与输出编码(0.20.0)
|
|
6
|
+
|
|
7
|
+
1. 设置 → 联动工作区 → 「SSH 主机密钥与输出编码」应能看到「主机密钥策略」(tofu / strict)、「远端命令输出编码」(utf8 / gbk),以及已记住的主机列表(每行显示 `host:port` 与 `SHA256:…` 指纹)。
|
|
8
|
+
2. 把策略切到 strict,在「忘记」某个主机的密钥后再点该主机的工作区:目录树应报「Host key … is not known yet」,HTTP 409,且不会悄悄重新记住。
|
|
9
|
+
3. 切回 tofu 再刷新:连接恢复,密钥重新出现在列表里。
|
|
10
|
+
4. 把输出编码切到 gbk,用 `hosts.exec` 让中文 Windows 远端输出中文,应正常显示;切回 utf8 应变成乱码(说明不是被强行转码)。
|
|
11
|
+
|
|
12
|
+
## 本地改动推回远端(0.19.0)
|
|
13
|
+
|
|
14
|
+
1. 在联动工作区的**本地**目录里改一个文件、新建一个文件,然后点目录栏的同步按钮:差异预览里能看到「新增 1 · 修改 1」,并列出这两个文件。
|
|
15
|
+
2. 点「推送(跳过冲突)」后提示「已推送 N 个文件」,远端目录刷新后能看到新内容(`ssh … cat` 核对)。
|
|
16
|
+
3. 在**远端**改同一个文件、本地再改一次,重新打开差异预览:该文件出现在「冲突」里;点「推送(跳过冲突)」后远端内容保持不变,提示里带「1 个冲突未处理」;点「推送并覆盖冲突」才会用本地版本覆盖。
|
|
17
|
+
4. 在行菜单上对某个远端文件点「把这个推送到远端」:差异预览只包含该文件。
|
|
18
|
+
5. 设置 → 联动工作区 → 「自动推回远端」:打开开关会先出现黄色说明与「我明白,开启自动推送」,未确认前不会开启;确认后本地保存文件约 1.5 秒后自动出现在远端,同一文件远端也改过时保留远端版本。
|
|
19
|
+
6. 断网或 SSH 断开时推送会失败并显示原因,本地文件不受影响。
|
|
20
|
+
|
|
5
21
|
## @ 引用与搜索增强(0.18.0)
|
|
6
22
|
|
|
7
23
|
1. 内容搜索栏在「内容」模式下有五枚 chip(`Aa`、`.*`、目录范围、`.*/`、文件图标)与一个「停止」按钮(仅在搜索中、且有 jobId 时出现)。
|