lingshu-skill 5.17.0 → 5.18.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/scripts/growth.py CHANGED
@@ -3524,6 +3524,26 @@ def _tag_coverage() -> float:
3524
3524
  return good / len(rows)
3525
3525
 
3526
3526
 
3527
+ def health_score(passed: int = 0, warned: int = 0, failed: int = 0,
3528
+ failures_7d: int | None = None) -> dict:
3529
+ """健康度分数(0~100)+ 扣分明细。参数没给就取最近一次体检历史。"""
3530
+ if failures_7d is None:
3531
+ failures_7d = _recent_failures(7)
3532
+ if not (passed or warned or failed):
3533
+ hist = [r for r in doctor_history() if str(r.get("kind") or "doctor") == "doctor"]
3534
+ if hist:
3535
+ last = hist[-1]
3536
+ passed = int(last.get("pass") or 0)
3537
+ warned = int(last.get("warn") or 0)
3538
+ failed = int(last.get("fail") or 0)
3539
+ score = 100 - int(failed) * 10 - int(warned) * 3 - int(failures_7d) // 5
3540
+ score = max(0, min(100, score))
3541
+ return {"score": score, "pass": int(passed), "warn": int(warned),
3542
+ "fail": int(failed), "failures_7d": int(failures_7d),
3543
+ "deduct": {"fail": int(failed) * 10, "warn": int(warned) * 3,
3544
+ "failures": int(failures_7d) // 5}}
3545
+
3546
+
3527
3547
  def stage_state() -> dict:
3528
3548
  """算出当前成长阶段 + 依据(面板/CLI 都读它)。"""
3529
3549
  hist = doctor_history()
@@ -3587,9 +3607,14 @@ def stage_state() -> dict:
3587
3607
  # 跑了不少次却还在"蛋":明说是被 failures 卡住,不是没在记录
3588
3608
  if stage == "蛋" and doc_runs >= 5:
3589
3609
  label += "·卡在 failures"
3610
+ try:
3611
+ _health = health_score(failures_7d=fails)
3612
+ except Exception: # noqa: BLE001
3613
+ _health = None
3590
3614
  return {"stage": stage, "doctor_runs": doc_runs, "self_reviews": self_reviews,
3591
3615
  "failures_7d": fails, "coverage": round(cov, 3),
3592
- "drift_fixed": drift_fixed, "next": need, "label": label}
3616
+ "drift_fixed": drift_fixed, "next": need, "label": label,
3617
+ "health": _health}
3593
3618
 
3594
3619
 
3595
3620
  def release_drift() -> dict:
@@ -962,6 +962,18 @@ class Handler(BaseHTTPRequestHandler):
962
962
  limit = _int_param(url, "limit", 60, 1, 300)
963
963
  self._json(brain.growth_timeline(days, limit))
964
964
  return
965
+ if path == "/api/doctor-history":
966
+ # P2-4:体检历史(成长阶段/健康度都基于它)。limit 默认 90 条。
967
+ try:
968
+ lim = _int_param(url, "limit", 90, 1, 1000)
969
+ hist = growth.doctor_history(limit=lim)
970
+ st = growth.stage_state()
971
+ except Exception as exc: # noqa: BLE001
972
+ self._json({"error": f"读取体检历史失败:{exc}"}, 500)
973
+ return
974
+ self._json({"items": hist, "count": len(hist),
975
+ "stage": st, "health": st.get("health")})
976
+ return
965
977
  if path == "/api/logs":
966
978
  limit = _int_param(url, "limit", 200, 1, 2000)
967
979
  level = (parse_qs(url.query).get("level") or [""])[0] or None
@@ -76,6 +76,15 @@ CONFIG_SCHEMA: list[dict[str, Any]] = [
76
76
  "hint": "送进 rerank 的候选条数,越大越准也越慢"},
77
77
 
78
78
  # —— 面板与宿主 ——
79
+ {"key": "emotion_inertia_enabled", "group": "情绪与人格", "label": "情绪惯性",
80
+ "kind": "bool",
81
+ "hint": "情绪上来快、下去慢:负面衰减更慢 + 强情绪冷却 + 标签需 2 条事件才切换"},
82
+ {"key": "emotion_negative_slow", "group": "情绪与人格", "label": "负面情绪更耐放",
83
+ "kind": "bool", "hint": "负面情绪衰减速率更慢(半衰期 ×1.25)"},
84
+ {"key": "emotion_cooldown_enabled", "group": "情绪与人格", "label": "强情绪冷却",
85
+ "kind": "bool", "hint": "强度>0.7 之后 3 个事件内同组增益减半,防越说越气"},
86
+ {"key": "emotion_label_gate_enabled", "group": "情绪与人格", "label": "心情标签防跳变",
87
+ "kind": "bool", "hint": "标签需 ≥2 条情绪事件支撑才切换,避免单句话横跳"},
79
88
  {"key": "speak_up_prob", "group": "水位与节奏", "label": "主动搭话概率",
80
89
  "kind": "float", "min": 0, "max": 1, "step": 0.05,
81
90
  "hint": "每轮结束按此概率让灵枢自己说一句(纯模板、不进模型);0=关闭"},