marmonitor 0.2.6 → 0.2.7
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.
- package/README.ko.md +36 -2
- package/README.md +35 -2
- package/dist/cli.js +49 -26
- package/dist/config/index.d.ts +1 -0
- package/dist/config/index.js +6 -1
- package/dist/output/index.d.ts +6 -3
- package/dist/output/index.js +43 -32
- package/dist/output/utils.d.ts +9 -2
- package/dist/output/utils.js +58 -2
- package/dist/scanner/cache.d.ts +10 -0
- package/dist/scanner/cache.js +14 -0
- package/dist/scanner/claude.d.ts +70 -3
- package/dist/scanner/claude.js +302 -16
- package/dist/scanner/codex.d.ts +37 -0
- package/dist/scanner/codex.js +133 -0
- package/dist/scanner/daemon-loop.js +3 -0
- package/dist/scanner/daemon-utils.d.ts +11 -0
- package/dist/scanner/daemon-utils.js +42 -11
- package/dist/scanner/group.d.ts +1 -1
- package/dist/scanner/group.js +9 -0
- package/dist/scanner/index.d.ts +18 -0
- package/dist/scanner/index.js +247 -28
- package/dist/scanner/process.d.ts +12 -0
- package/dist/scanner/process.js +241 -25
- package/dist/scanner/session-registry.d.ts +21 -0
- package/dist/scanner/session-registry.js +85 -4
- package/dist/scanner/status.d.ts +36 -1
- package/dist/scanner/status.js +49 -5
- package/dist/sessions.d.ts +9 -0
- package/dist/sessions.js +11 -0
- package/dist/tmux/index.d.ts +7 -3
- package/dist/tmux/index.js +54 -13
- package/dist/types.d.ts +8 -0
- package/package.json +3 -1
package/dist/tmux/index.js
CHANGED
|
@@ -10,7 +10,7 @@ export function parseTmuxPanes(raw) {
|
|
|
10
10
|
.map((line) => line.trim())
|
|
11
11
|
.filter(Boolean)
|
|
12
12
|
.flatMap((line) => {
|
|
13
|
-
const [target, panePidRaw, cwd] = line.split("\t");
|
|
13
|
+
const [target, panePidRaw, cwd, paneId] = line.split("\t");
|
|
14
14
|
if (!target || !panePidRaw || !cwd)
|
|
15
15
|
return [];
|
|
16
16
|
const [sessionName, coords] = target.split(":");
|
|
@@ -26,6 +26,7 @@ export function parseTmuxPanes(raw) {
|
|
|
26
26
|
paneIndex: Number.parseInt(paneIndexRaw, 10),
|
|
27
27
|
panePid: Number.parseInt(panePidRaw, 10),
|
|
28
28
|
cwd,
|
|
29
|
+
...(paneId && /^%\d+$/.test(paneId) ? { paneId } : {}),
|
|
29
30
|
};
|
|
30
31
|
return Number.isFinite(pane.panePid) ? [pane] : [];
|
|
31
32
|
})
|
|
@@ -64,14 +65,28 @@ export function isPidInTree(rootPid, targetPid, childMap) {
|
|
|
64
65
|
}
|
|
65
66
|
return false;
|
|
66
67
|
}
|
|
67
|
-
export function selectTmuxPaneForAgent(agent, panes, childMap) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
export function selectTmuxPaneForAgent(agent, panes, childMap, ttys = new Map(), allowCwdFallback = false) {
|
|
69
|
+
// Linked windows can expose the same physical pane through multiple paths.
|
|
70
|
+
const uniquePanes = [
|
|
71
|
+
...new Map(panes.map((pane) => [pane.paneId ?? pane.panePid, pane])).values(),
|
|
72
|
+
];
|
|
73
|
+
const treeMatches = uniquePanes.filter((pane) => isPidInTree(pane.panePid, agent.pid, childMap));
|
|
74
|
+
if (treeMatches.length === 1) {
|
|
75
|
+
return { pane: treeMatches[0], match: "pid-tree" };
|
|
71
76
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
77
|
+
if (treeMatches.length > 1)
|
|
78
|
+
return undefined;
|
|
79
|
+
const tty = ttys.get(agent.pid);
|
|
80
|
+
if (tty && /^\/dev\/(?:tty[^/]*|pts\/\d+|pty[^/]*)$/.test(tty)) {
|
|
81
|
+
const ttyMatches = uniquePanes.filter((pane) => ttys.get(pane.panePid) === tty);
|
|
82
|
+
if (ttyMatches.length === 1)
|
|
83
|
+
return { pane: ttyMatches[0], match: "tty" };
|
|
84
|
+
if (ttyMatches.length > 1)
|
|
85
|
+
return undefined;
|
|
86
|
+
}
|
|
87
|
+
const cwdMatches = allowCwdFallback ? uniquePanes.filter((pane) => pane.cwd === agent.cwd) : [];
|
|
88
|
+
if (cwdMatches.length === 1) {
|
|
89
|
+
return { pane: cwdMatches[0], match: "cwd" };
|
|
75
90
|
}
|
|
76
91
|
return undefined;
|
|
77
92
|
}
|
|
@@ -81,7 +96,7 @@ export async function listTmuxPanes() {
|
|
|
81
96
|
"list-panes",
|
|
82
97
|
"-a",
|
|
83
98
|
"-F",
|
|
84
|
-
"#{session_name}:#{window_index}.#{pane_index}\t#{pane_pid}\t#{pane_current_path}",
|
|
99
|
+
"#{session_name}:#{window_index}.#{pane_index}\t#{pane_pid}\t#{pane_current_path}\t#{pane_id}",
|
|
85
100
|
]);
|
|
86
101
|
return parseTmuxPanes(stdout);
|
|
87
102
|
}
|
|
@@ -201,13 +216,39 @@ export async function findActiveAgentPid(agentPids, panePid) {
|
|
|
201
216
|
}
|
|
202
217
|
}
|
|
203
218
|
export async function resolveTmuxJumpTarget(agent) {
|
|
219
|
+
return (await resolveAgentTmuxTargets([agent])).get(agent.pid);
|
|
220
|
+
}
|
|
221
|
+
/** Resolve labels, jumps and stdout capture using process/TTY ownership.
|
|
222
|
+
* Cwd matching is available only to callers that explicitly request an estimate. */
|
|
223
|
+
export async function resolveAgentTmuxTargets(agents, allowCwdFallback = false) {
|
|
224
|
+
const targets = new Map();
|
|
225
|
+
if (agents.length === 0)
|
|
226
|
+
return targets;
|
|
204
227
|
try {
|
|
205
|
-
const [panes,
|
|
206
|
-
|
|
228
|
+
const [panes, tree] = await Promise.all([listTmuxPanes(), getProcessTree()]);
|
|
229
|
+
if (panes.length === 0)
|
|
230
|
+
return targets;
|
|
231
|
+
for (const agent of agents) {
|
|
232
|
+
const target = selectTmuxPaneForAgent(agent, panes, tree, new Map(), false);
|
|
233
|
+
if (target)
|
|
234
|
+
targets.set(agent.pid, target);
|
|
235
|
+
}
|
|
236
|
+
const unresolved = agents.filter((agent) => !targets.has(agent.pid));
|
|
237
|
+
if (unresolved.length > 0) {
|
|
238
|
+
const ttys = await getProcessTtys([
|
|
239
|
+
...new Set([...unresolved.map((a) => a.pid), ...panes.map((p) => p.panePid)]),
|
|
240
|
+
]);
|
|
241
|
+
for (const agent of unresolved) {
|
|
242
|
+
const target = selectTmuxPaneForAgent(agent, panes, tree, ttys, allowCwdFallback);
|
|
243
|
+
if (target)
|
|
244
|
+
targets.set(agent.pid, target);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
207
247
|
}
|
|
208
248
|
catch {
|
|
209
|
-
|
|
249
|
+
// Location is optional: keep the running CLI and fall back to PID labels.
|
|
210
250
|
}
|
|
251
|
+
return targets;
|
|
211
252
|
}
|
|
212
253
|
export async function captureTmuxPaneOutput(target, lines = 30) {
|
|
213
254
|
try {
|
|
@@ -215,7 +256,7 @@ export async function captureTmuxPaneOutput(target, lines = 30) {
|
|
|
215
256
|
"capture-pane",
|
|
216
257
|
"-p",
|
|
217
258
|
"-t",
|
|
218
|
-
target.pane.target,
|
|
259
|
+
target.pane.paneId ?? target.pane.target,
|
|
219
260
|
"-S",
|
|
220
261
|
`-${lines}`,
|
|
221
262
|
]);
|
package/dist/types.d.ts
CHANGED
|
@@ -14,11 +14,13 @@ export type SessionStatus = "Active" | "Idle" | "Stalled" | "Unmatched" | "Dead"
|
|
|
14
14
|
export type SessionPhase = "thinking" | "tool" | "permission" | "done" | undefined;
|
|
15
15
|
/** Runtime source / host environment */
|
|
16
16
|
export type RuntimeSource = "cli" | "vscode" | "unknown";
|
|
17
|
+
export type StatuslineLabelMode = "path" | "tmux" | "auto";
|
|
17
18
|
/** Child/worker process info */
|
|
18
19
|
export interface WorkerProcess {
|
|
19
20
|
pid: number;
|
|
20
21
|
cpuPercent: number;
|
|
21
22
|
memoryMb: number;
|
|
23
|
+
resourceUsageAvailable?: boolean;
|
|
22
24
|
status: SessionStatus;
|
|
23
25
|
}
|
|
24
26
|
/** Detected AI agent session */
|
|
@@ -29,6 +31,8 @@ export interface AgentSession {
|
|
|
29
31
|
cwd: string;
|
|
30
32
|
cpuPercent: number;
|
|
31
33
|
memoryMb: number;
|
|
34
|
+
/** False when resource measurement failed. Numeric resource fields are compatibility placeholders. */
|
|
35
|
+
resourceUsageAvailable?: boolean;
|
|
32
36
|
status: SessionStatus;
|
|
33
37
|
startedAt?: number;
|
|
34
38
|
processStartedAt?: number;
|
|
@@ -41,6 +45,10 @@ export interface AgentSession {
|
|
|
41
45
|
phase?: SessionPhase;
|
|
42
46
|
lastResponseAt?: number;
|
|
43
47
|
lastActivityAt?: number;
|
|
48
|
+
/** Observed-only activity: session file / index timestamps, never an inference (#113). */
|
|
49
|
+
observedActivityAt?: number;
|
|
50
|
+
/** Epoch seconds when the process last looked busy by CPU/phase alone (#113). */
|
|
51
|
+
inferredBusyAt?: number;
|
|
44
52
|
runtimeSource?: RuntimeSource;
|
|
45
53
|
branch?: string;
|
|
46
54
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "marmonitor",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.7",
|
|
4
4
|
"author": "MJ JO <mjjo16@gmail.com>",
|
|
5
5
|
"description": "tmux status bar monitor for AI coding agents — track Claude Code, Codex, Gemini sessions, tokens, and phases in real time",
|
|
6
6
|
"type": "module",
|
|
@@ -48,6 +48,8 @@
|
|
|
48
48
|
"start": "node bin/marmonitor.js",
|
|
49
49
|
"lint": "biome check src tests",
|
|
50
50
|
"test": "node --test tests/*.test.mjs",
|
|
51
|
+
"verify:local": "npm run build && node scripts/verify-local.mjs",
|
|
52
|
+
"verify:labels": "npm run build && node scripts/verify-statusline-labels.mjs",
|
|
51
53
|
"postinstall": "node bin/postinstall.cjs",
|
|
52
54
|
"preuninstall": "node bin/preuninstall.cjs",
|
|
53
55
|
"prepublishOnly": "npm run build && npm test"
|