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