♻️ refactor: flatten packages, split large files, improve structure#43
♻️ refactor: flatten packages, split large files, improve structure#43
Conversation
- Move all CLI commands from root to cmd/anna/ following Go standard layout - Extract config types and loading logic into dedicated config/ package - Split monolithic main.go into focused command files: - main.go: minimal entry point - commands.go: app setup and factories - chat.go, gateway.go, models.go, skills.go, version.go, onboard.go - Update mise.toml and .goreleaser.yaml build paths - Maintain all existing functionality and tests
…sform to root - Move ai/types/*.go → ai/*.go (Message, Model, Events, Options) - Merge ai/registry/ + ai/stream/ → ai/provider.go - Move ai/transform/ → ai/transform.go - Delete ai/types/, ai/registry/, ai/stream/, ai/transform/ subpackages - Update all imports: ai/types → ai, ai/stream → ai, ai/registry → ai - Providers now import "github.com/vaayne/anna/ai" directly
- pool_options.go: PoolOption, ChatOption, all With* funcs - pool_reaper.go: StartReaper, reap (idle/dead runner cleanup) - pool_compaction.go: CompactSession, NeedsCompaction, compaction prompt - pool.go: Pool struct, session CRUD, Chat, runner lifecycle, persistence
- chat_view.go: View(), resize(), renderMarkdown(), refreshViewport() - chat_input.go: handleInput(), waitNextChunk(), updateCompletions() - chat_picker.go: handlePickingKey(), currentModelIndex() - chat.go: types, chatModel struct, newChatModel, Init(), Update()
- Move agent/store/ → store/ - Update imports in agent/, cmd/anna/ - Store is a cross-cutting concern, not agent-specific
- service.go: Service struct, scheduling, job CRUD - persistence.go: JSON file I/O (loadJobs, saveJobsLocked) - Delete monolithic cron.go
- architecture.md: new package layout, ai/ flattening, store/ extraction, pool/cron/chat splits, updated provider interface references - README.md: updated package tree to match new structure - CLAUDE.md: updated package flow description - session-compaction.md: pool_compaction.go + store/ paths - cron-system.md: service.go + persistence.go split
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dd1bd659db
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| builds: | ||
| - id: anna | ||
| main: . | ||
| main: ./cmd/anna |
There was a problem hiding this comment.
Update container build target after moving main package
After switching the release build entrypoint to ./cmd/anna, the repo root no longer has the CLI main package, but the Docker build still compiles . (Dockerfile:12 uses go build ... .). In any environment that builds the container image, this refactor causes the image build to fail because the root package is no longer runnable; please update Docker (and any other root-target builds) to compile ./cmd/anna as well.
Useful? React with 👍 / 👎.
The refactor moved main.go into cmd/anna/, but the Dockerfile still built from the root directory, causing "no Go files" build failures.
- ai/provider_test.go: Registry, ChannelEventStream, Stream, Complete - config/config_test.go: CronEnabled, channel IsEnabled/IsNotifyEnabled, modelConfigToType, HeartbeatConfig.FilePath absolute path - channel/notifier_test.go: NotifyTool definition and execute paths - memory/memory_test.go: MemoryTool update/append/search/unknown action
Adds coverage for NeedsCompaction edge cases (no store, disabled, under threshold) plus pool Close idempotency, empty History, and concurrent Chat to provide coverage buffer above 50% CI threshold.
📊 Coverage ReportTotal coverage: 50.0% Per-package breakdown |
Summary
Major codebase reorganization following the refactor plan in
.context/REFACTOR_PLAN.md. All changes are structural — no behavior changes.ai/package — Movedai/types/,ai/registry/,ai/stream/,ai/transform/toai/root. Importai.Messageinstead ofai/types.Message. Deleted 4 subpackages.agent/pool.go(776 lines) — Intopool.go,pool_options.go,pool_reaper.go,pool_compaction.gowith single responsibilities.channel/cli/chat.go(701 lines) — Intochat.go,chat_view.go,chat_input.go,chat_picker.go.store/— Movedagent/store/to top-levelstore/package (cross-cutting concern).cron/cron.go— Intoservice.go(scheduling) andpersistence.go(JSON I/O).architecture.md,README.md,CLAUDE.md,session-compaction.md,cron-system.md.Also includes the prior commit reorganizing CLI into
cmd/anna/andconfig/packages.Test plan
mise run buildpassesmise run testpasses with-racemise run lintreports 0 issuesai/types,ai/stream,ai/registry,ai/transform,agent/store)anna chatworks end-to-endanna gatewaystarts correctly