@uncarved/jade 0.3.0 → 0.3.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 +1 -0
- package/dist/api.d.ts +1 -1
- package/dist/api.js +1 -1
- package/package.json +2 -2
- package/plugins/approval/index.ts +14 -11
- package/plugins/approval/policy.ts +34 -16
- package/plugins/fs/grep.ts +13 -3
- package/plugins/fs/index.ts +5 -5
- package/plugins/fs/plugin.json +1 -1
- package/plugins/mcp/index.ts +5 -5
- package/plugins/mcp/plugin.json +1 -1
- package/plugins/models/index.ts +4 -3
- package/plugins/models/provider.ts +12 -1
- package/plugins/repeats/index.ts +31 -1
- package/plugins/screenshot/browser.ts +221 -0
- package/plugins/screenshot/index.ts +3 -2
- package/plugins/screenshot/tool.ts +27 -51
- package/plugins/shell/index.ts +64 -6
- package/plugins/shell/plugin.json +1 -1
- package/plugins/shell/shell.ts +90 -33
- package/plugins/task/index.ts +12 -42
- package/plugins/task/plugin.json +1 -2
- package/plugins/task/subagent.ts +2 -2
- package/plugins/tools/index.ts +50 -0
- package/plugins/tools/plugin.json +7 -0
- package/plugins/tui/frontend.ts +27 -3
- package/plugins/tui/mascot.ts +8 -7
- package/plugins/tui/tui.ts +23 -7
- package/plugins/web/index.ts +7 -7
- package/plugins/web/plugin.json +1 -1
- package/plugins-dist/approval/index.js +16 -12
- package/plugins-dist/approval/policy.js +30 -15
- package/plugins-dist/fs/grep.js +12 -3
- package/plugins-dist/fs/index.js +5 -5
- package/plugins-dist/fs/plugin.json +1 -1
- package/plugins-dist/mcp/index.js +5 -5
- package/plugins-dist/mcp/plugin.json +1 -1
- package/plugins-dist/models/index.js +4 -3
- package/plugins-dist/models/provider.js +13 -1
- package/plugins-dist/repeats/index.js +27 -1
- package/plugins-dist/screenshot/browser.js +187 -0
- package/plugins-dist/screenshot/index.js +3 -2
- package/plugins-dist/screenshot/tool.js +27 -49
- package/plugins-dist/shell/index.js +68 -5
- package/plugins-dist/shell/plugin.json +1 -1
- package/plugins-dist/shell/shell.js +82 -30
- package/plugins-dist/task/index.js +11 -42
- package/plugins-dist/task/plugin.json +1 -3
- package/plugins-dist/task/subagent.js +1 -1
- package/plugins-dist/tools/index.js +49 -0
- package/plugins-dist/tools/plugin.json +9 -0
- package/plugins-dist/tui/frontend.js +28 -3
- package/plugins-dist/tui/mascot.js +8 -6
- package/plugins-dist/tui/tui.js +18 -7
- package/plugins-dist/tui/vendor.js +1388 -1088
- package/plugins-dist/web/index.js +6 -6
- package/plugins-dist/web/plugin.json +1 -1
- package/sdk/python/__pycache__/jade_plugin.cpython-312.pyc +0 -0
- package/src/api.ts +1 -1
|
@@ -43,7 +43,11 @@ const OWN = [
|
|
|
43
43
|
{ name: "copy", args: "[code]", about: "copy the last reply to the clipboard as it was written (code: only its last code block)" },
|
|
44
44
|
{ name: "exit", about: "quit (the session stays resumable)" },
|
|
45
45
|
];
|
|
46
|
-
const KEYS = "Keys: enter send · ctrl+j, alt+enter or \\ then enter: new line · ↑↓ history · esc interrupt (twice to also move queued messages back to the input) · ↑ on the first line edits queued messages · ctrl+o expand · ctrl+c twice to exit";
|
|
46
|
+
const KEYS = "Keys: enter send · !<command> runs a shell command yourself · ctrl+j, alt+enter or \\ then enter: new line · ↑↓ history · esc interrupt (twice to also move queued messages back to the input) · ↑ on the first line edits queued messages · ctrl+o expand · ctrl+c twice to exit";
|
|
47
|
+
/** 退出时最多等正在做的事这么久 */
|
|
48
|
+
const QUIT_WAIT_MS = 3000;
|
|
49
|
+
/** 命令运行中的临时显示(CommandContext.progress)最多占几行 */
|
|
50
|
+
const LIVE_ROWS = 8;
|
|
47
51
|
/** 第二次 esc 算作"再按一次"的时间窗口 */
|
|
48
52
|
const SECOND_ESC_MS = 3000;
|
|
49
53
|
const VERSION = (() => {
|
|
@@ -495,7 +499,10 @@ async function run(services, bridge, opts) {
|
|
|
495
499
|
quitting = true;
|
|
496
500
|
if (running)
|
|
497
501
|
current?.abort(new Error("exiting"));
|
|
498
|
-
|
|
502
|
+
// 正在做的事停不下来时(例如命令杀不掉)不一直等:退出不能被它卡住
|
|
503
|
+
for (const ac of commandAborts)
|
|
504
|
+
ac.abort(new Error("exiting"));
|
|
505
|
+
await Promise.race([work?.catch(() => { }), new Promise((r) => setTimeout(r, QUIT_WAIT_MS))]);
|
|
499
506
|
keyAbort.abort(new Error("exiting"));
|
|
500
507
|
offMode?.();
|
|
501
508
|
offModel?.();
|
|
@@ -561,7 +568,19 @@ async function run(services, bridge, opts) {
|
|
|
561
568
|
}
|
|
562
569
|
const ac = new AbortController();
|
|
563
570
|
commandAborts.add(ac);
|
|
564
|
-
|
|
571
|
+
// 命令的临时显示:末尾几行,每行占进度区的一行
|
|
572
|
+
const showLive = (text) => {
|
|
573
|
+
const lines = text?.replace(/\r\n?/g, "\n").trimEnd().split("\n").slice(-LIVE_ROWS) ?? [];
|
|
574
|
+
for (let i = 0; i < LIVE_ROWS; i++)
|
|
575
|
+
screen.progress(`command:${i}`, text !== undefined && i < lines.length ? dim(` │ ${lines[i]}`) : undefined);
|
|
576
|
+
};
|
|
577
|
+
const ctx = {
|
|
578
|
+
signal: ac.signal,
|
|
579
|
+
ui: bridge.ui,
|
|
580
|
+
sessions: manager,
|
|
581
|
+
print: (t, o) => screen.log(t, o?.details ? { details: o.details } : undefined),
|
|
582
|
+
progress: showLive,
|
|
583
|
+
};
|
|
565
584
|
try {
|
|
566
585
|
const result = await found.command.run(rest, ctx);
|
|
567
586
|
if (typeof result === "string")
|
|
@@ -578,6 +597,7 @@ async function run(services, bridge, opts) {
|
|
|
578
597
|
screen.log(red(`[error] /${name}: ${errorText(e)}`));
|
|
579
598
|
}
|
|
580
599
|
finally {
|
|
600
|
+
showLive(undefined);
|
|
581
601
|
commandAborts.delete(ac);
|
|
582
602
|
}
|
|
583
603
|
return true;
|
|
@@ -585,6 +605,9 @@ async function run(services, bridge, opts) {
|
|
|
585
605
|
function onSubmit(text) {
|
|
586
606
|
if (quitting)
|
|
587
607
|
return;
|
|
608
|
+
// !<命令> 是 /sh <命令> 的简写(jade/shell 提供):用户自己执行,不经过模型
|
|
609
|
+
if (/^!\s*\S/.test(text))
|
|
610
|
+
text = `/sh ${text.slice(1).trim()}`;
|
|
588
611
|
const name = commandName(text);
|
|
589
612
|
if (name !== undefined && instant(name)) {
|
|
590
613
|
// 不碰会话的命令运行中也直接执行
|
|
@@ -625,6 +648,8 @@ async function run(services, bridge, opts) {
|
|
|
625
648
|
showQueued();
|
|
626
649
|
view.echo(text);
|
|
627
650
|
if (commandName(text) !== undefined) {
|
|
651
|
+
// 命令可能要跑一阵(/sh 跑测试):让用户看到它在跑
|
|
652
|
+
screen.busy("Running");
|
|
628
653
|
if (!(await command(text))) {
|
|
629
654
|
exit = true;
|
|
630
655
|
return;
|
|
@@ -333,12 +333,14 @@ function side(mood, now, t) {
|
|
|
333
333
|
const c = mix(BANG[0], BANG[1], 0.5 + 0.5 * Math.sin(now / 160));
|
|
334
334
|
return [0, 1, 2, 4].map((y) => [1, y, c]);
|
|
335
335
|
}
|
|
336
|
-
case "stopping":
|
|
337
|
-
//
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
[
|
|
341
|
-
];
|
|
336
|
+
case "stopping": {
|
|
337
|
+
// 汗珠从头的右上角贴着身体一滴滴往下滑:亮的一头在下面,上面拖一格淡的;滑到底停一拍再冒下一滴
|
|
338
|
+
const row = Math.floor((now % 1000) / 200);
|
|
339
|
+
if (row > 3)
|
|
340
|
+
return [];
|
|
341
|
+
const head = [-1, row, mix(SWEAT, rgb("#ffffff"), 0.4)];
|
|
342
|
+
return row > 0 ? [[-1, row - 1, SWEAT], head] : [head];
|
|
343
|
+
}
|
|
342
344
|
default:
|
|
343
345
|
return [];
|
|
344
346
|
}
|
package/plugins-dist/tui/tui.js
CHANGED
|
@@ -1260,9 +1260,7 @@ function Prompt({ commands, handlers, history: initial, bridge, hint, onHintDone
|
|
|
1260
1260
|
/** 提示只在空闲、输入框为空、没有在搜索历史时显示,也只有这时能接受 */
|
|
1261
1261
|
const hinting = () => hint !== undefined && !busy && current().value === "" && !getSearch();
|
|
1262
1262
|
const set = (s) => {
|
|
1263
|
-
//
|
|
1264
|
-
if (s.value && hint !== undefined)
|
|
1265
|
-
onHintDone();
|
|
1263
|
+
// 打字时提示只是不显示(hinting() 要求输入框为空),删回空的又出现;发出去才作废
|
|
1266
1264
|
setState(s);
|
|
1267
1265
|
setSelected(0);
|
|
1268
1266
|
setNotice(undefined);
|
|
@@ -1278,6 +1276,8 @@ function Prompt({ commands, handlers, history: initial, bridge, hint, onHintDone
|
|
|
1278
1276
|
const submit = (text) => {
|
|
1279
1277
|
if (!text.trim())
|
|
1280
1278
|
return;
|
|
1279
|
+
if (hint !== undefined)
|
|
1280
|
+
onHintDone();
|
|
1281
1281
|
remember(text);
|
|
1282
1282
|
set(empty);
|
|
1283
1283
|
// 发出去之后弹出的对话框是用户自己要的(/mode、/model),马上就能回答
|
|
@@ -1415,8 +1415,13 @@ function Prompt({ commands, handlers, history: initial, bridge, hint, onHintDone
|
|
|
1415
1415
|
? setSearch({ query: "", index: 0 })
|
|
1416
1416
|
: undefined;
|
|
1417
1417
|
if (key.ctrl && input === "c") {
|
|
1418
|
-
if (busy)
|
|
1418
|
+
if (busy) {
|
|
1419
|
+
// 第一下中断;停不下来时(卡在 Interrupting)再按一下也能退出
|
|
1420
|
+
if (Date.now() - lastCtrlC.current < 2000)
|
|
1421
|
+
return handlers.exit();
|
|
1422
|
+
lastCtrlC.current = Date.now();
|
|
1419
1423
|
return handlers.interrupt();
|
|
1424
|
+
}
|
|
1420
1425
|
if (state.value)
|
|
1421
1426
|
return discard();
|
|
1422
1427
|
if (Date.now() - lastCtrlC.current < 2000)
|
|
@@ -1459,7 +1464,6 @@ function Prompt({ commands, handlers, history: initial, bridge, hint, onHintDone
|
|
|
1459
1464
|
}
|
|
1460
1465
|
// Tab 或 →:把提示变成输入框里的文字,接着可以改
|
|
1461
1466
|
if (((key.tab && !key.shift) || key.rightArrow) && hinting()) {
|
|
1462
|
-
onHintDone();
|
|
1463
1467
|
browsing.current = -1;
|
|
1464
1468
|
return set({ value: hint, cursor: hint.length });
|
|
1465
1469
|
}
|
|
@@ -1523,8 +1527,10 @@ function Prompt({ commands, handlers, history: initial, bridge, hint, onHintDone
|
|
|
1523
1527
|
const dragged = drag && drag.value === state.value && drag.anchor !== drag.focus
|
|
1524
1528
|
? [Math.min(drag.anchor, drag.focus), Math.max(drag.anchor, drag.focus)]
|
|
1525
1529
|
: undefined;
|
|
1530
|
+
// ! 开头:这一行是用户自己执行的 shell 命令(/sh),边框换个颜色、上边框的右边写一行说明
|
|
1531
|
+
const bang = !search && state.value.startsWith("!");
|
|
1526
1532
|
// 对话框打开时隐藏但不卸载,输入到一半的内容和历史都保留
|
|
1527
|
-
return h(Box, { flexDirection: "column", marginTop: 1, display: active ? "flex" : "none" }, h(Box, { borderStyle: "round", borderColor: busy ? "gray" : "cyan", paddingX: 1 }, search
|
|
1533
|
+
return h(Box, { flexDirection: "column", marginTop: 1, display: active ? "flex" : "none" }, h(Box, { borderStyle: "round", borderColor: bang ? "magenta" : busy ? "gray" : "cyan", paddingX: 1 }, search
|
|
1528
1534
|
? h(EditableText, {
|
|
1529
1535
|
state: { value: search.query, cursor: search.query.length },
|
|
1530
1536
|
width: Math.max(10, columns - 5),
|
|
@@ -1588,7 +1594,12 @@ function Prompt({ commands, handlers, history: initial, bridge, hint, onHintDone
|
|
|
1588
1594
|
? h(Text, { color: "yellow" }, ` ${notice}`)
|
|
1589
1595
|
: null,
|
|
1590
1596
|
// 压在输入框上边框的右边,不占行,出现和消失时下面的内容不跳
|
|
1591
|
-
|
|
1597
|
+
// ! 开头时同一个位置写这一行是什么(刚复制的提示优先)
|
|
1598
|
+
flash
|
|
1599
|
+
? h(Box, { position: "absolute", top: 0, right: 2 }, h(Text, { color: "green" }, ` ${flash} `))
|
|
1600
|
+
: bang
|
|
1601
|
+
? h(Box, { position: "absolute", top: 0, right: 2 }, h(Text, { color: "magenta" }, columns >= 70 ? (busy ? " shell command · runs after this turn · esc stops it " : " shell command · you run it, not the agent · esc stops it ") : " shell command "))
|
|
1602
|
+
: null);
|
|
1592
1603
|
}
|
|
1593
1604
|
/** 提示在输入框里只显示第一行,后面还有时加 … */
|
|
1594
1605
|
const hintLine = (hint) => {
|