Skip to content

Commit 73e7e0e

Browse files
committed
chore: 美化样式
1 parent acc4038 commit 73e7e0e

File tree

2 files changed

+38
-24
lines changed

2 files changed

+38
-24
lines changed

.claude/settings.local.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"Bash(dotnet build:*)",
5+
"Bash(export:*)",
6+
"Bash(timeout 5 dotnet run:*)",
7+
"WebSearch",
8+
"WebFetch(domain:spectreconsole.net)",
9+
"Bash(find:*)"
10+
],
11+
"deny": [],
12+
"ask": []
13+
}
14+
}

YCode.CLI/Program.cs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@
3737
}
3838
};
3939

40+
// Agent类型到图标和颜色的映射
41+
var AGENT_ICONS = new Dictionary<string, (string icon, string color)>()
42+
{
43+
["explore"] = ("🔍", "blue"),
44+
["code"] = ("💻", "green"),
45+
["plan"] = ("📋", "yellow")
46+
};
47+
4048
var SYSTEM = $"""
4149
"You are a coding agent operating INSIDE the user's repository at {WORKDIR}.\n"
4250
"Follow this loop strictly: plan briefly → use TOOLS to act directly on files/shell → report concise results.\n"
@@ -230,7 +238,7 @@
230238
? (DateTime.Now - toolStartTime.Value).TotalSeconds
231239
: 0;
232240

233-
AnsiConsole.MarkupLine($"[bold green]✓[/] [bold cyan]{currentToolName}[/] [dim]completed in {elapsed:F3}s[/]");
241+
AnsiConsole.MarkupLine($"[bold green]✓[/] [bold cyan]{currentToolName}[/] [dim]completed in {elapsed:F1}s[/]");
234242
currentToolName = null;
235243
toolStartTime = null;
236244
}
@@ -350,7 +358,11 @@ You are a {agentType} subagent operating INSIDE the user's repository at {WORKDI
350358
}).GetChatClient(model)
351359
.CreateAIAgent(sub_system, tools: sub_tools);
352360

353-
Console.WriteLine($" [{agentType}] {description}");
361+
var (icon, color) = AGENT_ICONS.TryGetValue(agentType, out var agentIcon)
362+
? agentIcon
363+
: ("🔧", "gray");
364+
365+
AnsiConsole.MarkupLine($"[dim] [/][bold {color}]{icon} [[{EscapeMarkup(agentType)}]][/] {EscapeMarkup(description)}");
354366

355367
var start = DateTime.Now;
356368

@@ -377,7 +389,7 @@ You are a {agentType} subagent operating INSIDE the user's repository at {WORKDI
377389

378390
sub_tools_use.Add(result);
379391

380-
Console.WriteLine($" [{agentType}] {description} ... {sub_tools_use.Count} tools, {DateTime.Now - start}");
392+
AnsiConsole.MarkupLine($"[dim] [/][bold {color}]{icon} [[{EscapeMarkup(agentType)}]][/] {EscapeMarkup(description)} ... [dim]{sub_tools_use.Count} tools, {(DateTime.Now - start).TotalSeconds:F1}s[/]");
381393
}
382394
break;
383395
}
@@ -391,7 +403,7 @@ You are a {agentType} subagent operating INSIDE the user's repository at {WORKDI
391403

392404
sub_messages.Add(new ChatMessage(ChatRole.Assistant, next));
393405

394-
Console.WriteLine($" [{agentType}] {description} - done ({sub_tools_use.Count} tools, {DateTime.Now - start}s)");
406+
AnsiConsole.MarkupLine($"[dim] [/][bold {color}]✓ [[{EscapeMarkup(agentType)}]][/] {EscapeMarkup(description)} - done ([dim]{sub_tools_use.Count} tools, {(DateTime.Now - start).TotalSeconds:F1}s[/])");
395407

396408
if (!String.IsNullOrWhiteSpace(next))
397409
{
@@ -541,7 +553,7 @@ void EnsureContextBlock(string text)
541553

542554
void PrettyToolLine(string kind, string title)
543555
{
544-
var body = title != null ? $"{kind}({EscapeMarkup(title)})" : kind;
556+
var body = title != null ? $"{EscapeMarkup(kind)}({EscapeMarkup(title)})" : EscapeMarkup(kind);
545557

546558
AnsiConsole.MarkupLine($"[bold magenta]⚡[/] [bold purple]{body}[/] [dim yellow]executing...[/]");
547559
}
@@ -551,28 +563,15 @@ void PrettySubLine(string text)
551563
if (string.IsNullOrEmpty(text))
552564
return;
553565

554-
// 先处理转义的换行符 \\n
566+
// 处理转义的换行符 \\n
555567
var processedText = text.Replace("\\n", "\n");
556568
var lines = processedText.Split("\n");
557569

558-
if (lines.Length <= 3)
570+
// 显示所有行
571+
foreach (var line in lines)
559572
{
560-
// 如果内容很少,直接显示
561-
foreach (var line in lines)
562-
{
563-
// 转义特殊字符,防止AnsiConsole解析错误
564-
var escapedLine = EscapeMarkup(line);
565-
AnsiConsole.MarkupLine($"[dim]┃[/] [bold white]{escapedLine}[/]");
566-
}
567-
}
568-
else
569-
{
570-
// 如果内容很多,折叠显示
571-
var escapedLine1 = EscapeMarkup(lines[0]);
572-
var escapedLine2 = EscapeMarkup(lines[1]);
573-
AnsiConsole.MarkupLine($"[dim]┃[/] [bold white]{escapedLine1}[/]");
574-
AnsiConsole.MarkupLine($"[dim]┃[/] [bold white]{escapedLine2}[/]");
575-
AnsiConsole.MarkupLine($"[dim]┃[/] [bold yellow]... and {lines.Length - 2} more lines (collapsed)[/]");
573+
var escapedLine = EscapeMarkup(line);
574+
AnsiConsole.MarkupLine($"[dim]┃[/] [bold white]{escapedLine}[/]");
576575
}
577576
}
578577

@@ -599,9 +598,10 @@ string EscapeMarkup(string text)
599598
.Replace("]", "]]");
600599
}
601600

601+
602602
void ShowToolSpinner(string toolName)
603603
{
604-
AnsiConsole.Markup($"[yellow]>[/] [dim]{toolName} executing...[/] ");
604+
AnsiConsole.Markup($"[yellow]>[/] [dim]{EscapeMarkup(toolName)} executing...[/] ");
605605
}
606606

607607
void HideToolSpinner()

0 commit comments

Comments
 (0)