|
1 | | -# AGENTS.md — TemplateJs |
2 | 1 |
|
3 | | -Canonical instructions for coding agents. Human-facing docs are in `README.md`. |
| 2 | +# Rules |
4 | 3 |
|
5 | | -## Quick facts |
6 | | -- Minimal single-page web app (static HTML + modular JS) |
| 4 | +## General |
| 5 | +- Minimal local first web app (static HTML + modular JS) |
7 | 6 | - Entrypoint: `index.html` (+ static pages in `pages/`) |
8 | | -- Source in `src/` with colocated tests |
9 | | -- Deploy via GitHub Pages from `main` (static assets) |
10 | | -- Preferred dev env: Codespaces (optional) |
11 | | - |
12 | | -## Runbook |
13 | | -- Before commit: `npm run check:all` then `npm test` |
14 | | -- Before PR/release: `npm run validate:all` (tests + checks + mutation) |
15 | | -- Always run commands in a real terminal and include actual output in notes/PRs. |
| 7 | +- Source composed of small, focused modules in `src/` (`components/`, `utils/`, ..) with colocated tests |
| 8 | +- Frequently during development and before each commit: run `npm test` |
| 9 | +- `README.md` typically contains big picture dev. spec and context. It should be kept up to date whenever the code is ready for a PR |
| 10 | +- Static app => serve `index.html` with simple static server (e.g., VS Code Live Server) |
| 11 | +- Only change code directly related to the current task; keep diffs small |
| 12 | +- Preserve existing comments & docs; add concise, long-lived comments where useful and avoid narrating changes via comments |
| 13 | +- When external documentation is needed and you lack a browsing/online search tool, ask the user to run an online search for you (e.g., "Please search for \"x\" and paste back the findings") |
16 | 14 |
|
17 | | -## Build/Serve |
18 | | -- Static app; serve `index.html` with a simple static server (e.g., VS Code Live Server) |
| 15 | +## Dependencies & no-build approach to use |
| 16 | +This project follows a no-build, static workflow: |
| 17 | +- Use native ES modules and `<script type="importmap">` to map bare specifiers when needed. |
| 18 | +- Then load your entry/module scripts with `<script type="module">` and import using the mapped specifiers. |
| 19 | +- Prefer CDN URLs from unpkg.com for third-party modules compatible with ESM. |
| 20 | +- Do not add bundlers/build chains unless explicitly requested in an issue/PR. |
19 | 21 |
|
20 | | -## Tests |
21 | | -- Run all tests: `npm test` |
22 | | -- Tests live near code: `src/**/foo.test.js`, `*.property.test.js` |
| 22 | +## Test layout |
| 23 | +- Unit specs: `*.test.js` |
| 24 | +- Property-based specs: `*.property.test.js` |
| 25 | +- Property-based tests are important, don't omit them for important components |
23 | 26 | - Keep tests deterministic and fast; avoid E2E unless asked |
24 | 27 |
|
25 | | -Failure loop |
26 | | -1) Prefer the simplest fix |
27 | | -2) Make minimal, focused changes |
28 | | -3) Re-run failing tests immediately and include real output |
29 | | -4) Iterate until green |
30 | | - |
31 | | -## Coding guidelines |
32 | | -- Small, focused modules in `src/` (`components/`, `utils/`) |
33 | | -- Keep public HTML under `pages/` stable; don’t break URLs |
34 | | -- Use existing lint/format scripts if present |
35 | | - |
36 | | -## Commits & PRs |
37 | | -- Commits: concise; Conventional Commits preferred (e.g., `feat: add person card`); don’t churn history for formatting |
38 | | -- PRs: small, scoped diffs; explain what you ran (install/tests/validation); add/update tests for changed behavior |
39 | | - |
40 | | -Checklist |
41 | | -- [ ] `npm ci` and `npm run validate:all` pass locally |
42 | | -- [ ] Tests added/updated for new behavior |
43 | | -- [ ] No unrelated refactors/drive-bys |
44 | | -- [ ] PR description includes summary, commands run, brief test output |
45 | | - |
46 | | -## Safety & guardrails |
47 | | -- No secrets (.env/tokens/creds) |
48 | | -- No deploy changes (Pages/release flows) |
49 | | -- Least privilege: prefer read-only changes |
50 | | - |
51 | | -## File map (read before changing code) |
52 | | -- `README.md` |
53 | | -- `package.json` source of truth for commands |
54 | | -- `index.html`, `pages/` static entry points |
55 | | -- `src/` — app code and tests |
56 | | - |
57 | | -## When in doubt — ask before |
58 | | -- Large refactors |
59 | | -- Changing public URLs or Pages config |
| 28 | +## TDD Failure loop to use |
| 29 | +1. Prefer the simplest fix first |
| 30 | +2. Use TDD: Add a failing test first and run `npm test` to verify it's failing |
| 31 | +3. Make minimal, focused changes |
| 32 | +4. Re-run `npm test` after each fix and document real output |
| 33 | +5. Iterate until green |
60 | 34 |
|
61 | | -## Feature development process (for agents) |
| 35 | +## Feature development process to use |
62 | 36 |
|
63 | 37 | Follow this lightweight spec-first flow before coding: |
64 | 38 |
|
65 | 39 | 1) Requirements gathering |
66 | | -- Ask one question at a time and iterate until requirements are complete. |
67 | | -- Build each question on previous answers; prefer numbered response options to keep it structured. |
| 40 | +- Ask one question at a time and iterate until requirements are clear. |
| 41 | +- Build each question on previous answers; prefer 4+ numbered response options for the user to select from. |
| 42 | +- For larger changes: draft a high-level implementation plan and pause for explicit user approval before modifying code. |
68 | 43 |
|
69 | 44 | 2) Specification development |
70 | | -- Major features: capture functional requirements, architecture choices/integration points, data handling (I/O, validation), error handling and edge cases, testing strategy (unit, property-based, integration), and any UI/performance considerations. |
71 | | -- Smaller changes: clearly state what changes, how it integrates, and key edge cases. |
| 45 | +- Smaller changes: clearly state what changes, how it integrates, testing strategy and key edge cases. |
| 46 | +- Major features: capture functional requirements, architecture choices/integration points, data handling (I/O, validation), error handling and edge cases, testing strategy (unit + property-based + integration), and any UI & performance considerations. |
72 | 47 |
|
73 | 48 | 3) Final specification |
74 | | -- Compile a concise developer-ready spec markdown next to new components if any were added |
75 | | - |
76 | | -## Implementation guidelines |
77 | | -- Only change code directly related to the current task; keep diffs small |
78 | | -- Preserve existing comments/docs; add concise, long-lived docs where useful and avoid narrating changes via comments |
79 | | - |
80 | | -## Quality checks |
81 | | -- During development: run frequently |
82 | | - - `npm run check:all` |
83 | | - - `npm test` |
84 | | -- Before PR: `npm run validate:all` (tests + checks + mutation) |
85 | | - |
86 | | -Test structure |
87 | | -- `*.test.js` — unit |
88 | | -- `*.property.test.js` — property-based (fast-check) |
89 | | -- Mutation: `npm run mutation` (CI too); aim >50% |
90 | | - |
91 | | -Failure triage loop |
92 | | -1. Simplest fix first |
93 | | -2. Minimal changes |
94 | | -3. Re-run the specific failing scope |
95 | | -4. Iterate until green |
96 | | - |
97 | | -Verification discipline |
98 | | -- Only claim pass/fail with real command output |
99 | | - |
100 | | -## Dependencies & no-build approach |
101 | | - |
102 | | -This project follows a no-build, static workflow: |
103 | | -- Use native ES modules and `<script type="importmap">` to map bare specifiers when needed. |
104 | | -- Then load your entry/module scripts with `<script type="module">` and import using the mapped specifiers. |
105 | | -- Prefer CDN URLs from unpkg.com for third-party modules compatible with ESM. |
106 | | -- Do not add bundlers/build chains unless explicitly requested in an issue/PR. |
| 49 | +- Compile a concise developer-ready spec markdown next to new components if any were added. Include as a first line a summary that could also be used as a commit message for the change. |
0 commit comments