install.ps1 11 KB

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