@termwire/tmux 0.2.2 → 0.3.0
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/CHANGELOG.md +31 -0
- package/README.md +23 -7
- package/dist/client.d.ts +1 -1
- package/dist/client.js +2 -2
- package/dist/command.js +1 -1
- package/dist/create-tmux.d.ts +6 -6
- package/dist/create-tmux.js +6 -6
- package/dist/index.d.ts +12 -12
- package/dist/index.js +6 -6
- package/dist/pane.d.ts +1 -1
- package/dist/pane.js +3 -3
- package/dist/process.d.ts +1 -1
- package/dist/process.js +23 -13
- package/dist/session.d.ts +2 -2
- package/dist/session.js +3 -3
- package/dist/window.d.ts +2 -2
- package/dist/window.js +3 -3
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
# @termwire/tmux
|
|
2
2
|
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- f57c480: Run on Node instead of requiring Bun. Every package now spawns through
|
|
8
|
+
`node:child_process`, emits explicit `.js` extensions on relative imports, and
|
|
9
|
+
ships a `#!/usr/bin/env node` entry point. `engines` declares `node >=22.12.0`,
|
|
10
|
+
the floor set by Commander 15.
|
|
11
|
+
|
|
12
|
+
The published CLI and MCP server previously failed under Node with
|
|
13
|
+
`ERR_MODULE_NOT_FOUND` and had no test covering it. `bun run verify:node`
|
|
14
|
+
executes both built artifacts under Node, and CI runs it on every push.
|
|
15
|
+
|
|
16
|
+
This makes `npx -y @termwire/mcp` the recommended MCP registration. Unlike
|
|
17
|
+
`bunx`, the `npx` cache lives under `~/.npm` and is not swept by the nightly
|
|
18
|
+
macOS temporary-directory cleanup that silently broke the server.
|
|
19
|
+
|
|
20
|
+
Emitted type declarations are now typed against `@types/node` alone and no
|
|
21
|
+
longer reference Bun types.
|
|
22
|
+
|
|
23
|
+
The repository is still developed with Bun. Only the published output changed.
|
|
24
|
+
|
|
25
|
+
- f57c480: Add the `termwire open <target>` command, which opens a file in the workspace
|
|
26
|
+
Neovim and focuses the editor pane. A trailing `:<line>` selects a line, and
|
|
27
|
+
`--line` keeps the target verbatim for filenames that end in a colon and
|
|
28
|
+
digits. This gives any agent that can run a shell command the same capability
|
|
29
|
+
as the MCP server and the OpenCode plugin, with nothing to configure.
|
|
30
|
+
|
|
31
|
+
Correct the OpenCode plugin's out-of-workspace error to `not inside a termwire
|
|
32
|
+
workspace`, matching the CLI and the MCP server.
|
|
33
|
+
|
|
3
34
|
## 0.2.2
|
|
4
35
|
|
|
5
36
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# @termwire/tmux
|
|
2
2
|
|
|
3
|
+
A thin, typed adapter for tmux 3.2 or newer.
|
|
4
|
+
|
|
3
5
|
```bash
|
|
4
6
|
bun add @termwire/tmux
|
|
5
7
|
```
|
|
@@ -8,18 +10,32 @@ bun add @termwire/tmux
|
|
|
8
10
|
import { createTmux } from "@termwire/tmux";
|
|
9
11
|
|
|
10
12
|
const tmux = createTmux();
|
|
13
|
+
|
|
14
|
+
if (!(await tmux.hasSession("repo-dev"))) {
|
|
15
|
+
await tmux.newSession({ session: "repo-dev", name: "editor", cwd: "/repo" });
|
|
16
|
+
}
|
|
11
17
|
```
|
|
12
18
|
|
|
13
|
-
|
|
14
|
-
|
|
19
|
+
`createTmux({ exec, env })` spawns through `node:child_process` in production,
|
|
20
|
+
so it runs on Node and on Bun alike. Tests inject a fake `exec` and need no
|
|
21
|
+
tmux binary.
|
|
15
22
|
|
|
16
23
|
## API
|
|
17
24
|
|
|
18
|
-
|
|
19
|
-
`
|
|
20
|
-
|
|
25
|
+
- Sessions: `hasSession`, `newSession`, `killSession`, `setSessionTitle`,
|
|
26
|
+
`setEnvironment`, `attach`.
|
|
27
|
+
- Windows: `newWindow`, `selectWindow`, `selectLayout`.
|
|
28
|
+
- Panes: `splitPane`, `respawnPane`, `selectPane`, `sendKeys`.
|
|
29
|
+
|
|
30
|
+
`attach` uses `attach-session` outside tmux and `switch-client` when `TMUX` is
|
|
31
|
+
set, so attaching works the same from a plain terminal and from inside another
|
|
32
|
+
session.
|
|
33
|
+
|
|
34
|
+
`newSession` and `newWindow` return the created window and pane ids. Termwire
|
|
35
|
+
uses those ids to place panes and to record the editor pane in
|
|
36
|
+
`TERMWIRE_EDITOR_PANE`.
|
|
21
37
|
|
|
22
38
|
## Boundary
|
|
23
39
|
|
|
24
|
-
This package owns tmux commands only.
|
|
25
|
-
|
|
40
|
+
This package owns tmux commands only. Layout interpretation, editor roles,
|
|
41
|
+
Neovim, and workspace orchestration belong to the CLI.
|
package/dist/client.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { type Exec } from "./process";
|
|
1
|
+
import { type Exec } from "./process.js";
|
|
2
2
|
export declare function attach(exec: Exec, env: Record<string, string | undefined>, session: string): Promise<void>;
|
package/dist/client.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CommandError, execute } from "./process";
|
|
2
|
-
import { assertNotEmpty } from "./validation";
|
|
1
|
+
import { CommandError, execute } from "./process.js";
|
|
2
|
+
import { assertNotEmpty } from "./validation.js";
|
|
3
3
|
export async function attach(exec, env, session) {
|
|
4
4
|
assertNotEmpty("session", session);
|
|
5
5
|
const internal = env.TMUX !== undefined && env.TMUX.length > 0;
|
package/dist/command.js
CHANGED
package/dist/create-tmux.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { respawnPane, sendKeys, splitPane } from "./pane";
|
|
2
|
-
import { type Exec } from "./process";
|
|
3
|
-
import { newSession } from "./session";
|
|
4
|
-
import { newWindow, selectLayout } from "./window";
|
|
1
|
+
import { respawnPane, sendKeys, splitPane } from "./pane.js";
|
|
2
|
+
import { type Exec } from "./process.js";
|
|
3
|
+
import { newSession } from "./session.js";
|
|
4
|
+
import { newWindow, selectLayout } from "./window.js";
|
|
5
5
|
export interface CreateTmuxOptions {
|
|
6
6
|
exec?: Exec;
|
|
7
7
|
env?: Record<string, string | undefined>;
|
|
8
8
|
}
|
|
9
9
|
export declare function createTmux({ exec, env }?: CreateTmuxOptions): {
|
|
10
10
|
hasSession: (session: string) => Promise<boolean>;
|
|
11
|
-
newSession: (options: Parameters<typeof newSession>[1]) => Promise<import("./command").WindowPaneIds>;
|
|
12
|
-
newWindow: (options: Parameters<typeof newWindow>[1]) => Promise<import("./command").WindowPaneIds>;
|
|
11
|
+
newSession: (options: Parameters<typeof newSession>[1]) => Promise<import("./command.js").WindowPaneIds>;
|
|
12
|
+
newWindow: (options: Parameters<typeof newWindow>[1]) => Promise<import("./command.js").WindowPaneIds>;
|
|
13
13
|
setEnvironment: (session: string, key: string, value: string) => Promise<void>;
|
|
14
14
|
setSessionTitle: (session: string) => Promise<void>;
|
|
15
15
|
killSession: (session: string) => Promise<void>;
|
package/dist/create-tmux.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { attach } from "./client";
|
|
2
|
-
import { respawnPane, selectPane, sendKeys, splitPane } from "./pane";
|
|
3
|
-
import {
|
|
4
|
-
import { hasSession, killSession, newSession, setEnvironment, setSessionTitle } from "./session";
|
|
5
|
-
import { newWindow, selectLayout, selectWindow } from "./window";
|
|
6
|
-
export function createTmux({ exec =
|
|
1
|
+
import { attach } from "./client.js";
|
|
2
|
+
import { respawnPane, selectPane, sendKeys, splitPane } from "./pane.js";
|
|
3
|
+
import { spawnExec } from "./process.js";
|
|
4
|
+
import { hasSession, killSession, newSession, setEnvironment, setSessionTitle } from "./session.js";
|
|
5
|
+
import { newWindow, selectLayout, selectWindow } from "./window.js";
|
|
6
|
+
export function createTmux({ exec = spawnExec, env = process.env } = {}) {
|
|
7
7
|
return {
|
|
8
8
|
hasSession: (session) => hasSession(exec, session),
|
|
9
9
|
newSession: (options) => newSession(exec, options),
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export type { WindowPaneIds } from "./command";
|
|
2
|
-
export type { CreateTmuxOptions } from "./create-tmux";
|
|
3
|
-
export { createTmux } from "./create-tmux";
|
|
4
|
-
export type { RespawnPaneOptions, SplitPaneOptions } from "./pane";
|
|
5
|
-
export { respawnPane } from "./pane";
|
|
6
|
-
export type { Exec, ExecOptions, ExecResult } from "./process";
|
|
7
|
-
export { CommandError } from "./process";
|
|
8
|
-
export type { NewSessionOptions } from "./session";
|
|
9
|
-
export { killSession, setEnvironment } from "./session";
|
|
10
|
-
export { ValidationError } from "./validation";
|
|
11
|
-
export type { NewWindowOptions, TmuxLayout } from "./window";
|
|
12
|
-
export { selectLayout, tmuxLayouts } from "./window";
|
|
1
|
+
export type { WindowPaneIds } from "./command.js";
|
|
2
|
+
export type { CreateTmuxOptions } from "./create-tmux.js";
|
|
3
|
+
export { createTmux } from "./create-tmux.js";
|
|
4
|
+
export type { RespawnPaneOptions, SplitPaneOptions } from "./pane.js";
|
|
5
|
+
export { respawnPane } from "./pane.js";
|
|
6
|
+
export type { Exec, ExecOptions, ExecResult } from "./process.js";
|
|
7
|
+
export { CommandError } from "./process.js";
|
|
8
|
+
export type { NewSessionOptions } from "./session.js";
|
|
9
|
+
export { killSession, setEnvironment } from "./session.js";
|
|
10
|
+
export { ValidationError } from "./validation.js";
|
|
11
|
+
export type { NewWindowOptions, TmuxLayout } from "./window.js";
|
|
12
|
+
export { selectLayout, tmuxLayouts } from "./window.js";
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { createTmux } from "./create-tmux";
|
|
2
|
-
export { respawnPane } from "./pane";
|
|
3
|
-
export { CommandError } from "./process";
|
|
4
|
-
export { killSession, setEnvironment } from "./session";
|
|
5
|
-
export { ValidationError } from "./validation";
|
|
6
|
-
export { selectLayout, tmuxLayouts } from "./window";
|
|
1
|
+
export { createTmux } from "./create-tmux.js";
|
|
2
|
+
export { respawnPane } from "./pane.js";
|
|
3
|
+
export { CommandError } from "./process.js";
|
|
4
|
+
export { killSession, setEnvironment } from "./session.js";
|
|
5
|
+
export { ValidationError } from "./validation.js";
|
|
6
|
+
export { selectLayout, tmuxLayouts } from "./window.js";
|
package/dist/pane.d.ts
CHANGED
package/dist/pane.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { appendCommand, appendEnvironment, readPaneId } from "./command";
|
|
2
|
-
import { CommandError, execute } from "./process";
|
|
3
|
-
import { assertNotEmpty, ValidationError } from "./validation";
|
|
1
|
+
import { appendCommand, appendEnvironment, readPaneId } from "./command.js";
|
|
2
|
+
import { CommandError, execute } from "./process.js";
|
|
3
|
+
import { assertNotEmpty, ValidationError } from "./validation.js";
|
|
4
4
|
export async function respawnPane(exec, options) {
|
|
5
5
|
assertNotEmpty("target", options.target);
|
|
6
6
|
if (options.cwd !== undefined)
|
package/dist/process.d.ts
CHANGED
|
@@ -15,4 +15,4 @@ export declare class CommandError extends Error {
|
|
|
15
15
|
static from(argv: readonly string[], result: ExecResult): CommandError;
|
|
16
16
|
}
|
|
17
17
|
export declare function execute(exec: Exec, argv: readonly string[], options?: ExecOptions): Promise<ExecResult>;
|
|
18
|
-
export declare function
|
|
18
|
+
export declare function spawnExec(argv: readonly string[], options?: ExecOptions): Promise<ExecResult>;
|
package/dist/process.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
1
2
|
export class CommandError extends Error {
|
|
2
3
|
argv;
|
|
3
4
|
exitCode;
|
|
@@ -23,18 +24,27 @@ export async function execute(exec, argv, options) {
|
|
|
23
24
|
throw new CommandError(argv, null, "", { cause });
|
|
24
25
|
}
|
|
25
26
|
}
|
|
26
|
-
export async function
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
: { stdout: "pipe", stderr: "pipe" });
|
|
31
|
-
const exitCode = await proc.exited;
|
|
32
|
-
if (inherited) {
|
|
33
|
-
return { exitCode, stdout: "", stderr: "" };
|
|
27
|
+
export async function spawnExec(argv, options = {}) {
|
|
28
|
+
const [command, ...args] = argv;
|
|
29
|
+
if (command === undefined) {
|
|
30
|
+
throw new Error("command must not be empty");
|
|
34
31
|
}
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
32
|
+
const inherited = options.stdio === "inherit";
|
|
33
|
+
return await new Promise((resolve, reject) => {
|
|
34
|
+
const child = spawn(command, args, {
|
|
35
|
+
stdio: inherited ? "inherit" : ["ignore", "pipe", "pipe"],
|
|
36
|
+
});
|
|
37
|
+
let stdout = "";
|
|
38
|
+
let stderr = "";
|
|
39
|
+
child.stdout?.setEncoding("utf8").on("data", (chunk) => {
|
|
40
|
+
stdout += chunk;
|
|
41
|
+
});
|
|
42
|
+
child.stderr?.setEncoding("utf8").on("data", (chunk) => {
|
|
43
|
+
stderr += chunk;
|
|
44
|
+
});
|
|
45
|
+
child.once("error", reject);
|
|
46
|
+
child.once("close", (code) => {
|
|
47
|
+
resolve({ exitCode: code ?? 1, stdout, stderr });
|
|
48
|
+
});
|
|
49
|
+
});
|
|
40
50
|
}
|
package/dist/session.d.ts
CHANGED
package/dist/session.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { appendCommand, appendEnvironment, readWindowPaneIds } from "./command";
|
|
2
|
-
import { CommandError, execute } from "./process";
|
|
3
|
-
import { assertNotEmpty } from "./validation";
|
|
1
|
+
import { appendCommand, appendEnvironment, readWindowPaneIds, } from "./command.js";
|
|
2
|
+
import { CommandError, execute } from "./process.js";
|
|
3
|
+
import { assertNotEmpty } from "./validation.js";
|
|
4
4
|
export async function hasSession(exec, session) {
|
|
5
5
|
assertNotEmpty("session", session);
|
|
6
6
|
const command = ["tmux", "has-session", "-t", `=${session}`];
|
package/dist/window.d.ts
CHANGED
package/dist/window.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { appendCommand, appendEnvironment, readWindowPaneIds } from "./command";
|
|
2
|
-
import { CommandError, execute } from "./process";
|
|
3
|
-
import { assertNotEmpty } from "./validation";
|
|
1
|
+
import { appendCommand, appendEnvironment, readWindowPaneIds, } from "./command.js";
|
|
2
|
+
import { CommandError, execute } from "./process.js";
|
|
3
|
+
import { assertNotEmpty } from "./validation.js";
|
|
4
4
|
export const tmuxLayouts = [
|
|
5
5
|
"even-horizontal",
|
|
6
6
|
"even-vertical",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@termwire/tmux",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"engines": {
|
|
25
|
-
"
|
|
25
|
+
"node": ">=22.12.0"
|
|
26
26
|
},
|
|
27
27
|
"repository": {
|
|
28
28
|
"type": "git",
|