@rsdoctor/docs 1.5.3 → 1.5.5

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.
@@ -73,7 +73,7 @@ Rsdoctor v1.1 introduced MCP support, which is based on **Model Context Protocol
73
73
 
74
74
  Rsdoctor MCP supports natural language Q&A - you can directly ask questions like "Which packages have the largest volume?" or "Why wasn't this module tree-shaken?" The system will intelligently analyze and provide optimization suggestions, helping you quickly identify and resolve build issues.
75
75
 
76
- > [View usage details](/guide/start/mcp)
76
+ > [View usage details](/guide/usage/mcp)
77
77
 
78
78
  <video
79
79
  src="https://lf3-static.bytednsdoc.com/obj/eden-cn/lognuvj/rsdoctor/docs/mcp-bundle-optimize-2.mp4"
@@ -284,6 +284,171 @@ export default {
284
284
  };
285
285
  ```
286
286
 
287
+ ### [E1007] Tree Shaking Side Effects Only
288
+
289
+ Rule key: `tree-shaking-side-effects-only`
290
+
291
+ This rule detects modules that are pulled in and bundled solely due to side effects. This is often caused by unintended tree-shaking failures (e.g. missing or incorrect `"sideEffects"` field in `package.json`, or non-tree-shakeable import patterns), resulting in the entire module being bundled even though none of its exports are used.
292
+
293
+ #### Common causes
294
+
295
+ - The package's `package.json` is missing `"sideEffects": false` (or incorrectly set to `true`), preventing the bundler from pruning unused exports.
296
+ - An import statement like `import 'some-module'` or `import './styles.css'` is being treated as a side-effect-only import, but the intended use was to consume exports.
297
+ - Barrel files (index files that re-export many things) cause the whole module to be kept alive when only a side-effect import is present.
298
+
299
+ #### Solutions
300
+
301
+ 1. **Audit import statements**: Make sure you are actually importing and using named exports from this module. Replace bare side-effect imports with explicit named imports when you intend to use the module's exports.
302
+ 2. **Set `"sideEffects"` correctly**: In the module's `package.json`, set `"sideEffects": false` if the module has no global side effects, so the bundler can safely tree-shake unused exports.
303
+ 3. **Avoid unintended side-effect imports**: Remove or convert `import 'module'` patterns to explicit `import { foo } from 'module'` patterns where the exports are needed.
304
+
305
+ #### Configuration
306
+
307
+ - **ignore**: Module path patterns to ignore (string match: if the module path contains any of these strings, it is ignored).
308
+ - **include**: Module path patterns to include when the module is under `node_modules` (by default, modules in `node_modules` are skipped).
309
+
310
+ ```ts
311
+ interface Config {
312
+ /** Module path fragments to ignore */
313
+ ignore: string[];
314
+ /**
315
+ * Module path patterns to include when the module is under node_modules.
316
+ * Example: ['react', '@babel/runtime']
317
+ */
318
+ include: string[];
319
+ }
320
+ ```
321
+
322
+ Configuration example:
323
+
324
+ ```ts
325
+ import { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin';
326
+
327
+ export default {
328
+ plugins: [
329
+ new RsdoctorRspackPlugin({
330
+ linter: {
331
+ rules: {
332
+ 'tree-shaking-side-effects-only': [
333
+ 'Warn',
334
+ {
335
+ ignore: ['src/polyfills'],
336
+ include: ['some-lib'],
337
+ },
338
+ ],
339
+ },
340
+ },
341
+ }),
342
+ ],
343
+ };
344
+ ```
345
+
346
+ ### [E1008] CJS Require Cannot Tree-Shake
347
+
348
+ Rule key: `cjs-require`
349
+
350
+ This rule warns when code uses a bare `require()` call (e.g. `const mod = require('module')`) to import an entire module without statically accessing its exports. This pattern prevents tree-shaking because the bundler cannot statically determine which exports are actually used, resulting in the entire module being bundled and increasing output size.
351
+
352
+ #### Common causes
353
+
354
+ - Using `const mod = require('module')` instead of `const { foo } = require('module')`.
355
+ - Dynamically composing the require argument (e.g. `require('module/' + name)`), which the bundler cannot statically analyze.
356
+ - Mixing `require()` inside ESM files, preventing the bundler from tree-shaking the module.
357
+
358
+ #### Solutions
359
+
360
+ 1. **Switch to destructured require**: Replace `const mod = require('module')` with `const { foo, bar } = require('module')` so the bundler can statically analyze which exports are used.
361
+ 2. **Migrate to ESM**: Prefer static `import { foo } from 'module'` syntax to take full advantage of bundler tree-shaking.
362
+ 3. **Avoid dynamic require**: If dynamic loading is needed, replace dynamic `require()` with dynamic `import()`.
363
+
364
+ #### Configuration
365
+
366
+ - **ignore**: Module path patterns to ignore (substring match applied to both issuer and required module paths).
367
+
368
+ ```ts
369
+ interface Config {
370
+ /** Module path fragments to ignore */
371
+ ignore: string[];
372
+ }
373
+ ```
374
+
375
+ Configuration example:
376
+
377
+ ```ts
378
+ import { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin';
379
+
380
+ export default {
381
+ plugins: [
382
+ new RsdoctorRspackPlugin({
383
+ linter: {
384
+ rules: {
385
+ 'cjs-require': [
386
+ 'Warn',
387
+ { ignore: ['legacy-lib', 'node_modules/@internal/'] },
388
+ ],
389
+ },
390
+ },
391
+ }),
392
+ ],
393
+ };
394
+ ```
395
+
396
+ ### [E1009] ESM Import Resolved to CJS
397
+
398
+ Rule key: `esm-resolved-to-cjs`
399
+
400
+ This rule warns when a package provides both ESM and CJS formats (via the `module` field or `exports["."]["import"]` in `package.json`), but the bundler resolves an ESM `import` statement to the CJS entry instead. This prevents tree-shaking and leads to larger bundle sizes.
401
+
402
+ #### Common causes
403
+
404
+ - The `exports` field in `package.json` is misconfigured, so the `"import"` condition does not map to the correct ESM entry.
405
+ - An older bundler version that does not support `exports` conditional exports falls back to the CJS entry.
406
+ - The package's `module` field or `exports["import"]` path is incorrect or points to a non-existent file.
407
+ - The consumer's build config does not have `mainFields: ['module', ...]` or does not correctly handle `exports` conditions.
408
+
409
+ #### Solutions
410
+
411
+ 1. **Check the package's `exports` config**: Ensure the target package's `exports` field correctly defines the `"import"` condition pointing to a valid ESM entry file.
412
+ 2. **Upgrade the bundler or plugins**: Make sure you are using a bundler version that supports `exports` conditional exports (e.g. Rspack, Webpack 5+).
413
+ 3. **Report to the package author**: If the problem is a misconfigured `package.json` in a third-party package, file an issue with the package author.
414
+ 4. **Temporarily ignore**: If the package cannot be fixed for now, use the `ignore` option to skip the check for that package.
415
+
416
+ #### Configuration
417
+
418
+ - **ignore**: Package name patterns to ignore (substring match against the import request string).
419
+
420
+ ```ts
421
+ interface Config {
422
+ /**
423
+ * Package name patterns to ignore (substring match against the import request string).
424
+ * Example: ['my-legacy-pkg', '@internal/']
425
+ * @default []
426
+ */
427
+ ignore: string[];
428
+ }
429
+ ```
430
+
431
+ Configuration example:
432
+
433
+ ```ts
434
+ import { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin';
435
+
436
+ export default {
437
+ plugins: [
438
+ new RsdoctorRspackPlugin({
439
+ linter: {
440
+ rules: {
441
+ 'esm-resolved-to-cjs': [
442
+ 'Warn',
443
+ { ignore: ['my-legacy-pkg', '@internal/'] },
444
+ ],
445
+ },
446
+ },
447
+ }),
448
+ ],
449
+ };
450
+ ```
451
+
287
452
  ## Linter type
288
453
 
289
454
  - The type definition for the `linter` field is as follows:
@@ -5,6 +5,6 @@
5
5
  "cicd",
6
6
  "action",
7
7
  "cli",
8
- "mcp",
8
+ "ai",
9
9
  "playground"
10
10
  ]
@@ -0,0 +1,101 @@
1
+ import { PackageManagerTabs } from '@theme';
2
+
3
+ # AI
4
+
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
+
7
+ - [Agent Skills](#agent-skills)
8
+ - [MCP Server](#mcp-server)
9
+ - [llms.txt](#llmstxt)
10
+ - [Markdown docs](#markdown-docs)
11
+ - [AGENTS.md](#agentsmd)
12
+
13
+ ## Agent Skills
14
+
15
+ Agent Skills are domain-specific knowledge packs that can be installed into Agents, enabling them to give more accurate and professional suggestions or perform actions in specific scenarios.
16
+
17
+ In the [rstackjs/agent-skills](https://github.com/rstackjs/agent-skills) repository, there are many skills for the Rstack ecosystem. The skills related to Rsdoctor include:
18
+
19
+ - [rsdoctor-analysis](https://github.com/rstackjs/agent-skills#rsdoctor-skills): Use Rsdoctor for build analysis and provide optimization recommendations.
20
+
21
+ In Coding Agents that support skills, you can use the [skills](https://www.npmjs.com/package/skills) package to install a specific skill with the following command:
22
+
23
+ <PackageManagerTabs
24
+ command="skills add rstackjs/agent-skills --skill rsdoctor-analysis"
25
+ dlx
26
+ />
27
+
28
+ After installation, simply use natural language prompts to trigger the skill, for example:
29
+
30
+ ```
31
+ Use Rsdoctor to analyze this project and provide optimization suggestions
32
+ ```
33
+
34
+ ## MCP Server
35
+
36
+ Rsdoctor provides MCP Server so AI tools can query your local build analysis data. See the [MCP Server](/guide/usage/mcp) documentation.
37
+
38
+ ## llms.txt
39
+
40
+ [llms.txt](https://llmstxt.org/) is a standard that helps LLMs discover and use project documentation. Rsdoctor follows this standard and publishes the following two files:
41
+
42
+ - [llms.txt](https://rsdoctor.rs/llms.txt): A structured index file containing the titles, links, and brief descriptions of all documentation pages.
43
+
44
+ ```
45
+ https://rsdoctor.rs/llms.txt
46
+ ```
47
+
48
+ - [llms-full.txt](https://rsdoctor.rs/llms-full.txt): A full-content file that concatenates the complete content of every documentation page into a single file.
49
+
50
+ ```
51
+ https://rsdoctor.rs/llms-full.txt
52
+ ```
53
+
54
+ You can choose the file that best fits your use case:
55
+
56
+ - `llms.txt` is smaller and consumes fewer tokens, making it suitable for AI to fetch specific pages on demand.
57
+ - `llms-full.txt` contains the complete documentation content, so AI doesn't need to follow individual links - ideal when you need AI to have a comprehensive understanding of Rsdoctor, though it consumes more tokens and is best used with AI tools that support large context windows.
58
+
59
+ ## Markdown docs
60
+
61
+ Every Rsdoctor documentation page has a corresponding `.md` plain-text version that can be provided directly to AI. On any doc page, you can click "Copy Markdown" or "Copy Markdown Link" under the title to get the Markdown content or link.
62
+
63
+ ```
64
+ https://rsdoctor.rs/guide/start/intro.md
65
+ ```
66
+
67
+ Providing the Markdown link or content allows AI to focus on a specific chapter, which is useful for targeted troubleshooting or looking up a particular topic.
68
+
69
+ ## AGENTS.md
70
+
71
+ You can create an `AGENTS.md` file in the root of a project that uses Rsdoctor. This file follows the [AGENTS.md](https://agents.md/) specification and provides key project information to Agents.
72
+
73
+ Here is an example of Rsdoctor-related content you can add to `AGENTS.md`:
74
+
75
+ ```markdown wrapCode
76
+ # AGENTS.md
77
+
78
+ You are an expert in JavaScript, Rsdoctor, and build analysis.
79
+
80
+ ## Tools
81
+
82
+ ### Rsdoctor
83
+
84
+ - Run `RSDOCTOR=true npm run build` to build the app with Rsdoctor
85
+
86
+ ## Docs
87
+
88
+ - Rsdoctor: https://rsdoctor.rs/llms.txt
89
+ ```
90
+
91
+ You can also customize it for your project, adding more details about the project structure, overall architecture, and other relevant information so Agents can better understand your project.
92
+
93
+ ::: tip
94
+
95
+ If you are using Claude Code, you can create a `CLAUDE.md` file and reference the `AGENTS.md` file in it.
96
+
97
+ ```markdown title="CLAUDE.md"
98
+ @AGENTS.md
99
+ ```
100
+
101
+ :::
@@ -11,5 +11,6 @@
11
11
  "module-analysis",
12
12
  "resolver",
13
13
  "rule-config",
14
- "bundle-diff"
14
+ "bundle-diff",
15
+ "mcp"
15
16
  ]
@@ -298,4 +298,4 @@ new RsdoctorRspackPlugin({
298
298
  - Ensure the Rsdoctor local Server has been successfully started.
299
299
  - Manually start the local Server, do not use MCP Client to start the project, as the local service of Rsdoctor will block the dialogue process of MCP Client.
300
300
  - If the Rsdoctor MCP server uses the `--port` parameter, please ensure the Rsdoctor startup port configuration is correct.
301
- - Check if the Rsdoctor plugin version meets the requirements. [Version requirements](/guide/start/mcp#-version-requirements)
301
+ - Check if the Rsdoctor plugin version meets the requirements. [Version requirements](/guide/usage/mcp#-version-requirements)
@@ -71,4 +71,4 @@ You can also use MCP for analysis. By asking "Please help me to check why react-
71
71
  alt="tree-shaking"
72
72
  />
73
73
 
74
- > For MCP analysis, see [MCP Analysis](/guide/start/mcp)
74
+ > For MCP analysis, see [MCP Analysis](/guide/usage/mcp)
@@ -73,7 +73,7 @@ Rsdoctor v1.1 引入了 MCP 支持,它基于 **Model Context Protocol (MCP)**
73
73
 
74
74
  Rsdoctor MCP 支持自然语言问答,你可以直接问"哪些包体积最大?"、"为什么这个模块没有被 Tree Shaking?"等问题,系统会智能分析并给出优化建议,帮助你快速定位和解决构建问题。主要功能包括获取产物信息、依赖分析、优化建议、编译性能及 tree shaking 分析等核心分析能力。
75
75
 
76
- > [查看使用详情](/guide/start/mcp)
76
+ > [查看使用详情](/guide/usage/mcp)
77
77
 
78
78
  <video
79
79
  src="https://lf3-static.bytednsdoc.com/obj/eden-cn/lognuvj/rsdoctor/docs/mcp-bundle-optimize-2.mp4"
@@ -280,6 +280,171 @@ export default {
280
280
  };
281
281
  ```
282
282
 
283
+ ### [E1007] Tree Shaking Side Effects Only
284
+
285
+ 规则 key: `tree-shaking-side-effects-only`
286
+
287
+ 当某个模块仅以副作用(side effects)方式被引入并打进产物时,该规则会发出警告。这通常是由于意外的 tree-shaking 失败导致的(例如 `package.json` 中缺少或错误设置了 `"sideEffects"` 字段,或使用了不可 tree-shake 的 import 写法),使整个模块被打包进产物,即使其导出的内容没有被实际使用。
288
+
289
+ #### 常见原因
290
+
291
+ - 包的 `package.json` 缺少 `"sideEffects": false`(或错误地设置为 `true`),导致打包器无法裁剪未使用的导出。
292
+ - `import 'some-module'` 或 `import './styles.css'` 这类语句被当作纯副作用引入处理,而实际意图是使用该模块的导出内容。
293
+ - Barrel 文件(将许多内容重新导出的 index 文件)在只存在副作用引入时,导致整个模块被保留。
294
+
295
+ #### 解决方案
296
+
297
+ 1. **审查 import 语句**:确认你确实在引入并使用该模块的具名导出。当你需要使用模块的导出时,将裸副作用引入替换为显式的具名引入。
298
+ 2. **正确设置 `"sideEffects"`**:如果该模块没有全局副作用,在其 `package.json` 中设置 `"sideEffects": false`,使打包器可以安全地 tree-shake 未使用的导出。
299
+ 3. **避免非预期的副作用引入**:将 `import 'module'` 模式转换为 `import { foo } from 'module'` 的显式写法(当需要使用导出时)。
300
+
301
+ #### 配置
302
+
303
+ - **ignore**:需要忽略的模块路径匹配规则(字符串匹配:模块路径包含配置中的某字符串即忽略)。
304
+ - **include**:当模块位于 `node_modules` 下时,需要纳入检查的模块路径匹配规则(默认情况下 `node_modules` 中的模块会被跳过)。
305
+
306
+ ```ts
307
+ interface Config {
308
+ /** 需要忽略的模块路径片段 */
309
+ ignore: string[];
310
+ /**
311
+ * 当模块位于 node_modules 下时,需要纳入检查的模块路径匹配规则。
312
+ * 示例:['react', '@babel/runtime']
313
+ */
314
+ include: string[];
315
+ }
316
+ ```
317
+
318
+ 配置示例:
319
+
320
+ ```ts
321
+ import { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin';
322
+
323
+ export default {
324
+ plugins: [
325
+ new RsdoctorRspackPlugin({
326
+ linter: {
327
+ rules: {
328
+ 'tree-shaking-side-effects-only': [
329
+ 'Warn',
330
+ {
331
+ ignore: ['src/polyfills'],
332
+ include: ['some-lib'],
333
+ },
334
+ ],
335
+ },
336
+ },
337
+ }),
338
+ ],
339
+ };
340
+ ```
341
+
342
+ ### [E1008] CJS Require Cannot Tree-Shake
343
+
344
+ 规则 key: `cjs-require`
345
+
346
+ 当代码中使用裸 `require()` 调用(例如 `const mod = require('module')`)导入整个模块,而没有对导出属性做静态访问时,该规则会发出警告。这类写法会阻止打包器进行 tree-shaking,因为打包器无法静态分析实际使用了哪些导出,导致整个模块被打进产物,产物体积增大。
347
+
348
+ #### 常见原因
349
+
350
+ - 使用 `const mod = require('module')` 导入整个模块,而非 `const { foo } = require('module')`。
351
+ - 动态拼接 require 参数(如 `require('module/' + name)`),打包器无法静态分析。
352
+ - 在 ESM 文件中混用 `require()`,使打包器无法对该模块做 tree-shaking。
353
+
354
+ #### 解决方案
355
+
356
+ 1. **改用解构 require**:将 `const mod = require('module')` 改为 `const { foo, bar } = require('module')`,使打包器可以静态分析实际使用的导出。
357
+ 2. **迁移到 ESM**:优先使用 `import { foo } from 'module'` 的静态 ESM 写法,充分利用打包器的 tree-shaking 能力。
358
+ 3. **避免动态 require**:如有动态加载需求,可改用动态 `import()` 代替动态 `require()`。
359
+
360
+ #### 配置
361
+
362
+ - **ignore**:需要忽略的模块路径匹配规则(对 issuer 和被 require 的模块路径均做字符串匹配)。
363
+
364
+ ```ts
365
+ interface Config {
366
+ /** 需要忽略的模块路径片段 */
367
+ ignore: string[];
368
+ }
369
+ ```
370
+
371
+ 配置示例:
372
+
373
+ ```ts
374
+ import { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin';
375
+
376
+ export default {
377
+ plugins: [
378
+ new RsdoctorRspackPlugin({
379
+ linter: {
380
+ rules: {
381
+ 'cjs-require': [
382
+ 'Warn',
383
+ { ignore: ['legacy-lib', 'node_modules/@internal/'] },
384
+ ],
385
+ },
386
+ },
387
+ }),
388
+ ],
389
+ };
390
+ ```
391
+
392
+ ### [E1009] ESM Import Resolved to CJS
393
+
394
+ 规则 key: `esm-resolved-to-cjs`
395
+
396
+ 当某个包同时提供了 ESM 和 CJS 两种格式(通过 `package.json` 中的 `module` 字段或 `exports["."]["import"]`),但打包器在处理 ESM `import` 语句时却解析到了 CJS 入口,该规则会发出警告。这种情况会导致 tree-shaking 失效,产物体积变大。
397
+
398
+ #### 常见原因
399
+
400
+ - `package.json` 中的 `exports` 字段配置不正确,导致 `import` 条件未能正确映射到 ESM 入口。
401
+ - 打包器版本较旧,不支持 `exports` 条件导出,退而解析到 CJS 入口。
402
+ - 包本身的 `module` 字段或 `exports["import"]` 路径指向错误,或文件不存在。
403
+ - 消费方的构建配置未开启 `mainFields: ['module', ...]` 或未正确处理 `exports` 条件。
404
+
405
+ #### 解决方案
406
+
407
+ 1. **检查 `package.json` 的 `exports` 配置**:确保目标包的 `exports` 字段正确配置了 `"import"` 条件,并指向合法的 ESM 入口文件。
408
+ 2. **升级打包器或相关插件**:确保使用支持 `exports` 条件导出的打包器版本(如 Rspack、Webpack 5+)。
409
+ 3. **联系包作者**:若问题出在第三方包的 `package.json` 配置错误,可向包作者反馈或提 issue。
410
+ 4. **临时忽略**:若该包暂无法修复,可通过 `ignore` 配置项跳过对该包的检查。
411
+
412
+ #### 配置
413
+
414
+ - **ignore**:需要忽略的包名匹配规则(对 import 请求字符串做子串匹配)。
415
+
416
+ ```ts
417
+ interface Config {
418
+ /**
419
+ * 需要忽略的包名匹配规则(子串匹配 import 请求字符串)。
420
+ * 示例:['my-legacy-pkg', '@internal/']
421
+ * @default []
422
+ */
423
+ ignore: string[];
424
+ }
425
+ ```
426
+
427
+ 配置示例:
428
+
429
+ ```ts
430
+ import { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin';
431
+
432
+ export default {
433
+ plugins: [
434
+ new RsdoctorRspackPlugin({
435
+ linter: {
436
+ rules: {
437
+ 'esm-resolved-to-cjs': [
438
+ 'Warn',
439
+ { ignore: ['my-legacy-pkg', '@internal/'] },
440
+ ],
441
+ },
442
+ },
443
+ }),
444
+ ],
445
+ };
446
+ ```
447
+
283
448
  ## Linter 类型定义
284
449
 
285
450
  - `linter`字段的类型如下:
@@ -5,6 +5,6 @@
5
5
  "cicd",
6
6
  "action",
7
7
  "cli",
8
- "mcp",
8
+ "ai",
9
9
  "playground"
10
10
  ]
@@ -0,0 +1,101 @@
1
+ import { PackageManagerTabs } from '@theme';
2
+
3
+ # AI
4
+
5
+ 为了帮助 AI 更全面地了解 Rsdoctor 的功能、配置与最佳实践,从而在日常开发和问题排查过程中提供更准确的帮助,Rsdoctor 提供了以下能力:
6
+
7
+ - [Agent Skills](#agent-skills)
8
+ - [MCP Server](#mcp-server)
9
+ - [llms.txt](#llmstxt)
10
+ - [Markdown 文档](#markdown-文档)
11
+ - [AGENTS.md](#agentsmd)
12
+
13
+ ## Agent Skills
14
+
15
+ Agent Skills 是可安装到 Agent 中的领域知识包,能够让 Agent 在特定场景下更准确、更专业地给出建议或执行操作。
16
+
17
+ 我们在 [rstackjs/agent-skills](https://github.com/rstackjs/agent-skills) 仓库中为 Rstack 生态提供了许多 Skills,其中关于 Rsdoctor 的 Skills 包括:
18
+
19
+ - [rsdoctor-analysis](https://github.com/rstackjs/agent-skills#rsdoctor-skills):使用 Rsdoctor 进行构建分析并提供优化建议。
20
+
21
+ 在支持 Skills 的 Coding Agent 中,可以通过以下命令使用 [skills](https://www.npmjs.com/package/skills) 包安装指定的 Skill:
22
+
23
+ <PackageManagerTabs
24
+ command="skills add rstackjs/agent-skills --skill rsdoctor-analysis"
25
+ dlx
26
+ />
27
+
28
+ 安装完成后,用自然语言输入相关提示词即可触发对应 Skill,例如:
29
+
30
+ ```
31
+ 使用 Rsdoctor 对该项目进行构建分析并给出优化建议
32
+ ```
33
+
34
+ ## MCP Server
35
+
36
+ Rsdoctor 提供 MCP Server 让 AI 工具可以查询本地构建分析数据,详见 [MCP Server](/guide/usage/mcp) 文档。
37
+
38
+ ## llms.txt
39
+
40
+ [llms.txt](https://llmstxt.org/) 是一种帮助 LLM 发现和使用项目文档的标准规范。Rsdoctor 遵循该规范,发布了以下两个文件:
41
+
42
+ - [llms.txt](https://rsdoctor.rs/llms.txt):结构化索引文件,包含所有文档页面的标题、链接与简要描述。
43
+
44
+ ```
45
+ https://rsdoctor.rs/llms.txt
46
+ ```
47
+
48
+ - [llms-full.txt](https://rsdoctor.rs/llms-full.txt):完整内容文件,将所有文档页面的内容合并为单个文件。
49
+
50
+ ```
51
+ https://rsdoctor.rs/llms-full.txt
52
+ ```
53
+
54
+ 你可以根据使用场景选择合适的文件:
55
+
56
+ - `llms.txt` 体积较小、消耗 token 少,适合让 AI 按需获取具体页面。
57
+ - `llms-full.txt` 包含全量文档内容,无需 AI 逐一跟随链接,适合需要 AI 全面了解 Rsdoctor 的场景,但会消耗更多 token,建议在支持大上下文窗口的 AI 工具中使用。
58
+
59
+ ## Markdown 文档
60
+
61
+ Rsdoctor 文档的每个页面都提供对应的 `.md` 纯文本版本,可直接作为上下文提供给 AI。你可以在文档任意页面的标题下方点击「复制 Markdown」或「复制 Markdown 链接」按钮,获取该页面对应的 Markdown 文件内容或链接。
62
+
63
+ ```
64
+ https://rsdoctor.rs/guide/start/intro.md
65
+ ```
66
+
67
+ 将 Markdown 链接或内容提供给 AI,即可让其精确了解某一具体章节的内容,适合在针对性问题排查或查阅特定内容时使用。
68
+
69
+ ## AGENTS.md
70
+
71
+ 你可以在使用 Rsdoctor 的项目根目录创建一个 `AGENTS.md` 文件。该文件遵循 [AGENTS.md](https://agents.md/) 规范,向 Agents 提供项目的关键信息。
72
+
73
+ 以下是可以在 `AGENTS.md` 中添加的 Rsdoctor 相关内容示例:
74
+
75
+ ```markdown wrapCode
76
+ # AGENTS.md
77
+
78
+ You are an expert in JavaScript, Rsdoctor, and build analysis.
79
+
80
+ ## Tools
81
+
82
+ ### Rsdoctor
83
+
84
+ - Run `RSDOCTOR=true npm run build` to build the app with Rsdoctor
85
+
86
+ ## Docs
87
+
88
+ - Rsdoctor: https://rsdoctor.rs/llms.txt
89
+ ```
90
+
91
+ 你也可以根据项目的实际情况进行修改,添加更多关于项目结构、整体架构等多方面的信息,以便 Agents 更好地理解你的项目。
92
+
93
+ ::: tip
94
+
95
+ 如果你使用的是 Claude Code,可以创建一个 `CLAUDE.md` 文件,并在其中引用 `AGENTS.md` 文件。
96
+
97
+ ```markdown title="CLAUDE.md"
98
+ @AGENTS.md
99
+ ```
100
+
101
+ :::
@@ -11,5 +11,6 @@
11
11
  "module-analysis",
12
12
  "resolver",
13
13
  "rule-config",
14
- "bundle-diff"
14
+ "bundle-diff",
15
+ "mcp"
15
16
  ]
@@ -312,4 +312,4 @@ new RsdoctorRspackPlugin({
312
312
  - 确保 Rsdoctor 本地 Server 已成功启动。
313
313
  - 手动启动本地 Server,请勿使用 MCP Client 启动项目,因为 Rsdoctor 的挂载的本地服务会卡住 MCP Client 的对话进程。
314
314
  - 如果 Rsdoctor MCP server 使用了 `--port` 参数,请确保 Rsdoctor 的启动端口配置正确。
315
- - 检查 Rsdoctor 插件版本是否符合要求。[版本要求](/guide/start/mcp#-%E7%89%88%E6%9C%AC%E8%A6%81%E6%B1%82)
315
+ - 检查 Rsdoctor 插件版本是否符合要求。[版本要求](/guide/usage/mcp#-%E7%89%88%E6%9C%AC%E8%A6%81%E6%B1%82)
@@ -71,4 +71,4 @@
71
71
  alt="tree-shaking"
72
72
  />
73
73
 
74
- > MCP 分析请查看 [MCP 分析](/guide/start/mcp)
74
+ > MCP 分析请查看 [MCP 分析](/guide/usage/mcp)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsdoctor/docs",
3
- "version": "1.5.3",
3
+ "version": "1.5.5",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/web-infra-dev/rsdoctor",
@@ -19,28 +19,29 @@
19
19
  "registry": "https://registry.npmjs.org/"
20
20
  },
21
21
  "devDependencies": {
22
- "@rspress/plugin-algolia": "2.0.3",
23
- "@rspress/plugin-llms": "2.0.3",
24
- "@rspress/plugin-rss": "2.0.2",
22
+ "@rspress/plugin-algolia": "2.0.5",
23
+ "@rspress/plugin-client-redirects": "2.0.5",
24
+ "@rspress/plugin-rss": "2.0.5",
25
25
  "@types/node": "^22.8.1",
26
26
  "@types/react": "^18.3.28",
27
27
  "@types/react-dom": "^18.3.7",
28
28
  "cross-env": "^7.0.3",
29
29
  "react": "18.3.1",
30
30
  "react-dom": "18.3.1",
31
+ "react-render-to-markdown": "^18.3.1",
31
32
  "rsbuild-plugin-google-analytics": "^1.0.5",
32
33
  "rsbuild-plugin-open-graph": "^1.1.2",
33
34
  "rspress-plugin-font-open-sans": "^1.0.3",
34
35
  "rspress-plugin-sitemap": "^1.2.1",
35
36
  "typescript": "^5.9.2",
36
- "@rsbuild/plugin-sass": "^1.5.0",
37
- "@rsdoctor/types": "1.5.3"
37
+ "@rsbuild/plugin-sass": "^1.5.1",
38
+ "@rsdoctor/types": "1.5.5"
38
39
  },
39
40
  "dependencies": {
40
- "@rstack-dev/doc-ui": "1.12.4",
41
+ "@rstack-dev/doc-ui": "1.12.5",
41
42
  "clsx": "^2.1.1",
42
43
  "react-markdown": "^9.1.0",
43
- "@rspress/core": "2.0.3"
44
+ "@rspress/core": "2.0.5"
44
45
  },
45
46
  "scripts": {
46
47
  "dev": "cross-env RSPRESS_PERSIST_CACHE=false rspress dev",