Skip to content

Commit 0532586

Browse files
docs: Add GitHub Copilot instructions (#30)
Co-authored-by: YDX-2147483647 <73375426+YDX-2147483647@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
1 parent e368963 commit 0532586

1 file changed

Lines changed: 242 additions & 0 deletions

File tree

.github/copilot-instructions.md

Lines changed: 242 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,242 @@
1+
# Best of Typst (TCDM) - GitHub Copilot Instructions
2+
3+
Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here.
4+
5+
**Updated after main branch merge** - All commands and validation steps have been verified to work correctly in the current repository state.
6+
7+
## Working Effectively
8+
9+
### Bootstrap and Build
10+
Run these commands in order to set up the development environment:
11+
12+
1. **Install system dependencies:**
13+
```bash
14+
sudo apt-get update && sudo apt-get install -y just
15+
```
16+
- Takes 2-3 minutes. NEVER CANCEL. Set timeout to 5+ minutes.
17+
18+
2. **Install Python dependencies:**
19+
```bash
20+
just bootstrap
21+
```
22+
- Installs `ruamel.yaml` Python package required for YAML processing
23+
- Takes ~3 seconds normally. Very fast and reliable with good network.
24+
- **May fail in sandboxed environments** with network restrictions (ReadTimeoutError from pypi.org)
25+
- **WORKAROUND**: If it fails, the dependency may already be installed - test with validation commands first
26+
27+
3. **Verify dependencies are working:**
28+
```bash
29+
python -c "from ruamel.yaml import YAML; YAML(typ='safe').load('projects.yaml')"
30+
```
31+
- Should run without error if dependencies are properly installed
32+
- Use this to test if ruamel.yaml is available before proceeding
33+
34+
4. **Install best-of generator (required for main functionality):**
35+
```bash
36+
pip install "best-of @ git+https://github.com/YDX-2147483647/best-of-generator.git@best-of-bits"
37+
```
38+
- Takes 20-25 seconds.
39+
- This is the core tool that generates README.md from projects.yaml
40+
41+
### Core Commands
42+
43+
#### List available commands:
44+
```bash
45+
just --list
46+
```
47+
48+
#### Sync issue form templates:
49+
```bash
50+
just sync-issue-form
51+
```
52+
- Syncs categories and labels from projects.yaml to GitHub issue templates
53+
- Takes <1 second. Always reliable.
54+
55+
#### Build for pandoc (creates processed markdown):
56+
```bash
57+
just build-for-pandoc
58+
```
59+
- Creates `build/index.md` from README.md for pandoc processing
60+
- Takes <1 second. Creates build/ directory automatically.
61+
62+
#### Generate best-of list (main functionality):
63+
```bash
64+
best-of generate projects.yaml --libraries-key=$LIBRARIES_KEY --github-key=$GITHUB_TOKEN --gitee-key=$GITEE_API_KEY
65+
```
66+
- **CRITICAL**: This command may fail in sandboxed environments due to network restrictions (DNS resolution failures for api.npmjs.org, libraries.io, etc.)
67+
- **WORKAROUND**: The command will run but with warnings and limited functionality without API keys
68+
- Takes 2-3 seconds to fail with network issues, or 30+ seconds with proper network access
69+
- **NEVER CANCEL**: If running with proper network access, allow up to 5+ minutes for completion
70+
71+
#### Add project from GitHub issue:
72+
```bash
73+
just add-project ISSUE_NUMBER
74+
```
75+
- Requires `gh` CLI and appropriate GitHub permissions
76+
- Extracts project information from GitHub issue and adds to projects.yaml
77+
78+
#### List project suggestions:
79+
```bash
80+
just list-project-suggestions
81+
```
82+
- Lists GitHub issues with the "add-project" label
83+
- Requires `gh` CLI access
84+
85+
## Validation
86+
87+
### Always run these validation steps before committing changes:
88+
89+
1. **Validate YAML syntax:**
90+
```bash
91+
python -c "from ruamel.yaml import YAML; YAML(typ='safe').load('projects.yaml')"
92+
```
93+
94+
2. **Validate YAML schema:**
95+
```bash
96+
# Install boon (JSON Schema validator)
97+
wget https://github.com/santhosh-tekuri/boon/releases/download/v0.6.1/boon-x86_64-unknown-linux-gnu.tar.gz
98+
tar -xzf boon-x86_64-unknown-linux-gnu.tar.gz
99+
sudo mv boon /usr/local/bin/boon
100+
101+
# Validate against schema
102+
boon scripts/projects.schema.json projects.yaml
103+
```
104+
- Validates projects.yaml structure against the JSON schema
105+
- Ensures all required fields are present and types are correct
106+
- Checks category and label enum values are valid
107+
108+
3. **Check for duplicate project names:**
109+
```bash
110+
yq '.projects.[] | line + " " + .name' projects.yaml | sort --key=2 | uniq --skip-fields=1 --all-repeated
111+
```
112+
- Should return empty output. Any output indicates duplicate names.
113+
114+
4. **Sync issue forms after modifying projects.yaml:**
115+
```bash
116+
just sync-issue-form
117+
```
118+
119+
5. **Test build process:**
120+
```bash
121+
just build-for-pandoc
122+
```
123+
124+
### Manual Testing Scenarios
125+
126+
**CRITICAL**: After making changes to projects.yaml, always test these scenarios:
127+
128+
1. **Project addition workflow:**
129+
- Modify projects.yaml to add a new project
130+
- Run `just sync-issue-form` to update templates
131+
- Verify no YAML syntax errors
132+
- Check that new project appears in appropriate category
133+
134+
2. **Build verification:**
135+
- Run `just build-for-pandoc`
136+
- Verify `build/index.md` is created successfully
137+
- Check that markdown structure is preserved
138+
139+
## Repository Structure
140+
141+
### Key Files and Directories:
142+
- `projects.yaml` - Main configuration file containing all projects and categories
143+
- `justfile` - Build recipes and automation commands
144+
- `scripts/` - Python automation scripts
145+
- `.github/workflows/` - CI/CD pipelines for automation
146+
- `config/header.md` - Template header for generated README
147+
- `config/footer.md` - Template footer for generated README
148+
- `build/` - Generated output directory (excluded from git)
149+
150+
### Important Scripts:
151+
- `scripts/sync_issue_form.py` - Syncs categories to GitHub issue templates
152+
- `scripts/add_project.py` - Adds projects from GitHub issues
153+
- `scripts/projects.schema.json` - JSON schema for validating projects.yaml structure
154+
155+
## GitHub Workflows
156+
157+
The repository includes several automated workflows:
158+
159+
1. **check.yml** - Validates projects.yaml for duplicate names and schema compliance
160+
2. **update-best-of-list.yml** - Automatically updates the best-of list monthly
161+
3. **add-project.yml** - Handles project additions from issues
162+
4. **deploy.yml** - Deploys to GitHub Pages
163+
164+
## Common Issues and Troubleshooting
165+
166+
### Network connectivity issues:
167+
- The `best-of generate` command may fail with DNS resolution errors in sandboxed environments
168+
- **Bootstrap command may fail** with ReadTimeoutError from pypi.org in restricted environments
169+
- This is normal - the commands will still run with warnings but limited functionality
170+
- **Always test YAML validation first** to verify dependencies are working
171+
- Document this as "expected behavior in restricted environments"
172+
173+
### Missing dependencies:
174+
- Always run `just bootstrap` before other commands
175+
- Install `just` via `sudo apt-get install -y just` if not available
176+
- Install best-of generator if generation commands are needed
177+
178+
### YAML validation errors:
179+
- Use `python -c "from ruamel.yaml import YAML; YAML(typ='safe').load('projects.yaml')"` to check syntax
180+
- Use `boon scripts/projects.schema.json projects.yaml` to validate against schema
181+
- Common issues: incorrect indentation, missing quotes for special characters, invalid category/label values
182+
183+
### GitHub CLI authentication:
184+
- Commands using `gh` CLI require proper GitHub authentication
185+
- Set `GH_TOKEN` environment variable or run `gh auth login`
186+
187+
## Environment Variables
188+
189+
The following environment variables are used:
190+
- `PYTHON` - Python executable (defaults to 'python')
191+
- `LIBRARIES_KEY` - Libraries.io API key (optional)
192+
- `GITHUB_TOKEN` - GitHub API token (required for full functionality)
193+
- `GITEE_API_KEY` - Gitee API key (optional)
194+
- `GH_TOKEN` - GitHub CLI token (required for issue-related commands)
195+
196+
## File Exclusions
197+
198+
When committing changes, exclude these files/directories:
199+
- `build/` - Generated output
200+
- `history/*.csv` - Generated project data
201+
- `history/*_changes.md` - Generated change logs
202+
- Any temporary files in `/tmp/`
203+
204+
## Timing Expectations
205+
206+
**NEVER CANCEL these operations - set appropriate timeouts:**
207+
- `sudo apt-get install -y just`: 2-3 minutes (timeout: 5+ minutes)
208+
- `pip install best-of-generator`: 20-25 seconds (timeout: 60+ minutes)
209+
- `best-of generate`: 30+ seconds with network, 2-3 seconds without (timeout: 10+ minutes)
210+
- `just bootstrap`: 3 seconds (timeout: 1 minute)
211+
- `just sync-issue-form`: <1 second (timeout: 30 seconds)
212+
- `just build-for-pandoc`: <1 second (timeout: 30 seconds)
213+
214+
## Best Practices
215+
216+
1. **Always validate changes locally before committing**
217+
2. **Run sync-issue-form after modifying categories in projects.yaml**
218+
3. **Test build-for-pandoc to ensure markdown generation works**
219+
4. **Check for duplicate project names before adding new projects**
220+
5. **Use descriptive commit messages when modifying projects.yaml**
221+
6. **Follow existing project structure when adding new entries**
222+
223+
## Quick Reference Commands
224+
225+
```bash
226+
# Setup
227+
sudo apt-get update && sudo apt-get install -y just
228+
just bootstrap # May fail in restricted environments - that's OK
229+
python -c "from ruamel.yaml import YAML; YAML(typ='safe').load('projects.yaml')" # Verify dependencies
230+
pip install "best-of @ git+https://github.com/YDX-2147483647/best-of-generator.git@best-of-bits"
231+
232+
# Validation (these work offline)
233+
python -c "from ruamel.yaml import YAML; YAML(typ='safe').load('projects.yaml')"
234+
just sync-issue-form
235+
just build-for-pandoc
236+
237+
# Generate (may fail in restricted environments)
238+
best-of generate projects.yaml
239+
240+
# List available commands
241+
just --list
242+
```

0 commit comments

Comments
 (0)