install.ps1 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. <#
  2. .SYNOPSIS
  3. Install claude-mods extensions to ~/.claude/
  4. .DESCRIPTION
  5. Copies commands, skills, agents, and rules to the global Claude Code config.
  6. Handles cleanup of deprecated items and command-to-skill migrations.
  7. .NOTES
  8. Run from the claude-mods directory:
  9. .\scripts\install.ps1
  10. #>
  11. $ErrorActionPreference = "Stop"
  12. Write-Host "================================================================" -ForegroundColor Cyan
  13. Write-Host " claude-mods Installer (Windows) " -ForegroundColor Cyan
  14. Write-Host "================================================================" -ForegroundColor Cyan
  15. Write-Host ""
  16. $scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
  17. $projectRoot = Split-Path -Parent $scriptDir
  18. $claudeDir = "$env:USERPROFILE\.claude"
  19. # Ensure ~/.claude directories exist
  20. $dirs = @("commands", "skills", "agents", "rules", "output-styles")
  21. foreach ($dir in $dirs) {
  22. $path = Join-Path $claudeDir $dir
  23. if (-not (Test-Path $path)) {
  24. New-Item -ItemType Directory -Path $path -Force | Out-Null
  25. Write-Host " Created $path" -ForegroundColor Green
  26. }
  27. }
  28. # =============================================================================
  29. # DEPRECATED ITEMS - Remove these from user config
  30. # =============================================================================
  31. $deprecated = @(
  32. "$claudeDir\commands\review.md",
  33. "$claudeDir\commands\testgen.md",
  34. "$claudeDir\commands\conclave.md",
  35. "$claudeDir\commands\pulse.md",
  36. "$claudeDir\skills\conclave",
  37. "$claudeDir\skills\claude-code-templates", # Replaced by skill-creator
  38. "$claudeDir\skills\agentmail", # Renamed to pigeon (v2.3.0)
  39. "$claudeDir\skills\claude-code-debug", # Merged into claude-code-ops (v3.0)
  40. "$claudeDir\skills\claude-code-headless", # Merged into claude-code-ops (v3.0)
  41. "$claudeDir\skills\claude-code-hooks", # Merged into claude-code-ops (v3.0)
  42. # Deprecated agents (v3.0): folded into their -ops skill twins
  43. "$claudeDir\agents\python-expert.md",
  44. "$claudeDir\agents\typescript-expert.md",
  45. "$claudeDir\agents\javascript-expert.md",
  46. "$claudeDir\agents\go-expert.md",
  47. "$claudeDir\agents\rust-expert.md",
  48. "$claudeDir\agents\react-expert.md",
  49. "$claudeDir\agents\vue-expert.md",
  50. "$claudeDir\agents\astro-expert.md",
  51. "$claudeDir\agents\laravel-expert.md",
  52. "$claudeDir\agents\sql-expert.md",
  53. "$claudeDir\agents\postgres-expert.md",
  54. "$claudeDir\agents\cypress-expert.md", # -> skills/cypress-ops
  55. "$claudeDir\agents\cloudflare-expert.md", # -> skills/cloudflare-ops
  56. "$claudeDir\agents\wrangler-expert.md", # -> skills/cloudflare-ops
  57. "$claudeDir\agents\bash-expert.md", # -> skills/bash-ops
  58. "$claudeDir\agents\claude-architect.md", # -> skills/claude-code-ops
  59. "$claudeDir\agents\aws-fargate-ecs-expert.md", # -> skills/container-orchestration
  60. "$claudeDir\agents\craftcms-expert.md", # -> skills/craftcms-ops
  61. "$claudeDir\agents\payloadcms-expert.md", # -> skills/payloadcms-ops
  62. "$claudeDir\agents\asus-router-expert.md" # -> skills/asus-router-ops
  63. )
  64. # Renamed skills: -patterns -> -ops (March 2026)
  65. $renamedSkills = @(
  66. "cli-patterns",
  67. "mcp-patterns",
  68. "python-async-patterns",
  69. "python-cli-patterns",
  70. "python-database-patterns",
  71. "python-fastapi-patterns",
  72. "python-observability-patterns",
  73. "python-pytest-patterns",
  74. "python-typing-patterns",
  75. "rest-patterns",
  76. "security-patterns",
  77. "sql-patterns",
  78. "tailwind-patterns",
  79. "testing-patterns"
  80. )
  81. foreach ($oldSkill in $renamedSkills) {
  82. $oldPath = "$claudeDir\skills\$oldSkill"
  83. if (Test-Path $oldPath) {
  84. Remove-Item -Path $oldPath -Recurse -Force
  85. $newName = $oldSkill -replace '-patterns$', '-ops'
  86. Write-Host " Removed renamed: $oldSkill (now $newName)" -ForegroundColor Red
  87. }
  88. }
  89. Write-Host "Cleaning up deprecated items..." -ForegroundColor Yellow
  90. foreach ($item in $deprecated) {
  91. if (Test-Path $item) {
  92. Remove-Item -Path $item -Recurse -Force
  93. Write-Host " Removed: $item" -ForegroundColor Red
  94. }
  95. }
  96. Write-Host ""
  97. # =============================================================================
  98. # COMMANDS - Only copy commands that have not been migrated to skills
  99. # =============================================================================
  100. Write-Host "Installing commands..." -ForegroundColor Cyan
  101. $skipCommands = @("review.md", "testgen.md")
  102. $commandsDir = Join-Path $projectRoot "commands"
  103. Get-ChildItem -Path $commandsDir -Filter "*.md" | ForEach-Object {
  104. if ($_.Name -notin $skipCommands -and $_.Name -notlike "archive*") {
  105. Copy-Item $_.FullName -Destination "$claudeDir\commands\" -Force
  106. Write-Host " $($_.Name)" -ForegroundColor Green
  107. }
  108. }
  109. Write-Host ""
  110. # =============================================================================
  111. # SKILLS - Copy all skill directories
  112. # =============================================================================
  113. Write-Host "Installing skills..." -ForegroundColor Cyan
  114. $skillsDir = Join-Path $projectRoot "skills"
  115. Get-ChildItem -Path $skillsDir -Directory | ForEach-Object {
  116. $dest = "$claudeDir\skills\$($_.Name)"
  117. if (Test-Path $dest) {
  118. Remove-Item -Path $dest -Recurse -Force
  119. }
  120. Copy-Item $_.FullName -Destination $dest -Recurse -Force
  121. Write-Host " $($_.Name)/" -ForegroundColor Green
  122. }
  123. Write-Host ""
  124. # =============================================================================
  125. # AGENTS - Copy all agent files
  126. # =============================================================================
  127. Write-Host "Installing agents..." -ForegroundColor Cyan
  128. $agentsDir = Join-Path $projectRoot "agents"
  129. Get-ChildItem -Path $agentsDir -Filter "*.md" | ForEach-Object {
  130. Copy-Item $_.FullName -Destination "$claudeDir\agents\" -Force
  131. Write-Host " $($_.Name)" -ForegroundColor Green
  132. }
  133. Write-Host ""
  134. # =============================================================================
  135. # RULES - Copy all rule files
  136. # =============================================================================
  137. Write-Host "Installing rules..." -ForegroundColor Cyan
  138. $rulesDir = Join-Path $projectRoot "rules"
  139. Get-ChildItem -Path $rulesDir -Filter "*.md" | ForEach-Object {
  140. Copy-Item $_.FullName -Destination "$claudeDir\rules\" -Force
  141. Write-Host " $($_.Name)" -ForegroundColor Green
  142. }
  143. Write-Host ""
  144. # =============================================================================
  145. # OUTPUT STYLES - Copy all output style files
  146. # =============================================================================
  147. Write-Host "Installing output styles..." -ForegroundColor Cyan
  148. $stylesDir = Join-Path $projectRoot "output-styles"
  149. if (Test-Path $stylesDir) {
  150. Get-ChildItem -Path $stylesDir -Filter "*.md" | ForEach-Object {
  151. Copy-Item $_.FullName -Destination "$claudeDir\output-styles\" -Force
  152. Write-Host " $($_.Name)" -ForegroundColor Green
  153. }
  154. }
  155. Write-Host ""
  156. # =============================================================================
  157. # PIGEON - Global install (scripts + hook config hint)
  158. # =============================================================================
  159. Write-Host "Installing pigeon (pmail)..." -ForegroundColor Cyan
  160. # Clean up old agentmail install if present
  161. $oldAgentmailDir = Join-Path $claudeDir "agentmail"
  162. if (Test-Path $oldAgentmailDir) {
  163. Remove-Item -Path $oldAgentmailDir -Recurse -Force
  164. Write-Host " Removed old agentmail/ (renamed to pigeon/)" -ForegroundColor Red
  165. }
  166. $pigeonDir = Join-Path $claudeDir "pigeon"
  167. New-Item -ItemType Directory -Force -Path $pigeonDir | Out-Null
  168. $mailDbSrc = Join-Path $projectRoot "skills\pigeon\scripts\mail-db.sh"
  169. $checkMailSrc = Join-Path $projectRoot "hooks\check-mail.sh"
  170. if (Test-Path $mailDbSrc) {
  171. Copy-Item $mailDbSrc -Destination "$pigeonDir\" -Force
  172. Write-Host " mail-db.sh" -ForegroundColor Green
  173. }
  174. if (Test-Path $checkMailSrc) {
  175. Copy-Item $checkMailSrc -Destination "$pigeonDir\" -Force
  176. Write-Host " check-mail.sh" -ForegroundColor Green
  177. }
  178. $settingsPath = Join-Path $claudeDir "settings.json"
  179. # Migrate stale agentmail hook path -> pigeon
  180. if ((Test-Path $settingsPath) -and (Select-String -Path $settingsPath -Pattern "agentmail/check-mail\.sh" -Quiet)) {
  181. $content = Get-Content $settingsPath -Raw
  182. $content = $content -replace 'agentmail/check-mail\.sh', 'pigeon/check-mail.sh'
  183. Set-Content $settingsPath -Value $content -NoNewline
  184. Write-Host " Migrated agentmail hook -> pigeon in settings.json" -ForegroundColor Green
  185. }
  186. # Check if hook is already configured (pigeon path)
  187. if ((Test-Path $settingsPath) -and (Select-String -Path $settingsPath -Pattern "pigeon/check-mail\.sh" -Quiet)) {
  188. Write-Host " Hook already configured in settings.json" -ForegroundColor Green
  189. } else {
  190. Write-Host ""
  191. Write-Host ' To enable automatic pmail notifications, add this to ~/.claude/settings.json:' -ForegroundColor Yellow
  192. Write-Host ""
  193. Write-Host ' "hooks": {'
  194. Write-Host ' "PreToolUse": [{'
  195. Write-Host ' "matcher": "*",'
  196. Write-Host ' "hooks": [{'
  197. Write-Host ' "type": "command",'
  198. Write-Host ' "command": "bash \"$HOME/.claude/pigeon/check-mail.sh\"",'
  199. Write-Host ' "timeout": 5'
  200. Write-Host ' }]'
  201. Write-Host ' }]'
  202. Write-Host ' }'
  203. Write-Host ""
  204. Write-Host " Without this, pigeon works but you must check manually (pigeon read)." -ForegroundColor Yellow
  205. }
  206. Write-Host ""
  207. # =============================================================================
  208. # AUTO-SKILL - Global install (tracking + evaluation hooks)
  209. # =============================================================================
  210. Write-Host "Installing auto-skill..." -ForegroundColor Cyan
  211. $autoSkillDir = Join-Path $claudeDir "auto-skill"
  212. New-Item -ItemType Directory -Force -Path $autoSkillDir | Out-Null
  213. $scripts = @("track-tools.sh", "evaluate.sh")
  214. foreach ($script in $scripts) {
  215. $src = Join-Path $projectRoot "skills\auto-skill\scripts\$script"
  216. if (Test-Path $src) {
  217. Copy-Item $src -Destination "$autoSkillDir\" -Force
  218. Write-Host " $script" -ForegroundColor Green
  219. }
  220. }
  221. $settingsPath = Join-Path $claudeDir "settings.json"
  222. if ((Test-Path $settingsPath) -and (Select-String -Path $settingsPath -Pattern "auto-skill" -Quiet)) {
  223. Write-Host " Hooks already configured in settings.json" -ForegroundColor Green
  224. } else {
  225. Write-Host ""
  226. Write-Host ' To enable automatic skill suggestions, add these hooks to ~/.claude/settings.json:' -ForegroundColor Yellow
  227. Write-Host ""
  228. Write-Host ' "PostToolUse": [{ "matcher": "*", "hooks": [{'
  229. Write-Host ' "type": "command",'
  230. Write-Host ' "command": "bash \"$HOME/.claude/auto-skill/track-tools.sh\"", "timeout": 2'
  231. Write-Host ' }] }],'
  232. Write-Host ' "Stop": [{ "hooks": [{'
  233. Write-Host ' "type": "command",'
  234. Write-Host ' "command": "bash \"$HOME/.claude/auto-skill/evaluate.sh\"", "timeout": 5'
  235. Write-Host ' }] }]'
  236. Write-Host ""
  237. Write-Host " Without this, /auto-skill still works but won't suggest automatically." -ForegroundColor Yellow
  238. }
  239. Write-Host ""
  240. # =============================================================================
  241. # SUMMARY
  242. # =============================================================================
  243. Write-Host "================================================================" -ForegroundColor Cyan
  244. Write-Host " Installation complete!" -ForegroundColor Green
  245. Write-Host "================================================================" -ForegroundColor Cyan
  246. Write-Host ""
  247. Write-Host "Restart Claude Code to load the new extensions." -ForegroundColor Yellow
  248. Write-Host ""