@waq666/pneuma 0.7.1 → 0.8.1

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 (416) hide show
  1. package/README.md +242 -206
  2. package/bin/dsc.js +9 -3
  3. package/bin/headless.cjs +1 -1
  4. package/lib/adapter/transcript.d.ts +19 -2
  5. package/lib/adapter/transcript.js +71 -14
  6. package/lib/app/AgentsOverlay.js +7 -6
  7. package/lib/app/App.js +1 -1
  8. package/lib/app/ApprovalCard.js +15 -9
  9. package/lib/app/ChatView.d.ts +3 -1
  10. package/lib/app/ChatView.js +21 -17
  11. package/lib/app/Composer.js +22 -4
  12. package/lib/app/MarkdownView.js +2 -1
  13. package/lib/app/ModelPicker.js +7 -6
  14. package/lib/app/PickerFrame.d.ts +4 -0
  15. package/lib/app/PickerFrame.js +18 -0
  16. package/lib/app/PlanReviewCard.js +2 -1
  17. package/lib/app/PresetPicker.js +8 -7
  18. package/lib/app/SessionPicker.js +21 -20
  19. package/lib/app/SettingsOverlay.js +1 -1
  20. package/lib/app/SkillsPicker.js +7 -6
  21. package/lib/app/StatusBar.js +3 -15
  22. package/lib/app/TaskStrips.js +1 -4
  23. package/lib/app/TimelineRail.js +2 -1
  24. package/lib/app/ToolCard.js +2 -6
  25. package/lib/app/Welcome.d.ts +1 -0
  26. package/lib/app/Welcome.js +1 -4
  27. package/lib/app/click.d.ts +0 -2
  28. package/lib/app/click.js +2 -21
  29. package/lib/app/display-width.d.ts +16 -0
  30. package/lib/app/display-width.js +33 -0
  31. package/lib/app/markdown.d.ts +1 -3
  32. package/lib/app/markdown.js +2 -19
  33. package/lib/app/scroll-model.js +1 -1
  34. package/lib/contract/approval.d.ts +91 -0
  35. package/lib/contract/approval.js +1 -0
  36. package/lib/contract/mode.d.ts +69 -0
  37. package/lib/contract/mode.js +1 -0
  38. package/lib/contract/plugin.d.ts +240 -0
  39. package/lib/contract/plugin.js +1 -0
  40. package/lib/contract/runtime.d.ts +282 -0
  41. package/lib/contract/runtime.js +1 -0
  42. package/lib/contract/session.d.ts +208 -0
  43. package/lib/contract/session.js +36 -0
  44. package/lib/contract/settings.d.ts +242 -0
  45. package/lib/contract/settings.js +1 -0
  46. package/lib/contract/snapshot.d.ts +453 -0
  47. package/lib/contract/snapshot.js +1 -0
  48. package/lib/contract/task.d.ts +189 -0
  49. package/lib/contract/task.js +10 -0
  50. package/lib/contract/transcript.d.ts +358 -0
  51. package/lib/contract/transcript.js +1 -0
  52. package/lib/contract/usage.d.ts +132 -0
  53. package/lib/contract/usage.js +10 -0
  54. package/lib/contract.d.ts +20 -1968
  55. package/lib/contract.js +19 -30
  56. package/lib/core/agent-roles.d.ts +1 -1
  57. package/lib/core/agent-roles.js +6 -5
  58. package/lib/core/approval-floor.d.ts +9 -0
  59. package/lib/core/approval-floor.js +152 -25
  60. package/lib/core/attachments.d.ts +185 -0
  61. package/lib/core/attachments.js +425 -0
  62. package/lib/core/bytes.d.ts +14 -0
  63. package/lib/core/bytes.js +28 -0
  64. package/lib/core/call-meaning.d.ts +20 -0
  65. package/lib/core/call-meaning.js +347 -0
  66. package/lib/core/cdp/actions.js +6 -0
  67. package/lib/core/cdp/launch.js +2 -2
  68. package/lib/core/cdp/report.d.ts +27 -0
  69. package/lib/core/cdp/report.js +50 -0
  70. package/lib/core/cdp/ring-buffer.d.ts +25 -0
  71. package/lib/core/cdp/ring-buffer.js +44 -0
  72. package/lib/core/cdp/snapshot.js +5 -9
  73. package/lib/core/cdp/transport.js +1 -1
  74. package/lib/core/clamp.d.ts +20 -0
  75. package/lib/core/clamp.js +24 -0
  76. package/lib/core/clock.d.ts +16 -0
  77. package/lib/core/clock.js +20 -0
  78. package/lib/core/command-policy.js +33 -1
  79. package/lib/core/commands-completion.d.ts +28 -0
  80. package/lib/core/commands-completion.js +108 -30
  81. package/lib/core/compact.d.ts +36 -6
  82. package/lib/core/compact.js +89 -17
  83. package/lib/core/desktop-control.js +1 -3
  84. package/lib/core/dsh-compat/llm-usage-event.d.ts +78 -0
  85. package/lib/core/dsh-compat/llm-usage-event.js +91 -0
  86. package/lib/core/dsh-compat/presentation.d.ts +84 -0
  87. package/lib/core/dsh-compat/presentation.js +105 -0
  88. package/lib/core/dsh-compat/resolve-hook.d.ts +3 -3
  89. package/lib/core/dsh-compat/resolve-hook.js +41 -13
  90. package/lib/core/dsh-compat/service-map.d.ts +52 -0
  91. package/lib/core/dsh-compat/service-map.js +87 -0
  92. package/lib/core/dsh-compat/session-bridge.d.ts +107 -0
  93. package/lib/core/dsh-compat/session-bridge.js +376 -0
  94. package/lib/core/dsh-compat/session-events.d.ts +54 -0
  95. package/lib/core/dsh-compat/session-events.js +297 -0
  96. package/lib/core/dsh-compat/shims/credentials.d.ts +62 -0
  97. package/lib/core/dsh-compat/shims/credentials.js +86 -0
  98. package/lib/core/dsh-compat/shims/home-paths.d.ts +77 -0
  99. package/lib/core/dsh-compat/shims/home-paths.js +143 -0
  100. package/lib/core/dsh-compat/tools-facade.d.ts +31 -1
  101. package/lib/core/dsh-compat/tools-facade.js +207 -3
  102. package/lib/core/err-text.d.ts +5 -0
  103. package/lib/core/err-text.js +5 -0
  104. package/lib/core/events.d.ts +31 -2
  105. package/lib/core/git-info.d.ts +127 -15
  106. package/lib/core/git-info.js +315 -34
  107. package/lib/core/git-surface.d.ts +17 -0
  108. package/lib/core/git-surface.js +7 -0
  109. package/lib/core/hooks.d.ts +19 -2
  110. package/lib/core/hooks.js +57 -13
  111. package/lib/core/host-methods.d.ts +1 -1
  112. package/lib/core/host-methods.js +4 -0
  113. package/lib/core/image-diet.js +1 -4
  114. package/lib/core/json-text.d.ts +11 -0
  115. package/lib/core/json-text.js +18 -0
  116. package/lib/core/learnings/skill-write.d.ts +1 -7
  117. package/lib/core/learnings/skill-write.js +3 -37
  118. package/lib/core/lifecycle-hooks.d.ts +11 -3
  119. package/lib/core/lifecycle-hooks.js +33 -42
  120. package/lib/core/llm.d.ts +42 -0
  121. package/lib/core/llm.js +40 -25
  122. package/lib/core/loop.d.ts +11 -1
  123. package/lib/core/loop.js +95 -28
  124. package/lib/core/lsp/client.js +30 -17
  125. package/lib/core/lsp/normalize.d.ts +0 -2
  126. package/lib/core/lsp/normalize.js +1 -6
  127. package/lib/core/lsp/servers.js +1 -4
  128. package/lib/core/mcp.d.ts +18 -0
  129. package/lib/core/mcp.js +60 -16
  130. package/lib/core/microcompact.d.ts +45 -0
  131. package/lib/core/microcompact.js +128 -0
  132. package/lib/core/native-bridge.js +2 -10
  133. package/lib/core/path-policy.d.ts +13 -1
  134. package/lib/core/path-policy.js +87 -18
  135. package/lib/core/permission-presets.d.ts +9 -5
  136. package/lib/core/permission-presets.js +14 -7
  137. package/lib/core/permission-scope.d.ts +65 -0
  138. package/lib/core/permission-scope.js +109 -0
  139. package/lib/core/plugin-bundle.d.ts +95 -0
  140. package/lib/core/plugin-bundle.js +137 -0
  141. package/lib/core/plugin-loader.d.ts +36 -1
  142. package/lib/core/plugin-loader.js +336 -12
  143. package/lib/core/plugin-patch.d.ts +64 -0
  144. package/lib/core/plugin-patch.js +146 -0
  145. package/lib/core/plugin-registry.d.ts +14 -0
  146. package/lib/core/plugin-registry.js +2 -0
  147. package/lib/core/prefs.js +40 -2
  148. package/lib/core/presets.d.ts +11 -0
  149. package/lib/core/presets.js +61 -22
  150. package/lib/core/profile-dir.d.ts +5 -0
  151. package/lib/core/profile-dir.js +40 -0
  152. package/lib/core/prompt.js +55 -19
  153. package/lib/core/ptc.d.ts +8 -2
  154. package/lib/core/ptc.js +18 -4
  155. package/lib/core/records.d.ts +16 -0
  156. package/lib/core/records.js +22 -0
  157. package/lib/core/remote/notify.js +1 -3
  158. package/lib/core/remote/push.js +2 -6
  159. package/lib/core/sandbox/execpolicy.js +27 -3
  160. package/lib/core/sandbox/net-proxy.js +2 -2
  161. package/lib/core/sandbox/policy.d.ts +1 -1
  162. package/lib/core/sandbox/policy.js +21 -15
  163. package/lib/core/sandbox/win/account.js +1 -4
  164. package/lib/core/sandbox/win/acl.js +1 -6
  165. package/lib/core/sandbox/win/backend.d.ts +24 -3
  166. package/lib/core/sandbox/win/backend.js +73 -23
  167. package/lib/core/sandbox/win/doctor.js +1 -4
  168. package/lib/core/sandbox/win/runner-entry.js +1 -6
  169. package/lib/core/sandbox/win/setup.js +1 -4
  170. package/lib/core/sandbox/win/utf16.d.ts +11 -0
  171. package/lib/core/sandbox/win/utf16.js +15 -0
  172. package/lib/core/sandbox/win/wfp.js +1 -4
  173. package/lib/core/schedule/rule.d.ts +0 -17
  174. package/lib/core/schedule/rule.js +1 -3
  175. package/lib/core/schedule/runner.d.ts +5 -2
  176. package/lib/core/schedule/runner.js +32 -9
  177. package/lib/core/schedule/store.d.ts +0 -2
  178. package/lib/core/schedule/store.js +2 -9
  179. package/lib/core/session-index.d.ts +50 -0
  180. package/lib/core/session-index.js +169 -3
  181. package/lib/core/session.d.ts +89 -13
  182. package/lib/core/session.js +385 -32
  183. package/lib/core/shell-quote.d.ts +21 -0
  184. package/lib/core/shell-quote.js +24 -0
  185. package/lib/core/side-ask.d.ts +52 -0
  186. package/lib/core/side-ask.js +89 -0
  187. package/lib/core/skills.d.ts +16 -0
  188. package/lib/core/skills.js +45 -8
  189. package/lib/core/snapshot-throttle.d.ts +8 -0
  190. package/lib/core/snapshot-throttle.js +24 -0
  191. package/lib/core/spill.d.ts +11 -5
  192. package/lib/core/spill.js +35 -36
  193. package/lib/core/strings.d.ts +21 -0
  194. package/lib/core/strings.js +33 -0
  195. package/lib/core/terminal-env.d.ts +61 -0
  196. package/lib/core/terminal-env.js +327 -0
  197. package/lib/core/text-format.d.ts +17 -0
  198. package/lib/core/text-format.js +26 -0
  199. package/lib/core/todo-reminder.d.ts +19 -14
  200. package/lib/core/todo-reminder.js +14 -23
  201. package/lib/core/token-estimate.d.ts +18 -2
  202. package/lib/core/token-estimate.js +10 -2
  203. package/lib/core/tool-result-prune.d.ts +42 -0
  204. package/lib/core/tool-result-prune.js +47 -0
  205. package/lib/core/tool-search.d.ts +3 -2
  206. package/lib/core/tool-search.js +3 -2
  207. package/lib/core/tools/bash.d.ts +35 -3
  208. package/lib/core/tools/bash.js +168 -41
  209. package/lib/core/tools/fs-tools.js +18 -17
  210. package/lib/core/tools/image-tool.d.ts +2 -0
  211. package/lib/core/tools/image-tool.js +59 -0
  212. package/lib/core/tools/path-args.d.ts +4 -0
  213. package/lib/core/tools/path-args.js +22 -0
  214. package/lib/core/tools/search-tools.d.ts +30 -0
  215. package/lib/core/tools/search-tools.js +321 -34
  216. package/lib/core/tools.d.ts +82 -0
  217. package/lib/core/tools.js +21 -0
  218. package/lib/core/transcript-text.d.ts +19 -0
  219. package/lib/core/transcript-text.js +44 -0
  220. package/lib/core/ui-boot-source.d.ts +5 -0
  221. package/lib/core/ui-boot-source.js +10 -3
  222. package/lib/core/ui-bundles.d.ts +80 -6
  223. package/lib/core/ui-bundles.js +700 -76
  224. package/lib/core/ui-events.d.ts +10 -0
  225. package/lib/core/ui-events.js +25 -0
  226. package/lib/core/ui-methods.d.ts +1 -1
  227. package/lib/core/ui-methods.js +42 -13
  228. package/lib/core/ui-route.js +11 -7
  229. package/lib/core/ui-server.d.ts +6 -0
  230. package/lib/core/ui-server.js +106 -1
  231. package/lib/core/unified-diff.d.ts +35 -0
  232. package/lib/core/unified-diff.js +86 -0
  233. package/lib/core/usage-log.js +39 -0
  234. package/lib/core/web-http.d.ts +1 -1
  235. package/lib/core/web-http.js +1 -3
  236. package/lib/host/kernel.js +57 -41
  237. package/lib/plugins/agent.js +101 -20
  238. package/lib/plugins/approval-floor.js +12 -8
  239. package/lib/plugins/approval.js +252 -80
  240. package/lib/plugins/ask.js +60 -8
  241. package/lib/plugins/browser.js +32 -84
  242. package/lib/plugins/commands.js +167 -57
  243. package/lib/plugins/compact.d.ts +2 -2
  244. package/lib/plugins/compact.js +200 -30
  245. package/lib/plugins/computer-use.js +34 -18
  246. package/lib/plugins/dock-browser.js +24 -65
  247. package/lib/plugins/dsh-compat.js +7 -0
  248. package/lib/plugins/file-review.js +59 -15
  249. package/lib/plugins/git.js +16 -8
  250. package/lib/plugins/goal.js +9 -8
  251. package/lib/plugins/hooks.js +4 -2
  252. package/lib/plugins/host-stdio.js +14 -16
  253. package/lib/plugins/lifecycle-hooks.d.ts +5 -4
  254. package/lib/plugins/lifecycle-hooks.js +12 -10
  255. package/lib/plugins/llm.js +74 -33
  256. package/lib/plugins/lsp.js +22 -27
  257. package/lib/plugins/mcp.js +16 -17
  258. package/lib/plugins/memory.js +3 -24
  259. package/lib/plugins/microcompact.d.ts +4 -1
  260. package/lib/plugins/microcompact.js +117 -19
  261. package/lib/plugins/mode.js +30 -11
  262. package/lib/plugins/permission-presets.d.ts +2 -1
  263. package/lib/plugins/permission-presets.js +55 -35
  264. package/lib/plugins/plugin-manager.js +4 -6
  265. package/lib/plugins/presets.js +56 -27
  266. package/lib/plugins/prompt.js +54 -11
  267. package/lib/plugins/ptc.d.ts +13 -0
  268. package/lib/plugins/ptc.js +121 -24
  269. package/lib/plugins/remote/types.d.ts +1 -1
  270. package/lib/plugins/remote/types.js +11 -0
  271. package/lib/plugins/remote.js +14 -15
  272. package/lib/plugins/runtime.js +91 -14
  273. package/lib/plugins/sandbox.js +181 -60
  274. package/lib/plugins/schedule.js +12 -11
  275. package/lib/plugins/self-improve.js +28 -18
  276. package/lib/plugins/session-search.js +18 -13
  277. package/lib/plugins/session-title.js +1 -1
  278. package/lib/plugins/session.js +103 -25
  279. package/lib/plugins/settings.js +16 -40
  280. package/lib/plugins/skills.js +18 -1
  281. package/lib/plugins/spill.js +18 -11
  282. package/lib/plugins/subagent.js +208 -42
  283. package/lib/plugins/team.js +11 -5
  284. package/lib/plugins/todo.d.ts +1 -1
  285. package/lib/plugins/todo.js +25 -19
  286. package/lib/plugins/tool-search.js +47 -28
  287. package/lib/plugins/tools-default.js +89 -5
  288. package/lib/plugins/tools.js +3 -3
  289. package/lib/plugins/transcript.js +116 -9
  290. package/lib/plugins/web-search.d.ts +1 -1
  291. package/lib/plugins/web-search.js +25 -16
  292. package/lib/plugins/webserver.js +40 -7
  293. package/lib/remote/assets/app-B3Id1EBq.js +14 -0
  294. package/lib/remote/assets/index.html +2 -2
  295. package/lib/remote/assets/{style-DIB6729x.css → style-NtlpbKOI.css} +1 -1
  296. package/lib/services/types.d.ts +247 -29
  297. package/lib/tools/plugin-cli.d.ts +1 -0
  298. package/lib/tools/plugin-cli.js +209 -0
  299. package/lib/ui/assets/app-B-Jx5dnh.js +90 -0
  300. package/lib/ui/assets/{chunk-BajyYBss.js → chunk-Bfdlo8Me.js} +1 -1
  301. package/lib/ui/assets/chunk-DGX-i4eb.js +12 -0
  302. package/lib/ui/assets/index.html +62 -14
  303. package/lib/ui/assets/style-WzxwEPaE.css +1 -0
  304. package/lib/ui/frames.js +1 -3
  305. package/lib/ui/index.d.ts +30 -1
  306. package/lib/ui/index.js +29 -0
  307. package/lib/ui/manifest.d.ts +24 -6
  308. package/lib/ui/manifest.js +3 -2
  309. package/lib/ui/plugins/actions/bundle.json +8 -0
  310. package/lib/ui/plugins/actions/client.js +43 -0
  311. package/lib/ui/plugins/ask/bundle.json +8 -0
  312. package/lib/ui/plugins/ask/client.js +415 -0
  313. package/lib/ui/plugins/browser/bundle.json +8 -0
  314. package/lib/ui/plugins/composer/bundle.json +9 -0
  315. package/lib/ui/plugins/composer/client.js +1806 -1087
  316. package/lib/ui/plugins/files/bundle.json +8 -0
  317. package/lib/ui/plugins/files/client.js +13 -98
  318. package/lib/ui/plugins/manifest.json +1 -104
  319. package/lib/ui/plugins/palette/bundle.json +8 -0
  320. package/lib/ui/plugins/palette/client.js +360 -0
  321. package/lib/ui/plugins/plugins/bundle.json +8 -0
  322. package/lib/ui/plugins/plugins/client.js +116 -38
  323. package/lib/ui/plugins/preview/bundle.json +8 -0
  324. package/lib/ui/plugins/preview/client.js +6 -16
  325. package/lib/ui/plugins/prompt/bundle.json +8 -0
  326. package/lib/ui/plugins/prompt/client.js +81 -47
  327. package/lib/ui/plugins/sessions/bundle.json +8 -0
  328. package/lib/ui/plugins/sessions/client.js +157 -111
  329. package/lib/ui/plugins/settings/bundle.json +8 -0
  330. package/lib/ui/plugins/settings/client.js +184 -170
  331. package/lib/ui/plugins/skills/bundle.json +8 -0
  332. package/lib/ui/plugins/skills/client.js +161 -79
  333. package/lib/ui/plugins/status/bundle.json +8 -0
  334. package/lib/ui/plugins/status/client.js +165 -26
  335. package/lib/ui/plugins/statusbar/bundle.json +9 -0
  336. package/lib/ui/plugins/statusbar/client.js +100 -144
  337. package/lib/ui/plugins/tasks/bundle.json +8 -0
  338. package/lib/ui/plugins/team/bundle.json +8 -0
  339. package/lib/ui/plugins/team/client.js +60 -58
  340. package/lib/ui/plugins/terminal/bundle.json +8 -0
  341. package/lib/ui/plugins/terminal/client.js +1 -7
  342. package/lib/ui/plugins/trace/bundle.json +11 -0
  343. package/lib/ui/plugins/trace/client.js +86 -179
  344. package/lib/ui/plugins/transcript/bundle.json +8 -0
  345. package/lib/ui/plugins/transcript/client.js +1608 -1243
  346. package/lib/ui/sdk/@dsc/ui/index.d.ts +54 -16
  347. package/lib/ui/sdk/@dsc/ui/package.json +1 -1
  348. package/lib/ui/sdk/@dsc/ui-core/contract.d.ts +20 -1968
  349. package/lib/ui/sdk/@dsc/ui-core/core/attachments.d.ts +185 -0
  350. package/lib/ui/sdk/@dsc/ui-core/core/bytes.d.ts +14 -0
  351. package/lib/ui/sdk/@dsc/ui-core/core/err-text.d.ts +18 -0
  352. package/lib/ui/sdk/@dsc/ui-core/core/git-surface.d.ts +17 -0
  353. package/lib/ui/sdk/@dsc/ui-core/core/json-text.d.ts +11 -0
  354. package/lib/ui/sdk/@dsc/ui-core/core/path-policy.d.ts +44 -0
  355. package/lib/ui/sdk/@dsc/ui-core/core/records.d.ts +16 -0
  356. package/lib/ui/sdk/@dsc/ui-core/core/throughput.d.ts +46 -0
  357. package/lib/ui/sdk/@dsc/ui-core/core/token-estimate.d.ts +18 -2
  358. package/lib/ui/sdk/@dsc/ui-core/core/unified-diff.d.ts +35 -0
  359. package/lib/ui/sdk/@dsc/ui-core/package.json +1 -1
  360. package/lib/ui/sdk/@dsc/ui-core/ui/index.d.ts +30 -1
  361. package/lib/ui/sdk/@dsc/ui-core/ui/manifest.d.ts +24 -6
  362. package/lib/ui/sdk/@dsc/ui-core/ui/services.d.ts +19 -8
  363. package/lib/ui/sdk/@dsc/ui-core/ui/signal.d.ts +49 -0
  364. package/lib/ui/sdk/@dsc/ui-dockkit/dock-model.d.ts +17 -3
  365. package/lib/ui/sdk/@dsc/ui-dockkit/dock-state.d.ts +1 -1
  366. package/lib/ui/sdk/@dsc/ui-dockkit/package.json +1 -1
  367. package/lib/ui/sdk/@dsc/ui-layout/app.d.ts +4 -0
  368. package/lib/ui/sdk/@dsc/ui-layout/appearance.d.ts +6 -1
  369. package/lib/ui/sdk/@dsc/ui-layout/host-channel.d.ts +21 -0
  370. package/lib/ui/sdk/@dsc/ui-layout/index.d.ts +1 -0
  371. package/lib/ui/sdk/@dsc/ui-layout/package.json +1 -1
  372. package/lib/ui/sdk/@dsc/ui-layout/page-state.d.ts +1 -1
  373. package/lib/ui/sdk/@dsc/ui-layout/runtime-context.d.ts +10 -1
  374. package/lib/ui/sdk/@dsc/ui-layout/thread-view.d.ts +1 -1
  375. package/lib/ui/sdk/@dsc/ui-layout/usage-today.d.ts +11 -0
  376. package/lib/ui/sdk/@dsc/ui-primitives/dialog-focus.d.ts +30 -0
  377. package/lib/ui/sdk/@dsc/ui-primitives/error-text.d.ts +12 -0
  378. package/lib/ui/sdk/@dsc/ui-primitives/git-surface.d.ts +9 -0
  379. package/lib/ui/sdk/@dsc/ui-primitives/highlight.d.ts +23 -0
  380. package/lib/ui/sdk/@dsc/ui-primitives/humanize-error.d.ts +35 -0
  381. package/lib/ui/sdk/@dsc/ui-primitives/icons-workspace.d.ts +33 -0
  382. package/lib/ui/sdk/@dsc/ui-primitives/icons.d.ts +21 -3
  383. package/lib/ui/sdk/@dsc/ui-primitives/image-lightbox.d.ts +21 -0
  384. package/lib/ui/sdk/@dsc/ui-primitives/index.d.ts +16 -0
  385. package/lib/ui/sdk/@dsc/ui-primitives/markdown.d.ts +10 -14
  386. package/lib/ui/sdk/@dsc/ui-primitives/package.json +1 -1
  387. package/lib/ui/sdk/@dsc/ui-primitives/panels.d.ts +31 -8
  388. package/lib/ui/sdk/@dsc/ui-primitives/paths.d.ts +2 -0
  389. package/lib/ui/sdk/@dsc/ui-primitives/review-findings-card.d.ts +25 -0
  390. package/lib/ui/sdk/@dsc/ui-primitives/review-findings.d.ts +64 -0
  391. package/lib/ui/sdk/@dsc/ui-primitives/review-notice-card.d.ts +27 -0
  392. package/lib/ui/sdk/@dsc/ui-primitives/review-notice.d.ts +80 -0
  393. package/lib/ui/sdk/@dsc/ui-primitives/signal.d.ts +9 -0
  394. package/lib/ui/sdk/@dsc/ui-primitives/sizes.d.ts +15 -0
  395. package/lib/ui/sdk/@dsc/ui-primitives/skeleton.d.ts +39 -0
  396. package/lib/ui/sdk/@dsc/ui-primitives/snapshot.d.ts +46 -0
  397. package/lib/ui/sdk/@dsc/ui-primitives/thread-resizer.d.ts +3 -3
  398. package/lib/ui/sdk/@dsc/ui-primitives/throughput.d.ts +13 -0
  399. package/lib/ui/sdk/@dsc/ui-primitives/tokens.d.ts +9 -0
  400. package/lib/ui/sdk/@dsc/ui-primitives/tool-args.d.ts +1 -1
  401. package/lib/ui/sdk/@dsc/ui-primitives/tool-summary.d.ts +30 -6
  402. package/lib/ui/sdk/@dsc/ui-primitives/unified-diff.d.ts +10 -0
  403. package/lib/ui/sdk/@dsc/ui-renderer/boot.d.ts +10 -1
  404. package/lib/ui/sdk/@dsc/ui-renderer/cordis-host.d.ts +113 -0
  405. package/lib/ui/sdk/@dsc/ui-renderer/package.json +1 -1
  406. package/lib/ui/sdk/@dsc/ui-slots/package.json +1 -1
  407. package/lib/ui/services.d.ts +19 -8
  408. package/lib/ui/services.js +20 -12
  409. package/lib/ui/signal.d.ts +49 -0
  410. package/lib/ui/signal.js +57 -0
  411. package/lib/ui/tui-plugins.js +36 -16
  412. package/package.json +71 -58
  413. package/lib/remote/assets/app-DAcUCOEn.js +0 -14
  414. package/lib/ui/assets/app-B70nVIKd.js +0 -69
  415. package/lib/ui/assets/chunk-BGcgwlCI.js +0 -12
  416. package/lib/ui/assets/style-Bq01xH_b.css +0 -1
@@ -70,6 +70,23 @@ export class Transcript {
70
70
  if (!running)
71
71
  this.working = false;
72
72
  }
73
+ /**
74
+ * 会话重新打开时把「最近一次请求的上下文占用」种回来。
75
+ *
76
+ * 为什么需要:contextUsed 只在收到 usage 事件时赋值,而重放历史明确不重放 usage;
77
+ * 宿主重启后第一帧于是显示 0%,用户看到的是「上下文被清空了」,实际只是读数没恢复。
78
+ * usage 日志里按会话存着每条请求的输入 token(最后一条就是此刻的占用),
79
+ * 由调用方读出后交给这里补上。
80
+ *
81
+ * 为什么只补总数、不补分段:分段(系统提示词 / 工具定义 / 对话消息)是宿主按
82
+ * 请求内容估出来的,日志里没有;它仍然要等下一次请求的 context 事件。这里若把
83
+ * 总数塞进 contextSegments,卡片就会拿一份假的分段画进度条。
84
+ *
85
+ * 没有样本的会话不要调用(调用方传 0 会把「还没数」伪装成一个 0% 读数)。
86
+ */
87
+ seedContextUsage(used) {
88
+ this.contextUsed = used;
89
+ }
73
90
  /**
74
91
  * 本会话已经落过几条压缩标记(`clear()` 归零)。新标记的 `count` 就是它加一,
75
92
  * 因此这个数就是「第几次压缩」。标记只在真正压过的地方产生,所以不必认识压缩服务。
@@ -118,15 +135,20 @@ export class Transcript {
118
135
  /**
119
136
  * 追加一条系统提示(错误/状态说明)。
120
137
  * @param compaction - 这条提示是「历史刚被压缩」的落点:带标记,轨迹页据此切区段。
138
+ * @param level - `'error'` 表示要人处理的问题:界面会弹一次提示而不再铺在首屏;缺省只进日志。
121
139
  */
122
- system(text, compaction = false) {
140
+ system(text, compaction = false, level = 'info', command = false) {
123
141
  // 这条不走 reduce,时间戳在这里自己取
124
142
  this.list.push({
125
143
  kind: 'system',
126
144
  id: this.seq++,
127
145
  text,
128
146
  ts: Date.now(),
147
+ // 只有错误才写这个字段:信息类条目保持原来的形状,落盘体积不变。
148
+ ...(level === 'error' ? { level } : {}),
129
149
  ...(compaction ? { compaction: this.compactionMark() } : {}),
150
+ // 命令输出带标记:空会话欢迎态也要画出来(见 contract 里这条的注释)
151
+ ...(command ? { command: true } : {}),
130
152
  });
131
153
  }
132
154
  /** 下一个压缩标记;只有真压过的地方才调用,所以序号不会跳。 */
@@ -175,7 +197,7 @@ export class Transcript {
175
197
  * 时间戳跟着消息走(`ChatMessage.ts`,由会话日志重放时填回):有就盖在条目上,
176
198
  * 没有(2026-09 之前的老日志)就传 null,条目干脆不带 ts,界面降级不显示时间。
177
199
  */
178
- replayHistory(messages, toolErrors, fileChanges) {
200
+ replayHistory(messages, toolErrors, fileChanges, presentations) {
179
201
  let changed = false;
180
202
  for (const message of messages) {
181
203
  const ts = message.ts ?? null;
@@ -187,6 +209,11 @@ export class Transcript {
187
209
  type: 'user',
188
210
  text: contentText(message.content),
189
211
  ...(images.length > 0 ? { images } : {}),
212
+ ...(message.files === undefined || message.files.length === 0 ? {} : { files: message.files }),
213
+ // 机器投递的通知带着 origin 落库(见 core/session 的 InboxOrigin):重放时
214
+ // 原样交给 reduce,靠它与前缀一起判 internal,否则「重开旧会话」会把它们
215
+ // 又还原成用户气泡。
216
+ ...(message.origin === 'notice' ? { origin: message.origin } : {}),
190
217
  }, ts) || changed;
191
218
  break;
192
219
  }
@@ -201,9 +228,11 @@ export class Transcript {
201
228
  changed =
202
229
  this.reduce({
203
230
  type: 'tool/call',
204
- callId: call.id,
205
- name: call.function.name,
206
- args: call.function.arguments,
231
+ // 老日志里可能存着 null(2026-10-30 那条 `未知工具:null`):
232
+ // 读回来时统一修成字符串,界面才敢对名字调字符串方法。
233
+ callId: typeof call.id === 'string' ? call.id : '',
234
+ name: typeof call.function.name === 'string' ? call.function.name : '',
235
+ args: typeof call.function.arguments === 'string' ? call.function.arguments : '',
207
236
  }, ts) || changed;
208
237
  }
209
238
  break;
@@ -217,11 +246,16 @@ export class Transcript {
217
246
  text: contentText(message.content),
218
247
  ...(error !== undefined ? { error } : {}),
219
248
  }, ts) || changed;
220
- // 成功的 write / edit 把轮尾卡的变更事实一并重放(日志 tool 记录里存着)
221
- const change = fileChanges?.get(callId);
222
- if (change !== undefined) {
249
+ // 成功的 write / edit 把轮尾卡的变更事实一并重放(日志 tool 记录里存着)。
250
+ // 一个 callId 可能对应多个文件(PTC 的一次脚本),逐个折成条目。
251
+ for (const change of fileChanges?.get(callId) ?? []) {
223
252
  changed = this.reduce({ type: 'tool/changes', callId, change }, ts) || changed;
224
253
  }
254
+ // dsh 插件的卡片数据也一并重放(日志 tool 记录里存着)
255
+ const presentation = presentations?.get(callId);
256
+ if (presentation !== undefined) {
257
+ changed = this.reduce({ type: 'tool/presentation', callId, presentation }, ts) || changed;
258
+ }
225
259
  break;
226
260
  }
227
261
  }
@@ -315,10 +349,12 @@ export class Transcript {
315
349
  this.turnUsage = { inputTokens: 0, outputTokens: 0 };
316
350
  const last = this.list[this.list.length - 1];
317
351
  const imageCount = event.images?.length ?? 0;
352
+ const fileCount = event.files?.length ?? 0;
318
353
  const sameAsLast = last !== undefined &&
319
354
  last.kind === 'user' &&
320
355
  last.text === event.text &&
321
- (last.images?.length ?? 0) === imageCount;
356
+ (last.images?.length ?? 0) === imageCount &&
357
+ (last.files?.length ?? 0) === fileCount;
322
358
  if (sameAsLast)
323
359
  return false;
324
360
  // 压缩摘要本身在内存里就是一条 role:'user' 的消息(core/compact.ts 造的),
@@ -331,12 +367,20 @@ export class Transcript {
331
367
  // 但不该在对话页装成人打的字。跟压缩摘要同一个套路——靠正文前缀认出来,认出后
332
368
  // 打 internal 标记,界面按「非人发起的唤醒」渲染(对照 dsh 的 turn-trigger 节点)。
333
369
  // 重放历史走的是同一条 reduce,所以老会话里的汇报也照样被认出来。
334
- const internal = event.text.startsWith(TEAMMATE_REPORT_OPEN) || event.text.startsWith(REVIEW_FINDINGS_OPEN);
370
+ //
371
+ // 另一种认法:`origin: 'notice'`。机器投递的唤醒(后台作业完成、定时补投、目标续跑、
372
+ // 记忆复盘……)正文没有固定前缀可言,靠事件/日志里的 origin 认(2026-11-02 报障:
373
+ // 后台作业通知没有前缀,于是当成人打的字渲染成了可编辑气泡)。两条判据是并集:
374
+ // 队友汇报与 findings 走前缀(老日志也认得出),其余机器消息走 origin。
375
+ const internal = event.text.startsWith(TEAMMATE_REPORT_OPEN) ||
376
+ event.text.startsWith(REVIEW_FINDINGS_OPEN) ||
377
+ event.origin === 'notice';
335
378
  this.list.push(this.stamp({
336
379
  kind: 'user',
337
380
  id: this.seq++,
338
381
  text: event.text,
339
382
  ...(imageCount > 0 ? { images: event.images } : {}),
383
+ ...(fileCount > 0 ? { files: event.files } : {}),
340
384
  ...(compacted ? { compaction: this.compactionMark() } : {}),
341
385
  ...(event.steering === true ? { steering: true } : {}),
342
386
  ...(internal ? { internal: true } : {}),
@@ -408,9 +452,9 @@ export class Transcript {
408
452
  // (条目的 ts 是「最后写入时刻」,只留给界面算轮次计时)
409
453
  const startedAt = this.eventTs;
410
454
  const call = {
411
- callId: event.callId,
412
- name: event.name,
413
- argsText: event.args,
455
+ callId: typeof event.callId === 'string' ? event.callId : '',
456
+ name: typeof event.name === 'string' ? event.name : '',
457
+ argsText: typeof event.args === 'string' ? event.args : '',
414
458
  status: 'running',
415
459
  // 重放老会话(eventTs 为 null)时拿不到发起时刻,干脆不写,界面据此降级
416
460
  ...(startedAt === null ? {} : { startedAt }),
@@ -471,6 +515,19 @@ export class Transcript {
471
515
  }
472
516
  return true;
473
517
  }
518
+ case 'tool/presentation': {
519
+ // dsh 插件的卡片数据:按 callId 缝回工具卡(界面按 card 标签挑形态)。
520
+ // 不产生独立条目——它是这张卡的一种画法,不是又一条消息。
521
+ const index = this.toolIndex.get(event.callId);
522
+ const owner = index === undefined ? undefined : this.list[index];
523
+ if (index !== undefined && owner !== undefined && owner.kind === 'tool') {
524
+ this.list[index] = {
525
+ ...owner,
526
+ call: { ...owner.call, presentation: event.presentation },
527
+ };
528
+ }
529
+ return true;
530
+ }
474
531
  case 'turn/diff': {
475
532
  // 回合收尾的聚合改动(同文件多刀合一):也是独立条目,渲染层优先拿它画轮尾卡。
476
533
  // 恢复会话的重放不重建它(纯内存条目不落盘),轮尾卡回退逐刀合并显示。
@@ -520,7 +577,7 @@ export class Transcript {
520
577
  return true;
521
578
  }
522
579
  case 'error':
523
- this.system(`错误:${event.message}`);
580
+ this.system(`错误:${event.message}`, false, 'error');
524
581
  return true;
525
582
  case 'turn/start':
526
583
  // 快照的 turnState 完全由事件驱动(inTurn),事件发出即通知重算。
@@ -9,8 +9,9 @@ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
9
9
  *
10
10
  * @module dsc-tui/app/AgentsOverlay
11
11
  */
12
- import { Box, Text } from 'ink';
13
- import { BORDER, GAP, MARK, PAD, STATUS_COLOR, TEXT } from './theme.js';
12
+ import { Text } from 'ink';
13
+ import { PickerFrame } from './PickerFrame.js';
14
+ import { MARK, STATUS_COLOR, TEXT } from './theme.js';
14
15
  /** 队友状态的词与颜色。 */
15
16
  const TEAM_STATE = {
16
17
  working: { text: '工作中', color: STATUS_COLOR.pending },
@@ -56,8 +57,8 @@ export function buildAgentRows(teammates, sessionStates) {
56
57
  }
57
58
  export function AgentsOverlay({ rows, index, }) {
58
59
  const safeIndex = Math.max(0, Math.min(index, rows.length - 1));
59
- return (_jsx(Box, { borderStyle: "round", borderColor: BORDER.active, paddingX: PAD.inline, flexDirection: "column", flexGrow: 1, overflowY: "hidden", gap: GAP.none, children: _jsxs(Box, { flexShrink: 0, flexDirection: "column", gap: GAP.none, children: [_jsxs(Text, { ...TEXT.label, color: STATUS_COLOR.pending, wrap: "truncate-end", children: ["\u5B50\u4EE3\u7406\u4E0E\u540E\u53F0\u4F1A\u8BDD\uFF08", rows.length, " \u4E2A\uFF09"] }), rows.length === 0 ? (_jsx(Text, { ...TEXT.secondary, wrap: "truncate-end", children: "\u5F53\u524D\u6CA1\u6709\u5728\u8DD1\u7684\u5B50\u4EE3\u7406\uFF1B\u6D3E\u6D3B\uFF08\u667A\u80FD\u4F53\u56E2\u961F / subagent \u5DE5\u5177\uFF09\u4E4B\u540E\u8FD9\u91CC\u80FD\u770B\u5230\u5B83\u4EEC\u3002" })) : null, rows.map((row, position) => {
60
- const selected = position === safeIndex;
61
- return (_jsxs(Text, { wrap: "truncate-end", children: [_jsx(Text, { color: selected ? STATUS_COLOR.pending : undefined, children: selected ? MARK.selected : MARK.idle }), _jsx(Text, { ...TEXT.body, children: row.title }), _jsxs(Text, { ...TEXT.label, color: row.stateColor, children: [' ', "\u00B7 ", row.stateText] }), _jsxs(Text, { ...TEXT.secondary, children: [" ", row.detail] })] }, `${row.kind}:${row.key}`));
62
- }), _jsx(Text, { ...TEXT.secondary, wrap: "truncate-end", children: "Enter \u6216\u70B9\u51FB\u67E5\u770B\u8F6C\u5F55 \u00B7 Esc \u5173\u95ED" })] }) }));
60
+ return (_jsxs(PickerFrame, { children: [_jsxs(Text, { ...TEXT.label, color: STATUS_COLOR.pending, wrap: "truncate-end", children: ["\u5B50\u4EE3\u7406\u4E0E\u540E\u53F0\u4F1A\u8BDD\uFF08", rows.length, " \u4E2A\uFF09"] }), rows.length === 0 ? (_jsx(Text, { ...TEXT.secondary, wrap: "truncate-end", children: "\u5F53\u524D\u6CA1\u6709\u5728\u8DD1\u7684\u5B50\u4EE3\u7406\uFF1B\u6D3E\u6D3B\uFF08\u667A\u80FD\u4F53\u56E2\u961F / subagent \u5DE5\u5177\uFF09\u4E4B\u540E\u8FD9\u91CC\u80FD\u770B\u5230\u5B83\u4EEC\u3002" })) : null, rows.map((row, position) => {
61
+ const selected = position === safeIndex;
62
+ return (_jsxs(Text, { wrap: "truncate-end", children: [_jsx(Text, { color: selected ? STATUS_COLOR.pending : undefined, children: selected ? MARK.selected : MARK.idle }), _jsx(Text, { ...TEXT.body, children: row.title }), _jsxs(Text, { ...TEXT.label, color: row.stateColor, children: [' ', "\u00B7 ", row.stateText] }), _jsxs(Text, { ...TEXT.secondary, children: [" ", row.detail] })] }, `${row.kind}:${row.key}`));
63
+ }), _jsx(Text, { ...TEXT.secondary, wrap: "truncate-end", children: "Enter \u6216\u70B9\u51FB\u67E5\u770B\u8F6C\u5F55 \u00B7 Esc \u5173\u95ED" })] }));
63
64
  }
package/lib/app/App.js CHANGED
@@ -1643,7 +1643,7 @@ export function App({ runtime, clipboardReader, imageRenderer, tuiNoticeExtras,
1643
1643
  (plan !== null && !planFeedback);
1644
1644
  /** 子代理转录的条数(标题用;切片与滚动都在 TranscriptViewport 里按行算)。 */
1645
1645
  const agentTotal = agentEntries?.length ?? 0;
1646
- return (_jsxs(Box, { height: frameRows, width: "100%", flexDirection: "column", overflow: "hidden", paddingX: PAD.page, children: [preview !== null ? (_jsx(PreviewOverlay, { title: preview.title, index: preview.index, total: preview.sources.length, block: previewBlock, loading: previewLoading, error: previewError, registerClick: registerClick, onClose: () => setPreview(null) })) : agentView !== null && agentView.mode === 'list' ? (_jsx(AgentsOverlay, { rows: agentRows, index: agentIndex })) : agentView !== null && agentView.mode === 'transcript' ? (_jsx(TranscriptOverlay, { ref: peekRef, entries: agentEntries ?? [], total: agentTotal, title: agentView.title, columns: columns, viewportLines: overlayViewportLines, hint: PEEK_HINT, registerClick: registerClick, expandedTools: expandedTools, onToggleTool: toggleTool })) : picker ? (_jsx(SessionPicker, { level: isWorkspaceLevel ? 'workspaces' : 'sessions', workspaces: visibleWorkspaces, workspaceTitle: pickerWorkspace === null ? null : workspaceLabel(pickerWorkspace), sessions: visibleSessions, total: isWorkspaceLevel ? workspaceList.length : pickerList.length, start: pickerStart, index: pickerIndex, page: pickerPage, query: pickerQuery, buffer: pickerBuffer, armed: pickerArmed, loading: snapshot.sessionsLoading, sessionStates: snapshot.sessionStates })) : transcriptOpen ? (_jsx(TranscriptOverlay, { ref: overlayRef, entries: snapshot.entries, total: snapshot.entries.length, columns: columns, viewportLines: overlayViewportLines, registerClick: registerClick, expandedTools: expandedTools, onToggleTool: toggleTool })) : modelPicker ? (_jsx(ModelPicker, { models: modelList, index: modelIndex, query: modelQuery })) : presetPicker && presetSurface !== null ? (_jsx(PresetPicker, { presets: presetList, current: presetSurface.current, defaultName: presetSurface.defaultName, index: presetIndex, query: presetQuery })) : skillsPicker ? (_jsx(SkillsPicker, { skills: skillsList, index: skillsIndex, query: skillsQuery })) : settingsOpen ? (_jsx(SettingsOverlay, { sections: settingsSections, rows: settingsRows, values: settingsValues, focusRow: settingsFocusRow, windowStart: settingsWindow, viewport: settingsViewport, editing: settingsEdit, notice: settingsNotice, section: settingsSection, group: settingsGroup })) : (_jsxs(_Fragment, { children: [_jsx(Box, { flexDirection: "column", flexGrow: 1, minHeight: 0, children: _jsx(ChatView, { entries: snapshot.entries, turnState: snapshot.status.turnState, expandThinking: expandThinking, empty: snapshot.entries.length === 0, welcome: snapshot.entries.length < WELCOME_MAX_ENTRIES ? (_jsx(Welcome, { model: snapshot.status.model, effort: snapshot.status.effort ?? '-', cwd: snapshot.status.cwd })) : undefined, maxWidth: Math.max(20, columns - PAD.page * 2), columns: columns,
1646
+ return (_jsxs(Box, { height: frameRows, width: "100%", flexDirection: "column", overflow: "hidden", paddingX: PAD.page, children: [preview !== null ? (_jsx(PreviewOverlay, { title: preview.title, index: preview.index, total: preview.sources.length, block: previewBlock, loading: previewLoading, error: previewError, registerClick: registerClick, onClose: () => setPreview(null) })) : agentView !== null && agentView.mode === 'list' ? (_jsx(AgentsOverlay, { rows: agentRows, index: agentIndex })) : agentView !== null && agentView.mode === 'transcript' ? (_jsx(TranscriptOverlay, { ref: peekRef, entries: agentEntries ?? [], total: agentTotal, title: agentView.title, columns: columns, viewportLines: overlayViewportLines, hint: PEEK_HINT, registerClick: registerClick, expandedTools: expandedTools, onToggleTool: toggleTool })) : picker ? (_jsx(SessionPicker, { level: isWorkspaceLevel ? 'workspaces' : 'sessions', workspaces: visibleWorkspaces, workspaceTitle: pickerWorkspace === null ? null : workspaceLabel(pickerWorkspace), sessions: visibleSessions, total: isWorkspaceLevel ? workspaceList.length : pickerList.length, start: pickerStart, index: pickerIndex, page: pickerPage, query: pickerQuery, buffer: pickerBuffer, armed: pickerArmed, loading: snapshot.sessionsLoading, sessionStates: snapshot.sessionStates })) : transcriptOpen ? (_jsx(TranscriptOverlay, { ref: overlayRef, entries: snapshot.entries, total: snapshot.entries.length, columns: columns, viewportLines: overlayViewportLines, registerClick: registerClick, expandedTools: expandedTools, onToggleTool: toggleTool })) : modelPicker ? (_jsx(ModelPicker, { models: modelList, index: modelIndex, query: modelQuery })) : presetPicker && presetSurface !== null ? (_jsx(PresetPicker, { presets: presetList, current: presetSurface.current, defaultName: presetSurface.defaultName, index: presetIndex, query: presetQuery })) : skillsPicker ? (_jsx(SkillsPicker, { skills: skillsList, index: skillsIndex, query: skillsQuery })) : settingsOpen ? (_jsx(SettingsOverlay, { sections: settingsSections, rows: settingsRows, values: settingsValues, focusRow: settingsFocusRow, windowStart: settingsWindow, viewport: settingsViewport, editing: settingsEdit, notice: settingsNotice, section: settingsSection, group: settingsGroup })) : (_jsxs(_Fragment, { children: [_jsx(Box, { flexDirection: "column", flexGrow: 1, minHeight: 0, children: _jsx(ChatView, { entries: snapshot.entries, turnState: snapshot.status.turnState, compactingSince: snapshot.status.compactingSince, expandThinking: expandThinking, empty: snapshot.entries.length === 0, welcome: snapshot.entries.length < WELCOME_MAX_ENTRIES ? (_jsx(Welcome, { model: snapshot.status.model, effort: snapshot.status.effort ?? '-', cwd: snapshot.status.cwd })) : undefined, maxWidth: Math.max(20, columns - PAD.page * 2), columns: columns,
1647
1647
  // 刻度栏居中按「帧高 − 状态栏」(只在终端改尺寸时才变):聊天区可用高度会随
1648
1648
  // 「回到底部」胶囊、草稿行数变化,按它居中会让整块刻度每滚一下上下挪一行
1649
1649
  railCenterLines: Math.max(1, frameRows - statusbarLines), viewportRef: chatRef, onAtTailChange: handleChatAtTail, expandedTools: expandedTools, onToggleTool: toggleTool, onPreviewImages: handlePreviewImages, onOpenAgent: handleOpenAgent, onPickTurn: (turn) => chatRef.current?.jumpToTurn(turn), registerClick: registerClick }) }), _jsxs(Box, { flexShrink: 0, flexDirection: "column", children: [_jsx(TaskStrips, { goal: snapshot.surfaces.goal, todos: snapshot.surfaces.todos }), approval !== null ? (_jsx(ApprovalCard, { request: approval, expanded: approvalExpanded, onAction: handleApprovalAction, registerClick: registerClick })) : null, approval === null && question !== null ? (_jsx(AskCard, { ask: question, index: askIndex, checked: askChecked, highlight: askHighlight, text: askText, onOptionClick: handleAskOption, registerClick: registerClick })) : null, approval === null && question === null && plan !== null ? (_jsx(PlanReviewCard, { plan: plan, expanded: planExpanded, feedbacking: planFeedback, onAction: handlePlanAction, registerClick: registerClick })) : null, notice !== null ? (_jsx(Box, { borderStyle: "single", borderColor: BORDER.frame, paddingX: PAD.inline, marginTop: GAP.tight, children: _jsx(Text, { ...TEXT.label, color: STATUS_COLOR.waiting, children: notice }) })) : null, tuiNoticeExtras, chatAwayFrom !== null ? (_jsx(TailIndicator, { hidden: Math.max(0, snapshot.entries.length - chatAwayFrom), onJump: () => chatRef.current?.toTail(), registerClick: registerClick })) : null, _jsx(Composer, { disabled: modal, models: models, placeholder: planFeedback ? '反馈原话(Enter 退回计划,Esc 取消)' : undefined, completionsEnabled: !planFeedback, lister: dockLister, onPanelOpenChange: setPanelOpen, onDraftChange: handleDraftChange, preset: composerPreset, attachments: attachments, onRemoveAttachment: removeAttachment, onPreviewAttachment: previewAttachment, onOpenSessions: openSessionPicker, working: snapshot.status.turnState !== 'idle', registerClick: registerClick, onSubmit: handleSubmit })] })] })), _jsx(Box, { flexShrink: 0, children: _jsx(StatusBar, { status: snapshot.status, surfaces: snapshot.surfaces, subagents: snapshot.subagents ?? [], queued: (snapshot.queued ?? []).length + (snapshot.notices ?? []).length, config: statusBarPrefs, onOpenAgent: handleOpenAgent, registerClick: registerClick }) })] }));
@@ -4,9 +4,12 @@ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
4
4
  * Esc)拒绝;按键只渲染 request.scopes 允许的档位,命中硬地板(hardline)只留拒绝。
5
5
  * 页脚按钮可鼠标点击(列区间按显示宽度与渲染同源计算,命中即等价按键)。
6
6
  *
7
- * 卡上补全宿主随请求带来的富信息:reason(为何要问)、risk 风险档、当前权限/协作
8
- * 模式、后台会话来源,write/edit 的「将做的改动」内嵌 diff(超长折叠,v 展开/收起)。
9
- * 键盘与鼠标路由在 App 顶层统一处理,本组件纯展示。
7
+ * 卡上补全宿主随请求带来的富信息:meaning(这次要干什么)、reason(为何要问)、
8
+ * risk 风险档、当前权限/协作模式、后台会话来源,write/edit 的「将做的改动」内嵌 diff
9
+ * (超长折叠,v 展开/收起)。键盘与鼠标路由在 App 顶层统一处理,本组件纯展示。
10
+ *
11
+ * 0.7.1 与桌面两张卡同口径:多一行中文含义,低风险不再挂「(低风险)」,
12
+ * 「需要授权」这类通用兜底理由不占一行。
10
13
  *
11
14
  * @module dsc-tui/app/ApprovalCard
12
15
  */
@@ -14,11 +17,9 @@ import { useRef } from 'react';
14
17
  import { Box, Text } from 'ink';
15
18
  import { BORDER, GAP, PAD, STATUS_COLOR, TEXT } from './theme.js';
16
19
  import { DiffBlock } from './DiffBlock.js';
17
- import { absoluteLeft, displayWidth, useClickRegion } from './click.js';
18
- const oneLine = (text, limit) => {
19
- const flat = text.replace(/\s+/g, ' ').trim();
20
- return flat.length > limit ? `${flat.slice(0, limit)}…` : flat;
21
- };
20
+ import { absoluteLeft, useClickRegion } from './click.js';
21
+ import { displayWidth } from './display-width.js';
22
+ import { oneLine } from '../core/strings.js';
22
23
  /** 风险档标签:critical / high 用失败红,medium 用等待黄,low 走暗淡。 */
23
24
  const RISK_LABEL = {
24
25
  low: { text: '低风险', color: undefined },
@@ -26,6 +27,11 @@ const RISK_LABEL = {
26
27
  high: { text: '高风险', color: STATUS_COLOR.failed },
27
28
  critical: { text: '极高风险', color: STATUS_COLOR.failed },
28
29
  };
30
+ /**
31
+ * 「为何要问」里没有信息量的几句(与桌面两张卡同口径):通用兜底不占版面,
32
+ * 有话说的是复核否决、沙箱边界、安全钩子这类具体原因。
33
+ */
34
+ const GENERIC_REASONS = new Set(['需要授权', '工作区内的改动需要确认']);
29
35
  /** 会话 jsonl 路径的短标识(文件名去后缀取前 8 位)。 */
30
36
  const shortId = (sessionPath) => (sessionPath.split(/[\\/]/).pop() ?? sessionPath).replace(/\.jsonl$/, '').slice(0, 8);
31
37
  /** 页脚按钮的渲染与点击列区间共用同一份数据,谁也不会跟谁漂。 */
@@ -68,7 +74,7 @@ export function ApprovalCard({ request, expanded, onAction, registerClick, }) {
68
74
  onAction(hit.id);
69
75
  return true;
70
76
  });
71
- return (_jsxs(Box, { ref: rootRef, borderStyle: "double", borderColor: BORDER.alert, paddingX: PAD.inline, flexDirection: "column", marginTop: GAP.tight, gap: GAP.none, children: [_jsxs(Text, { children: [_jsxs(Text, { ...TEXT.label, color: BORDER.alert, children: ["\u26A0 \u5DE5\u5177\u6388\u6743\uFF1A", request.toolName] }), _jsxs(Text, { ...TEXT.label, color: risk.color, children: [' ', "\uFF08", risk.text, "\uFF09"] })] }), request.reason !== '' ? (_jsxs(Text, { ...TEXT.label, color: STATUS_COLOR.waiting, children: ["\u4E3A\u4F55\u8981\u95EE\uFF1A", request.reason] })) : null, _jsx(Text, { ...TEXT.secondary, wrap: "truncate-end", children: oneLine(request.argsSummary, 200) }), _jsxs(Text, { ...TEXT.secondary, wrap: "truncate-end", children: ["\u6743\u9650 ", request.policy === 'readonly' ? '仅查看' : request.policy === 'auto-edit' ? '工作区自动' : '完全访问', " \u00B7 \u5BA1\u9605", ' ', request.reviewer === 'user' ? '本人' : 'AI 复核', " \u00B7 \u6A21\u5F0F ", request.mode, request.sessionPath !== undefined ? ` · 来自后台会话 ${shortId(request.sessionPath)}` : ''] }), request.escalation !== undefined ? (_jsxs(Text, { ...TEXT.label, color: STATUS_COLOR.waiting, children: ["\u6A21\u578B\u8BF7\u6C42\u653E\u5BBD\u6C99\u7BB1\uFF1A", request.escalation.effect, request.escalation.scope === 'session' ? '(它想本会话一直放宽)' : ''] })) : null, request.escalation !== undefined ? (_jsxs(Text, { ...TEXT.secondary, wrap: "truncate-end", children: ["\u7406\u7531\uFF1A", oneLine(request.escalation.justification, 160)] })) : null, request.diff !== undefined ? _jsx(DiffBlock, { diff: request.diff, expanded: expanded }) : null, request.hardline ? (_jsxs(Text, { children: [_jsx(Text, { ...TEXT.label, color: STATUS_COLOR.failed, children: "[n]" }), _jsx(Text, { ...TEXT.secondary, children: " \u62D2\u7EDD\uFF08\u547D\u4E2D\u786C\u5730\u677F\uFF0C\u4E0D\u53EF\u653E\u884C\uFF09" })] })) : (_jsx(Text, { children: buttons.map((id) => {
77
+ return (_jsxs(Box, { ref: rootRef, borderStyle: "double", borderColor: BORDER.alert, paddingX: PAD.inline, flexDirection: "column", marginTop: GAP.tight, gap: GAP.none, children: [_jsxs(Text, { children: [_jsxs(Text, { ...TEXT.label, color: BORDER.alert, children: ["\u26A0 \u5DE5\u5177\u6388\u6743\uFF1A", request.toolName] }), request.risk === 'low' ? null : (_jsxs(Text, { ...TEXT.label, color: risk.color, children: [' ', "\uFF08", risk.text, "\uFF09"] }))] }), request.meaning === undefined ? null : _jsx(Text, { ...TEXT.body, children: request.meaning }), request.reason !== '' && !GENERIC_REASONS.has(request.reason) ? (_jsxs(Text, { ...TEXT.label, color: STATUS_COLOR.waiting, children: ["\u4E3A\u4F55\u8981\u95EE\uFF1A", request.reason] })) : null, request.diff === undefined ? (_jsx(Text, { ...TEXT.secondary, wrap: "truncate-end", children: oneLine(request.argsSummary, 200) })) : null, _jsxs(Text, { ...TEXT.secondary, wrap: "truncate-end", children: ["\u6743\u9650 ", request.policy === 'readonly' ? '仅查看' : request.policy === 'auto-edit' ? '工作区自动' : '完全访问', " \u00B7 \u5BA1\u9605", ' ', request.reviewer === 'user' ? '本人' : 'AI 复核', " \u00B7 \u6A21\u5F0F ", request.mode, request.sessionPath !== undefined ? ` · 来自后台会话 ${shortId(request.sessionPath)}` : ''] }), request.escalation !== undefined ? (_jsxs(Text, { ...TEXT.label, color: STATUS_COLOR.waiting, children: ["\u6A21\u578B\u8BF7\u6C42\u653E\u5BBD\u6C99\u7BB1\uFF1A", request.escalation.effect, request.escalation.scope === 'session' ? '(它想本会话一直放宽)' : ''] })) : null, request.escalation !== undefined ? (_jsxs(Text, { ...TEXT.secondary, wrap: "truncate-end", children: ["\u7406\u7531\uFF1A", oneLine(request.escalation.justification, 160)] })) : null, request.diff !== undefined ? _jsx(DiffBlock, { diff: request.diff, expanded: expanded }) : null, request.hardline ? (_jsxs(Text, { children: [_jsx(Text, { ...TEXT.label, color: STATUS_COLOR.failed, children: "[n]" }), _jsx(Text, { ...TEXT.secondary, children: " \u62D2\u7EDD\uFF08\u547D\u4E2D\u786C\u5730\u677F\uFF0C\u4E0D\u53EF\u653E\u884C\uFF09" })] })) : (_jsx(Text, { children: buttons.map((id) => {
72
78
  const button = BUTTON_TEXT[id];
73
79
  const first = id === buttons[0];
74
80
  return (_jsxs(Text, { ...(button.dim ? TEXT.secondary : TEXT.body), children: [_jsxs(Text, { ...TEXT.label, color: button.color, children: [first ? '' : ' ', button.hint] }), _jsxs(Text, { children: [" ", button.label] })] }, id));
@@ -23,10 +23,12 @@ export declare const Entry: import("react").NamedExoticComponent<{
23
23
  onOpenAgent?: (file: string) => void;
24
24
  registerClick?: RegisterClick;
25
25
  }>;
26
- export declare function ChatView({ entries, turnState, expandThinking, empty, welcome, maxWidth, columns, railCenterLines, expandedTools, onToggleTool, onPreviewImages, onOpenAgent, onPickTurn, registerClick, viewportRef, onAtTailChange, }: {
26
+ export declare function ChatView({ entries, turnState, expandThinking, empty, welcome, maxWidth, columns, railCenterLines, expandedTools, onToggleTool, onPreviewImages, onOpenAgent, onPickTurn, registerClick, viewportRef, onAtTailChange, compactingSince, }: {
27
27
  /** 全量条目(窗口切片、行偏移、刻度几何都在 TranscriptViewport 里按行算)。 */
28
28
  entries: TranscriptEntry[];
29
29
  turnState: 'idle' | 'thinking' | 'working' | 'awaiting-approval';
30
+ /** 正在压缩上下文的开始时刻;undefined = 没在压(压缩期间底部画一行活动提示)。 */
31
+ compactingSince?: number;
30
32
  expandThinking: boolean;
31
33
  /** 全会话一条都没有(和「窗口恰好翻空」区分开,只有前者画开场提示)。 */
32
34
  empty: boolean;
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  /**
3
3
  * 会话流:把 TranscriptEntry 序列渲染成终端块。只渲染 App 算好的「可见窗口」切片
4
4
  * (整屏视口:根盒恒定高度、底对齐、老条目从顶上裁掉;回看走 Ctrl+O 浮层)。
@@ -17,12 +17,14 @@ import { memo, useRef } from 'react';
17
17
  import { Box, Text, useStdout } from 'ink';
18
18
  import { MarkdownView } from './MarkdownView.js';
19
19
  import { ToolCard } from './ToolCard.js';
20
- import { displayWidth } from './markdown.js';
20
+ import { displayWidth } from './display-width.js';
21
21
  import { measuredSpan, useClickRegion } from './click.js';
22
22
  import { HINT } from './keymap.js';
23
23
  import { useTick } from './ticker.js';
24
24
  import { TranscriptViewport } from './TranscriptViewport.js';
25
25
  import { ACCENT, DIFF_COLOR, GAP, INDENT, PAD, PALETTE, STATUS_COLOR, TEXT, mixHex } from './theme.js';
26
+ import { oneLine } from '../core/strings.js';
27
+ import { compactTokens } from '../core/text-format.js';
26
28
  /** 流式思考的盲文 spinner 帧(dsh 同款字符,80-120ms 一拍)。 */
27
29
  const BRAILLE = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
28
30
  /**
@@ -48,10 +50,6 @@ function BrailleSpinner({ pulse = false }) {
48
50
  const color = pulse === true ? mixHex(PALETTE.brand, PALETTE.ice, (Math.sin(frame * 0.9) + 1) / 2) : PALETTE.accent;
49
51
  return _jsx(Text, { color: color, children: BRAILLE[frame % BRAILLE.length] });
50
52
  }
51
- const oneLine = (text, limit) => {
52
- const flat = text.replace(/\s+/g, ' ').trim();
53
- return flat.length > limit ? `${flat.slice(0, limit)}…` : flat;
54
- };
55
53
  /** 时长的人话格式(dsh duration 同款):48s / 3m12s;不足 1 秒返回空串(不显示)。 */
56
54
  const fmtSeconds = (ms) => {
57
55
  const seconds = Math.floor(ms / 1000);
@@ -59,17 +57,21 @@ const fmtSeconds = (ms) => {
59
57
  return '';
60
58
  return seconds < 60 ? `${seconds}s` : `${Math.floor(seconds / 60)}m${seconds % 60}s`;
61
59
  };
62
- /** token 数的人话格式(与 StatusBar 的 fmtTokens 同口径:988 / 3.4k / 12k / 1.0M)。 */
63
- const fmtTokens = (value) => {
64
- if (value >= 1_000_000)
65
- return `${(value / 1_000_000).toFixed(1)}M`;
66
- if (value >= 1000)
67
- return `${(value / 1000).toFixed(1)}k`;
68
- return String(value);
69
- };
70
60
  /** 瀑布窗口恒定 3 行(Kimi Code 视觉语言,dsh 同款):高度不随输出抖动。子代理卡与
71
61
  * 思考块共用(`scroll-model.estimateLines` 里同口径)。 */
72
62
  const WATERFALL_ROWS = 3;
63
+ /**
64
+ * 压缩进行中的一行(0.7.2):盲文 spinner + 「压缩上下文中」+ 已用时。
65
+ *
66
+ * 为什么挂在视口底部而不是当成一条条目:压缩是命令驱动的,外面没有回合,硬塞一条
67
+ * 假条目会改行高表与滚动坐标(历史教训:占一行会让「滚上去再滚回来差一行」)。
68
+ * 底部这一行不参与滚动,压缩结束随字段一起消失。
69
+ */
70
+ function CompactingLine({ startedAt }) {
71
+ useTick(SECONDS_MS);
72
+ const seconds = fmtSeconds(Date.now() - startedAt);
73
+ return (_jsxs(Box, { marginLeft: INDENT.detail, flexDirection: "row", gap: 1, children: [_jsx(Box, { flexShrink: 0, children: _jsx(BrailleSpinner, {}) }), _jsx(Box, { minWidth: 0, children: _jsx(Text, { color: STATUS_COLOR.pending, wrap: "truncate-end", children: "\u538B\u7F29\u4E0A\u4E0B\u6587\u4E2D" }) }), _jsx(Box, { minWidth: 0, children: _jsx(Text, { ...TEXT.secondary, wrap: "truncate-end", children: `· 把更早的历史折成摘要${seconds === '' ? '' : ` · 已用 ${seconds}`}` }) })] }));
74
+ }
73
75
  /**
74
76
  * 按显示宽度硬截单行:折行会破坏瀑布的恒定 3 行窗口(dsh clipLine 同款)。
75
77
  * 逐码点走,CJK/emoji 宽字符永远不会被劈成两半。
@@ -184,7 +186,7 @@ function SubagentCard({ sub, onOpen, registerClick, }) {
184
186
  const elapsed = sub.startedAt === undefined ? undefined : (sub.finishedAt ?? Date.now()) - sub.startedAt;
185
187
  const seconds = elapsed === undefined ? '' : fmtSeconds(elapsed);
186
188
  const activity = settled ? [] : (sub.outputLines ?? []).slice(-WATERFALL_ROWS);
187
- return (_jsxs(Box, { ref: ref, flexDirection: "column", marginLeft: INDENT.detail, gap: GAP.none, children: [_jsxs(Box, { flexDirection: "row", gap: 1, children: [_jsx(Box, { flexShrink: 0, children: _jsx(Text, { color: info.color, children: sub.state === 'working' ? _jsx(BrailleSpinner, {}) : info.glyph }) }), _jsx(Box, { flexShrink: 0, children: _jsx(Text, { bold: true, color: PALETTE.text, children: `子代理:${oneLine(sub.task, 42)}` }) }), _jsx(Box, { minWidth: 0, children: _jsxs(Text, { ...TEXT.secondary, wrap: "truncate-end", children: [`· ${sub.model ?? 'default'} · ${sub.rounds}轮 · ${sub.toolCalls}工具`, seconds === '' ? '' : ` · ${seconds}`, sub.tokens === undefined ? '' : ` · ${fmtTokens(sub.tokens)} tok`, ` · `] }) }), _jsx(Box, { flexShrink: 0, children: _jsx(Text, { color: info.color, children: info.label }) })] }), !settled && sub.lastTool !== undefined ? (_jsxs(Text, { ...TEXT.secondary, wrap: "truncate-end", children: [` ${sub.lastTool.status === 'done' ? '✓ ' : sub.lastTool.status === 'failed' ? '✗ ' : ''}${sub.lastTool.name}`, sub.lastTool.args !== '' ? ` (${clipLine(sub.lastTool.args, Math.max(10, rowWidth - sub.lastTool.name.length - 6))})` : ''] })) : null, !settled
189
+ return (_jsxs(Box, { ref: ref, flexDirection: "column", marginLeft: INDENT.detail, gap: GAP.none, children: [_jsxs(Box, { flexDirection: "row", gap: 1, children: [_jsx(Box, { flexShrink: 0, children: _jsx(Text, { color: info.color, children: sub.state === 'working' ? _jsx(BrailleSpinner, {}) : info.glyph }) }), _jsx(Box, { flexShrink: 0, children: _jsx(Text, { bold: true, color: PALETTE.text, children: `子代理:${oneLine(sub.task, 42)}` }) }), _jsx(Box, { minWidth: 0, children: _jsxs(Text, { ...TEXT.secondary, wrap: "truncate-end", children: [`· ${sub.model ?? 'default'} · ${sub.rounds}轮 · ${sub.toolCalls}工具`, seconds === '' ? '' : ` · ${seconds}`, sub.tokens === undefined ? '' : ` · ${compactTokens(sub.tokens)} tok`, ` · `] }) }), _jsx(Box, { flexShrink: 0, children: _jsx(Text, { color: info.color, children: info.label }) })] }), !settled && sub.lastTool !== undefined ? (_jsxs(Text, { ...TEXT.secondary, wrap: "truncate-end", children: [` ${sub.lastTool.status === 'done' ? '✓ ' : sub.lastTool.status === 'failed' ? '✗ ' : ''}${sub.lastTool.name}`, sub.lastTool.args !== '' ? ` (${clipLine(sub.lastTool.args, Math.max(10, rowWidth - sub.lastTool.name.length - 6))})` : ''] })) : null, !settled
188
190
  ? Array.from({ length: WATERFALL_ROWS }, (_, index) => (_jsx(Text, { ...TEXT.secondary, wrap: "truncate-end", children: ` │ ${clipLine(activity[index] ?? '', rowWidth)}` }, `wf-${index}`)))
189
191
  : null, settled && sub.state === 'failed' && sub.error !== undefined ? (_jsx(Text, { color: STATUS_COLOR.failed, wrap: "truncate-end", children: ` └ ${clipLine(sub.error, rowWidth)}` })) : null] }));
190
192
  }
@@ -292,7 +294,7 @@ export const Entry = memo(function Entry({ entry, streaming, expandThinking, exp
292
294
  return null;
293
295
  }
294
296
  });
295
- export function ChatView({ entries, turnState, expandThinking, empty, welcome, maxWidth, columns, railCenterLines, expandedTools, onToggleTool, onPreviewImages, onOpenAgent, onPickTurn, registerClick, viewportRef, onAtTailChange, }) {
297
+ export function ChatView({ entries, turnState, expandThinking, empty, welcome, maxWidth, columns, railCenterLines, expandedTools, onToggleTool, onPreviewImages, onOpenAgent, onPickTurn, registerClick, viewportRef, onAtTailChange, compactingSince, }) {
296
298
  // 直播尾(负 id)与最后定稿 text 条目才带光标闪烁位。
297
299
  const lastId = entries[entries.length - 1]?.id;
298
300
  // 流头部(欢迎页 + 一句开场提示)当流里的第一块,跟着内容一起滚
@@ -306,5 +308,7 @@ export function ChatView({ entries, turnState, expandThinking, empty, welcome, m
306
308
  if (source === undefined || source.kind !== 'user')
307
309
  return null;
308
310
  return (_jsx(PinnedTurn, { text: oneLine(source.text, 240), turn: active.index, width: width, onPick: onPickTurn, registerClick: registerClick }));
309
- }, renderEntry: (entry) => (_jsx(Entry, { entry: entry, streaming: entry.id === lastId && entry.id < 0 && (turnState === 'thinking' || turnState === 'working'), expandThinking: expandThinking, expandedTools: expandedTools, onToggleTool: onToggleTool, onPreviewImages: onPreviewImages, onOpenAgent: onOpenAgent, registerClick: registerClick })), ...(leading === undefined ? {} : { leading }) }));
311
+ }, renderEntry: (entry) => (_jsx(Entry, { entry: entry, streaming: entry.id === lastId && entry.id < 0 && (turnState === 'thinking' || turnState === 'working'), expandThinking: expandThinking, expandedTools: expandedTools, onToggleTool: onToggleTool, onPreviewImages: onPreviewImages, onOpenAgent: onOpenAgent, registerClick: registerClick })), ...(compactingSince === undefined
312
+ ? {}
313
+ : { footer: _jsx(CompactingLine, { startedAt: compactingSince }) }), ...(leading === undefined ? {} : { leading }) }));
310
314
  }
@@ -18,10 +18,11 @@ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
18
18
  */
19
19
  import { useEffect, useMemo, useRef, useState } from 'react';
20
20
  import { Box, Text, useInput } from 'ink';
21
- import { completionsFor, expandCommand } from '../core/commands-completion.js';
21
+ import { completionsFor, expandCommand, inputClaimOf } from '../core/commands-completion.js';
22
22
  import { collectWorkspaceFiles, insertMention, mentionQueryAt, rankMentionCandidates, } from '../core/mention.js';
23
23
  import { useParkedCursor } from './cursor.js';
24
- import { displayWidth, measuredSpan, useClickRegion } from './click.js';
24
+ import { measuredSpan, useClickRegion } from './click.js';
25
+ import { displayWidth } from './display-width.js';
25
26
  import { loadHistory, recordHistory } from './history-store.js';
26
27
  import { settingsWindowStart } from './settings-model.js';
27
28
  import { ACCENT, BORDER, GAP, MARK, PAD, SEP, STATUS_COLOR, TEXT } from './theme.js';
@@ -189,10 +190,22 @@ export function Composer({ disabled, models, placeholder, completionsEnabled = t
189
190
  if (panelOpen && mention !== null)
190
191
  return; // 上面已处理
191
192
  // 面板打开时 Enter 采用当前选中项(`/mo`+Enter → `/model `),否则按前缀展开。
193
+ const typed = value.trim();
192
194
  const chosen = panelOpen ? completions[safeIndex]?.insert : undefined;
193
- const text = expandCommand((chosen ?? value).trim());
195
+ const text = expandCommand((chosen ?? typed).trim());
194
196
  if (text === '')
195
197
  return;
198
+ // 要收输入的命令(`/review`):回车只补成 `/review ` 并停手,让用户在框里写要求;
199
+ // 再按一次回车才带着写好的要求提交。走 update 是为了顺带把补全面板选中项归零。
200
+ //
201
+ // 这里只认最终那一行(含面板选中项):`/review` 撞 `/reviewer` 前缀的问题在候选
202
+ // 排序里解决(`commandCompletions` 把精确同名排第一),不在这里按用户原话覆盖,
203
+ // 否则「用 ↑↓ 选了 /reviewer」会被改写成 /review。
204
+ const claim = inputClaimOf(text);
205
+ if (claim !== null) {
206
+ update(claim.insert, claim.insert.length);
207
+ return;
208
+ }
196
209
  setHistory((previous) => recordHistory(previous, text));
197
210
  setHistoryIndex(-1);
198
211
  setSuppressedFor(null);
@@ -275,7 +288,12 @@ export function Composer({ disabled, models, placeholder, completionsEnabled = t
275
288
  });
276
289
  return (_jsxs(Box, { flexDirection: "column", gap: GAP.none, children: [panelOpen ? (_jsxs(Box, { borderStyle: "single", borderColor: BORDER.frame, paddingX: PAD.inline, flexDirection: "column", gap: GAP.none, children: [panelVisible.map((item, position) => {
277
290
  const selected = panelStart + position === safeIndex;
278
- return (_jsxs(Text, { color: selected ? ACCENT : undefined, children: [selected ? MARK.selected : MARK.idle, item.label, _jsxs(Text, { ...TEXT.secondary, children: [SEP.gap, item.description] })] }, item.label));
291
+ // 命令候选带中文短名(宿主给,见 CommandSpec.label):第一列读中文,英文名跟在后头;
292
+ // 英文名取 label 的第一段(`/diff [文件]` → `/diff`)——菜单里不摆参数占位,
293
+ // 选中后宿主已补一个空格,接着打参数就行。模型候选没有 title,照旧只画 label。
294
+ // 英文名取 label 的第一段并去掉斜杠:三端(桌面 / 手机 / 终端)显示的同一个名字。
295
+ const english = item.title === undefined ? '' : (item.label.split(' ')[0] ?? item.label).replace(/^\//, '');
296
+ return (_jsxs(Text, { color: selected ? ACCENT : undefined, wrap: "truncate", children: [selected ? MARK.selected : MARK.idle, item.title === undefined ? item.label : `${item.title} ${english}`, _jsxs(Text, { ...TEXT.secondary, children: [SEP.gap, item.description] })] }, item.label));
279
297
  }), _jsxs(Text, { ...TEXT.secondary, children: [completions.length > panelVisible.length
280
298
  ? `${panelStart + 1}–${panelStart + panelVisible.length}/${completions.length} 条 · `
281
299
  : '', "\u2191\u2193 \u9009\u62E9 \u00B7 Tab \u8865\u5168 \u00B7 Esc \u5173\u95ED"] })] })) : null, attachments !== undefined && attachments.length > 0 ? (_jsx(Box, { gap: PAD.field, flexWrap: "wrap", children: attachments.map((att) => (_jsx(AttachmentChip, { att: att, onRemove: onRemoveAttachment, onPreview: onPreviewAttachment, registerClick: registerClick }, att.id))) })) : null, _jsxs(Box, { ref: inputBoxRef, borderStyle: "round", borderColor: disabled ? BORDER.frame : BORDER.active, paddingX: PAD.inline, children: [onOpenSessions !== undefined ? (_jsx(Box, { ref: homeRef, children: _jsx(Text, { ...TEXT.secondary, children: "\u2338 " }) })) : null, _jsxs(Text, { color: working && !disabled ? BORDER.frame : ACCENT, children: ["\u276F", ' '] }), value === '' && placeholder !== undefined ? (_jsx(Text, { ...TEXT.secondary, children: placeholder })) : (_jsx(Text, { ...TEXT.body, children: value }))] })] }));
@@ -13,7 +13,8 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
13
13
  */
14
14
  import { useMemo } from 'react';
15
15
  import { Box, Text, useStdout } from 'ink';
16
- import { displayWidth, parseMarkdown, } from './markdown.js';
16
+ import { parseMarkdown } from './markdown.js';
17
+ import { displayWidth } from './display-width.js';
17
18
  import { PAD, PALETTE, TEXT } from './theme.js';
18
19
  /** 行内片段 → ink Text 序列(链接补注 url)。 */
19
20
  function Spans({ spans }) {
@@ -7,12 +7,13 @@ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
7
7
  *
8
8
  * @module dsc-tui/app/ModelPicker
9
9
  */
10
- import { Box, Text } from 'ink';
11
- import { ACCENT, BORDER, GAP, MARK, PAD, SEP, TEXT } from './theme.js';
10
+ import { Text } from 'ink';
11
+ import { PickerFrame } from './PickerFrame.js';
12
+ import { ACCENT, MARK, SEP, TEXT } from './theme.js';
12
13
  export function ModelPicker({ models, index, query, }) {
13
14
  const safeIndex = Math.min(index, Math.max(0, models.length - 1));
14
- return (_jsx(Box, { borderStyle: "round", borderColor: BORDER.active, paddingX: PAD.inline, flexDirection: "column", flexGrow: 1, overflowY: "hidden", gap: GAP.none, children: _jsxs(Box, { flexShrink: 0, flexDirection: "column", gap: GAP.none, children: [_jsxs(Text, { ...TEXT.label, color: ACCENT, wrap: "truncate-end", children: ["\u6A21\u578B\u9009\u62E9\uFF08", models.length, " \u4E2A\uFF09", _jsxs(Text, { ...TEXT.secondary, children: [SEP.gap, "\u70B9\u51FB\u9009\u4E2D\u3001\u518D\u70B9\u5E94\u7528 \u00B7 Enter \u5207\u6362\uFF08\u4E0B\u4E00\u6B21\u8BF7\u6C42\u751F\u6548\uFF09"] })] }), _jsxs(Text, { wrap: "truncate-end", children: [_jsxs(Text, { ...TEXT.label, color: ACCENT, children: ["\u7B5B\u9009", ' '] }), _jsxs(Text, { ...(query === '' ? TEXT.secondary : TEXT.body), children: [query === '' ? '(直接输入按端点/模型/说明过滤)' : query, _jsx(Text, { ...TEXT.secondary, children: "\u258F" })] })] }), models.length === 0 ? _jsx(Text, { ...TEXT.secondary, children: "\uFF08\u6CA1\u6709\u5339\u914D\u7684\u6A21\u578B\uFF09" }) : null, models.map((choice, position) => {
15
- const selected = position === safeIndex;
16
- return (_jsxs(Text, { color: selected ? ACCENT : undefined, wrap: "truncate-end", children: [selected ? MARK.selected : MARK.idle, choice.value, _jsxs(Text, { ...TEXT.secondary, children: [SEP.gap, choice.description] })] }, choice.value));
17
- }), _jsx(Text, { ...TEXT.secondary, wrap: "truncate-end", children: "\u2191\u2193 \u9009\u62E9 \u00B7 Enter \u5207\u6362 \u00B7 Esc \u5173\u95ED" })] }) }));
15
+ return (_jsxs(PickerFrame, { children: [_jsxs(Text, { ...TEXT.label, color: ACCENT, wrap: "truncate-end", children: ["\u6A21\u578B\u9009\u62E9\uFF08", models.length, " \u4E2A\uFF09", _jsxs(Text, { ...TEXT.secondary, children: [SEP.gap, "\u70B9\u51FB\u9009\u4E2D\u3001\u518D\u70B9\u5E94\u7528 \u00B7 Enter \u5207\u6362\uFF08\u4E0B\u4E00\u6B21\u8BF7\u6C42\u751F\u6548\uFF09"] })] }), _jsxs(Text, { wrap: "truncate-end", children: [_jsxs(Text, { ...TEXT.label, color: ACCENT, children: ["\u7B5B\u9009", ' '] }), _jsxs(Text, { ...(query === '' ? TEXT.secondary : TEXT.body), children: [query === '' ? '(直接输入按端点/模型/说明过滤)' : query, _jsx(Text, { ...TEXT.secondary, children: "\u258F" })] })] }), models.length === 0 ? _jsx(Text, { ...TEXT.secondary, children: "\uFF08\u6CA1\u6709\u5339\u914D\u7684\u6A21\u578B\uFF09" }) : null, models.map((choice, position) => {
16
+ const selected = position === safeIndex;
17
+ return (_jsxs(Text, { color: selected ? ACCENT : undefined, wrap: "truncate-end", children: [selected ? MARK.selected : MARK.idle, choice.value, _jsxs(Text, { ...TEXT.secondary, children: [SEP.gap, choice.description] })] }, choice.value));
18
+ }), _jsx(Text, { ...TEXT.secondary, wrap: "truncate-end", children: "\u2191\u2193 \u9009\u62E9 \u00B7 Enter \u5207\u6362 \u00B7 Esc \u5173\u95ED" })] }));
18
19
  }
@@ -0,0 +1,4 @@
1
+ import type { JSX, ReactNode } from 'react';
2
+ export declare function PickerFrame({ children }: {
3
+ children: ReactNode;
4
+ }): JSX.Element;
@@ -0,0 +1,18 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /**
3
+ * 终端浮层的公共外框:一层圆角边框,里面一层贴顶容器。
4
+ *
5
+ * 为什么要抽:模型、模式、技能、会话、子代理这五个浮层(`/model`、`/preset`、`/skills`、
6
+ * `/resume`、子代理清单)的外框与内层容器**逐字相同**——8 行属性一模一样。改一次圆角或
7
+ * 内边距要改五遍,漏掉的那一个在终端里看着就是歪的,而这类偏差没人会专门去查。
8
+ *
9
+ * 只收这两层:标题、筛选行、候选行、脚注仍归各浮层自己排。它们本来就不一样(有的带
10
+ * 计数、有的带分页、有的带状态色),硬凑成一个组件只会换来一堆布尔开关。
11
+ *
12
+ * @module dsc-tui/app/PickerFrame
13
+ */
14
+ import { Box } from 'ink';
15
+ import { BORDER, GAP, PAD } from './theme.js';
16
+ export function PickerFrame({ children }) {
17
+ return (_jsx(Box, { borderStyle: "round", borderColor: BORDER.active, paddingX: PAD.inline, flexDirection: "column", flexGrow: 1, overflowY: "hidden", gap: GAP.none, children: _jsx(Box, { flexShrink: 0, flexDirection: "column", gap: GAP.none, children: children }) }));
18
+ }
@@ -11,7 +11,8 @@ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
11
11
  import { useRef } from 'react';
12
12
  import { Box, Text } from 'ink';
13
13
  import { ACCENT, BORDER, GAP, PAD, STATUS_COLOR, TEXT } from './theme.js';
14
- import { absoluteLeft, displayWidth, useClickRegion } from './click.js';
14
+ import { absoluteLeft, useClickRegion } from './click.js';
15
+ import { displayWidth } from './display-width.js';
15
16
  /** 折叠时保留的正文行数。 */
16
17
  const PREVIEW_LINES = 12;
17
18
  const BUTTONS = [
@@ -7,13 +7,14 @@ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
7
7
  *
8
8
  * @module dsc-tui/app/PresetPicker
9
9
  */
10
- import { Box, Text } from 'ink';
11
- import { ACCENT, BORDER, GAP, MARK, PAD, SEP, STATUS_COLOR, TEXT } from './theme.js';
10
+ import { Text } from 'ink';
11
+ import { PickerFrame } from './PickerFrame.js';
12
+ import { ACCENT, MARK, SEP, STATUS_COLOR, TEXT } from './theme.js';
12
13
  export function PresetPicker({ presets, current, defaultName, index, query, }) {
13
14
  const safeIndex = Math.min(index, Math.max(0, presets.length - 1));
14
- return (_jsx(Box, { borderStyle: "round", borderColor: BORDER.active, paddingX: PAD.inline, flexDirection: "column", flexGrow: 1, overflowY: "hidden", gap: GAP.none, children: _jsxs(Box, { flexShrink: 0, flexDirection: "column", gap: GAP.none, children: [_jsxs(Text, { ...TEXT.label, color: ACCENT, wrap: "truncate-end", children: ["\u6A21\u5F0F\u9009\u62E9\uFF08", presets.length, " \u4E2A\uFF09", _jsxs(Text, { ...TEXT.secondary, children: [SEP.gap, "\u70B9\u51FB\u9009\u4E2D\u3001\u518D\u70B9\u5207\u6362 \u00B7 Enter \u5207\u6362\uFF08\u5199\u8FDB\u4F1A\u8BDD\u8BB0\u5F55\uFF0C\u6062\u590D\u4F1A\u8BDD\u65F6\u8DDF\u7740\u56DE\u6765\uFF09"] })] }), _jsxs(Text, { wrap: "truncate-end", children: [_jsxs(Text, { ...TEXT.label, color: ACCENT, children: ["\u7B5B\u9009", ' '] }), _jsxs(Text, { ...(query === '' ? TEXT.secondary : TEXT.body), children: [query === '' ? '(直接输入按显示名/名字/说明过滤)' : query, _jsx(Text, { ...TEXT.secondary, children: "\u258F" })] })] }), presets.length === 0 ? _jsx(Text, { ...TEXT.secondary, children: "\uFF08\u6CA1\u6709\u5339\u914D\u7684\u6A21\u5F0F\uFF09" }) : null, presets.map((preset, position) => {
15
- const selected = position === safeIndex;
16
- const isCurrent = preset.name === current;
17
- return (_jsxs(Text, { color: selected ? ACCENT : undefined, wrap: "truncate-end", children: [selected ? MARK.selected : MARK.idle, preset.label, _jsxs(Text, { ...TEXT.secondary, children: [SEP.gap, preset.name] }), isCurrent ? _jsxs(Text, { ...TEXT.label, color: STATUS_COLOR.done, children: [SEP.gap, "\u2713 \u5F53\u524D"] }) : null, !isCurrent && preset.name === defaultName ? (_jsxs(Text, { ...TEXT.label, color: STATUS_COLOR.waiting, children: [SEP.gap, "\u9ED8\u8BA4"] })) : null, preset.builtin ? _jsxs(Text, { ...TEXT.secondary, children: [SEP.gap, "\u5185\u7F6E"] }) : null, _jsxs(Text, { ...TEXT.secondary, children: [SEP.gap, preset.description] }), preset.problem !== undefined ? (_jsxs(Text, { ...TEXT.label, color: STATUS_COLOR.failed, children: [SEP.gap, "\u6CE8\u610F\uFF1A", preset.problem] })) : null] }, preset.name));
18
- }), _jsx(Text, { ...TEXT.secondary, wrap: "truncate-end", children: "\u2191\u2193 \u9009\u62E9 \u00B7 Enter \u5207\u6362 \u00B7 Esc \u5173\u95ED \u00B7 \u5E26\u53C2\u6570\u5207\u6362\u8D70 /preset <\u540D\u5B57>" })] }) }));
15
+ return (_jsxs(PickerFrame, { children: [_jsxs(Text, { ...TEXT.label, color: ACCENT, wrap: "truncate-end", children: ["\u6A21\u5F0F\u9009\u62E9\uFF08", presets.length, " \u4E2A\uFF09", _jsxs(Text, { ...TEXT.secondary, children: [SEP.gap, "\u70B9\u51FB\u9009\u4E2D\u3001\u518D\u70B9\u5207\u6362 \u00B7 Enter \u5207\u6362\uFF08\u5199\u8FDB\u4F1A\u8BDD\u8BB0\u5F55\uFF0C\u6062\u590D\u4F1A\u8BDD\u65F6\u8DDF\u7740\u56DE\u6765\uFF09"] })] }), _jsxs(Text, { wrap: "truncate-end", children: [_jsxs(Text, { ...TEXT.label, color: ACCENT, children: ["\u7B5B\u9009", ' '] }), _jsxs(Text, { ...(query === '' ? TEXT.secondary : TEXT.body), children: [query === '' ? '(直接输入按显示名/名字/说明过滤)' : query, _jsx(Text, { ...TEXT.secondary, children: "\u258F" })] })] }), presets.length === 0 ? _jsx(Text, { ...TEXT.secondary, children: "\uFF08\u6CA1\u6709\u5339\u914D\u7684\u6A21\u5F0F\uFF09" }) : null, presets.map((preset, position) => {
16
+ const selected = position === safeIndex;
17
+ const isCurrent = preset.name === current;
18
+ return (_jsxs(Text, { color: selected ? ACCENT : undefined, wrap: "truncate-end", children: [selected ? MARK.selected : MARK.idle, preset.label, _jsxs(Text, { ...TEXT.secondary, children: [SEP.gap, preset.name] }), isCurrent ? _jsxs(Text, { ...TEXT.label, color: STATUS_COLOR.done, children: [SEP.gap, "\u2713 \u5F53\u524D"] }) : null, !isCurrent && preset.name === defaultName ? (_jsxs(Text, { ...TEXT.label, color: STATUS_COLOR.waiting, children: [SEP.gap, "\u9ED8\u8BA4"] })) : null, preset.builtin ? _jsxs(Text, { ...TEXT.secondary, children: [SEP.gap, "\u5185\u7F6E"] }) : null, _jsxs(Text, { ...TEXT.secondary, children: [SEP.gap, preset.description] }), preset.problem !== undefined ? (_jsxs(Text, { ...TEXT.label, color: STATUS_COLOR.failed, children: [SEP.gap, "\u6CE8\u610F\uFF1A", preset.problem] })) : null] }, preset.name));
19
+ }), _jsx(Text, { ...TEXT.secondary, wrap: "truncate-end", children: "\u2191\u2193 \u9009\u62E9 \u00B7 Enter \u5207\u6362 \u00B7 Esc \u5173\u95ED \u00B7 \u5E26\u53C2\u6570\u5207\u6362\u8D70 /preset <\u540D\u5B57>" })] }));
19
20
  }