@duanz/pi-sol-pi-stats 1.0.0 → 1.0.1
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/README.en.md +58 -0
- package/README.md +58 -0
- package/package.json +8 -4
package/README.en.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# sol-pi-stats
|
|
2
|
+
|
|
3
|
+
<p align="center"><strong>English</strong> | <a href="./README.md">中文</a></p>
|
|
4
|
+
|
|
5
|
+
<p align="center"><img src="https://raw.githubusercontent.com/DuanZGit/D-Hub/master/docs/covers/sol-pi-stats.png" alt="sol-pi-stats cover" width="880"></p>
|
|
6
|
+
|
|
7
|
+
<p align="center"><strong>Context saved by observation-pack, always visible in the status bar</strong><br><sub>Event-driven · no timers · silent on failure</sub></p>
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
<a href="https://www.npmjs.com/package/@duanz/pi-sol-pi-stats"><img src="https://img.shields.io/npm/v/@duanz%2Fpi-sol-pi-stats.svg?style=flat-square" alt="npm"></a>
|
|
11
|
+
<a href="https://github.com/DuanZGit/D-Hub/blob/master/LICENSE"><img src="https://img.shields.io/npm/l/@duanz%2Fpi-sol-pi-stats.svg?style=flat-square" alt="license"></a>
|
|
12
|
+
<a href="https://github.com/DuanZGit/D-Hub"><img src="https://img.shields.io/badge/GitHub-DuanZGit%2FD--Hub-181717?style=flat-square&logo=github" alt="GitHub"></a>
|
|
13
|
+
<img src="https://img.shields.io/badge/pi-extension-34d399?style=flat-square" alt="pi extension">
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
<p align="center">
|
|
17
|
+
<code>pi install npm:@duanz/pi-sol-pi-stats</code>
|
|
18
|
+
</p>
|
|
19
|
+
|
|
20
|
+
## Why
|
|
21
|
+
|
|
22
|
+
sol-pi's observation-pack folds large tool outputs into placeholders and saves a lot of context. But it only flashes for 4 seconds when it saves something, then clears the status — the cumulative amount is invisible afterwards.
|
|
23
|
+
|
|
24
|
+
This extension aggregates the ledger into one always-on status line:
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
⚡SoL saved 36M tok · 22 packs
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
`/sol` shows details: pack count, cumulative savings, cost range, top packs.
|
|
31
|
+
|
|
32
|
+
## Data source
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
<sessionDir>/sol-pi/<sessionId>/observation-pack/ledger.jsonl
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
In rows with `event=placeholder`, `removedTokens` is what that request avoided sending (one row per pack per request).
|
|
39
|
+
|
|
40
|
+
## Implementation notes
|
|
41
|
+
|
|
42
|
+
- **Event-driven, no timers** — refreshes on session events, never idles
|
|
43
|
+
- **Reads cache only in sync phases** — no `await`, so a reloaded session cannot leave a stale `ctx`
|
|
44
|
+
- **(size, mtime) cache** — an unchanged ledger is not re-parsed
|
|
45
|
+
- **Silent on failure** — stats never break a session
|
|
46
|
+
|
|
47
|
+
## Usage
|
|
48
|
+
|
|
49
|
+
Enabled on install. Status line is permanent; `/sol` for details.
|
|
50
|
+
|
|
51
|
+
## Limits
|
|
52
|
+
|
|
53
|
+
- Requires sol-pi / observation-pack to actually write `ledger.jsonl`; otherwise no numbers appear.
|
|
54
|
+
- Cost figures are estimates from input and cache prices, not a bill.
|
|
55
|
+
|
|
56
|
+
## License
|
|
57
|
+
|
|
58
|
+
MIT © DuanZ
|
package/README.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# sol-pi-stats
|
|
2
|
+
|
|
3
|
+
<p align="center"><a href="./README.en.md">English</a> | <strong>中文</strong></p>
|
|
4
|
+
|
|
5
|
+
<p align="center"><img src="https://raw.githubusercontent.com/DuanZGit/D-Hub/master/docs/covers/sol-pi-stats.png" alt="sol-pi-stats cover" width="880"></p>
|
|
6
|
+
|
|
7
|
+
<p align="center"><strong>observation-pack 省下的上下文,常驻显示在状态栏</strong><br><sub>事件驱动 · 不设定时器 · 异常静默</sub></p>
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
<a href="https://www.npmjs.com/package/@duanz/pi-sol-pi-stats"><img src="https://img.shields.io/npm/v/@duanz%2Fpi-sol-pi-stats.svg?style=flat-square" alt="npm"></a>
|
|
11
|
+
<a href="https://github.com/DuanZGit/D-Hub/blob/master/LICENSE"><img src="https://img.shields.io/npm/l/@duanz%2Fpi-sol-pi-stats.svg?style=flat-square" alt="license"></a>
|
|
12
|
+
<a href="https://github.com/DuanZGit/D-Hub"><img src="https://img.shields.io/badge/GitHub-DuanZGit%2FD--Hub-181717?style=flat-square&logo=github" alt="GitHub"></a>
|
|
13
|
+
<img src="https://img.shields.io/badge/pi-extension-34d399?style=flat-square" alt="pi extension">
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
<p align="center">
|
|
17
|
+
<code>pi install npm:@duanz/pi-sol-pi-stats</code>
|
|
18
|
+
</p>
|
|
19
|
+
|
|
20
|
+
## 它解决什么
|
|
21
|
+
|
|
22
|
+
sol-pi 的 observation-pack 会把大块工具输出折成占位符,省下大量上下文。但它自己只在「省到东西」时闪 4 秒,之后把状态清掉——省下的量到底累计了多少,事后完全看不到。
|
|
23
|
+
|
|
24
|
+
这个扩展把 ledger 汇总成一条常驻状态:
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
⚡SoL 省 36M tok · 22 包
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
想看明细就用 `/sol`:包数、累计避免量、金额区间、Top 包。
|
|
31
|
+
|
|
32
|
+
## 数据源
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
<sessionDir>/sol-pi/<sessionId>/observation-pack/ledger.jsonl
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
`event=placeholder` 的行里 `removedTokens` 是该次请求少发的 token(同一个包每次请求各记一条)。
|
|
39
|
+
|
|
40
|
+
## 实现要点
|
|
41
|
+
|
|
42
|
+
- **事件驱动,不设定时器**:跟着会话事件刷新,避免空转
|
|
43
|
+
- **只在同步阶段读缓存**:不 `await`,防止会话重载后 `ctx` 失效
|
|
44
|
+
- **(size, mtime)缓存**:ledger 没变就不重新解析
|
|
45
|
+
- **异常静默**:统计失败不影响会话
|
|
46
|
+
|
|
47
|
+
## 用法
|
|
48
|
+
|
|
49
|
+
装完即生效。状态栏常驻;`/sol` 看明细。
|
|
50
|
+
|
|
51
|
+
## 限制
|
|
52
|
+
|
|
53
|
+
- 需要 sol-pi / observation-pack 真的在产生 `ledger.jsonl`,否则状态栏不会出现数字。
|
|
54
|
+
- 金额是区间估算(按输入价与缓存价推算),不是账单。
|
|
55
|
+
|
|
56
|
+
## License
|
|
57
|
+
|
|
58
|
+
MIT © DuanZ
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@duanz/pi-sol-pi-stats",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "状态栏常驻 token / 上下文用量,另有 /sol 明细",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"pi-package",
|
|
8
|
-
"pi-extension"
|
|
8
|
+
"pi-extension",
|
|
9
|
+
"pi-web"
|
|
9
10
|
],
|
|
10
11
|
"license": "MIT",
|
|
11
12
|
"author": "DuanZ",
|
|
@@ -16,12 +17,15 @@
|
|
|
16
17
|
"directory": "extensions/sol-pi-stats"
|
|
17
18
|
},
|
|
18
19
|
"files": [
|
|
19
|
-
"index.ts"
|
|
20
|
+
"index.ts",
|
|
21
|
+
"README.md",
|
|
22
|
+
"README.en.md"
|
|
20
23
|
],
|
|
21
24
|
"pi": {
|
|
22
25
|
"extensions": [
|
|
23
26
|
"./index.ts"
|
|
24
|
-
]
|
|
27
|
+
],
|
|
28
|
+
"image": "https://raw.githubusercontent.com/DuanZGit/D-Hub/master/docs/covers/sol-pi-stats.png"
|
|
25
29
|
},
|
|
26
30
|
"engines": {
|
|
27
31
|
"node": ">=20"
|