git-alchemist 1.0.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.
- git_alchemist-1.0.0/LICENSE +21 -0
- git_alchemist-1.0.0/PKG-INFO +99 -0
- git_alchemist-1.0.0/README.md +84 -0
- git_alchemist-1.0.0/git_alchemist.egg-info/PKG-INFO +99 -0
- git_alchemist-1.0.0/git_alchemist.egg-info/SOURCES.txt +20 -0
- git_alchemist-1.0.0/git_alchemist.egg-info/dependency_links.txt +1 -0
- git_alchemist-1.0.0/git_alchemist.egg-info/entry_points.txt +2 -0
- git_alchemist-1.0.0/git_alchemist.egg-info/requires.txt +4 -0
- git_alchemist-1.0.0/git_alchemist.egg-info/top_level.txt +1 -0
- git_alchemist-1.0.0/pyproject.toml +25 -0
- git_alchemist-1.0.0/setup.cfg +4 -0
- git_alchemist-1.0.0/src/architect.py +149 -0
- git_alchemist-1.0.0/src/audit.py +61 -0
- git_alchemist-1.0.0/src/cli.py +84 -0
- git_alchemist-1.0.0/src/committer.py +70 -0
- git_alchemist-1.0.0/src/core.py +59 -0
- git_alchemist-1.0.0/src/issue_gen.py +76 -0
- git_alchemist-1.0.0/src/profile_gen.py +197 -0
- git_alchemist-1.0.0/src/promote.py +74 -0
- git_alchemist-1.0.0/src/repo_tools.py +111 -0
- git_alchemist-1.0.0/src/sage.py +71 -0
- git_alchemist-1.0.0/src/utils.py +47 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 abduznik
|
|
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.
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: git-alchemist
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: A unified AI stack to optimize, describe, and architect your GitHub repositories.
|
|
5
|
+
Author: abduznik
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: >=3.10
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Dist: google-genai
|
|
11
|
+
Requires-Dist: rich
|
|
12
|
+
Requires-Dist: python-dotenv
|
|
13
|
+
Requires-Dist: requests
|
|
14
|
+
Dynamic: license-file
|
|
15
|
+
|
|
16
|
+
# Git-Alchemist ⚗️
|
|
17
|
+
|
|
18
|
+
**Git-Alchemist ⚗️** is a unified AI-powered CLI tool for automating GitHub repository management. It consolidates multiple technical utilities into a single, intelligent system powered by Google's Gemini 3 and Gemma 3 models.
|
|
19
|
+
|
|
20
|
+
### 🌐 [Visit the Official Site](https://abduznik.github.io/Git-Alchemist/)
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Features
|
|
25
|
+
|
|
26
|
+
* **Smart Profile Generator:** Intelligently generates or updates your GitHub Profile README.
|
|
27
|
+
* **Topic Generator:** Auto-tag your repositories with AI-suggested topics for better discoverability.
|
|
28
|
+
* **Description Refiner:** Automatically generates repository descriptions by analyzing your README content.
|
|
29
|
+
* **Issue Drafter:** Translates loose ideas into structured, technical GitHub Issue drafts.
|
|
30
|
+
* **Architect (Scaffold):** Generates and executes project scaffolding commands in a safe, temporary workspace.
|
|
31
|
+
* **Fix & Explain:** Apply AI-powered patches to specific files or get concise technical explanations for complex code.
|
|
32
|
+
* **Gold Score Audit:** Measure your repository's professional quality and health.
|
|
33
|
+
* **The Sage:** Contextual codebase chat to answer deep technical questions about your code.
|
|
34
|
+
* **Commit Alchemist:** Automated semantic commit message suggestions from staged changes.
|
|
35
|
+
|
|
36
|
+
## Model Tiers
|
|
37
|
+
|
|
38
|
+
Git-Alchemist features a dynamic fallback system to ensure you never hit a quota wall:
|
|
39
|
+
|
|
40
|
+
* **Fast Mode (Default):** Utilizes **Gemma 3 (27B)** and **Gemini 3 Flash**. Optimized for speed and high-volume tasks.
|
|
41
|
+
* **Smart Mode (`--smart`):** Utilizes **Gemini 3 Pro** and **Gemini 2.5 Pro**. Optimized for complex architecture and deep code analysis.
|
|
42
|
+
|
|
43
|
+
## Installation
|
|
44
|
+
|
|
45
|
+
1. **Clone the repository:**
|
|
46
|
+
```bash
|
|
47
|
+
git clone https://github.com/abduznik/Git-Alchemist.git
|
|
48
|
+
cd Git-Alchemist
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
2. **Install as a Global Library:**
|
|
52
|
+
```bash
|
|
53
|
+
pip install .
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
3. **Set up your Environment:**
|
|
57
|
+
Create a `.env` file in the directory or export it in your shell:
|
|
58
|
+
```env
|
|
59
|
+
GEMINI_API_KEY=your_actual_api_key_here
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Usage
|
|
63
|
+
|
|
64
|
+
Once installed, you can run the `alchemist` command from **any directory**:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
# Audit a repository
|
|
68
|
+
alchemist audit
|
|
69
|
+
|
|
70
|
+
# Optimize repository topics
|
|
71
|
+
alchemist topics
|
|
72
|
+
|
|
73
|
+
# Generate semantic commit messages
|
|
74
|
+
alchemist commit
|
|
75
|
+
|
|
76
|
+
# Ask the Sage a question
|
|
77
|
+
alchemist sage "How does the audit scoring work?"
|
|
78
|
+
|
|
79
|
+
# Scaffold a new project (Safe Mode)
|
|
80
|
+
alchemist scaffold "A FastAPI backend with a React frontend" --smart
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Requirements
|
|
84
|
+
|
|
85
|
+
* Python 3.10+
|
|
86
|
+
* GitHub CLI (`gh`) installed and authenticated (`gh auth login`).
|
|
87
|
+
* A Google Gemini API Key.
|
|
88
|
+
|
|
89
|
+
## Migration Note
|
|
90
|
+
|
|
91
|
+
This tool replaces and consolidates the following legacy scripts:
|
|
92
|
+
* `AI-Gen-Profile`
|
|
93
|
+
* `AI-Gen-Topics`
|
|
94
|
+
* `AI-Gen-Description`
|
|
95
|
+
* `AI-Gen-Issue`
|
|
96
|
+
* `Ai-Pro-Arch`
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
*Created by [abduznik](https://github.com/abduznik)*
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Git-Alchemist ⚗️
|
|
2
|
+
|
|
3
|
+
**Git-Alchemist ⚗️** is a unified AI-powered CLI tool for automating GitHub repository management. It consolidates multiple technical utilities into a single, intelligent system powered by Google's Gemini 3 and Gemma 3 models.
|
|
4
|
+
|
|
5
|
+
### 🌐 [Visit the Official Site](https://abduznik.github.io/Git-Alchemist/)
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
* **Smart Profile Generator:** Intelligently generates or updates your GitHub Profile README.
|
|
12
|
+
* **Topic Generator:** Auto-tag your repositories with AI-suggested topics for better discoverability.
|
|
13
|
+
* **Description Refiner:** Automatically generates repository descriptions by analyzing your README content.
|
|
14
|
+
* **Issue Drafter:** Translates loose ideas into structured, technical GitHub Issue drafts.
|
|
15
|
+
* **Architect (Scaffold):** Generates and executes project scaffolding commands in a safe, temporary workspace.
|
|
16
|
+
* **Fix & Explain:** Apply AI-powered patches to specific files or get concise technical explanations for complex code.
|
|
17
|
+
* **Gold Score Audit:** Measure your repository's professional quality and health.
|
|
18
|
+
* **The Sage:** Contextual codebase chat to answer deep technical questions about your code.
|
|
19
|
+
* **Commit Alchemist:** Automated semantic commit message suggestions from staged changes.
|
|
20
|
+
|
|
21
|
+
## Model Tiers
|
|
22
|
+
|
|
23
|
+
Git-Alchemist features a dynamic fallback system to ensure you never hit a quota wall:
|
|
24
|
+
|
|
25
|
+
* **Fast Mode (Default):** Utilizes **Gemma 3 (27B)** and **Gemini 3 Flash**. Optimized for speed and high-volume tasks.
|
|
26
|
+
* **Smart Mode (`--smart`):** Utilizes **Gemini 3 Pro** and **Gemini 2.5 Pro**. Optimized for complex architecture and deep code analysis.
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
1. **Clone the repository:**
|
|
31
|
+
```bash
|
|
32
|
+
git clone https://github.com/abduznik/Git-Alchemist.git
|
|
33
|
+
cd Git-Alchemist
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
2. **Install as a Global Library:**
|
|
37
|
+
```bash
|
|
38
|
+
pip install .
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
3. **Set up your Environment:**
|
|
42
|
+
Create a `.env` file in the directory or export it in your shell:
|
|
43
|
+
```env
|
|
44
|
+
GEMINI_API_KEY=your_actual_api_key_here
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Usage
|
|
48
|
+
|
|
49
|
+
Once installed, you can run the `alchemist` command from **any directory**:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# Audit a repository
|
|
53
|
+
alchemist audit
|
|
54
|
+
|
|
55
|
+
# Optimize repository topics
|
|
56
|
+
alchemist topics
|
|
57
|
+
|
|
58
|
+
# Generate semantic commit messages
|
|
59
|
+
alchemist commit
|
|
60
|
+
|
|
61
|
+
# Ask the Sage a question
|
|
62
|
+
alchemist sage "How does the audit scoring work?"
|
|
63
|
+
|
|
64
|
+
# Scaffold a new project (Safe Mode)
|
|
65
|
+
alchemist scaffold "A FastAPI backend with a React frontend" --smart
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Requirements
|
|
69
|
+
|
|
70
|
+
* Python 3.10+
|
|
71
|
+
* GitHub CLI (`gh`) installed and authenticated (`gh auth login`).
|
|
72
|
+
* A Google Gemini API Key.
|
|
73
|
+
|
|
74
|
+
## Migration Note
|
|
75
|
+
|
|
76
|
+
This tool replaces and consolidates the following legacy scripts:
|
|
77
|
+
* `AI-Gen-Profile`
|
|
78
|
+
* `AI-Gen-Topics`
|
|
79
|
+
* `AI-Gen-Description`
|
|
80
|
+
* `AI-Gen-Issue`
|
|
81
|
+
* `Ai-Pro-Arch`
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
*Created by [abduznik](https://github.com/abduznik)*
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: git-alchemist
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: A unified AI stack to optimize, describe, and architect your GitHub repositories.
|
|
5
|
+
Author: abduznik
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: >=3.10
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Dist: google-genai
|
|
11
|
+
Requires-Dist: rich
|
|
12
|
+
Requires-Dist: python-dotenv
|
|
13
|
+
Requires-Dist: requests
|
|
14
|
+
Dynamic: license-file
|
|
15
|
+
|
|
16
|
+
# Git-Alchemist ⚗️
|
|
17
|
+
|
|
18
|
+
**Git-Alchemist ⚗️** is a unified AI-powered CLI tool for automating GitHub repository management. It consolidates multiple technical utilities into a single, intelligent system powered by Google's Gemini 3 and Gemma 3 models.
|
|
19
|
+
|
|
20
|
+
### 🌐 [Visit the Official Site](https://abduznik.github.io/Git-Alchemist/)
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Features
|
|
25
|
+
|
|
26
|
+
* **Smart Profile Generator:** Intelligently generates or updates your GitHub Profile README.
|
|
27
|
+
* **Topic Generator:** Auto-tag your repositories with AI-suggested topics for better discoverability.
|
|
28
|
+
* **Description Refiner:** Automatically generates repository descriptions by analyzing your README content.
|
|
29
|
+
* **Issue Drafter:** Translates loose ideas into structured, technical GitHub Issue drafts.
|
|
30
|
+
* **Architect (Scaffold):** Generates and executes project scaffolding commands in a safe, temporary workspace.
|
|
31
|
+
* **Fix & Explain:** Apply AI-powered patches to specific files or get concise technical explanations for complex code.
|
|
32
|
+
* **Gold Score Audit:** Measure your repository's professional quality and health.
|
|
33
|
+
* **The Sage:** Contextual codebase chat to answer deep technical questions about your code.
|
|
34
|
+
* **Commit Alchemist:** Automated semantic commit message suggestions from staged changes.
|
|
35
|
+
|
|
36
|
+
## Model Tiers
|
|
37
|
+
|
|
38
|
+
Git-Alchemist features a dynamic fallback system to ensure you never hit a quota wall:
|
|
39
|
+
|
|
40
|
+
* **Fast Mode (Default):** Utilizes **Gemma 3 (27B)** and **Gemini 3 Flash**. Optimized for speed and high-volume tasks.
|
|
41
|
+
* **Smart Mode (`--smart`):** Utilizes **Gemini 3 Pro** and **Gemini 2.5 Pro**. Optimized for complex architecture and deep code analysis.
|
|
42
|
+
|
|
43
|
+
## Installation
|
|
44
|
+
|
|
45
|
+
1. **Clone the repository:**
|
|
46
|
+
```bash
|
|
47
|
+
git clone https://github.com/abduznik/Git-Alchemist.git
|
|
48
|
+
cd Git-Alchemist
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
2. **Install as a Global Library:**
|
|
52
|
+
```bash
|
|
53
|
+
pip install .
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
3. **Set up your Environment:**
|
|
57
|
+
Create a `.env` file in the directory or export it in your shell:
|
|
58
|
+
```env
|
|
59
|
+
GEMINI_API_KEY=your_actual_api_key_here
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Usage
|
|
63
|
+
|
|
64
|
+
Once installed, you can run the `alchemist` command from **any directory**:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
# Audit a repository
|
|
68
|
+
alchemist audit
|
|
69
|
+
|
|
70
|
+
# Optimize repository topics
|
|
71
|
+
alchemist topics
|
|
72
|
+
|
|
73
|
+
# Generate semantic commit messages
|
|
74
|
+
alchemist commit
|
|
75
|
+
|
|
76
|
+
# Ask the Sage a question
|
|
77
|
+
alchemist sage "How does the audit scoring work?"
|
|
78
|
+
|
|
79
|
+
# Scaffold a new project (Safe Mode)
|
|
80
|
+
alchemist scaffold "A FastAPI backend with a React frontend" --smart
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Requirements
|
|
84
|
+
|
|
85
|
+
* Python 3.10+
|
|
86
|
+
* GitHub CLI (`gh`) installed and authenticated (`gh auth login`).
|
|
87
|
+
* A Google Gemini API Key.
|
|
88
|
+
|
|
89
|
+
## Migration Note
|
|
90
|
+
|
|
91
|
+
This tool replaces and consolidates the following legacy scripts:
|
|
92
|
+
* `AI-Gen-Profile`
|
|
93
|
+
* `AI-Gen-Topics`
|
|
94
|
+
* `AI-Gen-Description`
|
|
95
|
+
* `AI-Gen-Issue`
|
|
96
|
+
* `Ai-Pro-Arch`
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
*Created by [abduznik](https://github.com/abduznik)*
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
git_alchemist.egg-info/PKG-INFO
|
|
5
|
+
git_alchemist.egg-info/SOURCES.txt
|
|
6
|
+
git_alchemist.egg-info/dependency_links.txt
|
|
7
|
+
git_alchemist.egg-info/entry_points.txt
|
|
8
|
+
git_alchemist.egg-info/requires.txt
|
|
9
|
+
git_alchemist.egg-info/top_level.txt
|
|
10
|
+
src/architect.py
|
|
11
|
+
src/audit.py
|
|
12
|
+
src/cli.py
|
|
13
|
+
src/committer.py
|
|
14
|
+
src/core.py
|
|
15
|
+
src/issue_gen.py
|
|
16
|
+
src/profile_gen.py
|
|
17
|
+
src/promote.py
|
|
18
|
+
src/repo_tools.py
|
|
19
|
+
src/sage.py
|
|
20
|
+
src/utils.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
src
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "git-alchemist"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "A unified AI stack to optimize, describe, and architect your GitHub repositories."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
authors = [{ name = "abduznik" }]
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
requires-python = ">=3.10"
|
|
13
|
+
dependencies = [
|
|
14
|
+
"google-genai",
|
|
15
|
+
"rich",
|
|
16
|
+
"python-dotenv",
|
|
17
|
+
"requests"
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
[project.scripts]
|
|
21
|
+
alchemist = "src.cli:main"
|
|
22
|
+
|
|
23
|
+
[tool.setuptools.packages.find]
|
|
24
|
+
where = ["."]
|
|
25
|
+
include = ["src*"]
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import json
|
|
3
|
+
import shutil
|
|
4
|
+
import tempfile
|
|
5
|
+
import subprocess
|
|
6
|
+
from rich.console import Console
|
|
7
|
+
from rich.prompt import Confirm
|
|
8
|
+
from .core import generate_content
|
|
9
|
+
from .utils import run_shell
|
|
10
|
+
|
|
11
|
+
console = Console()
|
|
12
|
+
|
|
13
|
+
def scaffold_project(instruction, mode="fast"):
|
|
14
|
+
"""
|
|
15
|
+
Generates shell commands to scaffold a project in a temporary directory.
|
|
16
|
+
"""
|
|
17
|
+
console.print(f"[cyan]Architecting solution for: {instruction} ({mode} mode)...[/cyan]")
|
|
18
|
+
|
|
19
|
+
# Create temp env
|
|
20
|
+
temp_dir = tempfile.mkdtemp(prefix="git_alchemist_scaffold_")
|
|
21
|
+
console.print(f"[gray]Created temporary workspace: {temp_dir}[/gray]")
|
|
22
|
+
|
|
23
|
+
prompt = f"""
|
|
24
|
+
Task: Project Scaffolding.
|
|
25
|
+
User Goal: "{instruction}"
|
|
26
|
+
Operating System: Linux/Unix (Termux)
|
|
27
|
+
Constraint: Return ONLY a JSON object with a single key "commands" containing an array of shell strings.
|
|
28
|
+
The commands should assume they are running INSIDE the project root.
|
|
29
|
+
Example: {{"commands": ["mkdir src", "touch src/main.py", "echo 'print(1)' > src/main.py"]}}
|
|
30
|
+
Do NOT use markdown blocks.
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
result = generate_content(prompt, mode=mode)
|
|
34
|
+
if not result:
|
|
35
|
+
shutil.rmtree(temp_dir)
|
|
36
|
+
return
|
|
37
|
+
|
|
38
|
+
try:
|
|
39
|
+
clean_result = result.replace("```json", "").replace("```", "").strip()
|
|
40
|
+
data = json.loads(clean_result)
|
|
41
|
+
commands = data.get("commands", [])
|
|
42
|
+
|
|
43
|
+
console.print("[green]Generated Plan:[/green]")
|
|
44
|
+
for cmd in commands:
|
|
45
|
+
console.print(f" > {cmd}")
|
|
46
|
+
|
|
47
|
+
if Confirm.ask("Execute these commands in the temporary workspace?"):
|
|
48
|
+
# Execute in temp dir
|
|
49
|
+
cwd = os.getcwd()
|
|
50
|
+
os.chdir(temp_dir)
|
|
51
|
+
try:
|
|
52
|
+
for cmd in commands:
|
|
53
|
+
console.print(f"[cyan]Running:[/cyan] {cmd}")
|
|
54
|
+
run_shell(cmd)
|
|
55
|
+
|
|
56
|
+
console.print("[green]Scaffolding complete in temporary workspace.[/green]")
|
|
57
|
+
console.print(f"[gray]Contents of {temp_dir}:[/gray]")
|
|
58
|
+
run_shell("ls -R")
|
|
59
|
+
|
|
60
|
+
if Confirm.ask("Keep these files? (Moves them to current directory)"):
|
|
61
|
+
# Move files from temp_dir to cwd
|
|
62
|
+
# We iterate over items in temp_dir and move them
|
|
63
|
+
for item in os.listdir(temp_dir):
|
|
64
|
+
s = os.path.join(temp_dir, item)
|
|
65
|
+
d = os.path.join(cwd, item)
|
|
66
|
+
if os.path.exists(d):
|
|
67
|
+
console.print(f"[yellow]Warning:[/yellow] {item} already exists in current directory. Skipping.")
|
|
68
|
+
else:
|
|
69
|
+
shutil.move(s, d)
|
|
70
|
+
console.print("[green]Files moved successfully.[/green]")
|
|
71
|
+
else:
|
|
72
|
+
console.print("[yellow]Discarding workspace.[/yellow]")
|
|
73
|
+
|
|
74
|
+
except Exception as e:
|
|
75
|
+
console.print(f"[red]Execution failed:[/red] {e}")
|
|
76
|
+
finally:
|
|
77
|
+
os.chdir(cwd)
|
|
78
|
+
|
|
79
|
+
except json.JSONDecodeError:
|
|
80
|
+
console.print(f"[red]Failed to parse AI response:[/red] {result}")
|
|
81
|
+
finally:
|
|
82
|
+
if os.path.exists(temp_dir):
|
|
83
|
+
shutil.rmtree(temp_dir)
|
|
84
|
+
console.print("[gray]Temporary workspace cleaned up.[/gray]")
|
|
85
|
+
|
|
86
|
+
def fix_code(file_path, instruction, mode="fast"):
|
|
87
|
+
"""
|
|
88
|
+
Reads a file, applies an AI fix, and optionally creates a PR.
|
|
89
|
+
"""
|
|
90
|
+
if not os.path.exists(file_path):
|
|
91
|
+
console.print(f"[red]File not found:[/red] {file_path}")
|
|
92
|
+
return
|
|
93
|
+
|
|
94
|
+
console.print(f"[cyan]Reading {file_path} ({mode} mode)...[/cyan]")
|
|
95
|
+
with open(file_path, "r", encoding="utf-8") as f:
|
|
96
|
+
content = f.read()
|
|
97
|
+
|
|
98
|
+
prompt = f"""
|
|
99
|
+
Task: Fix/Modify Code.
|
|
100
|
+
User Instructions:
|
|
101
|
+
'''
|
|
102
|
+
{instruction}
|
|
103
|
+
'''
|
|
104
|
+
|
|
105
|
+
Target File Content:
|
|
106
|
+
'''
|
|
107
|
+
{content}
|
|
108
|
+
'''
|
|
109
|
+
|
|
110
|
+
Goal: Return ONLY the complete, corrected file content based on the User Instructions. Do not use markdown blocks.
|
|
111
|
+
"""
|
|
112
|
+
|
|
113
|
+
console.print(f"[magenta]Consulting Gemini ({mode} mode)...[/magenta]")
|
|
114
|
+
result = generate_content(prompt, mode=mode)
|
|
115
|
+
if not result:
|
|
116
|
+
return
|
|
117
|
+
|
|
118
|
+
clean_result = result.replace("```python", "").replace("```", "").strip() # Generic cleanup
|
|
119
|
+
|
|
120
|
+
# Backup
|
|
121
|
+
backup_path = f"{file_path}.bak"
|
|
122
|
+
shutil.copy(file_path, backup_path)
|
|
123
|
+
console.print(f"[gray]Backup created: {backup_path}[/gray]")
|
|
124
|
+
|
|
125
|
+
with open(file_path, "w", encoding="utf-8") as f:
|
|
126
|
+
f.write(clean_result)
|
|
127
|
+
|
|
128
|
+
console.print(f"[green]File updated.[/green]")
|
|
129
|
+
|
|
130
|
+
if Confirm.ask("Create a PR for this fix?"):
|
|
131
|
+
# This assumes we are in a git repo
|
|
132
|
+
try:
|
|
133
|
+
branch_name = f"fix/ai-{os.urandom(4).hex()}"
|
|
134
|
+
run_shell(f"git checkout -b {branch_name}")
|
|
135
|
+
run_shell(f"git add {file_path}")
|
|
136
|
+
run_shell(f'git commit -m "AI Fix: {instruction}"')
|
|
137
|
+
run_shell(f"git push -u origin {branch_name}")
|
|
138
|
+
run_shell(f'gh pr create --title "AI Fix: {instruction}" --body "Automated fix." --web')
|
|
139
|
+
except Exception as e:
|
|
140
|
+
console.print(f"[red]PR creation failed:[/red] {e}")
|
|
141
|
+
|
|
142
|
+
def explain_code(context, mode="fast"):
|
|
143
|
+
"""
|
|
144
|
+
Explains a concept or code snippet.
|
|
145
|
+
"""
|
|
146
|
+
prompt = f"Task: Explain Concept/Code. Context: '{context}'. Keep it concise and technical."
|
|
147
|
+
result = generate_content(prompt, mode=mode)
|
|
148
|
+
if result:
|
|
149
|
+
console.print(f"\n[bold white]--- Explanation ---[/bold white]\n{result}\n[bold white]-------------------[/bold white]")
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import json
|
|
3
|
+
from rich.console import Console
|
|
4
|
+
from rich.table import Table
|
|
5
|
+
from rich.progress import Progress
|
|
6
|
+
from .utils import run_shell, check_gh_auth
|
|
7
|
+
|
|
8
|
+
console = Console()
|
|
9
|
+
|
|
10
|
+
def run_audit(user=None, repo_name=None):
|
|
11
|
+
"""
|
|
12
|
+
Audits a repository for 'Gold Standard' items and returns a score.
|
|
13
|
+
"""
|
|
14
|
+
username = user or check_gh_auth()
|
|
15
|
+
if not username:
|
|
16
|
+
console.print("[red]Not authenticated with gh CLI.[/red]")
|
|
17
|
+
return
|
|
18
|
+
|
|
19
|
+
# Use current directory if no repo specified
|
|
20
|
+
target_repo = repo_name or run_shell("gh repo view --json name --jq .name", check=False)
|
|
21
|
+
if not target_repo:
|
|
22
|
+
console.print("[yellow]Not inside a Git repository. Auditing current directory files only.[/yellow]")
|
|
23
|
+
repo_data = {}
|
|
24
|
+
else:
|
|
25
|
+
console.print(f"[cyan]Auditing Repository:[/cyan] [bold]{username}/{target_repo}[/bold]")
|
|
26
|
+
repo_data_raw = run_shell(f"gh repo view {username}/{target_repo} --json description,repositoryTopics,licenseInfo", check=False)
|
|
27
|
+
repo_data = json.loads(repo_data_raw) if repo_data_raw else {}
|
|
28
|
+
|
|
29
|
+
checks = {
|
|
30
|
+
"README.md": {"score": 20, "found": os.path.exists("README.md")},
|
|
31
|
+
"LICENSE": {"score": 10, "found": bool(repo_data.get("licenseInfo")) or any(os.path.exists(f) for f in ["LICENSE", "LICENSE.md", "LICENSE.txt"])},
|
|
32
|
+
"CONTRIBUTING.md": {"score": 10, "found": any(os.path.exists(f) for f in ["CONTRIBUTING.md", "CONTRIBUTING"])},
|
|
33
|
+
"Metadata: Description": {"score": 20, "found": bool(repo_data.get("description"))},
|
|
34
|
+
"Metadata: Topics": {"score": 20, "found": len(repo_data.get("repositoryTopics", [])) >= 3},
|
|
35
|
+
"CI/CD: GitHub Actions": {"score": 20, "found": os.path.exists(".github/workflows")},
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
total_score = sum(c["score"] for c in checks.values() if c["found"])
|
|
39
|
+
|
|
40
|
+
# Display Table
|
|
41
|
+
table = Table(title=f"Repository Audit: {target_repo or 'Local'}", border_style="blue")
|
|
42
|
+
table.add_column("Criterion", style="cyan")
|
|
43
|
+
table.add_column("Status", justify="center")
|
|
44
|
+
table.add_column("Weight", justify="right")
|
|
45
|
+
|
|
46
|
+
for name, data in checks.items():
|
|
47
|
+
status = "[green]GOLD[/green]" if data["found"] else "[red]LEAD[/red]"
|
|
48
|
+
table.add_row(name, status, f"{data['score']}")
|
|
49
|
+
|
|
50
|
+
console.print(table)
|
|
51
|
+
|
|
52
|
+
# Final Score Display
|
|
53
|
+
color = "green" if total_score >= 80 else "yellow" if total_score >= 50 else "red"
|
|
54
|
+
console.print(f"\n[bold]Transmutation Score:[/bold] [{color}]{total_score}%[/{color}]")
|
|
55
|
+
|
|
56
|
+
if total_score < 100:
|
|
57
|
+
console.print(f"\n[italic gray]The Alchemist suggests adding the missing components to reach 100% Gold.[/italic gray]")
|
|
58
|
+
else:
|
|
59
|
+
console.print(f"\n[bold yellow]✨ Pure Gold! This repository is optimized for the community.[/bold yellow]")
|
|
60
|
+
|
|
61
|
+
return total_score
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import sys
|
|
3
|
+
from rich.console import Console
|
|
4
|
+
from .profile_gen import generate_profile
|
|
5
|
+
from .architect import scaffold_project, fix_code, explain_code
|
|
6
|
+
from .repo_tools import optimize_topics, generate_descriptions
|
|
7
|
+
from .issue_gen import create_issue
|
|
8
|
+
from .audit import run_audit
|
|
9
|
+
from .sage import ask_sage
|
|
10
|
+
from .committer import suggest_commits
|
|
11
|
+
|
|
12
|
+
console = Console()
|
|
13
|
+
|
|
14
|
+
def main():
|
|
15
|
+
parser = argparse.ArgumentParser(description="Git-Alchemist: AI-powered Git Operations")
|
|
16
|
+
parser.add_argument("--smart", action="store_true", help="Use high-end Gemini Pro models (slower/lower quota)")
|
|
17
|
+
subparsers = parser.add_subparsers(dest="command", help="Available commands")
|
|
18
|
+
|
|
19
|
+
# Commit Command
|
|
20
|
+
commit_parser = subparsers.add_parser("commit", help="Generate semantic commit messages from changes")
|
|
21
|
+
|
|
22
|
+
# Sage Command
|
|
23
|
+
sage_parser = subparsers.add_parser("sage", help="Ask the Sage questions about your codebase")
|
|
24
|
+
sage_parser.add_argument("question", help="The question about your code")
|
|
25
|
+
|
|
26
|
+
# Audit Command
|
|
27
|
+
audit_parser = subparsers.add_parser("audit", help="Check repository 'Gold' status and metadata")
|
|
28
|
+
audit_parser.add_argument("--repo", help="Specific repository name to audit")
|
|
29
|
+
|
|
30
|
+
# Profile Generator Command
|
|
31
|
+
profile_parser = subparsers.add_parser("profile", help="Generate or update GitHub Profile README")
|
|
32
|
+
profile_parser.add_argument("--force", action="store_true", help="Force full regeneration")
|
|
33
|
+
profile_parser.add_argument("--user", help="GitHub username (optional, detects automatically)")
|
|
34
|
+
|
|
35
|
+
# Repo Tools
|
|
36
|
+
topics_parser = subparsers.add_parser("topics", help="Optimize repository topics/tags")
|
|
37
|
+
topics_parser.add_argument("--user", help="GitHub username")
|
|
38
|
+
|
|
39
|
+
describe_parser = subparsers.add_parser("describe", help="Generate missing repository descriptions")
|
|
40
|
+
describe_parser.add_argument("--user", help="GitHub username")
|
|
41
|
+
|
|
42
|
+
# Issue Generator
|
|
43
|
+
issue_parser = subparsers.add_parser("issue", help="Draft a technical issue from an idea")
|
|
44
|
+
issue_parser.add_argument("idea", help="The feature or bug idea")
|
|
45
|
+
|
|
46
|
+
# Architect Commands
|
|
47
|
+
scaffold_parser = subparsers.add_parser("scaffold", help="Generate a new project structure (safe mode)")
|
|
48
|
+
scaffold_parser.add_argument("instruction", help="What to build (e.g., 'A Flask app with Docker')")
|
|
49
|
+
|
|
50
|
+
fix_parser = subparsers.add_parser("fix", help="Modify a file using AI")
|
|
51
|
+
fix_parser.add_argument("file", help="Path to the file to fix")
|
|
52
|
+
fix_parser.add_argument("instruction", help="What to change")
|
|
53
|
+
|
|
54
|
+
explain_parser = subparsers.add_parser("explain", help="Explain code or concepts")
|
|
55
|
+
explain_parser.add_argument("context", help="The code or concept to explain")
|
|
56
|
+
|
|
57
|
+
args = parser.parse_args()
|
|
58
|
+
mode = "smart" if args.smart else "fast"
|
|
59
|
+
|
|
60
|
+
if args.command == "profile":
|
|
61
|
+
generate_profile(args.user, args.force, mode=mode)
|
|
62
|
+
elif args.command == "topics":
|
|
63
|
+
optimize_topics(args.user, mode=mode)
|
|
64
|
+
elif args.command == "describe":
|
|
65
|
+
generate_descriptions(args.user, mode=mode)
|
|
66
|
+
elif args.command == "issue":
|
|
67
|
+
create_issue(args.idea, mode=mode)
|
|
68
|
+
elif args.command == "scaffold":
|
|
69
|
+
scaffold_project(args.instruction, mode=mode)
|
|
70
|
+
elif args.command == "fix":
|
|
71
|
+
fix_code(args.file, args.instruction, mode=mode)
|
|
72
|
+
elif args.command == "explain":
|
|
73
|
+
explain_code(args.context, mode=mode)
|
|
74
|
+
elif args.command == "audit":
|
|
75
|
+
run_audit(repo_name=args.repo)
|
|
76
|
+
elif args.command == "sage":
|
|
77
|
+
ask_sage(args.question, mode=mode)
|
|
78
|
+
elif args.command == "commit":
|
|
79
|
+
suggest_commits(mode=mode)
|
|
80
|
+
else:
|
|
81
|
+
parser.print_help()
|
|
82
|
+
|
|
83
|
+
if __name__ == "__main__":
|
|
84
|
+
main()
|