marmonitor 0.1.3 → 0.1.6

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.
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * postinstall script — show install banner + setup guide.
5
+ * Runs after `npm install -g marmonitor`.
6
+ *
7
+ * npm postinstall runs with stdin as pipe (non-TTY),
8
+ * so interactive prompts are not possible here.
9
+ * Actual tmux setup is done via `marmonitor setup tmux`.
10
+ */
11
+
12
+ console.log("");
13
+ console.log(" ✓ marmonitor installed");
14
+ console.log(" Standing guard over your AI coding sessions");
15
+ console.log("");
16
+ console.log(" Quick start:");
17
+ console.log(" $ marmonitor setup tmux — auto-configure tmux integration");
18
+ console.log(" $ marmonitor status — show active AI sessions");
19
+ console.log(" $ marmonitor help — all commands and shortcuts");
20
+ console.log("");
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * preuninstall script — remove marmonitor plugin line from tmux.conf.
5
+ * Runs before `npm uninstall -g marmonitor`.
6
+ *
7
+ * Uses only CommonJS-compatible built-ins (no ESM import).
8
+ * Must never fail — errors are silently ignored.
9
+ */
10
+
11
+ try {
12
+ const fs = require("fs");
13
+ const path = require("path");
14
+ const os = require("os");
15
+
16
+ const PLUGIN_LINE = "set -g @plugin 'mjjo16/marmonitor-tmux'";
17
+ const confPath = path.join(os.homedir(), ".tmux.conf");
18
+
19
+ const content = fs.readFileSync(confPath, "utf-8");
20
+ const lines = content.split("\n");
21
+ const filtered = lines.filter((line) => line.trim() !== PLUGIN_LINE);
22
+
23
+ if (filtered.length < lines.length) {
24
+ fs.writeFileSync(confPath, filtered.join("\n"), "utf-8");
25
+ console.log(" marmonitor: removed tmux plugin line from ~/.tmux.conf");
26
+ }
27
+ } catch {
28
+ // silent — preuninstall must never block npm uninstall
29
+ }
package/dist/cli.js CHANGED
@@ -851,5 +851,54 @@ program
851
851
  printCleanPlan(targets, Boolean(opts.kill));
852
852
  }
853
853
  });
854
+ program
855
+ .command("setup")
856
+ .description("Set up marmonitor integrations")
857
+ .argument("<target>", "Integration target (tmux)")
858
+ .action(async (target) => {
859
+ if (target !== "tmux") {
860
+ console.error(`Unknown target: ${target}. Supported: tmux`);
861
+ process.exit(1);
862
+ }
863
+ const { addMarmonitorPlugin, hasMarmonitorPlugin } = await import("./tmux/setup.js");
864
+ const { homedir } = await import("node:os");
865
+ const { join } = await import("node:path");
866
+ const confPath = join(homedir(), ".tmux.conf");
867
+ if (await hasMarmonitorPlugin(confPath)) {
868
+ console.log("tmux integration already configured.");
869
+ return;
870
+ }
871
+ await addMarmonitorPlugin(confPath);
872
+ console.log("✓ Added marmonitor-tmux plugin to ~/.tmux.conf");
873
+ console.log("Press prefix+I inside tmux to activate.");
874
+ });
875
+ program
876
+ .command("uninstall-integration")
877
+ .description("Remove marmonitor settings from tmux.conf")
878
+ .action(async () => {
879
+ const { removeMarmonitorPlugin } = await import("./tmux/setup.js");
880
+ const { homedir } = await import("node:os");
881
+ const { join } = await import("node:path");
882
+ const confPath = join(homedir(), ".tmux.conf");
883
+ const removed = await removeMarmonitorPlugin(confPath);
884
+ if (removed) {
885
+ console.log("✓ Removed marmonitor-tmux plugin from ~/.tmux.conf");
886
+ }
887
+ else {
888
+ console.log("No marmonitor settings found in ~/.tmux.conf");
889
+ }
890
+ // Restore tmux memory state (status bar → 1 line, remove status-format[1])
891
+ try {
892
+ const { execFile: ef } = await import("node:child_process");
893
+ const { promisify: p } = await import("node:util");
894
+ const exec = p(ef);
895
+ await exec("tmux", ["set", "-g", "status", "on"]);
896
+ await exec("tmux", ["set", "-gu", "status-format[1]"]);
897
+ console.log("✓ Restored tmux status bar to single line");
898
+ }
899
+ catch {
900
+ console.log(" tmux not running — restart tmux to apply changes");
901
+ }
902
+ });
854
903
  installProcessSafetyHandlers();
855
904
  program.parse();
@@ -543,7 +543,7 @@ export function buildTmuxAttentionPills(items, maxCount = 5, width) {
543
543
  .filter((item) => item.kind !== "unmatched" && item.kind !== "stalled")
544
544
  .slice(0, layout.itemCount);
545
545
  if (jumpItems.length === 0) {
546
- return tmuxDetailBlock("✅ all ok");
546
+ return tmuxDetailBlock("no active");
547
547
  }
548
548
  const segments = jumpItems.map((item, index) => {
549
549
  const agent = agentShortName(item.agentName);
@@ -0,0 +1,7 @@
1
+ /**
2
+ * tmux.conf plugin line management.
3
+ * Adds/removes the marmonitor-tmux tpm plugin line.
4
+ */
5
+ export declare function hasMarmonitorPlugin(confPath: string): Promise<boolean>;
6
+ export declare function addMarmonitorPlugin(confPath: string): Promise<boolean>;
7
+ export declare function removeMarmonitorPlugin(confPath: string): Promise<boolean>;
@@ -0,0 +1,47 @@
1
+ /**
2
+ * tmux.conf plugin line management.
3
+ * Adds/removes the marmonitor-tmux tpm plugin line.
4
+ */
5
+ import { readFile, writeFile } from "node:fs/promises";
6
+ const PLUGIN_LINE = "set -g @plugin 'mjjo16/marmonitor-tmux'";
7
+ function matchesPluginLine(line) {
8
+ return line.trim() === PLUGIN_LINE;
9
+ }
10
+ export async function hasMarmonitorPlugin(confPath) {
11
+ try {
12
+ const content = await readFile(confPath, "utf-8");
13
+ return content.split("\n").some(matchesPluginLine);
14
+ }
15
+ catch {
16
+ return false;
17
+ }
18
+ }
19
+ export async function addMarmonitorPlugin(confPath) {
20
+ if (await hasMarmonitorPlugin(confPath))
21
+ return false;
22
+ let existing = "";
23
+ try {
24
+ existing = await readFile(confPath, "utf-8");
25
+ }
26
+ catch {
27
+ // file doesn't exist yet — will create
28
+ }
29
+ const separator = existing.length > 0 && !existing.endsWith("\n") ? "\n" : "";
30
+ await writeFile(confPath, `${existing}${separator}${PLUGIN_LINE}\n`, "utf-8");
31
+ return true;
32
+ }
33
+ export async function removeMarmonitorPlugin(confPath) {
34
+ let content;
35
+ try {
36
+ content = await readFile(confPath, "utf-8");
37
+ }
38
+ catch {
39
+ return false;
40
+ }
41
+ const lines = content.split("\n");
42
+ const filtered = lines.filter((line) => !matchesPluginLine(line));
43
+ if (filtered.length === lines.length)
44
+ return false;
45
+ await writeFile(confPath, filtered.join("\n"), "utf-8");
46
+ return true;
47
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marmonitor",
3
- "version": "0.1.3",
3
+ "version": "0.1.6",
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
+ "postinstall": "node bin/postinstall.js",
52
+ "preuninstall": "node bin/preuninstall.cjs",
51
53
  "prepublishOnly": "npm run build && npm test"
52
54
  },
53
55
  "dependencies": {