|
| 1 | +# Architecture |
| 2 | + |
| 3 | +This repository has four main content layers: |
| 4 | + |
| 5 | +1. `snippets/` |
| 6 | +Source of truth for executable JavaScript snippets. Each category contains the browser-console code that users and agents run. |
| 7 | + |
| 8 | +2. `pages/` |
| 9 | +Human-facing MDX documentation published by the Nextra site. Most pages document one snippet or a related set of snippets. Editorial pages can be declared with frontmatter such as `type: guide`. |
| 10 | + |
| 11 | +3. `skills/` |
| 12 | +Generated Agent Skills built from `snippets/` and `pages/`. These files are not the authoring source. Regenerate them with `npm run generate-skills`. |
| 13 | + |
| 14 | +4. `dist/` |
| 15 | +Generated readable artifacts for external consumption. These are also derived outputs, not source files. |
| 16 | + |
| 17 | +## Build Flow |
| 18 | + |
| 19 | +The normal flow is: |
| 20 | + |
| 21 | +`snippets/` + `pages/` -> `scripts/generate-skills.js` -> `skills/` + `dist/` |
| 22 | + |
| 23 | +Supporting files: |
| 24 | + |
| 25 | +- `lib/snippets-registry.js` powers site-level snippet metadata and imports. |
| 26 | +- `pages/**/_meta.json` defines sidebar navigation for each section. |
| 27 | +- `scripts/check-consistency.js` validates source-to-doc parity, editorial page declarations, `_meta.json` alignment, and published counts. |
| 28 | + |
| 29 | +## Source of Truth |
| 30 | + |
| 31 | +Treat these as editable source: |
| 32 | + |
| 33 | +- `snippets/` |
| 34 | +- `pages/` |
| 35 | +- `pages/**/_meta.json` |
| 36 | +- `lib/snippets-registry.js` |
| 37 | +- `README.md` |
| 38 | +- `SKILLS.md` |
| 39 | + |
| 40 | +Treat these as generated or derivative: |
| 41 | + |
| 42 | +- `skills/` |
| 43 | +- `dist/` |
| 44 | + |
| 45 | +## Common Contributor Workflow |
| 46 | + |
| 47 | +1. Edit or add a snippet in `snippets/`. |
| 48 | +2. Add or update its documentation in `pages/`. |
| 49 | +3. Update the relevant `_meta.json`. |
| 50 | +4. Run `npm run generate-skills` when you intentionally want to refresh derived artifacts. |
| 51 | +5. Run `npm run check:consistency`. |
| 52 | +6. Run `npm run lint` and `npm run build`. |
| 53 | + |
| 54 | +## When To Regenerate Skills |
| 55 | + |
| 56 | +Run `npm run generate-skills` whenever you change: |
| 57 | + |
| 58 | +- Any file in `snippets/` |
| 59 | +- Any MDX page used to build skill descriptions or thresholds |
| 60 | +- `package.json` version or metadata that should propagate to generated skills |
| 61 | + |
| 62 | +## Release Relationship |
| 63 | + |
| 64 | +Release packaging reads from generated `skills/`, so stale generated files can leak into release artifacts. Before a release, verify generation explicitly with: |
| 65 | + |
| 66 | +- `npm run check:consistency` |
| 67 | +- `npm run generate-skills:check` |
0 commit comments