@termwire/tmux 0.2.1 → 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 CHANGED
@@ -1,5 +1,42 @@
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
+
34
+ ## 0.2.2
35
+
36
+ ### Patch Changes
37
+
38
+ - f65db71: Use valid plain session targets for tmux session-title options, preventing `termwire up` from failing.
39
+
3
40
  ## 0.2.1
4
41
 
5
42
  ### 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
- A thin, typed adapter for tmux 3.2. Create it with `createTmux({ exec, env })`; production uses
14
- `Bun.spawn`, while tests can inject a fake `exec` without requiring a tmux binary.
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
- The factory exposes `hasSession`, `newSession`, `newWindow`, `splitPane`, `sendKeys`,
19
- `selectWindow`, `selectPane`, and `attach`. Attach uses `attach-session` outside tmux and
20
- `switch-client` when `TMUX` is set.
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. The CLI owns runtime layout interpretation and editor roles;
25
- no OpenCode, workspace orchestration, or Neovim logic belongs here.
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
@@ -1,4 +1,4 @@
1
- import { assertNotEmpty, ValidationError } from "./validation";
1
+ import { assertNotEmpty, ValidationError } from "./validation.js";
2
2
  export function appendEnvironment(argv, environment) {
3
3
  if (!environment)
4
4
  return;
@@ -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>;
@@ -1,9 +1,9 @@
1
- import { attach } from "./client";
2
- import { respawnPane, selectPane, sendKeys, splitPane } from "./pane";
3
- import { bunExec } from "./process";
4
- import { hasSession, killSession, newSession, setEnvironment, setSessionTitle } from "./session";
5
- import { newWindow, selectLayout, selectWindow } from "./window";
6
- export function createTmux({ exec = bunExec, env = process.env } = {}) {
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
@@ -1,4 +1,4 @@
1
- import { type Exec } from "./process";
1
+ import { type Exec } from "./process.js";
2
2
  export interface SplitPaneOptions {
3
3
  target: string;
4
4
  direction: "horizontal" | "vertical";
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 bunExec(argv: readonly string[], options?: ExecOptions): Promise<ExecResult>;
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 bunExec(argv, options) {
27
- const inherited = options?.stdio === "inherit";
28
- const proc = Bun.spawn([...argv], inherited
29
- ? { stdin: "inherit", stdout: "inherit", stderr: "inherit" }
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 [stdout, stderr] = await Promise.all([
36
- new Response(proc.stdout).text(),
37
- new Response(proc.stderr).text(),
38
- ]);
39
- return { exitCode, stdout, stderr };
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
@@ -1,5 +1,5 @@
1
- import { type WindowPaneIds } from "./command";
2
- import { type Exec } from "./process";
1
+ import { type WindowPaneIds } from "./command.js";
2
+ import { type Exec } from "./process.js";
3
3
  export interface NewSessionOptions {
4
4
  session: string;
5
5
  name?: string;
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}`];
@@ -23,7 +23,7 @@ export async function setEnvironment(exec, session, key, value) {
23
23
  }
24
24
  export async function setSessionTitle(exec, session) {
25
25
  assertNotEmpty("session", session);
26
- const setTitlesCommand = ["tmux", "set-option", "-t", `=${session}`, "set-titles", "on"];
26
+ const setTitlesCommand = ["tmux", "set-option", "-t", session, "set-titles", "on"];
27
27
  const setTitlesExecution = await execute(exec, setTitlesCommand);
28
28
  if (setTitlesExecution.exitCode !== 0) {
29
29
  throw CommandError.from(setTitlesCommand, setTitlesExecution);
@@ -32,7 +32,7 @@ export async function setSessionTitle(exec, session) {
32
32
  "tmux",
33
33
  "set-option",
34
34
  "-t",
35
- `=${session}`,
35
+ session,
36
36
  "set-titles-string",
37
37
  "#{session_name}",
38
38
  ];
package/dist/window.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { type WindowPaneIds } from "./command";
2
- import { type Exec } from "./process";
1
+ import { type WindowPaneIds } from "./command.js";
2
+ import { type Exec } from "./process.js";
3
3
  export interface NewWindowOptions {
4
4
  target: string;
5
5
  name?: string;
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.2.1",
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
- "bun": ">=1.3.14"
25
+ "node": ">=22.12.0"
26
26
  },
27
27
  "repository": {
28
28
  "type": "git",