@aku11i/phantom 0.7.0 → 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.
- package/dist/phantom.js +340 -94
- package/dist/phantom.js.map +4 -4
- package/package.json +1 -1
package/dist/phantom.js
CHANGED
|
@@ -995,6 +995,154 @@ ${message}`;
|
|
|
995
995
|
}
|
|
996
996
|
}
|
|
997
997
|
|
|
998
|
+
// src/core/utils/fzf.ts
|
|
999
|
+
import { spawn } from "node:child_process";
|
|
1000
|
+
async function selectWithFzf(items, options = {}) {
|
|
1001
|
+
return new Promise((resolve2) => {
|
|
1002
|
+
const args2 = [];
|
|
1003
|
+
if (options.prompt) {
|
|
1004
|
+
args2.push("--prompt", options.prompt);
|
|
1005
|
+
}
|
|
1006
|
+
if (options.header) {
|
|
1007
|
+
args2.push("--header", options.header);
|
|
1008
|
+
}
|
|
1009
|
+
if (options.previewCommand) {
|
|
1010
|
+
args2.push("--preview", options.previewCommand);
|
|
1011
|
+
}
|
|
1012
|
+
const fzf = spawn("fzf", args2, {
|
|
1013
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
1014
|
+
});
|
|
1015
|
+
let result = "";
|
|
1016
|
+
let errorOutput = "";
|
|
1017
|
+
fzf.stdout.on("data", (data) => {
|
|
1018
|
+
result += data.toString();
|
|
1019
|
+
});
|
|
1020
|
+
if (fzf.stderr) {
|
|
1021
|
+
fzf.stderr.on("data", (data) => {
|
|
1022
|
+
errorOutput += data.toString();
|
|
1023
|
+
});
|
|
1024
|
+
}
|
|
1025
|
+
fzf.on("error", (error) => {
|
|
1026
|
+
if (error.message.includes("ENOENT")) {
|
|
1027
|
+
resolve2(
|
|
1028
|
+
err(new Error("fzf command not found. Please install fzf first."))
|
|
1029
|
+
);
|
|
1030
|
+
} else {
|
|
1031
|
+
resolve2(err(error));
|
|
1032
|
+
}
|
|
1033
|
+
});
|
|
1034
|
+
fzf.on("close", (code) => {
|
|
1035
|
+
if (code === 0) {
|
|
1036
|
+
const selected = result.trim();
|
|
1037
|
+
resolve2(ok(selected || null));
|
|
1038
|
+
} else if (code === 1) {
|
|
1039
|
+
resolve2(ok(null));
|
|
1040
|
+
} else if (code === 130) {
|
|
1041
|
+
resolve2(ok(null));
|
|
1042
|
+
} else {
|
|
1043
|
+
resolve2(err(new Error(`fzf exited with code ${code}: ${errorOutput}`)));
|
|
1044
|
+
}
|
|
1045
|
+
});
|
|
1046
|
+
fzf.stdin.write(items.join("\n"));
|
|
1047
|
+
fzf.stdin.end();
|
|
1048
|
+
});
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
// src/core/worktree/list.ts
|
|
1052
|
+
async function getWorktreeStatus2(worktreePath) {
|
|
1053
|
+
try {
|
|
1054
|
+
const { stdout: stdout2 } = await executeGitCommandInDirectory(worktreePath, [
|
|
1055
|
+
"status",
|
|
1056
|
+
"--porcelain"
|
|
1057
|
+
]);
|
|
1058
|
+
return !stdout2;
|
|
1059
|
+
} catch {
|
|
1060
|
+
return true;
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
async function listWorktrees2(gitRoot) {
|
|
1064
|
+
try {
|
|
1065
|
+
const gitWorktrees = await listWorktrees(gitRoot);
|
|
1066
|
+
const phantomDir = getPhantomDirectory(gitRoot);
|
|
1067
|
+
const phantomWorktrees = gitWorktrees.filter(
|
|
1068
|
+
(worktree) => worktree.path.startsWith(phantomDir)
|
|
1069
|
+
);
|
|
1070
|
+
if (phantomWorktrees.length === 0) {
|
|
1071
|
+
return ok({
|
|
1072
|
+
worktrees: [],
|
|
1073
|
+
message: "No worktrees found"
|
|
1074
|
+
});
|
|
1075
|
+
}
|
|
1076
|
+
const worktrees = await Promise.all(
|
|
1077
|
+
phantomWorktrees.map(async (gitWorktree) => {
|
|
1078
|
+
const name = gitWorktree.path.substring(phantomDir.length + 1);
|
|
1079
|
+
const isClean = await getWorktreeStatus2(gitWorktree.path);
|
|
1080
|
+
return {
|
|
1081
|
+
name,
|
|
1082
|
+
path: gitWorktree.path,
|
|
1083
|
+
branch: gitWorktree.branch || "(detached HEAD)",
|
|
1084
|
+
isClean
|
|
1085
|
+
};
|
|
1086
|
+
})
|
|
1087
|
+
);
|
|
1088
|
+
return ok({
|
|
1089
|
+
worktrees
|
|
1090
|
+
});
|
|
1091
|
+
} catch (error) {
|
|
1092
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1093
|
+
throw new Error(`Failed to list worktrees: ${errorMessage}`);
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
// src/core/worktree/select.ts
|
|
1098
|
+
async function selectWorktreeWithFzf(gitRoot) {
|
|
1099
|
+
const listResult = await listWorktrees2(gitRoot);
|
|
1100
|
+
if (isErr(listResult)) {
|
|
1101
|
+
return listResult;
|
|
1102
|
+
}
|
|
1103
|
+
const { worktrees } = listResult.value;
|
|
1104
|
+
if (worktrees.length === 0) {
|
|
1105
|
+
return {
|
|
1106
|
+
ok: true,
|
|
1107
|
+
value: null
|
|
1108
|
+
};
|
|
1109
|
+
}
|
|
1110
|
+
const list = worktrees.map((wt) => {
|
|
1111
|
+
const branchInfo = wt.branch ? `(${wt.branch})` : "";
|
|
1112
|
+
const status = !wt.isClean ? " [dirty]" : "";
|
|
1113
|
+
return `${wt.name} ${branchInfo}${status}`;
|
|
1114
|
+
});
|
|
1115
|
+
const fzfResult = await selectWithFzf(list, {
|
|
1116
|
+
prompt: "Select worktree> ",
|
|
1117
|
+
header: "Git Worktrees (Phantoms)"
|
|
1118
|
+
});
|
|
1119
|
+
if (isErr(fzfResult)) {
|
|
1120
|
+
return fzfResult;
|
|
1121
|
+
}
|
|
1122
|
+
if (!fzfResult.value) {
|
|
1123
|
+
return {
|
|
1124
|
+
ok: true,
|
|
1125
|
+
value: null
|
|
1126
|
+
};
|
|
1127
|
+
}
|
|
1128
|
+
const selectedName = fzfResult.value.split(" ")[0];
|
|
1129
|
+
const selectedWorktree = worktrees.find((wt) => wt.name === selectedName);
|
|
1130
|
+
if (!selectedWorktree) {
|
|
1131
|
+
return {
|
|
1132
|
+
ok: false,
|
|
1133
|
+
error: new Error("Selected worktree not found")
|
|
1134
|
+
};
|
|
1135
|
+
}
|
|
1136
|
+
return {
|
|
1137
|
+
ok: true,
|
|
1138
|
+
value: {
|
|
1139
|
+
name: selectedWorktree.name,
|
|
1140
|
+
branch: selectedWorktree.branch,
|
|
1141
|
+
isClean: selectedWorktree.isClean
|
|
1142
|
+
}
|
|
1143
|
+
};
|
|
1144
|
+
}
|
|
1145
|
+
|
|
998
1146
|
// src/cli/handlers/delete.ts
|
|
999
1147
|
async function deleteHandler(args2) {
|
|
1000
1148
|
const { values, positionals } = parseArgs3({
|
|
@@ -1006,21 +1154,32 @@ async function deleteHandler(args2) {
|
|
|
1006
1154
|
},
|
|
1007
1155
|
current: {
|
|
1008
1156
|
type: "boolean"
|
|
1157
|
+
},
|
|
1158
|
+
fzf: {
|
|
1159
|
+
type: "boolean",
|
|
1160
|
+
default: false
|
|
1009
1161
|
}
|
|
1010
1162
|
},
|
|
1011
1163
|
strict: true,
|
|
1012
1164
|
allowPositionals: true
|
|
1013
1165
|
});
|
|
1014
1166
|
const deleteCurrent = values.current ?? false;
|
|
1015
|
-
|
|
1167
|
+
const useFzf = values.fzf ?? false;
|
|
1168
|
+
if (positionals.length === 0 && !deleteCurrent && !useFzf) {
|
|
1169
|
+
exitWithError(
|
|
1170
|
+
"Please provide a worktree name to delete, use --current to delete the current worktree, or use --fzf for interactive selection",
|
|
1171
|
+
exitCodes.validationError
|
|
1172
|
+
);
|
|
1173
|
+
}
|
|
1174
|
+
if ((positionals.length > 0 || useFzf) && deleteCurrent) {
|
|
1016
1175
|
exitWithError(
|
|
1017
|
-
"
|
|
1176
|
+
"Cannot specify --current with a worktree name or --fzf option",
|
|
1018
1177
|
exitCodes.validationError
|
|
1019
1178
|
);
|
|
1020
1179
|
}
|
|
1021
|
-
if (positionals.length > 0 &&
|
|
1180
|
+
if (positionals.length > 0 && useFzf) {
|
|
1022
1181
|
exitWithError(
|
|
1023
|
-
"Cannot specify both a worktree name and --
|
|
1182
|
+
"Cannot specify both a worktree name and --fzf option",
|
|
1024
1183
|
exitCodes.validationError
|
|
1025
1184
|
);
|
|
1026
1185
|
}
|
|
@@ -1037,6 +1196,15 @@ async function deleteHandler(args2) {
|
|
|
1037
1196
|
);
|
|
1038
1197
|
}
|
|
1039
1198
|
worktreeName = currentWorktree;
|
|
1199
|
+
} else if (useFzf) {
|
|
1200
|
+
const selectResult = await selectWorktreeWithFzf(gitRoot);
|
|
1201
|
+
if (isErr(selectResult)) {
|
|
1202
|
+
exitWithError(selectResult.error.message, exitCodes.generalError);
|
|
1203
|
+
}
|
|
1204
|
+
if (!selectResult.value) {
|
|
1205
|
+
exitWithSuccess();
|
|
1206
|
+
}
|
|
1207
|
+
worktreeName = selectResult.value.name;
|
|
1040
1208
|
} else {
|
|
1041
1209
|
worktreeName = positionals[0];
|
|
1042
1210
|
}
|
|
@@ -1096,78 +1264,45 @@ async function execHandler(args2) {
|
|
|
1096
1264
|
|
|
1097
1265
|
// src/cli/handlers/list.ts
|
|
1098
1266
|
import { parseArgs as parseArgs5 } from "node:util";
|
|
1099
|
-
|
|
1100
|
-
// src/core/worktree/list.ts
|
|
1101
|
-
async function getWorktreeStatus2(worktreePath) {
|
|
1102
|
-
try {
|
|
1103
|
-
const { stdout: stdout2 } = await executeGitCommandInDirectory(worktreePath, [
|
|
1104
|
-
"status",
|
|
1105
|
-
"--porcelain"
|
|
1106
|
-
]);
|
|
1107
|
-
return !stdout2;
|
|
1108
|
-
} catch {
|
|
1109
|
-
return true;
|
|
1110
|
-
}
|
|
1111
|
-
}
|
|
1112
|
-
async function listWorktrees2(gitRoot) {
|
|
1113
|
-
try {
|
|
1114
|
-
const gitWorktrees = await listWorktrees(gitRoot);
|
|
1115
|
-
const phantomDir = getPhantomDirectory(gitRoot);
|
|
1116
|
-
const phantomWorktrees = gitWorktrees.filter(
|
|
1117
|
-
(worktree) => worktree.path.startsWith(phantomDir)
|
|
1118
|
-
);
|
|
1119
|
-
if (phantomWorktrees.length === 0) {
|
|
1120
|
-
return ok({
|
|
1121
|
-
worktrees: [],
|
|
1122
|
-
message: "No worktrees found"
|
|
1123
|
-
});
|
|
1124
|
-
}
|
|
1125
|
-
const worktrees = await Promise.all(
|
|
1126
|
-
phantomWorktrees.map(async (gitWorktree) => {
|
|
1127
|
-
const name = gitWorktree.path.substring(phantomDir.length + 1);
|
|
1128
|
-
const isClean = await getWorktreeStatus2(gitWorktree.path);
|
|
1129
|
-
return {
|
|
1130
|
-
name,
|
|
1131
|
-
path: gitWorktree.path,
|
|
1132
|
-
branch: gitWorktree.branch || "(detached HEAD)",
|
|
1133
|
-
isClean
|
|
1134
|
-
};
|
|
1135
|
-
})
|
|
1136
|
-
);
|
|
1137
|
-
return ok({
|
|
1138
|
-
worktrees
|
|
1139
|
-
});
|
|
1140
|
-
} catch (error) {
|
|
1141
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1142
|
-
throw new Error(`Failed to list worktrees: ${errorMessage}`);
|
|
1143
|
-
}
|
|
1144
|
-
}
|
|
1145
|
-
|
|
1146
|
-
// src/cli/handlers/list.ts
|
|
1147
1267
|
async function listHandler(args2 = []) {
|
|
1148
|
-
parseArgs5({
|
|
1268
|
+
const { values } = parseArgs5({
|
|
1149
1269
|
args: args2,
|
|
1150
|
-
options: {
|
|
1270
|
+
options: {
|
|
1271
|
+
fzf: {
|
|
1272
|
+
type: "boolean",
|
|
1273
|
+
default: false
|
|
1274
|
+
}
|
|
1275
|
+
},
|
|
1151
1276
|
strict: true,
|
|
1152
1277
|
allowPositionals: false
|
|
1153
1278
|
});
|
|
1154
1279
|
try {
|
|
1155
1280
|
const gitRoot = await getGitRoot();
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
}
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
const
|
|
1170
|
-
|
|
1281
|
+
if (values.fzf) {
|
|
1282
|
+
const selectResult = await selectWorktreeWithFzf(gitRoot);
|
|
1283
|
+
if (isErr(selectResult)) {
|
|
1284
|
+
exitWithError(selectResult.error.message, exitCodes.generalError);
|
|
1285
|
+
}
|
|
1286
|
+
if (selectResult.value) {
|
|
1287
|
+
output.log(selectResult.value.name);
|
|
1288
|
+
}
|
|
1289
|
+
} else {
|
|
1290
|
+
const result = await listWorktrees2(gitRoot);
|
|
1291
|
+
if (isErr(result)) {
|
|
1292
|
+
exitWithError("Failed to list worktrees", exitCodes.generalError);
|
|
1293
|
+
}
|
|
1294
|
+
const { worktrees, message } = result.value;
|
|
1295
|
+
if (worktrees.length === 0) {
|
|
1296
|
+
output.log(message || "No worktrees found.");
|
|
1297
|
+
process.exit(exitCodes.success);
|
|
1298
|
+
}
|
|
1299
|
+
const maxNameLength = Math.max(...worktrees.map((wt) => wt.name.length));
|
|
1300
|
+
for (const worktree of worktrees) {
|
|
1301
|
+
const paddedName = worktree.name.padEnd(maxNameLength + 2);
|
|
1302
|
+
const branchInfo = worktree.branch ? `(${worktree.branch})` : "";
|
|
1303
|
+
const status = !worktree.isClean ? " [dirty]" : "";
|
|
1304
|
+
output.log(`${paddedName} ${branchInfo}${status}`);
|
|
1305
|
+
}
|
|
1171
1306
|
}
|
|
1172
1307
|
process.exit(exitCodes.success);
|
|
1173
1308
|
} catch (error) {
|
|
@@ -1181,21 +1316,45 @@ async function listHandler(args2 = []) {
|
|
|
1181
1316
|
// src/cli/handlers/shell.ts
|
|
1182
1317
|
import { parseArgs as parseArgs6 } from "node:util";
|
|
1183
1318
|
async function shellHandler(args2) {
|
|
1184
|
-
const { positionals } = parseArgs6({
|
|
1319
|
+
const { positionals, values } = parseArgs6({
|
|
1185
1320
|
args: args2,
|
|
1186
|
-
options: {
|
|
1321
|
+
options: {
|
|
1322
|
+
fzf: {
|
|
1323
|
+
type: "boolean",
|
|
1324
|
+
default: false
|
|
1325
|
+
}
|
|
1326
|
+
},
|
|
1187
1327
|
strict: true,
|
|
1188
1328
|
allowPositionals: true
|
|
1189
1329
|
});
|
|
1190
|
-
|
|
1330
|
+
const useFzf = values.fzf ?? false;
|
|
1331
|
+
if (positionals.length === 0 && !useFzf) {
|
|
1191
1332
|
exitWithError(
|
|
1192
|
-
"Usage: phantom shell <worktree-name>",
|
|
1333
|
+
"Usage: phantom shell <worktree-name> or phantom shell --fzf",
|
|
1193
1334
|
exitCodes.validationError
|
|
1194
1335
|
);
|
|
1195
1336
|
}
|
|
1196
|
-
|
|
1337
|
+
if (positionals.length > 0 && useFzf) {
|
|
1338
|
+
exitWithError(
|
|
1339
|
+
"Cannot specify both a worktree name and --fzf option",
|
|
1340
|
+
exitCodes.validationError
|
|
1341
|
+
);
|
|
1342
|
+
}
|
|
1343
|
+
let worktreeName;
|
|
1197
1344
|
try {
|
|
1198
1345
|
const gitRoot = await getGitRoot();
|
|
1346
|
+
if (useFzf) {
|
|
1347
|
+
const selectResult = await selectWorktreeWithFzf(gitRoot);
|
|
1348
|
+
if (isErr(selectResult)) {
|
|
1349
|
+
exitWithError(selectResult.error.message, exitCodes.generalError);
|
|
1350
|
+
}
|
|
1351
|
+
if (!selectResult.value) {
|
|
1352
|
+
exitWithSuccess();
|
|
1353
|
+
}
|
|
1354
|
+
worktreeName = selectResult.value.name;
|
|
1355
|
+
} else {
|
|
1356
|
+
worktreeName = positionals[0];
|
|
1357
|
+
}
|
|
1199
1358
|
const validation = await validateWorktreeExists(gitRoot, worktreeName);
|
|
1200
1359
|
if (!validation.exists) {
|
|
1201
1360
|
exitWithError(
|
|
@@ -1226,7 +1385,7 @@ import { parseArgs as parseArgs7 } from "node:util";
|
|
|
1226
1385
|
var package_default = {
|
|
1227
1386
|
name: "@aku11i/phantom",
|
|
1228
1387
|
packageManager: "pnpm@10.8.1",
|
|
1229
|
-
version: "0.
|
|
1388
|
+
version: "0.8.0",
|
|
1230
1389
|
description: "A powerful CLI tool for managing Git worktrees for parallel development",
|
|
1231
1390
|
keywords: [
|
|
1232
1391
|
"git",
|
|
@@ -1316,30 +1475,58 @@ async function whereWorktree(gitRoot, name) {
|
|
|
1316
1475
|
|
|
1317
1476
|
// src/cli/handlers/where.ts
|
|
1318
1477
|
async function whereHandler(args2) {
|
|
1319
|
-
const { positionals } = parseArgs8({
|
|
1478
|
+
const { positionals, values } = parseArgs8({
|
|
1320
1479
|
args: args2,
|
|
1321
|
-
options: {
|
|
1480
|
+
options: {
|
|
1481
|
+
fzf: {
|
|
1482
|
+
type: "boolean",
|
|
1483
|
+
default: false
|
|
1484
|
+
}
|
|
1485
|
+
},
|
|
1322
1486
|
strict: true,
|
|
1323
1487
|
allowPositionals: true
|
|
1324
1488
|
});
|
|
1325
|
-
|
|
1326
|
-
|
|
1489
|
+
const useFzf = values.fzf ?? false;
|
|
1490
|
+
if (positionals.length === 0 && !useFzf) {
|
|
1491
|
+
exitWithError(
|
|
1492
|
+
"Usage: phantom where <worktree-name> or phantom where --fzf",
|
|
1493
|
+
exitCodes.validationError
|
|
1494
|
+
);
|
|
1327
1495
|
}
|
|
1328
|
-
|
|
1496
|
+
if (positionals.length > 0 && useFzf) {
|
|
1497
|
+
exitWithError(
|
|
1498
|
+
"Cannot specify both a worktree name and --fzf option",
|
|
1499
|
+
exitCodes.validationError
|
|
1500
|
+
);
|
|
1501
|
+
}
|
|
1502
|
+
let worktreeName;
|
|
1503
|
+
let gitRoot;
|
|
1329
1504
|
try {
|
|
1330
|
-
|
|
1331
|
-
const result = await whereWorktree(gitRoot, worktreeName);
|
|
1332
|
-
if (isErr(result)) {
|
|
1333
|
-
exitWithError(result.error.message, exitCodes.notFound);
|
|
1334
|
-
}
|
|
1335
|
-
output.log(result.value.path);
|
|
1336
|
-
exitWithSuccess();
|
|
1505
|
+
gitRoot = await getGitRoot();
|
|
1337
1506
|
} catch (error) {
|
|
1338
1507
|
exitWithError(
|
|
1339
1508
|
error instanceof Error ? error.message : String(error),
|
|
1340
1509
|
exitCodes.generalError
|
|
1341
1510
|
);
|
|
1342
1511
|
}
|
|
1512
|
+
if (useFzf) {
|
|
1513
|
+
const selectResult = await selectWorktreeWithFzf(gitRoot);
|
|
1514
|
+
if (isErr(selectResult)) {
|
|
1515
|
+
exitWithError(selectResult.error.message, exitCodes.generalError);
|
|
1516
|
+
}
|
|
1517
|
+
if (!selectResult.value) {
|
|
1518
|
+
exitWithSuccess();
|
|
1519
|
+
}
|
|
1520
|
+
worktreeName = selectResult.value.name;
|
|
1521
|
+
} else {
|
|
1522
|
+
worktreeName = positionals[0];
|
|
1523
|
+
}
|
|
1524
|
+
const result = await whereWorktree(gitRoot, worktreeName);
|
|
1525
|
+
if (isErr(result)) {
|
|
1526
|
+
exitWithError(result.error.message, exitCodes.notFound);
|
|
1527
|
+
}
|
|
1528
|
+
output.log(result.value.path);
|
|
1529
|
+
exitWithSuccess();
|
|
1343
1530
|
}
|
|
1344
1531
|
|
|
1345
1532
|
// src/cli/help.ts
|
|
@@ -1611,6 +1798,16 @@ var deleteHelp = {
|
|
|
1611
1798
|
short: "f",
|
|
1612
1799
|
type: "boolean",
|
|
1613
1800
|
description: "Force deletion even if the worktree has uncommitted or unpushed changes"
|
|
1801
|
+
},
|
|
1802
|
+
{
|
|
1803
|
+
name: "--current",
|
|
1804
|
+
type: "boolean",
|
|
1805
|
+
description: "Delete the current worktree"
|
|
1806
|
+
},
|
|
1807
|
+
{
|
|
1808
|
+
name: "--fzf",
|
|
1809
|
+
type: "boolean",
|
|
1810
|
+
description: "Use fzf for interactive selection"
|
|
1614
1811
|
}
|
|
1615
1812
|
],
|
|
1616
1813
|
examples: [
|
|
@@ -1621,11 +1818,20 @@ var deleteHelp = {
|
|
|
1621
1818
|
{
|
|
1622
1819
|
description: "Force delete a worktree with uncommitted changes",
|
|
1623
1820
|
command: "phantom delete experimental --force"
|
|
1821
|
+
},
|
|
1822
|
+
{
|
|
1823
|
+
description: "Delete the current worktree",
|
|
1824
|
+
command: "phantom delete --current"
|
|
1825
|
+
},
|
|
1826
|
+
{
|
|
1827
|
+
description: "Delete a worktree with interactive fzf selection",
|
|
1828
|
+
command: "phantom delete --fzf"
|
|
1624
1829
|
}
|
|
1625
1830
|
],
|
|
1626
1831
|
notes: [
|
|
1627
1832
|
"By default, deletion will fail if the worktree has uncommitted changes",
|
|
1628
|
-
"The associated branch will also be deleted if it's not checked out elsewhere"
|
|
1833
|
+
"The associated branch will also be deleted if it's not checked out elsewhere",
|
|
1834
|
+
"With --fzf, you can interactively select the worktree to delete"
|
|
1629
1835
|
]
|
|
1630
1836
|
};
|
|
1631
1837
|
|
|
@@ -1659,16 +1865,28 @@ var execHelp = {
|
|
|
1659
1865
|
var listHelp = {
|
|
1660
1866
|
name: "list",
|
|
1661
1867
|
description: "List all Git worktrees (phantoms)",
|
|
1662
|
-
usage: "phantom list",
|
|
1868
|
+
usage: "phantom list [options]",
|
|
1869
|
+
options: [
|
|
1870
|
+
{
|
|
1871
|
+
name: "--fzf",
|
|
1872
|
+
type: "boolean",
|
|
1873
|
+
description: "Use fzf for interactive selection"
|
|
1874
|
+
}
|
|
1875
|
+
],
|
|
1663
1876
|
examples: [
|
|
1664
1877
|
{
|
|
1665
1878
|
description: "List all worktrees",
|
|
1666
1879
|
command: "phantom list"
|
|
1880
|
+
},
|
|
1881
|
+
{
|
|
1882
|
+
description: "List worktrees with interactive fzf selection",
|
|
1883
|
+
command: "phantom list --fzf"
|
|
1667
1884
|
}
|
|
1668
1885
|
],
|
|
1669
1886
|
notes: [
|
|
1670
1887
|
"Shows all worktrees with their paths and associated branches",
|
|
1671
|
-
"The main worktree is marked as '(bare)' if using a bare repository"
|
|
1888
|
+
"The main worktree is marked as '(bare)' if using a bare repository",
|
|
1889
|
+
"With --fzf, outputs only the selected worktree name"
|
|
1672
1890
|
]
|
|
1673
1891
|
};
|
|
1674
1892
|
|
|
@@ -1676,17 +1894,29 @@ var listHelp = {
|
|
|
1676
1894
|
var shellHelp = {
|
|
1677
1895
|
name: "shell",
|
|
1678
1896
|
description: "Open an interactive shell in a worktree directory",
|
|
1679
|
-
usage: "phantom shell <worktree-name>",
|
|
1897
|
+
usage: "phantom shell <worktree-name> [options]",
|
|
1898
|
+
options: [
|
|
1899
|
+
{
|
|
1900
|
+
name: "--fzf",
|
|
1901
|
+
type: "boolean",
|
|
1902
|
+
description: "Use fzf for interactive selection"
|
|
1903
|
+
}
|
|
1904
|
+
],
|
|
1680
1905
|
examples: [
|
|
1681
1906
|
{
|
|
1682
1907
|
description: "Open a shell in a worktree",
|
|
1683
1908
|
command: "phantom shell feature-auth"
|
|
1909
|
+
},
|
|
1910
|
+
{
|
|
1911
|
+
description: "Open a shell with interactive fzf selection",
|
|
1912
|
+
command: "phantom shell --fzf"
|
|
1684
1913
|
}
|
|
1685
1914
|
],
|
|
1686
1915
|
notes: [
|
|
1687
1916
|
"Uses your default shell from the SHELL environment variable",
|
|
1688
1917
|
"The shell starts with the worktree directory as the working directory",
|
|
1689
|
-
"Type 'exit' to return to your original directory"
|
|
1918
|
+
"Type 'exit' to return to your original directory",
|
|
1919
|
+
"With --fzf, you can interactively select the worktree to enter"
|
|
1690
1920
|
]
|
|
1691
1921
|
};
|
|
1692
1922
|
|
|
@@ -1708,7 +1938,14 @@ var versionHelp = {
|
|
|
1708
1938
|
var whereHelp = {
|
|
1709
1939
|
name: "where",
|
|
1710
1940
|
description: "Output the filesystem path of a specific worktree",
|
|
1711
|
-
usage: "phantom where <worktree-name>",
|
|
1941
|
+
usage: "phantom where <worktree-name> [options]",
|
|
1942
|
+
options: [
|
|
1943
|
+
{
|
|
1944
|
+
name: "--fzf",
|
|
1945
|
+
type: "boolean",
|
|
1946
|
+
description: "Use fzf for interactive selection"
|
|
1947
|
+
}
|
|
1948
|
+
],
|
|
1712
1949
|
examples: [
|
|
1713
1950
|
{
|
|
1714
1951
|
description: "Get the path of a worktree",
|
|
@@ -1717,11 +1954,20 @@ var whereHelp = {
|
|
|
1717
1954
|
{
|
|
1718
1955
|
description: "Change directory to a worktree",
|
|
1719
1956
|
command: "cd $(phantom where staging)"
|
|
1957
|
+
},
|
|
1958
|
+
{
|
|
1959
|
+
description: "Get path with interactive fzf selection",
|
|
1960
|
+
command: "phantom where --fzf"
|
|
1961
|
+
},
|
|
1962
|
+
{
|
|
1963
|
+
description: "Change directory using fzf selection",
|
|
1964
|
+
command: "cd $(phantom where --fzf)"
|
|
1720
1965
|
}
|
|
1721
1966
|
],
|
|
1722
1967
|
notes: [
|
|
1723
1968
|
"Outputs only the path, making it suitable for use in scripts",
|
|
1724
|
-
"Exits with an error code if the worktree doesn't exist"
|
|
1969
|
+
"Exits with an error code if the worktree doesn't exist",
|
|
1970
|
+
"With --fzf, you can interactively select the worktree"
|
|
1725
1971
|
]
|
|
1726
1972
|
};
|
|
1727
1973
|
|
package/dist/phantom.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/bin/phantom.ts", "../src/cli/handlers/attach.ts", "../src/core/git/libs/get-git-root.ts", "../src/core/git/executor.ts", "../src/core/types/result.ts", "../src/core/worktree/errors.ts", "../src/core/worktree/validate.ts", "../src/core/paths.ts", "../src/core/process/spawn.ts", "../src/core/process/errors.ts", "../src/core/process/exec.ts", "../src/core/process/shell.ts", "../src/core/worktree/attach.ts", "../src/core/git/libs/attach-worktree.ts", "../src/core/git/libs/branch-exists.ts", "../src/cli/output.ts", "../src/cli/errors.ts", "../src/cli/handlers/create.ts", "../src/core/config/loader.ts", "../src/core/utils/type-guards.ts", "../src/core/config/validate.ts", "../src/core/process/tmux.ts", "../src/core/worktree/create.ts", "../src/core/git/libs/add-worktree.ts", "../src/core/worktree/file-copier.ts", "../src/cli/handlers/delete.ts", "../src/core/git/libs/list-worktrees.ts", "../src/core/git/libs/get-current-worktree.ts", "../src/core/worktree/delete.ts", "../src/
|
|
4
|
-
"sourcesContent": ["#!/usr/bin/env node\n\nimport { argv, exit } from \"node:process\";\nimport { attachHandler } from \"../cli/handlers/attach.ts\";\nimport { createHandler } from \"../cli/handlers/create.ts\";\nimport { deleteHandler } from \"../cli/handlers/delete.ts\";\nimport { execHandler } from \"../cli/handlers/exec.ts\";\nimport { listHandler } from \"../cli/handlers/list.ts\";\nimport { shellHandler } from \"../cli/handlers/shell.ts\";\nimport { versionHandler } from \"../cli/handlers/version.ts\";\nimport { whereHandler } from \"../cli/handlers/where.ts\";\nimport { type CommandHelp, helpFormatter } from \"../cli/help.ts\";\nimport { attachHelp } from \"../cli/help/attach.ts\";\nimport { createHelp } from \"../cli/help/create.ts\";\nimport { deleteHelp } from \"../cli/help/delete.ts\";\nimport { execHelp } from \"../cli/help/exec.ts\";\nimport { listHelp } from \"../cli/help/list.ts\";\nimport { shellHelp } from \"../cli/help/shell.ts\";\nimport { versionHelp } from \"../cli/help/version.ts\";\nimport { whereHelp } from \"../cli/help/where.ts\";\n\ninterface Command {\n name: string;\n description: string;\n subcommands?: Command[];\n handler?: (args: string[]) => void | Promise<void>;\n help?: CommandHelp;\n}\n\nconst commands: Command[] = [\n {\n name: \"create\",\n description: \"Create a new Git worktree (phantom)\",\n handler: createHandler,\n help: createHelp,\n },\n {\n name: \"attach\",\n description: \"Attach to an existing branch by creating a new worktree\",\n handler: attachHandler,\n help: attachHelp,\n },\n {\n name: \"list\",\n description: \"List all Git worktrees (phantoms)\",\n handler: listHandler,\n help: listHelp,\n },\n {\n name: \"where\",\n description: \"Output the filesystem path of a specific worktree\",\n handler: whereHandler,\n help: whereHelp,\n },\n {\n name: \"delete\",\n description: \"Delete a Git worktree (phantom)\",\n handler: deleteHandler,\n help: deleteHelp,\n },\n {\n name: \"exec\",\n description: \"Execute a command in a worktree directory\",\n handler: execHandler,\n help: execHelp,\n },\n {\n name: \"shell\",\n description: \"Open an interactive shell in a worktree directory\",\n handler: shellHandler,\n help: shellHelp,\n },\n {\n name: \"version\",\n description: \"Display phantom version information\",\n handler: versionHandler,\n help: versionHelp,\n },\n];\n\nfunction printHelp(commands: Command[]) {\n const simpleCommands = commands.map((cmd) => ({\n name: cmd.name,\n description: cmd.description,\n }));\n console.log(helpFormatter.formatMainHelp(simpleCommands));\n}\n\nfunction findCommand(\n args: string[],\n commands: Command[],\n): { command: Command | null; remainingArgs: string[] } {\n if (args.length === 0) {\n return { command: null, remainingArgs: [] };\n }\n\n const [cmdName, ...rest] = args;\n const command = commands.find((cmd) => cmd.name === cmdName);\n\n if (!command) {\n return { command: null, remainingArgs: args };\n }\n\n if (command.subcommands && rest.length > 0) {\n const { command: subcommand, remainingArgs } = findCommand(\n rest,\n command.subcommands,\n );\n if (subcommand) {\n return { command: subcommand, remainingArgs };\n }\n }\n\n return { command, remainingArgs: rest };\n}\n\nconst args = argv.slice(2);\n\nif (args.length === 0 || args[0] === \"-h\" || args[0] === \"--help\") {\n printHelp(commands);\n exit(0);\n}\n\nif (args[0] === \"--version\" || args[0] === \"-v\") {\n versionHandler();\n exit(0);\n}\n\nconst { command, remainingArgs } = findCommand(args, commands);\n\nif (!command || !command.handler) {\n console.error(`Error: Unknown command '${args.join(\" \")}'\\n`);\n printHelp(commands);\n exit(1);\n}\n\n// Check if user is requesting help for a specific command\nif (remainingArgs.includes(\"--help\") || remainingArgs.includes(\"-h\")) {\n if (command.help) {\n console.log(helpFormatter.formatCommandHelp(command.help));\n } else {\n console.log(`Help not available for command '${command.name}'`);\n }\n exit(0);\n}\n\ntry {\n await command.handler(remainingArgs);\n} catch (error) {\n console.error(\n \"Error:\",\n error instanceof Error ? error.message : String(error),\n );\n exit(1);\n}\n", "import { parseArgs } from \"node:util\";\nimport { getGitRoot } from \"../../core/git/libs/get-git-root.ts\";\nimport { execInWorktree } from \"../../core/process/exec.ts\";\nimport { shellInWorktree } from \"../../core/process/shell.ts\";\nimport { isErr } from \"../../core/types/result.ts\";\nimport { attachWorktreeCore } from \"../../core/worktree/attach.ts\";\nimport {\n BranchNotFoundError,\n WorktreeAlreadyExistsError,\n} from \"../../core/worktree/errors.ts\";\nimport { exitCodes, exitWithError } from \"../errors.ts\";\nimport { output } from \"../output.ts\";\n\nexport async function attachHandler(args: string[]): Promise<void> {\n const { positionals, values } = parseArgs({\n args,\n strict: true,\n allowPositionals: true,\n options: {\n shell: {\n type: \"boolean\",\n short: \"s\",\n },\n exec: {\n type: \"string\",\n short: \"e\",\n },\n },\n });\n\n if (positionals.length === 0) {\n exitWithError(\n \"Missing required argument: branch name\",\n exitCodes.validationError,\n );\n }\n\n const [branchName] = positionals;\n\n if (values.shell && values.exec) {\n exitWithError(\n \"Cannot use both --shell and --exec options\",\n exitCodes.validationError,\n );\n }\n\n const gitRoot = await getGitRoot();\n const result = await attachWorktreeCore(gitRoot, branchName);\n\n if (isErr(result)) {\n const error = result.error;\n if (error instanceof WorktreeAlreadyExistsError) {\n exitWithError(error.message, exitCodes.validationError);\n }\n if (error instanceof BranchNotFoundError) {\n exitWithError(error.message, exitCodes.notFound);\n }\n exitWithError(error.message, exitCodes.generalError);\n }\n\n const worktreePath = result.value;\n output.log(`Attached phantom: ${branchName}`);\n\n if (values.shell) {\n const shellResult = await shellInWorktree(gitRoot, branchName);\n if (isErr(shellResult)) {\n exitWithError(shellResult.error.message, exitCodes.generalError);\n }\n } else if (values.exec) {\n const execResult = await execInWorktree(\n gitRoot,\n branchName,\n values.exec.split(\" \"),\n { interactive: true },\n );\n if (isErr(execResult)) {\n exitWithError(execResult.error.message, exitCodes.generalError);\n }\n }\n}\n", "import { dirname, resolve } from \"node:path\";\nimport { executeGitCommand } from \"../executor.ts\";\n\nexport async function getGitRoot(): Promise<string> {\n const { stdout } = await executeGitCommand([\"rev-parse\", \"--git-common-dir\"]);\n\n if (stdout.endsWith(\"/.git\") || stdout === \".git\") {\n return resolve(process.cwd(), dirname(stdout));\n }\n\n const { stdout: toplevel } = await executeGitCommand([\n \"rev-parse\",\n \"--show-toplevel\",\n ]);\n return toplevel;\n}\n", "import { execFile as execFileCallback } from \"node:child_process\";\nimport { promisify } from \"node:util\";\n\nconst execFile = promisify(execFileCallback);\n\nexport interface GitExecutorOptions {\n cwd?: string;\n env?: NodeJS.ProcessEnv;\n}\n\nexport interface GitExecutorResult {\n stdout: string;\n stderr: string;\n}\n\n/**\n * Execute a git command with consistent error handling\n */\nexport async function executeGitCommand(\n args: string[],\n options: GitExecutorOptions = {},\n): Promise<GitExecutorResult> {\n try {\n const result = await execFile(\"git\", args, {\n cwd: options.cwd,\n env: options.env || process.env,\n encoding: \"utf8\",\n });\n\n return {\n stdout: result.stdout.trim(),\n stderr: result.stderr.trim(),\n };\n } catch (error) {\n // Git commands often return non-zero exit codes for normal operations\n // (e.g., `git diff` returns 1 when there are differences)\n // So we need to handle errors carefully\n if (\n error &&\n typeof error === \"object\" &&\n \"stdout\" in error &&\n \"stderr\" in error\n ) {\n const execError = error as {\n stdout: string;\n stderr: string;\n code?: number;\n };\n\n // If we have stderr content, it's likely a real error\n if (execError.stderr?.trim()) {\n throw new Error(execError.stderr.trim());\n }\n\n // Otherwise, return the output even though the exit code was non-zero\n return {\n stdout: execError.stdout?.trim() || \"\",\n stderr: execError.stderr?.trim() || \"\",\n };\n }\n\n throw error;\n }\n}\n\n/**\n * Execute a git command in a specific directory\n */\nexport async function executeGitCommandInDirectory(\n directory: string,\n args: string[],\n): Promise<GitExecutorResult> {\n return executeGitCommand([\"-C\", directory, ...args], {});\n}\n", "/**\n * Represents a value that is either successful (Ok) or contains an error (Err).\n * This type is inspired by Rust's Result type and provides type-safe error handling.\n *\n * @template T - The type of the success value\n * @template E - The type of the error value (defaults to Error)\n */\nexport type Result<T, E = Error> =\n | { ok: true; value: T }\n | { ok: false; error: E };\n\n/**\n * Creates a successful Result containing the given value.\n *\n * @template T - The type of the success value\n * @param value - The success value to wrap\n * @returns A Result in the Ok state containing the value\n *\n * @example\n * const result = ok(42);\n * // result: Result<number, never> = { ok: true, value: 42 }\n */\nexport const ok = <T>(value: T): Result<T, never> => ({\n ok: true,\n value,\n});\n\n/**\n * Creates a failed Result containing the given error.\n *\n * @template E - The type of the error value\n * @param error - The error value to wrap\n * @returns A Result in the Err state containing the error\n *\n * @example\n * const result = err(new Error(\"Something went wrong\"));\n * // result: Result<never, Error> = { ok: false, error: Error(...) }\n */\nexport const err = <E>(error: E): Result<never, E> => ({\n ok: false,\n error,\n});\n\n/**\n * Type guard that checks if a Result is in the Ok state.\n *\n * @template T - The type of the success value\n * @template E - The type of the error value\n * @param result - The Result to check\n * @returns True if the Result is Ok, false otherwise\n *\n * @example\n * if (isOk(result)) {\n * console.log(result.value); // TypeScript knows result.value exists\n * }\n */\nexport const isOk = <T, E>(\n result: Result<T, E>,\n): result is { ok: true; value: T } => result.ok;\n\n/**\n * Type guard that checks if a Result is in the Err state.\n *\n * @template T - The type of the success value\n * @template E - The type of the error value\n * @param result - The Result to check\n * @returns True if the Result is Err, false otherwise\n *\n * @example\n * if (isErr(result)) {\n * console.error(result.error); // TypeScript knows result.error exists\n * }\n */\nexport const isErr = <T, E>(\n result: Result<T, E>,\n): result is { ok: false; error: E } => !result.ok;\n", "export class WorktreeError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"WorktreeError\";\n }\n}\n\nexport class WorktreeNotFoundError extends WorktreeError {\n constructor(name: string) {\n super(`Worktree '${name}' not found`);\n this.name = \"WorktreeNotFoundError\";\n }\n}\n\nexport class WorktreeAlreadyExistsError extends WorktreeError {\n constructor(name: string) {\n super(`Worktree '${name}' already exists`);\n this.name = \"WorktreeAlreadyExistsError\";\n }\n}\n\nexport class InvalidWorktreeNameError extends WorktreeError {\n constructor(name: string) {\n super(`Invalid worktree name: '${name}'`);\n this.name = \"InvalidWorktreeNameError\";\n }\n}\n\nexport class GitOperationError extends WorktreeError {\n constructor(operation: string, details: string) {\n super(`Git ${operation} failed: ${details}`);\n this.name = \"GitOperationError\";\n }\n}\n\nexport class BranchNotFoundError extends WorktreeError {\n constructor(branchName: string) {\n super(`Branch '${branchName}' not found`);\n this.name = \"BranchNotFoundError\";\n }\n}\n", "import fs from \"node:fs/promises\";\nimport { getPhantomDirectory, getWorktreePath } from \"../paths.ts\";\nimport { type Result, err, ok } from \"../types/result.ts\";\n\nexport interface ValidationResult {\n exists: boolean;\n path?: string;\n message?: string;\n}\n\nexport async function validateWorktreeExists(\n gitRoot: string,\n name: string,\n): Promise<ValidationResult> {\n const worktreePath = getWorktreePath(gitRoot, name);\n\n try {\n await fs.access(worktreePath);\n return {\n exists: true,\n path: worktreePath,\n };\n } catch {\n return {\n exists: false,\n message: `Worktree '${name}' does not exist`,\n };\n }\n}\n\nexport async function validateWorktreeDoesNotExist(\n gitRoot: string,\n name: string,\n): Promise<ValidationResult> {\n const worktreePath = getWorktreePath(gitRoot, name);\n\n try {\n await fs.access(worktreePath);\n return {\n exists: true,\n message: `Worktree '${name}' already exists`,\n };\n } catch {\n return {\n exists: false,\n path: worktreePath,\n };\n }\n}\n\nexport async function validatePhantomDirectoryExists(\n gitRoot: string,\n): Promise<boolean> {\n const phantomDir = getPhantomDirectory(gitRoot);\n\n try {\n await fs.access(phantomDir);\n return true;\n } catch {\n return false;\n }\n}\n\nexport function validateWorktreeName(name: string): Result<void, Error> {\n if (!name || name.trim() === \"\") {\n return err(new Error(\"Phantom name cannot be empty\"));\n }\n\n if (name.includes(\"/\")) {\n return err(new Error(\"Phantom name cannot contain slashes\"));\n }\n\n if (name.startsWith(\".\")) {\n return err(new Error(\"Phantom name cannot start with a dot\"));\n }\n\n return ok(undefined);\n}\n", "import { join } from \"node:path\";\n\nexport function getPhantomDirectory(gitRoot: string): string {\n return join(gitRoot, \".git\", \"phantom\", \"worktrees\");\n}\n\nexport function getWorktreePath(gitRoot: string, name: string): string {\n return join(getPhantomDirectory(gitRoot), name);\n}\n", "import {\n type ChildProcess,\n type SpawnOptions,\n spawn as nodeSpawn,\n} from \"node:child_process\";\nimport { type Result, err, ok } from \"../types/result.ts\";\nimport {\n type ProcessError,\n ProcessExecutionError,\n ProcessSignalError,\n ProcessSpawnError,\n} from \"./errors.ts\";\n\nexport interface SpawnSuccess {\n exitCode: number;\n}\n\nexport interface SpawnConfig {\n command: string;\n args?: string[];\n options?: SpawnOptions;\n}\n\nexport async function spawnProcess(\n config: SpawnConfig,\n): Promise<Result<SpawnSuccess, ProcessError>> {\n return new Promise((resolve) => {\n const { command, args = [], options = {} } = config;\n\n const childProcess: ChildProcess = nodeSpawn(command, args, {\n stdio: \"inherit\",\n ...options,\n });\n\n childProcess.on(\"error\", (error) => {\n resolve(err(new ProcessSpawnError(command, error.message)));\n });\n\n childProcess.on(\"exit\", (code, signal) => {\n if (signal) {\n resolve(err(new ProcessSignalError(signal)));\n } else {\n const exitCode = code ?? 0;\n if (exitCode === 0) {\n resolve(ok({ exitCode }));\n } else {\n resolve(err(new ProcessExecutionError(command, exitCode)));\n }\n }\n });\n });\n}\n", "export class ProcessError extends Error {\n public readonly exitCode?: number;\n\n constructor(message: string, exitCode?: number) {\n super(message);\n this.name = \"ProcessError\";\n this.exitCode = exitCode;\n }\n}\n\nexport class ProcessExecutionError extends ProcessError {\n constructor(command: string, exitCode: number) {\n super(`Command '${command}' failed with exit code ${exitCode}`, exitCode);\n this.name = \"ProcessExecutionError\";\n }\n}\n\nexport class ProcessSignalError extends ProcessError {\n constructor(signal: string) {\n const exitCode = 128 + (signal === \"SIGTERM\" ? 15 : 1);\n super(`Command terminated by signal: ${signal}`, exitCode);\n this.name = \"ProcessSignalError\";\n }\n}\n\nexport class ProcessSpawnError extends ProcessError {\n constructor(command: string, details: string) {\n super(`Error executing command '${command}': ${details}`);\n this.name = \"ProcessSpawnError\";\n }\n}\n", "import type { StdioOptions } from \"node:child_process\";\nimport { type Result, err } from \"../types/result.ts\";\nimport { WorktreeNotFoundError } from \"../worktree/errors.ts\";\nimport { validateWorktreeExists } from \"../worktree/validate.ts\";\nimport type { ProcessError } from \"./errors.ts\";\nimport { type SpawnSuccess, spawnProcess } from \"./spawn.ts\";\n\nexport type ExecInWorktreeSuccess = SpawnSuccess;\n\nexport interface ExecInWorktreeOptions {\n interactive?: boolean;\n}\n\nexport async function execInWorktree(\n gitRoot: string,\n worktreeName: string,\n command: string[],\n options: ExecInWorktreeOptions = {},\n): Promise<\n Result<ExecInWorktreeSuccess, WorktreeNotFoundError | ProcessError>\n> {\n const validation = await validateWorktreeExists(gitRoot, worktreeName);\n if (!validation.exists) {\n return err(new WorktreeNotFoundError(worktreeName));\n }\n\n const worktreePath = validation.path as string;\n const [cmd, ...args] = command;\n\n const stdio: StdioOptions = options.interactive\n ? \"inherit\"\n : [\"ignore\", \"inherit\", \"inherit\"];\n\n return spawnProcess({\n command: cmd,\n args,\n options: {\n cwd: worktreePath,\n stdio,\n },\n });\n}\n", "import { type Result, err } from \"../types/result.ts\";\nimport { WorktreeNotFoundError } from \"../worktree/errors.ts\";\nimport { validateWorktreeExists } from \"../worktree/validate.ts\";\nimport type { ProcessError } from \"./errors.ts\";\nimport { type SpawnSuccess, spawnProcess } from \"./spawn.ts\";\n\nexport type ShellInWorktreeSuccess = SpawnSuccess;\n\nexport async function shellInWorktree(\n gitRoot: string,\n worktreeName: string,\n): Promise<\n Result<ShellInWorktreeSuccess, WorktreeNotFoundError | ProcessError>\n> {\n const validation = await validateWorktreeExists(gitRoot, worktreeName);\n if (!validation.exists) {\n return err(new WorktreeNotFoundError(worktreeName));\n }\n\n const worktreePath = validation.path as string;\n const shell = process.env.SHELL || \"/bin/sh\";\n\n return spawnProcess({\n command: shell,\n args: [],\n options: {\n cwd: worktreePath,\n env: {\n ...process.env,\n PHANTOM: \"1\",\n PHANTOM_NAME: worktreeName,\n PHANTOM_PATH: worktreePath,\n },\n },\n });\n}\n", "import { existsSync } from \"node:fs\";\nimport { attachWorktree } from \"../git/libs/attach-worktree.ts\";\nimport { branchExists } from \"../git/libs/branch-exists.ts\";\nimport { getWorktreePath } from \"../paths.ts\";\nimport type { Result } from \"../types/result.ts\";\nimport { err, isErr, ok } from \"../types/result.ts\";\nimport { BranchNotFoundError, WorktreeAlreadyExistsError } from \"./errors.ts\";\nimport { validateWorktreeName } from \"./validate.ts\";\n\nexport async function attachWorktreeCore(\n gitRoot: string,\n name: string,\n): Promise<Result<string, Error>> {\n const validation = validateWorktreeName(name);\n if (isErr(validation)) {\n return validation;\n }\n\n const worktreePath = getWorktreePath(gitRoot, name);\n if (existsSync(worktreePath)) {\n return err(new WorktreeAlreadyExistsError(name));\n }\n\n const branchCheckResult = await branchExists(gitRoot, name);\n if (isErr(branchCheckResult)) {\n return err(branchCheckResult.error);\n }\n\n if (!branchCheckResult.value) {\n return err(new BranchNotFoundError(name));\n }\n\n const attachResult = await attachWorktree(gitRoot, worktreePath, name);\n if (isErr(attachResult)) {\n return err(attachResult.error);\n }\n\n return ok(worktreePath);\n}\n", "import type { Result } from \"../../types/result.ts\";\nimport { err, ok } from \"../../types/result.ts\";\nimport { executeGitCommand } from \"../executor.ts\";\n\nexport async function attachWorktree(\n gitRoot: string,\n worktreePath: string,\n branchName: string,\n): Promise<Result<void, Error>> {\n try {\n await executeGitCommand([\"worktree\", \"add\", worktreePath, branchName], {\n cwd: gitRoot,\n });\n return ok(undefined);\n } catch (error) {\n return err(\n error instanceof Error\n ? error\n : new Error(`Failed to attach worktree: ${String(error)}`),\n );\n }\n}\n", "import type { Result } from \"../../types/result.ts\";\nimport { err, isErr, ok } from \"../../types/result.ts\";\nimport { executeGitCommand } from \"../executor.ts\";\n\nexport async function branchExists(\n gitRoot: string,\n branchName: string,\n): Promise<Result<boolean, Error>> {\n try {\n await executeGitCommand(\n [\"show-ref\", \"--verify\", \"--quiet\", `refs/heads/${branchName}`],\n { cwd: gitRoot },\n );\n return ok(true);\n } catch (error) {\n if (error && typeof error === \"object\" && \"code\" in error) {\n const execError = error as { code?: number; message?: string };\n if (execError.code === 1) {\n return ok(false);\n }\n }\n return err(\n new Error(\n `Failed to check branch existence: ${\n error instanceof Error ? error.message : String(error)\n }`,\n ),\n );\n }\n}\n", "import type { ChildProcess } from \"node:child_process\";\n\nexport const output = {\n log: (message: string) => {\n console.log(message);\n },\n\n error: (message: string) => {\n console.error(message);\n },\n\n warn: (message: string) => {\n console.warn(message);\n },\n\n table: (data: unknown) => {\n console.table(data);\n },\n\n processOutput: (proc: ChildProcess) => {\n proc.stdout?.pipe(process.stdout);\n proc.stderr?.pipe(process.stderr);\n },\n};\n", "import { output } from \"./output.ts\";\n\nexport const exitCodes = {\n success: 0,\n generalError: 1,\n notFound: 2,\n validationError: 3,\n} as const;\n\nexport function handleError(\n error: unknown,\n exitCode: number = exitCodes.generalError,\n): never {\n if (error instanceof Error) {\n output.error(error.message);\n } else {\n output.error(String(error));\n }\n process.exit(exitCode);\n}\n\nexport function exitWithSuccess(): never {\n process.exit(exitCodes.success);\n}\n\nexport function exitWithError(\n message: string,\n exitCode: number = exitCodes.generalError,\n): never {\n output.error(message);\n process.exit(exitCode);\n}\n", "import { parseArgs } from \"node:util\";\nimport {\n ConfigNotFoundError,\n ConfigParseError,\n loadConfig,\n} from \"../../core/config/loader.ts\";\nimport { ConfigValidationError } from \"../../core/config/validate.ts\";\nimport { getGitRoot } from \"../../core/git/libs/get-git-root.ts\";\nimport { execInWorktree } from \"../../core/process/exec.ts\";\nimport { shellInWorktree } from \"../../core/process/shell.ts\";\nimport { executeTmuxCommand, isInsideTmux } from \"../../core/process/tmux.ts\";\nimport { isErr, isOk } from \"../../core/types/result.ts\";\nimport { createWorktree as createWorktreeCore } from \"../../core/worktree/create.ts\";\nimport { WorktreeAlreadyExistsError } from \"../../core/worktree/errors.ts\";\nimport { exitCodes, exitWithError, exitWithSuccess } from \"../errors.ts\";\nimport { output } from \"../output.ts\";\n\nexport async function createHandler(args: string[]): Promise<void> {\n const { values, positionals } = parseArgs({\n args,\n options: {\n shell: {\n type: \"boolean\",\n short: \"s\",\n },\n exec: {\n type: \"string\",\n short: \"x\",\n },\n tmux: {\n type: \"boolean\",\n short: \"t\",\n },\n \"tmux-vertical\": {\n type: \"boolean\",\n },\n \"tmux-v\": {\n type: \"boolean\",\n },\n \"tmux-horizontal\": {\n type: \"boolean\",\n },\n \"tmux-h\": {\n type: \"boolean\",\n },\n \"copy-file\": {\n type: \"string\",\n multiple: true,\n },\n },\n strict: true,\n allowPositionals: true,\n });\n\n if (positionals.length === 0) {\n exitWithError(\n \"Please provide a name for the new worktree\",\n exitCodes.validationError,\n );\n }\n\n const worktreeName = positionals[0];\n const openShell = values.shell ?? false;\n const execCommand = values.exec;\n const copyFileOptions = values[\"copy-file\"];\n\n // Determine tmux option\n const tmuxOption =\n values.tmux ||\n values[\"tmux-vertical\"] ||\n values[\"tmux-v\"] ||\n values[\"tmux-horizontal\"] ||\n values[\"tmux-h\"];\n\n let tmuxDirection: \"new\" | \"vertical\" | \"horizontal\" | undefined;\n if (values.tmux) {\n tmuxDirection = \"new\";\n } else if (values[\"tmux-vertical\"] || values[\"tmux-v\"]) {\n tmuxDirection = \"vertical\";\n } else if (values[\"tmux-horizontal\"] || values[\"tmux-h\"]) {\n tmuxDirection = \"horizontal\";\n }\n\n if (\n [openShell, execCommand !== undefined, tmuxOption].filter(Boolean).length >\n 1\n ) {\n exitWithError(\n \"Cannot use --shell, --exec, and --tmux options together\",\n exitCodes.validationError,\n );\n }\n\n if (tmuxOption && !(await isInsideTmux())) {\n exitWithError(\n \"The --tmux option can only be used inside a tmux session\",\n exitCodes.validationError,\n );\n }\n\n try {\n const gitRoot = await getGitRoot();\n\n let filesToCopy: string[] = [];\n\n // Load files from config\n const configResult = await loadConfig(gitRoot);\n if (isOk(configResult)) {\n if (configResult.value.postCreate?.copyFiles) {\n filesToCopy = [...configResult.value.postCreate.copyFiles];\n }\n } else {\n // Display warning for validation and parse errors\n if (configResult.error instanceof ConfigValidationError) {\n output.warn(`Configuration warning: ${configResult.error.message}`);\n } else if (configResult.error instanceof ConfigParseError) {\n output.warn(`Configuration warning: ${configResult.error.message}`);\n }\n // ConfigNotFoundError remains silent as the config file is optional\n }\n\n // Add files from CLI options\n if (copyFileOptions && copyFileOptions.length > 0) {\n const cliFiles = Array.isArray(copyFileOptions)\n ? copyFileOptions\n : [copyFileOptions];\n // Merge with config files, removing duplicates\n filesToCopy = [...new Set([...filesToCopy, ...cliFiles])];\n }\n\n const result = await createWorktreeCore(gitRoot, worktreeName, {\n copyFiles: filesToCopy.length > 0 ? filesToCopy : undefined,\n });\n\n if (isErr(result)) {\n const exitCode =\n result.error instanceof WorktreeAlreadyExistsError\n ? exitCodes.validationError\n : exitCodes.generalError;\n exitWithError(result.error.message, exitCode);\n }\n\n output.log(result.value.message);\n\n if (result.value.copyError) {\n output.error(\n `\\nWarning: Failed to copy some files: ${result.value.copyError}`,\n );\n }\n\n // Execute post-create commands from config\n if (isOk(configResult) && configResult.value.postCreate?.commands) {\n const commands = configResult.value.postCreate.commands;\n output.log(\"\\nRunning post-create commands...\");\n\n for (const command of commands) {\n output.log(`Executing: ${command}`);\n const shell = process.env.SHELL || \"/bin/sh\";\n const cmdResult = await execInWorktree(gitRoot, worktreeName, [\n shell,\n \"-c\",\n command,\n ]);\n\n if (isErr(cmdResult)) {\n output.error(`Failed to execute command: ${cmdResult.error.message}`);\n const exitCode =\n \"exitCode\" in cmdResult.error\n ? (cmdResult.error.exitCode ?? exitCodes.generalError)\n : exitCodes.generalError;\n exitWithError(`Post-create command failed: ${command}`, exitCode);\n }\n\n // Check exit code\n if (cmdResult.value.exitCode !== 0) {\n exitWithError(\n `Post-create command failed: ${command}`,\n cmdResult.value.exitCode,\n );\n }\n }\n }\n\n if (execCommand && isOk(result)) {\n output.log(\n `\\nExecuting command in worktree '${worktreeName}': ${execCommand}`,\n );\n\n const shell = process.env.SHELL || \"/bin/sh\";\n const execResult = await execInWorktree(\n gitRoot,\n worktreeName,\n [shell, \"-c\", execCommand],\n { interactive: true },\n );\n\n if (isErr(execResult)) {\n output.error(execResult.error.message);\n const exitCode =\n \"exitCode\" in execResult.error\n ? (execResult.error.exitCode ?? exitCodes.generalError)\n : exitCodes.generalError;\n exitWithError(\"\", exitCode);\n }\n\n process.exit(execResult.value.exitCode ?? 0);\n }\n\n if (openShell && isOk(result)) {\n output.log(\n `\\nEntering worktree '${worktreeName}' at ${result.value.path}`,\n );\n output.log(\"Type 'exit' to return to your original directory\\n\");\n\n const shellResult = await shellInWorktree(gitRoot, worktreeName);\n\n if (isErr(shellResult)) {\n output.error(shellResult.error.message);\n const exitCode =\n \"exitCode\" in shellResult.error\n ? (shellResult.error.exitCode ?? exitCodes.generalError)\n : exitCodes.generalError;\n exitWithError(\"\", exitCode);\n }\n\n process.exit(shellResult.value.exitCode ?? 0);\n }\n\n if (tmuxDirection && isOk(result)) {\n output.log(\n `\\nOpening worktree '${worktreeName}' in tmux ${\n tmuxDirection === \"new\" ? \"window\" : \"pane\"\n }...`,\n );\n\n const shell = process.env.SHELL || \"/bin/sh\";\n\n const tmuxResult = await executeTmuxCommand({\n direction: tmuxDirection,\n command: shell,\n cwd: result.value.path,\n env: {\n PHANTOM: \"1\",\n PHANTOM_NAME: worktreeName,\n PHANTOM_PATH: result.value.path,\n },\n });\n\n if (isErr(tmuxResult)) {\n output.error(tmuxResult.error.message);\n const exitCode =\n \"exitCode\" in tmuxResult.error\n ? (tmuxResult.error.exitCode ?? exitCodes.generalError)\n : exitCodes.generalError;\n exitWithError(\"\", exitCode);\n }\n }\n\n exitWithSuccess();\n } catch (error) {\n exitWithError(\n error instanceof Error ? error.message : String(error),\n exitCodes.generalError,\n );\n }\n}\n", "import fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { type Result, err, ok } from \"../types/result.ts\";\nimport { type ConfigValidationError, validateConfig } from \"./validate.ts\";\n\nexport interface PhantomConfig {\n postCreate?: {\n copyFiles?: string[];\n commands?: string[];\n };\n}\n\nexport class ConfigNotFoundError extends Error {\n constructor() {\n super(\"phantom.config.json not found\");\n this.name = \"ConfigNotFoundError\";\n }\n}\n\nexport class ConfigParseError extends Error {\n constructor(message: string) {\n super(`Failed to parse phantom.config.json: ${message}`);\n this.name = \"ConfigParseError\";\n }\n}\n\nexport async function loadConfig(\n gitRoot: string,\n): Promise<\n Result<\n PhantomConfig,\n ConfigNotFoundError | ConfigParseError | ConfigValidationError\n >\n> {\n const configPath = path.join(gitRoot, \"phantom.config.json\");\n\n try {\n const content = await fs.readFile(configPath, \"utf-8\");\n try {\n const parsed = JSON.parse(content);\n const validationResult = validateConfig(parsed);\n\n if (!validationResult.ok) {\n return err(validationResult.error);\n }\n\n return ok(validationResult.value);\n } catch (error) {\n return err(\n new ConfigParseError(\n error instanceof Error ? error.message : String(error),\n ),\n );\n }\n } catch (error) {\n if (error instanceof Error && \"code\" in error && error.code === \"ENOENT\") {\n return err(new ConfigNotFoundError());\n }\n throw error;\n }\n}\n", "export function isObject(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n", "import { type Result, err, ok } from \"../types/result.ts\";\nimport { isObject } from \"../utils/type-guards.ts\";\nimport type { PhantomConfig } from \"./loader.ts\";\n\nexport class ConfigValidationError extends Error {\n constructor(message: string) {\n super(`Invalid phantom.config.json: ${message}`);\n this.name = \"ConfigValidationError\";\n }\n}\n\nexport function validateConfig(\n config: unknown,\n): Result<PhantomConfig, ConfigValidationError> {\n if (!isObject(config)) {\n return err(new ConfigValidationError(\"Configuration must be an object\"));\n }\n\n const cfg = config;\n\n if (cfg.postCreate !== undefined) {\n if (!isObject(cfg.postCreate)) {\n return err(new ConfigValidationError(\"postCreate must be an object\"));\n }\n\n const postCreate = cfg.postCreate;\n if (postCreate.copyFiles !== undefined) {\n if (!Array.isArray(postCreate.copyFiles)) {\n return err(\n new ConfigValidationError(\"postCreate.copyFiles must be an array\"),\n );\n }\n\n if (!postCreate.copyFiles.every((f: unknown) => typeof f === \"string\")) {\n return err(\n new ConfigValidationError(\n \"postCreate.copyFiles must contain only strings\",\n ),\n );\n }\n }\n\n if (postCreate.commands !== undefined) {\n if (!Array.isArray(postCreate.commands)) {\n return err(\n new ConfigValidationError(\"postCreate.commands must be an array\"),\n );\n }\n\n if (!postCreate.commands.every((c: unknown) => typeof c === \"string\")) {\n return err(\n new ConfigValidationError(\n \"postCreate.commands must contain only strings\",\n ),\n );\n }\n }\n }\n\n return ok(config as PhantomConfig);\n}\n", "import type { Result } from \"../types/result.ts\";\nimport type { ProcessError } from \"./errors.ts\";\nimport { type SpawnSuccess, spawnProcess } from \"./spawn.ts\";\n\nexport type TmuxSplitDirection = \"new\" | \"vertical\" | \"horizontal\";\n\nexport interface TmuxOptions {\n direction: TmuxSplitDirection;\n command: string;\n cwd?: string;\n env?: Record<string, string>;\n}\n\nexport type TmuxSuccess = SpawnSuccess;\n\nexport async function isInsideTmux(): Promise<boolean> {\n return process.env.TMUX !== undefined;\n}\n\nexport async function executeTmuxCommand(\n options: TmuxOptions,\n): Promise<Result<TmuxSuccess, ProcessError>> {\n const { direction, command, cwd, env } = options;\n\n const tmuxArgs: string[] = [];\n\n switch (direction) {\n case \"new\":\n tmuxArgs.push(\"new-window\");\n break;\n case \"vertical\":\n tmuxArgs.push(\"split-window\", \"-v\");\n break;\n case \"horizontal\":\n tmuxArgs.push(\"split-window\", \"-h\");\n break;\n }\n\n if (cwd) {\n tmuxArgs.push(\"-c\", cwd);\n }\n\n // Add environment variables safely\n if (env) {\n for (const [key, value] of Object.entries(env)) {\n tmuxArgs.push(\"-e\", `${key}=${value}`);\n }\n }\n\n tmuxArgs.push(command);\n\n const result = await spawnProcess({\n command: \"tmux\",\n args: tmuxArgs,\n });\n\n return result;\n}\n", "import fs from \"node:fs/promises\";\nimport { addWorktree } from \"../git/libs/add-worktree.ts\";\nimport { getPhantomDirectory, getWorktreePath } from \"../paths.ts\";\nimport { type Result, err, isErr, isOk, ok } from \"../types/result.ts\";\nimport { GitOperationError, WorktreeAlreadyExistsError } from \"./errors.ts\";\nimport { copyFiles } from \"./file-copier.ts\";\nimport {\n validateWorktreeDoesNotExist,\n validateWorktreeName,\n} from \"./validate.ts\";\n\nexport interface CreateWorktreeOptions {\n branch?: string;\n commitish?: string;\n copyFiles?: string[];\n}\n\nexport interface CreateWorktreeSuccess {\n message: string;\n path: string;\n copiedFiles?: string[];\n skippedFiles?: string[];\n copyError?: string;\n}\n\nexport async function createWorktree(\n gitRoot: string,\n name: string,\n options: CreateWorktreeOptions = {},\n): Promise<\n Result<CreateWorktreeSuccess, WorktreeAlreadyExistsError | GitOperationError>\n> {\n const nameValidation = validateWorktreeName(name);\n if (isErr(nameValidation)) {\n return nameValidation;\n }\n\n const { branch = name, commitish = \"HEAD\" } = options;\n\n const worktreesPath = getPhantomDirectory(gitRoot);\n const worktreePath = getWorktreePath(gitRoot, name);\n\n try {\n await fs.access(worktreesPath);\n } catch {\n await fs.mkdir(worktreesPath, { recursive: true });\n }\n\n const validation = await validateWorktreeDoesNotExist(gitRoot, name);\n if (validation.exists) {\n return err(new WorktreeAlreadyExistsError(name));\n }\n\n try {\n await addWorktree({\n path: worktreePath,\n branch,\n commitish,\n });\n\n let copiedFiles: string[] | undefined;\n let skippedFiles: string[] | undefined;\n let copyError: string | undefined;\n\n if (options.copyFiles && options.copyFiles.length > 0) {\n const copyResult = await copyFiles(\n gitRoot,\n worktreePath,\n options.copyFiles,\n );\n\n if (isOk(copyResult)) {\n copiedFiles = copyResult.value.copiedFiles;\n skippedFiles = copyResult.value.skippedFiles;\n } else {\n copyError = copyResult.error.message;\n }\n }\n\n return ok({\n message: `Created worktree '${name}' at ${worktreePath}`,\n path: worktreePath,\n copiedFiles,\n skippedFiles,\n copyError,\n });\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n return err(new GitOperationError(\"worktree add\", errorMessage));\n }\n}\n", "import { executeGitCommand } from \"../executor.ts\";\n\nexport interface AddWorktreeOptions {\n path: string;\n branch: string;\n commitish?: string;\n}\n\nexport async function addWorktree(options: AddWorktreeOptions): Promise<void> {\n const { path, branch, commitish = \"HEAD\" } = options;\n\n await executeGitCommand([\"worktree\", \"add\", path, \"-b\", branch, commitish]);\n}\n", "import { copyFile, mkdir, stat } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { type Result, err, ok } from \"../types/result.ts\";\n\nexport interface CopyFileResult {\n copiedFiles: string[];\n skippedFiles: string[];\n}\n\nexport class FileCopyError extends Error {\n public readonly file: string;\n\n constructor(file: string, message: string) {\n super(`Failed to copy ${file}: ${message}`);\n this.name = \"FileCopyError\";\n this.file = file;\n }\n}\n\nexport async function copyFiles(\n sourceDir: string,\n targetDir: string,\n files: string[],\n): Promise<Result<CopyFileResult, FileCopyError>> {\n const copiedFiles: string[] = [];\n const skippedFiles: string[] = [];\n\n for (const file of files) {\n const sourcePath = path.join(sourceDir, file);\n const targetPath = path.join(targetDir, file);\n\n try {\n const stats = await stat(sourcePath);\n if (!stats.isFile()) {\n skippedFiles.push(file);\n continue;\n }\n\n const targetDirPath = path.dirname(targetPath);\n await mkdir(targetDirPath, { recursive: true });\n\n await copyFile(sourcePath, targetPath);\n copiedFiles.push(file);\n } catch (error) {\n if (\n error instanceof Error &&\n \"code\" in error &&\n error.code === \"ENOENT\"\n ) {\n skippedFiles.push(file);\n } else {\n return err(\n new FileCopyError(\n file,\n error instanceof Error ? error.message : String(error),\n ),\n );\n }\n }\n }\n\n return ok({ copiedFiles, skippedFiles });\n}\n", "import { parseArgs } from \"node:util\";\nimport { getCurrentWorktree } from \"../../core/git/libs/get-current-worktree.ts\";\nimport { getGitRoot } from \"../../core/git/libs/get-git-root.ts\";\nimport { isErr } from \"../../core/types/result.ts\";\nimport { deleteWorktree as deleteWorktreeCore } from \"../../core/worktree/delete.ts\";\nimport {\n WorktreeError,\n WorktreeNotFoundError,\n} from \"../../core/worktree/errors.ts\";\nimport { exitCodes, exitWithError, exitWithSuccess } from \"../errors.ts\";\nimport { output } from \"../output.ts\";\n\nexport async function deleteHandler(args: string[]): Promise<void> {\n const { values, positionals } = parseArgs({\n args,\n options: {\n force: {\n type: \"boolean\",\n short: \"f\",\n },\n current: {\n type: \"boolean\",\n },\n },\n strict: true,\n allowPositionals: true,\n });\n\n const deleteCurrent = values.current ?? false;\n\n if (positionals.length === 0 && !deleteCurrent) {\n exitWithError(\n \"Please provide a worktree name to delete or use --current to delete the current worktree\",\n exitCodes.validationError,\n );\n }\n\n if (positionals.length > 0 && deleteCurrent) {\n exitWithError(\n \"Cannot specify both a worktree name and --current option\",\n exitCodes.validationError,\n );\n }\n\n const forceDelete = values.force ?? false;\n\n try {\n const gitRoot = await getGitRoot();\n\n let worktreeName: string;\n if (deleteCurrent) {\n const currentWorktree = await getCurrentWorktree(gitRoot);\n if (!currentWorktree) {\n exitWithError(\n \"Not in a worktree directory. The --current option can only be used from within a worktree.\",\n exitCodes.validationError,\n );\n }\n worktreeName = currentWorktree;\n } else {\n worktreeName = positionals[0];\n }\n\n const result = await deleteWorktreeCore(gitRoot, worktreeName, {\n force: forceDelete,\n });\n\n if (isErr(result)) {\n const exitCode =\n result.error instanceof WorktreeNotFoundError\n ? exitCodes.validationError\n : result.error instanceof WorktreeError &&\n result.error.message.includes(\"uncommitted changes\")\n ? exitCodes.validationError\n : exitCodes.generalError;\n exitWithError(result.error.message, exitCode);\n }\n\n output.log(result.value.message);\n exitWithSuccess();\n } catch (error) {\n exitWithError(\n error instanceof Error ? error.message : String(error),\n exitCodes.generalError,\n );\n }\n}\n", "import { executeGitCommand } from \"../executor.ts\";\n\nexport interface GitWorktree {\n path: string;\n branch: string;\n head: string;\n isLocked: boolean;\n isPrunable: boolean;\n}\n\nexport async function listWorktrees(gitRoot: string): Promise<GitWorktree[]> {\n const { stdout } = await executeGitCommand([\n \"worktree\",\n \"list\",\n \"--porcelain\",\n ]);\n\n const worktrees: GitWorktree[] = [];\n let currentWorktree: Partial<GitWorktree> = {};\n\n const lines = stdout.split(\"\\n\").filter((line) => line.length > 0);\n\n for (const line of lines) {\n if (line.startsWith(\"worktree \")) {\n if (currentWorktree.path) {\n worktrees.push(currentWorktree as GitWorktree);\n }\n currentWorktree = {\n path: line.substring(\"worktree \".length),\n isLocked: false,\n isPrunable: false,\n };\n } else if (line.startsWith(\"HEAD \")) {\n currentWorktree.head = line.substring(\"HEAD \".length);\n } else if (line.startsWith(\"branch \")) {\n const fullBranch = line.substring(\"branch \".length);\n currentWorktree.branch = fullBranch.startsWith(\"refs/heads/\")\n ? fullBranch.substring(\"refs/heads/\".length)\n : fullBranch;\n } else if (line === \"detached\") {\n currentWorktree.branch = \"(detached HEAD)\";\n } else if (line === \"locked\") {\n currentWorktree.isLocked = true;\n } else if (line === \"prunable\") {\n currentWorktree.isPrunable = true;\n }\n }\n\n if (currentWorktree.path) {\n worktrees.push(currentWorktree as GitWorktree);\n }\n\n return worktrees;\n}\n", "import { executeGitCommand } from \"../executor.ts\";\nimport { listWorktrees } from \"./list-worktrees.ts\";\n\nexport async function getCurrentWorktree(\n gitRoot: string,\n): Promise<string | null> {\n try {\n const { stdout: currentPath } = await executeGitCommand([\n \"rev-parse\",\n \"--show-toplevel\",\n ]);\n\n const currentPathTrimmed = currentPath.trim();\n\n const worktrees = await listWorktrees(gitRoot);\n\n const currentWorktree = worktrees.find(\n (wt) => wt.path === currentPathTrimmed,\n );\n\n if (!currentWorktree || currentWorktree.path === gitRoot) {\n return null;\n }\n\n return currentWorktree.branch;\n } catch {\n return null;\n }\n}\n", "import {\n executeGitCommand,\n executeGitCommandInDirectory,\n} from \"../git/executor.ts\";\nimport { type Result, err, isOk, ok } from \"../types/result.ts\";\nimport {\n GitOperationError,\n WorktreeError,\n WorktreeNotFoundError,\n} from \"./errors.ts\";\nimport { validateWorktreeExists } from \"./validate.ts\";\n\nexport interface DeleteWorktreeOptions {\n force?: boolean;\n}\n\nexport interface DeleteWorktreeSuccess {\n message: string;\n hasUncommittedChanges?: boolean;\n changedFiles?: number;\n}\n\nexport interface WorktreeStatus {\n hasUncommittedChanges: boolean;\n changedFiles: number;\n}\n\nexport async function getWorktreeStatus(\n worktreePath: string,\n): Promise<WorktreeStatus> {\n try {\n const { stdout } = await executeGitCommandInDirectory(worktreePath, [\n \"status\",\n \"--porcelain\",\n ]);\n if (stdout) {\n return {\n hasUncommittedChanges: true,\n changedFiles: stdout.split(\"\\n\").length,\n };\n }\n } catch {\n // If git status fails, assume no changes\n }\n return {\n hasUncommittedChanges: false,\n changedFiles: 0,\n };\n}\n\nexport async function removeWorktree(\n gitRoot: string,\n worktreePath: string,\n force = false,\n): Promise<void> {\n try {\n await executeGitCommand([\"worktree\", \"remove\", worktreePath], {\n cwd: gitRoot,\n });\n } catch (error) {\n // Always try force removal if the regular removal fails\n try {\n await executeGitCommand([\"worktree\", \"remove\", \"--force\", worktreePath], {\n cwd: gitRoot,\n });\n } catch {\n throw new Error(\"Failed to remove worktree\");\n }\n }\n}\n\nexport async function deleteBranch(\n gitRoot: string,\n branchName: string,\n): Promise<Result<boolean, GitOperationError>> {\n try {\n await executeGitCommand([\"branch\", \"-D\", branchName], { cwd: gitRoot });\n return ok(true);\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n return err(new GitOperationError(\"branch delete\", errorMessage));\n }\n}\n\nexport async function deleteWorktree(\n gitRoot: string,\n name: string,\n options: DeleteWorktreeOptions = {},\n): Promise<\n Result<\n DeleteWorktreeSuccess,\n WorktreeNotFoundError | WorktreeError | GitOperationError\n >\n> {\n const { force = false } = options;\n\n const validation = await validateWorktreeExists(gitRoot, name);\n if (!validation.exists) {\n return err(new WorktreeNotFoundError(name));\n }\n\n const worktreePath = validation.path as string;\n\n const status = await getWorktreeStatus(worktreePath);\n\n if (status.hasUncommittedChanges && !force) {\n return err(\n new WorktreeError(\n `Worktree '${name}' has uncommitted changes (${status.changedFiles} files). Use --force to delete anyway.`,\n ),\n );\n }\n\n try {\n await removeWorktree(gitRoot, worktreePath, force);\n\n const branchName = name;\n const branchResult = await deleteBranch(gitRoot, branchName);\n\n let message: string;\n if (isOk(branchResult)) {\n message = `Deleted worktree '${name}' and its branch '${branchName}'`;\n } else {\n message = `Deleted worktree '${name}'`;\n message += `\\nNote: Branch '${branchName}' could not be deleted: ${branchResult.error.message}`;\n }\n\n if (status.hasUncommittedChanges) {\n message = `Warning: Worktree '${name}' had uncommitted changes (${status.changedFiles} files)\\n${message}`;\n }\n\n return ok({\n message,\n hasUncommittedChanges: status.hasUncommittedChanges,\n changedFiles: status.hasUncommittedChanges\n ? status.changedFiles\n : undefined,\n });\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n return err(new GitOperationError(\"worktree remove\", errorMessage));\n }\n}\n", "import { parseArgs } from \"node:util\";\nimport { getGitRoot } from \"../../core/git/libs/get-git-root.ts\";\nimport { execInWorktree as execInWorktreeCore } from \"../../core/process/exec.ts\";\nimport { isErr } from \"../../core/types/result.ts\";\nimport { WorktreeNotFoundError } from \"../../core/worktree/errors.ts\";\nimport { exitCodes, exitWithError } from \"../errors.ts\";\n\nexport async function execHandler(args: string[]): Promise<void> {\n const { positionals } = parseArgs({\n args,\n options: {},\n strict: true,\n allowPositionals: true,\n });\n\n if (positionals.length < 2) {\n exitWithError(\n \"Usage: phantom exec <worktree-name> <command> [args...]\",\n exitCodes.validationError,\n );\n }\n\n const [worktreeName, ...commandArgs] = positionals;\n\n try {\n const gitRoot = await getGitRoot();\n const result = await execInWorktreeCore(\n gitRoot,\n worktreeName,\n commandArgs,\n { interactive: true },\n );\n\n if (isErr(result)) {\n const exitCode =\n result.error instanceof WorktreeNotFoundError\n ? exitCodes.notFound\n : result.error.exitCode || exitCodes.generalError;\n exitWithError(result.error.message, exitCode);\n }\n\n process.exit(result.value.exitCode);\n } catch (error) {\n exitWithError(\n error instanceof Error ? error.message : String(error),\n exitCodes.generalError,\n );\n }\n}\n", "import { parseArgs } from \"node:util\";\nimport { getGitRoot } from \"../../core/git/libs/get-git-root.ts\";\nimport { isErr } from \"../../core/types/result.ts\";\nimport { listWorktrees as listWorktreesCore } from \"../../core/worktree/list.ts\";\nimport { exitCodes, exitWithError } from \"../errors.ts\";\nimport { output } from \"../output.ts\";\n\nexport async function listHandler(args: string[] = []): Promise<void> {\n parseArgs({\n args,\n options: {},\n strict: true,\n allowPositionals: false,\n });\n try {\n const gitRoot = await getGitRoot();\n const result = await listWorktreesCore(gitRoot);\n\n if (isErr(result)) {\n exitWithError(\"Failed to list worktrees\", exitCodes.generalError);\n }\n\n const { worktrees, message } = result.value;\n\n if (worktrees.length === 0) {\n output.log(message || \"No worktrees found.\");\n process.exit(exitCodes.success);\n }\n\n const maxNameLength = Math.max(...worktrees.map((wt) => wt.name.length));\n\n for (const worktree of worktrees) {\n const paddedName = worktree.name.padEnd(maxNameLength + 2);\n const branchInfo = worktree.branch ? `(${worktree.branch})` : \"\";\n const status = !worktree.isClean ? \" [dirty]\" : \"\";\n\n output.log(`${paddedName} ${branchInfo}${status}`);\n }\n\n process.exit(exitCodes.success);\n } catch (error) {\n exitWithError(\n error instanceof Error ? error.message : String(error),\n exitCodes.generalError,\n );\n }\n}\n", "import { executeGitCommandInDirectory } from \"../git/executor.ts\";\nimport { listWorktrees as gitListWorktrees } from \"../git/libs/list-worktrees.ts\";\nimport { getPhantomDirectory, getWorktreePath } from \"../paths.ts\";\nimport { type Result, ok } from \"../types/result.ts\";\n\nexport interface WorktreeInfo {\n name: string;\n path: string;\n branch: string;\n isClean: boolean;\n}\n\nexport interface ListWorktreesSuccess {\n worktrees: WorktreeInfo[];\n message?: string;\n}\n\nexport async function getWorktreeBranch(worktreePath: string): Promise<string> {\n try {\n const { stdout } = await executeGitCommandInDirectory(worktreePath, [\n \"branch\",\n \"--show-current\",\n ]);\n return stdout || \"(detached HEAD)\";\n } catch {\n return \"unknown\";\n }\n}\n\nexport async function getWorktreeStatus(\n worktreePath: string,\n): Promise<boolean> {\n try {\n const { stdout } = await executeGitCommandInDirectory(worktreePath, [\n \"status\",\n \"--porcelain\",\n ]);\n return !stdout; // Clean if no output\n } catch {\n // If git status fails, assume clean\n return true;\n }\n}\n\nexport async function getWorktreeInfo(\n gitRoot: string,\n name: string,\n): Promise<WorktreeInfo> {\n const worktreePath = getWorktreePath(gitRoot, name);\n\n const [branch, isClean] = await Promise.all([\n getWorktreeBranch(worktreePath),\n getWorktreeStatus(worktreePath),\n ]);\n\n return {\n name,\n path: worktreePath,\n branch,\n isClean,\n };\n}\n\nexport async function listWorktrees(\n gitRoot: string,\n): Promise<Result<ListWorktreesSuccess, never>> {\n try {\n const gitWorktrees = await gitListWorktrees(gitRoot);\n const phantomDir = getPhantomDirectory(gitRoot);\n\n const phantomWorktrees = gitWorktrees.filter((worktree) =>\n worktree.path.startsWith(phantomDir),\n );\n\n if (phantomWorktrees.length === 0) {\n return ok({\n worktrees: [],\n message: \"No worktrees found\",\n });\n }\n\n const worktrees = await Promise.all(\n phantomWorktrees.map(async (gitWorktree) => {\n const name = gitWorktree.path.substring(phantomDir.length + 1);\n const isClean = await getWorktreeStatus(gitWorktree.path);\n\n return {\n name,\n path: gitWorktree.path,\n branch: gitWorktree.branch || \"(detached HEAD)\",\n isClean,\n };\n }),\n );\n\n return ok({\n worktrees,\n });\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n throw new Error(`Failed to list worktrees: ${errorMessage}`);\n }\n}\n", "import { parseArgs } from \"node:util\";\nimport { getGitRoot } from \"../../core/git/libs/get-git-root.ts\";\nimport { shellInWorktree as shellInWorktreeCore } from \"../../core/process/shell.ts\";\nimport { isErr } from \"../../core/types/result.ts\";\nimport { WorktreeNotFoundError } from \"../../core/worktree/errors.ts\";\nimport { validateWorktreeExists } from \"../../core/worktree/validate.ts\";\nimport { exitCodes, exitWithError } from \"../errors.ts\";\nimport { output } from \"../output.ts\";\n\nexport async function shellHandler(args: string[]): Promise<void> {\n const { positionals } = parseArgs({\n args,\n options: {},\n strict: true,\n allowPositionals: true,\n });\n\n if (positionals.length === 0) {\n exitWithError(\n \"Usage: phantom shell <worktree-name>\",\n exitCodes.validationError,\n );\n }\n\n const worktreeName = positionals[0];\n\n try {\n const gitRoot = await getGitRoot();\n\n // Get worktree path for display\n const validation = await validateWorktreeExists(gitRoot, worktreeName);\n if (!validation.exists) {\n exitWithError(\n validation.message || `Worktree '${worktreeName}' not found`,\n exitCodes.generalError,\n );\n }\n\n output.log(`Entering worktree '${worktreeName}' at ${validation.path}`);\n output.log(\"Type 'exit' to return to your original directory\\n\");\n\n const result = await shellInWorktreeCore(gitRoot, worktreeName);\n\n if (isErr(result)) {\n const exitCode =\n result.error instanceof WorktreeNotFoundError\n ? exitCodes.notFound\n : result.error.exitCode || exitCodes.generalError;\n exitWithError(result.error.message, exitCode);\n }\n\n process.exit(result.value.exitCode);\n } catch (error) {\n exitWithError(\n error instanceof Error ? error.message : String(error),\n exitCodes.generalError,\n );\n }\n}\n", "import { parseArgs } from \"node:util\";\nimport { getVersion } from \"../../core/version.ts\";\nimport { exitWithSuccess } from \"../errors.ts\";\nimport { output } from \"../output.ts\";\n\nexport function versionHandler(args: string[] = []): void {\n parseArgs({\n args,\n options: {},\n strict: true,\n allowPositionals: false,\n });\n const version = getVersion();\n output.log(`Phantom v${version}`);\n exitWithSuccess();\n}\n", "{\n \"name\": \"@aku11i/phantom\",\n \"packageManager\": \"pnpm@10.8.1\",\n \"version\": \"0.7.0\",\n \"description\": \"A powerful CLI tool for managing Git worktrees for parallel development\",\n \"keywords\": [\n \"git\",\n \"worktree\",\n \"cli\",\n \"phantom\",\n \"workspace\",\n \"development\",\n \"parallel\"\n ],\n \"homepage\": \"https://github.com/aku11i/phantom#readme\",\n \"bugs\": {\n \"url\": \"https://github.com/aku11i/phantom/issues\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/aku11i/phantom.git\"\n },\n \"license\": \"MIT\",\n \"author\": \"aku11i\",\n \"type\": \"module\",\n \"bin\": {\n \"phantom\": \"./dist/phantom.js\"\n },\n \"scripts\": {\n \"start\": \"node ./src/bin/phantom.ts\",\n \"phantom\": \"node ./src/bin/phantom.ts\",\n \"build\": \"node build.ts\",\n \"typecheck\": \"tsgo --noEmit\",\n \"test\": \"node --test --experimental-strip-types --experimental-test-module-mocks \\\"src/**/*.test.js\\\"\",\n \"test:coverage\": \"node --experimental-test-coverage --test --experimental-strip-types --experimental-test-module-mocks \\\"src/**/*.test.js\\\"\",\n \"test:file\": \"node --test --experimental-strip-types --experimental-test-module-mocks\",\n \"lint\": \"biome check .\",\n \"fix\": \"biome check --write .\",\n \"ready\": \"pnpm fix && pnpm typecheck && pnpm test\",\n \"ready:check\": \"pnpm lint && pnpm typecheck && pnpm test\",\n \"prepublishOnly\": \"pnpm ready:check && pnpm build\"\n },\n \"engines\": {\n \"node\": \">=22.0.0\"\n },\n \"files\": [\n \"dist/\",\n \"README.md\",\n \"LICENSE\"\n ],\n \"devDependencies\": {\n \"@biomejs/biome\": \"^1.9.4\",\n \"@types/node\": \"^22.15.29\",\n \"@typescript/native-preview\": \"7.0.0-dev.20250602.1\",\n \"esbuild\": \"^0.25.5\",\n \"typescript\": \"^5.8.3\"\n }\n}\n", "import packageJson from \"../../package.json\" with { type: \"json\" };\n\nexport function getVersion(): string {\n return packageJson.version;\n}\n", "import { parseArgs } from \"node:util\";\nimport { getGitRoot } from \"../../core/git/libs/get-git-root.ts\";\nimport { isErr } from \"../../core/types/result.ts\";\nimport { whereWorktree as whereWorktreeCore } from \"../../core/worktree/where.ts\";\nimport { exitCodes, exitWithError, exitWithSuccess } from \"../errors.ts\";\nimport { output } from \"../output.ts\";\n\nexport async function whereHandler(args: string[]): Promise<void> {\n const { positionals } = parseArgs({\n args,\n options: {},\n strict: true,\n allowPositionals: true,\n });\n\n if (positionals.length === 0) {\n exitWithError(\"Please provide a worktree name\", exitCodes.validationError);\n }\n\n const worktreeName = positionals[0];\n\n try {\n const gitRoot = await getGitRoot();\n const result = await whereWorktreeCore(gitRoot, worktreeName);\n\n if (isErr(result)) {\n exitWithError(result.error.message, exitCodes.notFound);\n }\n\n output.log(result.value.path);\n exitWithSuccess();\n } catch (error) {\n exitWithError(\n error instanceof Error ? error.message : String(error),\n exitCodes.generalError,\n );\n }\n}\n", "import { type Result, err, ok } from \"../types/result.ts\";\nimport { WorktreeNotFoundError } from \"./errors.ts\";\nimport { validateWorktreeExists } from \"./validate.ts\";\n\nexport interface WhereWorktreeSuccess {\n path: string;\n}\n\nexport async function whereWorktree(\n gitRoot: string,\n name: string,\n): Promise<Result<WhereWorktreeSuccess, WorktreeNotFoundError>> {\n const validation = await validateWorktreeExists(gitRoot, name);\n\n if (!validation.exists) {\n return err(new WorktreeNotFoundError(name));\n }\n\n return ok({\n path: validation.path as string,\n });\n}\n", "import { stdout } from \"node:process\";\n\nexport interface CommandOption {\n name: string;\n short?: string;\n type: \"boolean\" | \"string\";\n description: string;\n multiple?: boolean;\n example?: string;\n}\n\nexport interface CommandHelp {\n name: string;\n description: string;\n usage: string;\n options?: CommandOption[];\n examples?: Array<{\n description: string;\n command: string;\n }>;\n notes?: string[];\n}\n\nexport class HelpFormatter {\n private readonly width: number;\n private readonly indent = \" \";\n\n constructor() {\n this.width = stdout.columns || 80;\n }\n\n formatMainHelp(\n commands: Array<{ name: string; description: string }>,\n ): string {\n const lines: string[] = [];\n\n lines.push(this.bold(\"Phantom - Git Worktree Manager\"));\n lines.push(\"\");\n lines.push(\n this.dim(\n \"A CLI tool for managing Git worktrees with enhanced functionality\",\n ),\n );\n lines.push(\"\");\n lines.push(this.section(\"USAGE\"));\n lines.push(`${this.indent}phantom <command> [options]`);\n lines.push(\"\");\n lines.push(this.section(\"COMMANDS\"));\n\n const maxNameLength = Math.max(...commands.map((cmd) => cmd.name.length));\n\n for (const cmd of commands) {\n const paddedName = cmd.name.padEnd(maxNameLength + 2);\n lines.push(`${this.indent}${this.cyan(paddedName)}${cmd.description}`);\n }\n\n lines.push(\"\");\n lines.push(this.section(\"GLOBAL OPTIONS\"));\n const helpOption = \"-h, --help\";\n const versionOption = \"-v, --version\";\n const globalOptionWidth =\n Math.max(helpOption.length, versionOption.length) + 2;\n lines.push(\n `${this.indent}${this.cyan(helpOption.padEnd(globalOptionWidth))}Show help`,\n );\n lines.push(\n `${this.indent}${this.cyan(versionOption.padEnd(globalOptionWidth))}Show version`,\n );\n lines.push(\"\");\n lines.push(\n this.dim(\n \"Run 'phantom <command> --help' for more information on a command.\",\n ),\n );\n\n return lines.join(\"\\n\");\n }\n\n formatCommandHelp(help: CommandHelp): string {\n const lines: string[] = [];\n\n lines.push(this.bold(`phantom ${help.name}`));\n lines.push(this.dim(help.description));\n lines.push(\"\");\n\n lines.push(this.section(\"USAGE\"));\n lines.push(`${this.indent}${help.usage}`);\n lines.push(\"\");\n\n if (help.options && help.options.length > 0) {\n lines.push(this.section(\"OPTIONS\"));\n const maxOptionLength = Math.max(\n ...help.options.map((opt) => this.formatOptionName(opt).length),\n );\n\n for (const option of help.options) {\n const optionName = this.formatOptionName(option);\n const paddedName = optionName.padEnd(maxOptionLength + 2);\n const description = this.wrapText(\n option.description,\n maxOptionLength + 4,\n );\n\n lines.push(`${this.indent}${this.cyan(paddedName)}${description[0]}`);\n for (let i = 1; i < description.length; i++) {\n lines.push(\n `${this.indent}${\" \".repeat(maxOptionLength + 2)}${description[i]}`,\n );\n }\n\n if (option.example) {\n const exampleIndent = \" \".repeat(maxOptionLength + 4);\n lines.push(\n `${this.indent}${exampleIndent}${this.dim(`Example: ${option.example}`)}`,\n );\n }\n }\n lines.push(\"\");\n }\n\n if (help.examples && help.examples.length > 0) {\n lines.push(this.section(\"EXAMPLES\"));\n for (const example of help.examples) {\n lines.push(`${this.indent}${this.dim(example.description)}`);\n lines.push(`${this.indent}${this.indent}$ ${example.command}`);\n lines.push(\"\");\n }\n }\n\n if (help.notes && help.notes.length > 0) {\n lines.push(this.section(\"NOTES\"));\n for (const note of help.notes) {\n const wrappedNote = this.wrapText(note, 2);\n for (const line of wrappedNote) {\n lines.push(`${this.indent}${line}`);\n }\n }\n lines.push(\"\");\n }\n\n return lines.join(\"\\n\");\n }\n\n private formatOptionName(option: CommandOption): string {\n const parts: string[] = [];\n\n if (option.short) {\n parts.push(`-${option.short},`);\n }\n\n parts.push(`--${option.name}`);\n\n if (option.type === \"string\") {\n parts.push(option.multiple ? \"<value>...\" : \"<value>\");\n }\n\n return parts.join(\" \");\n }\n\n private wrapText(text: string, indent: number): string[] {\n const maxWidth = this.width - indent - 2;\n const words = text.split(\" \");\n const lines: string[] = [];\n let currentLine = \"\";\n\n for (const word of words) {\n if (currentLine.length + word.length + 1 > maxWidth) {\n lines.push(currentLine);\n currentLine = word;\n } else {\n currentLine = currentLine ? `${currentLine} ${word}` : word;\n }\n }\n\n if (currentLine) {\n lines.push(currentLine);\n }\n\n return lines;\n }\n\n private section(text: string): string {\n return this.bold(text);\n }\n\n private bold(text: string): string {\n return `\\x1b[1m${text}\\x1b[0m`;\n }\n\n private dim(text: string): string {\n return `\\x1b[2m${text}\\x1b[0m`;\n }\n\n private cyan(text: string): string {\n return `\\x1b[36m${text}\\x1b[0m`;\n }\n}\n\nexport const helpFormatter = new HelpFormatter();\n", "import type { CommandHelp } from \"../help.ts\";\n\nexport const attachHelp: CommandHelp = {\n name: \"attach\",\n description: \"Attach to an existing branch by creating a new worktree\",\n usage: \"phantom attach <worktree-name> <branch-name> [options]\",\n options: [\n {\n name: \"shell\",\n short: \"s\",\n type: \"boolean\",\n description: \"Open an interactive shell in the worktree after attaching\",\n },\n {\n name: \"exec\",\n short: \"x\",\n type: \"string\",\n description: \"Execute a command in the worktree after attaching\",\n example: \"--exec 'git pull'\",\n },\n ],\n examples: [\n {\n description: \"Attach to an existing branch\",\n command: \"phantom attach review-pr main\",\n },\n {\n description: \"Attach to a remote branch and open a shell\",\n command: \"phantom attach hotfix origin/hotfix-v1.2 --shell\",\n },\n {\n description: \"Attach to a branch and pull latest changes\",\n command: \"phantom attach staging origin/staging --exec 'git pull'\",\n },\n ],\n notes: [\n \"The branch must already exist (locally or remotely)\",\n \"If attaching to a remote branch, it will be checked out locally\",\n \"Only one of --shell or --exec options can be used at a time\",\n ],\n};\n", "import type { CommandHelp } from \"../help.ts\";\n\nexport const createHelp: CommandHelp = {\n name: \"create\",\n description: \"Create a new Git worktree (phantom)\",\n usage: \"phantom create <name> [options]\",\n options: [\n {\n name: \"shell\",\n short: \"s\",\n type: \"boolean\",\n description:\n \"Open an interactive shell in the new worktree after creation\",\n },\n {\n name: \"exec\",\n short: \"x\",\n type: \"string\",\n description: \"Execute a command in the new worktree after creation\",\n example: \"--exec 'npm install'\",\n },\n {\n name: \"tmux\",\n short: \"t\",\n type: \"boolean\",\n description:\n \"Open the worktree in a new tmux window (requires being inside tmux)\",\n },\n {\n name: \"tmux-vertical\",\n type: \"boolean\",\n description:\n \"Open the worktree in a vertical tmux pane (requires being inside tmux)\",\n },\n {\n name: \"tmux-horizontal\",\n type: \"boolean\",\n description:\n \"Open the worktree in a horizontal tmux pane (requires being inside tmux)\",\n },\n {\n name: \"copy-file\",\n type: \"string\",\n multiple: true,\n description:\n \"Copy specified files from the current worktree to the new one. Can be used multiple times\",\n example: \"--copy-file .env --copy-file config.local.json\",\n },\n ],\n examples: [\n {\n description: \"Create a new worktree named 'feature-auth'\",\n command: \"phantom create feature-auth\",\n },\n {\n description: \"Create a worktree and open a shell in it\",\n command: \"phantom create bugfix-123 --shell\",\n },\n {\n description: \"Create a worktree and run npm install\",\n command: \"phantom create new-feature --exec 'npm install'\",\n },\n {\n description: \"Create a worktree in a new tmux window\",\n command: \"phantom create experiment --tmux\",\n },\n {\n description: \"Create a worktree and copy environment files\",\n command:\n \"phantom create staging --copy-file .env --copy-file database.yml\",\n },\n ],\n notes: [\n \"The worktree name will be used as the branch name\",\n \"Only one of --shell, --exec, or --tmux options can be used at a time\",\n \"File copying can also be configured in phantom.config.json\",\n ],\n};\n", "import type { CommandHelp } from \"../help.ts\";\n\nexport const deleteHelp: CommandHelp = {\n name: \"delete\",\n description: \"Delete a Git worktree (phantom)\",\n usage: \"phantom delete <name> [options]\",\n options: [\n {\n name: \"force\",\n short: \"f\",\n type: \"boolean\",\n description:\n \"Force deletion even if the worktree has uncommitted or unpushed changes\",\n },\n ],\n examples: [\n {\n description: \"Delete a worktree\",\n command: \"phantom delete feature-auth\",\n },\n {\n description: \"Force delete a worktree with uncommitted changes\",\n command: \"phantom delete experimental --force\",\n },\n ],\n notes: [\n \"By default, deletion will fail if the worktree has uncommitted changes\",\n \"The associated branch will also be deleted if it's not checked out elsewhere\",\n ],\n};\n", "import type { CommandHelp } from \"../help.ts\";\n\nexport const execHelp: CommandHelp = {\n name: \"exec\",\n description: \"Execute a command in a worktree directory\",\n usage: \"phantom exec <worktree-name> <command> [args...]\",\n examples: [\n {\n description: \"Run npm test in a worktree\",\n command: \"phantom exec feature-auth npm test\",\n },\n {\n description: \"Check git status in a worktree\",\n command: \"phantom exec bugfix-123 git status\",\n },\n {\n description: \"Run a complex command with arguments\",\n command: \"phantom exec staging npm run build -- --production\",\n },\n ],\n notes: [\n \"The command is executed with the worktree directory as the working directory\",\n \"All arguments after the worktree name are passed to the command\",\n \"The exit code of the executed command is preserved\",\n ],\n};\n", "import type { CommandHelp } from \"../help.ts\";\n\nexport const listHelp: CommandHelp = {\n name: \"list\",\n description: \"List all Git worktrees (phantoms)\",\n usage: \"phantom list\",\n examples: [\n {\n description: \"List all worktrees\",\n command: \"phantom list\",\n },\n ],\n notes: [\n \"Shows all worktrees with their paths and associated branches\",\n \"The main worktree is marked as '(bare)' if using a bare repository\",\n ],\n};\n", "import type { CommandHelp } from \"../help.ts\";\n\nexport const shellHelp: CommandHelp = {\n name: \"shell\",\n description: \"Open an interactive shell in a worktree directory\",\n usage: \"phantom shell <worktree-name>\",\n examples: [\n {\n description: \"Open a shell in a worktree\",\n command: \"phantom shell feature-auth\",\n },\n ],\n notes: [\n \"Uses your default shell from the SHELL environment variable\",\n \"The shell starts with the worktree directory as the working directory\",\n \"Type 'exit' to return to your original directory\",\n ],\n};\n", "import type { CommandHelp } from \"../help.ts\";\n\nexport const versionHelp: CommandHelp = {\n name: \"version\",\n description: \"Display phantom version information\",\n usage: \"phantom version\",\n examples: [\n {\n description: \"Show version\",\n command: \"phantom version\",\n },\n ],\n notes: [\"Also accessible via 'phantom --version' or 'phantom -v'\"],\n};\n", "import type { CommandHelp } from \"../help.ts\";\n\nexport const whereHelp: CommandHelp = {\n name: \"where\",\n description: \"Output the filesystem path of a specific worktree\",\n usage: \"phantom where <worktree-name>\",\n examples: [\n {\n description: \"Get the path of a worktree\",\n command: \"phantom where feature-auth\",\n },\n {\n description: \"Change directory to a worktree\",\n command: \"cd $(phantom where staging)\",\n },\n ],\n notes: [\n \"Outputs only the path, making it suitable for use in scripts\",\n \"Exits with an error code if the worktree doesn't exist\",\n ],\n};\n"],
|
|
5
|
-
"mappings": ";;;AAEA,SAAS,MAAM,YAAY;;;ACF3B,SAAS,iBAAiB;;;ACA1B,SAAS,SAAS,eAAe;;;ACAjC,SAAS,YAAY,wBAAwB;AAC7C,SAAS,iBAAiB;AAE1B,IAAM,WAAW,UAAU,gBAAgB;AAe3C,eAAsB,kBACpBA,OACA,UAA8B,CAAC,GACH;AAC5B,MAAI;AACF,UAAM,SAAS,MAAM,SAAS,OAAOA,OAAM;AAAA,MACzC,KAAK,QAAQ;AAAA,MACb,KAAK,QAAQ,OAAO,QAAQ;AAAA,MAC5B,UAAU;AAAA,IACZ,CAAC;AAED,WAAO;AAAA,MACL,QAAQ,OAAO,OAAO,KAAK;AAAA,MAC3B,QAAQ,OAAO,OAAO,KAAK;AAAA,IAC7B;AAAA,EACF,SAAS,OAAO;AAId,QACE,SACA,OAAO,UAAU,YACjB,YAAY,SACZ,YAAY,OACZ;AACA,YAAM,YAAY;AAOlB,UAAI,UAAU,QAAQ,KAAK,GAAG;AAC5B,cAAM,IAAI,MAAM,UAAU,OAAO,KAAK,CAAC;AAAA,MACzC;AAGA,aAAO;AAAA,QACL,QAAQ,UAAU,QAAQ,KAAK,KAAK;AAAA,QACpC,QAAQ,UAAU,QAAQ,KAAK,KAAK;AAAA,MACtC;AAAA,IACF;AAEA,UAAM;AAAA,EACR;AACF;AAKA,eAAsB,6BACpB,WACAA,OAC4B;AAC5B,SAAO,kBAAkB,CAAC,MAAM,WAAW,GAAGA,KAAI,GAAG,CAAC,CAAC;AACzD;;;ADtEA,eAAsB,aAA8B;AAClD,QAAM,EAAE,QAAAC,QAAO,IAAI,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IACA,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAAA,EACvD;AACA,OAAK,CAAC;AACR;",
|
|
6
|
-
"names": ["args", "stdout", "command", "resolve", "command", "args", "command", "args", "args", "parseArgs", "fs", "fs", "command", "fs", "path", "path", "path", "fs", "args", "parseArgs", "commands", "command", "parseArgs", "stdout", "stdout", "args", "
|
|
3
|
+
"sources": ["../src/bin/phantom.ts", "../src/cli/handlers/attach.ts", "../src/core/git/libs/get-git-root.ts", "../src/core/git/executor.ts", "../src/core/types/result.ts", "../src/core/worktree/errors.ts", "../src/core/worktree/validate.ts", "../src/core/paths.ts", "../src/core/process/spawn.ts", "../src/core/process/errors.ts", "../src/core/process/exec.ts", "../src/core/process/shell.ts", "../src/core/worktree/attach.ts", "../src/core/git/libs/attach-worktree.ts", "../src/core/git/libs/branch-exists.ts", "../src/cli/output.ts", "../src/cli/errors.ts", "../src/cli/handlers/create.ts", "../src/core/config/loader.ts", "../src/core/utils/type-guards.ts", "../src/core/config/validate.ts", "../src/core/process/tmux.ts", "../src/core/worktree/create.ts", "../src/core/git/libs/add-worktree.ts", "../src/core/worktree/file-copier.ts", "../src/cli/handlers/delete.ts", "../src/core/git/libs/list-worktrees.ts", "../src/core/git/libs/get-current-worktree.ts", "../src/core/worktree/delete.ts", "../src/core/utils/fzf.ts", "../src/core/worktree/list.ts", "../src/core/worktree/select.ts", "../src/cli/handlers/exec.ts", "../src/cli/handlers/list.ts", "../src/cli/handlers/shell.ts", "../src/cli/handlers/version.ts", "../package.json", "../src/core/version.ts", "../src/cli/handlers/where.ts", "../src/core/worktree/where.ts", "../src/cli/help.ts", "../src/cli/help/attach.ts", "../src/cli/help/create.ts", "../src/cli/help/delete.ts", "../src/cli/help/exec.ts", "../src/cli/help/list.ts", "../src/cli/help/shell.ts", "../src/cli/help/version.ts", "../src/cli/help/where.ts"],
|
|
4
|
+
"sourcesContent": ["#!/usr/bin/env node\n\nimport { argv, exit } from \"node:process\";\nimport { attachHandler } from \"../cli/handlers/attach.ts\";\nimport { createHandler } from \"../cli/handlers/create.ts\";\nimport { deleteHandler } from \"../cli/handlers/delete.ts\";\nimport { execHandler } from \"../cli/handlers/exec.ts\";\nimport { listHandler } from \"../cli/handlers/list.ts\";\nimport { shellHandler } from \"../cli/handlers/shell.ts\";\nimport { versionHandler } from \"../cli/handlers/version.ts\";\nimport { whereHandler } from \"../cli/handlers/where.ts\";\nimport { type CommandHelp, helpFormatter } from \"../cli/help.ts\";\nimport { attachHelp } from \"../cli/help/attach.ts\";\nimport { createHelp } from \"../cli/help/create.ts\";\nimport { deleteHelp } from \"../cli/help/delete.ts\";\nimport { execHelp } from \"../cli/help/exec.ts\";\nimport { listHelp } from \"../cli/help/list.ts\";\nimport { shellHelp } from \"../cli/help/shell.ts\";\nimport { versionHelp } from \"../cli/help/version.ts\";\nimport { whereHelp } from \"../cli/help/where.ts\";\n\ninterface Command {\n name: string;\n description: string;\n subcommands?: Command[];\n handler?: (args: string[]) => void | Promise<void>;\n help?: CommandHelp;\n}\n\nconst commands: Command[] = [\n {\n name: \"create\",\n description: \"Create a new Git worktree (phantom)\",\n handler: createHandler,\n help: createHelp,\n },\n {\n name: \"attach\",\n description: \"Attach to an existing branch by creating a new worktree\",\n handler: attachHandler,\n help: attachHelp,\n },\n {\n name: \"list\",\n description: \"List all Git worktrees (phantoms)\",\n handler: listHandler,\n help: listHelp,\n },\n {\n name: \"where\",\n description: \"Output the filesystem path of a specific worktree\",\n handler: whereHandler,\n help: whereHelp,\n },\n {\n name: \"delete\",\n description: \"Delete a Git worktree (phantom)\",\n handler: deleteHandler,\n help: deleteHelp,\n },\n {\n name: \"exec\",\n description: \"Execute a command in a worktree directory\",\n handler: execHandler,\n help: execHelp,\n },\n {\n name: \"shell\",\n description: \"Open an interactive shell in a worktree directory\",\n handler: shellHandler,\n help: shellHelp,\n },\n {\n name: \"version\",\n description: \"Display phantom version information\",\n handler: versionHandler,\n help: versionHelp,\n },\n];\n\nfunction printHelp(commands: Command[]) {\n const simpleCommands = commands.map((cmd) => ({\n name: cmd.name,\n description: cmd.description,\n }));\n console.log(helpFormatter.formatMainHelp(simpleCommands));\n}\n\nfunction findCommand(\n args: string[],\n commands: Command[],\n): { command: Command | null; remainingArgs: string[] } {\n if (args.length === 0) {\n return { command: null, remainingArgs: [] };\n }\n\n const [cmdName, ...rest] = args;\n const command = commands.find((cmd) => cmd.name === cmdName);\n\n if (!command) {\n return { command: null, remainingArgs: args };\n }\n\n if (command.subcommands && rest.length > 0) {\n const { command: subcommand, remainingArgs } = findCommand(\n rest,\n command.subcommands,\n );\n if (subcommand) {\n return { command: subcommand, remainingArgs };\n }\n }\n\n return { command, remainingArgs: rest };\n}\n\nconst args = argv.slice(2);\n\nif (args.length === 0 || args[0] === \"-h\" || args[0] === \"--help\") {\n printHelp(commands);\n exit(0);\n}\n\nif (args[0] === \"--version\" || args[0] === \"-v\") {\n versionHandler();\n exit(0);\n}\n\nconst { command, remainingArgs } = findCommand(args, commands);\n\nif (!command || !command.handler) {\n console.error(`Error: Unknown command '${args.join(\" \")}'\\n`);\n printHelp(commands);\n exit(1);\n}\n\n// Check if user is requesting help for a specific command\nif (remainingArgs.includes(\"--help\") || remainingArgs.includes(\"-h\")) {\n if (command.help) {\n console.log(helpFormatter.formatCommandHelp(command.help));\n } else {\n console.log(`Help not available for command '${command.name}'`);\n }\n exit(0);\n}\n\ntry {\n await command.handler(remainingArgs);\n} catch (error) {\n console.error(\n \"Error:\",\n error instanceof Error ? error.message : String(error),\n );\n exit(1);\n}\n", "import { parseArgs } from \"node:util\";\nimport { getGitRoot } from \"../../core/git/libs/get-git-root.ts\";\nimport { execInWorktree } from \"../../core/process/exec.ts\";\nimport { shellInWorktree } from \"../../core/process/shell.ts\";\nimport { isErr } from \"../../core/types/result.ts\";\nimport { attachWorktreeCore } from \"../../core/worktree/attach.ts\";\nimport {\n BranchNotFoundError,\n WorktreeAlreadyExistsError,\n} from \"../../core/worktree/errors.ts\";\nimport { exitCodes, exitWithError } from \"../errors.ts\";\nimport { output } from \"../output.ts\";\n\nexport async function attachHandler(args: string[]): Promise<void> {\n const { positionals, values } = parseArgs({\n args,\n strict: true,\n allowPositionals: true,\n options: {\n shell: {\n type: \"boolean\",\n short: \"s\",\n },\n exec: {\n type: \"string\",\n short: \"e\",\n },\n },\n });\n\n if (positionals.length === 0) {\n exitWithError(\n \"Missing required argument: branch name\",\n exitCodes.validationError,\n );\n }\n\n const [branchName] = positionals;\n\n if (values.shell && values.exec) {\n exitWithError(\n \"Cannot use both --shell and --exec options\",\n exitCodes.validationError,\n );\n }\n\n const gitRoot = await getGitRoot();\n const result = await attachWorktreeCore(gitRoot, branchName);\n\n if (isErr(result)) {\n const error = result.error;\n if (error instanceof WorktreeAlreadyExistsError) {\n exitWithError(error.message, exitCodes.validationError);\n }\n if (error instanceof BranchNotFoundError) {\n exitWithError(error.message, exitCodes.notFound);\n }\n exitWithError(error.message, exitCodes.generalError);\n }\n\n const worktreePath = result.value;\n output.log(`Attached phantom: ${branchName}`);\n\n if (values.shell) {\n const shellResult = await shellInWorktree(gitRoot, branchName);\n if (isErr(shellResult)) {\n exitWithError(shellResult.error.message, exitCodes.generalError);\n }\n } else if (values.exec) {\n const execResult = await execInWorktree(\n gitRoot,\n branchName,\n values.exec.split(\" \"),\n { interactive: true },\n );\n if (isErr(execResult)) {\n exitWithError(execResult.error.message, exitCodes.generalError);\n }\n }\n}\n", "import { dirname, resolve } from \"node:path\";\nimport { executeGitCommand } from \"../executor.ts\";\n\nexport async function getGitRoot(): Promise<string> {\n const { stdout } = await executeGitCommand([\"rev-parse\", \"--git-common-dir\"]);\n\n if (stdout.endsWith(\"/.git\") || stdout === \".git\") {\n return resolve(process.cwd(), dirname(stdout));\n }\n\n const { stdout: toplevel } = await executeGitCommand([\n \"rev-parse\",\n \"--show-toplevel\",\n ]);\n return toplevel;\n}\n", "import { execFile as execFileCallback } from \"node:child_process\";\nimport { promisify } from \"node:util\";\n\nconst execFile = promisify(execFileCallback);\n\nexport interface GitExecutorOptions {\n cwd?: string;\n env?: NodeJS.ProcessEnv;\n}\n\nexport interface GitExecutorResult {\n stdout: string;\n stderr: string;\n}\n\n/**\n * Execute a git command with consistent error handling\n */\nexport async function executeGitCommand(\n args: string[],\n options: GitExecutorOptions = {},\n): Promise<GitExecutorResult> {\n try {\n const result = await execFile(\"git\", args, {\n cwd: options.cwd,\n env: options.env || process.env,\n encoding: \"utf8\",\n });\n\n return {\n stdout: result.stdout.trim(),\n stderr: result.stderr.trim(),\n };\n } catch (error) {\n // Git commands often return non-zero exit codes for normal operations\n // (e.g., `git diff` returns 1 when there are differences)\n // So we need to handle errors carefully\n if (\n error &&\n typeof error === \"object\" &&\n \"stdout\" in error &&\n \"stderr\" in error\n ) {\n const execError = error as {\n stdout: string;\n stderr: string;\n code?: number;\n };\n\n // If we have stderr content, it's likely a real error\n if (execError.stderr?.trim()) {\n throw new Error(execError.stderr.trim());\n }\n\n // Otherwise, return the output even though the exit code was non-zero\n return {\n stdout: execError.stdout?.trim() || \"\",\n stderr: execError.stderr?.trim() || \"\",\n };\n }\n\n throw error;\n }\n}\n\n/**\n * Execute a git command in a specific directory\n */\nexport async function executeGitCommandInDirectory(\n directory: string,\n args: string[],\n): Promise<GitExecutorResult> {\n return executeGitCommand([\"-C\", directory, ...args], {});\n}\n", "/**\n * Represents a value that is either successful (Ok) or contains an error (Err).\n * This type is inspired by Rust's Result type and provides type-safe error handling.\n *\n * @template T - The type of the success value\n * @template E - The type of the error value (defaults to Error)\n */\nexport type Result<T, E = Error> =\n | { ok: true; value: T }\n | { ok: false; error: E };\n\n/**\n * Creates a successful Result containing the given value.\n *\n * @template T - The type of the success value\n * @param value - The success value to wrap\n * @returns A Result in the Ok state containing the value\n *\n * @example\n * const result = ok(42);\n * // result: Result<number, never> = { ok: true, value: 42 }\n */\nexport const ok = <T>(value: T): Result<T, never> => ({\n ok: true,\n value,\n});\n\n/**\n * Creates a failed Result containing the given error.\n *\n * @template E - The type of the error value\n * @param error - The error value to wrap\n * @returns A Result in the Err state containing the error\n *\n * @example\n * const result = err(new Error(\"Something went wrong\"));\n * // result: Result<never, Error> = { ok: false, error: Error(...) }\n */\nexport const err = <E>(error: E): Result<never, E> => ({\n ok: false,\n error,\n});\n\n/**\n * Type guard that checks if a Result is in the Ok state.\n *\n * @template T - The type of the success value\n * @template E - The type of the error value\n * @param result - The Result to check\n * @returns True if the Result is Ok, false otherwise\n *\n * @example\n * if (isOk(result)) {\n * console.log(result.value); // TypeScript knows result.value exists\n * }\n */\nexport const isOk = <T, E>(\n result: Result<T, E>,\n): result is { ok: true; value: T } => result.ok;\n\n/**\n * Type guard that checks if a Result is in the Err state.\n *\n * @template T - The type of the success value\n * @template E - The type of the error value\n * @param result - The Result to check\n * @returns True if the Result is Err, false otherwise\n *\n * @example\n * if (isErr(result)) {\n * console.error(result.error); // TypeScript knows result.error exists\n * }\n */\nexport const isErr = <T, E>(\n result: Result<T, E>,\n): result is { ok: false; error: E } => !result.ok;\n", "export class WorktreeError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"WorktreeError\";\n }\n}\n\nexport class WorktreeNotFoundError extends WorktreeError {\n constructor(name: string) {\n super(`Worktree '${name}' not found`);\n this.name = \"WorktreeNotFoundError\";\n }\n}\n\nexport class WorktreeAlreadyExistsError extends WorktreeError {\n constructor(name: string) {\n super(`Worktree '${name}' already exists`);\n this.name = \"WorktreeAlreadyExistsError\";\n }\n}\n\nexport class InvalidWorktreeNameError extends WorktreeError {\n constructor(name: string) {\n super(`Invalid worktree name: '${name}'`);\n this.name = \"InvalidWorktreeNameError\";\n }\n}\n\nexport class GitOperationError extends WorktreeError {\n constructor(operation: string, details: string) {\n super(`Git ${operation} failed: ${details}`);\n this.name = \"GitOperationError\";\n }\n}\n\nexport class BranchNotFoundError extends WorktreeError {\n constructor(branchName: string) {\n super(`Branch '${branchName}' not found`);\n this.name = \"BranchNotFoundError\";\n }\n}\n", "import fs from \"node:fs/promises\";\nimport { getPhantomDirectory, getWorktreePath } from \"../paths.ts\";\nimport { type Result, err, ok } from \"../types/result.ts\";\n\nexport interface ValidationResult {\n exists: boolean;\n path?: string;\n message?: string;\n}\n\nexport async function validateWorktreeExists(\n gitRoot: string,\n name: string,\n): Promise<ValidationResult> {\n const worktreePath = getWorktreePath(gitRoot, name);\n\n try {\n await fs.access(worktreePath);\n return {\n exists: true,\n path: worktreePath,\n };\n } catch {\n return {\n exists: false,\n message: `Worktree '${name}' does not exist`,\n };\n }\n}\n\nexport async function validateWorktreeDoesNotExist(\n gitRoot: string,\n name: string,\n): Promise<ValidationResult> {\n const worktreePath = getWorktreePath(gitRoot, name);\n\n try {\n await fs.access(worktreePath);\n return {\n exists: true,\n message: `Worktree '${name}' already exists`,\n };\n } catch {\n return {\n exists: false,\n path: worktreePath,\n };\n }\n}\n\nexport async function validatePhantomDirectoryExists(\n gitRoot: string,\n): Promise<boolean> {\n const phantomDir = getPhantomDirectory(gitRoot);\n\n try {\n await fs.access(phantomDir);\n return true;\n } catch {\n return false;\n }\n}\n\nexport function validateWorktreeName(name: string): Result<void, Error> {\n if (!name || name.trim() === \"\") {\n return err(new Error(\"Phantom name cannot be empty\"));\n }\n\n if (name.includes(\"/\")) {\n return err(new Error(\"Phantom name cannot contain slashes\"));\n }\n\n if (name.startsWith(\".\")) {\n return err(new Error(\"Phantom name cannot start with a dot\"));\n }\n\n return ok(undefined);\n}\n", "import { join } from \"node:path\";\n\nexport function getPhantomDirectory(gitRoot: string): string {\n return join(gitRoot, \".git\", \"phantom\", \"worktrees\");\n}\n\nexport function getWorktreePath(gitRoot: string, name: string): string {\n return join(getPhantomDirectory(gitRoot), name);\n}\n", "import {\n type ChildProcess,\n type SpawnOptions,\n spawn as nodeSpawn,\n} from \"node:child_process\";\nimport { type Result, err, ok } from \"../types/result.ts\";\nimport {\n type ProcessError,\n ProcessExecutionError,\n ProcessSignalError,\n ProcessSpawnError,\n} from \"./errors.ts\";\n\nexport interface SpawnSuccess {\n exitCode: number;\n}\n\nexport interface SpawnConfig {\n command: string;\n args?: string[];\n options?: SpawnOptions;\n}\n\nexport async function spawnProcess(\n config: SpawnConfig,\n): Promise<Result<SpawnSuccess, ProcessError>> {\n return new Promise((resolve) => {\n const { command, args = [], options = {} } = config;\n\n const childProcess: ChildProcess = nodeSpawn(command, args, {\n stdio: \"inherit\",\n ...options,\n });\n\n childProcess.on(\"error\", (error) => {\n resolve(err(new ProcessSpawnError(command, error.message)));\n });\n\n childProcess.on(\"exit\", (code, signal) => {\n if (signal) {\n resolve(err(new ProcessSignalError(signal)));\n } else {\n const exitCode = code ?? 0;\n if (exitCode === 0) {\n resolve(ok({ exitCode }));\n } else {\n resolve(err(new ProcessExecutionError(command, exitCode)));\n }\n }\n });\n });\n}\n", "export class ProcessError extends Error {\n public readonly exitCode?: number;\n\n constructor(message: string, exitCode?: number) {\n super(message);\n this.name = \"ProcessError\";\n this.exitCode = exitCode;\n }\n}\n\nexport class ProcessExecutionError extends ProcessError {\n constructor(command: string, exitCode: number) {\n super(`Command '${command}' failed with exit code ${exitCode}`, exitCode);\n this.name = \"ProcessExecutionError\";\n }\n}\n\nexport class ProcessSignalError extends ProcessError {\n constructor(signal: string) {\n const exitCode = 128 + (signal === \"SIGTERM\" ? 15 : 1);\n super(`Command terminated by signal: ${signal}`, exitCode);\n this.name = \"ProcessSignalError\";\n }\n}\n\nexport class ProcessSpawnError extends ProcessError {\n constructor(command: string, details: string) {\n super(`Error executing command '${command}': ${details}`);\n this.name = \"ProcessSpawnError\";\n }\n}\n", "import type { StdioOptions } from \"node:child_process\";\nimport { type Result, err } from \"../types/result.ts\";\nimport { WorktreeNotFoundError } from \"../worktree/errors.ts\";\nimport { validateWorktreeExists } from \"../worktree/validate.ts\";\nimport type { ProcessError } from \"./errors.ts\";\nimport { type SpawnSuccess, spawnProcess } from \"./spawn.ts\";\n\nexport type ExecInWorktreeSuccess = SpawnSuccess;\n\nexport interface ExecInWorktreeOptions {\n interactive?: boolean;\n}\n\nexport async function execInWorktree(\n gitRoot: string,\n worktreeName: string,\n command: string[],\n options: ExecInWorktreeOptions = {},\n): Promise<\n Result<ExecInWorktreeSuccess, WorktreeNotFoundError | ProcessError>\n> {\n const validation = await validateWorktreeExists(gitRoot, worktreeName);\n if (!validation.exists) {\n return err(new WorktreeNotFoundError(worktreeName));\n }\n\n const worktreePath = validation.path as string;\n const [cmd, ...args] = command;\n\n const stdio: StdioOptions = options.interactive\n ? \"inherit\"\n : [\"ignore\", \"inherit\", \"inherit\"];\n\n return spawnProcess({\n command: cmd,\n args,\n options: {\n cwd: worktreePath,\n stdio,\n },\n });\n}\n", "import { type Result, err } from \"../types/result.ts\";\nimport { WorktreeNotFoundError } from \"../worktree/errors.ts\";\nimport { validateWorktreeExists } from \"../worktree/validate.ts\";\nimport type { ProcessError } from \"./errors.ts\";\nimport { type SpawnSuccess, spawnProcess } from \"./spawn.ts\";\n\nexport type ShellInWorktreeSuccess = SpawnSuccess;\n\nexport async function shellInWorktree(\n gitRoot: string,\n worktreeName: string,\n): Promise<\n Result<ShellInWorktreeSuccess, WorktreeNotFoundError | ProcessError>\n> {\n const validation = await validateWorktreeExists(gitRoot, worktreeName);\n if (!validation.exists) {\n return err(new WorktreeNotFoundError(worktreeName));\n }\n\n const worktreePath = validation.path as string;\n const shell = process.env.SHELL || \"/bin/sh\";\n\n return spawnProcess({\n command: shell,\n args: [],\n options: {\n cwd: worktreePath,\n env: {\n ...process.env,\n PHANTOM: \"1\",\n PHANTOM_NAME: worktreeName,\n PHANTOM_PATH: worktreePath,\n },\n },\n });\n}\n", "import { existsSync } from \"node:fs\";\nimport { attachWorktree } from \"../git/libs/attach-worktree.ts\";\nimport { branchExists } from \"../git/libs/branch-exists.ts\";\nimport { getWorktreePath } from \"../paths.ts\";\nimport type { Result } from \"../types/result.ts\";\nimport { err, isErr, ok } from \"../types/result.ts\";\nimport { BranchNotFoundError, WorktreeAlreadyExistsError } from \"./errors.ts\";\nimport { validateWorktreeName } from \"./validate.ts\";\n\nexport async function attachWorktreeCore(\n gitRoot: string,\n name: string,\n): Promise<Result<string, Error>> {\n const validation = validateWorktreeName(name);\n if (isErr(validation)) {\n return validation;\n }\n\n const worktreePath = getWorktreePath(gitRoot, name);\n if (existsSync(worktreePath)) {\n return err(new WorktreeAlreadyExistsError(name));\n }\n\n const branchCheckResult = await branchExists(gitRoot, name);\n if (isErr(branchCheckResult)) {\n return err(branchCheckResult.error);\n }\n\n if (!branchCheckResult.value) {\n return err(new BranchNotFoundError(name));\n }\n\n const attachResult = await attachWorktree(gitRoot, worktreePath, name);\n if (isErr(attachResult)) {\n return err(attachResult.error);\n }\n\n return ok(worktreePath);\n}\n", "import type { Result } from \"../../types/result.ts\";\nimport { err, ok } from \"../../types/result.ts\";\nimport { executeGitCommand } from \"../executor.ts\";\n\nexport async function attachWorktree(\n gitRoot: string,\n worktreePath: string,\n branchName: string,\n): Promise<Result<void, Error>> {\n try {\n await executeGitCommand([\"worktree\", \"add\", worktreePath, branchName], {\n cwd: gitRoot,\n });\n return ok(undefined);\n } catch (error) {\n return err(\n error instanceof Error\n ? error\n : new Error(`Failed to attach worktree: ${String(error)}`),\n );\n }\n}\n", "import type { Result } from \"../../types/result.ts\";\nimport { err, isErr, ok } from \"../../types/result.ts\";\nimport { executeGitCommand } from \"../executor.ts\";\n\nexport async function branchExists(\n gitRoot: string,\n branchName: string,\n): Promise<Result<boolean, Error>> {\n try {\n await executeGitCommand(\n [\"show-ref\", \"--verify\", \"--quiet\", `refs/heads/${branchName}`],\n { cwd: gitRoot },\n );\n return ok(true);\n } catch (error) {\n if (error && typeof error === \"object\" && \"code\" in error) {\n const execError = error as { code?: number; message?: string };\n if (execError.code === 1) {\n return ok(false);\n }\n }\n return err(\n new Error(\n `Failed to check branch existence: ${\n error instanceof Error ? error.message : String(error)\n }`,\n ),\n );\n }\n}\n", "import type { ChildProcess } from \"node:child_process\";\n\nexport const output = {\n log: (message: string) => {\n console.log(message);\n },\n\n error: (message: string) => {\n console.error(message);\n },\n\n warn: (message: string) => {\n console.warn(message);\n },\n\n table: (data: unknown) => {\n console.table(data);\n },\n\n processOutput: (proc: ChildProcess) => {\n proc.stdout?.pipe(process.stdout);\n proc.stderr?.pipe(process.stderr);\n },\n};\n", "import { output } from \"./output.ts\";\n\nexport const exitCodes = {\n success: 0,\n generalError: 1,\n notFound: 2,\n validationError: 3,\n} as const;\n\nexport function handleError(\n error: unknown,\n exitCode: number = exitCodes.generalError,\n): never {\n if (error instanceof Error) {\n output.error(error.message);\n } else {\n output.error(String(error));\n }\n process.exit(exitCode);\n}\n\nexport function exitWithSuccess(): never {\n process.exit(exitCodes.success);\n}\n\nexport function exitWithError(\n message: string,\n exitCode: number = exitCodes.generalError,\n): never {\n output.error(message);\n process.exit(exitCode);\n}\n", "import { parseArgs } from \"node:util\";\nimport {\n ConfigNotFoundError,\n ConfigParseError,\n loadConfig,\n} from \"../../core/config/loader.ts\";\nimport { ConfigValidationError } from \"../../core/config/validate.ts\";\nimport { getGitRoot } from \"../../core/git/libs/get-git-root.ts\";\nimport { execInWorktree } from \"../../core/process/exec.ts\";\nimport { shellInWorktree } from \"../../core/process/shell.ts\";\nimport { executeTmuxCommand, isInsideTmux } from \"../../core/process/tmux.ts\";\nimport { isErr, isOk } from \"../../core/types/result.ts\";\nimport { createWorktree as createWorktreeCore } from \"../../core/worktree/create.ts\";\nimport { WorktreeAlreadyExistsError } from \"../../core/worktree/errors.ts\";\nimport { exitCodes, exitWithError, exitWithSuccess } from \"../errors.ts\";\nimport { output } from \"../output.ts\";\n\nexport async function createHandler(args: string[]): Promise<void> {\n const { values, positionals } = parseArgs({\n args,\n options: {\n shell: {\n type: \"boolean\",\n short: \"s\",\n },\n exec: {\n type: \"string\",\n short: \"x\",\n },\n tmux: {\n type: \"boolean\",\n short: \"t\",\n },\n \"tmux-vertical\": {\n type: \"boolean\",\n },\n \"tmux-v\": {\n type: \"boolean\",\n },\n \"tmux-horizontal\": {\n type: \"boolean\",\n },\n \"tmux-h\": {\n type: \"boolean\",\n },\n \"copy-file\": {\n type: \"string\",\n multiple: true,\n },\n },\n strict: true,\n allowPositionals: true,\n });\n\n if (positionals.length === 0) {\n exitWithError(\n \"Please provide a name for the new worktree\",\n exitCodes.validationError,\n );\n }\n\n const worktreeName = positionals[0];\n const openShell = values.shell ?? false;\n const execCommand = values.exec;\n const copyFileOptions = values[\"copy-file\"];\n\n // Determine tmux option\n const tmuxOption =\n values.tmux ||\n values[\"tmux-vertical\"] ||\n values[\"tmux-v\"] ||\n values[\"tmux-horizontal\"] ||\n values[\"tmux-h\"];\n\n let tmuxDirection: \"new\" | \"vertical\" | \"horizontal\" | undefined;\n if (values.tmux) {\n tmuxDirection = \"new\";\n } else if (values[\"tmux-vertical\"] || values[\"tmux-v\"]) {\n tmuxDirection = \"vertical\";\n } else if (values[\"tmux-horizontal\"] || values[\"tmux-h\"]) {\n tmuxDirection = \"horizontal\";\n }\n\n if (\n [openShell, execCommand !== undefined, tmuxOption].filter(Boolean).length >\n 1\n ) {\n exitWithError(\n \"Cannot use --shell, --exec, and --tmux options together\",\n exitCodes.validationError,\n );\n }\n\n if (tmuxOption && !(await isInsideTmux())) {\n exitWithError(\n \"The --tmux option can only be used inside a tmux session\",\n exitCodes.validationError,\n );\n }\n\n try {\n const gitRoot = await getGitRoot();\n\n let filesToCopy: string[] = [];\n\n // Load files from config\n const configResult = await loadConfig(gitRoot);\n if (isOk(configResult)) {\n if (configResult.value.postCreate?.copyFiles) {\n filesToCopy = [...configResult.value.postCreate.copyFiles];\n }\n } else {\n // Display warning for validation and parse errors\n if (configResult.error instanceof ConfigValidationError) {\n output.warn(`Configuration warning: ${configResult.error.message}`);\n } else if (configResult.error instanceof ConfigParseError) {\n output.warn(`Configuration warning: ${configResult.error.message}`);\n }\n // ConfigNotFoundError remains silent as the config file is optional\n }\n\n // Add files from CLI options\n if (copyFileOptions && copyFileOptions.length > 0) {\n const cliFiles = Array.isArray(copyFileOptions)\n ? copyFileOptions\n : [copyFileOptions];\n // Merge with config files, removing duplicates\n filesToCopy = [...new Set([...filesToCopy, ...cliFiles])];\n }\n\n const result = await createWorktreeCore(gitRoot, worktreeName, {\n copyFiles: filesToCopy.length > 0 ? filesToCopy : undefined,\n });\n\n if (isErr(result)) {\n const exitCode =\n result.error instanceof WorktreeAlreadyExistsError\n ? exitCodes.validationError\n : exitCodes.generalError;\n exitWithError(result.error.message, exitCode);\n }\n\n output.log(result.value.message);\n\n if (result.value.copyError) {\n output.error(\n `\\nWarning: Failed to copy some files: ${result.value.copyError}`,\n );\n }\n\n // Execute post-create commands from config\n if (isOk(configResult) && configResult.value.postCreate?.commands) {\n const commands = configResult.value.postCreate.commands;\n output.log(\"\\nRunning post-create commands...\");\n\n for (const command of commands) {\n output.log(`Executing: ${command}`);\n const shell = process.env.SHELL || \"/bin/sh\";\n const cmdResult = await execInWorktree(gitRoot, worktreeName, [\n shell,\n \"-c\",\n command,\n ]);\n\n if (isErr(cmdResult)) {\n output.error(`Failed to execute command: ${cmdResult.error.message}`);\n const exitCode =\n \"exitCode\" in cmdResult.error\n ? (cmdResult.error.exitCode ?? exitCodes.generalError)\n : exitCodes.generalError;\n exitWithError(`Post-create command failed: ${command}`, exitCode);\n }\n\n // Check exit code\n if (cmdResult.value.exitCode !== 0) {\n exitWithError(\n `Post-create command failed: ${command}`,\n cmdResult.value.exitCode,\n );\n }\n }\n }\n\n if (execCommand && isOk(result)) {\n output.log(\n `\\nExecuting command in worktree '${worktreeName}': ${execCommand}`,\n );\n\n const shell = process.env.SHELL || \"/bin/sh\";\n const execResult = await execInWorktree(\n gitRoot,\n worktreeName,\n [shell, \"-c\", execCommand],\n { interactive: true },\n );\n\n if (isErr(execResult)) {\n output.error(execResult.error.message);\n const exitCode =\n \"exitCode\" in execResult.error\n ? (execResult.error.exitCode ?? exitCodes.generalError)\n : exitCodes.generalError;\n exitWithError(\"\", exitCode);\n }\n\n process.exit(execResult.value.exitCode ?? 0);\n }\n\n if (openShell && isOk(result)) {\n output.log(\n `\\nEntering worktree '${worktreeName}' at ${result.value.path}`,\n );\n output.log(\"Type 'exit' to return to your original directory\\n\");\n\n const shellResult = await shellInWorktree(gitRoot, worktreeName);\n\n if (isErr(shellResult)) {\n output.error(shellResult.error.message);\n const exitCode =\n \"exitCode\" in shellResult.error\n ? (shellResult.error.exitCode ?? exitCodes.generalError)\n : exitCodes.generalError;\n exitWithError(\"\", exitCode);\n }\n\n process.exit(shellResult.value.exitCode ?? 0);\n }\n\n if (tmuxDirection && isOk(result)) {\n output.log(\n `\\nOpening worktree '${worktreeName}' in tmux ${\n tmuxDirection === \"new\" ? \"window\" : \"pane\"\n }...`,\n );\n\n const shell = process.env.SHELL || \"/bin/sh\";\n\n const tmuxResult = await executeTmuxCommand({\n direction: tmuxDirection,\n command: shell,\n cwd: result.value.path,\n env: {\n PHANTOM: \"1\",\n PHANTOM_NAME: worktreeName,\n PHANTOM_PATH: result.value.path,\n },\n });\n\n if (isErr(tmuxResult)) {\n output.error(tmuxResult.error.message);\n const exitCode =\n \"exitCode\" in tmuxResult.error\n ? (tmuxResult.error.exitCode ?? exitCodes.generalError)\n : exitCodes.generalError;\n exitWithError(\"\", exitCode);\n }\n }\n\n exitWithSuccess();\n } catch (error) {\n exitWithError(\n error instanceof Error ? error.message : String(error),\n exitCodes.generalError,\n );\n }\n}\n", "import fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { type Result, err, ok } from \"../types/result.ts\";\nimport { type ConfigValidationError, validateConfig } from \"./validate.ts\";\n\nexport interface PhantomConfig {\n postCreate?: {\n copyFiles?: string[];\n commands?: string[];\n };\n}\n\nexport class ConfigNotFoundError extends Error {\n constructor() {\n super(\"phantom.config.json not found\");\n this.name = \"ConfigNotFoundError\";\n }\n}\n\nexport class ConfigParseError extends Error {\n constructor(message: string) {\n super(`Failed to parse phantom.config.json: ${message}`);\n this.name = \"ConfigParseError\";\n }\n}\n\nexport async function loadConfig(\n gitRoot: string,\n): Promise<\n Result<\n PhantomConfig,\n ConfigNotFoundError | ConfigParseError | ConfigValidationError\n >\n> {\n const configPath = path.join(gitRoot, \"phantom.config.json\");\n\n try {\n const content = await fs.readFile(configPath, \"utf-8\");\n try {\n const parsed = JSON.parse(content);\n const validationResult = validateConfig(parsed);\n\n if (!validationResult.ok) {\n return err(validationResult.error);\n }\n\n return ok(validationResult.value);\n } catch (error) {\n return err(\n new ConfigParseError(\n error instanceof Error ? error.message : String(error),\n ),\n );\n }\n } catch (error) {\n if (error instanceof Error && \"code\" in error && error.code === \"ENOENT\") {\n return err(new ConfigNotFoundError());\n }\n throw error;\n }\n}\n", "export function isObject(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n", "import { type Result, err, ok } from \"../types/result.ts\";\nimport { isObject } from \"../utils/type-guards.ts\";\nimport type { PhantomConfig } from \"./loader.ts\";\n\nexport class ConfigValidationError extends Error {\n constructor(message: string) {\n super(`Invalid phantom.config.json: ${message}`);\n this.name = \"ConfigValidationError\";\n }\n}\n\nexport function validateConfig(\n config: unknown,\n): Result<PhantomConfig, ConfigValidationError> {\n if (!isObject(config)) {\n return err(new ConfigValidationError(\"Configuration must be an object\"));\n }\n\n const cfg = config;\n\n if (cfg.postCreate !== undefined) {\n if (!isObject(cfg.postCreate)) {\n return err(new ConfigValidationError(\"postCreate must be an object\"));\n }\n\n const postCreate = cfg.postCreate;\n if (postCreate.copyFiles !== undefined) {\n if (!Array.isArray(postCreate.copyFiles)) {\n return err(\n new ConfigValidationError(\"postCreate.copyFiles must be an array\"),\n );\n }\n\n if (!postCreate.copyFiles.every((f: unknown) => typeof f === \"string\")) {\n return err(\n new ConfigValidationError(\n \"postCreate.copyFiles must contain only strings\",\n ),\n );\n }\n }\n\n if (postCreate.commands !== undefined) {\n if (!Array.isArray(postCreate.commands)) {\n return err(\n new ConfigValidationError(\"postCreate.commands must be an array\"),\n );\n }\n\n if (!postCreate.commands.every((c: unknown) => typeof c === \"string\")) {\n return err(\n new ConfigValidationError(\n \"postCreate.commands must contain only strings\",\n ),\n );\n }\n }\n }\n\n return ok(config as PhantomConfig);\n}\n", "import type { Result } from \"../types/result.ts\";\nimport type { ProcessError } from \"./errors.ts\";\nimport { type SpawnSuccess, spawnProcess } from \"./spawn.ts\";\n\nexport type TmuxSplitDirection = \"new\" | \"vertical\" | \"horizontal\";\n\nexport interface TmuxOptions {\n direction: TmuxSplitDirection;\n command: string;\n cwd?: string;\n env?: Record<string, string>;\n}\n\nexport type TmuxSuccess = SpawnSuccess;\n\nexport async function isInsideTmux(): Promise<boolean> {\n return process.env.TMUX !== undefined;\n}\n\nexport async function executeTmuxCommand(\n options: TmuxOptions,\n): Promise<Result<TmuxSuccess, ProcessError>> {\n const { direction, command, cwd, env } = options;\n\n const tmuxArgs: string[] = [];\n\n switch (direction) {\n case \"new\":\n tmuxArgs.push(\"new-window\");\n break;\n case \"vertical\":\n tmuxArgs.push(\"split-window\", \"-v\");\n break;\n case \"horizontal\":\n tmuxArgs.push(\"split-window\", \"-h\");\n break;\n }\n\n if (cwd) {\n tmuxArgs.push(\"-c\", cwd);\n }\n\n // Add environment variables safely\n if (env) {\n for (const [key, value] of Object.entries(env)) {\n tmuxArgs.push(\"-e\", `${key}=${value}`);\n }\n }\n\n tmuxArgs.push(command);\n\n const result = await spawnProcess({\n command: \"tmux\",\n args: tmuxArgs,\n });\n\n return result;\n}\n", "import fs from \"node:fs/promises\";\nimport { addWorktree } from \"../git/libs/add-worktree.ts\";\nimport { getPhantomDirectory, getWorktreePath } from \"../paths.ts\";\nimport { type Result, err, isErr, isOk, ok } from \"../types/result.ts\";\nimport { GitOperationError, WorktreeAlreadyExistsError } from \"./errors.ts\";\nimport { copyFiles } from \"./file-copier.ts\";\nimport {\n validateWorktreeDoesNotExist,\n validateWorktreeName,\n} from \"./validate.ts\";\n\nexport interface CreateWorktreeOptions {\n branch?: string;\n commitish?: string;\n copyFiles?: string[];\n}\n\nexport interface CreateWorktreeSuccess {\n message: string;\n path: string;\n copiedFiles?: string[];\n skippedFiles?: string[];\n copyError?: string;\n}\n\nexport async function createWorktree(\n gitRoot: string,\n name: string,\n options: CreateWorktreeOptions = {},\n): Promise<\n Result<CreateWorktreeSuccess, WorktreeAlreadyExistsError | GitOperationError>\n> {\n const nameValidation = validateWorktreeName(name);\n if (isErr(nameValidation)) {\n return nameValidation;\n }\n\n const { branch = name, commitish = \"HEAD\" } = options;\n\n const worktreesPath = getPhantomDirectory(gitRoot);\n const worktreePath = getWorktreePath(gitRoot, name);\n\n try {\n await fs.access(worktreesPath);\n } catch {\n await fs.mkdir(worktreesPath, { recursive: true });\n }\n\n const validation = await validateWorktreeDoesNotExist(gitRoot, name);\n if (validation.exists) {\n return err(new WorktreeAlreadyExistsError(name));\n }\n\n try {\n await addWorktree({\n path: worktreePath,\n branch,\n commitish,\n });\n\n let copiedFiles: string[] | undefined;\n let skippedFiles: string[] | undefined;\n let copyError: string | undefined;\n\n if (options.copyFiles && options.copyFiles.length > 0) {\n const copyResult = await copyFiles(\n gitRoot,\n worktreePath,\n options.copyFiles,\n );\n\n if (isOk(copyResult)) {\n copiedFiles = copyResult.value.copiedFiles;\n skippedFiles = copyResult.value.skippedFiles;\n } else {\n copyError = copyResult.error.message;\n }\n }\n\n return ok({\n message: `Created worktree '${name}' at ${worktreePath}`,\n path: worktreePath,\n copiedFiles,\n skippedFiles,\n copyError,\n });\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n return err(new GitOperationError(\"worktree add\", errorMessage));\n }\n}\n", "import { executeGitCommand } from \"../executor.ts\";\n\nexport interface AddWorktreeOptions {\n path: string;\n branch: string;\n commitish?: string;\n}\n\nexport async function addWorktree(options: AddWorktreeOptions): Promise<void> {\n const { path, branch, commitish = \"HEAD\" } = options;\n\n await executeGitCommand([\"worktree\", \"add\", path, \"-b\", branch, commitish]);\n}\n", "import { copyFile, mkdir, stat } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { type Result, err, ok } from \"../types/result.ts\";\n\nexport interface CopyFileResult {\n copiedFiles: string[];\n skippedFiles: string[];\n}\n\nexport class FileCopyError extends Error {\n public readonly file: string;\n\n constructor(file: string, message: string) {\n super(`Failed to copy ${file}: ${message}`);\n this.name = \"FileCopyError\";\n this.file = file;\n }\n}\n\nexport async function copyFiles(\n sourceDir: string,\n targetDir: string,\n files: string[],\n): Promise<Result<CopyFileResult, FileCopyError>> {\n const copiedFiles: string[] = [];\n const skippedFiles: string[] = [];\n\n for (const file of files) {\n const sourcePath = path.join(sourceDir, file);\n const targetPath = path.join(targetDir, file);\n\n try {\n const stats = await stat(sourcePath);\n if (!stats.isFile()) {\n skippedFiles.push(file);\n continue;\n }\n\n const targetDirPath = path.dirname(targetPath);\n await mkdir(targetDirPath, { recursive: true });\n\n await copyFile(sourcePath, targetPath);\n copiedFiles.push(file);\n } catch (error) {\n if (\n error instanceof Error &&\n \"code\" in error &&\n error.code === \"ENOENT\"\n ) {\n skippedFiles.push(file);\n } else {\n return err(\n new FileCopyError(\n file,\n error instanceof Error ? error.message : String(error),\n ),\n );\n }\n }\n }\n\n return ok({ copiedFiles, skippedFiles });\n}\n", "import { parseArgs } from \"node:util\";\nimport { getCurrentWorktree } from \"../../core/git/libs/get-current-worktree.ts\";\nimport { getGitRoot } from \"../../core/git/libs/get-git-root.ts\";\nimport { isErr } from \"../../core/types/result.ts\";\nimport { deleteWorktree as deleteWorktreeCore } from \"../../core/worktree/delete.ts\";\nimport {\n WorktreeError,\n WorktreeNotFoundError,\n} from \"../../core/worktree/errors.ts\";\nimport { selectWorktreeWithFzf } from \"../../core/worktree/select.ts\";\nimport { exitCodes, exitWithError, exitWithSuccess } from \"../errors.ts\";\nimport { output } from \"../output.ts\";\n\nexport async function deleteHandler(args: string[]): Promise<void> {\n const { values, positionals } = parseArgs({\n args,\n options: {\n force: {\n type: \"boolean\",\n short: \"f\",\n },\n current: {\n type: \"boolean\",\n },\n fzf: {\n type: \"boolean\",\n default: false,\n },\n },\n strict: true,\n allowPositionals: true,\n });\n\n const deleteCurrent = values.current ?? false;\n const useFzf = values.fzf ?? false;\n\n if (positionals.length === 0 && !deleteCurrent && !useFzf) {\n exitWithError(\n \"Please provide a worktree name to delete, use --current to delete the current worktree, or use --fzf for interactive selection\",\n exitCodes.validationError,\n );\n }\n\n if ((positionals.length > 0 || useFzf) && deleteCurrent) {\n exitWithError(\n \"Cannot specify --current with a worktree name or --fzf option\",\n exitCodes.validationError,\n );\n }\n\n if (positionals.length > 0 && useFzf) {\n exitWithError(\n \"Cannot specify both a worktree name and --fzf option\",\n exitCodes.validationError,\n );\n }\n\n const forceDelete = values.force ?? false;\n\n try {\n const gitRoot = await getGitRoot();\n\n let worktreeName: string;\n if (deleteCurrent) {\n const currentWorktree = await getCurrentWorktree(gitRoot);\n if (!currentWorktree) {\n exitWithError(\n \"Not in a worktree directory. The --current option can only be used from within a worktree.\",\n exitCodes.validationError,\n );\n }\n worktreeName = currentWorktree;\n } else if (useFzf) {\n const selectResult = await selectWorktreeWithFzf(gitRoot);\n if (isErr(selectResult)) {\n exitWithError(selectResult.error.message, exitCodes.generalError);\n }\n if (!selectResult.value) {\n exitWithSuccess();\n }\n worktreeName = selectResult.value.name;\n } else {\n worktreeName = positionals[0];\n }\n\n const result = await deleteWorktreeCore(gitRoot, worktreeName, {\n force: forceDelete,\n });\n\n if (isErr(result)) {\n const exitCode =\n result.error instanceof WorktreeNotFoundError\n ? exitCodes.validationError\n : result.error instanceof WorktreeError &&\n result.error.message.includes(\"uncommitted changes\")\n ? exitCodes.validationError\n : exitCodes.generalError;\n exitWithError(result.error.message, exitCode);\n }\n\n output.log(result.value.message);\n exitWithSuccess();\n } catch (error) {\n exitWithError(\n error instanceof Error ? error.message : String(error),\n exitCodes.generalError,\n );\n }\n}\n", "import { executeGitCommand } from \"../executor.ts\";\n\nexport interface GitWorktree {\n path: string;\n branch: string;\n head: string;\n isLocked: boolean;\n isPrunable: boolean;\n}\n\nexport async function listWorktrees(gitRoot: string): Promise<GitWorktree[]> {\n const { stdout } = await executeGitCommand([\n \"worktree\",\n \"list\",\n \"--porcelain\",\n ]);\n\n const worktrees: GitWorktree[] = [];\n let currentWorktree: Partial<GitWorktree> = {};\n\n const lines = stdout.split(\"\\n\").filter((line) => line.length > 0);\n\n for (const line of lines) {\n if (line.startsWith(\"worktree \")) {\n if (currentWorktree.path) {\n worktrees.push(currentWorktree as GitWorktree);\n }\n currentWorktree = {\n path: line.substring(\"worktree \".length),\n isLocked: false,\n isPrunable: false,\n };\n } else if (line.startsWith(\"HEAD \")) {\n currentWorktree.head = line.substring(\"HEAD \".length);\n } else if (line.startsWith(\"branch \")) {\n const fullBranch = line.substring(\"branch \".length);\n currentWorktree.branch = fullBranch.startsWith(\"refs/heads/\")\n ? fullBranch.substring(\"refs/heads/\".length)\n : fullBranch;\n } else if (line === \"detached\") {\n currentWorktree.branch = \"(detached HEAD)\";\n } else if (line === \"locked\") {\n currentWorktree.isLocked = true;\n } else if (line === \"prunable\") {\n currentWorktree.isPrunable = true;\n }\n }\n\n if (currentWorktree.path) {\n worktrees.push(currentWorktree as GitWorktree);\n }\n\n return worktrees;\n}\n", "import { executeGitCommand } from \"../executor.ts\";\nimport { listWorktrees } from \"./list-worktrees.ts\";\n\nexport async function getCurrentWorktree(\n gitRoot: string,\n): Promise<string | null> {\n try {\n const { stdout: currentPath } = await executeGitCommand([\n \"rev-parse\",\n \"--show-toplevel\",\n ]);\n\n const currentPathTrimmed = currentPath.trim();\n\n const worktrees = await listWorktrees(gitRoot);\n\n const currentWorktree = worktrees.find(\n (wt) => wt.path === currentPathTrimmed,\n );\n\n if (!currentWorktree || currentWorktree.path === gitRoot) {\n return null;\n }\n\n return currentWorktree.branch;\n } catch {\n return null;\n }\n}\n", "import {\n executeGitCommand,\n executeGitCommandInDirectory,\n} from \"../git/executor.ts\";\nimport { type Result, err, isOk, ok } from \"../types/result.ts\";\nimport {\n GitOperationError,\n WorktreeError,\n WorktreeNotFoundError,\n} from \"./errors.ts\";\nimport { validateWorktreeExists } from \"./validate.ts\";\n\nexport interface DeleteWorktreeOptions {\n force?: boolean;\n}\n\nexport interface DeleteWorktreeSuccess {\n message: string;\n hasUncommittedChanges?: boolean;\n changedFiles?: number;\n}\n\nexport interface WorktreeStatus {\n hasUncommittedChanges: boolean;\n changedFiles: number;\n}\n\nexport async function getWorktreeStatus(\n worktreePath: string,\n): Promise<WorktreeStatus> {\n try {\n const { stdout } = await executeGitCommandInDirectory(worktreePath, [\n \"status\",\n \"--porcelain\",\n ]);\n if (stdout) {\n return {\n hasUncommittedChanges: true,\n changedFiles: stdout.split(\"\\n\").length,\n };\n }\n } catch {\n // If git status fails, assume no changes\n }\n return {\n hasUncommittedChanges: false,\n changedFiles: 0,\n };\n}\n\nexport async function removeWorktree(\n gitRoot: string,\n worktreePath: string,\n force = false,\n): Promise<void> {\n try {\n await executeGitCommand([\"worktree\", \"remove\", worktreePath], {\n cwd: gitRoot,\n });\n } catch (error) {\n // Always try force removal if the regular removal fails\n try {\n await executeGitCommand([\"worktree\", \"remove\", \"--force\", worktreePath], {\n cwd: gitRoot,\n });\n } catch {\n throw new Error(\"Failed to remove worktree\");\n }\n }\n}\n\nexport async function deleteBranch(\n gitRoot: string,\n branchName: string,\n): Promise<Result<boolean, GitOperationError>> {\n try {\n await executeGitCommand([\"branch\", \"-D\", branchName], { cwd: gitRoot });\n return ok(true);\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n return err(new GitOperationError(\"branch delete\", errorMessage));\n }\n}\n\nexport async function deleteWorktree(\n gitRoot: string,\n name: string,\n options: DeleteWorktreeOptions = {},\n): Promise<\n Result<\n DeleteWorktreeSuccess,\n WorktreeNotFoundError | WorktreeError | GitOperationError\n >\n> {\n const { force = false } = options;\n\n const validation = await validateWorktreeExists(gitRoot, name);\n if (!validation.exists) {\n return err(new WorktreeNotFoundError(name));\n }\n\n const worktreePath = validation.path as string;\n\n const status = await getWorktreeStatus(worktreePath);\n\n if (status.hasUncommittedChanges && !force) {\n return err(\n new WorktreeError(\n `Worktree '${name}' has uncommitted changes (${status.changedFiles} files). Use --force to delete anyway.`,\n ),\n );\n }\n\n try {\n await removeWorktree(gitRoot, worktreePath, force);\n\n const branchName = name;\n const branchResult = await deleteBranch(gitRoot, branchName);\n\n let message: string;\n if (isOk(branchResult)) {\n message = `Deleted worktree '${name}' and its branch '${branchName}'`;\n } else {\n message = `Deleted worktree '${name}'`;\n message += `\\nNote: Branch '${branchName}' could not be deleted: ${branchResult.error.message}`;\n }\n\n if (status.hasUncommittedChanges) {\n message = `Warning: Worktree '${name}' had uncommitted changes (${status.changedFiles} files)\\n${message}`;\n }\n\n return ok({\n message,\n hasUncommittedChanges: status.hasUncommittedChanges,\n changedFiles: status.hasUncommittedChanges\n ? status.changedFiles\n : undefined,\n });\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n return err(new GitOperationError(\"worktree remove\", errorMessage));\n }\n}\n", "import { spawn } from \"node:child_process\";\nimport { type Result, err, ok } from \"../types/result.ts\";\n\nexport interface FzfOptions {\n prompt?: string;\n header?: string;\n previewCommand?: string;\n}\n\nexport async function selectWithFzf(\n items: string[],\n options: FzfOptions = {},\n): Promise<Result<string | null, Error>> {\n return new Promise((resolve) => {\n const args: string[] = [];\n\n if (options.prompt) {\n args.push(\"--prompt\", options.prompt);\n }\n\n if (options.header) {\n args.push(\"--header\", options.header);\n }\n\n if (options.previewCommand) {\n args.push(\"--preview\", options.previewCommand);\n }\n\n const fzf = spawn(\"fzf\", args, {\n stdio: [\"pipe\", \"pipe\", \"pipe\"],\n });\n\n let result = \"\";\n let errorOutput = \"\";\n\n fzf.stdout.on(\"data\", (data) => {\n result += data.toString();\n });\n\n if (fzf.stderr) {\n fzf.stderr.on(\"data\", (data) => {\n errorOutput += data.toString();\n });\n }\n\n fzf.on(\"error\", (error) => {\n if (error.message.includes(\"ENOENT\")) {\n resolve(\n err(new Error(\"fzf command not found. Please install fzf first.\")),\n );\n } else {\n resolve(err(error));\n }\n });\n\n fzf.on(\"close\", (code) => {\n if (code === 0) {\n const selected = result.trim();\n resolve(ok(selected || null));\n } else if (code === 1) {\n resolve(ok(null));\n } else if (code === 130) {\n resolve(ok(null));\n } else {\n resolve(err(new Error(`fzf exited with code ${code}: ${errorOutput}`)));\n }\n });\n\n fzf.stdin.write(items.join(\"\\n\"));\n fzf.stdin.end();\n });\n}\n", "import { executeGitCommandInDirectory } from \"../git/executor.ts\";\nimport { listWorktrees as gitListWorktrees } from \"../git/libs/list-worktrees.ts\";\nimport { getPhantomDirectory, getWorktreePath } from \"../paths.ts\";\nimport { type Result, ok } from \"../types/result.ts\";\n\nexport interface WorktreeInfo {\n name: string;\n path: string;\n branch: string;\n isClean: boolean;\n}\n\nexport interface ListWorktreesSuccess {\n worktrees: WorktreeInfo[];\n message?: string;\n}\n\nexport async function getWorktreeBranch(worktreePath: string): Promise<string> {\n try {\n const { stdout } = await executeGitCommandInDirectory(worktreePath, [\n \"branch\",\n \"--show-current\",\n ]);\n return stdout || \"(detached HEAD)\";\n } catch {\n return \"unknown\";\n }\n}\n\nexport async function getWorktreeStatus(\n worktreePath: string,\n): Promise<boolean> {\n try {\n const { stdout } = await executeGitCommandInDirectory(worktreePath, [\n \"status\",\n \"--porcelain\",\n ]);\n return !stdout; // Clean if no output\n } catch {\n // If git status fails, assume clean\n return true;\n }\n}\n\nexport async function getWorktreeInfo(\n gitRoot: string,\n name: string,\n): Promise<WorktreeInfo> {\n const worktreePath = getWorktreePath(gitRoot, name);\n\n const [branch, isClean] = await Promise.all([\n getWorktreeBranch(worktreePath),\n getWorktreeStatus(worktreePath),\n ]);\n\n return {\n name,\n path: worktreePath,\n branch,\n isClean,\n };\n}\n\nexport async function listWorktrees(\n gitRoot: string,\n): Promise<Result<ListWorktreesSuccess, never>> {\n try {\n const gitWorktrees = await gitListWorktrees(gitRoot);\n const phantomDir = getPhantomDirectory(gitRoot);\n\n const phantomWorktrees = gitWorktrees.filter((worktree) =>\n worktree.path.startsWith(phantomDir),\n );\n\n if (phantomWorktrees.length === 0) {\n return ok({\n worktrees: [],\n message: \"No worktrees found\",\n });\n }\n\n const worktrees = await Promise.all(\n phantomWorktrees.map(async (gitWorktree) => {\n const name = gitWorktree.path.substring(phantomDir.length + 1);\n const isClean = await getWorktreeStatus(gitWorktree.path);\n\n return {\n name,\n path: gitWorktree.path,\n branch: gitWorktree.branch || \"(detached HEAD)\",\n isClean,\n };\n }),\n );\n\n return ok({\n worktrees,\n });\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n throw new Error(`Failed to list worktrees: ${errorMessage}`);\n }\n}\n", "import { type Result, isErr } from \"../types/result.ts\";\nimport { selectWithFzf } from \"../utils/fzf.ts\";\nimport { listWorktrees } from \"./list.ts\";\n\nexport interface SelectWorktreeResult {\n name: string;\n branch: string | null;\n isClean: boolean;\n}\n\nexport async function selectWorktreeWithFzf(\n gitRoot: string,\n): Promise<Result<SelectWorktreeResult | null, Error>> {\n const listResult = await listWorktrees(gitRoot);\n\n if (isErr(listResult)) {\n return listResult;\n }\n\n const { worktrees } = listResult.value;\n\n if (worktrees.length === 0) {\n return {\n ok: true,\n value: null,\n };\n }\n\n const list = worktrees.map((wt) => {\n const branchInfo = wt.branch ? `(${wt.branch})` : \"\";\n const status = !wt.isClean ? \" [dirty]\" : \"\";\n return `${wt.name} ${branchInfo}${status}`;\n });\n\n const fzfResult = await selectWithFzf(list, {\n prompt: \"Select worktree> \",\n header: \"Git Worktrees (Phantoms)\",\n });\n\n if (isErr(fzfResult)) {\n return fzfResult;\n }\n\n if (!fzfResult.value) {\n return {\n ok: true,\n value: null,\n };\n }\n\n const selectedName = fzfResult.value.split(\" \")[0];\n const selectedWorktree = worktrees.find((wt) => wt.name === selectedName);\n\n if (!selectedWorktree) {\n return {\n ok: false,\n error: new Error(\"Selected worktree not found\"),\n };\n }\n\n return {\n ok: true,\n value: {\n name: selectedWorktree.name,\n branch: selectedWorktree.branch,\n isClean: selectedWorktree.isClean,\n },\n };\n}\n", "import { parseArgs } from \"node:util\";\nimport { getGitRoot } from \"../../core/git/libs/get-git-root.ts\";\nimport { execInWorktree as execInWorktreeCore } from \"../../core/process/exec.ts\";\nimport { isErr } from \"../../core/types/result.ts\";\nimport { WorktreeNotFoundError } from \"../../core/worktree/errors.ts\";\nimport { exitCodes, exitWithError } from \"../errors.ts\";\n\nexport async function execHandler(args: string[]): Promise<void> {\n const { positionals } = parseArgs({\n args,\n options: {},\n strict: true,\n allowPositionals: true,\n });\n\n if (positionals.length < 2) {\n exitWithError(\n \"Usage: phantom exec <worktree-name> <command> [args...]\",\n exitCodes.validationError,\n );\n }\n\n const [worktreeName, ...commandArgs] = positionals;\n\n try {\n const gitRoot = await getGitRoot();\n const result = await execInWorktreeCore(\n gitRoot,\n worktreeName,\n commandArgs,\n { interactive: true },\n );\n\n if (isErr(result)) {\n const exitCode =\n result.error instanceof WorktreeNotFoundError\n ? exitCodes.notFound\n : result.error.exitCode || exitCodes.generalError;\n exitWithError(result.error.message, exitCode);\n }\n\n process.exit(result.value.exitCode);\n } catch (error) {\n exitWithError(\n error instanceof Error ? error.message : String(error),\n exitCodes.generalError,\n );\n }\n}\n", "import { parseArgs } from \"node:util\";\nimport { getGitRoot } from \"../../core/git/libs/get-git-root.ts\";\nimport { isErr } from \"../../core/types/result.ts\";\nimport { listWorktrees as listWorktreesCore } from \"../../core/worktree/list.ts\";\nimport { selectWorktreeWithFzf } from \"../../core/worktree/select.ts\";\nimport { exitCodes, exitWithError } from \"../errors.ts\";\nimport { output } from \"../output.ts\";\n\nexport async function listHandler(args: string[] = []): Promise<void> {\n const { values } = parseArgs({\n args,\n options: {\n fzf: {\n type: \"boolean\",\n default: false,\n },\n },\n strict: true,\n allowPositionals: false,\n });\n try {\n const gitRoot = await getGitRoot();\n\n if (values.fzf) {\n const selectResult = await selectWorktreeWithFzf(gitRoot);\n\n if (isErr(selectResult)) {\n exitWithError(selectResult.error.message, exitCodes.generalError);\n }\n\n if (selectResult.value) {\n output.log(selectResult.value.name);\n }\n } else {\n const result = await listWorktreesCore(gitRoot);\n\n if (isErr(result)) {\n exitWithError(\"Failed to list worktrees\", exitCodes.generalError);\n }\n\n const { worktrees, message } = result.value;\n\n if (worktrees.length === 0) {\n output.log(message || \"No worktrees found.\");\n process.exit(exitCodes.success);\n }\n\n const maxNameLength = Math.max(...worktrees.map((wt) => wt.name.length));\n\n for (const worktree of worktrees) {\n const paddedName = worktree.name.padEnd(maxNameLength + 2);\n const branchInfo = worktree.branch ? `(${worktree.branch})` : \"\";\n const status = !worktree.isClean ? \" [dirty]\" : \"\";\n\n output.log(`${paddedName} ${branchInfo}${status}`);\n }\n }\n\n process.exit(exitCodes.success);\n } catch (error) {\n exitWithError(\n error instanceof Error ? error.message : String(error),\n exitCodes.generalError,\n );\n }\n}\n", "import { parseArgs } from \"node:util\";\nimport { getGitRoot } from \"../../core/git/libs/get-git-root.ts\";\nimport { shellInWorktree as shellInWorktreeCore } from \"../../core/process/shell.ts\";\nimport { isErr } from \"../../core/types/result.ts\";\nimport { WorktreeNotFoundError } from \"../../core/worktree/errors.ts\";\nimport { selectWorktreeWithFzf } from \"../../core/worktree/select.ts\";\nimport { validateWorktreeExists } from \"../../core/worktree/validate.ts\";\nimport { exitCodes, exitWithError, exitWithSuccess } from \"../errors.ts\";\nimport { output } from \"../output.ts\";\n\nexport async function shellHandler(args: string[]): Promise<void> {\n const { positionals, values } = parseArgs({\n args,\n options: {\n fzf: {\n type: \"boolean\",\n default: false,\n },\n },\n strict: true,\n allowPositionals: true,\n });\n\n const useFzf = values.fzf ?? false;\n\n if (positionals.length === 0 && !useFzf) {\n exitWithError(\n \"Usage: phantom shell <worktree-name> or phantom shell --fzf\",\n exitCodes.validationError,\n );\n }\n\n if (positionals.length > 0 && useFzf) {\n exitWithError(\n \"Cannot specify both a worktree name and --fzf option\",\n exitCodes.validationError,\n );\n }\n\n let worktreeName: string;\n\n try {\n const gitRoot = await getGitRoot();\n\n if (useFzf) {\n const selectResult = await selectWorktreeWithFzf(gitRoot);\n if (isErr(selectResult)) {\n exitWithError(selectResult.error.message, exitCodes.generalError);\n }\n if (!selectResult.value) {\n exitWithSuccess();\n }\n worktreeName = selectResult.value.name;\n } else {\n worktreeName = positionals[0];\n }\n\n // Get worktree path for display\n const validation = await validateWorktreeExists(gitRoot, worktreeName);\n if (!validation.exists) {\n exitWithError(\n validation.message || `Worktree '${worktreeName}' not found`,\n exitCodes.generalError,\n );\n }\n\n output.log(`Entering worktree '${worktreeName}' at ${validation.path}`);\n output.log(\"Type 'exit' to return to your original directory\\n\");\n\n const result = await shellInWorktreeCore(gitRoot, worktreeName);\n\n if (isErr(result)) {\n const exitCode =\n result.error instanceof WorktreeNotFoundError\n ? exitCodes.notFound\n : result.error.exitCode || exitCodes.generalError;\n exitWithError(result.error.message, exitCode);\n }\n\n process.exit(result.value.exitCode);\n } catch (error) {\n exitWithError(\n error instanceof Error ? error.message : String(error),\n exitCodes.generalError,\n );\n }\n}\n", "import { parseArgs } from \"node:util\";\nimport { getVersion } from \"../../core/version.ts\";\nimport { exitWithSuccess } from \"../errors.ts\";\nimport { output } from \"../output.ts\";\n\nexport function versionHandler(args: string[] = []): void {\n parseArgs({\n args,\n options: {},\n strict: true,\n allowPositionals: false,\n });\n const version = getVersion();\n output.log(`Phantom v${version}`);\n exitWithSuccess();\n}\n", "{\n \"name\": \"@aku11i/phantom\",\n \"packageManager\": \"pnpm@10.8.1\",\n \"version\": \"0.8.0\",\n \"description\": \"A powerful CLI tool for managing Git worktrees for parallel development\",\n \"keywords\": [\n \"git\",\n \"worktree\",\n \"cli\",\n \"phantom\",\n \"workspace\",\n \"development\",\n \"parallel\"\n ],\n \"homepage\": \"https://github.com/aku11i/phantom#readme\",\n \"bugs\": {\n \"url\": \"https://github.com/aku11i/phantom/issues\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/aku11i/phantom.git\"\n },\n \"license\": \"MIT\",\n \"author\": \"aku11i\",\n \"type\": \"module\",\n \"bin\": {\n \"phantom\": \"./dist/phantom.js\"\n },\n \"scripts\": {\n \"start\": \"node ./src/bin/phantom.ts\",\n \"phantom\": \"node ./src/bin/phantom.ts\",\n \"build\": \"node build.ts\",\n \"typecheck\": \"tsgo --noEmit\",\n \"test\": \"node --test --experimental-strip-types --experimental-test-module-mocks \\\"src/**/*.test.js\\\"\",\n \"test:coverage\": \"node --experimental-test-coverage --test --experimental-strip-types --experimental-test-module-mocks \\\"src/**/*.test.js\\\"\",\n \"test:file\": \"node --test --experimental-strip-types --experimental-test-module-mocks\",\n \"lint\": \"biome check .\",\n \"fix\": \"biome check --write .\",\n \"ready\": \"pnpm fix && pnpm typecheck && pnpm test\",\n \"ready:check\": \"pnpm lint && pnpm typecheck && pnpm test\",\n \"prepublishOnly\": \"pnpm ready:check && pnpm build\"\n },\n \"engines\": {\n \"node\": \">=22.0.0\"\n },\n \"files\": [\n \"dist/\",\n \"README.md\",\n \"LICENSE\"\n ],\n \"devDependencies\": {\n \"@biomejs/biome\": \"^1.9.4\",\n \"@types/node\": \"^22.15.29\",\n \"@typescript/native-preview\": \"7.0.0-dev.20250602.1\",\n \"esbuild\": \"^0.25.5\",\n \"typescript\": \"^5.8.3\"\n }\n}\n", "import packageJson from \"../../package.json\" with { type: \"json\" };\n\nexport function getVersion(): string {\n return packageJson.version;\n}\n", "import { parseArgs } from \"node:util\";\nimport { getGitRoot } from \"../../core/git/libs/get-git-root.ts\";\nimport { isErr } from \"../../core/types/result.ts\";\nimport { selectWorktreeWithFzf } from \"../../core/worktree/select.ts\";\nimport { whereWorktree as whereWorktreeCore } from \"../../core/worktree/where.ts\";\nimport { exitCodes, exitWithError, exitWithSuccess } from \"../errors.ts\";\nimport { output } from \"../output.ts\";\n\nexport async function whereHandler(args: string[]): Promise<void> {\n const { positionals, values } = parseArgs({\n args,\n options: {\n fzf: {\n type: \"boolean\",\n default: false,\n },\n },\n strict: true,\n allowPositionals: true,\n });\n\n const useFzf = values.fzf ?? false;\n\n if (positionals.length === 0 && !useFzf) {\n exitWithError(\n \"Usage: phantom where <worktree-name> or phantom where --fzf\",\n exitCodes.validationError,\n );\n }\n\n if (positionals.length > 0 && useFzf) {\n exitWithError(\n \"Cannot specify both a worktree name and --fzf option\",\n exitCodes.validationError,\n );\n }\n\n let worktreeName: string;\n let gitRoot: string;\n\n try {\n gitRoot = await getGitRoot();\n } catch (error) {\n exitWithError(\n error instanceof Error ? error.message : String(error),\n exitCodes.generalError,\n );\n }\n\n if (useFzf) {\n const selectResult = await selectWorktreeWithFzf(gitRoot);\n if (isErr(selectResult)) {\n exitWithError(selectResult.error.message, exitCodes.generalError);\n }\n if (!selectResult.value) {\n exitWithSuccess();\n }\n worktreeName = selectResult.value.name;\n } else {\n worktreeName = positionals[0];\n }\n\n const result = await whereWorktreeCore(gitRoot, worktreeName);\n\n if (isErr(result)) {\n exitWithError(result.error.message, exitCodes.notFound);\n }\n\n output.log(result.value.path);\n exitWithSuccess();\n}\n", "import { type Result, err, ok } from \"../types/result.ts\";\nimport { WorktreeNotFoundError } from \"./errors.ts\";\nimport { validateWorktreeExists } from \"./validate.ts\";\n\nexport interface WhereWorktreeSuccess {\n path: string;\n}\n\nexport async function whereWorktree(\n gitRoot: string,\n name: string,\n): Promise<Result<WhereWorktreeSuccess, WorktreeNotFoundError>> {\n const validation = await validateWorktreeExists(gitRoot, name);\n\n if (!validation.exists) {\n return err(new WorktreeNotFoundError(name));\n }\n\n return ok({\n path: validation.path as string,\n });\n}\n", "import { stdout } from \"node:process\";\n\nexport interface CommandOption {\n name: string;\n short?: string;\n type: \"boolean\" | \"string\";\n description: string;\n multiple?: boolean;\n example?: string;\n}\n\nexport interface CommandHelp {\n name: string;\n description: string;\n usage: string;\n options?: CommandOption[];\n examples?: Array<{\n description: string;\n command: string;\n }>;\n notes?: string[];\n}\n\nexport class HelpFormatter {\n private readonly width: number;\n private readonly indent = \" \";\n\n constructor() {\n this.width = stdout.columns || 80;\n }\n\n formatMainHelp(\n commands: Array<{ name: string; description: string }>,\n ): string {\n const lines: string[] = [];\n\n lines.push(this.bold(\"Phantom - Git Worktree Manager\"));\n lines.push(\"\");\n lines.push(\n this.dim(\n \"A CLI tool for managing Git worktrees with enhanced functionality\",\n ),\n );\n lines.push(\"\");\n lines.push(this.section(\"USAGE\"));\n lines.push(`${this.indent}phantom <command> [options]`);\n lines.push(\"\");\n lines.push(this.section(\"COMMANDS\"));\n\n const maxNameLength = Math.max(...commands.map((cmd) => cmd.name.length));\n\n for (const cmd of commands) {\n const paddedName = cmd.name.padEnd(maxNameLength + 2);\n lines.push(`${this.indent}${this.cyan(paddedName)}${cmd.description}`);\n }\n\n lines.push(\"\");\n lines.push(this.section(\"GLOBAL OPTIONS\"));\n const helpOption = \"-h, --help\";\n const versionOption = \"-v, --version\";\n const globalOptionWidth =\n Math.max(helpOption.length, versionOption.length) + 2;\n lines.push(\n `${this.indent}${this.cyan(helpOption.padEnd(globalOptionWidth))}Show help`,\n );\n lines.push(\n `${this.indent}${this.cyan(versionOption.padEnd(globalOptionWidth))}Show version`,\n );\n lines.push(\"\");\n lines.push(\n this.dim(\n \"Run 'phantom <command> --help' for more information on a command.\",\n ),\n );\n\n return lines.join(\"\\n\");\n }\n\n formatCommandHelp(help: CommandHelp): string {\n const lines: string[] = [];\n\n lines.push(this.bold(`phantom ${help.name}`));\n lines.push(this.dim(help.description));\n lines.push(\"\");\n\n lines.push(this.section(\"USAGE\"));\n lines.push(`${this.indent}${help.usage}`);\n lines.push(\"\");\n\n if (help.options && help.options.length > 0) {\n lines.push(this.section(\"OPTIONS\"));\n const maxOptionLength = Math.max(\n ...help.options.map((opt) => this.formatOptionName(opt).length),\n );\n\n for (const option of help.options) {\n const optionName = this.formatOptionName(option);\n const paddedName = optionName.padEnd(maxOptionLength + 2);\n const description = this.wrapText(\n option.description,\n maxOptionLength + 4,\n );\n\n lines.push(`${this.indent}${this.cyan(paddedName)}${description[0]}`);\n for (let i = 1; i < description.length; i++) {\n lines.push(\n `${this.indent}${\" \".repeat(maxOptionLength + 2)}${description[i]}`,\n );\n }\n\n if (option.example) {\n const exampleIndent = \" \".repeat(maxOptionLength + 4);\n lines.push(\n `${this.indent}${exampleIndent}${this.dim(`Example: ${option.example}`)}`,\n );\n }\n }\n lines.push(\"\");\n }\n\n if (help.examples && help.examples.length > 0) {\n lines.push(this.section(\"EXAMPLES\"));\n for (const example of help.examples) {\n lines.push(`${this.indent}${this.dim(example.description)}`);\n lines.push(`${this.indent}${this.indent}$ ${example.command}`);\n lines.push(\"\");\n }\n }\n\n if (help.notes && help.notes.length > 0) {\n lines.push(this.section(\"NOTES\"));\n for (const note of help.notes) {\n const wrappedNote = this.wrapText(note, 2);\n for (const line of wrappedNote) {\n lines.push(`${this.indent}${line}`);\n }\n }\n lines.push(\"\");\n }\n\n return lines.join(\"\\n\");\n }\n\n private formatOptionName(option: CommandOption): string {\n const parts: string[] = [];\n\n if (option.short) {\n parts.push(`-${option.short},`);\n }\n\n parts.push(`--${option.name}`);\n\n if (option.type === \"string\") {\n parts.push(option.multiple ? \"<value>...\" : \"<value>\");\n }\n\n return parts.join(\" \");\n }\n\n private wrapText(text: string, indent: number): string[] {\n const maxWidth = this.width - indent - 2;\n const words = text.split(\" \");\n const lines: string[] = [];\n let currentLine = \"\";\n\n for (const word of words) {\n if (currentLine.length + word.length + 1 > maxWidth) {\n lines.push(currentLine);\n currentLine = word;\n } else {\n currentLine = currentLine ? `${currentLine} ${word}` : word;\n }\n }\n\n if (currentLine) {\n lines.push(currentLine);\n }\n\n return lines;\n }\n\n private section(text: string): string {\n return this.bold(text);\n }\n\n private bold(text: string): string {\n return `\\x1b[1m${text}\\x1b[0m`;\n }\n\n private dim(text: string): string {\n return `\\x1b[2m${text}\\x1b[0m`;\n }\n\n private cyan(text: string): string {\n return `\\x1b[36m${text}\\x1b[0m`;\n }\n}\n\nexport const helpFormatter = new HelpFormatter();\n", "import type { CommandHelp } from \"../help.ts\";\n\nexport const attachHelp: CommandHelp = {\n name: \"attach\",\n description: \"Attach to an existing branch by creating a new worktree\",\n usage: \"phantom attach <worktree-name> <branch-name> [options]\",\n options: [\n {\n name: \"shell\",\n short: \"s\",\n type: \"boolean\",\n description: \"Open an interactive shell in the worktree after attaching\",\n },\n {\n name: \"exec\",\n short: \"x\",\n type: \"string\",\n description: \"Execute a command in the worktree after attaching\",\n example: \"--exec 'git pull'\",\n },\n ],\n examples: [\n {\n description: \"Attach to an existing branch\",\n command: \"phantom attach review-pr main\",\n },\n {\n description: \"Attach to a remote branch and open a shell\",\n command: \"phantom attach hotfix origin/hotfix-v1.2 --shell\",\n },\n {\n description: \"Attach to a branch and pull latest changes\",\n command: \"phantom attach staging origin/staging --exec 'git pull'\",\n },\n ],\n notes: [\n \"The branch must already exist (locally or remotely)\",\n \"If attaching to a remote branch, it will be checked out locally\",\n \"Only one of --shell or --exec options can be used at a time\",\n ],\n};\n", "import type { CommandHelp } from \"../help.ts\";\n\nexport const createHelp: CommandHelp = {\n name: \"create\",\n description: \"Create a new Git worktree (phantom)\",\n usage: \"phantom create <name> [options]\",\n options: [\n {\n name: \"shell\",\n short: \"s\",\n type: \"boolean\",\n description:\n \"Open an interactive shell in the new worktree after creation\",\n },\n {\n name: \"exec\",\n short: \"x\",\n type: \"string\",\n description: \"Execute a command in the new worktree after creation\",\n example: \"--exec 'npm install'\",\n },\n {\n name: \"tmux\",\n short: \"t\",\n type: \"boolean\",\n description:\n \"Open the worktree in a new tmux window (requires being inside tmux)\",\n },\n {\n name: \"tmux-vertical\",\n type: \"boolean\",\n description:\n \"Open the worktree in a vertical tmux pane (requires being inside tmux)\",\n },\n {\n name: \"tmux-horizontal\",\n type: \"boolean\",\n description:\n \"Open the worktree in a horizontal tmux pane (requires being inside tmux)\",\n },\n {\n name: \"copy-file\",\n type: \"string\",\n multiple: true,\n description:\n \"Copy specified files from the current worktree to the new one. Can be used multiple times\",\n example: \"--copy-file .env --copy-file config.local.json\",\n },\n ],\n examples: [\n {\n description: \"Create a new worktree named 'feature-auth'\",\n command: \"phantom create feature-auth\",\n },\n {\n description: \"Create a worktree and open a shell in it\",\n command: \"phantom create bugfix-123 --shell\",\n },\n {\n description: \"Create a worktree and run npm install\",\n command: \"phantom create new-feature --exec 'npm install'\",\n },\n {\n description: \"Create a worktree in a new tmux window\",\n command: \"phantom create experiment --tmux\",\n },\n {\n description: \"Create a worktree and copy environment files\",\n command:\n \"phantom create staging --copy-file .env --copy-file database.yml\",\n },\n ],\n notes: [\n \"The worktree name will be used as the branch name\",\n \"Only one of --shell, --exec, or --tmux options can be used at a time\",\n \"File copying can also be configured in phantom.config.json\",\n ],\n};\n", "import type { CommandHelp } from \"../help.ts\";\n\nexport const deleteHelp: CommandHelp = {\n name: \"delete\",\n description: \"Delete a Git worktree (phantom)\",\n usage: \"phantom delete <name> [options]\",\n options: [\n {\n name: \"force\",\n short: \"f\",\n type: \"boolean\",\n description:\n \"Force deletion even if the worktree has uncommitted or unpushed changes\",\n },\n {\n name: \"--current\",\n type: \"boolean\",\n description: \"Delete the current worktree\",\n },\n {\n name: \"--fzf\",\n type: \"boolean\",\n description: \"Use fzf for interactive selection\",\n },\n ],\n examples: [\n {\n description: \"Delete a worktree\",\n command: \"phantom delete feature-auth\",\n },\n {\n description: \"Force delete a worktree with uncommitted changes\",\n command: \"phantom delete experimental --force\",\n },\n {\n description: \"Delete the current worktree\",\n command: \"phantom delete --current\",\n },\n {\n description: \"Delete a worktree with interactive fzf selection\",\n command: \"phantom delete --fzf\",\n },\n ],\n notes: [\n \"By default, deletion will fail if the worktree has uncommitted changes\",\n \"The associated branch will also be deleted if it's not checked out elsewhere\",\n \"With --fzf, you can interactively select the worktree to delete\",\n ],\n};\n", "import type { CommandHelp } from \"../help.ts\";\n\nexport const execHelp: CommandHelp = {\n name: \"exec\",\n description: \"Execute a command in a worktree directory\",\n usage: \"phantom exec <worktree-name> <command> [args...]\",\n examples: [\n {\n description: \"Run npm test in a worktree\",\n command: \"phantom exec feature-auth npm test\",\n },\n {\n description: \"Check git status in a worktree\",\n command: \"phantom exec bugfix-123 git status\",\n },\n {\n description: \"Run a complex command with arguments\",\n command: \"phantom exec staging npm run build -- --production\",\n },\n ],\n notes: [\n \"The command is executed with the worktree directory as the working directory\",\n \"All arguments after the worktree name are passed to the command\",\n \"The exit code of the executed command is preserved\",\n ],\n};\n", "import type { CommandHelp } from \"../help.ts\";\n\nexport const listHelp: CommandHelp = {\n name: \"list\",\n description: \"List all Git worktrees (phantoms)\",\n usage: \"phantom list [options]\",\n options: [\n {\n name: \"--fzf\",\n type: \"boolean\",\n description: \"Use fzf for interactive selection\",\n },\n ],\n examples: [\n {\n description: \"List all worktrees\",\n command: \"phantom list\",\n },\n {\n description: \"List worktrees with interactive fzf selection\",\n command: \"phantom list --fzf\",\n },\n ],\n notes: [\n \"Shows all worktrees with their paths and associated branches\",\n \"The main worktree is marked as '(bare)' if using a bare repository\",\n \"With --fzf, outputs only the selected worktree name\",\n ],\n};\n", "import type { CommandHelp } from \"../help.ts\";\n\nexport const shellHelp: CommandHelp = {\n name: \"shell\",\n description: \"Open an interactive shell in a worktree directory\",\n usage: \"phantom shell <worktree-name> [options]\",\n options: [\n {\n name: \"--fzf\",\n type: \"boolean\",\n description: \"Use fzf for interactive selection\",\n },\n ],\n examples: [\n {\n description: \"Open a shell in a worktree\",\n command: \"phantom shell feature-auth\",\n },\n {\n description: \"Open a shell with interactive fzf selection\",\n command: \"phantom shell --fzf\",\n },\n ],\n notes: [\n \"Uses your default shell from the SHELL environment variable\",\n \"The shell starts with the worktree directory as the working directory\",\n \"Type 'exit' to return to your original directory\",\n \"With --fzf, you can interactively select the worktree to enter\",\n ],\n};\n", "import type { CommandHelp } from \"../help.ts\";\n\nexport const versionHelp: CommandHelp = {\n name: \"version\",\n description: \"Display phantom version information\",\n usage: \"phantom version\",\n examples: [\n {\n description: \"Show version\",\n command: \"phantom version\",\n },\n ],\n notes: [\"Also accessible via 'phantom --version' or 'phantom -v'\"],\n};\n", "import type { CommandHelp } from \"../help.ts\";\n\nexport const whereHelp: CommandHelp = {\n name: \"where\",\n description: \"Output the filesystem path of a specific worktree\",\n usage: \"phantom where <worktree-name> [options]\",\n options: [\n {\n name: \"--fzf\",\n type: \"boolean\",\n description: \"Use fzf for interactive selection\",\n },\n ],\n examples: [\n {\n description: \"Get the path of a worktree\",\n command: \"phantom where feature-auth\",\n },\n {\n description: \"Change directory to a worktree\",\n command: \"cd $(phantom where staging)\",\n },\n {\n description: \"Get path with interactive fzf selection\",\n command: \"phantom where --fzf\",\n },\n {\n description: \"Change directory using fzf selection\",\n command: \"cd $(phantom where --fzf)\",\n },\n ],\n notes: [\n \"Outputs only the path, making it suitable for use in scripts\",\n \"Exits with an error code if the worktree doesn't exist\",\n \"With --fzf, you can interactively select the worktree\",\n ],\n};\n"],
|
|
5
|
+
"mappings": ";;;AAEA,SAAS,MAAM,YAAY;;;ACF3B,SAAS,iBAAiB;;;ACA1B,SAAS,SAAS,eAAe;;;ACAjC,SAAS,YAAY,wBAAwB;AAC7C,SAAS,iBAAiB;AAE1B,IAAM,WAAW,UAAU,gBAAgB;AAe3C,eAAsB,kBACpBA,OACA,UAA8B,CAAC,GACH;AAC5B,MAAI;AACF,UAAM,SAAS,MAAM,SAAS,OAAOA,OAAM;AAAA,MACzC,KAAK,QAAQ;AAAA,MACb,KAAK,QAAQ,OAAO,QAAQ;AAAA,MAC5B,UAAU;AAAA,IACZ,CAAC;AAED,WAAO;AAAA,MACL,QAAQ,OAAO,OAAO,KAAK;AAAA,MAC3B,QAAQ,OAAO,OAAO,KAAK;AAAA,IAC7B;AAAA,EACF,SAAS,OAAO;AAId,QACE,SACA,OAAO,UAAU,YACjB,YAAY,SACZ,YAAY,OACZ;AACA,YAAM,YAAY;AAOlB,UAAI,UAAU,QAAQ,KAAK,GAAG;AAC5B,cAAM,IAAI,MAAM,UAAU,OAAO,KAAK,CAAC;AAAA,MACzC;AAGA,aAAO;AAAA,QACL,QAAQ,UAAU,QAAQ,KAAK,KAAK;AAAA,QACpC,QAAQ,UAAU,QAAQ,KAAK,KAAK;AAAA,MACtC;AAAA,IACF;AAEA,UAAM;AAAA,EACR;AACF;AA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,OAAK,CAAC;AACR;AAGA,IAAI,cAAc,SAAS,QAAQ,KAAK,cAAc,SAAS,IAAI,GAAG;AACpE,MAAI,QAAQ,MAAM;AAChB,YAAQ,IAAI,cAAc,kBAAkB,QAAQ,IAAI,CAAC;AAAA,EAC3D,OAAO;AACL,YAAQ,IAAI,mCAAmC,QAAQ,IAAI,GAAG;AAAA,EAChE;AACA,OAAK,CAAC;AACR;AAEA,IAAI;AACF,QAAM,QAAQ,QAAQ,aAAa;AACrC,SAAS,OAAO;AACd,UAAQ;AAAA,IACN;AAAA,IACA,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAAA,EACvD;AACA,OAAK,CAAC;AACR;",
|
|
6
|
+
"names": ["args", "stdout", "command", "resolve", "command", "args", "command", "args", "args", "parseArgs", "fs", "fs", "command", "fs", "path", "path", "path", "fs", "args", "parseArgs", "commands", "command", "parseArgs", "stdout", "stdout", "resolve", "args", "getWorktreeStatus", "stdout", "listWorktrees", "getWorktreeStatus", "listWorktrees", "args", "parseArgs", "parseArgs", "args", "parseArgs", "parseArgs", "args", "parseArgs", "listWorktrees", "parseArgs", "args", "parseArgs", "parseArgs", "args", "parseArgs", "parseArgs", "args", "parseArgs", "commands", "commands", "args", "command", "remainingArgs"]
|
|
7
7
|
}
|