slashvibe-mcp 0.2.9 → 0.3.13

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 (205) hide show
  1. package/README.md +1 -0
  2. package/analytics.js +107 -0
  3. package/auth-store.js +148 -0
  4. package/auto-update.js +130 -0
  5. package/bridges/bridge-monitor.js +388 -0
  6. package/bridges/discord-bot.js +431 -0
  7. package/bridges/farcaster.js +299 -0
  8. package/bridges/telegram.js +261 -0
  9. package/bridges/webhook-health.js +420 -0
  10. package/bridges/webhook-server.js +437 -0
  11. package/bridges/whatsapp.js +441 -0
  12. package/bridges/x-webhook.js +423 -0
  13. package/config.js +154 -5
  14. package/crypto.js +3 -8
  15. package/games/arcade.js +406 -0
  16. package/games/chess.js +451 -0
  17. package/games/colorguess.js +343 -0
  18. package/games/crossword-words.js +171 -0
  19. package/games/crossword.js +461 -0
  20. package/games/drawing.js +347 -0
  21. package/games/gameroulette.js +300 -0
  22. package/games/gamerouter.js +336 -0
  23. package/games/gamestatus.js +337 -0
  24. package/games/guessnumber.js +209 -0
  25. package/games/hangman.js +279 -0
  26. package/games/memory.js +338 -0
  27. package/games/multiplayer-tictactoe.js +389 -0
  28. package/games/pixelart.js +399 -0
  29. package/games/quickduel.js +354 -0
  30. package/games/riddle.js +371 -0
  31. package/games/rockpaperscissors.js +291 -0
  32. package/games/snake.js +406 -0
  33. package/games/storybuilder.js +343 -0
  34. package/games/tictactoe.js +345 -0
  35. package/games/twentyquestions.js +286 -0
  36. package/games/twotruths.js +207 -0
  37. package/games/werewolf.js +508 -0
  38. package/games/wordassociation.js +247 -0
  39. package/games/wordchain.js +135 -0
  40. package/index.js +105 -216
  41. package/intelligence/index.js +45 -0
  42. package/intelligence/infer.js +316 -0
  43. package/intelligence/interests.js +369 -0
  44. package/intelligence/patterns.js +651 -0
  45. package/intelligence/proactive.js +358 -0
  46. package/intelligence/serendipity.js +306 -0
  47. package/memory.js +166 -0
  48. package/notification-emitter.js +77 -0
  49. package/notify.js +102 -1
  50. package/package.json +21 -7
  51. package/prompts.js +1 -1
  52. package/protocol/index.js +161 -1
  53. package/setup.js +402 -0
  54. package/store/api.js +528 -82
  55. package/store/profiles.js +160 -12
  56. package/tools/_actions.js +463 -16
  57. package/tools/_deprecated/auto-suggest-connections.js +304 -0
  58. package/tools/_deprecated/bootstrap-skills.js +231 -0
  59. package/tools/_deprecated/bridge-dashboard.js +342 -0
  60. package/tools/_deprecated/bridge-health.js +400 -0
  61. package/tools/_deprecated/bridge-live.js +384 -0
  62. package/tools/_deprecated/bridges.js +383 -0
  63. package/tools/_deprecated/colorguess.js +281 -0
  64. package/tools/_deprecated/discover-insights.js +379 -0
  65. package/tools/_deprecated/discover-momentum.js +256 -0
  66. package/tools/_deprecated/discovery-analytics.js +345 -0
  67. package/tools/_deprecated/discovery-auto-suggest.js +275 -0
  68. package/tools/_deprecated/discovery-bootstrap.js +267 -0
  69. package/tools/_deprecated/discovery-daily.js +375 -0
  70. package/tools/_deprecated/discovery-dashboard.js +385 -0
  71. package/tools/_deprecated/discovery-digest.js +314 -0
  72. package/tools/_deprecated/discovery-hub.js +357 -0
  73. package/tools/_deprecated/discovery-insights.js +384 -0
  74. package/tools/_deprecated/discovery-momentum.js +281 -0
  75. package/tools/_deprecated/discovery-monitor.js +319 -0
  76. package/tools/_deprecated/discovery-proactive.js +300 -0
  77. package/tools/_deprecated/draw.js +317 -0
  78. package/tools/_deprecated/farcaster.js +307 -0
  79. package/tools/_deprecated/forget.js +119 -0
  80. package/tools/_deprecated/games-catalog.js +376 -0
  81. package/tools/_deprecated/games.js +313 -0
  82. package/tools/_deprecated/guessnumber.js +194 -0
  83. package/tools/_deprecated/hangman.js +129 -0
  84. package/tools/_deprecated/multiplayer-tictactoe.js +303 -0
  85. package/tools/_deprecated/recall.js +147 -0
  86. package/tools/_deprecated/remember.js +86 -0
  87. package/tools/_deprecated/riddle.js +240 -0
  88. package/tools/_deprecated/run-bootstrap.js +69 -0
  89. package/tools/_deprecated/skills-analytics.js +349 -0
  90. package/tools/_deprecated/skills-bootstrap.js +301 -0
  91. package/tools/_deprecated/skills-dashboard.js +268 -0
  92. package/tools/_deprecated/skills.js +380 -0
  93. package/tools/_deprecated/smart-intro.js +353 -0
  94. package/tools/_deprecated/storybuilder.js +331 -0
  95. package/tools/_deprecated/telegram-bot.js +183 -0
  96. package/tools/_deprecated/telegram-setup.js +214 -0
  97. package/tools/_deprecated/twentyquestions.js +143 -0
  98. package/tools/_discovery-enhanced.js +290 -0
  99. package/tools/_discovery.js +439 -0
  100. package/tools/_proactive-discovery.js +301 -0
  101. package/tools/_shared/index.js +64 -0
  102. package/tools/_shared.js +234 -0
  103. package/tools/_work-context.js +338 -0
  104. package/tools/_work-context.manual-test.js +199 -0
  105. package/tools/_work-context.test.js +260 -0
  106. package/tools/activity.js +220 -0
  107. package/tools/admin-inbox.js +218 -0
  108. package/tools/agent-treasury.js +288 -0
  109. package/tools/analytics.js +191 -0
  110. package/tools/approve.js +197 -0
  111. package/tools/arcade.js +173 -0
  112. package/tools/artifact-create.js +17 -11
  113. package/tools/artifact-view.js +31 -1
  114. package/tools/artifacts-price.js +47 -43
  115. package/tools/ask-expert.js +160 -0
  116. package/tools/available.js +120 -0
  117. package/tools/become-expert.js +150 -0
  118. package/tools/broadcast.js +286 -0
  119. package/tools/chat.js +202 -0
  120. package/tools/collaborative-drawing.js +286 -0
  121. package/tools/connection-status.js +178 -0
  122. package/tools/crossword.js +17 -1
  123. package/tools/discover.js +350 -34
  124. package/tools/dm.js +115 -73
  125. package/tools/drawing.js +1 -1
  126. package/tools/earnings.js +126 -0
  127. package/tools/echo.js +16 -0
  128. package/tools/feed.js +51 -7
  129. package/tools/follow.js +224 -0
  130. package/tools/friends.js +207 -0
  131. package/tools/game.js +2 -2
  132. package/tools/genesis.js +233 -0
  133. package/tools/gig-browse.js +206 -0
  134. package/tools/gig-complete.js +144 -0
  135. package/tools/handoff.js +7 -1
  136. package/tools/help.js +4 -4
  137. package/tools/idea.js +9 -2
  138. package/tools/inbox.js +334 -28
  139. package/tools/init.js +727 -36
  140. package/tools/invite.js +15 -4
  141. package/tools/l2-bridge.js +272 -0
  142. package/tools/l2-status.js +217 -0
  143. package/tools/l2.js +206 -0
  144. package/tools/migrate.js +156 -0
  145. package/tools/mint.js +377 -0
  146. package/tools/multiplayer-game.js +1 -1
  147. package/tools/notifications.js +415 -0
  148. package/tools/observe.js +200 -0
  149. package/tools/onboarding.js +147 -0
  150. package/tools/open.js +143 -12
  151. package/tools/party-game.js +2 -2
  152. package/tools/plan.js +225 -0
  153. package/tools/presence-agent.js +7 -0
  154. package/tools/proof-of-work.js +100 -104
  155. package/tools/pulse.js +218 -0
  156. package/tools/reply.js +166 -0
  157. package/tools/report.js +2 -2
  158. package/tools/reputation.js +175 -0
  159. package/tools/request.js +17 -3
  160. package/tools/schedule.js +367 -0
  161. package/tools/search-messages.js +123 -0
  162. package/tools/session.js +420 -0
  163. package/tools/session_price.js +128 -0
  164. package/tools/settings.js +126 -3
  165. package/tools/ship.js +31 -8
  166. package/tools/shipback.js +326 -0
  167. package/tools/smart-check.js +201 -0
  168. package/tools/social-processor.js +445 -0
  169. package/tools/solo-game.js +1 -1
  170. package/tools/start.js +335 -93
  171. package/tools/status.js +53 -6
  172. package/tools/stuck.js +297 -0
  173. package/tools/subscribe.js +148 -0
  174. package/tools/subscriptions.js +134 -0
  175. package/tools/suggest-tags.js +6 -8
  176. package/tools/tag-suggestions.js +257 -0
  177. package/tools/tip.js +193 -0
  178. package/tools/token.js +103 -0
  179. package/tools/update.js +1 -1
  180. package/tools/wallet.js +239 -186
  181. package/tools/watch.js +157 -0
  182. package/tools/webhook-test.js +388 -0
  183. package/tools/who.js +54 -3
  184. package/tools/withdraw.js +145 -0
  185. package/tools/work-summary.js +96 -0
  186. package/tools/workshop.js +327 -0
  187. package/tools/x-mentions.js +1 -1
  188. package/version.json +14 -3
  189. package/tools/artifacts-buy.js +0 -111
  190. package/tools/connect.js +0 -284
  191. package/tools/gigs-apply.js +0 -99
  192. package/tools/gigs-browse.js +0 -114
  193. package/tools/gigs-complete.js +0 -128
  194. package/tools/gigs-post.js +0 -140
  195. package/tools/live-off.js +0 -109
  196. package/tools/live-watch.js +0 -176
  197. package/tools/live.js +0 -128
  198. package/tools/sessions-browse.js +0 -105
  199. package/tools/whats-happening.js +0 -125
  200. /package/tools/{away.js → _deprecated/away.js} +0 -0
  201. /package/tools/{back.js → _deprecated/back.js} +0 -0
  202. /package/tools/{mute.js → _deprecated/mute.js} +0 -0
  203. /package/tools/{skills-exchange.js → _deprecated/skills-exchange.js} +0 -0
  204. /package/tools/{tictactoe.js → _deprecated/tictactoe.js} +0 -0
  205. /package/tools/{wordassociation.js → _deprecated/wordassociation.js} +0 -0
@@ -0,0 +1,319 @@
1
+ /**
2
+ * Discovery Monitor — Proactive matching when people come online
3
+ *
4
+ * Features:
5
+ * - Watches for new users joining
6
+ * - Automatically suggests connections for new users
7
+ * - Identifies high-value connections when users become active
8
+ * - Sends smart welcome messages with connection suggestions
9
+ */
10
+
11
+ const config = require('../config');
12
+ const store = require('../store');
13
+ const userProfiles = require('../store/profiles');
14
+ const { suggest_connection } = require('./_actions');
15
+ const { formatTimeAgo } = require('./_shared');
16
+
17
+ // Watch for new users and suggest welcome connections
18
+ async function monitorNewUsers() {
19
+ const recentUsers = await getRecentUsers(24); // Last 24 hours
20
+ const suggestions = [];
21
+
22
+ for (const user of recentUsers) {
23
+ if (user.isNew) {
24
+ const welcomeConnections = await getWelcomeConnections(user.handle);
25
+
26
+ for (const connection of welcomeConnections.slice(0, 2)) {
27
+ // Suggest the connection
28
+ await suggest_connection(user.handle, connection.handle, connection.reason);
29
+ suggestions.push({
30
+ from: user.handle,
31
+ to: connection.handle,
32
+ reason: connection.reason,
33
+ type: 'welcome'
34
+ });
35
+ }
36
+ }
37
+ }
38
+
39
+ return suggestions;
40
+ }
41
+
42
+ // Get users who joined recently
43
+ async function getRecentUsers(hoursBack = 24) {
44
+ const profiles = await userProfiles.getAllProfiles();
45
+ const cutoff = Date.now() - (hoursBack * 60 * 60 * 1000);
46
+
47
+ const recent = profiles.filter(p =>
48
+ p.firstSeen && p.firstSeen > cutoff
49
+ );
50
+
51
+ return recent.map(p => ({
52
+ handle: p.handle,
53
+ firstSeen: p.firstSeen,
54
+ building: p.building,
55
+ interests: p.interests || [],
56
+ tags: p.tags || [],
57
+ isNew: true
58
+ }));
59
+ }
60
+
61
+ // Find best welcome connections for new users
62
+ async function getWelcomeConnections(newUserHandle) {
63
+ const newUser = await userProfiles.getProfile(newUserHandle);
64
+ const allProfiles = await userProfiles.getAllProfiles();
65
+
66
+ // Filter to established users (not brand new)
67
+ const weekAgo = Date.now() - (7 * 24 * 60 * 60 * 1000);
68
+ const establishedUsers = allProfiles.filter(p =>
69
+ p.handle !== newUserHandle &&
70
+ p.firstSeen && p.firstSeen < weekAgo &&
71
+ (p.connections?.length || 0) >= 1 // Has made at least one connection
72
+ );
73
+
74
+ if (establishedUsers.length === 0) {
75
+ return []; // No established users to suggest
76
+ }
77
+
78
+ const potentialConnections = [];
79
+
80
+ for (const user of establishedUsers) {
81
+ const score = calculateWelcomeScore(newUser, user);
82
+
83
+ if (score.total > 15) {
84
+ potentialConnections.push({
85
+ handle: user.handle,
86
+ score: score.total,
87
+ reason: score.reason,
88
+ building: user.building,
89
+ lastSeen: user.lastSeen
90
+ });
91
+ }
92
+ }
93
+
94
+ // Sort by score and prioritize recently active users
95
+ return potentialConnections
96
+ .sort((a, b) => {
97
+ // Boost recently active users
98
+ const aActive = a.lastSeen > Date.now() - (24 * 60 * 60 * 1000) ? 10 : 0;
99
+ const bActive = b.lastSeen > Date.now() - (24 * 60 * 60 * 1000) ? 10 : 0;
100
+
101
+ return (b.score + bActive) - (a.score + aActive);
102
+ })
103
+ .slice(0, 3);
104
+ }
105
+
106
+ // Calculate welcome connection score (similar to discovery but weighted for new users)
107
+ function calculateWelcomeScore(newUser, establishedUser) {
108
+ let score = 0;
109
+ let reasons = [];
110
+
111
+ // Base score for being an established, connected user
112
+ score += 10;
113
+ reasons.push('Active community member');
114
+
115
+ // Interest overlap (high weight for new users)
116
+ if (newUser.interests?.length > 0 && establishedUser.interests?.length > 0) {
117
+ const shared = newUser.interests.filter(i =>
118
+ establishedUser.interests.some(ei => ei.toLowerCase() === i.toLowerCase())
119
+ );
120
+
121
+ if (shared.length > 0) {
122
+ score += shared.length * 20;
123
+ reasons.unshift(`Both interested in ${shared.join(', ')}`);
124
+ }
125
+ }
126
+
127
+ // Tag/skill overlap
128
+ if (newUser.tags?.length > 0 && establishedUser.tags?.length > 0) {
129
+ const sharedTags = newUser.tags.filter(t =>
130
+ establishedUser.tags.some(et => et.toLowerCase() === t.toLowerCase())
131
+ );
132
+
133
+ if (sharedTags.length > 0) {
134
+ score += sharedTags.length * 15;
135
+ reasons.unshift(`Both work with ${sharedTags.join(', ')}`);
136
+ }
137
+ }
138
+
139
+ // Building similar things
140
+ if (newUser.building && establishedUser.building) {
141
+ const newBuilding = newUser.building.toLowerCase();
142
+ const establishedBuilding = establishedUser.building.toLowerCase();
143
+
144
+ const words1 = newBuilding.split(/\s+/).filter(w => w.length > 3);
145
+ const words2 = establishedBuilding.split(/\s+/).filter(w => w.length > 3);
146
+ const overlap = words1.filter(w => words2.includes(w));
147
+
148
+ if (overlap.length > 0) {
149
+ score += overlap.length * 12;
150
+ reasons.unshift(`Both building ${overlap.join(', ')} projects`);
151
+ }
152
+ }
153
+
154
+ // Complementary skills boost (mentor potential)
155
+ if (newUser.tags && establishedUser.tags) {
156
+ const complementary = findComplementarySkills(newUser.tags, establishedUser.tags);
157
+ if (complementary.length > 0) {
158
+ score += complementary.length * 8;
159
+ reasons.push(`Could help with ${complementary.join(', ')}`);
160
+ }
161
+ }
162
+
163
+ // Choose the best reason
164
+ const primaryReason = reasons[0] || 'Welcoming community member';
165
+
166
+ return {
167
+ total: score,
168
+ reason: primaryReason
169
+ };
170
+ }
171
+
172
+ // Find complementary skills for mentorship
173
+ function findComplementarySkills(newUserTags, establishedTags) {
174
+ const mentorPairs = [
175
+ { beginner: 'frontend', mentor: 'fullstack' },
176
+ { beginner: 'react', mentor: 'senior-engineer' },
177
+ { beginner: 'ai', mentor: 'machine-learning' },
178
+ { beginner: 'startup', mentor: 'founder' },
179
+ { beginner: 'design', mentor: 'product-design' },
180
+ ];
181
+
182
+ const complementary = [];
183
+
184
+ for (const pair of mentorPairs) {
185
+ const hasBeginnerSkill = newUserTags.some(t =>
186
+ t.toLowerCase().includes(pair.beginner.toLowerCase())
187
+ );
188
+ const hasMentorSkill = establishedTags.some(t =>
189
+ t.toLowerCase().includes(pair.mentor.toLowerCase())
190
+ );
191
+
192
+ if (hasBeginnerSkill && hasMentorSkill) {
193
+ complementary.push(pair.mentor);
194
+ }
195
+ }
196
+
197
+ return complementary;
198
+ }
199
+
200
+ // Monitor for high-value connections (mutual interest spikes)
201
+ async function monitorHighValueConnections() {
202
+ const profiles = await userProfiles.getAllProfiles();
203
+ const activeUsers = await store.getActiveUsers();
204
+
205
+ const highValueOpportunities = [];
206
+
207
+ for (let i = 0; i < activeUsers.length; i++) {
208
+ for (let j = i + 1; j < activeUsers.length; j++) {
209
+ const user1 = activeUsers[i];
210
+ const user2 = activeUsers[j];
211
+
212
+ // Skip if already connected
213
+ const alreadyConnected = await userProfiles.hasBeenConnected(user1.handle, user2.handle);
214
+ if (alreadyConnected) continue;
215
+
216
+ const profile1 = await userProfiles.getProfile(user1.handle);
217
+ const profile2 = await userProfiles.getProfile(user2.handle);
218
+
219
+ const matchScore = calculateTimeSensitiveScore(profile1, profile2, user1, user2);
220
+
221
+ if (matchScore.score > 30) { // High threshold for proactive suggestions
222
+ highValueOpportunities.push({
223
+ user1: user1.handle,
224
+ user2: user2.handle,
225
+ score: matchScore.score,
226
+ reason: matchScore.reason,
227
+ urgency: 'both-online'
228
+ });
229
+ }
230
+ }
231
+ }
232
+
233
+ return highValueOpportunities.sort((a, b) => b.score - a.score).slice(0, 3);
234
+ }
235
+
236
+ // Calculate time-sensitive match scores (bonus for being online together)
237
+ function calculateTimeSensitiveScore(profile1, profile2, activeUser1, activeUser2) {
238
+ let score = 0;
239
+ let reasons = [];
240
+
241
+ // Base match calculation (similar to discovery)
242
+ if (profile1.interests && profile2.interests) {
243
+ const shared = profile1.interests.filter(i => profile2.interests.includes(i));
244
+ score += shared.length * 15;
245
+ if (shared.length > 0) reasons.push(`Both into ${shared.join(', ')}`);
246
+ }
247
+
248
+ if (profile1.tags && profile2.tags) {
249
+ const sharedTags = profile1.tags.filter(t => profile2.tags.includes(t));
250
+ score += sharedTags.length * 12;
251
+ if (sharedTags.length > 0) reasons.push(`Both skilled in ${sharedTags.join(', ')}`);
252
+ }
253
+
254
+ // Time bonus - both online now
255
+ score += 20;
256
+ reasons.unshift('Both online right now');
257
+
258
+ // Activity similarity bonus
259
+ if (activeUser1.status && activeUser2.status) {
260
+ if (activeUser1.status === activeUser2.status) {
261
+ score += 10;
262
+ reasons.push(`Both ${activeUser1.status}`);
263
+ }
264
+ }
265
+
266
+ return {
267
+ score,
268
+ reason: reasons[0] || 'Great time to connect'
269
+ };
270
+ }
271
+
272
+ // Get connection statistics for monitoring
273
+ async function getConnectionStats() {
274
+ const profiles = await userProfiles.getAllProfiles();
275
+
276
+ const stats = {
277
+ totalUsers: profiles.length,
278
+ usersWithConnections: 0,
279
+ avgConnectionsPerUser: 0,
280
+ connectionsMadeToday: 0,
281
+ newUsersToday: 0,
282
+ activeUsersToday: 0
283
+ };
284
+
285
+ const today = Date.now() - (24 * 60 * 60 * 1000);
286
+ let totalConnections = 0;
287
+
288
+ for (const profile of profiles) {
289
+ if (profile.connections && profile.connections.length > 0) {
290
+ stats.usersWithConnections++;
291
+ totalConnections += profile.connections.length;
292
+
293
+ // Count connections made today
294
+ const todayConnections = profile.connections.filter(c => c.timestamp > today);
295
+ stats.connectionsMadeToday += todayConnections.length;
296
+ }
297
+
298
+ if (profile.firstSeen > today) {
299
+ stats.newUsersToday++;
300
+ }
301
+
302
+ if (profile.lastSeen > today) {
303
+ stats.activeUsersToday++;
304
+ }
305
+ }
306
+
307
+ stats.avgConnectionsPerUser = profiles.length > 0 ? (totalConnections / 2) / profiles.length : 0;
308
+ stats.connectionsMadeToday = Math.floor(stats.connectionsMadeToday / 2); // Each connection counted twice
309
+
310
+ return stats;
311
+ }
312
+
313
+ module.exports = {
314
+ monitorNewUsers,
315
+ monitorHighValueConnections,
316
+ getWelcomeConnections,
317
+ getConnectionStats,
318
+ getRecentUsers
319
+ };
@@ -0,0 +1,300 @@
1
+ /**
2
+ * vibe discovery-proactive — Real-time connection opportunities
3
+ *
4
+ * Monitors for immediate connection opportunities:
5
+ * - Users who just came online (welcome back suggestions)
6
+ * - Both users online at same time (perfect timing)
7
+ * - Recent ships that might interest others
8
+ * - Trending topic clusters
9
+ * - Follow-up on previous connections
10
+ */
11
+
12
+ const config = require('../config');
13
+ const store = require('../store');
14
+ const userProfiles = require('../store/profiles');
15
+ const proactiveDiscovery = require('./_proactive-discovery');
16
+ const { formatTimeAgo, requireInit } = require('./_shared');
17
+
18
+ const definition = {
19
+ name: 'vibe_discovery_proactive',
20
+ description: 'Find real-time connection opportunities and trending topics.',
21
+ inputSchema: {
22
+ type: 'object',
23
+ properties: {
24
+ action: {
25
+ type: 'string',
26
+ enum: ['opportunities', 'welcome', 'trending', 'ships'],
27
+ description: 'Type of proactive discovery to run'
28
+ },
29
+ autoSuggest: {
30
+ type: 'boolean',
31
+ description: 'Automatically make connection suggestions'
32
+ }
33
+ }
34
+ }
35
+ };
36
+
37
+ // Find and display current connection opportunities
38
+ async function findCurrentOpportunities(autoSuggest = false) {
39
+ const opportunities = await proactiveDiscovery.findOnlineConnectionOpportunities();
40
+ let actionsTaken = 0;
41
+
42
+ let display = `## Real-Time Connection Opportunities 🎯\n\n`;
43
+
44
+ if (opportunities.length === 0) {
45
+ display += `No high-value connections found among current online users.\n\n`;
46
+ display += `**Try:**\n`;
47
+ display += `• Check back when more users are online\n`;
48
+ display += `• \`discovery-proactive trending\` for topic-based connections\n`;
49
+ display += `• \`discovery-proactive ships\` for recent ship connections`;
50
+
51
+ return { display, actionsTaken };
52
+ }
53
+
54
+ display += `Found ${opportunities.length} high-value opportunities:\n\n`;
55
+
56
+ for (const opp of opportunities.slice(0, 5)) {
57
+ display += `**@${opp.user1} ↔ @${opp.user2}** _(${opp.score}% match)_\n`;
58
+
59
+ if (opp.reasons.length > 0) {
60
+ display += `🔗 ${opp.reasons.join(' • ')}\n`;
61
+ }
62
+
63
+ display += `⚡ Both online now - perfect timing!\n`;
64
+
65
+ if (opp.profiles.profile1.building) {
66
+ display += `${opp.user1}: ${opp.profiles.profile1.building}\n`;
67
+ }
68
+ if (opp.profiles.profile2.building) {
69
+ display += `${opp.user2}: ${opp.profiles.profile2.building}\n`;
70
+ }
71
+
72
+ display += `\n`;
73
+
74
+ // Auto-suggest if requested
75
+ if (autoSuggest) {
76
+ try {
77
+ // Make the suggestion (this would typically call suggest_connection)
78
+ proactiveDiscovery.recordSuggestion(opp.user1, opp.user2);
79
+ actionsTaken++;
80
+ display += `✅ Connection suggested to both users\n\n`;
81
+ } catch (error) {
82
+ display += `❌ Failed to suggest: ${error.message}\n\n`;
83
+ }
84
+ } else {
85
+ display += `Run with \`autoSuggest: true\` to make suggestions automatically\n\n`;
86
+ }
87
+ }
88
+
89
+ return { display, actionsTaken };
90
+ }
91
+
92
+ // Welcome back users who just came online
93
+ async function welcomeNewOnlineUsers() {
94
+ const newOnline = await proactiveDiscovery.findNewOnlineUsers();
95
+
96
+ let display = `## Welcome Back Online Users 👋\n\n`;
97
+
98
+ if (newOnline.length === 0) {
99
+ display += `No users have come online recently.\n\n`;
100
+ display += `This feature detects users who came online in the last 10 minutes.`;
101
+ return { display, actionsTaken: 0 };
102
+ }
103
+
104
+ display += `Found ${newOnline.length} users who just came online:\n\n`;
105
+
106
+ let actionsTaken = 0;
107
+
108
+ for (const user of newOnline) {
109
+ display += `**@${user.handle}** just came online\n`;
110
+
111
+ if (user.profile.building) {
112
+ display += `Building: ${user.profile.building}\n`;
113
+ }
114
+
115
+ // Get suggestions for this user
116
+ const suggestions = await proactiveDiscovery.generateWelcomeBackSuggestions(user.handle);
117
+
118
+ if (suggestions.length > 0) {
119
+ display += `\n**Immediate connection opportunities:**\n`;
120
+
121
+ for (const suggestion of suggestions.slice(0, 2)) {
122
+ display += `• @${suggestion.handle} (${suggestion.score}% match) - ${suggestion.reasons[0]}\n`;
123
+ }
124
+
125
+ actionsTaken++;
126
+ }
127
+
128
+ display += `\n`;
129
+ }
130
+
131
+ if (actionsTaken > 0) {
132
+ display += `💡 Perfect timing for connections - everyone's online now!\n`;
133
+ display += `Use \`message @handle\` to reach out while they're active.`;
134
+ }
135
+
136
+ return { display, actionsTaken };
137
+ }
138
+
139
+ // Find trending topic clusters
140
+ async function findTrendingClusters() {
141
+ const clusters = await proactiveDiscovery.generateTrendingTopicClusters();
142
+ const suggestions = await proactiveDiscovery.suggestTrendingTopicConnections();
143
+
144
+ let display = `## Trending Topic Clusters 📈\n\n`;
145
+
146
+ const clusterEntries = Object.entries(clusters);
147
+
148
+ if (clusterEntries.length === 0) {
149
+ display += `No trending topics detected yet.\n\n`;
150
+ display += `Trending topics are identified when multiple users:\n`;
151
+ display += `• Ship projects with similar keywords\n`;
152
+ display += `• Share similar interests or tags\n`;
153
+ display += `• Work on related projects\n\n`;
154
+ display += `Come back when there's more activity!`;
155
+ return { display, actionsTaken: 0 };
156
+ }
157
+
158
+ display += `Found ${clusterEntries.length} trending topics:\n\n`;
159
+
160
+ for (const [topic, users] of clusterEntries.slice(0, 5)) {
161
+ display += `**${topic}** (${users.length} users)\n`;
162
+ display += `${users.slice(0, 4).map(u => `@${u.handle}`).join(', ')}`;
163
+ if (users.length > 4) {
164
+ display += ` +${users.length - 4} more`;
165
+ }
166
+ display += `\n\n`;
167
+ }
168
+
169
+ if (suggestions.length > 0) {
170
+ display += `**Connection Opportunities:**\n\n`;
171
+
172
+ for (const suggestion of suggestions.slice(0, 3)) {
173
+ display += `**@${suggestion.user1} ↔ @${suggestion.user2}**\n`;
174
+ display += `Topic: ${suggestion.topic} • Match: ${suggestion.score}%\n`;
175
+ display += `${suggestion.reason}\n\n`;
176
+ }
177
+ }
178
+
179
+ return { display, actionsTaken: suggestions.length };
180
+ }
181
+
182
+ // Find connections based on recent ships
183
+ async function findShipConnections() {
184
+ const recentShippers = await proactiveDiscovery.findRecentShippers();
185
+ const shipConnections = await proactiveDiscovery.findShipBasedConnections();
186
+
187
+ let display = `## Recent Ships & Connection Opportunities 🚢\n\n`;
188
+
189
+ if (recentShippers.length === 0) {
190
+ display += `No recent ships found (last 24 hours).\n\n`;
191
+ display += `When users ship projects, I can:\n`;
192
+ display += `• Find others working on similar things\n`;
193
+ display += `• Connect complementary skill sets\n`;
194
+ display += `• Suggest collaboration opportunities\n\n`;
195
+ display += `Encourage people to use \`ship "what they built"\`!`;
196
+ return { display, actionsTaken: 0 };
197
+ }
198
+
199
+ display += `**Recent Ships (last 24h):**\n`;
200
+ for (const shipper of recentShippers.slice(0, 5)) {
201
+ display += `• @${shipper.handle}: ${shipper.ships[0].what}\n`;
202
+ }
203
+ display += `\n`;
204
+
205
+ if (shipConnections.length > 0) {
206
+ display += `**Connection Opportunities:**\n\n`;
207
+
208
+ for (const connection of shipConnections.slice(0, 5)) {
209
+ display += `**@${connection.shipper} → @${connection.interestedUser}**\n`;
210
+ display += `${connection.reason}\n`;
211
+ display += `_${formatTimeAgo(connection.timestamp)}_\n\n`;
212
+ }
213
+
214
+ display += `💡 These users might benefit from connecting based on recent ships!`;
215
+ } else {
216
+ display += `No specific ship-based connections identified yet.\n`;
217
+ display += `As more people ship and share interests, better matches will emerge.`;
218
+ }
219
+
220
+ return { display, actionsTaken: shipConnections.length };
221
+ }
222
+
223
+ async function handler(args) {
224
+ const initCheck = requireInit();
225
+ if (initCheck) return initCheck;
226
+
227
+ const action = args.action || 'opportunities';
228
+ const autoSuggest = args.autoSuggest || false;
229
+
230
+ let display = '';
231
+ let actionsTaken = 0;
232
+
233
+ try {
234
+ switch (action) {
235
+ case 'opportunities': {
236
+ const result = await findCurrentOpportunities(autoSuggest);
237
+ display = result.display;
238
+ actionsTaken = result.actionsTaken;
239
+ break;
240
+ }
241
+
242
+ case 'welcome': {
243
+ const result = await welcomeNewOnlineUsers();
244
+ display = result.display;
245
+ actionsTaken = result.actionsTaken;
246
+ break;
247
+ }
248
+
249
+ case 'trending': {
250
+ const result = await findTrendingClusters();
251
+ display = result.display;
252
+ actionsTaken = result.actionsTaken;
253
+ break;
254
+ }
255
+
256
+ case 'ships': {
257
+ const result = await findShipConnections();
258
+ display = result.display;
259
+ actionsTaken = result.actionsTaken;
260
+ break;
261
+ }
262
+
263
+ default:
264
+ display = `## Proactive Discovery Commands
265
+
266
+ **\`discovery-proactive opportunities\`** — Real-time connection opportunities
267
+ **\`discovery-proactive welcome\`** — Welcome users who just came online
268
+ **\`discovery-proactive trending\`** — Find trending topic clusters
269
+ **\`discovery-proactive ships\`** — Connections based on recent ships
270
+
271
+ **Advanced:**
272
+ Add \`autoSuggest: true\` to automatically make connection suggestions
273
+
274
+ **How it works:**
275
+ • Monitors users coming online in real-time
276
+ • Identifies when both users in a potential match are active
277
+ • Tracks trending topics and clusters users accordingly
278
+ • Finds connection opportunities based on recent ships
279
+ • Provides perfect-timing suggestions when both users are online`;
280
+ }
281
+
282
+ if (actionsTaken > 0) {
283
+ display += `\n\n---\n**Actions taken:** ${actionsTaken}`;
284
+ }
285
+
286
+ } catch (error) {
287
+ display = `## Proactive Discovery Error
288
+
289
+ ${error.message}
290
+
291
+ Try:
292
+ • \`discovery-proactive opportunities\` for online connections
293
+ • \`discovery-proactive trending\` for topic clusters
294
+ • \`who\` to see current online users`;
295
+ }
296
+
297
+ return { display };
298
+ }
299
+
300
+ module.exports = { definition, handler };