Skip to content

Commit 670d04f

Browse files
authored
docs(AGENTS.md): refine (#1251)
1 parent dcd495a commit 670d04f

File tree

2 files changed

+44
-12
lines changed

2 files changed

+44
-12
lines changed

AGENTS.md

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,52 @@
11
# Repository guidelines
22

3+
## Setup environment
4+
5+
1. Install [fnm](https://github.com/Schniz/fnm) and run `fnm install`/`fnm use` to match the Node.js version in `.nvmrc` (`v24.5.0`).
6+
2. Enable Corepack (`corepack enable`) and then activate pnpm via `corepack prepare` (the pnpm version is specified in `packageManager` field in `package.json`).
7+
3. Clone the repository and install dependencies with `pnpm install` from the repository root.
8+
39
## Project structure & module organization
410

5-
- Monorepo via `pnpm` + `Nx`.
6-
- Packages: `packages/core` (CLI + `@rslib/core`), `packages/plugin-dts` (DTS plugin), `packages/create-rslib` (scaffolder).
7-
- Tests: `packages/*/tests` (unit) and `tests/` (`integration`, `e2e`, `benchmark`); examples in `examples/`.
8-
- Key config: `nx.json`, `biome.json`, `.prettierrc.json`, `rslint.jsonc`, `pnpm-workspace.yaml`.
11+
- Monorepo via the `pnpm` workspace.
12+
- `packages/core` (`@rslib/core`): CLI entry (`rslib build`, `--watch`) and programmatic helpers (`build`, `defineConfig`, `loadConfig`).
13+
- `packages/plugin-dts` (`rsbuild-plugin-dts`): provides the `dts` configuration hook (e.g., `{ dts: { bundle: true } }`).
14+
- `packages/create-rslib` (`create-rslib`): scaffolds new projects via `pnpm dlx create-rslib` or `npx create-rslib`.
15+
- Tests live in `packages/*/tests` (unit) and `tests/` (`integration`, `e2e`, `benchmark`); examples in `examples/`.
16+
- Key configuration files: `nx.json`, `biome.json`, `.prettierrc.json`, `rslint.jsonc`, `pnpm-workspace.yaml`.
917

1018
## Build, test, and development commands
1119

12-
- Install: `pnpm install` (Node >= 18.12, pnpm >= 10.15).
20+
- Install: `pnpm install` (all packages will be built in postinstall).
1321
- Build: `pnpm build` (all) and `pnpm build:examples`.
1422
- Watch dev: `pnpm -C packages/core dev` (or other package).
1523
- Lint/format: `pnpm lint`; auto-fix: `pnpm format`.
1624
- Type-check: `pnpm type-check`.
17-
- Tests: `pnpm test`; targeted: `test:unit|:integration|:e2e|:benchmark`; update snapshots: `pnpm testu`.
25+
- Tests:
26+
- `pnpm test` runs the entire suites.
27+
- `pnpm test:unit` scopes to unit tests.
28+
- `pnpm test:integration` scopes to integration tests; add `<pattern>` to match specific cases.
29+
- `pnpm test:e2e` runs end-to-end tests.
1830

1931
## Coding style & naming conventions
2032

2133
- TypeScript + ESM; spaces; single quotes.
2234
- Biome is canonical linter/formatter; Prettier formats MD/CSS/JSON and `package.json`.
35+
- Run `pnpm biome check --write --unsafe` on modified source files; when `package.json` changes, also run `prettier --write package.json`.
2336
- Filenames: `camelCase` or `PascalCase` (Biome enforced).
2437

2538
## Testing guidelines
2639

2740
- Unit/integration: `@rstest/core`; E2E: `@playwright/test`.
2841
- Naming: `*.test.ts`/`*.test.tsx`; snapshots in `__snapshots__/`.
2942
- Placement: unit under `packages/*/tests`; integration under `tests/integration`; e2e under `tests/e2e`.
43+
- Target specific integration cases: `pnpm test:integration <pattern>` (faster than the full suite).
3044

3145
## Commit & pull request guidelines
3246

3347
- Conventional Commits (e.g., `fix(dts): ...`); keep commits focused; run lint + tests.
3448
- User-facing changes need a Changeset (`pnpm changeset`); PRs should include description, linked issues, and doc/example updates when needed.
3549

36-
## Architecture overview
37-
38-
- `packages/core` (`@rslib/core`): CLI `rslib build` (add `--watch`), config via `rslib.config.ts` using `defineConfig`; programmatic `import { build, defineConfig, loadConfig } from '@rslib/core'`.
39-
- `packages/plugin-dts` (`rsbuild-plugin-dts`): detail implementation of `dts` in `rslib.config.ts` (e.g., `{ dts: { bundle: true } }`);
40-
- `packages/create-rslib` (`create-rslib`): scaffold new projects/templates with `pnpm dlx create-rslib` (or `npx create-rslib`).
41-
4250
## Security & configuration tips
4351

4452
- Do not commit build artifacts (`dist/`, `compiled/`).

packages/create-rslib/AGENTS.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Package guidelines — create-rslib
2+
3+
This guide extends the repository instructions in `../../AGENTS.md`. Refer there for workspace setup, tooling versions, and global workflows.
4+
5+
## Package overview
6+
7+
- `create-rslib` provides the `pnpm create rslib` scaffolding CLI shipped from `dist/`.
8+
- Author source changes under `src/`; treat `dist/` as build output regenerated via `pnpm -C packages/create-rslib build`.
9+
- Template inputs live in `fragments/`; generated scaffolding blueprints are the `template-*` directories.
10+
- Tests in `test/` use `@rstest/core` to exercise CLI flows and validate generated projects.
11+
12+
## Common commands
13+
14+
- Build once before testing locally: `pnpm -C packages/create-rslib build`.
15+
- Watch rebuild during development: `pnpm -C packages/create-rslib dev`.
16+
- Regenerate template directories after touching fragments or generators: `pnpm -C packages/create-rslib generate-templates`.
17+
- Run package tests: `pnpm -C packages/create-rslib test`; the repo-level `pnpm test:unit` also covers this package.
18+
19+
## Working on templates
20+
21+
- Add or update base files in `fragments/base/*` and tool overlays in `fragments/tools/*`; keep naming aligned with `src/helpers.ts`.
22+
- Update `TEMPLATES` in `src/helpers.ts` whenever you introduce a new template combination so the CLI prompts and tests remain exhaustive.
23+
- Treat `template-*` directories as generated output from `pnpm -C packages/create-rslib generate-templates`; keep changes reproducible by updating generators in `src/` or fragments under `fragments/` instead of editing the generated files directly.
24+
- Keep dependency versions aligned across all `template-*` directories; when one template upgrades a shared dependency, update the others via fragments or generators to match.

0 commit comments

Comments
 (0)