claude-everything-workflow 0.1.9 → 0.2.3

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 (152) hide show
  1. package/AGENTS.md +20 -20
  2. package/CLAUDE.md +1 -5
  3. package/README.md +151 -113
  4. package/agents/e2e-runner.md +8 -141
  5. package/agents/harness-optimizer.md +3 -2
  6. package/commands/code-review.md +10 -15
  7. package/commands/learn.md +97 -0
  8. package/commands/pr.md +5 -6
  9. package/commands/to-spec.md +11 -0
  10. package/commands/verify.md +7 -11
  11. package/harness/manifest.json +346 -0
  12. package/hooks/check-code-size.js +33 -12
  13. package/hooks/check-console-log.js +72 -24
  14. package/package.json +10 -2
  15. package/rules/01-base.md +9 -49
  16. package/rules/02-code-size.md +5 -20
  17. package/rules/03-architecture.md +9 -61
  18. package/rules/04-error-handling.md +4 -26
  19. package/rules/05-git-workflow.md +12 -39
  20. package/rules/06-comments.md +3 -43
  21. package/rules/07-forbidden.md +8 -31
  22. package/rules/08-specialty-rules-index.md +18 -0
  23. package/rules/09-first-principles-adversarial-testing.md +6 -18
  24. package/rules/common/agent-orchestration.md +8 -47
  25. package/rules/common/context-hygiene.md +9 -72
  26. package/rules/common/harness-engineering.md +11 -38
  27. package/rules/common/hooks.md +13 -82
  28. package/rules/common/performance.md +8 -71
  29. package/rules/common/pr-automation.md +7 -68
  30. package/rules/common/skills-learning.md +12 -36
  31. package/rules/common/testing.md +16 -59
  32. package/scripts/cleanup-retired-skills.js +214 -0
  33. package/scripts/install-rules.js +100 -0
  34. package/scripts/install.ps1 +99 -87
  35. package/scripts/install.sh +77 -78
  36. package/scripts/learning/review-confidence.js +1 -4
  37. package/scripts/legacy-common-rule-hashes.json +78 -0
  38. package/scripts/merge-claude-settings.cjs +75 -0
  39. package/scripts/retired-skill-files.json +54 -0
  40. package/scripts/upstream-capability-baseline.json +27 -0
  41. package/scripts/upstream-capability-map.json +155 -0
  42. package/scripts/verify/core.js +91 -0
  43. package/scripts/verify/grilling-spec-gate-checks.js +266 -0
  44. package/scripts/verify/install-rules.test.js +156 -0
  45. package/scripts/verify/metadata-checks.js +747 -0
  46. package/scripts/verify/repository-checks.js +409 -0
  47. package/scripts/verify/runtime-checks.js +593 -0
  48. package/scripts/verify/skill-invocation.test.js +86 -0
  49. package/scripts/verify/skill-manifest-checks.js +197 -0
  50. package/scripts/verify/skill-manifest-checks.test.js +123 -0
  51. package/scripts/verify/workflow-checks.js +685 -0
  52. package/scripts/verify/workflow-ownership-fixtures.js +371 -0
  53. package/scripts/verify/workflow-ownership.js +780 -0
  54. package/scripts/verify-harness.js +18 -1075
  55. package/scripts/verify-upstream-capability-map.js +118 -0
  56. package/skills/README.md +28 -16
  57. package/skills/code-review/SKILL.md +63 -0
  58. package/skills/code-review/references/spec-reviewer-prompt.md +24 -0
  59. package/skills/code-review/references/standards-reviewer-prompt.md +35 -0
  60. package/skills/codebase-design/SKILL.md +63 -0
  61. package/skills/codebase-design/references/deepening.md +27 -0
  62. package/skills/codebase-design/references/design-it-twice.md +17 -0
  63. package/skills/continuous-learning-v2/SKILL.md +8 -8
  64. package/skills/continuous-learning-v2/config.json +0 -4
  65. package/skills/domain-modeling/SKILL.md +101 -0
  66. package/skills/e2e-testing/SKILL.md +20 -310
  67. package/skills/e2e-testing/references/playwright-patterns.md +324 -0
  68. package/skills/feature-acceptance/SKILL.md +89 -0
  69. package/skills/grilling/SKILL.md +83 -0
  70. package/skills/handoff/SKILL.md +55 -0
  71. package/skills/handoff/agents/openai.yaml +2 -0
  72. package/skills/implement/SKILL.md +48 -0
  73. package/skills/implement/references/ticket-delivery.md +43 -0
  74. package/skills/improve-codebase-architecture/SKILL.md +47 -0
  75. package/skills/improve-codebase-architecture/agents/openai.yaml +2 -0
  76. package/skills/iterative-retrieval/SKILL.md +10 -1
  77. package/skills/learn/README.md +2 -2
  78. package/skills/prototype/SKILL.md +50 -0
  79. package/skills/prototype/references/logic.md +28 -0
  80. package/skills/prototype/references/ui.md +30 -0
  81. package/skills/resolving-merge-conflicts/SKILL.md +27 -0
  82. package/skills/spec-gate/SKILL.md +149 -0
  83. package/skills/spec-gate/agents/openai.yaml +4 -0
  84. package/skills/spec-gate/references/spec-document-reviewer-prompt.md +31 -0
  85. package/skills/subagent-driven-development/SKILL.md +95 -414
  86. package/skills/systematic-debugging/SKILL.md +11 -49
  87. package/skills/systematic-debugging/references/diagnosing-bugs.upstream.md +129 -0
  88. package/skills/systematic-debugging/scripts/hitl-loop.template.js +75 -0
  89. package/skills/systematic-debugging/scripts/hitl-loop.template.sh +41 -0
  90. package/skills/test-driven-development/SKILL.md +24 -4
  91. package/skills/to-tickets/SKILL.md +96 -0
  92. package/skills/triage/SKILL.md +53 -0
  93. package/skills/triage/agents/openai.yaml +2 -0
  94. package/skills/triage/references/agent-brief.md +32 -0
  95. package/skills/triage/references/out-of-scope.md +14 -0
  96. package/skills/using-git-worktrees/SKILL.md +8 -5
  97. package/skills/using-superpowers/SKILL.md +76 -43
  98. package/skills/using-superpowers/references/process-outcomes.md +41 -0
  99. package/skills/verification-before-completion/SKILL.md +5 -4
  100. package/skills/visual-companion/SKILL.md +62 -0
  101. package/skills/visual-companion/agents/openai.yaml +4 -0
  102. package/skills/{brainstorming/visual-companion.md → visual-companion/references/guide.md} +1 -1
  103. package/skills/{brainstorming → visual-companion}/scripts/frame-template.html +42 -12
  104. package/skills/visual-companion/scripts/pages.cjs +28 -0
  105. package/skills/visual-companion/scripts/server-utils.cjs +82 -0
  106. package/skills/{brainstorming → visual-companion}/scripts/server.cjs +108 -248
  107. package/skills/{brainstorming → visual-companion}/scripts/start-server.sh +18 -4
  108. package/skills/visual-companion/scripts/websocket.cjs +86 -0
  109. package/agents/architect.md +0 -59
  110. package/agents/code-reviewer.md +0 -57
  111. package/agents/planner.md +0 -124
  112. package/agents/tdd-guide.md +0 -101
  113. package/commands/e2e.md +0 -28
  114. package/commands/evolve.md +0 -42
  115. package/commands/harness-audit.md +0 -27
  116. package/commands/instinct-status.md +0 -38
  117. package/commands/learn-eval.md +0 -91
  118. package/commands/projects.md +0 -27
  119. package/commands/promote.md +0 -29
  120. package/commands/prune.md +0 -46
  121. package/commands/tdd.md +0 -27
  122. package/homunculus/instincts/personal/always-test-first.md +0 -28
  123. package/homunculus/instincts/personal/pr-ci-quality-gate.md +0 -30
  124. package/rules/08-ecc-integration.md +0 -46
  125. package/rules/common/implementation.md +0 -25
  126. package/rules/common/security.md +0 -19
  127. package/skills/brainstorming/SKILL.md +0 -185
  128. package/skills/brainstorming/agents/openai.yaml +0 -3
  129. package/skills/brainstorming/spec-document-reviewer-prompt.md +0 -49
  130. package/skills/context-budget/SKILL.md +0 -59
  131. package/skills/discover-unknowns-zh/SKILL.md +0 -112
  132. package/skills/discover-unknowns-zh/agents/openai.yaml +0 -4
  133. package/skills/discover-unknowns-zh/references/prompt-patterns.md +0 -144
  134. package/skills/documentation-lookup/SKILL.md +0 -90
  135. package/skills/executing-plans/SKILL.md +0 -66
  136. package/skills/find-skills/SKILL.md +0 -142
  137. package/skills/skill-creator/LICENSE.txt +0 -202
  138. package/skills/skill-creator/SKILL.md +0 -356
  139. package/skills/skill-creator/references/output-patterns.md +0 -82
  140. package/skills/skill-creator/references/workflows.md +0 -28
  141. package/skills/skill-creator/scripts/init_skill.py +0 -303
  142. package/skills/skill-creator/scripts/package_skill.py +0 -110
  143. package/skills/skill-creator/scripts/quick_validate.py +0 -95
  144. package/skills/subagent-driven-development/implementer-prompt.md +0 -139
  145. package/skills/subagent-driven-development/scripts/review-package +0 -44
  146. package/skills/subagent-driven-development/scripts/sdd-workspace +0 -22
  147. package/skills/subagent-driven-development/scripts/task-brief +0 -40
  148. package/skills/subagent-driven-development/task-reviewer-prompt.md +0 -188
  149. package/skills/writing-plans/SKILL.md +0 -206
  150. package/skills/writing-plans/plan-document-reviewer-prompt.md +0 -49
  151. /package/skills/{brainstorming → visual-companion}/scripts/helper.js +0 -0
  152. /package/skills/{brainstorming → visual-companion}/scripts/stop-server.sh +0 -0
@@ -74,90 +74,13 @@ function Copy-ClaudeSettings {
74
74
  Backup-IfChanged -Source $Source -Destination $Destination
75
75
 
76
76
  if ($DryRun) {
77
- Write-Host "[dry-run] Merge '$Source' into '$Destination' preserving existing env and mcpServers, purging legacy hook paths"
77
+ Write-Host "[dry-run] Merge '$Source' into '$Destination' preserving existing env and mcpServers"
78
+ Write-Host "[dry-run] Purge legacy hook paths while merging Claude settings"
78
79
  return
79
80
  }
80
81
 
81
- # 使用 Node 脚本合并 settings.json,同时清理旧版 Hook 路径
82
- $mergeScript = @'
83
- const fs = require('fs')
84
-
85
- const [, , sourcePath, destinationPath] = process.argv
86
- const source = JSON.parse(fs.readFileSync(sourcePath, 'utf8'))
87
- const existing = fs.existsSync(destinationPath)
88
- ? JSON.parse(fs.readFileSync(destinationPath, 'utf8'))
89
- : {}
90
-
91
- const LEGACY_HOOK_PATTERNS = [
92
- 'scripts/hooks/run-with-flags.js',
93
- 'scripts/hooks/commit-quality.js',
94
- 'scripts/hooks/session-start.js',
95
- 'scripts/hooks/session-end.js',
96
- 'scripts/lib/hook-flags.js',
97
- 'scripts/lib/utils.js',
98
- 'hooks/observe.js',
99
- 'hooks/review-confidence.js',
100
- 'hooks/session-start.js',
101
- 'hooks/session-end.js',
102
- 'hooks/evaluate-session.js',
103
- 'hooks/pre-compact.js',
104
- 'hooks/runtime/session-utils.js'
105
- ]
106
-
107
- function isLegacyHook(hookDef) {
108
- if (typeof hookDef !== 'object' || !hookDef.command) return false
109
- return LEGACY_HOOK_PATTERNS.some(p => hookDef.command.includes(p))
110
- }
111
-
112
- function filterHooks(hooksArray) {
113
- if (!Array.isArray(hooksArray)) return hooksArray
114
- return hooksArray.map(entry => {
115
- if (!entry || !Array.isArray(entry.hooks)) return entry
116
- const filtered = entry.hooks.filter(h => !isLegacyHook(h))
117
- return { ...entry, hooks: filtered }
118
- }).filter(entry => entry.hooks && entry.hooks.length > 0)
119
- }
120
-
121
- function cleanHooks(hooksObj) {
122
- if (!hooksObj || typeof hooksObj !== 'object') return hooksObj
123
- const cleaned = {}
124
- for (const [eventType, entries] of Object.entries(hooksObj)) {
125
- const filtered = filterHooks(entries)
126
- if (filtered.length > 0) {
127
- cleaned[eventType] = filtered
128
- }
129
- }
130
- return cleaned
131
- }
132
-
133
- const merged = {
134
- ...existing,
135
- ...source,
136
- env: {
137
- ...(source.env || {}),
138
- ...(existing.env || {})
139
- },
140
- mcpServers: {
141
- ...(source.mcpServers || {}),
142
- ...(existing.mcpServers || {})
143
- },
144
- hooks: cleanHooks({
145
- ...(existing.hooks || {}),
146
- ...(source.hooks || {})
147
- })
148
- }
149
-
150
- fs.writeFileSync(destinationPath, JSON.stringify(merged, null, 2) + '\n')
151
- '@
152
-
153
- $scriptFile = [System.IO.Path]::GetTempFileName()
154
- Set-Content -LiteralPath $scriptFile -Value $mergeScript -Encoding UTF8
155
-
156
- try {
157
- & node $scriptFile $Source $Destination
158
- } finally {
159
- Remove-Item -LiteralPath $scriptFile -Force -ErrorAction SilentlyContinue
160
- }
82
+ $mergeScript = Join-Path $RootDir "scripts\merge-claude-settings.cjs"
83
+ & node $mergeScript $Source $Destination
161
84
  }
162
85
 
163
86
  function Convert-ClaudeSettingsHookPaths {
@@ -214,6 +137,11 @@ function Copy-DirectoryMerge {
214
137
  }
215
138
 
216
139
  $destDir = Join-Path $DestinationRoot $Name
140
+ $existingDest = Get-Item -LiteralPath $destDir -Force -ErrorAction SilentlyContinue
141
+ if ($null -ne $existingDest -and ($existingDest.Attributes -band [IO.FileAttributes]::ReparsePoint)) {
142
+ throw "Refusing to merge into symlinked destination: $destDir"
143
+ }
144
+
217
145
  Invoke-InstallCommand `
218
146
  -Description "New-Item -ItemType Directory '$destDir'" `
219
147
  -Action { New-Item -ItemType Directory -Path $destDir -Force | Out-Null }
@@ -227,14 +155,13 @@ function Install-SharedDirs {
227
155
  param([string]$Destination)
228
156
 
229
157
  $dirs = @(
230
- "rules",
231
158
  "agents",
232
159
  "commands",
233
160
  "scripts",
234
161
  "hooks",
235
162
  "skills",
236
- "homunculus",
237
- "references"
163
+ "references",
164
+ "harness"
238
165
  )
239
166
 
240
167
  foreach ($dir in $dirs) {
@@ -247,7 +174,22 @@ function Remove-PackageOnlyPaths {
247
174
 
248
175
  $packageOnlyFiles = @(
249
176
  "scripts\install.sh",
250
- "scripts\install.ps1"
177
+ "scripts\install.ps1",
178
+ "scripts\install-rules.js",
179
+ "scripts\legacy-common-rule-hashes.json",
180
+ "scripts\verify-harness.js",
181
+ "scripts\verify\core.js",
182
+ "scripts\verify\grilling-spec-gate-checks.js",
183
+ "scripts\verify\metadata-checks.js",
184
+ "scripts\verify\repository-checks.js",
185
+ "scripts\verify\runtime-checks.js",
186
+ "scripts\verify\workflow-checks.js",
187
+ "scripts\verify\workflow-ownership-fixtures.js",
188
+ "scripts\verify\workflow-ownership.js",
189
+ "scripts\verify\skill-manifest-checks.js",
190
+ "scripts\verify\skill-manifest-checks.test.js",
191
+ "scripts\verify\skill-invocation.test.js",
192
+ "scripts\verify\install-rules.test.js"
251
193
  )
252
194
 
253
195
  foreach ($relative in $packageOnlyFiles) {
@@ -258,12 +200,33 @@ function Remove-PackageOnlyPaths {
258
200
  -Action { Remove-Item -LiteralPath $target -Force }
259
201
  }
260
202
  }
203
+
204
+ $verifyDirectory = Join-Path $Destination "scripts\verify"
205
+ if (Test-Path -LiteralPath $verifyDirectory -PathType Container) {
206
+ $children = Get-ChildItem -LiteralPath $verifyDirectory -Force
207
+ if ($children.Count -eq 0) {
208
+ Invoke-InstallCommand `
209
+ -Description "Remove-Item '$verifyDirectory'" `
210
+ -Action { Remove-Item -LiteralPath $verifyDirectory -Force }
211
+ }
212
+ }
261
213
  }
262
214
 
263
215
  function Remove-ObsoleteWorkflowPaths {
264
216
  param([string]$Destination)
265
217
 
266
218
  $obsoleteFiles = @(
219
+ "commands\e2e.md",
220
+ "commands\evolve.md",
221
+ "commands\grill.md",
222
+ "commands\harness-audit.md",
223
+ "commands\instinct-status.md",
224
+ "commands\learn-eval.md",
225
+ "commands\projects.md",
226
+ "commands\promote.md",
227
+ "commands\prune.md",
228
+ "commands\setup-workflow.md",
229
+ "commands\tdd.md",
267
230
  "scripts\hooks\run-with-flags.js",
268
231
  "scripts\hooks\commit-quality.js",
269
232
  "scripts\hooks\session-start.js",
@@ -275,7 +238,13 @@ function Remove-ObsoleteWorkflowPaths {
275
238
  "hooks\session-end.js",
276
239
  "hooks\evaluate-session.js",
277
240
  "hooks\pre-compact.js",
278
- "hooks\runtime\session-utils.js"
241
+ "hooks\runtime\session-utils.js",
242
+ "rules\08-ecc-integration.md",
243
+ "skills\subagent-driven-development\implementer-prompt.md",
244
+ "skills\subagent-driven-development\task-reviewer-prompt.md",
245
+ "skills\subagent-driven-development\scripts\sdd-workspace",
246
+ "skills\subagent-driven-development\scripts\task-brief",
247
+ "skills\subagent-driven-development\scripts\review-package"
279
248
  )
280
249
 
281
250
  foreach ($relative in $obsoleteFiles) {
@@ -287,7 +256,7 @@ function Remove-ObsoleteWorkflowPaths {
287
256
  }
288
257
  }
289
258
 
290
- foreach ($relative in @("scripts\hooks", "scripts\lib")) {
259
+ foreach ($relative in @("scripts\hooks", "scripts\lib", "skills\subagent-driven-development\scripts")) {
291
260
  $target = Join-Path $Destination $relative
292
261
  if (Test-Path -LiteralPath $target -PathType Container) {
293
262
  $children = Get-ChildItem -LiteralPath $target -Force
@@ -300,6 +269,32 @@ function Remove-ObsoleteWorkflowPaths {
300
269
  }
301
270
  }
302
271
 
272
+ function Remove-RetiredSkills {
273
+ param([string]$Destination)
274
+
275
+ $cleanupScript = Join-Path $RootDir "scripts\cleanup-retired-skills.js"
276
+ if ($DryRun) {
277
+ & node $cleanupScript $Destination --dry-run
278
+ if ($LASTEXITCODE -ne 0) {
279
+ throw "Retired skill cleanup dry-run failed with exit code $LASTEXITCODE"
280
+ }
281
+ return
282
+ }
283
+
284
+ & node $cleanupScript $Destination
285
+ if ($LASTEXITCODE -ne 0) {
286
+ throw "Retired skill cleanup failed with exit code $LASTEXITCODE"
287
+ }
288
+ }
289
+
290
+ function Test-RetiredSkillManifest {
291
+ $cleanupScript = Join-Path $RootDir "scripts\cleanup-retired-skills.js"
292
+ & node $cleanupScript --validate
293
+ if ($LASTEXITCODE -ne 0) {
294
+ throw "Retired skill manifest validation failed with exit code $LASTEXITCODE"
295
+ }
296
+ }
297
+
303
298
  function Install-ClaudeWorkflow {
304
299
  $dest = Join-Path $HomeDir ".claude"
305
300
 
@@ -315,6 +310,8 @@ function Install-ClaudeWorkflow {
315
310
  Copy-ClaudeSettings -Source (Join-Path $RootDir "settings.json") -Destination $settingsPath
316
311
  Convert-ClaudeSettingsHookPaths -SettingsPath $settingsPath
317
312
  Install-SharedDirs -Destination $dest
313
+ Install-WorkflowRules -Destination $dest -HostName "claude-code"
314
+ Remove-RetiredSkills -Destination $dest
318
315
  Remove-PackageOnlyPaths -Destination $dest
319
316
  }
320
317
 
@@ -329,9 +326,24 @@ function Install-CodexWorkflow {
329
326
  Remove-ObsoleteWorkflowPaths -Destination $dest
330
327
  Copy-ConfigFile -Source (Join-Path $RootDir "AGENTS.md") -Destination (Join-Path $dest "AGENTS.md")
331
328
  Install-SharedDirs -Destination $dest
329
+ Install-WorkflowRules -Destination $dest -HostName "codex"
330
+ Remove-RetiredSkills -Destination $dest
332
331
  Remove-PackageOnlyPaths -Destination $dest
333
332
  }
334
333
 
334
+ function Install-WorkflowRules {
335
+ param([string]$Destination, [string]$HostName)
336
+
337
+ $ruleArgs = @((Join-Path $RootDir "scripts\install-rules.js"), $HostName, $Destination)
338
+ if ($DryRun) { $ruleArgs += "--dry-run" }
339
+ & node @ruleArgs
340
+ if ($LASTEXITCODE -ne 0) {
341
+ throw "Rule installation failed with exit code $LASTEXITCODE"
342
+ }
343
+ }
344
+
345
+ Test-RetiredSkillManifest
346
+
335
347
  if ($InstallClaude) {
336
348
  Install-ClaudeWorkflow
337
349
  }
@@ -86,82 +86,12 @@ copy_claude_settings() {
86
86
 
87
87
  backup_if_changed "$src" "$dest"
88
88
  if [ "$DRY_RUN" -eq 1 ]; then
89
- echo "[dry-run] merge '$src' into '$dest' preserving existing env and mcpServers, purging legacy hook paths"
89
+ echo "[dry-run] merge '$src' into '$dest' preserving existing env and mcpServers"
90
+ echo "[dry-run] purge legacy hook paths while merging Claude settings"
90
91
  return
91
92
  fi
92
93
 
93
- node - "$src" "$dest" <<'NODE'
94
- const fs = require('fs')
95
-
96
- const [, , sourcePath, destinationPath] = process.argv
97
- const source = JSON.parse(fs.readFileSync(sourcePath, 'utf8'))
98
- const existing = fs.existsSync(destinationPath)
99
- ? JSON.parse(fs.readFileSync(destinationPath, 'utf8'))
100
- : {}
101
-
102
- // 清理旧版 Hook 路径模式,避免合并后残留不存在的文件引用
103
- const LEGACY_HOOK_PATTERNS = [
104
- 'scripts/hooks/run-with-flags.js',
105
- 'scripts/hooks/commit-quality.js',
106
- 'scripts/hooks/session-start.js',
107
- 'scripts/hooks/session-end.js',
108
- 'scripts/lib/hook-flags.js',
109
- 'scripts/lib/utils.js',
110
- 'hooks/observe.js',
111
- 'hooks/review-confidence.js',
112
- 'hooks/session-start.js',
113
- 'hooks/session-end.js',
114
- 'hooks/evaluate-session.js',
115
- 'hooks/pre-compact.js',
116
- 'hooks/runtime/session-utils.js'
117
- ]
118
-
119
- function isLegacyHook(hookDef) {
120
- if (typeof hookDef !== 'object' || !hookDef.command) return false
121
- return LEGACY_HOOK_PATTERNS.some(p => hookDef.command.includes(p))
122
- }
123
-
124
- function filterHooks(hooksArray) {
125
- if (!Array.isArray(hooksArray)) return hooksArray
126
- return hooksArray.map(entry => {
127
- if (!entry || !Array.isArray(entry.hooks)) return entry
128
- const filtered = entry.hooks.filter(h => !isLegacyHook(h))
129
- return { ...entry, hooks: filtered }
130
- }).filter(entry => entry.hooks && entry.hooks.length > 0)
131
- }
132
-
133
- function cleanHooks(hooksObj) {
134
- if (!hooksObj || typeof hooksObj !== 'object') return hooksObj
135
- const cleaned = {}
136
- for (const [eventType, entries] of Object.entries(hooksObj)) {
137
- const filtered = filterHooks(entries)
138
- if (filtered.length > 0) {
139
- cleaned[eventType] = filtered
140
- }
141
- }
142
- return cleaned
143
- }
144
-
145
- const merged = {
146
- ...existing,
147
- ...source,
148
- env: {
149
- ...(source.env || {}),
150
- ...(existing.env || {})
151
- },
152
- mcpServers: {
153
- ...(source.mcpServers || {}),
154
- ...(existing.mcpServers || {})
155
- },
156
- // hooks 以 source 为权威,清理 existing 中的旧版残留
157
- hooks: cleanHooks({
158
- ...(existing.hooks || {}),
159
- ...(source.hooks || {})
160
- })
161
- }
162
-
163
- fs.writeFileSync(destinationPath, JSON.stringify(merged, null, 2) + '\n')
164
- NODE
94
+ node "$ROOT_DIR/scripts/merge-claude-settings.cjs" "$src" "$dest"
165
95
  chmod 600 "$dest"
166
96
  }
167
97
 
@@ -173,6 +103,11 @@ copy_dir() {
173
103
  return
174
104
  fi
175
105
 
106
+ if [ -L "$dest_root/$name" ]; then
107
+ echo "Refusing to merge into symlinked destination: $dest_root/$name" >&2
108
+ exit 1
109
+ fi
110
+
176
111
  run mkdir -p "$dest_root/$name"
177
112
  run rsync -a "$ROOT_DIR/$name/" "$dest_root/$name/"
178
113
  }
@@ -191,14 +126,13 @@ require_rsync() {
191
126
  install_shared_dirs() {
192
127
  local dest="$1"
193
128
 
194
- copy_dir rules "$dest"
195
129
  copy_dir agents "$dest"
196
130
  copy_dir commands "$dest"
197
131
  copy_dir scripts "$dest"
198
132
  copy_dir hooks "$dest"
199
133
  copy_dir skills "$dest"
200
- copy_dir homunculus "$dest"
201
134
  copy_dir references "$dest"
135
+ copy_dir harness "$dest"
202
136
  }
203
137
 
204
138
  remove_package_only_paths() {
@@ -206,12 +140,31 @@ remove_package_only_paths() {
206
140
 
207
141
  for file in \
208
142
  "scripts/install.sh" \
209
- "scripts/install.ps1"
143
+ "scripts/install.ps1" \
144
+ "scripts/install-rules.js" \
145
+ "scripts/legacy-common-rule-hashes.json" \
146
+ "scripts/verify-harness.js" \
147
+ "scripts/verify/core.js" \
148
+ "scripts/verify/grilling-spec-gate-checks.js" \
149
+ "scripts/verify/metadata-checks.js" \
150
+ "scripts/verify/repository-checks.js" \
151
+ "scripts/verify/runtime-checks.js" \
152
+ "scripts/verify/workflow-checks.js" \
153
+ "scripts/verify/workflow-ownership-fixtures.js" \
154
+ "scripts/verify/workflow-ownership.js" \
155
+ "scripts/verify/skill-manifest-checks.js" \
156
+ "scripts/verify/skill-manifest-checks.test.js" \
157
+ "scripts/verify/skill-invocation.test.js" \
158
+ "scripts/verify/install-rules.test.js"
210
159
  do
211
160
  if [ -f "$dest/$file" ]; then
212
161
  run rm -f "$dest/$file"
213
162
  fi
214
163
  done
164
+
165
+ if [ -d "$dest/scripts/verify" ] && [ -z "$(find "$dest/scripts/verify" -mindepth 1 -print -quit)" ]; then
166
+ run rmdir "$dest/scripts/verify"
167
+ fi
215
168
  }
216
169
 
217
170
  remove_obsolete_workflow_paths() {
@@ -220,6 +173,17 @@ remove_obsolete_workflow_paths() {
220
173
  local dir
221
174
 
222
175
  for file in \
176
+ "commands/e2e.md" \
177
+ "commands/evolve.md" \
178
+ "commands/grill.md" \
179
+ "commands/harness-audit.md" \
180
+ "commands/instinct-status.md" \
181
+ "commands/learn-eval.md" \
182
+ "commands/projects.md" \
183
+ "commands/promote.md" \
184
+ "commands/prune.md" \
185
+ "commands/setup-workflow.md" \
186
+ "commands/tdd.md" \
223
187
  "scripts/hooks/run-with-flags.js" \
224
188
  "scripts/hooks/commit-quality.js" \
225
189
  "scripts/hooks/session-start.js" \
@@ -231,20 +195,41 @@ remove_obsolete_workflow_paths() {
231
195
  "hooks/session-end.js" \
232
196
  "hooks/evaluate-session.js" \
233
197
  "hooks/pre-compact.js" \
234
- "hooks/runtime/session-utils.js"
198
+ "hooks/runtime/session-utils.js" \
199
+ "rules/08-ecc-integration.md" \
200
+ "skills/subagent-driven-development/implementer-prompt.md" \
201
+ "skills/subagent-driven-development/task-reviewer-prompt.md" \
202
+ "skills/subagent-driven-development/scripts/sdd-workspace" \
203
+ "skills/subagent-driven-development/scripts/task-brief" \
204
+ "skills/subagent-driven-development/scripts/review-package"
235
205
  do
236
206
  if [ -f "$dest/$file" ]; then
237
207
  run rm -f "$dest/$file"
238
208
  fi
239
209
  done
240
210
 
241
- for dir in "scripts/hooks" "scripts/lib"; do
211
+ for dir in "scripts/hooks" "scripts/lib" "skills/subagent-driven-development/scripts"; do
242
212
  if [ -d "$dest/$dir" ] && [ -z "$(find "$dest/$dir" -mindepth 1 -print -quit)" ]; then
243
213
  run rmdir "$dest/$dir"
244
214
  fi
245
215
  done
246
216
  }
247
217
 
218
+ cleanup_retired_skills() {
219
+ local dest="$1"
220
+
221
+ if [ "$DRY_RUN" -eq 1 ]; then
222
+ node "$ROOT_DIR/scripts/cleanup-retired-skills.js" "$dest" --dry-run
223
+ return
224
+ fi
225
+
226
+ node "$ROOT_DIR/scripts/cleanup-retired-skills.js" "$dest"
227
+ }
228
+
229
+ validate_retired_skill_manifest() {
230
+ node "$ROOT_DIR/scripts/cleanup-retired-skills.js" --validate
231
+ }
232
+
248
233
  install_claude() {
249
234
  local dest="$HOME_DIR/.claude"
250
235
 
@@ -255,6 +240,8 @@ install_claude() {
255
240
  copy_file "$ROOT_DIR/AGENTS.md" "$dest/AGENTS.md"
256
241
  copy_claude_settings "$ROOT_DIR/settings.json" "$dest/settings.json"
257
242
  install_shared_dirs "$dest"
243
+ install_workflow_rules claude-code "$dest"
244
+ cleanup_retired_skills "$dest"
258
245
  remove_package_only_paths "$dest"
259
246
  }
260
247
 
@@ -266,9 +253,21 @@ install_codex() {
266
253
  remove_obsolete_workflow_paths "$dest"
267
254
  copy_file "$ROOT_DIR/AGENTS.md" "$dest/AGENTS.md"
268
255
  install_shared_dirs "$dest"
256
+ install_workflow_rules codex "$dest"
257
+ cleanup_retired_skills "$dest"
269
258
  remove_package_only_paths "$dest"
270
259
  }
271
260
 
261
+ install_workflow_rules() {
262
+ local host_name="$1"
263
+ local dest="$2"
264
+ # Bash <4.4 treats empty arrays as unset under set -u.
265
+ local options=("$ROOT_DIR/scripts/install-rules.js" "$host_name" "$dest")
266
+ if [ "$DRY_RUN" -eq 1 ]; then options+=(--dry-run); fi
267
+ node "${options[@]}"
268
+ }
269
+
270
+ validate_retired_skill_manifest
272
271
  require_rsync
273
272
 
274
273
  if [ "$INSTALL_CLAUDE" -eq 1 ]; then
@@ -93,9 +93,6 @@ function findInstinctsPath(customPath) {
93
93
  if (fs.existsSync(resolved)) return resolved
94
94
  }
95
95
 
96
- const cwdPath = path.join(process.cwd(), 'homunculus', 'instincts')
97
- if (fs.existsSync(cwdPath)) return cwdPath
98
-
99
96
  return path.join(os.homedir(), '.claude', 'homunculus', 'instincts')
100
97
  }
101
98
 
@@ -348,7 +345,7 @@ function printTextReport(results, staleDays) {
348
345
  if (grouped.stale.length > 0 || grouped['low-evidence'].length > 0) {
349
346
  console.log('')
350
347
  console.log(
351
- '[Review] 提示: 使用 /instinct-status 查看详情,' +
348
+ '[Review] 提示: 使用 /learn status 查看详情,' +
352
349
  '手动决定是否保留、更新或移除'
353
350
  )
354
351
  }
@@ -0,0 +1,78 @@
1
+ {
2
+ "version": 1,
3
+ "algorithm": "sha256-lf",
4
+ "source": "origin/main history through a4f938bc70f3f85e4dcfad4d2534f522b823ea20",
5
+ "files": {
6
+ "common/agent-orchestration.md": [
7
+ "0518525f093f91b60dbae5259e0f228686687abdd65787b880f59e286c2e546c",
8
+ "3b5095839ff85adefb7324518526be65c473770df9124d190137ba05721ca6bf",
9
+ "3fb0846a2c57b833c12195610bab569e295981e2d2b6b33aa72660220be8131f",
10
+ "4840d178f06f4bdd9b67de8acb5bf4cc00b456f7dd5245db0cc5831c20b0587e",
11
+ "93a4101d3f6bb15dd8274a6064ae30c1bff43174a89384ce87a767e40b88805f",
12
+ "96bd24c0db02977e924a4d8c99e1cd9fc7ec0c43dd63e8de2fefd423cf795a5e"
13
+ ],
14
+ "common/context-hygiene.md": [
15
+ "0e98ade57a4739e99f0f9651b2e01507241849ba6f8dcdb676755694b4347a39",
16
+ "366c50d792cac5339e90e23d727dff5e818b2797a904284f3aac809377ee9a0c",
17
+ "d6462e16f190e9d8b737f9fb57039606a637920ca681641b0bcf6dbaad671ea2",
18
+ "de9a23f664094629974ec24697a196822f33d4f222b70b821831089d4d761a6e"
19
+ ],
20
+ "common/harness-engineering.md": [
21
+ "591091ef8f64c8f00d4de9dd78e112bc22bc4dfe36ba44f738670df0c2b44254",
22
+ "9247631278f21f200dc9231ad6c9a2608824f8382acbe136721db042d1626ad4"
23
+ ],
24
+ "common/hooks.md": [
25
+ "2b55915316968a573e2b375c5031cfd48a6a4c7a09581157c341193382089484",
26
+ "2bffbf111b970a42b7e9d5d3a99b83754a9162256e60679a9d98bf1c5be0665d",
27
+ "581ed0a2b50d46b5bdda7ecf6fb8a629b825216175aa02b22248e985380baae7",
28
+ "617f99d48a1a0a4f32f9a716758b75eb487b35596805b34e98cae655f79f8546",
29
+ "650dd4aa9e5106b70373abc662cfe12e19553cec691c344ce54170efde2c60bb",
30
+ "66fd4b6eab8dbec27bd30772299b7caf4a42a4cd60a471a90a134481c169445b",
31
+ "8a2a13bc972dfd343a1304f96711e1741d452688f94a690554f3ff32646d4fd3",
32
+ "ada8e689f116257fbefa429d5b93b1cad911ea92aaf763e1bfabfb25365a152f",
33
+ "ca9cfc09bec1960ac305a32f18fbd9d617cf994feb40145fca6c57a05a4c2030"
34
+ ],
35
+ "common/performance.md": [
36
+ "451a91bf7f92e747785e56d2e669ef14bca344bcddd3fa8ee0c6b2daf9aa0036",
37
+ "5b50781c4dce9e088c407efadcc31f5f5e2e5c09e77a3b2c264293be383401c5",
38
+ "7e34a17eeb86a54ae64b503edbc7635d7e0b92d4f24fe450f564a5fd76fbd17a",
39
+ "8c30e5a5561d315078d4806cc883444936e708b8e13f1ca5713ab5596317f283",
40
+ "b1d3f415dd7dd13efe7ea8d71b0dc5fd14d12f544d63f7d37bd26d12b7f5c11d"
41
+ ],
42
+ "common/pr-automation.md": [
43
+ "09b5a378cca840be6ffb202bc7f6e99ff1229762850586cf0a83faaf059aee24",
44
+ "3f6e221582a74976bb6ca164bc837cb593312d755f5ac23f1d7f7f72104d16ab",
45
+ "4f93b7d10834be91dc89e4491577cd2436fc1dcc00c256c737f75504c41173e6",
46
+ "9088d7449714af985f3800664281b0392916d40699d9a0cf2a37ed8a07d2c1ba",
47
+ "9d88f5dce7f87ba89c2c326331e27585d3f570f65416846d81c716c3e1f3b716",
48
+ "f4f1fd2cd8e07d1539144a00c3d1210658ff575da5fe85fec83d7d554f21cba8"
49
+ ],
50
+ "common/skills-learning.md": [
51
+ "04b82c7073fbb44bb8f350124331ec0631849592d0593ea0809bfc6d5c759342",
52
+ "0a70fdfce1dc9047743e525e38a7831ab3597e64741e706a06ac19a609bb333e",
53
+ "1c9377592732cf9ed4ee4eff2bed1504b30ef1f184c81c7db1cf75ddae17b6cb",
54
+ "3d80e4cc9966ba884b2a26d75950662d85e17d0a8b0fdba759f14b9ff405cc57",
55
+ "3e36e738fd540a5809217ef45d6898362c0c75e5ba842c3f05637321cac4038b",
56
+ "4b23bcfda2a1c40373b575868e9194f1f299c864c453405871464efebfbf640a",
57
+ "64f8da14651bd5cd1e70329b3bbd06b9767def04d3a3ca2ae4bb437e3f57b5da",
58
+ "79435212d7749c6b0e12419a4af9725bf2c686bc796a5388d807c6f7e160526b",
59
+ "7ea69af97511eaaeea662bcdb4b3c87de131d0d9835ca8c07f9f3b26114d8963",
60
+ "8d10b1b3a51516f485f184b487c4fb186cd13a675d89d1aed140ae6c08ee9baf",
61
+ "abc3dae7fe2a7801e130b8d4ab6e56fd27110ceceb715c987de2ccee2900ad81",
62
+ "b31acc0a27cc35f2e1441fb27b7033ff206f94892a990b588dd155814182f399",
63
+ "e54cd3640e4d8e858e384161b710c9cd7ccb1fa7bdeb612b5ca1d5855a5a4d8f"
64
+ ],
65
+ "common/testing.md": [
66
+ "5e8226b3bb360f107b68e99ead86799f3b3180635ab2c114dd32021feecbe4c9",
67
+ "660ec721b0a9d2a8b8c7806039454f6e30e509c57c2329b3f705627b81ed06f3",
68
+ "6cd550064aee456c58d2424c38f7c63f90afe8f89114bfc3ccfb1c4dd07ccfc6",
69
+ "73ae212aa8a6ebc55e044690b804b2c76d6c218dfd60a2557bd33fe884744787",
70
+ "9aa0e17f5c6d37157e059f39723dbc8b2e7e2a9efb46c609d5388ed966245d4e",
71
+ "9bbd08807d4c0d28cf74f3fa5baeea37167f2b42fff36e75795cc66c77a46f6d",
72
+ "b10bb70a5c673bfbae1bde35b8879ffd88209e024efb1011c86bd7e65045ef7d",
73
+ "c9f169a9720c038749d729f15cb110fe67d0f748fc7de73e301b3726509651ae",
74
+ "f10250dbc8a67c47b514defca1f97ce00cb2096aa9dada92ce410f308c9ffda5",
75
+ "f593217cd46431850e8f1c135c5e604cb71da7bd0c6614e8036d7bd7b0e9e92a"
76
+ ]
77
+ }
78
+ }
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+
3
+ const fs = require("fs");
4
+
5
+ const LEGACY_HOOK_PATTERNS = [
6
+ "scripts/hooks/run-with-flags.js",
7
+ "scripts/hooks/commit-quality.js",
8
+ "scripts/hooks/session-start.js",
9
+ "scripts/hooks/session-end.js",
10
+ "scripts/lib/hook-flags.js",
11
+ "scripts/lib/utils.js",
12
+ "hooks/observe.js",
13
+ "hooks/review-confidence.js",
14
+ "hooks/session-start.js",
15
+ "hooks/session-end.js",
16
+ "hooks/evaluate-session.js",
17
+ "hooks/pre-compact.js",
18
+ "hooks/runtime/session-utils.js",
19
+ ];
20
+
21
+ function isLegacyHook(hookDefinition) {
22
+ if (typeof hookDefinition !== "object" || !hookDefinition.command) return false;
23
+ return LEGACY_HOOK_PATTERNS.some((pattern) => hookDefinition.command.includes(pattern));
24
+ }
25
+
26
+ function filterHooks(entries) {
27
+ if (!Array.isArray(entries)) return entries;
28
+ return entries
29
+ .map((entry) => {
30
+ if (!entry || !Array.isArray(entry.hooks)) return entry;
31
+ const hooks = entry.hooks.filter((hook) => !isLegacyHook(hook));
32
+ return { ...entry, hooks };
33
+ })
34
+ .filter((entry) => entry.hooks && entry.hooks.length > 0);
35
+ }
36
+
37
+ function cleanHooks(hooks) {
38
+ if (!hooks || typeof hooks !== "object") return hooks;
39
+ const cleaned = {};
40
+ for (const [eventType, entries] of Object.entries(hooks)) {
41
+ const filtered = filterHooks(entries);
42
+ if (filtered.length > 0) cleaned[eventType] = filtered;
43
+ }
44
+ return cleaned;
45
+ }
46
+
47
+ function mergeSettings(source, existing) {
48
+ return {
49
+ ...existing,
50
+ ...source,
51
+ env: { ...(source.env || {}), ...(existing.env || {}) },
52
+ mcpServers: { ...(source.mcpServers || {}), ...(existing.mcpServers || {}) },
53
+ hooks: cleanHooks({ ...(existing.hooks || {}), ...(source.hooks || {}) }),
54
+ };
55
+ }
56
+
57
+ function readJson(path) {
58
+ const raw = fs.readFileSync(path, "utf8");
59
+ // strip BOM () if present
60
+ return JSON.parse(raw.charCodeAt(0) === 0xfeff ? raw.slice(1) : raw);
61
+ }
62
+
63
+ function main() {
64
+ const [, , sourcePath, destinationPath] = process.argv;
65
+ const source = readJson(sourcePath);
66
+ const existing = fs.existsSync(destinationPath)
67
+ ? readJson(destinationPath)
68
+ : {};
69
+ const merged = mergeSettings(source, existing);
70
+ fs.writeFileSync(destinationPath, JSON.stringify(merged, null, 2) + "\n");
71
+ }
72
+
73
+ if (require.main === module) main();
74
+
75
+ module.exports = { cleanHooks, mergeSettings };