@libtmux/workspace-cli 0.1.0-alpha.12 → 0.1.0-alpha.13

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.
@@ -2,7 +2,7 @@ import {
2
2
  normalize,
3
3
  openTerminal,
4
4
  processRun
5
- } from "./main-c8atq2pj.js";
5
+ } from "./main-04s13z6x.js";
6
6
  import {
7
7
  CliError,
8
8
  OperationOutput,
@@ -17,16 +17,17 @@ import {
17
17
  scalarText,
18
18
  styled,
19
19
  write
20
- } from "./main-gh3pafqb.js";
20
+ } from "./main-gky86mgf.js";
21
21
  import {
22
22
  __require
23
- } from "./main-1de529jm.js";
23
+ } from "./main-p4mbtvt8.js";
24
24
 
25
25
  // src/tmux.ts
26
26
  import {
27
27
  isTmuxName,
28
28
  LibTmuxError,
29
- Server
29
+ Server,
30
+ VersionTooLowError
30
31
  } from "libtmux";
31
32
  import { stat } from "node:fs/promises";
32
33
  import { setTimeout as sleep } from "node:timers/promises";
@@ -75,6 +76,16 @@ function terminalArguments(server) {
75
76
  ...server.socketPath ? ["-S", server.socketPath] : server.socketName ? ["-L", server.socketName] : []
76
77
  ];
77
78
  }
79
+ function clientQueryArguments(server) {
80
+ return [...terminalArguments(server), "-N", "display-message", "-p", "#{client_name}"];
81
+ }
82
+ function handoffArguments(server, sessionId, client, colors) {
83
+ const args = [...terminalArguments(server), "-N"];
84
+ if (colors === 256)
85
+ args.push("-2");
86
+ args.push(...client?.mode === "switch" ? client.client ? ["switch-client", "-c", client.client] : ["switch-client"] : ["attach-session"], "-t", sessionId);
87
+ return args;
88
+ }
78
89
  function targetMismatch() {
79
90
  return new CliError("usage", "This operation must target the current pane's tmux server", 2);
80
91
  }
@@ -133,7 +144,7 @@ async function attachmentClient(server, context) {
133
144
  return { mode: "switch" };
134
145
  }
135
146
  const { session } = await currentSession(server, context);
136
- const query = await processRun([...terminalArguments(server), "display-message", "-p", "#{client_name}"], {
147
+ const query = await processRun(clientQueryArguments(server), {
137
148
  cwd: context.cwd,
138
149
  env: context.env,
139
150
  terminal: "input",
@@ -541,12 +552,12 @@ async function promptChoice(context, message, choices) {
541
552
  }
542
553
  async function load(request, context) {
543
554
  if (request.values.colors === 88)
544
- throw new CliError("usage", "tmux 3.2a+ rejects the legacy 88-color flag (-8); remove it or use -2 for 256 colors", 2);
555
+ throw new CliError("usage", "tmux rejects the legacy 88-color flag (-8); remove it or use -2 for 256 colors", 2);
545
556
  if (request.mode !== "human" && !request.values.detached && !request.values.append)
546
557
  throw new CliError("usage", "Machine load requires -d or an explicit append operation", 2);
547
558
  let appendRequested = Boolean(request.values.append) && !request.values.detached;
548
559
  sessionDimensions(context);
549
- const progress = request.mode === "human" && context.stderr.isTTY ? (await import("./progress-n08zapg2.js")).LoadProgress.create(request, context) : undefined;
560
+ const progress = request.mode === "human" && context.stderr.isTTY ? (await import("./progress-bf8sfdrg.js")).LoadProgress.create(request, context) : undefined;
550
561
  const inputs = [];
551
562
  let bridge;
552
563
  const files = request.values.workspace_files;
@@ -556,7 +567,7 @@ async function load(request, context) {
556
567
  const document = await readDocument(path);
557
568
  const override = index === files.length - 1 && request.values.new_session_name ? scalarText(request.values.new_session_name) : undefined;
558
569
  if (["plugins", "workspace_builder", "workspace_builder_paths"].some((key) => Object.hasOwn(document, key)))
559
- bridge ??= await import("./extensions-8v6mfszj.js");
570
+ bridge ??= await import("./extensions-zx6s05v3.js");
560
571
  const extension = await bridge?.extensionPlan(document, path, context, appendRequested, override);
561
572
  inputs.push(extension ? { path, kind: "extension", spec: extension } : { path, kind: "native", spec: normalize(document, path, context, override) });
562
573
  } catch (error) {
@@ -719,10 +730,7 @@ async function load(request, context) {
719
730
  const last = results.at(-1);
720
731
  if (attached && last?.session_id) {
721
732
  last.stage = client?.mode === "switch" ? "switching-client" : "attaching";
722
- const args = terminalArguments(server);
723
- if (request.values.colors === 256)
724
- args.push("-2");
725
- args.push(...client?.mode === "switch" ? client.client ? ["switch-client", "-c", client.client] : ["switch-client"] : ["attach-session"], "-t", last.session_id);
733
+ const args = handoffArguments(server, last.session_id, client, request.values.colors);
726
734
  const child = await processRun(args, {
727
735
  cwd: context.cwd,
728
736
  env: context.env,
@@ -741,7 +749,7 @@ async function load(request, context) {
741
749
  const interrupted = context.signal?.aborted;
742
750
  const changed = results.some((result) => result.effects_unknown || result.stage === "completed" || result.session_id && !result.session_removed && !result.missing_windows);
743
751
  const unreachable = !(error instanceof CliError) && isTmuxUnavailable(error);
744
- const code = interrupted ? "interrupted" : error instanceof CliError ? error.code : unreachable ? "tmux_unavailable" : "tmux_failed";
752
+ const code = interrupted ? "interrupted" : error instanceof CliError ? error.code : error instanceof VersionTooLowError ? "tmux_unsupported" : unreachable ? "tmux_unavailable" : "tmux_failed";
745
753
  const kept = results.flatMap((result) => result.session_id && !result.session_removed ? result.created_window_names ?? [] : []);
746
754
  const message = (unreachable ? unreachableMessage(server, error) : error instanceof Error ? error.message : String(error)) + (kept.length > 0 ? `. Windows kept: ${kept.join(", ")}` : "");
747
755
  await output.result({
@@ -812,6 +820,8 @@ async function freeze(request, context) {
812
820
  } catch (error) {
813
821
  if (error instanceof CliError || context.signal?.aborted)
814
822
  throw error;
823
+ if (error instanceof VersionTooLowError)
824
+ throw new CliError("tmux_unsupported", error.message);
815
825
  if (isTmuxUnavailable(error))
816
826
  throw new CliError("tmux_unavailable", unreachableMessage(server, error));
817
827
  throw new CliError("tmux_failed", error instanceof Error ? error.message : String(error));
@@ -887,7 +897,9 @@ async function capture(server, request, context) {
887
897
  return 0;
888
898
  }
889
899
  export {
900
+ clientQueryArguments,
890
901
  connection,
891
902
  freeze,
903
+ handoffArguments,
892
904
  load
893
905
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@libtmux/workspace-cli",
3
- "version": "0.1.0-alpha.12",
3
+ "version": "0.1.0-alpha.13",
4
4
  "description": "A tmuxp-compatible workspace manager for Node and Bun.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -12,6 +12,7 @@
12
12
  "tmux-workspace": "./dist/main.js"
13
13
  },
14
14
  "files": [
15
+ "assets",
15
16
  "dist",
16
17
  "docs",
17
18
  "THIRD-PARTY-NOTICES.md"
@@ -32,14 +33,14 @@
32
33
  "test:install": "bun run build && bun scripts/check-install.ts"
33
34
  },
34
35
  "dependencies": {
35
- "libtmux": "0.1.0-alpha.12"
36
+ "libtmux": "0.1.0-alpha.13"
36
37
  },
37
38
  "devDependencies": {
38
39
  "cli-truncate": "6.1.1",
39
40
  "commander": "15.0.0",
40
- "oxfmt": "0.68.0",
41
- "string-width": "8.2.2",
42
- "yaml": "2.9.0"
41
+ "oxfmt": "0.73.0",
42
+ "string-width": "8.3.0",
43
+ "yaml": "2.9.1"
43
44
  },
44
45
  "engines": {
45
46
  "bun": ">=1.3.14",
@@ -1,37 +0,0 @@
1
- import { createRequire } from "node:module";
2
- var __create = Object.create;
3
- var __getProtoOf = Object.getPrototypeOf;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- function __accessProp(key) {
8
- return this[key];
9
- }
10
- var __toESMCache_node;
11
- var __toESMCache_esm;
12
- var __toESM = (mod, isNodeMode, target) => {
13
- var canCache = mod != null && typeof mod === "object";
14
- if (canCache) {
15
- var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
16
- var cached = cache.get(mod);
17
- if (cached)
18
- return cached;
19
- }
20
- target = mod != null ? __create(__getProtoOf(mod)) : {};
21
- const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
22
- if (mod && typeof mod === "object" || typeof mod === "function") {
23
- for (let key of __getOwnPropNames(mod))
24
- if (!__hasOwnProp.call(to, key))
25
- __defProp(to, key, {
26
- get: __accessProp.bind(mod, key),
27
- enumerable: true
28
- });
29
- }
30
- if (canCache)
31
- cache.set(mod, to);
32
- return to;
33
- };
34
- var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
35
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
36
-
37
- export { __toESM, __commonJS, __require };