This file contains high-signal context and rules for AI agents working in this repository. For more exhaustive architectural details, refer to CLAUDE.md.
- Test (Unit):
just test(runs safe tests without external dependencies) - Test (Integration):
just test-all(runs tests requiring a running Ollama model via-tags integration) - Verify:
just verify(runsfmt,tidy,test, andbuild). Always run this before completing a task. - Build:
just build(outputs binary tobin/sfai)
pkg/packages import ONLY otherpkg/packages.internal/packages import ONLYpkg/packages. Never import otherinternal/packages.cmd/is the ONLY layer allowed to import bothpkg/andinternal/to wire them together.
pkg/model: The LLM abstraction. Pure interface (Model.Query). No domain knowledge here.pkg/sfai: The application aggregator. When adding a new utility, add its interface and field to theSFaistruct here.internal/iohttp: HTTP server built onhuma v2. Endpoint validation is automatic fromInputandOutputstruct tags. No manual validation code needed for HTTP routes.- CLI IO Convention: Utilities resolve input by checking if the argument is a file path (reads lines), a raw string (single text), or empty (reads from stdin pipe). Output is JSONL.
- Adding New Utilities: To add a new capability (e.g.,
coords), define domain types inpkg/coords/, interface inpkg/sfai/sfai.go, implementation ininternal/iocoords/(which owns the system prompt), wire them together incmd/root.go, and add hooks incmd/coords.goandinternal/iohttp/coords.go. - Configuration: Uses Viper with precedence: CLI flags > Env vars (
SFAI_*) > config file > defaults. Persistent fields round-trip viaconfig.ToOptions(). Do NOT persist runtime-only config fields orHomeDir.