Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9b33f67

Browse files
committed
docs: enhance README and documentation across modules
- Updated README.md to include license badges, project description, and detailed interactive workflows for project generation and feature addition.- Improved docstrings in main.py, __init__.py, and various utility modules to provide clearer descriptions of functionality and usage.- Enhanced command execution and file operations documentation for better understanding of safety checks and operations.This update improves the overall clarity and usability of the documentation for new users and contributors.
1 parenta1127b1 commit9b33f67

File tree

10 files changed

+291
-88
lines changed

10 files changed

+291
-88
lines changed

‎README.md

Lines changed: 105 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
A powerful command-line tool that leverages artificial intelligence to generate complete project structures, add new features to existing projects, and streamline your development workflow.
44

5+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6+
[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
7+
8+
>**Python CLI AI Coder** helps developers quickly bootstrap new projects with well-structured codebases, proper configuration files, and best practices already implemented. Save hours of setup time and focus on building your application's unique features.
9+
510
##✨ Features
611

712
-**Project Generation**: Create complete project structures for various frameworks and languages
@@ -84,23 +89,68 @@ Run the project generator:
8489
python main.py
8590
```
8691

87-
Follow the interactive prompts to:
92+
<details>
93+
<summary><b>Interactive Workflow (click to expand)</b></summary>
94+
95+
1.**Select a project type** from the available options:
96+
97+
- Python
98+
- JavaScript
99+
- TypeScript
100+
- React + Vite (TypeScript or JavaScript)
101+
- Express (TypeScript or JavaScript)
102+
- Custom (specify your own)
103+
104+
2.**Enter a project name** that will be used for the project directory and in generated files
105+
106+
3.**Choose a directory** to store the project (defaults to`projects/your_project_name`)
107+
108+
4.**Provide a project description** that will be used to generate appropriate code and documentation
88109

89-
1. Select a project type
90-
2. Enter a project name
91-
3. Choose a directory to store the project
92-
4. Provide a project description
93-
5. Select optional features (Git, Tests, GitHub Actions, Documentation)
110+
5.**Select optional features**:
94111

95-
The tool will generate a complete project structure based on your specifications.
112+
- 🔀**Git Initialization**: Initialize a Git repository with appropriate .gitignore
113+
- 🚨**Testing Framework**: Add testing framework with sample tests
114+
- 🛠️**GitHub Actions**: Set up CI/CD workflows
115+
- 📝**Documentation**: Create documentation structure and templates
116+
117+
6.**Confirm and generate** your project structure
118+
119+
7.**View the summary** of generated files and directories
120+
</details>
121+
122+
The tool will generate a complete project structure based on your specifications, with proper file organization, configuration files, and boilerplate code.
96123

97124
###Add Features to an Existing Project
98125

99-
After generating a project, you can add new features:
126+
After generating a project, you can add new features to extend its functionality:
127+
128+
```bash
129+
# After project generation completes, you'll be prompted to add features
130+
# Or run the tool again and navigate to the existing project directory
131+
python main.py
132+
```
133+
134+
<details>
135+
<summary><b>Feature Addition Workflow (click to expand)</b></summary>
136+
137+
1.**Select "Yes"** when asked if you want to add features to the project
138+
139+
2.**Describe the feature** you want to add in natural language, for example:
140+
141+
- "Add a user authentication system with login and registration"
142+
- "Create a database connection module with SQLAlchemy"
143+
- "Add a REST API endpoint for user profiles"
144+
- "Implement a logging system with rotating file handlers"
145+
146+
3.**Watch as the tool analyzes** your project structure and implements the feature
147+
148+
4.**Review the changes** made to your project files
149+
150+
5.**Optionally add more features** by selecting "Yes" when prompted
151+
</details>
100152

101-
1. Select "Yes" when asked if you want to add features
102-
2. Describe the feature you want to add
103-
3. The tool will analyze your project and implement the new feature
153+
The tool will intelligently analyze your existing project structure and implement the requested feature with appropriate code, tests, and documentation updates.
104154

105155
##⚙️ Configuration Options
106156

@@ -111,41 +161,62 @@ After generating a project, you can add new features:
111161
-**GitHub Actions**: Set up CI/CD workflows
112162
-**Documentation**: Create documentation structure and templates
113163

114-
###Tool Calls
164+
###Technical Implementation
115165

116-
TheProjectGenerator class defines tools that AI Coder can call:
166+
ThePython CLI AI Coder uses a tool-based approach to generate project structures:
117167

118-
-`read_file`: Read the contents of a file
119-
-`get_file_metadata`: Get metadata for a file
120-
-`list_directory_contents`: List files and directories
121-
-`write_to_file`: Write content to a file
122-
-`create_directory`: Create a new directory
123-
-`run_command`: Execute a shell command
168+
<details>
169+
<summary><b>AI Tool System (click to expand)</b></summary>
170+
171+
The`ProjectGenerator` class defines a set of tools that the AI model can call to manipulate files and directories:
172+
173+
| Tool| Description| Usage|
174+
| -------------------------| ---------------------------| ------------------------------------|
175+
|`read_file`| Read the contents of a file| Used to analyze existing files|
176+
|`get_file_metadata`| Get metadata for a file| Used to check file properties|
177+
|`list_directory_contents`| List files and directories| Used to understand project structure|
178+
|`write_to_file`| Write content to a file| Used to create or update files|
179+
|`create_directory`| Create a new directory| Used to create folder structure|
180+
|`run_command`| Execute a shell command| Used to run initialization commands|
181+
182+
These tools are exposed to the AI model through a function-calling interface, allowing it to manipulate the filesystem in a controlled and secure manner.
183+
184+
</details>
185+
186+
This architecture enables the AI to generate complex project structures while maintaining security and control over the operations performed.
124187

125188
##How It Works
126189

127-
1.**Initialization**:
190+
<imgsrc="https://via.placeholder.com/800x400.png?text=Python+CLI+AI+Coder+Workflow"alt="Python CLI AI Coder Workflow Diagram"width="100%">
191+
192+
1.**Initialization** 🚀
128193

129194
- The tool loads the OpenAI API key from the`.env` file
130-
- It initializes the ProjectGenerator class with this key
195+
- It initializes the`ProjectGenerator` class with this key
196+
- The system prepares the available tools for AI to use
197+
198+
2.**User Input Collection** 💬
131199

132-
2.**User Input**:
200+
- The CLI presents an interactive interface with colorful prompts
201+
- Users select project type, name, location, and description
202+
- Users customize project features through a visual selection interface
203+
- All selections are validated and confirmed before proceeding
133204

134-
- The CLI collects project specifications from the user
135-
- Users select project type, name, description, and features
205+
3.**Project Generation Process** ⚙️
136206

137-
3.**Project Generation**:
207+
- The system crafts detailed prompts for the AI model with project specifications
208+
- The AI model (GPT-4o) analyzes the requirements and plans the project structure
209+
- The AI makes tool calls to create directories, files, and execute commands
210+
- The system executes these calls and provides real-time visual feedback
211+
- A comprehensive project structure is built according to best practices
138212

139-
- The tool sends prompts to GPT-4o with project specifications
140-
- GPT-4o responds with tool calls to create files and directories
141-
- The tool executes these calls to build the project structure
142-
- Progress is displayed in real-time
213+
4.**Feature Addition Capability** 🔍
143214

144-
4.**Feature Addition**:
145-
-Users can describe features to addto thegenerated project
146-
- Thetool analyzes theproject structure
147-
-AI generates codetoimplement thefeature
148-
-The tool integrates the new code into theproject
215+
- Users can request new features in natural language
216+
-The AI analyzes the existing project structuretounderstandthecodebase
217+
- Thesystem determines thenecessary changes to implement the feature
218+
-Files are modified or createdtoadd therequested functionality
219+
-Tests and documentation are updated to reflect thenew features
149220

150221
##📦 Dependencies
151222

‎main.py

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
1-
"""Entry point for theCode Project Generator.
1+
"""Entry point for thePython CLI AI Coder.
22
3-
NOTE: This application requires a virtual environment.
4-
Before running, make sure to activate the virtual environment:
3+
This is the main entry point for the application that generates complete project
4+
structures based on user specifications. The tool provides an interactive CLI
5+
interface for selecting project types, features, and configurations.
56
6-
source .venv/bin/activate # On Unix/Mac
7-
.venv/Scripts/activate # On Windows
7+
Requirements:
8+
- Python 3.8+
9+
- OpenAI API key (set in .env file)
10+
- Virtual environment (recommended)
811
9-
Then run the application with:
12+
Before running:
13+
1. Make sure to activate the virtual environment:
14+
source .venv/bin/activate # On Unix/Mac
15+
.venv\Scripts\activate # On Windows
16+
17+
2. Ensure your .env file contains your OpenAI API key:
18+
OPENAI_API_KEY=your_api_key_here
19+
20+
Usage:
1021
python main.py
1122
"""
1223
importos
@@ -16,8 +27,12 @@
1627
# Load environment variables from .env file
1728
load_dotenv()
1829

19-
# Check if running in virtual environment
2030
defis_venv():
31+
"""Check if the application is running in a virtual environment.
32+
33+
Returns:
34+
bool: True if running in a virtual environment, False otherwise
35+
"""
2136
returnhasattr(sys,'real_prefix')or \
2237
(hasattr(sys,'base_prefix')andsys.base_prefix!=sys.prefix)
2338

‎src/__init__.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
11
"""
2-
Code Project Generator package.
2+
Python CLI AI Coder - Main package.
3+
4+
This is the main package for the Python CLI AI Coder application, which generates
5+
complete project structures based on user specifications using AI assistance.
6+
7+
The package is organized into the following subpackages and modules:
8+
9+
- cli: Command-line interface implementation
10+
- core: Core functionality for project generation
11+
- utils: Utility functions for file operations and command execution
12+
13+
The application uses OpenAI's GPT models to generate project structures and
14+
provides a rich, interactive command-line interface for user interaction.
315
"""

‎src/cli/__init__.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
11
"""
2-
Command-line interface for the project generator.
2+
Command-line interface package for the Python CLI AI Coder.
3+
4+
This package contains the CLI implementation for the project generator,
5+
providing a rich, interactive interface for users to specify project
6+
requirements and visualize the generation process.
7+
8+
The CLI uses the Rich library to create a visually appealing interface
9+
with features such as:
10+
- Colorful text and formatting
11+
- Progress bars and spinners
12+
- Tables and panels
13+
- Interactive prompts
14+
15+
The main entry point for the CLI is the `main()` function in the `main` module.
316
"""

‎src/cli/main.py

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
"""
2-
Command-line interface for the project generator.
2+
Command-line interface module for the Python CLI AI Coder.
3+
4+
This module provides the interactive CLI interface for the project generator,
5+
allowing users to specify project types, names, descriptions, and features.
6+
It uses the Rich library to create a visually appealing interface with
7+
colorful text, progress bars, tables, and interactive prompts.
8+
9+
The main function in this module is `main()`, which is the entry point for
10+
the CLI interface. It handles user input, displays progress, and calls the
11+
ProjectGenerator to generate project structures.
12+
13+
Features:
14+
- Interactive project type selection
15+
- Project feature customization (Git, Tests, GitHub Actions, Documentation)
16+
- Visual progress tracking with spinners and progress bars
17+
- Detailed project summary display
18+
- Feature addition to existing projects
319
"""
420
importos
521
importjson
@@ -96,7 +112,22 @@
96112

97113
defmain():
98114
"""
99-
Main function that takes input from the terminal and runs the generator.
115+
Main entry point for the CLI interface.
116+
117+
This function handles the complete workflow of the project generator:
118+
1. Collects user input for project specifications
119+
2. Sets up the project directory
120+
3. Initializes the ProjectGenerator
121+
4. Displays progress during project generation
122+
5. Shows a summary of the generated project
123+
6. Optionally adds features to the existing project
124+
125+
The function uses Rich library components to create a visually appealing
126+
and interactive interface with colorful text, tables, progress bars, and
127+
status indicators.
128+
129+
Returns:
130+
None
100131
"""
101132
# Display a simpler header
102133
console.print("\n[bold cyan]GPT-4o PROJECT GENERATOR[/bold cyan]")

‎src/core/__init__.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
11
"""
2-
Core functionality for project generation.
2+
Core functionality package for the Python CLI AI Coder.
3+
4+
This package contains the core components responsible for project generation,
5+
including the ProjectGenerator class that interfaces with OpenAI's API to
6+
generate project structures based on user specifications.
7+
8+
The core functionality includes:
9+
- Project structure generation
10+
- README generation
11+
- Feature addition to existing projects
12+
- Tool call handling for AI-driven file and directory operations
13+
14+
The main class in this package is `ProjectGenerator` in the `project_generator` module.
315
"""

‎src/core/project_generator.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
"""
2-
Project generator core functionality.
2+
Project Generator core module for the Python CLI AI Coder.
3+
4+
This module contains the ProjectGenerator class, which is the central component
5+
of the application responsible for generating project structures using OpenAI's
6+
GPT models. The class provides methods for:
7+
8+
1. Generating complete project structures based on user specifications
9+
2. Adding new features to existing projects
10+
3. Generating project documentation (README.md)
11+
4. Handling AI tool calls for file and directory operations
12+
13+
The ProjectGenerator interfaces with OpenAI's API and uses a set of tools
14+
to create files, directories, and execute commands as directed by the AI model.
315
"""
416
importos
517
importjson
@@ -18,10 +30,20 @@
1830
classProjectGenerator:
1931
def__init__(self,api_key):
2032
"""
21-
Initializes the project generator with OpenAI API key.
33+
Initialize the ProjectGenerator with an OpenAI API key.
34+
35+
This constructor sets up the OpenAI client and defines the available tools
36+
that can be used by the AI model to generate project structures. These tools
37+
include file operations, directory management, and command execution.
2238
2339
Args:
24-
api_key (str): OpenAI API key
40+
api_key (str): OpenAI API key for authentication with the OpenAI service
41+
42+
Attributes:
43+
client (OpenAI): Initialized OpenAI client
44+
available_tools (list): List of tools available to the AI model
45+
messages (list): Conversation history for the AI model
46+
project_name (str): Name of the current project being generated
2547
"""
2648
self.client=OpenAI(api_key=api_key)
2749
self.available_tools= [

‎src/utils/__init__.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
11
"""
2-
Utility functions for file operations and command execution.
2+
Utility package for the Python CLI AI Coder.
3+
4+
This package contains utility modules that provide essential functionality
5+
for the project generator:
6+
7+
- file_operations: Functions for file and directory management
8+
- command_operations: Functions for safe command execution
9+
10+
These utilities handle the low-level operations needed by the project generator
11+
to create and manipulate files, directories, and execute commands safely.
312
"""

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp