@suifei/dsh-ai-team 0.4.113 → 0.4.114

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 CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.114 - 2026-11-16
4
+
5
+ **SkillOpt 判分不再因答复开头复述 JSON 格式而全部记零**
6
+
7
+ - il2c night 11(0.4.113,干净采集 1 会话 → 2 任务):所有判分都记成 `judge-parse-failed`,留出集 0.000 → 0.000,
8
+ 而判分子代理实际给出 0.6 / 0.85 / 0.78。答复先写一段说明、复述题面「return only JSON {"score": <0..1>, …}」,
9
+ 末尾才是真 JSON;`_extract_json` 的贪婪 `\{.*\}` 从复述处吃到末尾,解析失败;
10
+ - `_extract_json`:最宽跨度解析失败时,取最后一个能解析的同类 JSON 值(判分、挖任务、反思共用);
11
+ - `judge`:对象解析不出时兜底取最后一个 `"score": 数字`(night 11 有 1/11 份答复漏了收尾 `}`),原因记 `judge-score-only`;
12
+ - 测试:`test/skillopt-dsh-source.test.js` 新增 1 例(去掉修复即失败);
13
+
3
14
  ## 0.4.113 - 2026-11-16
4
15
 
5
16
  **dsh 来源也跳过「替引擎答题」的会话,不论谁派的**
@@ -292,15 +292,36 @@ class MockBackend(Backend):
292
292
  # ── Shared real-CLI backend (prompts + parsing + cache; subclasses do _call) ──
293
293
 
294
294
  def _extract_json(raw: str, kind: str):
295
- """Pull the first JSON object/array out of a possibly chatty CLI reply."""
296
- pat = r"\{.*\}" if kind == "object" else r"\[.*\]"
297
- m = re.search(pat, raw or "", re.DOTALL)
298
- if not m:
295
+ """Pull the JSON object/array out of a possibly chatty CLI reply.
296
+
297
+ The widest span (first opener .. last closer) is tried first, as before.
298
+ When it does not parse -- a reply that restates the requested format, e.g.
299
+ 'return only JSON {"score": <0..1>, ...}', before the real answer -- the
300
+ last value of the requested kind that does parse is taken: chatty replies
301
+ put the answer at the end (il2c night 11: every judge reply was scored
302
+ judge-parse-failed although each ended with a valid {"score": ...}).
303
+ """
304
+ text = raw or ""
305
+ opener, closer, want = ("{", "}", dict) if kind == "object" else ("[", "]", list)
306
+ first, last = text.find(opener), text.rfind(closer)
307
+ if first < 0 or last < first:
299
308
  return None
300
309
  try:
301
- return json.loads(m.group(0))
310
+ return json.loads(text[first:last + 1])
302
311
  except Exception:
303
- return None
312
+ pass
313
+ decoder = json.JSONDecoder()
314
+ found = None
315
+ pos = first
316
+ while pos >= 0:
317
+ try:
318
+ value, _ = decoder.raw_decode(text, pos)
319
+ except ValueError:
320
+ value = None
321
+ if isinstance(value, want):
322
+ found = value
323
+ pos = text.find(opener, pos + 1)
324
+ return found
304
325
 
305
326
 
306
327
  def _task_guardrail(pairs) -> str:
@@ -519,6 +540,12 @@ class CliBackend(Backend):
519
540
  return (1.0 if soft >= 0.8 else 0.0), soft, str(obj.get("reason", ""))[:200]
520
541
  except (ValueError, TypeError):
521
542
  pass
543
+ # A reply whose JSON lost its closing brace still carries the score
544
+ # (il2c night 11: 1 of 11 judge replies ended '..."' without '}').
545
+ scores = re.findall(r'"score"\s*:\s*([0-9]+(?:\.[0-9]+)?)', raw or "")
546
+ if scores:
547
+ soft = min(1.0, max(0.0, float(scores[-1])))
548
+ return (1.0 if soft >= 0.8 else 0.0), soft, "judge-score-only"
522
549
  return 0.0, 0.0, "judge-parse-failed"
523
550
 
524
551
  def reflect(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suifei/dsh-ai-team",
3
- "version": "0.4.113",
3
+ "version": "0.4.114",
4
4
  "type": "module",
5
5
  "description": "文渊阁 (Wenyuan Pavilion) — AI Team mode for DeepSeek Harness: concurrent projects, owned tasks, threads, inbox and an append-only team ledger",
6
6
  "license": "MIT",