@uncarved/jade 0.1.2 → 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 (436) hide show
  1. package/bin/jade.js +5 -4
  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 -28
  18. package/dist/index.js +11 -28
  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 +156 -1223
  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 +55 -0
  57. package/dist/update.js +258 -0
  58. package/dist/update.js.map +1 -0
  59. package/package.json +12 -9
  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 -84
  63. package/plugins/approval/review.ts +192 -0
  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 +68 -39
  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 +112 -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 +3 -4
  81. package/{src/tools → plugins/fs}/fs.ts +64 -46
  82. package/{src/tools → plugins/fs}/grep.ts +4 -3
  83. package/plugins/fs/index.ts +34 -0
  84. package/plugins/fs/plugin.json +7 -0
  85. package/plugins/fs/renderers.ts +138 -0
  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 +23 -27
  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 +36 -21
  141. package/{src → plugins/shell}/sys.ts +19 -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 +53 -1
  155. package/plugins/tui/frontend.ts +596 -0
  156. package/plugins/tui/index.ts +37 -0
  157. package/{src/ui → plugins/tui}/markdown.ts +258 -219
  158. package/plugins/tui/mentions.ts +113 -0
  159. package/plugins/tui/plugin.json +10 -0
  160. package/plugins/tui/render.ts +67 -0
  161. package/plugins/tui/screen.ts +268 -0
  162. package/{src/ui → plugins/tui}/transcript.ts +179 -111
  163. package/{src/ui/tui.tsx → plugins/tui/tui.ts} +684 -418
  164. package/{src/tools → plugins/undo}/checkpoint.ts +21 -60
  165. package/plugins/undo/index.ts +139 -0
  166. package/plugins/undo/notes.ts +43 -0
  167. package/plugins/undo/plugin.json +7 -0
  168. package/plugins/undo/style.ts +17 -0
  169. package/plugins/update/index.ts +40 -0
  170. package/plugins/update/plugin.json +13 -0
  171. package/plugins/web/env.ts +78 -0
  172. package/plugins/web/index.ts +133 -0
  173. package/plugins/web/plugin.json +15 -0
  174. package/plugins/web/renderers.ts +11 -0
  175. package/plugins/web/web.ts +713 -0
  176. package/plugins-dist/approval/index.js +271 -0
  177. package/plugins-dist/approval/plugin.json +24 -0
  178. package/{dist/plugins → plugins-dist/approval}/policy.js +15 -65
  179. package/plugins-dist/approval/review.js +176 -0
  180. package/{dist/plugins → plugins-dist/approval}/schema.js +0 -1
  181. package/plugins-dist/ask/index.js +145 -0
  182. package/plugins-dist/ask/plugin.json +12 -0
  183. package/plugins-dist/budget/index.js +37 -0
  184. package/plugins-dist/budget/plugin.json +15 -0
  185. package/{dist/plugins → plugins-dist/checks}/checks.js +65 -34
  186. package/plugins-dist/checks/index.js +150 -0
  187. package/plugins-dist/checks/plugin.json +21 -0
  188. package/plugins-dist/checks/project.js +76 -0
  189. package/plugins-dist/commands/index.js +33 -0
  190. package/plugins-dist/commands/plugin.json +9 -0
  191. package/{dist/plugins → plugins-dist/compact}/compact.js +95 -33
  192. package/plugins-dist/compact/index.js +100 -0
  193. package/plugins-dist/compact/plugin.json +25 -0
  194. package/plugins-dist/compact/style.js +14 -0
  195. package/plugins-dist/continue/index.js +57 -0
  196. package/plugins-dist/continue/plugin.json +15 -0
  197. package/{dist/ui → plugins-dist/fs}/diff.js +3 -5
  198. package/{dist/tools → plugins-dist/fs}/fs.js +62 -46
  199. package/{dist/tools → plugins-dist/fs}/grep.js +4 -4
  200. package/plugins-dist/fs/index.js +36 -0
  201. package/plugins-dist/fs/plugin.json +10 -0
  202. package/plugins-dist/fs/renderers.js +132 -0
  203. package/plugins-dist/fs/style.js +15 -0
  204. package/plugins-dist/fs/sys.js +54 -0
  205. package/plugins-dist/keys/index.js +36 -0
  206. package/plugins-dist/keys/plugin.json +9 -0
  207. package/plugins-dist/mcp/index.js +187 -0
  208. package/{dist → plugins-dist/mcp}/mcp.js +34 -30
  209. package/plugins-dist/mcp/plugin.json +12 -0
  210. package/plugins-dist/mcp/project.js +90 -0
  211. package/plugins-dist/memory/index.js +94 -0
  212. package/{dist → plugins-dist/memory}/memory.js +21 -3
  213. package/plugins-dist/memory/notes.js +36 -0
  214. package/plugins-dist/memory/plugin.json +11 -0
  215. package/plugins-dist/memory/style.js +14 -0
  216. package/plugins-dist/mentions/attach.js +120 -0
  217. package/plugins-dist/mentions/index.js +69 -0
  218. package/plugins-dist/mentions/plugin.json +9 -0
  219. package/plugins-dist/mentions/style.js +14 -0
  220. package/plugins-dist/models/config.js +53 -0
  221. package/plugins-dist/models/configure.js +415 -0
  222. package/plugins-dist/models/context.js +27 -0
  223. package/plugins-dist/models/index.js +167 -0
  224. package/plugins-dist/models/plugin.json +14 -0
  225. package/{dist → plugins-dist/models}/provider.js +22 -19
  226. package/plugins-dist/models/saved.js +80 -0
  227. package/plugins-dist/modes/index.js +190 -0
  228. package/plugins-dist/modes/plugin.json +18 -0
  229. package/plugins-dist/plugins/index.js +37 -0
  230. package/plugins-dist/plugins/plugin.json +10 -0
  231. package/plugins-dist/print/index.js +153 -0
  232. package/plugins-dist/print/plugin.json +14 -0
  233. package/plugins-dist/prompts/index.js +57 -0
  234. package/plugins-dist/prompts/plugin.json +13 -0
  235. package/plugins-dist/prompts/prompts.js +227 -0
  236. package/plugins-dist/prompts/sys.js +46 -0
  237. package/plugins-dist/renderers/index.js +36 -0
  238. package/plugins-dist/renderers/plugin.json +9 -0
  239. package/plugins-dist/repeats/index.js +165 -0
  240. package/plugins-dist/repeats/plugin.json +6 -0
  241. package/plugins-dist/schedule/cron.js +67 -0
  242. package/plugins-dist/schedule/index.js +281 -0
  243. package/plugins-dist/schedule/plugin.json +16 -0
  244. package/plugins-dist/schedule/store.js +125 -0
  245. package/plugins-dist/scratch/index.js +26 -0
  246. package/plugins-dist/scratch/plugin.json +10 -0
  247. package/plugins-dist/screenshot/index.js +35 -0
  248. package/plugins-dist/screenshot/plugin.json +11 -0
  249. package/plugins-dist/screenshot/sys.js +76 -0
  250. package/{dist/tools/screenshot.js → plugins-dist/screenshot/tool.js} +5 -4
  251. package/plugins-dist/sessions/index.js +136 -0
  252. package/plugins-dist/sessions/plugin.json +12 -0
  253. package/plugins-dist/shell/index.js +33 -0
  254. package/plugins-dist/shell/plugin.json +19 -0
  255. package/plugins-dist/shell/renderers.js +40 -0
  256. package/plugins-dist/shell/service.js +29 -0
  257. package/{dist/tools → plugins-dist/shell}/shell.js +36 -23
  258. package/{dist → plugins-dist/shell}/sys.js +20 -44
  259. package/plugins-dist/skills/index.js +90 -0
  260. package/plugins-dist/skills/plugin.json +12 -0
  261. package/plugins-dist/skills/project.js +47 -0
  262. package/{dist → plugins-dist/skills}/skills.js +3 -7
  263. package/plugins-dist/suggest/index.js +282 -0
  264. package/plugins-dist/suggest/plugin.json +23 -0
  265. package/plugins-dist/task/index.js +151 -0
  266. package/plugins-dist/task/plugin.json +23 -0
  267. package/plugins-dist/task/style.js +14 -0
  268. package/plugins-dist/task/subagent.js +208 -0
  269. package/{dist/tools/todo.js → plugins-dist/todo/index.js} +29 -7
  270. package/plugins-dist/todo/plugin.json +9 -0
  271. package/{dist/ui → plugins-dist/tui}/editor.js +53 -2
  272. package/plugins-dist/tui/frontend.js +586 -0
  273. package/{dist → plugins-dist/tui}/history.js +0 -1
  274. package/plugins-dist/tui/index.js +21 -0
  275. package/{dist/ui → plugins-dist/tui}/markdown.js +57 -20
  276. package/plugins-dist/tui/mentions.js +115 -0
  277. package/plugins-dist/tui/plugin.json +25 -0
  278. package/plugins-dist/tui/render.js +61 -0
  279. package/plugins-dist/tui/screen.js +201 -0
  280. package/{dist/ui → plugins-dist/tui}/transcript.js +179 -111
  281. package/{dist/ui → plugins-dist/tui}/tui.js +484 -101
  282. package/{dist/tools → plugins-dist/undo}/checkpoint.js +21 -55
  283. package/plugins-dist/undo/index.js +140 -0
  284. package/plugins-dist/undo/notes.js +36 -0
  285. package/plugins-dist/undo/plugin.json +9 -0
  286. package/plugins-dist/undo/style.js +14 -0
  287. package/plugins-dist/update/index.js +34 -0
  288. package/plugins-dist/update/plugin.json +15 -0
  289. package/plugins-dist/web/env.js +80 -0
  290. package/plugins-dist/web/index.js +124 -0
  291. package/plugins-dist/web/plugin.json +21 -0
  292. package/plugins-dist/web/renderers.js +7 -0
  293. package/plugins-dist/web/web.js +660 -0
  294. package/sdk/python/__pycache__/jade_plugin.cpython-312.pyc +0 -0
  295. package/sdk/python/jade_plugin.py +380 -0
  296. package/src/api.ts +298 -0
  297. package/src/config.ts +32 -134
  298. package/src/fetch.ts +216 -0
  299. package/src/hash.ts +39 -0
  300. package/src/host.ts +429 -0
  301. package/src/index.ts +23 -28
  302. package/src/install.ts +355 -0
  303. package/src/main.ts +152 -1263
  304. package/src/manifest.ts +160 -0
  305. package/src/membrane.ts +142 -0
  306. package/src/remote.ts +288 -0
  307. package/src/rescue.ts +217 -0
  308. package/src/resolve.ts +199 -0
  309. package/src/rpc.ts +144 -0
  310. package/src/secrets.ts +122 -0
  311. package/src/session.ts +458 -0
  312. package/src/source.ts +83 -0
  313. package/src/state.ts +120 -0
  314. package/src/update.ts +265 -0
  315. package/LICENSE +0 -21
  316. package/README.md +0 -198
  317. package/dist/commands.d.ts +0 -30
  318. package/dist/commands.js +0 -106
  319. package/dist/commands.js.map +0 -1
  320. package/dist/context.d.ts +0 -17
  321. package/dist/context.js +0 -53
  322. package/dist/context.js.map +0 -1
  323. package/dist/distro.d.ts +0 -104
  324. package/dist/distro.js +0 -312
  325. package/dist/distro.js.map +0 -1
  326. package/dist/history.d.ts +0 -10
  327. package/dist/history.js.map +0 -1
  328. package/dist/mcp.d.ts +0 -114
  329. package/dist/mcp.js.map +0 -1
  330. package/dist/memory.d.ts +0 -19
  331. package/dist/memory.js.map +0 -1
  332. package/dist/mentions.d.ts +0 -35
  333. package/dist/mentions.js +0 -130
  334. package/dist/mentions.js.map +0 -1
  335. package/dist/plugin-cli.d.ts +0 -16
  336. package/dist/plugin-cli.js +0 -251
  337. package/dist/plugin-cli.js.map +0 -1
  338. package/dist/plugins/budget.d.ts +0 -9
  339. package/dist/plugins/budget.js +0 -30
  340. package/dist/plugins/budget.js.map +0 -1
  341. package/dist/plugins/builtins.d.ts +0 -10
  342. package/dist/plugins/builtins.js +0 -22
  343. package/dist/plugins/builtins.js.map +0 -1
  344. package/dist/plugins/checks.d.ts +0 -70
  345. package/dist/plugins/checks.js.map +0 -1
  346. package/dist/plugins/compact.d.ts +0 -26
  347. package/dist/plugins/compact.js.map +0 -1
  348. package/dist/plugins/core.d.ts +0 -42
  349. package/dist/plugins/core.js +0 -190
  350. package/dist/plugins/core.js.map +0 -1
  351. package/dist/plugins/install.d.ts +0 -68
  352. package/dist/plugins/install.js +0 -377
  353. package/dist/plugins/install.js.map +0 -1
  354. package/dist/plugins/loader.d.ts +0 -182
  355. package/dist/plugins/loader.js +0 -253
  356. package/dist/plugins/loader.js.map +0 -1
  357. package/dist/plugins/policy.d.ts +0 -96
  358. package/dist/plugins/policy.js.map +0 -1
  359. package/dist/plugins/prompts.d.ts +0 -38
  360. package/dist/plugins/prompts.js +0 -196
  361. package/dist/plugins/prompts.js.map +0 -1
  362. package/dist/plugins/repeats.d.ts +0 -9
  363. package/dist/plugins/repeats.js +0 -90
  364. package/dist/plugins/repeats.js.map +0 -1
  365. package/dist/plugins/review.d.ts +0 -16
  366. package/dist/plugins/review.js +0 -92
  367. package/dist/plugins/review.js.map +0 -1
  368. package/dist/plugins/schema.d.ts +0 -2
  369. package/dist/plugins/schema.js.map +0 -1
  370. package/dist/provider.d.ts +0 -111
  371. package/dist/provider.js.map +0 -1
  372. package/dist/sessions.d.ts +0 -22
  373. package/dist/sessions.js +0 -53
  374. package/dist/sessions.js.map +0 -1
  375. package/dist/skills.d.ts +0 -37
  376. package/dist/skills.js.map +0 -1
  377. package/dist/sys.d.ts +0 -48
  378. package/dist/sys.js.map +0 -1
  379. package/dist/tools/checkpoint.d.ts +0 -43
  380. package/dist/tools/checkpoint.js.map +0 -1
  381. package/dist/tools/fs.d.ts +0 -35
  382. package/dist/tools/fs.js.map +0 -1
  383. package/dist/tools/grep.d.ts +0 -6
  384. package/dist/tools/grep.js.map +0 -1
  385. package/dist/tools/screenshot.d.ts +0 -15
  386. package/dist/tools/screenshot.js.map +0 -1
  387. package/dist/tools/shell.d.ts +0 -55
  388. package/dist/tools/shell.js.map +0 -1
  389. package/dist/tools/task.d.ts +0 -35
  390. package/dist/tools/task.js +0 -89
  391. package/dist/tools/task.js.map +0 -1
  392. package/dist/tools/todo.d.ts +0 -10
  393. package/dist/tools/todo.js.map +0 -1
  394. package/dist/tools/web.d.ts +0 -23
  395. package/dist/tools/web.js +0 -426
  396. package/dist/tools/web.js.map +0 -1
  397. package/dist/ui/configure.d.ts +0 -20
  398. package/dist/ui/configure.js +0 -378
  399. package/dist/ui/configure.js.map +0 -1
  400. package/dist/ui/diff.d.ts +0 -20
  401. package/dist/ui/diff.js.map +0 -1
  402. package/dist/ui/editor.d.ts +0 -33
  403. package/dist/ui/editor.js.map +0 -1
  404. package/dist/ui/markdown.d.ts +0 -17
  405. package/dist/ui/markdown.js.map +0 -1
  406. package/dist/ui/render.d.ts +0 -15
  407. package/dist/ui/render.js +0 -94
  408. package/dist/ui/render.js.map +0 -1
  409. package/dist/ui/screen.d.ts +0 -98
  410. package/dist/ui/screen.js +0 -108
  411. package/dist/ui/screen.js.map +0 -1
  412. package/dist/ui/transcript.d.ts +0 -33
  413. package/dist/ui/transcript.js.map +0 -1
  414. package/dist/ui/tui.d.ts +0 -45
  415. package/dist/ui/tui.js.map +0 -1
  416. package/src/commands.ts +0 -120
  417. package/src/context.ts +0 -64
  418. package/src/distro.ts +0 -400
  419. package/src/mentions.ts +0 -135
  420. package/src/plugin-cli.ts +0 -239
  421. package/src/plugins/budget.ts +0 -37
  422. package/src/plugins/builtins.ts +0 -31
  423. package/src/plugins/core.ts +0 -217
  424. package/src/plugins/install.ts +0 -429
  425. package/src/plugins/loader.ts +0 -386
  426. package/src/plugins/prompts.ts +0 -234
  427. package/src/plugins/repeats.ts +0 -96
  428. package/src/plugins/review.ts +0 -109
  429. package/src/sessions.ts +0 -61
  430. package/src/tools/task.ts +0 -109
  431. package/src/tools/web.ts +0 -451
  432. package/src/ui/configure.ts +0 -408
  433. package/src/ui/render.ts +0 -83
  434. package/src/ui/screen.ts +0 -169
  435. /package/{src/plugins → plugins/approval}/schema.ts +0 -0
  436. /package/{src → plugins/tui}/history.ts +0 -0
@@ -1,17 +1,27 @@
1
1
  // 把运行时的通知和日志事件显示成对话:模型的流式输出、工具调用和结果、轮次结束的原因,
2
2
  // 以及恢复会话时重新显示历史。顺带统计本会话的 token 用量、更新状态栏的上下文用量。
3
3
  //
4
- // 只负责显示和统计,不驱动运行时;宿主(main.ts)用 lastEnd、turnFailed 决定接下来做什么。
5
- import { readAll } from "uncarved";
6
- import { renderTodos } from "../tools/todo.js";
7
- import { callDetails, clip, detailsOf, summarize } from "./render.js";
4
+ // 只负责显示和统计,不驱动运行时;前端(frontend.ts)用 lastEnd、turnFailed 决定接下来做什么。
5
+ import { clip, clipStyled, detailsOf, preview, summarize } from "./render.js";
8
6
  import { bold, cyan, dim, green, red, yellow } from "./screen.js";
9
7
  /** 工具结果折叠起来的完整内容最多这么多行 */
10
8
  const MAX_DETAIL_LINES = 2000;
9
+ /** 插件事件里的用量:只取数字字段 */
10
+ function usageOf(u) {
11
+ if (typeof u !== "object" || u === null)
12
+ return undefined;
13
+ const out = {};
14
+ for (const k of ["inputTokens", "outputTokens", "cacheReadTokens", "cacheWriteTokens"]) {
15
+ const v = u[k];
16
+ if (typeof v === "number" && Number.isFinite(v))
17
+ out[k] = v;
18
+ }
19
+ return Object.keys(out).length ? out : undefined;
20
+ }
11
21
  const textOf = (blocks) => blocks.flatMap((b) => (b.kind === "text" ? [b.text] : [])).join("\n");
12
22
  const errorText = (err) => (err instanceof Error ? err.message : String(err));
13
23
  export function transcript(opts) {
14
- const { screen, cwd, store } = opts;
24
+ const { screen, cwd } = opts;
15
25
  const usage = { inputTokens: 0, outputTokens: 0, cacheReadTokens: 0, cacheWriteTokens: 0 };
16
26
  const addUsage = (u) => {
17
27
  for (const k of Object.keys(usage))
@@ -19,30 +29,38 @@ export function transcript(opts) {
19
29
  if (u)
20
30
  screen.status({ spent: { input: usage.inputTokens, output: usage.outputTokens } });
21
31
  };
22
- /** 一个事件带来的用量:模型回复、压缩时的总结调用、auto 模式的审查;子 Agent 的用量在它自己的日志里 */
32
+ /**
33
+ * 一个事件带来的用量:模型回复;插件事件 data 里的 usage(压缩时的总结调用、auto 模式的审查这类插件自己发的请求);
34
+ * 子 Agent 的用量在它自己的日志里(读不到时不算,不让一个读失败变成没人处理的 rejection)
35
+ */
23
36
  async function countUsage(e) {
24
37
  if (e.type === "model.responded")
25
38
  addUsage(e.data.usage);
26
- else if (e.type === "jade/compact/compacted" || e.type === "jade/policy/reviewed")
27
- addUsage(e.data.usage);
39
+ else if (e.origin.by === "plugin")
40
+ addUsage(usageOf(e.data?.usage));
28
41
  else if (e.type === "tool.completed") {
29
42
  const child = e.data.child;
30
- if (child)
31
- for (const c of await readAll(store, child.sessionId))
43
+ if (child && opts.readLog)
44
+ for (const c of await opts.readLog(child.sessionId).catch(() => []))
32
45
  await countUsage(c);
33
46
  }
34
47
  }
35
- /** 服务端报过缓存命中数。有的服务只在命中时才带这个字段,报过一次之后没带就是没命中 */
36
- let reportsCache = false;
48
+ /**
49
+ * 报过缓存命中数的 provider/模型。有的服务只在命中时才带这个字段,报过一次之后没带就是没命中;
50
+ * 换了服务或模型要重新看,否则从报缓存的服务换到不报的,会一直显示 0%
51
+ */
52
+ let reportsCache;
37
53
  /** 上下文用量:最近一次回复的输入加输出,就是下一次请求的大致起点;以及这次输入的缓存命中率 */
38
- function showContext(u) {
54
+ function showContext(e) {
55
+ const u = e.data.usage;
39
56
  if (u?.inputTokens === undefined)
40
57
  return;
58
+ const by = e.origin.by === "model" ? `${e.origin.provider}/${e.origin.model}` : "";
41
59
  if (u.cacheReadTokens !== undefined)
42
- reportsCache = true;
60
+ reportsCache = by;
43
61
  screen.status({
44
62
  context: { used: u.inputTokens + (u.outputTokens ?? 0), limit: opts.contextWindow(), compactAt: opts.compactAt?.() },
45
- cache: reportsCache && u.inputTokens > 0 ? (u.cacheReadTokens ?? 0) / u.inputTokens : undefined,
63
+ cache: reportsCache === by && u.inputTokens > 0 ? (u.cacheReadTokens ?? 0) / u.inputTokens : undefined,
46
64
  });
47
65
  }
48
66
  /**
@@ -54,7 +72,11 @@ export function transcript(opts) {
54
72
  const startSpeed = () => {
55
73
  speed.first = 0;
56
74
  speed.estimate = 0;
75
+ toolChars = 0;
57
76
  };
77
+ /** 这次回复里工具参数已经生成的字数:写大文件时一写几分钟,显示出来才看得出不是卡住了 */
78
+ let toolChars = 0;
79
+ const toolLabel = () => (toolChars < 1000 ? "Writing" : `Writing (${Math.floor(toolChars / 1000)}k chars)`);
58
80
  const trackSpeed = (text) => {
59
81
  const now = Date.now();
60
82
  if (!speed.first)
@@ -81,17 +103,13 @@ export function transcript(opts) {
81
103
  if (!replaying)
82
104
  screen.busy(label);
83
105
  };
84
- /** 结果不用再显示的工具调用 */
85
- const quiet = new Set();
86
106
  let streamed = false;
87
107
  /** 正在运行、显示着进度的工具 */
88
108
  const running = new Set();
89
- /** 子 Agent 调用过的工具,结束时放进 task 结果的折叠内容里 */
90
- const steps = new Map();
91
- /** 正在运行的子 Agent 的标签,显示在它的进度行开头 */
92
- const tasks = new Map();
93
109
  /** 调用行省略了的参数(例如很长的命令),结果出来后放在折叠内容的最前面 */
94
110
  const calls = new Map();
111
+ /** renderer 的 before 在执行前记下的东西,结果出来时交给它的 result */
112
+ const befores = new Map();
95
113
  const progress = (id, line, o) => {
96
114
  running.add(id);
97
115
  screen.progress(id, line, o);
@@ -100,6 +118,50 @@ export function transcript(opts) {
100
118
  if (running.delete(id))
101
119
  screen.progress(id, undefined);
102
120
  };
121
+ /** 有 result renderer 的调用的参数,结果出来时交给它 */
122
+ const inputs = new Map();
123
+ /** 出过错的 renderer(插件 + 工具),只提示一次 */
124
+ const failed = new Set();
125
+ /** 调用插件的 renderer;没有、出错时返回 undefined(用默认的显示) */
126
+ async function custom(name, use) {
127
+ const found = opts.renderer?.(name);
128
+ if (!found)
129
+ return undefined;
130
+ try {
131
+ return await use(found.renderer);
132
+ }
133
+ catch (err) {
134
+ renderFailed(found.plugin, name, err);
135
+ return undefined;
136
+ }
137
+ }
138
+ /** 同步的版本:摘要和结果在事件通知里同步显示 */
139
+ function customSync(name, use) {
140
+ const found = opts.renderer?.(name);
141
+ if (!found)
142
+ return undefined;
143
+ try {
144
+ return use(found.renderer);
145
+ }
146
+ catch (err) {
147
+ renderFailed(found.plugin, name, err);
148
+ return undefined;
149
+ }
150
+ }
151
+ function renderFailed(plugin, name, err) {
152
+ if (failed.has(`${plugin}:${name}`))
153
+ return;
154
+ failed.add(`${plugin}:${name}`);
155
+ screen.log(yellow(`[warning] plugin ${plugin}: showing ${name} failed, using the default display: ${errorText(err)}`));
156
+ }
157
+ const summary = (name, input) => {
158
+ const s = customSync(name, (r) => r.summary?.(input));
159
+ return typeof s === "string" ? clip(s.split("\n")[0], 120) : summarize(cwd, input);
160
+ };
161
+ const details = (name, input) => {
162
+ const d = customSync(name, (r) => r.details?.(input));
163
+ return typeof d === "string" && d ? d.replace(/^/gm, " ") : undefined;
164
+ };
103
165
  const self = {
104
166
  usage,
105
167
  lastEnd: undefined,
@@ -107,19 +169,24 @@ export function transcript(opts) {
107
169
  turnFailed: false,
108
170
  onNotice,
109
171
  replay,
172
+ summary,
173
+ details,
174
+ async preview(c) {
175
+ const p = await custom(c.name, (r) => r.preview?.(c.input));
176
+ return typeof p === "string" ? p : preview(c.input);
177
+ },
110
178
  echo: (text) => screen.log(text.startsWith("/") ? cyan(`› ${text}`) : `\n${bold(`› ${text.replace(/\n/g, "\n ")}`)}`),
111
179
  reset() {
112
180
  for (const k of Object.keys(usage))
113
181
  usage[k] = 0;
114
- reportsCache = false;
182
+ reportsCache = undefined;
115
183
  toolNames.clear();
116
- quiet.clear();
117
184
  for (const id of running)
118
185
  screen.progress(id, undefined);
119
186
  running.clear();
120
- steps.clear();
121
- tasks.clear();
122
187
  calls.clear();
188
+ befores.clear();
189
+ inputs.clear();
123
190
  self.lastEnd = undefined;
124
191
  },
125
192
  };
@@ -139,7 +206,12 @@ export function transcript(opts) {
139
206
  trackSpeed(n.delta.text);
140
207
  // 工具参数只用来计时,不显示;也不算已经输出了内容(重试时不用标记作废,回复结束时照常打印没流式输出的正文)
141
208
  if (n.delta.kind === "tool_input") {
142
- screen.busy("Writing");
209
+ // 只在千位变了时更新,不让每个增量都重画
210
+ const before = toolLabel();
211
+ toolChars += n.delta.text.length;
212
+ const label = toolLabel();
213
+ if (label !== before || toolChars === n.delta.text.length)
214
+ screen.busy(label);
143
215
  return;
144
216
  }
145
217
  streamed = true;
@@ -166,32 +238,19 @@ export function transcript(opts) {
166
238
  return renderEvent(n.event);
167
239
  }
168
240
  }
169
- function renderProgress(toolUseId, p) {
170
- if (typeof p !== "object" || p === null)
241
+ /** 工具的进度:有 renderer 的 progress 时由它换成一行;否则 { text } 形式的按输出逐行显示(例如 bash),其他的不显示 */
242
+ function renderProgress(toolUseId, update) {
243
+ const name = toolNames.get(toolUseId) ?? "?";
244
+ if (opts.renderer?.(name)?.renderer.progress) {
245
+ const line = customSync(name, (r) => r.progress?.(update, { toolUseId, summary }));
246
+ if (typeof line === "string" && line)
247
+ progress(toolUseId, clipStyled(line.split("\n")[0], 200));
171
248
  return;
172
- // 每个子 Agent 只有一行进度:标签、调用过几个工具、正在做什么。并行的几个靠标签分清
173
- const taskLine = (what) => {
174
- const n = steps.get(toolUseId)?.length ?? 0;
175
- progress(toolUseId, dim(` ↳ ${tasks.get(toolUseId) ?? "sub-agent"}${n ? ` (${n} tool call${n > 1 ? "s" : ""})` : ""} · ${what}`));
176
- };
177
- if (p.kind === "task-start") {
178
- tasks.set(toolUseId, p.description);
179
- return taskLine("starting");
180
249
  }
181
- if (p.kind === "task-model")
182
- return taskLine("thinking");
183
- if (p.kind === "task-tool") {
184
- // 要用户批准的调用在审批时显示
185
- if (p.decision === "ask")
186
- return;
187
- const step = `${p.decision === "deny" ? "✗" : "·"} ${p.name}(${summarize(cwd, p.name, p.input)})`;
188
- steps.set(toolUseId, [...(steps.get(toolUseId) ?? []), step]);
189
- return taskLine(step);
190
- }
191
- // 第三方工具的进度格式 jade 不认识,不显示
192
- if (typeof p.text !== "string")
250
+ const text = update?.text;
251
+ if (typeof text !== "string")
193
252
  return;
194
- for (const l of p.text.replace(/\n$/, "").split("\n"))
253
+ for (const l of text.replace(/\n$/, "").split("\n"))
195
254
  progress(toolUseId, dim(` │ ${clip(l, 200)}`), { output: true });
196
255
  }
197
256
  function renderEvent(e) {
@@ -204,7 +263,7 @@ export function transcript(opts) {
204
263
  case "model.responded": {
205
264
  const d = e.data;
206
265
  void countUsage(e);
207
- showContext(d.usage);
266
+ showContext(e);
208
267
  if (!replaying)
209
268
  finishSpeed(d.usage);
210
269
  for (const b of d.content)
@@ -223,26 +282,38 @@ export function transcript(opts) {
223
282
  case "tool.decided": {
224
283
  const d = e.data;
225
284
  const name = toolNames.get(d.toolUseId) ?? "?";
226
- const full = callDetails(name, d.input);
285
+ const full = details(name, d.input);
227
286
  if (full)
228
287
  calls.set(d.toolUseId, full);
288
+ if (opts.renderer?.(name)?.renderer.result)
289
+ inputs.set(d.toolUseId, d.input);
229
290
  if (d.decision === "ask")
230
291
  return;
231
- const head = `${bold(name)}(${summarize(cwd, name, d.input)})`;
292
+ // 执行前交给 renderer 的 before(例如按文件当时的内容算 diff);重新显示历史时文件已经变了,不调用
293
+ if (d.decision === "allow" && !replaying) {
294
+ const before = customSync(name, (r) => r.before?.(d.input));
295
+ if (before !== undefined)
296
+ befores.set(d.toolUseId, before);
297
+ }
298
+ const head = `${bold(name)}(${summary(name, d.input)})`;
232
299
  if (d.decision === "deny")
233
300
  screen.log(red(`✗ ${head}`) + dim(d.reason ? ` — ${clip(d.reason, 200)}` : ""), { id: d.toolUseId, details: full });
234
301
  else {
235
302
  activity(`Running ${name}`);
236
- if (name === "todo_write") {
237
- // 清单本身就是参数:直接显示,结果不再显示
238
- quiet.add(d.toolUseId);
239
- screen.log(cyan("● ") + bold("Todos"));
240
- screen.log(renderTodos(d.input.todos ?? []).replace(/^/gm, " "));
241
- }
242
- else if (d.decidedBy !== "user" || replaying) {
243
- // 用户批准的调用在审批时已经显示过;重新显示历史时没有审批这一步
244
- // auto 模式下审查放行的带着理由
245
- screen.log(cyan("● ") + head + (d.reason ? dim(` — ${clip(d.reason, 160)}`) : ""), { id: d.toolUseId, details: full });
303
+ // 用户批准的调用在审批时已经显示过;重新显示历史时没有审批这一步
304
+ if (d.decidedBy !== "user" || replaying) {
305
+ const own = customSync(name, (r) => r.call?.(d.input));
306
+ if (typeof own === "string" && own) {
307
+ // renderer 给的内容:第一行是调用行(结果接在它后面),其余的行不折叠
308
+ const [first, ...rest] = own.split("\n");
309
+ screen.log(cyan("● ") + first, { id: d.toolUseId, details: full });
310
+ if (rest.length)
311
+ screen.log(rest.join("\n"));
312
+ }
313
+ else {
314
+ // auto 模式下审查放行的带着理由
315
+ screen.log(cyan("● ") + head + (d.reason ? dim(` — ${clip(d.reason, 160)}`) : ""), { id: d.toolUseId, details: full });
316
+ }
246
317
  }
247
318
  }
248
319
  return;
@@ -252,25 +323,31 @@ export function transcript(opts) {
252
323
  void countUsage(e);
253
324
  activity("Working");
254
325
  doneProgress(d.toolUseId);
255
- const sub = steps.get(d.toolUseId) ?? [];
256
- steps.delete(d.toolUseId);
257
- tasks.delete(d.toolUseId);
258
326
  const call = calls.get(d.toolUseId);
259
327
  calls.delete(d.toolUseId);
260
- if (quiet.delete(d.toolUseId) && !d.isError)
261
- return;
328
+ const before = befores.get(d.toolUseId);
329
+ befores.delete(d.toolUseId);
330
+ const input = inputs.get(d.toolUseId);
331
+ inputs.delete(d.toolUseId);
262
332
  const text = textOf(d.content).trim();
333
+ const name = toolNames.get(d.toolUseId) ?? "?";
334
+ const mine = customSync(name, (r) => r.result?.({ toolUseId: d.toolUseId, input, text, isError: d.isError === true, before }));
335
+ // null:renderer 不要显示结果
336
+ if (mine === null)
337
+ return;
338
+ if (mine && typeof mine.line === "string") {
339
+ const own = typeof mine.details === "string" && mine.details ? [mine.details.replace(/^/gm, " ")] : [];
340
+ const folded = [...(call ? [call] : []), ...own].join("\n") || undefined;
341
+ screen.amend(d.toolUseId, (d.isError ? red : dim)("⎿ ") + clipStyled(mine.line.split("\n")[0], 200), { details: folded });
342
+ return;
343
+ }
263
344
  const lines = text.split("\n");
264
345
  // 结果接在调用的那一行后面;摘要省略了内容时,把完整结果(和子 Agent 调用过的工具)折叠起来,点击展开
265
346
  const shown = d.isError ? 4 : 1;
266
347
  const width = d.isError ? 200 : 160;
267
- const hidden = sub.length > 0 || lines.length > shown || lines.some((l) => l.length > width);
348
+ const hidden = lines.length > shown || lines.some((l) => l.length > width);
268
349
  const details = hidden || call
269
- ? [
270
- ...(call ? [call] : []),
271
- ...(sub.length ? [dim(` sub-agent ran ${sub.length} tool call${sub.length > 1 ? "s" : ""}:`), ...sub.map((l) => dim(` ${l}`))] : []),
272
- ...(hidden ? [detailsOf(lines, d.isError ? red : (s) => s, MAX_DETAIL_LINES)] : []),
273
- ].join("\n")
350
+ ? [...(call ? [call] : []), ...(hidden ? [detailsOf(lines, d.isError ? red : (s) => s, MAX_DETAIL_LINES)] : [])].join("\n")
274
351
  : undefined;
275
352
  if (d.isError)
276
353
  screen.amend(d.toolUseId, red(`⎿ ${lines.slice(0, shown).map((l) => clip(l, width)).join("\n ")}`), { details });
@@ -281,8 +358,9 @@ export function transcript(opts) {
281
358
  case "tool.interrupted": {
282
359
  const d = e.data;
283
360
  doneProgress(d.toolUseId);
284
- tasks.delete(d.toolUseId);
285
361
  calls.delete(d.toolUseId);
362
+ befores.delete(d.toolUseId);
363
+ inputs.delete(d.toolUseId);
286
364
  screen.amend(d.toolUseId, yellow("⎿ interrupted before finishing; not retried"));
287
365
  return;
288
366
  }
@@ -307,42 +385,33 @@ export function transcript(opts) {
307
385
  screen.log(dim("[send /retry to request again without adding a message]"));
308
386
  return;
309
387
  }
310
- case "jade/compact/compacted": {
311
- const d = e.data;
312
- void countUsage(e);
313
- screen.log(dim(`[compacted ${d.upTo - d.from} messages, ~${d.before} tokens before]`));
314
- return;
315
- }
316
- case "jade/checks/checked": {
317
- const d = e.data;
318
- const bad = d.summary.filter((s) => s.problems > 0 || s.others || s.failed);
319
- const details = d.report ? detailsOf(d.report.split("\n").slice(1), (s) => s, MAX_DETAIL_LINES) : undefined;
320
- if (bad.length === 0) {
321
- screen.log(dim(` ✓ checks passed: ${d.summary.map((s) => s.name).join(", ")}`), { details });
322
- }
323
- else {
324
- const what = bad.map((s) => s.failed
325
- ? `${s.name} ${s.failed}`
326
- : `${s.name}: ${[s.problems > 0 ? `${s.problems} problem${s.problems > 1 ? "s" : ""} in changed files` : "", s.others ? `${s.others} new elsewhere` : ""]
327
- .filter(Boolean)
328
- .join(", ")}`);
329
- screen.log(yellow(` ⚠ checks: ${what.join("; ")}`), { details });
330
- }
331
- return;
332
- }
333
- case "jade/policy/reviewed":
334
- // 审查的结果显示在工具调用那一行,这里只计用量
335
- void countUsage(e);
336
- return;
337
- case "jade/compact/trimmed": {
338
- const d = e.data;
339
- screen.log(dim(`[cleared old tool output, ~${d.saved} tokens]`));
340
- return;
341
- }
342
388
  default:
343
- return renderPluginNotice(e);
389
+ return renderPluginEvent(e);
344
390
  }
345
391
  }
392
+ /**
393
+ * 插件的事件:用量照常统计;插件为它注册了渲染器时由渲染器显示,
394
+ * 否则只有 ctx.emit("notice", { text, level? }) 写入的提示显示成 [插件 id] 文本
395
+ */
396
+ function renderPluginEvent(e) {
397
+ if (e.origin.by !== "plugin")
398
+ return;
399
+ void countUsage(e);
400
+ const found = opts.eventRenderer?.(e.type);
401
+ if (!found)
402
+ return renderPluginNotice(e);
403
+ let shown;
404
+ try {
405
+ shown = found.renderer.render(e.data);
406
+ }
407
+ catch (err) {
408
+ return renderFailed(found.plugin, e.type, err);
409
+ }
410
+ if (!shown || typeof shown.line !== "string")
411
+ return;
412
+ const details = typeof shown.details === "string" && shown.details ? shown.details.replace(/^/gm, " ") : undefined;
413
+ screen.log(shown.line, { details });
414
+ }
346
415
  /** 插件用 ctx.emit("notice", { text, level? }) 写入的提示,显示成 [插件 id] 文本 */
347
416
  function renderPluginNotice(e) {
348
417
  if (e.origin.by !== "plugin" || !e.type.endsWith("/notice"))
@@ -358,7 +427,7 @@ export function transcript(opts) {
358
427
  for (const e of events) {
359
428
  await countUsage(e);
360
429
  if (e.type === "model.responded")
361
- showContext(e.data.usage);
430
+ showContext(e);
362
431
  }
363
432
  return;
364
433
  }
@@ -379,10 +448,10 @@ export function transcript(opts) {
379
448
  const d = e.data;
380
449
  if (d.kind === "approval") {
381
450
  const name = toolNames.get(d.toolUseId) ?? "?";
382
- const head = `${bold(name)}(${summarize(cwd, name, asked.get(d.toolUseId))})`;
451
+ const head = `${bold(name)}(${summary(name, asked.get(d.toolUseId))})`;
383
452
  screen.log(d.approved ? green(`✓ ${head}`) : red(`✗ ${head}`) + dim(d.reason ? ` — ${clip(d.reason, 200)}` : ""), {
384
453
  id: d.toolUseId,
385
- details: callDetails(name, asked.get(d.toolUseId)),
454
+ details: details(name, asked.get(d.toolUseId)),
386
455
  });
387
456
  continue;
388
457
  }
@@ -405,4 +474,3 @@ export function transcript(opts) {
405
474
  }
406
475
  return self;
407
476
  }
408
- //# sourceMappingURL=transcript.js.map