pi-think-anchor 1.0.4 → 1.0.6

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 CHANGED
@@ -19,12 +19,12 @@ Measures the "focus fingerprint" of thinking and nudges the model back when it d
19
19
  | Window | 5 turns | sliding |
20
20
  | L1 cooldown | 10 min | first drift |
21
21
  | L2 cooldown | 15 min | sustained drift, max 2 per session |
22
- | Word lists | Chinese | 28 focus / 19 drift terms |
22
+ | Word lists | Chinese | 28 focus / 18 drift terms |
23
23
 
24
24
  ## Install
25
25
 
26
26
  ```bash
27
- pi install npm:pi-think-anchor@1.0.0
27
+ pi install npm:pi-think-anchor
28
28
  pi install ./pi-think-anchor
29
29
  ```
30
30
 
package/README.md CHANGED
@@ -24,7 +24,7 @@
24
24
  | 聚合窗口 | 5 轮 | 滑动窗口 |
25
25
  | L1 冷却 | 10 分钟 | 首次跌入发散 |
26
26
  | L2 冷却 | 15 分钟 | 持续发散,会话上限 2 次 |
27
- | 词表 | 中文 | 专注 28 词 / 发散 19 词 |
27
+ | 词表 | 中文 | 专注 28 词 / 发散 18 词 |
28
28
 
29
29
  ## 安装
30
30
 
package/index.ts CHANGED
@@ -20,7 +20,7 @@ const HOME = os.homedir();
20
20
  const CONF = path.join(HOME, ".pi", "think-anchor.json");
21
21
  const LOG = path.join(HOME, ".pi", "think-anchor.jsonl");
22
22
 
23
- // ── 默认词表(中文优先——本机 thinking 经 caveman-think-zh 引向中文;英文兼容) ──
23
+ // ── 默认词表(中文优先——本地 thinking 经 caveman-think-zh 引向中文;英文兼容) ──
24
24
  const DEF_POS = ["我们需要", "我们将", "我要", "直接", "下一步", "关键是", "结论", "根本原因", "失败原因", "执行", "验证", "检查", "核对", "确认", "修复", "同步", "提交", "收尾", "落盘", "更新", "测试", "完成", "清理", "we need", "we'll", "we will", "i will", "next step"];
25
25
  const DEF_NEG = ["让我", "来看看", "也许", "或许", "可能", "或者", "要不", "先试试", "随便", "不太确定", "好像", "不知道", "let me", "let's", "maybe", "perhaps", "i guess", "not sure"];
26
26
  const DEF_NEU: string[] = [];
@@ -110,10 +110,10 @@ export function bandOf(ratio: number, bands: { spec: number; react: number } = D
110
110
  * α=1(伪计数)+ minHits=3 后 react 占 9.7%,且选中样本 negRate 中位 0.86(真发散)。
111
111
  * α 的作用:低命中时比率趋向 1(mixed),不再因「命中少」被误判成 react。
112
112
  */
113
- export function classify(pos: number, neg: number, neu: number, c: { minHits: number; spec: number; react: number; alpha: number }): TABand {
113
+ export function classify(pos: number, neg: number, neu: number, c: { minHits: number; spec: number; react: number; alpha: number; beta?: number; eps?: number }): TABand {
114
114
  const hits = pos + neg + neu;
115
115
  if (hits < c.minHits) return "none";
116
- const r = (pos + 0.4 * neu + c.alpha) / (neg + 0.5 + c.alpha);
116
+ const r = (pos + (c.beta ?? 0.4) * neu + c.alpha) / (neg + (c.eps ?? 0.5) + c.alpha);
117
117
  if (r < c.react) return "react";
118
118
  if (r < c.spec) return "mixed";
119
119
  return "spec";
@@ -294,9 +294,9 @@ export default function thinkAnchor(pi: ExtensionAPI): void {
294
294
  lastHits = hits;
295
295
  lastNegRate = negRate;
296
296
  const ratio = ratioOf(agg.pos, agg.neg, agg.neu, st.cfg.weights);
297
- const band = classify(agg.pos, agg.neg, agg.neu, st.cfg.score);
297
+ const band = classify(agg.pos, agg.neg, agg.neu, { ...st.cfg.score, ...st.cfg.weights });
298
298
  const prevPhase = st.phase;
299
- const r = (agg.pos + 0.4 * agg.neu + st.cfg.score.alpha) / (agg.neg + 0.5 + st.cfg.score.alpha);
299
+ const r = (agg.pos + st.cfg.weights.beta * agg.neu + st.cfg.score.alpha) / (agg.neg + st.cfg.weights.eps + st.cfg.score.alpha);
300
300
  const d0 = decideNext(st.phase, band, st.l2Tried, st.cfg.intervention.maxL2);
301
301
  // 升级前先看上次干预有没有用:无效则本次不升 L2(实测 L2 无收益)
302
302
  const d = { ...d0, level: downgradeIfIneffective(d0.level, lastEffValue) };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-think-anchor",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "Monitors thinking focus drift and nudges the model back on track.",
5
5
  "type": "module",
6
6
  "license": "MIT",