@vibescope/mcp-server 0.0.1
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.md +98 -0
- package/dist/cli.d.ts +34 -0
- package/dist/cli.js +356 -0
- package/dist/cli.test.d.ts +1 -0
- package/dist/cli.test.js +367 -0
- package/dist/handlers/__test-utils__.d.ts +72 -0
- package/dist/handlers/__test-utils__.js +176 -0
- package/dist/handlers/blockers.d.ts +18 -0
- package/dist/handlers/blockers.js +81 -0
- package/dist/handlers/bodies-of-work.d.ts +34 -0
- package/dist/handlers/bodies-of-work.js +614 -0
- package/dist/handlers/checkouts.d.ts +37 -0
- package/dist/handlers/checkouts.js +377 -0
- package/dist/handlers/cost.d.ts +39 -0
- package/dist/handlers/cost.js +247 -0
- package/dist/handlers/decisions.d.ts +16 -0
- package/dist/handlers/decisions.js +64 -0
- package/dist/handlers/deployment.d.ts +36 -0
- package/dist/handlers/deployment.js +1062 -0
- package/dist/handlers/discovery.d.ts +14 -0
- package/dist/handlers/discovery.js +870 -0
- package/dist/handlers/fallback.d.ts +18 -0
- package/dist/handlers/fallback.js +216 -0
- package/dist/handlers/findings.d.ts +18 -0
- package/dist/handlers/findings.js +110 -0
- package/dist/handlers/git-issues.d.ts +22 -0
- package/dist/handlers/git-issues.js +247 -0
- package/dist/handlers/ideas.d.ts +19 -0
- package/dist/handlers/ideas.js +188 -0
- package/dist/handlers/index.d.ts +29 -0
- package/dist/handlers/index.js +65 -0
- package/dist/handlers/knowledge-query.d.ts +22 -0
- package/dist/handlers/knowledge-query.js +253 -0
- package/dist/handlers/knowledge.d.ts +12 -0
- package/dist/handlers/knowledge.js +108 -0
- package/dist/handlers/milestones.d.ts +20 -0
- package/dist/handlers/milestones.js +179 -0
- package/dist/handlers/organizations.d.ts +36 -0
- package/dist/handlers/organizations.js +428 -0
- package/dist/handlers/progress.d.ts +14 -0
- package/dist/handlers/progress.js +149 -0
- package/dist/handlers/project.d.ts +20 -0
- package/dist/handlers/project.js +278 -0
- package/dist/handlers/requests.d.ts +16 -0
- package/dist/handlers/requests.js +131 -0
- package/dist/handlers/roles.d.ts +30 -0
- package/dist/handlers/roles.js +281 -0
- package/dist/handlers/session.d.ts +20 -0
- package/dist/handlers/session.js +791 -0
- package/dist/handlers/tasks.d.ts +52 -0
- package/dist/handlers/tasks.js +1111 -0
- package/dist/handlers/tasks.test.d.ts +1 -0
- package/dist/handlers/tasks.test.js +431 -0
- package/dist/handlers/types.d.ts +94 -0
- package/dist/handlers/types.js +1 -0
- package/dist/handlers/validation.d.ts +16 -0
- package/dist/handlers/validation.js +188 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2707 -0
- package/dist/knowledge.d.ts +6 -0
- package/dist/knowledge.js +121 -0
- package/dist/tools.d.ts +2 -0
- package/dist/tools.js +2498 -0
- package/dist/utils.d.ts +149 -0
- package/dist/utils.js +317 -0
- package/dist/utils.test.d.ts +1 -0
- package/dist/utils.test.js +532 -0
- package/dist/validators.d.ts +35 -0
- package/dist/validators.js +111 -0
- package/dist/validators.test.d.ts +1 -0
- package/dist/validators.test.js +176 -0
- package/package.json +44 -0
- package/src/cli.test.ts +442 -0
- package/src/cli.ts +439 -0
- package/src/handlers/__test-utils__.ts +217 -0
- package/src/handlers/blockers.test.ts +390 -0
- package/src/handlers/blockers.ts +110 -0
- package/src/handlers/bodies-of-work.test.ts +1276 -0
- package/src/handlers/bodies-of-work.ts +783 -0
- package/src/handlers/cost.test.ts +436 -0
- package/src/handlers/cost.ts +322 -0
- package/src/handlers/decisions.test.ts +401 -0
- package/src/handlers/decisions.ts +86 -0
- package/src/handlers/deployment.test.ts +516 -0
- package/src/handlers/deployment.ts +1289 -0
- package/src/handlers/discovery.test.ts +254 -0
- package/src/handlers/discovery.ts +969 -0
- package/src/handlers/fallback.test.ts +687 -0
- package/src/handlers/fallback.ts +260 -0
- package/src/handlers/findings.test.ts +565 -0
- package/src/handlers/findings.ts +153 -0
- package/src/handlers/ideas.test.ts +753 -0
- package/src/handlers/ideas.ts +247 -0
- package/src/handlers/index.ts +69 -0
- package/src/handlers/milestones.test.ts +584 -0
- package/src/handlers/milestones.ts +217 -0
- package/src/handlers/organizations.test.ts +997 -0
- package/src/handlers/organizations.ts +550 -0
- package/src/handlers/progress.test.ts +369 -0
- package/src/handlers/progress.ts +188 -0
- package/src/handlers/project.test.ts +562 -0
- package/src/handlers/project.ts +352 -0
- package/src/handlers/requests.test.ts +531 -0
- package/src/handlers/requests.ts +150 -0
- package/src/handlers/session.test.ts +459 -0
- package/src/handlers/session.ts +912 -0
- package/src/handlers/tasks.test.ts +602 -0
- package/src/handlers/tasks.ts +1393 -0
- package/src/handlers/types.ts +88 -0
- package/src/handlers/validation.test.ts +880 -0
- package/src/handlers/validation.ts +223 -0
- package/src/index.ts +3205 -0
- package/src/knowledge.ts +132 -0
- package/src/tmpclaude-0078-cwd +1 -0
- package/src/tmpclaude-0ee1-cwd +1 -0
- package/src/tmpclaude-2dd5-cwd +1 -0
- package/src/tmpclaude-344c-cwd +1 -0
- package/src/tmpclaude-3860-cwd +1 -0
- package/src/tmpclaude-4b63-cwd +1 -0
- package/src/tmpclaude-5c73-cwd +1 -0
- package/src/tmpclaude-5ee3-cwd +1 -0
- package/src/tmpclaude-6795-cwd +1 -0
- package/src/tmpclaude-709e-cwd +1 -0
- package/src/tmpclaude-9839-cwd +1 -0
- package/src/tmpclaude-d829-cwd +1 -0
- package/src/tmpclaude-e072-cwd +1 -0
- package/src/tmpclaude-f6ee-cwd +1 -0
- package/src/utils.test.ts +681 -0
- package/src/utils.ts +375 -0
- package/src/validators.test.ts +223 -0
- package/src/validators.ts +122 -0
- package/tmpclaude-0439-cwd +1 -0
- package/tmpclaude-132f-cwd +1 -0
- package/tmpclaude-15bb-cwd +1 -0
- package/tmpclaude-165a-cwd +1 -0
- package/tmpclaude-1ba9-cwd +1 -0
- package/tmpclaude-21a3-cwd +1 -0
- package/tmpclaude-2a38-cwd +1 -0
- package/tmpclaude-2adf-cwd +1 -0
- package/tmpclaude-2f56-cwd +1 -0
- package/tmpclaude-3626-cwd +1 -0
- package/tmpclaude-3727-cwd +1 -0
- package/tmpclaude-40bc-cwd +1 -0
- package/tmpclaude-436f-cwd +1 -0
- package/tmpclaude-4783-cwd +1 -0
- package/tmpclaude-4b6d-cwd +1 -0
- package/tmpclaude-4ba4-cwd +1 -0
- package/tmpclaude-51e6-cwd +1 -0
- package/tmpclaude-5ecf-cwd +1 -0
- package/tmpclaude-6f97-cwd +1 -0
- package/tmpclaude-7fb2-cwd +1 -0
- package/tmpclaude-825c-cwd +1 -0
- package/tmpclaude-8baf-cwd +1 -0
- package/tmpclaude-8d9f-cwd +1 -0
- package/tmpclaude-975c-cwd +1 -0
- package/tmpclaude-9983-cwd +1 -0
- package/tmpclaude-a045-cwd +1 -0
- package/tmpclaude-ac4a-cwd +1 -0
- package/tmpclaude-b593-cwd +1 -0
- package/tmpclaude-b891-cwd +1 -0
- package/tmpclaude-c032-cwd +1 -0
- package/tmpclaude-cf43-cwd +1 -0
- package/tmpclaude-d040-cwd +1 -0
- package/tmpclaude-dcdd-cwd +1 -0
- package/tmpclaude-dcee-cwd +1 -0
- package/tmpclaude-e16b-cwd +1 -0
- package/tmpclaude-ecd2-cwd +1 -0
- package/tmpclaude-f48d-cwd +1 -0
- package/tsconfig.json +16 -0
- package/vitest.config.ts +13 -0
|
@@ -0,0 +1,532 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export declare const VALID_TASK_STATUSES: readonly ["backlog", "pending", "in_progress", "completed", "cancelled"];
|
|
2
|
+
export declare const VALID_PROJECT_STATUSES: readonly ["active", "paused", "completed", "archived"];
|
|
3
|
+
export declare const VALID_BLOCKER_STATUSES: readonly ["open", "resolved"];
|
|
4
|
+
export declare const VALID_DEPLOYMENT_STATUSES: readonly ["pending", "validating", "ready", "deploying", "deployed", "failed"];
|
|
5
|
+
export declare const VALID_ENVIRONMENTS: readonly ["development", "staging", "production"];
|
|
6
|
+
export type TaskStatus = typeof VALID_TASK_STATUSES[number];
|
|
7
|
+
export type ProjectStatus = typeof VALID_PROJECT_STATUSES[number];
|
|
8
|
+
export type BlockerStatus = typeof VALID_BLOCKER_STATUSES[number];
|
|
9
|
+
export type DeploymentStatus = typeof VALID_DEPLOYMENT_STATUSES[number];
|
|
10
|
+
export type Environment = typeof VALID_ENVIRONMENTS[number];
|
|
11
|
+
export declare class ValidationError extends Error {
|
|
12
|
+
field?: string;
|
|
13
|
+
hint?: string;
|
|
14
|
+
validValues?: readonly string[];
|
|
15
|
+
constructor(message: string, options?: {
|
|
16
|
+
field?: string;
|
|
17
|
+
hint?: string;
|
|
18
|
+
validValues?: readonly string[];
|
|
19
|
+
});
|
|
20
|
+
toJSON(): {
|
|
21
|
+
error: string;
|
|
22
|
+
message: string;
|
|
23
|
+
field: string | undefined;
|
|
24
|
+
hint: string | undefined;
|
|
25
|
+
valid_values: readonly string[] | undefined;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export declare function validateRequired(value: unknown, fieldName: string): void;
|
|
29
|
+
export declare function validateUUID(value: string | undefined, fieldName: string): void;
|
|
30
|
+
export declare function validateTaskStatus(status: string | undefined): void;
|
|
31
|
+
export declare function validateProjectStatus(status: string | undefined): void;
|
|
32
|
+
export declare function validatePriority(priority: number | undefined): void;
|
|
33
|
+
export declare function validateProgressPercentage(percentage: number | undefined): void;
|
|
34
|
+
export declare function validateEstimatedMinutes(minutes: number | undefined): void;
|
|
35
|
+
export declare function validateEnvironment(environment: string | undefined): void;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Validation Helpers
|
|
3
|
+
// ============================================================================
|
|
4
|
+
export const VALID_TASK_STATUSES = ['backlog', 'pending', 'in_progress', 'completed', 'cancelled'];
|
|
5
|
+
export const VALID_PROJECT_STATUSES = ['active', 'paused', 'completed', 'archived'];
|
|
6
|
+
export const VALID_BLOCKER_STATUSES = ['open', 'resolved'];
|
|
7
|
+
export const VALID_DEPLOYMENT_STATUSES = ['pending', 'validating', 'ready', 'deploying', 'deployed', 'failed'];
|
|
8
|
+
export const VALID_ENVIRONMENTS = ['development', 'staging', 'production'];
|
|
9
|
+
export class ValidationError extends Error {
|
|
10
|
+
field;
|
|
11
|
+
hint;
|
|
12
|
+
validValues;
|
|
13
|
+
constructor(message, options) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.name = 'ValidationError';
|
|
16
|
+
this.field = options?.field;
|
|
17
|
+
this.hint = options?.hint;
|
|
18
|
+
this.validValues = options?.validValues;
|
|
19
|
+
}
|
|
20
|
+
toJSON() {
|
|
21
|
+
return {
|
|
22
|
+
error: 'validation_error',
|
|
23
|
+
message: this.message,
|
|
24
|
+
field: this.field,
|
|
25
|
+
hint: this.hint,
|
|
26
|
+
valid_values: this.validValues,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export function validateRequired(value, fieldName) {
|
|
31
|
+
if (value === undefined || value === null || value === '') {
|
|
32
|
+
throw new ValidationError(`Missing required field: ${fieldName}`, {
|
|
33
|
+
field: fieldName,
|
|
34
|
+
hint: `Please provide a value for "${fieldName}"`,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export function validateUUID(value, fieldName) {
|
|
39
|
+
if (!value)
|
|
40
|
+
return;
|
|
41
|
+
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
42
|
+
if (!uuidRegex.test(value)) {
|
|
43
|
+
throw new ValidationError(`Invalid UUID format for ${fieldName}: "${value}"`, {
|
|
44
|
+
field: fieldName,
|
|
45
|
+
hint: 'UUIDs should be in format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export function validateTaskStatus(status) {
|
|
50
|
+
if (!status)
|
|
51
|
+
return;
|
|
52
|
+
if (!VALID_TASK_STATUSES.includes(status)) {
|
|
53
|
+
throw new ValidationError(`Invalid task status: "${status}"`, {
|
|
54
|
+
field: 'status',
|
|
55
|
+
validValues: VALID_TASK_STATUSES,
|
|
56
|
+
hint: `Status must be one of: ${VALID_TASK_STATUSES.join(', ')}`,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
export function validateProjectStatus(status) {
|
|
61
|
+
if (!status)
|
|
62
|
+
return;
|
|
63
|
+
if (!VALID_PROJECT_STATUSES.includes(status)) {
|
|
64
|
+
throw new ValidationError(`Invalid project status: "${status}"`, {
|
|
65
|
+
field: 'status',
|
|
66
|
+
validValues: VALID_PROJECT_STATUSES,
|
|
67
|
+
hint: `Status must be one of: ${VALID_PROJECT_STATUSES.join(', ')}`,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
export function validatePriority(priority) {
|
|
72
|
+
if (priority === undefined)
|
|
73
|
+
return;
|
|
74
|
+
if (!Number.isInteger(priority) || priority < 1 || priority > 5) {
|
|
75
|
+
throw new ValidationError(`Invalid priority: ${priority}. Must be an integer between 1 and 5`, {
|
|
76
|
+
field: 'priority',
|
|
77
|
+
hint: 'Priority 1 is highest, 5 is lowest',
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
export function validateProgressPercentage(percentage) {
|
|
82
|
+
if (percentage === undefined)
|
|
83
|
+
return;
|
|
84
|
+
if (!Number.isFinite(percentage) || percentage < 0 || percentage > 100) {
|
|
85
|
+
throw new ValidationError(`Invalid progress_percentage: ${percentage}. Must be between 0 and 100`, {
|
|
86
|
+
field: 'progress_percentage',
|
|
87
|
+
hint: 'Use 0 for not started, 100 for complete',
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
export function validateEstimatedMinutes(minutes) {
|
|
92
|
+
if (minutes === undefined)
|
|
93
|
+
return;
|
|
94
|
+
if (!Number.isInteger(minutes) || minutes < 1) {
|
|
95
|
+
throw new ValidationError(`Invalid estimated_minutes: ${minutes}. Must be a positive integer`, {
|
|
96
|
+
field: 'estimated_minutes',
|
|
97
|
+
hint: 'Estimate the task duration in minutes (e.g., 30 for half an hour)',
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
export function validateEnvironment(environment) {
|
|
102
|
+
if (!environment)
|
|
103
|
+
return;
|
|
104
|
+
if (!VALID_ENVIRONMENTS.includes(environment)) {
|
|
105
|
+
throw new ValidationError(`Invalid environment: "${environment}"`, {
|
|
106
|
+
field: 'environment',
|
|
107
|
+
validValues: VALID_ENVIRONMENTS,
|
|
108
|
+
hint: `Environment must be one of: ${VALID_ENVIRONMENTS.join(', ')}`,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}
|