@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
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
1
|
// 终端界面(Ink):全屏(备用屏幕缓冲区)分三块——顶部标题(版本、模型、目录),中间是对话,
|
|
3
2
|
// 自己滚动(滚轮、PgUp/PgDn),底部固定显示运行状态、排队的消息、输入框(或对话框)和状态栏。
|
|
4
3
|
// 运行中也能输入:提交的内容由宿主决定立即执行还是排队。
|
|
4
|
+
//
|
|
5
|
+
// 不用 JSX:插件以 .ts 源码加载,Node 的类型剥离不处理 .tsx,所以组件用 createElement(h)写。
|
|
5
6
|
import { writeSync } from "node:fs";
|
|
6
|
-
import { Box, render, Text, useBoxMetrics, useCursor, useInput, usePaste, useWindowSize, } from "
|
|
7
|
-
import { createContext, useContext, useEffect, useReducer, useRef, useState, useSyncExternalStore, } from "react";
|
|
7
|
+
import { Box, render, Text, useBoxMetrics, useCursor, useInput, usePaste, useWindowSize, createContext, createElement as h, useContext, useEffect, useReducer, useRef, useState, useSyncExternalStore, } from "./vendor.js";
|
|
8
8
|
import stringWidth from "string-width";
|
|
9
9
|
import wrapAnsi from "wrap-ansi";
|
|
10
|
-
import { mentionAt, mentionText, rankPaths } from "
|
|
10
|
+
import { mentionAt, mentionText, rankPaths } from "./mentions.js";
|
|
11
11
|
import { charWidth, edit, empty, layout, moveRow, offsetAt } from "./editor.js";
|
|
12
12
|
import { expandTabs, markdownStream } from "./markdown.js";
|
|
13
13
|
import { dim, } from "./screen.js";
|
|
@@ -242,7 +242,7 @@ class Store {
|
|
|
242
242
|
this.#wrapped = [];
|
|
243
243
|
this.#owners = [];
|
|
244
244
|
this.#named.clear();
|
|
245
|
-
this.update({ version: this.state.version + 1, live: undefined, progress: [], scroll: 0 }, true);
|
|
245
|
+
this.update({ version: this.state.version + 1, live: undefined, progress: [], scroll: 0, hint: undefined }, true);
|
|
246
246
|
}
|
|
247
247
|
/** 展开或收起最后一个可折叠的项(Ctrl+O);start、view 同 toggle */
|
|
248
248
|
toggleLatest(start, view) {
|
|
@@ -359,7 +359,16 @@ export function tuiScreen(opts) {
|
|
|
359
359
|
// 切到备用屏幕后光标还停在原来的位置(不少终端不会自动归位),Ink 从那里往下画第一帧会让屏幕滚动,
|
|
360
360
|
// 之后每帧只重写变化的行,整个界面就错位了。所以先自己切过去、清屏、把光标移到左上角
|
|
361
361
|
stdout.write("\x1b[?1049h\x1b[2J\x1b[H");
|
|
362
|
-
const
|
|
362
|
+
const commands = opts.commands;
|
|
363
|
+
const instance = render(h(App, {
|
|
364
|
+
store,
|
|
365
|
+
copy: (text) => void stdout.write(osc52(text)),
|
|
366
|
+
version: opts.version,
|
|
367
|
+
commands: typeof commands === "function" ? commands : () => commands,
|
|
368
|
+
handlers: opts.handlers,
|
|
369
|
+
history: opts.history ?? [],
|
|
370
|
+
draft,
|
|
371
|
+
}), {
|
|
363
372
|
exitOnCtrlC: false,
|
|
364
373
|
alternateScreen: true,
|
|
365
374
|
// 全屏每帧只重写变化的行
|
|
@@ -461,6 +470,7 @@ export function tuiScreen(opts) {
|
|
|
461
470
|
const value = text.replace(/\r\n?/g, "\n");
|
|
462
471
|
draft.current?.apply(() => ({ value, cursor: value.length }));
|
|
463
472
|
},
|
|
473
|
+
hint: (text) => store.update({ hint: text ? text.replace(/\r\n?/g, "\n") : undefined }),
|
|
464
474
|
},
|
|
465
475
|
select: (title, choices, o) => {
|
|
466
476
|
if (longBusy())
|
|
@@ -651,10 +661,16 @@ function App({ store, copy, version, commands, handlers, history, draft, }) {
|
|
|
651
661
|
copiedTimer.current = setTimeout(() => setCopied(undefined), COPIED_MS);
|
|
652
662
|
};
|
|
653
663
|
// Ink 增量渲染只用相对光标移动,第一帧起点一旦偏了(启动时终端尺寸还没稳定、窗口缩放、别的输出插进来),
|
|
654
|
-
//
|
|
664
|
+
// 之后每帧都会画错行。尺寸变化后和按 Ctrl+L 时让一帧比终端高,Ink 会清屏从左上角整帧重画(包在同步输出里),下一帧再恢复。
|
|
665
|
+
// 启动时不重画:第一帧之前已经清屏、光标在左上角;这两次清屏在不支持同步输出的终端上(Windows 上常见)看得出闪一下
|
|
655
666
|
const [redraws, setRedraws] = useState(0);
|
|
656
667
|
const [repaint, setRepaint] = useState(false);
|
|
668
|
+
const mounted = useRef(false);
|
|
657
669
|
useEffect(() => {
|
|
670
|
+
if (!mounted.current) {
|
|
671
|
+
mounted.current = true;
|
|
672
|
+
return;
|
|
673
|
+
}
|
|
658
674
|
const t = setTimeout(() => setRepaint(true), 100);
|
|
659
675
|
return () => clearTimeout(t);
|
|
660
676
|
}, [columns, rows, redraws]);
|
|
@@ -726,10 +742,44 @@ function App({ store, copy, version, commands, handlers, history, draft, }) {
|
|
|
726
742
|
// 总高度要比终端少一行,否则 Ink 认为输出占满了屏幕,每帧清屏重画。
|
|
727
743
|
// 重画那一帧上下各垫一行空白:终端把顶上那行滚出去后,看到的和平时逐行一样,所以不会闪。
|
|
728
744
|
// 只做纵向裁剪:每行都已按宽度折好或截断,横向裁剪会让 Ink 每帧对每一行再切一遍 ANSI 字符串
|
|
729
|
-
return (
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
745
|
+
return h(SelectionContext.Provider, { value: selectionApi }, h(Box, {
|
|
746
|
+
flexDirection: "column",
|
|
747
|
+
width: columns,
|
|
748
|
+
height: repaint ? rows + 1 : Math.max(1, rows - 1),
|
|
749
|
+
paddingY: repaint ? 1 : 0,
|
|
750
|
+
overflowY: "hidden",
|
|
751
|
+
},
|
|
752
|
+
// 垫的空白放在外层:里面这层在重画那一帧和平时一样高,对话区的 top(相对父节点)不变,点击换算的行号不会差一行
|
|
753
|
+
h(Box, { flexDirection: "column", flexGrow: 1, overflowY: "hidden" }, h(Header, { status: state.status, version, compact: rows < COMPACT_ROWS }), h(Box, {
|
|
754
|
+
ref,
|
|
755
|
+
flexDirection: "column",
|
|
756
|
+
flexGrow: 1,
|
|
757
|
+
flexShrink: 1,
|
|
758
|
+
flexBasis: 0,
|
|
759
|
+
overflowY: "hidden",
|
|
760
|
+
paddingX: 1,
|
|
761
|
+
}, shown.map((l, i) => {
|
|
762
|
+
const cols = selection && selectedCols(selection, start + i);
|
|
763
|
+
return h(Text, { key: i, wrap: "truncate-end" }, cols ? highlight(l || " ", ...cols) : l || " ");
|
|
764
|
+
}), scrolled
|
|
765
|
+
? h(Text, { dimColor: true, wrap: "truncate-end" }, `── ↓ ${scroll} more lines · wheel / PgDn to scroll · ctrl+end to jump to the bottom ──`)
|
|
766
|
+
: null), h(Box, { flexDirection: "column", flexShrink: 0 }, state.busy && !dialog ? h(Spinner, { label: state.busy.label, since: state.busy.since }) : null, state.queued.map((q, i) => h(Text, { key: i, dimColor: true, wrap: "truncate-end" }, " ↳ queued: ", q.replace(/\s+/g, " "))), dialog
|
|
767
|
+
? dialog.kind === "select"
|
|
768
|
+
? h(SelectDialog, { key: dialogKey(dialog), dialog })
|
|
769
|
+
: h(InputDialog, { key: dialogKey(dialog), dialog })
|
|
770
|
+
: null, h(Prompt, {
|
|
771
|
+
commands,
|
|
772
|
+
handlers,
|
|
773
|
+
history,
|
|
774
|
+
bridge: draft,
|
|
775
|
+
hint: state.hint,
|
|
776
|
+
onHintDone: () => store.update({ hint: undefined }),
|
|
777
|
+
busy: Boolean(state.busy),
|
|
778
|
+
queued: state.queued.length > 0,
|
|
779
|
+
active: !dialog,
|
|
780
|
+
onSubmit: () => store.scrollBy(-max, max),
|
|
781
|
+
flash: copied,
|
|
782
|
+
}), h(StatusBar, { status: state.status, width: Math.max(10, columns - 2) })))));
|
|
733
783
|
}
|
|
734
784
|
const JADE = "#00a86b";
|
|
735
785
|
const SHINE = "#b6f2d4";
|
|
@@ -738,13 +788,21 @@ const SHINE = "#b6f2d4";
|
|
|
738
788
|
* 每个字符上下两个像素;眼睛是玉上挖空的两格,左上角一点高光让它看起来像玉
|
|
739
789
|
*/
|
|
740
790
|
function Bot() {
|
|
741
|
-
return (
|
|
791
|
+
return h(Box, { flexDirection: "column", flexShrink: 0, marginRight: 2 }, h(Text, { color: JADE }, " ▄", h(Text, { color: SHINE, backgroundColor: JADE }, "▄"), "████▄"), h(Text, { color: JADE }, "██ ███ ██"), h(Text, { color: JADE }, "▀███████▀"));
|
|
742
792
|
}
|
|
743
793
|
function Header({ status, version, compact, }) {
|
|
744
794
|
const { columns } = useScreenSize();
|
|
795
|
+
// 模型 · 目录 (分支)
|
|
796
|
+
const where = [
|
|
797
|
+
h(Text, { key: "model", color: "cyan" }, status.model),
|
|
798
|
+
h(Text, { key: "sep", dimColor: true }, " · "),
|
|
799
|
+
h(Text, { key: "cwd" }, status.cwd),
|
|
800
|
+
status.branch ? h(Text, { key: "branch", color: "magenta" }, ` (${status.branch})`) : null,
|
|
801
|
+
];
|
|
802
|
+
const name = h(Text, { key: "name", color: "cyan", bold: true }, "jade");
|
|
745
803
|
if (compact)
|
|
746
|
-
return (
|
|
747
|
-
return (
|
|
804
|
+
return h(Box, { flexShrink: 0, paddingX: 1 }, h(Text, { wrap: "truncate-end" }, name, h(Text, { key: "dot", dimColor: true }, " · "), ...where));
|
|
805
|
+
return h(Box, { flexShrink: 0, borderStyle: "round", borderColor: "cyan", paddingX: 1 }, columns >= 50 ? h(Bot) : null, h(Box, { flexDirection: "column", flexGrow: 1, flexShrink: 1 }, h(Text, { wrap: "truncate-end" }, name, h(Text, { dimColor: true }, ` v${version}`), status.session ? h(Text, { dimColor: true }, ` · session ${status.session}`) : null), h(Text, { wrap: "truncate-end" }, ...where), h(Text, { dimColor: true, wrap: "truncate-end" }, "/help for commands · @ to attach files")));
|
|
748
806
|
}
|
|
749
807
|
const dialogIds = new WeakMap();
|
|
750
808
|
let dialogCounter = 0;
|
|
@@ -758,7 +816,7 @@ const FRAMES = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "
|
|
|
758
816
|
function Spinner({ label, since }) {
|
|
759
817
|
const now = Date.now();
|
|
760
818
|
const seconds = Math.floor((now - since) / 1000);
|
|
761
|
-
return (
|
|
819
|
+
return h(Box, { marginTop: 1 }, h(Text, { wrap: "truncate-end" }, h(Text, { color: "cyan" }, `${FRAMES[Math.floor(now / 100) % FRAMES.length]} `), h(Text, null, `${label}… `), h(Text, { dimColor: true }, `(${seconds}s · esc to interrupt)`)));
|
|
762
820
|
}
|
|
763
821
|
/** 在 width 列里放下尽量多的内容(保持原来的顺序) */
|
|
764
822
|
export function fitSegments(segments, width) {
|
|
@@ -846,12 +904,12 @@ function StatusBar({ status, width }) {
|
|
|
846
904
|
},
|
|
847
905
|
];
|
|
848
906
|
const shown = fitSegments(segments, width);
|
|
849
|
-
return (
|
|
907
|
+
return h(Box, { paddingX: 1 }, h(Text, { wrap: "truncate-end" }, shown.map((s, i) => h(Text, { key: i }, i ? h(Text, { dimColor: true }, " · ") : null, h(Text, { color: s.color, dimColor: s.dim }, s.text)))));
|
|
850
908
|
}
|
|
851
909
|
/** 一行提示:按宽度选第一个放得下的写法,都放不下时用最后一个并截断 */
|
|
852
910
|
function Hint({ variants, width }) {
|
|
853
911
|
const text = variants.find((v) => stringWidth(v) <= width) ?? variants.at(-1);
|
|
854
|
-
return (
|
|
912
|
+
return h(Text, { dimColor: true, wrap: "truncate-end" }, text);
|
|
855
913
|
}
|
|
856
914
|
const tokens = (n) => n >= 1_000_000
|
|
857
915
|
? `${(n / 1_000_000).toFixed(n >= 10_000_000 ? 0 : 1)}M`
|
|
@@ -890,6 +948,10 @@ function editKey(s, input, key) {
|
|
|
890
948
|
return edit.del(s);
|
|
891
949
|
if (key.ctrl && input === "w")
|
|
892
950
|
return edit.deleteWord(s);
|
|
951
|
+
if (key.meta && !key.ctrl && input === "f")
|
|
952
|
+
return edit.wordRight(s);
|
|
953
|
+
if (key.meta && !key.ctrl && input === "b")
|
|
954
|
+
return edit.wordLeft(s);
|
|
893
955
|
if (key.ctrl && input === "u")
|
|
894
956
|
return edit.killBefore(s);
|
|
895
957
|
if (key.ctrl && input === "k")
|
|
@@ -948,11 +1010,9 @@ function EditableText({ state, width, prefix, mask, placeholder, active, maxRows
|
|
|
948
1010
|
if (now.x !== at.x || now.y !== at.y)
|
|
949
1011
|
recheck();
|
|
950
1012
|
});
|
|
951
|
-
return (
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
? "↑".padEnd(prefix.length)
|
|
955
|
-
: " ".repeat(prefix.length) }), r] }, first + i))))] }));
|
|
1013
|
+
return h(Box, { ref, flexDirection: "column" }, active ? h(CursorAt, { position }) : null, state.value === "" && placeholder
|
|
1014
|
+
? h(Text, { wrap: "truncate-end" }, h(Text, { color: "cyan" }, prefix), h(Text, { dimColor: true }, placeholder))
|
|
1015
|
+
: rows.map((r, i) => h(Text, { key: first + i, wrap: "truncate-end" }, h(Text, { color: "cyan" }, first + i === 0 ? prefix : i === 0 ? "↑".padEnd(prefix.length) : " ".repeat(prefix.length)), r)));
|
|
956
1016
|
}
|
|
957
1017
|
/**
|
|
958
1018
|
* 终端光标只有一个,每个 useCursor 每次提交都会设一遍。没有焦点的输入框(弹出输入框时下面的主输入框)
|
|
@@ -973,7 +1033,7 @@ function origin(node) {
|
|
|
973
1033
|
}
|
|
974
1034
|
return { x, y };
|
|
975
1035
|
}
|
|
976
|
-
function Prompt({ commands, handlers, history: initial, bridge, busy, active, onSubmit, flash, }) {
|
|
1036
|
+
function Prompt({ commands, handlers, history: initial, bridge, hint, onHintDone, busy, queued, active, onSubmit, flash, }) {
|
|
977
1037
|
const selection = useContext(SelectionContext);
|
|
978
1038
|
const [current, setState] = useLive(empty);
|
|
979
1039
|
const [getSelected, setSelected] = useLive(0);
|
|
@@ -999,7 +1059,7 @@ function Prompt({ commands, handlers, history: initial, bridge, busy, active, on
|
|
|
999
1059
|
// Ctrl+R 搜索历史:结果新的在前,index 是选中的那条
|
|
1000
1060
|
const [getSearch, setSearch] = useLive(undefined);
|
|
1001
1061
|
const usageOf = (c) => `/${c.name}${c.args ? ` ${c.args}` : ""}`;
|
|
1002
|
-
const column = Math.max(...commands.map((c) => usageOf(c).length)) + 2;
|
|
1062
|
+
const column = Math.max(...commands().map((c) => usageOf(c).length)) + 2;
|
|
1003
1063
|
/** 由最新的输入算出补全菜单和搜索结果;渲染和按键处理都用它 */
|
|
1004
1064
|
const derive = () => {
|
|
1005
1065
|
const state = current();
|
|
@@ -1011,7 +1071,7 @@ function Prompt({ commands, handlers, history: initial, bridge, busy, active, on
|
|
|
1011
1071
|
history.current[history.current.length - 1 - browsing.current];
|
|
1012
1072
|
const naming = !recalled && state.value.startsWith("/") && !/\s/.test(state.value);
|
|
1013
1073
|
const matches = naming
|
|
1014
|
-
? commands.filter((c) => `/${c.name}`.startsWith(state.value))
|
|
1074
|
+
? commands().filter((c) => `/${c.name}`.startsWith(state.value))
|
|
1015
1075
|
: [];
|
|
1016
1076
|
const pick = matches[Math.min(selected, matches.length - 1)];
|
|
1017
1077
|
// @ 引用:光标处正在输入的路径和补全候选
|
|
@@ -1067,7 +1127,12 @@ function Prompt({ commands, handlers, history: initial, bridge, busy, active, on
|
|
|
1067
1127
|
const first = around(hit, results.length, menuRows);
|
|
1068
1128
|
const firstMatch = around(Math.max(0, matches.indexOf(pick)), matches.length, menuRows);
|
|
1069
1129
|
const firstFound = around(Math.max(0, found.indexOf(file)), found.length, menuRows);
|
|
1130
|
+
/** 提示只在空闲、输入框为空、没有在搜索历史时显示,也只有这时能接受 */
|
|
1131
|
+
const hinting = () => hint !== undefined && !busy && current().value === "" && !getSearch();
|
|
1070
1132
|
const set = (s) => {
|
|
1133
|
+
// 用户开始打字(或者插件改了输入框):提示作废
|
|
1134
|
+
if (s.value && hint !== undefined)
|
|
1135
|
+
onHintDone();
|
|
1071
1136
|
setState(s);
|
|
1072
1137
|
setSelected(0);
|
|
1073
1138
|
setNotice(undefined);
|
|
@@ -1222,6 +1287,12 @@ function Prompt({ commands, handlers, history: initial, bridge, busy, active, on
|
|
|
1222
1287
|
return complete(file);
|
|
1223
1288
|
return submit(state.value.trim());
|
|
1224
1289
|
}
|
|
1290
|
+
// Tab 或 →:把提示变成输入框里的文字,接着可以改
|
|
1291
|
+
if (((key.tab && !key.shift) || key.rightArrow) && hinting()) {
|
|
1292
|
+
onHintDone();
|
|
1293
|
+
browsing.current = -1;
|
|
1294
|
+
return set({ value: hint, cursor: hint.length });
|
|
1295
|
+
}
|
|
1225
1296
|
if (key.tab && key.shift)
|
|
1226
1297
|
return handlers.cycleMode?.();
|
|
1227
1298
|
if (key.tab) {
|
|
@@ -1243,6 +1314,11 @@ function Prompt({ commands, handlers, history: initial, bridge, busy, active, on
|
|
|
1243
1314
|
const up = moveRow(state, textWidth, -1);
|
|
1244
1315
|
if (up)
|
|
1245
1316
|
return setState(up);
|
|
1317
|
+
// 先取回排队的消息,取完了再翻历史
|
|
1318
|
+
if (handlers.unqueue?.()) {
|
|
1319
|
+
browsing.current = -1;
|
|
1320
|
+
return;
|
|
1321
|
+
}
|
|
1246
1322
|
if (browsing.current + 1 < history.current.length) {
|
|
1247
1323
|
if (browsing.current === -1)
|
|
1248
1324
|
draft.current = state.value;
|
|
@@ -1269,31 +1345,75 @@ function Prompt({ commands, handlers, history: initial, bridge, busy, active, on
|
|
|
1269
1345
|
set(next);
|
|
1270
1346
|
}, { isActive: active });
|
|
1271
1347
|
// 对话框打开时隐藏但不卸载,输入到一半的内容和历史都保留
|
|
1272
|
-
return (
|
|
1348
|
+
return h(Box, { flexDirection: "column", marginTop: 1, display: active ? "flex" : "none" }, h(Box, { borderStyle: "round", borderColor: busy ? "gray" : "cyan", paddingX: 1 }, search
|
|
1349
|
+
? h(EditableText, {
|
|
1350
|
+
state: { value: search.query, cursor: search.query.length },
|
|
1351
|
+
width: Math.max(10, columns - 5),
|
|
1352
|
+
prefix: "search history› ",
|
|
1353
|
+
placeholder: "type to filter",
|
|
1354
|
+
active,
|
|
1355
|
+
maxRows: inputRows,
|
|
1356
|
+
})
|
|
1357
|
+
: h(EditableText, {
|
|
1358
|
+
state,
|
|
1359
|
+
width: Math.max(10, columns - 5),
|
|
1360
|
+
prefix: "› ",
|
|
1361
|
+
placeholder: hinting()
|
|
1362
|
+
? hintLine(hint)
|
|
1363
|
+
: queued
|
|
1364
|
+
? "↑ to edit queued messages · esc to interrupt"
|
|
1365
|
+
: busy
|
|
1273
1366
|
? "Type to queue a message · esc to interrupt"
|
|
1274
1367
|
: columns >= 70
|
|
1275
1368
|
? "Message jade · / commands · @ files · ↑ or ctrl+r for history"
|
|
1276
|
-
: "Message jade · / commands · @ files",
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1369
|
+
: "Message jade · / commands · @ files",
|
|
1370
|
+
active,
|
|
1371
|
+
maxRows: inputRows,
|
|
1372
|
+
place,
|
|
1373
|
+
})), search
|
|
1374
|
+
? h(Box, { flexDirection: "column", paddingX: 2 }, results.length
|
|
1375
|
+
? results.slice(first, first + menuRows).map((item, i) => {
|
|
1376
|
+
const on = first + i === hit;
|
|
1377
|
+
return h(Text, { key: first + i, wrap: "truncate-end", color: on ? "cyan" : undefined, bold: on }, on ? "❯ " : " ", item.replace(/\s*\n\s*/g, " ⏎ "));
|
|
1378
|
+
})
|
|
1379
|
+
: h(Text, { dimColor: true }, " no match"), h(Hint, {
|
|
1380
|
+
width: hintWidth,
|
|
1381
|
+
variants: [" ↑↓ or ctrl+r select · enter/tab put in the input · esc cancel", " ↑↓ select · enter use · esc cancel"],
|
|
1382
|
+
}))
|
|
1383
|
+
: matches.length
|
|
1384
|
+
? h(Box, { flexDirection: "column", paddingX: 2 }, matches.slice(firstMatch, firstMatch + menuRows).map((c) => {
|
|
1385
|
+
const on = c === pick;
|
|
1386
|
+
return h(Text, { key: c.name, wrap: "truncate-end" }, h(Text, { color: on ? "cyan" : undefined, bold: on }, on ? "❯ " : " ", usageOf(c).padEnd(column)), h(Text, { dimColor: true }, c.about));
|
|
1387
|
+
}), h(Hint, {
|
|
1388
|
+
width: hintWidth,
|
|
1389
|
+
variants: [
|
|
1390
|
+
` ↑↓ select · enter run · tab complete${matches.length > menuRows ? ` · ${matches.length} commands` : ""}`,
|
|
1391
|
+
" ↑↓ · enter run · tab complete",
|
|
1392
|
+
],
|
|
1393
|
+
}))
|
|
1394
|
+
: found.length
|
|
1395
|
+
? h(Box, { flexDirection: "column", paddingX: 2 }, found.slice(firstFound, firstFound + menuRows).map((p) => {
|
|
1396
|
+
const on = p === file;
|
|
1397
|
+
return h(Text, { key: p, wrap: "truncate-middle", color: on ? "cyan" : p.endsWith("/") ? "blue" : undefined, bold: on }, on ? "❯ " : " ", p);
|
|
1398
|
+
}), h(Hint, {
|
|
1399
|
+
width: hintWidth,
|
|
1400
|
+
variants: [
|
|
1401
|
+
" ↑↓ select · enter/tab insert the path · the file's content is sent with the message",
|
|
1402
|
+
" ↑↓ select · enter/tab insert the path",
|
|
1403
|
+
" ↑↓ · enter insert",
|
|
1404
|
+
],
|
|
1405
|
+
}))
|
|
1406
|
+
: notice
|
|
1407
|
+
? h(Text, { color: "yellow" }, ` ${notice}`)
|
|
1408
|
+
: null,
|
|
1409
|
+
// 压在输入框上边框的右边,不占行,出现和消失时下面的内容不跳
|
|
1410
|
+
flash ? h(Box, { position: "absolute", top: 0, right: 2 }, h(Text, { color: "green" }, ` ${flash} `)) : null);
|
|
1296
1411
|
}
|
|
1412
|
+
/** 提示在输入框里只显示第一行,后面还有时加 … */
|
|
1413
|
+
const hintLine = (hint) => {
|
|
1414
|
+
const [first, ...rest] = hint.split("\n");
|
|
1415
|
+
return `${first}${rest.length ? " …" : ""}`;
|
|
1416
|
+
};
|
|
1297
1417
|
/** @ 补全最多显示几项 */
|
|
1298
1418
|
const MENTION_ROWS = 8;
|
|
1299
1419
|
/** 长列表只显示 size 项时,为了让第 selected 项在中间附近,从第几项开始显示 */
|
|
@@ -1375,12 +1495,17 @@ function SelectDialog({ dialog, }) {
|
|
|
1375
1495
|
});
|
|
1376
1496
|
// 选项多时只显示选中项附近的一段
|
|
1377
1497
|
const start = around(selected, n, visible);
|
|
1378
|
-
return (
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1498
|
+
return h(Box, { flexDirection: "column", borderStyle: "round", borderColor: "yellow", paddingX: 1, marginTop: 1 }, h(Text, { bold: true, wrap: "truncate-end" }, dialog.title), body.map((l, i) => h(Text, { key: i, wrap: "truncate-end" }, l || " ")), filtering
|
|
1499
|
+
? h(Text, { wrap: "truncate-end" }, h(Text, { color: "cyan" }, "filter› "), query ? h(Text, null, query) : h(Text, { dimColor: true }, `type to filter ${dialog.choices.length} items`))
|
|
1500
|
+
: null, h(Box, { flexDirection: "column", marginTop: filtering ? 0 : 1 }, start > 0 ? h(Text, { dimColor: true }, ` ↑ ${start} more`) : null, n === 0 ? h(Text, { dimColor: true }, " no match") : null, items.slice(start, start + visible).map(({ c, i }, j) => {
|
|
1501
|
+
const on = start + j === selected;
|
|
1502
|
+
return h(Text, { key: i, wrap: "truncate-end" }, h(Text, { color: on ? "cyan" : undefined, bold: on }, on ? "❯ " : " ", filtering ? "" : `${i + 1}. `, c.label), c.hint ? h(Text, { dimColor: true }, ` ${c.hint}`) : null);
|
|
1503
|
+
}), start + visible < n ? h(Text, { dimColor: true }, ` ↓ ${n - start - visible} more`) : null), h(Hint, {
|
|
1504
|
+
width: Math.max(10, columns - 4),
|
|
1505
|
+
variants: filtering
|
|
1506
|
+
? ["↑↓ select · type to filter · enter confirm · esc clear/cancel", "↑↓ · enter · esc"]
|
|
1507
|
+
: ["↑↓ select · enter confirm · esc cancel", "↑↓ · enter · esc"],
|
|
1508
|
+
}));
|
|
1384
1509
|
}
|
|
1385
1510
|
function InputDialog({ dialog, }) {
|
|
1386
1511
|
const selection = useContext(SelectionContext);
|
|
@@ -1404,6 +1529,12 @@ function InputDialog({ dialog, }) {
|
|
|
1404
1529
|
if (next)
|
|
1405
1530
|
setState(next);
|
|
1406
1531
|
});
|
|
1407
|
-
return (
|
|
1532
|
+
return h(Box, { flexDirection: "column", borderStyle: "round", borderColor: "yellow", paddingX: 1, marginTop: 1 }, h(Text, { bold: true }, dialog.title), h(EditableText, {
|
|
1533
|
+
state,
|
|
1534
|
+
width: Math.max(10, columns - 6),
|
|
1535
|
+
prefix: "› ",
|
|
1536
|
+
mask: dialog.mask,
|
|
1537
|
+
placeholder: dialog.placeholder,
|
|
1538
|
+
active: true,
|
|
1539
|
+
}), h(Text, { dimColor: true }, "enter confirm · esc cancel"));
|
|
1408
1540
|
}
|
|
1409
|
-
//# sourceMappingURL=tui.js.map
|