dskcode 0.1.22 → 0.1.23
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 +274 -256
- package/dist/index.js.map +1 -1
- package/package.json +9 -2
package/dist/index.js
CHANGED
|
@@ -814,7 +814,7 @@ var LOGO_LINES = [
|
|
|
814
814
|
];
|
|
815
815
|
|
|
816
816
|
// src/ui/ChatSession.tsx
|
|
817
|
-
import { Box as Box8, Text as
|
|
817
|
+
import { Box as Box8, Text as Text10, useInput, Static } from "ink";
|
|
818
818
|
import TextInput from "ink-text-input";
|
|
819
819
|
import { useEffect as useEffect3, useState as useState3, useCallback as useCallback2, useMemo, useRef as useRef2 } from "react";
|
|
820
820
|
|
|
@@ -850,7 +850,7 @@ function useDoubleCtrlC(onExit) {
|
|
|
850
850
|
import InkSpinner2 from "ink-spinner";
|
|
851
851
|
|
|
852
852
|
// src/ui/AssistantMessage.tsx
|
|
853
|
-
import { Box as Box4, Text as
|
|
853
|
+
import { Box as Box4, Text as Text6 } from "ink";
|
|
854
854
|
|
|
855
855
|
// src/provider/cost-tracker.ts
|
|
856
856
|
import { mkdir as mkdir3, readFile as readFile3, writeFile as writeFile2 } from "fs/promises";
|
|
@@ -1256,8 +1256,82 @@ function formatUsageSummary(usage) {
|
|
|
1256
1256
|
return summary;
|
|
1257
1257
|
}
|
|
1258
1258
|
|
|
1259
|
+
// src/ui/HighlightedText.tsx
|
|
1260
|
+
import { Text as Text5 } from "ink";
|
|
1261
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
1262
|
+
function parseBoldPairs(text) {
|
|
1263
|
+
const segments = [];
|
|
1264
|
+
let current = 0;
|
|
1265
|
+
while (current < text.length) {
|
|
1266
|
+
const openIdx = text.indexOf("**", current);
|
|
1267
|
+
if (openIdx === -1) {
|
|
1268
|
+
segments.push({ text: text.slice(current), type: "plain" });
|
|
1269
|
+
break;
|
|
1270
|
+
}
|
|
1271
|
+
if (openIdx > current) {
|
|
1272
|
+
segments.push({ text: text.slice(current, openIdx), type: "plain" });
|
|
1273
|
+
}
|
|
1274
|
+
const closeIdx = text.indexOf("**", openIdx + 2);
|
|
1275
|
+
if (closeIdx === -1) {
|
|
1276
|
+
segments.push({ text: text.slice(openIdx), type: "plain" });
|
|
1277
|
+
break;
|
|
1278
|
+
}
|
|
1279
|
+
segments.push({ text: text.slice(openIdx + 2, closeIdx), type: "bold" });
|
|
1280
|
+
current = closeIdx + 2;
|
|
1281
|
+
}
|
|
1282
|
+
return segments;
|
|
1283
|
+
}
|
|
1284
|
+
function parseCodePairs(segments) {
|
|
1285
|
+
const result = [];
|
|
1286
|
+
for (const seg of segments) {
|
|
1287
|
+
if (seg.type !== "plain") {
|
|
1288
|
+
result.push(seg);
|
|
1289
|
+
continue;
|
|
1290
|
+
}
|
|
1291
|
+
let current = 0;
|
|
1292
|
+
const text = seg.text;
|
|
1293
|
+
while (current < text.length) {
|
|
1294
|
+
const openIdx = text.indexOf("`", current);
|
|
1295
|
+
if (openIdx === -1) {
|
|
1296
|
+
result.push({ text: text.slice(current), type: "plain" });
|
|
1297
|
+
break;
|
|
1298
|
+
}
|
|
1299
|
+
if (openIdx > current) {
|
|
1300
|
+
result.push({ text: text.slice(current, openIdx), type: "plain" });
|
|
1301
|
+
}
|
|
1302
|
+
const closeIdx = text.indexOf("`", openIdx + 1);
|
|
1303
|
+
if (closeIdx === -1) {
|
|
1304
|
+
result.push({ text: text.slice(openIdx), type: "plain" });
|
|
1305
|
+
break;
|
|
1306
|
+
}
|
|
1307
|
+
result.push({ text: text.slice(openIdx + 1, closeIdx), type: "code" });
|
|
1308
|
+
current = closeIdx + 1;
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
return result;
|
|
1312
|
+
}
|
|
1313
|
+
var CODE_COLOR = "#00BFFF";
|
|
1314
|
+
var BOLD_COLOR = "#A855F7";
|
|
1315
|
+
function HighlightedText({ children: text }) {
|
|
1316
|
+
const boldSegments = parseBoldPairs(text);
|
|
1317
|
+
const segments = parseCodePairs(boldSegments);
|
|
1318
|
+
const isSimple = segments.length === 1 && segments[0].type === "plain";
|
|
1319
|
+
if (isSimple) {
|
|
1320
|
+
return /* @__PURE__ */ jsx4(Text5, { wrap: "wrap", children: text });
|
|
1321
|
+
}
|
|
1322
|
+
return /* @__PURE__ */ jsx4(Text5, { wrap: "wrap", children: segments.map((seg, i) => {
|
|
1323
|
+
if (seg.type === "code") {
|
|
1324
|
+
return /* @__PURE__ */ jsx4(Text5, { color: CODE_COLOR, children: seg.text }, i);
|
|
1325
|
+
}
|
|
1326
|
+
if (seg.type === "bold") {
|
|
1327
|
+
return /* @__PURE__ */ jsx4(Text5, { color: BOLD_COLOR, children: seg.text }, i);
|
|
1328
|
+
}
|
|
1329
|
+
return seg.text;
|
|
1330
|
+
}) });
|
|
1331
|
+
}
|
|
1332
|
+
|
|
1259
1333
|
// src/ui/AssistantMessage.tsx
|
|
1260
|
-
import { jsx as
|
|
1334
|
+
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1261
1335
|
function formatElapsed(ms) {
|
|
1262
1336
|
if (ms < 1e3) return `${ms}ms`;
|
|
1263
1337
|
const seconds = (ms / 1e3).toFixed(1);
|
|
@@ -1277,33 +1351,33 @@ function AssistantMessage({
|
|
|
1277
1351
|
}
|
|
1278
1352
|
return /* @__PURE__ */ jsxs4(Box4, { flexDirection: "column", marginTop: 1, children: [
|
|
1279
1353
|
/* @__PURE__ */ jsxs4(Box4, { flexDirection: "row", children: [
|
|
1280
|
-
/* @__PURE__ */
|
|
1354
|
+
/* @__PURE__ */ jsx5(Box4, { width: 4, flexShrink: 0, children: /* @__PURE__ */ jsx5(Text6, { bold: true, color: "#ff00ff", children: "\u{1F916}" }) }),
|
|
1281
1355
|
/* @__PURE__ */ jsxs4(Box4, { flexGrow: 1, flexDirection: "column", children: [
|
|
1282
|
-
content && /* @__PURE__ */
|
|
1283
|
-
isStreaming && !content && /* @__PURE__ */
|
|
1356
|
+
content && /* @__PURE__ */ jsx5(HighlightedText, { children: content }),
|
|
1357
|
+
isStreaming && !content && /* @__PURE__ */ jsx5(Text6, { color: "#888888", children: "..." })
|
|
1284
1358
|
] })
|
|
1285
1359
|
] }),
|
|
1286
|
-
toolCalls && toolCalls.length > 0 && /* @__PURE__ */
|
|
1360
|
+
toolCalls && toolCalls.length > 0 && /* @__PURE__ */ jsx5(Box4, { flexDirection: "column", children: toolCalls.map((tc, i) => /* @__PURE__ */ jsx5(ToolCallBlock, { call: tc }, tc.id ?? i)) }),
|
|
1287
1361
|
!isStreaming && (usage || elapsed !== void 0) && /* @__PURE__ */ jsxs4(Box4, { flexDirection: "column", marginTop: 1, marginLeft: 3, children: [
|
|
1288
|
-
/* @__PURE__ */
|
|
1362
|
+
/* @__PURE__ */ jsx5(Text6, { color: "#555555", children: "\u2500".repeat(36) }),
|
|
1289
1363
|
/* @__PURE__ */ jsxs4(Box4, { flexDirection: "row", gap: 2, children: [
|
|
1290
|
-
cost !== void 0 && cost > 0 && /* @__PURE__ */ jsxs4(
|
|
1364
|
+
cost !== void 0 && cost > 0 && /* @__PURE__ */ jsxs4(Text6, { color: "yellow", children: [
|
|
1291
1365
|
"\u{1F4B0} \u672C\u6B21 ",
|
|
1292
1366
|
formatMoney(cost)
|
|
1293
1367
|
] }),
|
|
1294
|
-
elapsed !== void 0 && /* @__PURE__ */ jsxs4(
|
|
1368
|
+
elapsed !== void 0 && /* @__PURE__ */ jsxs4(Text6, { color: "cyan", children: [
|
|
1295
1369
|
"\u{1F550} ",
|
|
1296
1370
|
formatElapsed(elapsed)
|
|
1297
1371
|
] }),
|
|
1298
|
-
usage && /* @__PURE__ */
|
|
1372
|
+
usage && /* @__PURE__ */ jsx5(Text6, { color: "#888888", children: formatUsageSummary(usage) })
|
|
1299
1373
|
] })
|
|
1300
1374
|
] })
|
|
1301
1375
|
] });
|
|
1302
1376
|
}
|
|
1303
1377
|
|
|
1304
1378
|
// src/ui/DiffPreview.tsx
|
|
1305
|
-
import { Box as Box5, Text as
|
|
1306
|
-
import { jsx as
|
|
1379
|
+
import { Box as Box5, Text as Text7 } from "ink";
|
|
1380
|
+
import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1307
1381
|
function DiffPreview({ diff }) {
|
|
1308
1382
|
const { patch, additions, deletions, existedBefore, filePath } = diff;
|
|
1309
1383
|
if (!patch || patch.length === 0) {
|
|
@@ -1313,13 +1387,13 @@ function DiffPreview({ diff }) {
|
|
|
1313
1387
|
const fileName = filePath.replace(/\\/g, "/").split("/").pop() ?? filePath;
|
|
1314
1388
|
return /* @__PURE__ */ jsxs5(Box5, { flexDirection: "column", marginTop: 1, children: [
|
|
1315
1389
|
/* @__PURE__ */ jsxs5(Box5, { flexDirection: "row", gap: 1, children: [
|
|
1316
|
-
/* @__PURE__ */ jsxs5(
|
|
1390
|
+
/* @__PURE__ */ jsxs5(Text7, { bold: true, color: "#00ffff", children: [
|
|
1317
1391
|
"\u{1F4DD} ",
|
|
1318
1392
|
existedBefore ? "\u4FEE\u6539" : "\u65B0\u5EFA",
|
|
1319
1393
|
":"
|
|
1320
1394
|
] }),
|
|
1321
|
-
/* @__PURE__ */
|
|
1322
|
-
/* @__PURE__ */ jsxs5(
|
|
1395
|
+
/* @__PURE__ */ jsx6(Text7, { bold: true, children: fileName }),
|
|
1396
|
+
/* @__PURE__ */ jsxs5(Text7, { color: "#555555", children: [
|
|
1323
1397
|
"(+",
|
|
1324
1398
|
additions,
|
|
1325
1399
|
" -",
|
|
@@ -1327,7 +1401,7 @@ function DiffPreview({ diff }) {
|
|
|
1327
1401
|
")"
|
|
1328
1402
|
] })
|
|
1329
1403
|
] }),
|
|
1330
|
-
/* @__PURE__ */
|
|
1404
|
+
/* @__PURE__ */ jsx6(Box5, { flexDirection: "column", marginLeft: 2, children: lines.filter((line) => !line.startsWith("---") && !line.startsWith("+++")).map((line, i) => /* @__PURE__ */ jsx6(DiffLine, { line }, i)) })
|
|
1331
1405
|
] });
|
|
1332
1406
|
}
|
|
1333
1407
|
function DiffLine({ line }) {
|
|
@@ -1335,20 +1409,20 @@ function DiffLine({ line }) {
|
|
|
1335
1409
|
return null;
|
|
1336
1410
|
}
|
|
1337
1411
|
if (line.startsWith("@@")) {
|
|
1338
|
-
return /* @__PURE__ */
|
|
1412
|
+
return /* @__PURE__ */ jsx6(Text7, { color: "#00cccc", children: line });
|
|
1339
1413
|
}
|
|
1340
1414
|
if (line.startsWith("+")) {
|
|
1341
|
-
return /* @__PURE__ */
|
|
1415
|
+
return /* @__PURE__ */ jsx6(Text7, { color: "#22c55e", children: line });
|
|
1342
1416
|
}
|
|
1343
1417
|
if (line.startsWith("-")) {
|
|
1344
|
-
return /* @__PURE__ */
|
|
1418
|
+
return /* @__PURE__ */ jsx6(Text7, { color: "#ef4444", children: line });
|
|
1345
1419
|
}
|
|
1346
|
-
return /* @__PURE__ */
|
|
1420
|
+
return /* @__PURE__ */ jsx6(Text7, { color: "#6b7280", children: line });
|
|
1347
1421
|
}
|
|
1348
1422
|
|
|
1349
1423
|
// src/ui/SkillSelector.tsx
|
|
1350
|
-
import { Box as Box6, Text as
|
|
1351
|
-
import { jsx as
|
|
1424
|
+
import { Box as Box6, Text as Text8 } from "ink";
|
|
1425
|
+
import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1352
1426
|
var HIGHLIGHT_COLOR = "#00bfff";
|
|
1353
1427
|
function SkillSelector({ skills, input, selectedIndex }) {
|
|
1354
1428
|
const match = input.match(/(?:^|\s)\/([^/]*)$/);
|
|
@@ -1359,18 +1433,18 @@ function SkillSelector({ skills, input, selectedIndex }) {
|
|
|
1359
1433
|
if (query && matched.length > 0 && matched.some((s) => s.name.toLowerCase() === query)) return null;
|
|
1360
1434
|
if (matched.length === 0) return null;
|
|
1361
1435
|
return /* @__PURE__ */ jsxs6(Box6, { flexDirection: "column", marginLeft: 4, marginTop: 1, children: [
|
|
1362
|
-
/* @__PURE__ */
|
|
1363
|
-
matched.map((skill, i) => /* @__PURE__ */
|
|
1436
|
+
/* @__PURE__ */ jsx7(Text8, { color: "#808080", dimColor: true, children: "\u652F\u6301\u7684 Skill\uFF1A" }),
|
|
1437
|
+
matched.map((skill, i) => /* @__PURE__ */ jsx7(Box6, { children: /* @__PURE__ */ jsxs6(Text8, { color: i === selectedIndex ? HIGHLIGHT_COLOR : "#808080", children: [
|
|
1364
1438
|
i === selectedIndex ? " \u203A " : " ",
|
|
1365
1439
|
skill.name
|
|
1366
1440
|
] }) }, skill.name)),
|
|
1367
|
-
/* @__PURE__ */
|
|
1441
|
+
/* @__PURE__ */ jsx7(Box6, { marginTop: 1, children: /* @__PURE__ */ jsx7(Text8, { color: "#808080", dimColor: true, children: "\u2191\u2193 \u9009\u62E9 \xB7 Tab \u8865\u5168" }) })
|
|
1368
1442
|
] });
|
|
1369
1443
|
}
|
|
1370
1444
|
|
|
1371
1445
|
// src/ui/FileSelector.tsx
|
|
1372
|
-
import { Box as Box7, Text as
|
|
1373
|
-
import { jsx as
|
|
1446
|
+
import { Box as Box7, Text as Text9 } from "ink";
|
|
1447
|
+
import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1374
1448
|
var HIGHLIGHT_COLOR2 = "#00ff41";
|
|
1375
1449
|
function FileSelector({ files, input, selectedIndex }) {
|
|
1376
1450
|
const match = input.match(/(?:^|\s)@([^@]*)$/);
|
|
@@ -1381,12 +1455,12 @@ function FileSelector({ files, input, selectedIndex }) {
|
|
|
1381
1455
|
if (query && matched.some((f) => f.toLowerCase() === query)) return null;
|
|
1382
1456
|
if (matched.length === 0) return null;
|
|
1383
1457
|
return /* @__PURE__ */ jsxs7(Box7, { flexDirection: "column", marginLeft: 4, marginTop: 1, children: [
|
|
1384
|
-
/* @__PURE__ */
|
|
1385
|
-
matched.map((file, i) => /* @__PURE__ */
|
|
1458
|
+
/* @__PURE__ */ jsx8(Text9, { color: "#808080", dimColor: true, children: "\u9879\u76EE\u6587\u4EF6\uFF1A" }),
|
|
1459
|
+
matched.map((file, i) => /* @__PURE__ */ jsx8(Box7, { children: /* @__PURE__ */ jsxs7(Text9, { color: i === selectedIndex ? HIGHLIGHT_COLOR2 : "#808080", children: [
|
|
1386
1460
|
i === selectedIndex ? " \u203A " : " ",
|
|
1387
1461
|
file
|
|
1388
1462
|
] }) }, file)),
|
|
1389
|
-
/* @__PURE__ */
|
|
1463
|
+
/* @__PURE__ */ jsx8(Box7, { marginTop: 1, children: /* @__PURE__ */ jsx8(Text9, { color: "#808080", dimColor: true, children: "\u2191\u2193 \u9009\u62E9 \xB7 Tab \u8865\u5168" }) })
|
|
1390
1464
|
] });
|
|
1391
1465
|
}
|
|
1392
1466
|
|
|
@@ -1479,102 +1553,45 @@ var AlwaysAllowGate = class {
|
|
|
1479
1553
|
}
|
|
1480
1554
|
};
|
|
1481
1555
|
|
|
1482
|
-
// src/agent/
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
"\u8BF7\u4E25\u683C\u9075\u5B88\u4EE5\u4E0B\u683C\u5F0F\u89C4\u5219\u3002",
|
|
1488
|
-
"",
|
|
1489
|
-
"\u4E00\u3001\u7981\u6B62\u4F7F\u7528\u7684\u7B26\u53F7",
|
|
1490
|
-
" - \u4E0D\u8981\u4F7F\u7528 Markdown \u6807\u9898\u7B26\u53F7\uFF08\u5355\u72EC\u6216\u8FDE\u7EED\u7684\u4E95\u53F7\uFF09",
|
|
1491
|
-
" - \u4E0D\u8981\u4F7F\u7528\u7C97\u4F53\u6216\u659C\u4F53\u7B26\u53F7\uFF08\u661F\u53F7\u3001\u4E0B\u5212\u7EBF\uFF09",
|
|
1492
|
-
" - \u4E0D\u8981\u4F7F\u7528\u4EE3\u7801\u5757\u6807\u8BB0\uFF08\u8FDE\u7EED\u4E09\u4E2A\u53CD\u5F15\u53F7\uFF09",
|
|
1493
|
-
" - \u4E0D\u8981\u4F7F\u7528\u5757\u5F15\u7528\u7B26\u53F7\uFF08\u5927\u4E8E\u53F7\uFF09",
|
|
1494
|
-
" - \u4E0D\u8981\u4F7F\u7528\u5206\u9694\u7EBF\uFF08\u8FDE\u7EED\u4E09\u4E2A\u51CF\u53F7\u6216\u661F\u53F7\uFF09",
|
|
1495
|
-
" - \u4E0D\u8981\u4F7F\u7528\u884C\u5185\u4EE3\u7801\u6807\u8BB0\uFF08\u5355\u4E2A\u53CD\u5F15\u53F7\uFF09",
|
|
1496
|
-
"",
|
|
1497
|
-
"\u4E8C\u3001\u63A8\u8350\u7684\u7EC4\u7EC7\u65B9\u5F0F",
|
|
1498
|
-
' - \u7528\u7EAF\u6587\u5B57\u63CF\u8FF0\u5C42\u7EA7\uFF0C\u4F8B\u5982"\u7B2C\u4E00\u70B9"\u3001"\u7B2C\u4E8C\u70B9"\u66FF\u4EE3\u6807\u9898\u7B26\u53F7',
|
|
1499
|
-
" - \u7528 emoji \u7B26\u53F7\u505A\u89C6\u89C9\u6807\u8BB0\uFF08\u5982 \u{1F4CC} \u{1F4E6} \u{1F4DD} \u26A0\uFE0F \u7B49\uFF09",
|
|
1500
|
-
" - \u7528\u6570\u5B57\u5E8F\u53F7\uFF081. 2. 3.\uFF09\u7EC4\u7EC7\u5217\u8868",
|
|
1501
|
-
" - \u4EE3\u7801\u793A\u4F8B\u7528\u7F29\u8FDB\uFF08\u6BCF\u884C\u524D\u52A0 4 \u4E2A\u7A7A\u683C\uFF09\u66FF\u4EE3\u4EE3\u7801\u5757\u6807\u8BB0",
|
|
1502
|
-
" - \u6587\u4EF6\u8DEF\u5F84\u3001\u547D\u4EE4\u3001\u53D8\u91CF\u540D\u76F4\u63A5\u4E66\u5199\uFF0C\u4E0D\u8981\u7528\u4EFB\u4F55\u7B26\u53F7\u5305\u88F9",
|
|
1503
|
-
"",
|
|
1504
|
-
"\u4E09\u3001\u6B63\u786E\u683C\u5F0F\u793A\u4F8B",
|
|
1505
|
-
"",
|
|
1506
|
-
" \u7B2C\u4E00\u70B9\uFF1A\u4F18\u5316\u6570\u636E\u5E93\u67E5\u8BE2",
|
|
1507
|
-
" 1. \u6DFB\u52A0\u7D22\u5F15\u5230 user_id \u5B57\u6BB5",
|
|
1508
|
-
" 2. \u7528\u8FDE\u63A5\u6C60\u66FF\u4EE3\u77ED\u8FDE\u63A5",
|
|
1509
|
-
"",
|
|
1510
|
-
" \u4EE3\u7801\u793A\u4F8B\uFF1A",
|
|
1511
|
-
" const pool = new Pool({ max: 20 });",
|
|
1512
|
-
' await pool.query("SELECT * FROM users");',
|
|
1513
|
-
"",
|
|
1514
|
-
" \u8F93\u51FA\u63D0\u793A\uFF1A",
|
|
1515
|
-
" \u{1F4CC} \u4F18\u5316\u524D\uFF1A\u67E5\u8BE2\u8017\u65F6 3.2 \u79D2",
|
|
1516
|
-
"",
|
|
1517
|
-
"\u56DB\u3001\u9519\u8BEF\u683C\u5F0F\u793A\u4F8B\uFF08\u7981\u6B62\u8FD9\u6837\u5199\uFF09",
|
|
1518
|
-
"",
|
|
1519
|
-
" \u4E95\u53F7\u4E32 \u4F18\u5316\u6570\u636E\u5E93\u67E5\u8BE2\uFF08\u8FD9\u662F\u9519\u8BEF\u7684\uFF09",
|
|
1520
|
-
" \u661F\u53F7 \u6DFB\u52A0\u7D22\u5F15\u5230 user_id \u5B57\u6BB5\uFF08\u8FD9\u662F\u9519\u8BEF\u7684\uFF09",
|
|
1521
|
-
" \u4E09\u4E2A\u53CD\u5F15\u53F7\u5F00\u59CB\u6216\u7ED3\u675F\uFF08\u8FD9\u662F\u9519\u8BEF\u7684\uFF09",
|
|
1522
|
-
"",
|
|
1523
|
-
"\u6CE8\u610F\uFF1A\u4E0A\u8FF0\u793A\u4F8B\u4E2D\u7684\u9519\u8BEF\u5199\u6CD5\u4EC5\u4F5C\u4E3A\u8BF4\u660E\uFF0C\u4F60\u7684\u56DE\u590D\u4E2D\u4E0D\u8981\u51FA\u73B0\u8FD9\u4E9B\u683C\u5F0F\u3002"
|
|
1524
|
-
].join("\n");
|
|
1556
|
+
// src/agent/system-prompt.ts
|
|
1557
|
+
import Handlebars from "handlebars";
|
|
1558
|
+
|
|
1559
|
+
// src/agent/prompts/system-prompt.hbs
|
|
1560
|
+
var system_prompt_default = '\u4F60\u662F dskcode\uFF0C\u4E00\u4E2A\u57FA\u4E8E DeepSeek \u7684 AI \u7F16\u7A0B\u52A9\u624B\uFF0C\u8FD0\u884C\u5728\u7528\u6237\u7EC8\u7AEF\u4E2D\u3002\u4F60\u7684\u804C\u8D23\u662F\u5E2E\u52A9\u5F00\u53D1\u8005\u7F16\u5199\u3001\u7406\u89E3\u3001\u8C03\u8BD5\u548C\u91CD\u6784\u4EE3\u7801\u3002\r\n\r\n## \u6838\u5FC3\u539F\u5219\r\n- \u56DE\u7B54\u4F7F\u7528\u4E2D\u6587\uFF0C\u4EE3\u7801\u6807\u8BC6\u7B26\u4FDD\u6301\u82F1\u6587\r\n- \u63D0\u4F9B\u51C6\u786E\u3001\u5B9E\u7528\u3001\u53EF\u64CD\u4F5C\u7684\u5EFA\u8BAE\r\n- \u5BF9\u4E0D\u786E\u5B9A\u7684\u5185\u5BB9\u660E\u786E\u6807\u6CE8\uFF0C\u4E0D\u7F16\u9020\u4E8B\u5B9E\r\n- \u4EE3\u7801\u793A\u4F8B\u4FDD\u6301\u7B80\u6D01\uFF0C\u9644\u5E26\u5FC5\u8981\u7684\u6CE8\u91CA\r\n\r\n## \u5DE5\u4F5C\u6D41\u7A0B\r\n\r\n\u4F60\u5904\u4E8E\u4E00\u4E2A\u5DE5\u5177\u8C03\u7528\u5FAA\u73AF\u4E2D\uFF1A\r\n1. \u6536\u5230\u7528\u6237\u8BF7\u6C42\r\n2. \u8C03\u7528\u5DE5\u5177\u83B7\u53D6\u4FE1\u606F\u6216\u4FEE\u6539\u6587\u4EF6\r\n3. \u5DE5\u5177\u7ED3\u679C\u8FD4\u56DE\u7ED9\u4F60\r\n4. \u6839\u636E\u7ED3\u679C\u51B3\u5B9A\u4E0B\u4E00\u6B65\uFF08\u7EE7\u7EED\u8C03\u7528\u5DE5\u5177\u6216\u7ED9\u51FA\u6700\u7EC8\u56DE\u7B54\uFF09\r\n5. \u4E00\u8F6E\u6700\u591A {{maxToolRounds}} \u6B21\u5DE5\u5177\u8C03\u7528\r\n\r\n## \u5DE5\u5177\u4F7F\u7528\u7B56\u7565\r\n\r\n{{#if tools}}\r\n\u5F53\u524D\u53EF\u7528\u7684\u5DE5\u5177\uFF1A\r\n{{#each tools}}\r\n- **{{name}}**\uFF1A{{description}}{{#if params}}\uFF08\u53C2\u6570\uFF1A{{params}}\uFF09{{/if}}\r\n{{/each}}\r\n\r\n\u4F7F\u7528\u539F\u5219\uFF1A\r\n- **\u5148\u641C\u7D22\u518D\u8BFB\u53D6** \u2014 \u4E0D\u786E\u5B9A\u76EE\u6807\u4F4D\u7F6E\u65F6\u5148\u7528 grep/glob \u5B9A\u4F4D\uFF0C\u518D\u7528 read_file \u8BFB\u53D6\r\n- **\u5148\u8BFB\u53D6\u518D\u4FEE\u6539** \u2014 \u7F16\u8F91\u6587\u4EF6\u524D\u5148 read_file \u786E\u8BA4\u5F53\u524D\u5185\u5BB9\r\n- **\u6279\u91CF\u64CD\u4F5C\u4E00\u6B21\u5B8C\u6210** \u2014 \u540C\u4E00\u6587\u4EF6\u7684\u591A\u5904\u6539\u52A8\u5728\u5355\u6B21 edit_file \u4E2D\u5B8C\u6210\r\n- **\u5DE5\u5177\u51FA\u9519\u65F6** \u2014 \u5206\u6790\u9519\u8BEF\u539F\u56E0\uFF08\u8DEF\u5F84\u4E0D\u5BF9\uFF1F\u683C\u5F0F\u4E0D\u5BF9\uFF1F\u6743\u9650\u4E0D\u8DB3\uFF1F\uFF09\uFF0C\u4FEE\u6B63\u540E\u91CD\u8BD5\uFF0C\u4E0D\u8981\u91CD\u590D\u76F8\u540C\u7684\u9519\u8BEF\u8C03\u7528\r\n- **\u5BA1\u614E\u6267\u884C** \u2014 bash \u6267\u884C\u5371\u9669\u547D\u4EE4\uFF08rm -rf\u3001\u5F3A\u5236\u5199\u5165\u7B49\uFF09\u524D\u5148\u786E\u8BA4\r\n{{/if}}\r\n\r\n{{#if projectContext}}\r\n## \u9879\u76EE\u4E0A\u4E0B\u6587\r\n\r\n{{projectContext}}\r\n{{/if}}\r\n\r\n## \u56DE\u7B54\u683C\u5F0F\r\n\r\n\u7EC8\u7AEF\u4E0D\u652F\u6301 Markdown \u6E32\u67D3\u3002\u56DE\u590D\u683C\u5F0F\u8981\u6C42\uFF1A\r\n\r\n- \u7528 emoji \u505A\u89C6\u89C9\u6807\u8BB0\uFF08\u{1F4CC} \u8981\u70B9 \u26A0\uFE0F \u6CE8\u610F \u{1F4DD} \u5F85\u529E \u2705 \u5B8C\u6210\uFF09\r\n- \u7528\u6570\u5B57\u5E8F\u53F7\u6216\u77ED\u6A2A\u7EBF\u7EC4\u7EC7\u5217\u8868\r\n- \u4EE3\u7801\u6807\u8BC6\u7B26\u3001\u6587\u4EF6\u8DEF\u5F84\u3001\u7C7B\u578B\u540D\u7528\u5355\u4E2A\u53CD\u5F15\u53F7 ` \u5305\u88F9\uFF0C\u4F1A\u88AB\u81EA\u52A8\u9AD8\u4EAE\r\n- \u5F3A\u8C03\u5185\u5BB9\u7528 **\u52A0\u7C97** \u5305\u88F9\uFF0C\u4F1A\u88AB\u81EA\u52A8\u9AD8\u4EAE\r\n- \u591A\u884C\u4EE3\u7801\u7528\u7F29\u8FDB 4 \u4E2A\u7A7A\u683C\u8868\u793A\uFF0C\u4E0D\u8981\u7528\u4E09\u53CD\u5F15\u53F7\u4EE3\u7801\u5757\r\n- \u6BB5\u843D\u95F4\u7528\u7A7A\u884C\u5206\u9694\uFF0C\u4E0D\u8981\u7528\u6807\u9898\u7B26\u53F7\r\n\r\n\u6B63\u786E\u793A\u4F8B\uFF1A\r\n\r\n\u{1F4CC} \u9700\u8981\u4FEE\u6539\u4E24\u4E2A\u5730\u65B9\uFF1A\r\n1. \u7B2C 12 \u884C\u7684 `interface FileDiff` \u6539\u4E3A `interface Diff`\r\n2. \u7B2C 432 \u884C\u7684 `): FileDiff` \u6539\u4E3A `): Diff`\r\n\r\n \u4EE3\u7801\u793A\u4F8B\uFF1A\r\n const pool = new Pool({ max: 20 });\r\n await pool.query("SELECT * FROM users");\r\n\r\n## \u884C\u4E3A\u7EA6\u675F\r\n- \u5982\u679C\u7528\u6237\u8BF7\u6C42\u4E0D\u660E\u786E\uFF0C\u4E3B\u52A8\u8BE2\u95EE\u6F84\u6E05\r\n- \u5BF9\u4E0D\u786E\u5B9A\u7684\u4FE1\u606F\u660E\u786E\u6807\u6CE8\uFF0C\u4E0D\u7F16\u9020\u4E8B\u5B9E\r\n- \u4E0D\u6267\u884C\u53EF\u80FD\u9020\u6210\u4E0D\u53EF\u9006\u635F\u5BB3\u7684\u64CD\u4F5C\uFF08\u5982 rm -rf\uFF09\uFF0C\u9664\u975E\u7528\u6237\u660E\u786E\u9010\u6761\u786E\u8BA4\r\n- \u5DE5\u5177\u8C03\u7528\u8FD4\u56DE\u9519\u8BEF\u65F6\uFF0C\u5148\u5206\u6790\u539F\u56E0\u518D\u91CD\u8BD5\uFF0C\u4E0D\u8981\u76F2\u76EE\u91CD\u8BD5\r\n\r\n## \u5F53\u524D\u6A21\u578B\r\n- \u6A21\u578B\uFF1A{{model}}\r\n\r\n## \u65F6\u95F4\u4E0A\u4E0B\u6587\r\n- \u5F53\u524D\u65E5\u671F\uFF1A{{date}}\r\n- \u5F53\u524D\u65F6\u95F4\uFF1A{{time}}\r\n- \u5DE5\u4F5C\u76EE\u5F55\uFF1A{{cwd}}\r\n';
|
|
1525
1561
|
|
|
1526
1562
|
// src/agent/system-prompt.ts
|
|
1563
|
+
var compiledTemplate = Handlebars.compile(system_prompt_default);
|
|
1564
|
+
function formatTools(tools) {
|
|
1565
|
+
return tools.map((t) => {
|
|
1566
|
+
const params = t.parameters && Object.keys(t.parameters.properties ?? {}).join(", ");
|
|
1567
|
+
return {
|
|
1568
|
+
name: t.name,
|
|
1569
|
+
description: t.description,
|
|
1570
|
+
params: params || void 0
|
|
1571
|
+
};
|
|
1572
|
+
});
|
|
1573
|
+
}
|
|
1527
1574
|
function buildSystemPrompt(opts) {
|
|
1528
|
-
const sections = [];
|
|
1529
|
-
sections.push(`\u4F60\u662F dskcode\uFF0C\u4E00\u4E2A\u57FA\u4E8E DeepSeek \u7684 AI \u7F16\u7A0B\u52A9\u624B\uFF0C\u8FD0\u884C\u5728\u7528\u6237\u7EC8\u7AEF\u4E2D\u3002\u4F60\u7684\u804C\u8D23\u662F\u5E2E\u52A9\u5F00\u53D1\u8005\u7F16\u5199\u3001\u7406\u89E3\u3001\u8C03\u8BD5\u548C\u91CD\u6784\u4EE3\u7801\u3002
|
|
1530
|
-
|
|
1531
|
-
## \u6838\u5FC3\u539F\u5219
|
|
1532
|
-
- \u56DE\u7B54\u4F7F\u7528\u4E2D\u6587\uFF0C\u4EE3\u7801\u6807\u8BC6\u7B26\u4FDD\u6301\u82F1\u6587
|
|
1533
|
-
- \u63D0\u4F9B\u51C6\u786E\u3001\u5B9E\u7528\u3001\u53EF\u64CD\u4F5C\u7684\u5EFA\u8BAE
|
|
1534
|
-
- \u5BF9\u4E0D\u786E\u5B9A\u7684\u5185\u5BB9\u660E\u786E\u6807\u6CE8\uFF0C\u4E0D\u7F16\u9020\u4E8B\u5B9E
|
|
1535
|
-
- \u4EE3\u7801\u793A\u4F8B\u4FDD\u6301\u7B80\u6D01\uFF0C\u9644\u5E26\u5FC5\u8981\u7684\u6CE8\u91CA`);
|
|
1536
|
-
sections.push(`## \u5F53\u524D\u6A21\u578B
|
|
1537
|
-
- \u6A21\u578B\uFF1A${opts.model}`);
|
|
1538
1575
|
const now = /* @__PURE__ */ new Date();
|
|
1539
|
-
const
|
|
1576
|
+
const date = now.toLocaleDateString("zh-CN", {
|
|
1540
1577
|
year: "numeric",
|
|
1541
1578
|
month: "long",
|
|
1542
1579
|
day: "numeric",
|
|
1543
1580
|
weekday: "long"
|
|
1544
1581
|
});
|
|
1545
|
-
const
|
|
1582
|
+
const time = now.toLocaleTimeString("zh-CN", {
|
|
1546
1583
|
hour: "2-digit",
|
|
1547
1584
|
minute: "2-digit"
|
|
1548
1585
|
});
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
sections.push(`## \u53EF\u7528\u5DE5\u5177
|
|
1559
|
-
|
|
1560
|
-
\u4F60\u53EF\u4EE5\u901A\u8FC7\u5DE5\u5177\u8C03\u7528\u6267\u884C\u64CD\u4F5C\u3002\u5F53\u524D\u53EF\u7528\u7684\u5DE5\u5177\uFF1A
|
|
1561
|
-
|
|
1562
|
-
${toolLines}
|
|
1563
|
-
|
|
1564
|
-
\u8C03\u7528\u5DE5\u5177\u65F6\uFF0C\u8BF7\u4F7F\u7528\u6807\u51C6 function_call \u683C\u5F0F\u3002\u5DE5\u5177\u5C06\u7531\u7CFB\u7EDF\u6267\u884C\u5E76\u8FD4\u56DE\u7ED3\u679C\u3002`);
|
|
1565
|
-
}
|
|
1566
|
-
if (opts.projectContext) {
|
|
1567
|
-
sections.push(`## \u9879\u76EE\u4E0A\u4E0B\u6587
|
|
1568
|
-
|
|
1569
|
-
${opts.projectContext}`);
|
|
1570
|
-
}
|
|
1571
|
-
sections.push(`## \u884C\u4E3A\u7EA6\u675F
|
|
1572
|
-
- \u5982\u679C\u7528\u6237\u8BF7\u6C42\u4E0D\u660E\u786E\uFF0C\u8BF7\u4E3B\u52A8\u8BE2\u95EE\u6F84\u6E05
|
|
1573
|
-
- \u6D89\u53CA\u6587\u4EF6\u64CD\u4F5C\u65F6\uFF0C\u5148\u786E\u8BA4\u6587\u4EF6\u8DEF\u5F84
|
|
1574
|
-
- \u4E0D\u6267\u884C\u53EF\u80FD\u9020\u6210\u4E0D\u53EF\u9006\u635F\u5BB3\u7684\u64CD\u4F5C\uFF08\u5982 rm -rf\uFF09\u9664\u975E\u7528\u6237\u660E\u786E\u786E\u8BA4
|
|
1575
|
-
- \u5F53\u5DE5\u5177\u8C03\u7528\u8FD4\u56DE\u9519\u8BEF\u65F6\uFF0C\u5206\u6790\u539F\u56E0\u5E76\u5C1D\u8BD5\u4FEE\u590D`);
|
|
1576
|
-
sections.push(EXTRA_PROMPT);
|
|
1577
|
-
return sections.join("\n\n");
|
|
1586
|
+
return compiledTemplate({
|
|
1587
|
+
model: opts.model,
|
|
1588
|
+
maxToolRounds: opts.maxToolRounds,
|
|
1589
|
+
cwd: opts.cwd,
|
|
1590
|
+
date,
|
|
1591
|
+
time,
|
|
1592
|
+
tools: opts.tools ? formatTools(opts.tools) : void 0,
|
|
1593
|
+
projectContext: opts.projectContext ?? void 0
|
|
1594
|
+
});
|
|
1578
1595
|
}
|
|
1579
1596
|
|
|
1580
1597
|
// src/tool/registry.ts
|
|
@@ -2058,6 +2075,7 @@ ${item.result.diff.patch}`;
|
|
|
2058
2075
|
}));
|
|
2059
2076
|
const opts = {
|
|
2060
2077
|
model: this.#provider.model(),
|
|
2078
|
+
maxToolRounds: this.#options.maxToolRounds,
|
|
2061
2079
|
tools: toolDescs.length > 0 ? toolDescs : void 0,
|
|
2062
2080
|
projectContext: this.#options.projectContext ?? void 0,
|
|
2063
2081
|
cwd: this.#options.cwd
|
|
@@ -3529,7 +3547,7 @@ function getGradientColors(text, phase, stops) {
|
|
|
3529
3547
|
}
|
|
3530
3548
|
|
|
3531
3549
|
// src/ui/ChatSession.tsx
|
|
3532
|
-
import { Fragment, jsx as
|
|
3550
|
+
import { Fragment, jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
3533
3551
|
var commandRegistry = /* @__PURE__ */ new Map();
|
|
3534
3552
|
function registerCommand(name, cmd) {
|
|
3535
3553
|
commandRegistry.set(name, cmd);
|
|
@@ -4110,33 +4128,33 @@ function ChatSession({
|
|
|
4110
4128
|
}, [isStreaming, externalCostTracker]);
|
|
4111
4129
|
return /* @__PURE__ */ jsxs8(Box8, { flexDirection: "column", paddingLeft: 1, paddingRight: 1, children: [
|
|
4112
4130
|
!hasConversationStarted && /* @__PURE__ */ jsxs8(Box8, { flexDirection: "row", marginBottom: 1, children: [
|
|
4113
|
-
/* @__PURE__ */
|
|
4131
|
+
/* @__PURE__ */ jsx9(Box8, { flexDirection: "column", marginRight: 4, children: LOGO_LINES.map((line, i) => {
|
|
4114
4132
|
const colorIndex = (i + offset) % CYBER_PALETTE.length;
|
|
4115
|
-
return /* @__PURE__ */
|
|
4133
|
+
return /* @__PURE__ */ jsx9(Box8, { children: /* @__PURE__ */ jsx9(Text10, { bold: true, color: CYBER_PALETTE[colorIndex], children: line }) }, i);
|
|
4116
4134
|
}) }),
|
|
4117
4135
|
/* @__PURE__ */ jsxs8(Box8, { flexDirection: "column", justifyContent: "center", children: [
|
|
4118
|
-
/* @__PURE__ */ jsxs8(
|
|
4136
|
+
/* @__PURE__ */ jsxs8(Text10, { color: "#00ff41", children: [
|
|
4119
4137
|
" \u2714 ",
|
|
4120
4138
|
"\u5DF2\u5C31\u7EEA ",
|
|
4121
4139
|
skillCount,
|
|
4122
4140
|
" \u4E2A Skill"
|
|
4123
4141
|
] }),
|
|
4124
|
-
/* @__PURE__ */ jsxs8(
|
|
4142
|
+
/* @__PURE__ */ jsxs8(Text10, { color: "#00ffff", children: [
|
|
4125
4143
|
" \u2139 ",
|
|
4126
4144
|
"\u5DF2\u5C31\u7EEA ",
|
|
4127
4145
|
toolCount,
|
|
4128
4146
|
" \u4E2A\u5DE5\u5177"
|
|
4129
4147
|
] }),
|
|
4130
|
-
/* @__PURE__ */ jsxs8(
|
|
4148
|
+
/* @__PURE__ */ jsxs8(Text10, { color: "#00ffff", children: [
|
|
4131
4149
|
" \u{1F527} \u6A21\u578B ",
|
|
4132
4150
|
SUPPORTED_MODELS[activeModel]?.displayName ?? activeModel
|
|
4133
4151
|
] }),
|
|
4134
|
-
thinkingEnabled && /* @__PURE__ */ jsxs8(
|
|
4152
|
+
thinkingEnabled && /* @__PURE__ */ jsxs8(Text10, { color: "#ff9800", children: [
|
|
4135
4153
|
" \u{1F9E0} \u6DF1\u5EA6\u601D\u8003 ",
|
|
4136
4154
|
thinkingEffort === "max" ? "Max" : "High"
|
|
4137
4155
|
] }),
|
|
4138
|
-
responseFormat === "json_object" && /* @__PURE__ */
|
|
4139
|
-
toolChoice !== void 0 && /* @__PURE__ */ jsxs8(
|
|
4156
|
+
responseFormat === "json_object" && /* @__PURE__ */ jsx9(Text10, { color: "#4caf50", children: " \u{1F4C4} JSON" }),
|
|
4157
|
+
toolChoice !== void 0 && /* @__PURE__ */ jsxs8(Text10, { color: "#e91e63", children: [
|
|
4140
4158
|
" \u{1F6E0} ",
|
|
4141
4159
|
toolChoice === "none" ? "\u7981\u6B62\u5DE5\u5177" : toolChoice === "required" ? "\u5F3A\u5236\u5DE5\u5177" : ""
|
|
4142
4160
|
] }),
|
|
@@ -4144,24 +4162,24 @@ function ChatSession({
|
|
|
4144
4162
|
const tip = cmdTips[cmdTipIndex % cmdTips.length];
|
|
4145
4163
|
if (!tip) return null;
|
|
4146
4164
|
const text = `${tip.name} ${tip.desc}`;
|
|
4147
|
-
return /* @__PURE__ */ jsxs8(
|
|
4148
|
-
/* @__PURE__ */
|
|
4149
|
-
cmdTipGradientColors.length > 0 ? text.split("").map((ch, i) => /* @__PURE__ */
|
|
4165
|
+
return /* @__PURE__ */ jsxs8(Text10, { children: [
|
|
4166
|
+
/* @__PURE__ */ jsx9(Text10, { color: "#808080", children: " \u{1F4A1} " }),
|
|
4167
|
+
cmdTipGradientColors.length > 0 ? text.split("").map((ch, i) => /* @__PURE__ */ jsx9(Text10, { color: cmdTipGradientColors[i] || void 0, children: ch }, i)) : /* @__PURE__ */ jsx9(Text10, { color: "#808080", children: text })
|
|
4150
4168
|
] });
|
|
4151
4169
|
})(),
|
|
4152
|
-
verbose ? /* @__PURE__ */
|
|
4170
|
+
verbose ? /* @__PURE__ */ jsx9(Text10, { color: "#ff1493", children: " \u26A1 Verbose" }) : null
|
|
4153
4171
|
] }),
|
|
4154
4172
|
/* @__PURE__ */ jsxs8(Box8, { flexGrow: 1, flexDirection: "column", justifyContent: "center", alignItems: "flex-end", children: [
|
|
4155
|
-
balanceLoading && balance === null ? /* @__PURE__ */
|
|
4156
|
-
/* @__PURE__ */
|
|
4157
|
-
/* @__PURE__ */ jsxs8(
|
|
4173
|
+
balanceLoading && balance === null ? /* @__PURE__ */ jsx9(Text10, { color: "yellow", children: " \u23F3 \u67E5\u8BE2\u4F59\u989D..." }) : balance !== null ? /* @__PURE__ */ jsxs8(Box8, { flexDirection: "row", children: [
|
|
4174
|
+
/* @__PURE__ */ jsx9(Text10, { color: "yellow", children: "\u{1F4B0} " }),
|
|
4175
|
+
/* @__PURE__ */ jsxs8(Text10, { color: "yellow", children: [
|
|
4158
4176
|
"\u4F59\u989D \xA5",
|
|
4159
4177
|
balance.toFixed(2)
|
|
4160
4178
|
] })
|
|
4161
4179
|
] }) : null,
|
|
4162
4180
|
todayCost !== null ? /* @__PURE__ */ jsxs8(Box8, { flexDirection: "row", children: [
|
|
4163
|
-
/* @__PURE__ */
|
|
4164
|
-
/* @__PURE__ */ jsxs8(
|
|
4181
|
+
/* @__PURE__ */ jsx9(Text10, { color: "cyan", children: "\u{1F4CA} " }),
|
|
4182
|
+
/* @__PURE__ */ jsxs8(Text10, { color: "cyan", children: [
|
|
4165
4183
|
"\u4ECA\u65E5 \xA5",
|
|
4166
4184
|
todayCost.toFixed(2)
|
|
4167
4185
|
] })
|
|
@@ -4169,24 +4187,24 @@ function ChatSession({
|
|
|
4169
4187
|
] })
|
|
4170
4188
|
] }),
|
|
4171
4189
|
/* @__PURE__ */ jsxs8(Box8, { flexDirection: "column", marginTop: 1, children: [
|
|
4172
|
-
/* @__PURE__ */
|
|
4190
|
+
/* @__PURE__ */ jsx9(Static, { items: displayMessages, children: (msg, i) => {
|
|
4173
4191
|
if (msg.role === "user") {
|
|
4174
4192
|
return /* @__PURE__ */ jsxs8(Box8, { marginTop: 1, children: [
|
|
4175
|
-
/* @__PURE__ */
|
|
4176
|
-
/* @__PURE__ */
|
|
4193
|
+
/* @__PURE__ */ jsx9(Box8, { width: 4, flexShrink: 0, children: /* @__PURE__ */ jsx9(Text10, { bold: true, color: "#00ff41", children: "\u{1F464}" }) }),
|
|
4194
|
+
/* @__PURE__ */ jsx9(Box8, { flexGrow: 1, children: /* @__PURE__ */ jsx9(Text10, { wrap: "wrap", children: msg.content }) })
|
|
4177
4195
|
] }, i);
|
|
4178
4196
|
}
|
|
4179
4197
|
if (msg.role === "tool") {
|
|
4180
4198
|
return /* @__PURE__ */ jsxs8(Box8, { marginTop: 1, flexDirection: "column", children: [
|
|
4181
4199
|
/* @__PURE__ */ jsxs8(Box8, { flexDirection: "row", children: [
|
|
4182
|
-
/* @__PURE__ */
|
|
4183
|
-
/* @__PURE__ */
|
|
4200
|
+
/* @__PURE__ */ jsx9(Box8, { width: 4, flexShrink: 0, children: /* @__PURE__ */ jsx9(Text10, { bold: true, color: "#f59e0b", children: "\u{1F527}" }) }),
|
|
4201
|
+
/* @__PURE__ */ jsx9(Box8, { flexGrow: 1, children: /* @__PURE__ */ jsx9(Text10, { wrap: "wrap", children: msg.content }) })
|
|
4184
4202
|
] }),
|
|
4185
|
-
msg.diff && /* @__PURE__ */
|
|
4203
|
+
msg.diff && /* @__PURE__ */ jsx9(DiffPreview, { diff: msg.diff })
|
|
4186
4204
|
] }, i);
|
|
4187
4205
|
}
|
|
4188
4206
|
const detail = msg.assistantDetail;
|
|
4189
|
-
return /* @__PURE__ */
|
|
4207
|
+
return /* @__PURE__ */ jsx9(
|
|
4190
4208
|
AssistantMessage,
|
|
4191
4209
|
{
|
|
4192
4210
|
content: msg.content,
|
|
@@ -4200,7 +4218,7 @@ function ChatSession({
|
|
|
4200
4218
|
i
|
|
4201
4219
|
);
|
|
4202
4220
|
} }, staticKey),
|
|
4203
|
-
isStreaming && /* @__PURE__ */
|
|
4221
|
+
isStreaming && /* @__PURE__ */ jsx9(
|
|
4204
4222
|
AssistantMessage,
|
|
4205
4223
|
{
|
|
4206
4224
|
content: currentContent,
|
|
@@ -4208,16 +4226,16 @@ function ChatSession({
|
|
|
4208
4226
|
isStreaming: true
|
|
4209
4227
|
}
|
|
4210
4228
|
),
|
|
4211
|
-
isStreaming && !currentContent && currentToolCalls.length === 0 && /* @__PURE__ */
|
|
4212
|
-
!isStreaming && streamError && /* @__PURE__ */
|
|
4229
|
+
isStreaming && !currentContent && currentToolCalls.length === 0 && /* @__PURE__ */ jsx9(Box8, { marginTop: 1, marginLeft: 4, children: /* @__PURE__ */ jsx9(Spinner, { type: "dots", label: "\u601D\u8003\u4E2D..." }) }),
|
|
4230
|
+
!isStreaming && streamError && /* @__PURE__ */ jsx9(Box8, { marginTop: 1, marginLeft: 3, children: /* @__PURE__ */ jsxs8(Text10, { color: "red", children: [
|
|
4213
4231
|
"\u26A0 ",
|
|
4214
4232
|
streamError
|
|
4215
4233
|
] }) })
|
|
4216
4234
|
] }),
|
|
4217
4235
|
selectingModel ? /* @__PURE__ */ jsxs8(Box8, { marginTop: 1, flexDirection: "column", children: [
|
|
4218
|
-
/* @__PURE__ */
|
|
4236
|
+
/* @__PURE__ */ jsx9(Text10, { color: "#00ffff", dimColor: true, children: "\u2500".repeat(dividerWidth) }),
|
|
4219
4237
|
/* @__PURE__ */ jsxs8(Box8, { flexDirection: "column", marginTop: 1, children: [
|
|
4220
|
-
/* @__PURE__ */
|
|
4238
|
+
/* @__PURE__ */ jsx9(Text10, { bold: true, color: "#00ffff", children: "\u9009\u62E9\u6A21\u578B\uFF1A" }),
|
|
4221
4239
|
modelOptions.map((id, i) => {
|
|
4222
4240
|
const meta = SUPPORTED_MODELS[id];
|
|
4223
4241
|
const isCurrent = id === activeModel;
|
|
@@ -4226,7 +4244,7 @@ function ChatSession({
|
|
|
4226
4244
|
const suffix = isCurrent ? " (\u5F53\u524D)" : "";
|
|
4227
4245
|
return /* @__PURE__ */ jsxs8(Box8, { children: [
|
|
4228
4246
|
/* @__PURE__ */ jsxs8(
|
|
4229
|
-
|
|
4247
|
+
Text10,
|
|
4230
4248
|
{
|
|
4231
4249
|
color: isSelected ? "#00ff41" : void 0,
|
|
4232
4250
|
bold: isSelected,
|
|
@@ -4237,34 +4255,34 @@ function ChatSession({
|
|
|
4237
4255
|
]
|
|
4238
4256
|
}
|
|
4239
4257
|
),
|
|
4240
|
-
isSelected && /* @__PURE__ */ jsxs8(
|
|
4258
|
+
isSelected && /* @__PURE__ */ jsxs8(Text10, { color: "#808080", children: [
|
|
4241
4259
|
" \u2014 ",
|
|
4242
4260
|
id
|
|
4243
4261
|
] })
|
|
4244
4262
|
] }, id);
|
|
4245
4263
|
}),
|
|
4246
|
-
/* @__PURE__ */
|
|
4264
|
+
/* @__PURE__ */ jsx9(Box8, { marginTop: 1, children: /* @__PURE__ */ jsx9(Text10, { color: "#808080", dimColor: true, children: "\u2191\u2193 \u9009\u62E9 \xB7 Enter \u786E\u8BA4 \xB7 Esc \u53D6\u6D88" }) })
|
|
4247
4265
|
] }),
|
|
4248
|
-
/* @__PURE__ */
|
|
4266
|
+
/* @__PURE__ */ jsx9(Text10, { color: "#00ffff", dimColor: true, children: "\u2500".repeat(dividerWidth) })
|
|
4249
4267
|
] }) : /* @__PURE__ */ jsxs8(Fragment, { children: [
|
|
4250
|
-
/* @__PURE__ */
|
|
4268
|
+
/* @__PURE__ */ jsx9(Box8, { marginTop: 1, children: hasConversationStarted && (balance !== null || sessionCost > 0 || isStreaming) ? /* @__PURE__ */ jsxs8(Text10, { color: "#00ffff", dimColor: true, children: [
|
|
4251
4269
|
"\u2500".repeat(Math.max(dividerWidth - 35, 10)),
|
|
4252
|
-
balance !== null && /* @__PURE__ */ jsxs8(
|
|
4270
|
+
balance !== null && /* @__PURE__ */ jsxs8(Text10, { color: "yellow", children: [
|
|
4253
4271
|
" \u{1F4B0} \u4F59\u989D \xA5",
|
|
4254
4272
|
balance.toFixed(2)
|
|
4255
4273
|
] }),
|
|
4256
|
-
isStreaming ? /* @__PURE__ */ jsxs8(
|
|
4274
|
+
isStreaming ? /* @__PURE__ */ jsxs8(Text10, { color: "cyan", children: [
|
|
4257
4275
|
" \u{1F4CA} \u672C\u6B21 \xA5",
|
|
4258
4276
|
sessionCost > 0 ? sessionCost.toFixed(4) + " " : "",
|
|
4259
|
-
/* @__PURE__ */
|
|
4260
|
-
] }) : sessionCost > 0 ? /* @__PURE__ */ jsxs8(
|
|
4277
|
+
/* @__PURE__ */ jsx9(InkSpinner2, { type: "dots" })
|
|
4278
|
+
] }) : sessionCost > 0 ? /* @__PURE__ */ jsxs8(Text10, { color: "cyan", children: [
|
|
4261
4279
|
" \u{1F4CA} \u672C\u6B21 \xA5",
|
|
4262
4280
|
sessionCost.toFixed(4)
|
|
4263
4281
|
] }) : null
|
|
4264
|
-
] }) : /* @__PURE__ */
|
|
4282
|
+
] }) : /* @__PURE__ */ jsx9(Text10, { color: "#00ffff", dimColor: true, children: "\u2500".repeat(dividerWidth) }) }),
|
|
4265
4283
|
/* @__PURE__ */ jsxs8(Box8, { children: [
|
|
4266
|
-
/* @__PURE__ */
|
|
4267
|
-
/* @__PURE__ */
|
|
4284
|
+
/* @__PURE__ */ jsx9(Box8, { width: 4, flexShrink: 0, children: /* @__PURE__ */ jsx9(Text10, { bold: true, color: "#00ff41", children: "\u26A1" }) }),
|
|
4285
|
+
/* @__PURE__ */ jsx9(Box8, { flexGrow: 1, children: !input && !isStreaming && idlePlaceholder && gradientColors.length > 0 ? /* @__PURE__ */ jsx9(Text10, { children: idlePlaceholder.split("").map((ch, i) => /* @__PURE__ */ jsx9(Text10, { color: gradientColors[i] ?? void 0, children: ch }, i)) }) : !input && isStreaming && streamingPlaceholder && streamingGradientColors.length > 0 ? /* @__PURE__ */ jsx9(Text10, { children: streamingPlaceholder.split("").map((ch, i) => /* @__PURE__ */ jsx9(Text10, { color: streamingGradientColors[i] ?? void 0, children: ch }, i)) }) : /* @__PURE__ */ jsx9(
|
|
4268
4286
|
TextInput,
|
|
4269
4287
|
{
|
|
4270
4288
|
value: input,
|
|
@@ -4275,19 +4293,19 @@ function ChatSession({
|
|
|
4275
4293
|
inputKey
|
|
4276
4294
|
) })
|
|
4277
4295
|
] }),
|
|
4278
|
-
/* @__PURE__ */
|
|
4279
|
-
/* @__PURE__ */
|
|
4280
|
-
/* @__PURE__ */
|
|
4296
|
+
/* @__PURE__ */ jsx9(Box8, { children: /* @__PURE__ */ jsx9(Text10, { color: "#00ffff", dimColor: true, children: "\u2500".repeat(dividerWidth) }) }),
|
|
4297
|
+
/* @__PURE__ */ jsx9(SkillSelector, { skills, input, selectedIndex: skillSelectIndex }),
|
|
4298
|
+
/* @__PURE__ */ jsx9(FileSelector, { files, input, selectedIndex: fileSelectIndex })
|
|
4281
4299
|
] }),
|
|
4282
|
-
doubleCtrlC && !isStreaming && /* @__PURE__ */
|
|
4283
|
-
isStreaming && /* @__PURE__ */
|
|
4300
|
+
doubleCtrlC && !isStreaming && /* @__PURE__ */ jsx9(Box8, { marginTop: 1, children: /* @__PURE__ */ jsx9(Text10, { color: "#ff1493", bold: true, children: " \u26A0 \u518D\u6309\u4E00\u6B21 Ctrl+C \u9000\u51FA dskcode" }) }),
|
|
4301
|
+
isStreaming && /* @__PURE__ */ jsx9(Box8, { marginTop: 1, children: /* @__PURE__ */ jsx9(Text10, { color: "yellow", dimColor: true, children: " \u63D0\u793A\uFF1A\u6309 Ctrl+C \u53D6\u6D88\u5F53\u524D\u8BF7\u6C42" }) })
|
|
4284
4302
|
] });
|
|
4285
4303
|
}
|
|
4286
4304
|
|
|
4287
4305
|
// src/ui/GamePicker.tsx
|
|
4288
|
-
import { Box as Box9, Text as
|
|
4306
|
+
import { Box as Box9, Text as Text11, useInput as useInput2 } from "ink";
|
|
4289
4307
|
import { useState as useState4, useCallback as useCallback3 } from "react";
|
|
4290
|
-
import { jsx as
|
|
4308
|
+
import { jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
4291
4309
|
function GamePicker({ games, onSelect, onExit, onBackToChat }) {
|
|
4292
4310
|
const [selectedIndex, setSelectedIndex] = useState4(0);
|
|
4293
4311
|
const exitAction = onBackToChat ?? onExit ?? (() => process.exit(0));
|
|
@@ -4316,17 +4334,17 @@ function GamePicker({ games, onSelect, onExit, onBackToChat }) {
|
|
|
4316
4334
|
)
|
|
4317
4335
|
);
|
|
4318
4336
|
return /* @__PURE__ */ jsxs9(Box9, { flexDirection: "column", children: [
|
|
4319
|
-
/* @__PURE__ */
|
|
4320
|
-
/* @__PURE__ */
|
|
4337
|
+
/* @__PURE__ */ jsx10(Box9, { marginBottom: 1, children: /* @__PURE__ */ jsx10(Text11, { bold: true, color: "#00ffff", children: "\u{1F3AE} \u6E38\u620F\u5217\u8868" }) }),
|
|
4338
|
+
/* @__PURE__ */ jsx10(Box9, { flexDirection: "column", children: games.map((game, index) => {
|
|
4321
4339
|
const isSelected = index === selectedIndex;
|
|
4322
4340
|
return /* @__PURE__ */ jsxs9(Box9, { flexDirection: "row", children: [
|
|
4323
|
-
/* @__PURE__ */
|
|
4324
|
-
/* @__PURE__ */
|
|
4325
|
-
/* @__PURE__ */
|
|
4341
|
+
/* @__PURE__ */ jsx10(Box9, { width: 3, flexShrink: 0, children: isSelected ? /* @__PURE__ */ jsx10(Text11, { bold: true, color: "#00ff41", children: "\u25B8 " }) : /* @__PURE__ */ jsx10(Text11, { children: " " }) }),
|
|
4342
|
+
/* @__PURE__ */ jsx10(Box9, { width: 20, flexShrink: 0, children: /* @__PURE__ */ jsx10(Text11, { bold: true, color: isSelected ? "#00ff41" : "#ffffff", children: game.name }) }),
|
|
4343
|
+
/* @__PURE__ */ jsx10(Box9, { children: /* @__PURE__ */ jsx10(Text11, { color: "#888888", children: game.description }) })
|
|
4326
4344
|
] }, game.id);
|
|
4327
4345
|
}) }),
|
|
4328
|
-
/* @__PURE__ */
|
|
4329
|
-
doubleCtrlC && /* @__PURE__ */
|
|
4346
|
+
/* @__PURE__ */ jsx10(Box9, { marginTop: 1, children: /* @__PURE__ */ jsx10(Text11, { dimColor: true, children: " \u2191/\u2193 \u9009\u62E9 Enter \u542F\u52A8 q \u8FD4\u56DE" }) }),
|
|
4347
|
+
doubleCtrlC && /* @__PURE__ */ jsx10(Box9, { marginTop: 1, children: /* @__PURE__ */ jsx10(Text11, { color: "#ff1493", bold: true, children: " \u26A0 \u518D\u6309\u4E00\u6B21 Ctrl+C \u9000\u51FA dskcode" }) })
|
|
4330
4348
|
] });
|
|
4331
4349
|
}
|
|
4332
4350
|
|
|
@@ -4343,9 +4361,9 @@ function listGames() {
|
|
|
4343
4361
|
}
|
|
4344
4362
|
|
|
4345
4363
|
// src/game/brick-breaker/index.tsx
|
|
4346
|
-
import { Box as Box10, Text as
|
|
4364
|
+
import { Box as Box10, Text as Text12, useInput as useInput3, render as render2 } from "ink";
|
|
4347
4365
|
import { useState as useState5, useEffect as useEffect4, useRef as useRef3, useCallback as useCallback4 } from "react";
|
|
4348
|
-
import { jsx as
|
|
4366
|
+
import { jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
4349
4367
|
var GAME_WIDTH = 40;
|
|
4350
4368
|
var GAME_HEIGHT = 18;
|
|
4351
4369
|
var PADDLE_WIDTH = 9;
|
|
@@ -4537,47 +4555,47 @@ function BrickBreakerGame({ onExit: _onExit }) {
|
|
|
4537
4555
|
void tick2;
|
|
4538
4556
|
return /* @__PURE__ */ jsxs10(Box10, { flexDirection: "column", children: [
|
|
4539
4557
|
/* @__PURE__ */ jsxs10(Box10, { flexDirection: "row", children: [
|
|
4540
|
-
/* @__PURE__ */
|
|
4558
|
+
/* @__PURE__ */ jsx11(Box10, { width: 20, children: /* @__PURE__ */ jsxs10(Text12, { children: [
|
|
4541
4559
|
"\u5173\u5361 ",
|
|
4542
4560
|
s.level,
|
|
4543
4561
|
": ",
|
|
4544
|
-
/* @__PURE__ */
|
|
4562
|
+
/* @__PURE__ */ jsx11(Text12, { color: "cyan", children: def.desc })
|
|
4545
4563
|
] }) }),
|
|
4546
|
-
/* @__PURE__ */
|
|
4564
|
+
/* @__PURE__ */ jsx11(Box10, { width: 12, children: /* @__PURE__ */ jsxs10(Text12, { children: [
|
|
4547
4565
|
"\u5206\u6570: ",
|
|
4548
|
-
/* @__PURE__ */
|
|
4566
|
+
/* @__PURE__ */ jsx11(Text12, { color: "yellow", children: String(s.score).padStart(3, "0") })
|
|
4549
4567
|
] }) }),
|
|
4550
|
-
/* @__PURE__ */
|
|
4568
|
+
/* @__PURE__ */ jsx11(Box10, { width: 12, children: /* @__PURE__ */ jsxs10(Text12, { children: [
|
|
4551
4569
|
"\u751F\u547D: ",
|
|
4552
|
-
/* @__PURE__ */
|
|
4570
|
+
/* @__PURE__ */ jsx11(Text12, { color: "red", children: "\u2665".repeat(Math.max(0, s.lives)) })
|
|
4553
4571
|
] }) }),
|
|
4554
|
-
/* @__PURE__ */
|
|
4572
|
+
/* @__PURE__ */ jsx11(Box10, { width: 10, children: /* @__PURE__ */ jsxs10(Text12, { children: [
|
|
4555
4573
|
"\u7816\u5757: ",
|
|
4556
|
-
/* @__PURE__ */
|
|
4574
|
+
/* @__PURE__ */ jsx11(Text12, { color: "cyan", children: aliveCount })
|
|
4557
4575
|
] }) }),
|
|
4558
|
-
/* @__PURE__ */
|
|
4576
|
+
/* @__PURE__ */ jsx11(Box10, { children: /* @__PURE__ */ jsxs10(Text12, { color: s.paused ? "gray" : "green", children: [
|
|
4559
4577
|
"[",
|
|
4560
4578
|
s.paused ? "\u6682\u505C" : "\u8FD0\u884C\u4E2D",
|
|
4561
4579
|
"]"
|
|
4562
4580
|
] }) })
|
|
4563
4581
|
] }),
|
|
4564
4582
|
/* @__PURE__ */ jsxs10(Box10, { flexDirection: "column", children: [
|
|
4565
|
-
/* @__PURE__ */ jsxs10(
|
|
4583
|
+
/* @__PURE__ */ jsxs10(Text12, { children: [
|
|
4566
4584
|
"\u250C",
|
|
4567
4585
|
"\u2500".repeat(GAME_WIDTH),
|
|
4568
4586
|
"\u2510"
|
|
4569
4587
|
] }),
|
|
4570
|
-
/* @__PURE__ */
|
|
4571
|
-
/* @__PURE__ */ jsxs10(
|
|
4588
|
+
/* @__PURE__ */ jsx11(Text12, { children: selectingLevel ? " \x1B[90m\u9009\u62E9\u5173\u5361\u540E\u5F00\u59CB...\x1B[0m" : board }),
|
|
4589
|
+
/* @__PURE__ */ jsxs10(Text12, { children: [
|
|
4572
4590
|
"\u2514",
|
|
4573
4591
|
"\u2500".repeat(GAME_WIDTH),
|
|
4574
4592
|
"\u2518"
|
|
4575
4593
|
] })
|
|
4576
4594
|
] }),
|
|
4577
4595
|
selectingLevel && /* @__PURE__ */ jsxs10(Box10, { marginTop: 1, flexDirection: "column", children: [
|
|
4578
|
-
/* @__PURE__ */
|
|
4579
|
-
/* @__PURE__ */
|
|
4580
|
-
/* @__PURE__ */
|
|
4596
|
+
/* @__PURE__ */ jsx11(Text12, { bold: true, color: "yellow", children: "\u9009\u62E9\u5173\u5361" }),
|
|
4597
|
+
/* @__PURE__ */ jsx11(Box10, { flexDirection: "row", flexWrap: "wrap", children: LEVELS.map((lv, i) => /* @__PURE__ */ jsx11(Box10, { width: 22, children: /* @__PURE__ */ jsxs10(Text12, { children: [
|
|
4598
|
+
/* @__PURE__ */ jsx11(Text12, { color: initialLevel === i + 1 ? "green" : "white", children: i + 1 === 10 ? "0" : String(i + 1) }),
|
|
4581
4599
|
". ",
|
|
4582
4600
|
lv.desc,
|
|
4583
4601
|
" (",
|
|
@@ -4586,16 +4604,16 @@ function BrickBreakerGame({ onExit: _onExit }) {
|
|
|
4586
4604
|
lv.cols,
|
|
4587
4605
|
")"
|
|
4588
4606
|
] }) }, i)) }),
|
|
4589
|
-
/* @__PURE__ */
|
|
4607
|
+
/* @__PURE__ */ jsx11(Box10, { marginTop: 1, children: /* @__PURE__ */ jsx11(Text12, { dimColor: true, children: "\u6309\u6570\u5B57\u9009\u5173 q \u9000\u51FA" }) })
|
|
4590
4608
|
] }),
|
|
4591
4609
|
!selectingLevel && (s.gameOver || s.win) && /* @__PURE__ */ jsxs10(Box10, { marginTop: 1, children: [
|
|
4592
|
-
/* @__PURE__ */
|
|
4593
|
-
/* @__PURE__ */ jsxs10(
|
|
4610
|
+
/* @__PURE__ */ jsx11(Text12, { bold: true, color: s.gameOver ? "red" : "green", children: s.gameOver ? "\u6E38\u620F\u7ED3\u675F\uFF01" : "\u606D\u559C\u901A\u5173\uFF01" }),
|
|
4611
|
+
/* @__PURE__ */ jsxs10(Text12, { children: [
|
|
4594
4612
|
" \u5206\u6570: ",
|
|
4595
|
-
/* @__PURE__ */
|
|
4613
|
+
/* @__PURE__ */ jsx11(Text12, { color: "yellow", children: s.score })
|
|
4596
4614
|
] })
|
|
4597
4615
|
] }),
|
|
4598
|
-
!selectingLevel && /* @__PURE__ */
|
|
4616
|
+
!selectingLevel && /* @__PURE__ */ jsx11(Box10, { marginTop: 1, children: s.gameOver || s.win ? /* @__PURE__ */ jsx11(Text12, { dimColor: true, children: "\u2190 \u2192 \u79FB\u52A8 r \u91CD\u5F00 l \u9009\u5173 q \u9000\u51FA" }) : /* @__PURE__ */ jsx11(Text12, { dimColor: true, children: "\u2190 \u2192 \u79FB\u52A8 p \u6682\u505C q \u9000\u51FA" }) })
|
|
4599
4617
|
] });
|
|
4600
4618
|
}
|
|
4601
4619
|
var brick_breaker_default = {
|
|
@@ -4605,7 +4623,7 @@ var brick_breaker_default = {
|
|
|
4605
4623
|
play: async () => {
|
|
4606
4624
|
await new Promise((resolve2) => {
|
|
4607
4625
|
const { unmount } = render2(
|
|
4608
|
-
/* @__PURE__ */
|
|
4626
|
+
/* @__PURE__ */ jsx11(BrickBreakerGame, { onExit: () => {
|
|
4609
4627
|
unmount();
|
|
4610
4628
|
resolve2();
|
|
4611
4629
|
} })
|
|
@@ -4615,9 +4633,9 @@ var brick_breaker_default = {
|
|
|
4615
4633
|
};
|
|
4616
4634
|
|
|
4617
4635
|
// src/game/coder-check/index.tsx
|
|
4618
|
-
import { Box as Box11, Text as
|
|
4636
|
+
import { Box as Box11, Text as Text13, useInput as useInput4, render as render3 } from "ink";
|
|
4619
4637
|
import { useState as useState6, useEffect as useEffect5, useRef as useRef4, useCallback as useCallback5 } from "react";
|
|
4620
|
-
import { jsx as
|
|
4638
|
+
import { jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
4621
4639
|
var GAME_W = 66;
|
|
4622
4640
|
var GAME_H = 20;
|
|
4623
4641
|
var SCORE_H = 6;
|
|
@@ -5089,43 +5107,43 @@ function CoderCheck({ onExit: _onExit }) {
|
|
|
5089
5107
|
const view = buildGameView(s, scoreLines, scoreColor, s.message);
|
|
5090
5108
|
void tick2;
|
|
5091
5109
|
return /* @__PURE__ */ jsxs11(Box11, { flexDirection: "column", paddingX: 1, children: [
|
|
5092
|
-
/* @__PURE__ */
|
|
5110
|
+
/* @__PURE__ */ jsx12(Box11, { flexDirection: "row", children: /* @__PURE__ */ jsxs11(Text13, { children: [
|
|
5093
5111
|
"\u751F\u547D ",
|
|
5094
|
-
/* @__PURE__ */
|
|
5112
|
+
/* @__PURE__ */ jsx12(Text13, { color: "red", children: "\u2665".repeat(Math.max(0, s.lives)) }),
|
|
5095
5113
|
" ",
|
|
5096
5114
|
"\u901F\u5EA6 ",
|
|
5097
|
-
/* @__PURE__ */ jsxs11(
|
|
5115
|
+
/* @__PURE__ */ jsxs11(Text13, { color: "cyan", children: [
|
|
5098
5116
|
"Lv.",
|
|
5099
5117
|
Math.floor(s.speed * 10)
|
|
5100
5118
|
] })
|
|
5101
5119
|
] }) }),
|
|
5102
|
-
!s.gameOver && s.target && /* @__PURE__ */
|
|
5120
|
+
!s.gameOver && s.target && /* @__PURE__ */ jsx12(Box11, { marginTop: 1, children: /* @__PURE__ */ jsxs11(Text13, { children: [
|
|
5103
5121
|
"\u6253\u5B57: ",
|
|
5104
|
-
/* @__PURE__ */
|
|
5105
|
-
/* @__PURE__ */
|
|
5122
|
+
/* @__PURE__ */ jsx12(Text13, { color: "green", children: s.typed }),
|
|
5123
|
+
/* @__PURE__ */ jsx12(Text13, { color: "white", children: s.target.slice(s.typed.length) })
|
|
5106
5124
|
] }) }),
|
|
5107
5125
|
/* @__PURE__ */ jsxs11(Box11, { flexDirection: "column", marginTop: 1, children: [
|
|
5108
|
-
/* @__PURE__ */ jsxs11(
|
|
5126
|
+
/* @__PURE__ */ jsxs11(Text13, { children: [
|
|
5109
5127
|
"\u250C",
|
|
5110
5128
|
"\u2500".repeat(GAME_W),
|
|
5111
5129
|
"\u2510"
|
|
5112
5130
|
] }),
|
|
5113
|
-
view.map((row, i) => /* @__PURE__ */
|
|
5114
|
-
/* @__PURE__ */ jsxs11(
|
|
5131
|
+
view.map((row, i) => /* @__PURE__ */ jsx12(Text13, { children: `\u2502${row}\u2502` }, i)),
|
|
5132
|
+
/* @__PURE__ */ jsxs11(Text13, { children: [
|
|
5115
5133
|
"\u2514",
|
|
5116
5134
|
"\u2500".repeat(GAME_W),
|
|
5117
5135
|
"\u2518"
|
|
5118
5136
|
] })
|
|
5119
5137
|
] }),
|
|
5120
5138
|
s.gameOver && /* @__PURE__ */ jsxs11(Box11, { marginTop: 1, children: [
|
|
5121
|
-
/* @__PURE__ */
|
|
5122
|
-
/* @__PURE__ */ jsxs11(
|
|
5139
|
+
/* @__PURE__ */ jsx12(Text13, { bold: true, color: "red", children: "\u6E38\u620F\u7ED3\u675F\uFF01" }),
|
|
5140
|
+
/* @__PURE__ */ jsxs11(Text13, { children: [
|
|
5123
5141
|
" \u5F97\u5206: ",
|
|
5124
|
-
/* @__PURE__ */
|
|
5142
|
+
/* @__PURE__ */ jsx12(Text13, { color: "yellow", children: s.score }),
|
|
5125
5143
|
" r \u91CD\u5F00 q \u9000\u51FA"
|
|
5126
5144
|
] })
|
|
5127
5145
|
] }),
|
|
5128
|
-
/* @__PURE__ */
|
|
5146
|
+
/* @__PURE__ */ jsx12(Box11, { marginTop: 1, children: /* @__PURE__ */ jsx12(Text13, { dimColor: true, children: "\u6253\u5B57\u6D88\u9664\u5355\u8BCD \u7A7A\u683C/Ctrl+P\u6682\u505C Ctrl+Q\u9000\u51FA" }) })
|
|
5129
5147
|
] });
|
|
5130
5148
|
}
|
|
5131
5149
|
var coder_check_default = {
|
|
@@ -5135,7 +5153,7 @@ var coder_check_default = {
|
|
|
5135
5153
|
play: async () => {
|
|
5136
5154
|
await new Promise((resolve2) => {
|
|
5137
5155
|
const { unmount } = render3(
|
|
5138
|
-
/* @__PURE__ */
|
|
5156
|
+
/* @__PURE__ */ jsx12(CoderCheck, { onExit: () => {
|
|
5139
5157
|
unmount();
|
|
5140
5158
|
resolve2();
|
|
5141
5159
|
} })
|
|
@@ -5515,12 +5533,12 @@ import { render as render4 } from "ink";
|
|
|
5515
5533
|
import chalk5 from "chalk";
|
|
5516
5534
|
|
|
5517
5535
|
// src/stock/StockList.tsx
|
|
5518
|
-
import { Box as Box12, Text as
|
|
5536
|
+
import { Box as Box12, Text as Text14, useInput as useInput5 } from "ink";
|
|
5519
5537
|
import { useState as useState7, useCallback as useCallback6, useEffect as useEffect6 } from "react";
|
|
5520
5538
|
import asciichart from "asciichart";
|
|
5521
5539
|
import os from "os";
|
|
5522
5540
|
import { join as join7 } from "path";
|
|
5523
|
-
import { jsx as
|
|
5541
|
+
import { jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
5524
5542
|
var SETTINGS_PATH = join7(os.homedir(), ".dskcode", "settings.json");
|
|
5525
5543
|
function toFileUrl(p) {
|
|
5526
5544
|
const norm = p.replace(/\\/g, "/");
|
|
@@ -5731,61 +5749,61 @@ function StockList({ codes, onExit, onBackToChat }) {
|
|
|
5731
5749
|
);
|
|
5732
5750
|
if (detailView) {
|
|
5733
5751
|
if (detailLoading) {
|
|
5734
|
-
return /* @__PURE__ */
|
|
5752
|
+
return /* @__PURE__ */ jsx13(Box12, { paddingLeft: 1, children: /* @__PURE__ */ jsx13(Text14, { dimColor: true, children: " \u27F3 \u52A0\u8F7D\u5206\u65F6\u6570\u636E..." }) });
|
|
5735
5753
|
}
|
|
5736
5754
|
return renderDetail(detailView, () => setDetailView(null), detailPrices ?? void 0, detailCountdown, currentTime);
|
|
5737
5755
|
}
|
|
5738
5756
|
const cp2 = (c) => dimMode ? { dimColor: true } : { color: c };
|
|
5739
5757
|
return /* @__PURE__ */ jsxs12(Box12, { flexDirection: "column", children: [
|
|
5740
5758
|
/* @__PURE__ */ jsxs12(Box12, { marginBottom: 1, justifyContent: "space-between", children: [
|
|
5741
|
-
/* @__PURE__ */
|
|
5742
|
-
/* @__PURE__ */ jsxs12(
|
|
5759
|
+
/* @__PURE__ */ jsx13(Text14, { bold: true, ...cp2("#00ffff"), children: " \u{1F4C8} \u81EA\u9009\u80A1\u76D1\u63A7" }),
|
|
5760
|
+
/* @__PURE__ */ jsxs12(Text14, { dimColor: true, children: [
|
|
5743
5761
|
" \u{1F550} ",
|
|
5744
5762
|
currentTime
|
|
5745
5763
|
] }),
|
|
5746
|
-
/* @__PURE__ */
|
|
5764
|
+
/* @__PURE__ */ jsx13(Text14, { dimColor: true, children: loading ? " \u27F3 \u5237\u65B0\u4E2D..." : ` ${countdown}s \u540E\u81EA\u52A8\u5237\u65B0` })
|
|
5747
5765
|
] }),
|
|
5748
5766
|
/* @__PURE__ */ jsxs12(Box12, { children: [
|
|
5749
|
-
/* @__PURE__ */
|
|
5750
|
-
/* @__PURE__ */
|
|
5751
|
-
/* @__PURE__ */
|
|
5752
|
-
/* @__PURE__ */
|
|
5753
|
-
/* @__PURE__ */
|
|
5754
|
-
/* @__PURE__ */
|
|
5755
|
-
/* @__PURE__ */
|
|
5756
|
-
/* @__PURE__ */
|
|
5757
|
-
/* @__PURE__ */
|
|
5767
|
+
/* @__PURE__ */ jsx13(Box12, { width: 3 }),
|
|
5768
|
+
/* @__PURE__ */ jsx13(Box12, { width: 9, children: /* @__PURE__ */ jsx13(Text14, { dimColor: true, children: "\u4EE3\u7801" }) }),
|
|
5769
|
+
/* @__PURE__ */ jsx13(Box12, { width: 16, children: /* @__PURE__ */ jsx13(Text14, { dimColor: true, children: "\u540D\u79F0" }) }),
|
|
5770
|
+
/* @__PURE__ */ jsx13(Box12, { width: 12, children: /* @__PURE__ */ jsx13(Text14, { dimColor: true, children: "\u6700\u65B0\u4EF7" }) }),
|
|
5771
|
+
/* @__PURE__ */ jsx13(Box12, { width: 12, children: /* @__PURE__ */ jsx13(Text14, { dimColor: true, children: "\u6DA8\u8DCC\u5E45" }) }),
|
|
5772
|
+
/* @__PURE__ */ jsx13(Box12, { width: 12, children: /* @__PURE__ */ jsx13(Text14, { dimColor: true, children: "\u6DA8\u8DCC\u989D" }) }),
|
|
5773
|
+
/* @__PURE__ */ jsx13(Box12, { width: 12, children: /* @__PURE__ */ jsx13(Text14, { dimColor: true, children: "\u6700\u9AD8" }) }),
|
|
5774
|
+
/* @__PURE__ */ jsx13(Box12, { width: 12, children: /* @__PURE__ */ jsx13(Text14, { dimColor: true, children: "\u6700\u4F4E" }) }),
|
|
5775
|
+
/* @__PURE__ */ jsx13(Box12, { children: /* @__PURE__ */ jsx13(Text14, { dimColor: true, children: "\u6210\u4EA4\u989D" }) })
|
|
5758
5776
|
] }),
|
|
5759
|
-
/* @__PURE__ */
|
|
5760
|
-
/* @__PURE__ */
|
|
5777
|
+
/* @__PURE__ */ jsx13(Box12, { children: /* @__PURE__ */ jsx13(Text14, { dimColor: true, children: " " + "\u2500".repeat(100) }) }),
|
|
5778
|
+
/* @__PURE__ */ jsx13(Box12, { flexDirection: "column", children: stocks.map((stock, index) => {
|
|
5761
5779
|
const isSelected = index === selectedIndex;
|
|
5762
5780
|
const isUp = stock.changePercent >= 0;
|
|
5763
5781
|
const color = isUp ? "#ff1493" : "#00ff41";
|
|
5764
5782
|
return /* @__PURE__ */ jsxs12(Box12, { children: [
|
|
5765
|
-
/* @__PURE__ */
|
|
5766
|
-
/* @__PURE__ */
|
|
5767
|
-
/* @__PURE__ */
|
|
5768
|
-
/* @__PURE__ */
|
|
5769
|
-
/* @__PURE__ */
|
|
5783
|
+
/* @__PURE__ */ jsx13(Box12, { width: 3, flexShrink: 0, children: isSelected ? /* @__PURE__ */ jsx13(Text14, { bold: true, ...cp2("#00ffff"), children: "\u25B8 " }) : /* @__PURE__ */ jsx13(Text14, { children: " " }) }),
|
|
5784
|
+
/* @__PURE__ */ jsx13(Box12, { width: 9, children: /* @__PURE__ */ jsx13(Text14, { bold: true, ...cp2(isSelected ? "#00ffff" : "#ffffff"), children: stock.code }) }),
|
|
5785
|
+
/* @__PURE__ */ jsx13(Box12, { width: 16, children: /* @__PURE__ */ jsx13(Text14, { ...cp2(isSelected ? "#ffffff" : "#cccccc"), children: stock.name }) }),
|
|
5786
|
+
/* @__PURE__ */ jsx13(Box12, { width: 12, children: /* @__PURE__ */ jsx13(Text14, { bold: true, ...cp2(color), children: formatPrice(stock.price) }) }),
|
|
5787
|
+
/* @__PURE__ */ jsx13(Box12, { width: 12, children: /* @__PURE__ */ jsxs12(Text14, { ...cp2(color), children: [
|
|
5770
5788
|
isUp ? "+" : "",
|
|
5771
5789
|
stock.changePercent.toFixed(2),
|
|
5772
5790
|
"%"
|
|
5773
5791
|
] }) }),
|
|
5774
|
-
/* @__PURE__ */
|
|
5792
|
+
/* @__PURE__ */ jsx13(Box12, { width: 12, children: /* @__PURE__ */ jsxs12(Text14, { ...cp2(color), children: [
|
|
5775
5793
|
isUp ? "+" : "",
|
|
5776
5794
|
stock.changeAmount.toFixed(3)
|
|
5777
5795
|
] }) }),
|
|
5778
|
-
/* @__PURE__ */
|
|
5779
|
-
/* @__PURE__ */
|
|
5780
|
-
/* @__PURE__ */
|
|
5796
|
+
/* @__PURE__ */ jsx13(Box12, { width: 12, children: /* @__PURE__ */ jsx13(Text14, { ...cp2("#cccccc"), children: formatPrice(stock.high) }) }),
|
|
5797
|
+
/* @__PURE__ */ jsx13(Box12, { width: 12, children: /* @__PURE__ */ jsx13(Text14, { ...cp2("#888888"), children: formatPrice(stock.low) }) }),
|
|
5798
|
+
/* @__PURE__ */ jsx13(Box12, { children: /* @__PURE__ */ jsx13(Text14, { ...cp2("#888888"), children: formatAmount(stock.amount) }) })
|
|
5781
5799
|
] }, stock.code);
|
|
5782
5800
|
}) }),
|
|
5783
|
-
/* @__PURE__ */
|
|
5801
|
+
/* @__PURE__ */ jsx13(Box12, { marginTop: 1, children: /* @__PURE__ */ jsx13(Text14, { dimColor: true, children: ` \u2191/\u2193 \u9009\u62E9 Enter \u8BE6\u60C5 r \u624B\u52A8\u5237\u65B0 h \u7F6E\u7070/\u6062\u590D q \u8FD4\u56DE` }) }),
|
|
5784
5802
|
/* @__PURE__ */ jsxs12(Box12, { children: [
|
|
5785
|
-
/* @__PURE__ */
|
|
5786
|
-
/* @__PURE__ */
|
|
5803
|
+
/* @__PURE__ */ jsx13(Text14, { dimColor: true, children: ` \u6700\u540E\u66F4\u65B0: ${lastUpdate} \u7F16\u8F91\u81EA\u9009\u80A1: ` }),
|
|
5804
|
+
/* @__PURE__ */ jsx13(Text14, { ...cp2("#c792ea"), children: osc8Link(toFileUrl(SETTINGS_PATH), SETTINGS_PATH) })
|
|
5787
5805
|
] }),
|
|
5788
|
-
doubleCtrlC && /* @__PURE__ */
|
|
5806
|
+
doubleCtrlC && /* @__PURE__ */ jsx13(Box12, { marginTop: 1, children: /* @__PURE__ */ jsx13(Text14, { bold: true, ...cp2("#ff1493"), children: " \u26A0 \u518D\u6309\u4E00\u6B21 Ctrl+C \u9000\u51FA dskcode" }) })
|
|
5789
5807
|
] });
|
|
5790
5808
|
}
|
|
5791
5809
|
function renderDetail(stock, _onBack, prices, countdown = 10, currentTime) {
|
|
@@ -5806,30 +5824,30 @@ function renderDetail(stock, _onBack, prices, countdown = 10, currentTime) {
|
|
|
5806
5824
|
return /* @__PURE__ */ jsxs12(Box12, { flexDirection: "column", paddingLeft: 1, children: [
|
|
5807
5825
|
/* @__PURE__ */ jsxs12(Box12, { marginBottom: 1, justifyContent: "space-between", children: [
|
|
5808
5826
|
/* @__PURE__ */ jsxs12(Box12, { children: [
|
|
5809
|
-
/* @__PURE__ */ jsxs12(
|
|
5827
|
+
/* @__PURE__ */ jsxs12(Text14, { bold: true, color: "#00ffff", children: [
|
|
5810
5828
|
" \u{1F4CA} ",
|
|
5811
5829
|
stock.name,
|
|
5812
5830
|
" "
|
|
5813
5831
|
] }),
|
|
5814
|
-
/* @__PURE__ */
|
|
5815
|
-
currentTime && /* @__PURE__ */ jsxs12(
|
|
5832
|
+
/* @__PURE__ */ jsx13(Text14, { dimColor: true, children: stock.code }),
|
|
5833
|
+
currentTime && /* @__PURE__ */ jsxs12(Text14, { dimColor: true, children: [
|
|
5816
5834
|
" \u{1F550} ",
|
|
5817
5835
|
currentTime
|
|
5818
5836
|
] })
|
|
5819
5837
|
] }),
|
|
5820
|
-
/* @__PURE__ */
|
|
5838
|
+
/* @__PURE__ */ jsx13(Text14, { dimColor: true, children: `${countdown}s \u540E\u5237\u65B0` })
|
|
5821
5839
|
] }),
|
|
5822
5840
|
/* @__PURE__ */ jsxs12(Box12, { children: [
|
|
5823
|
-
/* @__PURE__ */
|
|
5824
|
-
/* @__PURE__ */
|
|
5841
|
+
/* @__PURE__ */ jsx13(Box12, { width: 16, children: /* @__PURE__ */ jsx13(Text14, { bold: true, color: "#888888", children: "\u5F53\u524D\u4EF7" }) }),
|
|
5842
|
+
/* @__PURE__ */ jsx13(Box12, { children: /* @__PURE__ */ jsxs12(Text14, { bold: true, color: colorCode, children: [
|
|
5825
5843
|
arrow,
|
|
5826
5844
|
" ",
|
|
5827
5845
|
formatPrice(stock.price)
|
|
5828
5846
|
] }) })
|
|
5829
5847
|
] }),
|
|
5830
5848
|
/* @__PURE__ */ jsxs12(Box12, { children: [
|
|
5831
|
-
/* @__PURE__ */
|
|
5832
|
-
/* @__PURE__ */
|
|
5849
|
+
/* @__PURE__ */ jsx13(Box12, { width: 16, children: /* @__PURE__ */ jsx13(Text14, { color: "#888888", children: "\u6DA8\u8DCC\u5E45" }) }),
|
|
5850
|
+
/* @__PURE__ */ jsx13(Box12, { children: /* @__PURE__ */ jsxs12(Text14, { color: colorCode, children: [
|
|
5833
5851
|
isUp ? "+" : "",
|
|
5834
5852
|
stock.changePercent.toFixed(2),
|
|
5835
5853
|
"%",
|
|
@@ -5838,8 +5856,8 @@ function renderDetail(stock, _onBack, prices, countdown = 10, currentTime) {
|
|
|
5838
5856
|
stock.changeAmount.toFixed(3)
|
|
5839
5857
|
] }) })
|
|
5840
5858
|
] }),
|
|
5841
|
-
chartLines.length > 0 && /* @__PURE__ */
|
|
5842
|
-
/* @__PURE__ */
|
|
5859
|
+
chartLines.length > 0 && /* @__PURE__ */ jsx13(Box12, { marginTop: 1, flexDirection: "column", children: chartLines.map((line, i) => /* @__PURE__ */ jsx13(Box12, { children: /* @__PURE__ */ jsx13(Text14, { color: colorCode, children: line || " " }) }, i)) }),
|
|
5860
|
+
/* @__PURE__ */ jsx13(Box12, { marginTop: 1, children: /* @__PURE__ */ jsx13(Text14, { dimColor: true, children: " Space/q \u8FD4\u56DE\u5217\u8868" }) })
|
|
5843
5861
|
] });
|
|
5844
5862
|
}
|
|
5845
5863
|
|
|
@@ -5924,7 +5942,7 @@ async function scanProjectFiles(baseDir, dir) {
|
|
|
5924
5942
|
}
|
|
5925
5943
|
|
|
5926
5944
|
// src/cli/index.tsx
|
|
5927
|
-
import { jsx as
|
|
5945
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
5928
5946
|
var SUBCOMMANDS = ["chat", "run", "setup", "init", "completion", "game", "stock"];
|
|
5929
5947
|
function createCli() {
|
|
5930
5948
|
const program2 = new Command();
|
|
@@ -5970,7 +5988,7 @@ function createCli() {
|
|
|
5970
5988
|
);
|
|
5971
5989
|
const model = defaultProvider?.model ?? "deepseek-v4-flash";
|
|
5972
5990
|
const chatApp = renderApp(
|
|
5973
|
-
/* @__PURE__ */
|
|
5991
|
+
/* @__PURE__ */ jsx14(
|
|
5974
5992
|
ChatSession,
|
|
5975
5993
|
{
|
|
5976
5994
|
skillCount,
|
|
@@ -5988,7 +6006,7 @@ function createCli() {
|
|
|
5988
6006
|
initGames();
|
|
5989
6007
|
const games = listGames();
|
|
5990
6008
|
const { unmount } = render4(
|
|
5991
|
-
/* @__PURE__ */
|
|
6009
|
+
/* @__PURE__ */ jsx14(
|
|
5992
6010
|
GamePicker,
|
|
5993
6011
|
{
|
|
5994
6012
|
games,
|
|
@@ -6012,7 +6030,7 @@ function createCli() {
|
|
|
6012
6030
|
setImmediate(() => {
|
|
6013
6031
|
const defaultStockCodes = ctx?.config.stock?.symbols?.map((s) => s.code) ?? ["sh000001", "sz399006", "sh601688"];
|
|
6014
6032
|
const stockApp = renderApp(
|
|
6015
|
-
/* @__PURE__ */
|
|
6033
|
+
/* @__PURE__ */ jsx14(
|
|
6016
6034
|
StockList,
|
|
6017
6035
|
{
|
|
6018
6036
|
codes: defaultStockCodes,
|
|
@@ -6099,7 +6117,7 @@ compdef _dskcode_completion dskcode`);
|
|
|
6099
6117
|
const freshResult = await loadAndValidate();
|
|
6100
6118
|
const codeList = codes && codes.length > 0 ? codes : freshResult.config.stock?.symbols?.map((s) => s.code) ?? ["sh000001", "sz399006", "sh601688"];
|
|
6101
6119
|
const app = renderApp(
|
|
6102
|
-
/* @__PURE__ */
|
|
6120
|
+
/* @__PURE__ */ jsx14(
|
|
6103
6121
|
StockList,
|
|
6104
6122
|
{
|
|
6105
6123
|
codes: codeList,
|
|
@@ -6128,7 +6146,7 @@ compdef _dskcode_completion dskcode`);
|
|
|
6128
6146
|
}
|
|
6129
6147
|
const selectedGame = await new Promise((resolve2) => {
|
|
6130
6148
|
const { unmount } = render4(
|
|
6131
|
-
/* @__PURE__ */
|
|
6149
|
+
/* @__PURE__ */ jsx14(
|
|
6132
6150
|
GamePicker,
|
|
6133
6151
|
{
|
|
6134
6152
|
games,
|