@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,13 +1,14 @@
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
7
  import { Box, render, Text, useBoxMetrics, useCursor, useInput, usePaste, useWindowSize, } from "ink";
7
- import { createContext, useContext, useEffect, useReducer, useRef, useState, useSyncExternalStore, } from "react";
8
+ import { createContext, createElement as h, useContext, useEffect, useReducer, useRef, useState, useSyncExternalStore, } from "react";
8
9
  import stringWidth from "string-width";
9
10
  import wrapAnsi from "wrap-ansi";
10
- import { mentionAt, mentionText, rankPaths } from "../mentions.js";
11
+ import { mentionAt, mentionText, rankPaths } from "./mentions.js";
11
12
  import { charWidth, edit, empty, layout, moveRow, offsetAt } from "./editor.js";
12
13
  import { expandTabs, markdownStream } from "./markdown.js";
13
14
  import { dim, } from "./screen.js";
@@ -242,7 +243,7 @@ class Store {
242
243
  this.#wrapped = [];
243
244
  this.#owners = [];
244
245
  this.#named.clear();
245
- this.update({ version: this.state.version + 1, live: undefined, progress: [], scroll: 0 }, true);
246
+ this.update({ version: this.state.version + 1, live: undefined, progress: [], scroll: 0, hint: undefined }, true);
246
247
  }
247
248
  /** 展开或收起最后一个可折叠的项(Ctrl+O);start、view 同 toggle */
248
249
  toggleLatest(start, view) {
@@ -359,7 +360,16 @@ export function tuiScreen(opts) {
359
360
  // 切到备用屏幕后光标还停在原来的位置(不少终端不会自动归位),Ink 从那里往下画第一帧会让屏幕滚动,
360
361
  // 之后每帧只重写变化的行,整个界面就错位了。所以先自己切过去、清屏、把光标移到左上角
361
362
  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 }), {
363
+ const commands = opts.commands;
364
+ const instance = render(h(App, {
365
+ store,
366
+ copy: (text) => void stdout.write(osc52(text)),
367
+ version: opts.version,
368
+ commands: typeof commands === "function" ? commands : () => commands,
369
+ handlers: opts.handlers,
370
+ history: opts.history ?? [],
371
+ draft,
372
+ }), {
363
373
  exitOnCtrlC: false,
364
374
  alternateScreen: true,
365
375
  // 全屏每帧只重写变化的行
@@ -461,6 +471,7 @@ export function tuiScreen(opts) {
461
471
  const value = text.replace(/\r\n?/g, "\n");
462
472
  draft.current?.apply(() => ({ value, cursor: value.length }));
463
473
  },
474
+ hint: (text) => store.update({ hint: text ? text.replace(/\r\n?/g, "\n") : undefined }),
464
475
  },
465
476
  select: (title, choices, o) => {
466
477
  if (longBusy())
@@ -651,10 +662,16 @@ function App({ store, copy, version, commands, handlers, history, draft, }) {
651
662
  copiedTimer.current = setTimeout(() => setCopied(undefined), COPIED_MS);
652
663
  };
653
664
  // Ink 增量渲染只用相对光标移动,第一帧起点一旦偏了(启动时终端尺寸还没稳定、窗口缩放、别的输出插进来),
654
- // 之后每帧都会画错行。启动后、尺寸变化后和按 Ctrl+L 时让一帧比终端高,Ink 会清屏从左上角整帧重画(包在同步输出里),下一帧再恢复
665
+ // 之后每帧都会画错行。尺寸变化后和按 Ctrl+L 时让一帧比终端高,Ink 会清屏从左上角整帧重画(包在同步输出里),下一帧再恢复。
666
+ // 启动时不重画:第一帧之前已经清屏、光标在左上角;这两次清屏在不支持同步输出的终端上(Windows 上常见)看得出闪一下
655
667
  const [redraws, setRedraws] = useState(0);
656
668
  const [repaint, setRepaint] = useState(false);
669
+ const mounted = useRef(false);
657
670
  useEffect(() => {
671
+ if (!mounted.current) {
672
+ mounted.current = true;
673
+ return;
674
+ }
658
675
  const t = setTimeout(() => setRepaint(true), 100);
659
676
  return () => clearTimeout(t);
660
677
  }, [columns, rows, redraws]);
@@ -726,10 +743,44 @@ function App({ store, copy, version, commands, handlers, history, draft, }) {
726
743
  // 总高度要比终端少一行,否则 Ink 认为输出占满了屏幕,每帧清屏重画。
727
744
  // 重画那一帧上下各垫一行空白:终端把顶上那行滚出去后,看到的和平时逐行一样,所以不会闪。
728
745
  // 只做纵向裁剪:每行都已按宽度折好或截断,横向裁剪会让 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) })] })] }) }) }));
746
+ return h(SelectionContext.Provider, { value: selectionApi }, h(Box, {
747
+ flexDirection: "column",
748
+ width: columns,
749
+ height: repaint ? rows + 1 : Math.max(1, rows - 1),
750
+ paddingY: repaint ? 1 : 0,
751
+ overflowY: "hidden",
752
+ },
753
+ // 垫的空白放在外层:里面这层在重画那一帧和平时一样高,对话区的 top(相对父节点)不变,点击换算的行号不会差一行
754
+ h(Box, { flexDirection: "column", flexGrow: 1, overflowY: "hidden" }, h(Header, { status: state.status, version, compact: rows < COMPACT_ROWS }), h(Box, {
755
+ ref,
756
+ flexDirection: "column",
757
+ flexGrow: 1,
758
+ flexShrink: 1,
759
+ flexBasis: 0,
760
+ overflowY: "hidden",
761
+ paddingX: 1,
762
+ }, shown.map((l, i) => {
763
+ const cols = selection && selectedCols(selection, start + i);
764
+ return h(Text, { key: i, wrap: "truncate-end" }, cols ? highlight(l || " ", ...cols) : l || " ");
765
+ }), scrolled
766
+ ? h(Text, { dimColor: true, wrap: "truncate-end" }, `── ↓ ${scroll} more lines · wheel / PgDn to scroll · ctrl+end to jump to the bottom ──`)
767
+ : 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
768
+ ? dialog.kind === "select"
769
+ ? h(SelectDialog, { key: dialogKey(dialog), dialog })
770
+ : h(InputDialog, { key: dialogKey(dialog), dialog })
771
+ : null, h(Prompt, {
772
+ commands,
773
+ handlers,
774
+ history,
775
+ bridge: draft,
776
+ hint: state.hint,
777
+ onHintDone: () => store.update({ hint: undefined }),
778
+ busy: Boolean(state.busy),
779
+ queued: state.queued.length > 0,
780
+ active: !dialog,
781
+ onSubmit: () => store.scrollBy(-max, max),
782
+ flash: copied,
783
+ }), h(StatusBar, { status: state.status, width: Math.max(10, columns - 2) })))));
733
784
  }
734
785
  const JADE = "#00a86b";
735
786
  const SHINE = "#b6f2d4";
@@ -738,13 +789,21 @@ const SHINE = "#b6f2d4";
738
789
  * 每个字符上下两个像素;眼睛是玉上挖空的两格,左上角一点高光让它看起来像玉
739
790
  */
740
791
  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" })] }));
792
+ 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
793
  }
743
794
  function Header({ status, version, compact, }) {
744
795
  const { columns } = useScreenSize();
796
+ // 模型 · 目录 (分支)
797
+ const where = [
798
+ h(Text, { key: "model", color: "cyan" }, status.model),
799
+ h(Text, { key: "sep", dimColor: true }, " · "),
800
+ h(Text, { key: "cwd" }, status.cwd),
801
+ status.branch ? h(Text, { key: "branch", color: "magenta" }, ` (${status.branch})`) : null,
802
+ ];
803
+ const name = h(Text, { key: "name", color: "cyan", bold: true }, "jade");
745
804
  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" })] })] }));
805
+ return h(Box, { flexShrink: 0, paddingX: 1 }, h(Text, { wrap: "truncate-end" }, name, h(Text, { key: "dot", dimColor: true }, " · "), ...where));
806
+ 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
807
  }
749
808
  const dialogIds = new WeakMap();
750
809
  let dialogCounter = 0;
@@ -758,7 +817,7 @@ const FRAMES = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "
758
817
  function Spinner({ label, since }) {
759
818
  const now = Date.now();
760
819
  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)"] })] }) }));
820
+ 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
821
  }
763
822
  /** 在 width 列里放下尽量多的内容(保持原来的顺序) */
764
823
  export function fitSegments(segments, width) {
@@ -846,12 +905,12 @@ function StatusBar({ status, width }) {
846
905
  },
847
906
  ];
848
907
  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))) }) }));
908
+ 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
909
  }
851
910
  /** 一行提示:按宽度选第一个放得下的写法,都放不下时用最后一个并截断 */
852
911
  function Hint({ variants, width }) {
853
912
  const text = variants.find((v) => stringWidth(v) <= width) ?? variants.at(-1);
854
- return (_jsx(Text, { dimColor: true, wrap: "truncate-end", children: text }));
913
+ return h(Text, { dimColor: true, wrap: "truncate-end" }, text);
855
914
  }
856
915
  const tokens = (n) => n >= 1_000_000
857
916
  ? `${(n / 1_000_000).toFixed(n >= 10_000_000 ? 0 : 1)}M`
@@ -890,6 +949,10 @@ function editKey(s, input, key) {
890
949
  return edit.del(s);
891
950
  if (key.ctrl && input === "w")
892
951
  return edit.deleteWord(s);
952
+ if (key.meta && !key.ctrl && input === "f")
953
+ return edit.wordRight(s);
954
+ if (key.meta && !key.ctrl && input === "b")
955
+ return edit.wordLeft(s);
893
956
  if (key.ctrl && input === "u")
894
957
  return edit.killBefore(s);
895
958
  if (key.ctrl && input === "k")
@@ -948,11 +1011,9 @@ function EditableText({ state, width, prefix, mask, placeholder, active, maxRows
948
1011
  if (now.x !== at.x || now.y !== at.y)
949
1012
  recheck();
950
1013
  });
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))))] }));
1014
+ return h(Box, { ref, flexDirection: "column" }, active ? h(CursorAt, { position }) : null, state.value === "" && placeholder
1015
+ ? h(Text, { wrap: "truncate-end" }, h(Text, { color: "cyan" }, prefix), h(Text, { dimColor: true }, placeholder))
1016
+ : 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
1017
  }
957
1018
  /**
958
1019
  * 终端光标只有一个,每个 useCursor 每次提交都会设一遍。没有焦点的输入框(弹出输入框时下面的主输入框)
@@ -973,7 +1034,7 @@ function origin(node) {
973
1034
  }
974
1035
  return { x, y };
975
1036
  }
976
- function Prompt({ commands, handlers, history: initial, bridge, busy, active, onSubmit, flash, }) {
1037
+ function Prompt({ commands, handlers, history: initial, bridge, hint, onHintDone, busy, queued, active, onSubmit, flash, }) {
977
1038
  const selection = useContext(SelectionContext);
978
1039
  const [current, setState] = useLive(empty);
979
1040
  const [getSelected, setSelected] = useLive(0);
@@ -999,7 +1060,7 @@ function Prompt({ commands, handlers, history: initial, bridge, busy, active, on
999
1060
  // Ctrl+R 搜索历史:结果新的在前,index 是选中的那条
1000
1061
  const [getSearch, setSearch] = useLive(undefined);
1001
1062
  const usageOf = (c) => `/${c.name}${c.args ? ` ${c.args}` : ""}`;
1002
- const column = Math.max(...commands.map((c) => usageOf(c).length)) + 2;
1063
+ const column = Math.max(...commands().map((c) => usageOf(c).length)) + 2;
1003
1064
  /** 由最新的输入算出补全菜单和搜索结果;渲染和按键处理都用它 */
1004
1065
  const derive = () => {
1005
1066
  const state = current();
@@ -1011,7 +1072,7 @@ function Prompt({ commands, handlers, history: initial, bridge, busy, active, on
1011
1072
  history.current[history.current.length - 1 - browsing.current];
1012
1073
  const naming = !recalled && state.value.startsWith("/") && !/\s/.test(state.value);
1013
1074
  const matches = naming
1014
- ? commands.filter((c) => `/${c.name}`.startsWith(state.value))
1075
+ ? commands().filter((c) => `/${c.name}`.startsWith(state.value))
1015
1076
  : [];
1016
1077
  const pick = matches[Math.min(selected, matches.length - 1)];
1017
1078
  // @ 引用:光标处正在输入的路径和补全候选
@@ -1067,7 +1128,12 @@ function Prompt({ commands, handlers, history: initial, bridge, busy, active, on
1067
1128
  const first = around(hit, results.length, menuRows);
1068
1129
  const firstMatch = around(Math.max(0, matches.indexOf(pick)), matches.length, menuRows);
1069
1130
  const firstFound = around(Math.max(0, found.indexOf(file)), found.length, menuRows);
1131
+ /** 提示只在空闲、输入框为空、没有在搜索历史时显示,也只有这时能接受 */
1132
+ const hinting = () => hint !== undefined && !busy && current().value === "" && !getSearch();
1070
1133
  const set = (s) => {
1134
+ // 用户开始打字(或者插件改了输入框):提示作废
1135
+ if (s.value && hint !== undefined)
1136
+ onHintDone();
1071
1137
  setState(s);
1072
1138
  setSelected(0);
1073
1139
  setNotice(undefined);
@@ -1222,6 +1288,12 @@ function Prompt({ commands, handlers, history: initial, bridge, busy, active, on
1222
1288
  return complete(file);
1223
1289
  return submit(state.value.trim());
1224
1290
  }
1291
+ // Tab 或 →:把提示变成输入框里的文字,接着可以改
1292
+ if (((key.tab && !key.shift) || key.rightArrow) && hinting()) {
1293
+ onHintDone();
1294
+ browsing.current = -1;
1295
+ return set({ value: hint, cursor: hint.length });
1296
+ }
1225
1297
  if (key.tab && key.shift)
1226
1298
  return handlers.cycleMode?.();
1227
1299
  if (key.tab) {
@@ -1243,6 +1315,11 @@ function Prompt({ commands, handlers, history: initial, bridge, busy, active, on
1243
1315
  const up = moveRow(state, textWidth, -1);
1244
1316
  if (up)
1245
1317
  return setState(up);
1318
+ // 先取回排队的消息,取完了再翻历史
1319
+ if (handlers.unqueue?.()) {
1320
+ browsing.current = -1;
1321
+ return;
1322
+ }
1246
1323
  if (browsing.current + 1 < history.current.length) {
1247
1324
  if (browsing.current === -1)
1248
1325
  draft.current = state.value;
@@ -1269,31 +1346,75 @@ function Prompt({ commands, handlers, history: initial, bridge, busy, active, on
1269
1346
  set(next);
1270
1347
  }, { isActive: active });
1271
1348
  // 对话框打开时隐藏但不卸载,输入到一半的内容和历史都保留
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
1349
+ return h(Box, { flexDirection: "column", marginTop: 1, display: active ? "flex" : "none" }, h(Box, { borderStyle: "round", borderColor: busy ? "gray" : "cyan", paddingX: 1 }, search
1350
+ ? h(EditableText, {
1351
+ state: { value: search.query, cursor: search.query.length },
1352
+ width: Math.max(10, columns - 5),
1353
+ prefix: "search history› ",
1354
+ placeholder: "type to filter",
1355
+ active,
1356
+ maxRows: inputRows,
1357
+ })
1358
+ : h(EditableText, {
1359
+ state,
1360
+ width: Math.max(10, columns - 5),
1361
+ prefix: "› ",
1362
+ placeholder: hinting()
1363
+ ? hintLine(hint)
1364
+ : queued
1365
+ ? "↑ to edit queued messages · esc to interrupt"
1366
+ : busy
1273
1367
  ? "Type to queue a message · esc to interrupt"
1274
1368
  : columns >= 70
1275
1369
  ? "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] }));
1370
+ : "Message jade · / commands · @ files",
1371
+ active,
1372
+ maxRows: inputRows,
1373
+ place,
1374
+ })), search
1375
+ ? h(Box, { flexDirection: "column", paddingX: 2 }, results.length
1376
+ ? results.slice(first, first + menuRows).map((item, i) => {
1377
+ const on = first + i === hit;
1378
+ return h(Text, { key: first + i, wrap: "truncate-end", color: on ? "cyan" : undefined, bold: on }, on ? "❯ " : " ", item.replace(/\s*\n\s*/g, " ⏎ "));
1379
+ })
1380
+ : h(Text, { dimColor: true }, " no match"), h(Hint, {
1381
+ width: hintWidth,
1382
+ variants: [" ↑↓ or ctrl+r select · enter/tab put in the input · esc cancel", " ↑↓ select · enter use · esc cancel"],
1383
+ }))
1384
+ : matches.length
1385
+ ? h(Box, { flexDirection: "column", paddingX: 2 }, matches.slice(firstMatch, firstMatch + menuRows).map((c) => {
1386
+ const on = c === pick;
1387
+ 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));
1388
+ }), h(Hint, {
1389
+ width: hintWidth,
1390
+ variants: [
1391
+ ` ↑↓ select · enter run · tab complete${matches.length > menuRows ? ` · ${matches.length} commands` : ""}`,
1392
+ " ↑↓ · enter run · tab complete",
1393
+ ],
1394
+ }))
1395
+ : found.length
1396
+ ? h(Box, { flexDirection: "column", paddingX: 2 }, found.slice(firstFound, firstFound + menuRows).map((p) => {
1397
+ const on = p === file;
1398
+ return h(Text, { key: p, wrap: "truncate-middle", color: on ? "cyan" : p.endsWith("/") ? "blue" : undefined, bold: on }, on ? "❯ " : " ", p);
1399
+ }), h(Hint, {
1400
+ width: hintWidth,
1401
+ variants: [
1402
+ " ↑↓ select · enter/tab insert the path · the file's content is sent with the message",
1403
+ " ↑↓ select · enter/tab insert the path",
1404
+ " ↑↓ · enter insert",
1405
+ ],
1406
+ }))
1407
+ : notice
1408
+ ? h(Text, { color: "yellow" }, ` ${notice}`)
1409
+ : null,
1410
+ // 压在输入框上边框的右边,不占行,出现和消失时下面的内容不跳
1411
+ flash ? h(Box, { position: "absolute", top: 0, right: 2 }, h(Text, { color: "green" }, ` ${flash} `)) : null);
1296
1412
  }
1413
+ /** 提示在输入框里只显示第一行,后面还有时加 … */
1414
+ const hintLine = (hint) => {
1415
+ const [first, ...rest] = hint.split("\n");
1416
+ return `${first}${rest.length ? " …" : ""}`;
1417
+ };
1297
1418
  /** @ 补全最多显示几项 */
1298
1419
  const MENTION_ROWS = 8;
1299
1420
  /** 长列表只显示 size 项时,为了让第 selected 项在中间附近,从第几项开始显示 */
@@ -1375,12 +1496,17 @@ function SelectDialog({ dialog, }) {
1375
1496
  });
1376
1497
  // 选项多时只显示选中项附近的一段
1377
1498
  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"] })] }));
1499
+ 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
1500
+ ? 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`))
1501
+ : 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) => {
1502
+ const on = start + j === selected;
1503
+ 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);
1504
+ }), start + visible < n ? h(Text, { dimColor: true }, ` ↓ ${n - start - visible} more`) : null), h(Hint, {
1505
+ width: Math.max(10, columns - 4),
1506
+ variants: filtering
1507
+ ? ["↑↓ select · type to filter · enter confirm · esc clear/cancel", "↑↓ · enter · esc"]
1508
+ : ["↑↓ select · enter confirm · esc cancel", "↑↓ · enter · esc"],
1509
+ }));
1384
1510
  }
1385
1511
  function InputDialog({ dialog, }) {
1386
1512
  const selection = useContext(SelectionContext);
@@ -1404,6 +1530,12 @@ function InputDialog({ dialog, }) {
1404
1530
  if (next)
1405
1531
  setState(next);
1406
1532
  });
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" })] }));
1533
+ return h(Box, { flexDirection: "column", borderStyle: "round", borderColor: "yellow", paddingX: 1, marginTop: 1 }, h(Text, { bold: true }, dialog.title), h(EditableText, {
1534
+ state,
1535
+ width: Math.max(10, columns - 6),
1536
+ prefix: "› ",
1537
+ mask: dialog.mask,
1538
+ placeholder: dialog.placeholder,
1539
+ active: true,
1540
+ }), h(Text, { dimColor: true }, "enter confirm · esc cancel"));
1408
1541
  }
1409
- //# sourceMappingURL=tui.js.map
@@ -1,17 +1,13 @@
1
- // 文件快照:write_file / edit_file 写入前保存原内容,宿主的 /undo 用它恢复。
1
+ // 文件快照:write_file / edit_file / multi_edit 执行前保存原内容,/undo 用它恢复。从旧 jade 的 tools/checkpoint.ts 移植。
2
2
  //
3
- // 快照放在 <dir>/<sessionId>/<toolUseId>.json,不进日志:文件可能很大,而撤销是宿主的操作,不影响插件决策。
4
- // 哪些修改已经撤销由宿主用 Runtime.record 记在日志里(UNDO_KEY),恢复会话后仍然有效。
3
+ // 快照放在 <dir>/<sessionId>/<toolUseId>.json,不进日志:文件可能很大,而撤销是用户的操作,不影响插件决策。
4
+ // 哪些修改已经撤销记在同一个目录的 undone.json 里(命令拿不到会话日志),恢复会话后仍然有效。
5
5
  import { createHash } from "node:crypto";
6
- import { appendFile, mkdir, readdir, readFile, rm, writeFile } from "node:fs/promises";
6
+ import { mkdir, readdir, readFile, rm, writeFile } from "node:fs/promises";
7
7
  import path from "node:path";
8
- /** derived 中保存已撤销的 toolUseId 的键 */
9
- export const UNDO_KEY = "jade/undo";
10
8
  export const sha256 = (s) => createHash("sha256").update(s).digest("hex");
11
9
  export class Checkpoints {
12
10
  #dir;
13
- /** 会话 → 文件 → markSeen 记下的 sha256;第一次用到时从 seen.jsonl 读入 */
14
- #seen = new Map();
15
11
  constructor(dir) {
16
12
  this.#dir = dir;
17
13
  }
@@ -33,7 +29,7 @@ export class Checkpoints {
33
29
  }
34
30
  const out = [];
35
31
  for (const n of names) {
36
- if (!n.endsWith(".json"))
32
+ if (!n.endsWith(".json") || n === UNDONE)
37
33
  continue;
38
34
  try {
39
35
  out.push(JSON.parse(await readFile(path.join(dir, n), "utf8")));
@@ -44,53 +40,23 @@ export class Checkpoints {
44
40
  }
45
41
  return out.sort((a, b) => b.at - a.at);
46
42
  }
47
- /**
48
- * 记下本会话读过或写过的文件当时内容的 sha256。fs 工具在内存里也记一份,
49
- * 这里的是给恢复的会话用的:之前的进程里读过、写过的文件,内容没变就不用再读一遍。
50
- * 追加到每个会话一个的 seen.jsonl,后面的记录覆盖前面的;内容没变的重复读取不再写
51
- */
52
- async markSeen(sessionId, file, hash) {
53
- const seen = await this.#seenOf(sessionId);
54
- if (seen.get(file) === hash)
55
- return;
56
- seen.set(file, hash);
57
- const dir = path.join(this.#dir, safe(sessionId));
58
- await mkdir(dir, { recursive: true });
59
- await appendFile(path.join(dir, "seen.jsonl"), JSON.stringify({ path: file, hash }) + "\n");
60
- }
61
- /** markSeen 记下的 sha256;没有记录返回 undefined */
62
- async seenHash(sessionId, file) {
63
- const hash = (await this.#seenOf(sessionId)).get(file);
64
- if (hash !== undefined)
65
- return hash;
66
- // 旧版本每个文件一个 seen/<sha256(path)>.json
43
+ /** 已经撤销的修改(toolUseId) */
44
+ async undone(sessionId) {
67
45
  try {
68
- const rec = JSON.parse(await readFile(path.join(this.#dir, safe(sessionId), "seen", `${sha256(file)}.json`), "utf8"));
69
- return rec.path === file ? rec.hash : undefined;
46
+ const ids = JSON.parse(await readFile(path.join(this.#dir, safe(sessionId), UNDONE), "utf8"));
47
+ return new Set(Array.isArray(ids) ? ids.filter((x) => typeof x === "string") : []);
70
48
  }
71
49
  catch {
72
- return undefined;
50
+ return new Set();
73
51
  }
74
52
  }
75
- #seenOf(sessionId) {
76
- let seen = this.#seen.get(sessionId);
77
- if (!seen) {
78
- seen = readFile(path.join(this.#dir, safe(sessionId), "seen.jsonl"), "utf8").then((text) => {
79
- const map = new Map();
80
- for (const line of text.split("\n")) {
81
- try {
82
- const rec = JSON.parse(line);
83
- map.set(rec.path, rec.hash);
84
- }
85
- catch {
86
- // 空行或写到一半的一行
87
- }
88
- }
89
- return map;
90
- }, () => new Map());
91
- this.#seen.set(sessionId, seen);
92
- }
93
- return seen;
53
+ async markUndone(sessionId, ids) {
54
+ const all = await this.undone(sessionId);
55
+ for (const id of ids)
56
+ all.add(id);
57
+ const dir = path.join(this.#dir, safe(sessionId));
58
+ await mkdir(dir, { recursive: true });
59
+ await writeFile(path.join(dir, UNDONE), JSON.stringify([...all]));
94
60
  }
95
61
  /** 文件现在的内容是否还是这次写入的结果 */
96
62
  async unchangedSince(cp) {
@@ -111,9 +77,10 @@ export class Checkpoints {
111
77
  }
112
78
  }
113
79
  }
80
+ const UNDONE = "undone.json";
114
81
  /**
115
- * 最近一轮还有没撤销的修改的快照(最新的在前)。一轮从一条用户消息开始;
116
- * 只有工具结果、或者只有宿主说明(例如自动续写的提示)的消息不算新的一轮。没有可撤销的返回空数组
82
+ * 最近一轮还有没撤销的修改的快照(最新的在前)。一轮从一条用户自己写的消息开始;
83
+ * 只有工具结果、或者只有插件、宿主加的说明(例如自动续写的提示)的消息不算新的一轮。没有可撤销的返回空数组
117
84
  */
118
85
  export function lastTurnChanges(messages, checkpoints, undone) {
119
86
  const pending = checkpoints.filter((c) => !undone.has(c.toolUseId));
@@ -128,7 +95,7 @@ export function lastTurnChanges(messages, checkpoints, undone) {
128
95
  ids.add(b.id);
129
96
  continue;
130
97
  }
131
- const startsTurn = m.content.some((b) => b.kind !== "tool_result" && b.origin.by !== "host");
98
+ const startsTurn = m.content.some((b) => b.kind !== "tool_result" && b.origin.by === "user");
132
99
  if (!startsTurn)
133
100
  continue;
134
101
  const hits = pending.filter((c) => ids.has(c.toolUseId));
@@ -141,4 +108,3 @@ export function lastTurnChanges(messages, checkpoints, undone) {
141
108
  }
142
109
  /** 会话和工具调用的 id 用作文件名 */
143
110
  const safe = (id) => id.replace(/[^A-Za-z0-9_.-]/g, "_");
144
- //# sourceMappingURL=checkpoint.js.map