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,143 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Pre-commit 质量门 Hook
4
+ *
5
+ * 在 git commit 前执行质量检查:
6
+ * - 检查 staged 文件中的 console.log / debugger
7
+ * - 校验 commit message 格式
8
+ * - 检测硬编码密钥模式
9
+ *
10
+ * 退出码: 2 = 阻止提交, 0 = 仅警告
11
+ */
12
+
13
+ 'use strict'
14
+
15
+ const COMMIT_PATTERN = /^git\s+commit/
16
+ const SECRET_PATTERNS = [
17
+ /(?:api[_-]?key|apikey)\s*[:=]\s*['"][a-zA-Z0-9]{16,}/i,
18
+ /(?:secret|password|passwd|pwd)\s*[:=]\s*['"][^'"]{8,}/i,
19
+ /(?:token)\s*[:=]\s*['"][a-zA-Z0-9_\-.]{20,}/i,
20
+ /(?:AKIA|AGPA|AIDA|AROA|AIPA)[A-Z0-9]{12,}/
21
+ ]
22
+ const DEBUG_PATTERNS = [
23
+ /\bconsole\.log\b/,
24
+ /\bdebugger\b/
25
+ ]
26
+ const COMMIT_MSG_REGEX = /^(feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert)(\(.+\))?:\s.+/
27
+
28
+ /**
29
+ * Hook 入口 - 支持 run-with-flags.js 直接调用
30
+ * @param {string} raw - stdin 原始 JSON
31
+ * @returns {{ exitCode: number, stderr: string }}
32
+ */
33
+ function run(raw) {
34
+ let input
35
+ try {
36
+ input = JSON.parse(raw)
37
+ } catch {
38
+ return { exitCode: 0 }
39
+ }
40
+
41
+ const command = input.tool_input?.command || ''
42
+
43
+ // 仅拦截 git commit 命令
44
+ if (!COMMIT_PATTERN.test(command)) {
45
+ return { exitCode: 0 }
46
+ }
47
+
48
+ const warnings = []
49
+ let shouldBlock = false
50
+
51
+ // 检查 commit message 格式 (如果通过 -m 提供)
52
+ const msgMatch = command.match(/-m\s+['"]([^'"]+)['"]/)
53
+ if (msgMatch) {
54
+ const msg = msgMatch[1]
55
+ if (!COMMIT_MSG_REGEX.test(msg)) {
56
+ warnings.push(
57
+ `[Hook] Commit message 格式不符合规范: "${msg}"\n` +
58
+ '[Hook] 格式: <type>(<scope>): <description>\n' +
59
+ '[Hook] type: feat|fix|docs|style|refactor|perf|test|chore'
60
+ )
61
+ }
62
+ }
63
+
64
+ // 检测密钥和调试代码(通过 git diff --cached)
65
+ const checkPatterns = (content, filePath) => {
66
+ const lines = content.split('\n')
67
+ for (let i = 0; i < lines.length; i++) {
68
+ const line = lines[i]
69
+ // 仅检查新增行
70
+ if (!line.startsWith('+') || line.startsWith('+++')) continue
71
+
72
+ for (const pattern of SECRET_PATTERNS) {
73
+ if (pattern.test(line)) {
74
+ warnings.push(
75
+ `[Hook] 检测到疑似密钥: ${filePath}:${i + 1}`
76
+ )
77
+ shouldBlock = true
78
+ }
79
+ }
80
+
81
+ for (const pattern of DEBUG_PATTERNS) {
82
+ if (pattern.test(line)) {
83
+ warnings.push(
84
+ `[Hook] 检测到调试代码: ${filePath}:${i + 1} ` +
85
+ `(${line.trim().substring(0, 60)})`
86
+ )
87
+ }
88
+ }
89
+ }
90
+ }
91
+
92
+ // 尝试检查 staged 内容
93
+ try {
94
+ const { execSync } = require('child_process')
95
+ const diff = execSync('git diff --cached --unified=0', {
96
+ encoding: 'utf8',
97
+ timeout: 10000
98
+ })
99
+
100
+ let currentFile = ''
101
+ for (const line of diff.split('\n')) {
102
+ if (line.startsWith('diff --git')) {
103
+ const match = line.match(/b\/(.+)$/)
104
+ if (match) currentFile = match[1]
105
+ }
106
+ }
107
+
108
+ checkPatterns(diff, currentFile)
109
+ } catch {
110
+ // git 不可用时跳过
111
+ }
112
+
113
+ if (warnings.length === 0) {
114
+ return { exitCode: 0 }
115
+ }
116
+
117
+ const stderr = warnings.join('\n') + '\n'
118
+
119
+ if (shouldBlock) {
120
+ return {
121
+ exitCode: 2,
122
+ stderr: stderr +
123
+ '[Hook] 提交被阻止: 请移除密钥后重试\n'
124
+ }
125
+ }
126
+
127
+ return { exitCode: 0, stderr }
128
+ }
129
+
130
+ module.exports = { run }
131
+
132
+ // 支持独立运行
133
+ if (require.main === module) {
134
+ let data = ''
135
+ process.stdin.setEncoding('utf8')
136
+ process.stdin.on('data', chunk => { data += chunk })
137
+ process.stdin.on('end', () => {
138
+ const result = run(data)
139
+ if (result.stderr) process.stderr.write(result.stderr)
140
+ if (result.stdout) process.stdout.write(result.stdout)
141
+ process.exit(result.exitCode || 0)
142
+ })
143
+ }
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Evaluate Session Hook
4
+ *
5
+ * 会话结束时评估是否有可提取的模式
6
+ * 用于 Stop hook
7
+ */
8
+
9
+ const path = require('path')
10
+ const fs = require('fs')
11
+ const os = require('os')
12
+
13
+ function getLearnedSkillsDir() {
14
+ return path.join(os.homedir(), '.claude', 'skills', 'learn')
15
+ }
16
+
17
+ function ensureDir(dir) {
18
+ if (!fs.existsSync(dir)) {
19
+ fs.mkdirSync(dir, { recursive: true })
20
+ }
21
+ }
22
+
23
+ async function main() {
24
+ // 默认配置
25
+ const minSessionLength = 10
26
+ const learnedSkillsPath = getLearnedSkillsDir()
27
+
28
+ // 确保学习技能根目录存在;具体技能保存到分类子目录
29
+ ensureDir(learnedSkillsPath)
30
+
31
+ // 获取会话记录路径
32
+ const transcriptPath = process.env.CLAUDE_TRANSCRIPT_PATH
33
+
34
+ if (!transcriptPath || !fs.existsSync(transcriptPath)) {
35
+ process.exit(0)
36
+ }
37
+
38
+ // 计算用户消息数量
39
+ const content = fs.readFileSync(transcriptPath, 'utf8')
40
+ const messageCount = (content.match(/"type":"user"/g) || []).length
41
+
42
+ // 跳过短会话
43
+ if (messageCount < minSessionLength) {
44
+ console.error(`[ContinuousLearning] 会话过短 (${messageCount} 消息),跳过`)
45
+ process.exit(0)
46
+ }
47
+
48
+ // 提示开始评估
49
+ console.error(`[ContinuousLearning] 会话有 ${messageCount} 消息 - 评估可提取模式`)
50
+ console.error(`[ContinuousLearning] 保存技能到分类目录: ${path.join(learnedSkillsPath, '<category>')}`)
51
+ console.error('[ContinuousLearning] 提示: 使用 /learn 手动提取有价值的模式')
52
+
53
+ process.exit(0)
54
+ }
55
+
56
+ main().catch(err => {
57
+ console.error('[ContinuousLearning] 错误:', err.message)
58
+ process.exit(0)
59
+ })
@@ -0,0 +1,92 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * PreCompact Hook
4
+ *
5
+ * 在上下文压缩前保存关键信息
6
+ * 用于 PreCompact hook
7
+ */
8
+
9
+ const fs = require('fs')
10
+ const path = require('path')
11
+ const os = require('os')
12
+ const crypto = require('crypto')
13
+ const { execFileSync } = require('child_process')
14
+
15
+ function getCompactLogPath() {
16
+ const claudeDir = path.join(os.homedir(), '.claude')
17
+ return path.join(claudeDir, 'compact-history.jsonl')
18
+ }
19
+
20
+ function ensureDir(filePath) {
21
+ const dir = path.dirname(filePath)
22
+ if (!fs.existsSync(dir)) {
23
+ fs.mkdirSync(dir, { recursive: true })
24
+ }
25
+ }
26
+
27
+ function getProjectContext(input) {
28
+ const cwd = input.cwd || process.cwd()
29
+ let projectRoot = cwd
30
+
31
+ try {
32
+ projectRoot = execFileSync('git', ['rev-parse', '--show-toplevel'], {
33
+ cwd,
34
+ encoding: 'utf8',
35
+ timeout: 1000,
36
+ windowsHide: true,
37
+ stdio: ['ignore', 'pipe', 'ignore']
38
+ }).trim()
39
+ } catch {
40
+ projectRoot = path.resolve(cwd)
41
+ }
42
+
43
+ const projectId = crypto
44
+ .createHash('sha1')
45
+ .update(projectRoot.toLowerCase())
46
+ .digest('hex')
47
+ .slice(0, 12)
48
+
49
+ return {
50
+ cwd,
51
+ project_root: projectRoot,
52
+ project_name: path.basename(projectRoot),
53
+ project_id: projectId
54
+ }
55
+ }
56
+
57
+ async function main() {
58
+ let data = ''
59
+
60
+ process.stdin.on('data', chunk => {
61
+ data += chunk
62
+ })
63
+
64
+ process.stdin.on('end', () => {
65
+ try {
66
+ const input = JSON.parse(data)
67
+
68
+ // 记录压缩事件
69
+ const compactLog = {
70
+ timestamp: new Date().toISOString(),
71
+ session_id: input.session_id,
72
+ ...getProjectContext(input),
73
+ context_size: input.context_size || 'unknown',
74
+ message_count: input.message_count || 'unknown'
75
+ }
76
+
77
+ const logPath = getCompactLogPath()
78
+ ensureDir(logPath)
79
+
80
+ fs.appendFileSync(logPath, JSON.stringify(compactLog) + '\n')
81
+
82
+ // 提示用户
83
+ console.error('[PreCompact] 上下文即将压缩,关键信息已保存')
84
+ console.error(`[PreCompact] 当前消息数: ${compactLog.message_count}`)
85
+
86
+ } catch (error) {
87
+ console.error(`[PreCompact] 保存失败: ${error.message}`)
88
+ }
89
+ })
90
+ }
91
+
92
+ main()
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Hook Profile 标志控制
3
+ * 通过环境变量控制 Hook 启用/禁用
4
+ *
5
+ * 环境变量:
6
+ * ECC_HOOK_PROFILE - minimal | standard | strict (默认: standard)
7
+ * ECC_DISABLED_HOOKS - 逗号分隔的 Hook ID 列表
8
+ */
9
+
10
+ 'use strict'
11
+
12
+ /**
13
+ * 检查指定 Hook 是否启用
14
+ * @param {string} hookId - Hook 唯一标识 (如 "pre:bash:commit-quality")
15
+ * @param {object} options
16
+ * @param {string} options.profiles - 逗号分隔的允许 Profile 列表
17
+ * @returns {boolean}
18
+ */
19
+ function isHookEnabled(hookId, options = {}) {
20
+ // 检查是否被显式禁用
21
+ const disabled = (process.env.ECC_DISABLED_HOOKS || '')
22
+ .split(',')
23
+ .map(s => s.trim())
24
+ .filter(Boolean)
25
+
26
+ if (disabled.includes(hookId)) {
27
+ return false
28
+ }
29
+
30
+ // 检查 Profile 匹配
31
+ const { profiles = 'standard,strict' } = options
32
+ const allowedProfiles = profiles.split(',').map(s => s.trim())
33
+ const currentProfile = (
34
+ process.env.ECC_HOOK_PROFILE || 'standard'
35
+ ).trim().toLowerCase()
36
+
37
+ return allowedProfiles.includes(currentProfile)
38
+ }
39
+
40
+ module.exports = { isHookEnabled }
@@ -0,0 +1,141 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Hook 运行时控制器
4
+ *
5
+ * 根据 Hook Profile 决定是否执行目标脚本
6
+ * 支持 require() 直接加载(省去子进程开销)和 legacy spawnSync 两种模式
7
+ *
8
+ * 用法:
9
+ * node run-with-flags.js <hookId> <scriptRelativePath> [profilesCsv] [...scriptArgs]
10
+ */
11
+
12
+ 'use strict'
13
+
14
+ const fs = require('fs')
15
+ const path = require('path')
16
+ const { spawnSync } = require('child_process')
17
+ const { isHookEnabled } = require('./hook-flags')
18
+
19
+ const MAX_STDIN = 1024 * 1024
20
+
21
+ function readStdinRaw() {
22
+ return new Promise(resolve => {
23
+ let raw = ''
24
+ let truncated = false
25
+ process.stdin.setEncoding('utf8')
26
+
27
+ process.stdin.on('data', chunk => {
28
+ if (raw.length < MAX_STDIN) {
29
+ const remaining = MAX_STDIN - raw.length
30
+ raw += chunk.substring(0, remaining)
31
+ if (chunk.length > remaining) truncated = true
32
+ } else {
33
+ truncated = true
34
+ }
35
+ })
36
+
37
+ process.stdin.on('end', () => resolve({ raw, truncated }))
38
+ process.stdin.on('error', () => resolve({ raw, truncated }))
39
+ })
40
+ }
41
+
42
+ function getPluginRoot() {
43
+ if (process.env.CLAUDE_PLUGIN_ROOT) {
44
+ return process.env.CLAUDE_PLUGIN_ROOT
45
+ }
46
+ return path.resolve(__dirname, '..', '..')
47
+ }
48
+
49
+ async function main() {
50
+ const [, , hookId, relScriptPath, profilesCsv, ...scriptArgs] = process.argv
51
+ const { raw } = await readStdinRaw()
52
+
53
+ if (!hookId || !relScriptPath) {
54
+ process.exit(0)
55
+ }
56
+
57
+ // Profile 检查
58
+ if (!isHookEnabled(hookId, { profiles: profilesCsv })) {
59
+ process.exit(0)
60
+ }
61
+
62
+ const pluginRoot = getPluginRoot()
63
+ const resolvedRoot = path.resolve(pluginRoot)
64
+ const scriptPath = path.resolve(pluginRoot, relScriptPath)
65
+
66
+ // 路径遍历安全校验
67
+ if (!scriptPath.startsWith(resolvedRoot + path.sep)) {
68
+ process.stderr.write(
69
+ `[Hook] Path traversal rejected: ${hookId}\n`
70
+ )
71
+ process.exit(0)
72
+ }
73
+
74
+ if (!fs.existsSync(scriptPath)) {
75
+ process.stderr.write(
76
+ `[Hook] Script not found for ${hookId}: ${scriptPath}\n`
77
+ )
78
+ process.exit(0)
79
+ }
80
+
81
+ // 优先尝试 require() 直接加载(性能优化)
82
+ const src = fs.readFileSync(scriptPath, 'utf8')
83
+ const hasRunExport = /\bmodule\.exports\b/.test(src)
84
+ && /\brun\b/.test(src)
85
+
86
+ if (hasRunExport) {
87
+ try {
88
+ const hookModule = require(scriptPath)
89
+ if (typeof hookModule.run === 'function') {
90
+ const output = await hookModule.run(raw, {
91
+ hookId,
92
+ scriptArgs
93
+ })
94
+
95
+ if (typeof output === 'string') {
96
+ process.stdout.write(output)
97
+ process.exit(0)
98
+ }
99
+
100
+ if (output && typeof output === 'object') {
101
+ if (typeof output.stdout === 'string') {
102
+ process.stdout.write(output.stdout)
103
+ }
104
+ if (typeof output.stderr === 'string') {
105
+ process.stderr.write(output.stderr)
106
+ }
107
+
108
+ const exitCode = Number.isInteger(output.exitCode)
109
+ ? output.exitCode
110
+ : 0
111
+ process.exit(exitCode)
112
+ }
113
+
114
+ process.exit(0)
115
+ }
116
+ } catch (err) {
117
+ process.stderr.write(
118
+ `[Hook] require() failed for ${hookId}: ${err.message}\n`
119
+ )
120
+ }
121
+ }
122
+
123
+ // Fallback: spawnSync 子进程执行
124
+ const result = spawnSync(process.execPath, [scriptPath, ...scriptArgs], {
125
+ input: raw,
126
+ encoding: 'utf8',
127
+ cwd: process.cwd(),
128
+ timeout: 30000
129
+ })
130
+
131
+ if (result.stdout) process.stdout.write(result.stdout)
132
+ if (result.stderr) process.stderr.write(result.stderr)
133
+
134
+ const exitCode = Number.isInteger(result.status) ? result.status : 0
135
+ process.exit(exitCode)
136
+ }
137
+
138
+ main().catch(err => {
139
+ process.stderr.write(`[Hook] run-with-flags error: ${err.message}\n`)
140
+ process.exit(0)
141
+ })
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Session Hook 共享工具
3
+ */
4
+
5
+ 'use strict'
6
+
7
+ const fs = require('fs')
8
+ const os = require('os')
9
+ const path = require('path')
10
+
11
+ function getHomeDir() {
12
+ const explicit = process.env.HOME || process.env.USERPROFILE
13
+ if (explicit && explicit.trim().length > 0) {
14
+ return path.resolve(explicit)
15
+ }
16
+ return os.homedir()
17
+ }
18
+
19
+ function getClaudeDir() {
20
+ return path.join(getHomeDir(), '.claude')
21
+ }
22
+
23
+ function ensureDir(dirPath) {
24
+ if (!fs.existsSync(dirPath)) {
25
+ fs.mkdirSync(dirPath, { recursive: true })
26
+ }
27
+ return dirPath
28
+ }
29
+
30
+ function getDateTimeString() {
31
+ const now = new Date()
32
+ const y = now.getFullYear()
33
+ const m = String(now.getMonth() + 1).padStart(2, '0')
34
+ const d = String(now.getDate()).padStart(2, '0')
35
+ const h = String(now.getHours()).padStart(2, '0')
36
+ const min = String(now.getMinutes()).padStart(2, '0')
37
+ const s = String(now.getSeconds()).padStart(2, '0')
38
+ return `${y}-${m}-${d} ${h}:${min}:${s}`
39
+ }
40
+
41
+ module.exports = {
42
+ ensureDir,
43
+ getClaudeDir,
44
+ getDateTimeString
45
+ }
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Session End Hook
4
+ *
5
+ * 会话结束时持久化状态
6
+ * 用于 SessionEnd hook 或手动调用
7
+ */
8
+
9
+ 'use strict'
10
+
11
+ const fs = require('fs')
12
+ const path = require('path')
13
+
14
+ function getSessionDir() {
15
+ const utils = require('./runtime/session-utils')
16
+ return utils.ensureDir(
17
+ path.join(utils.getClaudeDir(), 'session-data')
18
+ )
19
+ }
20
+
21
+ function getProjectName() {
22
+ try {
23
+ const { execSync } = require('child_process')
24
+ const toplevel = execSync('git rev-parse --show-toplevel', {
25
+ encoding: 'utf8',
26
+ timeout: 5000
27
+ }).trim()
28
+ return path.basename(toplevel)
29
+ } catch {
30
+ return path.basename(process.cwd()) || 'unknown'
31
+ }
32
+ }
33
+
34
+ function run() {
35
+ const sessionDir = getSessionDir()
36
+ const stateFile = path.join(sessionDir, 'last-state.json')
37
+
38
+ const utils = require('./runtime/session-utils')
39
+ const state = {
40
+ project: getProjectName(),
41
+ lastActive: utils.getDateTimeString(),
42
+ cwd: process.cwd(),
43
+ sessionId: process.env.CLAUDE_SESSION_ID || null
44
+ }
45
+
46
+ try {
47
+ fs.writeFileSync(stateFile, JSON.stringify(state, null, 2), 'utf8')
48
+ process.stderr.write(
49
+ `[Session] 状态已保存: ${stateFile}\n`
50
+ )
51
+ } catch (err) {
52
+ process.stderr.write(
53
+ `[Session] 保存状态失败: ${err.message}\n`
54
+ )
55
+ }
56
+ }
57
+
58
+ module.exports = { run }
59
+
60
+ if (require.main === module) {
61
+ run()
62
+ }
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Session Start Hook
4
+ *
5
+ * 会话启动时加载上次上下文
6
+ * 用于 SessionStart 或手动调用
7
+ */
8
+
9
+ 'use strict'
10
+
11
+ const fs = require('fs')
12
+ const path = require('path')
13
+
14
+ function getSessionDir() {
15
+ const utils = require('./runtime/session-utils')
16
+ return path.join(utils.getClaudeDir(), 'session-data')
17
+ }
18
+
19
+ function run() {
20
+ const sessionDir = getSessionDir()
21
+ const stateFile = path.join(sessionDir, 'last-state.json')
22
+
23
+ if (!fs.existsSync(stateFile)) {
24
+ process.stderr.write(
25
+ '[Session] 无上次会话状态,以全新会话启动\n'
26
+ )
27
+ return
28
+ }
29
+
30
+ try {
31
+ const state = JSON.parse(fs.readFileSync(stateFile, 'utf8'))
32
+ const parts = []
33
+
34
+ if (state.project) {
35
+ parts.push(`项目: ${state.project}`)
36
+ }
37
+ if (state.lastActive) {
38
+ parts.push(`上次活动: ${state.lastActive}`)
39
+ }
40
+ if (state.pendingTasks && state.pendingTasks.length > 0) {
41
+ parts.push(`待处理: ${state.pendingTasks.join(', ')}`)
42
+ }
43
+
44
+ if (parts.length > 0) {
45
+ process.stderr.write(
46
+ `[Session] 恢复上下文 - ${parts.join(' | ')}\n`
47
+ )
48
+ }
49
+ } catch (err) {
50
+ process.stderr.write(
51
+ `[Session] 加载上次状态失败: ${err.message}\n`
52
+ )
53
+ }
54
+ }
55
+
56
+ module.exports = { run }
57
+
58
+ if (require.main === module) {
59
+ run()
60
+ }
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "claude-everything-workflow",
3
+ "version": "0.1.0",
4
+ "description": "Claude Code and Codex harness with rules, skills, agents, hooks, and verification gates.",
5
+ "keywords": [
6
+ "claude-code",
7
+ "codex",
8
+ "agents",
9
+ "harness",
10
+ "skills"
11
+ ],
12
+ "license": "MIT",
13
+ "type": "commonjs",
14
+ "bin": {
15
+ "claude-everything-workflow": "bin/claude-everything-workflow.js",
16
+ "cew": "bin/claude-everything-workflow.js"
17
+ },
18
+ "scripts": {
19
+ "verify": "node scripts/verify-harness.js",
20
+ "pack:dry-run": "npm pack --dry-run"
21
+ },
22
+ "files": [
23
+ "AGENTS.md",
24
+ "CLAUDE.md",
25
+ "LICENSE",
26
+ "README.md",
27
+ "settings.json",
28
+ "agents/",
29
+ "bin/",
30
+ "commands/",
31
+ "hooks/",
32
+ "homunculus/",
33
+ "references/",
34
+ "rules/",
35
+ "scripts/",
36
+ "skills/"
37
+ ],
38
+ "engines": {
39
+ "node": ">=18"
40
+ },
41
+ "publishConfig": {
42
+ "access": "public"
43
+ },
44
+ "repository": {
45
+ "type": "git",
46
+ "url": "git+https://github.com/xu91102/claude-everything-Workflow.git"
47
+ }
48
+ }