dsh-remote 0.8.90 → 0.8.92

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/README.en.md +1 -0
  2. package/README.md +1 -0
  3. package/lib/client.js +184 -70
  4. package/lib/credential.js +7 -0
  5. package/lib/index.js +125 -31
  6. package/lib/openssh.js +60 -1
  7. package/lib/pool.js +127 -68
  8. package/lib/posix-shell.cjs +34 -0
  9. package/lib/remote-shell-child.cjs +8 -11
  10. package/lib/remote-skills.js +312 -0
  11. package/lib/routes-fs.js +6 -0
  12. package/lib/routes-misc.js +38 -1
  13. package/lib/web-attach.js +17 -7
  14. package/package.json +11 -8
  15. package/node_modules/buildcheck/.eslintrc.js +0 -5
  16. package/node_modules/buildcheck/.github/workflows/ci.yml +0 -88
  17. package/node_modules/buildcheck/.github/workflows/lint.yml +0 -27
  18. package/node_modules/buildcheck/.npmignore +0 -3
  19. package/node_modules/buildcheck/LICENSE +0 -19
  20. package/node_modules/buildcheck/README.md +0 -106
  21. package/node_modules/buildcheck/deps/Find-VisualStudio.cs +0 -250
  22. package/node_modules/buildcheck/lib/findvs.js +0 -361
  23. package/node_modules/buildcheck/lib/index.js +0 -738
  24. package/node_modules/buildcheck/package.json +0 -36
  25. package/node_modules/buildcheck/test/test.js +0 -8
  26. package/node_modules/cpu-features/.eslintrc.js +0 -5
  27. package/node_modules/cpu-features/.github/workflows/ci.yml +0 -74
  28. package/node_modules/cpu-features/.github/workflows/lint.yml +0 -27
  29. package/node_modules/cpu-features/LICENSE +0 -19
  30. package/node_modules/cpu-features/README.md +0 -59
  31. package/node_modules/cpu-features/binding.gyp +0 -16
  32. package/node_modules/cpu-features/buildcheck.js +0 -32
  33. package/node_modules/cpu-features/deps/cpu_features/.clang-format +0 -4
  34. package/node_modules/cpu-features/deps/cpu_features/.dockerignore +0 -31
  35. package/node_modules/cpu-features/deps/cpu_features/.github/workflows/Dockerfile +0 -5
  36. package/node_modules/cpu-features/deps/cpu_features/.github/workflows/aarch64_linux_cmake.yml +0 -30
  37. package/node_modules/cpu-features/deps/cpu_features/.github/workflows/amd64_freebsd_cmake.yml +0 -22
  38. package/node_modules/cpu-features/deps/cpu_features/.github/workflows/amd64_linux_bazel.yml +0 -26
  39. package/node_modules/cpu-features/deps/cpu_features/.github/workflows/amd64_linux_cmake.yml +0 -31
  40. package/node_modules/cpu-features/deps/cpu_features/.github/workflows/amd64_macos_cmake.yml +0 -43
  41. package/node_modules/cpu-features/deps/cpu_features/.github/workflows/amd64_windows_cmake.yml +0 -25
  42. package/node_modules/cpu-features/deps/cpu_features/.github/workflows/arm_linux_cmake.yml +0 -31
  43. package/node_modules/cpu-features/deps/cpu_features/.github/workflows/clang_format.yml +0 -24
  44. package/node_modules/cpu-features/deps/cpu_features/.github/workflows/mips_linux_cmake.yml +0 -30
  45. package/node_modules/cpu-features/deps/cpu_features/.github/workflows/power_linux_cmake.yml +0 -29
  46. package/node_modules/cpu-features/deps/cpu_features/.github/workflows/riscv_linux_cmake.yml +0 -28
  47. package/node_modules/cpu-features/deps/cpu_features/.github/workflows/s390x_linux_cmake.yml +0 -27
  48. package/node_modules/cpu-features/deps/cpu_features/.grenrc.yml +0 -21
  49. package/node_modules/cpu-features/deps/cpu_features/BUILD.bazel +0 -329
  50. package/node_modules/cpu-features/deps/cpu_features/CMakeLists.txt +0 -261
  51. package/node_modules/cpu-features/deps/cpu_features/CONTRIBUTING.md +0 -23
  52. package/node_modules/cpu-features/deps/cpu_features/LICENSE +0 -230
  53. package/node_modules/cpu-features/deps/cpu_features/README.md +0 -272
  54. package/node_modules/cpu-features/deps/cpu_features/WORKSPACE +0 -19
  55. package/node_modules/cpu-features/deps/cpu_features/bazel/ci/README.md +0 -5
  56. package/node_modules/cpu-features/deps/cpu_features/bazel/platforms.bzl +0 -11
  57. package/node_modules/cpu-features/deps/cpu_features/cmake/CpuFeaturesConfig.cmake.in +0 -3
  58. package/node_modules/cpu-features/deps/cpu_features/cmake/CpuFeaturesNdkCompatConfig.cmake.in +0 -3
  59. package/node_modules/cpu-features/deps/cpu_features/cmake/README.md +0 -30
  60. package/node_modules/cpu-features/deps/cpu_features/cmake/ci/Makefile +0 -252
  61. package/node_modules/cpu-features/deps/cpu_features/cmake/ci/README.md +0 -40
  62. package/node_modules/cpu-features/deps/cpu_features/cmake/ci/doc/docker.dot +0 -64
  63. package/node_modules/cpu-features/deps/cpu_features/cmake/ci/doc/docker.svg +0 -312
  64. package/node_modules/cpu-features/deps/cpu_features/cmake/ci/doc/generate_image.sh +0 -7
  65. package/node_modules/cpu-features/deps/cpu_features/cmake/ci/docker/amd64/Dockerfile +0 -48
  66. package/node_modules/cpu-features/deps/cpu_features/cmake/ci/docker/toolchain/Dockerfile +0 -34
  67. package/node_modules/cpu-features/deps/cpu_features/cmake/ci/sample/CMakeLists.txt +0 -22
  68. package/node_modules/cpu-features/deps/cpu_features/cmake/ci/sample/main.cpp +0 -11
  69. package/node_modules/cpu-features/deps/cpu_features/cmake/ci/vagrant/freebsd/Vagrantfile +0 -107
  70. package/node_modules/cpu-features/deps/cpu_features/cmake/googletest.CMakeLists.txt.in +0 -15
  71. package/node_modules/cpu-features/deps/cpu_features/cpu_features.gyp +0 -105
  72. package/node_modules/cpu-features/deps/cpu_features/include/cpu_features_cache_info.h +0 -54
  73. package/node_modules/cpu-features/deps/cpu_features/include/cpu_features_macros.h +0 -384
  74. package/node_modules/cpu-features/deps/cpu_features/include/cpuinfo_aarch64.h +0 -259
  75. package/node_modules/cpu-features/deps/cpu_features/include/cpuinfo_arm.h +0 -121
  76. package/node_modules/cpu-features/deps/cpu_features/include/cpuinfo_mips.h +0 -74
  77. package/node_modules/cpu-features/deps/cpu_features/include/cpuinfo_ppc.h +0 -149
  78. package/node_modules/cpu-features/deps/cpu_features/include/cpuinfo_riscv.h +0 -72
  79. package/node_modules/cpu-features/deps/cpu_features/include/cpuinfo_s390x.h +0 -108
  80. package/node_modules/cpu-features/deps/cpu_features/include/cpuinfo_x86.h +0 -288
  81. package/node_modules/cpu-features/deps/cpu_features/include/internal/bit_utils.h +0 -40
  82. package/node_modules/cpu-features/deps/cpu_features/include/internal/cpuid_x86.h +0 -37
  83. package/node_modules/cpu-features/deps/cpu_features/include/internal/filesystem.h +0 -39
  84. package/node_modules/cpu-features/deps/cpu_features/include/internal/hwcaps.h +0 -240
  85. package/node_modules/cpu-features/deps/cpu_features/include/internal/stack_line_reader.h +0 -49
  86. package/node_modules/cpu-features/deps/cpu_features/include/internal/string_view.h +0 -110
  87. package/node_modules/cpu-features/deps/cpu_features/include/internal/windows_utils.h +0 -70
  88. package/node_modules/cpu-features/deps/cpu_features/ndk_compat/CMakeLists.txt +0 -60
  89. package/node_modules/cpu-features/deps/cpu_features/ndk_compat/README.md +0 -4
  90. package/node_modules/cpu-features/deps/cpu_features/ndk_compat/cpu-features.c +0 -205
  91. package/node_modules/cpu-features/deps/cpu_features/ndk_compat/cpu-features.h +0 -320
  92. package/node_modules/cpu-features/deps/cpu_features/ndk_compat/ndk-compat-test.c +0 -12
  93. package/node_modules/cpu-features/deps/cpu_features/patches/0001-Add-Apple-Silicon-Support.patch +0 -456
  94. package/node_modules/cpu-features/deps/cpu_features/scripts/generate_badges.d +0 -165
  95. package/node_modules/cpu-features/deps/cpu_features/scripts/make_release.sh +0 -75
  96. package/node_modules/cpu-features/deps/cpu_features/scripts/run_integration.sh +0 -490
  97. package/node_modules/cpu-features/deps/cpu_features/scripts/test_integration.sh +0 -79
  98. package/node_modules/cpu-features/deps/cpu_features/src/copy.inl +0 -19
  99. package/node_modules/cpu-features/deps/cpu_features/src/define_introspection.inl +0 -86
  100. package/node_modules/cpu-features/deps/cpu_features/src/define_introspection_and_hwcaps.inl +0 -26
  101. package/node_modules/cpu-features/deps/cpu_features/src/equals.inl +0 -22
  102. package/node_modules/cpu-features/deps/cpu_features/src/filesystem.c +0 -62
  103. package/node_modules/cpu-features/deps/cpu_features/src/hwcaps.c +0 -169
  104. package/node_modules/cpu-features/deps/cpu_features/src/impl_aarch64__base_implementation.inl +0 -88
  105. package/node_modules/cpu-features/deps/cpu_features/src/impl_aarch64_linux_or_android.c +0 -79
  106. package/node_modules/cpu-features/deps/cpu_features/src/impl_aarch64_macos_or_iphone.c +0 -82
  107. package/node_modules/cpu-features/deps/cpu_features/src/impl_aarch64_windows.c +0 -138
  108. package/node_modules/cpu-features/deps/cpu_features/src/impl_arm_linux_or_android.c +0 -212
  109. package/node_modules/cpu-features/deps/cpu_features/src/impl_mips_linux_or_android.c +0 -93
  110. package/node_modules/cpu-features/deps/cpu_features/src/impl_ppc_linux.c +0 -163
  111. package/node_modules/cpu-features/deps/cpu_features/src/impl_riscv_linux.c +0 -111
  112. package/node_modules/cpu-features/deps/cpu_features/src/impl_s390x_linux.c +0 -120
  113. package/node_modules/cpu-features/deps/cpu_features/src/impl_x86__base_implementation.inl +0 -2055
  114. package/node_modules/cpu-features/deps/cpu_features/src/impl_x86_freebsd.c +0 -68
  115. package/node_modules/cpu-features/deps/cpu_features/src/impl_x86_linux_or_android.c +0 -58
  116. package/node_modules/cpu-features/deps/cpu_features/src/impl_x86_macos.c +0 -57
  117. package/node_modules/cpu-features/deps/cpu_features/src/impl_x86_windows.c +0 -58
  118. package/node_modules/cpu-features/deps/cpu_features/src/stack_line_reader.c +0 -132
  119. package/node_modules/cpu-features/deps/cpu_features/src/string_view.c +0 -192
  120. package/node_modules/cpu-features/deps/cpu_features/src/utils/list_cpu_features.c +0 -461
  121. package/node_modules/cpu-features/deps/cpu_features/test/CMakeLists.txt +0 -114
  122. package/node_modules/cpu-features/deps/cpu_features/test/bit_utils_test.cc +0 -53
  123. package/node_modules/cpu-features/deps/cpu_features/test/cpuinfo_aarch64_test.cc +0 -396
  124. package/node_modules/cpu-features/deps/cpu_features/test/cpuinfo_arm_test.cc +0 -384
  125. package/node_modules/cpu-features/deps/cpu_features/test/cpuinfo_mips_test.cc +0 -176
  126. package/node_modules/cpu-features/deps/cpu_features/test/cpuinfo_ppc_test.cc +0 -131
  127. package/node_modules/cpu-features/deps/cpu_features/test/cpuinfo_riscv_test.cc +0 -180
  128. package/node_modules/cpu-features/deps/cpu_features/test/cpuinfo_s390x_test.cc +0 -82
  129. package/node_modules/cpu-features/deps/cpu_features/test/cpuinfo_x86_test.cc +0 -1729
  130. package/node_modules/cpu-features/deps/cpu_features/test/filesystem_for_testing.cc +0 -103
  131. package/node_modules/cpu-features/deps/cpu_features/test/filesystem_for_testing.h +0 -61
  132. package/node_modules/cpu-features/deps/cpu_features/test/hwcaps_for_testing.cc +0 -52
  133. package/node_modules/cpu-features/deps/cpu_features/test/hwcaps_for_testing.h +0 -31
  134. package/node_modules/cpu-features/deps/cpu_features/test/stack_line_reader_test.cc +0 -132
  135. package/node_modules/cpu-features/deps/cpu_features/test/string_view_test.cc +0 -202
  136. package/node_modules/cpu-features/lib/index.js +0 -5
  137. package/node_modules/cpu-features/package.json +0 -40
  138. package/node_modules/cpu-features/src/binding.cc +0 -151
  139. package/node_modules/cpu-features/test/test.js +0 -12
package/README.en.md CHANGED
@@ -61,6 +61,7 @@ The rest:
61
61
  - **Tell local and remote Sessions apart in the sidebar** (`0.8.43+`) — a remote Session row carries a **green dot** and its hover card names `user@host:port` plus the remote path; opening it also shows a host chip in the conversation header (a local Session shows neither). A Session counts as remote only when its cwd sits inside a `$DSH_HOME/remote-workspaces/…` mirror, so a machine that is merely saved never labels a local Session.
62
62
  - **A terminal in a remote Session opens on the remote host out of the box** (`0.8.75+`) — the shell menu's **remote ssh** entry routes by cwd (a mirror cwd → ssh into the remote workspace; anything else → transparent local-shell fallback), and it is the **default shell** whenever neither the host nor you picked one. Saved passwords are answered through the local credential bridge (`0.8.81+`, including OS-keychain ones) — no more `password:` prompt every time a terminal opens.
63
63
  - **Remote file previews have line numbers and syntax highlighting** (`0.8.86+`) — code files render through the host's own Shiki engine, and chat links carrying `file:line` (or `#L<n>`) land on that line with a flash.
64
+ - **Remote project skills need no prior sync** (issue #120) — `.dsh/skills` and `.agents/skills` on a remote workspace appear in the DSH skill catalog, including directory bundles and top-level Markdown files; full bodies load over SFTP on demand, and the remote candidate wins a same-named stale mirror copy. Resolve adjacent resources with `rw_list_dir` / `rw_read_file`. Writes, pushes and autoPush invalidate the catalog immediately; background/external edits are covered by a five-minute **invalidate-only** timer that performs no SFTP traffic of its own. Ordinary local Sessions keep the host's original skill discovery.
64
65
  - **Open a remote machine's DSH Web UI locally** (`0.8.36+`) — nothing has to be exposed on the remote: the plugin SSHes out, starts a `dsh web` there that binds **`127.0.0.1` only**, and tunnels its port back to a loopback port on this machine. The URL carries a one-time login token, consumed once by a redirect.
65
66
  - **The audit log opens locally** — preview recent entries in the panel, or use 「打开日志文件」/「在文件夹中显示」 to open the log with a local program (the log lives on the DSH host, so a browser cannot open it).
66
67
  - **Cross-platform remotes** — all file access is SFTP-protocol-level (no POSIX shell), so Linux/macOS/Windows remotes all work.
package/README.md CHANGED
@@ -50,6 +50,7 @@ DSH 的 Web 界面刻意只监听 `127.0.0.1`(CLI 为安全拒绝 `--host 0.0.
50
50
  - **会话列表里区分本地/远程**(`0.8.43+`)—— 远程会话的行首有一个**绿点**,悬停显示 `user@host:port` 与远端路径;打开该会话后,标题栏还会常显一个主机标签(本地会话两者都没有)。判定只看会话 cwd 是否落在 `$DSH_HOME/remote-workspaces/…` 镜像里,所以「保存过但没在用」的机器不会给本地会话打标。
51
51
  - **远程会话的终端开箱即在远端**(`0.8.75+`)—— 侧栏终端的 shell 菜单里有插件贡献的 **remote ssh**:按 cwd 智能路由(远程镜像 → `ssh` 进远端工作目录;本地会话 → 自动回落本地 shell),在没人占位时它还是**默认 shell**。已保存的密码由本机凭据桥自动应答(`0.8.81+`,含操作系统钥匙串里的),不会再每次开终端都问一遍 `password:`。
52
52
  - **远程文件预览带行号与语法高亮**(`0.8.86+`)—— 代码文件用宿主自家的 Shiki 引擎着色;AI 回答里的 `文件:行号`(或 `#L行号`)链接点开直接落到那一行并闪烁提示。
53
+ - **远程项目技能无需先同步**(issue #120)—— 远程工作区的 `.dsh/skills` 与 `.agents/skills` 会直接进入 DSH 技能目录,支持目录型 `SKILL.md` 和顶层 `.md`,完整正文按需经 SFTP 加载;同名时远端内容优先于本地镜像副本。技能里引用相邻资源时用 `rw_list_dir` / `rw_read_file` 读取。写入、推送、autoPush 会立即失效目录缓存;后台或外部进程的修改由每 5 分钟一次的**只失效、不联网**刷新兜底,不会制造定时 SFTP 流量。普通本地会话仍只使用宿主原有技能目录。
53
54
  - **把远端机器的 DSH 界面挂到本机**(`0.8.36+`)—— 不用在远端开任何端口:插件主动 SSH 连过去,在远端**只监听 `127.0.0.1`** 地起一个 `dsh web`,再把端口经隧道搬回本机的一个 loopback 端口。地址带一次性登录令牌,只在本机这次跳转里用一次。
54
55
  - **审计日志可以在本机直接打开** —— 面板里预览最近条目,另有「打开日志文件」「在文件夹中显示」直接调用本机程序打开那个日志(日志在运行 DSH 的机器上,浏览器打不开它)。
55
56
  - **远端跨平台** —— 文件访问走 SFTP 协议层(不依赖 POSIX shell),Linux/macOS/Windows 远端都能列/读/写/搜索/同步。
package/lib/client.js CHANGED
@@ -1360,15 +1360,21 @@ window.__ModuleLoader__.load({
1360
1360
  // Mirrors the host default (DEFAULT_UPDATE_MODE = 'auto') so the panel
1361
1361
  // does not flash "manual" before the first /update-check answers.
1362
1362
  const [updMode, setUpdMode] = React.useState('auto')
1363
- // Issue #78: initial value comes from localStorage, so a user's choice
1364
- // survives restarts (the bug was: the panel popped again every restart).
1363
+ // Render the local fallback immediately, then reconcile the shared host
1364
+ // value. The auto-open paths await the SAME promise, so a slow false never
1365
+ // arrives after an eager openTab.
1365
1366
  const [explorerAuto, setExplorerAuto] = React.useState(() => explorerAutoOpenEnabled())
1367
+ React.useEffect(() => {
1368
+ let cancelled = false
1369
+ explorerAutoOpenPreference().then((on) => { if (!cancelled) setExplorerAuto(on) })
1370
+ return () => { cancelled = true }
1371
+ }, [])
1366
1372
  // One applier per toggle, shared by the native-checkbox fallback (event
1367
1373
  // semantics) and the host Switch (bare-boolean callback), so both paths
1368
1374
  // behave identically.
1369
1375
  const applyExplorerAutoOpen = (on) => {
1370
1376
  setExplorerAuto(on)
1371
- try { window.localStorage.setItem(EXPLORER_AUTO_OPEN_KEY, on ? '1' : '0') } catch { /* private mode: choice lasts this session only */ }
1377
+ void updateExplorerAutoOpenPreference(on)
1372
1378
  }
1373
1379
  const checkUpdate = (quiet) => {
1374
1380
  if (updBusy) return
@@ -2986,17 +2992,62 @@ window.__ModuleLoader__.load({
2986
2992
  // resource type, never a better-sidebar card (see registerSidebarIntegration).
2987
2993
  const SIDEBAR_EXPLORER_ID = 'dsh-remote:explorer'
2988
2994
 
2989
- // Issue #78: durable opt-out for the sidebar auto-open. The in-memory
2990
- // autoOpenedFor set forgetting across restarts is by design; THIS key is
2991
- // the user's persistent "别再给我弹远程文件面板". Browser-local because the
2992
- // feature itself is browser-local. Default ON preserves the behaviour
2993
- // existing users know — only an explicit uncheck turns it off.
2995
+ // Issue #78 + #119: durable opt-out for BOTH sidebar worlds. localStorage
2996
+ // remains a fallback/migration source, but it is origin-scoped and tether can
2997
+ // give the same DSH_HOME a fresh origin. The host file is authoritative once
2998
+ // set; the first auto-open waits for this shared value instead of racing a
2999
+ // late `enabled:false` and popping the panel before it arrives.
2994
3000
  const EXPLORER_AUTO_OPEN_KEY = 'dsh-remote:explorerAutoOpen'
2995
- function explorerAutoOpenEnabled() {
3001
+ const EXPLORER_AUTO_OPEN_ROUTE = '/dsh-remote/explorer-auto-open'
3002
+ let explorerAutoEffective = true
3003
+ let explorerAutoPreferencePromise = null
3004
+ let explorerAutoPreferenceRevision = 0
3005
+ function localExplorerAutoOpenPreference() {
2996
3006
  try {
2997
- if (typeof window === 'undefined' || !window.localStorage) return true
2998
- return window.localStorage.getItem(EXPLORER_AUTO_OPEN_KEY) !== '0'
2999
- } catch { return true }
3007
+ if (typeof window === 'undefined' || !window.localStorage) return null
3008
+ const value = window.localStorage.getItem(EXPLORER_AUTO_OPEN_KEY)
3009
+ return value === '0' ? false : value === '1' ? true : null
3010
+ } catch { return null }
3011
+ }
3012
+ explorerAutoEffective = localExplorerAutoOpenPreference() ?? true
3013
+ function explorerAutoOpenEnabled() { return explorerAutoEffective }
3014
+ function explorerAutoOpenPreference() {
3015
+ if (explorerAutoPreferencePromise) return explorerAutoPreferencePromise
3016
+ const revision = explorerAutoPreferenceRevision
3017
+ const local = localExplorerAutoOpenPreference()
3018
+ if (local !== null) explorerAutoEffective = local
3019
+ explorerAutoPreferencePromise = api('GET', EXPLORER_AUTO_OPEN_ROUTE).then((r) => {
3020
+ // A user click after this request started always wins over its response.
3021
+ if (revision !== explorerAutoPreferenceRevision) return explorerAutoEffective
3022
+ if (r && typeof r.enabled === 'boolean') {
3023
+ if (r.persisted === true) {
3024
+ explorerAutoEffective = r.enabled
3025
+ } else if (local !== null) {
3026
+ // Upgrade path: the host has no explicit choice yet. Carry this
3027
+ // origin's old value into DSH_HOME; a failed migration still leaves
3028
+ // the local fallback in force for this run.
3029
+ explorerAutoEffective = local
3030
+ void api('POST', EXPLORER_AUTO_OPEN_ROUTE, { enabled: local }).catch(() => {})
3031
+ } else {
3032
+ explorerAutoEffective = r.enabled
3033
+ }
3034
+ } else if (local !== null) {
3035
+ explorerAutoEffective = local
3036
+ }
3037
+ return explorerAutoEffective
3038
+ }).catch(() => {
3039
+ // Host unreachable is not permission to ignore an explicit local OFF.
3040
+ if (revision === explorerAutoPreferenceRevision && local !== null) explorerAutoEffective = local
3041
+ return explorerAutoEffective
3042
+ })
3043
+ return explorerAutoPreferencePromise
3044
+ }
3045
+ function updateExplorerAutoOpenPreference(on) {
3046
+ explorerAutoPreferenceRevision++
3047
+ explorerAutoEffective = on
3048
+ try { window.localStorage.setItem(EXPLORER_AUTO_OPEN_KEY, on ? '1' : '0') } catch { /* session-only fallback */ }
3049
+ // Keep a working local fallback if the host is temporarily unreachable.
3050
+ return api('POST', EXPLORER_AUTO_OPEN_ROUTE, { enabled: on }).catch(() => null)
3000
3051
  }
3001
3052
 
3002
3053
  function fetchRemoteStatus(sessionId) {
@@ -3106,6 +3157,36 @@ window.__ModuleLoader__.load({
3106
3157
  }
3107
3158
  return best
3108
3159
  }
3160
+ // Server identity colors are independent of SSH health and workspace path.
3161
+ // Persist allocations per browser so adding a server never recolors old ones.
3162
+ const serverPalette = ['#5489d8', '#a579d5', '#d99a45', '#49a5ab', '#d8799c', '#858ed2', '#91a650', '#c5825c']
3163
+ const serverColorKey = 'dsh-remote.server-colors.v1'
3164
+ let serverColors = {}
3165
+ try {
3166
+ const saved = JSON.parse(localStorage.getItem(serverColorKey) || '{}')
3167
+ if (saved && typeof saved === 'object' && !Array.isArray(saved)) {
3168
+ for (const [key, value] of Object.entries(saved)) {
3169
+ if (/^#[0-9a-f]{6}$/i.test(value)) serverColors[key] = value
3170
+ }
3171
+ }
3172
+ } catch { /* storage may be unavailable */ }
3173
+ function mirrorColor(m) {
3174
+ // Ignore username: two accounts on the same endpoint are one server.
3175
+ const key = JSON.stringify([String(m.host || '').trim().toLowerCase(), Number(m.port) || 22])
3176
+ if (serverColors[key]) return serverColors[key]
3177
+ let hash = 2166136261
3178
+ for (let i = 0; i < key.length; i++) hash = Math.imul(hash ^ key.charCodeAt(i), 16777619) >>> 0
3179
+ const used = new Set(Object.values(serverColors))
3180
+ const start = hash % serverPalette.length
3181
+ let color = serverPalette[start]
3182
+ for (let i = 0; i < serverPalette.length; i++) {
3183
+ const candidate = serverPalette[(start + i) % serverPalette.length]
3184
+ if (!used.has(candidate)) { color = candidate; break }
3185
+ }
3186
+ serverColors[key] = color
3187
+ try { localStorage.setItem(serverColorKey, JSON.stringify(serverColors)) } catch { /* memory fallback */ }
3188
+ return color
3189
+ }
3109
3190
  /** `user@host:port` for a mirror record (port omitted when it is 22). */
3110
3191
  function mirrorTarget(m) {
3111
3192
  if (!m) return ''
@@ -3154,8 +3235,8 @@ window.__ModuleLoader__.load({
3154
3235
  return mirrorForCwd(cwd, MIRRORS.list)
3155
3236
  }
3156
3237
 
3157
- // Leading seat of a Session row: the 16px cell before the title. A green dot
3158
- // means "this session works on a remote host"; a local session renders
3238
+ // Leading seat of a Session row: the 16px cell before the title. A colored dot
3239
+ // identifies the remote server (not connection health); a local session renders
3159
3240
  // nothing at all, so the cell stays blank exactly as before. The owner only
3160
3241
  // mounts this seat while the row is idle (a running/pending row keeps its
3161
3242
  // own status dot there) — the hover card below therefore carries the host
@@ -3174,8 +3255,8 @@ window.__ModuleLoader__.load({
3174
3255
  'aria-hidden': 'true',
3175
3256
  style: {
3176
3257
  width: 8, height: 8, borderRadius: '50%',
3177
- background: 'var(--dsw-alias-state-success-primary, #4caf7d)',
3178
- boxShadow: '0 0 0 2px color-mix(in srgb, var(--dsw-alias-state-success-primary, #4caf7d) 22%, transparent)',
3258
+ background: mirrorColor(m),
3259
+ boxShadow: '0 0 0 2px color-mix(in srgb, ' + mirrorColor(m) + ' 22%, transparent)',
3179
3260
  },
3180
3261
  }))
3181
3262
  }
@@ -3190,7 +3271,7 @@ window.__ModuleLoader__.load({
3190
3271
  React.createElement('div', { style: { display: 'flex', alignItems: 'center', gap: 6 } },
3191
3272
  React.createElement('span', {
3192
3273
  'aria-hidden': 'true',
3193
- style: { width: 7, height: 7, borderRadius: '50%', flexShrink: 0, background: 'var(--dsw-alias-state-success-primary, #4caf7d)' },
3274
+ style: { width: 7, height: 7, borderRadius: '50%', flexShrink: 0, background: mirrorColor(m) },
3194
3275
  }),
3195
3276
  React.createElement('span', { style: { color: '#cfd3d6', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } }, mirrorLabel(m)),
3196
3277
  ),
@@ -3215,18 +3296,23 @@ window.__ModuleLoader__.load({
3215
3296
  // When better-sidebar is installed it owns the presentation (the
3216
3297
  // guide-card handshake arbitrates that); never open twice.
3217
3298
  React.useEffect(() => {
3218
- if (!m || !props.sessionId) return
3219
- if (!explorerAutoOpenEnabled()) return // the #78 opt-out covers both worlds
3220
- if (explorerOwnedByBs) return
3221
- if (autoOpenedNative.has(props.sessionId)) return
3299
+ if (!m || !props.sessionId) return undefined
3300
+ if (explorerOwnedByBs) return undefined
3301
+ if (autoOpenedNative.has(props.sessionId)) return undefined
3222
3302
  const right = SIDEBAR_RIGHT
3223
- if (!right || typeof right.openTab !== 'function') return
3224
- autoOpenedNative.add(props.sessionId)
3225
- try {
3226
- right.openTab(NATIVE_EXPLORER)
3227
- } catch {
3228
- autoOpenedNative.delete(props.sessionId) // unregistered kind, etc: retry next time
3229
- }
3303
+ if (!right || typeof right.openTab !== 'function') return undefined
3304
+ let cancelled = false
3305
+ const sessionId = props.sessionId
3306
+ void explorerAutoOpenPreference().then((enabled) => {
3307
+ if (cancelled || !enabled || explorerOwnedByBs || autoOpenedNative.has(sessionId)) return
3308
+ autoOpenedNative.add(sessionId)
3309
+ try {
3310
+ right.openTab(NATIVE_EXPLORER)
3311
+ } catch {
3312
+ autoOpenedNative.delete(sessionId) // unregistered kind, etc: retry next time
3313
+ }
3314
+ })
3315
+ return () => { cancelled = true }
3230
3316
  }, [m, props.sessionId])
3231
3317
  if (!m) return null
3232
3318
  const target = mirrorTarget(m)
@@ -3234,11 +3320,11 @@ window.__ModuleLoader__.load({
3234
3320
  'data-dsh-remote-chip': '',
3235
3321
  className: 'dsh-rw-pill is-ok',
3236
3322
  title: tr('session.remoteHover', { target }) + (m.remotePath ? '\n' + m.remotePath : ''),
3237
- style: { maxWidth: 220, overflow: 'hidden', textOverflow: 'ellipsis', display: 'inline-flex', alignItems: 'center', gap: 5 },
3323
+ style: { color: mirrorColor(m), borderColor: 'currentColor', maxWidth: 220, overflow: 'hidden', textOverflow: 'ellipsis', display: 'inline-flex', alignItems: 'center', gap: 5 },
3238
3324
  },
3239
3325
  React.createElement('span', {
3240
3326
  'aria-hidden': 'true',
3241
- style: { width: 7, height: 7, borderRadius: '50%', flexShrink: 0, background: 'var(--dsw-alias-state-success-primary, #4caf7d)' },
3327
+ style: { width: 7, height: 7, borderRadius: '50%', flexShrink: 0, background: mirrorColor(m) },
3242
3328
  }),
3243
3329
  React.createElement('span', { style: { overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } }, target),
3244
3330
  )
@@ -3879,7 +3965,9 @@ window.__ModuleLoader__.load({
3879
3965
  * null. A Windows drive colon never trails a digit sequence after a path
3880
3966
  * separator, and `path:0` is meaningless, so the strip is unambiguous. */
3881
3967
  function splitLineAnchor(rawPath) {
3882
- const m = /:(\d+)$/.exec(String(rawPath || ''))
3968
+ // Trailing `:42` or range `:24-30` / `:24:7` (the latter two keep the
3969
+ // start line, mirroring the core's own resolver).
3970
+ const m = /:(\d+)(?::\d+|-\d+)?$/.exec(String(rawPath || ''))
3883
3971
  if (!m) return { path: String(rawPath || ''), line: null }
3884
3972
  const line = Number(m[1])
3885
3973
  const path = String(rawPath).slice(0, m.index)
@@ -3997,7 +4085,7 @@ window.__ModuleLoader__.load({
3997
4085
  .catch((e) => { if (!cancelled) { setErr(String((e && e.message) || e)); setLoading(false) } })
3998
4086
  return () => { cancelled = true }
3999
4087
  }
4000
- React.useEffect(load, [path])
4088
+ React.useEffect(load, [path, fileSessionId])
4001
4089
 
4002
4090
  const startEdit = () => {
4003
4091
  if (!data || data.binary || data.image) return
@@ -4132,24 +4220,26 @@ window.__ModuleLoader__.load({
4132
4220
  let autoOpenedFor = new Set()
4133
4221
  let disposeAuto = null
4134
4222
  const tryAutoOpen = () => {
4135
- if (!explorerAutoOpenEnabled()) return // issue #78: the user said no, persistently
4136
4223
  if (typeof bs.subscribeState !== 'function') return
4137
4224
  const snap = bs.getSnapshot && bs.getSnapshot()
4138
4225
  if (!snap || !snap.sessionId) return
4139
4226
  if (autoOpenedFor.has(snap.sessionId)) return
4140
4227
  const sessionId = snap.sessionId
4141
- // Issue #13: only auto-open the Remote Files tab for sessions that are
4142
- // genuinely remote (cwd inside a mirror). A plain local session must
4143
- // not get a remote tab popped open by a machine that happens to be
4144
- // saved as "current".
4145
- resolveSessionRemote(sessionId).then((remotePath) => {
4146
- if (!remotePath || autoOpenedFor.has(sessionId)) return
4147
- autoOpenedFor.add(sessionId)
4148
- try {
4149
- bs.openTab({ type: SIDEBAR_EXPLORER_ID, title: tr('explorer.tabTitle'), path: remotePath })
4150
- } catch (e2) {
4151
- console.warn('[dsh-remote] better-sidebar auto-open skipped:', e2)
4152
- }
4228
+ // Native and better-sidebar await the SAME effective preference. Only
4229
+ // after it resolves may we resolve the remote path and call openTab.
4230
+ void explorerAutoOpenPreference().then((enabled) => {
4231
+ if (!enabled || autoOpenedFor.has(sessionId)) return
4232
+ // Issue #13: only auto-open for a genuinely remote session. A plain
4233
+ // local session must never borrow the active machine's workspace.
4234
+ return resolveSessionRemote(sessionId).then((remotePath) => {
4235
+ if (!remotePath || autoOpenedFor.has(sessionId)) return
4236
+ autoOpenedFor.add(sessionId)
4237
+ try {
4238
+ bs.openTab({ type: SIDEBAR_EXPLORER_ID, title: tr('explorer.tabTitle'), path: remotePath })
4239
+ } catch (e2) {
4240
+ console.warn('[dsh-remote] better-sidebar auto-open skipped:', e2)
4241
+ }
4242
+ })
4153
4243
  })
4154
4244
  }
4155
4245
  tryAutoOpen()
@@ -4204,15 +4294,19 @@ window.__ModuleLoader__.load({
4204
4294
  const rest = url.pathname.replace(/^\/+/, '')
4205
4295
  const [scope, ...tail] = rest.split('/')
4206
4296
  if (scope !== 'session' || tail.length < 2) return null
4207
- const sessionId = decodeURIComponent(tail[0])
4297
+ let sessionId, decoded
4298
+ try {
4299
+ sessionId = decodeURIComponent(tail[0])
4300
+ decoded = decodeURIComponent(tail.slice(1).join('/'))
4301
+ } catch { return null } // A malformed link must not throw out of the host router.
4208
4302
  if (!sessionId) return null
4209
4303
  // Dropping the leading empty segment keeps a session-root address ('') a
4210
4304
  // legitimate empty path instead of turning it into '/'.
4211
- const decoded = decodeURIComponent(tail.slice(1).join('/'))
4212
- // Issue #104: models cite lines as `path:42` or `path#L42`; the core keeps
4213
- // `:` literal in segments, so both reach us intact. Strip the anchor from
4214
- // the path (resolution must not look for a file literally named "x.c:42").
4215
- const hashLine = /^#L?(\d+)$/i.exec(url.hash || '')
4305
+ // Issue #104 + #108: models cite lines as `path:42` / `path#L42`, and as
4306
+ // RANGES (`path:24-30`, `#L24-L30`) — the core's own prompt teaches the
4307
+ // range form. Range or not, the anchor is stripped from the path (no file
4308
+ // is ever looked up as "x.c:42"); we take the start line, like the core.
4309
+ const hashLine = /^#L?(\d+)(?:-L?\d+)?$/i.exec(url.hash || '')
4216
4310
  const split = splitLineAnchor(decoded)
4217
4311
  const line = hashLine ? Number(hashLine[1]) : split.line
4218
4312
  return { sessionId, path: split.path, ...(line ? { line } : {}) }
@@ -4302,32 +4396,44 @@ window.__ModuleLoader__.load({
4302
4396
  const address = info.tab.navigation.address
4303
4397
  const parsed = parseCoreFileAddress(address)
4304
4398
  const sessionId = (parsed && parsed.sessionId) || props.sessionId
4305
- const [remotePath, setRemotePath] = React.useState(() => {
4306
- const p = parsed || parseCoreFileAddress(address)
4307
- return p ? remotePathForCoreAddress(p, sessionCwdFor(sessionId)) : null
4308
- })
4399
+ // Resolve from the current navigation on every render. Keeping only an
4400
+ // initial path in state made same-tab navigation continue reading the old file.
4401
+ const [, invalidate] = React.useState(0)
4402
+ const remotePath = parsed ? remotePathForCoreAddress(parsed, sessionCwdFor(sessionId)) : null
4309
4403
  React.useEffect(() => {
4310
- if (remotePath || !parsed) return undefined
4311
- let cancelled = false
4312
- ensureMirrors().then(() => {
4313
- if (cancelled) return
4314
- const cwd = sessionCwdFor(sessionId)
4315
- const resolved = remotePathForCoreAddress(parsed, cwd)
4316
- if (resolved) setRemotePath(resolved)
4317
- })
4318
- return () => { cancelled = true }
4319
- }, [address, remotePath])
4404
+ const changed = () => invalidate((version) => version + 1)
4405
+ mirrorWatchers.add(changed)
4406
+ const unsubscribe = SESSIONS?.list?.subscribe?.(changed)
4407
+ ensureMirrors()
4408
+ return () => {
4409
+ mirrorWatchers.delete(changed)
4410
+ if (typeof unsubscribe === 'function') unsubscribe()
4411
+ }
4412
+ }, [sessionId])
4320
4413
  if (!remotePath) {
4321
4414
  return React.createElement('div', { style: { padding: 16, fontSize: 12, opacity: 0.7 } },
4322
4415
  tr('file.linkUnresolved'))
4323
4416
  }
4417
+ // Issue #104 + #108: the line reaches us two ways — inside the address
4418
+ // (`x.c:42` / `#L42`, ranges take the start line) and, on 0.2.x, through
4419
+ // navigation params (`openResource(url, {params:{line}})`); the address
4420
+ // grammar itself never carries one.
4421
+ const paramsLine = (() => {
4422
+ try {
4423
+ const line = info.tab && info.tab.navigation && info.tab.navigation.params && info.tab.navigation.params.line
4424
+ // Host params are the current channel when the address has no
4425
+ // explicit anchor. Accept only actual positive integers: do not
4426
+ // coerce a string like "93" or let invalid params mask a legacy #L2.
4427
+ return Number.isSafeInteger(line) && line > 0 ? line : null
4428
+ } catch { return null }
4429
+ })()
4324
4430
  return React.createElement(RemoteFileTab, {
4325
4431
  key: remotePath,
4326
4432
  tab: { path: remotePath },
4327
4433
  scope: { sessionId },
4328
- // Issue #104: a chat link carrying a line (`x.c:42` or `…#L42`) lands
4329
- // the open file on that line instead of its top.
4330
- jumpLine: (parsed && parsed.line) || null,
4434
+ // Current hosts pass line numbers as navigation params; retain support
4435
+ // for older address-carried anchors. Invalid params must not mask them.
4436
+ jumpLine: (parsed && parsed.line) || paramsLine || null,
4331
4437
  })
4332
4438
  }
4333
4439
  /** The local cwd of a session, from the client's own session store. */
@@ -4421,7 +4527,9 @@ window.__ModuleLoader__.load({
4421
4527
  // `extension` band, which by contract outranks every viewer the product
4422
4528
  // ships — including the built-in text preview that currently claims
4423
4529
  // `dsh-resource://file/**` in the `fallback` band and reads locally.
4424
- // `canOpen` is the whole safety story: it must return true ONLY for a
4530
+ // better-sidebar also registers an extension-band editor, so the more
4531
+ // specific session/** pattern below must win the pattern-length tie-break.
4532
+ // `canOpen` is the safety guard: it must return true ONLY for a
4425
4533
  // session whose cwd is PROVEN to be a remote mirror. Local sessions, and
4426
4534
  // a page load before the mirror registry has arrived, fall through to the
4427
4535
  // built-in preview and behave exactly as they did before.
@@ -4436,7 +4544,13 @@ window.__ModuleLoader__.load({
4436
4544
  try {
4437
4545
  const dispose = tabs.register({
4438
4546
  id: NATIVE_LINK, kind: NATIVE_LINK,
4439
- patterns: ['dsh-resource://file/**'],
4547
+ // Specificity beats bundle order: the registry ranks longest-glob-first,
4548
+ // and ties fall to registration order (which we do not control). Another
4549
+ // extension claiming `dsh-resource://file/**` used to win those ties and
4550
+ // read the local mirror (ENOENT) even for provably remote sessions
4551
+ // (issue #108). The narrower glob matches exactly what
4552
+ // parseCoreFileAddress accepts — the session scope.
4553
+ patterns: ['dsh-resource://file/session/**'],
4440
4554
  canOpen: (address) => {
4441
4555
  const parsed = parseCoreFileAddress(address)
4442
4556
  if (!parsed) return false
package/lib/credential.js CHANGED
@@ -77,6 +77,13 @@ function run(bin, args, input) {
77
77
  })
78
78
  child.stdout.on('data', (d) => { out += d })
79
79
  child.stderr.on('data', (d) => { errOut += d })
80
+ // A helper may close its read end before stdin.end() flushes. EPIPE is an
81
+ // ASYNC Writable error, so the synchronous try/catch below cannot see it;
82
+ // without this listener it becomes an uncaughtException and kills the host.
83
+ child.stdin.on('error', (err) => {
84
+ try { child.kill('SIGTERM') } catch { /* already gone */ }
85
+ done(err)
86
+ })
80
87
  // Always end stdin: a helper that reads a secret from stdin needs EOF, and one
81
88
  // that does not must not inherit an open pipe.
82
89
  try { child.stdin.end(input == null ? '' : String(input)) } catch { /* closed early */ }