ai-factory-cli 6.3.0__py3-none-any.whl
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.
- ai_factory/__init__.py +1 -0
- ai_factory/tui.py.py +181 -0
- ai_factory_cli-6.3.0.dist-info/METADATA +41 -0
- ai_factory_cli-6.3.0.dist-info/RECORD +8 -0
- ai_factory_cli-6.3.0.dist-info/WHEEL +5 -0
- ai_factory_cli-6.3.0.dist-info/entry_points.txt +2 -0
- ai_factory_cli-6.3.0.dist-info/licenses/LICENSE.txt +21 -0
- ai_factory_cli-6.3.0.dist-info/top_level.txt +1 -0
ai_factory/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .tui import main
|
ai_factory/tui.py.py
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
import sys
|
|
3
|
+
import os
|
|
4
|
+
import shutil
|
|
5
|
+
import requests
|
|
6
|
+
import time
|
|
7
|
+
|
|
8
|
+
API_URL = "https://integrate.api.nvidia.com/v1/chat/completions"
|
|
9
|
+
API_KEY = "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"
|
|
10
|
+
|
|
11
|
+
MODELS = {
|
|
12
|
+
"1": {"name": "Poolside Laguna XS 2.1", "id": "poolside/laguna-xs-2.1", "max_ctx": 262144},
|
|
13
|
+
"2": {"name": "Google Gemma 4 31B IT", "id": "google/gemma-4-31b-it", "max_ctx": 262144}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
def select_model():
|
|
17
|
+
os.system('cls' if os.name == 'nt' else 'clear')
|
|
18
|
+
print("========================================================")
|
|
19
|
+
print(" AI FACTORY CLI | Model Selector ")
|
|
20
|
+
print("========================================================")
|
|
21
|
+
for key, m in MODELS.items():
|
|
22
|
+
print(f" [{key}] {m['name']}")
|
|
23
|
+
print("--------------------------------------------------------")
|
|
24
|
+
choice = input("Select model number [default 1]: ").strip()
|
|
25
|
+
if choice not in MODELS:
|
|
26
|
+
choice = "1"
|
|
27
|
+
return MODELS[choice]
|
|
28
|
+
|
|
29
|
+
def read_local_file(filepath):
|
|
30
|
+
try:
|
|
31
|
+
with open(filepath, "r", encoding="utf-8") as f:
|
|
32
|
+
return f.read()
|
|
33
|
+
except Exception as e:
|
|
34
|
+
return f"[Error reading file: {e}]"
|
|
35
|
+
|
|
36
|
+
def wrap_text(text, max_width):
|
|
37
|
+
"""Word-wraps long paragraphs into clean lines fitting inside the container box."""
|
|
38
|
+
wrapped_lines = []
|
|
39
|
+
for paragraph in text.splitlines():
|
|
40
|
+
if not paragraph:
|
|
41
|
+
wrapped_lines.append("")
|
|
42
|
+
continue
|
|
43
|
+
while len(paragraph) > max_width:
|
|
44
|
+
split_idx = paragraph.rfind(' ', 0, max_width)
|
|
45
|
+
if split_idx == -1:
|
|
46
|
+
split_idx = max_width
|
|
47
|
+
wrapped_lines.append(paragraph[:split_idx])
|
|
48
|
+
paragraph = paragraph[split_idx:].lstrip()
|
|
49
|
+
wrapped_lines.append(paragraph)
|
|
50
|
+
return wrapped_lines
|
|
51
|
+
|
|
52
|
+
def print_chat_container(title, text, border_color_code, title_color_code):
|
|
53
|
+
"""Renders an auto-expanding, cleanly aligned chat container box like ChatGPT/Claude/Gemini."""
|
|
54
|
+
term_width = shutil.get_terminal_size(fallback=(100, 30)).columns
|
|
55
|
+
box_width = min(max(term_width - 6, 60), 120) # Dynamic width bounded cleanly
|
|
56
|
+
|
|
57
|
+
content_lines = wrap_text(text, box_width - 4)
|
|
58
|
+
|
|
59
|
+
RESET = "\033[0m"
|
|
60
|
+
b_col = border_color_code
|
|
61
|
+
t_col = title_color_code
|
|
62
|
+
|
|
63
|
+
# Top border & title header
|
|
64
|
+
print(b_col + "+" + "-" * (box_width - 2) + "+" + RESET)
|
|
65
|
+
header_text = f" {t_col}\033[1m{title}\033[0m"
|
|
66
|
+
padding = box_width - len(title) - 4
|
|
67
|
+
print(f"{b_col}|{RESET}{header_text}" + " " * max(padding, 0) + f"{b_col}|{RESET}")
|
|
68
|
+
print(b_col + "+" + "-" * (box_width - 2) + "+" + RESET)
|
|
69
|
+
|
|
70
|
+
# Body lines inside container
|
|
71
|
+
for line in content_lines:
|
|
72
|
+
padded_line = line.ljust(box_width - 4)
|
|
73
|
+
print(f"{b_col}|{RESET} {padded_line} {b_col}|{RESET}")
|
|
74
|
+
|
|
75
|
+
# Bottom border
|
|
76
|
+
print(b_col + "+" + "-" * (box_width - 2) + "+" + RESET)
|
|
77
|
+
|
|
78
|
+
def main():
|
|
79
|
+
selected_model = select_model()
|
|
80
|
+
messages = [
|
|
81
|
+
{"role": "system", "content": "You are AI Factory CLI, an advanced autonomous software engineering coding assistant developed by ILAYABARATHI."}
|
|
82
|
+
]
|
|
83
|
+
|
|
84
|
+
total_tokens = 93
|
|
85
|
+
chat_history = [("ai", "Hello! I am AI Factory CLI, developed by ILAYABARATHI. Type 'read <file>' or ask your coding query.")]
|
|
86
|
+
|
|
87
|
+
while True:
|
|
88
|
+
term_size = shutil.get_terminal_size(fallback=(100, 30))
|
|
89
|
+
width = max(term_size.columns, 90)
|
|
90
|
+
|
|
91
|
+
os.system('cls' if os.name == 'nt' else 'clear')
|
|
92
|
+
|
|
93
|
+
BLUE = "\033[94m"
|
|
94
|
+
RESET = "\033[0m"
|
|
95
|
+
|
|
96
|
+
print("ilayabharathi@dev01: ~/projects/ai_factory [ssh - dev01]")
|
|
97
|
+
print(BLUE + "=" * width + RESET)
|
|
98
|
+
print(f"AI FACTORY CLI v6.3 | Dev: ILAYABARATHI".ljust(width - 32) + f"Model: {selected_model['name'][:24]}")
|
|
99
|
+
print(f"Context Tokens: {total_tokens:,} / Max: {selected_model['max_ctx']:,}".ljust(width - 32) + f"Status: Connected | Coimbatore")
|
|
100
|
+
print(BLUE + "-" * width + RESET)
|
|
101
|
+
print(f" {'[AI FACTORY CHAT WORKSPACE]':<50} | [DEV: ILAYABARATHI]")
|
|
102
|
+
print(BLUE + "-" * width + RESET)
|
|
103
|
+
|
|
104
|
+
# Render Chat Container History
|
|
105
|
+
for role, text in chat_history[-6:]:
|
|
106
|
+
print()
|
|
107
|
+
if role == "user":
|
|
108
|
+
print_chat_container("User Query", text, "\033[94m", "\033[96m") # Cyan/Blue box
|
|
109
|
+
else:
|
|
110
|
+
print_chat_container("AI Agent Response", text, "\033[92m", "\033[92m") # Green box
|
|
111
|
+
|
|
112
|
+
# Render Bottom User Input Box Field
|
|
113
|
+
print()
|
|
114
|
+
box_width = min(max(width - 6, 60), 120)
|
|
115
|
+
print(BLUE + "+" + "-" * (box_width - 2) + "+" + RESET)
|
|
116
|
+
print(f"{BLUE}|{RESET} \033[1mType your prompt or command below (e.g. 'read app.py'):\033[0m" + " " * max(box_width - 57, 0) + f"{BLUE}|{RESET}")
|
|
117
|
+
print(BLUE + "+" + "-" * (box_width - 2) + "+" + RESET)
|
|
118
|
+
|
|
119
|
+
user_query = input("user > ").strip()
|
|
120
|
+
|
|
121
|
+
if user_query.lower() in ["exit", "quit", "esc"]:
|
|
122
|
+
break
|
|
123
|
+
if not user_query:
|
|
124
|
+
continue
|
|
125
|
+
|
|
126
|
+
if user_query.startswith("read "):
|
|
127
|
+
filename = user_query.split(" ", 1)[1].strip()
|
|
128
|
+
file_content = read_local_file(filename)
|
|
129
|
+
chat_history.append(("user", user_query))
|
|
130
|
+
chat_history.append(("ai", f"File Contents of `{filename}`:\n{file_content}"))
|
|
131
|
+
continue
|
|
132
|
+
|
|
133
|
+
chat_history.append(("user", user_query))
|
|
134
|
+
messages.append({"role": "user", "content": user_query})
|
|
135
|
+
|
|
136
|
+
# --- LIVE AGENT STATUS PROGRESSION ---
|
|
137
|
+
os.system('cls' if os.name == 'nt' else 'clear')
|
|
138
|
+
print("ilayabharathi@dev01: ~/projects/ai_factory [ssh - dev01]")
|
|
139
|
+
print(BLUE + "=" * width + RESET)
|
|
140
|
+
print(f"AI FACTORY CLI v6.3 | Dev: ILAYABARATHI".ljust(width - 32) + f"Model: {selected_model['name'][:24]}")
|
|
141
|
+
print(f"Context Tokens: {total_tokens:,} / Max: {selected_model['max_ctx']:,}".ljust(width - 32) + f"Status: Active Agent")
|
|
142
|
+
print(BLUE + "-" * width + RESET)
|
|
143
|
+
|
|
144
|
+
print()
|
|
145
|
+
print_chat_container("User Query", user_query, "\033[94m", "\033[96m")
|
|
146
|
+
print()
|
|
147
|
+
print("\033[93m[STATUS] Thinking & Analyzing workspace context...\033[0m")
|
|
148
|
+
time.sleep(0.3)
|
|
149
|
+
print("\033[93m[STATUS] Fetching inference via NVIDIA NIM...\033[0m")
|
|
150
|
+
|
|
151
|
+
headers = {
|
|
152
|
+
"Authorization": f"Bearer {API_KEY}",
|
|
153
|
+
"Accept": "application/json",
|
|
154
|
+
"Content-Type": "application/json"
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
payload = {
|
|
158
|
+
"model": selected_model["id"],
|
|
159
|
+
"max_tokens": 4096,
|
|
160
|
+
"stream": False,
|
|
161
|
+
"temperature": 0.3,
|
|
162
|
+
"messages": messages
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
try:
|
|
166
|
+
response = requests.post(API_URL, headers=headers, json=payload, timeout=180)
|
|
167
|
+
if response.status_code == 200:
|
|
168
|
+
result = response.json()
|
|
169
|
+
answer = result["choices"][0]["message"]["content"]
|
|
170
|
+
usage = result.get("usage", {})
|
|
171
|
+
total_tokens = usage.get("total_tokens", total_tokens)
|
|
172
|
+
|
|
173
|
+
chat_history.append(("ai", answer))
|
|
174
|
+
messages.append({"role": "assistant", "content": answer})
|
|
175
|
+
else:
|
|
176
|
+
chat_history.append(("ai", f"Error: Status {response.status_code}"))
|
|
177
|
+
except Exception as e:
|
|
178
|
+
chat_history.append(("ai", f"Error connection/timeout: {e}"))
|
|
179
|
+
|
|
180
|
+
if __name__ == "__main__":
|
|
181
|
+
main()
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ai-factory-cli
|
|
3
|
+
Version: 6.3.0
|
|
4
|
+
Summary: Advanced AI Terminal Coding Agent with modern chat containers built by Ilayabharathi
|
|
5
|
+
Home-page: https://github.com/ilayabharathi/ai-factory-cli
|
|
6
|
+
Author: ILAYABARATHI
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Python: >=3.6
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE.txt
|
|
13
|
+
Requires-Dist: requests>=2.25.0
|
|
14
|
+
Dynamic: author
|
|
15
|
+
Dynamic: classifier
|
|
16
|
+
Dynamic: description
|
|
17
|
+
Dynamic: description-content-type
|
|
18
|
+
Dynamic: home-page
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
Dynamic: requires-dist
|
|
21
|
+
Dynamic: requires-python
|
|
22
|
+
Dynamic: summary
|
|
23
|
+
|
|
24
|
+
# AI Factory CLI
|
|
25
|
+
|
|
26
|
+
An advanced, autonomous terminal-based AI software engineering assistant developed by **ILAYABARATHI**.
|
|
27
|
+
|
|
28
|
+
Built with Python, dynamic terminal box-drawing containers, and fast inference via NVIDIA NIM API (`poolside/laguna-xs-2.1` & `google/gemma-4-31b-it`).
|
|
29
|
+
|
|
30
|
+
## Features
|
|
31
|
+
- **ChatGPT-Style Container UI**: Aligned, auto-expanding ASCII box responses and user prompt input field.
|
|
32
|
+
- **Local File System Reading**: Ability to inspect codebase files directly using the `read <filepath>` command.
|
|
33
|
+
- **Cross-Platform Compatibility**: Uses standard ASCII containers to prevent Windows encoding issues.
|
|
34
|
+
- **Real-Time Agent Status**: Displays live progress indicators (*Thinking*, *Analyzing context*, *Fetching NIM API*).
|
|
35
|
+
|
|
36
|
+
## Installation
|
|
37
|
+
|
|
38
|
+
Install globally via `pip`:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
pip install ai-factory-cli
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
ai_factory/__init__.py,sha256=sZeROR3_CyrXlRQrdx6oqMM9xBUwc_wv3JtUmmRLfAI,21
|
|
2
|
+
ai_factory/tui.py.py,sha256=65HGjbmHoML5j8TVTZuzzhaIJOMyrB-A6U7qtIEN2eE,7587
|
|
3
|
+
ai_factory_cli-6.3.0.dist-info/licenses/LICENSE.txt,sha256=4KGIPiBGpo_N4Nys22e4oFriu_Hk87780Gp32aAES1w,1088
|
|
4
|
+
ai_factory_cli-6.3.0.dist-info/METADATA,sha256=O3jV0OSwlMxPcdN9LIf4d7qHz7RiqcRWRcJySQ26uAE,1551
|
|
5
|
+
ai_factory_cli-6.3.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
6
|
+
ai_factory_cli-6.3.0.dist-info/entry_points.txt,sha256=OQizPWUVO0fpvGWFTEt3mub4QGH-taruCDbjwYbNkX8,51
|
|
7
|
+
ai_factory_cli-6.3.0.dist-info/top_level.txt,sha256=etn9CCTJ7T-YBqDgx24bJIYApht6rbfeFOALJt5mVtQ,11
|
|
8
|
+
ai_factory_cli-6.3.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ILAYABARATHI
|
|
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 @@
|
|
|
1
|
+
ai_factory
|