@treeport/treeport 0.5.0 → 0.7.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.
@@ -1,9 +1,10 @@
1
1
  #!/usr/bin/env node
2
- import { t as integrateShellLaunch } from "../../../shell-integration-Be_c91lw.js";
2
+ import "../../../dist-BsLn2Gbc.js";
3
+ import { t as integrateShellLaunch } from "../../../shell-integration-CPmrVa3B.js";
3
4
  import fs from "node:fs/promises";
4
5
  import path from "node:path";
5
- import { z } from "zod";
6
6
  import { spawn } from "node:child_process";
7
+ import { z } from "zod";
7
8
  import { fileURLToPath } from "node:url";
8
9
  //#region src/server/core/launcher.ts
9
10
  const FORWARDED_SIGNALS = [
@@ -13,11 +14,11 @@ const FORWARDED_SIGNALS = [
13
14
  ];
14
15
  const launchSpecSchema = z.object({
15
16
  argv: z.array(z.string()),
17
+ initialTitle: z.string().trim().min(1).max(120).optional(),
16
18
  fallbackArgv: z.array(z.string()).optional(),
17
19
  cwd: z.string(),
18
20
  env: z.record(z.string(), z.string()),
19
21
  shellIntegrationDir: z.string().optional(),
20
- tmuxExecutable: z.string().optional(),
21
22
  setupTasks: z.array(z.object({
22
23
  label: z.string(),
23
24
  argv: z.array(z.string()),
@@ -112,7 +113,6 @@ async function runLaunchSpec(spec, dependencies = {}) {
112
113
  const stdout = dependencies.stdout ?? process.stdout;
113
114
  const stderr = dependencies.stderr ?? process.stderr;
114
115
  const signalSource = dependencies.signalSource ?? process;
115
- const tmuxPane = dependencies.tmuxPane === void 0 ? process.env.TMUX_PANE : dependencies.tmuxPane ?? void 0;
116
116
  if (spec.setupError) {
117
117
  stderr.write(`[Treeport setup] ${safeDiagnostic(spec.setupError) || "setup preparation failed"}\n`);
118
118
  return 1;
@@ -158,7 +158,9 @@ async function runLaunchSpec(spec, dependencies = {}) {
158
158
  ...process.env,
159
159
  ...spec.env
160
160
  };
161
- const command = integrateShellLaunch(spec.argv, commandEnvironment, spec.shellIntegrationDir, spec.tmuxExecutable);
161
+ const command = integrateShellLaunch(spec.argv, commandEnvironment, spec.shellIntegrationDir, Boolean(spec.shellIntegrationDir));
162
+ const initialTitle = spec.initialTitle ? safeDiagnostic(spec.initialTitle) : "";
163
+ if (initialTitle && spec.shellIntegrationDir) stdout.write(`\u001b]777;command;${initialTitle}\u001b\\`);
162
164
  const result = await runChild(command.argv, {
163
165
  cwd: spec.cwd,
164
166
  env: command.env,
@@ -168,22 +170,8 @@ async function runLaunchSpec(spec, dependencies = {}) {
168
170
  if (result.spawnError) stderr.write(`Treeport launcher: ${safeDiagnostic(result.spawnError.message) || "spawn error"}\n`);
169
171
  if (result.forwardedSignal && (!spec.fallbackArgv || result.forwardedSignal !== "SIGINT")) return 1;
170
172
  if (spec.fallbackArgv) {
171
- if (spec.tmuxExecutable && tmuxPane && spec.fallbackArgv[0]) await runChild([
172
- spec.tmuxExecutable,
173
- "set-option",
174
- "-p",
175
- "-t",
176
- tmuxPane,
177
- "--",
178
- "@treeport-fallback-shell",
179
- Buffer.from(JSON.stringify(spec.fallbackArgv[0]), "utf8").toString("base64url")
180
- ], {
181
- cwd: spec.cwd,
182
- env: process.env,
183
- spawnProcess,
184
- signalSource
185
- });
186
- const fallback = integrateShellLaunch(spec.fallbackArgv, commandEnvironment, spec.shellIntegrationDir, spec.tmuxExecutable);
173
+ if (spec.shellIntegrationDir) stdout.write("\x1B]777;command;\x1B\\");
174
+ const fallback = integrateShellLaunch(spec.fallbackArgv, commandEnvironment, spec.shellIntegrationDir, Boolean(spec.shellIntegrationDir));
187
175
  const fallbackResult = await runChild(fallback.argv, {
188
176
  cwd: spec.cwd,
189
177
  env: fallback.env,
@@ -217,6 +205,9 @@ async function main() {
217
205
  process.exit(await runLaunchSpec(spec));
218
206
  }
219
207
  const invokedPath = process.argv[1];
220
- if (invokedPath && path.resolve(invokedPath) === path.resolve(fileURLToPath(import.meta.url))) main();
208
+ if (invokedPath && path.resolve(invokedPath) === path.resolve(fileURLToPath(import.meta.url))) main().catch((error) => {
209
+ process.stderr.write(`Treeport launcher: ${error instanceof Error ? error.message : String(error)}\n`);
210
+ process.exit(127);
211
+ });
221
212
  //#endregion
222
213
  export { runLaunchSpec };