mini-code-cli 0.1.1.0__tar.gz → 0.1.1.2__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 (33) hide show
  1. {mini_code_cli-0.1.1.0 → mini_code_cli-0.1.1.2}/PKG-INFO +74 -14
  2. {mini_code_cli-0.1.1.0 → mini_code_cli-0.1.1.2}/README.md +73 -13
  3. {mini_code_cli-0.1.1.0 → mini_code_cli-0.1.1.2}/mini_code_cli/agent_loop.py +648 -156
  4. {mini_code_cli-0.1.1.0 → mini_code_cli-0.1.1.2}/mini_code_cli/persistence.py +194 -80
  5. {mini_code_cli-0.1.1.0 → mini_code_cli-0.1.1.2}/mini_code_cli/tools.py +2 -3
  6. {mini_code_cli-0.1.1.0 → mini_code_cli-0.1.1.2}/mini_code_cli/ui.py +26 -0
  7. {mini_code_cli-0.1.1.0 → mini_code_cli-0.1.1.2}/mini_code_cli/utils.py +6 -13
  8. {mini_code_cli-0.1.1.0 → mini_code_cli-0.1.1.2}/mini_code_cli.egg-info/PKG-INFO +74 -14
  9. {mini_code_cli-0.1.1.0 → mini_code_cli-0.1.1.2}/pyproject.toml +1 -1
  10. {mini_code_cli-0.1.1.0 → mini_code_cli-0.1.1.2}/tests/test_e2e_agent_loop.py +99 -24
  11. {mini_code_cli-0.1.1.0 → mini_code_cli-0.1.1.2}/tests/test_interactive.py +431 -18
  12. {mini_code_cli-0.1.1.0 → mini_code_cli-0.1.1.2}/tests/test_subagents.py +4 -0
  13. {mini_code_cli-0.1.1.0 → mini_code_cli-0.1.1.2}/tests/test_tokens.py +62 -6
  14. {mini_code_cli-0.1.1.0 → mini_code_cli-0.1.1.2}/LICENSE +0 -0
  15. {mini_code_cli-0.1.1.0 → mini_code_cli-0.1.1.2}/mini_code_cli/__init__.py +0 -0
  16. {mini_code_cli-0.1.1.0 → mini_code_cli-0.1.1.2}/mini_code_cli/config.py +0 -0
  17. {mini_code_cli-0.1.1.0 → mini_code_cli-0.1.1.2}/mini_code_cli/permissions.py +0 -0
  18. {mini_code_cli-0.1.1.0 → mini_code_cli-0.1.1.2}/mini_code_cli/plan.py +0 -0
  19. {mini_code_cli-0.1.1.0 → mini_code_cli-0.1.1.2}/mini_code_cli/prompts.py +0 -0
  20. {mini_code_cli-0.1.1.0 → mini_code_cli-0.1.1.2}/mini_code_cli/runner.py +0 -0
  21. {mini_code_cli-0.1.1.0 → mini_code_cli-0.1.1.2}/mini_code_cli/sandbox.py +0 -0
  22. {mini_code_cli-0.1.1.0 → mini_code_cli-0.1.1.2}/mini_code_cli/shell_safety_utils.py +0 -0
  23. {mini_code_cli-0.1.1.0 → mini_code_cli-0.1.1.2}/mini_code_cli/skills.py +0 -0
  24. {mini_code_cli-0.1.1.0 → mini_code_cli-0.1.1.2}/mini_code_cli/subagents/__init__.py +0 -0
  25. {mini_code_cli-0.1.1.0 → mini_code_cli-0.1.1.2}/mini_code_cli/subagents/base.py +0 -0
  26. {mini_code_cli-0.1.1.0 → mini_code_cli-0.1.1.2}/mini_code_cli/subagents/builtin.py +0 -0
  27. {mini_code_cli-0.1.1.0 → mini_code_cli-0.1.1.2}/mini_code_cli/tokens.py +0 -0
  28. {mini_code_cli-0.1.1.0 → mini_code_cli-0.1.1.2}/mini_code_cli.egg-info/SOURCES.txt +0 -0
  29. {mini_code_cli-0.1.1.0 → mini_code_cli-0.1.1.2}/mini_code_cli.egg-info/dependency_links.txt +0 -0
  30. {mini_code_cli-0.1.1.0 → mini_code_cli-0.1.1.2}/mini_code_cli.egg-info/entry_points.txt +0 -0
  31. {mini_code_cli-0.1.1.0 → mini_code_cli-0.1.1.2}/mini_code_cli.egg-info/requires.txt +0 -0
  32. {mini_code_cli-0.1.1.0 → mini_code_cli-0.1.1.2}/mini_code_cli.egg-info/top_level.txt +0 -0
  33. {mini_code_cli-0.1.1.0 → mini_code_cli-0.1.1.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mini-code-cli
3
- Version: 0.1.1.0
3
+ Version: 0.1.1.2
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: GNU AFFERO GENERAL PUBLIC LICENSE
@@ -693,7 +693,7 @@ Dynamic: license-file
693
693
 
694
694
  **Purpose:** a no-bloat, minimal coding CLI to enjoy experimenting and researching.
695
695
 
696
- **Install** · [Quick start](#quick-start) · [Modes &amp; safety](#modes--safety) · [Options](#command-line-options) · [Tools](#available-tools) · [Sub-agents](#sub-agents) · [In-session commands](#in-session-commands) · [Development](#development) · [Citation](#citation)
696
+ **Install** · [Quick start](#quick-start) · [Modes &amp; safety](#modes--safety) · [Options](#command-line-options) · [Tools](#available-tools) · [Sub-agents](#sub-agents) · [In-session commands](#in-session-commands) · [Development](#development) · [Docs](#documentation) · [Citation](#citation)
697
697
 
698
698
  > [!TIP]
699
699
  > **New here?** `pip install mini-code-cli`, point it at a model (a local server on
@@ -708,7 +708,7 @@ pip3 install mini-code-cli
708
708
 
709
709
  - **PyPI:** <https://pypi.org/project/mini-code-cli/>
710
710
  - **Python:** `>= 3.10` &nbsp;·&nbsp; **runtime dependency:** `requests` only
711
- - **From source / contributing:** see [README_DEV.md](README_DEV.md)
711
+ - **From source / contributing:** see [docs/README_DEV.md](docs/README_DEV.md)
712
712
 
713
713
  ## Quick start
714
714
 
@@ -836,8 +836,8 @@ register(SummarizeSubAgent())
836
836
 
837
837
  Make sure the module is imported (e.g. `import my_subagents`) and it is discovered and exposed
838
838
  to the model automatically when `--enable-subagents` is set. See
839
- `mini_code_cli/subagents/builtin.py` for every knob and `ARCHITECTURE.md` (sections 2–3) for the
840
- design.
839
+ `mini_code_cli/subagents/builtin.py` for every knob and
840
+ [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) (sections 2–3) for the design.
841
841
 
842
842
  </details>
843
843
 
@@ -847,16 +847,35 @@ design.
847
847
  | --- | --- |
848
848
  | `/history` | list the conversation (turn number, what happened, where) |
849
849
  | `/history <n>` | show the full messages recorded for turn `n` |
850
- | `/reset [<n>]` | rewind to the end of turn `n` (drops everything after it) |
850
+ | `/history last` | ...for the most recent turn |
851
+ | `/reset [<n>]` | rewind to the end of turn `n` (`last` works too); drops everything after it |
851
852
  | `/clear` | clear the screen (keeps the conversation history) |
852
853
  | `/plan` | show the current goal + plan (plan mode only) |
853
854
  | `/help` | show this help |
854
855
  | `/quit`, `/exit` | save the session and exit |
855
856
 
857
+ > [!NOTE]
858
+ > `/history` and `/reset` are driven by `summary_history.json`, a flat recorder that maps every
859
+ > turn to the `history_{n}.json` segment and message index it lives in — so no full history is
860
+ > read just to list the conversation.
861
+ >
862
+ > * **`<n>` is validated**: `last`, or a positive 1-based turn number. `0`, negatives and
863
+ > non-numbers are rejected with `No such turn` instead of silently showing a different turn.
864
+ > * **A bare `/reset` never destroys anything**: it reports `Already at turn N` when the
865
+ > transcript already ends at the last recorded turn, and *warns instead of truncating* if
866
+ > there are messages that were never recorded. Only `/reset <n>` / `/reset last` rewind.
867
+ > * **A rewind really sticks**: the target `history_{n}.json` is truncated in place (no backup)
868
+ > and every higher `history_{m}.json` / `usage_{m}.json` segment is deleted, so a restart
869
+ > cannot resurrect the dropped turns. All history files are written atomically.
870
+ > * **Token usage is never rolled back**: a rewind does not un-spend tokens, and the session
871
+ > total is preserved. See
872
+ > [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md#rewinding-reset-and-what-it-does-to-the-files)
873
+ > for the files involved.
874
+
856
875
  ## Development
857
876
 
858
877
  Linting, the test suite, CI and the release process are documented in
859
- [**README_DEV.md**](README_DEV.md).
878
+ [**docs/README_DEV.md**](docs/README_DEV.md).
860
879
 
861
880
  ```bash
862
881
  python3 scripts/lint.py # lint (standard library only)
@@ -867,7 +886,18 @@ Releases are cut by tagging `main`: pushing a `v*` tag triggers
867
886
  [`.github/workflows/release.yml`](.github/workflows/release.yml), which builds the sdist + wheel,
868
887
  verifies them with `twine check`, and attaches them to a new GitHub release.
869
888
 
889
+ ## Documentation
890
+
891
+ Everything beyond this README lives in [`docs/`](docs/):
870
892
 
893
+ | Document | What it covers |
894
+ | --- | --- |
895
+ | [**docs/README_DEV.md**](docs/README_DEV.md) | developer guide — local setup, repository layout, linting, the test suite, CI and the release / PyPI upload process |
896
+ | [**docs/ARCHITECTURE.md**](docs/ARCHITECTURE.md) | design — module layout, on-disk conversation state (`history_{n}.json`, `summary_history.json`, usage files), the sub-agent framework and how to extend it |
897
+
898
+ This README stays the user-facing entry point (install, CLI flags, tools, sub-agents,
899
+ in-session commands, modes &amp; safety); the two documents above go deeper on the developer
900
+ and design side.
871
901
 
872
902
  ## Modes & safety
873
903
 
@@ -913,15 +943,23 @@ Every session is saved under `--cache-dir` (default `~/.cache/mini/sessions/`).
913
943
 
914
944
  | Flag | Behaviour |
915
945
  | --- | --- |
916
- | `--restore-session PATH` | continue that exact session |
946
+ | `--restore-session PATH` | continue that exact session (a session directory or a bare session id under `--cache-dir`) |
917
947
  | `-l`, `--load-last-session` | continue the session recorded in the `.mini/last_session.json` pointer, without asking |
918
948
 
919
- `--load-last-session` resumes under a **brand-new session id**, so the original is never
920
- overwritten; an explicit `--restore-session` wins if both are given. The "most recent" session
921
- comes from a single source — the tiny `.mini/last_session.json` pointer written at the end of
922
- every interactive session inside `--allowed-dir` (deliberately no timestamp fallback: with no
923
- pointer, a fresh session starts). That pointer lives in the same `.mini` directory as `--skills`,
924
- but as its own dedicated file, so the two never clash.
949
+ `--load-last-session` continues that session **in place** (same id, same folder, same
950
+ messages), so the conversation you were in is the one you get back; an explicit
951
+ `--restore-session` wins if both are given. The "most recent" session comes from a single
952
+ source — the tiny `.mini/last_session.json` pointer written when a session starts or is
953
+ restored inside `--allowed-dir` (deliberately no timestamp fallback: with no pointer, a fresh
954
+ session starts). That pointer lives in the same `.mini` directory as `--skills`, but as its
955
+ own dedicated file, so the two never clash.
956
+
957
+ A session folder is restorable only if it has what this version writes: a valid
958
+ `summary_history.json` recorder, plus the `history_{n}.json` segment its last record names
959
+ (usage files are optional). Anything else — a folder from an older release, a hand-assembled
960
+ transcript, a recorder that does not validate, a missing segment — is **refused with a note
961
+ saying why**, and a fresh session is started instead. Nothing is repaired, guessed at, or
962
+ written into the refused folder.
925
963
 
926
964
  ### Context compaction — `--max-context-tokens`
927
965
 
@@ -932,6 +970,28 @@ reserve (`--max-tokens`). Unset (default) it is derived from the model's context
932
970
  output reserve and a safety margin. Lower it to compact sooner, raise it to compact later — there
933
971
  is no message-count cap to configure.
934
972
 
973
+ Compaction replaces the older turns with a summary, but it always carries the **turn in flight**
974
+ across the rollover: the message you just typed (or, mid-turn, the tool call the model is
975
+ waiting on) is kept verbatim after the summary. So a compaction that fires just as you send an
976
+ instruction cannot swallow it — the model still answers what you asked, and the turn stays in
977
+ the session file, in `/history` and in a later restore.
978
+
979
+ Because a rollover leaves no trace in the transcript (the old turns really are gone), the
980
+ console says in plain terms what happened — all of it without `--verbose`:
981
+
982
+ ```
983
+ [!] Compacting the conversation: 42 messages -> a summary (51000 tokens in, 8192 reserved for the reply > 52000 budget). The current turn (1 message) is kept verbatim.
984
+ [!] Summary preview: The user asked for a token-based compaction trigger, then fixed ...
985
+ [!] Compacted history_0.json (42 messages) into a summary; history_1.json now starts with 3 messages (summary + 1 kept message).
986
+ ```
987
+
988
+ So you can see *what* was folded away (a preview of the summary itself), *how much* (the
989
+ message count of the segment that was closed), *where it went* (`history_0.json` closed,
990
+ `history_1.json` started) and that nothing you just typed was lost. If the summariser answers
991
+ with an empty summary twice, or the call fails, compaction is abandoned and the note says so
992
+ explicitly — "nothing was lost, but the next request may still be too large" — with the
993
+ transcript and the segment left untouched.
994
+
935
995
 
936
996
  ## Serving a model locally
937
997
 
@@ -13,7 +13,7 @@
13
13
 
14
14
  **Purpose:** a no-bloat, minimal coding CLI to enjoy experimenting and researching.
15
15
 
16
- **Install** · [Quick start](#quick-start) · [Modes &amp; safety](#modes--safety) · [Options](#command-line-options) · [Tools](#available-tools) · [Sub-agents](#sub-agents) · [In-session commands](#in-session-commands) · [Development](#development) · [Citation](#citation)
16
+ **Install** · [Quick start](#quick-start) · [Modes &amp; safety](#modes--safety) · [Options](#command-line-options) · [Tools](#available-tools) · [Sub-agents](#sub-agents) · [In-session commands](#in-session-commands) · [Development](#development) · [Docs](#documentation) · [Citation](#citation)
17
17
 
18
18
  > [!TIP]
19
19
  > **New here?** `pip install mini-code-cli`, point it at a model (a local server on
@@ -28,7 +28,7 @@ pip3 install mini-code-cli
28
28
 
29
29
  - **PyPI:** <https://pypi.org/project/mini-code-cli/>
30
30
  - **Python:** `>= 3.10` &nbsp;·&nbsp; **runtime dependency:** `requests` only
31
- - **From source / contributing:** see [README_DEV.md](README_DEV.md)
31
+ - **From source / contributing:** see [docs/README_DEV.md](docs/README_DEV.md)
32
32
 
33
33
  ## Quick start
34
34
 
@@ -156,8 +156,8 @@ register(SummarizeSubAgent())
156
156
 
157
157
  Make sure the module is imported (e.g. `import my_subagents`) and it is discovered and exposed
158
158
  to the model automatically when `--enable-subagents` is set. See
159
- `mini_code_cli/subagents/builtin.py` for every knob and `ARCHITECTURE.md` (sections 2–3) for the
160
- design.
159
+ `mini_code_cli/subagents/builtin.py` for every knob and
160
+ [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) (sections 2–3) for the design.
161
161
 
162
162
  </details>
163
163
 
@@ -167,16 +167,35 @@ design.
167
167
  | --- | --- |
168
168
  | `/history` | list the conversation (turn number, what happened, where) |
169
169
  | `/history <n>` | show the full messages recorded for turn `n` |
170
- | `/reset [<n>]` | rewind to the end of turn `n` (drops everything after it) |
170
+ | `/history last` | ...for the most recent turn |
171
+ | `/reset [<n>]` | rewind to the end of turn `n` (`last` works too); drops everything after it |
171
172
  | `/clear` | clear the screen (keeps the conversation history) |
172
173
  | `/plan` | show the current goal + plan (plan mode only) |
173
174
  | `/help` | show this help |
174
175
  | `/quit`, `/exit` | save the session and exit |
175
176
 
177
+ > [!NOTE]
178
+ > `/history` and `/reset` are driven by `summary_history.json`, a flat recorder that maps every
179
+ > turn to the `history_{n}.json` segment and message index it lives in — so no full history is
180
+ > read just to list the conversation.
181
+ >
182
+ > * **`<n>` is validated**: `last`, or a positive 1-based turn number. `0`, negatives and
183
+ > non-numbers are rejected with `No such turn` instead of silently showing a different turn.
184
+ > * **A bare `/reset` never destroys anything**: it reports `Already at turn N` when the
185
+ > transcript already ends at the last recorded turn, and *warns instead of truncating* if
186
+ > there are messages that were never recorded. Only `/reset <n>` / `/reset last` rewind.
187
+ > * **A rewind really sticks**: the target `history_{n}.json` is truncated in place (no backup)
188
+ > and every higher `history_{m}.json` / `usage_{m}.json` segment is deleted, so a restart
189
+ > cannot resurrect the dropped turns. All history files are written atomically.
190
+ > * **Token usage is never rolled back**: a rewind does not un-spend tokens, and the session
191
+ > total is preserved. See
192
+ > [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md#rewinding-reset-and-what-it-does-to-the-files)
193
+ > for the files involved.
194
+
176
195
  ## Development
177
196
 
178
197
  Linting, the test suite, CI and the release process are documented in
179
- [**README_DEV.md**](README_DEV.md).
198
+ [**docs/README_DEV.md**](docs/README_DEV.md).
180
199
 
181
200
  ```bash
182
201
  python3 scripts/lint.py # lint (standard library only)
@@ -187,7 +206,18 @@ Releases are cut by tagging `main`: pushing a `v*` tag triggers
187
206
  [`.github/workflows/release.yml`](.github/workflows/release.yml), which builds the sdist + wheel,
188
207
  verifies them with `twine check`, and attaches them to a new GitHub release.
189
208
 
209
+ ## Documentation
210
+
211
+ Everything beyond this README lives in [`docs/`](docs/):
190
212
 
213
+ | Document | What it covers |
214
+ | --- | --- |
215
+ | [**docs/README_DEV.md**](docs/README_DEV.md) | developer guide — local setup, repository layout, linting, the test suite, CI and the release / PyPI upload process |
216
+ | [**docs/ARCHITECTURE.md**](docs/ARCHITECTURE.md) | design — module layout, on-disk conversation state (`history_{n}.json`, `summary_history.json`, usage files), the sub-agent framework and how to extend it |
217
+
218
+ This README stays the user-facing entry point (install, CLI flags, tools, sub-agents,
219
+ in-session commands, modes &amp; safety); the two documents above go deeper on the developer
220
+ and design side.
191
221
 
192
222
  ## Modes & safety
193
223
 
@@ -233,15 +263,23 @@ Every session is saved under `--cache-dir` (default `~/.cache/mini/sessions/`).
233
263
 
234
264
  | Flag | Behaviour |
235
265
  | --- | --- |
236
- | `--restore-session PATH` | continue that exact session |
266
+ | `--restore-session PATH` | continue that exact session (a session directory or a bare session id under `--cache-dir`) |
237
267
  | `-l`, `--load-last-session` | continue the session recorded in the `.mini/last_session.json` pointer, without asking |
238
268
 
239
- `--load-last-session` resumes under a **brand-new session id**, so the original is never
240
- overwritten; an explicit `--restore-session` wins if both are given. The "most recent" session
241
- comes from a single source — the tiny `.mini/last_session.json` pointer written at the end of
242
- every interactive session inside `--allowed-dir` (deliberately no timestamp fallback: with no
243
- pointer, a fresh session starts). That pointer lives in the same `.mini` directory as `--skills`,
244
- but as its own dedicated file, so the two never clash.
269
+ `--load-last-session` continues that session **in place** (same id, same folder, same
270
+ messages), so the conversation you were in is the one you get back; an explicit
271
+ `--restore-session` wins if both are given. The "most recent" session comes from a single
272
+ source — the tiny `.mini/last_session.json` pointer written when a session starts or is
273
+ restored inside `--allowed-dir` (deliberately no timestamp fallback: with no pointer, a fresh
274
+ session starts). That pointer lives in the same `.mini` directory as `--skills`, but as its
275
+ own dedicated file, so the two never clash.
276
+
277
+ A session folder is restorable only if it has what this version writes: a valid
278
+ `summary_history.json` recorder, plus the `history_{n}.json` segment its last record names
279
+ (usage files are optional). Anything else — a folder from an older release, a hand-assembled
280
+ transcript, a recorder that does not validate, a missing segment — is **refused with a note
281
+ saying why**, and a fresh session is started instead. Nothing is repaired, guessed at, or
282
+ written into the refused folder.
245
283
 
246
284
  ### Context compaction — `--max-context-tokens`
247
285
 
@@ -252,6 +290,28 @@ reserve (`--max-tokens`). Unset (default) it is derived from the model's context
252
290
  output reserve and a safety margin. Lower it to compact sooner, raise it to compact later — there
253
291
  is no message-count cap to configure.
254
292
 
293
+ Compaction replaces the older turns with a summary, but it always carries the **turn in flight**
294
+ across the rollover: the message you just typed (or, mid-turn, the tool call the model is
295
+ waiting on) is kept verbatim after the summary. So a compaction that fires just as you send an
296
+ instruction cannot swallow it — the model still answers what you asked, and the turn stays in
297
+ the session file, in `/history` and in a later restore.
298
+
299
+ Because a rollover leaves no trace in the transcript (the old turns really are gone), the
300
+ console says in plain terms what happened — all of it without `--verbose`:
301
+
302
+ ```
303
+ [!] Compacting the conversation: 42 messages -> a summary (51000 tokens in, 8192 reserved for the reply > 52000 budget). The current turn (1 message) is kept verbatim.
304
+ [!] Summary preview: The user asked for a token-based compaction trigger, then fixed ...
305
+ [!] Compacted history_0.json (42 messages) into a summary; history_1.json now starts with 3 messages (summary + 1 kept message).
306
+ ```
307
+
308
+ So you can see *what* was folded away (a preview of the summary itself), *how much* (the
309
+ message count of the segment that was closed), *where it went* (`history_0.json` closed,
310
+ `history_1.json` started) and that nothing you just typed was lost. If the summariser answers
311
+ with an empty summary twice, or the call fails, compaction is abandoned and the note says so
312
+ explicitly — "nothing was lost, but the next request may still be too large" — with the
313
+ transcript and the segment left untouched.
314
+
255
315
 
256
316
  ## Serving a model locally
257
317