marmonitor 0.1.5 → 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.
@@ -1,115 +1,20 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  /**
4
- * postinstall script — show banner + offer tmux setup.
4
+ * postinstall script — show install banner + setup guide.
5
5
  * Runs after `npm install -g marmonitor`.
6
6
  *
7
- * - Non-TTY (CI): banner only, no prompt
8
- * - No tmux: banner + CLI-only message
9
- * - Already configured: banner + "already configured"
10
- * - Interactive: banner + y/n prompt → add plugin line to tmux.conf
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`.
11
10
  */
12
11
 
13
- import { execSync } from "node:child_process";
14
- import { readFileSync, writeFileSync, existsSync } from "node:fs";
15
- import { homedir } from "node:os";
16
- import { join } from "node:path";
17
- import { createInterface } from "node:readline";
18
-
19
- const PLUGIN_LINE = "set -g @plugin 'mjjo16/marmonitor-tmux'";
20
- const CONF_PATH = join(homedir(), ".tmux.conf");
21
-
22
- function hasTmux() {
23
- try {
24
- execSync("which tmux", { stdio: "ignore" });
25
- return true;
26
- } catch {
27
- return false;
28
- }
29
- }
30
-
31
- function hasPlugin() {
32
- try {
33
- const content = readFileSync(CONF_PATH, "utf-8");
34
- return content.split("\n").some((line) => line.trim() === PLUGIN_LINE);
35
- } catch {
36
- return false;
37
- }
38
- }
39
-
40
- function addPlugin() {
41
- let existing = "";
42
- try {
43
- existing = readFileSync(CONF_PATH, "utf-8");
44
- } catch {
45
- // file doesn't exist — will create
46
- }
47
- const sep = existing.length > 0 && !existing.endsWith("\n") ? "\n" : "";
48
- writeFileSync(CONF_PATH, `${existing}${sep}${PLUGIN_LINE}\n`, "utf-8");
49
- }
50
-
51
- function printBanner() {
52
- console.log("");
53
- console.log(" ✓ marmonitor installed");
54
- console.log(" Standing guard over your AI coding sessions");
55
- console.log("");
56
- }
57
-
58
- function ask(question) {
59
- return new Promise((resolve) => {
60
- const rl = createInterface({ input: process.stdin, output: process.stdout });
61
- rl.question(question, (answer) => {
62
- rl.close();
63
- resolve(answer.trim().toLowerCase());
64
- });
65
- });
66
- }
67
-
68
- async function main() {
69
- printBanner();
70
-
71
- // Non-interactive (CI, piped, etc.)
72
- if (!process.stdin.isTTY) {
73
- console.log(" Run 'marmonitor setup tmux' to configure tmux integration.");
74
- console.log("");
75
- return;
76
- }
77
-
78
- // No tmux
79
- if (!hasTmux()) {
80
- console.log(" tmux not found. marmonitor CLI is ready:");
81
- console.log(" $ marmonitor status");
82
- console.log(" $ marmonitor help");
83
- console.log("");
84
- return;
85
- }
86
-
87
- // Already configured
88
- if (hasPlugin()) {
89
- console.log(" tmux integration already configured.");
90
- console.log(" Press prefix+I in tmux to update the plugin.");
91
- console.log("");
92
- return;
93
- }
94
-
95
- // Interactive prompt
96
- const answer = await ask(" Set up tmux integration? (y/n): ");
97
-
98
- if (answer === "y" || answer === "yes") {
99
- addPlugin();
100
- console.log("");
101
- console.log(" ✓ Added to ~/.tmux.conf");
102
- console.log(" Press prefix+I inside tmux to activate.");
103
- console.log("");
104
- } else {
105
- console.log("");
106
- console.log(" Skipped. You can set up later:");
107
- console.log(" $ marmonitor setup tmux");
108
- console.log("");
109
- }
110
- }
111
-
112
- main().catch(() => {
113
- // postinstall must never fail the npm install
114
- process.exit(0);
115
- });
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
@@ -887,6 +887,18 @@ program
887
887
  else {
888
888
  console.log("No marmonitor settings found in ~/.tmux.conf");
889
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
+ }
890
902
  });
891
903
  installProcessSafetyHandlers();
892
904
  program.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marmonitor",
3
- "version": "0.1.5",
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",
@@ -49,7 +49,7 @@
49
49
  "lint": "biome check src tests",
50
50
  "test": "node --test tests/*.test.mjs",
51
51
  "postinstall": "node bin/postinstall.js",
52
- "preuninstall": "node bin/preuninstall.js",
52
+ "preuninstall": "node bin/preuninstall.cjs",
53
53
  "prepublishOnly": "npm run build && npm test"
54
54
  },
55
55
  "dependencies": {
@@ -1,43 +0,0 @@
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
- * - No prompt — automatic cleanup
8
- * - Only removes the exact plugin line, nothing else
9
- * - Silent if no tmux.conf or no plugin line found
10
- */
11
-
12
- import { readFileSync, writeFileSync } from "node:fs";
13
- import { homedir } from "node:os";
14
- import { join } from "node:path";
15
-
16
- const PLUGIN_LINE = "set -g @plugin 'mjjo16/marmonitor-tmux'";
17
- const CONF_PATH = join(homedir(), ".tmux.conf");
18
-
19
- function removePlugin() {
20
- let content;
21
- try {
22
- content = readFileSync(CONF_PATH, "utf-8");
23
- } catch {
24
- return false;
25
- }
26
-
27
- const lines = content.split("\n");
28
- const filtered = lines.filter((line) => line.trim() !== PLUGIN_LINE);
29
-
30
- if (filtered.length === lines.length) return false;
31
-
32
- writeFileSync(CONF_PATH, filtered.join("\n"), "utf-8");
33
- return true;
34
- }
35
-
36
- try {
37
- const removed = removePlugin();
38
- if (removed) {
39
- console.log(" marmonitor: removed tmux plugin line from ~/.tmux.conf");
40
- }
41
- } catch {
42
- // preuninstall must never fail the npm uninstall
43
- }