@vibescope/mcp-server 0.2.5 → 0.2.7

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 (82) hide show
  1. package/CHANGELOG.md +84 -84
  2. package/README.md +194 -194
  3. package/dist/cli.js +26 -26
  4. package/dist/handlers/tool-docs.js +828 -828
  5. package/dist/index.js +73 -73
  6. package/dist/templates/agent-guidelines.js +185 -185
  7. package/dist/token-tracking.js +4 -2
  8. package/dist/tools.js +65 -65
  9. package/dist/utils.js +11 -11
  10. package/docs/TOOLS.md +2053 -2053
  11. package/package.json +3 -2
  12. package/scripts/generate-docs.ts +212 -212
  13. package/scripts/version-bump.ts +203 -203
  14. package/src/api-client.test.ts +723 -723
  15. package/src/api-client.ts +2499 -2499
  16. package/src/cli.ts +212 -212
  17. package/src/handlers/__test-setup__.ts +236 -236
  18. package/src/handlers/__test-utils__.ts +87 -87
  19. package/src/handlers/blockers.test.ts +468 -468
  20. package/src/handlers/blockers.ts +163 -163
  21. package/src/handlers/bodies-of-work.test.ts +704 -704
  22. package/src/handlers/bodies-of-work.ts +526 -526
  23. package/src/handlers/connectors.test.ts +834 -834
  24. package/src/handlers/connectors.ts +229 -229
  25. package/src/handlers/cost.test.ts +462 -462
  26. package/src/handlers/cost.ts +285 -285
  27. package/src/handlers/decisions.test.ts +382 -382
  28. package/src/handlers/decisions.ts +153 -153
  29. package/src/handlers/deployment.test.ts +551 -551
  30. package/src/handlers/deployment.ts +541 -541
  31. package/src/handlers/discovery.test.ts +206 -206
  32. package/src/handlers/discovery.ts +390 -390
  33. package/src/handlers/fallback.test.ts +537 -537
  34. package/src/handlers/fallback.ts +194 -194
  35. package/src/handlers/file-checkouts.test.ts +750 -750
  36. package/src/handlers/file-checkouts.ts +185 -185
  37. package/src/handlers/findings.test.ts +633 -633
  38. package/src/handlers/findings.ts +239 -239
  39. package/src/handlers/git-issues.test.ts +631 -631
  40. package/src/handlers/git-issues.ts +136 -136
  41. package/src/handlers/ideas.test.ts +644 -644
  42. package/src/handlers/ideas.ts +207 -207
  43. package/src/handlers/index.ts +84 -84
  44. package/src/handlers/milestones.test.ts +475 -475
  45. package/src/handlers/milestones.ts +180 -180
  46. package/src/handlers/organizations.test.ts +826 -826
  47. package/src/handlers/organizations.ts +315 -315
  48. package/src/handlers/progress.test.ts +269 -269
  49. package/src/handlers/progress.ts +77 -77
  50. package/src/handlers/project.test.ts +546 -546
  51. package/src/handlers/project.ts +239 -239
  52. package/src/handlers/requests.test.ts +303 -303
  53. package/src/handlers/requests.ts +99 -99
  54. package/src/handlers/roles.test.ts +303 -303
  55. package/src/handlers/roles.ts +226 -226
  56. package/src/handlers/session.test.ts +875 -875
  57. package/src/handlers/session.ts +738 -738
  58. package/src/handlers/sprints.test.ts +732 -732
  59. package/src/handlers/sprints.ts +537 -537
  60. package/src/handlers/tasks.test.ts +907 -907
  61. package/src/handlers/tasks.ts +945 -945
  62. package/src/handlers/tool-categories.test.ts +66 -66
  63. package/src/handlers/tool-docs.ts +1096 -1096
  64. package/src/handlers/types.test.ts +259 -259
  65. package/src/handlers/types.ts +175 -175
  66. package/src/handlers/validation.test.ts +582 -582
  67. package/src/handlers/validation.ts +97 -97
  68. package/src/index.ts +792 -792
  69. package/src/setup.test.ts +233 -231
  70. package/src/setup.ts +370 -370
  71. package/src/templates/agent-guidelines.ts +210 -210
  72. package/src/token-tracking.test.ts +463 -453
  73. package/src/token-tracking.ts +166 -164
  74. package/src/tools.ts +3562 -3562
  75. package/src/utils.test.ts +683 -683
  76. package/src/utils.ts +436 -436
  77. package/src/validators.test.ts +223 -223
  78. package/src/validators.ts +249 -249
  79. package/tsconfig.json +16 -16
  80. package/vitest.config.ts +14 -14
  81. package/dist/knowledge.d.ts +0 -6
  82. package/dist/knowledge.js +0 -218
package/dist/index.js CHANGED
@@ -40,89 +40,89 @@ const handlerRegistry = buildHandlerRegistry();
40
40
  // Embedded Knowledge Base (on-demand help topics)
41
41
  // ============================================================================
42
42
  const KNOWLEDGE_BASE = {
43
- getting_started: `# Getting Started
44
- 1. Call start_work_session(git_url, model: "opus"|"sonnet"|"haiku") to initialize
45
- - IMPORTANT: Pass your model for accurate cost tracking
46
- - Check your system prompt for "You are powered by the model named..." to find it
47
- 2. Response includes next_task - start working on it immediately
48
- 3. Use update_task to mark in_progress and track progress
49
- 4. Call complete_task when done - it returns your next task
43
+ getting_started: `# Getting Started
44
+ 1. Call start_work_session(git_url, model: "opus"|"sonnet"|"haiku") to initialize
45
+ - IMPORTANT: Pass your model for accurate cost tracking
46
+ - Check your system prompt for "You are powered by the model named..." to find it
47
+ 2. Response includes next_task - start working on it immediately
48
+ 3. Use update_task to mark in_progress and track progress
49
+ 4. Call complete_task when done - it returns your next task
50
50
  5. Use get_help(topic) when you need guidance on specific workflows`,
51
- tasks: `# Task Workflow
52
- - Mark task in_progress with update_task before starting
53
- - Update progress_percentage regularly (every 15-20% progress)
54
- - Include progress_note to auto-log milestones
55
- - One task at a time - complete current before starting another
56
- - complete_task returns next_task and context counts (validation, blockers, deployment)
51
+ tasks: `# Task Workflow
52
+ - Mark task in_progress with update_task before starting
53
+ - Update progress_percentage regularly (every 15-20% progress)
54
+ - Include progress_note to auto-log milestones
55
+ - One task at a time - complete current before starting another
56
+ - complete_task returns next_task and context counts (validation, blockers, deployment)
57
57
  - Priority: 1=highest, 5=lowest`,
58
- validation: `# Task Validation
59
- Completed tasks need validation before deployment. PRIORITIZE validation over new tasks.
60
- 1. Check: get_tasks_awaiting_validation(project_id)
61
- 2. Claim: claim_validation(task_id) - marks "being reviewed" on dashboard
62
- 3. Review code changes and run tests
63
- 4. Complete: validate_task(task_id, approved: true/false, validation_notes: "...")
58
+ validation: `# Task Validation
59
+ Completed tasks need validation before deployment. PRIORITIZE validation over new tasks.
60
+ 1. Check: get_tasks_awaiting_validation(project_id)
61
+ 2. Claim: claim_validation(task_id) - marks "being reviewed" on dashboard
62
+ 3. Review code changes and run tests
63
+ 4. Complete: validate_task(task_id, approved: true/false, validation_notes: "...")
64
64
  Self-validation allowed when single-agent or to unblock deployment.`,
65
- deployment: `# Deployment Workflow
66
- 1. Ensure all completed tasks are validated first
67
- 2. request_deployment(project_id, environment: "production")
68
- 3. claim_deployment_validation(project_id) - claim for validation
69
- 4. Run: pnpm build && pnpm test
70
- 5. report_validation(project_id, build_passed: true, tests_passed: true)
71
- 6. start_deployment(project_id) - returns project's deployment_instructions
72
- 7. Follow the instructions (e.g., push to main, run deploy command)
65
+ deployment: `# Deployment Workflow
66
+ 1. Ensure all completed tasks are validated first
67
+ 2. request_deployment(project_id, environment: "production")
68
+ 3. claim_deployment_validation(project_id) - claim for validation
69
+ 4. Run: pnpm build && pnpm test
70
+ 5. report_validation(project_id, build_passed: true, tests_passed: true)
71
+ 6. start_deployment(project_id) - returns project's deployment_instructions
72
+ 7. Follow the instructions (e.g., push to main, run deploy command)
73
73
  8. complete_deployment(project_id, success: true, summary: "...")`,
74
- git: `# Git Workflow
75
- Call get_git_workflow(project_id) for project-specific config.
76
- Workflows: none, trunk-based, github-flow, git-flow
77
- - trunk-based: commit directly to main
78
- - github-flow: feature branches, merge via PR
79
- - git-flow: develop/release branches
74
+ git: `# Git Workflow
75
+ Call get_git_workflow(project_id) for project-specific config.
76
+ Workflows: none, trunk-based, github-flow, git-flow
77
+ - trunk-based: commit directly to main
78
+ - github-flow: feature branches, merge via PR
79
+ - git-flow: develop/release branches
80
80
  Update task git_branch when working on a branch.`,
81
- blockers: `# Working with Blockers
82
- When stuck and need human input:
83
- 1. add_blocker(project_id, description: "What's blocking")
84
- 2. Ask your question to the user
85
- 3. resolve_blocker(blocker_id, resolution_note: "How resolved")
81
+ blockers: `# Working with Blockers
82
+ When stuck and need human input:
83
+ 1. add_blocker(project_id, description: "What's blocking")
84
+ 2. Ask your question to the user
85
+ 3. resolve_blocker(blocker_id, resolution_note: "How resolved")
86
86
  Only use for genuine blockers requiring decisions - not routine questions.`,
87
- milestones: `# Task Milestones
88
- For complex tasks, break into milestones:
89
- 1. add_milestone(task_id, title: "Design schema")
90
- 2. add_milestone(task_id, title: "Implement API")
91
- 3. Update with complete_milestone(milestone_id) as you go
87
+ milestones: `# Task Milestones
88
+ For complex tasks, break into milestones:
89
+ 1. add_milestone(task_id, title: "Design schema")
90
+ 2. add_milestone(task_id, title: "Implement API")
91
+ 3. Update with complete_milestone(milestone_id) as you go
92
92
  Dashboard shows progress bar with completed/total.`,
93
- fallback: `# Fallback Activities
94
- When no tasks available, get_next_task suggests activities:
95
- - feature_ideation, code_review, performance_audit
96
- - security_review, test_coverage, documentation_review
97
- 1. start_fallback_activity(project_id, activity: "code_review")
98
- 2. Do the work, use add_finding for issues, add_idea for improvements
93
+ fallback: `# Fallback Activities
94
+ When no tasks available, get_next_task suggests activities:
95
+ - feature_ideation, code_review, performance_audit
96
+ - security_review, test_coverage, documentation_review
97
+ 1. start_fallback_activity(project_id, activity: "code_review")
98
+ 2. Do the work, use add_finding for issues, add_idea for improvements
99
99
  3. stop_fallback_activity(project_id, summary: "...")`,
100
- session: `# Session Management
101
- - start_work_session(git_url, model) initializes and returns next_task
102
- - ALWAYS pass model parameter ("opus", "sonnet", "haiku") for cost tracking
103
- - Use mode:'lite' (default) or mode:'full' for complete context
104
- - heartbeat every 30-60 seconds maintains active status
105
- - end_work_session releases claimed tasks and returns summary
106
- - NEVER STOP: After completing a task, immediately start the next one
107
- - When context grows large: /clear then start_work_session to continue fresh
100
+ session: `# Session Management
101
+ - start_work_session(git_url, model) initializes and returns next_task
102
+ - ALWAYS pass model parameter ("opus", "sonnet", "haiku") for cost tracking
103
+ - Use mode:'lite' (default) or mode:'full' for complete context
104
+ - heartbeat every 30-60 seconds maintains active status
105
+ - end_work_session releases claimed tasks and returns summary
106
+ - NEVER STOP: After completing a task, immediately start the next one
107
+ - When context grows large: /clear then start_work_session to continue fresh
108
108
  - Your progress is saved to the dashboard - nothing is lost on /clear`,
109
- tokens: `# Token Efficiency
110
- Be mindful of token costs - every tool call has a cost.
111
- - Use mode:'lite' (default) - saves ~85% vs full mode
112
- - Call get_token_usage() to check consumption
113
- - /compact when context grows large
114
- - Batch related updates when possible
109
+ tokens: `# Token Efficiency
110
+ Be mindful of token costs - every tool call has a cost.
111
+ - Use mode:'lite' (default) - saves ~85% vs full mode
112
+ - Call get_token_usage() to check consumption
113
+ - /compact when context grows large
114
+ - Batch related updates when possible
115
115
  - Trust lite mode; only use full mode for initial exploration`,
116
- topics: `# Available Help Topics
117
- - getting_started: Basic workflow overview
118
- - tasks: Working on tasks, progress tracking
119
- - validation: Cross-agent task validation
120
- - deployment: Deployment coordination
121
- - git: Git workflow configuration
122
- - blockers: Handling blockers
123
- - milestones: Breaking down complex tasks
124
- - fallback: Background activities when idle
125
- - session: Session management
116
+ topics: `# Available Help Topics
117
+ - getting_started: Basic workflow overview
118
+ - tasks: Working on tasks, progress tracking
119
+ - validation: Cross-agent task validation
120
+ - deployment: Deployment coordination
121
+ - git: Git workflow configuration
122
+ - blockers: Handling blockers
123
+ - milestones: Breaking down complex tasks
124
+ - fallback: Background activities when idle
125
+ - session: Session management
126
126
  - tokens: Token efficiency tips`,
127
127
  };
128
128
  // ============================================================================
@@ -5,183 +5,183 @@
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 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
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
185
  `;
186
186
  /**
187
187
  * Get the agent guidelines template
@@ -195,13 +195,13 @@ export function getAgentGuidelinesTemplate() {
195
195
  * @returns A brief summary of key guidelines
196
196
  */
197
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
-
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
206
  For full guidelines, create a \`.claude/CLAUDE.md\` file in your project with the agent guidelines template.`;
207
207
  }
@@ -19,8 +19,10 @@ export function estimateTokens(obj) {
19
19
  const json = JSON.stringify(obj);
20
20
  return Math.max(1, Math.ceil(json.length / 4));
21
21
  }
22
- catch {
23
- // If JSON serialization fails, return a minimal estimate
22
+ catch (error) {
23
+ // Log warning when serialization fails (e.g., circular references, BigInt)
24
+ const errorMessage = error instanceof Error ? error.message : String(error);
25
+ console.warn(`[Vibescope] Token estimation failed: ${errorMessage}. Returning minimal estimate of 1 token.`);
24
26
  return 1;
25
27
  }
26
28
  }