stashes 0.1.20 → 0.1.21
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/cli.js +62 -15
- package/dist/mcp.js +62 -15
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1417,11 +1417,27 @@ ${sourceCode.substring(0, 3000)}
|
|
|
1417
1417
|
].filter(Boolean).join(`
|
|
1418
1418
|
`);
|
|
1419
1419
|
const aiProcess = startAiProcess("chat", chatPrompt, this.projectPath);
|
|
1420
|
-
let
|
|
1420
|
+
let thinkingBuf = "";
|
|
1421
|
+
let textBuf = "";
|
|
1422
|
+
const pendingMessages = [];
|
|
1423
|
+
const now = new Date().toISOString();
|
|
1424
|
+
function flushThinking() {
|
|
1425
|
+
if (!thinkingBuf)
|
|
1426
|
+
return;
|
|
1427
|
+
pendingMessages.push({ id: crypto.randomUUID(), role: "assistant", content: thinkingBuf, type: "thinking", createdAt: now });
|
|
1428
|
+
thinkingBuf = "";
|
|
1429
|
+
}
|
|
1430
|
+
function flushText() {
|
|
1431
|
+
if (!textBuf)
|
|
1432
|
+
return;
|
|
1433
|
+
pendingMessages.push({ id: crypto.randomUUID(), role: "assistant", content: textBuf, type: "text", createdAt: now });
|
|
1434
|
+
textBuf = "";
|
|
1435
|
+
}
|
|
1421
1436
|
try {
|
|
1422
1437
|
for await (const chunk of parseClaudeStream(aiProcess.process)) {
|
|
1423
1438
|
if (chunk.type === "text") {
|
|
1424
|
-
|
|
1439
|
+
flushThinking();
|
|
1440
|
+
textBuf += chunk.content;
|
|
1425
1441
|
this.broadcast({
|
|
1426
1442
|
type: "ai_stream",
|
|
1427
1443
|
content: chunk.content,
|
|
@@ -1429,6 +1445,7 @@ ${sourceCode.substring(0, 3000)}
|
|
|
1429
1445
|
source: "chat"
|
|
1430
1446
|
});
|
|
1431
1447
|
} else if (chunk.type === "thinking") {
|
|
1448
|
+
thinkingBuf += chunk.content;
|
|
1432
1449
|
this.broadcast({
|
|
1433
1450
|
type: "ai_stream",
|
|
1434
1451
|
content: chunk.content,
|
|
@@ -1436,36 +1453,66 @@ ${sourceCode.substring(0, 3000)}
|
|
|
1436
1453
|
source: "chat"
|
|
1437
1454
|
});
|
|
1438
1455
|
} else if (chunk.type === "tool_use") {
|
|
1456
|
+
flushThinking();
|
|
1457
|
+
flushText();
|
|
1458
|
+
let toolName = "unknown";
|
|
1459
|
+
let toolParams = {};
|
|
1460
|
+
try {
|
|
1461
|
+
const parsed = JSON.parse(chunk.content);
|
|
1462
|
+
toolName = parsed.tool ?? "unknown";
|
|
1463
|
+
toolParams = parsed.input ?? {};
|
|
1464
|
+
} catch {}
|
|
1465
|
+
pendingMessages.push({
|
|
1466
|
+
id: crypto.randomUUID(),
|
|
1467
|
+
role: "assistant",
|
|
1468
|
+
content: chunk.content,
|
|
1469
|
+
type: "tool_start",
|
|
1470
|
+
toolName,
|
|
1471
|
+
toolParams,
|
|
1472
|
+
toolStatus: "running",
|
|
1473
|
+
createdAt: now
|
|
1474
|
+
});
|
|
1439
1475
|
this.broadcast({
|
|
1440
1476
|
type: "ai_stream",
|
|
1441
1477
|
content: chunk.content,
|
|
1442
1478
|
streamType: "tool_start",
|
|
1443
1479
|
source: "chat",
|
|
1444
|
-
toolName
|
|
1445
|
-
toolParams
|
|
1480
|
+
toolName,
|
|
1481
|
+
toolParams,
|
|
1446
1482
|
toolStatus: "running"
|
|
1447
1483
|
});
|
|
1448
1484
|
} else if (chunk.type === "tool_result") {
|
|
1485
|
+
let toolResult = chunk.content;
|
|
1486
|
+
let isError = false;
|
|
1487
|
+
try {
|
|
1488
|
+
const parsed = JSON.parse(chunk.content);
|
|
1489
|
+
toolResult = parsed.result ?? chunk.content;
|
|
1490
|
+
isError = !!parsed.is_error;
|
|
1491
|
+
} catch {}
|
|
1492
|
+
pendingMessages.push({
|
|
1493
|
+
id: crypto.randomUUID(),
|
|
1494
|
+
role: "assistant",
|
|
1495
|
+
content: chunk.content,
|
|
1496
|
+
type: "tool_end",
|
|
1497
|
+
toolStatus: isError ? "error" : "completed",
|
|
1498
|
+
toolResult: toolResult.substring(0, 300),
|
|
1499
|
+
createdAt: now
|
|
1500
|
+
});
|
|
1449
1501
|
this.broadcast({
|
|
1450
1502
|
type: "ai_stream",
|
|
1451
1503
|
content: chunk.content,
|
|
1452
1504
|
streamType: "tool_end",
|
|
1453
1505
|
source: "chat",
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
toolResult: chunk.content.substring(0, 300)
|
|
1506
|
+
toolStatus: isError ? "error" : "completed",
|
|
1507
|
+
toolResult: toolResult.substring(0, 300)
|
|
1457
1508
|
});
|
|
1458
1509
|
}
|
|
1459
1510
|
}
|
|
1460
1511
|
await aiProcess.process.exited;
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
content: fullResponse,
|
|
1466
|
-
type: "text",
|
|
1467
|
-
createdAt: new Date().toISOString()
|
|
1468
|
-
});
|
|
1512
|
+
flushThinking();
|
|
1513
|
+
flushText();
|
|
1514
|
+
for (const msg of pendingMessages) {
|
|
1515
|
+
this.persistence.saveChatMessage(projectId, chatId, msg);
|
|
1469
1516
|
}
|
|
1470
1517
|
} catch (err) {
|
|
1471
1518
|
this.broadcast({
|
package/dist/mcp.js
CHANGED
|
@@ -1613,11 +1613,27 @@ ${sourceCode.substring(0, 3000)}
|
|
|
1613
1613
|
].filter(Boolean).join(`
|
|
1614
1614
|
`);
|
|
1615
1615
|
const aiProcess = startAiProcess("chat", chatPrompt, this.projectPath);
|
|
1616
|
-
let
|
|
1616
|
+
let thinkingBuf = "";
|
|
1617
|
+
let textBuf = "";
|
|
1618
|
+
const pendingMessages = [];
|
|
1619
|
+
const now = new Date().toISOString();
|
|
1620
|
+
function flushThinking() {
|
|
1621
|
+
if (!thinkingBuf)
|
|
1622
|
+
return;
|
|
1623
|
+
pendingMessages.push({ id: crypto.randomUUID(), role: "assistant", content: thinkingBuf, type: "thinking", createdAt: now });
|
|
1624
|
+
thinkingBuf = "";
|
|
1625
|
+
}
|
|
1626
|
+
function flushText() {
|
|
1627
|
+
if (!textBuf)
|
|
1628
|
+
return;
|
|
1629
|
+
pendingMessages.push({ id: crypto.randomUUID(), role: "assistant", content: textBuf, type: "text", createdAt: now });
|
|
1630
|
+
textBuf = "";
|
|
1631
|
+
}
|
|
1617
1632
|
try {
|
|
1618
1633
|
for await (const chunk of parseClaudeStream(aiProcess.process)) {
|
|
1619
1634
|
if (chunk.type === "text") {
|
|
1620
|
-
|
|
1635
|
+
flushThinking();
|
|
1636
|
+
textBuf += chunk.content;
|
|
1621
1637
|
this.broadcast({
|
|
1622
1638
|
type: "ai_stream",
|
|
1623
1639
|
content: chunk.content,
|
|
@@ -1625,6 +1641,7 @@ ${sourceCode.substring(0, 3000)}
|
|
|
1625
1641
|
source: "chat"
|
|
1626
1642
|
});
|
|
1627
1643
|
} else if (chunk.type === "thinking") {
|
|
1644
|
+
thinkingBuf += chunk.content;
|
|
1628
1645
|
this.broadcast({
|
|
1629
1646
|
type: "ai_stream",
|
|
1630
1647
|
content: chunk.content,
|
|
@@ -1632,36 +1649,66 @@ ${sourceCode.substring(0, 3000)}
|
|
|
1632
1649
|
source: "chat"
|
|
1633
1650
|
});
|
|
1634
1651
|
} else if (chunk.type === "tool_use") {
|
|
1652
|
+
flushThinking();
|
|
1653
|
+
flushText();
|
|
1654
|
+
let toolName = "unknown";
|
|
1655
|
+
let toolParams = {};
|
|
1656
|
+
try {
|
|
1657
|
+
const parsed = JSON.parse(chunk.content);
|
|
1658
|
+
toolName = parsed.tool ?? "unknown";
|
|
1659
|
+
toolParams = parsed.input ?? {};
|
|
1660
|
+
} catch {}
|
|
1661
|
+
pendingMessages.push({
|
|
1662
|
+
id: crypto.randomUUID(),
|
|
1663
|
+
role: "assistant",
|
|
1664
|
+
content: chunk.content,
|
|
1665
|
+
type: "tool_start",
|
|
1666
|
+
toolName,
|
|
1667
|
+
toolParams,
|
|
1668
|
+
toolStatus: "running",
|
|
1669
|
+
createdAt: now
|
|
1670
|
+
});
|
|
1635
1671
|
this.broadcast({
|
|
1636
1672
|
type: "ai_stream",
|
|
1637
1673
|
content: chunk.content,
|
|
1638
1674
|
streamType: "tool_start",
|
|
1639
1675
|
source: "chat",
|
|
1640
|
-
toolName
|
|
1641
|
-
toolParams
|
|
1676
|
+
toolName,
|
|
1677
|
+
toolParams,
|
|
1642
1678
|
toolStatus: "running"
|
|
1643
1679
|
});
|
|
1644
1680
|
} else if (chunk.type === "tool_result") {
|
|
1681
|
+
let toolResult = chunk.content;
|
|
1682
|
+
let isError = false;
|
|
1683
|
+
try {
|
|
1684
|
+
const parsed = JSON.parse(chunk.content);
|
|
1685
|
+
toolResult = parsed.result ?? chunk.content;
|
|
1686
|
+
isError = !!parsed.is_error;
|
|
1687
|
+
} catch {}
|
|
1688
|
+
pendingMessages.push({
|
|
1689
|
+
id: crypto.randomUUID(),
|
|
1690
|
+
role: "assistant",
|
|
1691
|
+
content: chunk.content,
|
|
1692
|
+
type: "tool_end",
|
|
1693
|
+
toolStatus: isError ? "error" : "completed",
|
|
1694
|
+
toolResult: toolResult.substring(0, 300),
|
|
1695
|
+
createdAt: now
|
|
1696
|
+
});
|
|
1645
1697
|
this.broadcast({
|
|
1646
1698
|
type: "ai_stream",
|
|
1647
1699
|
content: chunk.content,
|
|
1648
1700
|
streamType: "tool_end",
|
|
1649
1701
|
source: "chat",
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
toolResult: chunk.content.substring(0, 300)
|
|
1702
|
+
toolStatus: isError ? "error" : "completed",
|
|
1703
|
+
toolResult: toolResult.substring(0, 300)
|
|
1653
1704
|
});
|
|
1654
1705
|
}
|
|
1655
1706
|
}
|
|
1656
1707
|
await aiProcess.process.exited;
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
content: fullResponse,
|
|
1662
|
-
type: "text",
|
|
1663
|
-
createdAt: new Date().toISOString()
|
|
1664
|
-
});
|
|
1708
|
+
flushThinking();
|
|
1709
|
+
flushText();
|
|
1710
|
+
for (const msg of pendingMessages) {
|
|
1711
|
+
this.persistence.saveChatMessage(projectId, chatId, msg);
|
|
1665
1712
|
}
|
|
1666
1713
|
} catch (err) {
|
|
1667
1714
|
this.broadcast({
|