dsh-project-flow 0.9.0 → 0.9.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 (46) hide show
  1. package/CHANGELOG.md +0 -0
  2. package/README.md +58 -11
  3. package/cordis.patch.yml +30 -11
  4. package/docs/DETAIL.md +6 -6
  5. package/docs/FEATURES.md +12 -5
  6. package/docs/LAUNCH.md +3 -3
  7. package/docs/MOMENTS.md +4 -4
  8. package/docs/USAGE.md +2 -2
  9. package/domains.mjs +1 -1
  10. package/evidence.mjs +19 -3
  11. package/flow.schema.mjs +192 -35
  12. package/gate.mjs +49 -23
  13. package/index.js +639 -120
  14. package/locale/en.json +15 -4
  15. package/locale/zh.json +17 -6
  16. package/package.json +5 -3
  17. package/tests/_heartbeat-regression.test.mjs +124 -0
  18. package/tests/aesthetic.test.mjs +534 -0
  19. package/tests/assertions-e2e.mjs +234 -0
  20. package/tests/bench-check.mjs +32 -0
  21. package/tests/client-bundle.test.mjs +707 -0
  22. package/tests/contract.test.mjs +137 -0
  23. package/tests/desktop.test.mjs +130 -0
  24. package/tests/domains.test.mjs +220 -0
  25. package/tests/e2e.mjs +300 -0
  26. package/tests/evidence.test.mjs +408 -0
  27. package/tests/extra-phase.test.mjs +133 -0
  28. package/tests/feedback.test.mjs +187 -0
  29. package/tests/flow-create.test.mjs +168 -0
  30. package/tests/flow-gate.test.mjs +232 -0
  31. package/tests/flow-schema.test.mjs +213 -0
  32. package/tests/gate.test.mjs +246 -0
  33. package/tests/issue-loop.test.mjs +254 -0
  34. package/tests/issues-e2e.mjs +246 -0
  35. package/tests/panel-independence.test.mjs +78 -0
  36. package/tests/panel-report.test.mjs +129 -0
  37. package/tests/patch-ledger.test.mjs +280 -0
  38. package/tests/paths.mjs +100 -0
  39. package/tests/preview-path.test.mjs +69 -0
  40. package/tests/qa-assertions.test.mjs +352 -0
  41. package/tests/run-all.mjs +90 -0
  42. package/tests/stage-model.test.mjs +120 -0
  43. package/tests/stop-resume.test.mjs +260 -0
  44. package/tests/watch-root.test.mjs +167 -0
  45. package/tests/watchdog-tokens.test.mjs +53 -0
  46. package/tests/watchdog.test.mjs +305 -0
package/locale/en.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "Project flow",
4
- "description": "Five-stage gated delivery: confirm intent, plan, build, self-check, then report against the original requirements. Stages 2-4 run in isolated child agents and exchange tickets, so a long job no longer overruns one conversation. Self-healing (per-stage retries, stage deadlines, resume after a crash) and rollback (a snapshot before and after every build attempt, restored wholesale or limited to the files that attempt touched). By Liu Shi.",
4
+ "description": "Four-stage gated delivery: confirm intent, plan, build, check. Plan, build and QA each run in an isolated child agent and exchange tickets instead of transcripts, so a long job no longer overruns one conversation. Self-healing (per-stage retries, stage deadlines, resume after a crash) and rollback (a snapshot before and after every build attempt, restored wholesale or limited to the files that attempt touched). By Liu Shi.",
5
5
  "detail": "docs/DETAIL.md"
6
6
  },
7
7
  "tool": {
@@ -11,14 +11,25 @@
11
11
  "snapshots": "List snapshots and the files each build attempt touched",
12
12
  "rollback": "Roll the workspace back to a snapshot, wholesale or per file",
13
13
  "status": "Read one project's current stage",
14
- "models": "Read the per-stage models plus self-healing and snapshot limits"
14
+ "models": "Read the per-stage models plus self-healing and snapshot limits",
15
+ "context": "Read the blindspot conclusions this directory confirmed last time",
16
+ "estimate": "Estimate what this project will cost before running it",
17
+ "setModel": "Change the model of one stage; takes effect immediately",
18
+ "cost": "Read this project's cost broken down by model"
15
19
  },
16
20
  "command": {
17
- "flow": "Start work mode and run the task through the five stages",
21
+ "flow": "Start work mode and run the task through the four stages",
18
22
  "status": "Show the current project's stage",
19
23
  "models": "Show the per-stage models",
20
24
  "resume": "Continue an interrupted project",
21
25
  "doctor": "Check the workspace, optionally repair it",
22
- "snapshots": "List a project's rollback targets"
26
+ "snapshots": "List a project's rollback targets",
27
+ "continue": "Resume from the last checkpoint",
28
+ "stop": "Stop and save progress",
29
+ "cost": "Show this project's cost broken down by model",
30
+ "diag": "Diagnose workspace configuration and state",
31
+ "domain": "Set or show which domain's conventions this run follows",
32
+ "patterns": "List the layout patterns collected in the library",
33
+ "prices": "Show the price table and exchange rate"
23
34
  }
24
35
  }
package/locale/zh.json CHANGED
@@ -1,24 +1,35 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "项目流程",
4
- "description": "五段接力交付:问意图、规划、实施、自检、验收。中间三段各开独立子会话,只传任务书不传过程,长任务不再堆爆一条对话。自带自愈(单段重试、超时切断、崩溃续跑)与回滚(每次实施前后自动快照,支持整棵恢复或只还原那一次动过的文件)。作者刘适。",
4
+ "description": "四阶接力交付:问意图、规划、实施、质检。规划、实施、质检各开独立子会话,只传任务书不传过程,长任务不再堆爆一条对话。自带自愈(单段重试、超时切断、崩溃续跑)与回滚(每次实施前后自动快照,支持整棵恢复或只还原那一次动过的文件)。作者刘适。",
5
5
  "detail": "docs/DETAIL.md"
6
6
  },
7
7
  "tool": {
8
- "run": "跑一个项目的五段流水",
8
+ "run": "跑一个项目的四阶流水",
9
9
  "resume": "接续被中断的项目,从中断那段接着跑",
10
10
  "doctor": "体检遗留锁、损坏状态与悬空阶段",
11
11
  "snapshots": "列出全部快照与每次实施动了哪些文件",
12
12
  "rollback": "回滚工作区到某个快照,可整棵恢复或只还原指定文件",
13
13
  "status": "看一个项目现在在哪一段",
14
- "models": "看五段各用什么模型和自愈、快照参数"
14
+ "models": "看四阶各用什么模型和自愈、快照参数",
15
+ "context": "取这个目录上次确认过的五个盲区结论,开新任务前先看",
16
+ "estimate": "估算这个项目跑完要花多少钱",
17
+ "setModel": "改某一阶用的模型,立即生效",
18
+ "cost": "看这个项目按模型分账的花费"
15
19
  },
16
20
  "command": {
17
- "flow": "开工作模式,把当前任务按五段跑",
21
+ "flow": "开工作模式,把当前任务按四阶跑",
18
22
  "status": "看当前项目跑到第几段",
19
- "models": "看五段各用什么模型",
23
+ "models": "看四阶各用什么模型",
20
24
  "resume": "接续被中断的项目",
21
25
  "doctor": "体检工作区,可顺手修",
22
- "snapshots": "看一个项目有哪些快照可以回滚"
26
+ "snapshots": "看一个项目有哪些快照可以回滚",
27
+ "continue": "从断点接着跑",
28
+ "stop": "停下来,进度存盘",
29
+ "cost": "看这个项目按模型分账的花费",
30
+ "diag": "诊断工作区配置与状态",
31
+ "domain": "设定或查看这次按哪个行当的做法跑",
32
+ "patterns": "看版式库里攒了哪些骨架",
33
+ "prices": "看价目表与汇率"
23
34
  }
24
35
  }
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "dsh-project-flow",
3
- "version": "0.9.0",
3
+ "version": "0.9.2",
4
4
  "private": false,
5
- "description": "Four-stage project workflow: requirement, plan, build, QA, with an intent gate, a rework loop, self-healing recovery, a watchdog that stops runaway runs, snapshot rollback, a single status light, and a machine-readable Completion_Evidence.json.",
5
+ "description": "Four-stage project workflow: requirement, plan, build, QA, with an intent gate, a rework loop, self-healing recovery, a watchdog that stops runaway runs, snapshot rollback with a retention cap, a single status light, and a machine-readable Completion_Evidence.json.",
6
6
  "type": "module",
7
7
  "main": "index.js",
8
8
  "author": {
@@ -46,6 +46,7 @@
46
46
  },
47
47
  "files": [
48
48
  "bench/",
49
+ "tests/*.mjs",
49
50
  "index.js",
50
51
  "client.js",
51
52
  "gate.mjs",
@@ -90,6 +91,7 @@
90
91
  }
91
92
  },
92
93
  "scripts": {
93
- "bench": "node bench/run.mjs"
94
+ "bench": "node bench/run.mjs",
95
+ "test": "node tests/run-all.mjs"
94
96
  }
95
97
  }
@@ -0,0 +1,124 @@
1
+ /**
2
+ * 回归测试:静默挂死的误判。
3
+ *
4
+ * 现场:2026-12-03 两次 project_run 都被 FAULT_SILENT_HANG 掐掉,而子会话日志显示
5
+ * 它一直在干活(实施 114 步 / 260k token;渲染图 v7→v27 连续在写)。
6
+ * 根因是心率只在「每阶结束」打一次,单阶跑过静默窗口就被判死。
7
+ *
8
+ * 这个测试锁两件事:
9
+ * 1) 没有干活信号时,超窗口仍然要判死(熔断本身不能被修没了)
10
+ * 2) 持续有干活信号时,绝不能判死(本次修复的核心)
11
+ */
12
+
13
+ import { test } from 'node:test'
14
+ import { sibling } from './paths.mjs'
15
+ import { pathToFileURL } from 'node:url'
16
+ import assert from 'node:assert/strict'
17
+ import { mkdtemp, rm } from 'node:fs/promises'
18
+ import { tmpdir } from 'node:os'
19
+ import { join } from 'node:path'
20
+
21
+ const { LivenessProbe, Watchdog, FAULT } = await import(pathToFileURL(sibling('watchdog.mjs')).href + `?t=${Date.now()}`)
22
+
23
+ const sleep = ms => new Promise(resolve => setTimeout(resolve, ms))
24
+
25
+ test('没有任何活动信号时,超窗口照样判静默挂死', async () => {
26
+ const cwd = await mkdtemp(join(tmpdir(), 'flow-silent-'))
27
+ let fired
28
+ const probe = new LivenessProbe({
29
+ cwd,
30
+ windowMs: 400,
31
+ onSilent: seconds => { fired = seconds },
32
+ })
33
+ try {
34
+ // 窗口 400ms,等下 1200ms,中间既无写文件也无 touch
35
+ await sleep(1200)
36
+ assert.notEqual(fired, undefined, '一直没动静必须判死,不然熔断就废了')
37
+ } finally {
38
+ probe.dispose()
39
+ await rm(cwd, { recursive: true, force: true })
40
+ }
41
+ })
42
+
43
+ test('持续 touch 时绝不判死——这正是本次修的洞', async () => {
44
+ const cwd = await mkdtemp(join(tmpdir(), 'flow-alive-'))
45
+ let fired
46
+ const probe = new LivenessProbe({
47
+ cwd,
48
+ windowMs: 400,
49
+ onSilent: seconds => { fired = seconds },
50
+ })
51
+ try {
52
+ // 总时长 1600ms,是窗口的 4 倍;每 100ms 顶一次心跳,模拟子会话一直吐 token
53
+ for (let i = 0; i < 16; i += 1) {
54
+ probe.touch()
55
+ await sleep(100)
56
+ }
57
+ assert.equal(fired, undefined, `一直在干活却被判死(${fired}s 静默),修复没生效`)
58
+ } finally {
59
+ probe.dispose()
60
+ await rm(cwd, { recursive: true, force: true })
61
+ }
62
+ })
63
+
64
+ test('touch 停止后仍然会判死——不会因为 touch 过就永久免疫', async () => {
65
+ const cwd = await mkdtemp(join(tmpdir(), 'flow-stall-'))
66
+ let fired
67
+ const probe = new LivenessProbe({
68
+ cwd,
69
+ windowMs: 400,
70
+ onSilent: seconds => { fired = seconds },
71
+ })
72
+ try {
73
+ probe.touch()
74
+ await sleep(1200)
75
+ assert.notEqual(fired, undefined, 'touch 之后真的停住了,必须能判死')
76
+ } finally {
77
+ probe.dispose()
78
+ await rm(cwd, { recursive: true, force: true })
79
+ }
80
+ })
81
+
82
+ test('Watchdog.touch() 在熔断之后不再洗白状态', async () => {
83
+ const cwd = await mkdtemp(join(tmpdir(), 'flow-trip-'))
84
+ const dog = new Watchdog({
85
+ cwd,
86
+ logPath: join(cwd, 'run.log'),
87
+ settings: { silentMsBuild: 300, budgetUsd: 10 },
88
+ })
89
+ try {
90
+ dog.beginStage(3, 'deepseek-v4.1-flash')
91
+ // beginStage 会把窗口重置回内置默认(900s),测试里得在它之后再压低。
92
+ dog.setWindows({ build: 300 })
93
+ await sleep(1000)
94
+ assert.equal(dog.fault?.code, FAULT.SILENT, '该判死的要判死')
95
+ // 熔断后再 touch:不能把 fault 抹掉
96
+ dog.touch()
97
+ assert.equal(dog.fault?.code, FAULT.SILENT, '熔断已成立,touch 不该洗白')
98
+ } finally {
99
+ dog.dispose()
100
+ await rm(cwd, { recursive: true, force: true })
101
+ }
102
+ })
103
+
104
+ test('Watchdog.touch() 让长阶不被误杀', async () => {
105
+ const cwd = await mkdtemp(join(tmpdir(), 'flow-long-'))
106
+ const dog = new Watchdog({
107
+ cwd,
108
+ logPath: join(cwd, 'run.log'),
109
+ settings: { silentMsBuild: 300, budgetUsd: 10 },
110
+ })
111
+ try {
112
+ dog.beginStage(3, 'deepseek-v4.1-flash')
113
+ dog.setWindows({ build: 300 })
114
+ // 跑满期窗口的 4 倍时长,但期间一直 touch
115
+ for (let i = 0; i < 24; i += 1) {
116
+ dog.touch()
117
+ await sleep(50)
118
+ }
119
+ assert.equal(dog.fault, undefined, '一直在出活却熔断了,修复没生效')
120
+ } finally {
121
+ dog.dispose()
122
+ await rm(cwd, { recursive: true, force: true })
123
+ }
124
+ })