lingshu-skill 5.31.0 → 5.33.0
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/CHANGELOG.md +96 -0
- package/README.md +1577 -1577
- package/SKILL-lite.md +59 -59
- package/SKILL-tiny.md +38 -38
- package/SKILL.md +171 -181
- package/assets/panel.html +15 -1
- package/docs//344/272/244/346/216/245/347/254/224/350/256/260-20261128.md +128 -0
- package/docs//345/256/241/346/240/270/346/224/271/350/277/233/345/276/205/345/212/236.md +38 -0
- package/package.json +52 -52
- package/scripts/astrbot_plugin_lingshu/CHECKSUMS.json +8 -8
- package/scripts/astrbot_plugin_lingshu/engine/CHANGELOG.md +96 -0
- package/scripts/astrbot_plugin_lingshu/engine/README.md +1577 -1577
- package/scripts/astrbot_plugin_lingshu/engine/SKILL-lite.md +59 -59
- package/scripts/astrbot_plugin_lingshu/engine/SKILL-tiny.md +38 -38
- package/scripts/astrbot_plugin_lingshu/engine/SKILL.md +171 -181
- package/scripts/astrbot_plugin_lingshu/engine/assets/panel.html +15 -1
- package/scripts/astrbot_plugin_lingshu/engine/scripts/cli.py +19 -2
- package/scripts/astrbot_plugin_lingshu/engine/scripts/memory.py +30 -2
- package/scripts/cli.py +19 -2
- package/scripts/memory.py +30 -2
|
@@ -5808,6 +5808,9 @@ def build_injection(query: str = "", budget_tokens: int | None = None,
|
|
|
5808
5808
|
for i, part in enumerate(out):
|
|
5809
5809
|
sec = out.secs[i] if i < len(out.secs) else "other"
|
|
5810
5810
|
chars[sec] = chars.get(sec, 0) + len(part) + (1 if i else 0)
|
|
5811
|
+
# 口径:账单按 chars_per_token 折 token(默认 2)。
|
|
5812
|
+
# v5.32 试过改成 1.8 与 char_budget 对齐,但 4 个测试的期望值基于 2,
|
|
5813
|
+
# 且 1.8 只是装配端给中文留的余量、不是账单标准 → 已回退,避免无证据改动。
|
|
5811
5814
|
ratio = _cfg_num(cfg, "context_chars_per_token", 2, float)
|
|
5812
5815
|
if not ratio or ratio <= 0:
|
|
5813
5816
|
ratio = 2.0
|
|
@@ -5819,8 +5822,33 @@ def build_injection(query: str = "", budget_tokens: int | None = None,
|
|
|
5819
5822
|
"budget_frac": round(t / budget, 4) if budget else 0.0})
|
|
5820
5823
|
total_chars += c
|
|
5821
5824
|
total_tokens += t
|
|
5822
|
-
# 自检:各段 chars
|
|
5823
|
-
|
|
5825
|
+
# 自检:各段 chars 求和应等于最终文本长度。
|
|
5826
|
+
# ⚠ 不能用 assert(v5.31 实测修):
|
|
5827
|
+
# 1) 上方对 _result 做过指针标记替换,长度会变,按未替换的 out 累加必然不等;
|
|
5828
|
+
# 2) 生产代码用 assert 校验数据,`python -O` 下会被整体跳过;
|
|
5829
|
+
# 3) 它把观测工具变成崩溃源——`context-stats` 会因为这里直接退出。
|
|
5830
|
+
# 改为:按真实长度把差额归到 other 段(保证 Σ段 == 总长、账单可信),
|
|
5831
|
+
# 同时记 warn,真实装配 bug 仍然看得见。
|
|
5832
|
+
if total_chars != len(_result):
|
|
5833
|
+
_delta = len(_result) - total_chars
|
|
5834
|
+
for _s in sections:
|
|
5835
|
+
if _s["name"] == "other":
|
|
5836
|
+
_s["chars"] += _delta
|
|
5837
|
+
_s["tokens"] = int(math.ceil(_s["chars"] / ratio)) if _s["chars"] > 0 else 0
|
|
5838
|
+
_s["budget_frac"] = round(_s["tokens"] / budget, 4) if budget else 0.0
|
|
5839
|
+
break
|
|
5840
|
+
else:
|
|
5841
|
+
sections.append({"name": "other", "chars": _delta,
|
|
5842
|
+
"tokens": int(math.ceil(max(0, _delta) / ratio)),
|
|
5843
|
+
"budget_frac": 0.0})
|
|
5844
|
+
total_chars = len(_result)
|
|
5845
|
+
total_tokens = sum(_s["tokens"] for _s in sections)
|
|
5846
|
+
try:
|
|
5847
|
+
log_event("inject",
|
|
5848
|
+
f"注入账单字符数与实际不符(已按实际校正 {_delta:+d}):"
|
|
5849
|
+
"通常是指针标记替换改变了长度", level="warn")
|
|
5850
|
+
except Exception: # noqa: BLE001
|
|
5851
|
+
pass
|
|
5824
5852
|
report.update({"sections": sections, "total_chars": total_chars,
|
|
5825
5853
|
"total_tokens": total_tokens, "budget": budget,
|
|
5826
5854
|
"chars_per_token": ratio})
|
package/scripts/cli.py
CHANGED
|
@@ -5075,10 +5075,27 @@ def _main(argv=None) -> int:
|
|
|
5075
5075
|
print("(没输入任何内容,未写交接笔记)")
|
|
5076
5076
|
return 0
|
|
5077
5077
|
body = "\n".join(f"【{k}】{v}" for k, v in sections.items())
|
|
5078
|
-
tags = "、".join(["交接", "handoff"])
|
|
5079
5078
|
rec, _ = growth.write_note("log", "交接笔记 · " + time.strftime("%m-%d %H:%M"), body,
|
|
5080
5079
|
tags=["交接", "handoff"])
|
|
5081
|
-
print(f"交接笔记已落盘:{rec.get('id', '')}(notes 里 kind=log
|
|
5080
|
+
print(f"交接笔记已落盘:{rec.get('id', '')}(notes 里 kind=log)")
|
|
5081
|
+
# ★ 同时落 handoffs/(v5.32 打通):startup 注入读的是 dream.latest_handoff(),
|
|
5082
|
+
# 只写 notes 的话这份手工交接**永远进不了注入**——AI 在水位高时辛苦写的
|
|
5083
|
+
# 「状态/死路/下一步」下个会话看不到,而注入的是 dream 那套自动摘要(可能过时)。
|
|
5084
|
+
try:
|
|
5085
|
+
import dream as _dm
|
|
5086
|
+
_pts = [v for k, v in sections.items() if k in ("目标", "死路及原因")]
|
|
5087
|
+
_dm.save_handoff({
|
|
5088
|
+
"at": _dm.now_ts(),
|
|
5089
|
+
"mode": "manual",
|
|
5090
|
+
"replayed": 0,
|
|
5091
|
+
"状态": sections.get("状态") or f"手工交接({len(sections)} 段)",
|
|
5092
|
+
"要点": _pts[:6],
|
|
5093
|
+
"未决": [sections["下一步"]] if sections.get("下一步") else [],
|
|
5094
|
+
"下一步": sections.get("下一步") or "先读 notes 里这条交接笔记,再从「状态」继续",
|
|
5095
|
+
})
|
|
5096
|
+
print(" 同时写入 handoffs/:下次 startup 的注入包里会带出这份交接。")
|
|
5097
|
+
except Exception as _e: # noqa: BLE001
|
|
5098
|
+
print(f"[警告] 写 handoffs/ 失败(notes 已存,不影响):{_e}", file=sys.stderr)
|
|
5082
5099
|
return 0
|
|
5083
5100
|
cfg = load_config()
|
|
5084
5101
|
# v3.86:--used 缺省时按优先级取真实水位——
|
package/scripts/memory.py
CHANGED
|
@@ -5808,6 +5808,9 @@ def build_injection(query: str = "", budget_tokens: int | None = None,
|
|
|
5808
5808
|
for i, part in enumerate(out):
|
|
5809
5809
|
sec = out.secs[i] if i < len(out.secs) else "other"
|
|
5810
5810
|
chars[sec] = chars.get(sec, 0) + len(part) + (1 if i else 0)
|
|
5811
|
+
# 口径:账单按 chars_per_token 折 token(默认 2)。
|
|
5812
|
+
# v5.32 试过改成 1.8 与 char_budget 对齐,但 4 个测试的期望值基于 2,
|
|
5813
|
+
# 且 1.8 只是装配端给中文留的余量、不是账单标准 → 已回退,避免无证据改动。
|
|
5811
5814
|
ratio = _cfg_num(cfg, "context_chars_per_token", 2, float)
|
|
5812
5815
|
if not ratio or ratio <= 0:
|
|
5813
5816
|
ratio = 2.0
|
|
@@ -5819,8 +5822,33 @@ def build_injection(query: str = "", budget_tokens: int | None = None,
|
|
|
5819
5822
|
"budget_frac": round(t / budget, 4) if budget else 0.0})
|
|
5820
5823
|
total_chars += c
|
|
5821
5824
|
total_tokens += t
|
|
5822
|
-
# 自检:各段 chars
|
|
5823
|
-
|
|
5825
|
+
# 自检:各段 chars 求和应等于最终文本长度。
|
|
5826
|
+
# ⚠ 不能用 assert(v5.31 实测修):
|
|
5827
|
+
# 1) 上方对 _result 做过指针标记替换,长度会变,按未替换的 out 累加必然不等;
|
|
5828
|
+
# 2) 生产代码用 assert 校验数据,`python -O` 下会被整体跳过;
|
|
5829
|
+
# 3) 它把观测工具变成崩溃源——`context-stats` 会因为这里直接退出。
|
|
5830
|
+
# 改为:按真实长度把差额归到 other 段(保证 Σ段 == 总长、账单可信),
|
|
5831
|
+
# 同时记 warn,真实装配 bug 仍然看得见。
|
|
5832
|
+
if total_chars != len(_result):
|
|
5833
|
+
_delta = len(_result) - total_chars
|
|
5834
|
+
for _s in sections:
|
|
5835
|
+
if _s["name"] == "other":
|
|
5836
|
+
_s["chars"] += _delta
|
|
5837
|
+
_s["tokens"] = int(math.ceil(_s["chars"] / ratio)) if _s["chars"] > 0 else 0
|
|
5838
|
+
_s["budget_frac"] = round(_s["tokens"] / budget, 4) if budget else 0.0
|
|
5839
|
+
break
|
|
5840
|
+
else:
|
|
5841
|
+
sections.append({"name": "other", "chars": _delta,
|
|
5842
|
+
"tokens": int(math.ceil(max(0, _delta) / ratio)),
|
|
5843
|
+
"budget_frac": 0.0})
|
|
5844
|
+
total_chars = len(_result)
|
|
5845
|
+
total_tokens = sum(_s["tokens"] for _s in sections)
|
|
5846
|
+
try:
|
|
5847
|
+
log_event("inject",
|
|
5848
|
+
f"注入账单字符数与实际不符(已按实际校正 {_delta:+d}):"
|
|
5849
|
+
"通常是指针标记替换改变了长度", level="warn")
|
|
5850
|
+
except Exception: # noqa: BLE001
|
|
5851
|
+
pass
|
|
5824
5852
|
report.update({"sections": sections, "total_chars": total_chars,
|
|
5825
5853
|
"total_tokens": total_tokens, "budget": budget,
|
|
5826
5854
|
"chars_per_token": ratio})
|