Skip to content
Draft
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
20 changes: 17 additions & 3 deletions skills/rsdoctor-analysis/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,22 @@ 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. Fetch only the Default Evidence Set first; run independent fetches in parallel when possible. Pass the selected `--compiler <name>` to every data-fetch command.
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, use the compiler explicitly named by the user. When the request identifies a target such as client, server, or worker but does not match an exact compiler name, map it only when the discovery result makes the match unambiguous; otherwise ask the user to choose from the returned names.
- If a legacy report returns one compiler with `name: null`, omit `--compiler`.
- Never combine or compare compiler results unless the user explicitly requests cross-compiler analysis. Keep the same selected compiler across the Default Evidence Set and all follow-up queries.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Define per-compiler passes for explicit comparisons

When the user explicitly requests a cross-compiler comparison, the first sentence permits combining results, but the next sentence requires keeping one selected compiler across every evidence and follow-up query. Following that instruction means the agent never fetches evidence for the second compiler and cannot perform the requested comparison. Specify that comparison requests run separate, consistent evidence passes for each selected compiler before comparing the results.

Useful? React with 👍 / 👎.

- Before fetching evidence, verify the selected compiler's `available` field is `true`. If it 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 +95,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 selected `--compiler <name>` to every direct command and `query` call; omit it only for a legacy report whose discovered name is `null`.
- 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 +122,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 one compiler using the rules above, and retry consistently with `--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
9 changes: 9 additions & 0 deletions 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 it 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 multiple compilers, select one according to the user's target and pass `--compiler <name>` to every direct command or `query` call.
- A legacy report appears as one entry with `name: null`; omit `--compiler` for that report.
- Do not merge results from different compilers unless the user explicitly asks for cross-compiler analysis.

## Chunks

- `chunks list` -> List all chunks. Pagination: `--page-number`, `--page-size`
Expand Down