dskcode 0.1.24 → 0.1.26

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 CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  estimateTokens,
8
8
  getModelMeta,
9
9
  isSupportedModel
10
- } from "./chunk-I6HEIOSU.js";
10
+ } from "./chunk-UV4IWYHZ.js";
11
11
 
12
12
  // src/cli/index.tsx
13
13
  import { Command } from "commander";
@@ -805,7 +805,7 @@ var LOGO_LINES = [
805
805
  ];
806
806
 
807
807
  // src/ui/ChatSession.tsx
808
- import { Box as Box8, Text as Text10, useInput, Static } from "ink";
808
+ import { Box as Box9, Text as Text10, useInput, Static } from "ink";
809
809
  import TextInput from "ink-text-input";
810
810
  import { useEffect as useEffect3, useState as useState3, useCallback as useCallback2, useMemo, useRef as useRef2 } from "react";
811
811
 
@@ -841,7 +841,7 @@ function useDoubleCtrlC(onExit) {
841
841
  import InkSpinner2 from "ink-spinner";
842
842
 
843
843
  // src/ui/AssistantMessage.tsx
844
- import { Box as Box4, Text as Text6 } from "ink";
844
+ import { Box as Box5, Text as Text6 } from "ink";
845
845
 
846
846
  // src/provider/cost-tracker.ts
847
847
  import { mkdir as mkdir3, readFile as readFile3, writeFile as writeFile2 } from "fs/promises";
@@ -1248,8 +1248,69 @@ function formatUsageSummary(usage) {
1248
1248
  }
1249
1249
 
1250
1250
  // src/ui/HighlightedText.tsx
1251
- import { Text as Text5 } from "ink";
1252
- import { jsx as jsx4 } from "react/jsx-runtime";
1251
+ import { Box as Box4, Text as Text5 } from "ink";
1252
+ import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
1253
+ function parseCodeBlocks(text) {
1254
+ const segments = [];
1255
+ let current = 0;
1256
+ while (current < text.length) {
1257
+ const openIdx = text.indexOf("```", current);
1258
+ if (openIdx === -1) {
1259
+ segments.push({ text: text.slice(current), type: "plain" });
1260
+ break;
1261
+ }
1262
+ if (openIdx > current) {
1263
+ segments.push({ text: text.slice(current, openIdx), type: "plain" });
1264
+ }
1265
+ const closeIdx = text.indexOf("```", openIdx + 3);
1266
+ if (closeIdx === -1) {
1267
+ segments.push({ text: text.slice(openIdx), type: "plain" });
1268
+ break;
1269
+ }
1270
+ const codeContent = text.slice(openIdx + 3, closeIdx);
1271
+ segments.push({ text: codeContent, type: "code_block" });
1272
+ current = closeIdx + 3;
1273
+ }
1274
+ return segments;
1275
+ }
1276
+ function isTableRow(line) {
1277
+ const t = line.trim();
1278
+ return /^\|.+\|$/.test(t);
1279
+ }
1280
+ function isTableSepRow(line) {
1281
+ const t = line.trim();
1282
+ return /^\|[-: |]+\|$/.test(t) && t.includes("-");
1283
+ }
1284
+ function parseTables(text) {
1285
+ const lines = text.split("\n");
1286
+ const result = [];
1287
+ let plainBuf = "";
1288
+ function flushPlain() {
1289
+ if (plainBuf) {
1290
+ result.push({ text: plainBuf, type: "plain" });
1291
+ plainBuf = "";
1292
+ }
1293
+ }
1294
+ for (let i = 0; i < lines.length; i++) {
1295
+ const line = lines[i] ?? "";
1296
+ if (isTableRow(line) && i + 1 < lines.length && isTableSepRow(lines[i + 1] ?? "") && i + 2 < lines.length && isTableRow(lines[i + 2] ?? "")) {
1297
+ flushPlain();
1298
+ const tableLineList = [];
1299
+ let j = i;
1300
+ while (j < lines.length && isTableRow(lines[j] ?? "")) {
1301
+ tableLineList.push(lines[j]);
1302
+ j++;
1303
+ }
1304
+ result.push({ text: tableLineList.join("\n"), type: "table" });
1305
+ i = j - 1;
1306
+ } else {
1307
+ if (plainBuf) plainBuf += "\n" + line;
1308
+ else plainBuf = line;
1309
+ }
1310
+ }
1311
+ flushPlain();
1312
+ return result;
1313
+ }
1253
1314
  function parseBoldPairs(text) {
1254
1315
  const segments = [];
1255
1316
  let current = 0;
@@ -1272,24 +1333,23 @@ function parseBoldPairs(text) {
1272
1333
  }
1273
1334
  return segments;
1274
1335
  }
1275
- function parseCodePairs(segments) {
1336
+ function parseInlineCode(text) {
1276
1337
  const result = [];
1277
- for (const seg of segments) {
1278
- if (seg.type !== "plain") {
1279
- result.push(seg);
1280
- continue;
1338
+ let current = 0;
1339
+ while (current < text.length) {
1340
+ const openIdx = text.indexOf("`", current);
1341
+ if (openIdx === -1) {
1342
+ result.push({ text: text.slice(current), type: "plain" });
1343
+ break;
1281
1344
  }
1282
- let current = 0;
1283
- const text = seg.text;
1284
- while (current < text.length) {
1285
- const openIdx = text.indexOf("`", current);
1286
- if (openIdx === -1) {
1287
- result.push({ text: text.slice(current), type: "plain" });
1288
- break;
1289
- }
1290
- if (openIdx > current) {
1291
- result.push({ text: text.slice(current, openIdx), type: "plain" });
1292
- }
1345
+ if (openIdx > current) {
1346
+ result.push({ text: text.slice(current, openIdx), type: "plain" });
1347
+ }
1348
+ let runLength = 1;
1349
+ while (openIdx + runLength < text.length && text[openIdx + runLength] === "`") {
1350
+ runLength++;
1351
+ }
1352
+ if (runLength === 1) {
1293
1353
  const closeIdx = text.indexOf("`", openIdx + 1);
1294
1354
  if (closeIdx === -1) {
1295
1355
  result.push({ text: text.slice(openIdx), type: "plain" });
@@ -1297,32 +1357,296 @@ function parseCodePairs(segments) {
1297
1357
  }
1298
1358
  result.push({ text: text.slice(openIdx + 1, closeIdx), type: "code" });
1299
1359
  current = closeIdx + 1;
1360
+ } else {
1361
+ result.push({
1362
+ text: text.slice(openIdx, openIdx + runLength),
1363
+ type: "plain"
1364
+ });
1365
+ current = openIdx + runLength;
1300
1366
  }
1301
1367
  }
1302
1368
  return result;
1303
1369
  }
1370
+ function parseCodePairs(segments) {
1371
+ const result = [];
1372
+ for (const seg of segments) {
1373
+ if (seg.type === "code_block" || seg.type === "table") {
1374
+ result.push(seg);
1375
+ continue;
1376
+ }
1377
+ const parts = parseInlineCode(seg.text);
1378
+ for (const part of parts) {
1379
+ if (part.type === "code") {
1380
+ result.push(part);
1381
+ } else if (seg.type === "bold") {
1382
+ result.push({ text: part.text, type: "bold" });
1383
+ } else {
1384
+ result.push(part);
1385
+ }
1386
+ }
1387
+ }
1388
+ return result;
1389
+ }
1390
+ var DIFF_ADD_COLOR = "#22c55e";
1391
+ var DIFF_DEL_COLOR = "#ef4444";
1392
+ var DIFF_HUNK_COLOR = "#00cccc";
1393
+ function CodeBlockRenderer({ code }) {
1394
+ const lines = code.split("\n");
1395
+ const firstLine = lines[0] ?? "";
1396
+ const hasLangLine = firstLine.trim().length > 0 && !firstLine.startsWith("+") && !firstLine.startsWith("-") && !firstLine.startsWith("@@") && !firstLine.startsWith(" ");
1397
+ const lang = hasLangLine ? firstLine : void 0;
1398
+ const codeLines = hasLangLine ? lines.slice(1) : lines;
1399
+ if (codeLines.length === 0) {
1400
+ return hasLangLine ? /* @__PURE__ */ jsx4(Box4, { marginLeft: 2, children: /* @__PURE__ */ jsxs4(Text5, { color: "#888888", children: [
1401
+ "\u250C ",
1402
+ lang
1403
+ ] }) }) : null;
1404
+ }
1405
+ return /* @__PURE__ */ jsxs4(Box4, { flexDirection: "column", marginLeft: 2, marginTop: 1, children: [
1406
+ lang && /* @__PURE__ */ jsxs4(Text5, { color: "#888888", children: [
1407
+ "\u250C ",
1408
+ lang
1409
+ ] }),
1410
+ codeLines.map((line, i) => {
1411
+ if (line.startsWith("+")) {
1412
+ return /* @__PURE__ */ jsx4(Text5, { color: DIFF_ADD_COLOR, children: line }, i);
1413
+ }
1414
+ if (line.startsWith("-")) {
1415
+ return /* @__PURE__ */ jsx4(Text5, { color: DIFF_DEL_COLOR, children: line }, i);
1416
+ }
1417
+ if (line.startsWith("@@")) {
1418
+ return /* @__PURE__ */ jsx4(Text5, { color: DIFF_HUNK_COLOR, children: line }, i);
1419
+ }
1420
+ return /* @__PURE__ */ jsx4(Text5, { children: line }, i);
1421
+ })
1422
+ ] });
1423
+ }
1424
+ var TABLE_MAX_WIDTH = 90;
1425
+ var TABLE_MIN_COL_WIDTH = 3;
1426
+ function charWidth(ch) {
1427
+ const cp2 = ch.codePointAt(0);
1428
+ if (cp2 === void 0) return 0;
1429
+ if (cp2 >= 4352 && cp2 <= 4447 || // Hangul Jamo
1430
+ cp2 === 9001 || cp2 === 9002 || cp2 >= 11904 && cp2 <= 42191 || // CJK Radicals ~ Yi
1431
+ cp2 >= 43360 && cp2 <= 43391 || // Hangul Extended
1432
+ cp2 >= 44032 && cp2 <= 55215 || // Hangul Syllables
1433
+ cp2 >= 63744 && cp2 <= 64255 || // CJK Compat
1434
+ cp2 >= 65040 && cp2 <= 65055 || // Vertical forms
1435
+ cp2 >= 65281 && cp2 <= 65376 || // Fullwidth
1436
+ cp2 >= 65504 && cp2 <= 65510 || cp2 >= 126976 && cp2 <= 131071) {
1437
+ return 2;
1438
+ }
1439
+ return 1;
1440
+ }
1441
+ function visualWidth(text) {
1442
+ let w = 0;
1443
+ for (const ch of text) {
1444
+ w += charWidth(ch);
1445
+ }
1446
+ return w;
1447
+ }
1448
+ function padToWidth(text, targetWidth, align) {
1449
+ const vw = visualWidth(text);
1450
+ const delta = targetWidth - vw;
1451
+ if (delta <= 0) return text;
1452
+ const leftPad = align === "right" ? delta : align === "center" ? Math.floor(delta / 2) : 0;
1453
+ const rightPad = delta - leftPad;
1454
+ return " ".repeat(leftPad) + text + " ".repeat(rightPad);
1455
+ }
1456
+ function parseTableCells(line) {
1457
+ const t = line.trim();
1458
+ const inner = t.slice(1, t.length - 1);
1459
+ return inner.split("|").map((c) => c.trim());
1460
+ }
1461
+ function parseAlignments(sepLine) {
1462
+ const cells = parseTableCells(sepLine);
1463
+ return cells.map((c) => {
1464
+ const l = c.startsWith(":");
1465
+ const r = c.endsWith(":");
1466
+ if (l && r) return "center";
1467
+ if (r) return "right";
1468
+ return "left";
1469
+ });
1470
+ }
1471
+ function TableRenderer({ text }) {
1472
+ const rawLines = text.split("\n").filter((l) => l.trim().length > 0);
1473
+ if (rawLines.length < 2) return /* @__PURE__ */ jsx4(Text5, { children: text });
1474
+ let sepIdx = -1;
1475
+ for (let k = 0; k < rawLines.length; k++) {
1476
+ if (isTableSepRow(rawLines[k])) {
1477
+ sepIdx = k;
1478
+ break;
1479
+ }
1480
+ }
1481
+ if (sepIdx === -1) return /* @__PURE__ */ jsx4(Text5, { children: text });
1482
+ const headerText = rawLines.slice(0, sepIdx).join("");
1483
+ const headerCells = parseTableCells(headerText);
1484
+ const alignments = parseAlignments(rawLines[sepIdx]);
1485
+ const dataRows = rawLines.slice(sepIdx + 1).map(parseTableCells);
1486
+ const colCount = headerCells.length;
1487
+ const colMaxWidths = headerCells.map((_, ci) => {
1488
+ let max = visualWidth(headerCells[ci] ?? "");
1489
+ for (const row of dataRows) {
1490
+ const w = visualWidth(row[ci] ?? "");
1491
+ if (w > max) max = w;
1492
+ }
1493
+ return Math.max(max, TABLE_MIN_COL_WIDTH);
1494
+ });
1495
+ const margin = 2;
1496
+ const totalMinWidth = colMaxWidths.reduce((s, w) => s + w + margin, 1);
1497
+ let colWidths;
1498
+ if (totalMinWidth <= TABLE_MAX_WIDTH) {
1499
+ colWidths = colMaxWidths;
1500
+ } else {
1501
+ const available = TABLE_MAX_WIDTH - 1 - margin * colCount;
1502
+ const sum = colMaxWidths.reduce((s, w) => s + w, 0);
1503
+ colWidths = colMaxWidths.map((w) => Math.max(TABLE_MIN_COL_WIDTH, Math.floor(w / sum * available)));
1504
+ }
1505
+ const H = "\u2500";
1506
+ const makeSep = (l, m, r) => l + colWidths.map((w) => H.repeat(w + margin)).join(m) + r;
1507
+ const topBorder = makeSep("\u250C", "\u252C", "\u2510");
1508
+ const midBorder = makeSep("\u251C", "\u253C", "\u2524");
1509
+ const botBorder = makeSep("\u2514", "\u2534", "\u2518");
1510
+ function rowLine(cells, keyBase) {
1511
+ return /* @__PURE__ */ jsxs4(Text5, { children: [
1512
+ "\u2502",
1513
+ cells.map((cell, ci) => /* @__PURE__ */ jsxs4(Text5, { children: [
1514
+ " ",
1515
+ padToWidth(cell.slice(0, colWidths[ci] ?? TABLE_MIN_COL_WIDTH), colWidths[ci] ?? TABLE_MIN_COL_WIDTH, alignments[ci] ?? "left"),
1516
+ " ",
1517
+ "\u2502"
1518
+ ] }, ci))
1519
+ ] }, keyBase);
1520
+ }
1521
+ const rows = [
1522
+ /* @__PURE__ */ jsx4(Text5, { color: "#888888", children: topBorder }, "top"),
1523
+ rowLine(headerCells, "hdr"),
1524
+ /* @__PURE__ */ jsx4(Text5, { color: "#888888", children: midBorder }, "mid"),
1525
+ ...dataRows.map((cells, ri) => rowLine(cells, `d${ri}`)),
1526
+ /* @__PURE__ */ jsx4(Text5, { color: "#888888", children: botBorder }, "bot")
1527
+ ];
1528
+ return /* @__PURE__ */ jsx4(Box4, { flexDirection: "column", marginTop: 1, children: rows });
1529
+ }
1530
+ var EMOJI_CP_RE = /[\u{1F000}-\u{1FFFF}\u{FE00}-\u{FE0F}\u{200D}\u{20E3}\u{2600}-\u{27BF}\u{231A}-\u{23FF}\u{2934}\u{2935}\u{25AA}-\u{25FE}\u{2B50}\u{2B55}\u{00A9}\u{00AE}\u{2122}\u{3030}\u{303D}\u{3297}\u{3299}]/u;
1531
+ function isEmojiCluster(text) {
1532
+ return EMOJI_CP_RE.test(text);
1533
+ }
1534
+ function splitEmojiClusters(text) {
1535
+ try {
1536
+ const segmenter = new Intl.Segmenter("en", {
1537
+ granularity: "grapheme"
1538
+ });
1539
+ const segments = [...segmenter.segment(text)];
1540
+ return segments.map((s) => ({
1541
+ text: s.segment,
1542
+ isEmoji: isEmojiCluster(s.segment)
1543
+ }));
1544
+ } catch {
1545
+ return [{ text, isEmoji: false }];
1546
+ }
1547
+ }
1548
+ function renderBoldText(text, key) {
1549
+ const clusters = splitEmojiClusters(text);
1550
+ if (clusters.length === 1 && !clusters[0].isEmoji) {
1551
+ return /* @__PURE__ */ jsx4(Text5, { color: BOLD_COLOR, children: text }, key);
1552
+ }
1553
+ const groups = [];
1554
+ for (const c of clusters) {
1555
+ const last = groups[groups.length - 1];
1556
+ if (last && last.isEmoji === c.isEmoji) {
1557
+ last.text += c.text;
1558
+ } else {
1559
+ groups.push({ text: c.text, isEmoji: c.isEmoji });
1560
+ }
1561
+ }
1562
+ return /* @__PURE__ */ jsx4(Text5, { children: groups.map(
1563
+ (g, i) => g.isEmoji ? g.text : /* @__PURE__ */ jsx4(Text5, { color: BOLD_COLOR, children: g.text }, i)
1564
+ ) }, key);
1565
+ }
1304
1566
  var CODE_COLOR = "#00BFFF";
1305
1567
  var BOLD_COLOR = "#A855F7";
1306
1568
  function HighlightedText({ children: text }) {
1307
- const boldSegments = parseBoldPairs(text);
1308
- const segments = parseCodePairs(boldSegments);
1309
- const isSimple = segments.length === 1 && segments[0].type === "plain";
1310
- if (isSimple) {
1311
- return /* @__PURE__ */ jsx4(Text5, { wrap: "wrap", children: text });
1569
+ const codeBlockSegments = parseCodeBlocks(text);
1570
+ const tableSegments = [];
1571
+ for (const seg of codeBlockSegments) {
1572
+ if (seg.type === "code_block") {
1573
+ tableSegments.push(seg);
1574
+ } else {
1575
+ tableSegments.push(...parseTables(seg.text));
1576
+ }
1312
1577
  }
1313
- return /* @__PURE__ */ jsx4(Text5, { wrap: "wrap", children: segments.map((seg, i) => {
1314
- if (seg.type === "code") {
1315
- return /* @__PURE__ */ jsx4(Text5, { color: CODE_COLOR, children: seg.text }, i);
1578
+ const boldSegments = [];
1579
+ for (const seg of tableSegments) {
1580
+ if (seg.type === "code_block" || seg.type === "table") {
1581
+ boldSegments.push(seg);
1582
+ } else {
1583
+ boldSegments.push(...parseBoldPairs(seg.text));
1316
1584
  }
1317
- if (seg.type === "bold") {
1318
- return /* @__PURE__ */ jsx4(Text5, { color: BOLD_COLOR, children: seg.text }, i);
1585
+ }
1586
+ const segments = parseCodePairs(boldSegments);
1587
+ const hasBlock = segments.some(
1588
+ (s) => s.type === "code_block" || s.type === "table"
1589
+ );
1590
+ if (!hasBlock) {
1591
+ const isSimple = segments.length === 1 && segments[0].type === "plain";
1592
+ if (isSimple) {
1593
+ return /* @__PURE__ */ jsx4(Text5, { wrap: "wrap", children: text });
1594
+ }
1595
+ return /* @__PURE__ */ jsx4(Text5, { wrap: "wrap", children: segments.map((seg, i) => {
1596
+ if (seg.type === "code") {
1597
+ return /* @__PURE__ */ jsx4(Text5, { color: CODE_COLOR, children: seg.text }, i);
1598
+ }
1599
+ if (seg.type === "bold") {
1600
+ return renderBoldText(seg.text, i);
1601
+ }
1602
+ return seg.text;
1603
+ }) });
1604
+ }
1605
+ const rendered = [];
1606
+ let inlineGroup = [];
1607
+ function flushInline(groupIdx) {
1608
+ if (inlineGroup.length === 0) return;
1609
+ const isSimpleInline = inlineGroup.length === 1 && inlineGroup[0].type === "plain";
1610
+ if (isSimpleInline) {
1611
+ rendered.push(
1612
+ /* @__PURE__ */ jsx4(Text5, { wrap: "wrap", children: inlineGroup[0].text }, groupIdx)
1613
+ );
1614
+ } else {
1615
+ rendered.push(
1616
+ /* @__PURE__ */ jsx4(Text5, { wrap: "wrap", children: inlineGroup.map((seg, j) => {
1617
+ if (seg.type === "code") {
1618
+ return /* @__PURE__ */ jsx4(Text5, { color: CODE_COLOR, children: seg.text }, j);
1619
+ }
1620
+ if (seg.type === "bold") {
1621
+ return renderBoldText(seg.text, j);
1622
+ }
1623
+ return seg.text;
1624
+ }) }, groupIdx)
1625
+ );
1626
+ }
1627
+ inlineGroup = [];
1628
+ }
1629
+ for (const seg of segments) {
1630
+ if (seg.type === "code_block") {
1631
+ flushInline(rendered.length);
1632
+ rendered.push(
1633
+ /* @__PURE__ */ jsx4(CodeBlockRenderer, { code: seg.text }, `b${rendered.length}`)
1634
+ );
1635
+ } else if (seg.type === "table") {
1636
+ flushInline(rendered.length);
1637
+ rendered.push(
1638
+ /* @__PURE__ */ jsx4(TableRenderer, { text: seg.text }, `t${rendered.length}`)
1639
+ );
1640
+ } else {
1641
+ inlineGroup.push(seg);
1319
1642
  }
1320
- return seg.text;
1321
- }) });
1643
+ }
1644
+ flushInline(rendered.length);
1645
+ return /* @__PURE__ */ jsx4(Box4, { flexDirection: "column", children: rendered });
1322
1646
  }
1323
1647
 
1324
1648
  // src/ui/AssistantMessage.tsx
1325
- import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
1649
+ import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
1326
1650
  function formatElapsed(ms) {
1327
1651
  if (ms < 1e3) return `${ms}ms`;
1328
1652
  const seconds = (ms / 1e3).toFixed(1);
@@ -1335,28 +1659,28 @@ function AssistantMessage({
1335
1659
  usage,
1336
1660
  elapsed,
1337
1661
  cost,
1338
- model
1662
+ model: _model
1339
1663
  }) {
1340
1664
  if (!content && (!toolCalls || toolCalls.length === 0) && !isStreaming) {
1341
1665
  return null;
1342
1666
  }
1343
- return /* @__PURE__ */ jsxs4(Box4, { flexDirection: "column", marginTop: 1, children: [
1344
- /* @__PURE__ */ jsxs4(Box4, { flexDirection: "row", children: [
1345
- /* @__PURE__ */ jsx5(Box4, { width: 4, flexShrink: 0, children: /* @__PURE__ */ jsx5(Text6, { bold: true, color: "#ff00ff", children: "\u{1F916}" }) }),
1346
- /* @__PURE__ */ jsxs4(Box4, { flexGrow: 1, flexDirection: "column", children: [
1667
+ return /* @__PURE__ */ jsxs5(Box5, { flexDirection: "column", marginTop: 1, children: [
1668
+ /* @__PURE__ */ jsxs5(Box5, { flexDirection: "row", children: [
1669
+ /* @__PURE__ */ jsx5(Box5, { width: 4, flexShrink: 0, children: /* @__PURE__ */ jsx5(Text6, { bold: true, color: "#ff00ff", children: "\u{1F916}" }) }),
1670
+ /* @__PURE__ */ jsxs5(Box5, { flexGrow: 1, flexDirection: "column", children: [
1347
1671
  content && /* @__PURE__ */ jsx5(HighlightedText, { children: content }),
1348
1672
  isStreaming && !content && /* @__PURE__ */ jsx5(Text6, { color: "#888888", children: "..." })
1349
1673
  ] })
1350
1674
  ] }),
1351
- toolCalls && toolCalls.length > 0 && /* @__PURE__ */ jsx5(Box4, { flexDirection: "column", children: toolCalls.map((tc, i) => /* @__PURE__ */ jsx5(ToolCallBlock, { call: tc }, tc.id ?? i)) }),
1352
- !isStreaming && (usage || elapsed !== void 0) && /* @__PURE__ */ jsxs4(Box4, { flexDirection: "column", marginTop: 1, marginLeft: 3, children: [
1675
+ toolCalls && toolCalls.length > 0 && /* @__PURE__ */ jsx5(Box5, { flexDirection: "column", children: toolCalls.map((tc, i) => /* @__PURE__ */ jsx5(ToolCallBlock, { call: tc }, tc.id ?? i)) }),
1676
+ !isStreaming && (usage || elapsed !== void 0) && /* @__PURE__ */ jsxs5(Box5, { flexDirection: "column", marginTop: 1, marginLeft: 3, children: [
1353
1677
  /* @__PURE__ */ jsx5(Text6, { color: "#555555", children: "\u2500".repeat(36) }),
1354
- /* @__PURE__ */ jsxs4(Box4, { flexDirection: "row", gap: 2, children: [
1355
- cost !== void 0 && cost > 0 && /* @__PURE__ */ jsxs4(Text6, { color: "yellow", children: [
1678
+ /* @__PURE__ */ jsxs5(Box5, { flexDirection: "row", gap: 2, children: [
1679
+ cost !== void 0 && cost > 0 && /* @__PURE__ */ jsxs5(Text6, { color: "yellow", children: [
1356
1680
  "\u{1F4B0} \u672C\u6B21 ",
1357
1681
  formatMoney(cost)
1358
1682
  ] }),
1359
- elapsed !== void 0 && /* @__PURE__ */ jsxs4(Text6, { color: "cyan", children: [
1683
+ elapsed !== void 0 && /* @__PURE__ */ jsxs5(Text6, { color: "cyan", children: [
1360
1684
  "\u{1F550} ",
1361
1685
  formatElapsed(elapsed)
1362
1686
  ] }),
@@ -1367,8 +1691,8 @@ function AssistantMessage({
1367
1691
  }
1368
1692
 
1369
1693
  // src/ui/DiffPreview.tsx
1370
- import { Box as Box5, Text as Text7 } from "ink";
1371
- import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
1694
+ import { Box as Box6, Text as Text7 } from "ink";
1695
+ import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
1372
1696
  function DiffPreview({ diff }) {
1373
1697
  const { patch, additions, deletions, existedBefore, filePath } = diff;
1374
1698
  if (!patch || patch.length === 0) {
@@ -1376,15 +1700,15 @@ function DiffPreview({ diff }) {
1376
1700
  }
1377
1701
  const lines = patch.split("\n");
1378
1702
  const fileName = filePath.replace(/\\/g, "/").split("/").pop() ?? filePath;
1379
- return /* @__PURE__ */ jsxs5(Box5, { flexDirection: "column", marginTop: 1, children: [
1380
- /* @__PURE__ */ jsxs5(Box5, { flexDirection: "row", gap: 1, children: [
1381
- /* @__PURE__ */ jsxs5(Text7, { bold: true, color: "#00ffff", children: [
1703
+ return /* @__PURE__ */ jsxs6(Box6, { flexDirection: "column", marginTop: 1, children: [
1704
+ /* @__PURE__ */ jsxs6(Box6, { flexDirection: "row", gap: 1, children: [
1705
+ /* @__PURE__ */ jsxs6(Text7, { bold: true, color: "#00ffff", children: [
1382
1706
  "\u{1F4DD} ",
1383
1707
  existedBefore ? "\u4FEE\u6539" : "\u65B0\u5EFA",
1384
1708
  ":"
1385
1709
  ] }),
1386
1710
  /* @__PURE__ */ jsx6(Text7, { bold: true, children: fileName }),
1387
- /* @__PURE__ */ jsxs5(Text7, { color: "#555555", children: [
1711
+ /* @__PURE__ */ jsxs6(Text7, { color: "#555555", children: [
1388
1712
  "(+",
1389
1713
  additions,
1390
1714
  " -",
@@ -1392,7 +1716,7 @@ function DiffPreview({ diff }) {
1392
1716
  ")"
1393
1717
  ] })
1394
1718
  ] }),
1395
- /* @__PURE__ */ jsx6(Box5, { flexDirection: "column", marginLeft: 2, children: lines.filter((line) => !line.startsWith("---") && !line.startsWith("+++")).map((line, i) => /* @__PURE__ */ jsx6(DiffLine, { line }, i)) })
1719
+ /* @__PURE__ */ jsx6(Box6, { flexDirection: "column", marginLeft: 2, children: lines.filter((line) => !line.startsWith("---") && !line.startsWith("+++")).map((line, i) => /* @__PURE__ */ jsx6(DiffLine, { line }, i)) })
1396
1720
  ] });
1397
1721
  }
1398
1722
  function DiffLine({ line }) {
@@ -1412,8 +1736,8 @@ function DiffLine({ line }) {
1412
1736
  }
1413
1737
 
1414
1738
  // src/ui/SkillSelector.tsx
1415
- import { Box as Box6, Text as Text8 } from "ink";
1416
- import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
1739
+ import { Box as Box7, Text as Text8 } from "ink";
1740
+ import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
1417
1741
  var HIGHLIGHT_COLOR = "#00bfff";
1418
1742
  function SkillSelector({ skills, input, selectedIndex }) {
1419
1743
  const match = input.match(/(?:^|\s)\/([^/]*)$/);
@@ -1421,21 +1745,21 @@ function SkillSelector({ skills, input, selectedIndex }) {
1421
1745
  const query = match[1].toLowerCase().trim();
1422
1746
  if (skills.length === 0) return null;
1423
1747
  const matched = !query && input.startsWith("/") ? skills.slice(0, 3) : skills.filter((s) => s.name.toLowerCase().includes(query)).slice(0, 3);
1424
- if (query && matched.length > 0 && matched.some((s) => s.name.toLowerCase() === query)) return null;
1748
+ if (query && matched.some((s) => s.name.toLowerCase() === query)) return null;
1425
1749
  if (matched.length === 0) return null;
1426
- return /* @__PURE__ */ jsxs6(Box6, { flexDirection: "column", marginLeft: 4, marginTop: 1, children: [
1750
+ return /* @__PURE__ */ jsxs7(Box7, { flexDirection: "column", marginLeft: 4, marginTop: 1, children: [
1427
1751
  /* @__PURE__ */ jsx7(Text8, { color: "#808080", dimColor: true, children: "\u652F\u6301\u7684 Skill\uFF1A" }),
1428
- matched.map((skill, i) => /* @__PURE__ */ jsx7(Box6, { children: /* @__PURE__ */ jsxs6(Text8, { color: i === selectedIndex ? HIGHLIGHT_COLOR : "#808080", children: [
1752
+ matched.map((skill, i) => /* @__PURE__ */ jsx7(Box7, { children: /* @__PURE__ */ jsxs7(Text8, { color: i === selectedIndex ? HIGHLIGHT_COLOR : "#808080", children: [
1429
1753
  i === selectedIndex ? " \u203A " : " ",
1430
1754
  skill.name
1431
1755
  ] }) }, skill.name)),
1432
- /* @__PURE__ */ jsx7(Box6, { marginTop: 1, children: /* @__PURE__ */ jsx7(Text8, { color: "#808080", dimColor: true, children: "\u2191\u2193 \u9009\u62E9 \xB7 Tab \u8865\u5168" }) })
1756
+ /* @__PURE__ */ jsx7(Box7, { marginTop: 1, children: /* @__PURE__ */ jsx7(Text8, { color: "#808080", dimColor: true, children: "\u2191\u2193 \u9009\u62E9 \xB7 Tab \u8865\u5168" }) })
1433
1757
  ] });
1434
1758
  }
1435
1759
 
1436
1760
  // src/ui/FileSelector.tsx
1437
- import { Box as Box7, Text as Text9 } from "ink";
1438
- import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
1761
+ import { Box as Box8, Text as Text9 } from "ink";
1762
+ import { jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
1439
1763
  var HIGHLIGHT_COLOR2 = "#00ff41";
1440
1764
  function FileSelector({ files, input, selectedIndex }) {
1441
1765
  const match = input.match(/(?:^|\s)@([^@]*)$/);
@@ -1445,13 +1769,13 @@ function FileSelector({ files, input, selectedIndex }) {
1445
1769
  const matched = !query && input.startsWith("@") ? files.slice(0, 5) : files.filter((f) => f.toLowerCase().includes(query)).slice(0, 5);
1446
1770
  if (query && matched.some((f) => f.toLowerCase() === query)) return null;
1447
1771
  if (matched.length === 0) return null;
1448
- return /* @__PURE__ */ jsxs7(Box7, { flexDirection: "column", marginLeft: 4, marginTop: 1, children: [
1772
+ return /* @__PURE__ */ jsxs8(Box8, { flexDirection: "column", marginLeft: 4, marginTop: 1, children: [
1449
1773
  /* @__PURE__ */ jsx8(Text9, { color: "#808080", dimColor: true, children: "\u9879\u76EE\u6587\u4EF6\uFF1A" }),
1450
- matched.map((file, i) => /* @__PURE__ */ jsx8(Box7, { children: /* @__PURE__ */ jsxs7(Text9, { color: i === selectedIndex ? HIGHLIGHT_COLOR2 : "#808080", children: [
1774
+ matched.map((file, i) => /* @__PURE__ */ jsx8(Box8, { children: /* @__PURE__ */ jsxs8(Text9, { color: i === selectedIndex ? HIGHLIGHT_COLOR2 : "#808080", children: [
1451
1775
  i === selectedIndex ? " \u203A " : " ",
1452
1776
  file
1453
1777
  ] }) }, file)),
1454
- /* @__PURE__ */ jsx8(Box7, { marginTop: 1, children: /* @__PURE__ */ jsx8(Text9, { color: "#808080", dimColor: true, children: "\u2191\u2193 \u9009\u62E9 \xB7 Tab \u8865\u5168" }) })
1778
+ /* @__PURE__ */ jsx8(Box8, { marginTop: 1, children: /* @__PURE__ */ jsx8(Text9, { color: "#808080", dimColor: true, children: "\u2191\u2193 \u9009\u62E9 \xB7 Tab \u8865\u5168" }) })
1455
1779
  ] });
1456
1780
  }
1457
1781
 
@@ -1499,6 +1823,7 @@ defaultRegistry.register("deepseek", (config) => {
1499
1823
  return new DeepSeekProvider({
1500
1824
  apiKey: config.apiKey,
1501
1825
  baseUrl: config.baseUrl,
1826
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
1502
1827
  model: config.model
1503
1828
  });
1504
1829
  });
@@ -1531,7 +1856,7 @@ function eraseTool(tool) {
1531
1856
  return tool.execute(args, ctx);
1532
1857
  },
1533
1858
  initialTitle(args) {
1534
- return tool.initialTitle?.(args) ?? `${tool.name}`;
1859
+ return tool.initialTitle?.(args) ?? tool.name;
1535
1860
  }
1536
1861
  };
1537
1862
  }
@@ -1548,10 +1873,10 @@ var AlwaysAllowGate = class {
1548
1873
  import Handlebars from "handlebars";
1549
1874
 
1550
1875
  // src/agent/prompts/system-prompt.hbs
1551
- 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';
1876
+ 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\r\n- **\u4E0D\u8981\u4F7F\u7528 `#` \u7B26\u53F7** \u2014 \u7EC8\u7AEF\u4E0D\u6E32\u67D3 Markdown \u6807\u9898\uFF0C\u8BF7\u7528 emoji + \u52A0\u7C97\u66FF\u4EE3\uFF08\u5982 `\u{1F4CC} **\u6807\u9898**`\uFF09\r\n\r\n\u6B63\u786E\u793A\u4F8B\uFF1A\r\n\r\n\u{1F4CC} **\u4FEE\u6539\u8BA1\u5212**\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';
1552
1877
 
1553
1878
  // src/agent/prompts/plan-prompt.hbs
1554
- var plan_prompt_default = "\u4F60\u662F dskcode\uFF0C\u5F53\u524D\u5DE5\u4F5C\u5728**\u8BA1\u5212\u6A21\u5F0F\uFF08Plan Mode\uFF09**\u3002\r\n\r\n\u5728\u6B64\u6A21\u5F0F\u4E0B\uFF0C**\u4F60\u53EA\u80FD\u8BFB\u53D6\u548C\u5206\u6790\u4EE3\u7801\uFF0C\u4E0D\u80FD\u6267\u884C\u4EFB\u4F55\u4FEE\u6539\u64CD\u4F5C**\u3002\u4F60\u7684\u804C\u8D23\u662F\u5E2E\u52A9\u7528\u6237\u7406\u89E3\u4EE3\u7801\u3001\u8BBE\u8BA1\u67B6\u6784\u3001\u89C4\u5212\u4EFB\u52A1\u3001\u8BC4\u4F30\u65B9\u6848\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- **\u7EDD\u4E0D\u6267\u884C\u4EFB\u4F55\u5199\u64CD\u4F5C** \u2014 \u4F60\u53EA\u80FD\u8BFB\u53D6\u548C\u5206\u6790\r\n\r\n## \u5DE5\u4F5C\u6D41\u7A0B\r\n1. \u6536\u5230\u7528\u6237\u8BF7\u6C42\r\n2. \u4F7F\u7528\u8BFB\u5DE5\u5177\uFF08read-file, grep, glob, ls, fetch\uFF09\u63A2\u7D22\u4EE3\u7801\u5E93\r\n3. \u6839\u636E\u53D1\u73B0\u7684\u4FE1\u606F\u63D0\u4F9B\u7ED3\u6784\u5316\u7684\u5206\u6790\u6216\u8BA1\u5212\r\n4. \u5DE5\u5177\u8FD4\u56DE\u51FA\u9519\u65F6\u5206\u6790\u539F\u56E0\u5E76\u4FEE\u6B63\u540E\u91CD\u8BD5\r\n5. \u5B8C\u6210\u540E\u8F93\u51FA\u6700\u7EC8\u5206\u6790\u7ED3\u679C\r\n\r\n## \u5DE5\u5177\u9650\u5236\r\n**\u4F60\u53EA\u80FD\u4F7F\u7528\u8BFB\u5DE5\u5177**\uFF0C\u4E0D\u80FD\u4F7F\u7528\u4EFB\u4F55\u5199\u5DE5\u5177\uFF08write-file, edit-file, multi-edit, delete-range, bash\uFF09\u3002\r\n\u5982\u679C\u7528\u6237\u8BF7\u6C42\u4FEE\u6539\u4EE3\u7801\uFF0C\u8BF7\uFF1A\r\n- \u63D0\u4F9B\u4FEE\u6539\u5EFA\u8BAE\u548C\u65B9\u6848\r\n- \u6307\u51FA\u9700\u8981\u4FEE\u6539\u7684\u6587\u4EF6\u548C\u4F4D\u7F6E\r\n- \u89E3\u91CA\u4FEE\u6539\u7684\u5F71\u54CD\r\n- \u4F46\u4E0D\u6267\u884C\u4EFB\u4F55\u4FEE\u6539\r\n\r\n## \u8BA1\u5212\u8F93\u51FA\u683C\u5F0F\r\n\r\n\u5F53\u7528\u6237\u8BF7\u6C42\u8BA1\u5212/\u65B9\u6848\u65F6\uFF0C\u5EFA\u8BAE\u6309\u7167\u4EE5\u4E0B\u7ED3\u6784\u7EC4\u7EC7\u8F93\u51FA\uFF1A\r\n\r\n\u{1F4CB} **\u6982\u8FF0**\r\n 1-2 \u53E5\u8BDD\u8BF4\u660E\u8981\u505A\u4EC0\u4E48\u4EE5\u53CA\u4E3A\u4EC0\u4E48\u8981\u505A\r\n\r\n\u{1F50D} **\u73B0\u72B6\u5206\u6790**\r\n \u5F53\u524D\u4EE3\u7801\u7684\u7EC4\u7EC7\u7ED3\u6784\u548C\u5173\u952E\u53D1\u73B0\r\n\r\n\u26A1 **\u5F71\u54CD\u8303\u56F4**\r\n \u54EA\u4E9B\u6587\u4EF6/\u6A21\u5757\u4F1A\u53D7\u5230\u5F71\u54CD\r\n\r\n\u{1F4DD} **\u5B9E\u65BD\u6B65\u9AA4**\r\n 1. \u7B2C\u4E00\u6B65\uFF08\u6587\u4EF6\u8DEF\u5F84/\u53D8\u66F4\u8BF4\u660E\uFF09\r\n 2. \u7B2C\u4E8C\u6B65\uFF08\u6587\u4EF6\u8DEF\u5F84/\u53D8\u66F4\u8BF4\u660E\uFF09\r\n 3. ...\r\n\r\n\u26A0\uFE0F **\u98CE\u9669\u4E0E\u6CE8\u610F\u4E8B\u9879**\r\n \u53EF\u80FD\u7684\u98CE\u9669\u70B9\u3001\u4F9D\u8D56\u5173\u7CFB\u3001\u56DE\u9000\u7B56\u7565\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- \u7528 emoji \u505A\u89C6\u89C9\u6807\u8BB0\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\u7528\u5355\u4E2A\u53CD\u5F15\u53F7 ` \u5305\u88F9\r\n- \u591A\u884C\u4EE3\u7801\u7528\u7F29\u8FDB 4 \u4E2A\u7A7A\u683C\u8868\u793A\r\n- \u6BB5\u843D\u95F4\u7528\u7A7A\u884C\u5206\u9694\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";
1879
+ var plan_prompt_default = "\u4F60\u662F dskcode\uFF0C\u5F53\u524D\u5DE5\u4F5C\u5728**\u8BA1\u5212\u6A21\u5F0F\uFF08Plan Mode\uFF09**\u3002\r\n\r\n\u5728\u6B64\u6A21\u5F0F\u4E0B\uFF0C**\u4F60\u53EA\u80FD\u8BFB\u53D6\u548C\u5206\u6790\u4EE3\u7801\uFF0C\u4E0D\u80FD\u6267\u884C\u4EFB\u4F55\u4FEE\u6539\u64CD\u4F5C**\u3002\u4F60\u7684\u804C\u8D23\u662F\u5E2E\u52A9\u7528\u6237\u7406\u89E3\u4EE3\u7801\u3001\u8BBE\u8BA1\u67B6\u6784\u3001\u89C4\u5212\u4EFB\u52A1\u3001\u8BC4\u4F30\u65B9\u6848\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- **\u7EDD\u4E0D\u6267\u884C\u4EFB\u4F55\u5199\u64CD\u4F5C** \u2014 \u4F60\u53EA\u80FD\u8BFB\u53D6\u548C\u5206\u6790\r\n\r\n## \u5DE5\u4F5C\u6D41\u7A0B\r\n1. \u6536\u5230\u7528\u6237\u8BF7\u6C42\r\n2. \u4F7F\u7528\u8BFB\u5DE5\u5177\uFF08read-file, grep, glob, ls, fetch\uFF09\u63A2\u7D22\u4EE3\u7801\u5E93\r\n3. \u6839\u636E\u53D1\u73B0\u7684\u4FE1\u606F\u63D0\u4F9B\u7ED3\u6784\u5316\u7684\u5206\u6790\u6216\u8BA1\u5212\r\n4. \u5DE5\u5177\u8FD4\u56DE\u51FA\u9519\u65F6\u5206\u6790\u539F\u56E0\u5E76\u4FEE\u6B63\u540E\u91CD\u8BD5\r\n5. \u5B8C\u6210\u540E\u8F93\u51FA\u6700\u7EC8\u5206\u6790\u7ED3\u679C\r\n\r\n## \u5DE5\u5177\u9650\u5236\r\n**\u4F60\u53EA\u80FD\u4F7F\u7528\u8BFB\u5DE5\u5177**\uFF0C\u4E0D\u80FD\u4F7F\u7528\u4EFB\u4F55\u5199\u5DE5\u5177\uFF08write-file, edit-file, multi-edit, delete-range, bash\uFF09\u3002\r\n\u5982\u679C\u7528\u6237\u8BF7\u6C42\u4FEE\u6539\u4EE3\u7801\uFF0C\u8BF7\uFF1A\r\n- \u63D0\u4F9B\u4FEE\u6539\u5EFA\u8BAE\u548C\u65B9\u6848\r\n- \u6307\u51FA\u9700\u8981\u4FEE\u6539\u7684\u6587\u4EF6\u548C\u4F4D\u7F6E\r\n- \u89E3\u91CA\u4FEE\u6539\u7684\u5F71\u54CD\r\n- \u4F46\u4E0D\u6267\u884C\u4EFB\u4F55\u4FEE\u6539\r\n\r\n## \u8BA1\u5212\u8F93\u51FA\u683C\u5F0F\r\n\r\n\u5F53\u7528\u6237\u8BF7\u6C42\u8BA1\u5212/\u65B9\u6848\u65F6\uFF0C\u5EFA\u8BAE\u6309\u7167\u4EE5\u4E0B\u7ED3\u6784\u7EC4\u7EC7\u8F93\u51FA\uFF1A\r\n\r\n\u{1F4CB} **\u6982\u8FF0**\r\n 1-2 \u53E5\u8BDD\u8BF4\u660E\u8981\u505A\u4EC0\u4E48\u4EE5\u53CA\u4E3A\u4EC0\u4E48\u8981\u505A\r\n\r\n\u{1F50D} **\u73B0\u72B6\u5206\u6790**\r\n \u5F53\u524D\u4EE3\u7801\u7684\u7EC4\u7EC7\u7ED3\u6784\u548C\u5173\u952E\u53D1\u73B0\r\n\r\n\u26A1 **\u5F71\u54CD\u8303\u56F4**\r\n \u54EA\u4E9B\u6587\u4EF6/\u6A21\u5757\u4F1A\u53D7\u5230\u5F71\u54CD\r\n\r\n\u{1F4DD} **\u5B9E\u65BD\u6B65\u9AA4**\r\n 1. \u7B2C\u4E00\u6B65\uFF08\u6587\u4EF6\u8DEF\u5F84/\u53D8\u66F4\u8BF4\u660E\uFF09\r\n 2. \u7B2C\u4E8C\u6B65\uFF08\u6587\u4EF6\u8DEF\u5F84/\u53D8\u66F4\u8BF4\u660E\uFF09\r\n 3. ...\r\n\r\n\u26A0\uFE0F **\u98CE\u9669\u4E0E\u6CE8\u610F\u4E8B\u9879**\r\n \u53EF\u80FD\u7684\u98CE\u9669\u70B9\u3001\u4F9D\u8D56\u5173\u7CFB\u3001\u56DE\u9000\u7B56\u7565\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- \u7528 emoji \u505A\u89C6\u89C9\u6807\u8BB0\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\u7528\u5355\u4E2A\u53CD\u5F15\u53F7 ` \u5305\u88F9\r\n- \u591A\u884C\u4EE3\u7801\u7528\u7F29\u8FDB 4 \u4E2A\u7A7A\u683C\u8868\u793A\r\n- \u6BB5\u843D\u95F4\u7528\u7A7A\u884C\u5206\u9694\r\n- **\u4E0D\u8981\u4F7F\u7528 `#` \u7B26\u53F7** \u2014 \u7EC8\u7AEF\u4E0D\u6E32\u67D3 Markdown \u6807\u9898\uFF0C\u8BF7\u7528 emoji + \u52A0\u7C97\u66FF\u4EE3\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";
1555
1880
 
1556
1881
  // src/agent/system-prompt.ts
1557
1882
  var compiledTemplate = Handlebars.compile(system_prompt_default);
@@ -1845,6 +2170,7 @@ var Session = class {
1845
2170
  const [trimmed] = trimMessages(
1846
2171
  [...this.#messages],
1847
2172
  {
2173
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
1848
2174
  model: this.#provider.model(),
1849
2175
  reservedForOutput: this.#options.reservedForOutput,
1850
2176
  systemPrompt,
@@ -1864,7 +2190,7 @@ var Session = class {
1864
2190
  let accumulatedText = "";
1865
2191
  let lastUsage;
1866
2192
  let lastToolCalls;
1867
- let lastFinishReason = null;
2193
+ let _lastFinishReason = null;
1868
2194
  for await (const chunk of stream) {
1869
2195
  if (chunk.content) {
1870
2196
  accumulatedText += chunk.content;
@@ -1877,7 +2203,7 @@ var Session = class {
1877
2203
  lastUsage = chunk.usage;
1878
2204
  }
1879
2205
  if (chunk.finishReason) {
1880
- lastFinishReason = chunk.finishReason;
2206
+ _lastFinishReason = chunk.finishReason;
1881
2207
  }
1882
2208
  }
1883
2209
  if (lastUsage) {
@@ -2083,6 +2409,7 @@ ${item.result.diff.patch}`;
2083
2409
  const toolDescs = enabledTools.map((t) => ({
2084
2410
  name: t.name,
2085
2411
  description: t.description,
2412
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
2086
2413
  parameters: t.parameters
2087
2414
  }));
2088
2415
  const opts = {
@@ -2108,6 +2435,7 @@ ${item.result.diff.patch}`;
2108
2435
  function: {
2109
2436
  name: t.name,
2110
2437
  description: t.description,
2438
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
2111
2439
  parameters: t.parameters
2112
2440
  }
2113
2441
  }));
@@ -2171,7 +2499,7 @@ function getDefaultTimeout() {
2171
2499
  return DEFAULT_TIMEOUT_MS;
2172
2500
  }
2173
2501
  async function execCommand(command, args, cwd, timeoutMs = DEFAULT_TIMEOUT_MS, signal, isShellCommand) {
2174
- return new Promise((resolve2) => {
2502
+ return new Promise((_resolve) => {
2175
2503
  let spawnCmd;
2176
2504
  let spawnArgs;
2177
2505
  let useShell;
@@ -2214,13 +2542,13 @@ async function execCommand(command, args, cwd, timeoutMs = DEFAULT_TIMEOUT_MS, s
2214
2542
  }
2215
2543
  child.on("close", (code) => {
2216
2544
  clearTimeout(timeout);
2217
- resolve2({ stdout, stderr, exitCode: code });
2545
+ _resolve({ stdout, stderr, exitCode: code });
2218
2546
  });
2219
2547
  child.on("error", (err) => {
2220
2548
  clearTimeout(timeout);
2221
2549
  stderr += `
2222
2550
  \u8FDB\u7A0B\u542F\u52A8\u5931\u8D25\uFF1A${err.message}`;
2223
- resolve2({ stdout, stderr, exitCode: null });
2551
+ _resolve({ stdout, stderr, exitCode: null });
2224
2552
  });
2225
2553
  });
2226
2554
  }
@@ -2263,42 +2591,41 @@ function computeLineDiff(oldLines, newLines) {
2263
2591
  const V = new Array(2 * maxD + 2).fill(-1);
2264
2592
  const offset = maxD;
2265
2593
  V[offset + 1] = 0;
2266
- outer:
2267
- for (let d = 0; d <= maxD; d++) {
2268
- const snapshot = /* @__PURE__ */ new Map();
2269
- const kStart = -d;
2270
- const kEnd = d;
2271
- for (let k = kStart; k <= kEnd; k += 2) {
2272
- const ki = k + offset;
2273
- let x;
2274
- if (k === -d || k !== d && V[ki - 1] < V[ki + 1]) {
2275
- x = V[ki + 1];
2276
- } else {
2277
- x = V[ki - 1] + 1;
2278
- }
2279
- let y = x - k;
2280
- while (x < N && y < M && oldLines[x] === newLines[y]) {
2281
- x++;
2282
- y++;
2283
- }
2284
- V[ki] = x;
2285
- snapshot.set(k, x);
2286
- if (x >= N && y >= M) {
2287
- trace.push(snapshot);
2288
- return backtrack(trace, N, M, oldLines, newLines, offset);
2289
- }
2594
+ for (let d = 0; d <= maxD; d++) {
2595
+ const snapshot = /* @__PURE__ */ new Map();
2596
+ const kStart = -d;
2597
+ const kEnd = d;
2598
+ for (let k = kStart; k <= kEnd; k += 2) {
2599
+ const ki = k + offset;
2600
+ let x;
2601
+ if (k === -d || k !== d && V[ki - 1] < V[ki + 1]) {
2602
+ x = V[ki + 1];
2603
+ } else {
2604
+ x = V[ki - 1] + 1;
2605
+ }
2606
+ let y = x - k;
2607
+ while (x < N && y < M && oldLines[x] === newLines[y]) {
2608
+ x++;
2609
+ y++;
2610
+ }
2611
+ V[ki] = x;
2612
+ snapshot.set(k, x);
2613
+ if (x >= N && y >= M) {
2614
+ trace.push(snapshot);
2615
+ return backtrack(trace, N, M, oldLines, newLines, offset);
2290
2616
  }
2291
- trace.push(snapshot);
2292
2617
  }
2618
+ trace.push(snapshot);
2619
+ }
2293
2620
  return oldLines.map((line) => ({ op: "remove", line })).concat(newLines.map((line) => ({ op: "add", line })));
2294
2621
  }
2295
- function backtrack(trace, N, M, oldLines, newLines, offset) {
2622
+ function backtrack(trace, N, M, oldLines, newLines, _offset) {
2296
2623
  const result = [];
2297
2624
  let x = N;
2298
2625
  let y = M;
2299
2626
  for (let d = trace.length - 1; d >= 1; d--) {
2300
2627
  const k = x - y;
2301
- const prevSnapshot = d > 0 ? trace[d - 1] : /* @__PURE__ */ new Map();
2628
+ const prevSnapshot = trace[d - 1];
2302
2629
  const prevKDown = prevSnapshot.get(k - 1);
2303
2630
  const prevKUp = prevSnapshot.get(k + 1);
2304
2631
  let prevK;
@@ -2687,7 +3014,7 @@ var writeFileTool = {
2687
3014
  } catch {
2688
3015
  }
2689
3016
  await mkdir4(dirname(filePath), { recursive: true });
2690
- const content = String(args.content);
3017
+ const content = args.content;
2691
3018
  await writeFileWithEol(filePath, oldContent, content);
2692
3019
  const diff = computeFileDiff(oldContent, content, filePath);
2693
3020
  diff.existedBefore = existedBefore;
@@ -3206,7 +3533,7 @@ var globTool = {
3206
3533
  // src/tool/builtins/grep.ts
3207
3534
  import { readdir as readdir3, readFile as readFile9, stat as stat3 } from "fs/promises";
3208
3535
  import { join as join5, relative as relative5, isAbsolute as isAbsolute3 } from "path";
3209
- async function collectFiles(dir, baseDir, extension, maxFiles = 200) {
3536
+ async function collectFiles(dir, extension, maxFiles = 200) {
3210
3537
  const results = [];
3211
3538
  let entries;
3212
3539
  try {
@@ -3221,7 +3548,7 @@ async function collectFiles(dir, baseDir, extension, maxFiles = 200) {
3221
3548
  }
3222
3549
  const fullPath = join5(dir, entry.name);
3223
3550
  if (entry.isDirectory()) {
3224
- results.push(...await collectFiles(fullPath, baseDir, extension, maxFiles - results.length));
3551
+ results.push(...await collectFiles(fullPath, extension, maxFiles - results.length));
3225
3552
  } else {
3226
3553
  if (extension && !entry.name.endsWith(`.${extension}`)) {
3227
3554
  continue;
@@ -3275,7 +3602,7 @@ var grepTool = {
3275
3602
  if (!dirStat.isDirectory()) {
3276
3603
  return { success: false, data: `\u8DEF\u5F84\u4E0D\u662F\u76EE\u5F55\uFF1A${searchDir}`, error: "NOT_DIRECTORY" };
3277
3604
  }
3278
- const files = await collectFiles(searchDir, searchDir, args.include, maxFiles);
3605
+ const files = await collectFiles(searchDir, args.include, maxFiles);
3279
3606
  const matches = [];
3280
3607
  for (const filePath of files) {
3281
3608
  try {
@@ -3283,7 +3610,7 @@ var grepTool = {
3283
3610
  const lines = content.split("\n");
3284
3611
  const relPath = relative5(searchDir, filePath);
3285
3612
  for (let i = 0; i < lines.length; i++) {
3286
- if (regex.test(lines[i])) {
3613
+ if (regex.test(lines[i] ?? "")) {
3287
3614
  regex.lastIndex = 0;
3288
3615
  matches.push({
3289
3616
  file: relPath,
@@ -3352,7 +3679,7 @@ var lsTool = {
3352
3679
  try {
3353
3680
  const entries = await readdir4(dirPath, { withFileTypes: true });
3354
3681
  const lines = [];
3355
- const sorted = [...entries].sort((a, b) => {
3682
+ const sorted = [...entries].toSorted((a, b) => {
3356
3683
  if (a.isDirectory() !== b.isDirectory()) {
3357
3684
  return a.isDirectory() ? -1 : 1;
3358
3685
  }
@@ -3566,7 +3893,7 @@ function getGradientColors(text, phase, stops) {
3566
3893
  }
3567
3894
 
3568
3895
  // src/ui/ChatSession.tsx
3569
- import { Fragment, jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
3896
+ import { Fragment, jsx as jsx9, jsxs as jsxs9 } from "react/jsx-runtime";
3570
3897
  var PHASE_CONFIG = {
3571
3898
  thinking: { icon: "\u{1F9E0}", label: "\u601D\u8003\u4E2D", color: "#ff9800" },
3572
3899
  generating: { icon: "\u2728", label: "\u751F\u6210\u4E2D", color: "#00ff41" },
@@ -3653,16 +3980,16 @@ function ChatSession({
3653
3980
  const streamingPhaseRef = useRef2(0);
3654
3981
  const [currentContent, setCurrentContent] = useState3("");
3655
3982
  const [currentToolCalls, setCurrentToolCalls] = useState3([]);
3656
- const [currentUsage, setCurrentUsage] = useState3(void 0);
3657
- const [currentElapsed, setCurrentElapsed] = useState3(void 0);
3658
- const [currentCost, setCurrentCost] = useState3(void 0);
3983
+ const [_currentUsage, setCurrentUsage] = useState3(void 0);
3984
+ const [_currentElapsed, setCurrentElapsed] = useState3(void 0);
3985
+ const [_currentCost, setCurrentCost] = useState3(void 0);
3659
3986
  const [activeModel, setActiveModel] = useState3(model);
3660
- const [streamingModel, setStreamingModel] = useState3(void 0);
3987
+ const [_streamingModel, setStreamingModel] = useState3(void 0);
3661
3988
  const [streamError, setStreamError] = useState3(void 0);
3662
3989
  const [sessionMode, setSessionMode] = useState3("code");
3663
3990
  const [thinkingEnabled, setThinkingEnabled] = useState3(true);
3664
3991
  const [thinkingEffort, setThinkingEffort] = useState3("high");
3665
- const [responseFormat, setResponseFormat] = useState3("text");
3992
+ const [responseFormat] = useState3("text");
3666
3993
  const [toolChoice, setToolChoice] = useState3(void 0);
3667
3994
  const sessionCost = useMemo(() => {
3668
3995
  return displayMessages.reduce((sum, msg) => {
@@ -3892,7 +4219,7 @@ function ChatSession({
3892
4219
  if (!apiKey || !baseUrl) return;
3893
4220
  let cancelled = false;
3894
4221
  setBalanceLoading(true);
3895
- import("./deepseek-YTT76XDE.js").then(({ DeepSeekProvider: DeepSeekProvider2 }) => {
4222
+ import("./deepseek-PGX76BK5.js").then(({ DeepSeekProvider: DeepSeekProvider2 }) => {
3896
4223
  const provider = new DeepSeekProvider2({
3897
4224
  apiKey,
3898
4225
  baseUrl,
@@ -4220,36 +4547,36 @@ function ChatSession({
4220
4547
  setTodayCost(externalCostTracker.todayTotalCost);
4221
4548
  }
4222
4549
  }, [isStreaming, externalCostTracker]);
4223
- return /* @__PURE__ */ jsxs8(Box8, { flexDirection: "column", paddingLeft: 1, paddingRight: 1, children: [
4224
- !hasConversationStarted && /* @__PURE__ */ jsxs8(Box8, { flexDirection: "row", marginBottom: 1, children: [
4225
- /* @__PURE__ */ jsx9(Box8, { flexDirection: "column", marginRight: 4, children: LOGO_LINES.map((line, i) => {
4550
+ return /* @__PURE__ */ jsxs9(Box9, { flexDirection: "column", paddingLeft: 1, paddingRight: 1, children: [
4551
+ !hasConversationStarted && /* @__PURE__ */ jsxs9(Box9, { flexDirection: "row", marginBottom: 1, children: [
4552
+ /* @__PURE__ */ jsx9(Box9, { flexDirection: "column", marginRight: 4, children: LOGO_LINES.map((line, i) => {
4226
4553
  const colorIndex = (i + offset) % CYBER_PALETTE.length;
4227
- return /* @__PURE__ */ jsx9(Box8, { children: /* @__PURE__ */ jsx9(Text10, { bold: true, color: CYBER_PALETTE[colorIndex], children: line }) }, i);
4554
+ return /* @__PURE__ */ jsx9(Box9, { children: /* @__PURE__ */ jsx9(Text10, { bold: true, color: CYBER_PALETTE[colorIndex], children: line }) }, i);
4228
4555
  }) }),
4229
- /* @__PURE__ */ jsxs8(Box8, { flexDirection: "column", justifyContent: "center", children: [
4230
- /* @__PURE__ */ jsxs8(Text10, { color: "#00ff41", children: [
4556
+ /* @__PURE__ */ jsxs9(Box9, { flexDirection: "column", justifyContent: "center", children: [
4557
+ /* @__PURE__ */ jsxs9(Text10, { color: "#00ff41", children: [
4231
4558
  " \u2714 ",
4232
4559
  "\u5DF2\u5C31\u7EEA ",
4233
4560
  skillCount,
4234
4561
  " \u4E2A Skill"
4235
4562
  ] }),
4236
- /* @__PURE__ */ jsxs8(Text10, { color: "#00ffff", children: [
4563
+ /* @__PURE__ */ jsxs9(Text10, { color: "#00ffff", children: [
4237
4564
  " \u2139 ",
4238
4565
  "\u5DF2\u5C31\u7EEA ",
4239
4566
  toolCount,
4240
4567
  " \u4E2A\u5DE5\u5177"
4241
4568
  ] }),
4242
- /* @__PURE__ */ jsxs8(Text10, { color: "#00ffff", children: [
4569
+ /* @__PURE__ */ jsxs9(Text10, { color: "#00ffff", children: [
4243
4570
  " \u{1F527} \u6A21\u578B ",
4244
4571
  SUPPORTED_MODELS[activeModel]?.displayName ?? activeModel
4245
4572
  ] }),
4246
- thinkingEnabled && /* @__PURE__ */ jsxs8(Text10, { color: "#ff9800", children: [
4573
+ thinkingEnabled && /* @__PURE__ */ jsxs9(Text10, { color: "#ff9800", children: [
4247
4574
  " \u{1F9E0} \u6DF1\u5EA6\u601D\u8003 ",
4248
4575
  thinkingEffort === "max" ? "Max" : "High"
4249
4576
  ] }),
4250
4577
  sessionMode === "plan" && /* @__PURE__ */ jsx9(Text10, { color: "#ff69b4", bold: true, children: " \u{1F4CB} \u8BA1\u5212\u6A21\u5F0F" }),
4251
4578
  responseFormat === "json_object" && /* @__PURE__ */ jsx9(Text10, { color: "#4caf50", children: " \u{1F4C4} JSON" }),
4252
- toolChoice !== void 0 && /* @__PURE__ */ jsxs8(Text10, { color: "#e91e63", children: [
4579
+ toolChoice !== void 0 && /* @__PURE__ */ jsxs9(Text10, { color: "#e91e63", children: [
4253
4580
  " \u{1F6E0} ",
4254
4581
  toolChoice === "none" ? "\u7981\u6B62\u5DE5\u5177" : toolChoice === "required" ? "\u5F3A\u5236\u5DE5\u5177" : ""
4255
4582
  ] }),
@@ -4257,43 +4584,43 @@ function ChatSession({
4257
4584
  const tip = cmdTips[cmdTipIndex % cmdTips.length];
4258
4585
  if (!tip) return null;
4259
4586
  const text = `${tip.name} ${tip.desc}`;
4260
- return /* @__PURE__ */ jsxs8(Text10, { children: [
4587
+ return /* @__PURE__ */ jsxs9(Text10, { children: [
4261
4588
  /* @__PURE__ */ jsx9(Text10, { color: "#808080", children: " \u{1F4A1} " }),
4262
4589
  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 })
4263
4590
  ] });
4264
4591
  })(),
4265
4592
  verbose ? /* @__PURE__ */ jsx9(Text10, { color: "#ff1493", children: " \u26A1 Verbose" }) : null
4266
4593
  ] }),
4267
- /* @__PURE__ */ jsxs8(Box8, { flexGrow: 1, flexDirection: "column", justifyContent: "center", alignItems: "flex-end", children: [
4268
- balanceLoading && balance === null ? /* @__PURE__ */ jsx9(Text10, { color: "yellow", children: " \u23F3 \u67E5\u8BE2\u4F59\u989D..." }) : balance !== null ? /* @__PURE__ */ jsxs8(Box8, { flexDirection: "row", children: [
4594
+ /* @__PURE__ */ jsxs9(Box9, { flexGrow: 1, flexDirection: "column", justifyContent: "center", alignItems: "flex-end", children: [
4595
+ balanceLoading && balance === null ? /* @__PURE__ */ jsx9(Text10, { color: "yellow", children: " \u23F3 \u67E5\u8BE2\u4F59\u989D..." }) : balance !== null ? /* @__PURE__ */ jsxs9(Box9, { flexDirection: "row", children: [
4269
4596
  /* @__PURE__ */ jsx9(Text10, { color: "yellow", children: "\u{1F4B0} " }),
4270
- /* @__PURE__ */ jsxs8(Text10, { color: "yellow", children: [
4597
+ /* @__PURE__ */ jsxs9(Text10, { color: "yellow", children: [
4271
4598
  "\u4F59\u989D \xA5",
4272
4599
  balance.toFixed(2)
4273
4600
  ] })
4274
4601
  ] }) : null,
4275
- todayCost !== null ? /* @__PURE__ */ jsxs8(Box8, { flexDirection: "row", children: [
4602
+ todayCost !== null ? /* @__PURE__ */ jsxs9(Box9, { flexDirection: "row", children: [
4276
4603
  /* @__PURE__ */ jsx9(Text10, { color: "cyan", children: "\u{1F4CA} " }),
4277
- /* @__PURE__ */ jsxs8(Text10, { color: "cyan", children: [
4604
+ /* @__PURE__ */ jsxs9(Text10, { color: "cyan", children: [
4278
4605
  "\u4ECA\u65E5 \xA5",
4279
4606
  todayCost.toFixed(2)
4280
4607
  ] })
4281
4608
  ] }) : null
4282
4609
  ] })
4283
4610
  ] }),
4284
- /* @__PURE__ */ jsxs8(Box8, { flexDirection: "column", marginTop: 1, children: [
4611
+ /* @__PURE__ */ jsxs9(Box9, { flexDirection: "column", marginTop: 1, children: [
4285
4612
  /* @__PURE__ */ jsx9(Static, { items: displayMessages, children: (msg, i) => {
4286
4613
  if (msg.role === "user") {
4287
- return /* @__PURE__ */ jsxs8(Box8, { marginTop: 1, children: [
4288
- /* @__PURE__ */ jsx9(Box8, { width: 4, flexShrink: 0, children: /* @__PURE__ */ jsx9(Text10, { bold: true, color: "#00ff41", children: "\u{1F464}" }) }),
4289
- /* @__PURE__ */ jsx9(Box8, { flexGrow: 1, children: /* @__PURE__ */ jsx9(Text10, { wrap: "wrap", children: msg.content }) })
4614
+ return /* @__PURE__ */ jsxs9(Box9, { marginTop: 1, children: [
4615
+ /* @__PURE__ */ jsx9(Box9, { width: 4, flexShrink: 0, children: /* @__PURE__ */ jsx9(Text10, { bold: true, color: "#00ff41", children: "\u{1F464}" }) }),
4616
+ /* @__PURE__ */ jsx9(Box9, { flexGrow: 1, children: /* @__PURE__ */ jsx9(Text10, { wrap: "wrap", children: msg.content }) })
4290
4617
  ] }, i);
4291
4618
  }
4292
4619
  if (msg.role === "tool") {
4293
- return /* @__PURE__ */ jsxs8(Box8, { marginTop: 1, flexDirection: "column", children: [
4294
- /* @__PURE__ */ jsxs8(Box8, { flexDirection: "row", children: [
4295
- /* @__PURE__ */ jsx9(Box8, { width: 4, flexShrink: 0, children: /* @__PURE__ */ jsx9(Text10, { bold: true, color: "#f59e0b", children: "\u{1F527}" }) }),
4296
- /* @__PURE__ */ jsx9(Box8, { flexGrow: 1, children: /* @__PURE__ */ jsx9(Text10, { wrap: "wrap", children: msg.content }) })
4620
+ return /* @__PURE__ */ jsxs9(Box9, { marginTop: 1, flexDirection: "column", children: [
4621
+ /* @__PURE__ */ jsxs9(Box9, { flexDirection: "row", children: [
4622
+ /* @__PURE__ */ jsx9(Box9, { width: 4, flexShrink: 0, children: /* @__PURE__ */ jsx9(Text10, { bold: true, color: "#f59e0b", children: "\u{1F527}" }) }),
4623
+ /* @__PURE__ */ jsx9(Box9, { flexGrow: 1, children: /* @__PURE__ */ jsx9(Text10, { wrap: "wrap", children: msg.content }) })
4297
4624
  ] }),
4298
4625
  msg.diff && /* @__PURE__ */ jsx9(DiffPreview, { diff: msg.diff })
4299
4626
  ] }, i);
@@ -4321,14 +4648,14 @@ function ChatSession({
4321
4648
  isStreaming: true
4322
4649
  }
4323
4650
  ),
4324
- !isStreaming && streamError && /* @__PURE__ */ jsx9(Box8, { marginTop: 1, marginLeft: 3, children: /* @__PURE__ */ jsxs8(Text10, { color: "red", children: [
4651
+ !isStreaming && streamError && /* @__PURE__ */ jsx9(Box9, { marginTop: 1, marginLeft: 3, children: /* @__PURE__ */ jsxs9(Text10, { color: "red", children: [
4325
4652
  "\u26A0 ",
4326
4653
  streamError
4327
4654
  ] }) })
4328
4655
  ] }),
4329
- selectingModel ? /* @__PURE__ */ jsxs8(Box8, { marginTop: 1, flexDirection: "column", children: [
4656
+ selectingModel ? /* @__PURE__ */ jsxs9(Box9, { marginTop: 1, flexDirection: "column", children: [
4330
4657
  /* @__PURE__ */ jsx9(Text10, { color: "#00ffff", dimColor: true, children: "\u2500".repeat(dividerWidth) }),
4331
- /* @__PURE__ */ jsxs8(Box8, { flexDirection: "column", marginTop: 1, children: [
4658
+ /* @__PURE__ */ jsxs9(Box9, { flexDirection: "column", marginTop: 1, children: [
4332
4659
  /* @__PURE__ */ jsx9(Text10, { bold: true, color: "#00ffff", children: "\u9009\u62E9\u6A21\u578B\uFF1A" }),
4333
4660
  modelOptions.map((id, i) => {
4334
4661
  const meta = SUPPORTED_MODELS[id];
@@ -4336,8 +4663,8 @@ function ChatSession({
4336
4663
  const isSelected = i === modelSelectIndex;
4337
4664
  const marker = isSelected ? " > " : " ";
4338
4665
  const suffix = isCurrent ? " (\u5F53\u524D)" : "";
4339
- return /* @__PURE__ */ jsxs8(Box8, { children: [
4340
- /* @__PURE__ */ jsxs8(
4666
+ return /* @__PURE__ */ jsxs9(Box9, { children: [
4667
+ /* @__PURE__ */ jsxs9(
4341
4668
  Text10,
4342
4669
  {
4343
4670
  color: isSelected ? "#00ff41" : void 0,
@@ -4349,42 +4676,42 @@ function ChatSession({
4349
4676
  ]
4350
4677
  }
4351
4678
  ),
4352
- isSelected && /* @__PURE__ */ jsxs8(Text10, { color: "#808080", children: [
4679
+ isSelected && /* @__PURE__ */ jsxs9(Text10, { color: "#808080", children: [
4353
4680
  " \u2014 ",
4354
4681
  id
4355
4682
  ] })
4356
4683
  ] }, id);
4357
4684
  }),
4358
- /* @__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" }) })
4685
+ /* @__PURE__ */ jsx9(Box9, { marginTop: 1, children: /* @__PURE__ */ jsx9(Text10, { color: "#808080", dimColor: true, children: "\u2191\u2193 \u9009\u62E9 \xB7 Enter \u786E\u8BA4 \xB7 Esc \u53D6\u6D88" }) })
4359
4686
  ] }),
4360
4687
  /* @__PURE__ */ jsx9(Text10, { color: "#00ffff", dimColor: true, children: "\u2500".repeat(dividerWidth) })
4361
- ] }) : /* @__PURE__ */ jsxs8(Fragment, { children: [
4362
- (hasConversationStarted || sessionMode === "plan") && isStreaming && streamingPhase ? /* @__PURE__ */ jsx9(Box8, { marginTop: 1, justifyContent: "center", children: /* @__PURE__ */ jsxs8(Text10, { bold: true, color: PHASE_CONFIG[streamingPhase].color, children: [
4688
+ ] }) : /* @__PURE__ */ jsxs9(Fragment, { children: [
4689
+ (hasConversationStarted || sessionMode === "plan") && isStreaming && streamingPhase ? /* @__PURE__ */ jsx9(Box9, { marginTop: 1, justifyContent: "center", children: /* @__PURE__ */ jsxs9(Text10, { bold: true, color: PHASE_CONFIG[streamingPhase].color, children: [
4363
4690
  PHASE_CONFIG[streamingPhase].icon,
4364
4691
  " ",
4365
4692
  PHASE_CONFIG[streamingPhase].label,
4366
4693
  " ",
4367
4694
  /* @__PURE__ */ jsx9(InkSpinner2, { type: "dots" })
4368
4695
  ] }) }) : null,
4369
- /* @__PURE__ */ jsx9(Box8, { marginTop: 1, children: hasConversationStarted || sessionMode === "plan" ? /* @__PURE__ */ jsxs8(Text10, { color: sessionMode === "plan" ? "#ff69b4" : "#00ffff", dimColor: sessionMode !== "plan", children: [
4696
+ /* @__PURE__ */ jsx9(Box9, { marginTop: 1, children: hasConversationStarted || sessionMode === "plan" ? /* @__PURE__ */ jsxs9(Text10, { color: sessionMode === "plan" ? "#ff69b4" : "#00ffff", dimColor: sessionMode !== "plan", children: [
4370
4697
  /* @__PURE__ */ jsx9(Text10, { children: sessionMode === "plan" ? "\u2500".repeat(Math.max(dividerWidth - 48, 1)) : "\u2500".repeat(Math.max(dividerWidth - 35, 10)) }),
4371
- balance !== null && /* @__PURE__ */ jsxs8(Text10, { color: "yellow", children: [
4698
+ balance !== null && /* @__PURE__ */ jsxs9(Text10, { color: "yellow", children: [
4372
4699
  " \u{1F4B0} \u4F59\u989D \xA5",
4373
4700
  balance.toFixed(2)
4374
4701
  ] }),
4375
- isStreaming ? /* @__PURE__ */ jsxs8(Text10, { color: "cyan", children: [
4702
+ isStreaming ? /* @__PURE__ */ jsxs9(Text10, { color: "cyan", children: [
4376
4703
  " \u{1F4CA} \u672C\u6B21 \xA5",
4377
4704
  sessionCost > 0 ? sessionCost.toFixed(4) + " " : "",
4378
4705
  /* @__PURE__ */ jsx9(InkSpinner2, { type: "dots" })
4379
- ] }) : sessionCost > 0 ? /* @__PURE__ */ jsxs8(Text10, { color: "cyan", children: [
4706
+ ] }) : sessionCost > 0 ? /* @__PURE__ */ jsxs9(Text10, { color: "cyan", children: [
4380
4707
  " \u{1F4CA} \u672C\u6B21 \xA5",
4381
4708
  sessionCost.toFixed(4)
4382
4709
  ] }) : null,
4383
4710
  sessionMode === "plan" && /* @__PURE__ */ jsx9(Text10, { color: "#ff69b4", bold: true, children: " \u{1F4CB} \u8BA1\u5212\u6A21\u5F0F" })
4384
4711
  ] }) : /* @__PURE__ */ jsx9(Text10, { color: "#00ffff", dimColor: true, children: "\u2500".repeat(dividerWidth) }) }),
4385
- /* @__PURE__ */ jsxs8(Box8, { children: [
4386
- /* @__PURE__ */ jsx9(Box8, { width: 4, flexShrink: 0, children: /* @__PURE__ */ jsx9(Text10, { bold: true, color: "#00ff41", children: "\u26A1" }) }),
4387
- /* @__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(
4712
+ /* @__PURE__ */ jsxs9(Box9, { children: [
4713
+ /* @__PURE__ */ jsx9(Box9, { width: 4, flexShrink: 0, children: /* @__PURE__ */ jsx9(Text10, { bold: true, color: "#00ff41", children: "\u26A1" }) }),
4714
+ /* @__PURE__ */ jsx9(Box9, { 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(
4388
4715
  TextInput,
4389
4716
  {
4390
4717
  value: input,
@@ -4395,19 +4722,19 @@ function ChatSession({
4395
4722
  inputKey
4396
4723
  ) })
4397
4724
  ] }),
4398
- /* @__PURE__ */ jsx9(Box8, { children: /* @__PURE__ */ jsx9(Text10, { color: "#00ffff", dimColor: true, children: "\u2500".repeat(dividerWidth) }) }),
4725
+ /* @__PURE__ */ jsx9(Box9, { children: /* @__PURE__ */ jsx9(Text10, { color: "#00ffff", dimColor: true, children: "\u2500".repeat(dividerWidth) }) }),
4399
4726
  /* @__PURE__ */ jsx9(SkillSelector, { skills, input, selectedIndex: skillSelectIndex }),
4400
4727
  /* @__PURE__ */ jsx9(FileSelector, { files, input, selectedIndex: fileSelectIndex })
4401
4728
  ] }),
4402
- 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" }) }),
4403
- 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" }) })
4729
+ doubleCtrlC && !isStreaming && /* @__PURE__ */ jsx9(Box9, { marginTop: 1, children: /* @__PURE__ */ jsx9(Text10, { color: "#ff1493", bold: true, children: " \u26A0 \u518D\u6309\u4E00\u6B21 Ctrl+C \u9000\u51FA dskcode" }) }),
4730
+ isStreaming && /* @__PURE__ */ jsx9(Box9, { marginTop: 1, children: /* @__PURE__ */ jsx9(Text10, { color: "yellow", dimColor: true, children: " \u63D0\u793A\uFF1A\u6309 Ctrl+C \u53D6\u6D88\u5F53\u524D\u8BF7\u6C42" }) })
4404
4731
  ] });
4405
4732
  }
4406
4733
 
4407
4734
  // src/ui/GamePicker.tsx
4408
- import { Box as Box9, Text as Text11, useInput as useInput2 } from "ink";
4735
+ import { Box as Box10, Text as Text11, useInput as useInput2 } from "ink";
4409
4736
  import { useState as useState4, useCallback as useCallback3 } from "react";
4410
- import { jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
4737
+ import { jsx as jsx10, jsxs as jsxs10 } from "react/jsx-runtime";
4411
4738
  function GamePicker({ games, onSelect, onExit, onBackToChat }) {
4412
4739
  const [selectedIndex, setSelectedIndex] = useState4(0);
4413
4740
  const exitAction = onBackToChat ?? onExit ?? (() => process.exit(0));
@@ -4435,18 +4762,18 @@ function GamePicker({ games, onSelect, onExit, onBackToChat }) {
4435
4762
  [games, selectedIndex, onSelect, onExit, onBackToChat, handleCtrlC]
4436
4763
  )
4437
4764
  );
4438
- return /* @__PURE__ */ jsxs9(Box9, { flexDirection: "column", children: [
4439
- /* @__PURE__ */ jsx10(Box9, { marginBottom: 1, children: /* @__PURE__ */ jsx10(Text11, { bold: true, color: "#00ffff", children: "\u{1F3AE} \u6E38\u620F\u5217\u8868" }) }),
4440
- /* @__PURE__ */ jsx10(Box9, { flexDirection: "column", children: games.map((game, index) => {
4765
+ return /* @__PURE__ */ jsxs10(Box10, { flexDirection: "column", children: [
4766
+ /* @__PURE__ */ jsx10(Box10, { marginBottom: 1, children: /* @__PURE__ */ jsx10(Text11, { bold: true, color: "#00ffff", children: "\u{1F3AE} \u6E38\u620F\u5217\u8868" }) }),
4767
+ /* @__PURE__ */ jsx10(Box10, { flexDirection: "column", children: games.map((game, index) => {
4441
4768
  const isSelected = index === selectedIndex;
4442
- return /* @__PURE__ */ jsxs9(Box9, { flexDirection: "row", children: [
4443
- /* @__PURE__ */ jsx10(Box9, { width: 3, flexShrink: 0, children: isSelected ? /* @__PURE__ */ jsx10(Text11, { bold: true, color: "#00ff41", children: "\u25B8 " }) : /* @__PURE__ */ jsx10(Text11, { children: " " }) }),
4444
- /* @__PURE__ */ jsx10(Box9, { width: 20, flexShrink: 0, children: /* @__PURE__ */ jsx10(Text11, { bold: true, color: isSelected ? "#00ff41" : "#ffffff", children: game.name }) }),
4445
- /* @__PURE__ */ jsx10(Box9, { children: /* @__PURE__ */ jsx10(Text11, { color: "#888888", children: game.description }) })
4769
+ return /* @__PURE__ */ jsxs10(Box10, { flexDirection: "row", children: [
4770
+ /* @__PURE__ */ jsx10(Box10, { width: 3, flexShrink: 0, children: isSelected ? /* @__PURE__ */ jsx10(Text11, { bold: true, color: "#00ff41", children: "\u25B8 " }) : /* @__PURE__ */ jsx10(Text11, { children: " " }) }),
4771
+ /* @__PURE__ */ jsx10(Box10, { width: 20, flexShrink: 0, children: /* @__PURE__ */ jsx10(Text11, { bold: true, color: isSelected ? "#00ff41" : "#ffffff", children: game.name }) }),
4772
+ /* @__PURE__ */ jsx10(Box10, { children: /* @__PURE__ */ jsx10(Text11, { color: "#888888", children: game.description }) })
4446
4773
  ] }, game.id);
4447
4774
  }) }),
4448
- /* @__PURE__ */ jsx10(Box9, { marginTop: 1, children: /* @__PURE__ */ jsx10(Text11, { dimColor: true, children: " \u2191/\u2193 \u9009\u62E9 Enter \u542F\u52A8 q \u8FD4\u56DE" }) }),
4449
- 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" }) })
4775
+ /* @__PURE__ */ jsx10(Box10, { marginTop: 1, children: /* @__PURE__ */ jsx10(Text11, { dimColor: true, children: " \u2191/\u2193 \u9009\u62E9 Enter \u542F\u52A8 q \u8FD4\u56DE" }) }),
4776
+ doubleCtrlC && /* @__PURE__ */ jsx10(Box10, { marginTop: 1, children: /* @__PURE__ */ jsx10(Text11, { color: "#ff1493", bold: true, children: " \u26A0 \u518D\u6309\u4E00\u6B21 Ctrl+C \u9000\u51FA dskcode" }) })
4450
4777
  ] });
4451
4778
  }
4452
4779
 
@@ -4463,9 +4790,9 @@ function listGames() {
4463
4790
  }
4464
4791
 
4465
4792
  // src/game/brick-breaker/index.tsx
4466
- import { Box as Box10, Text as Text12, useInput as useInput3, render as render2 } from "ink";
4793
+ import { Box as Box11, Text as Text12, useInput as useInput3, render as render2 } from "ink";
4467
4794
  import { useState as useState5, useEffect as useEffect4, useRef as useRef3, useCallback as useCallback4 } from "react";
4468
- import { jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
4795
+ import { jsx as jsx11, jsxs as jsxs11 } from "react/jsx-runtime";
4469
4796
  var GAME_WIDTH = 40;
4470
4797
  var GAME_HEIGHT = 18;
4471
4798
  var PADDLE_WIDTH = 9;
@@ -4509,7 +4836,7 @@ function createBricks(level) {
4509
4836
  function createInitialState(level) {
4510
4837
  const def = getLevel(level);
4511
4838
  const totalW = def.cols * def.bw + (def.cols - 1) * 2;
4512
- const startX = Math.floor((GAME_WIDTH - totalW) / 2);
4839
+ const _startX = Math.floor((GAME_WIDTH - totalW) / 2);
4513
4840
  return {
4514
4841
  level,
4515
4842
  bricks: createBricks(level),
@@ -4655,48 +4982,48 @@ function BrickBreakerGame({ onExit: _onExit }) {
4655
4982
  const board = buildBoard(s);
4656
4983
  const def = getLevel(s.level);
4657
4984
  void tick2;
4658
- return /* @__PURE__ */ jsxs10(Box10, { flexDirection: "column", children: [
4659
- /* @__PURE__ */ jsxs10(Box10, { flexDirection: "row", children: [
4660
- /* @__PURE__ */ jsx11(Box10, { width: 20, children: /* @__PURE__ */ jsxs10(Text12, { children: [
4985
+ return /* @__PURE__ */ jsxs11(Box11, { flexDirection: "column", children: [
4986
+ /* @__PURE__ */ jsxs11(Box11, { flexDirection: "row", children: [
4987
+ /* @__PURE__ */ jsx11(Box11, { width: 20, children: /* @__PURE__ */ jsxs11(Text12, { children: [
4661
4988
  "\u5173\u5361 ",
4662
4989
  s.level,
4663
4990
  ": ",
4664
4991
  /* @__PURE__ */ jsx11(Text12, { color: "cyan", children: def.desc })
4665
4992
  ] }) }),
4666
- /* @__PURE__ */ jsx11(Box10, { width: 12, children: /* @__PURE__ */ jsxs10(Text12, { children: [
4993
+ /* @__PURE__ */ jsx11(Box11, { width: 12, children: /* @__PURE__ */ jsxs11(Text12, { children: [
4667
4994
  "\u5206\u6570: ",
4668
4995
  /* @__PURE__ */ jsx11(Text12, { color: "yellow", children: String(s.score).padStart(3, "0") })
4669
4996
  ] }) }),
4670
- /* @__PURE__ */ jsx11(Box10, { width: 12, children: /* @__PURE__ */ jsxs10(Text12, { children: [
4997
+ /* @__PURE__ */ jsx11(Box11, { width: 12, children: /* @__PURE__ */ jsxs11(Text12, { children: [
4671
4998
  "\u751F\u547D: ",
4672
4999
  /* @__PURE__ */ jsx11(Text12, { color: "red", children: "\u2665".repeat(Math.max(0, s.lives)) })
4673
5000
  ] }) }),
4674
- /* @__PURE__ */ jsx11(Box10, { width: 10, children: /* @__PURE__ */ jsxs10(Text12, { children: [
5001
+ /* @__PURE__ */ jsx11(Box11, { width: 10, children: /* @__PURE__ */ jsxs11(Text12, { children: [
4675
5002
  "\u7816\u5757: ",
4676
5003
  /* @__PURE__ */ jsx11(Text12, { color: "cyan", children: aliveCount })
4677
5004
  ] }) }),
4678
- /* @__PURE__ */ jsx11(Box10, { children: /* @__PURE__ */ jsxs10(Text12, { color: s.paused ? "gray" : "green", children: [
5005
+ /* @__PURE__ */ jsx11(Box11, { children: /* @__PURE__ */ jsxs11(Text12, { color: s.paused ? "gray" : "green", children: [
4679
5006
  "[",
4680
5007
  s.paused ? "\u6682\u505C" : "\u8FD0\u884C\u4E2D",
4681
5008
  "]"
4682
5009
  ] }) })
4683
5010
  ] }),
4684
- /* @__PURE__ */ jsxs10(Box10, { flexDirection: "column", children: [
4685
- /* @__PURE__ */ jsxs10(Text12, { children: [
5011
+ /* @__PURE__ */ jsxs11(Box11, { flexDirection: "column", children: [
5012
+ /* @__PURE__ */ jsxs11(Text12, { children: [
4686
5013
  "\u250C",
4687
5014
  "\u2500".repeat(GAME_WIDTH),
4688
5015
  "\u2510"
4689
5016
  ] }),
4690
5017
  /* @__PURE__ */ jsx11(Text12, { children: selectingLevel ? " \x1B[90m\u9009\u62E9\u5173\u5361\u540E\u5F00\u59CB...\x1B[0m" : board }),
4691
- /* @__PURE__ */ jsxs10(Text12, { children: [
5018
+ /* @__PURE__ */ jsxs11(Text12, { children: [
4692
5019
  "\u2514",
4693
5020
  "\u2500".repeat(GAME_WIDTH),
4694
5021
  "\u2518"
4695
5022
  ] })
4696
5023
  ] }),
4697
- selectingLevel && /* @__PURE__ */ jsxs10(Box10, { marginTop: 1, flexDirection: "column", children: [
5024
+ selectingLevel && /* @__PURE__ */ jsxs11(Box11, { marginTop: 1, flexDirection: "column", children: [
4698
5025
  /* @__PURE__ */ jsx11(Text12, { bold: true, color: "yellow", children: "\u9009\u62E9\u5173\u5361" }),
4699
- /* @__PURE__ */ jsx11(Box10, { flexDirection: "row", flexWrap: "wrap", children: LEVELS.map((lv, i) => /* @__PURE__ */ jsx11(Box10, { width: 22, children: /* @__PURE__ */ jsxs10(Text12, { children: [
5026
+ /* @__PURE__ */ jsx11(Box11, { flexDirection: "row", flexWrap: "wrap", children: LEVELS.map((lv, i) => /* @__PURE__ */ jsx11(Box11, { width: 22, children: /* @__PURE__ */ jsxs11(Text12, { children: [
4700
5027
  /* @__PURE__ */ jsx11(Text12, { color: initialLevel === i + 1 ? "green" : "white", children: i + 1 === 10 ? "0" : String(i + 1) }),
4701
5028
  ". ",
4702
5029
  lv.desc,
@@ -4706,16 +5033,16 @@ function BrickBreakerGame({ onExit: _onExit }) {
4706
5033
  lv.cols,
4707
5034
  ")"
4708
5035
  ] }) }, i)) }),
4709
- /* @__PURE__ */ jsx11(Box10, { marginTop: 1, children: /* @__PURE__ */ jsx11(Text12, { dimColor: true, children: "\u6309\u6570\u5B57\u9009\u5173 q \u9000\u51FA" }) })
5036
+ /* @__PURE__ */ jsx11(Box11, { marginTop: 1, children: /* @__PURE__ */ jsx11(Text12, { dimColor: true, children: "\u6309\u6570\u5B57\u9009\u5173 q \u9000\u51FA" }) })
4710
5037
  ] }),
4711
- !selectingLevel && (s.gameOver || s.win) && /* @__PURE__ */ jsxs10(Box10, { marginTop: 1, children: [
5038
+ !selectingLevel && (s.gameOver || s.win) && /* @__PURE__ */ jsxs11(Box11, { marginTop: 1, children: [
4712
5039
  /* @__PURE__ */ jsx11(Text12, { bold: true, color: s.gameOver ? "red" : "green", children: s.gameOver ? "\u6E38\u620F\u7ED3\u675F\uFF01" : "\u606D\u559C\u901A\u5173\uFF01" }),
4713
- /* @__PURE__ */ jsxs10(Text12, { children: [
5040
+ /* @__PURE__ */ jsxs11(Text12, { children: [
4714
5041
  " \u5206\u6570: ",
4715
5042
  /* @__PURE__ */ jsx11(Text12, { color: "yellow", children: s.score })
4716
5043
  ] })
4717
5044
  ] }),
4718
- !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" }) })
5045
+ !selectingLevel && /* @__PURE__ */ jsx11(Box11, { 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" }) })
4719
5046
  ] });
4720
5047
  }
4721
5048
  var brick_breaker_default = {
@@ -4735,9 +5062,9 @@ var brick_breaker_default = {
4735
5062
  };
4736
5063
 
4737
5064
  // src/game/coder-check/index.tsx
4738
- import { Box as Box11, Text as Text13, useInput as useInput4, render as render3 } from "ink";
5065
+ import { Box as Box12, Text as Text13, useInput as useInput4, render as render3 } from "ink";
4739
5066
  import { useState as useState6, useEffect as useEffect5, useRef as useRef4, useCallback as useCallback5 } from "react";
4740
- import { jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
5067
+ import { jsx as jsx12, jsxs as jsxs12 } from "react/jsx-runtime";
4741
5068
  var GAME_W = 66;
4742
5069
  var GAME_H = 20;
4743
5070
  var SCORE_H = 6;
@@ -5208,44 +5535,44 @@ function CoderCheck({ onExit: _onExit }) {
5208
5535
  const scoreLines = buildScoreLines(scoreStr);
5209
5536
  const view = buildGameView(s, scoreLines, scoreColor, s.message);
5210
5537
  void tick2;
5211
- return /* @__PURE__ */ jsxs11(Box11, { flexDirection: "column", paddingX: 1, children: [
5212
- /* @__PURE__ */ jsx12(Box11, { flexDirection: "row", children: /* @__PURE__ */ jsxs11(Text13, { children: [
5538
+ return /* @__PURE__ */ jsxs12(Box12, { flexDirection: "column", paddingX: 1, children: [
5539
+ /* @__PURE__ */ jsx12(Box12, { flexDirection: "row", children: /* @__PURE__ */ jsxs12(Text13, { children: [
5213
5540
  "\u751F\u547D ",
5214
5541
  /* @__PURE__ */ jsx12(Text13, { color: "red", children: "\u2665".repeat(Math.max(0, s.lives)) }),
5215
5542
  " ",
5216
5543
  "\u901F\u5EA6 ",
5217
- /* @__PURE__ */ jsxs11(Text13, { color: "cyan", children: [
5544
+ /* @__PURE__ */ jsxs12(Text13, { color: "cyan", children: [
5218
5545
  "Lv.",
5219
5546
  Math.floor(s.speed * 10)
5220
5547
  ] })
5221
5548
  ] }) }),
5222
- !s.gameOver && s.target && /* @__PURE__ */ jsx12(Box11, { marginTop: 1, children: /* @__PURE__ */ jsxs11(Text13, { children: [
5549
+ !s.gameOver && s.target && /* @__PURE__ */ jsx12(Box12, { marginTop: 1, children: /* @__PURE__ */ jsxs12(Text13, { children: [
5223
5550
  "\u6253\u5B57: ",
5224
5551
  /* @__PURE__ */ jsx12(Text13, { color: "green", children: s.typed }),
5225
5552
  /* @__PURE__ */ jsx12(Text13, { color: "white", children: s.target.slice(s.typed.length) })
5226
5553
  ] }) }),
5227
- /* @__PURE__ */ jsxs11(Box11, { flexDirection: "column", marginTop: 1, children: [
5228
- /* @__PURE__ */ jsxs11(Text13, { children: [
5554
+ /* @__PURE__ */ jsxs12(Box12, { flexDirection: "column", marginTop: 1, children: [
5555
+ /* @__PURE__ */ jsxs12(Text13, { children: [
5229
5556
  "\u250C",
5230
5557
  "\u2500".repeat(GAME_W),
5231
5558
  "\u2510"
5232
5559
  ] }),
5233
5560
  view.map((row, i) => /* @__PURE__ */ jsx12(Text13, { children: `\u2502${row}\u2502` }, i)),
5234
- /* @__PURE__ */ jsxs11(Text13, { children: [
5561
+ /* @__PURE__ */ jsxs12(Text13, { children: [
5235
5562
  "\u2514",
5236
5563
  "\u2500".repeat(GAME_W),
5237
5564
  "\u2518"
5238
5565
  ] })
5239
5566
  ] }),
5240
- s.gameOver && /* @__PURE__ */ jsxs11(Box11, { marginTop: 1, children: [
5567
+ s.gameOver && /* @__PURE__ */ jsxs12(Box12, { marginTop: 1, children: [
5241
5568
  /* @__PURE__ */ jsx12(Text13, { bold: true, color: "red", children: "\u6E38\u620F\u7ED3\u675F\uFF01" }),
5242
- /* @__PURE__ */ jsxs11(Text13, { children: [
5569
+ /* @__PURE__ */ jsxs12(Text13, { children: [
5243
5570
  " \u5F97\u5206: ",
5244
5571
  /* @__PURE__ */ jsx12(Text13, { color: "yellow", children: s.score }),
5245
5572
  " r \u91CD\u5F00 q \u9000\u51FA"
5246
5573
  ] })
5247
5574
  ] }),
5248
- /* @__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" }) })
5575
+ /* @__PURE__ */ jsx12(Box12, { 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" }) })
5249
5576
  ] });
5250
5577
  }
5251
5578
  var coder_check_default = {
@@ -5635,12 +5962,12 @@ import { render as render4 } from "ink";
5635
5962
  import chalk5 from "chalk";
5636
5963
 
5637
5964
  // src/stock/StockList.tsx
5638
- import { Box as Box12, Text as Text14, useInput as useInput5 } from "ink";
5639
- import { useState as useState7, useCallback as useCallback6, useEffect as useEffect6 } from "react";
5965
+ import { Box as Box13, Text as Text14, useInput as useInput5 } from "ink";
5966
+ import { useState as useState7, useCallback as useCallback6, useEffect as useEffect6, useMemo as useMemo2 } from "react";
5640
5967
  import asciichart from "asciichart";
5641
5968
  import os from "os";
5642
5969
  import { join as join7 } from "path";
5643
- import { jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
5970
+ import { jsx as jsx13, jsxs as jsxs13 } from "react/jsx-runtime";
5644
5971
  var SETTINGS_PATH = join7(os.homedir(), ".dskcode", "settings.json");
5645
5972
  function toFileUrl(p) {
5646
5973
  const norm = p.replace(/\\/g, "/");
@@ -5756,6 +6083,13 @@ function StockList({ codes, onExit, onBackToChat }) {
5756
6083
  () => (/* @__PURE__ */ new Date()).toLocaleTimeString("zh-CN", { hour12: false })
5757
6084
  );
5758
6085
  const [dimMode, setDimMode] = useState7(false);
6086
+ const [sortOrder, setSortOrder] = useState7("default");
6087
+ const sortedStocks = useMemo2(() => {
6088
+ if (sortOrder === "default") return stocks;
6089
+ return [...stocks].toSorted(
6090
+ (a, b) => sortOrder === "desc" ? b.changePercent - a.changePercent : a.changePercent - b.changePercent
6091
+ );
6092
+ }, [stocks, sortOrder]);
5759
6093
  const { doubleCtrlC, handleCtrlC } = useDoubleCtrlC(onExit);
5760
6094
  useEffect6(() => {
5761
6095
  const timer = setInterval(() => {
@@ -5774,13 +6108,13 @@ function StockList({ codes, onExit, onBackToChat }) {
5774
6108
  setLoading(false);
5775
6109
  }, [codes]);
5776
6110
  useEffect6(() => {
5777
- loadData();
6111
+ void loadData();
5778
6112
  }, [loadData]);
5779
6113
  useEffect6(() => {
5780
6114
  const interval = setInterval(() => {
5781
6115
  setCountdown((prev) => {
5782
6116
  if (prev <= 1) {
5783
- loadData();
6117
+ void loadData();
5784
6118
  return 5;
5785
6119
  }
5786
6120
  return prev - 1;
@@ -5789,24 +6123,23 @@ function StockList({ codes, onExit, onBackToChat }) {
5789
6123
  return () => clearInterval(interval);
5790
6124
  }, [loadData]);
5791
6125
  useEffect6(() => {
5792
- if (!detailView) {
5793
- setDetailPrices(null);
5794
- setDetailLoading(false);
5795
- return;
6126
+ if (detailView) {
6127
+ const loadDetail = () => {
6128
+ minuteCache.delete(detailView.code);
6129
+ void fetchStockMinute(detailView.code).then((data) => {
6130
+ if (data && data.prices.length > 0) {
6131
+ cacheMinute(detailView.code, data.prices);
6132
+ setDetailPrices(data.prices);
6133
+ }
6134
+ });
6135
+ };
6136
+ loadDetail();
6137
+ setDetailCountdown(10);
6138
+ const timer = setInterval(loadDetail, 1e4);
6139
+ return () => clearInterval(timer);
5796
6140
  }
5797
- const loadDetail = () => {
5798
- minuteCache.delete(detailView.code);
5799
- fetchStockMinute(detailView.code).then((data) => {
5800
- if (data && data.prices.length > 0) {
5801
- cacheMinute(detailView.code, data.prices);
5802
- setDetailPrices(data.prices);
5803
- }
5804
- });
5805
- };
5806
- loadDetail();
5807
- setDetailCountdown(10);
5808
- const timer = setInterval(loadDetail, 1e4);
5809
- return () => clearInterval(timer);
6141
+ setDetailPrices(null);
6142
+ setDetailLoading(false);
5810
6143
  }, [detailView]);
5811
6144
  useEffect6(() => {
5812
6145
  if (!detailView) return;
@@ -5841,7 +6174,9 @@ function StockList({ codes, onExit, onBackToChat }) {
5841
6174
  else onExit();
5842
6175
  } else if (input === "r") {
5843
6176
  setCountdown(5);
5844
- loadData();
6177
+ void loadData();
6178
+ } else if (input === "o") {
6179
+ setSortOrder((prev) => prev === "default" ? "desc" : prev === "desc" ? "asc" : "default");
5845
6180
  } else if (input === "h") {
5846
6181
  setDimMode((v) => !v);
5847
6182
  }
@@ -5851,61 +6186,64 @@ function StockList({ codes, onExit, onBackToChat }) {
5851
6186
  );
5852
6187
  if (detailView) {
5853
6188
  if (detailLoading) {
5854
- return /* @__PURE__ */ jsx13(Box12, { paddingLeft: 1, children: /* @__PURE__ */ jsx13(Text14, { dimColor: true, children: " \u27F3 \u52A0\u8F7D\u5206\u65F6\u6570\u636E..." }) });
6189
+ return /* @__PURE__ */ jsx13(Box13, { paddingLeft: 1, children: /* @__PURE__ */ jsx13(Text14, { dimColor: true, children: " \u27F3 \u52A0\u8F7D\u5206\u65F6\u6570\u636E..." }) });
5855
6190
  }
5856
6191
  return renderDetail(detailView, () => setDetailView(null), detailPrices ?? void 0, detailCountdown, currentTime);
5857
6192
  }
5858
6193
  const cp2 = (c) => dimMode ? { dimColor: true } : { color: c };
5859
- return /* @__PURE__ */ jsxs12(Box12, { flexDirection: "column", children: [
5860
- /* @__PURE__ */ jsxs12(Box12, { marginBottom: 1, justifyContent: "space-between", children: [
6194
+ return /* @__PURE__ */ jsxs13(Box13, { flexDirection: "column", children: [
6195
+ /* @__PURE__ */ jsxs13(Box13, { marginBottom: 1, justifyContent: "space-between", children: [
5861
6196
  /* @__PURE__ */ jsx13(Text14, { bold: true, ...cp2("#00ffff"), children: " \u{1F4C8} \u81EA\u9009\u80A1\u76D1\u63A7" }),
5862
- /* @__PURE__ */ jsxs12(Text14, { dimColor: true, children: [
6197
+ /* @__PURE__ */ jsxs13(Text14, { dimColor: true, children: [
5863
6198
  " \u{1F550} ",
5864
6199
  currentTime
5865
6200
  ] }),
5866
6201
  /* @__PURE__ */ jsx13(Text14, { dimColor: true, children: loading ? " \u27F3 \u5237\u65B0\u4E2D..." : ` ${countdown}s \u540E\u81EA\u52A8\u5237\u65B0` })
5867
6202
  ] }),
5868
- /* @__PURE__ */ jsxs12(Box12, { children: [
5869
- /* @__PURE__ */ jsx13(Box12, { width: 3 }),
5870
- /* @__PURE__ */ jsx13(Box12, { width: 9, children: /* @__PURE__ */ jsx13(Text14, { dimColor: true, children: "\u4EE3\u7801" }) }),
5871
- /* @__PURE__ */ jsx13(Box12, { width: 16, children: /* @__PURE__ */ jsx13(Text14, { dimColor: true, children: "\u540D\u79F0" }) }),
5872
- /* @__PURE__ */ jsx13(Box12, { width: 12, children: /* @__PURE__ */ jsx13(Text14, { dimColor: true, children: "\u6700\u65B0\u4EF7" }) }),
5873
- /* @__PURE__ */ jsx13(Box12, { width: 12, children: /* @__PURE__ */ jsx13(Text14, { dimColor: true, children: "\u6DA8\u8DCC\u5E45" }) }),
5874
- /* @__PURE__ */ jsx13(Box12, { width: 12, children: /* @__PURE__ */ jsx13(Text14, { dimColor: true, children: "\u6DA8\u8DCC\u989D" }) }),
5875
- /* @__PURE__ */ jsx13(Box12, { width: 12, children: /* @__PURE__ */ jsx13(Text14, { dimColor: true, children: "\u6700\u9AD8" }) }),
5876
- /* @__PURE__ */ jsx13(Box12, { width: 12, children: /* @__PURE__ */ jsx13(Text14, { dimColor: true, children: "\u6700\u4F4E" }) }),
5877
- /* @__PURE__ */ jsx13(Box12, { children: /* @__PURE__ */ jsx13(Text14, { dimColor: true, children: "\u6210\u4EA4\u989D" }) })
6203
+ /* @__PURE__ */ jsxs13(Box13, { children: [
6204
+ /* @__PURE__ */ jsx13(Box13, { width: 3 }),
6205
+ /* @__PURE__ */ jsx13(Box13, { width: 9, children: /* @__PURE__ */ jsx13(Text14, { dimColor: true, children: "\u4EE3\u7801" }) }),
6206
+ /* @__PURE__ */ jsx13(Box13, { width: 16, children: /* @__PURE__ */ jsx13(Text14, { dimColor: true, children: "\u540D\u79F0" }) }),
6207
+ /* @__PURE__ */ jsx13(Box13, { width: 12, children: /* @__PURE__ */ jsx13(Text14, { dimColor: true, children: "\u6700\u65B0\u4EF7" }) }),
6208
+ /* @__PURE__ */ jsx13(Box13, { width: 12, children: /* @__PURE__ */ jsxs13(Text14, { dimColor: true, children: [
6209
+ "\u6DA8\u8DCC\u5E45",
6210
+ sortOrder === "desc" ? " \u25BC" : sortOrder === "asc" ? " \u25B2" : ""
6211
+ ] }) }),
6212
+ /* @__PURE__ */ jsx13(Box13, { width: 12, children: /* @__PURE__ */ jsx13(Text14, { dimColor: true, children: "\u6DA8\u8DCC\u989D" }) }),
6213
+ /* @__PURE__ */ jsx13(Box13, { width: 12, children: /* @__PURE__ */ jsx13(Text14, { dimColor: true, children: "\u6700\u9AD8" }) }),
6214
+ /* @__PURE__ */ jsx13(Box13, { width: 12, children: /* @__PURE__ */ jsx13(Text14, { dimColor: true, children: "\u6700\u4F4E" }) }),
6215
+ /* @__PURE__ */ jsx13(Box13, { children: /* @__PURE__ */ jsx13(Text14, { dimColor: true, children: "\u6210\u4EA4\u989D" }) })
5878
6216
  ] }),
5879
- /* @__PURE__ */ jsx13(Box12, { children: /* @__PURE__ */ jsx13(Text14, { dimColor: true, children: " " + "\u2500".repeat(100) }) }),
5880
- /* @__PURE__ */ jsx13(Box12, { flexDirection: "column", children: stocks.map((stock, index) => {
6217
+ /* @__PURE__ */ jsx13(Box13, { children: /* @__PURE__ */ jsx13(Text14, { dimColor: true, children: " " + "\u2500".repeat(100) }) }),
6218
+ /* @__PURE__ */ jsx13(Box13, { flexDirection: "column", children: sortedStocks.map((stock, index) => {
5881
6219
  const isSelected = index === selectedIndex;
5882
6220
  const isUp = stock.changePercent >= 0;
5883
6221
  const color = isUp ? "#ff1493" : "#00ff41";
5884
- return /* @__PURE__ */ jsxs12(Box12, { children: [
5885
- /* @__PURE__ */ jsx13(Box12, { width: 3, flexShrink: 0, children: isSelected ? /* @__PURE__ */ jsx13(Text14, { bold: true, ...cp2("#00ffff"), children: "\u25B8 " }) : /* @__PURE__ */ jsx13(Text14, { children: " " }) }),
5886
- /* @__PURE__ */ jsx13(Box12, { width: 9, children: /* @__PURE__ */ jsx13(Text14, { bold: true, ...cp2(isSelected ? "#00ffff" : "#ffffff"), children: stock.code }) }),
5887
- /* @__PURE__ */ jsx13(Box12, { width: 16, children: /* @__PURE__ */ jsx13(Text14, { ...cp2(isSelected ? "#ffffff" : "#cccccc"), children: stock.name }) }),
5888
- /* @__PURE__ */ jsx13(Box12, { width: 12, children: /* @__PURE__ */ jsx13(Text14, { bold: true, ...cp2(color), children: formatPrice(stock.price) }) }),
5889
- /* @__PURE__ */ jsx13(Box12, { width: 12, children: /* @__PURE__ */ jsxs12(Text14, { ...cp2(color), children: [
6222
+ return /* @__PURE__ */ jsxs13(Box13, { children: [
6223
+ /* @__PURE__ */ jsx13(Box13, { width: 3, flexShrink: 0, children: isSelected ? /* @__PURE__ */ jsx13(Text14, { bold: true, ...cp2("#00ffff"), children: "\u25B8 " }) : /* @__PURE__ */ jsx13(Text14, { children: " " }) }),
6224
+ /* @__PURE__ */ jsx13(Box13, { width: 9, children: /* @__PURE__ */ jsx13(Text14, { bold: true, ...cp2(isSelected ? "#00ffff" : "#ffffff"), children: stock.code }) }),
6225
+ /* @__PURE__ */ jsx13(Box13, { width: 16, children: /* @__PURE__ */ jsx13(Text14, { ...cp2(isSelected ? "#ffffff" : "#cccccc"), children: stock.name }) }),
6226
+ /* @__PURE__ */ jsx13(Box13, { width: 12, children: /* @__PURE__ */ jsx13(Text14, { bold: true, ...cp2(color), children: formatPrice(stock.price) }) }),
6227
+ /* @__PURE__ */ jsx13(Box13, { width: 12, children: /* @__PURE__ */ jsxs13(Text14, { ...cp2(color), children: [
5890
6228
  isUp ? "+" : "",
5891
6229
  stock.changePercent.toFixed(2),
5892
6230
  "%"
5893
6231
  ] }) }),
5894
- /* @__PURE__ */ jsx13(Box12, { width: 12, children: /* @__PURE__ */ jsxs12(Text14, { ...cp2(color), children: [
6232
+ /* @__PURE__ */ jsx13(Box13, { width: 12, children: /* @__PURE__ */ jsxs13(Text14, { ...cp2(color), children: [
5895
6233
  isUp ? "+" : "",
5896
6234
  stock.changeAmount.toFixed(3)
5897
6235
  ] }) }),
5898
- /* @__PURE__ */ jsx13(Box12, { width: 12, children: /* @__PURE__ */ jsx13(Text14, { ...cp2("#cccccc"), children: formatPrice(stock.high) }) }),
5899
- /* @__PURE__ */ jsx13(Box12, { width: 12, children: /* @__PURE__ */ jsx13(Text14, { ...cp2("#888888"), children: formatPrice(stock.low) }) }),
5900
- /* @__PURE__ */ jsx13(Box12, { children: /* @__PURE__ */ jsx13(Text14, { ...cp2("#888888"), children: formatAmount(stock.amount) }) })
6236
+ /* @__PURE__ */ jsx13(Box13, { width: 12, children: /* @__PURE__ */ jsx13(Text14, { ...cp2("#cccccc"), children: formatPrice(stock.high) }) }),
6237
+ /* @__PURE__ */ jsx13(Box13, { width: 12, children: /* @__PURE__ */ jsx13(Text14, { ...cp2("#888888"), children: formatPrice(stock.low) }) }),
6238
+ /* @__PURE__ */ jsx13(Box13, { children: /* @__PURE__ */ jsx13(Text14, { ...cp2("#888888"), children: formatAmount(stock.amount) }) })
5901
6239
  ] }, stock.code);
5902
6240
  }) }),
5903
- /* @__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` }) }),
5904
- /* @__PURE__ */ jsxs12(Box12, { children: [
6241
+ /* @__PURE__ */ jsx13(Box13, { marginTop: 1, children: /* @__PURE__ */ jsx13(Text14, { 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` }) }),
6242
+ /* @__PURE__ */ jsxs13(Box13, { children: [
5905
6243
  /* @__PURE__ */ jsx13(Text14, { dimColor: true, children: ` \u6700\u540E\u66F4\u65B0: ${lastUpdate} \u7F16\u8F91\u81EA\u9009\u80A1: ` }),
5906
6244
  /* @__PURE__ */ jsx13(Text14, { ...cp2("#c792ea"), children: osc8Link(toFileUrl(SETTINGS_PATH), SETTINGS_PATH) })
5907
6245
  ] }),
5908
- 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" }) })
6246
+ doubleCtrlC && /* @__PURE__ */ jsx13(Box13, { marginTop: 1, children: /* @__PURE__ */ jsx13(Text14, { bold: true, ...cp2("#ff1493"), children: " \u26A0 \u518D\u6309\u4E00\u6B21 Ctrl+C \u9000\u51FA dskcode" }) })
5909
6247
  ] });
5910
6248
  }
5911
6249
  function renderDetail(stock, _onBack, prices, countdown = 10, currentTime) {
@@ -5923,33 +6261,33 @@ function renderDetail(stock, _onBack, prices, countdown = 10, currentTime) {
5923
6261
  raw = raw.replaceAll("\u256D", "\u250C").replaceAll("\u256E", "\u2510").replaceAll("\u2570", "\u2514").replaceAll("\u256F", "\u2518");
5924
6262
  chartLines = raw.split("\n");
5925
6263
  }
5926
- return /* @__PURE__ */ jsxs12(Box12, { flexDirection: "column", paddingLeft: 1, children: [
5927
- /* @__PURE__ */ jsxs12(Box12, { marginBottom: 1, justifyContent: "space-between", children: [
5928
- /* @__PURE__ */ jsxs12(Box12, { children: [
5929
- /* @__PURE__ */ jsxs12(Text14, { bold: true, color: "#00ffff", children: [
6264
+ return /* @__PURE__ */ jsxs13(Box13, { flexDirection: "column", paddingLeft: 1, children: [
6265
+ /* @__PURE__ */ jsxs13(Box13, { marginBottom: 1, justifyContent: "space-between", children: [
6266
+ /* @__PURE__ */ jsxs13(Box13, { children: [
6267
+ /* @__PURE__ */ jsxs13(Text14, { bold: true, color: "#00ffff", children: [
5930
6268
  " \u{1F4CA} ",
5931
6269
  stock.name,
5932
6270
  " "
5933
6271
  ] }),
5934
6272
  /* @__PURE__ */ jsx13(Text14, { dimColor: true, children: stock.code }),
5935
- currentTime && /* @__PURE__ */ jsxs12(Text14, { dimColor: true, children: [
6273
+ currentTime && /* @__PURE__ */ jsxs13(Text14, { dimColor: true, children: [
5936
6274
  " \u{1F550} ",
5937
6275
  currentTime
5938
6276
  ] })
5939
6277
  ] }),
5940
6278
  /* @__PURE__ */ jsx13(Text14, { dimColor: true, children: `${countdown}s \u540E\u5237\u65B0` })
5941
6279
  ] }),
5942
- /* @__PURE__ */ jsxs12(Box12, { children: [
5943
- /* @__PURE__ */ jsx13(Box12, { width: 16, children: /* @__PURE__ */ jsx13(Text14, { bold: true, color: "#888888", children: "\u5F53\u524D\u4EF7" }) }),
5944
- /* @__PURE__ */ jsx13(Box12, { children: /* @__PURE__ */ jsxs12(Text14, { bold: true, color: colorCode, children: [
6280
+ /* @__PURE__ */ jsxs13(Box13, { children: [
6281
+ /* @__PURE__ */ jsx13(Box13, { width: 16, children: /* @__PURE__ */ jsx13(Text14, { bold: true, color: "#888888", children: "\u5F53\u524D\u4EF7" }) }),
6282
+ /* @__PURE__ */ jsx13(Box13, { children: /* @__PURE__ */ jsxs13(Text14, { bold: true, color: colorCode, children: [
5945
6283
  arrow,
5946
6284
  " ",
5947
6285
  formatPrice(stock.price)
5948
6286
  ] }) })
5949
6287
  ] }),
5950
- /* @__PURE__ */ jsxs12(Box12, { children: [
5951
- /* @__PURE__ */ jsx13(Box12, { width: 16, children: /* @__PURE__ */ jsx13(Text14, { color: "#888888", children: "\u6DA8\u8DCC\u5E45" }) }),
5952
- /* @__PURE__ */ jsx13(Box12, { children: /* @__PURE__ */ jsxs12(Text14, { color: colorCode, children: [
6288
+ /* @__PURE__ */ jsxs13(Box13, { children: [
6289
+ /* @__PURE__ */ jsx13(Box13, { width: 16, children: /* @__PURE__ */ jsx13(Text14, { color: "#888888", children: "\u6DA8\u8DCC\u5E45" }) }),
6290
+ /* @__PURE__ */ jsx13(Box13, { children: /* @__PURE__ */ jsxs13(Text14, { color: colorCode, children: [
5953
6291
  isUp ? "+" : "",
5954
6292
  stock.changePercent.toFixed(2),
5955
6293
  "%",
@@ -5958,8 +6296,8 @@ function renderDetail(stock, _onBack, prices, countdown = 10, currentTime) {
5958
6296
  stock.changeAmount.toFixed(3)
5959
6297
  ] }) })
5960
6298
  ] }),
5961
- 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)) }),
5962
- /* @__PURE__ */ jsx13(Box12, { marginTop: 1, children: /* @__PURE__ */ jsx13(Text14, { dimColor: true, children: " Space/q \u8FD4\u56DE\u5217\u8868" }) })
6299
+ chartLines.length > 0 && /* @__PURE__ */ jsx13(Box13, { marginTop: 1, flexDirection: "column", children: chartLines.map((line, i) => /* @__PURE__ */ jsx13(Box13, { children: /* @__PURE__ */ jsx13(Text14, { color: colorCode, children: line || " " }) }, i)) }),
6300
+ /* @__PURE__ */ jsx13(Box13, { marginTop: 1, children: /* @__PURE__ */ jsx13(Text14, { dimColor: true, children: " Space/q \u8FD4\u56DE\u5217\u8868" }) })
5963
6301
  ] });
5964
6302
  }
5965
6303
 
@@ -6075,81 +6413,8 @@ function createCli() {
6075
6413
  budgetLimit: ctx?.config.budgetLimit ?? 0,
6076
6414
  tokenBudgetLimit: ctx?.config.tokenBudgetLimit ?? 0
6077
6415
  });
6078
- startChat(ctx, costTracker);
6416
+ void startChat(ctx, costTracker);
6079
6417
  });
6080
- async function startChat(ctx, costTracker) {
6081
- const [globalSkillCount, localSkillCount, skills, files] = await Promise.all([
6082
- countDskcodeSkills(),
6083
- countProjectLocalSkills(process.cwd()),
6084
- getAllSkills(process.cwd()),
6085
- scanProjectFiles(process.cwd())
6086
- ]);
6087
- const skillCount = globalSkillCount + localSkillCount;
6088
- const defaultProvider = ctx?.config.providers.find(
6089
- (p) => p.name === (ctx?.config.defaultProvider ?? "deepseek")
6090
- );
6091
- const model = defaultProvider?.model ?? "deepseek-v4-flash";
6092
- const chatApp = renderApp(
6093
- /* @__PURE__ */ jsx14(
6094
- ChatSession,
6095
- {
6096
- skillCount,
6097
- skills,
6098
- files,
6099
- toolCount: ctx?.config.tools.length ?? 0,
6100
- verbose: ctx?.verbose ?? false,
6101
- apiKey: defaultProvider?.apiKey,
6102
- baseUrl: defaultProvider?.baseUrl ?? "https://api.deepseek.com",
6103
- costTracker,
6104
- model,
6105
- onLaunchGame: () => {
6106
- chatApp.unmount();
6107
- setImmediate(() => {
6108
- initGames();
6109
- const games = listGames();
6110
- const { unmount } = render4(
6111
- /* @__PURE__ */ jsx14(
6112
- GamePicker,
6113
- {
6114
- games,
6115
- onSelect: async (game) => {
6116
- unmount();
6117
- await game.play();
6118
- startChat(ctx, costTracker);
6119
- },
6120
- onBackToChat: () => {
6121
- unmount();
6122
- setImmediate(() => startChat(ctx, costTracker));
6123
- }
6124
- }
6125
- ),
6126
- { exitOnCtrlC: false }
6127
- );
6128
- });
6129
- },
6130
- onLaunchStock: () => {
6131
- chatApp.unmount();
6132
- setImmediate(() => {
6133
- const defaultStockCodes = ctx?.config.stock?.symbols?.map((s) => s.code) ?? ["sh000001", "sz399006", "sh601688"];
6134
- const stockApp = renderApp(
6135
- /* @__PURE__ */ jsx14(
6136
- StockList,
6137
- {
6138
- codes: defaultStockCodes,
6139
- onBackToChat: () => {
6140
- stockApp.unmount();
6141
- setImmediate(() => startChat(ctx, costTracker));
6142
- },
6143
- onExit: () => process.exit(0)
6144
- }
6145
- )
6146
- );
6147
- });
6148
- }
6149
- }
6150
- )
6151
- );
6152
- }
6153
6418
  program2.command("run").description("\u6267\u884C\u4E00\u6B21\u6027\u4EFB\u52A1").argument("[prompt...]", "\u4EFB\u52A1\u63CF\u8FF0").option("--model <name>", "\u6307\u5B9A\u4F7F\u7528\u7684\u6A21\u578B").action(async function(_prompt) {
6154
6419
  console.log("dskcode run \u2014 \u5F85\u5B9E\u73B0\uFF08\u7B2C07\u7AE0\uFF09");
6155
6420
  });
@@ -6194,7 +6459,7 @@ compdef _dskcode_completion dskcode`);
6194
6459
  }
6195
6460
  });
6196
6461
  program2.command("stock").description("\u67E5\u770B\u81EA\u9009\u80A1\u5B9E\u65F6\u884C\u60C5").argument("[codes...]", "\u80A1\u7968\u4EE3\u7801\uFF08\u7A7A\u683C\u5206\u9694\uFF09\uFF0C\u5982 513090 600519").action(async function(codes) {
6197
- const ctx = this.dskcodeCtx;
6462
+ const _ctx = this.dskcodeCtx;
6198
6463
  const home = process.env.HOME ?? process.env.USERPROFILE ?? "~";
6199
6464
  const globalConfigPath = join9(home, ".dskcode", "settings.json");
6200
6465
  let globalConfigHasStock = false;
@@ -6275,6 +6540,79 @@ compdef _dskcode_completion dskcode`);
6275
6540
  });
6276
6541
  return program2;
6277
6542
  }
6543
+ async function startChat(ctx, costTracker) {
6544
+ const [globalSkillCount, localSkillCount, skills, files] = await Promise.all([
6545
+ countDskcodeSkills(),
6546
+ countProjectLocalSkills(process.cwd()),
6547
+ getAllSkills(process.cwd()),
6548
+ scanProjectFiles(process.cwd())
6549
+ ]);
6550
+ const skillCount = globalSkillCount + localSkillCount;
6551
+ const defaultProvider = ctx?.config.providers.find(
6552
+ (p) => p.name === (ctx?.config.defaultProvider ?? "deepseek")
6553
+ );
6554
+ const model = defaultProvider?.model ?? "deepseek-v4-flash";
6555
+ const chatApp = renderApp(
6556
+ /* @__PURE__ */ jsx14(
6557
+ ChatSession,
6558
+ {
6559
+ skillCount,
6560
+ skills,
6561
+ files,
6562
+ toolCount: ctx?.config.tools.length ?? 0,
6563
+ verbose: ctx?.verbose ?? false,
6564
+ apiKey: defaultProvider?.apiKey,
6565
+ baseUrl: defaultProvider?.baseUrl ?? "https://api.deepseek.com",
6566
+ costTracker,
6567
+ model,
6568
+ onLaunchGame: () => {
6569
+ chatApp.unmount();
6570
+ setImmediate(() => {
6571
+ initGames();
6572
+ const games = listGames();
6573
+ const { unmount } = render4(
6574
+ /* @__PURE__ */ jsx14(
6575
+ GamePicker,
6576
+ {
6577
+ games,
6578
+ onSelect: async (game) => {
6579
+ unmount();
6580
+ await game.play();
6581
+ void startChat(ctx, costTracker);
6582
+ },
6583
+ onBackToChat: () => {
6584
+ unmount();
6585
+ setImmediate(() => startChat(ctx, costTracker));
6586
+ }
6587
+ }
6588
+ ),
6589
+ { exitOnCtrlC: false }
6590
+ );
6591
+ });
6592
+ },
6593
+ onLaunchStock: () => {
6594
+ chatApp.unmount();
6595
+ setImmediate(() => {
6596
+ const defaultStockCodes = ctx?.config.stock?.symbols?.map((s) => s.code) ?? ["sh000001", "sz399006", "sh601688"];
6597
+ const stockApp = renderApp(
6598
+ /* @__PURE__ */ jsx14(
6599
+ StockList,
6600
+ {
6601
+ codes: defaultStockCodes,
6602
+ onBackToChat: () => {
6603
+ stockApp.unmount();
6604
+ setImmediate(() => startChat(ctx, costTracker));
6605
+ },
6606
+ onExit: () => process.exit(0)
6607
+ }
6608
+ )
6609
+ );
6610
+ });
6611
+ }
6612
+ }
6613
+ )
6614
+ );
6615
+ }
6278
6616
 
6279
6617
  // src/cli/exit-codes.ts
6280
6618
  var ExitCode = {