portzap 0.1.4 → 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.
- package/README.md +232 -0
- package/package.json +6 -7
package/README.md
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
# portzap
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
A fast, cross-platform port management tool. Kill, list, and watch processes on network ports.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **Kill processes**: Terminate processes running on specified ports
|
|
10
|
+
- **List ports**: View all listening ports or inspect specific ones
|
|
11
|
+
- **Watch ports**: Automatically kill any process that binds to watched ports
|
|
12
|
+
- **Find free ports**: Find the next available port starting from a given number
|
|
13
|
+
- **Wait for ports**: Block until a port becomes free or occupied
|
|
14
|
+
- **Shell completions**: Generate completions for bash, zsh, fish, powershell, and elvish
|
|
15
|
+
- **Interactive mode**: Select which processes to kill interactively
|
|
16
|
+
- **Cross-platform**: Works on macOS, Linux, and Windows
|
|
17
|
+
- **Graceful shutdown**: Sends SIGTERM first, escalates to SIGKILL if needed
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
### Using Cargo (Recommended)
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
cargo install portzap
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Using npm
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install -g portzap
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### From source
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
git clone https://github.com/justinkarso/portzap
|
|
37
|
+
cd portzap
|
|
38
|
+
cargo install --path .
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Usage
|
|
42
|
+
|
|
43
|
+
### Kill processes on ports
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# Kill process on port 3000
|
|
47
|
+
portzap 3000
|
|
48
|
+
|
|
49
|
+
# Kill processes on multiple ports
|
|
50
|
+
portzap 3000 8080 9090
|
|
51
|
+
|
|
52
|
+
# Kill processes on port range
|
|
53
|
+
portzap 3000-3010
|
|
54
|
+
|
|
55
|
+
# Interactive mode: choose which process to kill
|
|
56
|
+
portzap -i 3000
|
|
57
|
+
|
|
58
|
+
# Dry run: show what would be killed without killing
|
|
59
|
+
portzap --dry-run 3000
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### List processes on ports
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
# List all listening ports
|
|
66
|
+
portzap list
|
|
67
|
+
|
|
68
|
+
# Show what's on port 3000
|
|
69
|
+
portzap list 3000
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Watch ports
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
# Watch port 3000 and auto-kill anything that binds to it
|
|
76
|
+
portzap watch 3000
|
|
77
|
+
|
|
78
|
+
# Watch multiple ports
|
|
79
|
+
portzap watch 3000 8080
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Find free ports
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
# Find the next free port starting from 3000
|
|
86
|
+
portzap free 3000
|
|
87
|
+
|
|
88
|
+
# Find free port with an upper bound
|
|
89
|
+
portzap free 3000 --max 4000
|
|
90
|
+
|
|
91
|
+
# JSON output (useful for scripts and agents)
|
|
92
|
+
portzap free 3000 --format json
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Wait for port state changes
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
# Wait until port 3000 becomes free (default)
|
|
99
|
+
portzap wait 3000
|
|
100
|
+
|
|
101
|
+
# Wait until port 3000 becomes occupied
|
|
102
|
+
portzap wait 3000 --until up
|
|
103
|
+
|
|
104
|
+
# Custom timeout (0 = infinite)
|
|
105
|
+
portzap wait 3000 --timeout 10
|
|
106
|
+
|
|
107
|
+
# Custom poll interval
|
|
108
|
+
portzap wait 3000 --poll 500
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Shell completions
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
# Generate completions for your shell
|
|
115
|
+
portzap completions bash
|
|
116
|
+
portzap completions zsh
|
|
117
|
+
portzap completions fish
|
|
118
|
+
portzap completions powershell
|
|
119
|
+
portzap completions elvish
|
|
120
|
+
|
|
121
|
+
# Example: add to your .bashrc
|
|
122
|
+
eval "$(portzap completions bash)"
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Interactive GUI Mode
|
|
126
|
+
|
|
127
|
+
Launch an interactive terminal UI to browse and manage processes:
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
# Open the GUI dashboard
|
|
131
|
+
portzap gui
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
The GUI provides:
|
|
135
|
+
- **Browse all listening ports** - View all processes using network ports with details (PID, command, protocol)
|
|
136
|
+
- **Search & filter** - Press `/` to filter processes by name
|
|
137
|
+
- **Sort** - Press `s` to cycle through sort options (port, PID, name, protocol)
|
|
138
|
+
- **Select & kill** - Use arrow keys to navigate, `Space`/`Enter` to toggle selection and kill processes
|
|
139
|
+
- **Keyboard shortcuts**:
|
|
140
|
+
- `↑/↓` - Navigate
|
|
141
|
+
- `Space/Enter` - Toggle selection and kill
|
|
142
|
+
- `Tab` - Multi-select
|
|
143
|
+
- `/` - Filter by name
|
|
144
|
+
- `s` - Sort
|
|
145
|
+
- `r` - Refresh
|
|
146
|
+
- `?` - Show help
|
|
147
|
+
- `q/Esc` - Quit
|
|
148
|
+
|
|
149
|
+
## Options
|
|
150
|
+
|
|
151
|
+
- `-i, --interactive`: Interactive mode to select processes
|
|
152
|
+
- `--dry-run`: Show what would be killed without actually killing
|
|
153
|
+
- `-s, --signal`: Signal to send (term, kill, int, hup)
|
|
154
|
+
- `--no-graceful`: Skip graceful shutdown, send signal immediately
|
|
155
|
+
- `-t, --timeout`: Timeout for graceful shutdown (default: 5 seconds)
|
|
156
|
+
- `--format`: Output format (table, json, plain)
|
|
157
|
+
|
|
158
|
+
## Examples
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
# Kill development server on port 3000
|
|
162
|
+
portzap 3000
|
|
163
|
+
|
|
164
|
+
# List all ports in JSON format
|
|
165
|
+
portzap list --format json
|
|
166
|
+
|
|
167
|
+
# Watch port 8080 with 2-second poll interval
|
|
168
|
+
portzap watch 8080 --poll 2000
|
|
169
|
+
|
|
170
|
+
# Kill process on port 5000 interactively
|
|
171
|
+
portzap -i 5000
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Using with AI Agents
|
|
175
|
+
|
|
176
|
+
AI coding agents (Claude Code, Cursor, Copilot, etc.) frequently need to check and kill processes on ports. Instead of parsing platform-specific `lsof` output, agents can use portzap's `--format json` for reliable, structured results.
|
|
177
|
+
|
|
178
|
+
### Agent-friendly commands
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
# Check what's on port 3000 (structured JSON output)
|
|
182
|
+
portzap list 3000 --format json
|
|
183
|
+
|
|
184
|
+
# List all listening ports
|
|
185
|
+
portzap list --format json
|
|
186
|
+
|
|
187
|
+
# Kill a process on port 3000 (with JSON result)
|
|
188
|
+
portzap 3000 --format json
|
|
189
|
+
|
|
190
|
+
# Preview what would be killed without killing
|
|
191
|
+
portzap --dry-run 3000 --format json
|
|
192
|
+
|
|
193
|
+
# Find the next free port starting from 3000
|
|
194
|
+
portzap free 3000 --format json
|
|
195
|
+
|
|
196
|
+
# Wait until a port is free before starting a server
|
|
197
|
+
portzap wait 3000 --timeout 10 --format json
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Example JSON output
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
$ portzap list 3000 --format json
|
|
204
|
+
```
|
|
205
|
+
```json
|
|
206
|
+
[
|
|
207
|
+
{
|
|
208
|
+
"pid": 12345,
|
|
209
|
+
"name": "node",
|
|
210
|
+
"port": 3000,
|
|
211
|
+
"protocol": "tcp",
|
|
212
|
+
"command": "node server.js"
|
|
213
|
+
}
|
|
214
|
+
]
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### Add to your project
|
|
218
|
+
|
|
219
|
+
Drop this into your project's `CLAUDE.md`, `.cursorrules`, or equivalent agent instructions file:
|
|
220
|
+
|
|
221
|
+
```
|
|
222
|
+
When you need to check or kill processes on ports, use `portzap` instead of lsof/netstat:
|
|
223
|
+
- Check a port: portzap list <port> --format json
|
|
224
|
+
- Kill a port: portzap <port> --format json
|
|
225
|
+
- List all ports: portzap list --format json
|
|
226
|
+
- Find free port: portzap free <port> --format json
|
|
227
|
+
- Wait for port: portzap wait <port> --timeout 10 --format json
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
## License
|
|
231
|
+
|
|
232
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "portzap",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "A fast, cross-platform port management tool. Kill, list, and watch processes on network ports.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -8,14 +8,13 @@
|
|
|
8
8
|
},
|
|
9
9
|
"files": [
|
|
10
10
|
"bin.js",
|
|
11
|
-
"
|
|
11
|
+
"README.md"
|
|
12
12
|
],
|
|
13
|
-
"readme": "../README.md",
|
|
14
13
|
"optionalDependencies": {
|
|
15
|
-
"@portzap/darwin-arm64": "0.
|
|
16
|
-
"@portzap/darwin-x64": "0.
|
|
17
|
-
"@portzap/linux-x64": "0.
|
|
18
|
-
"@portzap/linux-arm64": "0.
|
|
14
|
+
"@portzap/darwin-arm64": "0.3.0",
|
|
15
|
+
"@portzap/darwin-x64": "0.3.0",
|
|
16
|
+
"@portzap/linux-x64": "0.3.0",
|
|
17
|
+
"@portzap/linux-arm64": "0.3.0"
|
|
19
18
|
},
|
|
20
19
|
"keywords": [
|
|
21
20
|
"port",
|