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