fix(devkitd): ps parser drops all rows on Linux (padded columns), so `agent list` shows no agents
Summary
On Linux, ai-devkit agent list reports "No running agents detected." even though Claude Code sessions are running. The devkitd daemon fails to parse every row of ps output, so it returns []. The CLI treats any non-null daemon answer as authoritative and never falls back to its local adapters.
Versions: ai-devkit 0.70.0, devkitd v0.1.0 (@ai-devkit/devkitd-linux-x64), Linux 6.8 x86_64, procps ps.
Repro
claude & # any running agent
ai-devkit agent list # -> "No running agents detected."
AI_DEVKIT_NO_DAEMON=1 ai-devkit agent list # -> agents listed correctly
Root cause
The daemon polls ps -axo pid=,ppid=,tty=,command=. Linux procps right-aligns/pads columns with runs of spaces:
61524 60968 pts/1 claude
With RUST_LOG=trace, every sweep logs sweep procs=0, and the daemon's agents table in ~/.ai-devkit/daemon.db stays empty. Feeding the daemon synthetic ps output via a stub ps on PATH isolates the problem: any run of more than one space between fields makes the line unparseable.
stub ps line |
sweep procs |
|---|---|
61524 60968 pts/1 claude |
1 |
61524 60968 pts/1 claude (single leading space) |
1 |
61524 60968 pts/1 claude |
0 |
61524 60968 pts/1 claude |
0 |
61524 60968 pts/1 claude (real procps output) |
0 |
The parser most likely splits on single spaces (e.g. split(' ')/splitn(4, ' ')) rather than on whitespace runs.
The CLI side then hides the failure. AgentManager.listAgents() (@ai-devkit/agent-manager/dist/AgentManager.js) treats [] from the daemon as authoritative and skips local adapters, even though they correctly detect the agents.
Suggested fix
- devkitd: parse
psrows by splitting on whitespace runs for the first three fields (split_whitespace/splitnon trimmed whitespace) and keep the remainder ascommand. - CLI (defense in depth): consider not treating an empty daemon result as authoritative when local detection finds agents, or at least log a warning when a sweep parses 0 processes from non-empty
psoutput.
Workaround
export AI_DEVKIT_NO_DAEMON=1