slashvibe-mcp 0.2.2 → 0.2.3

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 (133) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +58 -40
  3. package/config.js +171 -3
  4. package/index.js +136 -16
  5. package/intelligence/index.js +38 -0
  6. package/intelligence/infer.js +316 -0
  7. package/intelligence/patterns.js +651 -0
  8. package/intelligence/proactive.js +358 -0
  9. package/intelligence/serendipity.js +306 -0
  10. package/notify.js +141 -18
  11. package/package.json +8 -4
  12. package/presence.js +5 -1
  13. package/protocol/index.js +88 -1
  14. package/protocol/telegram-commands.js +199 -0
  15. package/store/api.js +360 -25
  16. package/store/index.js +7 -7
  17. package/store/local.js +67 -11
  18. package/store/profiles.js +287 -0
  19. package/store/reservations.js +321 -0
  20. package/store/skills.js +378 -0
  21. package/tools/_actions.js +270 -14
  22. package/tools/_connection-queue.js +257 -0
  23. package/tools/_discovery-enhanced.js +290 -0
  24. package/tools/_discovery.js +346 -0
  25. package/tools/_proactive-discovery.js +301 -0
  26. package/tools/admin-inbox.js +218 -0
  27. package/tools/agent-treasury.js +288 -0
  28. package/tools/agents.js +122 -0
  29. package/tools/arcade.js +173 -0
  30. package/tools/artifact-create.js +236 -0
  31. package/tools/artifact-view.js +174 -0
  32. package/tools/ask-expert.js +160 -0
  33. package/tools/auto-suggest-connections.js +304 -0
  34. package/tools/away.js +68 -0
  35. package/tools/back.js +51 -0
  36. package/tools/become-expert.js +150 -0
  37. package/tools/bootstrap-skills.js +231 -0
  38. package/tools/bridge-dashboard.js +342 -0
  39. package/tools/bridge-health.js +400 -0
  40. package/tools/bridge-live.js +384 -0
  41. package/tools/bridges.js +383 -0
  42. package/tools/bye.js +4 -0
  43. package/tools/collaborative-drawing.js +286 -0
  44. package/tools/colorguess.js +281 -0
  45. package/tools/crossword.js +369 -0
  46. package/tools/discover-insights.js +379 -0
  47. package/tools/discover-momentum.js +256 -0
  48. package/tools/discover.js +395 -0
  49. package/tools/discovery-analytics.js +345 -0
  50. package/tools/discovery-auto-suggest.js +275 -0
  51. package/tools/discovery-bootstrap.js +267 -0
  52. package/tools/discovery-daily.js +375 -0
  53. package/tools/discovery-dashboard.js +385 -0
  54. package/tools/discovery-digest.js +314 -0
  55. package/tools/discovery-hub.js +357 -0
  56. package/tools/discovery-insights.js +384 -0
  57. package/tools/discovery-momentum.js +281 -0
  58. package/tools/discovery-monitor.js +319 -0
  59. package/tools/discovery-proactive.js +300 -0
  60. package/tools/dm.js +62 -9
  61. package/tools/draw.js +317 -0
  62. package/tools/drawing.js +310 -0
  63. package/tools/echo.js +16 -0
  64. package/tools/farcaster.js +307 -0
  65. package/tools/feed.js +196 -0
  66. package/tools/game.js +218 -110
  67. package/tools/games-catalog.js +376 -0
  68. package/tools/games.js +313 -0
  69. package/tools/genesis.js +233 -0
  70. package/tools/guessnumber.js +194 -0
  71. package/tools/hangman.js +129 -0
  72. package/tools/help.js +269 -0
  73. package/tools/idea.js +210 -0
  74. package/tools/inbox.js +148 -25
  75. package/tools/init.js +651 -33
  76. package/tools/insights.js +123 -0
  77. package/tools/invite.js +142 -21
  78. package/tools/l2-bridge.js +272 -0
  79. package/tools/l2-status.js +217 -0
  80. package/tools/l2.js +206 -0
  81. package/tools/migrate.js +156 -0
  82. package/tools/mint.js +377 -0
  83. package/tools/multiplayer-game.js +275 -0
  84. package/tools/multiplayer-tictactoe.js +303 -0
  85. package/tools/mute.js +97 -0
  86. package/tools/notifications.js +415 -0
  87. package/tools/observe.js +200 -0
  88. package/tools/onboarding.js +147 -0
  89. package/tools/open.js +14 -2
  90. package/tools/party-game.js +314 -0
  91. package/tools/presence-agent.js +167 -0
  92. package/tools/profile.js +219 -0
  93. package/tools/pulse.js +218 -0
  94. package/tools/react.js +4 -0
  95. package/tools/release.js +83 -0
  96. package/tools/report.js +109 -0
  97. package/tools/reputation.js +175 -0
  98. package/tools/request.js +217 -0
  99. package/tools/reservations.js +116 -0
  100. package/tools/reserve.js +111 -0
  101. package/tools/riddle.js +240 -0
  102. package/tools/run-bootstrap.js +69 -0
  103. package/tools/settings.js +112 -0
  104. package/tools/ship.js +182 -0
  105. package/tools/shipback.js +326 -0
  106. package/tools/skills-analytics.js +349 -0
  107. package/tools/skills-bootstrap.js +301 -0
  108. package/tools/skills-dashboard.js +268 -0
  109. package/tools/skills-exchange.js +342 -0
  110. package/tools/skills.js +380 -0
  111. package/tools/smart-intro.js +353 -0
  112. package/tools/social-inbox.js +326 -69
  113. package/tools/social-post.js +251 -66
  114. package/tools/social-processor.js +445 -0
  115. package/tools/solo-game.js +390 -0
  116. package/tools/start.js +205 -83
  117. package/tools/storybuilder.js +331 -0
  118. package/tools/suggest-tags.js +186 -0
  119. package/tools/tag-suggestions.js +257 -0
  120. package/tools/telegram-bot.js +183 -0
  121. package/tools/telegram-setup.js +214 -0
  122. package/tools/tictactoe.js +155 -0
  123. package/tools/tip.js +120 -0
  124. package/tools/token.js +103 -0
  125. package/tools/twentyquestions.js +143 -0
  126. package/tools/wallet.js +127 -0
  127. package/tools/webhook-test.js +388 -0
  128. package/tools/who.js +118 -25
  129. package/tools/wordassociation.js +247 -0
  130. package/tools/workshop-buddy.js +394 -0
  131. package/tools/workshop.js +327 -0
  132. package/version.json +12 -3
  133. package/tools/board.js +0 -130
@@ -0,0 +1,316 @@
1
+ /**
2
+ * Smart Detection — Ambient Intelligence for /vibe
3
+ *
4
+ * Automatically infers user state from context signals:
5
+ * - File activity (what they're editing)
6
+ * - Branch names (fix-, feat-, debug-)
7
+ * - Error patterns (debugging)
8
+ * - Session length (deep focus)
9
+ * - Message activity (social vs focused)
10
+ *
11
+ * Inferred states displayed in `vibe who` with (inferred) label
12
+ */
13
+
14
+ // State definitions with detection rules
15
+ const STATES = {
16
+ 'github-shipping': {
17
+ emoji: '🔥',
18
+ label: 'shipping code',
19
+ priority: 0, // Highest priority — real GitHub commits
20
+ description: 'Active GitHub commits detected'
21
+ },
22
+ 'deep-focus': {
23
+ emoji: '🧠',
24
+ label: 'deep focus',
25
+ priority: 1,
26
+ description: 'Long session, minimal messaging'
27
+ },
28
+ 'shipping': {
29
+ emoji: '🚀',
30
+ label: 'shipping',
31
+ priority: 2,
32
+ description: 'Active commits, on main/master branch'
33
+ },
34
+ 'debugging': {
35
+ emoji: '🐛',
36
+ label: 'debugging',
37
+ priority: 3,
38
+ description: 'Errors present or fix- branch'
39
+ },
40
+ 'exploring': {
41
+ emoji: '🔍',
42
+ label: 'exploring',
43
+ priority: 4,
44
+ description: 'Many file switches, few edits'
45
+ },
46
+ 'stuck': {
47
+ emoji: '🤔',
48
+ label: 'might be stuck',
49
+ priority: 5,
50
+ description: 'Same file for a while, no commits'
51
+ },
52
+ 'pairing': {
53
+ emoji: '👥',
54
+ label: 'pairing',
55
+ priority: 6,
56
+ description: 'Active messaging with one person'
57
+ },
58
+ 'late-night': {
59
+ emoji: '🌙',
60
+ label: 'late night',
61
+ priority: 7,
62
+ description: 'Coding after midnight local time'
63
+ }
64
+ };
65
+
66
+ /**
67
+ * Infer user state from context signals
68
+ *
69
+ * @param {Object} context - User's context from presence
70
+ * @param {string} context.file - Current file being edited
71
+ * @param {string} context.branch - Current git branch
72
+ * @param {string} context.error - Recent error message
73
+ * @param {string} context.note - User's note
74
+ * @param {string} context.mood - Explicit mood (if set)
75
+ * @param {number} context.sessionStart - Session start timestamp
76
+ * @param {number} context.lastMessage - Last message timestamp
77
+ * @param {number} context.messageCount - Messages in last hour
78
+ * @param {number} context.fileChangeCount - File changes in last 30min
79
+ * @param {string} context.lastCommit - Last commit timestamp
80
+ * @returns {Object|null} Inferred state or null if no strong signal
81
+ */
82
+ function inferState(context = {}) {
83
+ // If user has explicit mood set, respect it (no inference)
84
+ if (context.mood && !context.mood_inferred) {
85
+ return null;
86
+ }
87
+
88
+ const signals = analyzeSignals(context);
89
+ const candidates = [];
90
+
91
+ // Rule: GitHub Shipping (highest priority - real commits are undeniable)
92
+ // Active GitHub activity detected from cached activity data
93
+ if (signals.githubShippingMode === 'hot') {
94
+ candidates.push({
95
+ state: 'github-shipping',
96
+ confidence: 0.95, // Very high - based on actual commits
97
+ reason: signals.githubCommits > 0
98
+ ? `${signals.githubCommits} commits recently`
99
+ : 'active on GitHub'
100
+ });
101
+ } else if (signals.githubShippingMode === 'active') {
102
+ candidates.push({
103
+ state: 'github-shipping',
104
+ confidence: 0.85,
105
+ reason: 'pushing commits'
106
+ });
107
+ }
108
+
109
+ // Rule: Deep Focus
110
+ // Long session (2h+), minimal messaging in last hour
111
+ if (signals.sessionHours >= 2 && signals.messageCount < 2) {
112
+ candidates.push({
113
+ state: 'deep-focus',
114
+ confidence: Math.min(0.9, 0.5 + (signals.sessionHours - 2) * 0.1),
115
+ reason: `${signals.sessionHours}h session, focused`
116
+ });
117
+ }
118
+
119
+ // Rule: Debugging
120
+ // Has error OR on a fix/debug/bug branch
121
+ if (signals.hasError || signals.isDebugBranch) {
122
+ const confidence = signals.hasError ? 0.85 : 0.7;
123
+ const reason = signals.hasError
124
+ ? 'working through an error'
125
+ : `on ${context.branch}`;
126
+ candidates.push({
127
+ state: 'debugging',
128
+ confidence,
129
+ reason
130
+ });
131
+ }
132
+
133
+ // Rule: Shipping
134
+ // On main/master, recent commit activity
135
+ if (signals.isMainBranch && signals.recentCommit) {
136
+ candidates.push({
137
+ state: 'shipping',
138
+ confidence: 0.8,
139
+ reason: 'deploying to main'
140
+ });
141
+ }
142
+
143
+ // Rule: Stuck
144
+ // Same file for 30+ min, no commits
145
+ if (signals.sameFileDuration >= 30 && !signals.recentCommit) {
146
+ candidates.push({
147
+ state: 'stuck',
148
+ confidence: Math.min(0.7, 0.4 + (signals.sameFileDuration - 30) * 0.01),
149
+ reason: `${signals.sameFileDuration}min on same file`
150
+ });
151
+ }
152
+
153
+ // Rule: Exploring
154
+ // Many file changes, few edits (high switch rate)
155
+ if (signals.fileChangeCount >= 5 && signals.sessionHours < 1) {
156
+ candidates.push({
157
+ state: 'exploring',
158
+ confidence: 0.65,
159
+ reason: 'browsing codebase'
160
+ });
161
+ }
162
+
163
+ // Rule: Late Night
164
+ // After midnight, before 5am
165
+ if (signals.isLateNight) {
166
+ candidates.push({
167
+ state: 'late-night',
168
+ confidence: 0.75,
169
+ reason: 'burning midnight oil'
170
+ });
171
+ }
172
+
173
+ // Return highest confidence state above threshold
174
+ if (candidates.length === 0) return null;
175
+
176
+ candidates.sort((a, b) => b.confidence - a.confidence);
177
+ const best = candidates[0];
178
+
179
+ // Only return if confidence is high enough
180
+ if (best.confidence < 0.6) return null;
181
+
182
+ const stateInfo = STATES[best.state];
183
+ return {
184
+ state: best.state,
185
+ emoji: stateInfo.emoji,
186
+ label: stateInfo.label,
187
+ confidence: best.confidence,
188
+ reason: best.reason,
189
+ inferred: true
190
+ };
191
+ }
192
+
193
+ /**
194
+ * Analyze raw context into normalized signals
195
+ */
196
+ function analyzeSignals(context) {
197
+ const now = Date.now();
198
+
199
+ // Session duration in hours
200
+ const sessionStart = context.sessionStart || context.firstSeen || now;
201
+ const sessionHours = (now - sessionStart) / (1000 * 60 * 60);
202
+
203
+ // Branch analysis
204
+ const branch = (context.branch || '').toLowerCase();
205
+ const isDebugBranch = /^(fix|debug|bug|hotfix)[-_\/]/.test(branch);
206
+ const isMainBranch = ['main', 'master', 'production', 'prod'].includes(branch);
207
+
208
+ // Error present
209
+ const hasError = Boolean(context.error && context.error.length > 0);
210
+
211
+ // Time since last commit (in minutes)
212
+ const lastCommitTime = context.lastCommit ? new Date(context.lastCommit).getTime() : 0;
213
+ const minutesSinceCommit = lastCommitTime ? (now - lastCommitTime) / (1000 * 60) : Infinity;
214
+ const recentCommit = minutesSinceCommit < 30;
215
+
216
+ // File stickiness (how long on same file)
217
+ const sameFileDuration = context.sameFileSince
218
+ ? (now - context.sameFileSince) / (1000 * 60)
219
+ : 0;
220
+
221
+ // Message activity
222
+ const messageCount = context.messageCount || 0;
223
+
224
+ // File change frequency
225
+ const fileChangeCount = context.fileChangeCount || 0;
226
+
227
+ // Time of day check (local time)
228
+ const hour = new Date().getHours();
229
+ const isLateNight = hour >= 0 && hour < 5;
230
+
231
+ // GitHub activity signals (from presence enrichment)
232
+ const github = context.github || {};
233
+ const githubShippingMode = github.shipping_mode || null;
234
+ const githubCommits = github.total_commits || 0;
235
+
236
+ return {
237
+ sessionHours: Math.round(sessionHours * 10) / 10,
238
+ isDebugBranch,
239
+ isMainBranch,
240
+ hasError,
241
+ recentCommit,
242
+ sameFileDuration: Math.round(sameFileDuration),
243
+ messageCount,
244
+ fileChangeCount,
245
+ isLateNight,
246
+ // GitHub signals
247
+ githubShippingMode,
248
+ githubCommits
249
+ };
250
+ }
251
+
252
+ /**
253
+ * Get display text for inferred state
254
+ */
255
+ function formatInferredState(inference) {
256
+ if (!inference) return null;
257
+ return {
258
+ display: `${inference.emoji} ${inference.label} _(inferred)_`,
259
+ short: `${inference.emoji} ${inference.label}`,
260
+ reason: inference.reason
261
+ };
262
+ }
263
+
264
+ /**
265
+ * Enhance user data with inferred state
266
+ * Called when building presence list
267
+ */
268
+ function enhanceUserWithInference(user) {
269
+ // Build context from user data
270
+ const context = {
271
+ file: user.file,
272
+ branch: user.branch,
273
+ error: user.error,
274
+ note: user.note,
275
+ mood: user.mood,
276
+ mood_inferred: user.mood_inferred,
277
+ firstSeen: user.firstSeen,
278
+ sessionStart: user.firstSeen,
279
+ messageCount: user.messageCount || 0,
280
+ fileChangeCount: user.fileChangeCount || 0,
281
+ sameFileSince: user.sameFileSince,
282
+ lastCommit: user.lastCommit,
283
+ // GitHub activity data (from presence enrichment)
284
+ github: user.github || null
285
+ };
286
+
287
+ const inference = inferState(context);
288
+
289
+ if (inference) {
290
+ return {
291
+ ...user,
292
+ mood: inference.emoji,
293
+ mood_inferred: true,
294
+ mood_reason: inference.reason,
295
+ inferred_state: inference.state
296
+ };
297
+ }
298
+
299
+ return user;
300
+ }
301
+
302
+ /**
303
+ * Batch enhance multiple users
304
+ */
305
+ function enhanceUsersWithInference(users) {
306
+ return users.map(enhanceUserWithInference);
307
+ }
308
+
309
+ module.exports = {
310
+ STATES,
311
+ inferState,
312
+ analyzeSignals,
313
+ formatInferredState,
314
+ enhanceUserWithInference,
315
+ enhanceUsersWithInference
316
+ };