ps
uses tcmts.cli.running.liveRunning, which uses node:fs
tcm ps: what tcm runs on the codebase now, oldest first: each tcm dev, start and serve (with
the app it runs, the branch it's on, where it's listening and how long it's run), then each agent's MCP server
(tcm mcp, with its session's branch and the directory it's for).
import type { Codebase } from "#codebase/tcmts/cli/codebase"; import { liveMcpServers } from "#codebase/tcmts/cli/mcp"; import { liveRunning, shownUptime } from "#codebase/tcmts/cli/running"; import { dim } from "#codebase/tcmts/cli/style"; export function ps(cb: Codebase): number { const now = Date.now(); const rows = [ ...liveRunning(cb.lay.root).map((r) => ({ pid: r.pid, what: [r.command, r.app].filter(Boolean).join(" "), branch: r.branch ?? "", where: r.url ?? "", up: shownUptime(now - r.started), })), ...liveMcpServers(cb.lay.root).map((m) => ({ pid: m.pid, what: "mcp", branch: m.branch ?? "", where: m.client ? `for ${m.client}` : "", up: "", })), ]; if (!rows.length) { console.log( dim( "nothing tcm runs is running on this codebase (tcm dev, start, serve and mcp are listed here)", ), ); return 0; } const width = (k: "what" | "branch" | "where") => Math.max(...rows.map((r) => r[k].length)); const [w, b, u] = [width("what"), width("branch"), width("where")]; for (const r of rows) console.log( `${dim(String(r.pid).padStart(6))} ${r.what.padEnd(w)} ${r.branch.padEnd(b)} ${r.where.padEnd(u)} ${dim(r.up)}`.trimEnd(), ); return 0; }
uses
- tcmts.cli.codebase.Codebase
- tcmts.cli.mcp.liveMcpServers
- tcmts.cli.running.liveRunning
- tcmts.cli.running.shownUptime
- tcmts.cli.style.dim