1
0
Files
AnchorCli/IMPROVEME.md

2.9 KiB

Improvements for AnchorCli

This document contains criticisms and suggestions for improving the AnchorCli project.

Architecture

  1. Program.cs is too large (433 lines) - Split into smaller classes: ChatSession, ReplLoop, ResponseStreamer
  2. No dependency injection - Use Microsoft.Extensions.DependencyInjection for testability
  3. Static tool classes with global Log delegates - Convert to instance classes with injected ILogger

Testing

  1. No unit tests - Add xUnit project, test HashlineEncoder/Validator, tools, and ContextCompactor
  2. No integration tests - Use Spectre.Console.Testing for TUI workflows
  3. No CI/CD - Add GitHub Actions for test runs on push/PR

Documentation

  1. Missing XML docs - Add summary docs to public APIs
  2. Incomplete README - Add contributing, development, troubleshooting sections
  3. No CHANGELOG.md - Track releases and changes

Security & Safety

  1. Command execution unsandboxed - Add allowlist/denylist, time limits, output size limits
  2. No mutation rate limiting - Track edits per turn, add configurable limits
  3. API key in plain text - Use OS keychain or env var, set restrictive file permissions

Performance

  1. No file read caching - Cache file content per-turn with invalidation on write
  2. Regex not static - Make compiled regexes static readonly

User Experience

  1. No undo - Store edit history, add /undo command
  2. No session persistence - Add /save and /load commands
  3. Limited error recovery - Better error messages, /debug mode

Developer Experience

  1. No .editorconfig - Add code style enforcement
  2. No solution file - Create AnchorCli.sln
  3. Hardcoded model list - Fetch from OpenRouter API dynamically
  4. No version info - Add to .csproj, display in /help

Code Quality

  1. Inconsistent error handling - Standardize on error strings, avoid empty catch blocks
  2. Magic numbers - Extract to named constants (150_000, 300, KeepRecentTurns=2)
  3. Commented-out debug code - Remove or use #if DEBUG
  4. Weak hash algorithm - Adler-8 XOR only has 256 values; consider 4-char hex

Build & Dependencies

  1. No LICENSE file - Add MIT LICENSE file

Priority

High

  • Add unit tests
  • Implement undo functionality
  • Add mutation rate limiting
  • Refactor Program.cs
  • Add LICENSE file

Medium

  • Session persistence
  • XML documentation
  • Error handling consistency
  • .editorconfig
  • Dynamic model list

Low

  • CHANGELOG.md
  • CI/CD pipeline
  • Stronger hash algorithm
  • Code coverage reporting

Quick Wins (<1 hour each)

  • Add to .csproj
  • Create LICENSE file
  • Add .editorconfig
  • Remove commented code
  • Extract magic numbers to constants
  • Add XML docs to Hashline classes
  • Make regexes static readonly

Prioritize based on goals: safety, testability, or user experience.