@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
@@ -17,10 +17,40 @@ export interface DshToolDefinitionLike {
17
17
  description: unknown;
18
18
  parameters: unknown;
19
19
  execute?: unknown;
20
- /** dsh 规定必填;兼容层对缺了它的定义容错(跳过投影直接字符串化)。 */
20
+ /**
21
+ * dsh 规定必填;兼容层对缺了它的定义容错(跳过投影直接字符串化)。
22
+ *
23
+ * - `schema`:规范值的 JSON Schema,**声明了就校验**(dsh 会拒收不合 schema 的返回值);
24
+ * - `render`:规范值 → 内容块(模型可见文本);
25
+ * - `presentationMeta`:可重放的展示投影(卡片数据,与值无关的纯数据)。
26
+ */
21
27
  output?: {
22
28
  render?: unknown;
29
+ schema?: unknown;
30
+ presentationMeta?: unknown;
23
31
  } | unknown;
32
+ /** 调用阶段怎么画(dsh 的 ToolCallView)。 */
33
+ presentCall?: unknown;
34
+ /** 完成阶段怎么画(dsh 的 ToolResultView)。 */
35
+ presentResult?: unknown;
36
+ /**
37
+ * 执行体返回之后、任何策略之前,用它准备好的内容顶替模型可见内容
38
+ * (dsh 的 projectContent;返回 undefined 表示保持原样)。
39
+ *
40
+ * dsh 里这一步跑在 `tools/post-execute` 之前,好让策略看见真实图片块;
41
+ * 兼容层没有 post-execute 阶段,所以它直接排在 render 之后。
42
+ */
43
+ projectContent?: unknown;
44
+ /**
45
+ * 最后一公里改写模型可见内容(dsh 的 finalizeContent;返回 undefined 表示保持原样)。
46
+ *
47
+ * dsh 对**每一个**结果都调用它,失败结果也在内——那正是「把长输出截断」类
48
+ * 钩子能连错误文案一起裁的原因;兼容层照这个口径,成功路径在 render 之后调,
49
+ * 失败路径在错误抛出前调。
50
+ */
51
+ finalizeContent?: unknown;
52
+ /** 这条调用能不能与同轮别的工具并行(只认明确的 true)。 */
53
+ isConcurrencySafe?: unknown;
24
54
  timeoutMs?: unknown;
25
55
  }
26
56
  /** 插件条目树里关于 risk 的配置形状(值来自 JSON,宽松收进来再收敛)。 */
@@ -1,3 +1,4 @@
1
+ import { asCardView, validateOutput } from './presentation.js';
1
2
  const RISKS = new Set(['read', 'write', 'exec']);
2
3
  /** 判一个对象像不像 dsh 的 ToolDefinition(有 execute、没有 dsc 的 run)。 */
3
4
  export function looksLikeDshToolDefinition(candidate) {
@@ -40,6 +41,126 @@ function blocksToOutput(blocks, name) {
40
41
  function valueToText(value) {
41
42
  return typeof value === 'string' ? value : JSON.stringify(value, null, 2);
42
43
  }
44
+ /**
45
+ * 任意 render 产物 → 内容块数组。
46
+ *
47
+ * dsh 的 render 按契约返回 ContentBlock[],但兼容层对写歪的定义容错(返回字符串
48
+ * 或对象也收):先归一成数组,两个内容钩子才有一致的入参。
49
+ */
50
+ function asBlocks(raw) {
51
+ if (Array.isArray(raw))
52
+ return raw;
53
+ if (typeof raw === 'string')
54
+ return [{ type: 'text', text: raw }];
55
+ return [{ type: 'text', text: JSON.stringify(raw, null, 2) ?? String(raw) }];
56
+ }
57
+ /** 内容块 → 纯文本(失败路径要把钩子改过的内容折回错误文案)。 */
58
+ function blocksToText(blocks, name) {
59
+ const out = blocksToOutput(blocks, name);
60
+ return typeof out === 'string' ? out : out.text;
61
+ }
62
+ /**
63
+ * 跑 dsh 的两个内容钩子:先 projectContent,再 finalizeContent。
64
+ *
65
+ * 顺序与 dsh 一致(投影在策略前、定稿在策略后);两边都只认「返回数组」这一种
66
+ * 替换信号,返回 undefined 或抛错都保持原内容——与 dsh 的容错口径相同,
67
+ * 钩子写坏了不该让工具结果变成错误。
68
+ */
69
+ function applyContentHooks(definition, exec, value, blocks, name) {
70
+ const project = definition.projectContent;
71
+ const finalize = definition.finalizeContent;
72
+ if (typeof project !== 'function' && typeof finalize !== 'function')
73
+ return blocks;
74
+ let content = blocks;
75
+ // 冻结一份结果视图给钩子:dsh 传的是只读对象,插件不该能改我们的内部状态。
76
+ const result = Object.freeze({ isError: false, value, content });
77
+ if (typeof project === 'function') {
78
+ try {
79
+ const next = project(exec, result);
80
+ if (Array.isArray(next))
81
+ content = next;
82
+ }
83
+ catch (error) {
84
+ console.warn(`[dsh-compat] 工具 ${name} 的 projectContent 抛错,保留 render 的原始内容:${String(error)}`);
85
+ }
86
+ }
87
+ if (typeof finalize === 'function') {
88
+ try {
89
+ const next = finalize(exec, Object.freeze({ ...result, content }));
90
+ if (Array.isArray(next))
91
+ content = next;
92
+ }
93
+ catch (error) {
94
+ console.warn(`[dsh-compat] 工具 ${name} 的 finalizeContent 抛错,保留前一步的内容:${String(error)}`);
95
+ }
96
+ }
97
+ return content;
98
+ }
99
+ /**
100
+ * 失败路径的 finalizeContent:dsh 对这个钩子的承诺是「每个结果都调一次」,
101
+ * 错误结果也不例外(长输出工具靠它把错误文案一起截断)。
102
+ *
103
+ * 只在插件确实声明了钩子时才介入:没声明的插件抛什么就还是什么,错误类型与
104
+ * 堆栈一律不动;钩子自己抛错时退回原错误,绝不把错误换成「钩子失败」。
105
+ */
106
+ function finalizeFailure(definition, exec, name, error) {
107
+ const finalize = definition.finalizeContent;
108
+ if (typeof finalize !== 'function')
109
+ return error;
110
+ try {
111
+ const message = error instanceof Error ? error.message : String(error);
112
+ const content = [{ type: 'text', text: message }];
113
+ const result = Object.freeze({ isError: true, error: Object.freeze({ message }), content });
114
+ const next = finalize(exec, result);
115
+ if (!Array.isArray(next))
116
+ return error;
117
+ const text = blocksToText(next, name);
118
+ if (!(error instanceof Error))
119
+ return new Error(text);
120
+ try {
121
+ // 改 message 而不是新建错误:工具错误的类型(审批分类看得见)与堆栈都留住。
122
+ error.message = text;
123
+ return error;
124
+ }
125
+ catch {
126
+ // 冻结/只读的错误对象改不动,那就退回原错误——文案不完美好过类型丢失。
127
+ return error;
128
+ }
129
+ }
130
+ catch {
131
+ return error;
132
+ }
133
+ }
134
+ /** 把卡片数据挂到工具输出上(输出可能是字符串,那就升成对象)。 */
135
+ function withPresentation(output, presentation) {
136
+ if (presentation === undefined)
137
+ return output;
138
+ return typeof output === 'string' ? { text: output, presentation } : { ...output, presentation };
139
+ }
140
+ /** 一次调用能拿到的卡片:presentCall / presentResult / presentationMeta 三者有其一。 */
141
+ function cardsOf(definition, args, value, rendered) {
142
+ const call = typeof definition.presentCall === 'function'
143
+ ? asCardView(definition.presentCall(args))
144
+ : undefined;
145
+ const result = typeof definition.presentResult === 'function'
146
+ ? asCardView(definition.presentResult(args, {
147
+ // dsh 的 ToolResult:这里能给的只有渲染后的内容,够画卡了
148
+ content: typeof rendered === 'string' ? [{ type: 'text', text: rendered }] : [{ type: 'text', text: rendered.text }],
149
+ text: typeof rendered === 'string' ? rendered : rendered.text,
150
+ }))
151
+ : undefined;
152
+ const output = (definition.output ?? {});
153
+ const meta = typeof output.presentationMeta === 'function'
154
+ ? output.presentationMeta(args, value)
155
+ : undefined;
156
+ if (call === undefined && result === undefined && meta === undefined)
157
+ return undefined;
158
+ return {
159
+ ...(call === undefined ? {} : { call }),
160
+ ...(result === undefined ? {} : { result }),
161
+ ...(meta === undefined ? {} : { meta }),
162
+ };
163
+ }
43
164
  /**
44
165
  * 把一个 dsh ToolDefinition 包成 dsc ToolEntry。转出来的工具:
45
166
  * - 参数 schema 原样透传(两边同是 JSON Schema,llm 层怎么发就怎么发);
@@ -54,12 +175,38 @@ export function dshToolToEntry(definition, config) {
54
175
  : undefined;
55
176
  const renderFn = typeof render === 'function' ? render : undefined;
56
177
  const timeoutMs = typeof definition.timeoutMs === 'number' && definition.timeoutMs > 0 ? definition.timeoutMs : undefined;
178
+ const outputDef = (definition.output ?? {});
179
+ const schema = outputDef.schema === undefined ? undefined : outputDef.schema;
180
+ // 并发分类:只有明确返回 true 才算可并行(dsh 同一口径),抛错也当独占。
181
+ const concurrency = definition.isConcurrencySafe;
57
182
  const run = async (args, ctx) => {
58
183
  if (execute === undefined)
59
184
  throw new Error(`工具 ${name} 没有 execute 实现`);
60
- const exec = { signal: ctx.signal, cwd: ctx.cwd };
61
- const value = timeoutMs === undefined ? await execute(args, exec) : await withTimeout(execute(args, exec), name, timeoutMs);
62
- return renderFn !== undefined ? blocksToOutput(renderFn(args, value), name) : valueToText(value);
185
+ const exec = dshExec(name, args, ctx);
186
+ let value;
187
+ try {
188
+ value = timeoutMs === undefined ? await execute(args, exec) : await withTimeout(execute(args, exec), name, timeoutMs);
189
+ }
190
+ catch (error) {
191
+ // 失败结果也过一道 finalizeContent(声明了才走),见 finalizeFailure。
192
+ throw finalizeFailure(definition, exec, name, error);
193
+ }
194
+ // 规范值契约:声明了 output.schema 就校验;不合 schema 的返回值**不当成功**。
195
+ // 这条是 dsh 的硬规矩(违例抛 ToolArgsError),这里是同一处把关,只是文案说人话。
196
+ if (schema !== undefined) {
197
+ const violations = validateOutput(schema, value);
198
+ if (violations.length > 0) {
199
+ const head = violations.slice(0, 3).join(';');
200
+ const more = violations.length > 3 ? `(另有 ${String(violations.length - 3)} 处)` : '';
201
+ throw new Error(`工具 ${name} 的返回值不符合它自己声明的 output.schema:${head}${more}`);
202
+ }
203
+ }
204
+ const raw = renderFn !== undefined ? renderFn(args, value) : valueToText(value);
205
+ // 内容钩子排在 render 之后:compat 层没有 dsh 的 post-execute 阶段,
206
+ // projectContent 与 finalizeContent 在这里一前一后跑完,都只认「返回数组」。
207
+ const content = applyContentHooks(definition, exec, value, asBlocks(raw), name);
208
+ const rendered = blocksToOutput(content, name);
209
+ return withPresentation(rendered, cardsOf(definition, args, value, rendered));
63
210
  };
64
211
  return {
65
212
  name,
@@ -68,9 +215,66 @@ export function dshToolToEntry(definition, config) {
68
215
  ? definition.parameters
69
216
  : { type: 'object', properties: {} },
70
217
  risk: riskFor(definition, config),
218
+ ...(timeoutMs === undefined ? {} : { timeoutMs }),
219
+ ...(typeof concurrency === 'function'
220
+ ? {
221
+ isConcurrencySafe: (args) => {
222
+ try {
223
+ return concurrency(args) === true;
224
+ }
225
+ catch {
226
+ // 分类器抛错当独占(与 dsh 同一口径:出错就不并行)。
227
+ return false;
228
+ }
229
+ },
230
+ }
231
+ : {}),
71
232
  run,
72
233
  };
73
234
  }
235
+ /**
236
+ * 造 dsh 的执行上下文(`exec`)。
237
+ *
238
+ * 能给的真给,给不了的**明确降级**而不是假装有:
239
+ * - `signal` / `cwd`:真值;
240
+ * - `arguments`:真值(dsh 声明它是解析后的参数);
241
+ * - `agent`:从 dsc 的 `caller` 折出来(队友名/层级;主会话是 lead);
242
+ * - `token`:合成的对象(dsc 没有传输级执行令牌,这里只有身份信息,不要当授权凭据用);
243
+ * - `callId`:合成(dsc 的 callId 在循环那边,工具层拿不到);
244
+ * - `deferContext`:**收下但不投递**——dsc 的循环没有「延迟上下文」这条通道,
245
+ * 照 dsh 的说法这会把内容推迟进下一轮请求,我们没有对应落点,只能记一条告警;
246
+ * - `concludeTurn`:**空操作**(dsc 的收尾由循环自己判,工具说不了话)。
247
+ *
248
+ * 这两条降级在开发日志里有记录:用到它们的 dsh 插件行为会不完整,但不会崩。
249
+ */
250
+ function dshExec(name, args, ctx) {
251
+ let warned = false;
252
+ const warnOnce = (what) => {
253
+ if (warned)
254
+ return;
255
+ warned = true;
256
+ console.warn(`[dsh-compat] 工具 ${name} 用了 ${what},dsc 没有对应通道,已按空操作处理`);
257
+ };
258
+ return {
259
+ signal: ctx.signal,
260
+ cwd: ctx.cwd,
261
+ arguments: args,
262
+ callId: `${name}@${String(Date.now())}`,
263
+ token: { name, sessionId: ctx.sessionId, synthetic: true },
264
+ agent: {
265
+ name: ctx.caller?.name ?? 'lead',
266
+ depth: ctx.caller?.depth ?? 0,
267
+ background: ctx.caller?.background ?? false,
268
+ },
269
+ deferContext: (message) => {
270
+ warnOnce('deferContext(延迟上下文)');
271
+ void message;
272
+ },
273
+ concludeTurn: () => {
274
+ warnOnce('concludeTurn(工具收尾本轮)');
275
+ },
276
+ };
277
+ }
74
278
  async function withTimeout(promise, name, timeoutMs) {
75
279
  let timer;
76
280
  const timeout = new Promise((_, reject) => {
@@ -7,6 +7,11 @@
7
7
  * (渲染层照 diff-text 的先例经 `@dsc/runtime/err-text.js` 取用;adapter/transcript
8
8
  * 保留同名 re-export,既有 18 处 import 不断)。
9
9
  *
10
+ * 2026-10-28 第三批复审:另有十处把它叫成 `errorText` 各写一遍(core/mcp、core 的
11
+ * sandbox/win 四份、core/remote 两份、core/schedule/store、plugins/lsp、plugins/mcp)。
12
+ * 那些地方已改成 `import { errText as errorText }`——名字留着是为了不动调用点,
13
+ * 实现只能有这一份。
14
+ *
10
15
  * @module dsc/core/err-text
11
16
  */
12
17
  /** 把抛出来的东西压成一句话(Error 取 message,其余 String 化)。 */
@@ -7,6 +7,11 @@
7
7
  * (渲染层照 diff-text 的先例经 `@dsc/runtime/err-text.js` 取用;adapter/transcript
8
8
  * 保留同名 re-export,既有 18 处 import 不断)。
9
9
  *
10
+ * 2026-10-28 第三批复审:另有十处把它叫成 `errorText` 各写一遍(core/mcp、core 的
11
+ * sandbox/win 四份、core/remote 两份、core/schedule/store、plugins/lsp、plugins/mcp)。
12
+ * 那些地方已改成 `import { errText as errorText }`——名字留着是为了不动调用点,
13
+ * 实现只能有这一份。
14
+ *
10
15
  * @module dsc/core/err-text
11
16
  */
12
17
  /** 把抛出来的东西压成一句话(Error 取 message,其余 String 化)。 */
@@ -5,23 +5,30 @@
5
5
  *
6
6
  * @module dsc/core/events
7
7
  */
8
- import type { FileChangeSummary } from './tools.js';
8
+ import type { FileChangeSummary, ToolPresentation } from './tools.js';
9
9
  import type { RequestSegments } from './token-estimate.js';
10
10
  import type { SubagentCardView } from '../contract.js';
11
11
  /** MiniAgent 事件。 */
12
12
  export type CoreEvent =
13
13
  /**
14
- * 用户输入已入会话(回显);images 是随消息发出去的 data URL 清单。
14
+ * 用户输入已入会话(回显);images 是随消息发出去的图片(引用或老式 data URL),
15
+ * files 是视频 / 通用文件的落盘元数据(界面据此画文件卡;模型侧只看到路径句柄)。
15
16
  *
16
17
  * `steering` = 这条是在助手回合**还没跑完**时插进来的(对照 dsh 的 steering 节点)。
17
18
  * 它同样会被并进这一轮的下一次模型请求(messages 是同一份),区别只在界面上:
18
19
  * 轮中途插过话的那一轮不再提供整轮折叠(对照 dsh 的 `hasInterleavedInput`)。
20
+ *
21
+ * `origin: 'notice'` = 机器投递的唤醒(后台作业完成、定时补投、目标续跑……),不是人打的字:
22
+ * 界面据此画成一行内部触发行。它与日志里那条 user 记录的 `origin` 同源,重放走的是
23
+ * 同一个字段(见 core/session 的 InboxOrigin)。
19
24
  */
20
25
  {
21
26
  type: 'user';
22
27
  text: string;
23
28
  images?: string[];
29
+ files?: import('./attachments.js').UserFileAttachment[];
24
30
  steering?: boolean;
31
+ origin?: 'user' | 'notice';
25
32
  }
26
33
  /**
27
34
  * 收件箱变了(入箱 / 编辑 / 删除 / 提前),本身不产生条目:界面照快照里的
@@ -42,6 +49,18 @@ export type CoreEvent =
42
49
  text: string;
43
50
  reasoning: string;
44
51
  finishReason?: string | null;
52
+ /**
53
+ * 这一步模型吐出的工具调用(原样,参数是未解析的 JSON 字符串)。
54
+ *
55
+ * 为什么要带出来:dsh 的 `assistant/message` 把「说了什么」和「要调什么」放在同一条
56
+ * 消息里(工具调用是消息的内容块),只听 `tool/call` 事件重建不出那条消息。
57
+ * 我们的转录不用它(它按 `tool/call` 画卡),所以是可选的旁路字段。
58
+ */
59
+ toolCalls?: {
60
+ id: string;
61
+ name: string;
62
+ arguments: string;
63
+ }[];
45
64
  }
46
65
  /** 流式增量(直播尾)。 */
47
66
  | {
@@ -84,6 +103,16 @@ export type CoreEvent =
84
103
  callId: string;
85
104
  change: FileChangeSummary;
86
105
  }
106
+ /**
107
+ * 这次调用带给界面的卡片数据(dsh 插件的 presentCall / presentResult /
108
+ * presentationMeta 产物)。紧跟同 callId 的 `tool/result`;adapter 缝到工具卡上
109
+ * (`ToolCallView.presentation`),界面按 `card` 标签挑形态。
110
+ */
111
+ | {
112
+ type: 'tool/presentation';
113
+ callId: string;
114
+ presentation: ToolPresentation;
115
+ }
87
116
  /**
88
117
  * 回合收尾的聚合改动(codex TurnDiffUpdatedNotification 的同位事件):本回合动过的
89
118
  * 每个文件出一份「回合基线 vs 盘上终态」的差异,同文件多刀合并成一条。紧跟在
@@ -1,26 +1,137 @@
1
+ import type { ReviewStatusView } from '../services/types.js';
1
2
  import { type FileChangeSummary } from './tools.js';
2
- /** 审查 diff 塞进上下文的字符预算(约 1.5 万 token;超了从尾部截,头部是改动清单更值钱)。 */
3
- export declare const REVIEW_DIFF_BUDGET = 60000;
4
3
  /** 受控执行 git(execFile 固定首参字面量 + 参数数组;无 shell)。 */
5
4
  export declare function gitExec(cwd: string, args: string[]): Promise<string>;
6
5
  /**
7
- * 收集工作区未提交改动(codex /review 的 UncommittedChanges 目标):
8
- * `git diff HEAD` 含已暂存改动;untracked 不进 diff(`git diff` 本来就不含它们),
9
- * 只列名单让模型自己 read。不是 git 仓库时返回 null。
6
+ * 校验用户给的分支 / 提交引用。
7
+ *
8
+ * 为什么非校验不可:`git show <ref>` 的 ref 来自 `/review` 后面的自由输入,而
9
+ * `execFile` 只挡得住 shell 拼接、挡不住**选项注入**——填 `--output=D:\\任意路径` 时
10
+ * git 会把它当选项执行(把补丁写进那个文件)。所以只放行正常引用字符,并且不许以
11
+ * `-` 开头(那就是选项的地盘)。`~`、`^`、`@{` 这些 rev 语法照常可用。
12
+ *
13
+ * @param ref - 用户输入或候选里的原始值
14
+ * @returns 去掉首尾空白的引用
10
15
  */
11
- export declare function collectWorkingTree(cwd: string): Promise<{
12
- diff: string;
16
+ export declare function assertReviewRef(ref: string): string;
17
+ /** /review 的审查范围。 */
18
+ export type ReviewTarget = {
19
+ kind: 'worktree';
20
+ } | {
21
+ kind: 'base';
22
+ ref: string;
23
+ } | {
24
+ kind: 'commit';
25
+ ref: string;
26
+ title?: string;
27
+ } | {
28
+ kind: 'custom';
29
+ instructions: string;
30
+ };
31
+ /** 一次审查的取数结果:范围描述 + 完整 diff 落盘路径 + 改动清单 + 未跟踪名单。 */
32
+ export interface ReviewScope {
33
+ target: ReviewTarget;
34
+ /** 给用户与队友看的一句话范围(「未提交改动」「对比基准分支 main 的差异(共同祖先 abc1234)」)。 */
35
+ label: string;
36
+ /** 完整 diff 落盘的绝对路径。 */
37
+ diffPath: string;
38
+ /** 落盘 diff 的字节数(不是字符数——中文一个字 3 字节,按字节算才知道文件多大)。 */
39
+ diffBytes: number;
40
+ /** `git diff --stat` 的原文:给队友一眼看清单。 */
41
+ stat: string;
42
+ /** 未跟踪文件(diff 里本来就没有它们,只列名单让队友自己 read)。 */
13
43
  untracked: string[];
14
- } | null>;
44
+ /** base 范围算出来的共同祖先提交(完整 SHA)。 */
45
+ base?: string;
46
+ }
15
47
  /**
16
- * /review 的审查消息组装(T18:主会话回落轮与审查队友的任务描述共用这一份)。
17
- * 独立成纯函数便于脱离命令体系直测;挪进本模块是因为「收集」与「组装」同域,
18
- * 而 commands.js 的顶层不许出现 node 内置模块 import。
48
+ * 按范围取一次审查的完整数据(不截断)。
49
+ *
50
+ * 取数口径(`--no-textconv --no-ext-diff` 防文本转换与外部 diff driver 当场跑程序):
51
+ * - worktree / custom:`git diff HEAD`(含已暂存;未跟踪只列名单);
52
+ * - base:先 `git merge-base HEAD <ref>` 拿到共同祖先,再 `git diff <祖先>`;
53
+ * - commit:`git show <ref> --format=fuller`(连提交信息一起给队友)。
54
+ *
55
+ * @param cwd - 会话工作目录
56
+ * @param target - 审查范围
57
+ * @param sessionId - 会话 id(只用于 diff 文件名;不传就按 cwd 哈希,探针里两参调用即可)
58
+ * @returns 不是 git 仓库时 null;ref 不存在等 git 报错按异常抛出(调用方给用户看原文)
19
59
  */
20
- export declare function reviewMessage(collected: {
21
- diff: string;
22
- untracked: string[];
23
- }, focus: string): string;
60
+ export declare function collectReviewScope(cwd: string, target: ReviewTarget, sessionId?: string): Promise<ReviewScope | null>;
61
+ /** 本地分支清单(「对比基准分支」的候选项);不是 git 仓库或没有分支时给空数组。 */
62
+ export declare function listReviewBranches(cwd: string): Promise<string[]>;
63
+ /** 最近 100 条提交(「审查某次提交」的候选项);取不到给空数组,用户仍可手填 SHA。 */
64
+ export declare function listReviewCommits(cwd: string): Promise<{
65
+ sha: string;
66
+ subject: string;
67
+ }[]>;
68
+ /**
69
+ * 给审查队友的任务书(/review 的唯一组装点:派队友走它,回落主会话轮也走它)。
70
+ *
71
+ * 为什么要把「diff 已落盘」写进任务书:队友只有读类工具,不知道文件在哪就只能
72
+ * 在上下文里找,而完整 diff 可能几十 MB——先告诉它路径与读法,它才可能读全。
73
+ *
74
+ * @param scope - 取数结果
75
+ * @param focus - 用户写在 /review 后面的关注点(空串 = 不限)
76
+ */
77
+ export declare function reviewTaskText(scope: ReviewScope, focus: string): string;
78
+ /** 取消之后记进记录文件的那句话(/review-status 会原样回看)。 */
79
+ export declare const REVIEW_CANCELED_TEXT = "\u5BA1\u67E5\u88AB\u53D6\u6D88\u3002";
80
+ /** 一次正在跑的审查:记下队友名字与开始时间,取消与收工都用得上。 */
81
+ interface ReviewRun {
82
+ startedAt: number;
83
+ target: string;
84
+ /** 队友名(取消时要按它叫停)。 */
85
+ handle: string;
86
+ /** 已经被用户取消:收工记录里要保留「审查被取消」,不许被队友状态覆盖。 */
87
+ cancelled: boolean;
88
+ }
89
+ /**
90
+ * /review 的会话账本:内存里记「这个会话有没有在跑的审查」,磁盘上留「最近一次长什么样」。
91
+ *
92
+ * 为什么放在这里:命令侧(派审查前写 running)、审查通道(收工写 findings、取消时改状态)
93
+ * 与自检探针要共用同一份读写口径。各自拼路径、各自猜字段,重启后就对不上了。
94
+ * 记录文件 `<数据目录>/code-review/<会话 id>.json`,一个会话一份,后一次覆盖前一次。
95
+ */
96
+ export declare class ReviewJournal {
97
+ private readonly runs;
98
+ private readonly views;
99
+ private readonly home;
100
+ /** @param home - 数据目录(`ctx.settings.about().home`,与 DSC_HOME 同一个) */
101
+ constructor(home: string);
102
+ /** 这个会话的记录文件路径(会话 id 先洗一遍,别让奇怪的 id 拼出目录穿越)。 */
103
+ recordPath(sessionId: string): string;
104
+ /** 读记录文件;没有、读不动、字段对不上都算「没有记录」。 */
105
+ read(sessionId: string): ReviewStatusView | null;
106
+ /** 写记录文件(写不下去只让 /review-status 回看少一份,不影响审查本身)。 */
107
+ private write;
108
+ /** 最近一次审查的状态;没有记录返回 null。 */
109
+ status(sessionId: string): ReviewStatusView | null;
110
+ /** 这个会话正在跑的那次审查;没有返回 undefined(取消要按它拿队友名)。 */
111
+ running(sessionId: string): ReviewRun | undefined;
112
+ /** 派出去之后登记「在跑」并落一份 running 记录。 */
113
+ begin(sessionId: string, input: {
114
+ target: string;
115
+ handle: string;
116
+ startedAt?: number;
117
+ }): void;
118
+ /**
119
+ * 标记取消:记录立刻变成 finished +「审查被取消」,但**保留** runs 里那条,
120
+ * 好让随后的收工回调还知道这次审查的起始时间与范围(它会把同一句话再写一遍)。
121
+ * @returns 没有在跑的审查时 false
122
+ */
123
+ cancel(sessionId: string): boolean;
124
+ /** 这次审查是不是被用户取消的(收工时用来决定写哪句话)。 */
125
+ wasCancelled(sessionId: string): boolean;
126
+ /**
127
+ * 收工:把 findings 写进记录并清掉「在跑」那一笔。
128
+ * @param handle - 收工的是哪个队友;同一会话里前一次没收工又派了新的时,
129
+ * 旧那次收工不能把新那次的状态改成 finished(传了就按它比对,不传一律照写)
130
+ */
131
+ finish(sessionId: string, findings: string, handle?: string): void;
132
+ }
133
+ /** `/review-status` 上屏的那段文本(命令与探针共用一份,不许各写一套)。 */
134
+ export declare function reviewStatusText(view: ReviewStatusView | null): string;
24
135
  /**
25
136
  * 回合起点的 git 状态快照:仓库根 + porcelain 一行一条。非 git 仓库、git 跑不动
26
137
  * (超时/没装)一律返回 null——兜底只在确定拿得到的时候参与,绝不挡回合本身。
@@ -45,3 +156,4 @@ export declare function collectGitTurnChanges(cwd: string, before: {
45
156
  root: string;
46
157
  lines: string[];
47
158
  } | null, already: readonly string[]): Promise<FileChangeSummary[]>;
159
+ export {};