diff --git a/README.md b/README.md index 2e711f17b..8458d9b94 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,32 @@
-The Codegen SDK provides a programmatic interface to code agents provided by [Codegen](https://codegen.com). +# Codegen SDK + +The Codegen SDK provides a programmatic interface to AI-powered code agents provided by [Codegen](https://codegen.com). It enables developers to integrate intelligent code generation, analysis, and transformation capabilities into their workflows and applications. + +## Features + +- **AI-Powered Code Generation**: Generate code based on natural language descriptions +- **Code Analysis**: Analyze codebases for patterns, issues, and insights +- **Code Transformation**: Refactor and transform code with intelligent understanding of context +- **Multi-Language Support**: Works with Python, JavaScript, TypeScript, and more +- **Integration with Development Workflows**: Seamlessly integrate with your existing tools +- **Extensible Architecture**: Build custom extensions and workflows + +## Installation + +Install the SDK using pip or uv: + +```bash +pip install codegen +# or +uv pip install codegen +``` + +Requires Python 3.12 or newer. + +## Quick Start ```python from codegen.agents.agent import Agent @@ -51,31 +76,82 @@ if task.status == "completed": print(task.result) # Result often contains code, summaries, or links ``` -## Installation and Usage +## Advanced Usage -Install the SDK using pip or uv: +### Working with Specific Files + +```python +from codegen.agents.agent import Agent + +agent = Agent(org_id="YOUR_ORG_ID", token="YOUR_API_TOKEN") + +# Analyze a specific file +task = agent.run(prompt="Analyze this file for potential bugs and suggest improvements.", files=["path/to/your/file.py"]) + +# Wait for completion and get results +task.wait_until_complete() +print(task.result) +``` + +### Transforming Code + +```python +from codegen.agents.agent import Agent + +agent = Agent(org_id="YOUR_ORG_ID", token="YOUR_API_TOKEN") + +# Transform code based on requirements +task = agent.run(prompt="Refactor this code to use async/await pattern instead of callbacks.", files=["path/to/your/file.js"]) + +# Wait for completion and get results +task.wait_until_complete() +print(task.result) +``` + +## Command Line Interface + +The SDK includes a powerful CLI tool that allows you to interact with Codegen directly from your terminal: ```bash -pip install codegen -# or -uv pip install codegen +# Get help +codegen --help + +# Initialize configuration +codegen init + +# Run an agent with a prompt +codegen run "Implement a function to calculate Fibonacci numbers" + +# Analyze a file +codegen analyze path/to/file.py ``` -Get started at [codegen.com](https://codegen.com) and get your API token at [codegen.com/developer](https://codegen.com/developer). +## Integrations + +Codegen integrates with popular development tools: -You can interact with your AI engineer via API, or chat with it in Slack, Linear, Github, or on our website. +- **Slack**: Chat with your AI engineer in Slack +- **GitHub**: Get PR reviews and code suggestions +- **Linear**: Manage tasks and issues with AI assistance +- **Web Interface**: Use the web UI at [codegen.com](https://codegen.com) ## Resources -- [Docs](https://docs.codegen.com) -- [Getting Started](https://docs.codegen.com/introduction/getting-started) -- [Contributing](CONTRIBUTING.md) +- [Documentation](https://docs.codegen.com) +- [Getting Started Guide](https://docs.codegen.com/introduction/getting-started) +- [API Reference](https://docs.codegen.com/api-reference) +- [Examples](https://github.com/codegen-sh/codegen-examples) +- [Contributing Guide](CONTRIBUTING.md) - [Contact Us](https://codegen.com/contact) ## Contributing -Please see our [Contributing Guide](CONTRIBUTING.md) for instructions on how to set up the development environment and submit contributions. +We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for instructions on how to set up the development environment and submit contributions. ## Enterprise For more information on enterprise engagements, please [contact us](https://codegen.com/contact) or [request a demo](https://codegen.com/request-demo). + +## License + +This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details. diff --git a/codegen-examples/examples/ai_impact_analysis/dashboard/frontend/components/ui/chart.tsx b/codegen-examples/examples/ai_impact_analysis/dashboard/frontend/components/ui/chart.tsx index aa3d5f99a..f51563023 100644 --- a/codegen-examples/examples/ai_impact_analysis/dashboard/frontend/components/ui/chart.tsx +++ b/codegen-examples/examples/ai_impact_analysis/dashboard/frontend/components/ui/chart.tsx @@ -1,6 +1,7 @@ "use client"; import * as React from "react"; +import { useEffect, useRef } from "react"; import * as RechartsPrimitive from "recharts"; import { cn } from "@/lib/utils"; @@ -9,55 +10,52 @@ import { cn } from "@/lib/utils"; 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 } - ); + [key: string]: { + theme?: Record; + color?: string; + }; }; type ChartContextProps = { - config: ChartConfig; + chartId: string; }; -const ChartContext = React.createContext(null); +const ChartContext = React.createContext({ + chartId: "", +}); -function useChart() { +const useChart = () => { const context = React.useContext(ChartContext); if (!context) { - throw new Error("useChart must be used within a "); + throw new Error("useChart must be used within a ChartProvider"); } return context; -} +}; const ChartContainer = React.forwardRef< HTMLDivElement, - React.ComponentProps<"div"> & { - config: ChartConfig; - children: React.ComponentProps< - typeof RechartsPrimitive.ResponsiveContainer - >["children"]; + React.HTMLAttributes & { + config?: ChartConfig; } ->(({ id, className, children, config, ...props }, ref) => { - const uniqueId = React.useId(); - const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`; +>(({ children, config = {}, className, ...props }, ref) => { + const chartId = React.useId(); return ( - +
- + config.theme || config.color, + )} + /> {children} @@ -67,289 +65,105 @@ const ChartContainer = React.forwardRef< }); ChartContainer.displayName = "Chart"; -const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => { - const colorConfig = Object.entries(config).filter( - ([_, config]) => config.theme || config.color, - ); +// Add ChartThemeStylesProps type +type ChartThemeStylesProps = { + id: string; + colorConfig: [string, { theme?: Record; color?: string }][]; +}; +const ChartThemeStyles = ({ id, colorConfig }: ChartThemeStylesProps) => { if (!colorConfig.length) { return null; } - return ( -