agent-ps 0.2.0__tar.gz

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.
agent_ps-0.2.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 mkhuda
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,397 @@
1
+ Metadata-Version: 2.4
2
+ Name: agent-ps
3
+ Version: 0.2.0
4
+ Summary: 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
+ Author: mkhuda
6
+ License: MIT License
7
+
8
+ Copyright (c) 2026 mkhuda
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://github.com/mkhuda/agent-ps
29
+ Project-URL: Changelog, https://github.com/mkhuda/agent-ps/blob/main/CHANGELOG.md
30
+ Project-URL: Issues, https://github.com/mkhuda/agent-ps/issues
31
+ Keywords: cli,tui,curses,process-monitor,developer-tools,claude-code,codex,opencode,copilot
32
+ Classifier: Development Status :: 4 - Beta
33
+ Classifier: Environment :: Console :: Curses
34
+ Classifier: Intended Audience :: Developers
35
+ Classifier: License :: OSI Approved :: MIT License
36
+ Classifier: Operating System :: MacOS
37
+ Classifier: Operating System :: POSIX :: Linux
38
+ Classifier: Programming Language :: Python :: 3
39
+ Classifier: Programming Language :: Python :: 3 :: Only
40
+ Classifier: Topic :: System :: Monitoring
41
+ Classifier: Topic :: Utilities
42
+ Requires-Python: >=3.8
43
+ Description-Content-Type: text/markdown
44
+ License-File: LICENSE
45
+ Dynamic: license-file
46
+
47
+ # agent-ps
48
+
49
+ A process table for coding agent sessions, the way `ps` would look if it knew
50
+ what a session was.
51
+
52
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue?style=flat-square)](LICENSE)
53
+ ![Python 3.8+](https://img.shields.io/badge/python-3.8%2B-blue?style=flat-square)
54
+ ![macOS and Linux](https://img.shields.io/badge/platform-macOS%20%7C%20Linux-lightgrey?style=flat-square)
55
+ ![No dependencies](https://img.shields.io/badge/dependencies-none-brightgreen?style=flat-square)
56
+ ![7 agents](https://img.shields.io/badge/agents-7-orange?style=flat-square)
57
+
58
+ ![agent-ps listing sessions from claude, hermes, codex, opencode, pi, commandcode and copilot side by side, each with its model, uptime, idle time, cpu, memory, disk and working directory, with two hermes background helpers at the bottom](images/agent-ps-screenshot.jpg)
59
+
60
+ `ps aux | grep claude` gives you PIDs. It will not tell you which one is the
61
+ session you are talking to, what model it is spending on, whether it has been
62
+ idle for three days, or which rows are background daemons that outlived the
63
+ terminal that started them. It also misses the other six agents entirely.
64
+
65
+ agent-ps lists every session with its agent, model, working directory, uptime,
66
+ idle time and disk footprint, then stops one process tree, every background
67
+ helper, or the lot.
68
+
69
+ One file, no dependencies, reads local files only.
70
+
71
+ ## Install
72
+
73
+ ### One command
74
+
75
+ ```bash
76
+ curl -fsSL https://raw.githubusercontent.com/mkhuda/agent-ps/main/install.sh | sh
77
+ ```
78
+
79
+ Takes the latest release, checks it against the checksum published beside it,
80
+ makes sure it runs, and puts the single file in `~/.local/bin`. Set `BIN_DIR` to
81
+ install elsewhere, or `AGENT_PS_REF=v0.1.0` to pin a version.
82
+
83
+ ### With a package runner
84
+
85
+ ```bash
86
+ uvx agent-ps # uv
87
+ pipx install agent-ps # pipx
88
+ pip install agent-ps # pip
89
+
90
+ npx @mkhuda/agent-ps # npm
91
+ pnpm dlx @mkhuda/agent-ps # pnpm
92
+ bunx @mkhuda/agent-ps # bun
93
+ ```
94
+
95
+ The Python packages install the program itself. The npm one carries the same
96
+ executable and finds an interpreter for it, which is why it is scoped: the plain
97
+ name is too close to an existing package. Either way the command is `agent-ps`.
98
+
99
+ ### Just the file
100
+
101
+ If you would rather not pipe a script into a shell, the executable is the whole
102
+ program:
103
+
104
+ ```bash
105
+ mkdir -p ~/.local/bin
106
+ curl -fsSL -o ~/.local/bin/agent-ps \
107
+ https://github.com/mkhuda/agent-ps/releases/latest/download/agent-ps
108
+ chmod +x ~/.local/bin/agent-ps
109
+ ```
110
+
111
+ Every [release](https://github.com/mkhuda/agent-ps/releases) publishes a
112
+ `SHA256SUMS` next to it.
113
+
114
+ ### From a clone
115
+
116
+ ```bash
117
+ git clone https://github.com/mkhuda/agent-ps && cd agent-ps
118
+ ./install.sh
119
+ ```
120
+
121
+ Builds from the tree rather than downloading, so you install what you are
122
+ looking at.
123
+
124
+ ### What it needs, and how to remove it
125
+
126
+ Python 3.8 or later and nothing from PyPI. Tested on 3.8, 3.9, 3.10 and 3.14.
127
+ macOS and Linux; Windows is out because `curses` is not in its standard library.
128
+ It shells out to `ps`, and on macOS to `lsof`, which is how a process is matched
129
+ to a session everywhere except Claude Code.
130
+
131
+ ```bash
132
+ rm -f ~/.local/bin/agent-ps
133
+ ```
134
+
135
+ That is the whole uninstall. Nothing is written outside that directory, and
136
+ agent-ps only ever reads the agents' own files.
137
+
138
+ ## Agents
139
+
140
+ Each agent keeps its own colour in the table, and the same colours label the
141
+ legend above the keys.
142
+
143
+ | Agent | | Sessions in | Paired by | Tokens | Reopened with |
144
+ |---|---|---|---|---|---|
145
+ | [Claude Code](https://claude.com/claude-code) | ![yellow](https://img.shields.io/badge/-d4a72c?style=flat-square) | JSONL | the agent itself | no | `claude --resume` |
146
+ | [Pi](https://pi.dev) | ![cyan](https://img.shields.io/badge/-00a3a3?style=flat-square) | JSONL | directory | no | `pi --session` |
147
+ | CommandCode | ![magenta](https://img.shields.io/badge/-b83fb8?style=flat-square) | JSONL | directory | no | `cmd --resume` |
148
+ | [Codex CLI](https://github.com/openai/codex) | ![green](https://img.shields.io/badge/-3f9e3f?style=flat-square) | JSONL | directory | no | `codex resume` |
149
+ | [OpenCode](https://github.com/sst/opencode) | ![blue](https://img.shields.io/badge/-3b6fd4?style=flat-square) | SQLite | directory | yes | `opencode --session` |
150
+ | Hermes | ![red](https://img.shields.io/badge/-c0392b?style=flat-square) | SQLite | directory | yes | `hermes --resume` |
151
+ | GitHub Copilot | ![white](https://img.shields.io/badge/-cfd3d8?style=flat-square) | VS Code storage | no process | yes | in the editor |
152
+
153
+ Only Claude Code records which process is running which session, so every other
154
+ pairing is matched on working directory and shown as a guess. OpenCode, Hermes
155
+ and Copilot count tokens and cost, which the detail panel shows. Agents you have
156
+ not installed are skipped, not reported as missing.
157
+
158
+ Copilot is the exception to everything. It runs inside the VS Code extension
159
+ host, so it has no process of its own: no PID, no uptime, no CPU or memory, and
160
+ nothing to stop. What it does have is the credits each turn spent, which the free
161
+ tier meters and nothing else surfaces. A chat counts as open while its workspace
162
+ is open in the editor.
163
+
164
+ ## Usage
165
+
166
+ Run without arguments for the live table:
167
+
168
+ ```bash
169
+ agent-ps
170
+ ```
171
+
172
+ It refreshes every two seconds and stays out of the way until you act on
173
+ something.
174
+
175
+ | Key | Action |
176
+ |---|---|
177
+ | up, down | move the selection |
178
+ | `j`, `K` | down and up, since `k` is taken by stop |
179
+ | home, end | jump to the first or last row |
180
+ | enter | details for a live session, or reopen an ended one |
181
+ | `s` | cycle the sort column |
182
+ | `S` | reverse the direction |
183
+ | `k` | stop the selected process and its children, after confirming |
184
+ | `b` | stop every background helper, after confirming |
185
+ | `y`, `n` | answer a confirmation |
186
+ | `e` | show or hide ended sessions |
187
+ | `/` | filter by session, title, agent, model, directory, or PID |
188
+ | esc | leave filter mode, or close the detail panel |
189
+ | space | pause refreshing |
190
+ | `r` | refresh now |
191
+ | `q` | quit |
192
+
193
+ Those keys live at the bottom of the screen, under a line naming every agent on
194
+ screen in its own colour and, on the right, what the table is sorted by:
195
+
196
+ ![The bottom of the screen: a legend naming each agent in its own colour, the sort shown in words on the right, and the key bar beneath it](images/agent-ps-footer-screenshot.jpg)
197
+
198
+ That middle line does three jobs. It is the key to the colours in the AGENT
199
+ column, it says the sort order in words so the marked heading is never a guess,
200
+ and it is where a note appears for a few seconds after you act on something.
201
+
202
+ Backspacing a filter down to nothing leaves filter mode, so the key bar comes
203
+ back without reaching for escape.
204
+
205
+ ### Sorting
206
+
207
+ `s` cycles the sort column through agent, active, disk, cpu, mem, uptime,
208
+ session and title. The sorted heading is marked in place, and the line above the
209
+ keys names it in words:
210
+
211
+ ```
212
+ PID AGENT SESSION STATUS MODEL UPTIME ACTIVE CPU MEM DISKv
213
+ 31771 claude benchmark idle sonnet-5 54m 54m ago 0.2% 51M 127M
214
+ - claude web-app ended sonnet-5 - 16d8h ago - - 102M
215
+ - claude notes ended opus-5 - 2h22m ago - - 84M
216
+
217
+ agents claude codex commandcode copilot hermes opencode pi sorted by disk, high to low
218
+ up/down select enter details k stop b background e hide ended s sort S reverse / filter q quit
219
+ ```
220
+
221
+ `v` means descending and `^` ascending; `S` flips it. Numbers start at the
222
+ largest, names start at A, and rows with nothing in that column go to the end
223
+ either way.
224
+
225
+ Sorting covers running and ended sessions together, since "which session is the
226
+ biggest" does not care whether its process is still alive. Press `e` to include
227
+ ended sessions, then `s` until DISK is marked.
228
+
229
+ ### The detail panel
230
+
231
+ Enter on a live session opens everything known about it, including tokens and
232
+ cost where the agent counts them:
233
+
234
+ ```
235
+ session details
236
+
237
+ agent hermes
238
+ session 20260905_005254_2c9f4d
239
+ status idle
240
+ model nemotron-3.5-lightning-free
241
+ directory /Users/rg/projects/agent-ps
242
+ title halo are you hermes?
243
+ pid 21098 (parent 17518)
244
+ uptime 1h17m last turn 1h15m ago
245
+ usage cpu 0.0% memory 11M disk 121K
246
+ paired matched by working directory, not reported
247
+ provider opencode-free
248
+ tokens in 24,608 out 242 reasoning 190
249
+ calls 2 api, 6 messages, 0 tool calls
250
+ cost $0.0000 estimated
251
+ command /usr/bin/python3 /Users/rg/.hermes/hermes-agent/hermes
252
+ ```
253
+
254
+ The `paired` line appears only when the pairing was inferred. The provider,
255
+ tokens, calls and cost lines appear only for agents that record them, and are
256
+ simply absent for the rest.
257
+
258
+ Enter on an ended session reopens it in a new terminal tab instead. Copilot
259
+ chats live in the editor, so they have no reopen command and say so.
260
+
261
+ ### The advisory line
262
+
263
+ A line above the keys points out whatever is worth a look: background helpers
264
+ left running, sessions untouched for a day, or ended sessions you could resume.
265
+ It names the key that acts on it, and only ever shows one thing, since a wall of
266
+ warnings teaches people to ignore the line.
267
+
268
+ ## Scripting
269
+
270
+ ```bash
271
+ agent-ps list # print the table and exit
272
+ agent-ps list --all # include ended sessions
273
+ agent-ps list --json # machine readable, with idle seconds
274
+ agent-ps list --limit 100 # how many ended sessions (default 40)
275
+ agent-ps list --filter benchmark # same match as the / key
276
+ agent-ps agents # which agents were found, and where
277
+ agent-ps --agent codex list # one agent, or a comma separated list
278
+ agent-ps stop 32244 # stop one process tree
279
+ agent-ps stop 32244 --dry-run # show what would be stopped
280
+ agent-ps stop-background # stop daemons, warm spares, and servers
281
+ agent-ps stop-background --dry-run
282
+ agent-ps resume <session> # a unique id prefix is enough
283
+ agent-ps resume <session> --print # print the command instead of running it
284
+ agent-ps --version
285
+ ```
286
+
287
+ Piping works without a subcommand: with stdout not a terminal, agent-ps prints
288
+ the table and exits.
289
+
290
+ ## What each column means
291
+
292
+ | Column | Meaning |
293
+ |---|---|
294
+ | PID | the process, or a dash where there is none |
295
+ | AGENT | which agent, and what sort of process when it is not a plain session |
296
+ | SESSION | the directory the session was started in |
297
+ | STATUS | `busy`, `idle`, `ended`, or a dash when nothing says |
298
+ | MODEL | what answered the last turn, or the launcher's routing alias |
299
+ | UPTIME | how long the process has been alive, from one `ps` call |
300
+ | ACTIVE | how long since the session last wrote a turn |
301
+ | CPU, MEM | the same `ps` call |
302
+ | DISK | everything that session left on disk |
303
+ | DIR | the working directory |
304
+ | TITLE | the session title, or its opening prompt where the agent keeps none |
305
+
306
+ UPTIME and ACTIVE often disagree, and that is the point. A process can be five
307
+ days old and have answered a minute ago. UPTIME comes from the process table,
308
+ ACTIVE from the modification time of the log, which is appended on every turn,
309
+ so an ended session shows a dash under UPTIME and only ACTIVE says how stale it
310
+ is.
311
+
312
+ Each agent gets its own colour in the AGENT column, assigned in registry order,
313
+ and the same colours appear in the legend, which makes that line the key to the
314
+ palette. A selected row keeps its own highlight rather than being broken up, so
315
+ the cursor stays unmistakable. Terminals without colour fall back to plain text.
316
+
317
+ ## A PID marked with a question mark
318
+
319
+ Only Claude Code records which process is running which session, in
320
+ `<config dir>/sessions/<pid>.json`. For every other agent the two have to be
321
+ matched on working directory, and that cannot tell apart two sessions of the same
322
+ agent started in the same folder.
323
+
324
+ So an inferred pairing is shown as one:
325
+
326
+ ```
327
+ 32244 claude form-guardian idle opus-5 ...
328
+ 9666? codex agent-ps idle gpt-5.6-luna ...
329
+ ```
330
+
331
+ `9666?` means the process is certain and the session beside it is a guess. The
332
+ guess is the most recently active session in that directory, and where several
333
+ processes of one agent share a directory they are paired newest with newest, so
334
+ the process that started four minutes ago gets the session that has been active
335
+ for four minutes rather than the one from an hour ago.
336
+
337
+ It is still a guess, so the stop confirmation names the directory and says when
338
+ the pairing was inferred:
339
+
340
+ ```
341
+ Stop 1 process(es) in ~/projects/agent-ps, session matched by directory?
342
+ ```
343
+
344
+ Where no session matches at all, the row still appears with whatever the process
345
+ itself can answer. Nothing is invented to fill the gap.
346
+
347
+ ## How it works
348
+
349
+ The parts that are not obvious have their own page:
350
+ [where each agent keeps its sessions](docs/internals.md), how busy and idle are
351
+ decided per agent, which processes count as background helpers, how a shim is
352
+ told apart from a real session, and what the DISK column is adding up.
353
+
354
+ ## Stopping behaviour
355
+
356
+ Processes are stopped depth first, children before parents, so a supervisor does
357
+ not restart a worker you just killed. Each process gets `SIGTERM`, one second to
358
+ exit, then `SIGKILL` if it is still there.
359
+
360
+ agent-ps never lists or stops itself, or the shell that launched it, so running
361
+ it from inside an agent session is safe.
362
+
363
+ Exit status is zero when everything asked for was stopped, and one when something
364
+ survived, which makes it usable in scripts.
365
+
366
+ ## When something is missing
367
+
368
+ | Symptom | Cause |
369
+ |---|---|
370
+ | An agent you use is not listed | agent-ps only looks in the roots above. `agent-ps agents` prints what it found. |
371
+ | SESSION and MODEL are dashes on macOS | pairing needs `lsof` to read a process working directory. Linux reads `/proc`. |
372
+ | A row paired to the wrong session | see the question mark section above |
373
+ | No colour | the terminal reported none, so every row falls back to plain text |
374
+ | A Copilot chat has no PID | it never had one. Copilot runs inside VS Code. |
375
+
376
+ ## Build
377
+
378
+ The executable is a zipapp, built from the package by the standard library:
379
+
380
+ ```bash
381
+ ./build.sh
382
+ ```
383
+
384
+ That writes a single `agent-ps` file with no dependencies, which is what the curl
385
+ install fetches. The build is reproducible: the same source always produces the
386
+ same bytes, so the committed executable can be checked against the tree.
387
+
388
+ ```
389
+ 5045dee9f7c0a85a193886e0b5fcf37020a4c36f10537f36fa453d1020aff365 agent-ps
390
+ ```
391
+
392
+ Adding an agent takes one class and one line in the registry. See
393
+ [CONTRIBUTING.md](CONTRIBUTING.md).
394
+
395
+ ## License
396
+
397
+ MIT. See [LICENSE](LICENSE).