greadme 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
greadme-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Vinicius Paulino
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
greadme-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,296 @@
1
+ Metadata-Version: 2.4
2
+ Name: greadme
3
+ Version: 0.1.0
4
+ Summary: Generate README files using AI
5
+ License: MIT
6
+ License-File: LICENSE
7
+ Keywords: readme,ai,generator
8
+ Author: Vinicius de Freitas Paulino
9
+ Author-email: vinifreitaspaulino@gmail.com
10
+ Requires-Python: >=3.11,<4.0
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Programming Language :: Python :: 3.14
18
+ Requires-Dist: google-genai (>=1.0.0,<2.0.0)
19
+ Project-URL: Documentation, https://github.com/vinifreitaspaulino/readme-generator#readme
20
+ Project-URL: Repository, https://github.com/vinifreitaspaulino/readme-generator
21
+ Description-Content-Type: text/markdown
22
+
23
+ # README Generator
24
+
25
+ > CLI tool that reads your project structure, dependencies and source files, then writes the README for you, using AI models.
26
+
27
+ ## Badges
28
+
29
+ [![Project Status: Active](https://img.shields.io/badge/Status-Active-brightgreen?style=flat-square)](https://github.com/vinifreitaspaulino/readme-generator)
30
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)](https://github.com/vinifreitaspaulino/readme-generator/blob/main/LICENSE)
31
+ [![Last Commit](https://img.shields.io/github/last-commit/vinifreitaspaulino/readme-generator?style=flat-square)](https://github.com/vinifreitaspaulino/readme-generator/commits/main)
32
+ [![Top Language](https://img.shields.io/github/languages/top/vinifreitaspaulino/readme-generator?style=flat-square)](https://github.com/vinifreitaspaulino/readme-generator)
33
+
34
+ ## Table of Contents
35
+
36
+ - [README Generator](#readme-generator)
37
+ - [Badges](#badges)
38
+ - [Table of Contents](#table-of-contents)
39
+ - [Overview](#overview)
40
+ - [Project Demonstration](#project-demonstration)
41
+ - [Key Features](#key-features)
42
+ - [Technical Stack](#technical-stack)
43
+ - [Architecture](#architecture)
44
+ - [Directory Structure](#directory-structure)
45
+ - [Data Flow](#data-flow)
46
+ - [System Components](#system-components)
47
+ - [Getting Started](#getting-started)
48
+ - [Prerequisites](#prerequisites)
49
+ - [Installation](#installation)
50
+ - [Configuration](#configuration)
51
+ - [Usage](#usage)
52
+ - [Customization Options](#customization-options)
53
+ - [Configuration File Options](#configuration-file-options)
54
+ - [Command-Line Arguments (`greadme gen` subcommand)](#command-line-arguments-greadme-gen-subcommand)
55
+ - [Author](#author)
56
+ - [License](#license)
57
+
58
+ ## Overview
59
+
60
+ The `README Generator` addresses the common challenge faced by developers in creating and maintaining detailed, accurate `README.md` files for their projects. Manually documenting a project's purpose, architecture, dependencies, and usage can be a time-consuming and often overlooked task. This tool automates the process by leveraging artificial intelligence to analyze a project's codebase and infer all necessary details, thereby enabling developers and open-source maintainers to quickly generate high-quality documentation.
61
+
62
+ At its core, the project operates by scanning a target directory to understand its structure, programming language, and dependencies. It then compiles this contextual information into a prompt, which is subsequently sent to a large language model (Google Gemini). The AI processes the prompt and generates a comprehensive `README.md` tailored to the project. The tool also incorporates configurable settings for the AI model, API keys, and output language, ensuring flexibility and ease of use.
63
+
64
+ The `README Generator` stands out by providing an intelligent, automated solution to documentation generation, significantly reducing the manual effort involved. Its ability to infer crucial project details directly from the source code, coupled with support for multiple output languages and integration with `.gitignore` rules, ensures that the generated documentation is not only rich in detail but also relevant and concise. This approach minimizes setup time and maximizes productivity for developers looking to present their projects professionally.
65
+
66
+ ### Project Demonstration
67
+
68
+
69
+ ## Key Features
70
+
71
+ * **AI-Powered Generation**: Automatically generates detailed `README.md` files by leveraging a configured AI model (Google Gemini).
72
+ * **Intelligent Project Scanning**: Detects project type, extracts file structure, identifies dependencies, and reads relevant source file content.
73
+ * **Configurable Settings**: Supports persistent configuration for AI API keys, default README language (English/Portuguese), and GitHub username.
74
+ * **Command-Line Interface**: Provides an intuitive CLI for initiating README generation and managing application settings.
75
+ * **`.gitignore` Integration**: Respects `.gitignore` rules during project scanning to exclude irrelevant files and directories from analysis.
76
+ * **Multilingual Output**: Generates `README.md` files in either English (`en`) or Portuguese (`pt`) based on user preference.
77
+
78
+ ## Technical Stack
79
+
80
+ * **Programming Language**: Python 3.11+
81
+ * **Frameworks and Libraries**:
82
+ * `argparse` (Python standard library for command-line argument parsing)
83
+ * `pathlib` (Python standard library for object-oriented filesystem paths)
84
+ * `tomllib` (Python standard library for parsing TOML files, used for configuration)
85
+ * `json` (Python standard library for JSON data handling, used for Node.js dependency scanning)
86
+ * `xml.etree.ElementTree` (Python standard library for XML parsing, used for Java dependency scanning)
87
+ * Google Gemini API (For AI interaction)
88
+ * **Data Persistence**: Local `.toml` configuration file (`config.toml`)
89
+ * **Build and Deployment Tools**: Standard Python packaging and execution mechanisms.
90
+ * **Other relevant technologies**: File system interaction for project scanning and output writing.
91
+
92
+ ## Architecture
93
+
94
+ The `README Generator` is designed with a modular architecture, separating concerns into distinct components for project scanning, configuration management, AI prompting, and command-line interface handling.
95
+
96
+ ### Directory Structure
97
+
98
+ ```text
99
+ greadme/ # Main application package
100
+ cli.py # Command-Line Interface: entry point, argument parsing, orchestration
101
+ config.py # Configuration Manager: handles loading, saving, and managing application settings
102
+ scanner.py # Project Scanner: analyzes project directory, infers type, structure, dependencies
103
+ builder.py # Prompt Builder: constructs the AI prompt from scanned project context
104
+ ai.py # AI Interface: communicates with the Google Gemini API
105
+ templates/ # Templates for AI prompts
106
+ en.md # English prompt template
107
+ pt.md # Portuguese prompt template
108
+ ```
109
+
110
+ ### Data Flow
111
+
112
+ The following sequence diagram illustrates the primary data flow when generating a `README.md` file:
113
+
114
+ ```mermaid
115
+ sequenceDiagram
116
+ autonumber
117
+ participant User
118
+ participant CLI(greadme)
119
+ participant ConfigManager
120
+ participant ProjectScanner
121
+ participant PromptBuilder
122
+ participant AIModel
123
+ participant FileSystem
124
+
125
+ User->>CLI(greadme): Initiates README generation via 'greadme gen' command
126
+ CLI(greadme)->>ConfigManager: Loads persistent configuration (api_key, lang, github_user)
127
+ ConfigManager-->>CLI(greadme): Returns application settings
128
+ CLI(greadme)->>CLI(greadme): Overrides config with command-line arguments if provided
129
+ CLI(greadme)->>ProjectScanner: Scans the specified project path
130
+ ProjectScanner->>ProjectScanner: Loads and applies '.gitignore' rules
131
+ User->>ProjectScanner: Project name, repository name, and description (obtained directly from the user)
132
+ ProjectScanner->>ProjectScanner: Gathers file tree, dependencies, and content of relevant files
133
+ ProjectScanner-->>CLI(greadme): Returns comprehensive project context
134
+ CLI(greadme)->>PromptBuilder: Builds an AI prompt using the project context and desired language
135
+ PromptBuilder-->>CLI(greadme): Returns the structured AI prompt
136
+ CLI(greadme)->>AIModel: Sends the AI prompt, configured model, and API key to the AI service
137
+ AIModel-->>CLI(greadme): Returns the generated README content
138
+ CLI(greadme)->>FileSystem: Writes the generated content to 'README.md' or specified output path
139
+ FileSystem-->>CLI(greadme): Confirms file save operation
140
+ CLI(greadme)-->>User: Displays success or error message
141
+ ```
142
+
143
+ ### System Components
144
+
145
+ * **CLI Module (`greadme.cli`):** Serves as the primary entry point for the application. It handles command-line argument parsing using `argparse` and orchestrates the workflow by coordinating calls to other modules for scanning, configuration, and AI interaction. It defines the `gen` and `config` subcommands.
146
+ * **Configuration Module (`greadme.config`):** Manages application-wide settings such as the Gemini API key, preferred language, and GitHub username. It loads default values, persists user-defined settings to a `config.toml` file (located in `~/.config/greadme/` or `%APPDATA%\greadme\`), and ensures settings are applied consistently.
147
+ * **Scanner Module (`greadme.scanner`):** This is the intelligence gathering component. It recursively traverses a target project directory, identifies the project's primary language and type, extracts a hierarchical file structure, determines project dependencies by parsing common manifest files (`pyproject.toml`, `requirements.txt`, `package.json`, `Cargo.toml`, `pom.xml`, etc.), and reads the contents of key source files. It intelligently ignores common development artifacts and respects `.gitignore` rules.
148
+ * **Builder Module (`greadme.builder`):** Responsible for transforming the structured project context obtained from the `Scanner` into a coherent and effective prompt for the AI model. This module likely uses templates (e.g., `en.md`, `pt.md`) to guide the AI in generating a well-structured and informative `README.md`.
149
+ * **AI Module (`greadme.ai`):** Acts as the bridge between the application and the external AI service (Google Gemini). It encapsulates the logic for sending prompts, handling API requests, and return the AI responses.
150
+
151
+ ## Getting Started
152
+
153
+ ### Prerequisites
154
+ - Python 3.11+
155
+ - Google Gemini API key — get one at [Google AI Studio](https://aistudio.google.com)
156
+
157
+ ### Installation
158
+
159
+ Install via pip:
160
+ ```bash
161
+ pip install greadme
162
+ ```
163
+
164
+ Or with pipx (recommended for global CLI usage):
165
+ ```bash
166
+ pipx install greadme
167
+ ```
168
+
169
+ ### Configuration
170
+
171
+ Before generating your first README, you need to configure your API key and other preferences. Configuration settings are stored in a `config.toml` file, typically located at:
172
+ * **Linux/macOS**: `~/.config/greadme/config.toml`
173
+ * **Windows**: `%APPDATA%\greadme\config.toml`
174
+
175
+ You can manage these settings directly via the command-line interface:
176
+
177
+ * **`ai.api_key`**: Your Google Gemini API key.
178
+ * Default: `""` (empty string, causing an error if not set)
179
+ * Example:
180
+ ```bash
181
+ greadme config set ai.api_key YOUR_GEMINI_API_KEY
182
+ ```
183
+
184
+ * **`ai.model`**: The specific Google Gemini model to use for generation.
185
+ * Default: `"gemini-2.5-flash"`
186
+ * Example:
187
+ ```bash
188
+ greadme config set ai.model gemini-2.0-flash-lite
189
+ ```
190
+
191
+ * **`general.lang`**: The default language for the generated README (`en` for English, `pt` for Portuguese).
192
+ * Default: `"en"`
193
+ * Example:
194
+ ```bash
195
+ greadme config set general.lang pt
196
+ ```
197
+
198
+ * **`general.github_user`**: Your GitHub username, used for generating relevant links and information in the README.
199
+ * Default: `""` (empty string, causing an error if not set for some features)
200
+ * Example:
201
+ ```bash
202
+ greadme config set general.github_user vinifreitaspaulino
203
+ ```
204
+
205
+ To view your current configuration:
206
+ ```bash
207
+ greadme config show
208
+ ```
209
+
210
+ ## Usage
211
+
212
+ The `README Generator` is primarily controlled via its command-line interface. Once installed and configured, you can generate READMEs for your projects or manage settings.
213
+
214
+ To generate a `README.md` for a project:
215
+
216
+ ```bash
217
+ greadme gen <project_path> [--output <output_path>] [--lang <language>] [--verbose]
218
+ ```
219
+ or without `gen`:
220
+ ```bash
221
+ greadme <project_path> [--output <output_path>] [--lang <language>] [--verbose]
222
+ ```
223
+
224
+ **Examples**:
225
+
226
+ 1. **Generate a README for the current directory using default settings (English, default AI model, configured API key, default output path)**:
227
+ ```bash
228
+ greadme .
229
+ ```
230
+
231
+ 2. **Generate a README for a specific project path, outputting it in Portuguese**:
232
+ ```bash
233
+ greadme ~/my_python_project --lang pt
234
+ ```
235
+
236
+ 3. **Generate a README for a project, saving it to a custom location and enabling verbose output**:
237
+ ```bash
238
+ greadme /path/to/the/project --output /path/to/output/folder --verbose
239
+ ```
240
+
241
+ 4. **Override the API key and AI model directly for a single generation command**:
242
+ ```bash
243
+ greadme . --api-key ANOTHER_KEY --model gemini-3-flash-preview
244
+ ```
245
+
246
+ ## Customization Options
247
+
248
+ The `README Generator` offers several options for customizing its behavior, both through persistent configuration and command-line arguments.
249
+
250
+ ### Configuration File Options
251
+
252
+ These options are stored in the `config.toml` file and affect all subsequent `greadme` commands unless overridden by command-line arguments.
253
+
254
+ | Key | Type | Default | Description |
255
+ | :------------------ | :----- | :----------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
256
+ | `general.lang` | String | `"en"` | Sets the default language for generated `README.md` files. Supported values are `"en"` (English) and `"pt"` (Portuguese). |
257
+ | `general.github_user` | String | `""` | Your GitHub username. This is used by the AI to infer author details and construct GitHub-related links within the README. Essential for the badge links. |
258
+ | `ai.api_key` | String | `""` | Your API key for accessing the Google Gemini AI service. This is mandatory for the tool to function and generate READMEs. |
259
+ | `ai.model` | String | `"gemini-2.5-flash"` | Specifies the particular Google Gemini model to be used for AI generation. Different models may offer varying performance, cost, and output quality. |
260
+
261
+ **Example `config.toml` snippet:**
262
+
263
+ ```toml
264
+ [general]
265
+ lang = "en"
266
+ github_user = "vinifreitaspaulino"
267
+
268
+ [ai]
269
+ api_key = "YOUR_GEMINI_API_KEY_HERE"
270
+ model = "gemini-2.5-flash"
271
+ ```
272
+
273
+ ### Command-Line Arguments (`greadme gen` subcommand)
274
+
275
+ These arguments allow for temporary overrides of configured settings or provide specific parameters for a single `gen` operation. You can also omit `gen` and pass the path, this is also understood as generating a README.
276
+
277
+ | Argument | Type | Default (or config) | Description |
278
+ | :---------------- | :----- | :--------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
279
+ | `path` | Path | *Required* | The filesystem path to the project directory for which the README should be generated. |
280
+ | `--output`, `-o` | Path | `<project_path>/README.md` | Specifies the full output path, including the filename, for the generated `README.md`. If not provided, it defaults to `README.md` in the project root. |
281
+ | `--verbose`, `-v` | Flag | `False` | Activates verbose logging, displaying detailed progress messages during the scanning, prompt building, and AI call phases. |
282
+ | `--lang`, `-l` | String | `config["general"]["lang"]` | Overrides the default language for the generated README for this specific run. Choices are `"pt"` (Portuguese) or `"en"` (English). |
283
+ | `--api-key` | String | `config["ai"]["api_key"]` | Temporarily overrides the `ai.api_key` configured in `config.toml` for the current generation command. Useful for testing or managing multiple keys. |
284
+ | `--model` | String | `config["ai"]["model"]` | Temporarily overrides the `ai.model` configured in `config.toml` for the current generation command. Allows for on-the-fly switching between AI models. |
285
+ | `--github_user` | String | `config["general"]["github_user"]` | Temporarily overrides the `general.github_user` configured in `config.toml` for the current generation command. |
286
+
287
+ These options collectively provide fine-grained control over how `README Generator` operates, allowing users to tailor the generation process to their specific needs and project contexts.
288
+
289
+ ## Author
290
+
291
+ **Vinicius de Freitas Paulino**
292
+ - **GitHub:** [@vinifreitaspaulino](https://github.com/vinifreitaspaulino)
293
+
294
+ ## License
295
+
296
+ This project is licensed under the MIT License.
@@ -0,0 +1,274 @@
1
+ # README Generator
2
+
3
+ > CLI tool that reads your project structure, dependencies and source files, then writes the README for you, using AI models.
4
+
5
+ ## Badges
6
+
7
+ [![Project Status: Active](https://img.shields.io/badge/Status-Active-brightgreen?style=flat-square)](https://github.com/vinifreitaspaulino/readme-generator)
8
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)](https://github.com/vinifreitaspaulino/readme-generator/blob/main/LICENSE)
9
+ [![Last Commit](https://img.shields.io/github/last-commit/vinifreitaspaulino/readme-generator?style=flat-square)](https://github.com/vinifreitaspaulino/readme-generator/commits/main)
10
+ [![Top Language](https://img.shields.io/github/languages/top/vinifreitaspaulino/readme-generator?style=flat-square)](https://github.com/vinifreitaspaulino/readme-generator)
11
+
12
+ ## Table of Contents
13
+
14
+ - [README Generator](#readme-generator)
15
+ - [Badges](#badges)
16
+ - [Table of Contents](#table-of-contents)
17
+ - [Overview](#overview)
18
+ - [Project Demonstration](#project-demonstration)
19
+ - [Key Features](#key-features)
20
+ - [Technical Stack](#technical-stack)
21
+ - [Architecture](#architecture)
22
+ - [Directory Structure](#directory-structure)
23
+ - [Data Flow](#data-flow)
24
+ - [System Components](#system-components)
25
+ - [Getting Started](#getting-started)
26
+ - [Prerequisites](#prerequisites)
27
+ - [Installation](#installation)
28
+ - [Configuration](#configuration)
29
+ - [Usage](#usage)
30
+ - [Customization Options](#customization-options)
31
+ - [Configuration File Options](#configuration-file-options)
32
+ - [Command-Line Arguments (`greadme gen` subcommand)](#command-line-arguments-greadme-gen-subcommand)
33
+ - [Author](#author)
34
+ - [License](#license)
35
+
36
+ ## Overview
37
+
38
+ The `README Generator` addresses the common challenge faced by developers in creating and maintaining detailed, accurate `README.md` files for their projects. Manually documenting a project's purpose, architecture, dependencies, and usage can be a time-consuming and often overlooked task. This tool automates the process by leveraging artificial intelligence to analyze a project's codebase and infer all necessary details, thereby enabling developers and open-source maintainers to quickly generate high-quality documentation.
39
+
40
+ At its core, the project operates by scanning a target directory to understand its structure, programming language, and dependencies. It then compiles this contextual information into a prompt, which is subsequently sent to a large language model (Google Gemini). The AI processes the prompt and generates a comprehensive `README.md` tailored to the project. The tool also incorporates configurable settings for the AI model, API keys, and output language, ensuring flexibility and ease of use.
41
+
42
+ The `README Generator` stands out by providing an intelligent, automated solution to documentation generation, significantly reducing the manual effort involved. Its ability to infer crucial project details directly from the source code, coupled with support for multiple output languages and integration with `.gitignore` rules, ensures that the generated documentation is not only rich in detail but also relevant and concise. This approach minimizes setup time and maximizes productivity for developers looking to present their projects professionally.
43
+
44
+ ### Project Demonstration
45
+
46
+
47
+ ## Key Features
48
+
49
+ * **AI-Powered Generation**: Automatically generates detailed `README.md` files by leveraging a configured AI model (Google Gemini).
50
+ * **Intelligent Project Scanning**: Detects project type, extracts file structure, identifies dependencies, and reads relevant source file content.
51
+ * **Configurable Settings**: Supports persistent configuration for AI API keys, default README language (English/Portuguese), and GitHub username.
52
+ * **Command-Line Interface**: Provides an intuitive CLI for initiating README generation and managing application settings.
53
+ * **`.gitignore` Integration**: Respects `.gitignore` rules during project scanning to exclude irrelevant files and directories from analysis.
54
+ * **Multilingual Output**: Generates `README.md` files in either English (`en`) or Portuguese (`pt`) based on user preference.
55
+
56
+ ## Technical Stack
57
+
58
+ * **Programming Language**: Python 3.11+
59
+ * **Frameworks and Libraries**:
60
+ * `argparse` (Python standard library for command-line argument parsing)
61
+ * `pathlib` (Python standard library for object-oriented filesystem paths)
62
+ * `tomllib` (Python standard library for parsing TOML files, used for configuration)
63
+ * `json` (Python standard library for JSON data handling, used for Node.js dependency scanning)
64
+ * `xml.etree.ElementTree` (Python standard library for XML parsing, used for Java dependency scanning)
65
+ * Google Gemini API (For AI interaction)
66
+ * **Data Persistence**: Local `.toml` configuration file (`config.toml`)
67
+ * **Build and Deployment Tools**: Standard Python packaging and execution mechanisms.
68
+ * **Other relevant technologies**: File system interaction for project scanning and output writing.
69
+
70
+ ## Architecture
71
+
72
+ The `README Generator` is designed with a modular architecture, separating concerns into distinct components for project scanning, configuration management, AI prompting, and command-line interface handling.
73
+
74
+ ### Directory Structure
75
+
76
+ ```text
77
+ greadme/ # Main application package
78
+ cli.py # Command-Line Interface: entry point, argument parsing, orchestration
79
+ config.py # Configuration Manager: handles loading, saving, and managing application settings
80
+ scanner.py # Project Scanner: analyzes project directory, infers type, structure, dependencies
81
+ builder.py # Prompt Builder: constructs the AI prompt from scanned project context
82
+ ai.py # AI Interface: communicates with the Google Gemini API
83
+ templates/ # Templates for AI prompts
84
+ en.md # English prompt template
85
+ pt.md # Portuguese prompt template
86
+ ```
87
+
88
+ ### Data Flow
89
+
90
+ The following sequence diagram illustrates the primary data flow when generating a `README.md` file:
91
+
92
+ ```mermaid
93
+ sequenceDiagram
94
+ autonumber
95
+ participant User
96
+ participant CLI(greadme)
97
+ participant ConfigManager
98
+ participant ProjectScanner
99
+ participant PromptBuilder
100
+ participant AIModel
101
+ participant FileSystem
102
+
103
+ User->>CLI(greadme): Initiates README generation via 'greadme gen' command
104
+ CLI(greadme)->>ConfigManager: Loads persistent configuration (api_key, lang, github_user)
105
+ ConfigManager-->>CLI(greadme): Returns application settings
106
+ CLI(greadme)->>CLI(greadme): Overrides config with command-line arguments if provided
107
+ CLI(greadme)->>ProjectScanner: Scans the specified project path
108
+ ProjectScanner->>ProjectScanner: Loads and applies '.gitignore' rules
109
+ User->>ProjectScanner: Project name, repository name, and description (obtained directly from the user)
110
+ ProjectScanner->>ProjectScanner: Gathers file tree, dependencies, and content of relevant files
111
+ ProjectScanner-->>CLI(greadme): Returns comprehensive project context
112
+ CLI(greadme)->>PromptBuilder: Builds an AI prompt using the project context and desired language
113
+ PromptBuilder-->>CLI(greadme): Returns the structured AI prompt
114
+ CLI(greadme)->>AIModel: Sends the AI prompt, configured model, and API key to the AI service
115
+ AIModel-->>CLI(greadme): Returns the generated README content
116
+ CLI(greadme)->>FileSystem: Writes the generated content to 'README.md' or specified output path
117
+ FileSystem-->>CLI(greadme): Confirms file save operation
118
+ CLI(greadme)-->>User: Displays success or error message
119
+ ```
120
+
121
+ ### System Components
122
+
123
+ * **CLI Module (`greadme.cli`):** Serves as the primary entry point for the application. It handles command-line argument parsing using `argparse` and orchestrates the workflow by coordinating calls to other modules for scanning, configuration, and AI interaction. It defines the `gen` and `config` subcommands.
124
+ * **Configuration Module (`greadme.config`):** Manages application-wide settings such as the Gemini API key, preferred language, and GitHub username. It loads default values, persists user-defined settings to a `config.toml` file (located in `~/.config/greadme/` or `%APPDATA%\greadme\`), and ensures settings are applied consistently.
125
+ * **Scanner Module (`greadme.scanner`):** This is the intelligence gathering component. It recursively traverses a target project directory, identifies the project's primary language and type, extracts a hierarchical file structure, determines project dependencies by parsing common manifest files (`pyproject.toml`, `requirements.txt`, `package.json`, `Cargo.toml`, `pom.xml`, etc.), and reads the contents of key source files. It intelligently ignores common development artifacts and respects `.gitignore` rules.
126
+ * **Builder Module (`greadme.builder`):** Responsible for transforming the structured project context obtained from the `Scanner` into a coherent and effective prompt for the AI model. This module likely uses templates (e.g., `en.md`, `pt.md`) to guide the AI in generating a well-structured and informative `README.md`.
127
+ * **AI Module (`greadme.ai`):** Acts as the bridge between the application and the external AI service (Google Gemini). It encapsulates the logic for sending prompts, handling API requests, and return the AI responses.
128
+
129
+ ## Getting Started
130
+
131
+ ### Prerequisites
132
+ - Python 3.11+
133
+ - Google Gemini API key — get one at [Google AI Studio](https://aistudio.google.com)
134
+
135
+ ### Installation
136
+
137
+ Install via pip:
138
+ ```bash
139
+ pip install greadme
140
+ ```
141
+
142
+ Or with pipx (recommended for global CLI usage):
143
+ ```bash
144
+ pipx install greadme
145
+ ```
146
+
147
+ ### Configuration
148
+
149
+ Before generating your first README, you need to configure your API key and other preferences. Configuration settings are stored in a `config.toml` file, typically located at:
150
+ * **Linux/macOS**: `~/.config/greadme/config.toml`
151
+ * **Windows**: `%APPDATA%\greadme\config.toml`
152
+
153
+ You can manage these settings directly via the command-line interface:
154
+
155
+ * **`ai.api_key`**: Your Google Gemini API key.
156
+ * Default: `""` (empty string, causing an error if not set)
157
+ * Example:
158
+ ```bash
159
+ greadme config set ai.api_key YOUR_GEMINI_API_KEY
160
+ ```
161
+
162
+ * **`ai.model`**: The specific Google Gemini model to use for generation.
163
+ * Default: `"gemini-2.5-flash"`
164
+ * Example:
165
+ ```bash
166
+ greadme config set ai.model gemini-2.0-flash-lite
167
+ ```
168
+
169
+ * **`general.lang`**: The default language for the generated README (`en` for English, `pt` for Portuguese).
170
+ * Default: `"en"`
171
+ * Example:
172
+ ```bash
173
+ greadme config set general.lang pt
174
+ ```
175
+
176
+ * **`general.github_user`**: Your GitHub username, used for generating relevant links and information in the README.
177
+ * Default: `""` (empty string, causing an error if not set for some features)
178
+ * Example:
179
+ ```bash
180
+ greadme config set general.github_user vinifreitaspaulino
181
+ ```
182
+
183
+ To view your current configuration:
184
+ ```bash
185
+ greadme config show
186
+ ```
187
+
188
+ ## Usage
189
+
190
+ The `README Generator` is primarily controlled via its command-line interface. Once installed and configured, you can generate READMEs for your projects or manage settings.
191
+
192
+ To generate a `README.md` for a project:
193
+
194
+ ```bash
195
+ greadme gen <project_path> [--output <output_path>] [--lang <language>] [--verbose]
196
+ ```
197
+ or without `gen`:
198
+ ```bash
199
+ greadme <project_path> [--output <output_path>] [--lang <language>] [--verbose]
200
+ ```
201
+
202
+ **Examples**:
203
+
204
+ 1. **Generate a README for the current directory using default settings (English, default AI model, configured API key, default output path)**:
205
+ ```bash
206
+ greadme .
207
+ ```
208
+
209
+ 2. **Generate a README for a specific project path, outputting it in Portuguese**:
210
+ ```bash
211
+ greadme ~/my_python_project --lang pt
212
+ ```
213
+
214
+ 3. **Generate a README for a project, saving it to a custom location and enabling verbose output**:
215
+ ```bash
216
+ greadme /path/to/the/project --output /path/to/output/folder --verbose
217
+ ```
218
+
219
+ 4. **Override the API key and AI model directly for a single generation command**:
220
+ ```bash
221
+ greadme . --api-key ANOTHER_KEY --model gemini-3-flash-preview
222
+ ```
223
+
224
+ ## Customization Options
225
+
226
+ The `README Generator` offers several options for customizing its behavior, both through persistent configuration and command-line arguments.
227
+
228
+ ### Configuration File Options
229
+
230
+ These options are stored in the `config.toml` file and affect all subsequent `greadme` commands unless overridden by command-line arguments.
231
+
232
+ | Key | Type | Default | Description |
233
+ | :------------------ | :----- | :----------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
234
+ | `general.lang` | String | `"en"` | Sets the default language for generated `README.md` files. Supported values are `"en"` (English) and `"pt"` (Portuguese). |
235
+ | `general.github_user` | String | `""` | Your GitHub username. This is used by the AI to infer author details and construct GitHub-related links within the README. Essential for the badge links. |
236
+ | `ai.api_key` | String | `""` | Your API key for accessing the Google Gemini AI service. This is mandatory for the tool to function and generate READMEs. |
237
+ | `ai.model` | String | `"gemini-2.5-flash"` | Specifies the particular Google Gemini model to be used for AI generation. Different models may offer varying performance, cost, and output quality. |
238
+
239
+ **Example `config.toml` snippet:**
240
+
241
+ ```toml
242
+ [general]
243
+ lang = "en"
244
+ github_user = "vinifreitaspaulino"
245
+
246
+ [ai]
247
+ api_key = "YOUR_GEMINI_API_KEY_HERE"
248
+ model = "gemini-2.5-flash"
249
+ ```
250
+
251
+ ### Command-Line Arguments (`greadme gen` subcommand)
252
+
253
+ These arguments allow for temporary overrides of configured settings or provide specific parameters for a single `gen` operation. You can also omit `gen` and pass the path, this is also understood as generating a README.
254
+
255
+ | Argument | Type | Default (or config) | Description |
256
+ | :---------------- | :----- | :--------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
257
+ | `path` | Path | *Required* | The filesystem path to the project directory for which the README should be generated. |
258
+ | `--output`, `-o` | Path | `<project_path>/README.md` | Specifies the full output path, including the filename, for the generated `README.md`. If not provided, it defaults to `README.md` in the project root. |
259
+ | `--verbose`, `-v` | Flag | `False` | Activates verbose logging, displaying detailed progress messages during the scanning, prompt building, and AI call phases. |
260
+ | `--lang`, `-l` | String | `config["general"]["lang"]` | Overrides the default language for the generated README for this specific run. Choices are `"pt"` (Portuguese) or `"en"` (English). |
261
+ | `--api-key` | String | `config["ai"]["api_key"]` | Temporarily overrides the `ai.api_key` configured in `config.toml` for the current generation command. Useful for testing or managing multiple keys. |
262
+ | `--model` | String | `config["ai"]["model"]` | Temporarily overrides the `ai.model` configured in `config.toml` for the current generation command. Allows for on-the-fly switching between AI models. |
263
+ | `--github_user` | String | `config["general"]["github_user"]` | Temporarily overrides the `general.github_user` configured in `config.toml` for the current generation command. |
264
+
265
+ These options collectively provide fine-grained control over how `README Generator` operates, allowing users to tailor the generation process to their specific needs and project contexts.
266
+
267
+ ## Author
268
+
269
+ **Vinicius de Freitas Paulino**
270
+ - **GitHub:** [@vinifreitaspaulino](https://github.com/vinifreitaspaulino)
271
+
272
+ ## License
273
+
274
+ This project is licensed under the MIT License.
@@ -0,0 +1,11 @@
1
+ from google import genai
2
+
3
+ def gemini(prompt: str, model: str, api_key: str) -> str:
4
+ client = genai.Client(api_key=api_key)
5
+
6
+ response = client.models.generate_content(
7
+ model=model,
8
+ contents=prompt
9
+ )
10
+
11
+ return response.text.strip()
@@ -0,0 +1,20 @@
1
+ from pathlib import Path
2
+
3
+ TEMPLATES_DIR = Path(__file__).parent / "templates"
4
+
5
+
6
+ def build(context: dict, lang: str = "pt") -> str:
7
+ template_path = TEMPLATES_DIR / f"{lang}.md"
8
+ assert template_path.exists(), f"{template_path} DOESN'T EXISTS"
9
+ with open(template_path, "r", encoding="utf-8") as f:
10
+ template = f.read()
11
+
12
+ source_files = ""
13
+ for file in context["files"]:
14
+ source_files += (f"\n--- {file['name']} ---")
15
+ source_files += (file["content"])
16
+ format_template = template.format(**context)
17
+ format_template = format_template.replace("[FILE CONTENTS HERE]", source_files)
18
+
19
+ return format_template
20
+