diff --git a/main.py b/main.py deleted file mode 100644 index ccba834db..000000000 --- a/main.py +++ /dev/null @@ -1,50 +0,0 @@ -import sys - -from smol_dev.prompts import plan, specify_file_paths, generate_code_sync -from smol_dev.utils import generate_folder, write_file -from smol_dev.main import main -import argparse - - - - -# for local testing -# python main.py --prompt "a simple JavaScript/HTML/CSS/Canvas app that is a one player game of PONG..." --generate_folder_path "generated" --debug True - -if __name__ == "__main__": - prompt = """ - a simple JavaScript/HTML/CSS/Canvas app that is a one player game of PONG. - The left paddle is controlled by the player, following where the mouse goes. - The right paddle is controlled by a simple AI algorithm, which slowly moves the paddle toward the ball at every frame, with some probability of error. - Make the canvas a 400 x 400 black square and center it in the app. - Make the paddles 100px long, yellow and the ball small and red. - Make sure to render the paddles and name them so they can controlled in javascript. - Implement the collision detection and scoring as well. - Every time the ball bouncess off a paddle, the ball should move faster. - It is meant to run in Chrome browser, so dont use anything that is not supported by Chrome, and don't use the import and export keywords. - """ - if len(sys.argv) == 2: - prompt = sys.argv[1] - args = None - else: - parser = argparse.ArgumentParser() - parser.add_argument("--prompt", type=str, help="Prompt for the app to be created.") - parser.add_argument("--model", type=str, default="gpt-4-0613", help="model to use. can also use gpt-3.5-turbo-0613") - parser.add_argument("--generate_folder_path", type=str, default="generated", help="Path of the folder for generated code.") - parser.add_argument("--debug", type=bool, default=False, help="Enable or disable debug mode.") - args = parser.parse_args() - if args.prompt: - prompt = args.prompt - - # read file from prompt if it ends in a .md filetype - if len(prompt) < 100 and prompt.endswith(".md"): - with open(prompt, "r") as promptfile: - prompt = promptfile.read() - - print(prompt) - - if args is None: - # This is in case we're just calling the main function directly with a prompt - main(prompt=prompt) - else: - main(prompt=prompt, generate_folder_path=args.generate_folder_path, debug=args.debug, model=args.model) diff --git a/pyproject.toml b/pyproject.toml index 158cf4320..36ba8db77 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,27 +1,23 @@ -[tool.poetry] +[project] +authors = [ + {name = "swyx", email = "swyx@dontemail.me"}, +] +license = "MIT" +requires-python = "<4.0.0,>=3.10" +dependencies = [ + "openai<1.0.0,>=0.27.8", + "openai-function-call<1.0.0,>=0.0.5", + "tenacity<9.0.0,>=8.2.2", + "agent-protocol<2.0.0,>=1.0.0", +] name = "smol_dev" version = "0.0.3" description = "python module of smol developer" -authors = ["swyx "] -license = "MIT" readme = "readme.md" -packages = [{ include = "smol_dev" }] - -[tool.poetry.dependencies] -python = ">=3.10,<4.0.0" -openai = "^0.27.8" -openai-function-call = "^0.0.5" -tenacity = "^8.2.2" -agent-protocol = "^1.0.0" - -[build-system] -requires = ["poetry-core"] -build-backend = "poetry.core.masonry.api" - -[tool.poetry.scripts] -src = "src.__main__:main" -api = "smol_dev.api:main" - [project.urls] "Homepage" = "https://github.com/smol-ai/developer" "Bug Tracker" = "https://github.com/smol-ai/developer/issues" + +[project.scripts] +smol-dev-api = "smol_dev.api:main" +smol-dev = "smol_dev.main:main" diff --git a/readme.md b/readme.md index e4f1a0ce2..6e93ea91e 100644 --- a/readme.md +++ b/readme.md @@ -30,17 +30,17 @@ After the [successful initial v0 launch](https://twitter.com/swyx/status/1657578 ```bash # install -git clone https://github.com/smol-ai/developer.git -cd developer -poetry install # install dependencies. pip install poetry if you need +uv tool install https://github.com/smol-ai/developer.git # run -python main.py "a HTML/JS/CSS Tic Tac Toe Game" # defaults to gpt-4-0613 -# python main.py "a HTML/JS/CSS Tic Tac Toe Game" --model=gpt-3.5-turbo-0613 +smol-dev -h + +# alternatively, without installing to a fixed location +# uvx --from https://github.com/smol-ai/developer.git smol-dev --prompt asdfasdf # other cli flags -python main.py --prompt prompt.md # for longer prompts, move them into a markdown file -python main.py --prompt prompt.md --debug True # for debugging +smol-dev --prompt prompt.md # for longer prompts, move them into a markdown file +smol-dev --prompt prompt.md --debug True # for debugging ```
@@ -58,7 +58,7 @@ This lets you develop apps as a human in the loop, as per the original version o The demo example in `prompt.md` shows the potential of AI-enabled, but still firmly human developer centric, workflow: - Human writes a basic prompt for the app they want to build -- `main.py` generates code +- `smoll-dev` generates code - Human runs/reads the code - Human can: - simply add to the prompt as they discover underspecified parts of the prompt @@ -80,7 +80,7 @@ This is the new thing in smol developer v1! Add `smol developer` to your own pro pip install smol_dev ``` -Here you can basically look at the contents of `main.py` as our "documentation" of how you can use these functions and prompts in your own app: +Here you can basically look at the contents of `src/smoll_dev/main.py` as our "documentation" of how you can use these functions and prompts in your own app: ```python from smol_dev.prompts import plan, specify_file_paths, generate_code_sync diff --git a/smol_dev/__init__.py b/src/smol_dev/__init__.py similarity index 100% rename from smol_dev/__init__.py rename to src/smol_dev/__init__.py diff --git a/smol_dev/api.py b/src/smol_dev/api.py similarity index 100% rename from smol_dev/api.py rename to src/smol_dev/api.py diff --git a/smol_dev/main.py b/src/smol_dev/main.py similarity index 83% rename from smol_dev/main.py rename to src/smol_dev/main.py index 536e0ddec..0e75da59a 100644 --- a/smol_dev/main.py +++ b/src/smol_dev/main.py @@ -8,7 +8,7 @@ # model = "gpt-3.5-turbo-0613" defaultmodel = "gpt-4-0613" -def main(prompt, generate_folder_path="generated", debug=False, model: str = defaultmodel): +def _main(prompt, generate_folder_path="generated", debug=False, model: str = defaultmodel): # create generateFolder folder if doesnt exist generate_folder(generate_folder_path) @@ -75,7 +75,7 @@ def stream_handler(chunk): # for local testing # python main.py --prompt "a simple JavaScript/HTML/CSS/Canvas app that is a one player game of PONG..." --generate_folder_path "generated" --debug True -if __name__ == "__main__": +def main(): prompt = """ a simple JavaScript/HTML/CSS/Canvas app that is a one player game of PONG. The left paddle is controlled by the player, following where the mouse goes. @@ -87,18 +87,17 @@ def stream_handler(chunk): Every time the ball bouncess off a paddle, the ball should move faster. It is meant to run in Chrome browser, so dont use anything that is not supported by Chrome, and don't use the import and export keywords. """ - if len(sys.argv) == 2: - prompt = sys.argv[1] - else: - - parser = argparse.ArgumentParser() - parser.add_argument("--prompt", type=str, required=True, help="Prompt for the app to be created.") - parser.add_argument("--generate_folder_path", type=str, default="generated", help="Path of the folder for generated code.") - parser.add_argument("--debug", type=bool, default=False, help="Enable or disable debug mode.") - args = parser.parse_args() - if args.prompt: - prompt = args.prompt + parser = argparse.ArgumentParser() + parser.add_argument("--prompt", type=str, required=True, help="Prompt for the app to be created.") + parser.add_argument("--generate_folder_path", type=str, default="generated", help="Path of the folder for generated code.") + parser.add_argument("--debug", type=bool, default=False, help="Enable or disable debug mode.") + args = parser.parse_args() + if args.prompt: + prompt = args.prompt print(prompt) - main(prompt=prompt, generate_folder_path=args.generate_folder_path, debug=args.debug) + _main(prompt=prompt, generate_folder_path=args.generate_folder_path, debug=args.debug) + +if __name__ == "__main__": + main() diff --git a/smol_dev/prompts.py b/src/smol_dev/prompts.py similarity index 100% rename from smol_dev/prompts.py rename to src/smol_dev/prompts.py diff --git a/smol_dev/utils.py b/src/smol_dev/utils.py similarity index 100% rename from smol_dev/utils.py rename to src/smol_dev/utils.py