@mkhuda/agent-ps 0.4.0 → 0.6.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/CHANGELOG.md CHANGED
@@ -1,5 +1,41 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.6.0
4
+
5
+ Reclaiming what ended sessions leave behind.
6
+
7
+ - `agent-ps prune` removes the parts of an ended session that are not the
8
+ conversation: subagent transcripts, file history, task records, shell
9
+ snapshots, request dumps. On the machine it was written on that is 96M across
10
+ 43 sessions, against 33M for deleting every session older than a month,
11
+ because the sessions holding the space are recent rather than old.
12
+ - It reports by default and removes only with `--apply`. Transcripts are never
13
+ removed, a session with a running process is never touched whatever its age,
14
+ and agents that keep sessions in a database are left alone entirely.
15
+ - `p` in the table does the same for the selected row, after a confirmation
16
+ naming what goes. On a running session it refuses and says why.
17
+ - The detail panel marks which parts of a session can be pruned, and the line
18
+ above the keys reports the total when there is one.
19
+ - One confirmation path now serves every destructive key, rather than each
20
+ growing its own.
21
+ - Release pages take their title and notes from the changelog instead of the
22
+ commit list.
23
+
24
+ ## 0.5.0
25
+
26
+ The token counts four agents were already writing.
27
+
28
+ - Token counts for Claude Code, Codex, Pi and CommandCode, which all record
29
+ what a turn spent and were simply never read. Seven of the eight agents now
30
+ report what a session cost.
31
+ - The counts are summed over a whole log, which is the one thing here that
32
+ reads a file end to end, so it happens only for the session whose detail
33
+ panel is open. Logs are append only, so a session that grew costs the bytes
34
+ it just wrote rather than all of it again.
35
+ - `agent-ps list` now says when `ps` or `lsof` failed even where the table came
36
+ back with rows, rather than only when it came back empty.
37
+ - The tests run in CI, across every supported interpreter.
38
+
3
39
  ## 0.4.0
4
40
 
5
41
  Antigravity, and a legend that was lying about one of the colours.
package/README.md CHANGED
@@ -28,7 +28,7 @@ curl -fsSL https://raw.githubusercontent.com/mkhuda/agent-ps/main/install.sh | s
28
28
  `ps aux | grep claude` gives you PIDs. It will not tell you which one is the
29
29
  session you are talking to, what model it is spending on, whether it has been
30
30
  idle for three days, or which rows are background daemons that outlived the
31
- terminal that started them. It also misses the other six agents entirely.
31
+ terminal that started them. It also misses the other seven agents entirely.
32
32
 
33
33
  agent-ps lists every session with its agent, model, working directory, uptime,
34
34
  idle time and disk footprint, then stops one process tree, every background
@@ -68,8 +68,7 @@ pnpm dlx @mkhuda/agent-ps
68
68
  bunx @mkhuda/agent-ps
69
69
  ```
70
70
 
71
- The npm package is scoped because the plain name is too close to an existing
72
- one. Either way the command it gives you is `agent-ps`.
71
+ Either way the command it gives you is `agent-ps`.
73
72
 
74
73
  ### Just the file
75
74
 
@@ -98,7 +97,7 @@ looking at.
98
97
 
99
98
  ### What it needs, and how to remove it
100
99
 
101
- Python 3.8 or later and nothing from PyPI. Tested on 3.8, 3.9, 3.10 and 3.14.
100
+ Python 3.8 or later and nothing from PyPI. Tested on 3.8, 3.9, 3.12 and 3.13.
102
101
  macOS and Linux; Windows is out because `curses` is not in its standard library.
103
102
  It shells out to `ps`, and on macOS to `lsof`, which is how a process is matched
104
103
  to a session everywhere except Claude Code.
@@ -115,31 +114,23 @@ agent-ps only ever reads the agents' own files.
115
114
  Each agent keeps its own colour in the table, and the same colours label the
116
115
  legend above the keys.
117
116
 
118
- | Agent | | Sessions in | Paired by | Tokens | Reopened with |
119
- |---|---|---|---|---|---|
120
- | [Claude Code](https://claude.com/claude-code) | ![yellow](https://img.shields.io/badge/-d4a72c?style=flat-square) | JSONL | the agent itself | no | `claude --resume` |
121
- | [Pi](https://pi.dev) | ![cyan](https://img.shields.io/badge/-00a3a3?style=flat-square) | JSONL | directory | no | `pi --session` |
122
- | CommandCode | ![magenta](https://img.shields.io/badge/-b83fb8?style=flat-square) | JSONL | directory | no | `cmd --resume` |
123
- | [Codex CLI](https://github.com/openai/codex) | ![green](https://img.shields.io/badge/-3f9e3f?style=flat-square) | JSONL | directory | no | `codex resume` |
124
- | [OpenCode](https://github.com/sst/opencode) | ![blue](https://img.shields.io/badge/-3b6fd4?style=flat-square) | SQLite | directory | yes | `opencode --session` |
125
- | Hermes | ![red](https://img.shields.io/badge/-c0392b?style=flat-square) | SQLite | directory | yes | `hermes --resume` |
126
- | GitHub Copilot | ![white](https://img.shields.io/badge/-cfd3d8?style=flat-square) | VS Code storage | no process | yes | in the editor |
127
- | Antigravity | ![blue](https://img.shields.io/badge/-5f87ff?style=flat-square) | SQLite per conversation | directory | no | `agy --conversation` |
128
-
129
- Only Claude Code records which process is running which session, so every other
130
- pairing is matched on working directory and shown as a guess. OpenCode, Hermes
131
- and Copilot count tokens and cost, which the detail panel shows. Agents you have
132
- not installed are skipped, not reported as missing.
133
-
134
- Antigravity keeps each conversation in its own database, but the fields worth
135
- showing are inside protobuf blobs rather than columns, so they are read out one
136
- at a time. Its steps carry the same status whether a turn is running or has
137
- finished, so it is the one agent whose busy and idle cannot be told apart.
138
-
139
- Copilot is the exception to everything. It runs inside the VS Code extension
140
- host, so it has no process of its own: no PID, no uptime, no CPU or memory, and
141
- nothing to stop. What it does have is the credits each turn spent, which the free
142
- tier meters and nothing else surfaces. A chat counts as open while its workspace
117
+ | Agent | | Sessions in | Paired by | Reopened with |
118
+ |---|---|---|---|---|
119
+ | [Claude Code](https://claude.com/claude-code) | ![yellow](https://img.shields.io/badge/-d4a72c?style=flat-square) | JSONL | the agent itself | `claude --resume` |
120
+ | [Pi](https://pi.dev) | ![cyan](https://img.shields.io/badge/-00a3a3?style=flat-square) | JSONL | directory | `pi --session` |
121
+ | CommandCode | ![magenta](https://img.shields.io/badge/-b83fb8?style=flat-square) | JSONL | directory | `cmd --resume` |
122
+ | [Codex CLI](https://github.com/openai/codex) | ![green](https://img.shields.io/badge/-3f9e3f?style=flat-square) | JSONL | directory | `codex resume` |
123
+ | [OpenCode](https://github.com/sst/opencode) | ![blue](https://img.shields.io/badge/-3b6fd4?style=flat-square) | SQLite | directory | `opencode --session` |
124
+ | Hermes | ![red](https://img.shields.io/badge/-c0392b?style=flat-square) | SQLite | directory | `hermes --resume` |
125
+ | GitHub Copilot | ![white](https://img.shields.io/badge/-cfd3d8?style=flat-square) | VS Code storage | no process | in the editor |
126
+ | Antigravity | ![blue](https://img.shields.io/badge/-5f87ff?style=flat-square) | SQLite per conversation | directory | `agy --conversation` |
127
+
128
+ Only Claude Code records which process is running which session. Every other
129
+ pairing is matched on working directory and shown as a guess. Tokens and cost
130
+ appear in the detail panel.
131
+
132
+ Copilot is the exception: it runs inside the VS Code extension host, so it has no
133
+ process of its own and nothing to stop. A chat counts as open while its workspace
143
134
  is open in the editor.
144
135
 
145
136
  ## Usage
@@ -163,6 +154,7 @@ something.
163
154
  | `S` | reverse the direction |
164
155
  | `k` | stop the selected process and its children, after confirming |
165
156
  | `b` | stop every background helper, after confirming |
157
+ | `p` | remove what the selected ended session left behind, after confirming |
166
158
  | `y`, `n` | answer a confirmation |
167
159
  | `e` | show or hide ended sessions |
168
160
  | `/` | filter by session, title, agent, model, directory, or PID |
@@ -176,9 +168,8 @@ screen in its own colour and, on the right, what the table is sorted by:
176
168
 
177
169
  ![The bottom of the screen: a legend naming all eight agents, each in its own colour, the sort order spelled out on the right, and the key bar beneath it](https://raw.githubusercontent.com/mkhuda/agent-ps/main/images/agent-ps-footer-screenshot.jpg)
178
170
 
179
- That middle line does three jobs. It is the key to the colours in the AGENT
180
- column, it says the sort order in words so the marked heading is never a guess,
181
- and it is where a note appears for a few seconds after you act on something.
171
+ That middle line is the key to the colours, names the sort order in words, and
172
+ is where a note appears for a few seconds after you act on something.
182
173
 
183
174
  Backspacing a filter down to nothing leaves filter mode, so the key bar comes
184
175
  back without reaching for escape.
@@ -209,20 +200,17 @@ ended sessions, then `s` until DISK is marked.
209
200
 
210
201
  ### The detail panel
211
202
 
212
- Enter on a live session opens everything known about it, grouped in the order
213
- the questions arrive: what the session is, what it is doing to the machine, what
214
- it has cost, and the command line last, since it is long and rarely the
215
- question.
203
+ Enter on a live session opens everything known about it, in four groups: what
204
+ the session is, what it is doing to the machine, what it has cost, and the
205
+ command line.
216
206
 
217
207
  <img src="https://raw.githubusercontent.com/mkhuda/agent-ps/main/images/agent-ps-detail.jpg" width="620"
218
208
  alt="The detail panel for a Claude Code session, in four groups. Session: agent, id, status, model, title and directory. Process: pid with its parent, uptime, and time since the last turn. Usage: cpu, memory, and a 41M disk total broken into 28M of transcript, 11M of subagent logs and 2M of file history. Command: the command line that started it.">
219
209
 
220
- The disk total is broken down, because the number on its own is not something
221
- you can act on. Forty megabytes of transcript and forty of file history call for
222
- different answers, and until you can see which it is there is nothing to decide.
210
+ The disk total is broken down by what is holding it, since transcript and file
211
+ history call for different answers.
223
212
 
224
- Where the agent counts tokens, they are here too. Hermes and OpenCode report
225
- cost, Copilot reports the credits a turn spent:
213
+ Tokens and cost are here too, and Copilot reports the credits a turn spent:
226
214
 
227
215
  ```
228
216
  provider opencode-free
@@ -236,14 +224,13 @@ directory rather than reported, so you know before pressing `k` that the pairing
236
224
  is a guess.
237
225
 
238
226
  Enter on an ended session reopens it in a new terminal tab instead. Copilot
239
- chats live in the editor, so they have no reopen command and say so.
227
+ chats reopen in the editor.
240
228
 
241
229
  ### The advisory line
242
230
 
243
231
  A line above the keys points out whatever is worth a look: background helpers
244
232
  left running, sessions untouched for a day, or ended sessions you could resume.
245
- It names the key that acts on it, and only ever shows one thing, since a wall of
246
- warnings teaches people to ignore the line.
233
+ It names the key that acts on it, and shows one thing at a time.
247
234
 
248
235
  ## Scripting
249
236
 
@@ -253,6 +240,9 @@ agent-ps list --all # include ended sessions
253
240
  agent-ps list --json # machine readable, with idle seconds
254
241
  agent-ps list --limit 100 # how many ended sessions (default 40)
255
242
  agent-ps list --filter benchmark # same match as the / key
243
+ agent-ps prune # what ended sessions left, minus the conversation
244
+ agent-ps prune --older-than 30d # only sessions idle that long (default 7d)
245
+ agent-ps prune --apply # actually remove it
256
246
  agent-ps agents # which agents were found, and where
257
247
  agent-ps --agent codex list # one agent, or a comma separated list
258
248
  agent-ps stop 32244 # stop one process tree
@@ -267,6 +257,30 @@ agent-ps --version
267
257
  Piping works without a subcommand: with stdout not a terminal, agent-ps prints
268
258
  the table and exits.
269
259
 
260
+ ## Reclaiming space
261
+
262
+ A session writes more than its conversation. Claude Code alone keeps subagent
263
+ transcripts, file history for `/rewind`, task records and a session
264
+ environment, and on this machine those came to a fifth of everything on disk.
265
+
266
+ ```bash
267
+ agent-ps prune
268
+ ```
269
+
270
+ Reports and removes nothing. It lists what ended sessions left behind, grouped
271
+ by what it is and which sessions hold the most, and `--apply` removes it.
272
+
273
+ In the table, `p` does the same for the row you are on, and the detail panel
274
+ marks which parts of a session those are. On a session that is still running it
275
+ refuses and says why rather than going quiet.
276
+
277
+ Three things it will not do. It never touches a transcript, so every session
278
+ stays resumable. It never touches a session with a running process, whatever
279
+ its age, because file history is what `/rewind` reaches for. And it never
280
+ touches OpenCode, Copilot or Antigravity, whose sessions are rows in a database
281
+ the agent may have open: agent-ps reads, and does not write, the stores it
282
+ did not create.
283
+
270
284
  ## What each column means
271
285
 
272
286
  | Column | Meaning |
@@ -281,18 +295,14 @@ the table and exits.
281
295
  | CPU, MEM | the same `ps` call |
282
296
  | DISK | everything that session left on disk |
283
297
  | DIR | the working directory |
284
- | TITLE | the session title, or its opening prompt where the agent keeps none |
298
+ | TITLE | the session title, or its opening prompt |
285
299
 
286
- UPTIME and ACTIVE often disagree, and that is the point. A process can be five
287
- days old and have answered a minute ago. UPTIME comes from the process table,
288
- ACTIVE from the modification time of the log, which is appended on every turn,
289
- so an ended session shows a dash under UPTIME and only ACTIVE says how stale it
290
- is.
300
+ UPTIME and ACTIVE often disagree: a process can be five days old and have
301
+ answered a minute ago. UPTIME comes from the process table, ACTIVE from the log,
302
+ which is appended on every turn.
291
303
 
292
- Each agent gets its own colour in the AGENT column, assigned in registry order,
293
- and the same colours appear in the legend, which makes that line the key to the
294
- palette. A selected row keeps its own highlight rather than being broken up, so
295
- the cursor stays unmistakable. Terminals without colour fall back to plain text.
304
+ Each agent has its own colour, and the legend above the keys is the key to it.
305
+ Terminals without colour fall back to plain text.
296
306
 
297
307
  ## A PID marked with a question mark
298
308
 
@@ -366,7 +376,7 @@ install fetches. The build is reproducible: the same source always produces the
366
376
  same bytes, so the committed executable can be checked against the tree.
367
377
 
368
378
  ```
369
- 1a44868de812f5d0d2ac012ec97d610a34bca21884f718c7a8dffae80fb05ee6 agent-ps
379
+ b57e60c153471ce8a5630d72a2688633b7d6ff9c5359b372e12fc03d0d9379d9 agent-ps
370
380
  ```
371
381
 
372
382
  Adding an agent takes one class and one line in the registry. See
package/agent-ps CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mkhuda/agent-ps",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
4
4
  "description": "A process table for coding agent sessions. Claude Code, Codex, OpenCode, Hermes, Pi, CommandCode and Copilot in one view, with models, idle time, disk use and one key to stop them.",
5
5
  "keywords": [
6
6
  "cli",