@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.
- package/README.md +161 -150
- package/bin/jade.js +14 -25
- package/dist/api.d.ts +266 -0
- package/dist/api.js +38 -0
- package/dist/api.js.map +1 -0
- package/dist/config.d.ts +13 -32
- package/dist/config.js +39 -121
- package/dist/config.js.map +1 -1
- package/dist/fetch.d.ts +20 -0
- package/dist/fetch.js +190 -0
- package/dist/fetch.js.map +1 -0
- package/dist/hash.d.ts +2 -0
- package/dist/hash.js +42 -0
- package/dist/hash.js.map +1 -0
- package/dist/host.d.ts +71 -0
- package/dist/host.js +400 -0
- package/dist/host.js.map +1 -0
- package/dist/index.d.ts +11 -30
- package/dist/index.js +11 -30
- package/dist/index.js.map +1 -1
- package/dist/install.d.ts +78 -0
- package/dist/install.js +292 -0
- package/dist/install.js.map +1 -0
- package/dist/main.d.ts +1 -2
- package/dist/main.js +160 -1362
- package/dist/main.js.map +1 -1
- package/dist/manifest.d.ts +23 -0
- package/dist/manifest.js +159 -0
- package/dist/manifest.js.map +1 -0
- package/dist/membrane.d.ts +33 -0
- package/dist/membrane.js +140 -0
- package/dist/membrane.js.map +1 -0
- package/dist/remote.d.ts +10 -0
- package/dist/remote.js +292 -0
- package/dist/remote.js.map +1 -0
- package/dist/rescue.d.ts +10 -0
- package/dist/rescue.js +216 -0
- package/dist/rescue.js.map +1 -0
- package/dist/resolve.d.ts +34 -0
- package/dist/resolve.js +178 -0
- package/dist/resolve.js.map +1 -0
- package/dist/rpc.d.ts +26 -0
- package/dist/rpc.js +144 -0
- package/dist/rpc.js.map +1 -0
- package/dist/secrets.d.ts +12 -0
- package/dist/secrets.js +125 -0
- package/dist/secrets.js.map +1 -0
- package/dist/session.d.ts +45 -0
- package/dist/session.js +401 -0
- package/dist/session.js.map +1 -0
- package/dist/source.d.ts +12 -0
- package/dist/source.js +72 -0
- package/dist/source.js.map +1 -0
- package/dist/state.d.ts +37 -0
- package/dist/state.js +93 -0
- package/dist/state.js.map +1 -0
- package/dist/update.d.ts +2 -0
- package/dist/update.js +6 -3
- package/dist/update.js.map +1 -1
- package/package.json +10 -8
- package/plugins/approval/index.ts +311 -0
- package/plugins/approval/plugin.json +22 -0
- package/{src/plugins → plugins/approval}/policy.ts +45 -104
- package/{src/plugins → plugins/approval}/review.ts +62 -16
- package/plugins/ask/index.ts +159 -0
- package/plugins/ask/plugin.json +8 -0
- package/plugins/budget/index.ts +38 -0
- package/plugins/budget/plugin.json +13 -0
- package/{src/plugins → plugins/checks}/checks.ts +48 -38
- package/plugins/checks/index.ts +158 -0
- package/plugins/checks/plugin.json +14 -0
- package/plugins/checks/project.ts +81 -0
- package/plugins/commands/index.ts +76 -0
- package/plugins/commands/plugin.json +7 -0
- package/{src/plugins → plugins/compact}/compact.ts +80 -39
- package/plugins/compact/index.ts +115 -0
- package/plugins/compact/plugin.json +17 -0
- package/plugins/compact/style.ts +17 -0
- package/plugins/continue/index.ts +58 -0
- package/plugins/continue/plugin.json +13 -0
- package/{src/ui → plugins/fs}/diff.ts +2 -2
- package/{src/tools → plugins/fs}/fs.ts +89 -46
- package/{src/tools → plugins/fs}/grep.ts +36 -8
- package/plugins/fs/index.ts +37 -0
- package/plugins/fs/plugin.json +7 -0
- package/{src/ui → plugins/fs}/renderers.ts +25 -70
- package/plugins/fs/style.ts +18 -0
- package/plugins/fs/sys.ts +81 -0
- package/plugins/keys/index.ts +53 -0
- package/plugins/keys/plugin.json +7 -0
- package/plugins/mcp/index.ts +192 -0
- package/{src → plugins/mcp}/mcp.ts +32 -32
- package/plugins/mcp/plugin.json +7 -0
- package/plugins/mcp/project.ts +93 -0
- package/plugins/memory/index.ts +105 -0
- package/{src → plugins/memory}/memory.ts +20 -2
- package/plugins/memory/notes.ts +43 -0
- package/plugins/memory/plugin.json +7 -0
- package/plugins/memory/style.ts +17 -0
- package/plugins/mentions/attach.ts +127 -0
- package/plugins/mentions/index.ts +99 -0
- package/plugins/mentions/plugin.json +7 -0
- package/plugins/mentions/style.ts +17 -0
- package/plugins/models/config.ts +53 -0
- package/plugins/models/configure.ts +455 -0
- package/plugins/models/context.ts +32 -0
- package/plugins/models/index.ts +213 -0
- package/plugins/models/plugin.json +8 -0
- package/{src → plugins/models}/provider.ts +16 -119
- package/plugins/models/saved.ts +94 -0
- package/plugins/modes/index.ts +222 -0
- package/plugins/modes/plugin.json +9 -0
- package/plugins/plugins/index.ts +38 -0
- package/plugins/plugins/plugin.json +7 -0
- package/plugins/print/index.ts +160 -0
- package/plugins/print/plugin.json +8 -0
- package/plugins/prompts/index.ts +111 -0
- package/plugins/prompts/plugin.json +8 -0
- package/plugins/prompts/prompts.ts +258 -0
- package/plugins/prompts/results.ts +63 -0
- package/plugins/prompts/sys.ts +84 -0
- package/plugins/renderers/index.ts +78 -0
- package/plugins/renderers/plugin.json +7 -0
- package/plugins/repeats/index.ts +165 -0
- package/plugins/repeats/plugin.json +6 -0
- package/plugins/schedule/cron.ts +74 -0
- package/plugins/schedule/index.ts +292 -0
- package/plugins/schedule/plugin.json +13 -0
- package/plugins/schedule/store.ts +149 -0
- package/plugins/scratch/index.ts +31 -0
- package/plugins/scratch/plugin.json +7 -0
- package/plugins/screenshot/index.ts +40 -0
- package/plugins/screenshot/plugin.json +7 -0
- package/plugins/screenshot/sys.ts +84 -0
- package/{src/tools/screenshot.ts → plugins/screenshot/tool.ts} +6 -6
- package/plugins/sessions/index.ts +148 -0
- package/plugins/sessions/plugin.json +8 -0
- package/plugins/shell/index.ts +33 -0
- package/plugins/shell/plugin.json +17 -0
- package/plugins/shell/renderers.ts +45 -0
- package/plugins/shell/service.ts +44 -0
- package/{src/tools → plugins/shell}/shell.ts +31 -20
- package/{src → plugins/shell}/sys.ts +2 -43
- package/plugins/skills/index.ts +96 -0
- package/plugins/skills/plugin.json +7 -0
- package/plugins/skills/project.ts +49 -0
- package/{src → plugins/skills}/skills.ts +4 -11
- package/plugins/suggest/index.ts +286 -0
- package/plugins/suggest/plugin.json +18 -0
- package/plugins/task/index.ts +168 -0
- package/plugins/task/plugin.json +15 -0
- package/plugins/task/style.ts +17 -0
- package/plugins/task/subagent.ts +343 -0
- package/plugins/todo/index.ts +93 -0
- package/plugins/todo/plugin.json +7 -0
- package/{src/ui → plugins/tui}/editor.ts +3 -0
- package/plugins/tui/frontend.ts +619 -0
- package/plugins/tui/index.ts +37 -0
- package/plugins/tui/mentions.ts +153 -0
- package/plugins/tui/plugin.json +10 -0
- package/{src/ui → plugins/tui}/render.ts +8 -2
- package/{src/ui → plugins/tui}/screen.ts +8 -3
- package/{src/ui → plugins/tui}/transcript.ts +79 -100
- package/{src/ui/tui.tsx → plugins/tui/tui.ts} +360 -392
- package/plugins/tui/vendor.ts +16 -0
- package/{src/tools → plugins/undo}/checkpoint.ts +45 -60
- package/plugins/undo/index.ts +143 -0
- package/plugins/undo/notes.ts +43 -0
- package/plugins/undo/plugin.json +7 -0
- package/plugins/undo/style.ts +17 -0
- package/plugins/update/index.ts +40 -0
- package/plugins/update/plugin.json +13 -0
- package/plugins/web/env.ts +78 -0
- package/plugins/web/index.ts +133 -0
- package/plugins/web/plugin.json +15 -0
- package/plugins/web/renderers.ts +11 -0
- package/{src/tools → plugins/web}/web.ts +64 -31
- package/plugins-dist/approval/index.js +287 -0
- package/plugins-dist/approval/plugin.json +28 -0
- package/{dist/plugins → plugins-dist/approval}/policy.js +41 -85
- package/{dist/plugins → plugins-dist/approval}/review.js +56 -10
- package/{dist/plugins → plugins-dist/approval}/schema.js +0 -1
- package/plugins-dist/ask/index.js +145 -0
- package/plugins-dist/ask/plugin.json +12 -0
- package/plugins-dist/budget/index.js +37 -0
- package/plugins-dist/budget/plugin.json +15 -0
- package/{dist/plugins → plugins-dist/checks}/checks.js +46 -35
- package/plugins-dist/checks/index.js +150 -0
- package/plugins-dist/checks/plugin.json +21 -0
- package/plugins-dist/checks/project.js +76 -0
- package/plugins-dist/commands/index.js +33 -0
- package/plugins-dist/commands/plugin.json +9 -0
- package/{dist/plugins → plugins-dist/compact}/compact.js +58 -34
- package/plugins-dist/compact/index.js +100 -0
- package/plugins-dist/compact/plugin.json +25 -0
- package/plugins-dist/compact/style.js +14 -0
- package/plugins-dist/continue/index.js +57 -0
- package/plugins-dist/continue/plugin.json +15 -0
- package/{dist/ui → plugins-dist/fs}/diff.js +2 -3
- package/{dist/tools → plugins-dist/fs}/fs.js +82 -46
- package/{dist/tools → plugins-dist/fs}/grep.js +36 -11
- package/plugins-dist/fs/index.js +39 -0
- package/plugins-dist/fs/plugin.json +10 -0
- package/{dist/ui → plugins-dist/fs}/renderers.js +24 -61
- package/plugins-dist/fs/style.js +15 -0
- package/plugins-dist/fs/sys.js +54 -0
- package/plugins-dist/keys/index.js +36 -0
- package/plugins-dist/keys/plugin.json +9 -0
- package/plugins-dist/mcp/index.js +187 -0
- package/{dist → plugins-dist/mcp}/mcp.js +34 -30
- package/plugins-dist/mcp/plugin.json +12 -0
- package/plugins-dist/mcp/project.js +90 -0
- package/plugins-dist/memory/index.js +94 -0
- package/{dist → plugins-dist/memory}/memory.js +21 -3
- package/plugins-dist/memory/notes.js +36 -0
- package/plugins-dist/memory/plugin.json +11 -0
- package/plugins-dist/memory/style.js +14 -0
- package/plugins-dist/mentions/attach.js +120 -0
- package/plugins-dist/mentions/index.js +87 -0
- package/plugins-dist/mentions/plugin.json +9 -0
- package/plugins-dist/mentions/style.js +14 -0
- package/plugins-dist/models/config.js +53 -0
- package/plugins-dist/models/configure.js +415 -0
- package/plugins-dist/models/context.js +27 -0
- package/plugins-dist/models/index.js +181 -0
- package/plugins-dist/models/plugin.json +14 -0
- package/{dist → plugins-dist/models}/provider.js +18 -81
- package/plugins-dist/models/saved.js +80 -0
- package/plugins-dist/modes/index.js +190 -0
- package/plugins-dist/modes/plugin.json +18 -0
- package/plugins-dist/plugins/index.js +37 -0
- package/plugins-dist/plugins/plugin.json +10 -0
- package/plugins-dist/print/index.js +172 -0
- package/plugins-dist/print/plugin.json +14 -0
- package/plugins-dist/prompts/index.js +85 -0
- package/plugins-dist/prompts/plugin.json +13 -0
- package/plugins-dist/prompts/prompts.js +231 -0
- package/plugins-dist/prompts/results.js +60 -0
- package/plugins-dist/prompts/sys.js +58 -0
- package/plugins-dist/renderers/index.js +36 -0
- package/plugins-dist/renderers/plugin.json +9 -0
- package/plugins-dist/repeats/index.js +165 -0
- package/plugins-dist/repeats/plugin.json +6 -0
- package/plugins-dist/schedule/cron.js +67 -0
- package/plugins-dist/schedule/index.js +281 -0
- package/plugins-dist/schedule/plugin.json +16 -0
- package/plugins-dist/schedule/store.js +125 -0
- package/plugins-dist/scratch/index.js +26 -0
- package/plugins-dist/scratch/plugin.json +10 -0
- package/plugins-dist/screenshot/index.js +35 -0
- package/plugins-dist/screenshot/plugin.json +11 -0
- package/plugins-dist/screenshot/sys.js +76 -0
- package/{dist/tools/screenshot.js → plugins-dist/screenshot/tool.js} +5 -4
- package/plugins-dist/sessions/index.js +136 -0
- package/plugins-dist/sessions/plugin.json +12 -0
- package/plugins-dist/shell/index.js +33 -0
- package/plugins-dist/shell/plugin.json +19 -0
- package/plugins-dist/shell/renderers.js +40 -0
- package/plugins-dist/shell/service.js +29 -0
- package/{dist/tools → plugins-dist/shell}/shell.js +31 -22
- package/{dist → plugins-dist/shell}/sys.js +2 -43
- package/plugins-dist/skills/index.js +90 -0
- package/plugins-dist/skills/plugin.json +12 -0
- package/plugins-dist/skills/project.js +47 -0
- package/{dist → plugins-dist/skills}/skills.js +3 -7
- package/plugins-dist/suggest/index.js +282 -0
- package/plugins-dist/suggest/plugin.json +23 -0
- package/plugins-dist/task/index.js +152 -0
- package/plugins-dist/task/plugin.json +23 -0
- package/plugins-dist/task/style.js +14 -0
- package/plugins-dist/task/subagent.js +284 -0
- package/{dist/tools/todo.js → plugins-dist/todo/index.js} +31 -9
- package/plugins-dist/todo/plugin.json +9 -0
- package/{dist/ui → plugins-dist/tui}/editor.js +3 -1
- package/plugins-dist/tui/frontend.js +609 -0
- package/{dist → plugins-dist/tui}/history.js +0 -1
- package/plugins-dist/tui/index.js +21 -0
- package/{dist/ui → plugins-dist/tui}/markdown.js +0 -1
- package/plugins-dist/tui/mentions.js +153 -0
- package/plugins-dist/tui/plugin.json +25 -0
- package/{dist/ui → plugins-dist/tui}/render.js +7 -3
- package/{dist/ui → plugins-dist/tui}/screen.js +6 -2
- package/{dist/ui → plugins-dist/tui}/transcript.js +79 -99
- package/{dist/ui → plugins-dist/tui}/tui.js +185 -54
- package/plugins-dist/tui/vendor.js +13822 -0
- package/{dist/tools → plugins-dist/undo}/checkpoint.js +48 -55
- package/plugins-dist/undo/index.js +143 -0
- package/plugins-dist/undo/notes.js +36 -0
- package/plugins-dist/undo/plugin.json +9 -0
- package/plugins-dist/undo/style.js +14 -0
- package/plugins-dist/update/index.js +34 -0
- package/plugins-dist/update/plugin.json +15 -0
- package/plugins-dist/web/env.js +80 -0
- package/plugins-dist/web/index.js +124 -0
- package/plugins-dist/web/plugin.json +21 -0
- package/plugins-dist/web/renderers.js +7 -0
- package/{dist/tools → plugins-dist/web}/web.js +56 -29
- package/sdk/python/__pycache__/jade_plugin.cpython-312.pyc +0 -0
- package/sdk/python/jade_plugin.py +380 -0
- package/src/api.ts +298 -0
- package/src/config.ts +32 -134
- package/src/fetch.ts +216 -0
- package/src/hash.ts +39 -0
- package/src/host.ts +429 -0
- package/src/index.ts +23 -30
- package/src/install.ts +355 -0
- package/src/main.ts +156 -1387
- package/src/manifest.ts +160 -0
- package/src/membrane.ts +142 -0
- package/src/remote.ts +288 -0
- package/src/rescue.ts +217 -0
- package/src/resolve.ts +199 -0
- package/src/rpc.ts +144 -0
- package/src/secrets.ts +122 -0
- package/src/session.ts +458 -0
- package/src/source.ts +83 -0
- package/src/state.ts +120 -0
- package/src/update.ts +265 -262
- package/LICENSE +0 -21
- package/dist/commands.d.ts +0 -50
- package/dist/commands.js +0 -126
- package/dist/commands.js.map +0 -1
- package/dist/context.d.ts +0 -17
- package/dist/context.js +0 -53
- package/dist/context.js.map +0 -1
- package/dist/distro.d.ts +0 -141
- package/dist/distro.js +0 -462
- package/dist/distro.js.map +0 -1
- package/dist/history.d.ts +0 -10
- package/dist/history.js.map +0 -1
- package/dist/mcp.d.ts +0 -114
- package/dist/mcp.js.map +0 -1
- package/dist/memory.d.ts +0 -19
- package/dist/memory.js.map +0 -1
- package/dist/mentions.d.ts +0 -35
- package/dist/mentions.js +0 -130
- package/dist/mentions.js.map +0 -1
- package/dist/plugin-cli.d.ts +0 -16
- package/dist/plugin-cli.js +0 -294
- package/dist/plugin-cli.js.map +0 -1
- package/dist/plugins/budget.d.ts +0 -9
- package/dist/plugins/budget.js +0 -30
- package/dist/plugins/budget.js.map +0 -1
- package/dist/plugins/builtins.d.ts +0 -10
- package/dist/plugins/builtins.js +0 -25
- package/dist/plugins/builtins.js.map +0 -1
- package/dist/plugins/checks.d.ts +0 -71
- package/dist/plugins/checks.js.map +0 -1
- package/dist/plugins/compact.d.ts +0 -26
- package/dist/plugins/compact.js.map +0 -1
- package/dist/plugins/core.d.ts +0 -47
- package/dist/plugins/core.js +0 -229
- package/dist/plugins/core.js.map +0 -1
- package/dist/plugins/host.d.ts +0 -52
- package/dist/plugins/host.js +0 -115
- package/dist/plugins/host.js.map +0 -1
- package/dist/plugins/install.d.ts +0 -68
- package/dist/plugins/install.js +0 -377
- package/dist/plugins/install.js.map +0 -1
- package/dist/plugins/loader.d.ts +0 -410
- package/dist/plugins/loader.js +0 -407
- package/dist/plugins/loader.js.map +0 -1
- package/dist/plugins/policy.d.ts +0 -98
- package/dist/plugins/policy.js.map +0 -1
- package/dist/plugins/prompts.d.ts +0 -43
- package/dist/plugins/prompts.js +0 -284
- package/dist/plugins/prompts.js.map +0 -1
- package/dist/plugins/repeats.d.ts +0 -16
- package/dist/plugins/repeats.js +0 -151
- package/dist/plugins/repeats.js.map +0 -1
- package/dist/plugins/review.d.ts +0 -18
- package/dist/plugins/review.js.map +0 -1
- package/dist/plugins/schema.d.ts +0 -2
- package/dist/plugins/schema.js.map +0 -1
- package/dist/plugins/sessions.d.ts +0 -7
- package/dist/plugins/sessions.js +0 -110
- package/dist/plugins/sessions.js.map +0 -1
- package/dist/provider.d.ts +0 -165
- package/dist/provider.js.map +0 -1
- package/dist/session-lifecycle.d.ts +0 -61
- package/dist/session-lifecycle.js +0 -167
- package/dist/session-lifecycle.js.map +0 -1
- package/dist/session-scope.d.ts +0 -53
- package/dist/session-scope.js +0 -116
- package/dist/session-scope.js.map +0 -1
- package/dist/sessions.d.ts +0 -28
- package/dist/sessions.js +0 -73
- package/dist/sessions.js.map +0 -1
- package/dist/skills.d.ts +0 -37
- package/dist/skills.js.map +0 -1
- package/dist/sys.d.ts +0 -51
- package/dist/sys.js.map +0 -1
- package/dist/tools/ask.d.ts +0 -11
- package/dist/tools/ask.js +0 -62
- package/dist/tools/ask.js.map +0 -1
- package/dist/tools/checkpoint.d.ts +0 -43
- package/dist/tools/checkpoint.js.map +0 -1
- package/dist/tools/fs.d.ts +0 -39
- package/dist/tools/fs.js.map +0 -1
- package/dist/tools/grep.d.ts +0 -6
- package/dist/tools/grep.js.map +0 -1
- package/dist/tools/screenshot.d.ts +0 -15
- package/dist/tools/screenshot.js.map +0 -1
- package/dist/tools/shell.d.ts +0 -55
- package/dist/tools/shell.js.map +0 -1
- package/dist/tools/task.d.ts +0 -39
- package/dist/tools/task.js +0 -117
- package/dist/tools/task.js.map +0 -1
- package/dist/tools/todo.d.ts +0 -10
- package/dist/tools/todo.js.map +0 -1
- package/dist/tools/web.d.ts +0 -53
- package/dist/tools/web.js.map +0 -1
- package/dist/ui/configure.d.ts +0 -20
- package/dist/ui/configure.js +0 -447
- package/dist/ui/configure.js.map +0 -1
- package/dist/ui/diff.d.ts +0 -20
- package/dist/ui/diff.js.map +0 -1
- package/dist/ui/editor.d.ts +0 -41
- package/dist/ui/editor.js.map +0 -1
- package/dist/ui/markdown.d.ts +0 -22
- package/dist/ui/markdown.js.map +0 -1
- package/dist/ui/render.d.ts +0 -14
- package/dist/ui/render.js.map +0 -1
- package/dist/ui/renderers.d.ts +0 -8
- package/dist/ui/renderers.js.map +0 -1
- package/dist/ui/screen.d.ts +0 -118
- package/dist/ui/screen.js.map +0 -1
- package/dist/ui/transcript.d.ts +0 -46
- package/dist/ui/transcript.js.map +0 -1
- package/dist/ui/tui.d.ts +0 -47
- package/dist/ui/tui.js.map +0 -1
- package/src/commands.ts +0 -144
- package/src/context.ts +0 -64
- package/src/distro.ts +0 -577
- package/src/mentions.ts +0 -135
- package/src/plugin-cli.ts +0 -278
- package/src/plugins/budget.ts +0 -37
- package/src/plugins/builtins.ts +0 -34
- package/src/plugins/core.ts +0 -257
- package/src/plugins/host.ts +0 -146
- package/src/plugins/install.ts +0 -429
- package/src/plugins/loader.ts +0 -742
- package/src/plugins/prompts.ts +0 -327
- package/src/plugins/repeats.ts +0 -157
- package/src/plugins/sessions.ts +0 -109
- package/src/session-lifecycle.ts +0 -194
- package/src/session-scope.ts +0 -135
- package/src/sessions.ts +0 -78
- package/src/tools/ask.ts +0 -72
- package/src/tools/task.ts +0 -149
- package/src/tools/todo.ts +0 -67
- package/src/ui/configure.ts +0 -471
- /package/{src/plugins → plugins/approval}/schema.ts +0 -0
- /package/{src → plugins/tui}/history.ts +0 -0
- /package/{src/ui → plugins/tui}/markdown.ts +0 -0
package/dist/remote.js
ADDED
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
// 进程外插件的桥(第 6 节):启动插件进程,把它包成一个普通的 PluginModule。
|
|
2
|
+
// 核心的其余部分不知道插件在进程外:服务、注册、作用域、膜、隔离都和进程内插件一样。
|
|
3
|
+
//
|
|
4
|
+
// 协议方法和具体服务无关:
|
|
5
|
+
// 宿主 → 插件:initialize、scope/open、scope/close、call,通知 caller/open、caller/close、$/cancel
|
|
6
|
+
// 插件 → 宿主:provide、kernel/tool、kernel/hook、secrets/get、secrets/set、call(target 是服务名、"$session" 或函数句柄)
|
|
7
|
+
// 值里的函数表示成句柄 { "$fn": id },对方用 call 调用它。句柄属于一个作用域,作用域关闭后失效。
|
|
8
|
+
import { spawn } from "node:child_process";
|
|
9
|
+
import path from "node:path";
|
|
10
|
+
import { fileURLToPath } from "node:url";
|
|
11
|
+
import { API_VERSION } from "./api.js";
|
|
12
|
+
import { ambient } from "./membrane.js";
|
|
13
|
+
import { Rpc } from "./rpc.js";
|
|
14
|
+
/** 插件进程启动后多久内要回复 initialize */
|
|
15
|
+
export const INIT_TIMEOUT_MS = 10_000;
|
|
16
|
+
/** 关闭时等插件进程自己退出的时间,之后强制结束 */
|
|
17
|
+
const EXIT_GRACE_MS = 2000;
|
|
18
|
+
/** Python SDK(单文件 jade_plugin.py)所在目录,加进插件进程的 PYTHONPATH */
|
|
19
|
+
const PYTHON_SDK = fileURLToPath(new URL("../sdk/python", import.meta.url));
|
|
20
|
+
/** 插件进程退出时附在原因后面的 stderr 行数 */
|
|
21
|
+
const STDERR_TAIL = 5;
|
|
22
|
+
/** 参数里的 AbortSignal 不能序列化:发给插件时换成 null,中止时给插件发 $/cancel */
|
|
23
|
+
const signalIn = (args) => args.find((x) => x instanceof AbortSignal);
|
|
24
|
+
const withoutSignals = (args) => args.map((x) => (x instanceof AbortSignal ? null : x));
|
|
25
|
+
const isHandle = (v) => typeof v === "object" && v !== null && !Array.isArray(v) && typeof v.$fn === "string" && Object.keys(v).length === 1;
|
|
26
|
+
export async function startRemote(source, owner, opts) {
|
|
27
|
+
const { manifest, dir } = source;
|
|
28
|
+
const id = manifest.id;
|
|
29
|
+
const { command, args = [] } = manifest.runtime;
|
|
30
|
+
const env = { ...process.env, PYTHONPATH: [PYTHON_SDK, process.env.PYTHONPATH].filter(Boolean).join(path.delimiter), PYTHONUNBUFFERED: "1", PYTHONIOENCODING: "utf-8" };
|
|
31
|
+
// 插件进程的工作目录是插件目录,所以清单里可以写 "args": ["main.py"];jade 的工作目录在 scope/open 里给
|
|
32
|
+
const child = spawn(/^\.\.?[\\/]/.test(command) ? path.resolve(dir, command) : command, args, { cwd: dir, env, stdio: ["pipe", "pipe", "pipe"], windowsHide: true });
|
|
33
|
+
/** 打开的作用域:id → ctx。进程级的 id 是 "process" */
|
|
34
|
+
const scopes = new Map();
|
|
35
|
+
/** 交给插件的宿主函数:句柄 → 函数;按作用域分组,作用域关闭时释放 */
|
|
36
|
+
const local = new Map();
|
|
37
|
+
const buckets = new Map();
|
|
38
|
+
let next = 1;
|
|
39
|
+
let closing = false;
|
|
40
|
+
const stderr = [];
|
|
41
|
+
const encode = (v, scope, depth = 0) => {
|
|
42
|
+
if (typeof v === "function") {
|
|
43
|
+
const h = `h${next++}`;
|
|
44
|
+
local.set(h, v);
|
|
45
|
+
buckets.get(scope)?.add(h);
|
|
46
|
+
return { $fn: h };
|
|
47
|
+
}
|
|
48
|
+
if (depth > 32 || typeof v !== "object" || v === null)
|
|
49
|
+
return v;
|
|
50
|
+
if (Array.isArray(v))
|
|
51
|
+
return v.map((x) => encode(x, scope, depth + 1));
|
|
52
|
+
const proto = Object.getPrototypeOf(v);
|
|
53
|
+
if (proto !== Object.prototype && proto !== null)
|
|
54
|
+
return v; // class 实例按 JSON 序列化
|
|
55
|
+
return Object.fromEntries(Object.entries(v).map(([k, x]) => [k, encode(x, scope, depth + 1)]));
|
|
56
|
+
};
|
|
57
|
+
const decode = (v, scope) => {
|
|
58
|
+
if (isHandle(v))
|
|
59
|
+
return remoteFn(v.$fn, scope);
|
|
60
|
+
if (typeof v !== "object" || v === null)
|
|
61
|
+
return v;
|
|
62
|
+
if (Array.isArray(v))
|
|
63
|
+
return v.map((x) => decode(x, scope));
|
|
64
|
+
return Object.fromEntries(Object.entries(v).map(([k, x]) => [k, decode(x, scope)]));
|
|
65
|
+
};
|
|
66
|
+
/** 插件的函数:调用时经 call 发给插件 */
|
|
67
|
+
const remoteFn = (fn, scope) => {
|
|
68
|
+
return (...a) => {
|
|
69
|
+
if (!scopes.has(scope))
|
|
70
|
+
throw new Error(`a function of plugin ${id} was called after its scope closed`);
|
|
71
|
+
return rpc.request("call", { scope, target: { $fn: fn }, args: encode(withoutSignals(a), scope) }, signalIn(a)).then((r) => decode(r, scope));
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
const rpc = new Rpc((line) => child.stdin.write(line), (method, params, signal) => ambient.run(owner, () => serve(method, (params ?? {}), signal)));
|
|
75
|
+
rpc.onGarbage = (line) => opts.report(`plugin ${id}: ignored a line on stdout that is not a protocol message (write logs to stderr): ${line.slice(0, 200)}`);
|
|
76
|
+
child.stdout.setEncoding("utf8");
|
|
77
|
+
child.stdout.on("data", (d) => rpc.feed(d));
|
|
78
|
+
child.stdin.on("error", () => { }); // 进程已退出时写入失败,由 exit 处理
|
|
79
|
+
let errBuf = "";
|
|
80
|
+
child.stderr.setEncoding("utf8");
|
|
81
|
+
child.stderr.on("data", (d) => {
|
|
82
|
+
errBuf += d;
|
|
83
|
+
for (let i = errBuf.indexOf("\n"); i !== -1; i = errBuf.indexOf("\n")) {
|
|
84
|
+
const line = errBuf.slice(0, i).replace(/\r$/, "");
|
|
85
|
+
errBuf = errBuf.slice(i + 1);
|
|
86
|
+
if (!line.trim())
|
|
87
|
+
continue;
|
|
88
|
+
stderr.push(line);
|
|
89
|
+
if (stderr.length > STDERR_TAIL)
|
|
90
|
+
stderr.shift();
|
|
91
|
+
opts.report(`plugin ${id}: ${line}`);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
const exited = new Promise((resolve) => {
|
|
95
|
+
child.on("error", (e) => {
|
|
96
|
+
rpc.close(new Error(`cannot start "${command}": ${e.message}`));
|
|
97
|
+
resolve();
|
|
98
|
+
});
|
|
99
|
+
child.on("exit", (code, signal) => {
|
|
100
|
+
const reason = `its process exited (${signal ?? `code ${code}`})`;
|
|
101
|
+
rpc.close(new Error(stderr.length > 0 ? `${reason}; stderr: ${stderr.join(" | ")}` : reason));
|
|
102
|
+
if (!closing)
|
|
103
|
+
opts.exited(reason);
|
|
104
|
+
resolve();
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
// 宿主关闭插件(退出、隔离、激活失败)时结束进程。最先登记,所以在进程级作用域里最后执行
|
|
108
|
+
owner.scope.add(async () => {
|
|
109
|
+
closing = true;
|
|
110
|
+
await closeScope("process");
|
|
111
|
+
child.stdin.end();
|
|
112
|
+
const timer = setTimeout(() => child.kill(), EXIT_GRACE_MS);
|
|
113
|
+
await exited;
|
|
114
|
+
clearTimeout(timer);
|
|
115
|
+
});
|
|
116
|
+
async function openScope(scope, kind, ctx, extra) {
|
|
117
|
+
scopes.set(scope, ctx);
|
|
118
|
+
buckets.set(scope, new Set());
|
|
119
|
+
await rpc.request("scope/open", { scope, kind, cwd: ctx.cwd, home: ctx.home, config: ctx.config, ...extra });
|
|
120
|
+
}
|
|
121
|
+
async function closeScope(scope) {
|
|
122
|
+
if (!scopes.delete(scope))
|
|
123
|
+
return;
|
|
124
|
+
for (const h of buckets.get(scope) ?? [])
|
|
125
|
+
local.delete(h);
|
|
126
|
+
buckets.delete(scope);
|
|
127
|
+
try {
|
|
128
|
+
await rpc.request("scope/close", { scope });
|
|
129
|
+
}
|
|
130
|
+
catch {
|
|
131
|
+
// 进程已经退出,或者插件清理时出错:作用域在宿主这边已经关了
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/** 插件发来的请求 */
|
|
135
|
+
async function serve(method, p, signal) {
|
|
136
|
+
const scope = String(p.scope);
|
|
137
|
+
const ctx = scopes.get(scope);
|
|
138
|
+
if (!ctx)
|
|
139
|
+
throw new Error(`scope ${scope} is not open`);
|
|
140
|
+
switch (method) {
|
|
141
|
+
case "provide": {
|
|
142
|
+
if (scope !== "process")
|
|
143
|
+
throw new Error("services can only be provided in the process scope");
|
|
144
|
+
const service = String(p.service);
|
|
145
|
+
const methods = p.methods;
|
|
146
|
+
if (!Array.isArray(methods) || methods.some((m) => typeof m !== "string" || m === "then"))
|
|
147
|
+
throw new Error("provide: methods must be a list of method names");
|
|
148
|
+
const build = (caller) => Object.fromEntries(methods.map((m) => [
|
|
149
|
+
m,
|
|
150
|
+
(...a) => rpc.request("call", { scope, target: service, method: m, args: encode(withoutSignals(a), scope), ...(caller ? { caller } : {}) }, signalIn(a)).then((r) => decode(r, scope)),
|
|
151
|
+
]));
|
|
152
|
+
// 按调用方创建实例:插件那边收到 caller/open 时用工厂创建,caller/close 时撤销这个调用方的注册
|
|
153
|
+
const perCaller = (caller) => {
|
|
154
|
+
const c = `c${next++}`;
|
|
155
|
+
rpc.notify("caller/open", { service, caller: { id: c, plugin: caller.plugin, layer: caller.layer } });
|
|
156
|
+
caller.onDispose(() => rpc.notify("caller/close", { caller: c }));
|
|
157
|
+
return build(c);
|
|
158
|
+
};
|
|
159
|
+
ctx.provide(service, p.perCaller === true ? perCaller : build());
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
case "kernel/tool": {
|
|
163
|
+
if (scope === "process")
|
|
164
|
+
throw new Error("kernel/tool is only available in a session scope");
|
|
165
|
+
const t = (p.tool ?? {});
|
|
166
|
+
if (!isHandle(p.execute))
|
|
167
|
+
throw new Error("kernel/tool: execute must be a function handle");
|
|
168
|
+
if (t.effect !== "read" && t.effect !== "write" && t.effect !== "external")
|
|
169
|
+
throw new Error(`kernel/tool ${String(t.name)}: effect must be "read", "write" or "external"`);
|
|
170
|
+
const fn = p.execute.$fn;
|
|
171
|
+
ctx.kernel.tool({
|
|
172
|
+
name: String(t.name),
|
|
173
|
+
description: String(t.description ?? ""),
|
|
174
|
+
inputSchema: t.inputSchema ?? { type: "object" },
|
|
175
|
+
effect: t.effect,
|
|
176
|
+
concurrency: t.concurrency === "safe" ? "safe" : "exclusive",
|
|
177
|
+
idempotent: t.idempotent === true,
|
|
178
|
+
execute: async (input, tctx) => {
|
|
179
|
+
const r = await rpc.request("call", { scope, target: { $fn: fn }, args: [input, { sessionId: tctx.sessionId, toolUseId: tctx.toolUseId }] }, tctx.signal);
|
|
180
|
+
return (typeof r === "string" ? { content: r } : r);
|
|
181
|
+
},
|
|
182
|
+
});
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
case "kernel/hook": {
|
|
186
|
+
if (scope === "process")
|
|
187
|
+
throw new Error("kernel/hook is only available in a session scope");
|
|
188
|
+
const h = (p.hook ?? {});
|
|
189
|
+
if (!isHandle(p.fn))
|
|
190
|
+
throw new Error("kernel/hook: fn must be a function handle");
|
|
191
|
+
const fn = p.fn.$fn;
|
|
192
|
+
// 字段裁剪、回复检查、超时由内核保证(RemoteHookSpec)
|
|
193
|
+
const spec = {
|
|
194
|
+
kind: h.kind,
|
|
195
|
+
point: h.point,
|
|
196
|
+
remote: true,
|
|
197
|
+
reads: h.reads,
|
|
198
|
+
writes: h.writes ?? [],
|
|
199
|
+
timeoutMs: h.timeoutMs,
|
|
200
|
+
...(typeof h.order === "number" ? { order: h.order } : {}),
|
|
201
|
+
call: (payload, hctx) => rpc.request("call", { scope, target: { $fn: fn }, args: [payload] }, hctx.signal),
|
|
202
|
+
};
|
|
203
|
+
ctx.kernel.hook(spec);
|
|
204
|
+
return null;
|
|
205
|
+
}
|
|
206
|
+
case "secrets/get": {
|
|
207
|
+
if (typeof p.key !== "string")
|
|
208
|
+
throw new Error("secrets/get: key must be a string");
|
|
209
|
+
return (await ctx.secrets.get(p.key)) ?? null;
|
|
210
|
+
}
|
|
211
|
+
case "secrets/set": {
|
|
212
|
+
if (typeof p.key !== "string")
|
|
213
|
+
throw new Error("secrets/set: key must be a string");
|
|
214
|
+
if (p.value !== null && typeof p.value !== "string")
|
|
215
|
+
throw new Error("secrets/set: value must be a string or null");
|
|
216
|
+
await ctx.secrets.set(p.key, p.value === null ? undefined : p.value);
|
|
217
|
+
return null;
|
|
218
|
+
}
|
|
219
|
+
case "call": {
|
|
220
|
+
const a = decode(p.args ?? [], scope);
|
|
221
|
+
if (!Array.isArray(a))
|
|
222
|
+
throw new Error("call: args must be a list");
|
|
223
|
+
const target = p.target;
|
|
224
|
+
let result;
|
|
225
|
+
if (isHandle(target)) {
|
|
226
|
+
const f = local.get(target.$fn);
|
|
227
|
+
if (!f)
|
|
228
|
+
throw new Error(`function ${target.$fn} is no longer valid`);
|
|
229
|
+
result = await f(...a);
|
|
230
|
+
}
|
|
231
|
+
else if (target === "$session") {
|
|
232
|
+
const session = ctx.session;
|
|
233
|
+
if (!session)
|
|
234
|
+
throw new Error("$session is only available in a session scope");
|
|
235
|
+
if (p.method === "send")
|
|
236
|
+
result = await session.send(a[0]);
|
|
237
|
+
else if (p.method === "afterTurn")
|
|
238
|
+
session.afterTurn(a[0]);
|
|
239
|
+
else if (p.method === "abort")
|
|
240
|
+
session.abort(a[0] === undefined || a[0] === null ? undefined : String(a[0]));
|
|
241
|
+
else
|
|
242
|
+
throw new Error(`$session has no method ${String(p.method)}`);
|
|
243
|
+
}
|
|
244
|
+
else if (typeof target === "string") {
|
|
245
|
+
const service = ctx.service(target);
|
|
246
|
+
if (!service)
|
|
247
|
+
throw new Error(`service ${target} is not available`);
|
|
248
|
+
const m = service[String(p.method)];
|
|
249
|
+
if (typeof m !== "function")
|
|
250
|
+
throw new Error(`service ${target} has no method ${String(p.method)}`);
|
|
251
|
+
result = await m(...a);
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
throw new Error("call: target must be a service name, \"$session\" or a function handle");
|
|
255
|
+
}
|
|
256
|
+
if (signal.aborted)
|
|
257
|
+
throw signal.reason;
|
|
258
|
+
return encode(result, scope);
|
|
259
|
+
}
|
|
260
|
+
default:
|
|
261
|
+
throw new Error(`unknown method ${method}`);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
let init;
|
|
265
|
+
try {
|
|
266
|
+
init = ((await rpc.request("initialize", { plugin: id, version: manifest.version, api: API_VERSION }, AbortSignal.timeout(INIT_TIMEOUT_MS))) ?? {});
|
|
267
|
+
}
|
|
268
|
+
catch (e) {
|
|
269
|
+
if (e instanceof Error && e.name === "TimeoutError")
|
|
270
|
+
throw new Error(`"${command}" did not answer initialize within ${INIT_TIMEOUT_MS / 1000} s`);
|
|
271
|
+
throw e;
|
|
272
|
+
}
|
|
273
|
+
if (init.id !== undefined && init.id !== id)
|
|
274
|
+
throw new Error(`the process says it is plugin ${init.id}, but plugin.json says ${id}`);
|
|
275
|
+
let sessions = 0;
|
|
276
|
+
return {
|
|
277
|
+
async process(ctx) {
|
|
278
|
+
await openScope("process", "process", ctx, {});
|
|
279
|
+
},
|
|
280
|
+
...(init.session
|
|
281
|
+
? {
|
|
282
|
+
async session(ctx) {
|
|
283
|
+
const scope = `s${++sessions}`;
|
|
284
|
+
// 先登记关闭:插件在 scope/open 里出错时,宿主撤销这个作用域,插件那边也要清理
|
|
285
|
+
await ctx.effect(() => () => closeScope(scope));
|
|
286
|
+
await openScope(scope, "session", ctx, { session: { id: ctx.session.id } });
|
|
287
|
+
},
|
|
288
|
+
}
|
|
289
|
+
: {}),
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
//# sourceMappingURL=remote.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote.js","sourceRoot":"","sources":["../src/remote.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,4CAA4C;AAC5C,EAAE;AACF,eAAe;AACf,wFAAwF;AACxF,uGAAuG;AACvG,4DAA4D;AAE5D,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,WAAW,EAAkH,MAAM,UAAU,CAAC;AACvJ,OAAO,EAAE,OAAO,EAAc,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE/B,+BAA+B;AAC/B,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC;AACtC,6BAA6B;AAC7B,MAAM,aAAa,GAAG,IAAI,CAAC;AAC3B,4DAA4D;AAC5D,MAAM,UAAU,GAAG,aAAa,CAAC,IAAI,GAAG,CAAC,eAAe,EAA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K,CAAC,IAAI,OAAO,sCAAsC,eAAe,GAAG,IAAI,IAAI,CAAC,CAAC;QAClJ,MAAM,CAAC,CAAC;IACV,CAAC;IACD,IAAI,IAAI,CAAC,EAAE,KAAK,SAAS,IAAI,IAAI,CAAC,EAAE,KAAK,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,iCAAiC,IAAI,CAAC,EAAE,0BAA0B,EAAE,EAAE,CAAC,CAAC;IAErI,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,OAAO;QACL,KAAK,CAAC,OAAO,CAAC,GAAG;YACf,MAAM,SAAS,CAAC,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;QACjD,CAAC;QACD,GAAG,CAAC,IAAI,CAAC,OAAO;YACd,CAAC,CAAC;gBACE,KAAK,CAAC,OAAO,CAAC,GAAmB;oBAC/B,MAAM,KAAK,GAAG,IAAI,EAAE,QAAQ,EAAE,CAAC;oBAC/B,+CAA+C;oBAC/C,MAAM,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;oBAChD,MAAM,SAAS,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;gBAC9E,CAAC;aACF;YACH,CAAC,CAAC,EAAE,CAAC;KACR,CAAC;AACJ,CAAC"}
|
package/dist/rescue.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { TrustStore } from "uncarved";
|
|
2
|
+
import { type HostOptions } from "./host.ts";
|
|
3
|
+
export type PluginsCommandOptions = Pick<HostOptions, "roots" | "home" | "flags" | "safe"> & {
|
|
4
|
+
/** 项目层插件的信任记录;--project 安装时用它记下内容哈希 */
|
|
5
|
+
trust?: TrustStore;
|
|
6
|
+
/** 下载进度,写到 stderr */
|
|
7
|
+
log?: (text: string) => void;
|
|
8
|
+
};
|
|
9
|
+
/** 执行一条 plugins 子命令,返回要打印的文字;用法错误时抛错 */
|
|
10
|
+
export declare function pluginsCommand(args: readonly string[], opts: PluginsCommandOptions): Promise<string>;
|
package/dist/rescue.js
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
// 救援 CLI:jade plugins list|add|update|remove|enable|disable。
|
|
2
|
+
// 只读写 plugins.json、faults.json、安装记录、信任存储和插件目录,不执行任何插件代码(5.4)。
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { readPluginManifest } from "./fetch.js";
|
|
5
|
+
import { planPlugins } from "./host.js";
|
|
6
|
+
import { addPlugin, forgetPluginState, installDir, readRecords, removePlugin, updatePlugins } from "./install.js";
|
|
7
|
+
import { forgetFaults, readFaults, readPluginsConfig, writeFaults, writePluginsConfig } from "./state.js";
|
|
8
|
+
const USAGE = `usage: jade plugins <command>
|
|
9
|
+
|
|
10
|
+
list every plugin's state, services, and where it was installed from
|
|
11
|
+
add <source> [options] install a plugin
|
|
12
|
+
<source>: a local directory, an npm package (name, name@version, @scope/name,
|
|
13
|
+
npm:<spec>, a .tgz), or a git repository (https://…, git@…,
|
|
14
|
+
github:user/repo, user/repo; add #branch, #tag or #commit at the end)
|
|
15
|
+
--project install into <cwd>/.jade/plugins instead of $JADE_HOME/plugins
|
|
16
|
+
--path <dir> use this subdirectory of the source
|
|
17
|
+
--link local directory: link it instead of copying (for plugin development)
|
|
18
|
+
--force replace a plugin with the same id
|
|
19
|
+
update [id…] [--project] [--force] fetch again what "jade plugins add" installed
|
|
20
|
+
(all of them when no id is given); --force replaces local edits
|
|
21
|
+
remove <id> [--project] delete an installed plugin
|
|
22
|
+
disable <id> stop loading a plugin
|
|
23
|
+
enable <id> undo disable
|
|
24
|
+
|
|
25
|
+
Installing never runs the plugin's code; dependencies are installed with --ignore-scripts.`;
|
|
26
|
+
/** 执行一条 plugins 子命令,返回要打印的文字;用法错误时抛错 */
|
|
27
|
+
export async function pluginsCommand(args, opts) {
|
|
28
|
+
if (args[0] === "-h" || args[0] === "--help")
|
|
29
|
+
return USAGE;
|
|
30
|
+
const [sub = "list", ...tail] = args;
|
|
31
|
+
const parsed = parseArgs(tail);
|
|
32
|
+
if (parsed.help)
|
|
33
|
+
return USAGE;
|
|
34
|
+
switch (sub) {
|
|
35
|
+
case "list":
|
|
36
|
+
case "ls":
|
|
37
|
+
if (parsed.positionals.length > 0 || parsed.project || parsed.link || parsed.force || parsed.path)
|
|
38
|
+
throw new Error(USAGE);
|
|
39
|
+
return list(opts);
|
|
40
|
+
case "add":
|
|
41
|
+
case "install": {
|
|
42
|
+
if (parsed.positionals.length !== 1)
|
|
43
|
+
throw new Error(USAGE);
|
|
44
|
+
const installed = await addPlugin(parsed.positionals[0], {
|
|
45
|
+
root: installRoot(opts, parsed),
|
|
46
|
+
cwd: process.cwd(),
|
|
47
|
+
...(parsed.path ? { subdir: parsed.path } : {}),
|
|
48
|
+
...(parsed.link ? { link: true } : {}),
|
|
49
|
+
...(parsed.force ? { force: true } : {}),
|
|
50
|
+
project: parsed.project,
|
|
51
|
+
...(opts.trust ? { trust: opts.trust } : {}),
|
|
52
|
+
...(opts.log ? { log: opts.log } : {}),
|
|
53
|
+
});
|
|
54
|
+
const wasDisabled = await forgetPluginState(opts.home, installed.id);
|
|
55
|
+
let text = `installed ${installed.id}@${installed.version} into ${installed.dir}`;
|
|
56
|
+
if (installed.record.kind !== "local")
|
|
57
|
+
text += ` (${origin(installed.record)})`;
|
|
58
|
+
if (wasDisabled)
|
|
59
|
+
text += `\n${installed.id} was disabled; installing it enabled it again.`;
|
|
60
|
+
if (parsed.project)
|
|
61
|
+
text += `\nproject plugin: it will run with your permissions in this repository.`;
|
|
62
|
+
return text;
|
|
63
|
+
}
|
|
64
|
+
case "update":
|
|
65
|
+
case "upgrade": {
|
|
66
|
+
if (parsed.link || parsed.path)
|
|
67
|
+
throw new Error(USAGE);
|
|
68
|
+
const results = await updatePlugins(parsed.positionals, {
|
|
69
|
+
root: installRoot(opts, parsed),
|
|
70
|
+
cwd: process.cwd(),
|
|
71
|
+
...(parsed.force ? { force: true } : {}),
|
|
72
|
+
project: parsed.project,
|
|
73
|
+
...(opts.trust ? { trust: opts.trust } : {}),
|
|
74
|
+
...(opts.log ? { log: opts.log } : {}),
|
|
75
|
+
});
|
|
76
|
+
// 更新之后清掉连续崩溃记录;用户显式停用的仍然保持停用
|
|
77
|
+
for (const r of results)
|
|
78
|
+
if (r.status === "updated")
|
|
79
|
+
await forgetFaults(opts.home, r.id);
|
|
80
|
+
const lines = results.map(describe);
|
|
81
|
+
if (results.some((r) => r.status === "updated"))
|
|
82
|
+
lines.push("restart jade to load the new versions.");
|
|
83
|
+
return lines.length > 0 ? lines.join("\n") : 'no plugins were installed with "jade plugins add"';
|
|
84
|
+
}
|
|
85
|
+
case "remove":
|
|
86
|
+
case "rm":
|
|
87
|
+
case "uninstall": {
|
|
88
|
+
if (parsed.positionals.length !== 1 || parsed.link || parsed.force || parsed.path)
|
|
89
|
+
throw new Error(USAGE);
|
|
90
|
+
const id = parsed.positionals[0];
|
|
91
|
+
const root = installRoot(opts, parsed);
|
|
92
|
+
// 停用记录按插件 id;给的是目录名时先读清单换成 id
|
|
93
|
+
const manifest = await readPluginManifest(installDir(root, id)).catch(() => undefined);
|
|
94
|
+
const dir = await removePlugin(id, { root });
|
|
95
|
+
await forgetPluginState(opts.home, manifest?.id ?? id);
|
|
96
|
+
return `removed ${id} (${dir})`;
|
|
97
|
+
}
|
|
98
|
+
case "disable":
|
|
99
|
+
case "enable": {
|
|
100
|
+
if (parsed.positionals.length !== 1 || parsed.project || parsed.link || parsed.force || parsed.path)
|
|
101
|
+
throw new Error(USAGE);
|
|
102
|
+
return enableOrDisable(sub, parsed.positionals[0], opts);
|
|
103
|
+
}
|
|
104
|
+
default:
|
|
105
|
+
throw new Error(USAGE);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
async function enableOrDisable(sub, id, opts) {
|
|
109
|
+
const { plan } = await planPlugins(opts);
|
|
110
|
+
const known = plan.entries.some((e) => e.source.manifest.id === id);
|
|
111
|
+
const config = await readPluginsConfig(opts.home);
|
|
112
|
+
if (sub === "disable") {
|
|
113
|
+
if (!config.disabled.includes(id))
|
|
114
|
+
config.disabled.push(id);
|
|
115
|
+
await writePluginsConfig(opts.home, config);
|
|
116
|
+
return known ? `disabled ${id}` : `disabled ${id} (no installed plugin has this id)`;
|
|
117
|
+
}
|
|
118
|
+
config.disabled = config.disabled.filter((d) => d !== id);
|
|
119
|
+
await writePluginsConfig(opts.home, config);
|
|
120
|
+
// 同时清掉连续崩溃的记录,否则下次启动又被自动停用
|
|
121
|
+
const faults = await readFaults(opts.home);
|
|
122
|
+
faults.autoDisabled = faults.autoDisabled.filter((d) => d !== id);
|
|
123
|
+
delete faults.streaks[id];
|
|
124
|
+
await writeFaults(opts.home, faults);
|
|
125
|
+
return known ? `enabled ${id}` : `enabled ${id} (no installed plugin has this id)`;
|
|
126
|
+
}
|
|
127
|
+
/** 用户层插件的目录(`jade plugins add` 默认装到这里) */
|
|
128
|
+
const userRoot = (opts) => opts.roots.find((r) => r.layer === "user")?.root ?? path.join(process.env.JADE_HOME ?? "", "plugins");
|
|
129
|
+
const projectRoot = (opts) => opts.roots.find((r) => r.layer === "project")?.root ?? path.join(process.cwd(), ".jade", "plugins");
|
|
130
|
+
const installRoot = (opts, parsed) => (parsed.project ? projectRoot(opts) : userRoot(opts));
|
|
131
|
+
function parseArgs(tail) {
|
|
132
|
+
const out = { positionals: [], project: false, link: false, force: false, help: false };
|
|
133
|
+
for (let i = 0; i < tail.length; i++) {
|
|
134
|
+
const a = tail[i];
|
|
135
|
+
const value = (name) => {
|
|
136
|
+
const v = tail[++i];
|
|
137
|
+
if (v === undefined)
|
|
138
|
+
throw new Error(`${name} needs a value\n${USAGE}`);
|
|
139
|
+
return v;
|
|
140
|
+
};
|
|
141
|
+
if (a === "--project")
|
|
142
|
+
out.project = true;
|
|
143
|
+
else if (a === "--link")
|
|
144
|
+
out.link = true;
|
|
145
|
+
else if (a === "--force" || a === "-f")
|
|
146
|
+
out.force = true;
|
|
147
|
+
else if (a === "--path")
|
|
148
|
+
out.path = value(a);
|
|
149
|
+
else if (a.startsWith("--path="))
|
|
150
|
+
out.path = a.slice("--path=".length);
|
|
151
|
+
else if (a === "-h" || a === "--help")
|
|
152
|
+
out.help = true;
|
|
153
|
+
else if (a.startsWith("-"))
|
|
154
|
+
throw new Error(`unknown option ${a}\n${USAGE}`);
|
|
155
|
+
else
|
|
156
|
+
out.positionals.push(a);
|
|
157
|
+
}
|
|
158
|
+
return out;
|
|
159
|
+
}
|
|
160
|
+
function describe(r) {
|
|
161
|
+
switch (r.status) {
|
|
162
|
+
case "updated": {
|
|
163
|
+
if (r.from && r.to && r.from !== r.to)
|
|
164
|
+
return `updated ${r.id} ${r.from} → ${r.to}`;
|
|
165
|
+
return `updated ${r.id}${r.to ? ` (${r.to})` : ""}`;
|
|
166
|
+
}
|
|
167
|
+
case "current":
|
|
168
|
+
return `current ${r.id}${r.to ? ` (${r.to})` : ""}`;
|
|
169
|
+
case "linked":
|
|
170
|
+
return `linked ${r.id} (local directory; nothing to fetch)`;
|
|
171
|
+
case "unmanaged":
|
|
172
|
+
case "modified":
|
|
173
|
+
case "failed":
|
|
174
|
+
return `${r.id}: ${r.error}`;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
/** 按清单和状态文件推算出的状态:不激活插件,所以看不到激活阶段的失败(那些记在连续崩溃次数里) */
|
|
178
|
+
async function list(opts) {
|
|
179
|
+
const { plan, broken, faults } = await planPlugins(opts);
|
|
180
|
+
const records = new Map();
|
|
181
|
+
for (const { root } of opts.roots) {
|
|
182
|
+
for (const rec of Object.values(await readRecords(root)))
|
|
183
|
+
records.set(rec.id, rec);
|
|
184
|
+
}
|
|
185
|
+
const lines = [];
|
|
186
|
+
for (const e of plan.entries) {
|
|
187
|
+
const m = e.source.manifest;
|
|
188
|
+
const streak = faults.streaks[m.id];
|
|
189
|
+
const note = e.reason ?? (streak ? `faulted in the last ${streak.count} launch(es): ${streak.last}` : "");
|
|
190
|
+
const rec = records.get(m.id);
|
|
191
|
+
lines.push(`${m.id}@${m.version} ${e.source.layer} ${e.state}${note ? ` ${note}` : ""}${rec ? ` from ${origin(rec)}` : ""}`);
|
|
192
|
+
}
|
|
193
|
+
for (const b of broken)
|
|
194
|
+
lines.push(`${b.dir} ${b.layer} broken ${b.error}`);
|
|
195
|
+
for (const w of plan.warnings)
|
|
196
|
+
lines.push(`warning: ${w}`);
|
|
197
|
+
if (plan.providers.size > 0) {
|
|
198
|
+
lines.push("", "services:");
|
|
199
|
+
for (const [service, id] of [...plan.providers].sort())
|
|
200
|
+
lines.push(` ${service} ${id}`);
|
|
201
|
+
}
|
|
202
|
+
if (faults.unattributed.length > 0)
|
|
203
|
+
lines.push("", `${faults.unattributed.length} recent error(s) not attributable to any plugin, see state/faults.json`);
|
|
204
|
+
return lines.length > 0 ? lines.join("\n") : "no plugins installed";
|
|
205
|
+
}
|
|
206
|
+
function origin(rec) {
|
|
207
|
+
if (rec.kind === "link")
|
|
208
|
+
return `link ${rec.source}`;
|
|
209
|
+
const at = rec.commit ? `@${rec.commit.slice(0, 7)}` : "";
|
|
210
|
+
if (rec.kind === "npm")
|
|
211
|
+
return `${rec.source.startsWith("npm:") ? rec.source : `npm ${rec.source}`}${at}`;
|
|
212
|
+
if (rec.kind === "git")
|
|
213
|
+
return `${rec.source.startsWith("git+") ? rec.source : `git ${rec.source}`}${at}`;
|
|
214
|
+
return `${rec.source}${at}`;
|
|
215
|
+
}
|
|
216
|
+
//# sourceMappingURL=rescue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rescue.js","sourceRoot":"","sources":["../src/rescue.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,8DAA8D;AAE9D,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,kBAAkB,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,MAAM,GAAG,EAAE,EAAE,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type PluginSource } from "./api.ts";
|
|
2
|
+
/** 计划阶段的状态。激活之后宿主还会把状态改成 failed 或 quarantined */
|
|
3
|
+
export type PlanState = "active" | "disabled" | "duplicate" | "incompatible" | "replaced" | "conflict" | "skipped";
|
|
4
|
+
export interface PlanEntry {
|
|
5
|
+
source: PluginSource;
|
|
6
|
+
state: PlanState;
|
|
7
|
+
reason?: string;
|
|
8
|
+
/** 意料之中的跳过:没选中的前端,以及只因为它而缺依赖的插件。启动时不提示 */
|
|
9
|
+
expected?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface Plan {
|
|
12
|
+
/** 发现顺序,包括没有激活的 */
|
|
13
|
+
entries: PlanEntry[];
|
|
14
|
+
/** 激活顺序:依赖在前 */
|
|
15
|
+
order: PluginSource[];
|
|
16
|
+
/** 服务名 → 提供者 id */
|
|
17
|
+
providers: Map<string, string>;
|
|
18
|
+
/** 选中的前端插件 id */
|
|
19
|
+
frontend?: string;
|
|
20
|
+
/** 不影响激活、但用户应该知道的事 */
|
|
21
|
+
warnings: string[];
|
|
22
|
+
}
|
|
23
|
+
export interface ResolveOptions {
|
|
24
|
+
apiVersion: string;
|
|
25
|
+
/** 按 id 停用的插件 */
|
|
26
|
+
disabled?: ReadonlySet<string>;
|
|
27
|
+
/** 安全模式:只加载 bundled(5.4) */
|
|
28
|
+
safe?: boolean;
|
|
29
|
+
/** 命令行开关,用来选前端 */
|
|
30
|
+
flags?: readonly string[];
|
|
31
|
+
/** 核心自己提供的服务(jade@1):插件可以在 requires 里写,别人的 provides 不能占用这个名字 */
|
|
32
|
+
coreServices?: readonly string[];
|
|
33
|
+
}
|
|
34
|
+
export declare function resolve(sources: readonly PluginSource[], opts: ResolveOptions): Plan;
|