claude-everything-workflow 0.1.4 → 0.1.5
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 +7 -11
- package/hooks/check-code-size.js +111 -0
- package/package.json +1 -1
- package/rules/02-code-size.md +11 -2
- package/scripts/verify-harness.js +1 -21
- package/settings.json +5 -0
- package/commands/acceptance.md +0 -73
package/README.md
CHANGED
|
@@ -245,7 +245,6 @@ claude-everything-Workflow/
|
|
|
245
245
|
| ------------------ | ---------------------------------------------------------- |
|
|
246
246
|
| `/pr` | 提交、推送和创建 PR 的标准工作流 |
|
|
247
247
|
| `/verify` | 运行全面验证检查 |
|
|
248
|
-
| `/acceptance` | 对照需求、spec、plan、diff 和验证证据输出验收结论 |
|
|
249
248
|
| `/learn-eval` | 从会话提取模式 (含质量门评估) |
|
|
250
249
|
| `/instinct-status` | 查看学习状态和待审查报告 |
|
|
251
250
|
| `/projects` | 查看 Continuous Learning 项目注册表 |
|
|
@@ -299,7 +298,6 @@ Codex 安装同一套 `hooks/` 脚本材料,但不会因为安装本仓文件
|
|
|
299
298
|
-> 代码质量审查
|
|
300
299
|
-> verification-before-completion 完成声明前确认新鲜验证证据
|
|
301
300
|
-> /verify 质量门
|
|
302
|
-
-> /acceptance 验收结论
|
|
303
301
|
-> /pr 提交/PR
|
|
304
302
|
-> /learn-eval --preview 学习沉淀
|
|
305
303
|
```
|
|
@@ -312,12 +310,11 @@ Codex 安装同一套 `hooks/` 脚本材料,但不会因为安装本仓文件
|
|
|
312
310
|
- 没有 review,不标记任务完成。
|
|
313
311
|
- 没有新鲜验证证据,不声明完成、通过、已修复或 ready。
|
|
314
312
|
- 没有 verify,不进入 PR。
|
|
315
|
-
- 没有 acceptance,不把复杂任务声明为验收通过。
|
|
316
313
|
- 有脏工作区、并行任务或高风险改动时,先考虑 `using-git-worktrees`。
|
|
317
314
|
|
|
318
315
|
复杂任务包括新功能、架构调整、多文件行为变化、高风险实现,以及需求存在多种合理解释的工作。简单问答、翻译、格式调整、窄范围文档修正和无行为变化的小修复,可以直接处理,但完成前仍需运行与改动范围匹配的最小验证。
|
|
319
316
|
|
|
320
|
-
收尾阶段按 `/verify` -> `/
|
|
317
|
+
收尾阶段按 `/verify` -> `/pr` -> `/learn-eval --preview` 推进。`/learn-eval --preview` 是非阻塞学习建议门,只在模式高频、稳定、可复用时保存。
|
|
321
318
|
|
|
322
319
|
## Continuous Learning v2
|
|
323
320
|
|
|
@@ -363,11 +360,10 @@ Codex 安装同一套 `hooks/` 脚本材料,但不会因为安装本仓文件
|
|
|
363
360
|
6. 使用 /tdd 委派 tdd-guide 规划测试先行实现
|
|
364
361
|
7. 关键路径使用 /e2e 委派 e2e-runner 维护 Playwright
|
|
365
362
|
8. 使用 /verify 验证
|
|
366
|
-
9. 使用 /
|
|
367
|
-
10. 使用 /
|
|
368
|
-
11. 使用 /
|
|
369
|
-
12. 使用 /
|
|
370
|
-
13. 使用 /
|
|
371
|
-
14. 使用 /
|
|
372
|
-
15. 使用 /prune 清理已人工标记删除的直觉
|
|
363
|
+
9. 使用 /code-review 委派 code-reviewer 审查
|
|
364
|
+
10. 使用 /learn-eval 将稳定模式沉淀到 skills/learn/<category>/
|
|
365
|
+
11. 使用 /projects 查看项目级学习来源
|
|
366
|
+
12. 使用 /promote --dry-run 评估是否推广为全局直觉
|
|
367
|
+
13. 使用 /evolve 评估是否演化
|
|
368
|
+
14. 使用 /prune 清理已人工标记删除的直觉
|
|
373
369
|
```
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Check Code Size Hook
|
|
4
|
+
*
|
|
5
|
+
* 编辑后只检查本次改动的代码文件,正常静默,避免增加上下文噪音。
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
'use strict'
|
|
9
|
+
|
|
10
|
+
const fs = require('fs')
|
|
11
|
+
|
|
12
|
+
const DEFAULT_MAX_LINES = 600
|
|
13
|
+
const TEST_MAX_LINES = 1000
|
|
14
|
+
const CODE_EXTENSIONS = new Set([
|
|
15
|
+
'.c',
|
|
16
|
+
'.cc',
|
|
17
|
+
'.cpp',
|
|
18
|
+
'.cs',
|
|
19
|
+
'.css',
|
|
20
|
+
'.go',
|
|
21
|
+
'.h',
|
|
22
|
+
'.hpp',
|
|
23
|
+
'.html',
|
|
24
|
+
'.java',
|
|
25
|
+
'.js',
|
|
26
|
+
'.jsx',
|
|
27
|
+
'.kt',
|
|
28
|
+
'.lua',
|
|
29
|
+
'.mjs',
|
|
30
|
+
'.php',
|
|
31
|
+
'.py',
|
|
32
|
+
'.rb',
|
|
33
|
+
'.rs',
|
|
34
|
+
'.sh',
|
|
35
|
+
'.swift',
|
|
36
|
+
'.ts',
|
|
37
|
+
'.tsx',
|
|
38
|
+
'.vue'
|
|
39
|
+
])
|
|
40
|
+
|
|
41
|
+
function getExtension(filePath) {
|
|
42
|
+
const match = filePath.match(/(\.[^.\\/]+)$/)
|
|
43
|
+
return match ? match[1].toLowerCase() : ''
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function isCodeFile(filePath) {
|
|
47
|
+
return CODE_EXTENSIONS.has(getExtension(filePath))
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function isTestFile(filePath) {
|
|
51
|
+
return /(^|[\\/])__tests__([\\/]|$)/.test(filePath) ||
|
|
52
|
+
/\.(test|spec)\.[^.\\/]+$/.test(filePath)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function getMaxLines(filePath) {
|
|
56
|
+
return isTestFile(filePath) ? TEST_MAX_LINES : DEFAULT_MAX_LINES
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function countLines(content) {
|
|
60
|
+
if (content.length === 0) return 0
|
|
61
|
+
const lines = content.split(/\r?\n/)
|
|
62
|
+
return content.endsWith('\n') ? lines.length - 1 : lines.length
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function run(raw) {
|
|
66
|
+
let input
|
|
67
|
+
try {
|
|
68
|
+
input = JSON.parse(raw)
|
|
69
|
+
} catch {
|
|
70
|
+
return { exitCode: 0 }
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const filePath = input.tool_input?.file_path
|
|
74
|
+
if (!filePath || !isCodeFile(filePath) || !fs.existsSync(filePath)) {
|
|
75
|
+
return { exitCode: 0 }
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
let content
|
|
79
|
+
try {
|
|
80
|
+
content = fs.readFileSync(filePath, 'utf8')
|
|
81
|
+
} catch {
|
|
82
|
+
return { exitCode: 0 }
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const maxLines = getMaxLines(filePath)
|
|
86
|
+
const lineCount = countLines(content)
|
|
87
|
+
if (lineCount <= maxLines) {
|
|
88
|
+
return { exitCode: 0 }
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return {
|
|
92
|
+
exitCode: 0,
|
|
93
|
+
stderr:
|
|
94
|
+
`[Hook] 代码文件超过 ${maxLines} 行: ` +
|
|
95
|
+
`${filePath} (${lineCount} 行),请拆分后继续。\n`
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
module.exports = { run }
|
|
100
|
+
|
|
101
|
+
if (require.main === module) {
|
|
102
|
+
let data = ''
|
|
103
|
+
process.stdin.setEncoding('utf8')
|
|
104
|
+
process.stdin.on('data', chunk => { data += chunk })
|
|
105
|
+
process.stdin.on('end', () => {
|
|
106
|
+
const result = run(data)
|
|
107
|
+
if (result.stderr) process.stderr.write(result.stderr)
|
|
108
|
+
if (result.stdout) process.stdout.write(result.stdout)
|
|
109
|
+
process.exit(result.exitCode || 0)
|
|
110
|
+
})
|
|
111
|
+
}
|
package/package.json
CHANGED
package/rules/02-code-size.md
CHANGED
|
@@ -4,10 +4,19 @@
|
|
|
4
4
|
|
|
5
5
|
| 约束项 | 限制 | 违反后果 |
|
|
6
6
|
| ----------- | -------------- | ---------------------- |
|
|
7
|
-
|
|
|
7
|
+
| 单代码文件行数 | **≤ 600 行** | 必须拆分文件 |
|
|
8
|
+
| 单测试文件行数 | **≤ 1000 行** | 必须拆分测试场景 |
|
|
8
9
|
| 单函数/方法 | **≤ 80 行** | 必须提取子函数 |
|
|
9
10
|
| 函数参数 | **≤ 5 个** | 必须封装为对象 |
|
|
10
11
|
| 嵌套层级 | **≤ 4 层** | 必须提前返回或提取函数 |
|
|
11
12
|
| 单行长度 | **≤ 120 字符** | 必须换行 |
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
**超限处理**:代码文件过长→拆分 | 测试文件过长→拆分场景 | 函数过长→提取 | 参数过多→封装对象 | 嵌套过深→早返回
|
|
15
|
+
|
|
16
|
+
## 执行要求
|
|
17
|
+
|
|
18
|
+
- 编辑代码后必须触发轻量代码规模检查,只检查本次编辑的代码文件。
|
|
19
|
+
- `*.test.*`、`*.spec.*` 和 `__tests__/` 下的测试文件上限为 1000 行。
|
|
20
|
+
- 文档、设计稿、规则说明等非代码文件不受 600 行限制。
|
|
21
|
+
- 检查通过时保持静默;只有代码文件超过对应上限时输出短警告。
|
|
22
|
+
- 收到超限警告后,先拆分职责、提取模块或拆分测试场景,再继续实现。
|
|
@@ -291,7 +291,6 @@ function checkLearningPathPolicy() {
|
|
|
291
291
|
|
|
292
292
|
function checkRouterTargets() {
|
|
293
293
|
const expected = [
|
|
294
|
-
["commands/acceptance.md", ["commands/verify.md"]],
|
|
295
294
|
["commands/code-review.md", ["agents/code-reviewer.md"]],
|
|
296
295
|
[
|
|
297
296
|
"commands/tdd.md",
|
|
@@ -329,25 +328,6 @@ function checkRouterTargets() {
|
|
|
329
328
|
}
|
|
330
329
|
}
|
|
331
330
|
|
|
332
|
-
function checkAcceptanceGate() {
|
|
333
|
-
requireTokens("README.md", [
|
|
334
|
-
"`/acceptance`",
|
|
335
|
-
"/verify` -> `/acceptance` -> `/pr`",
|
|
336
|
-
"没有 acceptance,不把复杂任务声明为验收通过",
|
|
337
|
-
]);
|
|
338
|
-
|
|
339
|
-
requireTokens("commands/acceptance.md", [
|
|
340
|
-
"验收结果: [通过/部分通过/失败/依据不足]",
|
|
341
|
-
"需求覆盖:",
|
|
342
|
-
"验收标准:",
|
|
343
|
-
"测试证据:",
|
|
344
|
-
"未验收项:",
|
|
345
|
-
"范围外改动:",
|
|
346
|
-
"剩余风险:",
|
|
347
|
-
"不要把“测试通过”等同于“验收通过”",
|
|
348
|
-
]);
|
|
349
|
-
}
|
|
350
|
-
|
|
351
331
|
function checkNpmPackageSurface() {
|
|
352
332
|
requireTokens("package.json", [
|
|
353
333
|
'"name": "claude-everything-workflow"',
|
|
@@ -663,6 +643,7 @@ function checkScriptLayout() {
|
|
|
663
643
|
"hooks/session-start.js",
|
|
664
644
|
"hooks/session-end.js",
|
|
665
645
|
"hooks/commit-quality.js",
|
|
646
|
+
"hooks/check-code-size.js",
|
|
666
647
|
"scripts/learning/review-confidence.js",
|
|
667
648
|
"scripts/learning/project-utils.js",
|
|
668
649
|
"scripts/learning/projects.js",
|
|
@@ -865,7 +846,6 @@ function main() {
|
|
|
865
846
|
checkHookConfigReferences();
|
|
866
847
|
checkLearningPathPolicy();
|
|
867
848
|
checkRouterTargets();
|
|
868
|
-
checkAcceptanceGate();
|
|
869
849
|
checkNpmPackageSurface();
|
|
870
850
|
checkSkillLinks();
|
|
871
851
|
checkRuleLoadingPolicy();
|
package/settings.json
CHANGED
|
@@ -22,6 +22,11 @@
|
|
|
22
22
|
"type": "command",
|
|
23
23
|
"command": "node \"$HOME/.claude/hooks/runtime/run-with-flags.js\" post:edit:console-log \"$HOME/.claude/hooks/check-console-log.js\" standard,strict",
|
|
24
24
|
"timeout": 5
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"type": "command",
|
|
28
|
+
"command": "node \"$HOME/.claude/hooks/runtime/run-with-flags.js\" post:edit:code-size \"$HOME/.claude/hooks/check-code-size.js\" standard,strict",
|
|
29
|
+
"timeout": 5
|
|
25
30
|
}
|
|
26
31
|
]
|
|
27
32
|
},
|
package/commands/acceptance.md
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: 验收实现是否满足需求、spec、plan 和验证证据
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# /acceptance - 需求验收
|
|
6
|
-
|
|
7
|
-
`/acceptance` 是 Verify Gate 之后、`/pr` 之前的验收入口,依赖 `commands/verify.md` 定义的验证证据。它不替代测试,也不发明新的执行器;它把现有 spec、plan、diff、测试结果和 `/verify` 输出整理成可审查的验收结论。
|
|
8
|
-
|
|
9
|
-
## 使用方式
|
|
10
|
-
|
|
11
|
-
```text
|
|
12
|
-
/acceptance
|
|
13
|
-
/acceptance docs/superpowers/specs/2026-06-16-feature-design.md
|
|
14
|
-
/acceptance --staged
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
## 输入来源
|
|
18
|
-
|
|
19
|
-
按可用性读取:
|
|
20
|
-
|
|
21
|
-
1. 用户指定的 spec、plan 或需求说明。
|
|
22
|
-
2. `docs/superpowers/specs/` 中与当前任务相关的 design spec。
|
|
23
|
-
3. `docs/superpowers/plans/` 中与当前任务相关的 implementation plan。
|
|
24
|
-
4. 当前 `git diff` 或 `--staged` diff。
|
|
25
|
-
5. 本轮已运行的测试、构建、lint、E2E、`/verify` 结果。
|
|
26
|
-
|
|
27
|
-
如果缺少 spec 或 plan,仍可基于用户原始需求和 diff 做轻量验收,但必须标记“验收依据不足”。
|
|
28
|
-
|
|
29
|
-
## 验收流程
|
|
30
|
-
|
|
31
|
-
1. 提取需求点、验收标准和非目标。
|
|
32
|
-
2. 对照 diff,判断每个需求是否有实现证据。
|
|
33
|
-
3. 对照测试和 `/verify`,判断每个验收标准是否有验证证据。
|
|
34
|
-
4. 检查是否有未运行项、失败项、范围外改动和剩余风险。
|
|
35
|
-
5. 输出明确结论:通过、部分通过、失败或依据不足。
|
|
36
|
-
|
|
37
|
-
## 输出格式
|
|
38
|
-
|
|
39
|
-
```text
|
|
40
|
-
验收结果: [通过/部分通过/失败/依据不足]
|
|
41
|
-
|
|
42
|
-
需求覆盖:
|
|
43
|
-
- REQ-1: [通过/失败/未验证] — [实现证据路径或原因]
|
|
44
|
-
|
|
45
|
-
验收标准:
|
|
46
|
-
- AC-1: [通过/失败/未验证] — [测试命令、人工检查或证据路径]
|
|
47
|
-
|
|
48
|
-
测试证据:
|
|
49
|
-
- <command>: <passed/failed/not run> — <evidence>
|
|
50
|
-
|
|
51
|
-
未验收项:
|
|
52
|
-
- [项目] — [原因]
|
|
53
|
-
|
|
54
|
-
范围外改动:
|
|
55
|
-
- [文件/行为] — [是否需要回滚或说明]
|
|
56
|
-
|
|
57
|
-
剩余风险:
|
|
58
|
-
- [风险 or 无已知剩余风险]
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
## 判定标准
|
|
62
|
-
|
|
63
|
-
- **通过**:需求覆盖完整,验收标准均有证据,关键验证通过,无阻塞风险。
|
|
64
|
-
- **部分通过**:核心路径通过,但存在非阻塞缺口、未运行检查或低风险未验收项。
|
|
65
|
-
- **失败**:需求缺失、关键验收标准失败、关键验证失败或存在阻塞风险。
|
|
66
|
-
- **依据不足**:没有足够的需求、spec、plan 或验证证据支撑验收结论。
|
|
67
|
-
|
|
68
|
-
## 约束
|
|
69
|
-
|
|
70
|
-
- 不要把“测试通过”等同于“验收通过”;必须对照需求和验收标准。
|
|
71
|
-
- 不要声称验收通过,除非有实现证据和验证证据。
|
|
72
|
-
- 未运行检查必须写明原因。
|
|
73
|
-
- 发现缺口时,回到实现、测试或 `/verify` 阶段,不直接进入 `/pr`。
|