Skip to content

Commit 0f07265

Browse files
[AB#555] docs: add AGENTS.md for AI coding assistants
Root-level AI agent instructions that complement .github/copilot-instructions.md. Provides quick-start guidance, architecture overview, and critical Windows development constraints. Multiple locations ensure broader AI tool compatibility: - AGENTS.md (root) - discovered by most AI systems - .github/copilot-instructions.md - GitHub Copilot specific
1 parent 8cca6b2 commit 0f07265

2 files changed

Lines changed: 270 additions & 4 deletions

File tree

.github/copilot-instructions.md

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,32 @@
33
## Branch Structure
44

55
### Active Branches
6+
67
- **`main`** - Active development for v3.x (Go rewrite) - **USE THIS FOR ALL PRS**
78
- **`master`** - Legacy v2.x maintenance only (bash-based)
89

910
### PR Guidelines
11+
1012
✅ Target `main` for: features, bug fixes, docs, improvements
1113
❌ Target `master` only for: critical v2.x security patches
1214

1315
### Branch Naming
16+
1417
- `fix/issue/NNN` - Bug fixes
15-
- `feature/description` - New features
18+
- `feature/description` - New features
1619
- `docs/description` - Documentation
1720
- `refactor/description` - Code refactoring
1821

1922
## Project Architecture
2023

2124
### Tech Stack
25+
2226
- Language: Go (100% rewritten from bash in v3.x)
2327
- CLI Framework: Cobra
2428
- Testing: Go testing + some legacy BATS
2529

2630
### Directory Structure
31+
2732
```
2833
cmd/ # CLI commands (Cobra-based)
2934
├── core/ # Version management (install, use, list, info)
@@ -57,6 +62,7 @@ Windows uses `.bat` files instead of bash scripts for shims.
5762
**Batch File Constraints** (Reference: Issue #555):
5863

5964
**NEVER DO**:
65+
6066
```bat
6167
# BAD - Breaks CMD parsing!
6268
if "%var%"=="value" (
@@ -69,6 +75,7 @@ for %%a in (%*) do (...)
6975
```
7076

7177
**ALWAYS DO**:
78+
7279
```bat
7380
# GOOD - Use subroutines
7481
if "%var%"=="value" call :subroutine
@@ -80,21 +87,24 @@ exit /b 0
8087
```
8188

8289
**Key Rules**:
90+
8391
1. NO goto/labels inside parenthesized `if (...)` blocks
84-
2. NO raw `%*` expansion in `for` loops
92+
2. NO raw `%*` expansion in `for` loops
8593
3. Use single-line conditionals when possible: `if "%DEBUG%"=="1" echo on`
8694
4. Always propagate exit codes: `exit /b %ERRORLEVEL%`
8795
5. Use subroutines with `call :label` for complex logic
8896

8997
**Testing on macOS/Linux**:
98+
9099
- Go tests validate template logic ✅
91100
- Cannot execute `.bat` files on Unix
92101
- CI runs Windows tests automatically
93102

94103
## Key Implementation Patterns
95104

96105
### Shim System Flow
97-
1. User runs `go version`
106+
107+
1. User runs `go version`
98108
2. Hits shim at `~/.goenv/shims/go` (or `go.bat` on Windows)
99109
3. Shim executes `goenv exec go version`
100110
4. `goenv exec` resolves current version from:
@@ -106,12 +116,14 @@ exit /b 0
106116
5. Executes actual Go binary from resolved version
107117

108118
### Shim Generation
119+
109120
- Triggered by `goenv rehash`
110121
- Auto-rehashes after `goenv install` and `go install`
111122
- Scans all versions for binaries
112123
- Creates platform-specific wrapper (bash or .bat)
113124

114125
### Version Resolution
126+
115127
- `internal/resolver/resolver.go` - Core logic
116128
- Smart precedence handling
117129
- Walks directory tree for `.go-version`
@@ -138,20 +150,23 @@ make build
138150
## Common Development Tasks
139151

140152
### Adding a New Command
153+
141154
1. Create in appropriate `cmd/<category>/` directory
142155
2. Use Cobra framework pattern
143156
3. Add to parent command's `init()`
144157
4. Write tests in `<name>_test.go`
145158
5. Update documentation
146159

147160
### Modifying Shim Templates
161+
148162
1. Edit `internal/shims/manager.go`
149163
2. Update `createUnixShim()` OR `createWindowsShim()`
150164
3. ⚠️ Windows changes require extra care - see constraints above
151165
4. Test: `go test ./internal/shims/... ./cmd/shims/...`
152166
5. Consider Windows batch file gotchas
153167

154168
### Adding Platform Support
169+
155170
1. Update `internal/utils/` for OS detection
156171
2. Add platform-specific shim generator
157172
3. Update install scripts
@@ -160,20 +175,23 @@ make build
160175
## Code Style
161176

162177
### Conventional Commits
178+
163179
```
164180
feat(area): description
165-
fix(area): description
181+
fix(area): description
166182
docs(area): description
167183
refactor(area): description
168184
test(area): description
169185
```
170186

171187
### Error Handling
188+
172189
- Use `internal/errors` package
173190
- Provide context: `errors.FailedTo("action", err)`
174191
- User-friendly messages
175192

176193
### Configuration
194+
177195
- Respect environment variables (`GOENV_*`)
178196
- Use `internal/config` for paths
179197
- Support `GOENV_ROOT` customization
@@ -214,6 +232,7 @@ GitHub Actions builds release binaries for all platforms.
214232
## Issue Resolution Checklist
215233

216234
When fixing issues:
235+
217236
1. ✅ Read issue thoroughly including comments
218237
2. ✅ Identify affected files/components
219238
3. ✅ Check for similar issues in issue tracker
@@ -227,6 +246,7 @@ When fixing issues:
227246
## Windows-Specific Issue Patterns
228247

229248
Common Windows issues to watch for:
249+
230250
- Batch file syntax errors (goto/label problems)
231251
- Path separators (use `filepath.Join`)
232252
- Line endings (CRLF vs LF - see `.gitattributes`)

0 commit comments

Comments
 (0)