@uncarved/jade 0.1.3 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (455) hide show
  1. package/README.md +161 -150
  2. package/bin/jade.js +14 -25
  3. package/dist/api.d.ts +266 -0
  4. package/dist/api.js +38 -0
  5. package/dist/api.js.map +1 -0
  6. package/dist/config.d.ts +13 -32
  7. package/dist/config.js +39 -121
  8. package/dist/config.js.map +1 -1
  9. package/dist/fetch.d.ts +20 -0
  10. package/dist/fetch.js +190 -0
  11. package/dist/fetch.js.map +1 -0
  12. package/dist/hash.d.ts +2 -0
  13. package/dist/hash.js +42 -0
  14. package/dist/hash.js.map +1 -0
  15. package/dist/host.d.ts +71 -0
  16. package/dist/host.js +400 -0
  17. package/dist/host.js.map +1 -0
  18. package/dist/index.d.ts +11 -30
  19. package/dist/index.js +11 -30
  20. package/dist/index.js.map +1 -1
  21. package/dist/install.d.ts +78 -0
  22. package/dist/install.js +292 -0
  23. package/dist/install.js.map +1 -0
  24. package/dist/main.d.ts +1 -2
  25. package/dist/main.js +160 -1362
  26. package/dist/main.js.map +1 -1
  27. package/dist/manifest.d.ts +23 -0
  28. package/dist/manifest.js +159 -0
  29. package/dist/manifest.js.map +1 -0
  30. package/dist/membrane.d.ts +33 -0
  31. package/dist/membrane.js +140 -0
  32. package/dist/membrane.js.map +1 -0
  33. package/dist/remote.d.ts +10 -0
  34. package/dist/remote.js +292 -0
  35. package/dist/remote.js.map +1 -0
  36. package/dist/rescue.d.ts +10 -0
  37. package/dist/rescue.js +216 -0
  38. package/dist/rescue.js.map +1 -0
  39. package/dist/resolve.d.ts +34 -0
  40. package/dist/resolve.js +178 -0
  41. package/dist/resolve.js.map +1 -0
  42. package/dist/rpc.d.ts +26 -0
  43. package/dist/rpc.js +144 -0
  44. package/dist/rpc.js.map +1 -0
  45. package/dist/secrets.d.ts +12 -0
  46. package/dist/secrets.js +125 -0
  47. package/dist/secrets.js.map +1 -0
  48. package/dist/session.d.ts +45 -0
  49. package/dist/session.js +401 -0
  50. package/dist/session.js.map +1 -0
  51. package/dist/source.d.ts +12 -0
  52. package/dist/source.js +72 -0
  53. package/dist/source.js.map +1 -0
  54. package/dist/state.d.ts +37 -0
  55. package/dist/state.js +93 -0
  56. package/dist/state.js.map +1 -0
  57. package/dist/update.d.ts +2 -0
  58. package/dist/update.js +6 -3
  59. package/dist/update.js.map +1 -1
  60. package/package.json +10 -8
  61. package/plugins/approval/index.ts +311 -0
  62. package/plugins/approval/plugin.json +22 -0
  63. package/{src/plugins → plugins/approval}/policy.ts +45 -104
  64. package/{src/plugins → plugins/approval}/review.ts +62 -16
  65. package/plugins/ask/index.ts +159 -0
  66. package/plugins/ask/plugin.json +8 -0
  67. package/plugins/budget/index.ts +38 -0
  68. package/plugins/budget/plugin.json +13 -0
  69. package/{src/plugins → plugins/checks}/checks.ts +48 -38
  70. package/plugins/checks/index.ts +158 -0
  71. package/plugins/checks/plugin.json +14 -0
  72. package/plugins/checks/project.ts +81 -0
  73. package/plugins/commands/index.ts +76 -0
  74. package/plugins/commands/plugin.json +7 -0
  75. package/{src/plugins → plugins/compact}/compact.ts +80 -39
  76. package/plugins/compact/index.ts +115 -0
  77. package/plugins/compact/plugin.json +17 -0
  78. package/plugins/compact/style.ts +17 -0
  79. package/plugins/continue/index.ts +58 -0
  80. package/plugins/continue/plugin.json +13 -0
  81. package/{src/ui → plugins/fs}/diff.ts +2 -2
  82. package/{src/tools → plugins/fs}/fs.ts +89 -46
  83. package/{src/tools → plugins/fs}/grep.ts +36 -8
  84. package/plugins/fs/index.ts +37 -0
  85. package/plugins/fs/plugin.json +7 -0
  86. package/{src/ui → plugins/fs}/renderers.ts +25 -70
  87. package/plugins/fs/style.ts +18 -0
  88. package/plugins/fs/sys.ts +81 -0
  89. package/plugins/keys/index.ts +53 -0
  90. package/plugins/keys/plugin.json +7 -0
  91. package/plugins/mcp/index.ts +192 -0
  92. package/{src → plugins/mcp}/mcp.ts +32 -32
  93. package/plugins/mcp/plugin.json +7 -0
  94. package/plugins/mcp/project.ts +93 -0
  95. package/plugins/memory/index.ts +105 -0
  96. package/{src → plugins/memory}/memory.ts +20 -2
  97. package/plugins/memory/notes.ts +43 -0
  98. package/plugins/memory/plugin.json +7 -0
  99. package/plugins/memory/style.ts +17 -0
  100. package/plugins/mentions/attach.ts +127 -0
  101. package/plugins/mentions/index.ts +99 -0
  102. package/plugins/mentions/plugin.json +7 -0
  103. package/plugins/mentions/style.ts +17 -0
  104. package/plugins/models/config.ts +53 -0
  105. package/plugins/models/configure.ts +455 -0
  106. package/plugins/models/context.ts +32 -0
  107. package/plugins/models/index.ts +213 -0
  108. package/plugins/models/plugin.json +8 -0
  109. package/{src → plugins/models}/provider.ts +16 -119
  110. package/plugins/models/saved.ts +94 -0
  111. package/plugins/modes/index.ts +222 -0
  112. package/plugins/modes/plugin.json +9 -0
  113. package/plugins/plugins/index.ts +38 -0
  114. package/plugins/plugins/plugin.json +7 -0
  115. package/plugins/print/index.ts +160 -0
  116. package/plugins/print/plugin.json +8 -0
  117. package/plugins/prompts/index.ts +111 -0
  118. package/plugins/prompts/plugin.json +8 -0
  119. package/plugins/prompts/prompts.ts +258 -0
  120. package/plugins/prompts/results.ts +63 -0
  121. package/plugins/prompts/sys.ts +84 -0
  122. package/plugins/renderers/index.ts +78 -0
  123. package/plugins/renderers/plugin.json +7 -0
  124. package/plugins/repeats/index.ts +165 -0
  125. package/plugins/repeats/plugin.json +6 -0
  126. package/plugins/schedule/cron.ts +74 -0
  127. package/plugins/schedule/index.ts +292 -0
  128. package/plugins/schedule/plugin.json +13 -0
  129. package/plugins/schedule/store.ts +149 -0
  130. package/plugins/scratch/index.ts +31 -0
  131. package/plugins/scratch/plugin.json +7 -0
  132. package/plugins/screenshot/index.ts +40 -0
  133. package/plugins/screenshot/plugin.json +7 -0
  134. package/plugins/screenshot/sys.ts +84 -0
  135. package/{src/tools/screenshot.ts → plugins/screenshot/tool.ts} +6 -6
  136. package/plugins/sessions/index.ts +148 -0
  137. package/plugins/sessions/plugin.json +8 -0
  138. package/plugins/shell/index.ts +33 -0
  139. package/plugins/shell/plugin.json +17 -0
  140. package/plugins/shell/renderers.ts +45 -0
  141. package/plugins/shell/service.ts +44 -0
  142. package/{src/tools → plugins/shell}/shell.ts +31 -20
  143. package/{src → plugins/shell}/sys.ts +2 -43
  144. package/plugins/skills/index.ts +96 -0
  145. package/plugins/skills/plugin.json +7 -0
  146. package/plugins/skills/project.ts +49 -0
  147. package/{src → plugins/skills}/skills.ts +4 -11
  148. package/plugins/suggest/index.ts +286 -0
  149. package/plugins/suggest/plugin.json +18 -0
  150. package/plugins/task/index.ts +168 -0
  151. package/plugins/task/plugin.json +15 -0
  152. package/plugins/task/style.ts +17 -0
  153. package/plugins/task/subagent.ts +343 -0
  154. package/plugins/todo/index.ts +93 -0
  155. package/plugins/todo/plugin.json +7 -0
  156. package/{src/ui → plugins/tui}/editor.ts +3 -0
  157. package/plugins/tui/frontend.ts +619 -0
  158. package/plugins/tui/index.ts +37 -0
  159. package/plugins/tui/mentions.ts +153 -0
  160. package/plugins/tui/plugin.json +10 -0
  161. package/{src/ui → plugins/tui}/render.ts +8 -2
  162. package/{src/ui → plugins/tui}/screen.ts +8 -3
  163. package/{src/ui → plugins/tui}/transcript.ts +79 -100
  164. package/{src/ui/tui.tsx → plugins/tui/tui.ts} +360 -392
  165. package/plugins/tui/vendor.ts +16 -0
  166. package/{src/tools → plugins/undo}/checkpoint.ts +45 -60
  167. package/plugins/undo/index.ts +143 -0
  168. package/plugins/undo/notes.ts +43 -0
  169. package/plugins/undo/plugin.json +7 -0
  170. package/plugins/undo/style.ts +17 -0
  171. package/plugins/update/index.ts +40 -0
  172. package/plugins/update/plugin.json +13 -0
  173. package/plugins/web/env.ts +78 -0
  174. package/plugins/web/index.ts +133 -0
  175. package/plugins/web/plugin.json +15 -0
  176. package/plugins/web/renderers.ts +11 -0
  177. package/{src/tools → plugins/web}/web.ts +64 -31
  178. package/plugins-dist/approval/index.js +287 -0
  179. package/plugins-dist/approval/plugin.json +28 -0
  180. package/{dist/plugins → plugins-dist/approval}/policy.js +41 -85
  181. package/{dist/plugins → plugins-dist/approval}/review.js +56 -10
  182. package/{dist/plugins → plugins-dist/approval}/schema.js +0 -1
  183. package/plugins-dist/ask/index.js +145 -0
  184. package/plugins-dist/ask/plugin.json +12 -0
  185. package/plugins-dist/budget/index.js +37 -0
  186. package/plugins-dist/budget/plugin.json +15 -0
  187. package/{dist/plugins → plugins-dist/checks}/checks.js +46 -35
  188. package/plugins-dist/checks/index.js +150 -0
  189. package/plugins-dist/checks/plugin.json +21 -0
  190. package/plugins-dist/checks/project.js +76 -0
  191. package/plugins-dist/commands/index.js +33 -0
  192. package/plugins-dist/commands/plugin.json +9 -0
  193. package/{dist/plugins → plugins-dist/compact}/compact.js +58 -34
  194. package/plugins-dist/compact/index.js +100 -0
  195. package/plugins-dist/compact/plugin.json +25 -0
  196. package/plugins-dist/compact/style.js +14 -0
  197. package/plugins-dist/continue/index.js +57 -0
  198. package/plugins-dist/continue/plugin.json +15 -0
  199. package/{dist/ui → plugins-dist/fs}/diff.js +2 -3
  200. package/{dist/tools → plugins-dist/fs}/fs.js +82 -46
  201. package/{dist/tools → plugins-dist/fs}/grep.js +36 -11
  202. package/plugins-dist/fs/index.js +39 -0
  203. package/plugins-dist/fs/plugin.json +10 -0
  204. package/{dist/ui → plugins-dist/fs}/renderers.js +24 -61
  205. package/plugins-dist/fs/style.js +15 -0
  206. package/plugins-dist/fs/sys.js +54 -0
  207. package/plugins-dist/keys/index.js +36 -0
  208. package/plugins-dist/keys/plugin.json +9 -0
  209. package/plugins-dist/mcp/index.js +187 -0
  210. package/{dist → plugins-dist/mcp}/mcp.js +34 -30
  211. package/plugins-dist/mcp/plugin.json +12 -0
  212. package/plugins-dist/mcp/project.js +90 -0
  213. package/plugins-dist/memory/index.js +94 -0
  214. package/{dist → plugins-dist/memory}/memory.js +21 -3
  215. package/plugins-dist/memory/notes.js +36 -0
  216. package/plugins-dist/memory/plugin.json +11 -0
  217. package/plugins-dist/memory/style.js +14 -0
  218. package/plugins-dist/mentions/attach.js +120 -0
  219. package/plugins-dist/mentions/index.js +87 -0
  220. package/plugins-dist/mentions/plugin.json +9 -0
  221. package/plugins-dist/mentions/style.js +14 -0
  222. package/plugins-dist/models/config.js +53 -0
  223. package/plugins-dist/models/configure.js +415 -0
  224. package/plugins-dist/models/context.js +27 -0
  225. package/plugins-dist/models/index.js +181 -0
  226. package/plugins-dist/models/plugin.json +14 -0
  227. package/{dist → plugins-dist/models}/provider.js +18 -81
  228. package/plugins-dist/models/saved.js +80 -0
  229. package/plugins-dist/modes/index.js +190 -0
  230. package/plugins-dist/modes/plugin.json +18 -0
  231. package/plugins-dist/plugins/index.js +37 -0
  232. package/plugins-dist/plugins/plugin.json +10 -0
  233. package/plugins-dist/print/index.js +172 -0
  234. package/plugins-dist/print/plugin.json +14 -0
  235. package/plugins-dist/prompts/index.js +85 -0
  236. package/plugins-dist/prompts/plugin.json +13 -0
  237. package/plugins-dist/prompts/prompts.js +231 -0
  238. package/plugins-dist/prompts/results.js +60 -0
  239. package/plugins-dist/prompts/sys.js +58 -0
  240. package/plugins-dist/renderers/index.js +36 -0
  241. package/plugins-dist/renderers/plugin.json +9 -0
  242. package/plugins-dist/repeats/index.js +165 -0
  243. package/plugins-dist/repeats/plugin.json +6 -0
  244. package/plugins-dist/schedule/cron.js +67 -0
  245. package/plugins-dist/schedule/index.js +281 -0
  246. package/plugins-dist/schedule/plugin.json +16 -0
  247. package/plugins-dist/schedule/store.js +125 -0
  248. package/plugins-dist/scratch/index.js +26 -0
  249. package/plugins-dist/scratch/plugin.json +10 -0
  250. package/plugins-dist/screenshot/index.js +35 -0
  251. package/plugins-dist/screenshot/plugin.json +11 -0
  252. package/plugins-dist/screenshot/sys.js +76 -0
  253. package/{dist/tools/screenshot.js → plugins-dist/screenshot/tool.js} +5 -4
  254. package/plugins-dist/sessions/index.js +136 -0
  255. package/plugins-dist/sessions/plugin.json +12 -0
  256. package/plugins-dist/shell/index.js +33 -0
  257. package/plugins-dist/shell/plugin.json +19 -0
  258. package/plugins-dist/shell/renderers.js +40 -0
  259. package/plugins-dist/shell/service.js +29 -0
  260. package/{dist/tools → plugins-dist/shell}/shell.js +31 -22
  261. package/{dist → plugins-dist/shell}/sys.js +2 -43
  262. package/plugins-dist/skills/index.js +90 -0
  263. package/plugins-dist/skills/plugin.json +12 -0
  264. package/plugins-dist/skills/project.js +47 -0
  265. package/{dist → plugins-dist/skills}/skills.js +3 -7
  266. package/plugins-dist/suggest/index.js +282 -0
  267. package/plugins-dist/suggest/plugin.json +23 -0
  268. package/plugins-dist/task/index.js +152 -0
  269. package/plugins-dist/task/plugin.json +23 -0
  270. package/plugins-dist/task/style.js +14 -0
  271. package/plugins-dist/task/subagent.js +284 -0
  272. package/{dist/tools/todo.js → plugins-dist/todo/index.js} +31 -9
  273. package/plugins-dist/todo/plugin.json +9 -0
  274. package/{dist/ui → plugins-dist/tui}/editor.js +3 -1
  275. package/plugins-dist/tui/frontend.js +609 -0
  276. package/{dist → plugins-dist/tui}/history.js +0 -1
  277. package/plugins-dist/tui/index.js +21 -0
  278. package/{dist/ui → plugins-dist/tui}/markdown.js +0 -1
  279. package/plugins-dist/tui/mentions.js +153 -0
  280. package/plugins-dist/tui/plugin.json +25 -0
  281. package/{dist/ui → plugins-dist/tui}/render.js +7 -3
  282. package/{dist/ui → plugins-dist/tui}/screen.js +6 -2
  283. package/{dist/ui → plugins-dist/tui}/transcript.js +79 -99
  284. package/{dist/ui → plugins-dist/tui}/tui.js +185 -54
  285. package/plugins-dist/tui/vendor.js +13822 -0
  286. package/{dist/tools → plugins-dist/undo}/checkpoint.js +48 -55
  287. package/plugins-dist/undo/index.js +143 -0
  288. package/plugins-dist/undo/notes.js +36 -0
  289. package/plugins-dist/undo/plugin.json +9 -0
  290. package/plugins-dist/undo/style.js +14 -0
  291. package/plugins-dist/update/index.js +34 -0
  292. package/plugins-dist/update/plugin.json +15 -0
  293. package/plugins-dist/web/env.js +80 -0
  294. package/plugins-dist/web/index.js +124 -0
  295. package/plugins-dist/web/plugin.json +21 -0
  296. package/plugins-dist/web/renderers.js +7 -0
  297. package/{dist/tools → plugins-dist/web}/web.js +56 -29
  298. package/sdk/python/__pycache__/jade_plugin.cpython-312.pyc +0 -0
  299. package/sdk/python/jade_plugin.py +380 -0
  300. package/src/api.ts +298 -0
  301. package/src/config.ts +32 -134
  302. package/src/fetch.ts +216 -0
  303. package/src/hash.ts +39 -0
  304. package/src/host.ts +429 -0
  305. package/src/index.ts +23 -30
  306. package/src/install.ts +355 -0
  307. package/src/main.ts +156 -1387
  308. package/src/manifest.ts +160 -0
  309. package/src/membrane.ts +142 -0
  310. package/src/remote.ts +288 -0
  311. package/src/rescue.ts +217 -0
  312. package/src/resolve.ts +199 -0
  313. package/src/rpc.ts +144 -0
  314. package/src/secrets.ts +122 -0
  315. package/src/session.ts +458 -0
  316. package/src/source.ts +83 -0
  317. package/src/state.ts +120 -0
  318. package/src/update.ts +265 -262
  319. package/LICENSE +0 -21
  320. package/dist/commands.d.ts +0 -50
  321. package/dist/commands.js +0 -126
  322. package/dist/commands.js.map +0 -1
  323. package/dist/context.d.ts +0 -17
  324. package/dist/context.js +0 -53
  325. package/dist/context.js.map +0 -1
  326. package/dist/distro.d.ts +0 -141
  327. package/dist/distro.js +0 -462
  328. package/dist/distro.js.map +0 -1
  329. package/dist/history.d.ts +0 -10
  330. package/dist/history.js.map +0 -1
  331. package/dist/mcp.d.ts +0 -114
  332. package/dist/mcp.js.map +0 -1
  333. package/dist/memory.d.ts +0 -19
  334. package/dist/memory.js.map +0 -1
  335. package/dist/mentions.d.ts +0 -35
  336. package/dist/mentions.js +0 -130
  337. package/dist/mentions.js.map +0 -1
  338. package/dist/plugin-cli.d.ts +0 -16
  339. package/dist/plugin-cli.js +0 -294
  340. package/dist/plugin-cli.js.map +0 -1
  341. package/dist/plugins/budget.d.ts +0 -9
  342. package/dist/plugins/budget.js +0 -30
  343. package/dist/plugins/budget.js.map +0 -1
  344. package/dist/plugins/builtins.d.ts +0 -10
  345. package/dist/plugins/builtins.js +0 -25
  346. package/dist/plugins/builtins.js.map +0 -1
  347. package/dist/plugins/checks.d.ts +0 -71
  348. package/dist/plugins/checks.js.map +0 -1
  349. package/dist/plugins/compact.d.ts +0 -26
  350. package/dist/plugins/compact.js.map +0 -1
  351. package/dist/plugins/core.d.ts +0 -47
  352. package/dist/plugins/core.js +0 -229
  353. package/dist/plugins/core.js.map +0 -1
  354. package/dist/plugins/host.d.ts +0 -52
  355. package/dist/plugins/host.js +0 -115
  356. package/dist/plugins/host.js.map +0 -1
  357. package/dist/plugins/install.d.ts +0 -68
  358. package/dist/plugins/install.js +0 -377
  359. package/dist/plugins/install.js.map +0 -1
  360. package/dist/plugins/loader.d.ts +0 -410
  361. package/dist/plugins/loader.js +0 -407
  362. package/dist/plugins/loader.js.map +0 -1
  363. package/dist/plugins/policy.d.ts +0 -98
  364. package/dist/plugins/policy.js.map +0 -1
  365. package/dist/plugins/prompts.d.ts +0 -43
  366. package/dist/plugins/prompts.js +0 -284
  367. package/dist/plugins/prompts.js.map +0 -1
  368. package/dist/plugins/repeats.d.ts +0 -16
  369. package/dist/plugins/repeats.js +0 -151
  370. package/dist/plugins/repeats.js.map +0 -1
  371. package/dist/plugins/review.d.ts +0 -18
  372. package/dist/plugins/review.js.map +0 -1
  373. package/dist/plugins/schema.d.ts +0 -2
  374. package/dist/plugins/schema.js.map +0 -1
  375. package/dist/plugins/sessions.d.ts +0 -7
  376. package/dist/plugins/sessions.js +0 -110
  377. package/dist/plugins/sessions.js.map +0 -1
  378. package/dist/provider.d.ts +0 -165
  379. package/dist/provider.js.map +0 -1
  380. package/dist/session-lifecycle.d.ts +0 -61
  381. package/dist/session-lifecycle.js +0 -167
  382. package/dist/session-lifecycle.js.map +0 -1
  383. package/dist/session-scope.d.ts +0 -53
  384. package/dist/session-scope.js +0 -116
  385. package/dist/session-scope.js.map +0 -1
  386. package/dist/sessions.d.ts +0 -28
  387. package/dist/sessions.js +0 -73
  388. package/dist/sessions.js.map +0 -1
  389. package/dist/skills.d.ts +0 -37
  390. package/dist/skills.js.map +0 -1
  391. package/dist/sys.d.ts +0 -51
  392. package/dist/sys.js.map +0 -1
  393. package/dist/tools/ask.d.ts +0 -11
  394. package/dist/tools/ask.js +0 -62
  395. package/dist/tools/ask.js.map +0 -1
  396. package/dist/tools/checkpoint.d.ts +0 -43
  397. package/dist/tools/checkpoint.js.map +0 -1
  398. package/dist/tools/fs.d.ts +0 -39
  399. package/dist/tools/fs.js.map +0 -1
  400. package/dist/tools/grep.d.ts +0 -6
  401. package/dist/tools/grep.js.map +0 -1
  402. package/dist/tools/screenshot.d.ts +0 -15
  403. package/dist/tools/screenshot.js.map +0 -1
  404. package/dist/tools/shell.d.ts +0 -55
  405. package/dist/tools/shell.js.map +0 -1
  406. package/dist/tools/task.d.ts +0 -39
  407. package/dist/tools/task.js +0 -117
  408. package/dist/tools/task.js.map +0 -1
  409. package/dist/tools/todo.d.ts +0 -10
  410. package/dist/tools/todo.js.map +0 -1
  411. package/dist/tools/web.d.ts +0 -53
  412. package/dist/tools/web.js.map +0 -1
  413. package/dist/ui/configure.d.ts +0 -20
  414. package/dist/ui/configure.js +0 -447
  415. package/dist/ui/configure.js.map +0 -1
  416. package/dist/ui/diff.d.ts +0 -20
  417. package/dist/ui/diff.js.map +0 -1
  418. package/dist/ui/editor.d.ts +0 -41
  419. package/dist/ui/editor.js.map +0 -1
  420. package/dist/ui/markdown.d.ts +0 -22
  421. package/dist/ui/markdown.js.map +0 -1
  422. package/dist/ui/render.d.ts +0 -14
  423. package/dist/ui/render.js.map +0 -1
  424. package/dist/ui/renderers.d.ts +0 -8
  425. package/dist/ui/renderers.js.map +0 -1
  426. package/dist/ui/screen.d.ts +0 -118
  427. package/dist/ui/screen.js.map +0 -1
  428. package/dist/ui/transcript.d.ts +0 -46
  429. package/dist/ui/transcript.js.map +0 -1
  430. package/dist/ui/tui.d.ts +0 -47
  431. package/dist/ui/tui.js.map +0 -1
  432. package/src/commands.ts +0 -144
  433. package/src/context.ts +0 -64
  434. package/src/distro.ts +0 -577
  435. package/src/mentions.ts +0 -135
  436. package/src/plugin-cli.ts +0 -278
  437. package/src/plugins/budget.ts +0 -37
  438. package/src/plugins/builtins.ts +0 -34
  439. package/src/plugins/core.ts +0 -257
  440. package/src/plugins/host.ts +0 -146
  441. package/src/plugins/install.ts +0 -429
  442. package/src/plugins/loader.ts +0 -742
  443. package/src/plugins/prompts.ts +0 -327
  444. package/src/plugins/repeats.ts +0 -157
  445. package/src/plugins/sessions.ts +0 -109
  446. package/src/session-lifecycle.ts +0 -194
  447. package/src/session-scope.ts +0 -135
  448. package/src/sessions.ts +0 -78
  449. package/src/tools/ask.ts +0 -72
  450. package/src/tools/task.ts +0 -149
  451. package/src/tools/todo.ts +0 -67
  452. package/src/ui/configure.ts +0 -471
  453. /package/{src/plugins → plugins/approval}/schema.ts +0 -0
  454. /package/{src → plugins/tui}/history.ts +0 -0
  455. /package/{src/ui → plugins/tui}/markdown.ts +0 -0
@@ -0,0 +1,84 @@
1
+ // 跨运行时的进程和可执行文件查找:只用 Node 的标准库,Bun 和 Node ≥22.18 下走同一套代码。
2
+ // 和 jade/shell 里的 sys.ts 是同一份:插件之间不共享代码(见 docs/design/jade.md 3.5)。
3
+
4
+ import { spawn as nodeSpawn } from "node:child_process";
5
+ import { accessSync, constants, statSync } from "node:fs";
6
+ import path from "node:path";
7
+
8
+ export interface Proc {
9
+ pid: number;
10
+ /** 进程退出时 resolve 退出码;被信号杀掉时为 null */
11
+ exited: Promise<number | null>;
12
+ kill(): void;
13
+ }
14
+
15
+ export interface SpawnOptions {
16
+ stdout?: "pipe" | "ignore";
17
+ stderr?: "pipe" | "ignore";
18
+ }
19
+
20
+ /**
21
+ * 启动进程,等到确实启动了才返回。程序不存在(ENOENT)等启动错误会 reject,
22
+ * 调用方用 try/catch 判断"没装",和 Bun.spawn 同步抛错的用法一致
23
+ */
24
+ export function spawn(cmd: string[], opts: SpawnOptions = {}): Promise<Proc> {
25
+ const child = nodeSpawn(cmd[0]!, cmd.slice(1), {
26
+ stdio: ["ignore", opts.stdout ?? "pipe", opts.stderr ?? "pipe"],
27
+ // Windows 上不弹出控制台窗口
28
+ windowsHide: true,
29
+ });
30
+ const exited = new Promise<number | null>((resolve) => child.once("exit", (code) => resolve(code)));
31
+ return new Promise((resolve, reject) => {
32
+ child.once("error", reject);
33
+ child.once("spawn", () => {
34
+ child.off("error", reject);
35
+ // 启动之后的错误(例如 kill 一个已经退出的进程)不应该变成未处理的异常
36
+ child.on("error", () => {});
37
+ resolve({ pid: child.pid!, exited, kill: () => void child.kill() });
38
+ });
39
+ });
40
+ }
41
+
42
+ /** which 的结果,按 PATH 和 PATHEXT 记;找不到的过一会儿再查 */
43
+ const found = new Map<string, { file: string | undefined; at: number }>();
44
+ const MISS_TTL_MS = 30_000;
45
+
46
+ /** 在 PATH 里找可执行文件,找不到返回 undefined。Windows 上按 PATHEXT 补扩展名;带路径分隔符时只检查那个文件 */
47
+ export function which(bin: string): string | undefined {
48
+ if (bin.includes("/") || (process.platform === "win32" && bin.includes("\\"))) return lookup(bin);
49
+ const key = `${bin}\0${process.env.PATH ?? process.env.Path ?? ""}\0${process.env.PATHEXT ?? ""}`;
50
+ const hit = found.get(key);
51
+ if (hit && (hit.file !== undefined || Date.now() - hit.at < MISS_TTL_MS)) return hit.file;
52
+ const file = lookup(bin);
53
+ found.set(key, { file, at: Date.now() });
54
+ return file;
55
+ }
56
+
57
+ function lookup(bin: string): string | undefined {
58
+ const win = process.platform === "win32";
59
+ const exts = win ? ["", ...(process.env.PATHEXT ?? ".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean)] : [""];
60
+ const ok = (file: string) => {
61
+ try {
62
+ if (!statSync(file).isFile()) return false;
63
+ if (!win) accessSync(file, constants.X_OK);
64
+ return true;
65
+ } catch {
66
+ return false;
67
+ }
68
+ };
69
+ const tryAll = (base: string) => {
70
+ for (const ext of exts) {
71
+ // Windows 上没有扩展名的文件不能直接执行
72
+ if (win && ext === "" && !path.extname(base)) continue;
73
+ if (ok(base + ext)) return base + ext;
74
+ }
75
+ return undefined;
76
+ };
77
+ if (bin.includes("/") || (win && bin.includes("\\"))) return tryAll(path.resolve(bin));
78
+ const dirs = (process.env.PATH ?? process.env.Path ?? "").split(path.delimiter).filter(Boolean);
79
+ for (const dir of dirs) {
80
+ const hit = tryAll(path.join(dir.replace(/^"(.*)"$/, "$1"), bin));
81
+ if (hit) return hit;
82
+ }
83
+ return undefined;
84
+ }
@@ -1,18 +1,20 @@
1
1
  // 截图工具:用本机的 Chrome / Edge / Chromium 无头模式渲染网页或本地文件,把截图交给模型看。
2
2
  //
3
3
  // 模型写网页、SVG、样式时看不到效果,只能读源码猜,常常越改越乱,或者反复打开给用户看却说不出结果。
4
- // 有了截图它能自己检查。模型不能看图片时不发给模型(见 distro),否则截图到了模型那里只剩占位说明。
4
+ // 有了截图它能自己检查。模型不能看图片时(JADE_VISION)不给截图,说明原因。
5
5
  //
6
- // effect "read":本地文件按路径、URL 按主机由 policy 判断要不要问(URL 本身就能把数据带出去)。
6
+ // effect "read":本地文件按路径、URL 按主机由 jade/approval 判断要不要问(URL 本身就能把数据带出去)。
7
7
  // 允许 localhost:开发服务器是最常见的用途;访问网络的 URL 会先问用户。
8
8
  // 每次用新的临时用户目录,不碰用户自己的浏览器配置和登录状态。
9
+ //
10
+ // 从旧 jade 的 tools/screenshot.ts 移植。
9
11
 
10
12
  import { mkdtemp, readFile, rm, stat } from "node:fs/promises";
11
13
  import os from "node:os";
12
14
  import path from "node:path";
13
15
  import { pathToFileURL } from "node:url";
14
16
  import type { Block, Tool } from "uncarved";
15
- import { spawn as spawnProc, which, type Proc, type SpawnOptions } from "../sys.ts";
17
+ import { spawn as spawnProc, which, type Proc, type SpawnOptions } from "./sys.ts";
16
18
 
17
19
  const DEFAULT_WIDTH = 1280;
18
20
  const DEFAULT_HEIGHT = 800;
@@ -35,9 +37,7 @@ export interface ScreenshotOptions {
35
37
  /** 常见的安装位置,按优先级。Windows 上 Edge 总是有的 */
36
38
  function candidates(env: Record<string, string | undefined>): string[] {
37
39
  if (process.platform === "win32") {
38
- const roots = [env.ProgramFiles ?? "C:\\Program Files", env["ProgramFiles(x86)"] ?? "C:\\Program Files (x86)", env.LOCALAPPDATA].filter(
39
- (r): r is string => !!r,
40
- );
40
+ const roots = [env.ProgramFiles ?? "C:\\Program Files", env["ProgramFiles(x86)"] ?? "C:\\Program Files (x86)", env.LOCALAPPDATA].filter((r): r is string => !!r);
41
41
  const rel = ["Google\\Chrome\\Application\\chrome.exe", "Microsoft\\Edge\\Application\\msedge.exe", "Chromium\\Application\\chrome.exe"];
42
42
  return rel.flatMap((r) => roots.map((root) => path.join(root, r)));
43
43
  }
@@ -0,0 +1,148 @@
1
+ // jade/sessions:/clear、/resume、/retry,以及 /resume 用的会话索引。
2
+ // 索引是 $JADE_HOME/state/sessions.jsonl,每行 { id, cwd, title, at }:会话在本进程里第一次收到消息时追加一行。
3
+ // 读的时候按 id 合并:标题取最早的一行,时间取最晚的一行;目录按 cwdKey 比较。
4
+
5
+ import { appendFile, mkdir, readFile } from "node:fs/promises";
6
+ import path from "node:path";
7
+ import type { UserInput } from "uncarved";
8
+ import { definePlugin } from "../../src/api.ts";
9
+ import type { Commands } from "../commands/index.ts";
10
+
11
+ export interface SessionSummary {
12
+ id: string;
13
+ cwd: string;
14
+ /** 第一条消息的开头 */
15
+ title: string;
16
+ /** 最近一次使用的时间(ISO) */
17
+ at: string;
18
+ }
19
+
20
+ const TITLE_CHARS = 80;
21
+
22
+ /** 比较目录用的键:绝对路径、去掉末尾的分隔符;Windows 上不分大小写 */
23
+ export function cwdKey(cwd: string): string {
24
+ const p = path.resolve(cwd);
25
+ return process.platform === "win32" ? p.toLowerCase() : p;
26
+ }
27
+
28
+ /** 索引里的全部会话按目录分组,键是 cwdKey;每组最近用过的在前 */
29
+ export async function listAllSessions(file: string): Promise<Map<string, SessionSummary[]>> {
30
+ let text = "";
31
+ try {
32
+ text = await readFile(file, "utf8");
33
+ } catch {
34
+ return new Map();
35
+ }
36
+ const byId = new Map<string, SessionSummary>();
37
+ for (const line of text.split("\n")) {
38
+ if (!line.trim()) continue;
39
+ let e: SessionSummary;
40
+ try {
41
+ e = JSON.parse(line);
42
+ } catch {
43
+ continue; // 写到一半的行
44
+ }
45
+ if (typeof e?.id !== "string" || typeof e.cwd !== "string" || typeof e.at !== "string") continue;
46
+ const seen = byId.get(e.id);
47
+ byId.set(e.id, seen ? { ...seen, at: e.at > seen.at ? e.at : seen.at } : e);
48
+ }
49
+ const byCwd = new Map<string, SessionSummary[]>();
50
+ for (const s of byId.values()) {
51
+ const key = cwdKey(s.cwd);
52
+ const group = byCwd.get(key);
53
+ if (group) group.push(s);
54
+ else byCwd.set(key, [s]);
55
+ }
56
+ for (const group of byCwd.values()) group.sort((a, b) => b.at.localeCompare(a.at));
57
+ return byCwd;
58
+ }
59
+
60
+ /** 索引里 cwd 下的会话,最近用过的在前 */
61
+ export async function listSessions(file: string, cwd: string): Promise<SessionSummary[]> {
62
+ return (await listAllSessions(file)).get(cwdKey(cwd)) ?? [];
63
+ }
64
+
65
+ /** 多久以前,例如 "5m ago" */
66
+ export function ago(iso: string, now = Date.now()): string {
67
+ const s = Math.max(0, Math.round((now - Date.parse(iso)) / 1000));
68
+ if (s < 60) return "just now";
69
+ if (s < 3600) return `${Math.floor(s / 60)}m ago`;
70
+ if (s < 86400) return `${Math.floor(s / 3600)}h ago`;
71
+ return `${Math.floor(s / 86400)}d ago`;
72
+ }
73
+
74
+ function titleOf(input: UserInput): string | undefined {
75
+ if (input.kind !== "message") return undefined;
76
+ const text = input.content.flatMap((b) => (b.kind === "text" && b.origin.by === "user" ? [b.text] : [])).join(" ").replace(/\s+/g, " ").trim();
77
+ if (!text) return undefined;
78
+ return text.length > TITLE_CHARS ? `${text.slice(0, TITLE_CHARS)}…` : text;
79
+ }
80
+
81
+ /** sessions@1 */
82
+ export interface SessionIndex {
83
+ /** cwd 里的会话,最近用过的在前(jade --continue 取第一个) */
84
+ list(cwd: string): Promise<SessionSummary[]>;
85
+ }
86
+
87
+ export default definePlugin({
88
+ process(ctx) {
89
+ const file = path.join(ctx.home, "state", "sessions.jsonl");
90
+ ctx.provide("sessions@1", { list: (cwd: string) => listSessions(file, cwd) } satisfies SessionIndex);
91
+ const commands = ctx.require<Commands>("commands@1");
92
+
93
+ commands.register({
94
+ name: "clear",
95
+ description: "start a new session (the current one stays resumable)",
96
+ async run(_args, c) {
97
+ const previous = c.sessions.current;
98
+ await c.sessions.open();
99
+ return previous && previous.state.messages.length > 0 ? `Started a new session. Resume the previous one with /resume or: jade --resume ${previous.id}` : "Started a new session.";
100
+ },
101
+ });
102
+
103
+ commands.register({
104
+ name: "resume",
105
+ args: "[session id]",
106
+ description: "continue an earlier session in this directory",
107
+ async run(args, c) {
108
+ let id: string | undefined = args.trim() || undefined;
109
+ if (!id) {
110
+ const all = (await listSessions(file, ctx.cwd)).filter((s) => s.id !== c.sessions.current?.id).slice(0, 50);
111
+ if (all.length === 0) return "No other sessions in this directory.";
112
+ id = await c.ui.select({ title: "Resume which session?", options: all.map((s) => ({ label: s.title || "(untitled)", value: s.id, hint: `${ago(s.at)} · ${s.id}` })) }, c.signal);
113
+ if (!id) return;
114
+ }
115
+ // 前端在会话换掉之后重新显示它的对话
116
+ await c.sessions.open({ resume: id });
117
+ },
118
+ });
119
+
120
+ commands.register({
121
+ name: "retry",
122
+ description: "ask the model again after a failed request",
123
+ async run(_args, c) {
124
+ const s = c.sessions.current;
125
+ if (!s || s.state.messages.at(-1)?.role !== "user") return "Nothing to retry: the last request did not fail before the model answered.";
126
+ await s.send({ kind: "retry" });
127
+ },
128
+ });
129
+ },
130
+
131
+ session(ctx) {
132
+ const file = path.join(ctx.home, "state", "sessions.jsonl");
133
+ let indexed = false;
134
+ ctx.kernel.hook({
135
+ kind: "observe",
136
+ point: "event",
137
+ fn: async (e) => {
138
+ if (indexed || e.type !== "input.received") return;
139
+ const title = titleOf(e.data as UserInput);
140
+ if (title === undefined) return;
141
+ indexed = true;
142
+ const entry: SessionSummary = { id: ctx.session.id, cwd: path.resolve(ctx.cwd), title, at: new Date().toISOString() };
143
+ await mkdir(path.dirname(file), { recursive: true });
144
+ await appendFile(file, `${JSON.stringify(entry)}\n`);
145
+ },
146
+ });
147
+ },
148
+ });
@@ -0,0 +1,8 @@
1
+ {
2
+ "id": "jade/sessions",
3
+ "version": "0.1.0",
4
+ "api": "^1",
5
+ "entry": "./index.ts",
6
+ "provides": ["sessions@1"],
7
+ "requires": ["commands@1"]
8
+ }
@@ -0,0 +1,33 @@
1
+ // jade/shell:bash 工具,以及后台命令的 bash_output、kill_shell;shell@1 给其他插件执行命令。
2
+
3
+ import { definePlugin, type UI } from "../../src/api.ts";
4
+ import type { Prompts } from "../prompts/index.ts";
5
+ import type { Renderers } from "../renderers/index.ts";
6
+ import { shellRenderers } from "./renderers.ts";
7
+ import { shellService } from "./service.ts";
8
+ import { shellTools } from "./shell.ts";
9
+
10
+ export default definePlugin({
11
+ process(ctx) {
12
+ // 显示方式和会话无关,登记一次留到进程结束;没有 renderers@1(例如 print)时用前端的默认显示
13
+ const renderers = ctx.service<Renderers>("renderers@1");
14
+ if (renderers) for (const r of shellRenderers) renderers.tool(r);
15
+ // shell@1:找 shell 和杀进程树只有一份(见 service.ts)
16
+ ctx.provide("shell@1", shellService(typeof ctx.config.shell === "string" ? { shell: ctx.config.shell } : {}));
17
+ },
18
+
19
+ async session(ctx) {
20
+ const shell = typeof ctx.config.shell === "string" ? ctx.config.shell : undefined;
21
+ const { tools, executable, unavailable, shutdown } = shellTools({ cwd: ctx.cwd, ...(shell ? { shell } : {}) });
22
+ if (unavailable) ctx.service<UI>("ui@1")?.notify(unavailable, "warning");
23
+ for (const tool of tools) ctx.kernel.tool(tool);
24
+ if (executable) {
25
+ const lines = [`- Shell for the bash tool: ${executable} (POSIX syntax, also on Windows)`];
26
+ // 模型常用 xdg-open、open 打开文件,Git Bash 里没有;start 是 Git 自带的 /usr/bin/start
27
+ if (process.platform === "win32") lines.push('- To open a file or URL for the user, run: start "" <path-or-url> (xdg-open and open do not exist)');
28
+ ctx.service<Prompts>("prompts@1")?.add({ text: lines.join("\n") });
29
+ }
30
+ // 会话关闭(换会话、退出)时杀掉还在运行的后台命令
31
+ await ctx.effect(() => shutdown);
32
+ },
33
+ });
@@ -0,0 +1,17 @@
1
+ {
2
+ "id": "jade/shell",
3
+ "version": "0.3.0",
4
+ "api": "^1",
5
+ "entry": "./index.ts",
6
+ "provides": ["shell@1"],
7
+ "optional": [
8
+ "ui@1",
9
+ "prompts@1",
10
+ "renderers@1"
11
+ ],
12
+ "config": {
13
+ "shell": {
14
+ "description": "the shell the bash tool and shell@1 run; default $JADE_SHELL, else bash (Git Bash on Windows)"
15
+ }
16
+ }
17
+ }
@@ -0,0 +1,45 @@
1
+ // bash、bash_output、kill_shell 在对话和审批里怎么显示(登记到 renderers@1)。从旧 jade 的 ui/renderers.ts 移植。
2
+ //
3
+ // 运行中的输出不登记 progress:bash 推送的是 { kind, stream, text },前端对 { text } 形式的进度默认逐行显示,
4
+ // 正是想要的;自己写 progress 反而只能把一次推送(可能是好几行、半行)显示成一行。
5
+
6
+ import type { ToolRenderer } from "../renderers/index.ts";
7
+
8
+ // 截断和颜色从旧 jade 的 ui/render.ts、ui/screen.ts 复制:插件之间不共享代码,fs 插件也有一份
9
+ const clip = (s: string, n: number) => (s.length > n ? s.slice(0, n) + "…" : s);
10
+ // 设了 NO_COLOR(非空)或标准输出不是终端时不输出颜色,见 https://no-color.org
11
+ const colors = Boolean(process.stdout.isTTY) && !process.env.NO_COLOR;
12
+ const dim = (s: string) => (colors ? `\x1b[2m${s.replaceAll("\x1b[22m", "\x1b[22m\x1b[2m")}\x1b[22m` : s);
13
+
14
+ type Args = Record<string, unknown>;
15
+ const args = (input: unknown) => (input !== null && typeof input === "object" ? input : {}) as Args;
16
+ const command = (input: unknown) => String(args(input).command ?? "");
17
+
18
+ /** 摘要最多这么多个字符 */
19
+ const MAX_SUMMARY = 120;
20
+
21
+ /** 预览里的多行文字:每行前面加上标记,最多 max 行 */
22
+ function marked(s: string, mark: string, max = 30): string {
23
+ const all = s.split("\n");
24
+ const shown = all.slice(0, max).map((l) => `${mark} ${l}`);
25
+ if (all.length > max) shown.push(dim(` … ${all.length - max} more lines`));
26
+ return shown.join("\n");
27
+ }
28
+
29
+ export const shellRenderers: ToolRenderer[] = [
30
+ {
31
+ tool: "bash",
32
+ summary: (input) => clip(command(input).split("\n")[0]!, MAX_SUMMARY),
33
+ // 摘要省略了内容时(多行或很长的命令),展开后先显示完整的命令
34
+ details: (input) => {
35
+ const lines = command(input).split("\n");
36
+ if (lines.length === 1 && lines[0]!.length <= MAX_SUMMARY) return undefined;
37
+ const shown = lines.slice(0, 200).map((l, i) => dim(`${i === 0 ? "$" : " "} ${l}`));
38
+ if (lines.length > 200) shown.push(dim(`… ${lines.length - 200} more lines`));
39
+ return shown.join("\n");
40
+ },
41
+ preview: (input) => marked(command(input), "$"),
42
+ },
43
+ { tool: "bash_output", summary: (input) => String(args(input).id ?? "") },
44
+ { tool: "kill_shell", summary: (input) => String(args(input).id ?? "") },
45
+ ];
@@ -0,0 +1,44 @@
1
+ // shell@1:给其他插件执行命令的入口(例如 jade/checks 跑项目的检查)。
2
+ //
3
+ // 找 shell、补 Git Bash 的 PATH、杀进程树这些只有一份,在 shell.ts 里;这里只把它包成服务。
4
+ // 和 bash 工具不同,这里的命令不经过模型和审批:调用方(插件)自己决定要不要问用户。
5
+ // 没有 shell 时 executable 是 undefined,run 会抛错;调用方据此说明"在这台机器上做不了"。
6
+
7
+ import { capture, findShell, shellEnv, type RunCommand, type RunResult } from "./shell.ts";
8
+ import { which } from "./sys.ts";
9
+
10
+ /** shell@1 */
11
+ export interface Shell {
12
+ /** 实际执行的 shell 程序;这台机器上没有时为 undefined */
13
+ readonly executable: string | undefined;
14
+ /** 找不到 shell 时的说明 */
15
+ readonly unavailable?: string;
16
+ /** 执行一条命令并收集输出;超时或中止时连同子进程一起杀掉 */
17
+ run: RunCommand;
18
+ /** 在 PATH 里找可执行文件(Windows 上按 PATHEXT 补扩展名),找不到返回 undefined */
19
+ which(bin: string): string | undefined;
20
+ }
21
+
22
+ /** 默认的 shell:JADE_SHELL,否则 bash(Windows 上是 Git Bash) */
23
+ export const shellName = (configured: unknown): string => (typeof configured === "string" && configured.trim() ? configured : (process.env.JADE_SHELL ?? "bash"));
24
+
25
+ export function shellService(opts: { shell?: string } = {}): Shell {
26
+ const name = shellName(opts.shell);
27
+ const executable = findShell(name);
28
+ if (!executable) {
29
+ const hint = process.platform === "win32" ? "install Git for Windows, or set JADE_SHELL to the path of a bash executable" : "set JADE_SHELL to the path of a shell";
30
+ const unavailable = `${name} was not found; ${hint}`;
31
+ return {
32
+ executable: undefined,
33
+ unavailable,
34
+ run: () => Promise.reject(new Error(unavailable)),
35
+ which,
36
+ };
37
+ }
38
+ const env = shellEnv(executable);
39
+ return {
40
+ executable,
41
+ run: (command, o): Promise<RunResult> => capture(executable, env, command, o),
42
+ which,
43
+ };
44
+ }
@@ -6,7 +6,7 @@
6
6
  import { existsSync } from "node:fs";
7
7
  import path from "node:path";
8
8
  import type { Tool } from "uncarved";
9
- import { runSync, spawn as spawnProc, which, type Proc } from "../sys.ts";
9
+ import { runSync, spawn as spawnProc, which, type Proc } from "./sys.ts";
10
10
 
11
11
  const DEFAULT_TIMEOUT_MS = 120_000;
12
12
  const MAX_TIMEOUT_MS = 600_000;
@@ -214,25 +214,7 @@ export function shellTools(opts: ShellOptions): ShellTools {
214
214
  },
215
215
  };
216
216
 
217
- const run: RunCommand = async (command, { cwd, timeoutMs, signal }) => {
218
- signal?.throwIfAborted();
219
- const proc = await spawn(command, cwd);
220
- let timedOut = false;
221
- const kill = () => killTree(executable, env, proc.pid);
222
- const timer = setTimeout(() => {
223
- timedOut = true;
224
- kill();
225
- }, timeoutMs);
226
- signal?.addEventListener("abort", kill, { once: true });
227
- try {
228
- const [stdout, stderr, code] = await Promise.all([collect(proc.stdout, () => {}), collect(proc.stderr, () => {}), proc.exited]);
229
- signal?.throwIfAborted();
230
- return { code: timedOut ? null : code, output: [stdout, stderr].filter(Boolean).join("\n"), timedOut };
231
- } finally {
232
- clearTimeout(timer);
233
- signal?.removeEventListener("abort", kill);
234
- }
235
- };
217
+ const run: RunCommand = (command, opts) => capture(executable, env, command, opts);
236
218
 
237
219
  return {
238
220
  tools: [bash, bashOutput, killShell],
@@ -244,6 +226,35 @@ export function shellTools(opts: ShellOptions): ShellTools {
244
226
  };
245
227
  }
246
228
 
229
+ /**
230
+ * 执行一条命令并把输出收下来(不经过模型、不推进度);超时或中止时连同子进程一起杀掉。
231
+ * 后台命令和别的插件(`shell@1`,例如 jade/checks)都用它
232
+ */
233
+ export async function capture(executable: string, env: NodeJS.ProcessEnv | undefined, command: string, opts: { cwd?: string; timeoutMs: number; signal?: AbortSignal }): Promise<RunResult> {
234
+ opts.signal?.throwIfAborted();
235
+ const proc = await spawnProc([executable, "-c", command], {
236
+ cwd: opts.cwd,
237
+ env,
238
+ // 自成进程组,超时/中断时能连同子进程一起杀掉
239
+ detached: process.platform !== "win32",
240
+ });
241
+ let timedOut = false;
242
+ const kill = () => killTree(executable, env, proc.pid);
243
+ const timer = setTimeout(() => {
244
+ timedOut = true;
245
+ kill();
246
+ }, opts.timeoutMs);
247
+ opts.signal?.addEventListener("abort", kill, { once: true });
248
+ try {
249
+ const [stdout, stderr, code] = await Promise.all([collect(proc.stdout, () => {}), collect(proc.stderr, () => {}), proc.exited]);
250
+ opts.signal?.throwIfAborted();
251
+ return { code: timedOut ? null : code, output: [stdout, stderr].filter(Boolean).join("\n"), timedOut };
252
+ } finally {
253
+ clearTimeout(timer);
254
+ opts.signal?.removeEventListener("abort", kill);
255
+ }
256
+ }
257
+
247
258
  /** ctx.progress 推送的内容 */
248
259
  export interface ShellProgress {
249
260
  kind: "output";
@@ -1,12 +1,8 @@
1
- // 跨运行时的进程、可执行文件查找和 glob:只用 Node 的标准库,Bun 和 Node ≥22.18 下走同一套代码。
1
+ // 跨运行时的进程和可执行文件查找:只用 Node 的标准库,Bun 和 Node ≥22.18 下走同一套代码。
2
2
 
3
3
  import { spawn as nodeSpawn, spawnSync as nodeSpawnSync } from "node:child_process";
4
- import { accessSync, constants, existsSync, readFileSync, statSync } from "node:fs";
4
+ import { accessSync, constants, statSync } from "node:fs";
5
5
  import path from "node:path";
6
- import picomatch from "picomatch";
7
-
8
- /** jade 自己的版本号,src 和 dist 下都从包根目录的 package.json 读 */
9
- export const VERSION: string = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
10
6
 
11
7
  type Stdio = "pipe" | "ignore";
12
8
 
@@ -63,25 +59,11 @@ export function spawn(cmd: string[], opts: SpawnOptions = {}): Promise<Proc> {
63
59
  });
64
60
  }
65
61
 
66
- /** 运行一条命令,返回 stdout 文本和退出码;启动失败时 reject */
67
- export async function run(cmd: string[], opts: { cwd?: string } = {}): Promise<{ code: number | null; stdout: string }> {
68
- const proc = await spawn(cmd, { cwd: opts.cwd, stderr: "ignore" });
69
- const [stdout, code] = await Promise.all([text(proc.stdout), proc.exited]);
70
- return { code, stdout };
71
- }
72
-
73
62
  /** 同步运行,忽略输出和错误;用于退出前的清理 */
74
63
  export function runSync(cmd: string[], opts: { env?: NodeJS.ProcessEnv } = {}): void {
75
64
  nodeSpawnSync(cmd[0]!, cmd.slice(1), { stdio: "ignore", windowsHide: true, env: opts.env });
76
65
  }
77
66
 
78
- export async function text(stream: AsyncIterable<Uint8Array>): Promise<string> {
79
- const decoder = new TextDecoder();
80
- let out = "";
81
- for await (const chunk of stream) out += decoder.decode(chunk, { stream: true });
82
- return out + decoder.decode();
83
- }
84
-
85
67
  /** which 的结果,按 PATH 和 PATHEXT 记;找不到的过一会儿再查(会话中途装上的工具能用上) */
86
68
  const found = new Map<string, { file: string | undefined; at: number }>();
87
69
  const MISS_TTL_MS = 30_000;
@@ -128,26 +110,3 @@ function lookup(bin: string): string | undefined {
128
110
  }
129
111
  return undefined;
130
112
  }
131
-
132
- /**
133
- * 编译 glob,返回匹配函数。路径用正斜杠、相对于搜索根目录。
134
- * 和原先的 Bun.Glob#match 一致:* 也匹配点开头的文件,反斜杠是转义符而不是分隔符
135
- */
136
- export function globMatcher(pattern: string): (rel: string) => boolean {
137
- return picomatch(pattern, { dot: true, windows: false });
138
- }
139
-
140
- /** 找 npm 的 CLI 脚本,用当前的 node 运行它:Windows 上 npm 是 .cmd,不经过 shell 不能直接执行 */
141
- export function npmCommand(): string[] | undefined {
142
- const dirs = [path.dirname(process.execPath)];
143
- const onPath = which(process.platform === "win32" ? "npm.cmd" : "npm");
144
- if (onPath) dirs.push(path.dirname(onPath));
145
- for (const dir of dirs) {
146
- for (const cli of [path.join(dir, "node_modules", "npm", "bin", "npm-cli.js"), path.join(dir, "..", "lib", "node_modules", "npm", "bin", "npm-cli.js")]) {
147
- if (existsSync(cli)) return [process.execPath, cli];
148
- }
149
- }
150
- // POSIX 上 npm 本身就是可执行的脚本
151
- if (onPath && process.platform !== "win32") return [onPath];
152
- return undefined;
153
- }
@@ -0,0 +1,96 @@
1
+ // jade/skills:skill 工具、系统提示词里的 skill 列表、/skills,以及每个 skill 一条 /<skill 名> 命令。
2
+ //
3
+ // 每个会话打开时重新查找 skill(/clear 之后能用上新装的)。随仓库分发的 skill(项目层)不用确认:
4
+ // 它只是给模型看的文字,不执行代码;和旧 jade 一样,列表里有项目层的 skill 时整段标为不可信。
5
+
6
+ import path from "node:path";
7
+ import { definePlugin, type UI } from "../../src/api.ts";
8
+ import type { Approval } from "../approval/index.ts";
9
+ import type { Commands } from "../commands/index.ts";
10
+ import type { Prompts } from "../prompts/index.ts";
11
+ import { bold, clip, dim, display, realPath, repoRoot } from "./project.ts";
12
+ import { loadSkills, skillsPrompt, skillTool, type Skill } from "./skills.ts";
13
+
14
+ const ID = "jade/skills";
15
+
16
+ /** /<skill> 发给模型的消息:让它先加载这个 skill */
17
+ export function skillMessage(name: string, args: string): string {
18
+ return `Use the "${name}" skill${args.trim() ? ` for this: ${args.trim()}` : "."}`;
19
+ }
20
+
21
+ async function find(home: string, cwd: string) {
22
+ const here = realPath(cwd);
23
+ return loadSkills({ home, root: realPath(repoRoot(here)), cwd: here });
24
+ }
25
+
26
+ /** 最近一个会话找到的 skill,/skills 显示它 */
27
+ let latest: Skill[] | undefined;
28
+ /** 最近一个会话注册的 /<skill> 命令 → 撤销函数 */
29
+ const skillCommands = new Map<string, () => void>();
30
+ /** 已经告诉过用户的警告:每个会话都会重新查找,同样的警告不重复说 */
31
+ const warned = new Set<string>();
32
+
33
+ export default definePlugin({
34
+ process(ctx) {
35
+ latest = undefined;
36
+ skillCommands.clear();
37
+ ctx.service<Commands>("commands@1")?.register({
38
+ name: "skills",
39
+ description: "skills the agent can use",
40
+ instant: true,
41
+ async run() {
42
+ const skills = latest ?? (await find(ctx.home, ctx.cwd)).skills;
43
+ if (skills.length === 0) {
44
+ return dim(`(no skills) put them in ${display(ctx.cwd, path.join(ctx.home, "skills"))}/<name>/SKILL.md or .jade/skills/<name>/SKILL.md`);
45
+ }
46
+ return skills
47
+ .map((sk) => `${bold(sk.name)} ${dim(`${sk.layer} · ${display(ctx.cwd, sk.dir)}`)}\n ${clip(sk.description.replace(/\s+/g, " "), 300)}`)
48
+ .join("\n");
49
+ },
50
+ });
51
+ },
52
+
53
+ async session(ctx) {
54
+ const { skills, warnings } = await find(ctx.home, ctx.cwd);
55
+ latest = skills;
56
+ const ui = ctx.service<UI>("ui@1");
57
+ for (const w of warnings) {
58
+ if (warned.has(w)) continue;
59
+ warned.add(w);
60
+ ui?.notify(`${ID}: ${w}`, "warning");
61
+ }
62
+ if (skills.length === 0) return;
63
+
64
+ ctx.kernel.tool(skillTool(skills));
65
+ const text = skillsPrompt(skills)!;
66
+ // 读 skill 目录里的文件(脚本、参考资料)不用问;会话关闭时撤销
67
+ const approval = ctx.service<Approval>("approval@1");
68
+ for (const sk of skills) approval?.allowRead(sk.dir);
69
+ // 有随仓库分发的 skill 时整段不可信
70
+ ctx.service<Prompts>("prompts@1")?.add({ text, untrusted: !skills.every((s) => s.layer === "user") });
71
+
72
+ // skill 也可以当命令用:/<skill 名> [要做的事]。挂在会话作用域上,随会话撤销。
73
+ // 新会话在旧会话关闭之前打开:旧会话注册的同名命令先撤销,换成这个会话的。
74
+ // 名字已被别的插件的命令占用时让给它(会话级的注册总在进程级的命令之后)
75
+ const commands = ctx.service<Commands>("commands@1");
76
+ if (commands) {
77
+ for (const sk of skills) {
78
+ const key = sk.name.toLowerCase();
79
+ const taken = commands.get(sk.name);
80
+ if (taken && taken.plugin !== ID) continue;
81
+ if (taken) skillCommands.get(key)?.();
82
+ try {
83
+ const revoke = commands.register({
84
+ name: sk.name,
85
+ args: "[task]",
86
+ description: `${clip(sk.description.replace(/\s+/g, " "), 80)} (skill)`,
87
+ run: (args) => ({ prompt: skillMessage(sk.name, args) }),
88
+ });
89
+ skillCommands.set(key, revoke);
90
+ } catch {
91
+ // 名字不能当命令名(commands@1 的规则更严)或刚被占用:只是少一条快捷命令
92
+ }
93
+ }
94
+ }
95
+ },
96
+ });
@@ -0,0 +1,7 @@
1
+ {
2
+ "id": "jade/skills",
3
+ "version": "0.2.0",
4
+ "api": "^1",
5
+ "entry": "./index.ts",
6
+ "optional": ["ui@1", "prompts@1", "commands@1", "approval@1"]
7
+ }