@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.
- package/README.ja.md +323 -0
- package/README.md +347 -0
- package/bin/gwt.js +5 -0
- package/package.json +125 -0
- package/src/claude-history.ts +717 -0
- package/src/claude.ts +292 -0
- package/src/cli/ui/__tests__/SKIPPED_TESTS.md +119 -0
- package/src/cli/ui/__tests__/acceptance/branchList.acceptance.test.tsx.skip +239 -0
- package/src/cli/ui/__tests__/acceptance/navigation.acceptance.test.tsx +214 -0
- package/src/cli/ui/__tests__/acceptance/realtimeUpdate.acceptance.test.tsx.skip +219 -0
- package/src/cli/ui/__tests__/components/App.protected-branch.test.tsx +183 -0
- package/src/cli/ui/__tests__/components/App.shortcuts.test.tsx +313 -0
- package/src/cli/ui/__tests__/components/App.test.tsx +270 -0
- package/src/cli/ui/__tests__/components/common/Confirm.test.tsx +66 -0
- package/src/cli/ui/__tests__/components/common/ErrorBoundary.test.tsx +103 -0
- package/src/cli/ui/__tests__/components/common/Input.test.tsx +92 -0
- package/src/cli/ui/__tests__/components/common/LoadingIndicator.test.tsx +127 -0
- package/src/cli/ui/__tests__/components/common/Select.memo.test.tsx +264 -0
- package/src/cli/ui/__tests__/components/common/Select.test.tsx +246 -0
- package/src/cli/ui/__tests__/components/parts/Footer.test.tsx +62 -0
- package/src/cli/ui/__tests__/components/parts/Header.test.tsx +54 -0
- package/src/cli/ui/__tests__/components/parts/ScrollableList.test.tsx +68 -0
- package/src/cli/ui/__tests__/components/parts/Stats.test.tsx +135 -0
- package/src/cli/ui/__tests__/components/screens/AIToolSelectorScreen.test.tsx +153 -0
- package/src/cli/ui/__tests__/components/screens/BranchCreatorScreen.test.tsx +215 -0
- package/src/cli/ui/__tests__/components/screens/BranchListScreen.test.tsx +293 -0
- package/src/cli/ui/__tests__/components/screens/ExecutionModeSelectorScreen.test.tsx +161 -0
- package/src/cli/ui/__tests__/components/screens/PRCleanupScreen.test.tsx +215 -0
- package/src/cli/ui/__tests__/components/screens/SessionSelectorScreen.test.tsx +99 -0
- package/src/cli/ui/__tests__/components/screens/WorktreeManagerScreen.test.tsx +127 -0
- package/src/cli/ui/__tests__/hooks/useGitData.test.ts.skip +228 -0
- package/src/cli/ui/__tests__/hooks/useScreenState.test.ts +146 -0
- package/src/cli/ui/__tests__/hooks/useTerminalSize.test.ts +98 -0
- package/src/cli/ui/__tests__/integration/branchList.test.tsx.skip +253 -0
- package/src/cli/ui/__tests__/integration/edgeCases.test.tsx +306 -0
- package/src/cli/ui/__tests__/integration/navigation.test.tsx +405 -0
- package/src/cli/ui/__tests__/integration/realtimeUpdate.test.tsx +505 -0
- package/src/cli/ui/__tests__/integration/realtimeUpdate.test.tsx.skip +216 -0
- package/src/cli/ui/__tests__/performance/branchList.performance.test.tsx +180 -0
- package/src/cli/ui/__tests__/performance/useMemoOptimization.test.tsx +237 -0
- package/src/cli/ui/__tests__/utils/branchFormatter.test.ts +775 -0
- package/src/cli/ui/__tests__/utils/statisticsCalculator.test.ts +243 -0
- package/src/cli/ui/components/App.tsx +793 -0
- package/src/cli/ui/components/common/Confirm.tsx +40 -0
- package/src/cli/ui/components/common/ErrorBoundary.tsx +57 -0
- package/src/cli/ui/components/common/Input.tsx +36 -0
- package/src/cli/ui/components/common/LoadingIndicator.tsx +95 -0
- package/src/cli/ui/components/common/Select.tsx +216 -0
- package/src/cli/ui/components/parts/Footer.tsx +41 -0
- package/src/cli/ui/components/parts/Header.test.tsx +85 -0
- package/src/cli/ui/components/parts/Header.tsx +63 -0
- package/src/cli/ui/components/parts/MergeStatusList.tsx +75 -0
- package/src/cli/ui/components/parts/ProgressBar.tsx +73 -0
- package/src/cli/ui/components/parts/ScrollableList.tsx +24 -0
- package/src/cli/ui/components/parts/Stats.tsx +67 -0
- package/src/cli/ui/components/screens/AIToolSelectorScreen.tsx +116 -0
- package/src/cli/ui/components/screens/BatchMergeProgressScreen.tsx +70 -0
- package/src/cli/ui/components/screens/BatchMergeResultScreen.tsx +104 -0
- package/src/cli/ui/components/screens/BranchCreatorScreen.tsx +213 -0
- package/src/cli/ui/components/screens/BranchListScreen.tsx +299 -0
- package/src/cli/ui/components/screens/ExecutionModeSelectorScreen.tsx +149 -0
- package/src/cli/ui/components/screens/PRCleanupScreen.tsx +167 -0
- package/src/cli/ui/components/screens/SessionSelectorScreen.tsx +100 -0
- package/src/cli/ui/components/screens/WorktreeManagerScreen.tsx +117 -0
- package/src/cli/ui/hooks/useBatchMerge.ts +96 -0
- package/src/cli/ui/hooks/useGitData.ts +157 -0
- package/src/cli/ui/hooks/useScreenState.ts +44 -0
- package/src/cli/ui/hooks/useTerminalSize.ts +33 -0
- package/src/cli/ui/screens/BranchActionSelectorScreen.tsx +102 -0
- package/src/cli/ui/screens/__tests__/BranchActionSelectorScreen.test.tsx +151 -0
- package/src/cli/ui/types.ts +295 -0
- package/src/cli/ui/utils/baseBranch.ts +34 -0
- package/src/cli/ui/utils/branchFormatter.ts +222 -0
- package/src/cli/ui/utils/statisticsCalculator.ts +44 -0
- package/src/codex.ts +139 -0
- package/src/config/builtin-tools.ts +44 -0
- package/src/config/constants.ts +100 -0
- package/src/config/env-history.ts +45 -0
- package/src/config/index.ts +204 -0
- package/src/config/tools.ts +293 -0
- package/src/git.ts +1102 -0
- package/src/github.ts +158 -0
- package/src/index.test.ts +87 -0
- package/src/index.ts +684 -0
- package/src/index.ts.backup +1543 -0
- package/src/launcher.ts +142 -0
- package/src/repositories/git.repository.ts +129 -0
- package/src/repositories/github.repository.ts +83 -0
- package/src/repositories/worktree.repository.ts +69 -0
- package/src/services/BatchMergeService.ts +251 -0
- package/src/services/WorktreeOrchestrator.ts +115 -0
- package/src/services/__tests__/BatchMergeService.test.ts +518 -0
- package/src/services/__tests__/WorktreeOrchestrator.test.ts +258 -0
- package/src/services/dependency-installer.ts +199 -0
- package/src/services/git.service.ts +113 -0
- package/src/services/github.service.ts +61 -0
- package/src/services/worktree.service.ts +66 -0
- package/src/types/api.ts +241 -0
- package/src/types/tools.ts +235 -0
- package/src/utils/spinner.ts +54 -0
- package/src/utils/terminal.ts +272 -0
- package/src/utils.test.ts +43 -0
- package/src/utils.ts +60 -0
- package/src/web/client/index.html +12 -0
- package/src/web/client/src/components/BranchGraph.tsx +231 -0
- package/src/web/client/src/components/EnvEditor.tsx +145 -0
- package/src/web/client/src/components/Terminal.tsx +137 -0
- package/src/web/client/src/hooks/useBranches.ts +41 -0
- package/src/web/client/src/hooks/useConfig.ts +31 -0
- package/src/web/client/src/hooks/useSessions.ts +59 -0
- package/src/web/client/src/hooks/useWorktrees.ts +47 -0
- package/src/web/client/src/index.css +834 -0
- package/src/web/client/src/lib/api.ts +184 -0
- package/src/web/client/src/lib/websocket.ts +174 -0
- package/src/web/client/src/main.tsx +29 -0
- package/src/web/client/src/pages/BranchDetailPage.tsx +847 -0
- package/src/web/client/src/pages/BranchListPage.tsx +264 -0
- package/src/web/client/src/pages/ConfigManagementPage.tsx +203 -0
- package/src/web/client/src/router.tsx +27 -0
- package/src/web/client/vite.config.ts +21 -0
- package/src/web/server/env/importer.ts +54 -0
- package/src/web/server/index.ts +74 -0
- package/src/web/server/pty/manager.ts +189 -0
- package/src/web/server/routes/branches.ts +126 -0
- package/src/web/server/routes/config.ts +220 -0
- package/src/web/server/routes/index.ts +37 -0
- package/src/web/server/routes/sessions.ts +130 -0
- package/src/web/server/routes/worktrees.ts +108 -0
- package/src/web/server/services/branches.ts +368 -0
- package/src/web/server/services/worktrees.ts +85 -0
- package/src/web/server/websocket/handler.ts +180 -0
- 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
|
+
});
|