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.
Files changed (39) hide show
  1. package/.claude-plugin/hooks.json +1 -6
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/.codex-plugin/plugin.json +1 -1
  4. package/AGENTS.md +1 -1
  5. package/README.md +10 -6
  6. package/README.zh-CN.md +11 -7
  7. package/bin/claude-everything-workflow.js +16 -4
  8. package/commands/code-review.md +4 -4
  9. package/docs/plugins.md +21 -2
  10. package/evals/routing-scenarios.json +11 -2
  11. package/hooks/check-code-size.js +4 -126
  12. package/hooks/check-console-log.js +4 -79
  13. package/hooks/check-edited-file.js +139 -0
  14. package/hooks/commit-quality.js +1029 -72
  15. package/hooks/runtime/antigravity-pre-tool.js +116 -0
  16. package/package.json +4 -2
  17. package/rules/02-implementation.md +1 -1
  18. package/rules/common/hooks.md +2 -2
  19. package/scripts/cleanup-retired-skills.js +36 -3
  20. package/scripts/eval-scenarios.js +46 -14
  21. package/scripts/install-antigravity.js +545 -0
  22. package/scripts/install-rules.js +145 -49
  23. package/scripts/install.ps1 +76 -8
  24. package/scripts/install.sh +74 -21
  25. package/scripts/merge-claude-settings.cjs +14 -2
  26. package/scripts/retired-skill-files.json +12 -0
  27. package/scripts/verify/commit-quality.test.js +481 -0
  28. package/scripts/verify/install-rules.test.js +499 -10
  29. package/scripts/verify/metadata-checks.js +27 -1
  30. package/scripts/verify/runtime-checks.js +57 -2
  31. package/scripts/verify/scenario-checks.test.js +39 -10
  32. package/scripts/verify/workflow-checks.js +5 -1
  33. package/settings.json +1 -6
  34. package/skills/README.md +1 -1
  35. package/skills/code-review/SKILL.md +15 -21
  36. package/skills/implement/SKILL.md +2 -2
  37. package/skills/systematic-debugging/SKILL.md +7 -4
  38. package/skills/systematic-debugging/references/diagnostic-scenarios.md +7 -0
  39. 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)