dsh-ris-ide 1.7.2 → 1.8.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.
Files changed (79) hide show
  1. package/README.md +43 -4
  2. package/bin/check-listing.mjs +247 -0
  3. package/bin/proxy-janitor.mjs +183 -0
  4. package/bin/risd.mjs +287 -0
  5. package/bin/run-with-log.ps1 +43 -5
  6. package/lib/client-codemirror.js +92 -66
  7. package/lib/client.js +774 -89
  8. package/lib/index.js +2256 -21
  9. package/lib/janitor.js +377 -0
  10. package/lib/proxy.js +1577 -0
  11. package/lib/proxybridge-bundle.js +798 -0
  12. package/lib/redirector.js +2558 -0
  13. package/lib/risd/build.js +91 -0
  14. package/lib/risd/debug.js +374 -0
  15. package/lib/risd/git.js +207 -0
  16. package/lib/risd/leases.js +124 -0
  17. package/lib/risd/lifecycle.js +148 -0
  18. package/lib/risd/log.js +59 -0
  19. package/lib/risd/ping.js +94 -0
  20. package/lib/risd/programs.js +348 -0
  21. package/lib/risd/server.js +1478 -0
  22. package/lib/risd/state.js +137 -0
  23. package/lib/risd/ui.js +1705 -0
  24. package/lib/risd/view.js +79 -0
  25. package/lib/risd-client.js +282 -0
  26. package/lib/standalone/window.html +14 -16
  27. package/lib/startup.js +114 -0
  28. package/package.json +7 -2
  29. package/skills/dsh-ris-ide-debug/SKILL.md +37 -2
  30. package/test/client-build.test.mjs +113 -0
  31. package/test/client-viewer.test.mjs +314 -20
  32. package/test/companion.test.mjs +65 -0
  33. package/test/dsh-origin.test.mjs +140 -0
  34. package/test/dsh-window-refresh.test.mjs +100 -0
  35. package/test/harness.test.mjs +9 -0
  36. package/test/host-noloop.test.mjs +74 -0
  37. package/test/host-tail.test.mjs +54 -5
  38. package/test/host-window.test.mjs +4 -4
  39. package/test/inherit-engine.test.mjs +175 -0
  40. package/test/install-phase.test.mjs +36 -0
  41. package/test/janitor.test.mjs +172 -0
  42. package/test/lifecycle.test.mjs +109 -0
  43. package/test/merge-owners.test.mjs +155 -0
  44. package/test/proxy-restart.test.mjs +37 -0
  45. package/test/proxy-route.test.mjs +599 -0
  46. package/test/proxy-window.test.mjs +45 -0
  47. package/test/proxy.test.mjs +914 -0
  48. package/test/proxybridge-bundle.test.mjs +687 -0
  49. package/test/redirector-bundle.test.mjs +391 -0
  50. package/test/redirector.test.mjs +571 -0
  51. package/test/risd-api.test.mjs +470 -0
  52. package/test/risd-bridge-degrade.test.mjs +101 -0
  53. package/test/risd-build.test.mjs +20 -0
  54. package/test/risd-cli-home.test.mjs +50 -0
  55. package/test/risd-client.test.mjs +130 -0
  56. package/test/risd-debug.test.mjs +261 -0
  57. package/test/risd-election.test.mjs +104 -0
  58. package/test/risd-engine.test.mjs +132 -0
  59. package/test/risd-entry.test.mjs +118 -0
  60. package/test/risd-git.test.mjs +109 -0
  61. package/test/risd-handoff.test.mjs +116 -0
  62. package/test/risd-heal.test.mjs +50 -0
  63. package/test/risd-helpers.mjs +108 -0
  64. package/test/risd-host-p2.test.mjs +147 -0
  65. package/test/risd-janitor-guard.test.mjs +46 -0
  66. package/test/risd-lease.test.mjs +83 -0
  67. package/test/risd-lifecycle.test.mjs +210 -0
  68. package/test/risd-log-follow.test.mjs +227 -0
  69. package/test/risd-mode.test.mjs +161 -0
  70. package/test/risd-ping.test.mjs +99 -0
  71. package/test/risd-programs.test.mjs +169 -0
  72. package/test/risd-review-p2.test.mjs +217 -0
  73. package/test/risd-shutdown.test.mjs +97 -0
  74. package/test/risd-teardown.test.mjs +87 -0
  75. package/test/risd-tools.test.mjs +211 -0
  76. package/test/risd-ui.test.mjs +445 -0
  77. package/test/risd-write.test.mjs +170 -0
  78. package/test/startup-reconcile.test.mjs +100 -0
  79. package/test/windows.test.mjs +37 -2
package/README.md CHANGED
@@ -17,11 +17,11 @@ DSH(DeepSeek Harness)Web GUI 右侧栏里的 **RIS-IDE 本地开发面板**
17
17
 
18
18
  | 侧栏「RIS控制台」:控制台 + 实时日志|
19
19
  |---|
20
- | ![侧栏「RIS控制台」](https://gitee.com/riscloud/dsh-ris-ide/raw/master/docs/screenshots/ris-console.png) |
20
+ | ![侧栏「RIS控制台」](https://raw.githubusercontent.com/ris-cloud/dsh-ris-ide/master/docs/screenshots/ris-console.png) |
21
21
 
22
- | 独立窗口(打开即最大化、无会话历史;控制台标题栏有 📄/⚙)|
22
+ | 独立窗口(普通浏览器窗口、无会话历史;控制台标题栏有 📄/⚙)|
23
23
  |---|
24
- | ![独立窗口](https://gitee.com/riscloud/dsh-ris-ide/raw/master/docs/screenshots/ris-ide-window.png) |
24
+ | ![独立窗口](https://raw.githubusercontent.com/ris-cloud/dsh-ris-ide/master/docs/screenshots/ris-ide-window.png) |
25
25
 
26
26
  ## 功能
27
27
 
@@ -33,14 +33,53 @@ DSH(DeepSeek Harness)Web GUI 右侧栏里的 **RIS-IDE 本地开发面板**
33
33
  - **预览**:`.md/.markdown/.html/.htm` 编辑/预览切换按钮**悬浮在编辑区右上角**(不占代码行高,预览含未保存修改);超过整读上限的大文本以**只读分页预览**打开(滚到近底取下一页、内存超限释放前文、滚动位置按文件记住),标题栏「编辑」可强制全量加载进编辑(上限 32MB)。
34
34
  - **JDWP 调试(仅 Java)**:点行号加断点、双击红点删除(空行/注释行忽略);断点/线程/调用栈/变量/单步/继续;对象与数组懒加载展开、继承字段与空值也列出;依赖 jar 自动取 `-sources.jar`,没有则 `javap` 反汇编,也可在调试面板 ⚙ 填反编译 jar(如 CFR),缓存按 jar 指纹失效并有 64MB/30 天上限回收;命中后自动切「参数」页签、打开源码并高亮当前行;前端程序只能启停/看日志。
35
35
  - **独立窗口**:聊天页右上角 **⧉ RIS-IDE**(或控制台标题栏 ⧉)打开,**填满屏幕**、**不加载 DSH 界面/不带会话历史**,与侧栏同一套 `/dsh-ris-ide/*` 路由与 cookie,没有新端口;窗口按**工作空间**单例,从程序目录调试也不会开出第二个。
36
+ - **代理**:规则表是全机一份文件(`~/.dsh-ris-ide/proxy.json`),所以入口是 CLI/工具与 **risd 维护页**——`node <dsh-ris-ide>/lib/proxy.js rules` 看表、`… start` / `… stop` 管引擎,`yds proxy sync` 从 confcenter 自动生成该项目的规则(DB/Redis/gitlab/回调网段)。**插件面板不再内置代理配置界面**(1.8.0 起,D4):risd 维护页的「代理设置」页签(`http://127.0.0.1:11082/ui?tab=proxy`)不依赖 dsh,直接编辑全机规则表。系统层拦截需要的 **ProxyBridge 组件改为首次使用时下载**(不再随包内置 2.9 MB 二进制):risd 维护页「代理 → 组件」一点即下——内置 **Gitee 主地址、GitHub 备用**两个镜像(同一份发版附件,前一个失败自动换下一个),也可上传 `ris-proxy.4.0.tgz`,或设 `DSH_RIS_IDE_PROXYBRIDGE_URL` / `settings.json` 的 `proxybridgeUrl` 走内网镜像;装进 `~/.dsh-ris-ide/proxybridge/bundle/` 后复用,安装完成后面板只显示「已安装」。下载失败时面板给出两个下载地址与手动上传入口。许可文本(MIT + WinDivert LGPL-3.0)随包安装。组件包按**固定 sha256** 校验(下载与上传都验内容;`DSH_RIS_IDE_PROXYBRIDGE_SHA256` 或 `settings.json` 的 `proxybridgeSha256` 可覆盖,置空=首次信任;重发附件改了内容要同步更新常量并发版);已安装后在面板里可「重新下载」(强制刷新缓存副本)。未安装时会明确提示入口而不是静默失败;机器上已装的 ProxyBridge / `DSH_RIS_IDE_PROXYBRIDGE` 仍是回退。WSL 下先把 Windows 版复制到 `%LOCALAPPDATA%\dsh-ris-ide\proxybridge\windows` 再启动。**一个 启动/停止 管全部三层**——本地引擎(给本插件 spawn 的程序注入代理)、系统层拦截(ProxyBridge 按进程名在系统层改路,覆盖 Navicat、IDE 里的 java、终端 git)、git 配置(`git config --global http.https://<host>/.proxy = socks5h://…`,写完终端里的 `git` 与 dsh-git 都走隧道);`dsh` 退出时三层一起停,不留残留。**全机一份规则表**(`~/.dsh-ris-ide/proxy.json`,`DSH_RIS_IDE_PROXY_HOME` 可改位置),整机生效、不区分工作区与会话,行尾「来源」列只记是用户行还是 yds 注入(`yds·win` / `yds·wsl` 还会标出命中的一侧)。提权是正常流程:Windows 侧启动时弹 UAC,Linux 侧需要免密 sudo;提不到权时弹窗里给出可直接粘贴的命令。Windows 侧启动还有三个实测过的细节:GUI 安装的服务 `ProxyBridgeSvc` 与 CLI 互斥(都抢 WinDivert 句柄),所以先停服务再起 CLI(停过会记下来,停止时尝试恢复);手起或遗留的 `ProxyBridge_CLI.exe` 先结束再接管;CLI 没有日志开关,stdout 重定向到 `%TEMP%\dsh-ris-proxybridge.log`,起不来时日志尾部就是错误原因。两层兜底:ProxyBridge 没在跑时,支持代理的程序(java / git / node / curl)启动时注入**本机 CONNECT 代理** `http://127.0.0.1:11081`(`ALL_PROXY`/`HTTP(S)_PROXY` + JVM 的 `-Dhttp(s).proxyHost/Port`),每一条连接仍然要过规则里的 IP/端口白名单——注入不再等于「把上游 SOCKS 地址直接发给程序」。想让某个程序完全绕过白名单、直连上游 SOCKS,就在该行加 `"direct": true`(`proxy.json` 里的行级开关,界面暂无控件);不支持代理的客户端(Navicat / JDBC)自动映射 `127.0.0.1:同端口`——这些映射行是实现细节,不进界面。维护页「代理设置」页签上部填上游 SOCKS(host/port)与本地 CONNECT 端口,下部是规则表:`启用 · 程序 · IP 允许(1.1.1.* / 逗号)· 端口允许(1521 / 1000-1010,* 表示不限)· 状态 · 命中方式`。**全机一张表、改动直接覆盖**:没有「读取 / 保存」按钮,也没有按工作区区分——改动 700 ms 后自动校验并写表(缺程序/IP/端口或端口格式不对只提示、不写),写进去的就是整张表,未出现的行会被删掉(这也意味着 `yds stop` 能靠「不发那些行」把注入的规则撤干净);写盘后先停旧的系统层拦截再按新表重启,换拦截的两轮探测在后台跑,页面不会被它卡住。「状态」列直接回答这行现在生效没(未启用 / 缺… / 端口格式 / 待启动 / 生效)。引擎与拦截只用一个按钮管:运行中显示「停止」,停止后变「启动」(未运行/运行中的另一状态不再另设按钮);点下去到生效之间按钮显示「启动中…」/「停止中…」并暂时不可点(等提权或引擎拉起),不会看起来像没反应。`yds proxy sync` 注入的规则在 **Windows 与 WSL 两侧各一行**(`java.exe` / `java`、`git.exe` / `git`,「来源」列标 `yds·win` / `yds·wsl`)——ProxyBridge 按镜像名匹配,`java.exe` 匹配不到 WSL 里的 `java`,以前这里只注入 Windows 侧。ProxyBridge 组件安装好之后卡片只显示「已安装 · 文件 N 个」,不再给下载/上传按钮。程序列两种来源——**运行中的进程**(本侧 + Windows 侧,只列支持 SOCKS 的)或**固定程序**(文件浏览器选可执行文件,可在启动前配好;裸名按镜像名匹配,含路径则精确到那个可执行文件)。
37
+
38
+ - 弹窗**没有保存按钮**:改动在停手 700ms 后自动写盘;写的时候会过一遍校验——**新建但没填完整**的行不写入(底栏提示「N 条未填完整,未写入」),**已经在文件里**的行如果被改到一半,会连同新内容写成「停用」(提示「N 条改到一半,已置为停用」),不会留下旧内容假装生效,也不会让半截规则生效。写完本机引擎立刻生效、系统层拦截静默重启;「+ 添加规则」只追加一个空行,不会弹选择器盖住表格。
39
+ - 「选…」打开的两页签选择器:**运行中的程序**(本侧 + Windows 侧进程,只列支持 SOCKS 的)、**选择文件**;文件页签下面是**树**——点文件夹原地展开(只读被展开的那一层),点文件即选中,不再一级一级「进入目录」;顶层入口只有**根路径 `/`** 与 **Windows C:/D:**(WSL 下 `/mnt` 就是 Windows 盘,所以只有一个文件页签;在那里选中的路径会写成 `D:\…`);**没有子项的文件夹**渲染成叶子(`·`、灰一点、点不动),不会出现按下去没反应的空展开。
40
+ - 初始只给 **java / git** 两行模板(node、curl 不再自动生成;要用就自己加一行)。
41
+
42
+ **规则什么时候真的生效**:一行必须同时满足 ①已启用 ②填了程序 ③填了 IP ④填了端口——四样都显式写出才算数,要「全匹配」就写 `*`(空白**不等于**全部,半成品行在表里会用红字标「不生效:缺 IP/缺端口」,也不会进 ProxyBridge profile 和本机允许列表)。
43
+
44
+ **这些路由的信任边界**:全部只应答 loopback 请求,`sessionId` 的作用是选工作区(日志/启动目录),**不是权限凭据**——能连本机 3080 的进程就能改这台机器的规则表(与 `ris_dev_*` 系列同一模型)。若以后要收紧,正确做法是把「会话登记过的 cwd」做成白名单,而不是相信客户端传来的 `sessionId`。
45
+ **改规则不用重启**:本机引擎(`127.0.0.1` 映射 / CONNECT 允许列表)监听 `proxy.json`,保存后原地换规则、不重启进程;系统层拦截(ProxyBridge)只在启动时读 profile,由已提权的看门狗静默重启它(约 2s、不弹 UAC、不动其它程序)。
36
46
  - **给 agent 用**:内置 `ris_dev_*` 工具(列程序/状态/启动/重启/停止/读日志/调试/安装 skill),与面板共用同一套宿主命令。
37
47
  - **跨平台**:Linux/macOS 用 bash 包装;Windows 自动选 Git Bash 或原生 PowerShell 包装,停止用 `taskkill /T` 杀整棵进程树。
38
48
 
49
+ ## 相关插件:dsh-ris-yds(可选)
50
+
51
+ 如果在做 **YonBIP / YMS** 相关开发,[`dsh-ris-yds`](https://gitee.com/riscloud/dsh-ris-yds) 与本插件互补,
52
+ 提供这些辅助开发能力:
53
+
54
+ - 在本地运行 YMS 运行时,不必连远端环境;
55
+ - 访问内网数据库、缓存与内网服务;
56
+ - 准备本地开发配置,并可在「代理 / 直连」两种方式之间切换;
57
+ - 生成调用平台 API 的凭据,辅助前端调试。
58
+
59
+ - 两个插件**互不依赖**:各自都能单独安装、单独工作;装在一起时不会重复启动隧道。
60
+ - 工作区出现 YMS/YonBIP 工程特征时,`ris_dev_programs` 的返回里会附一句安装建议——只是推荐,不会调用它。
61
+
62
+ ## 可选:risd 代理 daemon
63
+
64
+ 代理引擎默认仍由插件进程托管(`Ctrl+C` 会一并停掉,与之前一致)。如果你希望代理生命周期不再绑在某个 dsh 窗口上(多开时关一个不影响其他人、窗口全部关闭后仍可按策略保留),可以打开 `daemonMode`:
65
+
66
+ - **默认开启**(`daemonMode=auto`,1.8.0 起;`daemonMode=off` 或 `DSH_RISD_MODE=off` 是一词回滚)。插件挂载时会确保 `risd` 在跑(`127.0.0.1:11082`,随机 token,状态在 `~/.dsh-ris-ide/risd.json`),并登记一个租约(owner pid + 心跳,3s 探活)。
67
+ - daemon 接管**引擎**:启动/停止代理、写规则、git 代理、系统层拦截的 reload 都经它串行执行;插件只负责转发。最后一个租约消失后,daemon 按 `session` 策略依次撤销 git → 拦截 → 引擎;随后空闲 10 分钟自动退出,下次需要时再被拉起。
68
+ - daemon 还负责写桥接心跳(不再由 dsh 进程写)并独占 janitor;升级 daemon 时用 `POST /v1/shutdown {handoff:true}` 交接,新 daemon 直接收养既有引擎(pid 不变,隧道不断)。
69
+ - daemon 还托管**程序与 JDWP**:`ris_dev_programs/start/stop/logs/debug` 在 `daemonMode=auto` 时优先问 daemon(失败自动回退本地,`ris_dev_status` 仍读本地 pidfile/日志),所以刷新页面不会丢调试会话;dsh 全部关掉后打开 `http://127.0.0.1:11082/ui` 就能启停程序、看日志、断开调试会话、重启桥接。维护页顶部居中三个页签(顺序 **开发环境 · 代理设置 · 概览**;刷新或快捷键重载后回到上次的页签与工作区,dsh 的 ⧉ 只切换工作区、不抢你正在用的页签):**概览**(守护进程状态、代理运行状态、按工作区分组的运行中程序、调试中的进程,都可停止)、**代理设置**(不依赖 dsh 的**全局**规则编辑器:规则按机器生效、不区分工作区;SOCKS/监听端口/规则行增删改**即自动保存**——700 ms 防抖 + 行校验,完整后自动启动引擎,CAS 冲突静默换 revision 重写一次;「重启系统层拦截」只在确实需要(重载失败/需要提权)时出现,鼠标悬停会说明原因)、**开发环境**(整页无留白地嵌入 dsh 的 IDE;左侧是**默认收起**的工作区面板,点 header 左侧的 `‹`/`›` 展开或收起并记住选择;按目录名显示、列表来自正在运行的 dsh,点击即切换;5 分钟没动静的工作区标「未活跃」但仍可点,选中时上方提示该窗口可能已关闭;在 iframe 外任意处点击都会把光标送回 IDE;dsh 不在时该页签自动置灰并显示原因)。
70
+ - **改完不用强刷**:插件把当前 client bundle 的指纹随 SSE `hello` 下发(另有 `GET /dsh-ris-ide/build`),并每 30s 复查一次;发现代码变了只在右下角提示「IDE 界面已更新:刷新页面后生效」(**不自动 reload,避免丢掉未保存的编辑与会话视图**,点提示再刷新)。维护页 `/ui` 同理:daemon 重启成新代码、或源码比进程新、或 token 因 daemon 重启失效,都在顶部显示横幅;**「插件版本已更新」这条点按钮就是「重启并刷新」**——daemon 先交接重启(保留正在跑的代理引擎/桥接),新进程起来后本页自动重新加载,不用自己去命令行重启。**开发环境里有未保存文件时横幅会多一个「保存所有文件」按钮**——点它先把内嵌 IDE 的脏 buffer 全部保存再整页刷新(不会悄悄丢掉编辑);没有未保存内容时直接自动刷新,刷新后回到原来的页签与工作区。代理规则未保存时也会先确认。Node 在启动时 import 的模块不会再读盘,这不是浏览器缓存,强刷也没用。
71
+ - **保存即换新**:保存规则时先把上一份表应用过的机器级副作用收回(git 条目按新表切 host 或清掉;系统层拦截若重载失败就直接停止,而不是留着旧规则继续拦截),再应用新表。若提示「旧规则可能仍在生效 / 需要提权」,提示旁有 **提权重启** 按钮:点一下即「停止 → 重载 → 启动」(Windows 弹一次 UAC;本侧 root 桥接需要 sudo,命令会显示在提示里)。
72
+ - daemon 不可达时视图与会话内动作自动回退到插件本地执行,维护页打不开时可以用 CLI;**`daemonMode=off` 即完全回到旧行为**,此时点 ⧉ 不会拉起 daemon(两个 owner 会抢同一个引擎与 janitor),而是直接打开独立 IDE 窗口。
73
+ - **入口**:dsh 顶部 ⧉ 和面板控制台的 ⧉ 都打开 **risd 维护页**(面板里不再有代理按钮:规则编辑只在这个页面),并且自动选中当前工作区(页签保持你上次的选择);**daemon 已停止或意外退出时,点 ⧉ 会先自动把它拉起**(点一次即可,失败才回退到独立窗口)。维护页「概览 → 守护进程」一行可看状态并停止 daemon;停止会同时停掉它托管的程序、调试会话和代理,页面会先弹确认列出将停止的内容。**概览底部还有「生命周期」设置**:守护进程 / 代理引擎 / 程序 / 调试会话各自可以选择是否「跟随 dsh」(最后一个 dsh 窗口退出后停)。**「跟随 daemon」是强制的**:停止 daemon 时它托管的程序、调试会话与代理一定一起停,不提供关闭项。默认是代理跟随 dsh、程序与调试不跟随 dsh,配置存在 `~/.dsh-ris-ide/risd-lifecycle.json`,保存即生效、不用重启。
74
+ - 手动体验(`risd` 命令由本包的 `bin` 暴露;`npm link` 或把 `bin/risd.mjs` 软链进 PATH 即可):`risd serve`、`risd status`、`risd health`、`risd stop`、`risd version`;日志 `~/.dsh-ris-ide/risd.log`。
75
+
76
+ 已知边界:本侧(WSL/Linux root 起的)系统层拦截仍不支持热重载(要重启);规则表的 `shadow` 端口没有内置默认值,全部来自配置与 dsh-ris-yds 的写入。
77
+
39
78
  ## 安装
40
79
 
41
80
  需要 DSH `>= 0.2.0-rc.2`,且 Web GUI 带官方右侧栏服务(`sidebarRight` / `sidebarRightTabs` / `slots`)。
42
81
 
43
- **本插件自身不依赖任何外部资源**:零运行时 npm 依赖、客户端产物(含 CodeMirror)已随包发布、不联网、不起独立端口,只使用 DSH 自带路由与 Node 内置模块。本机工具只在特定能力上需要:`git`(有则按 gitignore 过滤文件树/搜索;**没有 git 也能用**,退化为不过滤)、JDK `java`/`javap`(启动/调试 Java 程序、反汇编依赖类)、Maven(默认起 Spring 服务时会 `mvn compile`,本地仓库没缓存时会联网下载依赖)、Node/前端包管理器(启动前端 dev server)。
82
+ **本插件自身不依赖任何外部资源**:零运行时 npm 依赖、客户端产物(含 CodeMirror)已随包发布、不起独立端口,只使用 DSH 自带路由与 Node 内置模块。唯一的联网动作是用户在维护页触发的 **ProxyBridge 组件下载**(系统层拦截首次启用时;可换成内网/本地上传源),除此之外不联网。本机工具只在特定能力上需要:`git`(有则按 gitignore 过滤文件树/搜索;**没有 git 也能用**,退化为不过滤)、JDK `java`/`javap`(启动/调试 Java 程序、反汇编依赖类)、Maven(默认起 Spring 服务时会 `mvn compile`,本地仓库没缓存时会联网下载依赖)、Node/前端包管理器(启动前端 dev server)。
44
83
 
45
84
  发布到 npmjs 后:
46
85
 
@@ -0,0 +1,247 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * 上架自检:把 dsh-market(awesome-dsh-plugin 目录)与 dsh.so 的收录条件,变成能在本地跑的检查。
4
+ *
5
+ * npm run check:listing
6
+ * npm run check:listing -- --json
7
+ * npm run check:listing -- --strict # 警告也算失败
8
+ * npm run check:listing -- --net # 额外尝试联网确认仓库/包公开可达(内网环境会失败)
9
+ *
10
+ * 规则来源与逐条解释在**仓库外**的插件开发手册(`docs/dsh-plugin-listing-guide.md`)。这里是**静态**检查:license 选哪个、仓库要不要公开、
11
+ * npm 包名怎么定,这些决定项脚本只能标记出来,得人定。
12
+ */
13
+ import { readFile, readdir, stat } from 'node:fs/promises'
14
+ import { existsSync } from 'node:fs'
15
+ import { join, dirname, extname, relative } from 'node:path'
16
+ import { fileURLToPath } from 'node:url'
17
+
18
+ const ROOT = join(dirname(fileURLToPath(import.meta.url)), '..')
19
+ const argv = process.argv.slice(2)
20
+ const AS_JSON = argv.includes('--json')
21
+ const STRICT = argv.includes('--strict')
22
+ const NET = argv.includes('--net')
23
+
24
+ const results = []
25
+ const ok = (id, detail) => results.push({ id, level: 'ok', detail })
26
+ const warn = (id, detail) => results.push({ id, level: 'warn', detail })
27
+ const fail = (id, detail) => results.push({ id, level: 'error', detail })
28
+
29
+ async function readJson(rel) {
30
+ return JSON.parse(await readFile(join(ROOT, rel), 'utf8'))
31
+ }
32
+
33
+ async function readText(rel) {
34
+ try {
35
+ return await readFile(join(ROOT, rel), 'utf8')
36
+ } catch {
37
+ return null
38
+ }
39
+ }
40
+
41
+ /** 递归列出目录下的文件(跳过 node_modules / .git / 构建产物) */
42
+ async function listFiles(dir, acc = []) {
43
+ let entries
44
+ try {
45
+ entries = await readdir(join(ROOT, dir), { withFileTypes: true })
46
+ } catch {
47
+ return acc
48
+ }
49
+ for (const entry of entries) {
50
+ if (entry.name === 'node_modules' || entry.name === '.git' || entry.name === 'dist') continue
51
+ const rel = dir === '.' ? entry.name : `${dir}/${entry.name}`
52
+ if (entry.isDirectory()) {
53
+ await listFiles(rel, acc)
54
+ } else {
55
+ acc.push(rel)
56
+ }
57
+ }
58
+ return acc
59
+ }
60
+
61
+ const SRC_EXT = new Set(['.js', '.mjs', '.cjs', '.ts', '.tsx', '.jsx', '.sh', '.ps1', '.vue'])
62
+ const PUBLIC_HOSTS = ['github.com', 'gitee.com', 'gitlab.com']
63
+
64
+ function short(text, max = 120) {
65
+ const line = String(text).replace(/\s+/g, ' ').trim()
66
+ return line.length > max ? `${line.slice(0, max - 1)}…` : line
67
+ }
68
+
69
+ async function main() {
70
+ const pkg = await readJson('package.json')
71
+ const readme = await readText('README.md')
72
+
73
+ // ── dsh.so:插件 id(slug) ───────────────────────────────────────────────
74
+ const bareName = String(pkg.name || '').replace(/^@[^/]+\//, '')
75
+ if (/^[a-z0-9]+(-[a-z0-9]+)*$/.test(bareName)) ok('插件 id(slug)', `"${pkg.name}" → ${bareName} 匹配 ^[a-z0-9]+(-[a-z0-9]+)*$`)
76
+ else fail('插件 id(slug)', `"${pkg.name}" 不匹配 ^[a-z0-9]+(-[a-z0-9]+)*$:改成小写 kebab-case(scoped 包只校验 scope 后的段)`)
77
+
78
+ // ── 版本:市场展示的是最新正式版 ─────────────────────────────────────────
79
+ if (/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(String(pkg.version || ''))) {
80
+ if (String(pkg.version).includes('-')) warn('版本号', `${pkg.version} 是预发布版;市场/dsh.so 展示 latest 语义时应发布 X.Y.Z 正式版(快照只用于本地)`)
81
+ else ok('版本号', `${pkg.version}(合法 semver,正式版)`)
82
+ } else {
83
+ fail('版本号', `"${pkg.version}" 不是合法 semver`)
84
+ }
85
+
86
+ // ── dsh.so:DSH 兼容信号(至少一个) ─────────────────────────────────────
87
+ const signals = []
88
+ if (pkg.dsh && typeof pkg.dsh === 'object') signals.push('package.json 的 dsh 字段')
89
+ if (pkg.dsh?.bundle?.patch) signals.push(`dsh.bundle.patch = ${pkg.dsh.bundle.patch}`)
90
+ if (pkg.dsh?.plugin) signals.push('dsh.plugin.* manifest')
91
+ if (pkg.engines?.dsh) signals.push(`engines.dsh = ${pkg.engines.dsh}`)
92
+ if (existsSync(join(ROOT, 'cordis.patch.yml'))) signals.push('cordis.patch.yml')
93
+ if (existsSync(join(ROOT, 'agent.cordis.yml'))) signals.push('agent.cordis manifest')
94
+ if (signals.length) ok('DSH 兼容信号', signals.join(';'))
95
+ else fail('DSH 兼容信号', '缺少全部信号(dsh 字段 / cordis manifest / dsh-plugin topic)')
96
+
97
+ // ── dsh.so:README 含安装说明 ────────────────────────────────────────────
98
+ if (!readme) fail('README 安装说明', '没有 README.md')
99
+ else {
100
+ const installLines = readme
101
+ .split('\n')
102
+ .filter((line) => /dsh plugin --profile \S+ add /.test(line))
103
+ // 「公开」口径:这条安装命令不依赖内网 registry,市场用户照抄就能装
104
+ const publicLine = installLines.find(
105
+ (line) => !/registry=|\.npmrc|repository\/npm-/.test(line) && !/@\d/.test(line),
106
+ )
107
+ if (installLines.length === 0) {
108
+ fail('README 安装说明', 'README 里找不到 `dsh plugin --profile <p> add …`')
109
+ } else if (publicLine) {
110
+ ok('README 安装说明', `含公开可直接抄的安装命令:${short(publicLine, 80)}${installLines.length > 1 ? `(另有 ${installLines.length - 1} 条内网/带版本号的备选)` : ''}`)
111
+ } else {
112
+ warn('README 安装说明', '安装命令都指向内部 registry 或写死了版本号;公开上架需要一条不依赖内网、不写死版本的 `dsh plugin --profile web add <包名>`')
113
+ }
114
+ }
115
+
116
+ // ── dsh.so:开源 license + SPDX ─────────────────────────────────────────
117
+ const licenseFiles = (await listFiles('.')).filter((f) => /^LICEN[CS]E(\..*)?$/i.test(f))
118
+ const spdx = typeof pkg.license === 'string' ? pkg.license.trim() : ''
119
+ const spdxOk = /^[A-Za-z0-9.+-]+$/.test(spdx) && !/^(UNLICENSED|SEE LICENSE IN .*|PROPRIETARY)$/i.test(spdx)
120
+ if (spdxOk && licenseFiles.length) ok('License(SPDX)', `${spdx},文件:${licenseFiles.join(', ')}`)
121
+ else if (!spdx && !licenseFiles.length) fail('License(SPDX)', '既没有 package.json 的 license 字段,也没有 LICENSE 文件;dsh.so 要求开源许可证 + 可识别 SPDX(UNLICENSED 不算)')
122
+ else if (!spdx) fail('License(SPDX)', `有 ${licenseFiles.join(', ')} 但 package.json 缺 license 字段(要写 SPDX id)`)
123
+ else fail('License(SPDX)', `license 字段是 "${spdx}",不是可识别的 SPDX 开源标识`)
124
+
125
+ // ── dsh.so:可扫描源码 ───────────────────────────────────────────────────
126
+ const sourceFiles = (await listFiles('.')).filter((f) => SRC_EXT.has(extname(f).toLowerCase()))
127
+ if (sourceFiles.length >= 3) ok('可扫描源码', `${sourceFiles.length} 个源码/脚本文件(如 ${sourceFiles.slice(0, 3).join(', ')}…)`)
128
+ else fail('可扫描源码', `只找到 ${sourceFiles.length} 个可扫描文件;docs-only / 空仓库不能提交`)
129
+
130
+ // ── dsh-market:安装来源(npm 包名) ─────────────────────────────────────
131
+ if (typeof pkg.name === 'string' && pkg.name) ok('npm 包名(目录 install 字段)', `${pkg.name}(目录里 npm/version 取自公开 registry)`)
132
+ else fail('npm 包名', 'package.json 缺 name')
133
+
134
+ // ── dsh.so:仓库地址(公开托管 + topic) ──────────────────────────────────
135
+ const repoUrl = typeof pkg.repository === 'string' ? pkg.repository : pkg.repository?.url
136
+ if (!repoUrl) {
137
+ fail('公开仓库地址', 'package.json 缺 repository(dsh.so 只收 GitHub / Gitee / GitLab,且用它同步星数/license/最后提交)')
138
+ } else {
139
+ const cleaned = String(repoUrl).replace(/^git\+/, '')
140
+ const host = (cleaned.match(/^https?:\/\/([^/]+)/) || [])[1] || ''
141
+ if (PUBLIC_HOSTS.some((h) => host === h || host.endsWith(`.${h}`))) ok('公开仓库地址', `${cleaned}(${host})`)
142
+ else fail('公开仓库地址', `${cleaned} 的 host 是 "${host || '未知'}";dsh.so 只认 GitHub/Gitee/GitLab`)
143
+ }
144
+ if (pkg.homepage || pkg.bugs?.url) ok('homepage / bugs', short(pkg.homepage || pkg.bugs.url))
145
+ else warn('homepage / bugs', '建议补 homepage / bugs(市场卡片与 issue 入口会用到)')
146
+
147
+ // ── dsh.so:topic(只能人工在仓库上加,本地无法验证) ────────────────────
148
+ const topics = Array.isArray(pkg.keywords) ? pkg.keywords.map((k) => String(k).toLowerCase()) : []
149
+ if (topics.includes('dsh-plugin') || topics.includes('dsh-pack')) ok('keywords 的 dsh-plugin', 'package.json keywords 含 dsh-plugin / dsh-pack')
150
+ else warn('keywords 的 dsh-plugin', 'package.json keywords 缺 dsh-plugin(同时记得在 GitHub 仓库加 topic `dsh-plugin`,dsh.so 靠它自动索引;这条只能人在仓库里加)')
151
+
152
+ // ── dsh-market:双语描述 ─────────────────────────────────────────────────
153
+ const desc = String(pkg.description || '')
154
+ // 目录条目需要 en/zh 两条描述;package.json 只有一个 description,至少要求它能当英文文案用
155
+ //(判定口径:连续 15 个 ASCII 字母/空格/标点,短串像 "Spring Boot" 不算一句英文)
156
+ if (!desc) fail('描述(en + zh)', 'package.json 缺 description')
157
+ else if (/[A-Za-z][A-Za-z ,.'’/()-]{15,}/.test(desc)) ok('描述(en + zh)', `package.json description 含英文句子:${short(desc, 80)}`)
158
+ else warn('描述(en + zh)', `description 只有中文/短英文(${short(desc, 60)});目录条目要自己写 en/zh 两条(市场按 UI 语言显示),建议把英文句也写进 README 首段`)
159
+
160
+ // ── dsh-market:README 截图(只从 GitHub 托管加载) ──────────────────────
161
+ const shots = readme ? (readme.match(/!\[[^\]]*\]\(([^)]+)\)/g) || []).length : 0
162
+ if (shots >= 2) ok('README 截图', `${shots} 张(市场卡片是轮播,仓库托管即可)`)
163
+ else warn('README 截图', `README 只有 ${shots} 张图;市场卡片需要 2–4 张(侧栏控制台 / 独立窗口 / 调试面板),且必须由 GitHub 托管`)
164
+
165
+ // ── 安全扫描启发式(dsh.so 阻断项:硬编码密钥 / 私钥) ───────────────────
166
+ const scanTargets = sourceFiles.filter((f) => !/client-codemirror\.js$/.test(f)).slice(0, 400)
167
+ const secretPatterns = [
168
+ { name: '私钥块', re: /-----BEGIN [A-Z ]*PRIVATE KEY-----/ },
169
+ { name: 'AWS Access Key', re: /\bAKIA[0-9A-Z]{16}\b/ },
170
+ { name: 'GitHub token', re: /\bghp_[A-Za-z0-9]{36}\b/ },
171
+ { name: 'OpenAI 风格 key', re: /\bsk-[A-Za-z0-9]{20,}\b/ },
172
+ { name: '疑似硬编码口令', re: /\b(?:password|passwd|secret|apiKey|api_key)\s*[:=]\s*['"][^'"\s]{6,}['"]/i },
173
+ ]
174
+ const hits = []
175
+ for (const rel of scanTargets) {
176
+ const text = await readText(rel)
177
+ if (!text) continue
178
+ for (const { name, re } of secretPatterns) {
179
+ if (re.test(text)) hits.push(`${rel} → ${name}`)
180
+ }
181
+ }
182
+ if (hits.length) warn('安全扫描(硬编码密钥)', `${hits.length} 处命中,提交前逐条确认是否误报:${hits.slice(0, 5).join(';')}`)
183
+ else ok('安全扫描(硬编码密钥)', `${scanTargets.length} 个文件扫描,无私钥/密钥字面量命中`)
184
+
185
+ // ── 能力声明(本插件一定会带的外围能力,提交时会被人工复核) ──────────────
186
+ ok(
187
+ '能力边界(人工复核项)',
188
+ '插件会:启动/停止进程(含杀进程组)、读写工作区文件、读环境变量、注册 agent 工具。dsh.so 扫描会标出 fs-write/env/process,README 需写清用途与围栏(loopback 校验、pidfile 校验、路径限制)',
189
+ )
190
+
191
+ // ── 可选联网核对 ─────────────────────────────────────────────────────────
192
+ if (NET) {
193
+ await checkNetwork(pkg, repoUrl)
194
+ } else {
195
+ warn('公开可达性(可选)', '跳过联网核对(--net 开启);内网环境通常不可达,可在有外网的机器上跑')
196
+ }
197
+
198
+ report()
199
+ }
200
+
201
+ async function head(url) {
202
+ try {
203
+ const res = await fetch(url, { method: 'HEAD', redirect: 'follow', signal: AbortSignal.timeout(8000) })
204
+ return res.ok || res.status === 405
205
+ } catch {
206
+ return false
207
+ }
208
+ }
209
+
210
+ async function checkNetwork(pkg, repoUrl) {
211
+ const npmUrl = `https://registry.npmjs.org/${encodeURIComponent(pkg.name).replace('%2F', '/')}`
212
+ const npmOk = await head(npmUrl)
213
+ if (npmOk) ok('公开 npm 可达', `${npmUrl} 200`)
214
+ else fail('公开 npm 可达', `${npmUrl} 不可达:需先发布到公开 npm(只发在内部 registry 的包,市场装不到)`)
215
+
216
+ if (repoUrl) {
217
+ const url = String(repoUrl).replace(/^git\+/, '').replace(/\.git$/, '')
218
+ const repoOk = await head(url)
219
+ if (repoOk) ok('公开仓库可达', `${url} 200`)
220
+ else fail('公开仓库可达', `${url} 不可达或需要登录:dsh.so/dsh-market 都要公开可拉取`)
221
+ }
222
+ }
223
+
224
+ function report() {
225
+ const errors = results.filter((r) => r.level === 'error')
226
+ const warns = results.filter((r) => r.level === 'warn')
227
+ const icon = { ok: '✅', warn: '⚠️ ', error: '❌' }
228
+ if (AS_JSON) {
229
+ console.log(JSON.stringify({ ok: errors.length === 0, errors: errors.length, warnings: warns.length, results }, null, 2))
230
+ } else {
231
+ console.log('\n上架条件自检(dsh-market / dsh.so)· 规则见仓库外插件开发手册\n')
232
+ for (const r of results) {
233
+ console.log(`${icon[r.level]} ${r.id}`)
234
+ if (r.detail) console.log(` ${r.detail}`)
235
+ }
236
+ console.log(`\n合计:${results.length} 项 · ❌ ${errors.length} · ⚠️ ${warns.length}`)
237
+ if (errors.length) {
238
+ console.log('\n必须先解决:')
239
+ for (const r of errors) console.log(` ❌ ${r.id} — ${r.detail}`)
240
+ }
241
+ if (!errors.length) console.log(warns.length && !STRICT ? '\n静态条件里没有阻断项;⚠️ 需要人确认。' : '\n全部通过。')
242
+ }
243
+ const failed = errors.length > 0 || (STRICT && warns.length > 0)
244
+ process.exitCode = failed ? 1 : 0
245
+ }
246
+
247
+ await main()
@@ -0,0 +1,183 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Detached proxy janitor.
4
+ *
5
+ * Started by `armJanitor()` with the pid of the dsh process that owns the proxy
6
+ * layers. Polls that pid; when it disappears (graceful exit, crash, `kill -9`,
7
+ * closed terminal) it performs the same cleanup the exit hook does, then exits.
8
+ *
9
+ * Phase 1b P6 adds a handoff window: when the owner exits on purpose to let a
10
+ * successor daemon adopt the engine, its stop writes `handoffAt` into our state
11
+ * file first. In that window "owner died" must not be read as "the machine is
12
+ * free" — we wait for the successor to register itself and keep watching it
13
+ * instead of tearing the network down.
14
+ *
15
+ * Nothing here needs dsh: it runs in its own session, with only the state files
16
+ * (`proxy.pid`, `proxybridge.local.pid` / `proxybridge.windows.pid`,
17
+ * `proxybridge-service.json`, `git-proxy.json`) as input.
18
+ *
19
+ * A test run must never clean the real machine: janitor.js answers "no bridge" for
20
+ * the bridge probe when NODE_TEST_CONTEXT is set, and the layer seams keep the
21
+ * cleanup unit-testable without PowerShell.
22
+ *
23
+ * Usage: proxy-janitor.mjs --owner <pid> [--home <proxy home>] [--poll <ms>]
24
+ */
25
+ import { appendFileSync, mkdirSync, readFileSync } from 'node:fs'
26
+ import { join } from 'node:path'
27
+
28
+ import {
29
+ JANITOR_HANDOFF_GRACE_MS,
30
+ JANITOR_POLL_MS,
31
+ cleanupSideEffects,
32
+ janitorStatePath,
33
+ pendingSideEffects,
34
+ removeOwnJanitorState,
35
+ } from '../lib/janitor.js'
36
+
37
+ /** Parse `--flag value` pairs without pulling in a dependency. */
38
+ function parse(argv) {
39
+ const out = {}
40
+ for (let i = 0; i < argv.length; i += 1) {
41
+ const token = argv[i]
42
+ if (token.startsWith('--')) {
43
+ out[token.slice(2)] = argv[i + 1]
44
+ i += 1
45
+ }
46
+ }
47
+ return out
48
+ }
49
+
50
+ const args = parse(process.argv.slice(2))
51
+ const owner = Number.parseInt(args.owner ?? '', 10)
52
+ const poll = Number.parseInt(args.poll ?? '', 10) || JANITOR_POLL_MS
53
+ const home = args.home ?? process.env.DSH_RIS_IDE_PROXY_HOME ?? '.'
54
+ const logPath = join(home, 'janitor.log')
55
+
56
+ function log(line) {
57
+ try {
58
+ mkdirSync(home, { recursive: true })
59
+ appendFileSync(logPath, `${new Date().toISOString()} [${process.pid}] ${line}\n`)
60
+ } catch {
61
+ /* logging must never take the janitor down */
62
+ }
63
+ }
64
+
65
+ if (!Number.isInteger(owner) || owner <= 0) {
66
+ log('缺少 --owner <pid>,退出')
67
+ process.exit(2)
68
+ }
69
+
70
+ function alive(pid) {
71
+ try {
72
+ process.kill(pid, 0)
73
+ return true
74
+ } catch (error) {
75
+ return error?.code === 'EPERM'
76
+ }
77
+ }
78
+
79
+ /**
80
+ * Is the owner's exit an intentional handoff? The predecessor writes `handoffAt`
81
+ * before exiting; only a fresh stamp counts, so a stale one cannot keep the
82
+ * machine from being cleaned up forever.
83
+ * @returns {number|null} absolute deadline, null when this is not a handoff.
84
+ */
85
+ function handoffDeadline() {
86
+ try {
87
+ const raw = JSON.parse(readFileSync(janitorStatePath(), 'utf8'))
88
+ const at = typeof raw.handoffAt === 'string' ? Date.parse(raw.handoffAt) : Number.NaN
89
+ if (!Number.isFinite(at)) return null
90
+ const age = Date.now() - at
91
+ if (age < 0 || age >= JANITOR_HANDOFF_GRACE_MS) return null
92
+ return at + JANITOR_HANDOFF_GRACE_MS
93
+ } catch {
94
+ return null
95
+ }
96
+ }
97
+
98
+ /**
99
+ * Wait for the successor's own registration, then report both pids: `owner` is the
100
+ * dsh/risd process to watch next, `watcher` is the successor's own janitor.
101
+ *
102
+ * The field is `owner` — `armJanitor()` writes `{pid, owner, log}`. Reading
103
+ * `ownerPid` (review B-P1-5) always produced NaN, so the handoff window expired
104
+ * and this watcher tore down the engine the successor had just adopted.
105
+ * @returns {Promise<{owner:number, watcher:number}|null>} pids, or null on timeout.
106
+ */
107
+ function adoptSuccessor(previousOwner, deadline) {
108
+ return new Promise((resolve) => {
109
+ const tick = () => {
110
+ if (Date.now() > deadline) {
111
+ resolve(null)
112
+ return
113
+ }
114
+ try {
115
+ const raw = JSON.parse(readFileSync(janitorStatePath(), 'utf8'))
116
+ const candidate = Number.isInteger(raw.owner) ? raw.owner : Number(raw.ownerPid)
117
+ const watcher = Number.isInteger(raw.pid) ? raw.pid : 0
118
+ if (Number.isInteger(candidate) && candidate > 0 && candidate !== previousOwner && alive(candidate)) {
119
+ resolve({ owner: candidate, watcher })
120
+ return
121
+ }
122
+ } catch {
123
+ /* the state file may be mid-rewrite; keep waiting */
124
+ }
125
+ setTimeout(tick, 250)
126
+ }
127
+ tick()
128
+ })
129
+ }
130
+
131
+ let watched = owner
132
+
133
+ function cleanup() {
134
+ const pending = pendingSideEffects()
135
+ log(`dsh ${watched} 已退出,开始清理: ${JSON.stringify(pending)}`)
136
+ try {
137
+ const done = cleanupSideEffects({ log })
138
+ log(`清理完成: ${JSON.stringify({ engine: done.engine, bridge: done.bridge, service: done.service, git: done.git })}`)
139
+ } catch (error) {
140
+ log(`清理异常: ${error?.message ?? error}`)
141
+ }
142
+ try {
143
+ // Our own state file is the last thing to go: while it exists, `yds proxy
144
+ // status` reports a watcher, and a fresh start re-arms instead of doubling.
145
+ // Only ours, though: a successor may already have armed a newer watcher and
146
+ // written its own state file by now (review B-P2-9).
147
+ removeOwnJanitorState(process.pid)
148
+ } catch {
149
+ /* already gone */
150
+ }
151
+ process.exit(0)
152
+ }
153
+
154
+ function startWatch() {
155
+ log(`监视 dsh ${watched}(轮询 ${poll}ms,状态 ${janitorStatePath()})`)
156
+ // The interval must stay referenced: an unreferenced timer lets node exit
157
+ // immediately, which is the opposite of a watchdog.
158
+ const timer = setInterval(async () => {
159
+ if (alive(watched)) return
160
+ clearInterval(timer)
161
+ const deadline = handoffDeadline()
162
+ if (deadline !== null) {
163
+ log(`dsh ${watched} 已退出,处于交接窗口(剩余 ${Math.max(0, deadline - Date.now())}ms),等待继任者`)
164
+ const successor = await adoptSuccessor(watched, deadline)
165
+ if (successor !== null) {
166
+ // The successor armed its own watcher (it wrote the state file we just
167
+ // read): hand over and exit, so repeated handoffs do not accumulate
168
+ // watchers. If it failed to arm, keep watching on its behalf.
169
+ if (successor.watcher > 0 && successor.watcher !== process.pid && alive(successor.watcher)) {
170
+ log(`继任者 ${successor.owner} 已接管(其 janitor pid ${successor.watcher}),本守护退出`)
171
+ process.exit(0)
172
+ }
173
+ watched = successor.owner
174
+ startWatch()
175
+ return
176
+ }
177
+ log('交接窗口内没有继任者,按原逻辑清理')
178
+ }
179
+ cleanup()
180
+ })
181
+ }
182
+
183
+ startWatch()