@vibescope/mcp-server 0.0.1 → 0.2.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 (173) hide show
  1. package/README.md +113 -98
  2. package/dist/api-client.d.ts +1169 -0
  3. package/dist/api-client.js +713 -0
  4. package/dist/cli.d.ts +1 -6
  5. package/dist/cli.js +39 -240
  6. package/dist/config/tool-categories.d.ts +31 -0
  7. package/dist/config/tool-categories.js +253 -0
  8. package/dist/handlers/blockers.js +57 -58
  9. package/dist/handlers/bodies-of-work.d.ts +2 -0
  10. package/dist/handlers/bodies-of-work.js +108 -477
  11. package/dist/handlers/cost.d.ts +1 -0
  12. package/dist/handlers/cost.js +35 -113
  13. package/dist/handlers/decisions.d.ts +2 -0
  14. package/dist/handlers/decisions.js +28 -27
  15. package/dist/handlers/deployment.js +113 -828
  16. package/dist/handlers/discovery.d.ts +3 -0
  17. package/dist/handlers/discovery.js +26 -627
  18. package/dist/handlers/fallback.d.ts +2 -0
  19. package/dist/handlers/fallback.js +56 -142
  20. package/dist/handlers/findings.d.ts +8 -1
  21. package/dist/handlers/findings.js +65 -68
  22. package/dist/handlers/git-issues.d.ts +9 -13
  23. package/dist/handlers/git-issues.js +80 -225
  24. package/dist/handlers/ideas.d.ts +3 -0
  25. package/dist/handlers/ideas.js +53 -134
  26. package/dist/handlers/index.d.ts +2 -0
  27. package/dist/handlers/index.js +6 -0
  28. package/dist/handlers/milestones.d.ts +2 -0
  29. package/dist/handlers/milestones.js +51 -98
  30. package/dist/handlers/organizations.js +79 -275
  31. package/dist/handlers/progress.d.ts +2 -0
  32. package/dist/handlers/progress.js +25 -123
  33. package/dist/handlers/project.js +42 -221
  34. package/dist/handlers/requests.d.ts +2 -0
  35. package/dist/handlers/requests.js +23 -83
  36. package/dist/handlers/session.js +119 -590
  37. package/dist/handlers/sprints.d.ts +32 -0
  38. package/dist/handlers/sprints.js +275 -0
  39. package/dist/handlers/tasks.d.ts +7 -10
  40. package/dist/handlers/tasks.js +245 -894
  41. package/dist/handlers/tool-docs.d.ts +9 -0
  42. package/dist/handlers/tool-docs.js +904 -0
  43. package/dist/handlers/types.d.ts +11 -3
  44. package/dist/handlers/validation.d.ts +1 -1
  45. package/dist/handlers/validation.js +38 -153
  46. package/dist/index.js +493 -162
  47. package/dist/knowledge.js +106 -9
  48. package/dist/tools.js +34 -4
  49. package/dist/validators.d.ts +21 -0
  50. package/dist/validators.js +91 -0
  51. package/package.json +2 -3
  52. package/src/api-client.ts +1822 -0
  53. package/src/cli.test.ts +128 -302
  54. package/src/cli.ts +41 -285
  55. package/src/handlers/__test-setup__.ts +215 -0
  56. package/src/handlers/__test-utils__.ts +4 -134
  57. package/src/handlers/blockers.test.ts +114 -124
  58. package/src/handlers/blockers.ts +68 -70
  59. package/src/handlers/bodies-of-work.test.ts +236 -831
  60. package/src/handlers/bodies-of-work.ts +210 -525
  61. package/src/handlers/cost.test.ts +149 -113
  62. package/src/handlers/cost.ts +44 -132
  63. package/src/handlers/decisions.test.ts +111 -209
  64. package/src/handlers/decisions.ts +35 -27
  65. package/src/handlers/deployment.test.ts +193 -239
  66. package/src/handlers/deployment.ts +143 -896
  67. package/src/handlers/discovery.test.ts +20 -67
  68. package/src/handlers/discovery.ts +29 -714
  69. package/src/handlers/fallback.test.ts +206 -361
  70. package/src/handlers/fallback.ts +81 -156
  71. package/src/handlers/findings.test.ts +229 -320
  72. package/src/handlers/findings.ts +76 -64
  73. package/src/handlers/git-issues.test.ts +623 -0
  74. package/src/handlers/git-issues.ts +174 -0
  75. package/src/handlers/ideas.test.ts +229 -343
  76. package/src/handlers/ideas.ts +69 -143
  77. package/src/handlers/index.ts +6 -0
  78. package/src/handlers/milestones.test.ts +167 -281
  79. package/src/handlers/milestones.ts +54 -93
  80. package/src/handlers/organizations.test.ts +275 -467
  81. package/src/handlers/organizations.ts +84 -294
  82. package/src/handlers/progress.test.ts +112 -218
  83. package/src/handlers/progress.ts +29 -142
  84. package/src/handlers/project.test.ts +203 -226
  85. package/src/handlers/project.ts +48 -238
  86. package/src/handlers/requests.test.ts +74 -342
  87. package/src/handlers/requests.ts +25 -83
  88. package/src/handlers/session.test.ts +276 -206
  89. package/src/handlers/session.ts +136 -662
  90. package/src/handlers/sprints.test.ts +711 -0
  91. package/src/handlers/sprints.ts +510 -0
  92. package/src/handlers/tasks.test.ts +669 -353
  93. package/src/handlers/tasks.ts +263 -1015
  94. package/src/handlers/tool-docs.ts +1024 -0
  95. package/src/handlers/types.ts +12 -4
  96. package/src/handlers/validation.test.ts +237 -568
  97. package/src/handlers/validation.ts +43 -167
  98. package/src/index.ts +493 -186
  99. package/src/tools.ts +2532 -0
  100. package/src/validators.test.ts +223 -223
  101. package/src/validators.ts +127 -0
  102. package/tsconfig.json +1 -1
  103. package/vitest.config.ts +14 -13
  104. package/dist/cli.test.d.ts +0 -1
  105. package/dist/cli.test.js +0 -367
  106. package/dist/handlers/__test-utils__.d.ts +0 -72
  107. package/dist/handlers/__test-utils__.js +0 -176
  108. package/dist/handlers/checkouts.d.ts +0 -37
  109. package/dist/handlers/checkouts.js +0 -377
  110. package/dist/handlers/knowledge-query.d.ts +0 -22
  111. package/dist/handlers/knowledge-query.js +0 -253
  112. package/dist/handlers/knowledge.d.ts +0 -12
  113. package/dist/handlers/knowledge.js +0 -108
  114. package/dist/handlers/roles.d.ts +0 -30
  115. package/dist/handlers/roles.js +0 -281
  116. package/dist/handlers/tasks.test.d.ts +0 -1
  117. package/dist/handlers/tasks.test.js +0 -431
  118. package/dist/utils.test.d.ts +0 -1
  119. package/dist/utils.test.js +0 -532
  120. package/dist/validators.test.d.ts +0 -1
  121. package/dist/validators.test.js +0 -176
  122. package/src/knowledge.ts +0 -132
  123. package/src/tmpclaude-0078-cwd +0 -1
  124. package/src/tmpclaude-0ee1-cwd +0 -1
  125. package/src/tmpclaude-2dd5-cwd +0 -1
  126. package/src/tmpclaude-344c-cwd +0 -1
  127. package/src/tmpclaude-3860-cwd +0 -1
  128. package/src/tmpclaude-4b63-cwd +0 -1
  129. package/src/tmpclaude-5c73-cwd +0 -1
  130. package/src/tmpclaude-5ee3-cwd +0 -1
  131. package/src/tmpclaude-6795-cwd +0 -1
  132. package/src/tmpclaude-709e-cwd +0 -1
  133. package/src/tmpclaude-9839-cwd +0 -1
  134. package/src/tmpclaude-d829-cwd +0 -1
  135. package/src/tmpclaude-e072-cwd +0 -1
  136. package/src/tmpclaude-f6ee-cwd +0 -1
  137. package/tmpclaude-0439-cwd +0 -1
  138. package/tmpclaude-132f-cwd +0 -1
  139. package/tmpclaude-15bb-cwd +0 -1
  140. package/tmpclaude-165a-cwd +0 -1
  141. package/tmpclaude-1ba9-cwd +0 -1
  142. package/tmpclaude-21a3-cwd +0 -1
  143. package/tmpclaude-2a38-cwd +0 -1
  144. package/tmpclaude-2adf-cwd +0 -1
  145. package/tmpclaude-2f56-cwd +0 -1
  146. package/tmpclaude-3626-cwd +0 -1
  147. package/tmpclaude-3727-cwd +0 -1
  148. package/tmpclaude-40bc-cwd +0 -1
  149. package/tmpclaude-436f-cwd +0 -1
  150. package/tmpclaude-4783-cwd +0 -1
  151. package/tmpclaude-4b6d-cwd +0 -1
  152. package/tmpclaude-4ba4-cwd +0 -1
  153. package/tmpclaude-51e6-cwd +0 -1
  154. package/tmpclaude-5ecf-cwd +0 -1
  155. package/tmpclaude-6f97-cwd +0 -1
  156. package/tmpclaude-7fb2-cwd +0 -1
  157. package/tmpclaude-825c-cwd +0 -1
  158. package/tmpclaude-8baf-cwd +0 -1
  159. package/tmpclaude-8d9f-cwd +0 -1
  160. package/tmpclaude-975c-cwd +0 -1
  161. package/tmpclaude-9983-cwd +0 -1
  162. package/tmpclaude-a045-cwd +0 -1
  163. package/tmpclaude-ac4a-cwd +0 -1
  164. package/tmpclaude-b593-cwd +0 -1
  165. package/tmpclaude-b891-cwd +0 -1
  166. package/tmpclaude-c032-cwd +0 -1
  167. package/tmpclaude-cf43-cwd +0 -1
  168. package/tmpclaude-d040-cwd +0 -1
  169. package/tmpclaude-dcdd-cwd +0 -1
  170. package/tmpclaude-dcee-cwd +0 -1
  171. package/tmpclaude-e16b-cwd +0 -1
  172. package/tmpclaude-ecd2-cwd +0 -1
  173. package/tmpclaude-f48d-cwd +0 -1
@@ -1,532 +0,0 @@
1
- import { describe, it, expect, beforeEach, vi, afterEach } from 'vitest';
2
- import { AGENT_PERSONAS, FALLBACK_ACTIVITIES, getRandomFallbackActivity, selectPersona, RateLimiter, canValidateTask, isValidStatusTransition, isValidDeploymentStatusTransition, extractProjectNameFromGitUrl, normalizeGitUrl, } from './utils.js';
3
- // ============================================================================
4
- // Agent Personas Tests
5
- // ============================================================================
6
- describe('AGENT_PERSONAS', () => {
7
- it('should have unique personas', () => {
8
- expect(AGENT_PERSONAS.length).toBeGreaterThanOrEqual(22);
9
- const uniquePersonas = new Set(AGENT_PERSONAS);
10
- expect(uniquePersonas.size).toBe(AGENT_PERSONAS.length);
11
- });
12
- it('should contain expected personas', () => {
13
- expect(AGENT_PERSONAS).toContain('Atlas');
14
- expect(AGENT_PERSONAS).toContain('Bolt');
15
- expect(AGENT_PERSONAS).toContain('Cipher');
16
- expect(AGENT_PERSONAS).toContain('Zen');
17
- });
18
- it('should have short memorable names', () => {
19
- // All personas should be reasonably short for dashboard display
20
- for (const persona of AGENT_PERSONAS) {
21
- expect(persona.length).toBeLessThanOrEqual(6);
22
- }
23
- });
24
- });
25
- // ============================================================================
26
- // Fallback Activities Tests
27
- // ============================================================================
28
- describe('FALLBACK_ACTIVITIES', () => {
29
- it('should have 11 activities', () => {
30
- expect(FALLBACK_ACTIVITIES).toHaveLength(11);
31
- });
32
- it('should have required fields on each activity', () => {
33
- for (const activity of FALLBACK_ACTIVITIES) {
34
- expect(activity).toHaveProperty('activity');
35
- expect(activity).toHaveProperty('title');
36
- expect(activity).toHaveProperty('description');
37
- expect(activity).toHaveProperty('prompt');
38
- expect(typeof activity.activity).toBe('string');
39
- expect(typeof activity.title).toBe('string');
40
- expect(typeof activity.description).toBe('string');
41
- expect(typeof activity.prompt).toBe('string');
42
- }
43
- });
44
- it('should have unique activity identifiers', () => {
45
- const activityIds = FALLBACK_ACTIVITIES.map((a) => a.activity);
46
- const uniqueIds = new Set(activityIds);
47
- expect(uniqueIds.size).toBe(FALLBACK_ACTIVITIES.length);
48
- });
49
- it('should include critical activities', () => {
50
- const activityIds = FALLBACK_ACTIVITIES.map((a) => a.activity);
51
- expect(activityIds).toContain('feature_ideation');
52
- expect(activityIds).toContain('code_review');
53
- expect(activityIds).toContain('security_review');
54
- expect(activityIds).toContain('test_coverage');
55
- expect(activityIds).toContain('validate_completed_tasks');
56
- });
57
- });
58
- describe('getRandomFallbackActivity', () => {
59
- it('should return a valid fallback activity', () => {
60
- const activity = getRandomFallbackActivity();
61
- expect(activity).toHaveProperty('activity');
62
- expect(activity).toHaveProperty('title');
63
- expect(activity).toHaveProperty('description');
64
- expect(activity).toHaveProperty('prompt');
65
- });
66
- it('should return activity from the pool', () => {
67
- const activity = getRandomFallbackActivity();
68
- const activityIds = FALLBACK_ACTIVITIES.map((a) => a.activity);
69
- expect(activityIds).toContain(activity.activity);
70
- });
71
- });
72
- // ============================================================================
73
- // Persona Selection Tests
74
- // ============================================================================
75
- describe('selectPersona', () => {
76
- it('should return a random persona when none are in use', () => {
77
- const usedPersonas = new Set();
78
- const instanceId = 'abc123-def456';
79
- const selected = selectPersona(usedPersonas, instanceId);
80
- expect(AGENT_PERSONAS).toContain(selected);
81
- });
82
- it('should skip personas that are in use', () => {
83
- const usedPersonas = new Set([AGENT_PERSONAS[0], AGENT_PERSONAS[1]]);
84
- const instanceId = 'abc123-def456';
85
- const selected = selectPersona(usedPersonas, instanceId);
86
- expect(usedPersonas.has(selected)).toBe(false);
87
- expect(AGENT_PERSONAS).toContain(selected);
88
- });
89
- it('should return fallback name when all personas are in use', () => {
90
- const usedPersonas = new Set(AGENT_PERSONAS);
91
- const instanceId = 'abc123-def456';
92
- const selected = selectPersona(usedPersonas, instanceId);
93
- expect(selected).toBe('Agent-abc123');
94
- });
95
- it('should handle partial instance ID', () => {
96
- const usedPersonas = new Set(AGENT_PERSONAS);
97
- const instanceId = 'xyz';
98
- const selected = selectPersona(usedPersonas, instanceId);
99
- expect(selected).toBe('Agent-xyz');
100
- });
101
- it('should be case-sensitive for used personas', () => {
102
- const firstPersona = AGENT_PERSONAS[0];
103
- const usedPersonas = new Set([firstPersona.toLowerCase(), firstPersona.toUpperCase()]); // Different case
104
- const instanceId = 'abc123-def456';
105
- const selected = selectPersona(usedPersonas, instanceId);
106
- // Original case versions are still available (case-sensitive match)
107
- expect(AGENT_PERSONAS).toContain(selected);
108
- expect(usedPersonas.has(selected)).toBe(false);
109
- });
110
- });
111
- // ============================================================================
112
- // Rate Limiter Tests
113
- // ============================================================================
114
- describe('RateLimiter', () => {
115
- let rateLimiter;
116
- beforeEach(() => {
117
- vi.useFakeTimers();
118
- rateLimiter = new RateLimiter(5, 1000); // 5 requests per second for testing
119
- });
120
- afterEach(() => {
121
- vi.useRealTimers();
122
- });
123
- describe('constructor', () => {
124
- it('should use default values when none provided', () => {
125
- const defaultLimiter = new RateLimiter();
126
- const result = defaultLimiter.check('test');
127
- expect(result.remaining).toBe(59); // 60 - 1
128
- });
129
- it('should use custom values', () => {
130
- const customLimiter = new RateLimiter(10, 5000);
131
- const result = customLimiter.check('test');
132
- expect(result.remaining).toBe(9); // 10 - 1
133
- expect(result.resetIn).toBe(5000);
134
- });
135
- });
136
- describe('check', () => {
137
- it('should allow first request', () => {
138
- const result = rateLimiter.check('user-1');
139
- expect(result.allowed).toBe(true);
140
- expect(result.remaining).toBe(4);
141
- expect(result.resetIn).toBe(1000);
142
- });
143
- it('should decrement remaining count on subsequent requests', () => {
144
- rateLimiter.check('user-1');
145
- const result = rateLimiter.check('user-1');
146
- expect(result.allowed).toBe(true);
147
- expect(result.remaining).toBe(3);
148
- });
149
- it('should block requests when limit exceeded', () => {
150
- // Use up all requests
151
- for (let i = 0; i < 5; i++) {
152
- rateLimiter.check('user-1');
153
- }
154
- const result = rateLimiter.check('user-1');
155
- expect(result.allowed).toBe(false);
156
- expect(result.remaining).toBe(0);
157
- });
158
- it('should track different keys separately', () => {
159
- // Use up user-1's limit
160
- for (let i = 0; i < 5; i++) {
161
- rateLimiter.check('user-1');
162
- }
163
- // user-2 should still be allowed
164
- const result = rateLimiter.check('user-2');
165
- expect(result.allowed).toBe(true);
166
- expect(result.remaining).toBe(4);
167
- });
168
- it('should reset after window expires', () => {
169
- // Use up all requests
170
- for (let i = 0; i < 5; i++) {
171
- rateLimiter.check('user-1');
172
- }
173
- // Blocked
174
- expect(rateLimiter.check('user-1').allowed).toBe(false);
175
- // Advance time past window
176
- vi.advanceTimersByTime(1001);
177
- // Should be allowed again
178
- const result = rateLimiter.check('user-1');
179
- expect(result.allowed).toBe(true);
180
- expect(result.remaining).toBe(4);
181
- });
182
- it('should report correct resetIn time', () => {
183
- rateLimiter.check('user-1');
184
- // Advance time by 300ms
185
- vi.advanceTimersByTime(300);
186
- const result = rateLimiter.check('user-1');
187
- expect(result.resetIn).toBeLessThanOrEqual(700);
188
- expect(result.resetIn).toBeGreaterThan(0);
189
- });
190
- });
191
- describe('cleanup', () => {
192
- it('should remove expired entries', () => {
193
- rateLimiter.check('user-1');
194
- rateLimiter.check('user-2');
195
- expect(rateLimiter.getRequestCount('user-1')).toBe(1);
196
- expect(rateLimiter.getRequestCount('user-2')).toBe(1);
197
- // Advance past window
198
- vi.advanceTimersByTime(1001);
199
- rateLimiter.cleanup();
200
- expect(rateLimiter.getRequestCount('user-1')).toBeUndefined();
201
- expect(rateLimiter.getRequestCount('user-2')).toBeUndefined();
202
- });
203
- it('should keep non-expired entries', () => {
204
- rateLimiter.check('user-1');
205
- // Advance but not past window
206
- vi.advanceTimersByTime(500);
207
- rateLimiter.cleanup();
208
- expect(rateLimiter.getRequestCount('user-1')).toBe(1);
209
- });
210
- });
211
- describe('getRequestCount', () => {
212
- it('should return undefined for unknown key', () => {
213
- expect(rateLimiter.getRequestCount('unknown')).toBeUndefined();
214
- });
215
- it('should return correct count', () => {
216
- rateLimiter.check('user-1');
217
- rateLimiter.check('user-1');
218
- rateLimiter.check('user-1');
219
- expect(rateLimiter.getRequestCount('user-1')).toBe(3);
220
- });
221
- });
222
- });
223
- // ============================================================================
224
- // Task Validation Tests
225
- // ============================================================================
226
- describe('canValidateTask', () => {
227
- it('should allow validation of completed tasks', () => {
228
- const task = {
229
- status: 'completed',
230
- validated_at: null,
231
- working_agent_session_id: null,
232
- };
233
- const result = canValidateTask(task, 'session-123');
234
- expect(result.canValidate).toBe(true);
235
- expect(result.reason).toBeUndefined();
236
- });
237
- it('should reject non-completed tasks', () => {
238
- const statuses = ['pending', 'in_progress', 'cancelled'];
239
- for (const status of statuses) {
240
- const task = {
241
- status,
242
- validated_at: null,
243
- working_agent_session_id: null,
244
- };
245
- const result = canValidateTask(task, 'session-123');
246
- expect(result.canValidate).toBe(false);
247
- expect(result.reason).toBe('Can only validate completed tasks');
248
- }
249
- });
250
- it('should reject already validated tasks', () => {
251
- const task = {
252
- status: 'completed',
253
- validated_at: '2026-01-12T00:00:00Z',
254
- working_agent_session_id: null,
255
- };
256
- const result = canValidateTask(task, 'session-123');
257
- expect(result.canValidate).toBe(false);
258
- expect(result.reason).toBe('Task has already been validated');
259
- });
260
- it('should handle null validator session', () => {
261
- const task = {
262
- status: 'completed',
263
- validated_at: null,
264
- working_agent_session_id: null,
265
- };
266
- const result = canValidateTask(task, null);
267
- expect(result.canValidate).toBe(true);
268
- });
269
- });
270
- // ============================================================================
271
- // Status Transition Tests
272
- // ============================================================================
273
- describe('isValidStatusTransition', () => {
274
- describe('from pending', () => {
275
- it('should allow transition to in_progress', () => {
276
- const result = isValidStatusTransition('pending', 'in_progress');
277
- expect(result.isValid).toBe(true);
278
- });
279
- it('should allow transition to cancelled', () => {
280
- const result = isValidStatusTransition('pending', 'cancelled');
281
- expect(result.isValid).toBe(true);
282
- });
283
- it('should reject transition to completed', () => {
284
- const result = isValidStatusTransition('pending', 'completed');
285
- expect(result.isValid).toBe(false);
286
- expect(result.reason).toContain('Cannot transition');
287
- });
288
- });
289
- describe('from in_progress', () => {
290
- it('should allow transition to completed', () => {
291
- const result = isValidStatusTransition('in_progress', 'completed');
292
- expect(result.isValid).toBe(true);
293
- });
294
- it('should allow transition to pending', () => {
295
- const result = isValidStatusTransition('in_progress', 'pending');
296
- expect(result.isValid).toBe(true);
297
- });
298
- it('should allow transition to cancelled', () => {
299
- const result = isValidStatusTransition('in_progress', 'cancelled');
300
- expect(result.isValid).toBe(true);
301
- });
302
- });
303
- describe('from completed', () => {
304
- it('should allow transition to in_progress (validation failure)', () => {
305
- const result = isValidStatusTransition('completed', 'in_progress');
306
- expect(result.isValid).toBe(true);
307
- });
308
- it('should reject transition to pending', () => {
309
- const result = isValidStatusTransition('completed', 'pending');
310
- expect(result.isValid).toBe(false);
311
- });
312
- it('should reject transition to cancelled', () => {
313
- const result = isValidStatusTransition('completed', 'cancelled');
314
- expect(result.isValid).toBe(false);
315
- });
316
- });
317
- describe('from cancelled', () => {
318
- it('should allow transition to pending (reactivate)', () => {
319
- const result = isValidStatusTransition('cancelled', 'pending');
320
- expect(result.isValid).toBe(true);
321
- });
322
- it('should reject transition to in_progress', () => {
323
- const result = isValidStatusTransition('cancelled', 'in_progress');
324
- expect(result.isValid).toBe(false);
325
- });
326
- it('should reject transition to completed', () => {
327
- const result = isValidStatusTransition('cancelled', 'completed');
328
- expect(result.isValid).toBe(false);
329
- });
330
- });
331
- describe('unknown status', () => {
332
- it('should reject unknown current status', () => {
333
- const result = isValidStatusTransition('unknown', 'pending');
334
- expect(result.isValid).toBe(false);
335
- expect(result.reason).toContain('Unknown current status');
336
- });
337
- });
338
- });
339
- // ============================================================================
340
- // Deployment Status Transition Tests
341
- // ============================================================================
342
- describe('isValidDeploymentStatusTransition', () => {
343
- describe('from pending', () => {
344
- it('should allow pending → validating', () => {
345
- const result = isValidDeploymentStatusTransition('pending', 'validating');
346
- expect(result.isValid).toBe(true);
347
- });
348
- it('should allow pending → failed', () => {
349
- const result = isValidDeploymentStatusTransition('pending', 'failed');
350
- expect(result.isValid).toBe(true);
351
- });
352
- it('should reject pending → ready', () => {
353
- const result = isValidDeploymentStatusTransition('pending', 'ready');
354
- expect(result.isValid).toBe(false);
355
- });
356
- it('should reject pending → deployed', () => {
357
- const result = isValidDeploymentStatusTransition('pending', 'deployed');
358
- expect(result.isValid).toBe(false);
359
- });
360
- });
361
- describe('from validating', () => {
362
- it('should allow validating → ready', () => {
363
- const result = isValidDeploymentStatusTransition('validating', 'ready');
364
- expect(result.isValid).toBe(true);
365
- });
366
- it('should allow validating → failed', () => {
367
- const result = isValidDeploymentStatusTransition('validating', 'failed');
368
- expect(result.isValid).toBe(true);
369
- });
370
- it('should reject validating → deployed', () => {
371
- const result = isValidDeploymentStatusTransition('validating', 'deployed');
372
- expect(result.isValid).toBe(false);
373
- });
374
- });
375
- describe('from ready', () => {
376
- it('should allow ready → deploying', () => {
377
- const result = isValidDeploymentStatusTransition('ready', 'deploying');
378
- expect(result.isValid).toBe(true);
379
- });
380
- it('should allow ready → failed', () => {
381
- const result = isValidDeploymentStatusTransition('ready', 'failed');
382
- expect(result.isValid).toBe(true);
383
- });
384
- it('should reject ready → pending', () => {
385
- const result = isValidDeploymentStatusTransition('ready', 'pending');
386
- expect(result.isValid).toBe(false);
387
- });
388
- });
389
- describe('from deploying', () => {
390
- it('should allow deploying → deployed', () => {
391
- const result = isValidDeploymentStatusTransition('deploying', 'deployed');
392
- expect(result.isValid).toBe(true);
393
- });
394
- it('should allow deploying → failed', () => {
395
- const result = isValidDeploymentStatusTransition('deploying', 'failed');
396
- expect(result.isValid).toBe(true);
397
- });
398
- it('should reject deploying → pending', () => {
399
- const result = isValidDeploymentStatusTransition('deploying', 'pending');
400
- expect(result.isValid).toBe(false);
401
- });
402
- });
403
- describe('terminal states', () => {
404
- it('should reject deployed → any transition', () => {
405
- const result = isValidDeploymentStatusTransition('deployed', 'pending');
406
- expect(result.isValid).toBe(false);
407
- expect(result.reason).toContain('terminal state');
408
- });
409
- it('should reject failed → any transition', () => {
410
- const result = isValidDeploymentStatusTransition('failed', 'pending');
411
- expect(result.isValid).toBe(false);
412
- expect(result.reason).toContain('terminal state');
413
- });
414
- });
415
- describe('unknown status', () => {
416
- it('should reject unknown current status', () => {
417
- const result = isValidDeploymentStatusTransition('unknown', 'pending');
418
- expect(result.isValid).toBe(false);
419
- expect(result.reason).toContain('Unknown current status');
420
- });
421
- });
422
- });
423
- // ============================================================================
424
- // Git URL Parsing Tests
425
- // ============================================================================
426
- describe('extractProjectNameFromGitUrl', () => {
427
- it('should extract project name from https GitHub URL', () => {
428
- expect(extractProjectNameFromGitUrl('https://github.com/user/repo')).toBe('repo');
429
- });
430
- it('should extract project name from https GitHub URL with .git', () => {
431
- expect(extractProjectNameFromGitUrl('https://github.com/user/repo.git')).toBe('repo');
432
- });
433
- it('should extract project name from SSH GitHub URL', () => {
434
- expect(extractProjectNameFromGitUrl('git@github.com:user/repo.git')).toBe('repo');
435
- });
436
- it('should extract project name from SSH URL without .git', () => {
437
- expect(extractProjectNameFromGitUrl('git@github.com:user/repo')).toBe('repo');
438
- });
439
- it('should extract project name from GitLab URL', () => {
440
- expect(extractProjectNameFromGitUrl('https://gitlab.com/user/project-name')).toBe('project-name');
441
- });
442
- it('should extract project name from ssh:// protocol URL', () => {
443
- expect(extractProjectNameFromGitUrl('ssh://git@github.com/user/repo.git')).toBe('repo');
444
- });
445
- it('should handle nested paths (monorepo)', () => {
446
- expect(extractProjectNameFromGitUrl('https://github.com/org/monorepo')).toBe('monorepo');
447
- });
448
- it('should handle dashes and underscores in project names', () => {
449
- expect(extractProjectNameFromGitUrl('https://github.com/user/my-awesome_project')).toBe('my-awesome_project');
450
- });
451
- it('should return default for empty string', () => {
452
- expect(extractProjectNameFromGitUrl('')).toBe('my-project');
453
- });
454
- it('should return default for malformed URL', () => {
455
- expect(extractProjectNameFromGitUrl('not-a-url')).toBe('my-project');
456
- });
457
- it('should handle real Vibescope URL', () => {
458
- expect(extractProjectNameFromGitUrl('https://github.com/Nonatomic/Vibescope')).toBe('Vibescope');
459
- });
460
- });
461
- // ============================================================================
462
- // normalizeGitUrl Tests
463
- // ============================================================================
464
- describe('normalizeGitUrl', () => {
465
- describe('removing .git suffix', () => {
466
- it('should remove .git suffix from HTTPS URL', () => {
467
- expect(normalizeGitUrl('https://github.com/user/repo.git')).toBe('https://github.com/user/repo');
468
- });
469
- it('should not affect URL without .git suffix', () => {
470
- expect(normalizeGitUrl('https://github.com/user/repo')).toBe('https://github.com/user/repo');
471
- });
472
- it('should only remove .git at the end', () => {
473
- expect(normalizeGitUrl('https://github.com/user/dotgit')).toBe('https://github.com/user/dotgit');
474
- });
475
- });
476
- describe('converting SSH to HTTPS for GitHub', () => {
477
- it('should convert SSH URL with .git', () => {
478
- expect(normalizeGitUrl('git@github.com:user/repo.git')).toBe('https://github.com/user/repo');
479
- });
480
- it('should convert SSH URL without .git', () => {
481
- expect(normalizeGitUrl('git@github.com:user/repo')).toBe('https://github.com/user/repo');
482
- });
483
- it('should convert SSH URL with org path', () => {
484
- expect(normalizeGitUrl('git@github.com:Nonatomic/Vibescope.git')).toBe('https://github.com/Nonatomic/Vibescope');
485
- });
486
- });
487
- describe('converting SSH to HTTPS for GitLab', () => {
488
- it('should convert SSH URL with .git', () => {
489
- expect(normalizeGitUrl('git@gitlab.com:user/repo.git')).toBe('https://gitlab.com/user/repo');
490
- });
491
- it('should convert SSH URL without .git', () => {
492
- expect(normalizeGitUrl('git@gitlab.com:user/repo')).toBe('https://gitlab.com/user/repo');
493
- });
494
- });
495
- describe('converting SSH to HTTPS for Bitbucket', () => {
496
- it('should convert SSH URL with .git', () => {
497
- expect(normalizeGitUrl('git@bitbucket.org:user/repo.git')).toBe('https://bitbucket.org/user/repo');
498
- });
499
- it('should convert SSH URL without .git', () => {
500
- expect(normalizeGitUrl('git@bitbucket.org:user/repo')).toBe('https://bitbucket.org/user/repo');
501
- });
502
- });
503
- describe('passthrough behavior', () => {
504
- it('should pass through already-normalized HTTPS GitHub URL', () => {
505
- expect(normalizeGitUrl('https://github.com/user/repo')).toBe('https://github.com/user/repo');
506
- });
507
- it('should pass through HTTPS GitLab URL', () => {
508
- expect(normalizeGitUrl('https://gitlab.com/user/repo')).toBe('https://gitlab.com/user/repo');
509
- });
510
- it('should pass through HTTPS Bitbucket URL', () => {
511
- expect(normalizeGitUrl('https://bitbucket.org/user/repo')).toBe('https://bitbucket.org/user/repo');
512
- });
513
- it('should pass through empty string', () => {
514
- expect(normalizeGitUrl('')).toBe('');
515
- });
516
- it('should pass through unsupported git hosts', () => {
517
- expect(normalizeGitUrl('git@selfhosted.example.com:user/repo.git')).toBe('git@selfhosted.example.com:user/repo');
518
- });
519
- });
520
- describe('edge cases', () => {
521
- it('should handle complex paths with dashes and underscores', () => {
522
- expect(normalizeGitUrl('git@github.com:my-org/my_awesome-project.git')).toBe('https://github.com/my-org/my_awesome-project');
523
- });
524
- it('should handle nested paths', () => {
525
- expect(normalizeGitUrl('https://gitlab.com/group/subgroup/repo.git')).toBe('https://gitlab.com/group/subgroup/repo');
526
- });
527
- it('should handle URLs with port numbers', () => {
528
- // Port in URL - should just remove .git
529
- expect(normalizeGitUrl('https://github.com:443/user/repo.git')).toBe('https://github.com:443/user/repo');
530
- });
531
- });
532
- });
@@ -1 +0,0 @@
1
- export {};