@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,13 +1,13 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
1
  // 终端界面(Ink):全屏(备用屏幕缓冲区)分三块——顶部标题(版本、模型、目录),中间是对话,
3
2
  // 自己滚动(滚轮、PgUp/PgDn),底部固定显示运行状态、排队的消息、输入框(或对话框)和状态栏。
4
3
  // 运行中也能输入:提交的内容由宿主决定立即执行还是排队。
4
+ //
5
+ // 不用 JSX:插件以 .ts 源码加载,Node 的类型剥离不处理 .tsx,所以组件用 createElement(h)写。
5
6
  import { writeSync } from "node:fs";
6
- import { Box, render, Text, useBoxMetrics, useCursor, useInput, usePaste, useWindowSize, } from "ink";
7
- import { createContext, useContext, useEffect, useReducer, useRef, useState, useSyncExternalStore, } from "react";
7
+ import { Box, render, Text, useBoxMetrics, useCursor, useInput, usePaste, useWindowSize, createContext, createElement as h, useContext, useEffect, useReducer, useRef, useState, useSyncExternalStore, } from "./vendor.js";
8
8
  import stringWidth from "string-width";
9
9
  import wrapAnsi from "wrap-ansi";
10
- import { mentionAt, mentionText, rankPaths } from "../mentions.js";
10
+ import { mentionAt, mentionText, rankPaths } from "./mentions.js";
11
11
  import { charWidth, edit, empty, layout, moveRow, offsetAt } from "./editor.js";
12
12
  import { expandTabs, markdownStream } from "./markdown.js";
13
13
  import { dim, } from "./screen.js";
@@ -242,7 +242,7 @@ class Store {
242
242
  this.#wrapped = [];
243
243
  this.#owners = [];
244
244
  this.#named.clear();
245
- this.update({ version: this.state.version + 1, live: undefined, progress: [], scroll: 0 }, true);
245
+ this.update({ version: this.state.version + 1, live: undefined, progress: [], scroll: 0, hint: undefined }, true);
246
246
  }
247
247
  /** 展开或收起最后一个可折叠的项(Ctrl+O);start、view 同 toggle */
248
248
  toggleLatest(start, view) {
@@ -359,7 +359,16 @@ export function tuiScreen(opts) {
359
359
  // 切到备用屏幕后光标还停在原来的位置(不少终端不会自动归位),Ink 从那里往下画第一帧会让屏幕滚动,
360
360
  // 之后每帧只重写变化的行,整个界面就错位了。所以先自己切过去、清屏、把光标移到左上角
361
361
  stdout.write("\x1b[?1049h\x1b[2J\x1b[H");
362
- const instance = render(_jsx(App, { store: store, copy: (text) => stdout.write(osc52(text)), version: opts.version, commands: opts.commands, handlers: opts.handlers, history: opts.history ?? [], draft: draft }), {
362
+ const commands = opts.commands;
363
+ const instance = render(h(App, {
364
+ store,
365
+ copy: (text) => void stdout.write(osc52(text)),
366
+ version: opts.version,
367
+ commands: typeof commands === "function" ? commands : () => commands,
368
+ handlers: opts.handlers,
369
+ history: opts.history ?? [],
370
+ draft,
371
+ }), {
363
372
  exitOnCtrlC: false,
364
373
  alternateScreen: true,
365
374
  // 全屏每帧只重写变化的行
@@ -461,6 +470,7 @@ export function tuiScreen(opts) {
461
470
  const value = text.replace(/\r\n?/g, "\n");
462
471
  draft.current?.apply(() => ({ value, cursor: value.length }));
463
472
  },
473
+ hint: (text) => store.update({ hint: text ? text.replace(/\r\n?/g, "\n") : undefined }),
464
474
  },
465
475
  select: (title, choices, o) => {
466
476
  if (longBusy())
@@ -651,10 +661,16 @@ function App({ store, copy, version, commands, handlers, history, draft, }) {
651
661
  copiedTimer.current = setTimeout(() => setCopied(undefined), COPIED_MS);
652
662
  };
653
663
  // Ink 增量渲染只用相对光标移动,第一帧起点一旦偏了(启动时终端尺寸还没稳定、窗口缩放、别的输出插进来),
654
- // 之后每帧都会画错行。启动后、尺寸变化后和按 Ctrl+L 时让一帧比终端高,Ink 会清屏从左上角整帧重画(包在同步输出里),下一帧再恢复
664
+ // 之后每帧都会画错行。尺寸变化后和按 Ctrl+L 时让一帧比终端高,Ink 会清屏从左上角整帧重画(包在同步输出里),下一帧再恢复。
665
+ // 启动时不重画:第一帧之前已经清屏、光标在左上角;这两次清屏在不支持同步输出的终端上(Windows 上常见)看得出闪一下
655
666
  const [redraws, setRedraws] = useState(0);
656
667
  const [repaint, setRepaint] = useState(false);
668
+ const mounted = useRef(false);
657
669
  useEffect(() => {
670
+ if (!mounted.current) {
671
+ mounted.current = true;
672
+ return;
673
+ }
658
674
  const t = setTimeout(() => setRepaint(true), 100);
659
675
  return () => clearTimeout(t);
660
676
  }, [columns, rows, redraws]);
@@ -726,10 +742,44 @@ function App({ store, copy, version, commands, handlers, history, draft, }) {
726
742
  // 总高度要比终端少一行,否则 Ink 认为输出占满了屏幕,每帧清屏重画。
727
743
  // 重画那一帧上下各垫一行空白:终端把顶上那行滚出去后,看到的和平时逐行一样,所以不会闪。
728
744
  // 只做纵向裁剪:每行都已按宽度折好或截断,横向裁剪会让 Ink 每帧对每一行再切一遍 ANSI 字符串
729
- return (_jsx(SelectionContext.Provider, { value: selectionApi, children: _jsx(Box, { flexDirection: "column", width: columns, height: repaint ? rows + 1 : Math.max(1, rows - 1), paddingY: repaint ? 1 : 0, overflowY: "hidden", children: _jsxs(Box, { flexDirection: "column", flexGrow: 1, overflowY: "hidden", children: [_jsx(Header, { status: state.status, version: version, compact: rows < COMPACT_ROWS }), _jsxs(Box, { ref: ref, flexDirection: "column", flexGrow: 1, flexShrink: 1, flexBasis: 0, overflowY: "hidden", paddingX: 1, children: [shown.map((l, i) => {
730
- const cols = selection && selectedCols(selection, start + i);
731
- return (_jsx(Text, { wrap: "truncate-end", children: cols ? highlight(l || " ", ...cols) : l || " " }, i));
732
- }), scrolled ? (_jsx(Text, { dimColor: true, wrap: "truncate-end", children: `── ↓ ${scroll} more lines · wheel / PgDn to scroll · ctrl+end to jump to the bottom ──` })) : null] }), _jsxs(Box, { flexDirection: "column", flexShrink: 0, children: [state.busy && !dialog ? (_jsx(Spinner, { label: state.busy.label, since: state.busy.since })) : null, state.queued.map((q, i) => (_jsxs(Text, { dimColor: true, wrap: "truncate-end", children: [" ↳ queued: ", q.replace(/\s+/g, " ")] }, i))), dialog ? (dialog.kind === "select" ? (_jsx(SelectDialog, { dialog: dialog }, dialogKey(dialog))) : (_jsx(InputDialog, { dialog: dialog }, dialogKey(dialog)))) : null, _jsx(Prompt, { commands: commands, handlers: handlers, history: history, bridge: draft, busy: Boolean(state.busy), active: !dialog, onSubmit: () => store.scrollBy(-max, max), flash: copied }), _jsx(StatusBar, { status: state.status, width: Math.max(10, columns - 2) })] })] }) }) }));
745
+ return h(SelectionContext.Provider, { value: selectionApi }, h(Box, {
746
+ flexDirection: "column",
747
+ width: columns,
748
+ height: repaint ? rows + 1 : Math.max(1, rows - 1),
749
+ paddingY: repaint ? 1 : 0,
750
+ overflowY: "hidden",
751
+ },
752
+ // 垫的空白放在外层:里面这层在重画那一帧和平时一样高,对话区的 top(相对父节点)不变,点击换算的行号不会差一行
753
+ h(Box, { flexDirection: "column", flexGrow: 1, overflowY: "hidden" }, h(Header, { status: state.status, version, compact: rows < COMPACT_ROWS }), h(Box, {
754
+ ref,
755
+ flexDirection: "column",
756
+ flexGrow: 1,
757
+ flexShrink: 1,
758
+ flexBasis: 0,
759
+ overflowY: "hidden",
760
+ paddingX: 1,
761
+ }, shown.map((l, i) => {
762
+ const cols = selection && selectedCols(selection, start + i);
763
+ return h(Text, { key: i, wrap: "truncate-end" }, cols ? highlight(l || " ", ...cols) : l || " ");
764
+ }), scrolled
765
+ ? h(Text, { dimColor: true, wrap: "truncate-end" }, `── ↓ ${scroll} more lines · wheel / PgDn to scroll · ctrl+end to jump to the bottom ──`)
766
+ : null), h(Box, { flexDirection: "column", flexShrink: 0 }, state.busy && !dialog ? h(Spinner, { label: state.busy.label, since: state.busy.since }) : null, state.queued.map((q, i) => h(Text, { key: i, dimColor: true, wrap: "truncate-end" }, " ↳ queued: ", q.replace(/\s+/g, " "))), dialog
767
+ ? dialog.kind === "select"
768
+ ? h(SelectDialog, { key: dialogKey(dialog), dialog })
769
+ : h(InputDialog, { key: dialogKey(dialog), dialog })
770
+ : null, h(Prompt, {
771
+ commands,
772
+ handlers,
773
+ history,
774
+ bridge: draft,
775
+ hint: state.hint,
776
+ onHintDone: () => store.update({ hint: undefined }),
777
+ busy: Boolean(state.busy),
778
+ queued: state.queued.length > 0,
779
+ active: !dialog,
780
+ onSubmit: () => store.scrollBy(-max, max),
781
+ flash: copied,
782
+ }), h(StatusBar, { status: state.status, width: Math.max(10, columns - 2) })))));
733
783
  }
734
784
  const JADE = "#00a86b";
735
785
  const SHINE = "#b6f2d4";
@@ -738,13 +788,21 @@ const SHINE = "#b6f2d4";
738
788
  * 每个字符上下两个像素;眼睛是玉上挖空的两格,左上角一点高光让它看起来像玉
739
789
  */
740
790
  function Bot() {
741
- return (_jsxs(Box, { flexDirection: "column", flexShrink: 0, marginRight: 2, children: [_jsxs(Text, { color: JADE, children: [" ▄", _jsx(Text, { color: SHINE, backgroundColor: JADE, children: "\u2584" }), "████▄"] }), _jsx(Text, { color: JADE, children: "\u2588\u2588 \u2588\u2588\u2588 \u2588\u2588" }), _jsx(Text, { color: JADE, children: "\u2580\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2580" })] }));
791
+ return h(Box, { flexDirection: "column", flexShrink: 0, marginRight: 2 }, h(Text, { color: JADE }, " ▄", h(Text, { color: SHINE, backgroundColor: JADE }, "▄"), "████▄"), h(Text, { color: JADE }, "██ ███ ██"), h(Text, { color: JADE }, "▀███████▀"));
742
792
  }
743
793
  function Header({ status, version, compact, }) {
744
794
  const { columns } = useScreenSize();
795
+ // 模型 · 目录 (分支)
796
+ const where = [
797
+ h(Text, { key: "model", color: "cyan" }, status.model),
798
+ h(Text, { key: "sep", dimColor: true }, " · "),
799
+ h(Text, { key: "cwd" }, status.cwd),
800
+ status.branch ? h(Text, { key: "branch", color: "magenta" }, ` (${status.branch})`) : null,
801
+ ];
802
+ const name = h(Text, { key: "name", color: "cyan", bold: true }, "jade");
745
803
  if (compact)
746
- return (_jsx(Box, { flexShrink: 0, paddingX: 1, children: _jsxs(Text, { wrap: "truncate-end", children: [_jsx(Text, { color: "cyan", bold: true, children: "jade" }), _jsx(Text, { dimColor: true, children: " \u00B7 " }), _jsx(Text, { color: "cyan", children: status.model }), _jsx(Text, { dimColor: true, children: " \u00B7 " }), _jsx(Text, { children: status.cwd }), status.branch ? (_jsxs(Text, { color: "magenta", children: [" (", status.branch, ")"] })) : null] }) }));
747
- return (_jsxs(Box, { flexShrink: 0, borderStyle: "round", borderColor: "cyan", paddingX: 1, children: [columns >= 50 ? _jsx(Bot, {}) : null, _jsxs(Box, { flexDirection: "column", flexGrow: 1, flexShrink: 1, children: [_jsxs(Text, { wrap: "truncate-end", children: [_jsx(Text, { color: "cyan", bold: true, children: "jade" }), _jsxs(Text, { dimColor: true, children: [" v", version] }), status.session ? (_jsx(Text, { dimColor: true, children: ` · session ${status.session}` })) : null] }), _jsxs(Text, { wrap: "truncate-end", children: [_jsx(Text, { color: "cyan", children: status.model }), _jsx(Text, { dimColor: true, children: " \u00B7 " }), _jsx(Text, { children: status.cwd }), status.branch ? (_jsxs(Text, { color: "magenta", children: [" (", status.branch, ")"] })) : null] }), _jsx(Text, { dimColor: true, wrap: "truncate-end", children: "/help for commands \u00B7 @ to attach files" })] })] }));
804
+ return h(Box, { flexShrink: 0, paddingX: 1 }, h(Text, { wrap: "truncate-end" }, name, h(Text, { key: "dot", dimColor: true }, " · "), ...where));
805
+ return h(Box, { flexShrink: 0, borderStyle: "round", borderColor: "cyan", paddingX: 1 }, columns >= 50 ? h(Bot) : null, h(Box, { flexDirection: "column", flexGrow: 1, flexShrink: 1 }, h(Text, { wrap: "truncate-end" }, name, h(Text, { dimColor: true }, ` v${version}`), status.session ? h(Text, { dimColor: true }, ` · session ${status.session}`) : null), h(Text, { wrap: "truncate-end" }, ...where), h(Text, { dimColor: true, wrap: "truncate-end" }, "/help for commands · @ to attach files")));
748
806
  }
749
807
  const dialogIds = new WeakMap();
750
808
  let dialogCounter = 0;
@@ -758,7 +816,7 @@ const FRAMES = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "
758
816
  function Spinner({ label, since }) {
759
817
  const now = Date.now();
760
818
  const seconds = Math.floor((now - since) / 1000);
761
- return (_jsx(Box, { marginTop: 1, children: _jsxs(Text, { wrap: "truncate-end", children: [_jsxs(Text, { color: "cyan", children: [FRAMES[Math.floor(now / 100) % FRAMES.length], " "] }), _jsxs(Text, { children: [label, "\u2026 "] }), _jsxs(Text, { dimColor: true, children: ["(", seconds, "s \u00B7 esc to interrupt)"] })] }) }));
819
+ return h(Box, { marginTop: 1 }, h(Text, { wrap: "truncate-end" }, h(Text, { color: "cyan" }, `${FRAMES[Math.floor(now / 100) % FRAMES.length]} `), h(Text, null, `${label}… `), h(Text, { dimColor: true }, `(${seconds}s · esc to interrupt)`)));
762
820
  }
763
821
  /** 在 width 列里放下尽量多的内容(保持原来的顺序) */
764
822
  export function fitSegments(segments, width) {
@@ -846,12 +904,12 @@ function StatusBar({ status, width }) {
846
904
  },
847
905
  ];
848
906
  const shown = fitSegments(segments, width);
849
- return (_jsx(Box, { paddingX: 1, children: _jsx(Text, { wrap: "truncate-end", children: shown.map((s, i) => (_jsxs(Text, { children: [i ? _jsx(Text, { dimColor: true, children: " \u00B7 " }) : null, _jsx(Text, { color: s.color, dimColor: s.dim, children: s.text })] }, i))) }) }));
907
+ return h(Box, { paddingX: 1 }, h(Text, { wrap: "truncate-end" }, shown.map((s, i) => h(Text, { key: i }, i ? h(Text, { dimColor: true }, " · ") : null, h(Text, { color: s.color, dimColor: s.dim }, s.text)))));
850
908
  }
851
909
  /** 一行提示:按宽度选第一个放得下的写法,都放不下时用最后一个并截断 */
852
910
  function Hint({ variants, width }) {
853
911
  const text = variants.find((v) => stringWidth(v) <= width) ?? variants.at(-1);
854
- return (_jsx(Text, { dimColor: true, wrap: "truncate-end", children: text }));
912
+ return h(Text, { dimColor: true, wrap: "truncate-end" }, text);
855
913
  }
856
914
  const tokens = (n) => n >= 1_000_000
857
915
  ? `${(n / 1_000_000).toFixed(n >= 10_000_000 ? 0 : 1)}M`
@@ -890,6 +948,10 @@ function editKey(s, input, key) {
890
948
  return edit.del(s);
891
949
  if (key.ctrl && input === "w")
892
950
  return edit.deleteWord(s);
951
+ if (key.meta && !key.ctrl && input === "f")
952
+ return edit.wordRight(s);
953
+ if (key.meta && !key.ctrl && input === "b")
954
+ return edit.wordLeft(s);
893
955
  if (key.ctrl && input === "u")
894
956
  return edit.killBefore(s);
895
957
  if (key.ctrl && input === "k")
@@ -948,11 +1010,9 @@ function EditableText({ state, width, prefix, mask, placeholder, active, maxRows
948
1010
  if (now.x !== at.x || now.y !== at.y)
949
1011
  recheck();
950
1012
  });
951
- return (_jsxs(Box, { ref: ref, flexDirection: "column", children: [active ? _jsx(CursorAt, { position: position }) : null, state.value === "" && placeholder ? (_jsxs(Text, { wrap: "truncate-end", children: [_jsx(Text, { color: "cyan", children: prefix }), _jsx(Text, { dimColor: true, children: placeholder })] })) : (rows.map((r, i) => (_jsxs(Text, { wrap: "truncate-end", children: [_jsx(Text, { color: "cyan", children: first + i === 0
952
- ? prefix
953
- : i === 0
954
- ? "↑".padEnd(prefix.length)
955
- : " ".repeat(prefix.length) }), r] }, first + i))))] }));
1013
+ return h(Box, { ref, flexDirection: "column" }, active ? h(CursorAt, { position }) : null, state.value === "" && placeholder
1014
+ ? h(Text, { wrap: "truncate-end" }, h(Text, { color: "cyan" }, prefix), h(Text, { dimColor: true }, placeholder))
1015
+ : rows.map((r, i) => h(Text, { key: first + i, wrap: "truncate-end" }, h(Text, { color: "cyan" }, first + i === 0 ? prefix : i === 0 ? "↑".padEnd(prefix.length) : " ".repeat(prefix.length)), r)));
956
1016
  }
957
1017
  /**
958
1018
  * 终端光标只有一个,每个 useCursor 每次提交都会设一遍。没有焦点的输入框(弹出输入框时下面的主输入框)
@@ -973,7 +1033,7 @@ function origin(node) {
973
1033
  }
974
1034
  return { x, y };
975
1035
  }
976
- function Prompt({ commands, handlers, history: initial, bridge, busy, active, onSubmit, flash, }) {
1036
+ function Prompt({ commands, handlers, history: initial, bridge, hint, onHintDone, busy, queued, active, onSubmit, flash, }) {
977
1037
  const selection = useContext(SelectionContext);
978
1038
  const [current, setState] = useLive(empty);
979
1039
  const [getSelected, setSelected] = useLive(0);
@@ -999,7 +1059,7 @@ function Prompt({ commands, handlers, history: initial, bridge, busy, active, on
999
1059
  // Ctrl+R 搜索历史:结果新的在前,index 是选中的那条
1000
1060
  const [getSearch, setSearch] = useLive(undefined);
1001
1061
  const usageOf = (c) => `/${c.name}${c.args ? ` ${c.args}` : ""}`;
1002
- const column = Math.max(...commands.map((c) => usageOf(c).length)) + 2;
1062
+ const column = Math.max(...commands().map((c) => usageOf(c).length)) + 2;
1003
1063
  /** 由最新的输入算出补全菜单和搜索结果;渲染和按键处理都用它 */
1004
1064
  const derive = () => {
1005
1065
  const state = current();
@@ -1011,7 +1071,7 @@ function Prompt({ commands, handlers, history: initial, bridge, busy, active, on
1011
1071
  history.current[history.current.length - 1 - browsing.current];
1012
1072
  const naming = !recalled && state.value.startsWith("/") && !/\s/.test(state.value);
1013
1073
  const matches = naming
1014
- ? commands.filter((c) => `/${c.name}`.startsWith(state.value))
1074
+ ? commands().filter((c) => `/${c.name}`.startsWith(state.value))
1015
1075
  : [];
1016
1076
  const pick = matches[Math.min(selected, matches.length - 1)];
1017
1077
  // @ 引用:光标处正在输入的路径和补全候选
@@ -1067,7 +1127,12 @@ function Prompt({ commands, handlers, history: initial, bridge, busy, active, on
1067
1127
  const first = around(hit, results.length, menuRows);
1068
1128
  const firstMatch = around(Math.max(0, matches.indexOf(pick)), matches.length, menuRows);
1069
1129
  const firstFound = around(Math.max(0, found.indexOf(file)), found.length, menuRows);
1130
+ /** 提示只在空闲、输入框为空、没有在搜索历史时显示,也只有这时能接受 */
1131
+ const hinting = () => hint !== undefined && !busy && current().value === "" && !getSearch();
1070
1132
  const set = (s) => {
1133
+ // 用户开始打字(或者插件改了输入框):提示作废
1134
+ if (s.value && hint !== undefined)
1135
+ onHintDone();
1071
1136
  setState(s);
1072
1137
  setSelected(0);
1073
1138
  setNotice(undefined);
@@ -1222,6 +1287,12 @@ function Prompt({ commands, handlers, history: initial, bridge, busy, active, on
1222
1287
  return complete(file);
1223
1288
  return submit(state.value.trim());
1224
1289
  }
1290
+ // Tab 或 →:把提示变成输入框里的文字,接着可以改
1291
+ if (((key.tab && !key.shift) || key.rightArrow) && hinting()) {
1292
+ onHintDone();
1293
+ browsing.current = -1;
1294
+ return set({ value: hint, cursor: hint.length });
1295
+ }
1225
1296
  if (key.tab && key.shift)
1226
1297
  return handlers.cycleMode?.();
1227
1298
  if (key.tab) {
@@ -1243,6 +1314,11 @@ function Prompt({ commands, handlers, history: initial, bridge, busy, active, on
1243
1314
  const up = moveRow(state, textWidth, -1);
1244
1315
  if (up)
1245
1316
  return setState(up);
1317
+ // 先取回排队的消息,取完了再翻历史
1318
+ if (handlers.unqueue?.()) {
1319
+ browsing.current = -1;
1320
+ return;
1321
+ }
1246
1322
  if (browsing.current + 1 < history.current.length) {
1247
1323
  if (browsing.current === -1)
1248
1324
  draft.current = state.value;
@@ -1269,31 +1345,75 @@ function Prompt({ commands, handlers, history: initial, bridge, busy, active, on
1269
1345
  set(next);
1270
1346
  }, { isActive: active });
1271
1347
  // 对话框打开时隐藏但不卸载,输入到一半的内容和历史都保留
1272
- return (_jsxs(Box, { flexDirection: "column", marginTop: 1, display: active ? "flex" : "none", children: [_jsx(Box, { borderStyle: "round", borderColor: busy ? "gray" : "cyan", paddingX: 1, children: search ? (_jsx(EditableText, { state: { value: search.query, cursor: search.query.length }, width: Math.max(10, columns - 5), prefix: "search history\u203A ", placeholder: "type to filter", active: active, maxRows: inputRows })) : (_jsx(EditableText, { state: state, width: Math.max(10, columns - 5), prefix: "\u203A ", placeholder: busy
1348
+ return h(Box, { flexDirection: "column", marginTop: 1, display: active ? "flex" : "none" }, h(Box, { borderStyle: "round", borderColor: busy ? "gray" : "cyan", paddingX: 1 }, search
1349
+ ? h(EditableText, {
1350
+ state: { value: search.query, cursor: search.query.length },
1351
+ width: Math.max(10, columns - 5),
1352
+ prefix: "search history› ",
1353
+ placeholder: "type to filter",
1354
+ active,
1355
+ maxRows: inputRows,
1356
+ })
1357
+ : h(EditableText, {
1358
+ state,
1359
+ width: Math.max(10, columns - 5),
1360
+ prefix: "› ",
1361
+ placeholder: hinting()
1362
+ ? hintLine(hint)
1363
+ : queued
1364
+ ? "↑ to edit queued messages · esc to interrupt"
1365
+ : busy
1273
1366
  ? "Type to queue a message · esc to interrupt"
1274
1367
  : columns >= 70
1275
1368
  ? "Message jade · / commands · @ files · ↑ or ctrl+r for history"
1276
- : "Message jade · / commands · @ files", active: active, maxRows: inputRows, place: place })) }), search ? (_jsxs(Box, { flexDirection: "column", paddingX: 2, children: [results.length ? (results.slice(first, first + menuRows).map((h, i) => {
1277
- const on = first + i === hit;
1278
- return (_jsxs(Text, { wrap: "truncate-end", color: on ? "cyan" : undefined, bold: on, children: [on ? "❯ " : " ", h.replace(/\s*\n\s*/g, " ⏎ ")] }, first + i));
1279
- })) : (_jsx(Text, { dimColor: true, children: " no match" })), _jsx(Hint, { width: hintWidth, variants: [
1280
- " ↑↓ or ctrl+r select · enter/tab put in the input · esc cancel",
1281
- " ↑↓ select · enter use · esc cancel",
1282
- ] })] })) : matches.length ? (_jsxs(Box, { flexDirection: "column", paddingX: 2, children: [matches.slice(firstMatch, firstMatch + menuRows).map((c) => {
1283
- const on = c === pick;
1284
- return (_jsxs(Text, { wrap: "truncate-end", children: [_jsxs(Text, { color: on ? "cyan" : undefined, bold: on, children: [on ? "❯ " : " ", usageOf(c).padEnd(column)] }), _jsx(Text, { dimColor: true, children: c.about })] }, c.name));
1285
- }), _jsx(Hint, { width: hintWidth, variants: [
1286
- ` ↑↓ select · enter run · tab complete${matches.length > menuRows ? ` · ${matches.length} commands` : ""}`,
1287
- " ↑↓ · enter run · tab complete",
1288
- ] })] })) : found.length ? (_jsxs(Box, { flexDirection: "column", paddingX: 2, children: [found.slice(firstFound, firstFound + menuRows).map((p) => {
1289
- const on = p === file;
1290
- return (_jsxs(Text, { wrap: "truncate-middle", color: on ? "cyan" : p.endsWith("/") ? "blue" : undefined, bold: on, children: [on ? "❯ " : " ", p] }, p));
1291
- }), _jsx(Hint, { width: hintWidth, variants: [
1292
- " ↑↓ select · enter/tab insert the path · the file's content is sent with the message",
1293
- " ↑↓ select · enter/tab insert the path",
1294
- " ↑↓ · enter insert",
1295
- ] })] })) : notice ? (_jsxs(Text, { color: "yellow", children: [" ", notice] })) : null, flash ? (_jsx(Box, { position: "absolute", top: 0, right: 2, children: _jsxs(Text, { color: "green", children: [" ", flash, " "] }) })) : null] }));
1369
+ : "Message jade · / commands · @ files",
1370
+ active,
1371
+ maxRows: inputRows,
1372
+ place,
1373
+ })), search
1374
+ ? h(Box, { flexDirection: "column", paddingX: 2 }, results.length
1375
+ ? results.slice(first, first + menuRows).map((item, i) => {
1376
+ const on = first + i === hit;
1377
+ return h(Text, { key: first + i, wrap: "truncate-end", color: on ? "cyan" : undefined, bold: on }, on ? "❯ " : " ", item.replace(/\s*\n\s*/g, " ⏎ "));
1378
+ })
1379
+ : h(Text, { dimColor: true }, " no match"), h(Hint, {
1380
+ width: hintWidth,
1381
+ variants: [" ↑↓ or ctrl+r select · enter/tab put in the input · esc cancel", " ↑↓ select · enter use · esc cancel"],
1382
+ }))
1383
+ : matches.length
1384
+ ? h(Box, { flexDirection: "column", paddingX: 2 }, matches.slice(firstMatch, firstMatch + menuRows).map((c) => {
1385
+ const on = c === pick;
1386
+ return h(Text, { key: c.name, wrap: "truncate-end" }, h(Text, { color: on ? "cyan" : undefined, bold: on }, on ? "❯ " : " ", usageOf(c).padEnd(column)), h(Text, { dimColor: true }, c.about));
1387
+ }), h(Hint, {
1388
+ width: hintWidth,
1389
+ variants: [
1390
+ ` ↑↓ select · enter run · tab complete${matches.length > menuRows ? ` · ${matches.length} commands` : ""}`,
1391
+ " ↑↓ · enter run · tab complete",
1392
+ ],
1393
+ }))
1394
+ : found.length
1395
+ ? h(Box, { flexDirection: "column", paddingX: 2 }, found.slice(firstFound, firstFound + menuRows).map((p) => {
1396
+ const on = p === file;
1397
+ return h(Text, { key: p, wrap: "truncate-middle", color: on ? "cyan" : p.endsWith("/") ? "blue" : undefined, bold: on }, on ? "❯ " : " ", p);
1398
+ }), h(Hint, {
1399
+ width: hintWidth,
1400
+ variants: [
1401
+ " ↑↓ select · enter/tab insert the path · the file's content is sent with the message",
1402
+ " ↑↓ select · enter/tab insert the path",
1403
+ " ↑↓ · enter insert",
1404
+ ],
1405
+ }))
1406
+ : notice
1407
+ ? h(Text, { color: "yellow" }, ` ${notice}`)
1408
+ : null,
1409
+ // 压在输入框上边框的右边,不占行,出现和消失时下面的内容不跳
1410
+ flash ? h(Box, { position: "absolute", top: 0, right: 2 }, h(Text, { color: "green" }, ` ${flash} `)) : null);
1296
1411
  }
1412
+ /** 提示在输入框里只显示第一行,后面还有时加 … */
1413
+ const hintLine = (hint) => {
1414
+ const [first, ...rest] = hint.split("\n");
1415
+ return `${first}${rest.length ? " …" : ""}`;
1416
+ };
1297
1417
  /** @ 补全最多显示几项 */
1298
1418
  const MENTION_ROWS = 8;
1299
1419
  /** 长列表只显示 size 项时,为了让第 selected 项在中间附近,从第几项开始显示 */
@@ -1375,12 +1495,17 @@ function SelectDialog({ dialog, }) {
1375
1495
  });
1376
1496
  // 选项多时只显示选中项附近的一段
1377
1497
  const start = around(selected, n, visible);
1378
- return (_jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: "yellow", paddingX: 1, marginTop: 1, children: [_jsx(Text, { bold: true, wrap: "truncate-end", children: dialog.title }), body.map((l, i) => (_jsx(Text, { wrap: "truncate-end", children: l || " " }, i))), filtering ? (_jsxs(Text, { wrap: "truncate-end", children: [_jsx(Text, { color: "cyan", children: "filter\u203A " }), query ? (_jsx(Text, { children: query })) : (_jsxs(Text, { dimColor: true, children: ["type to filter ", dialog.choices.length, " items"] }))] })) : null, _jsxs(Box, { flexDirection: "column", marginTop: filtering ? 0 : 1, children: [start > 0 ? _jsxs(Text, { dimColor: true, children: [" \u2191 ", start, " more"] }) : null, n === 0 ? _jsx(Text, { dimColor: true, children: " no match" }) : null, items.slice(start, start + visible).map(({ c, i }, j) => {
1379
- const on = start + j === selected;
1380
- return (_jsxs(Text, { wrap: "truncate-end", children: [_jsxs(Text, { color: on ? "cyan" : undefined, bold: on, children: [on ? "❯ " : " ", filtering ? "" : `${i + 1}. `, c.label] }), c.hint ? _jsxs(Text, { dimColor: true, children: [" ", c.hint] }) : null] }, i));
1381
- }), start + visible < n ? (_jsxs(Text, { dimColor: true, children: [" \u2193 ", n - start - visible, " more"] })) : null] }), _jsx(Hint, { width: Math.max(10, columns - 4), variants: filtering
1382
- ? ["↑↓ select · type to filter · enter confirm · esc clear/cancel", "↑↓ · enter · esc"]
1383
- : ["↑↓ select · enter confirm · esc cancel", "↑↓ · enter · esc"] })] }));
1498
+ return h(Box, { flexDirection: "column", borderStyle: "round", borderColor: "yellow", paddingX: 1, marginTop: 1 }, h(Text, { bold: true, wrap: "truncate-end" }, dialog.title), body.map((l, i) => h(Text, { key: i, wrap: "truncate-end" }, l || " ")), filtering
1499
+ ? h(Text, { wrap: "truncate-end" }, h(Text, { color: "cyan" }, "filter› "), query ? h(Text, null, query) : h(Text, { dimColor: true }, `type to filter ${dialog.choices.length} items`))
1500
+ : null, h(Box, { flexDirection: "column", marginTop: filtering ? 0 : 1 }, start > 0 ? h(Text, { dimColor: true }, ` ↑ ${start} more`) : null, n === 0 ? h(Text, { dimColor: true }, " no match") : null, items.slice(start, start + visible).map(({ c, i }, j) => {
1501
+ const on = start + j === selected;
1502
+ return h(Text, { key: i, wrap: "truncate-end" }, h(Text, { color: on ? "cyan" : undefined, bold: on }, on ? "❯ " : " ", filtering ? "" : `${i + 1}. `, c.label), c.hint ? h(Text, { dimColor: true }, ` ${c.hint}`) : null);
1503
+ }), start + visible < n ? h(Text, { dimColor: true }, ` ↓ ${n - start - visible} more`) : null), h(Hint, {
1504
+ width: Math.max(10, columns - 4),
1505
+ variants: filtering
1506
+ ? ["↑↓ select · type to filter · enter confirm · esc clear/cancel", "↑↓ · enter · esc"]
1507
+ : ["↑↓ select · enter confirm · esc cancel", "↑↓ · enter · esc"],
1508
+ }));
1384
1509
  }
1385
1510
  function InputDialog({ dialog, }) {
1386
1511
  const selection = useContext(SelectionContext);
@@ -1404,6 +1529,12 @@ function InputDialog({ dialog, }) {
1404
1529
  if (next)
1405
1530
  setState(next);
1406
1531
  });
1407
- return (_jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: "yellow", paddingX: 1, marginTop: 1, children: [_jsx(Text, { bold: true, children: dialog.title }), _jsx(EditableText, { state: state, width: Math.max(10, columns - 6), prefix: "\u203A ", mask: dialog.mask, placeholder: dialog.placeholder, active: true }), _jsx(Text, { dimColor: true, children: "enter confirm \u00B7 esc cancel" })] }));
1532
+ return h(Box, { flexDirection: "column", borderStyle: "round", borderColor: "yellow", paddingX: 1, marginTop: 1 }, h(Text, { bold: true }, dialog.title), h(EditableText, {
1533
+ state,
1534
+ width: Math.max(10, columns - 6),
1535
+ prefix: "› ",
1536
+ mask: dialog.mask,
1537
+ placeholder: dialog.placeholder,
1538
+ active: true,
1539
+ }), h(Text, { dimColor: true }, "enter confirm · esc cancel"));
1408
1540
  }
1409
- //# sourceMappingURL=tui.js.map