@iyowei/rim-cli 0.0.0-stage → 0.0.1-stage
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/LICENSE +21 -0
- package/README.md +134 -2
- package/README.zh-CN.md +135 -0
- package/bin/bunfig.toml +5 -0
- package/bin/rim.mjs +433 -0
- package/dist/cli.js +163 -0
- package/dist/manifest.json +7 -0
- package/package.json +62 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 iTonyYo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,135 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@iyowei/rim-cli`
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://github.com/iyowei/clis/actions/workflows/release.yml)
|
|
4
|
+
[](https://www.npmjs.com/package/@iyowei/rim-cli)
|
|
5
|
+
[](https://www.npmjs.com/package/@iyowei/rim-cli)
|
|
6
|
+

|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
**English** | [中文](https://github.com/iyowei/clis/blob/main/packages/rim-cli/README.zh-CN.md)
|
|
10
|
+
|
|
11
|
+
`rim` is an all-in-one black-box website audit and release gate CLI (Bun-first, with clean Node.js `>= 22.18.0` fallback).
|
|
12
|
+
|
|
13
|
+
Install `rim` once and every probe works out of the box: protocol & compression, security headers & TLS, Lighthouse performance, runtime smoke, link/anchor scanning, WCAG accessibility, and bounded load testing — no extra global CLI tools required (browser-based probes simply reuse your local Chrome / Chromium / Edge). For programmatic use in scripts or pipelines, see [`@iyowei/rim`](https://github.com/iyowei/clis/blob/main/packages/rim/README.md).
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
### 1. One-click script (macOS / Linux / Windows, no Node / Bun required)
|
|
18
|
+
|
|
19
|
+
```shell
|
|
20
|
+
# macOS / Linux
|
|
21
|
+
curl -fsSL https://raw.githubusercontent.com/iyowei/clis/main/packages/rim-cli/install.sh | sh
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
```powershell
|
|
25
|
+
# Windows (PowerShell)
|
|
26
|
+
irm https://raw.githubusercontent.com/iyowei/clis/main/packages/rim-cli/install.ps1 | iex
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### 2. Package manager or zero-install run
|
|
30
|
+
|
|
31
|
+
```shell
|
|
32
|
+
bun install -g @iyowei/rim-cli
|
|
33
|
+
npm install -g @iyowei/rim-cli
|
|
34
|
+
bunx @iyowei/rim-cli --help
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Quick Start
|
|
38
|
+
|
|
39
|
+
```shell
|
|
40
|
+
# 1. Run in a project folder: auto-detect .rim.json or local build output (ci preset)
|
|
41
|
+
rim
|
|
42
|
+
|
|
43
|
+
# 2. Fast zero-browser audit against a live site (protocol, compression, cache, headers, CSP3)
|
|
44
|
+
rim https://example.com --preset quick
|
|
45
|
+
|
|
46
|
+
# 3. CI strict gate (exits 1 on failed budgets/thresholds, unexpected SKIP, or zero checks)
|
|
47
|
+
rim --preset ci --strict
|
|
48
|
+
|
|
49
|
+
# 4. Full 5-probe audit (mobile only, skip Lighthouse report files, explicit --allow-load)
|
|
50
|
+
rim https://example.com --preset full --allow-load --device mobile --no-report
|
|
51
|
+
|
|
52
|
+
# 5. Save a host baseline, show metric diffs, and write a single-file HTML summary
|
|
53
|
+
rim https://example.com --preset quick --save-baseline --diff --html report.html
|
|
54
|
+
|
|
55
|
+
# 6. Read-only check of runtime, browser, built-in engines, and optional external tools
|
|
56
|
+
rim doctor
|
|
57
|
+
|
|
58
|
+
# 7. Generate a starter .rim.json in the current directory
|
|
59
|
+
rim init --yes
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Choosing a Preset (`--preset`)
|
|
63
|
+
|
|
64
|
+
- **`quick`**: zero-browser fast check running `proto` + `sec` (finishes in seconds; great right after deploy).
|
|
65
|
+
- **`ci`** (default): pre-release gate running `proto` + `sec` + `perf`, plus `quality` when smoke is configured.
|
|
66
|
+
- **`full`**: deep end-to-end audit enabling all five probes (including built-in TLS matrix, external links, bundled `axe-core`, and guarded load).
|
|
67
|
+
|
|
68
|
+
Use `--only <list>` or `--skip <list>` to pick individual probes (`proto,sec,perf,quality,load`). Browser device profiles are controlled separately via `--device <mobile|desktop|both>`.
|
|
69
|
+
|
|
70
|
+
## Layer 1: Built-in Checks (Install `rim` Only, Zero Extra Setup)
|
|
71
|
+
|
|
72
|
+
Every check below ships directly inside `rim` and runs with no extra global CLI installs.
|
|
73
|
+
|
|
74
|
+
### 1. `proto` (Protocol, Compression, Caching & First-Packet Budgets)
|
|
75
|
+
|
|
76
|
+
- **Status & TTFB**: verifies HTTP `200` on entry routes and optional `TTFB` ceilings.
|
|
77
|
+
- **Exact 3-encoding wire bytes**: issues real `identity`, `gzip`, and `br` GET requests and measures exact compressed bytes on the wire (works accurately even for chunked responses); warns when compression or Brotli is missing.
|
|
78
|
+
- **Caching & revalidation**: checks `Vary: Accept-Encoding`, `ETag` / `Last-Modified`, and `Cache-Control` (warns if HTML is marked `immutable` or missing `Cache-Control`), and sends `If-None-Match` to verify `304 Not Modified`.
|
|
79
|
+
- **First-packet budgets & preloads**: checks against QUIC (`12 KB`) / TCP IW10 (`14.6 KB`) guidelines plus custom hard limits (`htmlBrBytes`, `totalCriticalBrBytes`) across HTML and preloaded assets (`<link rel="preload">` and HTTP `Link` headers).
|
|
80
|
+
- **HTTP/2 vs HTTP/3 (QUIC) path MTU probe**: on HTTPS targets in `ci`/`full`, compares H2 and H3 loads in headless Chrome to catch QUIC path MTU blackholes and silent protocol fallbacks.
|
|
81
|
+
|
|
82
|
+
### 2. `sec` (Security Headers, CSP3 & Native TLS)
|
|
83
|
+
|
|
84
|
+
- **CSP3 policy audit**: parses single or comma-separated `Content-Security-Policy` headers, checks `script-src` and `script-src-elem` independently, blocks bare `'unsafe-inline'` and JS `'unsafe-eval'`, allows `'wasm-unsafe-eval'`, and audits `style-src`, `frame-ancestors`, `base-uri`, and `object-src 'none'`.
|
|
85
|
+
- **Core security headers**: checks `HSTS` (HTTPS only, warns under 180 days), `X-Content-Type-Options: nosniff`, `X-Frame-Options`, `Referrer-Policy`, `COOP`, and `Permissions-Policy`.
|
|
86
|
+
- **Server fingerprint leak checks**: flags exposed `Server` / `X-Powered-By` headers (extensible via `forbidHeaders`).
|
|
87
|
+
- **Built-in native TLS audit (`node:tls`)**: automatic in `full` (or `sec.checkTls: true`); concurrently probes TLS `1.3` / `1.2` / `1.1` / `1.0` (fails if deprecated 1.0/1.1 is offered), validates trust chain and hostname, checks certificate expiry (`< 7d` fail, `< 30d` warn), public key strength (`RSA >= 2048`, `EC >= 224`), weak ciphers, and ALPN (`h2` / `http/1.1`).
|
|
88
|
+
|
|
89
|
+
### 3. `perf` (Lighthouse Performance & Web Vitals)
|
|
90
|
+
|
|
91
|
+
- **Bundled `lighthouse@13.7.0`**: lazy-loaded in-process only when `perf` runs (zero startup cost otherwise); supports `mobile`, `desktop`, or `both` across multiple `--path` routes.
|
|
92
|
+
- **Category scores & Web Vitals**: enforces thresholds on Performance, Accessibility, Best Practices, and SEO, and reports FCP, LCP, TBT, CLS, SI, and TTFB.
|
|
93
|
+
- **Main-thread diagnostics**: reports main-thread long tasks (`> 50ms`), main-thread time breakdown, and top script bootup timings; supports `--cold-gpu` and `--cpu-slowdown`.
|
|
94
|
+
- **Transparent waivers**: rules matched by `waivers[]` appear explicitly as `WAIVED` with their reason instead of failing the gate.
|
|
95
|
+
|
|
96
|
+
### 4. `quality` (Runtime Smoke, Links & Accessibility)
|
|
97
|
+
|
|
98
|
+
- **Chrome CDP runtime smoke**: fails on uncaught page exceptions, `console.error`, or failed same-origin requests; supports declarative E2E steps (`viewport`, `navigate`, `waitUntil`, `click`, `setValue`, `assert`).
|
|
99
|
+
- **Built-in link & anchor scanner**: checks same-origin `<a>`, `<img>`, `<script>`, `<link>`, `srcset`, media, and `<iframe>` targets for broken links, redirect chains (`> 2` hops), and broken in-page or cross-page `#anchor` targets; in `full` (or `quality.checkExternalLinks: true`), also verifies external links with per-host concurrency caps (`2`), anti-bot `403`/`429` classification, and strict SSRF pinning.
|
|
100
|
+
- **Bundled `axe-core@4.14.1` accessibility audit**: automatic in `full` (or `quality.checkAxe: true`); injects `axe-core` over native Chrome CDP (works under strict CSP and reuses the smoke browser session) and integrates with `waivers[]`.
|
|
101
|
+
|
|
102
|
+
### 5. `load` (Bounded Concurrency Load Test)
|
|
103
|
+
|
|
104
|
+
- **Opt-in with public-host guard**: only runs with `--only load` or `--preset full`, and refuses to hit non-loopback public targets unless `--allow-load` is explicitly passed.
|
|
105
|
+
- **Built-in `node:http2` + keep-alive runner**: negotiates TLS ALPN automatically to use pooled HTTP/2 multiplexed streams (`h2`) or HTTP/1.1 keep-alive pooling, reporting RPS, throughput, status counts, and TTFB / total latency `p50` / `p95` / `p99`.
|
|
106
|
+
- **Hardcoded safety caps**: concurrency `<= 20`, duration `<= 15s`, total requests `<= 500`, and redirects disabled so a stray run cannot overwhelm production.
|
|
107
|
+
|
|
108
|
+
## Layer 2: Optional External Enhancements (Zero Impact When Missing)
|
|
109
|
+
|
|
110
|
+
You do not need any of these tools for daily development or CI — Layer 1 already covers every probe natively. Only install one if you want its specialized depth and enable it explicitly in config (run `rim doctor` anytime to see status and install hints):
|
|
111
|
+
|
|
112
|
+
- **`testssl.sh`** (`sec.runTestssl: true`): exhaustive historical TLS CVE and compliance scanning beyond the built-in TLS matrix & certificate checks.
|
|
113
|
+
- **`oha` / `h2load`** (`load.runner: "oha" | "h2load"`): native Rust/C load generators when you want to swap or cross-check against the built-in `node:http2` runner.
|
|
114
|
+
- **`lychee`** (`quality.runLychee: true`): high-concurrency external link checking for very large multi-hundred-link sites.
|
|
115
|
+
- **`axe` (`@axe-core/cli`)** (`quality.runAxe: true`): external axe CLI runner when your pipeline pins a separate external version.
|
|
116
|
+
|
|
117
|
+
## Targets & Local Bridges
|
|
118
|
+
|
|
119
|
+
- **Live URL**: pass `http(s)://...` directly (e.g. `rim https://example.com`) to skip local server startup.
|
|
120
|
+
- **Config discovery**: `--config` > `RIM_CONFIG` > `.rim.json` > `rim.config.json` > `.rimrc.json` > `package.json#rim`.
|
|
121
|
+
- **Zero-config static server**: if no config exists, `rim` looks for `index.html` in `dist/web`, `dist`, `build`, `out`, `public`, or `.` and serves it on `127.0.0.1:0` with `.br`/`.gz` negotiation and `304` support (override via `--serve-dir`).
|
|
122
|
+
- **App bridges**: mount an in-process JS/TS module (`--bridge` / `bridge.type = "module"`) or run any command (`--start` / `bridge.type = "command"`), with automatic LIFO cleanup on exit or `Ctrl+C`.
|
|
123
|
+
|
|
124
|
+
## Baselines, Reports & CLI Contract
|
|
125
|
+
|
|
126
|
+
- **Host baselines**: stored in `~/.cache/rim/<host>/history.jsonl` via `--save-baseline`, `--diff`, and `rim baseline list|diff|prune`.
|
|
127
|
+
- **Single-file summary report**: pass `--html <path>` for a self-contained, XSS-escaped HTML summary.
|
|
128
|
+
- **Environment variables**: `RIM_CONFIG` (config path), `RIM_CHROME_PATH` / `CHROME_PATH` (browser path), `RIM_LANG` / `CLIS_LANG` (display language), `RIM_NO_COLOR` / `NO_COLOR` (disable ANSI color).
|
|
129
|
+
- **Language & JSON contract**: language flag is locked to `--lang <system|en|zh>` (`--locale` is rejected); every command supports `--json` with deterministic `{ ok: true, ... }` / `{ ok: false, error: { code, message } }` envelopes.
|
|
130
|
+
- **Built-in maintenance commands**: `rim lang [system|en|zh]`, `rim update [--check]`, and `rim uninstall [--dry-run]`.
|
|
131
|
+
|
|
132
|
+
## Documentation
|
|
133
|
+
|
|
134
|
+
- CLI command surface & JSON payloads: [packages/rim-cli/docs](https://github.com/iyowei/clis/tree/main/packages/rim-cli/docs/README.md)
|
|
135
|
+
- Programmable API & ADRs (`0033-0036`): [`@iyowei/rim`](https://github.com/iyowei/clis/blob/main/packages/rim/README.md)
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# `@iyowei/rim-cli`
|
|
2
|
+
|
|
3
|
+
[](https://github.com/iyowei/clis/actions/workflows/release.yml)
|
|
4
|
+
[](https://www.npmjs.com/package/@iyowei/rim-cli)
|
|
5
|
+
[](https://www.npmjs.com/package/@iyowei/rim-cli)
|
|
6
|
+

|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
[English](https://github.com/iyowei/clis/blob/main/packages/rim-cli/README.md) | **中文**
|
|
10
|
+
|
|
11
|
+
`rim` 是一个开箱即用的网站黑盒体检与上线门禁命令行工具 (Bun 优先, 支持 Node.js `>= 22.18.0` 平滑回退)。
|
|
12
|
+
|
|
13
|
+
你只需要装一个 `rim`, 协议压缩、安全头与 TLS、Lighthouse 性能、运行时冒烟、死链与锚点、无障碍审计和受控并发压测就全部就绪, 无需额外全局安装其他检测工具 (浏览器类探针直接复用本机已有的 Chrome / Chromium / Edge)。如果要在代码或脚本里直接调用引擎, 请看核心 API 包 [`@iyowei/rim`](https://github.com/iyowei/clis/blob/main/packages/rim/README.zh-CN.md)。
|
|
14
|
+
|
|
15
|
+
## 安装
|
|
16
|
+
|
|
17
|
+
### 1. 一键脚本安装 (macOS / Linux / Windows, 无需预装 Node / Bun)
|
|
18
|
+
|
|
19
|
+
```shell
|
|
20
|
+
# macOS / Linux
|
|
21
|
+
curl -fsSL https://raw.githubusercontent.com/iyowei/clis/main/packages/rim-cli/install.sh | sh
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
```powershell
|
|
25
|
+
# Windows (PowerShell)
|
|
26
|
+
irm https://raw.githubusercontent.com/iyowei/clis/main/packages/rim-cli/install.ps1 | iex
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### 2. 包管理器全局安装或免安装试跑
|
|
30
|
+
|
|
31
|
+
```shell
|
|
32
|
+
bun install -g @iyowei/rim-cli
|
|
33
|
+
npm install -g @iyowei/rim-cli
|
|
34
|
+
bunx @iyowei/rim-cli --help
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## 快速上手
|
|
38
|
+
|
|
39
|
+
```shell
|
|
40
|
+
# 1. 在项目目录直接运行: 自动读 .rim.json 或探测本地构建目录并跑默认 ci 门禁
|
|
41
|
+
rim
|
|
42
|
+
|
|
43
|
+
# 2. 零浏览器极速体检公网站点 (协议、压缩、缓存、安全头与 CSP3)
|
|
44
|
+
rim https://example.com --preset quick
|
|
45
|
+
|
|
46
|
+
# 3. CI 严格门禁 (不达标、出现意外 SKIP 或零检查均返回退出码 1)
|
|
47
|
+
rim --preset ci --strict
|
|
48
|
+
|
|
49
|
+
# 4. 完整五探针体检 (单端 mobile, 不落盘 Lighthouse 报告, 公网压测须带 --allow-load)
|
|
50
|
+
rim https://example.com --preset full --allow-load --device mobile --no-report
|
|
51
|
+
|
|
52
|
+
# 5. 保存历史基线、对比回归变化并导出单文件 HTML 报告
|
|
53
|
+
rim https://example.com --preset quick --save-baseline --diff --html report.html
|
|
54
|
+
|
|
55
|
+
# 6. 只读检查运行时、本机浏览器、内置引擎与可选扩展工具状态
|
|
56
|
+
rim doctor
|
|
57
|
+
|
|
58
|
+
# 7. 在当前目录生成起步配置 .rim.json
|
|
59
|
+
rim init --yes
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## 三档预设怎么选 (`--preset`)
|
|
63
|
+
|
|
64
|
+
- **`quick`**: 零浏览器极速体检, 只跑 `proto` + `sec` (几秒完成, 适合发版后快速复核)。
|
|
65
|
+
- **`ci`** (默认): 上线前常规门禁, 跑 `proto` + `sec` + `perf`, 如果配置了冒烟则一并跑 `quality`。
|
|
66
|
+
- **`full`**: 全链路深度体检, 五个探针全开 (包含内置 TLS 矩阵、跨源外链、随包 `axe-core` 无障碍与受控压测)。
|
|
67
|
+
|
|
68
|
+
也可以用 `--only <list>` 或 `--skip <list>` 按需组合单个探针 (`proto,sec,perf,quality,load`), 设备档位独立用 `--device <mobile|desktop|both>` 控制。
|
|
69
|
+
|
|
70
|
+
## 第一层: 开箱内置检测 (只装 `rim`, 零额外安装)
|
|
71
|
+
|
|
72
|
+
以下全部检测项在安装 `rim` 后即可直接运行, 不依赖任何第三方全局 CLI。
|
|
73
|
+
|
|
74
|
+
### 1. `proto` (协议、压缩、缓存与首包体积)
|
|
75
|
+
|
|
76
|
+
- **状态码与首字节耗时**: 核验入口 HTTP `200` 状态码与可选 `TTFB` 上限。
|
|
77
|
+
- **三编码真实线缆字节**: 分别发 `identity`、`gzip`、`br` 真实请求, 精确计量压缩后的线缆字节 (即使响应为 `chunked` 也能准确测量), 未开压缩或缺少 Brotli 时提醒。
|
|
78
|
+
- **缓存与条件验证**: 检查 `Vary: Accept-Encoding`、`ETag` / `Last-Modified`、`Cache-Control` (HTML 误设 `immutable` 或缺失 `Cache-Control` 时告警), 并实发 `If-None-Match` 验证 `304 Not Modified`。
|
|
79
|
+
- **首包预算与预加载**: 对照 QUIC (`12 KB`) 与 TCP IW10 (`14.6 KB`) 首包基线以及配置中的 `htmlBrBytes` / `totalCriticalBrBytes` 预算, 自动识别 HTML `<link rel="preload">` 与 HTTP `Link` 头预加载资源并汇总体积。
|
|
80
|
+
- **HTTP/2 与 HTTP/3 (QUIC) 路径 MTU 探测**: 针对 HTTPS 站点在 `ci`/`full` 档位下用本机 Chrome 分别测试 H2 与 H3 加载, 捕捉 QUIC 路径 MTU 黑洞与协商回退。
|
|
81
|
+
|
|
82
|
+
### 2. `sec` (安全响应头、CSP3 与原生 TLS)
|
|
83
|
+
|
|
84
|
+
- **CSP3 策略审计**: 解析单条或多条逗号分隔的 `Content-Security-Policy`, 独立校验 `script-src` 与 `script-src-elem`, 拦截裸 `'unsafe-inline'` 与 JS `'unsafe-eval'`, 放行 WebAssembly 所需的 `'wasm-unsafe-eval'`, 并检查 `style-src`、`frame-ancestors`、`base-uri` 与 `object-src 'none'`。
|
|
85
|
+
- **核心安全响应头**: 检查 `HSTS` (仅 HTTPS, 低于 180 天告警)、`X-Content-Type-Options: nosniff`、`X-Frame-Options`、`Referrer-Policy`、`COOP`、`Permissions-Policy`。
|
|
86
|
+
- **服务端指纹头防泄漏**: 检测 `Server`、`X-Powered-By` 等冗余指纹头 (支持按需自定义 `forbidHeaders`)。
|
|
87
|
+
- **内置原生 TLS 体检 (`node:tls`)**: `full` 档位 (或配置 `sec.checkTls: true`) 自动启用; 并发探测 TLS `1.3` / `1.2` / `1.1` / `1.0` (仍开 1.0/1.1 直接判红), 校验信任链、域名匹配、证书剩余天数 (`< 7` 天判红, `< 30` 天告警)、公钥强度 (`RSA >= 2048` / `EC >= 224`)、弱加密套件与 ALPN (`h2` / `http/1.1`)。
|
|
88
|
+
|
|
89
|
+
### 3. `perf` (Lighthouse 性能与 Web Vitals)
|
|
90
|
+
|
|
91
|
+
- **随包内置 `lighthouse@13.7.0`**: 进程内懒加载执行 (不跑 `perf` 时零加载开销), 支持 `mobile` / `desktop` / `both` 与多路由 (`--path`)。
|
|
92
|
+
- **四维评分与六大指标**: 检查 Performance、Accessibility、Best Practices、SEO 分数门槛, 以及 FCP、LCP、TBT、CLS、SI、TTFB。
|
|
93
|
+
- **主线程与脚本诊断**: 统计主线程长任务 (`> 50ms`) 数量、主线程耗时拆解与脚本启动耗时 Top 列表, 支持 `--cold-gpu` 复现冷着色器缓存和 `--cpu-slowdown` 调节节流。
|
|
94
|
+
- **透明规则豁免**: 命中配置中 `waivers[]` 的规则会明文标记 `WAIVED` 并附带理由, 不阻断门禁。
|
|
95
|
+
|
|
96
|
+
### 4. `quality` (运行时冒烟、全量链接与无障碍)
|
|
97
|
+
|
|
98
|
+
- **Chrome CDP 运行时冒烟**: 默认检查页面零未捕获异常、零 `console.error`、零失败同源请求; 支持在配置里声明交互步骤 (`viewport` / `navigate` / `waitUntil` / `click` / `setValue` / `assert`)。
|
|
99
|
+
- **内置全量链接与锚点扫描**: 扫描同源 `<a>`、`<img>`、`<script>`、`<link>`、`srcset`、音视频与 `<iframe>` 资源, 识别死链、超过 2 跳的重定向链, 以及页内与跨页 `#anchor` 失效; 在 `full` 档位 (或 `quality.checkExternalLinks: true`) 下同步探测跨源外链 (每域名限并发 2, 区分反爬 `403`/`429`, 严禁外链回打内网/回环)。
|
|
100
|
+
- **随包 `axe-core@4.14.1` 无障碍审计**: `full` 档位 (或 `quality.checkAxe: true`) 自动通过原生 Chrome CDP 注入执行 (穿透严格 CSP, 复用冒烟会话无二次启动), 违规规则可直接接入 `waivers[]`。
|
|
101
|
+
|
|
102
|
+
### 5. `load` (受控短时并发压测)
|
|
103
|
+
|
|
104
|
+
- **显式开启与公网护栏**: 仅在 `--only load` 或 `--preset full` 时启用; 针对非本机回环的公网目标必须显式附加 `--allow-load` 才会发压测流量。
|
|
105
|
+
- **内置原生 `node:http2` + Keep-Alive 引擎**: 对 HTTPS 目标自动探测 ALPN, 支持 `h2` 时启用池化 HTTP/2 多路复用流, 否则使用 HTTP/1.1 Keep-Alive 连接池, 产出 RPS、吞吐率、状态码分布以及 TTFB / 总延迟的 `p50` / `p95` / `p99`。
|
|
106
|
+
- **代码级硬上限**: 并发 `<= 20`、时长 `<= 15s`、总请求 `<= 500`, 禁止自动跟随重定向, 防止误操作打爆线上服务。
|
|
107
|
+
|
|
108
|
+
## 第二层: 可选外部工具增强 (不装完全不影响使用)
|
|
109
|
+
|
|
110
|
+
日常开发和 CI 完全不需要装下面这些工具, 上面第一层已经全部内置了等价能力。只有在需要更深度的专项扫描或想横向对比引擎时, 才按需安装并通过配置显式开启 (跑 `rim doctor` 可随时查看状态与安装命令):
|
|
111
|
+
|
|
112
|
+
- **`testssl.sh`** (配置 `sec.runTestssl: true`): 需要对历史 TLS CVE 和合规细节做穷举扫描时使用。
|
|
113
|
+
- **`oha` / `h2load`** (配置 `load.runner: "oha" | "h2load"`): 需要用独立 Rust/C 压测器对比或替代内置 `node:http2` 压测引擎时使用。
|
|
114
|
+
- **`lychee`** (配置 `quality.runLychee: true`): 单个站点有海量外链、需要更高并发扫描时使用。
|
|
115
|
+
- **`axe` (`@axe-core/cli`)** (配置 `quality.runAxe: true`): 团队流水线明确锁定外部独立版 axe CLI 时使用。
|
|
116
|
+
|
|
117
|
+
## 目标来源与本地桥接
|
|
118
|
+
|
|
119
|
+
- **审计线上地址**: 直接传 `http(s)://...` (例如 `rim https://example.com`), 跳过本地启动。
|
|
120
|
+
- **自动读取配置**: 按 `--config` > `RIM_CONFIG` > `.rim.json` > `rim.config.json` > `.rimrc.json` > `package.json#rim` 依次发现。
|
|
121
|
+
- **零配置本地静态服务**: 无配置文件时自动查找 `dist/web`、`dist`、`build`、`out`、`public`、`.` 中的 `index.html`, 在 `127.0.0.1:0` 拉起支持 `.br`/`.gz` 和 `304` 的静态服务 (也可用 `--serve-dir` 指定)。
|
|
122
|
+
- **动态应用桥接**: 支持进程内模块挂载 (`--bridge` / `bridge.type = "module"`) 与任意语言启动命令 (`--start` / `bridge.type = "command"`), 退出或 `Ctrl+C` 时自动逆序清理全部子进程。
|
|
123
|
+
|
|
124
|
+
## 基线、报告与 CLI 约定
|
|
125
|
+
|
|
126
|
+
- **基线水位线**: 存档在 `~/.cache/rim/<host>/history.jsonl`, 支持 `--save-baseline`、`--diff` 以及 `rim baseline list|diff|prune`。
|
|
127
|
+
- **单文件摘要报告**: 传 `--html <path>` 输出零外链、严格转义的单文件 HTML 报告。
|
|
128
|
+
- **环境变量**: `RIM_CONFIG` (配置路径)、`RIM_CHROME_PATH` / `CHROME_PATH` (浏览器路径)、`RIM_LANG` / `CLIS_LANG` (显示语言)、`RIM_NO_COLOR` / `NO_COLOR` (禁用颜色)。
|
|
129
|
+
- **语言与 JSON 契约**: 语言参数唯一锁定 `--lang <system|en|zh>` (拒绝 `--locale`); 全部命令支持 `--json`, 输出确定性 `{ ok: true, ... }` 或 `{ ok: false, error: { code, message } }`。
|
|
130
|
+
- **内置维护命令**: 支持 `rim lang [system|en|zh]`、`rim update [--check]`、`rim uninstall [--dry-run]`。
|
|
131
|
+
|
|
132
|
+
## 延伸文档
|
|
133
|
+
|
|
134
|
+
- CLI 命令面、选项与 JSON 契约: [packages/rim-cli/docs](https://github.com/iyowei/clis/tree/main/packages/rim-cli/docs/README.md)
|
|
135
|
+
- 可编程 API 与架构决策 (ADR 0033-0036): [`@iyowei/rim`](https://github.com/iyowei/clis/blob/main/packages/rim/README.zh-CN.md)
|