@vibescope/mcp-server 0.2.3 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/CHANGELOG.md +84 -0
  2. package/README.md +194 -138
  3. package/dist/api-client.d.ts +276 -8
  4. package/dist/api-client.js +123 -8
  5. package/dist/cli.d.ts +6 -3
  6. package/dist/cli.js +28 -10
  7. package/dist/handlers/blockers.d.ts +11 -0
  8. package/dist/handlers/blockers.js +37 -2
  9. package/dist/handlers/bodies-of-work.d.ts +2 -0
  10. package/dist/handlers/bodies-of-work.js +30 -1
  11. package/dist/handlers/connectors.js +2 -2
  12. package/dist/handlers/decisions.d.ts +11 -0
  13. package/dist/handlers/decisions.js +37 -2
  14. package/dist/handlers/deployment.d.ts +6 -0
  15. package/dist/handlers/deployment.js +33 -5
  16. package/dist/handlers/discovery.js +27 -11
  17. package/dist/handlers/fallback.js +12 -6
  18. package/dist/handlers/file-checkouts.d.ts +1 -0
  19. package/dist/handlers/file-checkouts.js +17 -2
  20. package/dist/handlers/findings.d.ts +5 -0
  21. package/dist/handlers/findings.js +19 -2
  22. package/dist/handlers/git-issues.js +4 -2
  23. package/dist/handlers/ideas.d.ts +5 -0
  24. package/dist/handlers/ideas.js +19 -2
  25. package/dist/handlers/progress.js +2 -2
  26. package/dist/handlers/project.d.ts +1 -0
  27. package/dist/handlers/project.js +35 -2
  28. package/dist/handlers/requests.js +6 -3
  29. package/dist/handlers/roles.js +13 -2
  30. package/dist/handlers/session.d.ts +12 -0
  31. package/dist/handlers/session.js +288 -25
  32. package/dist/handlers/sprints.d.ts +2 -0
  33. package/dist/handlers/sprints.js +30 -1
  34. package/dist/handlers/tasks.d.ts +25 -2
  35. package/dist/handlers/tasks.js +228 -35
  36. package/dist/handlers/tool-docs.js +834 -767
  37. package/dist/index.js +73 -73
  38. package/dist/knowledge.d.ts +6 -0
  39. package/dist/knowledge.js +218 -0
  40. package/dist/setup.d.ts +22 -0
  41. package/dist/setup.js +313 -0
  42. package/dist/templates/agent-guidelines.d.ts +18 -0
  43. package/dist/templates/agent-guidelines.js +207 -0
  44. package/dist/tools.js +527 -174
  45. package/dist/utils.d.ts +5 -2
  46. package/dist/utils.js +101 -62
  47. package/docs/TOOLS.md +2053 -2053
  48. package/package.json +51 -46
  49. package/scripts/generate-docs.ts +212 -212
  50. package/scripts/version-bump.ts +203 -0
  51. package/src/api-client.test.ts +723 -723
  52. package/src/api-client.ts +2499 -2140
  53. package/src/cli.ts +27 -10
  54. package/src/handlers/__test-setup__.ts +236 -231
  55. package/src/handlers/__test-utils__.ts +87 -87
  56. package/src/handlers/blockers.test.ts +468 -392
  57. package/src/handlers/blockers.ts +163 -109
  58. package/src/handlers/bodies-of-work.test.ts +704 -704
  59. package/src/handlers/bodies-of-work.ts +526 -468
  60. package/src/handlers/connectors.test.ts +834 -834
  61. package/src/handlers/connectors.ts +229 -229
  62. package/src/handlers/cost.test.ts +462 -462
  63. package/src/handlers/cost.ts +285 -285
  64. package/src/handlers/decisions.test.ts +382 -313
  65. package/src/handlers/decisions.ts +153 -99
  66. package/src/handlers/deployment.test.ts +551 -470
  67. package/src/handlers/deployment.ts +541 -508
  68. package/src/handlers/discovery.test.ts +206 -206
  69. package/src/handlers/discovery.ts +390 -374
  70. package/src/handlers/fallback.test.ts +537 -536
  71. package/src/handlers/fallback.ts +194 -188
  72. package/src/handlers/file-checkouts.test.ts +750 -670
  73. package/src/handlers/file-checkouts.ts +185 -165
  74. package/src/handlers/findings.test.ts +633 -633
  75. package/src/handlers/findings.ts +239 -203
  76. package/src/handlers/git-issues.test.ts +631 -631
  77. package/src/handlers/git-issues.ts +136 -134
  78. package/src/handlers/ideas.test.ts +644 -644
  79. package/src/handlers/ideas.ts +207 -175
  80. package/src/handlers/index.ts +84 -84
  81. package/src/handlers/milestones.test.ts +475 -475
  82. package/src/handlers/milestones.ts +180 -180
  83. package/src/handlers/organizations.test.ts +826 -826
  84. package/src/handlers/organizations.ts +315 -315
  85. package/src/handlers/progress.test.ts +269 -269
  86. package/src/handlers/progress.ts +77 -77
  87. package/src/handlers/project.test.ts +546 -546
  88. package/src/handlers/project.ts +239 -194
  89. package/src/handlers/requests.test.ts +303 -272
  90. package/src/handlers/requests.ts +99 -96
  91. package/src/handlers/roles.test.ts +303 -303
  92. package/src/handlers/roles.ts +226 -208
  93. package/src/handlers/session.test.ts +875 -576
  94. package/src/handlers/session.ts +738 -425
  95. package/src/handlers/sprints.test.ts +732 -732
  96. package/src/handlers/sprints.ts +537 -477
  97. package/src/handlers/tasks.test.ts +907 -980
  98. package/src/handlers/tasks.ts +945 -716
  99. package/src/handlers/tool-categories.test.ts +66 -66
  100. package/src/handlers/tool-docs.ts +1096 -1024
  101. package/src/handlers/types.test.ts +259 -0
  102. package/src/handlers/types.ts +175 -175
  103. package/src/handlers/validation.test.ts +582 -582
  104. package/src/handlers/validation.ts +97 -97
  105. package/src/index.ts +792 -792
  106. package/src/setup.test.ts +231 -0
  107. package/src/setup.ts +370 -0
  108. package/src/templates/agent-guidelines.ts +210 -0
  109. package/src/token-tracking.test.ts +453 -453
  110. package/src/token-tracking.ts +164 -164
  111. package/src/tools.ts +3562 -3208
  112. package/src/utils.test.ts +683 -681
  113. package/src/utils.ts +436 -392
  114. package/src/validators.test.ts +223 -223
  115. package/src/validators.ts +249 -249
  116. package/tsconfig.json +16 -16
  117. package/vitest.config.ts +14 -14
package/dist/setup.js ADDED
@@ -0,0 +1,313 @@
1
+ /**
2
+ * Vibescope Setup Wizard
3
+ * Guides users through setting up Vibescope MCP integration
4
+ *
5
+ * Usage: vibescope-cli setup
6
+ */
7
+ import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'node:fs';
8
+ import { createInterface } from 'node:readline';
9
+ import { homedir, platform } from 'node:os';
10
+ import { join, dirname } from 'node:path';
11
+ import { exec } from 'node:child_process';
12
+ const VIBESCOPE_SETTINGS_URL = 'https://vibescope.dev/dashboard/settings';
13
+ const DEFAULT_SUPABASE_URL = 'https://uuneucmuubpgswvfijwd.supabase.co';
14
+ // ============================================================================
15
+ // Config Path Helpers
16
+ // ============================================================================
17
+ function getClaudeDesktopConfigPath() {
18
+ const plat = platform();
19
+ const home = homedir();
20
+ if (plat === 'darwin') {
21
+ return join(home, 'Library', 'Application Support', 'Claude', 'claude_desktop_config.json');
22
+ }
23
+ else if (plat === 'win32') {
24
+ return join(home, 'AppData', 'Roaming', 'Claude', 'claude_desktop_config.json');
25
+ }
26
+ else {
27
+ return join(home, '.config', 'Claude', 'claude_desktop_config.json');
28
+ }
29
+ }
30
+ function getCursorConfigPath() {
31
+ const plat = platform();
32
+ const home = homedir();
33
+ if (plat === 'darwin') {
34
+ return join(home, 'Library', 'Application Support', 'Cursor', 'User', 'globalStorage', 'saoudrizwan.claude-dev', 'settings', 'cline_mcp_settings.json');
35
+ }
36
+ else if (plat === 'win32') {
37
+ return join(home, 'AppData', 'Roaming', 'Cursor', 'User', 'globalStorage', 'saoudrizwan.claude-dev', 'settings', 'cline_mcp_settings.json');
38
+ }
39
+ else {
40
+ return join(home, '.config', 'Cursor', 'User', 'globalStorage', 'saoudrizwan.claude-dev', 'settings', 'cline_mcp_settings.json');
41
+ }
42
+ }
43
+ function getGeminiConfigPath() {
44
+ return join(homedir(), '.gemini', 'settings.json');
45
+ }
46
+ // ============================================================================
47
+ // IDE Detection
48
+ // ============================================================================
49
+ export function detectIdes() {
50
+ const ides = [
51
+ {
52
+ name: 'claude-code',
53
+ displayName: 'Claude Code (CLI)',
54
+ configPath: '.mcp.json',
55
+ detected: true,
56
+ configFormat: 'mcp-json',
57
+ },
58
+ {
59
+ name: 'claude-desktop',
60
+ displayName: 'Claude Desktop',
61
+ configPath: getClaudeDesktopConfigPath(),
62
+ detected: existsSync(dirname(getClaudeDesktopConfigPath())),
63
+ configFormat: 'mcp-json',
64
+ },
65
+ {
66
+ name: 'cursor',
67
+ displayName: 'Cursor',
68
+ configPath: getCursorConfigPath(),
69
+ detected: existsSync(dirname(getCursorConfigPath())),
70
+ configFormat: 'mcp-json',
71
+ },
72
+ {
73
+ name: 'gemini',
74
+ displayName: 'Gemini CLI',
75
+ configPath: getGeminiConfigPath(),
76
+ detected: true,
77
+ configFormat: 'settings-json',
78
+ },
79
+ ];
80
+ return ides;
81
+ }
82
+ // ============================================================================
83
+ // User Prompts
84
+ // ============================================================================
85
+ async function prompt(question) {
86
+ const rl = createInterface({
87
+ input: process.stdin,
88
+ output: process.stdout,
89
+ });
90
+ return new Promise((resolve) => {
91
+ rl.question(question, (answer) => {
92
+ rl.close();
93
+ resolve(answer.trim());
94
+ });
95
+ });
96
+ }
97
+ async function promptSelect(question, options) {
98
+ console.log('\n' + question + '\n');
99
+ options.forEach((opt, i) => {
100
+ console.log(' ' + (i + 1) + ') ' + opt.label);
101
+ });
102
+ const answer = await prompt('\nEnter number: ');
103
+ const index = parseInt(answer, 10) - 1;
104
+ if (index >= 0 && index < options.length) {
105
+ return options[index].value;
106
+ }
107
+ console.log('Invalid selection, using first option.');
108
+ return options[0].value;
109
+ }
110
+ // ============================================================================
111
+ // Browser & Validation
112
+ // ============================================================================
113
+ function openBrowser(url) {
114
+ return new Promise((resolve) => {
115
+ const plat = platform();
116
+ let cmd;
117
+ if (plat === 'darwin') {
118
+ cmd = 'open "' + url + '"';
119
+ }
120
+ else if (plat === 'win32') {
121
+ cmd = 'start "" "' + url + '"';
122
+ }
123
+ else {
124
+ cmd = 'xdg-open "' + url + '"';
125
+ }
126
+ exec(cmd, (error) => {
127
+ if (error) {
128
+ console.log('\nCould not open browser automatically.');
129
+ console.log('Please visit: ' + url + '\n');
130
+ }
131
+ resolve();
132
+ });
133
+ });
134
+ }
135
+ export async function validateApiKey(apiKey) {
136
+ try {
137
+ const response = await fetch(DEFAULT_SUPABASE_URL + '/rest/v1/api_keys?key=eq.' + apiKey + '&select=id', {
138
+ headers: {
139
+ 'apikey': apiKey,
140
+ 'Authorization': 'Bearer ' + apiKey,
141
+ },
142
+ });
143
+ if (response.ok) {
144
+ return { valid: true, message: 'API key validated successfully!' };
145
+ }
146
+ else {
147
+ return { valid: false, message: 'API key appears to be invalid.' };
148
+ }
149
+ }
150
+ catch {
151
+ return { valid: true, message: 'Could not validate API key (network issue), but proceeding.' };
152
+ }
153
+ }
154
+ // ============================================================================
155
+ // Config Management
156
+ // ============================================================================
157
+ export function readExistingConfig(configPath) {
158
+ if (existsSync(configPath)) {
159
+ try {
160
+ return JSON.parse(readFileSync(configPath, 'utf-8'));
161
+ }
162
+ catch {
163
+ return {};
164
+ }
165
+ }
166
+ return {};
167
+ }
168
+ export function writeConfig(configPath, config) {
169
+ const dir = dirname(configPath);
170
+ if (!existsSync(dir)) {
171
+ mkdirSync(dir, { recursive: true });
172
+ }
173
+ writeFileSync(configPath, JSON.stringify(config, null, 2) + '\n');
174
+ }
175
+ export function generateMcpConfig(apiKey, ide) {
176
+ const vibescopeServer = {
177
+ command: 'npx',
178
+ args: ['-y', '-p', '@vibescope/mcp-server@latest', 'vibescope-mcp'],
179
+ env: {
180
+ VIBESCOPE_API_KEY: apiKey,
181
+ },
182
+ };
183
+ // Gemini CLI uses a different config format with additional options
184
+ if (ide.configFormat === 'settings-json') {
185
+ return {
186
+ mcpServers: {
187
+ vibescope: {
188
+ ...vibescopeServer,
189
+ timeout: 30000,
190
+ trust: true,
191
+ },
192
+ },
193
+ };
194
+ }
195
+ // Standard MCP config for Claude Code, Claude Desktop, Cursor
196
+ return {
197
+ mcpServers: {
198
+ vibescope: vibescopeServer,
199
+ },
200
+ };
201
+ }
202
+ // ============================================================================
203
+ // Main Setup Flow
204
+ // ============================================================================
205
+ export async function runSetup() {
206
+ console.log('\n=================================');
207
+ console.log(' Vibescope Setup Wizard');
208
+ console.log('=================================\n');
209
+ // Step 1: Detect IDEs
210
+ const ides = detectIdes();
211
+ const detectedIdes = ides.filter(ide => ide.detected);
212
+ console.log('Available development environments:');
213
+ detectedIdes.forEach(ide => {
214
+ console.log(' - ' + ide.displayName);
215
+ });
216
+ // Step 2: Select IDE to configure
217
+ let selectedIde;
218
+ if (detectedIdes.length === 1) {
219
+ selectedIde = detectedIdes[0];
220
+ console.log('\nConfiguring for ' + selectedIde.displayName + '...');
221
+ }
222
+ else {
223
+ const ideChoice = await promptSelect('Which environment do you want to configure?', detectedIdes.map(ide => ({ label: ide.displayName, value: ide.name })));
224
+ selectedIde = ides.find(ide => ide.name === ideChoice) || detectedIdes[0];
225
+ }
226
+ // Step 3: Check if config already exists
227
+ if (existsSync(selectedIde.configPath)) {
228
+ const existingConfig = readExistingConfig(selectedIde.configPath);
229
+ const hasMcpServers = 'mcpServers' in existingConfig;
230
+ const hasVibescope = hasMcpServers &&
231
+ typeof existingConfig.mcpServers === 'object' &&
232
+ existingConfig.mcpServers !== null &&
233
+ 'vibescope' in existingConfig.mcpServers;
234
+ if (hasVibescope) {
235
+ const overwrite = await prompt('\nVibescope is already configured. Reconfigure? (y/N): ');
236
+ if (overwrite.toLowerCase() !== 'y') {
237
+ console.log('\nSetup cancelled. Your existing configuration is preserved.');
238
+ return;
239
+ }
240
+ }
241
+ }
242
+ // Step 4: Get API key
243
+ console.log('\n--- Step 1: Get your API key ---\n');
244
+ console.log('Opening Vibescope settings page in your browser...');
245
+ console.log("Create an API key if you don't have one, then copy it.\n");
246
+ await openBrowser(VIBESCOPE_SETTINGS_URL);
247
+ const apiKey = await prompt('Paste your Vibescope API key: ');
248
+ if (!apiKey) {
249
+ console.error('\nError: API key is required.');
250
+ process.exit(1);
251
+ }
252
+ // Validate API key
253
+ console.log('\nValidating API key...');
254
+ const validation = await validateApiKey(apiKey);
255
+ console.log(validation.message);
256
+ if (!validation.valid) {
257
+ const proceed = await prompt('Proceed anyway? (y/N): ');
258
+ if (proceed.toLowerCase() !== 'y') {
259
+ process.exit(1);
260
+ }
261
+ }
262
+ // Step 5: Write configuration
263
+ console.log('\n--- Step 2: Writing Configuration ---\n');
264
+ const mcpConfig = generateMcpConfig(apiKey, selectedIde);
265
+ // Merge with existing config if present
266
+ const existingConfig = readExistingConfig(selectedIde.configPath);
267
+ const existingMcpServers = typeof existingConfig.mcpServers === 'object' && existingConfig.mcpServers !== null
268
+ ? existingConfig.mcpServers
269
+ : {};
270
+ const newMcpServers = mcpConfig.mcpServers;
271
+ const mergedConfig = {
272
+ ...existingConfig,
273
+ mcpServers: {
274
+ ...existingMcpServers,
275
+ ...newMcpServers,
276
+ },
277
+ };
278
+ writeConfig(selectedIde.configPath, mergedConfig);
279
+ console.log('Configuration written to: ' + selectedIde.configPath);
280
+ // Step 6: IDE-specific next steps
281
+ console.log('\n=================================');
282
+ console.log(' Setup Complete!');
283
+ console.log('=================================\n');
284
+ switch (selectedIde.name) {
285
+ case 'claude-code':
286
+ console.log('Next steps:');
287
+ console.log(' 1. Restart Claude Code (or run: claude mcp reload)');
288
+ console.log(' 2. Verify connection: claude mcp list');
289
+ console.log(' 3. Start using Vibescope in your conversation');
290
+ break;
291
+ case 'claude-desktop':
292
+ console.log('Next steps:');
293
+ console.log(' 1. Restart Claude Desktop');
294
+ console.log(' 2. Vibescope tools will be available in your conversations');
295
+ break;
296
+ case 'cursor':
297
+ console.log('Next steps:');
298
+ console.log(' 1. Restart Cursor');
299
+ console.log(' 2. Open the MCP settings to verify Vibescope is connected');
300
+ break;
301
+ case 'gemini':
302
+ console.log('Next steps:');
303
+ console.log(' 1. Restart Gemini CLI');
304
+ console.log(' 2. Verify connection: gemini mcp list');
305
+ console.log(' 3. Start using Vibescope in your conversation');
306
+ break;
307
+ default:
308
+ console.log('Next steps:');
309
+ console.log(' 1. Restart your IDE/CLI');
310
+ console.log(' 2. Verify Vibescope is connected');
311
+ }
312
+ console.log('\nHappy building!\n');
313
+ }
@@ -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
+ }