marmonitor 0.2.3 → 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 +2 -0
- package/dist/cli.js +129 -103
- package/dist/config/index.d.ts +1 -1
- 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 +2 -1
- package/dist/output/utils.js +1 -0
- package/dist/scanner/daemon-loop.js +4 -26
- package/dist/scanner/index.js +14 -0
- package/dist/scanner/process.js +6 -0
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
package/README.ko.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
5
|
<p align="center">
|
|
6
|
-
<strong>Claude Code
|
|
6
|
+
<strong>Claude Code · Codex · Gemini용 tmux 상태바 모니터 — AI 코딩 세션을 실시간으로 추적하세요</strong>
|
|
7
7
|
</p>
|
|
8
8
|
|
|
9
9
|
<p align="center">
|
|
@@ -21,20 +21,20 @@
|
|
|
21
21
|
|
|
22
22
|
## 왜 marmonitor인가?
|
|
23
23
|
|
|
24
|
-
tmux에서 여러 AI 코딩 에이전트를 동시에 실행하는
|
|
24
|
+
tmux에서 여러 AI 코딩 에이전트를 동시에 실행하는 건 이제 일상입니다 — Claude Code가 백엔드를 리팩토링하고, Codex가 다른 패널에서 테스트를 작성하고, Gemini가 문서를 검토합니다. 하지만 세션이 늘어날수록 같은 문제에 부딪힙니다:
|
|
25
25
|
|
|
26
26
|
- 패널로 전환했더니 에이전트가 10분째 `allow` 승인을 기다리고 있었다
|
|
27
27
|
- 방금 작업하던 Codex 세션이 어느 윈도우에 있는지 기억나지 않는다
|
|
28
28
|
- 여러 세션에서 토큰을 얼마나 소모했는지 알 수 없다
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
**이걸 보여주는 대시보드가 없습니다.** 패널을 하나하나 돌아가며 직접 확인해야 합니다.
|
|
31
31
|
|
|
32
|
-
**marmonitor**가 이 문제를 해결합니다. tmux.conf에 한 줄만 추가하면, 상태바가 머신에서 실행 중인 모든 AI
|
|
32
|
+
**marmonitor**가 이 문제를 해결합니다. tmux.conf에 한 줄만 추가하면, 상태바가 로컬 머신에서 실행 중인 모든 AI 세션을 실시간으로 보여주는 컨트롤 패널이 됩니다.
|
|
33
33
|
|
|
34
34
|
<p align="center">
|
|
35
35
|
<img src="docs/use_sample.png" alt="marmonitor tmux 상태바" width="640">
|
|
36
36
|
<br>
|
|
37
|
-
<em>에이전트 수, 단계 뱃지,
|
|
37
|
+
<em>에이전트 수, 단계 뱃지, 번호 붙은 어텐션 필 — 모두 tmux 상태바에서 확인할 수 있습니다</em>
|
|
38
38
|
</p>
|
|
39
39
|
|
|
40
40
|
### 주요 기능
|
|
@@ -59,9 +59,9 @@ tmux에서 여러 AI 코딩 에이전트를 동시에 실행하는 것은 이제
|
|
|
59
59
|
<em>모든 세션의 상태, 토큰, 단계, CPU/MEM, 워커 프로세스 트리</em>
|
|
60
60
|
</p>
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
**에이전트 수정 불필요** — API 키, 플러그인, 코드 변경 없이 바로 쓸 수 있습니다. marmonitor는 외부에서 로컬 프로세스 정보와 세션 파일을 읽습니다. 명령어 두 개만 실행하면 됩니다: `npm install -g marmonitor`, `marmonitor setup tmux`.
|
|
63
63
|
|
|
64
|
-
> **tmux + AI 멀티세션
|
|
64
|
+
> **tmux + AI 멀티세션 워크플로우에 맞춰 만들었습니다.** 매일 5개 이상의 AI 코딩 세션을 여러 프로젝트에서 실행한다면, marmonitor가 컨텍스트 전환을 추측에서 상태바 한 번 확인으로 바꿔줍니다.
|
|
65
65
|
|
|
66
66
|
## 지원 에이전트
|
|
67
67
|
|
|
@@ -87,7 +87,7 @@ marmonitor setup tmux
|
|
|
87
87
|
|
|
88
88
|
[marmonitor-tmux](https://github.com/mjjo16/marmonitor-tmux) 플러그인을 `~/.tmux.conf`에 추가합니다. tmux 안에서 `prefix + I`을 눌러 활성화하세요.
|
|
89
89
|
|
|
90
|
-
`marmonitor`를 업그레이드한 뒤에는
|
|
90
|
+
`marmonitor`를 업그레이드한 뒤에는 tmux 연동도 업데이트가 필요한지 확인하세요:
|
|
91
91
|
|
|
92
92
|
```bash
|
|
93
93
|
marmonitor update-integration
|
|
@@ -137,7 +137,19 @@ npm link
|
|
|
137
137
|
|
|
138
138
|
## 빠른 시작
|
|
139
139
|
|
|
140
|
-
|
|
140
|
+
### 데몬 시작
|
|
141
|
+
|
|
142
|
+
marmonitor는 2초마다 AI 세션을 스캔하는 백그라운드 데몬으로 실행됩니다:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
marmonitor start # 데몬 시작
|
|
146
|
+
marmonitor stop # 데몬 중지
|
|
147
|
+
marmonitor restart # 데몬 재시작 (예: npm 업데이트 후)
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
모든 명령어가 동작하려면 데몬이 실행 중이어야 합니다. `marmonitor setup tmux`를 실행하면 자동으로 시작됩니다.
|
|
151
|
+
|
|
152
|
+
### tmux 단축키
|
|
141
153
|
|
|
142
154
|
| 단축키 | 동작 |
|
|
143
155
|
|--------|------|
|
|
@@ -145,16 +157,33 @@ npm link
|
|
|
145
157
|
| `prefix + j` | 점프 팝업 — 이동할 세션 선택 |
|
|
146
158
|
| `prefix + m` | 독 — 컴팩트 모니터 패널 |
|
|
147
159
|
| `Option+1~5` | 어텐션 세션 #1~5로 바로 이동 |
|
|
160
|
+
| `Option+`` | 이전 패널로 돌아가기 |
|
|
148
161
|
|
|
149
|
-
CLI
|
|
162
|
+
### CLI 명령어
|
|
150
163
|
|
|
151
164
|
```bash
|
|
152
165
|
marmonitor status # 전체 세션 목록
|
|
153
166
|
marmonitor attention # 입력이 필요한 세션 확인
|
|
167
|
+
marmonitor activity # 각 세션의 활동 내역 (도구 호출 + 토큰)
|
|
154
168
|
marmonitor watch # 실시간 전체 화면 모니터
|
|
169
|
+
marmonitor jump-back # 마지막 점프 이전 패널로 복귀
|
|
155
170
|
marmonitor help # 모든 명령어 및 옵션
|
|
156
171
|
```
|
|
157
172
|
|
|
173
|
+
### 활동 로그
|
|
174
|
+
|
|
175
|
+
AI 세션이 실제로 수행한 작업을 추적합니다 — 파일 편집, bash 명령어, 사용 토큰:
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
marmonitor activity # 오늘의 활동
|
|
179
|
+
marmonitor activity --pid 1234 # PID로 필터링
|
|
180
|
+
marmonitor activity --session abc # 세션 ID로 필터링
|
|
181
|
+
marmonitor activity --days 3 # 최근 3일
|
|
182
|
+
marmonitor activity --json # JSON 출력
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
활동 내역은 데몬이 자동으로 수집하며 `~/.config/marmonitor/activity-log/`에 저장됩니다 (7일 보관).
|
|
186
|
+
|
|
158
187
|
## 단계 아이콘
|
|
159
188
|
|
|
160
189
|
| 아이콘 | 단계 | 의미 |
|
|
@@ -169,10 +198,10 @@ marmonitor help # 모든 명령어 및 옵션
|
|
|
169
198
|
| 레이블 | 의미 |
|
|
170
199
|
|--------|------|
|
|
171
200
|
| `[Active]` | CPU 활동 감지됨 |
|
|
172
|
-
| `[Idle]` |
|
|
201
|
+
| `[Idle]` | 프로세스는 살아 있지만 최근 활동 없음 |
|
|
173
202
|
| `[Stalled]` | 장기간 활동 없음 |
|
|
174
203
|
| `[Dead]` | 세션 파일은 있지만 프로세스가 종료됨 |
|
|
175
|
-
| `[Unmatched]` | AI 프로세스는 발견되었지만
|
|
204
|
+
| `[Unmatched]` | AI 프로세스는 발견되었지만 일치하는 세션 없음 |
|
|
176
205
|
|
|
177
206
|
## tmux 플러그인
|
|
178
207
|
|
|
@@ -182,11 +211,20 @@ marmonitor help # 모든 명령어 및 옵션
|
|
|
182
211
|
- 팝업, 점프, 독 키 바인딩
|
|
183
212
|
- Option+1~5 다이렉트 점프
|
|
184
213
|
|
|
185
|
-
|
|
214
|
+
`@marmonitor-*` 옵션으로 원하는 대로 바꿀 수 있습니다. 자세한 내용은 [플러그인 README](https://github.com/mjjo16/marmonitor-tmux)를 참조하세요.
|
|
215
|
+
|
|
216
|
+
### 뱃지 스타일
|
|
217
|
+
|
|
218
|
+
`integration.tmux.badgeStyle`로 tmux 뱃지와 터미널 텍스트 출력의 스타일을 통일할 수 있습니다.
|
|
219
|
+
|
|
220
|
+
- `basic` — 기본 컬러 필
|
|
221
|
+
- `basic-mono` — Powerline 테두리의 단색 필
|
|
222
|
+
- `text` — 배경 없는 컬러 텍스트
|
|
223
|
+
- `text-mono` — 회색조 텍스트 전용
|
|
186
224
|
|
|
187
225
|
## 설정
|
|
188
226
|
|
|
189
|
-
|
|
227
|
+
다음 경로를 순서대로 찾아 먼저 발견된 파일을 적용합니다:
|
|
190
228
|
|
|
191
229
|
1. `$XDG_CONFIG_HOME/marmonitor/settings.json`
|
|
192
230
|
2. `~/.config/marmonitor/settings.json`
|
|
@@ -220,6 +258,7 @@ marmonitor settings-init --stdout
|
|
|
220
258
|
},
|
|
221
259
|
"integration": {
|
|
222
260
|
"tmux": {
|
|
261
|
+
"badgeStyle": "basic",
|
|
223
262
|
"keys": {
|
|
224
263
|
"attentionPopup": "a",
|
|
225
264
|
"jumpPopup": "j",
|
|
@@ -241,10 +280,14 @@ npm uninstall -g marmonitor # CLI 제거
|
|
|
241
280
|
## 안전성
|
|
242
281
|
|
|
243
282
|
- **기본적으로 읽기 전용** — 관찰만 하며, 세션을 수정하지 않습니다
|
|
244
|
-
- **네트워크 미사용** —
|
|
283
|
+
- **네트워크 미사용** — 외부로 연결하지 않으며, 모든 데이터는 로컬에 남습니다
|
|
245
284
|
- **보수적인 기본값** — 모든 연동 기능은 옵트인 방식입니다
|
|
246
285
|
- **tmux 우선** — WezTerm/iTerm2 네이티브 지원은 현재 일시 중단 상태입니다
|
|
247
286
|
|
|
287
|
+
## 변경 이력
|
|
288
|
+
|
|
289
|
+
릴리스 이력과 호환성 변경사항은 [CHANGELOG.md](CHANGELOG.md)를 참조하세요.
|
|
290
|
+
|
|
248
291
|
## 기여하기
|
|
249
292
|
|
|
250
293
|
설정, 커밋 규칙, PR 가이드라인은 [CONTRIBUTING.md](CONTRIBUTING.md)를 참조하세요. 아키텍처 세부사항은 [ARCHITECTURE.md](ARCHITECTURE.md)를 확인하세요.
|
|
@@ -252,10 +295,10 @@ npm uninstall -g marmonitor # CLI 제거
|
|
|
252
295
|
## 알려진 제한사항
|
|
253
296
|
|
|
254
297
|
- 패널 점프 기능은 tmux가 필요합니다
|
|
255
|
-
- WezTerm / iTerm2 네이티브 바 지원은
|
|
298
|
+
- WezTerm / iTerm2 네이티브 바 지원은 일시 중단 상태이며, 현재 tmux만 지원합니다
|
|
256
299
|
- Gemini 권한 감지는 Ink TUI 아키텍처로 인해 제한적입니다
|
|
257
300
|
- 단계 감지는 휴리스틱 기반으로, 에이전트별 정확도가 다를 수 있습니다
|
|
258
|
-
- macOS
|
|
301
|
+
- macOS 기준으로 개발했으며, Linux에서는 아직 테스트하지 않았습니다
|
|
259
302
|
|
|
260
303
|
## 라이선스
|
|
261
304
|
|
package/README.md
CHANGED
|
@@ -221,6 +221,8 @@ tmux badges and terminal text output can share one style via `integration.tmux.b
|
|
|
221
221
|
|
|
222
222
|
- `basic` — default colored pills
|
|
223
223
|
- `basic-mono` — monochrome pills with Powerline borders
|
|
224
|
+
- `block` — filled background badges without Powerline separator glyphs
|
|
225
|
+
- `block-mono` — monochrome filled badges without Powerline separator glyphs
|
|
224
226
|
- `text` — plain colored text, no filled background
|
|
225
227
|
- `text-mono` — grayscale text only
|
|
226
228
|
|
package/dist/cli.js
CHANGED
|
@@ -542,9 +542,11 @@ program
|
|
|
542
542
|
});
|
|
543
543
|
program
|
|
544
544
|
.command("attention")
|
|
545
|
-
.description("Show prioritized sessions that need attention")
|
|
545
|
+
.description("Show prioritized sessions that need attention, optionally jump to one")
|
|
546
546
|
.option("--json", "Output as JSON")
|
|
547
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")
|
|
548
550
|
.option("--limit <n>", "Max items to show", "12")
|
|
549
551
|
.option("--config <path>", "Path to settings.json")
|
|
550
552
|
.action(async (opts) => {
|
|
@@ -553,11 +555,78 @@ program
|
|
|
553
555
|
applyTerminalStyle(config.integration.tmux.badgeStyle);
|
|
554
556
|
const limit = resolveAttentionLimit(opts, config.display.attentionLimit);
|
|
555
557
|
const interactiveLimit = resolveAttentionLimit(opts, config.display.attentionLimit, true);
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
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;
|
|
559
595
|
}
|
|
560
|
-
|
|
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;
|
|
623
|
+
}
|
|
624
|
+
// Interactive chooser
|
|
625
|
+
if (useInteractive) {
|
|
626
|
+
if (opts.json) {
|
|
627
|
+
console.error("--interactive cannot be combined with --json.");
|
|
628
|
+
process.exit(1);
|
|
629
|
+
}
|
|
561
630
|
if (!process.stdin.isTTY) {
|
|
562
631
|
console.error("--interactive requires an interactive terminal.");
|
|
563
632
|
process.exit(1);
|
|
@@ -599,6 +668,7 @@ program
|
|
|
599
668
|
process.exit(1);
|
|
600
669
|
return;
|
|
601
670
|
}
|
|
671
|
+
// Default: list mode
|
|
602
672
|
if (opts.json) {
|
|
603
673
|
printAttentionJson(agents, limit);
|
|
604
674
|
}
|
|
@@ -770,106 +840,30 @@ program
|
|
|
770
840
|
console.log("Pane capture:");
|
|
771
841
|
console.log(payload.paneOutput ?? "(none)");
|
|
772
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.
|
|
773
845
|
program
|
|
774
846
|
.command("jump")
|
|
775
|
-
.description("
|
|
776
|
-
.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")
|
|
777
849
|
.option("--attention", "Choose from attention items interactively")
|
|
778
|
-
.option("--attention-index <n>", "Jump to Nth
|
|
850
|
+
.option("--attention-index <n>", "Jump to Nth attention item directly")
|
|
779
851
|
.option("--json", "Output as JSON")
|
|
780
852
|
.option("--config <path>", "Path to settings.json")
|
|
781
853
|
.action(async (opts) => {
|
|
782
|
-
|
|
783
|
-
const
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
if (
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
console.error("--attention requires an interactive terminal.");
|
|
796
|
-
process.exit(1);
|
|
797
|
-
}
|
|
798
|
-
const limit = resolveAttentionLimit({ limit: undefined }, config.display.attentionLimit, true);
|
|
799
|
-
const totalItems = buildJumpAttentionItems(agents).length;
|
|
800
|
-
const totalPages = Math.max(1, Math.ceil(totalItems / limit));
|
|
801
|
-
let currentPage = 1;
|
|
802
|
-
let item;
|
|
803
|
-
while (true) {
|
|
804
|
-
clearScreen();
|
|
805
|
-
console.log(renderJumpAttentionChooser(agents, currentPage, limit));
|
|
806
|
-
const pageItemCount = Math.min(limit, Math.max(totalItems - (currentPage - 1) * limit, 0));
|
|
807
|
-
const action = await promptSelectionAction(pageItemCount, currentPage, totalPages);
|
|
808
|
-
if (!action || action.kind === "cancel")
|
|
809
|
-
return;
|
|
810
|
-
if (action.kind === "next") {
|
|
811
|
-
currentPage = Math.min(currentPage + 1, totalPages);
|
|
812
|
-
continue;
|
|
813
|
-
}
|
|
814
|
-
if (action.kind === "prev") {
|
|
815
|
-
currentPage = Math.max(currentPage - 1, 1);
|
|
816
|
-
continue;
|
|
817
|
-
}
|
|
818
|
-
item = selectJumpAttentionItemOnPage(agents, currentPage, action.selection, limit);
|
|
819
|
-
break;
|
|
820
|
-
}
|
|
821
|
-
if (!item) {
|
|
822
|
-
console.error("Invalid selection.");
|
|
823
|
-
process.exit(1);
|
|
824
|
-
}
|
|
825
|
-
pid = item.pid;
|
|
826
|
-
}
|
|
827
|
-
else if (useAttentionIndex) {
|
|
828
|
-
const selection = Number.parseInt(opts.attentionIndex, 10);
|
|
829
|
-
if (Number.isNaN(selection) || selection < 1) {
|
|
830
|
-
console.error(`Invalid attention index: ${opts.attentionIndex}`);
|
|
831
|
-
process.exit(1);
|
|
832
|
-
}
|
|
833
|
-
const item = selectJumpAttentionItem(agents, selection);
|
|
834
|
-
if (!item) {
|
|
835
|
-
console.error(`No jumpable attention item at index ${selection}.`);
|
|
836
|
-
process.exit(1);
|
|
837
|
-
}
|
|
838
|
-
pid = item.pid;
|
|
839
|
-
}
|
|
840
|
-
else {
|
|
841
|
-
pid = Number.parseInt(opts.pid, 10);
|
|
842
|
-
if (Number.isNaN(pid)) {
|
|
843
|
-
console.error(`Invalid pid: ${opts.pid}`);
|
|
844
|
-
process.exit(1);
|
|
845
|
-
}
|
|
846
|
-
}
|
|
847
|
-
const agent = agents.find((item) => item.pid === pid);
|
|
848
|
-
if (!agent) {
|
|
849
|
-
const result = {
|
|
850
|
-
found: false,
|
|
851
|
-
executed: false,
|
|
852
|
-
insideTmux: Boolean(process.env.TMUX),
|
|
853
|
-
pid,
|
|
854
|
-
message: `AI session not found for pid ${pid}.`,
|
|
855
|
-
};
|
|
856
|
-
if (opts.json) {
|
|
857
|
-
printJumpJson(result);
|
|
858
|
-
}
|
|
859
|
-
else {
|
|
860
|
-
printJumpResult(result);
|
|
861
|
-
}
|
|
862
|
-
process.exit(1);
|
|
863
|
-
}
|
|
864
|
-
const result = await jumpToAgent(agent);
|
|
865
|
-
if (opts.json) {
|
|
866
|
-
printJumpJson(result);
|
|
867
|
-
}
|
|
868
|
-
else {
|
|
869
|
-
printJumpResult(result);
|
|
870
|
-
}
|
|
871
|
-
if (!result.found)
|
|
872
|
-
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" });
|
|
873
867
|
});
|
|
874
868
|
program
|
|
875
869
|
.command("jump-back")
|
|
@@ -973,6 +967,8 @@ program
|
|
|
973
967
|
.option("--pid <pid>", "Filter by AI process PID")
|
|
974
968
|
.option("--session <sid>", "Filter by session ID (prefix match)")
|
|
975
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")
|
|
976
972
|
.option("--json", "Output as JSON")
|
|
977
973
|
.action(async (opts) => {
|
|
978
974
|
const { getConfigDir } = await import("./config/index.js");
|
|
@@ -980,6 +976,8 @@ program
|
|
|
980
976
|
const { getRecentDateKeys, readActivityLog } = await import("./scanner/activity-log.js");
|
|
981
977
|
const logDir = pj(getConfigDir(), "activity-log");
|
|
982
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";
|
|
983
981
|
const allEntries = [];
|
|
984
982
|
for (const dateStr of getRecentDateKeys(days)) {
|
|
985
983
|
const entries = await readActivityLog(logDir, dateStr);
|
|
@@ -987,14 +985,24 @@ program
|
|
|
987
985
|
}
|
|
988
986
|
// Filter
|
|
989
987
|
let filtered = allEntries;
|
|
988
|
+
let pidFilterAgent;
|
|
990
989
|
if (opts.pid) {
|
|
991
990
|
const agents = await getAgentsSnapshot();
|
|
992
991
|
const agent = agents.find((a) => a.pid === Number(opts.pid));
|
|
993
992
|
if (agent?.sessionId) {
|
|
993
|
+
pidFilterAgent = {
|
|
994
|
+
agentName: agent.agentName,
|
|
995
|
+
pid: agent.pid,
|
|
996
|
+
cwd: agent.cwd,
|
|
997
|
+
sessionId: agent.sessionId,
|
|
998
|
+
};
|
|
994
999
|
const sidPrefix = agent.sessionId.slice(0, 12);
|
|
995
1000
|
filtered = filtered.filter((e) => e.sid.startsWith(sidPrefix));
|
|
996
1001
|
}
|
|
997
1002
|
else {
|
|
1003
|
+
pidFilterAgent = agent
|
|
1004
|
+
? { agentName: agent.agentName, pid: agent.pid, cwd: agent.cwd, sessionId: "" }
|
|
1005
|
+
: undefined;
|
|
998
1006
|
filtered = [];
|
|
999
1007
|
}
|
|
1000
1008
|
}
|
|
@@ -1003,11 +1011,27 @@ program
|
|
|
1003
1011
|
filtered = filtered.filter((e) => e.sid.startsWith(prefix));
|
|
1004
1012
|
}
|
|
1005
1013
|
if (opts.json) {
|
|
1014
|
+
if (descOrder)
|
|
1015
|
+
filtered.reverse();
|
|
1006
1016
|
console.log(JSON.stringify(filtered, null, 2));
|
|
1007
1017
|
return;
|
|
1008
1018
|
}
|
|
1009
1019
|
if (filtered.length === 0) {
|
|
1010
|
-
|
|
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
|
+
}
|
|
1011
1035
|
return;
|
|
1012
1036
|
}
|
|
1013
1037
|
// Group by session
|
|
@@ -1025,15 +1049,17 @@ program
|
|
|
1025
1049
|
console.log(`\n${agent} ${sid}... ${cwd}`);
|
|
1026
1050
|
console.log(` ${entries.length} actions out:${formatTokensShort(totalOut)} cache:${formatTokensShort(totalCache)}`);
|
|
1027
1051
|
console.log(" ─────────────────────────────────────");
|
|
1028
|
-
|
|
1052
|
+
const sorted = descOrder ? [...entries].reverse() : entries;
|
|
1053
|
+
const shown = sorted.slice(0, maxLines);
|
|
1054
|
+
for (const e of shown) {
|
|
1029
1055
|
const t = new Date(e.ts * 1000).toLocaleTimeString("en-GB", {
|
|
1030
1056
|
hour: "2-digit",
|
|
1031
1057
|
minute: "2-digit",
|
|
1032
1058
|
});
|
|
1033
1059
|
console.log(` ${t} ${e.tool}: ${truncateForDisplay(e.target, 60)}`);
|
|
1034
1060
|
}
|
|
1035
|
-
if (entries.length >
|
|
1036
|
-
console.log(` ... +${entries.length -
|
|
1061
|
+
if (entries.length > maxLines) {
|
|
1062
|
+
console.log(` ... +${entries.length - maxLines} more (use --lines to show more)`);
|
|
1037
1063
|
}
|
|
1038
1064
|
}
|
|
1039
1065
|
});
|
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;
|
|
@@ -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 */
|
package/dist/output/index.js
CHANGED
|
@@ -19,7 +19,59 @@ export async function getSystemInfo() {
|
|
|
19
19
|
let monoMode = false;
|
|
20
20
|
/** Apply badge style to terminal chalk output: mono uses bold/dim only */
|
|
21
21
|
export function applyTerminalStyle(badgeStyle) {
|
|
22
|
-
monoMode =
|
|
22
|
+
monoMode =
|
|
23
|
+
badgeStyle === "basic-mono" || badgeStyle === "block-mono" || badgeStyle === "text-mono";
|
|
24
|
+
}
|
|
25
|
+
export function abbreviateModel(model) {
|
|
26
|
+
if (!model)
|
|
27
|
+
return "—";
|
|
28
|
+
if (model.includes("opus"))
|
|
29
|
+
return "opus";
|
|
30
|
+
if (model.includes("sonnet"))
|
|
31
|
+
return "sonnet";
|
|
32
|
+
if (model.includes("haiku"))
|
|
33
|
+
return "haiku";
|
|
34
|
+
if (model.length <= 12)
|
|
35
|
+
return model;
|
|
36
|
+
return model.slice(0, 11);
|
|
37
|
+
}
|
|
38
|
+
function cwdToProjectName(cwd) {
|
|
39
|
+
const home = process.env.HOME ?? "";
|
|
40
|
+
const short = cwd.startsWith(home) ? cwd.slice(home.length + 1) : cwd;
|
|
41
|
+
const parts = short.split("/");
|
|
42
|
+
return parts[parts.length - 1] || short;
|
|
43
|
+
}
|
|
44
|
+
/** Strip ANSI escape codes to get visible character count */
|
|
45
|
+
function visibleLength(str) {
|
|
46
|
+
// biome-ignore lint/suspicious/noControlCharactersInRegex: ANSI escape stripping
|
|
47
|
+
return str.replace(/\x1b\[\d*(;\d+)*m/g, "").length;
|
|
48
|
+
}
|
|
49
|
+
/** Pad string to fixed visible width (ANSI-aware) */
|
|
50
|
+
function padVisible(str, width) {
|
|
51
|
+
const visible = visibleLength(str);
|
|
52
|
+
return visible >= width ? str : str + " ".repeat(width - visible);
|
|
53
|
+
}
|
|
54
|
+
/** Right-align a string to fixed width (for numbers like CPU, MEM) */
|
|
55
|
+
function padVisibleRight(str, width) {
|
|
56
|
+
const visible = visibleLength(str);
|
|
57
|
+
return visible >= width ? str : " ".repeat(width - visible) + str;
|
|
58
|
+
}
|
|
59
|
+
function formatTokensCompact(n) {
|
|
60
|
+
if (n >= 1_000_000)
|
|
61
|
+
return `${(n / 1_000_000).toFixed(1)}M`;
|
|
62
|
+
if (n >= 1_000)
|
|
63
|
+
return `${(n / 1_000).toFixed(1)}K`;
|
|
64
|
+
return String(n);
|
|
65
|
+
}
|
|
66
|
+
function formatElapsedCompactTable(epochSec) {
|
|
67
|
+
const sec = Math.floor(Date.now() / 1000 - epochSec);
|
|
68
|
+
if (sec < 60)
|
|
69
|
+
return `${sec}s`;
|
|
70
|
+
if (sec < 3600)
|
|
71
|
+
return `${Math.floor(sec / 60)}m`;
|
|
72
|
+
if (sec < 86400)
|
|
73
|
+
return `${Math.floor(sec / 3600)}h`;
|
|
74
|
+
return `${Math.floor(sec / 86400)}d`;
|
|
23
75
|
}
|
|
24
76
|
/** Agent name with distinct color */
|
|
25
77
|
function agentLabel(name) {
|
|
@@ -141,29 +193,95 @@ export async function printStatus(agents) {
|
|
|
141
193
|
return;
|
|
142
194
|
}
|
|
143
195
|
if (alive.length > 0) {
|
|
144
|
-
console.log(`AI Sessions (${alive.length} active)
|
|
196
|
+
console.log(`AI Sessions (${alive.length} active):\n`);
|
|
197
|
+
// Column widths — fixed-width columns first, variable-width last
|
|
198
|
+
const W = {
|
|
199
|
+
status: 10,
|
|
200
|
+
agent: 7,
|
|
201
|
+
model: 12,
|
|
202
|
+
pid: 6,
|
|
203
|
+
cpu: 6,
|
|
204
|
+
mem: 7,
|
|
205
|
+
last: 6,
|
|
206
|
+
tokens: 10,
|
|
207
|
+
project: 22,
|
|
208
|
+
branch: 16,
|
|
209
|
+
};
|
|
210
|
+
// Table header
|
|
211
|
+
const cols = [
|
|
212
|
+
"Status".padEnd(W.status),
|
|
213
|
+
"Agent".padEnd(W.agent),
|
|
214
|
+
"Model".padEnd(W.model),
|
|
215
|
+
"PID".padEnd(W.pid),
|
|
216
|
+
"CPU".padEnd(W.cpu),
|
|
217
|
+
"MEM".padEnd(W.mem),
|
|
218
|
+
"Last".padEnd(W.last),
|
|
219
|
+
"Tokens".padEnd(W.tokens),
|
|
220
|
+
"Project".padEnd(W.project),
|
|
221
|
+
"Branch",
|
|
222
|
+
];
|
|
223
|
+
console.log(` ${chalk.dim(cols.join(" "))}`);
|
|
224
|
+
console.log(chalk.dim(` ${"─".repeat(cols.join(" ").length)}`));
|
|
145
225
|
for (const a of alive) {
|
|
146
|
-
|
|
147
|
-
const
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
226
|
+
// Fixed-width status: colorize label only, pad with plain spaces after
|
|
227
|
+
const statusWord = a.phase === "permission"
|
|
228
|
+
? "Allow"
|
|
229
|
+
: a.phase === "thinking"
|
|
230
|
+
? "Think"
|
|
231
|
+
: a.phase === "tool"
|
|
232
|
+
? "Tool"
|
|
233
|
+
: a.status;
|
|
234
|
+
const statusLabel2 = `[${statusWord}]`;
|
|
235
|
+
const coloredLabel = statusWord === "Active"
|
|
236
|
+
? chalk.green(statusLabel2)
|
|
237
|
+
: statusWord === "Idle"
|
|
238
|
+
? chalk.yellow(statusLabel2)
|
|
239
|
+
: statusWord === "Stalled"
|
|
240
|
+
? chalk.red(statusLabel2)
|
|
241
|
+
: statusWord === "Allow"
|
|
242
|
+
? chalk.red(statusLabel2)
|
|
243
|
+
: statusWord === "Think"
|
|
244
|
+
? chalk.magenta(statusLabel2)
|
|
245
|
+
: statusWord === "Tool"
|
|
246
|
+
? chalk.green(statusLabel2)
|
|
247
|
+
: chalk.white(statusLabel2);
|
|
248
|
+
const rawStatus = coloredLabel + " ".repeat(Math.max(0, W.status - statusLabel2.length));
|
|
249
|
+
const agentStr = a.agentName === "Claude Code" ? "Claude" : a.agentName;
|
|
250
|
+
const modelStr = abbreviateModel(a.model);
|
|
251
|
+
const cpu = `${a.cpuPercent}%`;
|
|
252
|
+
const mem = `${a.memoryMb.toFixed(0)}MB`;
|
|
253
|
+
const last = a.lastResponseAt
|
|
254
|
+
? formatElapsedCompactTable(a.lastResponseAt)
|
|
155
255
|
: a.lastActivityAt
|
|
156
|
-
?
|
|
157
|
-
: "";
|
|
158
|
-
|
|
159
|
-
|
|
256
|
+
? formatElapsedCompactTable(a.lastActivityAt)
|
|
257
|
+
: "—";
|
|
258
|
+
const tokens = a.tokenUsage ? `out:${formatTokensCompact(a.tokenUsage.outputTokens)}` : "";
|
|
259
|
+
const project = cwdToProjectName(a.cwd).slice(0, W.project - 1);
|
|
260
|
+
const branchStr = (a.branch ?? "—").slice(0, W.branch - 1);
|
|
261
|
+
const line = [
|
|
262
|
+
rawStatus,
|
|
263
|
+
padVisible(agentStr, W.agent),
|
|
264
|
+
chalk.dim(modelStr.padEnd(W.model)),
|
|
265
|
+
String(a.pid).padEnd(W.pid),
|
|
266
|
+
padVisibleRight(cpu, W.cpu),
|
|
267
|
+
padVisibleRight(mem, W.mem),
|
|
268
|
+
chalk.dim(last.padStart(W.last)),
|
|
269
|
+
chalk.dim(tokens.padEnd(W.tokens)),
|
|
270
|
+
project.padEnd(W.project),
|
|
271
|
+
chalk.dim(branchStr),
|
|
272
|
+
].join(" ");
|
|
273
|
+
console.log(` ${line}`);
|
|
160
274
|
if (a.workers && a.workers.length > 0) {
|
|
161
|
-
for (
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
275
|
+
for (const w of a.workers) {
|
|
276
|
+
const wLine = [
|
|
277
|
+
" ".repeat(W.status),
|
|
278
|
+
"└─".padEnd(W.agent),
|
|
279
|
+
" ".repeat(W.model),
|
|
280
|
+
String(w.pid).padEnd(W.pid),
|
|
281
|
+
padVisibleRight(`${w.cpuPercent}%`, W.cpu),
|
|
282
|
+
padVisibleRight(`${w.memoryMb.toFixed(0)}MB`, W.mem),
|
|
283
|
+
].join(" ");
|
|
284
|
+
console.log(chalk.dim(` ${wLine}`));
|
|
167
285
|
}
|
|
168
286
|
}
|
|
169
287
|
}
|
|
@@ -237,6 +355,8 @@ function attentionKindLabel(kind) {
|
|
|
237
355
|
function attentionLine(item) {
|
|
238
356
|
const name = item.agentName === "Claude Code" ? "Claude" : item.agentName;
|
|
239
357
|
const path = compactDirLabel(item.cwd);
|
|
358
|
+
const branch = item.branch;
|
|
359
|
+
const branchTag = branch ? chalk.dim(` (${branch})`) : "";
|
|
240
360
|
const runtime = runtimeLabel(item.runtimeSource);
|
|
241
361
|
const time = item.lastResponseAt
|
|
242
362
|
? ` ${chalk.dim(formatElapsed(item.lastResponseAt))}`
|
|
@@ -244,21 +364,21 @@ function attentionLine(item) {
|
|
|
244
364
|
? ` ${chalk.dim(formatElapsed(item.lastActivityAt))}`
|
|
245
365
|
: "";
|
|
246
366
|
if (item.kind === "unmatched") {
|
|
247
|
-
return `${name} ${chalk.dim(path)}${runtime} PID:${item.pid}${time}`;
|
|
367
|
+
return `${name} ${chalk.dim(path)}${branchTag}${runtime} PID:${item.pid}${time}`;
|
|
248
368
|
}
|
|
249
369
|
if (item.kind === "permission") {
|
|
250
|
-
return `${name} ${chalk.dim(path)}${runtime} allow pending PID:${item.pid}${time}`;
|
|
370
|
+
return `${name} ${chalk.dim(path)}${branchTag}${runtime} allow pending PID:${item.pid}${time}`;
|
|
251
371
|
}
|
|
252
372
|
if (item.kind === "stalled") {
|
|
253
|
-
return `${name} ${chalk.dim(path)}${runtime} stalled PID:${item.pid}${time}`;
|
|
373
|
+
return `${name} ${chalk.dim(path)}${branchTag}${runtime} stalled PID:${item.pid}${time}`;
|
|
254
374
|
}
|
|
255
375
|
if (item.kind === "thinking") {
|
|
256
|
-
return `${name} ${chalk.dim(path)}${runtime} thinking PID:${item.pid}${time}`;
|
|
376
|
+
return `${name} ${chalk.dim(path)}${branchTag}${runtime} thinking PID:${item.pid}${time}`;
|
|
257
377
|
}
|
|
258
378
|
if (item.kind === "active") {
|
|
259
|
-
return `${name} ${chalk.dim(path)}${runtime}
|
|
379
|
+
return `${name} ${chalk.dim(path)}${branchTag}${runtime} active PID:${item.pid}${time}`;
|
|
260
380
|
}
|
|
261
|
-
return `${name} ${chalk.dim(path)}${runtime} tool PID:${item.pid}${time}`;
|
|
381
|
+
return `${name} ${chalk.dim(path)}${branchTag}${runtime} tool PID:${item.pid}${time}`;
|
|
262
382
|
}
|
|
263
383
|
function jumpAttentionStatusLabel(item) {
|
|
264
384
|
if (item.kind === "permission")
|
|
@@ -267,7 +387,7 @@ function jumpAttentionStatusLabel(item) {
|
|
|
267
387
|
return chalk.green("[Thinking]");
|
|
268
388
|
if (item.kind === "tool")
|
|
269
389
|
return chalk.cyan("[Tool] ");
|
|
270
|
-
return chalk.blue("[
|
|
390
|
+
return chalk.blue("[Active] ");
|
|
271
391
|
}
|
|
272
392
|
function jumpAttentionPhaseIcon(item) {
|
|
273
393
|
if (item.kind === "permission")
|
|
@@ -281,6 +401,8 @@ function jumpAttentionPhaseIcon(item) {
|
|
|
281
401
|
function jumpAttentionLine(item) {
|
|
282
402
|
const name = item.agentName === "Claude Code" ? "Claude" : item.agentName;
|
|
283
403
|
const path = compactDirLabel(item.cwd);
|
|
404
|
+
const branch = item.branch;
|
|
405
|
+
const branchTag = branch ? chalk.dim(` (${branch})`) : "";
|
|
284
406
|
const runtime = runtimeLabel(item.runtimeSource);
|
|
285
407
|
const started = item.startedAt ? chalk.dim(` started ${formatElapsed(item.startedAt)}`) : "";
|
|
286
408
|
const activity = item.lastResponseAt
|
|
@@ -293,15 +415,15 @@ function jumpAttentionLine(item) {
|
|
|
293
415
|
const icon = jumpAttentionPhaseIcon(item);
|
|
294
416
|
const agent = agentLabel(item.agentName).padEnd(8);
|
|
295
417
|
if (item.kind === "permission") {
|
|
296
|
-
return ` ${status} ${agent} ${chalk.dim(path)}${runtime}${icon}\n PID:${item.pid} ${stats}${started}${activity}`;
|
|
418
|
+
return ` ${status} ${agent} ${chalk.dim(path)}${branchTag}${runtime}${icon}\n PID:${item.pid} ${stats}${started}${activity}`;
|
|
297
419
|
}
|
|
298
420
|
if (item.kind === "thinking") {
|
|
299
|
-
return ` ${status} ${agent} ${chalk.dim(path)}${runtime}${icon}\n PID:${item.pid} ${stats}${started}${activity}`;
|
|
421
|
+
return ` ${status} ${agent} ${chalk.dim(path)}${branchTag}${runtime}${icon}\n PID:${item.pid} ${stats}${started}${activity}`;
|
|
300
422
|
}
|
|
301
423
|
if (item.kind === "tool") {
|
|
302
|
-
return ` ${status} ${agent} ${chalk.dim(path)}${runtime}${icon}\n PID:${item.pid} ${stats}${started}${activity}`;
|
|
424
|
+
return ` ${status} ${agent} ${chalk.dim(path)}${branchTag}${runtime}${icon}\n PID:${item.pid} ${stats}${started}${activity}`;
|
|
303
425
|
}
|
|
304
|
-
return ` ${status} ${agent} ${chalk.dim(path)}${runtime}${icon}\n PID:${item.pid} ${stats}${started}${activity}`;
|
|
426
|
+
return ` ${status} ${agent} ${chalk.dim(path)}${branchTag}${runtime}${icon}\n PID:${item.pid} ${stats}${started}${activity}`;
|
|
305
427
|
}
|
|
306
428
|
function paginateJumpAttentionItems(items, page, pageSize = 10) {
|
|
307
429
|
const normalizedPage = Number.isInteger(page) && page > 0 ? page : 1;
|
package/dist/output/utils.d.ts
CHANGED
|
@@ -73,6 +73,7 @@ export interface AttentionItem {
|
|
|
73
73
|
phase?: AgentSession["phase"];
|
|
74
74
|
lastResponseAt?: number;
|
|
75
75
|
lastActivityAt?: number;
|
|
76
|
+
branch?: string;
|
|
76
77
|
}
|
|
77
78
|
export interface StatusPill {
|
|
78
79
|
label: string;
|
|
@@ -146,7 +147,7 @@ export declare function buildStatusPills(snapshot: StatuslineSnapshot): {
|
|
|
146
147
|
};
|
|
147
148
|
/** Build one-line persistent-bar summary string. */
|
|
148
149
|
export declare function buildStatuslineSummary(snapshot: StatuslineSnapshot, format?: StatuslineFormat): string;
|
|
149
|
-
export type BadgeStyle = "basic" | "basic-mono" | "text" | "text-mono";
|
|
150
|
+
export type BadgeStyle = "basic" | "basic-mono" | "block" | "block-mono" | "text" | "text-mono";
|
|
150
151
|
export declare function buildTmuxBadgeBar(snapshot: StatuslineSnapshot, focusText?: string, badgeStyle?: BadgeStyle, hasJumpAnchor?: boolean): string;
|
|
151
152
|
export declare function buildTmuxAttentionPills(items: AttentionItem[], maxCount?: number, width?: number, badgeStyle?: BadgeStyle): string | undefined;
|
|
152
153
|
export declare function serializeWeztermPills(snapshot: StatuslineSnapshot, focusText?: string): string;
|
package/dist/output/utils.js
CHANGED
|
@@ -342,6 +342,7 @@ export function buildAttentionItems(agents, nowSec = Date.now() / 1000) {
|
|
|
342
342
|
phase: agent.phase,
|
|
343
343
|
lastResponseAt: agent.lastResponseAt,
|
|
344
344
|
lastActivityAt: agent.lastActivityAt,
|
|
345
|
+
branch: agent.branch,
|
|
345
346
|
});
|
|
346
347
|
const tier1 = alive
|
|
347
348
|
.filter((agent) => attentionPriority(agent, nowSec) !== undefined)
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
* Daemon scan loop — runs in background, writes snapshots and registry to files.
|
|
3
3
|
* Reuses watch/dock pattern: light scan every intervalMs, full every detailIntervalMs.
|
|
4
4
|
*/
|
|
5
|
-
import { open,
|
|
6
|
-
import { join } from "node:path";
|
|
5
|
+
import { open, stat, unlink } from "node:fs/promises";
|
|
7
6
|
import { appendActivityEntries, cleanupOldActivityLogs, extractClaudeToolUses, extractCodexToolUses, formatDateKey, } from "./activity-log.js";
|
|
8
7
|
import { loadCodexBindingRegistryFromFile, pruneCodexBindingRegistry, saveCodexBindingRegistryToFile, } from "./codex-binding-registry.js";
|
|
9
8
|
import { writeDaemonPid, writeDaemonSnapshot } from "./daemon-utils.js";
|
|
@@ -85,32 +84,11 @@ export async function runDaemonLoop(config, options) {
|
|
|
85
84
|
const jsonlPath = agent.agentName === "Codex"
|
|
86
85
|
? codexBindingRegistry.get(`${agent.pid}:${agent.processStartedAt ?? 0}`)?.rolloutPath
|
|
87
86
|
: undefined;
|
|
88
|
-
// Claude:
|
|
87
|
+
// Claude: resolve JSONL path via resolveClaudeSessionFile (projects dir)
|
|
89
88
|
let sessionFile;
|
|
90
89
|
if (agent.agentName === "Claude Code" && agent.sessionId && agent.cwd) {
|
|
91
|
-
const {
|
|
92
|
-
|
|
93
|
-
for (const root of roots) {
|
|
94
|
-
try {
|
|
95
|
-
const dirs = await readdir(root);
|
|
96
|
-
for (const dir of dirs) {
|
|
97
|
-
const candidate = join(root, dir, `${agent.sessionId}.jsonl`);
|
|
98
|
-
try {
|
|
99
|
-
await stat(candidate);
|
|
100
|
-
sessionFile = candidate;
|
|
101
|
-
break;
|
|
102
|
-
}
|
|
103
|
-
catch {
|
|
104
|
-
// not here
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
if (sessionFile)
|
|
108
|
-
break;
|
|
109
|
-
}
|
|
110
|
-
catch {
|
|
111
|
-
// root doesn't exist
|
|
112
|
-
}
|
|
113
|
-
}
|
|
90
|
+
const { resolveClaudeSessionFile } = await import("./claude.js");
|
|
91
|
+
sessionFile = await resolveClaudeSessionFile(agent.sessionId, agent.cwd, agent.startedAt, config);
|
|
114
92
|
}
|
|
115
93
|
else if (agent.agentName === "Codex" && jsonlPath) {
|
|
116
94
|
sessionFile = jsonlPath;
|
package/dist/scanner/index.js
CHANGED
|
@@ -233,6 +233,18 @@ export async function scanAgents(config, options = {}) {
|
|
|
233
233
|
const elapsed = statusBaseAt ? Date.now() / 1000 - statusBaseAt : undefined;
|
|
234
234
|
const rawStatus = determineStatus(cpuPercent, elapsed, sessionMatched, phase, config, agentName);
|
|
235
235
|
const status = applyStatusHysteresis(rawStatus, cachedEnrichment?.status, elapsed, phase, agentName);
|
|
236
|
+
// Read git branch from .git/HEAD (full enrichment only, ~0.1ms per session)
|
|
237
|
+
let branch = cachedEnrichment?.branch;
|
|
238
|
+
if (isFullEnrichment && cwd !== "unknown") {
|
|
239
|
+
try {
|
|
240
|
+
const headContent = await readFile(join(cwd, ".git", "HEAD"), "utf-8");
|
|
241
|
+
const trimmed = headContent.trim();
|
|
242
|
+
branch = trimmed.startsWith("ref: refs/heads/") ? trimmed.slice(16) : undefined;
|
|
243
|
+
}
|
|
244
|
+
catch {
|
|
245
|
+
branch = undefined;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
236
248
|
const session = {
|
|
237
249
|
agentName,
|
|
238
250
|
pid: proc.pid,
|
|
@@ -251,6 +263,7 @@ export async function scanAgents(config, options = {}) {
|
|
|
251
263
|
lastResponseAt,
|
|
252
264
|
lastActivityAt,
|
|
253
265
|
runtimeSource,
|
|
266
|
+
branch,
|
|
254
267
|
};
|
|
255
268
|
if (isFullEnrichment) {
|
|
256
269
|
sessionEnrichmentCache.set(cacheKey, {
|
|
@@ -266,6 +279,7 @@ export async function scanAgents(config, options = {}) {
|
|
|
266
279
|
lastResponseAt: session.lastResponseAt,
|
|
267
280
|
lastActivityAt: session.lastActivityAt,
|
|
268
281
|
runtimeSource: session.runtimeSource,
|
|
282
|
+
branch: session.branch,
|
|
269
283
|
});
|
|
270
284
|
}
|
|
271
285
|
return session;
|
package/dist/scanner/process.js
CHANGED
|
@@ -75,8 +75,14 @@ export function matchesProcessCommand(command, processName) {
|
|
|
75
75
|
const escaped = processName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
76
76
|
return new RegExp(`(?:^|[/\\\\])${escaped}(?:\\s|$)`, "i").test(command);
|
|
77
77
|
}
|
|
78
|
+
/** Electron sub-process flags that indicate a desktop GUI helper, not a CLI agent. */
|
|
79
|
+
const ELECTRON_TYPE_RE = /--type=(utility|renderer|gpu-process|zygote|broker)/;
|
|
78
80
|
/** Match a process against agent signatures using process name first, then cmd fallback. */
|
|
79
81
|
export function detectAgentFromProcessSignature(proc, config) {
|
|
82
|
+
// Skip Electron sub-processes (renderer, utility, gpu, zygote) to avoid
|
|
83
|
+
// false-positive detection of desktop apps (e.g. Claude Desktop) as CLI agents.
|
|
84
|
+
if (proc.cmd && ELECTRON_TYPE_RE.test(proc.cmd))
|
|
85
|
+
return null;
|
|
80
86
|
const name = proc.name.toLowerCase();
|
|
81
87
|
const command = (proc.cmd ?? "").toLowerCase();
|
|
82
88
|
for (const [agentName, agentConfig] of Object.entries(config.agents)) {
|
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "marmonitor",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
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",
|