@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
@@ -0,0 +1,243 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import { calculateStatistics } from "../../utils/statisticsCalculator.js";
3
+ import type { BranchInfo } from "../../types.js";
4
+
5
+ describe("statisticsCalculator", () => {
6
+ describe("calculateStatistics", () => {
7
+ it("should calculate basic counts", () => {
8
+ const branches: BranchInfo[] = [
9
+ {
10
+ name: "main",
11
+ type: "local",
12
+ branchType: "main",
13
+ isCurrent: true,
14
+ },
15
+ {
16
+ name: "feature/test",
17
+ type: "local",
18
+ branchType: "feature",
19
+ isCurrent: false,
20
+ },
21
+ {
22
+ name: "origin/main",
23
+ type: "remote",
24
+ branchType: "main",
25
+ isCurrent: false,
26
+ },
27
+ ];
28
+
29
+ const stats = calculateStatistics(branches);
30
+
31
+ expect(stats.localCount).toBe(2);
32
+ expect(stats.remoteCount).toBe(1);
33
+ expect(stats.worktreeCount).toBe(0);
34
+ expect(stats.changesCount).toBe(0);
35
+ expect(stats.lastUpdated).toBeInstanceOf(Date);
36
+ });
37
+
38
+ it("should count worktrees", () => {
39
+ const branches: BranchInfo[] = [
40
+ {
41
+ name: "main",
42
+ type: "local",
43
+ branchType: "main",
44
+ isCurrent: true,
45
+ worktree: {
46
+ path: "/path/to/main",
47
+ locked: false,
48
+ prunable: false,
49
+ },
50
+ },
51
+ {
52
+ name: "feature/test",
53
+ type: "local",
54
+ branchType: "feature",
55
+ isCurrent: false,
56
+ worktree: {
57
+ path: "/path/to/feature",
58
+ locked: false,
59
+ prunable: false,
60
+ },
61
+ },
62
+ {
63
+ name: "feature/no-worktree",
64
+ type: "local",
65
+ branchType: "feature",
66
+ isCurrent: false,
67
+ },
68
+ ];
69
+
70
+ const stats = calculateStatistics(branches);
71
+
72
+ expect(stats.localCount).toBe(3);
73
+ expect(stats.worktreeCount).toBe(2);
74
+ });
75
+
76
+ it("should count branches with changes", () => {
77
+ const branches: BranchInfo[] = [
78
+ {
79
+ name: "main",
80
+ type: "local",
81
+ branchType: "main",
82
+ isCurrent: true,
83
+ worktree: {
84
+ path: "/path/to/main",
85
+ locked: false,
86
+ prunable: false,
87
+ },
88
+ },
89
+ {
90
+ name: "feature/test",
91
+ type: "local",
92
+ branchType: "feature",
93
+ isCurrent: false,
94
+ worktree: {
95
+ path: "/path/to/feature",
96
+ locked: false,
97
+ prunable: false,
98
+ },
99
+ },
100
+ ];
101
+
102
+ const changedBranches = new Set(["main", "feature/test"]);
103
+ const stats = calculateStatistics(branches, changedBranches);
104
+
105
+ expect(stats.changesCount).toBe(2);
106
+ });
107
+
108
+ it("should handle empty branch array", () => {
109
+ const stats = calculateStatistics([]);
110
+
111
+ expect(stats.localCount).toBe(0);
112
+ expect(stats.remoteCount).toBe(0);
113
+ expect(stats.worktreeCount).toBe(0);
114
+ expect(stats.changesCount).toBe(0);
115
+ expect(stats.lastUpdated).toBeInstanceOf(Date);
116
+ });
117
+
118
+ it("should handle only remote branches", () => {
119
+ const branches: BranchInfo[] = [
120
+ {
121
+ name: "origin/main",
122
+ type: "remote",
123
+ branchType: "main",
124
+ isCurrent: false,
125
+ },
126
+ {
127
+ name: "origin/develop",
128
+ type: "remote",
129
+ branchType: "develop",
130
+ isCurrent: false,
131
+ },
132
+ ];
133
+
134
+ const stats = calculateStatistics(branches);
135
+
136
+ expect(stats.localCount).toBe(0);
137
+ expect(stats.remoteCount).toBe(2);
138
+ expect(stats.worktreeCount).toBe(0);
139
+ });
140
+
141
+ it("should handle mixed branches with worktrees and changes", () => {
142
+ const branches: BranchInfo[] = [
143
+ {
144
+ name: "main",
145
+ type: "local",
146
+ branchType: "main",
147
+ isCurrent: true,
148
+ worktree: {
149
+ path: "/path/to/main",
150
+ locked: false,
151
+ prunable: false,
152
+ },
153
+ },
154
+ {
155
+ name: "feature/test",
156
+ type: "local",
157
+ branchType: "feature",
158
+ isCurrent: false,
159
+ worktree: {
160
+ path: "/path/to/feature",
161
+ locked: false,
162
+ prunable: false,
163
+ },
164
+ },
165
+ {
166
+ name: "feature/no-worktree",
167
+ type: "local",
168
+ branchType: "feature",
169
+ isCurrent: false,
170
+ },
171
+ {
172
+ name: "origin/main",
173
+ type: "remote",
174
+ branchType: "main",
175
+ isCurrent: false,
176
+ },
177
+ {
178
+ name: "origin/develop",
179
+ type: "remote",
180
+ branchType: "develop",
181
+ isCurrent: false,
182
+ },
183
+ ];
184
+
185
+ const changedBranches = new Set(["main", "feature/test"]);
186
+ const stats = calculateStatistics(branches, changedBranches);
187
+
188
+ expect(stats.localCount).toBe(3);
189
+ expect(stats.remoteCount).toBe(2);
190
+ expect(stats.worktreeCount).toBe(2);
191
+ expect(stats.changesCount).toBe(2);
192
+ });
193
+
194
+ it("should only count changes for local branches with worktrees", () => {
195
+ const branches: BranchInfo[] = [
196
+ {
197
+ name: "main",
198
+ type: "local",
199
+ branchType: "main",
200
+ isCurrent: true,
201
+ worktree: {
202
+ path: "/path/to/main",
203
+ locked: false,
204
+ prunable: false,
205
+ },
206
+ },
207
+ {
208
+ name: "feature/no-worktree",
209
+ type: "local",
210
+ branchType: "feature",
211
+ isCurrent: false,
212
+ },
213
+ {
214
+ name: "origin/main",
215
+ type: "remote",
216
+ branchType: "main",
217
+ isCurrent: false,
218
+ },
219
+ ];
220
+
221
+ // All branches in changed set, but only worktree branches should count
222
+ const changedBranches = new Set([
223
+ "main",
224
+ "feature/no-worktree",
225
+ "origin/main",
226
+ ]);
227
+ const stats = calculateStatistics(branches, changedBranches);
228
+
229
+ expect(stats.changesCount).toBe(1); // Only main has worktree
230
+ });
231
+
232
+ it("should generate recent timestamp", () => {
233
+ const before = new Date();
234
+ const stats = calculateStatistics([]);
235
+ const after = new Date();
236
+
237
+ expect(stats.lastUpdated.getTime()).toBeGreaterThanOrEqual(
238
+ before.getTime(),
239
+ );
240
+ expect(stats.lastUpdated.getTime()).toBeLessThanOrEqual(after.getTime());
241
+ });
242
+ });
243
+ });