From 53bbfc981342b61ccf046de8d9a527606f52cf89 Mon Sep 17 00:00:00 2001 From: Will Chen Date: Tue, 26 Aug 2025 09:57:19 -0700 Subject: [PATCH] Read JSON (#1081) Fixes #1037 --- ## Summary by cubic Enable JSON file support in codebase scanning so common configs and data (e.g., package.json, vercel.json, translations) are included. Adds .json to the allowed extensions and removes special-casing for package.json/vercel.json. --- .../import-app/context-manage/manual/baz.json | 2 +- .../context_manage.spec.ts_exclude-paths-basic | 3 ++- ...ntext_manage.spec.ts_exclude-paths-precedence | 3 ++- ...xt---smart-context---auto-includes-only-1.txt | 2 +- ....spec.ts_manage-context---smart-context-1.txt | 2 +- ....spec.ts_manage-context---smart-context-4.txt | 2 +- ...ular-auto-should-send-message-to-engine-1.txt | 8 ++++---- ...e-to-engine---anthropic-claude-sonnet-4-1.txt | 8 ++++---- ...send-message-to-engine---openai-gpt-4-1-1.txt | 8 ++++---- ...sage-to-engine---smart-context-balanced-1.txt | 8 ++++---- .../engine.spec.ts_send-message-to-engine-1.txt | 8 ++++---- ...mart-auto-should-send-message-to-engine-1.txt | 8 ++++---- ...thinking_budget.spec.ts_thinking-budget-2.txt | 8 ++++---- ...thinking_budget.spec.ts_thinking-budget-4.txt | 8 ++++---- ...thinking_budget.spec.ts_thinking-budget-6.txt | 8 ++++---- src/utils/codebase.ts | 16 +++++++++++++++- 16 files changed, 59 insertions(+), 43 deletions(-) diff --git a/e2e-tests/fixtures/import-app/context-manage/manual/baz.json b/e2e-tests/fixtures/import-app/context-manage/manual/baz.json index 9f38a43..681b937 100644 --- a/e2e-tests/fixtures/import-app/context-manage/manual/baz.json +++ b/e2e-tests/fixtures/import-app/context-manage/manual/baz.json @@ -1 +1 @@ -["should not be included b/c it's json"] +["even json is included"] diff --git a/e2e-tests/snapshots/context_manage.spec.ts_exclude-paths-basic b/e2e-tests/snapshots/context_manage.spec.ts_exclude-paths-basic index e4611c5..6fdc6f3 100644 --- a/e2e-tests/snapshots/context_manage.spec.ts_exclude-paths-basic +++ b/e2e-tests/snapshots/context_manage.spec.ts_exclude-paths-basic @@ -46,7 +46,8 @@ You need to first add Supabase to your app and then we can add auth. === role: user message: This is my codebase. -// File contents excluded from context +["even json is included"] + diff --git a/e2e-tests/snapshots/context_manage.spec.ts_exclude-paths-precedence b/e2e-tests/snapshots/context_manage.spec.ts_exclude-paths-precedence index 3d279e3..5dfc689 100644 --- a/e2e-tests/snapshots/context_manage.spec.ts_exclude-paths-precedence +++ b/e2e-tests/snapshots/context_manage.spec.ts_exclude-paths-precedence @@ -46,7 +46,8 @@ You need to first add Supabase to your app and then we can add auth. === role: user message: This is my codebase. -// File contents excluded from context +["even json is included"] + diff --git a/e2e-tests/snapshots/context_manage.spec.ts_manage-context---smart-context---auto-includes-only-1.txt b/e2e-tests/snapshots/context_manage.spec.ts_manage-context---smart-context---auto-includes-only-1.txt index 7a6f688..d9aa061 100644 --- a/e2e-tests/snapshots/context_manage.spec.ts_manage-context---smart-context---auto-includes-only-1.txt +++ b/e2e-tests/snapshots/context_manage.spec.ts_manage-context---smart-context---auto-includes-only-1.txt @@ -48,7 +48,7 @@ }, { "path": "manual/baz.json", - "content": "// File contents excluded from context", + "content": "[\"even json is included\"]\n", "force": true }, { diff --git a/e2e-tests/snapshots/context_manage.spec.ts_manage-context---smart-context-1.txt b/e2e-tests/snapshots/context_manage.spec.ts_manage-context---smart-context-1.txt index bc29f8a..94c022c 100644 --- a/e2e-tests/snapshots/context_manage.spec.ts_manage-context---smart-context-1.txt +++ b/e2e-tests/snapshots/context_manage.spec.ts_manage-context---smart-context-1.txt @@ -28,7 +28,7 @@ }, { "path": "manual/baz.json", - "content": "// File contents excluded from context", + "content": "[\"even json is included\"]\n", "force": true }, { diff --git a/e2e-tests/snapshots/context_manage.spec.ts_manage-context---smart-context-4.txt b/e2e-tests/snapshots/context_manage.spec.ts_manage-context---smart-context-4.txt index 264f0e0..24d09a7 100644 --- a/e2e-tests/snapshots/context_manage.spec.ts_manage-context---smart-context-4.txt +++ b/e2e-tests/snapshots/context_manage.spec.ts_manage-context---smart-context-4.txt @@ -64,7 +64,7 @@ }, { "path": "manual/baz.json", - "content": "// File contents excluded from context", + "content": "[\"even json is included\"]\n", "force": false }, { diff --git a/e2e-tests/snapshots/engine.spec.ts_regular-auto-should-send-message-to-engine-1.txt b/e2e-tests/snapshots/engine.spec.ts_regular-auto-should-send-message-to-engine-1.txt index addd43e..de0be17 100644 --- a/e2e-tests/snapshots/engine.spec.ts_regular-auto-should-send-message-to-engine-1.txt +++ b/e2e-tests/snapshots/engine.spec.ts_regular-auto-should-send-message-to-engine-1.txt @@ -33,7 +33,7 @@ }, { "path": "components.json", - "content": "// File contents excluded from context", + "content": "{\n \"$schema\": \"https://ui.shadcn.com/schema.json\",\n \"style\": \"default\",\n \"rsc\": false,\n \"tsx\": true,\n \"tailwind\": {\n \"config\": \"tailwind.config.ts\",\n \"css\": \"src/index.css\",\n \"baseColor\": \"slate\",\n \"cssVariables\": true,\n \"prefix\": \"\"\n },\n \"aliases\": {\n \"components\": \"@/components\",\n \"utils\": \"@/lib/utils\",\n \"ui\": \"@/components/ui\",\n \"lib\": \"@/lib\",\n \"hooks\": \"@/hooks\"\n }\n}\n", "force": false }, { @@ -388,17 +388,17 @@ }, { "path": "tsconfig.app.json", - "content": "// File contents excluded from context", + "content": "{\n \"compilerOptions\": {\n \"target\": \"ES2020\",\n \"useDefineForClassFields\": true,\n \"lib\": [\"ES2020\", \"DOM\", \"DOM.Iterable\"],\n \"module\": \"ESNext\",\n \"skipLibCheck\": true,\n\n /* Bundler mode */\n \"moduleResolution\": \"bundler\",\n \"allowImportingTsExtensions\": true,\n \"isolatedModules\": true,\n \"moduleDetection\": \"force\",\n \"noEmit\": true,\n \"jsx\": \"react-jsx\",\n\n /* Linting */\n \"strict\": false,\n \"noUnusedLocals\": false,\n \"noUnusedParameters\": false,\n \"noImplicitAny\": false,\n \"noFallthroughCasesInSwitch\": false,\n\n \"baseUrl\": \".\",\n \"paths\": {\n \"@/*\": [\"./src/*\"]\n }\n },\n \"include\": [\"src\"]\n}\n", "force": false }, { "path": "tsconfig.json", - "content": "// File contents excluded from context", + "content": "{\n \"files\": [],\n \"references\": [\n { \"path\": \"./tsconfig.app.json\" },\n { \"path\": \"./tsconfig.node.json\" }\n ],\n \"compilerOptions\": {\n \"baseUrl\": \".\",\n \"paths\": {\n \"@/*\": [\"./src/*\"]\n },\n \"noImplicitAny\": false,\n \"noUnusedParameters\": false,\n \"skipLibCheck\": true,\n \"allowJs\": true,\n \"noUnusedLocals\": false,\n \"strictNullChecks\": false\n }\n}\n", "force": false }, { "path": "tsconfig.node.json", - "content": "// File contents excluded from context", + "content": "{\n \"compilerOptions\": {\n \"target\": \"ES2022\",\n \"lib\": [\"ES2023\"],\n \"module\": \"ESNext\",\n \"skipLibCheck\": true,\n\n /* Bundler mode */\n \"moduleResolution\": \"bundler\",\n \"allowImportingTsExtensions\": true,\n \"isolatedModules\": true,\n \"moduleDetection\": \"force\",\n \"noEmit\": true,\n\n /* Linting */\n \"strict\": true,\n \"noUnusedLocals\": false,\n \"noUnusedParameters\": false,\n \"noFallthroughCasesInSwitch\": true\n },\n \"include\": [\"vite.config.ts\"]\n}\n", "force": false }, { diff --git a/e2e-tests/snapshots/engine.spec.ts_send-message-to-engine---anthropic-claude-sonnet-4-1.txt b/e2e-tests/snapshots/engine.spec.ts_send-message-to-engine---anthropic-claude-sonnet-4-1.txt index 187da12..9240ce1 100644 --- a/e2e-tests/snapshots/engine.spec.ts_send-message-to-engine---anthropic-claude-sonnet-4-1.txt +++ b/e2e-tests/snapshots/engine.spec.ts_send-message-to-engine---anthropic-claude-sonnet-4-1.txt @@ -28,7 +28,7 @@ }, { "path": "components.json", - "content": "// File contents excluded from context", + "content": "{\n \"$schema\": \"https://ui.shadcn.com/schema.json\",\n \"style\": \"default\",\n \"rsc\": false,\n \"tsx\": true,\n \"tailwind\": {\n \"config\": \"tailwind.config.ts\",\n \"css\": \"src/index.css\",\n \"baseColor\": \"slate\",\n \"cssVariables\": true,\n \"prefix\": \"\"\n },\n \"aliases\": {\n \"components\": \"@/components\",\n \"utils\": \"@/lib/utils\",\n \"ui\": \"@/components/ui\",\n \"lib\": \"@/lib\",\n \"hooks\": \"@/hooks\"\n }\n}\n", "force": false }, { @@ -383,17 +383,17 @@ }, { "path": "tsconfig.app.json", - "content": "// File contents excluded from context", + "content": "{\n \"compilerOptions\": {\n \"target\": \"ES2020\",\n \"useDefineForClassFields\": true,\n \"lib\": [\"ES2020\", \"DOM\", \"DOM.Iterable\"],\n \"module\": \"ESNext\",\n \"skipLibCheck\": true,\n\n /* Bundler mode */\n \"moduleResolution\": \"bundler\",\n \"allowImportingTsExtensions\": true,\n \"isolatedModules\": true,\n \"moduleDetection\": \"force\",\n \"noEmit\": true,\n \"jsx\": \"react-jsx\",\n\n /* Linting */\n \"strict\": false,\n \"noUnusedLocals\": false,\n \"noUnusedParameters\": false,\n \"noImplicitAny\": false,\n \"noFallthroughCasesInSwitch\": false,\n\n \"baseUrl\": \".\",\n \"paths\": {\n \"@/*\": [\"./src/*\"]\n }\n },\n \"include\": [\"src\"]\n}\n", "force": false }, { "path": "tsconfig.json", - "content": "// File contents excluded from context", + "content": "{\n \"files\": [],\n \"references\": [\n { \"path\": \"./tsconfig.app.json\" },\n { \"path\": \"./tsconfig.node.json\" }\n ],\n \"compilerOptions\": {\n \"baseUrl\": \".\",\n \"paths\": {\n \"@/*\": [\"./src/*\"]\n },\n \"noImplicitAny\": false,\n \"noUnusedParameters\": false,\n \"skipLibCheck\": true,\n \"allowJs\": true,\n \"noUnusedLocals\": false,\n \"strictNullChecks\": false\n }\n}\n", "force": false }, { "path": "tsconfig.node.json", - "content": "// File contents excluded from context", + "content": "{\n \"compilerOptions\": {\n \"target\": \"ES2022\",\n \"lib\": [\"ES2023\"],\n \"module\": \"ESNext\",\n \"skipLibCheck\": true,\n\n /* Bundler mode */\n \"moduleResolution\": \"bundler\",\n \"allowImportingTsExtensions\": true,\n \"isolatedModules\": true,\n \"moduleDetection\": \"force\",\n \"noEmit\": true,\n\n /* Linting */\n \"strict\": true,\n \"noUnusedLocals\": false,\n \"noUnusedParameters\": false,\n \"noFallthroughCasesInSwitch\": true\n },\n \"include\": [\"vite.config.ts\"]\n}\n", "force": false }, { diff --git a/e2e-tests/snapshots/engine.spec.ts_send-message-to-engine---openai-gpt-4-1-1.txt b/e2e-tests/snapshots/engine.spec.ts_send-message-to-engine---openai-gpt-4-1-1.txt index ead471f..d1baf18 100644 --- a/e2e-tests/snapshots/engine.spec.ts_send-message-to-engine---openai-gpt-4-1-1.txt +++ b/e2e-tests/snapshots/engine.spec.ts_send-message-to-engine---openai-gpt-4-1-1.txt @@ -29,7 +29,7 @@ }, { "path": "components.json", - "content": "// File contents excluded from context", + "content": "{\n \"$schema\": \"https://ui.shadcn.com/schema.json\",\n \"style\": \"default\",\n \"rsc\": false,\n \"tsx\": true,\n \"tailwind\": {\n \"config\": \"tailwind.config.ts\",\n \"css\": \"src/index.css\",\n \"baseColor\": \"slate\",\n \"cssVariables\": true,\n \"prefix\": \"\"\n },\n \"aliases\": {\n \"components\": \"@/components\",\n \"utils\": \"@/lib/utils\",\n \"ui\": \"@/components/ui\",\n \"lib\": \"@/lib\",\n \"hooks\": \"@/hooks\"\n }\n}\n", "force": false }, { @@ -384,17 +384,17 @@ }, { "path": "tsconfig.app.json", - "content": "// File contents excluded from context", + "content": "{\n \"compilerOptions\": {\n \"target\": \"ES2020\",\n \"useDefineForClassFields\": true,\n \"lib\": [\"ES2020\", \"DOM\", \"DOM.Iterable\"],\n \"module\": \"ESNext\",\n \"skipLibCheck\": true,\n\n /* Bundler mode */\n \"moduleResolution\": \"bundler\",\n \"allowImportingTsExtensions\": true,\n \"isolatedModules\": true,\n \"moduleDetection\": \"force\",\n \"noEmit\": true,\n \"jsx\": \"react-jsx\",\n\n /* Linting */\n \"strict\": false,\n \"noUnusedLocals\": false,\n \"noUnusedParameters\": false,\n \"noImplicitAny\": false,\n \"noFallthroughCasesInSwitch\": false,\n\n \"baseUrl\": \".\",\n \"paths\": {\n \"@/*\": [\"./src/*\"]\n }\n },\n \"include\": [\"src\"]\n}\n", "force": false }, { "path": "tsconfig.json", - "content": "// File contents excluded from context", + "content": "{\n \"files\": [],\n \"references\": [\n { \"path\": \"./tsconfig.app.json\" },\n { \"path\": \"./tsconfig.node.json\" }\n ],\n \"compilerOptions\": {\n \"baseUrl\": \".\",\n \"paths\": {\n \"@/*\": [\"./src/*\"]\n },\n \"noImplicitAny\": false,\n \"noUnusedParameters\": false,\n \"skipLibCheck\": true,\n \"allowJs\": true,\n \"noUnusedLocals\": false,\n \"strictNullChecks\": false\n }\n}\n", "force": false }, { "path": "tsconfig.node.json", - "content": "// File contents excluded from context", + "content": "{\n \"compilerOptions\": {\n \"target\": \"ES2022\",\n \"lib\": [\"ES2023\"],\n \"module\": \"ESNext\",\n \"skipLibCheck\": true,\n\n /* Bundler mode */\n \"moduleResolution\": \"bundler\",\n \"allowImportingTsExtensions\": true,\n \"isolatedModules\": true,\n \"moduleDetection\": \"force\",\n \"noEmit\": true,\n\n /* Linting */\n \"strict\": true,\n \"noUnusedLocals\": false,\n \"noUnusedParameters\": false,\n \"noFallthroughCasesInSwitch\": true\n },\n \"include\": [\"vite.config.ts\"]\n}\n", "force": false }, { diff --git a/e2e-tests/snapshots/engine.spec.ts_send-message-to-engine---smart-context-balanced-1.txt b/e2e-tests/snapshots/engine.spec.ts_send-message-to-engine---smart-context-balanced-1.txt index 85e47d5..659e63c 100644 --- a/e2e-tests/snapshots/engine.spec.ts_send-message-to-engine---smart-context-balanced-1.txt +++ b/e2e-tests/snapshots/engine.spec.ts_send-message-to-engine---smart-context-balanced-1.txt @@ -33,7 +33,7 @@ }, { "path": "components.json", - "content": "// File contents excluded from context", + "content": "{\n \"$schema\": \"https://ui.shadcn.com/schema.json\",\n \"style\": \"default\",\n \"rsc\": false,\n \"tsx\": true,\n \"tailwind\": {\n \"config\": \"tailwind.config.ts\",\n \"css\": \"src/index.css\",\n \"baseColor\": \"slate\",\n \"cssVariables\": true,\n \"prefix\": \"\"\n },\n \"aliases\": {\n \"components\": \"@/components\",\n \"utils\": \"@/lib/utils\",\n \"ui\": \"@/components/ui\",\n \"lib\": \"@/lib\",\n \"hooks\": \"@/hooks\"\n }\n}\n", "force": false }, { @@ -388,17 +388,17 @@ }, { "path": "tsconfig.app.json", - "content": "// File contents excluded from context", + "content": "{\n \"compilerOptions\": {\n \"target\": \"ES2020\",\n \"useDefineForClassFields\": true,\n \"lib\": [\"ES2020\", \"DOM\", \"DOM.Iterable\"],\n \"module\": \"ESNext\",\n \"skipLibCheck\": true,\n\n /* Bundler mode */\n \"moduleResolution\": \"bundler\",\n \"allowImportingTsExtensions\": true,\n \"isolatedModules\": true,\n \"moduleDetection\": \"force\",\n \"noEmit\": true,\n \"jsx\": \"react-jsx\",\n\n /* Linting */\n \"strict\": false,\n \"noUnusedLocals\": false,\n \"noUnusedParameters\": false,\n \"noImplicitAny\": false,\n \"noFallthroughCasesInSwitch\": false,\n\n \"baseUrl\": \".\",\n \"paths\": {\n \"@/*\": [\"./src/*\"]\n }\n },\n \"include\": [\"src\"]\n}\n", "force": false }, { "path": "tsconfig.json", - "content": "// File contents excluded from context", + "content": "{\n \"files\": [],\n \"references\": [\n { \"path\": \"./tsconfig.app.json\" },\n { \"path\": \"./tsconfig.node.json\" }\n ],\n \"compilerOptions\": {\n \"baseUrl\": \".\",\n \"paths\": {\n \"@/*\": [\"./src/*\"]\n },\n \"noImplicitAny\": false,\n \"noUnusedParameters\": false,\n \"skipLibCheck\": true,\n \"allowJs\": true,\n \"noUnusedLocals\": false,\n \"strictNullChecks\": false\n }\n}\n", "force": false }, { "path": "tsconfig.node.json", - "content": "// File contents excluded from context", + "content": "{\n \"compilerOptions\": {\n \"target\": \"ES2022\",\n \"lib\": [\"ES2023\"],\n \"module\": \"ESNext\",\n \"skipLibCheck\": true,\n\n /* Bundler mode */\n \"moduleResolution\": \"bundler\",\n \"allowImportingTsExtensions\": true,\n \"isolatedModules\": true,\n \"moduleDetection\": \"force\",\n \"noEmit\": true,\n\n /* Linting */\n \"strict\": true,\n \"noUnusedLocals\": false,\n \"noUnusedParameters\": false,\n \"noFallthroughCasesInSwitch\": true\n },\n \"include\": [\"vite.config.ts\"]\n}\n", "force": false }, { diff --git a/e2e-tests/snapshots/engine.spec.ts_send-message-to-engine-1.txt b/e2e-tests/snapshots/engine.spec.ts_send-message-to-engine-1.txt index 0408f9c..50ae7a2 100644 --- a/e2e-tests/snapshots/engine.spec.ts_send-message-to-engine-1.txt +++ b/e2e-tests/snapshots/engine.spec.ts_send-message-to-engine-1.txt @@ -33,7 +33,7 @@ }, { "path": "components.json", - "content": "// File contents excluded from context", + "content": "{\n \"$schema\": \"https://ui.shadcn.com/schema.json\",\n \"style\": \"default\",\n \"rsc\": false,\n \"tsx\": true,\n \"tailwind\": {\n \"config\": \"tailwind.config.ts\",\n \"css\": \"src/index.css\",\n \"baseColor\": \"slate\",\n \"cssVariables\": true,\n \"prefix\": \"\"\n },\n \"aliases\": {\n \"components\": \"@/components\",\n \"utils\": \"@/lib/utils\",\n \"ui\": \"@/components/ui\",\n \"lib\": \"@/lib\",\n \"hooks\": \"@/hooks\"\n }\n}\n", "force": false }, { @@ -388,17 +388,17 @@ }, { "path": "tsconfig.app.json", - "content": "// File contents excluded from context", + "content": "{\n \"compilerOptions\": {\n \"target\": \"ES2020\",\n \"useDefineForClassFields\": true,\n \"lib\": [\"ES2020\", \"DOM\", \"DOM.Iterable\"],\n \"module\": \"ESNext\",\n \"skipLibCheck\": true,\n\n /* Bundler mode */\n \"moduleResolution\": \"bundler\",\n \"allowImportingTsExtensions\": true,\n \"isolatedModules\": true,\n \"moduleDetection\": \"force\",\n \"noEmit\": true,\n \"jsx\": \"react-jsx\",\n\n /* Linting */\n \"strict\": false,\n \"noUnusedLocals\": false,\n \"noUnusedParameters\": false,\n \"noImplicitAny\": false,\n \"noFallthroughCasesInSwitch\": false,\n\n \"baseUrl\": \".\",\n \"paths\": {\n \"@/*\": [\"./src/*\"]\n }\n },\n \"include\": [\"src\"]\n}\n", "force": false }, { "path": "tsconfig.json", - "content": "// File contents excluded from context", + "content": "{\n \"files\": [],\n \"references\": [\n { \"path\": \"./tsconfig.app.json\" },\n { \"path\": \"./tsconfig.node.json\" }\n ],\n \"compilerOptions\": {\n \"baseUrl\": \".\",\n \"paths\": {\n \"@/*\": [\"./src/*\"]\n },\n \"noImplicitAny\": false,\n \"noUnusedParameters\": false,\n \"skipLibCheck\": true,\n \"allowJs\": true,\n \"noUnusedLocals\": false,\n \"strictNullChecks\": false\n }\n}\n", "force": false }, { "path": "tsconfig.node.json", - "content": "// File contents excluded from context", + "content": "{\n \"compilerOptions\": {\n \"target\": \"ES2022\",\n \"lib\": [\"ES2023\"],\n \"module\": \"ESNext\",\n \"skipLibCheck\": true,\n\n /* Bundler mode */\n \"moduleResolution\": \"bundler\",\n \"allowImportingTsExtensions\": true,\n \"isolatedModules\": true,\n \"moduleDetection\": \"force\",\n \"noEmit\": true,\n\n /* Linting */\n \"strict\": true,\n \"noUnusedLocals\": false,\n \"noUnusedParameters\": false,\n \"noFallthroughCasesInSwitch\": true\n },\n \"include\": [\"vite.config.ts\"]\n}\n", "force": false }, { diff --git a/e2e-tests/snapshots/engine.spec.ts_smart-auto-should-send-message-to-engine-1.txt b/e2e-tests/snapshots/engine.spec.ts_smart-auto-should-send-message-to-engine-1.txt index 719ffa0..cf9e74a 100644 --- a/e2e-tests/snapshots/engine.spec.ts_smart-auto-should-send-message-to-engine-1.txt +++ b/e2e-tests/snapshots/engine.spec.ts_smart-auto-should-send-message-to-engine-1.txt @@ -33,7 +33,7 @@ }, { "path": "components.json", - "content": "// File contents excluded from context", + "content": "{\n \"$schema\": \"https://ui.shadcn.com/schema.json\",\n \"style\": \"default\",\n \"rsc\": false,\n \"tsx\": true,\n \"tailwind\": {\n \"config\": \"tailwind.config.ts\",\n \"css\": \"src/index.css\",\n \"baseColor\": \"slate\",\n \"cssVariables\": true,\n \"prefix\": \"\"\n },\n \"aliases\": {\n \"components\": \"@/components\",\n \"utils\": \"@/lib/utils\",\n \"ui\": \"@/components/ui\",\n \"lib\": \"@/lib\",\n \"hooks\": \"@/hooks\"\n }\n}\n", "force": false }, { @@ -388,17 +388,17 @@ }, { "path": "tsconfig.app.json", - "content": "// File contents excluded from context", + "content": "{\n \"compilerOptions\": {\n \"target\": \"ES2020\",\n \"useDefineForClassFields\": true,\n \"lib\": [\"ES2020\", \"DOM\", \"DOM.Iterable\"],\n \"module\": \"ESNext\",\n \"skipLibCheck\": true,\n\n /* Bundler mode */\n \"moduleResolution\": \"bundler\",\n \"allowImportingTsExtensions\": true,\n \"isolatedModules\": true,\n \"moduleDetection\": \"force\",\n \"noEmit\": true,\n \"jsx\": \"react-jsx\",\n\n /* Linting */\n \"strict\": false,\n \"noUnusedLocals\": false,\n \"noUnusedParameters\": false,\n \"noImplicitAny\": false,\n \"noFallthroughCasesInSwitch\": false,\n\n \"baseUrl\": \".\",\n \"paths\": {\n \"@/*\": [\"./src/*\"]\n }\n },\n \"include\": [\"src\"]\n}\n", "force": false }, { "path": "tsconfig.json", - "content": "// File contents excluded from context", + "content": "{\n \"files\": [],\n \"references\": [\n { \"path\": \"./tsconfig.app.json\" },\n { \"path\": \"./tsconfig.node.json\" }\n ],\n \"compilerOptions\": {\n \"baseUrl\": \".\",\n \"paths\": {\n \"@/*\": [\"./src/*\"]\n },\n \"noImplicitAny\": false,\n \"noUnusedParameters\": false,\n \"skipLibCheck\": true,\n \"allowJs\": true,\n \"noUnusedLocals\": false,\n \"strictNullChecks\": false\n }\n}\n", "force": false }, { "path": "tsconfig.node.json", - "content": "// File contents excluded from context", + "content": "{\n \"compilerOptions\": {\n \"target\": \"ES2022\",\n \"lib\": [\"ES2023\"],\n \"module\": \"ESNext\",\n \"skipLibCheck\": true,\n\n /* Bundler mode */\n \"moduleResolution\": \"bundler\",\n \"allowImportingTsExtensions\": true,\n \"isolatedModules\": true,\n \"moduleDetection\": \"force\",\n \"noEmit\": true,\n\n /* Linting */\n \"strict\": true,\n \"noUnusedLocals\": false,\n \"noUnusedParameters\": false,\n \"noFallthroughCasesInSwitch\": true\n },\n \"include\": [\"vite.config.ts\"]\n}\n", "force": false }, { diff --git a/e2e-tests/snapshots/thinking_budget.spec.ts_thinking-budget-2.txt b/e2e-tests/snapshots/thinking_budget.spec.ts_thinking-budget-2.txt index ea305a5..004d590 100644 --- a/e2e-tests/snapshots/thinking_budget.spec.ts_thinking-budget-2.txt +++ b/e2e-tests/snapshots/thinking_budget.spec.ts_thinking-budget-2.txt @@ -41,7 +41,7 @@ }, { "path": "components.json", - "content": "// File contents excluded from context", + "content": "{\n \"$schema\": \"https://ui.shadcn.com/schema.json\",\n \"style\": \"default\",\n \"rsc\": false,\n \"tsx\": true,\n \"tailwind\": {\n \"config\": \"tailwind.config.ts\",\n \"css\": \"src/index.css\",\n \"baseColor\": \"slate\",\n \"cssVariables\": true,\n \"prefix\": \"\"\n },\n \"aliases\": {\n \"components\": \"@/components\",\n \"utils\": \"@/lib/utils\",\n \"ui\": \"@/components/ui\",\n \"lib\": \"@/lib\",\n \"hooks\": \"@/hooks\"\n }\n}\n", "force": false }, { @@ -396,17 +396,17 @@ }, { "path": "tsconfig.app.json", - "content": "// File contents excluded from context", + "content": "{\n \"compilerOptions\": {\n \"target\": \"ES2020\",\n \"useDefineForClassFields\": true,\n \"lib\": [\"ES2020\", \"DOM\", \"DOM.Iterable\"],\n \"module\": \"ESNext\",\n \"skipLibCheck\": true,\n\n /* Bundler mode */\n \"moduleResolution\": \"bundler\",\n \"allowImportingTsExtensions\": true,\n \"isolatedModules\": true,\n \"moduleDetection\": \"force\",\n \"noEmit\": true,\n \"jsx\": \"react-jsx\",\n\n /* Linting */\n \"strict\": false,\n \"noUnusedLocals\": false,\n \"noUnusedParameters\": false,\n \"noImplicitAny\": false,\n \"noFallthroughCasesInSwitch\": false,\n\n \"baseUrl\": \".\",\n \"paths\": {\n \"@/*\": [\"./src/*\"]\n }\n },\n \"include\": [\"src\"]\n}\n", "force": false }, { "path": "tsconfig.json", - "content": "// File contents excluded from context", + "content": "{\n \"files\": [],\n \"references\": [\n { \"path\": \"./tsconfig.app.json\" },\n { \"path\": \"./tsconfig.node.json\" }\n ],\n \"compilerOptions\": {\n \"baseUrl\": \".\",\n \"paths\": {\n \"@/*\": [\"./src/*\"]\n },\n \"noImplicitAny\": false,\n \"noUnusedParameters\": false,\n \"skipLibCheck\": true,\n \"allowJs\": true,\n \"noUnusedLocals\": false,\n \"strictNullChecks\": false\n }\n}\n", "force": false }, { "path": "tsconfig.node.json", - "content": "// File contents excluded from context", + "content": "{\n \"compilerOptions\": {\n \"target\": \"ES2022\",\n \"lib\": [\"ES2023\"],\n \"module\": \"ESNext\",\n \"skipLibCheck\": true,\n\n /* Bundler mode */\n \"moduleResolution\": \"bundler\",\n \"allowImportingTsExtensions\": true,\n \"isolatedModules\": true,\n \"moduleDetection\": \"force\",\n \"noEmit\": true,\n\n /* Linting */\n \"strict\": true,\n \"noUnusedLocals\": false,\n \"noUnusedParameters\": false,\n \"noFallthroughCasesInSwitch\": true\n },\n \"include\": [\"vite.config.ts\"]\n}\n", "force": false }, { diff --git a/e2e-tests/snapshots/thinking_budget.spec.ts_thinking-budget-4.txt b/e2e-tests/snapshots/thinking_budget.spec.ts_thinking-budget-4.txt index dc4e15a..1c0aff9 100644 --- a/e2e-tests/snapshots/thinking_budget.spec.ts_thinking-budget-4.txt +++ b/e2e-tests/snapshots/thinking_budget.spec.ts_thinking-budget-4.txt @@ -49,7 +49,7 @@ }, { "path": "components.json", - "content": "// File contents excluded from context", + "content": "{\n \"$schema\": \"https://ui.shadcn.com/schema.json\",\n \"style\": \"default\",\n \"rsc\": false,\n \"tsx\": true,\n \"tailwind\": {\n \"config\": \"tailwind.config.ts\",\n \"css\": \"src/index.css\",\n \"baseColor\": \"slate\",\n \"cssVariables\": true,\n \"prefix\": \"\"\n },\n \"aliases\": {\n \"components\": \"@/components\",\n \"utils\": \"@/lib/utils\",\n \"ui\": \"@/components/ui\",\n \"lib\": \"@/lib\",\n \"hooks\": \"@/hooks\"\n }\n}\n", "force": false }, { @@ -404,17 +404,17 @@ }, { "path": "tsconfig.app.json", - "content": "// File contents excluded from context", + "content": "{\n \"compilerOptions\": {\n \"target\": \"ES2020\",\n \"useDefineForClassFields\": true,\n \"lib\": [\"ES2020\", \"DOM\", \"DOM.Iterable\"],\n \"module\": \"ESNext\",\n \"skipLibCheck\": true,\n\n /* Bundler mode */\n \"moduleResolution\": \"bundler\",\n \"allowImportingTsExtensions\": true,\n \"isolatedModules\": true,\n \"moduleDetection\": \"force\",\n \"noEmit\": true,\n \"jsx\": \"react-jsx\",\n\n /* Linting */\n \"strict\": false,\n \"noUnusedLocals\": false,\n \"noUnusedParameters\": false,\n \"noImplicitAny\": false,\n \"noFallthroughCasesInSwitch\": false,\n\n \"baseUrl\": \".\",\n \"paths\": {\n \"@/*\": [\"./src/*\"]\n }\n },\n \"include\": [\"src\"]\n}\n", "force": false }, { "path": "tsconfig.json", - "content": "// File contents excluded from context", + "content": "{\n \"files\": [],\n \"references\": [\n { \"path\": \"./tsconfig.app.json\" },\n { \"path\": \"./tsconfig.node.json\" }\n ],\n \"compilerOptions\": {\n \"baseUrl\": \".\",\n \"paths\": {\n \"@/*\": [\"./src/*\"]\n },\n \"noImplicitAny\": false,\n \"noUnusedParameters\": false,\n \"skipLibCheck\": true,\n \"allowJs\": true,\n \"noUnusedLocals\": false,\n \"strictNullChecks\": false\n }\n}\n", "force": false }, { "path": "tsconfig.node.json", - "content": "// File contents excluded from context", + "content": "{\n \"compilerOptions\": {\n \"target\": \"ES2022\",\n \"lib\": [\"ES2023\"],\n \"module\": \"ESNext\",\n \"skipLibCheck\": true,\n\n /* Bundler mode */\n \"moduleResolution\": \"bundler\",\n \"allowImportingTsExtensions\": true,\n \"isolatedModules\": true,\n \"moduleDetection\": \"force\",\n \"noEmit\": true,\n\n /* Linting */\n \"strict\": true,\n \"noUnusedLocals\": false,\n \"noUnusedParameters\": false,\n \"noFallthroughCasesInSwitch\": true\n },\n \"include\": [\"vite.config.ts\"]\n}\n", "force": false }, { diff --git a/e2e-tests/snapshots/thinking_budget.spec.ts_thinking-budget-6.txt b/e2e-tests/snapshots/thinking_budget.spec.ts_thinking-budget-6.txt index d92c4f1..0ad1390 100644 --- a/e2e-tests/snapshots/thinking_budget.spec.ts_thinking-budget-6.txt +++ b/e2e-tests/snapshots/thinking_budget.spec.ts_thinking-budget-6.txt @@ -57,7 +57,7 @@ }, { "path": "components.json", - "content": "// File contents excluded from context", + "content": "{\n \"$schema\": \"https://ui.shadcn.com/schema.json\",\n \"style\": \"default\",\n \"rsc\": false,\n \"tsx\": true,\n \"tailwind\": {\n \"config\": \"tailwind.config.ts\",\n \"css\": \"src/index.css\",\n \"baseColor\": \"slate\",\n \"cssVariables\": true,\n \"prefix\": \"\"\n },\n \"aliases\": {\n \"components\": \"@/components\",\n \"utils\": \"@/lib/utils\",\n \"ui\": \"@/components/ui\",\n \"lib\": \"@/lib\",\n \"hooks\": \"@/hooks\"\n }\n}\n", "force": false }, { @@ -412,17 +412,17 @@ }, { "path": "tsconfig.app.json", - "content": "// File contents excluded from context", + "content": "{\n \"compilerOptions\": {\n \"target\": \"ES2020\",\n \"useDefineForClassFields\": true,\n \"lib\": [\"ES2020\", \"DOM\", \"DOM.Iterable\"],\n \"module\": \"ESNext\",\n \"skipLibCheck\": true,\n\n /* Bundler mode */\n \"moduleResolution\": \"bundler\",\n \"allowImportingTsExtensions\": true,\n \"isolatedModules\": true,\n \"moduleDetection\": \"force\",\n \"noEmit\": true,\n \"jsx\": \"react-jsx\",\n\n /* Linting */\n \"strict\": false,\n \"noUnusedLocals\": false,\n \"noUnusedParameters\": false,\n \"noImplicitAny\": false,\n \"noFallthroughCasesInSwitch\": false,\n\n \"baseUrl\": \".\",\n \"paths\": {\n \"@/*\": [\"./src/*\"]\n }\n },\n \"include\": [\"src\"]\n}\n", "force": false }, { "path": "tsconfig.json", - "content": "// File contents excluded from context", + "content": "{\n \"files\": [],\n \"references\": [\n { \"path\": \"./tsconfig.app.json\" },\n { \"path\": \"./tsconfig.node.json\" }\n ],\n \"compilerOptions\": {\n \"baseUrl\": \".\",\n \"paths\": {\n \"@/*\": [\"./src/*\"]\n },\n \"noImplicitAny\": false,\n \"noUnusedParameters\": false,\n \"skipLibCheck\": true,\n \"allowJs\": true,\n \"noUnusedLocals\": false,\n \"strictNullChecks\": false\n }\n}\n", "force": false }, { "path": "tsconfig.node.json", - "content": "// File contents excluded from context", + "content": "{\n \"compilerOptions\": {\n \"target\": \"ES2022\",\n \"lib\": [\"ES2023\"],\n \"module\": \"ESNext\",\n \"skipLibCheck\": true,\n\n /* Bundler mode */\n \"moduleResolution\": \"bundler\",\n \"allowImportingTsExtensions\": true,\n \"isolatedModules\": true,\n \"moduleDetection\": \"force\",\n \"noEmit\": true,\n\n /* Linting */\n \"strict\": true,\n \"noUnusedLocals\": false,\n \"noUnusedParameters\": false,\n \"noFallthroughCasesInSwitch\": true\n },\n \"include\": [\"vite.config.ts\"]\n}\n", "force": false }, { diff --git a/src/utils/codebase.ts b/src/utils/codebase.ts index d4852ae..4e5b715 100644 --- a/src/utils/codebase.ts +++ b/src/utils/codebase.ts @@ -30,6 +30,8 @@ const ALLOWED_EXTENSIONS = [ ".scss", ".sass", ".less", + // Oftentimes used as config (e.g. package.json, vercel.json) or data files (e.g. translations) + ".json", // GitHub Actions ".yml", ".yaml", @@ -58,7 +60,7 @@ const EXCLUDED_DIRS = ["node_modules", ".git", "dist", "build", ".next"]; 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"]; +const ALWAYS_INCLUDE_FILES = [".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 @@ -69,11 +71,23 @@ const ALWAYS_OMITTED_FILES = [".env", ".env.local"]; // // Why are we not using path.join here? // Because we have already normalized the path to use /. +// +// Note: these files are only omitted when NOT using smart context. +// +// Why do we omit these files when not using smart context? +// +// Because these files are typically low-signal and adding them +// to the context can cause users to much more quickly hit their +// free rate limits. const OMITTED_FILES = [ ...ALWAYS_OMITTED_FILES, "src/components/ui", "eslint.config", "tsconfig.json", + "tsconfig.app.json", + "tsconfig.node.json", + "tsconfig.base.json", + "components.json", ]; // Maximum file size to include (in bytes) - 1MB