mini-code-cli 0.0.8.1__tar.gz → 0.0.8.3__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.
Files changed (25) hide show
  1. {mini_code_cli-0.0.8.1 → mini_code_cli-0.0.8.3}/PKG-INFO +52 -5
  2. mini_code_cli-0.0.8.3/README.md +118 -0
  3. mini_code_cli-0.0.8.3/mini_code_cli/agent_loop.py +589 -0
  4. mini_code_cli-0.0.8.3/mini_code_cli/shell_safety_utils.py +168 -0
  5. {mini_code_cli-0.0.8.1 → mini_code_cli-0.0.8.3}/mini_code_cli/tools.py +28 -17
  6. mini_code_cli-0.0.8.3/mini_code_cli/ui.py +326 -0
  7. {mini_code_cli-0.0.8.1 → mini_code_cli-0.0.8.3}/mini_code_cli/utils.py +72 -11
  8. {mini_code_cli-0.0.8.1 → mini_code_cli-0.0.8.3}/mini_code_cli.egg-info/PKG-INFO +52 -5
  9. {mini_code_cli-0.0.8.1 → mini_code_cli-0.0.8.3}/mini_code_cli.egg-info/SOURCES.txt +9 -1
  10. mini_code_cli-0.0.8.3/mini_code_cli.egg-info/requires.txt +1 -0
  11. {mini_code_cli-0.0.8.1 → mini_code_cli-0.0.8.3}/pyproject.toml +4 -3
  12. mini_code_cli-0.0.8.3/tests/test_agent_loop.py +66 -0
  13. mini_code_cli-0.0.8.3/tests/test_sandboxing.py +91 -0
  14. mini_code_cli-0.0.8.3/tests/test_shell_safety.py +103 -0
  15. mini_code_cli-0.0.8.3/tests/test_tools.py +62 -0
  16. mini_code_cli-0.0.8.3/tests/test_ui.py +126 -0
  17. mini_code_cli-0.0.8.1/README.md +0 -72
  18. mini_code_cli-0.0.8.1/mini_code_cli/agent_loop.py +0 -348
  19. {mini_code_cli-0.0.8.1 → mini_code_cli-0.0.8.3}/LICENSE +0 -0
  20. {mini_code_cli-0.0.8.1 → mini_code_cli-0.0.8.3}/mini_code_cli/__init__.py +0 -0
  21. {mini_code_cli-0.0.8.1 → mini_code_cli-0.0.8.3}/mini_code_cli/prompts.py +0 -0
  22. {mini_code_cli-0.0.8.1 → mini_code_cli-0.0.8.3}/mini_code_cli.egg-info/dependency_links.txt +0 -0
  23. {mini_code_cli-0.0.8.1 → mini_code_cli-0.0.8.3}/mini_code_cli.egg-info/entry_points.txt +0 -0
  24. {mini_code_cli-0.0.8.1 → mini_code_cli-0.0.8.3}/mini_code_cli.egg-info/top_level.txt +0 -0
  25. {mini_code_cli-0.0.8.1 → mini_code_cli-0.0.8.3}/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.1
3
+ Version: 0.0.8.3
4
4
  Summary: Minimal Coding CLI
5
5
  Author-email: Nikolai Rozanov <nikolai.rozanov@gmail.com>
6
6
  License: The MIT License (MIT)
@@ -16,6 +16,7 @@ Project-URL: Homepage, https://github.com/ai-nikolai/mini-code-cli
16
16
  Requires-Python: >=3.10
17
17
  Description-Content-Type: text/markdown
18
18
  License-File: LICENSE
19
+ Requires-Dist: requests<3,>=2.31
19
20
  Dynamic: license-file
20
21
 
21
22
  # A minimal coding agent cli
@@ -42,16 +43,25 @@ mini-code #run the agent using `localhost:30000/v1` model
42
43
  export MINI_CODE_API_KEY="sk-YOUR_API_KEY"
43
44
  mini-code --url "https://api.deepseek.com" --model "deepseek-v4-flash"
44
45
  ```
46
+ 3. Auto-mode and shell enabled: (this will run localhost:30000)
47
+ ```bash
48
+ mini-code --enable-shell --auto-mode
49
+ ```
45
50
 
51
+ 4. Advanced usage:
46
52
  Auto-mode, Agent.md, Shell Enabled mode and a specific allowed dir:
47
53
  ```bash
48
54
  mini-code --enable-shell --auto-mode --agent-md "./skill.md" --allowed-dir "./" --ask-permission --system-prompt "Your awesome new system prompt..."
49
55
  ```
50
56
  - auto-mode: the agent will continue querying the LLM and executing tools, until no more tool calls are possible
51
57
  - agent.md: this will read an agent.md file with the specified name (e.g. ./skill.md)
52
- - shell-enabled: **Be careful**: This will allow the agent to execute shell commands. Specifically, there is no permission checks.
53
- - allowed-dir: this specifies which dirs the agent can read and write from, that does not stop the shell comands!
54
- - ask-permission: asks user permission before every tool call.
58
+ - shell-enabled: **Be careful**: This will allow the agent to execute shell commands. **Every command is first checked by a shell-safety classifier** that sorts it into three tiers:
59
+ - **DENY** — obviously destructive commands (e.g. `rm -rf /`, `dd of=/dev/...`, `mkfs.*`, fork bombs) are **refused outright** and never run.
60
+ - **ASK** — risky commands (e.g. `rm file`, `sudo ...`, `chmod`, `curl ... | sh`) require your confirmation before running.
61
+ - **ALLOW** — clearly safe commands (e.g. `ls`, `cat`, `git status`) run without prompting.
62
+ This protection is **always enforced** for the shell tool, even in auto-mode / without `--ask-permission`, so the agent can never run dangerous commands unattended. (The classifier is a heuristic, not a sandbox — use with care.)
63
+ - allowed-dir: this specifies which dirs the agent can read and write from, that does not stop the shell comands! (though dangerous shell commands are still blocked by the classifier above).
64
+ - ask-permission: asks user permission before every tool call. For shell commands, commands in the ALLOW tier skip the prompt, DENY is blocked, and ASK always prompts.
55
65
  - system-prompt: you can override the default prompt by using a string. (Not Agent.md is always appended after the system prompt.)
56
66
 
57
67
  3. Try a prompt:
@@ -82,11 +92,48 @@ options:
82
92
  --auto-mode Whether to run the agent in `auto-mode'. Or default: `manual-mode'.
83
93
  --agent-md AGENT_MD If the agent should use an agent-md file... (it will added after system message.)
84
94
  --prompt PROMPT An initial prompt from the user...
85
- --ask-permission Ask for permission before any tool call.
95
+ --ask-permission Ask for permission before any tool call. (Shell ALLOW-tier commands skip the prompt; DENY is blocked.)
86
96
  --allowed-dir ALLOWED_DIR
87
97
  Allowed directory for file operations
88
98
  --enable-shell Allow shell execution. Default: False
89
99
  ```
90
100
 
101
+ ## Testing
102
+
103
+ The project ships with a small standard-library test suite (no extra dependencies to install):
104
+
105
+ ```bash
106
+ # Run the whole suite from the repo root:
107
+ python3 -m unittest discover -s tests -p "test_*.py"
108
+
109
+ # ...or run a single test file:
110
+ python3 tests/test_tools.py
111
+ python3 tests/test_sandboxing.py
112
+ python3 tests/test_agent_loop.py
113
+ python3 tests/test_shell_safety.py
114
+ ```
115
+
116
+ The tests focus on the parts of the agent that are easy to get wrong and worth guarding:
117
+
118
+ - **`test_sandboxing.py`** — the `--allowed-dir` sandbox. Verifies that child paths are allowed, while `..` traversal and sibling paths outside the allowed directory are rejected.
119
+ - **`test_tools.py`** — the tool functions. Confirms they *return* their results/errors (instead of printing), that `run_shell_command` captures stderr and honors a timeout, and that the generated tool schema exposes the expected parameters.
120
+ - **`test_agent_loop.py`** — agent-loop behaviour. Confirms that enabling the shell forces per-command permission prompts, that memory compaction is correctly wired (accepts token accounting), and that token-usage formatting handles servers that report no usage.
121
+ - **`test_shell_safety.py`** — the shell command classifier. Confirms commands are sorted into the three tiers correctly: destructive commands (`rm -rf /`, `dd of=/dev/...`, `mkfs.*`, fork bombs) are **DENY**, risky ones (`rm file`, `sudo`, `curl | sh`, redirects to `/etc/...`) are **ASK**, and safe ones (`ls`, `cat`, `git status`) are **ALLOW**.
122
+
123
+ This keeps the tool honest as it grows, and makes it safe to experiment with riskier features (like `--enable-shell`) without regressions.
124
+
125
+ ## Other useful commands:
126
+
127
+ ### Serving a vllm model locally (with correct tools). vllm v0.30 (tested):
128
+ ```bash
129
+ vllm serve ornith-ai/Ornith-1.5-397B-FP8 \
130
+ --tensor-parallel-size 4 \
131
+ --host 0.0.0.0 \
132
+ --port 30000 \
133
+ --enable-auto-tool-choice \
134
+ --tool-call-parser qwen3_xml \
135
+ --reasoning-parser qwen3 \
136
+ --trust-remote-code
137
+ ```
91
138
 
92
139
  ## (C) Nikolai Rozanov, 2026 - Present
@@ -0,0 +1,118 @@
1
+ # A minimal coding agent cli
2
+
3
+ > No bloat, no dependencies, no tracking, no telemetry...
4
+
5
+ Purpose: A no bloat, minimal coding cli, to enjoy experimenting and researching...
6
+
7
+ ## Getting started:
8
+
9
+ ### Installation (from pypi)
10
+ ```bash
11
+ pip3 install mini-code-cli
12
+ ```
13
+
14
+ ### Run agent:
15
+
16
+ 1. Basic usage: (get local LLM running (e.g. via SGLang or Vllm))
17
+ ```bash
18
+ mini-code #run the agent using `localhost:30000/v1` model
19
+ ```
20
+ 2. Custom API based model:
21
+ ```bash
22
+ export MINI_CODE_API_KEY="sk-YOUR_API_KEY"
23
+ mini-code --url "https://api.deepseek.com" --model "deepseek-v4-flash"
24
+ ```
25
+ 3. Auto-mode and shell enabled: (this will run localhost:30000)
26
+ ```bash
27
+ mini-code --enable-shell --auto-mode
28
+ ```
29
+
30
+ 4. Advanced usage:
31
+ Auto-mode, Agent.md, Shell Enabled mode and a specific allowed dir:
32
+ ```bash
33
+ mini-code --enable-shell --auto-mode --agent-md "./skill.md" --allowed-dir "./" --ask-permission --system-prompt "Your awesome new system prompt..."
34
+ ```
35
+ - auto-mode: the agent will continue querying the LLM and executing tools, until no more tool calls are possible
36
+ - agent.md: this will read an agent.md file with the specified name (e.g. ./skill.md)
37
+ - shell-enabled: **Be careful**: This will allow the agent to execute shell commands. **Every command is first checked by a shell-safety classifier** that sorts it into three tiers:
38
+ - **DENY** — obviously destructive commands (e.g. `rm -rf /`, `dd of=/dev/...`, `mkfs.*`, fork bombs) are **refused outright** and never run.
39
+ - **ASK** — risky commands (e.g. `rm file`, `sudo ...`, `chmod`, `curl ... | sh`) require your confirmation before running.
40
+ - **ALLOW** — clearly safe commands (e.g. `ls`, `cat`, `git status`) run without prompting.
41
+ This protection is **always enforced** for the shell tool, even in auto-mode / without `--ask-permission`, so the agent can never run dangerous commands unattended. (The classifier is a heuristic, not a sandbox — use with care.)
42
+ - allowed-dir: this specifies which dirs the agent can read and write from, that does not stop the shell comands! (though dangerous shell commands are still blocked by the classifier above).
43
+ - ask-permission: asks user permission before every tool call. For shell commands, commands in the ALLOW tier skip the prompt, DENY is blocked, and ASK always prompts.
44
+ - system-prompt: you can override the default prompt by using a string. (Not Agent.md is always appended after the system prompt.)
45
+
46
+ 3. Try a prompt:
47
+ ```txt
48
+ Write an agent.md file for me that helps an LLM write efficient triton kernels, given a reference implementation.
49
+ ```
50
+
51
+ 4. Get help:
52
+ ```bash
53
+ mini-code --help
54
+ ```
55
+ ```
56
+ Agent loop for interacting with a language model
57
+
58
+ options:
59
+ -h, --help show this help message and exit
60
+ --url URL API host
61
+ --max-tokens MAX_TOKENS
62
+ Maximum tokens for LLM response
63
+ --temperature TEMPERATURE
64
+ Temperature for LLM
65
+ --model MODEL Model name
66
+ --api-key API_KEY API key for authentication. If not set, it tries to find it in env variable: MINI_CODE_API_KEY.
67
+ --cache-dir CACHE_DIR
68
+ The cache dir for the session histories.
69
+ --system-prompt SYSTEM_PROMPT
70
+ Replace system prompt, with a custom system prompt.
71
+ --auto-mode Whether to run the agent in `auto-mode'. Or default: `manual-mode'.
72
+ --agent-md AGENT_MD If the agent should use an agent-md file... (it will added after system message.)
73
+ --prompt PROMPT An initial prompt from the user...
74
+ --ask-permission Ask for permission before any tool call. (Shell ALLOW-tier commands skip the prompt; DENY is blocked.)
75
+ --allowed-dir ALLOWED_DIR
76
+ Allowed directory for file operations
77
+ --enable-shell Allow shell execution. Default: False
78
+ ```
79
+
80
+ ## Testing
81
+
82
+ The project ships with a small standard-library test suite (no extra dependencies to install):
83
+
84
+ ```bash
85
+ # Run the whole suite from the repo root:
86
+ python3 -m unittest discover -s tests -p "test_*.py"
87
+
88
+ # ...or run a single test file:
89
+ python3 tests/test_tools.py
90
+ python3 tests/test_sandboxing.py
91
+ python3 tests/test_agent_loop.py
92
+ python3 tests/test_shell_safety.py
93
+ ```
94
+
95
+ The tests focus on the parts of the agent that are easy to get wrong and worth guarding:
96
+
97
+ - **`test_sandboxing.py`** — the `--allowed-dir` sandbox. Verifies that child paths are allowed, while `..` traversal and sibling paths outside the allowed directory are rejected.
98
+ - **`test_tools.py`** — the tool functions. Confirms they *return* their results/errors (instead of printing), that `run_shell_command` captures stderr and honors a timeout, and that the generated tool schema exposes the expected parameters.
99
+ - **`test_agent_loop.py`** — agent-loop behaviour. Confirms that enabling the shell forces per-command permission prompts, that memory compaction is correctly wired (accepts token accounting), and that token-usage formatting handles servers that report no usage.
100
+ - **`test_shell_safety.py`** — the shell command classifier. Confirms commands are sorted into the three tiers correctly: destructive commands (`rm -rf /`, `dd of=/dev/...`, `mkfs.*`, fork bombs) are **DENY**, risky ones (`rm file`, `sudo`, `curl | sh`, redirects to `/etc/...`) are **ASK**, and safe ones (`ls`, `cat`, `git status`) are **ALLOW**.
101
+
102
+ This keeps the tool honest as it grows, and makes it safe to experiment with riskier features (like `--enable-shell`) without regressions.
103
+
104
+ ## Other useful commands:
105
+
106
+ ### Serving a vllm model locally (with correct tools). vllm v0.30 (tested):
107
+ ```bash
108
+ vllm serve ornith-ai/Ornith-1.5-397B-FP8 \
109
+ --tensor-parallel-size 4 \
110
+ --host 0.0.0.0 \
111
+ --port 30000 \
112
+ --enable-auto-tool-choice \
113
+ --tool-call-parser qwen3_xml \
114
+ --reasoning-parser qwen3 \
115
+ --trust-remote-code
116
+ ```
117
+
118
+ ## (C) Nikolai Rozanov, 2026 - Present