From 73be8afc5238b4b6994156d657bde189ff23ce58 Mon Sep 17 00:00:00 2001 From: codegen-bot Date: Sun, 26 Jan 2025 15:39:53 -0800 Subject: [PATCH 1/5] . --- docs/introduction/work-with-ai.mdx | 36 ------------------------------ 1 file changed, 36 deletions(-) diff --git a/docs/introduction/work-with-ai.mdx b/docs/introduction/work-with-ai.mdx index fb63578c6..00d1666d4 100644 --- a/docs/introduction/work-with-ai.mdx +++ b/docs/introduction/work-with-ai.mdx @@ -96,39 +96,3 @@ This will ensure that the IDE's native chat model is aware of the APIs and commo ## Devin, OpenHands and Semi-autonomous Code Agents Coming soon! - -## Coming Soon - - - - Pre-built prompts for common transformation scenarios, ready to use with any - AI. - - - Specialized prompts for specific upgrade paths (React, TypeScript, etc.). - - - -## Best Practices - -1. **Use Generated Prompts**: Let Codegen generate system prompts instead of writing them manually. They include important context about your codebase. - -2. **Be Specific**: When creating a codemod, provide detailed descriptions to help the AI understand your goals: - - ```bash - codegen create migrate-api --description "Update API calls to use the new v2 endpoints, handling pagination and error responses" - ``` - -3. **Leverage Context**: In Cursor, always @mention your codemod to give the AI full context about your transformation. - -4. **Iterative Refinement**: Use AI suggestions as a starting point, then refine based on your specific needs. - - - The system prompts are designed to be human-readable. Review them to - understand what context is being provided to the AI. - - - - You can also use the generated system prompts with other AI tools - just copy - the prompt content and paste it into your preferred AI interface. - From a1a202795a5721e0504d7a0c244bf750d7daae5f Mon Sep 17 00:00:00 2001 From: codegen-bot Date: Sun, 26 Jan 2025 15:50:25 -0800 Subject: [PATCH 2/5] . --- docs/building-with-codegen/symbol-api.mdx | 22 +++++++-------- docs/introduction/community.mdx | 31 --------------------- docs/introduction/how-it-works.mdx | 2 +- docs/introduction/overview.mdx | 34 ++++++++++------------- 4 files changed, 27 insertions(+), 62 deletions(-) diff --git a/docs/building-with-codegen/symbol-api.mdx b/docs/building-with-codegen/symbol-api.mdx index ff099a522..c39ae90bb 100644 --- a/docs/building-with-codegen/symbol-api.mdx +++ b/docs/building-with-codegen/symbol-api.mdx @@ -5,13 +5,13 @@ icon: "shapes" iconType: "solid" --- -The [`Symbol`](/api-reference/core/Symbol) is the primary way developers interact with code in Codegen. It maps to how developers think about code - as functions, classes, variables, and other named entities. +The [Symbol](/api-reference/core/Symbol) is the primary way developers interact with code in Codegen. It maps to how developers think about code - as functions, classes, variables, and other named entities. -Both the [`Function`](/api-reference/core/Function) and [`Class`](/api-reference/core/Class) symbols are subclasses of the [`Symbol`](/api-reference/core/Symbol) class. +Both the [Function](/api-reference/core/Function) and [Class](/api-reference/core/Class) symbols are subclasses of the [Symbol](/api-reference/core/Symbol) class. ## Accessing Symbols -The [`Codebase`](/api-reference/core/Codebase) class provides getters and iterators for functions, classes and symbols: +The [Codebase](/api-reference/core/Codebase) class provides getters and iterators for functions, classes and symbols: ```python # Core symbol types @@ -32,17 +32,17 @@ for symbol in codebase.functions + codebase.classes: All symbols share common APIs for manipulation: -- The [`Editable`](/api-reference/core/Editable) API +- The [Editable](/api-reference/core/Editable) API - Metadata - - [`symbol.name`](/api-reference/core/Symbol#name) - - [`symbol.source`](/api-reference/core/Symbol#source) - - [`symbol.docstring`](/api-reference/core/Symbol#docstring) + - [symbol.name](/api-reference/core/Symbol#name) + - [symbol.source](/api-reference/core/Symbol#source) + - [symbol.docstring](/api-reference/core/Symbol#docstring) - Edit operations - - [`symbol.set_docstring`](/api-reference/core/Symbol#add_comment) - - [`symbol.move_to_file`](/api-reference/core/Symbol#move-to-file) (see [Moving Symbols](/building-with-codegen/moving-symbols)) + - [symbol.set_docstring](/api-reference/core/Symbol#add_comment) + - [symbol.move_to_file](/api-reference/core/Symbol#move-to-file) (see [Moving Symbols](/building-with-codegen/moving-symbols)) - Graph relations (See [Usages and Dependencies](/building-with-codegen/dependencies-and-usages)) - - [`symbol.usages`](/api-reference/core/Symbol#usages) - - [`symbol.dependencies`](/api-reference/core/Symbol#dependencies) + - [symbol.usages](/api-reference/core/Symbol#usages) + - [symbol.dependencies](/api-reference/core/Symbol#dependencies) ## Name operations diff --git a/docs/introduction/community.mdx b/docs/introduction/community.mdx index 658f6b01e..06592b392 100644 --- a/docs/introduction/community.mdx +++ b/docs/introduction/community.mdx @@ -36,35 +36,6 @@ Join the growing Codegen community! We're excited to have you be part of our jou Please help us improve this library and documentation by submitting a PR! -## Community Channels - -### Slack - -Our [Slack community](https://community.codegen.com) is where you can: - -- Get help and support -- Share your Codegen projects -- Connect with other developers -- Stay updated on new features - -### GitHub - -Codegen is [open source](https://github.com/codegen-sh/codegen-sdk) and we welcome contributions! On GitHub you can: - -- Report issues -- Submit pull requests -- Star the project -- Browse the source code - -### Twitter (X) - -Follow us on [Twitter/X](https://x.com/codegen) to: - -- Get the latest updates -- See community highlights -- Connect with the team -- Share your Codegen wins - ## Contributing We welcome contributions of all kinds! Whether you're fixing a typo in documentation, reporting a bug, or implementing a new feature, we appreciate your help in making Codegen better. @@ -75,5 +46,3 @@ Check out our [Contributing Guide](https://github.com/codegen-sh/codegen-sdk/blo - Submit pull requests - Report issues - Contribute to documentation - -Together, we can build better tools for code transformation! diff --git a/docs/introduction/how-it-works.mdx b/docs/introduction/how-it-works.mdx index ac908a79b..8777a5be4 100644 --- a/docs/introduction/how-it-works.mdx +++ b/docs/introduction/how-it-works.mdx @@ -21,7 +21,7 @@ Codegen performs advanced static analysis to build a rich graph representation o ## The Codebase Graph -At the heart of Codegen is a comprehensive graph representation of your code. When you initialize a `[Codebase](/api-reference/core/Codebase)`, it performs static analysis to construct a rich graph structure connecting code elements: +At the heart of Codegen is a comprehensive graph representation of your code. When you initialize a [Codebase](/api-reference/core/Codebase), it performs static analysis to construct a rich graph structure connecting code elements: ```python # Initialize and analyze the codebase diff --git a/docs/introduction/overview.mdx b/docs/introduction/overview.mdx index 0a21491d1..24a10d0a6 100644 --- a/docs/introduction/overview.mdx +++ b/docs/introduction/overview.mdx @@ -9,24 +9,16 @@ iconType: "solid" It provides a scriptable interface to a powerful, multi-lingual language server built on top of [Tree-sitter](https://tree-sitter.github.io/tree-sitter/). -export const intoSnippet = `# grabs codebase content - -file = codebase.files[0] # or .get_file("test.py") -function = codebase.functions[0] # or .get_symbol("my_func") - -# print logs - -print(f'# of files: {len(codebase.files)}') -print(f'# of functions: {len(codebase.functions)}') - -# make edits - -file.edit('🌈' + file.content) # edit contents -function.rename('new_name') # rename -function.set_docstring('new docstring') # set docstring - -# ... etc. - +export const intoSnippet = `# Codegen builds a complete graph connecting +# functions, classes, imports and their relationships +from codegen import Codebase + +# Work with code without dealing with syntax trees or parsing +for function in codebase.functions: + # Comprehensive static analysis for references, dependencies, etc. + if not function.usages: + # Auto-handles references and imports to maintain correctness + function.remove() `