Skip to content

Commit 7f01fb7

Browse files
committed
style: format site code with biome
2 parents c91e9ea + 421a2be commit 7f01fb7

5 files changed

Lines changed: 55 additions & 39 deletions

File tree

‎apps/site/src/pages/.well-known/mcp/server-card.json.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ export const GET: APIRoute = async ({ locals }) => {
5757
},
5858
limit: {
5959
type: "integer",
60-
description: "Number of results to return (default: 10, max: 24).",
60+
description:
61+
"Number of results to return (default: 10, max: 24).",
6162
},
6263
},
6364
required: ["query"],

‎apps/site/src/pages/api/chat.ts‎

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { env } from "cloudflare:workers";
22
import { createMCPClient } from "@ai-sdk/mcp";
3+
import { createOpenRouter } from "@openrouter/ai-sdk-provider";
34
import { createClient } from "@sanity/client";
45
import { isStepCount, jsonSchema, streamText, tool } from "ai";
56
import type { APIRoute } from "astro";
6-
import { createOpenRouter } from "@openrouter/ai-sdk-provider";
77
import { createWorkersAI } from "workers-ai-provider";
88
import {
99
semanticSearchQuery,
@@ -179,15 +179,21 @@ export const POST: APIRoute = async ({ request }) => {
179179
results = res;
180180
}
181181
} catch (semanticErr) {
182-
console.warn("[search_content semantic error, falling back]", semanticErr);
182+
console.warn(
183+
"[search_content semantic error, falling back]",
184+
semanticErr,
185+
);
183186
}
184187

185188
if (!results.length) {
186189
try {
187-
const fallback = await sanityClient.fetch(textSearchFallbackQuery, {
188-
searchTerm: query,
189-
type: filterType,
190-
});
190+
const fallback = await sanityClient.fetch(
191+
textSearchFallbackQuery,
192+
{
193+
searchTerm: query,
194+
type: filterType,
195+
},
196+
);
191197
if (Array.isArray(fallback)) {
192198
results = fallback;
193199
}
@@ -271,9 +277,7 @@ export const POST: APIRoute = async ({ request }) => {
271277
{} as any,
272278
);
273279
const parsed =
274-
typeof mcpResult === "string"
275-
? JSON.parse(mcpResult)
276-
: mcpResult;
280+
typeof mcpResult === "string" ? JSON.parse(mcpResult) : mcpResult;
277281
const results =
278282
parsed?.result ||
279283
(Array.isArray(parsed?.content) && parsed.content[0]?.text
@@ -307,16 +311,26 @@ export const POST: APIRoute = async ({ request }) => {
307311
}
308312

309313
// If still empty and query was a search for a keyword, extract keyword and run semantic search
310-
const matchTerm = query.match(/match\s+["']\*?([a-zA-Z0-9_-]+)\*?["']/);
314+
const matchTerm = query.match(
315+
/match\s+["']\*?([a-zA-Z0-9_-]+)\*?["']/,
316+
);
311317
if (matchTerm?.[1]) {
312318
const keyword = matchTerm[1];
313-
const typeMatch = query.match(/_type\s*==\s*["']([a-zA-Z0-9_-]+)["']/);
319+
const typeMatch = query.match(
320+
/_type\s*==\s*["']([a-zA-Z0-9_-]+)["']/,
321+
);
314322
const filterType = typeMatch?.[1] || null;
315-
const semanticResults = await sanityClient.fetch(semanticSearchQuery, {
316-
searchTerm: keyword,
317-
type: filterType,
318-
});
319-
if (Array.isArray(semanticResults) && semanticResults.length > 0) {
323+
const semanticResults = await sanityClient.fetch(
324+
semanticSearchQuery,
325+
{
326+
searchTerm: keyword,
327+
type: filterType,
328+
},
329+
);
330+
if (
331+
Array.isArray(semanticResults) &&
332+
semanticResults.length > 0
333+
) {
320334
return semanticResults.slice(0, 10).map((item: any) => ({
321335
title: item.title,
322336
type: item._type,
@@ -384,7 +398,7 @@ export const POST: APIRoute = async ({ request }) => {
384398
"- When asked for 'top videos' or popular video podcasts, search for high-profile episodes with video recordings (e.g. episodes featuring Guillermo Rauch, Rich Harris, Lee Robinson, or recent GenAI/MCP video podcasts) and provide their YouTube links alongside CodingCat.dev episode links.\n" +
385399
"- Use `groq_query` for precise lookups when searching for specific author profiles (e.g. *[_type == 'author' && title match '*Alex*']).\n" +
386400
"- CRITICAL: ALWAYS execute tools by invoking them via function calls. NEVER output raw JSON or code blocks in your text describing tool calls instead of executing them.\n" +
387-
"- Once you receive results from your tool calls, synthesize them into an engaging, helpful response. List the relevant episode or article titles, brief descriptions, and markdown links using relative paths (e.g. [Episode Title](/podcast/slug) or [Post Title](/post/slug)). When YouTube links are available, always include them directly on their own line (e.g. https://www.youtube.com/watch?v=VIDEO_ID or https://youtu.be/VIDEO_ID). NEVER output localhost URLs, internal IP addresses, or malformed URL brackets like [\"/slug\"](http://localhost:3000/slug).",
401+
'- Once you receive results from your tool calls, synthesize them into an engaging, helpful response. List the relevant episode or article titles, brief descriptions, and markdown links using relative paths (e.g. [Episode Title](/podcast/slug) or [Post Title](/post/slug)). When YouTube links are available, always include them directly on their own line (e.g. https://www.youtube.com/watch?v=VIDEO_ID or https://youtu.be/VIDEO_ID). NEVER output localhost URLs, internal IP addresses, or malformed URL brackets like ["/slug"](http://localhost:3000/slug).',
388402
messages: coreMessages,
389403
tools,
390404
stopWhen: isStepCount(5),

‎apps/site/src/pages/api/mcp.ts‎

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -743,10 +743,7 @@ async function handleQueryContent(
743743
);
744744

745745
// Heal text::query("...") -> "*...*"
746-
cleanQuery = cleanQuery.replace(
747-
/text::query\((["'])(.*?)\1\)/g,
748-
"$1*$2*$1",
749-
);
746+
cleanQuery = cleanQuery.replace(/text::query\((["'])(.*?)\1\)/g, "$1*$2*$1");
750747

751748
// Remove [_score > 0]
752749
cleanQuery = cleanQuery.replace(/\[_score\s*>\s*0\]/g, "");
@@ -761,7 +758,9 @@ async function handleQueryContent(
761758
);
762759
if (keywordMatch?.[1]) {
763760
const term = keywordMatch[1].trim();
764-
const typeMatch = rawQuery.match(/_type\s*==\s*["']([a-zA-Z0-9_-]+)["']/);
761+
const typeMatch = rawQuery.match(
762+
/_type\s*==\s*["']([a-zA-Z0-9_-]+)["']/,
763+
);
765764
const fallbackType = typeMatch?.[1] || null;
766765
const fallbackRes = await client.fetch(semanticSearchQuery, {
767766
searchTerm: term,
@@ -907,7 +906,11 @@ async function handleSchemaExplorer(
907906
{ name: "date", type: "datetime", description: "Release date" },
908907
{ name: "episode", type: "number", description: "Episode number" },
909908
{ name: "season", type: "number", description: "Season number" },
910-
{ name: "excerpt", type: "text", description: "Show notes and summary" },
909+
{
910+
name: "excerpt",
911+
type: "text",
912+
description: "Show notes and summary",
913+
},
911914
{
912915
name: "guests",
913916
type: "array",
@@ -985,9 +988,7 @@ async function handleSchemaExplorer(
985988

986989
if (type && schemas[type]) {
987990
return {
988-
content: [
989-
{ type: "text", text: JSON.stringify(schemas[type], null, 2) },
990-
],
991+
content: [{ type: "text", text: JSON.stringify(schemas[type], null, 2) }],
991992
isError: false,
992993
};
993994
}

‎apps/site/src/pages/api/transcript.ts‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ export const GET: APIRoute = async ({ request }) => {
4444

4545
if (!idParam && !slugParam && !youtubeParam) {
4646
return new Response(
47-
JSON.stringify({ error: "Missing required query parameter: id, slug, or youtube" }),
47+
JSON.stringify({
48+
error: "Missing required query parameter: id, slug, or youtube",
49+
}),
4850
{ status: 400, headers: CORS_HEADERS },
4951
);
5052
}
@@ -109,7 +111,8 @@ export const GET: APIRoute = async ({ request }) => {
109111
// 3. Try finding by YouTube video ID
110112
if (!transcriptDoc && youtubeParam) {
111113
const parsedYt = parseYoutubeId(youtubeParam);
112-
const ytId = parsedYt || (youtubeParam.length === 11 ? youtubeParam : undefined);
114+
const ytId =
115+
parsedYt || (youtubeParam.length === 11 ? youtubeParam : undefined);
113116
if (ytId) {
114117
try {
115118
transcriptDoc = await client.fetch(
@@ -134,16 +137,13 @@ export const GET: APIRoute = async ({ request }) => {
134137

135138
// If no transcript found in Sanity
136139
if (!transcriptDoc) {
137-
return new Response(
138-
JSON.stringify({ error: "Transcript not found" }),
139-
{
140-
status: 404,
141-
headers: {
142-
...CORS_HEADERS,
143-
"cache-control": "no-store, no-cache, must-revalidate",
144-
},
140+
return new Response(JSON.stringify({ error: "Transcript not found" }), {
141+
status: 404,
142+
headers: {
143+
...CORS_HEADERS,
144+
"cache-control": "no-store, no-cache, must-revalidate",
145145
},
146-
);
146+
});
147147
}
148148

149149
// If transcript exists in Sanity with completed captions

‎apps/site/tests/tier1-features.test.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1171,7 +1171,7 @@ describe("Tier 1 - Feature Coverage", () => {
11711171
const data = await res.json();
11721172
assert.ok(
11731173
data.serverInfo.name === "codingcatdev-sanity-context-mcp" ||
1174-
data.serverInfo.name === "codingcatdev-search-mcp",
1174+
data.serverInfo.name === "codingcatdev-search-mcp",
11751175
);
11761176
assert.equal(data.transport.type, "streamable-http");
11771177
assert.ok(data.capabilities.tools);

0 commit comments

Comments
 (0)