clearai-dsh 0.4.0 → 0.5.1

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.
@@ -18,7 +18,7 @@
18
18
  * 面向人的新字符串一律先落在 `GLOSSARY`(内部词 → 一句 plain + 在哪看 + 下一步做什么);
19
19
  * `client.js` 的 `LOCALE_ZH/LOCALE_EN` 与它同源登记。
20
20
  */
21
- import { graphProjection, ontologyOutline } from './domain-language.js'
21
+ import { graphProjection } from './domain-language.js'
22
22
  import { bilingual, tr } from './lang.js'
23
23
 
24
24
  /** 卡文本上限。模型每一步只读这一张卡,而卡是**每回合**重算的:它必须小到能进预算。 */
@@ -67,7 +67,7 @@ export const GLOSSARY = bilingual({
67
67
  nextAction: ['派一次独立评估,把评估卡作为出处', 'Get one independent evaluation and cite its evaluation card'],
68
68
  },
69
69
  L4: {
70
- plain: ['人放行:交付前有人看过并批准', 'Released by a person: someone looked at it and approved before delivery'],
70
+ plain: ['人工批准:交付前已有人审阅并批准', 'Released by a person: someone looked at it and approved before delivery'],
71
71
  where: ['docs/verification-loop.md 的等级表', 'the level table in docs/verification-loop.md'],
72
72
  nextAction: ['等一次人的放行记录;没有人就不要声称到过这一级', 'Wait for a person to release it; without one, do not claim this level'],
73
73
  },
@@ -144,8 +144,8 @@ export const GLOSSARY = bilingual({
144
144
  plain: ['命题只有散文主张:两条结论是不是在说同一件事只能靠重读判断', 'Prose-only claims: whether two conclusions say the same thing can only be judged by rereading'],
145
145
  where: ['运行态卡 · 缺口', 'runtime card · gaps'],
146
146
  nextAction: [
147
- '先在 clear/ontology/ 下写概念、关系与主体的实体文件,再用 Frame 修订把主张写成断言(主词–谓词–宾语)',
148
- 'First write concept, relation and subject entity files under clear/ontology/, then revise with Frame to turn the claim into assertions (subject–predicate–object)',
147
+ '可选:用 Frame 修订在 ontology 里补上概念与关系,再把主张写成断言(主词–谓词–宾语)',
148
+ 'Optional: revise with Frame to add the concepts and relations in ontology, then write the claim as assertions (subject–predicate–object)',
149
149
  ],
150
150
  },
151
151
  untouched_claims: {
@@ -192,7 +192,8 @@ export const LEVELS = ['L0', 'L1', 'L2', 'L3', 'L4']
192
192
  * **说人话的三张小表**(第六阶段)。内部名不改;卡、工具结果与面板上一律写右边那一列。
193
193
  * 模型读到什么就会照着说什么——所以卡先说人话,答复才说得出人话。
194
194
  */
195
- export const LEVEL_WORD = bilingual({ L0: ['自己推了一遍', 'reasoned through alone'], L1: ['引用已有材料', 'cites existing material'], L2: ['可复算', 'reproducible'], L3: ['独立核验', 'independent check'], L4: ['人放行', 'released by a person'] })
195
+ /** 等级只说三档:L0–L2 合并成「自行检验」(旧账里的 L0 / L1 也这么读),L3 独立评估,L4 人工批准。 */
196
+ export const LEVEL_WORD = bilingual({ L0: ['自行检验', 'self-tested'], L1: ['自行检验', 'self-tested'], L2: ['自行检验', 'self-tested'], L3: ['独立核验', 'independent check'], L4: ['人工批准', 'approved by a person'] })
196
197
  export const VERDICT_WORD = bilingual({ support: ['支持', 'support'], refute: ['推翻', 'refute'], inconclusive: ['不确定', 'inconclusive'] })
197
198
  /** 判断短名的上限(汉字);没起名时取主张开头这么宽。与内核同一个数。 */
198
199
  export const HANDLE_LIMIT = 12
@@ -337,6 +338,22 @@ export function readingOf(hypothesis) {
337
338
  /** 步骤状态的人话。 */
338
339
  const STEP_WORD = bilingual({ open: ['待做', 'to do'], advanced: ['已交付', 'delivered'], void: ['已作废', 'voided'] })
339
340
 
341
+ /** 一条事实在卡上的一行:原话、边界、等级;来自别的会话的标出来。 */
342
+ /** 有开着的未解释项点名这条事实:它回到「待核验」,直到那些未解释项有了去处。 */
343
+ function questionedNote(fact, language) {
344
+ const ids = Array.isArray(fact?.questioned) ? fact.questioned : []
345
+ if (ids.length === 0) return ''
346
+ return language === 'en' ? ` · pending re-check (unexplained ${ids.join(', ')})` : ` · 待核验(未解释项 ${ids.join('、')})`
347
+ }
348
+
349
+ function factLine(fact) {
350
+ const scope = oneLine(fact?.scope ?? '')
351
+ return tr(
352
+ ` · 「${clamp(fact?.text, 100)}」${scope === '' ? '' : ` — 边界:${clamp(scope, 80)}`}${fact?.level ? ` · ${fact.level}` : ''}${fact?.foreign === true ? ' · 以前的会话' : ''}${questionedNote(fact, 'zh')}`,
353
+ ` · "${clamp(fact?.text, 100)}"${scope === '' ? '' : ` — boundary: ${clamp(scope, 80)}`}${fact?.level ? ` · ${fact.level}` : ''}${fact?.foreign === true ? ' · earlier session' : ''}${questionedNote(fact, 'en')}`,
354
+ )
355
+ }
356
+
340
357
  /**
341
358
  * **卡的正文**。它只读已经算好的 `view` 与 `(state, derived)`,不重算任何判据——
342
359
  * 同一份账本永远给出同一串字节:卡里**不带时刻**——时间戳会让同一个状态的卡每分钟变一次,
@@ -358,8 +375,6 @@ function cardLines(state, derived, options, view) {
358
375
  const evidence = Array.isArray(state?.evidence) ? state.evidence : []
359
376
  const facts = Array.isArray(state?.facts) ? state.facts : []
360
377
  const hostHealth = Array.isArray(state?.hostHealth) ? state.hostHealth : []
361
- const graph = graphProjection(state)
362
- const entityNodes = graph.nodes.filter((node) => node.layer === 'entity')
363
378
  const promotedIds = new Set(facts.map((fact) => fact?.hypothesis).filter((id) => typeof id === 'string'))
364
379
  const byId = new Map(hypotheses.map((hypothesis) => [hypothesis.id, hypothesis]))
365
380
  const nameOf = (id) => (byId.has(id) ? tr(`「${handleOf(byId.get(id))}」`, `"${handleOf(byId.get(id))}"`) : tr('一条已不在账上的判断', 'a judgment no longer on record'))
@@ -405,11 +420,36 @@ function cardLines(state, derived, options, view) {
405
420
  const terminal = group.key === 'refuted' || group.key === 'replaced'
406
421
  const named = typeof hypothesis.name === 'string' && hypothesis.name.trim() !== ''
407
422
  const head = tr(named ? `「${hypothesis.name.trim()}」${clamp(hypothesis.claim, 120)}` : `「${clamp(hypothesis.claim, 120)}」`, named ? `"${hypothesis.name.trim()}" ${clamp(hypothesis.claim, 120)}` : `"${clamp(hypothesis.claim, 120)}"`)
408
- const refute = terminal ? '' : tr(` — 算错的条件:${clamp(hypothesis.refute_when, 100)}`, ` — wrong if: ${clamp(hypothesis.refute_when, 100)}`)
423
+ const refute = terminal ? '' : tr(` — 推翻条件:${clamp(hypothesis.refute_when, 100)}`, ` — wrong if: ${clamp(hypothesis.refute_when, 100)}`)
409
424
  push(` · ${head}${refute} · ${readingOf(hypothesis)}`, terminal ? 1 : 0)
410
425
  }
411
426
  }
412
- if (hypotheses.length > 10) push(tr(` · 还有 ${hypotheses.length - 10} 条判断没展开(面板「本体」里有全部)`, ` · ${hypotheses.length - 10} more judgments not shown (all are in the Ontology pane)`), 2)
427
+ if (hypotheses.length > 10) push(tr(` · 还有 ${hypotheses.length - 10} 条判断没展开(「探索」货架里有全部)`, ` · ${hypotheses.length - 10} more judgments not shown (all are in the Explore shelf)`), 2)
428
+ }
429
+ /**
430
+ * **当前位置**:问题 → 候选假设(或调研板块)的计数,与探索货架同一份派生(`derived.exploration`)。
431
+ * 只在目标开着时给;没列问题的目标就是一个问题,这一行省掉(上面的判断列表已经说清)。
432
+ */
433
+ const exploration = isPlainObject(derived?.exploration) ? derived.exploration : null
434
+ if (exploration !== null && goal !== null && String(goal.status) === 'open') {
435
+ const STATE_WORD = { examining: tr('考察中', 'being examined'), excluded: tr('已排除', 'excluded'), adopted: tr('已采纳', 'adopted'), set_aside: tr('暂不考察', 'set aside') }
436
+ const AREA_WORD = { not_started: tr('未开始', 'not started'), in_progress: tr('调研中', 'in progress'), clear: tr('已厘清', 'clear') }
437
+ const declared = (exploration.questions ?? []).filter((question) => !question.implicit)
438
+ if (declared.length > 0 || (exploration.areas ?? []).length > 0) {
439
+ push(tr('- 当前位置:', '- Where things stand:'))
440
+ for (const area of (exploration.areas ?? []).slice(0, 8)) push(tr(` 板块「${clamp(area.name, 30)}」${AREA_WORD[area.state] ?? area.state} · 判断 ${area.judgments} 条,已采纳 ${area.verified} 条${area.openAnomalies > 0 ? ` · 未解释 ${area.openAnomalies} 条` : ''}`, ` Area "${clamp(area.name, 30)}" ${AREA_WORD[area.state] ?? area.state} · ${area.judgments} judgments, ${area.verified} adopted${area.openAnomalies > 0 ? ` · ${area.openAnomalies} unexplained` : ''}`), 1)
441
+ for (const question of declared.slice(0, 8)) {
442
+ const counts = Object.entries({ examining: question.counts?.examining, excluded: question.counts?.excluded, adopted: question.counts?.adopted }).filter(([, value]) => value > 0).map(([key, value]) => tr(`${STATE_WORD[key]} ${value}`, `${STATE_WORD[key]} ${value}`))
443
+ const status = question.status === 'answered' ? tr('已作答', 'answered') : question.status === 'emergent' ? tr('新发现,待人决定是否立为问题', 'newly found, awaiting a decision') : question.status === 'parked' ? tr('暂缓', 'parked') : counts.length > 0 ? tr(`候选假设 ${counts.join(' / ')}`, `candidates ${counts.join(' / ')}`) : tr('还没有候选假设', 'no candidates yet')
444
+ push(` ${question.id === exploration.current ? '▸' : '·'} ${question.id}「${clamp(question.text, 60)}」${status}`, question.id === exploration.current ? 0 : 1)
445
+ }
446
+ }
447
+ /** 本体里带形状、还没有候选由它提出的影响关系:只列出,不强制(不为竞争而竞争)。 */
448
+ const untapped = Array.isArray(exploration.untapped) ? exploration.untapped : []
449
+ if (untapped.length > 0) {
450
+ const SHAPE = { increasing: tr('单调升', 'increasing'), decreasing: tr('单调降', 'decreasing'), peak: tr('有峰', 'has a peak'), threshold: tr('有阈值', 'has a threshold'), coupled: tr('耦合', 'coupled') }
451
+ push(tr(`- 本体中尚无候选假设引用的影响关系:${untapped.slice(0, 5).map((item) => `${item.label}(${SHAPE[item.shape] ?? item.shape})`).join('、')}——若它们可能改变结论,可据此提出候选(\`from\` 写关系 id)`, `- Affects relations in the ontology no candidate cites yet: ${untapped.slice(0, 5).map((item) => `${item.label} (${SHAPE[item.shape] ?? item.shape})`).join(', ')}; if they could change the conclusion, propose candidates from them (\`from\` = the relation id)`), 1)
452
+ }
413
453
  }
414
454
  if (plan === null) {
415
455
  if (goal !== null && String(goal.status) === 'open') push(tr('- 计划:还没有(用 CreatePlan 把检验拆成步骤)', '- Plan: none yet (use CreatePlan to split the tests into steps)'), 1)
@@ -421,18 +461,63 @@ function cardLines(state, derived, options, view) {
421
461
  const tests = tested.length === 0 ? '' : tr(` · 检验 ${tested.map(nameOf).join('、')}(${level})`, ` · tests ${tested.map(nameOf).join(', ')} (${level})`)
422
462
  push(tr(` 第 ${step.ordinal} 步(${step.id})${clamp(step.do, 60)} · ${STEP_WORD[step.status] ?? step.status}${tests}`, ` Step ${step.ordinal} (${step.id}) ${clamp(step.do, 60)} · ${STEP_WORD[step.status] ?? step.status}${tests}`), 2)
423
463
  }
424
- if (plan.steps.length > 12) push(tr(` · 还有 ${plan.steps.length - 12} 步没展开(右栏「世界树」里有全部)`, ` · ${plan.steps.length - 12} more steps not shown (all are in the World Tree on the right)`), 2)
464
+ if (plan.steps.length > 12) push(tr(` · 还有 ${plan.steps.length - 12} 步没展开(「探索」货架里有全部)`, ` · ${plan.steps.length - 12} more steps not shown (all are in the Explore shelf)`), 2)
425
465
  const first = plan.steps.find((step) => step.status === 'open')
426
- if (first !== undefined) push(tr(`- 下一步:交付第 ${first.ordinal} 步(${first.id})——只能交付第一个没做完的步`, `- Next: deliver step ${first.ordinal} (${first.id}); only the first unfinished step can be delivered`))
427
- else if (goal !== null && String(goal.status) === 'open') push(tr('- 下一步:计划的步都做完了,ClosePlan 收尾,然后 Conclude 结案或开下一阶段', '- Next: every step is done; ClosePlan, then Conclude or start the next stage'))
466
+ if (first !== undefined) {
467
+ push(tr(`- 下一步:交付第 ${first.ordinal} 步(${first.id})——只能交付第一个没做完的步`, `- Next: deliver step ${first.ordinal} (${first.id}); only the first unfinished step can be delivered`))
468
+ /** 预期可选,但卡上提醒:没写下来的预期,落空了也看不见。 */
469
+ const next = exploration?.next ?? null
470
+ const predictions = next !== null && next.step === first.id && Array.isArray(next.predictions) ? next.predictions : []
471
+ if (predictions.length > 0) {
472
+ push(tr(' 各候选的预测:', ' Predictions per candidate:'))
473
+ for (const item of predictions.slice(0, 5)) push(tr(` · 若「${item.name}」成立:${clamp(item.expect, 120)}`, ` · If "${item.name}" holds: ${clamp(item.expect, 120)}`))
474
+ if (next.indistinct === true) push(tr(' 注意:各候选的预测相同,这一步区分不了它们;应改用能区分的检验(RevisePlan)', ' Warning: every candidate predicts the same, so this step cannot tell them apart; switch to a test that can (RevisePlan)'))
475
+ else push(tr(' 结果与预测不符的地方写进 anomalies,不要解释过去', ' Whatever contradicts the predictions goes in anomalies; do not explain it away'), 1)
476
+ }
477
+ if (typeof first.expect === 'string' && first.expect !== '') push(tr(` 预测:${clamp(first.expect, 160)}。结果与预测不符之处写入 anomalies,不要强行解释`, ` Expected: ${clamp(first.expect, 160)}; whatever does not match goes in anomalies, do not explain it away`))
478
+ else if (predictions.length === 0) push(tr(' 动手前写下预测(RevisePlan action="expect":按候选分别写 predictions,或写 expect 并注明来自哪条关系或经验),落空才看得见', ' Before acting, write predictions (RevisePlan action="expect": predictions per candidate, or expect with the relation or lesson it comes from), so a miss is visible'), 1)
479
+ }
480
+ else if (goal !== null && String(goal.status) === 'open') push(tr('- 下一步:计划的步都做完了,ClosePlan 收尾,然后 Conclude 结案(answers 按问题写结论、依据、尚未确定的事项、待您决策)或开下一阶段', '- Next: every step is done; ClosePlan, then Conclude (answers per question: conclusion, basis, open points, decisions for the user) or start the next stage'))
428
481
  if (plan.blocked !== undefined && plan.blocked !== null) push(tr(`- 计划停下等人:${plan.blocked.reason}(连续 ${plan.blocked.attempts} 次没过,已经问人怎么办;没人答就等着)`, `- Plan stopped, waiting for a person: ${plan.blocked.reason} (failed ${plan.blocked.attempts}× in a row; a person has been asked; wait if nobody answers)`))
429
482
  }
483
+ /**
484
+ * **未解释项**:卡上最不能省的一格。开着的逐条摆出来,直到被解释、写明理由排除、或交给人;
485
+ * 评估者报的标出来(那是做的人自己没看见的)。
486
+ */
487
+ const anomalies = Array.isArray(state?.anomalies) ? state.anomalies : []
488
+ const openAnomalies = anomalies.filter((item) => item?.status === 'open')
489
+ if (openAnomalies.length > 0) {
490
+ push(tr(`- 未解释(${openAnomalies.length} 条开着;用 Anomaly 解释、排除或交给人,不要解释过去):`, `- Unexplained (${openAnomalies.length} open; explain, rule out or hand to a person with Anomaly; do not explain them away):`))
491
+ for (const item of openAnomalies.slice(0, 8)) push(tr(` · ${item.id}${item.by === 'evaluator' ? '(评估者发现)' : ''}:${clamp(item.what, 140)}${item.anchor ? ` · 在 ${clamp(item.anchor, 30)}` : ''}${(item.touches ?? []).length > 0 ? ` · 涉及 ${item.touches.slice(0, 4).join('、')}` : ''}`, ` · ${item.id}${item.by === 'evaluator' ? ' (found by the evaluator)' : ''}: ${clamp(item.what, 140)}${item.anchor ? ` · on ${clamp(item.anchor, 30)}` : ''}${(item.touches ?? []).length > 0 ? ` · touches ${item.touches.slice(0, 4).join(', ')}` : ''}`))
492
+ if (openAnomalies.length > 8) push(tr(` · 还有 ${openAnomalies.length - 8} 条`, ` · ${openAnomalies.length - 8} more`), 1)
493
+ }
494
+ const settledAnomalies = anomalies.length - openAnomalies.length
495
+ if (settledAnomalies > 0) {
496
+ const escalated = anomalies.filter((item) => item?.status === 'escalated').length
497
+ push(tr(`- 已处理的未解释:${settledAnomalies} 条${escalated > 0 ? `(${escalated} 条交给人)` : ''},结案时随交付交给评估者`, `- Unexplained items handled: ${settledAnomalies}${escalated > 0 ? ` (${escalated} handed to a person)` : ''}; they go to the evaluator with the delivery`), 2)
498
+ }
430
499
  if (evidence.length > 0) {
431
500
  const last = evidence[evidence.length - 1]
432
501
  const who = last.evaluator === 'independent' ? LEVEL_WORD.L3 : LEVEL_WORD[last.level] ?? tr('自己判的', 'self-judged')
433
502
  const target = last.hypothesis === null || last.hypothesis === undefined ? tr('目标判据', 'goal criteria') : nameOf(last.hypothesis)
434
503
  push(tr(`- 最近一次结果:${target}${VERDICT_WORD[last.verdict] ?? last.verdict}(${who})`, `- Latest result: ${target} ${VERDICT_WORD[last.verdict] ?? last.verdict} (${who})`), 1)
435
504
  }
505
+ /**
506
+ * **经验**:以前结案时核过的「下次怎么做」。只在要做决定的时候摆出来:立题前、定计划前、
507
+ * 下一步动手而还没写预期时。与眼下目标和下一步提到同一装置或量的排在前面。
508
+ */
509
+ const lessonRows = Array.isArray(derived?.lessonRows) ? derived.lessonRows : []
510
+ const nextStep = plan === null ? null : (plan.steps.find((step) => step.status === 'open') ?? null)
511
+ const deciding = goal === null || String(goal.status) !== 'open' || plan === null || (nextStep !== null && (typeof nextStep.expect !== 'string' || nextStep.expect === ''))
512
+ if (lessonRows.length > 0 && deciding) {
513
+ const context = `${goal?.claim ?? ''}\n${nextStep?.do ?? ''}`.toLowerCase()
514
+ const score = (lesson) => (lesson.about ?? []).filter((item) => item !== '' && context.includes(String(item).toLowerCase())).length
515
+ const ranked = lessonRows.map((lesson, index) => ({ lesson, index, score: score(lesson) })).sort((a, b) => b.score - a.score || a.index - b.index)
516
+ const kindWord = { trap: tr('常见误区', 'common pitfall'), check: tr('前置核查', 'check first'), shortcut: tr('不可取的捷径', 'misleading shortcut'), prior: tr('先验知识', 'prior') }
517
+ push(tr(`- 以前留下的经验(${lessonRows.length} 条;制定计划、写预测前先阅读,引用时在预测中注明来自哪条):`, `- Lessons left earlier (${lessonRows.length}; read before planning or writing an expectation, and name the one you use in the expectation):`), 1)
518
+ for (const { lesson } of ranked.slice(0, 6)) push(` · ${lesson.id} · ${kindWord[lesson.kind] ?? lesson.kind} · ${clamp(lesson.text, 160)}${lesson.boundary ? tr(`(不适用:${clamp(lesson.boundary, 80)})`, ` (does not apply: ${clamp(lesson.boundary, 80)})`) : ''}`, 1)
519
+ if (lessonRows.length > 6) push(tr(` · 还有 ${lessonRows.length - 6} 条(clear/knowledge/lessons/)`, ` · ${lessonRows.length - 6} more (clear/knowledge/lessons/)`), 2)
520
+ }
436
521
  /** 事实行含别的会话留下的(`foreign`):攒下来的东西从这里开始被看见。 */
437
522
  const factRows = Array.isArray(derived?.factRows) ? derived.factRows : facts
438
523
  if (factRows.length > 0) {
@@ -447,23 +532,21 @@ function cardLines(state, derived, options, view) {
447
532
  )
448
533
  }
449
534
  /**
450
- * **本体大纲**:概念树与实体树的前两层(每支标节点数)、关系总数、跨文件问题。
451
- * 细节在 clear/ontology/ 下的文件里,模型自己去读。
535
+ * **立题之前**(或上一个目标已结):以前留下的事实原话与边界直接摆出来(最多 5 条)。立题是最该看已知的时刻,
536
+ * 这时还没有判断可以拿来做词面命中,所以按新近给。
537
+ */
538
+ if (goal === null || String(goal.status) !== 'open') {
539
+ const usable = factRows.filter((fact) => fact?.review?.decision !== 'retracted' && fact?.refuted !== true)
540
+ if (usable.length > 0) {
541
+ push(tr('- 以前留下的事实(立题前先看;要复检哪条,就在判断上写 retests,claim 照抄原话):', '- Facts left earlier (read before framing; to re-test one, put retests on a judgment with the original statement as the claim):'), 1)
542
+ for (const fact of usable.slice(-5).reverse()) push(factLine(fact), 1)
543
+ }
544
+ }
545
+ /**
546
+ * 本体提纲与计数不上卡(它从没改变过下一步):卡上只出现被判断引用到的本体项(见下面的预检)。
547
+ * 跨文件问题照旧报——那是要修的东西。
452
548
  */
453
- const outline = ontologyOutline(state)
454
549
  const ontologyProblems = Array.isArray(state?.ontologyProblems) ? state.ontologyProblems : []
455
- if (outline.concepts.total > 0 || outline.entities.total > 0 || outline.relations > 0) {
456
- const entityRelations = Array.isArray(state?.entityAssertions) ? state.entityAssertions.length : 0
457
- push(
458
- tr(
459
- `- 本体(clear/ontology/):${outline.concepts.total} 个概念 · ${outline.relations} 种关系 · ${outline.entities.total} 个实体 · ${entityRelations} 条实体关系`,
460
- `- Ontology (clear/ontology/): ${outline.concepts.total} concepts · ${outline.relations} relation types · ${outline.entities.total} entities · ${entityRelations} entity relations`,
461
- ),
462
- 1,
463
- )
464
- if (outline.concepts.lines.length > 0) push(tr(` · 概念树:${outline.concepts.lines.join(';')}${outline.concepts.more > 0 ? `;顶层还有 ${outline.concepts.more} 个` : ''}`, ` · Concept tree: ${outline.concepts.lines.join('; ')}${outline.concepts.more > 0 ? `; ${outline.concepts.more} more at the top level` : ''}`), 1)
465
- if (outline.entities.lines.length > 0) push(tr(` · 实体树:${outline.entities.lines.join(';')}${outline.entities.more > 0 ? `;顶层还有 ${outline.entities.more} 个` : ''}`, ` · Entity tree: ${outline.entities.lines.join('; ')}${outline.entities.more > 0 ? `; ${outline.entities.more} more at the top level` : ''}`), 1)
466
- } else if (entityNodes.length > 0) push(tr(`- 实体图上 ${entityNodes.length} 个实例`, `- ${entityNodes.length} instances on the entity graph`), 1)
467
550
  if (ontologyProblems.length > 0) {
468
551
  push(tr(`- 本体文件有 ${ontologyProblems.length} 处问题(有问题的节点或关系没进图):`, `- Ontology files have ${ontologyProblems.length} problems (the affected nodes or relations stay off the graph):`), 1)
469
552
  for (const item of ontologyProblems.slice(0, 5)) push(` · ${item.path}: ${clamp(item.detail, 160)}`, 1)
@@ -474,25 +557,35 @@ function cardLines(state, derived, options, view) {
474
557
  }
475
558
  if (knowledge.mode === 'knowledge') {
476
559
  const preflight = view.deliver.preflight
477
- if (preflight !== null && (preflight.terms.length > 0 || preflight.predicates.length > 0)) {
560
+ if (preflight !== null && (preflight.terms.length > 0 || preflight.predicates.length > 0 || preflight.facts.length > 0)) {
561
+ /**
562
+ * **递原文,不递名单**:命中的概念给它的释义(度量就是口径),命中的事实给原话与边界。
563
+ * 只给名字,模型得自己去翻文件——真跑里它从不去翻,本体于是从没影响过一次判断。
564
+ */
478
565
  const more = (count) => (count > 0 ? tr(`(还有 ${count} 个)`, ` (${count} more)`) : '')
479
566
  const named = (entry) => (entry.label === entry.id ? entry.id : `${entry.label}(${entry.id})`)
480
- const none = tr('无', 'none')
481
- const terms = preflight.terms.map(named).join(tr('、', ', ')) || none
482
- const predicates = preflight.predicates.map(named).join(tr('、', ', ')) || none
483
- push(tr(`- 已有的词,可直接用:概念 ${terms}${more(preflight.termsTruncated)};关系 ${predicates}${more(preflight.predicatesTruncated)}`, `- Existing terms you can use: concepts ${terms}${more(preflight.termsTruncated)}; relations ${predicates}${more(preflight.predicatesTruncated)}`), 1)
484
- if (preflight.facts.length > 0) push(tr(` · 能复用的已知 ${preflight.facts.length} 条${preflight.factsTruncated > 0 ? `(还有 ${preflight.factsTruncated} 条)` : ''}`, ` · ${preflight.facts.length} known facts to reuse${preflight.factsTruncated > 0 ? ` (${preflight.factsTruncated} more)` : ''}`), 1)
485
- } else
486
- push(
487
- tr(
488
- '- 已有的词里没有命中这些判断的:要写「主体 · 关系 · 对象」就先在 clear/ontology/ 下写概念与关系文件(字段见 SCHEMA.json);查不到不等于不存在',
489
- '- No existing term matches these judgments: to write "subject · relation · object", first write concept and relation files under clear/ontology/ (fields in SCHEMA.json); not found does not mean it does not exist',
490
- ),
491
- 1,
492
- )
567
+ if (preflight.terms.length > 0) {
568
+ push(tr(`- 这些判断用到的概念(释义就是口径,算法变了先改它)${more(preflight.termsTruncated)}:`, `- Concepts these judgments use (the gloss is the definition; if how it is computed changes, update it first)${more(preflight.termsTruncated)}:`), 1)
569
+ for (const term of preflight.terms.slice(0, 4)) push(` · ${named(term)}:${clamp(term.gloss, 100) || tr('(没写释义)', '(no gloss)')}${term.unit ? tr(`(单位 ${term.unit})`, ` (unit ${term.unit})`) : ''}`, 1)
570
+ }
571
+ /** 带形状或核对办法的关系逐条给(预期从这里来);其余只给名字。 */
572
+ const SHAPE_WORD = { increasing: tr('单调升', 'increasing'), decreasing: tr('单调降', 'decreasing'), peak: tr('有峰', 'has a peak'), threshold: tr('有阈值', 'has a threshold'), coupled: tr('与别的量耦合', 'coupled with another quantity') }
573
+ const telling = preflight.predicates.filter((predicate) => predicate.shape || predicate.check)
574
+ const plain = preflight.predicates.filter((predicate) => !(predicate.shape || predicate.check))
575
+ if (telling.length > 0) {
576
+ push(tr('- 用到的关系(预测的来源):', '- Relations in use (expectations come from these):'), 1)
577
+ for (const predicate of telling.slice(0, 4)) push(` · ${named(predicate)}${predicate.shape ? tr(`:${SHAPE_WORD[predicate.shape] ?? predicate.shape}`, `: ${SHAPE_WORD[predicate.shape] ?? predicate.shape}`) : ''}${predicate.gloss ? tr(`(${clamp(predicate.gloss, 80)})`, ` (${clamp(predicate.gloss, 80)})`) : ''}${predicate.check ? tr(` · 读数这样核:${clamp(predicate.check, 80)}`, ` · check readings by: ${clamp(predicate.check, 80)}`) : ''}`, 1)
578
+ }
579
+ if (plain.length > 0) push(tr(`- 用到的关系:${plain.slice(0, 6).map(named).join('、')}${more(preflight.predicatesTruncated)}`, `- Relations in use: ${plain.slice(0, 6).map(named).join(', ')}${more(preflight.predicatesTruncated)}`), 2)
580
+ if (preflight.facts.length > 0) {
581
+ push(tr(`- 和这些判断有关的已知${more(preflight.factsTruncated)}(引用前看边界;要复检就在判断上写 retests):`, `- Known facts related to these judgments${more(preflight.factsTruncated)} (check the boundary before citing; to re-test, put retests on a judgment):`), 1)
582
+ for (const fact of preflight.facts.slice(0, 3)) push(factLine(fact), 1)
583
+ }
584
+ }
493
585
  if (gaps.length === 0) push(tr('- 结构完整:判断都写成了断言、都检验过、主体都在实体图上', '- Structure complete: every judgment has assertions, has been tested, and its subjects are on the entity graph'))
494
586
  /** 缺口只给模型(人看不到):说清欠什么、下一步做什么,不写 code。 */
495
- for (const gap of gaps) push(tr(`- 还欠的:${gap.detail} → ${gap.nextAction}`, `- Still owed: ${gap.detail} → ${gap.nextAction}`))
587
+ /** 只有散文的判断不上卡(它是可选的加法,重复提醒从没改变过下一步);面板照旧列出。 */
588
+ for (const gap of gaps.filter((item) => item.code !== 'prose_only_claims')) push(tr(`- 还欠的:${gap.detail} → ${gap.nextAction}`, `- Still owed: ${gap.detail} → ${gap.nextAction}`))
496
589
  }
497
590
  for (const conflict of conflicts.slice(0, 3)) {
498
591
  push(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clearai-dsh",
3
- "version": "0.4.0",
3
+ "version": "0.5.1",
4
4
  "description": "ClearAI: an ontology-first DSH agent preset — evidence-checked research that grows into a domain ontology.",
5
5
  "type": "module",
6
6
  "private": false,
@@ -37,7 +37,7 @@
37
37
  ],
38
38
  "engines": {
39
39
  "node": ">=22",
40
- "dsh": ">=0.1.7-alpha.1"
40
+ "dsh": ">=0.2.0-rc.2"
41
41
  },
42
42
  "dependencies": {
43
43
  "zod": "^4.6.1"
@@ -21,7 +21,7 @@
21
21
  name: '@deepseek-ai/dsh-persona'
22
22
  config:
23
23
  prefix: '你是 ClearAI 的主人格,运行在 DeepSeek Harness 上。怎么工作见下面三段:身份、循环、对人说话。'
24
- suffix: 你的工作目录是 {{cwd}}。工作区就是用户的文件夹;`clear/` 是系统的目录,其余目录都是用户的。
24
+ suffix: 你的工作目录是 {{cwd}}。工作区就是用户的文件夹;`clear/` 下除本体(`clear/ontology/`)外是系统的目录,其余目录都是用户的。
25
25
 
26
26
  - id: agent-instructions
27
27
  name: '@deepseek-ai/dsh-agent-instructions'
@@ -135,7 +135,7 @@
135
135
 
136
136
  # ── 认识论内核(本预设的灵魂) ───────────────────────────────────────────────
137
137
 
138
- # 6 件意图工具(目标 2 + 计划 4,见 `MECHANISM_TOOLS`;领域本体没有工具,
138
+ # 7 件意图工具(目标 2 + 计划 5,见 `MECHANISM_TOOLS`;领域本体没有工具,
139
139
  # 模型用原生文件工具直接写 clear/ontology/{concepts,relations,entities}/**.json)
140
140
  # + 一个 guard + 每回合派生的运行态卡 + 面板数据路由。
141
141
  # 逐条对照 docs/loop-philosophy.md 的哲学,见 ./plugins/clearai-kernel.js 的文件头。
@@ -185,12 +185,20 @@
185
185
  # 为什么要有它:判据是"怎样算完成",它一变前面所有工作的验收含义跟着变——
186
186
  # 允许在同一次 Frame 里顺手改掉,等于允许把"做不到"重新定义成"做到了"。
187
187
  requireCriteriaVerdict: true
188
+ # 测量门槛:首次立题要在 Frame.ontology 里写出答案涉及的度量,以及每个度量由什么测量、读数如何核对。
189
+ # 为什么:真跑里唯一一条错误事实,来自把控制器回读值当成釜温。
190
+ requireMeasures: true
191
+ # 停止检查:achieved 结案要按问题写结论;仍在考察中的候选与开着的未解释项须写进「尚未确定的事项」。
192
+ requireAnswers: true
188
193
  # deny_rules 十条里可移植的九条(路径越狱那条不搬:宿主沙箱已经拥有它,ClearAI 自己也说「不重复」)
189
194
  bashDenyRules: true
190
195
  # 独立评估者:spawn = fresh context(fork 会继承历史,做的人与判的人就分不开了)
191
196
  auditProvider: spawn
192
197
  auditTimeoutMs: 240000
193
198
  # 评估者只读:工具面只给 read/glob/grep;provider 不支持时会降级,降级事实写进台账
199
+ # 评估者可以复跑:内核把工作区(不含 clear/)复制到临时目录,评估者在副本里跑产物自带的脚本核数字,
200
+ # 工具面因此多一个 bash;原工作区只读。L3「可重跑」这才名副其实。
201
+ auditRerun: true
194
202
  auditToolFilter:
195
203
  - read
196
204
  - glob
@@ -205,7 +213,7 @@
205
213
  # 当场抛错——未知机制 / 未知工具 / 未知段 / 已关机制却仍列着它的工具,四种错法都在装配期炸,
206
214
  # 而不是静默少装一件工具、等某一轮才发现。
207
215
  #
208
- # 这里只写**机制开关**;tools / sections 缺省 = 目录全量(6 件意图工具、3 段提示词,全部在场)。
216
+ # 这里只写**机制开关**;tools / sections 缺省 = 目录全量(7 件意图工具、3 段提示词,全部在场)。
209
217
  # 这些数字不靠人眼维持:`node tools/verify-truth-table.mjs` 会拿代码算出来的数核对它们。
210
218
  # 要裁剪就把 tools 或 sections 显式写出来:
211
219
  # tools: [Frame, CreatePlan, AdvancePlan, ...] # 名字必须都在工具目录里
@@ -38,7 +38,7 @@
38
38
  name: '@deepseek-ai/dsh-persona'
39
39
  config:
40
40
  prefix: '你是 ClearAI 的主人格,运行在 DeepSeek Harness 上。怎么工作见下面三段:身份、循环、对人说话。'
41
- suffix: 你的工作目录是 {{cwd}}。工作区就是用户的文件夹;`clear/` 是系统的目录,其余目录都是用户的。
41
+ suffix: 你的工作目录是 {{cwd}}。工作区就是用户的文件夹;`clear/` 下除本体(`clear/ontology/`)外是系统的目录,其余目录都是用户的。
42
42
 
43
43
  - id: agent-instructions
44
44
  name: '@deepseek-ai/dsh-agent-instructions'
@@ -152,7 +152,7 @@
152
152
 
153
153
  # ── 认识论内核(本预设的灵魂) ───────────────────────────────────────────────
154
154
 
155
- # 6 件意图工具(目标 2 + 计划 4,见 `MECHANISM_TOOLS`;领域本体没有工具,
155
+ # 7 件意图工具(目标 2 + 计划 5,见 `MECHANISM_TOOLS`;领域本体没有工具,
156
156
  # 模型用原生文件工具直接写 clear/ontology/{concepts,relations,entities}/**.json)
157
157
  # + 一个 guard + 每回合派生的运行态卡 + 面板数据路由。
158
158
  # 逐条对照 docs/loop-philosophy.md 的哲学,见 ./plugins/clearai-kernel.js 的文件头。
@@ -202,12 +202,20 @@
202
202
  # 为什么要有它:判据是"怎样算完成",它一变前面所有工作的验收含义跟着变——
203
203
  # 允许在同一次 Frame 里顺手改掉,等于允许把"做不到"重新定义成"做到了"。
204
204
  requireCriteriaVerdict: true
205
+ # 测量门槛:首次立题要在 Frame.ontology 里写出答案涉及的度量,以及每个度量由什么测量、读数如何核对。
206
+ # 为什么:真跑里唯一一条错误事实,来自把控制器回读值当成釜温。
207
+ requireMeasures: true
208
+ # 停止检查:achieved 结案要按问题写结论;仍在考察中的候选与开着的未解释项须写进「尚未确定的事项」。
209
+ requireAnswers: true
205
210
  # deny_rules 十条里可移植的九条(路径越狱那条不搬:宿主沙箱已经拥有它,ClearAI 自己也说「不重复」)
206
211
  bashDenyRules: true
207
212
  # 独立评估者:spawn = fresh context(fork 会继承历史,做的人与判的人就分不开了)
208
213
  auditProvider: spawn
209
214
  auditTimeoutMs: 240000
210
215
  # 评估者只读:工具面只给 read/glob/grep;provider 不支持时会降级,降级事实写进台账
216
+ # 评估者可以复跑:内核把工作区(不含 clear/)复制到临时目录,评估者在副本里跑产物自带的脚本核数字,
217
+ # 工具面因此多一个 bash;原工作区只读。L3「可重跑」这才名副其实。
218
+ auditRerun: true
211
219
  auditToolFilter:
212
220
  - read
213
221
  - glob
@@ -222,7 +230,7 @@
222
230
  # 当场抛错——未知机制 / 未知工具 / 未知段 / 已关机制却仍列着它的工具,四种错法都在装配期炸,
223
231
  # 而不是静默少装一件工具、等某一轮才发现。
224
232
  #
225
- # 这里只写**机制开关**;tools / sections 缺省 = 目录全量(6 件意图工具、3 段提示词,全部在场)。
233
+ # 这里只写**机制开关**;tools / sections 缺省 = 目录全量(7 件意图工具、3 段提示词,全部在场)。
226
234
  # 这些数字不靠人眼维持:`node tools/verify-truth-table.mjs` 会拿代码算出来的数核对它们。
227
235
  # 要裁剪就把 tools 或 sections 显式写出来:
228
236
  # tools: [Frame, CreatePlan, AdvancePlan, ...] # 名字必须都在工具目录里