slashvibe-mcp 0.3.19 → 0.3.21

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.
@@ -0,0 +1,87 @@
1
+ /**
2
+ * vibe_health — Check /vibe platform health status
3
+ *
4
+ * Shows service status, latency, and user stats.
5
+ * Useful for debugging connection issues or monitoring uptime.
6
+ */
7
+
8
+ const config = require('../config');
9
+
10
+ const API_URL = process.env.VIBE_API_URL || 'https://www.slashvibe.dev';
11
+
12
+ const definition = {
13
+ name: 'vibe_health',
14
+ description: 'Check /vibe platform health and service status',
15
+ inputSchema: {
16
+ type: 'object',
17
+ properties: {
18
+ full: {
19
+ type: 'boolean',
20
+ description: 'Include detailed service checks (default: false)'
21
+ }
22
+ }
23
+ }
24
+ };
25
+
26
+ async function handler(args) {
27
+ const { full = false } = args;
28
+
29
+ try {
30
+ const endpoint = `${API_URL}/api/health${full ? '?full=true' : ''}`;
31
+ const response = await fetch(endpoint);
32
+ const data = await response.json();
33
+
34
+ let display = `## /vibe Health Check\n\n`;
35
+
36
+ // Overall status
37
+ const statusEmoji = data.status === 'healthy' ? '\u2705' : data.status === 'degraded' ? '\u26a0\ufe0f' : '\u274c';
38
+ display += `**Status:** ${statusEmoji} ${data.status.toUpperCase()}\n`;
39
+ display += `**Version:** ${data.version}\n`;
40
+ display += `**Response Time:** ${data.responseTime}ms\n\n`;
41
+
42
+ // Service checks
43
+ if (data.checks) {
44
+ display += `### Services\n\n`;
45
+ display += `| Service | Status | Latency |\n`;
46
+ display += `|---------|--------|--------|\n`;
47
+
48
+ for (const [service, check] of Object.entries(data.checks)) {
49
+ const emoji = check.status === 'healthy' ? '\u2705' : check.status === 'not_configured' ? '\u2796' : '\u274c';
50
+ const latency = check.latency ? `${check.latency}ms` : '-';
51
+ display += `| ${service} | ${emoji} ${check.status} | ${latency} |\n`;
52
+ }
53
+ display += '\n';
54
+ }
55
+
56
+ // Stats (only in full mode)
57
+ if (data.stats) {
58
+ display += `### Platform Stats\n\n`;
59
+ display += `- **Registered Handles:** ${data.stats.registeredHandles}\n`;
60
+ display += `- **Active This Week:** ${data.stats.activeThisWeek}\n`;
61
+ display += `- **Total Tips:** ${data.stats.totalTips}\n\n`;
62
+ }
63
+
64
+ // Vibe Beats (activity metrics)
65
+ if (data.vibeBeats) {
66
+ display += `### Vibe Beats (Activity)\n\n`;
67
+ display += `| Period | Active Users |\n`;
68
+ display += `|--------|-------------|\n`;
69
+ display += `| Online (30 min) | ${data.vibeBeats.online} |\n`;
70
+ display += `| Hourly | ${data.vibeBeats.hourly} |\n`;
71
+ display += `| Daily (DAU) | ${data.vibeBeats.daily} |\n`;
72
+ display += `| Weekly (WAU) | ${data.vibeBeats.weekly} |\n`;
73
+ display += `| Monthly (MAU) | ${data.vibeBeats.monthly} |\n`;
74
+ }
75
+
76
+ display += `\n_Checked at ${data.timestamp}_`;
77
+
78
+ return { display };
79
+
80
+ } catch (e) {
81
+ return {
82
+ display: `## /vibe Health Check\n\n\u274c **Connection Failed**\n\nError: ${e.message}\n\nMake sure you have internet connectivity and try again.`
83
+ };
84
+ }
85
+ }
86
+
87
+ module.exports = { definition, handler };
@@ -0,0 +1,117 @@
1
+ /**
2
+ * vibe_leaderboard — See top builders on /vibe
3
+ *
4
+ * Shows the leaderboard ranked by Vibe Score:
5
+ * - Ships posted (building stuff)
6
+ * - Reactions received (quality signal)
7
+ * - Comments given (helping others)
8
+ * - Streak consistency (showing up)
9
+ * - Invites redeemed (growing community)
10
+ */
11
+
12
+ const config = require('../config');
13
+
14
+ const API_URL = process.env.VIBE_API_URL || 'https://www.slashvibe.dev';
15
+
16
+ const definition = {
17
+ name: 'vibe_leaderboard',
18
+ description: 'See top builders on /vibe ranked by Vibe Score',
19
+ inputSchema: {
20
+ type: 'object',
21
+ properties: {
22
+ category: {
23
+ type: 'string',
24
+ enum: ['overall', 'ships', 'streaks', 'reactions', 'helpful'],
25
+ description: 'Leaderboard category (default: overall)'
26
+ },
27
+ limit: {
28
+ type: 'number',
29
+ description: 'Number of entries to show (default: 10, max: 50)'
30
+ }
31
+ }
32
+ }
33
+ };
34
+
35
+ async function handler(args) {
36
+ const { category = 'overall', limit = 10 } = args;
37
+ const maxLimit = Math.min(limit, 50);
38
+
39
+ try {
40
+ const endpoint = `${API_URL}/api/growth/leaderboard?category=${category}&limit=${maxLimit}`;
41
+ const response = await fetch(endpoint);
42
+ const data = await response.json();
43
+
44
+ if (!data.success) {
45
+ return { display: `\u274c Failed to load leaderboard: ${data.error}` };
46
+ }
47
+
48
+ const myHandle = config.isInitialized() ? config.getHandle() : null;
49
+
50
+ let display = `## /vibe Leaderboard\n`;
51
+ display += `**Category:** ${category} | **Showing:** Top ${maxLimit}\n\n`;
52
+
53
+ if (data.leaderboard.length === 0) {
54
+ display += `_No entries yet. Be the first to ship!_\n`;
55
+ return { display };
56
+ }
57
+
58
+ // Table header
59
+ display += `| Rank | Builder | Vibe Score | Ships | Streak |\n`;
60
+ display += `|------|---------|------------|-------|--------|\n`;
61
+
62
+ for (const entry of data.leaderboard) {
63
+ const isMe = myHandle && entry.handle.toLowerCase() === myHandle.toLowerCase();
64
+ const highlight = isMe ? '**' : '';
65
+
66
+ // Position change indicator
67
+ let posIndicator = '';
68
+ if (entry.positionChange > 0) {
69
+ posIndicator = ` \u2191${entry.positionChange}`;
70
+ } else if (entry.positionChange < 0) {
71
+ posIndicator = ` \u2193${Math.abs(entry.positionChange)}`;
72
+ } else if (entry.isNew) {
73
+ posIndicator = ' \u2728';
74
+ }
75
+
76
+ // Tier emoji
77
+ const tierEmoji = entry.tierDisplay?.emoji || '';
78
+
79
+ display += `| ${highlight}#${entry.rank}${posIndicator}${highlight} | ${highlight}@${entry.handle}${highlight} ${tierEmoji} | ${entry.vibeScore} | ${entry.stats?.ships || 0} | ${entry.streak || 0}d |\n`;
80
+ }
81
+
82
+ // Stats summary
83
+ if (data.stats) {
84
+ display += `\n### Community Stats\n`;
85
+ display += `- **Total Builders:** ${data.stats.total}\n`;
86
+ display += `- **Ships Posted:** ${data.stats.shipsCount}\n`;
87
+ display += `- **Active Today:** ${data.stats.activeToday}\n`;
88
+ display += `- **Avg Vibe Score:** ${data.stats.averageVibeScore}\n`;
89
+ }
90
+
91
+ // Highlights
92
+ if (data.highlights?.movers?.length > 0) {
93
+ display += `\n### \ud83d\ude80 Biggest Movers\n`;
94
+ for (const mover of data.highlights.movers.slice(0, 3)) {
95
+ display += `- @${mover.handle} +${mover.change} (now #${mover.rank})\n`;
96
+ }
97
+ }
98
+
99
+ if (data.highlights?.newEntries?.length > 0) {
100
+ display += `\n### \u2728 New Entries\n`;
101
+ for (const entry of data.highlights.newEntries.slice(0, 3)) {
102
+ display += `- @${entry.handle} joined at #${entry.rank}\n`;
103
+ }
104
+ }
105
+
106
+ display += `\n_${data.note}_`;
107
+
108
+ return { display };
109
+
110
+ } catch (e) {
111
+ return {
112
+ display: `## /vibe Leaderboard\n\n\u274c **Failed to load**\n\nError: ${e.message}`
113
+ };
114
+ }
115
+ }
116
+
117
+ module.exports = { definition, handler };
@@ -0,0 +1,206 @@
1
+ /**
2
+ * Git Apply Library
3
+ *
4
+ * Downloads and applies git bundles from session forks.
5
+ * Used by session.js fork command to get actual code.
6
+ *
7
+ * Key functions:
8
+ * - downloadBundle(url) - Download bundle from signed URL
9
+ * - applyBundleFromUrl(url, branchName) - Download and apply in one step
10
+ */
11
+
12
+ const { execSync } = require('child_process');
13
+ const fs = require('fs');
14
+ const path = require('path');
15
+ const os = require('os');
16
+ const https = require('https');
17
+ const http = require('http');
18
+
19
+ const { isGitRepo, validateBundle, applyBundle } = require('./git-bundle');
20
+
21
+ /**
22
+ * Download a bundle from a URL
23
+ * @param {string} url - The signed download URL
24
+ * @returns {Promise<object>} - { success, buffer, error? }
25
+ */
26
+ async function downloadBundle(url) {
27
+ return new Promise((resolve) => {
28
+ const protocol = url.startsWith('https') ? https : http;
29
+
30
+ const request = protocol.get(url, (response) => {
31
+ // Handle redirects
32
+ if (response.statusCode >= 300 && response.statusCode < 400 && response.headers.location) {
33
+ downloadBundle(response.headers.location).then(resolve);
34
+ return;
35
+ }
36
+
37
+ if (response.statusCode !== 200) {
38
+ resolve({
39
+ success: false,
40
+ error: `HTTP ${response.statusCode}: ${response.statusMessage}`,
41
+ });
42
+ return;
43
+ }
44
+
45
+ const chunks = [];
46
+ response.on('data', (chunk) => chunks.push(chunk));
47
+ response.on('end', () => {
48
+ const buffer = Buffer.concat(chunks);
49
+ resolve({
50
+ success: true,
51
+ buffer,
52
+ size: buffer.length,
53
+ });
54
+ });
55
+ response.on('error', (err) => {
56
+ resolve({ success: false, error: err.message });
57
+ });
58
+ });
59
+
60
+ request.on('error', (err) => {
61
+ resolve({ success: false, error: err.message });
62
+ });
63
+
64
+ // Timeout after 60 seconds
65
+ request.setTimeout(60000, () => {
66
+ request.destroy();
67
+ resolve({ success: false, error: 'Download timeout (60s)' });
68
+ });
69
+ });
70
+ }
71
+
72
+ /**
73
+ * Download and apply a bundle from a URL
74
+ * @param {string} url - The signed download URL
75
+ * @param {string} branchName - Name for the new branch (default: 'forked-session')
76
+ * @returns {Promise<object>} - { success, branch, commits?, error? }
77
+ */
78
+ async function applyBundleFromUrl(url, branchName = 'forked-session') {
79
+ // Check we're in a git repo
80
+ if (!isGitRepo()) {
81
+ return { success: false, error: 'Not in a git repository' };
82
+ }
83
+
84
+ // Download the bundle
85
+ console.log(`[git-apply] Downloading bundle...`);
86
+ const downloadResult = await downloadBundle(url);
87
+
88
+ if (!downloadResult.success) {
89
+ return { success: false, error: `Download failed: ${downloadResult.error}` };
90
+ }
91
+
92
+ console.log(`[git-apply] Downloaded ${downloadResult.size} bytes`);
93
+
94
+ // Validate the bundle
95
+ const validation = validateBundle(downloadResult.buffer);
96
+ if (!validation.success) {
97
+ return { success: false, error: `Invalid bundle: ${validation.error}` };
98
+ }
99
+
100
+ // Apply the bundle
101
+ console.log(`[git-apply] Applying bundle to branch: ${branchName}`);
102
+ const applyResult = applyBundle(downloadResult.buffer, branchName);
103
+
104
+ if (!applyResult.success) {
105
+ return { success: false, error: `Apply failed: ${applyResult.error}` };
106
+ }
107
+
108
+ return {
109
+ success: true,
110
+ branch: applyResult.branch,
111
+ refs: applyResult.refs,
112
+ size: downloadResult.size,
113
+ message: `Bundle applied to branch '${applyResult.branch}'. Use 'git checkout ${applyResult.branch}' to view.`,
114
+ };
115
+ }
116
+
117
+ /**
118
+ * Check out the forked branch
119
+ * @param {string} branchName - Branch to checkout
120
+ * @returns {object} - { success, error? }
121
+ */
122
+ function checkoutBranch(branchName) {
123
+ try {
124
+ execSync(`git checkout ${branchName}`, {
125
+ stdio: 'pipe',
126
+ encoding: 'utf8',
127
+ });
128
+ return { success: true };
129
+ } catch (error) {
130
+ return { success: false, error: error.message };
131
+ }
132
+ }
133
+
134
+ /**
135
+ * Get info about a branch
136
+ * @param {string} branchName - Branch name
137
+ * @returns {object} - { exists, current, commits? }
138
+ */
139
+ function getBranchInfo(branchName) {
140
+ try {
141
+ // Check if branch exists
142
+ const branches = execSync('git branch --list', {
143
+ stdio: 'pipe',
144
+ encoding: 'utf8',
145
+ });
146
+
147
+ const branchList = branches.split('\n').map((b) => b.replace(/^\*?\s*/, '').trim());
148
+ const exists = branchList.includes(branchName);
149
+
150
+ // Check current branch
151
+ const currentBranch = execSync('git rev-parse --abbrev-ref HEAD', {
152
+ stdio: 'pipe',
153
+ encoding: 'utf8',
154
+ }).trim();
155
+
156
+ const result = {
157
+ exists,
158
+ current: currentBranch === branchName,
159
+ currentBranch,
160
+ };
161
+
162
+ // Get commit count if branch exists
163
+ if (exists) {
164
+ try {
165
+ const commitCount = execSync(`git rev-list --count ${branchName}`, {
166
+ stdio: 'pipe',
167
+ encoding: 'utf8',
168
+ });
169
+ result.commits = parseInt(commitCount.trim(), 10);
170
+ } catch (e) {
171
+ // Branch might not have commits yet
172
+ }
173
+ }
174
+
175
+ return result;
176
+ } catch (error) {
177
+ return { exists: false, current: false, error: error.message };
178
+ }
179
+ }
180
+
181
+ /**
182
+ * Delete a branch
183
+ * @param {string} branchName - Branch to delete
184
+ * @param {boolean} force - Force delete even if not merged
185
+ * @returns {object} - { success, error? }
186
+ */
187
+ function deleteBranch(branchName, force = false) {
188
+ try {
189
+ const flag = force ? '-D' : '-d';
190
+ execSync(`git branch ${flag} ${branchName}`, {
191
+ stdio: 'pipe',
192
+ encoding: 'utf8',
193
+ });
194
+ return { success: true };
195
+ } catch (error) {
196
+ return { success: false, error: error.message };
197
+ }
198
+ }
199
+
200
+ module.exports = {
201
+ downloadBundle,
202
+ applyBundleFromUrl,
203
+ checkoutBranch,
204
+ getBranchInfo,
205
+ deleteBranch,
206
+ };