-
Notifications
You must be signed in to change notification settings - Fork 156
docs: create AGENTS.md with CI-enforced rules for coding agents #754
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
sergio-sisternes-epam
wants to merge
3
commits into
microsoft:main
from
sergio-sisternes-epam:695-agents-md
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -62,6 +62,7 @@ docs/wip/ | |
| .env.local | ||
| .env.*.local | ||
| AGENTS.md | ||
| !/AGENTS.md | ||
| PRD.md | ||
| PRD*.md | ||
| WIP/ | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| # AGENTS.md | ||
|
|
||
| This file is for AI coding agents. Read it before making any code change in this repository. | ||
|
|
||
| For detailed per-module rules, see the instruction files in `.github/instructions/`. | ||
|
|
||
| ## Setup | ||
|
|
||
| ``` | ||
| uv sync --extra dev | ||
| uv run apm --version | ||
| ``` | ||
|
|
||
| - Use `uv` for all dependency management. Never use `pip` directly. | ||
| - Python 3.12 (CI-enforced via `ci.yml`). | ||
|
|
||
| ## Before Every Commit | ||
|
|
||
| Run these checks before every commit. All must pass. | ||
|
|
||
| 1. **Unit tests** | ||
| ``` | ||
| uv run pytest tests/unit tests/test_console.py -n auto --dist worksteal | ||
| ``` | ||
|
|
||
| 2. **YAML I/O lint** -- must return empty (no output = pass) | ||
| ``` | ||
| grep -rn --include='*.py' -P 'yaml\.(safe_)?dump\(.+,\s*[a-zA-Z_]\w*\b' src/apm_cli/ | grep -v 'utils/yaml_io.py' | grep -v '# yaml-io-exempt' | ||
| ``` | ||
|
|
||
| 3. **Path portability lint** -- must return empty (no output = pass) | ||
| ``` | ||
| grep -rn --include='*.py' -P 'str\([^)]*\.relative_to\(' src/apm_cli/ | grep -v portable_relpath | ||
| ``` | ||
|
|
||
| 4. **Encoding check** -- verify no non-ASCII characters in changed text files | ||
| ``` | ||
| git diff --cached --name-only --diff-filter=ACMR | xargs grep -Pn '[^\x09\x0a\x0d\x20-\x7e]' | ||
| ``` | ||
|
|
||
| 5. **CHANGELOG entry** -- add an entry under `[Unreleased]` for any PR changing code, tests, or docs. | ||
|
|
||
| ## Code Conventions | ||
|
|
||
| | Rule | Detail | | ||
| |------|--------| | ||
| | Python version | 3.12 (CI-enforced) | | ||
| | Package manager | `uv` only -- never `pip` | | ||
| | Formatter | `black` (line-length 88) | | ||
| | Import sorting | `isort` (profile=black) | | ||
| | YAML I/O | Use `yaml_io.load_yaml()` / `yaml_io.dump_yaml()` from `apm_cli.utils.yaml_io`. Never write `yaml.dump(data, file_handle)` directly. CI grep enforces this. Exempt with `# yaml-io-exempt` comment. | | ||
| | Path portability | Use `portable_relpath(path, base)` from `apm_cli.utils.paths`. Never use `str(path.relative_to(base))`. CI grep enforces this. | | ||
| | Path security | Validate user-supplied paths with `validate_path_segments()` and `ensure_path_within()` from `apm_cli.utils.path_security`. Never build filesystem paths from user input without these guards. | | ||
| | Console output | Use `_rich_success()`, `_rich_error()`, `_rich_warning()`, `_rich_info()` from `apm_cli.utils.console`. No raw `print()` calls. Rich library with colorama fallback. | | ||
| | Encoding | ALL source code and CLI output must stay within printable ASCII (U+0020--U+007E). No emojis, no Unicode symbols. Use bracket notation for status: `[+]` success, `[!]` warning, `[x]` error, `[i]` info, `[*]` action, `[>]` running. These map to `STATUS_SYMBOLS` in `console.py`. | | ||
|
sergio-sisternes-epam marked this conversation as resolved.
|
||
|
|
||
| ## CLI Conventions | ||
|
|
||
| - Help text must be plain ASCII (no emojis). | ||
| - Format: `help="Action description"` (sentence case, no period). | ||
| - Use Rich library for visual output with colorama fallback. | ||
| - Every new or modified CLI command/flag must be reflected in `docs/src/content/docs/reference/cli-commands.md`. | ||
| - Verify examples in documentation actually work. | ||
|
sergio-sisternes-epam marked this conversation as resolved.
|
||
|
|
||
| ## Testing Conventions | ||
|
|
||
| | Directory | Purpose | | ||
| |-----------|---------| | ||
| | `tests/unit/` | Fast isolated unit tests (default CI scope) | | ||
| | `tests/integration/` | E2E tests requiring network/external services | | ||
| | `tests/test_console.py` | Root-level test included in CI suite | | ||
|
|
||
|
sergio-sisternes-epam marked this conversation as resolved.
|
||
| - Mock all network calls in unit tests. | ||
| - No new external test dependencies without maintainer approval. | ||
| - No generated files committed to the repository. | ||
| - CI command: `uv run pytest tests/unit tests/test_console.py -n auto --dist worksteal` | ||
|
|
||
| ## Security | ||
|
|
||
| - CodeQL runs on every PR (Python + GitHub Actions analysis). | ||
| - Never commit secrets, tokens, or credentials to source. | ||
| - Path traversal validation: use `path_security.py` guards for all user-supplied paths. | ||
| - See `apm_cli/utils/path_security.py` for `validate_path_segments()`, `ensure_path_within()`, `safe_rmtree()`. | ||
|
|
||
| ## PR Hygiene | ||
|
|
||
| - Branch naming: `fix/NNN-short-description` or `feat/NNN-short-description`. | ||
| - Every PR changing code, tests, or docs must include a CHANGELOG.md entry under `[Unreleased]`. | ||
| - Do NOT modify `scripts/test-*.sh` files in feature PRs (integration tests run from `main` branch only). | ||
| - Keep PRs focused -- one logical change per PR. | ||
|
|
||
| ## Detailed Per-Module Rules | ||
|
|
||
| All files are in `.github/instructions/`. | ||
|
|
||
| | File | Scope | Description | | ||
| |------|-------|-------------| | ||
| | `encoding.instructions.md` | `**` | Cross-platform ASCII encoding rules | | ||
| | `doc-sync.instructions.md` | `**` | Documentation sync rules | | ||
| | `cli.instructions.md` | `src/apm_cli/cli.py` | CLI design guidelines and visual standards | | ||
| | `integrators.instructions.md` | `src/apm_cli/integration/**` | BaseIntegrator architecture pattern | | ||
| | `changelog.instructions.md` | `CHANGELOG.md` | Changelog format (Keep a Changelog) | | ||
| | `cicd.instructions.md` | `.github/workflows/**` | CI/CD pipeline architecture | | ||
|
sergio-sisternes-epam marked this conversation as resolved.
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.