@aku11i/phantom 0.4.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 CHANGED
@@ -7,6 +7,7 @@
7
7
  [![npm version](https://img.shields.io/npm/v/@aku11i/phantom.svg)](https://www.npmjs.com/package/@aku11i/phantom)
8
8
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
9
9
  [![Node.js Version](https://img.shields.io/node/v/@aku11i/phantom.svg)](https://nodejs.org)
10
+ [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/aku11i/phantom)
10
11
 
11
12
  [インストール](#-インストール) • [基本的な使い方](#-基本的な使い方) • [なぜPhantom?](#-なぜphantom) • [ドキュメント](#-ドキュメント)
12
13
 
@@ -24,6 +25,7 @@ Phantomは、Git worktreeの管理を劇的にシンプルにするCLIツール
24
25
  - 🎯 **ブランチとWorktreeの同期** - 各worktreeに対応するブランチを自動作成
25
26
  - 🐚 **インタラクティブシェル** - SSH風のworktreeナビゲーション体験
26
27
  - ⚡ **ゼロ設定** - 賢明なデフォルト設定ですぐに使用可能
28
+ - 📦 **ゼロ依存** - 外部依存関係がなく軽量で高速
27
29
 
28
30
  ## 🤔 なぜPhantom?
29
31
 
@@ -55,6 +57,9 @@ npm install -g @aku11i/phantom
55
57
  # 新しいworktreeを作成
56
58
  phantom create feature-awesome
57
59
 
60
+ # 既存のブランチにアタッチ
61
+ phantom attach existing-branch
62
+
58
63
  # worktreeにジャンプ
59
64
  phantom shell feature-awesome
60
65
 
@@ -104,6 +109,21 @@ npm link
104
109
  ```bash
105
110
  # 対応するブランチを持つ新しいworktreeを作成
106
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"
122
+
123
+ # 既存のブランチにworktreeとしてアタッチ
124
+ phantom attach <branch-name>
125
+ phantom attach <branch-name> --shell # アタッチしてインタラクティブシェルに入る
126
+ phantom attach <branch-name> --exec <command> # アタッチしてコマンドを実行
107
127
 
108
128
  # すべてのworktreeとその現在のステータスをリスト表示
109
129
  phantom list
@@ -149,7 +169,7 @@ tmuxとPhantomを組み合わせることで、驚くほど効率的なワーク
149
169
 
150
170
  ```bash
151
171
  # 新しいtmuxウィンドウを開いて、同時にworktreeを作成
152
- tmux new-window 'phantom create new-feature --shell'
172
+ tmux new-window 'phantom create --shell new-feature'
153
173
  ```
154
174
 
155
175
  このたった1行のコマンドで:
@@ -163,8 +183,11 @@ tmux new-window 'phantom create new-feature --shell'
163
183
 
164
184
  ```bash
165
185
  # worktreeを作成してすぐにVS Codeで開く
166
- phantom create feature-auth
167
- phantom exec feature-auth code .
186
+ phantom create --exec "code ." new-feature
187
+ phantom create --exec "cursor ." new-feature # Cursorでも動作します!
188
+
189
+ # 既存のブランチにアタッチしてVS Codeで開く
190
+ phantom attach --exec "code ." feature/existing-branch
168
191
  ```
169
192
 
170
193
  ### 並行開発ワークフロー
@@ -184,11 +207,55 @@ phantom shell feature-awesome # 機能開発を続行
184
207
  | 機能 | Git Worktree | Phantom |
185
208
  |---------|--------------|---------|
186
209
  | worktree + ブランチの作成 | `git worktree add -b feature ../project-feature` | `phantom create feature` |
210
+ | 既存のブランチにアタッチ | `git worktree add ../project-feature feature` | `phantom attach feature` |
187
211
  | worktreeのリスト表示 | `git worktree list` | `phantom list` |
188
212
  | worktreeへの移動 | `cd ../project-feature` | `phantom shell feature` |
189
213
  | worktreeでコマンド実行 | `cd ../project-feature && npm test` | `phantom exec feature npm test` |
190
214
  | worktreeの削除 | `git worktree remove ../project-feature` | `phantom delete feature` |
191
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
+
192
259
  ## 🛠️ 開発
193
260
 
194
261
  ```bash
@@ -200,8 +267,11 @@ pnpm install
200
267
  # テストの実行
201
268
  pnpm test
202
269
 
270
+ # 特定のテストファイルを実行
271
+ pnpm test:file src/core/worktree/create.test.js
272
+
203
273
  # 型チェック
204
- pnpm type-check
274
+ pnpm typecheck
205
275
 
206
276
  # リンティング
207
277
  pnpm lint
@@ -262,6 +332,33 @@ Phantomの新しいバージョンをリリースするには:
262
332
  --target main
263
333
  ```
264
334
 
335
+ 7. **リリースノートを分かりやすく更新**
336
+ - 自動生成されたリリースノートをレビュー
337
+ - 重要な詳細についてはPRの説明を確認
338
+ - リリースノートをよりユーザーフレンドリーに更新:
339
+ - 変更をカテゴリー別にグループ化(機能、バグ修正、改善)
340
+ - 新機能には使用例を追加
341
+ - 変更の影響を平易な言葉で説明
342
+ - セキュリティ修正と破壊的変更を強調
343
+
344
+ ```bash
345
+ # リリースノートを編集
346
+ gh release edit v<version> --notes "$(cat <<'EOF'
347
+ ## 🚀 v<version> の新機能
348
+
349
+ ### ✨ 新機能
350
+ - 使用例付きの機能説明
351
+
352
+ ### 🐛 バグ修正
353
+ - 修正内容の明確な説明
354
+
355
+ ### 🛠️ 改善
356
+ - パフォーマンス、セキュリティ、その他の改善
357
+
358
+ EOF
359
+ )"
360
+ ```
361
+
265
362
  ビルドプロセスは`prepublishOnly`スクリプトによって自動的に処理され、以下を行います:
266
363
  - すべてのテストとチェックを実行
267
364
  - esbuildを使用してTypeScriptソースをJavaScriptにビルド
package/README.md CHANGED
@@ -7,6 +7,7 @@
7
7
  [![npm version](https://img.shields.io/npm/v/@aku11i/phantom.svg)](https://www.npmjs.com/package/@aku11i/phantom)
8
8
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
9
9
  [![Node.js Version](https://img.shields.io/node/v/@aku11i/phantom.svg)](https://nodejs.org)
10
+ [![Ask DeepWiki](https://deepwiki.com/badge.svg)](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
 
@@ -24,6 +25,7 @@ Phantom is a CLI tool that dramatically simplifies Git worktree management. It's
24
25
  - 🎯 **Branch-Worktree Sync** - Automatically creates matching branches for each worktree
25
26
  - 🐚 **Interactive Shell** - SSH-like experience for worktree navigation
26
27
  - ⚡ **Zero Configuration** - Works out of the box with sensible defaults
28
+ - 📦 **Zero Dependencies** - Lightweight and fast with no external dependencies
27
29
 
28
30
  ## 🤔 Why Phantom?
29
31
 
@@ -55,6 +57,9 @@ npm install -g @aku11i/phantom
55
57
  # Create a new worktree
56
58
  phantom create feature-awesome
57
59
 
60
+ # Attach to an existing branch
61
+ phantom attach existing-branch
62
+
58
63
  # Jump into the worktree
59
64
  phantom shell feature-awesome
60
65
 
@@ -104,6 +109,21 @@ npm link
104
109
  ```bash
105
110
  # Create a new worktree with a matching branch
106
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"
122
+
123
+ # Attach to an existing branch as a worktree
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
107
127
 
108
128
  # List all worktrees with their current status
109
129
  phantom list
@@ -114,6 +134,8 @@ phantom where <name>
114
134
  # Delete a worktree and its branch
115
135
  phantom delete <name>
116
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
117
139
  ```
118
140
 
119
141
  #### Working with Worktrees
@@ -149,7 +171,7 @@ Combine tmux with Phantom for an incredibly efficient workflow:
149
171
 
150
172
  ```bash
151
173
  # Open a new tmux window and create a worktree in one command
152
- tmux new-window 'phantom create new-feature --shell'
174
+ tmux new-window 'phantom create --shell new-feature'
153
175
  ```
154
176
 
155
177
  This single line:
@@ -163,8 +185,11 @@ When developing multiple features in parallel, you can manage each feature in it
163
185
 
164
186
  ```bash
165
187
  # Create a worktree and immediately open it in VS Code
166
- phantom create feature-auth
167
- phantom exec feature-auth code .
188
+ phantom create --exec "code ." new-feature
189
+ phantom create --exec "cursor ." new-feature # also works with cursor!!
190
+
191
+ # Attach to existing branch and open in VS Code
192
+ phantom attach --exec "code ." feature/existing-branch
168
193
  ```
169
194
 
170
195
  ### Parallel Development Workflow
@@ -184,10 +209,55 @@ phantom shell feature-awesome # Continue feature development
184
209
  | Feature | Git Worktree | Phantom |
185
210
  |---------|--------------|---------|
186
211
  | Create worktree + branch | `git worktree add -b feature ../project-feature` | `phantom create feature` |
212
+ | Attach to existing branch | `git worktree add ../project-feature feature` | `phantom attach feature` |
187
213
  | List worktrees | `git worktree list` | `phantom list` |
188
214
  | Navigate to worktree | `cd ../project-feature` | `phantom shell feature` |
189
215
  | Run command in worktree | `cd ../project-feature && npm test` | `phantom exec feature npm test` |
190
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.
191
261
 
192
262
  ## 🛠️ Development
193
263
 
@@ -200,8 +270,11 @@ pnpm install
200
270
  # Run tests
201
271
  pnpm test
202
272
 
273
+ # Run a specific test file
274
+ pnpm test:file src/core/worktree/create.test.js
275
+
203
276
  # Type checking
204
- pnpm type-check
277
+ pnpm typecheck
205
278
 
206
279
  # Linting
207
280
  pnpm lint
@@ -262,6 +335,33 @@ To release a new version of Phantom:
262
335
  --target main
263
336
  ```
264
337
 
338
+ 7. **Update release notes for clarity**
339
+ - Review the auto-generated release notes
340
+ - Check PR descriptions for important details
341
+ - Update the release notes to be more user-friendly:
342
+ - Group changes by category (Features, Bug Fixes, Improvements)
343
+ - Add usage examples for new features
344
+ - Explain the impact of changes in plain language
345
+ - Highlight security fixes and breaking changes
346
+
347
+ ```bash
348
+ # Edit the release notes
349
+ gh release edit v<version> --notes "$(cat <<'EOF'
350
+ ## 🚀 What's New in v<version>
351
+
352
+ ### ✨ New Features
353
+ - Feature description with usage example
354
+
355
+ ### 🐛 Bug Fixes
356
+ - Clear description of what was fixed
357
+
358
+ ### 🛠️ Improvements
359
+ - Performance, security, or other improvements
360
+
361
+ EOF
362
+ )"
363
+ ```
364
+
265
365
  The build process is automatically handled by the `prepublishOnly` script, which:
266
366
  - Runs all tests and checks
267
367
  - Builds the TypeScript source to JavaScript using esbuild