Skip to content

Commit 064bc3e

Browse files
committed
Add AGENTS.md with project documentation for AI assistants
- Include frequently used commands for testing and linting - Document project structure and file purposes - Explain code style conventions and guidelines - Add important notes about test fixtures and pandoc behavior - Provide development workflow and debugging tips
1 parent 7ec4b48 commit 064bc3e

File tree

1 file changed

+134
-0
lines changed

1 file changed

+134
-0
lines changed

AGENTS.md

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
# AGENTS.md - AI Agent Instructions
2+
3+
This file contains information to help AI agents understand and work with this
4+
codebase effectively.
5+
6+
## Project Overview
7+
8+
This is a pre-commit hook that wraps pandoc for formatting Markdown files. It's
9+
designed to be used by others as an open-source tool via pre-commit framework.
10+
11+
## Frequently Used Commands
12+
13+
### Testing
14+
15+
``` bash
16+
# Run the full test suite
17+
./tests/test_pandoc_format.sh
18+
19+
# Test the pandoc-format script on a specific file
20+
./pandoc-format README.md
21+
22+
# Test with different options
23+
./pandoc-format --columns 60 --no-reference-links test.md
24+
```
25+
26+
### Linting
27+
28+
``` bash
29+
# Run shellcheck on all shell scripts
30+
shellcheck pandoc-format tests/test_pandoc_format.sh
31+
```
32+
33+
### Git Operations
34+
35+
``` bash
36+
# View commit history
37+
git log --oneline
38+
39+
# Run pre-commit hooks (excluding test fixtures)
40+
pre-commit run --all-files
41+
```
42+
43+
## Project Structure
44+
45+
.
46+
├── .github/
47+
│ └── workflows/
48+
│ └── test.yml # CI workflow for GitHub Actions
49+
├── tests/
50+
│ ├── fixtures/ # Test markdown files (must remain unformatted)
51+
│ │ ├── already-formatted.md
52+
│ │ ├── complex.md
53+
│ │ └── simple.md
54+
│ └── test_pandoc_format.sh # Test suite script
55+
├── .pre-commit-config.yaml # Example configuration for testing
56+
├── .pre-commit-hooks.yaml # Hook definition for pre-commit
57+
├── pandoc-format # Main wrapper script (executable)
58+
├── README.md # Documentation (must be pandoc-formatted)
59+
└── LICENSE # MIT License
60+
61+
## Code Style & Conventions
62+
63+
### Shell Scripts
64+
65+
- Use `#!/usr/bin/env bash` shebang
66+
- Set `set -euo pipefail` for error handling
67+
- Use shellcheck and fix all warnings
68+
- Prefer `[[ ]]` over `[ ]` for conditionals
69+
- Quote variables to prevent word splitting
70+
- Use meaningful variable names in UPPER_CASE for globals
71+
- Declare and assign variables separately when capturing command output
72+
73+
### Markdown Files
74+
75+
- README.md and documentation should be formatted with pandoc
76+
- Test fixtures in `tests/fixtures/` must NOT be formatted (they're test input)
77+
- Use reference-style links by default
78+
- 80-column width by default
79+
80+
### Git Commits
81+
82+
- Use conventional commit style when appropriate
83+
- Keep commits focused on a single change
84+
- Include tests with feature additions
85+
86+
## Important Notes
87+
88+
### Test Fixtures
89+
90+
**CRITICAL**: Files in `tests/fixtures/` must remain unformatted. These are
91+
input files for the test suite. The tests expect to format these files and
92+
detect changes. If they're already formatted, tests will fail.
93+
94+
### CI Configuration
95+
96+
The GitHub Actions workflow excludes test fixtures from pre-commit formatting by
97+
creating a custom configuration. This ensures the idempotency test works
98+
correctly.
99+
100+
### Pandoc Behavior
101+
102+
- Pandoc adds spaces after triple backticks in code blocks: ```` ```python ````
103+
becomes ```` ``` python ````
104+
- Pandoc uses two spaces after list numbers: `1. Item` becomes `1. Item`
105+
- Pandoc may add blank lines between list items for better readability
106+
- Reference links are placed at the end of the document
107+
108+
### Pre-commit Hook Usage
109+
110+
Users will include this hook in their `.pre-commit-config.yaml` like:
111+
112+
``` yaml
113+
repos:
114+
- repo: https://github.com/jupblb/pre-commit-pandoc
115+
rev: <version>
116+
hooks:
117+
- id: pandoc
118+
args: [--columns=80] # optional customization
119+
```
120+
121+
## Development Workflow
122+
123+
1. Make changes to the code
124+
2. Run shellcheck to ensure no linting issues
125+
3. Run the test suite to ensure all tests pass
126+
4. Format README.md with pandoc if modified
127+
5. Commit changes with descriptive messages
128+
129+
## Debugging Tips
130+
131+
- Use `bash -x ./pandoc-format <file>` to see execution trace
132+
- Check exit codes: 0 = no changes, 1 = formatted
133+
- Test fixtures can be temporarily formatted to see expected output
134+
- The CI workflow can be tested locally with act or similar tools

0 commit comments

Comments
 (0)