From 70ea8f849bc927c2e6ba8dea8b4eb2c52d05017f Mon Sep 17 00:00:00 2001 From: mawkone Date: Sat, 16 May 2026 12:40:31 -0700 Subject: [PATCH] feat(ai): inject full directory tree into context to eliminate manual fs_list probing --- .../ai/project-context/codebase-summary.ts | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/vibn-frontend/lib/ai/project-context/codebase-summary.ts b/vibn-frontend/lib/ai/project-context/codebase-summary.ts index 65c76d8..252cdfe 100644 --- a/vibn-frontend/lib/ai/project-context/codebase-summary.ts +++ b/vibn-frontend/lib/ai/project-context/codebase-summary.ts @@ -50,9 +50,11 @@ export async function buildCodebaseSummary( if [ -f vite.config.ts ] || [ -f vite.config.js ]; then echo "- Vite SPA"; fi if [ -f docker-compose.yml ]; then echo "- Docker Compose deployed"; fi - echo -e "\n=== ROOT STRUCTURE ===" - ls -la | awk '{print $9}' | grep -v "^$" | grep -v "^.$" | grep -v "^..$" | head -n 15 | tr '\n' ', ' - `; + echo -e "\n=== DIRECTORY TREE ===" + # Generate a tree up to 3 levels deep, ignoring heavy/noisy folders. + # This gives the AI an instant map of the codebase without needing to run fs_tree manually. + find . -maxdepth 4 -not -path "*/node_modules/*" -not -path "*/.git/*" -not -path "*/.next/*" -not -path "*/dist/*" -not -path "*/build/*" | sort | sed -e "s/[^-][^\\/]*\\// |/g" -e "s/|\\([^ ]\\)/|-\\1/" | head -n 300 + \`; const result = await execInDevContainer(projectId, bashScript); @@ -60,12 +62,12 @@ export async function buildCodebaseSummary( return ""; } - return `\n## CODEBASE SUMMARY (Auto-detected) -This is a quick summary of what currently exists in \`/workspace/${projectSlug}/\`: -\`\`\`text -${result.stdout.trim().slice(0, 1000)} -\`\`\` -Use this to orient yourself. Do not guess the stack; if it says Next.js and Prisma, use Next.js and Prisma.`; + return \`\n## CODEBASE SUMMARY (Auto-detected) +This is a real-time map of the files currently existing in \\\`/workspace/\${projectSlug}/\\\`: +\\\`\\\`\\\`text +\${result.stdout.trim().slice(0, 4000)} +\\\`\\\`\\\` +Use this directory tree to orient yourself. You do not need to run fs_list or fs_tree to find where files live. Do not guess the stack; if it says Next.js and Prisma, use Next.js and Prisma.\`; } catch (error) { console.warn("[Codebase Summary] Failed to generate summary:", error); return "";