@stackmemoryai/stackmemory
Version:
Project-scoped memory for AI coding tools. Durable context across sessions with MCP integration, frames, smart retrieval, Claude Code skills, and automatic hooks.
72 lines (71 loc) • 1.92 kB
JavaScript
import { fileURLToPath as __fileURLToPath } from 'url';
import { dirname as __pathDirname } from 'path';
const __filename = __fileURLToPath(import.meta.url);
const __dirname = __pathDirname(__filename);
import { execSync } from "child_process";
function isTmuxAvailable() {
try {
execSync("which tmux", { stdio: "ignore" });
return true;
} catch {
return false;
}
}
function createTmuxSession(name, paneCount) {
execSync(`tmux new-session -d -s ${name}`, { stdio: "ignore" });
for (let i = 1; i < paneCount; i++) {
execSync(`tmux split-window -t ${name}`, { stdio: "ignore" });
execSync(`tmux select-layout -t ${name} tiled`, { stdio: "ignore" });
}
execSync(`tmux select-layout -t ${name} tiled`, { stdio: "ignore" });
}
function sendToPane(session, pane, command) {
execSync(
`tmux send-keys -t ${session}:${pane} ${shellEscape(command)} Enter`,
{
stdio: "ignore"
}
);
}
function killTmuxSession(name) {
execSync(`tmux kill-session -t ${name}`, { stdio: "ignore" });
}
function attachToSession(name) {
execSync(`tmux attach-session -t ${name}`, { stdio: "inherit" });
}
function listPanes(session) {
try {
const output = execSync(
`tmux list-panes -t ${session} -F "#{pane_index}"`,
{ encoding: "utf-8" }
);
return output.trim().split("\n").filter(Boolean);
} catch {
return [];
}
}
function sendCtrlC(session, pane) {
execSync(`tmux send-keys -t ${session}:${pane} C-c`, { stdio: "ignore" });
}
function sessionExists(name) {
try {
execSync(`tmux has-session -t ${name}`, { stdio: "ignore" });
return true;
} catch {
return false;
}
}
function shellEscape(cmd) {
return "'" + cmd.replace(/'/g, "'\\''") + "'";
}
export {
attachToSession,
createTmuxSession,
isTmuxAvailable,
killTmuxSession,
listPanes,
sendCtrlC,
sendToPane,
sessionExists
};
//# sourceMappingURL=tmux-manager.js.map