pi-think-anchor 1.0.17 → 1.0.19

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.
Files changed (2) hide show
  1. package/README.md +66 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -9,6 +9,26 @@
9
9
 
10
10
  思维链锚定监测:读取 thinking 的词频指纹,判定专注 / 过渡 / 发散,发散时分级提示。
11
11
 
12
+ ## 快速事实
13
+
14
+ | 项 | 说明 |
15
+ | --- | --- |
16
+ | 配置文件 | ~/.pi/think-anchor.json(可省略) |
17
+ | 命令行 | /think-anchor [on|off|reset|stats] |
18
+ | 调用方式 | **全自动**:turn_end 评估 + 条件注入;命令可手动开关/重置 |
19
+
20
+ 完整配置(全部键与默认值):
21
+
22
+ ```json
23
+ {
24
+ "enabled": true,
25
+ "score": { "minHits": 3, "spec": 1.2, "react": 0.5, "alpha": 1 },
26
+ "windowSize": 5,
27
+ "weights": { "beta": 0.4, "eps": 0.5 },
28
+ "intervention": { "l1CooldownMin": 10, "l2CooldownMin": 15, "maxL2": 2 }
29
+ }
30
+ ```
31
+
12
32
  ## 安装
13
33
 
14
34
  ```bash
@@ -51,6 +71,19 @@ pi install npm:pi-think-anchor
51
71
  - 无效不升级:上次 `eff >= 0` 时 L2 降为 L1。
52
72
  - `session_start`:重置状态机,仅保留最近 3 条与 pending(跨会话结算)。
53
73
 
74
+ ```mermaid
75
+ flowchart TD
76
+ A[turn_end<br/>读 assistant thinking] --> B[词频指纹 pos/neg/neu]
77
+ B --> C{本轮命中 >= minHits?}
78
+ C -->|否| Z[只推进窗口<br/>不评分不干预]
79
+ C -->|是| D[滑窗聚合 + alpha 平滑比率]
80
+ D --> E{波段}
81
+ E -->|spec| F[healthy 静默]
82
+ E -->|mixed| G[watch]
83
+ E -->|react| H[状态机<br/>L1 / L2 干预]
84
+ H -->|nextTurn 尾部消息| A
85
+ ```
86
+
54
87
  ## 借鉴
55
88
 
56
89
  蒸馏自 DSH 插件 [`dsh-anchored-monitor`](https://dsh-plugin.org/zh/plugins/aik358/dsh-anchored-monitor) 0.3.1:机制思想来源,非代码移植(本实现为回合级,无独立进程)。
@@ -67,6 +100,26 @@ MIT
67
100
 
68
101
  Chain-of-thought drift monitor: reads a word-frequency fingerprint from thinking, classifies focused / mixed / reactive, and nudges when drifting.
69
102
 
103
+ ## At a glance
104
+
105
+ | Item | Description |
106
+ | --- | --- |
107
+ | Config file | ~/.pi/think-anchor.json (optional) |
108
+ | Commands | /think-anchor [on|off|reset|stats] |
109
+ | Automation | **Fully automatic**: evaluated on turn_end, injects only when needed; commands toggle/reset |
110
+
111
+ Full config (all keys and defaults):
112
+
113
+ ```json
114
+ {
115
+ "enabled": true,
116
+ "score": { "minHits": 3, "spec": 1.2, "react": 0.5, "alpha": 1 },
117
+ "windowSize": 5,
118
+ "weights": { "beta": 0.4, "eps": 0.5 },
119
+ "intervention": { "l1CooldownMin": 10, "l2CooldownMin": 15, "maxL2": 2 }
120
+ }
121
+ ```
122
+
70
123
  ## Install
71
124
 
72
125
  ```bash
@@ -109,6 +162,19 @@ Also: log `~/.pi/think-anchor.jsonl` (1 MiB truncation, tail-preserving).
109
162
  - No escalation: when the previous `eff >= 0`, L2 degrades to L1.
110
163
  - `session_start`: resets state, keeping only the last 3 samples and pending (cross-session settlement).
111
164
 
165
+ ```mermaid
166
+ flowchart TD
167
+ A[turn_end<br/>read assistant thinking] --> B[word fingerprint pos/neg/neu]
168
+ B --> C{hits >= minHits?}
169
+ C -->|no| Z[advance window only<br/>no score, no nudge]
170
+ C -->|yes| D[sliding window + alpha-smoothed ratio]
171
+ D --> E{band}
172
+ E -->|spec| F[healthy: silent]
173
+ E -->|mixed| G[watch]
174
+ E -->|react| H[state machine<br/>L1 / L2 nudge]
175
+ H -->|nextTurn message| A
176
+ ```
177
+
112
178
  ## Credits
113
179
 
114
180
  Distilled from the DSH plugin [`dsh-anchored-monitor`](https://dsh-plugin.org/zh/plugins/aik358/dsh-anchored-monitor) 0.3.1: the mechanism is upstream, the code is not (turn-level, no separate process).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-think-anchor",
3
- "version": "1.0.17",
3
+ "version": "1.0.19",
4
4
  "description": "Monitors thinking focus drift and nudges the model back on track.",
5
5
  "type": "module",
6
6
  "license": "MIT",