dsh-oh-my-workflow 0.1.0 → 0.2.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 +8 -0
- package/README.md +2 -2
- package/package.json +1 -1
- package/preset/agent.cordis.yml +2 -0
- package/preset/guard/evidence.mjs +13 -2
- package/preset/turn-guard.mjs +25 -1
- package/test/guard.test.mjs +49 -5
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,14 @@ All notable changes to this project are documented here. The format is based on
|
|
|
4
4
|
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project
|
|
5
5
|
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## [0.2.0] - 2026-11-25
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
|
|
11
|
+
- `turn-guard` 规则 A(改完必须验证)默认改为 **balanced** 判定:本轮在**首个改动之后**只要出现过一次成功验证就算通过,之后的收尾小改动不再反复触发打回。仍可通过 `evidenceScope: strict` 恢复旧的“验证必须在最后一次改动之后”语义。
|
|
12
|
+
- 官方 `bash`/`pwsh` 的成功结果现在会被识别:这类工具只在非零退出时输出 `[exit code: N]`,因此“非 error 且无标记”视为 exit 0(`assumed-ok`)。OPS `ops_bash` 仍只认显式 `opsShell` 进程事实。可用 `assumeOfficialShellSuccess: false` 关闭。
|
|
13
|
+
- 扩大“强验证”命令识别:`bun`/`deno test|check|lint`、`uv|poetry|pdm|pipenv run pytest|mypy|ruff|tox|nox`、`npm|pnpm|yarn|bun run <test|check|verify|build|lint|type|spec|e2e…>`,以及 `dotnet|go|gradle|flutter|deno|bun run` 目标程序。
|
|
14
|
+
|
|
7
15
|
## [0.1.0] - 2026-11-23
|
|
8
16
|
|
|
9
17
|
### Added
|
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
- **三档推进**:按目标清晰度与风险,自动判断 **快速 / 标准 / 深入** 三档;快速档直接改并验证,标准档先给 3–6 步计划,深入档先澄清/建模/写规格再实现。
|
|
8
8
|
- **22 个技能**:覆盖需求追问、写规格、拆工单、实现、评审、验证与交接(来源与许可见 [NOTICE.md](NOTICE.md))。
|
|
9
|
-
-
|
|
9
|
+
- **轮次守卫**:每轮结束前要求「改完必须真验证」的行为证据(默认 balanced:首个改动后的任意一次成功验证即算数,收尾小改动不再反复打回);同一种修法连续失败两次就停下来重新核对共同前提,避免 AI 反复瞎改。
|
|
10
10
|
- **可优雅卸载**:卸载时先清理默认预设指针,避免悬空指针让新会话启动失败。
|
|
11
11
|
|
|
12
12
|
## Install
|
|
@@ -25,7 +25,7 @@ dsh plugin --profile web add github:KianWu/dsh-oh-my-workflow
|
|
|
25
25
|
|
|
26
26
|
- **Preset `workflow`**(显示名 `Workflow`):自定义 persona、三档推进纪律、`agent-instructions` 工作区规则注入。
|
|
27
27
|
- **OPS Native 集成**:通过公开的 `dsh-ops/integration` 入口接入文件/Shell/渐进发现工具,不碰私有 `lib/*` 路径。
|
|
28
|
-
- **Turn guard(`turn-guard.mjs
|
|
28
|
+
- **Turn guard(`turn-guard.mjs`)**:在轮次收尾的串行钩子上读取本轮日志;发现「改了文件却没有任何成功验证」或「同一修法重复失败」时,回灌一条短消息让本轮再走一步;守卫自身失败不阻塞回合。默认 `evidenceScope: balanced`(首个改动后验证一次即通过),`assumeOfficialShellSuccess: true`(官方 bash/pwsh 非零才输出退出码,非 error 即视为成功);需要旧严格语义时设 `evidenceScope: strict`。
|
|
29
29
|
- **22 个技能**:见下方清单,全部随包内置,挂载时从本包目录加载。
|
|
30
30
|
- **Uninstall guard + 生命周期 CLI**:`dsh-oh-my-workflow status | doctor [--fix] | uninstall`。
|
|
31
31
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-oh-my-workflow",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "oh-my-workflow:开箱即用的 AI 软件交付工作流。借鉴 Karpathy 的 AI 编程四原则(先想清楚、保持简单、只做必要修改、以可验证目标驱动执行),融合 Matt Pocock 的工程技能包,内置 22 个技能与“改完必须真验证”的轮次守卫,覆盖需求追问 → 写规格 → 拆工单 → 实现 → 评审 → 验证 → 交接,让 AI 交付的代码真正可验收。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
package/preset/agent.cordis.yml
CHANGED
|
@@ -77,6 +77,8 @@
|
|
|
77
77
|
failStreak: 2
|
|
78
78
|
maxSteersPerTurn: 2
|
|
79
79
|
includeSubagents: true
|
|
80
|
+
evidenceScope: balanced
|
|
81
|
+
assumeOfficialShellSuccess: true
|
|
80
82
|
mutationTools: [write, edit, ops_replace, ops_write_file, ops_edit_file, ops_copy, ops_move, ops_remove]
|
|
81
83
|
checkTools: [bash, pwsh, ops_bash]
|
|
82
84
|
documentationSuffixes: ['.md', '.mdx', '.txt', '.rst', '.adoc']
|
|
@@ -67,10 +67,14 @@ function exitCodeFromText(text) {
|
|
|
67
67
|
* Reduce one outcome to process facts.
|
|
68
68
|
* Returns `null` for non-shell tools, otherwise `{ completed, exitCode, signal, command, reason }`.
|
|
69
69
|
*/
|
|
70
|
-
export function processFact(outcome) {
|
|
70
|
+
export function processFact(outcome, options = {}) {
|
|
71
71
|
if (!SHELLS.has(outcome?.name)) return null
|
|
72
72
|
const command = commandOf(outcome)
|
|
73
73
|
const shell = opsShellOf(outcome)
|
|
74
|
+
// Official `bash`/`pwsh` report `[exit code: N]` only for a non-zero exit, so
|
|
75
|
+
// a non-error result with no marker and no signal is a successful run. OPS
|
|
76
|
+
// results always carry explicit `opsShell` facts and are never assumed.
|
|
77
|
+
const assumeSuccess = options.assumeOfficialShellSuccess !== false
|
|
74
78
|
|
|
75
79
|
// OPS: a background/promoted result has no `opsShell` facts and is never a
|
|
76
80
|
// completed foreground process. A signal also outranks any text rendering.
|
|
@@ -93,6 +97,9 @@ export function processFact(outcome) {
|
|
|
93
97
|
return { completed: false, exitCode: code, signal, command, reason: 'signal' }
|
|
94
98
|
}
|
|
95
99
|
if (code === undefined) {
|
|
100
|
+
if (assumeSuccess && outcome?.isError !== true) {
|
|
101
|
+
return { completed: true, exitCode: 0, signal: undefined, command, reason: 'assumed-ok' }
|
|
102
|
+
}
|
|
96
103
|
return { completed: false, exitCode: undefined, signal: undefined, command, reason: 'missing-exit-code' }
|
|
97
104
|
}
|
|
98
105
|
return { completed: code === 0, exitCode: code, signal: undefined, command, reason: code === 0 ? 'ok' : 'non-zero-exit' }
|
|
@@ -113,6 +120,9 @@ const PROJECT_CHECK_PATTERNS = [
|
|
|
113
120
|
/\bmake\s+(?:test|check|build)\b/i,
|
|
114
121
|
/\bcmake\s+--build\b/i,
|
|
115
122
|
/\bnode\s+--test\b/i,
|
|
123
|
+
/\b(?:bun|deno)\s+(?:test|check|lint)\b/i,
|
|
124
|
+
/\b(?:uv|poetry|pdm|pipenv)\s+run\s+(?:pytest|mypy|ruff|tox|nox)\b/i,
|
|
125
|
+
/\b(?:npm|pnpm|yarn|bun)\s+run\s+[\w:-]*(?:test|check|verify|build|lint|type|spec|e2e)[\w:-]*/i,
|
|
116
126
|
]
|
|
117
127
|
|
|
118
128
|
/** Running a target script is evidence only when it names an edited file. */
|
|
@@ -124,6 +134,7 @@ const TARGET_RUN_PATTERNS = [
|
|
|
124
134
|
/\bpython(?:3)?\s+(?:\.\/)?([^\s]+\.py)\b/i,
|
|
125
135
|
/\bpython(?:3)?\s+-c\b/i,
|
|
126
136
|
/(?:^|\s)(?:\.\/)?([^\s]+\.(?:exe|cmd|bat|ps1|sh))\b/i,
|
|
137
|
+
/\b(?:dotnet|go|gradle|gradlew|flutter|deno|bun)\s+run\b/i,
|
|
127
138
|
]
|
|
128
139
|
|
|
129
140
|
function mentionsAny(command, files) {
|
|
@@ -160,7 +171,7 @@ export function classifyVerificationCommand(command, config = {}, mutatedFiles =
|
|
|
160
171
|
|
|
161
172
|
/** Full verification fact for one shell outcome. */
|
|
162
173
|
export function verificationFact(outcome, config = {}, mutatedFiles = []) {
|
|
163
|
-
const process = processFact(outcome)
|
|
174
|
+
const process = processFact(outcome, config)
|
|
164
175
|
if (process === null) return null
|
|
165
176
|
const classification = process.completed
|
|
166
177
|
? classifyVerificationCommand(process.command, config, mutatedFiles)
|
package/preset/turn-guard.mjs
CHANGED
|
@@ -42,6 +42,8 @@ const DEFAULTS = Object.freeze({
|
|
|
42
42
|
failStreak: 2,
|
|
43
43
|
maxSteersPerTurn: 2,
|
|
44
44
|
includeSubagents: true,
|
|
45
|
+
evidenceScope: 'balanced',
|
|
46
|
+
assumeOfficialShellSuccess: true,
|
|
45
47
|
mutationTools: MUTATION_TOOLS,
|
|
46
48
|
checkTools: SHELL_TOOLS,
|
|
47
49
|
documentationSuffixes: DEFAULT_DOCUMENTATION_SUFFIXES,
|
|
@@ -64,6 +66,15 @@ function positiveInteger(config, key) {
|
|
|
64
66
|
return value
|
|
65
67
|
}
|
|
66
68
|
|
|
69
|
+
function enumOption(config, key, allowed, fallback) {
|
|
70
|
+
const value = config[key]
|
|
71
|
+
if (value === undefined) return fallback
|
|
72
|
+
if (typeof value !== 'string' || !allowed.includes(value)) {
|
|
73
|
+
throw new TypeError(`${name}: ${key} must be one of ${allowed.join(', ')}`)
|
|
74
|
+
}
|
|
75
|
+
return value
|
|
76
|
+
}
|
|
77
|
+
|
|
67
78
|
function stringList(config, key, fallback) {
|
|
68
79
|
const value = config[key]
|
|
69
80
|
if (value === undefined) return [...fallback]
|
|
@@ -89,6 +100,8 @@ export function normalizeOptions(raw = {}) {
|
|
|
89
100
|
failStreak: positiveInteger(config, 'failStreak'),
|
|
90
101
|
maxSteersPerTurn: positiveInteger(config, 'maxSteersPerTurn'),
|
|
91
102
|
includeSubagents: booleanOption(config, 'includeSubagents'),
|
|
103
|
+
evidenceScope: enumOption(config, 'evidenceScope', ['balanced', 'strict'], DEFAULTS.evidenceScope),
|
|
104
|
+
assumeOfficialShellSuccess: booleanOption(config, 'assumeOfficialShellSuccess'),
|
|
92
105
|
mutationTools,
|
|
93
106
|
checkTools,
|
|
94
107
|
documentationSuffixes,
|
|
@@ -121,6 +134,7 @@ export function evaluateTurn(outcomes, options = {}) {
|
|
|
121
134
|
}
|
|
122
135
|
|
|
123
136
|
const lastMutation = mutations.length === 0 ? -1 : mutations[mutations.length - 1].index
|
|
137
|
+
const firstMutation = mutations.length === 0 ? -1 : mutations[0].index
|
|
124
138
|
const strong = verifications.filter(fact => fact.strong)
|
|
125
139
|
const lastStrong = strong.length === 0 ? -1 : strong[strong.length - 1].index
|
|
126
140
|
|
|
@@ -128,7 +142,14 @@ export function evaluateTurn(outcomes, options = {}) {
|
|
|
128
142
|
const unprovenFiles = [...new Set(unproven.flatMap(fact => fact.paths))]
|
|
129
143
|
const docOnly = unprovenFiles.length > 0 && onlyDocumentation(unprovenFiles, documentationSuffixes)
|
|
130
144
|
|
|
131
|
-
const
|
|
145
|
+
const evidenceScope = options.evidenceScope === 'strict' ? 'strict' : 'balanced'
|
|
146
|
+
// balanced: one strong verification after the *first* change of the turn is
|
|
147
|
+
// enough; later small edits do not force another run. strict: the check must
|
|
148
|
+
// come after the *last* change.
|
|
149
|
+
const missingUnderScope = evidenceScope === 'strict'
|
|
150
|
+
? lastMutation >= 0 && lastStrong < lastMutation
|
|
151
|
+
: lastMutation >= 0 && !(lastStrong > firstMutation)
|
|
152
|
+
const evidenceMissing = missingUnderScope && !docOnly
|
|
132
153
|
const failures = failureSummary(list, threshold)
|
|
133
154
|
|
|
134
155
|
let rule = 'allow'
|
|
@@ -139,7 +160,9 @@ export function evaluateTurn(outcomes, options = {}) {
|
|
|
139
160
|
rule,
|
|
140
161
|
mutationCount: mutations.length,
|
|
141
162
|
lastMutation,
|
|
163
|
+
firstMutation,
|
|
142
164
|
lastStrong,
|
|
165
|
+
evidenceScope,
|
|
143
166
|
evidenceMissing,
|
|
144
167
|
documentationOnly: docOnly,
|
|
145
168
|
mutatedFiles: allMutatedFiles,
|
|
@@ -238,6 +261,7 @@ export function apply(ctx, rawConfig = {}) {
|
|
|
238
261
|
documentationSuffixes: project.documentationSuffixes?.length > 0
|
|
239
262
|
? project.documentationSuffixes
|
|
240
263
|
: options.documentationSuffixes,
|
|
264
|
+
assumeOfficialShellSuccess: options.assumeOfficialShellSuccess,
|
|
241
265
|
}
|
|
242
266
|
|
|
243
267
|
const analysis = evaluateTurn(toolOutcomes(current), { ...options, verification })
|
package/test/guard.test.mjs
CHANGED
|
@@ -93,6 +93,22 @@ check('command classification separates project checks, target runs and noise',
|
|
|
93
93
|
assert.equal(classifyVerificationCommand('node custom-check.js', { commands: ['node custom-check.js'] }, []).strong, true)
|
|
94
94
|
})
|
|
95
95
|
|
|
96
|
+
check('official shell success without a marker is assumed ok; errors are not', () => {
|
|
97
|
+
const ok = toolOutcomes(events(
|
|
98
|
+
call(1, 'c1', 'pwsh', { command: 'npm test' }),
|
|
99
|
+
result(1, 'c1', { text: 'all tests passed' }),
|
|
100
|
+
))[0]
|
|
101
|
+
assert.equal(processFact(ok).completed, true)
|
|
102
|
+
assert.equal(processFact(ok).reason, 'assumed-ok')
|
|
103
|
+
assert.equal(processFact(ok, { assumeOfficialShellSuccess: false }).completed, false)
|
|
104
|
+
|
|
105
|
+
const errored = toolOutcomes(events(
|
|
106
|
+
call(1, 'c2', 'pwsh', { command: 'npm test' }),
|
|
107
|
+
result(1, 'c2', { text: 'boom', isError: true }),
|
|
108
|
+
))[0]
|
|
109
|
+
assert.equal(processFact(errored).completed, false)
|
|
110
|
+
})
|
|
111
|
+
|
|
96
112
|
check('failureSummary counts same-kind trailing failures only', () => {
|
|
97
113
|
const same = toolOutcomes(events(
|
|
98
114
|
...officialShell(1, 'c1', 'pwsh', 'npm test', 1),
|
|
@@ -207,15 +223,26 @@ await checkAsync('documentation-only edit is exempt; mixed edit is not', async (
|
|
|
207
223
|
assert.match(textOf(mixed.steers[0]), /core\.ts/)
|
|
208
224
|
})
|
|
209
225
|
|
|
210
|
-
await checkAsync('
|
|
226
|
+
await checkAsync('balanced: one check after the first edit covers later edits', async () => {
|
|
211
227
|
const run = makeRun()
|
|
212
228
|
await run.stop(events(
|
|
213
|
-
call(1, 'c1', 'write', { file_path: '
|
|
229
|
+
call(1, 'c1', 'write', { file_path: 'first.ts' }), result(1, 'c1'),
|
|
214
230
|
...officialShell(1, 'c2', 'pwsh', 'npm test', 0),
|
|
215
|
-
call(1, 'c3', 'edit', { file_path: '
|
|
231
|
+
call(1, 'c3', 'edit', { file_path: 'later.ts' }), result(1, 'c3'),
|
|
216
232
|
), 1)
|
|
217
|
-
assert.
|
|
218
|
-
|
|
233
|
+
assert.equal(run.steers.length, 0)
|
|
234
|
+
})
|
|
235
|
+
|
|
236
|
+
await checkAsync('strict scope still asks for a check after the last edit', async () => {
|
|
237
|
+
const run = makeRun({ evidenceScope: 'strict' })
|
|
238
|
+
await run.stop(events(
|
|
239
|
+
call(1, 'c1', 'write', { file_path: 'first.ts' }), result(1, 'c1'),
|
|
240
|
+
...officialShell(1, 'c2', 'pwsh', 'npm test', 0),
|
|
241
|
+
call(1, 'c3', 'edit', { file_path: 'later.ts' }), result(1, 'c3'),
|
|
242
|
+
), 1)
|
|
243
|
+
assert.equal(run.steers.length, 1)
|
|
244
|
+
assert.match(textOf(run.steers[0]), /later\.ts/)
|
|
245
|
+
assert.doesNotMatch(textOf(run.steers[0]), /first\.ts/)
|
|
219
246
|
})
|
|
220
247
|
|
|
221
248
|
await checkAsync('per-turn budget caps steers and rewords the second', async () => {
|
|
@@ -260,6 +287,7 @@ check('bad config throws at mount', () => {
|
|
|
260
287
|
assert.throws(() => makeRun({ failStreak: 0 }), /positive integer/)
|
|
261
288
|
assert.throws(() => makeRun({ evidence: 'yes' }), /must be a boolean/)
|
|
262
289
|
assert.throws(() => makeRun({ mutationTools: [] }), /must not be empty/)
|
|
290
|
+
assert.throws(() => makeRun({ evidenceScope: 'loose' }), /evidenceScope/)
|
|
263
291
|
})
|
|
264
292
|
|
|
265
293
|
await checkAsync('OPS completed + ops_bash success closes without a nudge', async () => {
|
|
@@ -323,4 +351,20 @@ await checkAsync('parent and child sessions keep independent counters', async ()
|
|
|
323
351
|
assert.equal(run.steers.length, 2)
|
|
324
352
|
})
|
|
325
353
|
|
|
354
|
+
check('running the edited target program is strong evidence', () => {
|
|
355
|
+
const cmd = "Start-Process -FilePath E:/Steam/steamapps/common/Godot/godot.windows.opt.tools.64.exe -ArgumentList '--path',$proj,'res://tmp_perf_probe.tscn' -Wait"
|
|
356
|
+
assert.equal(classifyVerificationCommand(cmd, {}, ['godot-flight-simulator/tmp_perf_probe.tscn']).strong, true)
|
|
357
|
+
})
|
|
358
|
+
|
|
359
|
+
await checkAsync('real-world: a Godot target run with no exit marker closes without a nudge', async () => {
|
|
360
|
+
const run = makeRun()
|
|
361
|
+
const cmd = "Start-Process -FilePath E:/Steam/steamapps/common/Godot/godot.windows.opt.tools.64.exe -ArgumentList '--path',$proj,'res://tmp_perf_probe.tscn' -Wait"
|
|
362
|
+
await run.stop(events(
|
|
363
|
+
call(1, 'c1', 'write', { file_path: 'godot-flight-simulator/tmp_perf_probe.tscn' }), result(1, 'c1'),
|
|
364
|
+
call(1, 'c2', 'pwsh', { command: cmd }),
|
|
365
|
+
result(1, 'c2', { text: 'elapsed=53s\r\nPERF|60|26.0|28.56|150.00' }),
|
|
366
|
+
), 1)
|
|
367
|
+
assert.equal(run.steers.length, 0)
|
|
368
|
+
})
|
|
369
|
+
|
|
326
370
|
console.log(`\n${passed} checks passed`)
|