@uncarved/jade 0.1.3 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (450) hide show
  1. package/bin/jade.js +5 -27
  2. package/dist/api.d.ts +266 -0
  3. package/dist/api.js +38 -0
  4. package/dist/api.js.map +1 -0
  5. package/dist/config.d.ts +13 -32
  6. package/dist/config.js +39 -121
  7. package/dist/config.js.map +1 -1
  8. package/dist/fetch.d.ts +20 -0
  9. package/dist/fetch.js +190 -0
  10. package/dist/fetch.js.map +1 -0
  11. package/dist/hash.d.ts +2 -0
  12. package/dist/hash.js +42 -0
  13. package/dist/hash.js.map +1 -0
  14. package/dist/host.d.ts +71 -0
  15. package/dist/host.js +400 -0
  16. package/dist/host.js.map +1 -0
  17. package/dist/index.d.ts +11 -30
  18. package/dist/index.js +11 -30
  19. package/dist/index.js.map +1 -1
  20. package/dist/install.d.ts +78 -0
  21. package/dist/install.js +292 -0
  22. package/dist/install.js.map +1 -0
  23. package/dist/main.d.ts +1 -2
  24. package/dist/main.js +159 -1362
  25. package/dist/main.js.map +1 -1
  26. package/dist/manifest.d.ts +23 -0
  27. package/dist/manifest.js +159 -0
  28. package/dist/manifest.js.map +1 -0
  29. package/dist/membrane.d.ts +33 -0
  30. package/dist/membrane.js +140 -0
  31. package/dist/membrane.js.map +1 -0
  32. package/dist/remote.d.ts +10 -0
  33. package/dist/remote.js +292 -0
  34. package/dist/remote.js.map +1 -0
  35. package/dist/rescue.d.ts +10 -0
  36. package/dist/rescue.js +216 -0
  37. package/dist/rescue.js.map +1 -0
  38. package/dist/resolve.d.ts +34 -0
  39. package/dist/resolve.js +178 -0
  40. package/dist/resolve.js.map +1 -0
  41. package/dist/rpc.d.ts +26 -0
  42. package/dist/rpc.js +144 -0
  43. package/dist/rpc.js.map +1 -0
  44. package/dist/secrets.d.ts +12 -0
  45. package/dist/secrets.js +125 -0
  46. package/dist/secrets.js.map +1 -0
  47. package/dist/session.d.ts +45 -0
  48. package/dist/session.js +401 -0
  49. package/dist/session.js.map +1 -0
  50. package/dist/source.d.ts +12 -0
  51. package/dist/source.js +72 -0
  52. package/dist/source.js.map +1 -0
  53. package/dist/state.d.ts +37 -0
  54. package/dist/state.js +93 -0
  55. package/dist/state.js.map +1 -0
  56. package/dist/update.d.ts +2 -0
  57. package/dist/update.js +6 -3
  58. package/dist/update.js.map +1 -1
  59. package/package.json +10 -8
  60. package/plugins/approval/index.ts +297 -0
  61. package/plugins/approval/plugin.json +18 -0
  62. package/{src/plugins → plugins/approval}/policy.ts +21 -100
  63. package/{src/plugins → plugins/approval}/review.ts +62 -16
  64. package/plugins/ask/index.ts +159 -0
  65. package/plugins/ask/plugin.json +8 -0
  66. package/plugins/budget/index.ts +38 -0
  67. package/plugins/budget/plugin.json +13 -0
  68. package/{src/plugins → plugins/checks}/checks.ts +48 -38
  69. package/plugins/checks/index.ts +158 -0
  70. package/plugins/checks/plugin.json +14 -0
  71. package/plugins/checks/project.ts +81 -0
  72. package/plugins/commands/index.ts +76 -0
  73. package/plugins/commands/plugin.json +7 -0
  74. package/{src/plugins → plugins/compact}/compact.ts +73 -38
  75. package/plugins/compact/index.ts +115 -0
  76. package/plugins/compact/plugin.json +17 -0
  77. package/plugins/compact/style.ts +17 -0
  78. package/plugins/continue/index.ts +58 -0
  79. package/plugins/continue/plugin.json +13 -0
  80. package/{src/ui → plugins/fs}/diff.ts +2 -2
  81. package/{src/tools → plugins/fs}/fs.ts +19 -42
  82. package/{src/tools → plugins/fs}/grep.ts +1 -1
  83. package/plugins/fs/index.ts +34 -0
  84. package/plugins/fs/plugin.json +7 -0
  85. package/{src/ui → plugins/fs}/renderers.ts +25 -70
  86. package/plugins/fs/style.ts +18 -0
  87. package/plugins/fs/sys.ts +81 -0
  88. package/plugins/keys/index.ts +53 -0
  89. package/plugins/keys/plugin.json +7 -0
  90. package/plugins/mcp/index.ts +192 -0
  91. package/{src → plugins/mcp}/mcp.ts +32 -32
  92. package/plugins/mcp/plugin.json +7 -0
  93. package/plugins/mcp/project.ts +93 -0
  94. package/plugins/memory/index.ts +105 -0
  95. package/{src → plugins/memory}/memory.ts +20 -2
  96. package/plugins/memory/notes.ts +43 -0
  97. package/plugins/memory/plugin.json +7 -0
  98. package/plugins/memory/style.ts +17 -0
  99. package/plugins/mentions/attach.ts +127 -0
  100. package/plugins/mentions/index.ts +79 -0
  101. package/plugins/mentions/plugin.json +7 -0
  102. package/plugins/mentions/style.ts +17 -0
  103. package/plugins/models/config.ts +53 -0
  104. package/plugins/models/configure.ts +455 -0
  105. package/plugins/models/context.ts +32 -0
  106. package/plugins/models/index.ts +198 -0
  107. package/plugins/models/plugin.json +8 -0
  108. package/{src → plugins/models}/provider.ts +16 -119
  109. package/plugins/models/saved.ts +94 -0
  110. package/plugins/modes/index.ts +222 -0
  111. package/plugins/modes/plugin.json +9 -0
  112. package/plugins/plugins/index.ts +38 -0
  113. package/plugins/plugins/plugin.json +7 -0
  114. package/plugins/print/index.ts +142 -0
  115. package/plugins/print/plugin.json +8 -0
  116. package/plugins/prompts/index.ts +83 -0
  117. package/plugins/prompts/plugin.json +8 -0
  118. package/plugins/prompts/prompts.ts +253 -0
  119. package/plugins/prompts/sys.ts +72 -0
  120. package/plugins/renderers/index.ts +78 -0
  121. package/plugins/renderers/plugin.json +7 -0
  122. package/plugins/repeats/index.ts +165 -0
  123. package/plugins/repeats/plugin.json +6 -0
  124. package/plugins/schedule/cron.ts +74 -0
  125. package/plugins/schedule/index.ts +292 -0
  126. package/plugins/schedule/plugin.json +13 -0
  127. package/plugins/schedule/store.ts +149 -0
  128. package/plugins/scratch/index.ts +31 -0
  129. package/plugins/scratch/plugin.json +7 -0
  130. package/plugins/screenshot/index.ts +40 -0
  131. package/plugins/screenshot/plugin.json +7 -0
  132. package/plugins/screenshot/sys.ts +84 -0
  133. package/{src/tools/screenshot.ts → plugins/screenshot/tool.ts} +6 -6
  134. package/plugins/sessions/index.ts +148 -0
  135. package/plugins/sessions/plugin.json +8 -0
  136. package/plugins/shell/index.ts +33 -0
  137. package/plugins/shell/plugin.json +17 -0
  138. package/plugins/shell/renderers.ts +45 -0
  139. package/plugins/shell/service.ts +44 -0
  140. package/{src/tools → plugins/shell}/shell.ts +31 -20
  141. package/{src → plugins/shell}/sys.ts +2 -43
  142. package/plugins/skills/index.ts +96 -0
  143. package/plugins/skills/plugin.json +7 -0
  144. package/plugins/skills/project.ts +49 -0
  145. package/{src → plugins/skills}/skills.ts +4 -11
  146. package/plugins/suggest/index.ts +286 -0
  147. package/plugins/suggest/plugin.json +18 -0
  148. package/plugins/task/index.ts +167 -0
  149. package/plugins/task/plugin.json +15 -0
  150. package/plugins/task/style.ts +17 -0
  151. package/plugins/task/subagent.ts +257 -0
  152. package/{src/tools/todo.ts → plugins/todo/index.ts} +33 -7
  153. package/plugins/todo/plugin.json +7 -0
  154. package/{src/ui → plugins/tui}/editor.ts +3 -0
  155. package/plugins/tui/frontend.ts +596 -0
  156. package/plugins/tui/index.ts +37 -0
  157. package/plugins/tui/mentions.ts +113 -0
  158. package/plugins/tui/plugin.json +10 -0
  159. package/{src/ui → plugins/tui}/render.ts +8 -2
  160. package/{src/ui → plugins/tui}/screen.ts +8 -3
  161. package/{src/ui → plugins/tui}/transcript.ts +74 -99
  162. package/{src/ui/tui.tsx → plugins/tui/tui.ts} +358 -387
  163. package/{src/tools → plugins/undo}/checkpoint.ts +21 -60
  164. package/plugins/undo/index.ts +139 -0
  165. package/plugins/undo/notes.ts +43 -0
  166. package/plugins/undo/plugin.json +7 -0
  167. package/plugins/undo/style.ts +17 -0
  168. package/plugins/update/index.ts +40 -0
  169. package/plugins/update/plugin.json +13 -0
  170. package/plugins/web/env.ts +78 -0
  171. package/plugins/web/index.ts +133 -0
  172. package/plugins/web/plugin.json +15 -0
  173. package/plugins/web/renderers.ts +11 -0
  174. package/{src/tools → plugins/web}/web.ts +58 -26
  175. package/plugins-dist/approval/index.js +271 -0
  176. package/plugins-dist/approval/plugin.json +24 -0
  177. package/{dist/plugins → plugins-dist/approval}/policy.js +15 -81
  178. package/{dist/plugins → plugins-dist/approval}/review.js +56 -10
  179. package/{dist/plugins → plugins-dist/approval}/schema.js +0 -1
  180. package/plugins-dist/ask/index.js +145 -0
  181. package/plugins-dist/ask/plugin.json +12 -0
  182. package/plugins-dist/budget/index.js +37 -0
  183. package/plugins-dist/budget/plugin.json +15 -0
  184. package/{dist/plugins → plugins-dist/checks}/checks.js +46 -35
  185. package/plugins-dist/checks/index.js +150 -0
  186. package/plugins-dist/checks/plugin.json +21 -0
  187. package/plugins-dist/checks/project.js +76 -0
  188. package/plugins-dist/commands/index.js +33 -0
  189. package/plugins-dist/commands/plugin.json +9 -0
  190. package/{dist/plugins → plugins-dist/compact}/compact.js +51 -33
  191. package/plugins-dist/compact/index.js +100 -0
  192. package/plugins-dist/compact/plugin.json +25 -0
  193. package/plugins-dist/compact/style.js +14 -0
  194. package/plugins-dist/continue/index.js +57 -0
  195. package/plugins-dist/continue/plugin.json +15 -0
  196. package/{dist/ui → plugins-dist/fs}/diff.js +2 -3
  197. package/{dist/tools → plugins-dist/fs}/fs.js +17 -42
  198. package/{dist/tools → plugins-dist/fs}/grep.js +1 -2
  199. package/plugins-dist/fs/index.js +36 -0
  200. package/plugins-dist/fs/plugin.json +10 -0
  201. package/{dist/ui → plugins-dist/fs}/renderers.js +24 -61
  202. package/plugins-dist/fs/style.js +15 -0
  203. package/plugins-dist/fs/sys.js +54 -0
  204. package/plugins-dist/keys/index.js +36 -0
  205. package/plugins-dist/keys/plugin.json +9 -0
  206. package/plugins-dist/mcp/index.js +187 -0
  207. package/{dist → plugins-dist/mcp}/mcp.js +34 -30
  208. package/plugins-dist/mcp/plugin.json +12 -0
  209. package/plugins-dist/mcp/project.js +90 -0
  210. package/plugins-dist/memory/index.js +94 -0
  211. package/{dist → plugins-dist/memory}/memory.js +21 -3
  212. package/plugins-dist/memory/notes.js +36 -0
  213. package/plugins-dist/memory/plugin.json +11 -0
  214. package/plugins-dist/memory/style.js +14 -0
  215. package/plugins-dist/mentions/attach.js +120 -0
  216. package/plugins-dist/mentions/index.js +69 -0
  217. package/plugins-dist/mentions/plugin.json +9 -0
  218. package/plugins-dist/mentions/style.js +14 -0
  219. package/plugins-dist/models/config.js +53 -0
  220. package/plugins-dist/models/configure.js +415 -0
  221. package/plugins-dist/models/context.js +27 -0
  222. package/plugins-dist/models/index.js +167 -0
  223. package/plugins-dist/models/plugin.json +14 -0
  224. package/{dist → plugins-dist/models}/provider.js +18 -81
  225. package/plugins-dist/models/saved.js +80 -0
  226. package/plugins-dist/modes/index.js +190 -0
  227. package/plugins-dist/modes/plugin.json +18 -0
  228. package/plugins-dist/plugins/index.js +37 -0
  229. package/plugins-dist/plugins/plugin.json +10 -0
  230. package/plugins-dist/print/index.js +153 -0
  231. package/plugins-dist/print/plugin.json +14 -0
  232. package/plugins-dist/prompts/index.js +57 -0
  233. package/plugins-dist/prompts/plugin.json +13 -0
  234. package/plugins-dist/prompts/prompts.js +227 -0
  235. package/plugins-dist/prompts/sys.js +46 -0
  236. package/plugins-dist/renderers/index.js +36 -0
  237. package/plugins-dist/renderers/plugin.json +9 -0
  238. package/plugins-dist/repeats/index.js +165 -0
  239. package/plugins-dist/repeats/plugin.json +6 -0
  240. package/plugins-dist/schedule/cron.js +67 -0
  241. package/plugins-dist/schedule/index.js +281 -0
  242. package/plugins-dist/schedule/plugin.json +16 -0
  243. package/plugins-dist/schedule/store.js +125 -0
  244. package/plugins-dist/scratch/index.js +26 -0
  245. package/plugins-dist/scratch/plugin.json +10 -0
  246. package/plugins-dist/screenshot/index.js +35 -0
  247. package/plugins-dist/screenshot/plugin.json +11 -0
  248. package/plugins-dist/screenshot/sys.js +76 -0
  249. package/{dist/tools/screenshot.js → plugins-dist/screenshot/tool.js} +5 -4
  250. package/plugins-dist/sessions/index.js +136 -0
  251. package/plugins-dist/sessions/plugin.json +12 -0
  252. package/plugins-dist/shell/index.js +33 -0
  253. package/plugins-dist/shell/plugin.json +19 -0
  254. package/plugins-dist/shell/renderers.js +40 -0
  255. package/plugins-dist/shell/service.js +29 -0
  256. package/{dist/tools → plugins-dist/shell}/shell.js +31 -22
  257. package/{dist → plugins-dist/shell}/sys.js +2 -43
  258. package/plugins-dist/skills/index.js +90 -0
  259. package/plugins-dist/skills/plugin.json +12 -0
  260. package/plugins-dist/skills/project.js +47 -0
  261. package/{dist → plugins-dist/skills}/skills.js +3 -7
  262. package/plugins-dist/suggest/index.js +282 -0
  263. package/plugins-dist/suggest/plugin.json +23 -0
  264. package/plugins-dist/task/index.js +151 -0
  265. package/plugins-dist/task/plugin.json +23 -0
  266. package/plugins-dist/task/style.js +14 -0
  267. package/plugins-dist/task/subagent.js +208 -0
  268. package/{dist/tools/todo.js → plugins-dist/todo/index.js} +29 -7
  269. package/plugins-dist/todo/plugin.json +9 -0
  270. package/{dist/ui → plugins-dist/tui}/editor.js +3 -1
  271. package/plugins-dist/tui/frontend.js +586 -0
  272. package/{dist → plugins-dist/tui}/history.js +0 -1
  273. package/plugins-dist/tui/index.js +21 -0
  274. package/{dist/ui → plugins-dist/tui}/markdown.js +0 -1
  275. package/plugins-dist/tui/mentions.js +115 -0
  276. package/plugins-dist/tui/plugin.json +25 -0
  277. package/{dist/ui → plugins-dist/tui}/render.js +7 -3
  278. package/{dist/ui → plugins-dist/tui}/screen.js +6 -2
  279. package/{dist/ui → plugins-dist/tui}/transcript.js +76 -98
  280. package/{dist/ui → plugins-dist/tui}/tui.js +185 -53
  281. package/{dist/tools → plugins-dist/undo}/checkpoint.js +21 -55
  282. package/plugins-dist/undo/index.js +140 -0
  283. package/plugins-dist/undo/notes.js +36 -0
  284. package/plugins-dist/undo/plugin.json +9 -0
  285. package/plugins-dist/undo/style.js +14 -0
  286. package/plugins-dist/update/index.js +34 -0
  287. package/plugins-dist/update/plugin.json +15 -0
  288. package/plugins-dist/web/env.js +80 -0
  289. package/plugins-dist/web/index.js +124 -0
  290. package/plugins-dist/web/plugin.json +21 -0
  291. package/plugins-dist/web/renderers.js +7 -0
  292. package/{dist/tools → plugins-dist/web}/web.js +50 -24
  293. package/sdk/python/__pycache__/jade_plugin.cpython-312.pyc +0 -0
  294. package/sdk/python/jade_plugin.py +380 -0
  295. package/src/api.ts +298 -0
  296. package/src/config.ts +32 -134
  297. package/src/fetch.ts +216 -0
  298. package/src/hash.ts +39 -0
  299. package/src/host.ts +429 -0
  300. package/src/index.ts +23 -30
  301. package/src/install.ts +355 -0
  302. package/src/main.ts +155 -1387
  303. package/src/manifest.ts +160 -0
  304. package/src/membrane.ts +142 -0
  305. package/src/remote.ts +288 -0
  306. package/src/rescue.ts +217 -0
  307. package/src/resolve.ts +199 -0
  308. package/src/rpc.ts +144 -0
  309. package/src/secrets.ts +122 -0
  310. package/src/session.ts +458 -0
  311. package/src/source.ts +83 -0
  312. package/src/state.ts +120 -0
  313. package/src/update.ts +265 -262
  314. package/LICENSE +0 -21
  315. package/README.md +0 -204
  316. package/dist/commands.d.ts +0 -50
  317. package/dist/commands.js +0 -126
  318. package/dist/commands.js.map +0 -1
  319. package/dist/context.d.ts +0 -17
  320. package/dist/context.js +0 -53
  321. package/dist/context.js.map +0 -1
  322. package/dist/distro.d.ts +0 -141
  323. package/dist/distro.js +0 -462
  324. package/dist/distro.js.map +0 -1
  325. package/dist/history.d.ts +0 -10
  326. package/dist/history.js.map +0 -1
  327. package/dist/mcp.d.ts +0 -114
  328. package/dist/mcp.js.map +0 -1
  329. package/dist/memory.d.ts +0 -19
  330. package/dist/memory.js.map +0 -1
  331. package/dist/mentions.d.ts +0 -35
  332. package/dist/mentions.js +0 -130
  333. package/dist/mentions.js.map +0 -1
  334. package/dist/plugin-cli.d.ts +0 -16
  335. package/dist/plugin-cli.js +0 -294
  336. package/dist/plugin-cli.js.map +0 -1
  337. package/dist/plugins/budget.d.ts +0 -9
  338. package/dist/plugins/budget.js +0 -30
  339. package/dist/plugins/budget.js.map +0 -1
  340. package/dist/plugins/builtins.d.ts +0 -10
  341. package/dist/plugins/builtins.js +0 -25
  342. package/dist/plugins/builtins.js.map +0 -1
  343. package/dist/plugins/checks.d.ts +0 -71
  344. package/dist/plugins/checks.js.map +0 -1
  345. package/dist/plugins/compact.d.ts +0 -26
  346. package/dist/plugins/compact.js.map +0 -1
  347. package/dist/plugins/core.d.ts +0 -47
  348. package/dist/plugins/core.js +0 -229
  349. package/dist/plugins/core.js.map +0 -1
  350. package/dist/plugins/host.d.ts +0 -52
  351. package/dist/plugins/host.js +0 -115
  352. package/dist/plugins/host.js.map +0 -1
  353. package/dist/plugins/install.d.ts +0 -68
  354. package/dist/plugins/install.js +0 -377
  355. package/dist/plugins/install.js.map +0 -1
  356. package/dist/plugins/loader.d.ts +0 -410
  357. package/dist/plugins/loader.js +0 -407
  358. package/dist/plugins/loader.js.map +0 -1
  359. package/dist/plugins/policy.d.ts +0 -98
  360. package/dist/plugins/policy.js.map +0 -1
  361. package/dist/plugins/prompts.d.ts +0 -43
  362. package/dist/plugins/prompts.js +0 -284
  363. package/dist/plugins/prompts.js.map +0 -1
  364. package/dist/plugins/repeats.d.ts +0 -16
  365. package/dist/plugins/repeats.js +0 -151
  366. package/dist/plugins/repeats.js.map +0 -1
  367. package/dist/plugins/review.d.ts +0 -18
  368. package/dist/plugins/review.js.map +0 -1
  369. package/dist/plugins/schema.d.ts +0 -2
  370. package/dist/plugins/schema.js.map +0 -1
  371. package/dist/plugins/sessions.d.ts +0 -7
  372. package/dist/plugins/sessions.js +0 -110
  373. package/dist/plugins/sessions.js.map +0 -1
  374. package/dist/provider.d.ts +0 -165
  375. package/dist/provider.js.map +0 -1
  376. package/dist/session-lifecycle.d.ts +0 -61
  377. package/dist/session-lifecycle.js +0 -167
  378. package/dist/session-lifecycle.js.map +0 -1
  379. package/dist/session-scope.d.ts +0 -53
  380. package/dist/session-scope.js +0 -116
  381. package/dist/session-scope.js.map +0 -1
  382. package/dist/sessions.d.ts +0 -28
  383. package/dist/sessions.js +0 -73
  384. package/dist/sessions.js.map +0 -1
  385. package/dist/skills.d.ts +0 -37
  386. package/dist/skills.js.map +0 -1
  387. package/dist/sys.d.ts +0 -51
  388. package/dist/sys.js.map +0 -1
  389. package/dist/tools/ask.d.ts +0 -11
  390. package/dist/tools/ask.js +0 -62
  391. package/dist/tools/ask.js.map +0 -1
  392. package/dist/tools/checkpoint.d.ts +0 -43
  393. package/dist/tools/checkpoint.js.map +0 -1
  394. package/dist/tools/fs.d.ts +0 -39
  395. package/dist/tools/fs.js.map +0 -1
  396. package/dist/tools/grep.d.ts +0 -6
  397. package/dist/tools/grep.js.map +0 -1
  398. package/dist/tools/screenshot.d.ts +0 -15
  399. package/dist/tools/screenshot.js.map +0 -1
  400. package/dist/tools/shell.d.ts +0 -55
  401. package/dist/tools/shell.js.map +0 -1
  402. package/dist/tools/task.d.ts +0 -39
  403. package/dist/tools/task.js +0 -117
  404. package/dist/tools/task.js.map +0 -1
  405. package/dist/tools/todo.d.ts +0 -10
  406. package/dist/tools/todo.js.map +0 -1
  407. package/dist/tools/web.d.ts +0 -53
  408. package/dist/tools/web.js.map +0 -1
  409. package/dist/ui/configure.d.ts +0 -20
  410. package/dist/ui/configure.js +0 -447
  411. package/dist/ui/configure.js.map +0 -1
  412. package/dist/ui/diff.d.ts +0 -20
  413. package/dist/ui/diff.js.map +0 -1
  414. package/dist/ui/editor.d.ts +0 -41
  415. package/dist/ui/editor.js.map +0 -1
  416. package/dist/ui/markdown.d.ts +0 -22
  417. package/dist/ui/markdown.js.map +0 -1
  418. package/dist/ui/render.d.ts +0 -14
  419. package/dist/ui/render.js.map +0 -1
  420. package/dist/ui/renderers.d.ts +0 -8
  421. package/dist/ui/renderers.js.map +0 -1
  422. package/dist/ui/screen.d.ts +0 -118
  423. package/dist/ui/screen.js.map +0 -1
  424. package/dist/ui/transcript.d.ts +0 -46
  425. package/dist/ui/transcript.js.map +0 -1
  426. package/dist/ui/tui.d.ts +0 -47
  427. package/dist/ui/tui.js.map +0 -1
  428. package/src/commands.ts +0 -144
  429. package/src/context.ts +0 -64
  430. package/src/distro.ts +0 -577
  431. package/src/mentions.ts +0 -135
  432. package/src/plugin-cli.ts +0 -278
  433. package/src/plugins/budget.ts +0 -37
  434. package/src/plugins/builtins.ts +0 -34
  435. package/src/plugins/core.ts +0 -257
  436. package/src/plugins/host.ts +0 -146
  437. package/src/plugins/install.ts +0 -429
  438. package/src/plugins/loader.ts +0 -742
  439. package/src/plugins/prompts.ts +0 -327
  440. package/src/plugins/repeats.ts +0 -157
  441. package/src/plugins/sessions.ts +0 -109
  442. package/src/session-lifecycle.ts +0 -194
  443. package/src/session-scope.ts +0 -135
  444. package/src/sessions.ts +0 -78
  445. package/src/tools/ask.ts +0 -72
  446. package/src/tools/task.ts +0 -149
  447. package/src/ui/configure.ts +0 -471
  448. /package/{src/plugins → plugins/approval}/schema.ts +0 -0
  449. /package/{src → plugins/tui}/history.ts +0 -0
  450. /package/{src/ui → plugins/tui}/markdown.ts +0 -0
@@ -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
+ }
@@ -0,0 +1,49 @@
1
+ // 仓库目录、显示用的小工具。插件之间不共享代码(只能共享类型),jade/mcp、jade/checks 各有一份。
2
+
3
+ import { existsSync, realpathSync } from "node:fs";
4
+ import path from "node:path";
5
+
6
+ export function realPath(p: string): string {
7
+ try {
8
+ return realpathSync.native(p);
9
+ } catch {
10
+ return path.resolve(p);
11
+ }
12
+ }
13
+
14
+ /** git 仓库的根目录(往上找 .git,目录或文件都算);不在仓库里时是 cwd 本身 */
15
+ export function repoRoot(cwd: string): string {
16
+ let d = path.resolve(cwd);
17
+ for (;;) {
18
+ if (existsSync(path.join(d, ".git"))) return d;
19
+ const parent = path.dirname(d);
20
+ if (parent === d) return path.resolve(cwd);
21
+ d = parent;
22
+ }
23
+ }
24
+
25
+ /** 从仓库根目录到工作目录的每一级目录,远的在前;工作目录不在仓库里时只有工作目录 */
26
+ export function projectDirs(root: string, cwd: string): string[] {
27
+ const rel = path.relative(root, cwd);
28
+ const inside = rel === "" || !(rel === ".." || rel.startsWith(`..${path.sep}`) || path.isAbsolute(rel));
29
+ if (!inside) return [cwd];
30
+ const dirs = [root];
31
+ if (rel) for (const seg of rel.split(path.sep)) dirs.push(path.join(dirs.at(-1)!, seg));
32
+ return dirs;
33
+ }
34
+
35
+ /** 工作目录里的显示成相对路径,外面的显示绝对路径 */
36
+ export function display(cwd: string, full: string): string {
37
+ const rel = path.relative(cwd, full);
38
+ const shown = rel && rel !== ".." && !rel.startsWith(`..${path.sep}`) && !path.isAbsolute(rel) ? rel : full;
39
+ return shown.split(path.sep).join("/");
40
+ }
41
+
42
+ export const clip = (s: string, n: number) => (s.length > n ? s.slice(0, n) + "…" : s);
43
+
44
+ // 设了 NO_COLOR(非空)或标准输出不是终端时不输出颜色,见 https://no-color.org
45
+ const colors = Boolean(process.stdout.isTTY) && !process.env.NO_COLOR;
46
+ const paint = (open: string, close: string) => (s: string) =>
47
+ colors ? `\x1b[${open}m${s.replaceAll(`\x1b[${close}m`, `\x1b[${close}m\x1b[${open}m`)}\x1b[${close}m` : s;
48
+ export const dim = paint("2", "22");
49
+ export const bold = paint("1", "22");
@@ -11,12 +11,13 @@
11
11
  // 查找位置(同名时后面的覆盖前面的):
12
12
  // ~/.claude/skills、$JADE_HOME/skills(用户层);
13
13
  // 仓库根目录到工作目录每一级的 .claude/skills、.jade/skills(项目层)。
14
+ // 从旧 jade 的 src/skills.ts 移植;旧 jade 的"插件自带 skills 目录"(PluginBundle)没有移植:新的插件宿主没有内容包的概念。
14
15
 
15
16
  import { readdir, readFile, stat } from "node:fs/promises";
16
17
  import os from "node:os";
17
18
  import path from "node:path";
18
19
  import type { Tool } from "uncarved";
19
- import { projectDirs } from "./commands.ts";
20
+ import { projectDirs } from "./project.ts";
20
21
 
21
22
  export interface Skill {
22
23
  name: string;
@@ -26,8 +27,6 @@ export interface Skill {
26
27
  layer: "user" | "project";
27
28
  /** 前一个同名 skill 被它覆盖 */
28
29
  overrides?: string;
29
- /** 来自哪个插件 */
30
- plugin?: string;
31
30
  }
32
31
 
33
32
  const NAME = /^[a-z0-9][a-z0-9_-]*$/i;
@@ -42,15 +41,10 @@ export async function loadSkills(opts: {
42
41
  cwd: string;
43
42
  /** 用户的主目录,读 ~/.claude/skills 用;测试时可以换掉 */
44
43
  userHome?: string;
45
- /** 插件带的 skills 目录,优先级低于同一层的 skills 目录 */
46
- plugins?: { plugin: string; dir: string; layer: Skill["layer"] }[];
47
44
  }): Promise<{ skills: Skill[]; warnings: string[] }> {
48
- const fromPlugins = (layer: Skill["layer"]) => (opts.plugins ?? []).filter((p) => p.layer === layer);
49
- const dirs: { dir: string; layer: Skill["layer"]; plugin?: string }[] = [
50
- ...fromPlugins("user"),
45
+ const dirs: { dir: string; layer: Skill["layer"] }[] = [
51
46
  { dir: path.join(opts.userHome ?? os.homedir(), ".claude", "skills"), layer: "user" },
52
47
  { dir: path.join(opts.home, "skills"), layer: "user" },
53
- ...fromPlugins("project"),
54
48
  ];
55
49
  for (const d of projectDirs(opts.root, opts.cwd)) {
56
50
  dirs.push({ dir: path.join(d, ".claude", "skills"), layer: "project" }, { dir: path.join(d, ".jade", "skills"), layer: "project" });
@@ -58,7 +52,7 @@ export async function loadSkills(opts: {
58
52
  const out = new Map<string, Skill>();
59
53
  const warnings: string[] = [];
60
54
  const seen = new Set<string>();
61
- for (const { dir, layer, plugin } of dirs) {
55
+ for (const { dir, layer } of dirs) {
62
56
  // JADE_HOME 就是 ~/.claude 之类的情况,同一个目录不读两次
63
57
  if (seen.has(path.resolve(dir))) continue;
64
58
  seen.add(path.resolve(dir));
@@ -96,7 +90,6 @@ export async function loadSkills(opts: {
96
90
  dir: skillDir,
97
91
  layer,
98
92
  overrides: prev?.dir,
99
- ...(plugin ? { plugin } : {}),
100
93
  });
101
94
  }
102
95
  }