Skip to content

Commit 885f04a

Browse files
authored
Roll status and get_log_paths into list (#31)
* CLAUDE.md updates * Unify list,status,get_log_paths to just list * Fixes, debug logging * Probably fix busted run() * Claude
1 parent bc966fa commit 885f04a

17 files changed

Lines changed: 319 additions & 540 deletions

CLAUDE.md

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
# Claude Development Notes
22

3+
## Structure
4+
5+
Typically begin by reading README.md.
6+
7+
Key files:
8+
- persistproc/cli.py
9+
- persistproc/tools.py
10+
- persistproc/process_manager.py
11+
312
## Running Tests
413

5-
Use `uv run python -m pytest` to run tests.
14+
Use `uv run python -m pytest` to run tests. For development, use `uv run python -m pytest -x --maxfail=3` to stop after 3 failures.
615

716
## Linting and Type Checking
817

@@ -18,4 +27,29 @@ Instead:
1827
- Use the test helpers in `tests/helpers.py` for programmatic testing
1928
- Debug issues through test output and logging
2029

21-
**NEVER background a process with an `&` suffix.**
30+
**NEVER background a process with an `&` suffix.**
31+
32+
**ALWAYS use `git --no-pager diff` for all diffs, never `git diff`.**
33+
34+
If you get a timeout in tests while running locally, it is NOT a "timing issue" or "race condition." It is as REAL BUG. You are running on a fast computer that is not under load. The correct response to a test timeout is to ADD DEBUG LOGGING and THINK HARD.
35+
36+
## Workflow guidelines
37+
38+
For EVERY programming task assigned, you are NOT FINISHED until you can produce a message in the following format:
39+
40+
<ReportFormat>
41+
After-action report for (task title here)
42+
43+
Relevant files found:
44+
- (list them)
45+
46+
(1-3 paragraphs justifying why the change is both correct and comprehensive)
47+
48+
Steps taken to verify:
49+
- (list them)
50+
51+
Web links supporting my changes:
52+
- (list them)
53+
54+
I solemnly swear there are no further steps I can take to verify the changes within the boundaries set for me.
55+
</ReportFormat>

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,10 @@ The server exposes the following tools:
9797
| Tool | Description |
9898
| --- | --- |
9999
| start | Start a new long-running process. |
100-
| list | List all managed processes and their status. |
101-
| status | Get the detailed status of a specific process. |
100+
| list | List all managed processes and their status. Can optionally filter by pid, command, or working directory and provides log paths. |
102101
| stop | Stop a running process. |
103102
| restart | Stops a process and starts it again with the same parameters. |
104103
| output | Retrieve captured output from a process. |
105-
| get_log_paths | Get the paths to the log files for a specific process. |
106104
| kill_persistproc | Kill all managed processes and get the PID of the persistproc server. |
107105

108106
## Getting started

docs/index.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,10 @@ The server exposes the following tools:
9696
| Tool | Description |
9797
| --- | --- |
9898
| start | Start a new long-running process. |
99-
| list | List all managed processes and their status. |
100-
| status | Get the detailed status of a specific process. |
99+
| list | List all managed processes and their status. Can optionally filter by pid, command, or working directory and provides log paths. |
101100
| stop | Stop a running process. |
102101
| restart | Stops a process and starts it again with the same parameters. |
103102
| output | Retrieve captured output from a process. |
104-
| get_log_paths | Get the paths to the log files for a specific process. |
105103
| kill_persistproc | Kill all managed processes and get the PID of the persistproc server. |
106104

107105
## Getting started

docs/tools.md

Lines changed: 24 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,14 @@ Add a custom label for complex commands:
213213

214214
## `list`
215215

216-
List all managed processes and their status.
216+
List all managed processes and their status, optionally filtered by pid, command, or working directory. Provides log paths for each process.
217217

218218
<!-- persistproc list --help -->
219219
```
220220
usage: persistproc list [-h] [--port PORT] [--data-dir DATA_DIR] [-v] [-q]
221-
[--format {text,json}]
221+
[--format {text,json}] [--pid PID]
222+
[--command-or-label COMMAND_OR_LABEL]
223+
[--working-directory WORKING_DIRECTORY]
222224
223225
options:
224226
-h, --help show this help message and exit
@@ -231,84 +233,55 @@ options:
231233
warnings and errors.
232234
--format {text,json} Output format (default: text; env:
233235
$PERSISTPROC_FORMAT)
236+
--pid PID Filter by process ID
237+
--command-or-label COMMAND_OR_LABEL
238+
Filter by command or label
239+
--working-directory WORKING_DIRECTORY
240+
Filter by working directory
234241
```
235242

236243
**Examples**
237244

245+
List all processes:
246+
238247
```bash
239248
> persistproc list
240249
PID 12345: npm run dev in /Users/user/myproject (running)
241250
Command: npm run dev
242251
Working directory: /Users/user/myproject
252+
Stdout log: /Users/user/Library/Application Support/persistproc/logs/12345_stdout.log
253+
Stderr log: /Users/user/Library/Application Support/persistproc/logs/12345_stderr.log
254+
Combined log: /Users/user/Library/Application Support/persistproc/logs/12345_combined.log
243255

244256
PID 67890: python -m http.server 8080 in /Users/user/docs (running)
245257
Command: python -m http.server 8080
246258
Working directory: /Users/user/docs
247259
```
248260

249-
Get more detailed output or different formats:
261+
Filter by specific process ID:
250262

251263
```bash
252-
> persistproc list -v
253-
> persistproc list --format json
254-
```
255-
256-
## `status`
257-
258-
Get the detailed status of a specific process.
259-
260-
<!-- persistproc status --help -->
261-
```
262-
usage: persistproc status [-h] [--port PORT] [--data-dir DATA_DIR] [-v] [-q]
263-
[--format {text,json}]
264-
[--working-directory WORKING_DIRECTORY]
265-
TARGET [args ...]
266-
267-
positional arguments:
268-
TARGET The PID, label, or command to get status for.
269-
args Arguments to the command
270-
271-
options:
272-
-h, --help show this help message and exit
273-
--port PORT Server port (default: 8947; env: $PERSISTPROC_PORT)
274-
--data-dir DATA_DIR Data directory (default:
275-
~/Library/Application Support/persistproc;
276-
env: $PERSISTPROC_DATA_DIR)
277-
-v, --verbose Increase verbosity; you can use -vv for more
278-
-q, --quiet Decrease verbosity. Passing -q once will show only
279-
warnings and errors.
280-
--format {text,json} Output format (default: text; env:
281-
$PERSISTPROC_FORMAT)
282-
--working-directory WORKING_DIRECTORY
283-
The working directory for the process.
264+
> persistproc list --pid 12345
284265
```
285266

286-
**Examples**
287-
288-
Get status by PID, command, or label:
267+
Filter by command or label:
289268

290269
```bash
291-
> persistproc status 12345
292-
PID: 12345
293-
Command: npm run dev
294-
Working directory: /Users/user/myproject
295-
Status: running
296-
Label: npm run dev in /Users/user/myproject
297-
298-
> persistproc status npm run dev
299-
> persistproc status "my-dev-server"
270+
> persistproc list --command "npm run dev"
271+
> persistproc list --command "my-dev-server"
300272
```
301273

302-
Add working directory context when matching by command:
274+
Filter by working directory:
303275

304276
```bash
305-
> persistproc status --working-directory /path/to/project npm run dev
277+
> persistproc list --working-directory /Users/user/myproject
306278
```
307279

308-
Get structured output:
280+
Get more detailed output or different formats:
309281

310282
```bash
311-
> persistproc status --format json 12345
283+
> persistproc list -v
284+
> persistproc list --format json
312285
```
313286

314287
## `stop`
@@ -507,55 +480,6 @@ Specify working directory context when matching by command:
507480
> persistproc output --working-directory /path/to/project npm run dev
508481
```
509482

510-
## `get_log_paths`
511-
512-
Get the paths to the log files for a specific process.
513-
514-
<!-- persistproc get_log_paths --help -->
515-
```
516-
usage: persistproc get_log_paths [-h] [--port PORT] [--data-dir DATA_DIR] [-v]
517-
[-q] [--format {text,json}]
518-
[--working-directory WORKING_DIRECTORY]
519-
TARGET [args ...]
520-
521-
positional arguments:
522-
TARGET The PID, label, or command to get log paths for.
523-
args Arguments to the command
524-
525-
options:
526-
-h, --help show this help message and exit
527-
--port PORT Server port (default: 8947; env: $PERSISTPROC_PORT)
528-
--data-dir DATA_DIR Data directory (default:
529-
~/Library/Application Support/persistproc;
530-
env: $PERSISTPROC_DATA_DIR)
531-
-v, --verbose Increase verbosity; you can use -vv for more
532-
-q, --quiet Decrease verbosity. Passing -q once will show only
533-
warnings and errors.
534-
--format {text,json} Output format (default: text; env:
535-
$PERSISTPROC_FORMAT)
536-
--working-directory WORKING_DIRECTORY
537-
The working directory for the process.
538-
```
539-
540-
**Examples**
541-
542-
Get log file paths by PID, command, or label:
543-
544-
```bash
545-
> persistproc get_log_paths 12345
546-
Stdout log: /Users/user/Library/Application Support/persistproc/logs/12345_stdout.log
547-
Stderr log: /Users/user/Library/Application Support/persistproc/logs/12345_stderr.log
548-
549-
> persistproc get_log_paths npm run dev
550-
> persistproc get_log_paths "my-dev-server"
551-
```
552-
553-
Add working directory context when matching by command:
554-
555-
```bash
556-
> persistproc get_log_paths --working-directory /path/to/project npm run dev
557-
```
558-
559483
## `kill_persistproc`
560484

561485
Kill all managed processes and get the PID of the persistproc server.

persistproc/cli.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import argparse
2+
import logging
23
import os
34
import shlex
45
import sys
@@ -384,6 +385,11 @@ def cli() -> None:
384385
"""Main CLI entry point."""
385386
try:
386387
action, metadata = parse_cli(sys.argv[1:])
388+
389+
logger = logging.getLogger(__name__)
390+
logger.debug("action: %s", repr(action))
391+
logger.debug("metadata: %s", repr(metadata))
392+
387393
handle_cli_action(action, metadata)
388394
except SystemExit as e:
389395
if e.code != 0:

persistproc/mcp_client_utils.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
from .process_types import (
1212
KillPersistprocResult,
1313
ListProcessesResult,
14-
ProcessLogPathsResult,
1514
ProcessOutputResult,
16-
ProcessStatusResult,
1715
RestartProcessResult,
1816
StartProcessResult,
1917
StopProcessResult,
@@ -69,10 +67,8 @@ def _create_result_object(tool_name: str, result_data: dict) -> object | None:
6967
result_type_map = {
7068
"start": StartProcessResult,
7169
"stop": StopProcessResult,
72-
"status": ProcessStatusResult,
7370
"list": ListProcessesResult,
7471
"output": ProcessOutputResult,
75-
"get_log_paths": ProcessLogPathsResult,
7672
"restart": RestartProcessResult,
7773
"kill_persistproc": KillPersistprocResult,
7874
}

0 commit comments

Comments
 (0)