@ww_nero/mini-cli 1.0.85 → 1.0.86

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ww_nero/mini-cli",
3
- "version": "1.0.85",
3
+ "version": "1.0.86",
4
4
  "description": "极简的 AI 命令行助手",
5
5
  "bin": {
6
6
  "mini": "bin/mini.js"
@@ -32,6 +32,8 @@
32
32
  "diff": "^5.2.0",
33
33
  "eventsource-parser": "^1.1.2",
34
34
  "gpt-tokenizer": "^2.9.0",
35
+ "marked": "^15.0.12",
36
+ "marked-terminal": "^7.3.0",
35
37
  "node-fetch": "^2.7.0",
36
38
  "openai": "^6.9.1"
37
39
  }
@@ -1,6 +1,22 @@
1
1
  const chalk = require('chalk');
2
+ const { marked } = require('marked');
3
+ const { markedTerminal } = require('marked-terminal');
2
4
  const { splitThinkContent, summarizeReasoning } = require('./think');
3
5
 
6
+ // 配置markdown终端渲染器
7
+ const renderer = markedTerminal({
8
+ heading: chalk.cyan.bold,
9
+ firstHeading: chalk.cyan.bold,
10
+ strong: chalk.bold,
11
+ em: chalk.italic,
12
+ blockquote: chalk.gray,
13
+ code: chalk.yellow,
14
+ codespan: chalk.yellow,
15
+ table: chalk.gray,
16
+ href: chalk.blue.underline
17
+ });
18
+ marked.use(renderer);
19
+
4
20
  const mergeReasoningContent = (...segments) => {
5
21
  const normalized = segments
6
22
  .map((segment) => (typeof segment === 'string' ? segment.trim() : ''))
@@ -22,7 +38,8 @@ const printAssistantContent = (text, ensureNewline) => {
22
38
  return;
23
39
  }
24
40
  ensureNewline();
25
- const output = chalk.white(text);
41
+ // 使用marked渲染markdown,生成带ANSI样式的终端输出
42
+ const output = marked(text);
26
43
  process.stdout.write(output);
27
44
  if (!text.endsWith('\n')) {
28
45
  process.stdout.write('\n');