@vibescope/mcp-server 0.4.0 → 0.4.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 (70) hide show
  1. package/dist/api-client/fallback.d.ts +33 -0
  2. package/dist/api-client/fallback.js +21 -0
  3. package/dist/api-client/findings.d.ts +69 -0
  4. package/dist/api-client/findings.js +36 -0
  5. package/dist/api-client/index.d.ts +78 -1
  6. package/dist/api-client/index.js +74 -4
  7. package/dist/api-client/milestones.d.ts +59 -0
  8. package/dist/api-client/milestones.js +30 -0
  9. package/dist/api-client/validation.d.ts +35 -0
  10. package/dist/api-client/validation.js +23 -0
  11. package/dist/api-client.d.ts +4 -0
  12. package/dist/cli-init.d.ts +17 -0
  13. package/dist/cli-init.js +497 -0
  14. package/dist/handlers/cloud-agents.d.ts +4 -0
  15. package/dist/handlers/cloud-agents.js +26 -12
  16. package/dist/handlers/discovery.js +15 -0
  17. package/dist/handlers/findings.js +1 -1
  18. package/dist/handlers/ideas.js +1 -1
  19. package/dist/handlers/index.d.ts +1 -0
  20. package/dist/handlers/index.js +3 -0
  21. package/dist/handlers/session.js +115 -2
  22. package/dist/handlers/tasks.js +7 -5
  23. package/dist/handlers/tool-docs.js +344 -0
  24. package/dist/handlers/version.d.ts +5 -0
  25. package/dist/handlers/version.js +53 -0
  26. package/dist/index.js +7 -0
  27. package/dist/templates/agent-guidelines.d.ts +3 -1
  28. package/dist/templates/agent-guidelines.js +5 -1
  29. package/dist/templates/help-content.js +2 -2
  30. package/dist/tools/chat.d.ts +7 -0
  31. package/dist/tools/chat.js +43 -0
  32. package/dist/tools/cloud-agents.js +31 -0
  33. package/dist/tools/index.d.ts +3 -1
  34. package/dist/tools/index.js +6 -1
  35. package/dist/tools/project.js +1 -1
  36. package/dist/tools/tasks.js +8 -0
  37. package/dist/tools/version.d.ts +5 -0
  38. package/dist/tools/version.js +28 -0
  39. package/dist/version.d.ts +28 -0
  40. package/dist/version.js +91 -0
  41. package/docs/TOOLS.md +93 -3
  42. package/package.json +4 -2
  43. package/src/api-client/fallback.ts +52 -0
  44. package/src/api-client/findings.ts +100 -0
  45. package/src/api-client/index.ts +91 -9
  46. package/src/api-client/milestones.ts +83 -0
  47. package/src/api-client/validation.ts +60 -0
  48. package/src/api-client.ts +4 -0
  49. package/src/cli-init.ts +557 -0
  50. package/src/handlers/cloud-agents.test.ts +438 -0
  51. package/src/handlers/cloud-agents.ts +35 -17
  52. package/src/handlers/discovery.ts +15 -0
  53. package/src/handlers/findings.ts +1 -1
  54. package/src/handlers/ideas.ts +1 -1
  55. package/src/handlers/index.ts +3 -0
  56. package/src/handlers/session.ts +128 -2
  57. package/src/handlers/tasks.ts +7 -5
  58. package/src/handlers/tool-docs.test.ts +511 -0
  59. package/src/handlers/tool-docs.ts +382 -0
  60. package/src/handlers/version.ts +63 -0
  61. package/src/index.ts +9 -0
  62. package/src/templates/agent-guidelines.ts +6 -1
  63. package/src/templates/help-content.ts +2 -2
  64. package/src/tools/chat.ts +46 -0
  65. package/src/tools/cloud-agents.ts +31 -0
  66. package/src/tools/index.ts +6 -0
  67. package/src/tools/project.ts +1 -1
  68. package/src/tools/tasks.ts +8 -0
  69. package/src/tools/version.ts +34 -0
  70. package/src/version.ts +109 -0
@@ -148,9 +148,27 @@ export const startWorkSession = async (args, ctx) => {
148
148
  result.auto_continue = true;
149
149
  // Session info
150
150
  result.session_id = data.session_id;
151
+ result.IMPORTANT_session_id_reminder = `Save this session_id ("${data.session_id}") and pass it on EVERY update_task and complete_task call. Without it, the dashboard shows "Agent" instead of your name.`;
151
152
  result.persona = data.persona;
152
153
  result.role = data.role;
153
154
  result.project = data.project;
155
+ // For cloud agents: include workspace setup instructions if repo not yet cloned
156
+ // Cloud agents pass git_url; check if workspace needs setup
157
+ if (git_url && data.project?.git_url) {
158
+ result.workspace_setup = {
159
+ message: 'If the project repo is NOT already cloned to your workspace, follow these steps:',
160
+ steps: [
161
+ `git clone ${data.project.git_url} ~/workspace/project`,
162
+ 'cd ~/workspace/project',
163
+ ...(data.project.git_workflow === 'git-flow'
164
+ ? [`git checkout ${data.project.git_develop_branch || 'develop'}`]
165
+ : []),
166
+ 'Install dependencies (check for pnpm-lock.yaml, package-lock.json, etc.)',
167
+ 'If using SvelteKit: run `pnpm exec svelte-kit sync` or equivalent',
168
+ ],
169
+ note: 'Skip these steps if ~/workspace/project already exists and has the repo.',
170
+ };
171
+ }
154
172
  // Inform agent if git_url was normalized (helps explain URL matching behavior)
155
173
  if (gitUrlWasNormalized) {
156
174
  result.git_url_normalized = {
@@ -259,6 +277,99 @@ export const startWorkSession = async (args, ctx) => {
259
277
  result.directive = `SETUP REQUIRED: This is your first time connecting as a ${data.agent_setup.agent_type} agent. Follow the agent_setup instructions before starting work.`;
260
278
  }
261
279
  }
280
+ // Build dynamic AGENT_RULES from project settings
281
+ const agentRules = [];
282
+ const projectWorkflow = data.project?.git_workflow;
283
+ const isBranching = projectWorkflow === 'git-flow' || projectWorkflow === 'github-flow';
284
+ const ruleBaseBranch = projectWorkflow === 'git-flow'
285
+ ? (data.project?.git_develop_branch || 'develop')
286
+ : (data.project?.git_main_branch || 'main');
287
+ // Git workflow rules (dynamic based on project settings)
288
+ if (isBranching) {
289
+ agentRules.push(`WORKTREE REQUIRED: Create a git worktree BEFORE making ANY file edits. Command: git worktree add ../PROJECT-PERSONA-task -b feature/TASKID-desc ${ruleBaseBranch}`);
290
+ agentRules.push(`REBASE BEFORE PR: Always rebase onto ${ruleBaseBranch} before creating a PR. Run: git fetch origin && git rebase origin/${ruleBaseBranch} && git push --force-with-lease. This prevents overwriting other agents' work.`);
291
+ }
292
+ if (projectWorkflow && projectWorkflow !== 'none') {
293
+ agentRules.push(`GIT WORKFLOW: This project uses ${projectWorkflow}. Branch from ${ruleBaseBranch}. Do NOT commit directly to main or develop.`);
294
+ }
295
+ // Task lifecycle rules
296
+ agentRules.push('COMPLETE TASKS: Always call complete_task(task_id, summary, session_id) immediately after creating a PR. This is mandatory — it updates the dashboard and triggers validation.');
297
+ agentRules.push('SESSION ID: Pass session_id on EVERY update_task and complete_task call. Without it, the dashboard shows "Agent" instead of your name.');
298
+ agentRules.push(`STATUS UPDATES: Call update_agent_status(status_message: "Working on: TASK_TITLE", project_id: "${data.project?.id || ''}", agent_name: "${result.persona || ''}") whenever you start or finish a task.`);
299
+ agentRules.push('TRACK PROGRESS: Call update_task with progress_percentage (0-100) every 15-20% of task completion.');
300
+ // Validation rules (dynamic based on project settings)
301
+ if (data.project?.validation_required !== false) {
302
+ agentRules.push('REVIEW REQUIRED: All completed tasks must be reviewed/validated by another agent before merging.');
303
+ }
304
+ if (data.project?.auto_merge_on_approval !== false) {
305
+ agentRules.push('AUTO-MERGE: After approving a PR during validation, merge it immediately with `gh pr merge --squash`.');
306
+ }
307
+ // Autonomy rules
308
+ agentRules.push('BE AUTONOMOUS: Pick up tasks without asking permission. Never ask "Should I continue?" — just continue to the next task.');
309
+ agentRules.push('BREAK DOWN COMPLEX TASKS: If a task is too large, create subtasks with add_subtask() and start on the first one immediately.');
310
+ result.AGENT_RULES = agentRules;
311
+ // Build WORKFLOW section — dynamic step-by-step instructions
312
+ // This replaces the hardcoded workflow in CLAUDE.md
313
+ const workflow = {};
314
+ // Continuous work loop
315
+ workflow.continuous_work = {
316
+ description: 'After completing a task, immediately continue to the next one.',
317
+ steps: [
318
+ 'complete_task(task_id, summary, session_id) — returns next_task if available',
319
+ 'If no next_task returned: call get_next_task(project_id)',
320
+ 'If no tasks available: call get_pending_requests(project_id) and handle any',
321
+ 'If still nothing: call signal_idle() then start_fallback_activity(project_id, activity: "code_review")',
322
+ ],
323
+ rule: 'Never ask permission. Never stop working while tasks exist.',
324
+ };
325
+ // Validation workflow (only if validation is enabled)
326
+ if (data.project?.validation_required !== false) {
327
+ workflow.validation = {
328
+ description: 'How to validate/review completed tasks. Review PRs in FIFO order (lowest PR number first).',
329
+ steps: [
330
+ 'claim_validation(task_id) — returns worktree setup commands and PR info',
331
+ `Set up worktree from existing branch: git fetch origin feature/xxx && git worktree add ../PROJECT-PERSONA-validation feature/xxx`,
332
+ 'Review code, run tests if applicable',
333
+ 'Verify PR checks: gh pr view <PR> --json statusCheckRollup,mergeable',
334
+ 'Approve: validate_task(task_id, approved: true, pr_checks_passing: true, validation_notes: "...")',
335
+ data.project?.auto_merge_on_approval !== false
336
+ ? 'Merge immediately: gh pr merge <PR> --squash'
337
+ : 'Do NOT merge — wait for project owner to merge.',
338
+ 'Reject: validate_task(task_id, approved: false, validation_notes: "...", create_fix_task: true)',
339
+ 'Clean up worktree after validation',
340
+ ],
341
+ handle_failures: {
342
+ tests_fail: 'Use create_fix_task: true in validate_task() to create a follow-up task',
343
+ merge_conflicts: 'Create a task: add_task(project_id, title: "Resolve merge conflicts in PR #XXX")',
344
+ minor_issues: 'Fix directly in the branch, push, and re-validate',
345
+ closed_pr: 'cancel_task(task_id, cancelled_reason: "pr_closed")',
346
+ },
347
+ rule: 'Every PR review MUST end with a clear action. Never leave PRs unmerged or unresolved.',
348
+ };
349
+ // Post-merge branch sync (git-flow only)
350
+ if (projectWorkflow === 'git-flow' && data.project) {
351
+ const devBranch = data.project.git_develop_branch || 'develop';
352
+ workflow.post_merge_sync = {
353
+ description: `After merging to main, sync main back to ${devBranch} to prevent divergence.`,
354
+ commands: [
355
+ `git checkout ${devBranch} && git pull origin ${devBranch}`,
356
+ 'git merge origin/main',
357
+ `git push origin ${devBranch}`,
358
+ ],
359
+ };
360
+ }
361
+ }
362
+ // Deployment resolution workflow
363
+ workflow.deployment_resolution = {
364
+ description: 'When a fix already exists but just needs deployment',
365
+ steps: [
366
+ 'add_finding(project_id, title: "Fix exists - needs deployment", category: "other", severity: "info")',
367
+ 'complete_task(task_id, summary: "Fix exists in [branch/commit], pending deployment", session_id)',
368
+ 'check_deployment_status(project_id) then request_deployment(project_id) if needed',
369
+ ],
370
+ rule: 'Don\'t block tasks waiting for deployment — investigation is complete when you identify the resolution.',
371
+ };
372
+ result.WORKFLOW = workflow;
262
373
  // Add next action at end - pending requests take priority over validation, then regular tasks
263
374
  if (hasUrgentQuestions) {
264
375
  const firstQuestion = data.URGENT_QUESTIONS?.requests?.[0] || data.pending_requests?.[0];
@@ -271,10 +382,12 @@ export const startWorkSession = async (args, ctx) => {
271
382
  result.next_action = data.next_action || `claim_validation(task_id: "${data.awaiting_validation[0].id}")`;
272
383
  }
273
384
  else if (data.next_task) {
274
- result.next_action = `update_task(task_id: "${data.next_task.id}", status: "in_progress")`;
385
+ result.next_action = `update_task(task_id: "${data.next_task.id}", status: "in_progress", session_id: "${result.session_id}")`;
275
386
  }
276
387
  else if (data.project) {
277
- result.next_action = `start_fallback_activity(project_id: "${data.project.id}", activity: "code_review")`;
388
+ result.next_action = data.project.fallback_activities_enabled !== false
389
+ ? `start_fallback_activity(project_id: "${data.project.id}", activity: "code_review")`
390
+ : 'signal_idle() — no tasks available and fallback activities are disabled.';
278
391
  }
279
392
  return { result };
280
393
  };
@@ -60,10 +60,12 @@ const updateTaskSchema = {
60
60
  worktree_path: { type: 'string' },
61
61
  task_type: { type: 'string', validate: createEnumValidator(VALID_TASK_TYPES) },
62
62
  skip_worktree_requirement: { type: 'boolean', default: false },
63
+ session_id: { type: 'string' },
63
64
  };
64
65
  const completeTaskSchema = {
65
66
  task_id: { type: 'string', required: true, validate: uuidValidator },
66
67
  summary: { type: 'string' },
68
+ session_id: { type: 'string' },
67
69
  };
68
70
  const deleteTaskSchema = {
69
71
  task_id: { type: 'string', required: true, validate: uuidValidator },
@@ -278,7 +280,7 @@ export const addTask = async (args, ctx) => {
278
280
  return { result };
279
281
  };
280
282
  export const updateTask = async (args, ctx) => {
281
- const { task_id, title, description, priority, status, progress_percentage, progress_note, estimated_minutes, git_branch, worktree_path, task_type, skip_worktree_requirement } = parseArgs(args, updateTaskSchema);
283
+ const { task_id, title, description, priority, status, progress_percentage, progress_note, estimated_minutes, git_branch, worktree_path, task_type, skip_worktree_requirement, session_id: explicit_session_id } = parseArgs(args, updateTaskSchema);
282
284
  const updates = { title, description, priority, status, progress_percentage, estimated_minutes, git_branch, worktree_path, task_type };
283
285
  // Enforce worktree creation: require git_branch when marking task as in_progress
284
286
  // This ensures multi-agent collaboration works properly with isolated worktrees
@@ -300,7 +302,7 @@ export const updateTask = async (args, ctx) => {
300
302
  const response = await api.updateTask(task_id, {
301
303
  ...updates,
302
304
  progress_note,
303
- session_id: ctx.session.currentSessionId || undefined,
305
+ session_id: explicit_session_id || ctx.session.currentSessionId || undefined,
304
306
  });
305
307
  if (!response.ok) {
306
308
  // Check for specific error types
@@ -416,7 +418,7 @@ export const updateTask = async (args, ctx) => {
416
418
  message: 'If investigation reveals the fix already exists but needs deployment:',
417
419
  steps: [
418
420
  '1. Add finding: add_finding(project_id, title: "Fix exists, awaits deployment", category: "other", severity: "info", description: "...", related_task_id: task_id)',
419
- '2. Complete task: complete_task(task_id, summary: "Fix already exists in codebase (PR #XXX). Needs deployment.")',
421
+ '2. Complete task: complete_task(task_id, summary: "Fix already exists in codebase (PR #{pr_number}). Needs deployment.")',
420
422
  '3. Check deployment: check_deployment_status(project_id)',
421
423
  '4. Request deployment if not pending: request_deployment(project_id, notes: "Includes fix for [issue]")',
422
424
  ],
@@ -426,11 +428,11 @@ export const updateTask = async (args, ctx) => {
426
428
  return { result };
427
429
  };
428
430
  export const completeTask = async (args, ctx) => {
429
- const { task_id, summary } = parseArgs(args, completeTaskSchema);
431
+ const { task_id, summary, session_id: explicit_session_id } = parseArgs(args, completeTaskSchema);
430
432
  const api = getApiClient();
431
433
  const response = await api.completeTask(task_id, {
432
434
  summary,
433
- session_id: ctx.session.currentSessionId || undefined,
435
+ session_id: explicit_session_id || ctx.session.currentSessionId || undefined,
434
436
  });
435
437
  if (!response.ok) {
436
438
  return { result: { error: response.error || 'Failed to complete task' }, isError: true };
@@ -980,4 +980,348 @@ Query aggregated project knowledge in a single call. Reduces token usage by comb
980
980
  **Token savings:** Replaces multiple tool calls (get_findings, get_decisions, get_blockers, etc.) with one call.
981
981
 
982
982
  **Example:** query_knowledge_base(project_id, categories: ["findings", "decisions"], limit: 10)`,
983
+ // Session tools (additional)
984
+ report_token_usage: `# report_token_usage
985
+ Report actual token usage from Claude API responses.
986
+
987
+ **Parameters:**
988
+ - session_id (optional): Session UUID (uses current session if not provided)
989
+ - input_tokens (required): Number of input tokens
990
+ - output_tokens (required): Number of output tokens
991
+ - model (optional): Model used (e.g., "claude-3-opus")
992
+
993
+ **Returns:** Updated token usage summary`,
994
+ signal_idle: `# signal_idle
995
+ Signal that the agent is idle and available for work.
996
+
997
+ **Parameters:**
998
+ - session_id (optional): Session UUID (uses current session if not provided)
999
+
1000
+ **Returns:** Idle status confirmation, may include suggested activities`,
1001
+ confirm_agent_setup: `# confirm_agent_setup
1002
+ Confirm that agent setup is complete after following setup instructions.
1003
+
1004
+ **Parameters:**
1005
+ - project_id (required): Project UUID
1006
+ - agent_type (required): Type of agent (e.g., "claude", "gemini")
1007
+
1008
+ **Returns:** Setup confirmation status`,
1009
+ // Project tools (additional)
1010
+ get_project_summary: `# get_project_summary
1011
+ Get unified project statistics overview in a single call.
1012
+
1013
+ **Parameters:**
1014
+ - project_id (required): Project UUID
1015
+
1016
+ **Returns:** Task counts, blocker counts, finding counts, decision counts, and more`,
1017
+ // Blocker tools (additional)
1018
+ get_blocker: `# get_blocker
1019
+ Get a single blocker by ID.
1020
+
1021
+ **Parameters:**
1022
+ - blocker_id (required): Blocker UUID
1023
+
1024
+ **Returns:** Blocker details including description, status, resolution`,
1025
+ get_blockers_stats: `# get_blockers_stats
1026
+ Get aggregate blocker statistics.
1027
+
1028
+ **Parameters:**
1029
+ - project_id (required): Project UUID
1030
+
1031
+ **Returns:** Open/resolved counts, breakdown by age`,
1032
+ // Decision tools (additional)
1033
+ get_decision: `# get_decision
1034
+ Get a single decision by ID.
1035
+
1036
+ **Parameters:**
1037
+ - decision_id (required): Decision UUID
1038
+
1039
+ **Returns:** Decision details including title, description, rationale`,
1040
+ get_decisions_stats: `# get_decisions_stats
1041
+ Get aggregate decision statistics.
1042
+
1043
+ **Parameters:**
1044
+ - project_id (required): Project UUID
1045
+
1046
+ **Returns:** Total count, recent decisions count`,
1047
+ // Idea tools (additional)
1048
+ get_idea: `# get_idea
1049
+ Get a single idea by ID.
1050
+
1051
+ **Parameters:**
1052
+ - idea_id (required): Idea UUID
1053
+
1054
+ **Returns:** Idea details including title, description, status`,
1055
+ // Finding tools (additional)
1056
+ get_finding: `# get_finding
1057
+ Get a single finding by ID.
1058
+
1059
+ **Parameters:**
1060
+ - finding_id (required): Finding UUID
1061
+
1062
+ **Returns:** Finding details including title, category, severity, status`,
1063
+ get_findings_stats: `# get_findings_stats
1064
+ Get aggregate finding statistics.
1065
+
1066
+ **Parameters:**
1067
+ - project_id (required): Project UUID
1068
+
1069
+ **Returns:** Counts by category, severity, and status`,
1070
+ // Deployment tools (additional)
1071
+ get_deployment_requirements_stats: `# get_deployment_requirements_stats
1072
+ Get aggregate deployment requirement statistics.
1073
+
1074
+ **Parameters:**
1075
+ - project_id (required): Project UUID
1076
+
1077
+ **Returns:** Counts by stage and status`,
1078
+ // Worktree tools
1079
+ get_stale_worktrees: `# get_stale_worktrees
1080
+ Find orphaned worktrees that need cleanup.
1081
+
1082
+ **Parameters:**
1083
+ - project_id (required): Project UUID
1084
+ - hostname (optional): Filter to worktrees created on this machine
1085
+
1086
+ **Returns:** List of stale worktrees with task info and cleanup commands`,
1087
+ clear_worktree_path: `# clear_worktree_path
1088
+ Clear worktree path from a task after cleanup.
1089
+
1090
+ **Parameters:**
1091
+ - task_id (required): Task UUID
1092
+
1093
+ **Note:** Call this AFTER running git worktree remove`,
1094
+ // Role tools
1095
+ get_role_settings: `# get_role_settings
1096
+ Get project role settings and configuration.
1097
+
1098
+ **Parameters:**
1099
+ - project_id (required): Project UUID
1100
+
1101
+ **Returns:** Role configuration including allowed roles, default role`,
1102
+ update_role_settings: `# update_role_settings
1103
+ Configure project role behavior.
1104
+
1105
+ **Parameters:**
1106
+ - project_id (required): Project UUID
1107
+ - default_role (optional): Default role for new sessions
1108
+ - allowed_roles (optional): Array of allowed role names
1109
+
1110
+ **Returns:** Updated role settings`,
1111
+ set_session_role: `# set_session_role
1112
+ Set the role for the current session.
1113
+
1114
+ **Parameters:**
1115
+ - session_id (optional): Session UUID (uses current session)
1116
+ - role (required): Role name (e.g., "developer", "validator", "deployer")
1117
+
1118
+ **Returns:** Updated session with new role`,
1119
+ get_agents_by_role: `# get_agents_by_role
1120
+ List active agents grouped by role.
1121
+
1122
+ **Parameters:**
1123
+ - project_id (required): Project UUID
1124
+
1125
+ **Returns:** Agents organized by role`,
1126
+ // File checkout/lock tools
1127
+ checkout_file: `# checkout_file
1128
+ Lock a file for editing to prevent conflicts with other agents.
1129
+
1130
+ **Parameters:**
1131
+ - project_id (required): Project UUID
1132
+ - file_path (required): Path to the file to lock
1133
+ - reason (optional): Why you need to edit this file
1134
+
1135
+ **Returns:** Checkout confirmation with expiry time`,
1136
+ checkin_file: `# checkin_file
1137
+ Release a file lock after editing.
1138
+
1139
+ **Parameters:**
1140
+ - project_id (required): Project UUID
1141
+ - file_path (required): Path to the file to release
1142
+
1143
+ **Returns:** Checkin confirmation`,
1144
+ get_file_checkouts: `# get_file_checkouts
1145
+ List current file locks.
1146
+
1147
+ **Parameters:**
1148
+ - project_id (required): Project UUID
1149
+ - file_path (optional): Filter to specific file
1150
+
1151
+ **Returns:** List of active file checkouts`,
1152
+ get_file_checkouts_stats: `# get_file_checkouts_stats
1153
+ Get file checkout statistics.
1154
+
1155
+ **Parameters:**
1156
+ - project_id (required): Project UUID
1157
+
1158
+ **Returns:** Active checkout count, breakdown by agent`,
1159
+ abandon_checkout: `# abandon_checkout
1160
+ Force-release a file lock (use with caution).
1161
+
1162
+ **Parameters:**
1163
+ - project_id (required): Project UUID
1164
+ - file_path (required): Path to the file to release
1165
+
1166
+ **Note:** Only use when the original agent is unreachable`,
1167
+ is_file_available: `# is_file_available
1168
+ Check if a file is available for checkout.
1169
+
1170
+ **Parameters:**
1171
+ - project_id (required): Project UUID
1172
+ - file_path (required): Path to check
1173
+
1174
+ **Returns:** Availability status, current holder if locked`,
1175
+ // Connector tools
1176
+ get_connectors: `# get_connectors
1177
+ List project connectors (integrations).
1178
+
1179
+ **Parameters:**
1180
+ - project_id (required): Project UUID
1181
+
1182
+ **Returns:** Array of configured connectors`,
1183
+ get_connector: `# get_connector
1184
+ Get connector details.
1185
+
1186
+ **Parameters:**
1187
+ - connector_id (required): Connector UUID
1188
+
1189
+ **Returns:** Connector configuration and status`,
1190
+ add_connector: `# add_connector
1191
+ Create a new external integration connector.
1192
+
1193
+ **Parameters:**
1194
+ - project_id (required): Project UUID
1195
+ - type (required): Connector type (webhook, slack, discord, etc.)
1196
+ - name (required): Display name
1197
+ - config (required): Type-specific configuration
1198
+
1199
+ **Returns:** Created connector details`,
1200
+ update_connector: `# update_connector
1201
+ Update connector configuration.
1202
+
1203
+ **Parameters:**
1204
+ - connector_id (required): Connector UUID
1205
+ - name (optional): New display name
1206
+ - config (optional): Updated configuration
1207
+ - enabled (optional): Enable/disable connector
1208
+
1209
+ **Returns:** Updated connector details`,
1210
+ delete_connector: `# delete_connector
1211
+ Remove a connector.
1212
+
1213
+ **Parameters:**
1214
+ - connector_id (required): Connector UUID
1215
+
1216
+ **Returns:** Deletion confirmation`,
1217
+ test_connector: `# test_connector
1218
+ Send a test event to verify connector configuration.
1219
+
1220
+ **Parameters:**
1221
+ - connector_id (required): Connector UUID
1222
+
1223
+ **Returns:** Test result with success/failure details`,
1224
+ get_connector_events: `# get_connector_events
1225
+ Get event history for a connector.
1226
+
1227
+ **Parameters:**
1228
+ - connector_id (required): Connector UUID
1229
+ - limit (optional): Max events to return (default: 50)
1230
+
1231
+ **Returns:** Array of sent events with status`,
1232
+ // Cloud agent tools
1233
+ update_agent_status: `# update_agent_status
1234
+ Update your status message on the dashboard. Call this after start_work_session and whenever you start a new task.
1235
+
1236
+ **Parameters:**
1237
+ - status_message (required): Status text shown on dashboard (e.g. "Working on: Task title")
1238
+ - agent_name (required): Your agent name
1239
+ - project_id (required): Project UUID
1240
+
1241
+ **Example:** update_agent_status(status_message: "Working on: Progress Report Modal", agent_name: "Leon", project_id: "...")`,
1242
+ cleanup_stale_cloud_agents: `# cleanup_stale_cloud_agents
1243
+ Clean up stale cloud agents that failed to start or lost connection.
1244
+
1245
+ **Parameters:**
1246
+ - project_id (required): Project UUID
1247
+ - stale_minutes (optional): Minutes of inactivity before considered stale (default: 5)
1248
+ - include_running (optional): Include running agents in cleanup (default: false)
1249
+ - dry_run (optional): Preview what would be cleaned without actually cleaning (default: false)
1250
+
1251
+ **Returns:**
1252
+ - cleaned: Number of agents cleaned up
1253
+ - failed: Number of cleanup failures
1254
+ - agents: Array of affected agents with status
1255
+
1256
+ **Example:** cleanup_stale_cloud_agents(project_id, stale_minutes: 10, dry_run: true)`,
1257
+ list_cloud_agents: `# list_cloud_agents
1258
+ List cloud agents for a project with optional status filter.
1259
+
1260
+ **Parameters:**
1261
+ - project_id (required): Project UUID
1262
+ - status (optional): Filter by status - starting, running, stopped, failed, or all (default: all)
1263
+
1264
+ **Returns:**
1265
+ - agents: Array of agents with id, name, status, created_at, last_heartbeat, public_ip, ecs_task_id
1266
+ - count: Total number of agents returned
1267
+
1268
+ **Example:** list_cloud_agents(project_id, status: "running")`,
1269
+ // Chat tools
1270
+ send_project_message: `# send_project_message
1271
+ Send a message to the project chat channel for agent and user communication.
1272
+
1273
+ **Parameters:**
1274
+ - project_id (required): Project UUID
1275
+ - message (required): Message content to send
1276
+ - author_name (optional): Name of the message sender (defaults to session persona)
1277
+
1278
+ **Returns:**
1279
+ - message_id: UUID of the sent message
1280
+ - timestamp: When the message was sent
1281
+
1282
+ **Example:** send_project_message(project_id: "123e4567-e89b-12d3-a456-426614174000", message: "Deployment completed successfully")`,
1283
+ get_project_messages: `# get_project_messages
1284
+ Read recent project chat messages to stay informed about project communication.
1285
+
1286
+ **Parameters:**
1287
+ - project_id (required): Project UUID
1288
+ - limit (optional): Number of recent messages to retrieve (default: 20, max: 100)
1289
+ - since (optional): ISO timestamp to get messages after this time
1290
+
1291
+ **Returns:**
1292
+ - messages: Array of messages with id, author_name, message, timestamp
1293
+ - count: Number of messages returned
1294
+
1295
+ **Example:** get_project_messages(project_id: "123e4567-e89b-12d3-a456-426614174000", limit: 10)`,
1296
+ // Version management tools
1297
+ check_mcp_version: `# check_mcp_version
1298
+ Check for available MCP server updates and version information.
1299
+
1300
+ **Parameters:**
1301
+ - check_remote (optional): Whether to check remote registry for updates (default: true)
1302
+
1303
+ **Returns:**
1304
+ - current_version: Currently running MCP server version
1305
+ - latest_version: Latest available version (if check_remote is true)
1306
+ - update_available: Boolean indicating if an update is available
1307
+ - release_notes: Summary of changes in latest version (if available)
1308
+
1309
+ **Example:** check_mcp_version(check_remote: true)`,
1310
+ update_mcp_server: `# update_mcp_server
1311
+ Self-update the MCP server to the latest available version.
1312
+
1313
+ **Parameters:**
1314
+ - version (optional): Specific version to update to (defaults to latest)
1315
+ - restart_after_update (optional): Whether to restart after update (default: true)
1316
+ - backup_config (optional): Whether to backup current config (default: true)
1317
+
1318
+ **Returns:**
1319
+ - success: Boolean indicating if update succeeded
1320
+ - old_version: Previous version before update
1321
+ - new_version: Version after update
1322
+ - restart_required: Whether manual restart is needed
1323
+
1324
+ **Example:** update_mcp_server()
1325
+
1326
+ **Note:** This operation may temporarily disconnect active sessions during restart.`,
983
1327
  };
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Version management handlers
3
+ */
4
+ import type { HandlerRegistry } from './types.js';
5
+ export declare const versionHandlers: HandlerRegistry;
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Version management handlers
3
+ */
4
+ import { execSync } from 'child_process';
5
+ import { success, error } from './types.js';
6
+ import { checkVersion, getLocalVersion } from '../version.js';
7
+ const PACKAGE_NAME = '@vibescope/mcp-server';
8
+ export const versionHandlers = {
9
+ check_mcp_version: async (_args, _ctx) => {
10
+ const info = await checkVersion();
11
+ if (info.error) {
12
+ return success({
13
+ current_version: info.current,
14
+ latest_version: info.latest,
15
+ update_available: false,
16
+ warning: info.error,
17
+ });
18
+ }
19
+ return success({
20
+ current_version: info.current,
21
+ latest_version: info.latest,
22
+ update_available: info.updateAvailable,
23
+ message: info.updateAvailable
24
+ ? `Update available! v${info.current} → v${info.latest}. Ask the user if they would like to update using the update_mcp_server tool.`
25
+ : `Vibescope MCP server is up to date (v${info.current}).`,
26
+ });
27
+ },
28
+ update_mcp_server: async (args, _ctx) => {
29
+ const useGlobal = args.global !== false; // default true
30
+ const flag = useGlobal ? '-g ' : '';
31
+ const command = `npm install ${flag}${PACKAGE_NAME}@latest`;
32
+ try {
33
+ const output = execSync(command, {
34
+ encoding: 'utf-8',
35
+ timeout: 60000,
36
+ stdio: ['pipe', 'pipe', 'pipe'],
37
+ });
38
+ // Check the new version
39
+ const newVersion = getLocalVersion();
40
+ return success({
41
+ updated: true,
42
+ command_run: command,
43
+ output: output.trim(),
44
+ new_version: newVersion,
45
+ message: 'Update complete. The MCP server must be restarted to use the new version. Please ask the user to restart their editor/MCP client, or reconnect the MCP server.',
46
+ });
47
+ }
48
+ catch (err) {
49
+ const message = err instanceof Error ? err.message : String(err);
50
+ return error(`Failed to update: ${message}. The user may need to run manually: ${command}`);
51
+ }
52
+ },
53
+ };
package/dist/index.js CHANGED
@@ -9,6 +9,7 @@ import { RateLimiter, getErrorMessage, } from './utils.js';
9
9
  import { buildHandlerRegistry } from './handlers/index.js';
10
10
  import { tools } from './tools/index.js';
11
11
  import { createTokenUsage, trackTokenUsage as trackTokens, } from './token-tracking.js';
12
+ import { getUpdateWarning } from './version.js';
12
13
  // ============================================================================
13
14
  // Agent Instance Tracking
14
15
  // ============================================================================
@@ -210,6 +211,11 @@ async function main() {
210
211
  console.error('Invalid API key');
211
212
  process.exit(1);
212
213
  }
214
+ // Check for updates (non-blocking, with timeout)
215
+ const updateWarning = await getUpdateWarning();
216
+ const serverInstructions = updateWarning
217
+ ? `${updateWarning}\n\nVibescope MCP server - AI project tracking and coordination tools.`
218
+ : 'Vibescope MCP server - AI project tracking and coordination tools.';
213
219
  const server = new Server({
214
220
  name: 'vibescope',
215
221
  version: '0.1.0',
@@ -217,6 +223,7 @@ async function main() {
217
223
  capabilities: {
218
224
  tools: {},
219
225
  },
226
+ instructions: serverInstructions,
220
227
  });
221
228
  // List available tools
222
229
  server.setRequestHandler(ListToolsRequestSchema, async () => {
@@ -5,7 +5,9 @@
5
5
  * in every project using Vibescope for agent tracking. These guidelines ensure
6
6
  * agents follow proper workflows and maintain visibility.
7
7
  */
8
- export declare const AGENT_GUIDELINES_TEMPLATE = "# Vibescope Agent Guidelines\n\n## Quick Start\n\n```\nstart_work_session(git_url: \"https://github.com/YOUR/REPO\", model: \"opus\")\n```\n\n**IMPORTANT:** Always pass your model (opus/sonnet/haiku) to enable cost tracking. Check your system prompt for \"You are powered by the model named...\" to determine your model.\n\nThis returns your persona, project info, and `next_task`. Start working immediately.\n\n## CRITICAL: MCP Connection Required\n\n**If the Vibescope MCP server fails to connect, you MUST end your session immediately.**\n\n### Why This Is Non-Negotiable\n\nWorking without MCP connection causes:\n- **No progress visibility** - Humans can't see what you're doing\n- **Lost work tracking** - Tasks aren't tracked, time is wasted\n- **Workflow violations** - Other agents may conflict with your work\n- **Dashboard confusion** - Project state becomes inconsistent\n\n### Connection Failure Handling\n\n**If `start_work_session` fails or returns an error:**\n\n1. **Do NOT proceed with any work**\n2. **Inform the user** that MCP connection failed\n3. **End the session** - do not attempt workarounds\n4. **Provide troubleshooting steps:**\n - Check if MCP server is configured: `claude mcp list`\n - Verify API key is set: check `.mcp.json` or environment\n - Restart Claude Code after fixing configuration\n\n**Example error responses you might see:**\n```\nError: Failed to start session\nError: VIBESCOPE_API_KEY not set\nError: Network error connecting to Vibescope API\nError: MCP server 'vibescope' not found\n```\n\n### Recovery Steps\n\nIf MCP connection fails, tell the user:\n\n```\nMCP connection to Vibescope failed. I cannot proceed without task tracking.\n\nTo fix:\n1. Run: claude mcp list (verify vibescope is configured)\n2. Check API key: ensure VIBESCOPE_API_KEY is set\n3. Restart Claude Code\n4. Try again with: start_work_session(git_url: \"...\")\n\nI am ending this session to prevent untracked work.\n```\n\n**Never \"work around\" a broken MCP connection.** The whole point of Vibescope is visibility and coordination. Working without it defeats the purpose.\n\n## Core Workflow\n\n1. **Start session** \u2192 `start_work_session(git_url, model)` - Always include your model!\n2. **Mark task in progress** \u2192 `update_task(task_id, status: \"in_progress\")` - Returns git workflow instructions!\n3. **Set up worktree** \u2192 Create isolated worktree for this task (see Git Workflow below)\n4. **Update progress** \u2192 `update_task(task_id, progress_percentage: 50, progress_note: \"...\")`\n5. **Complete task** \u2192 `complete_task(task_id, summary: \"...\")` - **MANDATORY, see below!**\n6. **Clean up** \u2192 Remove worktree, then start next task immediately\n\n## CRITICAL: Always Call complete_task (MANDATORY)\n\n**You MUST call `complete_task()` when you finish a task.** This is not optional.\n\n### When to Call complete_task\n\nCall `complete_task()` immediately after:\n- \u2705 Creating and pushing a PR\n- \u2705 Merging changes (for trunk-based workflow)\n- \u2705 Finishing any unit of work, even if no code changes\n\n**Do NOT wait for:**\n- \u274C PR to be reviewed/merged (that's what validation is for)\n- \u274C User confirmation\n- \u274C \"Perfect\" summary - a brief summary is fine\n\n### The Rule\n\n```\nPR created + pushed \u2192 complete_task() \u2192 THEN worry about next steps\n```\n\n**If you create a PR and don't call `complete_task()`, you have failed the workflow.**\n\n## CRITICAL: Git Worktrees for Multi-Agent\n\nWhen multiple agents share a repository, you **MUST** use git worktrees to prevent conflicts.\n\n**Before starting ANY task:**\n```bash\n# For git-flow: ensure you're on develop first, then create worktree\ngit checkout develop\ngit pull origin develop\ngit worktree add ../worktree-<task-short-id> -b feature/<task-id>-<title>\ncd ../worktree-<task-short-id>\n```\n\n**After task is merged:**\n```bash\ngit worktree remove ../worktree-<task-short-id>\n```\n\n**Why?** Branch switching in shared repos causes file conflicts between agents. Worktrees provide isolated directories.\n\nRun `get_help(\"git\")` for full worktree documentation.\n\n## CRITICAL: Never Ask Permission\n\n**You must NEVER:**\n- Ask \"Should I continue to the next task?\" \u2192 Just continue\n- Ask \"Should I clear my context?\" \u2192 Just clear it\n- Ask \"What should I do next?\" \u2192 Check `next_task` or use fallback activities\n- Say \"All tasks are done, let me know what to do\" \u2192 Use `get_next_task` or start fallback activity\n- Wait for confirmation before clearing context \u2192 Just do it\n\n**You must ALWAYS:**\n- Call `complete_task()` immediately after creating/pushing a PR - this is non-negotiable\n- Immediately start the next task after completing one\n- Clear context and restart session automatically when needed\n- Keep working until there are genuinely no tasks and no fallback activities\n\n## Continuous Work\n\n**IMPORTANT: Never stop working!** When you complete a task:\n1. `complete_task` returns `next_task` \u2192 Start it immediately\n2. No `next_task`? \u2192 Call `get_next_task(project_id)`\n3. Still no tasks? \u2192 Start a `fallback_activity` (code_review, security_review, etc.)\n\n**When context grows large or responses slow down:**\n1. Run `/clear` to reset conversation\n2. Immediately call `start_work_session(git_url, model)` to reload context\n3. Continue with `next_task` from the response\n\n**Do NOT ask the user if you should clear context. Just do it.** The dashboard tracks all your progress, so nothing is lost when you clear.\n\n## Need Help?\n\nUse `get_help(topic)` for detailed guidance:\n\n| Topic | Description |\n|-------|-------------|\n| `getting_started` | Basic workflow overview |\n| `tasks` | Working on tasks, progress tracking |\n| `validation` | Cross-agent task validation |\n| `deployment` | Deployment coordination |\n| `git` | Git workflow configuration |\n| `blockers` | Handling blockers |\n| `milestones` | Breaking down complex tasks |\n| `fallback` | Background activities when idle |\n| `session` | Session management |\n| `topics` | List all available topics |\n\n## MCP Server Not Connected?\n\n### Quick Setup (Claude Code)\n\n```bash\nclaude mcp add vibescope npx @vibescope/mcp-server@latest \\\n --env VIBESCOPE_API_KEY=your_key\n```\n\n### Manual Setup\n\n1. Copy `.mcp.json.example` to `.mcp.json`\n2. Get `VIBESCOPE_API_KEY` from https://vibescope.dev/dashboard/settings\n3. Restart Claude Code\n";
8
+ export declare const VIBESCOPE_SECTION_START = "<!-- vibescope:start -->";
9
+ export declare const VIBESCOPE_SECTION_END = "<!-- vibescope:end -->";
10
+ export declare const AGENT_GUIDELINES_TEMPLATE = "<!-- vibescope:start -->\n# Vibescope Agent Guidelines\n\n## Quick Start\n\n```\nstart_work_session(git_url: \"https://github.com/YOUR/REPO\", model: \"opus\")\n```\n\n**IMPORTANT:** Always pass your model (opus/sonnet/haiku) to enable cost tracking. Check your system prompt for \"You are powered by the model named...\" to determine your model.\n\nThis returns your persona, project info, and `next_task`. Start working immediately.\n\n## CRITICAL: MCP Connection Required\n\n**If the Vibescope MCP server fails to connect, you MUST end your session immediately.**\n\n### Why This Is Non-Negotiable\n\nWorking without MCP connection causes:\n- **No progress visibility** - Humans can't see what you're doing\n- **Lost work tracking** - Tasks aren't tracked, time is wasted\n- **Workflow violations** - Other agents may conflict with your work\n- **Dashboard confusion** - Project state becomes inconsistent\n\n### Connection Failure Handling\n\n**If `start_work_session` fails or returns an error:**\n\n1. **Do NOT proceed with any work**\n2. **Inform the user** that MCP connection failed\n3. **End the session** - do not attempt workarounds\n4. **Provide troubleshooting steps:**\n - Check if MCP server is configured: `claude mcp list`\n - Verify API key is set: check `.mcp.json` or environment\n - Restart Claude Code after fixing configuration\n\n**Example error responses you might see:**\n```\nError: Failed to start session\nError: VIBESCOPE_API_KEY not set\nError: Network error connecting to Vibescope API\nError: MCP server 'vibescope' not found\n```\n\n### Recovery Steps\n\nIf MCP connection fails, tell the user:\n\n```\nMCP connection to Vibescope failed. I cannot proceed without task tracking.\n\nTo fix:\n1. Run: claude mcp list (verify vibescope is configured)\n2. Check API key: ensure VIBESCOPE_API_KEY is set\n3. Restart Claude Code\n4. Try again with: start_work_session(git_url: \"...\")\n\nI am ending this session to prevent untracked work.\n```\n\n**Never \"work around\" a broken MCP connection.** The whole point of Vibescope is visibility and coordination. Working without it defeats the purpose.\n\n## Core Workflow\n\n1. **Start session** \u2192 `start_work_session(git_url, model)` - Always include your model!\n2. **Mark task in progress** \u2192 `update_task(task_id, status: \"in_progress\")` - Returns git workflow instructions!\n3. **Set up worktree** \u2192 Create isolated worktree for this task (see Git Workflow below)\n4. **Update progress** \u2192 `update_task(task_id, progress_percentage: 50, progress_note: \"...\")`\n5. **Complete task** \u2192 `complete_task(task_id, summary: \"...\")` - **MANDATORY, see below!**\n6. **Clean up** \u2192 Remove worktree, then start next task immediately\n\n## CRITICAL: Always Call complete_task (MANDATORY)\n\n**You MUST call `complete_task()` when you finish a task.** This is not optional.\n\n### When to Call complete_task\n\nCall `complete_task()` immediately after:\n- \u2705 Creating and pushing a PR\n- \u2705 Merging changes (for trunk-based workflow)\n- \u2705 Finishing any unit of work, even if no code changes\n\n**Do NOT wait for:**\n- \u274C PR to be reviewed/merged (that's what validation is for)\n- \u274C User confirmation\n- \u274C \"Perfect\" summary - a brief summary is fine\n\n### The Rule\n\n```\nPR created + pushed \u2192 complete_task() \u2192 THEN worry about next steps\n```\n\n**If you create a PR and don't call `complete_task()`, you have failed the workflow.**\n\n## CRITICAL: Git Worktrees for Multi-Agent\n\nWhen multiple agents share a repository, you **MUST** use git worktrees to prevent conflicts.\n\n**Before starting ANY task:**\n```bash\n# For git-flow: ensure you're on develop first, then create worktree\ngit checkout develop\ngit pull origin develop\ngit worktree add ../worktree-<task-short-id> -b feature/<task-id>-<title>\ncd ../worktree-<task-short-id>\n```\n\n**After task is merged:**\n```bash\ngit worktree remove ../worktree-<task-short-id>\n```\n\n**Why?** Branch switching in shared repos causes file conflicts between agents. Worktrees provide isolated directories.\n\nRun `get_help(\"git\")` for full worktree documentation.\n\n## CRITICAL: Never Ask Permission\n\n**You must NEVER:**\n- Ask \"Should I continue to the next task?\" \u2192 Just continue\n- Ask \"Should I clear my context?\" \u2192 Just clear it\n- Ask \"What should I do next?\" \u2192 Check `next_task` or use fallback activities\n- Say \"All tasks are done, let me know what to do\" \u2192 Use `get_next_task` or start fallback activity\n- Wait for confirmation before clearing context \u2192 Just do it\n\n**You must ALWAYS:**\n- Call `complete_task()` immediately after creating/pushing a PR - this is non-negotiable\n- Immediately start the next task after completing one\n- Clear context and restart session automatically when needed\n- Keep working until there are genuinely no tasks and no fallback activities\n\n## Continuous Work\n\n**IMPORTANT: Never stop working!** When you complete a task:\n1. `complete_task` returns `next_task` \u2192 Start it immediately\n2. No `next_task`? \u2192 Call `get_next_task(project_id)`\n3. Still no tasks? \u2192 Start a `fallback_activity` (code_review, security_review, etc.)\n\n**When context grows large or responses slow down:**\n1. Run `/clear` to reset conversation\n2. Immediately call `start_work_session(git_url, model)` to reload context\n3. Continue with `next_task` from the response\n\n**Do NOT ask the user if you should clear context. Just do it.** The dashboard tracks all your progress, so nothing is lost when you clear.\n\n## Need Help?\n\nUse `get_help(topic)` for detailed guidance:\n\n| Topic | Description |\n|-------|-------------|\n| `getting_started` | Basic workflow overview |\n| `tasks` | Working on tasks, progress tracking |\n| `validation` | Cross-agent task validation |\n| `deployment` | Deployment coordination |\n| `git` | Git workflow configuration |\n| `blockers` | Handling blockers |\n| `milestones` | Breaking down complex tasks |\n| `fallback` | Background activities when idle |\n| `session` | Session management |\n| `topics` | List all available topics |\n\n## MCP Server Not Connected?\n\n### Quick Setup (Claude Code)\n\n```bash\nclaude mcp add vibescope npx @vibescope/mcp-server@latest \\\n --env VIBESCOPE_API_KEY=your_key\n```\n\n### Manual Setup\n\n1. Copy `.mcp.json.example` to `.mcp.json`\n2. Get `VIBESCOPE_API_KEY` from https://vibescope.dev/dashboard/settings\n3. Restart Claude Code\n<!-- vibescope:end -->\n";
9
11
  /**
10
12
  * Get the agent guidelines template
11
13
  * @returns The full agent guidelines markdown template