@solaqua/gji 0.7.2 → 0.8.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.
@@ -3465,7 +3465,7 @@ var require_polyfills = __commonJS({
3465
3465
  var constants2 = __require("constants");
3466
3466
  var origCwd = process.cwd;
3467
3467
  var cwd = null;
3468
- var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform;
3468
+ var platform2 = process.env.GRACEFUL_FS_PLATFORM || process.platform;
3469
3469
  process.cwd = function() {
3470
3470
  if (!cwd)
3471
3471
  cwd = origCwd.call(process);
@@ -3524,7 +3524,7 @@ var require_polyfills = __commonJS({
3524
3524
  fs5.lchownSync = function() {
3525
3525
  };
3526
3526
  }
3527
- if (platform === "win32") {
3527
+ if (platform2 === "win32") {
3528
3528
  fs5.rename = typeof fs5.rename !== "function" ? fs5.rename : (function(fs$rename) {
3529
3529
  function rename(from, to, cb) {
3530
3530
  var start = Date.now();
@@ -5036,11 +5036,11 @@ var require_utils = __commonJS({
5036
5036
  var content = file.apply(null, arguments);
5037
5037
  return content ? parse(content) : null;
5038
5038
  };
5039
- var env4 = exports.env = function(prefix, env5) {
5040
- env5 = env5 || process.env;
5039
+ var env5 = exports.env = function(prefix, env6) {
5040
+ env6 = env6 || process.env;
5041
5041
  var obj = {};
5042
5042
  var l2 = prefix.length;
5043
- for (var k3 in env5) {
5043
+ for (var k3 in env6) {
5044
5044
  if (k3.toLowerCase().indexOf(prefix.toLowerCase()) === 0) {
5045
5045
  var keypath = k3.substring(l2).split("__");
5046
5046
  var _emptyStringIndex;
@@ -5052,7 +5052,7 @@ var require_utils = __commonJS({
5052
5052
  if (!_subkey || typeof cursor !== "object")
5053
5053
  return;
5054
5054
  if (i === keypath.length - 1)
5055
- cursor[_subkey] = env5[k3];
5055
+ cursor[_subkey] = env6[k3];
5056
5056
  if (cursor[_subkey] === void 0)
5057
5057
  cursor[_subkey] = {};
5058
5058
  cursor = cursor[_subkey];
@@ -5398,7 +5398,7 @@ var require_rc = __commonJS({
5398
5398
  argv = require_minimist()(process.argv.slice(2));
5399
5399
  defaults = ("string" === typeof defaults ? cc.json(defaults) : defaults) || {};
5400
5400
  parse = parse || cc.parse;
5401
- var env4 = cc.env(name + "_");
5401
+ var env5 = cc.env(name + "_");
5402
5402
  var configs = [defaults];
5403
5403
  var configFiles = [];
5404
5404
  function addConfigFile(file) {
@@ -5422,10 +5422,10 @@ var require_rc = __commonJS({
5422
5422
  join10(home, "." + name + "rc")
5423
5423
  ].forEach(addConfigFile);
5424
5424
  addConfigFile(cc.find("." + name + "rc"));
5425
- if (env4.config) addConfigFile(env4.config);
5425
+ if (env5.config) addConfigFile(env5.config);
5426
5426
  if (argv.config) addConfigFile(argv.config);
5427
5427
  return deepExtend.apply(null, configs.concat([
5428
- env4,
5428
+ env5,
5429
5429
  argv,
5430
5430
  configFiles.length ? { configs: configFiles, config: configFiles[configFiles.length - 1] } : void 0
5431
5431
  ]));
@@ -5439,7 +5439,7 @@ var require_polyfills2 = __commonJS({
5439
5439
  var constants2 = __require("constants");
5440
5440
  var origCwd = process.cwd;
5441
5441
  var cwd = null;
5442
- var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform;
5442
+ var platform2 = process.env.GRACEFUL_FS_PLATFORM || process.platform;
5443
5443
  process.cwd = function() {
5444
5444
  if (!cwd)
5445
5445
  cwd = origCwd.call(process);
@@ -5498,7 +5498,7 @@ var require_polyfills2 = __commonJS({
5498
5498
  fs5.lchownSync = function() {
5499
5499
  };
5500
5500
  }
5501
- if (platform === "win32") {
5501
+ if (platform2 === "win32") {
5502
5502
  fs5.rename = typeof fs5.rename !== "function" ? fs5.rename : (function(fs$rename) {
5503
5503
  function rename(from, to, cb) {
5504
5504
  var start = Date.now();
@@ -6423,13 +6423,13 @@ var require_config_chain = __commonJS({
6423
6423
  }
6424
6424
  return parse(content, file, "json");
6425
6425
  };
6426
- var env4 = exports.env = function(prefix, env5) {
6427
- env5 = env5 || process.env;
6426
+ var env5 = exports.env = function(prefix, env6) {
6427
+ env6 = env6 || process.env;
6428
6428
  var obj = {};
6429
6429
  var l2 = prefix.length;
6430
- for (var k3 in env5) {
6430
+ for (var k3 in env6) {
6431
6431
  if (k3.indexOf(prefix) === 0)
6432
- obj[k3.substring(l2)] = env5[k3];
6432
+ obj[k3.substring(l2)] = env6[k3];
6433
6433
  }
6434
6434
  return obj;
6435
6435
  };
@@ -6535,10 +6535,10 @@ var require_config_chain = __commonJS({
6535
6535
  }.bind(this));
6536
6536
  return this;
6537
6537
  };
6538
- ConfigChain.prototype.addEnv = function(prefix, env5, name) {
6538
+ ConfigChain.prototype.addEnv = function(prefix, env6, name) {
6539
6539
  name = name || "env";
6540
- var data = exports.env(prefix, env5);
6541
- this.sources[name] = { data, source: env5, prefix };
6540
+ var data = exports.env(prefix, env6);
6541
+ this.sources[name] = { data, source: env6, prefix };
6542
6542
  return this.add(data, name);
6543
6543
  };
6544
6544
  ConfigChain.prototype.addUrl = function(req, type, name) {
@@ -6630,28 +6630,28 @@ var require_env_replace = __commonJS({
6630
6630
  Object.defineProperty(exports, "__esModule", { value: true });
6631
6631
  exports.envReplace = void 0;
6632
6632
  var ENV_EXPR = /(?<!\\)(\\*)\$\{([^${}]+)\}/g;
6633
- function envReplace(settingValue, env4) {
6634
- return settingValue.replace(ENV_EXPR, replaceEnvMatch.bind(null, env4));
6633
+ function envReplace(settingValue, env5) {
6634
+ return settingValue.replace(ENV_EXPR, replaceEnvMatch.bind(null, env5));
6635
6635
  }
6636
6636
  exports.envReplace = envReplace;
6637
- function replaceEnvMatch(env4, orig, escape, name) {
6637
+ function replaceEnvMatch(env5, orig, escape, name) {
6638
6638
  if (escape.length % 2) {
6639
6639
  return orig.slice((escape.length + 1) / 2);
6640
6640
  }
6641
- const envValue = getEnvValue(env4, name);
6641
+ const envValue = getEnvValue(env5, name);
6642
6642
  if (envValue === void 0) {
6643
6643
  throw new Error(`Failed to replace env in config: ${orig}`);
6644
6644
  }
6645
6645
  return `${escape.slice(escape.length / 2)}${envValue}`;
6646
6646
  }
6647
6647
  var ENV_VALUE = /([^:-]+)(:?)-(.+)/;
6648
- function getEnvValue(env4, name) {
6648
+ function getEnvValue(env5, name) {
6649
6649
  const matched = name.match(ENV_VALUE);
6650
6650
  if (!matched)
6651
- return env4[name];
6651
+ return env5[name];
6652
6652
  const [, variableName, colon, fallback] = matched;
6653
- if (Object.prototype.hasOwnProperty.call(env4, variableName)) {
6654
- return !env4[variableName] && colon ? fallback : env4[variableName];
6653
+ if (Object.prototype.hasOwnProperty.call(env5, variableName)) {
6654
+ return !env5[variableName] && colon ? fallback : env5[variableName];
6655
6655
  }
6656
6656
  return fallback;
6657
6657
  }
@@ -6971,15 +6971,15 @@ var require_conf = __commonJS({
6971
6971
  }
6972
6972
  }
6973
6973
  // https://github.com/npm/cli/blob/latest/lib/config/core.js#L341-L357
6974
- addEnv(env4) {
6975
- env4 = env4 || process.env;
6974
+ addEnv(env5) {
6975
+ env5 = env5 || process.env;
6976
6976
  const conf = {};
6977
- Object.keys(env4).filter((x2) => /^npm_config_/i.test(x2)).forEach((x2) => {
6978
- if (!env4[x2]) {
6977
+ Object.keys(env5).filter((x2) => /^npm_config_/i.test(x2)).forEach((x2) => {
6978
+ if (!env5[x2]) {
6979
6979
  return;
6980
6980
  }
6981
6981
  const key = envKeyToSetting(x2.substr(11));
6982
- const rawVal = env4[x2];
6982
+ const rawVal = env5[x2];
6983
6983
  conf[key] = deserializeEnvVal(key, rawVal);
6984
6984
  });
6985
6985
  return super.addEnv("", conf, "env");
@@ -9354,8 +9354,8 @@ var require_picocolors = __commonJS({
9354
9354
  "node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js"(exports, module) {
9355
9355
  var p2 = process || {};
9356
9356
  var argv = p2.argv || [];
9357
- var env4 = p2.env || {};
9358
- var isColorSupported = !(!!env4.NO_COLOR || argv.includes("--no-color")) && (!!env4.FORCE_COLOR || argv.includes("--color") || p2.platform === "win32" || (p2.stdout || {}).isTTY && env4.TERM !== "dumb" || !!env4.CI);
9357
+ var env5 = p2.env || {};
9358
+ var isColorSupported = !(!!env5.NO_COLOR || argv.includes("--no-color")) && (!!env5.FORCE_COLOR || argv.includes("--color") || p2.platform === "win32" || (p2.stdout || {}).isTTY && env5.TERM !== "dumb" || !!env5.CI);
9359
9359
  var formatter = (open, close, replace = open) => (input) => {
9360
9360
  let string = "" + input, index = string.indexOf(close, open.length);
9361
9361
  return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
@@ -10178,7 +10178,7 @@ var Configstore = class {
10178
10178
  var ANSI_BACKGROUND_OFFSET = 10;
10179
10179
  var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
10180
10180
  var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
10181
- var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
10181
+ var wrapAnsi16m = (offset = 0) => (red2, green2, blue) => `\x1B[${38 + offset};2;${red2};${green2};${blue}m`;
10182
10182
  var styles = {
10183
10183
  modifier: {
10184
10184
  reset: [0, 0],
@@ -10273,17 +10273,17 @@ function assembleStyles() {
10273
10273
  styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
10274
10274
  Object.defineProperties(styles, {
10275
10275
  rgbToAnsi256: {
10276
- value(red, green, blue) {
10277
- if (red === green && green === blue) {
10278
- if (red < 8) {
10276
+ value(red2, green2, blue) {
10277
+ if (red2 === green2 && green2 === blue) {
10278
+ if (red2 < 8) {
10279
10279
  return 16;
10280
10280
  }
10281
- if (red > 248) {
10281
+ if (red2 > 248) {
10282
10282
  return 231;
10283
10283
  }
10284
- return Math.round((red - 8) / 247 * 24) + 232;
10284
+ return Math.round((red2 - 8) / 247 * 24) + 232;
10285
10285
  }
10286
- return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
10286
+ return 16 + 36 * Math.round(red2 / 255 * 5) + 6 * Math.round(green2 / 255 * 5) + Math.round(blue / 255 * 5);
10287
10287
  },
10288
10288
  enumerable: false
10289
10289
  },
@@ -10320,25 +10320,25 @@ function assembleStyles() {
10320
10320
  if (code < 16) {
10321
10321
  return 90 + (code - 8);
10322
10322
  }
10323
- let red;
10324
- let green;
10323
+ let red2;
10324
+ let green2;
10325
10325
  let blue;
10326
10326
  if (code >= 232) {
10327
- red = ((code - 232) * 10 + 8) / 255;
10328
- green = red;
10329
- blue = red;
10327
+ red2 = ((code - 232) * 10 + 8) / 255;
10328
+ green2 = red2;
10329
+ blue = red2;
10330
10330
  } else {
10331
10331
  code -= 16;
10332
10332
  const remainder = code % 36;
10333
- red = Math.floor(code / 36) / 5;
10334
- green = Math.floor(remainder / 6) / 5;
10333
+ red2 = Math.floor(code / 36) / 5;
10334
+ green2 = Math.floor(remainder / 6) / 5;
10335
10335
  blue = remainder % 6 / 5;
10336
10336
  }
10337
- const value = Math.max(red, green, blue) * 2;
10337
+ const value = Math.max(red2, green2, blue) * 2;
10338
10338
  if (value === 0) {
10339
10339
  return 30;
10340
10340
  }
10341
- let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
10341
+ let result = 30 + (Math.round(blue) << 2 | Math.round(green2) << 1 | Math.round(red2));
10342
10342
  if (value === 2) {
10343
10343
  result += 60;
10344
10344
  }
@@ -10347,7 +10347,7 @@ function assembleStyles() {
10347
10347
  enumerable: false
10348
10348
  },
10349
10349
  rgbToAnsi: {
10350
- value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
10350
+ value: (red2, green2, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red2, green2, blue)),
10351
10351
  enumerable: false
10352
10352
  },
10353
10353
  hexToAnsi: {
@@ -11976,7 +11976,7 @@ var import_ansi_align = __toESM(require_ansi_align(), 1);
11976
11976
  var ANSI_BACKGROUND_OFFSET2 = 10;
11977
11977
  var wrapAnsi162 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
11978
11978
  var wrapAnsi2562 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
11979
- var wrapAnsi16m2 = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
11979
+ var wrapAnsi16m2 = (offset = 0) => (red2, green2, blue) => `\x1B[${38 + offset};2;${red2};${green2};${blue}m`;
11980
11980
  var styles3 = {
11981
11981
  modifier: {
11982
11982
  reset: [0, 0],
@@ -12071,17 +12071,17 @@ function assembleStyles2() {
12071
12071
  styles3.bgColor.ansi16m = wrapAnsi16m2(ANSI_BACKGROUND_OFFSET2);
12072
12072
  Object.defineProperties(styles3, {
12073
12073
  rgbToAnsi256: {
12074
- value(red, green, blue) {
12075
- if (red === green && green === blue) {
12076
- if (red < 8) {
12074
+ value(red2, green2, blue) {
12075
+ if (red2 === green2 && green2 === blue) {
12076
+ if (red2 < 8) {
12077
12077
  return 16;
12078
12078
  }
12079
- if (red > 248) {
12079
+ if (red2 > 248) {
12080
12080
  return 231;
12081
12081
  }
12082
- return Math.round((red - 8) / 247 * 24) + 232;
12082
+ return Math.round((red2 - 8) / 247 * 24) + 232;
12083
12083
  }
12084
- return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
12084
+ return 16 + 36 * Math.round(red2 / 255 * 5) + 6 * Math.round(green2 / 255 * 5) + Math.round(blue / 255 * 5);
12085
12085
  },
12086
12086
  enumerable: false
12087
12087
  },
@@ -12118,25 +12118,25 @@ function assembleStyles2() {
12118
12118
  if (code < 16) {
12119
12119
  return 90 + (code - 8);
12120
12120
  }
12121
- let red;
12122
- let green;
12121
+ let red2;
12122
+ let green2;
12123
12123
  let blue;
12124
12124
  if (code >= 232) {
12125
- red = ((code - 232) * 10 + 8) / 255;
12126
- green = red;
12127
- blue = red;
12125
+ red2 = ((code - 232) * 10 + 8) / 255;
12126
+ green2 = red2;
12127
+ blue = red2;
12128
12128
  } else {
12129
12129
  code -= 16;
12130
12130
  const remainder = code % 36;
12131
- red = Math.floor(code / 36) / 5;
12132
- green = Math.floor(remainder / 6) / 5;
12131
+ red2 = Math.floor(code / 36) / 5;
12132
+ green2 = Math.floor(remainder / 6) / 5;
12133
12133
  blue = remainder % 6 / 5;
12134
12134
  }
12135
- const value = Math.max(red, green, blue) * 2;
12135
+ const value = Math.max(red2, green2, blue) * 2;
12136
12136
  if (value === 0) {
12137
12137
  return 30;
12138
12138
  }
12139
- let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
12139
+ let result = 30 + (Math.round(blue) << 2 | Math.round(green2) << 1 | Math.round(red2));
12140
12140
  if (value === 2) {
12141
12141
  result += 60;
12142
12142
  }
@@ -12145,7 +12145,7 @@ function assembleStyles2() {
12145
12145
  enumerable: false
12146
12146
  },
12147
12147
  rgbToAnsi: {
12148
- value: (red, green, blue) => styles3.ansi256ToAnsi(styles3.rgbToAnsi256(red, green, blue)),
12148
+ value: (red2, green2, blue) => styles3.ansi256ToAnsi(styles3.rgbToAnsi256(red2, green2, blue)),
12149
12149
  enumerable: false
12150
12150
  },
12151
12151
  hexToAnsi: {
@@ -12319,15 +12319,15 @@ var NEWLINE = "\n";
12319
12319
  var PAD = " ";
12320
12320
  var NONE = "none";
12321
12321
  var terminalColumns = () => {
12322
- const { env: env4, stdout, stderr } = process9;
12323
- if (stdout?.columns) {
12324
- return stdout.columns;
12322
+ const { env: env5, stdout: stdout2, stderr } = process9;
12323
+ if (stdout2?.columns) {
12324
+ return stdout2.columns;
12325
12325
  }
12326
12326
  if (stderr?.columns) {
12327
12327
  return stderr.columns;
12328
12328
  }
12329
- if (env4.COLUMNS) {
12330
- return Number.parseInt(env4.COLUMNS, 10);
12329
+ if (env5.COLUMNS) {
12330
+ return Number.parseInt(env5.COLUMNS, 10);
12331
12331
  }
12332
12332
  return 80;
12333
12333
  };
@@ -12554,10 +12554,10 @@ var determineDimensions = (text, options) => {
12554
12554
  }
12555
12555
  return options;
12556
12556
  };
12557
- var isHex = (color) => color.match(/^#(?:[0-f]{3}){1,2}$/i);
12558
- var isColorValid = (color) => typeof color === "string" && (source_default[color] ?? isHex(color));
12559
- var getColorFunction = (color) => isHex(color) ? source_default.hex(color) : source_default[color];
12560
- var getBGColorFunction = (color) => isHex(color) ? source_default.bgHex(color) : source_default[camelCase(["bg", color])];
12557
+ var isHex = (color2) => color2.match(/^#(?:[0-f]{3}){1,2}$/i);
12558
+ var isColorValid = (color2) => typeof color2 === "string" && (source_default[color2] ?? isHex(color2));
12559
+ var getColorFunction = (color2) => isHex(color2) ? source_default.hex(color2) : source_default[color2];
12560
+ var getBGColorFunction = (color2) => isHex(color2) ? source_default.bgHex(color2) : source_default[camelCase(["bg", color2])];
12561
12561
  function boxen(text, options) {
12562
12562
  options = {
12563
12563
  padding: 0,
@@ -13209,20 +13209,20 @@ import { promisify as promisify2 } from "node:util";
13209
13209
  var execFileAsync = promisify2(execFile);
13210
13210
  async function runGit(cwd, args) {
13211
13211
  try {
13212
- const { stdout } = await execFileAsync("git", args, { cwd });
13213
- return stdout.trim();
13212
+ const { stdout: stdout2 } = await execFileAsync("git", args, { cwd });
13213
+ return stdout2.trim();
13214
13214
  } catch (error) {
13215
13215
  const message = error instanceof Error ? error.message : String(error);
13216
13216
  throw new Error(`Git command failed in '${cwd}': ${message}`);
13217
13217
  }
13218
13218
  }
13219
13219
  async function readWorktreeHealth(cwd) {
13220
- const { stdout } = await execFileAsync(
13220
+ const { stdout: stdout2 } = await execFileAsync(
13221
13221
  "git",
13222
13222
  ["status", "--porcelain=v2", "--branch"],
13223
13223
  { cwd }
13224
13224
  );
13225
- return parseWorktreeHealth(stdout);
13225
+ return parseWorktreeHealth(stdout2);
13226
13226
  }
13227
13227
  async function isDirtyWorktree(cwd) {
13228
13228
  const health = await readWorktreeHealth(cwd);
@@ -13242,12 +13242,12 @@ async function isBranchMergedInto(cwd, branch, base = "HEAD") {
13242
13242
  }
13243
13243
  }
13244
13244
  async function resolveRemoteDefaultBranch(cwd, remote) {
13245
- const { stdout } = await execFileAsync(
13245
+ const { stdout: stdout2 } = await execFileAsync(
13246
13246
  "git",
13247
13247
  ["ls-remote", "--symref", remote, "HEAD"],
13248
13248
  { cwd }
13249
13249
  );
13250
- const refLine = stdout.split("\n").find((line) => line.startsWith("ref: refs/heads/"));
13250
+ const refLine = stdout2.split("\n").find((line) => line.startsWith("ref: refs/heads/"));
13251
13251
  if (!refLine) {
13252
13252
  return null;
13253
13253
  }
@@ -13256,12 +13256,12 @@ async function resolveRemoteDefaultBranch(cwd, remote) {
13256
13256
  }
13257
13257
  async function readBranchLastCommitTimestamp(cwd, branch) {
13258
13258
  try {
13259
- const { stdout } = await execFileAsync(
13259
+ const { stdout: stdout2 } = await execFileAsync(
13260
13260
  "git",
13261
13261
  ["log", "-1", "--format=%ct", branch],
13262
13262
  { cwd }
13263
13263
  );
13264
- const timestamp = Number(stdout.trim());
13264
+ const timestamp = Number(stdout2.trim());
13265
13265
  return Number.isFinite(timestamp) ? timestamp : null;
13266
13266
  } catch {
13267
13267
  return null;
@@ -13404,14 +13404,14 @@ function findOptionalPorcelainValue(block, key) {
13404
13404
 
13405
13405
  // src/shell-handoff.ts
13406
13406
  import { writeFile as writeFile3 } from "node:fs/promises";
13407
- async function writeShellOutput(envVar, value, stdout) {
13407
+ async function writeShellOutput(envVar, value, stdout2) {
13408
13408
  const output = `${value}
13409
13409
  `;
13410
13410
  if (process.env[envVar]) {
13411
13411
  await writeFile3(process.env[envVar], output, "utf8");
13412
13412
  return;
13413
13413
  }
13414
- stdout(output);
13414
+ stdout2(output);
13415
13415
  }
13416
13416
 
13417
13417
  // src/back.ts
@@ -13820,62 +13820,7 @@ var dD = class extends x {
13820
13820
  });
13821
13821
  }
13822
13822
  };
13823
- var mD = Object.defineProperty;
13824
- var bD = (e2, u2, t) => u2 in e2 ? mD(e2, u2, { enumerable: true, configurable: true, writable: true, value: t }) : e2[u2] = t;
13825
- var Z = (e2, u2, t) => (bD(e2, typeof u2 != "symbol" ? u2 + "" : u2, t), t);
13826
- var q = (e2, u2, t) => {
13827
- if (!u2.has(e2)) throw TypeError("Cannot " + t);
13828
- };
13829
- var T = (e2, u2, t) => (q(e2, u2, "read from private field"), t ? t.call(e2) : u2.get(e2));
13830
- var wD = (e2, u2, t) => {
13831
- if (u2.has(e2)) throw TypeError("Cannot add the same private member more than once");
13832
- u2 instanceof WeakSet ? u2.add(e2) : u2.set(e2, t);
13833
- };
13834
- var yD = (e2, u2, t, F2) => (q(e2, u2, "write to private field"), F2 ? F2.call(e2, t) : u2.set(e2, t), t);
13835
13823
  var A;
13836
- var _D = class extends x {
13837
- constructor(u2) {
13838
- super(u2, false), Z(this, "options"), Z(this, "cursor", 0), wD(this, A, void 0);
13839
- const { options: t } = u2;
13840
- yD(this, A, u2.selectableGroups !== false), this.options = Object.entries(t).flatMap(([F2, s]) => [{ value: F2, group: true, label: F2 }, ...s.map((i) => ({ ...i, group: F2 }))]), this.value = [...u2.initialValues ?? []], this.cursor = Math.max(this.options.findIndex(({ value: F2 }) => F2 === u2.cursorAt), T(this, A) ? 0 : 1), this.on("cursor", (F2) => {
13841
- switch (F2) {
13842
- case "left":
13843
- case "up": {
13844
- this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
13845
- const s = this.options[this.cursor]?.group === true;
13846
- !T(this, A) && s && (this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1);
13847
- break;
13848
- }
13849
- case "down":
13850
- case "right": {
13851
- this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
13852
- const s = this.options[this.cursor]?.group === true;
13853
- !T(this, A) && s && (this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1);
13854
- break;
13855
- }
13856
- case "space":
13857
- this.toggleValue();
13858
- break;
13859
- }
13860
- });
13861
- }
13862
- getGroupItems(u2) {
13863
- return this.options.filter((t) => t.group === u2);
13864
- }
13865
- isGroupSelected(u2) {
13866
- return this.getGroupItems(u2).every((t) => this.value.includes(t.value));
13867
- }
13868
- toggleValue() {
13869
- const u2 = this.options[this.cursor];
13870
- if (u2.group === true) {
13871
- const t = u2.value, F2 = this.getGroupItems(t);
13872
- this.isGroupSelected(t) ? this.value = this.value.filter((s) => F2.findIndex((i) => i.value === s) === -1) : this.value = [...this.value, ...F2.map((s) => s.value)], this.value = Array.from(new Set(this.value));
13873
- } else {
13874
- const t = this.value.includes(u2.value);
13875
- this.value = t ? this.value.filter((F2) => F2 !== u2.value) : [...this.value, u2.value];
13876
- }
13877
- }
13878
- };
13879
13824
  A = /* @__PURE__ */ new WeakMap();
13880
13825
  var OD = Object.defineProperty;
13881
13826
  var PD = (e2, u2, t) => u2 in e2 ? OD(e2, u2, { enumerable: true, configurable: true, writable: true, value: t }) : e2[u2] = t;
@@ -13939,14 +13884,14 @@ var d2 = u("\u2514", "\u2014");
13939
13884
  var k2 = u("\u25CF", ">");
13940
13885
  var P2 = u("\u25CB", " ");
13941
13886
  var A2 = u("\u25FB", "[\u2022]");
13942
- var T2 = u("\u25FC", "[+]");
13887
+ var T = u("\u25FC", "[+]");
13943
13888
  var F = u("\u25FB", "[ ]");
13944
13889
  var $e = u("\u25AA", "\u2022");
13945
13890
  var _2 = u("\u2500", "-");
13946
13891
  var me = u("\u256E", "+");
13947
13892
  var de = u("\u251C", "+");
13948
13893
  var pe = u("\u256F", "+");
13949
- var q2 = u("\u25CF", "\u2022");
13894
+ var q = u("\u25CF", "\u2022");
13950
13895
  var D = u("\u25C6", "*");
13951
13896
  var U = u("\u25B2", "!");
13952
13897
  var K2 = u("\u25A0", "x");
@@ -14045,60 +13990,6 @@ ${import_picocolors2.default.cyan(d2)}
14045
13990
  }
14046
13991
  } }).prompt();
14047
13992
  };
14048
- var be = (t) => {
14049
- const { selectableGroups: n = true } = t, r2 = (i, s, c = []) => {
14050
- const a = i.label ?? String(i.value), l2 = typeof i.group == "string", $2 = l2 && (c[c.indexOf(i) + 1] ?? { group: true }), g = l2 && $2.group === true, p2 = l2 ? n ? `${g ? d2 : o} ` : " " : "";
14051
- if (s === "active") return `${import_picocolors2.default.dim(p2)}${import_picocolors2.default.cyan(A2)} ${a} ${i.hint ? import_picocolors2.default.dim(`(${i.hint})`) : ""}`;
14052
- if (s === "group-active") return `${p2}${import_picocolors2.default.cyan(A2)} ${import_picocolors2.default.dim(a)}`;
14053
- if (s === "group-active-selected") return `${p2}${import_picocolors2.default.green(T2)} ${import_picocolors2.default.dim(a)}`;
14054
- if (s === "selected") {
14055
- const f = l2 || n ? import_picocolors2.default.green(T2) : "";
14056
- return `${import_picocolors2.default.dim(p2)}${f} ${import_picocolors2.default.dim(a)} ${i.hint ? import_picocolors2.default.dim(`(${i.hint})`) : ""}`;
14057
- }
14058
- if (s === "cancelled") return `${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(a))}`;
14059
- if (s === "active-selected") return `${import_picocolors2.default.dim(p2)}${import_picocolors2.default.green(T2)} ${a} ${i.hint ? import_picocolors2.default.dim(`(${i.hint})`) : ""}`;
14060
- if (s === "submitted") return `${import_picocolors2.default.dim(a)}`;
14061
- const v2 = l2 || n ? import_picocolors2.default.dim(F) : "";
14062
- return `${import_picocolors2.default.dim(p2)}${v2} ${import_picocolors2.default.dim(a)}`;
14063
- };
14064
- return new _D({ options: t.options, initialValues: t.initialValues, required: t.required ?? true, cursorAt: t.cursorAt, selectableGroups: n, validate(i) {
14065
- if (this.required && i.length === 0) return `Please select at least one option.
14066
- ${import_picocolors2.default.reset(import_picocolors2.default.dim(`Press ${import_picocolors2.default.gray(import_picocolors2.default.bgWhite(import_picocolors2.default.inverse(" space ")))} to select, ${import_picocolors2.default.gray(import_picocolors2.default.bgWhite(import_picocolors2.default.inverse(" enter ")))} to submit`))}`;
14067
- }, render() {
14068
- const i = `${import_picocolors2.default.gray(o)}
14069
- ${b2(this.state)} ${t.message}
14070
- `;
14071
- switch (this.state) {
14072
- case "submit":
14073
- return `${i}${import_picocolors2.default.gray(o)} ${this.options.filter(({ value: s }) => this.value.includes(s)).map((s) => r2(s, "submitted")).join(import_picocolors2.default.dim(", "))}`;
14074
- case "cancel": {
14075
- const s = this.options.filter(({ value: c }) => this.value.includes(c)).map((c) => r2(c, "cancelled")).join(import_picocolors2.default.dim(", "));
14076
- return `${i}${import_picocolors2.default.gray(o)} ${s.trim() ? `${s}
14077
- ${import_picocolors2.default.gray(o)}` : ""}`;
14078
- }
14079
- case "error": {
14080
- const s = this.error.split(`
14081
- `).map((c, a) => a === 0 ? `${import_picocolors2.default.yellow(d2)} ${import_picocolors2.default.yellow(c)}` : ` ${c}`).join(`
14082
- `);
14083
- return `${i}${import_picocolors2.default.yellow(o)} ${this.options.map((c, a, l2) => {
14084
- const $2 = this.value.includes(c.value) || c.group === true && this.isGroupSelected(`${c.value}`), g = a === this.cursor;
14085
- return !g && typeof c.group == "string" && this.options[this.cursor].value === c.group ? r2(c, $2 ? "group-active-selected" : "group-active", l2) : g && $2 ? r2(c, "active-selected", l2) : $2 ? r2(c, "selected", l2) : r2(c, g ? "active" : "inactive", l2);
14086
- }).join(`
14087
- ${import_picocolors2.default.yellow(o)} `)}
14088
- ${s}
14089
- `;
14090
- }
14091
- default:
14092
- return `${i}${import_picocolors2.default.cyan(o)} ${this.options.map((s, c, a) => {
14093
- const l2 = this.value.includes(s.value) || s.group === true && this.isGroupSelected(`${s.value}`), $2 = c === this.cursor;
14094
- return !$2 && typeof s.group == "string" && this.options[this.cursor].value === s.group ? r2(s, l2 ? "group-active-selected" : "group-active", a) : $2 && l2 ? r2(s, "active-selected", a) : l2 ? r2(s, "selected", a) : r2(s, $2 ? "active" : "inactive", a);
14095
- }).join(`
14096
- ${import_picocolors2.default.cyan(o)} `)}
14097
- ${import_picocolors2.default.cyan(d2)}
14098
- `;
14099
- }
14100
- } }).prompt();
14101
- };
14102
13993
  var Ie = (t = "") => {
14103
13994
  process.stdout.write(`${import_picocolors2.default.gray(ue)} ${t}
14104
13995
  `);
@@ -14284,6 +14175,7 @@ function hasStderr(error) {
14284
14175
  }
14285
14176
 
14286
14177
  // src/worktree-picker.ts
14178
+ import { env as env4, platform, stdin, stdout } from "node:process";
14287
14179
  async function buildWorktreePromptEntries(sources) {
14288
14180
  const [history, infos] = await Promise.all([
14289
14181
  loadHistory(),
@@ -14325,25 +14217,25 @@ function isAmbiguousRepoOnlyQuery(matches, query) {
14325
14217
  if (matches[0]?.matchScore === 1e3) return false;
14326
14218
  return matches.filter((match) => match.source.repoName.toLowerCase() === query).length > 1;
14327
14219
  }
14328
- async function promptForSingleWorktree(message, worktrees) {
14329
- const choice = await ve({
14220
+ async function promptForSingleWorktree(message, worktrees, io = {}) {
14221
+ const choice = await runSearchablePrompt({
14222
+ entries: worktrees.map(buildSearchableWorktreeEntry),
14223
+ input: io.input,
14330
14224
  message,
14331
- options: worktrees.map((worktree) => ({
14332
- label: worktree.label,
14333
- value: worktree.path
14334
- })),
14335
- maxItems: 12
14225
+ multiple: false,
14226
+ output: io.output
14336
14227
  });
14337
- return pD(choice) ? null : choice;
14228
+ return typeof choice === "string" ? choice : null;
14338
14229
  }
14339
- async function promptForMultipleWorktrees(message, worktrees) {
14340
- const choice = await be({
14230
+ async function promptForMultipleWorktrees(message, worktrees, io = {}) {
14231
+ const choice = await runSearchablePrompt({
14232
+ entries: buildGroupedSearchableEntries(worktrees),
14233
+ input: io.input,
14341
14234
  message,
14342
- options: groupPromptEntries(worktrees),
14343
- required: true,
14344
- selectableGroups: false
14235
+ multiple: true,
14236
+ output: io.output
14345
14237
  });
14346
- return pD(choice) ? null : choice;
14238
+ return Array.isArray(choice) ? choice : null;
14347
14239
  }
14348
14240
  function compareQueryMatches(a, b3) {
14349
14241
  if (a.matchScore !== b3.matchScore) {
@@ -14356,16 +14248,625 @@ function compareQueryMatches(a, b3) {
14356
14248
  ) || a.source.worktree.path.localeCompare(b3.source.worktree.path);
14357
14249
  }
14358
14250
  function groupPromptEntries(worktrees) {
14359
- const groups = {};
14251
+ const groups = /* @__PURE__ */ new Map();
14360
14252
  for (const worktree of worktrees) {
14361
14253
  const group = worktree.group === "recent" ? "Recent worktrees" : "Other worktrees";
14362
- groups[group] ??= [];
14363
- groups[group].push({
14364
- label: worktree.label,
14365
- value: worktree.path
14254
+ const groupWorktrees = groups.get(group);
14255
+ if (groupWorktrees === void 0) {
14256
+ groups.set(group, [worktree]);
14257
+ } else {
14258
+ groupWorktrees.push(worktree);
14259
+ }
14260
+ }
14261
+ return [...groups.entries()];
14262
+ }
14263
+ function buildGroupedSearchableEntries(worktrees) {
14264
+ const entries = [];
14265
+ for (const [group, groupWorktrees] of groupPromptEntries(worktrees)) {
14266
+ entries.push({
14267
+ label: group,
14268
+ searchText: group.toLowerCase(),
14269
+ selectable: false
14366
14270
  });
14271
+ for (const worktree of groupWorktrees) {
14272
+ entries.push(buildSearchableWorktreeEntry(worktree));
14273
+ }
14274
+ }
14275
+ return entries;
14276
+ }
14277
+ function buildSearchableWorktreeEntry(worktree) {
14278
+ const metadata = worktree.metadata ?? null;
14279
+ const branch = worktree.branch ?? "(detached)";
14280
+ return {
14281
+ detail: [worktree.repoName, branch, metadata, worktree.path].filter((part) => part !== null && part.length > 0).join(" \xB7 "),
14282
+ label: worktree.label,
14283
+ searchText: buildPromptSearchText(worktree),
14284
+ value: worktree.path,
14285
+ worktree: {
14286
+ branch,
14287
+ metadata,
14288
+ path: worktree.path,
14289
+ repoName: worktree.repoName
14290
+ }
14291
+ };
14292
+ }
14293
+ async function runSearchablePrompt(options) {
14294
+ const input = options.input ?? stdin;
14295
+ const output = options.output ?? stdout;
14296
+ if (!input.isTTY) {
14297
+ return null;
14298
+ }
14299
+ const prompt = new SearchablePrompt(options, input, output);
14300
+ const value = await prompt.run();
14301
+ return pD(value) ? null : value;
14302
+ }
14303
+ var SearchablePrompt = class {
14304
+ constructor(options, input, output) {
14305
+ this.options = options;
14306
+ this.output = output;
14307
+ this.cursor = this.firstSelectableIndex();
14308
+ const owner = this;
14309
+ this.prompt = new WorktreeCorePrompt(this, {
14310
+ input,
14311
+ output,
14312
+ render: function renderWorktreePrompt() {
14313
+ return owner.render(this.state, this.error);
14314
+ }
14315
+ });
14316
+ this.syncValue();
14317
+ }
14318
+ cursor = 0;
14319
+ query = "";
14320
+ searchActive = false;
14321
+ selected = /* @__PURE__ */ new Set();
14322
+ prompt;
14323
+ run() {
14324
+ return this.prompt.prompt();
14325
+ }
14326
+ handleKeypress(prompt, character, key) {
14327
+ if (prompt.state === "error") {
14328
+ prompt.state = "active";
14329
+ prompt.error = "";
14330
+ }
14331
+ const action = resolvePromptAction(character, key);
14332
+ if (action === "cancel") {
14333
+ this.cancel(prompt);
14334
+ return;
14335
+ }
14336
+ if (action === "escape") {
14337
+ this.handleEscapeKey(prompt);
14338
+ return;
14339
+ }
14340
+ if (action === "enter") {
14341
+ this.submit(prompt);
14342
+ return;
14343
+ }
14344
+ if (this.searchActive && this.handleSearchKey(character, key?.name)) {
14345
+ this.syncValue();
14346
+ renderPrompt(prompt);
14347
+ return;
14348
+ }
14349
+ if (character === "/" && !this.searchActive) {
14350
+ this.searchActive = true;
14351
+ this.query = "";
14352
+ this.cursor = this.firstSelectableIndex();
14353
+ this.syncValue();
14354
+ renderPrompt(prompt);
14355
+ return;
14356
+ }
14357
+ this.handleNavigationKey(character, action);
14358
+ this.syncValue();
14359
+ renderPrompt(prompt);
14360
+ }
14361
+ handleEscapeKey(prompt) {
14362
+ if (this.searchActive) {
14363
+ this.searchActive = false;
14364
+ this.query = "";
14365
+ this.cursor = this.firstSelectableIndex();
14366
+ this.syncValue();
14367
+ renderPrompt(prompt);
14368
+ return;
14369
+ }
14370
+ this.cancel(prompt);
14371
+ }
14372
+ cancel(prompt) {
14373
+ prompt.state = "cancel";
14374
+ renderPrompt(prompt);
14375
+ closePrompt(prompt);
14376
+ }
14377
+ handleSearchKey(character, keyName) {
14378
+ if (keyName === "space" || character === " ") {
14379
+ return false;
14380
+ }
14381
+ if (keyName === "backspace" || keyName === "delete") {
14382
+ this.query = this.query.slice(0, -1);
14383
+ this.cursor = this.firstSelectableIndex();
14384
+ return true;
14385
+ }
14386
+ if (isPrintableSearchCharacter(character)) {
14387
+ this.query += character;
14388
+ this.cursor = this.firstSelectableIndex();
14389
+ return true;
14390
+ }
14391
+ return false;
14392
+ }
14393
+ handleNavigationKey(character, action) {
14394
+ switch (action) {
14395
+ case "up":
14396
+ this.moveCursor(-1);
14397
+ return;
14398
+ case "down":
14399
+ this.moveCursor(1);
14400
+ return;
14401
+ case "space":
14402
+ this.toggleSelection();
14403
+ return;
14404
+ }
14405
+ switch (character) {
14406
+ case "k":
14407
+ this.moveCursor(-1);
14408
+ return;
14409
+ case "j":
14410
+ this.moveCursor(1);
14411
+ return;
14412
+ case " ":
14413
+ this.toggleSelection();
14414
+ return;
14415
+ }
14416
+ }
14417
+ moveCursor(direction) {
14418
+ const entries = this.visibleEntries();
14419
+ if (entries.length === 0) return;
14420
+ let nextCursor = this.cursor;
14421
+ for (let index = 0; index < entries.length; index += 1) {
14422
+ nextCursor = wrapIndex(nextCursor + direction, entries.length);
14423
+ if (isSelectableEntry(entries[nextCursor])) {
14424
+ this.cursor = nextCursor;
14425
+ return;
14426
+ }
14427
+ }
14428
+ }
14429
+ submit(prompt) {
14430
+ const entry = this.visibleEntries()[this.cursor];
14431
+ if (!this.options.multiple) {
14432
+ prompt.value = isSelectableEntry(entry) ? entry.value : null;
14433
+ prompt.state = "submit";
14434
+ renderPrompt(prompt);
14435
+ closePrompt(prompt);
14436
+ return;
14437
+ }
14438
+ if (this.selected.size === 0) {
14439
+ prompt.error = "Please select at least one option.";
14440
+ prompt.state = "error";
14441
+ renderPrompt(prompt);
14442
+ return;
14443
+ }
14444
+ prompt.value = [...this.selected];
14445
+ prompt.state = "submit";
14446
+ renderPrompt(prompt);
14447
+ closePrompt(prompt);
14448
+ }
14449
+ toggleSelection() {
14450
+ if (!this.options.multiple) return;
14451
+ const entry = this.visibleEntries()[this.cursor];
14452
+ if (!isSelectableEntry(entry)) return;
14453
+ if (this.selected.has(entry.value)) {
14454
+ this.selected.delete(entry.value);
14455
+ return;
14456
+ }
14457
+ this.selected.add(entry.value);
14458
+ }
14459
+ render(state, error) {
14460
+ const entries = this.visibleEntries();
14461
+ const visibleEntries = windowPromptEntries(
14462
+ entries,
14463
+ this.cursor,
14464
+ this.maxItems()
14465
+ );
14466
+ const glyphs = promptGlyphs();
14467
+ const colors = promptColors();
14468
+ const frame = promptFrameColor(state, colors);
14469
+ const lines = [
14470
+ colors.bar(glyphs.bar),
14471
+ this.renderTitle(state, glyphs, colors),
14472
+ `${frame(glyphs.bar)} ${this.renderSearchHint(colors)}`,
14473
+ frame(glyphs.bar)
14474
+ ];
14475
+ if (state === "error" && error.length > 0) {
14476
+ lines.push(`${colors.errorBar(glyphs.bar)} ${colors.error(error)}`);
14477
+ lines.push(frame(glyphs.bar));
14478
+ }
14479
+ lines.push(
14480
+ ...this.renderEntries(entries, visibleEntries, glyphs, colors, frame)
14481
+ );
14482
+ lines.push(frame(glyphs.bar));
14483
+ const preview = this.activePreview(entries, colors);
14484
+ if (preview !== null) {
14485
+ lines.push(`${frame(glyphs.bar)} ${preview}`);
14486
+ lines.push(frame(glyphs.bar));
14487
+ }
14488
+ const visibleWorktreeCount = entries.filter(isSelectableEntry).length;
14489
+ const footer = this.footerText(visibleWorktreeCount, colors);
14490
+ if (footer.length > 0) {
14491
+ lines.push(`${frame(glyphs.corner)} ${footer}`);
14492
+ }
14493
+ return `${lines.join("\n")}
14494
+ `;
14367
14495
  }
14368
- return groups;
14496
+ renderTitle(state, glyphs, colors) {
14497
+ const symbol = colors.symbol(promptSymbol(state, glyphs), state);
14498
+ const maxTitleLength = Math.max(8, this.columns() - 3);
14499
+ if (!this.searchActive) {
14500
+ return `${symbol} ${middleEllipsize(this.options.message, maxTitleLength)}`;
14501
+ }
14502
+ const search = ` /${this.query}`;
14503
+ const maxSearchLength = Math.min(
14504
+ terminalWidth(search),
14505
+ Math.floor(maxTitleLength / 2)
14506
+ );
14507
+ const message = middleEllipsize(
14508
+ this.options.message,
14509
+ Math.max(1, maxTitleLength - maxSearchLength)
14510
+ );
14511
+ const visibleSearch = middleEllipsize(
14512
+ search,
14513
+ Math.max(1, maxTitleLength - terminalWidth(message))
14514
+ );
14515
+ return `${symbol} ${message}${colors.search(visibleSearch)}`;
14516
+ }
14517
+ renderSearchHint(colors) {
14518
+ if (this.searchActive) {
14519
+ return `${colors.hint("type to filter")} ${colors.hint("\xB7")} ${colors.key("esc")} ${colors.hint("clears")}`;
14520
+ }
14521
+ return `${colors.hint("press ")}${colors.key("/")}${colors.hint(" to search")}`;
14522
+ }
14523
+ renderEntries(entries, visibleEntries, glyphs, colors, frame) {
14524
+ if (entries.length === 0) {
14525
+ return [`${frame(glyphs.bar)} ${colors.hint("No matching worktrees")}`];
14526
+ }
14527
+ return visibleEntries.map(
14528
+ (entry) => entry === "ellipsis" ? `${frame(glyphs.bar)} ${colors.hint("...")}` : this.renderEntry(entries, entry, glyphs, colors, frame)
14529
+ );
14530
+ }
14531
+ renderEntry(entries, entry, glyphs, colors, frame) {
14532
+ const active = entries[this.cursor] === entry;
14533
+ const selected = isSelectableEntry(entry) && this.selected.has(entry.value);
14534
+ const prefix = this.entryPrefix(entry, active, selected, glyphs);
14535
+ const label = this.entryLabel(entry, prefix);
14536
+ const line = isSelectableEntry(entry) ? active ? label : colors.hint(label) : colors.hint(label);
14537
+ const marker = selected ? colors.selected(prefix) : active ? this.options.multiple ? colors.option(prefix) : colors.selected(prefix) : colors.hint(prefix);
14538
+ return `${frame(glyphs.bar)} ${marker} ${line}`;
14539
+ }
14540
+ activePreview(entries, colors) {
14541
+ const entry = entries[this.cursor];
14542
+ if (!isSelectableEntry(entry) || entry.detail === void 0) return null;
14543
+ const label = "current";
14544
+ const separator = " ";
14545
+ const width = this.previewWidth();
14546
+ const prefixWidth = terminalWidth(label) + terminalWidth(separator);
14547
+ if (width <= prefixWidth) return colors.key(middleEllipsize(label, width));
14548
+ const detail = middleEllipsize(entry.detail, width - prefixWidth);
14549
+ return `${colors.key(label)}${colors.hint(separator)}${colors.hint(detail)}`;
14550
+ }
14551
+ entryLabel(entry, prefix) {
14552
+ const width = this.labelWidth(prefix);
14553
+ if (entry.worktree === void 0) {
14554
+ return middleEllipsize(entry.label, width);
14555
+ }
14556
+ return fitPromptPieces(
14557
+ [
14558
+ {
14559
+ ellipsize: middleEllipsize,
14560
+ max: 18,
14561
+ min: 6,
14562
+ value: entry.worktree.repoName
14563
+ },
14564
+ {
14565
+ ellipsize: middleEllipsize,
14566
+ max: 32,
14567
+ min: 8,
14568
+ value: entry.worktree.branch
14569
+ },
14570
+ ...entry.worktree.metadata === null ? [] : [
14571
+ {
14572
+ ellipsize: middleEllipsize,
14573
+ max: 30,
14574
+ min: 10,
14575
+ value: entry.worktree.metadata
14576
+ }
14577
+ ],
14578
+ {
14579
+ ellipsize: startEllipsize,
14580
+ max: 36,
14581
+ min: 12,
14582
+ value: entry.worktree.path
14583
+ }
14584
+ ],
14585
+ width
14586
+ );
14587
+ }
14588
+ labelWidth(prefix) {
14589
+ return Math.max(8, this.columns() - terminalWidth(prefix) - 4);
14590
+ }
14591
+ previewWidth() {
14592
+ return Math.max(8, this.columns() - 3);
14593
+ }
14594
+ entryPrefix(entry, active, selected, glyphs) {
14595
+ if (!isSelectableEntry(entry)) {
14596
+ return active ? glyphs.active : " ";
14597
+ }
14598
+ if (!this.options.multiple) {
14599
+ return active ? glyphs.active : glyphs.inactive;
14600
+ }
14601
+ if (active && selected) return glyphs.checked;
14602
+ if (active) return glyphs.uncheckedActive;
14603
+ return selected ? glyphs.checked : glyphs.unchecked;
14604
+ }
14605
+ footerText(visibleCount, colors) {
14606
+ if (!this.options.multiple) return "";
14607
+ return [
14608
+ `${colors.key("space")} ${colors.hint("select")}`,
14609
+ `${colors.selected(String(this.selected.size))} ${colors.hint("selected")}`,
14610
+ colors.hint(`${visibleCount} shown`)
14611
+ ].join(colors.hint(" \xB7 "));
14612
+ }
14613
+ firstSelectableIndex() {
14614
+ const index = this.visibleEntries().findIndex(isSelectableEntry);
14615
+ return index === -1 ? 0 : index;
14616
+ }
14617
+ visibleEntries() {
14618
+ const query = normalizeQuery(this.query);
14619
+ if (query === null) {
14620
+ return this.options.entries;
14621
+ }
14622
+ return filterSearchablePromptEntries(this.options.entries, query);
14623
+ }
14624
+ maxItems() {
14625
+ const rows = this.output.rows ?? 16;
14626
+ return Math.max(5, Math.min(12, rows - 8));
14627
+ }
14628
+ columns() {
14629
+ return Math.max(20, this.output.columns ?? 80);
14630
+ }
14631
+ syncValue() {
14632
+ if (this.options.multiple) {
14633
+ this.prompt.value = [...this.selected];
14634
+ return;
14635
+ }
14636
+ const entry = this.visibleEntries()[this.cursor];
14637
+ this.prompt.value = isSelectableEntry(entry) ? entry.value : null;
14638
+ }
14639
+ };
14640
+ var WorktreeCorePrompt = class extends x {
14641
+ constructor(worktreePrompt, options) {
14642
+ super(options, false);
14643
+ this.worktreePrompt = worktreePrompt;
14644
+ }
14645
+ };
14646
+ Object.defineProperty(WorktreeCorePrompt.prototype, "onKeypress", {
14647
+ value: onWorktreeKeypress,
14648
+ writable: true
14649
+ });
14650
+ function renderPrompt(prompt) {
14651
+ prompt.render();
14652
+ }
14653
+ function closePrompt(prompt) {
14654
+ prompt.close();
14655
+ }
14656
+ function onWorktreeKeypress(character, key) {
14657
+ this.worktreePrompt.handleKeypress(this, character, key);
14658
+ }
14659
+ function resolvePromptAction(character, key) {
14660
+ if (key?.ctrl && key.name === "c" || character === "") {
14661
+ return "cancel";
14662
+ }
14663
+ switch (key?.name) {
14664
+ case "escape":
14665
+ return "escape";
14666
+ case "return":
14667
+ return "enter";
14668
+ case "space":
14669
+ return "space";
14670
+ case "up":
14671
+ case "left":
14672
+ return "up";
14673
+ case "down":
14674
+ case "right":
14675
+ return "down";
14676
+ }
14677
+ switch (character) {
14678
+ case " ":
14679
+ return "space";
14680
+ case "k":
14681
+ case "h":
14682
+ return "up";
14683
+ case "j":
14684
+ case "l":
14685
+ return "down";
14686
+ }
14687
+ return void 0;
14688
+ }
14689
+ function promptGlyphs() {
14690
+ return supportsUnicode() ? {
14691
+ active: "\u25CF",
14692
+ bar: "\u2502",
14693
+ checked: "\u25FC",
14694
+ corner: "\u2514",
14695
+ inactive: "\u25CB",
14696
+ pending: "\u25C6",
14697
+ submitted: "\u25C7",
14698
+ unchecked: "\u25FB",
14699
+ uncheckedActive: "\u25FB"
14700
+ } : {
14701
+ active: ">",
14702
+ bar: "|",
14703
+ checked: "[x]",
14704
+ corner: "-",
14705
+ inactive: " ",
14706
+ pending: "*",
14707
+ submitted: "o",
14708
+ unchecked: "[ ]",
14709
+ uncheckedActive: "[ ]"
14710
+ };
14711
+ }
14712
+ function promptColors() {
14713
+ return {
14714
+ activeBar: cyan,
14715
+ bar: gray,
14716
+ error: yellow,
14717
+ errorBar: yellow,
14718
+ hint: dim,
14719
+ key: cyan,
14720
+ option: cyan,
14721
+ search: cyan,
14722
+ selected: green,
14723
+ symbol: (value, state) => {
14724
+ if (state === "submit") return green(value);
14725
+ if (state === "error") return yellow(value);
14726
+ if (state === "cancel") return red(value);
14727
+ return cyan(value);
14728
+ }
14729
+ };
14730
+ }
14731
+ function promptFrameColor(state, colors) {
14732
+ if (state === "error") return colors.errorBar;
14733
+ if (state === "active" || state === "initial") return colors.activeBar;
14734
+ return colors.bar;
14735
+ }
14736
+ function promptSymbol(state, glyphs) {
14737
+ return state === "submit" ? glyphs.submitted : glyphs.pending;
14738
+ }
14739
+ function cyan(value) {
14740
+ return color("\x1B[36m", "\x1B[39m", value);
14741
+ }
14742
+ function dim(value) {
14743
+ return color("\x1B[2m", "\x1B[22m", value);
14744
+ }
14745
+ function gray(value) {
14746
+ return color("\x1B[90m", "\x1B[39m", value);
14747
+ }
14748
+ function green(value) {
14749
+ return color("\x1B[32m", "\x1B[39m", value);
14750
+ }
14751
+ function red(value) {
14752
+ return color("\x1B[31m", "\x1B[39m", value);
14753
+ }
14754
+ function yellow(value) {
14755
+ return color("\x1B[33m", "\x1B[39m", value);
14756
+ }
14757
+ function color(open, close, value) {
14758
+ if (env4.NO_COLOR !== void 0) return value;
14759
+ return `${open}${value}${close}`;
14760
+ }
14761
+ function supportsUnicode() {
14762
+ if (platform !== "win32") {
14763
+ return env4.TERM !== "linux";
14764
+ }
14765
+ return Boolean(
14766
+ env4.CI || env4.WT_SESSION || env4.TERMINUS_SUBLIME || env4.ConEmuTask === "{cmd::Cmder}" || env4.TERM_PROGRAM === "Terminus-Sublime" || env4.TERM_PROGRAM === "vscode" || env4.TERM === "xterm-256color" || env4.TERM === "alacritty" || env4.TERMINAL_EMULATOR === "JetBrains-JediTerm"
14767
+ );
14768
+ }
14769
+ function isPrintableSearchCharacter(character) {
14770
+ return typeof character === "string" && character.length === 1 && character >= " " && character !== "\x7F";
14771
+ }
14772
+ function wrapIndex(index, length) {
14773
+ return (index + length) % length;
14774
+ }
14775
+ function windowPromptEntries(entries, cursor, maxItems) {
14776
+ if (entries.length <= maxItems) {
14777
+ return entries;
14778
+ }
14779
+ const activeIndex = Math.min(Math.max(cursor, 0), entries.length - 1);
14780
+ const start = Math.max(
14781
+ 0,
14782
+ Math.min(activeIndex - 2, entries.length - maxItems)
14783
+ );
14784
+ const window = entries.slice(start, start + maxItems);
14785
+ if (start > 0) {
14786
+ window[0] = "ellipsis";
14787
+ }
14788
+ if (start + maxItems < entries.length) {
14789
+ window[window.length - 1] = "ellipsis";
14790
+ }
14791
+ return window;
14792
+ }
14793
+ function fitPromptPieces(pieces, width) {
14794
+ const separator = " \xB7 ";
14795
+ let visiblePieces = pieces.filter((piece) => piece.value.length > 0);
14796
+ let available = width - terminalWidth(separator) * Math.max(0, visiblePieces.length - 1);
14797
+ while (visiblePieces.length > 1 && available < minimumPieceLength(visiblePieces)) {
14798
+ const removableIndex = visiblePieces.length === 4 ? 2 : visiblePieces.length - 2;
14799
+ visiblePieces = visiblePieces.filter(
14800
+ (_3, index) => index !== removableIndex
14801
+ );
14802
+ available = width - terminalWidth(separator) * Math.max(0, visiblePieces.length - 1);
14803
+ }
14804
+ if (available <= 0 || available < minimumPieceLength(visiblePieces)) {
14805
+ return middleEllipsize(
14806
+ visiblePieces.map((piece) => piece.value).join(separator),
14807
+ width
14808
+ );
14809
+ }
14810
+ const lengths = visiblePieces.map(
14811
+ (piece) => Math.min(terminalWidth(piece.value), piece.max)
14812
+ );
14813
+ while (sum(lengths) > available) {
14814
+ const index = largestShrinkablePieceIndex(visiblePieces, lengths);
14815
+ if (index === -1) break;
14816
+ lengths[index] -= 1;
14817
+ }
14818
+ return visiblePieces.map((piece, index) => piece.ellipsize(piece.value, lengths[index])).join(separator);
14819
+ }
14820
+ function minimumPieceLength(pieces) {
14821
+ return sum(
14822
+ pieces.map((piece) => Math.min(terminalWidth(piece.value), piece.min))
14823
+ );
14824
+ }
14825
+ function largestShrinkablePieceIndex(pieces, lengths) {
14826
+ let candidate = -1;
14827
+ for (let index = 0; index < pieces.length; index += 1) {
14828
+ if (lengths[index] <= Math.min(terminalWidth(pieces[index].value), pieces[index].min)) {
14829
+ continue;
14830
+ }
14831
+ if (candidate === -1 || lengths[index] > lengths[candidate]) {
14832
+ candidate = index;
14833
+ }
14834
+ }
14835
+ return candidate;
14836
+ }
14837
+ function sum(values) {
14838
+ return values.reduce((total, value) => total + value, 0);
14839
+ }
14840
+ function filterSearchablePromptEntries(entries, query) {
14841
+ const filtered = [];
14842
+ let pendingGroup = null;
14843
+ for (const entry of entries) {
14844
+ if (!isSelectableEntry(entry)) {
14845
+ pendingGroup = entry;
14846
+ continue;
14847
+ }
14848
+ if (!entry.searchText.includes(query)) {
14849
+ continue;
14850
+ }
14851
+ if (pendingGroup !== null) {
14852
+ filtered.push(pendingGroup);
14853
+ pendingGroup = null;
14854
+ }
14855
+ filtered.push(entry);
14856
+ }
14857
+ return filtered;
14858
+ }
14859
+ function isSelectableEntry(entry) {
14860
+ return entry !== void 0 && entry.selectable !== false && typeof entry.value === "string";
14861
+ }
14862
+ function buildPromptSearchText(worktree) {
14863
+ return [
14864
+ worktree.repoName,
14865
+ worktree.branch ?? "detached",
14866
+ worktree.path,
14867
+ worktree.label,
14868
+ `${worktree.repoName}/${worktree.branch ?? "detached"}`
14869
+ ].join(" ").toLowerCase();
14369
14870
  }
14370
14871
  function buildWorktreePromptEntry(source, info, lastUsedTimestamp, now) {
14371
14872
  const lastWorkedTimestamp = info.lastCommitTimestamp === null ? null : info.lastCommitTimestamp * 1e3;
@@ -14379,12 +14880,15 @@ function buildWorktreePromptEntry(source, info, lastUsedTimestamp, now) {
14379
14880
  now
14380
14881
  );
14381
14882
  const status = badges.length > 0 ? badges.map((badge) => `[${badge}]`).join(" ") : null;
14883
+ const metadataParts = [status, recency].filter(
14884
+ (part) => part !== null && part.length > 0
14885
+ );
14886
+ const metadata = metadataParts.length === 0 ? null : metadataParts.join(" \xB7 ");
14382
14887
  const path9 = middleEllipsize(source.worktree.path, 76);
14383
14888
  const label = [
14384
14889
  middleEllipsize(source.repoName, 22),
14385
14890
  middleEllipsize(branch, 34),
14386
- status,
14387
- recency,
14891
+ metadata,
14388
14892
  path9
14389
14893
  ].filter((part) => part !== null && part.length > 0).join(" \xB7 ");
14390
14894
  return {
@@ -14392,6 +14896,7 @@ function buildWorktreePromptEntry(source, info, lastUsedTimestamp, now) {
14392
14896
  group: lastUsedTimestamp !== null ? "recent" : "other",
14393
14897
  label,
14394
14898
  lastActivityTimestamp,
14899
+ metadata,
14395
14900
  repoName: source.repoName
14396
14901
  };
14397
14902
  }
@@ -14490,16 +14995,58 @@ function scoreWorktreeMatch(entry, query) {
14490
14995
  return buildSearchText(entry.repoName, entry).includes(query) ? 1 : null;
14491
14996
  }
14492
14997
  function middleEllipsize(value, maxLength) {
14493
- if (value.length <= maxLength) {
14998
+ if (terminalWidth(value) <= maxLength) {
14494
14999
  return value;
14495
15000
  }
14496
15001
  if (maxLength <= 1) {
14497
15002
  return "\u2026";
14498
15003
  }
14499
15004
  const keep = maxLength - 1;
14500
- const start = Math.ceil(keep / 2);
14501
- const end = Math.floor(keep / 2);
14502
- return `${value.slice(0, start)}\u2026${value.slice(value.length - end)}`;
15005
+ const start = takeTerminalColumns(value, Math.ceil(keep / 2), "start");
15006
+ const end = takeTerminalColumns(value, Math.floor(keep / 2), "end");
15007
+ return `${start}\u2026${end}`;
15008
+ }
15009
+ function startEllipsize(value, maxLength) {
15010
+ if (terminalWidth(value) <= maxLength) {
15011
+ return value;
15012
+ }
15013
+ if (maxLength <= 1) {
15014
+ return "\u2026";
15015
+ }
15016
+ return `\u2026${takeTerminalColumns(value, maxLength - 1, "end")}`;
15017
+ }
15018
+ function takeTerminalColumns(value, maxWidth, direction) {
15019
+ const characters = direction === "start" ? Array.from(value) : Array.from(value).reverse();
15020
+ const kept = [];
15021
+ let width = 0;
15022
+ for (const character of characters) {
15023
+ const characterWidth = terminalWidth(character);
15024
+ if (width + characterWidth > maxWidth) break;
15025
+ kept.push(character);
15026
+ width += characterWidth;
15027
+ }
15028
+ return direction === "start" ? kept.join("") : kept.reverse().join("");
15029
+ }
15030
+ function terminalWidth(value) {
15031
+ let width = 0;
15032
+ for (const character of Array.from(value)) {
15033
+ width += characterTerminalWidth(character);
15034
+ }
15035
+ return width;
15036
+ }
15037
+ function characterTerminalWidth(character) {
15038
+ const codePoint = character.codePointAt(0);
15039
+ if (codePoint === void 0) return 0;
15040
+ if (isZeroWidthCodePoint(codePoint) || new RegExp("\\p{Mark}", "u").test(character)) {
15041
+ return 0;
15042
+ }
15043
+ return isWideCodePoint(codePoint) ? 2 : 1;
15044
+ }
15045
+ function isZeroWidthCodePoint(codePoint) {
15046
+ return codePoint === 0 || codePoint === 8205 || codePoint >= 65024 && codePoint <= 65039;
15047
+ }
15048
+ function isWideCodePoint(codePoint) {
15049
+ return codePoint >= 4352 && codePoint <= 4447 || codePoint === 9001 || codePoint === 9002 || codePoint >= 11904 && codePoint <= 42191 || codePoint >= 44032 && codePoint <= 55203 || codePoint >= 63744 && codePoint <= 64255 || codePoint >= 65040 && codePoint <= 65049 || codePoint >= 65072 && codePoint <= 65135 || codePoint >= 65280 && codePoint <= 65376 || codePoint >= 65504 && codePoint <= 65510 || codePoint >= 127744 && codePoint <= 129791 || codePoint >= 131072 && codePoint <= 262141;
14503
15050
  }
14504
15051
 
14505
15052
  // src/worktree-prompts.ts
@@ -15265,8 +15812,8 @@ async function runConfigCommand(options) {
15265
15812
  `Invalid config arguments: ${[options.action, options.key, options.value].filter(Boolean).join(" ")}`
15266
15813
  );
15267
15814
  }
15268
- function writeJson(stdout, value) {
15269
- stdout(`${JSON.stringify(value, null, 2)}
15815
+ function writeJson(stdout2, value) {
15816
+ stdout2(`${JSON.stringify(value, null, 2)}
15270
15817
  `);
15271
15818
  }
15272
15819
 
@@ -16068,8 +16615,8 @@ async function localBranchExists(repoRoot, branchName) {
16068
16615
  return false;
16069
16616
  }
16070
16617
  }
16071
- async function writeOutput(worktreePath, stdout) {
16072
- await writeShellOutput(NEW_OUTPUT_FILE_ENV, worktreePath, stdout);
16618
+ async function writeOutput(worktreePath, stdout2) {
16619
+ await writeShellOutput(NEW_OUTPUT_FILE_ENV, worktreePath, stdout2);
16073
16620
  }
16074
16621
  function isNotRegisteredWorktreeError(error) {
16075
16622
  const stderr = hasExecStderr(error) ? error.stderr : String(error);
@@ -17272,8 +17819,8 @@ function sourceRefForForge(forge, prNumber) {
17272
17819
  return `refs/merge-requests/${prNumber}/head`;
17273
17820
  }
17274
17821
  }
17275
- async function writeOutput2(worktreePath, stdout) {
17276
- await writeShellOutput(PR_OUTPUT_FILE_ENV, worktreePath, stdout);
17822
+ async function writeOutput2(worktreePath, stdout2) {
17823
+ await writeShellOutput(PR_OUTPUT_FILE_ENV, worktreePath, stdout2);
17277
17824
  }
17278
17825
 
17279
17826
  // src/remove.ts
@@ -17436,8 +17983,8 @@ async function defaultConfirmRemoval2(worktree) {
17436
17983
  });
17437
17984
  return !pD(choice) && choice;
17438
17985
  }
17439
- async function writeOutput3(repoRoot, stdout) {
17440
- await writeShellOutput(REMOVE_OUTPUT_FILE_ENV, repoRoot, stdout);
17986
+ async function writeOutput3(repoRoot, stdout2) {
17987
+ await writeShellOutput(REMOVE_OUTPUT_FILE_ENV, repoRoot, stdout2);
17441
17988
  }
17442
17989
  function emitError2(options, message) {
17443
17990
  if (options.json) {
@@ -17810,17 +18357,17 @@ function readSyncFiles(config) {
17810
18357
  if (!Array.isArray(syncFiles2)) return [];
17811
18358
  return syncFiles2.filter((item) => typeof item === "string");
17812
18359
  }
17813
- function writeSyncFiles(stdout, files, json) {
18360
+ function writeSyncFiles(stdout2, files, json) {
17814
18361
  if (json) {
17815
- stdout(`${JSON.stringify(files, null, 2)}
18362
+ stdout2(`${JSON.stringify(files, null, 2)}
17816
18363
  `);
17817
18364
  return;
17818
18365
  }
17819
18366
  if (files.length === 0) {
17820
- stdout("No sync files configured for this repo.\n");
18367
+ stdout2("No sync files configured for this repo.\n");
17821
18368
  return;
17822
18369
  }
17823
- stdout(`${files.join("\n")}
18370
+ stdout2(`${files.join("\n")}
17824
18371
  `);
17825
18372
  }
17826
18373
  function validatePaths(paths, options) {
@@ -17910,11 +18457,11 @@ async function runCli(argv, options = {}) {
17910
18457
  maybeRegisterCurrentRepo(options.cwd ?? process.cwd());
17911
18458
  const program2 = createProgram();
17912
18459
  const cwd = options.cwd ?? process.cwd();
17913
- const stdout = options.stdout ?? (() => void 0);
18460
+ const stdout2 = options.stdout ?? (() => void 0);
17914
18461
  const stderr = options.stderr ?? (() => void 0);
17915
18462
  program2.configureOutput({
17916
18463
  writeErr: stderr,
17917
- writeOut: stdout
18464
+ writeOut: stdout2
17918
18465
  });
17919
18466
  program2.exitOverride();
17920
18467
  if (argv.length === 0) {
@@ -17922,7 +18469,7 @@ async function runCli(argv, options = {}) {
17922
18469
  return { exitCode: 0 };
17923
18470
  }
17924
18471
  try {
17925
- attachCommandActions(program2, { cwd, stderr, stdout });
18472
+ attachCommandActions(program2, { cwd, stderr, stdout: stdout2 });
17926
18473
  await program2.parseAsync(["node", "gji", ...argv], { from: "node" });
17927
18474
  return { exitCode: 0 };
17928
18475
  } catch (error) {