@vibescope/mcp-server 0.2.2 → 0.2.4

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 (80) hide show
  1. package/CHANGELOG.md +84 -0
  2. package/README.md +35 -20
  3. package/dist/api-client.d.ts +276 -8
  4. package/dist/api-client.js +128 -9
  5. package/dist/handlers/blockers.d.ts +11 -0
  6. package/dist/handlers/blockers.js +37 -2
  7. package/dist/handlers/bodies-of-work.d.ts +2 -0
  8. package/dist/handlers/bodies-of-work.js +30 -1
  9. package/dist/handlers/connectors.js +2 -2
  10. package/dist/handlers/decisions.d.ts +11 -0
  11. package/dist/handlers/decisions.js +37 -2
  12. package/dist/handlers/deployment.d.ts +6 -0
  13. package/dist/handlers/deployment.js +33 -5
  14. package/dist/handlers/discovery.js +27 -11
  15. package/dist/handlers/fallback.js +12 -6
  16. package/dist/handlers/file-checkouts.d.ts +1 -0
  17. package/dist/handlers/file-checkouts.js +17 -2
  18. package/dist/handlers/findings.d.ts +5 -0
  19. package/dist/handlers/findings.js +19 -2
  20. package/dist/handlers/git-issues.js +4 -2
  21. package/dist/handlers/ideas.d.ts +5 -0
  22. package/dist/handlers/ideas.js +19 -2
  23. package/dist/handlers/progress.js +2 -2
  24. package/dist/handlers/project.d.ts +1 -0
  25. package/dist/handlers/project.js +35 -2
  26. package/dist/handlers/requests.js +6 -3
  27. package/dist/handlers/roles.js +13 -2
  28. package/dist/handlers/session.d.ts +12 -0
  29. package/dist/handlers/session.js +288 -25
  30. package/dist/handlers/sprints.d.ts +2 -0
  31. package/dist/handlers/sprints.js +30 -1
  32. package/dist/handlers/tasks.d.ts +25 -2
  33. package/dist/handlers/tasks.js +228 -35
  34. package/dist/handlers/tool-docs.js +72 -5
  35. package/dist/templates/agent-guidelines.d.ts +18 -0
  36. package/dist/templates/agent-guidelines.js +207 -0
  37. package/dist/tools.js +478 -125
  38. package/dist/utils.d.ts +5 -2
  39. package/dist/utils.js +90 -51
  40. package/package.json +51 -46
  41. package/scripts/version-bump.ts +203 -0
  42. package/src/api-client.test.ts +8 -3
  43. package/src/api-client.ts +376 -13
  44. package/src/handlers/__test-setup__.ts +5 -0
  45. package/src/handlers/blockers.test.ts +76 -0
  46. package/src/handlers/blockers.ts +56 -2
  47. package/src/handlers/bodies-of-work.ts +59 -1
  48. package/src/handlers/connectors.ts +2 -2
  49. package/src/handlers/decisions.test.ts +71 -2
  50. package/src/handlers/decisions.ts +56 -2
  51. package/src/handlers/deployment.test.ts +81 -0
  52. package/src/handlers/deployment.ts +38 -5
  53. package/src/handlers/discovery.ts +27 -11
  54. package/src/handlers/fallback.test.ts +11 -10
  55. package/src/handlers/fallback.ts +14 -8
  56. package/src/handlers/file-checkouts.test.ts +83 -3
  57. package/src/handlers/file-checkouts.ts +22 -2
  58. package/src/handlers/findings.test.ts +2 -2
  59. package/src/handlers/findings.ts +38 -2
  60. package/src/handlers/git-issues.test.ts +2 -2
  61. package/src/handlers/git-issues.ts +4 -2
  62. package/src/handlers/ideas.test.ts +1 -1
  63. package/src/handlers/ideas.ts +34 -2
  64. package/src/handlers/progress.ts +2 -2
  65. package/src/handlers/project.ts +47 -2
  66. package/src/handlers/requests.test.ts +38 -7
  67. package/src/handlers/requests.ts +6 -3
  68. package/src/handlers/roles.test.ts +1 -1
  69. package/src/handlers/roles.ts +20 -2
  70. package/src/handlers/session.test.ts +303 -4
  71. package/src/handlers/session.ts +335 -28
  72. package/src/handlers/sprints.ts +61 -1
  73. package/src/handlers/tasks.test.ts +0 -73
  74. package/src/handlers/tasks.ts +269 -40
  75. package/src/handlers/tool-docs.ts +77 -5
  76. package/src/handlers/types.test.ts +259 -0
  77. package/src/templates/agent-guidelines.ts +210 -0
  78. package/src/tools.ts +479 -125
  79. package/src/utils.test.ts +7 -5
  80. package/src/utils.ts +95 -51
@@ -2,7 +2,11 @@
2
2
  * Task Handlers (Migrated to API Client)
3
3
  *
4
4
  * Handles task CRUD and management:
5
- * - get_tasks
5
+ * - get_task (single task by ID)
6
+ * - search_tasks (text search)
7
+ * - get_tasks_by_priority (priority filter)
8
+ * - get_recent_tasks (by date)
9
+ * - get_task_stats (aggregate counts)
6
10
  * - get_next_task
7
11
  * - add_task
8
12
  * - update_task
@@ -15,8 +19,11 @@
15
19
  * - add_subtask
16
20
  * - get_subtasks
17
21
  */
22
+ import os from 'os';
18
23
  import { parseArgs, uuidValidator, taskStatusValidator, priorityValidator, progressValidator, minutesValidator, createEnumValidator, ValidationError, } from '../validators.js';
19
24
  import { getApiClient } from '../api-client.js';
25
+ // Auto-detect machine hostname for worktree tracking
26
+ const MACHINE_HOSTNAME = os.hostname();
20
27
  // Valid task types
21
28
  const VALID_TASK_TYPES = [
22
29
  'frontend', 'backend', 'database', 'feature', 'bugfix',
@@ -25,15 +32,6 @@ const VALID_TASK_TYPES = [
25
32
  // ============================================================================
26
33
  // Argument Schemas
27
34
  // ============================================================================
28
- const getTasksSchema = {
29
- project_id: { type: 'string', required: true, validate: uuidValidator },
30
- status: { type: 'string', validate: taskStatusValidator },
31
- limit: { type: 'number', default: 50 },
32
- offset: { type: 'number', default: 0 },
33
- search_query: { type: 'string' },
34
- include_subtasks: { type: 'boolean', default: false },
35
- include_metadata: { type: 'boolean', default: false },
36
- };
37
35
  const getNextTaskSchema = {
38
36
  project_id: { type: 'string', required: true, validate: uuidValidator },
39
37
  };
@@ -92,6 +90,41 @@ const addSubtaskSchema = {
92
90
  const getSubtasksSchema = {
93
91
  parent_task_id: { type: 'string', required: true, validate: uuidValidator },
94
92
  status: { type: 'string', validate: taskStatusValidator },
93
+ limit: { type: 'number', default: 20 },
94
+ offset: { type: 'number', default: 0 },
95
+ };
96
+ // ============================================================================
97
+ // New Targeted Task Query Schemas
98
+ // ============================================================================
99
+ const getTaskSchema = {
100
+ task_id: { type: 'string', required: true, validate: uuidValidator },
101
+ include_subtasks: { type: 'boolean', default: false },
102
+ include_milestones: { type: 'boolean', default: false },
103
+ };
104
+ const searchTasksSchema = {
105
+ project_id: { type: 'string', required: true, validate: uuidValidator },
106
+ query: { type: 'string', required: true },
107
+ status: { type: 'array' },
108
+ limit: { type: 'number', default: 10 },
109
+ offset: { type: 'number', default: 0 },
110
+ };
111
+ const getTasksByPrioritySchema = {
112
+ project_id: { type: 'string', required: true, validate: uuidValidator },
113
+ priority: { type: 'number', validate: priorityValidator },
114
+ priority_max: { type: 'number', validate: priorityValidator },
115
+ status: { type: 'string', validate: taskStatusValidator },
116
+ limit: { type: 'number', default: 10 },
117
+ offset: { type: 'number', default: 0 },
118
+ };
119
+ const getRecentTasksSchema = {
120
+ project_id: { type: 'string', required: true, validate: uuidValidator },
121
+ order: { type: 'string', validate: createEnumValidator(['newest', 'oldest']) },
122
+ status: { type: 'string', validate: taskStatusValidator },
123
+ limit: { type: 'number', default: 10 },
124
+ offset: { type: 'number', default: 0 },
125
+ };
126
+ const getTaskStatsSchema = {
127
+ project_id: { type: 'string', required: true, validate: uuidValidator },
95
128
  };
96
129
  function getTaskCompleteGitInstructions(gitWorkflow, gitMainBranch, gitDevelopBranch, taskBranch, taskTitle, taskId) {
97
130
  if (gitWorkflow === 'none') {
@@ -143,28 +176,6 @@ export function getValidationApprovedGitInstructions(config, taskBranch) {
143
176
  // ============================================================================
144
177
  // Task Handlers - Using API Client
145
178
  // ============================================================================
146
- export const getTasks = async (args, ctx) => {
147
- const { project_id, status, limit, offset, search_query, include_subtasks, include_metadata } = parseArgs(args, getTasksSchema);
148
- const api = getApiClient();
149
- const response = await api.getTasks(project_id, {
150
- status,
151
- limit: Math.min(limit ?? 50, 200),
152
- offset,
153
- include_subtasks,
154
- search_query,
155
- include_metadata,
156
- });
157
- if (!response.ok) {
158
- return { result: { error: response.error || 'Failed to fetch tasks' }, isError: true };
159
- }
160
- return {
161
- result: {
162
- tasks: response.data?.tasks || [],
163
- total_count: response.data?.total_count || 0,
164
- has_more: response.data?.has_more || false,
165
- },
166
- };
167
- };
168
179
  export const getNextTask = async (args, ctx) => {
169
180
  const { project_id } = parseArgs(args, getNextTaskSchema);
170
181
  const api = getApiClient();
@@ -310,6 +321,16 @@ export const updateTask = async (args, ctx) => {
310
321
  if (data?.next_step) {
311
322
  result.next_step = data.next_step;
312
323
  }
324
+ // Add test reminder when starting work on a task
325
+ if (status === 'in_progress') {
326
+ result.test_reminder = {
327
+ message: 'Remember to write tests for this task before marking it complete.',
328
+ minimum_expectation: 'Basic tests that validate the task requirements are met',
329
+ ideal: 'Tests that also cover edge cases and error handling',
330
+ test_patterns: ['*.test.ts', '*.spec.ts', '*.test.js', '*.spec.js', '__tests__/*'],
331
+ note: 'Validators will check for test file changes during review. Documentation-only or config changes may not require tests.',
332
+ };
333
+ }
313
334
  return { result };
314
335
  };
315
336
  export const completeTask = async (args, ctx) => {
@@ -496,18 +517,178 @@ export const getSubtasks = async (args, ctx) => {
496
517
  };
497
518
  };
498
519
  // ============================================================================
520
+ // New Targeted Task Query Handlers
521
+ // ============================================================================
522
+ /**
523
+ * Get a single task by ID with optional subtasks and milestones
524
+ */
525
+ export const getTask = async (args, ctx) => {
526
+ const { task_id, include_subtasks, include_milestones } = parseArgs(args, getTaskSchema);
527
+ const api = getApiClient();
528
+ const response = await api.getTaskById(task_id, {
529
+ include_subtasks,
530
+ include_milestones,
531
+ });
532
+ if (!response.ok) {
533
+ return { result: { error: response.error || 'Failed to fetch task' }, isError: true };
534
+ }
535
+ const result = {
536
+ task: response.data?.task,
537
+ };
538
+ if (include_subtasks && response.data?.subtasks) {
539
+ result.subtasks = response.data.subtasks;
540
+ }
541
+ if (include_milestones && response.data?.milestones) {
542
+ result.milestones = response.data.milestones;
543
+ }
544
+ return { result };
545
+ };
546
+ /**
547
+ * Search tasks by text query with pagination
548
+ */
549
+ export const searchTasks = async (args, ctx) => {
550
+ const { project_id, query, status, limit, offset } = parseArgs(args, searchTasksSchema);
551
+ // Validate query length
552
+ if (query.length < 2) {
553
+ return {
554
+ result: {
555
+ error: 'query_too_short',
556
+ message: 'Search query must be at least 2 characters',
557
+ },
558
+ };
559
+ }
560
+ // Cap limit at 20, safe offset
561
+ const cappedLimit = Math.min(limit ?? 10, 20);
562
+ const safeOffset = Math.max(0, offset ?? 0);
563
+ const api = getApiClient();
564
+ const response = await api.searchTasks(project_id, {
565
+ query,
566
+ status: status,
567
+ limit: cappedLimit,
568
+ offset: safeOffset,
569
+ });
570
+ if (!response.ok) {
571
+ return { result: { error: response.error || 'Failed to search tasks' }, isError: true };
572
+ }
573
+ const tasks = response.data?.tasks || [];
574
+ const totalMatches = response.data?.total_matches || 0;
575
+ return {
576
+ result: {
577
+ tasks,
578
+ total_matches: totalMatches,
579
+ has_more: safeOffset + tasks.length < totalMatches,
580
+ offset: safeOffset,
581
+ limit: cappedLimit,
582
+ },
583
+ };
584
+ };
585
+ /**
586
+ * Get tasks filtered by priority with pagination
587
+ */
588
+ export const getTasksByPriority = async (args, ctx) => {
589
+ const { project_id, priority, priority_max, status, limit, offset } = parseArgs(args, getTasksByPrioritySchema);
590
+ // Cap limit at 20, safe offset
591
+ const cappedLimit = Math.min(limit ?? 10, 20);
592
+ const safeOffset = Math.max(0, offset ?? 0);
593
+ const api = getApiClient();
594
+ const response = await api.getTasksByPriority(project_id, {
595
+ priority,
596
+ priority_max,
597
+ status,
598
+ limit: cappedLimit,
599
+ offset: safeOffset,
600
+ });
601
+ if (!response.ok) {
602
+ return { result: { error: response.error || 'Failed to fetch tasks by priority' }, isError: true };
603
+ }
604
+ const tasks = response.data?.tasks || [];
605
+ const totalCount = response.data?.total_count || 0;
606
+ return {
607
+ result: {
608
+ tasks,
609
+ total_count: totalCount,
610
+ has_more: safeOffset + tasks.length < totalCount,
611
+ offset: safeOffset,
612
+ limit: cappedLimit,
613
+ },
614
+ };
615
+ };
616
+ /**
617
+ * Get recent tasks (newest or oldest) with pagination
618
+ */
619
+ export const getRecentTasks = async (args, ctx) => {
620
+ const { project_id, order, status, limit, offset } = parseArgs(args, getRecentTasksSchema);
621
+ // Cap limit at 20, safe offset
622
+ const cappedLimit = Math.min(limit ?? 10, 20);
623
+ const safeOffset = Math.max(0, offset ?? 0);
624
+ const api = getApiClient();
625
+ const response = await api.getRecentTasks(project_id, {
626
+ order: order,
627
+ status,
628
+ limit: cappedLimit,
629
+ offset: safeOffset,
630
+ });
631
+ if (!response.ok) {
632
+ return { result: { error: response.error || 'Failed to fetch recent tasks' }, isError: true };
633
+ }
634
+ const tasks = response.data?.tasks || [];
635
+ const totalCount = response.data?.total_count || 0;
636
+ return {
637
+ result: {
638
+ tasks,
639
+ total_count: totalCount,
640
+ has_more: safeOffset + tasks.length < totalCount,
641
+ offset: safeOffset,
642
+ limit: cappedLimit,
643
+ },
644
+ };
645
+ };
646
+ /**
647
+ * Get task statistics for a project (aggregate counts only, minimal tokens)
648
+ */
649
+ export const getTaskStats = async (args, ctx) => {
650
+ const { project_id } = parseArgs(args, getTaskStatsSchema);
651
+ const api = getApiClient();
652
+ const response = await api.getTaskStats(project_id);
653
+ if (!response.ok) {
654
+ return { result: { error: response.error || 'Failed to fetch task stats' }, isError: true };
655
+ }
656
+ return {
657
+ result: {
658
+ total: response.data?.total || 0,
659
+ by_status: response.data?.by_status || {
660
+ backlog: 0,
661
+ pending: 0,
662
+ in_progress: 0,
663
+ completed: 0,
664
+ cancelled: 0,
665
+ },
666
+ by_priority: response.data?.by_priority || { 1: 0, 2: 0, 3: 0, 4: 0, 5: 0 },
667
+ awaiting_validation: response.data?.awaiting_validation || 0,
668
+ oldest_pending_days: response.data?.oldest_pending_days ?? null,
669
+ },
670
+ };
671
+ };
672
+ // ============================================================================
499
673
  // Worktree Cleanup Handlers
500
674
  // ============================================================================
501
675
  const getStaleWorktreesSchema = {
502
676
  project_id: { type: 'string', required: true, validate: uuidValidator },
677
+ hostname: { type: 'string' }, // Machine hostname to filter worktrees
678
+ limit: { type: 'number', default: 20 },
679
+ offset: { type: 'number', default: 0 },
503
680
  };
504
681
  const clearWorktreePathSchema = {
505
682
  task_id: { type: 'string', required: true, validate: uuidValidator },
506
683
  };
507
684
  export const getStaleWorktrees = async (args, ctx) => {
508
- const { project_id } = parseArgs(args, getStaleWorktreesSchema);
685
+ const { project_id, hostname: providedHostname, limit, offset } = parseArgs(args, getStaleWorktreesSchema);
686
+ // Use auto-detected hostname if not provided - filters to only worktrees on THIS machine
687
+ const hostname = providedHostname || MACHINE_HOSTNAME;
688
+ // Cap limit to prevent context bloating
689
+ const cappedLimit = Math.min(limit ?? 20, 50);
509
690
  const api = getApiClient();
510
- const response = await api.getStaleWorktrees(project_id);
691
+ const response = await api.getStaleWorktrees(project_id, { hostname, limit: cappedLimit, offset });
511
692
  if (!response.ok) {
512
693
  return { result: { error: response.error || 'Failed to get stale worktrees' }, isError: true };
513
694
  }
@@ -516,9 +697,15 @@ export const getStaleWorktrees = async (args, ctx) => {
516
697
  result: {
517
698
  project_id: data?.project_id,
518
699
  project_name: data?.project_name,
700
+ hostname_filter: data?.hostname_filter,
519
701
  stale_worktrees: data?.stale_worktrees || [],
520
702
  count: data?.count || 0,
703
+ local_count: data?.local_count || 0,
704
+ remote_count: data?.remote_count || 0,
705
+ total_count: data?.total_count || 0,
706
+ has_more: data?.has_more || false,
521
707
  cleanup_instructions: data?.cleanup_instructions,
708
+ remote_worktree_note: data?.remote_worktree_note,
522
709
  },
523
710
  };
524
711
  };
@@ -541,7 +728,13 @@ export const clearWorktreePath = async (args, ctx) => {
541
728
  * Task handlers registry
542
729
  */
543
730
  export const taskHandlers = {
544
- get_tasks: getTasks,
731
+ // Targeted task query endpoints (token-efficient)
732
+ get_task: getTask,
733
+ search_tasks: searchTasks,
734
+ get_tasks_by_priority: getTasksByPriority,
735
+ get_recent_tasks: getRecentTasks,
736
+ get_task_stats: getTaskStats,
737
+ // Core task operations
545
738
  get_next_task: getNextTask,
546
739
  add_task: addTask,
547
740
  update_task: updateTask,
@@ -81,13 +81,69 @@ Sync README content to the dashboard.
81
81
  **Parameters:**
82
82
  - project_id (required): Project UUID
83
83
  - readme_content (required): Markdown content`,
84
- get_tasks: `# get_tasks
85
- Get tasks for a project.
84
+ get_task: `# get_task
85
+ Get a single task by ID with optional subtasks and milestones.
86
+
87
+ **Parameters:**
88
+ - task_id (required): Task UUID
89
+ - include_subtasks (optional): Include subtasks array (default: false)
90
+ - include_milestones (optional): Include milestones array (default: false)`,
91
+ search_tasks: `# search_tasks
92
+ Search tasks by text query. Supports pagination.
93
+
94
+ **Parameters:**
95
+ - project_id (required): Project UUID
96
+ - query (required): Search query (min 2 chars)
97
+ - status (optional): Array of statuses to filter
98
+ - limit (optional): Max results per page (1-20, default: 10)
99
+ - offset (optional): Number of results to skip (default: 0)
100
+
101
+ **Returns:**
102
+ - tasks: Array of matching tasks
103
+ - total_matches: Total number of matching tasks
104
+ - has_more: Whether more results exist beyond current page
105
+ - offset: Current offset
106
+ - limit: Current limit`,
107
+ get_tasks_by_priority: `# get_tasks_by_priority
108
+ Get tasks filtered by priority. Supports pagination.
109
+
110
+ **Parameters:**
111
+ - project_id (required): Project UUID
112
+ - priority (optional): Exact priority (1-5)
113
+ - priority_max (optional): Max priority for range query
114
+ - status (optional): Filter by status (default: pending)
115
+ - limit (optional): Max results per page (1-20, default: 10)
116
+ - offset (optional): Number of results to skip (default: 0)
117
+
118
+ **Returns:**
119
+ - tasks: Array of matching tasks
120
+ - total_count: Total number of matching tasks
121
+ - has_more: Whether more results exist beyond current page
122
+ - offset: Current offset
123
+ - limit: Current limit`,
124
+ get_recent_tasks: `# get_recent_tasks
125
+ Get tasks ordered by creation date. Supports pagination.
86
126
 
87
127
  **Parameters:**
88
128
  - project_id (required): Project UUID
89
- - status (optional): pending, in_progress, completed, cancelled
90
- - limit (optional): Max tasks (default 50)`,
129
+ - order (optional): 'newest' or 'oldest' (default: newest)
130
+ - status (optional): Filter by status
131
+ - limit (optional): Max results per page (1-20, default: 10)
132
+ - offset (optional): Number of results to skip (default: 0)
133
+
134
+ **Returns:**
135
+ - tasks: Array of matching tasks
136
+ - total_count: Total number of matching tasks
137
+ - has_more: Whether more results exist beyond current page
138
+ - offset: Current offset
139
+ - limit: Current limit`,
140
+ get_task_stats: `# get_task_stats
141
+ Get aggregate task statistics. Most token-efficient way to understand project state.
142
+
143
+ **Parameters:**
144
+ - project_id (required): Project UUID
145
+
146
+ **Returns:** Counts by status and priority, no task data`,
91
147
  get_next_task: `# get_next_task
92
148
  Get highest priority pending task not claimed by another agent.
93
149
 
@@ -128,6 +184,17 @@ Delete a task.
128
184
 
129
185
  **Parameters:**
130
186
  - task_id (required): Task UUID`,
187
+ cancel_task: `# cancel_task
188
+ Cancel a task with an optional reason. Use this when a task should be marked as cancelled rather than deleted (e.g., PR was closed, work was superseded). The task remains visible with a cancelled status for historical tracking.
189
+
190
+ **Parameters:**
191
+ - task_id (required): Task UUID
192
+ - cancelled_reason (optional): One of: pr_closed, superseded, user_cancelled, validation_failed, obsolete, blocked
193
+ - cancellation_note (optional): Additional context about the cancellation
194
+
195
+ **Returns:** task_id, cancelled_reason, message, sprint info (if auto-completed)
196
+
197
+ **Example:** cancel_task(task_id: "abc", cancelled_reason: "pr_closed", cancellation_note: "PR was closed without merging")`,
131
198
  batch_update_tasks: `# batch_update_tasks
132
199
  Update multiple tasks at once.
133
200
 
@@ -898,7 +965,7 @@ Query aggregated project knowledge in a single call. Reduces token usage by comb
898
965
  - stats: counts for each category, findings by severity
899
966
  - Category data based on selection
900
967
 
901
- **Token savings:** Replaces up to 6 separate tool calls (get_findings, get_decisions, get_tasks, get_blockers, etc.) with one call.
968
+ **Token savings:** Replaces multiple tool calls (get_findings, get_decisions, get_blockers, etc.) with one call.
902
969
 
903
970
  **Example:** query_knowledge_base(project_id, categories: ["findings", "decisions"], limit: 10)`,
904
971
  };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Agent Guidelines Template
3
+ *
4
+ * This template contains the essential CLAUDE.md content that should be included
5
+ * in every project using Vibescope for agent tracking. These guidelines ensure
6
+ * agents follow proper workflows and maintain visibility.
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";
9
+ /**
10
+ * Get the agent guidelines template
11
+ * @returns The full agent guidelines markdown template
12
+ */
13
+ export declare function getAgentGuidelinesTemplate(): string;
14
+ /**
15
+ * Get a summary of the agent guidelines for inclusion in responses
16
+ * @returns A brief summary of key guidelines
17
+ */
18
+ export declare function getAgentGuidelinesSummary(): string;
@@ -0,0 +1,207 @@
1
+ /**
2
+ * Agent Guidelines Template
3
+ *
4
+ * This template contains the essential CLAUDE.md content that should be included
5
+ * in every project using Vibescope for agent tracking. These guidelines ensure
6
+ * agents follow proper workflows and maintain visibility.
7
+ */
8
+ export const AGENT_GUIDELINES_TEMPLATE = `# Vibescope Agent Guidelines
9
+
10
+ ## Quick Start
11
+
12
+ \`\`\`
13
+ start_work_session(git_url: "https://github.com/YOUR/REPO", model: "opus")
14
+ \`\`\`
15
+
16
+ **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.
17
+
18
+ This returns your persona, project info, and \`next_task\`. Start working immediately.
19
+
20
+ ## CRITICAL: MCP Connection Required
21
+
22
+ **If the Vibescope MCP server fails to connect, you MUST end your session immediately.**
23
+
24
+ ### Why This Is Non-Negotiable
25
+
26
+ Working without MCP connection causes:
27
+ - **No progress visibility** - Humans can't see what you're doing
28
+ - **Lost work tracking** - Tasks aren't tracked, time is wasted
29
+ - **Workflow violations** - Other agents may conflict with your work
30
+ - **Dashboard confusion** - Project state becomes inconsistent
31
+
32
+ ### Connection Failure Handling
33
+
34
+ **If \`start_work_session\` fails or returns an error:**
35
+
36
+ 1. **Do NOT proceed with any work**
37
+ 2. **Inform the user** that MCP connection failed
38
+ 3. **End the session** - do not attempt workarounds
39
+ 4. **Provide troubleshooting steps:**
40
+ - Check if MCP server is configured: \`claude mcp list\`
41
+ - Verify API key is set: check \`.mcp.json\` or environment
42
+ - Restart Claude Code after fixing configuration
43
+
44
+ **Example error responses you might see:**
45
+ \`\`\`
46
+ Error: Failed to start session
47
+ Error: VIBESCOPE_API_KEY not set
48
+ Error: Network error connecting to Vibescope API
49
+ Error: MCP server 'vibescope' not found
50
+ \`\`\`
51
+
52
+ ### Recovery Steps
53
+
54
+ If MCP connection fails, tell the user:
55
+
56
+ \`\`\`
57
+ MCP connection to Vibescope failed. I cannot proceed without task tracking.
58
+
59
+ To fix:
60
+ 1. Run: claude mcp list (verify vibescope is configured)
61
+ 2. Check API key: ensure VIBESCOPE_API_KEY is set
62
+ 3. Restart Claude Code
63
+ 4. Try again with: start_work_session(git_url: "...")
64
+
65
+ I am ending this session to prevent untracked work.
66
+ \`\`\`
67
+
68
+ **Never "work around" a broken MCP connection.** The whole point of Vibescope is visibility and coordination. Working without it defeats the purpose.
69
+
70
+ ## Core Workflow
71
+
72
+ 1. **Start session** → \`start_work_session(git_url, model)\` - Always include your model!
73
+ 2. **Mark task in progress** → \`update_task(task_id, status: "in_progress")\` - Returns git workflow instructions!
74
+ 3. **Set up worktree** → Create isolated worktree for this task (see Git Workflow below)
75
+ 4. **Update progress** → \`update_task(task_id, progress_percentage: 50, progress_note: "...")\`
76
+ 5. **Complete task** → \`complete_task(task_id, summary: "...")\` - **MANDATORY, see below!**
77
+ 6. **Clean up** → Remove worktree, then start next task immediately
78
+
79
+ ## CRITICAL: Always Call complete_task (MANDATORY)
80
+
81
+ **You MUST call \`complete_task()\` when you finish a task.** This is not optional.
82
+
83
+ ### When to Call complete_task
84
+
85
+ Call \`complete_task()\` immediately after:
86
+ - ✅ Creating and pushing a PR
87
+ - ✅ Merging changes (for trunk-based workflow)
88
+ - ✅ Finishing any unit of work, even if no code changes
89
+
90
+ **Do NOT wait for:**
91
+ - ❌ PR to be reviewed/merged (that's what validation is for)
92
+ - ❌ User confirmation
93
+ - ❌ "Perfect" summary - a brief summary is fine
94
+
95
+ ### The Rule
96
+
97
+ \`\`\`
98
+ PR created + pushed → complete_task() → THEN worry about next steps
99
+ \`\`\`
100
+
101
+ **If you create a PR and don't call \`complete_task()\`, you have failed the workflow.**
102
+
103
+ ## CRITICAL: Git Worktrees for Multi-Agent
104
+
105
+ When multiple agents share a repository, you **MUST** use git worktrees to prevent conflicts.
106
+
107
+ **Before starting ANY task:**
108
+ \`\`\`bash
109
+ # For git-flow: ensure you're on develop first, then create worktree
110
+ git checkout develop
111
+ git pull origin develop
112
+ git worktree add ../worktree-<task-short-id> -b feature/<task-id>-<title>
113
+ cd ../worktree-<task-short-id>
114
+ \`\`\`
115
+
116
+ **After task is merged:**
117
+ \`\`\`bash
118
+ git worktree remove ../worktree-<task-short-id>
119
+ \`\`\`
120
+
121
+ **Why?** Branch switching in shared repos causes file conflicts between agents. Worktrees provide isolated directories.
122
+
123
+ Run \`get_help("git")\` for full worktree documentation.
124
+
125
+ ## CRITICAL: Never Ask Permission
126
+
127
+ **You must NEVER:**
128
+ - Ask "Should I continue to the next task?" → Just continue
129
+ - Ask "Should I clear my context?" → Just clear it
130
+ - Ask "What should I do next?" → Check \`next_task\` or use fallback activities
131
+ - Say "All tasks are done, let me know what to do" → Use \`get_next_task\` or start fallback activity
132
+ - Wait for confirmation before clearing context → Just do it
133
+
134
+ **You must ALWAYS:**
135
+ - Call \`complete_task()\` immediately after creating/pushing a PR - this is non-negotiable
136
+ - Immediately start the next task after completing one
137
+ - Clear context and restart session automatically when needed
138
+ - Keep working until there are genuinely no tasks and no fallback activities
139
+
140
+ ## Continuous Work
141
+
142
+ **IMPORTANT: Never stop working!** When you complete a task:
143
+ 1. \`complete_task\` returns \`next_task\` → Start it immediately
144
+ 2. No \`next_task\`? → Call \`get_next_task(project_id)\`
145
+ 3. Still no tasks? → Start a \`fallback_activity\` (code_review, security_review, etc.)
146
+
147
+ **When context grows large or responses slow down:**
148
+ 1. Run \`/clear\` to reset conversation
149
+ 2. Immediately call \`start_work_session(git_url, model)\` to reload context
150
+ 3. Continue with \`next_task\` from the response
151
+
152
+ **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.
153
+
154
+ ## Need Help?
155
+
156
+ Use \`get_help(topic)\` for detailed guidance:
157
+
158
+ | Topic | Description |
159
+ |-------|-------------|
160
+ | \`getting_started\` | Basic workflow overview |
161
+ | \`tasks\` | Working on tasks, progress tracking |
162
+ | \`validation\` | Cross-agent task validation |
163
+ | \`deployment\` | Deployment coordination |
164
+ | \`git\` | Git workflow configuration |
165
+ | \`blockers\` | Handling blockers |
166
+ | \`milestones\` | Breaking down complex tasks |
167
+ | \`fallback\` | Background activities when idle |
168
+ | \`session\` | Session management |
169
+ | \`topics\` | List all available topics |
170
+
171
+ ## MCP Server Not Connected?
172
+
173
+ ### Quick Setup (Claude Code)
174
+
175
+ \`\`\`bash
176
+ claude mcp add vibescope npx @vibescope/mcp-server@latest \\
177
+ --env VIBESCOPE_API_KEY=your_key
178
+ \`\`\`
179
+
180
+ ### Manual Setup
181
+
182
+ 1. Copy \`.mcp.json.example\` to \`.mcp.json\`
183
+ 2. Get \`VIBESCOPE_API_KEY\` from https://vibescope.dev/dashboard/settings
184
+ 3. Restart Claude Code
185
+ `;
186
+ /**
187
+ * Get the agent guidelines template
188
+ * @returns The full agent guidelines markdown template
189
+ */
190
+ export function getAgentGuidelinesTemplate() {
191
+ return AGENT_GUIDELINES_TEMPLATE;
192
+ }
193
+ /**
194
+ * Get a summary of the agent guidelines for inclusion in responses
195
+ * @returns A brief summary of key guidelines
196
+ */
197
+ export function getAgentGuidelinesSummary() {
198
+ return `## Essential Agent Guidelines
199
+
200
+ 1. **MCP Connection Required** - If start_work_session fails, END SESSION IMMEDIATELY
201
+ 2. **Always call complete_task()** - After creating a PR, call complete_task() right away
202
+ 3. **Use git worktrees** - Create worktrees for each task to avoid conflicts
203
+ 4. **Never ask permission** - Just continue working, clear context when needed
204
+ 5. **Continuous work** - Never stop; use get_next_task or fallback activities
205
+
206
+ For full guidelines, create a \`.claude/CLAUDE.md\` file in your project with the agent guidelines template.`;
207
+ }