initial commit

This commit is contained in:
pi
2026-04-10 23:12:17 +01:00
commit d64e050fcc
34 changed files with 6954 additions and 0 deletions

43
src/tmux.test.ts Normal file
View File

@@ -0,0 +1,43 @@
import test from "node:test";
import assert from "node:assert/strict";
import {
buildSplitWindowArgs,
buildWrapperShellCommand,
isInsideTmux,
} from "./tmux.ts";
test("isInsideTmux reads the TMUX environment variable", () => {
assert.equal(isInsideTmux({ TMUX: "/tmp/tmux-1000/default,123,0" } as NodeJS.ProcessEnv), true);
assert.equal(isInsideTmux({} as NodeJS.ProcessEnv), false);
});
test("buildWrapperShellCommand single-quotes paths safely", () => {
const command = buildWrapperShellCommand({
nodePath: "/usr/local/bin/node",
wrapperPath: "/repo/tmux-subagent/src/wrapper/cli.mjs",
metaPath: "/repo/.pi/subagents/runs/run-1/meta.json",
});
assert.equal(
command,
"'/usr/local/bin/node' '/repo/tmux-subagent/src/wrapper/cli.mjs' '/repo/.pi/subagents/runs/run-1/meta.json'",
);
});
test("buildSplitWindowArgs targets the current window and cwd", () => {
assert.deepEqual(buildSplitWindowArgs({
windowId: "@7",
cwd: "/repo",
command: "'node' '/wrapper.mjs' '/meta.json'",
}), [
"split-window",
"-P",
"-F",
"#{pane_id}",
"-t",
"@7",
"-c",
"/repo",
"'node' '/wrapper.mjs' '/meta.json'",
]);
});