|
| 1 | +# Contributing to gitagent |
| 2 | + |
| 3 | +Thanks for helping. This guide covers gitagent 2, the Rust binary on this branch. |
| 4 | + |
| 5 | +## Getting started |
| 6 | + |
| 7 | +1. Fork the repository and clone your fork: |
| 8 | + ```sh |
| 9 | + git clone https://github.com/<your-username>/gitagent.git |
| 10 | + cd gitagent |
| 11 | + ``` |
| 12 | +2. Install Rust. The toolchain is pinned in `rust-toolchain.toml`, so `rustup` picks the right version on its own. |
| 13 | +3. Build and test: |
| 14 | + ```sh |
| 15 | + cargo build |
| 16 | + cargo test --workspace |
| 17 | + ``` |
| 18 | + |
| 19 | +The tests need no network and no API keys. A scripted provider replays model replies from YAML (`--model scripted:<file>`), and the provider adapters are tested against local mock servers. To try a change by hand: |
| 20 | + |
| 21 | +```sh |
| 22 | +cargo run -p gitagent-cli -- -d path/to/agent -m scripted:path/to/script.yaml |
| 23 | +``` |
| 24 | + |
| 25 | +## Before you open a pull request |
| 26 | + |
| 27 | +Run all four; CI runs the same: |
| 28 | + |
| 29 | +```sh |
| 30 | +cargo fmt --all |
| 31 | +cargo clippy --workspace --all-targets -- -D warnings |
| 32 | +cargo test --workspace |
| 33 | +bash scripts/integrity-audit.sh |
| 34 | +``` |
| 35 | + |
| 36 | +- **The benchmark guard must pass.** `bench_prompt_and_tools_match_the_published_run` fails if the system prompt or the tool list sent to the model in `--bench` mode changes at all. Features for agent folders, the console or the SDKs must never reach benchmark mode. If a change to the benchmark setup is intended, say so in the pull request; it needs a measured run before it is merged. |
| 37 | +- **Behaviour that changes results is a profile switch.** Add it to `profiles/*.yaml`, off by default, and describe it in `docs/HOW-IT-WORKS.md`. |
| 38 | +- **Agents written for gitagent 1.x must keep working.** Tool names, hook scripts, `agent.yaml` fields and SDK options from 1.x are accepted; if you change how one is read, keep the 1.x form working and cover it with a test. |
| 39 | + |
| 40 | +## Project structure |
| 41 | + |
| 42 | +The workspace is split into crates under `crates/`: |
| 43 | + |
| 44 | +| Crate | What it does | |
| 45 | +|---|---| |
| 46 | +| `cli` | The `gitagent` binary: flags, the console, the IPC protocol, subcommands (`init`, `validate`, `install`, `plugin`, `schedule`, `learn`) | |
| 47 | +| `core` | The agent loop, sub-agents, the `plan` tool, workflows, approvals and the audit log | |
| 48 | +| `loader` | Reads agent folders and configuration into one spec: `agent.yaml`, identity files, skills, tools, hooks, memory, knowledge, workflows, schedules, plugins, environments, compliance | |
| 49 | +| `provider` | Model adapters: Anthropic, OpenAI, Google, OpenAI-compatible, and the scripted provider for tests | |
| 50 | +| `tools` | Built-in tools: shell, files, edits, memory, skills | |
| 51 | +| `terminal` | Persistent shells on a pseudo-terminal | |
| 52 | +| `shaper` | Shapes command output before the model sees it | |
| 53 | +| `context` | Masking and compaction of the conversation | |
| 54 | +| `guards` | The stop check, the time budget and the loop detector | |
| 55 | +| `hooks` | Hook scripts and their protocol | |
| 56 | +| `mcp` | The Model Context Protocol client | |
| 57 | +| `record` | Trajectories, counters and events | |
| 58 | +| `repo` | Repo mode: clones, branches, commits, pushes | |
| 59 | +| `sandbox` | Landlock and seccomp for the agent's shell | |
| 60 | +| `learn` | Offline learning of lessons from finished runs | |
| 61 | +| `sdk` | The Rust library interface | |
| 62 | + |
| 63 | +The Python and TypeScript clients live under `clients/` and talk to the binary over the IPC protocol (`gitagent --ipc`). |
| 64 | + |
| 65 | +## Guidelines |
| 66 | + |
| 67 | +- **No unsafe code.** The workspace forbids it. |
| 68 | +- **Small dependencies.** Prefer a few lines of code to a new crate. |
| 69 | +- **Test what you change.** Unit tests next to the code, end-to-end tests in `crates/cli/tests/`. |
| 70 | +- **One concern per pull request.** Keep it focused and reviewable. |
| 71 | +- **Write docs in plain language.** Short sentences, one idea each. |
| 72 | + |
| 73 | +## Commit messages |
| 74 | + |
| 75 | +A short subject saying what changed, then a body saying why when it is not obvious: |
| 76 | + |
| 77 | +- `Parallel tasks: the plan tool and a live task board` |
| 78 | +- `Hooks that crash are a warning, as in 1.x` |
| 79 | +- `Repo mode reuses an earlier clone of the same repository` |
| 80 | + |
| 81 | +## Reporting issues |
| 82 | + |
| 83 | +Search the existing issues first. Include what you ran, what you expected, what happened, `gitagent --version`, and your operating system. A trajectory (`trajectory.json` from the run's output folder) helps most. |
| 84 | + |
| 85 | +## License |
| 86 | + |
| 87 | +By contributing, you agree that your contributions are licensed under the [MIT License](./LICENSE). |
0 commit comments