ralphflow-dsh 2.2.0 → 2.3.0

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
@@ -81,7 +81,7 @@ CHECK 不是同一个会话再问一遍"你做完了吗"。它是一个**全新
81
81
 
82
82
  ### 安装
83
83
 
84
- 前置:已安装 **dsh**(`@deepseek-ai/dsh-* >= 0.2.0-rc.2`、`cordis >= 4.0.4`)与 **pnpm**(`dsh plugin` 是 pnpm 的转发器)。
84
+ 前置:已安装 **dsh** 与 **pnpm**(`dsh plugin` 是 pnpm 的转发器)。已验证 npm 默认频道 `dsh@0.2.0-rc.2`(`cordis@4.0.4`)及原有 `dsh@0.2.1-alpha.1`;**不需要升级到 alpha**。宿主包由 dsh 提供,插件不会通过 peer 自动安装另一套宿主。
85
85
 
86
86
  ```bash
87
87
  dsh plugin --profile web add ralphflow-dsh
@@ -182,7 +182,7 @@ steps:
182
182
 
183
183
  ### loop——多验证者对抗驱动的单步循环
184
184
 
185
- 开放式任务、Bug 修复、范围明确的功能开发。一个步骤内完成「实现 → 执行摘要 → 4 个验证者并行投票 → 修复」的迭代闭环,直到全过。
185
+ 开放式任务、Bug 修复、范围明确的功能开发。一个步骤内完成「实现 → 执行摘要 → 3 个验证者并行投票 → 修复」的迭代闭环,直到全过。
186
186
 
187
187
  ```
188
188
  /ralphflow-loop "用 JWT + refresh token 实现用户认证模块"
@@ -190,11 +190,11 @@ steps:
190
190
 
191
191
  ```mermaid
192
192
  flowchart LR
193
- L["loop<br/>实现 → 摘要 → 4 验证者投票"] -->|任一票不通过<br/>带失败理由返工| L
193
+ L["loop<br/>实现 → 摘要 → 3 验证者投票"] -->|任一票不通过<br/>带失败理由返工| L
194
194
  L -->|全过| Done
195
195
  ```
196
196
 
197
- 前三票逐字对齐 opencode 版(每一条要求都已落实 / 行为符合预期,真实可用 / 没有遗漏的需求,边界情况已覆盖),第 4 票是本仓库的口径「修改不影响原有功能,不破坏需求以外的边界」。标了 `reset: true`:失败返工时换干净上下文,每轮摘要追加到 `summary.md`。`max_fail_count: 100`。想增减验证者,改 `check_voting` 数组即可(1–5 条,写几个就几个)。
197
+ 三个视角分别验收:**需求完整性与边界**、**实际可用性与验证依据**、**回归影响**。需求落实与遗漏检查合并为一票,减少重复取证。标了 `reset: true`:失败返工时换干净上下文,每轮摘要追加到 `summary.md`。`max_fail_count: 100`。想增减验证者,改 `check_voting` 数组即可(1–5 条,写几个就几个)。默认三票减少验证者数量,但不代替供应商级的共享并发限制。
198
198
 
199
199
  ### spec——四步开发流水线
200
200
 
package/lib/engine.d.ts CHANGED
@@ -359,7 +359,7 @@ export interface Delegation {
359
359
  *
360
360
  * 这是**原始事实**(这一笔委派到底是第几次跑),不是派生量:聚合时要靠它区分
361
361
  * 「首轮 infra → 自动重试一次」与「重试仍 infra → 暂停」(照抄 opencode 的重试预算,
362
- * 见 `check-voting.ts` §4.4)。单 `check` 步骤不写该字段(省略 = 首轮)。
362
+ * 见 `check-voting.ts` §4.4)。单 `check` 与投票均写该字段;兼容旧状态(省略 = 首轮)。
363
363
  */
364
364
  attempt?: number;
365
365
  ts: string;
package/lib/engine.js CHANGED
@@ -1954,8 +1954,8 @@ export function createEngine(projectDir, ports) {
1954
1954
  advance(instId, state, wf, step);
1955
1955
  return false;
1956
1956
  }
1957
- /** 发起本步的验证:投票步走 {@link launchVotingRound}(N 票并发),单 check 步走原路径 */
1958
- async function launchVerification(instId, state, wf, step) {
1957
+ /** 发起本步的验证;单 check 与投票均只允许一次基础设施自动重试。 */
1958
+ async function launchVerification(instId, state, wf, step, attempt = 1) {
1959
1959
  if (voterCountOf(step) > 0) {
1960
1960
  // 全新一轮(DO 重新交卷 / 孤儿恢复后重投)⇒ 上一轮的票一律作废、N 票**全部**重投
1961
1961
  //(跨轮语义:工作已经变了,上一轮通过的票也不再复用 —— 见 opencode §4.7)。
@@ -1970,22 +1970,25 @@ export function createEngine(projectDir, ports) {
1970
1970
  /** 验证耗时(§3.2:判定事件必须带耗时)——起算点是委派发起,不是判定落账 */
1971
1971
  const startedAt = Date.now();
1972
1972
  state.delegations.push({
1973
- run_id: runId, check_index: checkIndex, ts: new Date().toISOString(),
1973
+ run_id: runId, check_index: checkIndex, attempt, ts: new Date().toISOString(),
1974
1974
  // 属主运行时(诊断)+ 心跳起点(判活的唯一依据):心跳只要还在刷新,别的会话 /
1975
1975
  // 别的沙箱进程 / 重载后的新实例就不得把这笔在飞委派当孤儿清掉。
1976
1976
  owner_runtime: runtimeId(), heartbeat_at: Date.now(),
1977
1977
  });
1978
- pushHistory(state, "verify_start", `check_index=${checkIndex}`, step.id);
1978
+ pushHistory(state, "verify_start", `check_index=${checkIndex},attempt=${attempt}`, step.id);
1979
1979
  writeState(state, instId);
1980
1980
  startHeartbeat(instId, runId);
1981
- log("info", "verify_start", { instId, step: step.id, checkIndex });
1981
+ log("info", "verify_start", { instId, step: step.id, checkIndex, attempt });
1982
1982
  // 阶段播报:验证是**异步**的(委派独立子代理,不阻塞主会话回合)。
1983
1983
  // 这段静默窗口必须讲清三件事:正在发生什么 / 要不要你操作 / 去哪看进度。
1984
1984
  //
1985
1985
  // **绝不给时长预估**:实测 3m53s / 7m29s / 8m34s,而且委派**没有超时上界**
1986
1986
  // (见 verify.ts:生命周期跟随宿主原生能力)—— 猜一个「通常 1–5 分钟」就是编。
1987
1987
  // 能诚实说的只有「它在读文件、跑命令取证,你(用户)看得到」。
1988
- notify(state, [
1988
+ notify(state, attempt > 1 ? [
1989
+ `🔍 步骤 \`${step.id}\` 验证发生基础设施故障,正在**自动重新验证一次**(不计失败次数)。`,
1990
+ "无需操作;重试仍故障会暂停,等你修复后继续。",
1991
+ ].join("\n") : [
1989
1992
  `🔍 步骤 \`${step.id}\` 已交卷,独立验证者(独立会话,看不到本对话)正在取证判定。`,
1990
1993
  "",
1991
1994
  `**这一步你是异步等待的,不需要做任何操作** —— 验证者跑完会自动唤醒本会话并继续工作流。它现在正在读文件、跑命令取证,你在会话里看得到它在做什么。`,
@@ -1994,7 +1997,9 @@ export function createEngine(projectDir, ports) {
1994
1997
  `- 直接在此会话补充信息或纠正方向(会被模型看到)`,
1995
1998
  `- 用 \`/ralphflow-status\` 随时查看进度与最近轨迹`,
1996
1999
  `- 想中止就 \`/ralphflow-cancel\``,
1997
- ].join("\n"), `🔍 步骤 ${step.id} 已交卷,独立验证者正在取证(无需操作)`);
2000
+ ].join("\n"), attempt > 1
2001
+ ? `🔍 步骤 ${step.id} 基础设施故障,自动重试中(不计失败)`
2002
+ : `🔍 步骤 ${step.id} 已交卷,独立验证者正在取证(无需操作)`);
1998
2003
  let verdict;
1999
2004
  try {
2000
2005
  verdict = await ports.verify({
@@ -2043,11 +2048,20 @@ export function createEngine(projectDir, ports) {
2043
2048
  fresh.delegations = fresh.delegations.filter((d) => d.run_id !== runId);
2044
2049
  fresh.verdicts.push(verdict);
2045
2050
  dropAbort(instId, controller);
2046
- pushHistory(fresh, `verdict_${verdict.status}`, verdict.reason.slice(0, 300), step.id);
2051
+ const retryInfra = verdict.status === "infra" && attempt < 2;
2052
+ pushHistory(fresh, retryInfra ? "verify_infra_retry" : `verdict_${verdict.status}`, verdict.reason.slice(0, 300), step.id);
2047
2053
  // 判定入执行日志:`reason` **全文不截断**(§3.2),并带耗时;与报告里的判定字符串同源同值。
2048
2054
  log("info", "verdict", { instId, step: step.id, checkIndex, status: verdict.status, reason: verdict.reason, ms: Date.now() - startedAt });
2055
+ if (retryInfra) {
2056
+ // 与投票恢复一致:故障不烧工作失败预算,只自动重跑一次。
2057
+ // 移除这次故障判定,让只读状态显示新委派正在运行,而非已经返回故障。
2058
+ fresh.verdicts = fresh.verdicts.filter((v) => v !== verdict);
2059
+ writeState(fresh, instId);
2060
+ void launchVerification(instId, fresh, wf, step, attempt + 1);
2061
+ return;
2062
+ }
2049
2063
  // 单 check 就是「一轮一票」:整体结论 = 这张票的判定,直接套用共享的结论应用段
2050
- //(暂停 / 返工 / 审查门 / 推进的规则与多验证者投票同一条路径,行为逐字未变)。
2064
+ //(自动重试耗尽后,暂停 / 返工 / 审查门 / 推进走同一条路径)。
2051
2065
  applyRoundOutcome(instId, fresh, wf, step, { kind: verdict.status, reason: verdict.reason }, startedAt);
2052
2066
  }
2053
2067
  // ─── 多验证者投票(check_voting)─────────────────────────────────────────────
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ralphflow-dsh",
3
- "version": "2.2.0",
3
+ "version": "2.3.0",
4
4
  "description": "Ralph Flow for DeepSeek Harness — 执行者/验证者模式的具象化:主会话执行,独立验证者对抗检查,推进权在机械程序(v2 原生重做)",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -59,23 +59,23 @@
59
59
  "js-yaml": "^4.1.1"
60
60
  },
61
61
  "peerDependencies": {
62
- "@deepseek-ai/cordis": "^4.0.5-alpha.1",
63
- "@deepseek-ai/dsh-agent": "^0.2.1-alpha.1",
64
- "@deepseek-ai/dsh-llm": "^0.2.1-alpha.1",
65
- "@deepseek-ai/dsh-tools": "^0.2.1-alpha.1",
66
- "@deepseek-ai/dsh-subagent": "^0.2.1-alpha.1",
67
- "@deepseek-ai/dsh-session": "^0.2.1-alpha.1",
68
- "@deepseek-ai/dsh-compaction": "^0.2.1-alpha.1",
69
- "@deepseek-ai/dsh-commands": "^0.2.1-alpha.1",
70
- "@deepseek-ai/dsh-skill": "^0.2.1-alpha.1",
71
- "@deepseek-ai/dsh-client-ui-chat": "^0.2.1-alpha.1",
72
- "@deepseek-ai/dsh-client-ui-conversation": "^0.2.1-alpha.1",
73
- "@deepseek-ai/dsh-client-ui-renderer": "^0.2.1-alpha.1",
74
- "@deepseek-ai/dsh-typert-protocol": "^0.2.1-alpha.1",
75
- "@deepseek-ai/dsh-typert-registry": "^0.2.1-alpha.1",
76
- "@deepseek-ai/dsh-api-gateway": "^0.2.1-alpha.1",
77
- "@deepseek-ai/dsh-session-query": "^0.2.1-alpha.1",
78
- "@deepseek-ai/dsh-client-ui-primitives": "^0.2.1-alpha.1"
62
+ "@deepseek-ai/cordis": "^4.0.4 || ^4.0.5-alpha.1",
63
+ "@deepseek-ai/dsh-agent": "^0.2.0-rc.2 || ^0.2.1-alpha.1",
64
+ "@deepseek-ai/dsh-llm": "^0.2.0-rc.2 || ^0.2.1-alpha.1",
65
+ "@deepseek-ai/dsh-tools": "^0.2.0-rc.2 || ^0.2.1-alpha.1",
66
+ "@deepseek-ai/dsh-subagent": "^0.2.0-rc.2 || ^0.2.1-alpha.1",
67
+ "@deepseek-ai/dsh-session": "^0.2.0-rc.2 || ^0.2.1-alpha.1",
68
+ "@deepseek-ai/dsh-compaction": "^0.2.0-rc.2 || ^0.2.1-alpha.1",
69
+ "@deepseek-ai/dsh-commands": "^0.2.0-rc.2 || ^0.2.1-alpha.1",
70
+ "@deepseek-ai/dsh-skill": "^0.2.0-rc.2 || ^0.2.1-alpha.1",
71
+ "@deepseek-ai/dsh-client-ui-chat": "^0.2.0-rc.2 || ^0.2.1-alpha.1",
72
+ "@deepseek-ai/dsh-client-ui-conversation": "^0.2.0-rc.2 || ^0.2.1-alpha.1",
73
+ "@deepseek-ai/dsh-client-ui-renderer": "^0.2.0-rc.2 || ^0.2.1-alpha.1",
74
+ "@deepseek-ai/dsh-typert-protocol": "^0.2.0-rc.2 || ^0.2.1-alpha.1",
75
+ "@deepseek-ai/dsh-typert-registry": "^0.2.0-rc.2 || ^0.2.1-alpha.1",
76
+ "@deepseek-ai/dsh-api-gateway": "^0.2.0-rc.2 || ^0.2.1-alpha.1",
77
+ "@deepseek-ai/dsh-session-query": "^0.2.0-rc.2 || ^0.2.1-alpha.1",
78
+ "@deepseek-ai/dsh-client-ui-primitives": "^0.2.0-rc.2 || ^0.2.1-alpha.1"
79
79
  },
80
80
  "devDependencies": {
81
81
  "@types/js-yaml": "^4.0.9",
@@ -83,30 +83,83 @@
83
83
  "esbuild": "^0.28.2",
84
84
  "@types/react": "^18.3.1",
85
85
  "react": "^18.3.1",
86
- "@deepseek-ai/cordis": "4.0.5-alpha.1",
87
- "@deepseek-ai/dsh-agent": "0.2.1-alpha.1",
88
- "@deepseek-ai/dsh-llm": "0.2.1-alpha.1",
89
- "@deepseek-ai/dsh-tools": "0.2.1-alpha.1",
90
- "@deepseek-ai/dsh-subagent": "0.2.1-alpha.1",
91
- "@deepseek-ai/dsh-session": "0.2.1-alpha.1",
92
- "@deepseek-ai/dsh-compaction": "0.2.1-alpha.1",
93
- "@deepseek-ai/dsh-commands": "0.2.1-alpha.1",
94
- "@deepseek-ai/dsh-skill": "0.2.1-alpha.1",
95
- "@deepseek-ai/dsh-client-ui-chat": "0.2.1-alpha.1",
96
- "@deepseek-ai/dsh-client-ui-conversation": "0.2.1-alpha.1",
97
- "@deepseek-ai/dsh-client-ui-renderer": "0.2.1-alpha.1",
98
- "@deepseek-ai/dsh-typert-protocol": "0.2.1-alpha.1",
99
- "@deepseek-ai/dsh-typert-registry": "0.2.1-alpha.1",
100
- "@deepseek-ai/dsh-api-gateway": "0.2.1-alpha.1",
101
- "@deepseek-ai/dsh-session-query": "0.2.1-alpha.1",
102
- "@deepseek-ai/dsh-client-ui-primitives": "0.2.1-alpha.1",
86
+ "@deepseek-ai/cordis": "4.0.4",
87
+ "@deepseek-ai/dsh-agent": "0.2.0-rc.2",
88
+ "@deepseek-ai/dsh-llm": "0.2.0-rc.2",
89
+ "@deepseek-ai/dsh-tools": "0.2.0-rc.2",
90
+ "@deepseek-ai/dsh-subagent": "0.2.0-rc.2",
91
+ "@deepseek-ai/dsh-session": "0.2.0-rc.2",
92
+ "@deepseek-ai/dsh-compaction": "0.2.0-rc.2",
93
+ "@deepseek-ai/dsh-commands": "0.2.0-rc.2",
94
+ "@deepseek-ai/dsh-skill": "0.2.0-rc.2",
95
+ "@deepseek-ai/dsh-client-ui-chat": "0.2.0-rc.2",
96
+ "@deepseek-ai/dsh-client-ui-conversation": "0.2.0-rc.2",
97
+ "@deepseek-ai/dsh-client-ui-renderer": "0.2.0-rc.2",
98
+ "@deepseek-ai/dsh-typert-protocol": "0.2.0-rc.2",
99
+ "@deepseek-ai/dsh-typert-registry": "0.2.0-rc.2",
100
+ "@deepseek-ai/dsh-api-gateway": "0.2.0-rc.2",
101
+ "@deepseek-ai/dsh-session-query": "0.2.0-rc.2",
102
+ "@deepseek-ai/dsh-client-ui-primitives": "0.2.0-rc.2",
103
103
  "typescript": "^5.9.3",
104
- "@deepseek-ai/dsh": "0.2.1-alpha.1"
104
+ "@deepseek-ai/dsh": "0.2.0-rc.2"
105
105
  },
106
106
  "scripts": {
107
107
  "build": "tsc -p tsconfig.json && node scripts/build-client.mjs",
108
108
  "typecheck": "tsc --noEmit -p tsconfig.json",
109
109
  "verify": "node scripts/verify-all.mjs",
110
110
  "prepublishOnly": "npm run build && npm run typecheck && npm run verify"
111
+ },
112
+ "peerDependenciesMeta": {
113
+ "@deepseek-ai/cordis": {
114
+ "optional": true
115
+ },
116
+ "@deepseek-ai/dsh-agent": {
117
+ "optional": true
118
+ },
119
+ "@deepseek-ai/dsh-llm": {
120
+ "optional": true
121
+ },
122
+ "@deepseek-ai/dsh-tools": {
123
+ "optional": true
124
+ },
125
+ "@deepseek-ai/dsh-subagent": {
126
+ "optional": true
127
+ },
128
+ "@deepseek-ai/dsh-session": {
129
+ "optional": true
130
+ },
131
+ "@deepseek-ai/dsh-compaction": {
132
+ "optional": true
133
+ },
134
+ "@deepseek-ai/dsh-commands": {
135
+ "optional": true
136
+ },
137
+ "@deepseek-ai/dsh-skill": {
138
+ "optional": true
139
+ },
140
+ "@deepseek-ai/dsh-client-ui-chat": {
141
+ "optional": true
142
+ },
143
+ "@deepseek-ai/dsh-client-ui-conversation": {
144
+ "optional": true
145
+ },
146
+ "@deepseek-ai/dsh-client-ui-renderer": {
147
+ "optional": true
148
+ },
149
+ "@deepseek-ai/dsh-typert-protocol": {
150
+ "optional": true
151
+ },
152
+ "@deepseek-ai/dsh-typert-registry": {
153
+ "optional": true
154
+ },
155
+ "@deepseek-ai/dsh-api-gateway": {
156
+ "optional": true
157
+ },
158
+ "@deepseek-ai/dsh-session-query": {
159
+ "optional": true
160
+ },
161
+ "@deepseek-ai/dsh-client-ui-primitives": {
162
+ "optional": true
163
+ }
111
164
  }
112
165
  }
@@ -1,4 +1,4 @@
1
- description: 单步对抗验证循环:实现与验证在同一环节内迭代,直到通过
1
+ description: 单步对抗验证循环:需求与边界、实际可用性、回归影响三个视角全部通过才结束
2
2
 
3
3
  # 验证者模型可选("provider/model" 或 {providerID, modelID});不填沿用发起会话当前模型。
4
4
  # 验证超时不在 ralphflow 里设置:委派生命周期跟随宿主 dsh 的原生能力
@@ -20,7 +20,8 @@ steps:
20
20
  # 标了会在启动回执里如实说明,绝不假装做过。
21
21
  reset: true
22
22
  do: |
23
- 把任务做到位:它的每一条要求都成立。
23
+ 按用户要求完成任务,控制修改范围,避免引入无关改动。
24
+ 交卷前自行核验完成情况;没有验证依据的事项如实标为未验证,不把计划当作完成。
24
25
 
25
26
  每轮交卷前,把本轮摘要**追加**到 summary.md(一轮一节,保持精简):
26
27
  - 完成事项(逐条对照任务要求)
@@ -34,13 +35,11 @@ steps:
34
35
  # 「产出目录」一节决定,不列进这里 —— 否则与紧邻的「产出目录」打架,诱导模型两边都写。
35
36
  output: 实现的代码/文件
36
37
  check_voting:
37
- # 前三条逐字照抄 opencode 版 loop.yaml 的三票(各自只查一条)
38
- - check: 用户任务的每一条要求都已落实
39
- - check: 实现的行为符合预期,真实可用
40
- - check: 没有遗漏的需求,边界情况已覆盖
41
- # 第 4 票是本仓库自己的口径(opencode 版没有这一票)。
42
- # 只写判断、不写取证动作:内置工作流要对任意项目通用,不能假定项目有测试套件或 git 基线。
43
- - check: 修改不影响原有功能,不破坏需求以外的边界
38
+ # 三个互补视角:需求与边界、实际可用性、回归影响;减少重复取证。
39
+ # 检查依据只写判定目标,不假定项目有测试套件或 git 基线。
40
+ - check: 用户任务的每一条要求都已落实,没有遗漏,相关边界与异常情况已覆盖
41
+ - check: 实现的行为和实际产出符合预期、真实可用,有可复核的验证依据
42
+ - check: 修改不影响原有功能和既有约定,不引入需求以外的副作用
44
43
  on_pass: done
45
44
  on_fail: loop
46
45
  max_fail_count: 100