marmonitor 0.2.2 → 0.2.4
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 +60 -17
- package/README.md +37 -2
- package/bin/postinstall.cjs +1 -0
- package/dist/cli.js +277 -103
- package/dist/config/index.d.ts +2 -1
- package/dist/config/index.js +1 -0
- package/dist/output/badge-themes.js +14 -0
- package/dist/output/index.d.ts +1 -0
- package/dist/output/index.js +154 -32
- package/dist/output/utils.d.ts +3 -2
- package/dist/output/utils.js +14 -2
- package/dist/scanner/activity-log.d.ts +29 -0
- package/dist/scanner/activity-log.js +225 -0
- package/dist/scanner/cache.d.ts +1 -0
- package/dist/scanner/cache.js +1 -0
- package/dist/scanner/codex-binding-registry.d.ts +30 -0
- package/dist/scanner/codex-binding-registry.js +87 -0
- package/dist/scanner/codex-sqlite.d.ts +6 -1
- package/dist/scanner/codex-sqlite.js +27 -7
- package/dist/scanner/codex.d.ts +3 -1
- package/dist/scanner/codex.js +14 -4
- package/dist/scanner/daemon-entry.js +3 -0
- package/dist/scanner/daemon-loop.d.ts +3 -0
- package/dist/scanner/daemon-loop.js +88 -4
- package/dist/scanner/index.js +73 -7
- package/dist/scanner/process.js +6 -0
- package/dist/scanner/session-registry.d.ts +4 -1
- package/dist/scanner/session-registry.js +16 -9
- package/dist/scanner/status.d.ts +3 -1
- package/dist/scanner/status.js +53 -8
- package/dist/scanner/types.d.ts +4 -0
- package/dist/types.d.ts +2 -0
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -13,6 +13,7 @@ import { detectCodexPhase, indexCodexSessions, matchCodexSession } from "./scann
|
|
|
13
13
|
import { isDaemonRunning, readDaemonPid, readDaemonSnapshot } from "./scanner/daemon-utils.js";
|
|
14
14
|
import { parseGeminiSession } from "./scanner/gemini.js";
|
|
15
15
|
import { scanAgents } from "./scanner/index.js";
|
|
16
|
+
import { loadRegistryFromFile } from "./scanner/session-registry.js";
|
|
16
17
|
import { detectCliStdoutPhase } from "./scanner/status.js";
|
|
17
18
|
import { captureTmuxPaneOutput, jumpToAgent, resolveTmuxJumpTarget } from "./tmux/index.js";
|
|
18
19
|
import { getClientTty, jumpBack } from "./tmux/jump-anchor.js";
|
|
@@ -75,6 +76,7 @@ function buildHelpAppendix() {
|
|
|
75
76
|
"Core workflows:",
|
|
76
77
|
" status Full one-shot inventory of local AI sessions",
|
|
77
78
|
" attention Priority list for sessions that need review",
|
|
79
|
+
" activity Show recent tool usage and tokens per session",
|
|
78
80
|
" watch Live full-screen monitor",
|
|
79
81
|
" dock Persistent tmux-friendly monitor",
|
|
80
82
|
" --statusline Status bar output for tmux",
|
|
@@ -119,11 +121,34 @@ function buildHelpAppendix() {
|
|
|
119
121
|
" integration.tmux.keys.*",
|
|
120
122
|
" paths.* (runtime data path overrides)",
|
|
121
123
|
"",
|
|
124
|
+
"Daemon:",
|
|
125
|
+
" start Start background scan daemon (required before use)",
|
|
126
|
+
" stop Stop daemon",
|
|
127
|
+
" restart Restart daemon (e.g. after update)",
|
|
128
|
+
" activity Show what each session did (tool calls + tokens)",
|
|
129
|
+
"",
|
|
130
|
+
"Activity log options:",
|
|
131
|
+
" --pid <pid> Filter by process ID",
|
|
132
|
+
" --session <sid> Filter by session ID prefix",
|
|
133
|
+
" --days <n> Number of days to show (default: 1)",
|
|
134
|
+
" --json JSON output",
|
|
135
|
+
"",
|
|
136
|
+
"Navigation:",
|
|
137
|
+
" jump --pid <pid> Jump to a session's tmux pane",
|
|
138
|
+
" jump --attention Interactive jump chooser",
|
|
139
|
+
" jump-back Return to pane before last jump",
|
|
140
|
+
"",
|
|
141
|
+
"Integration:",
|
|
142
|
+
" setup tmux Add tmux plugin to ~/.tmux.conf",
|
|
143
|
+
" update-integration Check tmux plugin sync status",
|
|
144
|
+
" uninstall-integration Remove tmux integration",
|
|
145
|
+
"",
|
|
122
146
|
"Default tmux shortcuts:",
|
|
123
147
|
" Prefix+a Attention popup",
|
|
124
148
|
" Prefix+j Jump popup",
|
|
125
149
|
" Prefix+m Toggle dock",
|
|
126
150
|
" Option+1..5 Direct jump to numbered attention sessions",
|
|
151
|
+
" Option+` Jump back to previous pane",
|
|
127
152
|
"",
|
|
128
153
|
`Config location: ${getConfigDir()}/settings.json`,
|
|
129
154
|
"Common settings:",
|
|
@@ -427,6 +452,11 @@ async function requireDaemonSnapshot() {
|
|
|
427
452
|
}
|
|
428
453
|
return agents;
|
|
429
454
|
}
|
|
455
|
+
async function loadSessionRegistry() {
|
|
456
|
+
const registry = new Map();
|
|
457
|
+
await loadRegistryFromFile(join(getConfigDir(), "session-registry.json"), registry);
|
|
458
|
+
return registry;
|
|
459
|
+
}
|
|
430
460
|
program
|
|
431
461
|
.option("--statusline", "One-line summary for tmux statusbar")
|
|
432
462
|
.option("--statusline-format <format>", "Statusline format: compact | standard | extended | tmux-badges", "compact")
|
|
@@ -512,9 +542,11 @@ program
|
|
|
512
542
|
});
|
|
513
543
|
program
|
|
514
544
|
.command("attention")
|
|
515
|
-
.description("Show prioritized sessions that need attention")
|
|
545
|
+
.description("Show prioritized sessions that need attention, optionally jump to one")
|
|
516
546
|
.option("--json", "Output as JSON")
|
|
517
547
|
.option("--interactive", "Choose an attention item and jump to its tmux pane")
|
|
548
|
+
.option("--pid <pid>", "Jump to AI session by PID")
|
|
549
|
+
.option("--attention-index <n>", "Jump to Nth attention item directly")
|
|
518
550
|
.option("--limit <n>", "Max items to show", "12")
|
|
519
551
|
.option("--config <path>", "Path to settings.json")
|
|
520
552
|
.action(async (opts) => {
|
|
@@ -523,11 +555,78 @@ program
|
|
|
523
555
|
applyTerminalStyle(config.integration.tmux.badgeStyle);
|
|
524
556
|
const limit = resolveAttentionLimit(opts, config.display.attentionLimit);
|
|
525
557
|
const interactiveLimit = resolveAttentionLimit(opts, config.display.attentionLimit, true);
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
558
|
+
const useDirectPid = typeof opts.pid === "string";
|
|
559
|
+
const useDirectIndex = typeof opts.attentionIndex === "string";
|
|
560
|
+
const useInteractive = Boolean(opts.interactive);
|
|
561
|
+
// Direct jump by PID
|
|
562
|
+
if (useDirectPid) {
|
|
563
|
+
const pid = Number.parseInt(opts.pid, 10);
|
|
564
|
+
if (Number.isNaN(pid)) {
|
|
565
|
+
console.error(`Invalid pid: ${opts.pid}`);
|
|
566
|
+
process.exit(1);
|
|
567
|
+
}
|
|
568
|
+
const agent = agents.find((a) => a.pid === pid);
|
|
569
|
+
if (!agent) {
|
|
570
|
+
const result = {
|
|
571
|
+
found: false,
|
|
572
|
+
executed: false,
|
|
573
|
+
insideTmux: Boolean(process.env.TMUX),
|
|
574
|
+
pid,
|
|
575
|
+
message: `AI session not found for pid ${pid}.`,
|
|
576
|
+
};
|
|
577
|
+
if (opts.json) {
|
|
578
|
+
printJumpJson(result);
|
|
579
|
+
}
|
|
580
|
+
else {
|
|
581
|
+
printJumpResult(result);
|
|
582
|
+
}
|
|
583
|
+
process.exit(1);
|
|
584
|
+
}
|
|
585
|
+
const result = await jumpToAgent(agent);
|
|
586
|
+
if (opts.json) {
|
|
587
|
+
printJumpJson(result);
|
|
588
|
+
}
|
|
589
|
+
else {
|
|
590
|
+
printJumpResult(result);
|
|
591
|
+
}
|
|
592
|
+
if (!result.found)
|
|
593
|
+
process.exit(1);
|
|
594
|
+
return;
|
|
595
|
+
}
|
|
596
|
+
// Direct jump by attention index
|
|
597
|
+
if (useDirectIndex) {
|
|
598
|
+
const selection = Number.parseInt(opts.attentionIndex, 10);
|
|
599
|
+
if (Number.isNaN(selection) || selection < 1) {
|
|
600
|
+
console.error(`Invalid attention index: ${opts.attentionIndex}`);
|
|
601
|
+
process.exit(1);
|
|
602
|
+
}
|
|
603
|
+
const item = selectJumpAttentionItem(agents, selection);
|
|
604
|
+
if (!item) {
|
|
605
|
+
console.error(`No jumpable attention item at index ${selection}.`);
|
|
606
|
+
process.exit(1);
|
|
607
|
+
}
|
|
608
|
+
const agent = agents.find((a) => a.pid === item.pid);
|
|
609
|
+
if (!agent) {
|
|
610
|
+
console.error(`AI session not found for pid ${item.pid}.`);
|
|
611
|
+
process.exit(1);
|
|
612
|
+
}
|
|
613
|
+
const result = await jumpToAgent(agent);
|
|
614
|
+
if (opts.json) {
|
|
615
|
+
printJumpJson(result);
|
|
616
|
+
}
|
|
617
|
+
else {
|
|
618
|
+
printJumpResult(result);
|
|
619
|
+
}
|
|
620
|
+
if (!result.found)
|
|
621
|
+
process.exit(1);
|
|
622
|
+
return;
|
|
529
623
|
}
|
|
530
|
-
|
|
624
|
+
// Interactive chooser
|
|
625
|
+
if (useInteractive) {
|
|
626
|
+
if (opts.json) {
|
|
627
|
+
console.error("--interactive cannot be combined with --json.");
|
|
628
|
+
process.exit(1);
|
|
629
|
+
}
|
|
531
630
|
if (!process.stdin.isTTY) {
|
|
532
631
|
console.error("--interactive requires an interactive terminal.");
|
|
533
632
|
process.exit(1);
|
|
@@ -569,6 +668,7 @@ program
|
|
|
569
668
|
process.exit(1);
|
|
570
669
|
return;
|
|
571
670
|
}
|
|
671
|
+
// Default: list mode
|
|
572
672
|
if (opts.json) {
|
|
573
673
|
printAttentionJson(agents, limit);
|
|
574
674
|
}
|
|
@@ -613,7 +713,10 @@ program
|
|
|
613
713
|
const config = await loadConfig(resolveConfigPath(opts));
|
|
614
714
|
let agents;
|
|
615
715
|
try {
|
|
616
|
-
agents = await scanAgents(config, {
|
|
716
|
+
agents = await scanAgents(config, {
|
|
717
|
+
enrichmentMode: "full",
|
|
718
|
+
sessionRegistry: await loadSessionRegistry(),
|
|
719
|
+
});
|
|
617
720
|
}
|
|
618
721
|
catch (error) {
|
|
619
722
|
const payload = {
|
|
@@ -655,10 +758,16 @@ program
|
|
|
655
758
|
sessionLastResponseAt = gemini.lastResponseAt;
|
|
656
759
|
}
|
|
657
760
|
else if (agent.agentName === "Codex") {
|
|
658
|
-
const
|
|
659
|
-
const
|
|
761
|
+
const { loadCodexBindingRegistryFromFile, selectCodexBindingSession, buildCodexBindingKey } = await import("./scanner/codex-binding-registry.js");
|
|
762
|
+
const { getConfigDir } = await import("./config/index.js");
|
|
763
|
+
const { join: pj } = await import("node:path");
|
|
764
|
+
const codexSessions = await indexCodexSessions(config, { activeCwds: [agent.cwd] });
|
|
765
|
+
const bindingRegistry = new Map();
|
|
766
|
+
await loadCodexBindingRegistryFromFile(pj(getConfigDir(), "codex-binding-registry.json"), bindingRegistry);
|
|
767
|
+
const matched = selectCodexBindingSession(bindingRegistry, agent.pid, agent.processStartedAt, agent.cwd, codexSessions) ?? matchCodexSession(agent.cwd, agent.processStartedAt, codexSessions);
|
|
660
768
|
sessionPhase = await detectCodexPhase(matched?.filePath, config);
|
|
661
769
|
sessionSourceFile = matched?.filePath;
|
|
770
|
+
sessionLastActivityAt = matched?.lastActivityAt;
|
|
662
771
|
}
|
|
663
772
|
else if (agent.agentName === "Claude Code" && agent.sessionId) {
|
|
664
773
|
const phaseResult = await detectClaudePhase(agent.sessionId, agent.cwd, agent.startedAt, config);
|
|
@@ -688,7 +797,27 @@ program
|
|
|
688
797
|
}
|
|
689
798
|
: null,
|
|
690
799
|
paneOutput: paneOutput?.trimEnd() ?? null,
|
|
800
|
+
codexBinding: null,
|
|
691
801
|
};
|
|
802
|
+
// Codex binding diagnostics
|
|
803
|
+
if (agent.agentName === "Codex") {
|
|
804
|
+
const { loadCodexBindingRegistryFromFile, buildCodexBindingKey } = await import("./scanner/codex-binding-registry.js");
|
|
805
|
+
const { getConfigDir } = await import("./config/index.js");
|
|
806
|
+
const { join: pj } = await import("node:path");
|
|
807
|
+
const bindingRegistry = new Map();
|
|
808
|
+
await loadCodexBindingRegistryFromFile(pj(getConfigDir(), "codex-binding-registry.json"), bindingRegistry);
|
|
809
|
+
const binding = bindingRegistry.get(buildCodexBindingKey(agent.pid, agent.processStartedAt));
|
|
810
|
+
if (binding) {
|
|
811
|
+
payload.codexBinding = {
|
|
812
|
+
threadId: binding.threadId,
|
|
813
|
+
rolloutPath: binding.rolloutPath,
|
|
814
|
+
confidence: binding.confidence,
|
|
815
|
+
unstableCount: binding.unstableCount,
|
|
816
|
+
lastVerifiedAt: binding.lastVerifiedAt,
|
|
817
|
+
deadAt: binding.deadAt ?? null,
|
|
818
|
+
};
|
|
819
|
+
}
|
|
820
|
+
}
|
|
692
821
|
if (opts.json) {
|
|
693
822
|
console.log(JSON.stringify(payload, null, 2));
|
|
694
823
|
return;
|
|
@@ -703,109 +832,38 @@ program
|
|
|
703
832
|
console.log(`Stdout phase: ${payload.stdoutPhase ?? "(none)"}`);
|
|
704
833
|
console.log(`Session file: ${payload.sessionSourceFile ?? "(none)"}`);
|
|
705
834
|
console.log(`tmux target: ${payload.tmuxTarget ? `${payload.tmuxTarget.pane} (${payload.tmuxTarget.match})` : "(none)"}`);
|
|
835
|
+
if (payload.codexBinding) {
|
|
836
|
+
const b = payload.codexBinding;
|
|
837
|
+
console.log(`Codex binding: thread=${b.threadId} confidence=${b.confidence} unstable=${b.unstableCount}`);
|
|
838
|
+
console.log(` rollout: ${b.rolloutPath}`);
|
|
839
|
+
}
|
|
706
840
|
console.log("Pane capture:");
|
|
707
841
|
console.log(payload.paneOutput ?? "(none)");
|
|
708
842
|
});
|
|
843
|
+
// "jump" is kept as an alias for backward compatibility (Option+N bindings, scripts).
|
|
844
|
+
// --attention maps to attention --interactive, --attention-index and --pid pass through.
|
|
709
845
|
program
|
|
710
846
|
.command("jump")
|
|
711
|
-
.description("
|
|
712
|
-
.option("--pid <pid>", "AI
|
|
847
|
+
.description("Alias for 'attention' — jump to an AI session's tmux pane")
|
|
848
|
+
.option("--pid <pid>", "Jump to AI session by PID")
|
|
713
849
|
.option("--attention", "Choose from attention items interactively")
|
|
714
|
-
.option("--attention-index <n>", "Jump to Nth
|
|
850
|
+
.option("--attention-index <n>", "Jump to Nth attention item directly")
|
|
715
851
|
.option("--json", "Output as JSON")
|
|
716
852
|
.option("--config <path>", "Path to settings.json")
|
|
717
853
|
.action(async (opts) => {
|
|
718
|
-
|
|
719
|
-
const
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
if (
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
console.error("--attention requires an interactive terminal.");
|
|
732
|
-
process.exit(1);
|
|
733
|
-
}
|
|
734
|
-
const limit = resolveAttentionLimit({ limit: undefined }, config.display.attentionLimit, true);
|
|
735
|
-
const totalItems = buildJumpAttentionItems(agents).length;
|
|
736
|
-
const totalPages = Math.max(1, Math.ceil(totalItems / limit));
|
|
737
|
-
let currentPage = 1;
|
|
738
|
-
let item;
|
|
739
|
-
while (true) {
|
|
740
|
-
clearScreen();
|
|
741
|
-
console.log(renderJumpAttentionChooser(agents, currentPage, limit));
|
|
742
|
-
const pageItemCount = Math.min(limit, Math.max(totalItems - (currentPage - 1) * limit, 0));
|
|
743
|
-
const action = await promptSelectionAction(pageItemCount, currentPage, totalPages);
|
|
744
|
-
if (!action || action.kind === "cancel")
|
|
745
|
-
return;
|
|
746
|
-
if (action.kind === "next") {
|
|
747
|
-
currentPage = Math.min(currentPage + 1, totalPages);
|
|
748
|
-
continue;
|
|
749
|
-
}
|
|
750
|
-
if (action.kind === "prev") {
|
|
751
|
-
currentPage = Math.max(currentPage - 1, 1);
|
|
752
|
-
continue;
|
|
753
|
-
}
|
|
754
|
-
item = selectJumpAttentionItemOnPage(agents, currentPage, action.selection, limit);
|
|
755
|
-
break;
|
|
756
|
-
}
|
|
757
|
-
if (!item) {
|
|
758
|
-
console.error("Invalid selection.");
|
|
759
|
-
process.exit(1);
|
|
760
|
-
}
|
|
761
|
-
pid = item.pid;
|
|
762
|
-
}
|
|
763
|
-
else if (useAttentionIndex) {
|
|
764
|
-
const selection = Number.parseInt(opts.attentionIndex, 10);
|
|
765
|
-
if (Number.isNaN(selection) || selection < 1) {
|
|
766
|
-
console.error(`Invalid attention index: ${opts.attentionIndex}`);
|
|
767
|
-
process.exit(1);
|
|
768
|
-
}
|
|
769
|
-
const item = selectJumpAttentionItem(agents, selection);
|
|
770
|
-
if (!item) {
|
|
771
|
-
console.error(`No jumpable attention item at index ${selection}.`);
|
|
772
|
-
process.exit(1);
|
|
773
|
-
}
|
|
774
|
-
pid = item.pid;
|
|
775
|
-
}
|
|
776
|
-
else {
|
|
777
|
-
pid = Number.parseInt(opts.pid, 10);
|
|
778
|
-
if (Number.isNaN(pid)) {
|
|
779
|
-
console.error(`Invalid pid: ${opts.pid}`);
|
|
780
|
-
process.exit(1);
|
|
781
|
-
}
|
|
782
|
-
}
|
|
783
|
-
const agent = agents.find((item) => item.pid === pid);
|
|
784
|
-
if (!agent) {
|
|
785
|
-
const result = {
|
|
786
|
-
found: false,
|
|
787
|
-
executed: false,
|
|
788
|
-
insideTmux: Boolean(process.env.TMUX),
|
|
789
|
-
pid,
|
|
790
|
-
message: `AI session not found for pid ${pid}.`,
|
|
791
|
-
};
|
|
792
|
-
if (opts.json) {
|
|
793
|
-
printJumpJson(result);
|
|
794
|
-
}
|
|
795
|
-
else {
|
|
796
|
-
printJumpResult(result);
|
|
797
|
-
}
|
|
798
|
-
process.exit(1);
|
|
799
|
-
}
|
|
800
|
-
const result = await jumpToAgent(agent);
|
|
801
|
-
if (opts.json) {
|
|
802
|
-
printJumpJson(result);
|
|
803
|
-
}
|
|
804
|
-
else {
|
|
805
|
-
printJumpResult(result);
|
|
806
|
-
}
|
|
807
|
-
if (!result.found)
|
|
808
|
-
process.exit(1);
|
|
854
|
+
// Translate jump flags to attention flags and re-parse
|
|
855
|
+
const args = ["attention"];
|
|
856
|
+
if (opts.attention)
|
|
857
|
+
args.push("--interactive");
|
|
858
|
+
if (opts.attentionIndex)
|
|
859
|
+
args.push("--attention-index", opts.attentionIndex);
|
|
860
|
+
if (opts.pid)
|
|
861
|
+
args.push("--pid", opts.pid);
|
|
862
|
+
if (opts.json)
|
|
863
|
+
args.push("--json");
|
|
864
|
+
if (opts.config)
|
|
865
|
+
args.push("--config", opts.config);
|
|
866
|
+
await program.parseAsync(args, { from: "user" });
|
|
809
867
|
});
|
|
810
868
|
program
|
|
811
869
|
.command("jump-back")
|
|
@@ -903,6 +961,122 @@ program
|
|
|
903
961
|
agents = []; // daemon stopped mid-loop
|
|
904
962
|
}
|
|
905
963
|
});
|
|
964
|
+
program
|
|
965
|
+
.command("activity")
|
|
966
|
+
.description("Show recent tool usage and token activity per session")
|
|
967
|
+
.option("--pid <pid>", "Filter by AI process PID")
|
|
968
|
+
.option("--session <sid>", "Filter by session ID (prefix match)")
|
|
969
|
+
.option("--days <n>", "Number of days to show", "1")
|
|
970
|
+
.option("--lines <n>", "Max activity lines per session (default 30, max 200)", "30")
|
|
971
|
+
.option("--order <dir>", "Sort order: desc (newest first) or asc (oldest first)", "desc")
|
|
972
|
+
.option("--json", "Output as JSON")
|
|
973
|
+
.action(async (opts) => {
|
|
974
|
+
const { getConfigDir } = await import("./config/index.js");
|
|
975
|
+
const { join: pj } = await import("node:path");
|
|
976
|
+
const { getRecentDateKeys, readActivityLog } = await import("./scanner/activity-log.js");
|
|
977
|
+
const logDir = pj(getConfigDir(), "activity-log");
|
|
978
|
+
const days = Math.max(1, Math.min(90, Number(opts.days) || 1));
|
|
979
|
+
const maxLines = Math.max(1, Math.min(200, Number(opts.lines) || 30));
|
|
980
|
+
const descOrder = opts.order !== "asc";
|
|
981
|
+
const allEntries = [];
|
|
982
|
+
for (const dateStr of getRecentDateKeys(days)) {
|
|
983
|
+
const entries = await readActivityLog(logDir, dateStr);
|
|
984
|
+
allEntries.push(...entries);
|
|
985
|
+
}
|
|
986
|
+
// Filter
|
|
987
|
+
let filtered = allEntries;
|
|
988
|
+
let pidFilterAgent;
|
|
989
|
+
if (opts.pid) {
|
|
990
|
+
const agents = await getAgentsSnapshot();
|
|
991
|
+
const agent = agents.find((a) => a.pid === Number(opts.pid));
|
|
992
|
+
if (agent?.sessionId) {
|
|
993
|
+
pidFilterAgent = {
|
|
994
|
+
agentName: agent.agentName,
|
|
995
|
+
pid: agent.pid,
|
|
996
|
+
cwd: agent.cwd,
|
|
997
|
+
sessionId: agent.sessionId,
|
|
998
|
+
};
|
|
999
|
+
const sidPrefix = agent.sessionId.slice(0, 12);
|
|
1000
|
+
filtered = filtered.filter((e) => e.sid.startsWith(sidPrefix));
|
|
1001
|
+
}
|
|
1002
|
+
else {
|
|
1003
|
+
pidFilterAgent = agent
|
|
1004
|
+
? { agentName: agent.agentName, pid: agent.pid, cwd: agent.cwd, sessionId: "" }
|
|
1005
|
+
: undefined;
|
|
1006
|
+
filtered = [];
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
if (opts.session) {
|
|
1010
|
+
const prefix = opts.session;
|
|
1011
|
+
filtered = filtered.filter((e) => e.sid.startsWith(prefix));
|
|
1012
|
+
}
|
|
1013
|
+
if (opts.json) {
|
|
1014
|
+
if (descOrder)
|
|
1015
|
+
filtered.reverse();
|
|
1016
|
+
console.log(JSON.stringify(filtered, null, 2));
|
|
1017
|
+
return;
|
|
1018
|
+
}
|
|
1019
|
+
if (filtered.length === 0) {
|
|
1020
|
+
if (pidFilterAgent) {
|
|
1021
|
+
console.log(`No activity found for PID ${pidFilterAgent.pid}.`);
|
|
1022
|
+
console.log(` Agent: ${pidFilterAgent.agentName}`);
|
|
1023
|
+
console.log(` CWD: ${pidFilterAgent.cwd}`);
|
|
1024
|
+
if (pidFilterAgent.sessionId) {
|
|
1025
|
+
console.log(` SID: ${pidFilterAgent.sessionId.slice(0, 12)}...`);
|
|
1026
|
+
}
|
|
1027
|
+
else {
|
|
1028
|
+
console.log(" SID: (no session matched — activity logging may not have started)");
|
|
1029
|
+
}
|
|
1030
|
+
console.log(`\n Activity log checked: last ${days} day(s) in ${logDir}`);
|
|
1031
|
+
}
|
|
1032
|
+
else {
|
|
1033
|
+
console.log("No activity found.");
|
|
1034
|
+
}
|
|
1035
|
+
return;
|
|
1036
|
+
}
|
|
1037
|
+
// Group by session
|
|
1038
|
+
const bySession = new Map();
|
|
1039
|
+
for (const e of filtered) {
|
|
1040
|
+
const key = `${e.sid}|${e.agent}|${e.cwd}`;
|
|
1041
|
+
if (!bySession.has(key))
|
|
1042
|
+
bySession.set(key, []);
|
|
1043
|
+
bySession.get(key).push(e);
|
|
1044
|
+
}
|
|
1045
|
+
for (const [key, entries] of bySession) {
|
|
1046
|
+
const [sid, agent, cwd] = key.split("|");
|
|
1047
|
+
const totalOut = entries.reduce((sum, e) => sum + (e.tokens?.out ?? 0), 0);
|
|
1048
|
+
const totalCache = entries.reduce((sum, e) => sum + (e.tokens?.cache ?? 0), 0);
|
|
1049
|
+
console.log(`\n${agent} ${sid}... ${cwd}`);
|
|
1050
|
+
console.log(` ${entries.length} actions out:${formatTokensShort(totalOut)} cache:${formatTokensShort(totalCache)}`);
|
|
1051
|
+
console.log(" ─────────────────────────────────────");
|
|
1052
|
+
const sorted = descOrder ? [...entries].reverse() : entries;
|
|
1053
|
+
const shown = sorted.slice(0, maxLines);
|
|
1054
|
+
for (const e of shown) {
|
|
1055
|
+
const t = new Date(e.ts * 1000).toLocaleTimeString("en-GB", {
|
|
1056
|
+
hour: "2-digit",
|
|
1057
|
+
minute: "2-digit",
|
|
1058
|
+
});
|
|
1059
|
+
console.log(` ${t} ${e.tool}: ${truncateForDisplay(e.target, 60)}`);
|
|
1060
|
+
}
|
|
1061
|
+
if (entries.length > maxLines) {
|
|
1062
|
+
console.log(` ... +${entries.length - maxLines} more (use --lines to show more)`);
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
});
|
|
1066
|
+
function formatTokensShort(n) {
|
|
1067
|
+
if (n >= 1_000_000)
|
|
1068
|
+
return `${(n / 1_000_000).toFixed(1)}M`;
|
|
1069
|
+
if (n >= 1_000)
|
|
1070
|
+
return `${(n / 1_000).toFixed(1)}K`;
|
|
1071
|
+
return String(n);
|
|
1072
|
+
}
|
|
1073
|
+
function truncateForDisplay(value, maxLength) {
|
|
1074
|
+
if (value.length <= maxLength)
|
|
1075
|
+
return value;
|
|
1076
|
+
if (maxLength <= 3)
|
|
1077
|
+
return value.slice(0, maxLength);
|
|
1078
|
+
return `${value.slice(0, maxLength - 3)}...`;
|
|
1079
|
+
}
|
|
906
1080
|
program
|
|
907
1081
|
.command("clean")
|
|
908
1082
|
.description("Show or terminate unmatched processes")
|
|
@@ -912,7 +1086,7 @@ program
|
|
|
912
1086
|
.option("--pid <pid...>", "Only include specific unmatched PID(s)")
|
|
913
1087
|
.action(async (opts) => {
|
|
914
1088
|
const config = await loadConfig(resolveConfigPath(opts));
|
|
915
|
-
const agents = await scanAgents(config);
|
|
1089
|
+
const agents = await scanAgents(config, { sessionRegistry: await loadSessionRegistry() });
|
|
916
1090
|
const selectedPids = Array.isArray(opts.pid)
|
|
917
1091
|
? opts.pid
|
|
918
1092
|
.map((value) => Number.parseInt(value, 10))
|
package/dist/config/index.d.ts
CHANGED
|
@@ -62,7 +62,7 @@ export interface MarmonitorConfig {
|
|
|
62
62
|
dockToggle: string;
|
|
63
63
|
directJump: string[];
|
|
64
64
|
};
|
|
65
|
-
badgeStyle: "basic" | "basic-mono" | "text" | "text-mono";
|
|
65
|
+
badgeStyle: "basic" | "basic-mono" | "block" | "block-mono" | "text" | "text-mono";
|
|
66
66
|
};
|
|
67
67
|
wezterm: {
|
|
68
68
|
enabled: boolean;
|
|
@@ -84,6 +84,7 @@ export interface MarmonitorConfig {
|
|
|
84
84
|
statuslineTtlMs: number;
|
|
85
85
|
stdoutHeuristicTtlMs: number;
|
|
86
86
|
daemonIntervalSec: number;
|
|
87
|
+
activityRetentionDays: number;
|
|
87
88
|
};
|
|
88
89
|
}
|
|
89
90
|
/** Get config search paths in priority order */
|
package/dist/config/index.js
CHANGED
|
@@ -20,6 +20,20 @@ export const BADGE_THEMES = {
|
|
|
20
20
|
empty: "#[fg=#313244,bg=#1e1e2e]#[fg=#6c7086,bg=#313244] no active #[fg=#313244,bg=#1e1e2e]#[default]",
|
|
21
21
|
jumpBack: "#[fg=#313244,bg=#1e1e2e]#[fg=#6c7086,bg=#313244] ↩ #[fg=#313244,bg=#1e1e2e]#[default]",
|
|
22
22
|
},
|
|
23
|
+
block: {
|
|
24
|
+
badge: "#[bold,fg={fg},bg={bg}] {label} #[default]",
|
|
25
|
+
attention: "#[bold,fg=#11111b,bg={bg}] {index} #[fg=#cdd6f4,bg=#313244] {label} #[default]",
|
|
26
|
+
focus: "#[fg=#bac2de,bg=#181825] {text} #[default]",
|
|
27
|
+
empty: "#[fg=#cdd6f4,bg=#313244] no active #[default]",
|
|
28
|
+
jumpBack: "#[fg=#bac2de,bg=#45475a] ↩ #[default]",
|
|
29
|
+
},
|
|
30
|
+
"block-mono": {
|
|
31
|
+
badge: "#[bold,fg=#cdd6f4,bg=#313244] {label} #[default]",
|
|
32
|
+
attention: "#[bold,fg=#cdd6f4,bg=#313244] {index} #[fg=#6c7086,bg=#1e1e2e] {label} #[default]",
|
|
33
|
+
focus: "#[fg=#6c7086,bg=#181825] {text} #[default]",
|
|
34
|
+
empty: "#[fg=#6c7086,bg=#313244] no active #[default]",
|
|
35
|
+
jumpBack: "#[fg=#6c7086,bg=#313244] ↩ #[default]",
|
|
36
|
+
},
|
|
23
37
|
text: {
|
|
24
38
|
badge: "#[fg={bg}]{label}#[default]",
|
|
25
39
|
attention: "#[fg={bg}]{index} {label}#[default]",
|
package/dist/output/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { type BadgeStyle, type StatuslineFormat } from "./utils.js";
|
|
|
5
5
|
export declare function getSystemInfo(): Promise<SystemInfo>;
|
|
6
6
|
/** Apply badge style to terminal chalk output: mono uses bold/dim only */
|
|
7
7
|
export declare function applyTerminalStyle(badgeStyle: BadgeStyle): void;
|
|
8
|
+
export declare function abbreviateModel(model: string | undefined): string;
|
|
8
9
|
/** Print agent status as formatted text */
|
|
9
10
|
export declare function printStatus(agents: AgentSession[]): Promise<void>;
|
|
10
11
|
/** Print agent status as JSON */
|