2.9 KiB
2.9 KiB
Improvements for AnchorCli
This document contains criticisms and suggestions for improving the AnchorCli project.
Architecture
- Program.cs is too large (433 lines) - Split into smaller classes: ChatSession, ReplLoop, ResponseStreamer
- No dependency injection - Use Microsoft.Extensions.DependencyInjection for testability
- Static tool classes with global Log delegates - Convert to instance classes with injected ILogger
Testing
- No unit tests - Add xUnit project, test HashlineEncoder/Validator, tools, and ContextCompactor
- No integration tests - Use Spectre.Console.Testing for TUI workflows
- No CI/CD - Add GitHub Actions for test runs on push/PR
Documentation
- Missing XML docs - Add summary docs to public APIs
- Incomplete README - Add contributing, development, troubleshooting sections
- No CHANGELOG.md - Track releases and changes
Security & Safety
- Command execution unsandboxed - Add allowlist/denylist, time limits, output size limits
- No mutation rate limiting - Track edits per turn, add configurable limits
- API key in plain text - Use OS keychain or env var, set restrictive file permissions
Performance
- No file read caching - Cache file content per-turn with invalidation on write
- Regex not static - Make compiled regexes static readonly
User Experience
- No undo - Store edit history, add /undo command
- No session persistence - Add /save and /load commands
- Limited error recovery - Better error messages, /debug mode
Developer Experience
- No .editorconfig - Add code style enforcement
- No solution file - Create AnchorCli.sln
- Hardcoded model list - Fetch from OpenRouter API dynamically
- No version info - Add to .csproj, display in /help
Code Quality
- Inconsistent error handling - Standardize on error strings, avoid empty catch blocks
- Magic numbers - Extract to named constants (150_000, 300, KeepRecentTurns=2)
- Commented-out debug code - Remove or use #if DEBUG
- Weak hash algorithm - Adler-8 XOR only has 256 values; consider 4-char hex
Build & Dependencies
- 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.