@vibescope/mcp-server 0.3.0 → 0.3.3

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 (154) hide show
  1. package/dist/api-client/blockers.d.ts +46 -0
  2. package/dist/api-client/blockers.js +43 -0
  3. package/dist/api-client/cost.d.ts +112 -0
  4. package/dist/api-client/cost.js +76 -0
  5. package/dist/api-client/decisions.d.ts +55 -0
  6. package/dist/api-client/decisions.js +32 -0
  7. package/dist/api-client/discovery.d.ts +62 -0
  8. package/dist/api-client/discovery.js +21 -0
  9. package/dist/api-client/ideas.d.ts +75 -0
  10. package/dist/api-client/ideas.js +36 -0
  11. package/dist/api-client/index.d.ts +749 -0
  12. package/dist/api-client/index.js +291 -0
  13. package/dist/api-client/project.d.ts +132 -0
  14. package/dist/api-client/project.js +45 -0
  15. package/dist/api-client/session.d.ts +163 -0
  16. package/dist/api-client/session.js +52 -0
  17. package/dist/api-client/tasks.d.ts +328 -0
  18. package/dist/api-client/tasks.js +132 -0
  19. package/dist/api-client/types.d.ts +25 -0
  20. package/dist/api-client/types.js +4 -0
  21. package/dist/api-client/worktrees.d.ts +33 -0
  22. package/dist/api-client/worktrees.js +26 -0
  23. package/dist/api-client.d.ts +9 -0
  24. package/dist/api-client.js +104 -25
  25. package/dist/cli-init.d.ts +17 -0
  26. package/dist/cli-init.js +445 -0
  27. package/dist/cli.js +0 -0
  28. package/dist/handlers/cloud-agents.d.ts +21 -0
  29. package/dist/handlers/cloud-agents.js +91 -0
  30. package/dist/handlers/discovery.js +7 -0
  31. package/dist/handlers/index.d.ts +1 -0
  32. package/dist/handlers/index.js +3 -0
  33. package/dist/handlers/session.js +3 -1
  34. package/dist/handlers/tasks.js +10 -12
  35. package/dist/handlers/types.d.ts +2 -1
  36. package/dist/handlers/validation.js +5 -1
  37. package/dist/index.js +8 -3
  38. package/dist/token-tracking.js +2 -2
  39. package/dist/tools/blockers.d.ts +13 -0
  40. package/dist/tools/blockers.js +119 -0
  41. package/dist/tools/bodies-of-work.d.ts +19 -0
  42. package/dist/tools/bodies-of-work.js +280 -0
  43. package/dist/tools/cloud-agents.d.ts +9 -0
  44. package/dist/tools/cloud-agents.js +67 -0
  45. package/dist/tools/connectors.d.ts +14 -0
  46. package/dist/tools/connectors.js +188 -0
  47. package/dist/tools/cost.d.ts +11 -0
  48. package/dist/tools/cost.js +108 -0
  49. package/dist/tools/decisions.d.ts +12 -0
  50. package/dist/tools/decisions.js +108 -0
  51. package/dist/tools/deployment.d.ts +24 -0
  52. package/dist/tools/deployment.js +439 -0
  53. package/dist/tools/discovery.d.ts +10 -0
  54. package/dist/tools/discovery.js +73 -0
  55. package/dist/tools/fallback.d.ts +11 -0
  56. package/dist/tools/fallback.js +108 -0
  57. package/dist/tools/file-checkouts.d.ts +13 -0
  58. package/dist/tools/file-checkouts.js +141 -0
  59. package/dist/tools/findings.d.ts +13 -0
  60. package/dist/tools/findings.js +98 -0
  61. package/dist/tools/git-issues.d.ts +11 -0
  62. package/dist/tools/git-issues.js +127 -0
  63. package/dist/tools/ideas.d.ts +13 -0
  64. package/dist/tools/ideas.js +159 -0
  65. package/dist/tools/index.d.ts +71 -0
  66. package/dist/tools/index.js +98 -0
  67. package/dist/tools/milestones.d.ts +12 -0
  68. package/dist/tools/milestones.js +115 -0
  69. package/dist/tools/organizations.d.ts +17 -0
  70. package/dist/tools/organizations.js +221 -0
  71. package/dist/tools/progress.d.ts +9 -0
  72. package/dist/tools/progress.js +70 -0
  73. package/dist/tools/project.d.ts +13 -0
  74. package/dist/tools/project.js +199 -0
  75. package/dist/tools/requests.d.ts +10 -0
  76. package/dist/tools/requests.js +65 -0
  77. package/dist/tools/roles.d.ts +11 -0
  78. package/dist/tools/roles.js +109 -0
  79. package/dist/tools/session.d.ts +15 -0
  80. package/dist/tools/session.js +178 -0
  81. package/dist/tools/sprints.d.ts +18 -0
  82. package/dist/tools/sprints.js +295 -0
  83. package/dist/tools/tasks.d.ts +27 -0
  84. package/dist/tools/tasks.js +539 -0
  85. package/dist/tools/types.d.ts +7 -0
  86. package/dist/tools/types.js +6 -0
  87. package/dist/tools/validation.d.ts +10 -0
  88. package/dist/tools/validation.js +72 -0
  89. package/dist/tools/worktrees.d.ts +9 -0
  90. package/dist/tools/worktrees.js +63 -0
  91. package/dist/utils.d.ts +66 -0
  92. package/dist/utils.js +102 -0
  93. package/docs/TOOLS.md +55 -2
  94. package/package.json +5 -3
  95. package/scripts/generate-docs.ts +1 -1
  96. package/src/api-client/blockers.ts +86 -0
  97. package/src/api-client/cost.ts +185 -0
  98. package/src/api-client/decisions.ts +87 -0
  99. package/src/api-client/discovery.ts +81 -0
  100. package/src/api-client/ideas.ts +112 -0
  101. package/src/api-client/index.ts +378 -0
  102. package/src/api-client/project.ts +179 -0
  103. package/src/api-client/session.ts +220 -0
  104. package/src/api-client/tasks.ts +450 -0
  105. package/src/api-client/types.ts +32 -0
  106. package/src/api-client/worktrees.ts +53 -0
  107. package/src/api-client.test.ts +136 -9
  108. package/src/api-client.ts +125 -27
  109. package/src/cli-init.ts +504 -0
  110. package/src/handlers/__test-utils__.ts +2 -0
  111. package/src/handlers/cloud-agents.ts +138 -0
  112. package/src/handlers/discovery.ts +7 -0
  113. package/src/handlers/index.ts +3 -0
  114. package/src/handlers/session.ts +3 -1
  115. package/src/handlers/tasks.ts +10 -12
  116. package/src/handlers/tool-categories.test.ts +1 -1
  117. package/src/handlers/types.ts +2 -1
  118. package/src/handlers/validation.ts +6 -1
  119. package/src/index.test.ts +2 -2
  120. package/src/index.ts +8 -2
  121. package/src/token-tracking.ts +3 -2
  122. package/src/tools/blockers.ts +122 -0
  123. package/src/tools/bodies-of-work.ts +283 -0
  124. package/src/tools/cloud-agents.ts +70 -0
  125. package/src/tools/connectors.ts +191 -0
  126. package/src/tools/cost.ts +111 -0
  127. package/src/tools/decisions.ts +111 -0
  128. package/src/tools/deployment.ts +442 -0
  129. package/src/tools/discovery.ts +76 -0
  130. package/src/tools/fallback.ts +111 -0
  131. package/src/tools/file-checkouts.ts +145 -0
  132. package/src/tools/findings.ts +101 -0
  133. package/src/tools/git-issues.ts +130 -0
  134. package/src/tools/ideas.ts +162 -0
  135. package/src/tools/index.ts +131 -0
  136. package/src/tools/milestones.ts +118 -0
  137. package/src/tools/organizations.ts +224 -0
  138. package/src/tools/progress.ts +73 -0
  139. package/src/tools/project.ts +202 -0
  140. package/src/tools/requests.ts +68 -0
  141. package/src/tools/roles.ts +112 -0
  142. package/src/tools/session.ts +181 -0
  143. package/src/tools/sprints.ts +298 -0
  144. package/src/tools/tasks.ts +542 -0
  145. package/src/tools/tools.test.ts +222 -0
  146. package/src/tools/types.ts +9 -0
  147. package/src/tools/validation.ts +75 -0
  148. package/src/tools/worktrees.ts +66 -0
  149. package/src/tools.test.ts +1 -1
  150. package/src/utils.test.ts +229 -0
  151. package/src/utils.ts +117 -0
  152. package/dist/tools.d.ts +0 -2
  153. package/dist/tools.js +0 -3602
  154. package/src/tools.ts +0 -3607
@@ -0,0 +1,450 @@
1
+ /**
2
+ * Tasks API Methods
3
+ *
4
+ * Methods for task management:
5
+ * - getTasks: List tasks for a project
6
+ * - createTask: Create a new task
7
+ * - getNextTask: Get highest priority pending task
8
+ * - getTask: Get a single task
9
+ * - getTaskById: Get task with optional subtasks/milestones
10
+ * - searchTasks: Search tasks by text query
11
+ * - getTasksByPriority: Get tasks filtered by priority
12
+ * - getRecentTasks: Get recently created/modified tasks
13
+ * - getTaskStats: Get task statistics
14
+ * - updateTask: Update task details
15
+ * - completeTask: Mark task as completed
16
+ * - deleteTask: Delete a task
17
+ * - releaseTask: Release task back to pending
18
+ * - cancelTask: Cancel a task
19
+ * - addTaskReference: Add reference URL to task
20
+ * - removeTaskReference: Remove reference from task
21
+ * - batchUpdateTasks: Update multiple tasks
22
+ * - batchCompleteTasks: Complete multiple tasks
23
+ */
24
+
25
+ import type { ApiResponse, RequestFn, ProxyFn } from './types.js';
26
+
27
+ export interface TasksMethods {
28
+ getTasks(projectId: string, params?: {
29
+ status?: string;
30
+ limit?: number;
31
+ offset?: number;
32
+ include_subtasks?: boolean;
33
+ search_query?: string;
34
+ include_metadata?: boolean;
35
+ }): Promise<ApiResponse<{
36
+ tasks: Array<{
37
+ id: string;
38
+ title: string;
39
+ description?: string;
40
+ priority: number;
41
+ status: string;
42
+ progress_percentage?: number;
43
+ estimated_minutes?: number;
44
+ started_at?: string;
45
+ completed_at?: string;
46
+ parent_task_id?: string;
47
+ }>;
48
+ total_count: number;
49
+ has_more: boolean;
50
+ }>>;
51
+
52
+ createTask(projectId: string, params: {
53
+ title: string;
54
+ description?: string;
55
+ priority?: number;
56
+ estimated_minutes?: number;
57
+ blocking?: boolean;
58
+ session_id?: string;
59
+ task_type?: string;
60
+ }): Promise<ApiResponse<{
61
+ success: boolean;
62
+ task_id: string;
63
+ title: string;
64
+ blocking?: boolean;
65
+ message?: string;
66
+ }>>;
67
+
68
+ getNextTask(projectId: string, sessionId?: string): Promise<ApiResponse<{
69
+ task?: {
70
+ id: string;
71
+ title: string;
72
+ description?: string;
73
+ priority: number;
74
+ estimated_minutes?: number;
75
+ blocking?: boolean;
76
+ } | null;
77
+ blocking_task?: boolean;
78
+ deployment_blocks_tasks?: boolean;
79
+ deployment?: {
80
+ id: string;
81
+ status: string;
82
+ env: string;
83
+ };
84
+ awaiting_validation?: Array<{
85
+ id: string;
86
+ title: string;
87
+ }>;
88
+ validation_priority?: string;
89
+ all_claimed?: boolean;
90
+ is_subtask?: boolean;
91
+ suggested_activity?: string;
92
+ directive?: string;
93
+ message?: string;
94
+ action?: string;
95
+ }>>;
96
+
97
+ getTask(taskId: string): Promise<ApiResponse<{
98
+ task: {
99
+ id: string;
100
+ title: string;
101
+ description?: string;
102
+ priority: number;
103
+ status: string;
104
+ progress_percentage?: number;
105
+ estimated_minutes?: number;
106
+ started_at?: string;
107
+ completed_at?: string;
108
+ git_branch?: string;
109
+ blocking?: boolean;
110
+ references?: Array<{ url: string; label?: string }>;
111
+ parent_task_id?: string;
112
+ working_agent_session_id?: string;
113
+ };
114
+ }>>;
115
+
116
+ getTaskById(taskId: string, params?: {
117
+ include_subtasks?: boolean;
118
+ include_milestones?: boolean;
119
+ }): Promise<ApiResponse<{
120
+ task: {
121
+ id: string;
122
+ title: string;
123
+ description?: string;
124
+ priority: number;
125
+ status: string;
126
+ progress_percentage?: number;
127
+ estimated_minutes?: number;
128
+ started_at?: string;
129
+ completed_at?: string;
130
+ git_branch?: string;
131
+ references?: Array<{ url: string; label?: string }>;
132
+ };
133
+ subtasks?: Array<{
134
+ id: string;
135
+ title: string;
136
+ status: string;
137
+ progress_percentage?: number;
138
+ }>;
139
+ milestones?: Array<{
140
+ id: string;
141
+ title: string;
142
+ status: string;
143
+ order_index: number;
144
+ }>;
145
+ }>>;
146
+
147
+ searchTasks(projectId: string, params: {
148
+ query: string;
149
+ status?: string[];
150
+ limit?: number;
151
+ offset?: number;
152
+ }): Promise<ApiResponse<{
153
+ tasks: Array<{
154
+ id: string;
155
+ title: string;
156
+ status: string;
157
+ priority: number;
158
+ snippet?: string;
159
+ }>;
160
+ total_matches: number;
161
+ hint?: string;
162
+ }>>;
163
+
164
+ getTasksByPriority(projectId: string, params?: {
165
+ priority?: number;
166
+ priority_max?: number;
167
+ status?: string;
168
+ limit?: number;
169
+ offset?: number;
170
+ }): Promise<ApiResponse<{
171
+ tasks: Array<{
172
+ id: string;
173
+ title: string;
174
+ priority: number;
175
+ status: string;
176
+ estimated_minutes?: number;
177
+ }>;
178
+ total_count: number;
179
+ }>>;
180
+
181
+ getRecentTasks(projectId: string, params?: {
182
+ order?: 'newest' | 'oldest';
183
+ status?: string;
184
+ limit?: number;
185
+ offset?: number;
186
+ }): Promise<ApiResponse<{
187
+ tasks: Array<{
188
+ id: string;
189
+ title: string;
190
+ status: string;
191
+ priority: number;
192
+ created_at: string;
193
+ age?: string;
194
+ }>;
195
+ total_count: number;
196
+ }>>;
197
+
198
+ getTaskStats(projectId: string): Promise<ApiResponse<{
199
+ total: number;
200
+ by_status: {
201
+ backlog: number;
202
+ pending: number;
203
+ in_progress: number;
204
+ completed: number;
205
+ cancelled: number;
206
+ };
207
+ by_priority: {
208
+ 1: number;
209
+ 2: number;
210
+ 3: number;
211
+ 4: number;
212
+ 5: number;
213
+ };
214
+ awaiting_validation: number;
215
+ oldest_pending_days: number | null;
216
+ }>>;
217
+
218
+ updateTask(taskId: string, updates: {
219
+ title?: string;
220
+ description?: string;
221
+ priority?: number;
222
+ status?: string;
223
+ progress_percentage?: number;
224
+ progress_note?: string;
225
+ estimated_minutes?: number;
226
+ git_branch?: string;
227
+ worktree_path?: string;
228
+ session_id?: string;
229
+ }): Promise<ApiResponse<{
230
+ success: boolean;
231
+ task_id: string;
232
+ git_workflow?: {
233
+ workflow: string;
234
+ base_branch: string;
235
+ suggested_branch: string;
236
+ worktree_required: boolean;
237
+ };
238
+ worktree_setup?: {
239
+ message: string;
240
+ commands: string[];
241
+ worktree_path: string;
242
+ branch_name: string;
243
+ cleanup_command: string;
244
+ };
245
+ next_step?: string;
246
+ }>>;
247
+
248
+ completeTask(taskId: string, params: {
249
+ summary?: string;
250
+ session_id?: string;
251
+ }): Promise<ApiResponse<{
252
+ success: boolean;
253
+ directive: string;
254
+ auto_continue: boolean;
255
+ completed_task_id: string;
256
+ next_task?: {
257
+ id: string;
258
+ title: string;
259
+ priority: number;
260
+ estimated_minutes?: number;
261
+ } | null;
262
+ context?: {
263
+ validation?: number;
264
+ blockers?: number;
265
+ deployment?: string;
266
+ worktree_path?: string;
267
+ };
268
+ next_action: string;
269
+ warnings?: string[];
270
+ }>>;
271
+
272
+ deleteTask(taskId: string): Promise<ApiResponse<{
273
+ success: boolean;
274
+ deleted_id: string;
275
+ }>>;
276
+
277
+ releaseTask(taskId: string, params?: {
278
+ reason?: string;
279
+ session_id?: string;
280
+ }): Promise<ApiResponse<{
281
+ success: boolean;
282
+ task_id: string;
283
+ message: string;
284
+ reason?: string;
285
+ hint: string;
286
+ }>>;
287
+
288
+ cancelTask(taskId: string, params?: {
289
+ cancelled_reason?: 'pr_closed' | 'superseded' | 'user_cancelled' | 'validation_failed' | 'obsolete' | 'blocked';
290
+ cancellation_note?: string;
291
+ session_id?: string;
292
+ }): Promise<ApiResponse<{
293
+ success: boolean;
294
+ task_id: string;
295
+ cancelled_reason: string | null;
296
+ message: string;
297
+ }>>;
298
+
299
+ addTaskReference(taskId: string, url: string, label?: string): Promise<ApiResponse<{
300
+ success: boolean;
301
+ task_id: string;
302
+ reference: { url: string; label?: string };
303
+ }>>;
304
+
305
+ removeTaskReference(taskId: string, url: string): Promise<ApiResponse<{
306
+ success: boolean;
307
+ task_id: string;
308
+ }>>;
309
+
310
+ batchUpdateTasks(updates: Array<{
311
+ task_id: string;
312
+ priority?: number;
313
+ status?: string;
314
+ progress_percentage?: number;
315
+ }>): Promise<ApiResponse<{
316
+ success: boolean;
317
+ updated_count: number;
318
+ results: Array<{ task_id: string; success: boolean; error?: string }>;
319
+ }>>;
320
+
321
+ batchCompleteTasks(completions: Array<{
322
+ task_id: string;
323
+ summary?: string;
324
+ }>): Promise<ApiResponse<{
325
+ success: boolean;
326
+ completed_count: number;
327
+ results: Array<{ task_id: string; success: boolean; error?: string }>;
328
+ }>>;
329
+ }
330
+
331
+ export function createTasksMethods(request: RequestFn, proxy: ProxyFn): TasksMethods {
332
+ return {
333
+ async getTasks(projectId, params) {
334
+ const queryParams = new URLSearchParams();
335
+ if (params?.status) queryParams.set('status', params.status);
336
+ if (params?.limit) queryParams.set('limit', params.limit.toString());
337
+ if (params?.offset) queryParams.set('offset', params.offset.toString());
338
+ if (params?.include_subtasks) queryParams.set('include_subtasks', 'true');
339
+ if (params?.search_query) queryParams.set('search_query', params.search_query);
340
+ if (params?.include_metadata) queryParams.set('include_metadata', 'true');
341
+ const query = queryParams.toString();
342
+ const url = `/api/mcp/projects/${projectId}/tasks${query ? `?${query}` : ''}`;
343
+ return request('GET', url);
344
+ },
345
+
346
+ async createTask(projectId, params) {
347
+ return request('POST', `/api/mcp/projects/${projectId}/tasks`, params);
348
+ },
349
+
350
+ async getNextTask(projectId, sessionId) {
351
+ const url = sessionId
352
+ ? `/api/mcp/projects/${projectId}/next-task?session_id=${sessionId}`
353
+ : `/api/mcp/projects/${projectId}/next-task`;
354
+ return request('GET', url);
355
+ },
356
+
357
+ async getTask(taskId) {
358
+ return request('GET', `/api/mcp/tasks/${taskId}`);
359
+ },
360
+
361
+ async getTaskById(taskId, params) {
362
+ return proxy('get_task', {
363
+ task_id: taskId,
364
+ include_subtasks: params?.include_subtasks,
365
+ include_milestones: params?.include_milestones,
366
+ });
367
+ },
368
+
369
+ async searchTasks(projectId, params) {
370
+ return proxy('search_tasks', {
371
+ project_id: projectId,
372
+ query: params.query,
373
+ status: params.status,
374
+ limit: params.limit,
375
+ offset: params.offset,
376
+ });
377
+ },
378
+
379
+ async getTasksByPriority(projectId, params) {
380
+ return proxy('get_tasks_by_priority', {
381
+ project_id: projectId,
382
+ priority: params?.priority,
383
+ priority_max: params?.priority_max,
384
+ status: params?.status,
385
+ limit: params?.limit,
386
+ offset: params?.offset,
387
+ });
388
+ },
389
+
390
+ async getRecentTasks(projectId, params) {
391
+ return proxy('get_recent_tasks', {
392
+ project_id: projectId,
393
+ order: params?.order,
394
+ status: params?.status,
395
+ limit: params?.limit,
396
+ offset: params?.offset,
397
+ });
398
+ },
399
+
400
+ async getTaskStats(projectId) {
401
+ return proxy('get_task_stats', { project_id: projectId });
402
+ },
403
+
404
+ async updateTask(taskId, updates) {
405
+ return request('PATCH', `/api/mcp/tasks/${taskId}`, updates);
406
+ },
407
+
408
+ async completeTask(taskId, params) {
409
+ return proxy('complete_task', {
410
+ task_id: taskId,
411
+ summary: params.summary,
412
+ }, params.session_id ? { session_id: params.session_id } : undefined);
413
+ },
414
+
415
+ async deleteTask(taskId) {
416
+ return request('DELETE', `/api/mcp/tasks/${taskId}`);
417
+ },
418
+
419
+ async releaseTask(taskId, params) {
420
+ return proxy('release_task', {
421
+ task_id: taskId,
422
+ reason: params?.reason,
423
+ }, params?.session_id ? { session_id: params.session_id } : undefined);
424
+ },
425
+
426
+ async cancelTask(taskId, params) {
427
+ return proxy('cancel_task', {
428
+ task_id: taskId,
429
+ cancelled_reason: params?.cancelled_reason,
430
+ cancellation_note: params?.cancellation_note,
431
+ }, params?.session_id ? { session_id: params.session_id } : undefined);
432
+ },
433
+
434
+ async addTaskReference(taskId, url, label) {
435
+ return proxy('add_task_reference', { task_id: taskId, url, label });
436
+ },
437
+
438
+ async removeTaskReference(taskId, url) {
439
+ return proxy('remove_task_reference', { task_id: taskId, url });
440
+ },
441
+
442
+ async batchUpdateTasks(updates) {
443
+ return proxy('batch_update_tasks', { updates });
444
+ },
445
+
446
+ async batchCompleteTasks(completions) {
447
+ return proxy('batch_complete_tasks', { completions });
448
+ }
449
+ };
450
+ }
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Shared Types for Vibescope API Client
3
+ */
4
+
5
+ export interface RetryConfig {
6
+ maxRetries?: number;
7
+ baseDelayMs?: number;
8
+ maxDelayMs?: number;
9
+ retryStatusCodes?: number[];
10
+ }
11
+
12
+ export interface ApiClientConfig {
13
+ apiKey: string;
14
+ baseUrl?: string;
15
+ retry?: RetryConfig;
16
+ }
17
+
18
+ export interface ApiResponse<T> {
19
+ ok: boolean;
20
+ status: number;
21
+ data?: T;
22
+ error?: string;
23
+ }
24
+
25
+ // Request function type that domain modules depend on
26
+ export type RequestFn = <T>(method: string, path: string, body?: unknown) => Promise<ApiResponse<T>>;
27
+
28
+ // Proxy function type for generic operations
29
+ export type ProxyFn = <T>(operation: string, args: Record<string, unknown>, sessionContext?: {
30
+ session_id?: string;
31
+ project_id?: string;
32
+ }) => Promise<ApiResponse<T>>;
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Worktrees API Methods
3
+ *
4
+ * Methods for git worktree management:
5
+ * - getStaleWorktrees: List stale worktrees for cleanup
6
+ * - clearWorktreePath: Clear worktree path from a task
7
+ */
8
+
9
+ import type { ApiResponse, RequestFn } from './types.js';
10
+
11
+ export interface WorktreesMethods {
12
+ getStaleWorktrees(projectId: string, params?: {
13
+ hostname?: string;
14
+ limit?: number;
15
+ offset?: number;
16
+ }): Promise<ApiResponse<{
17
+ stale_worktrees: Array<{
18
+ task_id: string;
19
+ task_title: string;
20
+ worktree_path: string;
21
+ worktree_hostname?: string | null;
22
+ last_heartbeat?: string;
23
+ session_status?: string;
24
+ }>;
25
+ total_count: number;
26
+ has_more: boolean;
27
+ cleanup_instructions: string;
28
+ }>>;
29
+
30
+ clearWorktreePath(taskId: string): Promise<ApiResponse<{
31
+ success: boolean;
32
+ task_id: string;
33
+ message: string;
34
+ }>>;
35
+ }
36
+
37
+ export function createWorktreesMethods(request: RequestFn): WorktreesMethods {
38
+ return {
39
+ async getStaleWorktrees(projectId, params) {
40
+ const queryParams = new URLSearchParams();
41
+ if (params?.hostname) queryParams.set('hostname', params.hostname);
42
+ if (params?.limit) queryParams.set('limit', params.limit.toString());
43
+ if (params?.offset) queryParams.set('offset', params.offset.toString());
44
+ const query = queryParams.toString();
45
+ const url = `/api/mcp/projects/${projectId}/worktrees/stale${query ? `?${query}` : ''}`;
46
+ return request('GET', url);
47
+ },
48
+
49
+ async clearWorktreePath(taskId) {
50
+ return request('POST', `/api/mcp/tasks/${taskId}/clear-worktree`);
51
+ }
52
+ };
53
+ }