@zhongqian97-code/ecode 0.5.55 → 0.5.56
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/dist/index.js +6 -2
- package/dist/{ui-5R3MFOW2.js → ui-YEBPUMP7.js} +163 -85
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -923,6 +923,10 @@ Node.js 16/18 \u8BF7\u4F7F\u7528 --web \u6216 --pipe \u6A21\u5F0F\u3002
|
|
|
923
923
|
);
|
|
924
924
|
process.exit(1);
|
|
925
925
|
}
|
|
926
|
-
const { App, React, render } = await import("./ui-
|
|
927
|
-
|
|
926
|
+
const { App, React, render, createStdinFilter } = await import("./ui-YEBPUMP7.js");
|
|
927
|
+
const stdinFilter = process.stdin.isTTY ? createStdinFilter(process.stdin) : process.stdin;
|
|
928
|
+
render(
|
|
929
|
+
React.createElement(App, { config: finalConfig, version: VERSION, autoMode, registry, trustedSkillDirs, initialMessages, stdinFilter }),
|
|
930
|
+
{ stdin: stdinFilter }
|
|
931
|
+
);
|
|
928
932
|
}
|
|
@@ -47,7 +47,7 @@ import { render } from "ink";
|
|
|
47
47
|
|
|
48
48
|
// src/ui/App.tsx
|
|
49
49
|
import { useState as useState3, useCallback, useRef as useRef2, useEffect as useEffect3, useMemo } from "react";
|
|
50
|
-
import { Box as Box6, Text as Text6, useInput as useInput2, useStdout
|
|
50
|
+
import { Box as Box6, Text as Text6, useInput as useInput2, useStdout } from "ink";
|
|
51
51
|
|
|
52
52
|
// src/skills/executor.ts
|
|
53
53
|
import { exec } from "child_process";
|
|
@@ -853,49 +853,6 @@ ${blocks.join("\n\n")}`;
|
|
|
853
853
|
${contextSection}` : contextSection;
|
|
854
854
|
}
|
|
855
855
|
|
|
856
|
-
// src/ui/mouseInput.ts
|
|
857
|
-
var SGR_MOUSE_RE = /^\x1b\[<(\d+);\d+;\d+[Mm]/;
|
|
858
|
-
var SGR_FULL_RE = /^\x1b\[<(\d+);(\d+);(\d+)([Mm])/;
|
|
859
|
-
function mouseEventLength(data) {
|
|
860
|
-
const s = typeof data === "string" ? data : data.toString("binary");
|
|
861
|
-
if (!s) return 0;
|
|
862
|
-
const sgrMatch = SGR_MOUSE_RE.exec(s);
|
|
863
|
-
if (sgrMatch) return sgrMatch[0].length;
|
|
864
|
-
if (s.length >= 6 && s.charCodeAt(0) === 27 && s[1] === "[" && s[2] === "M") return 6;
|
|
865
|
-
return 0;
|
|
866
|
-
}
|
|
867
|
-
function parseMouseScroll(data) {
|
|
868
|
-
const s = typeof data === "string" ? data : data.toString("binary");
|
|
869
|
-
if (!s) return null;
|
|
870
|
-
const sgrMatch = SGR_MOUSE_RE.exec(s);
|
|
871
|
-
if (sgrMatch) {
|
|
872
|
-
const cb = parseInt(sgrMatch[1], 10);
|
|
873
|
-
if (cb === 64) return { direction: "up" };
|
|
874
|
-
if (cb === 65) return { direction: "down" };
|
|
875
|
-
return null;
|
|
876
|
-
}
|
|
877
|
-
if (s.length >= 6 && s.charCodeAt(0) === 27 && s[1] === "[" && s[2] === "M") {
|
|
878
|
-
const buttonByte = s.charCodeAt(3);
|
|
879
|
-
if (buttonByte === 96) return { direction: "up" };
|
|
880
|
-
if (buttonByte === 97) return { direction: "down" };
|
|
881
|
-
return null;
|
|
882
|
-
}
|
|
883
|
-
return null;
|
|
884
|
-
}
|
|
885
|
-
function parseMouseSelectionEvent(data) {
|
|
886
|
-
const s = typeof data === "string" ? data : data.toString("binary");
|
|
887
|
-
const m = SGR_FULL_RE.exec(s);
|
|
888
|
-
if (!m) return null;
|
|
889
|
-
const cb = parseInt(m[1], 10);
|
|
890
|
-
const col = parseInt(m[2], 10) - 1;
|
|
891
|
-
const row = parseInt(m[3], 10) - 1;
|
|
892
|
-
const isRelease = m[4] === "m";
|
|
893
|
-
if (isRelease && cb === 0) return { type: "leftUp", col, row };
|
|
894
|
-
if (!isRelease && cb === 0) return { type: "leftDown", col, row };
|
|
895
|
-
if (!isRelease && cb === 32) return { type: "leftDrag", col, row };
|
|
896
|
-
return null;
|
|
897
|
-
}
|
|
898
|
-
|
|
899
856
|
// src/ui/App.tsx
|
|
900
857
|
import { homedir as homedir2 } from "os";
|
|
901
858
|
import { join as join5 } from "path";
|
|
@@ -2446,9 +2403,8 @@ function formatMetaAlignOutput(result, model) {
|
|
|
2446
2403
|
);
|
|
2447
2404
|
return lines.join("\n");
|
|
2448
2405
|
}
|
|
2449
|
-
function App({ config, version, autoMode = false, registry, trustedSkillDirs = [], initialMessages = [], llmClient }) {
|
|
2406
|
+
function App({ config, version, autoMode = false, registry, trustedSkillDirs = [], initialMessages = [], llmClient, stdinFilter }) {
|
|
2450
2407
|
const { stdout } = useStdout();
|
|
2451
|
-
const { stdin } = useStdin();
|
|
2452
2408
|
const historyMaxHeight = Math.max(5, ((stdout == null ? void 0 : stdout.rows) ?? 24) - 4);
|
|
2453
2409
|
const [messages, setMessages] = useState3(initialMessages);
|
|
2454
2410
|
const [status, setStatus] = useState3("idle");
|
|
@@ -2546,51 +2502,41 @@ function App({ config, version, autoMode = false, registry, trustedSkillDirs = [
|
|
|
2546
2502
|
};
|
|
2547
2503
|
}, []);
|
|
2548
2504
|
useEffect3(() => {
|
|
2549
|
-
if (!stdout
|
|
2505
|
+
if (!stdout) return;
|
|
2550
2506
|
stdout.write("\x1B[?1002h\x1B[?1006h");
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
const
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
setScrollOffset((prev) => Math.min(prev + step, Math.max(0, totalLinesRef.current - 1)));
|
|
2565
|
-
} else {
|
|
2566
|
-
setScrollOffset((prev) => Math.max(0, prev - step));
|
|
2567
|
-
}
|
|
2568
|
-
}
|
|
2569
|
-
const sel = parseMouseSelectionEvent(mouseStr);
|
|
2570
|
-
if (sel) {
|
|
2571
|
-
const totalL = totalLinesRef.current;
|
|
2572
|
-
const scrollOff = scrollOffsetRef.current;
|
|
2573
|
-
const histH = historyMaxHeightRef.current;
|
|
2574
|
-
const visibleCount = Math.min(Math.max(0, totalL - scrollOff), histH);
|
|
2575
|
-
const contentStartRow = histH - visibleCount;
|
|
2576
|
-
const lineIdx = sel.row - contentStartRow;
|
|
2577
|
-
if (lineIdx >= 0 && lineIdx < visibleCount) {
|
|
2578
|
-
const pt = { row: lineIdx, col: sel.col };
|
|
2579
|
-
if (sel.type === "leftDown") setSelectionState(startSelection(selectionStateRef.current, pt));
|
|
2580
|
-
else if (sel.type === "leftDrag") setSelectionState(updateSelection(selectionStateRef.current, pt));
|
|
2581
|
-
else if (sel.type === "leftUp") setSelectionState(finishSelection(selectionStateRef.current, pt));
|
|
2582
|
-
}
|
|
2507
|
+
return () => {
|
|
2508
|
+
stdout.write("\x1B[?1002l\x1B[?1006l");
|
|
2509
|
+
};
|
|
2510
|
+
}, [stdout]);
|
|
2511
|
+
useEffect3(() => {
|
|
2512
|
+
if (!stdinFilter) return;
|
|
2513
|
+
const onMouse = (e) => {
|
|
2514
|
+
if (e.kind === "scroll") {
|
|
2515
|
+
const step = Math.max(1, Math.floor(historyMaxHeightRef.current / 2));
|
|
2516
|
+
if (e.direction === "up") {
|
|
2517
|
+
setScrollOffset((prev) => Math.min(prev + step, Math.max(0, totalLinesRef.current - 1)));
|
|
2518
|
+
} else {
|
|
2519
|
+
setScrollOffset((prev) => Math.max(0, prev - step));
|
|
2583
2520
|
}
|
|
2584
|
-
|
|
2521
|
+
return;
|
|
2585
2522
|
}
|
|
2586
|
-
|
|
2587
|
-
|
|
2523
|
+
const totalL = totalLinesRef.current;
|
|
2524
|
+
const scrollOff = scrollOffsetRef.current;
|
|
2525
|
+
const histH = historyMaxHeightRef.current;
|
|
2526
|
+
const visibleCount = Math.min(Math.max(0, totalL - scrollOff), histH);
|
|
2527
|
+
const contentStartRow = histH - visibleCount;
|
|
2528
|
+
const lineIdx = e.row - contentStartRow;
|
|
2529
|
+
if (lineIdx < 0 || lineIdx >= visibleCount) return;
|
|
2530
|
+
const pt = { row: lineIdx, col: e.col };
|
|
2531
|
+
if (e.type === "leftDown") setSelectionState(startSelection(selectionStateRef.current, pt));
|
|
2532
|
+
else if (e.type === "leftDrag") setSelectionState(updateSelection(selectionStateRef.current, pt));
|
|
2533
|
+
else if (e.type === "leftUp") setSelectionState(finishSelection(selectionStateRef.current, pt));
|
|
2588
2534
|
};
|
|
2535
|
+
stdinFilter.on("mouse", onMouse);
|
|
2589
2536
|
return () => {
|
|
2590
|
-
|
|
2591
|
-
stdout.write("\x1B[?1002l\x1B[?1006l");
|
|
2537
|
+
stdinFilter.off("mouse", onMouse);
|
|
2592
2538
|
};
|
|
2593
|
-
}, [
|
|
2539
|
+
}, [stdinFilter]);
|
|
2594
2540
|
useEffect3(() => {
|
|
2595
2541
|
if (selectionState.dragging || !selectionState.anchor || !selectionState.focus) return;
|
|
2596
2542
|
const visible = messages.filter((m) => m.role !== "system");
|
|
@@ -3114,8 +3060,140 @@ function App({ config, version, autoMode = false, registry, trustedSkillDirs = [
|
|
|
3114
3060
|
)
|
|
3115
3061
|
] });
|
|
3116
3062
|
}
|
|
3063
|
+
|
|
3064
|
+
// src/ui/stdinFilter.ts
|
|
3065
|
+
import { Transform } from "stream";
|
|
3066
|
+
|
|
3067
|
+
// src/ui/mouseInput.ts
|
|
3068
|
+
var SGR_MOUSE_RE = /^\x1b\[<(\d+);\d+;\d+[Mm]/;
|
|
3069
|
+
var SGR_FULL_RE = /^\x1b\[<(\d+);(\d+);(\d+)([Mm])/;
|
|
3070
|
+
function mouseEventLength(data) {
|
|
3071
|
+
const s = typeof data === "string" ? data : data.toString("binary");
|
|
3072
|
+
if (!s) return 0;
|
|
3073
|
+
const sgrMatch = SGR_MOUSE_RE.exec(s);
|
|
3074
|
+
if (sgrMatch) return sgrMatch[0].length;
|
|
3075
|
+
if (s.length >= 6 && s.charCodeAt(0) === 27 && s[1] === "[" && s[2] === "M") return 6;
|
|
3076
|
+
return 0;
|
|
3077
|
+
}
|
|
3078
|
+
function parseMouseScroll(data) {
|
|
3079
|
+
const s = typeof data === "string" ? data : data.toString("binary");
|
|
3080
|
+
if (!s) return null;
|
|
3081
|
+
const sgrMatch = SGR_MOUSE_RE.exec(s);
|
|
3082
|
+
if (sgrMatch) {
|
|
3083
|
+
const cb = parseInt(sgrMatch[1], 10);
|
|
3084
|
+
if (cb === 64) return { direction: "up" };
|
|
3085
|
+
if (cb === 65) return { direction: "down" };
|
|
3086
|
+
return null;
|
|
3087
|
+
}
|
|
3088
|
+
if (s.length >= 6 && s.charCodeAt(0) === 27 && s[1] === "[" && s[2] === "M") {
|
|
3089
|
+
const buttonByte = s.charCodeAt(3);
|
|
3090
|
+
if (buttonByte === 96) return { direction: "up" };
|
|
3091
|
+
if (buttonByte === 97) return { direction: "down" };
|
|
3092
|
+
return null;
|
|
3093
|
+
}
|
|
3094
|
+
return null;
|
|
3095
|
+
}
|
|
3096
|
+
function parseMouseSelectionEvent(data) {
|
|
3097
|
+
const s = typeof data === "string" ? data : data.toString("binary");
|
|
3098
|
+
const m = SGR_FULL_RE.exec(s);
|
|
3099
|
+
if (!m) return null;
|
|
3100
|
+
const cb = parseInt(m[1], 10);
|
|
3101
|
+
const col = parseInt(m[2], 10) - 1;
|
|
3102
|
+
const row = parseInt(m[3], 10) - 1;
|
|
3103
|
+
const isRelease = m[4] === "m";
|
|
3104
|
+
if (isRelease && cb === 0) return { type: "leftUp", col, row };
|
|
3105
|
+
if (!isRelease && cb === 0) return { type: "leftDown", col, row };
|
|
3106
|
+
if (!isRelease && cb === 32) return { type: "leftDrag", col, row };
|
|
3107
|
+
return null;
|
|
3108
|
+
}
|
|
3109
|
+
|
|
3110
|
+
// src/ui/stdinTokenizer.ts
|
|
3111
|
+
var MAX_MOUSE_SEQ = 32;
|
|
3112
|
+
function isMousePartial(s) {
|
|
3113
|
+
if (!s.startsWith("\x1B")) return false;
|
|
3114
|
+
if (s.length === 1) return false;
|
|
3115
|
+
if (s[1] !== "[") return false;
|
|
3116
|
+
if (s.length === 2) return false;
|
|
3117
|
+
if (s[2] === "<") return true;
|
|
3118
|
+
if (s[2] === "M" && s.length < 6) return true;
|
|
3119
|
+
return false;
|
|
3120
|
+
}
|
|
3121
|
+
function tokenizeStdin(input, pendingIn) {
|
|
3122
|
+
const data = pendingIn + input;
|
|
3123
|
+
let i = 0;
|
|
3124
|
+
let keyboardOut = "";
|
|
3125
|
+
const events = [];
|
|
3126
|
+
while (i < data.length) {
|
|
3127
|
+
const ch = data[i];
|
|
3128
|
+
if (ch !== "\x1B") {
|
|
3129
|
+
keyboardOut += ch;
|
|
3130
|
+
i++;
|
|
3131
|
+
continue;
|
|
3132
|
+
}
|
|
3133
|
+
const tail = data.slice(i);
|
|
3134
|
+
const mLen = mouseEventLength(tail);
|
|
3135
|
+
if (mLen > 0) {
|
|
3136
|
+
const seq = tail.slice(0, mLen);
|
|
3137
|
+
const scroll = parseMouseScroll(seq);
|
|
3138
|
+
if (scroll) {
|
|
3139
|
+
events.push({ kind: "scroll", direction: scroll.direction });
|
|
3140
|
+
} else {
|
|
3141
|
+
const sel = parseMouseSelectionEvent(seq);
|
|
3142
|
+
if (sel) events.push({ kind: "select", type: sel.type, col: sel.col, row: sel.row });
|
|
3143
|
+
}
|
|
3144
|
+
i += mLen;
|
|
3145
|
+
continue;
|
|
3146
|
+
}
|
|
3147
|
+
if (isMousePartial(tail) && tail.length < MAX_MOUSE_SEQ) {
|
|
3148
|
+
return { keyboard: keyboardOut, pending: tail, events };
|
|
3149
|
+
}
|
|
3150
|
+
keyboardOut += ch;
|
|
3151
|
+
i++;
|
|
3152
|
+
}
|
|
3153
|
+
return { keyboard: keyboardOut, pending: "", events };
|
|
3154
|
+
}
|
|
3155
|
+
|
|
3156
|
+
// src/ui/stdinFilter.ts
|
|
3157
|
+
var StdinFilterImpl = class extends Transform {
|
|
3158
|
+
isTTY;
|
|
3159
|
+
source;
|
|
3160
|
+
pending = "";
|
|
3161
|
+
constructor(source) {
|
|
3162
|
+
super();
|
|
3163
|
+
this.source = source;
|
|
3164
|
+
this.isTTY = source.isTTY ?? false;
|
|
3165
|
+
source.pipe(this);
|
|
3166
|
+
}
|
|
3167
|
+
setRawMode(mode) {
|
|
3168
|
+
var _a, _b;
|
|
3169
|
+
(_b = (_a = this.source).setRawMode) == null ? void 0 : _b.call(_a, mode);
|
|
3170
|
+
}
|
|
3171
|
+
ref() {
|
|
3172
|
+
var _a, _b;
|
|
3173
|
+
(_b = (_a = this.source).ref) == null ? void 0 : _b.call(_a);
|
|
3174
|
+
}
|
|
3175
|
+
unref() {
|
|
3176
|
+
var _a, _b;
|
|
3177
|
+
(_b = (_a = this.source).unref) == null ? void 0 : _b.call(_a);
|
|
3178
|
+
}
|
|
3179
|
+
_transform(chunk, _encoding, callback) {
|
|
3180
|
+
const s = typeof chunk === "string" ? chunk : chunk.toString("binary");
|
|
3181
|
+
const { keyboard, pending, events } = tokenizeStdin(s, this.pending);
|
|
3182
|
+
this.pending = pending;
|
|
3183
|
+
for (const ev of events) this.emit("mouse", ev);
|
|
3184
|
+
if (keyboard.length > 0) {
|
|
3185
|
+
callback(null, Buffer.from(keyboard, "binary"));
|
|
3186
|
+
} else {
|
|
3187
|
+
callback();
|
|
3188
|
+
}
|
|
3189
|
+
}
|
|
3190
|
+
};
|
|
3191
|
+
function createStdinFilter(source) {
|
|
3192
|
+
return new StdinFilterImpl(source);
|
|
3193
|
+
}
|
|
3117
3194
|
export {
|
|
3118
3195
|
App,
|
|
3119
3196
|
default2 as React,
|
|
3197
|
+
createStdinFilter,
|
|
3120
3198
|
render
|
|
3121
3199
|
};
|