dskcode 0.1.36 → 0.1.37
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 +623 -599
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -805,9 +805,9 @@ var LOGO_LINES = [
|
|
|
805
805
|
];
|
|
806
806
|
|
|
807
807
|
// src/ui/ChatSession.tsx
|
|
808
|
-
import { Box as
|
|
808
|
+
import { Box as Box11, Text as Text12, useInput, Static } from "ink";
|
|
809
809
|
import TextInput from "ink-text-input";
|
|
810
|
-
import { useEffect as
|
|
810
|
+
import { useEffect as useEffect5, useState as useState5, useCallback as useCallback2, useMemo, useRef as useRef4 } from "react";
|
|
811
811
|
|
|
812
812
|
// src/ui/useDoubleCtrlC.ts
|
|
813
813
|
import { useState as useState2, useCallback, useEffect as useEffect2, useRef } from "react";
|
|
@@ -1192,89 +1192,6 @@ function ToolCallBlock({ call }) {
|
|
|
1192
1192
|
] });
|
|
1193
1193
|
}
|
|
1194
1194
|
|
|
1195
|
-
// src/agent/message-builder.ts
|
|
1196
|
-
function estimateMessageTokens(msg) {
|
|
1197
|
-
let text = msg.content;
|
|
1198
|
-
if (msg.toolCalls) {
|
|
1199
|
-
for (const tc of msg.toolCalls) {
|
|
1200
|
-
text += tc.name + tc.arguments;
|
|
1201
|
-
}
|
|
1202
|
-
}
|
|
1203
|
-
return estimateTokens(text) + 10;
|
|
1204
|
-
}
|
|
1205
|
-
function groupIntoTurns(messages) {
|
|
1206
|
-
const turns = [];
|
|
1207
|
-
let current = null;
|
|
1208
|
-
for (const msg of messages) {
|
|
1209
|
-
if (msg.role === "user") {
|
|
1210
|
-
if (current) turns.push(current);
|
|
1211
|
-
current = [msg];
|
|
1212
|
-
} else {
|
|
1213
|
-
if (!current) current = [];
|
|
1214
|
-
current.push(msg);
|
|
1215
|
-
}
|
|
1216
|
-
}
|
|
1217
|
-
if (current && current.length > 0) turns.push(current);
|
|
1218
|
-
return turns;
|
|
1219
|
-
}
|
|
1220
|
-
function estimateTurnTokens(turn) {
|
|
1221
|
-
let sum = 0;
|
|
1222
|
-
for (const msg of turn) sum += estimateMessageTokens(msg);
|
|
1223
|
-
return sum;
|
|
1224
|
-
}
|
|
1225
|
-
function trimMessages(messages, opts) {
|
|
1226
|
-
const meta = getModelMeta(opts.model);
|
|
1227
|
-
const maxInputTokens = meta.contextWindow - opts.reservedForOutput;
|
|
1228
|
-
const systemTokens = estimateTokens(opts.systemPrompt);
|
|
1229
|
-
let remaining = maxInputTokens - systemTokens;
|
|
1230
|
-
const turns = groupIntoTurns(messages);
|
|
1231
|
-
const preservedTurns = [];
|
|
1232
|
-
let roundsPreserved = 0;
|
|
1233
|
-
for (let i = turns.length - 1; i >= 0 && roundsPreserved < opts.preserveRecentRounds; i--) {
|
|
1234
|
-
preservedTurns.unshift(turns[i]);
|
|
1235
|
-
roundsPreserved++;
|
|
1236
|
-
}
|
|
1237
|
-
const preserved = preservedTurns.flat();
|
|
1238
|
-
for (const msg of preserved) {
|
|
1239
|
-
remaining -= estimateMessageTokens(msg);
|
|
1240
|
-
}
|
|
1241
|
-
if (remaining < 0) {
|
|
1242
|
-
while (preservedTurns.length > 1 && remaining < 0) {
|
|
1243
|
-
const dropped = preservedTurns.shift();
|
|
1244
|
-
remaining += estimateTurnTokens(dropped);
|
|
1245
|
-
}
|
|
1246
|
-
return [preservedTurns.flat(), true];
|
|
1247
|
-
}
|
|
1248
|
-
const olderTurns = turns.slice(0, turns.length - preservedTurns.length);
|
|
1249
|
-
const keptTurns = [];
|
|
1250
|
-
for (let i = olderTurns.length - 1; i >= 0; i--) {
|
|
1251
|
-
const cost = estimateTurnTokens(olderTurns[i]);
|
|
1252
|
-
if (remaining - cost < 0) break;
|
|
1253
|
-
remaining -= cost;
|
|
1254
|
-
keptTurns.unshift(olderTurns[i]);
|
|
1255
|
-
}
|
|
1256
|
-
const result = [...keptTurns, ...preservedTurns].flat();
|
|
1257
|
-
const trimmed = result.length < messages.length;
|
|
1258
|
-
return [result, trimmed];
|
|
1259
|
-
}
|
|
1260
|
-
function buildApiMessages(systemPrompt, history) {
|
|
1261
|
-
return [
|
|
1262
|
-
{ role: "system", content: systemPrompt },
|
|
1263
|
-
...history
|
|
1264
|
-
];
|
|
1265
|
-
}
|
|
1266
|
-
function formatUsageSummary(usage) {
|
|
1267
|
-
const prompt = usage.promptTokens.toLocaleString();
|
|
1268
|
-
const completion = usage.completionTokens.toLocaleString();
|
|
1269
|
-
const total = (usage.promptTokens + usage.completionTokens).toLocaleString();
|
|
1270
|
-
let summary = `\u{1F4E5} ${prompt} + \u{1F4E4} ${completion} = \u{1F4E6} ${total} tokens`;
|
|
1271
|
-
if (usage.cachedPromptTokens && usage.cachedPromptTokens > 0) {
|
|
1272
|
-
const cacheRate = (usage.cachedPromptTokens / usage.promptTokens * 100).toFixed(1);
|
|
1273
|
-
summary += ` \u2502 \u{1F5C4}\uFE0F \u7F13\u5B58\u547D\u4E2D ${cacheRate}%`;
|
|
1274
|
-
}
|
|
1275
|
-
return summary;
|
|
1276
|
-
}
|
|
1277
|
-
|
|
1278
1195
|
// src/ui/HighlightedText.tsx
|
|
1279
1196
|
import { Box as Box4, Text as Text5 } from "ink";
|
|
1280
1197
|
|
|
@@ -1801,23 +1718,6 @@ function HighlightedText({ children: text }) {
|
|
|
1801
1718
|
return /* @__PURE__ */ jsx4(Box4, { flexDirection: "column", children: rendered });
|
|
1802
1719
|
}
|
|
1803
1720
|
|
|
1804
|
-
// src/ui/reasoning-utils.ts
|
|
1805
|
-
var DEFAULT_REASONING_MAX_LINES = 8;
|
|
1806
|
-
function joinReasoningSegments(segments) {
|
|
1807
|
-
return segments.map((s) => s.trim()).filter((s) => s.length > 0).join("\n");
|
|
1808
|
-
}
|
|
1809
|
-
function truncateReasoningLines(text, maxLines) {
|
|
1810
|
-
const lines = text.split("\n");
|
|
1811
|
-
if (lines.length <= maxLines) {
|
|
1812
|
-
return { visible: text, hiddenLines: 0, totalLines: lines.length };
|
|
1813
|
-
}
|
|
1814
|
-
return {
|
|
1815
|
-
visible: lines.slice(-maxLines).join("\n"),
|
|
1816
|
-
hiddenLines: lines.length - maxLines,
|
|
1817
|
-
totalLines: lines.length
|
|
1818
|
-
};
|
|
1819
|
-
}
|
|
1820
|
-
|
|
1821
1721
|
// src/ui/AssistantMessage.tsx
|
|
1822
1722
|
import { Fragment, jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1823
1723
|
function formatElapsed(ms) {
|
|
@@ -1902,7 +1802,6 @@ function AnimatedUsage({ usage, cost }) {
|
|
|
1902
1802
|
}
|
|
1903
1803
|
function AssistantMessage({
|
|
1904
1804
|
content,
|
|
1905
|
-
reasoning,
|
|
1906
1805
|
toolCalls,
|
|
1907
1806
|
isStreaming = false,
|
|
1908
1807
|
usage,
|
|
@@ -1910,57 +1809,41 @@ function AssistantMessage({
|
|
|
1910
1809
|
cost,
|
|
1911
1810
|
model: _model
|
|
1912
1811
|
}) {
|
|
1913
|
-
if (!content && (!toolCalls || toolCalls.length === 0) &&
|
|
1812
|
+
if (!content && (!toolCalls || toolCalls.length === 0) && !isStreaming) {
|
|
1914
1813
|
return null;
|
|
1915
1814
|
}
|
|
1916
|
-
return /* @__PURE__ */ jsxs5(Box5, { flexDirection: "
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
isStreaming && (usage || cost !== void 0) && /* @__PURE__ */ jsx5(Box5, { flexDirection: "row", marginTop: 1, marginLeft: 3, children: /* @__PURE__ */ jsxs5(Text6, { color: "#666666", dimColor: true, children: [
|
|
1949
|
-
"\u23F3 \u5DF2\u6D88\u8017 ",
|
|
1950
|
-
/* @__PURE__ */ jsx5(AnimatedUsage, { usage, cost })
|
|
1951
|
-
] }) }),
|
|
1952
|
-
!isStreaming && (usage || elapsed !== void 0) && /* @__PURE__ */ jsxs5(Box5, { flexDirection: "column", marginTop: 1, marginLeft: 3, children: [
|
|
1953
|
-
/* @__PURE__ */ jsx5(Text6, { color: "#555555", children: "\u2500".repeat(36) }),
|
|
1954
|
-
/* @__PURE__ */ jsxs5(Box5, { flexDirection: "row", gap: 2, children: [
|
|
1955
|
-
cost !== void 0 && cost > 0 && /* @__PURE__ */ jsxs5(Text6, { color: "yellow", children: [
|
|
1956
|
-
"\u{1F4B0} \u672C\u6B21 ",
|
|
1957
|
-
formatMoney(cost)
|
|
1958
|
-
] }),
|
|
1959
|
-
elapsed !== void 0 && /* @__PURE__ */ jsxs5(Text6, { color: "cyan", children: [
|
|
1960
|
-
"\u{1F550} ",
|
|
1961
|
-
formatElapsed(elapsed)
|
|
1962
|
-
] }),
|
|
1963
|
-
usage && /* @__PURE__ */ jsx5(Text6, { color: "#888888", children: formatUsageSummary(usage) })
|
|
1815
|
+
return /* @__PURE__ */ jsxs5(Box5, { flexDirection: "row", marginTop: 1, children: [
|
|
1816
|
+
/* @__PURE__ */ jsx5(Box5, { width: 1, backgroundColor: "#E040FB", flexShrink: 0 }),
|
|
1817
|
+
/* @__PURE__ */ jsxs5(Box5, { flexGrow: 1, paddingLeft: 1, flexDirection: "column", children: [
|
|
1818
|
+
/* @__PURE__ */ jsxs5(Box5, { flexDirection: "row", children: [
|
|
1819
|
+
/* @__PURE__ */ jsx5(Box5, { width: 4, flexShrink: 0, children: /* @__PURE__ */ jsx5(Text6, { bold: true, color: "#ff00ff", children: "\u{1F916}" }) }),
|
|
1820
|
+
/* @__PURE__ */ jsxs5(Box5, { flexGrow: 1, flexDirection: "column", children: [
|
|
1821
|
+
content && /* @__PURE__ */ jsx5(HighlightedText, { children: content }),
|
|
1822
|
+
isStreaming && !content && /* @__PURE__ */ jsx5(Text6, { color: "#888888", children: "..." })
|
|
1823
|
+
] })
|
|
1824
|
+
] }),
|
|
1825
|
+
toolCalls && toolCalls.length > 0 && /* @__PURE__ */ jsx5(Box5, { flexDirection: "column", children: toolCalls.map((tc, i) => /* @__PURE__ */ jsx5(ToolCallBlock, { call: tc }, tc.id ?? i)) }),
|
|
1826
|
+
isStreaming && (usage || cost !== void 0) && /* @__PURE__ */ jsx5(Box5, { flexDirection: "row", marginTop: 1, marginLeft: 3, children: /* @__PURE__ */ jsxs5(Text6, { color: "#666666", dimColor: true, children: [
|
|
1827
|
+
"\u23F3 \u5DF2\u6D88\u8017 ",
|
|
1828
|
+
/* @__PURE__ */ jsx5(AnimatedUsage, { usage, cost })
|
|
1829
|
+
] }) }),
|
|
1830
|
+
!isStreaming && (usage || elapsed !== void 0) && /* @__PURE__ */ jsxs5(Box5, { flexDirection: "column", marginTop: 1, marginLeft: 3, children: [
|
|
1831
|
+
/* @__PURE__ */ jsx5(Text6, { color: "#555555", children: "\u2500".repeat(36) }),
|
|
1832
|
+
/* @__PURE__ */ jsxs5(Box5, { flexDirection: "row", gap: 2, children: [
|
|
1833
|
+
cost !== void 0 && cost > 0 && /* @__PURE__ */ jsxs5(Text6, { color: "yellow", children: [
|
|
1834
|
+
"\u{1F4B0} \u672C\u6B21 ",
|
|
1835
|
+
formatMoney(cost)
|
|
1836
|
+
] }),
|
|
1837
|
+
elapsed !== void 0 && /* @__PURE__ */ jsxs5(Text6, { color: "cyan", children: [
|
|
1838
|
+
"\u{1F550} ",
|
|
1839
|
+
formatElapsed(elapsed)
|
|
1840
|
+
] }),
|
|
1841
|
+
usage && /* @__PURE__ */ jsxs5(Text6, { color: "#888888", children: [
|
|
1842
|
+
"\u{1F4E6} ",
|
|
1843
|
+
(usage.promptTokens + usage.completionTokens).toLocaleString(),
|
|
1844
|
+
" tokens"
|
|
1845
|
+
] })
|
|
1846
|
+
] })
|
|
1964
1847
|
] })
|
|
1965
1848
|
] })
|
|
1966
1849
|
] });
|
|
@@ -2101,7 +1984,7 @@ function TodoListPanel({ items }) {
|
|
|
2101
1984
|
// package.json
|
|
2102
1985
|
var package_default = {
|
|
2103
1986
|
name: "dskcode",
|
|
2104
|
-
version: "0.1.
|
|
1987
|
+
version: "0.1.37",
|
|
2105
1988
|
repository: {
|
|
2106
1989
|
type: "git",
|
|
2107
1990
|
url: "git+https://github.com/Awu12277/deepseek-agent-cli/tree/main"
|
|
@@ -2312,6 +2195,78 @@ function buildPlanSystemPrompt(opts) {
|
|
|
2312
2195
|
return compiledPlanTemplate(buildTemplateVars(opts));
|
|
2313
2196
|
}
|
|
2314
2197
|
|
|
2198
|
+
// src/agent/message-builder.ts
|
|
2199
|
+
function estimateMessageTokens(msg) {
|
|
2200
|
+
let text = msg.content;
|
|
2201
|
+
if (msg.toolCalls) {
|
|
2202
|
+
for (const tc of msg.toolCalls) {
|
|
2203
|
+
text += tc.name + tc.arguments;
|
|
2204
|
+
}
|
|
2205
|
+
}
|
|
2206
|
+
return estimateTokens(text) + 10;
|
|
2207
|
+
}
|
|
2208
|
+
function groupIntoTurns(messages) {
|
|
2209
|
+
const turns = [];
|
|
2210
|
+
let current = null;
|
|
2211
|
+
for (const msg of messages) {
|
|
2212
|
+
if (msg.role === "user") {
|
|
2213
|
+
if (current) turns.push(current);
|
|
2214
|
+
current = [msg];
|
|
2215
|
+
} else {
|
|
2216
|
+
if (!current) current = [];
|
|
2217
|
+
current.push(msg);
|
|
2218
|
+
}
|
|
2219
|
+
}
|
|
2220
|
+
if (current && current.length > 0) turns.push(current);
|
|
2221
|
+
return turns;
|
|
2222
|
+
}
|
|
2223
|
+
function estimateTurnTokens(turn) {
|
|
2224
|
+
let sum = 0;
|
|
2225
|
+
for (const msg of turn) sum += estimateMessageTokens(msg);
|
|
2226
|
+
return sum;
|
|
2227
|
+
}
|
|
2228
|
+
function trimMessages(messages, opts) {
|
|
2229
|
+
const meta = getModelMeta(opts.model);
|
|
2230
|
+
const maxInputTokens = meta.contextWindow - opts.reservedForOutput;
|
|
2231
|
+
const systemTokens = estimateTokens(opts.systemPrompt);
|
|
2232
|
+
let remaining = maxInputTokens - systemTokens;
|
|
2233
|
+
const turns = groupIntoTurns(messages);
|
|
2234
|
+
const preservedTurns = [];
|
|
2235
|
+
let roundsPreserved = 0;
|
|
2236
|
+
for (let i = turns.length - 1; i >= 0 && roundsPreserved < opts.preserveRecentRounds; i--) {
|
|
2237
|
+
preservedTurns.unshift(turns[i]);
|
|
2238
|
+
roundsPreserved++;
|
|
2239
|
+
}
|
|
2240
|
+
const preserved = preservedTurns.flat();
|
|
2241
|
+
for (const msg of preserved) {
|
|
2242
|
+
remaining -= estimateMessageTokens(msg);
|
|
2243
|
+
}
|
|
2244
|
+
if (remaining < 0) {
|
|
2245
|
+
while (preservedTurns.length > 1 && remaining < 0) {
|
|
2246
|
+
const dropped = preservedTurns.shift();
|
|
2247
|
+
remaining += estimateTurnTokens(dropped);
|
|
2248
|
+
}
|
|
2249
|
+
return [preservedTurns.flat(), true];
|
|
2250
|
+
}
|
|
2251
|
+
const olderTurns = turns.slice(0, turns.length - preservedTurns.length);
|
|
2252
|
+
const keptTurns = [];
|
|
2253
|
+
for (let i = olderTurns.length - 1; i >= 0; i--) {
|
|
2254
|
+
const cost = estimateTurnTokens(olderTurns[i]);
|
|
2255
|
+
if (remaining - cost < 0) break;
|
|
2256
|
+
remaining -= cost;
|
|
2257
|
+
keptTurns.unshift(olderTurns[i]);
|
|
2258
|
+
}
|
|
2259
|
+
const result = [...keptTurns, ...preservedTurns].flat();
|
|
2260
|
+
const trimmed = result.length < messages.length;
|
|
2261
|
+
return [result, trimmed];
|
|
2262
|
+
}
|
|
2263
|
+
function buildApiMessages(systemPrompt, history) {
|
|
2264
|
+
return [
|
|
2265
|
+
{ role: "system", content: systemPrompt },
|
|
2266
|
+
...history
|
|
2267
|
+
];
|
|
2268
|
+
}
|
|
2269
|
+
|
|
2315
2270
|
// src/tool/registry.ts
|
|
2316
2271
|
var ToolRegistry = class {
|
|
2317
2272
|
#tools = /* @__PURE__ */ new Map();
|
|
@@ -5952,10 +5907,53 @@ function getGradientColors(text, phase, stops) {
|
|
|
5952
5907
|
});
|
|
5953
5908
|
}
|
|
5954
5909
|
|
|
5910
|
+
// src/ui/reasoning-utils.ts
|
|
5911
|
+
function joinReasoningSegments(segments) {
|
|
5912
|
+
return segments.map((s) => s.trim()).filter((s) => s.length > 0).join("\n");
|
|
5913
|
+
}
|
|
5914
|
+
|
|
5915
|
+
// src/ui/AnimatedLogo.tsx
|
|
5916
|
+
import { Box as Box10, Text as Text11 } from "ink";
|
|
5917
|
+
import { useEffect as useEffect4, useRef as useRef3, useState as useState4 } from "react";
|
|
5918
|
+
import { jsx as jsx10, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
5919
|
+
var LOGO_LINES2 = [
|
|
5920
|
+
" \u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2584 \u2584\u2584",
|
|
5921
|
+
" \u2584\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584\u2584\u2580\u2588\u2588\u2588\u2580\u2580",
|
|
5922
|
+
"\u2580\u2588 \u2580\u2580\u2588\u2588\u2588\u2584 \u2588\u2588\u2588\u2588",
|
|
5923
|
+
" \u2580\u2588\u2584 \u2584 \u2580\u2588\u2588\u2588\u2588\u2588\u2580",
|
|
5924
|
+
" \u2580\u2580\u2580\u2588\u2588\u2588\u2588\u2588\u2584\u2580\u2580\u2580\u2580\u2580"
|
|
5925
|
+
];
|
|
5926
|
+
var LOGO_WIDTH = 22;
|
|
5927
|
+
var MOVE_INTERVAL_MS = 120;
|
|
5928
|
+
var LOGO_COLOR = "#6185f6";
|
|
5929
|
+
function AnimatedLogo({ panelWidth }) {
|
|
5930
|
+
const posRef = useRef3(panelWidth);
|
|
5931
|
+
const [renderTick, setRenderTick] = useState4(0);
|
|
5932
|
+
useEffect4(() => {
|
|
5933
|
+
const timer = setInterval(() => {
|
|
5934
|
+
posRef.current -= 1;
|
|
5935
|
+
if (posRef.current <= -LOGO_WIDTH) {
|
|
5936
|
+
posRef.current = panelWidth;
|
|
5937
|
+
}
|
|
5938
|
+
setRenderTick((t) => t + 1);
|
|
5939
|
+
}, MOVE_INTERVAL_MS);
|
|
5940
|
+
return () => clearInterval(timer);
|
|
5941
|
+
}, [panelWidth]);
|
|
5942
|
+
const pos = posRef.current;
|
|
5943
|
+
if (pos >= panelWidth) return null;
|
|
5944
|
+
const leftClip = Math.max(0, -pos);
|
|
5945
|
+
const rightClip = Math.max(0, pos + LOGO_WIDTH - panelWidth);
|
|
5946
|
+
const padding = Math.max(0, pos);
|
|
5947
|
+
return /* @__PURE__ */ jsx10(Box10, { flexDirection: "column", alignItems: "flex-start", children: LOGO_LINES2.map((line, i) => /* @__PURE__ */ jsxs10(Text11, { color: LOGO_COLOR, bold: true, children: [
|
|
5948
|
+
" ".repeat(padding),
|
|
5949
|
+
line.slice(leftClip, LOGO_WIDTH - rightClip)
|
|
5950
|
+
] }, i)) });
|
|
5951
|
+
}
|
|
5952
|
+
|
|
5955
5953
|
// src/ui/ChatSession.tsx
|
|
5956
|
-
import { Fragment as Fragment2, jsx as
|
|
5954
|
+
import { Fragment as Fragment2, jsx as jsx11, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
5957
5955
|
var PHASE_CONFIG = {
|
|
5958
|
-
thinking: { icon: "\u{1F9E0}", label: "\
|
|
5956
|
+
thinking: { icon: "\u{1F9E0}", label: "\u601D\u8003\u4E2D", color: "#ff9800" },
|
|
5959
5957
|
generating: { icon: "\u2728", label: "\u751F\u6210\u4E2D", color: "#00ff41" },
|
|
5960
5958
|
calling_tools: { icon: "\u{1F6E0}", label: "\u8C03\u7528\u5DE5\u5177", color: "#f59e0b" },
|
|
5961
5959
|
executing_tools: { icon: "\u26A1", label: "\u6267\u884C\u5DE5\u5177", color: "#00ffff" }
|
|
@@ -6061,42 +6059,44 @@ function ChatSession({
|
|
|
6061
6059
|
onLaunchStock
|
|
6062
6060
|
}) {
|
|
6063
6061
|
const termWidth = typeof process.stdout.columns === "number" ? process.stdout.columns : 80;
|
|
6064
|
-
const
|
|
6065
|
-
const
|
|
6066
|
-
const
|
|
6067
|
-
const [
|
|
6068
|
-
const [
|
|
6069
|
-
const [
|
|
6070
|
-
const [
|
|
6071
|
-
const [
|
|
6072
|
-
const [
|
|
6073
|
-
const [
|
|
6074
|
-
const [
|
|
6075
|
-
const [
|
|
6062
|
+
const contentAreaWidth = termWidth - 2;
|
|
6063
|
+
const leftPanelWidth = Math.max(Math.floor(contentAreaWidth / 3), 30);
|
|
6064
|
+
const rightContentWidth = contentAreaWidth - leftPanelWidth - 1;
|
|
6065
|
+
const [offset, setOffset] = useState5(0);
|
|
6066
|
+
const [displayMessages, setDisplayMessages] = useState5([]);
|
|
6067
|
+
const [staticKey, setStaticKey] = useState5(0);
|
|
6068
|
+
const [input, setInput] = useState5("");
|
|
6069
|
+
const [balance, setBalance] = useState5(null);
|
|
6070
|
+
const [balanceLoading, setBalanceLoading] = useState5(false);
|
|
6071
|
+
const [todayCost, setTodayCost] = useState5(null);
|
|
6072
|
+
const [isStreaming, setIsStreaming] = useState5(false);
|
|
6073
|
+
const [streamingPhase, setStreamingPhase] = useState5(null);
|
|
6074
|
+
const [streamingPlaceholder, setStreamingPlaceholder] = useState5("");
|
|
6075
|
+
const [idlePlaceholder, setIdlePlaceholder] = useState5(
|
|
6076
6076
|
() => pickRandom(IDLE_PLACEHOLDERS)
|
|
6077
6077
|
);
|
|
6078
|
-
const [gradientColors, setGradientColors] =
|
|
6079
|
-
const gradientPhaseRef =
|
|
6080
|
-
const [streamingGradientColors, setStreamingGradientColors] =
|
|
6081
|
-
const streamingPhaseRef =
|
|
6082
|
-
const [currentContent, setCurrentContent] =
|
|
6083
|
-
const [currentReasoning, setCurrentReasoning] =
|
|
6084
|
-
const [currentToolCalls, setCurrentToolCalls] =
|
|
6085
|
-
const [_currentUsage, setCurrentUsage] =
|
|
6086
|
-
const [_currentElapsed, setCurrentElapsed] =
|
|
6087
|
-
const [_currentCost, setCurrentCost] =
|
|
6088
|
-
const [activeModel, setActiveModel] =
|
|
6089
|
-
const [_streamingModel, setStreamingModel] =
|
|
6090
|
-
const [streamError, setStreamError] =
|
|
6091
|
-
const [todoSnapshot, setTodoSnapshot] =
|
|
6092
|
-
const [todoPanelVisible, setTodoPanelVisible] =
|
|
6093
|
-
const todoHideTimerRef =
|
|
6094
|
-
const lastDoneBatchMaxIdRef =
|
|
6095
|
-
const [sessionMode, setSessionMode] =
|
|
6096
|
-
const [thinkingEnabled, setThinkingEnabled] =
|
|
6097
|
-
const [thinkingEffort, setThinkingEffort] =
|
|
6098
|
-
const [responseFormat] =
|
|
6099
|
-
const [toolChoice, setToolChoice] =
|
|
6078
|
+
const [gradientColors, setGradientColors] = useState5([]);
|
|
6079
|
+
const gradientPhaseRef = useRef4(0);
|
|
6080
|
+
const [streamingGradientColors, setStreamingGradientColors] = useState5([]);
|
|
6081
|
+
const streamingPhaseRef = useRef4(0);
|
|
6082
|
+
const [currentContent, setCurrentContent] = useState5("");
|
|
6083
|
+
const [currentReasoning, setCurrentReasoning] = useState5([]);
|
|
6084
|
+
const [currentToolCalls, setCurrentToolCalls] = useState5([]);
|
|
6085
|
+
const [_currentUsage, setCurrentUsage] = useState5(void 0);
|
|
6086
|
+
const [_currentElapsed, setCurrentElapsed] = useState5(void 0);
|
|
6087
|
+
const [_currentCost, setCurrentCost] = useState5(void 0);
|
|
6088
|
+
const [activeModel, setActiveModel] = useState5(model);
|
|
6089
|
+
const [_streamingModel, setStreamingModel] = useState5(void 0);
|
|
6090
|
+
const [streamError, setStreamError] = useState5(void 0);
|
|
6091
|
+
const [todoSnapshot, setTodoSnapshot] = useState5([]);
|
|
6092
|
+
const [todoPanelVisible, setTodoPanelVisible] = useState5(true);
|
|
6093
|
+
const todoHideTimerRef = useRef4(null);
|
|
6094
|
+
const lastDoneBatchMaxIdRef = useRef4(-1);
|
|
6095
|
+
const [sessionMode, setSessionMode] = useState5("code");
|
|
6096
|
+
const [thinkingEnabled, setThinkingEnabled] = useState5(true);
|
|
6097
|
+
const [thinkingEffort, setThinkingEffort] = useState5("high");
|
|
6098
|
+
const [responseFormat] = useState5("text");
|
|
6099
|
+
const [toolChoice, setToolChoice] = useState5(
|
|
6100
6100
|
void 0
|
|
6101
6101
|
);
|
|
6102
6102
|
const sessionCost = useMemo(() => {
|
|
@@ -6108,40 +6108,41 @@ function ChatSession({
|
|
|
6108
6108
|
}, 0);
|
|
6109
6109
|
}, [displayMessages]);
|
|
6110
6110
|
const hasConversationStarted = displayMessages.length > 0;
|
|
6111
|
+
const hasReasoningPanel = isStreaming && currentReasoning.length > 0;
|
|
6111
6112
|
const cmdTips = Array.from(getRegisteredCommands()).filter(([name]) => name !== "/exit" && name !== "/quit").map(([name, cmd]) => ({ name, desc: cmd.desc }));
|
|
6112
|
-
const [cmdTipIndex, setCmdTipIndex] =
|
|
6113
|
-
const [cmdTipGradientColors, setCmdTipGradientColors] =
|
|
6114
|
-
const cmdTipPhaseRef =
|
|
6115
|
-
const [skillSelectIndex, setSkillSelectIndex] =
|
|
6116
|
-
const [fileSelectIndex, setFileSelectIndex] =
|
|
6117
|
-
const [inputKey, setInputKey] =
|
|
6118
|
-
const [rewindSelecting, setRewindSelecting] =
|
|
6119
|
-
const [rewindSelectIndex, setRewindSelectIndex] =
|
|
6120
|
-
const [rewindList, setRewindList] =
|
|
6121
|
-
const [rewinding, setRewinding] =
|
|
6122
|
-
const [rewindHintPhase, setRewindHintPhase] =
|
|
6113
|
+
const [cmdTipIndex, setCmdTipIndex] = useState5(0);
|
|
6114
|
+
const [cmdTipGradientColors, setCmdTipGradientColors] = useState5([]);
|
|
6115
|
+
const cmdTipPhaseRef = useRef4(0);
|
|
6116
|
+
const [skillSelectIndex, setSkillSelectIndex] = useState5(0);
|
|
6117
|
+
const [fileSelectIndex, setFileSelectIndex] = useState5(0);
|
|
6118
|
+
const [inputKey, setInputKey] = useState5(0);
|
|
6119
|
+
const [rewindSelecting, setRewindSelecting] = useState5(false);
|
|
6120
|
+
const [rewindSelectIndex, setRewindSelectIndex] = useState5(0);
|
|
6121
|
+
const [rewindList, setRewindList] = useState5([]);
|
|
6122
|
+
const [rewinding, setRewinding] = useState5(false);
|
|
6123
|
+
const [rewindHintPhase, setRewindHintPhase] = useState5(
|
|
6123
6124
|
"idle"
|
|
6124
6125
|
);
|
|
6125
|
-
const currentRoundModifiedRef =
|
|
6126
|
-
const rewindHintTimerRef =
|
|
6127
|
-
const [selectingModel, setSelectingModel] =
|
|
6128
|
-
const [modelSelectIndex, setModelSelectIndex] =
|
|
6126
|
+
const currentRoundModifiedRef = useRef4(false);
|
|
6127
|
+
const rewindHintTimerRef = useRef4(null);
|
|
6128
|
+
const [selectingModel, setSelectingModel] = useState5(false);
|
|
6129
|
+
const [modelSelectIndex, setModelSelectIndex] = useState5(0);
|
|
6129
6130
|
const modelOptions = ["deepseek-v4-flash", "deepseek-v4-pro"];
|
|
6130
|
-
const sessionRef =
|
|
6131
|
-
const abortRef =
|
|
6132
|
-
const currentContentRef =
|
|
6133
|
-
const currentReasoningRef =
|
|
6134
|
-
const currentToolCallsRef =
|
|
6135
|
-
const currentUsageRef =
|
|
6136
|
-
const currentElapsedRef =
|
|
6137
|
-
const currentCostRef =
|
|
6138
|
-
const currentModelRef =
|
|
6139
|
-
const streamErrorRef =
|
|
6140
|
-
|
|
6131
|
+
const sessionRef = useRef4(null);
|
|
6132
|
+
const abortRef = useRef4(null);
|
|
6133
|
+
const currentContentRef = useRef4("");
|
|
6134
|
+
const currentReasoningRef = useRef4([]);
|
|
6135
|
+
const currentToolCallsRef = useRef4([]);
|
|
6136
|
+
const currentUsageRef = useRef4(void 0);
|
|
6137
|
+
const currentElapsedRef = useRef4(void 0);
|
|
6138
|
+
const currentCostRef = useRef4(void 0);
|
|
6139
|
+
const currentModelRef = useRef4(void 0);
|
|
6140
|
+
const streamErrorRef = useRef4(void 0);
|
|
6141
|
+
useEffect5(() => {
|
|
6141
6142
|
setSkillSelectIndex(0);
|
|
6142
6143
|
setFileSelectIndex(0);
|
|
6143
6144
|
}, [input]);
|
|
6144
|
-
|
|
6145
|
+
useEffect5(() => {
|
|
6145
6146
|
return () => {
|
|
6146
6147
|
if (rewindHintTimerRef.current) {
|
|
6147
6148
|
clearTimeout(rewindHintTimerRef.current);
|
|
@@ -6149,7 +6150,7 @@ function ChatSession({
|
|
|
6149
6150
|
}
|
|
6150
6151
|
};
|
|
6151
6152
|
}, []);
|
|
6152
|
-
|
|
6153
|
+
useEffect5(() => {
|
|
6153
6154
|
if (todoHideTimerRef.current) {
|
|
6154
6155
|
clearTimeout(todoHideTimerRef.current);
|
|
6155
6156
|
todoHideTimerRef.current = null;
|
|
@@ -6435,14 +6436,14 @@ function ChatSession({
|
|
|
6435
6436
|
]
|
|
6436
6437
|
)
|
|
6437
6438
|
);
|
|
6438
|
-
|
|
6439
|
+
useEffect5(() => {
|
|
6439
6440
|
if (cmdTips.length <= 1) return;
|
|
6440
6441
|
const timer = setInterval(() => {
|
|
6441
6442
|
setCmdTipIndex((prev) => (prev + 1) % cmdTips.length);
|
|
6442
6443
|
}, 2e3);
|
|
6443
6444
|
return () => clearInterval(timer);
|
|
6444
6445
|
}, [cmdTips.length]);
|
|
6445
|
-
|
|
6446
|
+
useEffect5(() => {
|
|
6446
6447
|
const tip = cmdTips[cmdTipIndex % cmdTips.length];
|
|
6447
6448
|
if (!tip) {
|
|
6448
6449
|
setCmdTipGradientColors([]);
|
|
@@ -6459,13 +6460,13 @@ function ChatSession({
|
|
|
6459
6460
|
}, GRADIENT_ANIMATION.cmdTipInterval);
|
|
6460
6461
|
return () => clearInterval(interval);
|
|
6461
6462
|
}, [cmdTipIndex, cmdTips.length]);
|
|
6462
|
-
|
|
6463
|
+
useEffect5(() => {
|
|
6463
6464
|
const timer = setInterval(() => {
|
|
6464
6465
|
setOffset((prev) => (prev + 1) % CYBER_PALETTE.length);
|
|
6465
6466
|
}, 500);
|
|
6466
6467
|
return () => clearInterval(timer);
|
|
6467
6468
|
}, []);
|
|
6468
|
-
|
|
6469
|
+
useEffect5(() => {
|
|
6469
6470
|
if (!apiKey || !baseUrl) return;
|
|
6470
6471
|
const provider = createProvider({
|
|
6471
6472
|
name: "deepseek",
|
|
@@ -6484,7 +6485,7 @@ function ChatSession({
|
|
|
6484
6485
|
sessionRef.current = null;
|
|
6485
6486
|
};
|
|
6486
6487
|
}, [apiKey, baseUrl, activeModel, externalCostTracker]);
|
|
6487
|
-
|
|
6488
|
+
useEffect5(() => {
|
|
6488
6489
|
if (!apiKey || !baseUrl) return;
|
|
6489
6490
|
let cancelled = false;
|
|
6490
6491
|
setBalanceLoading(true);
|
|
@@ -6509,7 +6510,7 @@ function ChatSession({
|
|
|
6509
6510
|
cancelled = true;
|
|
6510
6511
|
};
|
|
6511
6512
|
}, [apiKey, baseUrl]);
|
|
6512
|
-
|
|
6513
|
+
useEffect5(() => {
|
|
6513
6514
|
if (!externalCostTracker) return;
|
|
6514
6515
|
let cancelled = false;
|
|
6515
6516
|
let timer;
|
|
@@ -6527,7 +6528,7 @@ function ChatSession({
|
|
|
6527
6528
|
if (timer) clearInterval(timer);
|
|
6528
6529
|
};
|
|
6529
6530
|
}, [externalCostTracker]);
|
|
6530
|
-
|
|
6531
|
+
useEffect5(() => {
|
|
6531
6532
|
if (isStreaming || !idlePlaceholder) {
|
|
6532
6533
|
setGradientColors([]);
|
|
6533
6534
|
return;
|
|
@@ -6546,7 +6547,7 @@ function ChatSession({
|
|
|
6546
6547
|
}, GRADIENT_ANIMATION.idleInterval);
|
|
6547
6548
|
return () => clearInterval(interval);
|
|
6548
6549
|
}, [isStreaming, idlePlaceholder]);
|
|
6549
|
-
|
|
6550
|
+
useEffect5(() => {
|
|
6550
6551
|
if (!isStreaming || !streamingPlaceholder) {
|
|
6551
6552
|
setStreamingGradientColors([]);
|
|
6552
6553
|
return;
|
|
@@ -6996,251 +6997,274 @@ function ChatSession({
|
|
|
6996
6997
|
rewinding
|
|
6997
6998
|
]
|
|
6998
6999
|
);
|
|
6999
|
-
|
|
7000
|
+
useEffect5(() => {
|
|
7000
7001
|
if (!isStreaming && externalCostTracker) {
|
|
7001
7002
|
setTodayCost(externalCostTracker.todayTotalCost);
|
|
7002
7003
|
}
|
|
7003
7004
|
}, [isStreaming, externalCostTracker]);
|
|
7004
|
-
return /* @__PURE__ */
|
|
7005
|
-
|
|
7006
|
-
/* @__PURE__ */
|
|
7007
|
-
|
|
7008
|
-
const colorIndex = (i + offset) % CYBER_PALETTE.length;
|
|
7009
|
-
return /* @__PURE__ */ jsx10(Box10, { children: /* @__PURE__ */ jsx10(Text11, { bold: true, color: CYBER_PALETTE[colorIndex], children: line }) }, i);
|
|
7010
|
-
}),
|
|
7011
|
-
/* @__PURE__ */ jsx10(Box10, { marginTop: 1, children: /* @__PURE__ */ jsxs10(Text11, { color: "#808080", children: [
|
|
7012
|
-
" \u{1F4E6} v",
|
|
7013
|
-
VERSION
|
|
7014
|
-
] }) })
|
|
7015
|
-
] }),
|
|
7016
|
-
/* @__PURE__ */ jsxs10(Box10, { flexDirection: "column", justifyContent: "center", children: [
|
|
7017
|
-
/* @__PURE__ */ jsxs10(Text11, { color: "#00ff41", children: [
|
|
7018
|
-
" \u2714 ",
|
|
7019
|
-
"\u5DF2\u5C31\u7EEA ",
|
|
7020
|
-
skillCount,
|
|
7021
|
-
" \u4E2A Skill"
|
|
7022
|
-
] }),
|
|
7023
|
-
/* @__PURE__ */ jsxs10(Text11, { color: "#00ffff", children: [
|
|
7024
|
-
" \u2139 ",
|
|
7025
|
-
"\u5DF2\u5C31\u7EEA ",
|
|
7026
|
-
toolCount,
|
|
7027
|
-
" \u4E2A\u5DE5\u5177"
|
|
7028
|
-
] }),
|
|
7029
|
-
/* @__PURE__ */ jsxs10(Text11, { color: "#00ffff", children: [
|
|
7030
|
-
" \u{1F527} \u6A21\u578B ",
|
|
7031
|
-
SUPPORTED_MODELS[activeModel]?.displayName ?? activeModel
|
|
7032
|
-
] }),
|
|
7033
|
-
thinkingEnabled && /* @__PURE__ */ jsxs10(Text11, { color: "#ff9800", children: [
|
|
7034
|
-
" \u{1F9E0} \u6DF1\u5EA6\u601D\u8003 ",
|
|
7035
|
-
thinkingEffort === "max" ? "Max" : "High"
|
|
7036
|
-
] }),
|
|
7037
|
-
sessionMode === "plan" && /* @__PURE__ */ jsx10(Text11, { color: "#ff69b4", bold: true, children: " \u{1F4CB} \u8BA1\u5212\u6A21\u5F0F" }),
|
|
7038
|
-
responseFormat === "json_object" && /* @__PURE__ */ jsx10(Text11, { color: "#4caf50", children: " \u{1F4C4} JSON" }),
|
|
7039
|
-
toolChoice !== void 0 && /* @__PURE__ */ jsxs10(Text11, { color: "#e91e63", children: [
|
|
7040
|
-
" \u{1F6E0} ",
|
|
7041
|
-
toolChoice === "none" ? "\u7981\u6B62\u5DE5\u5177" : toolChoice === "required" ? "\u5F3A\u5236\u5DE5\u5177" : ""
|
|
7042
|
-
] }),
|
|
7043
|
-
cmdTips.length > 0 && (() => {
|
|
7044
|
-
const tip = cmdTips[cmdTipIndex % cmdTips.length];
|
|
7045
|
-
if (!tip) return null;
|
|
7046
|
-
const text = `${tip.name} ${tip.desc}`;
|
|
7047
|
-
return /* @__PURE__ */ jsxs10(Text11, { children: [
|
|
7048
|
-
/* @__PURE__ */ jsx10(Text11, { color: "#808080", children: " \u{1F4A1} " }),
|
|
7049
|
-
cmdTipGradientColors.length > 0 ? text.split("").map((ch, i) => /* @__PURE__ */ jsx10(Text11, { color: cmdTipGradientColors[i] || void 0, children: ch }, i)) : /* @__PURE__ */ jsx10(Text11, { color: "#808080", children: text })
|
|
7050
|
-
] });
|
|
7051
|
-
})(),
|
|
7052
|
-
verbose ? /* @__PURE__ */ jsx10(Text11, { color: "#ff1493", children: " \u26A1 Verbose" }) : null
|
|
7053
|
-
] }),
|
|
7054
|
-
/* @__PURE__ */ jsxs10(
|
|
7055
|
-
Box10,
|
|
7005
|
+
return /* @__PURE__ */ jsxs11(Box11, { flexDirection: "column", paddingLeft: 1, paddingRight: 1, children: [
|
|
7006
|
+
/* @__PURE__ */ jsxs11(Box11, { flexDirection: "row", flexGrow: 1, children: [
|
|
7007
|
+
/* @__PURE__ */ jsx11(
|
|
7008
|
+
Box11,
|
|
7056
7009
|
{
|
|
7057
|
-
|
|
7010
|
+
width: leftPanelWidth,
|
|
7011
|
+
flexShrink: 0,
|
|
7058
7012
|
flexDirection: "column",
|
|
7059
|
-
|
|
7060
|
-
|
|
7061
|
-
|
|
7062
|
-
|
|
7063
|
-
|
|
7064
|
-
|
|
7065
|
-
|
|
7066
|
-
|
|
7067
|
-
|
|
7068
|
-
|
|
7069
|
-
|
|
7070
|
-
|
|
7071
|
-
|
|
7072
|
-
|
|
7073
|
-
|
|
7074
|
-
|
|
7075
|
-
|
|
7076
|
-
|
|
7077
|
-
|
|
7078
|
-
|
|
7079
|
-
|
|
7080
|
-
|
|
7081
|
-
|
|
7082
|
-
|
|
7083
|
-
|
|
7084
|
-
|
|
7085
|
-
|
|
7086
|
-
|
|
7087
|
-
|
|
7088
|
-
|
|
7089
|
-
|
|
7090
|
-
|
|
7091
|
-
|
|
7092
|
-
|
|
7093
|
-
|
|
7094
|
-
|
|
7095
|
-
|
|
7096
|
-
|
|
7097
|
-
|
|
7098
|
-
|
|
7099
|
-
|
|
7100
|
-
|
|
7101
|
-
|
|
7102
|
-
|
|
7103
|
-
|
|
7104
|
-
|
|
7105
|
-
|
|
7106
|
-
|
|
7107
|
-
|
|
7108
|
-
|
|
7109
|
-
|
|
7110
|
-
|
|
7111
|
-
|
|
7112
|
-
|
|
7113
|
-
|
|
7114
|
-
|
|
7115
|
-
|
|
7116
|
-
|
|
7117
|
-
|
|
7118
|
-
|
|
7119
|
-
|
|
7120
|
-
|
|
7121
|
-
|
|
7122
|
-
|
|
7013
|
+
children: /* @__PURE__ */ jsx11(
|
|
7014
|
+
Box11,
|
|
7015
|
+
{
|
|
7016
|
+
borderStyle: "single",
|
|
7017
|
+
borderColor: "#333333",
|
|
7018
|
+
paddingX: 1,
|
|
7019
|
+
flexDirection: "column",
|
|
7020
|
+
flexGrow: 1,
|
|
7021
|
+
justifyContent: !hasConversationStarted ? "center" : "flex-end",
|
|
7022
|
+
children: !hasConversationStarted ? (
|
|
7023
|
+
/* ===== 首页:Logo + 状态概况 ===== */
|
|
7024
|
+
/* @__PURE__ */ jsxs11(Box11, { flexDirection: "column", alignItems: "center", children: [
|
|
7025
|
+
LOGO_LINES.map((line, i) => {
|
|
7026
|
+
const colorIndex = (i + offset) % CYBER_PALETTE.length;
|
|
7027
|
+
return /* @__PURE__ */ jsx11(Text12, { bold: true, color: CYBER_PALETTE[colorIndex], children: line }, i);
|
|
7028
|
+
}),
|
|
7029
|
+
/* @__PURE__ */ jsx11(Box11, { marginTop: 1, children: /* @__PURE__ */ jsxs11(Text12, { color: "#808080", children: [
|
|
7030
|
+
"\u{1F4E6} v",
|
|
7031
|
+
VERSION
|
|
7032
|
+
] }) }),
|
|
7033
|
+
/* @__PURE__ */ jsxs11(Box11, { marginTop: 1, flexDirection: "column", alignItems: "center", children: [
|
|
7034
|
+
/* @__PURE__ */ jsxs11(Text12, { color: "#00ff41", children: [
|
|
7035
|
+
"\u2714 ",
|
|
7036
|
+
skillCount,
|
|
7037
|
+
" Skills"
|
|
7038
|
+
] }),
|
|
7039
|
+
/* @__PURE__ */ jsxs11(Text12, { color: "#00ffff", children: [
|
|
7040
|
+
"\u2139 ",
|
|
7041
|
+
toolCount,
|
|
7042
|
+
" \u5DE5\u5177"
|
|
7043
|
+
] }),
|
|
7044
|
+
/* @__PURE__ */ jsxs11(Text12, { color: "#00ffff", children: [
|
|
7045
|
+
"\u{1F527} ",
|
|
7046
|
+
SUPPORTED_MODELS[activeModel]?.displayName ?? activeModel
|
|
7047
|
+
] }),
|
|
7048
|
+
thinkingEnabled && /* @__PURE__ */ jsxs11(Text12, { color: "#ff9800", children: [
|
|
7049
|
+
"\u{1F9E0} \u6DF1\u5EA6\u601D\u8003 ",
|
|
7050
|
+
thinkingEffort === "max" ? "Max" : "High"
|
|
7051
|
+
] }),
|
|
7052
|
+
sessionMode === "plan" && /* @__PURE__ */ jsx11(Text12, { color: "#ff69b4", bold: true, children: "\u{1F4CB} \u8BA1\u5212\u6A21\u5F0F" })
|
|
7053
|
+
] }),
|
|
7054
|
+
/* @__PURE__ */ jsxs11(Box11, { marginTop: 1, flexDirection: "column", alignItems: "center", children: [
|
|
7055
|
+
balance !== null ? /* @__PURE__ */ jsxs11(Text12, { color: "yellow", children: [
|
|
7056
|
+
"\u{1F4B0} \u4F59\u989D \xA5",
|
|
7057
|
+
balance.toFixed(2)
|
|
7058
|
+
] }) : balanceLoading ? /* @__PURE__ */ jsx11(Text12, { color: "yellow", children: "\u23F3 \u67E5\u8BE2\u4F59\u989D..." }) : null,
|
|
7059
|
+
todayCost !== null && /* @__PURE__ */ jsxs11(Text12, { color: "cyan", children: [
|
|
7060
|
+
"\u{1F4CA} \u4ECA\u65E5 \xA5",
|
|
7061
|
+
todayCost.toFixed(2)
|
|
7062
|
+
] })
|
|
7063
|
+
] }),
|
|
7064
|
+
verbose && /* @__PURE__ */ jsx11(Text12, { color: "#ff1493", children: "\u26A1 Verbose" })
|
|
7065
|
+
] })
|
|
7066
|
+
) : hasReasoningPanel ? (
|
|
7067
|
+
/* ===== 流式思考中:思考链 ===== */
|
|
7068
|
+
/* @__PURE__ */ jsxs11(Fragment2, { children: [
|
|
7069
|
+
/* @__PURE__ */ jsx11(Text12, { bold: true, color: "#ff9800", children: "\u{1F9E0} \u6DF1\u5EA6\u601D\u8003ing" }),
|
|
7070
|
+
/* @__PURE__ */ jsx11(Text12, { dimColor: true, wrap: "wrap", children: joinReasoningSegments(currentReasoning) })
|
|
7071
|
+
] })
|
|
7072
|
+
) : (
|
|
7073
|
+
/* ===== 对话中(无思考):会话状态面板 ===== */
|
|
7074
|
+
/* @__PURE__ */ jsxs11(Box11, { flexDirection: "column", alignItems: "center", children: [
|
|
7075
|
+
/* @__PURE__ */ jsx11(Text12, { color: "#00ffff", bold: true, children: "\u{1F4AC} \u5BF9\u8BDD\u8FDB\u884C\u4E2D" }),
|
|
7076
|
+
/* @__PURE__ */ jsxs11(Box11, { marginTop: 1, flexDirection: "column", alignItems: "center", children: [
|
|
7077
|
+
/* @__PURE__ */ jsxs11(Text12, { color: "#00ff41", children: [
|
|
7078
|
+
"\u{1F4DD} \u6D88\u606F ",
|
|
7079
|
+
displayMessages.length,
|
|
7080
|
+
" \u6761"
|
|
7081
|
+
] }),
|
|
7082
|
+
sessionCost > 0 && /* @__PURE__ */ jsxs11(Text12, { color: "cyan", children: [
|
|
7083
|
+
"\u{1F4B0} \u4F1A\u8BDD \xA5",
|
|
7084
|
+
sessionCost.toFixed(4)
|
|
7085
|
+
] })
|
|
7086
|
+
] }),
|
|
7087
|
+
/* @__PURE__ */ jsxs11(Box11, { marginTop: 1, flexDirection: "column", alignItems: "center", children: [
|
|
7088
|
+
/* @__PURE__ */ jsxs11(Text12, { color: "#808080", children: [
|
|
7089
|
+
"\u{1F527} ",
|
|
7090
|
+
SUPPORTED_MODELS[activeModel]?.displayName ?? activeModel
|
|
7091
|
+
] }),
|
|
7092
|
+
thinkingEnabled && /* @__PURE__ */ jsxs11(Text12, { color: "#ff9800", children: [
|
|
7093
|
+
"\u{1F9E0} ",
|
|
7094
|
+
thinkingEffort === "max" ? "Max" : "High"
|
|
7095
|
+
] })
|
|
7096
|
+
] }),
|
|
7097
|
+
balance !== null && /* @__PURE__ */ jsx11(Box11, { marginTop: 1, children: /* @__PURE__ */ jsxs11(Text12, { color: "yellow", children: [
|
|
7098
|
+
"\u{1F4B0} \xA5",
|
|
7099
|
+
balance.toFixed(2)
|
|
7100
|
+
] }) })
|
|
7101
|
+
] })
|
|
7102
|
+
)
|
|
7103
|
+
}
|
|
7104
|
+
)
|
|
7123
7105
|
}
|
|
7124
7106
|
),
|
|
7125
|
-
|
|
7126
|
-
|
|
7127
|
-
|
|
7128
|
-
|
|
7129
|
-
|
|
7130
|
-
|
|
7131
|
-
|
|
7132
|
-
|
|
7133
|
-
|
|
7134
|
-
|
|
7135
|
-
|
|
7136
|
-
|
|
7137
|
-
|
|
7138
|
-
|
|
7139
|
-
|
|
7140
|
-
|
|
7141
|
-
|
|
7142
|
-
/* @__PURE__ */
|
|
7143
|
-
|
|
7144
|
-
|
|
7145
|
-
|
|
7146
|
-
|
|
7147
|
-
|
|
7148
|
-
|
|
7149
|
-
|
|
7150
|
-
|
|
7151
|
-
|
|
7152
|
-
|
|
7153
|
-
|
|
7154
|
-
|
|
7155
|
-
|
|
7156
|
-
|
|
7157
|
-
|
|
7158
|
-
|
|
7159
|
-
|
|
7160
|
-
|
|
7161
|
-
|
|
7162
|
-
|
|
7163
|
-
|
|
7164
|
-
|
|
7165
|
-
|
|
7166
|
-
|
|
7167
|
-
|
|
7168
|
-
|
|
7169
|
-
|
|
7107
|
+
/* @__PURE__ */ jsx11(Box11, { width: 1, flexShrink: 0, children: /* @__PURE__ */ jsx11(Text12, { color: "#444", children: "\u2502" }) }),
|
|
7108
|
+
/* @__PURE__ */ jsxs11(Box11, { flexDirection: "column", flexGrow: 1, children: [
|
|
7109
|
+
/* @__PURE__ */ jsxs11(Box11, { flexDirection: "column", flexGrow: 1, children: [
|
|
7110
|
+
!hasConversationStarted && /* @__PURE__ */ jsxs11(Box11, { flexDirection: "column", alignItems: "flex-start", flexGrow: 1, paddingBottom: 1, children: [
|
|
7111
|
+
cmdTips.length > 0 && (() => {
|
|
7112
|
+
const tip = cmdTips[cmdTipIndex % cmdTips.length];
|
|
7113
|
+
if (!tip) return null;
|
|
7114
|
+
const text = `${tip.name} ${tip.desc}`;
|
|
7115
|
+
return /* @__PURE__ */ jsxs11(Box11, { marginTop: 1, alignSelf: "center", children: [
|
|
7116
|
+
/* @__PURE__ */ jsx11(Text12, { color: "#808080", children: "\u{1F4A1} " }),
|
|
7117
|
+
cmdTipGradientColors.length > 0 ? text.split("").map((ch, i) => /* @__PURE__ */ jsx11(Text12, { color: cmdTipGradientColors[i] || void 0, children: ch }, i)) : /* @__PURE__ */ jsx11(Text12, { color: "#808080", children: text })
|
|
7118
|
+
] });
|
|
7119
|
+
})(),
|
|
7120
|
+
/* @__PURE__ */ jsx11(Box11, { flexGrow: 1 }),
|
|
7121
|
+
/* @__PURE__ */ jsx11(AnimatedLogo, { panelWidth: rightContentWidth })
|
|
7122
|
+
] }),
|
|
7123
|
+
/* @__PURE__ */ jsxs11(Box11, { flexDirection: "column", marginTop: 1, children: [
|
|
7124
|
+
/* @__PURE__ */ jsx11(Static, { items: displayMessages, children: (msg, i) => {
|
|
7125
|
+
if (msg.role === "user") {
|
|
7126
|
+
return /* @__PURE__ */ jsxs11(Box11, { marginTop: 1, flexDirection: "row", children: [
|
|
7127
|
+
/* @__PURE__ */ jsx11(Box11, { width: 1, backgroundColor: "#FF8C00", flexShrink: 0 }),
|
|
7128
|
+
/* @__PURE__ */ jsx11(Box11, { flexGrow: 1, paddingLeft: 1, children: /* @__PURE__ */ jsxs11(Box11, { flexDirection: "row", children: [
|
|
7129
|
+
/* @__PURE__ */ jsx11(Box11, { width: 4, flexShrink: 0, children: /* @__PURE__ */ jsx11(Text12, { bold: true, color: "#FF8C00", children: "\u{1F4AC}" }) }),
|
|
7130
|
+
/* @__PURE__ */ jsx11(Box11, { flexGrow: 1, children: /* @__PURE__ */ jsx11(Text12, { wrap: "wrap", children: msg.content }) })
|
|
7131
|
+
] }) })
|
|
7132
|
+
] }, i);
|
|
7133
|
+
}
|
|
7134
|
+
if (msg.role === "tool") {
|
|
7135
|
+
return /* @__PURE__ */ jsxs11(Box11, { marginTop: 1, flexDirection: "row", children: [
|
|
7136
|
+
/* @__PURE__ */ jsx11(Box11, { width: 1, backgroundColor: "#666666", flexShrink: 0 }),
|
|
7137
|
+
/* @__PURE__ */ jsxs11(Box11, { flexGrow: 1, paddingLeft: 1, flexDirection: "column", children: [
|
|
7138
|
+
/* @__PURE__ */ jsxs11(Box11, { flexDirection: "row", children: [
|
|
7139
|
+
/* @__PURE__ */ jsx11(Box11, { width: 4, flexShrink: 0, children: /* @__PURE__ */ jsx11(Text12, { dimColor: true, children: "\u{1F527}" }) }),
|
|
7140
|
+
/* @__PURE__ */ jsx11(Box11, { flexGrow: 1, children: /* @__PURE__ */ jsx11(Text12, { dimColor: true, wrap: "wrap", children: msg.content }) })
|
|
7141
|
+
] }),
|
|
7142
|
+
msg.diff && /* @__PURE__ */ jsx11(DiffPreview, { diff: msg.diff })
|
|
7143
|
+
] })
|
|
7144
|
+
] }, i);
|
|
7145
|
+
}
|
|
7146
|
+
const detail = msg.assistantDetail;
|
|
7147
|
+
return /* @__PURE__ */ jsx11(
|
|
7148
|
+
AssistantMessage,
|
|
7149
|
+
{
|
|
7150
|
+
content: msg.content,
|
|
7151
|
+
toolCalls: detail?.toolCalls,
|
|
7152
|
+
isStreaming: false,
|
|
7153
|
+
usage: detail?.usage,
|
|
7154
|
+
elapsed: detail?.elapsed,
|
|
7155
|
+
cost: detail?.cost,
|
|
7156
|
+
model: detail?.model
|
|
7157
|
+
},
|
|
7158
|
+
i
|
|
7159
|
+
);
|
|
7160
|
+
} }, staticKey),
|
|
7161
|
+
isStreaming && /* @__PURE__ */ jsx11(
|
|
7162
|
+
AssistantMessage,
|
|
7163
|
+
{
|
|
7164
|
+
content: currentContent,
|
|
7165
|
+
toolCalls: currentToolCalls.length > 0 ? currentToolCalls : void 0,
|
|
7166
|
+
isStreaming: true,
|
|
7167
|
+
usage: _currentUsage,
|
|
7168
|
+
cost: _currentCost,
|
|
7169
|
+
model: _streamingModel
|
|
7170
|
+
}
|
|
7171
|
+
),
|
|
7172
|
+
!isStreaming && streamError && /* @__PURE__ */ jsx11(Box11, { marginTop: 1, marginLeft: 3, children: /* @__PURE__ */ jsxs11(Text12, { color: "red", children: [
|
|
7173
|
+
"\u26A0 ",
|
|
7174
|
+
streamError
|
|
7175
|
+
] }) })
|
|
7176
|
+
] }),
|
|
7177
|
+
todoPanelVisible && todoSnapshot.length > 0 && /* @__PURE__ */ jsx11(TodoListPanel, { items: todoSnapshot })
|
|
7178
|
+
] }),
|
|
7179
|
+
selectingModel ? /* @__PURE__ */ jsxs11(Box11, { marginTop: 1, flexDirection: "column", children: [
|
|
7180
|
+
/* @__PURE__ */ jsx11(Text12, { color: "#00ffff", dimColor: true, children: "\u2500".repeat(rightContentWidth) }),
|
|
7181
|
+
/* @__PURE__ */ jsxs11(Box11, { flexDirection: "column", marginTop: 1, children: [
|
|
7182
|
+
/* @__PURE__ */ jsx11(Text12, { bold: true, color: "#00ffff", children: "\u9009\u62E9\u6A21\u578B\uFF1A" }),
|
|
7183
|
+
modelOptions.map((id, i) => {
|
|
7184
|
+
const meta = SUPPORTED_MODELS[id];
|
|
7185
|
+
const isCurrent = id === activeModel;
|
|
7186
|
+
const isSelected = i === modelSelectIndex;
|
|
7187
|
+
const marker = isSelected ? " > " : " ";
|
|
7188
|
+
const suffix = isCurrent ? " (\u5F53\u524D)" : "";
|
|
7189
|
+
return /* @__PURE__ */ jsxs11(Box11, { children: [
|
|
7190
|
+
/* @__PURE__ */ jsxs11(Text12, { color: isSelected ? "#00ff41" : void 0, bold: isSelected, children: [
|
|
7191
|
+
marker,
|
|
7192
|
+
meta.displayName,
|
|
7193
|
+
suffix
|
|
7194
|
+
] }),
|
|
7195
|
+
isSelected && /* @__PURE__ */ jsxs11(Text12, { color: "#808080", children: [
|
|
7196
|
+
" \u2014 ",
|
|
7197
|
+
id
|
|
7198
|
+
] })
|
|
7199
|
+
] }, id);
|
|
7200
|
+
}),
|
|
7201
|
+
/* @__PURE__ */ jsx11(Box11, { marginTop: 1, children: /* @__PURE__ */ jsx11(Text12, { color: "#808080", dimColor: true, children: "\u2191\u2193 \u9009\u62E9 \xB7 Enter \u786E\u8BA4 \xB7 Esc \u53D6\u6D88" }) })
|
|
7202
|
+
] }),
|
|
7203
|
+
/* @__PURE__ */ jsx11(Text12, { color: "#00ffff", dimColor: true, children: "\u2500".repeat(rightContentWidth) })
|
|
7204
|
+
] }) : rewindSelecting ? /* @__PURE__ */ jsxs11(Box11, { marginTop: 1, flexDirection: "column", children: [
|
|
7205
|
+
/* @__PURE__ */ jsx11(Text12, { color: "#00ffff", dimColor: true, children: "\u2500".repeat(rightContentWidth) }),
|
|
7206
|
+
/* @__PURE__ */ jsxs11(Box11, { flexDirection: "column", marginTop: 1, children: [
|
|
7207
|
+
/* @__PURE__ */ jsx11(Text12, { bold: true, color: "#ff9800", children: "\u9009\u62E9\u8981\u56DE\u9000\u7684\u68C0\u67E5\u70B9\uFF1A" }),
|
|
7208
|
+
rewindList.map((cp2, i) => {
|
|
7209
|
+
const isSelected = i === rewindSelectIndex;
|
|
7210
|
+
const marker = isSelected ? " > " : " ";
|
|
7211
|
+
const time = new Date(cp2.timestamp).toLocaleTimeString();
|
|
7212
|
+
const preview = cp2.preview || "(\u7A7A)";
|
|
7213
|
+
const tag = cp2.isGitRepo ? "" : " [\u975E git\uFF0C\u4EC5\u5BF9\u8BDD]";
|
|
7214
|
+
return /* @__PURE__ */ jsx11(Box11, { children: /* @__PURE__ */ jsxs11(Text12, { color: isSelected ? "#ff9800" : void 0, bold: isSelected, children: [
|
|
7215
|
+
marker,
|
|
7216
|
+
"#",
|
|
7217
|
+
i + 1,
|
|
7218
|
+
" ",
|
|
7219
|
+
time,
|
|
7220
|
+
" `",
|
|
7221
|
+
preview,
|
|
7222
|
+
tag,
|
|
7223
|
+
"`"
|
|
7224
|
+
] }) }, cp2.index);
|
|
7225
|
+
}),
|
|
7226
|
+
/* @__PURE__ */ jsx11(Box11, { marginTop: 1, children: /* @__PURE__ */ jsx11(Text12, { color: "#808080", dimColor: true, children: "\u2191\u2193 \u9009\u62E9 \xB7 Enter \u786E\u8BA4 \xB7 Esc \u53D6\u6D88" }) })
|
|
7227
|
+
] }),
|
|
7228
|
+
/* @__PURE__ */ jsx11(Text12, { color: "#00ffff", dimColor: true, children: "\u2500".repeat(rightContentWidth) })
|
|
7229
|
+
] }) : /* @__PURE__ */ jsxs11(Fragment2, { children: [
|
|
7230
|
+
(hasConversationStarted || sessionMode === "plan") && isStreaming && streamingPhase ? /* @__PURE__ */ jsx11(Box11, { marginTop: 1, justifyContent: "center", children: /* @__PURE__ */ jsxs11(Text12, { bold: true, color: PHASE_CONFIG[streamingPhase].color, children: [
|
|
7231
|
+
PHASE_CONFIG[streamingPhase].icon,
|
|
7170
7232
|
" ",
|
|
7171
|
-
|
|
7172
|
-
"
|
|
7173
|
-
|
|
7174
|
-
|
|
7175
|
-
|
|
7176
|
-
|
|
7177
|
-
|
|
7178
|
-
|
|
7179
|
-
|
|
7180
|
-
|
|
7181
|
-
|
|
7182
|
-
|
|
7183
|
-
|
|
7184
|
-
|
|
7185
|
-
|
|
7186
|
-
|
|
7187
|
-
|
|
7188
|
-
|
|
7189
|
-
|
|
7190
|
-
|
|
7191
|
-
|
|
7192
|
-
|
|
7193
|
-
|
|
7194
|
-
Text11,
|
|
7195
|
-
{
|
|
7196
|
-
color: sessionMode === "plan" ? "#ff69b4" : "#00ffff",
|
|
7197
|
-
dimColor: sessionMode !== "plan",
|
|
7198
|
-
children: [
|
|
7199
|
-
/* @__PURE__ */ jsx10(Text11, { children: sessionMode === "plan" ? "\u2500".repeat(Math.max(dividerWidth - 48, 1)) : "\u2500".repeat(Math.max(dividerWidth - 35, 10)) }),
|
|
7200
|
-
balance !== null && /* @__PURE__ */ jsxs10(Text11, { color: "yellow", children: [
|
|
7201
|
-
" \u{1F4B0} \u4F59\u989D \xA5",
|
|
7202
|
-
balance.toFixed(2)
|
|
7203
|
-
] }),
|
|
7204
|
-
isStreaming ? /* @__PURE__ */ jsxs10(Text11, { color: "cyan", children: [
|
|
7205
|
-
" \u{1F4CA} \u672C\u6B21 \xA5",
|
|
7206
|
-
sessionCost > 0 ? sessionCost.toFixed(4) + " " : "",
|
|
7207
|
-
/* @__PURE__ */ jsx10(InkSpinner3, { type: "dots" })
|
|
7208
|
-
] }) : sessionCost > 0 ? /* @__PURE__ */ jsxs10(Text11, { color: "cyan", children: [
|
|
7209
|
-
" \u{1F4CA} \u672C\u6B21 \xA5",
|
|
7210
|
-
sessionCost.toFixed(4)
|
|
7211
|
-
] }) : null,
|
|
7212
|
-
sessionMode === "plan" && /* @__PURE__ */ jsx10(Text11, { color: "#ff69b4", bold: true, children: " \u{1F4CB} \u8BA1\u5212\u6A21\u5F0F" })
|
|
7213
|
-
]
|
|
7214
|
-
}
|
|
7215
|
-
) : /* @__PURE__ */ jsx10(Text11, { color: "#00ffff", dimColor: true, children: "\u2500".repeat(dividerWidth) }) }),
|
|
7216
|
-
/* @__PURE__ */ jsxs10(Box10, { children: [
|
|
7217
|
-
/* @__PURE__ */ jsx10(Box10, { width: 4, flexShrink: 0, children: /* @__PURE__ */ jsx10(Text11, { bold: true, color: "#00ff41", children: "\u26A1" }) }),
|
|
7218
|
-
/* @__PURE__ */ jsx10(Box10, { flexGrow: 1, children: !input && !isStreaming && idlePlaceholder && gradientColors.length > 0 ? /* @__PURE__ */ jsx10(Text11, { children: idlePlaceholder.split("").map((ch, i) => /* @__PURE__ */ jsx10(Text11, { color: gradientColors[i] ?? void 0, children: ch }, i)) }) : !input && isStreaming && streamingPlaceholder && streamingGradientColors.length > 0 ? /* @__PURE__ */ jsx10(Text11, { children: streamingPlaceholder.split("").map((ch, i) => /* @__PURE__ */ jsx10(Text11, { color: streamingGradientColors[i] ?? void 0, children: ch }, i)) }) : /* @__PURE__ */ jsx10(
|
|
7219
|
-
TextInput,
|
|
7220
|
-
{
|
|
7221
|
-
value: input,
|
|
7222
|
-
onChange: setInput,
|
|
7223
|
-
onSubmit: handleSubmit,
|
|
7224
|
-
placeholder: ""
|
|
7225
|
-
},
|
|
7226
|
-
inputKey
|
|
7227
|
-
) })
|
|
7228
|
-
] }),
|
|
7229
|
-
/* @__PURE__ */ jsx10(Box10, { children: /* @__PURE__ */ jsx10(Text11, { color: "#00ffff", dimColor: true, children: "\u2500".repeat(dividerWidth) }) }),
|
|
7230
|
-
/* @__PURE__ */ jsx10(SkillSelector, { skills, input, selectedIndex: skillSelectIndex }),
|
|
7231
|
-
/* @__PURE__ */ jsx10(FileSelector, { files, input, selectedIndex: fileSelectIndex })
|
|
7233
|
+
PHASE_CONFIG[streamingPhase].label,
|
|
7234
|
+
" ",
|
|
7235
|
+
/* @__PURE__ */ jsx11(InkSpinner3, { type: "dots" })
|
|
7236
|
+
] }) }) : rewindHintPhase === "visible" ? /* @__PURE__ */ jsx11(Box11, { marginTop: 1, justifyContent: "center", children: /* @__PURE__ */ jsx11(Text12, { color: "#808080", children: "\u21A9 /rewind 1 \u53EF\u64A4\u56DE\u672C\u6B21\u4FEE\u6539" }) }) : null,
|
|
7237
|
+
/* @__PURE__ */ jsx11(Box11, { marginTop: 1, children: /* @__PURE__ */ jsx11(Text12, { color: "#00ffff", dimColor: true, children: "\u2500".repeat(rightContentWidth) }) }),
|
|
7238
|
+
/* @__PURE__ */ jsxs11(Box11, { children: [
|
|
7239
|
+
/* @__PURE__ */ jsx11(Box11, { width: 4, flexShrink: 0, children: /* @__PURE__ */ jsx11(Text12, { bold: true, color: "#00ff41", children: "\u26A1" }) }),
|
|
7240
|
+
/* @__PURE__ */ jsx11(Box11, { flexGrow: 1, children: !input && !isStreaming && idlePlaceholder && gradientColors.length > 0 ? /* @__PURE__ */ jsx11(Text12, { children: idlePlaceholder.split("").map((ch, i) => /* @__PURE__ */ jsx11(Text12, { color: gradientColors[i] ?? void 0, children: ch }, i)) }) : !input && isStreaming && streamingPlaceholder && streamingGradientColors.length > 0 ? /* @__PURE__ */ jsx11(Text12, { children: streamingPlaceholder.split("").map((ch, i) => /* @__PURE__ */ jsx11(Text12, { color: streamingGradientColors[i] ?? void 0, children: ch }, i)) }) : /* @__PURE__ */ jsx11(
|
|
7241
|
+
TextInput,
|
|
7242
|
+
{
|
|
7243
|
+
value: input,
|
|
7244
|
+
onChange: setInput,
|
|
7245
|
+
onSubmit: handleSubmit,
|
|
7246
|
+
placeholder: ""
|
|
7247
|
+
},
|
|
7248
|
+
inputKey
|
|
7249
|
+
) })
|
|
7250
|
+
] }),
|
|
7251
|
+
/* @__PURE__ */ jsx11(Box11, { children: /* @__PURE__ */ jsx11(Text12, { color: "#00ffff", dimColor: true, children: "\u2500".repeat(rightContentWidth) }) }),
|
|
7252
|
+
/* @__PURE__ */ jsx11(SkillSelector, { skills, input, selectedIndex: skillSelectIndex }),
|
|
7253
|
+
/* @__PURE__ */ jsx11(FileSelector, { files, input, selectedIndex: fileSelectIndex })
|
|
7254
|
+
] })
|
|
7255
|
+
] })
|
|
7232
7256
|
] }),
|
|
7233
|
-
doubleCtrlC && !isStreaming && /* @__PURE__ */
|
|
7234
|
-
isStreaming && /* @__PURE__ */
|
|
7257
|
+
doubleCtrlC && !isStreaming && /* @__PURE__ */ jsx11(Box11, { marginTop: 1, children: /* @__PURE__ */ jsx11(Text12, { color: "#ff1493", bold: true, children: " \u26A0 \u518D\u6309\u4E00\u6B21 Ctrl+C \u9000\u51FA dskcode" }) }),
|
|
7258
|
+
isStreaming && /* @__PURE__ */ jsx11(Box11, { marginTop: 1, children: /* @__PURE__ */ jsx11(Text12, { color: "yellow", dimColor: true, children: " \u63D0\u793A\uFF1A\u6309 Ctrl+C \u53D6\u6D88\u5F53\u524D\u8BF7\u6C42" }) })
|
|
7235
7259
|
] });
|
|
7236
7260
|
}
|
|
7237
7261
|
|
|
7238
7262
|
// src/ui/GamePicker.tsx
|
|
7239
|
-
import { Box as
|
|
7240
|
-
import { useState as
|
|
7241
|
-
import { jsx as
|
|
7263
|
+
import { Box as Box12, Text as Text13, useInput as useInput2 } from "ink";
|
|
7264
|
+
import { useState as useState6, useCallback as useCallback3 } from "react";
|
|
7265
|
+
import { jsx as jsx12, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
7242
7266
|
function GamePicker({ games, onSelect, onExit, onBackToChat }) {
|
|
7243
|
-
const [selectedIndex, setSelectedIndex] =
|
|
7267
|
+
const [selectedIndex, setSelectedIndex] = useState6(0);
|
|
7244
7268
|
const exitAction = onBackToChat ?? onExit ?? (() => process.exit(0));
|
|
7245
7269
|
const { doubleCtrlC, handleCtrlC } = useDoubleCtrlC(exitAction);
|
|
7246
7270
|
useInput2(
|
|
@@ -7266,18 +7290,18 @@ function GamePicker({ games, onSelect, onExit, onBackToChat }) {
|
|
|
7266
7290
|
[games, selectedIndex, onSelect, onExit, onBackToChat, handleCtrlC]
|
|
7267
7291
|
)
|
|
7268
7292
|
);
|
|
7269
|
-
return /* @__PURE__ */
|
|
7270
|
-
/* @__PURE__ */
|
|
7271
|
-
/* @__PURE__ */
|
|
7293
|
+
return /* @__PURE__ */ jsxs12(Box12, { flexDirection: "column", children: [
|
|
7294
|
+
/* @__PURE__ */ jsx12(Box12, { marginBottom: 1, children: /* @__PURE__ */ jsx12(Text13, { bold: true, color: "#00ffff", children: "\u{1F3AE} \u6E38\u620F\u5217\u8868" }) }),
|
|
7295
|
+
/* @__PURE__ */ jsx12(Box12, { flexDirection: "column", children: games.map((game, index) => {
|
|
7272
7296
|
const isSelected = index === selectedIndex;
|
|
7273
|
-
return /* @__PURE__ */
|
|
7274
|
-
/* @__PURE__ */
|
|
7275
|
-
/* @__PURE__ */
|
|
7276
|
-
/* @__PURE__ */
|
|
7297
|
+
return /* @__PURE__ */ jsxs12(Box12, { flexDirection: "row", children: [
|
|
7298
|
+
/* @__PURE__ */ jsx12(Box12, { width: 3, flexShrink: 0, children: isSelected ? /* @__PURE__ */ jsx12(Text13, { bold: true, color: "#00ff41", children: "\u25B8 " }) : /* @__PURE__ */ jsx12(Text13, { children: " " }) }),
|
|
7299
|
+
/* @__PURE__ */ jsx12(Box12, { width: 20, flexShrink: 0, children: /* @__PURE__ */ jsx12(Text13, { bold: true, color: isSelected ? "#00ff41" : "#ffffff", children: game.name }) }),
|
|
7300
|
+
/* @__PURE__ */ jsx12(Box12, { children: /* @__PURE__ */ jsx12(Text13, { color: "#888888", children: game.description }) })
|
|
7277
7301
|
] }, game.id);
|
|
7278
7302
|
}) }),
|
|
7279
|
-
/* @__PURE__ */
|
|
7280
|
-
doubleCtrlC && /* @__PURE__ */
|
|
7303
|
+
/* @__PURE__ */ jsx12(Box12, { marginTop: 1, children: /* @__PURE__ */ jsx12(Text13, { dimColor: true, children: " \u2191/\u2193 \u9009\u62E9 Enter \u542F\u52A8 q \u8FD4\u56DE" }) }),
|
|
7304
|
+
doubleCtrlC && /* @__PURE__ */ jsx12(Box12, { marginTop: 1, children: /* @__PURE__ */ jsx12(Text13, { color: "#ff1493", bold: true, children: " \u26A0 \u518D\u6309\u4E00\u6B21 Ctrl+C \u9000\u51FA dskcode" }) })
|
|
7281
7305
|
] });
|
|
7282
7306
|
}
|
|
7283
7307
|
|
|
@@ -7294,9 +7318,9 @@ function listGames() {
|
|
|
7294
7318
|
}
|
|
7295
7319
|
|
|
7296
7320
|
// src/game/brick-breaker/index.tsx
|
|
7297
|
-
import { Box as
|
|
7298
|
-
import { useState as
|
|
7299
|
-
import { jsx as
|
|
7321
|
+
import { Box as Box13, Text as Text14, useInput as useInput3, render as render2 } from "ink";
|
|
7322
|
+
import { useState as useState7, useEffect as useEffect6, useRef as useRef5, useCallback as useCallback4 } from "react";
|
|
7323
|
+
import { jsx as jsx13, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
7300
7324
|
var GAME_WIDTH = 40;
|
|
7301
7325
|
var GAME_HEIGHT = 18;
|
|
7302
7326
|
var PADDLE_WIDTH = 9;
|
|
@@ -7427,13 +7451,13 @@ function buildBoard(state) {
|
|
|
7427
7451
|
return lines.map((l) => `\u2502${l}\u2502`).join("\n");
|
|
7428
7452
|
}
|
|
7429
7453
|
function BrickBreakerGame({ onExit: _onExit }) {
|
|
7430
|
-
const [initialLevel, setInitialLevel] =
|
|
7431
|
-
const [selectingLevel, setSelectingLevel] =
|
|
7432
|
-
const stateRef =
|
|
7433
|
-
const [tick2, setTick] =
|
|
7434
|
-
const onExitRef =
|
|
7454
|
+
const [initialLevel, setInitialLevel] = useState7(1);
|
|
7455
|
+
const [selectingLevel, setSelectingLevel] = useState7(true);
|
|
7456
|
+
const stateRef = useRef5(createInitialState(initialLevel));
|
|
7457
|
+
const [tick2, setTick] = useState7(0);
|
|
7458
|
+
const onExitRef = useRef5(_onExit);
|
|
7435
7459
|
onExitRef.current = _onExit;
|
|
7436
|
-
|
|
7460
|
+
useEffect6(() => {
|
|
7437
7461
|
if (selectingLevel) return;
|
|
7438
7462
|
const interval = setInterval(() => {
|
|
7439
7463
|
update(stateRef.current);
|
|
@@ -7486,49 +7510,49 @@ function BrickBreakerGame({ onExit: _onExit }) {
|
|
|
7486
7510
|
const board = buildBoard(s);
|
|
7487
7511
|
const def = getLevel(s.level);
|
|
7488
7512
|
void tick2;
|
|
7489
|
-
return /* @__PURE__ */
|
|
7490
|
-
/* @__PURE__ */
|
|
7491
|
-
/* @__PURE__ */
|
|
7513
|
+
return /* @__PURE__ */ jsxs13(Box13, { flexDirection: "column", children: [
|
|
7514
|
+
/* @__PURE__ */ jsxs13(Box13, { flexDirection: "row", children: [
|
|
7515
|
+
/* @__PURE__ */ jsx13(Box13, { width: 20, children: /* @__PURE__ */ jsxs13(Text14, { children: [
|
|
7492
7516
|
"\u5173\u5361 ",
|
|
7493
7517
|
s.level,
|
|
7494
7518
|
": ",
|
|
7495
|
-
/* @__PURE__ */
|
|
7519
|
+
/* @__PURE__ */ jsx13(Text14, { color: "cyan", children: def.desc })
|
|
7496
7520
|
] }) }),
|
|
7497
|
-
/* @__PURE__ */
|
|
7521
|
+
/* @__PURE__ */ jsx13(Box13, { width: 12, children: /* @__PURE__ */ jsxs13(Text14, { children: [
|
|
7498
7522
|
"\u5206\u6570: ",
|
|
7499
|
-
/* @__PURE__ */
|
|
7523
|
+
/* @__PURE__ */ jsx13(Text14, { color: "yellow", children: String(s.score).padStart(3, "0") })
|
|
7500
7524
|
] }) }),
|
|
7501
|
-
/* @__PURE__ */
|
|
7525
|
+
/* @__PURE__ */ jsx13(Box13, { width: 12, children: /* @__PURE__ */ jsxs13(Text14, { children: [
|
|
7502
7526
|
"\u751F\u547D: ",
|
|
7503
|
-
/* @__PURE__ */
|
|
7527
|
+
/* @__PURE__ */ jsx13(Text14, { color: "red", children: "\u2665".repeat(Math.max(0, s.lives)) })
|
|
7504
7528
|
] }) }),
|
|
7505
|
-
/* @__PURE__ */
|
|
7529
|
+
/* @__PURE__ */ jsx13(Box13, { width: 10, children: /* @__PURE__ */ jsxs13(Text14, { children: [
|
|
7506
7530
|
"\u7816\u5757: ",
|
|
7507
|
-
/* @__PURE__ */
|
|
7531
|
+
/* @__PURE__ */ jsx13(Text14, { color: "cyan", children: aliveCount })
|
|
7508
7532
|
] }) }),
|
|
7509
|
-
/* @__PURE__ */
|
|
7533
|
+
/* @__PURE__ */ jsx13(Box13, { children: /* @__PURE__ */ jsxs13(Text14, { color: s.paused ? "gray" : "green", children: [
|
|
7510
7534
|
"[",
|
|
7511
7535
|
s.paused ? "\u6682\u505C" : "\u8FD0\u884C\u4E2D",
|
|
7512
7536
|
"]"
|
|
7513
7537
|
] }) })
|
|
7514
7538
|
] }),
|
|
7515
|
-
/* @__PURE__ */
|
|
7516
|
-
/* @__PURE__ */
|
|
7539
|
+
/* @__PURE__ */ jsxs13(Box13, { flexDirection: "column", children: [
|
|
7540
|
+
/* @__PURE__ */ jsxs13(Text14, { children: [
|
|
7517
7541
|
"\u250C",
|
|
7518
7542
|
"\u2500".repeat(GAME_WIDTH),
|
|
7519
7543
|
"\u2510"
|
|
7520
7544
|
] }),
|
|
7521
|
-
/* @__PURE__ */
|
|
7522
|
-
/* @__PURE__ */
|
|
7545
|
+
/* @__PURE__ */ jsx13(Text14, { children: selectingLevel ? " \x1B[90m\u9009\u62E9\u5173\u5361\u540E\u5F00\u59CB...\x1B[0m" : board }),
|
|
7546
|
+
/* @__PURE__ */ jsxs13(Text14, { children: [
|
|
7523
7547
|
"\u2514",
|
|
7524
7548
|
"\u2500".repeat(GAME_WIDTH),
|
|
7525
7549
|
"\u2518"
|
|
7526
7550
|
] })
|
|
7527
7551
|
] }),
|
|
7528
|
-
selectingLevel && /* @__PURE__ */
|
|
7529
|
-
/* @__PURE__ */
|
|
7530
|
-
/* @__PURE__ */
|
|
7531
|
-
/* @__PURE__ */
|
|
7552
|
+
selectingLevel && /* @__PURE__ */ jsxs13(Box13, { marginTop: 1, flexDirection: "column", children: [
|
|
7553
|
+
/* @__PURE__ */ jsx13(Text14, { bold: true, color: "yellow", children: "\u9009\u62E9\u5173\u5361" }),
|
|
7554
|
+
/* @__PURE__ */ jsx13(Box13, { flexDirection: "row", flexWrap: "wrap", children: LEVELS.map((lv, i) => /* @__PURE__ */ jsx13(Box13, { width: 22, children: /* @__PURE__ */ jsxs13(Text14, { children: [
|
|
7555
|
+
/* @__PURE__ */ jsx13(Text14, { color: initialLevel === i + 1 ? "green" : "white", children: i + 1 === 10 ? "0" : String(i + 1) }),
|
|
7532
7556
|
". ",
|
|
7533
7557
|
lv.desc,
|
|
7534
7558
|
" (",
|
|
@@ -7537,16 +7561,16 @@ function BrickBreakerGame({ onExit: _onExit }) {
|
|
|
7537
7561
|
lv.cols,
|
|
7538
7562
|
")"
|
|
7539
7563
|
] }) }, i)) }),
|
|
7540
|
-
/* @__PURE__ */
|
|
7564
|
+
/* @__PURE__ */ jsx13(Box13, { marginTop: 1, children: /* @__PURE__ */ jsx13(Text14, { dimColor: true, children: "\u6309\u6570\u5B57\u9009\u5173 q \u9000\u51FA" }) })
|
|
7541
7565
|
] }),
|
|
7542
|
-
!selectingLevel && (s.gameOver || s.win) && /* @__PURE__ */
|
|
7543
|
-
/* @__PURE__ */
|
|
7544
|
-
/* @__PURE__ */
|
|
7566
|
+
!selectingLevel && (s.gameOver || s.win) && /* @__PURE__ */ jsxs13(Box13, { marginTop: 1, children: [
|
|
7567
|
+
/* @__PURE__ */ jsx13(Text14, { bold: true, color: s.gameOver ? "red" : "green", children: s.gameOver ? "\u6E38\u620F\u7ED3\u675F\uFF01" : "\u606D\u559C\u901A\u5173\uFF01" }),
|
|
7568
|
+
/* @__PURE__ */ jsxs13(Text14, { children: [
|
|
7545
7569
|
" \u5206\u6570: ",
|
|
7546
|
-
/* @__PURE__ */
|
|
7570
|
+
/* @__PURE__ */ jsx13(Text14, { color: "yellow", children: s.score })
|
|
7547
7571
|
] })
|
|
7548
7572
|
] }),
|
|
7549
|
-
!selectingLevel && /* @__PURE__ */
|
|
7573
|
+
!selectingLevel && /* @__PURE__ */ jsx13(Box13, { marginTop: 1, children: s.gameOver || s.win ? /* @__PURE__ */ jsx13(Text14, { dimColor: true, children: "\u2190 \u2192 \u79FB\u52A8 r \u91CD\u5F00 l \u9009\u5173 q \u9000\u51FA" }) : /* @__PURE__ */ jsx13(Text14, { dimColor: true, children: "\u2190 \u2192 \u79FB\u52A8 p \u6682\u505C q \u9000\u51FA" }) })
|
|
7550
7574
|
] });
|
|
7551
7575
|
}
|
|
7552
7576
|
var brick_breaker_default = {
|
|
@@ -7556,7 +7580,7 @@ var brick_breaker_default = {
|
|
|
7556
7580
|
play: async () => {
|
|
7557
7581
|
await new Promise((resolve2) => {
|
|
7558
7582
|
const { unmount } = render2(
|
|
7559
|
-
/* @__PURE__ */
|
|
7583
|
+
/* @__PURE__ */ jsx13(BrickBreakerGame, { onExit: () => {
|
|
7560
7584
|
unmount();
|
|
7561
7585
|
resolve2();
|
|
7562
7586
|
} })
|
|
@@ -7566,9 +7590,9 @@ var brick_breaker_default = {
|
|
|
7566
7590
|
};
|
|
7567
7591
|
|
|
7568
7592
|
// src/game/coder-check/index.tsx
|
|
7569
|
-
import { Box as
|
|
7570
|
-
import { useState as
|
|
7571
|
-
import { jsx as
|
|
7593
|
+
import { Box as Box14, Text as Text15, useInput as useInput4, render as render3 } from "ink";
|
|
7594
|
+
import { useState as useState8, useEffect as useEffect7, useRef as useRef6, useCallback as useCallback5 } from "react";
|
|
7595
|
+
import { jsx as jsx14, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
7572
7596
|
var GAME_W = 66;
|
|
7573
7597
|
var GAME_H = 20;
|
|
7574
7598
|
var SCORE_H = 6;
|
|
@@ -7959,18 +7983,18 @@ function buildGameView(s, scoreLines, scoreColor, message) {
|
|
|
7959
7983
|
return rows;
|
|
7960
7984
|
}
|
|
7961
7985
|
function CoderCheck({ onExit: _onExit }) {
|
|
7962
|
-
const stateRef =
|
|
7963
|
-
const [tick2, setTick] =
|
|
7964
|
-
const [colorOffset, setColorOffset] =
|
|
7965
|
-
const onExitRef =
|
|
7986
|
+
const stateRef = useRef6(createInitialState2());
|
|
7987
|
+
const [tick2, setTick] = useState8(0);
|
|
7988
|
+
const [colorOffset, setColorOffset] = useState8(0);
|
|
7989
|
+
const onExitRef = useRef6(_onExit);
|
|
7966
7990
|
onExitRef.current = _onExit;
|
|
7967
|
-
|
|
7991
|
+
useEffect7(() => {
|
|
7968
7992
|
const timer = setInterval(() => {
|
|
7969
7993
|
setColorOffset((prev) => (prev + 1) % CYBER_PALETTE2.length);
|
|
7970
7994
|
}, 400);
|
|
7971
7995
|
return () => clearInterval(timer);
|
|
7972
7996
|
}, []);
|
|
7973
|
-
|
|
7997
|
+
useEffect7(() => {
|
|
7974
7998
|
const interval = setInterval(() => {
|
|
7975
7999
|
update2(stateRef.current);
|
|
7976
8000
|
setTick((t) => t + 1);
|
|
@@ -8039,44 +8063,44 @@ function CoderCheck({ onExit: _onExit }) {
|
|
|
8039
8063
|
const scoreLines = buildScoreLines(scoreStr);
|
|
8040
8064
|
const view = buildGameView(s, scoreLines, scoreColor, s.message);
|
|
8041
8065
|
void tick2;
|
|
8042
|
-
return /* @__PURE__ */
|
|
8043
|
-
/* @__PURE__ */
|
|
8066
|
+
return /* @__PURE__ */ jsxs14(Box14, { flexDirection: "column", paddingX: 1, children: [
|
|
8067
|
+
/* @__PURE__ */ jsx14(Box14, { flexDirection: "row", children: /* @__PURE__ */ jsxs14(Text15, { children: [
|
|
8044
8068
|
"\u751F\u547D ",
|
|
8045
|
-
/* @__PURE__ */
|
|
8069
|
+
/* @__PURE__ */ jsx14(Text15, { color: "red", children: "\u2665".repeat(Math.max(0, s.lives)) }),
|
|
8046
8070
|
" ",
|
|
8047
8071
|
"\u901F\u5EA6 ",
|
|
8048
|
-
/* @__PURE__ */
|
|
8072
|
+
/* @__PURE__ */ jsxs14(Text15, { color: "cyan", children: [
|
|
8049
8073
|
"Lv.",
|
|
8050
8074
|
Math.floor(s.speed * 10)
|
|
8051
8075
|
] })
|
|
8052
8076
|
] }) }),
|
|
8053
|
-
!s.gameOver && s.target && /* @__PURE__ */
|
|
8077
|
+
!s.gameOver && s.target && /* @__PURE__ */ jsx14(Box14, { marginTop: 1, children: /* @__PURE__ */ jsxs14(Text15, { children: [
|
|
8054
8078
|
"\u6253\u5B57: ",
|
|
8055
|
-
/* @__PURE__ */
|
|
8056
|
-
/* @__PURE__ */
|
|
8079
|
+
/* @__PURE__ */ jsx14(Text15, { color: "green", children: s.typed }),
|
|
8080
|
+
/* @__PURE__ */ jsx14(Text15, { color: "white", children: s.target.slice(s.typed.length) })
|
|
8057
8081
|
] }) }),
|
|
8058
|
-
/* @__PURE__ */
|
|
8059
|
-
/* @__PURE__ */
|
|
8082
|
+
/* @__PURE__ */ jsxs14(Box14, { flexDirection: "column", marginTop: 1, children: [
|
|
8083
|
+
/* @__PURE__ */ jsxs14(Text15, { children: [
|
|
8060
8084
|
"\u250C",
|
|
8061
8085
|
"\u2500".repeat(GAME_W),
|
|
8062
8086
|
"\u2510"
|
|
8063
8087
|
] }),
|
|
8064
|
-
view.map((row, i) => /* @__PURE__ */
|
|
8065
|
-
/* @__PURE__ */
|
|
8088
|
+
view.map((row, i) => /* @__PURE__ */ jsx14(Text15, { children: `\u2502${row}\u2502` }, i)),
|
|
8089
|
+
/* @__PURE__ */ jsxs14(Text15, { children: [
|
|
8066
8090
|
"\u2514",
|
|
8067
8091
|
"\u2500".repeat(GAME_W),
|
|
8068
8092
|
"\u2518"
|
|
8069
8093
|
] })
|
|
8070
8094
|
] }),
|
|
8071
|
-
s.gameOver && /* @__PURE__ */
|
|
8072
|
-
/* @__PURE__ */
|
|
8073
|
-
/* @__PURE__ */
|
|
8095
|
+
s.gameOver && /* @__PURE__ */ jsxs14(Box14, { marginTop: 1, children: [
|
|
8096
|
+
/* @__PURE__ */ jsx14(Text15, { bold: true, color: "red", children: "\u6E38\u620F\u7ED3\u675F\uFF01" }),
|
|
8097
|
+
/* @__PURE__ */ jsxs14(Text15, { children: [
|
|
8074
8098
|
" \u5F97\u5206: ",
|
|
8075
|
-
/* @__PURE__ */
|
|
8099
|
+
/* @__PURE__ */ jsx14(Text15, { color: "yellow", children: s.score }),
|
|
8076
8100
|
" r \u91CD\u5F00 q \u9000\u51FA"
|
|
8077
8101
|
] })
|
|
8078
8102
|
] }),
|
|
8079
|
-
/* @__PURE__ */
|
|
8103
|
+
/* @__PURE__ */ jsx14(Box14, { marginTop: 1, children: /* @__PURE__ */ jsx14(Text15, { dimColor: true, children: "\u6253\u5B57\u6D88\u9664\u5355\u8BCD \u7A7A\u683C/Ctrl+P\u6682\u505C Ctrl+Q\u9000\u51FA" }) })
|
|
8080
8104
|
] });
|
|
8081
8105
|
}
|
|
8082
8106
|
var coder_check_default = {
|
|
@@ -8086,7 +8110,7 @@ var coder_check_default = {
|
|
|
8086
8110
|
play: async () => {
|
|
8087
8111
|
await new Promise((resolve2) => {
|
|
8088
8112
|
const { unmount } = render3(
|
|
8089
|
-
/* @__PURE__ */
|
|
8113
|
+
/* @__PURE__ */ jsx14(CoderCheck, { onExit: () => {
|
|
8090
8114
|
unmount();
|
|
8091
8115
|
resolve2();
|
|
8092
8116
|
} })
|
|
@@ -8466,12 +8490,12 @@ import { render as render4 } from "ink";
|
|
|
8466
8490
|
import chalk5 from "chalk";
|
|
8467
8491
|
|
|
8468
8492
|
// src/stock/StockList.tsx
|
|
8469
|
-
import { Box as
|
|
8470
|
-
import { useState as
|
|
8493
|
+
import { Box as Box15, Text as Text16, useInput as useInput5 } from "ink";
|
|
8494
|
+
import { useState as useState9, useCallback as useCallback6, useEffect as useEffect8, useMemo as useMemo2 } from "react";
|
|
8471
8495
|
import asciichart from "asciichart";
|
|
8472
8496
|
import os from "os";
|
|
8473
8497
|
import { join as join10 } from "path";
|
|
8474
|
-
import { jsx as
|
|
8498
|
+
import { jsx as jsx15, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
8475
8499
|
var SETTINGS_PATH = join10(os.homedir(), ".dskcode", "settings.json");
|
|
8476
8500
|
function toFileUrl(p) {
|
|
8477
8501
|
const norm = p.replace(/\\/g, "/");
|
|
@@ -8574,20 +8598,20 @@ function latestPoints(data, maxPoints = 60) {
|
|
|
8574
8598
|
return data.slice(data.length - maxPoints);
|
|
8575
8599
|
}
|
|
8576
8600
|
function StockList({ codes, onExit, onBackToChat }) {
|
|
8577
|
-
const [stocks, setStocks] =
|
|
8578
|
-
const [selectedIndex, setSelectedIndex] =
|
|
8579
|
-
const [loading, setLoading] =
|
|
8580
|
-
const [lastUpdate, setLastUpdate] =
|
|
8581
|
-
const [detailView, setDetailView] =
|
|
8582
|
-
const [detailPrices, setDetailPrices] =
|
|
8583
|
-
const [detailLoading, setDetailLoading] =
|
|
8584
|
-
const [detailCountdown, setDetailCountdown] =
|
|
8585
|
-
const [countdown, setCountdown] =
|
|
8586
|
-
const [currentTime, setCurrentTime] =
|
|
8601
|
+
const [stocks, setStocks] = useState9([]);
|
|
8602
|
+
const [selectedIndex, setSelectedIndex] = useState9(0);
|
|
8603
|
+
const [loading, setLoading] = useState9(true);
|
|
8604
|
+
const [lastUpdate, setLastUpdate] = useState9("");
|
|
8605
|
+
const [detailView, setDetailView] = useState9(null);
|
|
8606
|
+
const [detailPrices, setDetailPrices] = useState9(null);
|
|
8607
|
+
const [detailLoading, setDetailLoading] = useState9(false);
|
|
8608
|
+
const [detailCountdown, setDetailCountdown] = useState9(10);
|
|
8609
|
+
const [countdown, setCountdown] = useState9(5);
|
|
8610
|
+
const [currentTime, setCurrentTime] = useState9(
|
|
8587
8611
|
() => (/* @__PURE__ */ new Date()).toLocaleTimeString("zh-CN", { hour12: false })
|
|
8588
8612
|
);
|
|
8589
|
-
const [dimMode, setDimMode] =
|
|
8590
|
-
const [sortOrder, setSortOrder] =
|
|
8613
|
+
const [dimMode, setDimMode] = useState9(false);
|
|
8614
|
+
const [sortOrder, setSortOrder] = useState9("default");
|
|
8591
8615
|
const sortedStocks = useMemo2(() => {
|
|
8592
8616
|
if (sortOrder === "default") return stocks;
|
|
8593
8617
|
return [...stocks].toSorted(
|
|
@@ -8595,7 +8619,7 @@ function StockList({ codes, onExit, onBackToChat }) {
|
|
|
8595
8619
|
);
|
|
8596
8620
|
}, [stocks, sortOrder]);
|
|
8597
8621
|
const { doubleCtrlC, handleCtrlC } = useDoubleCtrlC(onExit);
|
|
8598
|
-
|
|
8622
|
+
useEffect8(() => {
|
|
8599
8623
|
const timer = setInterval(() => {
|
|
8600
8624
|
setCurrentTime((/* @__PURE__ */ new Date()).toLocaleTimeString("zh-CN", { hour12: false }));
|
|
8601
8625
|
}, 1e3);
|
|
@@ -8611,10 +8635,10 @@ function StockList({ codes, onExit, onBackToChat }) {
|
|
|
8611
8635
|
}
|
|
8612
8636
|
setLoading(false);
|
|
8613
8637
|
}, [codes]);
|
|
8614
|
-
|
|
8638
|
+
useEffect8(() => {
|
|
8615
8639
|
void loadData();
|
|
8616
8640
|
}, [loadData]);
|
|
8617
|
-
|
|
8641
|
+
useEffect8(() => {
|
|
8618
8642
|
const interval = setInterval(() => {
|
|
8619
8643
|
setCountdown((prev) => {
|
|
8620
8644
|
if (prev <= 1) {
|
|
@@ -8626,7 +8650,7 @@ function StockList({ codes, onExit, onBackToChat }) {
|
|
|
8626
8650
|
}, 1e3);
|
|
8627
8651
|
return () => clearInterval(interval);
|
|
8628
8652
|
}, [loadData]);
|
|
8629
|
-
|
|
8653
|
+
useEffect8(() => {
|
|
8630
8654
|
if (detailView) {
|
|
8631
8655
|
const loadDetail = () => {
|
|
8632
8656
|
minuteCache.delete(detailView.code);
|
|
@@ -8645,7 +8669,7 @@ function StockList({ codes, onExit, onBackToChat }) {
|
|
|
8645
8669
|
setDetailPrices(null);
|
|
8646
8670
|
setDetailLoading(false);
|
|
8647
8671
|
}, [detailView]);
|
|
8648
|
-
|
|
8672
|
+
useEffect8(() => {
|
|
8649
8673
|
if (!detailView) return;
|
|
8650
8674
|
const timer = setInterval(() => {
|
|
8651
8675
|
setDetailCountdown((prev) => prev > 0 ? prev - 1 : 10);
|
|
@@ -8690,64 +8714,64 @@ function StockList({ codes, onExit, onBackToChat }) {
|
|
|
8690
8714
|
);
|
|
8691
8715
|
if (detailView) {
|
|
8692
8716
|
if (detailLoading) {
|
|
8693
|
-
return /* @__PURE__ */
|
|
8717
|
+
return /* @__PURE__ */ jsx15(Box15, { paddingLeft: 1, children: /* @__PURE__ */ jsx15(Text16, { dimColor: true, children: " \u27F3 \u52A0\u8F7D\u5206\u65F6\u6570\u636E..." }) });
|
|
8694
8718
|
}
|
|
8695
8719
|
return renderDetail(detailView, () => setDetailView(null), detailPrices ?? void 0, detailCountdown, currentTime);
|
|
8696
8720
|
}
|
|
8697
8721
|
const cp2 = (c) => dimMode ? { dimColor: true } : { color: c };
|
|
8698
|
-
return /* @__PURE__ */
|
|
8699
|
-
/* @__PURE__ */
|
|
8700
|
-
/* @__PURE__ */
|
|
8701
|
-
/* @__PURE__ */
|
|
8722
|
+
return /* @__PURE__ */ jsxs15(Box15, { flexDirection: "column", children: [
|
|
8723
|
+
/* @__PURE__ */ jsxs15(Box15, { marginBottom: 1, justifyContent: "space-between", children: [
|
|
8724
|
+
/* @__PURE__ */ jsx15(Text16, { bold: true, ...cp2("#00ffff"), children: " \u{1F4C8} \u81EA\u9009\u80A1\u76D1\u63A7" }),
|
|
8725
|
+
/* @__PURE__ */ jsxs15(Text16, { dimColor: true, children: [
|
|
8702
8726
|
" \u{1F550} ",
|
|
8703
8727
|
currentTime
|
|
8704
8728
|
] }),
|
|
8705
|
-
/* @__PURE__ */
|
|
8729
|
+
/* @__PURE__ */ jsx15(Text16, { dimColor: true, children: loading ? " \u27F3 \u5237\u65B0\u4E2D..." : ` ${countdown}s \u540E\u81EA\u52A8\u5237\u65B0` })
|
|
8706
8730
|
] }),
|
|
8707
|
-
/* @__PURE__ */
|
|
8708
|
-
/* @__PURE__ */
|
|
8709
|
-
/* @__PURE__ */
|
|
8710
|
-
/* @__PURE__ */
|
|
8711
|
-
/* @__PURE__ */
|
|
8712
|
-
/* @__PURE__ */
|
|
8731
|
+
/* @__PURE__ */ jsxs15(Box15, { children: [
|
|
8732
|
+
/* @__PURE__ */ jsx15(Box15, { width: 3 }),
|
|
8733
|
+
/* @__PURE__ */ jsx15(Box15, { width: 9, children: /* @__PURE__ */ jsx15(Text16, { dimColor: true, children: "\u4EE3\u7801" }) }),
|
|
8734
|
+
/* @__PURE__ */ jsx15(Box15, { width: 16, children: /* @__PURE__ */ jsx15(Text16, { dimColor: true, children: "\u540D\u79F0" }) }),
|
|
8735
|
+
/* @__PURE__ */ jsx15(Box15, { width: 12, children: /* @__PURE__ */ jsx15(Text16, { dimColor: true, children: "\u6700\u65B0\u4EF7" }) }),
|
|
8736
|
+
/* @__PURE__ */ jsx15(Box15, { width: 12, children: /* @__PURE__ */ jsxs15(Text16, { dimColor: true, children: [
|
|
8713
8737
|
"\u6DA8\u8DCC\u5E45",
|
|
8714
8738
|
sortOrder === "desc" ? " \u25BC" : sortOrder === "asc" ? " \u25B2" : ""
|
|
8715
8739
|
] }) }),
|
|
8716
|
-
/* @__PURE__ */
|
|
8717
|
-
/* @__PURE__ */
|
|
8718
|
-
/* @__PURE__ */
|
|
8719
|
-
/* @__PURE__ */
|
|
8740
|
+
/* @__PURE__ */ jsx15(Box15, { width: 12, children: /* @__PURE__ */ jsx15(Text16, { dimColor: true, children: "\u6DA8\u8DCC\u989D" }) }),
|
|
8741
|
+
/* @__PURE__ */ jsx15(Box15, { width: 12, children: /* @__PURE__ */ jsx15(Text16, { dimColor: true, children: "\u6700\u9AD8" }) }),
|
|
8742
|
+
/* @__PURE__ */ jsx15(Box15, { width: 12, children: /* @__PURE__ */ jsx15(Text16, { dimColor: true, children: "\u6700\u4F4E" }) }),
|
|
8743
|
+
/* @__PURE__ */ jsx15(Box15, { children: /* @__PURE__ */ jsx15(Text16, { dimColor: true, children: "\u6210\u4EA4\u989D" }) })
|
|
8720
8744
|
] }),
|
|
8721
|
-
/* @__PURE__ */
|
|
8722
|
-
/* @__PURE__ */
|
|
8745
|
+
/* @__PURE__ */ jsx15(Box15, { children: /* @__PURE__ */ jsx15(Text16, { dimColor: true, children: " " + "\u2500".repeat(100) }) }),
|
|
8746
|
+
/* @__PURE__ */ jsx15(Box15, { flexDirection: "column", children: sortedStocks.map((stock, index) => {
|
|
8723
8747
|
const isSelected = index === selectedIndex;
|
|
8724
8748
|
const isUp = stock.changePercent >= 0;
|
|
8725
8749
|
const color = isUp ? "#ff1493" : "#00ff41";
|
|
8726
|
-
return /* @__PURE__ */
|
|
8727
|
-
/* @__PURE__ */
|
|
8728
|
-
/* @__PURE__ */
|
|
8729
|
-
/* @__PURE__ */
|
|
8730
|
-
/* @__PURE__ */
|
|
8731
|
-
/* @__PURE__ */
|
|
8750
|
+
return /* @__PURE__ */ jsxs15(Box15, { children: [
|
|
8751
|
+
/* @__PURE__ */ jsx15(Box15, { width: 3, flexShrink: 0, children: isSelected ? /* @__PURE__ */ jsx15(Text16, { bold: true, ...cp2("#00ffff"), children: "\u25B8 " }) : /* @__PURE__ */ jsx15(Text16, { children: " " }) }),
|
|
8752
|
+
/* @__PURE__ */ jsx15(Box15, { width: 9, children: /* @__PURE__ */ jsx15(Text16, { bold: true, ...cp2(isSelected ? "#00ffff" : "#ffffff"), children: stock.code }) }),
|
|
8753
|
+
/* @__PURE__ */ jsx15(Box15, { width: 16, children: /* @__PURE__ */ jsx15(Text16, { ...cp2(isSelected ? "#ffffff" : "#cccccc"), children: stock.name }) }),
|
|
8754
|
+
/* @__PURE__ */ jsx15(Box15, { width: 12, children: /* @__PURE__ */ jsx15(Text16, { bold: true, ...cp2(color), children: formatPrice(stock.price) }) }),
|
|
8755
|
+
/* @__PURE__ */ jsx15(Box15, { width: 12, children: /* @__PURE__ */ jsxs15(Text16, { ...cp2(color), children: [
|
|
8732
8756
|
isUp ? "+" : "",
|
|
8733
8757
|
stock.changePercent.toFixed(2),
|
|
8734
8758
|
"%"
|
|
8735
8759
|
] }) }),
|
|
8736
|
-
/* @__PURE__ */
|
|
8760
|
+
/* @__PURE__ */ jsx15(Box15, { width: 12, children: /* @__PURE__ */ jsxs15(Text16, { ...cp2(color), children: [
|
|
8737
8761
|
isUp ? "+" : "",
|
|
8738
8762
|
stock.changeAmount.toFixed(3)
|
|
8739
8763
|
] }) }),
|
|
8740
|
-
/* @__PURE__ */
|
|
8741
|
-
/* @__PURE__ */
|
|
8742
|
-
/* @__PURE__ */
|
|
8764
|
+
/* @__PURE__ */ jsx15(Box15, { width: 12, children: /* @__PURE__ */ jsx15(Text16, { ...cp2("#cccccc"), children: formatPrice(stock.high) }) }),
|
|
8765
|
+
/* @__PURE__ */ jsx15(Box15, { width: 12, children: /* @__PURE__ */ jsx15(Text16, { ...cp2("#888888"), children: formatPrice(stock.low) }) }),
|
|
8766
|
+
/* @__PURE__ */ jsx15(Box15, { children: /* @__PURE__ */ jsx15(Text16, { ...cp2("#888888"), children: formatAmount(stock.amount) }) })
|
|
8743
8767
|
] }, stock.code);
|
|
8744
8768
|
}) }),
|
|
8745
|
-
/* @__PURE__ */
|
|
8746
|
-
/* @__PURE__ */
|
|
8747
|
-
/* @__PURE__ */
|
|
8748
|
-
/* @__PURE__ */
|
|
8769
|
+
/* @__PURE__ */ jsx15(Box15, { marginTop: 1, children: /* @__PURE__ */ jsx15(Text16, { dimColor: true, children: ` \u2191/\u2193 \u9009\u62E9 Enter \u8BE6\u60C5 r \u624B\u52A8\u5237\u65B0 o \u6392\u5E8F h \u7F6E\u7070/\u6062\u590D q \u8FD4\u56DE` }) }),
|
|
8770
|
+
/* @__PURE__ */ jsxs15(Box15, { children: [
|
|
8771
|
+
/* @__PURE__ */ jsx15(Text16, { dimColor: true, children: ` \u6700\u540E\u66F4\u65B0: ${lastUpdate} \u7F16\u8F91\u81EA\u9009\u80A1: ` }),
|
|
8772
|
+
/* @__PURE__ */ jsx15(Text16, { ...cp2("#c792ea"), children: osc8Link(toFileUrl(SETTINGS_PATH), SETTINGS_PATH) })
|
|
8749
8773
|
] }),
|
|
8750
|
-
doubleCtrlC && /* @__PURE__ */
|
|
8774
|
+
doubleCtrlC && /* @__PURE__ */ jsx15(Box15, { marginTop: 1, children: /* @__PURE__ */ jsx15(Text16, { bold: true, ...cp2("#ff1493"), children: " \u26A0 \u518D\u6309\u4E00\u6B21 Ctrl+C \u9000\u51FA dskcode" }) })
|
|
8751
8775
|
] });
|
|
8752
8776
|
}
|
|
8753
8777
|
function renderDetail(stock, _onBack, prices, countdown = 10, currentTime) {
|
|
@@ -8765,33 +8789,33 @@ function renderDetail(stock, _onBack, prices, countdown = 10, currentTime) {
|
|
|
8765
8789
|
raw = raw.replaceAll("\u256D", "\u250C").replaceAll("\u256E", "\u2510").replaceAll("\u2570", "\u2514").replaceAll("\u256F", "\u2518");
|
|
8766
8790
|
chartLines = raw.split("\n");
|
|
8767
8791
|
}
|
|
8768
|
-
return /* @__PURE__ */
|
|
8769
|
-
/* @__PURE__ */
|
|
8770
|
-
/* @__PURE__ */
|
|
8771
|
-
/* @__PURE__ */
|
|
8792
|
+
return /* @__PURE__ */ jsxs15(Box15, { flexDirection: "column", paddingLeft: 1, children: [
|
|
8793
|
+
/* @__PURE__ */ jsxs15(Box15, { marginBottom: 1, justifyContent: "space-between", children: [
|
|
8794
|
+
/* @__PURE__ */ jsxs15(Box15, { children: [
|
|
8795
|
+
/* @__PURE__ */ jsxs15(Text16, { bold: true, color: "#00ffff", children: [
|
|
8772
8796
|
" \u{1F4CA} ",
|
|
8773
8797
|
stock.name,
|
|
8774
8798
|
" "
|
|
8775
8799
|
] }),
|
|
8776
|
-
/* @__PURE__ */
|
|
8777
|
-
currentTime && /* @__PURE__ */
|
|
8800
|
+
/* @__PURE__ */ jsx15(Text16, { dimColor: true, children: stock.code }),
|
|
8801
|
+
currentTime && /* @__PURE__ */ jsxs15(Text16, { dimColor: true, children: [
|
|
8778
8802
|
" \u{1F550} ",
|
|
8779
8803
|
currentTime
|
|
8780
8804
|
] })
|
|
8781
8805
|
] }),
|
|
8782
|
-
/* @__PURE__ */
|
|
8806
|
+
/* @__PURE__ */ jsx15(Text16, { dimColor: true, children: `${countdown}s \u540E\u5237\u65B0` })
|
|
8783
8807
|
] }),
|
|
8784
|
-
/* @__PURE__ */
|
|
8785
|
-
/* @__PURE__ */
|
|
8786
|
-
/* @__PURE__ */
|
|
8808
|
+
/* @__PURE__ */ jsxs15(Box15, { children: [
|
|
8809
|
+
/* @__PURE__ */ jsx15(Box15, { width: 16, children: /* @__PURE__ */ jsx15(Text16, { bold: true, color: "#888888", children: "\u5F53\u524D\u4EF7" }) }),
|
|
8810
|
+
/* @__PURE__ */ jsx15(Box15, { children: /* @__PURE__ */ jsxs15(Text16, { bold: true, color: colorCode, children: [
|
|
8787
8811
|
arrow,
|
|
8788
8812
|
" ",
|
|
8789
8813
|
formatPrice(stock.price)
|
|
8790
8814
|
] }) })
|
|
8791
8815
|
] }),
|
|
8792
|
-
/* @__PURE__ */
|
|
8793
|
-
/* @__PURE__ */
|
|
8794
|
-
/* @__PURE__ */
|
|
8816
|
+
/* @__PURE__ */ jsxs15(Box15, { children: [
|
|
8817
|
+
/* @__PURE__ */ jsx15(Box15, { width: 16, children: /* @__PURE__ */ jsx15(Text16, { color: "#888888", children: "\u6DA8\u8DCC\u5E45" }) }),
|
|
8818
|
+
/* @__PURE__ */ jsx15(Box15, { children: /* @__PURE__ */ jsxs15(Text16, { color: colorCode, children: [
|
|
8795
8819
|
isUp ? "+" : "",
|
|
8796
8820
|
stock.changePercent.toFixed(2),
|
|
8797
8821
|
"%",
|
|
@@ -8800,8 +8824,8 @@ function renderDetail(stock, _onBack, prices, countdown = 10, currentTime) {
|
|
|
8800
8824
|
stock.changeAmount.toFixed(3)
|
|
8801
8825
|
] }) })
|
|
8802
8826
|
] }),
|
|
8803
|
-
chartLines.length > 0 && /* @__PURE__ */
|
|
8804
|
-
/* @__PURE__ */
|
|
8827
|
+
chartLines.length > 0 && /* @__PURE__ */ jsx15(Box15, { marginTop: 1, flexDirection: "column", children: chartLines.map((line, i) => /* @__PURE__ */ jsx15(Box15, { children: /* @__PURE__ */ jsx15(Text16, { color: colorCode, children: line || " " }) }, i)) }),
|
|
8828
|
+
/* @__PURE__ */ jsx15(Box15, { marginTop: 1, children: /* @__PURE__ */ jsx15(Text16, { dimColor: true, children: " Space/q \u8FD4\u56DE\u5217\u8868" }) })
|
|
8805
8829
|
] });
|
|
8806
8830
|
}
|
|
8807
8831
|
|
|
@@ -8886,7 +8910,7 @@ async function scanProjectFiles(baseDir, dir) {
|
|
|
8886
8910
|
}
|
|
8887
8911
|
|
|
8888
8912
|
// src/cli/index.tsx
|
|
8889
|
-
import { jsx as
|
|
8913
|
+
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
8890
8914
|
var SUBCOMMANDS = ["chat", "run", "setup", "init", "completion", "game", "stock"];
|
|
8891
8915
|
function createCli() {
|
|
8892
8916
|
const program2 = new Command();
|
|
@@ -8988,7 +9012,7 @@ compdef _dskcode_completion dskcode`);
|
|
|
8988
9012
|
const freshResult = await loadAndValidate();
|
|
8989
9013
|
const codeList = codes && codes.length > 0 ? codes : freshResult.config.stock?.symbols?.map((s) => s.code) ?? ["sh000001", "sz399006", "sh601688"];
|
|
8990
9014
|
const app = renderApp(
|
|
8991
|
-
/* @__PURE__ */
|
|
9015
|
+
/* @__PURE__ */ jsx16(
|
|
8992
9016
|
StockList,
|
|
8993
9017
|
{
|
|
8994
9018
|
codes: codeList,
|
|
@@ -9017,7 +9041,7 @@ compdef _dskcode_completion dskcode`);
|
|
|
9017
9041
|
}
|
|
9018
9042
|
const selectedGame = await new Promise((resolve2) => {
|
|
9019
9043
|
const { unmount } = render4(
|
|
9020
|
-
/* @__PURE__ */
|
|
9044
|
+
/* @__PURE__ */ jsx16(
|
|
9021
9045
|
GamePicker,
|
|
9022
9046
|
{
|
|
9023
9047
|
games,
|
|
@@ -9057,7 +9081,7 @@ async function startChat(ctx, costTracker) {
|
|
|
9057
9081
|
);
|
|
9058
9082
|
const model = defaultProvider?.model ?? "deepseek-v4-flash";
|
|
9059
9083
|
const chatApp = renderApp(
|
|
9060
|
-
/* @__PURE__ */
|
|
9084
|
+
/* @__PURE__ */ jsx16(
|
|
9061
9085
|
ChatSession,
|
|
9062
9086
|
{
|
|
9063
9087
|
skillCount,
|
|
@@ -9075,7 +9099,7 @@ async function startChat(ctx, costTracker) {
|
|
|
9075
9099
|
initGames();
|
|
9076
9100
|
const games = listGames();
|
|
9077
9101
|
const { unmount } = render4(
|
|
9078
|
-
/* @__PURE__ */
|
|
9102
|
+
/* @__PURE__ */ jsx16(
|
|
9079
9103
|
GamePicker,
|
|
9080
9104
|
{
|
|
9081
9105
|
games,
|
|
@@ -9099,7 +9123,7 @@ async function startChat(ctx, costTracker) {
|
|
|
9099
9123
|
setImmediate(() => {
|
|
9100
9124
|
const defaultStockCodes = ctx?.config.stock?.symbols?.map((s) => s.code) ?? ["sh000001", "sz399006", "sh601688"];
|
|
9101
9125
|
const stockApp = renderApp(
|
|
9102
|
-
/* @__PURE__ */
|
|
9126
|
+
/* @__PURE__ */ jsx16(
|
|
9103
9127
|
StockList,
|
|
9104
9128
|
{
|
|
9105
9129
|
codes: defaultStockCodes,
|