claude-tmux 1.0.0 → 1.0.1
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 +2 -0
- package/dist/index.js +37 -3
- package/package.json +1 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Alan
|
|
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
CHANGED
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
|
3
3
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import { execSync } from "child_process";
|
|
6
|
-
import { writeFileSync } from "fs";
|
|
6
|
+
import { writeFileSync, appendFileSync } from "fs";
|
|
7
7
|
const SESSION_PREFIX = "claude-";
|
|
8
8
|
function runTmux(args) {
|
|
9
9
|
return execSync(`tmux ${args}`, { encoding: "utf-8", timeout: 10000 }).trim();
|
|
@@ -23,9 +23,17 @@ function sleep(ms) {
|
|
|
23
23
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
24
24
|
}
|
|
25
25
|
function isClaudeIdle(output) {
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
// Claude shows these patterns when actively working
|
|
27
|
+
const busyPatterns = [
|
|
28
|
+
'ctrl+c to interrupt',
|
|
29
|
+
'esc to interrupt',
|
|
30
|
+
];
|
|
31
|
+
for (const pattern of busyPatterns) {
|
|
32
|
+
if (output.includes(pattern)) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
28
35
|
}
|
|
36
|
+
// Not clearly busy - considered idle
|
|
29
37
|
return true;
|
|
30
38
|
}
|
|
31
39
|
function filterUIChrome(output) {
|
|
@@ -46,19 +54,45 @@ function filterUIChrome(output) {
|
|
|
46
54
|
});
|
|
47
55
|
return filtered.join('\n').trim();
|
|
48
56
|
}
|
|
57
|
+
function isClearlBusy(output) {
|
|
58
|
+
// These patterns definitively mean Claude is still working
|
|
59
|
+
const definitelyBusy = [
|
|
60
|
+
'ctrl+c to interrupt',
|
|
61
|
+
'esc to interrupt',
|
|
62
|
+
];
|
|
63
|
+
for (const pattern of definitelyBusy) {
|
|
64
|
+
if (output.includes(pattern)) {
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
49
70
|
async function waitForIdle(session) {
|
|
50
71
|
const timeout = 600000; // 10 minutes
|
|
51
72
|
const lines = 50;
|
|
52
73
|
const startTime = Date.now();
|
|
53
74
|
let lastOutput = "";
|
|
54
75
|
let stableCount = 0;
|
|
76
|
+
let iterations = 0;
|
|
55
77
|
while (Date.now() - startTime < timeout) {
|
|
56
78
|
await sleep(2000);
|
|
79
|
+
iterations++;
|
|
57
80
|
try {
|
|
58
81
|
const output = runTmux(`capture-pane -t "${session}" -p -S -${lines}`);
|
|
82
|
+
const busy = isClearlBusy(output);
|
|
83
|
+
// Debug: write to file so we can see what's happening
|
|
84
|
+
appendFileSync('/tmp/claude-tmux-debug.log', `[${new Date().toISOString()}] iteration=${iterations} busy=${busy} outputLen=${output.length}\n`);
|
|
85
|
+
// If clearly busy, never return early
|
|
86
|
+
if (isClearlBusy(output)) {
|
|
87
|
+
lastOutput = output;
|
|
88
|
+
stableCount = 0;
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
// If idle, return
|
|
59
92
|
if (isClaudeIdle(output)) {
|
|
60
93
|
return filterUIChrome(output);
|
|
61
94
|
}
|
|
95
|
+
// Fallback: if output is stable for 6 seconds and not clearly busy, return
|
|
62
96
|
if (output === lastOutput) {
|
|
63
97
|
stableCount++;
|
|
64
98
|
if (stableCount >= 3) {
|