Skip to content

Commit 5e1ea83

Browse files
committed
Add agents.md to help with LLM automation
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
1 parent 091ffca commit 5e1ea83

File tree

1 file changed

+207
-0
lines changed

1 file changed

+207
-0
lines changed

AGENTS.md

Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
# AGENTS.md - Guide for AI Agents Contributing to Arkade
2+
3+
This document provides guidance for AI agents working on arkade, specifically for reviewing and adding new CLI tools to the `arkade get` command.
4+
5+
## Types of Arkade Commands
6+
7+
Arkade provides several types of installers:
8+
9+
- **`arkade get`** - CLI tools usually to be placed at `/usr/local/bin/` or `$HOME/.arkade/bin/`. These are standalone binaries that can be downloaded and executed directly.
10+
11+
- **`arkade system install`** - Linux-only system-level tools like Node.js, Go, Prometheus. These require additional installation steps or system configuration.
12+
13+
- **`arkade oci install`** - Fetches binaries out of OCI images. Ideal for projects that use private repositories like slicer/actuated/k3sup-pro.
14+
15+
- **`arkade install`** - Kubernetes Helm charts or manifests for add-ons like OpenFaaS CE, Istio, PostgreSQL. These deploy software to Kubernetes clusters.
16+
17+
**This guide focuses on `arkade get`** - adding CLI tools that provide static binaries for download.
18+
19+
## 1. How to Add a New CLI (Tool) to Arkade
20+
21+
### What Can Be Added
22+
23+
**Only tools with static binaries** can be added to arkade. The tool must provide pre-compiled binaries for download.
24+
25+
**Cannot be added:**
26+
- Python-based tools (e.g., `aws-cli`, `azure-cli`) - require Python runtime
27+
- Node.js-based tools without static binaries - require Node.js runtime
28+
- Tools that require installation scripts or package managers
29+
- Tools that need runtime dependencies beyond the binary itself
30+
31+
### Prerequisites
32+
33+
1. Fork and create a branch: `git checkout -b add-TOOL_NAME`
34+
35+
### Step 1: Check GitHub Releases
36+
37+
**CRITICAL**: Before writing code, check the latest stable release on GitHub to see what OS/architecture combinations are available.
38+
39+
1. Go to `https://github.com/OWNER/REPO/releases/latest` (adds `/latest` to go directly to the latest release)
40+
2. Examine ALL download URLs in the "Assets" section
41+
3. Note available combinations:
42+
- Linux amd64 (x86_64)
43+
- Linux arm64 (aarch64)
44+
- Darwin amd64 (x86_64)
45+
- Darwin arm64
46+
- Windows amd64 (x86_64)
47+
48+
**Important**: Match the exact naming used by the upstream project (`amd64` vs `x86_64`, `arm64` vs `aarch64`).
49+
50+
### Step 2: Add Tool Definition
51+
52+
Edit `pkg/get/tools.go` and add a new `Tool` entry. **Reference existing examples** like `faas-cli` (lines 27-50) for the structure.
53+
54+
**Key points:**
55+
- Use `BinaryTemplate` for GitHub releases (simpler)
56+
- Use `URLTemplate` for custom URLs or non-GitHub sources
57+
- Supported archive formats: `.tar.gz`, `.zip` (`.tar.xz` is NOT supported)
58+
- Template variables: `.OS`, `.Arch`, `.Name`, `.Version`, `.VersionNumber`, `.Repo`, `.Owner`
59+
- Windows detection: `HasPrefix .OS "ming"`
60+
- **CRITICAL**: If a binary is missing for a specific OS/arch (e.g., Windows amd64), the template must still generate a URL that results in a 404 error, NOT download the wrong binary (e.g., don't download Linux binary when Windows was requested)
61+
62+
### Step 3: Write Unit Tests
63+
64+
Add a test function in `pkg/get/get_test.go`. **Reference `Test_DownloadFaasCli`** (around line 2761) as an example.
65+
66+
**Requirements:**
67+
- Use a pinned version (not "latest")
68+
- Test all available OS/arch combinations
69+
- Verify URLs match actual GitHub release URLs
70+
71+
### Step 4: Download and Verify Every OS/Arch Combination
72+
73+
**MANDATORY**: Download and verify EVERY combination using the `file` command.
74+
75+
```bash
76+
# Build arkade
77+
go build
78+
79+
# Test all combinations (script automates this)
80+
./hack/test-tool.sh TOOL_NAME
81+
```
82+
83+
For each combination, verify the `file` command output:
84+
- Linux amd64: `ELF 64-bit LSB executable, x86-64`
85+
- Linux arm64: `ELF 64-bit LSB executable, ARM aarch64`
86+
- Darwin amd64: `Mach-O 64-bit x86_64 executable`
87+
- Darwin arm64: `Mach-O 64-bit arm64 executable`
88+
- Windows amd64: `PE32+ executable (console) x86-64`
89+
90+
**Include the full output of `./hack/test-tool.sh TOOL_NAME` in your PR description.**
91+
92+
### Step 5: Update Documentation
93+
94+
The README.md file contains instructions for updating itself. Follow the note at the bottom of the "Catalog of CLIs" section: run `go build && ./arkade get --format markdown` to generate the updated table, then replace the existing catalog section.
95+
96+
### Step 6: Create Pull Request
97+
98+
**PR Description must include:**
99+
- List of available/unavailable OS/arch combinations from GitHub releases page
100+
- Full output from `./hack/test-tool.sh TOOL_NAME` showing `file` command results
101+
- Output from `make e2e` (if applicable)
102+
103+
**Checklist:**
104+
- [ ] All commits signed off (`git commit -s`)
105+
- [ ] Unit tests pass
106+
- [ ] All OS/arch combinations verified with `file` command
107+
- [ ] README.md updated
108+
- [ ] PR description includes verification output
109+
110+
### Architecture Support Reference
111+
112+
| OS | Architecture | Const name | Notes |
113+
|---|---|---|---|
114+
| macOS (Intel) | x86_64 | `arch64bit` | Intel Macs |
115+
| macOS (Apple Silicon) | arm64 | `archDarwinARM64` | M1/M2/M3 Macs |
116+
| Linux | x86_64 | `arch64bit` | Standard Linux |
117+
| Linux | aarch64/arm64 | `archARM64` | ARM64 Linux |
118+
| Windows | x86_64 | `arch64bit` | Windows (Git Bash) |
119+
120+
**Note**: Do not add ARMv6 or 32-bit x86 support.
121+
122+
### Troubleshooting
123+
124+
- **URLs don't match**: Check actual release URLs on GitHub and adjust template
125+
- **Wrong architecture in binary**: Verify binary names on GitHub releases page
126+
- **Missing combinations**: Document why in PR description if upstream doesn't provide them. The template must still generate a URL that returns 404 (not download the wrong binary)
127+
- **Downloads wrong binary**: If requesting Windows but getting Linux binary, the template is incorrectly falling back. Each OS/arch must have a unique URL that matches the actual release or returns 404
128+
129+
---
130+
131+
## 2. How to Review a New CLI Being Added as an AI Agent
132+
133+
### Pre-Review Checklist
134+
135+
- [ ] Issue has `design/approved` label
136+
- [ ] All commits signed off
137+
- [ ] PR adds only one tool
138+
139+
### Code Review
140+
141+
#### Tool Definition (`pkg/get/tools.go`)
142+
143+
- [ ] Tool provides static binaries (not Python/Node.js-based)
144+
- [ ] Required fields: `Name`, `Owner`, `Repo`, `Description`
145+
- [ ] Either `BinaryTemplate` or `URLTemplate` provided
146+
- [ ] Supports required OS/arch combinations (Linux amd64/arm64, Darwin amd64/arm64, Windows amd64)
147+
- [ ] Archive format is `.tar.gz` or `.zip` (not `.tar.xz`)
148+
- [ ] Missing OS/arch combinations generate URLs that return 404 (not download wrong binary)
149+
150+
#### Unit Tests (`pkg/get/get_test.go`)
151+
152+
- [ ] Test function exists with pinned version
153+
- [ ] Test cases for all available platforms
154+
- [ ] URLs match actual GitHub release URLs
155+
156+
#### Documentation
157+
158+
- [ ] README.md updated with tool entry
159+
160+
#### PR Description
161+
162+
- [ ] **CRITICAL**: Includes `file` command output for **every** OS/arch combination
163+
- [ ] Documents which OS/arch combinations are available from upstream
164+
- [ ] Includes output from `./hack/test-tool.sh TOOL_NAME`
165+
- [ ] Includes output from `make e2e` (if applicable)
166+
167+
### Critical Review: Binary Verification
168+
169+
**MANDATORY**: Verify `file` command output for every combination shows correct architecture:
170+
- Linux amd64: `ELF 64-bit LSB executable, x86-64`
171+
- Linux arm64: `ELF 64-bit LSB executable, ARM aarch64`
172+
- Darwin amd64: `Mach-O 64-bit x86_64 executable`
173+
- Darwin arm64: `Mach-O 64-bit arm64 executable`
174+
- Windows amd64: `PE32+ executable (console) x86-64`
175+
176+
**If missing, request it before approving.**
177+
178+
### Review Commands
179+
180+
```bash
181+
go build && ./hack/test-tool.sh TOOL_NAME
182+
go test ./pkg/get/... -v
183+
./arkade get --format markdown | grep TOOL_NAME
184+
```
185+
186+
### Common Issues
187+
188+
1. Tool requires runtime (Python/Node.js) - cannot be added
189+
2. Missing `file` command output for all combinations
190+
3. URLs don't match actual GitHub releases
191+
4. Missing architecture support
192+
5. Wrong architecture mapping (`arm64` vs `aarch64`, `amd64` vs `x86_64`)
193+
6. Using unsupported archive format (`.tar.xz`)
194+
7. Template downloads wrong binary when combination is missing (e.g., downloads Linux when Windows requested) - must return 404 instead
195+
196+
---
197+
198+
## Reference Examples
199+
200+
- **Simple BinaryTemplate**: `faas-cli` (lines 27-50 in `pkg/get/tools.go`)
201+
- **Test example**: `Test_DownloadFaasCli` (around line 2761 in `pkg/get/get_test.go`)
202+
- **Recent additions**: `dufs` (commit a120f8c), `logcli` (commit 4f72efe), `ripgrep` (commit a80f284)
203+
204+
## Additional Resources
205+
206+
- [CONTRIBUTING.md](CONTRIBUTING.md) - General contribution guidelines
207+
- [.github/PULL_REQUEST_TEMPLATE.md](.github/PULL_REQUEST_TEMPLATE.md) - PR template

0 commit comments

Comments
 (0)