@dsh-workbench/shared 0.3.10 → 1.0.0-beta.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 (391) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +97 -0
  3. package/dist/api/blocker-table.d.ts +3 -3
  4. package/dist/api/blocker-table.js +47 -23
  5. package/dist/api/dsh.d.ts +19 -1
  6. package/dist/api/host-write.d.ts +0 -15
  7. package/dist/api/host-write.js +1 -35
  8. package/dist/api/workbench-client.js +2 -1
  9. package/dist/components/Activity.css +0 -1
  10. package/dist/components/ApprovalDetail.css +1 -2
  11. package/dist/components/ApprovalDetail.d.ts +1 -1
  12. package/dist/components/ApprovalPlan.css +0 -1
  13. package/dist/components/Card.css +0 -1
  14. package/dist/components/Card.d.ts +1 -1
  15. package/dist/components/CardBoundary.d.ts +1 -1
  16. package/dist/components/CardHead.css +0 -1
  17. package/dist/components/CardHead.d.ts +1 -1
  18. package/dist/components/ChoiceGroup.css +1 -2
  19. package/dist/components/ConfirmBar.d.ts +1 -1
  20. package/dist/components/ConfirmBar.js +1 -1
  21. package/dist/components/Form.css +1 -1
  22. package/dist/components/FormActions.js +1 -1
  23. package/dist/components/LongTaskRow.css +1 -2
  24. package/dist/components/LongTaskRow.d.ts +1 -1
  25. package/dist/components/LongTaskRow.js +1 -1
  26. package/dist/components/Note.css +0 -1
  27. package/dist/components/ResourceStates.css +0 -1
  28. package/dist/components/SettingsSection.css +0 -1
  29. package/dist/components/Spinner.css +0 -1
  30. package/dist/components/Stack.css +0 -1
  31. package/dist/components/StateBlock.css +0 -1
  32. package/dist/components/board-module.d.ts +3 -3
  33. package/dist/components/icons.d.ts +1 -7
  34. package/dist/components/icons.js +11 -16
  35. package/dist/config/constants.d.ts +2 -2
  36. package/dist/config/constants.js +2 -2
  37. package/dist/config/storage.d.ts +0 -4
  38. package/dist/config/storage.js +0 -11
  39. package/dist/contract/adapters.d.ts +10 -0
  40. package/dist/contract/cli.d.ts +3 -0
  41. package/dist/contract/data.d.ts +126 -0
  42. package/dist/{api → contract}/facts.d.ts +12 -3
  43. package/dist/{api → contract}/facts.js +19 -1
  44. package/dist/contract/needs.d.ts +132 -0
  45. package/dist/contract/needs.js +232 -0
  46. package/dist/contract/plugin-source.d.ts +1 -0
  47. package/dist/contract/plugin-source.js +1 -0
  48. package/dist/contract/protocol/bundle-install.d.ts +136 -0
  49. package/dist/contract/protocol/bundle-install.js +12 -0
  50. package/dist/contract/protocol/config-sync.d.ts +55 -0
  51. package/dist/contract/protocol/config-sync.js +2 -0
  52. package/dist/contract/protocol/diy.d.ts +4 -0
  53. package/dist/contract/protocol/diy.js +4 -0
  54. package/dist/contract/protocol/dsh-plugins.d.ts +11 -0
  55. package/dist/contract/protocol/dsh-plugins.js +1 -0
  56. package/dist/contract/protocol/long-tasks.d.ts +13 -0
  57. package/dist/contract/protocol/long-tasks.js +1 -0
  58. package/dist/contract/protocol/market-index.d.ts +195 -0
  59. package/dist/contract/protocol/market-index.js +7 -0
  60. package/dist/contract/protocol/platform.d.ts +44 -0
  61. package/dist/contract/protocol/platform.js +1 -0
  62. package/dist/contract/protocol/preflight-wake.d.ts +7 -0
  63. package/dist/contract/protocol/preflight-wake.js +1 -0
  64. package/dist/contract/protocol/profile-create.d.ts +30 -0
  65. package/dist/contract/protocol/profile-create.js +2 -0
  66. package/dist/contract/protocol/sidebar-edition.d.ts +14 -0
  67. package/dist/contract/protocol/sidebar-edition.js +2 -0
  68. package/dist/contract/protocol/unit-manifests.d.ts +6 -0
  69. package/dist/contract/protocol/unit-manifests.js +1 -0
  70. package/dist/contract/unit-board.d.ts +18 -0
  71. package/dist/contract/unit-board.js +1 -0
  72. package/dist/contract/unit-capability.d.ts +34 -0
  73. package/dist/contract/unit-capability.js +1 -0
  74. package/dist/{api → contract}/unit-declaration.d.ts +7 -5
  75. package/dist/{api → contract}/unit-declaration.js +19 -13
  76. package/dist/contract/unit.d.ts +57 -0
  77. package/dist/contract/unit.js +24 -0
  78. package/dist/contract/workbench-contract.d.ts +15 -0
  79. package/dist/contract/workbench-contract.js +1 -0
  80. package/dist/host/adapter-set.d.ts +26 -0
  81. package/dist/host/adapter-set.js +243 -0
  82. package/dist/host/adapter-types.d.ts +79 -0
  83. package/dist/host/adapter-types.js +23 -0
  84. package/dist/host/adapters.d.ts +22 -0
  85. package/dist/host/adapters.js +9 -0
  86. package/dist/host/browser.d.ts +3 -0
  87. package/dist/host/browser.js +3 -0
  88. package/dist/host/changelog.d.ts +21 -0
  89. package/dist/host/changelog.js +188 -0
  90. package/dist/host/channel-plugin.d.ts +15 -0
  91. package/dist/host/channel-plugin.js +42 -0
  92. package/dist/host/cli.d.ts +4 -0
  93. package/dist/host/cli.js +7 -0
  94. package/dist/host/command-name.d.ts +1 -0
  95. package/dist/host/command-name.js +14 -0
  96. package/dist/host/data-error.d.ts +13 -0
  97. package/dist/host/data-error.js +20 -0
  98. package/dist/host/data-root.js +3 -0
  99. package/dist/host/diy-debug.js +2 -1
  100. package/dist/host/diy-record.js +2 -1
  101. package/dist/host/facts.d.ts +1 -1
  102. package/dist/host/facts.js +3 -2
  103. package/dist/host/git.js +2 -2
  104. package/dist/host/http.js +1 -1
  105. package/dist/host/lib-capabilities.d.ts +22 -0
  106. package/dist/host/lib-capabilities.js +37 -0
  107. package/dist/host/lib-install.d.ts +9 -0
  108. package/dist/host/lib-install.js +10 -0
  109. package/dist/host/long-task.d.ts +1 -1
  110. package/dist/host/long-task.js +4 -3
  111. package/dist/host/market-index.d.ts +22 -0
  112. package/dist/host/market-index.js +420 -0
  113. package/dist/host/needs.d.ts +4 -0
  114. package/dist/host/needs.js +2 -0
  115. package/dist/host/patch.d.ts +9 -0
  116. package/dist/host/patch.js +78 -0
  117. package/dist/host/paths.d.ts +12 -0
  118. package/dist/host/paths.js +28 -0
  119. package/dist/host/platform.d.ts +14 -0
  120. package/dist/host/platform.js +40 -0
  121. package/dist/host/plugin-source.d.ts +8 -6
  122. package/dist/host/plugin-source.js +43 -33
  123. package/dist/host/plugin.d.ts +4 -0
  124. package/dist/host/plugin.js +39 -0
  125. package/dist/host/port-types.d.ts +191 -0
  126. package/dist/host/port-types.js +1 -0
  127. package/dist/host/preflight.d.ts +28 -0
  128. package/dist/host/preflight.js +1 -0
  129. package/dist/host/profile-port.d.ts +4 -0
  130. package/dist/host/profile-port.js +4 -0
  131. package/dist/host/provision.d.ts +2 -2
  132. package/dist/host/provision.js +5 -3
  133. package/dist/host/recipe-rules.d.ts +5 -0
  134. package/dist/host/recipe-rules.js +382 -0
  135. package/dist/host/recipe.d.ts +14 -0
  136. package/dist/host/recipe.js +283 -0
  137. package/dist/host/shell-text.d.ts +9 -2
  138. package/dist/host/shell-text.js +15 -3
  139. package/dist/host/shell.d.ts +2 -0
  140. package/dist/host/shell.js +7 -0
  141. package/dist/host/spec.d.ts +8 -0
  142. package/dist/host/spec.js +24 -0
  143. package/dist/host/supply-index.d.ts +34 -0
  144. package/dist/host/supply-index.js +202 -0
  145. package/dist/host/supply-port.d.ts +5 -0
  146. package/dist/host/supply-port.js +39 -0
  147. package/dist/host/time.d.ts +12 -0
  148. package/dist/host/time.js +19 -0
  149. package/dist/host/tokens.d.ts +26 -0
  150. package/dist/host/tokens.js +154 -0
  151. package/dist/host/tool-approval.d.ts +12 -0
  152. package/dist/host/tool-approval.js +4 -0
  153. package/dist/host/tool-kit.js +1 -1
  154. package/dist/host/unit-face.d.ts +5 -4
  155. package/dist/host/version-range.d.ts +2 -0
  156. package/dist/host/version-range.js +73 -0
  157. package/dist/host/version.d.ts +3 -0
  158. package/dist/host/version.js +29 -0
  159. package/dist/host.d.ts +47 -16
  160. package/dist/host.js +47 -16
  161. package/dist/i18n/en.js +259 -86
  162. package/dist/i18n/index.d.ts +333 -88
  163. package/dist/i18n/merge.js +1 -1
  164. package/dist/i18n/need-text.d.ts +26 -0
  165. package/dist/i18n/need-text.js +26 -0
  166. package/dist/i18n/settings.d.ts +70 -0
  167. package/dist/i18n/settings.js +136 -0
  168. package/dist/i18n/zh.d.ts +332 -87
  169. package/dist/i18n/zh.js +260 -87
  170. package/dist/index.d.ts +24 -8
  171. package/dist/index.js +24 -8
  172. package/dist/lib/blocker-action.d.ts +0 -15
  173. package/dist/lib/blocker-action.js +1 -25
  174. package/dist/{api → lib}/dsh-client.d.ts +12 -1
  175. package/dist/lib/dsh-client.js +1 -0
  176. package/dist/lib/market-index.d.ts +7 -0
  177. package/dist/lib/market-index.js +25 -0
  178. package/dist/lib/react-types.d.ts +5 -0
  179. package/dist/lib/react-types.js +1 -0
  180. package/dist/lib/react.d.ts +1 -40
  181. package/dist/lib/react.js +0 -36
  182. package/dist/lib/ui.js +3 -9
  183. package/dist/testing/data.d.ts +13 -0
  184. package/dist/testing/data.js +46 -0
  185. package/dist/testing/declaration.d.ts +1 -1
  186. package/dist/testing/declaration.js +1 -1
  187. package/dist/testing/host-fakes.d.ts +0 -13
  188. package/dist/testing/host-fakes.js +0 -24
  189. package/dist/testing/needs.d.ts +16 -0
  190. package/dist/testing/needs.js +46 -0
  191. package/dist/testing.d.ts +2 -0
  192. package/dist/testing.js +2 -0
  193. package/package.json +18 -2
  194. package/src/api/__tests__/blocker-table.test.ts +135 -86
  195. package/src/api/blocker-table.ts +52 -26
  196. package/src/api/dsh.ts +17 -1
  197. package/src/api/host-write.ts +0 -43
  198. package/src/api/workbench-client.test.ts +2 -2
  199. package/src/api/workbench-client.ts +2 -1
  200. package/src/components/Activity.css +0 -1
  201. package/src/components/ApprovalDetail.css +1 -2
  202. package/src/components/ApprovalDetail.tsx +1 -1
  203. package/src/components/ApprovalPlan.css +0 -1
  204. package/src/components/Card.css +0 -1
  205. package/src/components/Card.tsx +1 -1
  206. package/src/components/CardAnchor.test.tsx +1 -1
  207. package/src/components/CardBoundary.tsx +1 -1
  208. package/src/components/CardHead.css +0 -1
  209. package/src/components/CardHead.tsx +1 -1
  210. package/src/components/ChoiceGroup.css +1 -2
  211. package/src/components/ConfirmBar.tsx +1 -1
  212. package/src/components/Form.css +1 -1
  213. package/src/components/Form.tsx +1 -1
  214. package/src/components/FormActions.tsx +1 -1
  215. package/src/components/LongTaskRow.css +1 -2
  216. package/src/components/LongTaskRow.tsx +1 -1
  217. package/src/components/Note.css +0 -1
  218. package/src/components/ResourceStates.css +0 -1
  219. package/src/components/SelectFieldNodes.tsx +0 -1
  220. package/src/components/SettingsSection.css +0 -1
  221. package/src/components/Spinner.css +0 -1
  222. package/src/components/Stack.css +0 -1
  223. package/src/components/StateBlock.css +0 -1
  224. package/src/components/__tests__/long-task-row.test.ts +1 -1
  225. package/src/components/board-module.ts +3 -3
  226. package/src/components/icons.tsx +16 -24
  227. package/src/config/constants.ts +2 -2
  228. package/src/config/storage.test.ts +1 -25
  229. package/src/config/storage.ts +0 -12
  230. package/src/{api → contract}/__tests__/facts.test.ts +73 -25
  231. package/src/{api → contract}/__tests__/long-task.test.ts +3 -3
  232. package/src/contract/__tests__/needs.test.ts +74 -0
  233. package/src/{host → contract}/__tests__/unit-declaration.test.ts +1 -1
  234. package/src/contract/__tests__/unit.test.ts +43 -0
  235. package/src/contract/adapters.ts +9 -0
  236. package/src/contract/cli.ts +3 -0
  237. package/src/contract/data.ts +145 -0
  238. package/src/{api → contract}/facts.ts +34 -4
  239. package/src/contract/needs.ts +331 -0
  240. package/src/contract/plugin-source.ts +1 -0
  241. package/src/contract/protocol/bundle-install.ts +198 -0
  242. package/src/contract/protocol/config-sync.ts +65 -0
  243. package/src/contract/protocol/diy.ts +4 -0
  244. package/src/contract/protocol/dsh-plugins.ts +13 -0
  245. package/src/contract/protocol/long-tasks.ts +16 -0
  246. package/src/contract/protocol/market-index.ts +246 -0
  247. package/src/contract/protocol/platform.ts +47 -0
  248. package/src/contract/protocol/preflight-wake.ts +17 -0
  249. package/src/contract/protocol/profile-create.ts +36 -0
  250. package/src/contract/protocol/sidebar-edition.ts +19 -0
  251. package/src/contract/protocol/unit-manifests.ts +8 -0
  252. package/src/contract/unit-board.ts +23 -0
  253. package/src/contract/unit-capability.ts +37 -0
  254. package/src/{host → contract}/unit-declaration.ts +22 -18
  255. package/src/contract/unit.ts +76 -0
  256. package/src/contract/workbench-contract.ts +30 -0
  257. package/src/host/__tests__/adapter-set.test.ts +228 -0
  258. package/src/host/__tests__/adapters.test.ts +27 -0
  259. package/src/host/__tests__/changelog.test.ts +102 -0
  260. package/src/host/__tests__/command-name.test.ts +16 -0
  261. package/src/host/__tests__/diy-record.test.ts +3 -3
  262. package/src/host/__tests__/facts.test.ts +5 -5
  263. package/src/host/__tests__/long-task.test.ts +1 -1
  264. package/src/host/__tests__/market-index.test.ts +179 -0
  265. package/src/host/__tests__/plugin-ledger.test.ts +10 -10
  266. package/src/host/__tests__/provision.test.ts +7 -6
  267. package/src/host/__tests__/shell-text.test.ts +16 -1
  268. package/src/host/__tests__/supply-index.test.ts +137 -0
  269. package/src/host/__tests__/tokens.test.ts +110 -0
  270. package/src/host/__tests__/version-range.test.ts +21 -0
  271. package/src/host/adapter-set.ts +298 -0
  272. package/src/host/adapter-types.ts +105 -0
  273. package/src/host/adapters.ts +44 -0
  274. package/src/host/browser.ts +3 -0
  275. package/src/host/changelog.ts +212 -0
  276. package/src/host/channel-plugin.ts +55 -0
  277. package/src/host/cli.ts +11 -0
  278. package/src/host/command-name.ts +15 -0
  279. package/src/host/data-error.ts +21 -0
  280. package/src/host/data-root.ts +2 -0
  281. package/src/host/diy-debug.ts +2 -1
  282. package/src/host/diy-record.ts +2 -1
  283. package/src/host/facts.ts +4 -3
  284. package/src/host/git.ts +2 -2
  285. package/src/host/http.ts +1 -1
  286. package/src/host/lib-capabilities.ts +52 -0
  287. package/src/host/lib-install.ts +18 -0
  288. package/src/host/long-task.ts +4 -3
  289. package/src/host/market-index.ts +413 -0
  290. package/src/host/needs.ts +6 -0
  291. package/src/host/patch.ts +93 -0
  292. package/src/host/paths.ts +37 -0
  293. package/src/host/platform.ts +48 -0
  294. package/src/host/plugin-source.ts +48 -56
  295. package/src/host/plugin.ts +39 -0
  296. package/src/host/port-types.ts +222 -0
  297. package/src/host/preflight.ts +31 -0
  298. package/src/host/profile-port.ts +9 -0
  299. package/src/host/provision.ts +7 -4
  300. package/src/host/recipe-rules.ts +330 -0
  301. package/src/host/recipe.test.ts +334 -0
  302. package/src/host/recipe.ts +323 -0
  303. package/src/host/shell-text.ts +15 -3
  304. package/src/host/shell.ts +9 -0
  305. package/src/host/spec.ts +32 -0
  306. package/src/host/supply-index.ts +256 -0
  307. package/src/host/supply-port.ts +45 -0
  308. package/src/host/time.ts +22 -0
  309. package/src/host/tokens.ts +186 -0
  310. package/src/host/tool-approval.ts +17 -0
  311. package/src/host/tool-kit.ts +1 -1
  312. package/src/host/unit-face.ts +5 -4
  313. package/src/host/version-range.ts +71 -0
  314. package/src/host/version.ts +30 -0
  315. package/src/host.ts +47 -16
  316. package/src/i18n/en.ts +261 -86
  317. package/src/i18n/merge.test.ts +6 -6
  318. package/src/i18n/merge.ts +1 -1
  319. package/src/i18n/need-text.ts +27 -0
  320. package/src/i18n/settings.ts +141 -0
  321. package/src/i18n/zh.ts +263 -87
  322. package/src/index.ts +24 -8
  323. package/src/lib/blocker-action.ts +0 -28
  324. package/src/{api → lib}/dsh-client.ts +16 -2
  325. package/src/lib/market-index.ts +36 -0
  326. package/src/lib/react-types.ts +5 -0
  327. package/src/lib/react.ts +1 -40
  328. package/src/lib/text.test.ts +2 -2
  329. package/src/lib/ui.test.ts +6 -5
  330. package/src/lib/ui.ts +3 -9
  331. package/src/testing/__tests__/declaration.test.ts +1 -1
  332. package/src/testing/data.ts +66 -0
  333. package/src/testing/declaration.ts +2 -2
  334. package/src/testing/host-fakes.ts +0 -38
  335. package/src/testing/needs.ts +80 -0
  336. package/src/testing.ts +2 -0
  337. package/dist/api/unit-board.d.ts +0 -39
  338. package/dist/api/unit-board.js +0 -45
  339. package/dist/api/unit.d.ts +0 -85
  340. package/dist/api/unit.js +0 -8
  341. package/dist/api/workbench-contract.d.ts +0 -44
  342. package/dist/components/MockStrip.css +0 -39
  343. package/dist/components/MockStrip.d.ts +0 -15
  344. package/dist/components/MockStrip.js +0 -8
  345. package/dist/components/SaveBar.css +0 -7
  346. package/dist/host/browser-find.d.ts +0 -38
  347. package/dist/host/browser-find.js +0 -242
  348. package/dist/host/browser-read.d.ts +0 -28
  349. package/dist/host/browser-read.js +0 -243
  350. package/dist/host/opencli-runtime.d.ts +0 -25
  351. package/dist/host/opencli-runtime.js +0 -56
  352. package/dist/host/opencli-window.d.ts +0 -2
  353. package/dist/host/opencli-window.js +0 -8
  354. package/dist/host/opencli.d.ts +0 -37
  355. package/dist/host/opencli.js +0 -155
  356. package/dist/host/unit-declaration.d.ts +0 -65
  357. package/dist/host/unit-declaration.js +0 -213
  358. package/dist/host/unit-libs.d.ts +0 -37
  359. package/dist/lib/diy-debug.d.ts +0 -80
  360. package/dist/lib/diy-debug.js +0 -88
  361. package/dist/lib/diy-record.d.ts +0 -135
  362. package/dist/lib/diy-record.js +0 -162
  363. package/dist/lib/lint-probe.d.ts +0 -1
  364. package/dist/lib/lint-probe.js +0 -6
  365. package/dist/lib/panel-state.d.ts +0 -120
  366. package/dist/lib/panel-state.js +0 -176
  367. package/src/api/__tests__/host-write.test.ts +0 -75
  368. package/src/api/__tests__/unit-board.test.ts +0 -76
  369. package/src/api/__tests__/unit.test.ts +0 -38
  370. package/src/api/unit-board.ts +0 -69
  371. package/src/api/unit.ts +0 -93
  372. package/src/api/workbench-contract.ts +0 -59
  373. package/src/host/__tests__/browser-find.test.ts +0 -330
  374. package/src/host/__tests__/browser-read.test.ts +0 -228
  375. package/src/host/__tests__/opencli-runtime.test.ts +0 -46
  376. package/src/host/browser-find.ts +0 -311
  377. package/src/host/browser-read.ts +0 -311
  378. package/src/host/opencli-runtime.ts +0 -79
  379. package/src/host/opencli-window.ts +0 -11
  380. package/src/host/opencli.ts +0 -213
  381. package/src/host/unit-libs.ts +0 -41
  382. package/src/lib/blocker-action.test.ts +0 -40
  383. /package/dist/{api/blocker.js → contract/adapters.js} +0 -0
  384. /package/dist/{api → contract}/blocker.d.ts +0 -0
  385. /package/dist/{api/dsh-client.js → contract/blocker.js} +0 -0
  386. /package/dist/{api/workbench-contract.js → contract/cli.js} +0 -0
  387. /package/dist/{host/unit-libs.js → contract/data.js} +0 -0
  388. /package/dist/{api → contract}/long-task.d.ts +0 -0
  389. /package/dist/{api → contract}/long-task.js +0 -0
  390. /package/src/{api → contract}/blocker.ts +0 -0
  391. /package/src/{api → contract}/long-task.ts +0 -0
@@ -23,6 +23,7 @@ export interface WorkspaceSnapshot {
23
23
 
24
24
  /**
25
25
  * 会话一行的来源(标题、空会话、在跑与否、被谁留住);retainedBy 按视图名记留住它的份数,mainView 大于 0 即正被主视图占着。
26
+ * projectionValues 是 dsh 的会话投影,外壳只读 `agentPreset` 一位(没选过模式时没有这一位)。
26
27
  */
27
28
  export interface SessionSummary {
28
29
  readonly id: string;
@@ -32,6 +33,7 @@ export interface SessionSummary {
32
33
  readonly updatedAt: number;
33
34
  readonly origin?: string;
34
35
  readonly retainedBy: Readonly<Partial<Record<string, number>>>;
36
+ readonly projectionValues?: Readonly<Record<string, unknown>>;
35
37
  }
36
38
 
37
39
  /**
@@ -254,7 +256,10 @@ export interface DshConversationService {
254
256
  * 浏览器侧的会话服务:快照加按 id 取作用域;create 是可选写口,不是每个 dsh 版本都有。
255
257
  */
256
258
  export interface DshSessionsService {
257
- readonly list: { getSnapshot(): SessionsSnapshot };
259
+ readonly list: {
260
+ getSnapshot(): SessionsSnapshot;
261
+ subscribe?(listener: () => void): () => void;
262
+ };
258
263
  scope(sessionId: string): unknown | undefined;
259
264
  create?(request: {
260
265
  readonly workspaceId?: string;
@@ -295,10 +300,19 @@ export interface DshSessionsRemote {
295
300
  }
296
301
 
297
302
  /**
298
- * dsh 客户端的远端写口集合;目前只有会话一家。
303
+ * remote.agentPresets 写口:给还没开跑的会话挑模式(同一件事就是模式选择器点一下);
304
+ * 会话发出第一条消息后 dsh 会拒(模式已锁)。
305
+ */
306
+ export interface DshAgentPresetsRemote {
307
+ select(sessionId: string, presetId: string): Promise<unknown>;
308
+ }
309
+
310
+ /**
311
+ * dsh 客户端的远端写口集合;会话与模式两家。
299
312
  */
300
313
  export interface DshClientRemote {
301
314
  readonly sessions: DshSessionsRemote;
315
+ readonly agentPresets?: DshAgentPresetsRemote;
302
316
  }
303
317
 
304
318
  /**
@@ -0,0 +1,36 @@
1
+ import type { MarketIndexSource, MarketLocalizedText } from '../contract/protocol/market-index.js';
2
+
3
+ const BRANCH = /^[A-Za-z0-9][A-Za-z0-9._/-]*$/;
4
+
5
+ export function marketBranchOk(value: string): boolean {
6
+ const branch = value.trim();
7
+ return (
8
+ BRANCH.test(branch) &&
9
+ !branch.includes('..') &&
10
+ !branch.endsWith('/') &&
11
+ !branch.endsWith('.') &&
12
+ !branch.includes('@{')
13
+ );
14
+ }
15
+
16
+ export function marketText(value: MarketLocalizedText | undefined, locale: string): string {
17
+ if (value === undefined) return '';
18
+ const zh = value.zh ?? '';
19
+ const en = value.en ?? '';
20
+ return locale.toLowerCase().startsWith('zh') ? zh || en : en || zh;
21
+ }
22
+
23
+ export function marketInstallTarget(
24
+ name: string,
25
+ version: string,
26
+ source: MarketIndexSource,
27
+ ): { readonly spec: string; readonly registry?: string } {
28
+ if (source.type === 'npm') {
29
+ const registry = (source.registry ?? '').trim();
30
+ return { spec: `${name}@${version}`, ...(registry === '' ? {} : { registry }) };
31
+ }
32
+ const base = `git+${source.url.trim().replace(/^git\+/, '')}#${source.commit}`;
33
+ const path = (source.path ?? '').trim().replace(/^\/+/, '');
34
+ return { spec: path === '' ? base : `${base}&path:/${path}` };
35
+ }
36
+
@@ -0,0 +1,5 @@
1
+ /**
2
+ * 从 react 借来的三个类型(`ReactNode` / `CSSProperties` / `ChangeEvent`)—— 模块从这里拿,
3
+ * 就不必自己直接依赖 react。只取类型:编译期擦除,不进任何产物。
4
+ */
5
+ export type { ReactNode, CSSProperties, ChangeEvent } from 'react';
package/src/lib/react.ts CHANGED
@@ -2,60 +2,21 @@ import type * as ReactTypes from 'react';
2
2
 
3
3
  const react = require('react') as typeof ReactTypes;
4
4
 
5
- /**
6
- * React 的 `createElement` 换个短名字再导出 —— 这套代码用 `h(...)` 写元素。
7
- */
8
5
  export const h = react.createElement;
9
6
 
10
- /**
11
- * React 的 `Fragment` 原样再导出 —— 模块从这里拿,就不必自己直接依赖 react。
12
- */
13
7
  export const Fragment = react.Fragment;
14
8
 
15
- /**
16
- * React 的 `Component` 原样再导出 —— 模块从这里拿,就不必自己直接依赖 react。
17
- */
18
9
  export const Component = react.Component;
19
10
 
20
- /**
21
- * React 的 `createContext` 原样再导出 —— 模块从这里拿,就不必自己直接依赖 react。
22
- */
23
11
  export const createContext = react.createContext;
24
- /**
25
- * React 的 `useContext` 原样再导出 —— 模块从这里拿,就不必自己直接依赖 react。
26
- */
27
12
  export const useContext = react.useContext;
28
13
 
29
- /**
30
- * React 的 `useState` 原样再导出 —— 模块从这里拿,就不必自己直接依赖 react。
31
- */
32
14
  export const useState = react.useState;
33
- /**
34
- * React 的 `useEffect` 原样再导出 —— 模块从这里拿,就不必自己直接依赖 react。
35
- */
36
15
  export const useEffect = react.useEffect;
37
- /**
38
- * React 的 `useLayoutEffect` 原样再导出 —— 模块从这里拿,就不必自己直接依赖 react。
39
- */
40
16
  export const useLayoutEffect = react.useLayoutEffect;
41
- /**
42
- * React 的 `useMemo` 原样再导出 —— 模块从这里拿,就不必自己直接依赖 react。
43
- */
44
17
  export const useMemo = react.useMemo;
45
- /**
46
- * React 的 `useCallback` 原样再导出 —— 模块从这里拿,就不必自己直接依赖 react。
47
- */
48
18
  export const useCallback = react.useCallback;
49
- /**
50
- * React 的 `useRef` 原样再导出 —— 模块从这里拿,就不必自己直接依赖 react。
51
- */
52
19
  export const useRef = react.useRef;
53
- /**
54
- * React 的 `useSyncExternalStore` 原样再导出 —— 模块从这里拿,就不必自己直接依赖 react。
55
- */
56
20
  export const useSyncExternalStore = react.useSyncExternalStore;
57
21
 
58
- /**
59
- * 从 react 借来的三个类型(`ReactNode` / `CSSProperties` / `ChangeEvent`)—— 模块从这里拿,就不必自己直接依赖 react。
60
- */
61
- export type { ReactNode, CSSProperties, ChangeEvent } from 'react';
22
+ export type { ReactNode, CSSProperties, ChangeEvent } from './react-types.js';
@@ -16,7 +16,7 @@ describe('parseJsonLoose', () => {
16
16
  expect(parseJsonLoose('[1,2]\n完成')).toEqual([1, 2]);
17
17
  });
18
18
 
19
- it('★ 噪音行自己带方括号时也不认错起点(真机:pagoda 的调试命令先打两行带 [] 的话)', () => {
19
+ it('★ 噪音行自己带方括号时也不认错起点(真机:acme 的调试命令先打两行带 [] 的话)', () => {
20
20
  const stdout = [
21
21
  '数据源 [dify_dataset] 调试成功',
22
22
  '结构类型: 3, 字段: code, name',
@@ -38,7 +38,7 @@ describe('parseJsonLoose', () => {
38
38
  ]);
39
39
  });
40
40
 
41
- it('解析不出来给 undefined,让调用方报 coding-bad-output', () => {
41
+ it('解析不出来给 undefined,让调用方报 demo-bad-output', () => {
42
42
  expect(parseJsonLoose('')).toBeUndefined();
43
43
  expect(parseJsonLoose('not json at all')).toBeUndefined();
44
44
  expect(parseJsonLoose('[1,2')).toBeUndefined();
@@ -1,3 +1,4 @@
1
+ import dayjs from 'dayjs';
1
2
  import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
2
3
  import {
3
4
  cx,
@@ -15,7 +16,7 @@ const t: TimeTranslate = (key, params) => {
15
16
  return `${key}:${String(params.n ?? params.t ?? '')}`;
16
17
  };
17
18
 
18
- const NOW = Date.parse('2026-09-27T12:00:00.000Z');
19
+ const NOW = dayjs('2026-09-27T12:00:00.000Z').valueOf();
19
20
 
20
21
  describe('cx', () => {
21
22
  it('拼上真值、丢掉假值', () => {
@@ -55,7 +56,7 @@ describe('relativeTime', () => {
55
56
 
56
57
  expect(old).not.toContain('time.');
57
58
  expect(old.match(/:/g)).toHaveLength(2);
58
- expect(old).toContain(String(new Date(NOW).getFullYear()));
59
+ expect(old).toContain(String(dayjs(NOW).year()));
59
60
  });
60
61
 
61
62
  it('非法时间戳给空串而不是 NaN', () => {
@@ -125,12 +126,12 @@ describe('parseLocalTimestamp', () => {
125
126
  it('按本地时区解析 Coding 的时间戳形态', () => {
126
127
  const parsed = parseLocalTimestamp('2026-09-27 08:18:36');
127
128
  expect(Number.isFinite(parsed)).toBe(true);
128
- expect(parsed).toBe(new Date('2026-09-27T08:18:36').getTime());
129
+ expect(parsed).toBe(dayjs('2026-09-27T08:18:36').valueOf());
129
130
  });
130
131
 
131
132
  it('也接受 ISO 的 T 分隔写法', () => {
132
133
  expect(parseLocalTimestamp('2026-09-27T08:18:36')).toBe(
133
- new Date('2026-09-27T08:18:36').getTime(),
134
+ dayjs('2026-09-27T08:18:36').valueOf(),
134
135
  );
135
136
  });
136
137
 
@@ -142,7 +143,7 @@ describe('parseLocalTimestamp', () => {
142
143
 
143
144
  it('容忍首尾空白', () => {
144
145
  expect(parseLocalTimestamp(' 2026-09-27 08:18:36 ')).toBe(
145
- new Date('2026-09-27T08:18:36').getTime(),
146
+ dayjs('2026-09-27T08:18:36').valueOf(),
146
147
  );
147
148
  });
148
149
  });
package/src/lib/ui.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import dayjs from 'dayjs';
1
2
  /**
2
3
  * 拼类名:只留真值、用空格连接(`false` / `null` / `undefined` / 空串都丢掉)。
3
4
  * @param parts - 若干类名或条件值。
@@ -91,14 +92,7 @@ export function relativeTime(epochMs: number, t: TimeTranslate): string {
91
92
  if (diff < 60 * MINUTE) return t('time.minutes', { n: Math.floor(diff / MINUTE) });
92
93
  if (diff < 24 * 60 * MINUTE) return t('time.hours', { n: Math.floor(diff / (60 * MINUTE)) });
93
94
  if (diff < 7 * 24 * 60 * MINUTE) return t('time.days', { n: Math.floor(diff / (24 * 60 * MINUTE)) });
94
- return new Date(epochMs).toLocaleString(undefined, {
95
- year: 'numeric',
96
- month: 'numeric',
97
- day: 'numeric',
98
- hour: '2-digit',
99
- minute: '2-digit',
100
- second: '2-digit',
101
- });
95
+ return dayjs(epochMs).format('YYYY/M/D HH:mm:ss');
102
96
  }
103
97
 
104
98
  /**
@@ -122,5 +116,5 @@ const LOCAL_TIMESTAMP = /^(\d{4})-(\d{2})-(\d{2})[ T](\d{2}):(\d{2}):(\d{2})$/;
122
116
  export function parseLocalTimestamp(text: string | null | undefined): number {
123
117
  const raw = String(text ?? '').trim();
124
118
  if (!LOCAL_TIMESTAMP.test(raw)) return Number.NaN;
125
- return new Date(raw.replace(' ', 'T')).getTime();
119
+ return dayjs(raw.replace(' ', 'T')).valueOf();
126
120
  }
@@ -19,7 +19,7 @@ afterEach(() => {
19
19
  });
20
20
 
21
21
  const DECLARED = {
22
- apiVersion: 1,
22
+ apiVersion: 2,
23
23
  unit: 'demo',
24
24
  card: { titleKey: 'demo.cardTitle', order: 7 },
25
25
  tools: [{ name: 'workbench_demo_list', writes: false }],
@@ -0,0 +1,66 @@
1
+ import type { CallOverrides, DataReader, DataRequest, RecipeCalls, RecipeResults, RequestRecipe } from '../contract/data.js';
2
+
3
+ export interface RecipeCall {
4
+ readonly kind: 'request' | 'submit' | 'many';
5
+ readonly recipe: RequestRecipe;
6
+ readonly overrides?: CallOverrides | undefined;
7
+ readonly calls?: RecipeCalls | undefined;
8
+ }
9
+
10
+ const NO_DATA = {
11
+ ok: false as const,
12
+ error: { code: 'invalid-request' as const, message: '测试没有注入 DataReader' },
13
+ };
14
+
15
+ function filled(names: readonly string[], value: unknown): RecipeResults {
16
+ const out: Record<string, unknown> = {};
17
+ for (const name of names) out[name] = value;
18
+ return out as RecipeResults;
19
+ }
20
+
21
+ export function createNoopDataReader(): DataReader {
22
+ return {
23
+ read: async () => NO_DATA,
24
+ request: async () => NO_DATA,
25
+ requestMany: async <T = unknown>(_recipe: RequestRecipe, calls: RecipeCalls): Promise<RecipeResults<T>> =>
26
+ filled(Object.keys(calls), NO_DATA) as RecipeResults<T>,
27
+ submit: async () => NO_DATA,
28
+ };
29
+ }
30
+
31
+ export function createFakeDataReader(
32
+ reply: unknown | ((request: DataRequest, index: number) => unknown) = { ok: true, data: null },
33
+ recipeReply: unknown | ((call: RecipeCall, index: number) => unknown) = { ok: true, data: null },
34
+ ): DataReader & {
35
+ readonly requests: readonly DataRequest[];
36
+ readonly calls: readonly RecipeCall[];
37
+ } {
38
+ const requests: DataRequest[] = [];
39
+ const calls: RecipeCall[] = [];
40
+ const answer = (call: RecipeCall): unknown =>
41
+ typeof recipeReply === 'function' ? recipeReply(call, calls.length - 1) : recipeReply;
42
+ const reader = {
43
+ async read(request: DataRequest): Promise<unknown> {
44
+ requests.push(request);
45
+ return typeof reply === 'function' ? reply(request, requests.length - 1) : reply;
46
+ },
47
+ async request(recipe: RequestRecipe, overrides?: CallOverrides): Promise<unknown> {
48
+ calls.push({ kind: 'request', recipe, overrides });
49
+ return answer(calls[calls.length - 1] as RecipeCall);
50
+ },
51
+ async requestMany(recipe: RequestRecipe, plan: RecipeCalls): Promise<RecipeResults> {
52
+ calls.push({ kind: 'many', recipe, calls: plan });
53
+ const answered = answer(calls[calls.length - 1] as RecipeCall);
54
+ return typeof answered === 'object' && answered !== null && !('ok' in answered)
55
+ ? (answered as RecipeResults)
56
+ : filled(Object.keys(plan), answered);
57
+ },
58
+ async submit(recipe: RequestRecipe, overrides?: CallOverrides): Promise<unknown> {
59
+ calls.push({ kind: 'submit', recipe, overrides });
60
+ return answer(calls[calls.length - 1] as RecipeCall);
61
+ },
62
+ } as unknown as DataReader;
63
+ return Object.assign(reader, { requests, calls });
64
+ }
65
+
66
+ export const fakeDataReader = createFakeDataReader;
@@ -1,7 +1,7 @@
1
1
  import fs from 'node:fs';
2
2
  import { fileURLToPath } from 'node:url';
3
- import type { UnitManifest } from '../api/unit.js';
4
- import { readDeclaration } from '../host/unit-declaration.js';
3
+ import type { UnitManifest } from '../contract/unit.js';
4
+ import { readDeclaration } from '../contract/unit-declaration.js';
5
5
 
6
6
  export function declarationOfPackage(pkg: string, packageJson: URL | string): UnitManifest {
7
7
  const at = typeof packageJson === 'string' ? packageJson : fileURLToPath(packageJson);
@@ -1,6 +1,5 @@
1
1
  import { setTimeout as delay } from 'node:timers/promises';
2
2
  import type { DshShell } from '../api/dsh.js';
3
- import type { Opencli, OpencliResult } from '../host/opencli.js';
4
3
 
5
4
  export interface ShellCall {
6
5
  command: string;
@@ -66,43 +65,6 @@ export function createFakeShell(replies: ShellReply[] | ((call: ShellCall, index
66
65
  };
67
66
  }
68
67
 
69
- export interface OpencliCall {
70
- args: readonly string[];
71
- key?: string;
72
- workdir?: string;
73
- session?: string;
74
- refresh?: boolean;
75
- }
76
-
77
- export function createFakeOpencli(
78
- replies: Array<unknown | Error> | ((call: OpencliCall, index: number) => unknown | Error) = [],
79
- ) {
80
- const calls: OpencliCall[] = [];
81
-
82
- const opencli: Opencli = {
83
- async json(args, options = {}) {
84
- const call: OpencliCall = {
85
- args,
86
- ...(options.key === undefined ? {} : { key: options.key }),
87
- ...(options.workdir === undefined ? {} : { workdir: options.workdir }),
88
- ...(options.session === undefined ? {} : { session: options.session }),
89
- };
90
- calls.push(call);
91
- const index = calls.length - 1;
92
- const reply =
93
- typeof replies === 'function' ? replies(call, index) : (replies[index] ?? []);
94
-
95
- if (reply instanceof Error) throw reply;
96
- return { value: reply, at: Date.now() } satisfies OpencliResult;
97
- },
98
- };
99
-
100
- return {
101
- opencli,
102
- calls,
103
- keys: () => calls.map((call) => call.key),
104
- };
105
- }
106
68
 
107
69
  export function createFakeLogger() {
108
70
  const warnings: string[] = [];
@@ -0,0 +1,80 @@
1
+ import type {
2
+ BinNeed,
3
+ EnvNeed,
4
+ ExtensionNeed,
5
+ LibNeed,
6
+ Need,
7
+ NeedKind,
8
+ SupplySource,
9
+ } from '../contract/needs.js';
10
+ import type { NeedState } from '../contract/unit-capability.js';
11
+ import type { UnitCapability } from '../contract/unit-capability.js';
12
+ import type { UnitManifest } from '../contract/unit.js';
13
+
14
+ export const fakeNpmSource: SupplySource = {
15
+ kind: 'npm',
16
+ registryEnv: 'WB_TEST_REGISTRY',
17
+ registryDefault: 'https://registry.invalid/',
18
+ };
19
+
20
+ export function extensionNeedOf(name: string, extra: Partial<ExtensionNeed> = {}): ExtensionNeed {
21
+ return {
22
+ kind: 'extension',
23
+ runtime: 'opencli',
24
+ name,
25
+ commands: [`${name}-read`],
26
+ purpose: '测试',
27
+ ...extra,
28
+ };
29
+ }
30
+
31
+ export function libNeedOf(name: string, extra: Partial<LibNeed> = {}): LibNeed {
32
+ return { kind: 'lib', name, purpose: '测试', ...extra };
33
+ }
34
+
35
+ export function binNeedOf(name: string, extra: Partial<BinNeed> = {}): BinNeed {
36
+ return { kind: 'bin', name, purpose: '测试', ...extra };
37
+ }
38
+
39
+ export function envNeedOf(name: string, extra: Partial<EnvNeed> = {}): EnvNeed {
40
+ return { kind: 'env', name, purpose: '测试', ...extra };
41
+ }
42
+
43
+ export function manifestOf(
44
+ options: {
45
+ readonly id?: string | undefined;
46
+ readonly needs?: readonly Need[] | undefined;
47
+ readonly card?: UnitManifest['card'];
48
+ } = {},
49
+ ): UnitManifest {
50
+ return {
51
+ id: options.id ?? 'fixture',
52
+ card: options.card === undefined ? { titleKey: `${options.id ?? 'fixture'}.mine`, order: 10 } : options.card,
53
+ tools: [],
54
+ host: { inject: [] },
55
+ ...(options.needs === undefined ? {} : { needs: options.needs }),
56
+ };
57
+ }
58
+
59
+ export function needStateOf(
60
+ need: Need,
61
+ status: NeedState['status'] = 'ok',
62
+ extra: Partial<NeedState> = {},
63
+ ): NeedState {
64
+ return {
65
+ id: need.id ?? `${need.kind}:${need.name}`,
66
+ kind: need.kind as NeedKind,
67
+ name: need.name,
68
+ status,
69
+ detail: `测试:${need.name}`,
70
+ ...extra,
71
+ };
72
+ }
73
+
74
+ export function capabilityOf(
75
+ unit: string,
76
+ needs: readonly NeedState[] = [],
77
+ extra: Partial<UnitCapability> = {},
78
+ ): UnitCapability {
79
+ return { unit, status: needs.some((need) => need.status !== 'ok') ? 'missing' : 'ok', needs, ...extra };
80
+ }
package/src/testing.ts CHANGED
@@ -1,2 +1,4 @@
1
1
  export * from './testing/host-fakes.js';
2
2
  export * from './testing/declaration.js';
3
+ export * from './testing/needs.js';
4
+ export * from './testing/data.js';
@@ -1,39 +0,0 @@
1
- import type { ModuleBlocker } from './blocker.js';
2
- import type { CapabilityPayload } from './workbench-contract.js';
3
- import type { ApiError } from './workbench-client.js';
4
- /**
5
- * 卡片闸的两种档:capability 按环境读数判,none 无条件放行。
6
- */
7
- export type GateMode = 'capability' | 'none';
8
- /**
9
- * 一次放行判定的结果;gated 为假时卡片不画。
10
- */
11
- export interface UnitGate {
12
- readonly gated: boolean;
13
- }
14
- /**
15
- * 判这张卡现在能不能画。
16
- * @param capability 环境读数;还没读到给 null。
17
- * @param mode 闸档。
18
- * @returns mode 为 none 或读数还没到都放行(先放行让它读);读到明确不通过(ok 与 unchecked 之外)才拦。
19
- */
20
- export declare function gateOf(capability: CapabilityPayload | null, mode: GateMode): UnitGate;
21
- /**
22
- * 一个单元攒下的卡住态:blocker 顶掉卡片,notice 只提示;组装方产出,卡片消费。
23
- */
24
- export interface UnitBlockers {
25
- readonly blocker?: ModuleBlocker;
26
- readonly notice?: ModuleBlocker;
27
- }
28
- /**
29
- * 把候选卡住态分档,每档只留第一个。
30
- * @param candidates 候选(可能含 undefined),按优先级从高到低给。
31
- * @returns 分出的 blocker 与 notice;已经有 blocker 时不带 notice(挡住就不必再提示)。
32
- */
33
- export declare function splitBlocker(candidates: readonly (ModuleBlocker | undefined)[]): UnitBlockers;
34
- /**
35
- * 由读口错误算出「出错搭车强探」的防抖键:同一个键只自动重探一次。
36
- * @param error 读口错误;undefined 表示这次没有错误。
37
- * @returns 键字符串;空 code 归一到 unknown。
38
- */
39
- export declare function probeKeyOf(error: ApiError | undefined): string | null;
@@ -1,45 +0,0 @@
1
- /**
2
- * 判这张卡现在能不能画。
3
- * @param capability 环境读数;还没读到给 null。
4
- * @param mode 闸档。
5
- * @returns mode 为 none 或读数还没到都放行(先放行让它读);读到明确不通过(ok 与 unchecked 之外)才拦。
6
- */
7
- export function gateOf(capability, mode) {
8
- if (mode === 'none')
9
- return { gated: true };
10
- if (capability === null)
11
- return { gated: true };
12
- return { gated: capability.status === 'ok' || capability.status === 'unchecked' };
13
- }
14
- /**
15
- * 把候选卡住态分档,每档只留第一个。
16
- * @param candidates 候选(可能含 undefined),按优先级从高到低给。
17
- * @returns 分出的 blocker 与 notice;已经有 blocker 时不带 notice(挡住就不必再提示)。
18
- */
19
- export function splitBlocker(candidates) {
20
- let blocker;
21
- let notice;
22
- for (const candidate of candidates) {
23
- if (candidate === undefined)
24
- continue;
25
- if (candidate.severity === 'block') {
26
- blocker ??= candidate;
27
- continue;
28
- }
29
- notice ??= candidate;
30
- }
31
- return {
32
- ...(blocker === undefined ? {} : { blocker }),
33
- ...(blocker !== undefined || notice === undefined ? {} : { notice }),
34
- };
35
- }
36
- /**
37
- * 由读口错误算出「出错搭车强探」的防抖键:同一个键只自动重探一次。
38
- * @param error 读口错误;undefined 表示这次没有错误。
39
- * @returns 键字符串;空 code 归一到 unknown。
40
- */
41
- export function probeKeyOf(error) {
42
- if (error === undefined)
43
- return null;
44
- return error.code === '' ? 'unknown' : error.code;
45
- }
@@ -1,85 +0,0 @@
1
- /**
2
- * 一张卡片在清单里的静态声明(文案键加排序位);默认显不显示由运行期面板配置定。
3
- */
4
- export interface UnitCard {
5
- readonly titleKey: string;
6
- readonly order: number;
7
- }
8
- /**
9
- * 一条工具在清单里的样子:全名加会不会写;审批按 writes 认领。
10
- */
11
- export interface UnitTool {
12
- readonly name: string;
13
- readonly writes: boolean;
14
- }
15
- /**
16
- * 模块要外壳的哪些服务:inject 缺一个就挂不上,optional 缺了照挂。
17
- */
18
- export interface UnitHostNeeds {
19
- readonly inject: readonly string[];
20
- readonly optional?: readonly string[];
21
- }
22
- /**
23
- * 一个 opencli 插件的来源三选一(git / 本地 / npm);npm 那支的安装源先看 registryEnv 那个环境变量,没设才用 registryDefault。
24
- */
25
- export type PluginSource = {
26
- readonly kind: 'git';
27
- readonly url: string;
28
- } | {
29
- readonly kind: 'local';
30
- readonly env: string;
31
- } | {
32
- readonly kind: 'npm';
33
- readonly package: string;
34
- readonly registryEnv: string;
35
- readonly registryDefault?: string;
36
- };
37
- /**
38
- * 模块要的一个 opencli 插件:名字、它得提供的命令,以及装它的来源(没写就是不代装)。
39
- */
40
- export interface UnitPluginNeed {
41
- readonly name: string;
42
- readonly commands?: readonly string[];
43
- readonly installSource?: PluginSource;
44
- }
45
- /**
46
- * 模块要的一个共用库:名字、期望范围与它为什么要这个版本(purpose 会进申报文案)。
47
- */
48
- export interface UnitLibNeed {
49
- readonly name: string;
50
- readonly version?: string | undefined;
51
- readonly registryEnv: string;
52
- readonly registryDefault: string;
53
- readonly purpose: string;
54
- }
55
- /**
56
- * 模块的整份环境需要:一条自检命令,加上插件与共用库两张表。
57
- */
58
- export interface UnitEnvNeeds {
59
- readonly command?: string;
60
- readonly plugins?: readonly UnitPluginNeed[];
61
- readonly libs?: readonly UnitLibNeed[];
62
- }
63
- /**
64
- * 已装插件与源上最新版那一对,用来判该不该提示升级;latest 缺省表示还没查到。
65
- */
66
- export interface PluginRelease {
67
- readonly installed: string;
68
- readonly latest?: string;
69
- }
70
- /**
71
- * 装配期用的模块清单:单元 id、卡片、工具与宿主 / 环境需要,比声明少一层协议包装。
72
- */
73
- export interface UnitManifest {
74
- readonly id: string;
75
- readonly card: UnitCard | null;
76
- readonly tools: readonly UnitTool[];
77
- readonly host: UnitHostNeeds;
78
- readonly env?: UnitEnvNeeds;
79
- }
80
- /**
81
- * 判这个模块要不要往外装东西。
82
- * @param manifest 模块清单。
83
- * @returns 插件与共用库两张表都空时给 false。
84
- */
85
- export declare function hasEnvSupply(manifest: UnitManifest): boolean;
package/dist/api/unit.js DELETED
@@ -1,8 +0,0 @@
1
- /**
2
- * 判这个模块要不要往外装东西。
3
- * @param manifest 模块清单。
4
- * @returns 插件与共用库两张表都空时给 false。
5
- */
6
- export function hasEnvSupply(manifest) {
7
- return (manifest.env?.plugins ?? []).length > 0 || (manifest.env?.libs ?? []).length > 0;
8
- }