@waq666/pneuma 0.0.0-stage → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (687) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +144 -2
  3. package/bin/dsc.js +91 -0
  4. package/bin/headless.cjs +40 -0
  5. package/lib/adapter/core-runtime.d.ts +11 -0
  6. package/lib/adapter/core-runtime.js +259 -0
  7. package/lib/adapter/host.d.ts +18 -0
  8. package/lib/adapter/host.js +14 -0
  9. package/lib/adapter/runtime.d.ts +15 -0
  10. package/lib/adapter/runtime.js +290 -0
  11. package/lib/adapter/transcript.d.ts +184 -0
  12. package/lib/adapter/transcript.js +605 -0
  13. package/lib/app/AgentsOverlay.d.ts +18 -0
  14. package/lib/app/AgentsOverlay.js +63 -0
  15. package/lib/app/App.d.ts +13 -0
  16. package/lib/app/App.js +1498 -0
  17. package/lib/app/ApprovalCard.d.ts +12 -0
  18. package/lib/app/ApprovalCard.js +76 -0
  19. package/lib/app/AskCard.d.ts +20 -0
  20. package/lib/app/AskCard.js +45 -0
  21. package/lib/app/ChatView.d.ts +32 -0
  22. package/lib/app/ChatView.js +198 -0
  23. package/lib/app/Composer.d.ts +50 -0
  24. package/lib/app/Composer.js +282 -0
  25. package/lib/app/DiffBlock.d.ts +6 -0
  26. package/lib/app/DiffBlock.js +37 -0
  27. package/lib/app/MarkdownView.d.ts +6 -0
  28. package/lib/app/MarkdownView.js +99 -0
  29. package/lib/app/ModelPicker.d.ts +7 -0
  30. package/lib/app/ModelPicker.js +18 -0
  31. package/lib/app/PlanReviewCard.d.ts +13 -0
  32. package/lib/app/PlanReviewCard.js +54 -0
  33. package/lib/app/PresetPicker.d.ts +11 -0
  34. package/lib/app/PresetPicker.js +19 -0
  35. package/lib/app/PreviewOverlay.d.ts +14 -0
  36. package/lib/app/PreviewOverlay.js +22 -0
  37. package/lib/app/SessionPicker.d.ts +43 -0
  38. package/lib/app/SessionPicker.js +56 -0
  39. package/lib/app/SettingsOverlay.d.ts +32 -0
  40. package/lib/app/SettingsOverlay.js +157 -0
  41. package/lib/app/SkillsPicker.d.ts +7 -0
  42. package/lib/app/SkillsPicker.js +19 -0
  43. package/lib/app/StatusBar.d.ts +22 -0
  44. package/lib/app/StatusBar.js +272 -0
  45. package/lib/app/TaskStrips.d.ts +13 -0
  46. package/lib/app/TaskStrips.js +40 -0
  47. package/lib/app/ToolCard.d.ts +5 -0
  48. package/lib/app/ToolCard.js +40 -0
  49. package/lib/app/TranscriptOverlay.d.ts +12 -0
  50. package/lib/app/TranscriptOverlay.js +17 -0
  51. package/lib/app/Welcome.d.ts +6 -0
  52. package/lib/app/Welcome.js +66 -0
  53. package/lib/app/attach.d.ts +16 -0
  54. package/lib/app/attach.js +58 -0
  55. package/lib/app/click.d.ts +27 -0
  56. package/lib/app/click.js +89 -0
  57. package/lib/app/clipboard-image.d.ts +11 -0
  58. package/lib/app/clipboard-image.js +66 -0
  59. package/lib/app/cursor.d.ts +4 -0
  60. package/lib/app/cursor.js +24 -0
  61. package/lib/app/hello.d.ts +11 -0
  62. package/lib/app/hello.js +8 -0
  63. package/lib/app/history-store.d.ts +4 -0
  64. package/lib/app/history-store.js +41 -0
  65. package/lib/app/image-blocks.d.ts +12 -0
  66. package/lib/app/image-blocks.js +125 -0
  67. package/lib/app/markdown.d.ts +54 -0
  68. package/lib/app/markdown.js +189 -0
  69. package/lib/app/settings-model.d.ts +69 -0
  70. package/lib/app/settings-model.js +114 -0
  71. package/lib/app/theme.d.ts +166 -0
  72. package/lib/app/theme.js +141 -0
  73. package/lib/boot.d.ts +1 -0
  74. package/lib/boot.js +34 -0
  75. package/lib/commands.d.ts +49 -0
  76. package/lib/commands.js +115 -0
  77. package/lib/contract.d.ts +1973 -0
  78. package/lib/contract.js +36 -0
  79. package/lib/core/agent-roles.d.ts +52 -0
  80. package/lib/core/agent-roles.js +274 -0
  81. package/lib/core/approval-floor.d.ts +183 -0
  82. package/lib/core/approval-floor.js +679 -0
  83. package/lib/core/approval.d.ts +42 -0
  84. package/lib/core/approval.js +8 -0
  85. package/lib/core/audit.d.ts +61 -0
  86. package/lib/core/audit.js +59 -0
  87. package/lib/core/boot-notices.d.ts +6 -0
  88. package/lib/core/boot-notices.js +61 -0
  89. package/lib/core/cdp/actions.d.ts +182 -0
  90. package/lib/core/cdp/actions.js +649 -0
  91. package/lib/core/cdp/launch.d.ts +192 -0
  92. package/lib/core/cdp/launch.js +491 -0
  93. package/lib/core/cdp/snapshot.d.ts +139 -0
  94. package/lib/core/cdp/snapshot.js +316 -0
  95. package/lib/core/cdp/transport.d.ts +160 -0
  96. package/lib/core/cdp/transport.js +359 -0
  97. package/lib/core/command-policy.d.ts +108 -0
  98. package/lib/core/command-policy.js +580 -0
  99. package/lib/core/commands-completion.d.ts +78 -0
  100. package/lib/core/commands-completion.js +167 -0
  101. package/lib/core/compact-anchors.d.ts +76 -0
  102. package/lib/core/compact-anchors.js +284 -0
  103. package/lib/core/compact.d.ts +110 -0
  104. package/lib/core/compact.js +210 -0
  105. package/lib/core/config-store.d.ts +38 -0
  106. package/lib/core/config-store.js +307 -0
  107. package/lib/core/config.d.ts +36 -0
  108. package/lib/core/config.js +124 -0
  109. package/lib/core/connection-test.d.ts +60 -0
  110. package/lib/core/connection-test.js +84 -0
  111. package/lib/core/desktop-control.d.ts +298 -0
  112. package/lib/core/desktop-control.js +1311 -0
  113. package/lib/core/diff-text.d.ts +74 -0
  114. package/lib/core/diff-text.js +257 -0
  115. package/lib/core/dock-browser.d.ts +137 -0
  116. package/lib/core/dock-browser.js +146 -0
  117. package/lib/core/dock-ops.d.ts +59 -0
  118. package/lib/core/dock-ops.js +104 -0
  119. package/lib/core/dock-session.d.ts +39 -0
  120. package/lib/core/dock-session.js +28 -0
  121. package/lib/core/dsh-compat/hook.d.ts +18 -0
  122. package/lib/core/dsh-compat/hook.js +52 -0
  123. package/lib/core/dsh-compat/resolve-hook.d.ts +5 -0
  124. package/lib/core/dsh-compat/resolve-hook.js +59 -0
  125. package/lib/core/dsh-compat/tools-facade.d.ts +47 -0
  126. package/lib/core/dsh-compat/tools-facade.js +108 -0
  127. package/lib/core/err-text.d.ts +13 -0
  128. package/lib/core/err-text.js +15 -0
  129. package/lib/core/events.d.ts +149 -0
  130. package/lib/core/events.js +1 -0
  131. package/lib/core/git-exec.d.ts +23 -0
  132. package/lib/core/git-exec.js +72 -0
  133. package/lib/core/git-info.d.ts +47 -0
  134. package/lib/core/git-info.js +157 -0
  135. package/lib/core/goal.d.ts +89 -0
  136. package/lib/core/goal.js +189 -0
  137. package/lib/core/hooks.d.ts +272 -0
  138. package/lib/core/hooks.js +818 -0
  139. package/lib/core/host-browser-link.d.ts +59 -0
  140. package/lib/core/host-browser-link.js +9 -0
  141. package/lib/core/host-methods.d.ts +25 -0
  142. package/lib/core/host-methods.js +103 -0
  143. package/lib/core/image-diet.d.ts +77 -0
  144. package/lib/core/image-diet.js +127 -0
  145. package/lib/core/learnings/ledger.d.ts +73 -0
  146. package/lib/core/learnings/ledger.js +273 -0
  147. package/lib/core/learnings/skill-write.d.ts +250 -0
  148. package/lib/core/learnings/skill-write.js +854 -0
  149. package/lib/core/learnings/store.d.ts +102 -0
  150. package/lib/core/learnings/store.js +266 -0
  151. package/lib/core/lifecycle-hooks.d.ts +189 -0
  152. package/lib/core/lifecycle-hooks.js +576 -0
  153. package/lib/core/llm.d.ts +272 -0
  154. package/lib/core/llm.js +548 -0
  155. package/lib/core/lockfile.d.ts +17 -0
  156. package/lib/core/lockfile.js +110 -0
  157. package/lib/core/loop.d.ts +185 -0
  158. package/lib/core/loop.js +587 -0
  159. package/lib/core/lsp/client.d.ts +189 -0
  160. package/lib/core/lsp/client.js +690 -0
  161. package/lib/core/lsp/framing.d.ts +84 -0
  162. package/lib/core/lsp/framing.js +181 -0
  163. package/lib/core/lsp/line-shift.d.ts +28 -0
  164. package/lib/core/lsp/line-shift.js +127 -0
  165. package/lib/core/lsp/manager.d.ts +93 -0
  166. package/lib/core/lsp/manager.js +418 -0
  167. package/lib/core/lsp/normalize.d.ts +32 -0
  168. package/lib/core/lsp/normalize.js +139 -0
  169. package/lib/core/lsp/servers.d.ts +106 -0
  170. package/lib/core/lsp/servers.js +352 -0
  171. package/lib/core/lsp/uri.d.ts +76 -0
  172. package/lib/core/lsp/uri.js +179 -0
  173. package/lib/core/market.d.ts +51 -0
  174. package/lib/core/market.js +358 -0
  175. package/lib/core/mcp.d.ts +201 -0
  176. package/lib/core/mcp.js +836 -0
  177. package/lib/core/memory-eval.d.ts +158 -0
  178. package/lib/core/memory-eval.js +215 -0
  179. package/lib/core/memory.d.ts +266 -0
  180. package/lib/core/memory.js +703 -0
  181. package/lib/core/mention.d.ts +57 -0
  182. package/lib/core/mention.js +129 -0
  183. package/lib/core/microcompact.d.ts +48 -0
  184. package/lib/core/microcompact.js +79 -0
  185. package/lib/core/migrate.d.ts +56 -0
  186. package/lib/core/migrate.js +134 -0
  187. package/lib/core/model-caps.d.ts +83 -0
  188. package/lib/core/model-caps.js +150 -0
  189. package/lib/core/model-discovery.d.ts +19 -0
  190. package/lib/core/model-discovery.js +69 -0
  191. package/lib/core/modes.d.ts +72 -0
  192. package/lib/core/modes.js +152 -0
  193. package/lib/core/native-bridge.d.ts +135 -0
  194. package/lib/core/native-bridge.js +563 -0
  195. package/lib/core/path-policy.d.ts +32 -0
  196. package/lib/core/path-policy.js +248 -0
  197. package/lib/core/permission-presets.d.ts +67 -0
  198. package/lib/core/permission-presets.js +75 -0
  199. package/lib/core/plugin-loader.d.ts +36 -0
  200. package/lib/core/plugin-loader.js +294 -0
  201. package/lib/core/plugin-registry.d.ts +113 -0
  202. package/lib/core/plugin-registry.js +256 -0
  203. package/lib/core/prefs.d.ts +82 -0
  204. package/lib/core/prefs.js +372 -0
  205. package/lib/core/presets.d.ts +80 -0
  206. package/lib/core/presets.js +373 -0
  207. package/lib/core/pricing.d.ts +90 -0
  208. package/lib/core/pricing.js +126 -0
  209. package/lib/core/prompt.d.ts +92 -0
  210. package/lib/core/prompt.js +339 -0
  211. package/lib/core/ptc.d.ts +66 -0
  212. package/lib/core/ptc.js +70 -0
  213. package/lib/core/remote/frames.d.ts +91 -0
  214. package/lib/core/remote/frames.js +174 -0
  215. package/lib/core/remote/notify.d.ts +54 -0
  216. package/lib/core/remote/notify.js +77 -0
  217. package/lib/core/remote/owner.d.ts +32 -0
  218. package/lib/core/remote/owner.js +75 -0
  219. package/lib/core/remote/pairing.d.ts +104 -0
  220. package/lib/core/remote/pairing.js +261 -0
  221. package/lib/core/remote/push.d.ts +80 -0
  222. package/lib/core/remote/push.js +222 -0
  223. package/lib/core/remote/store.d.ts +18 -0
  224. package/lib/core/remote/store.js +59 -0
  225. package/lib/core/remote/tickets.d.ts +20 -0
  226. package/lib/core/remote/tickets.js +49 -0
  227. package/lib/core/remote/uploads.d.ts +63 -0
  228. package/lib/core/remote/uploads.js +161 -0
  229. package/lib/core/request-attribution.d.ts +26 -0
  230. package/lib/core/request-attribution.js +86 -0
  231. package/lib/core/request-invariant.d.ts +61 -0
  232. package/lib/core/request-invariant.js +199 -0
  233. package/lib/core/sandbox/backends.d.ts +64 -0
  234. package/lib/core/sandbox/backends.js +194 -0
  235. package/lib/core/sandbox/execpolicy.d.ts +93 -0
  236. package/lib/core/sandbox/execpolicy.js +452 -0
  237. package/lib/core/sandbox/net-proxy.d.ts +31 -0
  238. package/lib/core/sandbox/net-proxy.js +162 -0
  239. package/lib/core/sandbox/policy.d.ts +211 -0
  240. package/lib/core/sandbox/policy.js +559 -0
  241. package/lib/core/sandbox/win/abi.d.ts +161 -0
  242. package/lib/core/sandbox/win/abi.js +169 -0
  243. package/lib/core/sandbox/win/account.d.ts +71 -0
  244. package/lib/core/sandbox/win/account.js +206 -0
  245. package/lib/core/sandbox/win/acl.d.ts +54 -0
  246. package/lib/core/sandbox/win/acl.js +339 -0
  247. package/lib/core/sandbox/win/backend.d.ts +61 -0
  248. package/lib/core/sandbox/win/backend.js +249 -0
  249. package/lib/core/sandbox/win/doctor.d.ts +24 -0
  250. package/lib/core/sandbox/win/doctor.js +272 -0
  251. package/lib/core/sandbox/win/ffi.d.ts +107 -0
  252. package/lib/core/sandbox/win/ffi.js +166 -0
  253. package/lib/core/sandbox/win/net-abi.d.ts +154 -0
  254. package/lib/core/sandbox/win/net-abi.js +316 -0
  255. package/lib/core/sandbox/win/runner-entry.d.ts +35 -0
  256. package/lib/core/sandbox/win/runner-entry.js +391 -0
  257. package/lib/core/sandbox/win/setup.d.ts +60 -0
  258. package/lib/core/sandbox/win/setup.js +986 -0
  259. package/lib/core/sandbox/win/token.d.ts +35 -0
  260. package/lib/core/sandbox/win/token.js +238 -0
  261. package/lib/core/sandbox/win/wfp.d.ts +41 -0
  262. package/lib/core/sandbox/win/wfp.js +200 -0
  263. package/lib/core/sandbox/win/workspace-sid.d.ts +9 -0
  264. package/lib/core/sandbox/win/workspace-sid.js +45 -0
  265. package/lib/core/schedule/rule.d.ts +184 -0
  266. package/lib/core/schedule/rule.js +745 -0
  267. package/lib/core/schedule/runner.d.ts +185 -0
  268. package/lib/core/schedule/runner.js +678 -0
  269. package/lib/core/schedule/store.d.ts +182 -0
  270. package/lib/core/schedule/store.js +455 -0
  271. package/lib/core/secrets.d.ts +41 -0
  272. package/lib/core/secrets.js +150 -0
  273. package/lib/core/session-export.d.ts +18 -0
  274. package/lib/core/session-export.js +73 -0
  275. package/lib/core/session-index.d.ts +159 -0
  276. package/lib/core/session-index.js +683 -0
  277. package/lib/core/session-meta.d.ts +41 -0
  278. package/lib/core/session-meta.js +97 -0
  279. package/lib/core/session.d.ts +356 -0
  280. package/lib/core/session.js +998 -0
  281. package/lib/core/skills.d.ts +60 -0
  282. package/lib/core/skills.js +171 -0
  283. package/lib/core/spill.d.ts +159 -0
  284. package/lib/core/spill.js +329 -0
  285. package/lib/core/surface-registry.d.ts +45 -0
  286. package/lib/core/surface-registry.js +67 -0
  287. package/lib/core/team-board.d.ts +95 -0
  288. package/lib/core/team-board.js +316 -0
  289. package/lib/core/throughput.d.ts +46 -0
  290. package/lib/core/throughput.js +40 -0
  291. package/lib/core/todo-reminder.d.ts +44 -0
  292. package/lib/core/todo-reminder.js +55 -0
  293. package/lib/core/todo.d.ts +81 -0
  294. package/lib/core/todo.js +222 -0
  295. package/lib/core/token-estimate.d.ts +55 -0
  296. package/lib/core/token-estimate.js +82 -0
  297. package/lib/core/tool-guards.d.ts +103 -0
  298. package/lib/core/tool-guards.js +77 -0
  299. package/lib/core/tool-search.d.ts +152 -0
  300. package/lib/core/tool-search.js +311 -0
  301. package/lib/core/tools/bash.d.ts +281 -0
  302. package/lib/core/tools/bash.js +871 -0
  303. package/lib/core/tools/command-runner.d.ts +84 -0
  304. package/lib/core/tools/command-runner.js +68 -0
  305. package/lib/core/tools/fs-tools.d.ts +23 -0
  306. package/lib/core/tools/fs-tools.js +247 -0
  307. package/lib/core/tools/index.d.ts +8 -0
  308. package/lib/core/tools/index.js +4 -0
  309. package/lib/core/tools/sandbox-args.d.ts +51 -0
  310. package/lib/core/tools/sandbox-args.js +90 -0
  311. package/lib/core/tools/search-tools.d.ts +3 -0
  312. package/lib/core/tools/search-tools.js +153 -0
  313. package/lib/core/tools.d.ts +96 -0
  314. package/lib/core/tools.js +53 -0
  315. package/lib/core/ui-boot-source.d.ts +71 -0
  316. package/lib/core/ui-boot-source.js +121 -0
  317. package/lib/core/ui-bundles.d.ts +249 -0
  318. package/lib/core/ui-bundles.js +830 -0
  319. package/lib/core/ui-combo.d.ts +49 -0
  320. package/lib/core/ui-combo.js +55 -0
  321. package/lib/core/ui-events.d.ts +81 -0
  322. package/lib/core/ui-events.js +364 -0
  323. package/lib/core/ui-hmr.d.ts +36 -0
  324. package/lib/core/ui-hmr.js +128 -0
  325. package/lib/core/ui-methods.d.ts +69 -0
  326. package/lib/core/ui-methods.js +341 -0
  327. package/lib/core/ui-route.d.ts +69 -0
  328. package/lib/core/ui-route.js +122 -0
  329. package/lib/core/ui-server.d.ts +75 -0
  330. package/lib/core/ui-server.js +369 -0
  331. package/lib/core/ui-trust.d.ts +47 -0
  332. package/lib/core/ui-trust.js +164 -0
  333. package/lib/core/untrusted.d.ts +30 -0
  334. package/lib/core/untrusted.js +48 -0
  335. package/lib/core/update-check.d.ts +81 -0
  336. package/lib/core/update-check.js +177 -0
  337. package/lib/core/usage-log.d.ts +82 -0
  338. package/lib/core/usage-log.js +306 -0
  339. package/lib/core/version.d.ts +1 -0
  340. package/lib/core/version.js +37 -0
  341. package/lib/core/web-http.d.ts +57 -0
  342. package/lib/core/web-http.js +137 -0
  343. package/lib/core/web-static.d.ts +31 -0
  344. package/lib/core/web-static.js +75 -0
  345. package/lib/headless.d.ts +1 -0
  346. package/lib/headless.js +31 -0
  347. package/lib/host/kernel.d.ts +33 -0
  348. package/lib/host/kernel.js +451 -0
  349. package/lib/index.d.ts +41 -0
  350. package/lib/index.js +35 -0
  351. package/lib/plugins/agent.d.ts +2 -0
  352. package/lib/plugins/agent.js +274 -0
  353. package/lib/plugins/approval-floor.d.ts +2 -0
  354. package/lib/plugins/approval-floor.js +223 -0
  355. package/lib/plugins/approval.d.ts +16 -0
  356. package/lib/plugins/approval.js +674 -0
  357. package/lib/plugins/ask.d.ts +2 -0
  358. package/lib/plugins/ask.js +245 -0
  359. package/lib/plugins/browser.d.ts +68 -0
  360. package/lib/plugins/browser.js +1341 -0
  361. package/lib/plugins/commands.d.ts +23 -0
  362. package/lib/plugins/commands.js +498 -0
  363. package/lib/plugins/compact.d.ts +21 -0
  364. package/lib/plugins/compact.js +274 -0
  365. package/lib/plugins/computer-use.d.ts +47 -0
  366. package/lib/plugins/computer-use.js +539 -0
  367. package/lib/plugins/desktop-dock.d.ts +2 -0
  368. package/lib/plugins/desktop-dock.js +626 -0
  369. package/lib/plugins/dock-browser.d.ts +34 -0
  370. package/lib/plugins/dock-browser.js +765 -0
  371. package/lib/plugins/dsh-compat.d.ts +25 -0
  372. package/lib/plugins/dsh-compat.js +37 -0
  373. package/lib/plugins/file-review.d.ts +108 -0
  374. package/lib/plugins/file-review.js +393 -0
  375. package/lib/plugins/git.d.ts +26 -0
  376. package/lib/plugins/git.js +132 -0
  377. package/lib/plugins/goal.d.ts +20 -0
  378. package/lib/plugins/goal.js +245 -0
  379. package/lib/plugins/guards.d.ts +14 -0
  380. package/lib/plugins/guards.js +18 -0
  381. package/lib/plugins/hooks.d.ts +19 -0
  382. package/lib/plugins/hooks.js +583 -0
  383. package/lib/plugins/host-stdio.d.ts +88 -0
  384. package/lib/plugins/host-stdio.js +317 -0
  385. package/lib/plugins/image-diet.d.ts +17 -0
  386. package/lib/plugins/image-diet.js +85 -0
  387. package/lib/plugins/lifecycle-hooks.d.ts +26 -0
  388. package/lib/plugins/lifecycle-hooks.js +338 -0
  389. package/lib/plugins/llm.d.ts +13 -0
  390. package/lib/plugins/llm.js +215 -0
  391. package/lib/plugins/lsp.d.ts +54 -0
  392. package/lib/plugins/lsp.js +608 -0
  393. package/lib/plugins/mcp.d.ts +16 -0
  394. package/lib/plugins/mcp.js +673 -0
  395. package/lib/plugins/memory.d.ts +17 -0
  396. package/lib/plugins/memory.js +858 -0
  397. package/lib/plugins/microcompact.d.ts +18 -0
  398. package/lib/plugins/microcompact.js +119 -0
  399. package/lib/plugins/mode.d.ts +18 -0
  400. package/lib/plugins/mode.js +115 -0
  401. package/lib/plugins/permission-presets.d.ts +18 -0
  402. package/lib/plugins/permission-presets.js +135 -0
  403. package/lib/plugins/plan.d.ts +2 -0
  404. package/lib/plugins/plan.js +192 -0
  405. package/lib/plugins/plugin-manager.d.ts +2 -0
  406. package/lib/plugins/plugin-manager.js +165 -0
  407. package/lib/plugins/presets.d.ts +2 -0
  408. package/lib/plugins/presets.js +182 -0
  409. package/lib/plugins/prompt.d.ts +2 -0
  410. package/lib/plugins/prompt.js +264 -0
  411. package/lib/plugins/ptc.d.ts +2 -0
  412. package/lib/plugins/ptc.js +272 -0
  413. package/lib/plugins/remote/http.d.ts +11 -0
  414. package/lib/plugins/remote/http.js +11 -0
  415. package/lib/plugins/remote/routes.d.ts +24 -0
  416. package/lib/plugins/remote/routes.js +384 -0
  417. package/lib/plugins/remote/types.d.ts +135 -0
  418. package/lib/plugins/remote/types.js +87 -0
  419. package/lib/plugins/remote.d.ts +17 -0
  420. package/lib/plugins/remote.js +1028 -0
  421. package/lib/plugins/runtime-api.d.ts +16 -0
  422. package/lib/plugins/runtime-api.js +99 -0
  423. package/lib/plugins/runtime.d.ts +10 -0
  424. package/lib/plugins/runtime.js +451 -0
  425. package/lib/plugins/sandbox.d.ts +2 -0
  426. package/lib/plugins/sandbox.js +761 -0
  427. package/lib/plugins/schedule.d.ts +26 -0
  428. package/lib/plugins/schedule.js +538 -0
  429. package/lib/plugins/self-improve.d.ts +61 -0
  430. package/lib/plugins/self-improve.js +953 -0
  431. package/lib/plugins/session-search.d.ts +16 -0
  432. package/lib/plugins/session-search.js +308 -0
  433. package/lib/plugins/session-title.d.ts +19 -0
  434. package/lib/plugins/session-title.js +109 -0
  435. package/lib/plugins/session.d.ts +7 -0
  436. package/lib/plugins/session.js +296 -0
  437. package/lib/plugins/settings.d.ts +3 -0
  438. package/lib/plugins/settings.js +705 -0
  439. package/lib/plugins/skills.d.ts +2 -0
  440. package/lib/plugins/skills.js +360 -0
  441. package/lib/plugins/spill.d.ts +16 -0
  442. package/lib/plugins/spill.js +200 -0
  443. package/lib/plugins/subagent.d.ts +2 -0
  444. package/lib/plugins/subagent.js +862 -0
  445. package/lib/plugins/surfaces.d.ts +11 -0
  446. package/lib/plugins/surfaces.js +20 -0
  447. package/lib/plugins/team.d.ts +16 -0
  448. package/lib/plugins/team.js +149 -0
  449. package/lib/plugins/todo.d.ts +19 -0
  450. package/lib/plugins/todo.js +188 -0
  451. package/lib/plugins/tool-search.d.ts +2 -0
  452. package/lib/plugins/tool-search.js +425 -0
  453. package/lib/plugins/tools-default.d.ts +12 -0
  454. package/lib/plugins/tools-default.js +275 -0
  455. package/lib/plugins/tools.d.ts +16 -0
  456. package/lib/plugins/tools.js +62 -0
  457. package/lib/plugins/transcript.d.ts +15 -0
  458. package/lib/plugins/transcript.js +311 -0
  459. package/lib/plugins/tui.d.ts +2 -0
  460. package/lib/plugins/tui.js +98 -0
  461. package/lib/plugins/waiting.d.ts +12 -0
  462. package/lib/plugins/waiting.js +34 -0
  463. package/lib/plugins/web-search.d.ts +14 -0
  464. package/lib/plugins/web-search.js +263 -0
  465. package/lib/plugins/webserver.d.ts +48 -0
  466. package/lib/plugins/webserver.js +228 -0
  467. package/lib/remote/assets/app-DAcUCOEn.js +14 -0
  468. package/lib/remote/assets/icon-192.png +0 -0
  469. package/lib/remote/assets/icon-512.png +0 -0
  470. package/lib/remote/assets/index.html +34 -0
  471. package/lib/remote/assets/manifest.json +27 -0
  472. package/lib/remote/assets/style-DIB6729x.css +1 -0
  473. package/lib/remote/assets/sw.js +66 -0
  474. package/lib/services/types.d.ts +1228 -0
  475. package/lib/services/types.js +1 -0
  476. package/lib/tools/config-cli.d.ts +1 -0
  477. package/lib/tools/config-cli.js +89 -0
  478. package/lib/ui/arrival.d.ts +72 -0
  479. package/lib/ui/arrival.js +105 -0
  480. package/lib/ui/assets/app-B70nVIKd.js +69 -0
  481. package/lib/ui/assets/chunk-2UxHyX5q.js +1 -0
  482. package/lib/ui/assets/chunk-B1dDrJ26.js +1 -0
  483. package/lib/ui/assets/chunk-B6aJPvgy.js +1 -0
  484. package/lib/ui/assets/chunk-BEwlwnbL.js +1 -0
  485. package/lib/ui/assets/chunk-BGcgwlCI.js +12 -0
  486. package/lib/ui/assets/chunk-BIGW1oBm.js +1 -0
  487. package/lib/ui/assets/chunk-BPQ3VLAy.js +1 -0
  488. package/lib/ui/assets/chunk-BRH0KZbk.js +141 -0
  489. package/lib/ui/assets/chunk-BX6H_ySx.js +1 -0
  490. package/lib/ui/assets/chunk-B_P3UbPa.js +1 -0
  491. package/lib/ui/assets/chunk-B_TYUkTI.js +1 -0
  492. package/lib/ui/assets/chunk-B_vNuMnf.js +1 -0
  493. package/lib/ui/assets/chunk-BajyYBss.js +10 -0
  494. package/lib/ui/assets/chunk-BdnUsdx6.js +1 -0
  495. package/lib/ui/assets/chunk-Buea-lGh.js +1 -0
  496. package/lib/ui/assets/chunk-C0PvZCCE.js +1 -0
  497. package/lib/ui/assets/chunk-C0m74zRD.js +1 -0
  498. package/lib/ui/assets/chunk-C27-OAKa.js +1 -0
  499. package/lib/ui/assets/chunk-C2oV4EkX.js +1 -0
  500. package/lib/ui/assets/chunk-C7zT0LnQ.js +1 -0
  501. package/lib/ui/assets/chunk-C9GSunVT.js +1 -0
  502. package/lib/ui/assets/chunk-C9tS-k6U.js +1 -0
  503. package/lib/ui/assets/chunk-CHLpvVh8.js +1 -0
  504. package/lib/ui/assets/chunk-CLxacb5B.js +1 -0
  505. package/lib/ui/assets/chunk-COt5Ahok.js +1 -0
  506. package/lib/ui/assets/chunk-CPTIWCL2.js +1 -0
  507. package/lib/ui/assets/chunk-CQLl-L-p.js +1 -0
  508. package/lib/ui/assets/chunk-CUWRgxuq.js +55 -0
  509. package/lib/ui/assets/chunk-CWanVSXC.js +1 -0
  510. package/lib/ui/assets/chunk-Cf5RLm7j.js +1 -0
  511. package/lib/ui/assets/chunk-CickPsom.js +1 -0
  512. package/lib/ui/assets/chunk-Cj5Yp3dK.js +1 -0
  513. package/lib/ui/assets/chunk-Cmh6b_Ma.js +1 -0
  514. package/lib/ui/assets/chunk-Cp-IABpG.js +1 -0
  515. package/lib/ui/assets/chunk-CqE71os6.js +1 -0
  516. package/lib/ui/assets/chunk-CtKP3W-j.js +1 -0
  517. package/lib/ui/assets/chunk-Cvjx9yec.js +1 -0
  518. package/lib/ui/assets/chunk-CxGP3dtY.js +1 -0
  519. package/lib/ui/assets/chunk-CylS5w8V.js +1 -0
  520. package/lib/ui/assets/chunk-D38fbIBN.js +1 -0
  521. package/lib/ui/assets/chunk-D97Zzqfu.js +1 -0
  522. package/lib/ui/assets/chunk-DAi9KRSo.js +1 -0
  523. package/lib/ui/assets/chunk-DHK4yRfg.js +1 -0
  524. package/lib/ui/assets/chunk-DJeabLx-.js +1 -0
  525. package/lib/ui/assets/chunk-DNRxmY5a.js +1 -0
  526. package/lib/ui/assets/chunk-DNSN1z5r.js +1 -0
  527. package/lib/ui/assets/chunk-DNasK_ZG.js +1 -0
  528. package/lib/ui/assets/chunk-DPvrY3IQ.js +1 -0
  529. package/lib/ui/assets/chunk-DXmwc3jG.js +1 -0
  530. package/lib/ui/assets/chunk-Dd0kTxKP.js +1 -0
  531. package/lib/ui/assets/chunk-De0Btta0.js +1 -0
  532. package/lib/ui/assets/chunk-Des-eS-w.js +1 -0
  533. package/lib/ui/assets/chunk-Df6bDoY_.js +1 -0
  534. package/lib/ui/assets/chunk-DijEV5ha.js +1 -0
  535. package/lib/ui/assets/chunk-DkvoVjww.js +1 -0
  536. package/lib/ui/assets/chunk-DlC-OlHO.js +1 -0
  537. package/lib/ui/assets/chunk-DnzrXTVv.js +1 -0
  538. package/lib/ui/assets/chunk-Dualf0xi.js +1 -0
  539. package/lib/ui/assets/chunk-EXT84bkm.js +1 -0
  540. package/lib/ui/assets/chunk-GwR3hkPK.js +1 -0
  541. package/lib/ui/assets/chunk-P80f7IUj.js +1 -0
  542. package/lib/ui/assets/chunk-VOosw3JB.js +1 -0
  543. package/lib/ui/assets/chunk-YQ4lDkt_.js +140 -0
  544. package/lib/ui/assets/chunk-Yzrsuije.js +1 -0
  545. package/lib/ui/assets/chunk-Z72CF80r.js +1 -0
  546. package/lib/ui/assets/chunk-g9-lgVsj.js +1 -0
  547. package/lib/ui/assets/chunk-vGWfd6FD.js +1 -0
  548. package/lib/ui/assets/chunk-wDzz0qaB.js +1 -0
  549. package/lib/ui/assets/chunk-ySF7HWmS.js +1 -0
  550. package/lib/ui/assets/icon.png +0 -0
  551. package/lib/ui/assets/index.html +14 -0
  552. package/lib/ui/assets/pdf.worker.min-CjEcRF4W.mjs +28 -0
  553. package/lib/ui/assets/style-Bq01xH_b.css +1 -0
  554. package/lib/ui/frames.d.ts +67 -0
  555. package/lib/ui/frames.js +146 -0
  556. package/lib/ui/index.d.ts +59 -0
  557. package/lib/ui/index.js +50 -0
  558. package/lib/ui/manifest.d.ts +172 -0
  559. package/lib/ui/manifest.js +158 -0
  560. package/lib/ui/plugin.d.ts +161 -0
  561. package/lib/ui/plugin.js +7 -0
  562. package/lib/ui/plugins/browser/client.js +290 -0
  563. package/lib/ui/plugins/browser/icon.png +0 -0
  564. package/lib/ui/plugins/composer/client.js +1843 -0
  565. package/lib/ui/plugins/composer/icon.png +0 -0
  566. package/lib/ui/plugins/files/client.js +646 -0
  567. package/lib/ui/plugins/files/icon.png +0 -0
  568. package/lib/ui/plugins/manifest.json +107 -0
  569. package/lib/ui/plugins/plugins/client.js +682 -0
  570. package/lib/ui/plugins/plugins/icon.png +0 -0
  571. package/lib/ui/plugins/preview/client.js +197 -0
  572. package/lib/ui/plugins/preview/icon.png +0 -0
  573. package/lib/ui/plugins/prompt/client.js +653 -0
  574. package/lib/ui/plugins/prompt/icon.png +0 -0
  575. package/lib/ui/plugins/sessions/client.js +1577 -0
  576. package/lib/ui/plugins/sessions/icon.png +0 -0
  577. package/lib/ui/plugins/settings/client.js +5470 -0
  578. package/lib/ui/plugins/settings/icon.png +0 -0
  579. package/lib/ui/plugins/skills/client.js +485 -0
  580. package/lib/ui/plugins/skills/icon.png +0 -0
  581. package/lib/ui/plugins/status/client.js +1420 -0
  582. package/lib/ui/plugins/status/icon.png +0 -0
  583. package/lib/ui/plugins/statusbar/client.js +504 -0
  584. package/lib/ui/plugins/statusbar/icon.png +0 -0
  585. package/lib/ui/plugins/tasks/client.js +52 -0
  586. package/lib/ui/plugins/tasks/icon.png +0 -0
  587. package/lib/ui/plugins/team/client.js +527 -0
  588. package/lib/ui/plugins/team/icon.png +0 -0
  589. package/lib/ui/plugins/terminal/client.js +232 -0
  590. package/lib/ui/plugins/terminal/icon.png +0 -0
  591. package/lib/ui/plugins/trace/client.js +1376 -0
  592. package/lib/ui/plugins/trace/icon.png +0 -0
  593. package/lib/ui/plugins/transcript/client.js +2661 -0
  594. package/lib/ui/plugins/transcript/icon.png +0 -0
  595. package/lib/ui/scoped-slots.d.ts +20 -0
  596. package/lib/ui/scoped-slots.js +21 -0
  597. package/lib/ui/sdk/@dsc/ui/index.d.ts +242 -0
  598. package/lib/ui/sdk/@dsc/ui/package.json +16 -0
  599. package/lib/ui/sdk/@dsc/ui-core/contract.d.ts +1973 -0
  600. package/lib/ui/sdk/@dsc/ui-core/core/diff-text.d.ts +74 -0
  601. package/lib/ui/sdk/@dsc/ui-core/core/dock-browser.d.ts +137 -0
  602. package/lib/ui/sdk/@dsc/ui-core/core/dock-ops.d.ts +59 -0
  603. package/lib/ui/sdk/@dsc/ui-core/core/model-caps.d.ts +83 -0
  604. package/lib/ui/sdk/@dsc/ui-core/core/native-bridge.d.ts +135 -0
  605. package/lib/ui/sdk/@dsc/ui-core/core/token-estimate.d.ts +55 -0
  606. package/lib/ui/sdk/@dsc/ui-core/package.json +16 -0
  607. package/lib/ui/sdk/@dsc/ui-core/ui/arrival.d.ts +72 -0
  608. package/lib/ui/sdk/@dsc/ui-core/ui/frames.d.ts +67 -0
  609. package/lib/ui/sdk/@dsc/ui-core/ui/index.d.ts +59 -0
  610. package/lib/ui/sdk/@dsc/ui-core/ui/manifest.d.ts +172 -0
  611. package/lib/ui/sdk/@dsc/ui-core/ui/plugin.d.ts +161 -0
  612. package/lib/ui/sdk/@dsc/ui-core/ui/scoped-slots.d.ts +20 -0
  613. package/lib/ui/sdk/@dsc/ui-core/ui/services-react.d.ts +27 -0
  614. package/lib/ui/sdk/@dsc/ui-core/ui/services.d.ts +63 -0
  615. package/lib/ui/sdk/@dsc/ui-core/ui/slots-react.d.ts +28 -0
  616. package/lib/ui/sdk/@dsc/ui-core/ui/slots.d.ts +481 -0
  617. package/lib/ui/sdk/@dsc/ui-core/ui/store.d.ts +89 -0
  618. package/lib/ui/sdk/@dsc/ui-dockkit/dock-model.d.ts +238 -0
  619. package/lib/ui/sdk/@dsc/ui-dockkit/dock-state.d.ts +163 -0
  620. package/lib/ui/sdk/@dsc/ui-dockkit/dock.d.ts +24 -0
  621. package/lib/ui/sdk/@dsc/ui-dockkit/index.d.ts +15 -0
  622. package/lib/ui/sdk/@dsc/ui-dockkit/package.json +16 -0
  623. package/lib/ui/sdk/@dsc/ui-layout/app.d.ts +74 -0
  624. package/lib/ui/sdk/@dsc/ui-layout/appearance.d.ts +70 -0
  625. package/lib/ui/sdk/@dsc/ui-layout/host-channel.d.ts +112 -0
  626. package/lib/ui/sdk/@dsc/ui-layout/index.d.ts +34 -0
  627. package/lib/ui/sdk/@dsc/ui-layout/package.json +16 -0
  628. package/lib/ui/sdk/@dsc/ui-layout/page-state.d.ts +14 -0
  629. package/lib/ui/sdk/@dsc/ui-layout/review-pane.d.ts +21 -0
  630. package/lib/ui/sdk/@dsc/ui-layout/runtime-context.d.ts +44 -0
  631. package/lib/ui/sdk/@dsc/ui-layout/thread-view.d.ts +28 -0
  632. package/lib/ui/sdk/@dsc/ui-layout/update-button.d.ts +21 -0
  633. package/lib/ui/sdk/@dsc/ui-primitives/code-file-icon-artwork.d.ts +53 -0
  634. package/lib/ui/sdk/@dsc/ui-primitives/code-view.d.ts +15 -0
  635. package/lib/ui/sdk/@dsc/ui-primitives/compat.d.ts +27 -0
  636. package/lib/ui/sdk/@dsc/ui-primitives/completion-sound.d.ts +24 -0
  637. package/lib/ui/sdk/@dsc/ui-primitives/confirm.d.ts +33 -0
  638. package/lib/ui/sdk/@dsc/ui-primitives/css.d.ts +47 -0
  639. package/lib/ui/sdk/@dsc/ui-primitives/diff-rows.d.ts +20 -0
  640. package/lib/ui/sdk/@dsc/ui-primitives/file-icons.d.ts +38 -0
  641. package/lib/ui/sdk/@dsc/ui-primitives/file-type-classify.d.ts +66 -0
  642. package/lib/ui/sdk/@dsc/ui-primitives/file-type-icon.d.ts +57 -0
  643. package/lib/ui/sdk/@dsc/ui-primitives/highlight.d.ts +24 -0
  644. package/lib/ui/sdk/@dsc/ui-primitives/hover-delay.d.ts +17 -0
  645. package/lib/ui/sdk/@dsc/ui-primitives/icons.d.ts +109 -0
  646. package/lib/ui/sdk/@dsc/ui-primitives/index.d.ts +55 -0
  647. package/lib/ui/sdk/@dsc/ui-primitives/lang-table.d.ts +10 -0
  648. package/lib/ui/sdk/@dsc/ui-primitives/markdown.d.ts +20 -0
  649. package/lib/ui/sdk/@dsc/ui-primitives/native.d.ts +41 -0
  650. package/lib/ui/sdk/@dsc/ui-primitives/package.json +16 -0
  651. package/lib/ui/sdk/@dsc/ui-primitives/panels.d.ts +86 -0
  652. package/lib/ui/sdk/@dsc/ui-primitives/paths.d.ts +11 -0
  653. package/lib/ui/sdk/@dsc/ui-primitives/pdf-view.d.ts +13 -0
  654. package/lib/ui/sdk/@dsc/ui-primitives/plugin-text.d.ts +15 -0
  655. package/lib/ui/sdk/@dsc/ui-primitives/select.d.ts +35 -0
  656. package/lib/ui/sdk/@dsc/ui-primitives/table-view.d.ts +23 -0
  657. package/lib/ui/sdk/@dsc/ui-primitives/thread-resizer.d.ts +22 -0
  658. package/lib/ui/sdk/@dsc/ui-primitives/time.d.ts +33 -0
  659. package/lib/ui/sdk/@dsc/ui-primitives/toast.d.ts +16 -0
  660. package/lib/ui/sdk/@dsc/ui-primitives/tokens.d.ts +14 -0
  661. package/lib/ui/sdk/@dsc/ui-primitives/tool-args.d.ts +49 -0
  662. package/lib/ui/sdk/@dsc/ui-primitives/tool-summary.d.ts +64 -0
  663. package/lib/ui/sdk/@dsc/ui-renderer/boot.d.ts +121 -0
  664. package/lib/ui/sdk/@dsc/ui-renderer/hmr.d.ts +43 -0
  665. package/lib/ui/sdk/@dsc/ui-renderer/index.d.ts +20 -0
  666. package/lib/ui/sdk/@dsc/ui-renderer/package.json +16 -0
  667. package/lib/ui/sdk/@dsc/ui-slots/index.d.ts +19 -0
  668. package/lib/ui/sdk/@dsc/ui-slots/package.json +16 -0
  669. package/lib/ui/sdk/@dsc/ui-slots/slots-react.d.ts +48 -0
  670. package/lib/ui/sdk/@dsc/ui-slots/slots.d.ts +102 -0
  671. package/lib/ui/services-react.d.ts +27 -0
  672. package/lib/ui/services-react.js +32 -0
  673. package/lib/ui/services.d.ts +63 -0
  674. package/lib/ui/services.js +121 -0
  675. package/lib/ui/slots-ink.d.ts +26 -0
  676. package/lib/ui/slots-ink.js +78 -0
  677. package/lib/ui/slots-react.d.ts +28 -0
  678. package/lib/ui/slots-react.js +88 -0
  679. package/lib/ui/slots.d.ts +481 -0
  680. package/lib/ui/slots.js +550 -0
  681. package/lib/ui/store.d.ts +89 -0
  682. package/lib/ui/store.js +62 -0
  683. package/lib/ui/tui-plugin-api.d.ts +23 -0
  684. package/lib/ui/tui-plugin-api.js +23 -0
  685. package/lib/ui/tui-plugins.d.ts +47 -0
  686. package/lib/ui/tui-plugins.js +220 -0
  687. package/package.json +58 -6
@@ -0,0 +1,282 @@
1
+ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
+ /**
3
+ * 输入行:ink 6 移除了 TextInput,这里用 useInput 自实现受控输入。
4
+ *
5
+ * 批次三起是「光标模型」:value + caret 两个状态,支持 ←→/Home/End 移动、
6
+ * Ctrl+A/E/U/K/W 编辑键、Shift+Enter / Ctrl+J 换行(多行输入)、粘贴整段插入
7
+ * (粘贴里的换行不再压平——PasteBurst-lite)。
8
+ *
9
+ * 补全面板两类:
10
+ * - `/` 命令补全(命令阶段列命令、`/model ` 参数阶段列模型),仅在行首生效;
11
+ * - `@` 文件提及补全(core/mention 的定位与排序,文件清单经 dock 的 fs-list
12
+ * 异步拉一次缓存),任意位置生效、优先于命令补全。
13
+ * ↑↓ 选择、Tab 补全、Esc 关闭(内容一变自动恢复);Enter 提交前做命令唯一前缀展开。
14
+ *
15
+ * 历史持久化在 history-store(~/.dsc/.tui-history,新的在前,多行压平存)。
16
+ *
17
+ * @module dsc/app/Composer
18
+ */
19
+ import { useEffect, useMemo, useRef, useState } from 'react';
20
+ import { Box, Text, useInput } from 'ink';
21
+ import { completionsFor, expandCommand } from '../core/commands-completion.js';
22
+ import { collectWorkspaceFiles, insertMention, mentionQueryAt, rankMentionCandidates, } from '../core/mention.js';
23
+ import { useParkedCursor } from './cursor.js';
24
+ import { displayWidth, measuredSpan, useClickRegion } from './click.js';
25
+ import { loadHistory, recordHistory } from './history-store.js';
26
+ import { settingsWindowStart } from './settings-model.js';
27
+ import { ACCENT, BORDER, GAP, MARK, PAD, SEP, STATUS_COLOR, TEXT } from './theme.js';
28
+ /** 补全面板视口行数:候选再多也只画这行窗口,聊天区不被挤没(选中越缘窗口跟滑)。 */
29
+ const PANEL_ROWS = 10;
30
+ /** 附件芯片:主体点击 = 预览,尾部的 ✕ 点击 = 摘下。 */
31
+ function AttachmentChip({ att, onRemove, onPreview, registerClick, }) {
32
+ const bodyRef = useRef(null);
33
+ const closeRef = useRef(null);
34
+ useClickRegion(bodyRef, onPreview === undefined ? undefined : registerClick, onPreview === undefined
35
+ ? undefined
36
+ : (col, row, top, height) => {
37
+ if (row < top || row >= top + height)
38
+ return false;
39
+ const span = measuredSpan(bodyRef.current);
40
+ if (span === null || col < span.left || col >= span.left + span.width)
41
+ return false;
42
+ onPreview(att.id);
43
+ return true;
44
+ });
45
+ useClickRegion(closeRef, onRemove === undefined ? undefined : registerClick, onRemove === undefined
46
+ ? undefined
47
+ : (col, row, top, height) => {
48
+ if (row < top || row >= top + height)
49
+ return false;
50
+ const span = measuredSpan(closeRef.current);
51
+ if (span === null || col < span.left || col >= span.left + span.width)
52
+ return false;
53
+ onRemove(att.id);
54
+ return true;
55
+ });
56
+ return (_jsxs(Box, { children: [_jsx(Box, { ref: bodyRef, children: _jsxs(Text, { color: ACCENT, wrap: "truncate-end", children: ["[\u56FE#", att.id, "] ", att.name] }) }), _jsx(Box, { ref: closeRef, children: _jsxs(Text, { ...TEXT.label, color: STATUS_COLOR.failed, children: [' ', "\u2715"] }) })] }));
57
+ }
58
+ export function Composer({ disabled, models, placeholder, completionsEnabled = true, lister, onPanelOpenChange, onDraftChange, preset, attachments, onRemoveAttachment, onPreviewAttachment, onOpenSessions, working = false, registerClick, onSubmit, }) {
59
+ const [value, setValue] = useState('');
60
+ const [caret, setCaret] = useState(0);
61
+ const [history, setHistory] = useState(() => loadHistory());
62
+ const [historyIndex, setHistoryIndex] = useState(-1);
63
+ const [completionIndex, setCompletionIndex] = useState(0);
64
+ /** @ 提及的工作区文件清单:第一次敲 @ 时拉一次,进程内缓存。 */
65
+ const [mentionFiles, setMentionFiles] = useState([]);
66
+ const mentionLoaded = useRef(false);
67
+ /** Esc 关闭面板后记住被抑制的输入;内容一变自动恢复。 */
68
+ const [suppressedFor, setSuppressedFor] = useState(null);
69
+ /** 光标处的 @ 提及查询(null = 不在 @ 补全态)。 */
70
+ const mention = useMemo(() => mentionQueryAt(value, caret), [value, caret]);
71
+ const completions = useMemo(() => {
72
+ if (value === suppressedFor)
73
+ return [];
74
+ if (mention !== null) {
75
+ return rankMentionCandidates(mentionFiles, mention.token, 8).map((path) => ({
76
+ insert: path,
77
+ label: path,
78
+ description: '文件提及',
79
+ }));
80
+ }
81
+ if (!completionsEnabled)
82
+ return [];
83
+ // 命令候选全量(内置 + 插件 + 技能命令,40+ 条);面板只画 PANEL_ROWS 行窗口,
84
+ // 选中项越缘窗口跟着滑(settingsWindowStart 焦点跟随语义,与设置页同款)。
85
+ return completionsFor(value, models);
86
+ }, [value, suppressedFor, mention, mentionFiles, completionsEnabled, models]);
87
+ const panelOpen = completions.length > 0;
88
+ const safeIndex = Math.max(0, Math.min(completionIndex, completions.length - 1));
89
+ /** 面板视口:候选超过 PANEL_ROWS 时只画选中项附近的窗口(纯派生,无新状态)。 */
90
+ const panelStart = settingsWindowStart(safeIndex, PANEL_ROWS, completions.length);
91
+ const panelVisible = completions.slice(panelStart, panelStart + PANEL_ROWS);
92
+ useEffect(() => {
93
+ onPanelOpenChange?.(panelOpen);
94
+ }, [panelOpen, onPanelOpenChange]);
95
+ /** 第一次需要 @ 候选时才拉工作区文件清单(异步递归,失败当空表——补全只是锦上添花)。 */
96
+ useEffect(() => {
97
+ if (mention === null || mentionLoaded.current || lister === undefined)
98
+ return;
99
+ mentionLoaded.current = true;
100
+ void collectWorkspaceFiles(lister)
101
+ .then((files) => setMentionFiles(files))
102
+ .catch(() => setMentionFiles([]));
103
+ }, [mention, lister]);
104
+ // 草稿上报(App 判断「输入框为空」的依据);preset 灌入(撤回文本回框)。
105
+ useEffect(() => {
106
+ onDraftChange?.(value);
107
+ }, [value, onDraftChange]);
108
+ useEffect(() => {
109
+ if (preset === undefined || preset.token === 0)
110
+ return;
111
+ setValue(preset.text);
112
+ setCaret(preset.text.length);
113
+ setHistoryIndex(-1);
114
+ setSuppressedFor(null);
115
+ }, [preset]);
116
+ // IME 光标停靠(0.6.57,ink useCursor):声明 caret 的逻辑行列,帧尾光标停到
117
+ // 输入框内——Windows Terminal 的拼音预览因此画在输入框里。
118
+ const inputBoxRef = useRef(null);
119
+ const homeRef = useRef(null);
120
+ useClickRegion(homeRef, onOpenSessions === undefined ? undefined : registerClick, onOpenSessions === undefined
121
+ ? undefined
122
+ : (col, row, top, height) => {
123
+ if (row < top || row >= top + height)
124
+ return false;
125
+ onOpenSessions();
126
+ return true;
127
+ });
128
+ const caretBefore = value.slice(0, caret).split('\n');
129
+ // 列原点:边框 1 + padding 1 + 「⌸ 」2(可选)+「❯ 」2
130
+ const promptCols = 2 + (onOpenSessions !== undefined ? 2 : 0);
131
+ useParkedCursor(inputBoxRef, caretBefore.length - 1, displayWidth(caretBefore[caretBefore.length - 1] ?? ''), !disabled, promptCols);
132
+ /** 修改输入并把光标带到位(函数式更新:同批多次按键不丢状态)。 */
133
+ const update = (next, nextCaret) => {
134
+ setValue(next);
135
+ setCaret(Math.max(0, Math.min(nextCaret, next.length)));
136
+ setCompletionIndex(0);
137
+ };
138
+ const insert = (text) => {
139
+ update(value.slice(0, caret) + text + value.slice(caret), caret + text.length);
140
+ };
141
+ /** Tab / Enter(面板开时):把选中候选项填进输入框。 */
142
+ const applyCompletion = () => {
143
+ const item = completions[safeIndex];
144
+ if (item === undefined)
145
+ return false;
146
+ setHistoryIndex(-1);
147
+ if (mention !== null) {
148
+ const next = insertMention(value, mention, item.insert);
149
+ update(next.text, next.caret);
150
+ }
151
+ else {
152
+ update(item.insert, item.insert.length);
153
+ }
154
+ return true;
155
+ };
156
+ useInput((input, key) => {
157
+ if (disabled)
158
+ return;
159
+ // SGR 鼠标事件(App 顶层已消费,这里兜底吞掉)绝不能当成打字灌进输入框。
160
+ if (/^\[<\d+;\d+;\d+[Mm]$/.test(input))
161
+ return;
162
+ // 补全面板打开时,导航键归面板(不与历史翻阅冲突)
163
+ if (panelOpen) {
164
+ if (key.upArrow) {
165
+ setCompletionIndex((current) => Math.max(0, Math.min(current, completions.length - 1) - 1));
166
+ return;
167
+ }
168
+ if (key.downArrow) {
169
+ setCompletionIndex((current) => Math.min(completions.length - 1, Math.min(current, completions.length - 1) + 1));
170
+ return;
171
+ }
172
+ if (key.tab) {
173
+ applyCompletion();
174
+ return;
175
+ }
176
+ if (key.escape) {
177
+ setSuppressedFor(value);
178
+ return;
179
+ }
180
+ if (key.return) {
181
+ // @ 提及:Enter 采纳候选;命令/模型:Enter 采纳(唯一前缀展开在下面统一做)。
182
+ if (mention !== null) {
183
+ applyCompletion();
184
+ return;
185
+ }
186
+ }
187
+ }
188
+ if (key.return && !key.shift && !(key.ctrl && input === 'j')) {
189
+ if (panelOpen && mention !== null)
190
+ return; // 上面已处理
191
+ // 面板打开时 Enter 采用当前选中项(`/mo`+Enter → `/model `),否则按前缀展开。
192
+ const chosen = panelOpen ? completions[safeIndex]?.insert : undefined;
193
+ const text = expandCommand((chosen ?? value).trim());
194
+ if (text === '')
195
+ return;
196
+ setHistory((previous) => recordHistory(previous, text));
197
+ setHistoryIndex(-1);
198
+ setSuppressedFor(null);
199
+ setValue('');
200
+ setCaret(0);
201
+ onSubmit(text);
202
+ return;
203
+ }
204
+ // 换行:Shift+Enter 或 Ctrl+J(ink 把 Shift+Enter 交成 key.return + key.shift)。
205
+ if ((key.return && key.shift) || (key.ctrl && input === 'j')) {
206
+ insert('\n');
207
+ return;
208
+ }
209
+ if (key.backspace || key.delete) {
210
+ if (key.delete && caret < value.length && !key.backspace) {
211
+ update(value.slice(0, caret) + value.slice(caret + 1), caret);
212
+ return;
213
+ }
214
+ if (caret > 0)
215
+ update(value.slice(0, caret - 1) + value.slice(caret), caret - 1);
216
+ return;
217
+ }
218
+ if (key.leftArrow) {
219
+ setCaret((current) => Math.max(0, current - 1));
220
+ return;
221
+ }
222
+ if (key.rightArrow) {
223
+ setCaret((current) => Math.min(value.length, current + 1));
224
+ return;
225
+ }
226
+ if (key.home || (key.ctrl && input === 'a')) {
227
+ setCaret(0);
228
+ return;
229
+ }
230
+ if (key.end || (key.ctrl && input === 'e')) {
231
+ setCaret(value.length);
232
+ return;
233
+ }
234
+ if (key.ctrl && input === 'u') {
235
+ update(value.slice(caret), 0);
236
+ return;
237
+ }
238
+ if (key.ctrl && input === 'k') {
239
+ update(value.slice(0, caret), caret);
240
+ return;
241
+ }
242
+ if (key.ctrl && input === 'w') {
243
+ // 删光标前的一个词(空白分词,吃掉前导空白)
244
+ const head = value.slice(0, caret);
245
+ const trimmed = head.replace(/\s+$/, '').replace(/\S*$/, '');
246
+ update(trimmed + value.slice(caret), trimmed.length);
247
+ return;
248
+ }
249
+ if (key.upArrow && value === '' && history.length > 0) {
250
+ const next = historyIndex < 0 ? 0 : Math.min(historyIndex + 1, history.length - 1);
251
+ setHistoryIndex(next);
252
+ const recalled = history[next] ?? '';
253
+ update(recalled, recalled.length);
254
+ return;
255
+ }
256
+ if (key.downArrow && historyIndex >= 0) {
257
+ const next = historyIndex - 1;
258
+ setHistoryIndex(next);
259
+ const recalled = next < 0 ? '' : history[next] ?? '';
260
+ update(recalled, recalled.length);
261
+ return;
262
+ }
263
+ if (key.upArrow || key.downArrow || key.pageUp || key.pageDown)
264
+ return;
265
+ if (key.tab || key.escape)
266
+ return;
267
+ if (key.ctrl || key.meta)
268
+ return;
269
+ // 粘贴整段(带换行)原样插入(只去 \r);普通输入照旧。
270
+ const printable = input.includes('\n') ? input.replace(/\r/g, '') : input.replace(/[\r\n]+/g, '');
271
+ if (printable !== '') {
272
+ setHistoryIndex(-1);
273
+ insert(printable);
274
+ }
275
+ });
276
+ 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
+ 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));
279
+ }), _jsxs(Text, { ...TEXT.secondary, children: [completions.length > panelVisible.length
280
+ ? `${panelStart + 1}–${panelStart + panelVisible.length}/${completions.length} 条 · `
281
+ : '', "\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 }))] })] }));
282
+ }
@@ -0,0 +1,6 @@
1
+ import type { JSX } from 'react';
2
+ import type { ApprovalDiffView } from '../contract.js';
3
+ export declare function DiffBlock({ diff, expanded }: {
4
+ diff: ApprovalDiffView;
5
+ expanded: boolean;
6
+ }): JSX.Element;
@@ -0,0 +1,37 @@
1
+ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
+ /**
3
+ * 差异块:unified hunk 的终端渲染(审批卡「将做的改动」与批次二的轮尾文件更改卡共用)。
4
+ * 新增行绿、删除行红、上下文暗淡;默认折叠(只留前若干行),expanded 展开全部。
5
+ *
6
+ * @module dsc-tui/app/DiffBlock
7
+ */
8
+ import { Box, Text } from 'ink';
9
+ import { DIFF_COLOR, GAP, INDENT, TEXT } from './theme.js';
10
+ /** 折叠时最多显示的差异行数(hunk 头不计)。 */
11
+ const FOLD_LINES = 14;
12
+ function DiffRow({ line }) {
13
+ if (line.kind === 'add')
14
+ return _jsxs(Text, { color: DIFF_COLOR.add, children: ["+ ", line.text] });
15
+ if (line.kind === 'remove')
16
+ return _jsxs(Text, { color: DIFF_COLOR.del, children: ["\u2212 ", line.text] });
17
+ return _jsxs(Text, { ...TEXT.secondary, children: [" ", line.text] });
18
+ }
19
+ export function DiffBlock({ diff, expanded }) {
20
+ const totalLines = diff.hunks.reduce((sum, hunk) => sum + hunk.lines.length, 0);
21
+ const rows = [];
22
+ let remaining = expanded ? Number.POSITIVE_INFINITY : FOLD_LINES;
23
+ for (const hunk of diff.hunks) {
24
+ if (remaining <= 0)
25
+ break;
26
+ rows.push(_jsxs(Text, { ...TEXT.secondary, children: ["@@ -", hunk.oldStart, ",", hunk.oldCount, " +", hunk.newStart, ",", hunk.newCount, " @@"] }, `h${rows.length}`));
27
+ for (const line of hunk.lines) {
28
+ if (remaining <= 0)
29
+ break;
30
+ rows.push(_jsx(DiffRow, { line: line }, `l${rows.length}`));
31
+ remaining -= 1;
32
+ }
33
+ }
34
+ const shown = totalLines - Math.max(0, remaining === Number.POSITIVE_INFINITY ? 0 : remaining);
35
+ const hidden = totalLines - shown;
36
+ return (_jsxs(Box, { flexDirection: "column", marginTop: GAP.none, gap: GAP.none, children: [_jsxs(Text, { ...TEXT.secondary, children: ["\u5C06\u505A\u7684\u6539\u52A8\uFF1A", diff.path, "\uFF08", diff.status === 'added' ? '新建' : '修改', "\uFF0C+", diff.added, " \u2212", diff.removed, diff.fellBack === true ? ',按参数推算' : '', diff.mismatch === 'missing' ? ',⚠ old 在盘上匹配不到,照参数执行会失败' : '', diff.mismatch === 'ambiguous' ? ',⚠ old 匹配多处,照参数执行会失败' : '', "\uFF09"] }), _jsx(Box, { flexDirection: "column", marginLeft: INDENT.detail, gap: GAP.none, children: rows }), hidden > 0 || diff.truncated === true ? (_jsxs(Text, { ...TEXT.secondary, children: ["\u2026 \u8FD8\u6709 ", hidden, " \u884C", diff.truncated === true ? '(超预算已截断)' : '', "\uFF0Cv \u5C55\u5F00/\u6536\u8D77"] })) : null] }));
37
+ }
@@ -0,0 +1,6 @@
1
+ import type { JSX } from 'react';
2
+ export declare function MarkdownView({ source, cursor, }: {
3
+ source: string;
4
+ /** 流式光标(追加在最后一个段落行尾)。 */
5
+ cursor?: boolean;
6
+ }): JSX.Element;
@@ -0,0 +1,99 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ /**
3
+ * markdown 渲染组件(0.6.58):把 markdown.ts 解析出的块画进 ink——对齐 dsh-TUI
4
+ * 的排版规格:H1 强调色粗体下划线 / H2 权限蓝粗体 / H3+ 粗体正文、行内代码权限蓝、
5
+ * 链接强调色下划线(url 退化补注——终端没有可点的超链接,藏掉 url 会丢信息)、
6
+ * 列表符号权限蓝、引用 ▎ 暗淡斜体、代码块两格缩进无闭合围栏、表格 ┌─┬┐ 框线 +
7
+ * 表头粗体居中(超宽降级成 label: value 行)。块与块之间空一行。
8
+ *
9
+ * 解析结果按 source memo(同一条目重渲染不重解析);流式光标 `▌` 追加在最后一段。
10
+ * 正文行一律自然折行(truncate 会把长回答砍成一行;高度交给聊天视口顶部裁剪)。
11
+ *
12
+ * @module dsc-tui/app/MarkdownView
13
+ */
14
+ import { useMemo } from 'react';
15
+ import { Box, Text, useStdout } from 'ink';
16
+ import { displayWidth, parseMarkdown, } from './markdown.js';
17
+ import { PAD, PALETTE, TEXT } from './theme.js';
18
+ /** 行内片段 → ink Text 序列(链接补注 url)。 */
19
+ function Spans({ spans }) {
20
+ return (_jsx(_Fragment, { children: spans.map((span, index) => {
21
+ const style = {
22
+ ...(span.bold === true ? { bold: true } : {}),
23
+ ...(span.italic === true ? { italic: true } : {}),
24
+ };
25
+ if (span.code === true) {
26
+ return (_jsx(Text, { ...style, color: PALETTE.permission, children: span.text }, index));
27
+ }
28
+ if (span.link !== undefined) {
29
+ return (_jsxs(Text, { children: [_jsx(Text, { ...style, color: PALETTE.accent, underline: true, children: span.text }), span.text !== span.link ? _jsxs(Text, { ...TEXT.secondary, children: [" (", span.link, ")"] }) : null] }, index));
30
+ }
31
+ return (_jsx(Text, { ...TEXT.body, ...style, children: span.text }, index));
32
+ }) }));
33
+ }
34
+ /** 表格:┌─┬┐ 框线 + 表头粗体居中;总宽超限降级成「表头: 首格;次格」行。 */
35
+ function TableView({ header, rows, maxWidth, }) {
36
+ const columnCount = Math.max(header.length, ...rows.map((row) => row.length), 1);
37
+ const widths = [];
38
+ for (let c = 0; c < columnCount; c += 1) {
39
+ let width = 0;
40
+ for (const span of header[c] ?? [])
41
+ width = Math.max(width, displayWidth(span.text));
42
+ for (const row of rows) {
43
+ for (const span of row[c] ?? [])
44
+ width = Math.max(width, displayWidth(span.text));
45
+ }
46
+ widths.push(Math.max(3, Math.min(width, 42)));
47
+ }
48
+ const total = widths.reduce((sum, w) => sum + w, 0) + columnCount * 3 + 1;
49
+ if (total > maxWidth) {
50
+ const label = header.map((spans) => spans.map((span) => span.text).join('')).join('·');
51
+ return (_jsx(Box, { flexDirection: "column", children: rows.map((row, index) => {
52
+ const cells = row.flatMap((cell, c) => c === 0 ? cell : [{ text: ';' }, ...cell]);
53
+ return (_jsxs(Text, { children: [_jsx(Text, { bold: true, children: label }), _jsx(Text, { ...TEXT.secondary, children: "\uFF1A " }), _jsx(Spans, { spans: cells })] }, index));
54
+ }) }));
55
+ }
56
+ const borderRow = (left, mid, right) => left + widths.map((w) => '─'.repeat(w + 2)).join(mid) + right;
57
+ const cellRow = (cells, bold, center) => (_jsxs(Text, { children: ["\u2502", widths.map((width, c) => {
58
+ const spans = cells[c] ?? [];
59
+ const plain = spans.map((span) => span.text).join('');
60
+ const pad = Math.max(0, width - displayWidth(plain));
61
+ const leftPad = center ? Math.floor(pad / 2) : 0;
62
+ // 段宽 = 1空格 + 内容(width) + 1空格 = w+2,与边框段 '─'.repeat(w+2) 对齐
63
+ return (_jsxs(Text, { children: [' ', ' '.repeat(leftPad), bold ? _jsx(Text, { bold: true, children: plain }) : _jsx(Spans, { spans: spans }), ' '.repeat(pad - leftPad), ' ', "\u2502"] }, c));
64
+ })] }));
65
+ return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { children: borderRow('┌', '┬', '┐') }), cellRow(header, true, true), _jsx(Text, { children: borderRow('├', '┼', '┤') }), rows.map((row, index) => (_jsx(Box, { children: cellRow(row, false, false) }, index))), _jsx(Text, { children: borderRow('└', '┴', '┘') })] }));
66
+ }
67
+ function BlockView({ block, maxWidth, isLast, cursor, }) {
68
+ switch (block.kind) {
69
+ case 'heading': {
70
+ const text = block.spans.map((span) => span.text).join('');
71
+ if (block.level === 1) {
72
+ return (_jsx(Text, { bold: true, color: PALETTE.accent, underline: true, children: text }));
73
+ }
74
+ if (block.level === 2) {
75
+ return (_jsx(Text, { bold: true, color: PALETTE.permission, children: text }));
76
+ }
77
+ return _jsx(Text, { bold: true, children: text });
78
+ }
79
+ case 'paragraph':
80
+ return (_jsx(Box, { flexDirection: "column", children: block.rows.map((row, index) => {
81
+ const lastRow = index === block.rows.length - 1;
82
+ return (_jsxs(Text, { children: [_jsx(Spans, { spans: row }), cursor && isLast && lastRow ? _jsx(Text, { color: PALETTE.accent, children: " \u258C" }) : null] }, index));
83
+ }) }));
84
+ case 'list':
85
+ return (_jsx(Box, { flexDirection: "column", children: block.items.map((item, index) => (_jsxs(Text, { children: [block.ordered ? (_jsxs(Text, { color: PALETTE.permission, bold: true, children: [index + 1, "."] })) : (_jsx(Text, { color: PALETTE.permission, children: "-" })), _jsx(Text, { children: " " }), _jsx(Spans, { spans: item })] }, index))) }));
86
+ case 'quote':
87
+ return (_jsxs(Text, { children: [_jsx(Text, { ...TEXT.secondary, children: "\u258E " }), _jsx(Text, { ...TEXT.body, italic: true, children: _jsx(Spans, { spans: block.spans }) })] }));
88
+ case 'code':
89
+ return (_jsxs(Box, { flexDirection: "column", children: [block.lang !== null ? _jsxs(Text, { ...TEXT.secondary, children: ["```", block.lang] }) : null, block.lines.map((line, index) => (_jsxs(Text, { ...TEXT.body, children: [' ', line] }, index)))] }));
90
+ case 'table':
91
+ return _jsx(TableView, { header: block.header, rows: block.rows, maxWidth: maxWidth });
92
+ }
93
+ }
94
+ export function MarkdownView({ source, cursor = false, }) {
95
+ const { stdout } = useStdout();
96
+ const maxWidth = Math.max(20, (stdout?.columns ?? 100) - PAD.page * 2 - 2);
97
+ const blocks = useMemo(() => parseMarkdown(source), [source]);
98
+ return (_jsxs(Box, { flexDirection: "column", gap: 1, children: [blocks.map((block, index) => (_jsx(BlockView, { block: block, maxWidth: maxWidth, isLast: index === blocks.length - 1, cursor: cursor }, index))), blocks.length === 0 && cursor ? _jsx(Text, { color: PALETTE.accent, children: " \u258C" }) : null] }));
99
+ }
@@ -0,0 +1,7 @@
1
+ import type { JSX } from 'react';
2
+ import type { ModelChoiceView } from '../contract.js';
3
+ export declare function ModelPicker({ models, index, query, }: {
4
+ models: ModelChoiceView[];
5
+ index: number;
6
+ query: string;
7
+ }): JSX.Element;
@@ -0,0 +1,18 @@
1
+ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
+ /**
3
+ * 模型选择浮层(/model 无参数打开):整屏可点版。根盒撑满状态栏之上的全部空间,
4
+ * 列表行从构造位置起排(上边框 + 标题 + 筛选行),屏幕行与候选一一对应——鼠标点击
5
+ * 选中、再点已选中项即切换;滚轮与 ↑↓ 同义(路由在 App 键盘/鼠标顶层)。输入即筛选
6
+ * (按端点/模型名/说明),Enter 切换(下一次请求生效)、Esc 关闭。本组件纯展示。
7
+ *
8
+ * @module dsc-tui/app/ModelPicker
9
+ */
10
+ import { Box, Text } from 'ink';
11
+ import { ACCENT, BORDER, GAP, MARK, PAD, SEP, TEXT } from './theme.js';
12
+ export function ModelPicker({ models, index, query, }) {
13
+ 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" })] }) }));
18
+ }
@@ -0,0 +1,13 @@
1
+ import type { JSX } from 'react';
2
+ import type { PlanView } from '../contract.js';
3
+ import { type RegisterClick } from './click.js';
4
+ /** 页脚按钮的动作 id(App 派发成与按键等价的调用)。 */
5
+ export type PlanAction = 'approve' | 'reject' | 'feedback';
6
+ export declare function PlanReviewCard({ plan, expanded, feedbacking, onAction, registerClick, }: {
7
+ plan: PlanView;
8
+ expanded: boolean;
9
+ feedbacking: boolean;
10
+ /** 鼠标点中页脚按钮 / 折叠标记行时派发;缺省即无鼠标行为。 */
11
+ onAction?: (action: PlanAction | 'toggle') => void;
12
+ registerClick?: RegisterClick;
13
+ }): JSX.Element;
@@ -0,0 +1,54 @@
1
+ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
+ /**
3
+ * 计划评审卡:exit_plan_mode 提交的计划等用户批。y 批准(批准后宿主自动切回执行
4
+ * 模式开工)/ n(或 Esc)拒绝 / e 带反馈退回——App 收到 e 后把 Composer 临时切成
5
+ * 反馈输入框,提交即把反馈原话捎给模型。计划全文超长折叠(只留前几行),v 或点击
6
+ * 「… 共 N 行」标记行展开/收起;页脚按钮可鼠标点击(列区间与渲染同源计算)。
7
+ * 键盘与鼠标路由在 App 顶层统一处理,本组件纯展示。
8
+ *
9
+ * @module dsc-tui/app/PlanReviewCard
10
+ */
11
+ import { useRef } from 'react';
12
+ import { Box, Text } from 'ink';
13
+ import { ACCENT, BORDER, GAP, PAD, STATUS_COLOR, TEXT } from './theme.js';
14
+ import { absoluteLeft, displayWidth, useClickRegion } from './click.js';
15
+ /** 折叠时保留的正文行数。 */
16
+ const PREVIEW_LINES = 12;
17
+ const BUTTONS = [
18
+ { id: 'approve', hint: '[y]', label: '批准开工', hintColor: STATUS_COLOR.done, labelDim: false },
19
+ { id: 'reject', hint: '[n]', label: '拒绝', hintColor: STATUS_COLOR.failed, labelDim: false },
20
+ { id: 'feedback', hint: '[e]', label: '带反馈退回', hintColor: ACCENT, labelDim: true },
21
+ ];
22
+ export function PlanReviewCard({ plan, expanded, feedbacking, onAction, registerClick, }) {
23
+ const rootRef = useRef(null);
24
+ const lines = plan.text.split('\n');
25
+ const folded = !expanded && lines.length > PREVIEW_LINES + 1;
26
+ const shown = folded ? lines.slice(0, PREVIEW_LINES) : lines;
27
+ let cursor = 0;
28
+ const spans = BUTTONS.map((button) => {
29
+ const text = `${button.hint} ${button.label}`;
30
+ const from = cursor;
31
+ cursor += displayWidth(text) + 2;
32
+ return { id: button.id, from, to: from + displayWidth(text) };
33
+ });
34
+ useClickRegion(rootRef, registerClick, onAction === undefined ? undefined : (col, row, top, height) => {
35
+ // 几何点击时现量:页脚在底边框上第一行(反馈输入态没有页脚);
36
+ // 折叠标记行在页脚之上(feedbacking 时就是最末内容行)。
37
+ const footerRow = feedbacking ? null : top + height - 2;
38
+ const markerRow = folded ? top + height - 2 - (feedbacking ? 0 : 1) : null;
39
+ if (markerRow !== null && row === markerRow) {
40
+ onAction('toggle');
41
+ return true;
42
+ }
43
+ if (footerRow === null || row !== footerRow)
44
+ return false;
45
+ // 页边距/边框/padding 的列原点点击时现量(对根帧 paddingX 变化免疫)
46
+ const contentCol = col - ((absoluteLeft(rootRef.current) ?? 0) + 1 + PAD.inline);
47
+ const hit = spans.find((span) => contentCol >= span.from && contentCol < span.to);
48
+ if (hit === undefined)
49
+ return false;
50
+ onAction(hit.id);
51
+ return true;
52
+ });
53
+ return (_jsxs(Box, { ref: rootRef, borderStyle: "double", borderColor: BORDER.alert, paddingX: PAD.inline, flexDirection: "column", marginTop: GAP.tight, gap: GAP.none, children: [_jsxs(Text, { ...TEXT.label, color: BORDER.alert, wrap: "truncate-end", children: ["\u2610 \u8BA1\u5212\u8BC4\u5BA1\uFF1A", plan.title] }), _jsxs(Text, { ...TEXT.secondary, wrap: "truncate-end", children: ["\u8BA1\u5212\u6587\u4EF6\uFF1A", plan.file] }), _jsx(Box, { flexDirection: "column", gap: GAP.none, children: shown.map((line, position) => (_jsx(Text, { ...TEXT.body, wrap: "truncate-end", children: line === '' ? ' ' : line }, position))) }), folded ? (_jsxs(Text, { ...TEXT.secondary, children: ["\u2026 \u5171 ", lines.length, " \u884C\uFF0Cv \u6216\u70B9\u51FB\u672C\u884C\u5C55\u5F00/\u6536\u8D77\u5168\u6587"] })) : null, feedbacking ? (_jsx(Text, { ...TEXT.label, color: STATUS_COLOR.waiting, children: "\u5E26\u53CD\u9988\u9000\u56DE\uFF1A\u5728\u4E0B\u65B9\u8F93\u5165\u6846\u5199\u53CD\u9988\u539F\u8BDD\uFF0CEnter \u63D0\u4EA4\uFF0CEsc \u53D6\u6D88" })) : (_jsx(Text, { children: BUTTONS.map((button, position) => (_jsxs(Text, { ...(button.labelDim ? TEXT.secondary : TEXT.body), children: [_jsxs(Text, { ...TEXT.label, color: button.hintColor, children: [position === 0 ? '' : ' ', button.hint] }), _jsxs(Text, { children: [" ", button.label] })] }, button.id))) }))] }));
54
+ }
@@ -0,0 +1,11 @@
1
+ import type { JSX } from 'react';
2
+ import type { PresetView } from '../contract.js';
3
+ export declare function PresetPicker({ presets, current, defaultName, index, query, }: {
4
+ presets: PresetView[];
5
+ /** 当前会话正在用的模式名。 */
6
+ current: string;
7
+ /** 新会话默认用的模式名。 */
8
+ defaultName: string;
9
+ index: number;
10
+ query: string;
11
+ }): JSX.Element;
@@ -0,0 +1,19 @@
1
+ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
+ /**
3
+ * 模式选择浮层(/preset 无参数打开,对齐 dsh 裸命令开 picker):整屏可点版。
4
+ * 数据来自 runtime.listPresets() 的模式投影(当前会话用的 + 新会话默认的 + 全部
5
+ * 可选),行带「✓ 当前 / 默认 / 内置」标记;输入即筛选(按显示名/名字/说明),
6
+ * Enter 切换当前会话的模式、Esc 关闭。键盘与鼠标路由在 App 顶层,本组件纯展示。
7
+ *
8
+ * @module dsc-tui/app/PresetPicker
9
+ */
10
+ import { Box, Text } from 'ink';
11
+ import { ACCENT, BORDER, GAP, MARK, PAD, SEP, STATUS_COLOR, TEXT } from './theme.js';
12
+ export function PresetPicker({ presets, current, defaultName, index, query, }) {
13
+ 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>" })] }) }));
19
+ }
@@ -0,0 +1,14 @@
1
+ import type { JSX } from 'react';
2
+ import { type RegisterClick } from './click.js';
3
+ export declare function PreviewOverlay({ title, index, total, block, loading, error, registerClick, onClose, }: {
4
+ title: string;
5
+ /** 当前是第几张(0 基)。 */
6
+ index: number;
7
+ total: number;
8
+ /** 渲染好的半块字符画(多行,无尾随换行);null = 还在渲染。 */
9
+ block: string | null;
10
+ loading: boolean;
11
+ error: string | null;
12
+ registerClick?: RegisterClick;
13
+ onClose: () => void;
14
+ }): JSX.Element;
@@ -0,0 +1,22 @@
1
+ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
+ /**
3
+ * 图片预览浮层(0.6.57):半块真彩字符画居中展示,←→ 在同一批图片里切换,
4
+ * Esc / 点击图片关闭。数据(渲染好的字符画)由 App 现算传入——渲染走 PowerShell
5
+ * 的 System.Drawing(见 image-blocks),本组件纯展示。
6
+ *
7
+ * @module dsc-tui/app/PreviewOverlay
8
+ */
9
+ import { useRef } from 'react';
10
+ import { Box, Text } from 'ink';
11
+ import { useClickRegion } from './click.js';
12
+ import { ACCENT, BORDER, GAP, PAD, STATUS_COLOR, TEXT } from './theme.js';
13
+ export function PreviewOverlay({ title, index, total, block, loading, error, registerClick, onClose, }) {
14
+ const ref = useRef(null);
15
+ useClickRegion(ref, registerClick, (col, row, top, height) => {
16
+ if (row < top || row >= top + height)
17
+ return false;
18
+ onClose();
19
+ return true;
20
+ });
21
+ return (_jsxs(Box, { ref: ref, borderStyle: "round", borderColor: BORDER.active, paddingX: PAD.inline, flexDirection: "column", flexGrow: 1, justifyContent: "center", alignItems: "center", gap: GAP.tight, children: [_jsxs(Text, { ...TEXT.label, color: ACCENT, wrap: "truncate-end", children: [title, total > 1 ? `(${index + 1}/${total})` : ''] }), loading ? (_jsx(Text, { ...TEXT.secondary, children: "\u6B63\u5728\u6E32\u67D3\u9884\u89C8\u2026" })) : error !== null ? (_jsxs(Text, { ...TEXT.label, color: STATUS_COLOR.failed, children: ["\u9884\u89C8\u5931\u8D25\uFF1A", error] })) : (_jsx(Box, { flexDirection: "column", children: (block ?? '').split('\n').map((line, position) => (_jsx(Text, { children: line }, position))) })), _jsxs(Text, { ...TEXT.secondary, wrap: "truncate-end", children: [total > 1 ? '←→ 切换 · ' : '', "\u70B9\u51FB\u56FE\u7247\u6216 Esc \u5173\u95ED"] })] }));
22
+ }