dsh-reconcile 0.1.1 → 0.1.3

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/README.md CHANGED
@@ -66,11 +66,11 @@ DeepSeek Harness 插件:**先核事实、再决定问不问、收工对账**
66
66
 
67
67
  ## 安装
68
68
 
69
- **从 npm 装(已发布 0.1.0):**
69
+ **从 npm 装(已发布 0.1.2):**
70
70
 
71
71
  ```bash
72
72
  dsh plugin --profile web add dsh-reconcile
73
- dsh plugin --profile web add dsh-reconcile@0.1.0 # 钉版本
73
+ dsh plugin --profile web add dsh-reconcile@0.1.2 # 钉版本
74
74
  ```
75
75
 
76
76
  npm 包页:<https://www.npmjs.com/package/dsh-reconcile>
package/client.js CHANGED
@@ -793,7 +793,8 @@ function formatScore(result) {
793
793
  }, [draft, inputActions, sessionId])
794
794
 
795
795
  if (!score) {
796
- return hasText
796
+ // 紧凑版没有「有文字」这个中间变量(那是输入框下方那个组件的),这里直接从 draft 现算
797
+ return String(draft ?? '').trim() !== ''
797
798
  ? h('span', { style: { color: T.muted, fontSize: 11 }, 'data-dsh-plugin': 'dsh-reconcile' }, `${t('scoreLabel')} …`)
798
799
  : null
799
800
  }
package/index.js CHANGED
@@ -712,26 +712,45 @@ export function apply(ctx, rawConfig = {}) {
712
712
  }],
713
713
  ]
714
714
 
715
- const connection = ctx.get('connection')
716
- if (config.routesEnabled !== false && connection?.fetch?.register) {
715
+ /**
716
+ * 路由挂载。必须用 ctx.inject(['connection']) 等它就绪:
717
+ * 插件之间是并行激活的,apply() 执行时 connection 可能还没起来;
718
+ * 直接 ctx.get('connection') 拿不到就静默跳过,表现为面板按钮全部 404。
719
+ */
720
+ const mountRoutes = (hostCtx) => {
721
+ const connection = hostCtx?.connection ?? hostCtx?.get?.('connection')
722
+ if (!connection?.fetch?.register) {
723
+ hostCtx?.logger?.warn?.('dsh-reconcile: connection.fetch 不可用,面板按钮会退化成只读(工具与收尾对账不受影响)')
724
+ return false
725
+ }
717
726
  for (const [routePath, methods, handler] of routes) {
718
- connection.fetch.register({
719
- path: routePath,
720
- methods,
721
- requestBody: 'buffered',
722
- fetch: async (request) => {
723
- const blocked = admit(request)
724
- if (blocked) return blocked
725
- try {
726
- return await handler(request)
727
- } catch (error) {
728
- return json({ ok: false, error: String(error?.message ?? error) }, 500)
729
- }
730
- },
731
- })
727
+ hostCtx.effect?.(() => {
728
+ const dispose = connection.fetch.register({
729
+ path: routePath,
730
+ methods,
731
+ requestBody: 'buffered',
732
+ fetch: async (request) => {
733
+ const blocked = admit(request)
734
+ if (blocked) return blocked
735
+ try {
736
+ return await handler(request)
737
+ } catch (error) {
738
+ return json({ ok: false, error: String(error?.message ?? error) }, 500)
739
+ }
740
+ },
741
+ })
742
+ return () => { void dispose?.() }
743
+ }, 'dsh-reconcile: route ' + routePath)
744
+ }
745
+ return true
746
+ }
747
+
748
+ if (config.routesEnabled !== false) {
749
+ if (typeof ctx.inject === 'function') {
750
+ ctx.inject(['connection'], (child) => { mountRoutes(child) })
751
+ } else {
752
+ mountRoutes(ctx)
732
753
  }
733
- } else {
734
- ctx.logger?.warn?.('dsh-reconcile: 没有 connection.fetch 服务,面板按钮会退化成只读(工具与收尾对账不受影响)')
735
754
  }
736
755
 
737
756
  return () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-reconcile",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "type": "module",
5
5
  "description": "交账 — fact-first clarification, heuristic ambiguity scoring, and an evidence-backed end-of-task reconciliation ledger",
6
6
  "license": "MIT",
@@ -910,6 +910,25 @@ x
910
910
  })
911
911
  }
912
912
 
913
+ /* --------------------- 9. 客户端作用域静态护栏 --------------------- */
914
+ {
915
+ const src = readFileSync(new URL('../client.js', import.meta.url), 'utf8')
916
+ const startOf = (name) => src.indexOf('function ' + name)
917
+ const scoreStart = startOf('ScoreHint')
918
+ const heroStart = startOf('HeroHint')
919
+ test('客户端作用域:hasText 只出现在 ScoreHint 内(HeroHint 误用会白屏崩溃)', () => {
920
+ assert.ok(scoreStart > 0 && heroStart > scoreStart, '函数定位失败')
921
+ const scoreSlice = src.slice(scoreStart, heroStart)
922
+ const outside = src.split('\n').map((line, i) => ({ line, no: i + 1 }))
923
+ .filter(({ line }) => /\bhasText\b/.test(line) && !/^\s*(\/\/|\*)/.test(line))
924
+ .filter(({ no }) => {
925
+ const pos = src.split('\n').slice(0, no - 1).join('\n').length
926
+ return !(pos >= scoreStart && pos < heroStart)
927
+ })
928
+ assert.deepEqual(outside.map((o) => o.no), [], 'hasText 出现在 ScoreHint 之外:' + JSON.stringify(outside))
929
+ })
930
+ }
931
+
913
932
  /* -------------------------------- 汇总 -------------------------------- */
914
933
  const total = passed + failed
915
934
  console.log(`\n自检:${passed}/${total} 通过${failed > 0 ? `,${failed} 失败` : ''}`)
@@ -919,4 +938,4 @@ if (failed > 0) {
919
938
  }
920
939
  process.exit(1)
921
940
  }
922
- console.log('全绿。覆盖:打分表 16 项 · TASK.md 解析/回写 14 项 · 证据判定 16 项 · 覆盖与防伪造 13 项 · 骨架与返工 4 项 · 跨站 8 项 · 候选排序 7 项 · 客户端打分器对拍 2 项')
941
+ console.log('全绿。覆盖:打分表 16 项 · TASK.md 解析/回写 14 项 · 证据判定 16 项 · 覆盖与防伪造 13 项 · 骨架与返工 4 项 · 跨站 8 项 · 候选排序 7 项 · 客户端打分器对拍 2 项 · 作用域护栏 1 项')