miniouto 0.1.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 (58) hide show
  1. miniouto-0.1.0/.github/workflows/release.yml +68 -0
  2. miniouto-0.1.0/.gitignore +51 -0
  3. miniouto-0.1.0/AGENTS.md +310 -0
  4. miniouto-0.1.0/LICENSE +201 -0
  5. miniouto-0.1.0/PKG-INFO +125 -0
  6. miniouto-0.1.0/README.md +99 -0
  7. miniouto-0.1.0/docs/README.md +78 -0
  8. miniouto-0.1.0/docs/architecture.md +266 -0
  9. miniouto-0.1.0/docs/cli.md +362 -0
  10. miniouto-0.1.0/docs/core.md +373 -0
  11. miniouto-0.1.0/docs/development.md +252 -0
  12. miniouto-0.1.0/docs/lma.md +82 -0
  13. miniouto-0.1.0/docs/skills.md +151 -0
  14. miniouto-0.1.0/docs/storage.md +290 -0
  15. miniouto-0.1.0/docs/styles.md +192 -0
  16. miniouto-0.1.0/docs/tools.md +418 -0
  17. miniouto-0.1.0/logo.png +0 -0
  18. miniouto-0.1.0/logo.svg +1 -0
  19. miniouto-0.1.0/preview.gif +0 -0
  20. miniouto-0.1.0/pyproject.toml +47 -0
  21. miniouto-0.1.0/src/miniouto/__init__.py +3 -0
  22. miniouto-0.1.0/src/miniouto/cli/__init__.py +70 -0
  23. miniouto-0.1.0/src/miniouto/cli/chat.py +77 -0
  24. miniouto-0.1.0/src/miniouto/cli/provider.py +272 -0
  25. miniouto-0.1.0/src/miniouto/cli/skill.py +51 -0
  26. miniouto-0.1.0/src/miniouto/cli/style.py +112 -0
  27. miniouto-0.1.0/src/miniouto/cli/tui.py +1257 -0
  28. miniouto-0.1.0/src/miniouto/core/__init__.py +13 -0
  29. miniouto-0.1.0/src/miniouto/core/chat.py +323 -0
  30. miniouto-0.1.0/src/miniouto/core/context.py +184 -0
  31. miniouto-0.1.0/src/miniouto/core/events.py +124 -0
  32. miniouto-0.1.0/src/miniouto/core/lma.py +139 -0
  33. miniouto-0.1.0/src/miniouto/core/providers.py +134 -0
  34. miniouto-0.1.0/src/miniouto/core/runtime.py +398 -0
  35. miniouto-0.1.0/src/miniouto/default_style/claude.md +333 -0
  36. miniouto-0.1.0/src/miniouto/default_style/codebuff.md +244 -0
  37. miniouto-0.1.0/src/miniouto/default_style/codex.md +376 -0
  38. miniouto-0.1.0/src/miniouto/default_style/default.md +111 -0
  39. miniouto-0.1.0/src/miniouto/default_style/oh-my-opencode.md +306 -0
  40. miniouto-0.1.0/src/miniouto/default_style/opencode.md +255 -0
  41. miniouto-0.1.0/src/miniouto/paths_runtime.py +8 -0
  42. miniouto-0.1.0/src/miniouto/storage/__init__.py +3 -0
  43. miniouto-0.1.0/src/miniouto/storage/paths.py +37 -0
  44. miniouto-0.1.0/src/miniouto/storage/providers.py +70 -0
  45. miniouto-0.1.0/src/miniouto/storage/sessions.py +88 -0
  46. miniouto-0.1.0/src/miniouto/storage/settings.py +46 -0
  47. miniouto-0.1.0/src/miniouto/storage/skills.py +98 -0
  48. miniouto-0.1.0/src/miniouto/storage/styles.py +242 -0
  49. miniouto-0.1.0/src/miniouto/storage/toml_io.py +23 -0
  50. miniouto-0.1.0/src/miniouto/tools/__init__.py +12 -0
  51. miniouto-0.1.0/src/miniouto/tools/_normalize.py +79 -0
  52. miniouto-0.1.0/src/miniouto/tools/bash.py +82 -0
  53. miniouto-0.1.0/src/miniouto/tools/delete.py +29 -0
  54. miniouto-0.1.0/src/miniouto/tools/edit.py +221 -0
  55. miniouto-0.1.0/src/miniouto/tools/media.py +140 -0
  56. miniouto-0.1.0/src/miniouto/tools/registry.py +279 -0
  57. miniouto-0.1.0/src/miniouto/tools/write.py +90 -0
  58. miniouto-0.1.0/uv.lock +1050 -0
@@ -0,0 +1,68 @@
1
+ name: release
2
+
3
+ # Builds and publishes to PyPI automatically when a `vX.Y.Z` tag is pushed.
4
+ #
5
+ # Setup (one-time, on PyPI):
6
+ # https://docs.pypi.org/trusted-publishers/adding-a-publisher/
7
+ # Owner: <github-org-or-user>, Repo: miniouto,
8
+ # Workflow filename: release.yml, Environment name: pypi
9
+ #
10
+ # To cut a release:
11
+ # 1. Bump `version` in pyproject.toml (and src/miniouto/__init__.py if it diverges).
12
+ # 2. git tag vX.Y.Z && git push origin vX.Y.Z
13
+ #
14
+ # This uses OIDC trusted publishing (no API token to manage or rotate).
15
+ # If you prefer an API token instead, replace the publish step with:
16
+ # - uses: pypa/gh-action-pypi-publish@release/v1
17
+ # with:
18
+ # password: ${{ secrets.PYPI_API_TOKEN }}
19
+
20
+ on:
21
+ push:
22
+ tags:
23
+ - "v*"
24
+
25
+ permissions:
26
+ contents: read
27
+
28
+ jobs:
29
+ build:
30
+ name: Build distributions
31
+ runs-on: ubuntu-latest
32
+ steps:
33
+ - uses: actions/checkout@v4
34
+
35
+ - name: Set up uv
36
+ uses: astral-sh/setup-uv@v6
37
+ with:
38
+ enable-cache: true
39
+
40
+ - name: Set up Python
41
+ run: uv python install 3.12
42
+
43
+ - name: Build wheel and sdist
44
+ run: uv build
45
+
46
+ - name: Upload distributions
47
+ uses: actions/upload-artifact@v4
48
+ with:
49
+ name: dist
50
+ path: dist/
51
+ if-no-files-found: error
52
+
53
+ publish:
54
+ name: Publish to PyPI
55
+ needs: build
56
+ runs-on: ubuntu-latest
57
+ environment: pypi
58
+ permissions:
59
+ id-token: write # required for trusted publishing (OIDC)
60
+ steps:
61
+ - name: Download distributions
62
+ uses: actions/download-artifact@v4
63
+ with:
64
+ name: dist
65
+ path: dist/
66
+
67
+ - name: Publish to PyPI
68
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,51 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ build/
8
+ develop-eggs/
9
+ dist/
10
+ downloads/
11
+ eggs/
12
+ .eggs/
13
+ lib/
14
+ lib64/
15
+ parts/
16
+ sdist/
17
+ var/
18
+ wheels/
19
+ *.egg-info/
20
+ .installed.cfg
21
+ *.egg
22
+
23
+ # Virtual environments
24
+ .venv/
25
+ venv/
26
+ env/
27
+ ENV/
28
+
29
+ # Tooling caches
30
+ .ruff_cache/
31
+ .mypy_cache/
32
+ .pytest_cache/
33
+ .coverage
34
+ htmlcov/
35
+
36
+ # IDE / editor
37
+ .idea/
38
+ .vscode/
39
+ *.swp
40
+ *.swo
41
+ .DS_Store
42
+
43
+ # Environment / secrets
44
+ .env
45
+ .env.local
46
+
47
+ # Local config
48
+ miniouto.toml
49
+
50
+ # Agent
51
+ .omo/
@@ -0,0 +1,310 @@
1
+ # AGENTS.md
2
+
3
+ > **Read this first.** This file is the single source of truth for the miniouto project. It tells you what every file does, why it exists, what depends on it, and what to watch out for when modifying it. The detailed docs live in [`docs/`](./docs/) — this file orients you to them.
4
+
5
+ ---
6
+
7
+ ## What this project is
8
+
9
+ **miniouto** is a minimal, file-driven CLI agent harness built on top of [`coreouto`](https://github.com/llaa33219/coreouto). It exposes a single `miniouto` command that can:
10
+
11
+ - Run a **one-shot chat turn** (`miniouto chat "..."`).
12
+ - Launch a **Textual TUI** (`miniouto` with no args).
13
+ - Manage **providers**, **styles**, and **skills** via CLI subcommands.
14
+ - Persist **session history** as plain JSON files.
15
+
16
+ Three principles from `README.md`: **Minimalism** (no bloat — extend with styles), **Automation-friendly** (full CLI, TUI optional), **Fluidity** (adapts to any environment).
17
+
18
+ **Version**: `0.1.0` (alpha). **Python**: `>=3.10`. **Build**: `hatchling`. **Console script**: `miniouto = "miniouto.cli:app"`.
19
+
20
+ ---
21
+
22
+ ## The 60-second mental model
23
+
24
+ ```
25
+ ~/.miniouto/ ← user's storage (override via $MINIOUTO_HOME)
26
+ ├── providers.toml ← LLM API connections (one top-level table per provider)
27
+ ├── settings.toml ← active provider / model / style / session / theme
28
+ ├── style/*.md ← system prompts (outo + subagent halves)
29
+ ├── sessions/*.json ← conversation history
30
+ └── logs/ ← reserved (currently unused)
31
+
32
+ ~/.agents/skills/ ← skills (NOT under ~/.miniouto/)
33
+ └── <name>/SKILL.md ← YAML frontmatter + markdown body
34
+
35
+ src/miniouto/
36
+ ├── cli/ ← Typer commands + Textual TUI
37
+ ├── core/ ← chat loop, runtime assembly, subagent dispatch, event sinks
38
+ ├── storage/ ← the only layer that touches disk (apart from tools/)
39
+ ├── tools/ ← Write / Edit / Delete / Bash (only bash is async)
40
+ ├── default_style/ ← 6 bundled .md templates, force-refreshed on every run
41
+ └── __init__.py, paths_runtime.py
42
+ ```
43
+
44
+ **Data flow per chat turn:**
45
+
46
+ ```
47
+ CLI flag bag → ChatOptions (core/chat.py)
48
+ → resolve_runtime_from_settings (core/runtime.py)
49
+ → RuntimeConfig
50
+ → build_runtime (core/runtime.py)
51
+ → coreouto provider registry + tool registry + up to 4 hooks
52
+ (BEFORE_TOOL_CALL, ON_ITERATION×2, AFTER_LLM_CALL)
53
+ → co.Agent(outo_config)
54
+ → run_chat(opts, sink) → agent.call_sync(prompt, history=...)
55
+ → Write/Edit/Delete/Bash/Image/Video/Audio (via tools/registry.py)
56
+ → call_subagent (delegates to subagent preset)
57
+ → persist user + assistant MessageRecord
58
+ ```
59
+
60
+ ---
61
+
62
+ ## Where to find what
63
+
64
+ | You want to… | Go to | Doc |
65
+ |---|---|---|
66
+ | Understand the architecture | `src/miniouto/` (tree) | [`docs/architecture.md`](./docs/architecture.md) |
67
+ | Add/modify a CLI command | `src/miniouto/cli/` | [`docs/cli.md`](./docs/cli.md) |
68
+ | Change storage layout or schemas | `src/miniouto/storage/` | [`docs/storage.md`](./docs/storage.md) |
69
+ | Modify the chat loop or runtime | `src/miniouto/core/` | [`docs/core.md`](./docs/core.md) |
70
+ | Add/modify a tool | `src/miniouto/tools/` | [`docs/tools.md`](./docs/tools.md) |
71
+ | Edit/create a style prompt | `~/.miniouto/style/*.md` or `src/miniouto/default_style/` | [`docs/styles.md`](./docs/styles.md) |
72
+ | Add/modify a skill | `~/.agents/skills/<name>/SKILL.md` | [`docs/skills.md`](./docs/skills.md) |
73
+ | Browse lma providers/models or change SDK mapping | `core/lma.py`, `core/providers.py:sdk_to_format`, `cli/provider.py` | [`docs/lma.md`](./docs/lma.md) |
74
+ | Set up dev environment / release | `pyproject.toml`, `uv.lock` | [`docs/development.md`](./docs/development.md) |
75
+
76
+ ---
77
+
78
+ ## The 13 invariants (do NOT break these)
79
+
80
+ These rules hold throughout the codebase. Breaking any of them silently degrades or breaks the system. **If your change seems to require breaking one, stop and ask.**
81
+
82
+ ### 1. Provider registry is rebuilt every turn
83
+ `core/runtime.py:build_runtime` calls `core.providers.clear_coreouto_state()` at the very start, then re-registers providers, presets, tools, hooks. This makes `build_runtime` **idempotent across CLI invocations** — necessary because TUI mode is a long-lived process that re-enters the function many times. **Do not remove `clear_coreouto_state()`.**
84
+
85
+ ### 2. Style documents are split into two halves
86
+ `storage/styles.py:split_style` parses each `.md` into `(outo_part, subagent_part)` using `<outo>...</outo>` and `<subagent>...</subagent>` tags:
87
+
88
+ - `<outo>` is required (or the whole document is used).
89
+ - `<subagent>` is **optional** — if absent, `core/runtime.py:_fallback_style("subagent")` provides a hardcoded minimal prompt.
90
+
91
+ If you change the tag format, update `split_style`, `default_style/*.md`, and `docs/styles.md`.
92
+
93
+ ### 3. Two-layer prompt assembly
94
+ The final prompt the outo model sees, top to bottom:
95
+ 1. **Per-call cwd preamble** (`_with_cwd("outo", …)`) — the user's working directory at miniouto invocation.
96
+ 2. **All active skills** from `~/.agents/skills/` joined by `\n\n---\n\n`.
97
+ 3. **The `<outo>` section** of the active style (or whole-document fallback).
98
+
99
+ Subagent mirrors this with `<subagent>` content and a different cwd preamble. The cwd preamble is regenerated on every call (not persisted).
100
+
101
+ ### 4. Context-window safety
102
+ `core/context.py` enforces a **16K-token output cap** by calling `https://lma.blp.sh/model?model-name=...&provider-name=...` (via `core.lma.get_model`) and clamping the result:
103
+
104
+ - **Floor**: `DEFAULT_MAX_OUTPUT_TOKENS = 16384`. Without this, Anthropic's default of 1024 silently truncates Write tool calls.
105
+ - **Ceiling**: `MAX_OUTPUT_TOKENS_CEILING = 16384`. Some lma entries report theoretical streaming caps (e.g. 512K) that the non-streaming API rejects.
106
+
107
+ If you touch `get_max_output_tokens`, you must preserve both bounds. Always thread the `provider_name` argument through so the lma lookup is scoped to the active provider (otherwise lma returns matches across every provider and we only see the first hit).
108
+
109
+ ### 5. Subagent is a re-implemented `agent_as_tool`
110
+ `core/runtime.py:_build_subagent_tool` does NOT use `coreouto.contrib.agent_as_tool`. The stock helper drops `provider_config` when calling `preset.to_config()` — that means subagent `Write` calls inherit the provider's low hard cap (1024 for Anthropic → silent truncation). This implementation explicitly merges `provider_config` (containing `max_tokens`) into the subagent's `AgentConfig`.
111
+
112
+ **Do not "simplify" this back to `coreouto.contrib.agent_as_tool`.**
113
+
114
+ ### 6. `BEFORE_TOOL_CALL` is global — depth tracked via ContextVar
115
+ coreouto's `BEFORE_TOOL_CALL` hook has no per-agent context. `core/runtime.py:_SUBAGENT_DEPTH: ContextVar[int]` is the only signal of "are we currently inside a subagent?" The `on_tool_call` closure built by `core/chat.py:_make_tool_call_dispatcher` reads it (via `current_subagent_depth()`) to label each tool trace with actor `outo` vs `subagent`. The bridge from coreouto's hook to that closure is `core/runtime.py:_make_tool_call_logger`. The var is bumped only inside `_wrap_subagent_handler`.
116
+
117
+ If you add a new async tool that itself calls subagents, route it through `_wrap_subagent_handler` or the depth tracking will be wrong.
118
+
119
+ ### 7. Edit tool: 6 enforced rules
120
+ `tools/edit.py` enforces six rules:
121
+ 1. **Exact match** priority (then fuzzy fallback).
122
+ 2. **Uniqueness** — multiple matches raise `EditError` with all line numbers.
123
+ 3. **All edits located against the original content** (no chaining).
124
+ 4. **No overlaps** — sorted-span check.
125
+ 5. **Reject empty / no-op edits** (empty `oldText`, identical `oldText`/`newText`).
126
+ 6. **Errors carry line numbers + how-to-fix** hints.
127
+
128
+ The fuzzy fallback normalizes smart quotes, dashes, NBSP, BOM, CRLF, zero-width chars, and trailing whitespace. These rules are testable — write tests before refactoring.
129
+
130
+ ### 8. `Write` refuses overwrite
131
+ `tools/write.py` raises `WriteError` if the target file exists. The intended workflow is `Write` to create, `Edit` to modify. **Do not add an `--overwrite` flag without explicit discussion** — accidental clobbering is the whole point of the refusal.
132
+
133
+ ### 9. Async only where needed
134
+ `tools/bash.py` is async (it spawns a subprocess). The other three tools are sync. The TUI uses `asyncio.to_thread(run_chat, opts, sink)` to call the sync `core.chat.run_chat` without blocking the Textual event loop. **Don't make the other tools async** — they don't need to be, and it complicates the TUI dispatch.
135
+
136
+ ### 10. Skill discovery lives outside `~/.miniouto/`
137
+ `storage/skills.py` reads from `~/.agents/skills/<name>/SKILL.md` (the Anthropic convention), NOT from `~/.miniouto/`. Skills are portable content, not per-installation config. **Do not move them into `~/.miniouto/`.**
138
+
139
+ ### 11. TUI model editor manages `Provider.default_model`, not `Settings.model`
140
+ In the TUI, picking or typing a model always writes to `provider.default_model` (via `dataclasses.replace(p, default_model=...)` + `provider_store.upsert`) and clears any prior `settings.model`. The model chip displays `provider.default_model` only — `settings.model` is reserved for the `chat --model` CLI flag. Legacy `settings.model` values from older sessions keep working at the runtime layer (`resolve_runtime_from_settings` still treats them as priority 2) but are invisible in the TUI. **Do not reintroduce a `settings.model`-as-TUI-override path.**
141
+
142
+ ### 12. lma-backed vs custom providers
143
+ `storage/providers.py:Provider` carries a `source: str` field, one of `SOURCE_CUSTOM` (default) or `SOURCE_LMA`. lma-backed (catalog) providers are added via `miniouto provider add …` or the TUI `+ add from catalog…` wizard; custom providers come from `provider custom add` or the TUI `+ add custom…` wizard. The TUI model picker dispatches on `source`:
144
+
145
+ - `source == "lma"` → `cli/tui.py:_catalog_model_picker_flow` (fetches `/model-list` and shows a `SelectionModal`).
146
+ - `source == "custom"` → `cli/tui.py:_open_custom_model_editor` (free-text `TextInputModal`).
147
+
148
+ The CLI command `miniouto provider providers` filters its "Addable?" column through `core.providers.sdk_to_format(sdk, api)`. Providers whose SDK cannot be hosted by any of the four coreouto builtins (openai / openai-response / anthropic / google) return `(None, None)` and are skipped by both the CLI and the TUI wizard.
149
+
150
+ Note: the source string remains the literal `"lma"` (it predates the "catalog" UI rename) — `SOURCE_LMA = "lma"`. The TUI and CLI surface call these "catalog" providers, but the underlying field value is still `"lma"`.
151
+
152
+ ### 13. lma cache lives in `core.lma._CACHE`
153
+ `core/lma.py` mirrors lma's 10-minute server-side TTL with a module-level dict. Cache keys are explicit (`"providers"`, `f"models:{provider.lower()}"`, `f"model:{provider.lower()}:{model.lower()}"` — both segments are lowercased); a cached `None` payload is meaningful (means "lma returned 404"). `core.lma.clear_cache()` exists for tests / manual refresh. **Do not cache anything other than `None` and successful payloads** — a transient transport error must not pollute the cache for 10 minutes.
154
+
155
+ ---
156
+
157
+ ## File-by-file cheat sheet
158
+
159
+ ### Top-level
160
+
161
+ | File | Purpose |
162
+ |---|---|
163
+ | `pyproject.toml` | Project metadata, deps, console script, hatchling config, ruff config |
164
+ | `uv.lock` | Pinned dependency lockfile |
165
+ | `README.md` | User-facing quickstart (install, commands, storage layout) |
166
+ | `logo.svg` | Project logo |
167
+ | `.gitignore` | Python ignores + `.ruff_cache/`, `miniouto.toml` |
168
+ | `.venv/` | uv-managed virtualenv |
169
+ | `.ruff_cache/` | Ruff cache |
170
+
171
+ ### `src/miniouto/`
172
+
173
+ | File | Purpose |
174
+ |---|---|
175
+ | `__init__.py` | `__version__ = "0.1.0"` |
176
+ | `paths_runtime.py` | `INVOCATION_CWD: Path` (captured cwd at import, used by every tool to absolutize relative paths) |
177
+ | `cli/__init__.py` | Typer `app`, root callback (TUI fallback), `status` command |
178
+ | `cli/chat.py` | `chat_cmd` — one-shot chat command |
179
+ | `cli/provider.py` | `provider providers/models/add` (catalog browse + add) + `provider custom add` + `provider list/remove/default` |
180
+ | `cli/style.py` | `style list/set/add/update/show` |
181
+ | `cli/skill.py` | `skill list/show` (read-only) |
182
+ | `cli/tui.py` | `ChatTUI` (Textual App), `run_tui()`, `tui_summary()`; provider catalog/custom add wizards + model picker |
183
+ | `core/__init__.py` | Re-exports `chat`, `events`, `lma`, `providers`, `runtime` (NOT `context`) |
184
+ | `core/chat.py` | `ChatOptions`, `run_chat(opts, sink=None)`, `ToolCallArgsError`, failure diagnostics, sink dispatchers (`_make_tool_call_dispatcher`, `_make_response_dispatcher`, `_make_iteration_dispatcher`) |
185
+ | `core/context.py` | lma `/model` fetcher (via `core.lma.get_model`), `make_summarize_hook` |
186
+ | `core/events.py` | `LoopEvent`, `EventSink` protocol, `NullSink`, `ConsoleEventSink` (CLI spinner + loop-event rendering) |
187
+ | `core/lma.py` | `lma.blp.sh` REST client + `slugify` + `find_provider`; in-process 10-min cache |
188
+ | `core/providers.py` | `SUPPORTED_FORMATS`, `sdk_to_format`, `add_provider_from_lma`, `build_coreouto_provider`, `clear_coreouto_state` |
189
+ | `core/runtime.py` | `RuntimeConfig`, `ChatOverrides`, `build_runtime`, subagent tool, hooks |
190
+ | `storage/__init__.py` | Re-exports submodules (NOT `skills`) |
191
+ | `storage/paths.py` | Path constants (incl. `STYLE_REPOS_FILE`) + `ensure_dirs()` (force-refreshes bundled styles) |
192
+ | `storage/providers.py` | `Provider` dataclass (with `source: SOURCE_CUSTOM \| SOURCE_LMA`) + `SOURCE_*`/`VALID_SOURCES` constants + TOML CRUD |
193
+ | `storage/sessions.py` | `MessageRecord` + JSON CRUD |
194
+ | `storage/settings.py` | `Settings` (`provider`, `model`, `style`, `session`, `theme`) + TOML CRUD |
195
+ | `storage/skills.py` | `Skill` discovery from `~/.agents/skills/` (NOT in `__all__`) |
196
+ | `storage/styles.py` | Style CRUD + `add_from_repo` (records repo in `style_repos.toml`) + `record_repo`/`list_repos` + `split_style` + `builtin_default` |
197
+ | `storage/toml_io.py` | `tomllib` + `tomli_w` wrapper |
198
+ | `tools/__init__.py` | Re-exports + `normalize_for_matching` |
199
+ | `tools/_normalize.py` | smart-quote/dash/NBSP/zero-width normalization |
200
+ | `tools/bash.py` | `async bash(command, *, timeout_seconds, cwd, env)` |
201
+ | `tools/delete.py` | `delete(file_path)` |
202
+ | `tools/edit.py` | `edit(file_path, edits)` — batch search/replace |
203
+ | `tools/media.py` | `load_image/load_video/load_audio(file_path)` → `LoadedMedia` (pure stdlib; `registry.py` wraps results into `co.ImageBlock`/`VideoBlock`/`AudioBlock`) |
204
+ | `tools/write.py` | `write(file_path, content)` — refuses overwrite |
205
+ | `tools/registry.py` | `register_all()` — wires Write/Edit/Delete/Bash/Image/Video/Audio into coreouto |
206
+ | `default_style/default.md` | Minimal fallback style |
207
+ | `default_style/claude.md` | Claude Code-style (~14 KB) |
208
+ | `default_style/codex.md` | OpenAI Codex CLI-style (~16 KB) |
209
+ | `default_style/opencode.md` | OpenCode-style (~9 KB) |
210
+ | `default_style/oh-my-opencode.md` | "Sisyphus" orchestrator (~11 KB) |
211
+ | `default_style/codebuff.md` | "Buffy" orchestrator (~10 KB) |
212
+ | `tui/` | **EMPTY placeholder** — TUI code lives in `cli/tui.py` |
213
+ | `utils/` | **EMPTY placeholder** — no code anywhere |
214
+
215
+ ### `docs/` (this directory's documentation)
216
+
217
+ | File | Covers |
218
+ |---|---|
219
+ | `docs/README.md` | Index of all docs |
220
+ | `docs/architecture.md` | High-level architecture & data flow |
221
+ | `docs/cli.md` | All CLI commands reference |
222
+ | `docs/storage.md` | Filesystem layout & persistence layer |
223
+ | `docs/core.md` | Chat loop, runtime, providers, context |
224
+ | `docs/tools.md` | Write/Edit/Delete/Bash tool internals |
225
+ | `docs/styles.md` | Style document system & bundled templates |
226
+ | `docs/skills.md` | Skills system from `~/.agents/skills/` |
227
+ | `docs/lma.md` | lma (llm-model-api) integration: provider/model discovery, context caps, CLI + TUI flows |
228
+ | `docs/development.md` | Dev setup, build, lint, contributing notes |
229
+
230
+ ---
231
+
232
+ ## Common modifications (quick recipes)
233
+
234
+ ### "Add a new CLI subcommand"
235
+ 1. Create `src/miniouto/cli/<name>.py` with `app = typer.Typer(...)`.
236
+ 2. Add `app.add_typer(<name>_module.app, name="<name>")` in `cli/__init__.py`.
237
+ 3. Document in `docs/cli.md`.
238
+
239
+ ### "Add a new tool"
240
+ See `docs/tools.md` § "Adding a new tool". TL;DR:
241
+ 1. `src/miniouto/tools/<name>.py` with the function (pure stdlib — no coreouto import; return a plain data structure if multimodal, like `media.py`'s `LoadedMedia`).
242
+ 2. `tools/registry.py`: schema, description, handler, `_register_if_missing` call. For multimodal tools the handler returns `list[co.ContentBlock]` — see the `Image`/`Video`/`Audio` handlers.
243
+ 3. `core/runtime.py`: add name to `ALL_TOOLS` (visible to both presets) or a new list.
244
+ 4. `core/chat.py`: add the name to `_LOGGABLE_TOOL_NAMES`, the tool-name set in `_make_tool_call_dispatcher`, and a branch in `_short_arg_summary` so loop events + failure diagnostics render the tool.
245
+ 5. Update `default_style/*.md` if the tool's name or behavior should be documented to the model.
246
+ 6. If the tool returns multimodal content, note that provider support varies (OpenAI Chat Completions rejects all multimodal blocks; OpenAI Responses API rejects video/audio). **Do not** put provider names in the description or style prompts — the agent cannot introspect its provider, so such hints are unactionable. Let provider rejections surface as `ValueError` at call time. Document the matrix in `docs/tools.md` for human operators.
247
+
248
+ ### "Add a new bundled style"
249
+ 1. Create `src/miniouto/default_style/<name>.md` (use the `<outo>` / `<subagent>` structure).
250
+ 2. It auto-seeds into `~/.miniouto/style/` and is force-refreshed on every `ensure_dirs()` call (overwrites any same-name installed file when content differs). To let users customize it, copy to a new name rather than editing the bundled one.
251
+ 3. Document in `docs/styles.md`.
252
+
253
+ ### "Add a new provider format"
254
+ 1. `core/providers.py`: add to `SUPPORTED_FORMATS`, add an `_instantiate` branch.
255
+ 2. `cli/provider.py`: update `FORMAT_HELP`.
256
+ 3. If the new format is reachable via an lma SDK, also extend `_SDK_TO_FORMAT` in `core/providers.py` so the TUI "add from catalog…" wizard and the `provider providers` CLI both surface it as addable.
257
+ 4. Document in `docs/cli.md`, `docs/core.md`, and `docs/lma.md`.
258
+
259
+ ### "Change the storage root"
260
+ Only one place: `src/miniouto/storage/paths.py`. Update the `ROOT` constant.
261
+
262
+ ### "Change the active tool set"
263
+ `src/miniouto/core/runtime.py:ALL_TOOLS`. Both presets share this list (both `register_agent_preset("outo", tools=ALL_TOOLS, …)` and `register_agent_preset("subagent", tools=ALL_TOOLS, …)` reference it). If you need asymmetric visibility, create separate lists and edit the `tools=` argument in each `register_agent_preset` call. (Do **not** confuse this with `_resolve_both_styles`, which only resolves the style *prompts*, not the tool lists.)
264
+
265
+ ### "Add tests"
266
+ The test directory doesn't exist yet. Suggested setup in `docs/development.md`. Start with `tools/edit.py` — highest-value, easiest to break with refactors.
267
+
268
+ ---
269
+
270
+ ## Things that look like bugs but aren't (and things that ARE bugs)
271
+
272
+ ### NOT bugs (intentional)
273
+
274
+ - **`tui/` and `utils/` are empty** — placeholder directories from an older layout. The TUI code is in `cli/tui.py`. Don't add code to those empty dirs without first deciding the right home for it.
275
+ - **`core/context.py` is not in `core/__init__.py`'s `__all__`** — it's an implementation detail of `runtime.build_runtime`.
276
+ - **`storage/skills.py` is not in `storage/__init__.py`'s `__all__`** — it's imported directly as `skill_store`.
277
+ - **`Write` refuses to overwrite** — by design. The agent should use `Edit` for modifications.
278
+ - **`continue_loop` is referenced in every bundled style** but **not registered** in `tools/registry.py`. Models improvise. If you want this to actually work, register a no-op tool and add it to `ALL_TOOLS`.
279
+
280
+ ### Bugs / cleanup opportunities
281
+
282
+ 1. **No tests directory exists.** The codebase has zero automated test coverage. `tools/edit.py` and `core/context.py:make_summarize_hook` are the highest-value test targets.
283
+ 2. **Four of the six bundled styles** (`claude.md`, `codex.md`, `opencode.md`, `oh-my-opencode.md`) describe a `claude.md` / `codex.md` / `oh-my-opencode.md` / `opencode.md` CWD memory file. **No such loader exists in miniouto.** Either implement it (in `core/runtime.py:_load_active_skills` or a sibling) or edit the styles to remove the misleading references.
284
+ 3. **`tools/registry.py:_register_if_missing` accepts but silently discards the `schema` parameter** — the `_xxx_schema()` dicts are computed at registration time but never passed to `coreouto.register_tool`. Only the handler's Python type hints and the `description` string reach the model. The schema dicts are effectively dead code.
285
+
286
+ ---
287
+
288
+ ## Dependency reference
289
+
290
+ | Package | Min version | Role |
291
+ |---|---|---|
292
+ | `coreouto[all]` | 0.4.2 | Agent loop, providers, tool registry, hooks (the runtime) |
293
+ | `typer` | 0.12.0 | CLI framework |
294
+ | `rich` | 13.7.0 | Terminal output, tables, markdown |
295
+ | `textual` | 0.80.0 | TUI framework |
296
+ | `pydantic` | 2.0 | Data models (used by coreouto) |
297
+ | `httpx` | 0.27.0 | HTTP client (`lma` REST client, style repo fetcher) |
298
+ | `tomli-w` | 1.0.0 | TOML serializer (paired with stdlib `tomllib`) |
299
+
300
+ The `[all]` extra on `coreouto` pulls in all four provider SDKs. Anything beyond these seven packages should be discussed before adding.
301
+
302
+ ---
303
+
304
+ ## When in doubt
305
+
306
+ 1. **Search the docs first.** `docs/README.md` is the index. Use `grep` on `docs/*.md` for keywords.
307
+ 2. **Read the relevant module's `__init__.py`** — it usually lists what the package exports.
308
+ 3. **Look at the bundled styles** for examples of how the model sees the system.
309
+ 4. **Check `docs/development.md` "Known sharp edges"** before doing anything risky.
310
+ 5. **If you're about to delete code, run `git blame` first** — the comments often explain *why* it exists.
miniouto-0.1.0/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.