maidang 29.8.3 → 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 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 日报(--list 最近 10 期,--date 指定日期)
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
@@ -1651,10 +1651,264 @@ function createWhoAmICommand() {
1651
1651
  }
1652
1652
 
1653
1653
  // src/commands/chat.tsx
1654
- import React, { useState, useRef, useEffect } from "react";
1655
- 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";
1656
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
1657
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
+ };
1658
1912
 
1659
1913
  // src/utils/os-agent-api.ts
1660
1914
  import { mkdirSync, readFileSync, writeFileSync } from "fs";
@@ -1814,22 +2068,36 @@ function parseFrame(frame) {
1814
2068
  }
1815
2069
 
1816
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
+ };
1817
2077
  async function chatSync(message, json = false, sessionId) {
1818
2078
  try {
1819
- let streamed = "";
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
+ };
1820
2089
  const result = await runAgentChat({
1821
2090
  message,
1822
2091
  sessionId,
1823
2092
  onEvent: (event) => {
1824
2093
  if (json) return;
1825
2094
  if (event.type === "delta") {
1826
- streamed += event.text;
1827
- process.stdout.write(event.text);
2095
+ pending += event.text;
1828
2096
  } else if (event.type === "tool") {
1829
- if (streamed && !streamed.endsWith("\n")) process.stdout.write("\n");
1830
- process.stdout.write(`${chalk3.dim("\u26A1")} ${chalk3.yellow(event.name)}
2097
+ flushPending();
2098
+ process.stdout.write(`${chalk4.dim("\u26A1")} ${chalk4.yellow(event.name)}
1831
2099
  `);
1832
- streamed = "";
2100
+ wrote = true;
1833
2101
  }
1834
2102
  }
1835
2103
  });
@@ -1844,32 +2112,32 @@ async function chatSync(message, json = false, sessionId) {
1844
2112
  }, null, 2));
1845
2113
  return;
1846
2114
  }
1847
- if (streamed && !streamed.endsWith("\n")) process.stdout.write("\n");
1848
- if (!streamed.trim() && !result.response.trim()) console.log(chalk3.dim("(\u5BF9\u65B9\u6C89\u9ED8\u4E86)"));
1849
- else if (!streamed.trim()) console.log(result.response);
2115
+ flushPending();
2116
+ if (!wrote && !result.response.trim()) console.log(chalk4.dim("(\u5BF9\u65B9\u6C89\u9ED8\u4E86)"));
2117
+ else if (!wrote) writeHumanMarkdown(result.response);
1850
2118
  if (result.sessionId && result.sessionId !== sessionId) {
1851
2119
  console.log();
1852
- console.log(chalk3.dim(`Session: ${chalk3.cyan(result.sessionId)}`));
1853
- console.log(chalk3.dim("\u4F7F\u7528 --session-id \u7EE7\u7EED\u5BF9\u8BDD"));
2120
+ console.log(chalk4.dim(`Session: ${chalk4.cyan(result.sessionId)}`));
2121
+ console.log(chalk4.dim("\u4F7F\u7528 --session-id \u7EE7\u7EED\u5BF9\u8BDD"));
1854
2122
  }
1855
2123
  } catch (err) {
1856
2124
  if (json) {
1857
2125
  console.error(JSON.stringify({ tool: "maidang", command: "chat", error: err.message }, null, 2));
1858
2126
  process.exit(1);
1859
2127
  } else {
1860
- console.error(chalk3.red(`Error: ${err.message}`));
2128
+ console.error(chalk4.red(`Error: ${err.message}`));
1861
2129
  process.exit(1);
1862
2130
  }
1863
2131
  }
1864
2132
  }
1865
2133
  var _id = 0;
1866
2134
  var uid = () => ++_id;
1867
- var ItemUser = ({ content }) => /* @__PURE__ */ React.createElement(Box, { width: "100%", marginBottom: 1 }, /* @__PURE__ */ React.createElement(Box, { width: "100%", backgroundColor: "cyan", paddingX: 1, paddingY: 0 }, /* @__PURE__ */ React.createElement(Text, { color: "black", wrap: "wrap" }, content)));
1868
- var ItemThinking = ({ content, expanded }) => /* @__PURE__ */ React.createElement(Box, { flexDirection: "column", width: "100%", marginBottom: 1 }, /* @__PURE__ */ React.createElement(Text, { dimColor: true }, "\u601D\u8003"), expanded && /* @__PURE__ */ React.createElement(Box, { width: "100%", borderStyle: "round", borderColor: "gray", paddingX: 1, paddingY: 0, marginTop: 0 }, /* @__PURE__ */ React.createElement(Text, { dimColor: true, wrap: "wrap" }, content)));
1869
- var ItemLoading = () => /* @__PURE__ */ React.createElement(Box, { width: "100%", marginBottom: 1 }, /* @__PURE__ */ React.createElement(Text, { dimColor: true }, "\u601D\u8003\u4E2D..."));
1870
- var ItemTool = ({ content }) => /* @__PURE__ */ React.createElement(Box, { flexDirection: "column", width: "100%", marginBottom: 1 }, /* @__PURE__ */ React.createElement(Text, { color: "yellow" }, "\u26A1"), /* @__PURE__ */ React.createElement(Box, { width: "100%", borderStyle: "round", borderColor: "yellow", paddingX: 1, paddingY: 0, marginTop: 0 }, /* @__PURE__ */ React.createElement(Text, { color: "yellow", wrap: "wrap" }, content)));
1871
- var ItemContent = ({ content }) => /* @__PURE__ */ React.createElement(Box, { width: "100%", marginBottom: 1 }, /* @__PURE__ */ React.createElement(Text, { wrap: "wrap" }, content));
1872
- var ItemError = ({ content }) => /* @__PURE__ */ React.createElement(Box, { width: "100%", marginBottom: 1 }, /* @__PURE__ */ React.createElement(Text, { color: "red" }, content));
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));
1873
2141
  var DOUBLE_PRESS_WINDOW = 1e3;
1874
2142
  var ChatApp = ({ sessionId: initialSessionId }) => {
1875
2143
  const [items, setItems] = useState([]);
@@ -2026,24 +2294,24 @@ var ChatApp = ({ sessionId: initialSessionId }) => {
2026
2294
  const cursorChar = input[cursorPos] ?? " ";
2027
2295
  const after = input.slice(cursorPos + 1);
2028
2296
  const fw = isFullWidth(cursorChar) ? 2 : 1;
2029
- return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Text, { color: "cyan" }, "> "), /* @__PURE__ */ React.createElement(Text, null, before), /* @__PURE__ */ React.createElement(Text, { backgroundColor: "gray", color: "black" }, cursorChar, fw === 2 ? " " : ""), /* @__PURE__ */ React.createElement(Text, null, after), loading && /* @__PURE__ */ React.createElement(Text, { dimColor: true }, " "));
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 }, " "));
2030
2298
  };
2031
- return /* @__PURE__ */ React.createElement(Box, { flexDirection: "column", paddingX: 1, flexGrow: 1 }, /* @__PURE__ */ React.createElement(Box, { flexDirection: "column", flexGrow: 1 }, items.map((item) => {
2299
+ return /* @__PURE__ */ React2.createElement(Box2, { flexDirection: "column", paddingX: 1, flexGrow: 1 }, /* @__PURE__ */ React2.createElement(Box2, { flexDirection: "column", flexGrow: 1 }, items.map((item) => {
2032
2300
  switch (item.type) {
2033
2301
  case "user":
2034
- return /* @__PURE__ */ React.createElement(ItemUser, { key: item.id, content: item.content });
2302
+ return /* @__PURE__ */ React2.createElement(ItemUser, { key: item.id, content: item.content });
2035
2303
  case "thinking":
2036
- return /* @__PURE__ */ React.createElement(ItemThinking, { key: item.id, content: item.content, expanded: showThinking });
2304
+ return /* @__PURE__ */ React2.createElement(ItemThinking, { key: item.id, content: item.content, expanded: showThinking });
2037
2305
  case "loading":
2038
- return /* @__PURE__ */ React.createElement(ItemLoading, { key: item.id });
2306
+ return /* @__PURE__ */ React2.createElement(ItemLoading, { key: item.id });
2039
2307
  case "tool":
2040
- return /* @__PURE__ */ React.createElement(ItemTool, { key: item.id, content: item.content });
2308
+ return /* @__PURE__ */ React2.createElement(ItemTool, { key: item.id, content: item.content });
2041
2309
  case "content":
2042
- return /* @__PURE__ */ React.createElement(ItemContent, { key: item.id, content: item.content });
2310
+ return /* @__PURE__ */ React2.createElement(ItemContent, { key: item.id, content: item.content });
2043
2311
  case "error":
2044
- return /* @__PURE__ */ React.createElement(ItemError, { key: item.id, content: item.content });
2312
+ return /* @__PURE__ */ React2.createElement(ItemError, { key: item.id, content: item.content });
2045
2313
  }
2046
- })), /* @__PURE__ */ React.createElement(Box, { flexDirection: "column", flexShrink: 0 }, /* @__PURE__ */ React.createElement(Box, { borderStyle: "single", borderColor: "gray", paddingX: 1 }, renderInputLine()), /* @__PURE__ */ React.createElement(Box, { paddingTop: 1 }, /* @__PURE__ */ React.createElement(Text, { 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__ */ React.createElement(Box, { paddingTop: 0 }, /* @__PURE__ */ React.createElement(Text, { dimColor: true, color: "yellow" }, hint)), !loading && items.some((i) => i.type === "thinking") && !showThinking && /* @__PURE__ */ React.createElement(Box, { paddingTop: 0 }, /* @__PURE__ */ React.createElement(Text, { dimColor: true, color: "cyan" }, "Ctrl+O \u67E5\u770B\u601D\u8003"))), /* @__PURE__ */ React.createElement(Box, { ref: bottomRef }));
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 }));
2047
2315
  };
2048
2316
  function createChatCommand() {
2049
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");
@@ -2060,7 +2328,7 @@ function createChatCommand() {
2060
2328
  await chatSync(opts.message, !!opts.json, opts.sessionId);
2061
2329
  return;
2062
2330
  }
2063
- render(/* @__PURE__ */ React.createElement(ChatApp, { sessionId: opts.sessionId }));
2331
+ render(/* @__PURE__ */ React2.createElement(ChatApp, { sessionId: opts.sessionId }));
2064
2332
  });
2065
2333
  return cmd;
2066
2334
  }
@@ -2183,7 +2451,7 @@ function printIssue(issue) {
2183
2451
  console.log(" " + hairline());
2184
2452
  console.log("");
2185
2453
  if (issue.headline) {
2186
- console.log(" " + theme.inkBody(`\u5934\u6761\uFF1A${issue.headline}`));
2454
+ console.log(" " + theme.inkBody("\u5934\u6761\uFF1A") + renderMarkdownAnsi(issue.headline).trimEnd());
2187
2455
  console.log("");
2188
2456
  }
2189
2457
  let lastSection = "";
@@ -2193,10 +2461,12 @@ function printIssue(issue) {
2193
2461
  console.log(" " + theme.accent(`\u25CF ${item.section}`));
2194
2462
  lastSection = item.section;
2195
2463
  }
2196
- console.log(` ${theme.inkMuted(String(item.rank).padStart(2, "0"))} ${theme.inkBody(item.title)}`);
2197
- if (item.summary) console.log(` ${theme.inkSoft(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: " " });
2198
2466
  if (item.ordinaryExplanation) {
2199
- console.log(` ${theme.inkMuted(`\u548C\u4F60\u6709\u4EC0\u4E48\u5173\u7CFB\uFF1A${item.ordinaryExplanation}`)}`);
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}`));
2200
2470
  }
2201
2471
  });
2202
2472
  console.log("");
@@ -2212,7 +2482,7 @@ function printIssueList(issues) {
2212
2482
  console.log("");
2213
2483
  issues.forEach((issue, index) => {
2214
2484
  console.log(` ${theme.inkMuted(String(index + 1).padStart(2, "0"))} ${theme.inkBody(`${issue.issueDate.slice(0, 10)} \xB7 \u7B2C ${issue.issueNumber} \u671F`)}`);
2215
- if (issue.headline) console.log(` ${theme.inkSoft(issue.headline)}`);
2485
+ if (issue.headline) printMarkdownAnsi(issue.headline, { indent: " " });
2216
2486
  });
2217
2487
  console.log("");
2218
2488
  }