Skip to content

Commit 156003c

Browse files
committed
AGENTS.md: Add basic AGENTS.md
This does speed up AGENTS, and it fixes a few problems different ones have. Including the style of changes it makes and detecting commit message issues, and agents not formatting code or running tests properly. Note, this is used by both review and code generating agents. Made with some manual tweaks from the combination of a few different AGENTS.md creators and researcher agents. It is one file rather than several, because some agents do not support nested AGENTS.md well. Even copilot in vscode at time of writing. I think we can use this as a beginning and add more documentation or things in here as we spot other issues.
1 parent 493808f commit 156003c

File tree

1 file changed

+367
-0
lines changed

1 file changed

+367
-0
lines changed

AGENTS.md

Lines changed: 367 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,367 @@
1+
# AGENTS.md
2+
version: 1
3+
default_agent: "@dev-agent"
4+
5+
> **Consulted files (agent must populate before committing):**
6+
>
7+
> **README.md files:**
8+
> - `/README.md` - Main project README
9+
> - `/frontend/README.md` - Frontend-specific README
10+
> - `/backend/README.md` - Backend quickstart guide
11+
> - `/app/README.md` - Desktop app README
12+
> - `/e2e-tests/README.md` - End-to-end testing README
13+
> - `/load-tests/README.md` - Load testing guide
14+
> - `/plugins/README.md` - Plugins overview
15+
> - `/plugins/headlamp-plugin/README.md` - Plugin development tools
16+
> - `/plugins/pluginctl/README.md` - Plugin control utility
17+
> - `/backend/pkg/telemetry/README.md` - Telemetry module
18+
> - `/docker-extension/README.md` - Docker extension
19+
> - `/charts/headlamp/README.md` - Helm chart
20+
> - `/backstage-test/README.md` - Backstage integration test
21+
> - `/tools/i18n/README.md` - Internationalization tools
22+
> - `/eslint-config/README.md` - ESLint configuration
23+
> - `/frontend/src/i18n/README.md` - Frontend i18n
24+
> - `/app/e2e-tests/README.md` - Desktop app e2e tests
25+
> - Plugin examples: `/plugins/examples/*/README.md` (multiple examples)
26+
>
27+
> **Documentation files:**
28+
> - `/docs/development/index.md` - Main development guide with build/run commands
29+
> - `/docs/development/frontend.md` - Frontend development guide
30+
> - `/docs/development/backend.md` - Backend development guide with testing commands
31+
> - `/docs/development/testing.md` - Load testing guide
32+
> - `/docs/development/architecture.md` - Architecture documentation
33+
> - `/docs/development/plugins/index.md` - Plugin system overview
34+
> - `/docs/development/plugins/building.md` - Plugin building guide
35+
> - `/docs/development/plugins/getting-started.md` - Plugin getting started
36+
> - `/docs/development/plugins/publishing.md` - Plugin publishing guide
37+
> - `/docs/development/i18n/index.md` - Internationalization guide
38+
> - `/docs/development/release-guide.md` - Release process
39+
> - `/docs/installation/index.mdx` - Installation instructions
40+
> - `/docs/installation/in-cluster/index.md` - In-cluster deployment
41+
> - `/docs/installation/desktop/index.mdx` - Desktop installation
42+
> - `/docs/contributing.md` - Contribution guidelines
43+
> - `/docs/faq.md` - Frequently asked questions
44+
> - `/docs/platforms.md` - Tested platforms list
45+
>
46+
> **Build/Config files:**
47+
> - `/package.json` - Root package with all npm scripts and Node.js version (>=20.11.1)
48+
> - `/backend/go.mod` - Go version (1.24.11)
49+
> - `/CONTRIBUTING.md` - Contributing guidelines
50+
> - `/OWNERS` - Code reviewers and approvers
51+
52+
---
53+
54+
### Agent persona and scope
55+
- **@dev-agent** — pragmatic, conservative, test-first, risk-averse.
56+
- **Scope:** propose, validate, and prepare code/docs patches; run local build/test commands; create PR drafts.
57+
- **Not allowed:** push images/releases, modify CI or infra, or merge without human approval.
58+
59+
---
60+
61+
### Explicit non-goals
62+
should NOT unless explicitly requested or strictly necessary for the change
63+
- Propose refactors without a clear bug, performance, or maintenance justification
64+
- Change public APIs without explicit request
65+
- Reformat unrelated code
66+
- Rename files or symbols for stylistic reasons
67+
- Introduce new dependencies unless required to fix a bug or implement a requested feature and an existing dependency can not be used
68+
69+
---
70+
71+
### Tech stack and environment
72+
- **Languages:** TypeScript (frontend), Go (backend).
73+
- **Runtimes/tools:**
74+
- Node.js >=20.11.1 (specified in `/package.json` engines field)
75+
- npm >=10.0.0 (specified in `/package.json` engines field)
76+
- Go 1.24.11 (specified in `/backend/go.mod`)
77+
- **Reproduce locally:** Use commands from `/package.json` scripts section and documentation files listed above.
78+
79+
---
80+
81+
### Repo map
82+
- **`frontend/`** — UI code (TypeScript/React); see `/frontend/README.md` and `/docs/development/frontend.md` for build/run/test commands.
83+
- **`backend/`** — Go server and API; see `/backend/README.md` and `/docs/development/backend.md` for server commands.
84+
- **`docs/`** — all developer and user docs; reference specific files under `docs/` for workflows.
85+
- **`plugins/`** — plugin system and examples; see `/plugins/README.md` and `/docs/development/plugins/`.
86+
- **`app/`** — desktop application (Electron); see `/app/README.md`.
87+
- **CI & infra:** `.github/workflows/`, Dockerfiles (`/Dockerfile`, `/Dockerfile.plugins`), Kubernetes manifests (`kubernetes-headlamp*.yaml`), Helm charts (`/charts/`) — treat as manual-review-only.
88+
89+
---
90+
91+
### Primary entry points (exact commands from repository)
92+
93+
#### Build commands (from `/package.json` and `/docs/development/index.md`):
94+
- **Build everything:** `npm run build` (builds backend and frontend - from `/package.json`)
95+
- **Build frontend only:** `npm run frontend:build` (from `/package.json`, documented in `/docs/development/frontend.md`)
96+
- **Build backend only:** `npm run backend:build` (from `/package.json`, documented in `/docs/development/backend.md`)
97+
- **Build desktop app:** `npm run app:build` (from `/package.json`)
98+
99+
#### Run commands (from `/package.json` and `/docs/development/index.md`):
100+
- **Run both backend and frontend:** `npm start` (from `/package.json`, documented in `/docs/development/index.md`)
101+
- **Run backend only:** `npm run backend:start` (from `/package.json`, documented in `/docs/development/backend.md`)
102+
- **Run frontend only:** `npm run frontend:start` (from `/package.json`, documented in `/docs/development/frontend.md`)
103+
- **Run desktop app:** `npm run app:start` (from `/package.json`)
104+
105+
#### Test commands (from `/package.json` and `/docs/development/backend.md`):
106+
- **Run all tests:** `npm test` (from `/package.json`)
107+
- **Backend tests:** `npm run backend:test` (from `/package.json`, documented in `/docs/development/backend.md`)
108+
- **Backend coverage:** `npm run backend:coverage` (from `/package.json`, documented in `/docs/development/backend.md`)
109+
- **Backend coverage HTML:** `npm run backend:coverage:html` (from `/package.json`, documented in `/docs/development/backend.md`)
110+
- **Frontend tests:** `npm run frontend:test` (from `/package.json`)
111+
- **App unit tests:** `npm run app:test:unit` (from `/package.json`)
112+
- **App e2e tests:** `npm run app:test:e2e` (from `/package.json`)
113+
114+
#### Lint commands (from `/package.json` and `/docs/development/backend.md`):
115+
- **Lint all:** `npm run lint` (from `/package.json`)
116+
- **Lint backend:** `npm run backend:lint` (from `/package.json`, documented in `/docs/development/backend.md`)
117+
- **Lint backend (fix):** `npm run backend:lint:fix` (from `/package.json`, documented in `/docs/development/backend.md`)
118+
- **Lint frontend:** `npm run frontend:lint` (from `/package.json`)
119+
- **Lint frontend (fix):** `npm run frontend:lint:fix` (from `/package.json`)
120+
121+
#### Format commands (from `/package.json` and `/docs/development/backend.md`):
122+
- **Format backend:** `npm run backend:format` (from `/package.json`, documented in `/docs/development/backend.md`)
123+
- **Format and lint frontend:** `npm run frontend:lint:fix` (from `/package.json`)
124+
125+
#### Documentation generation (from `/package.json` and `/docs/development/frontend.md`):
126+
- **Generate API docs:** `npm run docs` (from `/package.json`, documented in `/docs/development/frontend.md`)
127+
128+
#### Storybook (from `/package.json` and `/docs/development/frontend.md`):
129+
- **Run Storybook:** `npm run frontend:storybook` (from `/package.json`, documented in `/docs/development/frontend.md`)
130+
- **Build Storybook:** `npm run frontend:build:storybook` (from `/package.json`)
131+
132+
---
133+
134+
### Allowed commands and CI interactions
135+
- **Permitted to suggest/run locally:**
136+
- All npm scripts from `/package.json`
137+
- Go commands: `go build`, `go test`, `go fmt` (documented in `/docs/development/backend.md`)
138+
- Node/npm commands: `npm install`, `npm run build`, `npm run test`, `npm start`
139+
- **Require human approval:**
140+
- Pushing container images (references in `/docs/development/index.md`)
141+
- Publishing releases (process documented in `/docs/development/release-guide.md`)
142+
- Modifying `.github/workflows/*`
143+
- Changing `Dockerfile` or `/Dockerfile.plugins`
144+
- Altering Kubernetes manifests (`kubernetes-headlamp*.yaml`)
145+
- Modifying Helm charts in `/charts/`
146+
- **Reporting CI results:** GitHub Actions workflows in `.github/workflows/` - summarize failing steps, include logs, recommend fixes with local reproduction commands.
147+
148+
---
149+
150+
### Change rules and safety constraints
151+
- **Manual-review-only:**
152+
- `.github/workflows/*` - CI workflows
153+
- `Dockerfile`, `Dockerfile.plugins` - container definitions
154+
- `charts/` - Helm charts
155+
- `kubernetes-*.yaml` - Kubernetes manifests
156+
- `SECURITY.md`, `SECURITY_CONTACTS` - security policy files
157+
- `OWNERS`, `OWNERS_ALIASES` - maintainer lists (documented in `/OWNERS`)
158+
- `LICENSE`, `NOTICE` - license files
159+
- `code-of-conduct.md` - code of conduct
160+
- **Pre-change checks:**
161+
- Run `npm run lint` (from `/package.json`)
162+
- Run `npm test` (from `/package.json`)
163+
- Run `npm run backend:test` for backend changes (from `/package.json`)
164+
- Run `npm run frontend:test` for frontend changes (from `/package.json`)
165+
- Run `npm run backend:format` for backend code formatting (from `/package.json`)
166+
- Run `npm run frontend:lint:fix` for frontend code formatting (from `/package.json`)
167+
- Run TypeScript compiler: `npm run frontend:tsc` (from `/package.json`) or `npm run app:tsc` (from `/package.json`)
168+
- Run e2e tests for UI changes: `npm run app:test:e2e` (from `/package.json`)
169+
- **Dependency updates:**
170+
- Run full test suite: `npm test`
171+
- Tag maintainers from `/OWNERS` (headlamp-maintainers, headlamp-reviewers)
172+
- Do not bump major versions without approval
173+
- **Licenses/copyright:**
174+
- Do not alter `/LICENSE` or `/NOTICE` files
175+
- Do not modify copyright headers
176+
177+
---
178+
179+
### Best practices and coding guidelines
180+
- **Reduce solution size:**
181+
- Make minimal, surgical changes - modify as few lines as possible to achieve the goal
182+
- Prefer focused, single-purpose changes over large refactors
183+
- Break down complex changes into smaller, reviewable increments
184+
- Remove unnecessary code, dependencies, or complexity when fixing issues
185+
- **Testing best practices:**
186+
- Avoid using mocks in tests if possible - prefer testing with real implementations
187+
- Use integration tests over unit tests when it improves test reliability
188+
- Only mock external dependencies (APIs, databases, file systems) when necessary
189+
- Write tests that validate actual behavior, not implementation details
190+
- **Consider best practices for the type of change:**
191+
- **Bug fixes:** Add regression tests, verify the fix doesn't break existing functionality
192+
- **New features:** Follow existing patterns, add comprehensive tests, update documentation
193+
- **Refactoring:** Ensure behavior remains unchanged, validate with existing tests
194+
- **Performance:** Add benchmarks, measure before and after, document improvements
195+
- **Security:** Follow secure coding practices, validate inputs, avoid common vulnerabilities
196+
- **Documentation:** Keep it concise, accurate, and consistent with code examples
197+
- **Frontend-specific guidelines:**
198+
- **Screenshots:** Always include screenshots for UI changes in PRs to show visual impact
199+
- **React components:** Add Storybook stories with error and loading states for new components (use `npm run frontend:storybook`)
200+
- **Formatting:** Run `npm run frontend:lint:fix` to format code before committing
201+
- **End-to-end tests:** For significant UI changes, consider adding or updating e2e tests (`npm run app:test:e2e`)
202+
203+
---
204+
205+
### Examples and templates
206+
207+
#### Example 1: Small frontend code fix
208+
- **Files to change:** `frontend/src/components/Example.tsx` (example path)
209+
- **Rationale:** Fix null-check to avoid runtime error
210+
- **Commands to validate:**
211+
1. `npm run frontend:install` (from `/package.json`)
212+
2. `npm run frontend:lint:fix` (from `/package.json`) - format code
213+
3. `npm run frontend:lint` (from `/package.json`)
214+
4. `npm run frontend:test` (from `/package.json`)
215+
5. `npm run frontend:tsc` (from `/package.json`)
216+
6. `npm run app:test:e2e` (from `/package.json`) - if UI changes
217+
- **Additional requirements:**
218+
- Include screenshots of any UI changes in the PR
219+
- If adding/modifying React components, add Storybook stories with error and loading states
220+
221+
#### Example 2: Backend code fix
222+
- **Files to change:** `backend/pkg/example/handler.go` (example path)
223+
- **Rationale:** Fix error handling in API endpoint
224+
- **Commands to validate:**
225+
1. `npm run backend:build` (from `/package.json`, documented in `/docs/development/backend.md`)
226+
2. `npm run backend:lint` (from `/package.json`, documented in `/docs/development/backend.md`)
227+
3. `npm run backend:test` (from `/package.json`, documented in `/docs/development/backend.md`)
228+
4. `npm run backend:format` (from `/package.json`, documented in `/docs/development/backend.md`)
229+
230+
#### Example 3: Documentation update
231+
- **Files to change:** `docs/development/index.md` (from consulted files list)
232+
- **Rationale:** Clarify local dev startup steps to match current npm scripts
233+
- **Commands to validate:**
234+
- Run the documented commands exactly as written and confirm they succeed
235+
- For doc-only changes, testing commands is sufficient; no build needed
236+
237+
#### Example 4: Plugin development
238+
- **Files to change:** Plugin code in `/plugins/examples/` directory
239+
- **Rationale:** Add new plugin example
240+
- **Commands to validate:**
241+
1. `cd plugins/headlamp-plugin && npm install` (from `/package.json`)
242+
2. Follow plugin testing commands in `/docs/development/plugins/building.md`
243+
244+
---
245+
246+
### PR description & commit message format
247+
248+
Reference: `/docs/contributing.md` and `/.github/pull_request_template.md`
249+
250+
#### Commit message format (from `/docs/contributing.md`):
251+
- **Format:** `<area>: <description of changes>`
252+
- **Examples:**
253+
- `frontend: HomeButton: Fix so it navigates to home`
254+
- `backend: config: Add enable-dynamic-clusters flag`
255+
- **Guidelines:**
256+
- Use atomic commits - keep each commit focused on a single change
257+
- Keep commit titles under 72 characters (soft requirement)
258+
- Commit messages should explain the intention and _why_ something is done
259+
- Commit titles should be meaningful and describe _what_ the commit does
260+
- Use `git rebase` to squash and order commits for easy review
261+
- Do not write "Fixes #NN" issue number in the commit message
262+
263+
#### PR description template (from `/.github/pull_request_template.md`):
264+
- **Summary:** Brief description of what the change does
265+
- **Related Issue:** Link via `Fixes #ISSUE_NUMBER` if applicable
266+
- **Changes:** List of added/updated/fixed components
267+
- **Steps to Test:** Numbered steps to verify the changes
268+
- **Screenshots:** Include for UI changes
269+
- **Notes for the Reviewer:** Any relevant context or areas to focus on
270+
271+
#### PR guidelines (from `/docs/contributing.md`):
272+
- Run tests: `npm run frontend:test`, `npm run backend:test`
273+
- Run linters: `npm run frontend:lint`, `npm run backend:lint`
274+
- Summarize changes and explain _why_ they are needed
275+
- Provide steps to test the changes
276+
- Link to related issue via `Fixes #ISSUE_NUMBER`
277+
278+
---
279+
280+
### Agent output checklist (must pass before creating patch/PR)
281+
- **Summary:** one-line intent and short rationale
282+
- **Sources:** list consulted README/docs file paths with specific line numbers
283+
- **Files changed:** explicit file list with rationale for each
284+
- **Diff/patch:** minimal unified diff showing only necessary changes
285+
- **Tests:**
286+
- List tests added/updated
287+
- Exact commands to run them (from `/package.json`)
288+
- Test results showing pass status
289+
- **Local validation:**
290+
- Exact commands to reproduce build/test results
291+
- Output showing successful execution
292+
- For frontend: verify in browser at `localhost:3000` (from `/docs/development/frontend.md`)
293+
- For backend: verify server starts successfully (from `/docs/development/backend.md`)
294+
- **CI expectations:**
295+
- Which workflows in `.github/workflows/` should pass
296+
- Expected test coverage (documented in `/docs/development/backend.md` lines 60-67)
297+
- **Reviewers:**
298+
- Suggested reviewers from `/OWNERS`: headlamp-maintainers, headlamp-reviewers
299+
- Tag specific maintainers for specialized areas if needed
300+
301+
---
302+
303+
### Appendix
304+
305+
#### All consulted README.md files:
306+
1. `/README.md` - Main project README with overview, features, quickstart
307+
2. `/frontend/README.md` - Frontend module pointer to docs
308+
3. `/backend/README.md` - Backend quickstart with build/run commands
309+
4. `/app/README.md` - Desktop app information
310+
5. `/e2e-tests/README.md` - End-to-end testing guide
311+
6. `/load-tests/README.md` - Load testing with KWOK
312+
7. `/plugins/README.md` - Plugins overview
313+
8. `/plugins/headlamp-plugin/README.md` - Plugin development tools
314+
9. `/plugins/headlamp-plugin/template/README.md` - Plugin template
315+
10. `/plugins/pluginctl/README.md` - Plugin control utility
316+
11. `/backend/pkg/telemetry/README.md` - Telemetry module
317+
12. `/docker-extension/README.md` - Docker extension
318+
13. `/charts/headlamp/README.md` - Helm chart documentation
319+
14. `/backstage-test/README.md` - Backstage integration
320+
15. `/tools/i18n/README.md` - Internationalization tools
321+
16. `/eslint-config/README.md` - ESLint configuration
322+
17. `/frontend/src/i18n/README.md` - Frontend i18n
323+
18. `/app/e2e-tests/README.md` - Desktop app e2e tests
324+
19. Plugin examples in `/plugins/examples/` (activity, app-menus, change-logo, cluster-chooser, custom-theme, customizing-map, details-view, dynamic-clusters, headlamp-events, pod-counter, projects, resource-charts, sidebar, tables, ui-panels)
325+
326+
#### Key documentation files:
327+
1. `/docs/development/index.md` - Primary development guide (lines 1-310)
328+
2. `/docs/development/frontend.md` - Frontend dev guide (lines 1-82)
329+
3. `/docs/development/backend.md` - Backend dev guide (lines 1-69)
330+
4. `/docs/development/testing.md` - Testing guide (lines 1-83)
331+
5. `/docs/development/architecture.md` - System architecture
332+
6. `/docs/development/plugins/index.md` - Plugin system
333+
7. `/docs/development/plugins/building.md` - Building plugins
334+
8. `/docs/development/plugins/getting-started.md` - Plugin quickstart
335+
9. `/docs/development/plugins/publishing.md` - Publishing plugins
336+
10. `/docs/development/plugins/common-patterns.md` - Plugin patterns
337+
11. `/docs/development/i18n/index.md` - Internationalization
338+
12. `/docs/development/release-guide.md` - Release process
339+
13. `/docs/contributing.md` - Contribution guidelines
340+
14. `/docs/faq.md` - FAQ
341+
15. `/docs/platforms.md` - Tested platforms
342+
343+
#### Versioning guidance:
344+
- Follow semantic versioning (documented in `/docs/development/release-guide.md`)
345+
- App version defined in `/app/package.json`
346+
- Docker image version from git tags
347+
- Request maintainer approval for version bumps and releases
348+
- Release process documented in `/docs/development/release-guide.md`
349+
350+
---
351+
352+
## Final instructions for the agent (implementation complete)
353+
1.**Searched the repository** for all `README.md` files and files under `docs/` - listed their relative paths in "Consulted files" section above
354+
2.**Extracted exact commands and versions** from package.json, go.mod, and documentation - replaced all placeholders with exact text and file path citations
355+
3.**Commands are ready for validation** - all commands listed can be run locally following the exact syntax provided
356+
4.**File is ready for commit** - consulted-files list is complete and all placeholders have been replaced with exact commands and paths from the repository
357+
358+
**Version Information:**
359+
- Node.js: >=20.11.1 (from `/package.json`)
360+
- npm: >=10.0.0 (from `/package.json`)
361+
- Go: 1.24.11 (from `/backend/go.mod`)
362+
363+
**Key Command Sources:**
364+
- Build/test commands: `/package.json`
365+
- Development workflow: `/docs/development/index.md`
366+
- Backend specifics: `/docs/development/backend.md`
367+
- Frontend specifics: `/docs/development/frontend.md`

0 commit comments

Comments
 (0)