dsh-project-flow 0.0.0-stage → 0.8.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/CHANGELOG.md +189 -0
- package/LICENSE +128 -0
- package/README.md +422 -2
- package/aesthetic-library.mjs +288 -0
- package/aesthetic-seeds.mjs +373 -0
- package/aesthetic.mjs +273 -0
- package/assets/icon-180.png +0 -0
- package/assets/icon-256.png +0 -0
- package/assets/icon-512.png +0 -0
- package/client.js +1079 -0
- package/cordis.patch.yml +48 -0
- package/desktop.mjs +100 -0
- package/docs/COMMERCIAL.md +79 -0
- package/docs/DETAIL.md +279 -0
- package/docs/FEATURES.md +345 -0
- package/docs/LAUNCH.md +148 -0
- package/docs/MOMENTS.md +118 -0
- package/docs/RELEASE-0.3.0.md +52 -0
- package/docs/USAGE.md +232 -0
- package/domains.mjs +306 -0
- package/evidence.mjs +504 -0
- package/gate.mjs +389 -0
- package/icon.svg +12 -0
- package/index.js +5863 -0
- package/locale/en.json +24 -0
- package/locale/zh.json +24 -0
- package/package.json +85 -3
- package/prices.mjs +215 -0
- package/watchdog.mjs +583 -0
package/locale/en.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"meta": {
|
|
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.",
|
|
5
|
+
"detail": "docs/DETAIL.md"
|
|
6
|
+
},
|
|
7
|
+
"tool": {
|
|
8
|
+
"run": "Run the gated pipeline for one project",
|
|
9
|
+
"resume": "Continue an interrupted project from where it stopped",
|
|
10
|
+
"doctor": "Check stale locks, broken state and dangling stages",
|
|
11
|
+
"snapshots": "List snapshots and the files each build attempt touched",
|
|
12
|
+
"rollback": "Roll the workspace back to a snapshot, wholesale or per file",
|
|
13
|
+
"status": "Read one project's current stage",
|
|
14
|
+
"models": "Read the per-stage models plus self-healing and snapshot limits"
|
|
15
|
+
},
|
|
16
|
+
"command": {
|
|
17
|
+
"flow": "Start work mode and run the task through the five stages",
|
|
18
|
+
"status": "Show the current project's stage",
|
|
19
|
+
"models": "Show the per-stage models",
|
|
20
|
+
"resume": "Continue an interrupted project",
|
|
21
|
+
"doctor": "Check the workspace, optionally repair it",
|
|
22
|
+
"snapshots": "List a project's rollback targets"
|
|
23
|
+
}
|
|
24
|
+
}
|
package/locale/zh.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"meta": {
|
|
3
|
+
"title": "项目流程",
|
|
4
|
+
"description": "五段接力交付:问意图、规划、实施、自检、验收。中间三段各开独立子会话,只传任务书不传过程,长任务不再堆爆一条对话。自带自愈(单段重试、超时切断、崩溃续跑)与回滚(每次实施前后自动快照,支持整棵恢复或只还原那一次动过的文件)。作者刘适。",
|
|
5
|
+
"detail": "docs/DETAIL.md"
|
|
6
|
+
},
|
|
7
|
+
"tool": {
|
|
8
|
+
"run": "跑一个项目的五段流水",
|
|
9
|
+
"resume": "接续被中断的项目,从中断那段接着跑",
|
|
10
|
+
"doctor": "体检遗留锁、损坏状态与悬空阶段",
|
|
11
|
+
"snapshots": "列出全部快照与每次实施动了哪些文件",
|
|
12
|
+
"rollback": "回滚工作区到某个快照,可整棵恢复或只还原指定文件",
|
|
13
|
+
"status": "看一个项目现在在哪一段",
|
|
14
|
+
"models": "看五段各用什么模型和自愈、快照参数"
|
|
15
|
+
},
|
|
16
|
+
"command": {
|
|
17
|
+
"flow": "开工作模式,把当前任务按五段跑",
|
|
18
|
+
"status": "看当前项目跑到第几段",
|
|
19
|
+
"models": "看五段各用什么模型",
|
|
20
|
+
"resume": "接续被中断的项目",
|
|
21
|
+
"doctor": "体检工作区,可顺手修",
|
|
22
|
+
"snapshots": "看一个项目有哪些快照可以回滚"
|
|
23
|
+
}
|
|
24
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,88 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-project-flow",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
3
|
+
"version": "0.8.0",
|
|
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.",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "index.js",
|
|
8
|
+
"author": {
|
|
9
|
+
"name": "刘适",
|
|
10
|
+
"url": "https://github.com/LiuShi611"
|
|
11
|
+
},
|
|
12
|
+
"license": "PolyForm-Small-Business-1.0.0",
|
|
13
|
+
"copyright": "Copyright © 2026 刘适",
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@deepseek-ai/schemastery": "^3.19.0"
|
|
16
|
+
},
|
|
17
|
+
"homepage": "https://github.com/LiuShi611/dsh-project-flow",
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/LiuShi611/dsh-project-flow.git"
|
|
21
|
+
},
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/LiuShi611/dsh-project-flow/issues"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"deepseek",
|
|
27
|
+
"harness",
|
|
28
|
+
"dsh",
|
|
29
|
+
"dsh-plugin",
|
|
30
|
+
"workflow",
|
|
31
|
+
"agent",
|
|
32
|
+
"four-stage",
|
|
33
|
+
"completion-evidence"
|
|
34
|
+
],
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": ">=20.0.0"
|
|
37
|
+
},
|
|
38
|
+
"exports": {
|
|
39
|
+
".": "./index.js",
|
|
40
|
+
"./client": {
|
|
41
|
+
"default": "./client.js"
|
|
42
|
+
},
|
|
43
|
+
"./locale/*.json": "./locale/*.json",
|
|
44
|
+
"./icon": "./icon.svg",
|
|
45
|
+
"./package.json": "./package.json"
|
|
46
|
+
},
|
|
47
|
+
"files": [
|
|
48
|
+
"index.js",
|
|
49
|
+
"client.js",
|
|
50
|
+
"gate.mjs",
|
|
51
|
+
"watchdog.mjs",
|
|
52
|
+
"prices.mjs",
|
|
53
|
+
"evidence.mjs",
|
|
54
|
+
"aesthetic.mjs",
|
|
55
|
+
"aesthetic-library.mjs",
|
|
56
|
+
"aesthetic-seeds.mjs",
|
|
57
|
+
"domains.mjs",
|
|
58
|
+
"desktop.mjs",
|
|
59
|
+
"cordis.patch.yml",
|
|
60
|
+
"locale/*.json",
|
|
61
|
+
"docs/*.md",
|
|
62
|
+
"icon.svg",
|
|
63
|
+
"assets/*.png",
|
|
64
|
+
"README.md",
|
|
65
|
+
"CHANGELOG.md",
|
|
66
|
+
"LICENSE"
|
|
67
|
+
],
|
|
68
|
+
"dsh": {
|
|
69
|
+
"bundle": {
|
|
70
|
+
"patch": "./cordis.patch.yml"
|
|
71
|
+
},
|
|
72
|
+
"client": {
|
|
73
|
+
"platform": "web",
|
|
74
|
+
"inject": [
|
|
75
|
+
"@deepseek-ai/dsh-client-ui-conversation"
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
"peerDependencies": {
|
|
80
|
+
"@deepseek-ai/schemastery": "*",
|
|
81
|
+
"@deepseek-ai/dsh-client-ui-conversation": "*"
|
|
82
|
+
},
|
|
83
|
+
"peerDependenciesMeta": {
|
|
84
|
+
"@deepseek-ai/dsh-client-ui-conversation": {
|
|
85
|
+
"optional": true
|
|
86
|
+
}
|
|
87
|
+
}
|
|
6
88
|
}
|
package/prices.mjs
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 模型费率:让「选哪个模型」这件事不再被价目表限制。
|
|
3
|
+
*
|
|
4
|
+
* 背景:以前只内置了三个模型的价(deepseek-v4.1-flash / hy4flash /
|
|
5
|
+
* kimi-k3.1-pro)。换任何一个别的模型,查不到价就退回「最贵兜底」,
|
|
6
|
+
* 于是预估和实际都虚高,等于换模型就没法估预算。
|
|
7
|
+
*
|
|
8
|
+
* 现在的规则:
|
|
9
|
+
* 1. 用户在配置里写死的最优先(confidence=exact);
|
|
10
|
+
* 2. 内置已知价次之(confidence=builtin);
|
|
11
|
+
* 3. 认不出型号但能认出「族」(flash / pro / max / glm / kimi / qwen …)
|
|
12
|
+
* 就按该族的典型价估(confidence=family)——有数总比没数强;
|
|
13
|
+
* 4. 连族都认不出才用最贵兜底(confidence=fallback)。
|
|
14
|
+
*
|
|
15
|
+
* 每一档都带 confidence,界面上必须如实标出来:估的就是估的。
|
|
16
|
+
* family 和 fallback 的数字是**启发式**,不是厂商报价;
|
|
17
|
+
* 要精确就写进配置的 priceTable,或者用 /flow-set 价格 覆盖。
|
|
18
|
+
*
|
|
19
|
+
* 单位:美元 / 百万 token。
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/** 内置已知价。这三个是插件原本就带的,属于「作者确认过」的那档。 */
|
|
23
|
+
export const BUILTIN_PRICE = {
|
|
24
|
+
'deepseek-v4.1-flash': { input: 0.14, output: 0.28 },
|
|
25
|
+
'hy4flash': { input: 0.20, output: 0.80 },
|
|
26
|
+
'kimi-k3.1-pro': { input: 0.60, output: 2.40 },
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 按型号族估的典型价。
|
|
31
|
+
*
|
|
32
|
+
* 顺序有意义:先匹配到的赢。所以窄规则(glm-5.3-flash)要排在
|
|
33
|
+
* 宽规则(glm)前面,否则 flash 会被当成整族的价。
|
|
34
|
+
*
|
|
35
|
+
* 这些数字是启发式,用来「给个量级」,不是报价。为什么仍然要给:
|
|
36
|
+
* 用户的诉求是换模型也能估预算。给一个标注为「估算」的数,
|
|
37
|
+
* 比直接拿最贵兜底(能差十倍)有用得多。
|
|
38
|
+
*/
|
|
39
|
+
export const FAMILY_RULES = [
|
|
40
|
+
// 免费档:显式 0
|
|
41
|
+
{ match: /-free$/iu, price: { input: 0, output: 0 }, label: '免费档' },
|
|
42
|
+
|
|
43
|
+
// flash 级:各家最便宜的一档
|
|
44
|
+
{ match: /flash/iu, price: { input: 0.14, output: 0.28 }, label: 'flash 级' },
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* max / prime / ultra 级:最贵那一档。
|
|
48
|
+
*
|
|
49
|
+
* 必须卡词边界,不能只写 /max/——「MiniMax-M2.5」里的 Max 会被吞进来,
|
|
50
|
+
* 把一个中档模型估成 2/8(贵八倍)。只认「-max」「max-」「开头就是 max」这几种。
|
|
51
|
+
*/
|
|
52
|
+
{ match: /(?:^|[-_])max(?:$|[-_\d])/iu, price: { input: 2.00, output: 8.00 }, label: 'max 级' },
|
|
53
|
+
{ match: /(?:^|[-_])(?:prime|ultra)(?:$|[-_\d])/iu, price: { input: 2.00, output: 8.00 }, label: '顶配级' },
|
|
54
|
+
|
|
55
|
+
/** pro / plus / std 级:中间档。同样卡边界,「preview」不许被当成 pro。 */
|
|
56
|
+
{ match: /(?:^|[-_])(?:pro|plus|std)(?:$|[-_\d])/iu, price: { input: 0.51, output: 1.02 }, label: 'pro 级' },
|
|
57
|
+
|
|
58
|
+
// 厂商族
|
|
59
|
+
{ match: /^space-bunny/iu, price: { input: 0.08, output: 0.32 }, label: 'Space-Bunny' },
|
|
60
|
+
{ match: /^minimax/iu, price: { input: 0.30, output: 1.20 }, label: 'MiniMax 族' },
|
|
61
|
+
{ match: /^glm/iu, price: { input: 0.69, output: 2.76 }, label: 'GLM 族' },
|
|
62
|
+
{ match: /^kimi/iu, price: { input: 0.60, output: 2.40 }, label: 'Kimi 族' },
|
|
63
|
+
{ match: /^qwen/iu, price: { input: 0.40, output: 1.60 }, label: 'Qwen 族' },
|
|
64
|
+
{ match: /^step/iu, price: { input: 0.33, output: 1.32 }, label: 'Step 族' },
|
|
65
|
+
{ match: /^mimo/iu, price: { input: 0.13, output: 0.52 }, label: 'MiMo 族' },
|
|
66
|
+
{ match: /^hy4/iu, price: { input: 0.20, output: 0.80 }, label: 'Hy4 族' },
|
|
67
|
+
{ match: /^deepseek/iu, price: { input: 0.28, output: 1.12 }, label: 'DeepSeek 族' },
|
|
68
|
+
]
|
|
69
|
+
|
|
70
|
+
/** 连族都认不出时的兜底:按最贵估,宁可估高。 */
|
|
71
|
+
export const FALLBACK_PRICE = { input: 0.60, output: 2.40 }
|
|
72
|
+
|
|
73
|
+
/** 合法 USD/百万 token 价。 */
|
|
74
|
+
function sane(input, output) {
|
|
75
|
+
const i = Number(input)
|
|
76
|
+
const o = Number(output)
|
|
77
|
+
if (!Number.isFinite(i) || !Number.isFinite(o)) return undefined
|
|
78
|
+
if (i < 0 || o < 0) return undefined
|
|
79
|
+
return { input: i, output: o }
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* 把配置里的 priceTable 解析成「模型 → 价」。
|
|
84
|
+
*
|
|
85
|
+
* 配置里写的键原样进表(用户说了算)。支持两种写法:
|
|
86
|
+
* { "glm-5.3": { "input": 0.69, "output": 2.76 } }
|
|
87
|
+
* { "glm-5.3": [0.69, 2.76] }
|
|
88
|
+
*
|
|
89
|
+
* @param {string|object|undefined} raw
|
|
90
|
+
* @returns {Record<string, {input:number, output:number}>}
|
|
91
|
+
*/
|
|
92
|
+
export function parseOverrideTable(raw) {
|
|
93
|
+
const out = {}
|
|
94
|
+
if (raw === undefined || raw === null) return out
|
|
95
|
+
if (typeof raw === 'string' && raw.trim() === '') return out
|
|
96
|
+
let parsed = raw
|
|
97
|
+
if (typeof raw === 'string') {
|
|
98
|
+
try {
|
|
99
|
+
parsed = JSON.parse(raw)
|
|
100
|
+
} catch {
|
|
101
|
+
return out
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (parsed === null || typeof parsed !== 'object') return out
|
|
105
|
+
for (const [model, value] of Object.entries(parsed)) {
|
|
106
|
+
const price = Array.isArray(value)
|
|
107
|
+
? sane(value[0], value[1])
|
|
108
|
+
: sane(value?.input, value?.output)
|
|
109
|
+
if (price !== undefined) out[model] = price
|
|
110
|
+
}
|
|
111
|
+
return out
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** 按型号族猜一个价。认不出返回 undefined。 */
|
|
115
|
+
export function familyPrice(model) {
|
|
116
|
+
const id = String(model ?? '')
|
|
117
|
+
if (id === '') return undefined
|
|
118
|
+
for (const rule of FAMILY_RULES) {
|
|
119
|
+
if (rule.match.test(id)) return { ...rule.price, label: rule.label }
|
|
120
|
+
}
|
|
121
|
+
return undefined
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* 给一个模型定出价,并说明这个数是怎么来的。
|
|
126
|
+
*
|
|
127
|
+
* @returns {{ input:number, output:number, confidence:'exact'|'builtin'|'family'|'fallback', label:string }}
|
|
128
|
+
*/
|
|
129
|
+
export function priceFor(model, overrides = {}) {
|
|
130
|
+
const id = String(model ?? '')
|
|
131
|
+
const override = overrides[id]
|
|
132
|
+
if (override !== undefined) {
|
|
133
|
+
return { ...override, confidence: 'exact', label: '配置里写的' }
|
|
134
|
+
}
|
|
135
|
+
const builtin = BUILTIN_PRICE[id]
|
|
136
|
+
if (builtin !== undefined) {
|
|
137
|
+
return { ...builtin, confidence: 'builtin', label: '内置已知价' }
|
|
138
|
+
}
|
|
139
|
+
const family = familyPrice(id)
|
|
140
|
+
if (family !== undefined) {
|
|
141
|
+
return {
|
|
142
|
+
input: family.input,
|
|
143
|
+
output: family.output,
|
|
144
|
+
confidence: 'family',
|
|
145
|
+
label: `按${family.label}估算`,
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return { ...FALLBACK_PRICE, confidence: 'fallback', label: '认不出型号,按最贵兜底' }
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* 给一串模型名(通常来自本机 LLM 注册表)全部定价。
|
|
153
|
+
*
|
|
154
|
+
* @param {string[]} models 本机可用的模型 id
|
|
155
|
+
* @param {Record<string,{input:number,output:number}>} overrides 用户配置
|
|
156
|
+
* @returns {{ rows: object[], byConfidence: Record<string, number> }}
|
|
157
|
+
*/
|
|
158
|
+
export function priceCatalog(models, overrides = {}) {
|
|
159
|
+
const seen = new Set()
|
|
160
|
+
const rows = []
|
|
161
|
+
for (const model of Array.isArray(models) ? models : []) {
|
|
162
|
+
if (typeof model !== 'string' || model === '' || seen.has(model)) continue
|
|
163
|
+
seen.add(model)
|
|
164
|
+
rows.push({ model, ...priceFor(model, overrides) })
|
|
165
|
+
}
|
|
166
|
+
const byConfidence = { exact: 0, builtin: 0, family: 0, fallback: 0 }
|
|
167
|
+
for (const row of rows) byConfidence[row.confidence] += 1
|
|
168
|
+
return { rows, byConfidence }
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* 把「用户覆盖 + 内置 + 族估算」合成一张完整表。
|
|
173
|
+
*
|
|
174
|
+
* 给预算熔断和预估共用。没列在 models 里的模型也会按同一套规则定价,
|
|
175
|
+
* 所以任何时候查 priceFor 都能拿到一个数,不会因为是新模型就崩。
|
|
176
|
+
*/
|
|
177
|
+
export function resolvePriceTable(raw, models = []) {
|
|
178
|
+
const overrides = parseOverrideTable(raw)
|
|
179
|
+
const table = {}
|
|
180
|
+
// 内置已知价先铺一层:即使本机没检测到,配置里写了也能用。
|
|
181
|
+
for (const [id, price] of Object.entries(BUILTIN_PRICE)) {
|
|
182
|
+
table[id] = { ...price }
|
|
183
|
+
}
|
|
184
|
+
for (const [id, price] of Object.entries(overrides)) {
|
|
185
|
+
table[id] = { ...price }
|
|
186
|
+
}
|
|
187
|
+
// 本机检测到的模型逐个补齐(配置和内置都不覆盖才用族估算)。
|
|
188
|
+
for (const model of Array.isArray(models) ? models : []) {
|
|
189
|
+
if (typeof model !== 'string' || model === '') continue
|
|
190
|
+
if (table[model] !== undefined) continue
|
|
191
|
+
const priced = priceFor(model, overrides)
|
|
192
|
+
table[model] = { input: priced.input, output: priced.output }
|
|
193
|
+
}
|
|
194
|
+
return table
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/** 表里最贵的一档。查不到模型的价钱时用它兜底。 */
|
|
198
|
+
export function worstPrice(table) {
|
|
199
|
+
let worst = { input: 0, output: 0 }
|
|
200
|
+
for (const price of Object.values(table ?? {})) {
|
|
201
|
+
const input = Number(price?.input)
|
|
202
|
+
const output = Number(price?.output)
|
|
203
|
+
if (Number.isFinite(input)) worst.input = Math.max(worst.input, input)
|
|
204
|
+
if (Number.isFinite(output)) worst.output = Math.max(worst.output, output)
|
|
205
|
+
}
|
|
206
|
+
return worst.input > 0 || worst.output > 0 ? worst : FALLBACK_PRICE
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/** confidence → 人话。界面上必须用它,别让人把估算当成报价。 */
|
|
210
|
+
export const CONFIDENCE_LABEL = {
|
|
211
|
+
exact: '你配的',
|
|
212
|
+
builtin: '内置',
|
|
213
|
+
family: '估算',
|
|
214
|
+
fallback: '兜底',
|
|
215
|
+
}
|