dsh-mcmp 2.1.0 → 2.1.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.
package/README.md CHANGED
@@ -123,7 +123,7 @@ Client 插件(dsh-mcmp,标准 __ModuleLoader__ bundle)
123
123
 
124
124
  ## 文件说明
125
125
 
126
- > 仓库根目录即插件包本体(发布到 npm 的内容 = `lib/` + `cordis.patch.yml` + `package.json`)。
126
+ > 仓库根目录即插件包本体(发布到 npm 的内容 = `lib/` + `cordis.patch.yml` + `package.json`;`tests/` 不随包发布)。
127
127
 
128
128
  | 文件 | 内容 |
129
129
  | --- | --- |
@@ -131,6 +131,7 @@ Client 插件(dsh-mcmp,标准 __ModuleLoader__ bundle)
131
131
  | `cordis.patch.yml` | **bundle 补丁**:安装时自动注册插件行(`insert: mcmp`),无需手动编辑配置 |
132
132
  | `lib/index.js` | **Host 半**:命令注册、识图能力探测、断点续跑、Host 侧子智能体编排(8 步骤 + 兜底定稿)、`/mcmp-api` 面板路由 |
133
133
  | `lib/client.js` | **Client 半**:浮动进度面板(标准 `__ModuleLoader__` bundle,`fetch` 轮询) |
134
+ | `tests/smoke.mjs` | **冒烟测试**:伪造 Cordis ctx 驱动插件,验证启动/触发/断点续跑(含多轮)/中止/兜底/`--from`/识图探测等路径,`node tests/smoke.mjs`(不随 npm 包发布) |
134
135
 
135
136
  ## License
136
137
 
package/lib/client.js CHANGED
@@ -80,7 +80,8 @@ window.__ModuleLoader__.load({
80
80
  // 拖拽只绑定在标题文字上,避免指针捕获吞掉同栏按钮的点击
81
81
  const onTitleDown = (e) => {
82
82
  if (e.button !== 0) return
83
- const box = e.currentTarget.parentElement ? e.currentTarget.parentElement.parentElement : null
83
+ const head = e.currentTarget.parentElement
84
+ const box = head && head.parentElement ? head.parentElement : null
84
85
  if (!box) return
85
86
  const rect = box.getBoundingClientRect()
86
87
  box.setPointerCapture(e.pointerId)
package/lib/index.js CHANGED
@@ -170,33 +170,32 @@ export function apply(ctx) {
170
170
  if (ev.type === 'tool-workflow/run-start') {
171
171
  const d = ev.data || {}
172
172
  if (d.name === FLOW_NAME) {
173
- current = { started: [], ended: [] }
173
+ current = { done: new Set() }
174
174
  runs.push(current)
175
175
  } else {
176
176
  current = null
177
177
  }
178
- } else if (ev.type === 'tool-workflow/agent-start' && current) {
179
- const d = ev.data || {}
180
- if (Number.isSafeInteger(d.seq) && d.seq >= 1) current.started[d.seq - 1] = true
181
178
  } else if (ev.type === 'tool-workflow/agent-end' && current) {
182
179
  const d = ev.data || {}
183
- if (Number.isSafeInteger(d.seq) && d.seq >= 1) current.ended[d.seq - 1] = d.outcome === 'completed'
180
+ if (Number.isSafeInteger(d.seq) && d.seq >= 1 && d.outcome === 'completed') current.done.add(d.seq)
184
181
  }
185
182
  } catch (err) { /* 单条事件解析失败忽略 */ }
186
183
  }
187
- const prefix = (run) => {
188
- let n = 0
189
- for (let i = 0; i < run.started.length; i++) {
190
- if (run.started[i] === true && run.ended[i] === true) n = i + 1
191
- else break
192
- }
193
- return n
184
+ // 一次运行从最小序号 S 起连续完成 C 个迭代,则该运行贡献 = (S-1) + C。
185
+ // 这样多轮/续跑运行(seq 20、39…继续编号)也能正确累计,而不是只数 1..19。
186
+ const contribution = (run) => {
187
+ if (!run || run.done.size === 0) return 0
188
+ let S = Infinity
189
+ for (const seq of run.done) if (seq < S) S = seq
190
+ let c = 0
191
+ while (run.done.has(S + c)) c++
192
+ return (S - 1) + c
194
193
  }
195
194
  const last = runs[runs.length - 1]
196
- let n = last ? prefix(last) : 0
195
+ let n = last ? contribution(last) : 0
197
196
  if (n === 0) {
198
197
  let m = 0
199
- for (const run of runs) m = Math.max(m, prefix(run))
198
+ for (const run of runs) m = Math.max(m, contribution(run))
200
199
  n = m
201
200
  }
202
201
  return n
@@ -534,7 +533,8 @@ export function apply(ctx) {
534
533
  if (!Number.isSafeInteger(rounds) || rounds < 1) rounds = 1
535
534
  if (rounds > 10) return { kind: 'error', text: '--round 最大为 10。每轮 19 次迭代、每次迭代启动一个专家子智能体,轮数过大会非常耗时。' }
536
535
  const fresh = /(?:^|\s)--fresh\b/i.test(raw)
537
- const mFrom = /(?:^|\s)--from(?:=)?\s*([^\r\n]+)$/i.exec(raw)
536
+ // --from 路径:允许含空格,遇到下一个 -- 标志或行尾即结束,避免吞掉后面的 --round/--fresh
537
+ const mFrom = /(?:^|\s)--from(?:=)?\s*([^\r\n]+?)(?=\s+--|\r?$)/i.exec(raw)
538
538
  let problem = null
539
539
  if (mFrom) {
540
540
  let p = mFrom[1].trim().replace(/^["']|["']$/g, '')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-mcmp",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "description": "DeepSeek Harness 插件:数学建模论文自动化流水线 v2(8 步骤 × 19 迭代 × N 轮:图表视觉自检与修复、评审问题修复闭环、跨步骤缺陷台账与向上修复、论文兜底定稿、质疑驱动、断点续跑、进度面板)",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",