Skip to content

feat(cli): add lanterna ps for process discovery#88

Merged
arkerone merged 2 commits into
mainfrom
feat/lanterna-ps-command
May 27, 2026
Merged

feat(cli): add lanterna ps for process discovery#88
arkerone merged 2 commits into
mainfrom
feat/lanterna-ps-command

Conversation

@arkerone
Copy link
Copy Markdown
Owner

Summary

  • Adds lanterna ps, a subcommand that lists live Node.js processes Lanterna can attach to (pid, runtime, attach mode, command, cwd, age, CPU, memory). Output auto-detects: colored table on a TTY, JSON when piped — so agents and scripts can discover an attachable PID before lanterna attach --pid.
  • Refactors attach-target.ts: OS-process discovery (node-process-discovery.ts) and table rendering (node-process-table.ts) move into reusable modules shared between the interactive picker and the new command.
  • Updates the lanterna-profiler skill to drive PID discovery via lanterna ps --format json before attach (enumerate, present, ask — never pick silently). Also refines --heap-sample-interval units in memory-profiling.md and elevates workload sourcing to a primary question in workload-guidance.md.

Test plan

  • npm run typecheck
  • npm test (531 tests across the 3 packages, including the new ps.test.ts and node-process-discovery.test.ts)
  • npm run check (biome)
  • Smoke: lanterna ps on a TTY → colored table sorted cdp-ready first, then by CPU
  • Smoke: lanterna ps | jq . → JSON array
  • Smoke: lanterna ps --format json --pretty → pretty-printed JSON
  • Smoke: empty case (no node processes) → empty JSON array / friendly text message

🤖 Generated with Claude Code

arkerone and others added 2 commits May 27, 2026 17:49
Lists running Node.js processes Lanterna can attach to, with a colored
TTY table or JSON output (auto-detected from stdout). Each entry exposes
pid, runtime, attachMode (`cdp-ready` or `pid-attach`), command, cwd,
ageMs, cpu and memory — so agents and scripts can discover an
attachable PID before `lanterna attach --pid`.

Refactors attach-target.ts so OS-process discovery and table rendering
live in reusable modules (`node-process-discovery.ts`,
`node-process-table.ts`) shared with the new command.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Updates the lanterna-profiler skill to drive PID discovery via the new
`lanterna ps` command before attach: enumerates live node/nodejs
runtimes, presents the candidates back, and asks the user to pick rather
than choosing silently. Prefers `cdp-ready` targets and falls back to
`run` or `--inspect-url` when the list is empty.

Also refines two reference pages: clarifies `--heap-sample-interval`
units in memory-profiling.md and elevates workload sourcing (already
active vs. user-launched vs. agent-launched) to a primary question in
workload-guidance.md.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@arkerone arkerone merged commit f3aa73c into main May 27, 2026
3 checks passed
@arkerone arkerone deleted the feat/lanterna-ps-command branch May 27, 2026 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant