shrinker-ai 0.3.3 → 0.4.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,57 +1,101 @@
1
- param(
2
- [switch]$SkipUnlink,
3
- [switch]$SkipAgentRules,
4
- [switch]$CopilotOnly,
5
- [switch]$ClaudeOnly,
6
- [string]$ProfilePath = $PROFILE
7
- )
8
-
9
- $ErrorActionPreference = "Stop"
10
- $UninstallStep = 0
11
-
12
- function Write-UninstallStep {
13
- param([string]$Emoji, [string]$Message)
14
- $script:UninstallStep++
15
- Write-Host "$($script:UninstallStep). $Emoji $Message"
16
- }
17
-
18
- function Remove-AgentRules {
19
- param([string]$Path)
20
- if (-not (Test-Path $Path)) { return }
21
- $content = Get-Content $Path -Raw
22
- $start = "<!-- shrinker agent rules start -->"
23
- $end = "<!-- shrinker agent rules end -->"
24
- if ($null -ne $content -and $content.Contains($start) -and $content.Contains($end)) {
25
- $pattern = [regex]::Escape($start) + ".*?" + [regex]::Escape($end)
26
- Set-Content $Path ([regex]::Replace($content, $pattern, "", 'Singleline').TrimEnd() + "`n")
27
- Write-UninstallStep "📄" "Removed managed rules from: $Path"
28
- }
29
- }
30
-
31
- function Remove-ProfileIntegration {
32
- param([string]$ProfileFile)
33
- if (-not (Test-Path $ProfileFile)) { return }
34
- $content = Get-Content $ProfileFile -Raw
35
- if ($null -eq $content) { return }
36
- $start = $content.IndexOf("# >>> shrinker integration >>>")
37
- $endMarker = "# <<< shrinker integration <<<"
38
- if ($start -ge 0) {
39
- $end = $content.IndexOf($endMarker, $start)
40
- if ($end -ge 0) { Set-Content $ProfileFile $content.Remove($start, $end + $endMarker.Length - $start) }
41
- }
42
- }
43
-
44
- if (-not $SkipUnlink) {
45
- Write-UninstallStep "🔗" "Unlinking shrinker globally..."
46
- & npm unlink --silent --global shrinker-ai
47
- if ($LASTEXITCODE -ne 0) { throw "npm unlink failed." }
48
- }
49
- else { Write-UninstallStep "⏭️" "Skipped global npm unlink." }
50
- Write-UninstallStep "🔧" "Removing PowerShell profile integration..."
51
- Remove-ProfileIntegration $ProfilePath
52
- if (-not $SkipAgentRules) {
53
- if (-not $ClaudeOnly) { Remove-AgentRules (Join-Path $HOME ".copilot\copilot-instructions.md") }
54
- if (-not $CopilotOnly) { Remove-AgentRules (Join-Path $HOME ".claude\CLAUDE.md") }
55
- }
56
- else { Write-UninstallStep "⏭️" "Skipped managed agent rules." }
57
- Write-UninstallStep "✅" "Uninstall complete."
1
+ param(
2
+ [switch]$SkipUnlink,
3
+ [switch]$SkipAgentRules,
4
+ [switch]$CopilotOnly,
5
+ [switch]$ClaudeOnly,
6
+ [switch]$PurgeData,
7
+ [int]$Port = 4317,
8
+ [string]$ProfilePath = $PROFILE,
9
+ [string]$ConfigPath = $(if ($env:SHRINKER_CONFIG_PATH) { $env:SHRINKER_CONFIG_PATH } else { Join-Path $HOME ".shrinker/config" })
10
+ )
11
+
12
+ $ErrorActionPreference = "Stop"
13
+ $UninstallStep = 0
14
+ $DataDir = Split-Path -Parent $ConfigPath
15
+
16
+ function Write-UninstallStep {
17
+ param([string]$Emoji, [string]$Message)
18
+ $script:UninstallStep++
19
+ Write-Host "$($script:UninstallStep). $Emoji $Message"
20
+ }
21
+
22
+ function Remove-AgentRules {
23
+ param([string]$Path)
24
+ if (-not (Test-Path $Path)) { return }
25
+ $content = Get-Content $Path -Raw
26
+ $start = "<!-- shrinker agent rules start -->"
27
+ $end = "<!-- shrinker agent rules end -->"
28
+ if ($null -ne $content -and $content.Contains($start) -and $content.Contains($end)) {
29
+ $pattern = [regex]::Escape($start) + ".*?" + [regex]::Escape($end)
30
+ Set-Content $Path ([regex]::Replace($content, $pattern, "", 'Singleline').TrimEnd() + "`n")
31
+ Write-UninstallStep "📄" "Removed managed rules from: $Path"
32
+ }
33
+ }
34
+
35
+ function Remove-ProfileIntegration {
36
+ param([string]$ProfileFile)
37
+ if (-not (Test-Path $ProfileFile)) { return }
38
+ $content = Get-Content $ProfileFile -Raw
39
+ if ($null -eq $content) { return }
40
+ $start = $content.IndexOf("# >>> shrinker integration >>>")
41
+ $endMarker = "# <<< shrinker integration <<<"
42
+ if ($start -ge 0) {
43
+ $end = $content.IndexOf($endMarker, $start)
44
+ if ($end -ge 0) { Set-Content $ProfileFile $content.Remove($start, $end + $endMarker.Length - $start) }
45
+ }
46
+ }
47
+
48
+ # The dashboard runs as a detached daemon, so unlinking the package never stops it.
49
+ function Stop-DashboardServer {
50
+ param([int]$DashboardPort)
51
+ try {
52
+ Invoke-WebRequest -Uri "http://127.0.0.1:$DashboardPort/__shrinker_shutdown" -Method Post -TimeoutSec 3 -UseBasicParsing | Out-Null
53
+ Start-Sleep -Seconds 1
54
+ }
55
+ catch { }
56
+
57
+ try {
58
+ $listener = Get-NetTCPConnection -LocalPort $DashboardPort -State Listen -ErrorAction SilentlyContinue | Select-Object -First 1
59
+ if ($listener) { Stop-Process -Id $listener.OwningProcess -Force -ErrorAction SilentlyContinue }
60
+ }
61
+ catch { }
62
+ }
63
+
64
+ # Only drop installer-managed keys so hand-written settings survive.
65
+ function Remove-ManagedConfig {
66
+ if (-not (Test-Path -LiteralPath $ConfigPath)) { return }
67
+ $remaining = @(Get-Content -LiteralPath $ConfigPath | Where-Object { $_ -notmatch '^\s*SHRINKER_TRACK_UNCOVERED\s*=' })
68
+ if ($remaining.Count -gt 0) { Set-Content -LiteralPath $ConfigPath -Value $remaining -Encoding utf8 }
69
+ else { Remove-Item -LiteralPath $ConfigPath -Force -ErrorAction SilentlyContinue }
70
+ }
71
+
72
+ Write-UninstallStep "🛑" "Stopping the dashboard server on port $Port..."
73
+ Stop-DashboardServer $Port
74
+
75
+ if (-not $SkipUnlink) {
76
+ Write-UninstallStep "🔗" "Unlinking shrinker globally..."
77
+ & npm unlink --silent --global shrinker-ai
78
+ if ($LASTEXITCODE -ne 0) { throw "npm unlink failed." }
79
+ }
80
+ else { Write-UninstallStep "⏭️" "Skipped global npm unlink." }
81
+ Write-UninstallStep "🔧" "Removing PowerShell profile integration..."
82
+ Remove-ProfileIntegration $ProfilePath
83
+ if (-not $SkipAgentRules) {
84
+ if (-not $ClaudeOnly) { Remove-AgentRules (Join-Path $HOME ".copilot\copilot-instructions.md") }
85
+ if (-not $CopilotOnly) { Remove-AgentRules (Join-Path $HOME ".claude\CLAUDE.md") }
86
+ }
87
+ else { Write-UninstallStep "⏭️" "Skipped managed agent rules." }
88
+
89
+ Write-UninstallStep "🔧" "Removing managed settings..."
90
+ Remove-ManagedConfig
91
+ Remove-Item -LiteralPath (Join-Path $DataDir "dashboard.html") -Force -ErrorAction SilentlyContinue
92
+
93
+ if ($PurgeData) {
94
+ Remove-Item -LiteralPath $DataDir -Recurse -Force -ErrorAction SilentlyContinue
95
+ Write-UninstallStep "🧹" "Removed local data: $DataDir"
96
+ }
97
+ elseif (Test-Path -LiteralPath $DataDir) {
98
+ Write-UninstallStep "💾" "Kept saved stats in $DataDir (use -PurgeData to delete)."
99
+ }
100
+
101
+ Write-UninstallStep "✅" "Uninstall complete."
package/package.json CHANGED
@@ -1,39 +1,46 @@
1
- {
2
- "name": "shrinker-ai",
3
- "version": "0.3.3",
4
- "description": "Local deterministic command-output shrinker for coding agents",
5
- "type": "module",
6
- "bin": {
7
- "shrinker": "dist/src/cli.js"
8
- },
9
- "scripts": {
10
- "start": "tsc -w -p tsconfig.json",
11
- "build": "tsc -p tsconfig.json",
12
- "pack": "npm run build --silent && npm pack",
13
- "test": "npm run build --silent && node --test \"dist/tests/*.test.js\"",
14
- "demo": "npm run build --silent && node dist/demo/run-demo.js",
15
- "install:local": "pwsh -ExecutionPolicy Bypass -File ./integrations/windows/install.ps1 -Local",
16
- "install:local:macos": "./integrations/macos/install.sh --local",
17
- "install:github": "pwsh -ExecutionPolicy Bypass -File ./integrations/windows/install.ps1",
18
- "install:github:macos": "./integrations/macos/install.sh",
19
- "uninstall:local": "pwsh -ExecutionPolicy Bypass -File ./integrations/windows/uninstall.ps1",
20
- "uninstall:local:macos": "./integrations/macos/uninstall.sh",
21
- "uninstall:github": "pwsh -ExecutionPolicy Bypass -File ./integrations/windows/uninstall.ps1",
22
- "uninstall:github:macos": "./integrations/macos/uninstall.sh"
23
- },
24
- "devDependencies": {
25
- "@types/node": "^24.0.0",
26
- "typescript": "^5.9.0"
27
- },
28
- "engines": {
29
- "node": ">=22.13"
30
- },
31
- "publishConfig": {
32
- "registry": "https://registry.npmjs.org"
33
- },
34
- "license": "MIT",
35
- "repository": {
36
- "type": "git",
37
- "url": "git+https://github.com/ivanduplenskikh/shrinker.git"
38
- }
39
- }
1
+ {
2
+ "name": "shrinker-ai",
3
+ "version": "0.4.0",
4
+ "description": "Local deterministic command-output shrinker for coding agents",
5
+ "type": "module",
6
+ "bin": {
7
+ "shrinker": "dist/src/cli.js"
8
+ },
9
+ "workspaces": [
10
+ "packages/*"
11
+ ],
12
+ "scripts": {
13
+ "start": "npm run build --silent && npm run dev:ui",
14
+ "build:ui": "npm run build --workspace @shrinker/dashboard-ui",
15
+ "dev:ui": "npm run dev --workspace @shrinker/dashboard-ui",
16
+ "build": "npm run build:ui && tsc -p tsconfig.json",
17
+ "dashboard": "npm run build --silent && node dist/src/cli.js stats --dashboard",
18
+ "dashboard:restart": "npm run build --silent && node dist/src/cli.js stats --dashboard --restart",
19
+ "pack": "npm run build --silent && npm pack",
20
+ "test": "npm run build --silent && node --test \"dist/tests/*.test.js\"",
21
+ "demo": "npm run build --silent && node dist/demo/run-demo.js",
22
+ "install:local": "pwsh -ExecutionPolicy Bypass -File ./integrations/windows/install.ps1 -Local",
23
+ "install:local:macos": "./integrations/macos/install.sh --local",
24
+ "install:github": "pwsh -ExecutionPolicy Bypass -File ./integrations/windows/install.ps1",
25
+ "install:github:macos": "./integrations/macos/install.sh",
26
+ "uninstall:local": "pwsh -ExecutionPolicy Bypass -File ./integrations/windows/uninstall.ps1",
27
+ "uninstall:local:macos": "./integrations/macos/uninstall.sh",
28
+ "uninstall:github": "pwsh -ExecutionPolicy Bypass -File ./integrations/windows/uninstall.ps1",
29
+ "uninstall:github:macos": "./integrations/macos/uninstall.sh"
30
+ },
31
+ "devDependencies": {
32
+ "@types/node": "^24.0.0",
33
+ "typescript": "^5.9.0"
34
+ },
35
+ "engines": {
36
+ "node": ">=22.13"
37
+ },
38
+ "publishConfig": {
39
+ "registry": "https://registry.npmjs.org"
40
+ },
41
+ "license": "MIT",
42
+ "repository": {
43
+ "type": "git",
44
+ "url": "git+https://github.com/ivanduplenskikh/shrinker.git"
45
+ }
46
+ }
@@ -1,19 +1,19 @@
1
- Use `shrinker` for high-volume terminal outputs to reduce tokens.
2
-
3
- Routing policy:
4
- - `git status|diff|log|show|reflog|branch|tag|stash` -> `shrinker git ...`
5
- - `npm test|t|install|i|ci|ls|list` -> `shrinker npm ...`
6
- - `docker ps|logs|images|compose` -> `shrinker docker ...`
7
- - `kubectl get|describe|logs` -> `shrinker kubectl ...`
8
- - `gh pr|issue|run` -> `shrinker gh ...`
9
- - `rg`, `find`, `tail`, `cat`, `ls`, `dir` -> `shrinker <command> ...`
10
-
11
- Bypass shrinker when:
12
- - command modifies remote state and output volume is already tiny
13
- - command requires interactive stdin
14
- - command explicitly needs `shrinker --raw`
15
-
16
- Examples:
17
- - `shrinker git log -n 20`
18
- - `shrinker rg "pattern" src`
1
+ Use `shrinker` for high-volume terminal outputs to reduce tokens.
2
+
3
+ Routing policy:
4
+ - `git status|diff|log|show|reflog|branch|tag|stash` -> `shrinker git ...`
5
+ - `npm test|t|install|i|ci|ls|list` -> `shrinker npm ...`
6
+ - `docker ps|logs|images|compose` -> `shrinker docker ...`
7
+ - `kubectl get|describe|logs` -> `shrinker kubectl ...`
8
+ - `gh pr|issue|run` -> `shrinker gh ...`
9
+ - `rg`, `find`, `tail`, `cat`, `ls`, `dir` -> `shrinker <command> ...`
10
+
11
+ Bypass shrinker when:
12
+ - command modifies remote state and output volume is already tiny
13
+ - command requires interactive stdin
14
+ - command explicitly needs `shrinker --raw`
15
+
16
+ Examples:
17
+ - `shrinker git log -n 20`
18
+ - `shrinker rg "pattern" src`
19
19
  - `shrinker docker logs api --tail 500`
@@ -1,28 +0,0 @@
1
-
2
-
3
-
4
- <!-- shrinker agent rules start -->
5
- Use `shrinker` for high-volume terminal outputs to reduce tokens.
6
-
7
- Routing policy:
8
- - `git status|diff|log|show|reflog|branch|tag|stash` -> `shrinker git ...`
9
- - `npm test|t|install|i|ci|ls|list` -> `shrinker npm ...`
10
- - `docker ps|logs|images|compose` -> `shrinker docker ...`
11
- - `kubectl get|describe|logs` -> `shrinker kubectl ...`
12
- - `gh pr|issue|run` -> `shrinker gh ...`
13
- - `rg`, `find`, `tail`, `cat`, `ls`, `dir` -> `shrinker <command> ...`
14
-
15
- Bypass shrinker when:
16
- - command modifies remote state and output volume is already tiny
17
- - command requires interactive stdin
18
- - command explicitly needs `shrinker --raw`
19
-
20
- Examples:
21
- - `shrinker git log -n 20`
22
- - `shrinker rg "pattern" src`
23
- - `shrinker docker logs api --tail 500`
24
- <!-- shrinker agent rules end -->
25
-
26
-
27
-
28
-
package/CLAUDE.md DELETED
@@ -1,28 +0,0 @@
1
-
2
-
3
-
4
- <!-- shrinker agent rules start -->
5
- Use `shrinker` for high-volume terminal outputs to reduce tokens.
6
-
7
- Routing policy:
8
- - `git status|diff|log|show|reflog|branch|tag|stash` -> `shrinker git ...`
9
- - `npm test|t|install|i|ci|ls|list` -> `shrinker npm ...`
10
- - `docker ps|logs|images|compose` -> `shrinker docker ...`
11
- - `kubectl get|describe|logs` -> `shrinker kubectl ...`
12
- - `gh pr|issue|run` -> `shrinker gh ...`
13
- - `rg`, `find`, `tail`, `cat`, `ls`, `dir` -> `shrinker <command> ...`
14
-
15
- Bypass shrinker when:
16
- - command modifies remote state and output volume is already tiny
17
- - command requires interactive stdin
18
- - command explicitly needs `shrinker --raw`
19
-
20
- Examples:
21
- - `shrinker git log -n 20`
22
- - `shrinker rg "pattern" src`
23
- - `shrinker docker logs api --tail 500`
24
- <!-- shrinker agent rules end -->
25
-
26
-
27
-
28
-