Skip to content

Commit bbbcdef

Browse files
authored
docs: refresh root agent guide (#2072)
## Summary Refresh the root `AGENTS.md` guidance to match the current repository structure and test workflow. - Remove stale references to the deleted `packages/test` package and document that `vite-plus/test*` is now generated from upstream Vitest shims in `packages/cli`. - Update the repository map with current crates and package ownership. - Clarify that new CLI snapshot coverage should use the PTY-based runner introduced in #2052, while legacy snap-test trees are migration-only. - Update validation guidance and references for the current snapshot test commands.
1 parent 603140d commit bbbcdef

1 file changed

Lines changed: 37 additions & 27 deletions

File tree

AGENTS.md

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,33 @@ High-signal repo map:
2222

2323
```
2424
vite-plus/
25-
├── packages/cli/ # Published vite-plus package, JS CLI, docs, templates, snap tests, NAPI binding
25+
├── packages/cli/ # Published vite-plus package, JS CLI, docs, templates, legacy snap tests, NAPI binding
2626
│ ├── src/bin.ts # JS entrypoint and local CLI dispatch
27+
│ ├── src/resolve-test.ts # Resolves upstream Vitest for `vp test`
2728
│ ├── src/utils/agent.ts # Generated agent-file marker/update logic
2829
│ ├── binding/ # Rust NAPI binding used by the local CLI
29-
│ ├── snap-tests/ # Local CLI output snapshots
30-
│ └── snap-tests-global/ # Global CLI output snapshots
31-
├── packages/core/ # @voidzero-dev/vite-plus-core bundled toolchain surfaces
32-
├── packages/test/ # @voidzero-dev/vite-plus-test Vitest-compatible exports
33-
├── packages/prompts/ # Prompt UI/helpers package
34-
├── packages/tools/ # Repo tooling
35-
├── crates/vite_cli_snapshots/ # PTY snapshot test runner + vpt helper (dev-only, new CLI tests)
30+
│ ├── snap-tests/ # Legacy local CLI output snapshots
31+
│ └── snap-tests-global/ # Legacy global CLI output snapshots
32+
├── packages/core/ # @voidzero-dev/vite-plus-core bundled Vite/Rolldown/tsdown/VitePress surfaces
33+
├── packages/prompts/ # Prompt UI/helpers package, including snapshot milestones
34+
├── packages/tools/ # Repo tooling, local npm registry, legacy snap migrator
35+
├── crates/vite_cli_snapshots/ # PTY snapshot test runner + vpt helper (new CLI tests)
36+
├── crates/vite_command/ # Shared command execution helpers
37+
├── crates/vite_error/ # Shared error types
3638
├── crates/vite_global_cli/ # Standalone global vp binary and top-level command routing
37-
├── crates/vite_pm_cli/ # Package-manager command surface
3839
├── crates/vite_install/ # Package-manager detection/install behavior
40+
├── crates/vite_installer/ # Installer binary support
3941
├── crates/vite_js_runtime/ # Managed Node.js runtime support
42+
├── crates/vite_migration/ # Rust migration helpers
43+
├── crates/vite_pm_cli/ # Package-manager command surface
44+
├── crates/vite_setup/ # Setup helpers
45+
├── crates/vite_shared/ # Shared Rust env config, tracing, output, utilities
4046
├── crates/vite_static_config/ # Static extraction of vite.config.* data
41-
└── crates/vite_shared/ # Shared Rust env config, tracing, output, utilities
47+
└── crates/vite_trampoline/ # Windows shim trampoline
4248
```
4349

50+
`packages/test` is no longer tracked. The public test API is `vite-plus/test*`, generated by `packages/cli/build.ts` as shims over upstream `vitest` and `@vitest/browser*` exports.
51+
4452
## Where to Start
4553

4654
- **JS-backed CLI behavior**: start at `packages/cli/src/bin.ts` and nearby `packages/cli/src/**` files.
@@ -51,10 +59,10 @@ vite-plus/
5159
- **Static `vite.config.ts` extraction**: start at `crates/vite_static_config/README.md` and `packages/cli/src/resolve-vite-config.ts`.
5260
- **Migration behavior**: `docs/guide/migrate-rules.md`.
5361
- **Migrator code (`vp migrate`)**: category modules under `packages/cli/src/migration/migrator/` behind the `migrator.ts` barrel; follow `migrator/README.md` when changing migrator code.
54-
- **Bundled toolchain surfaces**: start with `packages/core/BUNDLING.md`, `packages/cli/BUNDLING.md`, and `packages/test/BUNDLING.md`.
62+
- **Bundled toolchain surfaces**: start with `packages/core/BUNDLING.md` and `packages/cli/BUNDLING.md`.
5563
- **Generated project agent guidance**: `packages/cli/AGENTS.md` and `packages/cli/src/utils/agent.ts`; do not edit these when the task is only to improve root repo guidance.
5664
- **Product/repo docs**: root contributor docs live at the repo root and the VitePress site under `docs/` (`docs/guide/`, `docs/config/`); generated agent guidance is separate.
57-
- **CLI output behavior**: inspect the relevant code plus `crates/vite_cli_snapshots/tests/cli_snapshots/` (new PTY snapshot suite; write new cases here) or the legacy `packages/cli/snap-tests/` / `packages/cli/snap-tests-global/` trees.
65+
- **CLI output behavior**: inspect the relevant code plus `crates/vite_cli_snapshots/tests/cli_snapshots/` (PTY snapshot suite; write new cases here). Legacy `packages/cli/snap-tests/` and `packages/cli/snap-tests-global/` are migration-only.
5866
- **Interactive CLI testing (prompts, pickers, keystrokes)**: `crates/vite_cli_snapshots/tests/cli_snapshots/README.md` and `rfcs/interactive-snapshot-tests.md`.
5967
- **Install-testing against the local build**: `packages/tools/src/local-npm-registry.ts` serves the packed checkout behind a real registry interface; used by install snap fixtures (`localVitePlusPackages`), ecosystem e2e (`ecosystem-ci/patch-project.ts`), and local `vp migrate`/`vp create` iteration (see `CONTRIBUTING.md`).
6068

@@ -65,7 +73,7 @@ vite-plus/
6573
```bash
6674
vp dev # Vite dev server
6775
vp build # Vite + Rolldown build
68-
vp test # Bundled Vitest
76+
vp test # Bundled upstream Vitest
6977
vp lint # Oxlint
7078
vp fmt # Oxfmt
7179
vp check # Format/lint/type-check workflow
@@ -77,7 +85,8 @@ vpr build # Shorthand for vp run build
7785

7886
Important distinctions:
7987

80-
- `vp test` is a built-in command. `vp run test` runs a `package.json` script or `vite.config.ts` run task named `test`.
88+
- `vp test` is a built-in command that executes upstream Vitest. `vp run test` runs a `package.json` script or `vite.config.ts` run task named `test`.
89+
- User-facing test imports should stay on `vite-plus/test*`; do not recreate `@voidzero-dev/vite-plus-test`.
8190
- Existing `package.json` scripts are first-class `vp run <script>` targets and are not cached by default.
8291
- Define `run.tasks` in `vite.config.ts` when a task needs explicit command config, default caching, dependencies, input tracking, or environment tracking.
8392
- A task name can come from `package.json` or `vite.config.ts`, but not both.
@@ -108,15 +117,15 @@ Use `pnpm bootstrap-cli` when you need to validate the installed global CLI at `
108117

109118
Choose checks by change type:
110119

111-
| Change type | Useful validation |
112-
| ----------------------------- | ---------------------------------------------------------------------------------------------------- |
113-
| Docs-only / agent-guide edits | Check referenced paths and commands; run `git diff --check -- <files>` |
114-
| TypeScript or JS CLI behavior | `vp check`, `pnpm test:unit`, plus focused package tests when available |
115-
| Rust CLI/crate behavior | `just check`, `just test`, `just lint` |
116-
| CLI output or command UX | `just snapshot-test <filter>` (new PTY runner); legacy snap tests + `git diff` while migration lasts |
117-
| Global CLI behavior | `pnpm bootstrap-cli`, `vp --version`, then relevant global snap tests |
118-
| Release/build behavior | `just build` |
119-
| Pre-merge/full validation | `pnpm bootstrap-cli && pnpm test && git status` |
120+
| Change type | Useful validation |
121+
| ----------------------------- | ------------------------------------------------------------------------------------------- |
122+
| Docs-only / agent-guide edits | Check referenced paths and commands; run `git diff --check -- <files>` |
123+
| TypeScript or JS CLI behavior | `vp check`, `pnpm test:unit`, plus focused package tests when available |
124+
| Rust CLI/crate behavior | `just check`, `just test`, `just lint` |
125+
| CLI output or command UX | `just snapshot-test <filter>` (PTY runner); `UPDATE_SNAPSHOTS=1` to accept reviewed changes |
126+
| Global CLI behavior | `pnpm bootstrap-cli`, `vp --version`, or `just snapshot-test-global <filter>` |
127+
| Release/build behavior | `just build` |
128+
| Pre-merge/full validation | `pnpm bootstrap-cli && pnpm test && git status` |
120129

121130
Use `vp check --fix` only when you intentionally want formatting or lint fixes applied.
122131

@@ -127,14 +136,15 @@ Use `vp check --fix` only when you intentionally want formatting or lint fixes a
127136
```bash
128137
just snapshot-test # build vp, run everything
129138
just snapshot-test <name-filter>
139+
just snapshot-test-global <name-filter> # skip local flavor when no JS build is available
130140
UPDATE_SNAPSHOTS=1 just snapshot-test <name-filter> # record/accept snapshots
131141
```
132142

133-
Snapshot mismatches fail the run with a unified diff and write `<case>.md.new`; recorded `.md` snapshots are reviewed like code and committed with the fixture. Steps are argv arrays (no shell); use `vpt` subcommands instead of coreutils so cases stay platform-identical.
143+
Snapshot mismatches fail the run with a unified diff and write `<case>.md.new`; recorded `.md` snapshots are reviewed like code and committed with the fixture. Steps are argv arrays (no shell); use `vpt` subcommands instead of coreutils so cases stay platform-identical. Cases declare `vp = "local" | "global" | ["local", "global"]`; local-flavor cases require a fresh `packages/cli/dist`.
134144

135145
### Snap tests (legacy, being migrated)
136146

137-
The old trees `packages/cli/snap-tests/` and `packages/cli/snap-tests-global/` still run in CI during the migration but must not receive new cases; convert them with `tool migrate-snap-tests` instead (see the runner README).
147+
The old trees `packages/cli/snap-tests/` and `packages/cli/snap-tests-global/` still run in CI during the migration but must not receive new cases; convert them with `node packages/tools/src/bin.js migrate-snap-tests ...` instead (see the runner README).
138148

139149
```bash
140150
pnpm -F vite-plus snap-test
@@ -173,7 +183,7 @@ Use the validation matrix above as the source of truth. For behavior-bearing cha
173183
## Common Pitfalls
174184

175185
- **Treating Vite+ as only Vite Task**: Vite Task is integrated, but this repo spans CLI, runtime, package management, bundled packages, create/migrate, docs, and upstream integration.
176-
- **Looking for local `crates/vite_task`**: it does not exist here. Check `Cargo.toml` for git dependency wiring.
186+
- **Looking for local `packages/test` or `crates/vite_task`**: neither is tracked here. Check `packages/cli/BUNDLING.md` for test shims and `Cargo.toml` for Vite Task git dependency wiring.
177187
- **Confusing built-ins with scripts**: `vp test` and `vp run test` can do different things.
178188
- **Trusting snap-test exit status alone**: always inspect snapshot diffs.
179189

@@ -203,5 +213,5 @@ Use the validation matrix above as the source of truth. For behavior-bearing cha
203213
- Run config: `docs/config/run.md`
204214
- CLI package architecture: `packages/cli/BUNDLING.md`
205215
- Core package architecture: `packages/core/BUNDLING.md`
206-
- Test package architecture: `packages/test/BUNDLING.md`
216+
- CLI snapshot runner: `crates/vite_cli_snapshots/tests/cli_snapshots/README.md`
207217
- Generated agent guidance: `packages/cli/AGENTS.md`, `packages/cli/src/utils/agent.ts`

0 commit comments

Comments
 (0)