claude-everything-workflow 0.2.10 → 0.2.12
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/.claude-plugin/hooks.json +1 -6
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/AGENTS.md +1 -1
- package/README.md +10 -6
- package/README.zh-CN.md +11 -7
- package/bin/claude-everything-workflow.js +16 -4
- package/commands/code-review.md +4 -4
- package/docs/plugins.md +21 -2
- package/evals/routing-scenarios.json +11 -2
- package/hooks/check-code-size.js +4 -126
- package/hooks/check-console-log.js +4 -79
- package/hooks/check-edited-file.js +139 -0
- package/hooks/commit-quality.js +1029 -72
- package/hooks/runtime/antigravity-pre-tool.js +116 -0
- package/package.json +4 -2
- package/rules/02-implementation.md +1 -1
- package/rules/common/hooks.md +2 -2
- package/scripts/cleanup-retired-skills.js +36 -3
- package/scripts/eval-scenarios.js +46 -14
- package/scripts/install-antigravity.js +545 -0
- package/scripts/install-rules.js +145 -49
- package/scripts/install.ps1 +76 -8
- package/scripts/install.sh +74 -21
- package/scripts/merge-claude-settings.cjs +14 -2
- package/scripts/retired-skill-files.json +12 -0
- package/scripts/verify/commit-quality.test.js +481 -0
- package/scripts/verify/install-rules.test.js +499 -10
- package/scripts/verify/metadata-checks.js +27 -1
- package/scripts/verify/runtime-checks.js +57 -2
- package/scripts/verify/scenario-checks.test.js +39 -10
- package/scripts/verify/workflow-checks.js +5 -1
- package/settings.json +1 -6
- package/skills/README.md +1 -1
- package/skills/code-review/SKILL.md +15 -21
- package/skills/implement/SKILL.md +2 -2
- package/skills/systematic-debugging/SKILL.md +7 -4
- package/skills/systematic-debugging/references/diagnostic-scenarios.md +7 -0
- package/agents/harness-optimizer.md +0 -93
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict'
|
|
3
|
+
|
|
4
|
+
const fs = require('node:fs')
|
|
5
|
+
const { isHookEnabled } = require('./runtime/hook-flags')
|
|
6
|
+
|
|
7
|
+
const CODE_TARGET_LINES = 800
|
|
8
|
+
const TEST_MAX_LINES = 1000
|
|
9
|
+
const MAX_LINE_LENGTH = 120
|
|
10
|
+
const MAX_STDIN_BYTES = 1024 * 1024
|
|
11
|
+
const CODE_EXTENSIONS = new Set([
|
|
12
|
+
'.c', '.cc', '.cpp', '.cs', '.css', '.go', '.h', '.hpp',
|
|
13
|
+
'.html', '.java', '.js', '.jsx', '.kt', '.lua', '.mjs', '.php',
|
|
14
|
+
'.py', '.rb', '.rs', '.sh', '.swift', '.ts', '.tsx', '.vue'
|
|
15
|
+
])
|
|
16
|
+
const TS_EXTENSIONS = new Set(['.ts', '.tsx', '.mts', '.cts'])
|
|
17
|
+
const FORBIDDEN_PATTERNS = [
|
|
18
|
+
{ label: 'console.log 调试残留', pattern: /\bconsole\.log\s*\(/ },
|
|
19
|
+
{ label: 'debugger 调试残留', pattern: /^\s*debugger\b/m },
|
|
20
|
+
{ label: '@ts-ignore', pattern: /@ts-ignore/ },
|
|
21
|
+
{ label: '@ts-nocheck', pattern: /@ts-nocheck/ },
|
|
22
|
+
{ label: 'any 类型(: any)', pattern: /:\s*any\b/ },
|
|
23
|
+
{ label: 'any 断言(as any)', pattern: /\bas\s+any\b/ }
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
function getExtension(filePath) {
|
|
27
|
+
const match = filePath.match(/(\.[^.\\/]+)$/)
|
|
28
|
+
return match ? match[1].toLowerCase() : ''
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function isTestFile(filePath) {
|
|
32
|
+
return /(^|[\\/])__tests__([\\/]|$)/.test(filePath) ||
|
|
33
|
+
/\.(test|spec)\.[^.\\/]+$/.test(filePath)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function countLines(content) {
|
|
37
|
+
if (content.length === 0) return 0
|
|
38
|
+
const lines = content.split(/\r?\n/)
|
|
39
|
+
return content.endsWith('\n') ? lines.length - 1 : lines.length
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function sizeWarnings(filePath, content) {
|
|
43
|
+
const testFile = isTestFile(filePath)
|
|
44
|
+
const lineThreshold = testFile ? TEST_MAX_LINES : CODE_TARGET_LINES
|
|
45
|
+
const lineCount = countLines(content)
|
|
46
|
+
const messages = []
|
|
47
|
+
|
|
48
|
+
if (lineCount > lineThreshold) {
|
|
49
|
+
messages.push(
|
|
50
|
+
testFile
|
|
51
|
+
? `测试文件超过 ${lineThreshold} 行上限 (${lineCount} 行),请拆分测试场景。`
|
|
52
|
+
: `代码文件超过约 ${lineThreshold} 行的参考值 (${lineCount} 行),请评估是否按职责拆分。`
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const longLineNumbers = []
|
|
57
|
+
content.split(/\r?\n/).forEach((line, index) => {
|
|
58
|
+
if (line.length > MAX_LINE_LENGTH && longLineNumbers.length < 3) {
|
|
59
|
+
longLineNumbers.push(index + 1)
|
|
60
|
+
}
|
|
61
|
+
})
|
|
62
|
+
if (longLineNumbers.length > 0) {
|
|
63
|
+
messages.push(
|
|
64
|
+
`存在超过 ${MAX_LINE_LENGTH} 字符的行(如第 ${longLineNumbers.join('、')} 行),请换行或提取。`
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return messages
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function checkEditedFile(raw, patterns, size) {
|
|
72
|
+
let filePath
|
|
73
|
+
try {
|
|
74
|
+
filePath = JSON.parse(raw)?.tool_input?.file_path
|
|
75
|
+
} catch {
|
|
76
|
+
return { exitCode: 0 }
|
|
77
|
+
}
|
|
78
|
+
if (typeof filePath !== 'string') return { exitCode: 0 }
|
|
79
|
+
|
|
80
|
+
const ext = getExtension(filePath)
|
|
81
|
+
const checkPatterns = patterns && ext && !/^\.(md|json|txt)$/.test(ext)
|
|
82
|
+
const checkSize = size && CODE_EXTENSIONS.has(ext)
|
|
83
|
+
if (!checkPatterns && !checkSize) return { exitCode: 0 }
|
|
84
|
+
|
|
85
|
+
let content
|
|
86
|
+
try {
|
|
87
|
+
content = fs.readFileSync(filePath, 'utf8')
|
|
88
|
+
} catch {
|
|
89
|
+
return { exitCode: 0 }
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const warnings = []
|
|
93
|
+
if (checkPatterns) {
|
|
94
|
+
const hits = FORBIDDEN_PATTERNS
|
|
95
|
+
.filter(rule => (!rule.label.includes('any') || TS_EXTENSIONS.has(ext)) && rule.pattern.test(content))
|
|
96
|
+
.map(rule => rule.label)
|
|
97
|
+
if (hits.length) {
|
|
98
|
+
warnings.push(
|
|
99
|
+
`[Hook] 警告: ${filePath} 含禁止模式: ${hits.join('、')},请按 rules/02-implementation.md 处理`
|
|
100
|
+
)
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (checkSize) {
|
|
104
|
+
const messages = sizeWarnings(filePath, content)
|
|
105
|
+
if (messages.length) warnings.push(`[Hook] ${filePath}: ${messages.join(' ')}`)
|
|
106
|
+
}
|
|
107
|
+
return warnings.length ? { exitCode: 0, stderr: warnings.join('\n') + '\n' } : { exitCode: 0 }
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function isSubHookEnabled(hookId) {
|
|
111
|
+
// Allow ECC_DISABLED_HOOKS per sub-check without overriding the profile set on post:edit:quality.
|
|
112
|
+
return isHookEnabled(hookId, { profiles: 'minimal,standard,strict' })
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function run(raw) {
|
|
116
|
+
return checkEditedFile(
|
|
117
|
+
raw,
|
|
118
|
+
isSubHookEnabled('post:edit:console-log'),
|
|
119
|
+
isSubHookEnabled('post:edit:code-size')
|
|
120
|
+
)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function runCli(check) {
|
|
124
|
+
let raw = ''
|
|
125
|
+
process.stdin.setEncoding('utf8')
|
|
126
|
+
process.stdin.on('data', chunk => {
|
|
127
|
+
if (raw.length < MAX_STDIN_BYTES) raw += chunk.slice(0, MAX_STDIN_BYTES - raw.length)
|
|
128
|
+
})
|
|
129
|
+
process.stdin.on('end', () => {
|
|
130
|
+
const result = check(raw)
|
|
131
|
+
if (result.stderr) process.stderr.write(result.stderr)
|
|
132
|
+
if (result.stdout) process.stdout.write(result.stdout)
|
|
133
|
+
process.exit(result.exitCode || 0)
|
|
134
|
+
})
|
|
135
|
+
process.stdin.on('error', () => process.exit(0))
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
module.exports = { run, checkEditedFile, runCli }
|
|
139
|
+
if (require.main === module) runCli(run)
|