@rsdoctor/docs 1.5.9 → 1.5.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,6 +5,7 @@ import { PackageManagerTabs } from '@theme';
5
5
  To help AI better understand Rsdoctor's features, configuration, and best practices so it can provide more accurate assistance during day-to-day development and troubleshooting, Rsdoctor provides the following capabilities:
6
6
 
7
7
  - [Agent Skills](#agent-skills)
8
+ - [Agent CLI](#agent-cli)
8
9
  - [MCP Server](#mcp-server)
9
10
  - [llms.txt](#llmstxt)
10
11
  - [Markdown docs](#markdown-docs)
@@ -31,6 +32,87 @@ After installation, simply use natural language prompts to trigger the skill, fo
31
32
  Use Rsdoctor to analyze this project and provide optimization suggestions
32
33
  ```
33
34
 
35
+ ## Agent CLI
36
+
37
+ [`@rsdoctor/agent-cli`](https://github.com/web-infra-dev/rsdoctor/tree/main/packages/agent-cli) is a command-line tool for Agents. It reads Rsdoctor build analysis data and outputs structured JSON, making it easier for Agents to search, filter, and analyze the results.
38
+
39
+ It is typically used together with the [rsdoctor-analysis](https://github.com/rstackjs/agent-skills#rsdoctor-skills) skill: first use the skill to guide the project through Rsdoctor build analysis, then use Agent CLI to query the generated analysis data.
40
+
41
+ - Install it in your project (optional, because the skill can automatically install this dependency globally):
42
+
43
+ <PackageManagerTabs command="add -D @rsdoctor/agent-cli" />
44
+
45
+ - The main `rsdoctor-agent` commands include:
46
+
47
+ ```bash
48
+ rsdoctor-agent --help
49
+ rsdoctor-agent --version
50
+ rsdoctor-agent list
51
+ rsdoctor-agent query <tool-name> --data-file <path> [--input <json>]
52
+ rsdoctor-agent <group> <subcommand> --data-file <path>
53
+ ```
54
+
55
+ **Description:**
56
+
57
+ - `rsdoctor-agent --help`: Show command help, including available subcommands, argument descriptions, and examples.
58
+ - `rsdoctor-agent --version`: Show the current `@rsdoctor/agent-cli` package version.
59
+ - `rsdoctor-agent list`: List the currently available direct grouped subcommands (for example, `group subcommand` / `group.subcommand`) for interactive use. This output is not the same as the catalog `<tool-name>` values used by `query`.
60
+ - `rsdoctor-agent query <tool-name> --data-file <path> [--input <json>]`: Invoke a specified catalog tool and return the result.
61
+ - `<tool-name>`: The catalog tool name to invoke, for example `packages_duplicates`.
62
+ - `--data-file <path>`: Path to the Rsdoctor analysis data file (required).
63
+ - `[--input <json>]`: Optional extra input passed to the tool (JSON string).
64
+ - `rsdoctor-agent <group> <subcommand> --data-file <path>`: Run grouped commands directly for interactive analysis.
65
+
66
+ ### Execution examples
67
+
68
+ - Skill execution example:
69
+ - Prompt: `Use rsdoctor to help me do bundle analysis to see from which aspects the product volume can be optimized.`
70
+
71
+ <img
72
+ src="https://assets.rspack.rs/others/assets/rsdoctor/agent-cli-2.gif"
73
+ style={{ margin: 'auto' }}
74
+ />
75
+ <br />
76
+
77
+ As shown in the animation above, the AI tool runs the corresponding `@rsdoctor/agent-cli` commands based on the Rsdoctor skill, retrieves the required data, and outputs optimization suggestions after consolidating the analysis. It also provides a deeper follow-up analysis plan, so you can follow the guidance to further investigate project build issues.
78
+
79
+ <br />
80
+
81
+ <img
82
+ src="https://assets.rspack.rs/others/assets/rsdoctor/agent-cli-next.png"
83
+ style={{ margin: 'auto' }}
84
+ />
85
+ <br />
86
+
87
+ - Command example (triggered by skill execution):
88
+
89
+ ```bash
90
+ # Build optimize with side-effects pagination tuned for analysis
91
+ rsdoctor-agent bundle optimize --data-file ./dist/rsdoctor-data.json --side-effects-page-size 10
92
+
93
+ # Example: return only required fields
94
+ rsdoctor-agent query packages_duplicates --data-file ./dist/rsdoctor-data.json --filter "<command-specific-filter>"
95
+ ```
96
+
97
+ ### QA
98
+
99
+ #### What should I do if `rsdoctor-data.json` is not generated correctly?
100
+
101
+ The `rsdoctor-analysis` skill analyzes the data in `rsdoctor-data.json`. You can generate this file by setting `output.mode` to `'brief'` and `output.options.type` to `['json']`:
102
+
103
+ ```js
104
+ new RsdoctorRspackPlugin({
105
+ output: {
106
+ mode: 'brief',
107
+ options: {
108
+ type: ['json'],
109
+ },
110
+ },
111
+ });
112
+ ```
113
+
114
+ You can also set the `RSDOCTOR_OUTPUT='json'` environment variable to output the analysis data as a JSON file. This environment configuration requires `@rsdoctor/*-plugin` version `>= 1.5.11`.
115
+
34
116
  ## MCP Server
35
117
 
36
118
  Rsdoctor provides MCP Server so AI tools can query your local build analysis data. See the [MCP Server](/guide/usage/mcp) documentation.
@@ -5,6 +5,7 @@ import { PackageManagerTabs } from '@theme';
5
5
  为了帮助 AI 更全面地了解 Rsdoctor 的功能、配置与最佳实践,从而在日常开发和问题排查过程中提供更准确的帮助,Rsdoctor 提供了以下能力:
6
6
 
7
7
  - [Agent Skills](#agent-skills)
8
+ - [Agent CLI](#agent-cli)
8
9
  - [MCP Server](#mcp-server)
9
10
  - [llms.txt](#llmstxt)
10
11
  - [Markdown 文档](#markdown-文档)
@@ -31,6 +32,87 @@ Agent Skills 是可安装到 Agent 中的领域知识包,能够让 Agent 在
31
32
  使用 Rsdoctor 对该项目进行构建分析并给出优化建议
32
33
  ```
33
34
 
35
+ ## Agent CLI
36
+
37
+ [`@rsdoctor/agent-cli`](https://github.com/web-infra-dev/rsdoctor/tree/main/packages/agent-cli) 是面向 Agent 的命令行工具,可以读取 Rsdoctor 生成的构建分析数据,并以结构化 JSON 的形式输出,便于 Agent 进一步检索、过滤和分析。
38
+
39
+ 它通常与 [rsdoctor-analysis](https://github.com/rstackjs/agent-skills#rsdoctor-skills) Skill 配合使用:先让 Skill 引导项目完成 Rsdoctor 构建分析,再通过 Agent CLI 查询生成的分析数据。
40
+
41
+ - 在项目中安装(可选,因为 Skill 可以自动全局安装这个依赖):
42
+
43
+ <PackageManagerTabs command="add -D @rsdoctor/agent-cli" />
44
+
45
+ - `rsdoctor-agent` 命令主要包含:
46
+
47
+ ```bash
48
+ rsdoctor-agent --help
49
+ rsdoctor-agent --version
50
+ rsdoctor-agent list
51
+ rsdoctor-agent query <tool-name> --data-file <path> [--input <json>]
52
+ rsdoctor-agent <group> <subcommand> --data-file <path>
53
+ ```
54
+
55
+ **说明:**
56
+
57
+ - `rsdoctor-agent --help`:查看命令帮助信息,包括可用子命令、参数说明和示例。
58
+ - `rsdoctor-agent --version`:查看当前 `@rsdoctor/agent-cli` 包版本。
59
+ - `rsdoctor-agent list`:列出当前可用的直接子命令(如 `group subcommand` / `group.subcommand`),便于了解可直接执行的分组命令。
60
+ - `rsdoctor-agent query <tool-name> --data-file <path> [--input <json>]`:调用指定工具并返回结果。
61
+ - `<tool-name>`:要调用的 catalog tool name(例如 `packages_duplicates`),不是 `rsdoctor-agent list` 输出的分组子命令名称。
62
+ - `--data-file <path>`:Rsdoctor 分析数据文件路径(必填)。
63
+ - `[--input <json>]`:可选,向工具传入额外输入参数(JSON 字符串)。
64
+ - `rsdoctor-agent <group> <subcommand> --data-file <path>`:直接执行分组命令,适合交互式分析。
65
+
66
+ ### 执行示例
67
+
68
+ - Skill 执行示例:
69
+ - 问题:`Use rsdoctor to help me do bundle analysis to see from which aspects the product volume can be optimized.`
70
+
71
+ <img
72
+ src="https://assets.rspack.rs/others/assets/rsdoctor/agent-cli-2.gif"
73
+ style={{ margin: 'auto' }}
74
+ />
75
+ <br />
76
+
77
+ 如上动图所示,AI 工具会依据 Rsdoctor Skill 执行相应的 `@rsdoctor/agent-cli` 命令,获取所需数据,并在整合分析后输出优化建议。同时,它还会提供下一步更深入的分析计划,你可以根据指引进一步研究项目构建问题。
78
+
79
+ <br />
80
+
81
+ <img
82
+ src="https://assets.rspack.rs/others/assets/rsdoctor/agent-cli-next.png"
83
+ style={{ margin: 'auto' }}
84
+ />
85
+ <br />
86
+
87
+ - 命令示例 (由 Skill 触发执行):
88
+
89
+ ```bash
90
+ # Build optimize with side-effects pagination tuned for analysis
91
+ rsdoctor-agent bundle optimize --data-file ./dist/rsdoctor-data.json --side-effects-page-size 10
92
+
93
+ # Example: return only required fields
94
+ rsdoctor-agent query packages_duplicates --data-file ./dist/rsdoctor-data.json --filter "<command-specific-filter>"
95
+ ```
96
+
97
+ ### QA
98
+
99
+ #### 如果没有正确生成 `rsdoctor-data.json` 应该怎么办?
100
+
101
+ `rsdoctor-analysis` Skill 分析的是 `rsdoctor-data.json` 中的数据。你可以通过将 `output.mode` 设置为 `'brief'`,并将 `output.options.type` 设置为 `['json']` 来生成该文件:
102
+
103
+ ```js
104
+ new RsdoctorRspackPlugin({
105
+ output: {
106
+ mode: 'brief',
107
+ options: {
108
+ type: ['json'],
109
+ },
110
+ },
111
+ });
112
+ ```
113
+
114
+ 也可以通过设置 `RSDOCTOR_OUTPUT='json'` 环境变量,将分析数据输出为 JSON 文件。这个环境配置需要 `@rsdoctor/*-plugin` `>= 1.5.11`。
115
+
34
116
  ## MCP Server
35
117
 
36
118
  Rsdoctor 提供 MCP Server 让 AI 工具可以查询本地构建分析数据,详见 [MCP Server](/guide/usage/mcp) 文档。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsdoctor/docs",
3
- "version": "1.5.9",
3
+ "version": "1.5.11",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/web-infra-dev/rsdoctor",
@@ -19,8 +19,8 @@
19
19
  "registry": "https://registry.npmjs.org/"
20
20
  },
21
21
  "devDependencies": {
22
- "@rspress/plugin-algolia": "2.0.9",
23
- "@rspress/plugin-client-redirects": "2.0.9",
22
+ "@rspress/plugin-algolia": "2.0.10",
23
+ "@rspress/plugin-client-redirects": "2.0.10",
24
24
  "@rspress/plugin-rss": "2.0.5",
25
25
  "@types/node": "^22.8.1",
26
26
  "@types/react": "^18.3.28",
@@ -34,14 +34,14 @@
34
34
  "rspress-plugin-font-open-sans": "^1.0.3",
35
35
  "rspress-plugin-sitemap": "^1.2.1",
36
36
  "typescript": "^5.9.2",
37
- "@rsbuild/plugin-sass": "^1.5.1",
38
- "@rsdoctor/types": "1.5.9"
37
+ "@rsbuild/plugin-sass": "^1.5.2",
38
+ "@rsdoctor/types": "1.5.11"
39
39
  },
40
40
  "dependencies": {
41
41
  "@rstack-dev/doc-ui": "1.12.5",
42
42
  "clsx": "^2.1.1",
43
43
  "react-markdown": "^9.1.0",
44
- "@rspress/core": "2.0.9"
44
+ "@rspress/core": "2.0.10"
45
45
  },
46
46
  "scripts": {
47
47
  "dev": "cross-env RSPRESS_PERSIST_CACHE=false rspress dev",