Skip to content

Commit 7715828

Browse files
committed
ai(rules[AGENTS]) Add AGENTS.md
1 parent 1ea28dd commit 7715828

File tree

1 file changed

+129
-0
lines changed

1 file changed

+129
-0
lines changed

AGENTS.md

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# AGENTS.md
2+
3+
This file provides guidance to AI agents (including Claude Code, Cursor, and other LLM-powered tools) when working with code in this repository. The tooling and docs rely on the gp-libs ecosystem; treat gp-libs as the shared dev toolkit that underpins this project.
4+
5+
## CRITICAL REQUIREMENTS
6+
7+
### Test Success
8+
- ALL tests MUST pass for code to be considered complete and working
9+
- Never describe code as "working as expected" if there are ANY failing tests
10+
- Even if specific feature tests pass, failing tests elsewhere indicate broken functionality
11+
- Changes that break existing tests must be fixed before considering implementation complete
12+
- A successful implementation must pass linting, type checking, AND all existing tests
13+
14+
## Project Overview
15+
16+
g is a lightweight CLI wrapper that proxies to the current directory's VCS command (git, svn, or hg). It auto-detects the repo type, forwards user arguments, and exits after invoking the native tool. The project lives in the gp-libs family of git-pull utilities and uses gp-libs packages for docs and development helpers.
17+
18+
Key features:
19+
- Detects VCS by walking parent directories and mapping `.git`, `.svn`, or `.hg`
20+
- Proxies CLI arguments directly to the detected VCS binary
21+
- Minimal surface area: primary logic lives in `src/g/__init__.py`
22+
- Test fixtures cover CLI behavior for both repo and non-repo directories
23+
24+
## Development Environment
25+
26+
This project uses:
27+
- Python 3.10+
28+
- [uv](https://github.com/astral-sh/uv) for dependency management and execution
29+
- [ruff](https://github.com/astral-sh/ruff) for linting and formatting
30+
- [mypy](https://github.com/python/mypy) for type checking
31+
- [pytest](https://docs.pytest.org/) (invoked as `py.test`) for testing
32+
- [gp-libs](https://gp-libs.git-pull.com/) for shared Sphinx/test helpers (included in dev/docs extras)
33+
34+
## Common Commands
35+
36+
### Setting Up Environment
37+
38+
```bash
39+
# Install all dev and doc dependencies
40+
uv sync --all-extras --dev
41+
```
42+
43+
### Running Tests
44+
45+
```bash
46+
# Run full suite
47+
make test
48+
# or directly
49+
uv run py.test
50+
51+
# Watch tests (pytest-watcher)
52+
make start # runs tests once then ptw .
53+
54+
# Watch tests via entr (requires entr(1))
55+
make watch_test
56+
```
57+
58+
### Linting and Type Checking
59+
60+
```bash
61+
# Lint and format with ruff
62+
uv run ruff check .
63+
uv run ruff format .
64+
65+
# make targets
66+
make ruff
67+
make ruff_format
68+
make watch_ruff
69+
70+
# Type checking
71+
uv run mypy .
72+
make mypy
73+
make watch_mypy
74+
```
75+
76+
### Documentation
77+
78+
```bash
79+
# Build docs
80+
make build_docs
81+
82+
# Live docs server with autoreload
83+
make start_docs
84+
85+
# Docs design assets
86+
make design_docs
87+
```
88+
89+
## Code Architecture
90+
91+
```
92+
src/g/__init__.py
93+
├─ find_repo_type(): detect VCS by walking parent directories
94+
├─ run(): CLI entrypoint; proxies args to detected VCS, honors G_IS_TEST
95+
└─ DEFAULT + vcspath_registry helpers
96+
97+
tests/test_cli.py
98+
└─ Parametrized CLI tests for git/non-repo scenarios
99+
```
100+
101+
## Testing Strategy
102+
103+
- Tests live in `tests/test_cli.py` and use `pytest` with parametrized fixtures.
104+
- `G_IS_TEST` env flag forces `run()` to return the subprocess so output can be asserted; set when modifying run logic.
105+
- CLI tests rely on actual VCS binaries (e.g., `git`) being available on PATH. If adding tests for svn/hg, ensure binaries are installed or skip appropriately.
106+
- Use `tmp_path` and `monkeypatch` to simulate non-repo directories instead of mocks where possible.
107+
- Prefer pytest-watcher (`make start`) for TDD loops; for file-watch without ptw, use `make watch_test` (requires entr).
108+
109+
## Coding Standards
110+
111+
- Include `from __future__ import annotations` at the top of Python modules.
112+
- Use namespace imports: `import typing as t`, `import logging`, etc.; avoid `from typing import ...`.
113+
- Follow NumPy-style docstrings (see existing docstrings in `run` and pytest config requiring `pydocstyle` via ruff).
114+
- Ruff is the source of truth for lint rules; see `pyproject.toml` for enabled checks (E, F, I, UP, A, B, C4, COM, EM, Q, PTH, SIM, TRY, PERF, RUF, D, FA100).
115+
- Type checking is strict (`mypy --strict`); favor precise types and avoid `Any` unless necessary.
116+
117+
## Debugging Tips
118+
119+
- Add logging with `logging` configured in `run`; keep output minimal because the CLI forwards to underlying VCS.
120+
- When diagnosing repo detection, log the path iteration in `find_repo_type` or unit-test with synthetic directory trees.
121+
- If subprocess output is swallowed, run with `G_IS_TEST=1` and `wait=True` to capture stdout/stderr in tests.
122+
123+
## References
124+
125+
- Documentation: https://g.git-pull.com/
126+
- API: https://g.git-pull.com/api.html
127+
- Changelog: https://g.git-pull.com/history.html
128+
- Repository: https://github.com/vcs-python/g
129+
- Shared tooling (gp-libs): https://gp-libs.git-pull.com/

0 commit comments

Comments
 (0)