mini-code-cli 0.0.8.0__tar.gz → 0.0.8.1__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.
- {mini_code_cli-0.0.8.0 → mini_code_cli-0.0.8.1}/PKG-INFO +25 -1
- {mini_code_cli-0.0.8.0 → mini_code_cli-0.0.8.1}/README.md +24 -0
- {mini_code_cli-0.0.8.0 → mini_code_cli-0.0.8.1}/mini_code_cli/agent_loop.py +60 -21
- {mini_code_cli-0.0.8.0 → mini_code_cli-0.0.8.1}/mini_code_cli/prompts.py +1 -1
- {mini_code_cli-0.0.8.0 → mini_code_cli-0.0.8.1}/mini_code_cli.egg-info/PKG-INFO +25 -1
- {mini_code_cli-0.0.8.0 → mini_code_cli-0.0.8.1}/pyproject.toml +1 -1
- {mini_code_cli-0.0.8.0 → mini_code_cli-0.0.8.1}/LICENSE +0 -0
- {mini_code_cli-0.0.8.0 → mini_code_cli-0.0.8.1}/mini_code_cli/__init__.py +0 -0
- {mini_code_cli-0.0.8.0 → mini_code_cli-0.0.8.1}/mini_code_cli/tools.py +0 -0
- {mini_code_cli-0.0.8.0 → mini_code_cli-0.0.8.1}/mini_code_cli/utils.py +0 -0
- {mini_code_cli-0.0.8.0 → mini_code_cli-0.0.8.1}/mini_code_cli.egg-info/SOURCES.txt +0 -0
- {mini_code_cli-0.0.8.0 → mini_code_cli-0.0.8.1}/mini_code_cli.egg-info/dependency_links.txt +0 -0
- {mini_code_cli-0.0.8.0 → mini_code_cli-0.0.8.1}/mini_code_cli.egg-info/entry_points.txt +0 -0
- {mini_code_cli-0.0.8.0 → mini_code_cli-0.0.8.1}/mini_code_cli.egg-info/top_level.txt +0 -0
- {mini_code_cli-0.0.8.0 → mini_code_cli-0.0.8.1}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mini-code-cli
|
|
3
|
-
Version: 0.0.8.
|
|
3
|
+
Version: 0.0.8.1
|
|
4
4
|
Summary: Minimal Coding CLI
|
|
5
5
|
Author-email: Nikolai Rozanov <nikolai.rozanov@gmail.com>
|
|
6
6
|
License: The MIT License (MIT)
|
|
@@ -63,6 +63,30 @@ Write an agent.md file for me that helps an LLM write efficient triton kernels,
|
|
|
63
63
|
```bash
|
|
64
64
|
mini-code --help
|
|
65
65
|
```
|
|
66
|
+
```
|
|
67
|
+
Agent loop for interacting with a language model
|
|
68
|
+
|
|
69
|
+
options:
|
|
70
|
+
-h, --help show this help message and exit
|
|
71
|
+
--url URL API host
|
|
72
|
+
--max-tokens MAX_TOKENS
|
|
73
|
+
Maximum tokens for LLM response
|
|
74
|
+
--temperature TEMPERATURE
|
|
75
|
+
Temperature for LLM
|
|
76
|
+
--model MODEL Model name
|
|
77
|
+
--api-key API_KEY API key for authentication. If not set, it tries to find it in env variable: MINI_CODE_API_KEY.
|
|
78
|
+
--cache-dir CACHE_DIR
|
|
79
|
+
The cache dir for the session histories.
|
|
80
|
+
--system-prompt SYSTEM_PROMPT
|
|
81
|
+
Replace system prompt, with a custom system prompt.
|
|
82
|
+
--auto-mode Whether to run the agent in `auto-mode'. Or default: `manual-mode'.
|
|
83
|
+
--agent-md AGENT_MD If the agent should use an agent-md file... (it will added after system message.)
|
|
84
|
+
--prompt PROMPT An initial prompt from the user...
|
|
85
|
+
--ask-permission Ask for permission before any tool call.
|
|
86
|
+
--allowed-dir ALLOWED_DIR
|
|
87
|
+
Allowed directory for file operations
|
|
88
|
+
--enable-shell Allow shell execution. Default: False
|
|
89
|
+
```
|
|
66
90
|
|
|
67
91
|
|
|
68
92
|
## (C) Nikolai Rozanov, 2026 - Present
|
|
@@ -43,6 +43,30 @@ Write an agent.md file for me that helps an LLM write efficient triton kernels,
|
|
|
43
43
|
```bash
|
|
44
44
|
mini-code --help
|
|
45
45
|
```
|
|
46
|
+
```
|
|
47
|
+
Agent loop for interacting with a language model
|
|
48
|
+
|
|
49
|
+
options:
|
|
50
|
+
-h, --help show this help message and exit
|
|
51
|
+
--url URL API host
|
|
52
|
+
--max-tokens MAX_TOKENS
|
|
53
|
+
Maximum tokens for LLM response
|
|
54
|
+
--temperature TEMPERATURE
|
|
55
|
+
Temperature for LLM
|
|
56
|
+
--model MODEL Model name
|
|
57
|
+
--api-key API_KEY API key for authentication. If not set, it tries to find it in env variable: MINI_CODE_API_KEY.
|
|
58
|
+
--cache-dir CACHE_DIR
|
|
59
|
+
The cache dir for the session histories.
|
|
60
|
+
--system-prompt SYSTEM_PROMPT
|
|
61
|
+
Replace system prompt, with a custom system prompt.
|
|
62
|
+
--auto-mode Whether to run the agent in `auto-mode'. Or default: `manual-mode'.
|
|
63
|
+
--agent-md AGENT_MD If the agent should use an agent-md file... (it will added after system message.)
|
|
64
|
+
--prompt PROMPT An initial prompt from the user...
|
|
65
|
+
--ask-permission Ask for permission before any tool call.
|
|
66
|
+
--allowed-dir ALLOWED_DIR
|
|
67
|
+
Allowed directory for file operations
|
|
68
|
+
--enable-shell Allow shell execution. Default: False
|
|
69
|
+
```
|
|
46
70
|
|
|
47
71
|
|
|
48
72
|
## (C) Nikolai Rozanov, 2026 - Present
|
|
@@ -12,13 +12,16 @@ import os
|
|
|
12
12
|
import json
|
|
13
13
|
import signal
|
|
14
14
|
|
|
15
|
+
import time
|
|
16
|
+
import uuid
|
|
17
|
+
|
|
18
|
+
import argparse
|
|
19
|
+
import sys
|
|
15
20
|
|
|
16
21
|
from . import prompts
|
|
17
22
|
from . import tools
|
|
18
23
|
from . import utils
|
|
19
24
|
|
|
20
|
-
import argparse
|
|
21
|
-
import sys
|
|
22
25
|
|
|
23
26
|
# ANSI escape codes for colors and bold
|
|
24
27
|
BOLD = '\033[1m'
|
|
@@ -30,11 +33,21 @@ MAGENTA = '\033[95m'
|
|
|
30
33
|
CYAN = '\033[96m'
|
|
31
34
|
RESET = '\033[0m'
|
|
32
35
|
|
|
33
|
-
def save_history(messages):
|
|
36
|
+
def save_history(messages, args, session_name=""):
|
|
34
37
|
# Save messages to history.json
|
|
35
|
-
|
|
38
|
+
if args.cache_dir:
|
|
39
|
+
cache_dir = args.cache_dir
|
|
40
|
+
else:
|
|
41
|
+
cache_dir = os.path.expanduser("~/.cache/mini_code/sessions/")
|
|
42
|
+
os.makedirs(cache_dir, exist_ok=True)
|
|
43
|
+
history_path = os.path.join(cache_dir, f"history_{session_name}.json")
|
|
44
|
+
with open(history_path, 'w') as f:
|
|
36
45
|
json.dump(messages, f, indent=2)
|
|
37
46
|
|
|
47
|
+
def generate_unique_id():
|
|
48
|
+
"""Generate a unique ID based on current time and a random component."""
|
|
49
|
+
timestamp = int(time.time() * 1000000) # microseconds
|
|
50
|
+
return f"{timestamp}-{uuid.uuid4().hex[:8]}"
|
|
38
51
|
|
|
39
52
|
def parse_args():
|
|
40
53
|
parser = argparse.ArgumentParser(description="Agent loop for interacting with a language model")
|
|
@@ -45,10 +58,15 @@ def parse_args():
|
|
|
45
58
|
parser.add_argument("--model", type=str, default="default", help="Model name")
|
|
46
59
|
parser.add_argument("--api-key", type=str, default=None, help="API key for authentication. If not set, it tries to find it in env variable: MINI_CODE_API_KEY.")
|
|
47
60
|
|
|
61
|
+
# Other settings:
|
|
62
|
+
parser.add_argument("--cache-dir", type=str, help="The cache dir for the session histories.")
|
|
63
|
+
|
|
64
|
+
|
|
48
65
|
# Agent behaviour related
|
|
49
66
|
parser.add_argument("--system-prompt", type=str, help="Replace system prompt, with a custom system prompt.")
|
|
50
67
|
parser.add_argument("--auto-mode", action="store_true", help="Whether to run the agent in `auto-mode'. Or default: `manual-mode'.")
|
|
51
68
|
parser.add_argument("--agent-md", type=str, help="If the agent should use an agent-md file... (it will added after system message.)")
|
|
69
|
+
parser.add_argument("--prompt", type=str, help="An initial prompt from the user...")
|
|
52
70
|
|
|
53
71
|
# Agent permissions related
|
|
54
72
|
parser.add_argument("--ask-permission", action="store_true", help="Ask for permission before any tool call.")
|
|
@@ -60,7 +78,7 @@ def parse_args():
|
|
|
60
78
|
return args
|
|
61
79
|
|
|
62
80
|
|
|
63
|
-
def print_welcome(allowed_dir, server_url, args):
|
|
81
|
+
def print_welcome(allowed_dir, server_url, args, unique_id, cache_dir):
|
|
64
82
|
# Calculate the length of the longest line inside the box
|
|
65
83
|
version = __import__('mini_code_cli').__version__
|
|
66
84
|
|
|
@@ -70,6 +88,8 @@ def print_welcome(allowed_dir, server_url, args):
|
|
|
70
88
|
|
|
71
89
|
lines = [
|
|
72
90
|
f" MiniCodeCLI (v{version})",
|
|
91
|
+
f" The session-id is: {unique_id}" ,
|
|
92
|
+
f" It will be saved under: `{cache_dir}`",
|
|
73
93
|
" Type 'quit' or 'exit' to exit the loop.",
|
|
74
94
|
f" Allowed dir: {allowed_dir}",
|
|
75
95
|
f" Server URL: {server_url}",
|
|
@@ -90,8 +110,8 @@ def print_welcome(allowed_dir, server_url, args):
|
|
|
90
110
|
bottom = "╚" + "═" * inner_width + "╝"
|
|
91
111
|
print(bottom)
|
|
92
112
|
|
|
93
|
-
def print_help(allowed_dir, server_url, args):
|
|
94
|
-
print_welcome(allowed_dir, server_url, args)
|
|
113
|
+
def print_help(allowed_dir, server_url, args, unique_id, cache_dir):
|
|
114
|
+
print_welcome(allowed_dir, server_url, args, unique_id, cache_dir)
|
|
95
115
|
|
|
96
116
|
help_message = ""
|
|
97
117
|
help_message += "Manual-mode means the agent will ask for user input after each LLM prediction." if not args.auto_mode else "Auto-mode means the agent will keep calling the LLM until no further LLM calls are possible."
|
|
@@ -119,9 +139,14 @@ def call_function_with_timeout(func, tool_params, name):
|
|
|
119
139
|
|
|
120
140
|
return result
|
|
121
141
|
|
|
142
|
+
|
|
143
|
+
|
|
122
144
|
def main():
|
|
123
145
|
args = parse_args()
|
|
124
146
|
|
|
147
|
+
# Get session unique ID:
|
|
148
|
+
unique_id = generate_unique_id()
|
|
149
|
+
cache_dir = args.cache_dir if args.cache_dir else "~/.cache/mini_code/sessions/"
|
|
125
150
|
|
|
126
151
|
# LLM Related
|
|
127
152
|
server_url = f"{args.url}"
|
|
@@ -172,7 +197,7 @@ def main():
|
|
|
172
197
|
# Append the content as a user message after the system prompt
|
|
173
198
|
messages.append({"role": "user", "content": agent_md_content})
|
|
174
199
|
|
|
175
|
-
print_welcome(allowed_dir, server_url, args)
|
|
200
|
+
print_welcome(allowed_dir, server_url, args, unique_id, cache_dir)
|
|
176
201
|
|
|
177
202
|
# Agent Logic Flags
|
|
178
203
|
llm_response_flag = False
|
|
@@ -180,7 +205,10 @@ def main():
|
|
|
180
205
|
llm_repeat_flag = False
|
|
181
206
|
tool_count = 0
|
|
182
207
|
|
|
208
|
+
user_input = args.prompt
|
|
209
|
+
|
|
183
210
|
while True:
|
|
211
|
+
|
|
184
212
|
if llm_tool_response_flag and args.auto_mode: #skip user input and try to call the model again until there no more tool calls.
|
|
185
213
|
print(f"{BOLD}{YELLOW}System:{RESET} Skipping user input. Continuing with LLM calls until no more tool calls. [Tool count={tool_count}]")
|
|
186
214
|
llm_repeat_flag = True
|
|
@@ -190,23 +218,29 @@ def main():
|
|
|
190
218
|
print(f"{BOLD}{YELLOW}System:{RESET} Called {tool_count} tools in total. Exiting tool loop.")
|
|
191
219
|
|
|
192
220
|
tool_count = 0
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
221
|
+
if not user_input:
|
|
222
|
+
try:
|
|
223
|
+
print("-"*30)
|
|
224
|
+
user_input = input(f"{BOLD}{CYAN}You:{RESET} ")
|
|
225
|
+
if user_input.lower() in ["quit", "exit", "/quit", "/exit"]:
|
|
226
|
+
print("\nThank you. Goodbye! Saving history...")
|
|
227
|
+
save_history(messages, args, unique_id)
|
|
228
|
+
break
|
|
229
|
+
except KeyboardInterrupt:
|
|
197
230
|
print("\nThank you. Goodbye! Saving history...")
|
|
198
|
-
save_history(messages)
|
|
231
|
+
save_history(messages, args, unique_id)
|
|
199
232
|
break
|
|
200
|
-
|
|
201
|
-
print("
|
|
202
|
-
|
|
203
|
-
break
|
|
233
|
+
else:
|
|
234
|
+
print("-"*30)
|
|
235
|
+
print(f"{BOLD}{CYAN}You (preset): {RESET}{user_input}")
|
|
204
236
|
|
|
205
237
|
if user_input == "/help":
|
|
206
|
-
print_help(allowed_dir, server_url, args)
|
|
238
|
+
print_help(allowed_dir, server_url, args, unique_id, cache_dir)
|
|
239
|
+
user_input = ""
|
|
207
240
|
continue
|
|
208
241
|
|
|
209
242
|
messages.append({"role": "user", "content": user_input})
|
|
243
|
+
user_input = ""
|
|
210
244
|
|
|
211
245
|
llm_response_flag = False
|
|
212
246
|
llm_tool_response_flag = False
|
|
@@ -267,7 +301,7 @@ def main():
|
|
|
267
301
|
permission_input = input("Type: 'y' or 'yes'\n")
|
|
268
302
|
except KeyboardInterrupt:
|
|
269
303
|
print("\nThank you. Goodbye! Saving history...")
|
|
270
|
-
save_history(messages)
|
|
304
|
+
save_history(messages, args, unique_id)
|
|
271
305
|
sys.exit(0)
|
|
272
306
|
|
|
273
307
|
if not permission_input in ['y', 'yes']:
|
|
@@ -292,7 +326,12 @@ def main():
|
|
|
292
326
|
"content": str(result)
|
|
293
327
|
})
|
|
294
328
|
else:
|
|
295
|
-
print(f"{BOLD}{RED}
|
|
329
|
+
print(f"{BOLD}{RED}Error:{RESET} Unknown tool: {name}, params {params_str}")
|
|
330
|
+
messages.append({
|
|
331
|
+
"role": "tool",
|
|
332
|
+
"tool_call_id": call_id,
|
|
333
|
+
"content": f"Error: Unknown tool: {name}, params {params_str}"
|
|
334
|
+
})
|
|
296
335
|
else:
|
|
297
336
|
messages.append({
|
|
298
337
|
"role": "assistant",
|
|
@@ -303,7 +342,7 @@ def main():
|
|
|
303
342
|
if not llm_response_flag and not llm_tool_response_flag:
|
|
304
343
|
print(f"{BOLD}{RED}Warning:{RESET} No response was given by the LLM.")
|
|
305
344
|
|
|
306
|
-
save_history(messages)
|
|
345
|
+
save_history(messages, args, unique_id)
|
|
307
346
|
|
|
308
347
|
if __name__ == "__main__":
|
|
309
348
|
main()
|
|
@@ -6,7 +6,7 @@ def system_prompt(tools_dict=None, allowed_dir=None):
|
|
|
6
6
|
|
|
7
7
|
if tools_dict:
|
|
8
8
|
tool_descriptions = "\n".join([f"{name} : {data['description']}" for name, data in tools_dict.items()])
|
|
9
|
-
base_prompt = "You are a helpful AI assistant with access to the following tools:\n"
|
|
9
|
+
base_prompt = "You are a helpful AI assistant with access to the following tools (only):\n"
|
|
10
10
|
end_prompt = (
|
|
11
11
|
"Choose the most appropriate tool for the task at hand. "
|
|
12
12
|
"If a tool fails or you hit a limit, analyze the error and try a different approach. "
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mini-code-cli
|
|
3
|
-
Version: 0.0.8.
|
|
3
|
+
Version: 0.0.8.1
|
|
4
4
|
Summary: Minimal Coding CLI
|
|
5
5
|
Author-email: Nikolai Rozanov <nikolai.rozanov@gmail.com>
|
|
6
6
|
License: The MIT License (MIT)
|
|
@@ -63,6 +63,30 @@ Write an agent.md file for me that helps an LLM write efficient triton kernels,
|
|
|
63
63
|
```bash
|
|
64
64
|
mini-code --help
|
|
65
65
|
```
|
|
66
|
+
```
|
|
67
|
+
Agent loop for interacting with a language model
|
|
68
|
+
|
|
69
|
+
options:
|
|
70
|
+
-h, --help show this help message and exit
|
|
71
|
+
--url URL API host
|
|
72
|
+
--max-tokens MAX_TOKENS
|
|
73
|
+
Maximum tokens for LLM response
|
|
74
|
+
--temperature TEMPERATURE
|
|
75
|
+
Temperature for LLM
|
|
76
|
+
--model MODEL Model name
|
|
77
|
+
--api-key API_KEY API key for authentication. If not set, it tries to find it in env variable: MINI_CODE_API_KEY.
|
|
78
|
+
--cache-dir CACHE_DIR
|
|
79
|
+
The cache dir for the session histories.
|
|
80
|
+
--system-prompt SYSTEM_PROMPT
|
|
81
|
+
Replace system prompt, with a custom system prompt.
|
|
82
|
+
--auto-mode Whether to run the agent in `auto-mode'. Or default: `manual-mode'.
|
|
83
|
+
--agent-md AGENT_MD If the agent should use an agent-md file... (it will added after system message.)
|
|
84
|
+
--prompt PROMPT An initial prompt from the user...
|
|
85
|
+
--ask-permission Ask for permission before any tool call.
|
|
86
|
+
--allowed-dir ALLOWED_DIR
|
|
87
|
+
Allowed directory for file operations
|
|
88
|
+
--enable-shell Allow shell execution. Default: False
|
|
89
|
+
```
|
|
66
90
|
|
|
67
91
|
|
|
68
92
|
## (C) Nikolai Rozanov, 2026 - Present
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|