@uncarved/jade 0.1.3 → 0.2.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 (455) hide show
  1. package/README.md +161 -150
  2. package/bin/jade.js +14 -25
  3. package/dist/api.d.ts +266 -0
  4. package/dist/api.js +38 -0
  5. package/dist/api.js.map +1 -0
  6. package/dist/config.d.ts +13 -32
  7. package/dist/config.js +39 -121
  8. package/dist/config.js.map +1 -1
  9. package/dist/fetch.d.ts +20 -0
  10. package/dist/fetch.js +190 -0
  11. package/dist/fetch.js.map +1 -0
  12. package/dist/hash.d.ts +2 -0
  13. package/dist/hash.js +42 -0
  14. package/dist/hash.js.map +1 -0
  15. package/dist/host.d.ts +71 -0
  16. package/dist/host.js +400 -0
  17. package/dist/host.js.map +1 -0
  18. package/dist/index.d.ts +11 -30
  19. package/dist/index.js +11 -30
  20. package/dist/index.js.map +1 -1
  21. package/dist/install.d.ts +78 -0
  22. package/dist/install.js +292 -0
  23. package/dist/install.js.map +1 -0
  24. package/dist/main.d.ts +1 -2
  25. package/dist/main.js +160 -1362
  26. package/dist/main.js.map +1 -1
  27. package/dist/manifest.d.ts +23 -0
  28. package/dist/manifest.js +159 -0
  29. package/dist/manifest.js.map +1 -0
  30. package/dist/membrane.d.ts +33 -0
  31. package/dist/membrane.js +140 -0
  32. package/dist/membrane.js.map +1 -0
  33. package/dist/remote.d.ts +10 -0
  34. package/dist/remote.js +292 -0
  35. package/dist/remote.js.map +1 -0
  36. package/dist/rescue.d.ts +10 -0
  37. package/dist/rescue.js +216 -0
  38. package/dist/rescue.js.map +1 -0
  39. package/dist/resolve.d.ts +34 -0
  40. package/dist/resolve.js +178 -0
  41. package/dist/resolve.js.map +1 -0
  42. package/dist/rpc.d.ts +26 -0
  43. package/dist/rpc.js +144 -0
  44. package/dist/rpc.js.map +1 -0
  45. package/dist/secrets.d.ts +12 -0
  46. package/dist/secrets.js +125 -0
  47. package/dist/secrets.js.map +1 -0
  48. package/dist/session.d.ts +45 -0
  49. package/dist/session.js +401 -0
  50. package/dist/session.js.map +1 -0
  51. package/dist/source.d.ts +12 -0
  52. package/dist/source.js +72 -0
  53. package/dist/source.js.map +1 -0
  54. package/dist/state.d.ts +37 -0
  55. package/dist/state.js +93 -0
  56. package/dist/state.js.map +1 -0
  57. package/dist/update.d.ts +2 -0
  58. package/dist/update.js +6 -3
  59. package/dist/update.js.map +1 -1
  60. package/package.json +10 -8
  61. package/plugins/approval/index.ts +311 -0
  62. package/plugins/approval/plugin.json +22 -0
  63. package/{src/plugins → plugins/approval}/policy.ts +45 -104
  64. package/{src/plugins → plugins/approval}/review.ts +62 -16
  65. package/plugins/ask/index.ts +159 -0
  66. package/plugins/ask/plugin.json +8 -0
  67. package/plugins/budget/index.ts +38 -0
  68. package/plugins/budget/plugin.json +13 -0
  69. package/{src/plugins → plugins/checks}/checks.ts +48 -38
  70. package/plugins/checks/index.ts +158 -0
  71. package/plugins/checks/plugin.json +14 -0
  72. package/plugins/checks/project.ts +81 -0
  73. package/plugins/commands/index.ts +76 -0
  74. package/plugins/commands/plugin.json +7 -0
  75. package/{src/plugins → plugins/compact}/compact.ts +80 -39
  76. package/plugins/compact/index.ts +115 -0
  77. package/plugins/compact/plugin.json +17 -0
  78. package/plugins/compact/style.ts +17 -0
  79. package/plugins/continue/index.ts +58 -0
  80. package/plugins/continue/plugin.json +13 -0
  81. package/{src/ui → plugins/fs}/diff.ts +2 -2
  82. package/{src/tools → plugins/fs}/fs.ts +89 -46
  83. package/{src/tools → plugins/fs}/grep.ts +36 -8
  84. package/plugins/fs/index.ts +37 -0
  85. package/plugins/fs/plugin.json +7 -0
  86. package/{src/ui → plugins/fs}/renderers.ts +25 -70
  87. package/plugins/fs/style.ts +18 -0
  88. package/plugins/fs/sys.ts +81 -0
  89. package/plugins/keys/index.ts +53 -0
  90. package/plugins/keys/plugin.json +7 -0
  91. package/plugins/mcp/index.ts +192 -0
  92. package/{src → plugins/mcp}/mcp.ts +32 -32
  93. package/plugins/mcp/plugin.json +7 -0
  94. package/plugins/mcp/project.ts +93 -0
  95. package/plugins/memory/index.ts +105 -0
  96. package/{src → plugins/memory}/memory.ts +20 -2
  97. package/plugins/memory/notes.ts +43 -0
  98. package/plugins/memory/plugin.json +7 -0
  99. package/plugins/memory/style.ts +17 -0
  100. package/plugins/mentions/attach.ts +127 -0
  101. package/plugins/mentions/index.ts +99 -0
  102. package/plugins/mentions/plugin.json +7 -0
  103. package/plugins/mentions/style.ts +17 -0
  104. package/plugins/models/config.ts +53 -0
  105. package/plugins/models/configure.ts +455 -0
  106. package/plugins/models/context.ts +32 -0
  107. package/plugins/models/index.ts +213 -0
  108. package/plugins/models/plugin.json +8 -0
  109. package/{src → plugins/models}/provider.ts +16 -119
  110. package/plugins/models/saved.ts +94 -0
  111. package/plugins/modes/index.ts +222 -0
  112. package/plugins/modes/plugin.json +9 -0
  113. package/plugins/plugins/index.ts +38 -0
  114. package/plugins/plugins/plugin.json +7 -0
  115. package/plugins/print/index.ts +160 -0
  116. package/plugins/print/plugin.json +8 -0
  117. package/plugins/prompts/index.ts +111 -0
  118. package/plugins/prompts/plugin.json +8 -0
  119. package/plugins/prompts/prompts.ts +258 -0
  120. package/plugins/prompts/results.ts +63 -0
  121. package/plugins/prompts/sys.ts +84 -0
  122. package/plugins/renderers/index.ts +78 -0
  123. package/plugins/renderers/plugin.json +7 -0
  124. package/plugins/repeats/index.ts +165 -0
  125. package/plugins/repeats/plugin.json +6 -0
  126. package/plugins/schedule/cron.ts +74 -0
  127. package/plugins/schedule/index.ts +292 -0
  128. package/plugins/schedule/plugin.json +13 -0
  129. package/plugins/schedule/store.ts +149 -0
  130. package/plugins/scratch/index.ts +31 -0
  131. package/plugins/scratch/plugin.json +7 -0
  132. package/plugins/screenshot/index.ts +40 -0
  133. package/plugins/screenshot/plugin.json +7 -0
  134. package/plugins/screenshot/sys.ts +84 -0
  135. package/{src/tools/screenshot.ts → plugins/screenshot/tool.ts} +6 -6
  136. package/plugins/sessions/index.ts +148 -0
  137. package/plugins/sessions/plugin.json +8 -0
  138. package/plugins/shell/index.ts +33 -0
  139. package/plugins/shell/plugin.json +17 -0
  140. package/plugins/shell/renderers.ts +45 -0
  141. package/plugins/shell/service.ts +44 -0
  142. package/{src/tools → plugins/shell}/shell.ts +31 -20
  143. package/{src → plugins/shell}/sys.ts +2 -43
  144. package/plugins/skills/index.ts +96 -0
  145. package/plugins/skills/plugin.json +7 -0
  146. package/plugins/skills/project.ts +49 -0
  147. package/{src → plugins/skills}/skills.ts +4 -11
  148. package/plugins/suggest/index.ts +286 -0
  149. package/plugins/suggest/plugin.json +18 -0
  150. package/plugins/task/index.ts +168 -0
  151. package/plugins/task/plugin.json +15 -0
  152. package/plugins/task/style.ts +17 -0
  153. package/plugins/task/subagent.ts +343 -0
  154. package/plugins/todo/index.ts +93 -0
  155. package/plugins/todo/plugin.json +7 -0
  156. package/{src/ui → plugins/tui}/editor.ts +3 -0
  157. package/plugins/tui/frontend.ts +619 -0
  158. package/plugins/tui/index.ts +37 -0
  159. package/plugins/tui/mentions.ts +153 -0
  160. package/plugins/tui/plugin.json +10 -0
  161. package/{src/ui → plugins/tui}/render.ts +8 -2
  162. package/{src/ui → plugins/tui}/screen.ts +8 -3
  163. package/{src/ui → plugins/tui}/transcript.ts +79 -100
  164. package/{src/ui/tui.tsx → plugins/tui/tui.ts} +360 -392
  165. package/plugins/tui/vendor.ts +16 -0
  166. package/{src/tools → plugins/undo}/checkpoint.ts +45 -60
  167. package/plugins/undo/index.ts +143 -0
  168. package/plugins/undo/notes.ts +43 -0
  169. package/plugins/undo/plugin.json +7 -0
  170. package/plugins/undo/style.ts +17 -0
  171. package/plugins/update/index.ts +40 -0
  172. package/plugins/update/plugin.json +13 -0
  173. package/plugins/web/env.ts +78 -0
  174. package/plugins/web/index.ts +133 -0
  175. package/plugins/web/plugin.json +15 -0
  176. package/plugins/web/renderers.ts +11 -0
  177. package/{src/tools → plugins/web}/web.ts +64 -31
  178. package/plugins-dist/approval/index.js +287 -0
  179. package/plugins-dist/approval/plugin.json +28 -0
  180. package/{dist/plugins → plugins-dist/approval}/policy.js +41 -85
  181. package/{dist/plugins → plugins-dist/approval}/review.js +56 -10
  182. package/{dist/plugins → plugins-dist/approval}/schema.js +0 -1
  183. package/plugins-dist/ask/index.js +145 -0
  184. package/plugins-dist/ask/plugin.json +12 -0
  185. package/plugins-dist/budget/index.js +37 -0
  186. package/plugins-dist/budget/plugin.json +15 -0
  187. package/{dist/plugins → plugins-dist/checks}/checks.js +46 -35
  188. package/plugins-dist/checks/index.js +150 -0
  189. package/plugins-dist/checks/plugin.json +21 -0
  190. package/plugins-dist/checks/project.js +76 -0
  191. package/plugins-dist/commands/index.js +33 -0
  192. package/plugins-dist/commands/plugin.json +9 -0
  193. package/{dist/plugins → plugins-dist/compact}/compact.js +58 -34
  194. package/plugins-dist/compact/index.js +100 -0
  195. package/plugins-dist/compact/plugin.json +25 -0
  196. package/plugins-dist/compact/style.js +14 -0
  197. package/plugins-dist/continue/index.js +57 -0
  198. package/plugins-dist/continue/plugin.json +15 -0
  199. package/{dist/ui → plugins-dist/fs}/diff.js +2 -3
  200. package/{dist/tools → plugins-dist/fs}/fs.js +82 -46
  201. package/{dist/tools → plugins-dist/fs}/grep.js +36 -11
  202. package/plugins-dist/fs/index.js +39 -0
  203. package/plugins-dist/fs/plugin.json +10 -0
  204. package/{dist/ui → plugins-dist/fs}/renderers.js +24 -61
  205. package/plugins-dist/fs/style.js +15 -0
  206. package/plugins-dist/fs/sys.js +54 -0
  207. package/plugins-dist/keys/index.js +36 -0
  208. package/plugins-dist/keys/plugin.json +9 -0
  209. package/plugins-dist/mcp/index.js +187 -0
  210. package/{dist → plugins-dist/mcp}/mcp.js +34 -30
  211. package/plugins-dist/mcp/plugin.json +12 -0
  212. package/plugins-dist/mcp/project.js +90 -0
  213. package/plugins-dist/memory/index.js +94 -0
  214. package/{dist → plugins-dist/memory}/memory.js +21 -3
  215. package/plugins-dist/memory/notes.js +36 -0
  216. package/plugins-dist/memory/plugin.json +11 -0
  217. package/plugins-dist/memory/style.js +14 -0
  218. package/plugins-dist/mentions/attach.js +120 -0
  219. package/plugins-dist/mentions/index.js +87 -0
  220. package/plugins-dist/mentions/plugin.json +9 -0
  221. package/plugins-dist/mentions/style.js +14 -0
  222. package/plugins-dist/models/config.js +53 -0
  223. package/plugins-dist/models/configure.js +415 -0
  224. package/plugins-dist/models/context.js +27 -0
  225. package/plugins-dist/models/index.js +181 -0
  226. package/plugins-dist/models/plugin.json +14 -0
  227. package/{dist → plugins-dist/models}/provider.js +18 -81
  228. package/plugins-dist/models/saved.js +80 -0
  229. package/plugins-dist/modes/index.js +190 -0
  230. package/plugins-dist/modes/plugin.json +18 -0
  231. package/plugins-dist/plugins/index.js +37 -0
  232. package/plugins-dist/plugins/plugin.json +10 -0
  233. package/plugins-dist/print/index.js +172 -0
  234. package/plugins-dist/print/plugin.json +14 -0
  235. package/plugins-dist/prompts/index.js +85 -0
  236. package/plugins-dist/prompts/plugin.json +13 -0
  237. package/plugins-dist/prompts/prompts.js +231 -0
  238. package/plugins-dist/prompts/results.js +60 -0
  239. package/plugins-dist/prompts/sys.js +58 -0
  240. package/plugins-dist/renderers/index.js +36 -0
  241. package/plugins-dist/renderers/plugin.json +9 -0
  242. package/plugins-dist/repeats/index.js +165 -0
  243. package/plugins-dist/repeats/plugin.json +6 -0
  244. package/plugins-dist/schedule/cron.js +67 -0
  245. package/plugins-dist/schedule/index.js +281 -0
  246. package/plugins-dist/schedule/plugin.json +16 -0
  247. package/plugins-dist/schedule/store.js +125 -0
  248. package/plugins-dist/scratch/index.js +26 -0
  249. package/plugins-dist/scratch/plugin.json +10 -0
  250. package/plugins-dist/screenshot/index.js +35 -0
  251. package/plugins-dist/screenshot/plugin.json +11 -0
  252. package/plugins-dist/screenshot/sys.js +76 -0
  253. package/{dist/tools/screenshot.js → plugins-dist/screenshot/tool.js} +5 -4
  254. package/plugins-dist/sessions/index.js +136 -0
  255. package/plugins-dist/sessions/plugin.json +12 -0
  256. package/plugins-dist/shell/index.js +33 -0
  257. package/plugins-dist/shell/plugin.json +19 -0
  258. package/plugins-dist/shell/renderers.js +40 -0
  259. package/plugins-dist/shell/service.js +29 -0
  260. package/{dist/tools → plugins-dist/shell}/shell.js +31 -22
  261. package/{dist → plugins-dist/shell}/sys.js +2 -43
  262. package/plugins-dist/skills/index.js +90 -0
  263. package/plugins-dist/skills/plugin.json +12 -0
  264. package/plugins-dist/skills/project.js +47 -0
  265. package/{dist → plugins-dist/skills}/skills.js +3 -7
  266. package/plugins-dist/suggest/index.js +282 -0
  267. package/plugins-dist/suggest/plugin.json +23 -0
  268. package/plugins-dist/task/index.js +152 -0
  269. package/plugins-dist/task/plugin.json +23 -0
  270. package/plugins-dist/task/style.js +14 -0
  271. package/plugins-dist/task/subagent.js +284 -0
  272. package/{dist/tools/todo.js → plugins-dist/todo/index.js} +31 -9
  273. package/plugins-dist/todo/plugin.json +9 -0
  274. package/{dist/ui → plugins-dist/tui}/editor.js +3 -1
  275. package/plugins-dist/tui/frontend.js +609 -0
  276. package/{dist → plugins-dist/tui}/history.js +0 -1
  277. package/plugins-dist/tui/index.js +21 -0
  278. package/{dist/ui → plugins-dist/tui}/markdown.js +0 -1
  279. package/plugins-dist/tui/mentions.js +153 -0
  280. package/plugins-dist/tui/plugin.json +25 -0
  281. package/{dist/ui → plugins-dist/tui}/render.js +7 -3
  282. package/{dist/ui → plugins-dist/tui}/screen.js +6 -2
  283. package/{dist/ui → plugins-dist/tui}/transcript.js +79 -99
  284. package/{dist/ui → plugins-dist/tui}/tui.js +185 -54
  285. package/plugins-dist/tui/vendor.js +13822 -0
  286. package/{dist/tools → plugins-dist/undo}/checkpoint.js +48 -55
  287. package/plugins-dist/undo/index.js +143 -0
  288. package/plugins-dist/undo/notes.js +36 -0
  289. package/plugins-dist/undo/plugin.json +9 -0
  290. package/plugins-dist/undo/style.js +14 -0
  291. package/plugins-dist/update/index.js +34 -0
  292. package/plugins-dist/update/plugin.json +15 -0
  293. package/plugins-dist/web/env.js +80 -0
  294. package/plugins-dist/web/index.js +124 -0
  295. package/plugins-dist/web/plugin.json +21 -0
  296. package/plugins-dist/web/renderers.js +7 -0
  297. package/{dist/tools → plugins-dist/web}/web.js +56 -29
  298. package/sdk/python/__pycache__/jade_plugin.cpython-312.pyc +0 -0
  299. package/sdk/python/jade_plugin.py +380 -0
  300. package/src/api.ts +298 -0
  301. package/src/config.ts +32 -134
  302. package/src/fetch.ts +216 -0
  303. package/src/hash.ts +39 -0
  304. package/src/host.ts +429 -0
  305. package/src/index.ts +23 -30
  306. package/src/install.ts +355 -0
  307. package/src/main.ts +156 -1387
  308. package/src/manifest.ts +160 -0
  309. package/src/membrane.ts +142 -0
  310. package/src/remote.ts +288 -0
  311. package/src/rescue.ts +217 -0
  312. package/src/resolve.ts +199 -0
  313. package/src/rpc.ts +144 -0
  314. package/src/secrets.ts +122 -0
  315. package/src/session.ts +458 -0
  316. package/src/source.ts +83 -0
  317. package/src/state.ts +120 -0
  318. package/src/update.ts +265 -262
  319. package/LICENSE +0 -21
  320. package/dist/commands.d.ts +0 -50
  321. package/dist/commands.js +0 -126
  322. package/dist/commands.js.map +0 -1
  323. package/dist/context.d.ts +0 -17
  324. package/dist/context.js +0 -53
  325. package/dist/context.js.map +0 -1
  326. package/dist/distro.d.ts +0 -141
  327. package/dist/distro.js +0 -462
  328. package/dist/distro.js.map +0 -1
  329. package/dist/history.d.ts +0 -10
  330. package/dist/history.js.map +0 -1
  331. package/dist/mcp.d.ts +0 -114
  332. package/dist/mcp.js.map +0 -1
  333. package/dist/memory.d.ts +0 -19
  334. package/dist/memory.js.map +0 -1
  335. package/dist/mentions.d.ts +0 -35
  336. package/dist/mentions.js +0 -130
  337. package/dist/mentions.js.map +0 -1
  338. package/dist/plugin-cli.d.ts +0 -16
  339. package/dist/plugin-cli.js +0 -294
  340. package/dist/plugin-cli.js.map +0 -1
  341. package/dist/plugins/budget.d.ts +0 -9
  342. package/dist/plugins/budget.js +0 -30
  343. package/dist/plugins/budget.js.map +0 -1
  344. package/dist/plugins/builtins.d.ts +0 -10
  345. package/dist/plugins/builtins.js +0 -25
  346. package/dist/plugins/builtins.js.map +0 -1
  347. package/dist/plugins/checks.d.ts +0 -71
  348. package/dist/plugins/checks.js.map +0 -1
  349. package/dist/plugins/compact.d.ts +0 -26
  350. package/dist/plugins/compact.js.map +0 -1
  351. package/dist/plugins/core.d.ts +0 -47
  352. package/dist/plugins/core.js +0 -229
  353. package/dist/plugins/core.js.map +0 -1
  354. package/dist/plugins/host.d.ts +0 -52
  355. package/dist/plugins/host.js +0 -115
  356. package/dist/plugins/host.js.map +0 -1
  357. package/dist/plugins/install.d.ts +0 -68
  358. package/dist/plugins/install.js +0 -377
  359. package/dist/plugins/install.js.map +0 -1
  360. package/dist/plugins/loader.d.ts +0 -410
  361. package/dist/plugins/loader.js +0 -407
  362. package/dist/plugins/loader.js.map +0 -1
  363. package/dist/plugins/policy.d.ts +0 -98
  364. package/dist/plugins/policy.js.map +0 -1
  365. package/dist/plugins/prompts.d.ts +0 -43
  366. package/dist/plugins/prompts.js +0 -284
  367. package/dist/plugins/prompts.js.map +0 -1
  368. package/dist/plugins/repeats.d.ts +0 -16
  369. package/dist/plugins/repeats.js +0 -151
  370. package/dist/plugins/repeats.js.map +0 -1
  371. package/dist/plugins/review.d.ts +0 -18
  372. package/dist/plugins/review.js.map +0 -1
  373. package/dist/plugins/schema.d.ts +0 -2
  374. package/dist/plugins/schema.js.map +0 -1
  375. package/dist/plugins/sessions.d.ts +0 -7
  376. package/dist/plugins/sessions.js +0 -110
  377. package/dist/plugins/sessions.js.map +0 -1
  378. package/dist/provider.d.ts +0 -165
  379. package/dist/provider.js.map +0 -1
  380. package/dist/session-lifecycle.d.ts +0 -61
  381. package/dist/session-lifecycle.js +0 -167
  382. package/dist/session-lifecycle.js.map +0 -1
  383. package/dist/session-scope.d.ts +0 -53
  384. package/dist/session-scope.js +0 -116
  385. package/dist/session-scope.js.map +0 -1
  386. package/dist/sessions.d.ts +0 -28
  387. package/dist/sessions.js +0 -73
  388. package/dist/sessions.js.map +0 -1
  389. package/dist/skills.d.ts +0 -37
  390. package/dist/skills.js.map +0 -1
  391. package/dist/sys.d.ts +0 -51
  392. package/dist/sys.js.map +0 -1
  393. package/dist/tools/ask.d.ts +0 -11
  394. package/dist/tools/ask.js +0 -62
  395. package/dist/tools/ask.js.map +0 -1
  396. package/dist/tools/checkpoint.d.ts +0 -43
  397. package/dist/tools/checkpoint.js.map +0 -1
  398. package/dist/tools/fs.d.ts +0 -39
  399. package/dist/tools/fs.js.map +0 -1
  400. package/dist/tools/grep.d.ts +0 -6
  401. package/dist/tools/grep.js.map +0 -1
  402. package/dist/tools/screenshot.d.ts +0 -15
  403. package/dist/tools/screenshot.js.map +0 -1
  404. package/dist/tools/shell.d.ts +0 -55
  405. package/dist/tools/shell.js.map +0 -1
  406. package/dist/tools/task.d.ts +0 -39
  407. package/dist/tools/task.js +0 -117
  408. package/dist/tools/task.js.map +0 -1
  409. package/dist/tools/todo.d.ts +0 -10
  410. package/dist/tools/todo.js.map +0 -1
  411. package/dist/tools/web.d.ts +0 -53
  412. package/dist/tools/web.js.map +0 -1
  413. package/dist/ui/configure.d.ts +0 -20
  414. package/dist/ui/configure.js +0 -447
  415. package/dist/ui/configure.js.map +0 -1
  416. package/dist/ui/diff.d.ts +0 -20
  417. package/dist/ui/diff.js.map +0 -1
  418. package/dist/ui/editor.d.ts +0 -41
  419. package/dist/ui/editor.js.map +0 -1
  420. package/dist/ui/markdown.d.ts +0 -22
  421. package/dist/ui/markdown.js.map +0 -1
  422. package/dist/ui/render.d.ts +0 -14
  423. package/dist/ui/render.js.map +0 -1
  424. package/dist/ui/renderers.d.ts +0 -8
  425. package/dist/ui/renderers.js.map +0 -1
  426. package/dist/ui/screen.d.ts +0 -118
  427. package/dist/ui/screen.js.map +0 -1
  428. package/dist/ui/transcript.d.ts +0 -46
  429. package/dist/ui/transcript.js.map +0 -1
  430. package/dist/ui/tui.d.ts +0 -47
  431. package/dist/ui/tui.js.map +0 -1
  432. package/src/commands.ts +0 -144
  433. package/src/context.ts +0 -64
  434. package/src/distro.ts +0 -577
  435. package/src/mentions.ts +0 -135
  436. package/src/plugin-cli.ts +0 -278
  437. package/src/plugins/budget.ts +0 -37
  438. package/src/plugins/builtins.ts +0 -34
  439. package/src/plugins/core.ts +0 -257
  440. package/src/plugins/host.ts +0 -146
  441. package/src/plugins/install.ts +0 -429
  442. package/src/plugins/loader.ts +0 -742
  443. package/src/plugins/prompts.ts +0 -327
  444. package/src/plugins/repeats.ts +0 -157
  445. package/src/plugins/sessions.ts +0 -109
  446. package/src/session-lifecycle.ts +0 -194
  447. package/src/session-scope.ts +0 -135
  448. package/src/sessions.ts +0 -78
  449. package/src/tools/ask.ts +0 -72
  450. package/src/tools/task.ts +0 -149
  451. package/src/tools/todo.ts +0 -67
  452. package/src/ui/configure.ts +0 -471
  453. /package/{src/plugins → plugins/approval}/schema.ts +0 -0
  454. /package/{src → plugins/tui}/history.ts +0 -0
  455. /package/{src/ui → plugins/tui}/markdown.ts +0 -0
@@ -1,8 +1,11 @@
1
1
  // 终端界面(Ink):全屏(备用屏幕缓冲区)分三块——顶部标题(版本、模型、目录),中间是对话,
2
2
  // 自己滚动(滚轮、PgUp/PgDn),底部固定显示运行状态、排队的消息、输入框(或对话框)和状态栏。
3
3
  // 运行中也能输入:提交的内容由宿主决定立即执行还是排队。
4
+ //
5
+ // 不用 JSX:插件以 .ts 源码加载,Node 的类型剥离不处理 .tsx,所以组件用 createElement(h)写。
4
6
 
5
7
  import { writeSync } from "node:fs";
8
+ import type { DOMElement, Key } from "ink";
6
9
  import {
7
10
  Box,
8
11
  render,
@@ -12,21 +15,18 @@ import {
12
15
  useInput,
13
16
  usePaste,
14
17
  useWindowSize,
15
- type DOMElement,
16
- type Key,
17
- } from "ink";
18
- import {
19
18
  createContext,
19
+ createElement as h,
20
20
  useContext,
21
21
  useEffect,
22
22
  useReducer,
23
23
  useRef,
24
24
  useState,
25
25
  useSyncExternalStore,
26
- } from "react";
26
+ } from "./vendor.ts";
27
27
  import stringWidth from "string-width";
28
28
  import wrapAnsi from "wrap-ansi";
29
- import { mentionAt, mentionText, rankPaths } from "../mentions.ts";
29
+ import { mentionAt, mentionText, rankPaths } from "./mentions.ts";
30
30
  import { charWidth, edit, empty, layout, moveRow, offsetAt, type EditState } from "./editor.ts";
31
31
  import { expandTabs, markdownStream, type MdLine } from "./markdown.ts";
32
32
  import {
@@ -52,6 +52,8 @@ export interface TuiHandlers {
52
52
  submit(text: string): void;
53
53
  /** 运行中按 Esc 或 Ctrl+C */
54
54
  interrupt(): void;
55
+ /** 输入框第一行按 ↑:把排队的消息放回输入框;没有排队的消息时返回 false,↑ 照常翻历史 */
56
+ unqueue?(): boolean;
55
57
  /** 空闲时连按两次 Ctrl+C */
56
58
  exit(): void;
57
59
  /** 输入 @ 时补全用的路径(目录以 / 结尾);每次开始输入一个新的 @ 引用时取一次 */
@@ -104,6 +106,8 @@ interface UiState {
104
106
  queued: string[];
105
107
  dialogs: Dialog[];
106
108
  status: StatusInfo;
109
+ /** 插件设置的灰色提示(ctx.input.hint):输入框为空时显示,Tab 或 → 接受 */
110
+ hint?: string;
107
111
  }
108
112
 
109
113
  /** 对话最多保留这么多行(折行前),超出时丢掉最早的一段 */
@@ -352,7 +356,7 @@ class Store {
352
356
  this.#owners = [];
353
357
  this.#named.clear();
354
358
  this.update(
355
- { version: this.state.version + 1, live: undefined, progress: [], scroll: 0 },
359
+ { version: this.state.version + 1, live: undefined, progress: [], scroll: 0, hint: undefined },
356
360
  true,
357
361
  );
358
362
  }
@@ -375,7 +379,8 @@ export interface TuiOptions {
375
379
  status: StatusInfo;
376
380
  /** 标题里显示的版本号 */
377
381
  version: string;
378
- commands: CommandInfo[];
382
+ /** 斜杠命令菜单的内容;命令随会话的插件增减时传函数,每次显示菜单时取最新的 */
383
+ commands: CommandInfo[] | (() => CommandInfo[]);
379
384
  handlers: TuiHandlers;
380
385
  /** 之前提交过的输入(旧的在前),↑/↓ 和 Ctrl+R 用 */
381
386
  history?: string[];
@@ -468,7 +473,7 @@ export function tuiScreen(opts: TuiOptions): Screen {
468
473
  };
469
474
 
470
475
  /** signal 中止时关掉对话框,返回 undefined */
471
- const ask = <T,>(dialog: Dialog, signal?: AbortSignal) =>
476
+ const ask = <T>(dialog: Dialog, signal?: AbortSignal) =>
472
477
  new Promise<T>((resolve) => {
473
478
  if (signal?.aborted) return resolve(undefined as T);
474
479
  const close = () => d.resolve(undefined);
@@ -490,16 +495,17 @@ export function tuiScreen(opts: TuiOptions): Screen {
490
495
  // 切到备用屏幕后光标还停在原来的位置(不少终端不会自动归位),Ink 从那里往下画第一帧会让屏幕滚动,
491
496
  // 之后每帧只重写变化的行,整个界面就错位了。所以先自己切过去、清屏、把光标移到左上角
492
497
  stdout.write("\x1b[?1049h\x1b[2J\x1b[H");
498
+ const commands = opts.commands;
493
499
  const instance = render(
494
- <App
495
- store={store}
496
- copy={(text) => stdout.write(osc52(text))}
497
- version={opts.version}
498
- commands={opts.commands}
499
- handlers={opts.handlers}
500
- history={opts.history ?? []}
501
- draft={draft}
502
- />,
500
+ h(App, {
501
+ store,
502
+ copy: (text: string) => void stdout.write(osc52(text)),
503
+ version: opts.version,
504
+ commands: typeof commands === "function" ? commands : () => commands,
505
+ handlers: opts.handlers,
506
+ history: opts.history ?? [],
507
+ draft,
508
+ }),
503
509
  {
504
510
  exitOnCtrlC: false,
505
511
  alternateScreen: true,
@@ -603,8 +609,9 @@ export function tuiScreen(opts: TuiOptions): Screen {
603
609
  const value = text.replace(/\r\n?/g, "\n");
604
610
  draft.current?.apply(() => ({ value, cursor: value.length }));
605
611
  },
612
+ hint: (text) => store.update({ hint: text ? text.replace(/\r\n?/g, "\n") : undefined }),
606
613
  },
607
- select: <T,>(title: string, choices: Choice<T>[], o?: { body?: string; signal?: AbortSignal }) => {
614
+ select: <T>(title: string, choices: Choice<T>[], o?: { body?: string; signal?: AbortSignal }) => {
608
615
  if (longBusy()) notify(title);
609
616
  return ask<T | undefined>(
610
617
  {
@@ -773,7 +780,7 @@ function App({
773
780
  /** 把选中的文字放进剪贴板 */
774
781
  copy(text: string): void;
775
782
  version: string;
776
- commands: CommandInfo[];
783
+ commands: () => CommandInfo[];
777
784
  handlers: TuiHandlers;
778
785
  history: string[];
779
786
  draft: DraftBridge;
@@ -845,10 +852,16 @@ function App({
845
852
  };
846
853
 
847
854
  // Ink 增量渲染只用相对光标移动,第一帧起点一旦偏了(启动时终端尺寸还没稳定、窗口缩放、别的输出插进来),
848
- // 之后每帧都会画错行。启动后、尺寸变化后和按 Ctrl+L 时让一帧比终端高,Ink 会清屏从左上角整帧重画(包在同步输出里),下一帧再恢复
855
+ // 之后每帧都会画错行。尺寸变化后和按 Ctrl+L 时让一帧比终端高,Ink 会清屏从左上角整帧重画(包在同步输出里),下一帧再恢复。
856
+ // 启动时不重画:第一帧之前已经清屏、光标在左上角;这两次清屏在不支持同步输出的终端上(Windows 上常见)看得出闪一下
849
857
  const [redraws, setRedraws] = useState(0);
850
858
  const [repaint, setRepaint] = useState(false);
859
+ const mounted = useRef(false);
851
860
  useEffect(() => {
861
+ if (!mounted.current) {
862
+ mounted.current = true;
863
+ return;
864
+ }
852
865
  const t = setTimeout(() => setRepaint(true), 100);
853
866
  return () => clearTimeout(t);
854
867
  }, [columns, rows, redraws]);
@@ -904,77 +917,75 @@ function App({
904
917
  // 总高度要比终端少一行,否则 Ink 认为输出占满了屏幕,每帧清屏重画。
905
918
  // 重画那一帧上下各垫一行空白:终端把顶上那行滚出去后,看到的和平时逐行一样,所以不会闪。
906
919
  // 只做纵向裁剪:每行都已按宽度折好或截断,横向裁剪会让 Ink 每帧对每一行再切一遍 ANSI 字符串
907
- return (
908
- <SelectionContext.Provider value={selectionApi}>
909
- <Box
910
- flexDirection="column"
911
- width={columns}
912
- height={repaint ? rows + 1 : Math.max(1, rows - 1)}
913
- paddingY={repaint ? 1 : 0}
914
- overflowY="hidden"
915
- >
916
- {/* 垫的空白放在外层:里面这层在重画那一帧和平时一样高,对话区的 top(相对父节点)不变,点击换算的行号不会差一行 */}
917
- <Box flexDirection="column" flexGrow={1} overflowY="hidden">
918
- <Header
919
- status={state.status}
920
- version={version}
921
- compact={rows < COMPACT_ROWS}
922
- />
923
- <Box
924
- ref={ref}
925
- flexDirection="column"
926
- flexGrow={1}
927
- flexShrink={1}
928
- flexBasis={0}
929
- overflowY="hidden"
930
- paddingX={1}
931
- >
932
- {shown.map((l, i) => {
920
+ return h(
921
+ SelectionContext.Provider,
922
+ { value: selectionApi },
923
+ h(
924
+ Box,
925
+ {
926
+ flexDirection: "column",
927
+ width: columns,
928
+ height: repaint ? rows + 1 : Math.max(1, rows - 1),
929
+ paddingY: repaint ? 1 : 0,
930
+ overflowY: "hidden",
931
+ },
932
+ // 垫的空白放在外层:里面这层在重画那一帧和平时一样高,对话区的 top(相对父节点)不变,点击换算的行号不会差一行
933
+ h(
934
+ Box,
935
+ { flexDirection: "column", flexGrow: 1, overflowY: "hidden" },
936
+ h(Header, { status: state.status, version, compact: rows < COMPACT_ROWS }),
937
+ h(
938
+ Box,
939
+ {
940
+ ref,
941
+ flexDirection: "column",
942
+ flexGrow: 1,
943
+ flexShrink: 1,
944
+ flexBasis: 0,
945
+ overflowY: "hidden",
946
+ paddingX: 1,
947
+ },
948
+ shown.map((l, i) => {
933
949
  const cols = selection && selectedCols(selection, start + i);
934
- return (
935
- <Text key={i} wrap="truncate-end">
936
- {cols ? highlight(l || " ", ...cols) : l || " "}
937
- </Text>
938
- );
939
- })}
940
- {scrolled ? (
941
- <Text dimColor wrap="truncate-end">
942
- {`── ↓ ${scroll} more lines · wheel / PgDn to scroll · ctrl+end to jump to the bottom ──`}
943
- </Text>
944
- ) : null}
945
- </Box>
946
- <Box flexDirection="column" flexShrink={0}>
947
- {state.busy && !dialog ? (
948
- <Spinner label={state.busy.label} since={state.busy.since} />
949
- ) : null}
950
- {state.queued.map((q, i) => (
951
- <Text key={i} dimColor wrap="truncate-end">
952
- {" ↳ queued: "}
953
- {q.replace(/\s+/g, " ")}
954
- </Text>
955
- ))}
956
- {dialog ? (
957
- dialog.kind === "select" ? (
958
- <SelectDialog key={dialogKey(dialog)} dialog={dialog} />
959
- ) : (
960
- <InputDialog key={dialogKey(dialog)} dialog={dialog} />
961
- )
962
- ) : null}
963
- <Prompt
964
- commands={commands}
965
- handlers={handlers}
966
- history={history}
967
- bridge={draft}
968
- busy={Boolean(state.busy)}
969
- active={!dialog}
970
- onSubmit={() => store.scrollBy(-max, max)}
971
- flash={copied}
972
- />
973
- <StatusBar status={state.status} width={Math.max(10, columns - 2)} />
974
- </Box>
975
- </Box>
976
- </Box>
977
- </SelectionContext.Provider>
950
+ return h(Text, { key: i, wrap: "truncate-end" }, cols ? highlight(l || " ", ...cols) : l || " ");
951
+ }),
952
+ scrolled
953
+ ? h(
954
+ Text,
955
+ { dimColor: true, wrap: "truncate-end" },
956
+ `── ↓ ${scroll} more lines · wheel / PgDn to scroll · ctrl+end to jump to the bottom ──`,
957
+ )
958
+ : null,
959
+ ),
960
+ h(
961
+ Box,
962
+ { flexDirection: "column", flexShrink: 0 },
963
+ state.busy && !dialog ? h(Spinner, { label: state.busy.label, since: state.busy.since }) : null,
964
+ state.queued.map((q, i) =>
965
+ h(Text, { key: i, dimColor: true, wrap: "truncate-end" }, " ↳ queued: ", q.replace(/\s+/g, " ")),
966
+ ),
967
+ dialog
968
+ ? dialog.kind === "select"
969
+ ? h(SelectDialog, { key: dialogKey(dialog), dialog })
970
+ : h(InputDialog, { key: dialogKey(dialog), dialog })
971
+ : null,
972
+ h(Prompt, {
973
+ commands,
974
+ handlers,
975
+ history,
976
+ bridge: draft,
977
+ hint: state.hint,
978
+ onHintDone: () => store.update({ hint: undefined }),
979
+ busy: Boolean(state.busy),
980
+ queued: state.queued.length > 0,
981
+ active: !dialog,
982
+ onSubmit: () => store.scrollBy(-max, max),
983
+ flash: copied,
984
+ }),
985
+ h(StatusBar, { status: state.status, width: Math.max(10, columns - 2) }),
986
+ ),
987
+ ),
988
+ ),
978
989
  );
979
990
  }
980
991
 
@@ -986,18 +997,12 @@ const SHINE = "#b6f2d4";
986
997
  * 每个字符上下两个像素;眼睛是玉上挖空的两格,左上角一点高光让它看起来像玉
987
998
  */
988
999
  function Bot() {
989
- return (
990
- <Box flexDirection="column" flexShrink={0} marginRight={2}>
991
- <Text color={JADE}>
992
- {" ▄"}
993
- <Text color={SHINE} backgroundColor={JADE}>
994
- ▄
995
- </Text>
996
- {"████▄"}
997
- </Text>
998
- <Text color={JADE}>██ ███ ██</Text>
999
- <Text color={JADE}>▀███████▀</Text>
1000
- </Box>
1000
+ return h(
1001
+ Box,
1002
+ { flexDirection: "column", flexShrink: 0, marginRight: 2 },
1003
+ h(Text, { color: JADE }, " ▄", h(Text, { color: SHINE, backgroundColor: JADE }, "▄"), "████▄"),
1004
+ h(Text, { color: JADE }, "██ ███ ██"),
1005
+ h(Text, { color: JADE }, "▀███████▀"),
1001
1006
  );
1002
1007
  }
1003
1008
 
@@ -1012,49 +1017,37 @@ function Header({
1012
1017
  compact: boolean;
1013
1018
  }) {
1014
1019
  const { columns } = useScreenSize();
1020
+ // 模型 · 目录 (分支)
1021
+ const where = [
1022
+ h(Text, { key: "model", color: "cyan" }, status.model),
1023
+ h(Text, { key: "sep", dimColor: true }, " · "),
1024
+ h(Text, { key: "cwd" }, status.cwd),
1025
+ status.branch ? h(Text, { key: "branch", color: "magenta" }, ` (${status.branch})`) : null,
1026
+ ];
1027
+ const name = h(Text, { key: "name", color: "cyan", bold: true }, "jade");
1015
1028
  if (compact)
1016
- return (
1017
- <Box flexShrink={0} paddingX={1}>
1018
- <Text wrap="truncate-end">
1019
- <Text color="cyan" bold>
1020
- jade
1021
- </Text>
1022
- <Text dimColor> · </Text>
1023
- <Text color="cyan">{status.model}</Text>
1024
- <Text dimColor> · </Text>
1025
- <Text>{status.cwd}</Text>
1026
- {status.branch ? (
1027
- <Text color="magenta"> ({status.branch})</Text>
1028
- ) : null}
1029
- </Text>
1030
- </Box>
1029
+ return h(
1030
+ Box,
1031
+ { flexShrink: 0, paddingX: 1 },
1032
+ h(Text, { wrap: "truncate-end" }, name, h(Text, { key: "dot", dimColor: true }, " · "), ...where),
1031
1033
  );
1032
- return (
1033
- <Box flexShrink={0} borderStyle="round" borderColor="cyan" paddingX={1}>
1034
- {columns >= 50 ? <Bot /> : null}
1035
- <Box flexDirection="column" flexGrow={1} flexShrink={1}>
1036
- <Text wrap="truncate-end">
1037
- <Text color="cyan" bold>
1038
- jade
1039
- </Text>
1040
- <Text dimColor> v{version}</Text>
1041
- {status.session ? (
1042
- <Text dimColor>{` · session ${status.session}`}</Text>
1043
- ) : null}
1044
- </Text>
1045
- <Text wrap="truncate-end">
1046
- <Text color="cyan">{status.model}</Text>
1047
- <Text dimColor> · </Text>
1048
- <Text>{status.cwd}</Text>
1049
- {status.branch ? (
1050
- <Text color="magenta"> ({status.branch})</Text>
1051
- ) : null}
1052
- </Text>
1053
- <Text dimColor wrap="truncate-end">
1054
- /help for commands · @ to attach files
1055
- </Text>
1056
- </Box>
1057
- </Box>
1034
+ return h(
1035
+ Box,
1036
+ { flexShrink: 0, borderStyle: "round", borderColor: "cyan", paddingX: 1 },
1037
+ columns >= 50 ? h(Bot) : null,
1038
+ h(
1039
+ Box,
1040
+ { flexDirection: "column", flexGrow: 1, flexShrink: 1 },
1041
+ h(
1042
+ Text,
1043
+ { wrap: "truncate-end" },
1044
+ name,
1045
+ h(Text, { dimColor: true }, ` v${version}`),
1046
+ status.session ? h(Text, { dimColor: true }, ` · session ${status.session}`) : null,
1047
+ ),
1048
+ h(Text, { wrap: "truncate-end" }, ...where),
1049
+ h(Text, { dimColor: true, wrap: "truncate-end" }, "/help for commands · @ to attach files"),
1050
+ ),
1058
1051
  );
1059
1052
  }
1060
1053
 
@@ -1071,14 +1064,16 @@ const FRAMES = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "
1071
1064
  function Spinner({ label, since }: { label: string; since: number }) {
1072
1065
  const now = Date.now();
1073
1066
  const seconds = Math.floor((now - since) / 1000);
1074
- return (
1075
- <Box marginTop={1}>
1076
- <Text wrap="truncate-end">
1077
- <Text color="cyan">{FRAMES[Math.floor(now / 100) % FRAMES.length]} </Text>
1078
- <Text>{label}… </Text>
1079
- <Text dimColor>({seconds}s · esc to interrupt)</Text>
1080
- </Text>
1081
- </Box>
1067
+ return h(
1068
+ Box,
1069
+ { marginTop: 1 },
1070
+ h(
1071
+ Text,
1072
+ { wrap: "truncate-end" },
1073
+ h(Text, { color: "cyan" }, `${FRAMES[Math.floor(now / 100) % FRAMES.length]} `),
1074
+ h(Text, null, `${label}… `),
1075
+ h(Text, { dimColor: true }, `(${seconds}s · esc to interrupt)`),
1076
+ ),
1082
1077
  );
1083
1078
  }
1084
1079
 
@@ -1181,19 +1176,16 @@ function StatusBar({ status, width }: { status: StatusInfo; width: number }) {
1181
1176
  },
1182
1177
  ];
1183
1178
  const shown = fitSegments(segments, width);
1184
- return (
1185
- <Box paddingX={1}>
1186
- <Text wrap="truncate-end">
1187
- {shown.map((s, i) => (
1188
- <Text key={i}>
1189
- {i ? <Text dimColor> · </Text> : null}
1190
- <Text color={s.color} dimColor={s.dim}>
1191
- {s.text}
1192
- </Text>
1193
- </Text>
1194
- ))}
1195
- </Text>
1196
- </Box>
1179
+ return h(
1180
+ Box,
1181
+ { paddingX: 1 },
1182
+ h(
1183
+ Text,
1184
+ { wrap: "truncate-end" },
1185
+ shown.map((s, i) =>
1186
+ h(Text, { key: i }, i ? h(Text, { dimColor: true }, " · ") : null, h(Text, { color: s.color, dimColor: s.dim }, s.text)),
1187
+ ),
1188
+ ),
1197
1189
  );
1198
1190
  }
1199
1191
 
@@ -1201,11 +1193,7 @@ function StatusBar({ status, width }: { status: StatusInfo; width: number }) {
1201
1193
  function Hint({ variants, width }: { variants: string[]; width: number }) {
1202
1194
  const text =
1203
1195
  variants.find((v) => stringWidth(v) <= width) ?? variants.at(-1)!;
1204
- return (
1205
- <Text dimColor wrap="truncate-end">
1206
- {text}
1207
- </Text>
1208
- );
1196
+ return h(Text, { dimColor: true, wrap: "truncate-end" }, text);
1209
1197
  }
1210
1198
 
1211
1199
  const tokens = (n: number) =>
@@ -1241,6 +1229,8 @@ function editKey(s: EditState, input: string, key: Key): EditState | undefined {
1241
1229
  if (key.backspace) return key.meta ? edit.deleteWord(s) : edit.backspace(s);
1242
1230
  if (key.delete || (key.ctrl && input === "d")) return edit.del(s);
1243
1231
  if (key.ctrl && input === "w") return edit.deleteWord(s);
1232
+ if (key.meta && !key.ctrl && input === "f") return edit.wordRight(s);
1233
+ if (key.meta && !key.ctrl && input === "b") return edit.wordLeft(s);
1244
1234
  if (key.ctrl && input === "u") return edit.killBefore(s);
1245
1235
  if (key.ctrl && input === "k") return edit.killAfter(s);
1246
1236
  if (
@@ -1325,29 +1315,24 @@ function EditableText({
1325
1315
  if (now.x !== at.x || now.y !== at.y) recheck();
1326
1316
  });
1327
1317
 
1328
- return (
1329
- <Box ref={ref} flexDirection="column">
1330
- {active ? <CursorAt position={position} /> : null}
1331
- {state.value === "" && placeholder ? (
1332
- <Text wrap="truncate-end">
1333
- <Text color="cyan">{prefix}</Text>
1334
- <Text dimColor>{placeholder}</Text>
1335
- </Text>
1336
- ) : (
1337
- rows.map((r, i) => (
1338
- <Text key={first + i} wrap="truncate-end">
1339
- <Text color="cyan">
1340
- {first + i === 0
1341
- ? prefix
1342
- : i === 0
1343
- ? "↑".padEnd(prefix.length)
1344
- : " ".repeat(prefix.length)}
1345
- </Text>
1346
- {r}
1347
- </Text>
1348
- ))
1349
- )}
1350
- </Box>
1318
+ return h(
1319
+ Box,
1320
+ { ref, flexDirection: "column" },
1321
+ active ? h(CursorAt, { position }) : null,
1322
+ state.value === "" && placeholder
1323
+ ? h(Text, { wrap: "truncate-end" }, h(Text, { color: "cyan" }, prefix), h(Text, { dimColor: true }, placeholder))
1324
+ : rows.map((r, i) =>
1325
+ h(
1326
+ Text,
1327
+ { key: first + i, wrap: "truncate-end" },
1328
+ h(
1329
+ Text,
1330
+ { color: "cyan" },
1331
+ first + i === 0 ? prefix : i === 0 ? "↑".padEnd(prefix.length) : " ".repeat(prefix.length),
1332
+ ),
1333
+ r,
1334
+ ),
1335
+ ),
1351
1336
  );
1352
1337
  }
1353
1338
 
@@ -1377,17 +1362,27 @@ function Prompt({
1377
1362
  handlers,
1378
1363
  history: initial,
1379
1364
  bridge,
1365
+ hint,
1366
+ onHintDone,
1380
1367
  busy,
1368
+ queued,
1381
1369
  active,
1382
1370
  onSubmit,
1383
1371
  flash,
1384
1372
  }: {
1385
- commands: CommandInfo[];
1373
+ /** 当前的命令(随会话的插件增减),每次算菜单时取 */
1374
+ commands: () => CommandInfo[];
1386
1375
  handlers: TuiHandlers;
1387
1376
  history: string[];
1388
1377
  /** 让 tuiScreen 的 draft 读写输入框 */
1389
1378
  bridge: DraftBridge;
1379
+ /** 插件设置的灰色提示 */
1380
+ hint?: string;
1381
+ /** 提示被接受了,或者用户开始打字了:去掉它 */
1382
+ onHintDone(): void;
1390
1383
  busy: boolean;
1384
+ /** 有排队等待发送的消息 */
1385
+ queued: boolean;
1391
1386
  active: boolean;
1392
1387
  /** 提交后对话区回到底部 */
1393
1388
  onSubmit(): void;
@@ -1424,7 +1419,7 @@ function Prompt({
1424
1419
  >(undefined);
1425
1420
 
1426
1421
  const usageOf = (c: CommandInfo) => `/${c.name}${c.args ? ` ${c.args}` : ""}`;
1427
- const column = Math.max(...commands.map((c) => usageOf(c).length)) + 2;
1422
+ const column = Math.max(...commands().map((c) => usageOf(c).length)) + 2;
1428
1423
 
1429
1424
  /** 由最新的输入算出补全菜单和搜索结果;渲染和按键处理都用它 */
1430
1425
  const derive = () => {
@@ -1439,7 +1434,7 @@ function Prompt({
1439
1434
  const naming =
1440
1435
  !recalled && state.value.startsWith("/") && !/\s/.test(state.value);
1441
1436
  const matches = naming
1442
- ? commands.filter((c) => `/${c.name}`.startsWith(state.value))
1437
+ ? commands().filter((c) => `/${c.name}`.startsWith(state.value))
1443
1438
  : [];
1444
1439
  const pick = matches[Math.min(selected, matches.length - 1)];
1445
1440
  // @ 引用:光标处正在输入的路径和补全候选
@@ -1501,7 +1496,11 @@ function Prompt({
1501
1496
  const firstMatch = around(Math.max(0, matches.indexOf(pick!)), matches.length, menuRows);
1502
1497
  const firstFound = around(Math.max(0, found.indexOf(file!)), found.length, menuRows);
1503
1498
 
1499
+ /** 提示只在空闲、输入框为空、没有在搜索历史时显示,也只有这时能接受 */
1500
+ const hinting = () => hint !== undefined && !busy && current().value === "" && !getSearch();
1504
1501
  const set = (s: EditState) => {
1502
+ // 用户开始打字(或者插件改了输入框):提示作废
1503
+ if (s.value && hint !== undefined) onHintDone();
1505
1504
  setState(s);
1506
1505
  setSelected(0);
1507
1506
  setNotice(undefined);
@@ -1651,6 +1650,12 @@ function Prompt({
1651
1650
  if (file) return complete(file);
1652
1651
  return submit(state.value.trim());
1653
1652
  }
1653
+ // Tab 或 →:把提示变成输入框里的文字,接着可以改
1654
+ if (((key.tab && !key.shift) || key.rightArrow) && hinting()) {
1655
+ onHintDone();
1656
+ browsing.current = -1;
1657
+ return set({ value: hint!, cursor: hint!.length });
1658
+ }
1654
1659
  if (key.tab && key.shift) return handlers.cycleMode?.();
1655
1660
  if (key.tab) {
1656
1661
  const { pick, file } = derive();
@@ -1668,6 +1673,11 @@ function Prompt({
1668
1673
  // 按折行后的屏幕行移动:一大段没有换行的文字也能上下走,到了第一行才翻历史
1669
1674
  const up = moveRow(state, textWidth, -1);
1670
1675
  if (up) return setState(up);
1676
+ // 先取回排队的消息,取完了再翻历史
1677
+ if (handlers.unqueue?.()) {
1678
+ browsing.current = -1;
1679
+ return;
1680
+ }
1671
1681
  if (browsing.current + 1 < history.current.length) {
1672
1682
  if (browsing.current === -1) draft.current = state.value;
1673
1683
  recall(browsing.current + 1);
@@ -1691,132 +1701,116 @@ function Prompt({
1691
1701
  );
1692
1702
 
1693
1703
  // 对话框打开时隐藏但不卸载,输入到一半的内容和历史都保留
1694
- return (
1695
- <Box
1696
- flexDirection="column"
1697
- marginTop={1}
1698
- display={active ? "flex" : "none"}
1699
- >
1700
- <Box
1701
- borderStyle="round"
1702
- borderColor={busy ? "gray" : "cyan"}
1703
- paddingX={1}
1704
- >
1705
- {search ? (
1706
- <EditableText
1707
- state={{ value: search.query, cursor: search.query.length }}
1708
- width={Math.max(10, columns - 5)}
1709
- prefix="search history› "
1710
- placeholder="type to filter"
1711
- active={active}
1712
- maxRows={inputRows}
1713
- />
1714
- ) : (
1715
- <EditableText
1716
- state={state}
1717
- width={Math.max(10, columns - 5)}
1718
- prefix="› "
1719
- placeholder={
1720
- busy
1721
- ? "Type to queue a message · esc to interrupt"
1722
- : columns >= 70
1723
- ? "Message jade · / commands · @ files · ↑ or ctrl+r for history"
1724
- : "Message jade · / commands · @ files"
1725
- }
1726
- active={active}
1727
- maxRows={inputRows}
1728
- place={place}
1729
- />
1730
- )}
1731
- </Box>
1732
- {search ? (
1733
- <Box flexDirection="column" paddingX={2}>
1734
- {results.length ? (
1735
- results.slice(first, first + menuRows).map((h, i) => {
1736
- const on = first + i === hit;
1737
- return (
1738
- <Text
1739
- key={first + i}
1740
- wrap="truncate-end"
1741
- color={on ? "cyan" : undefined}
1742
- bold={on}
1743
- >
1744
- {on ? "❯ " : " "}
1745
- {h.replace(/\s*\n\s*/g, " ⏎ ")}
1746
- </Text>
1704
+ return h(
1705
+ Box,
1706
+ { flexDirection: "column", marginTop: 1, display: active ? "flex" : "none" },
1707
+ h(
1708
+ Box,
1709
+ { borderStyle: "round", borderColor: busy ? "gray" : "cyan", paddingX: 1 },
1710
+ search
1711
+ ? h(EditableText, {
1712
+ state: { value: search.query, cursor: search.query.length },
1713
+ width: Math.max(10, columns - 5),
1714
+ prefix: "search history› ",
1715
+ placeholder: "type to filter",
1716
+ active,
1717
+ maxRows: inputRows,
1718
+ })
1719
+ : h(EditableText, {
1720
+ state,
1721
+ width: Math.max(10, columns - 5),
1722
+ prefix: "› ",
1723
+ placeholder: hinting()
1724
+ ? hintLine(hint!)
1725
+ : queued
1726
+ ? "↑ to edit queued messages · esc to interrupt"
1727
+ : busy
1728
+ ? "Type to queue a message · esc to interrupt"
1729
+ : columns >= 70
1730
+ ? "Message jade · / commands · @ files · ↑ or ctrl+r for history"
1731
+ : "Message jade · / commands · @ files",
1732
+ active,
1733
+ maxRows: inputRows,
1734
+ place,
1735
+ }),
1736
+ ),
1737
+ search
1738
+ ? h(
1739
+ Box,
1740
+ { flexDirection: "column", paddingX: 2 },
1741
+ results.length
1742
+ ? results.slice(first, first + menuRows).map((item, i) => {
1743
+ const on = first + i === hit;
1744
+ return h(
1745
+ Text,
1746
+ { key: first + i, wrap: "truncate-end", color: on ? "cyan" : undefined, bold: on },
1747
+ on ? "❯ " : " ",
1748
+ item.replace(/\s*\n\s*/g, " ⏎ "),
1749
+ );
1750
+ })
1751
+ : h(Text, { dimColor: true }, " no match"),
1752
+ h(Hint, {
1753
+ width: hintWidth,
1754
+ variants: [" ↑↓ or ctrl+r select · enter/tab put in the input · esc cancel", " ↑↓ select · enter use · esc cancel"],
1755
+ }),
1756
+ )
1757
+ : matches.length
1758
+ ? h(
1759
+ Box,
1760
+ { flexDirection: "column", paddingX: 2 },
1761
+ matches.slice(firstMatch, firstMatch + menuRows).map((c) => {
1762
+ const on = c === pick;
1763
+ return h(
1764
+ Text,
1765
+ { key: c.name, wrap: "truncate-end" },
1766
+ h(Text, { color: on ? "cyan" : undefined, bold: on }, on ? "❯ " : " ", usageOf(c).padEnd(column)),
1767
+ h(Text, { dimColor: true }, c.about),
1747
1768
  );
1748
- })
1749
- ) : (
1750
- <Text dimColor> no match</Text>
1751
- )}
1752
- <Hint
1753
- width={hintWidth}
1754
- variants={[
1755
- " ↑↓ or ctrl+r select · enter/tab put in the input · esc cancel",
1756
- " ↑↓ select · enter use · esc cancel",
1757
- ]}
1758
- />
1759
- </Box>
1760
- ) : matches.length ? (
1761
- <Box flexDirection="column" paddingX={2}>
1762
- {matches.slice(firstMatch, firstMatch + menuRows).map((c) => {
1763
- const on = c === pick;
1764
- return (
1765
- <Text key={c.name} wrap="truncate-end">
1766
- <Text color={on ? "cyan" : undefined} bold={on}>
1767
- {on ? "❯ " : " "}
1768
- {usageOf(c).padEnd(column)}
1769
- </Text>
1770
- <Text dimColor>{c.about}</Text>
1771
- </Text>
1772
- );
1773
- })}
1774
- <Hint
1775
- width={hintWidth}
1776
- variants={[
1777
- ` ↑↓ select · enter run · tab complete${matches.length > menuRows ? ` · ${matches.length} commands` : ""}`,
1778
- " ↑↓ · enter run · tab complete",
1779
- ]}
1780
- />
1781
- </Box>
1782
- ) : found.length ? (
1783
- <Box flexDirection="column" paddingX={2}>
1784
- {found.slice(firstFound, firstFound + menuRows).map((p) => {
1785
- const on = p === file;
1786
- return (
1787
- <Text
1788
- key={p}
1789
- wrap="truncate-middle"
1790
- color={on ? "cyan" : p.endsWith("/") ? "blue" : undefined}
1791
- bold={on}
1792
- >
1793
- {on ? "❯ " : " "}
1794
- {p}
1795
- </Text>
1796
- );
1797
- })}
1798
- <Hint
1799
- width={hintWidth}
1800
- variants={[
1801
- " ↑↓ select · enter/tab insert the path · the file's content is sent with the message",
1802
- " ↑↓ select · enter/tab insert the path",
1803
- " ↑↓ · enter insert",
1804
- ]}
1805
- />
1806
- </Box>
1807
- ) : notice ? (
1808
- <Text color="yellow"> {notice}</Text>
1809
- ) : null}
1810
- {/* 压在输入框上边框的右边,不占行,出现和消失时下面的内容不跳 */}
1811
- {flash ? (
1812
- <Box position="absolute" top={0} right={2}>
1813
- <Text color="green"> {flash} </Text>
1814
- </Box>
1815
- ) : null}
1816
- </Box>
1769
+ }),
1770
+ h(Hint, {
1771
+ width: hintWidth,
1772
+ variants: [
1773
+ ` ↑↓ select · enter run · tab complete${matches.length > menuRows ? ` · ${matches.length} commands` : ""}`,
1774
+ " ↑↓ · enter run · tab complete",
1775
+ ],
1776
+ }),
1777
+ )
1778
+ : found.length
1779
+ ? h(
1780
+ Box,
1781
+ { flexDirection: "column", paddingX: 2 },
1782
+ found.slice(firstFound, firstFound + menuRows).map((p) => {
1783
+ const on = p === file;
1784
+ return h(
1785
+ Text,
1786
+ { key: p, wrap: "truncate-middle", color: on ? "cyan" : p.endsWith("/") ? "blue" : undefined, bold: on },
1787
+ on ? "❯ " : " ",
1788
+ p,
1789
+ );
1790
+ }),
1791
+ h(Hint, {
1792
+ width: hintWidth,
1793
+ variants: [
1794
+ " ↑↓ select · enter/tab insert the path · the file's content is sent with the message",
1795
+ " ↑↓ select · enter/tab insert the path",
1796
+ " ↑↓ · enter insert",
1797
+ ],
1798
+ }),
1799
+ )
1800
+ : notice
1801
+ ? h(Text, { color: "yellow" }, ` ${notice}`)
1802
+ : null,
1803
+ // 压在输入框上边框的右边,不占行,出现和消失时下面的内容不跳
1804
+ flash ? h(Box, { position: "absolute", top: 0, right: 2 }, h(Text, { color: "green" }, ` ${flash} `)) : null,
1817
1805
  );
1818
1806
  }
1819
1807
 
1808
+ /** 提示在输入框里只显示第一行,后面还有时加 … */
1809
+ const hintLine = (hint: string) => {
1810
+ const [first, ...rest] = hint.split("\n");
1811
+ return `${first}${rest.length ? " …" : ""}`;
1812
+ };
1813
+
1820
1814
  /** @ 补全最多显示几项 */
1821
1815
  const MENTION_ROWS = 8;
1822
1816
 
@@ -1901,61 +1895,41 @@ function SelectDialog({
1901
1895
  });
1902
1896
  // 选项多时只显示选中项附近的一段
1903
1897
  const start = around(selected, n, visible);
1904
- return (
1905
- <Box
1906
- flexDirection="column"
1907
- borderStyle="round"
1908
- borderColor="yellow"
1909
- paddingX={1}
1910
- marginTop={1}
1911
- >
1912
- <Text bold wrap="truncate-end">
1913
- {dialog.title}
1914
- </Text>
1915
- {body.map((l, i) => (
1916
- <Text key={i} wrap="truncate-end">
1917
- {l || " "}
1918
- </Text>
1919
- ))}
1920
- {filtering ? (
1921
- <Text wrap="truncate-end">
1922
- <Text color="cyan">filter› </Text>
1923
- {query ? (
1924
- <Text>{query}</Text>
1925
- ) : (
1926
- <Text dimColor>type to filter {dialog.choices.length} items</Text>
1927
- )}
1928
- </Text>
1929
- ) : null}
1930
- <Box flexDirection="column" marginTop={filtering ? 0 : 1}>
1931
- {start > 0 ? <Text dimColor> ↑ {start} more</Text> : null}
1932
- {n === 0 ? <Text dimColor> no match</Text> : null}
1933
- {items.slice(start, start + visible).map(({ c, i }, j) => {
1934
- const on = start + j === selected;
1935
- return (
1936
- <Text key={i} wrap="truncate-end">
1937
- <Text color={on ? "cyan" : undefined} bold={on}>
1938
- {on ? "❯ " : " "}
1939
- {filtering ? "" : `${i + 1}. `}
1940
- {c.label}
1941
- </Text>
1942
- {c.hint ? <Text dimColor> {c.hint}</Text> : null}
1943
- </Text>
1944
- );
1945
- })}
1946
- {start + visible < n ? (
1947
- <Text dimColor> ↓ {n - start - visible} more</Text>
1948
- ) : null}
1949
- </Box>
1950
- <Hint
1951
- width={Math.max(10, columns - 4)}
1952
- variants={
1953
- filtering
1954
- ? ["↑↓ select · type to filter · enter confirm · esc clear/cancel", "↑↓ · enter · esc"]
1955
- : ["↑↓ select · enter confirm · esc cancel", "↑↓ · enter · esc"]
1956
- }
1957
- />
1958
- </Box>
1898
+ return h(
1899
+ Box,
1900
+ { flexDirection: "column", borderStyle: "round", borderColor: "yellow", paddingX: 1, marginTop: 1 },
1901
+ h(Text, { bold: true, wrap: "truncate-end" }, dialog.title),
1902
+ body.map((l, i) => h(Text, { key: i, wrap: "truncate-end" }, l || " ")),
1903
+ filtering
1904
+ ? h(
1905
+ Text,
1906
+ { wrap: "truncate-end" },
1907
+ h(Text, { color: "cyan" }, "filter› "),
1908
+ query ? h(Text, null, query) : h(Text, { dimColor: true }, `type to filter ${dialog.choices.length} items`),
1909
+ )
1910
+ : null,
1911
+ h(
1912
+ Box,
1913
+ { flexDirection: "column", marginTop: filtering ? 0 : 1 },
1914
+ start > 0 ? h(Text, { dimColor: true }, ` ↑ ${start} more`) : null,
1915
+ n === 0 ? h(Text, { dimColor: true }, " no match") : null,
1916
+ items.slice(start, start + visible).map(({ c, i }, j) => {
1917
+ const on = start + j === selected;
1918
+ return h(
1919
+ Text,
1920
+ { key: i, wrap: "truncate-end" },
1921
+ h(Text, { color: on ? "cyan" : undefined, bold: on }, on ? "❯ " : " ", filtering ? "" : `${i + 1}. `, c.label),
1922
+ c.hint ? h(Text, { dimColor: true }, ` ${c.hint}`) : null,
1923
+ );
1924
+ }),
1925
+ start + visible < n ? h(Text, { dimColor: true }, ` ↓ ${n - start - visible} more`) : null,
1926
+ ),
1927
+ h(Hint, {
1928
+ width: Math.max(10, columns - 4),
1929
+ variants: filtering
1930
+ ? ["↑↓ select · type to filter · enter confirm · esc clear/cancel", "↑↓ · enter · esc"]
1931
+ : ["↑↓ select · enter confirm · esc cancel", "↑↓ · enter · esc"],
1932
+ }),
1959
1933
  );
1960
1934
  }
1961
1935
 
@@ -1984,24 +1958,18 @@ function InputDialog({
1984
1958
  const next = editKey(state, input, key);
1985
1959
  if (next) setState(next);
1986
1960
  });
1987
- return (
1988
- <Box
1989
- flexDirection="column"
1990
- borderStyle="round"
1991
- borderColor="yellow"
1992
- paddingX={1}
1993
- marginTop={1}
1994
- >
1995
- <Text bold>{dialog.title}</Text>
1996
- <EditableText
1997
- state={state}
1998
- width={Math.max(10, columns - 6)}
1999
- prefix="› "
2000
- mask={dialog.mask}
2001
- placeholder={dialog.placeholder}
2002
- active
2003
- />
2004
- <Text dimColor>enter confirm · esc cancel</Text>
2005
- </Box>
1961
+ return h(
1962
+ Box,
1963
+ { flexDirection: "column", borderStyle: "round", borderColor: "yellow", paddingX: 1, marginTop: 1 },
1964
+ h(Text, { bold: true }, dialog.title),
1965
+ h(EditableText, {
1966
+ state,
1967
+ width: Math.max(10, columns - 6),
1968
+ prefix: "› ",
1969
+ mask: dialog.mask,
1970
+ placeholder: dialog.placeholder,
1971
+ active: true,
1972
+ }),
1973
+ h(Text, { dimColor: true }, "enter confirm · esc cancel"),
2006
1974
  );
2007
1975
  }