From c70f302ecabfa5c251b418283b13e16a3875e052 Mon Sep 17 00:00:00 2001 From: Jay Hack Date: Tue, 23 Jun 2026 11:31:59 -0700 Subject: [PATCH 1/2] Remove agent and AI APIs --- docs/api-reference/core/Codebase.mdx | 50 - docs/api-reference/openapi3.json | 218 - .../codegen-with-wsl.mdx | 6 +- .../comments-and-docstrings.mdx | 29 +- .../dot-codegen.mdx | 12 +- .../parsing-codebases.mdx | 2 +- .../reusable-codemods.mdx | 18 +- .../semantic-code-search.mdx | 133 - docs/cli/about.mdx | 21 +- docs/cli/create.mdx | 5 +- docs/cli/diagnose.mdx | 2 +- docs/cli/doctor.mdx | 2 +- docs/cli/expert.mdx | 58 - docs/cli/init.mdx | 10 +- docs/cli/parse.mdx | 2 +- docs/cli/run.mdx | 2 +- docs/cli/uvx.mdx | 2 +- docs/graph-sitter/about.mdx | 10 +- docs/graph-sitter/getting-started.mdx | 8 - docs/graph-sitter/guiding-principles.mdx | 2 +- docs/graph-sitter/overview.mdx | 15 +- docs/introduction/about.mdx | 10 +- docs/introduction/api.mdx | 77 - docs/introduction/guiding-principles.mdx | 2 +- docs/introduction/overview.mdx | 15 +- docs/snippets/links.mdx | 2 - docs/tutorials/at-a-glance.mdx | 19 - docs/tutorials/attributions.mdx | 191 - .../preparing-your-codebase-for-ai.mdx | 179 - docs/tutorials/training-data.mdx | 202 - examples/STRUCTURE.md | 18 +- .../examples/ai_impact_analysis/README.md | 124 - .../ai_impact_analysis/dashboard/README.md | 86 - .../dashboard/backend/api.py | 54 - .../dashboard/frontend/app/favicon.ico | Bin 15406 -> 0 bytes .../dashboard/frontend/app/globals.css | 76 - .../dashboard/frontend/app/layout.tsx | 34 - .../dashboard/frontend/app/page.tsx | 9 - .../dashboard/frontend/components.json | 21 - .../components/contribution-timeline.tsx | 83 - .../components/contributors-breakdown.tsx | 131 - .../frontend/components/dashboard-header.tsx | 18 - .../components/high-impact-symbols.tsx | 58 - .../frontend/components/loading-screen.tsx | 15 - .../components/repo-analysis-dashboard.tsx | 113 - .../frontend/components/summary-cards.tsx | 77 - .../frontend/components/theme-provider.tsx | 11 - .../frontend/components/top-ai-files.tsx | 48 - .../frontend/components/ui/button.tsx | 56 - .../dashboard/frontend/components/ui/card.tsx | 86 - .../frontend/components/ui/chart.tsx | 365 - .../frontend/components/ui/input-otp.tsx | 71 - .../frontend/components/ui/input.tsx | 22 - .../frontend/components/ui/progress.tsx | 28 - .../frontend/components/ui/scroll-area.tsx | 48 - .../frontend/components/ui/skeleton.tsx | 15 - .../frontend/components/ui/use-mobile.tsx | 21 - .../frontend/components/ui/use-toast.ts | 191 - .../dashboard/frontend/hooks/use-mobile.tsx | 21 - .../dashboard/frontend/hooks/use-toast.ts | 191 - .../dashboard/frontend/lib/types.ts | 27 - .../dashboard/frontend/lib/utils.ts | 6 - .../dashboard/frontend/next.config.mjs | 48 - .../dashboard/frontend/package-lock.json | 4532 ------ .../dashboard/frontend/package.json | 70 - .../dashboard/frontend/postcss.config.mjs | 8 - .../dashboard/frontend/styles/globals.css | 94 - .../dashboard/frontend/tailwind.config.js | 77 - .../dashboard/frontend/tsconfig.json | 27 - examples/examples/ai_impact_analysis/run.py | 60 - .../examples/codegen-mcp-server/README.md | 67 - .../codegen-mcp-server/llms-install.md | 17 - .../codegen-mcp-server/pyproject.toml | 20 - .../examples/codegen-mcp-server/server.py | 470 - examples/examples/codegen-mcp-server/uv.lock | 2643 ---- .../examples/document_functions/README.md | 100 - examples/examples/document_functions/run.py | 119 - .../examples/generate_training_data/README.md | 92 - .../examples/generate_training_data/run.py | 105 - examples/examples/modal_repo_rag/README.md | 120 - examples/examples/modal_repo_rag/api.py | 126 - .../examples/modal_repo_rag/pyproject.toml | 11 - .../examples/symbol-attributions/README.md | 92 - examples/examples/symbol-attributions/run.py | 92 - examples/pyproject.toml | 3 - examples/uv.lock | 3129 ++--- pyproject.toml | 4 - site/lib/docs.ts | 2 - src/graph_sitter/ai/client.py | 5 - src/graph_sitter/cli/auth/constants.py | 1 - src/graph_sitter/cli/cli.py | 4 +- src/graph_sitter/cli/codemod/convert.py | 2 +- src/graph_sitter/cli/commands/create/main.py | 7 +- src/graph_sitter/cli/commands/init/main.py | 2 +- src/graph_sitter/cli/commands/init/render.py | 4 +- src/graph_sitter/cli/mcp/README.md | 40 - .../cli/mcp/resources/system_prompt.py | 9911 ------------- .../resources/system_setup_instructions.py | 11 - src/graph_sitter/cli/mcp/server.py | 58 - src/graph_sitter/cli/utils/codemods.py | 11 - .../cli/workspace/initialize_workspace.py | 6 +- .../code_generation/changelog_generation.py | 142 - .../code_generation/prompts/api_docs.py | 4 +- .../token_utils.py} | 2 +- src/graph_sitter/codebase/codebase_ai.py | 208 - src/graph_sitter/codebase/config.py | 4 - src/graph_sitter/configs/constants.py | 1 - src/graph_sitter/configs/models/secrets.py | 1 - src/graph_sitter/core/codebase.py | 127 +- src/graph_sitter/extensions/__init__.py | 7 +- .../extensions/attribution/3pp/__init__.py | 1 - .../extensions/attribution/3pp/cursor.py | 593 - .../extensions/attribution/3pp/windsurf.py | 186 - .../extensions/attribution/cli.py | 153 - .../extensions/attribution/git_history.py | 433 - .../extensions/attribution/main.py | 87 - src/graph_sitter/extensions/index/__init__.py | 0 .../extensions/index/code_index.py | 225 - .../extensions/index/file_index.py | 366 - .../extensions/index/symbol_index.py | 160 - src/graph_sitter/extensions/mcp/README.md | 43 - .../extensions/mcp/codebase_mods.py | 47 - .../extensions/mcp/codebase_tools.py | 59 - .../extensions/swebench/README.md | 29 - .../extensions/swebench/__init__.py | 0 src/graph_sitter/extensions/swebench/enums.py | 13 - .../extensions/swebench/harness.py | 200 - .../extensions/swebench/report.py | 154 - .../extensions/swebench/subsets.py | 146 - .../extensions/swebench/success_rates.py | 302 - src/graph_sitter/extensions/swebench/tests.py | 33 - src/graph_sitter/extensions/swebench/utils.py | 135 - src/graph_sitter/gscli/generate/commands.py | 57 - .../gscli/generate/system_prompt.py | 41 - src/graph_sitter/output/ast.py | 2 +- src/graph_sitter/shared/decorators/docs.py | 10 +- .../shared/exceptions/control_flow.py | 8 - src/graph_sitter/system-prompt.txt | 11684 ---------------- src/graph_sitter/typescript/symbol.py | 2 +- src/graph_sitter/writer_decorators.py | 2 +- .../test_api_doc_generation.py | 2 +- .../codemod/test_verified_codemods.py | 3 - tests/integration/test_vector_index.py | 137 - tests/shared/mocks/mock_ai_helper.py | 35 - tests/unit/runner/sandbox/test_executor.py | 12 - .../sdk/python/codebase/test_control_flow.py | 14 - .../unit/skills/implementations/ai_skills.py | 147 - .../missing-documentation.py | 83 - .../implementations/guides/codebase-ai.py | 324 - .../guides/creating-documentation.py | 68 - uv.lock | 377 - 151 files changed, 1452 insertions(+), 41035 deletions(-) delete mode 100644 docs/building-with-graph-sitter/semantic-code-search.mdx delete mode 100644 docs/cli/expert.mdx delete mode 100644 docs/introduction/api.mdx delete mode 100644 docs/tutorials/attributions.mdx delete mode 100644 docs/tutorials/preparing-your-codebase-for-ai.mdx delete mode 100644 docs/tutorials/training-data.mdx delete mode 100644 examples/examples/ai_impact_analysis/README.md delete mode 100644 examples/examples/ai_impact_analysis/dashboard/README.md delete mode 100644 examples/examples/ai_impact_analysis/dashboard/backend/api.py delete mode 100644 examples/examples/ai_impact_analysis/dashboard/frontend/app/favicon.ico delete mode 100644 examples/examples/ai_impact_analysis/dashboard/frontend/app/globals.css delete mode 100644 examples/examples/ai_impact_analysis/dashboard/frontend/app/layout.tsx delete mode 100644 examples/examples/ai_impact_analysis/dashboard/frontend/app/page.tsx delete mode 100644 examples/examples/ai_impact_analysis/dashboard/frontend/components.json delete mode 100644 examples/examples/ai_impact_analysis/dashboard/frontend/components/contribution-timeline.tsx delete mode 100644 examples/examples/ai_impact_analysis/dashboard/frontend/components/contributors-breakdown.tsx delete mode 100644 examples/examples/ai_impact_analysis/dashboard/frontend/components/dashboard-header.tsx delete mode 100644 examples/examples/ai_impact_analysis/dashboard/frontend/components/high-impact-symbols.tsx delete mode 100644 examples/examples/ai_impact_analysis/dashboard/frontend/components/loading-screen.tsx delete mode 100644 examples/examples/ai_impact_analysis/dashboard/frontend/components/repo-analysis-dashboard.tsx delete mode 100644 examples/examples/ai_impact_analysis/dashboard/frontend/components/summary-cards.tsx delete mode 100644 examples/examples/ai_impact_analysis/dashboard/frontend/components/theme-provider.tsx delete mode 100644 examples/examples/ai_impact_analysis/dashboard/frontend/components/top-ai-files.tsx delete mode 100644 examples/examples/ai_impact_analysis/dashboard/frontend/components/ui/button.tsx delete mode 100644 examples/examples/ai_impact_analysis/dashboard/frontend/components/ui/card.tsx delete mode 100644 examples/examples/ai_impact_analysis/dashboard/frontend/components/ui/chart.tsx delete mode 100644 examples/examples/ai_impact_analysis/dashboard/frontend/components/ui/input-otp.tsx delete mode 100644 examples/examples/ai_impact_analysis/dashboard/frontend/components/ui/input.tsx delete mode 100644 examples/examples/ai_impact_analysis/dashboard/frontend/components/ui/progress.tsx delete mode 100644 examples/examples/ai_impact_analysis/dashboard/frontend/components/ui/scroll-area.tsx delete mode 100644 examples/examples/ai_impact_analysis/dashboard/frontend/components/ui/skeleton.tsx delete mode 100644 examples/examples/ai_impact_analysis/dashboard/frontend/components/ui/use-mobile.tsx delete mode 100644 examples/examples/ai_impact_analysis/dashboard/frontend/components/ui/use-toast.ts delete mode 100644 examples/examples/ai_impact_analysis/dashboard/frontend/hooks/use-mobile.tsx delete mode 100644 examples/examples/ai_impact_analysis/dashboard/frontend/hooks/use-toast.ts delete mode 100644 examples/examples/ai_impact_analysis/dashboard/frontend/lib/types.ts delete mode 100644 examples/examples/ai_impact_analysis/dashboard/frontend/lib/utils.ts delete mode 100644 examples/examples/ai_impact_analysis/dashboard/frontend/next.config.mjs delete mode 100644 examples/examples/ai_impact_analysis/dashboard/frontend/package-lock.json delete mode 100644 examples/examples/ai_impact_analysis/dashboard/frontend/package.json delete mode 100644 examples/examples/ai_impact_analysis/dashboard/frontend/postcss.config.mjs delete mode 100644 examples/examples/ai_impact_analysis/dashboard/frontend/styles/globals.css delete mode 100644 examples/examples/ai_impact_analysis/dashboard/frontend/tailwind.config.js delete mode 100644 examples/examples/ai_impact_analysis/dashboard/frontend/tsconfig.json delete mode 100644 examples/examples/ai_impact_analysis/run.py delete mode 100644 examples/examples/codegen-mcp-server/README.md delete mode 100644 examples/examples/codegen-mcp-server/llms-install.md delete mode 100644 examples/examples/codegen-mcp-server/pyproject.toml delete mode 100644 examples/examples/codegen-mcp-server/server.py delete mode 100644 examples/examples/codegen-mcp-server/uv.lock delete mode 100644 examples/examples/document_functions/README.md delete mode 100644 examples/examples/document_functions/run.py delete mode 100644 examples/examples/generate_training_data/README.md delete mode 100644 examples/examples/generate_training_data/run.py delete mode 100644 examples/examples/modal_repo_rag/README.md delete mode 100644 examples/examples/modal_repo_rag/api.py delete mode 100644 examples/examples/modal_repo_rag/pyproject.toml delete mode 100644 examples/examples/symbol-attributions/README.md delete mode 100644 examples/examples/symbol-attributions/run.py delete mode 100644 src/graph_sitter/ai/client.py delete mode 100644 src/graph_sitter/cli/mcp/README.md delete mode 100644 src/graph_sitter/cli/mcp/resources/system_prompt.py delete mode 100644 src/graph_sitter/cli/mcp/resources/system_setup_instructions.py delete mode 100644 src/graph_sitter/cli/mcp/server.py delete mode 100644 src/graph_sitter/code_generation/changelog_generation.py rename src/graph_sitter/{ai/utils.py => code_generation/token_utils.py} (88%) delete mode 100644 src/graph_sitter/codebase/codebase_ai.py delete mode 100644 src/graph_sitter/extensions/attribution/3pp/__init__.py delete mode 100644 src/graph_sitter/extensions/attribution/3pp/cursor.py delete mode 100644 src/graph_sitter/extensions/attribution/3pp/windsurf.py delete mode 100644 src/graph_sitter/extensions/attribution/cli.py delete mode 100644 src/graph_sitter/extensions/attribution/git_history.py delete mode 100644 src/graph_sitter/extensions/attribution/main.py delete mode 100644 src/graph_sitter/extensions/index/__init__.py delete mode 100644 src/graph_sitter/extensions/index/code_index.py delete mode 100644 src/graph_sitter/extensions/index/file_index.py delete mode 100644 src/graph_sitter/extensions/index/symbol_index.py delete mode 100644 src/graph_sitter/extensions/mcp/README.md delete mode 100644 src/graph_sitter/extensions/mcp/codebase_mods.py delete mode 100644 src/graph_sitter/extensions/mcp/codebase_tools.py delete mode 100644 src/graph_sitter/extensions/swebench/README.md delete mode 100644 src/graph_sitter/extensions/swebench/__init__.py delete mode 100644 src/graph_sitter/extensions/swebench/enums.py delete mode 100644 src/graph_sitter/extensions/swebench/harness.py delete mode 100755 src/graph_sitter/extensions/swebench/report.py delete mode 100644 src/graph_sitter/extensions/swebench/subsets.py delete mode 100644 src/graph_sitter/extensions/swebench/success_rates.py delete mode 100755 src/graph_sitter/extensions/swebench/tests.py delete mode 100644 src/graph_sitter/extensions/swebench/utils.py delete mode 100644 src/graph_sitter/gscli/generate/system_prompt.py delete mode 100644 src/graph_sitter/system-prompt.txt delete mode 100644 tests/integration/test_vector_index.py delete mode 100644 tests/shared/mocks/mock_ai_helper.py delete mode 100644 tests/unit/skills/implementations/ai_skills.py delete mode 100644 tests/unit/skills/implementations/guides/code-quality-metrics/missing-documentation.py delete mode 100644 tests/unit/skills/implementations/guides/codebase-ai.py diff --git a/docs/api-reference/core/Codebase.mdx b/docs/api-reference/core/Codebase.mdx index 854af3782..566b16b38 100644 --- a/docs/api-reference/core/Codebase.mdx +++ b/docs/api-reference/core/Codebase.mdx @@ -87,41 +87,6 @@ import {Attribute} from '/snippets/Attribute.mdx'; ## Methods -### ai -Generates a response from the AI based on the provided prompt, target, and context. - - - -str } - description="The text prompt to send to the AI." - defaultValue="" -/> -Editable | None } - description="An optional editable object (like a function, class, etc.) that provides the main focus for the AI's response." - defaultValue="None" -/> -Editable | list[ Editable ] | dict[str, Editable | list[ Editable ]] | None } - description="Additional context to help inform the AI's response." - defaultValue="None" -/> -str } - description="The AI model to use for generating the response. Defaults to "gpt-4o"." - defaultValue=""gpt-4o"" -/> - - - -str } description="The generated response from the AI."/> - - ### checkout Checks out a git branch or commit and syncs the codebase graph to the new state. @@ -622,14 +587,6 @@ Resets the codebase by None } description=""/> -### set_ai_key -Sets the OpenAI key for the current Codebase instance. - - - -None } description=""/> - - ### set_session_options Sets the session options for the current codebase. @@ -647,12 +604,6 @@ Sets the session options for the current codebase. description="The maximum duration in seconds for a session" defaultValue="" /> -int, optional } - description="The maximum number of AI requests" - defaultValue="" -/> @@ -699,4 +650,3 @@ Visualizes a NetworkX graph or Plotly figure. None } description=""/> - diff --git a/docs/api-reference/openapi3.json b/docs/api-reference/openapi3.json index a1283d875..bb559e584 100644 --- a/docs/api-reference/openapi3.json +++ b/docs/api-reference/openapi3.json @@ -165,160 +165,6 @@ } } }, - "/v1/organizations/{org_id}/agent/run": { - "post": { - "tags": ["agents", "agents", "agents"], - "summary": "Create Agent Run", - "description": "Create a new agent run.\n\nCreates and initiates a long-running agent process based on the provided prompt.\nThe process will complete asynchronously, and the response contains the agent run ID\nwhich can be used to check the status later. The requesting user must be a member\nof the specified organization.\n\nRate limit: 10 requests per minute.", - "operationId": "create_agent_run_v1_organizations__org_id__agent_run_post", - "parameters": [ - { - "name": "org_id", - "in": "path", - "required": true, - "schema": { "type": "integer", "title": "Org Id" } - }, - { - "name": "authorization", - "in": "header", - "required": false, - "schema": { "title": "Authorization" } - } - ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/CreateAgentRunInput" } - } - } - }, - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/AgentRunResponse" } - } - } - }, - "429": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/APIRateLimitErrorResponse" - } - } - }, - "description": "Too Many Requests" - }, - "402": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/AgentRunLimitReachedErrorResponse" - } - } - }, - "description": "Payment Required" - }, - "403": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/PermissionsErrorResponse" - } - } - }, - "description": "Forbidden" - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - } - } - }, - "/v1/organizations/{org_id}/agent/run/{agent_run_id}": { - "get": { - "tags": ["agents", "agents", "agents"], - "summary": "Get Agent Run", - "description": "Retrieve the status and result of an agent run.\n\nReturns the current status, progress, and any available results for the specified agent run.\nThe agent run must belong to the specified organization. If the agent run is still in progress,\nthis endpoint can be polled to check for completion.\n\nRate limit: 60 requests per 30 seconds.", - "operationId": "get_agent_run_v1_organizations__org_id__agent_run__agent_run_id__get", - "parameters": [ - { - "name": "agent_run_id", - "in": "path", - "required": true, - "schema": { "type": "integer", "title": "Agent Run Id" } - }, - { - "name": "org_id", - "in": "path", - "required": true, - "schema": { "type": "integer", "title": "Org Id" } - }, - { - "name": "authorization", - "in": "header", - "required": false, - "schema": { "title": "Authorization" } - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/AgentRunResponse" } - } - } - }, - "429": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/APIRateLimitErrorResponse" - } - } - }, - "description": "Too Many Requests" - }, - "403": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/PermissionsErrorResponse" - } - } - }, - "description": "Forbidden" - }, - "404": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/AgentRunNotFoundErrorResponse" - } - } - }, - "description": "Not Found" - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { "$ref": "#/components/schemas/HTTPValidationError" } - } - } - } - } - } - }, "/v1/organizations": { "get": { "tags": ["organizations", "organizations", "organizations"], @@ -407,70 +253,6 @@ "type": "object", "title": "APIRateLimitErrorResponse" }, - "AgentRunLimitReachedErrorResponse": { - "properties": { - "message": { - "type": "string", - "title": "Message", - "default": "Alloted agent runs for the current billing plan have been reached. Please upgrade your plan to continue." - }, - "status_code": { - "type": "integer", - "title": "Status Code", - "default": 402 - } - }, - "type": "object", - "title": "AgentRunLimitReachedErrorResponse" - }, - "AgentRunNotFoundErrorResponse": { - "properties": { - "message": { - "type": "string", - "title": "Message", - "default": "Agent run not found." - }, - "status_code": { - "type": "integer", - "title": "Status Code", - "default": 404 - } - }, - "type": "object", - "title": "AgentRunNotFoundErrorResponse" - }, - "AgentRunResponse": { - "properties": { - "id": { "type": "integer", "title": "Id" }, - "organization_id": { "type": "integer", "title": "Organization Id" }, - "status": { - "anyOf": [{ "type": "string" }, { "type": "null" }], - "title": "Status" - }, - "created_at": { - "anyOf": [{ "type": "string" }, { "type": "null" }], - "title": "Created At" - }, - "web_url": { - "anyOf": [{ "type": "string" }, { "type": "null" }], - "title": "Web Url" - }, - "result": { - "anyOf": [{ "type": "string" }, { "type": "null" }], - "title": "Result" - } - }, - "type": "object", - "required": ["id", "organization_id"], - "title": "AgentRunResponse", - "description": "Represents an agent run in API responses" - }, - "CreateAgentRunInput": { - "properties": { "prompt": { "type": "string", "title": "Prompt" } }, - "type": "object", - "required": ["prompt"], - "title": "CreateAgentRunInput" - }, "HTTPValidationError": { "properties": { "detail": { diff --git a/docs/building-with-graph-sitter/codegen-with-wsl.mdx b/docs/building-with-graph-sitter/codegen-with-wsl.mdx index da82c74a6..a80d065de 100644 --- a/docs/building-with-graph-sitter/codegen-with-wsl.mdx +++ b/docs/building-with-graph-sitter/codegen-with-wsl.mdx @@ -58,13 +58,9 @@ To use WSL with VSCode: You can read more about Developing in WSL [here](https://code.visualstudio.com/docs/remote/wsl). - -If you plan on using Codegen's MCP (Model Context Protocol) or LSP (Language Server Protocol) features, running VSCode through WSL is highly recommended. - - ## Troubleshooting -- **I have trouble connecting to MCP or LSP from VSCode**: Windows and WSL run on two different network environments. WSL does come with a compatibility layer called [NAT (Network Address Translation)](https://learn.microsoft.com/en-us/windows/wsl/networking#default-networking-mode-nat) as a translation layer between the two environments, but it can sometimes cause issues. On machines running Windows 11 22H2 and higher, try switching to [Mirrored mode networking](https://learn.microsoft.com/en-us/windows/wsl/networking#mirrored-mode-networking) to see if that fixes the issue. +- **I have trouble connecting development tools from VSCode**: Windows and WSL run on two different network environments. WSL does come with a compatibility layer called [NAT (Network Address Translation)](https://learn.microsoft.com/en-us/windows/wsl/networking#default-networking-mode-nat) as a translation layer between the two environments, but it can sometimes cause issues. On machines running Windows 11 22H2 and higher, try switching to [Mirrored mode networking](https://learn.microsoft.com/en-us/windows/wsl/networking#mirrored-mode-networking) to see if that fixes the issue. - **WSL takes up too much memory after running Codegen**: This is a known issue with WSL. Memory does not get properly released after running a memory-intensive process like Codegen. Try killing the WSL process using `wsl --shutdown` to free up memory. ([GitHub Issue for WSL](https://github.com/microsoft/WSL/issues/4166)) - **WSL hangs and pins the CPU at 100% when I try to run Codegen**: This could be because of WSL running out of memory. Try killing the WSL process using `wsl --shutdown` and then try running Graph-sitter again. If that doesn't work, try [downloading more RAM](https://downloadmoreram.com/). diff --git a/docs/building-with-graph-sitter/comments-and-docstrings.mdx b/docs/building-with-graph-sitter/comments-and-docstrings.mdx index 759afd2c4..e5a108ce1 100644 --- a/docs/building-with-graph-sitter/comments-and-docstrings.mdx +++ b/docs/building-with-graph-sitter/comments-and-docstrings.mdx @@ -147,7 +147,7 @@ for file in codebase.files: indentation and maintains the existing comment style. -## Special APIs and AI Integration +## Special APIs ### Google Style Docstrings @@ -160,31 +160,6 @@ func_b = symbol_a.get_method("funcB") func_b.docstring.to_google_docstring(func_b) ``` -### Using AI for Documentation - -Graph-sitter integrates with LLMs to help generate and improve documentation. You can use the [Codebase.ai(...)](/api-reference/core/Codebase#ai) method to: - -- Generate comprehensive docstrings -- Update existing documentation -- Convert between documentation styles -- Add parameter descriptions - -```python -# Generate a docstring using AI -function = codebase.get_function("my_function") - -new_docstring = codebase.ai( - "Generate a comprehensive docstring in Google style", - target=function - context={ - # provide additional context to the LLM - 'usages': function.usages, - 'dependencies': function.dependencies - } -) -function.set_docstring(new_docstring) -``` - ### Documentation Coverage You can analyze and improve documentation coverage across your codebase: @@ -200,4 +175,4 @@ for function in codebase.functions: coverage = (documented / total * 100) if total > 0 else 0 print(f"Documentation coverage: {coverage:.1f}%") -``` \ No newline at end of file +``` diff --git a/docs/building-with-graph-sitter/dot-codegen.mdx b/docs/building-with-graph-sitter/dot-codegen.mdx index 42420ad91..d1aaa8d32 100644 --- a/docs/building-with-graph-sitter/dot-codegen.mdx +++ b/docs/building-with-graph-sitter/dot-codegen.mdx @@ -14,8 +14,7 @@ The `.codegen` directory contains your project's Graph-sitter configuration, cod ├── .venv/ # Python virtual environment (gitignored) ├── config.toml # Project configuration ├── codemods/ # Your codemod implementations -├── jupyter/ # Jupyter notebooks for exploration -└── codegen-system-prompt.txt # AI system prompt +└── jupyter/ # Jupyter notebooks for exploration ``` ## Initialization @@ -62,7 +61,6 @@ Graph-sitter automatically adds appropriate entries to your `.gitignore`: .codegen/.venv/ .codegen/docs/ .codegen/jupyter/ -.codegen/codegen-system-prompt.txt ``` @@ -75,13 +73,12 @@ Graph-sitter automatically adds appropriate entries to your `.gitignore`: The `codemods/` directory is where your transformation functions live. You can create new codemods using: ```bash -gs create my-codemod PATH [--description "what it does"] +gs create my-codemod PATH ``` This will: 1. Create a new file in `.codegen/codemods/` -2. Generate a system prompt in `.codegen/prompts/` (if using `--description`) -3. Set up the necessary imports and decorators +2. Set up the necessary imports and decorators Use `gs list` to see all codemods in your project. @@ -112,11 +109,10 @@ After initializing your `.codegen` directory: 1. Create your first codemod: ```bash -gs create my-codemod . -d "describe what you want to do" +gs create my-codemod . ``` 2. Run it: ```bash gs run my-codemod --apply-local ``` - diff --git a/docs/building-with-graph-sitter/parsing-codebases.mdx b/docs/building-with-graph-sitter/parsing-codebases.mdx index d1a93c809..1a14b554c 100644 --- a/docs/building-with-graph-sitter/parsing-codebases.mdx +++ b/docs/building-with-graph-sitter/parsing-codebases.mdx @@ -75,7 +75,7 @@ from graph_sitter.configs.models.secrets import SecretsConfig codebase = Codebase( "path/to/repository", config=CodebaseConfig(debug=True), - secrets=SecretsConfig(openai_api_key="your-openai-key") # For AI-powered features + secrets=SecretsConfig(github_token="your-github-token"), ) ``` diff --git a/docs/building-with-graph-sitter/reusable-codemods.mdx b/docs/building-with-graph-sitter/reusable-codemods.mdx index fa3211f91..9d414b268 100644 --- a/docs/building-with-graph-sitter/reusable-codemods.mdx +++ b/docs/building-with-graph-sitter/reusable-codemods.mdx @@ -32,19 +32,6 @@ def run(codebase: Codebase): Codemods are stored in `.codegen/codemods/name/name.py` and are tracked in Git for easy sharing. -### AI-Powered Generation with `-d` - -You can use AI to generate an initial implementation by providing a description: - -```bash -gs create rename-function . -d "Rename the getUserData function to fetchUserProfile" -``` - -This will: -1. Generate an implementation based on your description -2. Create a custom system prompt that you can provide to an IDE chat assistant -3. Place both files in the codemod directory - ## Running Codemods Once created, run your codemod using: @@ -115,6 +102,5 @@ Your codemods live in a dedicated directory structure: .codegen/ └── codemods/ └── rename_function/ - ├── rename_function.py # The codemod implementation - └── rename_function_prompt.md # System prompt (if using AI) -``` \ No newline at end of file + └── rename_function.py # The codemod implementation +``` diff --git a/docs/building-with-graph-sitter/semantic-code-search.mdx b/docs/building-with-graph-sitter/semantic-code-search.mdx deleted file mode 100644 index 2b54ee8ac..000000000 --- a/docs/building-with-graph-sitter/semantic-code-search.mdx +++ /dev/null @@ -1,133 +0,0 @@ ---- -title: "Semantic Code Search" -sidebarTitle: "Semantic Code Search" -icon: "magnifying-glass" -iconType: "solid" ---- - -Graph-sitter provides semantic code search capabilities using embeddings. This allows you to search codebases using natural language queries and find semantically related code, even when the exact terms aren't present. - -This is under active development. Interested in an application? [Reach out to the team!](/introduction/about.tsx) - -## Basic Usage - -Here's how to create and use a semantic code search index: - -```python -# Parse a codebase -codebase = Codebase.from_repo('fastapi/fastapi', language='python') - -# Create index -index = FileIndex(codebase) -index.create() # computes per-file embeddings - -# Save index to .pkl -index.save('index.pkl') - -# Load index into memory -index.load('index.pkl') - -# Update index after changes -codebase.files[0].edit('# 🌈 Replacing File Content 🌈') -codebase.commit() -index.update() # re-computes 1 embedding -``` - - -## Searching Code - -Once you have an index, you can perform semantic searches: - -```python -# Search with natural language -results = index.similarity_search( - "How does FastAPI handle dependency injection?", - k=5 # number of results -) - -# Print results -for file, score in results: - print(f"\nScore: {score:.3f} | File: {file.filepath}") - print(f"Preview: {file.content[:200]}...") -``` -The `FileIndex` returns tuples of ([File](/api-reference/core/SourceFile), `score`) - - -The search uses cosine similarity between embeddings to find the most semantically related files, regardless of exact keyword matches. - - -## Available Indices - -Graph-sitter provides two types of semantic indices: - -### FileIndex - -The `FileIndex` operates at the file level: -- Indexes entire files, splitting large files into chunks -- Best for finding relevant files or modules -- Simpler and faster to create/update - -```python -from graph_sitter.extensions.index.file_index import FileIndex - -index = FileIndex(codebase) -index.create() -``` - -### SymbolIndex (Experimental) - -The `SymbolIndex` operates at the symbol level: -- Indexes individual functions, classes, and methods -- Better for finding specific code elements -- More granular search results - -```python -from graph_sitter.extensions.index.symbol_index import SymbolIndex - -index = SymbolIndex(codebase) -index.create() -``` - -## How It Works - -The semantic indices: -1. Process code at either file or symbol level -2. Split large content into chunks that fit within token limits -3. Use OpenAI's text-embedding-3-small model to create embeddings -4. Store embeddings efficiently for similarity search -5. Support incremental updates when code changes - -When searching: -1. Your query is converted to an embedding -2. Cosine similarity is computed with all stored embeddings -3. The most similar items are returned with their scores - - -Creating embeddings requires an OpenAI API key with access to the embeddings endpoint. - - -## Example Searches - -Here are some example semantic searches: - -```python -# Find authentication-related code -results = index.similarity_search( - "How is user authentication implemented?", - k=3 -) - -# Find error handling patterns -results = index.similarity_search( - "Show me examples of error handling and custom exceptions", - k=3 -) - -# Find configuration management -results = index.similarity_search( - "Where is the application configuration and settings handled?", - k=3 -) -``` - -The semantic search can understand concepts and return relevant results even when the exact terms aren't present in the code. diff --git a/docs/cli/about.mdx b/docs/cli/about.mdx index 397ff5107..ac52bad9b 100644 --- a/docs/cli/about.mdx +++ b/docs/cli/about.mdx @@ -12,7 +12,6 @@ The Graph-sitter CLI helps you: - Initialize Graph-sitter in your repository - Create and run codemods - Run one-shot transformations by import path -- Work with AI assistance For installation instructions, see our [Getting @@ -51,11 +50,9 @@ graph-sitter init 4. **Create your first codemod**: ```bash -graph-sitter create my-codemod --description "What you want to accomplish" +graph-sitter create my-codemod . ``` -The `--description` flag enables AI assistance to help generate your codemod. Be as specific as possible about what you want to achieve. - ## Available Commands @@ -75,7 +72,7 @@ The `--description` flag enables AI assistance to help generate your codemod. Be Report parse time, memory use, and graph size for a repository. - Create new codemods with optional AI assistance. + Scaffold new codemods. Execute registered codemods with check and write modes. @@ -83,18 +80,4 @@ The `--description` flag enables AI assistance to help generate your codemod. Be Run one-shot codemods by Python import path or file path. - - Use Graph-sitter docs and project context with an AI assistant. - - -## Working with AI - -When using Cursor, you can mention `@codegen-sh` in any chat or composer window to get: - -- Documentation about available APIs -- Context about your active codemod -- Examples of similar codemods -- Relevant code snippets - -The AI uses this context to provide accurate and helpful responses about working with Codegen. diff --git a/docs/cli/create.mdx b/docs/cli/create.mdx index 30d24fb46..71b213f0b 100644 --- a/docs/cli/create.mdx +++ b/docs/cli/create.mdx @@ -24,7 +24,7 @@ gs create NAME PATH [OPTIONS] ## Options -- `--description`, `-d`: A description of what the codemod should do. This will be used to generate an AI-powered implementation. +- `--overwrite`: Replace an existing codemod file with the same name. ## Generated Files @@ -34,8 +34,7 @@ When you run `gs create rename-function .`, it creates: .codegen/ └── codemods/ └── rename_function/ - ├── rename_function.py # The codemod implementation - └── rename_function-system-prompt.txt # System prompt (if --description used) + └── rename_function.py # The codemod implementation ``` The generated codemod will have this structure: diff --git a/docs/cli/diagnose.mdx b/docs/cli/diagnose.mdx index 37287b55b..dc9676670 100644 --- a/docs/cli/diagnose.mdx +++ b/docs/cli/diagnose.mdx @@ -44,7 +44,7 @@ Human-readable output includes: - Memory delta - Core graph counts such as symbols, imports, exports, and dependencies -Use JSON output in CI or agent workflows: +Use JSON output in CI or automation workflows: ```bash graph-sitter diagnose . --language python --backend rust --fallback error --json diff --git a/docs/cli/doctor.mdx b/docs/cli/doctor.mdx index b3336772a..c674c67de 100644 --- a/docs/cli/doctor.mdx +++ b/docs/cli/doctor.mdx @@ -6,7 +6,7 @@ iconType: "solid" --- The `doctor` command checks whether Graph-sitter can run in the current Python -environment. It is useful for setup, CI, and agent workflows before parsing a +environment. It is useful for setup, CI, and automation workflows before parsing a large repository or running a codemod. ```bash diff --git a/docs/cli/expert.mdx b/docs/cli/expert.mdx deleted file mode 100644 index 4f5fb8a3c..000000000 --- a/docs/cli/expert.mdx +++ /dev/null @@ -1,58 +0,0 @@ ---- -title: "AI Assistance" -sidebarTitle: "expert" -icon: "robot" -iconType: "solid" ---- - -Use this workflow when you want an AI assistant to help write, review, or refine -Graph-sitter codemods. - - - This branch does not expose a standalone `gs expert` shell command. The - `expert` page describes the AI-assistance workflow around the documented CLI - commands. - - -## Recommended Flow - -1. Initialize Graph-sitter in the target repository. - -```bash -gs init -``` - -2. Scaffold a codemod. - -```bash -gs create rename-function . -``` - -3. Ask your assistant to edit the generated codemod with Graph-sitter APIs such -as `Codebase`, `Function`, `Import`, and `commit()`. - -4. Run the codemod in check mode before applying changes. - -```bash -gs run rename-function . --check -``` - -5. Apply the codemod after reviewing the diff. - -```bash -gs run rename-function . --write -``` - -## What To Give The Assistant - -- The goal of the codemod. -- The target repository path and language. -- Any expected symbol names, import paths, or file patterns. -- Whether the run should use the Python backend or the opt-in Rust backend. -- The generated codemod file under `.codegen/codemods/`. - -## Related Commands - -- [`create`](/cli/create): scaffold a codemod file. -- [`run`](/cli/run): execute a local codemod. -- [`parse`](/cli/about): inspect the codebase graph before editing. diff --git a/docs/cli/init.mdx b/docs/cli/init.mdx index fcacad300..e7ae90bdd 100644 --- a/docs/cli/init.mdx +++ b/docs/cli/init.mdx @@ -27,11 +27,8 @@ When you run `init`, gs creates a `.codegen` directory in your repository with t ├── config.toml # Configuration file with repo and org info ├── codemods/ # Your codemods live here │ └── my_codemod.py # Created via `gs create my-codemod` -├── docs/ # Local documentation for offline access -│ ├── api/ -│ ├── examples/ -│ └── tutorials/ -└── prompts/ # Generated system prompts for AI assistance +├── jupyter/ # Local notebooks for exploration +└── .venv/ # Python virtual environment ``` @@ -58,7 +55,6 @@ We recommend keeping your Graph-sitter codemods in the `.codegen/codemods/` dire Graph-sitter pulls documentation and examples locally to: - Provide offline access to guides and references -- Enable AI to give contextual help about your codebase - Allow searching through examples and tutorials ## Requirements @@ -92,7 +88,7 @@ After initializing: 1. Create your first codemod: ```bash -gs create my-function . -d "describe what you want to do" +gs create my-function . ``` Note: The second parameter (`.`) specifies the path where the codemod should be created. This is required. diff --git a/docs/cli/parse.mdx b/docs/cli/parse.mdx index 0d27e8e65..f01c3111c 100644 --- a/docs/cli/parse.mdx +++ b/docs/cli/parse.mdx @@ -36,7 +36,7 @@ graph-sitter parse [PATH] [OPTIONS] ## JSON Output -Use JSON output in scripts, CI, and agent workflows: +Use JSON output in scripts, CI, and automation workflows: ```bash graph-sitter parse . --language python --backend python --format json diff --git a/docs/cli/run.mdx b/docs/cli/run.mdx index b5ac8bc89..5ddbc117d 100644 --- a/docs/cli/run.mdx +++ b/docs/cli/run.mdx @@ -96,7 +96,7 @@ repository to a temporary Git repo before running the codemod, so codemods that call `codebase.commit()` internally do not mutate the original checkout. For compatibility, `run` may still apply changes when neither `--check` nor -`--write` is supplied. New docs, CI, and agent workflows should always pass an +`--write` is supplied. New docs, CI, and automation workflows should always pass an explicit mode. ## Execution Flow diff --git a/docs/cli/uvx.mdx b/docs/cli/uvx.mdx index a9e1a0e01..283492525 100644 --- a/docs/cli/uvx.mdx +++ b/docs/cli/uvx.mdx @@ -80,7 +80,7 @@ For large repositories, scope the parse to the files that matter: uvx --python 3.13 graph-sitter parse ./monorepo --language typescript --subdir packages/app --subdir packages/ui --format json ``` -Write JSON to a file when another tool or agent consumes the graph summary: +Write JSON to a file when another tool consumes the graph summary: ```bash uvx --python 3.13 graph-sitter parse . --format json --output graph-sitter-index.json diff --git a/docs/graph-sitter/about.mdx b/docs/graph-sitter/about.mdx index 33cd239c2..e8855eb77 100644 --- a/docs/graph-sitter/about.mdx +++ b/docs/graph-sitter/about.mdx @@ -13,13 +13,11 @@ iconType: "solid" ## Our Mission -Our mission is to build fully-autonomous software engineering - the equivalent of self-driving cars for code. +Our mission is to make large-scale software engineering changes programmable, reliable, and easy to review. -We believe the highest leverage path to autonomous development is enabling AI agents to "act via code." +Graph-sitter provides the foundational layer for code transformation: a programmatic interface for expressing complex codebase changes through code itself. -Just as self-driving cars need sophisticated sensors and controls to navigate the physical world, AI agents need powerful, precise tools to manipulate codebases. We're building that foundational layer: a programmatic interface that lets AI agents express complex code transformations through code itself. - -This approach creates a shared language that both humans and AI can use to: +This approach creates a shared language that developers can use to: - Express powerful changes with precision and predictability - Build sophisticated tools from primitive operations @@ -32,7 +30,7 @@ Based in San Francisco, we're a team of engineers and researchers passionate abo - Making large-scale code changes more accessible - Building tools that work the way developers think -- Creating the infrastructure for AI-powered code manipulation +- Creating infrastructure for reliable code manipulation - Advancing the state of the art in program transformation ## Open Source diff --git a/docs/graph-sitter/getting-started.mdx b/docs/graph-sitter/getting-started.mdx index 7c6dfce85..c40167151 100644 --- a/docs/graph-sitter/getting-started.mdx +++ b/docs/graph-sitter/getting-started.mdx @@ -331,12 +331,4 @@ These are considered experimental and unstable features that may be removed or c Iterate locally with your favorite IDE, work with a debugger and build sophisticated codemods - - Learn how to use Graph-sitter with Cursor, Devin, Windsurf, and more. - - diff --git a/docs/graph-sitter/guiding-principles.mdx b/docs/graph-sitter/guiding-principles.mdx index e5ba2b3d0..ce91fa513 100644 --- a/docs/graph-sitter/guiding-principles.mdx +++ b/docs/graph-sitter/guiding-principles.mdx @@ -66,7 +66,7 @@ It is built with the insight that each codebase only needs to be parsed once per Graph-sitter embraces Python's strength as a "glue language" - its ability to seamlessly integrate different tools and APIs. This makes it natural to compose Graph-sitter with your existing toolchain: - Build complex transforms by combining simpler operations -- Integrate Graph-sitter with your existing tools (linters, type checkers, test frameworks, AI tools) +- Integrate Graph-sitter with your existing tools (linters, type checkers, and test frameworks) Python's rich ecosystem makes it ideal for code manipulation tasks. Graph-sitter is diff --git a/docs/graph-sitter/overview.mdx b/docs/graph-sitter/overview.mdx index 2281bf3ec..afc3b9330 100644 --- a/docs/graph-sitter/overview.mdx +++ b/docs/graph-sitter/overview.mdx @@ -71,13 +71,6 @@ Codegen's simple yet powerful APIs enable a range of applications, including: > Generate interactive visualizations of your codebase's structure, dependencies, and relationships. - - Create high-quality training data for fine-tuning LLMs on your codebase. - - Go to [developer settings](https://codegen.sh/token) to generate an API token - - -```python -from graph_sitter import Agent - -# Initialize the Agent with your organization ID and API token -agent = Agent(org_id="...", token="...") - -# Run an agent with a prompt -task = agent.run(prompt="Leave a review on PR #123") - -# Check the initial status -print(task.status) - -# Refresh the task to get updated status (tasks can take time) -task.refresh() - -if task.status == "completed": - print(task.result) # Result often contains code, summaries, or links -``` - - - Graph-sitter agents can research code, create PRs, modify Linear tickets, and more. - - -## Installation - -Install the SDK using pip or uv: - -```bash -pip install graph-sitter -# or -uv pip install graph-sitter -``` - -## What can I do with the Codegen SDK? - -The Codegen SDK is your gateway to programmatically interacting with your AI Software Engineer. You can use it to: - -- **Automate development tasks**: Assign tasks like implementing features, fixing bugs, writing tests, or improving documentation to the agent. -- **Integrate AI into your workflows**: Trigger agent tasks from your CI/CD pipelines, scripts, or other development tools. -- **Provide context and guidance**: Supply the agent with specific instructions, relevant code snippets, or background information to ensure it performs tasks according to your requirements. - -Essentially, the SDK allows you to leverage Codegen's AI capabilities wherever you can run Python code. - -## Get Started - -import { - COMMUNITY_SLACK_URL, - CODEGEN_SDK_GITHUB_URL, -} from "/snippets/links.mdx"; - - - - Sign up for a free account and get your API token. - - - Get help and connect with the Graph-sitter community. - - - Learn how to use Graph-sitter for common code transformation tasks. - - - Star us on GitHub and contribute to the project. - - diff --git a/docs/introduction/guiding-principles.mdx b/docs/introduction/guiding-principles.mdx index e5ba2b3d0..ce91fa513 100644 --- a/docs/introduction/guiding-principles.mdx +++ b/docs/introduction/guiding-principles.mdx @@ -66,7 +66,7 @@ It is built with the insight that each codebase only needs to be parsed once per Graph-sitter embraces Python's strength as a "glue language" - its ability to seamlessly integrate different tools and APIs. This makes it natural to compose Graph-sitter with your existing toolchain: - Build complex transforms by combining simpler operations -- Integrate Graph-sitter with your existing tools (linters, type checkers, test frameworks, AI tools) +- Integrate Graph-sitter with your existing tools (linters, type checkers, and test frameworks) Python's rich ecosystem makes it ideal for code manipulation tasks. Graph-sitter is diff --git a/docs/introduction/overview.mdx b/docs/introduction/overview.mdx index d2ba9d0fc..0ef13cb1f 100644 --- a/docs/introduction/overview.mdx +++ b/docs/introduction/overview.mdx @@ -74,13 +74,6 @@ Graph-sitter's simple yet powerful APIs enable a range of applications, includin > Generate interactive visualizations of your codebase's structure, dependencies, and relationships. - - Create high-quality training data for fine-tuning LLMs on your codebase. - Generate interactive visualizations of your codebase's structure, dependencies, and relationships. - - Create high-quality training data for LLM pre-training similar to word2vec or node2vec - -## AI - - - - Generate system prompts, create hierarchical documentation, and optimize for AI assistance. - - - Each tutorial includes practical examples, code snippets, and best practices. Follow them in order or jump to the ones most relevant to your needs. diff --git a/docs/tutorials/attributions.mdx b/docs/tutorials/attributions.mdx deleted file mode 100644 index be3f20660..000000000 --- a/docs/tutorials/attributions.mdx +++ /dev/null @@ -1,191 +0,0 @@ ---- -title: "Code Attributions" -sidebarTitle: "Code Attributions" -description: "Learn how to analyze code statistics and attributions using Codegen" -icon: "network-wired" -iconType: "solid" ---- - -# AI Impact Analysis - -This tutorial shows how to use Graph-sitter's attribution extension to analyze the impact of AI on your -codebase. You'll learn how to identify which parts of your code were written by AI tools like -GitHub Copilot, Devin, or other AI assistants. - -Note: the code is flexible - you can track CI pipeline bots, or any other contributor you want. - - -## Overview - -The attribution extension analyzes git history to: - -1. Identify which symbols (functions, classes, etc.) were authored or modified by AI tools -2. Calculate the percentage of AI contributions in your codebase -3. Find high-impact AI-written code (code that many other parts depend on) -4. Track the evolution of AI contributions over time - -## Installation - -The attribution extension is included with Graph-sitter. No additional installation is required. - -## Basic Usage - -### Running the Analysis - -You can run the AI impact analysis using the graph_sitter.cli: - -```bash -graph-sitter analyze-ai-impact -``` - -Or from Python code: - -```python -from graph_sitter import Codebase -from graph_sitter.extensions.attribution.cli import run - -# Initialize codebase from current directory -codebase = Codebase.from_repo("your-org/your-repo", language="python") - -# Run the analysis -run(codebase) -``` - -### Understanding the Results - -The analysis will print a summary of AI contributions to your console and save detailed results to a JSON file. The summary includes: - -- List of all contributors (human and AI) -- Percentage of commits made by AI -- Number of files and symbols touched by AI -- High-impact AI-written code (code with many dependents) -- Top files by AI contribution percentage - -## Advanced Usage - -### Accessing Attribution Information - -After running the analysis, each symbol in your codebase will have attribution information attached to it: - -```python -from graph_sitter import Codebase -from graph_sitter.extensions.attribution.main import add_attribution_to_symbols - -# Initialize codebase -codebase = Codebase.from_repo("your-org/your-repo", language="python") - -# Add attribution information to symbols -ai_authors = ['github-actions[bot]', 'dependabot[bot]', 'copilot[bot]'] -add_attribution_to_symbols(codebase, ai_authors) - -# Access attribution information on symbols -for symbol in codebase.symbols: - if hasattr(symbol, 'is_ai_authored') and symbol.is_ai_authored: - print(f"AI-authored symbol: {symbol.name} in {symbol.filepath}") - print(f"Last editor: {symbol.last_editor}") - print(f"All editors: {symbol.editor_history}") -``` - -### Customizing AI Author Detection - -By default, the analysis looks for common AI bot names in commit authors. -You can customize this by providing your own list of AI authors: - -```python -from graph_sitter import Codebase -from graph_sitter.extensions.attribution.main import analyze_ai_impact - -# Initialize codebase -codebase = Codebase.from_repo("your-org/your-repo", language="python") - -# Define custom AI authors -ai_authors = [ - 'github-actions[bot]', - 'dependabot[bot]', - 'copilot[bot]', - 'devin[bot]', - 'your-custom-ai-email@example.com' -] - -# Run analysis with custom AI authors -results = analyze_ai_impact(codebase, ai_authors) -``` - -## Example: Contributor Analysis - -Here's a complete example that analyzes contributors to your codebase and their impact: - -```python -import os -from collections import Counter - -from graph_sitter import Codebase -from graph_sitter.extensions.attribution.main import add_attribution_to_symbols -from graph_sitter.git.repo_operator.repo_operator import RepoOperator -from graph_sitter.git.schemas.repo_config import RepoConfig -from graph_sitter.sdk.codebase.config import ProjectConfig -from graph_sitter.shared.enums.programming_language import ProgrammingLanguage - -def analyze_contributors(codebase): - """Analyze contributors to the codebase and their impact.""" - print("\n🔍 Contributor Analysis:") - - # Define which authors are considered AI - ai_authors = ['devin[bot]', 'graph-sitter[bot]', 'github-actions[bot]', 'dependabot[bot]'] - - # Add attribution information to all symbols - print("Adding attribution information to symbols...") - add_attribution_to_symbols(codebase, ai_authors) - - # Collect statistics about contributors - contributor_stats = Counter() - ai_contributor_stats = Counter() - - print("Analyzing symbol attributions...") - for symbol in codebase.symbols: - if hasattr(symbol, 'last_editor') and symbol.last_editor: - contributor_stats[symbol.last_editor] += 1 - - # Track if this is an AI contributor - if any(ai in symbol.last_editor for ai in ai_authors): - ai_contributor_stats[symbol.last_editor] += 1 - - # Print top contributors overall - print("\n👥 Top Contributors by Symbols Authored:") - for contributor, count in contributor_stats.most_common(10): - is_ai = any(ai in contributor for ai in ai_authors) - ai_indicator = "🤖" if is_ai else "👤" - print(f" {ai_indicator} {contributor}: {count} symbols") - - # Print top AI contributors if any - if ai_contributor_stats: - print("\n🤖 Top AI Contributors:") - for contributor, count in ai_contributor_stats.most_common(5): - print(f" • {contributor}: {count} symbols") - -# Initialize codebase from current directory -if os.path.exists(".git"): - repo_path = os.getcwd() - repo_config = RepoConfig.from_repo_path(repo_path) - repo_operator = RepoOperator(repo_config=repo_config) - - project = ProjectConfig.from_repo_operator( - repo_operator=repo_operator, - programming_language=ProgrammingLanguage.PYTHON - ) - codebase = Codebase(projects=[project]) - - # Run the contributor analysis - analyze_contributors(codebase) -``` - -## Conclusion - -The attribution extension provides valuable insights into how AI tools are being used in your -development process. By understanding which parts of your codebase are authored by AI, you can: - -- Track the adoption of AI coding assistants in your team -- Identify areas where AI is most effective -- Ensure appropriate review of AI-generated code -- Measure the impact of AI on developer productivity - diff --git a/docs/tutorials/preparing-your-codebase-for-ai.mdx b/docs/tutorials/preparing-your-codebase-for-ai.mdx deleted file mode 100644 index 4f6f03e5d..000000000 --- a/docs/tutorials/preparing-your-codebase-for-ai.mdx +++ /dev/null @@ -1,179 +0,0 @@ ---- -title: "Preparing Your Codebase for AI" -sidebarTitle: "AI Preparation" -icon: "robot" -iconType: "solid" -description: "Generate a hierarchical README for your codebase using AI" ---- - -When working with large codebases, having clear documentation about each directory's purpose and contents is crucial. This guide shows how to use Codegen and AI to automatically generate a hierarchical README that explains your codebase structure. - -## Generating Directory READMEs - -Here's how to recursively generate README files for each directory using AI: - -```python -def generate_directory_readme(directory): - # Skip non-source directories - if any(skip in directory.name for skip in [ - 'node_modules', 'venv', '.git', '__pycache__', 'build', 'dist' - ]): - return - - # Collect directory contents for context - files = [f for f in directory.files if f.is_source_file] - functions = directory.functions - classes = directory.classes - - # Create context for AI - context = { - "Directory Name": directory.name, - "Files": [f"{f.name} ({len(f.source.splitlines())} lines)" for f in files], - "Functions": [f.name for f in functions], - "Classes": [c.name for c in classes] - } - - # Generate directory summary using AI - readme_content = codebase.ai( - prompt="""Generate a README section that explains this directory's: - 1. Purpose and responsibility - 2. Key components and their roles - 3. How it fits into the larger codebase - 4. Important patterns or conventions - - Keep it clear and concise.""", - target=directory, - context=context - ) - - # Add file listing - if files: - readme_content += "\n\n## Files\n" - for file in files: - # Get file summary from AI - file_summary = codebase.ai( - prompt="Describe this file's purpose in one line:", - target=file - ) - readme_content += f"\n### {file.name}\n{file_summary}\n" - - # List key components - if file.classes: - readme_content += "\nKey classes:\n" - for cls in file.classes: - readme_content += f"- `{cls.name}`\n" - if file.functions: - readme_content += "\nKey functions:\n" - for func in file.functions: - readme_content += f"- `{func.name}`\n" - - # Create or update README.md - readme_path = f"{directory.path}/README.md" - if codebase.has_file(readme_path): - readme_file = codebase.get_file(readme_path) - readme_file.edit(readme_content) - else: - readme_file = codebase.create_file(readme_path) - readme_file.edit(readme_content) - - # Recursively process subdirectories - for subdir in directory.subdirectories: - generate_directory_readme(subdir) - -# Generate READMEs for the entire codebase -generate_directory_readme(codebase.root_directory) -``` - -This will create a hierarchy of README.md files that explain each directory's purpose and contents. For example: - -```markdown -# src/ -Core implementation directory containing the main business logic and data models. -This directory is responsible for the core functionality of the application. - -## Key Patterns -- Business logic is separated from API endpoints -- Models follow the Active Record pattern -- Services implement the Repository pattern - -## Files - -### models.py -Defines the core data models and their relationships. - -Key classes: -- `User` -- `Product` -- `Order` - -### services.py -Implements business logic and data access services. - -Key classes: -- `UserService` -- `ProductService` -Key functions: -- `initialize_db` -- `migrate_data` -``` - -## Customizing the Generation - -You can customize the README generation by modifying the prompts and adding more context: - -```python -def get_directory_patterns(directory): - """Analyze common patterns in a directory""" - patterns = [] - - # Check for common file patterns - if any('test_' in f.name for f in directory.files): - patterns.append("Contains unit tests") - if any('interface' in f.name.lower() for f in directory.files): - patterns.append("Uses interface-based design") - if any(c.is_dataclass for c in directory.classes): - patterns.append("Uses dataclasses for data models") - - return patterns - -def generate_enhanced_readme(directory): - # Get additional context - patterns = get_directory_patterns(directory) - dependencies = [imp.module for imp in directory.imports] - - # Enhanced context for AI - context = { - "Common Patterns": patterns, - "Dependencies": dependencies, - "Parent Directory": directory.parent.name if directory.parent else None, - "Child Directories": [d.name for d in directory.subdirectories], - "Style": "technical but approachable" - } - - # Generate README with enhanced context - # ... rest of the generation logic -``` - -## Best Practices - -1. **Keep Summaries Focused**: Direct the AI to generate concise, purpose-focused summaries. - -2. **Include Key Information**: - - Directory purpose - - Important patterns - - Key files and their roles - - How components work together - -3. **Maintain Consistency**: Use consistent formatting and structure across all READMEs. - -4. **Update Regularly**: Regenerate READMEs when directory structure or purpose changes. - -5. **Version Control**: Commit generated READMEs to track documentation evolution. - - -The AI-generated summaries are a starting point. Review and refine them to ensure accuracy and completeness. - - - -Be mindful of sensitive information in your codebase. Configure the generator to skip sensitive files or directories. - diff --git a/docs/tutorials/training-data.mdx b/docs/tutorials/training-data.mdx deleted file mode 100644 index 6ee9cc865..000000000 --- a/docs/tutorials/training-data.mdx +++ /dev/null @@ -1,202 +0,0 @@ ---- -title: "Mining Training Data for LLMs" -sidebarTitle: "Mining Data" -description: "Learn how to generate training data for large language models using Codegen" -icon: "network-wired" -iconType: "solid" ---- - -This guide demonstrates how to use Graph-sitter to generate high-quality training data for large language models (LLMs) by extracting function implementations along with their dependencies and usages. This approach is similar to [word2vec](https://www.tensorflow.org/text/tutorials/word2vec) or [node2vec](https://snap.stanford.edu/node2vec/) - given the context of a function, learn to predict the function's implementation. - -View the full code in our [examples repository](https://github.com/codegen-sh/graph-sitter/tree/develop/examples/examples/generate_training_data) - -This example works with both Python and Typescript repositories without modification - -## Overview - -The process involves three main steps: - -1. Finding all functions in the codebase -2. Extracting their implementations, dependencies, and usages -3. Generating structured training data - -Let's walk through each step using Codegen. - -## Step 1: Finding Functions and Their Context - -First, we will do a "graph expansion" for each function - grab the function's source, as well as the full source of all usages of the function and all dependencies. - -See [dependencies and usages](/building-with-graph-sitter/dependencies-and-usages) to learn more about navigating the code graph - -First, let's import the types we need from Codegen: - -```python -import graph_sitter -from graph_sitter import Codebase -from graph_sitter.sdk.core.external_module import ExternalModule -from graph_sitter.sdk.core.import_resolution import Import -from graph_sitter.sdk.core.symbol import Symbol -``` - -Here's how we get the full context for each function: - -```python -def get_function_context(function) -> dict: - """Get the implementation, dependencies, and usages of a function.""" - context = { - "implementation": {"source": function.source, "filepath": function.filepath}, - "dependencies": [], - "usages": [], - } - - # Add dependencies - for dep in function.dependencies: - # Hop through imports to find the root symbol source - if isinstance(dep, Import): - dep = hop_through_imports(dep) - - context["dependencies"].append({"source": dep.source, "filepath": dep.filepath}) - - # Add usages - for usage in function.usages: - context["usages"].append({ - "source": usage.usage_symbol.source, - "filepath": usage.usage_symbol.filepath, - }) - - return context -``` - -Notice how we use `hop_through_imports` to resolve dependencies. When working with imports, symbols can be re-exported multiple times. For example, a helper function might be imported and re-exported through several files before being used. We need to follow this chain to find the actual implementation: - -```python -def hop_through_imports(imp: Import) -> Symbol | ExternalModule: - """Finds the root symbol for an import.""" - if isinstance(imp.imported_symbol, Import): - return hop_through_imports(imp.imported_symbol) - return imp.imported_symbol -``` - -This creates a structured representation of each function's context: - -```json -{ - "implementation": { - "source": "def process_data(input: str) -> dict: ...", - "filepath": "src/data_processor.py" - }, - "dependencies": [ - { - "source": "def validate_input(data: str) -> bool: ...", - "filepath": "src/validators.py" - } - ], - "usages": [ - { - "source": "result = process_data(user_input)", - "filepath": "src/api.py" - } - ] -} -``` - -## Step 2: Processing the Codebase - -Next, we process all functions in the codebase to generate our training data: - -```python -def run(codebase: Codebase): - """Generate training data using a node2vec-like approach for code embeddings.""" - # Track all function contexts - training_data = { - "functions": [], - "metadata": { - "total_functions": len(codebase.functions), - "total_processed": 0, - "avg_dependencies": 0, - "avg_usages": 0, - }, - } - - # Process each function in the codebase - for function in codebase.functions: - # Skip if function is too small - if len(function.source.split("\n")) < 2: - continue - - # Get function context - context = get_function_context(function) - - # Only keep functions with enough context - if len(context["dependencies"]) + len(context["usages"]) > 0: - training_data["functions"].append(context) - - # Update metadata - training_data["metadata"]["total_processed"] = len(training_data["functions"]) - if training_data["functions"]: - training_data["metadata"]["avg_dependencies"] = sum( - len(f["dependencies"]) for f in training_data["functions"] - ) / len(training_data["functions"]) - training_data["metadata"]["avg_usages"] = sum( - len(f["usages"]) for f in training_data["functions"] - ) / len(training_data["functions"]) - - return training_data -``` - -## Step 3: Running the Generator - -Finally, we can run our training data generator on any codebase. - -See [parsing codebases](/building-with-graph-sitter/parsing-codebases) to learn more - -```python -if __name__ == "__main__": - print("Initializing codebase...") - codebase = Codebase.from_repo("fastapi/fastapi") - - print("Generating training data...") - training_data = run(codebase) - - print("Saving training data...") - with open("training_data.json", "w") as f: - json.dump(training_data, f, indent=2) - print("Training data saved to training_data.json") -``` - -This will: -1. Load the target codebase -2. Process all functions -3. Save the structured training data to a JSON file - - - You can use any Git repository as your source codebase by passing the repo URL - to [Codebase.from_repo(...)](/api-reference/core/Codebase#from-repo). - - -## Using the Training Data - -The generated data can be used to train LLMs in several ways: - -1. **Masked Function Prediction**: Hide a function's implementation and predict it from dependencies and usages -2. **Code Embeddings**: Generate embeddings that capture semantic relationships between functions -3. **Dependency Prediction**: Learn to predict which functions are likely to be dependencies -4. **Usage Pattern Learning**: Train models to understand common usage patterns - -For example, to create a masked prediction task: - -```python -def create_training_example(function_data): - """Create a masked prediction example from function data.""" - return { - "context": { - "dependencies": function_data["dependencies"], - "usages": function_data["usages"] - }, - "target": function_data["implementation"] - } - -# Create training examples -examples = [create_training_example(f) for f in training_data["functions"]] -``` - diff --git a/examples/STRUCTURE.md b/examples/STRUCTURE.md index b4222af0d..4b0101467 100644 --- a/examples/STRUCTURE.md +++ b/examples/STRUCTURE.md @@ -1,6 +1,6 @@ # Structuring Graph-sitter Examples -This guide explains how to structure examples for the Graph-sitter library. A well-structured example helps both humans and AI understand the code's purpose and how to use it effectively. +This guide explains how to structure examples for the Graph-sitter library. A well-structured example helps readers understand the code's purpose and how to use it effectively. ## Core Principles @@ -20,7 +20,7 @@ example-name/ ## Code Organization in `run.py` -Your `run.py` should follow this structure, demonstrated well in the `generate_training_data` example: +Your `run.py` should follow this structure, demonstrated well in the `delete_dead_code` example: 1. **Imports at the top** @@ -126,7 +126,7 @@ Choose between these approaches based on: ## Example Reference Implementation -The `generate_training_data` example demonstrates these principles well: +The `delete_dead_code` example demonstrates these principles well: ```python # Focused utility function @@ -136,14 +136,14 @@ def get_function_context(function) -> dict: # Main transformation with decorator -@graph_sitter.function("generate-training-data") +@graph_sitter.function("delete-dead-code") def run(codebase: Codebase): - """Generate training data using a node2vec-like approach... + """Delete unused symbols from a codebase. This codemod: - 1. Finds all functions... - 2. For each function... - 3. Outputs structured JSON... + 1. Finds symbols with no usages... + 2. Removes the dead symbols... + 3. Commits the change... """ # Clear implementation with good structure... @@ -177,4 +177,4 @@ Before submitting: 1. Ensure the example runs with minimal setup 1. Check that documentation is clear and accurate -Remember: Your example might be used by both humans and AI to understand Graph-sitter's capabilities. Clear structure and documentation help everyone use your code effectively. +Remember: Clear structure and documentation help everyone use your code effectively. diff --git a/examples/examples/ai_impact_analysis/README.md b/examples/examples/ai_impact_analysis/README.md deleted file mode 100644 index 8148b65ad..000000000 --- a/examples/examples/ai_impact_analysis/README.md +++ /dev/null @@ -1,124 +0,0 @@ -# AI Impact Analysis - -This script analyzes a codebase to measure and report the impact of AI-generated code contributions. It provides detailed insights about AI vs human contributions, helping teams understand the role of AI in their development process. - -## Features - -- **Repository Analysis**: Automatically detects and analyzes git repositories: - - - Uses current directory if it's a git repo - - - Searches parent directories for a git repo - - - Falls back to cloning a specified repository if needed - - ```python - # Basic repository setup - repo_path = os.getcwd() - repo_config = RepoConfig.from_repo_path(repo_path) - repo_operator = RepoOperator(repo_config=repo_config) - project = ProjectConfig.from_repo_operator(repo_operator=repo_operator, programming_language=ProgrammingLanguage.PYTHON) - codebase = Codebase(projects=[project]) - ``` - -- **Comprehensive Statistics**: - - - Total number of commits and AI vs human contribution percentages - - Files with significant AI contribution (>50%) - - AI-touched symbols and their impact - - Detailed contributor breakdown (human and AI contributors) - - ```python - # Run the analysis - ai_authors = ["github-actions[bot]", "dependabot[bot]"] - results = analyze_ai_impact(codebase, ai_authors) - - # Access statistics - stats = results["stats"] - print(f"Total commits: {stats['total_commits']}") - print(f"AI commits: {stats['ai_commits']} ({stats['ai_percentage']:.1f}%)") - print(f"Files with >50% AI: {stats['ai_file_count']} of {stats['total_file_count']}") - - # View contributors - for author, count in results["contributors"]: - is_ai = any(ai_name in author for ai_name in ai_authors) - print(f"{'🤖' if is_ai else '👤'} {author}: {count} commits") - ``` - -- **High-Impact Code Detection**: - - - Identifies AI-written code that is heavily used by other parts of the codebase - - Shows dependency relationships for AI-contributed code - - ```python - # Access high-impact AI symbols - for symbol in results["high_impact_symbols"]: - print(f"Symbol: {symbol['name']} ({symbol['filepath']})") - print(f"Used by {symbol['usage_count']} other symbols") - print(f"Last edited by: {symbol['last_editor']}") - - # View top AI-contributed files - for file_path, percentage in stats["top_ai_files"]: - print(f"{file_path}: {percentage:.1f}% AI contribution") - ``` - -- **Detailed Attribution**: - - - Maps symbols to git history - - Tracks last editor and complete editor history for each symbol - - Flags AI-authored symbols - - ```python - # Get attribution information for a specific symbol - symbol = codebase.get_symbol("path/to/file.py:MyClass.my_method") - - # Access attribution data - print(f"Last editor: {symbol.last_editor}") - print(f"Editor history: {symbol.editor_history}") - print(f"AI authored: {symbol.is_ai_authored}") - - # Find all AI-authored symbols - ai_symbols = [s for s in codebase.get_symbols() if s.is_ai_authored] - for symbol in ai_symbols: - print(f"AI symbol: {symbol.name}") - ``` - -## Output - -The script generates: - -1. Console output with summary statistics -1. Detailed analysis in `ai_impact_analysis.json` -1. Attribution information added to codebase symbols - -## Usage - -```bash -python run.py -``` - -The script will automatically: - -1. Initialize and analyze the codebase -1. Process git history -1. Generate attribution information -1. Output detailed statistics - -You can also visualize the AI impact analysis results using a dashboard. For setup and usage instructions, please see the documentation in the `/dashboard` subdirectory. - -## Symbol Attribution - -After running the analysis, symbols in the codebase will have the following attribution information: - -- `symbol.last_editor`: The last person who edited the symbol -- `symbol.editor_history`: List of all editors who have touched the symbol -- `symbol.is_ai_authored`: Boolean indicating if the symbol was authored by AI - -## Learn More - -- [Attributions](https://graph-sitter.com/tutorials/attributions) -- [Graph-sitter Documentation](https://graph-sitter.com) - -## Contributing - -Feel free to submit issues and enhancement requests! diff --git a/examples/examples/ai_impact_analysis/dashboard/README.md b/examples/examples/ai_impact_analysis/dashboard/README.md deleted file mode 100644 index 41de8b6a1..000000000 --- a/examples/examples/ai_impact_analysis/dashboard/README.md +++ /dev/null @@ -1,86 +0,0 @@ -# AI Impact Analysis Dashboard - -A web dashboard for visualizing AI-generated code contributions in your codebase. This dashboard provides detailed insights about AI vs human contributions, helping understand the role of AI in a codebase development process. - -## Setup - -### Backend - -1. Install dependencies: - -```bash -uv venv -source .venv/bin/activate -uv pip install modal graph-sitter fastapi -``` - -2. Deploy or serve the Modal endpoint: - -```bash -modal serve backend/api.py -``` - -```bash -modal deploy backend/api.py -``` - -### Frontend - -1. Install dependencies: - -```bash -cd frontend -npm install -``` - -2. Update the API endpoint: - Edit the fetch URL on line 29 in `components/repo-analysis-dashboard.tsx` to point to your Modal endpoint: - -```bash - fetch(`[your-modal-deployment-url]/analyze?repo_full_name=${repoFullName}`, { - method: 'POST', - }) -``` - -3. Start the development server: - -```bash -npm run dev -``` - -## Usage - -1. Visit the dashboard in your browser (default: http://localhost:3000) -1. Enter a GitHub repository name (format: username/repo) -1. Click "Analyze Repo" to generate insights - -The dashboard will display: - -- Summary statistics of AI contributions -- Monthly contribution timeline -- Top files with AI contributions -- High-impact AI-authored symbols -- Contributor breakdown visualization - -## Architecture - -- **Backend**: Modal-deployed FastAPI service that: - - - Clones and analyzes repositories - - Processes git history - - Calculates AI impact metrics - - Returns structured analysis data - -- **Frontend**: Next.js application with: - - - Interactive charts - - Visualized AI impact metrics - -## Learn More - -- [AI Impact Analysis Documentation](https://graph-sitter.com/tutorials/attributions) -- [Graph-sitter Documentation](https://graph-sitter.com) - -## Contributing - -Feel free to submit issues and enhancement requests! diff --git a/examples/examples/ai_impact_analysis/dashboard/backend/api.py b/examples/examples/ai_impact_analysis/dashboard/backend/api.py deleted file mode 100644 index 634e7893f..000000000 --- a/examples/examples/ai_impact_analysis/dashboard/backend/api.py +++ /dev/null @@ -1,54 +0,0 @@ -from graph_sitter import Codebase -from graph_sitter.extensions.attribution.main import ( - add_attribution_to_symbols, - analyze_ai_impact, -) -from fastapi import FastAPI -from fastapi.middleware.cors import CORSMiddleware -import modal - -image = modal.Image.debian_slim().apt_install("git").pip_install("codegen", "fastapi", "intervaltree", "pygit2", "requests") - -app = modal.App(name="ai-impact-analysis", image=image) - -fastapi_app = FastAPI() - -fastapi_app.add_middleware( - CORSMiddleware, - allow_origins=["*"], - allow_credentials=True, - allow_methods=["*"], - allow_headers=["*"], -) - - -@fastapi_app.post("/analyze") -async def analyze(repo_full_name: str): - codebase = Codebase.from_repo(repo_full_name=repo_full_name, language="python", full_history=True) - - print("🤖 Analyzing AI impact on codebase...") - - ai_authors = [ - "renovate[bot]", - "dependabot[bot]", - "github-actions[bot]", - "devin-ai-integration[bot]", - ] - - results = analyze_ai_impact(codebase, ai_authors) - - print("\n🏷️ Adding attribution information to symbols...") - add_attribution_to_symbols(codebase, ai_authors) - print("✅ Attribution information added to symbols") - - return results - - -@app.function(image=image) -@modal.asgi_app() -def fastapi_modal_app(): - return fastapi_app - - -if __name__ == "__main__": - app.deploy("ai-impact-analysis") diff --git a/examples/examples/ai_impact_analysis/dashboard/frontend/app/favicon.ico b/examples/examples/ai_impact_analysis/dashboard/frontend/app/favicon.ico deleted file mode 100644 index fd85877464ce8ec6468b611d781ca11399bb1a5e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 15406 zcmeI2d5jgs7Ka-_P!JtdgrMLIg5tgqx1h3!im2}yBAS>O)WpOs`j3hlV~k6D8sqZN zC+-Vw(YQtI}As}oFPVE&0`vgJI*x3F&YCsU&iEfWQqV(;9V8Os37=;a4$kDDRs9MV9 z@|G~D>WpL{-!NDVOQ5NmGO!;B%fQHTB5G1a!ER^xF3R{4;k+omuu^91M#E2${nLaS zK_9pl=vlvzJ_c5S-8qX8q50KmqJ)r@n!}+ke>5d}) zr{o>5wV;y+4>EQ3ZcWxPpz zi^%SJ;zn+YbOTVl9x0a+ZWrl?5dS#RFCrWq>Gvc)T5$>Sdn23A2#2<7+yC-B5Z;N> zHSUJR(-lWI817PNr$y=N^93ML+eSbW$fv2UJhl$IO-iNG3xtv%U_}@!muK6yzGv(= zE|<#BMEMlVfxbR_mmd4xpmF#(^l{k~q0^*ngmIwt>7OX{pXSN&e@EM>_bh0G5?s)o zKB&H^UV;v}oLG-~`l0gSijEr75v?uZI#;wGl&iYqYgfAVcFk=B;hI>K4=RrreY>MV zt@o=P`k4jRy&>g4;HX1;?~X7WzO>S36j48AYM*_=DqD{_I}A5<5Z?wq0m+R}^BACv zexUW$7S*$jsoR9;bS63)5_3S$w$9}7h1hQfuYfJ@p~!vi!d83VLeSnC?!Ue|jb3(9 z9)g6t!BcqNFt%ACw%WTtik0vIap(SO%27JV&XyNZY-;RGh^_%R>81t!Ibe&<2dVvE zxuplC+wv@m#2(A@1kjm6Yp;;chsV9(S?9w?!Iq^cMp(8wPe^Zz@+bCap2tC}ZOHRF zm~55X3*9V-?YHQ5maRh2vn|TU7erFfnRAeBujluY)?xV@pr7e5)>&~cFz2ASiN$Hd@IiBMo+HyQ=&p9?e?vFMT~6schrLn#N+h-Rqto|;&e68~Pj#TY z#7^M3nbY+|hYwdeY>n!_4tsrn$S+&2LD8{R5!ZatSdNR%`bWjfx3=Wp$Nwup~j&R+3r`I2jO_v z_pZJfZFvyI-L{hF1x41cvRYbNcB0&G9Cg_$`MGD&^{YI}-HsJ%sa;|0S^n)NL?WiG=qS#H43oLtum3oIPJo8T#!19e@y3UoUxD)L?5M>-csUWOft zuBRU5;pcAfJQ&}JhN5qeed|$YQDx$vzMI|+y>GyMuip zajq}YmukwAAE57k-NED)okx#^)VFLkb=PW3{qp@VSOV3`axzSTzoiYT7sf)C@463Z z0iWo8V|=asSZ#jl>;=cdSKt%fC+PeCLRjWALVr)S_19ugeLdj>_#S++ii8uPH>j=p z=KUFLS+;iV+5>9wr<%M}ZhZO4b|m&JKh?g(`oiAW^qPAI!F0GWLVMT*Nd1qC%0NF59tVvXmuQ?m08OqsjgEB2 zd-%IXE1^%c_Kkql`hae8P+#e;D(;Konv=62b*F(&YtB%Z13pn1YNK;Lpx+W60-q@V zi{Sjd4t;;nd-IJslEQa-AE9$Bpx64NZ%%t2pz4rki48G*t`O@{=#i1Do z4rw||x_%Qtoe+(4@0~SiThYurSvRuU@H}>!GkR}Z!(7PfH~rpL={L&R*yNRk7^cQw ztS@wjc1K2GnwuKO!{Mb2J0+=YnRg(hYtFiUheGWXjm6BpiFBP4A93dHRO+rWeqY&{ z(izjdujK!R*!Qz`^2( z|Hg!>Lp~>VFm%iz;-leJ@QM0D?;-r3MMu2@OQrIYq-U)Ins?7ZV*N8^q3;VOp#9Dz>R;^cypm*()H%QpU z`0ENu-yU8AUmMiFcY$vo)VXIWXg|@I{0P*h6Cm|}2l4^E_N^J<8-Mae=iJ?0KHEC% zw5~n|zOkS&taT}CKhyh=U+P!yT#fwS1)JZ&CGuV83g>yt_T4;VKLoVrYRtMsdX0xh zlc%d8W$5gpcVxeFJ?lMg+m*7(Hwc~p^|wn@zUnQa4Na7z{xJQea4tCiFDP$&$gjSc z3EBr-qBf|WUGtXdv!jfma6fzx_keSq^5ysGDW?H$0N?x~DZF>C`S)GQ(YM$Lg+70} zqNhB~#ake2ebc$j`yNQs`us3xZ5Rfrb+jwK<;_EV+F!J((8EKc7P-`3i$+(5>rEr8eS^=EG#jnhzT9 zQ^9!-tyD*Mq~n{`o8_Q$MO<_y_;+{sP-`9dc@XG3$+SW1=cHQ8?XLXzs&AORVG%5b TvEcn(qr3cCU(fm;uzTSD5Uj=O diff --git a/examples/examples/ai_impact_analysis/dashboard/frontend/app/globals.css b/examples/examples/ai_impact_analysis/dashboard/frontend/app/globals.css deleted file mode 100644 index 1535f872d..000000000 --- a/examples/examples/ai_impact_analysis/dashboard/frontend/app/globals.css +++ /dev/null @@ -1,76 +0,0 @@ -@tailwind base; -@tailwind components; -@tailwind utilities; - -@layer base { - :root { - --background: 0 0% 100%; - --foreground: 222.2 84% 4.9%; - - --card: 0 0% 100%; - --card-foreground: 222.2 84% 4.9%; - - --popover: 0 0% 100%; - --popover-foreground: 222.2 84% 4.9%; - - --primary: 221.2 83.2% 53.3%; - --primary-foreground: 210 40% 98%; - - --secondary: 210 40% 96.1%; - --secondary-foreground: 222.2 47.4% 11.2%; - - --muted: 210 40% 96.1%; - --muted-foreground: 215.4 16.3% 46.9%; - - --accent: 210 40% 96.1%; - --accent-foreground: 222.2 47.4% 11.2%; - - --destructive: 0 84.2% 60.2%; - --destructive-foreground: 210 40% 98%; - - --border: 214.3 31.8% 91.4%; - --input: 214.3 31.8% 91.4%; - --ring: 221.2 83.2% 53.3%; - - --radius: 0.5rem; - } - - .dark { - --background: 222.2 84% 4.9%; - --foreground: 210 40% 98%; - - --card: 222.2 84% 4.9%; - --card-foreground: 210 40% 98%; - - --popover: 222.2 84% 4.9%; - --popover-foreground: 210 40% 98%; - - --primary: 217.2 91.2% 59.8%; - --primary-foreground: 222.2 47.4% 11.2%; - - --secondary: 217.2 32.6% 17.5%; - --secondary-foreground: 210 40% 98%; - - --muted: 217.2 32.6% 17.5%; - --muted-foreground: 215 20.2% 65.1%; - - --accent: 217.2 32.6% 17.5%; - --accent-foreground: 210 40% 98%; - - --destructive: 0 62.8% 30.6%; - --destructive-foreground: 210 40% 98%; - - --border: 217.2 32.6% 17.5%; - --input: 217.2 32.6% 17.5%; - --ring: 224.3 76.3% 48%; - } -} - -@layer base { - * { - @apply border-border; - } - body { - @apply bg-background text-foreground; - } -} diff --git a/examples/examples/ai_impact_analysis/dashboard/frontend/app/layout.tsx b/examples/examples/ai_impact_analysis/dashboard/frontend/app/layout.tsx deleted file mode 100644 index 264632940..000000000 --- a/examples/examples/ai_impact_analysis/dashboard/frontend/app/layout.tsx +++ /dev/null @@ -1,34 +0,0 @@ -import type { Metadata } from "next"; -import { Inter } from "next/font/google"; -import type React from "react"; -import "./globals.css"; -import { ThemeProvider } from "@/components/theme-provider"; - -const inter = Inter({ subsets: ["latin"] }); - -export const metadata: Metadata = { - title: "AI Code Impact Analysis", -}; - -export default function RootLayout({ - children, -}: { - children: React.ReactNode; -}) { - return ( - - - - {children} - - - - ); -} - -import "./globals.css"; diff --git a/examples/examples/ai_impact_analysis/dashboard/frontend/app/page.tsx b/examples/examples/ai_impact_analysis/dashboard/frontend/app/page.tsx deleted file mode 100644 index 5b048bbdf..000000000 --- a/examples/examples/ai_impact_analysis/dashboard/frontend/app/page.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import { RepoAnalysisDashboard } from "@/components/repo-analysis-dashboard"; - -export default function Home() { - return ( -
- -
- ); -} diff --git a/examples/examples/ai_impact_analysis/dashboard/frontend/components.json b/examples/examples/ai_impact_analysis/dashboard/frontend/components.json deleted file mode 100644 index 7f48f98e8..000000000 --- a/examples/examples/ai_impact_analysis/dashboard/frontend/components.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "$schema": "https://ui.shadcn.com/schema.json", - "style": "default", - "rsc": true, - "tsx": true, - "tailwind": { - "config": "tailwind.config.ts", - "css": "app/globals.css", - "baseColor": "neutral", - "cssVariables": true, - "prefix": "" - }, - "aliases": { - "components": "@/components", - "utils": "@/lib/utils", - "ui": "@/components/ui", - "lib": "@/lib", - "hooks": "@/hooks" - }, - "iconLibrary": "lucide" -} diff --git a/examples/examples/ai_impact_analysis/dashboard/frontend/components/contribution-timeline.tsx b/examples/examples/ai_impact_analysis/dashboard/frontend/components/contribution-timeline.tsx deleted file mode 100644 index e6017ba9c..000000000 --- a/examples/examples/ai_impact_analysis/dashboard/frontend/components/contribution-timeline.tsx +++ /dev/null @@ -1,83 +0,0 @@ -"use client"; - -import { - Card, - CardContent, - CardDescription, - CardHeader, - CardTitle, -} from "@/components/ui/card"; -import type { Timeline } from "@/lib/types"; -import { - Bar, - BarChart, - ResponsiveContainer, - Tooltip, - XAxis, - YAxis, -} from "recharts"; - -interface ContributionTimelineProps { - timeline: Timeline[]; -} - -export function ContributionTimeline({ timeline }: ContributionTimelineProps) { - return ( - - - AI Contribution Timeline - Monthly AI contributions over time - - - - - - `${value}`} - /> - { - if (active && payload && payload.length) { - return ( -
-
-
- - Date - - - {payload[0].payload.date} - -
-
- - Commits - - - {payload[0].value} - -
-
-
- ); - } - return null; - }} - /> - -
-
-
-
- ); -} diff --git a/examples/examples/ai_impact_analysis/dashboard/frontend/components/contributors-breakdown.tsx b/examples/examples/ai_impact_analysis/dashboard/frontend/components/contributors-breakdown.tsx deleted file mode 100644 index fb54b7fec..000000000 --- a/examples/examples/ai_impact_analysis/dashboard/frontend/components/contributors-breakdown.tsx +++ /dev/null @@ -1,131 +0,0 @@ -"use client"; - -import { - Card, - CardContent, - CardDescription, - CardHeader, - CardTitle, -} from "@/components/ui/card"; -import { ScrollArea } from "@/components/ui/scroll-area"; -import { - Cell, - Legend, - Pie, - PieChart, - ResponsiveContainer, - Tooltip, -} from "recharts"; - -interface ContributorsBreakdownProps { - contributors: [string, number][]; -} - -export function ContributorsBreakdown({ - contributors, -}: ContributorsBreakdownProps) { - // Take top 5 contributors for the chart - const topContributors = contributors.slice(0, 5); - const otherContributors = contributors.slice(5); - const otherCount = otherContributors.reduce( - (sum, [_, count]) => sum + count, - 0, - ); - - const chartData = [ - ...topContributors.map(([name, count]) => ({ - name: name.split(" ")[0], // Just use first name for chart - fullName: name, - count, - })), - otherContributors.length > 0 - ? { name: "Others", fullName: "Other Contributors", count: otherCount } - : null, - ].filter(Boolean); - - const COLORS = [ - "#3b82f6", - "#10b981", - "#f59e0b", - "#ef4444", - "#8b5cf6", - "#6b7280", - ]; - - return ( - - - Contributors Breakdown - Top contributors by commit count - - -
-
- - - - {chartData.map((entry, index) => ( - - ))} - - [ - value, - props.payload.fullName, - ]} - contentStyle={{ - backgroundColor: "white", - borderColor: "#e2e8f0", - borderRadius: "0.375rem", - }} - /> - - - -
-
- -
- {contributors.slice(0, 10).map(([name, count], index) => ( -
-
-
- - {name.split(" ")[0]} - -
-
{count}
-
- ))} - {contributors.length > 10 && ( -
- +{contributors.length - 10} more contributors -
- )} -
- -
-
- - - ); -} diff --git a/examples/examples/ai_impact_analysis/dashboard/frontend/components/dashboard-header.tsx b/examples/examples/ai_impact_analysis/dashboard/frontend/components/dashboard-header.tsx deleted file mode 100644 index 3fa854491..000000000 --- a/examples/examples/ai_impact_analysis/dashboard/frontend/components/dashboard-header.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import { Code2 } from "lucide-react"; - -export function DashboardHeader() { - return ( -
-
-
-

- AI Code Impact Analysis -

-
-

- Analyze AI-generated code contributions in your repository -

-
-
- ); -} diff --git a/examples/examples/ai_impact_analysis/dashboard/frontend/components/high-impact-symbols.tsx b/examples/examples/ai_impact_analysis/dashboard/frontend/components/high-impact-symbols.tsx deleted file mode 100644 index db1fe51aa..000000000 --- a/examples/examples/ai_impact_analysis/dashboard/frontend/components/high-impact-symbols.tsx +++ /dev/null @@ -1,58 +0,0 @@ -import { - Card, - CardContent, - CardDescription, - CardHeader, - CardTitle, -} from "@/components/ui/card"; -import { ScrollArea } from "@/components/ui/scroll-area"; -import type { HighImpactSymbol } from "@/lib/types"; - -interface HighImpactSymbolsProps { - symbols: HighImpactSymbol[]; -} - -export function HighImpactSymbols({ symbols }: HighImpactSymbolsProps) { - return ( - - - High-Impact AI Symbols - - AI-written code with significant usage - - - - -
- {symbols.length > 0 ? ( - symbols.map((symbol) => ( -
-
-
{symbol.name}
-
- Used by {symbol.usage_count} symbols -
-
-
- {symbol.filepath} -
-
- Last edited by:{" "} - {symbol.last_editor} -
-
- )) - ) : ( -
- No high-impact AI symbols found -
- )} -
-
-
-
- ); -} diff --git a/examples/examples/ai_impact_analysis/dashboard/frontend/components/loading-screen.tsx b/examples/examples/ai_impact_analysis/dashboard/frontend/components/loading-screen.tsx deleted file mode 100644 index 089cdf833..000000000 --- a/examples/examples/ai_impact_analysis/dashboard/frontend/components/loading-screen.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import { Loader2 } from "lucide-react"; - -export function LoadingScreen() { - return ( -
-
- -

- Analyzing Repository -

-

This may take a few seconds...

-
-
- ); -} diff --git a/examples/examples/ai_impact_analysis/dashboard/frontend/components/repo-analysis-dashboard.tsx b/examples/examples/ai_impact_analysis/dashboard/frontend/components/repo-analysis-dashboard.tsx deleted file mode 100644 index 4cf6ddb71..000000000 --- a/examples/examples/ai_impact_analysis/dashboard/frontend/components/repo-analysis-dashboard.tsx +++ /dev/null @@ -1,113 +0,0 @@ -"use client"; - -import { ContributionTimeline } from "@/components/contribution-timeline"; -import { ContributorsBreakdown } from "@/components/contributors-breakdown"; -import { DashboardHeader } from "@/components/dashboard-header"; -import { HighImpactSymbols } from "@/components/high-impact-symbols"; -import { LoadingScreen } from "@/components/loading-screen"; -import { SummaryCards } from "@/components/summary-cards"; -import { TopAIFiles } from "@/components/top-ai-files"; -import { Button } from "@/components/ui/button"; -import { Card, CardContent } from "@/components/ui/card"; -import { Input } from "@/components/ui/input"; -import type { AnalysisData } from "@/lib/types"; -import { GitBranch, Loader2 } from "lucide-react"; -import { useState } from "react"; - -export function RepoAnalysisDashboard() { - const [data, setData] = useState(null); - const [loading, setLoading] = useState(false); - const [repoUrl, setRepoUrl] = useState(""); - - const handleSubmit = (e: React.FormEvent) => { - e.preventDefault(); - if (repoUrl.trim()) { - setLoading(true); - const match = repoUrl.match(/(?:github\.com\/)?([^/\s]+\/[^/\s]+)/); - if (match) { - const repoFullName = match[1]; - fetch( - `[your-modal-deployment-url]/analyze?repo_full_name=${repoFullName}`, - { - method: "POST", - }, - ) - .then((response) => { - if (!response.ok) { - throw new Error("Network response was not ok"); - } - return response.json(); - }) - .then((analysisData: AnalysisData) => { - setData(analysisData); - setLoading(false); - }) - .catch((error) => { - console.error("Error analyzing repository:", error); - setLoading(false); - }); - } - } - }; - - return ( -
- {loading && } - - - - - -
-
- -
-
- - setRepoUrl(e.target.value)} - disabled={loading} - /> -
- -
-
-
-
-
- - {data && ( -
- - -
- - -
- -
- - -
-
- )} -

-

-
- ); -} diff --git a/examples/examples/ai_impact_analysis/dashboard/frontend/components/summary-cards.tsx b/examples/examples/ai_impact_analysis/dashboard/frontend/components/summary-cards.tsx deleted file mode 100644 index dea866379..000000000 --- a/examples/examples/ai_impact_analysis/dashboard/frontend/components/summary-cards.tsx +++ /dev/null @@ -1,77 +0,0 @@ -import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; -import type { AnalysisData } from "@/lib/types"; -import { BarChart3, FileCode, GitCommit, Percent } from "lucide-react"; - -interface SummaryCardsProps { - data: AnalysisData; -} - -export function SummaryCards({ data }: SummaryCardsProps) { - const { stats, ai_symbol_count, total_symbol_count } = data; - - return ( -
- - - AI Commits - - - -
- {stats.ai_commits} / {stats.total_commits} -
-

- {stats.ai_percentage.toFixed(1)}% of total commits -

-
-
- - - - AI Files - - - -
- {stats.ai_file_count} / {stats.total_file_count} -
-

- {((stats.ai_file_count / stats.total_file_count) * 100).toFixed(1)}% - of files have >50% AI contribution -

-
-
- - - - AI Symbols - - - -
- {ai_symbol_count} / {total_symbol_count} -
-

- {((ai_symbol_count / total_symbol_count) * 100).toFixed(1)}% of code - symbols -

-
-
- - - - High Impact - - - -
- {data.high_impact_symbols.length} -
-

- AI-written symbols with high usage -

-
-
-
- ); -} diff --git a/examples/examples/ai_impact_analysis/dashboard/frontend/components/theme-provider.tsx b/examples/examples/ai_impact_analysis/dashboard/frontend/components/theme-provider.tsx deleted file mode 100644 index 020003cf9..000000000 --- a/examples/examples/ai_impact_analysis/dashboard/frontend/components/theme-provider.tsx +++ /dev/null @@ -1,11 +0,0 @@ -"use client"; - -import { - ThemeProvider as NextThemesProvider, - type ThemeProviderProps, -} from "next-themes"; -import * as React from "react"; - -export function ThemeProvider({ children, ...props }: ThemeProviderProps) { - return {children}; -} diff --git a/examples/examples/ai_impact_analysis/dashboard/frontend/components/top-ai-files.tsx b/examples/examples/ai_impact_analysis/dashboard/frontend/components/top-ai-files.tsx deleted file mode 100644 index 67a5472a8..000000000 --- a/examples/examples/ai_impact_analysis/dashboard/frontend/components/top-ai-files.tsx +++ /dev/null @@ -1,48 +0,0 @@ -import { - Card, - CardContent, - CardDescription, - CardHeader, - CardTitle, -} from "@/components/ui/card"; -import { Progress } from "@/components/ui/progress"; -import { ScrollArea } from "@/components/ui/scroll-area"; - -interface TopAIFilesProps { - files: [string, number][]; -} - -export function TopAIFiles({ files }: TopAIFilesProps) { - return ( - - - Top AI-Contributed Files - - Files with highest AI contribution percentage - - - - -
- {files.map(([filepath, percentage]) => ( -
-
-
- {filepath.split("/").pop()} -
-
- {percentage.toFixed(1)}% -
-
- -
- {filepath} -
-
- ))} -
-
-
-
- ); -} diff --git a/examples/examples/ai_impact_analysis/dashboard/frontend/components/ui/button.tsx b/examples/examples/ai_impact_analysis/dashboard/frontend/components/ui/button.tsx deleted file mode 100644 index 91b784a28..000000000 --- a/examples/examples/ai_impact_analysis/dashboard/frontend/components/ui/button.tsx +++ /dev/null @@ -1,56 +0,0 @@ -import { Slot } from "@radix-ui/react-slot"; -import { type VariantProps, cva } from "class-variance-authority"; -import * as React from "react"; - -import { cn } from "@/lib/utils"; - -const buttonVariants = cva( - "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0", - { - variants: { - variant: { - default: "bg-primary text-primary-foreground hover:bg-primary/90", - destructive: - "bg-destructive text-destructive-foreground hover:bg-destructive/90", - outline: - "border border-input bg-background hover:bg-accent hover:text-accent-foreground", - secondary: - "bg-secondary text-secondary-foreground hover:bg-secondary/80", - ghost: "hover:bg-accent hover:text-accent-foreground", - link: "text-primary underline-offset-4 hover:underline", - }, - size: { - default: "h-10 px-4 py-2", - sm: "h-9 rounded-md px-3", - lg: "h-11 rounded-md px-8", - icon: "h-10 w-10", - }, - }, - defaultVariants: { - variant: "default", - size: "default", - }, - }, -); - -export interface ButtonProps - extends React.ButtonHTMLAttributes, - VariantProps { - asChild?: boolean; -} - -const Button = React.forwardRef( - ({ className, variant, size, asChild = false, ...props }, ref) => { - const Comp = asChild ? Slot : "button"; - return ( - - ); - }, -); -Button.displayName = "Button"; - -export { Button, buttonVariants }; diff --git a/examples/examples/ai_impact_analysis/dashboard/frontend/components/ui/card.tsx b/examples/examples/ai_impact_analysis/dashboard/frontend/components/ui/card.tsx deleted file mode 100644 index bb368bd00..000000000 --- a/examples/examples/ai_impact_analysis/dashboard/frontend/components/ui/card.tsx +++ /dev/null @@ -1,86 +0,0 @@ -import * as React from "react"; - -import { cn } from "@/lib/utils"; - -const Card = React.forwardRef< - HTMLDivElement, - React.HTMLAttributes ->(({ className, ...props }, ref) => ( -
-)); -Card.displayName = "Card"; - -const CardHeader = React.forwardRef< - HTMLDivElement, - React.HTMLAttributes ->(({ className, ...props }, ref) => ( -
-)); -CardHeader.displayName = "CardHeader"; - -const CardTitle = React.forwardRef< - HTMLDivElement, - React.HTMLAttributes ->(({ className, ...props }, ref) => ( -
-)); -CardTitle.displayName = "CardTitle"; - -const CardDescription = React.forwardRef< - HTMLDivElement, - React.HTMLAttributes ->(({ className, ...props }, ref) => ( -
-)); -CardDescription.displayName = "CardDescription"; - -const CardContent = React.forwardRef< - HTMLDivElement, - React.HTMLAttributes ->(({ className, ...props }, ref) => ( -
-)); -CardContent.displayName = "CardContent"; - -const CardFooter = React.forwardRef< - HTMLDivElement, - React.HTMLAttributes ->(({ className, ...props }, ref) => ( -
-)); -CardFooter.displayName = "CardFooter"; - -export { - Card, - CardHeader, - CardFooter, - CardTitle, - CardDescription, - CardContent, -}; diff --git a/examples/examples/ai_impact_analysis/dashboard/frontend/components/ui/chart.tsx b/examples/examples/ai_impact_analysis/dashboard/frontend/components/ui/chart.tsx deleted file mode 100644 index aa3d5f99a..000000000 --- a/examples/examples/ai_impact_analysis/dashboard/frontend/components/ui/chart.tsx +++ /dev/null @@ -1,365 +0,0 @@ -"use client"; - -import * as React from "react"; -import * as RechartsPrimitive from "recharts"; - -import { cn } from "@/lib/utils"; - -// Format: { THEME_NAME: CSS_SELECTOR } -const THEMES = { light: "", dark: ".dark" } as const; - -export type ChartConfig = { - [k in string]: { - label?: React.ReactNode; - icon?: React.ComponentType; - } & ( - | { color?: string; theme?: never } - | { color?: never; theme: Record } - ); -}; - -type ChartContextProps = { - config: ChartConfig; -}; - -const ChartContext = React.createContext(null); - -function useChart() { - const context = React.useContext(ChartContext); - - if (!context) { - throw new Error("useChart must be used within a "); - } - - return context; -} - -const ChartContainer = React.forwardRef< - HTMLDivElement, - React.ComponentProps<"div"> & { - config: ChartConfig; - children: React.ComponentProps< - typeof RechartsPrimitive.ResponsiveContainer - >["children"]; - } ->(({ id, className, children, config, ...props }, ref) => { - const uniqueId = React.useId(); - const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`; - - return ( - -
- - - {children} - -
-
- ); -}); -ChartContainer.displayName = "Chart"; - -const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => { - const colorConfig = Object.entries(config).filter( - ([_, config]) => config.theme || config.color, - ); - - if (!colorConfig.length) { - return null; - } - - return ( -