@solaqua/gji 0.7.2 → 0.8.1
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/dist/clean.js +34 -19
- package/dist/gji-bundle.mjs +846 -266
- package/dist/remove.js +2 -2
- package/dist/worktree-management.d.ts +2 -1
- package/dist/worktree-management.js +23 -7
- package/dist/worktree-picker.d.ts +14 -2
- package/dist/worktree-picker.js +723 -27
- package/man/man1/gji-back.1 +1 -1
- package/man/man1/gji-clean.1 +1 -1
- package/man/man1/gji-completion.1 +1 -1
- package/man/man1/gji-config.1 +1 -1
- package/man/man1/gji-go.1 +1 -1
- package/man/man1/gji-history.1 +1 -1
- package/man/man1/gji-init.1 +1 -1
- package/man/man1/gji-ls.1 +1 -1
- package/man/man1/gji-new.1 +1 -1
- package/man/man1/gji-open.1 +1 -1
- package/man/man1/gji-pr.1 +1 -1
- package/man/man1/gji-remove.1 +1 -1
- package/man/man1/gji-root.1 +1 -1
- package/man/man1/gji-run-hook.1 +1 -1
- package/man/man1/gji-status.1 +1 -1
- package/man/man1/gji-sync-files.1 +1 -1
- package/man/man1/gji-sync.1 +1 -1
- package/man/man1/gji-warp.1 +1 -1
- package/man/man1/gji.1 +1 -1
- package/package.json +1 -1
package/dist/gji-bundle.mjs
CHANGED
|
@@ -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
|
|
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 (
|
|
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
|
|
5040
|
-
|
|
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
|
|
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] =
|
|
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
|
|
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 (
|
|
5425
|
+
if (env5.config) addConfigFile(env5.config);
|
|
5426
5426
|
if (argv.config) addConfigFile(argv.config);
|
|
5427
5427
|
return deepExtend.apply(null, configs.concat([
|
|
5428
|
-
|
|
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
|
|
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 (
|
|
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
|
|
6427
|
-
|
|
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
|
|
6430
|
+
for (var k3 in env6) {
|
|
6431
6431
|
if (k3.indexOf(prefix) === 0)
|
|
6432
|
-
obj[k3.substring(l2)] =
|
|
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,
|
|
6538
|
+
ConfigChain.prototype.addEnv = function(prefix, env6, name) {
|
|
6539
6539
|
name = name || "env";
|
|
6540
|
-
var data = exports.env(prefix,
|
|
6541
|
-
this.sources[name] = { data, source:
|
|
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,
|
|
6634
|
-
return settingValue.replace(ENV_EXPR, replaceEnvMatch.bind(null,
|
|
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(
|
|
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(
|
|
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(
|
|
6648
|
+
function getEnvValue(env5, name) {
|
|
6649
6649
|
const matched = name.match(ENV_VALUE);
|
|
6650
6650
|
if (!matched)
|
|
6651
|
-
return
|
|
6651
|
+
return env5[name];
|
|
6652
6652
|
const [, variableName, colon, fallback] = matched;
|
|
6653
|
-
if (Object.prototype.hasOwnProperty.call(
|
|
6654
|
-
return !
|
|
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(
|
|
6975
|
-
|
|
6974
|
+
addEnv(env5) {
|
|
6975
|
+
env5 = env5 || process.env;
|
|
6976
6976
|
const conf = {};
|
|
6977
|
-
Object.keys(
|
|
6978
|
-
if (!
|
|
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 =
|
|
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
|
|
9358
|
-
var isColorSupported = !(!!
|
|
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) => (
|
|
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(
|
|
10277
|
-
if (
|
|
10278
|
-
if (
|
|
10276
|
+
value(red2, green2, blue) {
|
|
10277
|
+
if (red2 === green2 && green2 === blue) {
|
|
10278
|
+
if (red2 < 8) {
|
|
10279
10279
|
return 16;
|
|
10280
10280
|
}
|
|
10281
|
-
if (
|
|
10281
|
+
if (red2 > 248) {
|
|
10282
10282
|
return 231;
|
|
10283
10283
|
}
|
|
10284
|
-
return Math.round((
|
|
10284
|
+
return Math.round((red2 - 8) / 247 * 24) + 232;
|
|
10285
10285
|
}
|
|
10286
|
-
return 16 + 36 * Math.round(
|
|
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
|
|
10324
|
-
let
|
|
10323
|
+
let red2;
|
|
10324
|
+
let green2;
|
|
10325
10325
|
let blue;
|
|
10326
10326
|
if (code >= 232) {
|
|
10327
|
-
|
|
10328
|
-
|
|
10329
|
-
blue =
|
|
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
|
-
|
|
10334
|
-
|
|
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(
|
|
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(
|
|
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: (
|
|
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) => (
|
|
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(
|
|
12075
|
-
if (
|
|
12076
|
-
if (
|
|
12074
|
+
value(red2, green2, blue) {
|
|
12075
|
+
if (red2 === green2 && green2 === blue) {
|
|
12076
|
+
if (red2 < 8) {
|
|
12077
12077
|
return 16;
|
|
12078
12078
|
}
|
|
12079
|
-
if (
|
|
12079
|
+
if (red2 > 248) {
|
|
12080
12080
|
return 231;
|
|
12081
12081
|
}
|
|
12082
|
-
return Math.round((
|
|
12082
|
+
return Math.round((red2 - 8) / 247 * 24) + 232;
|
|
12083
12083
|
}
|
|
12084
|
-
return 16 + 36 * Math.round(
|
|
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
|
|
12122
|
-
let
|
|
12121
|
+
let red2;
|
|
12122
|
+
let green2;
|
|
12123
12123
|
let blue;
|
|
12124
12124
|
if (code >= 232) {
|
|
12125
|
-
|
|
12126
|
-
|
|
12127
|
-
blue =
|
|
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
|
-
|
|
12132
|
-
|
|
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(
|
|
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(
|
|
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: (
|
|
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:
|
|
12323
|
-
if (
|
|
12324
|
-
return
|
|
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 (
|
|
12330
|
-
return Number.parseInt(
|
|
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 = (
|
|
12558
|
-
var isColorValid = (
|
|
12559
|
-
var getColorFunction = (
|
|
12560
|
-
var getBGColorFunction = (
|
|
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
|
|
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(
|
|
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 =
|
|
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(
|
|
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,
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
`);
|
|
@@ -14236,6 +14127,7 @@ function formatRelativeAge(timestampSeconds) {
|
|
|
14236
14127
|
|
|
14237
14128
|
// src/worktree-management.ts
|
|
14238
14129
|
import { execFile as execFile2 } from "node:child_process";
|
|
14130
|
+
import { rm } from "node:fs/promises";
|
|
14239
14131
|
import { promisify as promisify3 } from "node:util";
|
|
14240
14132
|
var execFileAsync2 = promisify3(execFile2);
|
|
14241
14133
|
var GIT_ENV = { ...process.env, LC_ALL: "C" };
|
|
@@ -14256,10 +14148,24 @@ async function removeWorktree(repoRoot, worktreePath) {
|
|
|
14256
14148
|
});
|
|
14257
14149
|
}
|
|
14258
14150
|
async function forceRemoveWorktree(repoRoot, worktreePath) {
|
|
14259
|
-
|
|
14260
|
-
|
|
14261
|
-
|
|
14262
|
-
|
|
14151
|
+
try {
|
|
14152
|
+
await execFileAsync2(
|
|
14153
|
+
"git",
|
|
14154
|
+
["worktree", "remove", "--force", worktreePath],
|
|
14155
|
+
{
|
|
14156
|
+
cwd: repoRoot,
|
|
14157
|
+
env: GIT_ENV
|
|
14158
|
+
}
|
|
14159
|
+
);
|
|
14160
|
+
} catch (error) {
|
|
14161
|
+
const worktreeIsStillRegistered = (await listWorktrees(repoRoot)).some(
|
|
14162
|
+
(worktree) => worktree.path === worktreePath
|
|
14163
|
+
);
|
|
14164
|
+
if (worktreeIsStillRegistered) {
|
|
14165
|
+
throw error;
|
|
14166
|
+
}
|
|
14167
|
+
await rm(worktreePath, { force: true, recursive: true });
|
|
14168
|
+
}
|
|
14263
14169
|
}
|
|
14264
14170
|
async function deleteBranch(repoRoot, branch) {
|
|
14265
14171
|
await execFileAsync2("git", ["branch", "-d", branch], {
|
|
@@ -14273,8 +14179,14 @@ async function forceDeleteBranch(repoRoot, branch) {
|
|
|
14273
14179
|
env: GIT_ENV
|
|
14274
14180
|
});
|
|
14275
14181
|
}
|
|
14276
|
-
function
|
|
14277
|
-
|
|
14182
|
+
function isWorktreeForceRemovalError(error) {
|
|
14183
|
+
if (!hasStderr(error)) {
|
|
14184
|
+
return false;
|
|
14185
|
+
}
|
|
14186
|
+
return error.stderr.includes("contains modified or untracked files") || isWorktreeDeletionError(error);
|
|
14187
|
+
}
|
|
14188
|
+
function isWorktreeDeletionError(error) {
|
|
14189
|
+
return hasStderr(error) && error.stderr.includes("failed to delete");
|
|
14278
14190
|
}
|
|
14279
14191
|
function isBranchUnmergedError(error) {
|
|
14280
14192
|
return hasStderr(error) && error.stderr.includes("is not fully merged");
|
|
@@ -14284,6 +14196,7 @@ function hasStderr(error) {
|
|
|
14284
14196
|
}
|
|
14285
14197
|
|
|
14286
14198
|
// src/worktree-picker.ts
|
|
14199
|
+
import { env as env4, platform, stdin, stdout } from "node:process";
|
|
14287
14200
|
async function buildWorktreePromptEntries(sources) {
|
|
14288
14201
|
const [history, infos] = await Promise.all([
|
|
14289
14202
|
loadHistory(),
|
|
@@ -14325,25 +14238,25 @@ function isAmbiguousRepoOnlyQuery(matches, query) {
|
|
|
14325
14238
|
if (matches[0]?.matchScore === 1e3) return false;
|
|
14326
14239
|
return matches.filter((match) => match.source.repoName.toLowerCase() === query).length > 1;
|
|
14327
14240
|
}
|
|
14328
|
-
async function promptForSingleWorktree(message, worktrees) {
|
|
14329
|
-
const choice = await
|
|
14241
|
+
async function promptForSingleWorktree(message, worktrees, io = {}) {
|
|
14242
|
+
const choice = await runSearchablePrompt({
|
|
14243
|
+
entries: worktrees.map(buildSearchableWorktreeEntry),
|
|
14244
|
+
input: io.input,
|
|
14330
14245
|
message,
|
|
14331
|
-
|
|
14332
|
-
|
|
14333
|
-
value: worktree.path
|
|
14334
|
-
})),
|
|
14335
|
-
maxItems: 12
|
|
14246
|
+
multiple: false,
|
|
14247
|
+
output: io.output
|
|
14336
14248
|
});
|
|
14337
|
-
return
|
|
14249
|
+
return typeof choice === "string" ? choice : null;
|
|
14338
14250
|
}
|
|
14339
|
-
async function promptForMultipleWorktrees(message, worktrees) {
|
|
14340
|
-
const choice = await
|
|
14251
|
+
async function promptForMultipleWorktrees(message, worktrees, io = {}) {
|
|
14252
|
+
const choice = await runSearchablePrompt({
|
|
14253
|
+
entries: buildGroupedSearchableEntries(worktrees),
|
|
14254
|
+
input: io.input,
|
|
14341
14255
|
message,
|
|
14342
|
-
|
|
14343
|
-
|
|
14344
|
-
selectableGroups: false
|
|
14256
|
+
multiple: true,
|
|
14257
|
+
output: io.output
|
|
14345
14258
|
});
|
|
14346
|
-
return
|
|
14259
|
+
return Array.isArray(choice) ? choice : null;
|
|
14347
14260
|
}
|
|
14348
14261
|
function compareQueryMatches(a, b3) {
|
|
14349
14262
|
if (a.matchScore !== b3.matchScore) {
|
|
@@ -14356,16 +14269,625 @@ function compareQueryMatches(a, b3) {
|
|
|
14356
14269
|
) || a.source.worktree.path.localeCompare(b3.source.worktree.path);
|
|
14357
14270
|
}
|
|
14358
14271
|
function groupPromptEntries(worktrees) {
|
|
14359
|
-
const groups =
|
|
14272
|
+
const groups = /* @__PURE__ */ new Map();
|
|
14360
14273
|
for (const worktree of worktrees) {
|
|
14361
14274
|
const group = worktree.group === "recent" ? "Recent worktrees" : "Other worktrees";
|
|
14362
|
-
groups
|
|
14363
|
-
|
|
14364
|
-
|
|
14365
|
-
|
|
14275
|
+
const groupWorktrees = groups.get(group);
|
|
14276
|
+
if (groupWorktrees === void 0) {
|
|
14277
|
+
groups.set(group, [worktree]);
|
|
14278
|
+
} else {
|
|
14279
|
+
groupWorktrees.push(worktree);
|
|
14280
|
+
}
|
|
14281
|
+
}
|
|
14282
|
+
return [...groups.entries()];
|
|
14283
|
+
}
|
|
14284
|
+
function buildGroupedSearchableEntries(worktrees) {
|
|
14285
|
+
const entries = [];
|
|
14286
|
+
for (const [group, groupWorktrees] of groupPromptEntries(worktrees)) {
|
|
14287
|
+
entries.push({
|
|
14288
|
+
label: group,
|
|
14289
|
+
searchText: group.toLowerCase(),
|
|
14290
|
+
selectable: false
|
|
14291
|
+
});
|
|
14292
|
+
for (const worktree of groupWorktrees) {
|
|
14293
|
+
entries.push(buildSearchableWorktreeEntry(worktree));
|
|
14294
|
+
}
|
|
14295
|
+
}
|
|
14296
|
+
return entries;
|
|
14297
|
+
}
|
|
14298
|
+
function buildSearchableWorktreeEntry(worktree) {
|
|
14299
|
+
const metadata = worktree.metadata ?? null;
|
|
14300
|
+
const branch = worktree.branch ?? "(detached)";
|
|
14301
|
+
return {
|
|
14302
|
+
detail: [worktree.repoName, branch, metadata, worktree.path].filter((part) => part !== null && part.length > 0).join(" \xB7 "),
|
|
14303
|
+
label: worktree.label,
|
|
14304
|
+
searchText: buildPromptSearchText(worktree),
|
|
14305
|
+
value: worktree.path,
|
|
14306
|
+
worktree: {
|
|
14307
|
+
branch,
|
|
14308
|
+
metadata,
|
|
14309
|
+
path: worktree.path,
|
|
14310
|
+
repoName: worktree.repoName
|
|
14311
|
+
}
|
|
14312
|
+
};
|
|
14313
|
+
}
|
|
14314
|
+
async function runSearchablePrompt(options) {
|
|
14315
|
+
const input = options.input ?? stdin;
|
|
14316
|
+
const output = options.output ?? stdout;
|
|
14317
|
+
if (!input.isTTY) {
|
|
14318
|
+
return null;
|
|
14319
|
+
}
|
|
14320
|
+
const prompt = new SearchablePrompt(options, input, output);
|
|
14321
|
+
const value = await prompt.run();
|
|
14322
|
+
return pD(value) ? null : value;
|
|
14323
|
+
}
|
|
14324
|
+
var SearchablePrompt = class {
|
|
14325
|
+
constructor(options, input, output) {
|
|
14326
|
+
this.options = options;
|
|
14327
|
+
this.output = output;
|
|
14328
|
+
this.cursor = this.firstSelectableIndex();
|
|
14329
|
+
const owner = this;
|
|
14330
|
+
this.prompt = new WorktreeCorePrompt(this, {
|
|
14331
|
+
input,
|
|
14332
|
+
output,
|
|
14333
|
+
render: function renderWorktreePrompt() {
|
|
14334
|
+
return owner.render(this.state, this.error);
|
|
14335
|
+
}
|
|
14366
14336
|
});
|
|
14337
|
+
this.syncValue();
|
|
14338
|
+
}
|
|
14339
|
+
cursor = 0;
|
|
14340
|
+
query = "";
|
|
14341
|
+
searchActive = false;
|
|
14342
|
+
selected = /* @__PURE__ */ new Set();
|
|
14343
|
+
prompt;
|
|
14344
|
+
run() {
|
|
14345
|
+
return this.prompt.prompt();
|
|
14346
|
+
}
|
|
14347
|
+
handleKeypress(prompt, character, key) {
|
|
14348
|
+
if (prompt.state === "error") {
|
|
14349
|
+
prompt.state = "active";
|
|
14350
|
+
prompt.error = "";
|
|
14351
|
+
}
|
|
14352
|
+
const action = resolvePromptAction(character, key);
|
|
14353
|
+
if (action === "cancel") {
|
|
14354
|
+
this.cancel(prompt);
|
|
14355
|
+
return;
|
|
14356
|
+
}
|
|
14357
|
+
if (action === "escape") {
|
|
14358
|
+
this.handleEscapeKey(prompt);
|
|
14359
|
+
return;
|
|
14360
|
+
}
|
|
14361
|
+
if (action === "enter") {
|
|
14362
|
+
this.submit(prompt);
|
|
14363
|
+
return;
|
|
14364
|
+
}
|
|
14365
|
+
if (this.searchActive && this.handleSearchKey(character, key?.name)) {
|
|
14366
|
+
this.syncValue();
|
|
14367
|
+
renderPrompt(prompt);
|
|
14368
|
+
return;
|
|
14369
|
+
}
|
|
14370
|
+
if (character === "/" && !this.searchActive) {
|
|
14371
|
+
this.searchActive = true;
|
|
14372
|
+
this.query = "";
|
|
14373
|
+
this.cursor = this.firstSelectableIndex();
|
|
14374
|
+
this.syncValue();
|
|
14375
|
+
renderPrompt(prompt);
|
|
14376
|
+
return;
|
|
14377
|
+
}
|
|
14378
|
+
this.handleNavigationKey(character, action);
|
|
14379
|
+
this.syncValue();
|
|
14380
|
+
renderPrompt(prompt);
|
|
14381
|
+
}
|
|
14382
|
+
handleEscapeKey(prompt) {
|
|
14383
|
+
if (this.searchActive) {
|
|
14384
|
+
this.searchActive = false;
|
|
14385
|
+
this.query = "";
|
|
14386
|
+
this.cursor = this.firstSelectableIndex();
|
|
14387
|
+
this.syncValue();
|
|
14388
|
+
renderPrompt(prompt);
|
|
14389
|
+
return;
|
|
14390
|
+
}
|
|
14391
|
+
this.cancel(prompt);
|
|
14392
|
+
}
|
|
14393
|
+
cancel(prompt) {
|
|
14394
|
+
prompt.state = "cancel";
|
|
14395
|
+
renderPrompt(prompt);
|
|
14396
|
+
closePrompt(prompt);
|
|
14397
|
+
}
|
|
14398
|
+
handleSearchKey(character, keyName) {
|
|
14399
|
+
if (keyName === "space" || character === " ") {
|
|
14400
|
+
return false;
|
|
14401
|
+
}
|
|
14402
|
+
if (keyName === "backspace" || keyName === "delete") {
|
|
14403
|
+
this.query = this.query.slice(0, -1);
|
|
14404
|
+
this.cursor = this.firstSelectableIndex();
|
|
14405
|
+
return true;
|
|
14406
|
+
}
|
|
14407
|
+
if (isPrintableSearchCharacter(character)) {
|
|
14408
|
+
this.query += character;
|
|
14409
|
+
this.cursor = this.firstSelectableIndex();
|
|
14410
|
+
return true;
|
|
14411
|
+
}
|
|
14412
|
+
return false;
|
|
14413
|
+
}
|
|
14414
|
+
handleNavigationKey(character, action) {
|
|
14415
|
+
switch (action) {
|
|
14416
|
+
case "up":
|
|
14417
|
+
this.moveCursor(-1);
|
|
14418
|
+
return;
|
|
14419
|
+
case "down":
|
|
14420
|
+
this.moveCursor(1);
|
|
14421
|
+
return;
|
|
14422
|
+
case "space":
|
|
14423
|
+
this.toggleSelection();
|
|
14424
|
+
return;
|
|
14425
|
+
}
|
|
14426
|
+
switch (character) {
|
|
14427
|
+
case "k":
|
|
14428
|
+
this.moveCursor(-1);
|
|
14429
|
+
return;
|
|
14430
|
+
case "j":
|
|
14431
|
+
this.moveCursor(1);
|
|
14432
|
+
return;
|
|
14433
|
+
case " ":
|
|
14434
|
+
this.toggleSelection();
|
|
14435
|
+
return;
|
|
14436
|
+
}
|
|
14437
|
+
}
|
|
14438
|
+
moveCursor(direction) {
|
|
14439
|
+
const entries = this.visibleEntries();
|
|
14440
|
+
if (entries.length === 0) return;
|
|
14441
|
+
let nextCursor = this.cursor;
|
|
14442
|
+
for (let index = 0; index < entries.length; index += 1) {
|
|
14443
|
+
nextCursor = wrapIndex(nextCursor + direction, entries.length);
|
|
14444
|
+
if (isSelectableEntry(entries[nextCursor])) {
|
|
14445
|
+
this.cursor = nextCursor;
|
|
14446
|
+
return;
|
|
14447
|
+
}
|
|
14448
|
+
}
|
|
14449
|
+
}
|
|
14450
|
+
submit(prompt) {
|
|
14451
|
+
const entry = this.visibleEntries()[this.cursor];
|
|
14452
|
+
if (!this.options.multiple) {
|
|
14453
|
+
prompt.value = isSelectableEntry(entry) ? entry.value : null;
|
|
14454
|
+
prompt.state = "submit";
|
|
14455
|
+
renderPrompt(prompt);
|
|
14456
|
+
closePrompt(prompt);
|
|
14457
|
+
return;
|
|
14458
|
+
}
|
|
14459
|
+
if (this.selected.size === 0) {
|
|
14460
|
+
prompt.error = "Please select at least one option.";
|
|
14461
|
+
prompt.state = "error";
|
|
14462
|
+
renderPrompt(prompt);
|
|
14463
|
+
return;
|
|
14464
|
+
}
|
|
14465
|
+
prompt.value = [...this.selected];
|
|
14466
|
+
prompt.state = "submit";
|
|
14467
|
+
renderPrompt(prompt);
|
|
14468
|
+
closePrompt(prompt);
|
|
14469
|
+
}
|
|
14470
|
+
toggleSelection() {
|
|
14471
|
+
if (!this.options.multiple) return;
|
|
14472
|
+
const entry = this.visibleEntries()[this.cursor];
|
|
14473
|
+
if (!isSelectableEntry(entry)) return;
|
|
14474
|
+
if (this.selected.has(entry.value)) {
|
|
14475
|
+
this.selected.delete(entry.value);
|
|
14476
|
+
return;
|
|
14477
|
+
}
|
|
14478
|
+
this.selected.add(entry.value);
|
|
14479
|
+
}
|
|
14480
|
+
render(state, error) {
|
|
14481
|
+
const entries = this.visibleEntries();
|
|
14482
|
+
const visibleEntries = windowPromptEntries(
|
|
14483
|
+
entries,
|
|
14484
|
+
this.cursor,
|
|
14485
|
+
this.maxItems()
|
|
14486
|
+
);
|
|
14487
|
+
const glyphs = promptGlyphs();
|
|
14488
|
+
const colors = promptColors();
|
|
14489
|
+
const frame = promptFrameColor(state, colors);
|
|
14490
|
+
const lines = [
|
|
14491
|
+
colors.bar(glyphs.bar),
|
|
14492
|
+
this.renderTitle(state, glyphs, colors),
|
|
14493
|
+
`${frame(glyphs.bar)} ${this.renderSearchHint(colors)}`,
|
|
14494
|
+
frame(glyphs.bar)
|
|
14495
|
+
];
|
|
14496
|
+
if (state === "error" && error.length > 0) {
|
|
14497
|
+
lines.push(`${colors.errorBar(glyphs.bar)} ${colors.error(error)}`);
|
|
14498
|
+
lines.push(frame(glyphs.bar));
|
|
14499
|
+
}
|
|
14500
|
+
lines.push(
|
|
14501
|
+
...this.renderEntries(entries, visibleEntries, glyphs, colors, frame)
|
|
14502
|
+
);
|
|
14503
|
+
lines.push(frame(glyphs.bar));
|
|
14504
|
+
const preview = this.activePreview(entries, colors);
|
|
14505
|
+
if (preview !== null) {
|
|
14506
|
+
lines.push(`${frame(glyphs.bar)} ${preview}`);
|
|
14507
|
+
lines.push(frame(glyphs.bar));
|
|
14508
|
+
}
|
|
14509
|
+
const visibleWorktreeCount = entries.filter(isSelectableEntry).length;
|
|
14510
|
+
const footer = this.footerText(visibleWorktreeCount, colors);
|
|
14511
|
+
if (footer.length > 0) {
|
|
14512
|
+
lines.push(`${frame(glyphs.corner)} ${footer}`);
|
|
14513
|
+
}
|
|
14514
|
+
return `${lines.join("\n")}
|
|
14515
|
+
`;
|
|
14516
|
+
}
|
|
14517
|
+
renderTitle(state, glyphs, colors) {
|
|
14518
|
+
const symbol = colors.symbol(promptSymbol(state, glyphs), state);
|
|
14519
|
+
const maxTitleLength = Math.max(8, this.columns() - 3);
|
|
14520
|
+
if (!this.searchActive) {
|
|
14521
|
+
return `${symbol} ${middleEllipsize(this.options.message, maxTitleLength)}`;
|
|
14522
|
+
}
|
|
14523
|
+
const search = ` /${this.query}`;
|
|
14524
|
+
const maxSearchLength = Math.min(
|
|
14525
|
+
terminalWidth(search),
|
|
14526
|
+
Math.floor(maxTitleLength / 2)
|
|
14527
|
+
);
|
|
14528
|
+
const message = middleEllipsize(
|
|
14529
|
+
this.options.message,
|
|
14530
|
+
Math.max(1, maxTitleLength - maxSearchLength)
|
|
14531
|
+
);
|
|
14532
|
+
const visibleSearch = middleEllipsize(
|
|
14533
|
+
search,
|
|
14534
|
+
Math.max(1, maxTitleLength - terminalWidth(message))
|
|
14535
|
+
);
|
|
14536
|
+
return `${symbol} ${message}${colors.search(visibleSearch)}`;
|
|
14537
|
+
}
|
|
14538
|
+
renderSearchHint(colors) {
|
|
14539
|
+
if (this.searchActive) {
|
|
14540
|
+
return `${colors.hint("type to filter")} ${colors.hint("\xB7")} ${colors.key("esc")} ${colors.hint("clears")}`;
|
|
14541
|
+
}
|
|
14542
|
+
return `${colors.hint("press ")}${colors.key("/")}${colors.hint(" to search")}`;
|
|
14543
|
+
}
|
|
14544
|
+
renderEntries(entries, visibleEntries, glyphs, colors, frame) {
|
|
14545
|
+
if (entries.length === 0) {
|
|
14546
|
+
return [`${frame(glyphs.bar)} ${colors.hint("No matching worktrees")}`];
|
|
14547
|
+
}
|
|
14548
|
+
return visibleEntries.map(
|
|
14549
|
+
(entry) => entry === "ellipsis" ? `${frame(glyphs.bar)} ${colors.hint("...")}` : this.renderEntry(entries, entry, glyphs, colors, frame)
|
|
14550
|
+
);
|
|
14551
|
+
}
|
|
14552
|
+
renderEntry(entries, entry, glyphs, colors, frame) {
|
|
14553
|
+
const active = entries[this.cursor] === entry;
|
|
14554
|
+
const selected = isSelectableEntry(entry) && this.selected.has(entry.value);
|
|
14555
|
+
const prefix = this.entryPrefix(entry, active, selected, glyphs);
|
|
14556
|
+
const label = this.entryLabel(entry, prefix);
|
|
14557
|
+
const line = isSelectableEntry(entry) ? active ? label : colors.hint(label) : colors.hint(label);
|
|
14558
|
+
const marker = selected ? colors.selected(prefix) : active ? this.options.multiple ? colors.option(prefix) : colors.selected(prefix) : colors.hint(prefix);
|
|
14559
|
+
return `${frame(glyphs.bar)} ${marker} ${line}`;
|
|
14560
|
+
}
|
|
14561
|
+
activePreview(entries, colors) {
|
|
14562
|
+
const entry = entries[this.cursor];
|
|
14563
|
+
if (!isSelectableEntry(entry) || entry.detail === void 0) return null;
|
|
14564
|
+
const label = "current";
|
|
14565
|
+
const separator = " ";
|
|
14566
|
+
const width = this.previewWidth();
|
|
14567
|
+
const prefixWidth = terminalWidth(label) + terminalWidth(separator);
|
|
14568
|
+
if (width <= prefixWidth) return colors.key(middleEllipsize(label, width));
|
|
14569
|
+
const detail = middleEllipsize(entry.detail, width - prefixWidth);
|
|
14570
|
+
return `${colors.key(label)}${colors.hint(separator)}${colors.hint(detail)}`;
|
|
14571
|
+
}
|
|
14572
|
+
entryLabel(entry, prefix) {
|
|
14573
|
+
const width = this.labelWidth(prefix);
|
|
14574
|
+
if (entry.worktree === void 0) {
|
|
14575
|
+
return middleEllipsize(entry.label, width);
|
|
14576
|
+
}
|
|
14577
|
+
return fitPromptPieces(
|
|
14578
|
+
[
|
|
14579
|
+
{
|
|
14580
|
+
ellipsize: middleEllipsize,
|
|
14581
|
+
max: 18,
|
|
14582
|
+
min: 6,
|
|
14583
|
+
value: entry.worktree.repoName
|
|
14584
|
+
},
|
|
14585
|
+
{
|
|
14586
|
+
ellipsize: middleEllipsize,
|
|
14587
|
+
max: 32,
|
|
14588
|
+
min: 8,
|
|
14589
|
+
value: entry.worktree.branch
|
|
14590
|
+
},
|
|
14591
|
+
...entry.worktree.metadata === null ? [] : [
|
|
14592
|
+
{
|
|
14593
|
+
ellipsize: middleEllipsize,
|
|
14594
|
+
max: 30,
|
|
14595
|
+
min: 10,
|
|
14596
|
+
value: entry.worktree.metadata
|
|
14597
|
+
}
|
|
14598
|
+
],
|
|
14599
|
+
{
|
|
14600
|
+
ellipsize: startEllipsize,
|
|
14601
|
+
max: 36,
|
|
14602
|
+
min: 12,
|
|
14603
|
+
value: entry.worktree.path
|
|
14604
|
+
}
|
|
14605
|
+
],
|
|
14606
|
+
width
|
|
14607
|
+
);
|
|
14608
|
+
}
|
|
14609
|
+
labelWidth(prefix) {
|
|
14610
|
+
return Math.max(8, this.columns() - terminalWidth(prefix) - 4);
|
|
14611
|
+
}
|
|
14612
|
+
previewWidth() {
|
|
14613
|
+
return Math.max(8, this.columns() - 3);
|
|
14614
|
+
}
|
|
14615
|
+
entryPrefix(entry, active, selected, glyphs) {
|
|
14616
|
+
if (!isSelectableEntry(entry)) {
|
|
14617
|
+
return active ? glyphs.active : " ";
|
|
14618
|
+
}
|
|
14619
|
+
if (!this.options.multiple) {
|
|
14620
|
+
return active ? glyphs.active : glyphs.inactive;
|
|
14621
|
+
}
|
|
14622
|
+
if (active && selected) return glyphs.checked;
|
|
14623
|
+
if (active) return glyphs.uncheckedActive;
|
|
14624
|
+
return selected ? glyphs.checked : glyphs.unchecked;
|
|
14625
|
+
}
|
|
14626
|
+
footerText(visibleCount, colors) {
|
|
14627
|
+
if (!this.options.multiple) return "";
|
|
14628
|
+
return [
|
|
14629
|
+
`${colors.key("space")} ${colors.hint("select")}`,
|
|
14630
|
+
`${colors.selected(String(this.selected.size))} ${colors.hint("selected")}`,
|
|
14631
|
+
colors.hint(`${visibleCount} shown`)
|
|
14632
|
+
].join(colors.hint(" \xB7 "));
|
|
14633
|
+
}
|
|
14634
|
+
firstSelectableIndex() {
|
|
14635
|
+
const index = this.visibleEntries().findIndex(isSelectableEntry);
|
|
14636
|
+
return index === -1 ? 0 : index;
|
|
14637
|
+
}
|
|
14638
|
+
visibleEntries() {
|
|
14639
|
+
const query = normalizeQuery(this.query);
|
|
14640
|
+
if (query === null) {
|
|
14641
|
+
return this.options.entries;
|
|
14642
|
+
}
|
|
14643
|
+
return filterSearchablePromptEntries(this.options.entries, query);
|
|
14644
|
+
}
|
|
14645
|
+
maxItems() {
|
|
14646
|
+
const rows = this.output.rows ?? 16;
|
|
14647
|
+
return Math.max(5, Math.min(12, rows - 8));
|
|
14648
|
+
}
|
|
14649
|
+
columns() {
|
|
14650
|
+
return Math.max(20, this.output.columns ?? 80);
|
|
14651
|
+
}
|
|
14652
|
+
syncValue() {
|
|
14653
|
+
if (this.options.multiple) {
|
|
14654
|
+
this.prompt.value = [...this.selected];
|
|
14655
|
+
return;
|
|
14656
|
+
}
|
|
14657
|
+
const entry = this.visibleEntries()[this.cursor];
|
|
14658
|
+
this.prompt.value = isSelectableEntry(entry) ? entry.value : null;
|
|
14659
|
+
}
|
|
14660
|
+
};
|
|
14661
|
+
var WorktreeCorePrompt = class extends x {
|
|
14662
|
+
constructor(worktreePrompt, options) {
|
|
14663
|
+
super(options, false);
|
|
14664
|
+
this.worktreePrompt = worktreePrompt;
|
|
14665
|
+
}
|
|
14666
|
+
};
|
|
14667
|
+
Object.defineProperty(WorktreeCorePrompt.prototype, "onKeypress", {
|
|
14668
|
+
value: onWorktreeKeypress,
|
|
14669
|
+
writable: true
|
|
14670
|
+
});
|
|
14671
|
+
function renderPrompt(prompt) {
|
|
14672
|
+
prompt.render();
|
|
14673
|
+
}
|
|
14674
|
+
function closePrompt(prompt) {
|
|
14675
|
+
prompt.close();
|
|
14676
|
+
}
|
|
14677
|
+
function onWorktreeKeypress(character, key) {
|
|
14678
|
+
this.worktreePrompt.handleKeypress(this, character, key);
|
|
14679
|
+
}
|
|
14680
|
+
function resolvePromptAction(character, key) {
|
|
14681
|
+
if (key?.ctrl && key.name === "c" || character === "") {
|
|
14682
|
+
return "cancel";
|
|
14683
|
+
}
|
|
14684
|
+
switch (key?.name) {
|
|
14685
|
+
case "escape":
|
|
14686
|
+
return "escape";
|
|
14687
|
+
case "return":
|
|
14688
|
+
return "enter";
|
|
14689
|
+
case "space":
|
|
14690
|
+
return "space";
|
|
14691
|
+
case "up":
|
|
14692
|
+
case "left":
|
|
14693
|
+
return "up";
|
|
14694
|
+
case "down":
|
|
14695
|
+
case "right":
|
|
14696
|
+
return "down";
|
|
14697
|
+
}
|
|
14698
|
+
switch (character) {
|
|
14699
|
+
case " ":
|
|
14700
|
+
return "space";
|
|
14701
|
+
case "k":
|
|
14702
|
+
case "h":
|
|
14703
|
+
return "up";
|
|
14704
|
+
case "j":
|
|
14705
|
+
case "l":
|
|
14706
|
+
return "down";
|
|
14707
|
+
}
|
|
14708
|
+
return void 0;
|
|
14709
|
+
}
|
|
14710
|
+
function promptGlyphs() {
|
|
14711
|
+
return supportsUnicode() ? {
|
|
14712
|
+
active: "\u25CF",
|
|
14713
|
+
bar: "\u2502",
|
|
14714
|
+
checked: "\u25FC",
|
|
14715
|
+
corner: "\u2514",
|
|
14716
|
+
inactive: "\u25CB",
|
|
14717
|
+
pending: "\u25C6",
|
|
14718
|
+
submitted: "\u25C7",
|
|
14719
|
+
unchecked: "\u25FB",
|
|
14720
|
+
uncheckedActive: "\u25FB"
|
|
14721
|
+
} : {
|
|
14722
|
+
active: ">",
|
|
14723
|
+
bar: "|",
|
|
14724
|
+
checked: "[x]",
|
|
14725
|
+
corner: "-",
|
|
14726
|
+
inactive: " ",
|
|
14727
|
+
pending: "*",
|
|
14728
|
+
submitted: "o",
|
|
14729
|
+
unchecked: "[ ]",
|
|
14730
|
+
uncheckedActive: "[ ]"
|
|
14731
|
+
};
|
|
14732
|
+
}
|
|
14733
|
+
function promptColors() {
|
|
14734
|
+
return {
|
|
14735
|
+
activeBar: cyan,
|
|
14736
|
+
bar: gray,
|
|
14737
|
+
error: yellow,
|
|
14738
|
+
errorBar: yellow,
|
|
14739
|
+
hint: dim,
|
|
14740
|
+
key: cyan,
|
|
14741
|
+
option: cyan,
|
|
14742
|
+
search: cyan,
|
|
14743
|
+
selected: green,
|
|
14744
|
+
symbol: (value, state) => {
|
|
14745
|
+
if (state === "submit") return green(value);
|
|
14746
|
+
if (state === "error") return yellow(value);
|
|
14747
|
+
if (state === "cancel") return red(value);
|
|
14748
|
+
return cyan(value);
|
|
14749
|
+
}
|
|
14750
|
+
};
|
|
14751
|
+
}
|
|
14752
|
+
function promptFrameColor(state, colors) {
|
|
14753
|
+
if (state === "error") return colors.errorBar;
|
|
14754
|
+
if (state === "active" || state === "initial") return colors.activeBar;
|
|
14755
|
+
return colors.bar;
|
|
14756
|
+
}
|
|
14757
|
+
function promptSymbol(state, glyphs) {
|
|
14758
|
+
return state === "submit" ? glyphs.submitted : glyphs.pending;
|
|
14759
|
+
}
|
|
14760
|
+
function cyan(value) {
|
|
14761
|
+
return color("\x1B[36m", "\x1B[39m", value);
|
|
14762
|
+
}
|
|
14763
|
+
function dim(value) {
|
|
14764
|
+
return color("\x1B[2m", "\x1B[22m", value);
|
|
14765
|
+
}
|
|
14766
|
+
function gray(value) {
|
|
14767
|
+
return color("\x1B[90m", "\x1B[39m", value);
|
|
14768
|
+
}
|
|
14769
|
+
function green(value) {
|
|
14770
|
+
return color("\x1B[32m", "\x1B[39m", value);
|
|
14771
|
+
}
|
|
14772
|
+
function red(value) {
|
|
14773
|
+
return color("\x1B[31m", "\x1B[39m", value);
|
|
14774
|
+
}
|
|
14775
|
+
function yellow(value) {
|
|
14776
|
+
return color("\x1B[33m", "\x1B[39m", value);
|
|
14777
|
+
}
|
|
14778
|
+
function color(open, close, value) {
|
|
14779
|
+
if (env4.NO_COLOR !== void 0) return value;
|
|
14780
|
+
return `${open}${value}${close}`;
|
|
14781
|
+
}
|
|
14782
|
+
function supportsUnicode() {
|
|
14783
|
+
if (platform !== "win32") {
|
|
14784
|
+
return env4.TERM !== "linux";
|
|
14785
|
+
}
|
|
14786
|
+
return Boolean(
|
|
14787
|
+
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"
|
|
14788
|
+
);
|
|
14789
|
+
}
|
|
14790
|
+
function isPrintableSearchCharacter(character) {
|
|
14791
|
+
return typeof character === "string" && character.length === 1 && character >= " " && character !== "\x7F";
|
|
14792
|
+
}
|
|
14793
|
+
function wrapIndex(index, length) {
|
|
14794
|
+
return (index + length) % length;
|
|
14795
|
+
}
|
|
14796
|
+
function windowPromptEntries(entries, cursor, maxItems) {
|
|
14797
|
+
if (entries.length <= maxItems) {
|
|
14798
|
+
return entries;
|
|
14799
|
+
}
|
|
14800
|
+
const activeIndex = Math.min(Math.max(cursor, 0), entries.length - 1);
|
|
14801
|
+
const start = Math.max(
|
|
14802
|
+
0,
|
|
14803
|
+
Math.min(activeIndex - 2, entries.length - maxItems)
|
|
14804
|
+
);
|
|
14805
|
+
const window = entries.slice(start, start + maxItems);
|
|
14806
|
+
if (start > 0) {
|
|
14807
|
+
window[0] = "ellipsis";
|
|
14808
|
+
}
|
|
14809
|
+
if (start + maxItems < entries.length) {
|
|
14810
|
+
window[window.length - 1] = "ellipsis";
|
|
14811
|
+
}
|
|
14812
|
+
return window;
|
|
14813
|
+
}
|
|
14814
|
+
function fitPromptPieces(pieces, width) {
|
|
14815
|
+
const separator = " \xB7 ";
|
|
14816
|
+
let visiblePieces = pieces.filter((piece) => piece.value.length > 0);
|
|
14817
|
+
let available = width - terminalWidth(separator) * Math.max(0, visiblePieces.length - 1);
|
|
14818
|
+
while (visiblePieces.length > 1 && available < minimumPieceLength(visiblePieces)) {
|
|
14819
|
+
const removableIndex = visiblePieces.length === 4 ? 2 : visiblePieces.length - 2;
|
|
14820
|
+
visiblePieces = visiblePieces.filter(
|
|
14821
|
+
(_3, index) => index !== removableIndex
|
|
14822
|
+
);
|
|
14823
|
+
available = width - terminalWidth(separator) * Math.max(0, visiblePieces.length - 1);
|
|
14824
|
+
}
|
|
14825
|
+
if (available <= 0 || available < minimumPieceLength(visiblePieces)) {
|
|
14826
|
+
return middleEllipsize(
|
|
14827
|
+
visiblePieces.map((piece) => piece.value).join(separator),
|
|
14828
|
+
width
|
|
14829
|
+
);
|
|
14830
|
+
}
|
|
14831
|
+
const lengths = visiblePieces.map(
|
|
14832
|
+
(piece) => Math.min(terminalWidth(piece.value), piece.max)
|
|
14833
|
+
);
|
|
14834
|
+
while (sum(lengths) > available) {
|
|
14835
|
+
const index = largestShrinkablePieceIndex(visiblePieces, lengths);
|
|
14836
|
+
if (index === -1) break;
|
|
14837
|
+
lengths[index] -= 1;
|
|
14838
|
+
}
|
|
14839
|
+
return visiblePieces.map((piece, index) => piece.ellipsize(piece.value, lengths[index])).join(separator);
|
|
14840
|
+
}
|
|
14841
|
+
function minimumPieceLength(pieces) {
|
|
14842
|
+
return sum(
|
|
14843
|
+
pieces.map((piece) => Math.min(terminalWidth(piece.value), piece.min))
|
|
14844
|
+
);
|
|
14845
|
+
}
|
|
14846
|
+
function largestShrinkablePieceIndex(pieces, lengths) {
|
|
14847
|
+
let candidate = -1;
|
|
14848
|
+
for (let index = 0; index < pieces.length; index += 1) {
|
|
14849
|
+
if (lengths[index] <= Math.min(terminalWidth(pieces[index].value), pieces[index].min)) {
|
|
14850
|
+
continue;
|
|
14851
|
+
}
|
|
14852
|
+
if (candidate === -1 || lengths[index] > lengths[candidate]) {
|
|
14853
|
+
candidate = index;
|
|
14854
|
+
}
|
|
14367
14855
|
}
|
|
14368
|
-
return
|
|
14856
|
+
return candidate;
|
|
14857
|
+
}
|
|
14858
|
+
function sum(values) {
|
|
14859
|
+
return values.reduce((total, value) => total + value, 0);
|
|
14860
|
+
}
|
|
14861
|
+
function filterSearchablePromptEntries(entries, query) {
|
|
14862
|
+
const filtered = [];
|
|
14863
|
+
let pendingGroup = null;
|
|
14864
|
+
for (const entry of entries) {
|
|
14865
|
+
if (!isSelectableEntry(entry)) {
|
|
14866
|
+
pendingGroup = entry;
|
|
14867
|
+
continue;
|
|
14868
|
+
}
|
|
14869
|
+
if (!entry.searchText.includes(query)) {
|
|
14870
|
+
continue;
|
|
14871
|
+
}
|
|
14872
|
+
if (pendingGroup !== null) {
|
|
14873
|
+
filtered.push(pendingGroup);
|
|
14874
|
+
pendingGroup = null;
|
|
14875
|
+
}
|
|
14876
|
+
filtered.push(entry);
|
|
14877
|
+
}
|
|
14878
|
+
return filtered;
|
|
14879
|
+
}
|
|
14880
|
+
function isSelectableEntry(entry) {
|
|
14881
|
+
return entry !== void 0 && entry.selectable !== false && typeof entry.value === "string";
|
|
14882
|
+
}
|
|
14883
|
+
function buildPromptSearchText(worktree) {
|
|
14884
|
+
return [
|
|
14885
|
+
worktree.repoName,
|
|
14886
|
+
worktree.branch ?? "detached",
|
|
14887
|
+
worktree.path,
|
|
14888
|
+
worktree.label,
|
|
14889
|
+
`${worktree.repoName}/${worktree.branch ?? "detached"}`
|
|
14890
|
+
].join(" ").toLowerCase();
|
|
14369
14891
|
}
|
|
14370
14892
|
function buildWorktreePromptEntry(source, info, lastUsedTimestamp, now) {
|
|
14371
14893
|
const lastWorkedTimestamp = info.lastCommitTimestamp === null ? null : info.lastCommitTimestamp * 1e3;
|
|
@@ -14379,12 +14901,15 @@ function buildWorktreePromptEntry(source, info, lastUsedTimestamp, now) {
|
|
|
14379
14901
|
now
|
|
14380
14902
|
);
|
|
14381
14903
|
const status = badges.length > 0 ? badges.map((badge) => `[${badge}]`).join(" ") : null;
|
|
14904
|
+
const metadataParts = [status, recency].filter(
|
|
14905
|
+
(part) => part !== null && part.length > 0
|
|
14906
|
+
);
|
|
14907
|
+
const metadata = metadataParts.length === 0 ? null : metadataParts.join(" \xB7 ");
|
|
14382
14908
|
const path9 = middleEllipsize(source.worktree.path, 76);
|
|
14383
14909
|
const label = [
|
|
14384
14910
|
middleEllipsize(source.repoName, 22),
|
|
14385
14911
|
middleEllipsize(branch, 34),
|
|
14386
|
-
|
|
14387
|
-
recency,
|
|
14912
|
+
metadata,
|
|
14388
14913
|
path9
|
|
14389
14914
|
].filter((part) => part !== null && part.length > 0).join(" \xB7 ");
|
|
14390
14915
|
return {
|
|
@@ -14392,6 +14917,7 @@ function buildWorktreePromptEntry(source, info, lastUsedTimestamp, now) {
|
|
|
14392
14917
|
group: lastUsedTimestamp !== null ? "recent" : "other",
|
|
14393
14918
|
label,
|
|
14394
14919
|
lastActivityTimestamp,
|
|
14920
|
+
metadata,
|
|
14395
14921
|
repoName: source.repoName
|
|
14396
14922
|
};
|
|
14397
14923
|
}
|
|
@@ -14490,16 +15016,58 @@ function scoreWorktreeMatch(entry, query) {
|
|
|
14490
15016
|
return buildSearchText(entry.repoName, entry).includes(query) ? 1 : null;
|
|
14491
15017
|
}
|
|
14492
15018
|
function middleEllipsize(value, maxLength) {
|
|
14493
|
-
if (value
|
|
15019
|
+
if (terminalWidth(value) <= maxLength) {
|
|
14494
15020
|
return value;
|
|
14495
15021
|
}
|
|
14496
15022
|
if (maxLength <= 1) {
|
|
14497
15023
|
return "\u2026";
|
|
14498
15024
|
}
|
|
14499
15025
|
const keep = maxLength - 1;
|
|
14500
|
-
const start = Math.ceil(keep / 2);
|
|
14501
|
-
const end = Math.floor(keep / 2);
|
|
14502
|
-
return `${
|
|
15026
|
+
const start = takeTerminalColumns(value, Math.ceil(keep / 2), "start");
|
|
15027
|
+
const end = takeTerminalColumns(value, Math.floor(keep / 2), "end");
|
|
15028
|
+
return `${start}\u2026${end}`;
|
|
15029
|
+
}
|
|
15030
|
+
function startEllipsize(value, maxLength) {
|
|
15031
|
+
if (terminalWidth(value) <= maxLength) {
|
|
15032
|
+
return value;
|
|
15033
|
+
}
|
|
15034
|
+
if (maxLength <= 1) {
|
|
15035
|
+
return "\u2026";
|
|
15036
|
+
}
|
|
15037
|
+
return `\u2026${takeTerminalColumns(value, maxLength - 1, "end")}`;
|
|
15038
|
+
}
|
|
15039
|
+
function takeTerminalColumns(value, maxWidth, direction) {
|
|
15040
|
+
const characters = direction === "start" ? Array.from(value) : Array.from(value).reverse();
|
|
15041
|
+
const kept = [];
|
|
15042
|
+
let width = 0;
|
|
15043
|
+
for (const character of characters) {
|
|
15044
|
+
const characterWidth = terminalWidth(character);
|
|
15045
|
+
if (width + characterWidth > maxWidth) break;
|
|
15046
|
+
kept.push(character);
|
|
15047
|
+
width += characterWidth;
|
|
15048
|
+
}
|
|
15049
|
+
return direction === "start" ? kept.join("") : kept.reverse().join("");
|
|
15050
|
+
}
|
|
15051
|
+
function terminalWidth(value) {
|
|
15052
|
+
let width = 0;
|
|
15053
|
+
for (const character of Array.from(value)) {
|
|
15054
|
+
width += characterTerminalWidth(character);
|
|
15055
|
+
}
|
|
15056
|
+
return width;
|
|
15057
|
+
}
|
|
15058
|
+
function characterTerminalWidth(character) {
|
|
15059
|
+
const codePoint = character.codePointAt(0);
|
|
15060
|
+
if (codePoint === void 0) return 0;
|
|
15061
|
+
if (isZeroWidthCodePoint(codePoint) || new RegExp("\\p{Mark}", "u").test(character)) {
|
|
15062
|
+
return 0;
|
|
15063
|
+
}
|
|
15064
|
+
return isWideCodePoint(codePoint) ? 2 : 1;
|
|
15065
|
+
}
|
|
15066
|
+
function isZeroWidthCodePoint(codePoint) {
|
|
15067
|
+
return codePoint === 0 || codePoint === 8205 || codePoint >= 65024 && codePoint <= 65039;
|
|
15068
|
+
}
|
|
15069
|
+
function isWideCodePoint(codePoint) {
|
|
15070
|
+
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
15071
|
}
|
|
14504
15072
|
|
|
14505
15073
|
// src/worktree-prompts.ts
|
|
@@ -14609,8 +15177,8 @@ function createCleanCommand(dependencies = {}) {
|
|
|
14609
15177
|
}
|
|
14610
15178
|
return 0;
|
|
14611
15179
|
}
|
|
14612
|
-
const removedPaths = [];
|
|
14613
15180
|
const removedWorktrees = [];
|
|
15181
|
+
const failures = [];
|
|
14614
15182
|
for (const worktree of selectedWorktrees) {
|
|
14615
15183
|
if (options.stale && !await isStaleCleanupCandidate(
|
|
14616
15184
|
repository.repoRoot,
|
|
@@ -14626,10 +15194,15 @@ function createCleanCommand(dependencies = {}) {
|
|
|
14626
15194
|
try {
|
|
14627
15195
|
await removeWorktree(repository.repoRoot, worktree.path);
|
|
14628
15196
|
} catch (error) {
|
|
14629
|
-
if (!
|
|
14630
|
-
|
|
15197
|
+
if (!isWorktreeForceRemovalError(error)) {
|
|
15198
|
+
failures.push({
|
|
15199
|
+
branch: worktree.branch,
|
|
15200
|
+
message: toMessage(error),
|
|
15201
|
+
path: worktree.path
|
|
15202
|
+
});
|
|
15203
|
+
continue;
|
|
14631
15204
|
}
|
|
14632
|
-
if (options.stale) {
|
|
15205
|
+
if (options.stale && !isWorktreeDeletionError(error)) {
|
|
14633
15206
|
options.stderr(
|
|
14634
15207
|
`Skipped ${worktree.path}: no longer a safe stale cleanup candidate
|
|
14635
15208
|
`
|
|
@@ -14637,24 +15210,24 @@ function createCleanCommand(dependencies = {}) {
|
|
|
14637
15210
|
continue;
|
|
14638
15211
|
}
|
|
14639
15212
|
if (!options.force && !await confirmForceRemoveWorktree(worktree.path)) {
|
|
14640
|
-
|
|
14641
|
-
|
|
14642
|
-
|
|
15213
|
+
failures.push({
|
|
15214
|
+
branch: worktree.branch,
|
|
15215
|
+
message: "force removal declined",
|
|
15216
|
+
path: worktree.path
|
|
15217
|
+
});
|
|
15218
|
+
continue;
|
|
14643
15219
|
}
|
|
14644
15220
|
try {
|
|
14645
15221
|
await forceRemoveWorktree(repository.repoRoot, worktree.path);
|
|
14646
15222
|
} catch (forceError) {
|
|
14647
|
-
|
|
14648
|
-
|
|
14649
|
-
|
|
14650
|
-
|
|
14651
|
-
|
|
14652
|
-
|
|
14653
|
-
);
|
|
14654
|
-
return 1;
|
|
15223
|
+
failures.push({
|
|
15224
|
+
branch: worktree.branch,
|
|
15225
|
+
message: toMessage(forceError),
|
|
15226
|
+
path: worktree.path
|
|
15227
|
+
});
|
|
15228
|
+
continue;
|
|
14655
15229
|
}
|
|
14656
15230
|
}
|
|
14657
|
-
removedPaths.push(worktree.path);
|
|
14658
15231
|
removedWorktrees.push(worktree);
|
|
14659
15232
|
if (worktree.branch) {
|
|
14660
15233
|
try {
|
|
@@ -14686,13 +15259,16 @@ function createCleanCommand(dependencies = {}) {
|
|
|
14686
15259
|
const info = selectedInfoByPath.get(worktree.path);
|
|
14687
15260
|
return info === void 0 ? { branch: worktree.branch, path: worktree.path } : serializeWorktreeInfo(info);
|
|
14688
15261
|
});
|
|
14689
|
-
|
|
15262
|
+
const payload = failures.length === 0 ? { removed } : { removed, failed: failures };
|
|
15263
|
+
options.stdout(`${JSON.stringify(payload, null, 2)}
|
|
14690
15264
|
`);
|
|
15265
|
+
} else if (failures.length > 0) {
|
|
15266
|
+
reportCleanFailures(failures, options.stderr);
|
|
14691
15267
|
} else {
|
|
14692
15268
|
options.stdout(`${repository.repoRoot}
|
|
14693
15269
|
`);
|
|
14694
15270
|
}
|
|
14695
|
-
return 0;
|
|
15271
|
+
return failures.length === 0 ? 0 : 1;
|
|
14696
15272
|
};
|
|
14697
15273
|
}
|
|
14698
15274
|
var runCleanCommand = createCleanCommand();
|
|
@@ -14769,9 +15345,13 @@ function resolveSelectedWorktrees(worktrees, selections) {
|
|
|
14769
15345
|
}
|
|
14770
15346
|
return selectedWorktrees;
|
|
14771
15347
|
}
|
|
14772
|
-
function
|
|
14773
|
-
|
|
14774
|
-
|
|
15348
|
+
function reportCleanFailures(failures, stderr) {
|
|
15349
|
+
const noun = failures.length === 1 ? "worktree" : "worktrees";
|
|
15350
|
+
stderr(`Failed to clean ${failures.length} ${noun}:
|
|
15351
|
+
`);
|
|
15352
|
+
for (const failure of failures) {
|
|
15353
|
+
const branch = failure.branch === null ? "detached" : failure.branch;
|
|
15354
|
+
stderr(`- ${failure.path} (${branch}): ${failure.message}
|
|
14775
15355
|
`);
|
|
14776
15356
|
}
|
|
14777
15357
|
}
|
|
@@ -15265,8 +15845,8 @@ async function runConfigCommand(options) {
|
|
|
15265
15845
|
`Invalid config arguments: ${[options.action, options.key, options.value].filter(Boolean).join(" ")}`
|
|
15266
15846
|
);
|
|
15267
15847
|
}
|
|
15268
|
-
function writeJson(
|
|
15269
|
-
|
|
15848
|
+
function writeJson(stdout2, value) {
|
|
15849
|
+
stdout2(`${JSON.stringify(value, null, 2)}
|
|
15270
15850
|
`);
|
|
15271
15851
|
}
|
|
15272
15852
|
|
|
@@ -16068,8 +16648,8 @@ async function localBranchExists(repoRoot, branchName) {
|
|
|
16068
16648
|
return false;
|
|
16069
16649
|
}
|
|
16070
16650
|
}
|
|
16071
|
-
async function writeOutput(worktreePath,
|
|
16072
|
-
await writeShellOutput(NEW_OUTPUT_FILE_ENV, worktreePath,
|
|
16651
|
+
async function writeOutput(worktreePath, stdout2) {
|
|
16652
|
+
await writeShellOutput(NEW_OUTPUT_FILE_ENV, worktreePath, stdout2);
|
|
16073
16653
|
}
|
|
16074
16654
|
function isNotRegisteredWorktreeError(error) {
|
|
16075
16655
|
const stderr = hasExecStderr(error) ? error.stderr : String(error);
|
|
@@ -17272,8 +17852,8 @@ function sourceRefForForge(forge, prNumber) {
|
|
|
17272
17852
|
return `refs/merge-requests/${prNumber}/head`;
|
|
17273
17853
|
}
|
|
17274
17854
|
}
|
|
17275
|
-
async function writeOutput2(worktreePath,
|
|
17276
|
-
await writeShellOutput(PR_OUTPUT_FILE_ENV, worktreePath,
|
|
17855
|
+
async function writeOutput2(worktreePath, stdout2) {
|
|
17856
|
+
await writeShellOutput(PR_OUTPUT_FILE_ENV, worktreePath, stdout2);
|
|
17277
17857
|
}
|
|
17278
17858
|
|
|
17279
17859
|
// src/remove.ts
|
|
@@ -17371,7 +17951,7 @@ function createRemoveCommand(dependencies = {}) {
|
|
|
17371
17951
|
try {
|
|
17372
17952
|
await removeWorktree(repository.repoRoot, worktree.path);
|
|
17373
17953
|
} catch (error) {
|
|
17374
|
-
if (!
|
|
17954
|
+
if (!isWorktreeForceRemovalError(error)) {
|
|
17375
17955
|
throw error;
|
|
17376
17956
|
}
|
|
17377
17957
|
if (!options.force && !await confirmForceRemoveWorktree(worktree.path)) {
|
|
@@ -17436,8 +18016,8 @@ async function defaultConfirmRemoval2(worktree) {
|
|
|
17436
18016
|
});
|
|
17437
18017
|
return !pD(choice) && choice;
|
|
17438
18018
|
}
|
|
17439
|
-
async function writeOutput3(repoRoot,
|
|
17440
|
-
await writeShellOutput(REMOVE_OUTPUT_FILE_ENV, repoRoot,
|
|
18019
|
+
async function writeOutput3(repoRoot, stdout2) {
|
|
18020
|
+
await writeShellOutput(REMOVE_OUTPUT_FILE_ENV, repoRoot, stdout2);
|
|
17441
18021
|
}
|
|
17442
18022
|
function emitError2(options, message) {
|
|
17443
18023
|
if (options.json) {
|
|
@@ -17810,17 +18390,17 @@ function readSyncFiles(config) {
|
|
|
17810
18390
|
if (!Array.isArray(syncFiles2)) return [];
|
|
17811
18391
|
return syncFiles2.filter((item) => typeof item === "string");
|
|
17812
18392
|
}
|
|
17813
|
-
function writeSyncFiles(
|
|
18393
|
+
function writeSyncFiles(stdout2, files, json) {
|
|
17814
18394
|
if (json) {
|
|
17815
|
-
|
|
18395
|
+
stdout2(`${JSON.stringify(files, null, 2)}
|
|
17816
18396
|
`);
|
|
17817
18397
|
return;
|
|
17818
18398
|
}
|
|
17819
18399
|
if (files.length === 0) {
|
|
17820
|
-
|
|
18400
|
+
stdout2("No sync files configured for this repo.\n");
|
|
17821
18401
|
return;
|
|
17822
18402
|
}
|
|
17823
|
-
|
|
18403
|
+
stdout2(`${files.join("\n")}
|
|
17824
18404
|
`);
|
|
17825
18405
|
}
|
|
17826
18406
|
function validatePaths(paths, options) {
|
|
@@ -17910,11 +18490,11 @@ async function runCli(argv, options = {}) {
|
|
|
17910
18490
|
maybeRegisterCurrentRepo(options.cwd ?? process.cwd());
|
|
17911
18491
|
const program2 = createProgram();
|
|
17912
18492
|
const cwd = options.cwd ?? process.cwd();
|
|
17913
|
-
const
|
|
18493
|
+
const stdout2 = options.stdout ?? (() => void 0);
|
|
17914
18494
|
const stderr = options.stderr ?? (() => void 0);
|
|
17915
18495
|
program2.configureOutput({
|
|
17916
18496
|
writeErr: stderr,
|
|
17917
|
-
writeOut:
|
|
18497
|
+
writeOut: stdout2
|
|
17918
18498
|
});
|
|
17919
18499
|
program2.exitOverride();
|
|
17920
18500
|
if (argv.length === 0) {
|
|
@@ -17922,7 +18502,7 @@ async function runCli(argv, options = {}) {
|
|
|
17922
18502
|
return { exitCode: 0 };
|
|
17923
18503
|
}
|
|
17924
18504
|
try {
|
|
17925
|
-
attachCommandActions(program2, { cwd, stderr, stdout });
|
|
18505
|
+
attachCommandActions(program2, { cwd, stderr, stdout: stdout2 });
|
|
17926
18506
|
await program2.parseAsync(["node", "gji", ...argv], { from: "node" });
|
|
17927
18507
|
return { exitCode: 0 };
|
|
17928
18508
|
} catch (error) {
|