omnicell-router 0.1.0 → 0.2.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 (212) hide show
  1. package/RELEASING.md +238 -238
  2. package/RELEASING.zh-CN.md +230 -230
  3. package/backend/dist/capture/recorder.js +2 -1
  4. package/backend/dist/cli/clients/base.js +8 -16
  5. package/backend/dist/cli/clients/dsh.js +8 -16
  6. package/backend/dist/cli/clients/pi.js +16 -9
  7. package/backend/dist/cli/types.d.ts +5 -0
  8. package/backend/dist/config/env.js +2 -1
  9. package/backend/dist/config/index.js +2 -0
  10. package/backend/dist/config/types.d.ts +23 -0
  11. package/backend/dist/harness/adapters/amp.d.ts +2 -0
  12. package/backend/dist/harness/adapters/amp.js +7 -0
  13. package/backend/dist/harness/adapters/claude.d.ts +2 -0
  14. package/backend/dist/harness/adapters/claude.js +7 -0
  15. package/backend/dist/harness/adapters/cline.d.ts +2 -0
  16. package/backend/dist/harness/adapters/cline.js +6 -0
  17. package/backend/dist/harness/adapters/codex.d.ts +2 -0
  18. package/backend/dist/harness/adapters/codex.js +6 -0
  19. package/backend/dist/harness/adapters/cursor.d.ts +5 -0
  20. package/backend/dist/harness/adapters/cursor.js +10 -0
  21. package/backend/dist/harness/adapters/declarative.d.ts +62 -0
  22. package/backend/dist/harness/adapters/declarative.js +202 -0
  23. package/backend/dist/harness/adapters/dsh.d.ts +5 -0
  24. package/backend/dist/harness/adapters/dsh.js +6 -0
  25. package/backend/dist/harness/adapters/gemini-cli.d.ts +2 -0
  26. package/backend/dist/harness/adapters/gemini-cli.js +7 -0
  27. package/backend/dist/harness/adapters/github-copilot.d.ts +5 -0
  28. package/backend/dist/harness/adapters/github-copilot.js +10 -0
  29. package/backend/dist/harness/adapters/index.d.ts +44 -0
  30. package/backend/dist/harness/adapters/index.js +99 -0
  31. package/backend/dist/harness/adapters/opencode.d.ts +2 -0
  32. package/backend/dist/harness/adapters/opencode.js +55 -0
  33. package/backend/dist/harness/adapters/pi.d.ts +1 -0
  34. package/backend/dist/harness/adapters/pi.js +22 -0
  35. package/backend/dist/harness/adapters/skills-paths.d.ts +15 -0
  36. package/backend/dist/harness/adapters/skills-paths.js +17 -0
  37. package/backend/dist/harness/adapters/types.d.ts +174 -0
  38. package/backend/dist/harness/adapters/types.js +12 -0
  39. package/backend/dist/harness/adapters/universal.d.ts +6 -0
  40. package/backend/dist/harness/adapters/universal.js +10 -0
  41. package/backend/dist/harness/adapters/windsurf.d.ts +2 -0
  42. package/backend/dist/harness/adapters/windsurf.js +10 -0
  43. package/backend/dist/harness/adapters/zed.d.ts +2 -0
  44. package/backend/dist/harness/adapters/zed.js +6 -0
  45. package/backend/dist/harness/awesome-opencode.d.ts +40 -0
  46. package/backend/dist/harness/awesome-opencode.js +75 -0
  47. package/backend/dist/harness/browse.d.ts +202 -0
  48. package/backend/dist/harness/browse.js +1214 -0
  49. package/backend/dist/harness/catalog-npm.d.ts +59 -0
  50. package/backend/dist/harness/catalog-npm.js +145 -0
  51. package/backend/dist/harness/clawhub.d.ts +212 -0
  52. package/backend/dist/harness/clawhub.js +426 -0
  53. package/backend/dist/harness/config-file.d.ts +29 -0
  54. package/backend/dist/harness/config-file.js +35 -0
  55. package/backend/dist/harness/detail.d.ts +74 -0
  56. package/backend/dist/harness/detail.js +330 -0
  57. package/backend/dist/harness/discover.d.ts +118 -0
  58. package/backend/dist/harness/discover.js +507 -0
  59. package/backend/dist/harness/drift.d.ts +21 -0
  60. package/backend/dist/harness/drift.js +25 -0
  61. package/backend/dist/harness/hash.d.ts +10 -0
  62. package/backend/dist/harness/hash.js +63 -0
  63. package/backend/dist/harness/hosts.d.ts +18 -0
  64. package/backend/dist/harness/hosts.js +15 -0
  65. package/backend/dist/harness/install.d.ts +88 -0
  66. package/backend/dist/harness/install.js +301 -0
  67. package/backend/dist/harness/inventory.d.ts +10 -0
  68. package/backend/dist/harness/inventory.js +198 -0
  69. package/backend/dist/harness/ledger.d.ts +39 -0
  70. package/backend/dist/harness/ledger.js +83 -0
  71. package/backend/dist/harness/maintenance.d.ts +115 -0
  72. package/backend/dist/harness/maintenance.js +603 -0
  73. package/backend/dist/harness/manifest.d.ts +31 -0
  74. package/backend/dist/harness/manifest.js +234 -0
  75. package/backend/dist/harness/net.d.ts +86 -0
  76. package/backend/dist/harness/net.js +113 -0
  77. package/backend/dist/harness/opencode-cafe.d.ts +40 -0
  78. package/backend/dist/harness/opencode-cafe.js +85 -0
  79. package/backend/dist/harness/opencode-ecosystem.d.ts +34 -0
  80. package/backend/dist/harness/opencode-ecosystem.js +246 -0
  81. package/backend/dist/harness/pi-dev.d.ts +81 -0
  82. package/backend/dist/harness/pi-dev.js +187 -0
  83. package/backend/dist/harness/probe.d.ts +33 -0
  84. package/backend/dist/harness/probe.js +85 -0
  85. package/backend/dist/harness/registry.d.ts +2 -0
  86. package/backend/dist/harness/registry.js +26 -0
  87. package/backend/dist/harness/scopes.d.ts +21 -0
  88. package/backend/dist/harness/scopes.js +22 -0
  89. package/backend/dist/harness/skill-md.d.ts +18 -0
  90. package/backend/dist/harness/skill-md.js +71 -0
  91. package/backend/dist/harness/skills-sh.d.ts +109 -0
  92. package/backend/dist/harness/skills-sh.js +178 -0
  93. package/backend/dist/harness/smithery.d.ts +64 -0
  94. package/backend/dist/harness/smithery.js +146 -0
  95. package/backend/dist/harness/sources/awesome-opencode.d.ts +11 -0
  96. package/backend/dist/harness/sources/awesome-opencode.js +39 -0
  97. package/backend/dist/harness/sources/clawhub.d.ts +2 -0
  98. package/backend/dist/harness/sources/clawhub.js +83 -0
  99. package/backend/dist/harness/sources/github.d.ts +9 -0
  100. package/backend/dist/harness/sources/github.js +202 -0
  101. package/backend/dist/harness/sources/mcp-official.d.ts +2 -0
  102. package/backend/dist/harness/sources/mcp-official.js +110 -0
  103. package/backend/dist/harness/sources/npm.d.ts +2 -0
  104. package/backend/dist/harness/sources/npm.js +152 -0
  105. package/backend/dist/harness/sources/opencode-cafe.d.ts +11 -0
  106. package/backend/dist/harness/sources/opencode-cafe.js +41 -0
  107. package/backend/dist/harness/sources/smithery.d.ts +2 -0
  108. package/backend/dist/harness/sources/smithery.js +81 -0
  109. package/backend/dist/harness/spi.d.ts +98 -0
  110. package/backend/dist/harness/spi.js +8 -0
  111. package/backend/dist/harness/stars.d.ts +70 -0
  112. package/backend/dist/harness/stars.js +202 -0
  113. package/backend/dist/harness/translation.d.ts +142 -0
  114. package/backend/dist/harness/translation.js +567 -0
  115. package/backend/dist/harness/tree.d.ts +13 -0
  116. package/backend/dist/harness/tree.js +19 -0
  117. package/backend/dist/harness/types.d.ts +286 -0
  118. package/backend/dist/harness/types.js +8 -0
  119. package/backend/dist/harness/writers/extension.d.ts +116 -0
  120. package/backend/dist/harness/writers/extension.js +219 -0
  121. package/backend/dist/harness/writers/mcp.d.ts +72 -0
  122. package/backend/dist/harness/writers/mcp.js +195 -0
  123. package/backend/dist/harness/writers/skill.d.ts +60 -0
  124. package/backend/dist/harness/writers/skill.js +146 -0
  125. package/backend/dist/opencode/agents.d.ts +5 -0
  126. package/backend/dist/opencode/agents.js +10 -1
  127. package/backend/dist/opencode/catalog/cache.js +2 -1
  128. package/backend/dist/opencode/catalog/logos.js +2 -1
  129. package/backend/dist/opencode/catalog/ocr-store.js +2 -1
  130. package/backend/dist/opencode/catalog/overrides-store.js +2 -1
  131. package/backend/dist/opencode/credentials/factory.js +10 -27
  132. package/backend/dist/opencode/credentials/ocr-store.js +2 -1
  133. package/backend/dist/opencode/provider-defs.js +2 -1
  134. package/backend/dist/opencode/user-config.js +8 -16
  135. package/backend/dist/providers/registry.d.ts +15 -4
  136. package/backend/dist/providers/registry.js +29 -5
  137. package/backend/dist/providers/virtual-meta.d.ts +13 -0
  138. package/backend/dist/providers/virtual-meta.js +18 -0
  139. package/backend/dist/quota/store.js +2 -1
  140. package/backend/dist/resilience/breaker-state.js +2 -1
  141. package/backend/dist/resilience/credential-state.js +2 -1
  142. package/backend/dist/routes/console.js +137 -15
  143. package/backend/dist/routes/harness.d.ts +2 -0
  144. package/backend/dist/routes/harness.js +622 -0
  145. package/backend/dist/server.js +4 -0
  146. package/backend/dist/session/session-manager.js +2 -1
  147. package/backend/dist/surfaces/systemone-probe.d.ts +25 -0
  148. package/backend/dist/surfaces/systemone-probe.js +74 -0
  149. package/backend/dist/utils/atomic-write.d.ts +12 -0
  150. package/backend/dist/utils/atomic-write.js +29 -0
  151. package/bin/ocr.js +2 -2
  152. package/frontend/dist/assets/{index-DEo2iAT7.css → index-1o7qI-KJ.css} +1 -1
  153. package/frontend/dist/assets/index-DvXKvNxl.js +962 -0
  154. package/frontend/dist/index.html +2 -2
  155. package/package.json +87 -87
  156. package/backend/dist/budget/budget-manager.d.ts +0 -25
  157. package/backend/dist/budget/budget-manager.js +0 -54
  158. package/backend/dist/config/governance-limits.d.ts +0 -68
  159. package/backend/dist/config/governance-limits.js +0 -261
  160. package/backend/dist/flywheel/collector.d.ts +0 -74
  161. package/backend/dist/flywheel/collector.js +0 -235
  162. package/backend/dist/flywheel/dataset.d.ts +0 -130
  163. package/backend/dist/flywheel/dataset.js +0 -638
  164. package/backend/dist/flywheel/decision-capture.d.ts +0 -68
  165. package/backend/dist/flywheel/decision-capture.js +0 -85
  166. package/backend/dist/flywheel/prune.d.ts +0 -133
  167. package/backend/dist/flywheel/prune.js +0 -495
  168. package/backend/dist/flywheel/schema.d.ts +0 -108
  169. package/backend/dist/flywheel/schema.js +0 -117
  170. package/backend/dist/flywheel/trainer.d.ts +0 -84
  171. package/backend/dist/flywheel/trainer.js +0 -198
  172. package/backend/dist/opencode/catalog/custom-store.d.ts +0 -50
  173. package/backend/dist/opencode/catalog/custom-store.js +0 -144
  174. package/backend/dist/opencode/credentials/push.d.ts +0 -38
  175. package/backend/dist/opencode/credentials/push.js +0 -116
  176. package/backend/dist/opencode/credentials/reconcile.d.ts +0 -49
  177. package/backend/dist/opencode/credentials/reconcile.js +0 -216
  178. package/backend/dist/opencode/sync.d.ts +0 -29
  179. package/backend/dist/opencode/sync.js +0 -186
  180. package/backend/dist/pipeline/account-selection.d.ts +0 -101
  181. package/backend/dist/pipeline/account-selection.js +0 -112
  182. package/backend/dist/providers/systemone.d.ts +0 -29
  183. package/backend/dist/providers/systemone.js +0 -170
  184. package/backend/dist/ratelimit/duration.d.ts +0 -24
  185. package/backend/dist/ratelimit/duration.js +0 -43
  186. package/backend/dist/ratelimit/governance-runtime.d.ts +0 -121
  187. package/backend/dist/ratelimit/governance-runtime.js +0 -183
  188. package/backend/dist/ratelimit/index.d.ts +0 -4
  189. package/backend/dist/ratelimit/index.js +0 -4
  190. package/backend/dist/ratelimit/limiter.d.ts +0 -157
  191. package/backend/dist/ratelimit/limiter.js +0 -244
  192. package/backend/dist/ratelimit/sliding-window-counter.d.ts +0 -63
  193. package/backend/dist/ratelimit/sliding-window-counter.js +0 -103
  194. package/backend/dist/ratelimit/subject.d.ts +0 -26
  195. package/backend/dist/ratelimit/subject.js +0 -28
  196. package/backend/dist/resilience/account-state.d.ts +0 -84
  197. package/backend/dist/resilience/account-state.js +0 -228
  198. package/backend/dist/router/layer1-classifier.d.ts +0 -111
  199. package/backend/dist/router/layer1-classifier.js +0 -467
  200. package/backend/dist/router/layer2-judge.d.ts +0 -111
  201. package/backend/dist/router/layer2-judge.js +0 -373
  202. package/backend/dist/router/retry-escalation.d.ts +0 -89
  203. package/backend/dist/router/retry-escalation.js +0 -99
  204. package/backend/dist/routes/flywheel.d.ts +0 -3
  205. package/backend/dist/routes/flywheel.js +0 -268
  206. package/backend/dist/routes/systemone.d.ts +0 -3
  207. package/backend/dist/routes/systemone.js +0 -90
  208. package/backend/dist/surfaces/governance-envelope.d.ts +0 -34
  209. package/backend/dist/surfaces/governance-envelope.js +0 -47
  210. package/backend/dist/utils/token-estimator.d.ts +0 -7
  211. package/backend/dist/utils/token-estimator.js +0 -20
  212. package/frontend/dist/assets/index-nwgWkmU1.js +0 -840
@@ -1,230 +1,230 @@
1
- # OmniCellRouter (OCR) 发行与打包发布指南
2
-
3
- <div align="center">
4
-
5
- [![npm](https://img.shields.io/npm/v/omnicell-router.svg?color=blue)](https://www.npmjs.com/package/omnicell-router)
6
- [![Desktop Release](https://img.shields.io/github/v/release/kenlin8827/omnicell-router?color=purple)](https://github.com/kenlin8827/omnicell-router/releases)
7
- [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
8
-
9
- [英文版 (English)](RELEASING.md) | [中文版 (Chinese)](RELEASING.zh-CN.md) | [用户使用手册 (README)](README.zh-CN.md)
10
-
11
- </div>
12
-
13
- 本文档详细介绍了 **OmniCellRouter (OCR)** 的两大发布渠道与发行流程:
14
-
15
- 1. **npm Registry 官方源 (`omnicell-router`)**:Web 控制台与 CLI 完整网关包。用户通过 `npm install -g omnicell-router` 全局安装或通过 `npx omnicell-router` 免安装直接启动。
16
- 2. **GitHub Releases 多平台桌面版**:独立的原生桌面安装包(Tauri v2 + 嵌入式 Bun 编译网关 Sidecar),覆盖 Windows (`.exe` NSIS)、macOS (`.dmg` 包含 Apple Silicon 与 Intel) 以及 Linux (`.AppImage`, `.deb`)。
17
-
18
- ---
19
-
20
- ## 1. 发行架构总览
21
-
22
- ```
23
- ┌──────────────────────────────────────────────┐
24
- │ OmniCellRouter 源码库 │
25
- └───────┬──────────────────────────────┬───────┘
26
- │ │
27
- npm 发布 (Web/CLI 网关) GitHub Actions Tag 推送 (桌面版)
28
- │ │
29
- ▼ ▼
30
- ┌─────────────────────────┐ ┌───────────────────────────┐
31
- │ npm 官方源 │ │ GitHub Releases │
32
- │ (omnicell-router) │ │ (多平台桌面安装包) │
33
- └────────────┬────────────┘ └─────────────┬─────────────┘
34
- │ │
35
- `npm i -g ...` 桌面客户端安装包:
36
- `npx ...` - Windows NSIS (.exe)
37
- │ - macOS 苹果芯片 M 系列 (.dmg)
38
- ▼ - macOS Intel 芯片 (.dmg)
39
- CLI 命令行 & Web 控制台 - Linux AppImage 与 Deb
40
- (`ocr start / web`) - 原生桌面托盘与客户端窗口
41
- ```
42
-
43
- ---
44
-
45
- ## 2. 发布到 npm 官方源 (`omnicell-router`)
46
-
47
- ### 2.1 npm 安装包运行机制
48
-
49
- - **全局可执行命令**:用户安装后,npm 会自动在系统 `PATH` 中注册 `ocr` 与 `omnicell-router` 命令,指向跨平台脚本 [bin/ocr.js](file:///d:/OpenHub/omnicell-router/bin/ocr.js)。
50
- - **原生 Node.js 兼容**:运行时支持 Node.js (>= 18.0.0),终端用户无需预先安装 Bun 或 TypeScript。
51
- - **内嵌完整 Web 控制台**:发布包内仅包含编译后的生产文件(前端 [frontend/dist](file:///d:/OpenHub/omnicell-router/frontend/dist) 与后端 [backend/dist](file:///d:/OpenHub/omnicell-router/backend/dist)),包解压体积仅约 28 MB(内嵌了完整的离线字体与静态资产)。
52
- - **完整生命周期管理**:支持所有 CLI 指令,如 `ocr start`(后台启动)、`ocr web`(启动并打开浏览器)、`ocr status`(查看监控)和 `ocr stop`(停止服务)。
53
-
54
- ### 2.2 发布前准备
55
-
56
- 1. 拥有 [npmjs.com](https://www.npmjs.com/) 注册账号。
57
- 2. 本地已安装 Node.js (>= 18) 或 Bun。
58
- 3. 终端已配置并登录 npm 账号(支持双重身份验证 2FA)。
59
-
60
- ### 2.3 npm 发布步骤全流程
61
-
62
- #### 步骤 1:切换至官方源
63
- 确保当前终端使用的是 npm 官方源,而非淘宝等第三方镜像源:
64
-
65
- ```bash
66
- npm config set registry https://registry.npmjs.org/
67
- ```
68
-
69
- #### 步骤 2:登录 npm 账号
70
- 在终端运行登录命令:
71
-
72
- ```bash
73
- npm login
74
- ```
75
- 终端会弹出浏览器授权或提示输入用户名、密码及一次性动态验证码 (OTP)。登录后验证身份:
76
-
77
- ```bash
78
- npm whoami
79
- ```
80
-
81
- #### 步骤 3:更新版本号
82
- 根据本次更新性质,递增 `package.json` 中的版本号:
83
-
84
- ```bash
85
- # Bug 修复 / 小改动(如 0.0.1 -> 0.0.2)
86
- npm version patch
87
-
88
- # 新增向下兼容功能(如 0.0.1 -> 0.1.0)
89
- npm version minor
90
-
91
- # 重大架构更新 / 不兼容改动
92
- npm version major
93
- ```
94
-
95
- #### 步骤 4:本地打包预检(Dry-run)
96
- 在发布前执行模拟打包,确保上传文件精简纯净:
97
-
98
- ```bash
99
- npm pack --dry-run
100
- # 或者使用 Bun:
101
- bun pm pack --dry-run
102
- ```
103
-
104
- 确认清单仅包含:
105
- - `bin/ocr.js` 与 `bin/` 脚本;
106
- - `backend/dist/`(编译后网关后端);
107
- - `frontend/dist/`(编译后 Web 控制台前端静态资源);
108
- - `README.md`、`README.zh-CN.md`、`LICENSE`。
109
- - 测试用例、源代码(`*.ts`, `*.tsx`)、`.git` 和 `desktop/` 源码均被自动排除。
110
-
111
- #### 步骤 5:执行正式发布
112
- 运行发布命令:
113
-
114
- ```bash
115
- npm publish --access public
116
- ```
117
-
118
- > [!NOTE]
119
- > 根目录 `package.json` 中配置了 `"prepublishOnly": "bun run build"` 钩子,npm 会在打包前自动执行全量构建(`tsc -p backend && vite build frontend`),确保发布代码为最新编译产物。
120
-
121
- #### 步骤 6:验证用户安装
122
- 发布成功后,可另开一个终端窗口或在测试机上验证:
123
-
124
- ```bash
125
- # 全局安装
126
- npm install -g omnicell-router
127
-
128
- # 查看版本
129
- ocr --version
130
-
131
- # 启动 Web 控制台(自动拉起后台服务并打开浏览器)
132
- ocr web
133
- ```
134
-
135
- ---
136
-
137
- ## 3. 多平台桌面版安装包发布 (GitHub Releases)
138
-
139
- OCR 桌面端基于 Tauri v2 框架开发,网关后端通过 Bun 单文件交叉编译(`bun build --compile`)直接注入为原生 Sidecar 二进制。
140
-
141
- ### 3.1 目标平台与安装包格式
142
-
143
- | 目标系统与架构 | 平台编译目标 (Target) | 打包格式 | 安装包文件名格式 |
144
- | :--- | :--- | :--- | :--- |
145
- | **Windows x64** | `x86_64-pc-windows-msvc` | NSIS | `OmniCellRouter_<版本>_x64-setup.exe` |
146
- | **macOS (Apple Silicon)** | `aarch64-apple-darwin` | DMG | `OmniCellRouter_<版本>_aarch64.dmg` |
147
- | **macOS (Intel)** | `x86_64-apple-darwin` | DMG | `OmniCellRouter_<版本>_x64.dmg` |
148
- | **Linux x64** | `x86_64-unknown-linux-gnu` | AppImage & DEB | `OmniCellRouter_<版本>_amd64.AppImage`<br>`OmniCellRouter_<版本>_amd64.deb` |
149
-
150
- ### 3.2 自动化 GitHub Actions 发布流水线
151
-
152
- 工程已在 [.github/workflows/desktop-build.yml](file:///d:/OpenHub/omnicell-router/.github/workflows/desktop-build.yml) 中配置全自动发布流水线,任何以 `v*`(如 `v0.1.0`)格式的 Git Tag 推送都会自动触发:
153
-
154
- 1. **多平台矩阵并行编译**:
155
- - `windows-latest`:编译 Windows NSIS 极速安装包;
156
- - `macos-latest`:交叉编译 Apple Silicon (`aarch64`) 与 Intel (`x86_64`) 的 DMG 镜像;
157
- - `ubuntu-22.04`:在 Linux 容器中链接 webkit2gtk-4.1 并打包 AppImage 与 deb 安装包。
158
- 2. **网关 Sidecar 版本注入**:
159
- - 自动运行 `desktop/scripts/build-sidecar.ts`,将当前 Tag 版本号注入到编译二进制中。
160
- 3. **自动创建 Release 并上传安装包**:
161
- - `release` 任务会自动汇总上述所有操作系统的安装包产物;
162
- - 自动创建 GitHub Release,生成 Release Notes,并将全部平台的 `.exe`、`.dmg`、`.AppImage`、`.deb` 文件挂载至资产列表。
163
-
164
- ### 3.3 桌面版发布操作步骤
165
-
166
- #### 步骤 1:确认并同步版本号
167
- 版本号以根 [package.json](file:///d:/OpenHub/omnicell-router/package.json) 为唯一事实源,人工只改它;其余副本(子包 package.json、`desktop/src-tauri/tauri.conf.json`、`Cargo.toml`、`Cargo.lock`)由 `npm version` 生命周期钩子经 [scripts/version-sync.ts](file:///d:/OpenHub/omnicell-router/scripts/version-sync.ts) 自动同步:
168
-
169
- ```bash
170
- npm version minor # 0.1.0 -> 0.2.0,钩子自动同步全部版本副本
171
- ```
172
-
173
- 漂移由 CI 守门(`desktop-build.yml` 的 `bun scripts/version-sync.ts --check`),也可本地自查:
174
-
175
- ```bash
176
- bun scripts/version-sync.ts --check
177
- ```
178
-
179
- #### 步骤 2:提交代码并打 Tag
180
- ```bash
181
- git add .
182
- git commit -m "chore: release v0.1.0"
183
- git tag v0.1.0
184
- ```
185
-
186
- #### 步骤 3:推送 Tag 到 GitHub
187
- ```bash
188
- git push origin v0.1.0
189
- ```
190
-
191
- #### 步骤 4:查看 GitHub Actions 构建进度
192
- 1. 访问 GitHub 仓库的 **Actions** 页面,可观察 `desktop-build` 流水线各系统并发构建状态;
193
- 2. 构建完成后(约 15-20 分钟),进入 GitHub 仓库的 **Releases** 页面;
194
- 3. 确认新版本已成功发布,且 Assets 附件中已包含了全部操作系统的桌面安装包。
195
-
196
- ---
197
-
198
- ### 3.4 本地编译桌面版(可选 / 开发调试)
199
-
200
- 如需在本地开发机调试或直接编译当前平台的安装包:
201
-
202
- ```bash
203
- # 1. 构建全量后端与前端代码
204
- bun run build
205
-
206
- # 2. 编译本地平台对应的网关 Sidecar 二进制
207
- cd desktop
208
- bun run sidecar
209
-
210
- # 3. 运行本地打包
211
- bun run build
212
- ```
213
-
214
- 打包生成的安装包文件保存在:
215
- `desktop/src-tauri/target/release/bundle/`
216
-
217
- ---
218
-
219
- ## 4. 完整发行 CheckList 检查清单
220
-
221
- 在对外进行新版本发布时,建议按照如下步骤逐一确认:
222
-
223
- - [ ] 本地测试套件全绿:`bun run test`(121 个测试套件,1600+ 用例通过)。
224
- - [ ] TypeScript 类型检查无误:`bun run typecheck`。
225
- - [ ] 版本号只改根 `package.json` 并运行 `npm version <patch|minor|major>`(钩子自动同步其余副本;`bun scripts/version-sync.ts --check` 应全绿)。
226
- - [ ] 提交代码变更:`git commit -m "chore: release vX.Y.Z"`。
227
- - [ ] 推送 Git Tag 触发桌面版发布:`git tag vX.Y.Z && git push origin vX.Y.Z`。
228
- - [ ] 检查 GitHub Actions 流水线是否成功发布 Release 并挂载了所有平台安装包。
229
- - [ ] 执行 npm 发布:`npm publish --access public`。
230
- - [ ] 验证用户安装:运行 `npm install -g omnicell-router`,测试 `ocr --version` 与 `ocr web`。
1
+ # OmniCellRouter (OCR) 发行与打包发布指南
2
+
3
+ <div align="center">
4
+
5
+ [![npm](https://img.shields.io/npm/v/omnicell-router.svg?color=blue)](https://www.npmjs.com/package/omnicell-router)
6
+ [![Desktop Release](https://img.shields.io/github/v/release/kenlin8827/omnicell-router?color=purple)](https://github.com/kenlin8827/omnicell-router/releases)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
8
+
9
+ [英文版 (English)](RELEASING.md) | [中文版 (Chinese)](RELEASING.zh-CN.md) | [用户使用手册 (README)](README.zh-CN.md)
10
+
11
+ </div>
12
+
13
+ 本文档详细介绍了 **OmniCellRouter (OCR)** 的两大发布渠道与发行流程:
14
+
15
+ 1. **npm Registry 官方源 (`omnicell-router`)**:Web 控制台与 CLI 完整网关包。用户通过 `npm install -g omnicell-router` 全局安装或通过 `npx omnicell-router` 免安装直接启动。
16
+ 2. **GitHub Releases 多平台桌面版**:独立的原生桌面安装包(Tauri v2 + 嵌入式 Bun 编译网关 Sidecar),覆盖 Windows (`.exe` NSIS)、macOS (`.dmg` 包含 Apple Silicon 与 Intel) 以及 Linux (`.AppImage`, `.deb`)。
17
+
18
+ ---
19
+
20
+ ## 1. 发行架构总览
21
+
22
+ ```
23
+ ┌──────────────────────────────────────────────┐
24
+ │ OmniCellRouter 源码库 │
25
+ └───────┬──────────────────────────────┬───────┘
26
+ │ │
27
+ npm 发布 (Web/CLI 网关) GitHub Actions Tag 推送 (桌面版)
28
+ │ │
29
+ ▼ ▼
30
+ ┌─────────────────────────┐ ┌───────────────────────────┐
31
+ │ npm 官方源 │ │ GitHub Releases │
32
+ │ (omnicell-router) │ │ (多平台桌面安装包) │
33
+ └────────────┬────────────┘ └─────────────┬─────────────┘
34
+ │ │
35
+ `npm i -g ...` 桌面客户端安装包:
36
+ `npx ...` - Windows NSIS (.exe)
37
+ │ - macOS 苹果芯片 M 系列 (.dmg)
38
+ ▼ - macOS Intel 芯片 (.dmg)
39
+ CLI 命令行 & Web 控制台 - Linux AppImage 与 Deb
40
+ (`ocr start / web`) - 原生桌面托盘与客户端窗口
41
+ ```
42
+
43
+ ---
44
+
45
+ ## 2. 发布到 npm 官方源 (`omnicell-router`)
46
+
47
+ ### 2.1 npm 安装包运行机制
48
+
49
+ - **全局可执行命令**:用户安装后,npm 会自动在系统 `PATH` 中注册 `ocr` 与 `omnicell-router` 命令,指向跨平台脚本 [bin/ocr.js](file:///d:/OpenHub/omnicell-router/bin/ocr.js)。
50
+ - **原生 Node.js 兼容**:运行时支持 Node.js (>= 18.0.0),终端用户无需预先安装 Bun 或 TypeScript。
51
+ - **内嵌完整 Web 控制台**:发布包内仅包含编译后的生产文件(前端 [frontend/dist](file:///d:/OpenHub/omnicell-router/frontend/dist) 与后端 [backend/dist](file:///d:/OpenHub/omnicell-router/backend/dist)),包解压体积仅约 28 MB(内嵌了完整的离线字体与静态资产)。
52
+ - **完整生命周期管理**:支持所有 CLI 指令,如 `ocr start`(后台启动)、`ocr web`(启动并打开浏览器)、`ocr status`(查看监控)和 `ocr stop`(停止服务)。
53
+
54
+ ### 2.2 发布前准备
55
+
56
+ 1. 拥有 [npmjs.com](https://www.npmjs.com/) 注册账号。
57
+ 2. 本地已安装 Node.js (>= 18) 或 Bun。
58
+ 3. 终端已配置并登录 npm 账号(支持双重身份验证 2FA)。
59
+
60
+ ### 2.3 npm 发布步骤全流程
61
+
62
+ #### 步骤 1:切换至官方源
63
+ 确保当前终端使用的是 npm 官方源,而非淘宝等第三方镜像源:
64
+
65
+ ```bash
66
+ npm config set registry https://registry.npmjs.org/
67
+ ```
68
+
69
+ #### 步骤 2:登录 npm 账号
70
+ 在终端运行登录命令:
71
+
72
+ ```bash
73
+ npm login
74
+ ```
75
+ 终端会弹出浏览器授权或提示输入用户名、密码及一次性动态验证码 (OTP)。登录后验证身份:
76
+
77
+ ```bash
78
+ npm whoami
79
+ ```
80
+
81
+ #### 步骤 3:更新版本号
82
+ 根据本次更新性质,递增 `package.json` 中的版本号:
83
+
84
+ ```bash
85
+ # Bug 修复 / 小改动(如 0.0.1 -> 0.0.2)
86
+ npm version patch
87
+
88
+ # 新增向下兼容功能(如 0.0.1 -> 0.1.0)
89
+ npm version minor
90
+
91
+ # 重大架构更新 / 不兼容改动
92
+ npm version major
93
+ ```
94
+
95
+ #### 步骤 4:本地打包预检(Dry-run)
96
+ 在发布前执行模拟打包,确保上传文件精简纯净:
97
+
98
+ ```bash
99
+ npm pack --dry-run
100
+ # 或者使用 Bun:
101
+ bun pm pack --dry-run
102
+ ```
103
+
104
+ 确认清单仅包含:
105
+ - `bin/ocr.js` 与 `bin/` 脚本;
106
+ - `backend/dist/`(编译后网关后端);
107
+ - `frontend/dist/`(编译后 Web 控制台前端静态资源);
108
+ - `README.md`、`README.zh-CN.md`、`LICENSE`。
109
+ - 测试用例、源代码(`*.ts`, `*.tsx`)、`.git` 和 `desktop/` 源码均被自动排除。
110
+
111
+ #### 步骤 5:执行正式发布
112
+ 运行发布命令:
113
+
114
+ ```bash
115
+ npm publish --access public
116
+ ```
117
+
118
+ > [!NOTE]
119
+ > 根目录 `package.json` 中配置了 `"prepublishOnly": "bun run build"` 钩子,npm 会在打包前自动执行全量构建(`tsc -p backend && vite build frontend`),确保发布代码为最新编译产物。
120
+
121
+ #### 步骤 6:验证用户安装
122
+ 发布成功后,可另开一个终端窗口或在测试机上验证:
123
+
124
+ ```bash
125
+ # 全局安装
126
+ npm install -g omnicell-router
127
+
128
+ # 查看版本
129
+ ocr --version
130
+
131
+ # 启动 Web 控制台(自动拉起后台服务并打开浏览器)
132
+ ocr web
133
+ ```
134
+
135
+ ---
136
+
137
+ ## 3. 多平台桌面版安装包发布 (GitHub Releases)
138
+
139
+ OCR 桌面端基于 Tauri v2 框架开发,网关后端通过 Bun 单文件交叉编译(`bun build --compile`)直接注入为原生 Sidecar 二进制。
140
+
141
+ ### 3.1 目标平台与安装包格式
142
+
143
+ | 目标系统与架构 | 平台编译目标 (Target) | 打包格式 | 安装包文件名格式 |
144
+ | :--- | :--- | :--- | :--- |
145
+ | **Windows x64** | `x86_64-pc-windows-msvc` | NSIS | `OmniCellRouter_<版本>_x64-setup.exe` |
146
+ | **macOS (Apple Silicon)** | `aarch64-apple-darwin` | DMG | `OmniCellRouter_<版本>_aarch64.dmg` |
147
+ | **macOS (Intel)** | `x86_64-apple-darwin` | DMG | `OmniCellRouter_<版本>_x64.dmg` |
148
+ | **Linux x64** | `x86_64-unknown-linux-gnu` | AppImage & DEB | `OmniCellRouter_<版本>_amd64.AppImage`<br>`OmniCellRouter_<版本>_amd64.deb` |
149
+
150
+ ### 3.2 自动化 GitHub Actions 发布流水线
151
+
152
+ 工程已在 [.github/workflows/desktop-build.yml](file:///d:/OpenHub/omnicell-router/.github/workflows/desktop-build.yml) 中配置全自动发布流水线,任何以 `v*`(如 `v0.1.0`)格式的 Git Tag 推送都会自动触发:
153
+
154
+ 1. **多平台矩阵并行编译**:
155
+ - `windows-latest`:编译 Windows NSIS 极速安装包;
156
+ - `macos-latest`:交叉编译 Apple Silicon (`aarch64`) 与 Intel (`x86_64`) 的 DMG 镜像;
157
+ - `ubuntu-22.04`:在 Linux 容器中链接 webkit2gtk-4.1 并打包 AppImage 与 deb 安装包。
158
+ 2. **网关 Sidecar 版本注入**:
159
+ - 自动运行 `desktop/scripts/build-sidecar.ts`,将当前 Tag 版本号注入到编译二进制中。
160
+ 3. **自动创建 Release 并上传安装包**:
161
+ - `release` 任务会自动汇总上述所有操作系统的安装包产物;
162
+ - 自动创建 GitHub Release,生成 Release Notes,并将全部平台的 `.exe`、`.dmg`、`.AppImage`、`.deb` 文件挂载至资产列表。
163
+
164
+ ### 3.3 桌面版发布操作步骤
165
+
166
+ #### 步骤 1:确认并同步版本号
167
+ 版本号以根 [package.json](file:///d:/OpenHub/omnicell-router/package.json) 为唯一事实源,人工只改它;其余副本(子包 package.json、`desktop/src-tauri/tauri.conf.json`、`Cargo.toml`、`Cargo.lock`)由 `npm version` 生命周期钩子经 [scripts/version-sync.ts](file:///d:/OpenHub/omnicell-router/scripts/version-sync.ts) 自动同步:
168
+
169
+ ```bash
170
+ npm version minor # 0.1.0 -> 0.2.0,钩子自动同步全部版本副本
171
+ ```
172
+
173
+ 漂移由 CI 守门(`desktop-build.yml` 的 `bun scripts/version-sync.ts --check`),也可本地自查:
174
+
175
+ ```bash
176
+ bun scripts/version-sync.ts --check
177
+ ```
178
+
179
+ #### 步骤 2:提交代码并打 Tag
180
+ ```bash
181
+ git add .
182
+ git commit -m "chore: release v0.1.0"
183
+ git tag v0.1.0
184
+ ```
185
+
186
+ #### 步骤 3:推送 Tag 到 GitHub
187
+ ```bash
188
+ git push origin v0.1.0
189
+ ```
190
+
191
+ #### 步骤 4:查看 GitHub Actions 构建进度
192
+ 1. 访问 GitHub 仓库的 **Actions** 页面,可观察 `desktop-build` 流水线各系统并发构建状态;
193
+ 2. 构建完成后(约 15-20 分钟),进入 GitHub 仓库的 **Releases** 页面;
194
+ 3. 确认新版本已成功发布,且 Assets 附件中已包含了全部操作系统的桌面安装包。
195
+
196
+ ---
197
+
198
+ ### 3.4 本地编译桌面版(可选 / 开发调试)
199
+
200
+ 如需在本地开发机调试或直接编译当前平台的安装包:
201
+
202
+ ```bash
203
+ # 1. 构建全量后端与前端代码
204
+ bun run build
205
+
206
+ # 2. 编译本地平台对应的网关 Sidecar 二进制
207
+ cd desktop
208
+ bun run sidecar
209
+
210
+ # 3. 运行本地打包
211
+ bun run build
212
+ ```
213
+
214
+ 打包生成的安装包文件保存在:
215
+ `desktop/src-tauri/target/release/bundle/`
216
+
217
+ ---
218
+
219
+ ## 4. 完整发行 CheckList 检查清单
220
+
221
+ 在对外进行新版本发布时,建议按照如下步骤逐一确认:
222
+
223
+ - [ ] 本地测试套件全绿:`bun run test`(121 个测试套件,1600+ 用例通过)。
224
+ - [ ] TypeScript 类型检查无误:`bun run typecheck`。
225
+ - [ ] 版本号只改根 `package.json` 并运行 `npm version <patch|minor|major>`(钩子自动同步其余副本;`bun scripts/version-sync.ts --check` 应全绿)。
226
+ - [ ] 提交代码变更:`git commit -m "chore: release vX.Y.Z"`。
227
+ - [ ] 推送 Git Tag 触发桌面版发布:`git tag vX.Y.Z && git push origin vX.Y.Z`。
228
+ - [ ] 检查 GitHub Actions 流水线是否成功发布 Release 并挂载了所有平台安装包。
229
+ - [ ] 执行 npm 发布:`npm publish --access public`。
230
+ - [ ] 验证用户安装:运行 `npm install -g omnicell-router`,测试 `ocr --version` 与 `ocr web`。
@@ -2,6 +2,7 @@ import crypto from 'node:crypto';
2
2
  import fs from 'node:fs';
3
3
  import path from 'node:path';
4
4
  import { getEnvPaths } from '../config/env.js';
5
+ import { renameWithRetry } from '../utils/atomic-write.js';
5
6
  import { DEFAULT_MAX_BODY_BYTES } from '../config/defaults.js';
6
7
  const DATE_DIR_RE = /^\d{4}-\d{2}-\d{2}$/;
7
8
  // Session ids that are already filesystem-safe are kept verbatim for
@@ -1400,7 +1401,7 @@ export class CaptureRecorder {
1400
1401
  const tmp = `${fp}.${process.pid}.${crypto.randomUUID().slice(0, 8)}.tmp`;
1401
1402
  try {
1402
1403
  fs.writeFileSync(tmp, raw);
1403
- fs.renameSync(tmp, fp);
1404
+ renameWithRetry(tmp, fp);
1404
1405
  }
1405
1406
  catch (inner) {
1406
1407
  try {
@@ -1,6 +1,7 @@
1
1
  import fs from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import { loadConfig } from '../../config/index.js';
4
+ import { renameWithRetry } from '../../utils/atomic-write.js';
4
5
  export const OCR_DEFAULT_PORT = 4000;
5
6
  export const OCR_DEFAULT_URL = `http://127.0.0.1:${OCR_DEFAULT_PORT}`;
6
7
  export const OCR_DEFAULT_V1_URL = `${OCR_DEFAULT_URL}/v1`;
@@ -47,25 +48,16 @@ export function safeWriteJson(filePath, data) {
47
48
  const content = JSON.stringify(data, null, 2) + '\n';
48
49
  const tmpPath = `${filePath}.tmp.${process.pid}.${Date.now()}`;
49
50
  fs.writeFileSync(tmpPath, content, 'utf8');
50
- let lastError;
51
- for (let attempt = 0; attempt < 5; attempt++) {
51
+ try {
52
+ renameWithRetry(tmpPath, filePath);
53
+ }
54
+ catch (e) {
52
55
  try {
53
- fs.renameSync(tmpPath, filePath);
54
- return;
55
- }
56
- catch (e) {
57
- lastError = e;
58
- if (attempt < 4) {
59
- const until = Date.now() + (attempt + 1) * 10;
60
- while (Date.now() < until) { }
61
- }
56
+ fs.unlinkSync(tmpPath);
62
57
  }
58
+ catch { }
59
+ throw e;
63
60
  }
64
- try {
65
- fs.unlinkSync(tmpPath);
66
- }
67
- catch { }
68
- throw lastError;
69
61
  }
70
62
  export function createBackup(filePath) {
71
63
  if (!fs.existsSync(filePath))
@@ -4,6 +4,7 @@ import os from 'node:os';
4
4
  import { parse, stringify } from 'yaml';
5
5
  import { createBackup, restoreBackup, defaultGatewayPort, } from './base.js';
6
6
  import { VIRTUAL_AUTO_IDS } from '../types.js';
7
+ import { renameWithRetry } from '../../utils/atomic-write.js';
7
8
  /**
8
9
  * Hook target: DeepSeek Harness (`dsh`). Unlike the JSON-config clients, dsh
9
10
  * reads a PER-PROFILE Cordis patch layer: $DSH_HOME/profiles/<name>/
@@ -282,24 +283,15 @@ export class DshClientAdapter {
282
283
  fs.mkdirSync(dir, { recursive: true });
283
284
  const tmpPath = `${configPath}.tmp.${process.pid}.${Date.now()}`;
284
285
  fs.writeFileSync(tmpPath, stringify(entries), 'utf8');
285
- let lastError;
286
- for (let attempt = 0; attempt < 5; attempt++) {
286
+ try {
287
+ renameWithRetry(tmpPath, configPath);
288
+ }
289
+ catch (e) {
287
290
  try {
288
- fs.renameSync(tmpPath, configPath);
289
- return;
290
- }
291
- catch (e) {
292
- lastError = e;
293
- if (attempt < 4) {
294
- const until = Date.now() + (attempt + 1) * 10;
295
- while (Date.now() < until) { }
296
- }
291
+ fs.unlinkSync(tmpPath);
297
292
  }
293
+ catch { }
294
+ throw e;
298
295
  }
299
- try {
300
- fs.unlinkSync(tmpPath);
301
- }
302
- catch { }
303
- throw lastError;
304
296
  }
305
297
  }
@@ -221,7 +221,7 @@ export class PiClientAdapter {
221
221
  // Pi has one model picker (/model, --model); the first entry is the main slot.
222
222
  { key: 'main', value: models[0]?.id ? String(models[0].id) : undefined, default: 'auto' },
223
223
  ];
224
- for (const role of this.discoverSubagentRoles(overrides)) {
224
+ for (const { name: role, description } of this.discoverSubagentRoles(overrides)) {
225
225
  const pinnedModel = overrides?.[role]?.model;
226
226
  modelSlots.push({
227
227
  key: role,
@@ -229,6 +229,7 @@ export class PiClientAdapter {
229
229
  ? pinnedModel.startsWith(SUBAGENT_MODEL_PREFIX) ? pinnedModel.slice(SUBAGENT_MODEL_PREFIX.length) : pinnedModel
230
230
  : undefined,
231
231
  default: PI_SUBAGENT_TIERS[role] || 'auto',
232
+ description,
232
233
  });
233
234
  }
234
235
  return {
@@ -360,7 +361,7 @@ export class PiClientAdapter {
360
361
  continue; // unchanged echo — leave a manual pin byte-identical
361
362
  overrides[role] = { ...base, model: value.includes('/') ? value : `${PI_PROVIDER_KEY}/${value}` };
362
363
  }
363
- for (const role of this.discoverSubagentRoles(overrides)) {
364
+ for (const { name: role } of this.discoverSubagentRoles(overrides)) {
364
365
  if (explicitRoles.has(role))
365
366
  continue;
366
367
  const tier = PI_SUBAGENT_TIERS[role] || 'auto';
@@ -570,7 +571,7 @@ export class PiClientAdapter {
570
571
  * preset-known roles first, then the rest alphabetically.
571
572
  */
572
573
  discoverSubagentRoles(overrides) {
573
- const found = new Set();
574
+ const found = new Map();
574
575
  const agentRoot = path.dirname(this.getConfigPath());
575
576
  const scanDirs = [
576
577
  { dir: path.join(agentRoot, 'npm', 'node_modules', 'pi-subagents', 'agents'), isPackage: true },
@@ -601,20 +602,26 @@ export class PiClientAdapter {
601
602
  continue;
602
603
  if (isPackage && /^runner:/m.test(frontmatter))
603
604
  continue; // external-CLI launcher — not model-routed
604
- found.add(name);
605
+ // The role's own one-line description, when the agent file carries one.
606
+ // Package files land first, user files second, so a user override's
607
+ // description wins (same precedence as the name itself).
608
+ const description = /^[ \t]*description:[ \t]*(.+)$/m.exec(frontmatter)?.[1]
609
+ ?.trim()
610
+ .replace(/^['"]|['"]$/g, '');
611
+ found.set(name, description || found.get(name));
605
612
  }
606
613
  }
607
614
  if (found.size === 0) {
608
615
  for (const role of Object.keys(PI_SUBAGENT_TIERS))
609
- found.add(role);
616
+ found.set(role, undefined);
610
617
  }
611
618
  for (const role of Object.keys(overrides || {})) {
612
- if (typeof role === 'string' && role)
613
- found.add(role);
619
+ if (typeof role === 'string' && role && !found.has(role))
620
+ found.set(role, undefined);
614
621
  }
615
622
  const known = Object.keys(PI_SUBAGENT_TIERS).filter(r => found.has(r));
616
- const rest = [...found].filter(r => !(r in PI_SUBAGENT_TIERS)).sort();
617
- return [...known, ...rest];
623
+ const rest = [...found.keys()].filter(r => !(r in PI_SUBAGENT_TIERS)).sort();
624
+ return [...known, ...rest].map(name => ({ name, description: found.get(name) }));
618
625
  }
619
626
  /**
620
627
  * Remove router-owned subagent model overrides from the settings file
@@ -58,4 +58,9 @@ export interface ClientModelSlot {
58
58
  value?: string;
59
59
  /** Recommended default for this role (e.g. haiku → 'lite', opus → 'pro'); used for UI seeding and reset */
60
60
  default?: string;
61
+ /** What this role/slot is FOR, when the client itself declares it (agent
62
+ * frontmatter / live roster). Console-only: feeds the smart-assign decider's
63
+ * role context. Absent = unknown — never synthesized here, because role sets
64
+ * are DISCOVERED per client and change with the installed package. */
65
+ description?: string;
61
66
  }
@@ -1,6 +1,7 @@
1
1
  import fs from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import { getOcrHomeDir } from '../cli/paths.js';
4
+ import { renameWithRetry } from '../utils/atomic-write.js';
4
5
  /* ------------------------------------------------------------------------- *
5
6
  * Named environments ("book-sets") — single source of truth for which
6
7
  * environment the process runs in and where every state file lives.
@@ -156,7 +157,7 @@ export function writePointer(name) {
156
157
  const file = path.join(root, POINTER_FILE);
157
158
  const tmp = `${file}.tmp.${process.pid}.${Date.now()}`;
158
159
  fs.writeFileSync(tmp, `${name}\n`, 'utf8');
159
- fs.renameSync(tmp, file);
160
+ renameWithRetry(tmp, file);
160
161
  }
161
162
  function removePointer() {
162
163
  try {