shrinker-ai 0.1.0 → 0.3.0

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.
@@ -1,166 +0,0 @@
1
- param(
2
- [switch]$SkipNpmInstall,
3
- [switch]$SkipBuild,
4
- [switch]$SkipLink,
5
- [switch]$EnableProfileRouting,
6
- [switch]$SkipProfile,
7
- [switch]$SkipAgentRules,
8
- [switch]$CopilotOnly,
9
- [switch]$ClaudeOnly,
10
- [string]$ProfilePath = $PROFILE
11
- )
12
-
13
- $ErrorActionPreference = "Stop"
14
-
15
- if ($EnableProfileRouting -and $SkipProfile) {
16
- throw "Use either -EnableProfileRouting or -SkipProfile, not both."
17
- }
18
- if ($CopilotOnly -and $ClaudeOnly) {
19
- throw "Use either -CopilotOnly or -ClaudeOnly, not both."
20
- }
21
-
22
- $blockStart = "<!-- shrinker agent rules start -->"
23
- $blockEnd = "<!-- shrinker agent rules end -->"
24
-
25
- function Set-AgentRules {
26
- param(
27
- [string]$RepoRoot,
28
- [string]$Body
29
- )
30
-
31
- $targets = @()
32
- if (-not $ClaudeOnly) { $targets += (Join-Path $RepoRoot ".copilot-instructions.md") }
33
- if (-not $CopilotOnly) { $targets += (Join-Path $RepoRoot "CLAUDE.md") }
34
-
35
- foreach ($target in $targets) {
36
- $content = if (Test-Path $target) { Get-Content -Path $target -Raw } else { "" }
37
- $newBlock = "$blockStart`n$Body`n$blockEnd"
38
- if ($content -and $content.Contains($blockStart) -and $content.Contains($blockEnd)) {
39
- $pattern = [regex]::Escape($blockStart) + ".*?" + [regex]::Escape($blockEnd)
40
- $content = [regex]::Replace($content, $pattern, $newBlock, [System.Text.RegularExpressions.RegexOptions]::Singleline)
41
- Set-Content -Path $target -Value $content
42
- } elseif ($content) {
43
- Add-Content -Path $target -Value "`n$newBlock`n"
44
- } else {
45
- Set-Content -Path $target -Value "$newBlock`n"
46
- }
47
- Write-Host "Installed managed rules in: $target"
48
- }
49
- }
50
-
51
- function Test-NodeVersion {
52
- $versionText = & node -v 2>$null
53
- if (-not $versionText) {
54
- throw "Node.js was not found on PATH. Install Node.js 22.13+ first."
55
- }
56
-
57
- $match = [regex]::Match($versionText, "^v(\d+)\.(\d+)\.(\d+)$")
58
- if (-not $match.Success) {
59
- throw "Could not parse Node.js version: $versionText"
60
- }
61
-
62
- $major = [int]$match.Groups[1].Value
63
- $minor = [int]$match.Groups[2].Value
64
- $patch = [int]$match.Groups[3].Value
65
-
66
- if ($major -lt 22 -or ($major -eq 22 -and $minor -lt 13)) {
67
- throw "Node.js 22.13+ is required. Found $versionText"
68
- }
69
-
70
- return $versionText
71
- }
72
-
73
- function Add-ProfileIntegration {
74
- param(
75
- [string]$ProfileFile,
76
- [string]$IntegrationFile
77
- )
78
-
79
- if (-not (Test-Path $ProfileFile)) {
80
- New-Item -ItemType File -Path $ProfileFile -Force | Out-Null
81
- }
82
-
83
- $startMarker = "# >>> shrinker integration >>>"
84
- $endMarker = "# <<< shrinker integration <<<"
85
-
86
- $existing = Get-Content -Path $ProfileFile -Raw -ErrorAction SilentlyContinue
87
- if ($existing -and $existing.Contains($startMarker)) {
88
- Write-Host "Profile already contains shrinker integration block: $ProfileFile"
89
- return
90
- }
91
-
92
- $block = @"
93
- $startMarker
94
- . "$IntegrationFile"
95
- $endMarker
96
- "@
97
-
98
- Add-Content -Path $ProfileFile -Value "`n$block`n"
99
- Write-Host "Added shrinker integration block to profile: $ProfileFile"
100
- }
101
-
102
- $scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
103
- $templatePath = Join-Path $scriptDir "..\templates\agent-rules.md"
104
- $repoRoot = Resolve-Path (Join-Path $scriptDir "..")
105
- $integrationPath = (Resolve-Path (Join-Path $scriptDir "shrinker-profile.ps1")).Path
106
-
107
- if (-not $SkipAgentRules) {
108
- if (-not (Test-Path $templatePath)) {
109
- throw "Agent rules template not found: $templatePath"
110
- }
111
- $rulesBody = Get-Content -Path $templatePath -Raw
112
- }
113
-
114
- Write-Host "Installing shrinker from: $repoRoot"
115
- $nodeVersion = Test-NodeVersion
116
- Write-Host "Detected Node.js: $nodeVersion"
117
-
118
- Push-Location $repoRoot
119
- try {
120
- if (-not $SkipNpmInstall) {
121
- Write-Host "Running npm install..."
122
- & npm install
123
- if ($LASTEXITCODE -ne 0) {
124
- throw "npm install failed with exit code $LASTEXITCODE"
125
- }
126
- }
127
-
128
- if (-not $SkipBuild) {
129
- Write-Host "Running npm run build..."
130
- & npm run build --silent
131
- if ($LASTEXITCODE -ne 0) {
132
- throw "npm run build failed with exit code $LASTEXITCODE"
133
- }
134
- }
135
-
136
- if (-not $SkipLink) {
137
- Write-Host "Running npm link..."
138
- & npm link
139
- if ($LASTEXITCODE -ne 0) {
140
- throw "npm link failed with exit code $LASTEXITCODE"
141
- }
142
- }
143
- }
144
- finally {
145
- Pop-Location
146
- }
147
-
148
- if (-not $SkipProfile) {
149
- if ($EnableProfileRouting) {
150
- Add-ProfileIntegration -ProfileFile $ProfilePath -IntegrationFile $integrationPath
151
- Write-Host "Reload your profile with: . `$PROFILE"
152
- }
153
- else {
154
- Write-Host "Profile routing not enabled (default). Native commands remain unchanged."
155
- Write-Host "To enable routing later: pwsh -ExecutionPolicy Bypass -File .\integrations\install-shrinker.ps1 -SkipNpmInstall -SkipBuild -SkipLink -EnableProfileRouting"
156
- }
157
- }
158
- else {
159
- Write-Host "Profile routing skipped via -SkipProfile. Native commands remain unchanged."
160
- }
161
-
162
- if (-not $SkipAgentRules) {
163
- Set-AgentRules -RepoRoot (Get-Location).Path -Body $rulesBody
164
- }
165
-
166
- Write-Host "Install complete. Try: shrinker help"
@@ -1,46 +0,0 @@
1
- param(
2
- [string]$PackageName = "shrinker-ai",
3
- [string]$Registry = "https://registry.npmjs.org",
4
- [string]$Version,
5
- [switch]$EnableProfileRouting,
6
- [switch]$SkipAgentRules,
7
- [switch]$CopilotOnly,
8
- [switch]$ClaudeOnly
9
- )
10
-
11
- $ErrorActionPreference = "Stop"
12
-
13
- if ($CopilotOnly -and $ClaudeOnly) {
14
- throw "Use either -CopilotOnly or -ClaudeOnly, not both."
15
- }
16
-
17
- $packageSpec = if ($Version) { "$PackageName@$Version" } else { $PackageName }
18
- Write-Host "Installing $packageSpec from $Registry..."
19
- & npm install --global $packageSpec "--registry=$Registry"
20
- if ($LASTEXITCODE -ne 0) {
21
- throw "npm package installation failed with exit code $LASTEXITCODE"
22
- }
23
-
24
- $globalRoot = (& npm root --global).Trim()
25
- if (-not $globalRoot) {
26
- throw "Could not determine the global npm package directory."
27
- }
28
-
29
- $packageRoot = Join-Path $globalRoot ($PackageName -replace '/', '\')
30
- $localInstaller = Join-Path $packageRoot "integrations\install-shrinker.ps1"
31
- if (-not (Test-Path $localInstaller)) {
32
- throw "Installed package integration not found: $localInstaller"
33
- }
34
-
35
- $localArgs = @("-ExecutionPolicy", "Bypass", "-File", $localInstaller, "-SkipNpmInstall", "-SkipBuild", "-SkipLink")
36
- if ($EnableProfileRouting) { $localArgs += "-EnableProfileRouting" }
37
- if ($SkipAgentRules) { $localArgs += "-SkipAgentRules" }
38
- if ($CopilotOnly) { $localArgs += "-CopilotOnly" }
39
- if ($ClaudeOnly) { $localArgs += "-ClaudeOnly" }
40
-
41
- & pwsh @localArgs
42
- if ($LASTEXITCODE -ne 0) {
43
- throw "Installed package integration failed with exit code $LASTEXITCODE"
44
- }
45
-
46
- Write-Host "Package installation complete. Try: shrinker help"
@@ -1,79 +0,0 @@
1
- param(
2
- [switch]$SkipUnlink,
3
- [switch]$SkipAgentRules,
4
- [switch]$CopilotOnly,
5
- [switch]$ClaudeOnly,
6
- [string]$ProfilePath = $PROFILE
7
- )
8
-
9
- $ErrorActionPreference = "Stop"
10
-
11
- if ($CopilotOnly -and $ClaudeOnly) {
12
- throw "Use either -CopilotOnly or -ClaudeOnly, not both."
13
- }
14
-
15
- $blockStart = "<!-- shrinker agent rules start -->"
16
- $blockEnd = "<!-- shrinker agent rules end -->"
17
-
18
- function Remove-AgentRules {
19
- param([string]$Path)
20
-
21
- if (-not (Test-Path $Path)) { return }
22
- $content = Get-Content -Path $Path -Raw
23
- if (-not ($content.Contains($blockStart) -and $content.Contains($blockEnd))) { return }
24
- $pattern = [regex]::Escape($blockStart) + ".*?" + [regex]::Escape($blockEnd)
25
- Set-Content -Path $Path -Value ([regex]::Replace($content, $pattern, "", [System.Text.RegularExpressions.RegexOptions]::Singleline).TrimEnd() + "`n")
26
- Write-Host "Removed managed rules from: $Path"
27
- }
28
-
29
- function Remove-ProfileIntegration {
30
- param([string]$ProfileFile)
31
-
32
- if (-not (Test-Path $ProfileFile)) {
33
- Write-Host "Profile not found: $ProfileFile"
34
- return
35
- }
36
-
37
- $startMarker = "# >>> shrinker integration >>>"
38
- $endMarker = "# <<< shrinker integration <<<"
39
- $content = Get-Content -Path $ProfileFile -Raw
40
- if ($null -eq $content -or $content.Length -eq 0) {
41
- Write-Host "Profile is empty; nothing to remove."
42
- return
43
- }
44
-
45
- $start = $content.IndexOf($startMarker)
46
- if ($start -lt 0) {
47
- Write-Host "No shrinker integration block found in profile."
48
- return
49
- }
50
-
51
- $end = $content.IndexOf($endMarker, $start)
52
- if ($end -lt 0) {
53
- Write-Host "Integration block start found but end marker is missing; leaving profile unchanged."
54
- return
55
- }
56
-
57
- $end += $endMarker.Length
58
- $updated = $content.Remove($start, $end - $start)
59
- Set-Content -Path $ProfileFile -Value $updated
60
- Write-Host "Removed shrinker integration block from: $ProfileFile"
61
- }
62
-
63
- if (-not $SkipUnlink) {
64
- Write-Host "Running npm unlink -g shrinker..."
65
- & npm unlink -g shrinker
66
- if ($LASTEXITCODE -ne 0) {
67
- throw "npm unlink failed with exit code $LASTEXITCODE"
68
- }
69
- }
70
-
71
- Remove-ProfileIntegration -ProfileFile $ProfilePath
72
- Write-Host "If this terminal previously loaded shrinker-profile.ps1, restart terminal or remove Function:git/Function:rg wrappers from current session."
73
-
74
- if (-not $SkipAgentRules) {
75
- if (-not $ClaudeOnly) { Remove-AgentRules -Path (Join-Path (Get-Location).Path ".copilot-instructions.md") }
76
- if (-not $CopilotOnly) { Remove-AgentRules -Path (Join-Path (Get-Location).Path "CLAUDE.md") }
77
- }
78
-
79
- Write-Host "Uninstall complete."
@@ -1,35 +0,0 @@
1
- param(
2
- [string]$PackageName = "shrinker-ai",
3
- [string]$Registry = "https://registry.npmjs.org",
4
- [switch]$SkipAgentRules,
5
- [switch]$CopilotOnly,
6
- [switch]$ClaudeOnly
7
- )
8
-
9
- $ErrorActionPreference = "Stop"
10
-
11
- if ($CopilotOnly -and $ClaudeOnly) {
12
- throw "Use either -CopilotOnly or -ClaudeOnly, not both."
13
- }
14
-
15
- $globalRoot = (& npm root --global).Trim()
16
- $packageRoot = Join-Path $globalRoot ($PackageName -replace '/', '\')
17
- $localUninstaller = Join-Path $packageRoot "integrations\uninstall-shrinker.ps1"
18
- if (Test-Path $localUninstaller) {
19
- $localArgs = @("-ExecutionPolicy", "Bypass", "-File", $localUninstaller, "-SkipUnlink")
20
- if ($SkipAgentRules) { $localArgs += "-SkipAgentRules" }
21
- if ($CopilotOnly) { $localArgs += "-CopilotOnly" }
22
- if ($ClaudeOnly) { $localArgs += "-ClaudeOnly" }
23
- & pwsh @localArgs
24
- if ($LASTEXITCODE -ne 0) {
25
- throw "Installed package integration failed with exit code $LASTEXITCODE"
26
- }
27
- }
28
-
29
- Write-Host "Removing $PackageName..."
30
- & npm uninstall --global $PackageName "--registry=$Registry"
31
- if ($LASTEXITCODE -ne 0) {
32
- throw "npm package removal failed with exit code $LASTEXITCODE"
33
- }
34
-
35
- Write-Host "Package uninstallation complete."