@vibescope/mcp-server 0.2.1 → 0.2.2

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 (93) hide show
  1. package/README.md +60 -7
  2. package/dist/api-client.d.ts +187 -0
  3. package/dist/api-client.js +48 -0
  4. package/dist/handlers/blockers.js +9 -8
  5. package/dist/handlers/bodies-of-work.js +14 -14
  6. package/dist/handlers/connectors.d.ts +45 -0
  7. package/dist/handlers/connectors.js +183 -0
  8. package/dist/handlers/cost.d.ts +10 -0
  9. package/dist/handlers/cost.js +54 -0
  10. package/dist/handlers/decisions.js +3 -3
  11. package/dist/handlers/deployment.js +35 -19
  12. package/dist/handlers/discovery.d.ts +7 -0
  13. package/dist/handlers/discovery.js +61 -2
  14. package/dist/handlers/fallback.js +5 -4
  15. package/dist/handlers/file-checkouts.d.ts +2 -0
  16. package/dist/handlers/file-checkouts.js +38 -6
  17. package/dist/handlers/findings.js +13 -12
  18. package/dist/handlers/git-issues.js +4 -4
  19. package/dist/handlers/ideas.js +5 -5
  20. package/dist/handlers/index.d.ts +1 -0
  21. package/dist/handlers/index.js +3 -0
  22. package/dist/handlers/milestones.js +5 -5
  23. package/dist/handlers/organizations.js +13 -13
  24. package/dist/handlers/progress.js +2 -2
  25. package/dist/handlers/project.js +6 -6
  26. package/dist/handlers/requests.js +3 -3
  27. package/dist/handlers/session.js +28 -9
  28. package/dist/handlers/sprints.js +17 -17
  29. package/dist/handlers/tasks.d.ts +2 -0
  30. package/dist/handlers/tasks.js +78 -20
  31. package/dist/handlers/types.d.ts +64 -2
  32. package/dist/handlers/types.js +48 -1
  33. package/dist/handlers/validation.js +3 -3
  34. package/dist/index.js +7 -2716
  35. package/dist/token-tracking.d.ts +74 -0
  36. package/dist/token-tracking.js +122 -0
  37. package/dist/tools.js +298 -9
  38. package/dist/utils.d.ts +5 -0
  39. package/dist/utils.js +17 -0
  40. package/docs/TOOLS.md +2053 -0
  41. package/package.json +4 -1
  42. package/scripts/generate-docs.ts +212 -0
  43. package/src/api-client.test.ts +718 -0
  44. package/src/api-client.ts +231 -0
  45. package/src/handlers/__test-setup__.ts +9 -0
  46. package/src/handlers/blockers.test.ts +31 -19
  47. package/src/handlers/blockers.ts +9 -8
  48. package/src/handlers/bodies-of-work.test.ts +55 -32
  49. package/src/handlers/bodies-of-work.ts +14 -14
  50. package/src/handlers/connectors.test.ts +834 -0
  51. package/src/handlers/connectors.ts +229 -0
  52. package/src/handlers/cost.ts +66 -0
  53. package/src/handlers/decisions.test.ts +34 -25
  54. package/src/handlers/decisions.ts +3 -3
  55. package/src/handlers/deployment.ts +39 -19
  56. package/src/handlers/discovery.ts +61 -2
  57. package/src/handlers/fallback.test.ts +26 -22
  58. package/src/handlers/fallback.ts +5 -4
  59. package/src/handlers/file-checkouts.test.ts +242 -49
  60. package/src/handlers/file-checkouts.ts +44 -6
  61. package/src/handlers/findings.test.ts +38 -24
  62. package/src/handlers/findings.ts +13 -12
  63. package/src/handlers/git-issues.test.ts +51 -43
  64. package/src/handlers/git-issues.ts +4 -4
  65. package/src/handlers/ideas.test.ts +28 -23
  66. package/src/handlers/ideas.ts +5 -5
  67. package/src/handlers/index.ts +3 -0
  68. package/src/handlers/milestones.test.ts +33 -28
  69. package/src/handlers/milestones.ts +5 -5
  70. package/src/handlers/organizations.test.ts +104 -83
  71. package/src/handlers/organizations.ts +13 -13
  72. package/src/handlers/progress.test.ts +20 -14
  73. package/src/handlers/progress.ts +2 -2
  74. package/src/handlers/project.test.ts +34 -27
  75. package/src/handlers/project.ts +6 -6
  76. package/src/handlers/requests.test.ts +27 -18
  77. package/src/handlers/requests.ts +3 -3
  78. package/src/handlers/session.test.ts +47 -0
  79. package/src/handlers/session.ts +32 -9
  80. package/src/handlers/sprints.test.ts +71 -50
  81. package/src/handlers/sprints.ts +17 -17
  82. package/src/handlers/tasks.test.ts +77 -15
  83. package/src/handlers/tasks.ts +90 -21
  84. package/src/handlers/tool-categories.test.ts +66 -0
  85. package/src/handlers/types.ts +81 -2
  86. package/src/handlers/validation.test.ts +78 -45
  87. package/src/handlers/validation.ts +3 -3
  88. package/src/index.ts +12 -2732
  89. package/src/token-tracking.test.ts +453 -0
  90. package/src/token-tracking.ts +164 -0
  91. package/src/tools.ts +298 -9
  92. package/src/utils.test.ts +2 -2
  93. package/src/utils.ts +17 -0
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Token Tracking Utilities
3
+ *
4
+ * Functions for estimating and tracking token usage across MCP tool calls.
5
+ * Extracted from index.ts to enable unit testing.
6
+ */
7
+ export interface ModelTokens {
8
+ input: number;
9
+ output: number;
10
+ }
11
+ export interface TokenUsage {
12
+ callCount: number;
13
+ totalTokens: number;
14
+ byTool: Record<string, {
15
+ calls: number;
16
+ tokens: number;
17
+ }>;
18
+ byModel: Record<string, ModelTokens>;
19
+ currentModel: string | null;
20
+ }
21
+ /**
22
+ * Estimate tokens from a JSON-serializable object.
23
+ * Uses a rough heuristic of ~4 characters per token.
24
+ *
25
+ * @param obj - Any JSON-serializable object
26
+ * @returns Estimated token count (always >= 1)
27
+ */
28
+ export declare function estimateTokens(obj: unknown): number;
29
+ /**
30
+ * Create a fresh token usage tracker.
31
+ */
32
+ export declare function createTokenUsage(): TokenUsage;
33
+ /**
34
+ * Track token usage for a tool call.
35
+ * Updates the usage object in-place with input/output token estimates.
36
+ *
37
+ * @param usage - The token usage object to update
38
+ * @param toolName - Name of the tool being called
39
+ * @param args - Input arguments to the tool
40
+ * @param response - Response from the tool
41
+ */
42
+ export declare function trackTokenUsage(usage: TokenUsage, toolName: string, args: unknown, response: unknown): void;
43
+ /**
44
+ * Set the current model for token tracking.
45
+ * Subsequent calls to trackTokenUsage will be attributed to this model.
46
+ *
47
+ * @param usage - The token usage object to update
48
+ * @param model - Model name (e.g., "opus", "sonnet", "haiku")
49
+ */
50
+ export declare function setCurrentModel(usage: TokenUsage, model: string | null): void;
51
+ /**
52
+ * Reset token usage tracking to initial state.
53
+ *
54
+ * @param usage - The token usage object to reset
55
+ */
56
+ export declare function resetTokenUsage(usage: TokenUsage): void;
57
+ /**
58
+ * Get a summary of token usage for reporting.
59
+ *
60
+ * @param usage - The token usage object
61
+ * @returns Summary object with stats
62
+ */
63
+ export declare function getTokenUsageSummary(usage: TokenUsage): {
64
+ total_calls: number;
65
+ total_tokens: number;
66
+ average_tokens_per_call: number;
67
+ by_tool: Record<string, {
68
+ calls: number;
69
+ tokens: number;
70
+ avg: number;
71
+ }>;
72
+ by_model: Record<string, ModelTokens>;
73
+ current_model: string | null;
74
+ };
@@ -0,0 +1,122 @@
1
+ /**
2
+ * Token Tracking Utilities
3
+ *
4
+ * Functions for estimating and tracking token usage across MCP tool calls.
5
+ * Extracted from index.ts to enable unit testing.
6
+ */
7
+ // ============================================================================
8
+ // Token Estimation
9
+ // ============================================================================
10
+ /**
11
+ * Estimate tokens from a JSON-serializable object.
12
+ * Uses a rough heuristic of ~4 characters per token.
13
+ *
14
+ * @param obj - Any JSON-serializable object
15
+ * @returns Estimated token count (always >= 1)
16
+ */
17
+ export function estimateTokens(obj) {
18
+ try {
19
+ const json = JSON.stringify(obj);
20
+ return Math.max(1, Math.ceil(json.length / 4));
21
+ }
22
+ catch {
23
+ // If JSON serialization fails, return a minimal estimate
24
+ return 1;
25
+ }
26
+ }
27
+ // ============================================================================
28
+ // Token Usage Tracking
29
+ // ============================================================================
30
+ /**
31
+ * Create a fresh token usage tracker.
32
+ */
33
+ export function createTokenUsage() {
34
+ return {
35
+ callCount: 0,
36
+ totalTokens: 0,
37
+ byTool: {},
38
+ byModel: {},
39
+ currentModel: null,
40
+ };
41
+ }
42
+ /**
43
+ * Track token usage for a tool call.
44
+ * Updates the usage object in-place with input/output token estimates.
45
+ *
46
+ * @param usage - The token usage object to update
47
+ * @param toolName - Name of the tool being called
48
+ * @param args - Input arguments to the tool
49
+ * @param response - Response from the tool
50
+ */
51
+ export function trackTokenUsage(usage, toolName, args, response) {
52
+ const inputTokens = estimateTokens(args);
53
+ const outputTokens = estimateTokens(response);
54
+ const totalTokens = inputTokens + outputTokens;
55
+ usage.callCount++;
56
+ usage.totalTokens += totalTokens;
57
+ if (!usage.byTool[toolName]) {
58
+ usage.byTool[toolName] = { calls: 0, tokens: 0 };
59
+ }
60
+ usage.byTool[toolName].calls++;
61
+ usage.byTool[toolName].tokens += totalTokens;
62
+ // Track by model if a model is set
63
+ const model = usage.currentModel;
64
+ if (model) {
65
+ if (!usage.byModel[model]) {
66
+ usage.byModel[model] = { input: 0, output: 0 };
67
+ }
68
+ usage.byModel[model].input += inputTokens;
69
+ usage.byModel[model].output += outputTokens;
70
+ }
71
+ }
72
+ /**
73
+ * Set the current model for token tracking.
74
+ * Subsequent calls to trackTokenUsage will be attributed to this model.
75
+ *
76
+ * @param usage - The token usage object to update
77
+ * @param model - Model name (e.g., "opus", "sonnet", "haiku")
78
+ */
79
+ export function setCurrentModel(usage, model) {
80
+ usage.currentModel = model;
81
+ }
82
+ /**
83
+ * Reset token usage tracking to initial state.
84
+ *
85
+ * @param usage - The token usage object to reset
86
+ */
87
+ export function resetTokenUsage(usage) {
88
+ usage.callCount = 0;
89
+ usage.totalTokens = 0;
90
+ usage.byTool = {};
91
+ usage.byModel = {};
92
+ usage.currentModel = null;
93
+ }
94
+ /**
95
+ * Get a summary of token usage for reporting.
96
+ *
97
+ * @param usage - The token usage object
98
+ * @returns Summary object with stats
99
+ */
100
+ export function getTokenUsageSummary(usage) {
101
+ const byTool = {};
102
+ for (const [tool, stats] of Object.entries(usage.byTool)) {
103
+ byTool[tool] = {
104
+ calls: stats.calls,
105
+ tokens: stats.tokens,
106
+ avg: stats.calls > 0 ? Math.round(stats.tokens / stats.calls) : 0,
107
+ };
108
+ }
109
+ // Deep copy byModel to prevent mutation
110
+ const byModel = {};
111
+ for (const [model, tokens] of Object.entries(usage.byModel)) {
112
+ byModel[model] = { input: tokens.input, output: tokens.output };
113
+ }
114
+ return {
115
+ total_calls: usage.callCount,
116
+ total_tokens: usage.totalTokens,
117
+ average_tokens_per_call: usage.callCount > 0 ? Math.round(usage.totalTokens / usage.callCount) : 0,
118
+ by_tool: byTool,
119
+ by_model: byModel,
120
+ current_model: usage.currentModel,
121
+ };
122
+ }
package/dist/tools.js CHANGED
@@ -5,7 +5,9 @@ export const tools = [
5
5
  {
6
6
  name: 'start_work_session',
7
7
  description: `CALL THIS FIRST when beginning work on a project.
8
- Returns session info, persona, role, and next task. Use mode:'full' for complete context.`,
8
+ Returns session info, persona, role, and next_task. Start the next_task IMMEDIATELY without asking the user.
9
+
10
+ Use mode:'full' for complete context, mode:'lite' (default) for minimal tokens.`,
9
11
  inputSchema: {
10
12
  type: 'object',
11
13
  properties: {
@@ -187,6 +189,40 @@ Returns session info, persona, role, and next task. Use mode:'full' for complete
187
189
  required: ['project_id'],
188
190
  },
189
191
  },
192
+ {
193
+ name: 'get_body_of_work_costs',
194
+ description: 'Get cost breakdown by body of work with phase-level details. Returns costs for pre/core/post phases and model breakdown.',
195
+ inputSchema: {
196
+ type: 'object',
197
+ properties: {
198
+ body_of_work_id: {
199
+ type: 'string',
200
+ description: 'Body of work UUID (optional if project_id provided)',
201
+ },
202
+ project_id: {
203
+ type: 'string',
204
+ description: 'Project UUID to get all body of work costs (optional if body_of_work_id provided)',
205
+ },
206
+ },
207
+ },
208
+ },
209
+ {
210
+ name: 'get_sprint_costs',
211
+ description: 'Get cost breakdown by sprint with velocity metrics. Returns cost per story point and phase breakdown.',
212
+ inputSchema: {
213
+ type: 'object',
214
+ properties: {
215
+ sprint_id: {
216
+ type: 'string',
217
+ description: 'Sprint UUID (optional if project_id provided)',
218
+ },
219
+ project_id: {
220
+ type: 'string',
221
+ description: 'Project UUID to get all sprint costs (optional if sprint_id provided)',
222
+ },
223
+ },
224
+ },
225
+ },
190
226
  // Knowledge Base Query Tool
191
227
  {
192
228
  name: 'query_knowledge_base',
@@ -231,7 +267,7 @@ Returns session info, persona, role, and next task. Use mode:'full' for complete
231
267
  properties: {
232
268
  category: {
233
269
  type: 'string',
234
- enum: ['session', 'project', 'tasks', 'milestones', 'progress', 'blockers', 'decisions', 'ideas', 'findings', 'validation', 'deployment', 'fallback', 'requests', 'organizations', 'cost', 'knowledge'],
270
+ enum: ['session', 'project', 'tasks', 'milestones', 'progress', 'blockers', 'decisions', 'ideas', 'findings', 'validation', 'deployment', 'fallback', 'bodies_of_work', 'sprints', 'requests', 'organizations', 'cost', 'git_issues', 'knowledge', 'discovery', 'subtasks', 'worktrees', 'roles', 'file_locks'],
235
271
  description: 'Category to list (omit for all categories)',
236
272
  },
237
273
  },
@@ -427,7 +463,9 @@ Returns session info, persona, role, and next task. Use mode:'full' for complete
427
463
  },
428
464
  {
429
465
  name: 'get_next_task',
430
- description: 'Get highest priority pending task. Skips claimed tasks. Check deployment_blocks_tasks first.',
466
+ description: `Get highest priority pending task. Start it IMMEDIATELY by calling update_task(task_id, status: "in_progress").
467
+
468
+ Do NOT ask the user for permission. Follow the directive in the response.`,
431
469
  inputSchema: {
432
470
  type: 'object',
433
471
  properties: {
@@ -483,7 +521,13 @@ Returns session info, persona, role, and next task. Use mode:'full' for complete
483
521
  },
484
522
  {
485
523
  name: 'update_task',
486
- description: 'Update task status, progress, or details. Include progress_note with progress_percentage.',
524
+ description: `Update task status, progress, or details. Include progress_note with progress_percentage.
525
+
526
+ IMPORTANT: When setting status to "in_progress", you MUST provide git_branch AND worktree_path to enable cleanup tracking.
527
+ Create worktree first: git worktree add ../PROJECT-task-TASKID -b feature/TASKID-description BASE_BRANCH
528
+ Then call: update_task(task_id, status: "in_progress", git_branch: "feature/TASKID-description", worktree_path: "../PROJECT-task-TASKID")
529
+
530
+ For projects without git branching (trunk-based or none), use skip_worktree_requirement: true.`,
487
531
  inputSchema: {
488
532
  type: 'object',
489
533
  properties: {
@@ -519,20 +563,35 @@ Returns session info, persona, role, and next task. Use mode:'full' for complete
519
563
  },
520
564
  git_branch: {
521
565
  type: 'string',
522
- description: 'Git branch associated with this task',
566
+ description: 'Git branch associated with this task. REQUIRED when status is "in_progress" (unless skip_worktree_requirement is true)',
567
+ },
568
+ worktree_path: {
569
+ type: 'string',
570
+ description: 'Git worktree path for this task (e.g., "../project-task-abc123"). Store this for cleanup tracking across sessions.',
523
571
  },
524
572
  model_capability: {
525
573
  type: 'string',
526
574
  enum: ['haiku', 'sonnet', 'opus'],
527
575
  description: 'Recommended model capability: haiku (simple tasks), sonnet (standard), opus (complex reasoning)',
528
576
  },
577
+ skip_worktree_requirement: {
578
+ type: 'boolean',
579
+ description: 'Skip git_branch requirement for projects without branching workflows (trunk-based or none). Default: false',
580
+ },
529
581
  },
530
582
  required: ['task_id'],
531
583
  },
532
584
  },
533
585
  {
534
586
  name: 'complete_task',
535
- description: 'Mark task done. Returns next_task and context counts (validation, blockers, deployment).',
587
+ description: `Mark task done. Returns next_task which you MUST start immediately without asking the user.
588
+
589
+ CRITICAL: After calling this tool, you must:
590
+ 1. If next_task is returned → Start it immediately by calling update_task(task_id, status: "in_progress")
591
+ 2. If no next_task → Call get_next_task() or start a fallback_activity
592
+ 3. NEVER ask the user "What should I do next?" or "Should I continue?"
593
+
594
+ The auto_continue: true flag in the response means you are expected to continue working autonomously.`,
536
595
  inputSchema: {
537
596
  type: 'object',
538
597
  properties: {
@@ -1104,6 +1163,46 @@ Returns subtasks with aggregate completion stats.`,
1104
1163
  required: ['parent_task_id'],
1105
1164
  },
1106
1165
  },
1166
+ {
1167
+ name: 'get_stale_worktrees',
1168
+ description: `Get worktrees that need cleanup.
1169
+
1170
+ Returns tasks with worktree_path set where:
1171
+ - Task is completed or cancelled (worktree should have been cleaned up)
1172
+ - Task has been abandoned (no activity for 24+ hours while in_progress)
1173
+
1174
+ IMPORTANT: Call this on session start to clean up orphaned worktrees from previous sessions.
1175
+ For each stale worktree:
1176
+ 1. Run: git worktree remove <worktree_path>
1177
+ 2. Call: clear_worktree_path(task_id)`,
1178
+ inputSchema: {
1179
+ type: 'object',
1180
+ properties: {
1181
+ project_id: {
1182
+ type: 'string',
1183
+ description: 'Project UUID',
1184
+ },
1185
+ },
1186
+ required: ['project_id'],
1187
+ },
1188
+ },
1189
+ {
1190
+ name: 'clear_worktree_path',
1191
+ description: `Clear the worktree_path from a task after cleanup.
1192
+
1193
+ Call this AFTER removing the worktree with git worktree remove.
1194
+ This marks the task as cleaned up so it won't appear in get_stale_worktrees.`,
1195
+ inputSchema: {
1196
+ type: 'object',
1197
+ properties: {
1198
+ task_id: {
1199
+ type: 'string',
1200
+ description: 'Task UUID',
1201
+ },
1202
+ },
1203
+ required: ['task_id'],
1204
+ },
1205
+ },
1107
1206
  {
1108
1207
  name: 'heartbeat',
1109
1208
  description: `Send heartbeat to maintain 'active' status. Call every 30-60 seconds.`,
@@ -1432,8 +1531,14 @@ Returns subtasks with aggregate completion stats.`,
1432
1531
  },
1433
1532
  schedule_type: {
1434
1533
  type: 'string',
1435
- description: 'Schedule type: once (one-time), daily, weekly, or monthly',
1436
- enum: ['once', 'daily', 'weekly', 'monthly'],
1534
+ description: 'Schedule type: once (one-time), hourly, daily, weekly, or monthly',
1535
+ enum: ['once', 'hourly', 'daily', 'weekly', 'monthly'],
1536
+ },
1537
+ hours_interval: {
1538
+ type: 'number',
1539
+ description: 'For hourly schedules, the number of hours between runs (1-24, default: 1)',
1540
+ minimum: 1,
1541
+ maximum: 24,
1437
1542
  },
1438
1543
  auto_trigger: {
1439
1544
  type: 'boolean',
@@ -1496,7 +1601,13 @@ Returns subtasks with aggregate completion stats.`,
1496
1601
  schedule_type: {
1497
1602
  type: 'string',
1498
1603
  description: 'New schedule type',
1499
- enum: ['once', 'daily', 'weekly', 'monthly'],
1604
+ enum: ['once', 'hourly', 'daily', 'weekly', 'monthly'],
1605
+ },
1606
+ hours_interval: {
1607
+ type: 'number',
1608
+ description: 'For hourly schedules, the number of hours between runs (1-24)',
1609
+ minimum: 1,
1610
+ maximum: 24,
1500
1611
  },
1501
1612
  auto_trigger: {
1502
1613
  type: 'boolean',
@@ -1594,6 +1705,7 @@ Returns subtasks with aggregate completion stats.`,
1594
1705
  'documentation_review',
1595
1706
  'dependency_audit',
1596
1707
  'validate_completed_tasks',
1708
+ 'worktree_cleanup',
1597
1709
  ],
1598
1710
  },
1599
1711
  },
@@ -2912,4 +3024,181 @@ Returns committed vs completed points and average velocity.`,
2912
3024
  required: ['git_issue_id'],
2913
3025
  },
2914
3026
  },
3027
+ // ============================================================================
3028
+ // Connector Tools (External Integrations)
3029
+ // ============================================================================
3030
+ {
3031
+ name: 'get_connectors',
3032
+ description: `List connectors for a project. Connectors enable sending events to external services (Slack, Discord, webhooks, etc.).`,
3033
+ inputSchema: {
3034
+ type: 'object',
3035
+ properties: {
3036
+ project_id: {
3037
+ type: 'string',
3038
+ description: 'Project UUID',
3039
+ },
3040
+ type: {
3041
+ type: 'string',
3042
+ enum: ['webhook', 'slack', 'discord', 'github', 'custom'],
3043
+ description: 'Filter by connector type (optional)',
3044
+ },
3045
+ status: {
3046
+ type: 'string',
3047
+ enum: ['active', 'disabled'],
3048
+ description: 'Filter by status (optional)',
3049
+ },
3050
+ limit: {
3051
+ type: 'number',
3052
+ description: 'Max connectors to return (default: 50)',
3053
+ },
3054
+ offset: {
3055
+ type: 'number',
3056
+ description: 'Pagination offset (default: 0)',
3057
+ },
3058
+ },
3059
+ required: ['project_id'],
3060
+ },
3061
+ },
3062
+ {
3063
+ name: 'get_connector',
3064
+ description: `Get a single connector with full details including configuration (sensitive fields are masked).`,
3065
+ inputSchema: {
3066
+ type: 'object',
3067
+ properties: {
3068
+ connector_id: {
3069
+ type: 'string',
3070
+ description: 'Connector UUID',
3071
+ },
3072
+ },
3073
+ required: ['connector_id'],
3074
+ },
3075
+ },
3076
+ {
3077
+ name: 'add_connector',
3078
+ description: `Add a new connector for external integrations. Supports webhook, Slack, Discord, GitHub, and custom connectors.`,
3079
+ inputSchema: {
3080
+ type: 'object',
3081
+ properties: {
3082
+ project_id: {
3083
+ type: 'string',
3084
+ description: 'Project UUID',
3085
+ },
3086
+ name: {
3087
+ type: 'string',
3088
+ description: 'Connector name (e.g., "Slack Notifications")',
3089
+ },
3090
+ type: {
3091
+ type: 'string',
3092
+ enum: ['webhook', 'slack', 'discord', 'github', 'custom'],
3093
+ description: 'Connector type',
3094
+ },
3095
+ description: {
3096
+ type: 'string',
3097
+ description: 'Optional description',
3098
+ },
3099
+ config: {
3100
+ type: 'object',
3101
+ description: 'Type-specific configuration (e.g., { webhook_url: "..." } for Slack)',
3102
+ },
3103
+ events: {
3104
+ type: 'object',
3105
+ description: 'Event subscriptions (e.g., { task_completed: true, blocker_added: true })',
3106
+ },
3107
+ },
3108
+ required: ['project_id', 'name', 'type'],
3109
+ },
3110
+ },
3111
+ {
3112
+ name: 'update_connector',
3113
+ description: `Update a connector's configuration, events, or status.`,
3114
+ inputSchema: {
3115
+ type: 'object',
3116
+ properties: {
3117
+ connector_id: {
3118
+ type: 'string',
3119
+ description: 'Connector UUID',
3120
+ },
3121
+ name: {
3122
+ type: 'string',
3123
+ description: 'Updated name',
3124
+ },
3125
+ description: {
3126
+ type: 'string',
3127
+ description: 'Updated description',
3128
+ },
3129
+ config: {
3130
+ type: 'object',
3131
+ description: 'Updated configuration (merged with existing)',
3132
+ },
3133
+ events: {
3134
+ type: 'object',
3135
+ description: 'Updated event subscriptions',
3136
+ },
3137
+ status: {
3138
+ type: 'string',
3139
+ enum: ['active', 'disabled'],
3140
+ description: 'Enable or disable the connector',
3141
+ },
3142
+ },
3143
+ required: ['connector_id'],
3144
+ },
3145
+ },
3146
+ {
3147
+ name: 'delete_connector',
3148
+ description: `Delete a connector.`,
3149
+ inputSchema: {
3150
+ type: 'object',
3151
+ properties: {
3152
+ connector_id: {
3153
+ type: 'string',
3154
+ description: 'Connector UUID',
3155
+ },
3156
+ },
3157
+ required: ['connector_id'],
3158
+ },
3159
+ },
3160
+ {
3161
+ name: 'test_connector',
3162
+ description: `Test a connector by sending a test event. Returns success/failure status.`,
3163
+ inputSchema: {
3164
+ type: 'object',
3165
+ properties: {
3166
+ connector_id: {
3167
+ type: 'string',
3168
+ description: 'Connector UUID to test',
3169
+ },
3170
+ },
3171
+ required: ['connector_id'],
3172
+ },
3173
+ },
3174
+ {
3175
+ name: 'get_connector_events',
3176
+ description: `Get event history for a connector or project. Shows delivery status and errors.`,
3177
+ inputSchema: {
3178
+ type: 'object',
3179
+ properties: {
3180
+ connector_id: {
3181
+ type: 'string',
3182
+ description: 'Connector UUID (optional if project_id provided)',
3183
+ },
3184
+ project_id: {
3185
+ type: 'string',
3186
+ description: 'Project UUID (optional if connector_id provided)',
3187
+ },
3188
+ status: {
3189
+ type: 'string',
3190
+ enum: ['pending', 'sent', 'failed', 'retrying'],
3191
+ description: 'Filter by delivery status (optional)',
3192
+ },
3193
+ limit: {
3194
+ type: 'number',
3195
+ description: 'Max events to return (default: 50)',
3196
+ },
3197
+ offset: {
3198
+ type: 'number',
3199
+ description: 'Pagination offset (default: 0)',
3200
+ },
3201
+ },
3202
+ },
3203
+ },
2915
3204
  ];
package/dist/utils.d.ts CHANGED
@@ -55,6 +55,11 @@ export declare const FALLBACK_ACTIVITIES: readonly [{
55
55
  readonly title: "Validate completed tasks";
56
56
  readonly description: "Review tasks completed by other agents to ensure quality.";
57
57
  readonly prompt: "Call get_tasks_awaiting_validation to find completed tasks that need review. Validate each one by checking the implementation and running tests if applicable.";
58
+ }, {
59
+ readonly activity: "worktree_cleanup";
60
+ readonly title: "Clean up stale worktrees";
61
+ readonly description: "Find and remove git worktrees from completed or abandoned tasks.";
62
+ readonly prompt: "Clean up stale git worktrees to reclaim disk space and prevent confusion:\n\n1. Call get_stale_worktrees(project_id) to find worktrees needing cleanup\n2. For each stale worktree returned:\n a. Check if the worktree directory exists: ls -la <worktree_path>\n b. If it exists, remove it: git worktree remove <worktree_path>\n c. If removal fails (untracked files), use: git worktree remove --force <worktree_path>\n d. Call clear_worktree_path(task_id) to mark it as cleaned up\n3. Run 'git worktree list' to verify cleanup\n4. Log any issues encountered with add_blocker if worktrees cannot be removed\n\nThis prevents disk bloat from accumulated worktrees and keeps the workspace clean.";
58
63
  }];
59
64
  export type FallbackActivity = typeof FALLBACK_ACTIVITIES[number];
60
65
  /**
package/dist/utils.js CHANGED
@@ -125,6 +125,23 @@ export const FALLBACK_ACTIVITIES = [
125
125
  description: 'Review tasks completed by other agents to ensure quality.',
126
126
  prompt: 'Call get_tasks_awaiting_validation to find completed tasks that need review. Validate each one by checking the implementation and running tests if applicable.',
127
127
  },
128
+ {
129
+ activity: 'worktree_cleanup',
130
+ title: 'Clean up stale worktrees',
131
+ description: 'Find and remove git worktrees from completed or abandoned tasks.',
132
+ prompt: `Clean up stale git worktrees to reclaim disk space and prevent confusion:
133
+
134
+ 1. Call get_stale_worktrees(project_id) to find worktrees needing cleanup
135
+ 2. For each stale worktree returned:
136
+ a. Check if the worktree directory exists: ls -la <worktree_path>
137
+ b. If it exists, remove it: git worktree remove <worktree_path>
138
+ c. If removal fails (untracked files), use: git worktree remove --force <worktree_path>
139
+ d. Call clear_worktree_path(task_id) to mark it as cleaned up
140
+ 3. Run 'git worktree list' to verify cleanup
141
+ 4. Log any issues encountered with add_blocker if worktrees cannot be removed
142
+
143
+ This prevents disk bloat from accumulated worktrees and keeps the workspace clean.`,
144
+ },
128
145
  ];
129
146
  /**
130
147
  * Get a random fallback activity