feat(ai): inject full directory tree into context to eliminate manual fs_list probing

This commit is contained in:
2026-05-16 12:40:31 -07:00
parent ca8a915fe2
commit 70ea8f849b

View File

@@ -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 "";