Skip to content

Recording directory & mode directory at extension level, Ask Superwhisper, and Search History improvements - #26221

Closed
devmarkpro wants to merge 8 commits into
raycast:mainfrom
devmarkpro:ext/superwhisper
Closed

devmarkpro wants to merge 8 commits into
raycast:mainfrom
devmarkpro:ext/superwhisper

Conversation

@devmarkpro

@devmarkpro devmarkpro commented Mar 11, 2026 •

Copy link
Copy Markdown

Description

  • Preferences: Recording Directory and Mode Directory are now set once at the extension level (Preferences > Extensions > Superwhisper) and shared by all relevant commands; per-command duplicates were removed.
  • Copy/Paste Last History: Both commands use the extension Recording Directory preference when set, with fallback to ~/Documents/superwhisper/recordings.
  • Ask Superwhisper: New AI tool/command to ask questions from your Superwhisper transcripts.
  • Search History: Text search, filter by mode, delete recording (with confirmation), and Ctrl+X hotkey to delete the selected recording.
  • UI: Select Mode and Search History show mode icons from mode JSON when available.

Screencast

Recording and Mode config

Moved recordingDir and modeDir from command-level to extension-level config to reuse them in different commands.

ScreenShot 2026-03-11 at 07 01 04@2x

Select Mode View

Now, select-mode shows the icon for each primary mode. (Custom Icon is not supported)
ScreenShot 2026-03-11 at 06 53 22@2x

Start Recording in the Select Mode View

ScreenShot 2026-03-11 at 10 06 35@2x ScreenShot 2026-03-11 at 10 07 09@2x

Search View

Added search by mode dropdown and a metadata view in search view
image

Delete a recording:

ScreenShot 2026-03-11 at 06 56 31@2x ScreenShot 2026-03-11 at 06 55 43@2x

Copy Prompt command, if available:
ScreenShot 2026-03-11 at 06 57 37@2x

Ask-SuperWhisper

ScreenShot 2026-03-11 at 06 50 36@2x ScreenShot 2026-03-11 at 06 51 35@2x

Checklist

- 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
@raycastbot raycastbot added extension fix / improvement Label for PRs with extension's fix improvements extension: superwhisper Issues related to the superwhisper extension AI Extension platform: macOS labels Mar 11, 2026
@raycastbot

raycastbot commented Mar 11, 2026 •

Copy link
Copy Markdown
Collaborator

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 commands
BRANCH="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 dev

We're currently experiencing a high volume of incoming requests. As a result, the initial review may take up to 10-15 business days.

@devmarkpro devmarkpro changed the title Update superwhisper extension Recording directory & mode directory at extension level, Ask Superwhisper, and Search History improvements Mar 11, 2026
@devmarkpro
devmarkpro marked this pull request as ready for review March 11, 2026 06:00
@greptile-apps

greptile-apps Bot commented Mar 11, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds several improvements to the Superwhisper extension: recordingDir and modeDir are promoted to extension-level preferences (removing per-command duplicates), a new "Ask Superwhisper" AI tool lets users query their transcript history, and Search History gains text/mode filtering, a metadata panel, prompt preview, and a delete-recording action with confirmation.

Key points:

  • deleteRecording uses rmSync — this permanently destroys the recording folder without going through Trash, contrary to Raycast's recommendation to use trash() from @raycast/api.
  • Excerpt anchor bug in ask-superwhisper.ts — when a recording scores > 0 only because secondary terms matched (not terms[0]), indexOf(terms[0]) returns -1 and the excerpt is incorrectly taken from the very start of the transcript instead of near the matching content.
  • Manual preference type in ask-superwhisper.ts — getPreferenceValues<{ recordingDir?: string }>() should use the auto-generated Preferences type.
  • Tool title formatting — "Ask-Superwhisper" uses a hyphen; it should be "Ask Superwhisper" to match title-case conventions used by all other commands.

Confidence Score: 3/5

  • Safe to merge after addressing the permanent-deletion (rmSync) issue and the excerpt-anchor logic bug.
  • The rmSync usage permanently destroys recording folders rather than moving them to Trash, which is a UX/safety concern and a violation of the Raycast extension guidelines. The excerpt anchor bug means the AI tool can receive misleading context when only secondary search terms match. The remaining issues (manual preference type, tool title hyphen) are minor style fixes.
  • extensions/superwhisper/src/hooks.ts (permanent deletion via rmSync) and extensions/superwhisper/src/tools/ask-superwhisper.ts (excerpt anchor logic + manual preference type).

Important Files Changed

Filename Overview
extensions/superwhisper/src/hooks.ts Adds deleteRecording (uses rmSync — should use Raycast's trash()), exposes revalidate from useRecordings, adds extra metadata fields to RecordingMeta, and adds formatDurationMs utility.
extensions/superwhisper/src/tools/ask-superwhisper.ts New AI tool that searches transcripts via two sequential AI.ask calls. Has a logic issue where the excerpt window is anchored to terms[0] even when that term is absent from the recording, and uses a manual getPreferenceValues type annotation.
extensions/superwhisper/package.json Moves recordingDir/modeDir to extension-level preferences, adds the ask-superwhisper tool. Tool title uses "Ask-Superwhisper" (hyphen) instead of the conventional "Ask Superwhisper" (space).
extensions/superwhisper/src/search-history.tsx Adds mode-filter dropdown, metadata panel, prompt preview, and a delete-recording action with confirmation dialog. Implementation is clean; delete wires to deleteRecording which has a trash() concern (flagged in hooks.ts).

Last reviewed commit: ed75b3a

Comment thread extensions/superwhisper/src/hooks.ts Resolved
Comment thread extensions/superwhisper/package.json Resolved
devmarkpro and others added 6 commits March 11, 2026 08:45
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
@pernielsentikaer

Copy link
Copy Markdown
Contributor

@nchudleigh do you want to check this?

@pernielsentikaer pernielsentikaer self-assigned this Mar 23, 2026

@pernielsentikaer pernielsentikaer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 😊

Comment on lines +1 to +38
{
"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"
}
]
}
]
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{
"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"
}
]
}
]
}

@pernielsentikaer
pernielsentikaer marked this pull request as draft March 23, 2026 11:53
Comment on lines +1 to +286
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.";
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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,
};
}

Comment on lines +1 to +38
{
"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"
}
]
}
]
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{
"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"
}
]
}
]
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like a good idea 🙂

@raycastbot

Copy link
Copy Markdown
Collaborator

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 😊

@raycastbot raycastbot added the status: stalled Stalled due inactivity label Apr 8, 2026
@raycastbot

Copy link
Copy Markdown
Collaborator

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.

@raycastbot raycastbot closed this Apr 15, 2026
raycastbot added a commit that referenced this pull request Jun 9, 2026
…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]>
almatkai pushed a commit to almatkai/raymes-extensions that referenced this pull request Jul 13, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI Extension extension fix / improvement Label for PRs with extension's fix improvements extension: superwhisper Issues related to the superwhisper extension platform: macOS status: stalled Stalled due inactivity

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants