How uliboooo/ghost_git_writer works
Project type and purpose
• This is a Rust-based command-line application (“ghost writer” / ggw) that invokes large-language-model APIs (OpenAI, Anthropic, Gemini, Deepseek) to automate tasks around Git: generating commit messages, summarizing diffs, producing README drafts, and suggesting semantic-version bumps.
File structure
• Top-level files:
• Cargo.toml / Cargo.lock (Rust package manifest)
• config_template.toml, reference/… (documentation and sample config)
• CI workflow: .github/workflows/rust.yml
• CLI executable entry point: src/main.rs
• Core modules in src/:
• cli.rs, cli_helper.rs → parse arguments, dispatch subcommands
• config.rs → load and validate configuration from file / env vars
• git.rs, get_input.rs → shell out to Git or read diffs from stdin
• commit_gen.rs, diff_sum_gen.rs, readme_gen.rs, which_sem.rs → orchestrate LLM prompt assembly and post-processing
• llm.rs → HTTP client that routes requests to the selected LLM provider
• helper.rs → shared utilities
README for additional insights
• Highlights four primary subcommands: commit, readme, sumdiff, which-sem.
• Emphasizes environment variables for API keys, global options (model, path, language, extra prompt, config file), and per-command flags.
a. Main components
• CLI Frontend
• Configuration Loader
• Git Interface & Diff Reader
• Source Scanner (for README generation)
• Task Orchestrators (CommitGen, ReadDiffGen, ReadmeGen, SemVerGen)
• LLM Client
• External LLM Services (Gemini, OpenAI, Anthropic, Deepseek)
• Output Handler (console, write files, git commit)
b. Relationships and data flow
1. User invokes ggw <subcommand> [options] → CLI Frontend
2. CLI Frontend calls Configuration Loader to merge env vars, config file, and CLI flags
3. Depending on subcommand:
• For commit and sumdiff: Git Interface shell-outs to git diff or reads diff from stdin
• For readme: Source Scanner walks the codebase or accepts explicit file lists
• For which-sem: Git Interface reads diff, passes to SemVerGen
4. The diff or source files are passed to the respective Task Orchestrator module
5. Task Orchestrator assembles a prompt and calls LLM Client
6. LLM Client issues HTTP requests to the chosen LLM provider and receives a response
7. Task Orchestrator post-processes the response
8. Output Handler prints results to stdout, optionally writes to README.md or invokes git commit
c. Architectural patterns and design principles
• Single-binary CLI structured as modular components
• Clear separation of concerns: argument parsing, config management, Git I/O, prompt generation, HTTP client, output
• Strategy pattern for LLM providers (pluggable via environment variables / flags)
• Stateless, functional tasks that transform inputs (diffs or source) into outputs (text)
d. Key technologies
• Rust and Cargo ecosystem
• clap or structopt (presumed) for CLI parsing
• reqwest or hyper for HTTP calls in llm.rs
• serde + toml for config parsing
• Standard library’s process::Command for Git interaction
Detail
• Every module from src/, even shared helper.rs, to show full separation of concerns
• How config_template.toml and environment variables feed into Config Loader