portzap 0.2.1 → 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.
Files changed (2) hide show
  1. package/README.md +103 -1
  2. package/package.json +5 -5
package/README.md CHANGED
@@ -9,6 +9,9 @@ A fast, cross-platform port management tool. Kill, list, and watch processes on
9
9
  - **Kill processes**: Terminate processes running on specified ports
10
10
  - **List ports**: View all listening ports or inspect specific ones
11
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
12
15
  - **Interactive mode**: Select which processes to kill interactively
13
16
  - **Cross-platform**: Works on macOS, Linux, and Windows
14
17
  - **Graceful shutdown**: Sends SIGTERM first, escalates to SIGKILL if needed
@@ -76,6 +79,49 @@ portzap watch 3000
76
79
  portzap watch 3000 8080
77
80
  ```
78
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
+
79
125
  ### Interactive GUI Mode
80
126
 
81
127
  Launch an interactive terminal UI to browse and manage processes:
@@ -125,6 +171,62 @@ portzap watch 8080 --poll 2000
125
171
  portzap -i 5000
126
172
  ```
127
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
+
128
230
  ## License
129
231
 
130
- MIT OR Apache-2.0
232
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "portzap",
3
- "version": "0.2.1",
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": {
@@ -11,10 +11,10 @@
11
11
  "README.md"
12
12
  ],
13
13
  "optionalDependencies": {
14
- "@portzap/darwin-arm64": "0.2.1",
15
- "@portzap/darwin-x64": "0.2.1",
16
- "@portzap/linux-x64": "0.2.1",
17
- "@portzap/linux-arm64": "0.2.1"
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"
18
18
  },
19
19
  "keywords": [
20
20
  "port",