@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,222 @@
1
+ // jade/modes:权限模式的切换。模式本身归 jade/approval(approval@1),这里提供切换方式和给前端显示的状态:
2
+ // Shift+Tab 在 ask → auto → plan 之间轮换,/mode 查看或选择,modes@1 让前端显示当前模式、在模式变化时更新。
3
+ //
4
+ // 计划模式的两件事也在这里:
5
+ // - 在 plan 模式时经 prompts@1 往系统提示词里加一段,告诉模型先给计划、不要改东西(切出去时去掉)
6
+ // - propose_plan 工具:模型写好要执行的计划后调用它,问用户要不要执行;批准了就换模式,工具结果告诉模型开始做。
7
+ // 由模型声明"这是要执行的计划",追问、回答问题、只要计划本身(比如健身计划)的回复不会被当成计划去问。
8
+ // 用户的选择在工具结果里,会话日志里看得到
9
+
10
+ import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
11
+ import path from "node:path";
12
+ import type { Tool } from "uncarved";
13
+ import { definePlugin, type UI } from "../../src/api.ts";
14
+ import type { Approval } from "../approval/index.ts";
15
+ import type { Commands } from "../commands/index.ts";
16
+ import type { Keys } from "../keys/index.ts";
17
+ import type { Prompts } from "../prompts/index.ts";
18
+
19
+ /** modes@1 */
20
+ export interface Modes {
21
+ current(): string;
22
+ list(): { name: string; description: string }[];
23
+ /** 换模式,从下一个工具调用起生效 */
24
+ set(mode: string): void;
25
+ /** 换到轮换顺序里的下一个 */
26
+ cycle(): string;
27
+ /** 模式变化时调用,返回取消订阅的函数;调用方关闭时自动取消 */
28
+ subscribe(fn: (mode: string) => void): () => void;
29
+ }
30
+
31
+ export const DESCRIPTIONS: Record<string, string> = {
32
+ ask: "ask before edits and commands",
33
+ auto: "edits in this directory and harmless commands run without asking; others still ask",
34
+ plan: "change nothing: research read-only and propose a plan",
35
+ readonly: "change nothing",
36
+ yolo: "never ask",
37
+ };
38
+ const CYCLE = ["ask", "auto", "plan"];
39
+
40
+ /** 计划模式时加进系统提示词的段落;不能问用户(-p、非终端)时没有 propose_plan,只让模型给出计划后停下 */
41
+ export function planNote(canPropose: boolean): string {
42
+ return (
43
+ "The session is in plan mode. Investigate with read-only tools (and the task tool for broad searches); do not try to modify files " +
44
+ "or run commands that change anything, such calls are denied. If the request is unclear in a way that changes the plan, ask the user first. " +
45
+ "When the task needs changes made (files edited, commands run), reply with a concise, concrete plan: the steps in order (for code, the files to change and how), " +
46
+ "any open questions, and how you will verify the result. " +
47
+ (canPropose
48
+ ? "Then call propose_plan so the user can approve it. If nothing needs to be executed (a question, or the plan itself is the answer the user wants), " +
49
+ "just answer and do not call propose_plan."
50
+ : "Then stop and wait for the user's approval.")
51
+ );
52
+ }
53
+
54
+ /** 批准计划之后工具结果里的那句 */
55
+ export const APPROVED_NOTE = "The user approved the plan. Implement it now.";
56
+ /** 没批准时工具结果里的那句 */
57
+ export const NOT_APPROVED = "The user did not approve the plan yet. End your turn and wait for their feedback.";
58
+
59
+ export const PROPOSE_PLAN = "propose_plan";
60
+
61
+ /** propose_plan:问用户要不要执行刚写好的计划,批准了就换到用户选的模式 */
62
+ export function proposePlanTool(approval: Approval, ui: UI): Tool {
63
+ return {
64
+ name: PROPOSE_PLAN,
65
+ description:
66
+ "In plan mode, ask the user to approve the plan you just wrote in your reply, and wait for the answer. Write the full plan in your reply text first; " +
67
+ "call this only for a plan of changes to execute, not for questions, clarifications or answers that need nothing executed.",
68
+ inputSchema: { type: "object", properties: {}, additionalProperties: false },
69
+ // 不碰文件和进程:plan 模式下不用批准
70
+ effect: "read",
71
+ concurrency: "exclusive",
72
+ idempotent: false,
73
+ async execute(_input, ctx) {
74
+ if (approval.mode() !== "plan") return { content: "The session is not in plan mode; no approval is needed.", isError: true };
75
+ const choice = await ui.select(
76
+ {
77
+ title: "Execute this plan?",
78
+ options: [
79
+ { label: "Yes, in auto mode", value: "auto", hint: "edits and safe commands run without asking" },
80
+ { label: "Yes, and ask before each edit", value: "ask", hint: "mode ask" },
81
+ { label: "No, keep planning", value: "plan", hint: "type what to change" },
82
+ ],
83
+ },
84
+ ctx.signal,
85
+ );
86
+ ctx.signal.throwIfAborted();
87
+ if (choice !== "auto" && choice !== "ask") return { content: NOT_APPROVED };
88
+ setMode(approval, choice);
89
+ return { content: `${APPROVED_NOTE} (mode: ${choice})` };
90
+ },
91
+ };
92
+ }
93
+
94
+ /** 模式变化时通知前端和会话里的订阅者(模块每个进程只加载一次,进程级和会话级共用) */
95
+ const listeners = new Set<(mode: string) => void>();
96
+
97
+ /**
98
+ * 用户选的模式记在 $JADE_HOME/mode.json,下次启动接着用(比配置里的 mode 优先)。
99
+ * plan 是一次任务里的,yolo 不该悄悄带到下一次启动:这两个不记
100
+ */
101
+ const REMEMBERED = new Set(["ask", "auto", "readonly"]);
102
+ let modeFile: string | undefined;
103
+ /** 记下的模式只在第一个可交互的会话里恢复一次:jade -p 这类不能问用户的运行一直用配置的模式 */
104
+ let restored = false;
105
+
106
+ function readRemembered(file: string): string | undefined {
107
+ try {
108
+ const mode = (JSON.parse(readFileSync(file, "utf8")) as { mode?: unknown }).mode;
109
+ return typeof mode === "string" && REMEMBERED.has(mode) ? mode : undefined;
110
+ } catch {
111
+ return undefined;
112
+ }
113
+ }
114
+
115
+ function remember(mode: string): void {
116
+ if (!modeFile || !REMEMBERED.has(mode)) return;
117
+ try {
118
+ // 同步写:连按几次 Shift+Tab 时,文件里留下的一定是最后一次
119
+ mkdirSync(path.dirname(modeFile), { recursive: true });
120
+ writeFileSync(modeFile, `${JSON.stringify({ mode })}\n`);
121
+ } catch {
122
+ // 记不下只是下次从配置的模式开始
123
+ }
124
+ }
125
+
126
+ function setMode(approval: Approval, mode: string): void {
127
+ if (mode === approval.mode()) return;
128
+ approval.setMode(mode as ReturnType<Approval["mode"]>);
129
+ remember(mode);
130
+ for (const fn of [...listeners]) {
131
+ try {
132
+ fn(mode);
133
+ } catch {
134
+ // 订阅者的错误经过膜归它自己,不影响别的订阅者
135
+ }
136
+ }
137
+ }
138
+
139
+ export default definePlugin({
140
+ process(ctx) {
141
+ const approval = ctx.require<Approval>("approval@1");
142
+ modeFile = path.join(ctx.home, "mode.json");
143
+ restored = false;
144
+ const set = (mode: string) => setMode(approval, mode);
145
+ const cycle = () => {
146
+ const next = CYCLE[(CYCLE.indexOf(approval.mode()) + 1) % CYCLE.length]!;
147
+ set(next);
148
+ return next;
149
+ };
150
+ const list = () => Object.entries(DESCRIPTIONS).map(([name, description]) => ({ name, description }));
151
+
152
+ ctx.provide("modes@1", (caller): Modes => ({
153
+ current: () => approval.mode(),
154
+ list,
155
+ set,
156
+ cycle,
157
+ subscribe(fn) {
158
+ listeners.add(fn);
159
+ const off = () => void listeners.delete(fn);
160
+ caller.onDispose(off);
161
+ return off;
162
+ },
163
+ }));
164
+
165
+ ctx.service<Keys>("keys@1")?.register({ key: "shift+tab", description: "cycle ask/auto/plan", run: () => void cycle() });
166
+ ctx.service<Commands>("commands@1")?.register({
167
+ name: "mode",
168
+ args: `[${Object.keys(DESCRIPTIONS).join("|")}]`,
169
+ description: "show or change the permission mode",
170
+ instant: true,
171
+ async run(args, c) {
172
+ let want: string | undefined = args.trim() || undefined;
173
+ if (!want) {
174
+ want = await c.ui.select(
175
+ { title: "Permission mode", options: list().map((m) => ({ label: m.name, value: m.name, hint: m.name === approval.mode() ? "current" : m.description })) },
176
+ c.signal,
177
+ );
178
+ if (!want) return;
179
+ }
180
+ if (!(want in DESCRIPTIONS)) return `unknown mode ${want}; one of ${Object.keys(DESCRIPTIONS).join(", ")}`;
181
+ set(want);
182
+ return `mode: ${approval.mode()}`;
183
+ },
184
+ });
185
+ },
186
+
187
+ session(ctx) {
188
+ const approval = ctx.require<Approval>("approval@1");
189
+ const prompts = ctx.service<Prompts>("prompts@1");
190
+ const ui = ctx.service<UI>("ui@1");
191
+
192
+ if (!restored && ui?.interactive && modeFile) {
193
+ restored = true;
194
+ const saved = readRemembered(modeFile);
195
+ if (saved) setMode(approval, saved);
196
+ }
197
+
198
+ // 能问用户时才有 propose_plan;它只在 plan 模式下发给模型
199
+ const canPropose = !!ui?.interactive;
200
+ if (canPropose) ctx.kernel.tool(proposePlanTool(approval, ui!));
201
+ ctx.kernel.hook({
202
+ kind: "transform",
203
+ point: "context.build",
204
+ fn: (req) => (approval.mode() === "plan" ? req : { ...req, tools: req.tools.filter((t) => t.name !== PROPOSE_PLAN) }),
205
+ });
206
+
207
+ // 计划模式的说明跟着模式进出系统提示词
208
+ let note: (() => void) | undefined;
209
+ const sync = () => {
210
+ const plan = approval.mode() === "plan";
211
+ if (plan && !note && prompts) note = prompts.add({ text: planNote(canPropose), stable: false });
212
+ else if (!plan && note) {
213
+ note();
214
+ note = undefined;
215
+ }
216
+ };
217
+ sync();
218
+ const onChange = () => sync();
219
+ listeners.add(onChange);
220
+ ctx.effect(() => () => void listeners.delete(onChange));
221
+ },
222
+ });
@@ -0,0 +1,9 @@
1
+ {
2
+ "id": "jade/modes",
3
+ "version": "0.2.0",
4
+ "api": "^1",
5
+ "entry": "./index.ts",
6
+ "provides": ["modes@1"],
7
+ "requires": ["approval@1"],
8
+ "optional": ["keys@1", "commands@1", "prompts@1", "ui@1"]
9
+ }
@@ -0,0 +1,38 @@
1
+ // jade/plugins:/plugins 命令。列出这次启动里每个插件的状态和原因(failed、skipped、conflicted……),
2
+ // 以及每个服务由谁提供。数据来自核心自己的 jade@1 服务,和救援 CLI `jade plugins list` 是同一份状态。
3
+
4
+ import { definePlugin, type Jade } from "../../src/api.ts";
5
+ import type { Commands } from "../commands/index.ts";
6
+
7
+ export default definePlugin({
8
+ process(ctx) {
9
+ const commands = ctx.require<Commands>("commands@1");
10
+ const jade = ctx.require<Jade>("jade@1");
11
+
12
+ commands.register({
13
+ name: "plugins",
14
+ args: "[id]",
15
+ description: "every plugin's state and why it is not active, and who provides each service",
16
+ // 只读,不碰会话
17
+ instant: true,
18
+ run(args) {
19
+ const all = jade.plugins();
20
+ const query = args.trim();
21
+ if (query) {
22
+ const found = all.filter((p) => p.id === query || p.id?.endsWith(`/${query}`) || p.dir === query);
23
+ if (found.length === 0) return `No plugin matches ${query}. /plugins lists them all.`;
24
+ const lines = found.map((p) => `${p.id ?? p.dir}@${p.version ?? "?"} ${p.layer} ${p.state}${p.reason ? ` ${p.reason}` : ""}\n ${p.dir}`);
25
+ for (const s of jade.services().filter((s) => found.some((p) => p.id === s.provider))) lines.push(` provides ${s.service}`);
26
+ return lines.join("\n");
27
+ }
28
+
29
+ const lines = all.map((p) => `${p.id ?? p.dir}@${p.version ?? "?"} ${p.layer} ${p.state}${p.reason ? ` ${p.reason}` : ""}`);
30
+ const broken = all.filter((p) => p.state !== "active");
31
+ if (broken.length > 0) lines.push("", `${broken.length} of ${all.length} plugins are not active; /plugins <id> shows where one lives.`);
32
+ const services = jade.services();
33
+ if (services.length > 0) lines.push("", "services:", ...services.map((s) => ` ${s.service} ${s.provider}`));
34
+ return lines.join("\n");
35
+ },
36
+ });
37
+ },
38
+ });
@@ -0,0 +1,7 @@
1
+ {
2
+ "id": "jade/plugins",
3
+ "version": "0.1.0",
4
+ "api": "^1",
5
+ "entry": "./index.ts",
6
+ "requires": ["commands@1", "jade@1"]
7
+ }
@@ -0,0 +1,142 @@
1
+ // jade/print:jade -p "<prompt>" 跑一轮就退出。模型的回复写到 stdout,工具调用和提示写到 stderr。
2
+ // 不能向用户提问:ui@1 的 select 总是返回 undefined,要审批的调用由审批插件拒绝。
3
+
4
+ import type { Block, LogEvent, RuntimeNotice } from "uncarved";
5
+ import { definePlugin, type Frontend, type UI } from "../../src/api.ts";
6
+
7
+ const USAGE = `usage: jade -p <prompt> [--resume <session id>]
8
+ echo <prompt> | jade -p
9
+
10
+ Runs one prompt and exits. The reply goes to stdout; tool calls and notices go to stderr.
11
+ Exit code: 0 when the turn ends normally, 1 on an error, 130 when interrupted.`;
12
+
13
+ const ui: UI = {
14
+ interactive: false,
15
+ notify(message, level = "info") {
16
+ process.stderr.write(`${level === "info" ? "" : `[${level}] `}${message}\n`);
17
+ },
18
+ select: async () => undefined,
19
+ input: async () => undefined,
20
+ };
21
+
22
+ const frontend: Frontend = {
23
+ async run({ argv, sessions }) {
24
+ const args = parse(argv);
25
+ if (typeof args === "string") {
26
+ process.stderr.write(`${args}\n\n${USAGE}\n`);
27
+ return 2;
28
+ }
29
+ if (args.help) {
30
+ process.stdout.write(`${USAGE}\n`);
31
+ return 0;
32
+ }
33
+ const prompt = args.prompt ?? (process.stdin.isTTY ? "" : (await readStdin()).trim());
34
+ if (!prompt) {
35
+ process.stderr.write(`no prompt given\n\n${USAGE}\n`);
36
+ return 2;
37
+ }
38
+
39
+ const session = await sessions.open(args.resume ? { resume: args.resume } : {});
40
+ let ended: { reason: string; error?: string } | undefined;
41
+ let midLine = false;
42
+ const out = (text: string) => {
43
+ process.stdout.write(text);
44
+ midLine = !text.endsWith("\n");
45
+ };
46
+ /** 这次模型调用推送过文字增量;没推送的(不流式的服务),回复到了再一次写出 */
47
+ let streamed = false;
48
+ const unsubscribe = session.subscribe((n: RuntimeNotice) => {
49
+ if (n.type === "delta" && n.delta.kind === "text") {
50
+ streamed = true;
51
+ out(n.delta.text);
52
+ }
53
+ if (n.type !== "event") return;
54
+ const e = n.event as LogEvent;
55
+ if (e.type === "model.responded") {
56
+ const content = (e.data as { content: Block[] }).content;
57
+ if (!streamed) for (const b of content) if (b.kind === "text") out(b.text);
58
+ streamed = false;
59
+ if (midLine) out("\n");
60
+ for (const b of content) if (b.kind === "tool_use") process.stderr.write(`· ${b.name} ${summary(b.input)}\n`);
61
+ }
62
+ if (e.type === "tool.decided") {
63
+ const d = e.data as { decision: string; reason?: string };
64
+ if (d.decision === "deny") process.stderr.write(` denied${d.reason ? `: ${d.reason}` : ""}\n`);
65
+ }
66
+ if (e.type === "tool.completed") {
67
+ const d = e.data as { isError: boolean; content: Block[] };
68
+ if (d.isError) process.stderr.write(` failed: ${firstLine(d.content)}\n`);
69
+ }
70
+ if (e.type === "turn.ended") ended = e.data as { reason: string; error?: string };
71
+ });
72
+
73
+ const interrupt = () => session.abort(new Error("interrupted"));
74
+ process.once("SIGINT", interrupt);
75
+ let failure: unknown;
76
+ try {
77
+ if (args.resume) await session.recover();
78
+ await session.send({ kind: "message", content: [{ kind: "text", text: prompt, origin: { by: "user" }, trust: "trusted" }] });
79
+ await session.idle();
80
+ } catch (e) {
81
+ failure = e;
82
+ } finally {
83
+ process.off("SIGINT", interrupt);
84
+ unsubscribe();
85
+ }
86
+ if (midLine) out("\n");
87
+ process.stderr.write(`session ${session.id}\n`);
88
+ const end = ended as { reason: string; error?: string } | undefined;
89
+ if (end?.reason === "aborted") return 130;
90
+ if (failure !== undefined || end?.reason === "error") {
91
+ // 模型服务的错误经过膜时包成了 PluginError,用户要看的是原因
92
+ const cause = failure instanceof Error && failure.cause instanceof Error ? failure.cause : failure;
93
+ process.stderr.write(`error: ${cause instanceof Error ? cause.message : (end?.error ?? String(cause ?? "the turn failed"))}\n`);
94
+ return 1;
95
+ }
96
+ return 0;
97
+ },
98
+ };
99
+
100
+ export default definePlugin({
101
+ process(ctx) {
102
+ ctx.provide("ui@1", ui);
103
+ ctx.provide("frontend@1", frontend);
104
+ },
105
+ });
106
+
107
+ function parse(argv: readonly string[]): { prompt?: string; resume?: string; help?: boolean } | string {
108
+ const out: { prompt?: string; resume?: string; help?: boolean } = {};
109
+ const words: string[] = [];
110
+ for (let i = 0; i < argv.length; i++) {
111
+ const a = argv[i]!;
112
+ if (a === "-p" || a === "--print") continue;
113
+ if (a === "-h" || a === "--help") out.help = true;
114
+ else if (a === "--resume") {
115
+ const id = argv[++i];
116
+ if (!id) return "--resume needs a session id";
117
+ out.resume = id;
118
+ } else if (a.startsWith("-")) return `unknown option ${a}`;
119
+ else words.push(a);
120
+ }
121
+ if (words.length > 0) out.prompt = words.join(" ");
122
+ return out;
123
+ }
124
+
125
+ async function readStdin(): Promise<string> {
126
+ const chunks: Buffer[] = [];
127
+ for await (const c of process.stdin) chunks.push(c as Buffer);
128
+ return Buffer.concat(chunks).toString("utf8");
129
+ }
130
+
131
+ /** 工具参数的一行摘要:常见的 path、command、pattern,其余是截断的 JSON */
132
+ function summary(input: unknown): string {
133
+ const i = input as Record<string, unknown> | null;
134
+ const s = typeof i?.command === "string" ? i.command : typeof i?.path === "string" ? i.path : typeof i?.pattern === "string" ? i.pattern : JSON.stringify(input);
135
+ const line = (s ?? "").split("\n")[0]!;
136
+ return line.length > 120 ? `${line.slice(0, 120)}…` : line;
137
+ }
138
+
139
+ function firstLine(content: Block[]): string {
140
+ const text = content.find((b) => b.kind === "text");
141
+ return text && "text" in text ? text.text.split("\n")[0]! : "(no message)";
142
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "id": "jade/print",
3
+ "version": "0.2.0",
4
+ "api": "^1",
5
+ "entry": "./index.ts",
6
+ "provides": ["frontend@1", "ui@1"],
7
+ "frontend": { "name": "print", "flag": "-p" }
8
+ }
@@ -0,0 +1,83 @@
1
+ // jade/prompts:在 context.build 里生成系统提示词。其他插件经 prompts@1 往里加段落。
2
+
3
+ import path from "node:path";
4
+ import type { ContentSource, SystemSegment } from "uncarved";
5
+ import { definePlugin, type UI } from "../../src/api.ts";
6
+ import type { Models } from "../models/index.ts";
7
+ import { allInstructions, environment, mainPrompt, realPath } from "./prompts.ts";
8
+
9
+ /** prompts@1 */
10
+ export interface Prompts {
11
+ /**
12
+ * 往系统提示词里加一段,排在主体、环境信息和指令文件之后,返回撤销函数;调用方的作用域关闭时自动撤销。
13
+ * stable(默认 true)的段落排在 volatile 的前面:会变的段落放在后面,前面的才能命中提示缓存。
14
+ * 项目层插件加的段落标为不可信;untrusted 为 true 时也标为不可信(内容来自外部,例如 MCP 服务的说明、仓库里的 skill)
15
+ */
16
+ add(section: { text: string; stable?: boolean; untrusted?: boolean }): () => void;
17
+ }
18
+
19
+ interface Section {
20
+ plugin: string;
21
+ text: string;
22
+ stable: boolean;
23
+ trusted: boolean;
24
+ }
25
+
26
+ const ID = "jade/prompts";
27
+
28
+ /** 其他插件加的段落。模块每个进程只加载一次,进程级和会话级共用 */
29
+ const sections: Section[] = [];
30
+
31
+ function segment(text: string, trust: SystemSegment["trust"] = "trusted", stability: SystemSegment["stability"] = "stable", by = ID, source?: ContentSource): SystemSegment {
32
+ return { text, stability, origin: { by: "plugin", id: by, ...(source ? { source } : {}) }, trust };
33
+ }
34
+
35
+ /** 工作目录里的显示成相对路径,外面的显示绝对路径 */
36
+ 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 default definePlugin({
43
+ process(ctx) {
44
+ ctx.provide("prompts@1", (caller): Prompts => ({
45
+ add({ text, stable = true, untrusted = false }) {
46
+ if (typeof text !== "string" || !text) throw new Error("prompts.add: text must be a non-empty string");
47
+ const s: Section = { plugin: caller.plugin, text, stable, trusted: caller.layer !== "project" && untrusted !== true };
48
+ sections.push(s);
49
+ const remove = () => {
50
+ const i = sections.indexOf(s);
51
+ if (i !== -1) sections.splice(i, 1);
52
+ };
53
+ caller.onDispose(remove);
54
+ return remove;
55
+ },
56
+ }));
57
+ },
58
+
59
+ async session(ctx) {
60
+ const models = ctx.service<Models>("models@1");
61
+ const [env, instructions] = await Promise.all([environment(ctx.cwd), allInstructions(ctx.home, ctx.cwd)]);
62
+ const fixed = [segment(env), ...instructions.map((i) => segment(i.text, i.trust, "stable", ID, i.source))];
63
+ // 告诉用户读了哪些指令文件,否则看不出它们生效了
64
+ if (instructions.length > 0) ctx.service<UI>("ui@1")?.notify(`loaded instructions: ${instructions.map((i) => display(realPath(ctx.cwd), i.file)).join(", ")}`);
65
+
66
+ ctx.kernel.hook({
67
+ kind: "transform",
68
+ point: "context.build",
69
+ fn: (req) => {
70
+ const main = segment(mainPrompt(new Set(req.tools.map((t) => t.name))));
71
+ const model = models?.current();
72
+ // 说成"配置的模型":服务商的别名、路由背后实际回复的可能是别的模型
73
+ const modelLine = model?.model
74
+ ? [segment(`Jade is configured to use the model "${model.model}" via ${model.via}. If the user asks which model you are, answer with this rather than guessing from your training.`)]
75
+ : [];
76
+ const extra = [...sections.filter((s) => s.stable), ...sections.filter((s) => !s.stable)].map((s) =>
77
+ segment(s.text, s.trusted ? "trusted" : "untrusted", s.stable ? "stable" : "volatile", s.plugin),
78
+ );
79
+ return { ...req, system: [main, ...fixed, ...modelLine, ...extra, ...req.system] };
80
+ },
81
+ });
82
+ },
83
+ });
@@ -0,0 +1,8 @@
1
+ {
2
+ "id": "jade/prompts",
3
+ "version": "0.4.0",
4
+ "api": "^1",
5
+ "entry": "./index.ts",
6
+ "provides": ["prompts@1"],
7
+ "optional": ["models@1", "ui@1"]
8
+ }