Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions skills/rsdoctor-analysis/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,23 @@ Response order (required): High-Priority Issues -> Proposed Solutions -> Optiona
3. If data exists, skip all plugin version/config/build generation logic. Update cache when useful.
4. If data is missing, stop analysis: do not run `rsdoctor-agent` analysis commands, do not run the Analysis Gate, and either ask for the data path or run the Generation Gate below only when setup/generation is required.
5. After a real data file exists, run Analysis Gate at most once before the first `rsdoctor-agent` data-fetch command: verify global `@rsdoctor/agent-cli` with `npm view @rsdoctor/agent-cli version` and `rsdoctor-agent --version`; install latest only if missing/outdated, a version-related error occurs, or the user asks to refresh.
6. Fetch only the Default Evidence Set first; run independent fetches in parallel when possible.
7. Run the ROI Triage Gate below before selecting deep-dive commands or recommendations. Use it to rank issue categories by measured impact, then synthesize findings in the required response order.
6. Discover compilers before analysis with `rsdoctor-agent compilers list --data-file <path>`, then follow the Compiler selection rules below.
7. For each selected compiler, fetch only the Default Evidence Set first; run independent fetches in parallel when possible. Pass that compiler's `--compiler <name>` to every data-fetch command in its evidence pass.
8. Run the ROI Triage Gate below before selecting deep-dive commands or recommendations. Use it to rank issue categories by measured impact, then synthesize findings in the required response order.

Performance rules: parallelize independent checks, cache only derived facts (`dataFile`, `dataFileMtime`, `pluginName`, `pluginVersion`, dependency/config/plugin modification times), and invalidate cache when paths disappear, modification times change, the user asks to refresh, or cached values fail. Speculative plugin checks must not trigger generation; use them only after confirming the data file is missing.

## Compiler selection

Treat compiler discovery as the first data query, not part of the parallel evidence fetch:

- If the report has one named compiler, use its exact `name` for the entire analysis.
- If the report has multiple compilers, resolve each target named by the user to an exact compiler name. When the request identifies a target such as client, server, or worker but does not match an exact name, map it only when the discovery result makes the match unambiguous; if no target is given or a match is ambiguous, ask the user to choose from the returned names.
- If a legacy report returns one compiler with `name: null`, omit `--compiler`.
- For a single-compiler analysis, keep the same selected compiler across the Default Evidence Set and all follow-up queries. If the user explicitly requests cross-compiler analysis, select each requested compiler using the rules above (or all returned compilers when the user requests all), run a separate evidence pass with its own `--compiler <name>`, then compare clearly labeled results. Never mix results from different compilers within a pass.
- For local JSON evidence in each pass, including E1001/E1002 summaries, read only the selected compiler entry's resolved data file returned by `compilers list`. Do not read the originally supplied aggregate or index file as compiler-scoped evidence.
- Before fetching evidence, verify that every selected compiler's `available` field is `true`. If any is false, ask the user to restore or regenerate that compiler data file.

## ROI triage gate

Before recommending fixes, classify the current build into broad cost buckets and choose the highest-ROI lever from evidence, not intuition. This gate is generic for Rspack/Webpack projects; do not use framework-specific runtime layers unless the user's project exposes them in the data.
Expand Down Expand Up @@ -84,7 +96,7 @@ Default Evidence Set:

Scope rules:

- Use `rsdoctor-agent` for bundle data access only after `rsdoctor-data.json` exists; prefer parallel independent fetches; bound output with `--filter`, pagination, and `--limit`.
- Use `rsdoctor-agent` for bundle data access only after `rsdoctor-data.json` exists; prefer parallel independent fetches; bound output with `--filter`, pagination, and `--limit`. After discovery, pass the compiler selected for that evidence pass as `--compiler <name>` to every direct command and `query` call; omit it only for a legacy report whose discovered name is `null`.
Comment thread
yifancong marked this conversation as resolved.
- Default analysis stays within the Default Evidence Set. For non-default analysis, choose minimal fields from [references/rsdoctor-data-types.md](references/rsdoctor-data-types.md) and patterns from [references/common-analysis-patterns.md](references/common-analysis-patterns.md).
- Treat chain tracing, broad commands, optimization edits, splitChunks experiments, and build re-runs as opt-in follow-ups that require user confirmation.
- For duplicate packages and tree-shaking issues, identify issues first; trace reference/import chains only after user confirmation.
Expand All @@ -111,6 +123,9 @@ Recovery rules:
- `rsdoctor-data.json` missing: do not run `rsdoctor-agent`; ask for the data path or run Generation Gate, then use the matching install reference if setup is needed.
- Command not found: run Analysis Gate, then retry with `rsdoctor-agent`.
- `query` reports unknown tool: run `list` and use a catalog tool name, or switch to direct `<group> <subcommand>` mode.
- `COMPILER_REQUIRED`: run `compilers list`, select the requested compiler or compilers using the rules above, and retry each evidence pass consistently with its own `--compiler`.
- `COMPILER_NOT_FOUND`: refresh the compiler list and use an exact returned name; do not guess from `displayName`.
- `COMPILER_DATA_NOT_FOUND`: ask the user to restore or regenerate the selected compiler data file.
- JSON read error: verify file path, JSON validity, and permissions.
- Run installs, builds, version checks, and `rsdoctor-agent...` commands only in the host's authorized command environment when it has the required project, dependency, and network access. If the available environment lacks that access, stop and ask the user instead of attempting to bypass the sandbox or permission boundary. Clearly identify the missing permission or access; if an Rsdoctor dependency must be installed, tell the user which dependency is required and provide the appropriate package-manager command for them to run.

Expand Down
11 changes: 10 additions & 1 deletion skills/rsdoctor-analysis/references/command-map.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Top-level command mode:

`query` catalog (current):

- `compilers_list`
- `chunks_list`
- `packages_direct_dependencies`
- `packages_duplicates`
Expand All @@ -29,10 +30,18 @@ Option scopes:
- `--data-file <path>`:
- required for `query`, direct `<group> <subcommand>`, and `ai <group> <subcommand>`
- not required for `list`, `ai --describe`, `ai --schema`
- `--compiler <name>`: exact compiler name returned by `compilers list`; pass the compiler selected for that evidence pass to every analysis command when the report contains named compiler metadata
- `--input <json>`: optional for `query`
- `--filter <...>`: supported by every data-fetch function; use it to return only required fields selected from `@rsdoctor/types` / [rsdoctor-data-types.md](rsdoctor-data-types.md)
- `--compact`: add whenever possible to keep CLI JSON compact. Do not use it with `tree-shaking retained-modules`; use `--filter` and `--limit` instead.

## Compilers

- `compilers list --data-file <path>` -> Discover compiler names, resolved data files, and availability before fetching analysis evidence. Tool name: `compilers_list`.
- A single named compiler is selected automatically by the CLI, but still use its exact name consistently after discovery. For a single-compiler analysis of a multi-compiler report, select one according to the user's target and pass `--compiler <name>` to every direct command or `query` call in that evidence pass.
- A legacy report appears as one entry with `name: null`; omit `--compiler` for that report.
- For an explicit cross-compiler comparison, run separate evidence passes with each requested compiler's name, then compare clearly labeled results. Do not mix compiler results within a pass.

## Chunks

- `chunks list` -> List all chunks. Pagination: `--page-number`, `--page-size`
Expand Down Expand Up @@ -81,7 +90,7 @@ Option scopes:
## Errors

- `errors list` -> All errors and warnings
- `errors by-code --code <code>` -> Filter by code. For default E1001/E1002 summaries, prefer local JSON summarization.
- `errors by-code --code <code>` -> Filter by code. For default E1001/E1002 summaries, prefer local JSON summarization from the selected compiler entry's resolved data file in `compilers list`, never from the aggregate or index file.
- `errors by-level --level <level>` -> Filter by level

## Rules
Expand Down
Loading