@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
@@ -0,0 +1,282 @@
1
+ // jade/suggest:每一轮正常结束后,预测用户下一条想发的消息,灰色显示在输入框里,Tab 或 → 接受。默认关着(enabled)。
2
+ //
3
+ // 模型经 models@1:配置 model 是 /model 保存过的模型名,不设时用会话的模型。
4
+ // /suggest 在 TUI 里开关、选模型,马上生效,记在 $JADE_HOME/state/suggest.json,盖过 config.json 里的 enabled 和 model。
5
+ // 对话从 context.project(每次请求模型前的消息)和 model.after(这一轮最后的回复)取,轮次结束从 turn.ended 事件知道。
6
+ // 从旧 jade 的 examples/plugins/suggest 移植;提示词、对话的整理和截取、回复的清理参考 dsh-ghost-prompt。
7
+ import { randomBytes } from "node:crypto";
8
+ import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
9
+ import path from "node:path";
10
+ import { definePlugin } from "../../dist/api.js";
11
+ export const SYSTEM = [
12
+ "You predict the next message the USER will type to an AI coding assistant.",
13
+ "You are given the recent conversation. Write the single message the user is most likely to send next, exactly as they would type it.",
14
+ "Rules:",
15
+ '- Write from the user\'s point of view, addressed to the assistant (e.g. "run the tests", "commit this", "yes, go ahead").',
16
+ "- Match the language and tone the user has been writing in. If the user writes Chinese, answer in Chinese.",
17
+ "- Keep it short: one sentence, at most about 20 words or 40 CJK characters.",
18
+ "- Prefer the obvious next step: answering a question the assistant just asked, approving a proposed plan, verifying or continuing the work.",
19
+ "- Never repeat a request the user already made, and never invent facts, file names or numbers not in the conversation.",
20
+ "- If no next message is reasonably predictable, output exactly: NONE",
21
+ 'Output only the message text on one line. No quotes, no prefix like "User:", no explanation, no Markdown.',
22
+ ].join("\n");
23
+ /** 送给预测模型的最近对话(字符),从最新的往前取 */
24
+ const MAX_CONTEXT_CHARS = 8000;
25
+ /** 每条消息最多这么多字,超出时留头尾 */
26
+ const PER_MESSAGE_CHARS = 2400;
27
+ /** 一次预测的时限 */
28
+ const TIMEOUT_MS = 30_000;
29
+ /** 太长的消息留头和尾,中间最不要紧 */
30
+ function clip(text, max) {
31
+ if (text.length <= max)
32
+ return text;
33
+ const half = Math.floor((max - 5) / 2);
34
+ return `${text.slice(0, half)}\n…\n${text.slice(-half)}`;
35
+ }
36
+ /** 一条消息里给预测模型看的文字:用户消息只取用户自己打的字(工具结果、插件附的说明不算),回复里的工具调用只留名字 */
37
+ function textOf(m) {
38
+ const parts = [];
39
+ for (const b of m.content) {
40
+ if (b.kind === "text" && b.text.trim() && (m.role === "assistant" || b.origin.by === "user"))
41
+ parts.push(b.text.trim());
42
+ else if (b.kind === "tool_use" && m.role === "assistant")
43
+ parts.push(`[called tool: ${b.name}]`);
44
+ }
45
+ return parts.join("\n");
46
+ }
47
+ /** 整理成用户、助手交替的对话:没有文字的消息去掉,相邻同一方的合并(一轮里助手的几步并成一条) */
48
+ export function transcriptOf(messages) {
49
+ const out = [];
50
+ for (const m of messages) {
51
+ const text = textOf(m);
52
+ if (!text)
53
+ continue;
54
+ const last = out.at(-1);
55
+ if (last?.role === m.role)
56
+ last.text += `\n${text}`;
57
+ else
58
+ out.push({ role: m.role, text });
59
+ }
60
+ return out;
61
+ }
62
+ const frameLine = (e) => `<${e.role}>\n${clip(e.text, PER_MESSAGE_CHARS)}\n</${e.role}>`;
63
+ /** 从最新的往前放,放不下就停;最后一条总是放进去 */
64
+ export function frame(transcript, budget = MAX_CONTEXT_CHARS) {
65
+ const lines = [];
66
+ let used = 0;
67
+ for (let i = transcript.length - 1; i >= 0; i--) {
68
+ const line = frameLine(transcript[i]);
69
+ if (lines.length > 0 && used + line.length > budget)
70
+ break;
71
+ lines.unshift(line);
72
+ used += line.length;
73
+ }
74
+ return ["Recent conversation, oldest first:", "", lines.join("\n\n"), "", "Predict the user's next message."].join("\n");
75
+ }
76
+ const LEADING_PREFIX = /^(?:user|用户)\s*[::]\s*/i;
77
+ const LEADING_QUOTES = /^["'“”‘’`「『]+/;
78
+ const TRAILING_QUOTES = /["'“”‘’`」』]+$/;
79
+ /** 模型回复的第一行整理成建议:去掉 "User:" 前缀和包着的引号;NONE 或空的时候 undefined */
80
+ export function tidy(reply) {
81
+ let line = reply.trimStart().split(/\r?\n/)[0].trim().replace(LEADING_PREFIX, "");
82
+ if (LEADING_QUOTES.test(line))
83
+ line = line.replace(LEADING_QUOTES, "").replace(TRAILING_QUOTES, "").trim();
84
+ if (!line || /^none\.?$/i.test(line))
85
+ return undefined;
86
+ return line.length > 300 ? `${line.slice(0, 299)}…` : line;
87
+ }
88
+ /** process() 里读好、/suggest 改的设置,session() 里每次预测时读 */
89
+ let settings = { enabled: false, model: undefined };
90
+ /** 设置改了时通知每个会话(关掉时去掉已经显示的建议) */
91
+ const changed = new Set();
92
+ /** state/suggest.json 里 /suggest 记下的设置;没有、读不了或格式不对的键不算 */
93
+ async function readState(file) {
94
+ try {
95
+ const data = JSON.parse(await readFile(file, "utf8"));
96
+ return {
97
+ ...(typeof data.enabled === "boolean" ? { enabled: data.enabled } : {}),
98
+ // 空字符串表示用会话的模型
99
+ ...(typeof data.model === "string" ? { model: data.model.trim() || undefined } : {}),
100
+ };
101
+ }
102
+ catch {
103
+ return {};
104
+ }
105
+ }
106
+ async function writeState(file, s) {
107
+ await mkdir(path.dirname(file), { recursive: true });
108
+ const tmp = `${file}.${process.pid}.${randomBytes(4).toString("hex")}.tmp`;
109
+ await writeFile(tmp, `${JSON.stringify({ enabled: s.enabled, model: s.model ?? "" }, null, 2)}\n`);
110
+ await rename(tmp, file);
111
+ }
112
+ export default definePlugin({
113
+ async process(ctx) {
114
+ const file = path.join(ctx.home, "state", "suggest.json");
115
+ const raw = ctx.config.model;
116
+ if (raw !== undefined && typeof raw !== "string")
117
+ ctx.service("ui@1")?.notify(`jade/suggest: model must be a model name, got ${JSON.stringify(raw)}; using the session's model`, "warning");
118
+ settings = {
119
+ enabled: ctx.config.enabled === true,
120
+ model: typeof raw === "string" && raw.trim() ? raw.trim() : undefined,
121
+ ...(await readState(file)),
122
+ };
123
+ const models = ctx.require("models@1");
124
+ const describe = () => `suggestions are ${settings.enabled ? "on" : "off"}, predicted by ${settings.model ? `the saved model ${settings.model}` : "the session's model"}`;
125
+ const update = async (next) => {
126
+ settings = { ...settings, ...next };
127
+ for (const fn of changed)
128
+ fn();
129
+ await writeState(file, settings);
130
+ return `${describe()}.`;
131
+ };
132
+ ctx.service("commands@1")?.register({
133
+ name: "suggest",
134
+ args: "[on|off|model [name]]",
135
+ description: "predict your next message after each turn (one more model request per turn), and which model predicts",
136
+ // 只改插件自己的设置
137
+ instant: true,
138
+ async run(args, c) {
139
+ const [sub = "", ...rest] = args.trim().split(/\s+/);
140
+ if (sub === "on" || sub === "off")
141
+ return update({ enabled: sub === "on" });
142
+ if (sub === "model") {
143
+ const saved = (await models.saved?.()) ?? [];
144
+ let name = rest.join(" ");
145
+ if (!name) {
146
+ const SESSION = "\0session";
147
+ const picked = await c.ui.select({
148
+ title: "Which model predicts your next message?",
149
+ options: [
150
+ { label: "The session's model", value: SESSION },
151
+ ...saved.map((m) => ({ label: m, value: m, ...(m === settings.model ? { hint: "current" } : {}) })),
152
+ ],
153
+ }, c.signal);
154
+ if (picked === undefined)
155
+ return;
156
+ name = picked === SESSION ? undefined : picked;
157
+ }
158
+ else if (models.saved && !saved.includes(name)) {
159
+ return `${name} is not a model saved by /model. ${saved.length ? `Saved: ${saved.join(", ")}.` : "Add one with /model first."}`;
160
+ }
161
+ return update({ model: name });
162
+ }
163
+ if (sub)
164
+ return "usage: /suggest [on|off|model [name]]";
165
+ return `${describe()}. /suggest on|off turns them on or off; /suggest model picks the model.`;
166
+ },
167
+ });
168
+ },
169
+ session(ctx) {
170
+ const input = ctx.input;
171
+ // 没有输入框的前端(-p)用不上
172
+ if (!input)
173
+ return;
174
+ const models = ctx.require("models@1");
175
+ /** 最近一次发给模型的消息,加上这一轮最后的回复 */
176
+ let messages = [];
177
+ let reply;
178
+ /** 正在进行的预测:新的一次请求开始、会话结束时中止 */
179
+ let pending;
180
+ ctx.signal.addEventListener("abort", () => pending?.abort());
181
+ // /suggest off:停下正在进行的预测,去掉已经显示的建议
182
+ const onChange = () => {
183
+ if (settings.enabled)
184
+ return;
185
+ pending?.abort();
186
+ input.hint(undefined);
187
+ };
188
+ changed.add(onChange);
189
+ ctx.signal.addEventListener("abort", () => changed.delete(onChange));
190
+ /** 上一次提示过的错误:同样的错误每轮都提示太吵,成功一次后清掉 */
191
+ let warned;
192
+ const warn = (e) => {
193
+ const message = e instanceof Error ? e.message : String(e);
194
+ if (message === warned)
195
+ return;
196
+ warned = message;
197
+ ctx.service("ui@1")?.notify(`jade/suggest: prediction failed (${settings.model ? `model ${settings.model}` : "the session's model"}): ${message}`, "warning");
198
+ };
199
+ async function predict() {
200
+ if (!settings.enabled)
201
+ return;
202
+ const { model } = settings;
203
+ const transcript = transcriptOf([...messages, ...(reply ? [reply] : [])]);
204
+ // 用户还没说过话,或者最后不是助手的回复:没有可回答的
205
+ if (!transcript.some((e) => e.role === "user") || transcript.at(-1)?.role !== "assistant")
206
+ return;
207
+ pending?.abort();
208
+ const mine = (pending = new AbortController());
209
+ // 第一行完整了就停:建议只要一行,后面的都会丢掉
210
+ const firstLine = new AbortController();
211
+ let streamed = "";
212
+ const onDelta = (d) => {
213
+ if (d.kind === "reset")
214
+ streamed = "";
215
+ else if (d.kind === "text")
216
+ streamed += d.text;
217
+ if (/\S[^\n]*\n/.test(streamed))
218
+ firstLine.abort();
219
+ };
220
+ const origin = { by: "plugin", id: ctx.plugin };
221
+ const request = {
222
+ system: [{ text: SYSTEM, stability: "stable", origin, trust: "trusted" }],
223
+ messages: [{ role: "user", content: [{ kind: "text", text: frame(transcript), origin, trust: "trusted" }] }],
224
+ tools: [],
225
+ };
226
+ let text;
227
+ const timeout = AbortSignal.timeout(TIMEOUT_MS);
228
+ try {
229
+ const res = await models.complete(request, {
230
+ signal: AbortSignal.any([mine.signal, firstLine.signal, timeout]),
231
+ onDelta,
232
+ ...(model ? { model } : {}),
233
+ });
234
+ text = res.content.flatMap((b) => (b.kind === "text" ? [b.text] : [])).join("");
235
+ }
236
+ catch (e) {
237
+ // 第一行完整后自己停下的,用已经收到的
238
+ if (firstLine.signal.aborted && !mine.signal.aborted)
239
+ text = streamed;
240
+ else {
241
+ // 超时、被中止不打扰用户;模型出错(配置不对之类)说一次,否则开着却什么都不显示,看不出为什么
242
+ if (!mine.signal.aborted && !timeout.aborted && !ctx.signal.aborted)
243
+ warn(e);
244
+ return;
245
+ }
246
+ }
247
+ warned = undefined;
248
+ const hint = tidy(text);
249
+ if (hint && !mine.signal.aborted)
250
+ input.hint(hint);
251
+ }
252
+ ctx.kernel.hook({
253
+ // 每次请求模型前:记下这次发出的消息,不改它们。新的请求说明新的一轮(或下一步)开始了,之前的建议作废
254
+ kind: "transform",
255
+ point: "context.project",
256
+ optional: true,
257
+ fn: (msgs) => {
258
+ messages = msgs;
259
+ reply = undefined;
260
+ pending?.abort();
261
+ input.hint(undefined);
262
+ return undefined;
263
+ },
264
+ });
265
+ ctx.kernel.hook({
266
+ kind: "observe",
267
+ point: "model.after",
268
+ fn: (res) => {
269
+ reply = { role: "assistant", content: res.content };
270
+ },
271
+ });
272
+ ctx.kernel.hook({
273
+ // 这一轮正常结束(不是中断、出错或被截断)时预测。不 await:hook 有时限,预测在后台进行
274
+ kind: "observe",
275
+ point: "event",
276
+ fn: (e) => {
277
+ if (e.type === "turn.ended" && e.data.reason === "end")
278
+ void predict();
279
+ },
280
+ });
281
+ },
282
+ });
@@ -0,0 +1,23 @@
1
+ {
2
+ "id": "jade/suggest",
3
+ "version": "0.1.0",
4
+ "api": "^1",
5
+ "entry": "./index.js",
6
+ "requires": [
7
+ "models@1"
8
+ ],
9
+ "optional": [
10
+ "ui@1",
11
+ "commands@1"
12
+ ],
13
+ "config": {
14
+ "enabled": {
15
+ "default": false,
16
+ "description": "after each turn, predict your next message and show it in gray in the input box (Tab or → accepts it); each prediction is one more model request; /suggest on|off overrides it"
17
+ },
18
+ "model": {
19
+ "default": "",
20
+ "description": "the model that predicts, by a name saved with /model; empty uses the session's model; /suggest model overrides it"
21
+ }
22
+ }
23
+ }
@@ -0,0 +1,151 @@
1
+ // jade/task:task 工具,把调研交给只读的子 Agent(见 subagent.ts)。
2
+ //
3
+ // 子 Agent 用哪些工具:插件经 task@1 登记只读工具(jade/fs 登记 read_file、list_dir、glob、grep),
4
+ // 登记随登记者的作用域撤销。主会话里的工具对象是各插件私有的,子 Agent 拿到的是登记者另给的一份。
5
+ import { definePlugin } from "../../dist/api.js";
6
+ import { taskTool } from "./subagent.js";
7
+ import { clip, dim, red } from "./style.js";
8
+ const DEFAULT_MAX_STEPS = 40;
9
+ const MAX_DETAIL_LINES = 40;
10
+ /** 登记的只读工具,按登记顺序 */
11
+ const registry = [];
12
+ /** 这次启动子 Agent 时给它的工具:同名的取最后登记的那个,when 返回 false 或出错的不给 */
13
+ function available() {
14
+ const latest = new Map();
15
+ for (const r of registry) {
16
+ latest.delete(r.tool.name);
17
+ latest.set(r.tool.name, r);
18
+ }
19
+ return [...latest.values()].flatMap((r) => {
20
+ try {
21
+ return !r.when || r.when() ? [r.tool] : [];
22
+ }
23
+ catch {
24
+ return [];
25
+ }
26
+ });
27
+ }
28
+ /** 子 Agent 的审批一次问一个:并行的几个子 Agent 不同时弹对话框 */
29
+ let asking = Promise.resolve();
30
+ export default definePlugin({
31
+ process(ctx) {
32
+ ctx.provide("task@1", (caller) => ({
33
+ tool(tool, opts) {
34
+ if (typeof tool?.name !== "string" || typeof tool.execute !== "function")
35
+ throw new Error("task.tool: a tool needs a name and execute");
36
+ if (tool.effect !== "read")
37
+ throw new Error(`task.tool: ${tool.name} is not read-only (effect ${JSON.stringify(tool.effect)}); sub-agents only get read-only tools`);
38
+ // 同一个插件重复登记是正常的:换会话时新会话先登记,旧会话随后撤销它的那份;取最后登记的
39
+ const taken = registry.find((r) => r.tool.name === tool.name && r.plugin !== caller.plugin);
40
+ if (taken)
41
+ throw new Error(`task.tool: ${tool.name} is already registered by ${taken.plugin}`);
42
+ if (opts?.when !== undefined && typeof opts.when !== "function")
43
+ throw new Error("task.tool: when must be a function");
44
+ const entry = { tool, plugin: caller.plugin, ...(opts?.when ? { when: opts.when } : {}) };
45
+ registry.push(entry);
46
+ const revoke = () => {
47
+ const i = registry.indexOf(entry);
48
+ if (i !== -1)
49
+ registry.splice(i, 1);
50
+ };
51
+ caller.onDispose(revoke);
52
+ return revoke;
53
+ },
54
+ }));
55
+ const renderers = ctx.service("renderers@1");
56
+ if (renderers) {
57
+ // 运行中每个只有一行进度(标签、调用过几个工具、正在做什么),并行的几个靠标签分清;结束时把它调用过的工具放进结果的折叠内容里
58
+ const labels = new Map();
59
+ const steps = new Map();
60
+ const line = (id, what) => {
61
+ const n = steps.get(id)?.length ?? 0;
62
+ return dim(` ↳ ${labels.get(id) ?? "sub-agent"}${n ? ` (${n} tool call${n > 1 ? "s" : ""})` : ""} · ${what}`);
63
+ };
64
+ renderers.tool({
65
+ tool: "task",
66
+ summary: (input) => String(input?.description ?? ""),
67
+ progress(update, { toolUseId: id, summary }) {
68
+ const p = update;
69
+ if (p?.kind === "task-start") {
70
+ labels.set(id, p.description);
71
+ return line(id, "starting");
72
+ }
73
+ if (p?.kind === "task-model")
74
+ return line(id, "thinking");
75
+ if (p?.kind === "task-tool") {
76
+ const step = `${p.decision === "deny" ? "✗" : "·"} ${p.name}(${summary(p.name, p.input)})`;
77
+ steps.set(id, [...(steps.get(id) ?? []), step]);
78
+ return line(id, step);
79
+ }
80
+ return undefined;
81
+ },
82
+ result({ toolUseId: id, text, isError }) {
83
+ const sub = steps.get(id) ?? [];
84
+ steps.delete(id);
85
+ labels.delete(id);
86
+ // 没调用过工具时用默认的显示
87
+ if (!sub.length)
88
+ return undefined;
89
+ const lines = text.split("\n");
90
+ const shown = lines.slice(0, MAX_DETAIL_LINES).map((l) => (isError ? red(l) : l));
91
+ if (lines.length > MAX_DETAIL_LINES)
92
+ shown.push(dim(`… (${lines.length - MAX_DETAIL_LINES} more lines)`));
93
+ return {
94
+ line: isError ? red(clip(lines[0] ?? "", 200)) : dim(`${clip(lines[0] ?? "", 160)}${lines.length > 1 ? ` (+${lines.length - 1} lines)` : ""}`),
95
+ details: [dim(`sub-agent ran ${sub.length} tool call${sub.length > 1 ? "s" : ""}:`), ...sub.map((l) => dim(` ${l}`)), ...shown].join("\n"),
96
+ };
97
+ },
98
+ });
99
+ }
100
+ },
101
+ session(ctx) {
102
+ const models = ctx.require("models@1");
103
+ /** 跑完、还没记进日志的子 Agent 用量,按 task 调用的 toolUseId */
104
+ const usage = new Map();
105
+ const configured = ctx.config.maxSteps;
106
+ const maxSteps = typeof configured === "number" && Number.isInteger(configured) && configured > 0 ? configured : DEFAULT_MAX_STEPS;
107
+ const approve = (call, signal) => {
108
+ const ui = ctx.service("ui@1");
109
+ if (!ui?.interactive)
110
+ return Promise.resolve({ approved: false, reason: "Nobody can approve this action for a sub-agent. Report what you need instead." });
111
+ const ask = asking.then(async () => {
112
+ const choice = await ui.select({
113
+ title: `A sub-agent wants to ${call.why}. Allow it?`,
114
+ detail: `${call.name} ${clip(JSON.stringify(call.input), 2000)}`,
115
+ options: [
116
+ { label: "Yes", value: "yes" },
117
+ { label: "No", value: "no" },
118
+ ],
119
+ }, signal);
120
+ return choice === "yes" ? { approved: true } : { approved: false, reason: "The user denied this action." };
121
+ });
122
+ asking = ask.catch(() => { });
123
+ return ask;
124
+ };
125
+ ctx.kernel.tool(taskTool({
126
+ cwd: ctx.cwd,
127
+ provider: { id: ctx.plugin, complete: (req, o) => models.complete(req, o) },
128
+ tools: available,
129
+ maxSteps,
130
+ approve,
131
+ allowed: (call) => ctx.service("approval@1")?.allows(ctx.session.id, call) ?? false,
132
+ id: ctx.plugin,
133
+ usage: (toolUseId, u) => void usage.set(toolUseId, u),
134
+ }));
135
+ // 子 Agent 的用量记成本插件的事件(和压缩、审查的用量一样),界面据此计入会话用量;只能在 hook 里记
136
+ ctx.kernel.hook({
137
+ kind: "transform",
138
+ point: "tool.after",
139
+ fn: async (outcome, hook) => {
140
+ const u = usage.get(outcome.call.toolUseId);
141
+ if (!u)
142
+ return undefined;
143
+ usage.delete(outcome.call.toolUseId);
144
+ await hook.emit("subagent", { toolUseId: outcome.call.toolUseId, usage: u });
145
+ return undefined;
146
+ },
147
+ });
148
+ // 被中断的调用不经过 tool.after,一轮结束时还留着的不会再用到
149
+ ctx.kernel.hook({ kind: "observe", point: "event", fn: (e) => void (e.type === "turn.ended" && usage.clear()) });
150
+ },
151
+ });
@@ -0,0 +1,23 @@
1
+ {
2
+ "id": "jade/task",
3
+ "version": "0.2.0",
4
+ "api": "^1",
5
+ "entry": "./index.js",
6
+ "provides": [
7
+ "task@1"
8
+ ],
9
+ "requires": [
10
+ "models@1"
11
+ ],
12
+ "optional": [
13
+ "ui@1",
14
+ "renderers@1",
15
+ "approval@1"
16
+ ],
17
+ "config": {
18
+ "maxSteps": {
19
+ "default": 40,
20
+ "description": "how many responses a sub-agent may make before it is asked for its report"
21
+ }
22
+ }
23
+ }
@@ -0,0 +1,14 @@
1
+ // 显示用的小工具:截断和 ANSI 颜色。插件之间不共享代码(只能共享类型),所以这里也有一份(同 jade/fs 的 style.ts)。
2
+ export const clip = (s, n) => (s.length > n ? s.slice(0, n) + "…" : s);
3
+ // 设了 NO_COLOR(非空)或标准输出不是终端时不输出颜色,见 https://no-color.org
4
+ const colors = Boolean(process.stdout.isTTY) && !process.env.NO_COLOR;
5
+ /**
6
+ * 每种样式用自己的关闭码,不用 \x1b[0m 全部重置:外面套着别的样式时,后面的文字仍保持外层样式。
7
+ * 里面出现同一个关闭码(例如 dim 里套 bold,两者都用 22 关闭)时紧接着重新打开外层的样式
8
+ */
9
+ const paint = (open, close) => (s) => colors ? `\x1b[${open}m${s.replaceAll(`\x1b[${close}m`, `\x1b[${close}m\x1b[${open}m`)}\x1b[${close}m` : s;
10
+ export const dim = paint("2", "22");
11
+ export const red = paint("31", "39");
12
+ export const green = paint("32", "39");
13
+ export const yellow = paint("33", "39");
14
+ export const bold = paint("1", "22");