@vibescope/mcp-server 0.4.4 → 0.4.5

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 (65) hide show
  1. package/dist/api-client/bodies-of-work.d.ts +125 -0
  2. package/dist/api-client/bodies-of-work.js +78 -0
  3. package/dist/api-client/chat.d.ts +26 -0
  4. package/dist/api-client/chat.js +20 -0
  5. package/dist/api-client/connectors.d.ts +104 -0
  6. package/dist/api-client/connectors.js +46 -0
  7. package/dist/api-client/deployment.d.ts +190 -0
  8. package/dist/api-client/deployment.js +113 -0
  9. package/dist/api-client/file-checkouts.d.ts +71 -0
  10. package/dist/api-client/file-checkouts.js +43 -0
  11. package/dist/api-client/git-issues.d.ts +55 -0
  12. package/dist/api-client/git-issues.js +34 -0
  13. package/dist/api-client/index.d.ts +619 -1
  14. package/dist/api-client/index.js +148 -0
  15. package/dist/api-client/organizations.d.ts +101 -0
  16. package/dist/api-client/organizations.js +86 -0
  17. package/dist/api-client/progress.d.ts +61 -0
  18. package/dist/api-client/progress.js +34 -0
  19. package/dist/api-client/requests.d.ts +28 -0
  20. package/dist/api-client/requests.js +28 -0
  21. package/dist/api-client/sprints.d.ts +153 -0
  22. package/dist/api-client/sprints.js +82 -0
  23. package/dist/api-client/subtasks.d.ts +37 -0
  24. package/dist/api-client/subtasks.js +23 -0
  25. package/dist/api-client.d.ts +22 -0
  26. package/dist/api-client.js +15 -0
  27. package/dist/handlers/blockers.js +4 -0
  28. package/dist/handlers/chat.d.ts +21 -0
  29. package/dist/handlers/chat.js +59 -0
  30. package/dist/handlers/deployment.d.ts +3 -0
  31. package/dist/handlers/deployment.js +23 -0
  32. package/dist/handlers/discovery.js +1 -0
  33. package/dist/handlers/index.d.ts +1 -0
  34. package/dist/handlers/index.js +3 -0
  35. package/dist/handlers/session.js +7 -0
  36. package/dist/handlers/tasks.js +7 -0
  37. package/dist/handlers/tool-docs.js +7 -0
  38. package/dist/tools/deployment.js +13 -0
  39. package/docs/TOOLS.md +17 -3
  40. package/package.json +1 -1
  41. package/src/api-client/bodies-of-work.ts +194 -0
  42. package/src/api-client/chat.ts +50 -0
  43. package/src/api-client/connectors.ts +152 -0
  44. package/src/api-client/deployment.ts +313 -0
  45. package/src/api-client/file-checkouts.ts +115 -0
  46. package/src/api-client/git-issues.ts +88 -0
  47. package/src/api-client/index.ts +179 -13
  48. package/src/api-client/organizations.ts +185 -0
  49. package/src/api-client/progress.ts +94 -0
  50. package/src/api-client/requests.ts +54 -0
  51. package/src/api-client/sprints.ts +227 -0
  52. package/src/api-client/subtasks.ts +57 -0
  53. package/src/api-client.test.ts +16 -19
  54. package/src/api-client.ts +34 -0
  55. package/src/handlers/__test-setup__.ts +4 -0
  56. package/src/handlers/blockers.ts +9 -0
  57. package/src/handlers/chat.test.ts +185 -0
  58. package/src/handlers/chat.ts +69 -0
  59. package/src/handlers/deployment.ts +29 -0
  60. package/src/handlers/discovery.ts +1 -0
  61. package/src/handlers/index.ts +3 -0
  62. package/src/handlers/session.ts +12 -0
  63. package/src/handlers/tasks.ts +12 -0
  64. package/src/handlers/tool-docs.ts +8 -0
  65. package/src/tools/deployment.ts +13 -0
@@ -0,0 +1,185 @@
1
+ import { describe, it, expect, vi, beforeEach } from 'vitest';
2
+ import { sendProjectMessage, getProjectMessages, autoPostActivity } from './chat.js';
3
+ import { ValidationError } from '../validators.js';
4
+ import { createMockContext } from './__test-utils__.js';
5
+
6
+ // vi.mock is hoisted above imports by Vitest — this intercepts the api-client module
7
+ const mockSendProjectMessage = vi.fn();
8
+ const mockGetProjectMessages = vi.fn();
9
+
10
+ vi.mock('../api-client.js', () => ({
11
+ getApiClient: () => ({
12
+ sendProjectMessage: mockSendProjectMessage,
13
+ getProjectMessages: mockGetProjectMessages,
14
+ }),
15
+ initApiClient: vi.fn(),
16
+ VibescopeApiClient: vi.fn(),
17
+ }));
18
+
19
+ const VALID_PROJECT_ID = '123e4567-e89b-12d3-a456-426614174000';
20
+
21
+ // ============================================================================
22
+ // sendProjectMessage Tests
23
+ // ============================================================================
24
+
25
+ describe('sendProjectMessage', () => {
26
+ beforeEach(() => {
27
+ vi.clearAllMocks();
28
+ mockSendProjectMessage.mockResolvedValue({ ok: true, data: {} });
29
+ mockGetProjectMessages.mockResolvedValue({ ok: true, data: { messages: [], count: 0 } });
30
+ });
31
+
32
+ it('should throw for missing project_id', async () => {
33
+ const ctx = createMockContext();
34
+ await expect(
35
+ sendProjectMessage({ message: 'Hello' }, ctx)
36
+ ).rejects.toThrow(ValidationError);
37
+ });
38
+
39
+ it('should throw for invalid project_id UUID', async () => {
40
+ const ctx = createMockContext();
41
+ await expect(
42
+ sendProjectMessage({ project_id: 'not-a-uuid', message: 'Hello' }, ctx)
43
+ ).rejects.toThrow(ValidationError);
44
+ });
45
+
46
+ it('should throw for missing message', async () => {
47
+ const ctx = createMockContext();
48
+ await expect(
49
+ sendProjectMessage({ project_id: VALID_PROJECT_ID }, ctx)
50
+ ).rejects.toThrow(ValidationError);
51
+ });
52
+
53
+ it('should send message successfully', async () => {
54
+ mockSendProjectMessage.mockResolvedValue({
55
+ ok: true,
56
+ data: { success: true, message_id: 'msg-1', sent_at: '2026-02-22T12:00:00Z' },
57
+ });
58
+ const ctx = createMockContext({ sessionId: 'session-abc' });
59
+
60
+ const result = await sendProjectMessage(
61
+ { project_id: VALID_PROJECT_ID, message: 'Deployment complete' },
62
+ ctx
63
+ );
64
+
65
+ expect(result.result).toMatchObject({ success: true, message_id: 'msg-1' });
66
+ expect(mockSendProjectMessage).toHaveBeenCalledWith(
67
+ VALID_PROJECT_ID,
68
+ 'Deployment complete',
69
+ 'session-abc'
70
+ );
71
+ });
72
+
73
+ it('should return error when API fails', async () => {
74
+ mockSendProjectMessage.mockResolvedValue({
75
+ ok: false,
76
+ error: 'Project not found',
77
+ });
78
+ const ctx = createMockContext();
79
+
80
+ const result = await sendProjectMessage(
81
+ { project_id: VALID_PROJECT_ID, message: 'Hi' },
82
+ ctx
83
+ );
84
+
85
+ expect(result.isError).toBe(true);
86
+ expect(result.result).toMatchObject({ error: 'Project not found' });
87
+ });
88
+ });
89
+
90
+ // ============================================================================
91
+ // getProjectMessages Tests
92
+ // ============================================================================
93
+
94
+ describe('getProjectMessages', () => {
95
+ beforeEach(() => {
96
+ vi.clearAllMocks();
97
+ mockSendProjectMessage.mockResolvedValue({ ok: true, data: {} });
98
+ mockGetProjectMessages.mockResolvedValue({ ok: true, data: { messages: [], count: 0 } });
99
+ });
100
+
101
+ it('should throw for missing project_id', async () => {
102
+ const ctx = createMockContext();
103
+ await expect(
104
+ getProjectMessages({}, ctx)
105
+ ).rejects.toThrow(ValidationError);
106
+ });
107
+
108
+ it('should fetch messages successfully', async () => {
109
+ const mockMessages = [
110
+ { id: 'msg-1', sender_type: 'agent', sender_name: 'Garath', content: 'Started session', created_at: '2026-02-22T12:00:00Z' },
111
+ ];
112
+ mockGetProjectMessages.mockResolvedValue({
113
+ ok: true,
114
+ data: { messages: mockMessages, count: 1 },
115
+ });
116
+ const ctx = createMockContext();
117
+
118
+ const result = await getProjectMessages({ project_id: VALID_PROJECT_ID }, ctx);
119
+
120
+ expect(result.result).toMatchObject({ messages: mockMessages, count: 1 });
121
+ expect(mockGetProjectMessages).toHaveBeenCalledWith(VALID_PROJECT_ID, undefined);
122
+ });
123
+
124
+ it('should pass limit when provided', async () => {
125
+ const ctx = createMockContext();
126
+
127
+ await getProjectMessages({ project_id: VALID_PROJECT_ID, limit: 5 }, ctx);
128
+
129
+ expect(mockGetProjectMessages).toHaveBeenCalledWith(VALID_PROJECT_ID, 5);
130
+ });
131
+
132
+ it('should return error when API fails', async () => {
133
+ mockGetProjectMessages.mockResolvedValue({ ok: false, error: 'Unauthorized' });
134
+ const ctx = createMockContext();
135
+
136
+ const result = await getProjectMessages({ project_id: VALID_PROJECT_ID }, ctx);
137
+
138
+ expect(result.isError).toBe(true);
139
+ });
140
+ });
141
+
142
+ // ============================================================================
143
+ // autoPostActivity Tests
144
+ // ============================================================================
145
+
146
+ describe('autoPostActivity', () => {
147
+ beforeEach(() => {
148
+ vi.clearAllMocks();
149
+ mockSendProjectMessage.mockResolvedValue({ ok: true, data: {} });
150
+ });
151
+
152
+ it('should call sendProjectMessage with correct args', async () => {
153
+ await autoPostActivity(VALID_PROJECT_ID, 'Agent started work', 'session-123');
154
+
155
+ expect(mockSendProjectMessage).toHaveBeenCalledWith(
156
+ VALID_PROJECT_ID,
157
+ 'Agent started work',
158
+ 'session-123'
159
+ );
160
+ });
161
+
162
+ it('should silently ignore errors (never throws)', async () => {
163
+ mockSendProjectMessage.mockRejectedValue(new Error('Network error'));
164
+
165
+ // Should not throw
166
+ await expect(
167
+ autoPostActivity(VALID_PROJECT_ID, 'message', 'session-123')
168
+ ).resolves.toBeUndefined();
169
+ });
170
+
171
+ it('should do nothing when projectId is empty', async () => {
172
+ await autoPostActivity('', 'message', 'session-123');
173
+ expect(mockSendProjectMessage).not.toHaveBeenCalled();
174
+ });
175
+
176
+ it('should work without sessionId', async () => {
177
+ await autoPostActivity(VALID_PROJECT_ID, 'no session message');
178
+
179
+ expect(mockSendProjectMessage).toHaveBeenCalledWith(
180
+ VALID_PROJECT_ID,
181
+ 'no session message',
182
+ undefined
183
+ );
184
+ });
185
+ });
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Chat handlers
3
+ *
4
+ * Handlers for project chat tools:
5
+ * - send_project_message: Post a message to the project chat
6
+ * - get_project_messages: Read recent messages from project chat
7
+ *
8
+ * Also exports autoPostActivity — a fire-and-forget helper used by other
9
+ * handlers to log agent boot progress and key events to the chat window.
10
+ */
11
+
12
+ import type { Handler, HandlerRegistry } from './types.js';
13
+ import { parseArgs, uuidValidator } from '../validators.js';
14
+ import { getApiClient } from '../api-client.js';
15
+
16
+ const sendProjectMessageSchema = {
17
+ project_id: { type: 'string' as const, required: true as const, validate: uuidValidator },
18
+ message: { type: 'string' as const, required: true as const },
19
+ };
20
+
21
+ const getProjectMessagesSchema = {
22
+ project_id: { type: 'string' as const, required: true as const, validate: uuidValidator },
23
+ limit: { type: 'number' as const },
24
+ };
25
+
26
+ export const sendProjectMessage: Handler = async (args, ctx) => {
27
+ const { project_id, message } = parseArgs(args, sendProjectMessageSchema);
28
+ const api = getApiClient();
29
+ const response = await api.sendProjectMessage(project_id, message, ctx.session.currentSessionId || undefined);
30
+ if (!response.ok) {
31
+ return { result: { error: response.error || 'Failed to send message' }, isError: true };
32
+ }
33
+ return { result: response.data };
34
+ };
35
+
36
+ export const getProjectMessages: Handler = async (args, _ctx) => {
37
+ const { project_id, limit } = parseArgs(args, getProjectMessagesSchema);
38
+ const api = getApiClient();
39
+ const response = await api.getProjectMessages(project_id, limit);
40
+ if (!response.ok) {
41
+ return { result: { error: response.error || 'Failed to fetch messages' }, isError: true };
42
+ }
43
+ return { result: response.data };
44
+ };
45
+
46
+ /**
47
+ * Auto-post an agent activity message to the project chat.
48
+ *
49
+ * Fire-and-forget: errors are silently swallowed so auto-posting never
50
+ * interrupts or breaks the main tool response.
51
+ */
52
+ export async function autoPostActivity(
53
+ projectId: string,
54
+ message: string,
55
+ sessionId?: string | null
56
+ ): Promise<void> {
57
+ if (!projectId) return;
58
+ try {
59
+ const api = getApiClient();
60
+ await api.sendProjectMessage(projectId, message, sessionId ?? undefined);
61
+ } catch {
62
+ // Silently ignore — activity logging must never break main functionality
63
+ }
64
+ }
65
+
66
+ export const chatHandlers: HandlerRegistry = {
67
+ send_project_message: sendProjectMessage,
68
+ get_project_messages: getProjectMessages,
69
+ };
@@ -12,6 +12,8 @@
12
12
  * - add_deployment_requirement
13
13
  * - complete_deployment_requirement
14
14
  * - get_deployment_requirements
15
+ * - get_deployment_requirements_stats
16
+ * - reorder_deployment_requirements
15
17
  */
16
18
 
17
19
  import type { Handler, HandlerRegistry } from './types.js';
@@ -334,6 +336,32 @@ export const getDeploymentRequirementsStats: Handler = async (args, ctx) => {
334
336
  return { result: response.data };
335
337
  };
336
338
 
339
+ // ============================================================================
340
+ // Reorder Deployment Requirements
341
+ // ============================================================================
342
+
343
+ const reorderDeploymentRequirementsSchema = {
344
+ project_id: { type: 'string' as const, required: true as const, validate: uuidValidator },
345
+ stage: { type: 'string' as const, required: true as const, validate: createEnumValidator(REQUIREMENT_STAGES) },
346
+ requirement_ids: { type: 'object' as const, required: true as const },
347
+ };
348
+
349
+ export const reorderDeploymentRequirements: Handler = async (args, ctx) => {
350
+ const { project_id, stage, requirement_ids } = parseArgs(args, reorderDeploymentRequirementsSchema);
351
+
352
+ const apiClient = getApiClient();
353
+ const response = await apiClient.reorderDeploymentRequirements(project_id, {
354
+ stage,
355
+ requirement_ids: requirement_ids as unknown as string[],
356
+ });
357
+
358
+ if (!response.ok) {
359
+ return { result: { error: response.error || 'Failed to reorder deployment requirements' }, isError: true };
360
+ }
361
+
362
+ return { result: response.data };
363
+ };
364
+
337
365
  // ============================================================================
338
366
  // Scheduled Deployments
339
367
  // ============================================================================
@@ -531,6 +559,7 @@ export const deploymentHandlers: HandlerRegistry = {
531
559
  complete_deployment_requirement: completeDeploymentRequirement,
532
560
  get_deployment_requirements: getDeploymentRequirements,
533
561
  get_deployment_requirements_stats: getDeploymentRequirementsStats,
562
+ reorder_deployment_requirements: reorderDeploymentRequirements,
534
563
  // Scheduled deployments
535
564
  schedule_deployment: scheduleDeployment,
536
565
  get_scheduled_deployments: getScheduledDeployments,
@@ -167,6 +167,7 @@ export const TOOL_CATEGORIES: Record<string, { description: string; tools: Array
167
167
  { name: 'complete_deployment_requirement', brief: 'Mark step done' },
168
168
  { name: 'get_deployment_requirements', brief: 'List pre-deploy steps' },
169
169
  { name: 'get_deployment_requirements_stats', brief: 'Get requirements statistics' },
170
+ { name: 'reorder_deployment_requirements', brief: 'Reorder steps within a stage' },
170
171
  { name: 'schedule_deployment', brief: 'Schedule future deployment' },
171
172
  { name: 'get_scheduled_deployments', brief: 'List scheduled deployments' },
172
173
  { name: 'update_scheduled_deployment', brief: 'Update schedule config' },
@@ -30,6 +30,7 @@ export * from './roles.js';
30
30
  export * from './connectors.js';
31
31
  export * from './cloud-agents.js';
32
32
  export * from './version.js';
33
+ export * from './chat.js';
33
34
 
34
35
  import type { HandlerRegistry } from './types.js';
35
36
  import { milestoneHandlers } from './milestones.js';
@@ -56,6 +57,7 @@ import { roleHandlers } from './roles.js';
56
57
  import { connectorHandlers } from './connectors.js';
57
58
  import { cloudAgentHandlers } from './cloud-agents.js';
58
59
  import { versionHandlers } from './version.js';
60
+ import { chatHandlers } from './chat.js';
59
61
 
60
62
  /**
61
63
  * Build the complete handler registry from all modules
@@ -86,5 +88,6 @@ export function buildHandlerRegistry(): HandlerRegistry {
86
88
  ...connectorHandlers,
87
89
  ...cloudAgentHandlers,
88
90
  ...versionHandlers,
91
+ ...chatHandlers,
89
92
  };
90
93
  }
@@ -17,6 +17,7 @@ import { getApiClient } from '../api-client.js';
17
17
  import { getAgentGuidelinesTemplate, getAgentGuidelinesSummary } from '../templates/agent-guidelines.js';
18
18
  import { getFallbackHelpContent, getAvailableHelpTopics } from '../templates/help-content.js';
19
19
  import { normalizeGitUrl } from '../utils.js';
20
+ import { autoPostActivity } from './chat.js';
20
21
 
21
22
  /**
22
23
  * Simple hash for content change detection.
@@ -569,6 +570,17 @@ export const startWorkSession: Handler = async (args, ctx) => {
569
570
  : 'signal_idle() — no tasks available and fallback activities are disabled.';
570
571
  }
571
572
 
573
+ // Auto-post boot activity to project chat
574
+ if (data.project?.id) {
575
+ const persona = data.persona || 'Agent';
576
+ const nextTaskInfo = data.next_task ? ` Next task: **${data.next_task.title}**` : '';
577
+ void autoPostActivity(
578
+ data.project.id,
579
+ `🤖 **${persona}** started a work session.${nextTaskInfo}`,
580
+ data.session_id
581
+ );
582
+ }
583
+
572
584
  return { result };
573
585
  };
574
586
 
@@ -36,6 +36,7 @@ import {
36
36
  } from '../validators.js';
37
37
  import { getApiClient } from '../api-client.js';
38
38
  import { capPagination, PAGINATION_LIMITS } from '../utils.js';
39
+ import { autoPostActivity } from './chat.js';
39
40
 
40
41
  // Auto-detect machine hostname for worktree tracking
41
42
  const MACHINE_HOSTNAME = os.hostname();
@@ -591,6 +592,17 @@ export const completeTask: Handler = async (args, ctx) => {
591
592
  };
592
593
  }
593
594
 
595
+ // Auto-post completion activity to project chat
596
+ if (ctx.session.currentProjectId) {
597
+ const persona = ctx.session.currentPersona || 'Agent';
598
+ const summaryText = summary ? `: ${summary}` : '';
599
+ void autoPostActivity(
600
+ ctx.session.currentProjectId,
601
+ `✅ **${persona}** completed a task${summaryText}`,
602
+ ctx.session.currentSessionId || undefined
603
+ );
604
+ }
605
+
594
606
  return { result };
595
607
  };
596
608
 
@@ -1081,6 +1081,14 @@ Get pending deployment requirements.
1081
1081
  - stage (optional): preparation, deployment, verification, or all
1082
1082
  - status (optional): pending, completed, converted_to_task, or all (default: pending)`,
1083
1083
 
1084
+ reorder_deployment_requirements: `# reorder_deployment_requirements
1085
+ Reorder deployment requirements within a stage.
1086
+
1087
+ **Parameters:**
1088
+ - project_id (required): Project UUID
1089
+ - stage (required): preparation, deployment, or verification
1090
+ - requirement_ids (required): Array of requirement UUIDs in desired order`,
1091
+
1084
1092
  // Knowledge base
1085
1093
  query_knowledge_base: `# query_knowledge_base
1086
1094
  Query aggregated project knowledge in a single call. Reduces token usage by combining multiple data sources.
@@ -265,6 +265,19 @@ export const deploymentTools: Tool[] = [
265
265
  required: ['project_id'],
266
266
  },
267
267
  },
268
+ {
269
+ name: 'reorder_deployment_requirements',
270
+ description: `Reorder deployment requirements within a stage. Pass the requirement IDs in the desired order.`,
271
+ inputSchema: {
272
+ type: 'object',
273
+ properties: {
274
+ project_id: { type: 'string', description: 'Project UUID' },
275
+ stage: { type: 'string', enum: ['preparation', 'deployment', 'verification'], description: 'Deployment stage' },
276
+ requirement_ids: { type: 'array', items: { type: 'string' }, description: 'Ordered array of requirement UUIDs' },
277
+ },
278
+ required: ['project_id', 'stage', 'requirement_ids'],
279
+ },
280
+ },
268
281
  {
269
282
  name: 'schedule_deployment',
270
283
  description: `Schedule a deployment for a specific time. Supports one-time and recurring schedules with auto-trigger or manual trigger modes.`,