mini-code-cli 0.1.1.3__tar.gz → 0.2.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.
Files changed (49) hide show
  1. {mini_code_cli-0.1.1.3 → mini_code_cli-0.2.0.0}/PKG-INFO +118 -18
  2. {mini_code_cli-0.1.1.3 → mini_code_cli-0.2.0.0}/README.md +117 -17
  3. mini_code_cli-0.2.0.0/mini_code_cli/agent_files.py +90 -0
  4. {mini_code_cli-0.1.1.3 → mini_code_cli-0.2.0.0}/mini_code_cli/agent_loop.py +962 -128
  5. mini_code_cli-0.2.0.0/mini_code_cli/background.py +494 -0
  6. mini_code_cli-0.2.0.0/mini_code_cli/compaction.py +245 -0
  7. {mini_code_cli-0.1.1.3 → mini_code_cli-0.2.0.0}/mini_code_cli/config.py +35 -19
  8. {mini_code_cli-0.1.1.3 → mini_code_cli-0.2.0.0}/mini_code_cli/permissions.py +15 -9
  9. {mini_code_cli-0.1.1.3 → mini_code_cli-0.2.0.0}/mini_code_cli/persistence.py +14 -7
  10. mini_code_cli-0.2.0.0/mini_code_cli/planning.py +29 -0
  11. {mini_code_cli-0.1.1.3 → mini_code_cli-0.2.0.0}/mini_code_cli/prompts.py +144 -6
  12. {mini_code_cli-0.1.1.3 → mini_code_cli-0.2.0.0}/mini_code_cli/runner.py +17 -3
  13. {mini_code_cli-0.1.1.3 → mini_code_cli-0.2.0.0}/mini_code_cli/sandbox.py +1 -0
  14. {mini_code_cli-0.1.1.3 → mini_code_cli-0.2.0.0}/mini_code_cli/subagents/__init__.py +4 -3
  15. {mini_code_cli-0.1.1.3 → mini_code_cli-0.2.0.0}/mini_code_cli/subagents/base.py +66 -9
  16. {mini_code_cli-0.1.1.3 → mini_code_cli-0.2.0.0}/mini_code_cli/subagents/builtin.py +10 -9
  17. {mini_code_cli-0.1.1.3 → mini_code_cli-0.2.0.0}/mini_code_cli/tokens.py +66 -0
  18. {mini_code_cli-0.1.1.3 → mini_code_cli-0.2.0.0}/mini_code_cli/tools.py +302 -48
  19. mini_code_cli-0.2.0.0/mini_code_cli/tui.py +1046 -0
  20. {mini_code_cli-0.1.1.3 → mini_code_cli-0.2.0.0}/mini_code_cli/ui.py +216 -15
  21. {mini_code_cli-0.1.1.3 → mini_code_cli-0.2.0.0}/mini_code_cli/utils.py +116 -62
  22. {mini_code_cli-0.1.1.3 → mini_code_cli-0.2.0.0}/mini_code_cli.egg-info/PKG-INFO +118 -18
  23. {mini_code_cli-0.1.1.3 → mini_code_cli-0.2.0.0}/mini_code_cli.egg-info/SOURCES.txt +13 -1
  24. {mini_code_cli-0.1.1.3 → mini_code_cli-0.2.0.0}/pyproject.toml +8 -3
  25. mini_code_cli-0.2.0.0/tests/test_advanced_features.py +459 -0
  26. mini_code_cli-0.2.0.0/tests/test_background.py +221 -0
  27. mini_code_cli-0.2.0.0/tests/test_cli_features.py +177 -0
  28. mini_code_cli-0.2.0.0/tests/test_config.py +82 -0
  29. {mini_code_cli-0.1.1.3 → mini_code_cli-0.2.0.0}/tests/test_e2e_agent_loop.py +53 -1
  30. {mini_code_cli-0.1.1.3 → mini_code_cli-0.2.0.0}/tests/test_interactive.py +78 -5
  31. {mini_code_cli-0.1.1.3 → mini_code_cli-0.2.0.0}/tests/test_permissions.py +8 -0
  32. {mini_code_cli-0.1.1.3 → mini_code_cli-0.2.0.0}/tests/test_runner.py +13 -0
  33. {mini_code_cli-0.1.1.3 → mini_code_cli-0.2.0.0}/tests/test_subagents.py +89 -0
  34. {mini_code_cli-0.1.1.3 → mini_code_cli-0.2.0.0}/tests/test_tokens.py +29 -2
  35. mini_code_cli-0.2.0.0/tests/test_tools.py +225 -0
  36. mini_code_cli-0.2.0.0/tests/test_tui.py +1148 -0
  37. mini_code_cli-0.2.0.0/tests/test_utils.py +111 -0
  38. {mini_code_cli-0.1.1.3 → mini_code_cli-0.2.0.0}/LICENSE +0 -0
  39. {mini_code_cli-0.1.1.3 → mini_code_cli-0.2.0.0}/mini_code_cli/__init__.py +0 -0
  40. {mini_code_cli-0.1.1.3 → mini_code_cli-0.2.0.0}/mini_code_cli/__main__.py +0 -0
  41. {mini_code_cli-0.1.1.3 → mini_code_cli-0.2.0.0}/mini_code_cli/plan.py +0 -0
  42. {mini_code_cli-0.1.1.3 → mini_code_cli-0.2.0.0}/mini_code_cli/shell_safety_utils.py +0 -0
  43. {mini_code_cli-0.1.1.3 → mini_code_cli-0.2.0.0}/mini_code_cli/skills.py +0 -0
  44. {mini_code_cli-0.1.1.3 → mini_code_cli-0.2.0.0}/mini_code_cli.egg-info/dependency_links.txt +0 -0
  45. {mini_code_cli-0.1.1.3 → mini_code_cli-0.2.0.0}/mini_code_cli.egg-info/entry_points.txt +0 -0
  46. {mini_code_cli-0.1.1.3 → mini_code_cli-0.2.0.0}/mini_code_cli.egg-info/requires.txt +0 -0
  47. {mini_code_cli-0.1.1.3 → mini_code_cli-0.2.0.0}/mini_code_cli.egg-info/top_level.txt +0 -0
  48. {mini_code_cli-0.1.1.3 → mini_code_cli-0.2.0.0}/setup.cfg +0 -0
  49. {mini_code_cli-0.1.1.3 → mini_code_cli-0.2.0.0}/tests/test_release_script.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mini-code-cli
3
- Version: 0.1.1.3
3
+ Version: 0.2.0.0
4
4
  Summary: Mini Coding Agent. Allows you to easily experiment with a small coding agent.
5
5
  Author-email: Nikolai Rozanov <nikolai.rozanov@gmail.com>
6
6
  License-Expression: AGPL-3.0-only
@@ -67,7 +67,7 @@ mini-code --url "https://api.deepseek.com" --model "deepseek-v4-flash"
67
67
  **3 — The shortcuts** (plan mode, sub-agents, shell, auto-mode, no permission prompts):
68
68
 
69
69
  ```bash
70
- mini-code --all # = --plan --enable-subagents --enable-shell --auto-mode --sudo
70
+ mini-code --all # = --plan --enable-subagents --enable-shell --skills --auto-mode --sudo --background
71
71
  mini-code --all-last # ...and continue your last session
72
72
  ```
73
73
 
@@ -95,20 +95,25 @@ given a reference implementation.
95
95
  | `--prompt TEXT` | — | initial user prompt |
96
96
  | `-a`, `--auto-mode` | off | keep querying the model and running tools until no tool calls remain |
97
97
  | `--agent-md FILE` | — | append an `agent.md` file after the system prompt (e.g. `./skill.md`) |
98
- | `--ask-permission` | off | ask before every tool call (ALLOW-tier shell commands still skip the prompt) |
98
+ | `--ask-permission` | off | ask before **every** tool call, including an ALLOW-tier shell command (`--sudo` disables all prompts) |
99
99
  | `--sudo` | off | **dangerous:** never ask. DENY-tier commands are still refused |
100
100
  | `--allowed-dir DIR` | `./` | sandbox for **file** tools (does not restrict the shell) |
101
101
  | `-s`, `--enable-shell` | off | allow shell execution (classifier always applies) |
102
102
  | `-g`, `--enable-subagents` | off | expose sub-agents as tools |
103
- | `--skills` | off | enable the `.mini` skills directory (`skill.md`s, `SKILLS.md`, runnable scripts) |
104
- | `-p`, `--plan` | off | plan mode (`CURRENT_GOAL.md` / `CURRENT_PLAN.md`, `/plan`) |
103
+ | `--background` | off | enable background shell/sub-agent tasks and the `background` tool; needs `--enable-shell` or `--enable-subagents` |
104
+ | `--tui [auto\|on\|off]` | `auto` | fixed full-screen dashboard. `auto` enables it only on a known interactive TTY; `on` forces it; `off` uses the scrolling console |
105
+ | `--skills` | off | enable the `.mini` skills directory (`skill.md`s, `SKILLS.md`, runnable scripts). **`run_skill` executes those Python scripts — arbitrary code execution, even without `--enable-shell`**; only enable it for a directory you trust |
106
+ | `-p`, `--plan` | off | plan mode (`CURRENT_GOAL.md` / `CURRENT_PLAN.md`, printed plan, `/plan`, `/skip-plan`) |
107
+ | `--plan-strategy NAME` | `plan-verify-step` | `plan-verify-step`, `plan-verify` or `open-plan` (implies `--plan`) |
108
+ | `--scratchpad` | off | give the agent a free-form `.mini/SCRATCHPAD.md` (plus further scratch files) for thoughts, plans and learnings |
109
+ | `--compaction-strategy NAME` | `summarise` | `summarise`, `predict-files` or `predict-messages` |
105
110
  | `--llm-timeout S` | `500` | HTTP timeout for LLM requests |
106
111
  | `--tool-timeout S` | `120` | timeout for a single tool call |
107
112
  | `--max-context-tokens N` | derived | input-token budget before the history is compacted |
108
113
  | `--cache-dir DIR` | `~/.cache/mini/sessions/` | where session histories are stored |
109
114
  | `--restore-session PATH` | — | continue a specific previous session |
110
115
  | `-l`, `--load-last-session` | off | continue the session recorded in the `.mini` pointer |
111
- | `--all` | off | `--plan --enable-subagents --enable-shell --auto-mode --sudo` |
116
+ | `--all` | off | `--plan --enable-subagents --enable-shell --skills --auto-mode --sudo --background` |
112
117
  | `--all-last` | off | `--all` + `--load-last-session` |
113
118
  | `--verbose` | off | print full detail (default: user/assistant turns, token usage, tool calls only) |
114
119
  | `-h`, `--help` | — | show the built-in help |
@@ -120,14 +125,15 @@ parameter a model does not need is defaulted, so omitting it keeps the previous
120
125
 
121
126
  | Tool | What it does |
122
127
  | --- | --- |
123
- | `read_file` | read a file; `offset` (1-based line) and `limit` page through large files |
128
+ | `read_file` | read a file; `offset` (1-based line) and `limit` page through large files. Output is capped at 100k characters, so page or narrow instead of relying on a whole-file read |
124
129
  | `write_file` | write/overwrite; `append` adds to the end, `create_dirs` creates parents |
125
130
  | `edit` | replace an **exact** string (`old_string` → `new_string`); refuses a missing or ambiguous match unless `replace_all` |
126
- | `grep` | regex search a file or directory; `recursive`, `include`, `ignore_case`, `line_numbers`, `max_results` (noise dirs skipped) |
127
- | `glob` | list files matching a glob (one per line, `**` supported), optionally against a `root` |
131
+ | `grep` | regex search a file or directory; `recursive`, `include`, `ignore_case`, `line_numbers`, `max_results` (noise dirs skipped). Output is capped at 100k characters |
132
+ | `glob` | list files matching a glob (one per line, `**` supported), optionally against a `root`; capped at 2000 matches / 100k characters |
128
133
  | `web_search` | best-effort lookup: related queries + a short Wikipedia extract. Never raises |
129
- | `read_website` | fetch raw text/HTML of a URL (bounded by `--tool-timeout`), `max_chars` caps size |
134
+ | `read_website` | fetch raw text/HTML of a **public http/https** URL (other schemes and private/link-local hosts are rejected; `MINI_CODE_ALLOW_PRIVATE_URLS=1` overrides); `max_chars` caps size |
130
135
  | `run_shell_command` | run a shell command (needs `--enable-shell`); `cwd`, `timeout`, and stdout/stderr/exit code are all reported |
136
+ | `background` | start/list/output/wait/cancel background **shell** tasks (needs `--background --enable-shell`) or **sub-agent** tasks (needs `--background --enable-subagents`); output is captured in a per-task log |
131
137
 
132
138
  ## Sub-agents
133
139
 
@@ -151,8 +157,10 @@ mini-code --enable-subagents # the available sub-agents then show up in /h
151
157
 
152
158
  > [!NOTE]
153
159
  > A sub-agent's `tools`, `enable_shell` and `max_steps` are always **intersected with the
154
- > parent's** permissions, so it can never do anything the main agent could not. Sub-agents
155
- > compose with `--plan`: each keeps its own `CURRENT_PLAN.md` / `CURRENT_GOAL.md`.
160
+ > parent's** permissions, so it can never do anything the main agent could not. The `tools`
161
+ > allowlist is enforced on the nested session itself (both the schemas offered to the model and
162
+ > the dispatch table), not merely described in its prompt. Sub-agents compose with `--plan`:
163
+ > each keeps its own `CURRENT_PLAN.md` / `CURRENT_GOAL.md`.
156
164
 
157
165
  <details>
158
166
  <summary><b>Adding your own sub-agent</b></summary>
@@ -180,6 +188,24 @@ to the model automatically when `--enable-subagents` is set. See
180
188
 
181
189
  </details>
182
190
 
191
+ ## Background tasks
192
+
193
+ When `--background` is enabled together with shell execution or sub-agents, the agent also gets a `background` tool:
194
+
195
+ - `background(action="start", command="pytest -q")` starts a long command in its own process group;
196
+ - `background(action="start", kind="subagent", subagent="software_engineer", task="...")` starts
197
+ a nested agent task;
198
+ - `list`, `output`, `wait` and `cancel` inspect or control the tasks.
199
+
200
+ Each task has an id (`bg-1`), a status, a log under the session folder
201
+ (`background/bg-1.log`), an output tail, and a cancellation path. Shell tasks are killed as a
202
+ process group; sub-agent tasks receive a cancellation event between steps. Background tasks are
203
+ session-local and do not survive a restart (the logs do).
204
+
205
+ Use `/background` to see the foreground activity and all tasks, or `/background bg-1` for one
206
+ task's output. Note that the main loop is synchronous, so `/background` can be typed between
207
+ steps; it shows the last/current blocking activity rather than live-during the call.
208
+
183
209
  ## In-session commands
184
210
 
185
211
  | Command | What it does |
@@ -190,9 +216,40 @@ to the model automatically when `--enable-subagents` is set. See
190
216
  | `/reset [<n>]` | rewind to the end of turn `n` (`last` works too); drops everything after it |
191
217
  | `/clear` | clear the screen (keeps the conversation history) |
192
218
  | `/plan` | show the current goal + plan (plan mode only) |
219
+ | `/context` | show how the context window is used: tokens and percentages by category (system prompt, user/assistant messages, tool calls/outputs, reasoning, overhead) |
220
+ | `/background [id]` | show foreground activity + background tasks, or one task's output tail |
221
+ | `/expand [n]` | show the full detail of the nth most recent tool call (default: the last one) |
222
+ | `/skip-plan <prompt>` | send `<prompt>` once without generating or reviewing a plan |
193
223
  | `/help` | show this help |
194
224
  | `/quit`, `/exit` | save the session and exit |
195
225
 
226
+ **Multi-line input:** press `Shift+Enter` (or `Ctrl-J`) to insert a newline; plain
227
+ `Enter` sends the turn. This works in the session prompt and the startup tip
228
+ reminds you. Terminals that report `Shift+Enter` as a CSI-u/modifyOtherKeys
229
+ sequence are recognised; elsewhere `Ctrl-J` inserts the newline.
230
+
231
+ With `--tui`, mini-code switches to a fixed alternate-screen dashboard: a
232
+ **Mini-Code** summary box (version/session/model/context) at the top, a core
233
+ conversation view of user/assistant turns in the middle, and an input box with
234
+ a one-line help hint at the bottom. The whole screen is redrawn on changes, so the view never
235
+ scrolls; tool/thinking status is a transient line that disappears when the
236
+ operation finishes. `Shift+↑`/`Shift+↓` scroll the middle pane one line at a
237
+ time and show `(lines scrolled / total)`; `Esc` returns to the bottom or closes
238
+ command output (`/help`, `/history`, ...). Info/warnings sit below a small
239
+ separator at the bottom of the body. The dashboard is coloured when the
240
+ terminal supports it; info/warnings/errors are shown as coloured
241
+ `ℹ`/`⚠`/`✖`/`✔` lines. Each assistant block also carries a dim line with
242
+ that turn's tool calls, background tasks and assistant-message count.
243
+ Questions (resume/permission) use a yellow "Question to User" box just above
244
+ the input. Restored sessions load their history into
245
+ the core view and mark the summary as `[restored]`; generated plans append to
246
+ the core view. Tool details can be expanded with `/expand [n]`.
247
+
248
+ The prompt has a small line editor: `↑`/`↓` recall previous turns, `←`/`→` move
249
+ the cursor, Home/End jump within the line, and `Ctrl-A/E/K/U/L` provide the
250
+ usual editing/clear shortcuts. `--tui` defaults to `auto` (known TTY only); use `--tui=off` for the old
251
+ scrolling console or `--tui=on` to force it. It is not part of `--all`.
252
+
196
253
  > [!NOTE]
197
254
  > `/history` and `/reset` are driven by `summary_history.json`, a flat recorder that maps every
198
255
  > turn to the `history_{n}.json` segment and message index it lives in — so no full history is
@@ -251,6 +308,9 @@ command into one of three tiers:
251
308
  | **ASK** | `rm file`, `sudo ...`, `chmod`, `curl ... \| sh` | requires your confirmation |
252
309
  | **ALLOW** | `ls`, `cat`, `git status` | runs without prompting |
253
310
 
311
+ `--sudo` removes the confirmation prompts (ASK tier and `--ask-permission`); DENY commands are
312
+ still refused. With no flags, an ASK-tier command prompts and an ALLOW-tier one runs unaided.
313
+
254
314
  > [!WARNING]
255
315
  > The classifier is **always enforced** — even in auto-mode and with `--sudo` — so the agent
256
316
  > cannot run destructive commands unattended. It is a heuristic, not a sandbox: use it with care.
@@ -261,13 +321,34 @@ command into one of three tiers:
261
321
  The loop keeps two human-readable tracking files in the session directory: `CURRENT_GOAL.md`
262
322
  (your latest instruction) and `CURRENT_PLAN.md` (a step-by-step plan for that goal, marked
263
323
  finished when it is done). They are authored by the *loop*, not the agent, live outside
264
- `--allowed-dir`, and can be inspected any time with `/plan`.
324
+ `--allowed-dir`, and can be inspected any time with `/plan`. The generated plan is
325
+ also printed as a box right after planning, so you can see it without asking.
326
+ Use `/skip-plan <prompt>` to send one prompt without planning it (plan mode stays
327
+ on for later turns).
328
+
329
+ `--plan-strategy` selects how planning is wired:
330
+
331
+ | Strategy | What happens |
332
+ | --- | --- |
333
+ | `plan-verify-step` (default) | Current behaviour: author a plan, review it once the work settles, then run one extra step and keep whatever that step says. |
334
+ | `plan-verify` | Same plan + review, but the post-review step is kept only when it calls a tool. A no-tool answer is shown to you and ends the turn without being appended to the transcript. |
335
+ | `open-plan` | The agent owns a plan document at `.mini/PLAN.md` inside `--allowed-dir`, reads and updates it with the normal file tools, and the loop neither authors nor reviews a plan. |
265
336
 
266
337
  > [!NOTE]
267
338
  > Plan mode also changes **history compaction**: after the transcript is compacted to a summary,
268
339
  > `CURRENT_PLAN.md` and `CURRENT_GOAL.md` are re-injected, so the agent keeps working against the
269
- > same goal. When the work looks done the plan is reviewed and any outstanding task is re-queued
270
- > before the agent returns to you.
340
+ > same goal. With `open-plan`, the agent's `.mini/PLAN.md` is re-injected instead. When the work
341
+ > looks done the plan is reviewed and any outstanding task is re-queued before the agent returns
342
+ > to you (except with `open-plan`).
343
+
344
+ ### Scratchpad — `--scratchpad`
345
+
346
+ With `--scratchpad`, the loop creates `.mini/SCRATCHPAD.md` inside `--allowed-dir` and tells the
347
+ agent that it may read and write that file freely, and may create additional scratch files in the
348
+ same directory (for example `SCRATCH-NOTES.md`, `SCRATCH-IDEAS.md`). The scratchpad is ordinary
349
+ state inside the sandbox, so the normal `read_file` / `write_file` / `edit` tools work; no special
350
+ tool is registered. It is meant for the agent's own thoughts, plans, learnings and open questions,
351
+ and survives a history compaction because it lives on disk.
271
352
 
272
353
  ### Sessions — resume, or start fresh
273
354
 
@@ -315,6 +396,20 @@ waiting on) is kept verbatim after the summary. So a compaction that fires just
315
396
  instruction cannot swallow it — the model still answers what you asked, and the turn stays in
316
397
  the session file, in `/history` and in a later restore.
317
398
 
399
+ `--compaction-strategy` chooses what else survives besides the summary:
400
+
401
+ | Strategy | Messages after compaction |
402
+ | --- | --- |
403
+ | `summarise` (default) | `system`, `summary`, `plan`, `current turn` |
404
+ | `predict-files` | `system`, `summary`, predicted read-only tool calls + results, `plan`, `current turn` |
405
+ | `predict-messages` | `system`, `summary`, original messages the model names by index, `plan`, `current turn` |
406
+
407
+ `predict-files` asks the model which files it needs to re-read and executes only the read-only
408
+ tools (`read_file`, `grep`, `glob`) it predicts; `predict-messages` asks for a JSON array of
409
+ 0-based message indexes to keep verbatim. Both predictions are one extra tool-free (or
410
+ read-only-tool) LLM call, are billed normally, and are capped so they cannot refill the context
411
+ they just freed. A failed prediction degrades to the plain summary.
412
+
318
413
  Because a rollover leaves no trace in the transcript (the old turns really are gone), the
319
414
  console says in plain terms what happened — all of it without `--verbose`:
320
415
 
@@ -334,19 +429,24 @@ transcript and the segment left untouched.
334
429
  ### Exiting — the good-bye box
335
430
 
336
431
  Quitting (`/quit`, `exit`, or EOF on stdin) saves the session and then prints a short yellow
337
- box: the version, a sign-off, and what the session left behind — session id, folder, the
338
- history segments on disk, how many turns were recorded, and the token / call totals.
432
+ box: the version, a sign-off, and what the session left behind — session id, model, folder,
433
+ the history segments on disk, how many turns were recorded, run duration, token / call totals,
434
+ background tasks cancelled on exit, and a `--load-last-session` resume hint.
339
435
 
340
436
  ```
341
437
  ╔══════════ MiniCodeCLI v0.1.1.2 - goodbye ═════════════════════╗
342
438
  ║ Goodbye, and thanks for using MiniCodeCLI! ║
343
439
  ║ ║
344
440
  ║ session id : 1792666273983619-36ca3c2e ║
441
+ ║ model : ornith-ai/Ornith-1.5-35B-A3B ║
345
442
  ║ saved under : ~/.cache/mini/sessions/1792…-36ca3c2e/ ║
346
443
  ║ history : history_0.json (segment 0), 5 messages ║
347
444
  ║ conversation : 2 recorded turns ║
445
+ ║ duration : 12m 34s ║
348
446
  ║ tokens : 20 in / 10 out (30 total) ║
349
447
  ║ calls : 2 LLM, 0 tool ║
448
+ ║ background : none running ║
449
+ ║ resume : mini-code --load-last-session ║
350
450
  ╚═══════════════════════════════════════════════════════════════╝
351
451
  ```
352
452
 
@@ -379,7 +479,7 @@ If you use `mini-code-cli` in your research or writing, please cite it:
379
479
  author = {Rozanov, Nikolai},
380
480
  title = {mini-code-cli: A minimal, dependency-light coding agent},
381
481
  year = {2026},
382
- version = {0.1.1.2},
482
+ version = {0.2.0.0},
383
483
  howpublished = {\url{https://github.com/ai-nikolai/mini-code-cli}},
384
484
  note = {A no-bloat, dependency-light agent CLI for experimenting.}
385
485
  }
@@ -48,7 +48,7 @@ mini-code --url "https://api.deepseek.com" --model "deepseek-v4-flash"
48
48
  **3 — The shortcuts** (plan mode, sub-agents, shell, auto-mode, no permission prompts):
49
49
 
50
50
  ```bash
51
- mini-code --all # = --plan --enable-subagents --enable-shell --auto-mode --sudo
51
+ mini-code --all # = --plan --enable-subagents --enable-shell --skills --auto-mode --sudo --background
52
52
  mini-code --all-last # ...and continue your last session
53
53
  ```
54
54
 
@@ -76,20 +76,25 @@ given a reference implementation.
76
76
  | `--prompt TEXT` | — | initial user prompt |
77
77
  | `-a`, `--auto-mode` | off | keep querying the model and running tools until no tool calls remain |
78
78
  | `--agent-md FILE` | — | append an `agent.md` file after the system prompt (e.g. `./skill.md`) |
79
- | `--ask-permission` | off | ask before every tool call (ALLOW-tier shell commands still skip the prompt) |
79
+ | `--ask-permission` | off | ask before **every** tool call, including an ALLOW-tier shell command (`--sudo` disables all prompts) |
80
80
  | `--sudo` | off | **dangerous:** never ask. DENY-tier commands are still refused |
81
81
  | `--allowed-dir DIR` | `./` | sandbox for **file** tools (does not restrict the shell) |
82
82
  | `-s`, `--enable-shell` | off | allow shell execution (classifier always applies) |
83
83
  | `-g`, `--enable-subagents` | off | expose sub-agents as tools |
84
- | `--skills` | off | enable the `.mini` skills directory (`skill.md`s, `SKILLS.md`, runnable scripts) |
85
- | `-p`, `--plan` | off | plan mode (`CURRENT_GOAL.md` / `CURRENT_PLAN.md`, `/plan`) |
84
+ | `--background` | off | enable background shell/sub-agent tasks and the `background` tool; needs `--enable-shell` or `--enable-subagents` |
85
+ | `--tui [auto\|on\|off]` | `auto` | fixed full-screen dashboard. `auto` enables it only on a known interactive TTY; `on` forces it; `off` uses the scrolling console |
86
+ | `--skills` | off | enable the `.mini` skills directory (`skill.md`s, `SKILLS.md`, runnable scripts). **`run_skill` executes those Python scripts — arbitrary code execution, even without `--enable-shell`**; only enable it for a directory you trust |
87
+ | `-p`, `--plan` | off | plan mode (`CURRENT_GOAL.md` / `CURRENT_PLAN.md`, printed plan, `/plan`, `/skip-plan`) |
88
+ | `--plan-strategy NAME` | `plan-verify-step` | `plan-verify-step`, `plan-verify` or `open-plan` (implies `--plan`) |
89
+ | `--scratchpad` | off | give the agent a free-form `.mini/SCRATCHPAD.md` (plus further scratch files) for thoughts, plans and learnings |
90
+ | `--compaction-strategy NAME` | `summarise` | `summarise`, `predict-files` or `predict-messages` |
86
91
  | `--llm-timeout S` | `500` | HTTP timeout for LLM requests |
87
92
  | `--tool-timeout S` | `120` | timeout for a single tool call |
88
93
  | `--max-context-tokens N` | derived | input-token budget before the history is compacted |
89
94
  | `--cache-dir DIR` | `~/.cache/mini/sessions/` | where session histories are stored |
90
95
  | `--restore-session PATH` | — | continue a specific previous session |
91
96
  | `-l`, `--load-last-session` | off | continue the session recorded in the `.mini` pointer |
92
- | `--all` | off | `--plan --enable-subagents --enable-shell --auto-mode --sudo` |
97
+ | `--all` | off | `--plan --enable-subagents --enable-shell --skills --auto-mode --sudo --background` |
93
98
  | `--all-last` | off | `--all` + `--load-last-session` |
94
99
  | `--verbose` | off | print full detail (default: user/assistant turns, token usage, tool calls only) |
95
100
  | `-h`, `--help` | — | show the built-in help |
@@ -101,14 +106,15 @@ parameter a model does not need is defaulted, so omitting it keeps the previous
101
106
 
102
107
  | Tool | What it does |
103
108
  | --- | --- |
104
- | `read_file` | read a file; `offset` (1-based line) and `limit` page through large files |
109
+ | `read_file` | read a file; `offset` (1-based line) and `limit` page through large files. Output is capped at 100k characters, so page or narrow instead of relying on a whole-file read |
105
110
  | `write_file` | write/overwrite; `append` adds to the end, `create_dirs` creates parents |
106
111
  | `edit` | replace an **exact** string (`old_string` → `new_string`); refuses a missing or ambiguous match unless `replace_all` |
107
- | `grep` | regex search a file or directory; `recursive`, `include`, `ignore_case`, `line_numbers`, `max_results` (noise dirs skipped) |
108
- | `glob` | list files matching a glob (one per line, `**` supported), optionally against a `root` |
112
+ | `grep` | regex search a file or directory; `recursive`, `include`, `ignore_case`, `line_numbers`, `max_results` (noise dirs skipped). Output is capped at 100k characters |
113
+ | `glob` | list files matching a glob (one per line, `**` supported), optionally against a `root`; capped at 2000 matches / 100k characters |
109
114
  | `web_search` | best-effort lookup: related queries + a short Wikipedia extract. Never raises |
110
- | `read_website` | fetch raw text/HTML of a URL (bounded by `--tool-timeout`), `max_chars` caps size |
115
+ | `read_website` | fetch raw text/HTML of a **public http/https** URL (other schemes and private/link-local hosts are rejected; `MINI_CODE_ALLOW_PRIVATE_URLS=1` overrides); `max_chars` caps size |
111
116
  | `run_shell_command` | run a shell command (needs `--enable-shell`); `cwd`, `timeout`, and stdout/stderr/exit code are all reported |
117
+ | `background` | start/list/output/wait/cancel background **shell** tasks (needs `--background --enable-shell`) or **sub-agent** tasks (needs `--background --enable-subagents`); output is captured in a per-task log |
112
118
 
113
119
  ## Sub-agents
114
120
 
@@ -132,8 +138,10 @@ mini-code --enable-subagents # the available sub-agents then show up in /h
132
138
 
133
139
  > [!NOTE]
134
140
  > A sub-agent's `tools`, `enable_shell` and `max_steps` are always **intersected with the
135
- > parent's** permissions, so it can never do anything the main agent could not. Sub-agents
136
- > compose with `--plan`: each keeps its own `CURRENT_PLAN.md` / `CURRENT_GOAL.md`.
141
+ > parent's** permissions, so it can never do anything the main agent could not. The `tools`
142
+ > allowlist is enforced on the nested session itself (both the schemas offered to the model and
143
+ > the dispatch table), not merely described in its prompt. Sub-agents compose with `--plan`:
144
+ > each keeps its own `CURRENT_PLAN.md` / `CURRENT_GOAL.md`.
137
145
 
138
146
  <details>
139
147
  <summary><b>Adding your own sub-agent</b></summary>
@@ -161,6 +169,24 @@ to the model automatically when `--enable-subagents` is set. See
161
169
 
162
170
  </details>
163
171
 
172
+ ## Background tasks
173
+
174
+ When `--background` is enabled together with shell execution or sub-agents, the agent also gets a `background` tool:
175
+
176
+ - `background(action="start", command="pytest -q")` starts a long command in its own process group;
177
+ - `background(action="start", kind="subagent", subagent="software_engineer", task="...")` starts
178
+ a nested agent task;
179
+ - `list`, `output`, `wait` and `cancel` inspect or control the tasks.
180
+
181
+ Each task has an id (`bg-1`), a status, a log under the session folder
182
+ (`background/bg-1.log`), an output tail, and a cancellation path. Shell tasks are killed as a
183
+ process group; sub-agent tasks receive a cancellation event between steps. Background tasks are
184
+ session-local and do not survive a restart (the logs do).
185
+
186
+ Use `/background` to see the foreground activity and all tasks, or `/background bg-1` for one
187
+ task's output. Note that the main loop is synchronous, so `/background` can be typed between
188
+ steps; it shows the last/current blocking activity rather than live-during the call.
189
+
164
190
  ## In-session commands
165
191
 
166
192
  | Command | What it does |
@@ -171,9 +197,40 @@ to the model automatically when `--enable-subagents` is set. See
171
197
  | `/reset [<n>]` | rewind to the end of turn `n` (`last` works too); drops everything after it |
172
198
  | `/clear` | clear the screen (keeps the conversation history) |
173
199
  | `/plan` | show the current goal + plan (plan mode only) |
200
+ | `/context` | show how the context window is used: tokens and percentages by category (system prompt, user/assistant messages, tool calls/outputs, reasoning, overhead) |
201
+ | `/background [id]` | show foreground activity + background tasks, or one task's output tail |
202
+ | `/expand [n]` | show the full detail of the nth most recent tool call (default: the last one) |
203
+ | `/skip-plan <prompt>` | send `<prompt>` once without generating or reviewing a plan |
174
204
  | `/help` | show this help |
175
205
  | `/quit`, `/exit` | save the session and exit |
176
206
 
207
+ **Multi-line input:** press `Shift+Enter` (or `Ctrl-J`) to insert a newline; plain
208
+ `Enter` sends the turn. This works in the session prompt and the startup tip
209
+ reminds you. Terminals that report `Shift+Enter` as a CSI-u/modifyOtherKeys
210
+ sequence are recognised; elsewhere `Ctrl-J` inserts the newline.
211
+
212
+ With `--tui`, mini-code switches to a fixed alternate-screen dashboard: a
213
+ **Mini-Code** summary box (version/session/model/context) at the top, a core
214
+ conversation view of user/assistant turns in the middle, and an input box with
215
+ a one-line help hint at the bottom. The whole screen is redrawn on changes, so the view never
216
+ scrolls; tool/thinking status is a transient line that disappears when the
217
+ operation finishes. `Shift+↑`/`Shift+↓` scroll the middle pane one line at a
218
+ time and show `(lines scrolled / total)`; `Esc` returns to the bottom or closes
219
+ command output (`/help`, `/history`, ...). Info/warnings sit below a small
220
+ separator at the bottom of the body. The dashboard is coloured when the
221
+ terminal supports it; info/warnings/errors are shown as coloured
222
+ `ℹ`/`⚠`/`✖`/`✔` lines. Each assistant block also carries a dim line with
223
+ that turn's tool calls, background tasks and assistant-message count.
224
+ Questions (resume/permission) use a yellow "Question to User" box just above
225
+ the input. Restored sessions load their history into
226
+ the core view and mark the summary as `[restored]`; generated plans append to
227
+ the core view. Tool details can be expanded with `/expand [n]`.
228
+
229
+ The prompt has a small line editor: `↑`/`↓` recall previous turns, `←`/`→` move
230
+ the cursor, Home/End jump within the line, and `Ctrl-A/E/K/U/L` provide the
231
+ usual editing/clear shortcuts. `--tui` defaults to `auto` (known TTY only); use `--tui=off` for the old
232
+ scrolling console or `--tui=on` to force it. It is not part of `--all`.
233
+
177
234
  > [!NOTE]
178
235
  > `/history` and `/reset` are driven by `summary_history.json`, a flat recorder that maps every
179
236
  > turn to the `history_{n}.json` segment and message index it lives in — so no full history is
@@ -232,6 +289,9 @@ command into one of three tiers:
232
289
  | **ASK** | `rm file`, `sudo ...`, `chmod`, `curl ... \| sh` | requires your confirmation |
233
290
  | **ALLOW** | `ls`, `cat`, `git status` | runs without prompting |
234
291
 
292
+ `--sudo` removes the confirmation prompts (ASK tier and `--ask-permission`); DENY commands are
293
+ still refused. With no flags, an ASK-tier command prompts and an ALLOW-tier one runs unaided.
294
+
235
295
  > [!WARNING]
236
296
  > The classifier is **always enforced** — even in auto-mode and with `--sudo` — so the agent
237
297
  > cannot run destructive commands unattended. It is a heuristic, not a sandbox: use it with care.
@@ -242,13 +302,34 @@ command into one of three tiers:
242
302
  The loop keeps two human-readable tracking files in the session directory: `CURRENT_GOAL.md`
243
303
  (your latest instruction) and `CURRENT_PLAN.md` (a step-by-step plan for that goal, marked
244
304
  finished when it is done). They are authored by the *loop*, not the agent, live outside
245
- `--allowed-dir`, and can be inspected any time with `/plan`.
305
+ `--allowed-dir`, and can be inspected any time with `/plan`. The generated plan is
306
+ also printed as a box right after planning, so you can see it without asking.
307
+ Use `/skip-plan <prompt>` to send one prompt without planning it (plan mode stays
308
+ on for later turns).
309
+
310
+ `--plan-strategy` selects how planning is wired:
311
+
312
+ | Strategy | What happens |
313
+ | --- | --- |
314
+ | `plan-verify-step` (default) | Current behaviour: author a plan, review it once the work settles, then run one extra step and keep whatever that step says. |
315
+ | `plan-verify` | Same plan + review, but the post-review step is kept only when it calls a tool. A no-tool answer is shown to you and ends the turn without being appended to the transcript. |
316
+ | `open-plan` | The agent owns a plan document at `.mini/PLAN.md` inside `--allowed-dir`, reads and updates it with the normal file tools, and the loop neither authors nor reviews a plan. |
246
317
 
247
318
  > [!NOTE]
248
319
  > Plan mode also changes **history compaction**: after the transcript is compacted to a summary,
249
320
  > `CURRENT_PLAN.md` and `CURRENT_GOAL.md` are re-injected, so the agent keeps working against the
250
- > same goal. When the work looks done the plan is reviewed and any outstanding task is re-queued
251
- > before the agent returns to you.
321
+ > same goal. With `open-plan`, the agent's `.mini/PLAN.md` is re-injected instead. When the work
322
+ > looks done the plan is reviewed and any outstanding task is re-queued before the agent returns
323
+ > to you (except with `open-plan`).
324
+
325
+ ### Scratchpad — `--scratchpad`
326
+
327
+ With `--scratchpad`, the loop creates `.mini/SCRATCHPAD.md` inside `--allowed-dir` and tells the
328
+ agent that it may read and write that file freely, and may create additional scratch files in the
329
+ same directory (for example `SCRATCH-NOTES.md`, `SCRATCH-IDEAS.md`). The scratchpad is ordinary
330
+ state inside the sandbox, so the normal `read_file` / `write_file` / `edit` tools work; no special
331
+ tool is registered. It is meant for the agent's own thoughts, plans, learnings and open questions,
332
+ and survives a history compaction because it lives on disk.
252
333
 
253
334
  ### Sessions — resume, or start fresh
254
335
 
@@ -296,6 +377,20 @@ waiting on) is kept verbatim after the summary. So a compaction that fires just
296
377
  instruction cannot swallow it — the model still answers what you asked, and the turn stays in
297
378
  the session file, in `/history` and in a later restore.
298
379
 
380
+ `--compaction-strategy` chooses what else survives besides the summary:
381
+
382
+ | Strategy | Messages after compaction |
383
+ | --- | --- |
384
+ | `summarise` (default) | `system`, `summary`, `plan`, `current turn` |
385
+ | `predict-files` | `system`, `summary`, predicted read-only tool calls + results, `plan`, `current turn` |
386
+ | `predict-messages` | `system`, `summary`, original messages the model names by index, `plan`, `current turn` |
387
+
388
+ `predict-files` asks the model which files it needs to re-read and executes only the read-only
389
+ tools (`read_file`, `grep`, `glob`) it predicts; `predict-messages` asks for a JSON array of
390
+ 0-based message indexes to keep verbatim. Both predictions are one extra tool-free (or
391
+ read-only-tool) LLM call, are billed normally, and are capped so they cannot refill the context
392
+ they just freed. A failed prediction degrades to the plain summary.
393
+
299
394
  Because a rollover leaves no trace in the transcript (the old turns really are gone), the
300
395
  console says in plain terms what happened — all of it without `--verbose`:
301
396
 
@@ -315,19 +410,24 @@ transcript and the segment left untouched.
315
410
  ### Exiting — the good-bye box
316
411
 
317
412
  Quitting (`/quit`, `exit`, or EOF on stdin) saves the session and then prints a short yellow
318
- box: the version, a sign-off, and what the session left behind — session id, folder, the
319
- history segments on disk, how many turns were recorded, and the token / call totals.
413
+ box: the version, a sign-off, and what the session left behind — session id, model, folder,
414
+ the history segments on disk, how many turns were recorded, run duration, token / call totals,
415
+ background tasks cancelled on exit, and a `--load-last-session` resume hint.
320
416
 
321
417
  ```
322
418
  ╔══════════ MiniCodeCLI v0.1.1.2 - goodbye ═════════════════════╗
323
419
  ║ Goodbye, and thanks for using MiniCodeCLI! ║
324
420
  ║ ║
325
421
  ║ session id : 1792666273983619-36ca3c2e ║
422
+ ║ model : ornith-ai/Ornith-1.5-35B-A3B ║
326
423
  ║ saved under : ~/.cache/mini/sessions/1792…-36ca3c2e/ ║
327
424
  ║ history : history_0.json (segment 0), 5 messages ║
328
425
  ║ conversation : 2 recorded turns ║
426
+ ║ duration : 12m 34s ║
329
427
  ║ tokens : 20 in / 10 out (30 total) ║
330
428
  ║ calls : 2 LLM, 0 tool ║
429
+ ║ background : none running ║
430
+ ║ resume : mini-code --load-last-session ║
331
431
  ╚═══════════════════════════════════════════════════════════════╝
332
432
  ```
333
433
 
@@ -360,7 +460,7 @@ If you use `mini-code-cli` in your research or writing, please cite it:
360
460
  author = {Rozanov, Nikolai},
361
461
  title = {mini-code-cli: A minimal, dependency-light coding agent},
362
462
  year = {2026},
363
- version = {0.1.1.2},
463
+ version = {0.2.0.0},
364
464
  howpublished = {\url{https://github.com/ai-nikolai/mini-code-cli}},
365
465
  note = {A no-bloat, dependency-light agent CLI for experimenting.}
366
466
  }
@@ -0,0 +1,90 @@
1
+ """Agent-owned files kept in ``--allowed-dir/.mini``.
2
+
3
+ Two opt-in features put a file the *agent* may read and write there, rather
4
+ than in the session directory the loop owns:
5
+
6
+ * the **scratchpad** (``--scratchpad``): a free-form note file for thoughts,
7
+ plans and learnings, plus as many additional scratch files as the agent
8
+ wants to create;
9
+ * the **open plan** (``--plan-strategy open-plan``): a plan document the
10
+ agent maintains itself with the normal file tools.
11
+
12
+ Both live under the same ``.mini`` directory as the skills folder and the
13
+ latest-session pointer, so they are inside the ``--allowed-dir`` sandbox and
14
+ the normal ``read_file`` / ``write_file`` / ``edit`` tools can reach them. The
15
+ directory name is read from :mod:`mini_code_cli.persistence` at call time, so
16
+ the test suite can redirect it globally (exactly like the session pointer).
17
+ """
18
+
19
+ import os
20
+
21
+ from . import persistence
22
+
23
+ SCRATCHPAD_FILENAME = "SCRATCHPAD.md"
24
+ OPEN_PLAN_FILENAME = "PLAN.md"
25
+
26
+ _SCRATCHPAD_HEADER = """# Scratchpad
27
+
28
+ This file belongs to the agent. It may read and write it freely and may create
29
+ additional scratch files in the same directory. Use it for thoughts, plans,
30
+ learnings and notes that should survive a compaction.
31
+ """
32
+
33
+ _OPEN_PLAN_HEADER = """# Agent Plan
34
+
35
+ This plan document belongs to the agent. Read it before continuing, keep it up
36
+ to date as work progresses, and mark steps done or outstanding.
37
+ """
38
+
39
+
40
+ def mini_dir(allowed_dir):
41
+ """The ``.mini`` directory inside ``allowed_dir`` (not created)."""
42
+ return os.path.join(os.path.abspath(allowed_dir), persistence.SESSION_DIRNAME)
43
+
44
+
45
+ def scratchpad_path(allowed_dir):
46
+ """Path to the main scratch-pad file."""
47
+ return os.path.join(mini_dir(allowed_dir), SCRATCHPAD_FILENAME)
48
+
49
+
50
+ def open_plan_path(allowed_dir):
51
+ """Path to the agent-authored plan document."""
52
+ return os.path.join(mini_dir(allowed_dir), OPEN_PLAN_FILENAME)
53
+
54
+
55
+ def ensure_scratchpad(allowed_dir):
56
+ """Create the main scratch-pad file (and its directory) if missing."""
57
+ return _ensure_file(scratchpad_path(allowed_dir), _SCRATCHPAD_HEADER)
58
+
59
+
60
+ def ensure_open_plan(allowed_dir):
61
+ """Create the agent plan document (and its directory) if missing."""
62
+ return _ensure_file(open_plan_path(allowed_dir), _OPEN_PLAN_HEADER)
63
+
64
+
65
+ def read_text(path, limit=None):
66
+ """Read ``path`` as text, returning ``""`` when it cannot be read.
67
+
68
+ ``limit`` caps the returned characters (the open-plan re-injection after a
69
+ compaction should not be able to re-fill the context with the document).
70
+ """
71
+ try:
72
+ with open(path, "r", encoding="utf-8", errors="replace") as handle:
73
+ text = handle.read()
74
+ except OSError:
75
+ return ""
76
+ if limit is not None and len(text) > limit:
77
+ return text[:limit] + "\n[... truncated ...]\n"
78
+ return text
79
+
80
+
81
+ def _ensure_file(path, header):
82
+ """Best-effort create-with-header; never raises, always returns ``path``."""
83
+ try:
84
+ if not os.path.isfile(path):
85
+ os.makedirs(os.path.dirname(path), exist_ok=True)
86
+ with open(path, "w", encoding="utf-8") as handle:
87
+ handle.write(header)
88
+ except OSError:
89
+ pass
90
+ return path