From 01c2d33208e00c6e327fc126a7fd5302a05836d6 Mon Sep 17 00:00:00 2001 From: Mark Henderson Date: Mon, 9 Mar 2026 14:21:25 -0700 Subject: [PATCH] fix: strip backticks from CODEBASE_MAP.md path parsing Paths wrapped in backticks like `app/` were being captured with the backtick character, producing invalid app names and paths. Made-with: Cursor --- app/api/projects/[projectId]/apps/route.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/app/api/projects/[projectId]/apps/route.ts b/app/api/projects/[projectId]/apps/route.ts index dee52d5..727a5e0 100644 --- a/app/api/projects/[projectId]/apps/route.ts +++ b/app/api/projects/[projectId]/apps/route.ts @@ -67,11 +67,11 @@ export async function GET( const mapFile = await giteaGet(`/repos/${giteaRepo}/contents/CODEBASE_MAP.md`).catch(() => null); if (mapFile?.content) { const decoded = Buffer.from(mapFile.content, 'base64').toString('utf-8'); - // Extract component folder paths from the map (lines like "### [name] — folder/path") - const matches = [...decoded.matchAll(/###\s+.+?—\s+([^\n(]+)/g)]; + // Extract component folder paths from lines like "### Name — `folder/path`" or "### Name — folder/path" + const matches = [...decoded.matchAll(/###\s+.+?[—–-]\s+[`]?([^`\n(]+)[`]?/g)]; const parsedApps = matches - .map(m => m[1].trim()) - .filter(p => p && !p.includes(' ') && !p.startsWith('http')) + .map(m => m[1].trim().replace(/^`|`$/g, '').replace(/\/$/, '')) + .filter(p => p && p.length > 0 && !p.includes(' ') && !p.startsWith('http') && p !== '.') .map(p => ({ name: p.split('/').pop() ?? p, path: p })); if (parsedApps.length > 0) { apps = parsedApps; @@ -93,14 +93,15 @@ export async function GET( const candidates = await Promise.all( dirs.map(async (dir) => { try { - const sub: Array<{ name: string }> = await giteaGet(`/repos/${giteaRepo}/contents/${dir.path}`); - const isApp = sub.some(f => APP_SIGNALS.includes(f.name)); - return isApp ? { name: dir.name, path: dir.path } : null; + const sub: Array<{ name: string; type: string }> = await giteaGet(`/repos/${giteaRepo}/contents/${dir.path}`); + // Check direct app signals OR subdirs that each contain app signals (monorepo-style) + const hasDirectSignal = sub.some(f => APP_SIGNALS.includes(f.name)); + return hasDirectSignal ? { name: dir.name, path: dir.path } : null; } catch { return null; } }) ); - apps = candidates.filter((a): a is { name: string; path: string } => a !== null); + apps = candidates.filter((a): a is { name: string; path: string } => a !== null && a.name.length > 0); } catch { /* scan failed */ } } }