1
0

initial commit

This commit is contained in:
2026-03-04 07:59:35 +01:00
commit 3ceb0e4884
27 changed files with 2280 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
using Microsoft.Extensions.AI;
using Spectre.Console;
namespace AnchorCli.Commands;
internal class CompactCommand(ContextCompactor compactor, List<ChatMessage> history) : ICommand
{
public string Name => "compact";
public string Description => "Manually compact conversation history via LLM summarization";
public async Task ExecuteAsync(string[] args, CancellationToken ct)
{
if (history.Count < 5)
{
AnsiConsole.MarkupLine("[dim grey]Nothing to compact (too few messages).[/]");
return;
}
AnsiConsole.MarkupLine("[yellow]⚠ Manually compacting conversation history...[/]");
bool compacted = await AnsiConsole.Status()
.Spinner(Spinner.Known.BouncingBar)
.SpinnerStyle(Style.Parse("yellow"))
.StartAsync("Compacting context...", async ctx =>
await compactor.TryCompactAsync(history, ct));
if (compacted)
{
AnsiConsole.MarkupLine(
$"[green]✓ Context compacted ({history.Count} messages remaining)[/]");
}
else
{
AnsiConsole.MarkupLine(
"[dim grey] (compaction skipped — not enough history to compress)[/]");
}
}
}