Fantasy Development Guide
Commands
- Build:
go build ./... - Test all:
task testorgo test ./... -count=1 -timeout=30m - Test single:
go test -run TestName ./package -v - Lint:
task lintorgolangci-lint run - Lint fix:
task lint:fix - Format:
task fmt(usesgofumpt, notgofmt)
Style Notes
- Prefer
cmp.Orfor defaults - Struct tags
json,description,enumdrive schema generation charm.land/x/vcrfor HTTP test recording (not go-vcr)
Project Layout
/— Core packagefantasy: Provider, LanguageModel, Agent, Content, Tool, errors, retry/providers/{openai,anthropic,google,bedrock,azure,openrouter,openaicompat,vercel,kronk}/object— Typed structured outputs:object.Generate[T],object.Stream[T]/schema,/jsonrepair— JSON schema generation and repair utilities/providertests— Integration tests with VCR cassettes intestdata/
Testing
- Env vars:
FANTASY_<PROVIDER>_API_KEY, loaded from.envvia godotenv - VCR recorder injected as
http.Clienttransport