dsh-cohub 0.10.1 → 0.10.2

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.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/lib/index.js +202 -67
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # dsh-cohub
2
2
 
3
- > 本文对应 **v0.10.1**;完整变更历史见 [CHANGELOG.md](./CHANGELOG.md)。
3
+ > 本文对应 **v0.10.2**;完整变更历史见 [CHANGELOG.md](./CHANGELOG.md)。
4
4
 
5
5
  DeepSeek Harness 版(对照 [OpenCode 版](../oh-my-opencode-cohub/)):中文智能体编排插件。
6
6
  把「纯调度模式 + 13 个技能(12 个代理编排体系 + co-cordis 组合创作)+ 多模型共识 + 运行期调度韧性」移植到 DSH 原生能力之上。
package/lib/index.js CHANGED
@@ -5384,6 +5384,60 @@ var STATUS_TITLE = {
5384
5384
  interrupted: "interrupted(被取消,结论不完整)",
5385
5385
  failed: "failed(分析失败,本轮没有模型结论,原因见下方「分析错误说明」)"
5386
5386
  };
5387
+ function inferSessionsTruncated(sessionsTruncated, lineageTotal, sessionsAnalyzed) {
5388
+ if (typeof sessionsTruncated === "boolean")
5389
+ return sessionsTruncated;
5390
+ if (lineageTotal !== null && sessionsAnalyzed !== null)
5391
+ return sessionsAnalyzed < lineageTotal;
5392
+ return;
5393
+ }
5394
+ function ruleText(note) {
5395
+ return note.length > 0 && note !== DASH ? note : "";
5396
+ }
5397
+ function ruleSuffix(note) {
5398
+ const rule = ruleText(note);
5399
+ return rule.length > 0 ? `(${rule})` : "";
5400
+ }
5401
+ function samplingKind(note) {
5402
+ const rule = ruleText(note);
5403
+ const sampled = rule.includes("取最新");
5404
+ const readFailed = rule.includes("读取失败");
5405
+ if (sampled && readFailed)
5406
+ return "both";
5407
+ if (sampled)
5408
+ return "sampled";
5409
+ if (readFailed)
5410
+ return "readFailed";
5411
+ return "unknown";
5412
+ }
5413
+ function sessionsCoverageText(sessionsTruncatedRaw, lineageTotal, sessionsAnalyzed, samplingNote, childCount) {
5414
+ const sessionsTruncated = inferSessionsTruncated(sessionsTruncatedRaw, lineageTotal, sessionsAnalyzed);
5415
+ const analyzed = sessionsAnalyzed ?? (sessionsTruncated === false ? childCount : null);
5416
+ if (sessionsTruncated === true) {
5417
+ if (lineageTotal !== null && analyzed !== null) {
5418
+ return `已分析 ${analyzed} / 共 ${lineageTotal} 个子会话${ruleSuffix(samplingNote)}`;
5419
+ }
5420
+ if (lineageTotal !== null)
5421
+ return `共 ${lineageTotal} 个子会话(已分析数未记录)`;
5422
+ if (analyzed !== null)
5423
+ return `已分析 ${analyzed} 个子会话(总数未知)`;
5424
+ return "已取样截断(总数未记录)";
5425
+ }
5426
+ if (sessionsTruncated === false) {
5427
+ if (analyzed !== null)
5428
+ return `全部 ${analyzed} 个子会话`;
5429
+ if (lineageTotal !== null)
5430
+ return `全部 ${lineageTotal} 个子会话`;
5431
+ return "全部子会话(数量未记录)";
5432
+ }
5433
+ return "未知(本报告由旧版本生成,未记录子会话总数)";
5434
+ }
5435
+ function childCountFromSessions(report) {
5436
+ const list = Array.isArray(report?.sessions) ? report.sessions : [];
5437
+ if (list.length === 0)
5438
+ return null;
5439
+ return Math.max(0, list.length - 1);
5440
+ }
5387
5441
  function renderMarkdown(report, opts = {}) {
5388
5442
  const r = report ?? {};
5389
5443
  const excerptLimit = typeof opts.excerptLimit === "number" && opts.excerptLimit > 0 ? Math.floor(opts.excerptLimit) : 120;
@@ -5394,12 +5448,18 @@ function renderMarkdown(report, opts = {}) {
5394
5448
  const coverage = r.coverage ?? { throughSeq: {}, complete: false, gaps: [], inputTruncated: false };
5395
5449
  const gaps = Array.isArray(coverage.gaps) ? coverage.gaps : [];
5396
5450
  const complete = coverage.complete === true;
5451
+ const sessionsTruncated = coverage.sessionsTruncated;
5452
+ const lineageTotal = typeof coverage.lineageTotal === "number" && Number.isFinite(coverage.lineageTotal) ? coverage.lineageTotal : null;
5453
+ const sessionsAnalyzedRaw = typeof coverage.sessionsAnalyzed === "number" && Number.isFinite(coverage.sessionsAnalyzed) ? coverage.sessionsAnalyzed : null;
5454
+ const sessionsTruncatedEffective = inferSessionsTruncated(sessionsTruncated, lineageTotal, sessionsAnalyzedRaw);
5455
+ const samplingNote = text(coverage.samplingNote);
5397
5456
  lines.push("# 会话复盘报告", "");
5398
5457
  lines.push(`- 项目 cwd:${text(r.project?.cwd)}`);
5399
5458
  lines.push(`- 项目键:${text(r.project?.key)}`);
5400
5459
  lines.push(`- root session id:${text(r.rootSessionId)}`);
5401
5460
  lines.push(`- 生成时间:${new Date().toISOString()}`);
5402
- lines.push(`- 采集完整性:${complete ? "complete(所有目标会话已读至末尾)" : "不完整(存在缺口,结论需降级)"}`);
5461
+ lines.push(`- 事件流完整性:${complete ? "complete(已分析会话内部事件连续无缺口)" : "不完整(已分析会话内存在事件缺口,结论需降级)"}`);
5462
+ lines.push(`- 会话集合覆盖:${sessionsCoverageText(sessionsTruncated, lineageTotal, sessionsAnalyzedRaw, samplingNote, childCountFromSessions(r))}`);
5403
5463
  lines.push(`- 分析输入是否被裁剪:${coverage.inputTruncated ? "是(结论不得外推到未读区间)" : "否"}`);
5404
5464
  const analysis = r.analysis ?? {};
5405
5465
  const statusRaw = typeof analysis.status === "string" && analysis.status.length > 0 ? analysis.status : "";
@@ -5419,6 +5479,22 @@ function renderMarkdown(report, opts = {}) {
5419
5479
  lines.push("## 覆盖范围", "");
5420
5480
  const throughSeq = coverage.throughSeq ?? {};
5421
5481
  const throughEntries = Object.entries(throughSeq);
5482
+ const rootSid = typeof r.rootSessionId === "string" ? r.rootSessionId : "";
5483
+ const rootSeq = rootSid.length > 0 ? throughSeq[rootSid] : undefined;
5484
+ if (typeof rootSeq === "number" && Number.isFinite(rootSeq)) {
5485
+ lines.push(`> 本报告是快照:根会话截至 seq ${rootSeq}。此后的新 turn 与委派不在本报告范围内,需要重新生成。`, "");
5486
+ } else {
5487
+ lines.push(`> 本报告是快照:根会话的已读 seq ${DASH}(未记录)。此后的新 turn 与委派不在本报告范围内,需要重新生成。`, "");
5488
+ }
5489
+ if (sessionsTruncatedEffective === true) {
5490
+ const totalLabel = lineageTotal !== null ? `${lineageTotal} 个` : `${DASH}(未记录)个`;
5491
+ const analyzedLabel = sessionsAnalyzedRaw !== null ? `${sessionsAnalyzedRaw} 个` : `${DASH}(未记录)个`;
5492
+ if (samplingKind(samplingNote) === "readFailed") {
5493
+ lines.push(`⚠️ 部分子会话读取失败:共 ${totalLabel},成功分析 ${analyzedLabel}。失败子会话的消耗与问题不在本报告内。`, "");
5494
+ } else {
5495
+ lines.push(`⚠️ 子会话取样截断:共 ${totalLabel},只分析了 ${analyzedLabel}${ruleSuffix(samplingNote)}。未分析的子会话的消耗与问题不在本报告内。`, "");
5496
+ }
5497
+ }
5422
5498
  if (throughEntries.length === 0) {
5423
5499
  lines.push(`- 无覆盖记录(throughSeq 为空,${DASH})`);
5424
5500
  } else {
@@ -5524,21 +5600,31 @@ function renderMarkdown(report, opts = {}) {
5524
5600
  lines.push("## 限制说明", "");
5525
5601
  const noConclusion = verified.length === 0;
5526
5602
  const analysisError = typeof r.analysis?.error === "string" && r.analysis.error.length > 0 ? String(r.analysis.error) : null;
5527
- const needsReview = gaps.length > 0 || unverified.length > 0 || !complete;
5603
+ const needsReview = gaps.length > 0 || unverified.length > 0 || !complete || coverage.inputTruncated === true || sessionsTruncatedEffective === true;
5528
5604
  if (needsReview) {
5529
5605
  lines.push("本报告存在未覆盖部分,结论需人工复核。", "");
5606
+ if (coverage.inputTruncated === true) {
5607
+ lines.push("- 分析输入被裁剪:模型摘要超过 12000 字被裁剪(coverage.inputTruncated),结论不得外推到未读区间。");
5608
+ }
5609
+ if (sessionsTruncatedEffective === true) {
5610
+ const totalLabel = lineageTotal !== null ? `${lineageTotal}` : `${DASH}`;
5611
+ const analyzedLabel = sessionsAnalyzedRaw !== null ? `${sessionsAnalyzedRaw}` : `${DASH}`;
5612
+ if (samplingKind(samplingNote) === "readFailed") {
5613
+ lines.push(`- 部分子会话读取失败:共 ${totalLabel} 个,成功分析 ${analyzedLabel} 个,失败子会话不在结论范围内。`);
5614
+ } else {
5615
+ lines.push(`- 子会话取样截断:共 ${totalLabel} 个,只分析了 ${analyzedLabel} 个${ruleSuffix(samplingNote)},未分析的子会话不在结论范围内。`);
5616
+ }
5617
+ }
5530
5618
  if (gaps.length > 0)
5531
5619
  lines.push(`- 采集缺口 ${gaps.length} 处,相关区间的事件未被读到,不应据此下结论。`);
5620
+ if (!complete)
5621
+ lines.push("- coverage.complete 为 false,已分析会话内存在事件缺口,统计数字不完整。");
5532
5622
  if (unverified.length > 0) {
5533
5623
  lines.push(`- ${unverified.length} 条结论缺少证据,已移入「未验证」节,未计入正式分组。`);
5534
5624
  }
5535
5625
  if (noConclusion) {
5536
5626
  lines.push("- 本次复盘**没有产出任何带锚点的结论**(findings 为空),不存在可复核的结论条目。");
5537
5627
  }
5538
- if (!complete)
5539
- lines.push("- coverage.complete 为 false,统计数字不完整。");
5540
- if (coverage.inputTruncated)
5541
- lines.push("- 分析输入被裁剪,结论不得外推到未读区间。");
5542
5628
  if (analysisError)
5543
5629
  lines.push(`- 分析失败/降级原因:${analysisError}`);
5544
5630
  lines.push("");
@@ -5685,6 +5771,10 @@ function updateIndex(entry) {
5685
5771
  };
5686
5772
  if (typeof entry.note === "string" && entry.note.length > 0)
5687
5773
  lastReport.note = entry.note;
5774
+ if (Number.isFinite(entry.lineageTotal))
5775
+ lastReport.lineageTotal = entry.lineageTotal;
5776
+ if (typeof entry.sessionsTruncated === "boolean")
5777
+ lastReport.sessionsTruncated = entry.sessionsTruncated;
5688
5778
  index.projects[key] = {
5689
5779
  cwd: slashed(cwd) ?? prev?.cwd ?? "",
5690
5780
  name: cwd !== null ? basename(cwd) : prev?.name ?? "(未知项目)",
@@ -5717,6 +5807,21 @@ function sortedProjects(index) {
5717
5807
  });
5718
5808
  return rows;
5719
5809
  }
5810
+ function sessionsCoverage(r) {
5811
+ const total = typeof r.lineageTotal === "number" && Number.isFinite(r.lineageTotal) ? r.lineageTotal : null;
5812
+ const analyzed = Number.isFinite(r.sessions) && r.sessions > 0 ? Math.max(0, r.sessions - 1) : null;
5813
+ const truncated = typeof r.sessionsTruncated === "boolean" ? r.sessionsTruncated : total !== null && analyzed !== null ? total > analyzed : null;
5814
+ if (truncated === true) {
5815
+ if (total !== null && analyzed !== null)
5816
+ return `(子会话 ${analyzed}/${total})`;
5817
+ if (total !== null)
5818
+ return `(子会话共 ${total},已分析数未知)`;
5819
+ return "(子会话取样截断,总数未知)";
5820
+ }
5821
+ if (truncated === false)
5822
+ return "(子会话全量)";
5823
+ return "(子会话总数未知)";
5824
+ }
5720
5825
  function renderIndexMarkdown(index) {
5721
5826
  const rows = sortedProjects(index);
5722
5827
  const lines = [];
@@ -5736,7 +5841,7 @@ function renderIndexMarkdown(index) {
5736
5841
  lines.push("| --- | --- | --- | --- | --- |");
5737
5842
  for (const [, p] of rows) {
5738
5843
  const r = p.lastReport;
5739
- lines.push("| " + p.name + " | " + r.status + " | " + r.findings + " | " + r.sessions + " | " + formatLocalTime(r.at) + " |");
5844
+ lines.push("| " + p.name + " | " + r.status + " | " + r.findings + " | " + r.sessions + sessionsCoverage(r) + " | " + formatLocalTime(r.at) + " |");
5740
5845
  }
5741
5846
  lines.push("");
5742
5847
  for (const [key, p] of rows) {
@@ -5745,7 +5850,7 @@ function renderIndexMarkdown(index) {
5745
5850
  lines.push("");
5746
5851
  lines.push("- 项目路径:`" + (p.cwd.length > 0 ? p.cwd : "(未知)") + "`");
5747
5852
  lines.push("- 最近报告:" + formatLocalTime(r.at) + "(本地时间)");
5748
- lines.push("- 状态:" + r.status + " findings:" + r.findings + " 会话数:" + r.sessions);
5853
+ lines.push("- 状态:" + r.status + " findings:" + r.findings + " 会话数:" + r.sessions + sessionsCoverage(r));
5749
5854
  lines.push("- 会话:" + r.sessionId);
5750
5855
  lines.push("- 报告(DSH):`" + (r.jsonPath.length > 0 ? r.jsonPath : "(无)") + "`");
5751
5856
  lines.push("- 报告 MD:`" + (r.mdPath ?? "(无)") + "`");
@@ -5763,15 +5868,15 @@ var DIGEST_LIMIT_CHARS = 12000;
5763
5868
  var ANALYSIS_MAX_TOKENS = 5000;
5764
5869
  var RAW_OUTPUT_KEEP_CHARS = 2000;
5765
5870
  var MAX_CHILD_SESSIONS = 50;
5766
- var MAX_CHILD_FILTER_CALLS = 20;
5871
+ var MAX_LINEAGE_WALK_DEPTH = 64;
5767
5872
  var ANALYSIS_TIMEOUT_MS = 60000;
5768
5873
  var MAX_ROOT_ASCEND = 32;
5769
5874
  function idOf(rec) {
5770
- const v = rec?.session?.id ?? rec?.id ?? rec?.sessionId;
5875
+ const v = rec?.session?.id ?? rec?.id ?? rec?.sessionId ?? rec?.header?.id ?? rec?.session?.header?.id;
5771
5876
  return typeof v === "string" && v.length > 0 ? v : undefined;
5772
5877
  }
5773
5878
  function parentOf(rec) {
5774
- const v = rec?.session?.parentSession ?? rec?.parentSession ?? rec?.parentSessionId;
5879
+ const v = rec?.session?.parentSession ?? rec?.parentSession ?? rec?.parentSessionId ?? rec?.header?.parentSession ?? rec?.session?.header?.parentSession;
5775
5880
  return typeof v === "string" && v.length > 0 ? v : undefined;
5776
5881
  }
5777
5882
  function toSessionEvents(read, fallbackId) {
@@ -5793,92 +5898,115 @@ function toSessionEvents(read, fallbackId) {
5793
5898
  events
5794
5899
  };
5795
5900
  }
5796
- function collectLineageIds(node, out, depth = 0) {
5797
- if (node === null || typeof node !== "object" || depth > 8)
5901
+ function createdAtOf(rec) {
5902
+ const v = rec?.header?.createdAt ?? rec?.session?.header?.createdAt ?? rec?.createdAt;
5903
+ return typeof v === "number" && Number.isFinite(v) ? v : 0;
5904
+ }
5905
+ function normalizeSessionId(id) {
5906
+ const s = typeof id === "string" ? id : "";
5907
+ return s.startsWith("session-") ? s.slice("session-".length) : s;
5908
+ }
5909
+ function collectLineageNodes(node, out, depth = 0) {
5910
+ if (node === null || typeof node !== "object" || depth > MAX_LINEAGE_WALK_DEPTH)
5798
5911
  return;
5799
5912
  if (Array.isArray(node)) {
5800
5913
  for (const item of node)
5801
- collectLineageIds(item, out, depth + 1);
5914
+ collectLineageNodes(item, out, depth + 1);
5802
5915
  return;
5803
5916
  }
5804
5917
  const direct = idOf(node);
5805
- if (direct)
5806
- out.add(direct);
5918
+ if (direct && !out.has(direct))
5919
+ out.set(direct, { id: direct, createdAt: createdAtOf(node) });
5807
5920
  for (const value of Object.values(node)) {
5808
5921
  if (value !== null && typeof value === "object")
5809
- collectLineageIds(value, out, depth + 1);
5922
+ collectLineageNodes(value, out, depth + 1);
5923
+ }
5924
+ }
5925
+ function sampleNewest(nodes, limit) {
5926
+ const sorted = [...nodes].sort((a, b) => b.createdAt - a.createdAt || a.id.localeCompare(b.id));
5927
+ return sorted.slice(0, Math.max(0, limit)).map((n) => n.id);
5928
+ }
5929
+ function toDiscovery(nodes, source) {
5930
+ const total = nodes.size;
5931
+ const ids = sampleNewest(nodes.values(), MAX_CHILD_SESSIONS);
5932
+ return { ids, total, truncated: total > ids.length, source };
5933
+ }
5934
+ function applyDiscoveryCoverage(coverage, discovery, childReadFailed = 0) {
5935
+ const failed = Math.max(0, childReadFailed);
5936
+ const sampled = discovery.ids.length;
5937
+ const sessionsAnalyzed = Math.max(0, sampled - failed);
5938
+ coverage.lineageTotal = discovery.total;
5939
+ coverage.sessionsAnalyzed = sessionsAnalyzed;
5940
+ coverage.sessionsTruncated = discovery.total > sessionsAnalyzed;
5941
+ const sampledOut = sampled < discovery.total;
5942
+ const readFailed = failed > 0;
5943
+ if (sampledOut && readFailed) {
5944
+ coverage.samplingNote = "按创建时间倒序取最新,且存在读取失败的子会话";
5945
+ } else if (sampledOut) {
5946
+ coverage.samplingNote = "按创建时间倒序取最新";
5947
+ } else if (readFailed) {
5948
+ coverage.samplingNote = "存在读取失败的子会话";
5949
+ } else {
5950
+ coverage.samplingNote = undefined;
5810
5951
  }
5811
5952
  }
5812
5953
  async function findChildIds(ctx, rootId, signal) {
5813
- const ids = new Set;
5814
5954
  try {
5815
5955
  const trace = ctx?.sessionQuery?.traceSession;
5816
5956
  if (typeof trace === "function") {
5817
5957
  const tree = await trace.call(ctx.sessionQuery, rootId, signal);
5818
- const found = new Set;
5819
- collectLineageIds(tree?.descendants, found);
5820
- for (const id of found)
5821
- if (id !== rootId)
5822
- ids.add(id);
5823
- }
5824
- } catch (error) {
5825
- ctx.logger?.warn?.("[cohub review] traceSession 失败:" + String(error?.message ?? error));
5826
- }
5827
- if (ids.size > 0)
5828
- return [...ids].slice(0, MAX_CHILD_SESSIONS);
5829
- try {
5830
- const filter = ctx?.sessionQuery?.filterSessions;
5831
- if (typeof filter === "function") {
5832
- const queue = [rootId];
5833
- let calls = 0;
5834
- while (queue.length > 0 && ids.size < MAX_CHILD_SESSIONS && calls < MAX_CHILD_FILTER_CALLS) {
5835
- const parentId = queue.shift();
5836
- calls++;
5837
- const listed = await filter.call(ctx.sessionQuery, { parentSessionId: parentId }, signal);
5838
- const records = Array.isArray(listed) ? listed : [];
5839
- for (const rec of records) {
5840
- const id = idOf(rec);
5841
- if (!id || id === rootId || ids.has(id))
5842
- continue;
5843
- ids.add(id);
5844
- queue.push(id);
5845
- if (ids.size >= MAX_CHILD_SESSIONS)
5846
- break;
5958
+ if (tree !== null && typeof tree === "object") {
5959
+ const found = new Map;
5960
+ collectLineageNodes(tree?.descendants, found);
5961
+ const rootKey = normalizeSessionId(rootId);
5962
+ for (const id of [...found.keys()]) {
5963
+ if (id === rootId || normalizeSessionId(id) === rootKey)
5964
+ found.delete(id);
5847
5965
  }
5966
+ return toDiscovery(found, "trace");
5848
5967
  }
5849
5968
  }
5850
5969
  } catch (error) {
5851
- ctx.logger?.warn?.("[cohub review] filterSessions 失败:" + String(error?.message ?? error));
5970
+ ctx.logger?.warn?.("[cohub review] traceSession 失败:" + String(error?.message ?? error));
5852
5971
  }
5853
- if (ids.size > 0)
5854
- return [...ids].slice(0, MAX_CHILD_SESSIONS);
5855
5972
  try {
5856
5973
  const list = await ctx.sessionQuery.listSessions(signal);
5857
5974
  const records = Array.isArray(list) ? list : [];
5858
5975
  const byParent = new Map;
5859
5976
  for (const rec of records) {
5860
- const id = idOf(rec);
5861
5977
  const parent = parentOf(rec);
5862
- if (!id || !parent)
5978
+ const key = normalizeSessionId(parent);
5979
+ if (!key)
5863
5980
  continue;
5864
- const bucket = byParent.get(parent) ?? [];
5865
- bucket.push(id);
5866
- byParent.set(parent, bucket);
5981
+ const bucket = byParent.get(key) ?? [];
5982
+ bucket.push(rec);
5983
+ byParent.set(key, bucket);
5867
5984
  }
5868
- const queue = [rootId];
5869
- while (queue.length > 0 && ids.size < MAX_CHILD_SESSIONS) {
5985
+ const found = new Map;
5986
+ const rootKey = normalizeSessionId(rootId);
5987
+ const queue = [rootKey];
5988
+ const seenParents = new Set([rootKey]);
5989
+ while (queue.length > 0) {
5870
5990
  const cur = queue.shift();
5871
- for (const child of byParent.get(cur) ?? []) {
5872
- if (child === rootId || ids.has(child))
5991
+ for (const rec of byParent.get(cur) ?? []) {
5992
+ const id = idOf(rec);
5993
+ if (!id)
5873
5994
  continue;
5874
- ids.add(child);
5875
- queue.push(child);
5995
+ const idKey = normalizeSessionId(id);
5996
+ if (idKey === rootKey || found.has(id))
5997
+ continue;
5998
+ found.set(id, { id, createdAt: createdAtOf(rec) });
5999
+ if (!seenParents.has(idKey)) {
6000
+ seenParents.add(idKey);
6001
+ queue.push(idKey);
6002
+ }
5876
6003
  }
5877
6004
  }
6005
+ return toDiscovery(found, "list");
5878
6006
  } catch (error) {
5879
6007
  ctx.logger?.warn?.("[cohub review] listSessions 失败:" + String(error?.message ?? error));
5880
6008
  }
5881
- return [...ids];
6009
+ return { ids: [], total: 0, truncated: false, source: "list" };
5882
6010
  }
5883
6011
  function writeTextAtomic2(file, text) {
5884
6012
  const tmp = file + ".tmp";
@@ -6280,7 +6408,9 @@ async function runAnalysis(ctx, agent, sessionId, cwdHint, withLlm) {
6280
6408
  jsonPath: errorPath,
6281
6409
  mdPath: null,
6282
6410
  projectCopyPath: null,
6283
- note: "本次复盘整体失败,仅落盘 error 记录:" + String(error?.message ?? error).slice(0, 200)
6411
+ note: "本次复盘整体失败,仅落盘 error 记录:" + String(error?.message ?? error).slice(0, 200),
6412
+ lineageTotal: undefined,
6413
+ sessionsTruncated: undefined
6284
6414
  });
6285
6415
  } catch {}
6286
6416
  }
@@ -6292,22 +6422,25 @@ async function runAnalysis(ctx, agent, sessionId, cwdHint, withLlm) {
6292
6422
  async function runAnalysisInner(ctx, agent, sessionId, cwdHint, withLlm, signal) {
6293
6423
  const { sessionId: rootId, read: rootRead, failed: rootFailed } = await readRootSession(ctx, sessionId, signal);
6294
6424
  const root = toSessionEvents(rootRead, rootId);
6295
- const childIds = await findChildIds(ctx, root.sessionId, signal);
6425
+ const discovery = await findChildIds(ctx, root.sessionId, signal);
6296
6426
  const children = [];
6297
6427
  const gaps = [];
6428
+ let childReadFailed = 0;
6298
6429
  if (rootFailed)
6299
6430
  gaps.push(rootId + ": " + rootFailed);
6300
- for (const childId of childIds) {
6431
+ for (const childId of discovery.ids) {
6301
6432
  try {
6302
6433
  const read = await ctx.sessionQuery.readSession(childId, signal);
6303
6434
  children.push(toSessionEvents(read, childId));
6304
6435
  } catch (error) {
6436
+ childReadFailed++;
6305
6437
  gaps.push(childId + ": 子会话读取失败(" + String(error?.message ?? error) + ")");
6306
6438
  }
6307
6439
  }
6308
6440
  const report = buildReport({ root, children });
6441
+ applyDiscoveryCoverage(report.coverage, discovery, childReadFailed);
6309
6442
  report.coverage.gaps.push(...gaps);
6310
- if (gaps.length > 0)
6443
+ if (childReadFailed > 0 || rootFailed)
6311
6444
  report.coverage.complete = false;
6312
6445
  const cwd = root.cwd ?? cwdHint;
6313
6446
  const { text: digest, digest: inputDigest, truncated } = buildDigest(report);
@@ -6385,7 +6518,9 @@ async function runAnalysisInner(ctx, agent, sessionId, cwdHint, withLlm, signal)
6385
6518
  jsonPath,
6386
6519
  mdPath: mdOk ? mdPath : null,
6387
6520
  projectCopyPath: copy.path,
6388
- note: copy.note ?? undefined
6521
+ note: copy.note ?? undefined,
6522
+ lineageTotal: report.coverage.lineageTotal,
6523
+ sessionsTruncated: report.coverage.sessionsTruncated
6389
6524
  });
6390
6525
  if (!indexed)
6391
6526
  ctx.logger?.warn?.("[cohub review] 复盘索引更新失败(不影响报告)");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-cohub",
3
- "version": "0.10.1",
3
+ "version": "0.10.2",
4
4
  "description": "DeepSeek Harness 版 CoHub:中文智能体编排——用户可选 2 种工作模式(co-orchestrator 纯调度 / cohub-cordis 创造模式)+ 13 个专职代理技能 + 多模型共识;另由 cohub-subagent-readonly / cohub-subagent-write 两个支撑 preset 实现子代理读写硬隔离(共 4 个 preset)",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",