@aiti-ai/aiti-cpu-meter 0.2.9 → 0.2.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.
- package/DESC.en.md +43 -0
- package/README.md +61 -121
- package/README.zh-CN.md +98 -0
- package/client/src/internal-client.mjs +3 -2
- package/dev-pack.mjs +16 -3
- package/dist/aiti-cpu-meter-client.mjs +39 -67
- package/icon.svg +1 -1
- package/index.ts +27 -1
- package/package.json +12 -3
- package/skills/jank-debug/SKILL.md +3 -0
- package/tools/deploy.mjs +1 -0
package/DESC.en.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
Main-thread smoothness detector: a small panel in the corner of the page — a rAF seconds counter + a 0-100 smoothness score (Apdex-anchored, color tiers). **When the main thread stalls, the counter freezes and the score drops off a cliff**; minimize it to a corner icon for long sessions and open it later to see the session average.
|
|
2
|
+
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
## Four ways to use it
|
|
6
|
+
|
|
7
|
+
### 1. Pages of this instance (pi-web)
|
|
8
|
+
|
|
9
|
+
Off by default in the aiti-ai build (turn on "Enable detector" under Feature Management in the extension manager). The panel can be dragged and minimized; position / scoring / minimize toggles are listed under Feature Management below.
|
|
10
|
+
|
|
11
|
+
### 2. Inject into any website: script tag
|
|
12
|
+
|
|
13
|
+
The external build is a single-file IIFE — any page can load it with a `<script>` tag (cross-origin allowed, publicApi declared):
|
|
14
|
+
|
|
15
|
+
```html
|
|
16
|
+
<script src="{{aiti-url}}/api/extensions/{{ext-id}}/aiti-cpu-meter.js" defer></script>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
> `{{aiti-url}}` is replaced with **this pi-web instance's external address** (including the `/dev` prefix) — paste it into the target site and it works.
|
|
20
|
+
|
|
21
|
+
### 3. Inject into any website: bookmarklet (no site changes)
|
|
22
|
+
|
|
23
|
+
Create a browser bookmark, paste the line below as its URL (click "Copy"), then click the bookmark on any page to attach the detector:
|
|
24
|
+
|
|
25
|
+
```js
|
|
26
|
+
javascript:(function(){var s=document.createElement('script');s.src='{{aiti-url}}/api/extensions/{{ext-id}}/aiti-cpu-meter.js';s.defer=1;document.body.appendChild(s)})();void 0
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### 4. Site-wide automatic injection: service-tunnels
|
|
30
|
+
|
|
31
|
+
After installing [service-tunnels](http://aiti.pw/extensions/service-tunnels.html), tick "CPU smoothness detector" in its public config — proxied/public page HTML gets injected automatically, no per-page script needed.
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Jank analysis (🤖 ask AI)
|
|
36
|
+
|
|
37
|
+
The 🤖 "Ask AI" button in the panel header hands the live data (smoothness score / long tasks / LoAF script attribution / jank snapshot) to `aiti-helper`, which starts a "debug page jank" AI session to find the root cause and propose a fix.
|
|
38
|
+
|
|
39
|
+
## How the numbers work
|
|
40
|
+
|
|
41
|
+
- The counter = real time since the previous frame; a main thread hogged by a long task freezes the counter
|
|
42
|
+
- The 0-100 smoothness score is Apdex-anchored on the long-task ratio, with color tiers (green ≥ 90 / yellow ≥ 70 / red < 70)
|
|
43
|
+
- Session stats: average score / running time / lowest score, accumulating even while minimized
|
package/README.md
CHANGED
|
@@ -1,157 +1,97 @@
|
|
|
1
|
-
# aiti-cpu-meter
|
|
1
|
+
# @aiti-ai/aiti-cpu-meter
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> Main-thread smoothness detector — a seconds counter + 0–100 smoothness score + color tiers + minimize + AI jank debugging. Ships as two artifacts: a pi-web extension (internal) and a standalone single-file injector you can register into any website you develop.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
English · [简体中文](./README.zh-CN.md)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## About aiti
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
This package is part of the **aiti** ecosystem — a personal AI development workbench powered by [pi](https://pi.dev): **aiti-agent** (a self-hosted web workbench built on the open-source [pi-web](https://github.com/aiti-ai/aiti-ai)) plus debug injection into mainstream dev tools (aiti-devtools) and a rich extension system.
|
|
10
10
|
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
- 官网 / site: <https://aiti.pw>
|
|
11
|
+
- Workbench & monorepo: <https://github.com/aiti-ai/aiti-ai>
|
|
12
|
+
- Site: <https://aiti.pw>
|
|
14
13
|
|
|
14
|
+
## What it does
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
可注册/注入到**其他网站**评估开发者自己的站点。
|
|
18
|
-
|
|
19
|
-
## 这是什么
|
|
20
|
-
|
|
21
|
-
| 能力 | 说明 |
|
|
16
|
+
| Capability | Notes |
|
|
22
17
|
|---|---|
|
|
23
|
-
|
|
|
24
|
-
|
|
|
25
|
-
|
|
|
26
|
-
|
|
|
27
|
-
|
|
|
28
|
-
| **✨
|
|
29
|
-
|
|
|
30
|
-
| **双产物** | 内部版(pi-web 扩展,features 控制)+ 外部版(standalone 单文件,任意网站注入) |
|
|
18
|
+
| **Smoothness score** | 0–100 (100 = fluid, 0 = stuck), gap-magnitude curve anchored on Apdex/INP/TBT + blocking/freeze penalties, 4 color tiers |
|
|
19
|
+
| **Seconds counter** | rAF-driven; freezes exactly when the main thread is stuck (a hard signal for diagnosing freeze moments) |
|
|
20
|
+
| **Session stats** | Time-weighted **average smoothness** + **run duration** + **lowest dip** for the whole session — keep it running all day, check the overall picture when you wrap up |
|
|
21
|
+
| **Minimize** | Shrinks to a tiny icon (color dot + live score); drag it out of the way and keep it running; position/state persisted |
|
|
22
|
+
| **On-site report** | `window.__aitiCpuMeter.report()` returns the full snapshot: score / window averages / gaps / long tasks / **LoAF script attribution** / jank snapshots / environment |
|
|
23
|
+
| **✨ Ask AI** | Panel button → hands the on-site report to aiti-helper and opens a "debug page jank" session (internal), or POSTs it to pi-web and jumps to the new session (standalone on any website) |
|
|
24
|
+
| **Dual artifacts** | Internal (pi-web extension, feature-gated) + external (standalone single file, injectable into any website) |
|
|
31
25
|
|
|
32
|
-
##
|
|
26
|
+
## Three injection channels (evaluate your own sites)
|
|
33
27
|
|
|
34
|
-
### ① service-tunnels
|
|
28
|
+
### ① service-tunnels injection (main path: proxied / published sites)
|
|
35
29
|
|
|
36
|
-
|
|
37
|
-
响应自动注入外部版(无需改自己网站代码)。注册源 id=`aiti-cpu-meter`(零 service-tunnels 改动)。
|
|
30
|
+
When publishing/proxying a site port through service-tunnels, tick **CPU smoothness meter** in the publish form → the external artifact is auto-injected into that channel's HTML responses (no changes to your site). Registered under source id `aiti-cpu-meter`.
|
|
38
31
|
|
|
39
|
-
### ②
|
|
32
|
+
### ② Bookmarklet (any non-proxied website)
|
|
40
33
|
|
|
41
34
|
```
|
|
42
|
-
javascript:(()=>{if(window.__aitiCpuMeter){window.__aitiCpuMeter.dispose();return;}const s=document.createElement('script');s.src='https://<pi-web
|
|
35
|
+
javascript:(()=>{if(window.__aitiCpuMeter){window.__aitiCpuMeter.dispose();return;}const s=document.createElement('script');s.src='https://<pi-web host>/api/extensions/aiti-cpu-meter/aiti-cpu-meter.js';s.defer=true;document.head.appendChild(s)})()
|
|
43
36
|
```
|
|
44
37
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
### ③ 跨实例注入(feature:service.url + inject.enabled)
|
|
48
|
-
|
|
49
|
-
从目标 pi-web 实例拉外部版注入当前页(参照 aiti-debug-inject)。
|
|
50
|
-
|
|
51
|
-
## 交互
|
|
52
|
-
|
|
53
|
-
- **最小化**:标题栏 **−** → 缩成小图标(色点 + 实时两位分数,颜色随流畅度变化),可拖到任意位置,点开展开。
|
|
54
|
-
- **拖动**:**内部版**面板走 aiti-float 契约(data-ext-float,拖动/位置持久化接管,max=0 不注入最大化);**外部版**面板 + FAB 由 core 自带拖动(外部网站没有 aiti-float),位置持久化。两版 FAB 均由 core 自带拖动。
|
|
55
|
-
- **关闭**:**✕** 只隐藏当前页(不持久化,刷新重现);最小化/展开状态会持久化(刷新后保持小图标原位)。
|
|
56
|
-
- 展开态面板:**第一行** 当前分(大)+ 10 格色条(同色);**第二行** 会话统计(平均/运行/最低);下面保留 v0.1 原始诊断行
|
|
57
|
-
(CPU 读秒 / gap / max / longtask / 上次卡顿快照)。标题栏为「渲染流畅度」。
|
|
38
|
+
Run once to inject, run again to remove. Parameters: `aiti-cpu-meter.js?meter-pos=right-top&meter-score=off&meter-min=off`.
|
|
58
39
|
|
|
59
|
-
|
|
40
|
+
### ③ Cross-instance injection (feature: service.url + inject.enabled)
|
|
60
41
|
|
|
61
|
-
|
|
42
|
+
Pulls the external artifact from a target pi-web instance and injects it into the current page.
|
|
62
43
|
|
|
63
|
-
|
|
64
|
-
现场报告 JSON 已预填输入框)→ 用户补充现象描述 → 生成 → AI 按 `skills/jank-debug/SKILL.md`
|
|
65
|
-
手册调试(读本报告/LoAF 归因/历史卡顿案例库 → 定位元凶 → 修复建议)。
|
|
66
|
-
aiti-helper 是懒加载扩展:未物化时先 `ctx.ensureMaterialized("aiti-helper")` 拉起再唤起。
|
|
67
|
-
会话 cwd = 当前会话工作目录(helper invoke 自动带)。
|
|
68
|
-
- **外部版**(任意注入网站,没有 aiti-helper):点 ✨ → 简易 prompt 弹窗(自动附当前分/平均/最低/
|
|
69
|
-
longtask 概要)→ 提交 → `POST /api/extensions/aiti-cpu-meter/ask-ai` → 服务端**两段式建会话**
|
|
70
|
-
(`ensure_session` 秒级拿 sessionId → 非阻塞发 prompt,手册指针内联注入——不等模型回合,
|
|
71
|
-
不撞网关 60s 超时;同 ts 幂等,POST 超时后 GET 重试不重复建;`ask-ai` 已声明 publicApi 作
|
|
72
|
-
GET 兑底)→ 返回 `{ sessionId, url }` → 新标签页跳转 pi-web `/?session=<id>`。pi-web 地址按
|
|
73
|
-
注入脚本来源自动推导(也可 `__aitiCpuMeterOpts.base` 显式指定);跨域回源需部署
|
|
74
|
-
`API_ALLOW_ORIGINS`(本部署已配 `*`)。
|
|
75
|
-
会话 cwd = 用户 HOME(外部站点调试与项目无关联,AI 可跨仓读性能文档;env
|
|
76
|
-
`AITI_CPU_METER_CWD` 可覆盖)。
|
|
77
|
-
服务端两段式建会话(ensure_session 秒级 → 非阻塞发 prompt)——不等模型回合,不撞网关 60s 超时;
|
|
78
|
-
同 ts 幂等(POST 超时后 GET 重试不重复建会话,失败不缓存可重试)。
|
|
79
|
-
报告附带:页面脚本源码路径全集 + 主要大块区域(LoAF 归因对号用)+ doc 元信息 + 同站 cookie
|
|
80
|
-
(`meter-cookie=0` 关;HttpOnly 不可见)。
|
|
81
|
-
会话 cwd = 用户 HOME(外部站点调试与项目无关联,AI 可跨仓读性能文档;env
|
|
82
|
-
`AITI_CPU_METER_CWD` 可覆盖)。
|
|
44
|
+
## Interaction
|
|
83
45
|
|
|
84
|
-
|
|
85
|
-
|
|
46
|
+
- **Minimize**: title-bar **−** → tiny icon (color dot + live score), draggable, click to expand.
|
|
47
|
+
- **Drag**: internal panel follows the aiti-float contract (`data-ext-float`, drag/position persistence taken over); external panel + FAB have built-in dragging (external sites don't have aiti-float), position persisted.
|
|
48
|
+
- **Close**: **✕** hides the current page only (not persisted, reappears on refresh); minimized/expanded state persists.
|
|
49
|
+
- Expanded panel: row 1 = current score (large) + 10-cell color bar; row 2 = session stats (average/duration/dip); below that the raw diagnostics (CPU seconds / gap / max / longtask / last jank snapshot).
|
|
86
50
|
|
|
87
|
-
##
|
|
51
|
+
## Scoring algorithm
|
|
88
52
|
|
|
89
53
|
```
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
skills/ aiti-helper 帮助点:jank-debug「调试页面卡顿」(现场分析手册 + 历史案例库 + 修复工具箱)
|
|
54
|
+
gapScore(g): ≤33ms=100 · 200ms=40 · 1000ms=10 · 10000ms=0 (piecewise linear, eye-calibrated)
|
|
55
|
+
frameHealth = min(gapScore(ewmaGap), gapScore(recentMax)) # sustained (EWMA) vs spike (decayed max), worse wins
|
|
56
|
+
smoothness = clamp( 100 − 0.60×(100−frameHealth) − 0.20×blockingPenalty − 0.20×freezePenalty , 0, 100 )
|
|
57
|
+
blockingPenalty = long-task TBT blocking-ratio EWMA (Σmax(0,dur−50))
|
|
58
|
+
freezePenalty = min(50, freezeCount×10) (>600ms frames, decayed counting)
|
|
59
|
+
colors: ≥90 green · 75–89 yellow · 50–74 orange · <50 red
|
|
97
60
|
```
|
|
98
61
|
|
|
99
|
-
|
|
100
|
-
- **内部版接 aiti-float**(pi-web 内有它):面板标 `data-ext-float="1"`(autoh/max=0/显式 key),拖动/位置/缩放/置前由 aiti-float 接管;**外部版自带拖动**(外部网站没有 aiti-float,功能一致,core 同一份实现)。
|
|
101
|
-
- 服务端端点:`/api/extensions/aiti-cpu-meter/aiti-cpu-meter.js`(外部版,no-store)、
|
|
102
|
-
`.../meter-version`(内容哈希,浏览器侧注入前取 `?v=`)。
|
|
103
|
-
- 外部版幂等:`window.__aitiCpuMeter` 已存在则先 dispose(防三通道叠加);dispose 后可卸载。
|
|
62
|
+
Anchored on public algorithms: **Apdex** (satisfaction threshold), **INP** (200/500ms), **TBT** (Google), **RAIL** (frame ≤16.7ms). Calibration: fully idle = 100 · intermittent 120ms = 82 · single 2s freeze = 44 · repeated 1s freeze ×5 = 38 · sustained 150ms ≈ 75.
|
|
104
63
|
|
|
105
|
-
##
|
|
64
|
+
## Features (extman feature panel)
|
|
106
65
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
锚定公开算法:**Apdex**(满意度阈值)、**INP**(200/500ms)、**TBT**(Google)、**RAIL**(帧 ≤16.7ms)。
|
|
117
|
-
校准(实现期实测):全程空闲=100 · 断续 120ms=82 · 单次 2s 冻结=44 · 反复 1s 冻结×5=38 · 持续 150ms≈75。
|
|
66
|
+
| feature | type | default | notes |
|
|
67
|
+
|---|---|---|---|
|
|
68
|
+
| `enabled` | boolean | false | show the meter on this instance (off by default; enable in ExtMan "Feature management") |
|
|
69
|
+
| `pos` | string | left-bottom | default position (drag position wins once dragged) |
|
|
70
|
+
| `score` | boolean | true | smoothness score row (off = pure counter) |
|
|
71
|
+
| `minimize` | boolean | true | allow minimizing (off = expanded + ✕ only) |
|
|
72
|
+
| `askAi` | boolean | true | panel "Ask AI" button (✨; on-site report → aiti-helper jank-debug session) |
|
|
73
|
+
| `inject.enabled` | boolean | false | cross-instance injection (from the `service.url` target instance) |
|
|
74
|
+
| `service.url` | string | — | target pi-web base URL (incl. sub-path) |
|
|
118
75
|
|
|
119
|
-
##
|
|
76
|
+
## Design notes
|
|
120
77
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
| `score` | boolean | true | 流畅度评分行(关 = 纯读秒) |
|
|
126
|
-
| `minimize` | boolean | true | 支持最小化(关 = 只有展开态 + ✕) |
|
|
127
|
-
| `askAi` | boolean | true | 面板「问 AI」按钮(✨ sparkles 图标;现场报告 → aiti-helper 卡顿调试会话) |
|
|
128
|
-
| `inject.enabled` | boolean | false | 跨实例注入(从 `service.url` 目标实例注入外部版) |
|
|
129
|
-
| `service.url` | string | — | 目标 pi-web 基址(含子路径) |
|
|
130
|
-
|
|
131
|
-
## 部署
|
|
132
|
-
|
|
133
|
-
```bash
|
|
134
|
-
node pi-web-ext/aiti-cpu-meter/tools/build.mjs # 构建双产物(esbuild,复用仓库根依赖)
|
|
135
|
-
node pi-web-ext/aiti-cpu-meter/tools/deploy.mjs # 部署到 ~/.pi/web{,-dev}/extensions/aiti-cpu-meter/
|
|
136
|
-
```
|
|
78
|
+
- Background tabs: rAF stops naturally → no sampling; on visibility restore the frame baseline resets so hidden time is never counted as jank. Session stats accumulate only while visible.
|
|
79
|
+
- First-load 2s gate: samples but doesn't score, avoiding the first-layout gap.
|
|
80
|
+
- localStorage keys are prefixed `aiti-cpu-meter:` — isolated per site domain, no conflicts on third-party sites.
|
|
81
|
+
- Injection registry (`__stInjectRegistry`) is owned by service-tunnels; this extension registers through it (soft dependency).
|
|
137
82
|
|
|
138
|
-
|
|
83
|
+
## Install
|
|
139
84
|
|
|
140
|
-
|
|
85
|
+
Bundled with **aiti-agent** (`@aiti-ai/pi-web`) — enable it from the in-app extension manager (ExtMan / App Center).
|
|
141
86
|
|
|
142
|
-
|
|
143
|
-
无 UI 插槽、无 npm 构建链(esbuild 复用仓库根)。拖动/定位:内部版面板接 aiti-float(v0.3 起,统一契约;
|
|
144
|
-
aiti-float 未装时静态停角位)、FAB 与外部版全自带。
|
|
87
|
+
Manual install: place this package at `~/.pi/web/extensions/aiti-cpu-meter/` and reload pi-web. The standalone artifact is served at `/api/extensions/aiti-cpu-meter/aiti-cpu-meter.js`.
|
|
145
88
|
|
|
146
|
-
##
|
|
89
|
+
## Documentation
|
|
147
90
|
|
|
148
|
-
-
|
|
149
|
-
-
|
|
150
|
-
-
|
|
151
|
-
- 协议唯一来源:注入注册点(`__stInjectRegistry`)归 service-tunnels,本扩展经其注册(软依赖:未装则跳过)。
|
|
91
|
+
- Documentation (English): <https://aiti.pw/en/extensions/aiti-cpu-meter.html>
|
|
92
|
+
- 文档(中文): <https://aiti.pw/extensions/aiti-cpu-meter.html>
|
|
93
|
+
- Extension registry: <https://aiti.pw/extensions.html> · machine-readable <https://aiti.pw/extensions.json>
|
|
152
94
|
|
|
153
|
-
##
|
|
95
|
+
## License
|
|
154
96
|
|
|
155
|
-
|
|
156
|
-
- English docs: <https://aiti.pw/en/extensions/aiti-cpu-meter.html>
|
|
157
|
-
- 扩展注册表 / registry: <https://aiti.pw/extensions.html> · machine-readable <https://aiti.pw/extensions.json>
|
|
97
|
+
MIT
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# @aiti-ai/aiti-cpu-meter
|
|
2
|
+
|
|
3
|
+
> 主线程流畅度检测器——读秒 + **0-100 流畅度分** + **颜色分层** + **最小化** + **AI 卡顿调试**。内部版(pi-web 扩展)/ 外部版(standalone 单文件,可注入任意网站)双产物。
|
|
4
|
+
|
|
5
|
+
[English](./README.md) · 简体中文
|
|
6
|
+
|
|
7
|
+
## 关于 aiti
|
|
8
|
+
|
|
9
|
+
本包是 **aiti** 生态的组成部分——以 [pi](https://pi.dev) 为引擎的个人 AI 开发工作台与本地调试注入生态:**aiti-agent**(自托管 Web 工作台,基于开源项目 [pi-web](https://github.com/aiti-ai/aiti-ai) 构建,浏览器为主操作面)+ 各开发工具内的调试注入(aiti-devtools)+ 丰富的扩展体系。
|
|
10
|
+
|
|
11
|
+
- 工作台 / 生态仓库(aiti-agent,基于 pi-web): <https://github.com/aiti-ai/aiti-ai>
|
|
12
|
+
- 官网: <https://aiti.pw>
|
|
13
|
+
|
|
14
|
+
## 功能定位
|
|
15
|
+
|
|
16
|
+
| 能力 | 说明 |
|
|
17
|
+
|---|---|
|
|
18
|
+
| **流畅度评分** | 0-100(100=流畅,0=卡死),Apdex/INP/TBT 锚定的 gap 幅值曲线 + 阻塞/冻结惩罚,4 档颜色 |
|
|
19
|
+
| **读秒器** | rAF 驱动,主线程卡死即冻结(诊断卡死时刻的硬信号) |
|
|
20
|
+
| **会话统计** | 全程时间加权**平均流畅度** + **运行时长** + **最低谷**——工作全程挂着,收工点开看整体表现 |
|
|
21
|
+
| **最小化** | 缩成小图标(色点 + 实时分数),拖到不碍事处长期跑着;位置/状态持久化 |
|
|
22
|
+
| **现场报告 report()** | `window.__aitiCpuMeter.report()` 一键取全套现场:评分/窗口平均/gap/长任务/**LoAF 脚本归因**/卡顿快照/环境 |
|
|
23
|
+
| **✨ 问 AI** | 面板按钮 → 现场报告交 aiti-helper 建「调试页面卡顿」会话(内部版);或 POST 回 pi-web 建会话并自动跳转(外部版) |
|
|
24
|
+
| **双产物** | 内部版(pi-web 扩展,features 控制)+ 外部版(standalone 单文件,任意网站注入) |
|
|
25
|
+
|
|
26
|
+
## 三通道注入(开发者评估自己的网站)
|
|
27
|
+
|
|
28
|
+
### ① service-tunnels 注入(主路径:被代理/公开的站点)
|
|
29
|
+
|
|
30
|
+
在 service-tunnels 公开/代理自己的站点端口时,公开表单勾选 **CPU 流畅度检测器** → 该通道的 HTML 响应自动注入外部版(无需改自己网站代码)。注册源 id=`aiti-cpu-meter`。
|
|
31
|
+
|
|
32
|
+
### ② bookmarklet(任意未代理网站)
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
javascript:(()=>{if(window.__aitiCpuMeter){window.__aitiCpuMeter.dispose();return;}const s=document.createElement('script');s.src='https://<pi-web 域>/api/extensions/aiti-cpu-meter/aiti-cpu-meter.js';s.defer=true;document.head.appendChild(s)})()
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
执行一次注入、再执行一次卸载。可带参数:`aiti-cpu-meter.js?meter-pos=right-top&meter-score=off&meter-min=off`。
|
|
39
|
+
|
|
40
|
+
### ③ 跨实例注入(feature:service.url + inject.enabled)
|
|
41
|
+
|
|
42
|
+
从目标 pi-web 实例拉外部版注入当前页。
|
|
43
|
+
|
|
44
|
+
## 交互
|
|
45
|
+
|
|
46
|
+
- **最小化**:标题栏 **−** → 缩成小图标(色点 + 实时两位分数),可拖动,点开展开。
|
|
47
|
+
- **拖动**:内部版面板走 aiti-float 契约(拖动/位置持久化接管);外部版面板 + FAB 自带拖动,位置持久化。
|
|
48
|
+
- **关闭**:**✕** 只隐藏当前页(刷新重现);最小化/展开状态持久化。
|
|
49
|
+
- 展开态面板:第一行当前分(大)+ 10 格色条;第二行会话统计(平均/运行/最低);下面保留原始诊断行(CPU 读秒 / gap / max / longtask / 上次卡顿快照)。
|
|
50
|
+
|
|
51
|
+
## 评分算法
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
gapScore(g):≤33ms=100 · 200ms=40 · 1000ms=10 · 10000ms=0(分段线性,贴合人眼)
|
|
55
|
+
frameHealth = min(gapScore(ewmaGap), gapScore(recentMax)) # 持续(EWMA)与尖峰(衰减max)取较差
|
|
56
|
+
流畅度 = clamp( 100 − 0.60×(100−frameHealth) − 0.20×blockingPenalty − 0.20×freezePenalty , 0, 100 )
|
|
57
|
+
blockingPenalty = 长任务 TBT 阻塞占比 EWMA(Σmax(0,dur−50))
|
|
58
|
+
freezePenalty = min(50, 冻结次数×10)(>600ms 帧,衰减计数)
|
|
59
|
+
颜色:≥90 绿 · 75–89 黄 · 50–74 橙 · <50 红
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
锚定公开算法:**Apdex**(满意度阈值)、**INP**(200/500ms)、**TBT**(Google)、**RAIL**(帧 ≤16.7ms)。
|
|
63
|
+
校准:全程空闲=100 · 断续 120ms=82 · 单次 2s 冻结=44 · 反复 1s 冻结×5=38 · 持续 150ms≈75。
|
|
64
|
+
|
|
65
|
+
## 特性(feature 开关,extman 功能管理面板)
|
|
66
|
+
|
|
67
|
+
| feature | type | 默认 | 说明 |
|
|
68
|
+
|---|---|---|---|
|
|
69
|
+
| `enabled` | boolean | false | 本实例显示检测器(默认关,extman「功能管理」打开) |
|
|
70
|
+
| `pos` | string | left-bottom | 默认位置(可拖动后以拖动位置为准) |
|
|
71
|
+
| `score` | boolean | true | 流畅度评分行(关 = 纯读秒) |
|
|
72
|
+
| `minimize` | boolean | true | 支持最小化(关 = 只有展开态 + ✕) |
|
|
73
|
+
| `askAi` | boolean | true | 面板「问 AI」按钮(✨;现场报告 → aiti-helper 卡顿调试会话) |
|
|
74
|
+
| `inject.enabled` | boolean | false | 跨实例注入(从 `service.url` 目标实例注入外部版) |
|
|
75
|
+
| `service.url` | string | — | 目标 pi-web 基址(含子路径) |
|
|
76
|
+
|
|
77
|
+
## 设计说明
|
|
78
|
+
|
|
79
|
+
- 后台标签页:rAF 停发天然不采样;恢复可见时重置帧基准,不把隐藏时长当卡顿。会话统计仅可见时累计。
|
|
80
|
+
- 首载 2s 门控:只采集不评分,避开首帧布局大 gap。
|
|
81
|
+
- localStorage 键带 `aiti-cpu-meter:` 前缀,第三方网站各站域名隔离,无冲突。
|
|
82
|
+
- 注入注册点(`__stInjectRegistry`)归 service-tunnels,本扩展经其注册(软依赖)。
|
|
83
|
+
|
|
84
|
+
## 安装
|
|
85
|
+
|
|
86
|
+
随 **aiti-agent**(`@aiti-ai/pi-web`)捆绑发行——在工作台内的扩展管理器(ExtMan / 应用中心)启用即可。
|
|
87
|
+
|
|
88
|
+
手动安装:把本包放到 `~/.pi/web/extensions/aiti-cpu-meter/` 后 reload。外部版产物由 `/api/extensions/aiti-cpu-meter/aiti-cpu-meter.js` 提供。
|
|
89
|
+
|
|
90
|
+
## 文档
|
|
91
|
+
|
|
92
|
+
- 中文文档: <https://aiti.pw/extensions/aiti-cpu-meter.html>
|
|
93
|
+
- Documentation (English): <https://aiti.pw/en/extensions/aiti-cpu-meter.html>
|
|
94
|
+
- 扩展注册表: <https://aiti.pw/extensions.html> · machine-readable <https://aiti.pw/extensions.json>
|
|
95
|
+
|
|
96
|
+
## 许可证
|
|
97
|
+
|
|
98
|
+
MIT
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// 面板一律 core 自带拖动(内部版/外部版同一份;不再接 aiti-float——Android 实测其接管
|
|
5
5
|
// 导致交互延迟数秒 + 评分被操作拉低)。
|
|
6
6
|
// 读 extman features:
|
|
7
|
-
// - enabled(bool,默认 false——aiti-ai
|
|
7
|
+
// - enabled(bool,默认 false——aiti-ai 镜像侧;开发源内部版 true):本实例页面显示检测器
|
|
8
8
|
// - pos(string,默认 left-bottom)
|
|
9
9
|
// - score(bool,默认 true):流畅度评分行
|
|
10
10
|
// - minimize(bool,默认 true):支持最小化
|
|
@@ -16,9 +16,10 @@
|
|
|
16
16
|
// 无 toolbar / 无弹窗——「就是简单注入检测器」。幂等:feature 变更重挂(先 dispose 旧实例)。
|
|
17
17
|
|
|
18
18
|
import { createMeter, ICON_AI } from "./core.mjs";
|
|
19
|
-
import { extDisplayName } from "../../../_shared/ext-display-names";
|
|
19
|
+
import { extDisplayName, primeExtRegistry } from "../../../_shared/ext-display-names";
|
|
20
20
|
|
|
21
21
|
export default function register(ctx) {
|
|
22
|
+
primeExtRegistry((p) => ctx.apiUrl ? ctx.apiUrl(p) : p); // self-description registry (no central table)
|
|
22
23
|
if (typeof document === "undefined") return;
|
|
23
24
|
|
|
24
25
|
const INJECT_FLAG = "data-aiti-cpu-meter-inject";
|
package/dev-pack.mjs
CHANGED
|
@@ -77,7 +77,7 @@ export function agentsMdTemplate(extId) {
|
|
|
77
77
|
|
|
78
78
|
/** 默认 tools/build.mjs(esbuild 单包零配置;扩展自带 tools/build.mjs 则不走到这里)。 */
|
|
79
79
|
function buildMjsTemplate(extId, extRoot, clientOut, entryRel) {
|
|
80
|
-
|
|
80
|
+
// No hardcoded checkout path: candidates are resolved at run time (see repoCandidates below).
|
|
81
81
|
return `/**
|
|
82
82
|
* ${extId} · 现场构建入口(dev-pack 默认模板,esbuild 单包零配置)
|
|
83
83
|
* 用法:node tools/build.mjs
|
|
@@ -96,12 +96,25 @@ const entryRel = ${JSON.stringify(entryRel || "")};
|
|
|
96
96
|
|
|
97
97
|
// esbuild 解析:部署目录 node_modules → 源码仓 node_modules(本机开发场景)→ PATH 上的 esbuild → npm exec 现拉。
|
|
98
98
|
// 注意:node_modules/esbuild/bin/esbuild 是原生二进制(ELF/Mach-O),必须直接执行(不能当 JS 跑)。
|
|
99
|
+
// Checkout roots are discovered by walking up from the extension dir (a root has node_modules/),
|
|
100
|
+
// plus AITI_REPO_ROOT when set — no machine-specific absolute paths baked into generated files.
|
|
101
|
+
function repoCandidates() {
|
|
102
|
+
const out = [];
|
|
103
|
+
if (process.env.AITI_REPO_ROOT) out.push(process.env.AITI_REPO_ROOT.split(pathSep).join("/") + "/node_modules/esbuild/bin/esbuild");
|
|
104
|
+
let d = extRoot;
|
|
105
|
+
for (let i = 0; i < 8; i++) {
|
|
106
|
+
out.push(d.split(pathSep).join("/") + "/node_modules/esbuild/bin/esbuild");
|
|
107
|
+
const up = dirname(d);
|
|
108
|
+
if (up === d) break;
|
|
109
|
+
d = up;
|
|
110
|
+
}
|
|
111
|
+
return out;
|
|
112
|
+
}
|
|
99
113
|
function findEsbuild() {
|
|
100
114
|
const home = (process.env.HOME || process.env.USERPROFILE || "").split(pathSep).join("/");
|
|
101
115
|
const candidates = [
|
|
102
116
|
extRoot + "/node_modules/esbuild/bin/esbuild",
|
|
103
|
-
|
|
104
|
-
"C:/workspace/aiti-ai/node_modules/esbuild/bin/esbuild", // windows dev box(源码在 D 盘)
|
|
117
|
+
...repoCandidates(),
|
|
105
118
|
];
|
|
106
119
|
for (const c of candidates) {
|
|
107
120
|
if (!existsSync(c)) continue;
|
|
@@ -856,85 +856,57 @@ function createMeter(opts) {
|
|
|
856
856
|
}
|
|
857
857
|
|
|
858
858
|
// ../_shared/ext-display-names.ts
|
|
859
|
-
var EXT_DISPLAY_NAMES = {
|
|
860
|
-
"aiti-acp-agent": { en: "ACP Session Backend", zh: "ACP \u4F1A\u8BDD\u540E\u7AEF" },
|
|
861
|
-
"aiti-ai-input": { en: "AI Input Enhancer", zh: "AI \u8F93\u5165\u589E\u5F3A" },
|
|
862
|
-
"aiti-ai-schedule": { en: "AI Schedule", zh: "AI \u5B9A\u65F6\u4EFB\u52A1" },
|
|
863
|
-
"aiti-ai-speek": { en: "AI Voice Reading", zh: "AI \u8BED\u97F3\u6717\u8BFB" },
|
|
864
|
-
"aiti-ai-usage": { en: "AI Usage", zh: "AI \u7528\u91CF\u7EDF\u8BA1" },
|
|
865
|
-
"aiti-append-system": { en: "Append System Prompt", zh: "\u8FFD\u52A0\u7CFB\u7EDF\u63D0\u793A\u8BCD" },
|
|
866
|
-
"aiti-attach-agent": { en: "Attach Session Backend", zh: "\u9644\u7740\u4F1A\u8BDD\u540E\u7AEF" },
|
|
867
|
-
"aiti-channels": { en: "IM Channels", zh: "IM \u6E20\u9053" },
|
|
868
|
-
"aiti-claude-code-agent": { en: "Claude Code Session Backend", zh: "Claude Code \u4F1A\u8BDD\u540E\u7AEF" },
|
|
869
|
-
"aiti-cmd": { en: "Command Palette", zh: "\u547D\u4EE4\u9762\u677F" },
|
|
870
|
-
"aiti-codex-agent": { en: "Codex Session Backend", zh: "Codex \u4F1A\u8BDD\u540E\u7AEF" },
|
|
871
|
-
"aiti-configs": { en: "Config Versioning & Self-check", zh: "\u914D\u7F6E\u7248\u672C\u5316 + \u5D29\u6E83\u81EA\u68C0" },
|
|
872
|
-
"aiti-cpu-meter": { en: "CPU Meter", zh: "CPU \u6D41\u7545\u5EA6\u4EEA\u8868" },
|
|
873
|
-
"aiti-crash-fatal": { en: "Crash Drill (dev)", zh: "\u5D29\u6E83\u6F14\u4E60\uFF08\u5F00\u53D1\uFF09" },
|
|
874
|
-
"aiti-cursor-agent": { en: "Cursor Session Backend", zh: "Cursor \u4F1A\u8BDD\u540E\u7AEF" },
|
|
875
|
-
"aiti-debug-inject": { en: "Remote Debug Inject", zh: "\u8FDC\u7A0B\u8C03\u8BD5\u6CE8\u5165" },
|
|
876
|
-
"aiti-devtools": { en: "Page DevTools", zh: "\u9875\u9762 AI \u8C03\u8BD5\u5DE5\u5177" },
|
|
877
|
-
"aiti-devtools-vite": { en: "DevTools Vite Plugin", zh: "DevTools Vite \u63D2\u4EF6" },
|
|
878
|
-
"aiti-devtools-vue": { en: "DevTools Vue Plugin", zh: "DevTools Vue \u63D2\u4EF6" },
|
|
879
|
-
"aiti-doc-center": { en: "Doc Center", zh: "\u6587\u6863\u4E2D\u5FC3" },
|
|
880
|
-
"aiti-draft-keeper": { en: "Draft Keeper", zh: "\u8349\u7A3F\u4FDD\u7BA1\u5458" },
|
|
881
|
-
"aiti-echo-agent": { en: "Echo Session Backend", zh: "Echo \u4F1A\u8BDD\u540E\u7AEF" },
|
|
882
|
-
"aiti-editor": { en: "File Editor", zh: "\u6587\u4EF6\u7F16\u8F91\u5668" },
|
|
883
|
-
"aiti-event-bus": { en: "Page Event Bus", zh: "\u9875\u9762\u4E8B\u4EF6\u603B\u7EBF" },
|
|
884
|
-
"aiti-extman": { en: "Extension Manager", zh: "\u6269\u5C55\u7BA1\u7406\u5668" },
|
|
885
|
-
"aiti-float": { en: "Dialog Float Enhancer", zh: "\u5F39\u7A97\u6D6E\u52A8\u589E\u5F3A\u5668" },
|
|
886
|
-
"aiti-folder": { en: "Folder Browser", zh: "\u6587\u4EF6\u5939\u6D4F\u89C8\u5668" },
|
|
887
|
-
"aiti-git-review": { en: "Git Review", zh: "Git \u4EE3\u7801\u5BA1\u6838" },
|
|
888
|
-
"aiti-git-trace": { en: "AI Change Trace", zh: "AI \u53D8\u66F4\u8FFD\u8E2A" },
|
|
889
|
-
"aiti-helper": { en: "AI Helper", zh: "AI \u52A9\u624B\u5165\u53E3" },
|
|
890
|
-
"aiti-inject": { en: "Debug Inject FAB", zh: "\u8C03\u8BD5\u6CE8\u5165\u6309\u94AE" },
|
|
891
|
-
"aiti-mcp-bridge": { en: "MCP Bridge", zh: "MCP \u6865" },
|
|
892
|
-
"aiti-model-check": { en: "Model Availability", zh: "\u6A21\u578B\u53EF\u7528\u6027\u7BA1\u7406" },
|
|
893
|
-
"aiti-model-wizard": { en: "Model Wizard", zh: "\u6A21\u578B\u6DFB\u52A0\u5411\u5BFC" },
|
|
894
|
-
"aiti-msg-anchor": { en: "Message Anchor Banner", zh: "\u6D88\u606F\u951A\u70B9\u6A2A\u5E45" },
|
|
895
|
-
"aiti-msg-nav": { en: "Message Scroll Nav", zh: "\u6D88\u606F\u6EDA\u52A8\u5BFC\u822A" },
|
|
896
|
-
"aiti-msg-smart": { en: "Message Intelligence", zh: "\u6D88\u606F\u667A\u80FD" },
|
|
897
|
-
"aiti-onlyoffice": { en: "OnlyOffice Editor", zh: "OnlyOffice \u7F16\u8F91" },
|
|
898
|
-
"aiti-pi-agent": { en: "pi Session Backend", zh: "pi \u4F1A\u8BDD\u540E\u7AEF" },
|
|
899
|
-
"aiti-plan-first": { en: "Plan-First Reminder", zh: "\u65B9\u6848\u5148\u884C" },
|
|
900
|
-
"aiti-plan-review": { en: "Plan Review", zh: "\u65B9\u6848\u8BC4\u5BA1" },
|
|
901
|
-
"aiti-prompts": { en: "Prompt Snippets", zh: "Prompt \u7247\u6BB5\u6536\u85CF\u5E93" },
|
|
902
|
-
"aiti-qoder-agent": { en: "Qoder Session Backend", zh: "Qoder \u4F1A\u8BDD\u540E\u7AEF" },
|
|
903
|
-
"aiti-queue-keeper": { en: "Queue Keeper", zh: "\u961F\u5217\u7BA1\u5BB6" },
|
|
904
|
-
"aiti-sheet-univer": { en: "Excel Editor", zh: "Excel \u7F16\u8F91\u5668" },
|
|
905
|
-
"aiti-subagents": { en: "Subagents", zh: "\u5B50\u4EE3\u7406" },
|
|
906
|
-
"aiti-testagent": { en: "TestAgent \xB7 Java Debugging", zh: "TestAgent \xB7 Java \u540E\u7AEF\u8C03\u8BD5" },
|
|
907
|
-
"aiti-ui-env": { en: "UI Environment", zh: "UI \u73AF\u5883\uFF08\u684C\u9762/\u65E0\u5934\u865A\u62DF\u5C4F\uFF09" },
|
|
908
|
-
"aiti-word-docx-preview": { en: "Word Preview", zh: "Word \u9884\u89C8" },
|
|
909
|
-
"aiti-word-superdoc": { en: "Word Editor", zh: "Word \u7F16\u8F91" },
|
|
910
|
-
"aiti-zcode-agent": { en: "ZCode Session Backend", zh: "ZCode \u4F1A\u8BDD\u540E\u7AEF" },
|
|
911
|
-
"demo": { en: "Demo Extension", zh: "\u793A\u4F8B\u6269\u5C55" },
|
|
912
|
-
"demo-lazy": { en: "Demo Extension (Lazy)", zh: "\u793A\u4F8B\u6269\u5C55\uFF08\u61D2\u52A0\u8F7D\uFF09" },
|
|
913
|
-
"devtools-vscode": { en: "VS Code Plugin", zh: "VS Code \u63D2\u4EF6" },
|
|
914
|
-
"devtools-idea": { en: "IDEA Plugin", zh: "IDEA \u63D2\u4EF6" },
|
|
915
|
-
"ext-jsx-client": { en: "JSX Client Template", zh: "\u6269\u5C55 JSX \u5BA2\u6237\u7AEF\u6A21\u677F" },
|
|
916
|
-
"service-tunnels": { en: "Service Tunnels", zh: "\u670D\u52A1\u96A7\u9053" },
|
|
917
|
-
"session-manager": { en: "Session Manager", zh: "\u4F1A\u8BDD\u7BA1\u7406\u5668" },
|
|
918
|
-
"sm-demo-source": { en: "Demo Session Source", zh: "\u7B2C\u4E09\u65B9\u4F1A\u8BDD\u6E90\u793A\u4F8B" }
|
|
919
|
-
};
|
|
920
|
-
var CJK_RE = /[\u3400-\u4dbf\u4e00-\u9fff]/;
|
|
921
859
|
function currentUiLocale() {
|
|
922
860
|
try {
|
|
923
861
|
const v = window.localStorage.getItem("pi-locale");
|
|
924
|
-
if (v === "zh-CN" || v === "en") return v;
|
|
862
|
+
if (v === "zh-CN" || v === "zh-TW" || v === "en") return v;
|
|
925
863
|
} catch {
|
|
926
864
|
}
|
|
927
865
|
return "en";
|
|
928
866
|
}
|
|
867
|
+
var registry = null;
|
|
868
|
+
var registryPrimed = false;
|
|
869
|
+
var registryApiUrl = null;
|
|
870
|
+
var listeners = /* @__PURE__ */ new Set();
|
|
871
|
+
function primeExtRegistry(apiUrlFn) {
|
|
872
|
+
if (apiUrlFn) registryApiUrl = apiUrlFn;
|
|
873
|
+
if (registryPrimed || typeof window === "undefined") return;
|
|
874
|
+
const urlFn = registryApiUrl;
|
|
875
|
+
if (!urlFn) return;
|
|
876
|
+
registryPrimed = true;
|
|
877
|
+
fetch(urlFn("/api/extensions/manifest")).then((r) => r.json()).then((d) => {
|
|
878
|
+
const map = {};
|
|
879
|
+
for (const e of d?.extensions ?? []) if (e?.id) map[e.id] = e;
|
|
880
|
+
registry = map;
|
|
881
|
+
for (const l of [...listeners]) {
|
|
882
|
+
try {
|
|
883
|
+
l();
|
|
884
|
+
} catch {
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
}).catch(() => {
|
|
888
|
+
registryPrimed = false;
|
|
889
|
+
});
|
|
890
|
+
}
|
|
891
|
+
function ui18nExact(ui18n, locale) {
|
|
892
|
+
if (!ui18n) return {};
|
|
893
|
+
return ui18n[locale] ?? {};
|
|
894
|
+
}
|
|
895
|
+
var CJK_RE = /[\u3400-\u4dbf\u4e00-\u9fff]/;
|
|
929
896
|
function extDisplayName(id, fallbackName) {
|
|
930
|
-
const
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
897
|
+
const locale = currentUiLocale();
|
|
898
|
+
primeExtRegistry();
|
|
899
|
+
const entry = registry?.[id];
|
|
900
|
+
const over = entry ? ui18nExact(entry.ui?.i18n, locale)["ext.displayName"] : void 0;
|
|
901
|
+
if (over) return over;
|
|
902
|
+
const name = fallbackName ?? entry?.name ?? "";
|
|
903
|
+
if (!name) return id;
|
|
904
|
+
return locale.startsWith("zh") ? name : CJK_RE.test(name) ? id : name;
|
|
934
905
|
}
|
|
935
906
|
|
|
936
907
|
// client/src/internal-client.mjs
|
|
937
908
|
function register(ctx) {
|
|
909
|
+
primeExtRegistry((p) => ctx.apiUrl ? ctx.apiUrl(p) : p);
|
|
938
910
|
if (typeof document === "undefined") return;
|
|
939
911
|
const INJECT_FLAG = "data-aiti-cpu-meter-inject";
|
|
940
912
|
let meter = null;
|
package/icon.svg
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="M12 6v6l4 2"/></svg>
|
package/index.ts
CHANGED
|
@@ -29,7 +29,6 @@ import { homedir } from "node:os";
|
|
|
29
29
|
export default {
|
|
30
30
|
id: "aiti-cpu-meter",
|
|
31
31
|
name: "主线程流畅度检测器(读秒 + 0-100 分 + 可注入任意站点)",
|
|
32
|
-
version: "0.3.1",
|
|
33
32
|
icon: "icon.svg",
|
|
34
33
|
client: "dist/aiti-cpu-meter-client.mjs",
|
|
35
34
|
|
|
@@ -110,6 +109,33 @@ export default {
|
|
|
110
109
|
},
|
|
111
110
|
],
|
|
112
111
|
|
|
112
|
+
|
|
113
|
+
ui: {
|
|
114
|
+
// English manifest-text overrides (name/description/feature labels); zh source lives in the manifest.
|
|
115
|
+
i18n: {
|
|
116
|
+
"zh-CN": {
|
|
117
|
+
"ext.displayName": "CPU 流畅度仪表",
|
|
118
|
+
},
|
|
119
|
+
en: {
|
|
120
|
+
"feat.enabled.desc": "Shows the CPU smoothness meter on this instance's page (rAF timer + 0-100 smoothness score + color tiers + minimize)",
|
|
121
|
+
"feat.pos.desc": "Default position: left-bottom (default) / left-top / right-bottom / right-top. Change anytime from the panel menu",
|
|
122
|
+
"feat.score.desc": "Shows the 0-100 smoothness score (Apdex-anchored + color tiers) + session stats (avg/runtime/min)",
|
|
123
|
+
"feat.minimize.desc": "Panel can minimize to a small icon (color dot + live score) dragged out of the way; click to restore",
|
|
124
|
+
"feat.askAi.desc": "Shows an AI icon in the panel title bar (✨ sparkles, same style as aiti-helper); click to send the recent jam window to AI for analysis",
|
|
125
|
+
"feat.inject.enabled.desc": "Injects the CPU meter of the \"Service URL\" target instance into the current page (cross-instance viewing requires the target to have this enabled too)",
|
|
126
|
+
"feat.service.url.desc": "Target pi-web base URL (with sub-path, e.g. https://host:port/dev)",
|
|
127
|
+
"ext.displayName": "CPU Meter",
|
|
128
|
+
"feat.enabled": "Enable the meter",
|
|
129
|
+
"feat.pos": "Position",
|
|
130
|
+
"feat.score": "Smoothness score",
|
|
131
|
+
"feat.minimize": "Allow minimizing",
|
|
132
|
+
"feat.askAi": "\"Ask AI\" panel button",
|
|
133
|
+
"feat.inject.enabled": "Cross-instance injection",
|
|
134
|
+
"feat.service.url": "Service URL",
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
|
|
113
139
|
server: {
|
|
114
140
|
async startup(ctx) {
|
|
115
141
|
let disposeInject;
|
package/package.json
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiti-ai/aiti-cpu-meter",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.2.11",
|
|
4
|
+
"description": "Main-thread smoothness detector — a seconds counter + 0–100 smoothness score + color tiers + minimize + AI jank debugging. Ships as two artifacts: a pi-web extension (internal) and a standalone single-file injector you can register into any website you develop.",
|
|
5
|
+
"displayNameI18n": {
|
|
6
|
+
"en": "CPU Meter"
|
|
7
|
+
},
|
|
8
|
+
"descriptionI18n": {
|
|
9
|
+
"zh-CN": "主线程流畅度检测——读秒 + 0-100 分 + 颜色分层 + 最小化 + AI 卡顿调试(aiti-helper 帮助点);可注入任意站点(内部版/外部版双产物)"
|
|
10
|
+
},
|
|
5
11
|
"soul": "主线程一卡,读秒就停;流畅度一分,忙闲立见——挂在工作页角落,收工点开看平均。",
|
|
12
|
+
"soulI18n": {
|
|
13
|
+
"en": "A stalled main thread stops the clock; one score tells busy from idle."
|
|
14
|
+
},
|
|
6
15
|
"scripts": {
|
|
7
16
|
"build": "node tools/build.mjs",
|
|
8
17
|
"deploy": "node tools/deploy.mjs",
|
|
@@ -10,7 +19,7 @@
|
|
|
10
19
|
},
|
|
11
20
|
"aitiExtProtocol": "1.0",
|
|
12
21
|
"license": "MIT",
|
|
13
|
-
"contentHash": "
|
|
22
|
+
"contentHash": "a7d38d119d3b00f7",
|
|
14
23
|
"repository": {
|
|
15
24
|
"type": "git",
|
|
16
25
|
"url": "git+https://github.com/aiti-ai/aiti-ai.git",
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: jank-debug
|
|
3
3
|
title: 调试页面卡顿(cpu-meter 现场分析)
|
|
4
|
+
title.en: "Debug page jank (cpu-meter live analysis)"
|
|
4
5
|
placeholder: 什么时候卡?做什么操作时卡?持续多久?有无报错…
|
|
6
|
+
placeholder.en: "When does it jank? During which actions? How long? Any errors…"
|
|
5
7
|
summary: 读取 aiti-cpu-meter 检测器现场(流畅度分/长任务/LoAF 脚本归因/卡顿快照),对照本仓历史卡顿案例定位主线程元凶,给出可执行修复建议
|
|
8
|
+
summary.en: "Read aiti-cpu-meter's live detector data (smoothness score/long tasks/LoAF script attribution/jank snapshots), match against known jank cases in this repo to find the main-thread culprit, and give actionable fixes"
|
|
6
9
|
outputs:
|
|
7
10
|
format: text
|
|
8
11
|
---
|
package/tools/deploy.mjs
CHANGED
|
@@ -50,6 +50,7 @@ for (const extDir of targets) {
|
|
|
50
50
|
copyFileSync(resolve(root, "icon.svg"), resolve(extDir, "icon.svg"));
|
|
51
51
|
// markdown 描述(extman 详情页渲染;缺文件则详情页无描述块)
|
|
52
52
|
try { copyFileSync(resolve(root, "DESC.md"), resolve(extDir, "DESC.md")); } catch {}
|
|
53
|
+
try { copyFileSync(resolve(root, "DESC.en.md"), resolve(extDir, "DESC.en.md")); } catch {}
|
|
53
54
|
console.log("[deploy] 源码 → " + resolve(extDir, "index.ts"));
|
|
54
55
|
|
|
55
56
|
// 内部版 client(产物统一 dist/,宿主按 index.ts 声明 /assets/dist/… 服务)
|