@aku11i/phantom 0.5.0 → 0.6.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/README.ja.md +59 -0
- package/README.md +62 -0
- package/dist/phantom.js +364 -54
- package/dist/phantom.js.map +4 -4
- package/package.json +4 -2
package/README.ja.md
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
[](https://www.npmjs.com/package/@aku11i/phantom)
|
|
8
8
|
[](https://opensource.org/licenses/MIT)
|
|
9
9
|
[](https://nodejs.org)
|
|
10
|
+
[](https://deepwiki.com/aku11i/phantom)
|
|
10
11
|
|
|
11
12
|
[インストール](#-インストール) • [基本的な使い方](#-基本的な使い方) • [なぜPhantom?](#-なぜphantom) • [ドキュメント](#-ドキュメント)
|
|
12
13
|
|
|
@@ -108,9 +109,21 @@ npm link
|
|
|
108
109
|
```bash
|
|
109
110
|
# 対応するブランチを持つ新しいworktreeを作成
|
|
110
111
|
phantom create <name>
|
|
112
|
+
phantom create <name> --shell # 作成してインタラクティブシェルに入る
|
|
113
|
+
phantom create <name> --exec <command> # 作成してコマンドを実行
|
|
114
|
+
phantom create <name> --tmux # 作成して新しいtmuxウィンドウで開く
|
|
115
|
+
phantom create <name> --tmux-vertical # 作成してtmuxペインを縦に分割
|
|
116
|
+
phantom create <name> --tmux-v # --tmux-verticalの短縮形
|
|
117
|
+
phantom create <name> --tmux-horizontal # 作成してtmuxペインを横に分割
|
|
118
|
+
phantom create <name> --tmux-h # --tmux-horizontalの短縮形
|
|
119
|
+
|
|
120
|
+
# worktreeを作成し、特定のファイルをコピー
|
|
121
|
+
phantom create <name> --copy-file ".env" --copy-file ".env.local"
|
|
111
122
|
|
|
112
123
|
# 既存のブランチにworktreeとしてアタッチ
|
|
113
124
|
phantom attach <branch-name>
|
|
125
|
+
phantom attach <branch-name> --shell # アタッチしてインタラクティブシェルに入る
|
|
126
|
+
phantom attach <branch-name> --exec <command> # アタッチしてコマンドを実行
|
|
114
127
|
|
|
115
128
|
# すべてのworktreeとその現在のステータスをリスト表示
|
|
116
129
|
phantom list
|
|
@@ -200,6 +213,49 @@ phantom shell feature-awesome # 機能開発を続行
|
|
|
200
213
|
| worktreeでコマンド実行 | `cd ../project-feature && npm test` | `phantom exec feature npm test` |
|
|
201
214
|
| worktreeの削除 | `git worktree remove ../project-feature` | `phantom delete feature` |
|
|
202
215
|
|
|
216
|
+
## ⚙️ 設定
|
|
217
|
+
|
|
218
|
+
Phantomはリポジトリルートの`phantom.config.json`ファイルによる設定をサポートします。これにより、新しいworktreeを作成する際に自動的にコピーされるファイルを定義できます。
|
|
219
|
+
|
|
220
|
+
### 設定ファイル
|
|
221
|
+
|
|
222
|
+
リポジトリルートに`phantom.config.json`ファイルを作成します:
|
|
223
|
+
|
|
224
|
+
```json
|
|
225
|
+
{
|
|
226
|
+
"postCreate": {
|
|
227
|
+
"copyFiles": [
|
|
228
|
+
".env",
|
|
229
|
+
".env.local",
|
|
230
|
+
"config/local.json"
|
|
231
|
+
]
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### ファイルコピー機能
|
|
237
|
+
|
|
238
|
+
新しいworktreeを作成する際、Phantomは現在のworktreeから新しいworktreeへ指定されたファイルを自動的にコピーできます。これは以下のような場合に特に便利です:
|
|
239
|
+
|
|
240
|
+
- 環境設定ファイル(`.env`、`.env.local`)
|
|
241
|
+
- ローカル開発設定
|
|
242
|
+
- gitignoreされているシークレットファイル
|
|
243
|
+
|
|
244
|
+
ファイルのコピーは2つの方法で指定できます:
|
|
245
|
+
|
|
246
|
+
1. **コマンドラインオプションを使用:**
|
|
247
|
+
```bash
|
|
248
|
+
phantom create feature --copy-file ".env" --copy-file ".env.local" --copy-file "config/local.json"
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
2. **設定ファイルを使用:**
|
|
252
|
+
`phantom.config.json`で一度設定すれば、すべての新しいworktreeに適用されます。
|
|
253
|
+
|
|
254
|
+
3. **両方を使用:**
|
|
255
|
+
設定ファイルとコマンドラインオプションの両方で指定されたファイルはマージされます(重複は削除されます)。
|
|
256
|
+
|
|
257
|
+
> **注意:** 現在、globパターンはサポートされていません。ファイルはリポジトリルートからの相対パスで正確に指定する必要があります。
|
|
258
|
+
|
|
203
259
|
## 🛠️ 開発
|
|
204
260
|
|
|
205
261
|
```bash
|
|
@@ -211,6 +267,9 @@ pnpm install
|
|
|
211
267
|
# テストの実行
|
|
212
268
|
pnpm test
|
|
213
269
|
|
|
270
|
+
# 特定のテストファイルを実行
|
|
271
|
+
pnpm test:file src/core/worktree/create.test.js
|
|
272
|
+
|
|
214
273
|
# 型チェック
|
|
215
274
|
pnpm typecheck
|
|
216
275
|
|
package/README.md
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
[](https://www.npmjs.com/package/@aku11i/phantom)
|
|
8
8
|
[](https://opensource.org/licenses/MIT)
|
|
9
9
|
[](https://nodejs.org)
|
|
10
|
+
[](https://deepwiki.com/aku11i/phantom)
|
|
10
11
|
|
|
11
12
|
[Installation](#-installation) • [Basic Usage](#-basic-usage) • [Why Phantom?](#-why-phantom) • [Documentation](#-documentation) • [日本語](./README.ja.md)
|
|
12
13
|
|
|
@@ -108,9 +109,21 @@ npm link
|
|
|
108
109
|
```bash
|
|
109
110
|
# Create a new worktree with a matching branch
|
|
110
111
|
phantom create <name>
|
|
112
|
+
phantom create <name> --shell # Create and enter interactive shell
|
|
113
|
+
phantom create <name> --exec <command> # Create and execute command
|
|
114
|
+
phantom create <name> --tmux # Create and open in new tmux window
|
|
115
|
+
phantom create <name> --tmux-vertical # Create and split tmux pane vertically
|
|
116
|
+
phantom create <name> --tmux-v # Shorthand for --tmux-vertical
|
|
117
|
+
phantom create <name> --tmux-horizontal # Create and split tmux pane horizontally
|
|
118
|
+
phantom create <name> --tmux-h # Shorthand for --tmux-horizontal
|
|
119
|
+
|
|
120
|
+
# Create a worktree and copy specific files
|
|
121
|
+
phantom create <name> --copy-file ".env" --copy-file ".env.local"
|
|
111
122
|
|
|
112
123
|
# Attach to an existing branch as a worktree
|
|
113
124
|
phantom attach <branch-name>
|
|
125
|
+
phantom attach <branch-name> --shell # Attach and enter interactive shell
|
|
126
|
+
phantom attach <branch-name> --exec <command> # Attach and execute command
|
|
114
127
|
|
|
115
128
|
# List all worktrees with their current status
|
|
116
129
|
phantom list
|
|
@@ -121,6 +134,8 @@ phantom where <name>
|
|
|
121
134
|
# Delete a worktree and its branch
|
|
122
135
|
phantom delete <name>
|
|
123
136
|
phantom delete <name> --force # Force delete with uncommitted changes
|
|
137
|
+
phantom delete --current # Delete the current worktree (when inside one)
|
|
138
|
+
phantom delete --current --force # Force delete current worktree
|
|
124
139
|
```
|
|
125
140
|
|
|
126
141
|
#### Working with Worktrees
|
|
@@ -199,6 +214,50 @@ phantom shell feature-awesome # Continue feature development
|
|
|
199
214
|
| Navigate to worktree | `cd ../project-feature` | `phantom shell feature` |
|
|
200
215
|
| Run command in worktree | `cd ../project-feature && npm test` | `phantom exec feature npm test` |
|
|
201
216
|
| Remove worktree | `git worktree remove ../project-feature` | `phantom delete feature` |
|
|
217
|
+
| Remove current worktree | `cd .. && git worktree remove project-feature` | `phantom delete --current` |
|
|
218
|
+
|
|
219
|
+
## ⚙️ Configuration
|
|
220
|
+
|
|
221
|
+
Phantom supports configuration through a `phantom.config.json` file in your repository root. This allows you to define files to be automatically copied when creating new worktrees.
|
|
222
|
+
|
|
223
|
+
### Configuration File
|
|
224
|
+
|
|
225
|
+
Create a `phantom.config.json` file in your repository root:
|
|
226
|
+
|
|
227
|
+
```json
|
|
228
|
+
{
|
|
229
|
+
"postCreate": {
|
|
230
|
+
"copyFiles": [
|
|
231
|
+
".env",
|
|
232
|
+
".env.local",
|
|
233
|
+
"config/local.json"
|
|
234
|
+
]
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### Copy Files Feature
|
|
240
|
+
|
|
241
|
+
When creating a new worktree, Phantom can automatically copy specified files from your current worktree to the new one. This is particularly useful for:
|
|
242
|
+
|
|
243
|
+
- Environment configuration files (`.env`, `.env.local`)
|
|
244
|
+
- Local development settings
|
|
245
|
+
- Secret files that are gitignored
|
|
246
|
+
|
|
247
|
+
You can specify files to copy in two ways:
|
|
248
|
+
|
|
249
|
+
1. **Using the command line option:**
|
|
250
|
+
```bash
|
|
251
|
+
phantom create feature --copy-file ".env" --copy-file ".env.local" --copy-file "config/local.json"
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
2. **Using the configuration file:**
|
|
255
|
+
Configure once in `phantom.config.json` and it will apply to all new worktrees.
|
|
256
|
+
|
|
257
|
+
3. **Using both:**
|
|
258
|
+
Files specified in both the configuration file and command line options are merged together (duplicates are removed).
|
|
259
|
+
|
|
260
|
+
> **Note:** Currently, glob patterns are not supported. Files must be specified with their exact paths relative to the repository root.
|
|
202
261
|
|
|
203
262
|
## 🛠️ Development
|
|
204
263
|
|
|
@@ -211,6 +270,9 @@ pnpm install
|
|
|
211
270
|
# Run tests
|
|
212
271
|
pnpm test
|
|
213
272
|
|
|
273
|
+
# Run a specific test file
|
|
274
|
+
pnpm test:file src/core/worktree/create.test.js
|
|
275
|
+
|
|
214
276
|
# Type checking
|
|
215
277
|
pnpm typecheck
|
|
216
278
|
|
package/dist/phantom.js
CHANGED
|
@@ -327,6 +327,9 @@ var output = {
|
|
|
327
327
|
error: (message) => {
|
|
328
328
|
console.error(message);
|
|
329
329
|
},
|
|
330
|
+
warn: (message) => {
|
|
331
|
+
console.warn(message);
|
|
332
|
+
},
|
|
330
333
|
table: (data) => {
|
|
331
334
|
console.table(data);
|
|
332
335
|
},
|
|
@@ -415,13 +418,173 @@ async function attachHandler(args2) {
|
|
|
415
418
|
// src/cli/handlers/create.ts
|
|
416
419
|
import { parseArgs as parseArgs2 } from "node:util";
|
|
417
420
|
|
|
418
|
-
// src/core/
|
|
421
|
+
// src/core/config/loader.ts
|
|
419
422
|
import fs2 from "node:fs/promises";
|
|
423
|
+
import path from "node:path";
|
|
424
|
+
|
|
425
|
+
// src/core/utils/type-guards.ts
|
|
426
|
+
function isObject(value) {
|
|
427
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
// src/core/config/validate.ts
|
|
431
|
+
var ConfigValidationError = class extends Error {
|
|
432
|
+
constructor(message) {
|
|
433
|
+
super(`Invalid phantom.config.json: ${message}`);
|
|
434
|
+
this.name = "ConfigValidationError";
|
|
435
|
+
}
|
|
436
|
+
};
|
|
437
|
+
function validateConfig(config) {
|
|
438
|
+
if (!isObject(config)) {
|
|
439
|
+
return err(new ConfigValidationError("Configuration must be an object"));
|
|
440
|
+
}
|
|
441
|
+
const cfg = config;
|
|
442
|
+
if (cfg.postCreate !== void 0) {
|
|
443
|
+
if (!isObject(cfg.postCreate)) {
|
|
444
|
+
return err(new ConfigValidationError("postCreate must be an object"));
|
|
445
|
+
}
|
|
446
|
+
const postCreate = cfg.postCreate;
|
|
447
|
+
if (postCreate.copyFiles !== void 0) {
|
|
448
|
+
if (!Array.isArray(postCreate.copyFiles)) {
|
|
449
|
+
return err(
|
|
450
|
+
new ConfigValidationError("postCreate.copyFiles must be an array")
|
|
451
|
+
);
|
|
452
|
+
}
|
|
453
|
+
if (!postCreate.copyFiles.every((f) => typeof f === "string")) {
|
|
454
|
+
return err(
|
|
455
|
+
new ConfigValidationError(
|
|
456
|
+
"postCreate.copyFiles must contain only strings"
|
|
457
|
+
)
|
|
458
|
+
);
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
return ok(config);
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
// src/core/config/loader.ts
|
|
466
|
+
var ConfigNotFoundError = class extends Error {
|
|
467
|
+
constructor() {
|
|
468
|
+
super("phantom.config.json not found");
|
|
469
|
+
this.name = "ConfigNotFoundError";
|
|
470
|
+
}
|
|
471
|
+
};
|
|
472
|
+
var ConfigParseError = class extends Error {
|
|
473
|
+
constructor(message) {
|
|
474
|
+
super(`Failed to parse phantom.config.json: ${message}`);
|
|
475
|
+
this.name = "ConfigParseError";
|
|
476
|
+
}
|
|
477
|
+
};
|
|
478
|
+
async function loadConfig(gitRoot) {
|
|
479
|
+
const configPath = path.join(gitRoot, "phantom.config.json");
|
|
480
|
+
try {
|
|
481
|
+
const content = await fs2.readFile(configPath, "utf-8");
|
|
482
|
+
try {
|
|
483
|
+
const parsed = JSON.parse(content);
|
|
484
|
+
const validationResult = validateConfig(parsed);
|
|
485
|
+
if (!validationResult.ok) {
|
|
486
|
+
return err(validationResult.error);
|
|
487
|
+
}
|
|
488
|
+
return ok(validationResult.value);
|
|
489
|
+
} catch (error) {
|
|
490
|
+
return err(
|
|
491
|
+
new ConfigParseError(
|
|
492
|
+
error instanceof Error ? error.message : String(error)
|
|
493
|
+
)
|
|
494
|
+
);
|
|
495
|
+
}
|
|
496
|
+
} catch (error) {
|
|
497
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
498
|
+
return err(new ConfigNotFoundError());
|
|
499
|
+
}
|
|
500
|
+
throw error;
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
// src/core/process/tmux.ts
|
|
505
|
+
async function isInsideTmux() {
|
|
506
|
+
return process.env.TMUX !== void 0;
|
|
507
|
+
}
|
|
508
|
+
async function executeTmuxCommand(options) {
|
|
509
|
+
const { direction, command: command2, cwd, env } = options;
|
|
510
|
+
const tmuxArgs = [];
|
|
511
|
+
switch (direction) {
|
|
512
|
+
case "new":
|
|
513
|
+
tmuxArgs.push("new-window");
|
|
514
|
+
break;
|
|
515
|
+
case "vertical":
|
|
516
|
+
tmuxArgs.push("split-window", "-v");
|
|
517
|
+
break;
|
|
518
|
+
case "horizontal":
|
|
519
|
+
tmuxArgs.push("split-window", "-h");
|
|
520
|
+
break;
|
|
521
|
+
}
|
|
522
|
+
if (cwd) {
|
|
523
|
+
tmuxArgs.push("-c", cwd);
|
|
524
|
+
}
|
|
525
|
+
if (env) {
|
|
526
|
+
for (const [key, value] of Object.entries(env)) {
|
|
527
|
+
tmuxArgs.push("-e", `${key}=${value}`);
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
tmuxArgs.push(command2);
|
|
531
|
+
const result = await spawnProcess({
|
|
532
|
+
command: "tmux",
|
|
533
|
+
args: tmuxArgs
|
|
534
|
+
});
|
|
535
|
+
return result;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
// src/core/worktree/create.ts
|
|
539
|
+
import fs3 from "node:fs/promises";
|
|
420
540
|
|
|
421
541
|
// src/core/git/libs/add-worktree.ts
|
|
422
542
|
async function addWorktree(options) {
|
|
423
|
-
const { path, branch, commitish = "HEAD" } = options;
|
|
424
|
-
await executeGitCommand(["worktree", "add",
|
|
543
|
+
const { path: path3, branch, commitish = "HEAD" } = options;
|
|
544
|
+
await executeGitCommand(["worktree", "add", path3, "-b", branch, commitish]);
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
// src/core/worktree/file-copier.ts
|
|
548
|
+
import { copyFile, mkdir, stat } from "node:fs/promises";
|
|
549
|
+
import path2 from "node:path";
|
|
550
|
+
var FileCopyError = class extends Error {
|
|
551
|
+
file;
|
|
552
|
+
constructor(file, message) {
|
|
553
|
+
super(`Failed to copy ${file}: ${message}`);
|
|
554
|
+
this.name = "FileCopyError";
|
|
555
|
+
this.file = file;
|
|
556
|
+
}
|
|
557
|
+
};
|
|
558
|
+
async function copyFiles(sourceDir, targetDir, files) {
|
|
559
|
+
const copiedFiles = [];
|
|
560
|
+
const skippedFiles = [];
|
|
561
|
+
for (const file of files) {
|
|
562
|
+
const sourcePath = path2.join(sourceDir, file);
|
|
563
|
+
const targetPath = path2.join(targetDir, file);
|
|
564
|
+
try {
|
|
565
|
+
const stats = await stat(sourcePath);
|
|
566
|
+
if (!stats.isFile()) {
|
|
567
|
+
skippedFiles.push(file);
|
|
568
|
+
continue;
|
|
569
|
+
}
|
|
570
|
+
const targetDirPath = path2.dirname(targetPath);
|
|
571
|
+
await mkdir(targetDirPath, { recursive: true });
|
|
572
|
+
await copyFile(sourcePath, targetPath);
|
|
573
|
+
copiedFiles.push(file);
|
|
574
|
+
} catch (error) {
|
|
575
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
576
|
+
skippedFiles.push(file);
|
|
577
|
+
} else {
|
|
578
|
+
return err(
|
|
579
|
+
new FileCopyError(
|
|
580
|
+
file,
|
|
581
|
+
error instanceof Error ? error.message : String(error)
|
|
582
|
+
)
|
|
583
|
+
);
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
return ok({ copiedFiles, skippedFiles });
|
|
425
588
|
}
|
|
426
589
|
|
|
427
590
|
// src/core/worktree/create.ts
|
|
@@ -434,9 +597,9 @@ async function createWorktree(gitRoot, name, options = {}) {
|
|
|
434
597
|
const worktreesPath = getPhantomDirectory(gitRoot);
|
|
435
598
|
const worktreePath = getWorktreePath(gitRoot, name);
|
|
436
599
|
try {
|
|
437
|
-
await
|
|
600
|
+
await fs3.access(worktreesPath);
|
|
438
601
|
} catch {
|
|
439
|
-
await
|
|
602
|
+
await fs3.mkdir(worktreesPath, { recursive: true });
|
|
440
603
|
}
|
|
441
604
|
const validation = await validateWorktreeDoesNotExist(gitRoot, name);
|
|
442
605
|
if (validation.exists) {
|
|
@@ -448,9 +611,28 @@ async function createWorktree(gitRoot, name, options = {}) {
|
|
|
448
611
|
branch,
|
|
449
612
|
commitish
|
|
450
613
|
});
|
|
614
|
+
let copiedFiles;
|
|
615
|
+
let skippedFiles;
|
|
616
|
+
let copyError;
|
|
617
|
+
if (options.copyFiles && options.copyFiles.length > 0) {
|
|
618
|
+
const copyResult = await copyFiles(
|
|
619
|
+
gitRoot,
|
|
620
|
+
worktreePath,
|
|
621
|
+
options.copyFiles
|
|
622
|
+
);
|
|
623
|
+
if (isOk(copyResult)) {
|
|
624
|
+
copiedFiles = copyResult.value.copiedFiles;
|
|
625
|
+
skippedFiles = copyResult.value.skippedFiles;
|
|
626
|
+
} else {
|
|
627
|
+
copyError = copyResult.error.message;
|
|
628
|
+
}
|
|
629
|
+
}
|
|
451
630
|
return ok({
|
|
452
631
|
message: `Created worktree '${name}' at ${worktreePath}`,
|
|
453
|
-
path: worktreePath
|
|
632
|
+
path: worktreePath,
|
|
633
|
+
copiedFiles,
|
|
634
|
+
skippedFiles,
|
|
635
|
+
copyError
|
|
454
636
|
});
|
|
455
637
|
} catch (error) {
|
|
456
638
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -470,6 +652,26 @@ async function createHandler(args2) {
|
|
|
470
652
|
exec: {
|
|
471
653
|
type: "string",
|
|
472
654
|
short: "x"
|
|
655
|
+
},
|
|
656
|
+
tmux: {
|
|
657
|
+
type: "boolean",
|
|
658
|
+
short: "t"
|
|
659
|
+
},
|
|
660
|
+
"tmux-vertical": {
|
|
661
|
+
type: "boolean"
|
|
662
|
+
},
|
|
663
|
+
"tmux-v": {
|
|
664
|
+
type: "boolean"
|
|
665
|
+
},
|
|
666
|
+
"tmux-horizontal": {
|
|
667
|
+
type: "boolean"
|
|
668
|
+
},
|
|
669
|
+
"tmux-h": {
|
|
670
|
+
type: "boolean"
|
|
671
|
+
},
|
|
672
|
+
"copy-file": {
|
|
673
|
+
type: "string",
|
|
674
|
+
multiple: true
|
|
473
675
|
}
|
|
474
676
|
},
|
|
475
677
|
strict: true,
|
|
@@ -484,20 +686,61 @@ async function createHandler(args2) {
|
|
|
484
686
|
const worktreeName = positionals[0];
|
|
485
687
|
const openShell = values.shell ?? false;
|
|
486
688
|
const execCommand = values.exec;
|
|
487
|
-
|
|
689
|
+
const copyFileOptions = values["copy-file"];
|
|
690
|
+
const tmuxOption = values.tmux || values["tmux-vertical"] || values["tmux-v"] || values["tmux-horizontal"] || values["tmux-h"];
|
|
691
|
+
let tmuxDirection;
|
|
692
|
+
if (values.tmux) {
|
|
693
|
+
tmuxDirection = "new";
|
|
694
|
+
} else if (values["tmux-vertical"] || values["tmux-v"]) {
|
|
695
|
+
tmuxDirection = "vertical";
|
|
696
|
+
} else if (values["tmux-horizontal"] || values["tmux-h"]) {
|
|
697
|
+
tmuxDirection = "horizontal";
|
|
698
|
+
}
|
|
699
|
+
if ([openShell, execCommand !== void 0, tmuxOption].filter(Boolean).length > 1) {
|
|
700
|
+
exitWithError(
|
|
701
|
+
"Cannot use --shell, --exec, and --tmux options together",
|
|
702
|
+
exitCodes.validationError
|
|
703
|
+
);
|
|
704
|
+
}
|
|
705
|
+
if (tmuxOption && !await isInsideTmux()) {
|
|
488
706
|
exitWithError(
|
|
489
|
-
"
|
|
707
|
+
"The --tmux option can only be used inside a tmux session",
|
|
490
708
|
exitCodes.validationError
|
|
491
709
|
);
|
|
492
710
|
}
|
|
493
711
|
try {
|
|
494
712
|
const gitRoot = await getGitRoot();
|
|
495
|
-
|
|
713
|
+
let filesToCopy = [];
|
|
714
|
+
const configResult = await loadConfig(gitRoot);
|
|
715
|
+
if (isOk(configResult)) {
|
|
716
|
+
if (configResult.value.postCreate?.copyFiles) {
|
|
717
|
+
filesToCopy = [...configResult.value.postCreate.copyFiles];
|
|
718
|
+
}
|
|
719
|
+
} else {
|
|
720
|
+
if (configResult.error instanceof ConfigValidationError) {
|
|
721
|
+
output.warn(`Configuration warning: ${configResult.error.message}`);
|
|
722
|
+
} else if (configResult.error instanceof ConfigParseError) {
|
|
723
|
+
output.warn(`Configuration warning: ${configResult.error.message}`);
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
if (copyFileOptions && copyFileOptions.length > 0) {
|
|
727
|
+
const cliFiles = Array.isArray(copyFileOptions) ? copyFileOptions : [copyFileOptions];
|
|
728
|
+
filesToCopy = [.../* @__PURE__ */ new Set([...filesToCopy, ...cliFiles])];
|
|
729
|
+
}
|
|
730
|
+
const result = await createWorktree(gitRoot, worktreeName, {
|
|
731
|
+
copyFiles: filesToCopy.length > 0 ? filesToCopy : void 0
|
|
732
|
+
});
|
|
496
733
|
if (isErr(result)) {
|
|
497
734
|
const exitCode = result.error instanceof WorktreeAlreadyExistsError ? exitCodes.validationError : exitCodes.generalError;
|
|
498
735
|
exitWithError(result.error.message, exitCode);
|
|
499
736
|
}
|
|
500
737
|
output.log(result.value.message);
|
|
738
|
+
if (result.value.copyError) {
|
|
739
|
+
output.error(
|
|
740
|
+
`
|
|
741
|
+
Warning: Failed to copy some files: ${result.value.copyError}`
|
|
742
|
+
);
|
|
743
|
+
}
|
|
501
744
|
if (execCommand && isOk(result)) {
|
|
502
745
|
output.log(
|
|
503
746
|
`
|
|
@@ -530,6 +773,28 @@ Entering worktree '${worktreeName}' at ${result.value.path}`
|
|
|
530
773
|
}
|
|
531
774
|
process.exit(shellResult.value.exitCode ?? 0);
|
|
532
775
|
}
|
|
776
|
+
if (tmuxDirection && isOk(result)) {
|
|
777
|
+
output.log(
|
|
778
|
+
`
|
|
779
|
+
Opening worktree '${worktreeName}' in tmux ${tmuxDirection === "new" ? "window" : "pane"}...`
|
|
780
|
+
);
|
|
781
|
+
const shell = process.env.SHELL || "/bin/sh";
|
|
782
|
+
const tmuxResult = await executeTmuxCommand({
|
|
783
|
+
direction: tmuxDirection,
|
|
784
|
+
command: shell,
|
|
785
|
+
cwd: result.value.path,
|
|
786
|
+
env: {
|
|
787
|
+
PHANTOM: "1",
|
|
788
|
+
PHANTOM_NAME: worktreeName,
|
|
789
|
+
PHANTOM_PATH: result.value.path
|
|
790
|
+
}
|
|
791
|
+
});
|
|
792
|
+
if (isErr(tmuxResult)) {
|
|
793
|
+
output.error(tmuxResult.error.message);
|
|
794
|
+
const exitCode = "exitCode" in tmuxResult.error ? tmuxResult.error.exitCode ?? exitCodes.generalError : exitCodes.generalError;
|
|
795
|
+
exitWithError("", exitCode);
|
|
796
|
+
}
|
|
797
|
+
}
|
|
533
798
|
exitWithSuccess();
|
|
534
799
|
} catch (error) {
|
|
535
800
|
exitWithError(
|
|
@@ -542,6 +807,66 @@ Entering worktree '${worktreeName}' at ${result.value.path}`
|
|
|
542
807
|
// src/cli/handlers/delete.ts
|
|
543
808
|
import { parseArgs as parseArgs3 } from "node:util";
|
|
544
809
|
|
|
810
|
+
// src/core/git/libs/list-worktrees.ts
|
|
811
|
+
async function listWorktrees(gitRoot) {
|
|
812
|
+
const { stdout } = await executeGitCommand([
|
|
813
|
+
"worktree",
|
|
814
|
+
"list",
|
|
815
|
+
"--porcelain"
|
|
816
|
+
]);
|
|
817
|
+
const worktrees = [];
|
|
818
|
+
let currentWorktree = {};
|
|
819
|
+
const lines = stdout.split("\n").filter((line) => line.length > 0);
|
|
820
|
+
for (const line of lines) {
|
|
821
|
+
if (line.startsWith("worktree ")) {
|
|
822
|
+
if (currentWorktree.path) {
|
|
823
|
+
worktrees.push(currentWorktree);
|
|
824
|
+
}
|
|
825
|
+
currentWorktree = {
|
|
826
|
+
path: line.substring("worktree ".length),
|
|
827
|
+
isLocked: false,
|
|
828
|
+
isPrunable: false
|
|
829
|
+
};
|
|
830
|
+
} else if (line.startsWith("HEAD ")) {
|
|
831
|
+
currentWorktree.head = line.substring("HEAD ".length);
|
|
832
|
+
} else if (line.startsWith("branch ")) {
|
|
833
|
+
const fullBranch = line.substring("branch ".length);
|
|
834
|
+
currentWorktree.branch = fullBranch.startsWith("refs/heads/") ? fullBranch.substring("refs/heads/".length) : fullBranch;
|
|
835
|
+
} else if (line === "detached") {
|
|
836
|
+
currentWorktree.branch = "(detached HEAD)";
|
|
837
|
+
} else if (line === "locked") {
|
|
838
|
+
currentWorktree.isLocked = true;
|
|
839
|
+
} else if (line === "prunable") {
|
|
840
|
+
currentWorktree.isPrunable = true;
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
if (currentWorktree.path) {
|
|
844
|
+
worktrees.push(currentWorktree);
|
|
845
|
+
}
|
|
846
|
+
return worktrees;
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
// src/core/git/libs/get-current-worktree.ts
|
|
850
|
+
async function getCurrentWorktree(gitRoot) {
|
|
851
|
+
try {
|
|
852
|
+
const { stdout: currentPath } = await executeGitCommand([
|
|
853
|
+
"rev-parse",
|
|
854
|
+
"--show-toplevel"
|
|
855
|
+
]);
|
|
856
|
+
const currentPathTrimmed = currentPath.trim();
|
|
857
|
+
const worktrees = await listWorktrees(gitRoot);
|
|
858
|
+
const currentWorktree = worktrees.find(
|
|
859
|
+
(wt) => wt.path === currentPathTrimmed
|
|
860
|
+
);
|
|
861
|
+
if (!currentWorktree || currentWorktree.path === gitRoot) {
|
|
862
|
+
return null;
|
|
863
|
+
}
|
|
864
|
+
return currentWorktree.branch;
|
|
865
|
+
} catch {
|
|
866
|
+
return null;
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
|
|
545
870
|
// src/core/worktree/delete.ts
|
|
546
871
|
async function getWorktreeStatus(worktreePath) {
|
|
547
872
|
try {
|
|
@@ -636,21 +961,43 @@ async function deleteHandler(args2) {
|
|
|
636
961
|
force: {
|
|
637
962
|
type: "boolean",
|
|
638
963
|
short: "f"
|
|
964
|
+
},
|
|
965
|
+
current: {
|
|
966
|
+
type: "boolean"
|
|
639
967
|
}
|
|
640
968
|
},
|
|
641
969
|
strict: true,
|
|
642
970
|
allowPositionals: true
|
|
643
971
|
});
|
|
644
|
-
|
|
972
|
+
const deleteCurrent = values.current ?? false;
|
|
973
|
+
if (positionals.length === 0 && !deleteCurrent) {
|
|
645
974
|
exitWithError(
|
|
646
|
-
"Please provide a worktree name to delete",
|
|
975
|
+
"Please provide a worktree name to delete or use --current to delete the current worktree",
|
|
976
|
+
exitCodes.validationError
|
|
977
|
+
);
|
|
978
|
+
}
|
|
979
|
+
if (positionals.length > 0 && deleteCurrent) {
|
|
980
|
+
exitWithError(
|
|
981
|
+
"Cannot specify both a worktree name and --current option",
|
|
647
982
|
exitCodes.validationError
|
|
648
983
|
);
|
|
649
984
|
}
|
|
650
|
-
const worktreeName = positionals[0];
|
|
651
985
|
const forceDelete = values.force ?? false;
|
|
652
986
|
try {
|
|
653
987
|
const gitRoot = await getGitRoot();
|
|
988
|
+
let worktreeName;
|
|
989
|
+
if (deleteCurrent) {
|
|
990
|
+
const currentWorktree = await getCurrentWorktree(gitRoot);
|
|
991
|
+
if (!currentWorktree) {
|
|
992
|
+
exitWithError(
|
|
993
|
+
"Not in a worktree directory. The --current option can only be used from within a worktree.",
|
|
994
|
+
exitCodes.validationError
|
|
995
|
+
);
|
|
996
|
+
}
|
|
997
|
+
worktreeName = currentWorktree;
|
|
998
|
+
} else {
|
|
999
|
+
worktreeName = positionals[0];
|
|
1000
|
+
}
|
|
654
1001
|
const result = await deleteWorktree(gitRoot, worktreeName, {
|
|
655
1002
|
force: forceDelete
|
|
656
1003
|
});
|
|
@@ -703,45 +1050,6 @@ async function execHandler(args2) {
|
|
|
703
1050
|
// src/cli/handlers/list.ts
|
|
704
1051
|
import { parseArgs as parseArgs5 } from "node:util";
|
|
705
1052
|
|
|
706
|
-
// src/core/git/libs/list-worktrees.ts
|
|
707
|
-
async function listWorktrees(gitRoot) {
|
|
708
|
-
const { stdout } = await executeGitCommand([
|
|
709
|
-
"worktree",
|
|
710
|
-
"list",
|
|
711
|
-
"--porcelain"
|
|
712
|
-
]);
|
|
713
|
-
const worktrees = [];
|
|
714
|
-
let currentWorktree = {};
|
|
715
|
-
const lines = stdout.split("\n").filter((line) => line.length > 0);
|
|
716
|
-
for (const line of lines) {
|
|
717
|
-
if (line.startsWith("worktree ")) {
|
|
718
|
-
if (currentWorktree.path) {
|
|
719
|
-
worktrees.push(currentWorktree);
|
|
720
|
-
}
|
|
721
|
-
currentWorktree = {
|
|
722
|
-
path: line.substring("worktree ".length),
|
|
723
|
-
isLocked: false,
|
|
724
|
-
isPrunable: false
|
|
725
|
-
};
|
|
726
|
-
} else if (line.startsWith("HEAD ")) {
|
|
727
|
-
currentWorktree.head = line.substring("HEAD ".length);
|
|
728
|
-
} else if (line.startsWith("branch ")) {
|
|
729
|
-
const fullBranch = line.substring("branch ".length);
|
|
730
|
-
currentWorktree.branch = fullBranch.startsWith("refs/heads/") ? fullBranch.substring("refs/heads/".length) : fullBranch;
|
|
731
|
-
} else if (line === "detached") {
|
|
732
|
-
currentWorktree.branch = "(detached HEAD)";
|
|
733
|
-
} else if (line === "locked") {
|
|
734
|
-
currentWorktree.isLocked = true;
|
|
735
|
-
} else if (line === "prunable") {
|
|
736
|
-
currentWorktree.isPrunable = true;
|
|
737
|
-
}
|
|
738
|
-
}
|
|
739
|
-
if (currentWorktree.path) {
|
|
740
|
-
worktrees.push(currentWorktree);
|
|
741
|
-
}
|
|
742
|
-
return worktrees;
|
|
743
|
-
}
|
|
744
|
-
|
|
745
1053
|
// src/core/worktree/list.ts
|
|
746
1054
|
async function getWorktreeStatus2(worktreePath) {
|
|
747
1055
|
try {
|
|
@@ -871,7 +1179,7 @@ import { parseArgs as parseArgs7 } from "node:util";
|
|
|
871
1179
|
var package_default = {
|
|
872
1180
|
name: "@aku11i/phantom",
|
|
873
1181
|
packageManager: "pnpm@10.8.1",
|
|
874
|
-
version: "0.
|
|
1182
|
+
version: "0.6.0",
|
|
875
1183
|
description: "A powerful CLI tool for managing Git worktrees for parallel development",
|
|
876
1184
|
keywords: [
|
|
877
1185
|
"git",
|
|
@@ -901,7 +1209,9 @@ var package_default = {
|
|
|
901
1209
|
phantom: "node ./src/bin/phantom.ts",
|
|
902
1210
|
build: "node build.ts",
|
|
903
1211
|
typecheck: "tsgo --noEmit",
|
|
904
|
-
test:
|
|
1212
|
+
test: 'node --test --experimental-strip-types --experimental-test-module-mocks "src/**/*.test.js"',
|
|
1213
|
+
"test:coverage": 'node --experimental-test-coverage --test --experimental-strip-types --experimental-test-module-mocks "src/**/*.test.js"',
|
|
1214
|
+
"test:file": "node --test --experimental-strip-types --experimental-test-module-mocks",
|
|
905
1215
|
lint: "biome check .",
|
|
906
1216
|
fix: "biome check --write .",
|
|
907
1217
|
ready: "pnpm fix && pnpm typecheck && pnpm test",
|
|
@@ -989,7 +1299,7 @@ async function whereHandler(args2) {
|
|
|
989
1299
|
var commands = [
|
|
990
1300
|
{
|
|
991
1301
|
name: "create",
|
|
992
|
-
description: "Create a new worktree [--shell | --exec <command>]",
|
|
1302
|
+
description: "Create a new worktree [--shell | --exec <command> | --tmux | --tmux-vertical | --tmux-horizontal] [--copy-file <file>]...",
|
|
993
1303
|
handler: createHandler
|
|
994
1304
|
},
|
|
995
1305
|
{
|
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/worktree/create.ts", "../src/core/git/libs/add-worktree.ts", "../src/cli/handlers/delete.ts", "../src/core/
|
|
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\";\n\ninterface Command {\n name: string;\n description: string;\n subcommands?: Command[];\n handler?: (args: string[]) => void | Promise<void>;\n}\n\nconst commands: Command[] = [\n {\n name: \"create\",\n description: \"Create a new worktree [--shell | --exec <command>]\",\n handler: createHandler,\n },\n {\n name: \"attach\",\n description: \"Attach to an existing branch [--shell | --exec <command>]\",\n handler: attachHandler,\n },\n {\n name: \"list\",\n description: \"List all worktrees\",\n handler: listHandler,\n },\n {\n name: \"where\",\n description: \"Output the path of a specific worktree\",\n handler: whereHandler,\n },\n {\n name: \"delete\",\n description: \"Delete a worktree (use --force for uncommitted changes)\",\n handler: deleteHandler,\n },\n {\n name: \"exec\",\n description: \"Execute a command in a worktree directory\",\n handler: execHandler,\n },\n {\n name: \"shell\",\n description: \"Open interactive shell in a worktree directory\",\n handler: shellHandler,\n },\n {\n name: \"version\",\n description: \"Display phantom version\",\n handler: versionHandler,\n },\n];\n\nfunction printHelp(commands: Command[]) {\n console.log(\"Usage: phantom <command> [options]\\n\");\n console.log(\"Commands:\");\n for (const cmd of commands) {\n console.log(` ${cmd.name.padEnd(12)} ${cmd.description}`);\n }\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\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 );\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 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 async function execInWorktree(\n gitRoot: string,\n worktreeName: string,\n command: string[],\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 return spawnProcess({\n command: cmd,\n args,\n options: {\n cwd: worktreePath,\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 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 { 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, 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 },\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\n if (openShell && execCommand) {\n exitWithError(\n \"Cannot use --shell and --exec together\",\n exitCodes.validationError,\n );\n }\n\n try {\n const gitRoot = await getGitRoot();\n const result = await createWorktreeCore(gitRoot, worktreeName);\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 (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(gitRoot, worktreeName, [\n shell,\n \"-c\",\n execCommand,\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 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 { addWorktree } from \"../git/libs/add-worktree.ts\";\nimport { getPhantomDirectory, getWorktreePath } from \"../paths.ts\";\nimport { type Result, err, isErr, ok } from \"../types/result.ts\";\nimport { GitOperationError, WorktreeAlreadyExistsError } from \"./errors.ts\";\nimport {\n validateWorktreeDoesNotExist,\n validateWorktreeName,\n} from \"./validate.ts\";\n\nexport interface CreateWorktreeOptions {\n branch?: string;\n commitish?: string;\n}\n\nexport interface CreateWorktreeSuccess {\n message: string;\n path: 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 return ok({\n message: `Created worktree '${name}' at ${worktreePath}`,\n path: worktreePath,\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 { parseArgs } from \"node:util\";\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 },\n strict: true,\n allowPositionals: true,\n });\n\n if (positionals.length === 0) {\n exitWithError(\n \"Please provide a worktree name to delete\",\n exitCodes.validationError,\n );\n }\n\n const worktreeName = positionals[0];\n const forceDelete = values.force ?? false;\n\n try {\n const gitRoot = await getGitRoot();\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 {\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(gitRoot, worktreeName, commandArgs);\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 { 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 { 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.5.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.ts\",\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"],
|
|
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,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AC9C;AAAA,EACF;AAEA,SAAO,EAAE,SAAAD,UAAS,eAAe,KAAK;AACxC;AAEA,IAAM,OAAO,KAAK,MAAM,CAAC;AAEzB,IAAI,KAAK,WAAW,KAAK,KAAK,CAAC,MAAM,QAAQ,KAAK,CAAC,MAAM,UAAU;AACjE,YAAU,QAAQ;AAClB,OAAK,CAAC;AACR;AAEA,IAAI,KAAK,CAAC,MAAM,eAAe,KAAK,CAAC,MAAM,MAAM;AAC/C,iBAAe;AACf,OAAK,CAAC;AACR;AAEA,IAAM,EAAE,SAAS,cAAc,IAAI,YAAY,MAAM,QAAQ;AAE7D,IAAI,CAAC,WAAW,CAAC,QAAQ,SAAS;AAChC,UAAQ,MAAM,2BAA2B,KAAK,KAAK,GAAG,CAAC;AAAA,CAAK;AAC5D,YAAU,QAAQ;AAClB,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", "command", "resolve", "command", "args", "command", "args", "args", "parseArgs", "fs", "fs", "args", "parseArgs", "parseArgs", "args", "parseArgs", "parseArgs", "args", "parseArgs", "parseArgs", "getWorktreeStatus", "listWorktrees", "getWorktreeStatus", "args", "parseArgs", "listWorktrees", "parseArgs", "args", "parseArgs", "parseArgs", "args", "parseArgs", "parseArgs", "args", "parseArgs", "commands", "args", "command", "remainingArgs"]
|
|
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/cli/handlers/exec.ts", "../src/cli/handlers/list.ts", "../src/core/worktree/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"],
|
|
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\";\n\ninterface Command {\n name: string;\n description: string;\n subcommands?: Command[];\n handler?: (args: string[]) => void | Promise<void>;\n}\n\nconst commands: Command[] = [\n {\n name: \"create\",\n description:\n \"Create a new worktree [--shell | --exec <command> | --tmux | --tmux-vertical | --tmux-horizontal] [--copy-file <file>]...\",\n handler: createHandler,\n },\n {\n name: \"attach\",\n description: \"Attach to an existing branch [--shell | --exec <command>]\",\n handler: attachHandler,\n },\n {\n name: \"list\",\n description: \"List all worktrees\",\n handler: listHandler,\n },\n {\n name: \"where\",\n description: \"Output the path of a specific worktree\",\n handler: whereHandler,\n },\n {\n name: \"delete\",\n description: \"Delete a worktree (use --force for uncommitted changes)\",\n handler: deleteHandler,\n },\n {\n name: \"exec\",\n description: \"Execute a command in a worktree directory\",\n handler: execHandler,\n },\n {\n name: \"shell\",\n description: \"Open interactive shell in a worktree directory\",\n handler: shellHandler,\n },\n {\n name: \"version\",\n description: \"Display phantom version\",\n handler: versionHandler,\n },\n];\n\nfunction printHelp(commands: Command[]) {\n console.log(\"Usage: phantom <command> [options]\\n\");\n console.log(\"Commands:\");\n for (const cmd of commands) {\n console.log(` ${cmd.name.padEnd(12)} ${cmd.description}`);\n }\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\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 );\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 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 async function execInWorktree(\n gitRoot: string,\n worktreeName: string,\n command: string[],\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 return spawnProcess({\n command: cmd,\n args,\n options: {\n cwd: worktreePath,\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 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(gitRoot, worktreeName, [\n shell,\n \"-c\",\n execCommand,\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 ${tmuxDirection === \"new\" ? \"window\" : \"pane\"}...`,\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 };\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\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(gitRoot, worktreeName, commandArgs);\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.6.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"],
|
|
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;AA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A,OAAK,CAAC;AACR;",
|
|
6
|
+
"names": ["args", "command", "resolve", "command", "args", "command", "args", "args", "parseArgs", "fs", "fs", "command", "fs", "path", "path", "path", "fs", "args", "parseArgs", "parseArgs", "args", "parseArgs", "parseArgs", "args", "parseArgs", "parseArgs", "getWorktreeStatus", "listWorktrees", "getWorktreeStatus", "args", "parseArgs", "listWorktrees", "parseArgs", "args", "parseArgs", "parseArgs", "args", "parseArgs", "parseArgs", "args", "parseArgs", "commands", "args", "command", "remainingArgs"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aku11i/phantom",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "A powerful CLI tool for managing Git worktrees for parallel development",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"git",
|
|
@@ -45,7 +45,9 @@
|
|
|
45
45
|
"phantom": "node ./src/bin/phantom.ts",
|
|
46
46
|
"build": "node build.ts",
|
|
47
47
|
"typecheck": "tsgo --noEmit",
|
|
48
|
-
"test": "node --test --experimental-strip-types --experimental-test-module-mocks src/**/*.test.
|
|
48
|
+
"test": "node --test --experimental-strip-types --experimental-test-module-mocks \"src/**/*.test.js\"",
|
|
49
|
+
"test:coverage": "node --experimental-test-coverage --test --experimental-strip-types --experimental-test-module-mocks \"src/**/*.test.js\"",
|
|
50
|
+
"test:file": "node --test --experimental-strip-types --experimental-test-module-mocks",
|
|
49
51
|
"lint": "biome check .",
|
|
50
52
|
"fix": "biome check --write .",
|
|
51
53
|
"ready": "pnpm fix && pnpm typecheck && pnpm test",
|