1
0

feat: Introduce a /reset command to clear the chat session and token tracking, and update documentation.

This commit is contained in:
2026-03-04 22:24:05 +01:00
parent d7a94436d1
commit ed897aeb01
9 changed files with 777 additions and 387 deletions

View File

@@ -22,7 +22,7 @@ This eliminates:
## Features
- **Interactive REPL**: Chat with an AI model to edit files, manage directories, and execute commands
- **Slash Commands**: `/setup`, `/help`, `/exit`, `/clear`, `/status`, `/compact`
- **Slash Commands**: `/setup`, `/help`, `/exit`, `/clear`, `/status`, `/compact`, `/reset`
- **Token Tracking**: Real-time token usage and cost per response, plus session totals
- **Model Pricing Display**: Shows current model pricing from OpenRouter in the header
- **Context Compaction**: Automatic conversation history compression when approaching context limits, including stale tool result compaction
@@ -69,7 +69,7 @@ The resulting binary is ~12 MB, has no .NET runtime dependency, and starts insta
| `/clear` | Clear the conversation history |
| `/status` | Show session token usage and cost |
| `/compact` | Manually trigger context compaction |
| `/reset` | Clear session and reset token tracker |
## Available Tools
**File Operations:**
@@ -98,31 +98,37 @@ The resulting binary is ~12 MB, has no .NET runtime dependency, and starts insta
**Command Execution:**
- `execute_command` - Run shell commands (with user approval)
## Project Structure
```
AnchorCli/
├── Program.cs # Entry point + REPL loop + AI client setup
├── AnchorConfig.cs # JSON file-based configuration (~APPDATA~\anchor\config.json)
├── ContextCompactor.cs # Conversation history compression
├── AppJsonContext.cs # Source-generated JSON context (AOT)
├── Program.cs # Entry point + CLI parsing
├── ReplLoop.cs # Main REPL loop with streaming, spinners, and cancellation
├── ChatSession.cs # AI chat client wrapper with message history
├── ToolRegistry.cs # Centralized tool registration and dispatch
├── AnchorConfig.cs # JSON file-based configuration (~APPDATA~/anchor/config.json)
├── ContextCompactor.cs # Conversation history compression
├── AppJsonContext.cs # Source-generated JSON context (AOT)
├── SetupTui.cs # Interactive setup TUI
├── Hashline/
│ ├── HashlineEncoder.cs # Adler-8 + position-seed hashing
│ ├── HashlineEncoder.cs # Adler-8 + position-seed hashing
│ └── HashlineValidator.cs # Anchor resolution + validation
├── Tools/
│ ├── FileTools.cs # read_file, grep_file, grep_recursive, find_files, get_file_info
│ ├── EditTools.cs # replace_lines, insert_after, delete_range, create/delete/rename/copy/append
│ ├── DirTools.cs # list_dir, create_dir, rename_dir, delete_dir
│ └── CommandTool.cs # execute_command
│ ├── FileTools.cs # read_file, grep_file, grep_recursive, find_files, get_file_info
│ ├── EditTools.cs # replace_lines, insert_after, delete_range, create/delete/rename/copy/append
│ ├── DirTools.cs # list_dir, create_dir, rename_dir, delete_dir
│ └── CommandTool.cs # execute_command
├── Commands/
│ ├── ExitCommand.cs # /exit command
│ ├── HelpCommand.cs # /help command
│ ├── ClearCommand.cs # /clear command
│ ├── StatusCommand.cs # /status command
── CompactCommand.cs # /compact command
├── OpenRouter/
── PricingProvider.cs # Fetch model pricing from OpenRouter
└── SetupTui.cs # Interactive setup TUI
│ ├── ICommand.cs # Command interface
│ ├── CommandRegistry.cs # Command registration
│ ├── CommandDispatcher.cs # Command dispatch logic
│ ├── ExitCommand.cs # /exit command
── HelpCommand.cs # /help command
│ ├── ClearCommand.cs # /clear command
── StatusCommand.cs # /status command
│ ├── CompactCommand.cs # /compact command
│ ├── ResetCommand.cs # /reset command
│ └── SetupCommand.cs # /setup command
└── OpenRouter/
└── PricingProvider.cs # Fetch model pricing from OpenRouter
```
## How It Works