pi-ptc-meter 1.0.16 → 1.0.18
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.md +71 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,6 +9,24 @@
|
|
|
9
9
|
|
|
10
10
|
每轮工具调用计量:统计调用次数与耗时,并把数字回灌给模型。
|
|
11
11
|
|
|
12
|
+
## 快速事实
|
|
13
|
+
|
|
14
|
+
| 项 | 说明 |
|
|
15
|
+
| --- | --- |
|
|
16
|
+
| 配置文件 | ~/.pi/ptc-meter.json(可省略) |
|
|
17
|
+
| 命令行 | /ptc [n](默认 20) |
|
|
18
|
+
| 调用方式 | **全自动**:计数与回灌无需触发;命令只查看 |
|
|
19
|
+
|
|
20
|
+
完整配置(全部键与默认值):
|
|
21
|
+
|
|
22
|
+
```json
|
|
23
|
+
{
|
|
24
|
+
"threshold": 39,
|
|
25
|
+
"inject": true,
|
|
26
|
+
"notify": false
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
12
30
|
## 安装
|
|
13
31
|
|
|
14
32
|
```bash
|
|
@@ -42,6 +60,8 @@ pi install npm:pi-ptc-meter
|
|
|
42
60
|
- `session_start`:模块级计量归零。
|
|
43
61
|
- system 内 section `ptc_meter` 只含逐字不变的骨架。
|
|
44
62
|
|
|
63
|
+
## 原理(专业)
|
|
64
|
+
|
|
45
65
|
```mermaid
|
|
46
66
|
flowchart TD
|
|
47
67
|
A[tool_call] -->|计数 +1| B[turn_end<br/>记录次数与耗时]
|
|
@@ -51,6 +71,19 @@ flowchart TD
|
|
|
51
71
|
D -.->|system 只留静态骨架| S[ptc_meter section]
|
|
52
72
|
```
|
|
53
73
|
|
|
74
|
+
## 原理(小白)
|
|
75
|
+
|
|
76
|
+
像计步器:这一趟跑了多少步(调用了几次工具),下一趟出发前告诉你「上次 40 步,比平时多」,你自己决定要不要合并行程。
|
|
77
|
+
|
|
78
|
+
```mermaid
|
|
79
|
+
flowchart LR
|
|
80
|
+
A[这一轮干活] --> B[计步:用了几次工具]
|
|
81
|
+
B --> C[记下来]
|
|
82
|
+
C --> D[下一轮开始时报数]
|
|
83
|
+
D --> A
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
|
|
54
87
|
## License
|
|
55
88
|
|
|
56
89
|
MIT
|
|
@@ -63,6 +96,24 @@ MIT
|
|
|
63
96
|
|
|
64
97
|
Per-turn tool-call metering: counts calls and duration, then feeds the numbers back to the model.
|
|
65
98
|
|
|
99
|
+
## At a glance
|
|
100
|
+
|
|
101
|
+
| Item | Description |
|
|
102
|
+
| --- | --- |
|
|
103
|
+
| Config file | ~/.pi/ptc-meter.json (optional) |
|
|
104
|
+
| Commands | /ptc [n] (default 20) |
|
|
105
|
+
| Automation | **Fully automatic**: metering and feedback need no trigger; the command only reads |
|
|
106
|
+
|
|
107
|
+
Full config (all keys and defaults):
|
|
108
|
+
|
|
109
|
+
```json
|
|
110
|
+
{
|
|
111
|
+
"threshold": 39,
|
|
112
|
+
"inject": true,
|
|
113
|
+
"notify": false
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
66
117
|
## Install
|
|
67
118
|
|
|
68
119
|
```bash
|
|
@@ -96,7 +147,27 @@ Also: log `~/.pi/ptc-meter.jsonl` (1 MiB truncation, tail-preserving); no enviro
|
|
|
96
147
|
- `session_start`: resets module-level counters.
|
|
97
148
|
- The `ptc_meter` system section holds only a byte-stable skeleton.
|
|
98
149
|
|
|
150
|
+
## How it works (technical)
|
|
151
|
+
|
|
99
152
|
```mermaid
|
|
153
|
+
flowchart TD
|
|
154
|
+
A[tool_call] -->|counter +1| B[turn_end<br/>record calls and duration]
|
|
155
|
+
B --> C[agent_end<br/>write one log line]
|
|
156
|
+
C --> D[before_agent_start<br/>settle previous turn]
|
|
157
|
+
D -->|nextTurn message<br/>calls / duration / deviation / median| A
|
|
158
|
+
D -.->|system keeps a static skeleton| S[ptc_meter section]
|
|
159
|
+
|
|
160
|
+
## How it works (plain words)
|
|
161
|
+
|
|
162
|
+
Like a pedometer: counts how many steps (tool calls) this trip took, then tells you before the next trip that last one was 40 steps, above your usual — you decide whether to combine errands.
|
|
163
|
+
|
|
164
|
+
```mermaid
|
|
165
|
+
flowchart LR
|
|
166
|
+
A[this turn's work] --> B[count: how many tool calls]
|
|
167
|
+
B --> C[record it]
|
|
168
|
+
C --> D[report at the start of the next turn]
|
|
169
|
+
D --> A
|
|
170
|
+
```
|
|
100
171
|
flowchart TD
|
|
101
172
|
A[tool_call] -->|counter +1| B[turn_end<br/>record calls and duration]
|
|
102
173
|
B --> C[agent_end<br/>write one log line]
|