slashvibe-mcp 0.2.2 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. package/README.md +1 -0
  2. package/analytics.js +107 -0
  3. package/config.js +174 -3
  4. package/index.js +163 -34
  5. package/intelligence/index.js +45 -0
  6. package/intelligence/infer.js +316 -0
  7. package/intelligence/interests.js +369 -0
  8. package/intelligence/patterns.js +651 -0
  9. package/intelligence/proactive.js +358 -0
  10. package/intelligence/serendipity.js +306 -0
  11. package/notification-emitter.js +77 -0
  12. package/notify.js +141 -18
  13. package/package.json +14 -6
  14. package/presence.js +5 -1
  15. package/protocol/index.js +88 -1
  16. package/protocol/telegram-commands.js +199 -0
  17. package/store/api.js +469 -29
  18. package/store/index.js +7 -7
  19. package/store/local.js +67 -11
  20. package/store/profiles.js +435 -0
  21. package/store/reservations.js +321 -0
  22. package/store/skills.js +378 -0
  23. package/tools/_actions.js +491 -22
  24. package/tools/_connection-queue.js +257 -0
  25. package/tools/_discovery-enhanced.js +290 -0
  26. package/tools/_discovery.js +439 -0
  27. package/tools/_proactive-discovery.js +301 -0
  28. package/tools/_shared/index.js +64 -0
  29. package/tools/_work-context.js +338 -0
  30. package/tools/_work-context.manual-test.js +199 -0
  31. package/tools/_work-context.test.js +260 -0
  32. package/tools/admin-inbox.js +218 -0
  33. package/tools/agent-treasury.js +288 -0
  34. package/tools/agents.js +122 -0
  35. package/tools/analytics.js +191 -0
  36. package/tools/approve.js +197 -0
  37. package/tools/arcade.js +173 -0
  38. package/tools/artifact-create.js +247 -0
  39. package/tools/artifact-view.js +174 -0
  40. package/tools/artifacts-price.js +107 -0
  41. package/tools/ask-expert.js +160 -0
  42. package/tools/auto-suggest-connections.js +304 -0
  43. package/tools/away.js +68 -0
  44. package/tools/back.js +51 -0
  45. package/tools/become-expert.js +150 -0
  46. package/tools/bootstrap-skills.js +231 -0
  47. package/tools/bridge-dashboard.js +342 -0
  48. package/tools/bridge-health.js +400 -0
  49. package/tools/bridge-live.js +384 -0
  50. package/tools/bridges.js +383 -0
  51. package/tools/broadcast.js +286 -0
  52. package/tools/bye.js +4 -0
  53. package/tools/chat.js +202 -0
  54. package/tools/collaborative-drawing.js +286 -0
  55. package/tools/colorguess.js +281 -0
  56. package/tools/crossword.js +369 -0
  57. package/tools/discover-insights.js +379 -0
  58. package/tools/discover-momentum.js +256 -0
  59. package/tools/discover.js +675 -0
  60. package/tools/discovery-analytics.js +345 -0
  61. package/tools/discovery-auto-suggest.js +275 -0
  62. package/tools/discovery-bootstrap.js +267 -0
  63. package/tools/discovery-daily.js +375 -0
  64. package/tools/discovery-dashboard.js +385 -0
  65. package/tools/discovery-digest.js +314 -0
  66. package/tools/discovery-hub.js +357 -0
  67. package/tools/discovery-insights.js +384 -0
  68. package/tools/discovery-momentum.js +281 -0
  69. package/tools/discovery-monitor.js +319 -0
  70. package/tools/discovery-proactive.js +300 -0
  71. package/tools/dm.js +84 -14
  72. package/tools/draw.js +317 -0
  73. package/tools/drawing.js +310 -0
  74. package/tools/earnings.js +126 -0
  75. package/tools/echo.js +16 -0
  76. package/tools/farcaster.js +307 -0
  77. package/tools/feed.js +215 -0
  78. package/tools/follow.js +224 -0
  79. package/tools/friends.js +192 -0
  80. package/tools/game.js +218 -110
  81. package/tools/games-catalog.js +376 -0
  82. package/tools/games.js +313 -0
  83. package/tools/genesis.js +233 -0
  84. package/tools/gig-browse.js +206 -0
  85. package/tools/gig-complete.js +139 -0
  86. package/tools/guessnumber.js +194 -0
  87. package/tools/hangman.js +129 -0
  88. package/tools/help.js +269 -0
  89. package/tools/idea.js +217 -0
  90. package/tools/inbox.js +291 -25
  91. package/tools/init.js +657 -33
  92. package/tools/insights.js +123 -0
  93. package/tools/invite.js +142 -21
  94. package/tools/l2-bridge.js +272 -0
  95. package/tools/l2-status.js +217 -0
  96. package/tools/l2.js +206 -0
  97. package/tools/migrate.js +156 -0
  98. package/tools/mint.js +377 -0
  99. package/tools/multiplayer-game.js +275 -0
  100. package/tools/multiplayer-tictactoe.js +303 -0
  101. package/tools/mute.js +97 -0
  102. package/tools/notifications.js +415 -0
  103. package/tools/observe.js +200 -0
  104. package/tools/onboarding.js +147 -0
  105. package/tools/open.js +52 -3
  106. package/tools/party-game.js +314 -0
  107. package/tools/plan.js +225 -0
  108. package/tools/presence-agent.js +167 -0
  109. package/tools/profile.js +219 -0
  110. package/tools/proof-of-work.js +139 -0
  111. package/tools/pulse.js +218 -0
  112. package/tools/react.js +4 -0
  113. package/tools/release.js +83 -0
  114. package/tools/report.js +109 -0
  115. package/tools/reputation.js +175 -0
  116. package/tools/request.js +231 -0
  117. package/tools/reservations.js +116 -0
  118. package/tools/reserve.js +111 -0
  119. package/tools/riddle.js +240 -0
  120. package/tools/run-bootstrap.js +69 -0
  121. package/tools/schedule.js +367 -0
  122. package/tools/session.js +420 -0
  123. package/tools/session_price.js +128 -0
  124. package/tools/settings.js +200 -0
  125. package/tools/ship.js +188 -0
  126. package/tools/shipback.js +326 -0
  127. package/tools/skills-analytics.js +349 -0
  128. package/tools/skills-bootstrap.js +301 -0
  129. package/tools/skills-dashboard.js +268 -0
  130. package/tools/skills-exchange.js +342 -0
  131. package/tools/skills.js +380 -0
  132. package/tools/smart-intro.js +353 -0
  133. package/tools/social-inbox.js +326 -69
  134. package/tools/social-post.js +251 -66
  135. package/tools/social-processor.js +445 -0
  136. package/tools/solo-game.js +390 -0
  137. package/tools/start.js +296 -81
  138. package/tools/status.js +53 -6
  139. package/tools/storybuilder.js +331 -0
  140. package/tools/stuck.js +297 -0
  141. package/tools/subscribe.js +148 -0
  142. package/tools/subscriptions.js +134 -0
  143. package/tools/suggest-tags.js +184 -0
  144. package/tools/tag-suggestions.js +257 -0
  145. package/tools/telegram-bot.js +183 -0
  146. package/tools/telegram-setup.js +214 -0
  147. package/tools/tictactoe.js +155 -0
  148. package/tools/tip.js +120 -0
  149. package/tools/token.js +103 -0
  150. package/tools/twentyquestions.js +143 -0
  151. package/tools/update.js +1 -1
  152. package/tools/wallet.js +127 -0
  153. package/tools/watch.js +157 -0
  154. package/tools/webhook-test.js +388 -0
  155. package/tools/who.js +118 -25
  156. package/tools/withdraw.js +145 -0
  157. package/tools/wordassociation.js +247 -0
  158. package/tools/work-summary.js +96 -0
  159. package/tools/workshop-buddy.js +394 -0
  160. package/tools/workshop.js +327 -0
  161. package/version.json +12 -3
  162. package/tools/board.js +0 -130
@@ -0,0 +1,376 @@
1
+ /**
2
+ * vibe games — Discover and launch all available games on /vibe
3
+ *
4
+ * Your one-stop shop for finding fun! Browse all games, get recommendations,
5
+ * and quick-launch your favorites.
6
+ */
7
+
8
+ const config = require('../config');
9
+ const { requireInit } = require('./_shared');
10
+
11
+ const definition = {
12
+ name: 'vibe_games',
13
+ description: 'Discover all available games on /vibe. Browse catalog, get recommendations, quick-launch games.',
14
+ inputSchema: {
15
+ type: 'object',
16
+ properties: {
17
+ category: {
18
+ type: 'string',
19
+ description: 'Filter by game category',
20
+ enum: ['all', 'solo', 'multiplayer', 'collaborative', 'party', 'creative']
21
+ },
22
+ players: {
23
+ type: 'number',
24
+ description: 'Filter by number of players (1 for solo, 2+ for multiplayer)'
25
+ },
26
+ mood: {
27
+ type: 'string',
28
+ description: 'Get game recommendations based on your mood',
29
+ enum: ['competitive', 'creative', 'chill', 'brainy', 'social']
30
+ }
31
+ },
32
+ required: []
33
+ }
34
+ };
35
+
36
+ // Games catalog with all available games
37
+ const GAMES_CATALOG = {
38
+ // Solo Games
39
+ solo: [
40
+ {
41
+ name: '20 Questions',
42
+ command: 'vibe twenty-questions',
43
+ description: 'I think of something, you guess with yes/no questions',
44
+ emoji: 'ā“',
45
+ difficulty: 'medium',
46
+ playtime: '5-10 min',
47
+ tags: ['brainy', 'solo', 'guessing']
48
+ },
49
+ {
50
+ name: 'Riddles',
51
+ command: 'vibe riddle',
52
+ description: 'Challenge your mind with brain teasers across difficulty levels',
53
+ emoji: '🧩',
54
+ difficulty: 'varies',
55
+ playtime: '3-15 min',
56
+ tags: ['brainy', 'solo', 'puzzle']
57
+ },
58
+ {
59
+ name: 'Hangman',
60
+ command: 'vibe hangman',
61
+ description: 'Classic word guessing game - can you save the stick figure?',
62
+ emoji: 'šŸŽŖ',
63
+ difficulty: 'easy',
64
+ playtime: '5 min',
65
+ tags: ['casual', 'solo', 'word']
66
+ },
67
+ {
68
+ name: 'Number Guessing',
69
+ command: 'vibe guessnumber',
70
+ description: 'Guess my number between 1-100 with strategic hints',
71
+ emoji: 'šŸ”¢',
72
+ difficulty: 'easy',
73
+ playtime: '3-5 min',
74
+ tags: ['casual', 'solo', 'logic']
75
+ }
76
+ ],
77
+
78
+ // 1v1 Games
79
+ versus: [
80
+ {
81
+ name: 'Tic-Tac-Toe',
82
+ command: 'vibe game @friend',
83
+ description: 'Classic 3x3 grid strategy - get three in a row!',
84
+ emoji: 'ā­•',
85
+ players: 2,
86
+ difficulty: 'easy',
87
+ playtime: '2 min',
88
+ tags: ['competitive', '1v1', 'classic']
89
+ },
90
+ {
91
+ name: 'Chess',
92
+ command: 'vibe game @friend --game chess',
93
+ description: 'The timeless strategy game with full piece movement',
94
+ emoji: 'ā™Ÿļø',
95
+ players: 2,
96
+ difficulty: 'hard',
97
+ playtime: '10-60 min',
98
+ tags: ['competitive', '1v1', 'strategy']
99
+ },
100
+ {
101
+ name: 'Rock Paper Scissors',
102
+ command: 'vibe rockpaperscissors @friend',
103
+ description: 'Quick decision game of chance and psychology',
104
+ emoji: 'āœ‚ļø',
105
+ players: 2,
106
+ difficulty: 'easy',
107
+ playtime: '1 min',
108
+ tags: ['competitive', '1v1', 'quick']
109
+ }
110
+ ],
111
+
112
+ // Collaborative & Creative Games
113
+ collaborative: [
114
+ {
115
+ name: 'Collaborative Drawing',
116
+ command: 'vibe drawing --action start',
117
+ description: 'šŸŽØ Real-time shared canvas! Draw together with emojis and Unicode art',
118
+ emoji: 'šŸŽØ',
119
+ players: '1-8',
120
+ difficulty: 'easy',
121
+ playtime: '10-30 min',
122
+ tags: ['creative', 'collaborative', 'art', 'realtime']
123
+ },
124
+ {
125
+ name: 'Story Builder',
126
+ command: 'vibe story-builder --action create',
127
+ description: 'šŸ“– Build stories together! Each person adds one sentence',
128
+ emoji: 'šŸ“–',
129
+ players: '1-8',
130
+ difficulty: 'easy',
131
+ playtime: '15-30 min',
132
+ tags: ['creative', 'collaborative', 'writing', 'storytelling']
133
+ }
134
+ ],
135
+
136
+ // Multiplayer Party Games
137
+ party: [
138
+ {
139
+ name: 'Word Association',
140
+ command: 'vibe multiplayer-game wordassociation --action create',
141
+ description: 'Say words that relate to the previous word. Build themes together!',
142
+ emoji: 'šŸ’­',
143
+ players: '2-6',
144
+ difficulty: 'easy',
145
+ playtime: '10-20 min',
146
+ tags: ['social', 'party', 'word', 'creative']
147
+ },
148
+ {
149
+ name: 'Werewolf',
150
+ command: 'vibe werewolf --action create',
151
+ description: 'Social deduction party game - find the werewolves!',
152
+ emoji: '🐺',
153
+ players: '5-12',
154
+ difficulty: 'medium',
155
+ playtime: '20-45 min',
156
+ tags: ['social', 'party', 'deduction', 'strategy']
157
+ },
158
+ {
159
+ name: 'Two Truths and a Lie',
160
+ command: 'vibe twotruths',
161
+ description: 'Share facts about yourself - others guess which is the lie',
162
+ emoji: '🤄',
163
+ players: '3+',
164
+ difficulty: 'easy',
165
+ playtime: '10-20 min',
166
+ tags: ['social', 'party', 'icebreaker']
167
+ }
168
+ ]
169
+ };
170
+
171
+ // Mood-based game recommendations
172
+ const MOOD_RECOMMENDATIONS = {
173
+ competitive: ['Chess', 'Tic-Tac-Toe', 'Rock Paper Scissors', 'Werewolf'],
174
+ creative: ['Collaborative Drawing', 'Story Builder', 'Word Association'],
175
+ chill: ['20 Questions', 'Hangman', 'Number Guessing', 'Two Truths and a Lie'],
176
+ brainy: ['Riddles', '20 Questions', 'Chess', 'Werewolf'],
177
+ social: ['Word Association', 'Story Builder', 'Werewolf', 'Two Truths and a Lie', 'Collaborative Drawing']
178
+ };
179
+
180
+ // Quick stats about the game ecosystem
181
+ function getGameStats() {
182
+ const allGames = Object.values(GAMES_CATALOG).flat();
183
+ const totalGames = allGames.length;
184
+
185
+ const byCategory = {};
186
+ const byPlayers = { solo: 0, duo: 0, party: 0 };
187
+
188
+ Object.entries(GAMES_CATALOG).forEach(([category, games]) => {
189
+ byCategory[category] = games.length;
190
+ });
191
+
192
+ allGames.forEach(game => {
193
+ if (!game.players || game.players === 1) {
194
+ byPlayers.solo++;
195
+ } else if (game.players === 2) {
196
+ byPlayers.duo++;
197
+ } else {
198
+ byPlayers.party++;
199
+ }
200
+ });
201
+
202
+ return { totalGames, byCategory, byPlayers };
203
+ }
204
+
205
+ // Format games display
206
+ function formatGamesDisplay(games, title, showCommands = true) {
207
+ if (games.length === 0) {
208
+ return `**${title}**\nNo games found matching your criteria.`;
209
+ }
210
+
211
+ let display = `## ${title}\n\n`;
212
+
213
+ for (const game of games) {
214
+ display += `### ${game.emoji} ${game.name}\n`;
215
+ display += `${game.description}\n\n`;
216
+
217
+ // Game details
218
+ const details = [];
219
+ if (game.players) details.push(`šŸ‘„ ${game.players} players`);
220
+ if (game.difficulty) details.push(`šŸŽÆ ${game.difficulty}`);
221
+ if (game.playtime) details.push(`ā±ļø ${game.playtime}`);
222
+
223
+ if (details.length > 0) {
224
+ display += `**Details:** ${details.join(' • ')}\n`;
225
+ }
226
+
227
+ if (showCommands) {
228
+ display += `**Play:** \`${game.command}\`\n\n`;
229
+ } else {
230
+ display += '\n';
231
+ }
232
+ }
233
+
234
+ return display;
235
+ }
236
+
237
+ // Get games by category
238
+ function getGamesByCategory(category) {
239
+ if (category === 'all') {
240
+ return Object.values(GAMES_CATALOG).flat();
241
+ }
242
+
243
+ const categoryMap = {
244
+ 'solo': 'solo',
245
+ 'multiplayer': ['versus', 'party'],
246
+ 'collaborative': 'collaborative',
247
+ 'party': 'party',
248
+ 'creative': 'collaborative' // Alias for collaborative
249
+ };
250
+
251
+ const targetCategories = Array.isArray(categoryMap[category]) ?
252
+ categoryMap[category] : [categoryMap[category]];
253
+
254
+ const games = [];
255
+ for (const cat of targetCategories) {
256
+ if (GAMES_CATALOG[cat]) {
257
+ games.push(...GAMES_CATALOG[cat]);
258
+ }
259
+ }
260
+
261
+ return games;
262
+ }
263
+
264
+ // Get games by player count
265
+ function getGamesByPlayers(playerCount) {
266
+ const allGames = Object.values(GAMES_CATALOG).flat();
267
+
268
+ return allGames.filter(game => {
269
+ if (!game.players) return playerCount === 1; // Solo games
270
+
271
+ const players = game.players;
272
+
273
+ // Handle ranges like "2-6" or "3+"
274
+ if (typeof players === 'string') {
275
+ if (players.includes('-')) {
276
+ const [min, max] = players.split('-').map(n => parseInt(n));
277
+ return playerCount >= min && playerCount <= max;
278
+ } else if (players.includes('+')) {
279
+ const min = parseInt(players.replace('+', ''));
280
+ return playerCount >= min;
281
+ }
282
+ return parseInt(players) === playerCount;
283
+ }
284
+
285
+ return players === playerCount;
286
+ });
287
+ }
288
+
289
+ // Get mood-based recommendations
290
+ function getMoodRecommendations(mood) {
291
+ const gameNames = MOOD_RECOMMENDATIONS[mood] || [];
292
+ const allGames = Object.values(GAMES_CATALOG).flat();
293
+
294
+ return allGames.filter(game => gameNames.includes(game.name));
295
+ }
296
+
297
+ async function handler(args) {
298
+ const initCheck = requireInit();
299
+ if (initCheck) return initCheck;
300
+
301
+ const { category = 'all', players, mood } = args;
302
+
303
+ // Handle mood-based recommendations
304
+ if (mood) {
305
+ const games = getMoodRecommendations(mood);
306
+ const title = `šŸŽ® Games for ${mood.toUpperCase()} mood`;
307
+ return {
308
+ display: formatGamesDisplay(games, title)
309
+ };
310
+ }
311
+
312
+ // Handle player count filter
313
+ if (players) {
314
+ const games = getGamesByPlayers(players);
315
+ const title = `šŸŽ® Games for ${players} player${players !== 1 ? 's' : ''}`;
316
+ return {
317
+ display: formatGamesDisplay(games, title)
318
+ };
319
+ }
320
+
321
+ // Handle category filter
322
+ if (category && category !== 'all') {
323
+ const games = getGamesByCategory(category);
324
+ const title = `šŸŽ® ${category.toUpperCase()} Games`;
325
+ return {
326
+ display: formatGamesDisplay(games, title)
327
+ };
328
+ }
329
+
330
+ // Show full catalog (default)
331
+ const stats = getGameStats();
332
+
333
+ let display = `# šŸŽ® /vibe Games Catalog\n\n`;
334
+ display += `Welcome to the /vibe games arcade! We have **${stats.totalGames} games** across multiple categories.\n\n`;
335
+
336
+ // Quick stats
337
+ display += `**Quick Browse:**\n`;
338
+ display += `• šŸŽÆ \`vibe games --category solo\` - ${stats.byCategory.solo} solo games\n`;
339
+ display += `• āš”ļø \`vibe games --category versus\` - 1v1 competitive games\n`;
340
+ display += `• šŸŽØ \`vibe games --category collaborative\` - Create together\n`;
341
+ display += `• šŸŽ‰ \`vibe games --category party\` - Group fun\n\n`;
342
+
343
+ display += `**By Mood:**\n`;
344
+ display += `• šŸ† \`vibe games --mood competitive\` - Ready to win\n`;
345
+ display += `• šŸŽØ \`vibe games --mood creative\` - Make something cool\n`;
346
+ display += `• 😌 \`vibe games --mood chill\` - Relaxed fun\n`;
347
+ display += `• 🧠 \`vibe games --mood brainy\` - Mental challenge\n`;
348
+ display += `• šŸ‘„ \`vibe games --mood social\` - Connect with others\n\n`;
349
+
350
+ display += `**By Players:**\n`;
351
+ display += `• \`vibe games --players 1\` - Solo adventures\n`;
352
+ display += `• \`vibe games --players 2\` - Perfect for pairs\n`;
353
+ display += `• \`vibe games --players 4\` - Small group games\n\n`;
354
+
355
+ // Highlight featured games
356
+ display += `## ⭐ Featured Games\n\n`;
357
+
358
+ const featured = [
359
+ GAMES_CATALOG.collaborative[0], // Drawing
360
+ GAMES_CATALOG.party[0], // Word Association
361
+ GAMES_CATALOG.versus[1], // Chess
362
+ GAMES_CATALOG.solo[0] // 20 Questions
363
+ ];
364
+
365
+ for (const game of featured) {
366
+ display += `**${game.emoji} ${game.name}** - ${game.description}\n`;
367
+ display += `ā–ø \`${game.command}\`\n\n`;
368
+ }
369
+
370
+ display += `šŸ’” **Tip:** Many games work great for icebreakers, team building, or just having fun with friends!\n\n`;
371
+ display += `Use \`vibe games --category all\` to see the complete catalog with details.`;
372
+
373
+ return { display };
374
+ }
375
+
376
+ module.exports = { definition, handler };
package/tools/games.js ADDED
@@ -0,0 +1,313 @@
1
+ /**
2
+ * vibe games — Browse and launch workshop games
3
+ *
4
+ * Discover all available games, get recommendations, and launch games
5
+ */
6
+
7
+ const config = require('../config');
8
+ const store = require('../store');
9
+ const { createGamePayload, formatPayload } = require('../protocol');
10
+ const { requireInit, normalizeHandle } = require('./_shared');
11
+
12
+ // Import game systems
13
+ const arcade = require('../games/arcade');
14
+ const gamerouter = require('../games/gamerouter');
15
+
16
+ // Track active game sessions per user
17
+ const activeSessions = new Map();
18
+
19
+ const definition = {
20
+ name: 'vibe_games',
21
+ description: 'Browse and launch workshop games. Discover new games, get recommendations, or launch any game.',
22
+ inputSchema: {
23
+ type: 'object',
24
+ properties: {
25
+ action: {
26
+ type: 'string',
27
+ description: 'What to do: browse, launch, suggest, help, status',
28
+ enum: ['browse', 'launch', 'suggest', 'help', 'status', 'quit']
29
+ },
30
+ game: {
31
+ type: 'string',
32
+ description: 'Game to launch (e.g., hangman, wordchain, drawing)'
33
+ },
34
+ category: {
35
+ type: 'string',
36
+ description: 'Game category to browse (classic, word, puzzle, action, creative, social)'
37
+ },
38
+ difficulty: {
39
+ type: 'string',
40
+ description: 'Difficulty preference for suggestions (easy, medium, hard)',
41
+ enum: ['easy', 'medium', 'hard']
42
+ },
43
+ players: {
44
+ type: 'string',
45
+ description: 'Player preference for suggestions (solo, multiplayer)',
46
+ enum: ['solo', 'multiplayer']
47
+ },
48
+ command: {
49
+ type: 'string',
50
+ description: 'Command to send to active game'
51
+ }
52
+ },
53
+ required: []
54
+ }
55
+ };
56
+
57
+ // Get user session
58
+ function getUserSession(handle) {
59
+ if (!activeSessions.has(handle)) {
60
+ activeSessions.set(handle, {
61
+ currentGame: null,
62
+ gameState: null,
63
+ arcadeState: arcade.createInitialArcadeState(),
64
+ lastActivity: new Date().toISOString()
65
+ });
66
+ }
67
+ return activeSessions.get(handle);
68
+ }
69
+
70
+ // Clear user session
71
+ function clearUserSession(handle) {
72
+ activeSessions.delete(handle);
73
+ }
74
+
75
+ // Format game list for display
76
+ function formatGameList(games, title = 'Games') {
77
+ if (!games || games.length === 0) {
78
+ return `**${title}**\n*No games found.*`;
79
+ }
80
+
81
+ let display = `**${title}** (${games.length} games)\n\n`;
82
+
83
+ games.forEach(game => {
84
+ display += `${game.icon || 'šŸŽ®'} **${game.name}**\n`;
85
+ display += ` *${game.description}*\n`;
86
+ display += ` Players: ${game.players} • Difficulty: ${game.difficulty}\n\n`;
87
+ });
88
+
89
+ return display;
90
+ }
91
+
92
+ // Launch a specific game
93
+ function launchGame(session, gameId) {
94
+ // Check if game exists
95
+ if (!gamerouter.gameAvailable(gameId)) {
96
+ const availableGames = gamerouter.getAvailableGames();
97
+ return {
98
+ error: `Game '${gameId}' not found! Available games: ${availableGames.join(', ')}`
99
+ };
100
+ }
101
+
102
+ // Create game state
103
+ const result = gamerouter.createGameState(gameId);
104
+ if (result.error) {
105
+ return { error: result.error };
106
+ }
107
+
108
+ // Update session
109
+ session.currentGame = gameId;
110
+ session.gameState = result.gameState;
111
+ session.lastActivity = new Date().toISOString();
112
+
113
+ // Get display
114
+ const display = gamerouter.displayGame(gameId, result.gameState);
115
+ const instructions = gamerouter.getQuickStart(gameId);
116
+
117
+ return {
118
+ success: true,
119
+ display: display + '\n\nšŸ’” **Quick Start:** ' + instructions + '\n\n*Use `vibe games --command [action]` to play, or `vibe games --action quit` to exit.*'
120
+ };
121
+ }
122
+
123
+ // Handle game command
124
+ function handleGameCommand(session, command) {
125
+ if (!session.currentGame || !session.gameState) {
126
+ return { error: 'No active game. Use `vibe games --action launch --game [name]` to start a game.' };
127
+ }
128
+
129
+ const result = gamerouter.handleGameCommand(session.currentGame, session.gameState, command);
130
+ if (result.error) {
131
+ return { error: result.error };
132
+ }
133
+
134
+ // Update session
135
+ if (result.gameState) {
136
+ session.gameState = result.gameState;
137
+ session.lastActivity = new Date().toISOString();
138
+ }
139
+
140
+ // Format response
141
+ let display = '';
142
+ if (result.display) {
143
+ display = result.display;
144
+ } else if (result.gameState) {
145
+ display = gamerouter.displayGame(session.currentGame, result.gameState);
146
+ } else {
147
+ display = 'Command processed.';
148
+ }
149
+
150
+ return { success: true, display: display };
151
+ }
152
+
153
+ // Generate game recommendations
154
+ function getRecommendations(difficulty = 'any', players = 'any') {
155
+ const suggestions = gamerouter.getGameSuggestions(players, difficulty);
156
+
157
+ let display = 'šŸŽÆ **Game Recommendations**\n\n';
158
+
159
+ if (difficulty !== 'any') {
160
+ display += `*${difficulty.charAt(0).toUpperCase() + difficulty.slice(1)} difficulty games*\n`;
161
+ }
162
+ if (players !== 'any') {
163
+ display += `*${players.charAt(0).toUpperCase() + players.slice(1)} games*\n`;
164
+ }
165
+
166
+ display += '\n';
167
+
168
+ const recommendedGames = suggestions.slice(0, 6); // Show top 6 recommendations
169
+
170
+ recommendedGames.forEach(game => {
171
+ const status = game.available ? 'āœ…' : '🚧';
172
+ display += `${status} ${game.icon || 'šŸŽ®'} **${game.name}** (${game.players})\n`;
173
+ display += ` *${game.description}*\n`;
174
+ display += ` Launch with: \`vibe games --action launch --game ${game.id}\`\n\n`;
175
+ });
176
+
177
+ if (suggestions.length > 6) {
178
+ display += `*... and ${suggestions.length - 6} more games! Use \`vibe games --action browse\` to see all.*\n`;
179
+ }
180
+
181
+ return display;
182
+ }
183
+
184
+ // Generate help text
185
+ function generateHelp() {
186
+ return `šŸŽ® **Workshop Games Help**
187
+
188
+ **Actions:**
189
+ • \`vibe games --action browse\` - Browse all available games
190
+ • \`vibe games --action browse --category word\` - Browse word games
191
+ • \`vibe games --action launch --game hangman\` - Launch hangman game
192
+ • \`vibe games --action suggest\` - Get game recommendations
193
+ • \`vibe games --action suggest --difficulty easy --players solo\` - Filtered suggestions
194
+ • \`vibe games --action status\` - See your current game status
195
+ • \`vibe games --action quit\` - Quit current game
196
+
197
+ **Game Categories:**
198
+ šŸŽ² classic • šŸ“ word • 🧩 puzzle • ⚔ action • šŸŽØ creative • šŸ‘„ social
199
+
200
+ **While Playing:**
201
+ • \`vibe games --command [action]\` - Send command to current game
202
+ • Each game has its own commands - check the quick start guide!
203
+
204
+ **Popular Games:**
205
+ ā­• tic-tac-toe • šŸŽÆ hangman • šŸ”— wordchain • šŸŽØ drawing • ā“ twentyquestions
206
+
207
+ *Type \`vibe games --action browse\` to see all ${gamerouter.getAvailableGames().length} available games!*`;
208
+ }
209
+
210
+ async function handler(args) {
211
+ const initCheck = requireInit();
212
+ if (initCheck) return initCheck;
213
+
214
+ const { action = 'browse', game, category, difficulty, players, command } = args;
215
+ const myHandle = config.getHandle();
216
+ const session = getUserSession(myHandle);
217
+
218
+ try {
219
+ switch (action) {
220
+ case 'help':
221
+ return { display: generateHelp() };
222
+
223
+ case 'browse': {
224
+ if (category) {
225
+ // Browse specific category using arcade
226
+ const result = arcade.navigateToCategory(session.arcadeState, category);
227
+ if (result.error) {
228
+ return { display: result.error };
229
+ }
230
+ session.arcadeState = result.gameState;
231
+ const display = arcade.formatArcadeDisplay(session.arcadeState);
232
+ return { display };
233
+ } else {
234
+ // Browse all games using arcade
235
+ session.arcadeState = arcade.createInitialArcadeState();
236
+ const display = arcade.formatArcadeDisplay(session.arcadeState);
237
+ return { display };
238
+ }
239
+ }
240
+
241
+ case 'launch': {
242
+ if (!game) {
243
+ return { display: 'Please specify a game to launch. Use `vibe games --action browse` to see available games.' };
244
+ }
245
+ return launchGame(session, game);
246
+ }
247
+
248
+ case 'suggest': {
249
+ const display = getRecommendations(difficulty, players);
250
+ return { display };
251
+ }
252
+
253
+ case 'status': {
254
+ if (session.currentGame) {
255
+ const display = gamerouter.displayGame(session.currentGame, session.gameState);
256
+ return {
257
+ display: `**Current Game:** ${session.currentGame}\n\n${display}\n\n*Use \`vibe games --command [action]\` to play, or \`vibe games --action quit\` to exit.*`
258
+ };
259
+ } else {
260
+ const totalGames = gamerouter.getAvailableGames().length;
261
+ return {
262
+ display: `**No Active Game**\n\nšŸŽ® **${totalGames} games available** in the Workshop\n\nUse \`vibe games --action launch --game [name]\` to start a game\nOr \`vibe games --action browse\` to explore all games`
263
+ };
264
+ }
265
+ }
266
+
267
+ case 'quit': {
268
+ if (session.currentGame) {
269
+ const gameName = session.currentGame;
270
+ session.currentGame = null;
271
+ session.gameState = null;
272
+ return { display: `āœ… Quit ${gameName}. Use \`vibe games --action browse\` to find another game!` };
273
+ } else {
274
+ return { display: 'No active game to quit.' };
275
+ }
276
+ }
277
+
278
+ default: {
279
+ // If we have a command and active game, handle it
280
+ if (command && session.currentGame) {
281
+ return handleGameCommand(session, command);
282
+ }
283
+
284
+ // Default to browse if no specific action
285
+ session.arcadeState = arcade.createInitialArcadeState();
286
+ const display = arcade.formatArcadeDisplay(session.arcadeState);
287
+ return { display };
288
+ }
289
+ }
290
+
291
+ } catch (error) {
292
+ console.error('[games] Error:', error);
293
+ return { display: `Error: ${error.message}. Try \`vibe games --action help\` for usage.` };
294
+ }
295
+ }
296
+
297
+ // Clean up inactive sessions (called periodically)
298
+ function cleanupInactiveSessions() {
299
+ const now = Date.now();
300
+ const TIMEOUT = 30 * 60 * 1000; // 30 minutes
301
+
302
+ for (const [handle, session] of activeSessions.entries()) {
303
+ const lastActivity = new Date(session.lastActivity).getTime();
304
+ if (now - lastActivity > TIMEOUT) {
305
+ activeSessions.delete(handle);
306
+ }
307
+ }
308
+ }
309
+
310
+ // Run cleanup every 10 minutes
311
+ setInterval(cleanupInactiveSessions, 10 * 60 * 1000);
312
+
313
+ module.exports = { definition, handler };