install.ps1 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  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. )
  55. # Renamed skills: -patterns -> -ops (March 2026)
  56. $renamedSkills = @(
  57. "cli-patterns",
  58. "mcp-patterns",
  59. "python-async-patterns",
  60. "python-cli-patterns",
  61. "python-database-patterns",
  62. "python-fastapi-patterns",
  63. "python-observability-patterns",
  64. "python-pytest-patterns",
  65. "python-typing-patterns",
  66. "rest-patterns",
  67. "security-patterns",
  68. "sql-patterns",
  69. "tailwind-patterns",
  70. "testing-patterns"
  71. )
  72. foreach ($oldSkill in $renamedSkills) {
  73. $oldPath = "$claudeDir\skills\$oldSkill"
  74. if (Test-Path $oldPath) {
  75. Remove-Item -Path $oldPath -Recurse -Force
  76. $newName = $oldSkill -replace '-patterns$', '-ops'
  77. Write-Host " Removed renamed: $oldSkill (now $newName)" -ForegroundColor Red
  78. }
  79. }
  80. Write-Host "Cleaning up deprecated items..." -ForegroundColor Yellow
  81. foreach ($item in $deprecated) {
  82. if (Test-Path $item) {
  83. Remove-Item -Path $item -Recurse -Force
  84. Write-Host " Removed: $item" -ForegroundColor Red
  85. }
  86. }
  87. Write-Host ""
  88. # =============================================================================
  89. # COMMANDS - Only copy commands that have not been migrated to skills
  90. # =============================================================================
  91. Write-Host "Installing commands..." -ForegroundColor Cyan
  92. $skipCommands = @("review.md", "testgen.md")
  93. $commandsDir = Join-Path $projectRoot "commands"
  94. Get-ChildItem -Path $commandsDir -Filter "*.md" | ForEach-Object {
  95. if ($_.Name -notin $skipCommands -and $_.Name -notlike "archive*") {
  96. Copy-Item $_.FullName -Destination "$claudeDir\commands\" -Force
  97. Write-Host " $($_.Name)" -ForegroundColor Green
  98. }
  99. }
  100. Write-Host ""
  101. # =============================================================================
  102. # SKILLS - Copy all skill directories
  103. # =============================================================================
  104. Write-Host "Installing skills..." -ForegroundColor Cyan
  105. $skillsDir = Join-Path $projectRoot "skills"
  106. Get-ChildItem -Path $skillsDir -Directory | ForEach-Object {
  107. $dest = "$claudeDir\skills\$($_.Name)"
  108. if (Test-Path $dest) {
  109. Remove-Item -Path $dest -Recurse -Force
  110. }
  111. Copy-Item $_.FullName -Destination $dest -Recurse -Force
  112. Write-Host " $($_.Name)/" -ForegroundColor Green
  113. }
  114. Write-Host ""
  115. # =============================================================================
  116. # AGENTS - Copy all agent files
  117. # =============================================================================
  118. Write-Host "Installing agents..." -ForegroundColor Cyan
  119. $agentsDir = Join-Path $projectRoot "agents"
  120. Get-ChildItem -Path $agentsDir -Filter "*.md" | ForEach-Object {
  121. Copy-Item $_.FullName -Destination "$claudeDir\agents\" -Force
  122. Write-Host " $($_.Name)" -ForegroundColor Green
  123. }
  124. Write-Host ""
  125. # =============================================================================
  126. # RULES - Copy all rule files
  127. # =============================================================================
  128. Write-Host "Installing rules..." -ForegroundColor Cyan
  129. $rulesDir = Join-Path $projectRoot "rules"
  130. Get-ChildItem -Path $rulesDir -Filter "*.md" | ForEach-Object {
  131. Copy-Item $_.FullName -Destination "$claudeDir\rules\" -Force
  132. Write-Host " $($_.Name)" -ForegroundColor Green
  133. }
  134. Write-Host ""
  135. # =============================================================================
  136. # OUTPUT STYLES - Copy all output style files
  137. # =============================================================================
  138. Write-Host "Installing output styles..." -ForegroundColor Cyan
  139. $stylesDir = Join-Path $projectRoot "output-styles"
  140. if (Test-Path $stylesDir) {
  141. Get-ChildItem -Path $stylesDir -Filter "*.md" | ForEach-Object {
  142. Copy-Item $_.FullName -Destination "$claudeDir\output-styles\" -Force
  143. Write-Host " $($_.Name)" -ForegroundColor Green
  144. }
  145. }
  146. Write-Host ""
  147. # =============================================================================
  148. # PIGEON - Global install (scripts + hook config hint)
  149. # =============================================================================
  150. Write-Host "Installing pigeon (pmail)..." -ForegroundColor Cyan
  151. # Clean up old agentmail install if present
  152. $oldAgentmailDir = Join-Path $claudeDir "agentmail"
  153. if (Test-Path $oldAgentmailDir) {
  154. Remove-Item -Path $oldAgentmailDir -Recurse -Force
  155. Write-Host " Removed old agentmail/ (renamed to pigeon/)" -ForegroundColor Red
  156. }
  157. $pigeonDir = Join-Path $claudeDir "pigeon"
  158. New-Item -ItemType Directory -Force -Path $pigeonDir | Out-Null
  159. $mailDbSrc = Join-Path $projectRoot "skills\pigeon\scripts\mail-db.sh"
  160. $checkMailSrc = Join-Path $projectRoot "hooks\check-mail.sh"
  161. if (Test-Path $mailDbSrc) {
  162. Copy-Item $mailDbSrc -Destination "$pigeonDir\" -Force
  163. Write-Host " mail-db.sh" -ForegroundColor Green
  164. }
  165. if (Test-Path $checkMailSrc) {
  166. Copy-Item $checkMailSrc -Destination "$pigeonDir\" -Force
  167. Write-Host " check-mail.sh" -ForegroundColor Green
  168. }
  169. $settingsPath = Join-Path $claudeDir "settings.json"
  170. # Migrate stale agentmail hook path -> pigeon
  171. if ((Test-Path $settingsPath) -and (Select-String -Path $settingsPath -Pattern "agentmail/check-mail\.sh" -Quiet)) {
  172. $content = Get-Content $settingsPath -Raw
  173. $content = $content -replace 'agentmail/check-mail\.sh', 'pigeon/check-mail.sh'
  174. Set-Content $settingsPath -Value $content -NoNewline
  175. Write-Host " Migrated agentmail hook -> pigeon in settings.json" -ForegroundColor Green
  176. }
  177. # Check if hook is already configured (pigeon path)
  178. if ((Test-Path $settingsPath) -and (Select-String -Path $settingsPath -Pattern "pigeon/check-mail\.sh" -Quiet)) {
  179. Write-Host " Hook already configured in settings.json" -ForegroundColor Green
  180. } else {
  181. Write-Host ""
  182. Write-Host ' To enable automatic pmail notifications, add this to ~/.claude/settings.json:' -ForegroundColor Yellow
  183. Write-Host ""
  184. Write-Host ' "hooks": {'
  185. Write-Host ' "PreToolUse": [{'
  186. Write-Host ' "matcher": "*",'
  187. Write-Host ' "hooks": [{'
  188. Write-Host ' "type": "command",'
  189. Write-Host ' "command": "bash \"$HOME/.claude/pigeon/check-mail.sh\"",'
  190. Write-Host ' "timeout": 5'
  191. Write-Host ' }]'
  192. Write-Host ' }]'
  193. Write-Host ' }'
  194. Write-Host ""
  195. Write-Host " Without this, pigeon works but you must check manually (pigeon read)." -ForegroundColor Yellow
  196. }
  197. Write-Host ""
  198. # =============================================================================
  199. # AUTO-SKILL - Global install (tracking + evaluation hooks)
  200. # =============================================================================
  201. Write-Host "Installing auto-skill..." -ForegroundColor Cyan
  202. $autoSkillDir = Join-Path $claudeDir "auto-skill"
  203. New-Item -ItemType Directory -Force -Path $autoSkillDir | Out-Null
  204. $scripts = @("track-tools.sh", "evaluate.sh")
  205. foreach ($script in $scripts) {
  206. $src = Join-Path $projectRoot "skills\auto-skill\scripts\$script"
  207. if (Test-Path $src) {
  208. Copy-Item $src -Destination "$autoSkillDir\" -Force
  209. Write-Host " $script" -ForegroundColor Green
  210. }
  211. }
  212. $settingsPath = Join-Path $claudeDir "settings.json"
  213. if ((Test-Path $settingsPath) -and (Select-String -Path $settingsPath -Pattern "auto-skill" -Quiet)) {
  214. Write-Host " Hooks already configured in settings.json" -ForegroundColor Green
  215. } else {
  216. Write-Host ""
  217. Write-Host ' To enable automatic skill suggestions, add these hooks to ~/.claude/settings.json:' -ForegroundColor Yellow
  218. Write-Host ""
  219. Write-Host ' "PostToolUse": [{ "matcher": "*", "hooks": [{'
  220. Write-Host ' "type": "command",'
  221. Write-Host ' "command": "bash \"$HOME/.claude/auto-skill/track-tools.sh\"", "timeout": 2'
  222. Write-Host ' }] }],'
  223. Write-Host ' "Stop": [{ "hooks": [{'
  224. Write-Host ' "type": "command",'
  225. Write-Host ' "command": "bash \"$HOME/.claude/auto-skill/evaluate.sh\"", "timeout": 5'
  226. Write-Host ' }] }]'
  227. Write-Host ""
  228. Write-Host " Without this, /auto-skill still works but won't suggest automatically." -ForegroundColor Yellow
  229. }
  230. Write-Host ""
  231. # =============================================================================
  232. # SUMMARY
  233. # =============================================================================
  234. Write-Host "================================================================" -ForegroundColor Cyan
  235. Write-Host " Installation complete!" -ForegroundColor Green
  236. Write-Host "================================================================" -ForegroundColor Cyan
  237. Write-Host ""
  238. Write-Host "Restart Claude Code to load the new extensions." -ForegroundColor Yellow
  239. Write-Host ""