slashvibe-mcp 0.3.21 → 0.3.22

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 (229) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +280 -47
  3. package/config.js +36 -31
  4. package/crypto.js +1 -6
  5. package/discord.js +19 -19
  6. package/index.js +217 -207
  7. package/intelligence/index.js +2 -9
  8. package/intelligence/infer.js +10 -16
  9. package/intelligence/patterns.js +23 -18
  10. package/intelligence/proactive.js +16 -15
  11. package/intelligence/serendipity.js +57 -20
  12. package/memory.js +13 -8
  13. package/notify.js +39 -14
  14. package/package.json +27 -20
  15. package/presence.js +2 -2
  16. package/prompts.js +5 -9
  17. package/protocol/index.js +123 -87
  18. package/protocol/telegram-commands.js +36 -37
  19. package/store/api.js +358 -529
  20. package/store/local.js +9 -10
  21. package/store/profiles.js +48 -192
  22. package/store/reservations.js +2 -9
  23. package/store/skills.js +69 -71
  24. package/store/sqlite.js +355 -0
  25. package/tools/_actions.js +48 -387
  26. package/tools/_connection-queue.js +45 -56
  27. package/tools/_discovery-enhanced.js +52 -57
  28. package/tools/_discovery.js +87 -185
  29. package/tools/{l2-status.js → _experimental/l2-status.js} +68 -70
  30. package/tools/{shipback.js → _experimental/shipback.js} +4 -3
  31. package/tools/_proactive-discovery.js +60 -73
  32. package/tools/_shared/index.js +41 -64
  33. package/tools/admin-inbox.js +10 -15
  34. package/tools/agents.js +1 -1
  35. package/tools/artifact-create.js +13 -23
  36. package/tools/artifact-view.js +4 -4
  37. package/tools/{_deprecated/back.js → back.js} +1 -1
  38. package/tools/bye.js +3 -5
  39. package/tools/consent.js +2 -2
  40. package/tools/context.js +9 -10
  41. package/tools/crossword.js +3 -2
  42. package/tools/discover.js +94 -356
  43. package/tools/dm.js +27 -86
  44. package/tools/doctor.js +12 -41
  45. package/tools/drawing.js +34 -20
  46. package/tools/echo.js +11 -11
  47. package/tools/feed.js +30 -58
  48. package/tools/follow.js +64 -187
  49. package/tools/{_deprecated/forget.js → forget.js} +4 -7
  50. package/tools/game.js +144 -48
  51. package/tools/handoff.js +6 -8
  52. package/tools/help.js +3 -3
  53. package/tools/idea.js +15 -27
  54. package/tools/inbox.js +121 -293
  55. package/tools/init.js +54 -151
  56. package/tools/invite.js +8 -21
  57. package/tools/migrate.js +27 -24
  58. package/tools/multiplayer-game.js +50 -40
  59. package/tools/{_deprecated/mute.js → mute.js} +4 -3
  60. package/tools/notifications.js +58 -48
  61. package/tools/observe.js +12 -15
  62. package/tools/onboarding.js +8 -11
  63. package/tools/open.js +13 -144
  64. package/tools/party-game.js +23 -12
  65. package/tools/patterns.js +2 -1
  66. package/tools/ping.js +5 -7
  67. package/tools/react.js +28 -30
  68. package/tools/{_deprecated/recall.js → recall.js} +5 -10
  69. package/tools/release.js +4 -2
  70. package/tools/{_deprecated/remember.js → remember.js} +4 -6
  71. package/tools/report.js +2 -2
  72. package/tools/request.js +6 -26
  73. package/tools/reserve.js +1 -1
  74. package/tools/session-fork.js +97 -0
  75. package/tools/session-save.js +109 -0
  76. package/tools/settings.js +30 -99
  77. package/tools/ship.js +74 -56
  78. package/tools/{_deprecated/skills-exchange.js → skills-exchange.js} +38 -39
  79. package/tools/social-inbox.js +22 -28
  80. package/tools/social-post.js +24 -27
  81. package/tools/solo-game.js +54 -46
  82. package/tools/start.js +14 -148
  83. package/tools/status.js +21 -68
  84. package/tools/submit.js +4 -2
  85. package/tools/suggest-tags.js +36 -33
  86. package/tools/summarize.js +19 -16
  87. package/tools/tag-suggestions.js +72 -73
  88. package/tools/test.js +1 -1
  89. package/tools/{_deprecated/tictactoe.js → tictactoe.js} +26 -26
  90. package/tools/token.js +4 -4
  91. package/tools/update.js +1 -2
  92. package/tools/watch.js +132 -112
  93. package/tools/who.js +20 -40
  94. package/tools/{_deprecated/wordassociation.js → wordassociation.js} +23 -20
  95. package/tools/workshop-buddy.js +52 -53
  96. package/tools/x-mentions.js +0 -1
  97. package/tools/x-reply.js +0 -1
  98. package/twitter.js +14 -20
  99. package/version.json +8 -10
  100. package/analytics.js +0 -107
  101. package/auth-store.js +0 -148
  102. package/auto-update.js +0 -130
  103. package/bridges/bridge-monitor.js +0 -388
  104. package/bridges/discord-bot.js +0 -431
  105. package/bridges/farcaster.js +0 -299
  106. package/bridges/telegram.js +0 -261
  107. package/bridges/webhook-health.js +0 -420
  108. package/bridges/webhook-server.js +0 -437
  109. package/bridges/whatsapp.js +0 -441
  110. package/bridges/x-webhook.js +0 -423
  111. package/games/arcade.js +0 -406
  112. package/games/chess.js +0 -451
  113. package/games/colorguess.js +0 -343
  114. package/games/crossword-words.js +0 -171
  115. package/games/crossword.js +0 -461
  116. package/games/drawing.js +0 -347
  117. package/games/gameroulette.js +0 -300
  118. package/games/gamerouter.js +0 -336
  119. package/games/gamestatus.js +0 -337
  120. package/games/guessnumber.js +0 -209
  121. package/games/hangman.js +0 -279
  122. package/games/memory.js +0 -338
  123. package/games/multiplayer-tictactoe.js +0 -389
  124. package/games/pixelart.js +0 -399
  125. package/games/quickduel.js +0 -354
  126. package/games/riddle.js +0 -371
  127. package/games/rockpaperscissors.js +0 -291
  128. package/games/snake.js +0 -406
  129. package/games/storybuilder.js +0 -343
  130. package/games/tictactoe.js +0 -345
  131. package/games/twentyquestions.js +0 -286
  132. package/games/twotruths.js +0 -207
  133. package/games/werewolf.js +0 -508
  134. package/games/wordassociation.js +0 -247
  135. package/games/wordchain.js +0 -135
  136. package/intelligence/interests.js +0 -369
  137. package/notification-emitter.js +0 -77
  138. package/setup.js +0 -480
  139. package/smart-inbox.js +0 -276
  140. package/tools/_deprecated/auto-suggest-connections.js +0 -304
  141. package/tools/_deprecated/bootstrap-skills.js +0 -231
  142. package/tools/_deprecated/bridge-dashboard.js +0 -342
  143. package/tools/_deprecated/bridge-health.js +0 -400
  144. package/tools/_deprecated/bridge-live.js +0 -384
  145. package/tools/_deprecated/bridges.js +0 -383
  146. package/tools/_deprecated/colorguess.js +0 -281
  147. package/tools/_deprecated/discover-insights.js +0 -379
  148. package/tools/_deprecated/discover-momentum.js +0 -256
  149. package/tools/_deprecated/discovery-analytics.js +0 -345
  150. package/tools/_deprecated/discovery-auto-suggest.js +0 -275
  151. package/tools/_deprecated/discovery-bootstrap.js +0 -267
  152. package/tools/_deprecated/discovery-daily.js +0 -375
  153. package/tools/_deprecated/discovery-dashboard.js +0 -385
  154. package/tools/_deprecated/discovery-digest.js +0 -314
  155. package/tools/_deprecated/discovery-hub.js +0 -357
  156. package/tools/_deprecated/discovery-insights.js +0 -384
  157. package/tools/_deprecated/discovery-momentum.js +0 -281
  158. package/tools/_deprecated/discovery-monitor.js +0 -319
  159. package/tools/_deprecated/discovery-proactive.js +0 -300
  160. package/tools/_deprecated/draw.js +0 -317
  161. package/tools/_deprecated/farcaster.js +0 -307
  162. package/tools/_deprecated/games-catalog.js +0 -376
  163. package/tools/_deprecated/games.js +0 -313
  164. package/tools/_deprecated/guessnumber.js +0 -194
  165. package/tools/_deprecated/hangman.js +0 -129
  166. package/tools/_deprecated/multiplayer-tictactoe.js +0 -303
  167. package/tools/_deprecated/riddle.js +0 -240
  168. package/tools/_deprecated/run-bootstrap.js +0 -69
  169. package/tools/_deprecated/skills-analytics.js +0 -349
  170. package/tools/_deprecated/skills-bootstrap.js +0 -301
  171. package/tools/_deprecated/skills-dashboard.js +0 -268
  172. package/tools/_deprecated/skills.js +0 -380
  173. package/tools/_deprecated/smart-intro.js +0 -353
  174. package/tools/_deprecated/storybuilder.js +0 -331
  175. package/tools/_deprecated/telegram-bot.js +0 -183
  176. package/tools/_deprecated/telegram-setup.js +0 -214
  177. package/tools/_deprecated/twentyquestions.js +0 -143
  178. package/tools/_shared.js +0 -234
  179. package/tools/_work-context.js +0 -338
  180. package/tools/_work-context.manual-test.js +0 -199
  181. package/tools/_work-context.test.js +0 -260
  182. package/tools/activity.js +0 -220
  183. package/tools/agent-treasury.js +0 -288
  184. package/tools/analytics.js +0 -191
  185. package/tools/approve.js +0 -197
  186. package/tools/arcade.js +0 -173
  187. package/tools/artifacts-price.js +0 -107
  188. package/tools/ask-expert.js +0 -160
  189. package/tools/available.js +0 -120
  190. package/tools/become-expert.js +0 -150
  191. package/tools/broadcast.js +0 -325
  192. package/tools/chat.js +0 -202
  193. package/tools/collaborative-drawing.js +0 -286
  194. package/tools/connection-status.js +0 -178
  195. package/tools/earnings.js +0 -126
  196. package/tools/friends.js +0 -207
  197. package/tools/genesis.js +0 -233
  198. package/tools/gig-browse.js +0 -206
  199. package/tools/gig-complete.js +0 -144
  200. package/tools/health.js +0 -87
  201. package/tools/leaderboard.js +0 -117
  202. package/tools/lib/git-apply.js +0 -206
  203. package/tools/lib/git-bundle.js +0 -407
  204. package/tools/mint.js +0 -377
  205. package/tools/plan.js +0 -225
  206. package/tools/profile.js +0 -219
  207. package/tools/proof-of-work.js +0 -144
  208. package/tools/pulse.js +0 -218
  209. package/tools/reply.js +0 -166
  210. package/tools/reputation.js +0 -175
  211. package/tools/schedule.js +0 -367
  212. package/tools/search-messages.js +0 -123
  213. package/tools/session.js +0 -467
  214. package/tools/session_price.js +0 -128
  215. package/tools/smart-check.js +0 -201
  216. package/tools/social-processor.js +0 -445
  217. package/tools/streak.js +0 -147
  218. package/tools/stuck.js +0 -297
  219. package/tools/subscribe.js +0 -148
  220. package/tools/subscriptions.js +0 -134
  221. package/tools/tip.js +0 -193
  222. package/tools/wallet.js +0 -269
  223. package/tools/webhook-test.js +0 -388
  224. package/tools/withdraw.js +0 -145
  225. package/tools/work-summary.js +0 -96
  226. package/tools/workshop.js +0 -327
  227. /package/tools/{l2-bridge.js → _experimental/l2-bridge.js} +0 -0
  228. /package/tools/{l2.js → _experimental/l2.js} +0 -0
  229. /package/tools/{_deprecated/away.js → away.js} +0 -0
package/tools/reply.js DELETED
@@ -1,166 +0,0 @@
1
- /**
2
- * vibe reply — Quick reply to the most recent unread message
3
- *
4
- * Streamlined flow: one command instead of inbox → open → dm
5
- */
6
-
7
- const config = require('../config');
8
- const store = require('../store');
9
- const patterns = require('../intelligence/patterns');
10
- const userProfiles = require('../store/profiles');
11
- const { trackMessage } = require('./summarize');
12
- const { requireInit, normalizeHandle, truncate, warning, fetchRelevantUsers } = require('./_shared');
13
- const { actions, formatActions } = require('./_actions');
14
-
15
- const definition = {
16
- name: 'vibe_reply',
17
- description: 'Quick reply to your most recent unread message, or to a specific person. Streamlined: one command instead of inbox → open → dm.',
18
- inputSchema: {
19
- type: 'object',
20
- properties: {
21
- message: {
22
- type: 'string',
23
- description: 'Your reply message'
24
- },
25
- to: {
26
- type: 'string',
27
- description: 'Optional: reply to a specific person (e.g., @alex). If not provided, replies to most recent unread.'
28
- }
29
- },
30
- required: ['message']
31
- }
32
- };
33
-
34
- async function handler(args) {
35
- const initCheck = requireInit();
36
- if (initCheck) return initCheck;
37
-
38
- const { message, to } = args;
39
- const myHandle = config.getHandle();
40
-
41
- if (!message || message.trim().length === 0) {
42
- return { display: 'Need a message to reply with.' };
43
- }
44
-
45
- let targetHandle;
46
- let threadContext = null;
47
-
48
- // If specific recipient provided, use that
49
- if (to) {
50
- targetHandle = normalizeHandle(to);
51
- } else {
52
- // Find most recent unread thread
53
- const threads = await store.getInbox(myHandle);
54
-
55
- if (!threads || threads.length === 0) {
56
- return {
57
- display: '📭 No messages to reply to.\n\nUse `vibe dm @someone "message"` to start a conversation.',
58
- actions: formatActions(actions.recommendedConnections([]))
59
- };
60
- }
61
-
62
- // Find first thread with unread messages
63
- const unreadThread = threads.find(t => t.unread > 0);
64
-
65
- if (!unreadThread) {
66
- // No unread, show most recent thread
67
- const mostRecent = threads[0];
68
- return {
69
- display: `📭 All caught up! Most recent: @${mostRecent.handle}\n\nUse \`vibe reply "message" --to @${mostRecent.handle}\` to continue that conversation.`,
70
- actions: formatActions(actions.afterInboxCompact([{ handle: mostRecent.handle, unread: 0 }]))
71
- };
72
- }
73
-
74
- targetHandle = unreadThread.handle;
75
- threadContext = {
76
- unreadCount: unreadThread.unread,
77
- preview: unreadThread.lastMessage ? truncate(unreadThread.lastMessage, 50) : null
78
- };
79
- }
80
-
81
- // Can't reply to yourself
82
- if (targetHandle === myHandle) {
83
- return { display: 'You can\'t DM yourself.' };
84
- }
85
-
86
- // Route @echo messages to the echo agent
87
- if (targetHandle === 'echo') {
88
- const echo = require('./echo');
89
- return echo.handler({ message, anonymous: false });
90
- }
91
-
92
- // Truncate message if too long
93
- const MAX_LENGTH = 2000;
94
- const trimmed = message.trim();
95
- const wasTruncated = trimmed.length > MAX_LENGTH;
96
- const finalMessage = wasTruncated ? trimmed.substring(0, MAX_LENGTH) : trimmed;
97
-
98
- // Send typing indicator (shows "typing..." to recipient)
99
- store.sendTypingIndicator(myHandle, targetHandle).catch(() => {});
100
-
101
- // Send the message
102
- const result = await store.sendMessage(myHandle, targetHandle, finalMessage, 'dm', null);
103
-
104
- // Check for errors
105
- if (result && result.error) {
106
- return {
107
- display: `❌ **Failed to send reply**\n\n${result.message}\n\n_Please try again._`
108
- };
109
- }
110
-
111
- // Mark the thread as read since we're replying
112
- try {
113
- await store.markThreadRead(myHandle, targetHandle);
114
- } catch (e) {
115
- // Non-fatal - continue
116
- console.warn('[reply] Failed to mark thread as read:', e.message);
117
- }
118
-
119
- // Log social pattern
120
- patterns.logMessageSent(targetHandle);
121
-
122
- // Record connection if first time
123
- try {
124
- const hasConnected = await userProfiles.hasBeenConnected(myHandle, targetHandle);
125
- if (!hasConnected) {
126
- await userProfiles.recordConnection(myHandle, targetHandle, 'first_message');
127
- }
128
- } catch (e) {
129
- console.warn('[reply] Failed to update profile connection:', e);
130
- }
131
-
132
- // Track for session summary
133
- trackMessage(myHandle, targetHandle, 'sent');
134
-
135
- // Build response
136
- let display = `✓ Replied to **@${targetHandle}**`;
137
-
138
- if (wasTruncated) {
139
- display += ` ${warning(`truncated to ${MAX_LENGTH} chars`)}`;
140
- }
141
-
142
- if (threadContext) {
143
- display += `\n\n_${threadContext.unreadCount} message${threadContext.unreadCount > 1 ? 's' : ''} marked as read_`;
144
- }
145
-
146
- // Check for more unread
147
- const remainingThreads = await store.getInbox(myHandle);
148
- const stillUnread = remainingThreads.filter(t => t.unread > 0 && t.handle !== targetHandle);
149
-
150
- if (stillUnread.length > 0) {
151
- const nextHandle = stillUnread[0].handle;
152
- const totalUnread = stillUnread.reduce((sum, t) => sum + t.unread, 0);
153
- display += `\n\n📬 ${totalUnread} more unread from ${stillUnread.map(t => `@${t.handle}`).slice(0, 3).join(', ')}`;
154
- display += `\n_Say \`vibe reply "message"\` to reply to @${nextHandle}_`;
155
- }
156
-
157
- // Build response with actions
158
- const response = { display };
159
-
160
- // Suggest follow-up actions
161
- response.actions = formatActions(actions.afterDm(targetHandle));
162
-
163
- return response;
164
- }
165
-
166
- module.exports = { definition, handler };
@@ -1,175 +0,0 @@
1
- /**
2
- * vibe_reputation - Check your reputation score and tier
3
- *
4
- * View your standing in the /vibe social hierarchy
5
- *
6
- * Examples:
7
- * - "vibe reputation"
8
- * - "check my tier"
9
- * - "show my badges"
10
- * - "vibe rep leaderboard"
11
- */
12
-
13
- const fetch = require('node-fetch');
14
-
15
- module.exports = {
16
- name: 'vibe_reputation',
17
- description: 'Check your reputation score, tier, badges, and ranking. Shows economic, social, expert, and creator scores.',
18
-
19
- inputSchema: {
20
- type: 'object',
21
- properties: {
22
- action: {
23
- type: 'string',
24
- enum: ['score', 'leaderboard'],
25
- description: 'Action: score (your stats) or leaderboard (top users)',
26
- default: 'score'
27
- },
28
- dimension: {
29
- type: 'string',
30
- enum: ['overall', 'economic', 'social', 'expert', 'creator'],
31
- description: 'Leaderboard dimension (only for leaderboard action)',
32
- default: 'overall'
33
- },
34
- limit: {
35
- type: 'number',
36
- description: 'Number of users to show in leaderboard (default 10)',
37
- default: 10
38
- }
39
- }
40
- },
41
-
42
- async execute({ action = 'score', dimension = 'overall', limit = 10 }, context) {
43
- try {
44
- const handle = context.handle;
45
-
46
- if (!handle) {
47
- return {
48
- success: false,
49
- error: 'Not authenticated. Use vibe init first.'
50
- };
51
- }
52
-
53
- const apiUrl = process.env.VIBE_API_URL || 'https://www.slashvibe.dev';
54
-
55
- if (action === 'score') {
56
- const response = await fetch(
57
- `${apiUrl}/api/reputation/score?handle=${handle}`,
58
- {
59
- headers: {
60
- 'Authorization': `Bearer ${context.token}`
61
- }
62
- }
63
- );
64
-
65
- const result = await response.json();
66
-
67
- if (!response.ok) {
68
- return {
69
- success: false,
70
- error: result.error || 'Failed to fetch reputation',
71
- message: result.message
72
- };
73
- }
74
-
75
- const tierIcons = {
76
- genesis: '🌱',
77
- bronze: '🥉',
78
- silver: '🥈',
79
- gold: '🥇',
80
- platinum: '💎',
81
- diamond: '👑'
82
- };
83
-
84
- const progressBar = '█'.repeat(Math.floor(result.progress_to_next * 20)) +
85
- '░'.repeat(20 - Math.floor(result.progress_to_next * 20));
86
-
87
- const badgeList = result.badges?.slice(0, 5).map(b =>
88
- ` ${b.icon || '🏆'} ${b.name} (${b.rarity})`
89
- ) || [];
90
-
91
- return {
92
- success: true,
93
- reputation: result,
94
- formatted: `
95
- ⭐ Reputation: ${handle}
96
-
97
- Tier: ${tierIcons[result.tier] || ''} ${result.tier.toUpperCase()}
98
- Overall Score: ${result.overall_score}
99
- Global Rank: #${result.rank} (top ${result.percentile.toFixed(1)}%)
100
-
101
- Dimension Scores:
102
- 💰 Economic: ${result.scores.economic}
103
- 👥 Social: ${result.scores.social}
104
- 🎓 Expert: ${result.scores.expert}
105
- 🎨 Creator: ${result.scores.creator}
106
-
107
- Progress to ${result.next_tier?.toUpperCase() || 'MAX'}:
108
- [${progressBar}] ${(result.progress_to_next * 100).toFixed(1)}%
109
- ${result.points_needed > 0 ? `${result.points_needed} points needed` : 'Max tier reached!'}
110
-
111
- Badges (${result.badges?.length || 0}):
112
- ${badgeList.length > 0 ? badgeList.join('\n') : ' No badges yet'}
113
-
114
- Tier Unlocks:
115
- ${JSON.stringify(result.tier_unlocks, null, 2).replace(/[{}"]/g, '').trim()}
116
- `.trim()
117
- };
118
-
119
- } else if (action === 'leaderboard') {
120
- const response = await fetch(
121
- `${apiUrl}/api/reputation/leaderboard?dimension=${dimension}&limit=${Math.min(limit, 50)}`,
122
- {
123
- headers: {
124
- 'Authorization': `Bearer ${context.token}`
125
- }
126
- }
127
- );
128
-
129
- const result = await response.json();
130
-
131
- if (!response.ok) {
132
- return {
133
- success: false,
134
- error: 'Failed to fetch leaderboard'
135
- };
136
- }
137
-
138
- const tierIcons = {
139
- genesis: '🌱',
140
- bronze: '🥉',
141
- silver: '🥈',
142
- gold: '🥇',
143
- platinum: '💎',
144
- diamond: '👑'
145
- };
146
-
147
- const leaderboardLines = result.leaderboard?.map(user => {
148
- const tier = tierIcons[user.tier] || '';
149
- const scoreField = dimension === 'overall' ? user.overall_score : user.score;
150
- return ` ${user.rank}. ${user.handle.padEnd(15)} ${scoreField.toString().padStart(5)} ${tier} ${user.tier}`;
151
- }) || [];
152
-
153
- return {
154
- success: true,
155
- leaderboard: result.leaderboard,
156
- formatted: `
157
- 🏆 Reputation Leaderboard (${dimension})
158
-
159
- ${leaderboardLines.join('\n')}
160
-
161
- Dimension: ${dimension}
162
- Total users: ${result.leaderboard?.length || 0}
163
- `.trim()
164
- };
165
- }
166
-
167
- } catch (error) {
168
- return {
169
- success: false,
170
- error: 'Failed to fetch reputation',
171
- details: error.message
172
- };
173
- }
174
- }
175
- };
package/tools/schedule.js DELETED
@@ -1,367 +0,0 @@
1
- /**
2
- * vibe schedule — Schedule and manage upcoming sessions
3
- *
4
- * Commands:
5
- * - schedule "title" --time "tomorrow 3pm" → Schedule a session
6
- * - schedule list → Your scheduled sessions
7
- * - schedule browse → All upcoming sessions
8
- * - schedule rsvp <id> → RSVP to a session
9
- * - schedule cancel <id> → Cancel your session
10
- * - schedule myrsvps → Sessions you've RSVP'd to
11
- */
12
-
13
- const config = require('../config');
14
- const { requireInit } = require('./_shared');
15
-
16
- const definition = {
17
- name: 'vibe_schedule',
18
- description: 'Schedule upcoming broadcast sessions. RSVP to sessions to get notified when they go live.',
19
- inputSchema: {
20
- type: 'object',
21
- properties: {
22
- action: {
23
- type: 'string',
24
- enum: ['create', 'list', 'browse', 'rsvp', 'cancel', 'myrsvps'],
25
- description: 'Action: create, list, browse, rsvp, cancel, myrsvps'
26
- },
27
- title: {
28
- type: 'string',
29
- description: 'Session title (for create action)'
30
- },
31
- time: {
32
- type: 'string',
33
- description: 'When to schedule (e.g., "tomorrow 3pm", "2026-01-20T15:00:00Z")'
34
- },
35
- duration: {
36
- type: 'number',
37
- description: 'Estimated duration in minutes (default: 60)'
38
- },
39
- tags: {
40
- type: 'array',
41
- items: { type: 'string' },
42
- description: 'Tags for the session (e.g., ["mcp", "ai"])'
43
- },
44
- scheduleId: {
45
- type: 'string',
46
- description: 'Schedule ID (for rsvp/cancel actions)'
47
- }
48
- }
49
- }
50
- };
51
-
52
- async function handler(args) {
53
- const initCheck = requireInit();
54
- if (initCheck) return initCheck;
55
-
56
- const myHandle = config.getHandle();
57
- const apiUrl = config.getApiUrl();
58
- const action = args.action || 'browse';
59
-
60
- try {
61
- // CREATE — Schedule a new session
62
- if (action === 'create') {
63
- if (!args.title) {
64
- return { display: '⚠️ Please provide a title: `vibe schedule create "Building X" --time "tomorrow 3pm"`' };
65
- }
66
-
67
- if (!args.time) {
68
- return { display: '⚠️ Please provide a time: `vibe schedule create "Building X" --time "tomorrow 3pm"`' };
69
- }
70
-
71
- // Parse time string
72
- const scheduledFor = parseTimeString(args.time);
73
- if (!scheduledFor) {
74
- return { display: '⚠️ Could not parse time. Try ISO format: `2026-01-20T15:00:00Z` or `tomorrow 3pm`' };
75
- }
76
-
77
- const response = await fetch(`${apiUrl}/api/sessions/schedule`, {
78
- method: 'POST',
79
- headers: { 'Content-Type': 'application/json' },
80
- body: JSON.stringify({
81
- handle: myHandle,
82
- title: args.title,
83
- scheduledFor: scheduledFor.toISOString(),
84
- duration: args.duration || 60,
85
- tags: args.tags || []
86
- })
87
- });
88
-
89
- const data = await response.json();
90
-
91
- if (!data.success) {
92
- return { display: `⚠️ ${data.error}` };
93
- }
94
-
95
- const schedule = data.schedule;
96
- const dateStr = formatScheduleTime(schedule.scheduledFor);
97
-
98
- let display = `## 📅 Session Scheduled!\n\n`;
99
- display += `**${schedule.title}**\n`;
100
- display += `📆 ${dateStr}\n`;
101
- display += `⏱️ ~${schedule.duration} minutes\n\n`;
102
- display += `**Share URL:**\n${schedule.shareUrl}\n\n`;
103
- display += `Your followers will be notified.\n\n`;
104
- display += `---\n`;
105
- display += `_When it's time, use \`vibe broadcast start\` to go live._`;
106
-
107
- return { display };
108
- }
109
-
110
- // LIST — My scheduled sessions
111
- if (action === 'list') {
112
- const response = await fetch(`${apiUrl}/api/sessions/schedule?handle=${myHandle}`);
113
- const data = await response.json();
114
-
115
- if (!data.success) {
116
- return { display: `⚠️ ${data.error}` };
117
- }
118
-
119
- if (data.schedules.length === 0) {
120
- let display = `## My Scheduled Sessions\n\n`;
121
- display += `_No upcoming sessions scheduled._\n\n`;
122
- display += `**Schedule one:**\n`;
123
- display += `\`vibe schedule create "Topic" --time "tomorrow 3pm"\``;
124
- return { display };
125
- }
126
-
127
- let display = `## My Scheduled Sessions\n\n`;
128
-
129
- for (const schedule of data.schedules) {
130
- const dateStr = formatScheduleTime(schedule.scheduledFor);
131
- display += `**${schedule.title}**\n`;
132
- display += `📆 ${dateStr}`;
133
- if (schedule.rsvpCount > 0) {
134
- display += ` · 🎟️ ${schedule.rsvpCount} RSVPs`;
135
- }
136
- display += `\n`;
137
- display += `ID: \`${schedule.id}\`\n\n`;
138
- }
139
-
140
- display += `---\n`;
141
- display += `_Cancel: \`vibe schedule cancel <id>\`_`;
142
-
143
- return { display };
144
- }
145
-
146
- // BROWSE — All upcoming sessions
147
- if (action === 'browse') {
148
- const response = await fetch(`${apiUrl}/api/sessions/schedule`);
149
- const data = await response.json();
150
-
151
- if (!data.success) {
152
- return { display: `⚠️ ${data.error}` };
153
- }
154
-
155
- if (data.schedules.length === 0) {
156
- let display = `## Upcoming Sessions\n\n`;
157
- display += `_No sessions scheduled yet._\n\n`;
158
- display += `**Be the first:**\n`;
159
- display += `\`vibe schedule create "Topic" --time "tomorrow 3pm"\``;
160
- return { display };
161
- }
162
-
163
- let display = `## 📅 Upcoming Sessions\n\n`;
164
-
165
- for (const schedule of data.schedules) {
166
- const dateStr = formatScheduleTime(schedule.scheduledFor);
167
- display += `**${schedule.title}**\n`;
168
- display += `@${schedule.handle} · ${dateStr}`;
169
- if (schedule.rsvpCount > 0) {
170
- display += ` · 🎟️ ${schedule.rsvpCount}`;
171
- }
172
- display += `\n`;
173
- if (schedule.tags && schedule.tags.length > 0) {
174
- display += `🏷️ ${schedule.tags.join(', ')}\n`;
175
- }
176
- display += `\`vibe schedule rsvp ${schedule.id}\`\n\n`;
177
- }
178
-
179
- return { display };
180
- }
181
-
182
- // RSVP — RSVP to a session
183
- if (action === 'rsvp') {
184
- if (!args.scheduleId) {
185
- return { display: '⚠️ Please provide a schedule ID: `vibe schedule rsvp sched_xxx`' };
186
- }
187
-
188
- const response = await fetch(`${apiUrl}/api/sessions/rsvp`, {
189
- method: 'POST',
190
- headers: { 'Content-Type': 'application/json' },
191
- body: JSON.stringify({
192
- scheduleId: args.scheduleId,
193
- handle: myHandle
194
- })
195
- });
196
-
197
- const data = await response.json();
198
-
199
- if (!data.success) {
200
- return { display: `⚠️ ${data.error}` };
201
- }
202
-
203
- let display = `## 🎟️ RSVP Confirmed!\n\n`;
204
- if (data.schedule) {
205
- display += `**${data.schedule.title}**\n`;
206
- display += `@${data.schedule.handle}\n`;
207
- display += `📆 ${formatScheduleTime(data.schedule.scheduledFor)}\n\n`;
208
- }
209
- display += `You'll be notified when they go live.\n\n`;
210
- display += `_${data.rsvpCount} people attending_`;
211
-
212
- return { display };
213
- }
214
-
215
- // CANCEL — Cancel my session
216
- if (action === 'cancel') {
217
- if (!args.scheduleId) {
218
- return { display: '⚠️ Please provide a schedule ID: `vibe schedule cancel sched_xxx`' };
219
- }
220
-
221
- const response = await fetch(`${apiUrl}/api/sessions/schedule`, {
222
- method: 'DELETE',
223
- headers: { 'Content-Type': 'application/json' },
224
- body: JSON.stringify({
225
- id: args.scheduleId,
226
- handle: myHandle
227
- })
228
- });
229
-
230
- const data = await response.json();
231
-
232
- if (!data.success) {
233
- return { display: `⚠️ ${data.error}` };
234
- }
235
-
236
- return { display: `✅ Session cancelled. RSVPs have been notified.` };
237
- }
238
-
239
- // MYRSVPS — Sessions I've RSVP'd to
240
- if (action === 'myrsvps') {
241
- const response = await fetch(`${apiUrl}/api/sessions/rsvp?handle=${myHandle}`);
242
- const data = await response.json();
243
-
244
- if (!data.success) {
245
- return { display: `⚠️ ${data.error}` };
246
- }
247
-
248
- if (data.rsvps.length === 0) {
249
- let display = `## My RSVPs\n\n`;
250
- display += `_You haven't RSVP'd to any sessions._\n\n`;
251
- display += `**Browse upcoming:**\n`;
252
- display += `\`vibe schedule browse\``;
253
- return { display };
254
- }
255
-
256
- let display = `## 🎟️ My RSVPs\n\n`;
257
-
258
- for (const schedule of data.rsvps) {
259
- const dateStr = formatScheduleTime(schedule.scheduledFor);
260
- display += `**${schedule.title}**\n`;
261
- display += `@${schedule.handle} · ${dateStr}\n\n`;
262
- }
263
-
264
- display += `_You'll be notified when these sessions go live._`;
265
-
266
- return { display };
267
- }
268
-
269
- return { display: 'Unknown action. Use: create, list, browse, rsvp, cancel, myrsvps' };
270
-
271
- } catch (error) {
272
- return { display: `## Error\n\n${error.message}` };
273
- }
274
- }
275
-
276
- /**
277
- * Parse natural language time strings
278
- */
279
- function parseTimeString(timeStr) {
280
- // Try ISO format first
281
- const isoDate = new Date(timeStr);
282
- if (!isNaN(isoDate.getTime())) {
283
- return isoDate;
284
- }
285
-
286
- const now = new Date();
287
- const lower = timeStr.toLowerCase();
288
-
289
- // "tomorrow 3pm", "tomorrow at 3pm"
290
- if (lower.includes('tomorrow')) {
291
- const tomorrow = new Date(now);
292
- tomorrow.setDate(tomorrow.getDate() + 1);
293
-
294
- const timeMatch = lower.match(/(\d{1,2})(?::(\d{2}))?\s*(am|pm)?/i);
295
- if (timeMatch) {
296
- let hours = parseInt(timeMatch[1]);
297
- const mins = parseInt(timeMatch[2]) || 0;
298
- const ampm = timeMatch[3]?.toLowerCase();
299
-
300
- if (ampm === 'pm' && hours < 12) hours += 12;
301
- if (ampm === 'am' && hours === 12) hours = 0;
302
-
303
- tomorrow.setHours(hours, mins, 0, 0);
304
- return tomorrow;
305
- }
306
-
307
- // Default to noon
308
- tomorrow.setHours(12, 0, 0, 0);
309
- return tomorrow;
310
- }
311
-
312
- // "in 2 hours"
313
- const inHoursMatch = lower.match(/in\s+(\d+)\s+hours?/);
314
- if (inHoursMatch) {
315
- const hours = parseInt(inHoursMatch[1]);
316
- return new Date(now.getTime() + hours * 60 * 60 * 1000);
317
- }
318
-
319
- // "next monday 3pm"
320
- const dayNames = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'];
321
- for (let i = 0; i < dayNames.length; i++) {
322
- if (lower.includes(dayNames[i])) {
323
- const targetDay = i;
324
- const currentDay = now.getDay();
325
- let daysUntil = targetDay - currentDay;
326
- if (daysUntil <= 0) daysUntil += 7;
327
-
328
- const targetDate = new Date(now);
329
- targetDate.setDate(targetDate.getDate() + daysUntil);
330
-
331
- const timeMatch = lower.match(/(\d{1,2})(?::(\d{2}))?\s*(am|pm)?/i);
332
- if (timeMatch) {
333
- let hours = parseInt(timeMatch[1]);
334
- const mins = parseInt(timeMatch[2]) || 0;
335
- const ampm = timeMatch[3]?.toLowerCase();
336
-
337
- if (ampm === 'pm' && hours < 12) hours += 12;
338
- if (ampm === 'am' && hours === 12) hours = 0;
339
-
340
- targetDate.setHours(hours, mins, 0, 0);
341
- } else {
342
- targetDate.setHours(12, 0, 0, 0);
343
- }
344
-
345
- return targetDate;
346
- }
347
- }
348
-
349
- return null;
350
- }
351
-
352
- /**
353
- * Format schedule time for display
354
- */
355
- function formatScheduleTime(isoString) {
356
- const date = new Date(isoString);
357
- return date.toLocaleDateString('en-US', {
358
- weekday: 'short',
359
- month: 'short',
360
- day: 'numeric',
361
- hour: 'numeric',
362
- minute: '2-digit',
363
- timeZoneName: 'short'
364
- });
365
- }
366
-
367
- module.exports = { definition, handler };