Repository navigation
Recording directory & mode directory at extension level, Ask Superwhisper, and Search History improvements - #26221
devmarkpro wants to merge 8 commits into
Conversation
- fix lint issues - Update preference to centralize recording directory configuration. - Implement recording directory configuration for copy/paste history functionality.
- fix contributer list - add ai command for ask-superwhisper - add ctrl+x hotkey for delete - move modeDir to extention level - add search and delete to search-history view - add mode icon to select-mode and search-history views
|
Thank you for your contribution! 🎉 🔔 @nchudleigh @jfkisafk @nagauta @Aayush9029 you might want to have a look. You can use this guide to learn how to check out the Pull Request locally in order to test it. 📋 Quick checkout commandsBRANCH="ext/superwhisper"
FORK_URL="https://github.com/devmarkpro/extensions.git"
EXTENSION_NAME="superwhisper"
REPO_NAME="extensions"
git clone -n --depth=1 --filter=tree:0 -b $BRANCH $FORK_URL
cd $REPO_NAME
git sparse-checkout set --no-cone "extensions/$EXTENSION_NAME"
git checkout
cd "extensions/$EXTENSION_NAME"
npm install && npm run devWe're currently experiencing a high volume of incoming requests. As a result, the initial review may take up to 10-15 business days. |
Greptile SummaryThis PR adds several improvements to the Superwhisper extension: Key points:
Confidence Score: 3/5
Important Files Changed
Last reviewed commit: ed75b3a |
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
- use trash instead of rmSync - Pull contributions
…' mode icon in select-mode
|
@nchudleigh do you want to check this? |
pernielsentikaer
left a comment
There was a problem hiding this comment.
Thanks for the update @devmarkpro
The ask-superwhisper tool is trying to be an AI assistant itself — it calls AI.ask inside the tool, manually ranks excerpts, and returns a finished answer string. This completely misunderstands the Raycast AI tools model.
How Raycast AI tools actually work:
Tool → returns raw data → Raycast AI reasons over it → answers the user
A tool is just a data provider. Its job is to fetch/read data and return it. Raycast AI is the one that reasons over the returned data and answers the user's question. The AI decides when and how to call the tool — the tool doesn't ask the AI anything
I converted this PR into a draft until it's ready for the review, please press the button Ready for review when it's ready and we'll have a look 😊
| { | ||
| "instructions": "When the user asks about their voice transcripts, what they said in recordings, or meeting notes from Superwhisper, call the ask-superwhisper tool with their question as the question argument. Use this tool only for questions about the user's own transcript content.", | ||
| "evals": [ | ||
| { | ||
| "input": "@superwhisper What did I say about the project deadline?", | ||
| "mocks": { | ||
| "ask-superwhisper": [ | ||
| "Based on your transcripts: You mentioned the project deadline in recording from 2024-01-15. You said the deadline is next Friday." | ||
| ] | ||
| }, | ||
| "expected": [ | ||
| { | ||
| "callsTool": { | ||
| "name": "ask-superwhisper", | ||
| "arguments": { | ||
| "question": { | ||
| "includes": "deadline" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "input": "@superwhisper Summarize what I said in my last meeting notes.", | ||
| "mocks": { | ||
| "ask-superwhisper": [ | ||
| "Summary from your transcripts: You discussed three action items and assigned owners. The next meeting is set for next week." | ||
| ] | ||
| }, | ||
| "expected": [ | ||
| { | ||
| "callsTool": "ask-superwhisper" | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } |
There was a problem hiding this comment.
| { | |
| "instructions": "When the user asks about their voice transcripts, what they said in recordings, or meeting notes from Superwhisper, call the ask-superwhisper tool with their question as the question argument. Use this tool only for questions about the user's own transcript content.", | |
| "evals": [ | |
| { | |
| "input": "@superwhisper What did I say about the project deadline?", | |
| "mocks": { | |
| "ask-superwhisper": [ | |
| "Based on your transcripts: You mentioned the project deadline in recording from 2024-01-15. You said the deadline is next Friday." | |
| ] | |
| }, | |
| "expected": [ | |
| { | |
| "callsTool": { | |
| "name": "ask-superwhisper", | |
| "arguments": { | |
| "question": { | |
| "includes": "deadline" | |
| } | |
| } | |
| } | |
| } | |
| ] | |
| }, | |
| { | |
| "input": "@superwhisper Summarize what I said in my last meeting notes.", | |
| "mocks": { | |
| "ask-superwhisper": [ | |
| "Summary from your transcripts: You discussed three action items and assigned owners. The next meeting is set for next week." | |
| ] | |
| }, | |
| "expected": [ | |
| { | |
| "callsTool": "ask-superwhisper" | |
| } | |
| ] | |
| } | |
| ] | |
| } | |
| { | |
| "instructions": "When the user asks about their voice recordings, transcripts, meeting notes, or anything related to their Superwhisper history, call the ask-superwhisper tool. Use the optional searchQuery argument to filter by keyword when the user is looking for something specific. Leave searchQuery empty when the user wants a summary, statistics, or their most recent recordings.", | |
| "evals": [ | |
| { | |
| "input": "@superwhisper What did I say about the project deadline?", | |
| "mocks": { | |
| "ask-superwhisper": { | |
| "totalRecordings": 42, | |
| "returnedRecordings": 1, | |
| "recordings": [ | |
| { | |
| "date": "2024-01-15 10:30", | |
| "transcript": "We need to wrap up the project deadline by next Friday. Everyone should submit their parts by Thursday at the latest.", | |
| "durationMs": 95000, | |
| "mode": "General", | |
| "transcriptionModel": "whisper-large-v3", | |
| "languageModel": "gpt-4o" | |
| } | |
| ] | |
| } | |
| }, | |
| "expected": [ | |
| { | |
| "callsTool": { | |
| "name": "ask-superwhisper", | |
| "arguments": { | |
| "searchQuery": { | |
| "includes": "deadline" | |
| } | |
| } | |
| } | |
| }, | |
| { | |
| "includes": "friday" | |
| } | |
| ] | |
| }, | |
| { | |
| "input": "@superwhisper Summarize my most recent recording.", | |
| "mocks": { | |
| "ask-superwhisper": { | |
| "totalRecordings": 42, | |
| "returnedRecordings": 1, | |
| "recordings": [ | |
| { | |
| "date": "2024-01-20 09:15", | |
| "transcript": "Quick note: follow up with the design team about the new dashboard mockups. Also remember to book the flight for the conference next month.", | |
| "durationMs": 48000, | |
| "mode": "General", | |
| "transcriptionModel": "whisper-large-v3", | |
| "languageModel": "gpt-4o" | |
| } | |
| ] | |
| } | |
| }, | |
| "expected": [ | |
| { | |
| "callsTool": "ask-superwhisper" | |
| }, | |
| { | |
| "meetsCriteria": "Summarizes the content of the most recent recording" | |
| } | |
| ] | |
| }, | |
| { | |
| "input": "@superwhisper How many recordings do I have?", | |
| "mocks": { | |
| "ask-superwhisper": { | |
| "totalRecordings": 42, | |
| "returnedRecordings": 20, | |
| "recordings": [] | |
| } | |
| }, | |
| "expected": [ | |
| { | |
| "callsTool": "ask-superwhisper" | |
| }, | |
| { | |
| "includes": "42" | |
| } | |
| ] | |
| } | |
| ] | |
| } |
| import { AI, environment, getPreferenceValues } from "@raycast/api"; | ||
| import { homedir } from "os"; | ||
| import { join } from "path"; | ||
| import { format, startOfDay, subDays } from "date-fns"; | ||
| import { getRecordings, getRecordingPrimaryText, type Recording } from "../hooks"; | ||
|
|
||
| const DEFAULT_RECORDINGS_PATH = join(homedir(), "Documents", "superwhisper", "recordings"); | ||
| const MAX_EXCERPTS = 10; | ||
| const EXCERPT_WINDOW = 300; | ||
|
|
||
| type RecordingStats = { | ||
| total: number; | ||
| yesterday: number; | ||
| today: number; | ||
| last7Days: number; | ||
| }; | ||
|
|
||
| function getRecordingStats(recordings: Recording[]): RecordingStats { | ||
| const now = new Date(); | ||
| const todayStart = startOfDay(now); | ||
| const yesterdayStart = startOfDay(subDays(now, 1)); | ||
| const sevenDaysAgo = subDays(todayStart, 7); | ||
|
|
||
| let yesterday = 0; | ||
| let today = 0; | ||
| let last7Days = 0; | ||
|
|
||
| for (const r of recordings) { | ||
| const t = r.timestamp.getTime(); | ||
| if (t >= yesterdayStart.getTime() && t < todayStart.getTime()) yesterday += 1; | ||
| else if (t >= todayStart.getTime()) today += 1; | ||
| if (t >= sevenDaysAgo.getTime()) last7Days += 1; | ||
| } | ||
|
|
||
| return { | ||
| total: recordings.length, | ||
| yesterday, | ||
| today, | ||
| last7Days, | ||
| }; | ||
| } | ||
|
|
||
| type MetadataSummary = { | ||
| modeCounts: Record<string, number>; | ||
| modelCounts: Record<string, number>; | ||
| languageModelCounts: Record<string, number>; | ||
| }; | ||
|
|
||
| const MS_PER_MIN = 60 * 1000; | ||
| const MS_PER_HOUR = 60 * MS_PER_MIN; | ||
|
|
||
| function buildMetadataSummary(recordings: Recording[]): MetadataSummary { | ||
| const modeCounts: Record<string, number> = {}; | ||
| const modelCounts: Record<string, number> = {}; | ||
| const languageModelCounts: Record<string, number> = {}; | ||
|
|
||
| for (const r of recordings) { | ||
| const m = r.meta; | ||
| if (m.modeName?.trim()) { | ||
| const name = m.modeName.trim(); | ||
| modeCounts[name] = (modeCounts[name] ?? 0) + 1; | ||
| } | ||
| if (m.modelName?.trim()) { | ||
| const name = m.modelName.trim(); | ||
| modelCounts[name] = (modelCounts[name] ?? 0) + 1; | ||
| } | ||
| if (m.languageModelName?.trim()) { | ||
| const name = m.languageModelName.trim(); | ||
| languageModelCounts[name] = (languageModelCounts[name] ?? 0) + 1; | ||
| } | ||
| } | ||
|
|
||
| return { | ||
| modeCounts, | ||
| modelCounts, | ||
| languageModelCounts, | ||
| }; | ||
| } | ||
|
|
||
| /** Parse a duration threshold from the question (e.g. "longer than 45 minutes", "over 2 hours"). Returns ms and a label for the answer. */ | ||
| function parseDurationThreshold(question: string): { valueMs: number; label: string } | null { | ||
| const q = question.toLowerCase(); | ||
| const durationIntent = | ||
| q.includes("longer than") || q.includes("over") || q.includes("more than") || q.includes("at least"); | ||
| if (!durationIntent && !q.includes("minute") && !q.includes("hour") && !q.includes(" min") && !q.includes(" hr")) { | ||
| return null; | ||
| } | ||
| // Match "30 minutes", "45 min", "1.5 hours", "2 hours", "90 min", etc. | ||
| const minMatch = question.match(/(\d+(?:\.\d+)?)\s*(?:minute|min)s?/i); | ||
| const hourMatch = question.match(/(\d+(?:\.\d+)?)\s*(?:hour|hr)s?/i); | ||
| if (minMatch) { | ||
| const value = parseFloat(minMatch[1]); | ||
| if (Number.isFinite(value) && value > 0) { | ||
| const valueMs = value * MS_PER_MIN; | ||
| const label = value === 1 ? "1 minute" : `${value} minutes`; | ||
| return { valueMs, label }; | ||
| } | ||
| } | ||
| if (hourMatch) { | ||
| const value = parseFloat(hourMatch[1]); | ||
| if (Number.isFinite(value) && value > 0) { | ||
| const valueMs = value * MS_PER_HOUR; | ||
| const label = value === 1 ? "1 hour" : `${value} hours`; | ||
| return { valueMs, label }; | ||
| } | ||
| } | ||
| return null; | ||
| } | ||
|
|
||
| function formatMetadataSummaryBlock(summary: MetadataSummary): string { | ||
| const lines: string[] = [ | ||
| "Recording metadata (use for questions about mode, duration, or model):", | ||
| "For duration: each recording has a duration in ms; user can ask e.g. 'how many longer than 45 minutes' or 'over 2 hours'.", | ||
| ]; | ||
| if (Object.keys(summary.modeCounts).length > 0) { | ||
| const modeList = Object.entries(summary.modeCounts) | ||
| .map(([name, n]) => ` - "${name}": ${n}`) | ||
| .join("\n"); | ||
| lines.push("By mode:\n" + modeList); | ||
| } | ||
| if (Object.keys(summary.modelCounts).length > 0) { | ||
| const modelList = Object.entries(summary.modelCounts) | ||
| .map(([name, n]) => ` - "${name}": ${n}`) | ||
| .join("\n"); | ||
| lines.push("By transcription model (modelName):\n" + modelList); | ||
| } | ||
| if (Object.keys(summary.languageModelCounts).length > 0) { | ||
| const llmList = Object.entries(summary.languageModelCounts) | ||
| .map(([name, n]) => ` - "${name}": ${n}`) | ||
| .join("\n"); | ||
| lines.push("By language model (languageModelName):\n" + llmList); | ||
| } | ||
| return lines.join("\n") + "\n\n"; | ||
| } | ||
|
|
||
| /** Build the full context block (stats + metadata). Optionally append a duration count line when the question mentions a duration threshold. */ | ||
| function buildFullContextBlock( | ||
| stats: RecordingStats, | ||
| metadataSummary: MetadataSummary, | ||
| question: string, | ||
| recordings: Recording[], | ||
| ): string { | ||
| let block = `Recording statistics (each folder = one recording/meeting): | ||
| - Total recordings: ${stats.total} | ||
| - Recordings yesterday: ${stats.yesterday} | ||
| - Recordings today: ${stats.today} | ||
| - Recordings in the last 7 days: ${stats.last7Days} | ||
|
|
||
| ${formatMetadataSummaryBlock(metadataSummary)}`; | ||
| const durationThreshold = parseDurationThreshold(question); | ||
| if (durationThreshold) { | ||
| const count = recordings.filter( | ||
| (r) => typeof r.meta.duration === "number" && r.meta.duration >= durationThreshold.valueMs, | ||
| ).length; | ||
| block += `Recordings longer than ${durationThreshold.label}: ${count}\n\n`; | ||
| } | ||
| return block; | ||
| } | ||
|
|
||
| type Input = { | ||
| /** | ||
| * The user's question about their voice transcripts (e.g. "What did I say about the project deadline?"). | ||
| * Pass the user's exact question when they ask about their Superwhisper recordings. | ||
| */ | ||
| question: string; | ||
| }; | ||
|
|
||
| /** | ||
| * Search the user's Superwhisper transcripts and answer their question using AI. | ||
| * Use this when the user asks about their voice recordings, meeting notes, or what they said in past transcripts. | ||
| */ | ||
| export default async function askSuperwhisper(input: Input): Promise<string> { | ||
| const question = input.question?.trim(); | ||
| if (!question) { | ||
| return "Please ask a question about your transcripts (e.g. what you said about a topic, or a summary of your recordings)."; | ||
| } | ||
|
|
||
| if (!environment.canAccess(AI)) { | ||
| return "Raycast Pro is required to use AI for searching your transcripts. Please upgrade to use this feature."; | ||
| } | ||
|
|
||
| const prefs = getPreferenceValues<Preferences>(); | ||
| const recordingsPath = prefs.recordingDir || DEFAULT_RECORDINGS_PATH; | ||
|
|
||
| let recordings: Recording[]; | ||
| try { | ||
| recordings = await getRecordings(recordingsPath); | ||
| } catch (err) { | ||
| const message = err instanceof Error ? err.message : String(err); | ||
| return `Could not load recordings: ${message}. Please check that Superwhisper is installed and you have made at least one recording.`; | ||
| } | ||
|
|
||
| if (recordings.length === 0) { | ||
| return "No recordings found. Make a recording with Superwhisper first, then ask again."; | ||
| } | ||
|
|
||
| const stats = getRecordingStats(recordings); | ||
| const metadataSummary = buildMetadataSummary(recordings); | ||
|
|
||
| const corpus = recordings.map((r) => ({ | ||
| id: r.directory, | ||
| timestamp: r.timestamp, | ||
| text: getRecordingPrimaryText(r.meta), | ||
| })); | ||
|
|
||
| const textsWithContent = corpus.filter((c) => c.text.length > 0); | ||
| const contextBlock = buildFullContextBlock(stats, metadataSummary, question, recordings); | ||
|
|
||
| let excerptBlock: string; | ||
| if (textsWithContent.length === 0) { | ||
| excerptBlock = "No transcript content is available in your recordings (meta may be missing llmResult/rawResult)."; | ||
| } else { | ||
| let refinedQuery: string; | ||
| try { | ||
| refinedQuery = await AI.ask( | ||
| `You are helping refine a search query. The user will ask a question about their voice transcripts. Output ONLY a short search query (keywords or phrase, no full sentence) that would best find relevant transcript content. Do not explain. Output nothing else. | ||
|
|
||
| User question: ${question}`, | ||
| { creativity: "none" }, | ||
| ); | ||
| } catch (err) { | ||
| return "Failed to prepare the search. Please try again."; | ||
| } | ||
|
|
||
| const query = refinedQuery.trim() || question; | ||
| const queryLower = query.toLowerCase(); | ||
| const terms = queryLower.split(/\s+/).filter(Boolean); | ||
|
|
||
| type Match = { id: string; date: string; excerpt: string; score: number }; | ||
| const matches: Match[] = []; | ||
|
|
||
| for (const item of textsWithContent) { | ||
| const text = item.text; | ||
| const textLower = text.toLowerCase(); | ||
| let score = 0; | ||
| if (terms.length === 0) { | ||
| score = 1; | ||
| } else { | ||
| for (const term of terms) { | ||
| if (textLower.includes(term)) score += 1; | ||
| } | ||
| } | ||
| if (score === 0) continue; | ||
|
|
||
| const anchorTerm = terms.find((t) => textLower.includes(t)); | ||
| const idx = anchorTerm ? textLower.indexOf(anchorTerm) : 0; | ||
| const start = Math.max(0, idx - EXCERPT_WINDOW); | ||
| const end = Math.min(text.length, idx + (anchorTerm?.length ?? 0) + EXCERPT_WINDOW); | ||
| let excerpt = text.slice(start, end); | ||
| if (start > 0) excerpt = "…" + excerpt; | ||
| if (end < text.length) excerpt = excerpt + "…"; | ||
|
|
||
| matches.push({ | ||
| id: item.id, | ||
| date: format(item.timestamp, "yyyy-MM-dd HH:mm"), | ||
| excerpt, | ||
| score, | ||
| }); | ||
| } | ||
|
|
||
| matches.sort((a, b) => b.score - a.score); | ||
| const top = matches.slice(0, MAX_EXCERPTS); | ||
|
|
||
| if (top.length === 0) { | ||
| excerptBlock = "No transcript excerpts found for this query."; | ||
| } else { | ||
| excerptBlock = top.map((m) => `[Recording ${m.id} (${m.date})]\n${m.excerpt}`).join("\n\n---\n\n"); | ||
| } | ||
| } | ||
|
|
||
| try { | ||
| const answer = await AI.ask( | ||
| `You have the following recording statistics and metadata. Use them to answer count and metadata questions (e.g. how many recordings, how many in a mode, how many longer than X, which model). When transcript excerpts are provided below, use them for content questions (e.g. what was said about a topic). Answer only from this data; if the answer is not here, say so. When relevant, mention which recording or date the information came from. | ||
|
|
||
| User question: ${question} | ||
|
|
||
| ${contextBlock} | ||
| Transcript excerpts: | ||
| ${excerptBlock}`, | ||
| { creativity: "low" }, | ||
| ); | ||
| return answer.trim(); | ||
| } catch (err) { | ||
| return "Failed to generate an answer from your transcripts. Please try again."; | ||
| } | ||
| } |
There was a problem hiding this comment.
| import { AI, environment, getPreferenceValues } from "@raycast/api"; | |
| import { homedir } from "os"; | |
| import { join } from "path"; | |
| import { format, startOfDay, subDays } from "date-fns"; | |
| import { getRecordings, getRecordingPrimaryText, type Recording } from "../hooks"; | |
| const DEFAULT_RECORDINGS_PATH = join(homedir(), "Documents", "superwhisper", "recordings"); | |
| const MAX_EXCERPTS = 10; | |
| const EXCERPT_WINDOW = 300; | |
| type RecordingStats = { | |
| total: number; | |
| yesterday: number; | |
| today: number; | |
| last7Days: number; | |
| }; | |
| function getRecordingStats(recordings: Recording[]): RecordingStats { | |
| const now = new Date(); | |
| const todayStart = startOfDay(now); | |
| const yesterdayStart = startOfDay(subDays(now, 1)); | |
| const sevenDaysAgo = subDays(todayStart, 7); | |
| let yesterday = 0; | |
| let today = 0; | |
| let last7Days = 0; | |
| for (const r of recordings) { | |
| const t = r.timestamp.getTime(); | |
| if (t >= yesterdayStart.getTime() && t < todayStart.getTime()) yesterday += 1; | |
| else if (t >= todayStart.getTime()) today += 1; | |
| if (t >= sevenDaysAgo.getTime()) last7Days += 1; | |
| } | |
| return { | |
| total: recordings.length, | |
| yesterday, | |
| today, | |
| last7Days, | |
| }; | |
| } | |
| type MetadataSummary = { | |
| modeCounts: Record<string, number>; | |
| modelCounts: Record<string, number>; | |
| languageModelCounts: Record<string, number>; | |
| }; | |
| const MS_PER_MIN = 60 * 1000; | |
| const MS_PER_HOUR = 60 * MS_PER_MIN; | |
| function buildMetadataSummary(recordings: Recording[]): MetadataSummary { | |
| const modeCounts: Record<string, number> = {}; | |
| const modelCounts: Record<string, number> = {}; | |
| const languageModelCounts: Record<string, number> = {}; | |
| for (const r of recordings) { | |
| const m = r.meta; | |
| if (m.modeName?.trim()) { | |
| const name = m.modeName.trim(); | |
| modeCounts[name] = (modeCounts[name] ?? 0) + 1; | |
| } | |
| if (m.modelName?.trim()) { | |
| const name = m.modelName.trim(); | |
| modelCounts[name] = (modelCounts[name] ?? 0) + 1; | |
| } | |
| if (m.languageModelName?.trim()) { | |
| const name = m.languageModelName.trim(); | |
| languageModelCounts[name] = (languageModelCounts[name] ?? 0) + 1; | |
| } | |
| } | |
| return { | |
| modeCounts, | |
| modelCounts, | |
| languageModelCounts, | |
| }; | |
| } | |
| /** Parse a duration threshold from the question (e.g. "longer than 45 minutes", "over 2 hours"). Returns ms and a label for the answer. */ | |
| function parseDurationThreshold(question: string): { valueMs: number; label: string } | null { | |
| const q = question.toLowerCase(); | |
| const durationIntent = | |
| q.includes("longer than") || q.includes("over") || q.includes("more than") || q.includes("at least"); | |
| if (!durationIntent && !q.includes("minute") && !q.includes("hour") && !q.includes(" min") && !q.includes(" hr")) { | |
| return null; | |
| } | |
| // Match "30 minutes", "45 min", "1.5 hours", "2 hours", "90 min", etc. | |
| const minMatch = question.match(/(\d+(?:\.\d+)?)\s*(?:minute|min)s?/i); | |
| const hourMatch = question.match(/(\d+(?:\.\d+)?)\s*(?:hour|hr)s?/i); | |
| if (minMatch) { | |
| const value = parseFloat(minMatch[1]); | |
| if (Number.isFinite(value) && value > 0) { | |
| const valueMs = value * MS_PER_MIN; | |
| const label = value === 1 ? "1 minute" : `${value} minutes`; | |
| return { valueMs, label }; | |
| } | |
| } | |
| if (hourMatch) { | |
| const value = parseFloat(hourMatch[1]); | |
| if (Number.isFinite(value) && value > 0) { | |
| const valueMs = value * MS_PER_HOUR; | |
| const label = value === 1 ? "1 hour" : `${value} hours`; | |
| return { valueMs, label }; | |
| } | |
| } | |
| return null; | |
| } | |
| function formatMetadataSummaryBlock(summary: MetadataSummary): string { | |
| const lines: string[] = [ | |
| "Recording metadata (use for questions about mode, duration, or model):", | |
| "For duration: each recording has a duration in ms; user can ask e.g. 'how many longer than 45 minutes' or 'over 2 hours'.", | |
| ]; | |
| if (Object.keys(summary.modeCounts).length > 0) { | |
| const modeList = Object.entries(summary.modeCounts) | |
| .map(([name, n]) => ` - "${name}": ${n}`) | |
| .join("\n"); | |
| lines.push("By mode:\n" + modeList); | |
| } | |
| if (Object.keys(summary.modelCounts).length > 0) { | |
| const modelList = Object.entries(summary.modelCounts) | |
| .map(([name, n]) => ` - "${name}": ${n}`) | |
| .join("\n"); | |
| lines.push("By transcription model (modelName):\n" + modelList); | |
| } | |
| if (Object.keys(summary.languageModelCounts).length > 0) { | |
| const llmList = Object.entries(summary.languageModelCounts) | |
| .map(([name, n]) => ` - "${name}": ${n}`) | |
| .join("\n"); | |
| lines.push("By language model (languageModelName):\n" + llmList); | |
| } | |
| return lines.join("\n") + "\n\n"; | |
| } | |
| /** Build the full context block (stats + metadata). Optionally append a duration count line when the question mentions a duration threshold. */ | |
| function buildFullContextBlock( | |
| stats: RecordingStats, | |
| metadataSummary: MetadataSummary, | |
| question: string, | |
| recordings: Recording[], | |
| ): string { | |
| let block = `Recording statistics (each folder = one recording/meeting): | |
| - Total recordings: ${stats.total} | |
| - Recordings yesterday: ${stats.yesterday} | |
| - Recordings today: ${stats.today} | |
| - Recordings in the last 7 days: ${stats.last7Days} | |
| ${formatMetadataSummaryBlock(metadataSummary)}`; | |
| const durationThreshold = parseDurationThreshold(question); | |
| if (durationThreshold) { | |
| const count = recordings.filter( | |
| (r) => typeof r.meta.duration === "number" && r.meta.duration >= durationThreshold.valueMs, | |
| ).length; | |
| block += `Recordings longer than ${durationThreshold.label}: ${count}\n\n`; | |
| } | |
| return block; | |
| } | |
| type Input = { | |
| /** | |
| * The user's question about their voice transcripts (e.g. "What did I say about the project deadline?"). | |
| * Pass the user's exact question when they ask about their Superwhisper recordings. | |
| */ | |
| question: string; | |
| }; | |
| /** | |
| * Search the user's Superwhisper transcripts and answer their question using AI. | |
| * Use this when the user asks about their voice recordings, meeting notes, or what they said in past transcripts. | |
| */ | |
| export default async function askSuperwhisper(input: Input): Promise<string> { | |
| const question = input.question?.trim(); | |
| if (!question) { | |
| return "Please ask a question about your transcripts (e.g. what you said about a topic, or a summary of your recordings)."; | |
| } | |
| if (!environment.canAccess(AI)) { | |
| return "Raycast Pro is required to use AI for searching your transcripts. Please upgrade to use this feature."; | |
| } | |
| const prefs = getPreferenceValues<Preferences>(); | |
| const recordingsPath = prefs.recordingDir || DEFAULT_RECORDINGS_PATH; | |
| let recordings: Recording[]; | |
| try { | |
| recordings = await getRecordings(recordingsPath); | |
| } catch (err) { | |
| const message = err instanceof Error ? err.message : String(err); | |
| return `Could not load recordings: ${message}. Please check that Superwhisper is installed and you have made at least one recording.`; | |
| } | |
| if (recordings.length === 0) { | |
| return "No recordings found. Make a recording with Superwhisper first, then ask again."; | |
| } | |
| const stats = getRecordingStats(recordings); | |
| const metadataSummary = buildMetadataSummary(recordings); | |
| const corpus = recordings.map((r) => ({ | |
| id: r.directory, | |
| timestamp: r.timestamp, | |
| text: getRecordingPrimaryText(r.meta), | |
| })); | |
| const textsWithContent = corpus.filter((c) => c.text.length > 0); | |
| const contextBlock = buildFullContextBlock(stats, metadataSummary, question, recordings); | |
| let excerptBlock: string; | |
| if (textsWithContent.length === 0) { | |
| excerptBlock = "No transcript content is available in your recordings (meta may be missing llmResult/rawResult)."; | |
| } else { | |
| let refinedQuery: string; | |
| try { | |
| refinedQuery = await AI.ask( | |
| `You are helping refine a search query. The user will ask a question about their voice transcripts. Output ONLY a short search query (keywords or phrase, no full sentence) that would best find relevant transcript content. Do not explain. Output nothing else. | |
| User question: ${question}`, | |
| { creativity: "none" }, | |
| ); | |
| } catch (err) { | |
| return "Failed to prepare the search. Please try again."; | |
| } | |
| const query = refinedQuery.trim() || question; | |
| const queryLower = query.toLowerCase(); | |
| const terms = queryLower.split(/\s+/).filter(Boolean); | |
| type Match = { id: string; date: string; excerpt: string; score: number }; | |
| const matches: Match[] = []; | |
| for (const item of textsWithContent) { | |
| const text = item.text; | |
| const textLower = text.toLowerCase(); | |
| let score = 0; | |
| if (terms.length === 0) { | |
| score = 1; | |
| } else { | |
| for (const term of terms) { | |
| if (textLower.includes(term)) score += 1; | |
| } | |
| } | |
| if (score === 0) continue; | |
| const anchorTerm = terms.find((t) => textLower.includes(t)); | |
| const idx = anchorTerm ? textLower.indexOf(anchorTerm) : 0; | |
| const start = Math.max(0, idx - EXCERPT_WINDOW); | |
| const end = Math.min(text.length, idx + (anchorTerm?.length ?? 0) + EXCERPT_WINDOW); | |
| let excerpt = text.slice(start, end); | |
| if (start > 0) excerpt = "…" + excerpt; | |
| if (end < text.length) excerpt = excerpt + "…"; | |
| matches.push({ | |
| id: item.id, | |
| date: format(item.timestamp, "yyyy-MM-dd HH:mm"), | |
| excerpt, | |
| score, | |
| }); | |
| } | |
| matches.sort((a, b) => b.score - a.score); | |
| const top = matches.slice(0, MAX_EXCERPTS); | |
| if (top.length === 0) { | |
| excerptBlock = "No transcript excerpts found for this query."; | |
| } else { | |
| excerptBlock = top.map((m) => `[Recording ${m.id} (${m.date})]\n${m.excerpt}`).join("\n\n---\n\n"); | |
| } | |
| } | |
| try { | |
| const answer = await AI.ask( | |
| `You have the following recording statistics and metadata. Use them to answer count and metadata questions (e.g. how many recordings, how many in a mode, how many longer than X, which model). When transcript excerpts are provided below, use them for content questions (e.g. what was said about a topic). Answer only from this data; if the answer is not here, say so. When relevant, mention which recording or date the information came from. | |
| User question: ${question} | |
| ${contextBlock} | |
| Transcript excerpts: | |
| ${excerptBlock}`, | |
| { creativity: "low" }, | |
| ); | |
| return answer.trim(); | |
| } catch (err) { | |
| return "Failed to generate an answer from your transcripts. Please try again."; | |
| } | |
| } | |
| import { getPreferenceValues } from "@raycast/api"; | |
| import { homedir } from "os"; | |
| import { join } from "path"; | |
| import { format } from "date-fns"; | |
| import { getRecordings, getRecordingPrimaryText } from "../hooks"; | |
| const DEFAULT_RECORDINGS_PATH = join(homedir(), "Documents", "superwhisper", "recordings"); | |
| type Input = { | |
| /** | |
| * Optional keyword(s) to filter recordings by their transcript content. | |
| * Leave empty to return all recordings. | |
| */ | |
| searchQuery?: string; | |
| /** | |
| * Maximum number of recordings to return. Defaults to 20. | |
| */ | |
| limit?: number; | |
| }; | |
| /** | |
| * Returns the user's Superwhisper voice recordings and their transcripts. | |
| * Use this when the user asks about their voice recordings, meeting notes, | |
| * what they said in past transcripts, recording statistics, or anything | |
| * related to their Superwhisper history. | |
| */ | |
| export default async function tool(input: Input) { | |
| const prefs = getPreferenceValues<Preferences>(); | |
| const recordingsPath = prefs.recordingDir || DEFAULT_RECORDINGS_PATH; | |
| const recordings = await getRecordings(recordingsPath); | |
| const limit = input.limit ?? 20; | |
| const query = input.searchQuery?.toLowerCase().trim(); | |
| const filtered = query | |
| ? recordings.filter((r) => getRecordingPrimaryText(r.meta).toLowerCase().includes(query)) | |
| : recordings; | |
| const results = filtered.slice(0, limit).map((r) => ({ | |
| date: format(r.timestamp, "yyyy-MM-dd HH:mm"), | |
| transcript: getRecordingPrimaryText(r.meta), | |
| durationMs: r.meta.duration, | |
| mode: r.meta.modeName, | |
| transcriptionModel: r.meta.modelName, | |
| languageModel: r.meta.languageModelName, | |
| })); | |
| return { | |
| totalRecordings: recordings.length, | |
| returnedRecordings: results.length, | |
| recordings: results, | |
| }; | |
| } |
| { | ||
| "instructions": "When the user asks about their voice transcripts, what they said in recordings, or meeting notes from Superwhisper, call the ask-superwhisper tool with their question as the question argument. Use this tool only for questions about the user's own transcript content.", | ||
| "evals": [ | ||
| { | ||
| "input": "@superwhisper What did I say about the project deadline?", | ||
| "mocks": { | ||
| "ask-superwhisper": [ | ||
| "Based on your transcripts: You mentioned the project deadline in recording from 2024-01-15. You said the deadline is next Friday." | ||
| ] | ||
| }, | ||
| "expected": [ | ||
| { | ||
| "callsTool": { | ||
| "name": "ask-superwhisper", | ||
| "arguments": { | ||
| "question": { | ||
| "includes": "deadline" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "input": "@superwhisper Summarize what I said in my last meeting notes.", | ||
| "mocks": { | ||
| "ask-superwhisper": [ | ||
| "Summary from your transcripts: You discussed three action items and assigned owners. The next meeting is set for next week." | ||
| ] | ||
| }, | ||
| "expected": [ | ||
| { | ||
| "callsTool": "ask-superwhisper" | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } |
There was a problem hiding this comment.
| { | |
| "instructions": "When the user asks about their voice transcripts, what they said in recordings, or meeting notes from Superwhisper, call the ask-superwhisper tool with their question as the question argument. Use this tool only for questions about the user's own transcript content.", | |
| "evals": [ | |
| { | |
| "input": "@superwhisper What did I say about the project deadline?", | |
| "mocks": { | |
| "ask-superwhisper": [ | |
| "Based on your transcripts: You mentioned the project deadline in recording from 2024-01-15. You said the deadline is next Friday." | |
| ] | |
| }, | |
| "expected": [ | |
| { | |
| "callsTool": { | |
| "name": "ask-superwhisper", | |
| "arguments": { | |
| "question": { | |
| "includes": "deadline" | |
| } | |
| } | |
| } | |
| } | |
| ] | |
| }, | |
| { | |
| "input": "@superwhisper Summarize what I said in my last meeting notes.", | |
| "mocks": { | |
| "ask-superwhisper": [ | |
| "Summary from your transcripts: You discussed three action items and assigned owners. The next meeting is set for next week." | |
| ] | |
| }, | |
| "expected": [ | |
| { | |
| "callsTool": "ask-superwhisper" | |
| } | |
| ] | |
| } | |
| ] | |
| } | |
| { | |
| "instructions": "When the user asks about their voice recordings, transcripts, meeting notes, or anything related to their Superwhisper history, call the ask-superwhisper tool. Use the optional searchQuery argument to filter by keyword when the user is looking for something specific. Leave searchQuery empty when the user wants a summary, statistics, or their most recent recordings.", | |
| "evals": [ | |
| { | |
| "input": "@superwhisper What did I say about the project deadline?", | |
| "mocks": { | |
| "ask-superwhisper": { | |
| "totalRecordings": 42, | |
| "returnedRecordings": 1, | |
| "recordings": [ | |
| { | |
| "date": "2024-01-15 10:30", | |
| "transcript": "We need to wrap up the project deadline by next Friday. Everyone should submit their parts by Thursday at the latest.", | |
| "durationMs": 95000, | |
| "mode": "General", | |
| "transcriptionModel": "whisper-large-v3", | |
| "languageModel": "gpt-4o" | |
| } | |
| ] | |
| } | |
| }, | |
| "expected": [ | |
| { | |
| "callsTool": { | |
| "name": "ask-superwhisper", | |
| "arguments": { | |
| "searchQuery": { | |
| "includes": "deadline" | |
| } | |
| } | |
| } | |
| }, | |
| { | |
| "includes": "friday" | |
| } | |
| ] | |
| }, | |
| { | |
| "input": "@superwhisper Summarize my most recent recording.", | |
| "mocks": { | |
| "ask-superwhisper": { | |
| "totalRecordings": 42, | |
| "returnedRecordings": 1, | |
| "recordings": [ | |
| { | |
| "date": "2024-01-20 09:15", | |
| "transcript": "Quick note: follow up with the design team about the new dashboard mockups. Also remember to book the flight for the conference next month.", | |
| "durationMs": 48000, | |
| "mode": "General", | |
| "transcriptionModel": "whisper-large-v3", | |
| "languageModel": "gpt-4o" | |
| } | |
| ] | |
| } | |
| }, | |
| "expected": [ | |
| { | |
| "callsTool": "ask-superwhisper" | |
| }, | |
| { | |
| "meetsCriteria": "Summarizes the content of the most recent recording" | |
| } | |
| ] | |
| }, | |
| { | |
| "input": "@superwhisper How many recordings do I have?", | |
| "mocks": { | |
| "ask-superwhisper": { | |
| "totalRecordings": 42, | |
| "returnedRecordings": 20, | |
| "recordings": [] | |
| } | |
| }, | |
| "expected": [ | |
| { | |
| "callsTool": "ask-superwhisper" | |
| }, | |
| { | |
| "includes": "42" | |
| } | |
| ] | |
| } | |
| ] | |
| } |
There was a problem hiding this comment.
Thanks for the review @pernielsentikaer. If you agree, I will remove the RaycastAI and focus only on non-AI features as part of this PR. Later, I will create a separate PR to add ask-superwhisper as a new feature.
There was a problem hiding this comment.
Sounds like a good idea 🙂
|
This pull request has been automatically marked as stale because it did not have any recent activity. It will be closed if no further activity occurs in the next 7 days to keep our backlog clean 😊 |
|
This pull request has been automatically closed due to inactivity. Feel free to comment in the thread when you're ready to continue working on it 🙂 You can also catch us in Slack if you want to discuss this. |
…ds (#28635) * fix(superwhisper): apply recordingDir preference to copy/paste commands - Lift recordingDir to extension-level preferences - Thread the path through getLatestRecordingByVariant - Wire it into copy-last-history and paste-last-history Users keeping recordings outside the default path could configure Search History but still saw "Please make a recording first" on Copy and Paste Last History because those commands fell back to the hardcoded path. This applies the existing preference uniformly. Related: #25369, #25684, #24272, #24703 Prior art: #26213, #26221 * fix(superwhisper): drop redundant copy/paste fallback path getRecordings already applies the same homedir-based fallback when no customRecordingsPath is passed, so duplicating it in the command files adds noise. Pass recordingDir through directly (coerced to undefined when empty) and let the canonical fallback in hooks.ts handle it. * Update CHANGELOG.md --------- Co-authored-by: Dhruv Suthar <[email protected]> Co-authored-by: raycastbot <[email protected]>
…ds (raycast#28635) * fix(superwhisper): apply recordingDir preference to copy/paste commands - Lift recordingDir to extension-level preferences - Thread the path through getLatestRecordingByVariant - Wire it into copy-last-history and paste-last-history Users keeping recordings outside the default path could configure Search History but still saw "Please make a recording first" on Copy and Paste Last History because those commands fell back to the hardcoded path. This applies the existing preference uniformly. Related: raycast#25369, raycast#25684, raycast#24272, raycast#24703 Prior art: raycast#26213, raycast#26221 * fix(superwhisper): drop redundant copy/paste fallback path getRecordings already applies the same homedir-based fallback when no customRecordingsPath is passed, so duplicating it in the command files adds noise. Pass recordingDir through directly (coerced to undefined when empty) and let the canonical fallback in hooks.ts handle it. * Update CHANGELOG.md --------- Co-authored-by: Dhruv Suthar <[email protected]> Co-authored-by: raycastbot <[email protected]>
Description
~/Documents/superwhisper/recordings.Screencast
Recording and Mode config
Moved
recordingDirandmodeDirfrom command-level to extension-level config to reuse them in different commands.Select Mode View
Now,

select-modeshows the icon for each primary mode. (Custom Icon is not supported)Start Recording in the Select Mode View
Search View
Added search by mode dropdown and a metadata view in search view

Delete a recording:
Copy Prompt command, if available:

Ask-SuperWhisper
Checklist
npm run buildand tested this distribution build in Raycastassetsfolder are used by the extension itselfREADMEare placed outside of themetadatafolder