lingshu-skill 5.30.0 → 5.32.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 +121 -0
- package/README.md +1577 -1577
- package/SKILL-lite.md +59 -59
- package/SKILL-tiny.md +38 -38
- package/SKILL.md +317 -405
- package/assets/panel.html +505 -19
- package/cordis-plugin/lingshu-cron/plugin.js +195 -29
- package/docs//344/275/277/347/224/250/346/214/207/345/215/227.md +229 -0
- package/docs//345/256/241/346/240/270/346/224/271/350/277/233/345/276/205/345/212/236.md +73 -31
- package/docs//345/276/205/345/212/236/346/250/241/346/235/277.md +140 -0
- package/package.json +52 -52
- package/scripts/astrbot_plugin_lingshu/CHECKSUMS.json +20 -17
- package/scripts/astrbot_plugin_lingshu/engine/CHANGELOG.md +121 -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 +317 -405
- package/scripts/astrbot_plugin_lingshu/engine/assets/panel.html +505 -19
- package/scripts/astrbot_plugin_lingshu/engine/scripts/cli.py +47 -18
- package/scripts/astrbot_plugin_lingshu/engine/scripts/core.py +32 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/dream.py +7 -1
- package/scripts/astrbot_plugin_lingshu/engine/scripts/emotion.py +14 -6
- package/scripts/astrbot_plugin_lingshu/engine/scripts/growth.py +27 -5
- package/scripts/astrbot_plugin_lingshu/engine/scripts/mem_dialogue.py +15 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/memory.py +489 -16
- package/scripts/astrbot_plugin_lingshu/engine/scripts/panel_icon.py +220 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/panel_launcher.py +114 -10
- package/scripts/astrbot_plugin_lingshu/engine/scripts/panel_server.py +165 -41
- package/scripts/astrbot_plugin_lingshu/engine/scripts/panel_shortcut.py +330 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/panel_splash.py +181 -0
- package/scripts/astrbot_plugin_lingshu/engine/scripts/persona.py +19 -5
- package/scripts/astrbot_plugin_lingshu/engine/scripts/safety_net.py +29 -3
- package/scripts/cli.py +47 -18
- package/scripts/core.py +32 -0
- package/scripts/dream.py +7 -1
- package/scripts/emotion.py +14 -6
- package/scripts/growth.py +27 -5
- package/scripts/mem_dialogue.py +15 -0
- package/scripts/memory.py +489 -16
- package/scripts/panel_icon.py +220 -0
- package/scripts/panel_launcher.py +114 -10
- package/scripts/panel_server.py +165 -41
- package/scripts/panel_shortcut.py +330 -0
- package/scripts/panel_splash.py +181 -0
- package/scripts/persona.py +19 -5
- package/scripts/safety_net.py +29 -3
package/scripts/cli.py
CHANGED
|
@@ -397,10 +397,21 @@ def cmd_backup(target: str | None = None, keep: int = 20, password: str | None =
|
|
|
397
397
|
keep_h = int(cfg.get("backup_keep_hourly") or 0)
|
|
398
398
|
keep_d = int(cfg.get("backup_keep_daily") or 0)
|
|
399
399
|
keep_w = int(cfg.get("backup_keep_weekly") or 0)
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
400
|
+
# ★ 各层各算"要保留哪些",最后取**并集**(审计 cli.py:402)。
|
|
401
|
+
# 原实现把 drop 当并集用:hourly 先 `drop.update(existing[keep_h:])`
|
|
402
|
+
# 把第 keep_h 个之后全标废弃,daily/weekly 只能继续往 drop 里加、
|
|
403
|
+
# 救不回来 → backup_keep_daily/weekly 完全失效,3 天前那份按天该留的
|
|
404
|
+
# 备份照样被移进 .pruned。分层保留必须"任一层想留就留"。
|
|
405
|
+
keep_set: set = set()
|
|
406
|
+
# 语义分层(改错过一次,务必看清):
|
|
407
|
+
# · **显式 keep>0 = 硬上限**:只保留最近 keep 个,GFS 三层不参与。
|
|
408
|
+
# · **keep<=0 = 交给 GFS**:三层各算保留集取并集,任一层想留就留。
|
|
409
|
+
_explicit_keep = bool(keep and keep > 0)
|
|
410
|
+
if _explicit_keep:
|
|
411
|
+
keep_set.update(existing[:keep])
|
|
412
|
+
elif keep_h > 0:
|
|
413
|
+
keep_set.update(existing[:keep_h]) # 最近 N 个
|
|
414
|
+
if not _explicit_keep and keep_d > 0:
|
|
404
415
|
seen_days, kept_d = set(), 0
|
|
405
416
|
for p in existing:
|
|
406
417
|
day = datetime.fromtimestamp(p.stat().st_mtime).strftime("%Y%m%d")
|
|
@@ -408,9 +419,9 @@ def cmd_backup(target: str | None = None, keep: int = 20, password: str | None =
|
|
|
408
419
|
continue
|
|
409
420
|
seen_days.add(day)
|
|
410
421
|
kept_d += 1
|
|
411
|
-
if kept_d
|
|
412
|
-
|
|
413
|
-
if keep_w > 0:
|
|
422
|
+
if kept_d <= keep_d:
|
|
423
|
+
keep_set.add(p) # 每天的第一个
|
|
424
|
+
if not _explicit_keep and keep_w > 0:
|
|
414
425
|
seen_weeks, kept_w = set(), 0
|
|
415
426
|
for p in existing:
|
|
416
427
|
wk = datetime.fromtimestamp(p.stat().st_mtime).strftime("%G%V")
|
|
@@ -418,11 +429,11 @@ def cmd_backup(target: str | None = None, keep: int = 20, password: str | None =
|
|
|
418
429
|
continue
|
|
419
430
|
seen_weeks.add(wk)
|
|
420
431
|
kept_w += 1
|
|
421
|
-
if kept_w
|
|
422
|
-
|
|
423
|
-
if keep and keep > 0:
|
|
424
|
-
drop.update(existing[keep:])
|
|
432
|
+
if kept_w <= keep_w:
|
|
433
|
+
keep_set.add(p) # 每周的第一个
|
|
425
434
|
# 最新那份永不删(否则备份完立刻把自己删了)
|
|
435
|
+
keep_set.add(existing[0])
|
|
436
|
+
drop = set(existing) - keep_set
|
|
426
437
|
drop.discard(existing[0])
|
|
427
438
|
# 修剪 = **移到 .pruned/**,不是删除(待办 L718 #2 + 用户"只移不删"规矩)。
|
|
428
439
|
# 理由:备份策略误配(keep 设太小)时,被"修剪"的好备份还能从这里捞回来;
|
|
@@ -4384,9 +4395,18 @@ def _main(argv=None) -> int:
|
|
|
4384
4395
|
try:
|
|
4385
4396
|
import persona as _persona
|
|
4386
4397
|
pr = _persona.persona_check()
|
|
4387
|
-
|
|
4388
|
-
|
|
4389
|
-
|
|
4398
|
+
# ⚠ 必须按 persona_check() 真实返回的键读(它返回 fails/warns/info):
|
|
4399
|
+
# 原来读 issues/problems,这两个键从不出现 → issues 恒空 → 无论
|
|
4400
|
+
# NaN traits、evidence 非数组、数值越界,永远输出"人格完整"。
|
|
4401
|
+
# 这条检查的意义就是让故障暴露,结果自己静默失效。
|
|
4402
|
+
issues = list(pr.get("fails") or [])
|
|
4403
|
+
warns = list(pr.get("warns") or [])
|
|
4404
|
+
st = "FAIL" if issues else ("WARN" if warns else "PASS")
|
|
4405
|
+
detail = ("; ".join(map(str, issues)) or "; ".join(map(str, warns))
|
|
4406
|
+
or "人格完整")
|
|
4407
|
+
if issues:
|
|
4408
|
+
detail += f"({len(issues)} 处必须修)"
|
|
4409
|
+
checks.append(("persona", st, detail))
|
|
4390
4410
|
except Exception as e:
|
|
4391
4411
|
checks.append(("persona", "FAIL", str(e)))
|
|
4392
4412
|
# 3. memory diagnose
|
|
@@ -4600,12 +4620,17 @@ def _main(argv=None) -> int:
|
|
|
4600
4620
|
|
|
4601
4621
|
# v5.12:把本次体检结果追加到 doctor-history.jsonl——灵枢自己的成长账本,
|
|
4602
4622
|
# 面板"体检历史"页签和未来的健康度分数用它。append-only,单条 try/except 吞掉。
|
|
4623
|
+
# ⚠ 字段名必须与 growth.record_doctor_run() 一致({kind,pass,warn,fail}):
|
|
4624
|
+
# 原来这里写成 {fails,warns,passes},同一个文件里两套字段名 → 面板按
|
|
4625
|
+
# passes/fails 求和时,由 record_doctor_run 写的那一半永远贡献 0,
|
|
4626
|
+
# 折线图恒平、成长阶段按双倍计数晋级。
|
|
4603
4627
|
try:
|
|
4604
4628
|
_dr = {
|
|
4605
4629
|
"ts": int(time.time()),
|
|
4606
|
-
"
|
|
4607
|
-
"
|
|
4608
|
-
"
|
|
4630
|
+
"kind": "doctor",
|
|
4631
|
+
"pass": sum(1 for _, s, _ in checks if s == "PASS"),
|
|
4632
|
+
"warn": sum(1 for _, s, _ in checks if s == "WARN"),
|
|
4633
|
+
"fail": sum(1 for _, s, _ in checks if s == "FAIL"),
|
|
4609
4634
|
"checks": {n: s for n, s, _ in checks},
|
|
4610
4635
|
}
|
|
4611
4636
|
_dh_path = (globals().get("brain") or sys.modules.get("brain")).HOME / "doctor-history.jsonl"
|
|
@@ -4746,7 +4771,11 @@ def _main(argv=None) -> int:
|
|
|
4746
4771
|
out_lines.append(f"## 知识库({len(kb)} 条)")
|
|
4747
4772
|
out_lines.append("")
|
|
4748
4773
|
for k in kb[:200]:
|
|
4749
|
-
|
|
4774
|
+
# 知识条目的正文字段是 body(见 growth 的 _new_knowledge);
|
|
4775
|
+
# 原来读 content/text,两个键都不存在 → 恒空串 →
|
|
4776
|
+
# export 的"知识库"节每条只剩一个 "- "(审计 cli.py:4763)。
|
|
4777
|
+
body = str(k.get("body") or k.get("content") or k.get("text")
|
|
4778
|
+
or "").replace("\n", " ")
|
|
4750
4779
|
if len(body) > 200:
|
|
4751
4780
|
body = body[:200] + "…"
|
|
4752
4781
|
out_lines.append(f"- {body}")
|
package/scripts/core.py
CHANGED
|
@@ -956,6 +956,27 @@ def config_unset(key: str) -> dict:
|
|
|
956
956
|
return cfg
|
|
957
957
|
|
|
958
958
|
|
|
959
|
+
def _num(v, default: float = 0.0) -> float:
|
|
960
|
+
"""安全取数:None / bool / 非数值 / NaN / inf 一律回 default。
|
|
961
|
+
|
|
962
|
+
⚠ 本轮(v5.32)才发现 core.py 里**有 6 处调用 _num() 却从未定义它**:
|
|
963
|
+
token_context_pressure()(4 处)每次都抛 NameError,又被 except 吞成
|
|
964
|
+
return None → 灵枢**从来没读到过 APP tokenMeter 的准确水位**,
|
|
965
|
+
只能退回字符估算,于是报 14% 而实际 66%。
|
|
966
|
+
DETAIL_CONSOLIDATE 的 lambda 同样会炸(做梦淡化规则静默失效)。
|
|
967
|
+
这是典型的「except Exception 吞掉真实错误」——异常没有消失,只是没声张。
|
|
968
|
+
"""
|
|
969
|
+
try:
|
|
970
|
+
if v is None or isinstance(v, bool):
|
|
971
|
+
return default
|
|
972
|
+
f = float(v)
|
|
973
|
+
if f != f or f in (float("inf"), float("-inf")):
|
|
974
|
+
return default
|
|
975
|
+
return f
|
|
976
|
+
except (TypeError, ValueError):
|
|
977
|
+
return default
|
|
978
|
+
|
|
979
|
+
|
|
959
980
|
def _cfg_num(cfg: dict, key: str, default, cast=float):
|
|
960
981
|
"""从配置里安全取一个数字:坏值/手改错时回退默认,绝不让注入崩掉。"""
|
|
961
982
|
try:
|
|
@@ -1333,6 +1354,17 @@ def read_pressure(cfg: dict | None = None) -> dict | None:
|
|
|
1333
1354
|
except Exception:
|
|
1334
1355
|
pass
|
|
1335
1356
|
tp = token_context_pressure()
|
|
1357
|
+
# ★ 估算值让位给 tokenMeter(v5.32,实测修):
|
|
1358
|
+
# lingshu-cron 拿不到完整对话历史,只能按「本轮几条消息的字符数」估,
|
|
1359
|
+
# 实测报 14% 而 APP tokenMeter 实测 65.7%(窗口是 1M 不是 131K)。
|
|
1360
|
+
# 它写进 _pressure.json 的 source 就是 'chars'/'floor',属于**估算**,
|
|
1361
|
+
# 不该冒充用户显式给的准值去压住宿主真值。
|
|
1362
|
+
# 规则:人工/真值(manual、usage、check-context)优先;
|
|
1363
|
+
# 估算类(chars、floor、chars+calib、cron)在有 tokenMeter 时让位。
|
|
1364
|
+
_EST_SOURCES = ('chars', 'floor', 'chars+calib', 'cron', 'unknown')
|
|
1365
|
+
if (legacy is not None and tp is not None
|
|
1366
|
+
and str(legacy.get('source') or '').lower() in _EST_SOURCES):
|
|
1367
|
+
legacy = None
|
|
1336
1368
|
if legacy is not None:
|
|
1337
1369
|
th = pressure_thresholds(cfg if cfg is not None else load_config())
|
|
1338
1370
|
pct = legacy["pct"]
|
package/scripts/dream.py
CHANGED
|
@@ -504,8 +504,14 @@ def _bounded_growth(records: list, now: int) -> list:
|
|
|
504
504
|
软上限可用 config `dream.capacity_cap` 覆盖。返回本次被归档的记录列表。
|
|
505
505
|
保护名单与 _is_archivable 一致:pinned / verbatim / identity / correction / pending。
|
|
506
506
|
"""
|
|
507
|
+
# ⚠ `config set dream.capacity_cap N` 经 _set_cfg_path 写的是**嵌套**
|
|
508
|
+
# cfg["dream"]["capacity_cap"];这里原来读平铺键 "dream.capacity_cap",
|
|
509
|
+
# 永远取不到 → 软上限恒为 3000,用户配置形同虚设(审计 dream.py:499)。
|
|
507
510
|
try:
|
|
508
|
-
|
|
511
|
+
_cfg = load_config()
|
|
512
|
+
_drm = _cfg.get("dream") if isinstance(_cfg.get("dream"), dict) else {}
|
|
513
|
+
_raw_cap = _drm.get("capacity_cap", _cfg.get("dream.capacity_cap"))
|
|
514
|
+
cap = int(_num(_raw_cap, 3000))
|
|
509
515
|
except Exception:
|
|
510
516
|
cap = 3000
|
|
511
517
|
cap = max(cap, 100) # 防呆:设得太小也不至于清空热层
|
package/scripts/emotion.py
CHANGED
|
@@ -410,8 +410,11 @@ def feel(name: str, intensity: float = 0.6, why: str = "",
|
|
|
410
410
|
"ts": ts_now, "emotion": name, "valence": v, "arousal": a,
|
|
411
411
|
"intensity": round(eff, 3),
|
|
412
412
|
"why": _why, "about": _about,
|
|
413
|
+
# ⚠ 用 `is not None` 判"给没给",不能用真值判断(审计 emotion.py:413):
|
|
414
|
+
# `if decay_hours` 把 0 当假 → `--decay-hours 0` 不落到钳制下限 0.5,
|
|
415
|
+
# 而是回落默认 6 小时,用户显式传 0 却被无视。
|
|
413
416
|
"decay_hours": (max(0.5, min(720.0, float(decay_hours)))
|
|
414
|
-
if decay_hours else EMOTION_HALF_LIFE / HOUR),
|
|
417
|
+
if decay_hours is not None else EMOTION_HALF_LIFE / HOUR),
|
|
415
418
|
"genesis": bool(genesis),
|
|
416
419
|
}
|
|
417
420
|
if resonance != "none":
|
|
@@ -529,7 +532,8 @@ def _save_gate(st: dict) -> None:
|
|
|
529
532
|
pass
|
|
530
533
|
|
|
531
534
|
|
|
532
|
-
def _apply_label_gate(v: float, a: float, active, base_label: str
|
|
535
|
+
def _apply_label_gate(v: float, a: float, active, base_label: str,
|
|
536
|
+
n_ev_total: int | None = None) -> str:
|
|
533
537
|
"""跃迁阈值 + 2 轮确认:标签不能单轮跳变。
|
|
534
538
|
|
|
535
539
|
规则:候选标签与当前对外标签不同时,若 |Δv| ≥ 阈值 → 记为待定并计数;
|
|
@@ -582,9 +586,12 @@ def _apply_label_gate(v: float, a: float, active, base_label: str) -> str:
|
|
|
582
586
|
_save_gate(st)
|
|
583
587
|
return cur
|
|
584
588
|
# 幅度够:看是否有**新的情绪事件**支撑同一候选(单条事件不许独自翻转标签)
|
|
589
|
+
# 用**截断前**的事件总数:active 在 _mood_snapshot 里已被截成 active[:6]
|
|
590
|
+
# 供注入展示用,拿它当"事件数"会在满 6 条后恒不再增长,
|
|
591
|
+
# `n_ev > prev_n` 永不成立 → 标签卡死不切换(审计 emotion.py:591)。
|
|
585
592
|
try:
|
|
586
|
-
n_ev = len(active or [])
|
|
587
|
-
except TypeError:
|
|
593
|
+
n_ev = int(n_ev_total) if n_ev_total is not None else len(active or [])
|
|
594
|
+
except (TypeError, ValueError):
|
|
588
595
|
n_ev = 0
|
|
589
596
|
prev_pending = str(st.get("pending") or "")
|
|
590
597
|
prev_n = int(st.get("pending_events") or 0)
|
|
@@ -624,7 +631,7 @@ def _finalize_mood(m: dict) -> dict:
|
|
|
624
631
|
return out
|
|
625
632
|
out["label"] = _apply_label_gate(
|
|
626
633
|
_num(out.get("valence"), 0.0), _num(out.get("arousal"), 0.0),
|
|
627
|
-
out.get("active"), _lbl)
|
|
634
|
+
out.get("active"), _lbl, out.get("active_total"))
|
|
628
635
|
return out
|
|
629
636
|
except Exception: # noqa: BLE001
|
|
630
637
|
return m
|
|
@@ -707,7 +714,8 @@ def mood_now(at: float | None = None) -> dict:
|
|
|
707
714
|
"raw_label": _base_label,
|
|
708
715
|
"category": groups[0]["group"] if groups else "静",
|
|
709
716
|
"intensity": round(min(1.0, sw), 3),
|
|
710
|
-
|
|
717
|
+
# active 截断只影响展示;active_total 供门控用(见 _apply_label_gate)
|
|
718
|
+
"active": active[:6], "active_total": len(active), "groups": groups,
|
|
711
719
|
"complex": complex_flag, "storm": a >= STORM_AROUSAL,
|
|
712
720
|
"note": "悲喜交加" if complex_flag else ""}
|
|
713
721
|
# 跃迁阈值 + 2 轮确认:**必须在 EMA 之后**——`_mood_ema` 自己会重算 label,
|
package/scripts/growth.py
CHANGED
|
@@ -2870,10 +2870,16 @@ def install_skill(name: str, force: bool = False, from_dir: str | None = None,
|
|
|
2870
2870
|
inst_meta = {}
|
|
2871
2871
|
|
|
2872
2872
|
def _vt(v) -> tuple | None:
|
|
2873
|
+
# 必须补零到三段再比(审计 growth.py:2872):
|
|
2874
|
+
# "5.11" → (5,11),"5.11.0" → (5,11,0),而 (5,11) < (5,11,0) 为真
|
|
2875
|
+
# → 一个合法的更新会被误判成"倒退"而拒绝。
|
|
2873
2876
|
try:
|
|
2874
|
-
|
|
2877
|
+
parts = [int(x) for x in str(v).strip().split(".")]
|
|
2875
2878
|
except (TypeError, ValueError):
|
|
2876
2879
|
return None
|
|
2880
|
+
while len(parts) < 3:
|
|
2881
|
+
parts.append(0)
|
|
2882
|
+
return tuple(parts[:3])
|
|
2877
2883
|
src_v, inst_v = _vt(meta.get("version")), _vt(inst_meta.get("version"))
|
|
2878
2884
|
if src_v is not None and inst_v is not None and src_v < inst_v:
|
|
2879
2885
|
raise KeyError(
|
|
@@ -3417,9 +3423,21 @@ def _file_lock_probe(path: Path) -> dict:
|
|
|
3417
3423
|
"($_.ExecutablePath -and $_.ExecutablePath.ToLower().Contains('" +
|
|
3418
3424
|
target.replace("'", "''") + "'))} | "
|
|
3419
3425
|
"Select-Object ProcessId,Name,CommandLine | ConvertTo-Json -Compress")
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3426
|
+
# ★ 用 Popen 而不是 subprocess.run(审计 growth.py:3430):
|
|
3427
|
+
# run() 返回的是 CompletedProcess,**没有 .pid 属性**(只有 args/returncode/
|
|
3428
|
+
# stdout/stderr)。原来下面写 `if pid in (my_pid, r.pid)` 每进这个分支必抛
|
|
3429
|
+
# AttributeError,又被外层 `except Exception: pass` 吞掉 → out["pids"] 恒为空,
|
|
3430
|
+
# 于是"占用者探测"只能回落到"查不到具体进程",这项诊断等于没做。
|
|
3431
|
+
proc = subprocess.Popen(["powershell", "-NoProfile", "-Command", ps],
|
|
3432
|
+
stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
|
|
3433
|
+
try:
|
|
3434
|
+
out_bytes, _ = proc.communicate(timeout=15)
|
|
3435
|
+
except subprocess.TimeoutExpired:
|
|
3436
|
+
proc.kill()
|
|
3437
|
+
out_bytes, _ = proc.communicate()
|
|
3438
|
+
raise
|
|
3439
|
+
ps_pid = proc.pid
|
|
3440
|
+
rows = json.loads((out_bytes or b"").decode("utf-8", "replace") or "[]")
|
|
3423
3441
|
if isinstance(rows, dict):
|
|
3424
3442
|
rows = [rows]
|
|
3425
3443
|
my_pid = os.getpid()
|
|
@@ -3427,7 +3445,7 @@ def _file_lock_probe(path: Path) -> dict:
|
|
|
3427
3445
|
try:
|
|
3428
3446
|
pid = int(row.get("ProcessId", 0))
|
|
3429
3447
|
# 排除自己(探测进程的命令行里也含目标路径)和跑查询的 powershell 子进程
|
|
3430
|
-
if pid in (my_pid,
|
|
3448
|
+
if pid in (my_pid, ps_pid):
|
|
3431
3449
|
continue
|
|
3432
3450
|
out["pids"].append({"pid": pid,
|
|
3433
3451
|
"name": str(row.get("Name", "")),
|
|
@@ -4476,6 +4494,10 @@ def log_evolution(kind: str, title: str, detail: str = "", refs=None) -> dict:
|
|
|
4476
4494
|
with brain._locked(EVOLUTION_FILE):
|
|
4477
4495
|
rows = brain.read_jsonl(EVOLUTION_FILE)
|
|
4478
4496
|
rows.append(row)
|
|
4497
|
+
# #26 有界增长:原来只追加不裁剪,load_evolution() 每次全量读 →
|
|
4498
|
+
# 长期使用后文件与读取成本无界。与 audit.jsonl(5000→4000)同口径。
|
|
4499
|
+
if len(rows) > 5000:
|
|
4500
|
+
rows = rows[-4000:]
|
|
4479
4501
|
brain.write_jsonl(EVOLUTION_FILE, rows)
|
|
4480
4502
|
return row
|
|
4481
4503
|
|
package/scripts/mem_dialogue.py
CHANGED
|
@@ -203,6 +203,21 @@ def ingest_dialogues(paths=None, limit: int | None = None, dry_run: bool = False
|
|
|
203
203
|
if blob and not blob.endswith(b"\n"):
|
|
204
204
|
cut = blob.rfind(b"\n")
|
|
205
205
|
if cut < 0:
|
|
206
|
+
# #29:整块没有换行 = 这个文件被压成了一行(或单行超长)。
|
|
207
|
+
# 原来的裸 continue 不写日志、不推进 offset → 每次读 8MB、
|
|
208
|
+
# 每次跳过,永远不摄取且无任何提示。这里记一次日志
|
|
209
|
+
# (同一文件只报一次,避免每轮刷屏),让用户知道该换格式。
|
|
210
|
+
try:
|
|
211
|
+
_warned = globals().setdefault("_LONGLINE_WARNED", set())
|
|
212
|
+
if str(f) not in _warned:
|
|
213
|
+
_warned.add(str(f))
|
|
214
|
+
core.log_event(
|
|
215
|
+
"dialogue",
|
|
216
|
+
f"跳过 {f.name}:单块 {len(blob)} 字节内没有换行,"
|
|
217
|
+
"疑似被压成一行的导出文件——请改用逐行 JSONL",
|
|
218
|
+
level="warn")
|
|
219
|
+
except Exception: # noqa: BLE001
|
|
220
|
+
pass
|
|
206
221
|
continue
|
|
207
222
|
blob = blob[:cut + 1]
|
|
208
223
|
text = _dialogue_decode(blob, f.name)
|