dsh-code-server-app 0.1.19 → 0.1.22

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 jinsiyu
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.en.md ADDED
@@ -0,0 +1,202 @@
1
+ # dsh-code-server-app — Integrate code-server (VS Code in the browser) into DSH
2
+
3
+ > Source repository: see `repository` / `homepage` in `package.json`.
4
+
5
+ > ## ⚠️ Extension Marketplace Note (important)
6
+ >
7
+ > - **code-server's extension store is [Open VSX](https://open-vsx.org/), not the Microsoft Visual Studio Marketplace**;
8
+ > - Microsoft's Marketplace terms **prohibit third-party products (including code-server) from using its API**, so code-server cannot query Microsoft's extension list;
9
+ > - As a result, Microsoft **commercial/proprietary** extensions (e.g. **GitHub Copilot, the Remote series like Remote-SSH, Azure tools, IntelliCode**) are **not available** in the store — this is Microsoft's distribution policy, not a defect;
10
+ > - Microsoft **open-source** extensions (Python, TypeScript debugger, ESLint, …) are mirrored on Open VSX and install normally by search;
11
+ > - **If you need a proprietary Microsoft extension**: download the `.vsix` from the Marketplace page and install it manually with `code-server --install-extension <file>` (or drop it into `--extensions-dir`).
12
+
13
+ A static profile plugin (npm package with host + client bundle) that ships the latest [code-server](https://github.com/coder/code-server) **as a plugin dependency** (installed by the plugin's postinstall), auto-discovered and used on startup — no global npm install, no `bin` configuration.
14
+
15
+ - **Floating ball** (bottom-right, official code-server icon, above the composer): click to **expand the floating window and light it up** (blue glow), click again to **collapse**; **drag to any position** (remembered across refreshes; no accidental click after drag);
16
+ no sidebar button, no window control button group (the ball is the only entry/toggle); the ball carries a status dot (green = running / amber = starting / red = error);
17
+ - Window is an **internal floating window** (modeled on dsh-univer-office's WorktreeWindow): fixed-position overlay + an inert root container, the window takes over pointer events,
18
+ **no title bar / buttons** — drag the top strip to move (hover shows a faint hint; **drag to the top of the screen and release = maximize**,
19
+ **grab the top strip downward while maximized = restore** and keep dragging), double-click to maximize, 8-direction resize, Esc to close (same as collapsing the ball),
20
+ initial position above the composer, maximized/resized dimensions stop above the input bar (never cover the composer);
21
+ - The window hosts the code-server page directly (iframe); shows status/error info when not running or failed to start;
22
+ - code-server's workspace **follows the active DSH session/workspace**: switching sessions/workspaces while the overlay is open restarts code-server to the new directory
23
+ (resolution order: current session cwd → session's workspace.path → recentWorkspace.path → first workspace.path);
24
+ the opened directory is shown inside code-server (`?folder=<cwd>`, the page reloads when following a switch);
25
+ implementation note: the iframe `src` must carry `?folder=<cwd>` — code-server's front-end remembers the "last workspace" and restores it by itself;
26
+ a bare root URL only shows the previously opened directory and does not follow switches (verified locally).
27
+ **Windows path format (verified)**: the `folder` parameter must start with `/` and use forward slashes only, e.g. `/C:/Users/User/Desktop/biss`;
28
+ a bare Windows path (`C:\...`) is parsed as a URI scheme and the drive letter is stripped (page shows `\Users\User\...` with an empty file tree),
29
+ while `file:///C:/...` reports "Workspace does not exist".
30
+ - Process lifecycle is managed by the host plugin: startup writes `$DSH_HOME/code-server/pid.json`, stop kills the tree (`taskkill /T` or process-group SIGKILL),
31
+ crash/exit updates status live; after a DSH host restart the plugin **adopts** a still-running instance (verifies pid + `/healthz`), without duplicate start or killing unrelated processes;
32
+ - `node_modules` (dependencies, including code-server) is git-ignored; after cloning, follow "Install plugin (code-server self-installed in profile)" below — `pnpm pack` + `dsh plugin --profile web add`.
33
+
34
+ > Verified locally (BM: Windows 11 ARM64): `code-server@4.134.0` (with Code 1.135.0)
35
+ > shipped with the plugin, auto-discovered → started → healthz 200 → cwd switch restart while running → stopped → fully recycled.
36
+
37
+ ## Install the plugin (code-server self-installed in profile; zero flags, zero errors)
38
+
39
+ ```powershell
40
+ # 1) Pack (in the plugin workspace)
41
+ cd C:\Users\User\Desktop\dsh-code-server-app
42
+ # Fresh clone: install dev deps and generate the client bundle first (lib/client.js is not committed; built from src/factory.js)
43
+ pnpm install # esbuild + motion (pack only)
44
+ pnpm run build:client # src/factory.js → lib/client.js
45
+ pnpm pack
46
+
47
+ # 2) One-time: approve the plugin postinstall (pnpm only honors the host root config)
48
+ cd C:\Users\User\.dsh\profiles\web
49
+ pnpm approve-builds dsh-code-server-app # interactive 'yes'; if it fails, edit pnpm-workspace.yaml manually
50
+ ```
51
+
52
+ > If `approve-builds` rejects the `file:` spec (unknown), set the `dsh-code-server-app@file:...tgz` entry
53
+ > in `pnpm-workspace.yaml`'s `allowBuilds` to `true` (equivalent to interactive approval, once only).
54
+
55
+ ```powershell
56
+ # 3) Install (published tarball; no --ignore-scripts / --allow-build needed)
57
+ dsh plugin --profile web add C:\Users\User\Desktop\dsh-code-server-app\dsh-code-server-app-0.1.20.tgz
58
+ ```
59
+
60
+ ### Install mechanism
61
+
62
+ - **code-server is not in `dependencies`** (pnpm never touches it; no script-approval issues);
63
+ - The plugin's `postinstall` (`scripts/setup-code-server.mjs`) installs **the latest** `code-server` **with npm into a dedicated profile directory**
64
+ (version not pinned; npm `latest` is used at install time):
65
+ - Install root: `<profile>\.code-server-app` (e.g. `C:\Users\User\.dsh\profiles\web\.code-server-app`),
66
+ a standalone project isolated from the profile dependency tree (avoids ERESOLVE);
67
+ - The install root carries its own `package.json` with `allowScripts`: `code-server: false` (skips the official `sh ./postinstall.sh`
68
+ — Windows has no `sh`, it would fail; `argon2/unrs-resolver: true` builds native modules; both without version pins);
69
+ - Afterwards it installs VS Code internal dependencies (144 packages) + `bin\code-server.cmd`;
70
+ - **code-server lands at** `<profile>\.code-server-app\node_modules\code-server\`;
71
+ idempotent and self-healing (reinstalling the plugin → postinstall reruns → skips if already instantiated;
72
+ **if the installed version differs from the latest, it auto-upgrades**).
73
+ - **Pin a version**: set the env var `DSHCS_CODE_SERVER_VERSION` (e.g. `4.134.0`) to freeze a specific release; unset it to follow latest.
74
+
75
+ > **Uninstall**: the code-server directory is independent of the plugin package — first
76
+ > `Remove-Item -Recurse -Force <profile>\.code-server-app`, then `dsh plugin --profile web remove dsh-code-server-app`.
77
+ > The settings card's "Environment check" section also shows this hint.
78
+
79
+ > After install/dependency changes, **restart `dsh web`** (the static plugin row and host probe paths load at startup).
80
+
81
+ ### Development: install from source (changes take effect immediately)
82
+
83
+ ```powershell
84
+ dsh plugin --profile web add C:\Users\User\Desktop\dsh-code-server-app
85
+ ```
86
+
87
+ > A source path installs via `link:`; pnpm installs code-server into the **plugin workspace node_modules**;
88
+ > the layout differs from the profile-dir approach (the host supports both). First time also needs step 2 above.
89
+ >
90
+ > **Changing the client bundle**: edit `src/factory.js` then run `pnpm run build:client`
91
+ > to regenerate `lib/client.js` (that artifact is not tracked; a browser refresh picks it up — no host restart needed).
92
+ > Window animations are driven by the embedded `motion`; feel parameters live in `winPhysics` (one spot) in `src/factory.js`.
93
+
94
+ ### Environment requirements (packages that need building + toolchain)
95
+
96
+ During installation (`postinstall` → `scripts/setup-code-server.mjs` → npm self-installs code-server + VS Code internal deps), **only one package really needs local compilation**:
97
+
98
+ | Package | Build method | ARM64 local compile | x64 local compile |
99
+ |---|---|---|---|
100
+ | **code-server** (main) | official `sh ./postinstall.sh` is skipped via `allowScripts: code-server: false` (no `sh` on Windows) | ❌ | ❌ |
101
+ | **argon2** | `node-gyp-build` (binding.gyp + node-addon-api) | ✅ **mandatory** | ✅ **mandatory too** — prebuilds only contain Linux `*.glibc.node`; **no Windows prebuilds at all** |
102
+ | **unrs-resolver** | `napi-postinstall check`; loads the prebuilt `@unrs/resolver-binding-win32-{x64,arm64}-msvc` | ❌ pure prebuilt | ❌ pure prebuilt |
103
+ | **VS Code internal deps** (`lib/vscode/node_modules`, 144 pkgs) | `ensureNpmDeps` runs `npm install` per dir; own postinstalls (node-pty/koffi/kerberos…) | ⚠️ mostly prebuilt | ⚠️ mostly prebuilt |
104
+
105
+ **Base environment checklist (verified locally, Windows)**:
106
+
107
+ | Env | Version / requirement | ARM64 | x64 |
108
+ |---|---|---|---|
109
+ | Node.js | **v24.x** (latest code-server requirement; v24.13.1 here) | required | required |
110
+ | npm | ships with Node | required | required |
111
+ | **MSVC build tools** | **VS Community 2026 (18.9) + C++ desktop workload** | ✅ **required** (argon2 compile) | ✅ **required** (argon2 compile) |
112
+ | **VS Spectre-mitigated libs** | "MSVC v18x Spectre-mitigated libraries for ARM64" (use the matching-arch libs on x64) | ✅ required (otherwise MSB8040) | ✅ required (otherwise MSB8040) |
113
+ | Python | **3.13.x** (e.g. `Python313-arm64\python.exe`; x64 version on x64) | ✅ required (node-gyp scripts) | ✅ required |
114
+ | node-gyp | **13.x** (9.x doesn't recognize VS 2026) | ✅ required | ✅ required |
115
+
116
+ > **Bottom line (corrected from measurements)**:
117
+ > - **Windows (x64 and ARM64 are the same)**: argon2's prebuilds contain **only Linux `*.glibc.node` — no Windows prebuilds at all**; `node-gyp-build` can't find one → **always falls back to a local node-gyp compile**. So **x64 also needs the full C++ toolchain** (MSVC + Spectre + Python + node-gyp 13); there is no "zero-compile on x64";
118
+ > - unrs-resolver and VS Code internal deps use prebuilds — no extra tools;
119
+ > - On a machine without a toolchain you may set `allowScripts.argon2: false` in the install root `package.json`, but argon2 missing makes code-server fail at startup with a `node-gyp-build` error — only suitable if you don't depend on argon2 (not recommended).
120
+
121
+ ### Windows native build notes (verified locally, ARM64)
122
+
123
+ - **VS needs the Spectre-mitigated libraries** (MSB8040): Visual Studio Installer → Individual components →
124
+ "MSVC v18x Spectre-mitigated libraries for ARM64" (same for x86/x64).
125
+ - **node-gyp 13.x** (9.x does not recognize VS 2026): `npm install -g node-gyp@latest`.
126
+ - Latest code-server requires **Node v24** (checked by postinstall; v24.13.1 verified here).
127
+ - If you don't need the self-contained install (e.g. a global code-server already exists), skip it:
128
+ the plugin falls back to a configured/PATH `bin` (see the "Config" table).
129
+
130
+ ### Upgrading the code-server version
131
+
132
+ - **Automatic by default**: postinstall does not pin the version — if the installed version differs from npm latest it reinstalls to latest (no manual edits).
133
+ - **To pin**: set the env var `DSHCS_CODE_SERVER_VERSION` (e.g. `4.134.0`); unset it to follow latest again.
134
+ - Re-run `pnpm pack` + `dsh plugin --profile web add <tgz>` to trigger the postinstall check (or delete `.code-server-app` and reinstall).
135
+
136
+ ### Compatibility with the old runtime-directory install
137
+
138
+ `runtime/node_modules/code-server` (the earlier manual approach) is no longer supported —
139
+ host probe order: `<profile>\.code-server-app` (dedicated dir) > plugin-internal `node_modules` > PATH/config `bin`
140
+ (top-level hoisted is a historical layout and is no longer probed).
141
+
142
+ ## Settings card (Settings → Plugins → Code Server)
143
+
144
+ Modeled after dsh-auto-open-web's custom card, registered on the `settings.plugin.item` slot,
145
+ persisted via the official settings domain (`settingsScope`, namespace `code-server`) into the official settings document:
146
+
147
+ | Key | Default | Description |
148
+ |---|---|---|
149
+ | `reserveComposer` | `true` | Whether the window **reserves space above the composer**: on, the window's initial/drag/resize/maximize stop above the composer (never covers it); off, it may cover the composer (maximize to viewport bottom) |
150
+ | `windowedOpen` | `false` | **Open in a window**: on, clicking the floating ball opens code-server in a browser **new tab** (auto-starts and follows the active workspace); off (default) uses the internal floating window |
151
+
152
+ > Card changes take effect immediately via `scope.watch` (the host status API returns `reserveComposer` and
153
+ > `windowedOpen`; the client applies them at once); no dsh restart needed. **After adding new setting keys, restart dsh web before first use**,
154
+ > so the host re-registers the settings namespace (schema includes the new key); otherwise save/validation of the new key won't work.
155
+
156
+ ## Config (`config` in cordis.patch.yml; all have defaults)
157
+
158
+ | Key | Default | Description |
159
+ |---|---|---|
160
+ | `bin` | `code-server` (placeholder) | Launch priority: explicit `bin` in config > `<profile>\.code-server-app` (dedicated dir, auto-run with node) > plugin-internal `node_modules` > `code-server` on PATH. None present → startup error with install guidance |
161
+ | `host` | `127.0.0.1` | Bind address; `auth: none` only allows loopback (localhost/127.0.0.1/::1) |
162
+ | `port` | `8090` | Port; on conflict startup fails with diagnostics (no automatic port change) |
163
+ | `auth` | `none` | `none` \| `password`; non-loopback host automatically requires password |
164
+ | `passwordToken` | `''` | Token for password mode (passed to code-server via the `PASSWORD` env var) |
165
+ | `userDataDir` | `$DSH_HOME/code-server/user-data` | User-data isolation directory |
166
+ | `extensionsDir` | `$DSH_HOME/code-server/extensions` | Extensions directory |
167
+ | `readyTimeoutMs` | `60000` | `/healthz` readiness probe timeout |
168
+
169
+ User-level override example (write in `$DSH_HOME/profiles/web/cordis.patch.yml`, using the `- id: code-server` row):
170
+
171
+ ```yaml
172
+ - id: code-server
173
+ config:
174
+ port: 8091
175
+ # Explicit (overrides dependency-install probing): a globally installed shim, or any entry.js
176
+ bin: C:\Users\User\AppData\Roaming\npm\code-server.cmd
177
+ ```
178
+
179
+ ## JSON API (same-origin fetch; shared by the overlay and the web page)
180
+
181
+ | Method | Path | Description |
182
+ |---|---|---|
183
+ | GET | `/code-server/status` | `{ ok, running, status, host, port, pid, cwd, url, version, error, logTail, adopted }` (also `env` environment check and `setup` install-task progress) |
184
+ | POST | `/code-server/start` | body `{ cwd? }` (omit cwd to keep the current workspace); idempotent |
185
+ | POST | `/code-server/stop` | Stop and recycle the process tree |
186
+ | POST | `/code-server/setup` | Run the environment install in the background (npm install code-server + native + VS Code internal deps); progress via `status.setup` polling |
187
+ | POST | `/code-server/open-file` | body `{ file }` — writes the signal consumed by the built-in `dshcs-open-file` extension to open the file in code-server (also auto-expands the window from the client side) |
188
+
189
+ ## Artifact open buttons
190
+
191
+ Each produced file (written/edited) in a turn is shown as a chip with a **code-server icon button** next to it
192
+ in the conversation's turn tail; clicking either opens the file in code-server (and expands the floating window if collapsed).
193
+ The `dshcs-open-file` extension is installed as a **built-in** extension of code-server (in `lib/vscode/extensions`),
194
+ so users cannot remove it from the extensions panel.
195
+
196
+ ## Known limitations
197
+
198
+ - **No sub-path**: the code-server front-end uses root paths/WebSocket/Service Worker, so it must be a direct iframe on its own port;
199
+ no DSH webServer reverse proxy; `--base-path` is not officially supported.
200
+ - **Single instance across sessions**: one shared code-server per host; switching cwd requires a restart (the overlay handles it and hints).
201
+ - **Remote access**: default is loopback + no auth. Cross-machine access requires `host` + `auth: password` + `passwordToken`,
202
+ and the browser must be able to reach that host directly (the plugin's "open in new tab" builds the URL from `host:port`).
package/README.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  > 源码仓库地址见 `package.json` 的 `repository` / `homepage` 字段。
4
4
 
5
+ > ## ⚠️ 扩展市场说明(重要)
6
+ >
7
+ > - **code-server 的扩展商店是 [Open VSX](https://open-vsx.org/),不是微软 Visual Studio Marketplace**;
8
+ > - 微软 Marketplace 的条款**禁止第三方产品(含 code-server)使用其 API**,所以 code-server 无法查询微软市场的扩展列表;
9
+ > - 因此微软**商业/专有**扩展(如 **GitHub Copilot、Remote-SSH 等 Remote 系列、Azure 系列、IntelliCode**)在商店里**找不到**——这是微软发行策略,不是缺失;
10
+ > - 微软**开源系**扩展(Python、TypeScript 调试、ESLint 等)在 Open VSX 有镜像,搜索正常可装;
11
+ > - **需要微软专有扩展时**:从 Marketplace 网页下载 `.vsix`,用 `code-server --install-extension <文件>`(或放入 `--extensions-dir`)手动安装,即可在插件列表使用。
12
+
5
13
  静态 profile 插件(npm 包形态,host + client bundle),把最新版 [code-server](https://github.com/coder/code-server)
6
14
  **作为插件依赖随装**(package.json dependencies),插件启动时自动发现并使用它,
7
15
  无需全局 npm 安装、无需配置 `bin`。
@@ -58,14 +66,15 @@ dsh plugin --profile web add C:\Users\User\Desktop\dsh-code-server-app\dsh-code-
58
66
 
59
67
  - **code-server 不在 `dependencies`**(pnpm 不触碰它、无脚本许可问题);
60
68
  - 插件的 `postinstall`(`scripts/setup-code-server.mjs`)在 **profile 专用目录**用 **npm** 自装
61
- `code-server@4.134.0`:
69
+ **最新版** `code-server`(不锁版本,安装时取 npm latest):
62
70
  - 安装根:`<profile>\.code-server-app`(如 `C:\Users\User\.dsh\profiles\web\.code-server-app`),
63
71
  独立项目,与 profile 依赖树隔离(避开 ERESOLVE);
64
72
  - 安装根自带 `package.json`(allowScripts:`code-server: false` 跳过官方 `sh ./postinstall.sh`
65
- ——Windows 无 sh 会失败、`argon2/unrs-resolver: true` native 构建);
73
+ ——Windows 无 sh 会失败、`argon2/unrs-resolver: true` native 构建,均不带版本号);
66
74
  - 装完补装 VS Code 内部依赖(144 包)+ `bin\code-server.cmd`;
67
75
  - **code-server 落在** `<profile>\.code-server-app\node_modules\code-server\`;
68
- 幂等自愈(pnpm 重装插件 → postinstall 重跑 → 检测已实例化则跳过)。
76
+ 幂等自愈(pnpm 重装插件 → postinstall 重跑 → 检测已实例化则跳过;**若已装版本与最新不一致则自动升级到最新**)。
77
+ - **锁版本**:设置环境变量 `DSHCS_CODE_SERVER_VERSION`(如在 dsh web 环境)可钉住某个版本(如 `4.134.0`);缺省跟随 npm latest。
69
78
 
70
79
  > **卸载**:code-server 目录独立于插件包——先手动删除
71
80
  > `Remove-Item -Recurse -Force <profile>\.code-server-app`,再 `dsh plugin --profile web remove dsh-code-server-app`。
@@ -86,6 +95,33 @@ dsh plugin --profile web add C:\Users\User\Desktop\dsh-code-server-app
86
95
  > 重新生成 `lib/client.js`(仓库不跟踪该产物;浏览器刷新即生效,host 无需重启)。
87
96
  > 窗口动画由内嵌 `motion` 驱动,手感参数在 `src/factory.js` 的 `winPhysics`(一处)。
88
97
 
98
+ ### 安装环境要求(需要编译的包与工具链)
99
+
100
+ 安装过程(`postinstall` → `scripts/setup-code-server.mjs` → npm 自装 code-server + VS Code 内部依赖)中,**真正需要本地编译的只有一个包**:
101
+
102
+ | 包 | 构建方式 | ARM64 本地编译 | x64 本地编译 |
103
+ |---|---|---|---|
104
+ | **code-server**(主包) | 官方 `sh ./postinstall.sh` 已被 `allowScripts: code-server: false` 跳过(Windows 无 sh) | ❌ | ❌ |
105
+ | **argon2** | `node-gyp-build`(binding.gyp + node-addon-api) | ✅ **必须** | ✅ **也必须**——prebuilds 目录里只有 Linux 的 `*.glibc.node`,**Windows 无任何预编译** |
106
+ | **unrs-resolver** | `napi-postinstall check`,加载 `@unrs/resolver-binding-win32-{x64,arm64}-msvc` 预编译绑定 | ❌ 纯预编译 | ❌ 纯预编译 |
107
+ | **VS Code 内部依赖**(`lib/vscode/node_modules`,144 包) | `ensureNpmDeps` 逐一 `npm install`,自带 postinstall(node-pty/koffi/kerberos 等) | ⚠️ 多数预编译 | ⚠️ 多数预编译 |
108
+
109
+ **基础环境清单(Windows 实测)**:
110
+
111
+ | 环境 | 版本/要求 | ARM64 | x64 |
112
+ |---|---|---|---|
113
+ | Node.js | **v24.x**(code-server 最新要求;本机 v24.13.1) | 必需 | 必需 |
114
+ | npm | 跟随 Node | 必需 | 必需 |
115
+ | **MSVC 构建工具** | **VS Community 2026(18.9)+ C++ 桌面负载** | ✅ **必需**(argon2 编译) | ✅ **必需**(argon2 编译) |
116
+ | **VS Spectre 缓解库** | "适用于 ARM64 的 MSVC v18x Spectre-mitigated 库"(x64 用对应位数库) | ✅ 必需(否则 MSB8040) | ✅ 必需(否则 MSB8040) |
117
+ | Python | **3.13.x**(如 `Python313-arm64\python.exe`;x64 用 x64 版) | ✅ 必需(node-gyp 脚本) | ✅ 必需 |
118
+ | node-gyp | **13.x**(9.x 不识别 VS 2026) | ✅ 必需 | ✅ 必需 |
119
+
120
+ > **结论(实测更正)**:
121
+ > - **Windows(x64 与 ARM64 相同)**:argon2 的 prebuilds 目录里**只有 Linux 的 `*.glibc.node`,没有 Windows 预编译**——`node-gyp-build` 找不到 → **一律回退本地 node-gyp 编译**。因此 **x64 同样必须配齐 C++ 工具链**(MSVC + Spectre + Python + node-gyp 13),不存在"x64 零编译";
122
+ > - 其余(unrs-resolver、VS Code 内部依赖)走预编译,无需额外工具;
123
+ > - 若开发机没有工具链,可将安装根 `package.json` 的 `allowScripts.argon2` 设为 `false` 跳过(但 argon2 缺失会导致 code-server 启动报 `node-gyp-build` 错误——仅适合不依赖 argon2 的场景,通常不建议)。
124
+
89
125
  ### Windows 原生构建要点(本机实测,ARM64)
90
126
 
91
127
  - **VS 需 Spectre 缓解库组件**(MSB8040):Visual Studio Installer → 单个组件 →
@@ -97,10 +133,9 @@ dsh plugin --profile web add C:\Users\User\Desktop\dsh-code-server-app
97
133
 
98
134
  ### 升级 code-server 版本
99
135
 
100
- 1. `scripts/setup-code-server.mjs` `CODE_SERVER_VERSION`;
101
- 2. 同步 `package.json` `allowScripts` 表(若 native 依赖版本变更导致条目失配,
102
- `npm install-scripts ls` 的结果更新;code-server 保持 `false`);
103
- 3. 重新 `pnpm pack` + `dsh plugin --profile web add <tgz>`(包内旧版本由 postinstall 覆盖)。
136
+ - **默认自动**:postinstall 不锁版本——已装版本与 npm latest 不一致时自动重装到最新(无需手动改)。
137
+ - **想钉住版本**:设环境变量 `DSHCS_CODE_SERVER_VERSION`(如 `4.134.0`);去掉它回到跟随 latest。
138
+ - 重新 `pnpm pack` + `dsh plugin --profile web add <tgz>` 即触发 postinstall 检查(或直接删 `.code-server-app` 重装)
104
139
 
105
140
  ### 兼容旧的 runtime 目录安装
106
141
 
@@ -0,0 +1,61 @@
1
+ // dshcs-open-file:DSH host 通过信号文件请求打开文件。
2
+ // host 写入 <user-data>/User/dshcs-open.json 后,本扩展在已连接的窗口中打开该文件。
3
+ // 信号路径优先取环境变量 DSHCS_OPEN_FILE_SIGNAL(host 注入);
4
+ // 取不到时用 context.globalStorageUri 推导(=<user-data>/User/globalStorage/<id> 的上两级)。
5
+ const fs = require('fs');
6
+ const vscode = require('vscode');
7
+
8
+ function signalPath(context) {
9
+ const envP = process.env.DSHCS_OPEN_FILE_SIGNAL;
10
+ if (typeof envP === 'string' && envP !== '') return envP;
11
+ try {
12
+ const user = vscode.Uri.joinPath(context.globalStorageUri, '..', '..');
13
+ return vscode.Uri.joinPath(user, 'dshcs-open.json').fsPath;
14
+ } catch {
15
+ return null;
16
+ }
17
+ }
18
+
19
+ let timer = null;
20
+ function processSignal(signal) {
21
+ let raw;
22
+ try {
23
+ raw = fs.readFileSync(signal, 'utf8');
24
+ } catch {
25
+ return; // 尚无信号
26
+ }
27
+ let file = null;
28
+ try {
29
+ file = JSON.parse(raw).file;
30
+ } catch {
31
+ return;
32
+ }
33
+ if (typeof file !== 'string' || file === '') return;
34
+ const uri = vscode.Uri.file(file);
35
+ vscode.window.showTextDocument(uri, { preview: false }).then(
36
+ () => {
37
+ try {
38
+ fs.unlinkSync(signal);
39
+ } catch {}
40
+ },
41
+ (err) => {
42
+ // 尚未有窗口连接(或打开失败):保留信号,轮询会重试
43
+ console.log('[dshcs-open-file] open failed, will retry:', err && err.message ? err.message : String(err));
44
+ },
45
+ );
46
+ }
47
+
48
+ function activate(context) {
49
+ const signal = signalPath(context);
50
+ if (signal === null) {
51
+ console.log('[dshcs-open-file] no signal path (env/globalStorage both unavailable)');
52
+ return;
53
+ }
54
+ console.log('[dshcs-open-file] watching ' + signal);
55
+ // 启动先处理一次,随后每 800ms 轮询(信号可能由 host 晚些写入)
56
+ processSignal(signal);
57
+ timer = setInterval(function () { processSignal(signal); }, 800);
58
+ context.subscriptions.push({ dispose: function () { clearInterval(timer); } });
59
+ }
60
+
61
+ exports.activate = activate;
@@ -0,0 +1,14 @@
1
+ {
2
+ "name": "dshcs-open-file",
3
+ "displayName": "DSH Code Server Open File",
4
+ "description": "Opens files requested by the DSH host through a signal file (dshcs-open.json).",
5
+ "version": "0.0.1",
6
+ "publisher": "dsh-code-server-app",
7
+ "engines": {
8
+ "vscode": "^1.80.0"
9
+ },
10
+ "activationEvents": [
11
+ "onStartupFinished"
12
+ ],
13
+ "main": "./extension.js"
14
+ }
Binary file
@@ -0,0 +1,4 @@
1
+ <svg width="100%" height="100%" viewBox="0 0 147 147" xmlns="http://www.w3.org/2000/svg">
2
+ <style>@media (prefers-color-scheme: dark) {* { fill: white; }}</style>
3
+ <path d="m42.4214,39.655c-24.4057,0 -42.1554,13.1721 -42.1554,33.845c0,20.5814 18.4892,33.845 42.1554,33.845c23.6662,0 38.1803,-11.6171 38.7349,-28.7225l-21.0777,-0.4574c-0.9244,9.3303 -9.1059,15.1845 -17.6572,15.1845c-11.7406,0 -20.4306,-7.5922 -20.4306,-19.8496c0,-12.2574 8.69,-19.9868 20.4306,-20.2155c8.5513,-0.183 16.9177,5.9457 17.4723,15.276l21.0777,-0.6403c-0.4622,-16.8311 -14.1442,-28.2652 -38.55,-28.2652zm48.8446,2l55.468,0l0,64.0311l-55.468,0l0,-64.0311z" clip-rule="evenodd" fill-rule="evenodd"/>
4
+ </svg>