claude-everything-workflow 0.1.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.
Files changed (99) hide show
  1. package/AGENTS.md +36 -0
  2. package/CLAUDE.md +7 -0
  3. package/LICENSE +22 -0
  4. package/README.md +369 -0
  5. package/agents/architect.md +59 -0
  6. package/agents/code-reviewer.md +57 -0
  7. package/agents/database-reviewer.md +44 -0
  8. package/agents/e2e-runner.md +153 -0
  9. package/agents/harness-optimizer.md +92 -0
  10. package/agents/planner.md +124 -0
  11. package/agents/refactor-cleaner.md +54 -0
  12. package/agents/security-reviewer.md +47 -0
  13. package/agents/tdd-guide.md +101 -0
  14. package/bin/claude-everything-workflow.js +91 -0
  15. package/commands/code-review.md +27 -0
  16. package/commands/e2e.md +28 -0
  17. package/commands/evolve.md +42 -0
  18. package/commands/harness-audit.md +27 -0
  19. package/commands/instinct-status.md +38 -0
  20. package/commands/learn-eval.md +91 -0
  21. package/commands/pr.md +88 -0
  22. package/commands/projects.md +27 -0
  23. package/commands/promote.md +29 -0
  24. package/commands/prune.md +46 -0
  25. package/commands/tdd.md +27 -0
  26. package/commands/verify.md +93 -0
  27. package/homunculus/instincts/personal/always-test-first.md +28 -0
  28. package/homunculus/instincts/personal/pr-ci-quality-gate.md +30 -0
  29. package/hooks/check-console-log.js +37 -0
  30. package/hooks/commit-quality.js +143 -0
  31. package/hooks/evaluate-session.js +59 -0
  32. package/hooks/pre-compact.js +92 -0
  33. package/hooks/runtime/hook-flags.js +40 -0
  34. package/hooks/runtime/run-with-flags.js +141 -0
  35. package/hooks/runtime/session-utils.js +45 -0
  36. package/hooks/session-end.js +62 -0
  37. package/hooks/session-start.js +60 -0
  38. package/package.json +48 -0
  39. package/references/agents/database-reviewer.md +657 -0
  40. package/references/agents/refactor-cleaner.md +75 -0
  41. package/references/agents/security-reviewer.md +542 -0
  42. package/rules/01-base.md +49 -0
  43. package/rules/02-code-size.md +13 -0
  44. package/rules/03-architecture.md +64 -0
  45. package/rules/04-error-handling.md +27 -0
  46. package/rules/05-git-workflow.md +56 -0
  47. package/rules/06-comments.md +44 -0
  48. package/rules/07-forbidden.md +43 -0
  49. package/rules/08-ecc-integration.md +46 -0
  50. package/rules/common/agent-orchestration.md +54 -0
  51. package/rules/common/context-hygiene.md +85 -0
  52. package/rules/common/harness-engineering.md +46 -0
  53. package/rules/common/hooks.md +87 -0
  54. package/rules/common/implementation.md +25 -0
  55. package/rules/common/performance.md +71 -0
  56. package/rules/common/pr-automation.md +73 -0
  57. package/rules/common/security.md +19 -0
  58. package/rules/common/skills-learning.md +39 -0
  59. package/rules/common/testing.md +68 -0
  60. package/scripts/install.ps1 +286 -0
  61. package/scripts/install.sh +214 -0
  62. package/scripts/learning/migrate-homunculus.js +93 -0
  63. package/scripts/learning/project-utils.js +214 -0
  64. package/scripts/learning/projects.js +60 -0
  65. package/scripts/learning/promote.js +98 -0
  66. package/scripts/learning/review-confidence.js +455 -0
  67. package/scripts/verify-harness.js +868 -0
  68. package/settings.json +77 -0
  69. package/skills/brainstorming/SKILL.md +185 -0
  70. package/skills/brainstorming/agents/openai.yaml +3 -0
  71. package/skills/brainstorming/scripts/frame-template.html +214 -0
  72. package/skills/brainstorming/scripts/helper.js +88 -0
  73. package/skills/brainstorming/scripts/server.cjs +354 -0
  74. package/skills/brainstorming/scripts/start-server.sh +148 -0
  75. package/skills/brainstorming/scripts/stop-server.sh +56 -0
  76. package/skills/brainstorming/spec-document-reviewer-prompt.md +49 -0
  77. package/skills/brainstorming/visual-companion.md +287 -0
  78. package/skills/continuous-learning-v2/SKILL.md +74 -0
  79. package/skills/continuous-learning-v2/agents/observer.md +129 -0
  80. package/skills/continuous-learning-v2/agents/start-observer.sh +83 -0
  81. package/skills/continuous-learning-v2/config.json +58 -0
  82. package/skills/continuous-learning-v2/hooks/observe-v2.js +144 -0
  83. package/skills/documentation-lookup/SKILL.md +90 -0
  84. package/skills/e2e-testing/SKILL.md +326 -0
  85. package/skills/executing-plans/SKILL.md +66 -0
  86. package/skills/find-skills/SKILL.md +142 -0
  87. package/skills/skill-creator/LICENSE.txt +202 -0
  88. package/skills/skill-creator/SKILL.md +356 -0
  89. package/skills/skill-creator/references/output-patterns.md +82 -0
  90. package/skills/skill-creator/references/workflows.md +28 -0
  91. package/skills/skill-creator/scripts/init_skill.py +303 -0
  92. package/skills/skill-creator/scripts/package_skill.py +110 -0
  93. package/skills/skill-creator/scripts/quick_validate.py +95 -0
  94. package/skills/systematic-debugging/SKILL.md +59 -0
  95. package/skills/test-driven-development/SKILL.md +71 -0
  96. package/skills/using-git-worktrees/SKILL.md +64 -0
  97. package/skills/verification-before-completion/SKILL.md +77 -0
  98. package/skills/writing-plans/SKILL.md +183 -0
  99. package/skills/writing-plans/plan-document-reviewer-prompt.md +49 -0
@@ -0,0 +1,455 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Review Confidence
4
+ *
5
+ * 置信度审查工具 - 生成直觉健康报告,帮助用户识别需关注的直觉
6
+ * 不自动修改任何置信度值,所有变更由用户决策驱动
7
+ *
8
+ * 用法:
9
+ * node review-confidence.js # 生成审查报告
10
+ * node review-confidence.js --stale 30 # 自定义过期天数
11
+ * node review-confidence.js --json # JSON 格式输出
12
+ * node review-confidence.js --help # 显示帮助
13
+ * node review-confidence.js --path <dir> # 指定直觉目录
14
+ */
15
+
16
+ const fs = require('fs')
17
+ const path = require('path')
18
+ const os = require('os')
19
+ const {
20
+ getDataRoot,
21
+ getGlobalInstinctsDir,
22
+ getProjectContext,
23
+ getProjectInstinctsDir,
24
+ loadConfig,
25
+ loadProjects
26
+ } = require('./project-utils')
27
+
28
+ const DEFAULT_STALE_DAYS = 30
29
+
30
+ // --- 命令行解析 ---
31
+
32
+ function parseArgs() {
33
+ const args = process.argv.slice(2)
34
+
35
+ if (args.includes('--help')) {
36
+ printHelp()
37
+ process.exit(0)
38
+ }
39
+
40
+ return {
41
+ staleDays: parseIntArg(args, '--stale', DEFAULT_STALE_DAYS),
42
+ jsonOutput: args.includes('--json'),
43
+ customPath: parseStringArg(args, '--path'),
44
+ scope: parseStringArg(args, '--scope') || 'all',
45
+ projectId: parseStringArg(args, '--project-id'),
46
+ cwd: parseStringArg(args, '--cwd')
47
+ }
48
+ }
49
+
50
+ function parseIntArg(args, flag, defaultValue) {
51
+ const index = args.indexOf(flag)
52
+ if (index === -1 || !args[index + 1]) return defaultValue
53
+ const value = parseInt(args[index + 1], 10)
54
+ return isNaN(value) ? defaultValue : value
55
+ }
56
+
57
+ function parseStringArg(args, flag) {
58
+ const index = args.indexOf(flag)
59
+ if (index === -1 || !args[index + 1]) return null
60
+ return args[index + 1]
61
+ }
62
+
63
+ function printHelp() {
64
+ console.log(`
65
+ 置信度审查工具 - 生成直觉健康报告
66
+
67
+ 用法:
68
+ node review-confidence.js [选项]
69
+
70
+ 选项:
71
+ --stale <天数> 过期阈值天数 (默认: ${DEFAULT_STALE_DAYS})
72
+ --json JSON 格式输出
73
+ --path <目录> 指定直觉目录
74
+ --scope <范围> all | project | global | legacy (默认: all)
75
+ --project-id <id> 指定项目 ID
76
+ --cwd <目录> 用目录推断当前项目
77
+ --help 显示帮助
78
+
79
+ 报告分类:
80
+ [活跃] 最近有观察记录,置信度有证据支持
81
+ [待审查] 超过阈值天数未被观察,建议用户验证
82
+ [低证据] 置信度较低且缺乏充分证据
83
+
84
+ 注意: 此工具只生成报告,不会修改任何文件的置信度值。
85
+ `.trim())
86
+ }
87
+
88
+ // --- 路径查找 ---
89
+
90
+ function findInstinctsPath(customPath) {
91
+ if (customPath) {
92
+ const resolved = path.resolve(customPath)
93
+ if (fs.existsSync(resolved)) return resolved
94
+ }
95
+
96
+ const cwdPath = path.join(process.cwd(), 'homunculus', 'instincts')
97
+ if (fs.existsSync(cwdPath)) return cwdPath
98
+
99
+ return path.join(os.homedir(), '.claude', 'homunculus', 'instincts')
100
+ }
101
+
102
+ function findConfig() {
103
+ const cwdConfig = path.join(
104
+ process.cwd(), 'skills', 'continuous-learning-v2', 'config.json'
105
+ )
106
+ if (fs.existsSync(cwdConfig)) return cwdConfig
107
+
108
+ return path.join(
109
+ os.homedir(), '.claude', 'skills',
110
+ 'continuous-learning-v2', 'config.json'
111
+ )
112
+ }
113
+
114
+ function loadStaleDays(cliValue) {
115
+ if (cliValue !== DEFAULT_STALE_DAYS) return cliValue
116
+
117
+ try {
118
+ const configPath = findConfig()
119
+ if (fs.existsSync(configPath)) {
120
+ const config = JSON.parse(fs.readFileSync(configPath, 'utf8'))
121
+ return config.instincts?.stale_threshold_days ?? cliValue
122
+ }
123
+ } catch {
124
+ // 配置加载失败时使用 CLI 传入值
125
+ }
126
+ return cliValue
127
+ }
128
+
129
+ // --- YAML Frontmatter 解析 ---
130
+
131
+ function parseFrontmatter(content) {
132
+ const match = content.match(/^---\r?\n([\s\S]*?)\r?\n---/)
133
+ if (!match) return { meta: {}, body: content }
134
+
135
+ const meta = {}
136
+ match[1].split(/\r?\n/).forEach(line => {
137
+ const colonIndex = line.indexOf(':')
138
+ if (colonIndex <= 0) return
139
+
140
+ const key = line.slice(0, colonIndex).trim()
141
+ let value = line.slice(colonIndex + 1).trim()
142
+
143
+ // 移除引号
144
+ if (
145
+ (value.startsWith('"') && value.endsWith('"')) ||
146
+ (value.startsWith("'") && value.endsWith("'"))
147
+ ) {
148
+ value = value.slice(1, -1)
149
+ }
150
+
151
+ // 解析数字
152
+ if (/^-?\d+\.?\d*$/.test(value)) {
153
+ value = parseFloat(value)
154
+ }
155
+
156
+ meta[key] = value
157
+ })
158
+
159
+ return { meta, body: content.slice(match[0].length) }
160
+ }
161
+
162
+ // --- 文件扫描 ---
163
+
164
+ function scanInstinctsDir(basePath, scope = 'legacy', projectId = null) {
165
+ const files = []
166
+ for (const dir of ['personal', 'inherited']) {
167
+ const dirPath = path.join(basePath, dir)
168
+ if (!fs.existsSync(dirPath)) continue
169
+
170
+ for (const entry of fs.readdirSync(dirPath)) {
171
+ if (entry.endsWith('.md')) {
172
+ files.push({
173
+ path: path.join(dirPath, entry),
174
+ category: dir,
175
+ scope,
176
+ projectId
177
+ })
178
+ }
179
+ }
180
+ }
181
+ return files
182
+ }
183
+
184
+ function collectInstinctFiles(options) {
185
+ if (options.customPath) {
186
+ return scanInstinctsDir(findInstinctsPath(options.customPath), 'custom')
187
+ }
188
+
189
+ const config = loadConfig()
190
+ const dataRoot = getDataRoot(config)
191
+ const files = []
192
+
193
+ if (options.scope === 'all' || options.scope === 'global') {
194
+ files.push(...scanInstinctsDir(getGlobalInstinctsDir(dataRoot), 'global'))
195
+ }
196
+
197
+ if (options.scope === 'all' || options.scope === 'project') {
198
+ const currentProjectId = options.projectId ||
199
+ getProjectContext({ cwd: options.cwd || process.cwd() }).project_id
200
+ files.push(
201
+ ...scanInstinctsDir(
202
+ getProjectInstinctsDir(dataRoot, currentProjectId),
203
+ 'project',
204
+ currentProjectId
205
+ )
206
+ )
207
+ }
208
+
209
+ if (options.scope === 'all' || options.scope === 'legacy') {
210
+ files.push(...scanInstinctsDir(findInstinctsPath(null), 'legacy'))
211
+ }
212
+
213
+ if (options.scope === 'all') {
214
+ const projects = loadProjects(dataRoot).projects || {}
215
+ for (const projectId of Object.keys(projects)) {
216
+ const alreadyCurrent = files.some(
217
+ file => file.scope === 'project' && file.projectId === projectId
218
+ )
219
+ if (!alreadyCurrent) {
220
+ files.push(
221
+ ...scanInstinctsDir(
222
+ getProjectInstinctsDir(dataRoot, projectId),
223
+ 'project',
224
+ projectId
225
+ )
226
+ )
227
+ }
228
+ }
229
+ }
230
+
231
+ return files
232
+ }
233
+
234
+ // --- 直觉分析 ---
235
+
236
+ /**
237
+ * 计算自上次观察以来的天数
238
+ */
239
+ function daysSinceLastObserved(lastObserved, filePath) {
240
+ const dateStr = lastObserved || getFileModifiedDate(filePath)
241
+ if (!dateStr) return null
242
+
243
+ const lastDate = new Date(dateStr)
244
+ if (isNaN(lastDate.getTime())) return null
245
+
246
+ const diffMs = Date.now() - lastDate.getTime()
247
+ return Math.floor(diffMs / (1000 * 60 * 60 * 24))
248
+ }
249
+
250
+ function getFileModifiedDate(filePath) {
251
+ try {
252
+ return fs.statSync(filePath).mtime.toISOString().split('T')[0]
253
+ } catch {
254
+ return null
255
+ }
256
+ }
257
+
258
+ /**
259
+ * 分析单个直觉文件,生成审查条目
260
+ */
261
+ function analyzeInstinct(fileInfo, staleDays) {
262
+ const content = fs.readFileSync(fileInfo.path, 'utf8')
263
+ const { meta } = parseFrontmatter(content)
264
+
265
+ const confidence = typeof meta.confidence === 'number'
266
+ ? meta.confidence
267
+ : parseFloat(meta.confidence) || 0.5
268
+
269
+ const daysSince = daysSinceLastObserved(meta.lastObserved, fileInfo.path)
270
+ const status = classifyStatus(confidence, daysSince, staleDays)
271
+
272
+ return {
273
+ id: meta.id || path.basename(fileInfo.path, '.md'),
274
+ file: path.basename(fileInfo.path),
275
+ category: fileInfo.category,
276
+ scope: fileInfo.scope,
277
+ projectId: fileInfo.projectId,
278
+ confidence,
279
+ domain: meta.domain || 'unknown',
280
+ lastObserved: meta.lastObserved || 'N/A',
281
+ daysSinceObserved: daysSince,
282
+ status,
283
+ suggestion: getSuggestion(status, confidence, daysSince)
284
+ }
285
+ }
286
+
287
+ /**
288
+ * 根据证据对直觉进行分类
289
+ */
290
+ function classifyStatus(confidence, daysSince, staleDays) {
291
+ if (daysSince !== null && daysSince <= staleDays) {
292
+ return 'active'
293
+ }
294
+ if (confidence <= 0.3) {
295
+ return 'low-evidence'
296
+ }
297
+ if (daysSince !== null && daysSince > staleDays) {
298
+ return 'stale'
299
+ }
300
+ return 'active'
301
+ }
302
+
303
+ /**
304
+ * 根据状态生成操作建议
305
+ */
306
+ function getSuggestion(status, confidence, daysSince) {
307
+ switch (status) {
308
+ case 'active':
309
+ return '保持现状,置信度有近期证据支持'
310
+ case 'stale':
311
+ if (confidence >= 0.7) {
312
+ return `${daysSince} 天未观察,但置信度高 - 建议人工确认是否仍适用`
313
+ }
314
+ return `${daysSince} 天未观察 - 建议验证或考虑移除`
315
+ case 'low-evidence':
316
+ return '证据不足,建议在实践中验证后再决定保留或移除'
317
+ default:
318
+ return '请人工评估'
319
+ }
320
+ }
321
+
322
+ // --- 报告输出 ---
323
+
324
+ function printTextReport(results, staleDays) {
325
+ const grouped = {
326
+ active: results.filter(r => r.status === 'active'),
327
+ stale: results.filter(r => r.status === 'stale'),
328
+ 'low-evidence': results.filter(r => r.status === 'low-evidence')
329
+ }
330
+
331
+ console.log('[Review] 置信度审查报告')
332
+ console.log(`[Review] 过期阈值: ${staleDays} 天`)
333
+ console.log(`[Review] 扫描直觉: ${results.length} 个`)
334
+ console.log(`[Review] 范围: ${formatScopes(results)}`)
335
+ console.log('')
336
+
337
+ printSection('活跃', grouped.active, '近期有观察证据')
338
+ printSection('待审查', grouped.stale, '超过阈值天数未观察')
339
+ printSection('低证据', grouped['low-evidence'], '置信度低且缺乏证据')
340
+
341
+ console.log('---')
342
+ console.log(
343
+ `[Review] 总结: ${grouped.active.length} 活跃, ` +
344
+ `${grouped.stale.length} 待审查, ` +
345
+ `${grouped['low-evidence'].length} 低证据`
346
+ )
347
+
348
+ if (grouped.stale.length > 0 || grouped['low-evidence'].length > 0) {
349
+ console.log('')
350
+ console.log(
351
+ '[Review] 提示: 使用 /instinct-status 查看详情,' +
352
+ '手动决定是否保留、更新或移除'
353
+ )
354
+ }
355
+
356
+ console.log('')
357
+ console.log('[Review] 注意: 此报告不会修改任何文件。')
358
+ }
359
+
360
+ function formatScopes(results) {
361
+ const counts = {}
362
+ for (const item of results) {
363
+ counts[item.scope || 'unknown'] = (counts[item.scope || 'unknown'] || 0) + 1
364
+ }
365
+ return Object.entries(counts)
366
+ .map(([scope, count]) => `${scope}=${count}`)
367
+ .join(', ') || 'none'
368
+ }
369
+
370
+ function printSection(label, items, description) {
371
+ if (items.length === 0) return
372
+
373
+ console.log(`## ${label} (${items.length}) - ${description}`)
374
+ console.log('')
375
+ console.log('| 直觉 | 范围 | 置信度 | 领域 | 最后观察 | 建议 |')
376
+ console.log('|------|------|--------|------|----------|------|')
377
+
378
+ for (const item of items) {
379
+ console.log(
380
+ `| ${item.id} | ${item.scope || 'unknown'} | ${item.confidence} | ` +
381
+ `${item.domain} | ${item.lastObserved} | ` +
382
+ `${item.suggestion} |`
383
+ )
384
+ }
385
+ console.log('')
386
+ }
387
+
388
+ function printJsonReport(results, staleDays) {
389
+ const report = {
390
+ generated: new Date().toISOString(),
391
+ staleThresholdDays: staleDays,
392
+ totalInstincts: results.length,
393
+ scopes: results.reduce((acc, item) => {
394
+ const scope = item.scope || 'unknown'
395
+ acc[scope] = (acc[scope] || 0) + 1
396
+ return acc
397
+ }, {}),
398
+ summary: {
399
+ active: results.filter(r => r.status === 'active').length,
400
+ stale: results.filter(r => r.status === 'stale').length,
401
+ lowEvidence: results.filter(r => r.status === 'low-evidence').length
402
+ },
403
+ instincts: results,
404
+ note: '此报告不会修改任何文件的置信度值'
405
+ }
406
+ console.log(JSON.stringify(report, null, 2))
407
+ }
408
+
409
+ // --- 主函数 ---
410
+
411
+ function main() {
412
+ const options = parseArgs()
413
+ const { staleDays: cliStaleDays, jsonOutput, customPath } = options
414
+ const staleDays = loadStaleDays(cliStaleDays)
415
+ const instinctsPath = findInstinctsPath(customPath)
416
+
417
+ if (!jsonOutput) {
418
+ console.log(customPath
419
+ ? `[Review] 直觉目录: ${instinctsPath}`
420
+ : `[Review] 数据根目录: ${getDataRoot(loadConfig())}`
421
+ )
422
+ console.log('')
423
+ }
424
+
425
+ const files = collectInstinctFiles(options)
426
+
427
+ if (files.length === 0) {
428
+ if (jsonOutput) {
429
+ printJsonReport([], staleDays)
430
+ } else {
431
+ console.log('[Review] 未找到直觉文件')
432
+ }
433
+ return
434
+ }
435
+
436
+ const results = []
437
+ for (const fileInfo of files) {
438
+ try {
439
+ results.push(analyzeInstinct(fileInfo, staleDays))
440
+ } catch (error) {
441
+ console.error(
442
+ `[Review] 分析 ${path.basename(fileInfo.path)} 失败:`,
443
+ error.message
444
+ )
445
+ }
446
+ }
447
+
448
+ if (jsonOutput) {
449
+ printJsonReport(results, staleDays)
450
+ } else {
451
+ printTextReport(results, staleDays)
452
+ }
453
+ }
454
+
455
+ main()