@deepseek-harness-tui/dsh-tui 0.8.1 → 0.8.2

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 (240) hide show
  1. package/README.md +22 -13
  2. package/dsh-ecosystem-spec/protocols/profile-definitions.d.ts +13 -0
  3. package/dsh-ecosystem-spec/protocols/profile-definitions.js +59 -0
  4. package/dsh-ecosystem-spec/protocols/tui-channel-http.d.ts +15 -0
  5. package/dsh-ecosystem-spec/protocols/tui-channel-http.js +32 -0
  6. package/dsh-ecosystem-spec/protocols/tui-channel.d.ts +59 -0
  7. package/dsh-ecosystem-spec/protocols/tui-channel.js +166 -0
  8. package/dsh-ecosystem-spec/protocols/tui-contributions.d.ts +42 -0
  9. package/dsh-ecosystem-spec/protocols/tui-contributions.js +143 -0
  10. package/dsh-ecosystem-spec/registry/README.md +14 -0
  11. package/dsh-ecosystem-spec/registry/contracts/scene-v1alpha1.json +13 -0
  12. package/dsh-ecosystem-spec/registry/contracts/settings-section-v1alpha1.json +13 -0
  13. package/dsh-ecosystem-spec/registry/contracts/tui-channel-v1alpha1.json +30 -0
  14. package/dsh-ecosystem-spec/registry/contracts/workspace-provider-v1alpha1.json +6 -0
  15. package/{ecosystem-spec → dsh-ecosystem-spec}/registry/permissions-0.1.json +1 -1
  16. package/dsh-ecosystem-spec/registry/registry-0.15.json +149 -0
  17. package/lib/types/command-trees.d.ts +2 -1
  18. package/lib/types/command-trees.d.ts.map +1 -1
  19. package/lib/types/command-trees.js +1 -1
  20. package/lib/types/components/LoadedContextPanel.d.ts +10 -5
  21. package/lib/types/components/LoadedContextPanel.d.ts.map +1 -1
  22. package/lib/types/components/LoadedContextPanel.js +18 -7
  23. package/lib/types/components/LogoV2.d.ts.map +1 -1
  24. package/lib/types/components/LogoV2.js +16 -7
  25. package/lib/types/components/Markdown.d.ts +13 -1
  26. package/lib/types/components/Markdown.d.ts.map +1 -1
  27. package/lib/types/components/Markdown.js +15 -1
  28. package/lib/types/components/MessageList.d.ts +3 -1
  29. package/lib/types/components/MessageList.d.ts.map +1 -1
  30. package/lib/types/components/MessageList.js +90 -9
  31. package/lib/types/components/PromptInput.d.ts.map +1 -1
  32. package/lib/types/components/PromptInput.js +26 -12
  33. package/lib/types/components/StreamingMarkdown.d.ts +2 -8
  34. package/lib/types/components/StreamingMarkdown.d.ts.map +1 -1
  35. package/lib/types/components/StreamingMarkdown.js +51 -9
  36. package/lib/types/components/activityFrames.d.ts +1 -1
  37. package/lib/types/components/activityFrames.d.ts.map +1 -1
  38. package/lib/types/components/activityFrames.js +4 -1
  39. package/lib/types/components/messages/AssistantThinkingMessage.d.ts +5 -1
  40. package/lib/types/components/messages/AssistantThinkingMessage.d.ts.map +1 -1
  41. package/lib/types/components/messages/AssistantThinkingMessage.js +26 -3
  42. package/lib/types/components/messages/AssistantToolUseMessage.d.ts.map +1 -1
  43. package/lib/types/components/messages/AssistantToolUseMessage.js +12 -1
  44. package/lib/types/dsh-adapter/channel.d.ts +31 -4
  45. package/lib/types/dsh-adapter/channel.d.ts.map +1 -1
  46. package/lib/types/dsh-adapter/channel.js +267 -102
  47. package/lib/types/dsh-adapter/childStderr.d.ts.map +1 -1
  48. package/lib/types/dsh-adapter/childStderr.js +10 -0
  49. package/lib/types/dsh-adapter/command-attribution.d.ts.map +1 -1
  50. package/lib/types/dsh-adapter/command-attribution.js +2 -2
  51. package/lib/types/dsh-adapter/command-trees.d.ts +7 -1
  52. package/lib/types/dsh-adapter/command-trees.d.ts.map +1 -1
  53. package/lib/types/dsh-adapter/command-trees.js +70 -20
  54. package/lib/types/dsh-adapter/component-identity.d.ts +5 -0
  55. package/lib/types/dsh-adapter/component-identity.d.ts.map +1 -1
  56. package/lib/types/dsh-adapter/component-identity.js +14 -14
  57. package/lib/types/dsh-adapter/decision-guard.d.ts.map +1 -1
  58. package/lib/types/dsh-adapter/decision-guard.js +10 -16
  59. package/lib/types/dsh-adapter/dialogs.d.ts +2 -3
  60. package/lib/types/dsh-adapter/dialogs.d.ts.map +1 -1
  61. package/lib/types/dsh-adapter/dialogs.js +114 -60
  62. package/lib/types/dsh-adapter/effect-ledger.d.ts +0 -8
  63. package/lib/types/dsh-adapter/effect-ledger.d.ts.map +1 -1
  64. package/lib/types/dsh-adapter/effect-ledger.js +73 -53
  65. package/lib/types/dsh-adapter/extension-events.d.ts.map +1 -1
  66. package/lib/types/dsh-adapter/extension-events.js +39 -1
  67. package/lib/types/dsh-adapter/grants.d.ts.map +1 -1
  68. package/lib/types/dsh-adapter/grants.js +43 -14
  69. package/lib/types/dsh-adapter/host-access.d.ts +37 -0
  70. package/lib/types/dsh-adapter/host-access.d.ts.map +1 -0
  71. package/lib/types/dsh-adapter/host-access.js +652 -0
  72. package/lib/types/dsh-adapter/host-descriptor.d.ts +2 -2
  73. package/lib/types/dsh-adapter/host-descriptor.d.ts.map +1 -1
  74. package/lib/types/dsh-adapter/host-descriptor.js +31 -8
  75. package/lib/types/dsh-adapter/index.d.ts +4 -0
  76. package/lib/types/dsh-adapter/index.d.ts.map +1 -1
  77. package/lib/types/dsh-adapter/index.js +1 -0
  78. package/lib/types/dsh-adapter/message-observer.d.ts +10 -15
  79. package/lib/types/dsh-adapter/message-observer.d.ts.map +1 -1
  80. package/lib/types/dsh-adapter/message-observer.js +114 -70
  81. package/lib/types/dsh-adapter/plugin-host.d.ts +39 -6
  82. package/lib/types/dsh-adapter/plugin-host.d.ts.map +1 -1
  83. package/lib/types/dsh-adapter/plugin-host.js +139 -44
  84. package/lib/types/dsh-adapter/plugin-storage.d.ts +0 -5
  85. package/lib/types/dsh-adapter/plugin-storage.d.ts.map +1 -1
  86. package/lib/types/dsh-adapter/plugin-storage.js +48 -36
  87. package/lib/types/dsh-adapter/plugin.d.ts.map +1 -1
  88. package/lib/types/dsh-adapter/plugin.js +80 -16
  89. package/lib/types/dsh-adapter/promptDebug.d.ts +0 -6
  90. package/lib/types/dsh-adapter/promptDebug.d.ts.map +1 -1
  91. package/lib/types/dsh-adapter/promptDebug.js +13 -4
  92. package/lib/types/dsh-adapter/renderers.d.ts +6 -14
  93. package/lib/types/dsh-adapter/renderers.d.ts.map +1 -1
  94. package/lib/types/dsh-adapter/renderers.js +81 -46
  95. package/lib/types/dsh-adapter/scenes.d.ts +8 -4
  96. package/lib/types/dsh-adapter/scenes.d.ts.map +1 -1
  97. package/lib/types/dsh-adapter/scenes.js +136 -37
  98. package/lib/types/dsh-adapter/settings-sections.d.ts +7 -3
  99. package/lib/types/dsh-adapter/settings-sections.d.ts.map +1 -1
  100. package/lib/types/dsh-adapter/settings-sections.js +106 -26
  101. package/lib/types/dsh-adapter/shortcuts.d.ts +8 -10
  102. package/lib/types/dsh-adapter/shortcuts.d.ts.map +1 -1
  103. package/lib/types/dsh-adapter/shortcuts.js +108 -36
  104. package/lib/types/dsh-adapter/status.d.ts +6 -7
  105. package/lib/types/dsh-adapter/status.d.ts.map +1 -1
  106. package/lib/types/dsh-adapter/status.js +88 -22
  107. package/lib/types/dsh-adapter/workspaces.d.ts +16 -5
  108. package/lib/types/dsh-adapter/workspaces.d.ts.map +1 -1
  109. package/lib/types/dsh-adapter/workspaces.js +287 -170
  110. package/lib/types/extensions.d.ts +10 -5
  111. package/lib/types/extensions.d.ts.map +1 -1
  112. package/lib/types/extensions.js +11 -5
  113. package/lib/types/force-production-react.d.ts +1 -0
  114. package/lib/types/force-production-react.d.ts.map +1 -0
  115. package/lib/types/force-production-react.js +12 -0
  116. package/lib/types/i18n.d.ts +14 -6
  117. package/lib/types/i18n.d.ts.map +1 -1
  118. package/lib/types/i18n.js +4 -2
  119. package/lib/types/index.d.ts +1 -0
  120. package/lib/types/index.d.ts.map +1 -1
  121. package/lib/types/index.js +1 -0
  122. package/lib/types/ink/components/App.d.ts +2 -0
  123. package/lib/types/ink/components/App.d.ts.map +1 -1
  124. package/lib/types/ink/components/App.js +4 -0
  125. package/lib/types/ink/ink.d.ts +20 -3
  126. package/lib/types/ink/ink.d.ts.map +1 -1
  127. package/lib/types/ink/ink.js +57 -5
  128. package/lib/types/ink/log-update.d.ts.map +1 -1
  129. package/lib/types/ink/log-update.js +128 -9
  130. package/lib/types/ink/output.d.ts +28 -2
  131. package/lib/types/ink/output.d.ts.map +1 -1
  132. package/lib/types/ink/output.js +158 -12
  133. package/lib/types/ink/screen.d.ts +39 -0
  134. package/lib/types/ink/screen.d.ts.map +1 -1
  135. package/lib/types/ink/screen.js +117 -0
  136. package/lib/types/ink/terminal.d.ts.map +1 -1
  137. package/lib/types/ink/terminal.js +10 -2
  138. package/lib/types/ink/wrapAnsi.d.ts +1 -1
  139. package/lib/types/ink/wrapAnsi.d.ts.map +1 -1
  140. package/lib/types/ink/wrapAnsi.js +29 -2
  141. package/lib/types/plugin-host.d.ts +13 -11
  142. package/lib/types/plugin-host.d.ts.map +1 -1
  143. package/lib/types/plugin-host.js +16 -16
  144. package/lib/types/plugin-spec/registry.d.ts +2 -2
  145. package/lib/types/plugin-spec/registry.d.ts.map +1 -1
  146. package/lib/types/plugin-spec/registry.js +113 -18
  147. package/lib/types/plugin-spec/tui-extension.d.ts.map +1 -1
  148. package/lib/types/plugin-spec/tui-extension.js +2 -0
  149. package/lib/types/plugin-spec/validate.d.ts.map +1 -1
  150. package/lib/types/plugin-spec/validate.js +20 -1
  151. package/lib/types/scenes.d.ts +2 -1
  152. package/lib/types/scenes.d.ts.map +1 -1
  153. package/lib/types/scenes.js +1 -1
  154. package/lib/types/screens/Chat.d.ts +3 -3
  155. package/lib/types/screens/Chat.d.ts.map +1 -1
  156. package/lib/types/screens/Chat.js +38 -17
  157. package/lib/types/screens/SessionBrowser.d.ts.map +1 -1
  158. package/lib/types/screens/SessionBrowser.js +10 -3
  159. package/lib/types/sessions/view.d.ts +3 -2
  160. package/lib/types/sessions/view.d.ts.map +1 -1
  161. package/lib/types/sessions/view.js +18 -0
  162. package/lib/types/settings-sections.d.ts +2 -1
  163. package/lib/types/settings-sections.d.ts.map +1 -1
  164. package/lib/types/settings-sections.js +1 -1
  165. package/lib/types/utils/execFileNoThrow.d.ts.map +1 -1
  166. package/lib/types/utils/execFileNoThrow.js +3 -0
  167. package/lib/types/workspaces.d.ts +2 -1
  168. package/lib/types/workspaces.d.ts.map +1 -1
  169. package/lib/types/workspaces.js +1 -1
  170. package/node_modules/@dsh-std/command/CHANGELOG.md +8 -0
  171. package/node_modules/@dsh-std/command/package.json +1 -1
  172. package/node_modules/@dsh-std/connection/CHANGELOG.md +8 -0
  173. package/node_modules/@dsh-std/connection/lib/memory.d.ts +1 -1
  174. package/node_modules/@dsh-std/connection/lib/memory.d.ts.map +1 -1
  175. package/node_modules/@dsh-std/connection/lib/memory.js +1 -0
  176. package/node_modules/@dsh-std/connection/lib/memory.js.map +1 -1
  177. package/node_modules/@dsh-std/connection/package.json +1 -1
  178. package/node_modules/@dsh-std/core/CHANGELOG.md +8 -0
  179. package/node_modules/@dsh-std/core/package.json +1 -1
  180. package/node_modules/@dsh-std/manifest/CHANGELOG.md +9 -0
  181. package/node_modules/@dsh-std/manifest/package.json +1 -1
  182. package/node_modules/@dsh-std/messages/CHANGELOG.md +8 -0
  183. package/node_modules/@dsh-std/messages/package.json +1 -1
  184. package/node_modules/@dsh-std/presentation/CHANGELOG.md +9 -0
  185. package/node_modules/@dsh-std/presentation/README.md +2 -1
  186. package/node_modules/@dsh-std/presentation/README.zh.md +2 -1
  187. package/node_modules/@dsh-std/presentation/lib/callback.d.ts +2 -0
  188. package/node_modules/@dsh-std/presentation/lib/callback.js +179 -0
  189. package/node_modules/@dsh-std/presentation/lib/callback.js.map +1 -0
  190. package/node_modules/@dsh-std/presentation/lib/index.d.ts +44 -1
  191. package/node_modules/@dsh-std/presentation/lib/index.d.ts.map +1 -1
  192. package/node_modules/@dsh-std/presentation/lib/index.js +6 -3
  193. package/node_modules/@dsh-std/presentation/lib/index.js.map +1 -1
  194. package/node_modules/@dsh-std/presentation/package.json +7 -3
  195. package/node_modules/@dsh-std/storage/CHANGELOG.md +8 -0
  196. package/node_modules/@dsh-std/storage/package.json +1 -1
  197. package/package.json +10 -5
  198. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/CHANGELOG.md +8 -0
  199. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/memory.d.ts +1 -1
  200. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/memory.d.ts.map +1 -1
  201. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/memory.js +1 -0
  202. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/memory.js.map +1 -1
  203. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/package.json +1 -1
  204. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/CHANGELOG.md +8 -0
  205. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/package.json +1 -1
  206. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/CHANGELOG.md +9 -0
  207. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/package.json +1 -1
  208. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/CHANGELOG.md +9 -0
  209. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/README.md +2 -1
  210. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/README.zh.md +2 -1
  211. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/callback.d.ts +2 -0
  212. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/callback.js +179 -0
  213. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/callback.js.map +1 -0
  214. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/index.d.ts +44 -1
  215. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/index.d.ts.map +1 -1
  216. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/index.js +6 -3
  217. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/index.js.map +1 -1
  218. package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/package.json +7 -3
  219. package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/CHANGELOG.md +8 -0
  220. package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/package.json +1 -1
  221. package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/CHANGELOG.md +8 -0
  222. package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/package.json +1 -1
  223. package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/CHANGELOG.md +8 -0
  224. package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/package.json +1 -1
  225. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/CHANGELOG.md +8 -0
  226. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/memory.d.ts +1 -1
  227. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/memory.d.ts.map +1 -1
  228. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/memory.js +1 -0
  229. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/memory.js.map +1 -1
  230. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/package.json +1 -1
  231. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/CHANGELOG.md +8 -0
  232. package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/package.json +1 -1
  233. package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/CHANGELOG.md +8 -0
  234. package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/package.json +1 -1
  235. package/ecosystem-spec/registry/registry-0.15.json +0 -57
  236. /package/{ecosystem-spec → dsh-ecosystem-spec}/registry/contracts/decision-events-v1alpha1.json +0 -0
  237. /package/{ecosystem-spec → dsh-ecosystem-spec}/registry/host-descriptor.tui.example.json +0 -0
  238. /package/{ecosystem-spec → dsh-ecosystem-spec}/schemas/conformance-claim.schema.json +0 -0
  239. /package/{ecosystem-spec → dsh-ecosystem-spec}/schemas/effect-ledger-record.schema.json +0 -0
  240. /package/{ecosystem-spec → dsh-ecosystem-spec}/schemas/host-descriptor.schema.json +0 -0
package/README.md CHANGED
@@ -13,6 +13,12 @@
13
13
  <a href="LICENSE"><img alt="MIT License" src="https://img.shields.io/badge/license-MIT-263146?style=flat-square"></a>
14
14
  <img alt="Public beta" src="https://img.shields.io/badge/status-public%20beta-7da1de?style=flat-square">
15
15
  <img alt="官方收录" src="https://img.shields.io/badge/DeepSeek%20Harness%20官方公众号-收录-brightgreen">
16
+ <a href="https://github.com/ccch1mneyyy/dsh-TUI/stargazers"><img alt="GitHub stars" src="https://img.shields.io/github/stars/ccch1mneyyy/dsh-TUI?style=flat-square&color=4b6fff"></a>
17
+ <a href="https://www.npmjs.com/package/@deepseek-harness-tui/dsh-tui"><img alt="npm downloads" src="https://img.shields.io/npm/dm/@deepseek-harness-tui/dsh-tui?style=flat-square&color=4b6fff"></a>
18
+ </p>
19
+
20
+ <p align="center">
21
+ <a href="https://trendshift.io/repositories/146168" title="GitHub Trending 日榜 #7 · TypeScript 口径"><img alt="Trendshift" src="https://trendshift.io/api/badge/trendshift/repositories/146168/daily?language=TypeScript"></a>
16
22
  </p>
17
23
 
18
24
  # dsh-TUI
@@ -100,7 +106,7 @@ TUI 启动后会在后台检查 npm 是否有新版本;发现更新时会提
100
106
 
101
107
  | 键 | 功能 |
102
108
  |---|---|
103
- | `Enter` | 发送(`Shift+Enter` 换行);命令菜单打开时执行选中项 |
109
+ | `Enter` | 发送(`Shift+Enter` 换行,无法上报修饰键时可用 `Ctrl+J`);命令菜单打开时执行选中项 |
104
110
  | `Ctrl+C` | 中断当前回合;空闲时连按两次退出 |
105
111
  | `Esc` | 关闭命令/文件菜单;空闲双击清空输入;**空输入双击 = 时间回溯** |
106
112
  | `Ctrl+O` | 展开/收起详情(思考全文、工具参数与输出) |
@@ -143,12 +149,26 @@ macOS 自带 Terminal.app 会自行消费 `⌘` 快捷键,请继续使用 `Ctr
143
149
  |---|---|
144
150
  | 会话 | `/new` 新会话 · `/resume` 会话浏览器(搜索、预览、跨项目、折叠子 agent 运行) · `/rename` 重命名会话 · `/workspace resume|rename|open` 管理工作区 · `/clear` 清屏 · `/compact` 压缩 · `/export` 导出 Markdown · `/trace` 轨迹场景(亦可 `Ctrl+T`) |
145
151
  | 状态 | `/context` 已加载上下文明细 · `/status` 会话信息 · `/cost` token 用量 · `/doctor` 环境自检 · `/config` 配置来源 · `/init` 创建 AGENTS.md |
146
- | 模型 | `/model` 选择器 · `/thinking` 思考显示 · `/tokens` token 明细 · `/theme` 主题选择器 · `/lang` 中英界面切换 |
152
+ | 模型 | `/model` 选择器 · `/thinking` 思考显示 · `/tokens` token 明细 · `/theme` 主题选择器 · `/lang` 中英界面切换(`/settings` 中亦可选择) |
147
153
  | 账号/策略 | `/provider` 添加模型提供方 · `/login` 凭证状态 · `/logout` 登出说明 · `/permissions` 权限说明 · `/add-dir` 文件策略范围 · `/hooks` · `/mcp` |
148
154
  | 技能 | `/audit` 代码审计 · `/bug` bug 报告 · `/review` 代码评审 · `/practice` 编程练习 · `/pr_comments` PR 评论 · `/release-notes` 发布说明 · `/vuln-check` 漏洞检查 |
149
155
  | 其它 | `/agents` 子代理列表 · `/update` 自动更新并重启 · `/vim` · `/terminal-setup` · `/connect` · `/help` · `/exit` |
150
156
  | 注册表 | `/plan` `/goal`(DSH 命令注册表插件,随插件自动并入 `/` 菜单) |
151
157
 
158
+ ## 插件生态
159
+
160
+ 想为 dsh-TUI 做插件/扩展?欢迎加入生态!
161
+
162
+ - **接口与兼容性协定**:[终端交互生态插件准入规范与实施标准](https://github.com/T-Auto/dsh-ecosystem-spec)
163
+ - **插件开发指南**:[`docs/plugins.md`](docs/plugins.md)(接缝、契约、规范与验证清单)
164
+ - **生态组织**:[dsh-tui-ecosystem](https://github.com/dsh-tui-ecosystem)(社区插件与模板的家)
165
+ - **模板仓库**:[plugin-template](https://github.com/dsh-tui-ecosystem/plugin-template)(从模板起步,5 分钟出一个插件)
166
+ - **参考实现**:`dsh-working-activity`(实时工作状态行:TUI 槽位 + `activity/status` 会话事件双出口)
167
+
168
+ 核心仓库不迁移、社区插件独立成仓。组织只维护收录列表与准入规范,不对社区插件
169
+ 的功能、质量或安全作背书或担保;插件作者对自己的仓库保持完全所有权,并自行承担
170
+ 维护与安全责任。
171
+
152
172
  ## 文档
153
173
 
154
174
  | 主题 | 内容 |
@@ -256,18 +276,7 @@ pnpm smoke
256
276
  构建门禁。npm Git URL 安装通过 `prepare` 生成同一套运行时。渲染、问卷和工具卡
257
277
  改动还需运行对应回归脚本。
258
278
 
259
- ## 插件生态
260
-
261
- 想为 dsh-TUI 做插件/扩展?欢迎加入生态:
262
-
263
- - **插件开发指南**:[`docs/plugins.md`](docs/plugins.md)(接缝、契约、规范与验证清单)
264
- - **生态组织**:[dsh-tui-ecosystem](https://github.com/dsh-tui-ecosystem)(社区插件与模板的家)
265
- - **模板仓库**:[plugin-template](https://github.com/dsh-tui-ecosystem/plugin-template)(从模板起步,5 分钟出一个插件)
266
- - **参考实现**:`dsh-working-activity`(实时工作状态行:TUI 槽位 + `activity/status` 会话事件双出口)
267
279
 
268
- 核心仓库不迁移、社区插件独立成仓。组织只维护收录列表与准入规范,不对社区插件
269
- 的功能、质量或安全作背书或担保;插件作者对自己的仓库保持完全所有权,并自行承担
270
- 维护与安全责任。
271
280
 
272
281
  ## 社区
273
282
 
@@ -0,0 +1,13 @@
1
+ import type { ApiReference, ProtocolCatalog, ProtocolDefinition } from '@dsh-std/core'
2
+ export { registerTuiContributionExtensions } from './tui-contributions.js'
3
+ export * from './tui-channel.js'
4
+
5
+ export const DECISION_EVENTS: Readonly<ApiReference & {
6
+ apiVersion: 'tui.dsh/v1alpha1'
7
+ kind: 'DecisionEvents'
8
+ }>
9
+
10
+ export const decisionEventsDefinition: ProtocolDefinition
11
+ export const profileDefinitions: readonly ProtocolDefinition[]
12
+
13
+ export function registerProfileProtocols(catalog: ProtocolCatalog): () => void
@@ -0,0 +1,59 @@
1
+ /** dsh-TUI private protocol definitions evaluated by @dsh-std/core. */
2
+
3
+ export { registerTuiContributionExtensions } from './tui-contributions.js'
4
+ export * from './tui-channel.js'
5
+ import { tuiChannelDefinition } from './tui-channel.js'
6
+
7
+ export const DECISION_EVENTS = Object.freeze({
8
+ apiVersion: 'tui.dsh/v1alpha1',
9
+ kind: 'DecisionEvents',
10
+ })
11
+
12
+ function featureSupport(value, label) {
13
+ if (value === undefined) return Object.freeze({ features: Object.freeze([]) })
14
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) {
15
+ throw new TypeError(`${label} support spec must be an object`)
16
+ }
17
+ const unknown = Object.keys(value).filter(key => key !== 'features' && !key.startsWith('x-'))
18
+ if (unknown.length > 0) throw new TypeError(`${label} support spec contains unknown field ${JSON.stringify(unknown[0])}`)
19
+ if (value.features !== undefined && (!Array.isArray(value.features)
20
+ || value.features.some(feature => typeof feature !== 'string' || feature.trim() === ''))) {
21
+ throw new TypeError(`${label} support spec.features must be an array of non-empty strings`)
22
+ }
23
+ return Object.freeze({ features: Object.freeze([...(value.features ?? [])].sort()) })
24
+ }
25
+
26
+ function providerDefinition(reference, label) {
27
+ return Object.freeze({
28
+ ...reference,
29
+ validateRequirement(value) {
30
+ if (value !== undefined) throw new TypeError(`${label} requirement does not accept spec in manifest v0.15`)
31
+ return undefined
32
+ },
33
+ validateSupport(value) { return featureSupport(value, label) },
34
+ negotiate(input) {
35
+ const providers = [...new Set(input.supports.map(row => row.participant))].sort()
36
+ const issues = input.requirements.flatMap(row => providers.length === 0
37
+ ? [{
38
+ code: row.requirement.optional === true ? 'optional-support-missing' : 'required-support-missing',
39
+ severity: row.requirement.optional === true ? 'warning' : 'error',
40
+ participant: row.participant,
41
+ message: `${label} has no provider in this negotiation scope`,
42
+ }]
43
+ : [])
44
+ return { agreement: Object.freeze({ providers: Object.freeze(providers) }), issues: Object.freeze(issues) }
45
+ },
46
+ })
47
+ }
48
+
49
+ export const decisionEventsDefinition = providerDefinition(DECISION_EVENTS, 'DecisionEvents')
50
+
51
+ export const profileDefinitions = Object.freeze([
52
+ decisionEventsDefinition,
53
+ tuiChannelDefinition,
54
+ ])
55
+
56
+ export function registerProfileProtocols(catalog) {
57
+ const disposers = profileDefinitions.map(definition => catalog.register(definition))
58
+ return () => { for (const dispose of disposers.reverse()) dispose() }
59
+ }
@@ -0,0 +1,15 @@
1
+ export const TUI_CHANNEL_HTTP_API_VERSION: 'tui.dsh/v1alpha1'
2
+ export const TUI_CHANNEL_HTTP_KIND: 'ChannelEndpoint'
3
+ export const TUI_CHANNEL_HTTP_HEALTH_PATH: '/dsh-tui/v1/health'
4
+ export const TUI_CHANNEL_HTTP_DESCRIPTOR_PATH: '/dsh-tui/v1/endpoint'
5
+ export const TUI_CHANNEL_HTTP_WEBSOCKET_PATH: '/dsh-tui/v1/connection'
6
+
7
+ export interface TuiChannelEndpointDescriptor {
8
+ readonly apiVersion: typeof TUI_CHANNEL_HTTP_API_VERSION
9
+ readonly kind: typeof TUI_CHANNEL_HTTP_KIND
10
+ readonly origin: string
11
+ readonly connection: typeof TUI_CHANNEL_HTTP_WEBSOCKET_PATH
12
+ }
13
+
14
+ export function createTuiChannelEndpointDescriptor(origin: string): TuiChannelEndpointDescriptor
15
+ export function validateTuiChannelEndpointDescriptor(value: unknown): TuiChannelEndpointDescriptor
@@ -0,0 +1,32 @@
1
+ export const TUI_CHANNEL_HTTP_API_VERSION = 'tui.dsh/v1alpha1'
2
+ export const TUI_CHANNEL_HTTP_KIND = 'ChannelEndpoint'
3
+ export const TUI_CHANNEL_HTTP_HEALTH_PATH = '/dsh-tui/v1/health'
4
+ export const TUI_CHANNEL_HTTP_DESCRIPTOR_PATH = '/dsh-tui/v1/endpoint'
5
+ export const TUI_CHANNEL_HTTP_WEBSOCKET_PATH = '/dsh-tui/v1/connection'
6
+
7
+ export function createTuiChannelEndpointDescriptor(origin) {
8
+ const normalized = new URL(origin)
9
+ if (normalized.protocol !== 'http:' && normalized.protocol !== 'https:') {
10
+ throw new TypeError('TUI Channel endpoint origin must use http or https')
11
+ }
12
+ normalized.pathname = '/'
13
+ normalized.search = ''
14
+ normalized.hash = ''
15
+ return Object.freeze({
16
+ apiVersion: TUI_CHANNEL_HTTP_API_VERSION,
17
+ kind: TUI_CHANNEL_HTTP_KIND,
18
+ origin: normalized.toString().replace(/\/$/u, ''),
19
+ connection: TUI_CHANNEL_HTTP_WEBSOCKET_PATH,
20
+ })
21
+ }
22
+
23
+ export function validateTuiChannelEndpointDescriptor(value) {
24
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) throw new TypeError('TUI Channel endpoint descriptor must be an object')
25
+ if (value.apiVersion !== TUI_CHANNEL_HTTP_API_VERSION || value.kind !== TUI_CHANNEL_HTTP_KIND) {
26
+ throw new TypeError('TUI Channel endpoint descriptor version or kind is unsupported')
27
+ }
28
+ if (typeof value.origin !== 'string') throw new TypeError('TUI Channel endpoint origin must be a string')
29
+ createTuiChannelEndpointDescriptor(value.origin)
30
+ if (value.connection !== TUI_CHANNEL_HTTP_WEBSOCKET_PATH) throw new TypeError('TUI Channel endpoint connection path is unsupported')
31
+ return value
32
+ }
@@ -0,0 +1,59 @@
1
+ import type { ApiReference, ProtocolDefinition } from '@dsh-std/core'
2
+
3
+ export type JsonValue = null | boolean | number | string | readonly JsonValue[] | { readonly [key: string]: JsonValue }
4
+
5
+ export const TUI_CHANNEL: Readonly<ApiReference & {
6
+ apiVersion: 'tui.dsh/v1alpha1'
7
+ kind: 'Channel'
8
+ }>
9
+ export const TUI_CHANNEL_WIRE_REVISION: 6
10
+ export const TUI_CHANNEL_FEATURES: readonly string[]
11
+
12
+ export interface TuiChannelRequirementSpec {
13
+ readonly wireRevision: number
14
+ readonly features: readonly string[]
15
+ }
16
+ export interface TuiChannelSupportSpec extends TuiChannelRequirementSpec {}
17
+
18
+ export interface TuiChannelSnapshot {
19
+ readonly wireRevision: number
20
+ readonly channelId: string
21
+ readonly version: number
22
+ readonly state: Readonly<Record<string, JsonValue>>
23
+ }
24
+
25
+ export interface TuiChannelWorkspaceFlowChoice {
26
+ readonly id: string
27
+ readonly label: string
28
+ readonly description?: string
29
+ readonly badge?: string
30
+ readonly action: string
31
+ readonly input?: {
32
+ readonly action: string
33
+ readonly initialValue?: string
34
+ readonly placeholder?: string
35
+ }
36
+ }
37
+
38
+ export type TuiChannelWorkspaceFlowResult =
39
+ | { readonly kind: 'target'; readonly target: import('./tui-contributions.js').WorkspaceTarget }
40
+ | { readonly kind: 'choices'; readonly title: string; readonly choices: readonly TuiChannelWorkspaceFlowChoice[] }
41
+
42
+ export type TuiChannelInput =
43
+ | { readonly operation: 'open'; readonly value: { readonly workspace?: string; readonly sessionId?: string; readonly options?: JsonValue } }
44
+ | { readonly operation: 'subscribe'; readonly value: { readonly channelId: string; readonly afterVersion: number } }
45
+ | { readonly operation: 'invoke'; readonly value: { readonly channelId: string; readonly method: string; readonly arguments: readonly JsonValue[] } }
46
+ | { readonly operation: 'close'; readonly value: { readonly channelId: string } }
47
+
48
+ export interface TuiChannelInvokeOutput {
49
+ readonly value: JsonValue
50
+ readonly valueDefined?: boolean
51
+ readonly snapshot?: TuiChannelSnapshot
52
+ }
53
+
54
+ export const tuiChannelDefinition: ProtocolDefinition
55
+ export function validateTuiChannelRequirement(value: unknown): TuiChannelRequirementSpec
56
+ export function validateTuiChannelSupport(value: unknown): TuiChannelSupportSpec
57
+ export function validateTuiChannelInput(operation: string, value: unknown): object
58
+ export function validateTuiChannelSnapshot(value: unknown): TuiChannelSnapshot
59
+ export function validateTuiChannelOutput(operation: string, value: unknown): object
@@ -0,0 +1,166 @@
1
+ import { defineCapabilityProtocol } from '@dsh-std/connection'
2
+
3
+ export const TUI_CHANNEL = Object.freeze({
4
+ apiVersion: 'tui.dsh/v1alpha1',
5
+ kind: 'Channel',
6
+ })
7
+
8
+ export const TUI_CHANNEL_WIRE_REVISION = 6
9
+
10
+ export const TUI_CHANNEL_FEATURES = Object.freeze([
11
+ 'commands',
12
+ 'credentials',
13
+ 'diagnostics',
14
+ 'files',
15
+ 'models',
16
+ 'modes',
17
+ 'presets',
18
+ 'presentation',
19
+ 'provider-setup',
20
+ 'scenes',
21
+ 'session-history',
22
+ 'session-input',
23
+ 'session-lifecycle',
24
+ 'session-state',
25
+ 'settings',
26
+ 'skills',
27
+ 'subagents',
28
+ 'trace',
29
+ 'workspaces',
30
+ ])
31
+
32
+ export const tuiChannelDefinition = defineCapabilityProtocol({
33
+ ...TUI_CHANNEL,
34
+ validateRequirement: validateTuiChannelRequirement,
35
+ validateSupport: validateTuiChannelSupport,
36
+ })
37
+
38
+ export function validateTuiChannelRequirement(value) {
39
+ const spec = exactRecord(value, ['wireRevision', 'features'], 'Channel requirement')
40
+ const wireRevision = positiveInteger(spec.wireRevision, 'Channel requirement.wireRevision')
41
+ const features = featureList(spec.features, 'Channel requirement.features')
42
+ return Object.freeze({ wireRevision, features })
43
+ }
44
+
45
+ export function validateTuiChannelSupport(value) {
46
+ const spec = exactRecord(value, ['wireRevision', 'features'], 'Channel support')
47
+ const wireRevision = positiveInteger(spec.wireRevision, 'Channel support.wireRevision')
48
+ const features = featureList(spec.features, 'Channel support.features')
49
+ return Object.freeze({ wireRevision, features })
50
+ }
51
+
52
+ export function validateTuiChannelInput(operation, value) {
53
+ switch (operation) {
54
+ case 'open': {
55
+ const input = exactRecord(value, ['workspace', 'sessionId', 'options'], 'Channel.open input')
56
+ optionalString(input.workspace, 'Channel.open input.workspace')
57
+ optionalString(input.sessionId, 'Channel.open input.sessionId')
58
+ if (input.options !== undefined) jsonValue(input.options, 'Channel.open input.options', new Set())
59
+ return input
60
+ }
61
+ case 'subscribe': {
62
+ const input = exactRecord(value, ['channelId', 'afterVersion'], 'Channel.subscribe input')
63
+ nonEmpty(input.channelId, 'Channel.subscribe input.channelId')
64
+ nonNegativeInteger(input.afterVersion, 'Channel.subscribe input.afterVersion')
65
+ return input
66
+ }
67
+ case 'invoke': {
68
+ const input = exactRecord(value, ['channelId', 'method', 'arguments'], 'Channel.invoke input')
69
+ nonEmpty(input.channelId, 'Channel.invoke input.channelId')
70
+ nonEmpty(input.method, 'Channel.invoke input.method')
71
+ if (!Array.isArray(input.arguments)) throw new TypeError('Channel.invoke input.arguments must be an array')
72
+ jsonValue(input.arguments, 'Channel.invoke input.arguments', new Set())
73
+ return input
74
+ }
75
+ case 'close': {
76
+ const input = exactRecord(value, ['channelId'], 'Channel.close input')
77
+ nonEmpty(input.channelId, 'Channel.close input.channelId')
78
+ return input
79
+ }
80
+ default:
81
+ throw new TypeError(`Channel operation ${JSON.stringify(operation)} is not defined`)
82
+ }
83
+ }
84
+
85
+ export function validateTuiChannelSnapshot(value) {
86
+ const snapshot = exactRecord(value, ['wireRevision', 'channelId', 'version', 'state'], 'Channel snapshot')
87
+ positiveInteger(snapshot.wireRevision, 'Channel snapshot.wireRevision')
88
+ nonEmpty(snapshot.channelId, 'Channel snapshot.channelId')
89
+ nonNegativeInteger(snapshot.version, 'Channel snapshot.version')
90
+ const state = exactRecord(snapshot.state, Object.keys(snapshot.state ?? {}), 'Channel snapshot.state')
91
+ jsonValue(state, 'Channel snapshot.state', new Set())
92
+ return snapshot
93
+ }
94
+
95
+ export function validateTuiChannelOutput(operation, value) {
96
+ if (operation === 'open' || operation === 'subscribe') return validateTuiChannelSnapshot(value)
97
+ if (operation === 'invoke') {
98
+ const output = exactRecord(value, ['value', 'valueDefined', 'snapshot'], 'Channel.invoke output')
99
+ jsonValue(output.value, 'Channel.invoke output.value', new Set())
100
+ if (output.valueDefined !== undefined && typeof output.valueDefined !== 'boolean') {
101
+ throw new TypeError('Channel.invoke output.valueDefined must be boolean')
102
+ }
103
+ if (output.snapshot !== undefined) validateTuiChannelSnapshot(output.snapshot)
104
+ return output
105
+ }
106
+ if (operation === 'close') {
107
+ const output = exactRecord(value, ['closed'], 'Channel.close output')
108
+ if (output.closed !== true) throw new TypeError('Channel.close output.closed must be true')
109
+ return output
110
+ }
111
+ throw new TypeError(`Channel operation ${JSON.stringify(operation)} is not defined`)
112
+ }
113
+
114
+ function exactRecord(value, allowed, label) {
115
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) throw new TypeError(`${label} must be an object`)
116
+ const unknown = Object.keys(value).filter(key => !allowed.includes(key) && !key.startsWith('x-'))
117
+ if (unknown.length > 0) throw new TypeError(`${label} contains unknown field ${JSON.stringify(unknown[0])}`)
118
+ return value
119
+ }
120
+
121
+ function featureList(value, label) {
122
+ if (!Array.isArray(value) || value.length === 0) throw new TypeError(`${label} must be a non-empty array`)
123
+ const features = value.map((feature, index) => {
124
+ nonEmpty(feature, `${label}[${index}]`)
125
+ return feature
126
+ })
127
+ if (new Set(features).size !== features.length) throw new TypeError(`${label} contains duplicates`)
128
+ return Object.freeze([...features].sort())
129
+ }
130
+
131
+ function positiveInteger(value, label) {
132
+ if (!Number.isSafeInteger(value) || value < 1) throw new TypeError(`${label} must be a positive integer`)
133
+ return value
134
+ }
135
+
136
+ function nonNegativeInteger(value, label) {
137
+ if (!Number.isSafeInteger(value) || value < 0) throw new TypeError(`${label} must be a non-negative integer`)
138
+ return value
139
+ }
140
+
141
+ function nonEmpty(value, label) {
142
+ if (typeof value !== 'string' || value.trim() === '') throw new TypeError(`${label} must be a non-empty string`)
143
+ }
144
+
145
+ function optionalString(value, label) {
146
+ if (value !== undefined) nonEmpty(value, label)
147
+ }
148
+
149
+ function jsonValue(value, label, ancestors) {
150
+ if (value === null || typeof value === 'boolean' || typeof value === 'string') return
151
+ if (typeof value === 'number') {
152
+ if (!Number.isFinite(value)) throw new TypeError(`${label} must contain only finite numbers`)
153
+ return
154
+ }
155
+ if (typeof value !== 'object') throw new TypeError(`${label} must be a JSON value`)
156
+ if (ancestors.has(value)) throw new TypeError(`${label} must not contain cycles`)
157
+ ancestors.add(value)
158
+ if (Array.isArray(value)) {
159
+ for (const [index, item] of value.entries()) jsonValue(item, `${label}[${index}]`, ancestors)
160
+ } else {
161
+ const prototype = Object.getPrototypeOf(value)
162
+ if (prototype !== Object.prototype && prototype !== null) throw new TypeError(`${label} must contain only plain objects`)
163
+ for (const [key, item] of Object.entries(value)) jsonValue(item, `${label}.${key}`, ancestors)
164
+ }
165
+ ancestors.delete(value)
166
+ }
@@ -0,0 +1,42 @@
1
+ import type { ApiReference } from '@dsh-std/core'
2
+ import type { ManifestDefinitionCatalog, ManifestObjectDefinition } from '@dsh-std/manifest'
3
+
4
+ export const API_VERSION: 'tui.dsh/v1alpha1'
5
+ export const SETTINGS_SECTION: Readonly<ApiReference & { kind: 'SettingsSection' }>
6
+ export const SCENE: Readonly<ApiReference & { kind: 'Scene' }>
7
+
8
+ export type LocalizedText = Readonly<Record<string, string>>
9
+ export type SettingsFieldKind = 'text' | 'number' | 'boolean' | 'select'
10
+ export interface SettingsFieldOption { readonly value: string; readonly label: string; readonly titles?: LocalizedText }
11
+ export interface SettingsFieldSpec {
12
+ readonly path: readonly string[]
13
+ readonly label: string
14
+ readonly titles?: LocalizedText
15
+ readonly hint?: string
16
+ readonly hintTitles?: LocalizedText
17
+ readonly kind: SettingsFieldKind
18
+ readonly options?: readonly SettingsFieldOption[]
19
+ readonly placeholder?: string
20
+ readonly secretRef?: string
21
+ }
22
+ export interface SettingsSectionSpec {
23
+ readonly namespace: string
24
+ readonly title: string
25
+ readonly titles?: LocalizedText
26
+ readonly fields: readonly SettingsFieldSpec[]
27
+ }
28
+ export interface SettingsSectionHandler {}
29
+
30
+ export interface SceneSpec { readonly title?: string; readonly titles?: LocalizedText }
31
+ export interface SceneHandler<Props = unknown, Result = unknown> {
32
+ readonly component: (props: Props) => Result
33
+ }
34
+
35
+ export const settingsSectionExtensionDefinition: ManifestObjectDefinition
36
+ export const sceneExtensionDefinition: ManifestObjectDefinition
37
+ export const contributionExtensionDefinitions: readonly ManifestObjectDefinition[]
38
+ export function validateSettingsSectionSpec(value: unknown): Readonly<SettingsSectionSpec>
39
+ export function validateSceneSpec(value: unknown): Readonly<SceneSpec>
40
+ export function registerTuiContributionExtensions(catalog: ManifestDefinitionCatalog): () => void
41
+ export function assertSettingsSectionHandler(value: unknown): asserts value is SettingsSectionHandler
42
+ export function assertSceneHandler(value: unknown): asserts value is SceneHandler
@@ -0,0 +1,143 @@
1
+ /** dsh-TUI private, lifecycle-owned manifest contribution definitions. */
2
+
3
+ export const API_VERSION = 'tui.dsh/v1alpha1'
4
+
5
+ export const SETTINGS_SECTION = Object.freeze({
6
+ apiVersion: API_VERSION,
7
+ kind: 'SettingsSection',
8
+ })
9
+
10
+ export const SCENE = Object.freeze({
11
+ apiVersion: API_VERSION,
12
+ kind: 'Scene',
13
+ })
14
+
15
+ export const settingsSectionExtensionDefinition = Object.freeze({
16
+ ...SETTINGS_SECTION,
17
+ validateMetadata(metadata) {
18
+ contributionName(metadata?.name, 'SettingsSection metadata.name')
19
+ },
20
+ validateSpec: validateSettingsSectionSpec,
21
+ })
22
+
23
+ export function validateSettingsSectionSpec(value) {
24
+ const spec = exactRecord(value, ['namespace', 'title', 'titles', 'fields'], 'SettingsSection content')
25
+ contributionName(spec.namespace, 'SettingsSection content.namespace')
26
+ nonEmpty(spec.title, 'SettingsSection content.title')
27
+ localized(spec.titles, 'SettingsSection content.titles')
28
+ if (!Array.isArray(spec.fields)) throw new TypeError('SettingsSection content.fields must be an array')
29
+ return Object.freeze({
30
+ namespace: spec.namespace,
31
+ title: spec.title,
32
+ ...(spec.titles === undefined ? {} : { titles: freezeRecord(spec.titles) }),
33
+ fields: Object.freeze(spec.fields.map((field, index) => validateSettingsField(field, index))),
34
+ })
35
+ }
36
+
37
+ export const sceneExtensionDefinition = Object.freeze({
38
+ ...SCENE,
39
+ validateMetadata(metadata) {
40
+ contributionName(metadata?.name, 'Scene metadata.name')
41
+ },
42
+ validateSpec: validateSceneSpec,
43
+ })
44
+
45
+ export function validateSceneSpec(value) {
46
+ const spec = exactRecord(value, ['title', 'titles'], 'Scene content')
47
+ if (spec.title !== undefined) nonEmpty(spec.title, 'Scene content.title')
48
+ localized(spec.titles, 'Scene content.titles')
49
+ return Object.freeze({
50
+ ...(spec.title === undefined ? {} : { title: spec.title }),
51
+ ...(spec.titles === undefined ? {} : { titles: freezeRecord(spec.titles) }),
52
+ })
53
+ }
54
+
55
+ export const contributionExtensionDefinitions = Object.freeze([
56
+ settingsSectionExtensionDefinition,
57
+ sceneExtensionDefinition,
58
+ ])
59
+
60
+ export function registerTuiContributionExtensions(catalog) {
61
+ const disposers = contributionExtensionDefinitions.map(definition => catalog.registerExtension(definition))
62
+ return () => { for (const dispose of disposers.reverse()) dispose() }
63
+ }
64
+
65
+ export function assertSettingsSectionHandler(value) {
66
+ runtimeObject(value, 'SettingsSection handler')
67
+ }
68
+
69
+ export function assertSceneHandler(value) {
70
+ const handler = runtimeObject(value, 'Scene handler')
71
+ if (typeof handler.component !== 'function') throw new TypeError('Scene handler.component must be a function')
72
+ }
73
+
74
+ function validateSettingsField(value, index) {
75
+ const label = `SettingsSection spec.fields[${index}]`
76
+ const field = exactRecord(value, [
77
+ 'path', 'label', 'titles', 'hint', 'hintTitles', 'kind', 'options', 'placeholder', 'secretRef',
78
+ ], label)
79
+ if (!Array.isArray(field.path) || field.path.length === 0
80
+ || field.path.some(segment => typeof segment !== 'string' || segment.length === 0)) {
81
+ throw new TypeError(`${label}.path must be a non-empty string array`)
82
+ }
83
+ nonEmpty(field.label, `${label}.label`)
84
+ localized(field.titles, `${label}.titles`)
85
+ if (field.hint !== undefined) nonEmpty(field.hint, `${label}.hint`)
86
+ localized(field.hintTitles, `${label}.hintTitles`)
87
+ if (!['text', 'number', 'boolean', 'select'].includes(field.kind)) {
88
+ throw new TypeError(`${label}.kind is invalid`)
89
+ }
90
+ if (field.placeholder !== undefined && typeof field.placeholder !== 'string') {
91
+ throw new TypeError(`${label}.placeholder must be a string`)
92
+ }
93
+ if (field.secretRef !== undefined) nonEmpty(field.secretRef, `${label}.secretRef`)
94
+ if (field.options !== undefined) {
95
+ if (!Array.isArray(field.options)) throw new TypeError(`${label}.options must be an array`)
96
+ for (const [optionIndex, valueOption] of field.options.entries()) {
97
+ const option = exactRecord(valueOption, ['value', 'label', 'titles'], `${label}.options[${optionIndex}]`)
98
+ nonEmpty(option.value, `${label}.options[${optionIndex}].value`)
99
+ nonEmpty(option.label, `${label}.options[${optionIndex}].label`)
100
+ localized(option.titles, `${label}.options[${optionIndex}].titles`)
101
+ }
102
+ }
103
+ return Object.freeze(structuredClone(field))
104
+ }
105
+
106
+ function exactRecord(value, allowed, label) {
107
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) {
108
+ throw new TypeError(`${label} must be an object`)
109
+ }
110
+ const unknown = Object.keys(value).filter(key => !allowed.includes(key) && !key.startsWith('x-'))
111
+ if (unknown.length > 0) throw new TypeError(`${label} contains unknown field ${JSON.stringify(unknown[0])}`)
112
+ return value
113
+ }
114
+
115
+ function runtimeObject(value, label) {
116
+ if ((typeof value !== 'object' && typeof value !== 'function') || value === null || Array.isArray(value)) {
117
+ throw new TypeError(`${label} must be an object`)
118
+ }
119
+ return value
120
+ }
121
+
122
+ function contributionName(value, label) {
123
+ if (typeof value !== 'string' || !/^[a-z][a-z0-9_-]*$/u.test(value)) {
124
+ throw new TypeError(`${label} is invalid`)
125
+ }
126
+ }
127
+
128
+ function nonEmpty(value, label) {
129
+ if (typeof value !== 'string' || value.trim() === '') throw new TypeError(`${label} must be a non-empty string`)
130
+ }
131
+
132
+ function localized(value, label) {
133
+ if (value === undefined) return
134
+ const record = exactRecord(value, Object.keys(value), label)
135
+ for (const [locale, text] of Object.entries(record)) {
136
+ if (locale.trim() === '') throw new TypeError(`${label} contains an empty locale`)
137
+ nonEmpty(text, `${label}.${locale}`)
138
+ }
139
+ }
140
+
141
+ function freezeRecord(value) {
142
+ return Object.freeze({ ...value })
143
+ }
@@ -0,0 +1,14 @@
1
+ # dsh-TUI Admission Protocol Profile
2
+
3
+ [`registry-0.15.json`](registry-0.15.json) 不是全局协议注册表。它描述本 TUI admission profile 使用的 definition 集合:
4
+
5
+ - `imports` 引用固定 dsh-std revision 已提供的 definitions;
6
+ - `definitions` 只收录 dsh-TUI 私有 definitions。
7
+
8
+ 导入条目不复制 dsh-std 的 schema 或 contract 正文。Community v0.15 的 `Command`、`LocalStorage`、`MessageObserver`、Presentation 与 Workspace 定义分别由 `@dsh-std/command`、`@dsh-std/storage`、`@dsh-std/messages`、`@dsh-std/presentation` 与 `@dsh-std/workspace` 注册。
9
+
10
+ 本地 definition 的 contract profile 使用 SHA-256 固定。修改 profile 内容必须更新 digest,并按兼容性决定保留坐标或发布新 `apiVersion`。digest 只证明字节一致,不证明发布者身份。
11
+
12
+ `tui.dsh/*` 是 dsh-TUI 私有 namespace。私有 definition 与公共 definition 一样注册到 dsh-std `ProtocolCatalog`;目录收录本身不产生 live support。
13
+
14
+ 权限目录仍是 TUI authorization policy 的输入。permission grant 与 protocol support 分开判断,安装 definition 不自动授权操作。
@@ -0,0 +1,13 @@
1
+ {
2
+ "name":"tui.scene","version":"v1alpha1","kind":"extension",
3
+ "coordinates":{"apiVersion":"tui.dsh/v1alpha1","kind":"Scene"},
4
+ "caller":"trusted in-process dsh-TUI scene shell",
5
+ "permissions":[],
6
+ "operations":["open","close","render"],
7
+ "errors":["SCENE_INVALID","SCENE_CONFLICT","RENDERER_INCOMPATIBLE"],
8
+ "concurrency":"one scene may own the full-screen surface at a time",
9
+ "timeout":"scene operations are local; domain calls made by a scene retain their own deadlines",
10
+ "cleanup":"an open scene closes when its owning facet deactivates",
11
+ "privacyClass":"sensitive",
12
+ "securityBoundary":false
13
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "name":"tui.settings-section","version":"v1alpha1","kind":"extension",
3
+ "coordinates":{"apiVersion":"tui.dsh/v1alpha1","kind":"SettingsSection"},
4
+ "caller":"dsh-TUI settings contribution binder",
5
+ "permissions":[],
6
+ "operations":["render"],
7
+ "errors":["SECTION_INVALID","NAMESPACE_CONFLICT","NAMESPACE_UNAVAILABLE"],
8
+ "concurrency":"one active section owns each settings namespace",
9
+ "timeout":"not applicable to declarative rendering; writes use the settings protocol deadline",
10
+ "cleanup":"removing a section removes only UI metadata and preserves settings and credentials",
11
+ "privacyClass":"public",
12
+ "securityBoundary":false
13
+ }