@vibescope/mcp-server 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +98 -0
- package/dist/cli.d.ts +34 -0
- package/dist/cli.js +356 -0
- package/dist/cli.test.d.ts +1 -0
- package/dist/cli.test.js +367 -0
- package/dist/handlers/__test-utils__.d.ts +72 -0
- package/dist/handlers/__test-utils__.js +176 -0
- package/dist/handlers/blockers.d.ts +18 -0
- package/dist/handlers/blockers.js +81 -0
- package/dist/handlers/bodies-of-work.d.ts +34 -0
- package/dist/handlers/bodies-of-work.js +614 -0
- package/dist/handlers/checkouts.d.ts +37 -0
- package/dist/handlers/checkouts.js +377 -0
- package/dist/handlers/cost.d.ts +39 -0
- package/dist/handlers/cost.js +247 -0
- package/dist/handlers/decisions.d.ts +16 -0
- package/dist/handlers/decisions.js +64 -0
- package/dist/handlers/deployment.d.ts +36 -0
- package/dist/handlers/deployment.js +1062 -0
- package/dist/handlers/discovery.d.ts +14 -0
- package/dist/handlers/discovery.js +870 -0
- package/dist/handlers/fallback.d.ts +18 -0
- package/dist/handlers/fallback.js +216 -0
- package/dist/handlers/findings.d.ts +18 -0
- package/dist/handlers/findings.js +110 -0
- package/dist/handlers/git-issues.d.ts +22 -0
- package/dist/handlers/git-issues.js +247 -0
- package/dist/handlers/ideas.d.ts +19 -0
- package/dist/handlers/ideas.js +188 -0
- package/dist/handlers/index.d.ts +29 -0
- package/dist/handlers/index.js +65 -0
- package/dist/handlers/knowledge-query.d.ts +22 -0
- package/dist/handlers/knowledge-query.js +253 -0
- package/dist/handlers/knowledge.d.ts +12 -0
- package/dist/handlers/knowledge.js +108 -0
- package/dist/handlers/milestones.d.ts +20 -0
- package/dist/handlers/milestones.js +179 -0
- package/dist/handlers/organizations.d.ts +36 -0
- package/dist/handlers/organizations.js +428 -0
- package/dist/handlers/progress.d.ts +14 -0
- package/dist/handlers/progress.js +149 -0
- package/dist/handlers/project.d.ts +20 -0
- package/dist/handlers/project.js +278 -0
- package/dist/handlers/requests.d.ts +16 -0
- package/dist/handlers/requests.js +131 -0
- package/dist/handlers/roles.d.ts +30 -0
- package/dist/handlers/roles.js +281 -0
- package/dist/handlers/session.d.ts +20 -0
- package/dist/handlers/session.js +791 -0
- package/dist/handlers/tasks.d.ts +52 -0
- package/dist/handlers/tasks.js +1111 -0
- package/dist/handlers/tasks.test.d.ts +1 -0
- package/dist/handlers/tasks.test.js +431 -0
- package/dist/handlers/types.d.ts +94 -0
- package/dist/handlers/types.js +1 -0
- package/dist/handlers/validation.d.ts +16 -0
- package/dist/handlers/validation.js +188 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2707 -0
- package/dist/knowledge.d.ts +6 -0
- package/dist/knowledge.js +121 -0
- package/dist/tools.d.ts +2 -0
- package/dist/tools.js +2498 -0
- package/dist/utils.d.ts +149 -0
- package/dist/utils.js +317 -0
- package/dist/utils.test.d.ts +1 -0
- package/dist/utils.test.js +532 -0
- package/dist/validators.d.ts +35 -0
- package/dist/validators.js +111 -0
- package/dist/validators.test.d.ts +1 -0
- package/dist/validators.test.js +176 -0
- package/package.json +44 -0
- package/src/cli.test.ts +442 -0
- package/src/cli.ts +439 -0
- package/src/handlers/__test-utils__.ts +217 -0
- package/src/handlers/blockers.test.ts +390 -0
- package/src/handlers/blockers.ts +110 -0
- package/src/handlers/bodies-of-work.test.ts +1276 -0
- package/src/handlers/bodies-of-work.ts +783 -0
- package/src/handlers/cost.test.ts +436 -0
- package/src/handlers/cost.ts +322 -0
- package/src/handlers/decisions.test.ts +401 -0
- package/src/handlers/decisions.ts +86 -0
- package/src/handlers/deployment.test.ts +516 -0
- package/src/handlers/deployment.ts +1289 -0
- package/src/handlers/discovery.test.ts +254 -0
- package/src/handlers/discovery.ts +969 -0
- package/src/handlers/fallback.test.ts +687 -0
- package/src/handlers/fallback.ts +260 -0
- package/src/handlers/findings.test.ts +565 -0
- package/src/handlers/findings.ts +153 -0
- package/src/handlers/ideas.test.ts +753 -0
- package/src/handlers/ideas.ts +247 -0
- package/src/handlers/index.ts +69 -0
- package/src/handlers/milestones.test.ts +584 -0
- package/src/handlers/milestones.ts +217 -0
- package/src/handlers/organizations.test.ts +997 -0
- package/src/handlers/organizations.ts +550 -0
- package/src/handlers/progress.test.ts +369 -0
- package/src/handlers/progress.ts +188 -0
- package/src/handlers/project.test.ts +562 -0
- package/src/handlers/project.ts +352 -0
- package/src/handlers/requests.test.ts +531 -0
- package/src/handlers/requests.ts +150 -0
- package/src/handlers/session.test.ts +459 -0
- package/src/handlers/session.ts +912 -0
- package/src/handlers/tasks.test.ts +602 -0
- package/src/handlers/tasks.ts +1393 -0
- package/src/handlers/types.ts +88 -0
- package/src/handlers/validation.test.ts +880 -0
- package/src/handlers/validation.ts +223 -0
- package/src/index.ts +3205 -0
- package/src/knowledge.ts +132 -0
- package/src/tmpclaude-0078-cwd +1 -0
- package/src/tmpclaude-0ee1-cwd +1 -0
- package/src/tmpclaude-2dd5-cwd +1 -0
- package/src/tmpclaude-344c-cwd +1 -0
- package/src/tmpclaude-3860-cwd +1 -0
- package/src/tmpclaude-4b63-cwd +1 -0
- package/src/tmpclaude-5c73-cwd +1 -0
- package/src/tmpclaude-5ee3-cwd +1 -0
- package/src/tmpclaude-6795-cwd +1 -0
- package/src/tmpclaude-709e-cwd +1 -0
- package/src/tmpclaude-9839-cwd +1 -0
- package/src/tmpclaude-d829-cwd +1 -0
- package/src/tmpclaude-e072-cwd +1 -0
- package/src/tmpclaude-f6ee-cwd +1 -0
- package/src/utils.test.ts +681 -0
- package/src/utils.ts +375 -0
- package/src/validators.test.ts +223 -0
- package/src/validators.ts +122 -0
- package/tmpclaude-0439-cwd +1 -0
- package/tmpclaude-132f-cwd +1 -0
- package/tmpclaude-15bb-cwd +1 -0
- package/tmpclaude-165a-cwd +1 -0
- package/tmpclaude-1ba9-cwd +1 -0
- package/tmpclaude-21a3-cwd +1 -0
- package/tmpclaude-2a38-cwd +1 -0
- package/tmpclaude-2adf-cwd +1 -0
- package/tmpclaude-2f56-cwd +1 -0
- package/tmpclaude-3626-cwd +1 -0
- package/tmpclaude-3727-cwd +1 -0
- package/tmpclaude-40bc-cwd +1 -0
- package/tmpclaude-436f-cwd +1 -0
- package/tmpclaude-4783-cwd +1 -0
- package/tmpclaude-4b6d-cwd +1 -0
- package/tmpclaude-4ba4-cwd +1 -0
- package/tmpclaude-51e6-cwd +1 -0
- package/tmpclaude-5ecf-cwd +1 -0
- package/tmpclaude-6f97-cwd +1 -0
- package/tmpclaude-7fb2-cwd +1 -0
- package/tmpclaude-825c-cwd +1 -0
- package/tmpclaude-8baf-cwd +1 -0
- package/tmpclaude-8d9f-cwd +1 -0
- package/tmpclaude-975c-cwd +1 -0
- package/tmpclaude-9983-cwd +1 -0
- package/tmpclaude-a045-cwd +1 -0
- package/tmpclaude-ac4a-cwd +1 -0
- package/tmpclaude-b593-cwd +1 -0
- package/tmpclaude-b891-cwd +1 -0
- package/tmpclaude-c032-cwd +1 -0
- package/tmpclaude-cf43-cwd +1 -0
- package/tmpclaude-d040-cwd +1 -0
- package/tmpclaude-dcdd-cwd +1 -0
- package/tmpclaude-dcee-cwd +1 -0
- package/tmpclaude-e16b-cwd +1 -0
- package/tmpclaude-ecd2-cwd +1 -0
- package/tmpclaude-f48d-cwd +1 -0
- package/tsconfig.json +16 -0
- package/vitest.config.ts +13 -0
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fallback Handlers
|
|
3
|
+
*
|
|
4
|
+
* Handles background activities when idle:
|
|
5
|
+
* - start_fallback_activity
|
|
6
|
+
* - stop_fallback_activity
|
|
7
|
+
* - get_activity_history
|
|
8
|
+
* - get_activity_schedules
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type { Handler, HandlerRegistry } from './types.js';
|
|
12
|
+
import { validateRequired, validateUUID } from '../validators.js';
|
|
13
|
+
import { FALLBACK_ACTIVITIES } from '../utils.js';
|
|
14
|
+
|
|
15
|
+
const VALID_ACTIVITIES = [
|
|
16
|
+
'feature_ideation',
|
|
17
|
+
'code_review',
|
|
18
|
+
'performance_audit',
|
|
19
|
+
'ux_review',
|
|
20
|
+
'cost_analysis',
|
|
21
|
+
'security_review',
|
|
22
|
+
'test_coverage',
|
|
23
|
+
'documentation_review',
|
|
24
|
+
'dependency_audit',
|
|
25
|
+
'validate_completed_tasks',
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
export const startFallbackActivity: Handler = async (args, ctx) => {
|
|
29
|
+
const { project_id, activity } = args as { project_id: string; activity: string };
|
|
30
|
+
|
|
31
|
+
validateRequired(project_id, 'project_id');
|
|
32
|
+
validateUUID(project_id, 'project_id');
|
|
33
|
+
validateRequired(activity, 'activity');
|
|
34
|
+
|
|
35
|
+
if (!VALID_ACTIVITIES.includes(activity)) {
|
|
36
|
+
throw new Error(`Invalid activity. Must be one of: ${VALID_ACTIVITIES.join(', ')}`);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const { supabase, session } = ctx;
|
|
40
|
+
const currentSessionId = session.currentSessionId;
|
|
41
|
+
|
|
42
|
+
// Update the current session's fallback activity
|
|
43
|
+
const { error: updateError } = await supabase
|
|
44
|
+
.from('agent_sessions')
|
|
45
|
+
.update({
|
|
46
|
+
current_fallback_activity: activity,
|
|
47
|
+
current_task_id: null, // Clear any task when starting fallback
|
|
48
|
+
status: 'active',
|
|
49
|
+
last_synced_at: new Date().toISOString(),
|
|
50
|
+
})
|
|
51
|
+
.eq('id', currentSessionId);
|
|
52
|
+
|
|
53
|
+
if (updateError) throw updateError;
|
|
54
|
+
|
|
55
|
+
// Get the activity details for the response
|
|
56
|
+
const activityInfo = FALLBACK_ACTIVITIES.find((a) => a.activity === activity);
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
result: {
|
|
60
|
+
success: true,
|
|
61
|
+
activity,
|
|
62
|
+
title: activityInfo?.title || activity,
|
|
63
|
+
description: activityInfo?.description || '',
|
|
64
|
+
prompt: activityInfo?.prompt || '',
|
|
65
|
+
message: `Started fallback activity: ${activityInfo?.title || activity}`,
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export const stopFallbackActivity: Handler = async (args, ctx) => {
|
|
71
|
+
const { project_id, summary } = args as { project_id: string; summary?: string };
|
|
72
|
+
|
|
73
|
+
validateRequired(project_id, 'project_id');
|
|
74
|
+
validateUUID(project_id, 'project_id');
|
|
75
|
+
|
|
76
|
+
const { supabase, session } = ctx;
|
|
77
|
+
const currentSessionId = session.currentSessionId;
|
|
78
|
+
|
|
79
|
+
// Get the current session's fallback activity before clearing it
|
|
80
|
+
const { data: sessionData, error: sessionError } = await supabase
|
|
81
|
+
.from('agent_sessions')
|
|
82
|
+
.select('current_fallback_activity')
|
|
83
|
+
.eq('id', currentSessionId)
|
|
84
|
+
.single();
|
|
85
|
+
|
|
86
|
+
if (sessionError) throw sessionError;
|
|
87
|
+
|
|
88
|
+
const activityType = sessionData?.current_fallback_activity;
|
|
89
|
+
|
|
90
|
+
// Log the activity completion to history if there was an active activity
|
|
91
|
+
if (activityType) {
|
|
92
|
+
const completedAt = new Date().toISOString();
|
|
93
|
+
|
|
94
|
+
// Insert history record
|
|
95
|
+
await supabase.from('background_activity_history').insert({
|
|
96
|
+
project_id,
|
|
97
|
+
activity_type: activityType,
|
|
98
|
+
completed_at: completedAt,
|
|
99
|
+
completed_by_session_id: currentSessionId,
|
|
100
|
+
summary: summary || null,
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
// Update schedule if one exists for this activity
|
|
104
|
+
const { data: schedule } = await supabase
|
|
105
|
+
.from('background_activity_schedules')
|
|
106
|
+
.select('*')
|
|
107
|
+
.eq('project_id', project_id)
|
|
108
|
+
.eq('activity_type', activityType)
|
|
109
|
+
.eq('enabled', true)
|
|
110
|
+
.single();
|
|
111
|
+
|
|
112
|
+
if (schedule) {
|
|
113
|
+
let nextRunAt: string | null = null;
|
|
114
|
+
let enabled = true;
|
|
115
|
+
|
|
116
|
+
// Calculate next run time based on schedule type
|
|
117
|
+
const completedDate = new Date(completedAt);
|
|
118
|
+
switch (schedule.schedule_type) {
|
|
119
|
+
case 'once':
|
|
120
|
+
enabled = false;
|
|
121
|
+
break;
|
|
122
|
+
case 'daily':
|
|
123
|
+
completedDate.setDate(completedDate.getDate() + 1);
|
|
124
|
+
nextRunAt = completedDate.toISOString();
|
|
125
|
+
break;
|
|
126
|
+
case 'weekly':
|
|
127
|
+
completedDate.setDate(completedDate.getDate() + 7);
|
|
128
|
+
nextRunAt = completedDate.toISOString();
|
|
129
|
+
break;
|
|
130
|
+
case 'monthly':
|
|
131
|
+
completedDate.setDate(completedDate.getDate() + 30);
|
|
132
|
+
nextRunAt = completedDate.toISOString();
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
await supabase
|
|
137
|
+
.from('background_activity_schedules')
|
|
138
|
+
.update({ next_run_at: nextRunAt, enabled })
|
|
139
|
+
.eq('id', schedule.id);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Clear the current session's fallback activity
|
|
144
|
+
const { error: updateError } = await supabase
|
|
145
|
+
.from('agent_sessions')
|
|
146
|
+
.update({
|
|
147
|
+
current_fallback_activity: null,
|
|
148
|
+
status: 'idle',
|
|
149
|
+
last_synced_at: new Date().toISOString(),
|
|
150
|
+
})
|
|
151
|
+
.eq('id', currentSessionId);
|
|
152
|
+
|
|
153
|
+
if (updateError) throw updateError;
|
|
154
|
+
|
|
155
|
+
return {
|
|
156
|
+
result: {
|
|
157
|
+
success: true,
|
|
158
|
+
message: activityType
|
|
159
|
+
? `Fallback activity '${activityType}' completed and logged to history`
|
|
160
|
+
: 'Fallback activity stopped',
|
|
161
|
+
},
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
export const getActivityHistory: Handler = async (args, ctx) => {
|
|
166
|
+
const { project_id, activity_type, limit = 50 } = args as {
|
|
167
|
+
project_id: string;
|
|
168
|
+
activity_type?: string;
|
|
169
|
+
limit?: number;
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
validateRequired(project_id, 'project_id');
|
|
173
|
+
validateUUID(project_id, 'project_id');
|
|
174
|
+
|
|
175
|
+
const { supabase } = ctx;
|
|
176
|
+
|
|
177
|
+
let query = supabase
|
|
178
|
+
.from('background_activity_history')
|
|
179
|
+
.select(
|
|
180
|
+
`
|
|
181
|
+
id,
|
|
182
|
+
activity_type,
|
|
183
|
+
completed_at,
|
|
184
|
+
completed_by_session_id,
|
|
185
|
+
summary,
|
|
186
|
+
created_at,
|
|
187
|
+
agent_sessions!completed_by_session_id (
|
|
188
|
+
agent_name
|
|
189
|
+
)
|
|
190
|
+
`
|
|
191
|
+
)
|
|
192
|
+
.eq('project_id', project_id)
|
|
193
|
+
.order('completed_at', { ascending: false })
|
|
194
|
+
.limit(limit);
|
|
195
|
+
|
|
196
|
+
if (activity_type) {
|
|
197
|
+
query = query.eq('activity_type', activity_type);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const { data: history, error } = await query;
|
|
201
|
+
|
|
202
|
+
if (error) throw error;
|
|
203
|
+
|
|
204
|
+
// Also get the most recent completion for each activity type
|
|
205
|
+
const latestByType: Record<string, unknown> = {};
|
|
206
|
+
for (const entry of history || []) {
|
|
207
|
+
if (!latestByType[entry.activity_type]) {
|
|
208
|
+
latestByType[entry.activity_type] = entry;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
return {
|
|
213
|
+
result: {
|
|
214
|
+
history: history || [],
|
|
215
|
+
latest_by_type: latestByType,
|
|
216
|
+
count: history?.length || 0,
|
|
217
|
+
},
|
|
218
|
+
};
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
export const getActivitySchedules: Handler = async (args, ctx) => {
|
|
222
|
+
const { project_id } = args as { project_id: string };
|
|
223
|
+
|
|
224
|
+
validateRequired(project_id, 'project_id');
|
|
225
|
+
validateUUID(project_id, 'project_id');
|
|
226
|
+
|
|
227
|
+
const { supabase } = ctx;
|
|
228
|
+
|
|
229
|
+
const { data: schedules, error } = await supabase
|
|
230
|
+
.from('background_activity_schedules')
|
|
231
|
+
.select('*')
|
|
232
|
+
.eq('project_id', project_id)
|
|
233
|
+
.order('activity_type');
|
|
234
|
+
|
|
235
|
+
if (error) throw error;
|
|
236
|
+
|
|
237
|
+
// Identify which activities are "due" (next_run_at < now AND enabled)
|
|
238
|
+
const now = new Date();
|
|
239
|
+
const dueActivities = (schedules || [])
|
|
240
|
+
.filter((s) => s.enabled && s.next_run_at && new Date(s.next_run_at) < now)
|
|
241
|
+
.map((s) => s.activity_type);
|
|
242
|
+
|
|
243
|
+
return {
|
|
244
|
+
result: {
|
|
245
|
+
schedules: schedules || [],
|
|
246
|
+
due_activities: dueActivities,
|
|
247
|
+
count: schedules?.length || 0,
|
|
248
|
+
},
|
|
249
|
+
};
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Fallback handlers registry
|
|
254
|
+
*/
|
|
255
|
+
export const fallbackHandlers: HandlerRegistry = {
|
|
256
|
+
start_fallback_activity: startFallbackActivity,
|
|
257
|
+
stop_fallback_activity: stopFallbackActivity,
|
|
258
|
+
get_activity_history: getActivityHistory,
|
|
259
|
+
get_activity_schedules: getActivitySchedules,
|
|
260
|
+
};
|