Skip to content

Remove shadcn from exclude list for smartcontext #769

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 5, 2025
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@
},
{
"path": "src/components/ui/button.tsx",
"content": "// File contents excluded from context",
"content": "// button.tsx\n",
"force": false
},
{
"path": "src/components/ui/helper.ts",
"content": "// File contents excluded from context",
"content": "// helper.ts\n",
"force": false
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
},
{
"path": "src/components/ui/helper.ts",
"content": "// File contents excluded from context",
"content": "// helper.ts\n",
"force": false
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"files": [
{
"path": "src/components/ui/helper.ts",
"content": "// File contents excluded from context",
"content": "// helper.ts\n",
"force": false
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@
},
{
"path": "src/components/ui/button.tsx",
"content": "// File contents excluded from context",
"content": "// button.tsx\n",
"force": false
},
{
"path": "src/components/ui/helper.ts",
"content": "// File contents excluded from context",
"content": "// helper.ts\n",
"force": false
},
{
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

100 changes: 50 additions & 50 deletions e2e-tests/snapshots/engine.spec.ts_send-message-to-engine-1.txt

Large diffs are not rendered by default.

Large diffs are not rendered by default.

100 changes: 50 additions & 50 deletions e2e-tests/snapshots/thinking_budget.spec.ts_thinking-budget-2.txt

Large diffs are not rendered by default.

100 changes: 50 additions & 50 deletions e2e-tests/snapshots/thinking_budget.spec.ts_thinking-budget-4.txt

Large diffs are not rendered by default.

100 changes: 50 additions & 50 deletions e2e-tests/snapshots/thinking_budget.spec.ts_thinking-budget-6.txt

Large diffs are not rendered by default.

49 changes: 40 additions & 9 deletions src/utils/codebase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,20 @@ const EXCLUDED_FILES = ["pnpm-lock.yaml", "package-lock.json"];
// Files to always include, regardless of extension
const ALWAYS_INCLUDE_FILES = ["package.json", "vercel.json", ".gitignore"];

// File patterns to always omit (contents will be replaced with a placeholder)
// We don't want to send environment variables to the LLM because they
// are sensitive and users should be configuring them via the UI.
const ALWAYS_OMITTED_FILES = [".env", ".env.local"];

// File patterns to omit (contents will be replaced with a placeholder)
//
// Why are we not using path.join here?
// Because we have already normalized the path to use /.
const OMITTED_FILES = [
...ALWAYS_OMITTED_FILES,
"src/components/ui",
"eslint.config",
"tsconfig.json",

".env",
];

// Maximum file size to include (in bytes) - 1MB
Expand Down Expand Up @@ -306,11 +310,6 @@ async function collectFiles(dir: string, baseDir: string): Promise<string[]> {
return files;
}

// Skip large configuration files or generated code (just include the path)
function isOmittedFile(relativePath: string): boolean {
return OMITTED_FILES.some((pattern) => relativePath.includes(pattern));
}

const OMITTED_FILE_CONTENT = "// File contents excluded from context";

/**
Expand All @@ -327,7 +326,34 @@ function shouldReadFileContents({
const fileName = path.basename(filePath);

// OMITTED_FILES takes precedence - never read if omitted
if (isOmittedFile(normalizedRelativePath)) {
if (
OMITTED_FILES.some((pattern) => normalizedRelativePath.includes(pattern))
) {
return false;
}

// Check if file should be included based on extension or filename
return (
ALLOWED_EXTENSIONS.includes(ext) || ALWAYS_INCLUDE_FILES.includes(fileName)
);
}

function shouldReadFileContentsForSmartContext({
filePath,
normalizedRelativePath,
}: {
filePath: string;
normalizedRelativePath: string;
}): boolean {
const ext = path.extname(filePath).toLowerCase();
const fileName = path.basename(filePath);

// ALWAYS__OMITTED_FILES takes precedence - never read if omitted
if (
ALWAYS_OMITTED_FILES.some((pattern) =>
normalizedRelativePath.includes(pattern),
)
) {
return false;
}

Expand Down Expand Up @@ -521,7 +547,12 @@ export async function extractCodebase({

// Determine file content based on whether we should read it
let fileContent: string;
if (!shouldReadFileContents({ filePath: file, normalizedRelativePath })) {
if (
!shouldReadFileContentsForSmartContext({
filePath: file,
normalizedRelativePath,
})
) {
fileContent = OMITTED_FILE_CONTENT;
} else {
const readContent = await readFileWithCache(file, virtualFileSystem);
Expand Down
Loading