maidang 29.8.2 → 29.9.0
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/README.md +3 -3
- package/dist/index.js +309 -36
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -27,13 +27,13 @@ maidang skills 可分享的 Agent Skills
|
|
|
27
27
|
maidang cat|meow 麦麦
|
|
28
28
|
maidang contact 给麦当留言(直发,不经过大模型)
|
|
29
29
|
maidang manifest 面向 AI 的公开资料清单
|
|
30
|
-
maidang chat
|
|
31
|
-
maidang news AI
|
|
30
|
+
maidang chat 和我对话(TUI / -m 渲染 Markdown)
|
|
31
|
+
maidang news AI 日报(TTY 渲染 Markdown;--list 最近 10 期,--date 指定日期)
|
|
32
32
|
maidang changelog 站点更新日志
|
|
33
33
|
maidang upgrade 升级 maidang(--yes 跳过确认,--json 仅检查)
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
-
所有命令支持 **--json** 输出,结构化数据,方便程序读取。
|
|
36
|
+
所有命令支持 **--json** 输出,结构化数据,方便程序读取。TTY 下 `chat`、`chat -m`、`news` 会排版标题、列表和代码块;`--json` 仍是原文。
|
|
37
37
|
|
|
38
38
|
## 退出码
|
|
39
39
|
|
package/dist/index.js
CHANGED
|
@@ -50,13 +50,16 @@ var commands = [
|
|
|
50
50
|
{ name: "career", desc: "\u5DE5\u4F5C\u7ECF\u5386" },
|
|
51
51
|
{ name: "projects", desc: "\u4E00\u4E9B\u5DF2\u7ECF\u843D\u5730\u7684\u4E1C\u897F" },
|
|
52
52
|
{ name: "posts", desc: "\u6700\u8FD1\u5728\u5199\u3001\u5728\u60F3\u7684" },
|
|
53
|
+
{ name: "news", desc: "AI \u65E5\u62A5" },
|
|
54
|
+
{ name: "changelog", desc: "\u7AD9\u70B9\u66F4\u65B0\u65E5\u5FD7" },
|
|
53
55
|
{ name: "tools", desc: "\u6700\u8FD1\u5728\u7528\u7684\u597D\u7269" },
|
|
54
56
|
{ name: "skills", desc: "\u53EF\u5206\u4EAB\u7684 Agent Skills" },
|
|
55
57
|
{ name: "songs", desc: "\u5E74\u5EA6\u6B4C\u5355" },
|
|
56
58
|
{ name: "links", desc: "\u793E\u4EA4\u4E0E\u5916\u94FE" },
|
|
57
59
|
{ name: "cat", desc: "\u9EA6\u9EA6" },
|
|
58
60
|
{ name: "contact", desc: "\u7ED9\u6211\u7559\u8A00" },
|
|
59
|
-
{ name: "manifest", desc: "\u4E00\u6B21\u6027\u7ED9 AI \u7684\u5168\u90E8\u6570\u636E (JSON)" }
|
|
61
|
+
{ name: "manifest", desc: "\u4E00\u6B21\u6027\u7ED9 AI \u7684\u5168\u90E8\u6570\u636E (JSON)" },
|
|
62
|
+
{ name: "upgrade", desc: "\u5347\u7EA7 maidang \u5230\u6700\u65B0\u7248" }
|
|
60
63
|
];
|
|
61
64
|
function createHomeCommand() {
|
|
62
65
|
const cmd = new Command("maidang").description("\u4E00\u4EFD\u53EF\u4EE5\u88AB AI \u8BFB\u53D6\u7684\u4E2A\u4EBA\u624B\u518C").action(() => {
|
|
@@ -1648,10 +1651,264 @@ function createWhoAmICommand() {
|
|
|
1648
1651
|
}
|
|
1649
1652
|
|
|
1650
1653
|
// src/commands/chat.tsx
|
|
1651
|
-
import
|
|
1652
|
-
import { render, Box, Text, useInput } from "ink";
|
|
1654
|
+
import React2, { useState, useRef, useEffect } from "react";
|
|
1655
|
+
import { render, Box as Box2, Text as Text2, useInput } from "ink";
|
|
1653
1656
|
import { Command as Command12 } from "commander";
|
|
1657
|
+
import chalk4 from "chalk";
|
|
1658
|
+
|
|
1659
|
+
// src/components/markdown-view.tsx
|
|
1660
|
+
import React from "react";
|
|
1661
|
+
import { Box, Text } from "ink";
|
|
1662
|
+
|
|
1663
|
+
// src/utils/markdown-ast.ts
|
|
1664
|
+
var FENCE_OPEN = /^(`{3,}|~{3,})(.*)$/;
|
|
1665
|
+
var HEADING = /^(#{1,6})\s+(.+?)\s*$/;
|
|
1666
|
+
var UNORDERED = /^\s*[-*+]\s+(.+)$/;
|
|
1667
|
+
var ORDERED = /^\s*\d+\.\s+(.+)$/;
|
|
1668
|
+
var isBlockStart = (line) => FENCE_OPEN.test(line) || HEADING.test(line) || UNORDERED.test(line) || ORDERED.test(line);
|
|
1669
|
+
var plainPaint = {
|
|
1670
|
+
heading: (text) => text,
|
|
1671
|
+
bold: (text) => text,
|
|
1672
|
+
italic: (text) => text,
|
|
1673
|
+
code: (text) => text,
|
|
1674
|
+
linkText: (text) => text,
|
|
1675
|
+
href: (text) => text,
|
|
1676
|
+
marker: (text) => text,
|
|
1677
|
+
codeLine: (text) => text
|
|
1678
|
+
};
|
|
1679
|
+
var matchLink = (input, start) => {
|
|
1680
|
+
if (input[start] !== "[") return null;
|
|
1681
|
+
const close = input.indexOf("]", start + 1);
|
|
1682
|
+
if (close === -1 || input[close + 1] !== "(") return null;
|
|
1683
|
+
const hrefEnd = input.indexOf(")", close + 2);
|
|
1684
|
+
if (hrefEnd === -1) return null;
|
|
1685
|
+
return {
|
|
1686
|
+
text: input.slice(start + 1, close),
|
|
1687
|
+
href: input.slice(close + 2, hrefEnd),
|
|
1688
|
+
end: hrefEnd + 1
|
|
1689
|
+
};
|
|
1690
|
+
};
|
|
1691
|
+
var isWordChar = (ch) => Boolean(ch && /[A-Za-z0-9]/.test(ch));
|
|
1692
|
+
var parseInlines = (input) => {
|
|
1693
|
+
const nodes = [];
|
|
1694
|
+
let i = 0;
|
|
1695
|
+
let text = "";
|
|
1696
|
+
const flush = () => {
|
|
1697
|
+
if (!text) return;
|
|
1698
|
+
nodes.push({ type: "text", value: text });
|
|
1699
|
+
text = "";
|
|
1700
|
+
};
|
|
1701
|
+
while (i < input.length) {
|
|
1702
|
+
const ch = input[i];
|
|
1703
|
+
if (ch === "\\" && i + 1 < input.length) {
|
|
1704
|
+
text += input[i + 1];
|
|
1705
|
+
i += 2;
|
|
1706
|
+
continue;
|
|
1707
|
+
}
|
|
1708
|
+
if (ch === "`") {
|
|
1709
|
+
const end = input.indexOf("`", i + 1);
|
|
1710
|
+
if (end !== -1) {
|
|
1711
|
+
flush();
|
|
1712
|
+
nodes.push({ type: "code", value: input.slice(i + 1, end) });
|
|
1713
|
+
i = end + 1;
|
|
1714
|
+
continue;
|
|
1715
|
+
}
|
|
1716
|
+
}
|
|
1717
|
+
if (ch === "[") {
|
|
1718
|
+
const link = matchLink(input, i);
|
|
1719
|
+
if (link) {
|
|
1720
|
+
flush();
|
|
1721
|
+
nodes.push({ type: "link", text: link.text, href: link.href });
|
|
1722
|
+
i = link.end;
|
|
1723
|
+
continue;
|
|
1724
|
+
}
|
|
1725
|
+
}
|
|
1726
|
+
if (input.startsWith("**", i) || input.startsWith("__", i)) {
|
|
1727
|
+
const delim = input.slice(i, i + 2);
|
|
1728
|
+
const end = input.indexOf(delim, i + 2);
|
|
1729
|
+
if (end !== -1) {
|
|
1730
|
+
flush();
|
|
1731
|
+
nodes.push({ type: "bold", children: parseInlines(input.slice(i + 2, end)) });
|
|
1732
|
+
i = end + 2;
|
|
1733
|
+
continue;
|
|
1734
|
+
}
|
|
1735
|
+
}
|
|
1736
|
+
if (ch === "_" && isWordChar(input[i - 1]) && isWordChar(input[i + 1])) {
|
|
1737
|
+
text += ch;
|
|
1738
|
+
i += 1;
|
|
1739
|
+
continue;
|
|
1740
|
+
}
|
|
1741
|
+
if (ch === "*" || ch === "_") {
|
|
1742
|
+
const end = input.indexOf(ch, i + 1);
|
|
1743
|
+
if (end !== -1 && input[end + 1] !== ch) {
|
|
1744
|
+
flush();
|
|
1745
|
+
nodes.push({ type: "italic", children: parseInlines(input.slice(i + 1, end)) });
|
|
1746
|
+
i = end + 1;
|
|
1747
|
+
continue;
|
|
1748
|
+
}
|
|
1749
|
+
}
|
|
1750
|
+
text += ch;
|
|
1751
|
+
i += 1;
|
|
1752
|
+
}
|
|
1753
|
+
flush();
|
|
1754
|
+
return nodes;
|
|
1755
|
+
};
|
|
1756
|
+
var parseMarkdown = (source) => {
|
|
1757
|
+
const lines = source.replace(/\r\n/g, "\n").split("\n");
|
|
1758
|
+
const blocks = [];
|
|
1759
|
+
let i = 0;
|
|
1760
|
+
while (i < lines.length) {
|
|
1761
|
+
const line = lines[i];
|
|
1762
|
+
if (!line.trim()) {
|
|
1763
|
+
i += 1;
|
|
1764
|
+
continue;
|
|
1765
|
+
}
|
|
1766
|
+
const fence = line.match(FENCE_OPEN);
|
|
1767
|
+
if (fence) {
|
|
1768
|
+
const marker = fence[1];
|
|
1769
|
+
const lang = fence[2].trim();
|
|
1770
|
+
const body = [];
|
|
1771
|
+
i += 1;
|
|
1772
|
+
while (i < lines.length && !lines[i].startsWith(marker)) {
|
|
1773
|
+
body.push(lines[i]);
|
|
1774
|
+
i += 1;
|
|
1775
|
+
}
|
|
1776
|
+
if (i < lines.length) i += 1;
|
|
1777
|
+
blocks.push({ type: "code", lang, value: body.join("\n") });
|
|
1778
|
+
continue;
|
|
1779
|
+
}
|
|
1780
|
+
const heading = line.match(HEADING);
|
|
1781
|
+
if (heading) {
|
|
1782
|
+
blocks.push({
|
|
1783
|
+
type: "heading",
|
|
1784
|
+
level: heading[1].length,
|
|
1785
|
+
children: parseInlines(heading[2].replace(/\s+#+\s*$/, "").trim())
|
|
1786
|
+
});
|
|
1787
|
+
i += 1;
|
|
1788
|
+
continue;
|
|
1789
|
+
}
|
|
1790
|
+
const unordered = UNORDERED.test(line);
|
|
1791
|
+
const ordered = ORDERED.test(line);
|
|
1792
|
+
if (unordered || ordered) {
|
|
1793
|
+
const pattern = ordered ? ORDERED : UNORDERED;
|
|
1794
|
+
const items = [];
|
|
1795
|
+
while (i < lines.length) {
|
|
1796
|
+
const item = lines[i].match(pattern);
|
|
1797
|
+
if (!item) break;
|
|
1798
|
+
items.push(parseInlines(item[1]));
|
|
1799
|
+
i += 1;
|
|
1800
|
+
}
|
|
1801
|
+
blocks.push({ type: "list", ordered, items });
|
|
1802
|
+
continue;
|
|
1803
|
+
}
|
|
1804
|
+
const para = [];
|
|
1805
|
+
while (i < lines.length && lines[i].trim() && !isBlockStart(lines[i])) {
|
|
1806
|
+
para.push(lines[i].trim());
|
|
1807
|
+
i += 1;
|
|
1808
|
+
}
|
|
1809
|
+
blocks.push({ type: "paragraph", children: parseInlines(para.join(" ")) });
|
|
1810
|
+
}
|
|
1811
|
+
return blocks;
|
|
1812
|
+
};
|
|
1813
|
+
var renderInlines = (nodes, paint) => nodes.map((node) => {
|
|
1814
|
+
switch (node.type) {
|
|
1815
|
+
case "text":
|
|
1816
|
+
return node.value;
|
|
1817
|
+
case "bold":
|
|
1818
|
+
return paint.bold(renderInlines(node.children, paint));
|
|
1819
|
+
case "italic":
|
|
1820
|
+
return paint.italic(renderInlines(node.children, paint));
|
|
1821
|
+
case "code":
|
|
1822
|
+
return paint.code(node.value);
|
|
1823
|
+
case "link":
|
|
1824
|
+
return `${paint.linkText(node.text)}${node.href ? paint.href(` ${node.href}`) : ""}`;
|
|
1825
|
+
}
|
|
1826
|
+
}).join("");
|
|
1827
|
+
var renderBlock = (block, paint) => {
|
|
1828
|
+
switch (block.type) {
|
|
1829
|
+
case "heading":
|
|
1830
|
+
return paint.heading(renderInlines(block.children, paint));
|
|
1831
|
+
case "paragraph":
|
|
1832
|
+
return renderInlines(block.children, paint);
|
|
1833
|
+
case "list":
|
|
1834
|
+
return block.items.map((item, index) => {
|
|
1835
|
+
const marker = block.ordered ? `${index + 1}.` : "\u2022";
|
|
1836
|
+
return `${paint.marker(marker)} ${renderInlines(item, paint)}`;
|
|
1837
|
+
}).join("\n");
|
|
1838
|
+
case "code": {
|
|
1839
|
+
const lines = block.value.length > 0 ? block.value.split("\n") : [""];
|
|
1840
|
+
const body = lines.map((line) => paint.codeLine(line || " ")).join("\n");
|
|
1841
|
+
return block.lang ? `${paint.marker(block.lang)}
|
|
1842
|
+
${body}` : body;
|
|
1843
|
+
}
|
|
1844
|
+
}
|
|
1845
|
+
};
|
|
1846
|
+
var formatMarkdown = (source, options = {}) => {
|
|
1847
|
+
const indent = options.indent ?? "";
|
|
1848
|
+
const paint = options.paint ?? plainPaint;
|
|
1849
|
+
const blocks = parseMarkdown(source);
|
|
1850
|
+
if (blocks.length === 0) return indent;
|
|
1851
|
+
const body = blocks.map((block) => renderBlock(block, paint)).join("\n\n");
|
|
1852
|
+
if (!indent) return body;
|
|
1853
|
+
return body.split("\n").map((line) => indent + line).join("\n");
|
|
1854
|
+
};
|
|
1855
|
+
|
|
1856
|
+
// src/components/markdown-view.tsx
|
|
1857
|
+
var renderInlines2 = (nodes) => nodes.map((node, index) => renderInline(node, index));
|
|
1858
|
+
var renderInline = (node, index) => {
|
|
1859
|
+
switch (node.type) {
|
|
1860
|
+
case "text":
|
|
1861
|
+
return /* @__PURE__ */ React.createElement(Text, { key: index }, node.value);
|
|
1862
|
+
case "bold":
|
|
1863
|
+
return /* @__PURE__ */ React.createElement(Text, { key: index, bold: true }, renderInlines2(node.children));
|
|
1864
|
+
case "italic":
|
|
1865
|
+
return /* @__PURE__ */ React.createElement(Text, { key: index, italic: true }, renderInlines2(node.children));
|
|
1866
|
+
case "code":
|
|
1867
|
+
return /* @__PURE__ */ React.createElement(Text, { key: index, color: "cyan" }, node.value);
|
|
1868
|
+
case "link":
|
|
1869
|
+
return /* @__PURE__ */ React.createElement(Text, { key: index }, /* @__PURE__ */ React.createElement(Text, { color: "cyan" }, node.text), node.href ? /* @__PURE__ */ React.createElement(Text, { dimColor: true }, " ", node.href) : null);
|
|
1870
|
+
}
|
|
1871
|
+
};
|
|
1872
|
+
var renderListItem = (item, index, ordered) => /* @__PURE__ */ React.createElement(Box, { key: index, width: "100%" }, /* @__PURE__ */ React.createElement(Text, { dimColor: true }, ordered ? `${index + 1}. ` : "\u2022 "), /* @__PURE__ */ React.createElement(Text, { wrap: "wrap" }, renderInlines2(item)));
|
|
1873
|
+
var renderCodeLine = (line, index) => /* @__PURE__ */ React.createElement(Text, { key: index, color: "gray" }, line || " ");
|
|
1874
|
+
var renderBlock2 = (block, index) => {
|
|
1875
|
+
switch (block.type) {
|
|
1876
|
+
case "heading":
|
|
1877
|
+
return /* @__PURE__ */ React.createElement(Box, { key: index, width: "100%", marginBottom: 1 }, /* @__PURE__ */ React.createElement(Text, { bold: true, color: "cyan", wrap: "wrap" }, renderInlines2(block.children)));
|
|
1878
|
+
case "paragraph":
|
|
1879
|
+
return /* @__PURE__ */ React.createElement(Box, { key: index, width: "100%", marginBottom: 1 }, /* @__PURE__ */ React.createElement(Text, { wrap: "wrap" }, renderInlines2(block.children)));
|
|
1880
|
+
case "list":
|
|
1881
|
+
return /* @__PURE__ */ React.createElement(Box, { key: index, flexDirection: "column", width: "100%", marginBottom: 1 }, block.items.map((item, itemIndex) => renderListItem(item, itemIndex, block.ordered)));
|
|
1882
|
+
case "code":
|
|
1883
|
+
return /* @__PURE__ */ React.createElement(Box, { key: index, flexDirection: "column", width: "100%", marginBottom: 1 }, block.lang ? /* @__PURE__ */ React.createElement(Text, { dimColor: true }, block.lang) : null, block.value.split("\n").map((line, lineIndex) => renderCodeLine(line, lineIndex)));
|
|
1884
|
+
}
|
|
1885
|
+
};
|
|
1886
|
+
var MarkdownView = ({ source }) => {
|
|
1887
|
+
const blocks = parseMarkdown(source);
|
|
1888
|
+
if (blocks.length === 0) {
|
|
1889
|
+
return /* @__PURE__ */ React.createElement(Text, { wrap: "wrap" }, source);
|
|
1890
|
+
}
|
|
1891
|
+
return /* @__PURE__ */ React.createElement(Box, { flexDirection: "column", width: "100%" }, blocks.map((block, index) => renderBlock2(block, index)));
|
|
1892
|
+
};
|
|
1893
|
+
|
|
1894
|
+
// src/utils/markdown.ts
|
|
1654
1895
|
import chalk3 from "chalk";
|
|
1896
|
+
var ansiPaint = {
|
|
1897
|
+
heading: (text) => theme.accentBold(text),
|
|
1898
|
+
bold: (text) => chalk3.bold(text),
|
|
1899
|
+
italic: (text) => chalk3.italic(text),
|
|
1900
|
+
code: (text) => theme.accent(text),
|
|
1901
|
+
linkText: (text) => theme.link(text),
|
|
1902
|
+
href: (text) => theme.inkMuted(text),
|
|
1903
|
+
marker: (text) => theme.inkMuted(text),
|
|
1904
|
+
codeLine: (text) => theme.inkSoft(text)
|
|
1905
|
+
};
|
|
1906
|
+
var renderMarkdownAnsi = (source, options = {}) => formatMarkdown(source, { indent: options.indent, paint: ansiPaint });
|
|
1907
|
+
var printMarkdownAnsi = (source, options = {}) => {
|
|
1908
|
+
const text = renderMarkdownAnsi(source, options);
|
|
1909
|
+
if (!text) return;
|
|
1910
|
+
console.log(text);
|
|
1911
|
+
};
|
|
1655
1912
|
|
|
1656
1913
|
// src/utils/os-agent-api.ts
|
|
1657
1914
|
import { mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
@@ -1811,22 +2068,36 @@ function parseFrame(frame) {
|
|
|
1811
2068
|
}
|
|
1812
2069
|
|
|
1813
2070
|
// src/commands/chat.tsx
|
|
2071
|
+
var writeHumanMarkdown = (source) => {
|
|
2072
|
+
const rendered = renderMarkdownAnsi(source);
|
|
2073
|
+
if (!rendered) return;
|
|
2074
|
+
process.stdout.write(rendered);
|
|
2075
|
+
if (!rendered.endsWith("\n")) process.stdout.write("\n");
|
|
2076
|
+
};
|
|
1814
2077
|
async function chatSync(message, json = false, sessionId) {
|
|
1815
2078
|
try {
|
|
1816
|
-
let
|
|
2079
|
+
let pending = "";
|
|
2080
|
+
let wrote = false;
|
|
2081
|
+
const flushPending = () => {
|
|
2082
|
+
if (!pending) return;
|
|
2083
|
+
if (!json) {
|
|
2084
|
+
writeHumanMarkdown(pending);
|
|
2085
|
+
wrote = true;
|
|
2086
|
+
}
|
|
2087
|
+
pending = "";
|
|
2088
|
+
};
|
|
1817
2089
|
const result = await runAgentChat({
|
|
1818
2090
|
message,
|
|
1819
2091
|
sessionId,
|
|
1820
2092
|
onEvent: (event) => {
|
|
1821
2093
|
if (json) return;
|
|
1822
2094
|
if (event.type === "delta") {
|
|
1823
|
-
|
|
1824
|
-
process.stdout.write(event.text);
|
|
2095
|
+
pending += event.text;
|
|
1825
2096
|
} else if (event.type === "tool") {
|
|
1826
|
-
|
|
1827
|
-
process.stdout.write(`${
|
|
2097
|
+
flushPending();
|
|
2098
|
+
process.stdout.write(`${chalk4.dim("\u26A1")} ${chalk4.yellow(event.name)}
|
|
1828
2099
|
`);
|
|
1829
|
-
|
|
2100
|
+
wrote = true;
|
|
1830
2101
|
}
|
|
1831
2102
|
}
|
|
1832
2103
|
});
|
|
@@ -1841,32 +2112,32 @@ async function chatSync(message, json = false, sessionId) {
|
|
|
1841
2112
|
}, null, 2));
|
|
1842
2113
|
return;
|
|
1843
2114
|
}
|
|
1844
|
-
|
|
1845
|
-
if (!
|
|
1846
|
-
else if (!
|
|
2115
|
+
flushPending();
|
|
2116
|
+
if (!wrote && !result.response.trim()) console.log(chalk4.dim("(\u5BF9\u65B9\u6C89\u9ED8\u4E86)"));
|
|
2117
|
+
else if (!wrote) writeHumanMarkdown(result.response);
|
|
1847
2118
|
if (result.sessionId && result.sessionId !== sessionId) {
|
|
1848
2119
|
console.log();
|
|
1849
|
-
console.log(
|
|
1850
|
-
console.log(
|
|
2120
|
+
console.log(chalk4.dim(`Session: ${chalk4.cyan(result.sessionId)}`));
|
|
2121
|
+
console.log(chalk4.dim("\u4F7F\u7528 --session-id \u7EE7\u7EED\u5BF9\u8BDD"));
|
|
1851
2122
|
}
|
|
1852
2123
|
} catch (err) {
|
|
1853
2124
|
if (json) {
|
|
1854
2125
|
console.error(JSON.stringify({ tool: "maidang", command: "chat", error: err.message }, null, 2));
|
|
1855
2126
|
process.exit(1);
|
|
1856
2127
|
} else {
|
|
1857
|
-
console.error(
|
|
2128
|
+
console.error(chalk4.red(`Error: ${err.message}`));
|
|
1858
2129
|
process.exit(1);
|
|
1859
2130
|
}
|
|
1860
2131
|
}
|
|
1861
2132
|
}
|
|
1862
2133
|
var _id = 0;
|
|
1863
2134
|
var uid = () => ++_id;
|
|
1864
|
-
var ItemUser = ({ content }) => /* @__PURE__ */
|
|
1865
|
-
var ItemThinking = ({ content, expanded }) => /* @__PURE__ */
|
|
1866
|
-
var ItemLoading = () => /* @__PURE__ */
|
|
1867
|
-
var ItemTool = ({ content }) => /* @__PURE__ */
|
|
1868
|
-
var ItemContent = ({ content }) => /* @__PURE__ */
|
|
1869
|
-
var ItemError = ({ content }) => /* @__PURE__ */
|
|
2135
|
+
var ItemUser = ({ content }) => /* @__PURE__ */ React2.createElement(Box2, { width: "100%", marginBottom: 1 }, /* @__PURE__ */ React2.createElement(Box2, { width: "100%", backgroundColor: "cyan", paddingX: 1, paddingY: 0 }, /* @__PURE__ */ React2.createElement(Text2, { color: "black", wrap: "wrap" }, content)));
|
|
2136
|
+
var ItemThinking = ({ content, expanded }) => /* @__PURE__ */ React2.createElement(Box2, { flexDirection: "column", width: "100%", marginBottom: 1 }, /* @__PURE__ */ React2.createElement(Text2, { dimColor: true }, "\u601D\u8003"), expanded && /* @__PURE__ */ React2.createElement(Box2, { width: "100%", borderStyle: "round", borderColor: "gray", paddingX: 1, paddingY: 0, marginTop: 0 }, /* @__PURE__ */ React2.createElement(Text2, { dimColor: true, wrap: "wrap" }, content)));
|
|
2137
|
+
var ItemLoading = () => /* @__PURE__ */ React2.createElement(Box2, { width: "100%", marginBottom: 1 }, /* @__PURE__ */ React2.createElement(Text2, { dimColor: true }, "\u601D\u8003\u4E2D..."));
|
|
2138
|
+
var ItemTool = ({ content }) => /* @__PURE__ */ React2.createElement(Box2, { flexDirection: "column", width: "100%", marginBottom: 1 }, /* @__PURE__ */ React2.createElement(Text2, { color: "yellow" }, "\u26A1"), /* @__PURE__ */ React2.createElement(Box2, { width: "100%", borderStyle: "round", borderColor: "yellow", paddingX: 1, paddingY: 0, marginTop: 0 }, /* @__PURE__ */ React2.createElement(Text2, { color: "yellow", wrap: "wrap" }, content)));
|
|
2139
|
+
var ItemContent = ({ content }) => /* @__PURE__ */ React2.createElement(Box2, { width: "100%", marginBottom: 1 }, /* @__PURE__ */ React2.createElement(MarkdownView, { source: content }));
|
|
2140
|
+
var ItemError = ({ content }) => /* @__PURE__ */ React2.createElement(Box2, { width: "100%", marginBottom: 1 }, /* @__PURE__ */ React2.createElement(Text2, { color: "red" }, content));
|
|
1870
2141
|
var DOUBLE_PRESS_WINDOW = 1e3;
|
|
1871
2142
|
var ChatApp = ({ sessionId: initialSessionId }) => {
|
|
1872
2143
|
const [items, setItems] = useState([]);
|
|
@@ -2023,24 +2294,24 @@ var ChatApp = ({ sessionId: initialSessionId }) => {
|
|
|
2023
2294
|
const cursorChar = input[cursorPos] ?? " ";
|
|
2024
2295
|
const after = input.slice(cursorPos + 1);
|
|
2025
2296
|
const fw = isFullWidth(cursorChar) ? 2 : 1;
|
|
2026
|
-
return /* @__PURE__ */
|
|
2297
|
+
return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(Text2, { color: "cyan" }, "> "), /* @__PURE__ */ React2.createElement(Text2, null, before), /* @__PURE__ */ React2.createElement(Text2, { backgroundColor: "gray", color: "black" }, cursorChar, fw === 2 ? " " : ""), /* @__PURE__ */ React2.createElement(Text2, null, after), loading && /* @__PURE__ */ React2.createElement(Text2, { dimColor: true }, " "));
|
|
2027
2298
|
};
|
|
2028
|
-
return /* @__PURE__ */
|
|
2299
|
+
return /* @__PURE__ */ React2.createElement(Box2, { flexDirection: "column", paddingX: 1, flexGrow: 1 }, /* @__PURE__ */ React2.createElement(Box2, { flexDirection: "column", flexGrow: 1 }, items.map((item) => {
|
|
2029
2300
|
switch (item.type) {
|
|
2030
2301
|
case "user":
|
|
2031
|
-
return /* @__PURE__ */
|
|
2302
|
+
return /* @__PURE__ */ React2.createElement(ItemUser, { key: item.id, content: item.content });
|
|
2032
2303
|
case "thinking":
|
|
2033
|
-
return /* @__PURE__ */
|
|
2304
|
+
return /* @__PURE__ */ React2.createElement(ItemThinking, { key: item.id, content: item.content, expanded: showThinking });
|
|
2034
2305
|
case "loading":
|
|
2035
|
-
return /* @__PURE__ */
|
|
2306
|
+
return /* @__PURE__ */ React2.createElement(ItemLoading, { key: item.id });
|
|
2036
2307
|
case "tool":
|
|
2037
|
-
return /* @__PURE__ */
|
|
2308
|
+
return /* @__PURE__ */ React2.createElement(ItemTool, { key: item.id, content: item.content });
|
|
2038
2309
|
case "content":
|
|
2039
|
-
return /* @__PURE__ */
|
|
2310
|
+
return /* @__PURE__ */ React2.createElement(ItemContent, { key: item.id, content: item.content });
|
|
2040
2311
|
case "error":
|
|
2041
|
-
return /* @__PURE__ */
|
|
2312
|
+
return /* @__PURE__ */ React2.createElement(ItemError, { key: item.id, content: item.content });
|
|
2042
2313
|
}
|
|
2043
|
-
})), /* @__PURE__ */
|
|
2314
|
+
})), /* @__PURE__ */ React2.createElement(Box2, { flexDirection: "column", flexShrink: 0 }, /* @__PURE__ */ React2.createElement(Box2, { borderStyle: "single", borderColor: "gray", paddingX: 1 }, renderInputLine()), /* @__PURE__ */ React2.createElement(Box2, { paddingTop: 1 }, /* @__PURE__ */ React2.createElement(Text2, { dimColor: true }, "Ctrl+C \u9000\u51FA \xB7 Enter \u53D1\u9001 \xB7 Esc Esc \u6E05\u7A7A\u8F93\u5165 \xB7 \u2190\u2192 \u79FB\u52A8\u5149\u6807")), hint && /* @__PURE__ */ React2.createElement(Box2, { paddingTop: 0 }, /* @__PURE__ */ React2.createElement(Text2, { dimColor: true, color: "yellow" }, hint)), !loading && items.some((i) => i.type === "thinking") && !showThinking && /* @__PURE__ */ React2.createElement(Box2, { paddingTop: 0 }, /* @__PURE__ */ React2.createElement(Text2, { dimColor: true, color: "cyan" }, "Ctrl+O \u67E5\u770B\u601D\u8003"))), /* @__PURE__ */ React2.createElement(Box2, { ref: bottomRef }));
|
|
2044
2315
|
};
|
|
2045
2316
|
function createChatCommand() {
|
|
2046
2317
|
const cmd = new Command12("chat").description("\u548C\u9EA6\u5F53\u5BF9\u8BDD\uFF08-m \u5355\u8F6E\u6D88\u606F\uFF0C--session-id \u7EED\u63A5\u5BF9\u8BDD\uFF09").option("-m, --message <text>", "\u76F4\u63A5\u53D1\u9001\u6D88\u606F\uFF08\u975E\u4EA4\u4E92\u6A21\u5F0F\uFF09").option("--json", "\u8F93\u51FA JSON \u683C\u5F0F").option("--session-id <id>", "\u7EED\u63A5\u5DF2\u6709\u5BF9\u8BDD");
|
|
@@ -2057,7 +2328,7 @@ function createChatCommand() {
|
|
|
2057
2328
|
await chatSync(opts.message, !!opts.json, opts.sessionId);
|
|
2058
2329
|
return;
|
|
2059
2330
|
}
|
|
2060
|
-
render(/* @__PURE__ */
|
|
2331
|
+
render(/* @__PURE__ */ React2.createElement(ChatApp, { sessionId: opts.sessionId }));
|
|
2061
2332
|
});
|
|
2062
2333
|
return cmd;
|
|
2063
2334
|
}
|
|
@@ -2180,7 +2451,7 @@ function printIssue(issue) {
|
|
|
2180
2451
|
console.log(" " + hairline());
|
|
2181
2452
|
console.log("");
|
|
2182
2453
|
if (issue.headline) {
|
|
2183
|
-
console.log(" " + theme.inkBody(
|
|
2454
|
+
console.log(" " + theme.inkBody("\u5934\u6761\uFF1A") + renderMarkdownAnsi(issue.headline).trimEnd());
|
|
2184
2455
|
console.log("");
|
|
2185
2456
|
}
|
|
2186
2457
|
let lastSection = "";
|
|
@@ -2190,10 +2461,12 @@ function printIssue(issue) {
|
|
|
2190
2461
|
console.log(" " + theme.accent(`\u25CF ${item.section}`));
|
|
2191
2462
|
lastSection = item.section;
|
|
2192
2463
|
}
|
|
2193
|
-
console.log(` ${theme.inkMuted(String(item.rank).padStart(2, "0"))} ${
|
|
2194
|
-
if (item.summary)
|
|
2464
|
+
console.log(` ${theme.inkMuted(String(item.rank).padStart(2, "0"))} ${renderMarkdownAnsi(item.title).trimEnd()}`);
|
|
2465
|
+
if (item.summary) printMarkdownAnsi(item.summary, { indent: " " });
|
|
2195
2466
|
if (item.ordinaryExplanation) {
|
|
2196
|
-
|
|
2467
|
+
const explanation = renderMarkdownAnsi(item.ordinaryExplanation).split("\n");
|
|
2468
|
+
console.log(` ${theme.inkMuted("\u548C\u4F60\u6709\u4EC0\u4E48\u5173\u7CFB\uFF1A")}${explanation[0] ?? ""}`);
|
|
2469
|
+
explanation.slice(1).forEach((line) => console.log(` ${line}`));
|
|
2197
2470
|
}
|
|
2198
2471
|
});
|
|
2199
2472
|
console.log("");
|
|
@@ -2209,7 +2482,7 @@ function printIssueList(issues) {
|
|
|
2209
2482
|
console.log("");
|
|
2210
2483
|
issues.forEach((issue, index) => {
|
|
2211
2484
|
console.log(` ${theme.inkMuted(String(index + 1).padStart(2, "0"))} ${theme.inkBody(`${issue.issueDate.slice(0, 10)} \xB7 \u7B2C ${issue.issueNumber} \u671F`)}`);
|
|
2212
|
-
if (issue.headline)
|
|
2485
|
+
if (issue.headline) printMarkdownAnsi(issue.headline, { indent: " " });
|
|
2213
2486
|
});
|
|
2214
2487
|
console.log("");
|
|
2215
2488
|
}
|