terminal-pilot 0.0.7 → 0.0.9

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.
Files changed (51) hide show
  1. package/dist/cli.js +66 -103
  2. package/dist/cli.js.map +4 -4
  3. package/dist/commands/close-session.js +33 -81
  4. package/dist/commands/close-session.js.map +3 -3
  5. package/dist/commands/create-session.js +33 -81
  6. package/dist/commands/create-session.js.map +3 -3
  7. package/dist/commands/fill.js +33 -81
  8. package/dist/commands/fill.js.map +3 -3
  9. package/dist/commands/get-session.js +33 -81
  10. package/dist/commands/get-session.js.map +3 -3
  11. package/dist/commands/index.js +41 -92
  12. package/dist/commands/index.js.map +4 -4
  13. package/dist/commands/install.js +2 -5
  14. package/dist/commands/install.js.map +4 -4
  15. package/dist/commands/installer.js +2 -5
  16. package/dist/commands/installer.js.map +4 -4
  17. package/dist/commands/list-sessions.js +33 -81
  18. package/dist/commands/list-sessions.js.map +3 -3
  19. package/dist/commands/press-key.js +33 -81
  20. package/dist/commands/press-key.js.map +3 -3
  21. package/dist/commands/read-history.js +33 -81
  22. package/dist/commands/read-history.js.map +3 -3
  23. package/dist/commands/read-screen.js +33 -81
  24. package/dist/commands/read-screen.js.map +3 -3
  25. package/dist/commands/resize.js +33 -81
  26. package/dist/commands/resize.js.map +3 -3
  27. package/dist/commands/runtime.js +33 -81
  28. package/dist/commands/runtime.js.map +3 -3
  29. package/dist/commands/screenshot.js +33 -81
  30. package/dist/commands/screenshot.js.map +3 -3
  31. package/dist/commands/send-signal.js +33 -81
  32. package/dist/commands/send-signal.js.map +3 -3
  33. package/dist/commands/type.js +33 -81
  34. package/dist/commands/type.js.map +3 -3
  35. package/dist/commands/uninstall.js +1 -4
  36. package/dist/commands/uninstall.js.map +4 -4
  37. package/dist/commands/wait-for-exit.js +33 -81
  38. package/dist/commands/wait-for-exit.js.map +3 -3
  39. package/dist/commands/wait-for.js +33 -81
  40. package/dist/commands/wait-for.js.map +3 -3
  41. package/dist/index.js +33 -81
  42. package/dist/index.js.map +3 -3
  43. package/dist/terminal-pilot.js +33 -81
  44. package/dist/terminal-pilot.js.map +3 -3
  45. package/dist/terminal-session.js +33 -81
  46. package/dist/terminal-session.js.map +3 -3
  47. package/dist/testing/cli-repl.js +66 -103
  48. package/dist/testing/cli-repl.js.map +4 -4
  49. package/dist/testing/qa-cli.js +66 -103
  50. package/dist/testing/qa-cli.js.map +4 -4
  51. package/package.json +1 -1
@@ -1734,8 +1734,8 @@ function findVisibleChild(group, token, scope) {
1734
1734
  (child) => child.name === token || child.aliases.includes(token)
1735
1735
  );
1736
1736
  }
1737
- function resolveHelpTarget(root, argv, scope) {
1738
- const breadcrumb = [root.name];
1737
+ function resolveHelpTarget(root, argv, scope, rootDisplayName) {
1738
+ const breadcrumb = [rootDisplayName ?? root.name];
1739
1739
  let current = root;
1740
1740
  for (const token of argv.slice(2)) {
1741
1741
  if (token.startsWith("-") || token === "help") {
@@ -1826,7 +1826,7 @@ function formatCommandRows(group, scope) {
1826
1826
  function formatGlobalOptionRows(showVersion) {
1827
1827
  const rows = [
1828
1828
  {
1829
- flags: "--preset",
1829
+ flags: "--preset <path>",
1830
1830
  description: "Load parameter defaults from a JSON file"
1831
1831
  },
1832
1832
  {
@@ -1834,11 +1834,11 @@ function formatGlobalOptionRows(showVersion) {
1834
1834
  description: "Accept defaults, skip prompts"
1835
1835
  },
1836
1836
  {
1837
- flags: "--output",
1837
+ flags: "--output <format>",
1838
1838
  description: "Output format (rich, md, json)"
1839
1839
  },
1840
1840
  {
1841
- flags: "--help",
1841
+ flags: "-h, --help",
1842
1842
  description: "Show help"
1843
1843
  }
1844
1844
  ];
@@ -1853,7 +1853,14 @@ function formatGlobalOptionRows(showVersion) {
1853
1853
  function renderHelpSections(sections) {
1854
1854
  return sections.filter((section) => section.length > 0).join("\n\n");
1855
1855
  }
1856
- function renderGroupHelp(group, breadcrumb, scope, showVersion) {
1856
+ function buildUsageLine(breadcrumb, rootUsageName, suffix) {
1857
+ if (rootUsageName === void 0) {
1858
+ return void 0;
1859
+ }
1860
+ const subPath = breadcrumb.slice(1).join(" ");
1861
+ return subPath ? `${rootUsageName} ${subPath} ${suffix}` : `${rootUsageName} ${suffix}`;
1862
+ }
1863
+ function renderGroupHelp(group, breadcrumb, scope, showVersion, rootUsageName) {
1857
1864
  const sections = [];
1858
1865
  const commandRows = formatCommandRows(group, scope);
1859
1866
  if (commandRows.length > 0) {
@@ -1864,12 +1871,13 @@ ${formatCommandList(commandRows)}`);
1864
1871
  ${formatOptionList(formatGlobalOptionRows(showVersion))}`);
1865
1872
  return renderHelpDocument({
1866
1873
  breadcrumb,
1874
+ usageLine: buildUsageLine(breadcrumb, rootUsageName, "[options] [command]"),
1867
1875
  description: group.description,
1868
1876
  requiresAuth: group.requires?.auth === true,
1869
1877
  sections
1870
1878
  });
1871
1879
  }
1872
- function renderLeafHelp(command, breadcrumb, casing) {
1880
+ function renderLeafHelp(command, breadcrumb, casing, rootUsageName) {
1873
1881
  const sections = [];
1874
1882
  const fields = assignPositionals(collectFields(command.params, casing), command.positional);
1875
1883
  const optionRows = fields.map((field) => ({
@@ -1887,8 +1895,11 @@ ${formatOptionList(formatGlobalOptionRows(false))}`);
1887
1895
  sections.push(`${text.section("Secrets (via environment):")}
1888
1896
  ${formatOptionList(secretRows)}`);
1889
1897
  }
1898
+ const positionalFields = fields.filter((f) => f.positionalIndex !== void 0);
1899
+ const usageSuffix = positionalFields.length > 0 ? `[options] ${positionalFields.map(formatPositionalToken).join(" ")}` : "[options]";
1890
1900
  return renderHelpDocument({
1891
1901
  breadcrumb,
1902
+ usageLine: buildUsageLine(breadcrumb, rootUsageName, usageSuffix),
1892
1903
  description: command.description,
1893
1904
  requiresAuth: command.requires?.auth === true,
1894
1905
  sections
@@ -1896,11 +1907,14 @@ ${formatOptionList(secretRows)}`);
1896
1907
  }
1897
1908
  function renderHelpDocument(input) {
1898
1909
  const lines = [text.heading(input.breadcrumb.join(" ")), ""];
1910
+ if (input.usageLine !== void 0) {
1911
+ lines.push(`${text.section("Usage:")} ${text.usageCommand(input.usageLine)}`, "");
1912
+ }
1899
1913
  if (input.description !== void 0) {
1900
- lines.push(` ${input.description}`);
1914
+ lines.push(input.description);
1901
1915
  }
1902
1916
  if (input.requiresAuth) {
1903
- lines.push(" Requires: authentication");
1917
+ lines.push("Requires: authentication");
1904
1918
  }
1905
1919
  if (input.description !== void 0 || input.requiresAuth) {
1906
1920
  lines.push("");
@@ -1910,11 +1924,11 @@ function renderHelpDocument(input) {
1910
1924
  `;
1911
1925
  }
1912
1926
  async function renderGeneratedHelp(root, argv, options) {
1913
- const target = resolveHelpTarget(root, argv, "cli");
1927
+ const target = resolveHelpTarget(root, argv, "cli", options.rootDisplayName);
1914
1928
  const output = resolveHelpOutput(argv);
1915
1929
  const casing = options.casing ?? "kebab";
1916
1930
  await withOutputFormat2(output, async () => {
1917
- const rendered = target.node.kind === "group" ? renderGroupHelp(target.node, target.breadcrumb, "cli", options.version !== void 0) : renderLeafHelp(target.node, target.breadcrumb, casing);
1931
+ const rendered = target.node.kind === "group" ? renderGroupHelp(target.node, target.breadcrumb, "cli", options.version !== void 0, options.rootUsageName) : renderLeafHelp(target.node, target.breadcrumb, casing, options.rootUsageName);
1918
1932
  process.stdout.write(rendered);
1919
1933
  });
1920
1934
  }
@@ -2684,8 +2698,10 @@ async function runCLI(roots, options = {}) {
2684
2698
  import { randomUUID } from "node:crypto";
2685
2699
 
2686
2700
  // src/terminal-session.ts
2687
- import { spawn as spawnChildProcess } from "node:child_process";
2688
2701
  import { EventEmitter } from "node:events";
2702
+ import { accessSync, chmodSync, constants } from "node:fs";
2703
+ import { createRequire } from "node:module";
2704
+ import { dirname, join } from "node:path";
2689
2705
  import * as nodePty from "node-pty";
2690
2706
 
2691
2707
  // src/terminal-buffer.ts
@@ -3523,93 +3539,43 @@ function createPtyProcess({
3523
3539
  cols,
3524
3540
  rows
3525
3541
  }) {
3526
- try {
3527
- return nodePty.spawn(command, args, {
3528
- cwd,
3529
- env,
3530
- cols,
3531
- rows,
3532
- encoding: "utf8"
3533
- });
3534
- } catch {
3535
- return createChildProcessFallback({ command, args, cwd, env });
3536
- }
3537
- }
3538
- function createChildProcessFallback({
3539
- command,
3540
- args,
3541
- cwd,
3542
- env
3543
- }) {
3544
- const child = spawnChildProcess(command, args, {
3542
+ ensureSpawnHelperExecutable();
3543
+ return nodePty.spawn(command, args, {
3545
3544
  cwd,
3546
3545
  env,
3547
- stdio: ["pipe", "pipe", "pipe"]
3546
+ cols,
3547
+ rows,
3548
+ encoding: "utf8"
3548
3549
  });
3549
- return new ChildProcessFallback(child);
3550
3550
  }
3551
- var ChildProcessFallback = class {
3552
- pid;
3553
- child;
3554
- dataEmitter = new EventEmitter();
3555
- exitEmitter = new EventEmitter();
3556
- constructor(child) {
3557
- this.child = child;
3558
- this.pid = child.pid ?? -1;
3559
- child.stdout.setEncoding("utf8");
3560
- child.stderr.setEncoding("utf8");
3561
- child.stdout.on("data", this.handleData);
3562
- child.stderr.on("data", this.handleData);
3563
- child.on("exit", (exitCode, signal) => {
3564
- this.exitEmitter.emit("exit", {
3565
- exitCode: exitCode ?? signalToExitCode(signal),
3566
- signal: void 0
3567
- });
3568
- });
3569
- }
3570
- write(data) {
3571
- this.child.stdin.write(data);
3572
- }
3573
- resize() {
3574
- }
3575
- kill(signal) {
3576
- this.child.kill(signal);
3577
- }
3578
- onData(listener) {
3579
- this.dataEmitter.on("data", listener);
3580
- return {
3581
- dispose: () => {
3582
- this.dataEmitter.off("data", listener);
3583
- }
3584
- };
3585
- }
3586
- onExit(listener) {
3587
- this.exitEmitter.on("exit", listener);
3588
- return {
3589
- dispose: () => {
3590
- this.exitEmitter.off("exit", listener);
3551
+ var spawnHelperChecked = false;
3552
+ function ensureSpawnHelperExecutable() {
3553
+ if (spawnHelperChecked) return;
3554
+ spawnHelperChecked = true;
3555
+ const require3 = createRequire(import.meta.url);
3556
+ const nodePtyDir = dirname(require3.resolve("node-pty"));
3557
+ const helper = join(nodePtyDir, "..", "prebuilds", `${process.platform}-${process.arch}`, "spawn-helper");
3558
+ try {
3559
+ accessSync(helper, constants.X_OK);
3560
+ } catch (error2) {
3561
+ if (isMissingFileError(error2)) {
3562
+ return;
3563
+ }
3564
+ try {
3565
+ chmodSync(helper, 493);
3566
+ } catch (chmodError) {
3567
+ if (isMissingFileError(chmodError)) {
3568
+ return;
3591
3569
  }
3592
- };
3593
- }
3594
- handleData = (chunk) => {
3595
- this.dataEmitter.emit("data", String(chunk));
3596
- };
3597
- };
3598
- function signalToExitCode(signal) {
3599
- if (signal === null) {
3600
- return 0;
3570
+ throw chmodError;
3571
+ }
3601
3572
  }
3602
- const signalNumbers = {
3603
- SIGTERM: 15,
3604
- SIGINT: 2,
3605
- SIGHUP: 1,
3606
- SIGKILL: 9
3607
- };
3608
- const signalNumber = signalNumbers[signal];
3609
- if (signalNumber === void 0) {
3610
- return 1;
3573
+ }
3574
+ function isMissingFileError(error2) {
3575
+ if (!(error2 instanceof Error)) {
3576
+ return false;
3611
3577
  }
3612
- return 128 + signalNumber;
3578
+ return "code" in error2 && error2.code === "ENOENT";
3613
3579
  }
3614
3580
  function matchPattern(buffer, pattern) {
3615
3581
  const clean = normalizeHistoryBuffer(stripAnsi(buffer));
@@ -4996,9 +4962,6 @@ async function executeMutation(mutation, context, options) {
4996
4962
  import Mustache2 from "mustache";
4997
4963
  var originalEscape = Mustache2.escape;
4998
4964
 
4999
- // ../agent-skill-config/src/templates.ts
5000
- import { readFile as readFile2 } from "node:fs/promises";
5001
-
5002
4965
  // ../agent-skill-config/src/apply.ts
5003
4966
  var UnsupportedAgentError = class extends Error {
5004
4967
  constructor(agentId) {
@@ -5057,7 +5020,7 @@ async function installSkill(agentId, skill, options) {
5057
5020
  import os2 from "node:os";
5058
5021
  import path4 from "node:path";
5059
5022
  import * as nodeFs from "node:fs/promises";
5060
- import { readFile as readFile3 } from "node:fs/promises";
5023
+ import { readFile as readFile2 } from "node:fs/promises";
5061
5024
  var DEFAULT_INSTALL_AGENT = "claude-code";
5062
5025
  var DEFAULT_INSTALL_SCOPE = "local";
5063
5026
  var TERMINAL_PILOT_SKILL_NAME = "terminal-pilot";
@@ -5107,7 +5070,7 @@ async function loadTerminalPilotTemplate() {
5107
5070
  ];
5108
5071
  for (const candidate of candidates) {
5109
5072
  try {
5110
- terminalPilotTemplateCache = await readFile3(candidate, "utf8");
5073
+ terminalPilotTemplateCache = await readFile2(candidate, "utf8");
5111
5074
  return terminalPilotTemplateCache;
5112
5075
  } catch (error2) {
5113
5076
  if (!isNotFoundError(error2)) {
@@ -5542,14 +5505,14 @@ import { Resvg } from "@resvg/resvg-js";
5542
5505
 
5543
5506
  // ../terminal-png/src/font.ts
5544
5507
  import { readFileSync } from "node:fs";
5545
- import { createRequire } from "node:module";
5546
- import { dirname, join } from "node:path";
5508
+ import { createRequire as createRequire2 } from "node:module";
5509
+ import { dirname as dirname2, join as join2 } from "node:path";
5547
5510
  import { fileURLToPath as fileURLToPath2 } from "node:url";
5548
- var require2 = createRequire(import.meta.url);
5549
- var fontPackageRoot = dirname(require2.resolve("jetbrains-mono/package.json"));
5550
- var webfontRoot = join(fontPackageRoot, "fonts/webfonts");
5511
+ var require2 = createRequire2(import.meta.url);
5512
+ var fontPackageRoot = dirname2(require2.resolve("jetbrains-mono/package.json"));
5513
+ var webfontRoot = join2(fontPackageRoot, "fonts/webfonts");
5551
5514
  function readWebfontBase64(filename) {
5552
- return readFileSync(join(webfontRoot, filename)).toString("base64");
5515
+ return readFileSync(join2(webfontRoot, filename)).toString("base64");
5553
5516
  }
5554
5517
  function resolveAssetPath(filename) {
5555
5518
  return fileURLToPath2(new URL(`../assets/${filename}`, import.meta.url));