install.ps1 10 KB

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