diff --git a/src/codegen/cli/api/client.py b/src/codegen/cli/api/client.py index a1b887f..d8cf20c 100644 --- a/src/codegen/cli/api/client.py +++ b/src/codegen/cli/api/client.py @@ -168,13 +168,13 @@ def ask_expert(self, query: str) -> AskExpertResponse: AskExpertResponse, ) - def create(self, query: str) -> CreateResponse: + def create(self, name: str, query: str) -> CreateResponse: """Get AI-generated starter code for a codemod.""" session = CodegenSession() return self._make_request( "GET", CREATE_ENDPOINT, - CreateInput(input=CreateInput.BaseCreateInput(query=query, repo_full_name=session.repo_name)), + CreateInput(input=CreateInput.BaseCreateInput(name=name, query=query, repo_full_name=session.repo_name)), CreateResponse, ) diff --git a/src/codegen/cli/api/schemas.py b/src/codegen/cli/api/schemas.py index 8afb479..43141c5 100644 --- a/src/codegen/cli/api/schemas.py +++ b/src/codegen/cli/api/schemas.py @@ -91,6 +91,7 @@ class DocsResponse(SafeBaseModel): class CreateInput(SafeBaseModel): class BaseCreateInput(SafeBaseModel): + name: str query: str | None = None repo_full_name: str | None = None diff --git a/src/codegen/cli/commands/create/main.py b/src/codegen/cli/commands/create/main.py index 3788354..d6e1e54 100644 --- a/src/codegen/cli/commands/create/main.py +++ b/src/codegen/cli/commands/create/main.py @@ -79,7 +79,7 @@ def create_command(session: CodegenSession, name: str, path: Path, description: # Check if file exists if target_path.exists() and not overwrite: rel_path = make_relative(target_path) - pretty_print_error(f"File already exists at {format_path(rel_path)}\n\n" "To overwrite the file:\n" f"{format_command(f'codegen create {name} {rel_path} --overwrite')}") + pretty_print_error(f"File already exists at {format_path(rel_path)}\n\nTo overwrite the file:\n{format_command(f'codegen create {name} {rel_path} --overwrite')}") return if description: @@ -91,7 +91,7 @@ def create_command(session: CodegenSession, name: str, path: Path, description: with create_spinner(status_message) as status: try: # Get code from API - response = RestAPI(session.token).create(description if description else None) + response = RestAPI(session.token).create(name=name, query=description if description else None) # Convert the code to include the decorator code = convert_to_cli(response.code, session.config.programming_language or ProgrammingLanguage.PYTHON, name) @@ -120,7 +120,7 @@ def create_command(session: CodegenSession, name: str, path: Path, description: rich.print("📁 Files Created:") rich.print(f" [dim]Function:[/dim] {make_relative(target_path)}") if response.context: - rich.print(f" [dim]Prompt:[/dim] {make_relative(get_prompts_dir() / f'{name.lower().replace(' ', '-')}-system-prompt.md')}") + rich.print(f" [dim]Prompt:[/dim] {make_relative(get_prompts_dir() / f'{name.lower().replace(" ", "-")}-system-prompt.md')}") # Next steps rich.print("\n[bold]What's next?[/bold]\n")