Git-AI is organized around feature boundaries instead of dumping command, provider, and UI logic into single files. Keep new work close to the responsibility it changes.
src/main.rsowns CLI dispatch and top-level error presentation.src/cli/owns user-facing commands and interactive flows.src/config/owns persisted configuration, provider defaults, config paths, and config schema.src/services/owns provider communication and response parsing.src/theme/owns terminal palettes, dark/light detection, and output styling.src/utils/owns small cross-cutting helpers such as Git, HTTP transport, cleanup, environment loading, and compatibility re-exports.
src/cli/review/handles target-branch reviews and fast local reviews:mod.rsorchestrates review mode selection, fetch, diff filtering, and AI invocation.branches.rsowns remote fetch handling and origin branch tree navigation.diff.rsowns numstat summaries, large/binary file detection, and exclusion prompts.limits.rsowns changed-file and changed-line threshold policy.notes.rscaptures optional task/ticket and previous-comment context.prompt.rsbuilds the AI review prompt.output.rsrenders terminal/Markdown output.
src/cli/commit.rshandles commit-message generation and commit orchestration.src/cli/list_models.rshandles the standalone model-listing command.src/cli/config/is split by workflow responsibility:mod.rsorchestrates the command.display.rsrenders current config and masked secrets.prompts.rscentralizes reusable interactive prompt helpers.provider_select.rsowns provider and commit-format selection.model_select.rsowns model discovery and manual fallback.theme_select.rsowns built-in/custom theme selection and RGB theme creation.
src/config/schema.rsdefines TOML schema types only.src/config/provider.rsdefines provider defaults, known provider names, and API-key lookup priority.src/config/paths.rsresolves config file locations.src/config/store.rsexposes theAppConfigAPI used by the rest of the app.
Provider-specific API keys intentionally take priority over AI_API_KEY so switching providers cannot silently reuse a key from another vendor.
src/services/ai/ keeps provider protocol logic isolated:
openai_compatible.rshandles OpenAI-compatible chat completions and model listing.anthropic.rshandles Anthropic messages and model listing.gemini.rshandles Gemini generateContent and model listing.ollama.rshandles local Ollama generation and tags.messages.rscontains shared message-composition helpers.
Adding a provider should usually mean adding one provider module plus a small dispatch entry in src/services/ai/mod.rs.
src/theme/palette.rsdefines RGB values, built-in palettes, and RGB parsing.src/theme/detect.rsdetects system dark/light preference.src/theme/style.rsapplies the active palette to terminal output.src/utils/colors.rsis only a compatibility re-export for older imports.
Top-level commands should return AppResult<T> and let src/main.rs render user-facing errors. Do not print raw debug structs or provider JSON bodies. Provider HTTP failures must go through AppError::user_message() so auth failures, rate limits, and server errors stay readable and sanitized.