Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1788,16 +1788,11 @@ export const sidebar: Sidebar = [

export async function fetchAndUpdateSidebar() {
try {
const response = await fetch('https://raw.githubusercontent.com/base/web/refs/heads/master/apps/base-docs/sidebar.ts');
if (!response.ok) {
throw new Error(`Failed to fetch sidebar: ${response.statusText}`);
}
sidebarContent = await response.text();
console.log('Successfully fetched and updated sidebar content');
console.log(sidebarContent);
// The upstream repository structure now lives under base/docs.
// Use fallback sidebarContent when remote sidebar asset is not available.
return;
} catch (error) {
console.error('Error fetching sidebar:', error);
// We'll keep using the fallback content if fetch fails
}
}

Expand Down
39 changes: 30 additions & 9 deletions tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,38 @@ export const getGuide = async ({
}: z.infer<typeof getGuideParams>) => {
console.log("Received request for guide:", guideLink);
try {
// Remove the base URL prefix and ensure the path starts correctly
const guidePath = guideLink.replace("https://docs.base.org", "");
const githubRawUrl = `https://raw.githubusercontent.com/base/web/refs/heads/master/apps/base-docs/docs/pages${guidePath}.mdx`;
console.log("Fetching from URL:", githubRawUrl);
// Normalize path by stripping base URL if provided
let guidePath = guideLink.replace(/^https?:\/\/docs\.base\.org/, "");
if (!guidePath.startsWith("/")) {
guidePath = `/${guidePath}`;
}
// Strip trailing slash if any
guidePath = guidePath.replace(/\/$/, "");
// Strip existing .mdx or .md extension if passed
guidePath = guidePath.replace(/\.(mdx|md)$/, "");

const baseRawDocsUrl = "https://raw.githubusercontent.com/base/docs/master/docs";
const candidates = [
`${baseRawDocsUrl}${guidePath}.mdx`,
`${baseRawDocsUrl}${guidePath}.md`,
`${baseRawDocsUrl}${guidePath}/index.mdx`,
`${baseRawDocsUrl}${guidePath}/index.md`,
];

let guide: string | null = null;
for (const url of candidates) {
console.log("Fetching from URL:", url);
const response = await fetch(url);
if (response.ok) {
guide = await response.text();
console.log("Successfully fetched guide content from:", url);
break;
}
}

const response = await fetch(githubRawUrl);
if (!response.ok) {
throw new Error(`Failed to fetch guide: ${response.statusText}`);
if (!guide) {
throw new Error(`Failed to fetch guide for path: ${guidePath}`);
}
const guide = await response.text();
console.log("Successfully fetched guide content");

let finalResult = guide;

Expand Down
4 changes: 2 additions & 2 deletions utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ export const findGuideParamsPrompt = `
${getFormattedSidebar()}
Find the path of the guide in the sidebar and pass it as guideLink by adding https://docs.base.org to the getStepsList tool.

For example, if the user wants to create a sign and verify component, the guideLink should be https://docs.base.org/identity/smart-wallet/guides/signing-and-verifying-messages
For example, if the user wants to create a sign and verify component, the guideLink should be https://docs.base.org/base-account/guides/sign-and-verify-typed-data

You will find that in the sidebar list, the guide is under the "Smart Wallet" section.
You will find that in the sidebar list, the guide is under the "Base Account" section.
`;

export const testingPrompt = (code: string) => {
Expand Down