slashvibe-mcp 0.3.20 → 0.3.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -252
- package/analytics.js +107 -0
- package/auth-store.js +148 -0
- package/auto-update.js +130 -0
- package/bridges/bridge-monitor.js +388 -0
- package/bridges/discord-bot.js +431 -0
- package/bridges/farcaster.js +299 -0
- package/bridges/telegram.js +261 -0
- package/bridges/webhook-health.js +420 -0
- package/bridges/webhook-server.js +437 -0
- package/bridges/whatsapp.js +441 -0
- package/bridges/x-webhook.js +423 -0
- package/config.js +27 -15
- package/games/arcade.js +406 -0
- package/games/chess.js +451 -0
- package/games/colorguess.js +343 -0
- package/games/crossword-words.js +171 -0
- package/games/crossword.js +461 -0
- package/games/drawing.js +347 -0
- package/games/gameroulette.js +300 -0
- package/games/gamerouter.js +336 -0
- package/games/gamestatus.js +337 -0
- package/games/guessnumber.js +209 -0
- package/games/hangman.js +279 -0
- package/games/memory.js +338 -0
- package/games/multiplayer-tictactoe.js +389 -0
- package/games/pixelart.js +399 -0
- package/games/quickduel.js +354 -0
- package/games/riddle.js +371 -0
- package/games/rockpaperscissors.js +291 -0
- package/games/snake.js +406 -0
- package/games/storybuilder.js +343 -0
- package/games/tictactoe.js +345 -0
- package/games/twentyquestions.js +286 -0
- package/games/twotruths.js +207 -0
- package/games/werewolf.js +508 -0
- package/games/wordassociation.js +247 -0
- package/games/wordchain.js +135 -0
- package/index.js +116 -159
- package/intelligence/index.js +9 -2
- package/intelligence/interests.js +369 -0
- package/notification-emitter.js +77 -0
- package/notify.js +5 -1
- package/package.json +21 -16
- package/prompts.js +1 -1
- package/protocol/index.js +73 -0
- package/setup.js +480 -0
- package/smart-inbox.js +276 -0
- package/store/api.js +536 -215
- package/store/profiles.js +160 -12
- package/tools/_actions.js +362 -21
- package/tools/_discovery.js +119 -26
- package/tools/_shared/index.js +64 -0
- package/tools/_shared.js +234 -0
- package/tools/_work-context.js +338 -0
- package/tools/_work-context.manual-test.js +199 -0
- package/tools/_work-context.test.js +260 -0
- package/tools/activity.js +220 -0
- package/tools/analytics.js +191 -0
- package/tools/approve.js +197 -0
- package/tools/artifact-create.js +14 -3
- package/tools/artifacts-price.js +107 -0
- package/tools/available.js +120 -0
- package/tools/broadcast.js +325 -0
- package/tools/chat.js +202 -0
- package/tools/collaborative-drawing.js +1 -1
- package/tools/connection-status.js +178 -0
- package/tools/discover.js +350 -34
- package/tools/dm.js +80 -8
- package/tools/earnings.js +126 -0
- package/tools/feed.js +35 -4
- package/tools/follow.js +224 -0
- package/tools/friends.js +207 -0
- package/tools/gig-browse.js +206 -0
- package/tools/gig-complete.js +144 -0
- package/tools/health.js +87 -0
- package/tools/help.js +3 -3
- package/tools/idea.js +9 -2
- package/tools/inbox.js +289 -105
- package/tools/init.js +131 -34
- package/tools/invite.js +15 -4
- package/tools/leaderboard.js +117 -0
- package/tools/lib/git-apply.js +206 -0
- package/tools/lib/git-bundle.js +407 -0
- package/tools/migrate.js +3 -3
- package/tools/multiplayer-game.js +1 -1
- package/tools/onboarding.js +7 -7
- package/tools/open.js +143 -12
- package/tools/party-game.js +1 -1
- package/tools/plan.js +225 -0
- package/tools/proof-of-work.js +144 -0
- package/tools/reply.js +166 -0
- package/tools/report.js +1 -1
- package/tools/request.js +17 -3
- package/tools/schedule.js +367 -0
- package/tools/search-messages.js +123 -0
- package/tools/session.js +467 -0
- package/tools/session_price.js +128 -0
- package/tools/settings.js +90 -2
- package/tools/ship.js +30 -7
- package/tools/smart-check.js +201 -0
- package/tools/start.js +147 -12
- package/tools/status.js +53 -6
- package/tools/streak.js +147 -0
- package/tools/stuck.js +297 -0
- package/tools/subscribe.js +148 -0
- package/tools/subscriptions.js +134 -0
- package/tools/suggest-tags.js +6 -8
- package/tools/tag-suggestions.js +1 -1
- package/tools/tip.js +150 -77
- package/tools/token.js +4 -4
- package/tools/update.js +1 -1
- package/tools/wallet.js +221 -79
- package/tools/watch.js +157 -0
- package/tools/who.js +30 -1
- package/tools/withdraw.js +145 -0
- package/tools/work-summary.js +96 -0
- package/version.json +10 -8
- package/LICENSE +0 -21
- package/store/sqlite.js +0 -347
- /package/tools/{auto-suggest-connections.js → _deprecated/auto-suggest-connections.js} +0 -0
- /package/tools/{away.js → _deprecated/away.js} +0 -0
- /package/tools/{back.js → _deprecated/back.js} +0 -0
- /package/tools/{bootstrap-skills.js → _deprecated/bootstrap-skills.js} +0 -0
- /package/tools/{bridge-dashboard.js → _deprecated/bridge-dashboard.js} +0 -0
- /package/tools/{bridge-health.js → _deprecated/bridge-health.js} +0 -0
- /package/tools/{bridge-live.js → _deprecated/bridge-live.js} +0 -0
- /package/tools/{bridges.js → _deprecated/bridges.js} +0 -0
- /package/tools/{colorguess.js → _deprecated/colorguess.js} +0 -0
- /package/tools/{discover-insights.js → _deprecated/discover-insights.js} +0 -0
- /package/tools/{discover-momentum.js → _deprecated/discover-momentum.js} +0 -0
- /package/tools/{discovery-analytics.js → _deprecated/discovery-analytics.js} +0 -0
- /package/tools/{discovery-auto-suggest.js → _deprecated/discovery-auto-suggest.js} +0 -0
- /package/tools/{discovery-bootstrap.js → _deprecated/discovery-bootstrap.js} +0 -0
- /package/tools/{discovery-daily.js → _deprecated/discovery-daily.js} +0 -0
- /package/tools/{discovery-dashboard.js → _deprecated/discovery-dashboard.js} +0 -0
- /package/tools/{discovery-digest.js → _deprecated/discovery-digest.js} +0 -0
- /package/tools/{discovery-hub.js → _deprecated/discovery-hub.js} +0 -0
- /package/tools/{discovery-insights.js → _deprecated/discovery-insights.js} +0 -0
- /package/tools/{discovery-momentum.js → _deprecated/discovery-momentum.js} +0 -0
- /package/tools/{discovery-monitor.js → _deprecated/discovery-monitor.js} +0 -0
- /package/tools/{discovery-proactive.js → _deprecated/discovery-proactive.js} +0 -0
- /package/tools/{draw.js → _deprecated/draw.js} +0 -0
- /package/tools/{farcaster.js → _deprecated/farcaster.js} +0 -0
- /package/tools/{forget.js → _deprecated/forget.js} +0 -0
- /package/tools/{games-catalog.js → _deprecated/games-catalog.js} +0 -0
- /package/tools/{games.js → _deprecated/games.js} +0 -0
- /package/tools/{guessnumber.js → _deprecated/guessnumber.js} +0 -0
- /package/tools/{hangman.js → _deprecated/hangman.js} +0 -0
- /package/tools/{multiplayer-tictactoe.js → _deprecated/multiplayer-tictactoe.js} +0 -0
- /package/tools/{mute.js → _deprecated/mute.js} +0 -0
- /package/tools/{recall.js → _deprecated/recall.js} +0 -0
- /package/tools/{remember.js → _deprecated/remember.js} +0 -0
- /package/tools/{riddle.js → _deprecated/riddle.js} +0 -0
- /package/tools/{run-bootstrap.js → _deprecated/run-bootstrap.js} +0 -0
- /package/tools/{skills-analytics.js → _deprecated/skills-analytics.js} +0 -0
- /package/tools/{skills-bootstrap.js → _deprecated/skills-bootstrap.js} +0 -0
- /package/tools/{skills-dashboard.js → _deprecated/skills-dashboard.js} +0 -0
- /package/tools/{skills-exchange.js → _deprecated/skills-exchange.js} +0 -0
- /package/tools/{skills.js → _deprecated/skills.js} +0 -0
- /package/tools/{smart-intro.js → _deprecated/smart-intro.js} +0 -0
- /package/tools/{storybuilder.js → _deprecated/storybuilder.js} +0 -0
- /package/tools/{telegram-bot.js → _deprecated/telegram-bot.js} +0 -0
- /package/tools/{telegram-setup.js → _deprecated/telegram-setup.js} +0 -0
- /package/tools/{tictactoe.js → _deprecated/tictactoe.js} +0 -0
- /package/tools/{twentyquestions.js → _deprecated/twentyquestions.js} +0 -0
- /package/tools/{wordassociation.js → _deprecated/wordassociation.js} +0 -0
|
@@ -0,0 +1,367 @@
|
|
|
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 };
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vibe_search_messages - Search your DM history
|
|
3
|
+
*
|
|
4
|
+
* Search through all your conversations or filter to a specific person.
|
|
5
|
+
* Returns matching messages with context highlighting.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const config = require('../config');
|
|
9
|
+
const store = require('../store');
|
|
10
|
+
|
|
11
|
+
const searchMessagesSchema = {
|
|
12
|
+
name: 'vibe_search_messages',
|
|
13
|
+
description: 'Search through your DM history. Find messages by keyword across all conversations or with a specific person.',
|
|
14
|
+
inputSchema: {
|
|
15
|
+
type: 'object',
|
|
16
|
+
properties: {
|
|
17
|
+
query: {
|
|
18
|
+
type: 'string',
|
|
19
|
+
description: 'Search term (at least 2 characters)',
|
|
20
|
+
},
|
|
21
|
+
with: {
|
|
22
|
+
type: 'string',
|
|
23
|
+
description: 'Optional: Filter to conversation with specific user (e.g., @alice)',
|
|
24
|
+
},
|
|
25
|
+
limit: {
|
|
26
|
+
type: 'number',
|
|
27
|
+
description: 'Max results to return (default: 20)',
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
required: ['query'],
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
async function searchMessagesHandler({ query, with: withUser, limit = 20 }) {
|
|
35
|
+
const handle = config.getHandle();
|
|
36
|
+
if (!handle) {
|
|
37
|
+
return {
|
|
38
|
+
content: [
|
|
39
|
+
{
|
|
40
|
+
type: 'text',
|
|
41
|
+
text: '❌ Not initialized. Run `vibe init` first.',
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (!query || query.trim().length < 2) {
|
|
48
|
+
return {
|
|
49
|
+
content: [
|
|
50
|
+
{
|
|
51
|
+
type: 'text',
|
|
52
|
+
text: '❌ Search query must be at least 2 characters.',
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
const results = await store.searchMessages(query, {
|
|
60
|
+
with: withUser?.replace('@', ''),
|
|
61
|
+
limit: Math.min(limit, 50),
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
if (!results.messages || results.messages.length === 0) {
|
|
65
|
+
const scope = withUser ? ` in conversation with @${withUser.replace('@', '')}` : '';
|
|
66
|
+
return {
|
|
67
|
+
content: [
|
|
68
|
+
{
|
|
69
|
+
type: 'text',
|
|
70
|
+
text: `🔍 No messages found for "${query}"${scope}.`,
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Format results
|
|
77
|
+
let output = `🔍 **Search: "${query}"**\n`;
|
|
78
|
+
output += `Found ${results.total} message${results.total !== 1 ? 's' : ''}`;
|
|
79
|
+
if (withUser) {
|
|
80
|
+
output += ` with @${withUser.replace('@', '')}`;
|
|
81
|
+
}
|
|
82
|
+
output += '\n\n';
|
|
83
|
+
|
|
84
|
+
for (const msg of results.messages) {
|
|
85
|
+
const fromMe = msg.from === handle;
|
|
86
|
+
const direction = fromMe ? '→' : '←';
|
|
87
|
+
const other = fromMe ? msg.to : msg.from;
|
|
88
|
+
const date = new Date(msg.created_at).toLocaleDateString();
|
|
89
|
+
|
|
90
|
+
output += `**${direction} @${other}** (${date})\n`;
|
|
91
|
+
output += `> ${msg.match_preview}\n\n`;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (results.has_more) {
|
|
95
|
+
output += `_Showing ${results.count} of ${results.total} results. Add \`limit: ${limit + 20}\` for more._\n`;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return {
|
|
99
|
+
content: [
|
|
100
|
+
{
|
|
101
|
+
type: 'text',
|
|
102
|
+
text: output,
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
} catch (error) {
|
|
108
|
+
console.error('[search-messages] Error:', error);
|
|
109
|
+
return {
|
|
110
|
+
content: [
|
|
111
|
+
{
|
|
112
|
+
type: 'text',
|
|
113
|
+
text: `❌ Search failed: ${error.message}`,
|
|
114
|
+
},
|
|
115
|
+
],
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
module.exports = {
|
|
121
|
+
schema: searchMessagesSchema,
|
|
122
|
+
handler: searchMessagesHandler,
|
|
123
|
+
};
|