@akiojin/gwt 2.0.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.
Files changed (132) hide show
  1. package/README.ja.md +323 -0
  2. package/README.md +347 -0
  3. package/bin/gwt.js +5 -0
  4. package/package.json +125 -0
  5. package/src/claude-history.ts +717 -0
  6. package/src/claude.ts +292 -0
  7. package/src/cli/ui/__tests__/SKIPPED_TESTS.md +119 -0
  8. package/src/cli/ui/__tests__/acceptance/branchList.acceptance.test.tsx.skip +239 -0
  9. package/src/cli/ui/__tests__/acceptance/navigation.acceptance.test.tsx +214 -0
  10. package/src/cli/ui/__tests__/acceptance/realtimeUpdate.acceptance.test.tsx.skip +219 -0
  11. package/src/cli/ui/__tests__/components/App.protected-branch.test.tsx +183 -0
  12. package/src/cli/ui/__tests__/components/App.shortcuts.test.tsx +313 -0
  13. package/src/cli/ui/__tests__/components/App.test.tsx +270 -0
  14. package/src/cli/ui/__tests__/components/common/Confirm.test.tsx +66 -0
  15. package/src/cli/ui/__tests__/components/common/ErrorBoundary.test.tsx +103 -0
  16. package/src/cli/ui/__tests__/components/common/Input.test.tsx +92 -0
  17. package/src/cli/ui/__tests__/components/common/LoadingIndicator.test.tsx +127 -0
  18. package/src/cli/ui/__tests__/components/common/Select.memo.test.tsx +264 -0
  19. package/src/cli/ui/__tests__/components/common/Select.test.tsx +246 -0
  20. package/src/cli/ui/__tests__/components/parts/Footer.test.tsx +62 -0
  21. package/src/cli/ui/__tests__/components/parts/Header.test.tsx +54 -0
  22. package/src/cli/ui/__tests__/components/parts/ScrollableList.test.tsx +68 -0
  23. package/src/cli/ui/__tests__/components/parts/Stats.test.tsx +135 -0
  24. package/src/cli/ui/__tests__/components/screens/AIToolSelectorScreen.test.tsx +153 -0
  25. package/src/cli/ui/__tests__/components/screens/BranchCreatorScreen.test.tsx +215 -0
  26. package/src/cli/ui/__tests__/components/screens/BranchListScreen.test.tsx +293 -0
  27. package/src/cli/ui/__tests__/components/screens/ExecutionModeSelectorScreen.test.tsx +161 -0
  28. package/src/cli/ui/__tests__/components/screens/PRCleanupScreen.test.tsx +215 -0
  29. package/src/cli/ui/__tests__/components/screens/SessionSelectorScreen.test.tsx +99 -0
  30. package/src/cli/ui/__tests__/components/screens/WorktreeManagerScreen.test.tsx +127 -0
  31. package/src/cli/ui/__tests__/hooks/useGitData.test.ts.skip +228 -0
  32. package/src/cli/ui/__tests__/hooks/useScreenState.test.ts +146 -0
  33. package/src/cli/ui/__tests__/hooks/useTerminalSize.test.ts +98 -0
  34. package/src/cli/ui/__tests__/integration/branchList.test.tsx.skip +253 -0
  35. package/src/cli/ui/__tests__/integration/edgeCases.test.tsx +306 -0
  36. package/src/cli/ui/__tests__/integration/navigation.test.tsx +405 -0
  37. package/src/cli/ui/__tests__/integration/realtimeUpdate.test.tsx +505 -0
  38. package/src/cli/ui/__tests__/integration/realtimeUpdate.test.tsx.skip +216 -0
  39. package/src/cli/ui/__tests__/performance/branchList.performance.test.tsx +180 -0
  40. package/src/cli/ui/__tests__/performance/useMemoOptimization.test.tsx +237 -0
  41. package/src/cli/ui/__tests__/utils/branchFormatter.test.ts +775 -0
  42. package/src/cli/ui/__tests__/utils/statisticsCalculator.test.ts +243 -0
  43. package/src/cli/ui/components/App.tsx +793 -0
  44. package/src/cli/ui/components/common/Confirm.tsx +40 -0
  45. package/src/cli/ui/components/common/ErrorBoundary.tsx +57 -0
  46. package/src/cli/ui/components/common/Input.tsx +36 -0
  47. package/src/cli/ui/components/common/LoadingIndicator.tsx +95 -0
  48. package/src/cli/ui/components/common/Select.tsx +216 -0
  49. package/src/cli/ui/components/parts/Footer.tsx +41 -0
  50. package/src/cli/ui/components/parts/Header.test.tsx +85 -0
  51. package/src/cli/ui/components/parts/Header.tsx +63 -0
  52. package/src/cli/ui/components/parts/MergeStatusList.tsx +75 -0
  53. package/src/cli/ui/components/parts/ProgressBar.tsx +73 -0
  54. package/src/cli/ui/components/parts/ScrollableList.tsx +24 -0
  55. package/src/cli/ui/components/parts/Stats.tsx +67 -0
  56. package/src/cli/ui/components/screens/AIToolSelectorScreen.tsx +116 -0
  57. package/src/cli/ui/components/screens/BatchMergeProgressScreen.tsx +70 -0
  58. package/src/cli/ui/components/screens/BatchMergeResultScreen.tsx +104 -0
  59. package/src/cli/ui/components/screens/BranchCreatorScreen.tsx +213 -0
  60. package/src/cli/ui/components/screens/BranchListScreen.tsx +299 -0
  61. package/src/cli/ui/components/screens/ExecutionModeSelectorScreen.tsx +149 -0
  62. package/src/cli/ui/components/screens/PRCleanupScreen.tsx +167 -0
  63. package/src/cli/ui/components/screens/SessionSelectorScreen.tsx +100 -0
  64. package/src/cli/ui/components/screens/WorktreeManagerScreen.tsx +117 -0
  65. package/src/cli/ui/hooks/useBatchMerge.ts +96 -0
  66. package/src/cli/ui/hooks/useGitData.ts +157 -0
  67. package/src/cli/ui/hooks/useScreenState.ts +44 -0
  68. package/src/cli/ui/hooks/useTerminalSize.ts +33 -0
  69. package/src/cli/ui/screens/BranchActionSelectorScreen.tsx +102 -0
  70. package/src/cli/ui/screens/__tests__/BranchActionSelectorScreen.test.tsx +151 -0
  71. package/src/cli/ui/types.ts +295 -0
  72. package/src/cli/ui/utils/baseBranch.ts +34 -0
  73. package/src/cli/ui/utils/branchFormatter.ts +222 -0
  74. package/src/cli/ui/utils/statisticsCalculator.ts +44 -0
  75. package/src/codex.ts +139 -0
  76. package/src/config/builtin-tools.ts +44 -0
  77. package/src/config/constants.ts +100 -0
  78. package/src/config/env-history.ts +45 -0
  79. package/src/config/index.ts +204 -0
  80. package/src/config/tools.ts +293 -0
  81. package/src/git.ts +1102 -0
  82. package/src/github.ts +158 -0
  83. package/src/index.test.ts +87 -0
  84. package/src/index.ts +684 -0
  85. package/src/index.ts.backup +1543 -0
  86. package/src/launcher.ts +142 -0
  87. package/src/repositories/git.repository.ts +129 -0
  88. package/src/repositories/github.repository.ts +83 -0
  89. package/src/repositories/worktree.repository.ts +69 -0
  90. package/src/services/BatchMergeService.ts +251 -0
  91. package/src/services/WorktreeOrchestrator.ts +115 -0
  92. package/src/services/__tests__/BatchMergeService.test.ts +518 -0
  93. package/src/services/__tests__/WorktreeOrchestrator.test.ts +258 -0
  94. package/src/services/dependency-installer.ts +199 -0
  95. package/src/services/git.service.ts +113 -0
  96. package/src/services/github.service.ts +61 -0
  97. package/src/services/worktree.service.ts +66 -0
  98. package/src/types/api.ts +241 -0
  99. package/src/types/tools.ts +235 -0
  100. package/src/utils/spinner.ts +54 -0
  101. package/src/utils/terminal.ts +272 -0
  102. package/src/utils.test.ts +43 -0
  103. package/src/utils.ts +60 -0
  104. package/src/web/client/index.html +12 -0
  105. package/src/web/client/src/components/BranchGraph.tsx +231 -0
  106. package/src/web/client/src/components/EnvEditor.tsx +145 -0
  107. package/src/web/client/src/components/Terminal.tsx +137 -0
  108. package/src/web/client/src/hooks/useBranches.ts +41 -0
  109. package/src/web/client/src/hooks/useConfig.ts +31 -0
  110. package/src/web/client/src/hooks/useSessions.ts +59 -0
  111. package/src/web/client/src/hooks/useWorktrees.ts +47 -0
  112. package/src/web/client/src/index.css +834 -0
  113. package/src/web/client/src/lib/api.ts +184 -0
  114. package/src/web/client/src/lib/websocket.ts +174 -0
  115. package/src/web/client/src/main.tsx +29 -0
  116. package/src/web/client/src/pages/BranchDetailPage.tsx +847 -0
  117. package/src/web/client/src/pages/BranchListPage.tsx +264 -0
  118. package/src/web/client/src/pages/ConfigManagementPage.tsx +203 -0
  119. package/src/web/client/src/router.tsx +27 -0
  120. package/src/web/client/vite.config.ts +21 -0
  121. package/src/web/server/env/importer.ts +54 -0
  122. package/src/web/server/index.ts +74 -0
  123. package/src/web/server/pty/manager.ts +189 -0
  124. package/src/web/server/routes/branches.ts +126 -0
  125. package/src/web/server/routes/config.ts +220 -0
  126. package/src/web/server/routes/index.ts +37 -0
  127. package/src/web/server/routes/sessions.ts +130 -0
  128. package/src/web/server/routes/worktrees.ts +108 -0
  129. package/src/web/server/services/branches.ts +368 -0
  130. package/src/web/server/services/worktrees.ts +85 -0
  131. package/src/web/server/websocket/handler.ts +180 -0
  132. package/src/worktree.ts +703 -0
package/README.ja.md ADDED
@@ -0,0 +1,323 @@
1
+ # @akiojin/gwt
2
+
3
+ [English](README.md)
4
+
5
+ Claude Code / Codex CLI 対応の対話型Gitワークツリーマネージャー(グラフィカルなブランチ選択と高度なワークフロー管理機能付き)
6
+
7
+ ## 概要
8
+
9
+ `@akiojin/gwt`は、直感的なインターフェースを通じてGitワークツリー管理を革新する強力なCLIツールです。Claude Code / Codex CLI の開発ワークフローとシームレスに統合し、インテリジェントなブランチ選択、自動ワークツリー作成、包括的なプロジェクト管理機能を提供します。
10
+
11
+ ## ✨ 主要機能
12
+
13
+ - 🎯 **対話型ブランチ選択**: ブランチ種別・ワークツリー・変更状態アイコンに加え配置インジケータ枠(左=L, 右=R, リモートのみ=☁)で所在を示し、リモート名の `origin/` を省いたシンプルなリストで判別しやすく、現在の選択は `>` プレフィックスで強調されるため誤操作を防止
14
+ - 🌟 **スマートブランチ作成**: ガイド付きプロンプトと自動ベースブランチ選択でfeature、hotfix、releaseブランチを作成
15
+ - 🔄 **高度なワークツリー管理**: 作成、クリーンアップ、パス最適化を含む完全なライフサイクル管理
16
+ - 🤖 **AIツール選択**: 起動時の対話型ランチャーで Claude Code / Codex CLI を選択
17
+ - 🚀 **AIツール統合**: 選択したツールをワークツリーで起動(Claude Codeは権限設定・変更処理の統合あり)
18
+ - 📊 **GitHub PR統合**: マージされたプルリクエストのブランチとワークツリーの自動クリーンアップ
19
+ - 🛠️ **変更管理**: 開発セッション後のコミット、stash、破棄の内蔵サポート
20
+ - 📦 **ユニバーサルパッケージ**: 一度インストールすれば全プロジェクトで一貫した動作
21
+ - 🔍 **リポジトリ統計**: プロジェクト概要の向上のためのブランチとワークツリー数のリアルタイム表示
22
+
23
+ ## インストール
24
+
25
+ ### グローバルインストール(推奨)
26
+
27
+ 永続的なアクセスのためにグローバルインストール:
28
+
29
+ #### bun(グローバルインストール)
30
+
31
+ ```bash
32
+ bun add -g @akiojin/gwt
33
+ ```
34
+
35
+ ### 一回限りの使用
36
+
37
+ インストールせずに実行:
38
+
39
+ #### bunx (bun)
40
+
41
+ ```bash
42
+ bunx @akiojin/gwt
43
+ ```
44
+
45
+ ## クイックスタート
46
+
47
+ 任意のGitリポジトリで実行:
48
+
49
+ ```bash
50
+ # グローバルインストール済みの場合
51
+ gwt
52
+
53
+ # または一回限りの実行に bunx を使用
54
+ bunx @akiojin/gwt
55
+ ```
56
+
57
+ CLIオプション:
58
+
59
+ ```bash
60
+ # ヘルプを表示
61
+ gwt --help
62
+
63
+ # バージョンを確認
64
+ gwt --version
65
+ # または
66
+ gwt -v
67
+ ```
68
+
69
+ ツールは以下のオプションを持つ対話型インターフェースを提供します:
70
+
71
+ 1. **既存ブランチを選択**: ワークツリー自動作成機能付きでローカル・リモートブランチから選択
72
+ 2. **新規ブランチ作成**: タイプ選択(feature/hotfix/release)によるガイド付きブランチ作成
73
+ 3. **ワークツリー管理**: 既存ワークツリーの表示、オープン、削除
74
+ 4. **ブランチクリーンアップ**: マージ済みPRやベースブランチと差分がないブランチ/ワークツリーをローカルから自動削除
75
+
76
+ ## 高度なワークフロー
77
+
78
+ ### ブランチ作成ワークフロー
79
+
80
+ > **重要**: このワークフローは人間の開発者向けです。エージェントは、ユーザーから明確かつタスク固有の指示がない限り、ブランチの作成や削除を絶対に行ってはいけません。
81
+
82
+ 1. メインメニューから「新規ブランチ作成」を選択
83
+ 2. ブランチタイプ(feature、hotfix、release)を選択
84
+ 3. 自動プレフィックス適用でブランチ名を入力
85
+ 4. 利用可能なオプションからベースブランチを選択
86
+ 5. ワークツリー作成パスを確認
87
+ 6. 自動ワークツリーセットアップと選択ツールの起動
88
+
89
+ ### ワークツリー管理
90
+
91
+ - **既存を開く**: 既存ワークツリーで選択ツールを起動
92
+ - **ワークツリー削除**: オプションのブランチ削除付きクリーン削除
93
+ - **バッチ操作**: 複数ワークツリーの効率的な処理
94
+
95
+ ### GitHub統合
96
+
97
+ - **ブランチクリーンアップ**: マージ済みPRやベースブランチと差分がないブランチを自動検出して安全に削除
98
+ - **認証確認**: 操作前にGitHub CLIセットアップを検証
99
+ - **リモート同期**: クリーンアップ操作前に最新変更を取得
100
+
101
+ ### PR自動マージ
102
+
103
+ リポジトリには、開発プロセスを効率化するPR自動マージワークフローが含まれています:
104
+
105
+ - **自動マージ**: すべてのCIチェック(Test、Lint)が成功し、競合がない場合、PRを自動的にマージ
106
+ - **マージ方法**: マージコミットを使用して完全なコミット履歴を保持
107
+ - **スマートスキップロジック**: ドラフトPR、競合のあるPR、CI失敗時は自動的にスキップ
108
+ - **対象ブランチ**: `develop`ブランチへのPRで有効(機能統合)
109
+ - **安全第一**: ブランチ保護ルールを尊重し、CI成功を必須条件とする
110
+
111
+ **動作の仕組み:**
112
+
113
+ 1. `develop`を対象とするPRを作成
114
+ 2. CIワークフロー(Test、Lint)が自動実行
115
+ 3. すべてのCIチェックが成功し、競合がない場合、PRが自動的に`develop`にマージされる
116
+ 4. 変更は`develop`に蓄積され、リリース準備ができるまで待機
117
+ 5. `/release`コマンドを使用して`develop`を`main`にマージし、semantic-releaseをトリガー
118
+
119
+ **自動マージの無効化:**
120
+
121
+ - ドラフトPRとして作成すると自動マージを防げます: `gh pr create --draft`
122
+ - 自動マージワークフローはこの設定を尊重し、ドラフトPRはスキップします
123
+
124
+ 技術的な詳細については、[specs/SPEC-cff08403/](specs/SPEC-cff08403/)を参照してください。
125
+
126
+ ## システム要件
127
+
128
+ - **Bun**: >= 1.0.0
129
+ - **Node.js**(任意): Nodeベースの開発ツール利用時は >= 18.0.0 を推奨
130
+ - **pnpm**: >= 8.0.0(CI/CD・Docker環境用 - ハードリンクによるnode_modules効率化)
131
+ - **Git**: ワークツリーサポート付き最新版
132
+ - **AIツール**: 少なくともいずれかが必要(Claude Code もしくは Codex CLI)
133
+ - **GitHub CLI**: PR クリーンアップ機能に必要(オプション)
134
+ - **Python**: >= 3.11(Spec Kit CLIに必要)
135
+ - **uv**: Pythonパッケージマネージャー(Spec Kit CLIに必要)
136
+
137
+ ## Spec Kit による仕様駆動開発
138
+
139
+ このプロジェクトは、仕様駆動開発ワークフローのために **@akiojin/spec-kit**(GitHub Spec Kit の日本語対応版)を使用しています。
140
+
141
+ ### Spec Kit CLI のインストール
142
+
143
+ ```bash
144
+ # uvでグローバルインストール
145
+ uv tool install specify-cli --from git+https://github.com/akiojin/spec-kit.git
146
+
147
+ # インストール確認
148
+ specify --help
149
+ ```
150
+
151
+ ### 利用可能な Spec Kit コマンド
152
+
153
+ Claude Code で以下のコマンドを実行して、仕様駆動開発を活用できます:
154
+
155
+ - `/speckit.constitution` - プロジェクト原則とガイドラインを定義
156
+ - `/speckit.specify` - 機能仕様書を作成
157
+ - `/speckit.plan` - 技術実装計画を作成
158
+ - `/speckit.tasks` - 実行可能なタスクリストを生成
159
+ - `/speckit.implement` - 実装を実行
160
+
161
+ ### 品質保証用オプションコマンド
162
+
163
+ - `/speckit.clarify` - 計画前に曖昧な領域を解消
164
+ - `/speckit.analyze` - 仕様、計画、タスク間の整合性を検証
165
+ - `/speckit.checklist` - 要件の網羅性と明確性を検証
166
+
167
+ ### Spec Kit ワークフロー
168
+
169
+ 1. `/speckit.constitution` でプロジェクトの基礎を確立
170
+ 2. `/speckit.specify` で構築したいものを定義
171
+ 3. `/speckit.plan` で技術アーキテクチャを作成
172
+ 4. `/speckit.tasks` でタスクを生成
173
+ 5. `/speckit.implement` で実装を実行
174
+
175
+ 詳細は [Spec Kit ドキュメント](https://github.com/akiojin/spec-kit) を参照してください。
176
+
177
+ ## プロジェクト構造
178
+
179
+ ```
180
+ @akiojin/gwt/
181
+ ├── src/
182
+ │ ├── index.ts # メインアプリケーションエントリーポイント
183
+ │ ├── git.ts # Git操作とブランチ管理
184
+ │ ├── worktree.ts # ワークツリー作成と管理
185
+ │ ├── claude.ts # Claude Code 統合
186
+ │ ├── codex.ts # Codex CLI 統合
187
+ │ ├── github.ts # GitHub CLI統合
188
+ │ ├── utils.ts # ユーティリティ関数とエラーハンドリング
189
+ │ └── ui/ # ユーザーインターフェースコンポーネント
190
+ │ ├── display.ts # コンソール出力フォーマット
191
+ │ ├── prompts.ts # 対話型プロンプト
192
+ │ ├── table.ts # ブランチテーブル生成
193
+ │ └── types.ts # TypeScript型定義
194
+ ├── bin/
195
+ │ └── gwt.js # 実行可能ラッパー
196
+ ├── .claude/ # Claude Code 設定
197
+ │ └── commands/ # Spec Kit スラッシュコマンド
198
+ ├── .specify/ # Spec Kit スクリプトとテンプレート
199
+ │ ├── memory/ # プロジェクトメモリファイル
200
+ │ ├── scripts/ # 自動化スクリプト
201
+ │ └── templates/ # 仕様書テンプレート
202
+ ├── specs/ # 機能仕様書
203
+ └── dist/ # コンパイル済みJavaScript出力
204
+ ```
205
+
206
+ ## 開発
207
+
208
+ ### セットアップ
209
+
210
+ ```bash
211
+ # リポジトリをクローン
212
+ git clone https://github.com/akiojin/gwt.git
213
+ cd gwt
214
+
215
+ # 依存関係をインストール(bun)
216
+ bun install
217
+
218
+ # プロジェクトをビルド(bun)
219
+ bun run build
220
+ ```
221
+
222
+ ### 利用可能なスクリプト
223
+
224
+ ```bash
225
+ # 自動リビルド付き開発モード(bun)
226
+ bun run dev
227
+
228
+ # プロダクションビルド(bun)
229
+ bun run build
230
+
231
+ # 型チェック(bun)
232
+ bun run type-check
233
+
234
+ # コードリンティング(bun)
235
+ bun run lint
236
+
237
+ # ビルド成果物をクリーン(bun)
238
+ bun run clean
239
+
240
+ # CLIをローカルテスト(bun)
241
+ bun run start
242
+ ```
243
+
244
+ ### 開発ワークフロー
245
+
246
+ 1. **フォークとクローン**: リポジトリをフォークし、あなたのフォークをクローン
247
+ 2. **ブランチ作成**: ツール自体を使用してfeatureブランチを作成
248
+ 3. **開発**: TypeScriptサポート付きで変更を実施
249
+ 4. **テスト**: `bun run start`でCLI機能をテスト
250
+ 5. **品質チェック**: `bun run type-check`と`bun run lint`を実行
251
+ 6. **プルリクエスト**: 明確な説明付きでPRを提出
252
+
253
+ ### コード構造
254
+
255
+ - **エントリーポイント**: `src/index.ts` - メインアプリケーションロジック
256
+ - **コアモジュール**: Git操作、ワークツリー管理、Claude統合
257
+ - **UIコンポーネント**: `src/ui/`のモジュラーインターフェースコンポーネント
258
+ - **型安全性**: 包括的なTypeScript定義
259
+ - **エラーハンドリング**: 全モジュールにわたる堅牢なエラー管理
260
+
261
+ ## 統合例
262
+
263
+ ### カスタムスクリプト
264
+
265
+ ```bash
266
+ # Package.jsonスクリプト例
267
+ {
268
+ "scripts": {
269
+ "worktree": "gwt"
270
+ }
271
+ }
272
+ ```
273
+
274
+ ## リリースプロセス
275
+
276
+ 利用者の方は GitHub Releases もしくは npm で公開される最新版をご利用ください。リリース自動化の概要は [docs/release-guide.md](./docs/release-guide.md)(日本語版: [docs/release-guide.ja.md](./docs/release-guide.ja.md))にまとめており、詳細設計は `specs/SPEC-57fde06f/` を参照してください。
277
+
278
+ ## トラブルシューティング
279
+
280
+ ### よくある問題
281
+
282
+ **権限エラー**: Claude Codeが適切なディレクトリ権限を持っていることを確認
283
+ **Git ワークツリー競合**: クリーンアップ機能を使用して古いワークツリーを削除
284
+ **GitHub認証**: PRクリーンアップ機能使用前に`gh auth login`を実行
285
+ **Bunバージョン**: `bun --version`でBun >= 1.0.0を確認
286
+
287
+ ### デバッグモード
288
+
289
+ 詳細出力には環境変数を設定:
290
+
291
+ ```bash
292
+ DEBUG=gwt gwt
293
+ ```
294
+
295
+ ## ライセンス
296
+
297
+ MIT - 詳細はLICENSEファイルを参照
298
+
299
+ ## 貢献
300
+
301
+ 貢献を歓迎します!以下の貢献ガイドラインをお読みください:
302
+
303
+ 1. **Issues**: GitHub IssuesでバグレポートやFeatureリクエストを報告
304
+ 2. **プルリクエスト**: 上記の開発ワークフローに従う
305
+ 3. **コードスタイル**: TypeScriptベストプラクティスと既存パターンを維持
306
+ 4. **ドキュメント**: 重要な変更についてはREADMEとコードコメントを更新
307
+
308
+ ### 貢献者
309
+
310
+ - AI Novel Project Team
311
+ - コミュニティ貢献者歓迎
312
+
313
+ ## サポート
314
+
315
+ - **ドキュメント**: このREADMEとインラインコードドキュメント
316
+ - **Issues**: バグレポートとFeatureリクエスト用のGitHub Issues
317
+ - **ディスカッション**: 質問とコミュニティサポート用のGitHub Discussions
318
+
319
+ ### アイコン凡例
320
+
321
+ - 先頭3枠: ⚡(main/develop) / ✨(feature) / 🔥(hotfix) / 📦(release) / 📌(other)、🟢=ワークツリーあり、🟠=ワークツリーあり(アクセス不可)、✏️=未コミット、⚠️=警告、⭐=現在ブランチ
322
+ - 配置枠: 空白=ローカルが存在、`☁`=リモートのみ存在
323
+ - 選択枠: カラー環境では背景反転を用いず `>`プレフィックス(スペース付き)で選択中を表示
package/README.md ADDED
@@ -0,0 +1,347 @@
1
+ # @akiojin/gwt
2
+
3
+ [日本語](README.ja.md)
4
+
5
+ Interactive Git worktree manager with AI tool selection (Claude Code / Codex CLI), graphical branch selection, and advanced workflow management.
6
+
7
+ ## Overview
8
+
9
+ `@akiojin/gwt` is a powerful CLI tool that revolutionizes Git worktree management through an intuitive interface. It seamlessly integrates with Claude Code / Codex CLI workflows, providing intelligent branch selection, automated worktree creation, and comprehensive project management capabilities.
10
+
11
+ ## ✨ Key Features
12
+
13
+ - 🎯 **Modern React-based UI**: Built with Ink.js for a smooth, responsive terminal interface with real-time updates
14
+ - 🖼️ **Full-screen Layout**: Persistent header with statistics, scrollable branch list, and always-visible footer with keyboard shortcuts
15
+ - 🌟 **Smart Branch Creation**: Create feature, hotfix, or release branches with guided prompts and automatic base branch selection
16
+ - 🔄 **Advanced Worktree Management**: Complete lifecycle management including creation, cleanup, and path optimization
17
+ - 🤖 **AI Tool Selection**: Choose between Claude Code / Codex CLI through the interactive launcher
18
+ - 🚀 **AI Tool Integration**: Launch the selected tool in the worktree (Claude Code includes permission handling and post-change flow)
19
+ - 🔒 **Worktree Command Restriction**: PreToolUse hooks enforce worktree boundaries, blocking directory navigation, branch switching, and file operations outside the worktree
20
+ - 📊 **GitHub PR Integration**: Automatic cleanup of merged pull request branches and worktrees
21
+ - 🛠️ **Change Management**: Built-in support for committing, stashing, or discarding changes after development sessions
22
+ - 📦 **Universal Package**: Install once, use across all your projects with consistent behavior
23
+ - 🔍 **Real-time Statistics**: Live updates of branch and worktree counts with automatic terminal resize handling
24
+
25
+ ## Installation
26
+
27
+ ### Global Installation (Recommended)
28
+
29
+ Install globally with your preferred package manager:
30
+
31
+ #### bun (global install)
32
+
33
+ ```bash
34
+ bun add -g @akiojin/gwt
35
+ ```
36
+
37
+ ### One-time Usage
38
+
39
+ Run without installation using bunx:
40
+
41
+ #### bunx (bun)
42
+
43
+ ```bash
44
+ bunx @akiojin/gwt
45
+ ```
46
+
47
+ ## Quick Start
48
+
49
+ Run in any Git repository:
50
+
51
+ ```bash
52
+ # If installed globally
53
+ gwt
54
+
55
+ # Or use bunx for one-time execution
56
+ bunx @akiojin/gwt
57
+ ```
58
+
59
+ CLI options:
60
+
61
+ ```bash
62
+ # Display help
63
+ gwt --help
64
+
65
+ # Check version
66
+ gwt --version
67
+ # or
68
+ gwt -v
69
+ ```
70
+
71
+ The tool presents an interactive interface with the following options:
72
+
73
+ 1. **Select Existing Branch**: Choose from local or remote branches with worktree auto-creation
74
+ 2. **Create New Branch**: Guided branch creation with type selection (feature/hotfix/release)
75
+ 3. **Manage Worktrees**: View, open, or remove existing worktrees
76
+ 4. **Cleanup Branches**: Remove merged PR branches or branches identical to their base directly from the CLI
77
+
78
+ ## Advanced Workflows
79
+
80
+ ### Branch Strategy
81
+
82
+ This repository follows a structured branching strategy:
83
+
84
+ - **`main`**: Production-ready code. Protected branch for releases only.
85
+ - **`develop`**: Integration branch for features. All feature branches merge here.
86
+ - **`feature/*`**: New features and enhancements. **Must be based on and target `develop`**.
87
+ - **`hotfix/*`**: Critical production fixes. Based on and target `main`.
88
+ - **`release/*`**: Release preparation branches.
89
+
90
+ **Important**: When creating feature branches, always use `develop` as the base branch:
91
+
92
+ ```bash
93
+ # Correct: Create feature branch from develop
94
+ git checkout develop
95
+ git pull origin develop
96
+ git checkout -b feature/my-feature
97
+
98
+ # Or use this tool which handles it automatically
99
+ gwt
100
+ # → Select "Create new branch" → "feature" → automatically uses develop as base
101
+ ```
102
+
103
+ ### Branch Creation Workflow
104
+
105
+ > **Important**: This workflow is intended for human developers. Autonomous agents must never create or delete branches unless a human gives explicit, task-specific instructions.
106
+
107
+ 1. Select "Create new branch" from the main menu
108
+ 2. Choose branch type (feature, hotfix, release)
109
+ 3. Enter branch name with automatic prefix application
110
+ 4. Select base branch from available options (feature → develop, hotfix → main)
111
+ 5. Confirm worktree creation path
112
+ 6. Automatic worktree setup and selected tool launch
113
+
114
+ ### Worktree Management
115
+
116
+ - **Open Existing**: Launch the selected tool in existing worktrees
117
+ - **Remove Worktree**: Clean removal with optional branch deletion
118
+ - **Batch Operations**: Handle multiple worktrees efficiently
119
+
120
+ ### GitHub Integration
121
+
122
+ - **Branch Cleanup**: Automatically detect and remove merged pull request branches or branches that no longer differ from their base
123
+ - **Authentication Check**: Verify GitHub CLI setup before operations
124
+ - **Remote Sync**: Fetch latest changes before cleanup operations
125
+
126
+ ### Automated PR Merge
127
+
128
+ The repository includes an automated PR merge workflow that streamlines the development process:
129
+
130
+ - **Automatic Merge**: PRs are automatically merged when all CI checks (Test, Lint) pass and there are no conflicts
131
+ - **Merge Method**: Uses merge commit to preserve full commit history
132
+ - **Smart Skip Logic**: Automatically skips draft PRs, conflicted PRs, and failed CI runs
133
+ - **Target Branch**: Active for PRs targeting `develop` branch (feature integration)
134
+ - **Safety First**: Respects branch protection rules and requires successful CI completion
135
+
136
+ **How it works:**
137
+
138
+ 1. PR is created targeting `develop`
139
+ 2. CI workflows (Test, Lint) run automatically
140
+ 3. When all CI checks pass and no conflicts exist, the PR is automatically merged to `develop`
141
+ 4. Changes accumulate on `develop` until ready for release
142
+ 5. Use `/release` command to merge `develop` to `main` and trigger semantic-release
143
+
144
+ **Disabling auto-merge:**
145
+
146
+ - Create PRs as drafts to prevent auto-merge: `gh pr create --draft`
147
+ - The auto-merge workflow respects this setting and will skip draft PRs
148
+
149
+ For technical details, see [specs/SPEC-cff08403/](specs/SPEC-cff08403/).
150
+
151
+ ## System Requirements
152
+
153
+ - **Bun**: >= 1.0.0
154
+ - **Node.js** (optional): Recommended >= 18.0.0 when working with Node-based tooling
155
+ - **pnpm**: >= 8.0.0 (for CI/CD and Docker environments - uses hardlinked node_modules)
156
+ - **Git**: Latest version with worktree support
157
+ - **AI Tool**: At least one of Claude Code or Codex CLI should be available
158
+ - **GitHub CLI**: Required for PR cleanup features (optional)
159
+ - **Python**: >= 3.11 (for Spec Kit CLI)
160
+ - **uv**: Python package manager (for Spec Kit CLI)
161
+
162
+ ## Spec-Driven Development with Spec Kit
163
+
164
+ This project uses **@akiojin/spec-kit**, a Japanese-localized version of GitHub's Spec Kit for spec-driven development workflows.
165
+
166
+ ### Installing Spec Kit CLI
167
+
168
+ ```bash
169
+ # Install globally with uv
170
+ uv tool install specify-cli --from git+https://github.com/akiojin/spec-kit.git
171
+
172
+ # Verify installation
173
+ specify --help
174
+ ```
175
+
176
+ ### Available Spec Kit Commands
177
+
178
+ Execute these commands in Claude Code to leverage spec-driven development:
179
+
180
+ - `/speckit.constitution` - Define project principles and guidelines
181
+ - `/speckit.specify` - Create feature specifications
182
+ - `/speckit.plan` - Create technical implementation plans
183
+ - `/speckit.tasks` - Generate actionable task lists
184
+ - `/speckit.implement` - Execute implementation
185
+
186
+ ### Optional Quality Assurance Commands
187
+
188
+ - `/speckit.clarify` - Resolve ambiguities before planning
189
+ - `/speckit.analyze` - Validate consistency between spec, plan, and tasks
190
+ - `/speckit.checklist` - Verify requirement coverage and clarity
191
+
192
+ ### Spec Kit Workflow
193
+
194
+ 1. Start with `/speckit.constitution` to establish project foundations
195
+ 2. Use `/speckit.specify` to define what you want to build
196
+ 3. Run `/speckit.plan` to create technical architecture
197
+ 4. Generate tasks with `/speckit.tasks`
198
+ 5. Implement with `/speckit.implement`
199
+
200
+ For more details, see the [Spec Kit documentation](https://github.com/akiojin/spec-kit).
201
+
202
+ ## Project Structure
203
+
204
+ ```
205
+ @akiojin/gwt/
206
+ ├── src/
207
+ │ ├── index.ts # Main application entry point
208
+ │ ├── git.ts # Git operations and branch management
209
+ │ ├── worktree.ts # Worktree creation and management
210
+ │ ├── claude.ts # Claude Code integration
211
+ │ ├── codex.ts # Codex CLI integration
212
+ │ ├── github.ts # GitHub CLI integration
213
+ │ ├── utils.ts # Utility functions and error handling
214
+ │ └── ui/ # User interface components
215
+ │ ├── display.ts # Console output formatting
216
+ │ ├── prompts.ts # Interactive prompts
217
+ │ ├── table.ts # Branch table generation
218
+ │ └── types.ts # TypeScript type definitions
219
+ ├── bin/
220
+ │ └── gwt.js # Executable wrapper
221
+ ├── .claude/ # Claude Code configuration
222
+ │ ├── commands/ # Spec Kit slash commands
223
+ │ ├── settings.json # Hook configuration
224
+ │ └── hooks/ # PreToolUse hooks for command restriction
225
+ │ ├── block-cd-command.sh # Restricts cd commands to worktree
226
+ │ ├── block-git-branch-ops.sh # Controls git branch operations
227
+ │ └── block-file-ops.sh # Restricts file operations to worktree
228
+ ├── .specify/ # Spec Kit scripts and templates
229
+ │ ├── memory/ # Project memory files
230
+ │ ├── scripts/ # Automation scripts
231
+ │ └── templates/ # Specification templates
232
+ ├── specs/ # Feature specifications
233
+ └── dist/ # Compiled JavaScript output
234
+ ```
235
+
236
+ ## Development
237
+
238
+ ### Setup
239
+
240
+ ```bash
241
+ # Clone the repository
242
+ git clone https://github.com/akiojin/gwt.git
243
+ cd gwt
244
+
245
+ # Install dependencies (bun)
246
+ bun install
247
+
248
+ # Build the project (bun)
249
+ bun run build
250
+ ```
251
+
252
+ ### Available Scripts
253
+
254
+ ```bash
255
+ # Development mode with auto-rebuild (bun)
256
+ bun run dev
257
+
258
+ # Production build (bun)
259
+ bun run build
260
+
261
+ # Type checking (bun)
262
+ bun run type-check
263
+
264
+ # Code linting (bun)
265
+ bun run lint
266
+
267
+ # Clean build artifacts (bun)
268
+ bun run clean
269
+
270
+ # Test the CLI locally (bun)
271
+ bun run start
272
+ ```
273
+
274
+ ### Development Workflow
275
+
276
+ 1. **Fork and Clone**: Fork the repository and clone your fork
277
+ 2. **Create Branch**: Use the tool itself to create a feature branch
278
+ 3. **Development**: Make changes with TypeScript support
279
+ 4. **Testing**: Test CLI functionality with `bun run start`
280
+ 5. **Quality Checks**: Run `bun run type-check` and `bun run lint`
281
+ 6. **Pull Request**: Submit a PR with clear description
282
+
283
+ ### Code Structure
284
+
285
+ - **Entry Point**: `src/index.ts` - Main application logic
286
+ - **Core Modules**: Git operations, worktree management, Claude integration
287
+ - **UI Components**: Modular interface components in `src/ui/`
288
+ - **Type Safety**: Comprehensive TypeScript definitions
289
+ - **Error Handling**: Robust error management across all modules
290
+
291
+ ## Integration Examples
292
+
293
+ ### Custom Scripts
294
+
295
+ ```bash
296
+ # Package.json script example
297
+ {
298
+ "scripts": {
299
+ "worktree": "gwt"
300
+ }
301
+ }
302
+ ```
303
+
304
+ ## Release Process
305
+
306
+ We ship releases through semantic-release. End users can simply install the latest published package (via npm or the GitHub Releases tab) and rely on versioned artifacts. Maintainers who need the full workflow should read [docs/release-guide.md](./docs/release-guide.md) (日本語版: [docs/release-guide.ja.md](./docs/release-guide.ja.md)) and the in-depth specs under `specs/SPEC-57fde06f/`.
307
+
308
+ ## Troubleshooting
309
+
310
+ ### Common Issues
311
+
312
+ **Permission Errors**: Ensure Claude Code has proper directory permissions
313
+ **Git Worktree Conflicts**: Use the cleanup feature to remove stale worktrees
314
+ **GitHub Authentication**: Run `gh auth login` before using PR cleanup features
315
+ **Bun Version**: Verify Bun >= 1.0.0 with `bun --version`
316
+
317
+ ### Debug Mode
318
+
319
+ For verbose output, set the environment variable:
320
+
321
+ ```bash
322
+ DEBUG=gwt gwt
323
+ ```
324
+
325
+ ## License
326
+
327
+ MIT - See LICENSE file for details
328
+
329
+ ## Contributing
330
+
331
+ We welcome contributions! Please read our contributing guidelines:
332
+
333
+ 1. **Issues**: Report bugs or request features via GitHub Issues
334
+ 2. **Pull Requests**: Follow the development workflow above
335
+ 3. **Code Style**: Maintain TypeScript best practices and existing patterns
336
+ 4. **Documentation**: Update README and code comments for significant changes
337
+
338
+ ### Contributors
339
+
340
+ - AI Novel Project Team
341
+ - Community contributors welcome
342
+
343
+ ## Support
344
+
345
+ - **Documentation**: This README and inline code documentation
346
+ - **Issues**: GitHub Issues for bug reports and feature requests
347
+ - **Discussions**: GitHub Discussions for questions and community support
package/bin/gwt.js ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+ import('../dist/index.js').catch(err => {
3
+ console.error(err);
4
+ process.exit(1);
5
+ });