@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.
- package/README.md +113 -98
- package/dist/api-client.d.ts +1169 -0
- package/dist/api-client.js +713 -0
- package/dist/cli.d.ts +1 -6
- package/dist/cli.js +39 -240
- package/dist/config/tool-categories.d.ts +31 -0
- package/dist/config/tool-categories.js +253 -0
- package/dist/handlers/blockers.js +57 -58
- package/dist/handlers/bodies-of-work.d.ts +2 -0
- package/dist/handlers/bodies-of-work.js +108 -477
- package/dist/handlers/cost.d.ts +1 -0
- package/dist/handlers/cost.js +35 -113
- package/dist/handlers/decisions.d.ts +2 -0
- package/dist/handlers/decisions.js +28 -27
- package/dist/handlers/deployment.js +113 -828
- package/dist/handlers/discovery.d.ts +3 -0
- package/dist/handlers/discovery.js +26 -627
- package/dist/handlers/fallback.d.ts +2 -0
- package/dist/handlers/fallback.js +56 -142
- package/dist/handlers/findings.d.ts +8 -1
- package/dist/handlers/findings.js +65 -68
- package/dist/handlers/git-issues.d.ts +9 -13
- package/dist/handlers/git-issues.js +80 -225
- package/dist/handlers/ideas.d.ts +3 -0
- package/dist/handlers/ideas.js +53 -134
- package/dist/handlers/index.d.ts +2 -0
- package/dist/handlers/index.js +6 -0
- package/dist/handlers/milestones.d.ts +2 -0
- package/dist/handlers/milestones.js +51 -98
- package/dist/handlers/organizations.js +79 -275
- package/dist/handlers/progress.d.ts +2 -0
- package/dist/handlers/progress.js +25 -123
- package/dist/handlers/project.js +42 -221
- package/dist/handlers/requests.d.ts +2 -0
- package/dist/handlers/requests.js +23 -83
- package/dist/handlers/session.js +119 -590
- package/dist/handlers/sprints.d.ts +32 -0
- package/dist/handlers/sprints.js +275 -0
- package/dist/handlers/tasks.d.ts +7 -10
- package/dist/handlers/tasks.js +245 -894
- package/dist/handlers/tool-docs.d.ts +9 -0
- package/dist/handlers/tool-docs.js +904 -0
- package/dist/handlers/types.d.ts +11 -3
- package/dist/handlers/validation.d.ts +1 -1
- package/dist/handlers/validation.js +38 -153
- package/dist/index.js +493 -162
- package/dist/knowledge.js +106 -9
- package/dist/tools.js +34 -4
- package/dist/validators.d.ts +21 -0
- package/dist/validators.js +91 -0
- package/package.json +2 -3
- package/src/api-client.ts +1822 -0
- package/src/cli.test.ts +128 -302
- package/src/cli.ts +41 -285
- package/src/handlers/__test-setup__.ts +215 -0
- package/src/handlers/__test-utils__.ts +4 -134
- package/src/handlers/blockers.test.ts +114 -124
- package/src/handlers/blockers.ts +68 -70
- package/src/handlers/bodies-of-work.test.ts +236 -831
- package/src/handlers/bodies-of-work.ts +210 -525
- package/src/handlers/cost.test.ts +149 -113
- package/src/handlers/cost.ts +44 -132
- package/src/handlers/decisions.test.ts +111 -209
- package/src/handlers/decisions.ts +35 -27
- package/src/handlers/deployment.test.ts +193 -239
- package/src/handlers/deployment.ts +143 -896
- package/src/handlers/discovery.test.ts +20 -67
- package/src/handlers/discovery.ts +29 -714
- package/src/handlers/fallback.test.ts +206 -361
- package/src/handlers/fallback.ts +81 -156
- package/src/handlers/findings.test.ts +229 -320
- package/src/handlers/findings.ts +76 -64
- package/src/handlers/git-issues.test.ts +623 -0
- package/src/handlers/git-issues.ts +174 -0
- package/src/handlers/ideas.test.ts +229 -343
- package/src/handlers/ideas.ts +69 -143
- package/src/handlers/index.ts +6 -0
- package/src/handlers/milestones.test.ts +167 -281
- package/src/handlers/milestones.ts +54 -93
- package/src/handlers/organizations.test.ts +275 -467
- package/src/handlers/organizations.ts +84 -294
- package/src/handlers/progress.test.ts +112 -218
- package/src/handlers/progress.ts +29 -142
- package/src/handlers/project.test.ts +203 -226
- package/src/handlers/project.ts +48 -238
- package/src/handlers/requests.test.ts +74 -342
- package/src/handlers/requests.ts +25 -83
- package/src/handlers/session.test.ts +276 -206
- package/src/handlers/session.ts +136 -662
- package/src/handlers/sprints.test.ts +711 -0
- package/src/handlers/sprints.ts +510 -0
- package/src/handlers/tasks.test.ts +669 -353
- package/src/handlers/tasks.ts +263 -1015
- package/src/handlers/tool-docs.ts +1024 -0
- package/src/handlers/types.ts +12 -4
- package/src/handlers/validation.test.ts +237 -568
- package/src/handlers/validation.ts +43 -167
- package/src/index.ts +493 -186
- package/src/tools.ts +2532 -0
- package/src/validators.test.ts +223 -223
- package/src/validators.ts +127 -0
- package/tsconfig.json +1 -1
- package/vitest.config.ts +14 -13
- package/dist/cli.test.d.ts +0 -1
- package/dist/cli.test.js +0 -367
- package/dist/handlers/__test-utils__.d.ts +0 -72
- package/dist/handlers/__test-utils__.js +0 -176
- package/dist/handlers/checkouts.d.ts +0 -37
- package/dist/handlers/checkouts.js +0 -377
- package/dist/handlers/knowledge-query.d.ts +0 -22
- package/dist/handlers/knowledge-query.js +0 -253
- package/dist/handlers/knowledge.d.ts +0 -12
- package/dist/handlers/knowledge.js +0 -108
- package/dist/handlers/roles.d.ts +0 -30
- package/dist/handlers/roles.js +0 -281
- package/dist/handlers/tasks.test.d.ts +0 -1
- package/dist/handlers/tasks.test.js +0 -431
- package/dist/utils.test.d.ts +0 -1
- package/dist/utils.test.js +0 -532
- package/dist/validators.test.d.ts +0 -1
- package/dist/validators.test.js +0 -176
- package/src/knowledge.ts +0 -132
- package/src/tmpclaude-0078-cwd +0 -1
- package/src/tmpclaude-0ee1-cwd +0 -1
- package/src/tmpclaude-2dd5-cwd +0 -1
- package/src/tmpclaude-344c-cwd +0 -1
- package/src/tmpclaude-3860-cwd +0 -1
- package/src/tmpclaude-4b63-cwd +0 -1
- package/src/tmpclaude-5c73-cwd +0 -1
- package/src/tmpclaude-5ee3-cwd +0 -1
- package/src/tmpclaude-6795-cwd +0 -1
- package/src/tmpclaude-709e-cwd +0 -1
- package/src/tmpclaude-9839-cwd +0 -1
- package/src/tmpclaude-d829-cwd +0 -1
- package/src/tmpclaude-e072-cwd +0 -1
- package/src/tmpclaude-f6ee-cwd +0 -1
- package/tmpclaude-0439-cwd +0 -1
- package/tmpclaude-132f-cwd +0 -1
- package/tmpclaude-15bb-cwd +0 -1
- package/tmpclaude-165a-cwd +0 -1
- package/tmpclaude-1ba9-cwd +0 -1
- package/tmpclaude-21a3-cwd +0 -1
- package/tmpclaude-2a38-cwd +0 -1
- package/tmpclaude-2adf-cwd +0 -1
- package/tmpclaude-2f56-cwd +0 -1
- package/tmpclaude-3626-cwd +0 -1
- package/tmpclaude-3727-cwd +0 -1
- package/tmpclaude-40bc-cwd +0 -1
- package/tmpclaude-436f-cwd +0 -1
- package/tmpclaude-4783-cwd +0 -1
- package/tmpclaude-4b6d-cwd +0 -1
- package/tmpclaude-4ba4-cwd +0 -1
- package/tmpclaude-51e6-cwd +0 -1
- package/tmpclaude-5ecf-cwd +0 -1
- package/tmpclaude-6f97-cwd +0 -1
- package/tmpclaude-7fb2-cwd +0 -1
- package/tmpclaude-825c-cwd +0 -1
- package/tmpclaude-8baf-cwd +0 -1
- package/tmpclaude-8d9f-cwd +0 -1
- package/tmpclaude-975c-cwd +0 -1
- package/tmpclaude-9983-cwd +0 -1
- package/tmpclaude-a045-cwd +0 -1
- package/tmpclaude-ac4a-cwd +0 -1
- package/tmpclaude-b593-cwd +0 -1
- package/tmpclaude-b891-cwd +0 -1
- package/tmpclaude-c032-cwd +0 -1
- package/tmpclaude-cf43-cwd +0 -1
- package/tmpclaude-d040-cwd +0 -1
- package/tmpclaude-dcdd-cwd +0 -1
- package/tmpclaude-dcee-cwd +0 -1
- package/tmpclaude-e16b-cwd +0 -1
- package/tmpclaude-ecd2-cwd +0 -1
- package/tmpclaude-f48d-cwd +0 -1
package/src/handlers/cost.ts
CHANGED
|
@@ -7,9 +7,11 @@
|
|
|
7
7
|
* - add_cost_alert
|
|
8
8
|
* - update_cost_alert
|
|
9
9
|
* - delete_cost_alert
|
|
10
|
+
* - get_task_costs
|
|
10
11
|
*/
|
|
11
12
|
|
|
12
13
|
import type { Handler, HandlerRegistry } from './types.js';
|
|
14
|
+
import { getApiClient } from '../api-client.js';
|
|
13
15
|
|
|
14
16
|
/**
|
|
15
17
|
* Get cost summary for a project (daily, weekly, or monthly)
|
|
@@ -21,8 +23,6 @@ export const getCostSummary: Handler = async (args, ctx) => {
|
|
|
21
23
|
limit?: number;
|
|
22
24
|
};
|
|
23
25
|
|
|
24
|
-
const { supabase } = ctx;
|
|
25
|
-
|
|
26
26
|
if (!project_id) {
|
|
27
27
|
return {
|
|
28
28
|
result: { error: 'project_id is required' },
|
|
@@ -30,45 +30,17 @@ export const getCostSummary: Handler = async (args, ctx) => {
|
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
const { data, error } = await supabase
|
|
37
|
-
.from(viewName)
|
|
38
|
-
.select('*')
|
|
39
|
-
.eq('project_id', project_id)
|
|
40
|
-
.order(period === 'daily' ? 'date' : period === 'weekly' ? 'week_start' : 'month_start', { ascending: false })
|
|
41
|
-
.limit(limit);
|
|
33
|
+
const apiClient = getApiClient();
|
|
34
|
+
const response = await apiClient.getCostSummary(project_id, { period, limit });
|
|
42
35
|
|
|
43
|
-
if (
|
|
36
|
+
if (!response.ok) {
|
|
44
37
|
return {
|
|
45
|
-
result: { error:
|
|
38
|
+
result: { error: response.error || 'Failed to get cost summary' },
|
|
46
39
|
isError: true,
|
|
47
40
|
};
|
|
48
41
|
}
|
|
49
42
|
|
|
50
|
-
|
|
51
|
-
const totals = (data || []).reduce(
|
|
52
|
-
(acc, row) => ({
|
|
53
|
-
sessions: acc.sessions + (row.session_count || 0),
|
|
54
|
-
tokens: acc.tokens + (row.total_tokens || 0),
|
|
55
|
-
calls: acc.calls + (row.total_calls || 0),
|
|
56
|
-
cost: acc.cost + parseFloat(row.estimated_cost_usd || '0'),
|
|
57
|
-
}),
|
|
58
|
-
{ sessions: 0, tokens: 0, calls: 0, cost: 0 }
|
|
59
|
-
);
|
|
60
|
-
|
|
61
|
-
return {
|
|
62
|
-
result: {
|
|
63
|
-
period,
|
|
64
|
-
project_id,
|
|
65
|
-
summary: data || [],
|
|
66
|
-
totals: {
|
|
67
|
-
...totals,
|
|
68
|
-
cost: Math.round(totals.cost * 100) / 100,
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
};
|
|
43
|
+
return { result: response.data };
|
|
72
44
|
};
|
|
73
45
|
|
|
74
46
|
/**
|
|
@@ -76,33 +48,18 @@ export const getCostSummary: Handler = async (args, ctx) => {
|
|
|
76
48
|
*/
|
|
77
49
|
export const getCostAlerts: Handler = async (args, ctx) => {
|
|
78
50
|
const { project_id } = args as { project_id?: string };
|
|
79
|
-
const { supabase, auth } = ctx;
|
|
80
|
-
|
|
81
|
-
let query = supabase
|
|
82
|
-
.from('cost_alerts')
|
|
83
|
-
.select('*')
|
|
84
|
-
.eq('user_id', auth.userId)
|
|
85
|
-
.order('threshold_amount', { ascending: true });
|
|
86
|
-
|
|
87
|
-
if (project_id) {
|
|
88
|
-
query = query.eq('project_id', project_id);
|
|
89
|
-
}
|
|
90
51
|
|
|
91
|
-
const
|
|
52
|
+
const apiClient = getApiClient();
|
|
53
|
+
const response = await apiClient.getCostAlerts();
|
|
92
54
|
|
|
93
|
-
if (
|
|
55
|
+
if (!response.ok) {
|
|
94
56
|
return {
|
|
95
|
-
result: { error:
|
|
57
|
+
result: { error: response.error || 'Failed to get cost alerts' },
|
|
96
58
|
isError: true,
|
|
97
59
|
};
|
|
98
60
|
}
|
|
99
61
|
|
|
100
|
-
return {
|
|
101
|
-
result: {
|
|
102
|
-
alerts: data || [],
|
|
103
|
-
count: data?.length || 0,
|
|
104
|
-
},
|
|
105
|
-
};
|
|
62
|
+
return { result: response.data };
|
|
106
63
|
};
|
|
107
64
|
|
|
108
65
|
/**
|
|
@@ -121,8 +78,6 @@ export const addCostAlert: Handler = async (args, ctx) => {
|
|
|
121
78
|
alert_type?: 'warning' | 'critical';
|
|
122
79
|
};
|
|
123
80
|
|
|
124
|
-
const { supabase, auth } = ctx;
|
|
125
|
-
|
|
126
81
|
if (!threshold_amount || threshold_amount <= 0) {
|
|
127
82
|
return {
|
|
128
83
|
result: { error: 'threshold_amount must be a positive number' },
|
|
@@ -137,32 +92,22 @@ export const addCostAlert: Handler = async (args, ctx) => {
|
|
|
137
92
|
};
|
|
138
93
|
}
|
|
139
94
|
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
.select()
|
|
150
|
-
.single();
|
|
151
|
-
|
|
152
|
-
if (error) {
|
|
95
|
+
const apiClient = getApiClient();
|
|
96
|
+
const response = await apiClient.addCostAlert({
|
|
97
|
+
project_id,
|
|
98
|
+
threshold_amount,
|
|
99
|
+
threshold_period,
|
|
100
|
+
alert_type
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
if (!response.ok) {
|
|
153
104
|
return {
|
|
154
|
-
result: { error:
|
|
105
|
+
result: { error: response.error || 'Failed to create cost alert' },
|
|
155
106
|
isError: true,
|
|
156
107
|
};
|
|
157
108
|
}
|
|
158
109
|
|
|
159
|
-
return {
|
|
160
|
-
result: {
|
|
161
|
-
success: true,
|
|
162
|
-
alert: data,
|
|
163
|
-
message: `Alert created: ${alert_type} when ${threshold_period} cost exceeds $${threshold_amount}`,
|
|
164
|
-
},
|
|
165
|
-
};
|
|
110
|
+
return { result: response.data };
|
|
166
111
|
};
|
|
167
112
|
|
|
168
113
|
/**
|
|
@@ -183,8 +128,6 @@ export const updateCostAlert: Handler = async (args, ctx) => {
|
|
|
183
128
|
enabled?: boolean;
|
|
184
129
|
};
|
|
185
130
|
|
|
186
|
-
const { supabase, auth } = ctx;
|
|
187
|
-
|
|
188
131
|
if (!alert_id) {
|
|
189
132
|
return {
|
|
190
133
|
result: { error: 'alert_id is required' },
|
|
@@ -192,7 +135,12 @@ export const updateCostAlert: Handler = async (args, ctx) => {
|
|
|
192
135
|
};
|
|
193
136
|
}
|
|
194
137
|
|
|
195
|
-
const updates:
|
|
138
|
+
const updates: {
|
|
139
|
+
threshold_amount?: number;
|
|
140
|
+
threshold_period?: 'daily' | 'weekly' | 'monthly';
|
|
141
|
+
alert_type?: 'warning' | 'critical';
|
|
142
|
+
enabled?: boolean;
|
|
143
|
+
} = {};
|
|
196
144
|
if (threshold_amount !== undefined) updates.threshold_amount = threshold_amount;
|
|
197
145
|
if (threshold_period !== undefined) updates.threshold_period = threshold_period;
|
|
198
146
|
if (alert_type !== undefined) updates.alert_type = alert_type;
|
|
@@ -205,27 +153,17 @@ export const updateCostAlert: Handler = async (args, ctx) => {
|
|
|
205
153
|
};
|
|
206
154
|
}
|
|
207
155
|
|
|
208
|
-
const
|
|
209
|
-
|
|
210
|
-
.update(updates)
|
|
211
|
-
.eq('id', alert_id)
|
|
212
|
-
.eq('user_id', auth.userId)
|
|
213
|
-
.select()
|
|
214
|
-
.single();
|
|
156
|
+
const apiClient = getApiClient();
|
|
157
|
+
const response = await apiClient.updateCostAlert(alert_id, updates);
|
|
215
158
|
|
|
216
|
-
if (
|
|
159
|
+
if (!response.ok) {
|
|
217
160
|
return {
|
|
218
|
-
result: { error:
|
|
161
|
+
result: { error: response.error || 'Failed to update cost alert' },
|
|
219
162
|
isError: true,
|
|
220
163
|
};
|
|
221
164
|
}
|
|
222
165
|
|
|
223
|
-
return {
|
|
224
|
-
result: {
|
|
225
|
-
success: true,
|
|
226
|
-
alert: data,
|
|
227
|
-
},
|
|
228
|
-
};
|
|
166
|
+
return { result: response.data };
|
|
229
167
|
};
|
|
230
168
|
|
|
231
169
|
/**
|
|
@@ -233,7 +171,6 @@ export const updateCostAlert: Handler = async (args, ctx) => {
|
|
|
233
171
|
*/
|
|
234
172
|
export const deleteCostAlert: Handler = async (args, ctx) => {
|
|
235
173
|
const { alert_id } = args as { alert_id: string };
|
|
236
|
-
const { supabase, auth } = ctx;
|
|
237
174
|
|
|
238
175
|
if (!alert_id) {
|
|
239
176
|
return {
|
|
@@ -242,25 +179,17 @@ export const deleteCostAlert: Handler = async (args, ctx) => {
|
|
|
242
179
|
};
|
|
243
180
|
}
|
|
244
181
|
|
|
245
|
-
const
|
|
246
|
-
|
|
247
|
-
.delete()
|
|
248
|
-
.eq('id', alert_id)
|
|
249
|
-
.eq('user_id', auth.userId);
|
|
182
|
+
const apiClient = getApiClient();
|
|
183
|
+
const response = await apiClient.deleteCostAlert(alert_id);
|
|
250
184
|
|
|
251
|
-
if (
|
|
185
|
+
if (!response.ok) {
|
|
252
186
|
return {
|
|
253
|
-
result: { error:
|
|
187
|
+
result: { error: response.error || 'Failed to delete cost alert' },
|
|
254
188
|
isError: true,
|
|
255
189
|
};
|
|
256
190
|
}
|
|
257
191
|
|
|
258
|
-
return {
|
|
259
|
-
result: {
|
|
260
|
-
success: true,
|
|
261
|
-
deleted_alert_id: alert_id,
|
|
262
|
-
},
|
|
263
|
-
};
|
|
192
|
+
return { result: response.data };
|
|
264
193
|
};
|
|
265
194
|
|
|
266
195
|
/**
|
|
@@ -272,8 +201,6 @@ export const getTaskCosts: Handler = async (args, ctx) => {
|
|
|
272
201
|
limit?: number;
|
|
273
202
|
};
|
|
274
203
|
|
|
275
|
-
const { supabase } = ctx;
|
|
276
|
-
|
|
277
204
|
if (!project_id) {
|
|
278
205
|
return {
|
|
279
206
|
result: { error: 'project_id is required' },
|
|
@@ -281,32 +208,17 @@ export const getTaskCosts: Handler = async (args, ctx) => {
|
|
|
281
208
|
};
|
|
282
209
|
}
|
|
283
210
|
|
|
284
|
-
const
|
|
285
|
-
|
|
286
|
-
.select('*')
|
|
287
|
-
.eq('project_id', project_id)
|
|
288
|
-
.order('estimated_cost_usd', { ascending: false })
|
|
289
|
-
.limit(limit);
|
|
211
|
+
const apiClient = getApiClient();
|
|
212
|
+
const response = await apiClient.getTaskCosts(project_id, limit);
|
|
290
213
|
|
|
291
|
-
if (
|
|
214
|
+
if (!response.ok) {
|
|
292
215
|
return {
|
|
293
|
-
result: { error:
|
|
216
|
+
result: { error: response.error || 'Failed to get task costs' },
|
|
294
217
|
isError: true,
|
|
295
218
|
};
|
|
296
219
|
}
|
|
297
220
|
|
|
298
|
-
|
|
299
|
-
(sum, task) => sum + parseFloat(task.estimated_cost_usd || '0'),
|
|
300
|
-
0
|
|
301
|
-
);
|
|
302
|
-
|
|
303
|
-
return {
|
|
304
|
-
result: {
|
|
305
|
-
project_id,
|
|
306
|
-
tasks: data || [],
|
|
307
|
-
total_cost_usd: Math.round(totalCost * 100) / 100,
|
|
308
|
-
},
|
|
309
|
-
};
|
|
221
|
+
return { result: response.data };
|
|
310
222
|
};
|
|
311
223
|
|
|
312
224
|
/**
|