@vibescope/mcp-server 0.0.1 → 0.1.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 (170) hide show
  1. package/README.md +113 -98
  2. package/dist/api-client.d.ts +1114 -0
  3. package/dist/api-client.js +698 -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 +106 -476
  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 +112 -828
  16. package/dist/handlers/discovery.js +31 -0
  17. package/dist/handlers/fallback.d.ts +2 -0
  18. package/dist/handlers/fallback.js +39 -134
  19. package/dist/handlers/findings.js +43 -67
  20. package/dist/handlers/git-issues.d.ts +9 -13
  21. package/dist/handlers/git-issues.js +80 -225
  22. package/dist/handlers/ideas.d.ts +3 -0
  23. package/dist/handlers/ideas.js +53 -134
  24. package/dist/handlers/index.d.ts +2 -0
  25. package/dist/handlers/index.js +6 -0
  26. package/dist/handlers/milestones.d.ts +2 -0
  27. package/dist/handlers/milestones.js +51 -98
  28. package/dist/handlers/organizations.js +79 -275
  29. package/dist/handlers/progress.d.ts +2 -0
  30. package/dist/handlers/progress.js +25 -123
  31. package/dist/handlers/project.js +42 -221
  32. package/dist/handlers/requests.d.ts +2 -0
  33. package/dist/handlers/requests.js +23 -83
  34. package/dist/handlers/session.js +99 -585
  35. package/dist/handlers/sprints.d.ts +32 -0
  36. package/dist/handlers/sprints.js +274 -0
  37. package/dist/handlers/tasks.d.ts +7 -10
  38. package/dist/handlers/tasks.js +230 -900
  39. package/dist/handlers/tool-docs.d.ts +8 -0
  40. package/dist/handlers/tool-docs.js +657 -0
  41. package/dist/handlers/types.d.ts +11 -3
  42. package/dist/handlers/validation.d.ts +1 -1
  43. package/dist/handlers/validation.js +26 -153
  44. package/dist/index.js +473 -160
  45. package/dist/knowledge.js +106 -9
  46. package/dist/tools.js +4 -0
  47. package/dist/validators.d.ts +21 -0
  48. package/dist/validators.js +91 -0
  49. package/package.json +2 -3
  50. package/src/api-client.ts +1752 -0
  51. package/src/cli.test.ts +128 -302
  52. package/src/cli.ts +41 -285
  53. package/src/handlers/__test-setup__.ts +210 -0
  54. package/src/handlers/__test-utils__.ts +4 -134
  55. package/src/handlers/blockers.test.ts +114 -124
  56. package/src/handlers/blockers.ts +68 -70
  57. package/src/handlers/bodies-of-work.test.ts +236 -831
  58. package/src/handlers/bodies-of-work.ts +194 -525
  59. package/src/handlers/cost.test.ts +149 -113
  60. package/src/handlers/cost.ts +44 -132
  61. package/src/handlers/decisions.test.ts +111 -209
  62. package/src/handlers/decisions.ts +35 -27
  63. package/src/handlers/deployment.test.ts +193 -239
  64. package/src/handlers/deployment.ts +140 -895
  65. package/src/handlers/discovery.test.ts +20 -67
  66. package/src/handlers/discovery.ts +32 -0
  67. package/src/handlers/fallback.test.ts +128 -361
  68. package/src/handlers/fallback.ts +62 -148
  69. package/src/handlers/findings.test.ts +127 -345
  70. package/src/handlers/findings.ts +49 -66
  71. package/src/handlers/git-issues.test.ts +623 -0
  72. package/src/handlers/git-issues.ts +174 -0
  73. package/src/handlers/ideas.test.ts +229 -343
  74. package/src/handlers/ideas.ts +69 -143
  75. package/src/handlers/index.ts +6 -0
  76. package/src/handlers/milestones.test.ts +167 -281
  77. package/src/handlers/milestones.ts +54 -93
  78. package/src/handlers/organizations.test.ts +275 -467
  79. package/src/handlers/organizations.ts +84 -294
  80. package/src/handlers/progress.test.ts +112 -218
  81. package/src/handlers/progress.ts +29 -142
  82. package/src/handlers/project.test.ts +203 -226
  83. package/src/handlers/project.ts +48 -238
  84. package/src/handlers/requests.test.ts +74 -342
  85. package/src/handlers/requests.ts +25 -83
  86. package/src/handlers/session.test.ts +241 -206
  87. package/src/handlers/session.ts +110 -657
  88. package/src/handlers/sprints.test.ts +711 -0
  89. package/src/handlers/sprints.ts +497 -0
  90. package/src/handlers/tasks.test.ts +608 -353
  91. package/src/handlers/tasks.ts +248 -1025
  92. package/src/handlers/types.ts +12 -4
  93. package/src/handlers/validation.test.ts +189 -572
  94. package/src/handlers/validation.ts +29 -166
  95. package/src/index.ts +473 -184
  96. package/src/knowledge.ts +107 -9
  97. package/src/tools.ts +2506 -0
  98. package/src/validators.test.ts +223 -223
  99. package/src/validators.ts +127 -0
  100. package/tsconfig.json +1 -1
  101. package/vitest.config.ts +14 -13
  102. package/dist/cli.test.d.ts +0 -1
  103. package/dist/cli.test.js +0 -367
  104. package/dist/handlers/__test-utils__.d.ts +0 -72
  105. package/dist/handlers/__test-utils__.js +0 -176
  106. package/dist/handlers/checkouts.d.ts +0 -37
  107. package/dist/handlers/checkouts.js +0 -377
  108. package/dist/handlers/knowledge-query.d.ts +0 -22
  109. package/dist/handlers/knowledge-query.js +0 -253
  110. package/dist/handlers/knowledge.d.ts +0 -12
  111. package/dist/handlers/knowledge.js +0 -108
  112. package/dist/handlers/roles.d.ts +0 -30
  113. package/dist/handlers/roles.js +0 -281
  114. package/dist/handlers/tasks.test.d.ts +0 -1
  115. package/dist/handlers/tasks.test.js +0 -431
  116. package/dist/utils.test.d.ts +0 -1
  117. package/dist/utils.test.js +0 -532
  118. package/dist/validators.test.d.ts +0 -1
  119. package/dist/validators.test.js +0 -176
  120. package/src/tmpclaude-0078-cwd +0 -1
  121. package/src/tmpclaude-0ee1-cwd +0 -1
  122. package/src/tmpclaude-2dd5-cwd +0 -1
  123. package/src/tmpclaude-344c-cwd +0 -1
  124. package/src/tmpclaude-3860-cwd +0 -1
  125. package/src/tmpclaude-4b63-cwd +0 -1
  126. package/src/tmpclaude-5c73-cwd +0 -1
  127. package/src/tmpclaude-5ee3-cwd +0 -1
  128. package/src/tmpclaude-6795-cwd +0 -1
  129. package/src/tmpclaude-709e-cwd +0 -1
  130. package/src/tmpclaude-9839-cwd +0 -1
  131. package/src/tmpclaude-d829-cwd +0 -1
  132. package/src/tmpclaude-e072-cwd +0 -1
  133. package/src/tmpclaude-f6ee-cwd +0 -1
  134. package/tmpclaude-0439-cwd +0 -1
  135. package/tmpclaude-132f-cwd +0 -1
  136. package/tmpclaude-15bb-cwd +0 -1
  137. package/tmpclaude-165a-cwd +0 -1
  138. package/tmpclaude-1ba9-cwd +0 -1
  139. package/tmpclaude-21a3-cwd +0 -1
  140. package/tmpclaude-2a38-cwd +0 -1
  141. package/tmpclaude-2adf-cwd +0 -1
  142. package/tmpclaude-2f56-cwd +0 -1
  143. package/tmpclaude-3626-cwd +0 -1
  144. package/tmpclaude-3727-cwd +0 -1
  145. package/tmpclaude-40bc-cwd +0 -1
  146. package/tmpclaude-436f-cwd +0 -1
  147. package/tmpclaude-4783-cwd +0 -1
  148. package/tmpclaude-4b6d-cwd +0 -1
  149. package/tmpclaude-4ba4-cwd +0 -1
  150. package/tmpclaude-51e6-cwd +0 -1
  151. package/tmpclaude-5ecf-cwd +0 -1
  152. package/tmpclaude-6f97-cwd +0 -1
  153. package/tmpclaude-7fb2-cwd +0 -1
  154. package/tmpclaude-825c-cwd +0 -1
  155. package/tmpclaude-8baf-cwd +0 -1
  156. package/tmpclaude-8d9f-cwd +0 -1
  157. package/tmpclaude-975c-cwd +0 -1
  158. package/tmpclaude-9983-cwd +0 -1
  159. package/tmpclaude-a045-cwd +0 -1
  160. package/tmpclaude-ac4a-cwd +0 -1
  161. package/tmpclaude-b593-cwd +0 -1
  162. package/tmpclaude-b891-cwd +0 -1
  163. package/tmpclaude-c032-cwd +0 -1
  164. package/tmpclaude-cf43-cwd +0 -1
  165. package/tmpclaude-d040-cwd +0 -1
  166. package/tmpclaude-dcdd-cwd +0 -1
  167. package/tmpclaude-dcee-cwd +0 -1
  168. package/tmpclaude-e16b-cwd +0 -1
  169. package/tmpclaude-ecd2-cwd +0 -1
  170. package/tmpclaude-f48d-cwd +0 -1
@@ -0,0 +1,698 @@
1
+ /**
2
+ * Vibescope API Client
3
+ *
4
+ * HTTP client for communicating with the Vibescope API.
5
+ * All database operations are handled server-side through these endpoints.
6
+ */
7
+ const DEFAULT_API_URL = 'https://vibescope.dev';
8
+ export class VibescopeApiClient {
9
+ apiKey;
10
+ baseUrl;
11
+ constructor(config) {
12
+ this.apiKey = config.apiKey;
13
+ this.baseUrl = config.baseUrl || process.env.VIBESCOPE_API_URL || DEFAULT_API_URL;
14
+ }
15
+ async request(method, path, body) {
16
+ const url = `${this.baseUrl}${path}`;
17
+ try {
18
+ const response = await fetch(url, {
19
+ method,
20
+ headers: {
21
+ 'Content-Type': 'application/json',
22
+ 'X-API-Key': this.apiKey
23
+ },
24
+ body: body ? JSON.stringify(body) : undefined
25
+ });
26
+ const data = await response.json();
27
+ if (!response.ok) {
28
+ return {
29
+ ok: false,
30
+ status: response.status,
31
+ error: data.error || `HTTP ${response.status}`
32
+ };
33
+ }
34
+ return {
35
+ ok: true,
36
+ status: response.status,
37
+ data
38
+ };
39
+ }
40
+ catch (err) {
41
+ return {
42
+ ok: false,
43
+ status: 0,
44
+ error: err instanceof Error ? err.message : 'Network error'
45
+ };
46
+ }
47
+ }
48
+ // Auth endpoints
49
+ async validateAuth() {
50
+ return this.request('POST', '/api/mcp/auth/validate', {
51
+ api_key: this.apiKey
52
+ });
53
+ }
54
+ // Session endpoints
55
+ async startSession(params) {
56
+ return this.request('POST', '/api/mcp/sessions/start', params);
57
+ }
58
+ async heartbeat(sessionId) {
59
+ return this.request('POST', '/api/mcp/sessions/heartbeat', {
60
+ session_id: sessionId
61
+ });
62
+ }
63
+ async endSession(sessionId) {
64
+ return this.request('POST', '/api/mcp/sessions/end', {
65
+ session_id: sessionId
66
+ });
67
+ }
68
+ // Project endpoints
69
+ async listProjects() {
70
+ return this.request('GET', '/api/mcp/projects');
71
+ }
72
+ async createProject(params) {
73
+ return this.request('POST', '/api/mcp/projects', params);
74
+ }
75
+ async getProject(projectId, gitUrl) {
76
+ const url = gitUrl
77
+ ? `/api/mcp/projects/${projectId}?git_url=${encodeURIComponent(gitUrl)}`
78
+ : `/api/mcp/projects/${projectId}`;
79
+ return this.request('GET', url);
80
+ }
81
+ async updateProject(projectId, updates) {
82
+ return this.request('PATCH', `/api/mcp/projects/${projectId}`, updates);
83
+ }
84
+ // Task endpoints
85
+ async getTasks(projectId, params) {
86
+ const queryParams = new URLSearchParams();
87
+ if (params?.status)
88
+ queryParams.set('status', params.status);
89
+ if (params?.limit)
90
+ queryParams.set('limit', params.limit.toString());
91
+ if (params?.offset)
92
+ queryParams.set('offset', params.offset.toString());
93
+ if (params?.include_subtasks)
94
+ queryParams.set('include_subtasks', 'true');
95
+ if (params?.search_query)
96
+ queryParams.set('search_query', params.search_query);
97
+ if (params?.include_metadata)
98
+ queryParams.set('include_metadata', 'true');
99
+ const query = queryParams.toString();
100
+ const url = `/api/mcp/projects/${projectId}/tasks${query ? `?${query}` : ''}`;
101
+ return this.request('GET', url);
102
+ }
103
+ async createTask(projectId, params) {
104
+ return this.request('POST', `/api/mcp/projects/${projectId}/tasks`, params);
105
+ }
106
+ async getNextTask(projectId, sessionId) {
107
+ const url = sessionId
108
+ ? `/api/mcp/projects/${projectId}/next-task?session_id=${sessionId}`
109
+ : `/api/mcp/projects/${projectId}/next-task`;
110
+ return this.request('GET', url);
111
+ }
112
+ async getTask(taskId) {
113
+ return this.request('GET', `/api/mcp/tasks/${taskId}`);
114
+ }
115
+ async updateTask(taskId, updates) {
116
+ return this.request('PATCH', `/api/mcp/tasks/${taskId}`, updates);
117
+ }
118
+ async completeTask(taskId, params) {
119
+ return this.request('POST', `/api/mcp/tasks/${taskId}/complete`, params);
120
+ }
121
+ async deleteTask(taskId) {
122
+ return this.request('DELETE', `/api/mcp/tasks/${taskId}`);
123
+ }
124
+ // Progress endpoints
125
+ async logProgress(projectId, params) {
126
+ return this.request('POST', `/api/mcp/projects/${projectId}/progress`, params);
127
+ }
128
+ // Git workflow endpoint
129
+ async getGitWorkflow(projectId, taskId) {
130
+ const url = taskId
131
+ ? `/api/mcp/projects/${projectId}/git-workflow?task_id=${taskId}`
132
+ : `/api/mcp/projects/${projectId}/git-workflow`;
133
+ return this.request('GET', url);
134
+ }
135
+ // ============================================================================
136
+ // Proxy endpoint - Generic method for all operations
137
+ // ============================================================================
138
+ async proxy(operation, args, sessionContext) {
139
+ return this.request('POST', '/api/mcp/proxy', {
140
+ operation,
141
+ args,
142
+ session_context: sessionContext
143
+ });
144
+ }
145
+ // ============================================================================
146
+ // Blocker endpoints
147
+ // ============================================================================
148
+ async getBlockers(projectId, params) {
149
+ return this.proxy('get_blockers', {
150
+ project_id: projectId,
151
+ ...params
152
+ });
153
+ }
154
+ async addBlocker(projectId, description, sessionId) {
155
+ return this.proxy('add_blocker', { project_id: projectId, description }, sessionId ? {
156
+ session_id: sessionId,
157
+ persona: null,
158
+ instance_id: ''
159
+ } : undefined);
160
+ }
161
+ async resolveBlocker(blockerId, resolutionNote) {
162
+ return this.proxy('resolve_blocker', {
163
+ blocker_id: blockerId,
164
+ resolution_note: resolutionNote
165
+ });
166
+ }
167
+ async deleteBlocker(blockerId) {
168
+ return this.proxy('delete_blocker', { blocker_id: blockerId });
169
+ }
170
+ // ============================================================================
171
+ // Decision endpoints
172
+ // ============================================================================
173
+ async getDecisions(projectId) {
174
+ return this.proxy('get_decisions', { project_id: projectId });
175
+ }
176
+ async logDecision(projectId, params, sessionId) {
177
+ return this.proxy('log_decision', {
178
+ project_id: projectId,
179
+ ...params
180
+ }, sessionId ? { session_id: sessionId, persona: null, instance_id: '' } : undefined);
181
+ }
182
+ async deleteDecision(decisionId) {
183
+ return this.proxy('delete_decision', { decision_id: decisionId });
184
+ }
185
+ // ============================================================================
186
+ // Idea endpoints
187
+ // ============================================================================
188
+ async getIdeas(projectId, params) {
189
+ return this.proxy('get_ideas', {
190
+ project_id: projectId,
191
+ ...params
192
+ });
193
+ }
194
+ async addIdea(projectId, params, sessionId) {
195
+ return this.proxy('add_idea', {
196
+ project_id: projectId,
197
+ ...params
198
+ }, sessionId ? { session_id: sessionId, persona: null, instance_id: '' } : undefined);
199
+ }
200
+ async updateIdea(ideaId, updates) {
201
+ return this.proxy('update_idea', {
202
+ idea_id: ideaId,
203
+ ...updates
204
+ });
205
+ }
206
+ async deleteIdea(ideaId) {
207
+ return this.proxy('delete_idea', { idea_id: ideaId });
208
+ }
209
+ async convertIdeaToTask(ideaId, params) {
210
+ return this.proxy('convert_idea_to_task', {
211
+ idea_id: ideaId,
212
+ ...params
213
+ });
214
+ }
215
+ // ============================================================================
216
+ // Finding endpoints
217
+ // ============================================================================
218
+ async getFindings(projectId, params) {
219
+ return this.proxy('get_findings', {
220
+ project_id: projectId,
221
+ ...params
222
+ });
223
+ }
224
+ async addFinding(projectId, params, sessionId) {
225
+ return this.proxy('add_finding', {
226
+ project_id: projectId,
227
+ ...params
228
+ }, sessionId ? { session_id: sessionId, persona: null, instance_id: '' } : undefined);
229
+ }
230
+ async updateFinding(findingId, updates) {
231
+ return this.proxy('update_finding', {
232
+ finding_id: findingId,
233
+ ...updates
234
+ });
235
+ }
236
+ async deleteFinding(findingId) {
237
+ return this.proxy('delete_finding', { finding_id: findingId });
238
+ }
239
+ // ============================================================================
240
+ // Milestone endpoints
241
+ // ============================================================================
242
+ async getMilestones(taskId) {
243
+ return this.proxy('get_milestones', { task_id: taskId });
244
+ }
245
+ async addMilestone(taskId, params, sessionId) {
246
+ return this.proxy('add_milestone', {
247
+ task_id: taskId,
248
+ ...params
249
+ }, sessionId ? { session_id: sessionId, persona: null, instance_id: '' } : undefined);
250
+ }
251
+ async updateMilestone(milestoneId, updates) {
252
+ return this.proxy('update_milestone', {
253
+ milestone_id: milestoneId,
254
+ ...updates
255
+ });
256
+ }
257
+ async completeMilestone(milestoneId) {
258
+ return this.proxy('complete_milestone', { milestone_id: milestoneId });
259
+ }
260
+ async deleteMilestone(milestoneId) {
261
+ return this.proxy('delete_milestone', { milestone_id: milestoneId });
262
+ }
263
+ // ============================================================================
264
+ // Request endpoints
265
+ // ============================================================================
266
+ async getPendingRequests(projectId, sessionId) {
267
+ return this.proxy('get_pending_requests', { project_id: projectId }, sessionId ? {
268
+ session_id: sessionId,
269
+ persona: null,
270
+ instance_id: ''
271
+ } : undefined);
272
+ }
273
+ async acknowledgeRequest(requestId, sessionId) {
274
+ return this.proxy('acknowledge_request', { request_id: requestId }, sessionId ? {
275
+ session_id: sessionId,
276
+ persona: null,
277
+ instance_id: ''
278
+ } : undefined);
279
+ }
280
+ async answerQuestion(requestId, answer, sessionId) {
281
+ return this.proxy('answer_question', {
282
+ request_id: requestId,
283
+ answer
284
+ }, sessionId ? { session_id: sessionId, persona: null, instance_id: '' } : undefined);
285
+ }
286
+ // ============================================================================
287
+ // Validation endpoints
288
+ // ============================================================================
289
+ async getTasksAwaitingValidation(projectId) {
290
+ return this.proxy('get_tasks_awaiting_validation', { project_id: projectId });
291
+ }
292
+ async claimValidation(taskId, sessionId) {
293
+ return this.proxy('claim_validation', { task_id: taskId }, sessionId ? {
294
+ session_id: sessionId,
295
+ persona: null,
296
+ instance_id: ''
297
+ } : undefined);
298
+ }
299
+ async validateTask(taskId, params, sessionId) {
300
+ return this.proxy('validate_task', {
301
+ task_id: taskId,
302
+ ...params
303
+ }, sessionId ? { session_id: sessionId, persona: null, instance_id: '' } : undefined);
304
+ }
305
+ // ============================================================================
306
+ // Fallback activity endpoints
307
+ // ============================================================================
308
+ async startFallbackActivity(projectId, activity, sessionId) {
309
+ return this.proxy('start_fallback_activity', {
310
+ project_id: projectId,
311
+ activity
312
+ }, sessionId ? { session_id: sessionId, persona: null, instance_id: '' } : undefined);
313
+ }
314
+ async stopFallbackActivity(projectId, summary, sessionId) {
315
+ return this.proxy('stop_fallback_activity', {
316
+ project_id: projectId,
317
+ summary
318
+ }, sessionId ? { session_id: sessionId, persona: null, instance_id: '' } : undefined);
319
+ }
320
+ async getActivityHistory(projectId, params) {
321
+ return this.proxy('get_activity_history', {
322
+ project_id: projectId,
323
+ ...params
324
+ });
325
+ }
326
+ async getActivitySchedules(projectId) {
327
+ return this.proxy('get_activity_schedules', { project_id: projectId });
328
+ }
329
+ // ============================================================================
330
+ // Subtask endpoints
331
+ // ============================================================================
332
+ async addSubtask(parentTaskId, params, sessionId) {
333
+ return this.proxy('add_subtask', {
334
+ parent_task_id: parentTaskId,
335
+ ...params
336
+ }, sessionId ? { session_id: sessionId, persona: null, instance_id: '' } : undefined);
337
+ }
338
+ async getSubtasks(parentTaskId, status) {
339
+ return this.proxy('get_subtasks', {
340
+ parent_task_id: parentTaskId,
341
+ status
342
+ });
343
+ }
344
+ // ============================================================================
345
+ // Activity feed endpoint
346
+ // ============================================================================
347
+ async getActivityFeed(projectId, params) {
348
+ return this.proxy('get_activity_feed', {
349
+ project_id: projectId,
350
+ ...params
351
+ });
352
+ }
353
+ // ============================================================================
354
+ // Deployment endpoints
355
+ // ============================================================================
356
+ async requestDeployment(projectId, params, sessionId) {
357
+ return this.proxy('request_deployment', {
358
+ project_id: projectId,
359
+ ...params
360
+ }, sessionId ? { session_id: sessionId, persona: null, instance_id: '' } : undefined);
361
+ }
362
+ async checkDeploymentStatus(projectId) {
363
+ return this.proxy('check_deployment_status', { project_id: projectId });
364
+ }
365
+ async claimDeploymentValidation(projectId, sessionId) {
366
+ return this.proxy('claim_deployment_validation', { project_id: projectId }, sessionId ? {
367
+ session_id: sessionId,
368
+ persona: null,
369
+ instance_id: ''
370
+ } : undefined);
371
+ }
372
+ async reportValidation(projectId, params) {
373
+ return this.proxy('report_validation', {
374
+ project_id: projectId,
375
+ ...params
376
+ });
377
+ }
378
+ async startDeployment(projectId, sessionId) {
379
+ return this.proxy('start_deployment', { project_id: projectId }, sessionId ? {
380
+ session_id: sessionId,
381
+ persona: null,
382
+ instance_id: ''
383
+ } : undefined);
384
+ }
385
+ async completeDeployment(projectId, params) {
386
+ return this.proxy('complete_deployment', {
387
+ project_id: projectId,
388
+ ...params
389
+ });
390
+ }
391
+ async cancelDeployment(projectId, reason) {
392
+ return this.proxy('cancel_deployment', {
393
+ project_id: projectId,
394
+ reason
395
+ });
396
+ }
397
+ // ============================================================================
398
+ // Task reference endpoints
399
+ // ============================================================================
400
+ async addTaskReference(taskId, url, label) {
401
+ return this.proxy('add_task_reference', {
402
+ task_id: taskId,
403
+ url,
404
+ label
405
+ });
406
+ }
407
+ async removeTaskReference(taskId, url) {
408
+ return this.proxy('remove_task_reference', {
409
+ task_id: taskId,
410
+ url
411
+ });
412
+ }
413
+ // ============================================================================
414
+ // Knowledge base endpoint
415
+ // ============================================================================
416
+ async queryKnowledgeBase(projectId, params) {
417
+ return this.proxy('query_knowledge_base', {
418
+ project_id: projectId,
419
+ ...params
420
+ });
421
+ }
422
+ // ============================================================================
423
+ // Session sync endpoint
424
+ // ============================================================================
425
+ async syncSession(sessionId, params) {
426
+ return this.proxy('sync_session', {
427
+ session_id: sessionId,
428
+ ...params
429
+ });
430
+ }
431
+ // ============================================================================
432
+ // Organization endpoints
433
+ // ============================================================================
434
+ async listOrganizations() {
435
+ return this.proxy('list_organizations', {});
436
+ }
437
+ async createOrganization(params) {
438
+ return this.proxy('create_organization', params);
439
+ }
440
+ async updateOrganization(organizationId, updates) {
441
+ return this.proxy('update_organization', {
442
+ organization_id: organizationId,
443
+ ...updates
444
+ });
445
+ }
446
+ async deleteOrganization(organizationId) {
447
+ return this.proxy('delete_organization', { organization_id: organizationId });
448
+ }
449
+ async listOrgMembers(organizationId) {
450
+ return this.proxy('list_org_members', { organization_id: organizationId });
451
+ }
452
+ async inviteMember(organizationId, email, role) {
453
+ return this.proxy('invite_member', {
454
+ organization_id: organizationId,
455
+ email,
456
+ role
457
+ });
458
+ }
459
+ async updateMemberRole(organizationId, userId, role) {
460
+ return this.proxy('update_member_role', {
461
+ organization_id: organizationId,
462
+ user_id: userId,
463
+ role
464
+ });
465
+ }
466
+ async removeMember(organizationId, userId) {
467
+ return this.proxy('remove_member', {
468
+ organization_id: organizationId,
469
+ user_id: userId
470
+ });
471
+ }
472
+ async shareProjectWithOrg(projectId, organizationId, permission) {
473
+ return this.proxy('share_project_with_org', {
474
+ project_id: projectId,
475
+ organization_id: organizationId,
476
+ permission
477
+ });
478
+ }
479
+ async unshareProject(projectId, organizationId) {
480
+ return this.proxy('unshare_project', {
481
+ project_id: projectId,
482
+ organization_id: organizationId
483
+ });
484
+ }
485
+ async leaveOrganization(organizationId) {
486
+ return this.proxy('leave_organization', { organization_id: organizationId });
487
+ }
488
+ async updateProjectShare(projectId, organizationId, permission) {
489
+ return this.proxy('update_project_share', {
490
+ project_id: projectId,
491
+ organization_id: organizationId,
492
+ permission
493
+ });
494
+ }
495
+ async listProjectShares(projectId) {
496
+ return this.proxy('list_project_shares', { project_id: projectId });
497
+ }
498
+ // ============================================================================
499
+ // Body of work endpoints
500
+ // ============================================================================
501
+ async createBodyOfWork(projectId, params) {
502
+ return this.proxy('create_body_of_work', {
503
+ project_id: projectId,
504
+ ...params
505
+ });
506
+ }
507
+ async getBodyOfWork(bodyOfWorkId) {
508
+ return this.proxy('get_body_of_work', { body_of_work_id: bodyOfWorkId });
509
+ }
510
+ async getBodiesOfWork(projectId, params) {
511
+ return this.proxy('get_bodies_of_work', {
512
+ project_id: projectId,
513
+ ...params
514
+ });
515
+ }
516
+ async updateBodyOfWork(bodyOfWorkId, updates) {
517
+ return this.proxy('update_body_of_work', {
518
+ body_of_work_id: bodyOfWorkId,
519
+ ...updates
520
+ });
521
+ }
522
+ async deleteBodyOfWork(bodyOfWorkId) {
523
+ return this.proxy('delete_body_of_work', { body_of_work_id: bodyOfWorkId });
524
+ }
525
+ async addTaskToBodyOfWork(bodyOfWorkId, taskId, phase, orderIndex) {
526
+ return this.proxy('add_task_to_body_of_work', {
527
+ body_of_work_id: bodyOfWorkId,
528
+ task_id: taskId,
529
+ phase,
530
+ order_index: orderIndex
531
+ });
532
+ }
533
+ async removeTaskFromBodyOfWork(taskId) {
534
+ return this.proxy('remove_task_from_body_of_work', { task_id: taskId });
535
+ }
536
+ async activateBodyOfWork(bodyOfWorkId) {
537
+ return this.proxy('activate_body_of_work', { body_of_work_id: bodyOfWorkId });
538
+ }
539
+ async addTaskDependency(bodyOfWorkId, taskId, dependsOnTaskId) {
540
+ return this.proxy('add_task_dependency', {
541
+ body_of_work_id: bodyOfWorkId,
542
+ task_id: taskId,
543
+ depends_on_task_id: dependsOnTaskId
544
+ });
545
+ }
546
+ async removeTaskDependency(taskId, dependsOnTaskId) {
547
+ return this.proxy('remove_task_dependency', {
548
+ task_id: taskId,
549
+ depends_on_task_id: dependsOnTaskId
550
+ });
551
+ }
552
+ async getTaskDependencies(params) {
553
+ return this.proxy('get_task_dependencies', params);
554
+ }
555
+ async getNextBodyOfWorkTask(bodyOfWorkId) {
556
+ return this.proxy('get_next_body_of_work_task', { body_of_work_id: bodyOfWorkId });
557
+ }
558
+ // ============================================================================
559
+ // Git issues endpoints
560
+ // ============================================================================
561
+ async addGitIssue(projectId, params, sessionId) {
562
+ return this.proxy('add_git_issue', {
563
+ project_id: projectId,
564
+ ...params
565
+ }, sessionId ? { session_id: sessionId, persona: null, instance_id: '' } : undefined);
566
+ }
567
+ async resolveGitIssue(gitIssueId, params, sessionId) {
568
+ return this.proxy('resolve_git_issue', {
569
+ git_issue_id: gitIssueId,
570
+ ...params
571
+ }, sessionId ? { session_id: sessionId, persona: null, instance_id: '' } : undefined);
572
+ }
573
+ async getGitIssues(projectId, params) {
574
+ return this.proxy('get_git_issues', {
575
+ project_id: projectId,
576
+ ...params
577
+ });
578
+ }
579
+ async deleteGitIssue(gitIssueId) {
580
+ return this.proxy('delete_git_issue', { git_issue_id: gitIssueId });
581
+ }
582
+ // ============================================================================
583
+ // Cost tracking endpoints
584
+ // ============================================================================
585
+ async getCostSummary(projectId, params) {
586
+ return this.proxy('get_cost_summary', {
587
+ project_id: projectId,
588
+ ...params
589
+ });
590
+ }
591
+ async getCostAlerts() {
592
+ return this.proxy('get_cost_alerts', {});
593
+ }
594
+ async addCostAlert(params) {
595
+ return this.proxy('add_cost_alert', params);
596
+ }
597
+ async updateCostAlert(alertId, updates) {
598
+ return this.proxy('update_cost_alert', {
599
+ alert_id: alertId,
600
+ ...updates
601
+ });
602
+ }
603
+ async deleteCostAlert(alertId) {
604
+ return this.proxy('delete_cost_alert', { alert_id: alertId });
605
+ }
606
+ async getTaskCosts(projectId, limit) {
607
+ return this.proxy('get_task_costs', {
608
+ project_id: projectId,
609
+ limit
610
+ });
611
+ }
612
+ async getTokenUsage() {
613
+ return this.proxy('get_token_usage', {});
614
+ }
615
+ // ============================================================================
616
+ // Batch operation endpoints
617
+ // ============================================================================
618
+ async batchUpdateTasks(updates) {
619
+ return this.proxy('batch_update_tasks', { updates });
620
+ }
621
+ async batchCompleteTasks(completions) {
622
+ return this.proxy('batch_complete_tasks', { completions });
623
+ }
624
+ // ============================================================================
625
+ // Deployment requirements and scheduling endpoints
626
+ // ============================================================================
627
+ async addDeploymentRequirement(projectId, params) {
628
+ return this.proxy('add_deployment_requirement', {
629
+ project_id: projectId,
630
+ ...params
631
+ });
632
+ }
633
+ async getDeploymentRequirements(projectId, params) {
634
+ return this.proxy('get_deployment_requirements', {
635
+ project_id: projectId,
636
+ ...params
637
+ });
638
+ }
639
+ async completeDeploymentRequirement(requirementId) {
640
+ return this.proxy('complete_deployment_requirement', { requirement_id: requirementId });
641
+ }
642
+ async scheduleDeployment(projectId, params) {
643
+ return this.proxy('schedule_deployment', {
644
+ project_id: projectId,
645
+ ...params
646
+ });
647
+ }
648
+ async getScheduledDeployments(projectId, includeDisabled) {
649
+ return this.proxy('get_scheduled_deployments', {
650
+ project_id: projectId,
651
+ include_disabled: includeDisabled
652
+ });
653
+ }
654
+ async updateScheduledDeployment(scheduleId, updates) {
655
+ return this.proxy('update_scheduled_deployment', {
656
+ schedule_id: scheduleId,
657
+ ...updates
658
+ });
659
+ }
660
+ async deleteScheduledDeployment(scheduleId) {
661
+ return this.proxy('delete_scheduled_deployment', { schedule_id: scheduleId });
662
+ }
663
+ async triggerScheduledDeployment(scheduleId, sessionId) {
664
+ return this.proxy('trigger_scheduled_deployment', { schedule_id: scheduleId }, sessionId ? {
665
+ session_id: sessionId,
666
+ persona: null,
667
+ instance_id: ''
668
+ } : undefined);
669
+ }
670
+ async checkDueDeployments(projectId) {
671
+ return this.proxy('check_due_deployments', { project_id: projectId });
672
+ }
673
+ // ============================================================================
674
+ // Project README endpoint
675
+ // ============================================================================
676
+ async updateProjectReadme(projectId, readmeContent) {
677
+ return this.proxy('update_project_readme', {
678
+ project_id: projectId,
679
+ readme_content: readmeContent
680
+ });
681
+ }
682
+ }
683
+ // Singleton instance
684
+ let apiClient = null;
685
+ export function getApiClient() {
686
+ if (!apiClient) {
687
+ const apiKey = process.env.VIBESCOPE_API_KEY;
688
+ if (!apiKey) {
689
+ throw new Error('VIBESCOPE_API_KEY environment variable is required');
690
+ }
691
+ apiClient = new VibescopeApiClient({ apiKey });
692
+ }
693
+ return apiClient;
694
+ }
695
+ export function initApiClient(config) {
696
+ apiClient = new VibescopeApiClient(config);
697
+ return apiClient;
698
+ }