marmonitor 0.1.0
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/LICENSE +21 -0
- package/README.md +219 -0
- package/bin/marmonitor.js +2 -0
- package/dist/banner/index.d.ts +7 -0
- package/dist/banner/index.js +212 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +855 -0
- package/dist/config/index.d.ts +105 -0
- package/dist/config/index.js +218 -0
- package/dist/guard/index.d.ts +23 -0
- package/dist/guard/index.js +128 -0
- package/dist/output/index.d.ts +28 -0
- package/dist/output/index.js +457 -0
- package/dist/output/utils.d.ts +138 -0
- package/dist/output/utils.js +588 -0
- package/dist/process-safety.d.ts +2 -0
- package/dist/process-safety.js +7 -0
- package/dist/scanner/bounded-map.d.ts +10 -0
- package/dist/scanner/bounded-map.js +25 -0
- package/dist/scanner/cache.d.ts +88 -0
- package/dist/scanner/cache.js +32 -0
- package/dist/scanner/claude.d.ts +25 -0
- package/dist/scanner/claude.js +425 -0
- package/dist/scanner/codex.d.ts +14 -0
- package/dist/scanner/codex.js +195 -0
- package/dist/scanner/gemini.d.ts +21 -0
- package/dist/scanner/gemini.js +131 -0
- package/dist/scanner/group.d.ts +7 -0
- package/dist/scanner/group.js +54 -0
- package/dist/scanner/index.d.ts +16 -0
- package/dist/scanner/index.js +256 -0
- package/dist/scanner/process.d.ts +17 -0
- package/dist/scanner/process.js +91 -0
- package/dist/scanner/status.d.ts +8 -0
- package/dist/scanner/status.js +45 -0
- package/dist/scanner/types.d.ts +6 -0
- package/dist/scanner/types.js +4 -0
- package/dist/tmux/index.d.ts +34 -0
- package/dist/tmux/index.js +166 -0
- package/dist/types.d.ts +55 -0
- package/dist/types.js +1 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +1 -0
- package/docs/banner-ansi.png +0 -0
- package/docs/marmot-small.png +0 -0
- package/package.json +70 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="docs/banner-ansi.png" alt="marmonitor" width="480">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<strong>tmux status bar monitor for Claude Code, Codex & Gemini — track AI coding sessions in real time</strong>
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
<a href="https://www.npmjs.com/package/marmonitor"><img src="https://img.shields.io/npm/v/marmonitor" alt="npm version"></a>
|
|
11
|
+
<a href="https://github.com/mjjo16/marmonitor/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/marmonitor" alt="license"></a>
|
|
12
|
+
<img src="https://img.shields.io/node/v/marmonitor" alt="node version">
|
|
13
|
+
<img src="https://img.shields.io/badge/platform-macOS%20%7C%20Linux-blue" alt="platform">
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Why marmonitor?
|
|
19
|
+
|
|
20
|
+
Running multiple AI coding agents in tmux is now the norm — Claude Code refactoring your backend, Codex writing tests in another pane, Gemini reviewing docs in a third. But as sessions multiply, you hit the same wall:
|
|
21
|
+
|
|
22
|
+
- You switch to a pane only to find the agent has been waiting for `allow` for 10 minutes
|
|
23
|
+
- You forget which window has the Codex session you were just working with
|
|
24
|
+
- You have no idea how many tokens you've burned across sessions
|
|
25
|
+
|
|
26
|
+
**There's no dashboard for this.** You're alt-tabbing between panes, checking each one manually.
|
|
27
|
+
|
|
28
|
+
**marmonitor** fixes this. One line in your tmux.conf, and your status bar becomes a live control panel for every AI session on your machine.
|
|
29
|
+
|
|
30
|
+
<p align="center">
|
|
31
|
+
<img src="docs/use_sample.png" alt="marmonitor tmux statusbar" width="640">
|
|
32
|
+
<br>
|
|
33
|
+
<em>Agent counts, phase badges, and numbered attention pills — all in your tmux bar</em>
|
|
34
|
+
</p>
|
|
35
|
+
|
|
36
|
+
### What it does
|
|
37
|
+
|
|
38
|
+
**tmux statusline** — always visible at the bottom of your terminal:
|
|
39
|
+
- Agent counts (`Cl 12`, `Cx 2`, `Gm 1`) — how many sessions are running
|
|
40
|
+
- Phase alerts (`⏳ 1`, `🤔 2`, `🔧 1`) — which sessions need attention
|
|
41
|
+
- Numbered pills (`1 ⏳Cl my-project allow`, `2 •Cx api-server 6m`) — jump to any session with `Option+1~5`
|
|
42
|
+
|
|
43
|
+
**Attention priority** — sessions that need your input come first:
|
|
44
|
+
- ⏳ `permission` (allow waiting) is always #1 — you need to approve
|
|
45
|
+
- 🤔 `thinking` (AI responding) is #2 — result coming soon
|
|
46
|
+
- Then most recently active sessions, so you can quickly return to what you were working on
|
|
47
|
+
|
|
48
|
+
**Quick jump** — press `Option+1` to jump directly to the #1 attention session's tmux pane. No searching through windows.
|
|
49
|
+
|
|
50
|
+
**Full status** — `marmonitor status` shows everything:
|
|
51
|
+
|
|
52
|
+
<p align="center">
|
|
53
|
+
<img src="docs/use_status_sample.png" alt="marmonitor status output" width="640">
|
|
54
|
+
<br>
|
|
55
|
+
<em>All sessions with status, tokens, phase, CPU/MEM, and worker process tree</em>
|
|
56
|
+
</p>
|
|
57
|
+
|
|
58
|
+
**Zero setup** — no API keys, no agent plugins, no code changes. marmonitor reads local process info and session files from the outside. Install, add one line to tmux.conf, done.
|
|
59
|
+
|
|
60
|
+
> **Built for the tmux + AI multi-session workflow.** If you run 5+ AI coding sessions daily across different projects, marmonitor turns context-switching from guesswork into a glance at your status bar.
|
|
61
|
+
|
|
62
|
+
## Supported Agents
|
|
63
|
+
|
|
64
|
+
| Agent | Detection | Session Enrichment | Phase Tracking |
|
|
65
|
+
|-------|-----------|-------------------|----------------|
|
|
66
|
+
| **Claude Code** | Native binary | Tokens, timestamps, model | thinking, tool, permission, done |
|
|
67
|
+
| **Codex** | Binary + cmd fallback | Tokens, timestamps, model | thinking, tool, done |
|
|
68
|
+
| **Gemini** | cmd fallback | Tokens, timestamps, model | thinking, tool, done |
|
|
69
|
+
|
|
70
|
+
## Install
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
npm install -g marmonitor
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Or from source:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
git clone https://github.com/mjjo16/marmonitor.git
|
|
80
|
+
cd marmonitor
|
|
81
|
+
npm install && npm run build
|
|
82
|
+
npm link
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Quick Start
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
# Full session inventory
|
|
89
|
+
marmonitor status
|
|
90
|
+
|
|
91
|
+
# Focused attention list — what needs your input?
|
|
92
|
+
marmonitor attention
|
|
93
|
+
|
|
94
|
+
# Long-running monitor
|
|
95
|
+
marmonitor watch
|
|
96
|
+
marmonitor dock # compact, for tmux panes
|
|
97
|
+
|
|
98
|
+
# Jump to a session's tmux pane
|
|
99
|
+
marmonitor jump --attention-index 1
|
|
100
|
+
|
|
101
|
+
# tmux statusline widget
|
|
102
|
+
marmonitor --statusline --statusline-format tmux-badges
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Phase Icons
|
|
106
|
+
|
|
107
|
+
| Icon | Phase | Meaning |
|
|
108
|
+
|------|-------|---------|
|
|
109
|
+
| ⏳ | `permission` | AI requesting tool approval — **user input needed** |
|
|
110
|
+
| 🤔 | `thinking` | AI generating a response |
|
|
111
|
+
| 🔧 | `tool` | Approved tool executing |
|
|
112
|
+
| ✅ | `done` | Response complete, awaiting next instruction |
|
|
113
|
+
|
|
114
|
+
## Status Labels
|
|
115
|
+
|
|
116
|
+
| Label | Meaning |
|
|
117
|
+
|-------|---------|
|
|
118
|
+
| `[Active]` | CPU activity detected |
|
|
119
|
+
| `[Idle]` | Process alive, no recent activity |
|
|
120
|
+
| `[Stalled]` | No activity for extended period |
|
|
121
|
+
| `[Dead]` | Session file exists but process is gone |
|
|
122
|
+
| `[Unmatched]` | AI process found but no matching session |
|
|
123
|
+
|
|
124
|
+
## Terminal Integration
|
|
125
|
+
|
|
126
|
+
### tmux
|
|
127
|
+
|
|
128
|
+
Add to your `~/.tmux.conf`:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
# Two-line status bar with AI session badges
|
|
132
|
+
set -g status-right '#(marmonitor --statusline --statusline-format tmux-badges)'
|
|
133
|
+
|
|
134
|
+
# Popup attention chooser (prefix + a)
|
|
135
|
+
bind a display-popup -E -w 80 -h 20 "marmonitor attention --interactive"
|
|
136
|
+
|
|
137
|
+
# Direct jump by number (Option+1~5)
|
|
138
|
+
bind -n M-1 run-shell "marmonitor jump --attention-index 1"
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
See [`examples/tmux/`](examples/tmux/) for full setup.
|
|
142
|
+
|
|
143
|
+
### Non-tmux terminal surfaces
|
|
144
|
+
|
|
145
|
+
WezTerm / iTerm2 terminal-native surfaces are currently paused.
|
|
146
|
+
|
|
147
|
+
- `marmonitor` is `tmux-first`
|
|
148
|
+
- non-tmux bars are not part of the supported default setup right now
|
|
149
|
+
- existing WezTerm example files remain in the repo as paused reference material, not active product surface
|
|
150
|
+
|
|
151
|
+
## Configuration
|
|
152
|
+
|
|
153
|
+
Config is loaded from (first found wins):
|
|
154
|
+
|
|
155
|
+
1. `$XDG_CONFIG_HOME/marmonitor/settings.json`
|
|
156
|
+
2. `~/.config/marmonitor/settings.json`
|
|
157
|
+
3. `~/.marmonitor.json`
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
# View current config path and values
|
|
161
|
+
marmonitor settings-path
|
|
162
|
+
marmonitor settings-show
|
|
163
|
+
|
|
164
|
+
# Generate a starter config
|
|
165
|
+
marmonitor settings-init --stdout
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Example Config
|
|
169
|
+
|
|
170
|
+
```json
|
|
171
|
+
{
|
|
172
|
+
"display": {
|
|
173
|
+
"attentionLimit": 10,
|
|
174
|
+
"statuslineAttentionLimit": 5
|
|
175
|
+
},
|
|
176
|
+
"status": {
|
|
177
|
+
"stalledAfterMin": 20,
|
|
178
|
+
"phaseDecay": {
|
|
179
|
+
"thinking": 20,
|
|
180
|
+
"tool": 30,
|
|
181
|
+
"permission": 0,
|
|
182
|
+
"done": 5
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
"integration": {
|
|
186
|
+
"tmux": {
|
|
187
|
+
"keys": {
|
|
188
|
+
"attentionPopup": "a",
|
|
189
|
+
"jumpPopup": "j",
|
|
190
|
+
"dockToggle": "m",
|
|
191
|
+
"directJump": ["M-1", "M-2", "M-3", "M-4", "M-5"]
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## Safety
|
|
199
|
+
|
|
200
|
+
- **Read-only by default** — observes only, never modifies your sessions
|
|
201
|
+
- **No network** — zero outbound connections, all data stays local
|
|
202
|
+
- **Conservative defaults** — all integrations are opt-in
|
|
203
|
+
- **tmux-first** — terminal-native WezTerm/iTerm2 surfaces are currently paused
|
|
204
|
+
|
|
205
|
+
## Contributing
|
|
206
|
+
|
|
207
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for setup, commit conventions, and PR guidelines. For architecture details, see [ARCHITECTURE.md](ARCHITECTURE.md).
|
|
208
|
+
|
|
209
|
+
## Known Limitations
|
|
210
|
+
|
|
211
|
+
- Pane jump requires tmux
|
|
212
|
+
- WezTerm / iTerm2 native bars are paused for now; tmux is the supported surface
|
|
213
|
+
- Gemini permission detection is limited due to Ink TUI architecture
|
|
214
|
+
- Phase detection relies on heuristics — accuracy varies by agent
|
|
215
|
+
- macOS first; Linux support is untested
|
|
216
|
+
|
|
217
|
+
## License
|
|
218
|
+
|
|
219
|
+
[MIT](LICENSE) — MJ JO
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function supportsInlineBannerImage(env?: NodeJS.ProcessEnv): boolean;
|
|
2
|
+
export declare function renderInstallInfo(): string;
|
|
3
|
+
export declare function renderRuntimeInfo(activeSessions?: number): string;
|
|
4
|
+
export declare function renderInstallBanner(env?: NodeJS.ProcessEnv): string;
|
|
5
|
+
export declare function renderRuntimeBanner(activeSessions?: number, env?: NodeJS.ProcessEnv): string;
|
|
6
|
+
export declare const BANNER: string;
|
|
7
|
+
export declare const BANNER_SMALL: string;
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { execFileSync } from "node:child_process";
|
|
2
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { VERSION } from "../version.js";
|
|
6
|
+
const INSTALL_BANNER_ASSET_PATH = join(dirname(fileURLToPath(import.meta.url)), "..", "docs", "banner-ansi.png");
|
|
7
|
+
const RUNTIME_BANNER_ASSET_PATH = join(dirname(fileURLToPath(import.meta.url)), "..", "docs", "marmot-small.png");
|
|
8
|
+
const ANSI_MARMOT_PALETTE = {
|
|
9
|
+
"1": [194, 154, 115],
|
|
10
|
+
"2": [145, 103, 69],
|
|
11
|
+
"3": [103, 66, 41],
|
|
12
|
+
"4": [1, 0, 0],
|
|
13
|
+
};
|
|
14
|
+
const TEXT_LOGO_PRIMARY = [145, 103, 69];
|
|
15
|
+
const TEXT_LOGO_SHADOW = [103, 66, 41];
|
|
16
|
+
const GLYPH_HEIGHT = 7;
|
|
17
|
+
const PIXEL_FONT = {
|
|
18
|
+
M: ["1 1", "11 11", "1 1 1", "1 1", "1 1", "1 1", "1 1"],
|
|
19
|
+
A: [" 111 ", "1 1", "1 1", "11111", "1 1", "1 1", "1 1"],
|
|
20
|
+
R: ["1111 ", "1 1", "1 1", "1111 ", "1 1 ", "1 1 ", "1 1"],
|
|
21
|
+
O: [" 111 ", "1 1", "1 1", "1 1", "1 1", "1 1", " 111 "],
|
|
22
|
+
N: ["1 1", "11 1", "1 1 1", "1 11", "1 1", "1 1", "1 1"],
|
|
23
|
+
I: ["11111", " 1 ", " 1 ", " 1 ", " 1 ", " 1 ", "11111"],
|
|
24
|
+
T: ["11111", " 1 ", " 1 ", " 1 ", " 1 ", " 1 ", " 1 "],
|
|
25
|
+
};
|
|
26
|
+
const ANSI_MARMOT_ROWS = [
|
|
27
|
+
" 22221",
|
|
28
|
+
" 22 223",
|
|
29
|
+
" 2222223",
|
|
30
|
+
" 2112222",
|
|
31
|
+
" 211333 ",
|
|
32
|
+
" 3211222 ",
|
|
33
|
+
" 322111112",
|
|
34
|
+
" 332111111",
|
|
35
|
+
" 3321111111",
|
|
36
|
+
" 3332111122",
|
|
37
|
+
" 3323221123",
|
|
38
|
+
" 3322211112",
|
|
39
|
+
" 332221113",
|
|
40
|
+
" 4232221112",
|
|
41
|
+
"322233221113",
|
|
42
|
+
"332 33223333",
|
|
43
|
+
];
|
|
44
|
+
function fg(color) {
|
|
45
|
+
return `\x1b[38;2;${color[0]};${color[1]};${color[2]}m`;
|
|
46
|
+
}
|
|
47
|
+
function bg(color) {
|
|
48
|
+
return `\x1b[48;2;${color[0]};${color[1]};${color[2]}m`;
|
|
49
|
+
}
|
|
50
|
+
function renderAnsiMarmot() {
|
|
51
|
+
const lines = [];
|
|
52
|
+
for (let y = 0; y < ANSI_MARMOT_ROWS.length; y += 2) {
|
|
53
|
+
const top = ANSI_MARMOT_ROWS[y] ?? "";
|
|
54
|
+
const bottom = ANSI_MARMOT_ROWS[y + 1] ?? "";
|
|
55
|
+
let line = "";
|
|
56
|
+
const width = Math.max(top.length, bottom.length);
|
|
57
|
+
for (let x = 0; x < width; x += 1) {
|
|
58
|
+
const topChar = top[x] ?? " ";
|
|
59
|
+
const bottomChar = bottom[x] ?? " ";
|
|
60
|
+
const topColor = ANSI_MARMOT_PALETTE[topChar];
|
|
61
|
+
const bottomColor = ANSI_MARMOT_PALETTE[bottomChar];
|
|
62
|
+
if (!topColor && !bottomColor) {
|
|
63
|
+
line += " ";
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
if (topColor && bottomColor) {
|
|
67
|
+
line += `${fg(topColor)}${bg(bottomColor)}▀\x1b[0m`;
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
if (topColor) {
|
|
71
|
+
line += `${fg(topColor)}▀\x1b[0m`;
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
line += `${fg(bottomColor)}▄\x1b[0m`;
|
|
75
|
+
}
|
|
76
|
+
lines.push(line);
|
|
77
|
+
}
|
|
78
|
+
return lines.join("\n");
|
|
79
|
+
}
|
|
80
|
+
function colorizeTextLogoLine(line) {
|
|
81
|
+
let result = "";
|
|
82
|
+
for (const ch of line) {
|
|
83
|
+
if (ch === "1") {
|
|
84
|
+
result += `${fg(TEXT_LOGO_PRIMARY)}█\x1b[0m`;
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
if (ch === "2") {
|
|
88
|
+
result += `${fg(TEXT_LOGO_SHADOW)}█\x1b[0m`;
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
result += " ";
|
|
92
|
+
}
|
|
93
|
+
return result;
|
|
94
|
+
}
|
|
95
|
+
function buildPixelWordmark(word) {
|
|
96
|
+
const rows = Array.from({ length: GLYPH_HEIGHT }, () => "");
|
|
97
|
+
for (const character of word) {
|
|
98
|
+
const glyph = PIXEL_FONT[character];
|
|
99
|
+
if (!glyph)
|
|
100
|
+
continue;
|
|
101
|
+
for (let rowIndex = 0; rowIndex < GLYPH_HEIGHT; rowIndex += 1) {
|
|
102
|
+
rows[rowIndex] += glyph[rowIndex];
|
|
103
|
+
rows[rowIndex] += " ";
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return rows.map((row) => row.trimEnd());
|
|
107
|
+
}
|
|
108
|
+
function stretchWordmarkRows(rows) {
|
|
109
|
+
if (rows.length < 5)
|
|
110
|
+
return rows;
|
|
111
|
+
return [rows[0], rows[1], rows[2], rows[2], rows[3], rows[4], rows[5], rows[6]];
|
|
112
|
+
}
|
|
113
|
+
function buildTextLogoRows() {
|
|
114
|
+
return stretchWordmarkRows(buildPixelWordmark("MARMONITOR")).map(colorizeTextLogoLine);
|
|
115
|
+
}
|
|
116
|
+
function renderRuntimeMark() {
|
|
117
|
+
return `${fg(TEXT_LOGO_SHADOW)}▚${fg(TEXT_LOGO_PRIMARY)}▞\x1b[0m`;
|
|
118
|
+
}
|
|
119
|
+
function renderAnsiInstallFallback() {
|
|
120
|
+
const marmotLines = renderAnsiMarmot().split("\n");
|
|
121
|
+
const logoLines = buildTextLogoRows();
|
|
122
|
+
const totalLines = marmotLines.length;
|
|
123
|
+
const visibleLogoLines = logoLines.length > totalLines ? logoLines.slice(0, totalLines) : logoLines;
|
|
124
|
+
const logoTop = Math.max(0, Math.floor((totalLines - visibleLogoLines.length) / 2));
|
|
125
|
+
return Array.from({ length: totalLines }, (_, index) => {
|
|
126
|
+
const marmotLine = marmotLines[index] ?? "";
|
|
127
|
+
const logoIndex = index - logoTop;
|
|
128
|
+
const logoLine = logoIndex >= 0 && logoIndex < visibleLogoLines.length ? visibleLogoLines[logoIndex] : "";
|
|
129
|
+
return logoLine ? `${marmotLine} ${logoLine}` : marmotLine;
|
|
130
|
+
}).join("\n");
|
|
131
|
+
}
|
|
132
|
+
function readInlineBannerImage() {
|
|
133
|
+
if (!existsSync(INSTALL_BANNER_ASSET_PATH))
|
|
134
|
+
return undefined;
|
|
135
|
+
try {
|
|
136
|
+
return readFileSync(INSTALL_BANNER_ASSET_PATH).toString("base64");
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
return undefined;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
export function supportsInlineBannerImage(env = process.env) {
|
|
143
|
+
return env.MARMONITOR_ENABLE_INLINE_IMAGE === "1";
|
|
144
|
+
}
|
|
145
|
+
function renderWeztermInlineImage(width, assetPath) {
|
|
146
|
+
if (!existsSync(assetPath))
|
|
147
|
+
return undefined;
|
|
148
|
+
try {
|
|
149
|
+
const weztermExecutable = process.env.WEZTERM_EXECUTABLE || "wezterm";
|
|
150
|
+
return execFileSync(weztermExecutable, ["imgcat", "--width", width, "--tmux-passthru", "detect", assetPath], {
|
|
151
|
+
encoding: "utf8",
|
|
152
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
catch {
|
|
156
|
+
return undefined;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
function renderBestEffortImage(width, assetPath, env = process.env) {
|
|
160
|
+
if (!supportsInlineBannerImage(env))
|
|
161
|
+
return undefined;
|
|
162
|
+
if (env.WEZTERM_PANE || env.WEZTERM_EXECUTABLE || env.TERM_PROGRAM === "WezTerm") {
|
|
163
|
+
return renderWeztermInlineImage(width, assetPath);
|
|
164
|
+
}
|
|
165
|
+
if (env.TERM_PROGRAM === "iTerm.app") {
|
|
166
|
+
if (assetPath !== INSTALL_BANNER_ASSET_PATH)
|
|
167
|
+
return undefined;
|
|
168
|
+
const imageData = readInlineBannerImage();
|
|
169
|
+
if (!imageData)
|
|
170
|
+
return undefined;
|
|
171
|
+
return width === "32"
|
|
172
|
+
? `\u001b]1337;File=inline=1;width=32:${imageData}\u0007`
|
|
173
|
+
: `\u001b]1337;File=inline=1;preserveAspectRatio=1:${imageData}\u0007`;
|
|
174
|
+
}
|
|
175
|
+
return undefined;
|
|
176
|
+
}
|
|
177
|
+
export function renderInstallInfo() {
|
|
178
|
+
return [
|
|
179
|
+
`marmonitor v${VERSION}`,
|
|
180
|
+
"Standing guard over your AI sessions",
|
|
181
|
+
"",
|
|
182
|
+
"Get started:",
|
|
183
|
+
" $ marmonitor status - Show active AI sessions",
|
|
184
|
+
" $ marmonitor attention - Focus sessions that need review",
|
|
185
|
+
" $ marmonitor watch - Live full-screen monitor",
|
|
186
|
+
" $ marmonitor dock - Persistent tmux monitor",
|
|
187
|
+
" $ marmonitor --statusline - tmux statusbar widget",
|
|
188
|
+
" $ marmonitor help - Commands, shortcuts, integration tips",
|
|
189
|
+
"",
|
|
190
|
+
"tmux defaults:",
|
|
191
|
+
" Prefix+a attention popup | Prefix+j jump popup | Prefix+m dock",
|
|
192
|
+
" Option+1..5 direct jump to top attention sessions",
|
|
193
|
+
"",
|
|
194
|
+
"Docs: https://github.com/mjjo16/marmonitor",
|
|
195
|
+
].join("\n");
|
|
196
|
+
}
|
|
197
|
+
export function renderRuntimeInfo(activeSessions) {
|
|
198
|
+
const sessionText = typeof activeSessions === "number"
|
|
199
|
+
? `${activeSessions} active session${activeSessions === 1 ? "" : "s"}`
|
|
200
|
+
: "local AI agent monitor";
|
|
201
|
+
return `marmonitor v${VERSION}\nMonitoring: Claude Code, Codex${activeSessions !== undefined ? ` | ${sessionText}` : ""}`;
|
|
202
|
+
}
|
|
203
|
+
export function renderInstallBanner(env = process.env) {
|
|
204
|
+
const bannerImage = renderBestEffortImage("50%", INSTALL_BANNER_ASSET_PATH, env) ?? renderAnsiInstallFallback();
|
|
205
|
+
return `${bannerImage}\n\n${renderInstallInfo()}`;
|
|
206
|
+
}
|
|
207
|
+
export function renderRuntimeBanner(activeSessions, env = process.env) {
|
|
208
|
+
const bannerImage = renderBestEffortImage("12", RUNTIME_BANNER_ASSET_PATH, env) ?? renderRuntimeMark();
|
|
209
|
+
return `${bannerImage} ${renderRuntimeInfo(activeSessions)}`;
|
|
210
|
+
}
|
|
211
|
+
export const BANNER = renderInstallBanner();
|
|
212
|
+
export const BANNER_SMALL = renderRuntimeBanner();
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|