@rsdoctor/docs 1.5.15 → 1.5.17
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.
- package/docs/en/config/options/_meta.json +1 -0
- package/docs/en/config/options/options.mdx +3 -0
- package/docs/en/config/options/server.mdx +124 -0
- package/docs/en/guide/start/action.mdx +45 -0
- package/docs/public/actions-ai-card.png +0 -0
- package/docs/public/actions-ai-detail.png +0 -0
- package/docs/zh/config/options/_meta.json +1 -0
- package/docs/zh/config/options/options.mdx +3 -0
- package/docs/zh/config/options/server.mdx +124 -0
- package/docs/zh/guide/start/action.mdx +45 -0
- package/package.json +2 -2
|
@@ -77,6 +77,7 @@ This `Options` object is the configuration for [RsdoctorRspackPlugin](#rsdoctorr
|
|
|
77
77
|
- [features](./features.mdx) - **Feature Toggle Configuration**: Control various analysis features of Rsdoctor, such as loader analysis, bundle analysis, rule checking, etc.
|
|
78
78
|
- [output](./output.mdx) - **Output Related Configuration**: Control report output format, directory and other options, including mode, options, reportCodeType, etc.
|
|
79
79
|
- [port](./port.mdx) - **Service Port Configuration**: Set the port number for the Rsdoctor development server, used for report preview during local development.
|
|
80
|
+
- [server](./server.mdx) - **Report Server Configuration**: Configure the Rsdoctor report server, including `server.port` and `server.cors`.
|
|
80
81
|
- [supports](./supports.mdx) - **Feature Support Configuration**: Enable compatibility support for specific build tools, such as BannerPlugin, etc.
|
|
81
82
|
- [brief](./brief.mdx) - **Brief Mode Configuration**: Control the generation of brief mode reports, including HTML filename and whether to generate JSON data files.
|
|
82
83
|
- [mode](./mode.mdx) - **Build Report Data Output Mode**: Select the output mode for reports, supporting normal (normal mode) and brief (brief mode).
|
|
@@ -109,6 +110,8 @@ interface RsdoctorWebpackPluginOptions<
|
|
|
109
110
|
|
|
110
111
|
port?: number;
|
|
111
112
|
|
|
113
|
+
server?: SDK.RsdoctorServerConfig;
|
|
114
|
+
|
|
112
115
|
/**
|
|
113
116
|
* @deprecated Use `output.options.htmlOptions` instead
|
|
114
117
|
*/
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# server
|
|
2
|
+
|
|
3
|
+
- **Type:** `RsdoctorServerConfig`
|
|
4
|
+
- **Optional:** `true`
|
|
5
|
+
- **Default:** `{}`
|
|
6
|
+
|
|
7
|
+
Configure the Rsdoctor report server.
|
|
8
|
+
|
|
9
|
+
## port
|
|
10
|
+
|
|
11
|
+
- **Type:** `number`
|
|
12
|
+
- **Optional:** `true`
|
|
13
|
+
- **Default:** `random(3000, 8999)`
|
|
14
|
+
|
|
15
|
+
Configure the port for the Rsdoctor report server.
|
|
16
|
+
|
|
17
|
+
If `server.port` is not set, Rsdoctor uses the top-level [`port`](./port.mdx) option. If both options are set, `server.port` takes priority.
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
new RsdoctorRspackPlugin({
|
|
21
|
+
server: {
|
|
22
|
+
port: 3001,
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## cors
|
|
28
|
+
|
|
29
|
+
- **Type:** `boolean | RsdoctorServerCorsOptions`
|
|
30
|
+
- **Optional:** `true`
|
|
31
|
+
- **Default:** Allows local origins only.
|
|
32
|
+
|
|
33
|
+
Configure CORS response headers for the Rsdoctor report server.
|
|
34
|
+
|
|
35
|
+
By default, Rsdoctor allows local origins only:
|
|
36
|
+
|
|
37
|
+
- `http://localhost` and `https://localhost`
|
|
38
|
+
- `localhost` subdomains, such as `http://foo.localhost`
|
|
39
|
+
- `http://127.0.0.1` and `https://127.0.0.1`
|
|
40
|
+
- `http://[::1]` and `https://[::1]`
|
|
41
|
+
|
|
42
|
+
All default local origins can include any port.
|
|
43
|
+
|
|
44
|
+
### Values
|
|
45
|
+
|
|
46
|
+
- `false`: Disable the CORS middleware.
|
|
47
|
+
- `true`: Use the defaults from the `cors` package.
|
|
48
|
+
- `object`: Pass options to the `cors` middleware. If `origin` is omitted, Rsdoctor keeps the default local-origin policy. If `origin` is set, it replaces the default local-origin policy.
|
|
49
|
+
|
|
50
|
+
Rsdoctor still validates local request hosts separately. The `cors` option only controls CORS middleware behavior and response headers.
|
|
51
|
+
|
|
52
|
+
### Examples
|
|
53
|
+
|
|
54
|
+
Allow a custom origin:
|
|
55
|
+
|
|
56
|
+
```js
|
|
57
|
+
new RsdoctorRspackPlugin({
|
|
58
|
+
server: {
|
|
59
|
+
cors: {
|
|
60
|
+
origin: 'https://example.com',
|
|
61
|
+
credentials: true,
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Keep the default local-origin policy and add other CORS options:
|
|
68
|
+
|
|
69
|
+
```js
|
|
70
|
+
new RsdoctorRspackPlugin({
|
|
71
|
+
server: {
|
|
72
|
+
cors: {
|
|
73
|
+
credentials: true,
|
|
74
|
+
methods: ['GET', 'POST', 'OPTIONS'],
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Use the `cors` package defaults:
|
|
81
|
+
|
|
82
|
+
```js
|
|
83
|
+
new RsdoctorRspackPlugin({
|
|
84
|
+
server: {
|
|
85
|
+
cors: true,
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Type definitions
|
|
91
|
+
|
|
92
|
+
```ts
|
|
93
|
+
interface RsdoctorServerConfig {
|
|
94
|
+
port?: number;
|
|
95
|
+
cors?: boolean | RsdoctorServerCorsOptions;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
type RsdoctorServerCorsStaticOrigin =
|
|
99
|
+
| boolean
|
|
100
|
+
| string
|
|
101
|
+
| RegExp
|
|
102
|
+
| Array<boolean | string | RegExp>;
|
|
103
|
+
|
|
104
|
+
type RsdoctorServerCorsOrigin =
|
|
105
|
+
| RsdoctorServerCorsStaticOrigin
|
|
106
|
+
| ((
|
|
107
|
+
requestOrigin: string | undefined,
|
|
108
|
+
callback: (
|
|
109
|
+
err: Error | null,
|
|
110
|
+
origin?: RsdoctorServerCorsStaticOrigin,
|
|
111
|
+
) => void,
|
|
112
|
+
) => void);
|
|
113
|
+
|
|
114
|
+
interface RsdoctorServerCorsOptions {
|
|
115
|
+
origin?: RsdoctorServerCorsOrigin;
|
|
116
|
+
methods?: string | string[];
|
|
117
|
+
allowedHeaders?: string | string[];
|
|
118
|
+
exposedHeaders?: string | string[];
|
|
119
|
+
credentials?: boolean;
|
|
120
|
+
maxAge?: number;
|
|
121
|
+
preflightContinue?: boolean;
|
|
122
|
+
optionsSuccessStatus?: number;
|
|
123
|
+
}
|
|
124
|
+
```
|
|
@@ -59,6 +59,8 @@ target_branch: ${{ github.event_name == 'pull_request' && github.event.pull_requ
|
|
|
59
59
|
```
|
|
60
60
|
|
|
61
61
|
- `dispatch_target_branch`: Optional, used to specify the target branch when manually triggered (workflow_dispatch).
|
|
62
|
+
- `AI_TOKEN`: Optional, used to enable AI-assisted bundle degradation analysis. Configure it as a GitHub Actions secret and pass it to the action step through `env`.
|
|
63
|
+
- `ai_model`: Optional, AI model used for degradation analysis. The default is `claude-3-5-haiku-latest`. The provider is automatically detected from the model name prefix. Supported prefixes include `claude`, `gemini`, `deepseek`, and `qwen`; other model names use the OpenAI provider.
|
|
62
64
|
|
|
63
65
|
- `on` indicates when the workflow runs, commonly set to `pull_request` and `push`, and also supports `workflow_dispatch` for manual triggering.
|
|
64
66
|
- On `pull_request`, Rsdoctor Action fetches baseline and current and performs bundle diff analysis.
|
|
@@ -122,6 +124,9 @@ jobs:
|
|
|
122
124
|
|
|
123
125
|
- name: Bundle Analysis
|
|
124
126
|
uses: web-infra-dev/rsdoctor-action@main
|
|
127
|
+
env:
|
|
128
|
+
# Optional. Required only when you want AI-assisted analysis.
|
|
129
|
+
AI_TOKEN: ${{ secrets.AI_TOKEN }}
|
|
125
130
|
with:
|
|
126
131
|
file_path: 'dist/.rsdoctor/rsdoctor-data.json'
|
|
127
132
|
# Default 'main'. If you want to use a dynamic target branch, i.e., automatically get the target branch of the current pull request instead of a fixed main branch, you can use the following configuration:
|
|
@@ -129,8 +134,40 @@ jobs:
|
|
|
129
134
|
target_branch: 'main'
|
|
130
135
|
# Target branch for manual trigger
|
|
131
136
|
dispatch_target_branch: ${{ github.event.inputs.target_branch }}
|
|
137
|
+
# Optional. Defaults to 'claude-3-5-haiku-latest'.
|
|
138
|
+
ai_model: 'claude-3-5-haiku-latest'
|
|
132
139
|
```
|
|
133
140
|
|
|
141
|
+
## AI-assisted analysis
|
|
142
|
+
|
|
143
|
+
Rsdoctor Action can use AI to summarize bundle degradation in pull requests and workflow summaries. AI-assisted analysis runs only when baseline data exists and the bundle size changes. To enable it, add an AI provider token as a repository secret and pass it to the action step:
|
|
144
|
+
|
|
145
|
+
1. Open your GitHub repository, then go to `Settings` -> `Secrets and variables` -> `Actions`.
|
|
146
|
+
2. Create a repository secret named `AI_TOKEN`.
|
|
147
|
+
3. Pass the secret to `rsdoctor-action` with `env.AI_TOKEN`.
|
|
148
|
+
4. Optionally set `ai_model` if you want to use a model other than the default `claude-3-5-haiku-latest`.
|
|
149
|
+
|
|
150
|
+
```yaml
|
|
151
|
+
- name: Bundle Analysis
|
|
152
|
+
uses: web-infra-dev/rsdoctor-action@main
|
|
153
|
+
env:
|
|
154
|
+
AI_TOKEN: ${{ secrets.AI_TOKEN }}
|
|
155
|
+
with:
|
|
156
|
+
file_path: 'dist/.rsdoctor/rsdoctor-data.json'
|
|
157
|
+
target_branch: 'main'
|
|
158
|
+
ai_model: 'claude-3-5-haiku-latest'
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
<div style={{ flex: '0 1 320px', maxWidth: 560, margin: 'auto' }}>
|
|
162
|
+
<img
|
|
163
|
+
src="/actions-ai-detail.png"
|
|
164
|
+
alt="AI-assisted analysis details"
|
|
165
|
+
style={{ display: 'block', width: '100%' }}
|
|
166
|
+
/>
|
|
167
|
+
</div>
|
|
168
|
+
|
|
169
|
+
If `AI_TOKEN` is not provided, the Action still runs the regular bundle diff analysis, but AI-assisted analysis will be skipped. The token must match the provider detected from `ai_model`. For example, use an Anthropic token with `claude-*`, a Google token with `gemini-*`, a DeepSeek token with `deepseek-*`, a Qwen token with `qwen*`, or an OpenAI token with OpenAI model names such as `gpt-4o-mini`.
|
|
170
|
+
|
|
134
171
|
## View Reports
|
|
135
172
|
|
|
136
173
|
After submitting the above configuration file to your repository, GitHub Actions will automatically run under the specified trigger conditions and generate Rsdoctor analysis reports. You will see bundle size change comparison prompts in GitHub CI, as shown below:
|
|
@@ -160,6 +197,14 @@ Additionally, clicking "Download Bundle Diff Report" allows you to download Rsdo
|
|
|
160
197
|
|
|
161
198
|
- This is normal for the first run or for new repositories, because no baseline has been uploaded yet. The baseline data will be created after the first merge into the main branch.
|
|
162
199
|
|
|
200
|
+
**Q: AI-assisted analysis is not shown**
|
|
201
|
+
|
|
202
|
+
- Ensure the `AI_TOKEN` secret has been created in repository settings and passed to the action step through `env`.
|
|
203
|
+
- Check whether the selected `ai_model` matches the provider token. The provider is detected from the model name prefix.
|
|
204
|
+
- Confirm that baseline data exists and the bundle size changed in the current run.
|
|
205
|
+
- For pull requests from forks, GitHub may not expose repository secrets to the workflow for security reasons.
|
|
206
|
+
|
|
163
207
|
## More Resources
|
|
164
208
|
|
|
165
209
|
- [rsdoctor-action GitHub Repository](https://github.com/web-infra-dev/rsdoctor-action)
|
|
210
|
+
- [Rsdoctor AI Guide](/guide/start/ai)
|
|
Binary file
|
|
Binary file
|
|
@@ -77,6 +77,7 @@ new RsdoctorWebpackPlugin({
|
|
|
77
77
|
- [features](./features.mdx) - **特性开关配置**:控制 Rsdoctor 的各项分析功能,如 loader 分析、bundle 分析、规则检查等
|
|
78
78
|
- [output](./output.mdx) - **输出相关配置**:控制报告的输出格式、目录等选项,包括 mode、options、reportCodeType 等
|
|
79
79
|
- [port](./port.mdx) - **服务端口配置**:设置 Rsdoctor 开发服务器的端口号,用于本地开发时的报告预览
|
|
80
|
+
- [server](./server.mdx) - **报告服务配置**:配置 Rsdoctor 报告服务,包括 `server.port` 和 `server.cors`
|
|
80
81
|
- [supports](./supports.mdx) - **特性支持配置**:启用特定构建工具的兼容性支持,如 BannerPlugin 等
|
|
81
82
|
- [brief](./brief.mdx) - **Brief 模式的配置**:控制简要模式报告的生成,包括 HTML 文件名和是否生成 JSON 数据文件
|
|
82
83
|
- [mode](./mode.mdx) - **构建报告数据输出模式**:选择报告的输出模式,支持 normal(普通模式)和 brief(简要模式)
|
|
@@ -108,6 +109,8 @@ interface RsdoctorWebpackPluginOptions<
|
|
|
108
109
|
|
|
109
110
|
port?: number;
|
|
110
111
|
|
|
112
|
+
server?: SDK.RsdoctorServerConfig;
|
|
113
|
+
|
|
111
114
|
/**
|
|
112
115
|
* @deprecated 使用 `output.options.htmlOptions` 代替
|
|
113
116
|
*/
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# server
|
|
2
|
+
|
|
3
|
+
- **类型:** `RsdoctorServerConfig`
|
|
4
|
+
- **可选:** `true`
|
|
5
|
+
- **默认值:** `{}`
|
|
6
|
+
|
|
7
|
+
配置 Rsdoctor 报告服务。
|
|
8
|
+
|
|
9
|
+
## port
|
|
10
|
+
|
|
11
|
+
- **类型:** `number`
|
|
12
|
+
- **可选:** `true`
|
|
13
|
+
- **默认值:** `random(3000, 8999)`
|
|
14
|
+
|
|
15
|
+
配置 Rsdoctor 报告服务的端口。
|
|
16
|
+
|
|
17
|
+
如果没有配置 `server.port`,Rsdoctor 会使用顶层 [`port`](./port.mdx) 配置。如果两个配置同时存在,`server.port` 优先级更高。
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
new RsdoctorRspackPlugin({
|
|
21
|
+
server: {
|
|
22
|
+
port: 3001,
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## cors
|
|
28
|
+
|
|
29
|
+
- **类型:** `boolean | RsdoctorServerCorsOptions`
|
|
30
|
+
- **可选:** `true`
|
|
31
|
+
- **默认值:** 只允许本地来源。
|
|
32
|
+
|
|
33
|
+
配置 Rsdoctor 报告服务的 CORS 响应头。
|
|
34
|
+
|
|
35
|
+
默认情况下,Rsdoctor 只允许以下本地来源:
|
|
36
|
+
|
|
37
|
+
- `http://localhost` 和 `https://localhost`
|
|
38
|
+
- `localhost` 子域名,例如 `http://foo.localhost`
|
|
39
|
+
- `http://127.0.0.1` 和 `https://127.0.0.1`
|
|
40
|
+
- `http://[::1]` 和 `https://[::1]`
|
|
41
|
+
|
|
42
|
+
以上默认本地来源都可以携带任意端口。
|
|
43
|
+
|
|
44
|
+
### 可选值
|
|
45
|
+
|
|
46
|
+
- `false`:关闭 CORS 中间件。
|
|
47
|
+
- `true`:使用 `cors` 包的默认配置。
|
|
48
|
+
- `object`:传递给 `cors` 中间件的配置对象。如果没有配置 `origin`,Rsdoctor 会保留默认的本地来源策略。如果配置了 `origin`,它会替换默认的本地来源策略。
|
|
49
|
+
|
|
50
|
+
Rsdoctor 仍然会单独校验本地请求 Host。`cors` 配置只控制 CORS 中间件行为和响应头。
|
|
51
|
+
|
|
52
|
+
### 示例
|
|
53
|
+
|
|
54
|
+
允许一个自定义来源:
|
|
55
|
+
|
|
56
|
+
```js
|
|
57
|
+
new RsdoctorRspackPlugin({
|
|
58
|
+
server: {
|
|
59
|
+
cors: {
|
|
60
|
+
origin: 'https://example.com',
|
|
61
|
+
credentials: true,
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
保留默认本地来源策略,并添加其他 CORS 选项:
|
|
68
|
+
|
|
69
|
+
```js
|
|
70
|
+
new RsdoctorRspackPlugin({
|
|
71
|
+
server: {
|
|
72
|
+
cors: {
|
|
73
|
+
credentials: true,
|
|
74
|
+
methods: ['GET', 'POST', 'OPTIONS'],
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
使用 `cors` 包的默认配置:
|
|
81
|
+
|
|
82
|
+
```js
|
|
83
|
+
new RsdoctorRspackPlugin({
|
|
84
|
+
server: {
|
|
85
|
+
cors: true,
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### 类型定义
|
|
91
|
+
|
|
92
|
+
```ts
|
|
93
|
+
interface RsdoctorServerConfig {
|
|
94
|
+
port?: number;
|
|
95
|
+
cors?: boolean | RsdoctorServerCorsOptions;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
type RsdoctorServerCorsStaticOrigin =
|
|
99
|
+
| boolean
|
|
100
|
+
| string
|
|
101
|
+
| RegExp
|
|
102
|
+
| Array<boolean | string | RegExp>;
|
|
103
|
+
|
|
104
|
+
type RsdoctorServerCorsOrigin =
|
|
105
|
+
| RsdoctorServerCorsStaticOrigin
|
|
106
|
+
| ((
|
|
107
|
+
requestOrigin: string | undefined,
|
|
108
|
+
callback: (
|
|
109
|
+
err: Error | null,
|
|
110
|
+
origin?: RsdoctorServerCorsStaticOrigin,
|
|
111
|
+
) => void,
|
|
112
|
+
) => void);
|
|
113
|
+
|
|
114
|
+
interface RsdoctorServerCorsOptions {
|
|
115
|
+
origin?: RsdoctorServerCorsOrigin;
|
|
116
|
+
methods?: string | string[];
|
|
117
|
+
allowedHeaders?: string | string[];
|
|
118
|
+
exposedHeaders?: string | string[];
|
|
119
|
+
credentials?: boolean;
|
|
120
|
+
maxAge?: number;
|
|
121
|
+
preflightContinue?: boolean;
|
|
122
|
+
optionsSuccessStatus?: number;
|
|
123
|
+
}
|
|
124
|
+
```
|
|
@@ -59,6 +59,8 @@ target_branch: ${{ github.event_name == 'pull_request' && github.event.pull_requ
|
|
|
59
59
|
```
|
|
60
60
|
|
|
61
61
|
- `dispatch_target_branch`:非必需,用于手动触发 (workflow_dispatch) 时指定目标分支。
|
|
62
|
+
- `AI_TOKEN`:非必需,用于开启 AI 辅助的产物劣化分析。请将其配置为 GitHub Actions Secret,并通过 action step 的 `env` 传入。
|
|
63
|
+
- `ai_model`:非必需,用于指定产物劣化分析使用的 AI 模型。默认值为 `claude-3-5-haiku-latest`。Action 会根据模型名称前缀自动识别 provider。支持的前缀包括 `claude`、`gemini`、`deepseek` 和 `qwen`;其他模型名称会使用 OpenAI provider。
|
|
62
64
|
|
|
63
65
|
- `on` 是指 workflow 运行的时机,通常设置为 `pull_request` 和 `push`,也支持 `workflow_dispatch` 手动触发。
|
|
64
66
|
- 在 `pull_request` 时,Rsdoctor Action 会拉取 baseline 和 current,进行 bundle diff 分析。
|
|
@@ -122,6 +124,9 @@ jobs:
|
|
|
122
124
|
|
|
123
125
|
- name: Bundle Analysis
|
|
124
126
|
uses: web-infra-dev/rsdoctor-action@main
|
|
127
|
+
env:
|
|
128
|
+
# 可选,仅在需要 AI 辅助分析时配置。
|
|
129
|
+
AI_TOKEN: ${{ secrets.AI_TOKEN }}
|
|
125
130
|
with:
|
|
126
131
|
file_path: 'dist/.rsdoctor/rsdoctor-data.json'
|
|
127
132
|
# 默认 'main',如果想用不固定的目标分支,即自动获取当前 pull request 的 target branch,则可以使用下方配置:
|
|
@@ -129,8 +134,40 @@ jobs:
|
|
|
129
134
|
target_branch: 'main'
|
|
130
135
|
# 手动触发时使用的目标分支
|
|
131
136
|
dispatch_target_branch: ${{ github.event.inputs.target_branch }}
|
|
137
|
+
# 可选,默认值为 'claude-3-5-haiku-latest'。
|
|
138
|
+
ai_model: 'claude-3-5-haiku-latest'
|
|
132
139
|
```
|
|
133
140
|
|
|
141
|
+
## AI 辅助分析
|
|
142
|
+
|
|
143
|
+
Rsdoctor Action 可以借助 AI 在 Pull Request 评论和 workflow summary 中总结产物劣化原因。AI 辅助分析只会在存在 baseline 数据且产物体积发生变化时运行。启用方式如下:
|
|
144
|
+
|
|
145
|
+
1. 打开 GitHub 仓库,进入 `Settings` -> `Secrets and variables` -> `Actions`。
|
|
146
|
+
2. 创建名为 `AI_TOKEN` 的 repository secret。
|
|
147
|
+
3. 通过 `env.AI_TOKEN` 将 Secret 传入 `rsdoctor-action`。
|
|
148
|
+
4. 如果不想使用默认的 `claude-3-5-haiku-latest`,可以通过 `ai_model` 指定其他模型。
|
|
149
|
+
|
|
150
|
+
```yaml
|
|
151
|
+
- name: Bundle Analysis
|
|
152
|
+
uses: web-infra-dev/rsdoctor-action@main
|
|
153
|
+
env:
|
|
154
|
+
AI_TOKEN: ${{ secrets.AI_TOKEN }}
|
|
155
|
+
with:
|
|
156
|
+
file_path: 'dist/.rsdoctor/rsdoctor-data.json'
|
|
157
|
+
target_branch: 'main'
|
|
158
|
+
ai_model: 'claude-3-5-haiku-latest'
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
<div style={{ flex: '0 1 320px', maxWidth: 560, margin: 'auto' }}>
|
|
162
|
+
<img
|
|
163
|
+
src="/actions-ai-detail.png"
|
|
164
|
+
alt="AI 辅助分析详情"
|
|
165
|
+
style={{ display: 'block', width: '100%' }}
|
|
166
|
+
/>
|
|
167
|
+
</div>
|
|
168
|
+
|
|
169
|
+
如果未提供 `AI_TOKEN`,Action 仍会执行常规的 bundle diff 分析,但会跳过 AI 辅助分析。`AI_TOKEN` 需要与 `ai_model` 自动识别出的 provider 匹配。例如,`claude-*` 使用 Anthropic token,`gemini-*` 使用 Google token,`deepseek-*` 使用 DeepSeek token,`qwen*` 使用 Qwen token,`gpt-4o-mini` 等 OpenAI 模型使用 OpenAI token。
|
|
170
|
+
|
|
134
171
|
## 查看报告
|
|
135
172
|
|
|
136
173
|
将上述配置文件提交到你的仓库后,GitHub Actions 将在指定的触发条件下自动运行,生成 Rsdoctor 的分析报告。你将在 GitHub CI 中看到 Bundle 大小变化的对比提示,如下图:
|
|
@@ -160,6 +197,14 @@ jobs:
|
|
|
160
197
|
|
|
161
198
|
- 这对于首次运行或新仓库是正常的,因为还没有上传 Baseline。因为基线数据将在首次合并到主分支后创建。
|
|
162
199
|
|
|
200
|
+
**Q: 没有展示 AI 辅助分析**
|
|
201
|
+
|
|
202
|
+
- 确保已经在仓库设置中创建 `AI_TOKEN` Secret,并通过 action step 的 `env` 传入。
|
|
203
|
+
- 检查当前 `ai_model` 是否与传入的 provider token 匹配。Action 会根据模型名称前缀识别 provider。
|
|
204
|
+
- 确认当前 workflow 已存在 baseline 数据,并且本次产物体积发生了变化。
|
|
205
|
+
- 对于来自 fork 仓库的 Pull Request,GitHub 出于安全原因可能不会向 workflow 暴露仓库 Secrets。
|
|
206
|
+
|
|
163
207
|
## 更多资源
|
|
164
208
|
|
|
165
209
|
- [rsdoctor-action GitHub 仓库](https://github.com/web-infra-dev/rsdoctor-action)
|
|
210
|
+
- [Rsdoctor AI 指南](/guide/start/ai)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsdoctor/docs",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.17",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/web-infra-dev/rsdoctor",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"rspress-plugin-sitemap": "^1.2.1",
|
|
36
36
|
"typescript": "^6.0.3",
|
|
37
37
|
"@rsbuild/plugin-sass": "^1.5.3",
|
|
38
|
-
"@rsdoctor/types": "1.5.
|
|
38
|
+
"@rsdoctor/types": "1.5.17"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@rstack-dev/doc-ui": "1.14.3",
|