From 1ddeb9a3e26d103baf416de5e84ca27ef09f4a97 Mon Sep 17 00:00:00 2001 From: Rushil Patel Date: Wed, 29 Jan 2025 15:10:55 -0800 Subject: [PATCH 1/3] fix: create commnad response access --- src/codegen/cli/commands/create/main.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/codegen/cli/commands/create/main.py b/src/codegen/cli/commands/create/main.py index 390276a2d..0a7b8f9ce 100644 --- a/src/codegen/cli/commands/create/main.py +++ b/src/codegen/cli/commands/create/main.py @@ -86,23 +86,24 @@ def create_command(session: CodegenSession, name: str, path: Path, description: return rich.print("") # Add a newline before output - + response = None try: if description: # Use API to generate implementation with create_spinner("Generating function (using LLM, this will take ~10s)") as status: response = RestAPI(session.token).create(name=name, query=description) code = convert_to_cli(response.code, session.language, name) + prompt_path.write_text(response.context) else: # Use default implementation code = DEFAULT_CODEMOD.format(name=name) - # Create the target directory if needed - codemod_path.parent.mkdir(parents=True, exist_ok=True) + # Create the target directory if needed + codemod_path.parent.mkdir(parents=True, exist_ok=True) - # Write the function code - codemod_path.write_text(code) - prompt_path.write_text(response.context) + # Write the function code + codemod_path.write_text(code) + except (ServerError, ValueError) as e: raise click.ClickException(str(e)) @@ -112,8 +113,8 @@ def create_command(session: CodegenSession, name: str, path: Path, description: rich.print("") rich.print("📁 Files Created:") rich.print(f" [dim]Function:[/dim] {make_relative(codemod_path)}") - if description and response.context: - rich.print(f" [dim]Prompt:[/dim] {make_relative(prompt_path)}") + if description and response and response.context: + rich.print(f" [dim]Prompt:[/dim] {description}") # Next steps rich.print("\n[bold]What's next?[/bold]\n") From 37944f10ff06ed2351a3e79a3e8453a32f4f31c3 Mon Sep 17 00:00:00 2001 From: Rushil Patel Date: Wed, 29 Jan 2025 15:24:02 -0800 Subject: [PATCH 2/3] fix: precommit lint --- src/codegen/cli/commands/create/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/codegen/cli/commands/create/main.py b/src/codegen/cli/commands/create/main.py index 0a7b8f9ce..339f38102 100644 --- a/src/codegen/cli/commands/create/main.py +++ b/src/codegen/cli/commands/create/main.py @@ -103,7 +103,7 @@ def create_command(session: CodegenSession, name: str, path: Path, description: # Write the function code codemod_path.write_text(code) - + except (ServerError, ValueError) as e: raise click.ClickException(str(e)) From e2944615cbf7bdd097dfaec1912f9bfa40e0ddf4 Mon Sep 17 00:00:00 2001 From: Rushil Patel Date: Wed, 29 Jan 2025 15:42:08 -0800 Subject: [PATCH 3/3] fix: precommit lint --- docs/mint.json | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/docs/mint.json b/docs/mint.json index 5a54f68a0..7bf73f9bf 100644 --- a/docs/mint.json +++ b/docs/mint.json @@ -9,21 +9,21 @@ "default": "dark" }, "metadata": { - "og:site_name": "Codegen", - "og:title": "Codegen - Manipulate code at scale", - "og:description": "A scriptable interface to a powerful, multi-lingual language server built on top of Tree-sitter.", - "og:url": "https://codegen.com", - "og:image": "https://mintlify.s3.us-west-1.amazonaws.com/codegeninc/images/codegen.jpeg", - "og:locale": "en_US", - "og:logo": "https://mintlify.s3.us-west-1.amazonaws.com/codegeninc/images/codegen-thumbnail.png", - "article:publisher": "Codegen, Inc.", - "twitter:title": "Codegen - Manipulate code at scale", - "twitter:description": "A scriptable interface to a powerful, multi-lingual language server built on top of Tree-sitter.", - "twitter:url": "https://codegen.com", - "twitter:image": "https://mintlify.s3.us-west-1.amazonaws.com/codegeninc/images/codegen.jpeg", - "twitter:site": "@codegen", - "og:image:width": "2400", - "og:image:height": "1200" + "og:site_name": "Codegen", + "og:title": "Codegen - Manipulate code at scale", + "og:description": "A scriptable interface to a powerful, multi-lingual language server built on top of Tree-sitter.", + "og:url": "https://codegen.com", + "og:image": "https://mintlify.s3.us-west-1.amazonaws.com/codegeninc/images/codegen.jpeg", + "og:locale": "en_US", + "og:logo": "https://mintlify.s3.us-west-1.amazonaws.com/codegeninc/images/codegen-thumbnail.png", + "article:publisher": "Codegen, Inc.", + "twitter:title": "Codegen - Manipulate code at scale", + "twitter:description": "A scriptable interface to a powerful, multi-lingual language server built on top of Tree-sitter.", + "twitter:url": "https://codegen.com", + "twitter:image": "https://mintlify.s3.us-west-1.amazonaws.com/codegeninc/images/codegen.jpeg", + "twitter:site": "@codegen", + "og:image:width": "2400", + "og:image:height": "1200" }, "favicon": "/favicon.svg", "colors": {