untaped 2.4.4__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 (52) hide show
  1. untaped-2.4.4/LICENSE +21 -0
  2. untaped-2.4.4/PKG-INFO +153 -0
  3. untaped-2.4.4/README.md +133 -0
  4. untaped-2.4.4/pyproject.toml +117 -0
  5. untaped-2.4.4/src/untaped/__init__.py +10 -0
  6. untaped-2.4.4/src/untaped/api.py +130 -0
  7. untaped-2.4.4/src/untaped/app_context.py +70 -0
  8. untaped-2.4.4/src/untaped/batch.py +114 -0
  9. untaped-2.4.4/src/untaped/cli.py +372 -0
  10. untaped-2.4.4/src/untaped/config/__init__.py +5 -0
  11. untaped-2.4.4/src/untaped/config/application/__init__.py +19 -0
  12. untaped-2.4.4/src/untaped/config/application/context.py +67 -0
  13. untaped-2.4.4/src/untaped/config/application/get_setting.py +26 -0
  14. untaped-2.4.4/src/untaped/config/application/list_settings.py +135 -0
  15. untaped-2.4.4/src/untaped/config/application/ports.py +31 -0
  16. untaped-2.4.4/src/untaped/config/application/set_setting.py +39 -0
  17. untaped-2.4.4/src/untaped/config/application/unset_setting.py +40 -0
  18. untaped-2.4.4/src/untaped/config/domain/__init__.py +4 -0
  19. untaped-2.4.4/src/untaped/config/domain/formatting.py +28 -0
  20. untaped-2.4.4/src/untaped/config/domain/models.py +49 -0
  21. untaped-2.4.4/src/untaped/config/infrastructure/__init__.py +3 -0
  22. untaped-2.4.4/src/untaped/config/infrastructure/settings_repo.py +181 -0
  23. untaped-2.4.4/src/untaped/config_app.py +406 -0
  24. untaped-2.4.4/src/untaped/config_file.py +207 -0
  25. untaped-2.4.4/src/untaped/config_schema.py +142 -0
  26. untaped-2.4.4/src/untaped/errors.py +74 -0
  27. untaped-2.4.4/src/untaped/http.py +549 -0
  28. untaped-2.4.4/src/untaped/identity.py +32 -0
  29. untaped-2.4.4/src/untaped/output.py +54 -0
  30. untaped-2.4.4/src/untaped/pipe.py +96 -0
  31. untaped-2.4.4/src/untaped/profile/__init__.py +17 -0
  32. untaped-2.4.4/src/untaped/profile/app.py +263 -0
  33. untaped-2.4.4/src/untaped/profile/models.py +42 -0
  34. untaped-2.4.4/src/untaped/profile/ports.py +46 -0
  35. untaped-2.4.4/src/untaped/profile/repository.py +119 -0
  36. untaped-2.4.4/src/untaped/profile/use_cases.py +208 -0
  37. untaped-2.4.4/src/untaped/profile_resolver.py +139 -0
  38. untaped-2.4.4/src/untaped/progress.py +224 -0
  39. untaped-2.4.4/src/untaped/prompts.py +274 -0
  40. untaped-2.4.4/src/untaped/py.typed +0 -0
  41. untaped-2.4.4/src/untaped/quiet.py +33 -0
  42. untaped-2.4.4/src/untaped/run.py +322 -0
  43. untaped-2.4.4/src/untaped/settings.py +376 -0
  44. untaped-2.4.4/src/untaped/settings_layout.py +83 -0
  45. untaped-2.4.4/src/untaped/skills.py +390 -0
  46. untaped-2.4.4/src/untaped/skills_app.py +134 -0
  47. untaped-2.4.4/src/untaped/stdin.py +116 -0
  48. untaped-2.4.4/src/untaped/testing.py +127 -0
  49. untaped-2.4.4/src/untaped/theme.py +148 -0
  50. untaped-2.4.4/src/untaped/tool.py +85 -0
  51. untaped-2.4.4/src/untaped/ui.py +584 -0
  52. untaped-2.4.4/src/untaped/verbose.py +59 -0
untaped-2.4.4/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025-2026 Alexis Beaulieu
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
untaped-2.4.4/PKG-INFO ADDED
@@ -0,0 +1,153 @@
1
+ Metadata-Version: 2.4
2
+ Name: untaped
3
+ Version: 2.4.4
4
+ Summary: A batteries-included CLI framework for building standalone DevOps tools.
5
+ Author: Alexis Beaulieu
6
+ Author-email: Alexis Beaulieu <alexisbeaulieu97@gmail.com>
7
+ License-Expression: MIT
8
+ License-File: LICENSE
9
+ Requires-Dist: cyclopts>=4.16.0,<5
10
+ Requires-Dist: filelock>=3.29.0
11
+ Requires-Dist: httpx>=0.28.1
12
+ Requires-Dist: prompt-toolkit>=3.0.52
13
+ Requires-Dist: pydantic>=2.13.3
14
+ Requires-Dist: pydantic-settings>=2.14.0
15
+ Requires-Dist: pyyaml>=6.0.3
16
+ Requires-Dist: rich>=15.0.0
17
+ Requires-Dist: truststore>=0.10.4
18
+ Requires-Python: >=3.14
19
+ Description-Content-Type: text/markdown
20
+
21
+ # untaped
22
+
23
+ **untaped** is a batteries-included CLI framework for building standalone
24
+ DevOps tools on [cyclopts](https://cyclopts.readthedocs.io/). It is an SDK, not
25
+ an app: there is no central `untaped` command. You build a tool, depend on the
26
+ SDK, and ship an independent CLI.
27
+
28
+ The SDK gives every tool, for free:
29
+
30
+ - **Config** — a shared `~/.untaped/config.yml` with top-level `active:` /
31
+ `profiles:`, per-profile SDK `http` / `ui` settings, and each tool's own
32
+ profile settings plus tool-managed top-level state.
33
+ - **Profiles** — named overlays (`dev`, `prod`, `homelab`) and a `--profile`
34
+ root option, built in.
35
+ - **Themes** — built-in theme presets for consistent terminal styling.
36
+ - **Output** — consistent `--format json|yaml|table|raw|pipe` and `--columns`,
37
+ so commands compose. `pipe` is a self-describing NDJSON record stream another
38
+ untaped tool can read back. `emit(...)` renders a single entity as a vertical
39
+ detail view or a sequence as a collection, dispatching by shape.
40
+ - **HTTP / UI helpers** — an `HttpClient` with profile-aware TLS, automatic
41
+ retries for transient failures (`RetryPolicy`), and pagination helpers, plus a
42
+ `UiContext` for messages, prompts, and progress.
43
+ - **Config tooling** — `<tool> config doctor` diagnoses the shared file and
44
+ `<tool> config edit` opens it in `$VISUAL`/`$EDITOR`; a `--quiet` root option
45
+ mutes progress and `success`/`info` chatter.
46
+
47
+ You import the surface from `untaped.api` (re-exported from the `untaped`
48
+ package root), declare a `ToolSpec`, and call `run_tool(app, spec)` from your
49
+ tool's `main()`. The contract surface is the `__all__` list in
50
+ [`src/untaped/api.py`](./src/untaped/api.py).
51
+
52
+ ```python
53
+ # my_tool/__main__.py
54
+ from untaped.api import create_app, run_tool, ToolSpec
55
+ from my_tool.settings import MyProfile
56
+
57
+ app = create_app(...)
58
+
59
+ def main() -> None:
60
+ run_tool(app, ToolSpec(
61
+ command="untaped-mytool",
62
+ section="mytool",
63
+ profile_model=MyProfile,
64
+ ))
65
+ ```
66
+
67
+ ```toml
68
+ # pyproject.toml
69
+ [project]
70
+ dependencies = [
71
+ "untaped>=2.4.4,<3",
72
+ ]
73
+
74
+ [project.scripts]
75
+ untaped-mytool = "my_tool.__main__:main"
76
+ ```
77
+
78
+ Suite repos may keep a `[tool.uv.sources]` git tag while developing against an
79
+ exact SDK release. Published wheels are built with `uv build --no-sources`, so
80
+ package metadata resolves from the declared PyPI range.
81
+
82
+ ## Requirements
83
+
84
+ Python 3.14 and [uv](https://docs.astral.sh/uv/).
85
+
86
+ ## The suite
87
+
88
+ Seven tools are built on the SDK. Each is an independent CLI installed into its
89
+ own `uv tool` environment. As each PyPI-backed tool completes its first package
90
+ release, install it by package name:
91
+
92
+ ```bash
93
+ uv tool install untaped-github
94
+ uv tool install untaped-jira
95
+ uv tool install untaped-awx
96
+ uv tool install untaped-ansible
97
+ uv tool install untaped-workspace
98
+ uv tool install untaped-recipe
99
+ uv tool install git+https://github.com/alexisbeaulieu97/untaped-apple-health.git
100
+ ```
101
+
102
+ `untaped-apple-health` is outside the current PyPI release wave; install it from
103
+ git until that repo owns a package release workflow.
104
+
105
+ Because every tool reads the same `~/.untaped/config.yml` and shares the same
106
+ `--format pipe` envelope, independently installed tools interoperate and
107
+ compose:
108
+
109
+ ```bash
110
+ untaped-awx job-templates list --format raw --columns name \
111
+ | fzf \
112
+ | untaped-awx job-templates get --stdin --format json
113
+ ```
114
+
115
+ ## Documentation
116
+
117
+ User-facing docs live in [`docs/`](./docs/README.md):
118
+
119
+ - [Building a tool with the untaped SDK](./docs/plugins.md) — the guide to
120
+ declaring a `ToolSpec`, wiring `run_tool`, and packaging an independent CLI.
121
+ - [Configuration](./docs/configuration.md) — the `~/.untaped/config.yml`
122
+ format, profiles, secrets, and TLS.
123
+ - [Agent Skills](./docs/skills.md) — how each tool ships and installs
124
+ Codex/Claude agent skills.
125
+ - [Releasing](./docs/release.md) — PyPI/TestPyPI workflow, Trusted Publisher
126
+ setup, and recovery rules.
127
+ - [Architecture decisions](./docs/decisions.md) — the settled ADRs behind the
128
+ SDK-only direction.
129
+
130
+ Per-tool command references live in each tool's own repo:
131
+
132
+ - [GitHub](https://github.com/alexisbeaulieu97/untaped-github)
133
+ - [Jira](https://github.com/alexisbeaulieu97/untaped-jira)
134
+ - [AWX / AAP](https://github.com/alexisbeaulieu97/untaped-awx)
135
+ - [Ansible](https://github.com/alexisbeaulieu97/untaped-ansible)
136
+ - [Workspaces](https://github.com/alexisbeaulieu97/untaped-workspace)
137
+ - [Recipe](https://github.com/alexisbeaulieu97/untaped-recipe)
138
+ - [Apple Health](https://github.com/alexisbeaulieu97/untaped-apple-health)
139
+
140
+ ## Security
141
+
142
+ Please report suspected vulnerabilities privately. See
143
+ [SECURITY.md](./SECURITY.md).
144
+
145
+ ## Contributing
146
+
147
+ See [CONTRIBUTING.md](./CONTRIBUTING.md) and [AGENTS.md](./AGENTS.md) for the
148
+ local workflow, architecture rules, and recipes for extending the SDK and its
149
+ tools.
150
+
151
+ ## License
152
+
153
+ MIT. See [LICENSE](./LICENSE).
@@ -0,0 +1,133 @@
1
+ # untaped
2
+
3
+ **untaped** is a batteries-included CLI framework for building standalone
4
+ DevOps tools on [cyclopts](https://cyclopts.readthedocs.io/). It is an SDK, not
5
+ an app: there is no central `untaped` command. You build a tool, depend on the
6
+ SDK, and ship an independent CLI.
7
+
8
+ The SDK gives every tool, for free:
9
+
10
+ - **Config** — a shared `~/.untaped/config.yml` with top-level `active:` /
11
+ `profiles:`, per-profile SDK `http` / `ui` settings, and each tool's own
12
+ profile settings plus tool-managed top-level state.
13
+ - **Profiles** — named overlays (`dev`, `prod`, `homelab`) and a `--profile`
14
+ root option, built in.
15
+ - **Themes** — built-in theme presets for consistent terminal styling.
16
+ - **Output** — consistent `--format json|yaml|table|raw|pipe` and `--columns`,
17
+ so commands compose. `pipe` is a self-describing NDJSON record stream another
18
+ untaped tool can read back. `emit(...)` renders a single entity as a vertical
19
+ detail view or a sequence as a collection, dispatching by shape.
20
+ - **HTTP / UI helpers** — an `HttpClient` with profile-aware TLS, automatic
21
+ retries for transient failures (`RetryPolicy`), and pagination helpers, plus a
22
+ `UiContext` for messages, prompts, and progress.
23
+ - **Config tooling** — `<tool> config doctor` diagnoses the shared file and
24
+ `<tool> config edit` opens it in `$VISUAL`/`$EDITOR`; a `--quiet` root option
25
+ mutes progress and `success`/`info` chatter.
26
+
27
+ You import the surface from `untaped.api` (re-exported from the `untaped`
28
+ package root), declare a `ToolSpec`, and call `run_tool(app, spec)` from your
29
+ tool's `main()`. The contract surface is the `__all__` list in
30
+ [`src/untaped/api.py`](./src/untaped/api.py).
31
+
32
+ ```python
33
+ # my_tool/__main__.py
34
+ from untaped.api import create_app, run_tool, ToolSpec
35
+ from my_tool.settings import MyProfile
36
+
37
+ app = create_app(...)
38
+
39
+ def main() -> None:
40
+ run_tool(app, ToolSpec(
41
+ command="untaped-mytool",
42
+ section="mytool",
43
+ profile_model=MyProfile,
44
+ ))
45
+ ```
46
+
47
+ ```toml
48
+ # pyproject.toml
49
+ [project]
50
+ dependencies = [
51
+ "untaped>=2.4.4,<3",
52
+ ]
53
+
54
+ [project.scripts]
55
+ untaped-mytool = "my_tool.__main__:main"
56
+ ```
57
+
58
+ Suite repos may keep a `[tool.uv.sources]` git tag while developing against an
59
+ exact SDK release. Published wheels are built with `uv build --no-sources`, so
60
+ package metadata resolves from the declared PyPI range.
61
+
62
+ ## Requirements
63
+
64
+ Python 3.14 and [uv](https://docs.astral.sh/uv/).
65
+
66
+ ## The suite
67
+
68
+ Seven tools are built on the SDK. Each is an independent CLI installed into its
69
+ own `uv tool` environment. As each PyPI-backed tool completes its first package
70
+ release, install it by package name:
71
+
72
+ ```bash
73
+ uv tool install untaped-github
74
+ uv tool install untaped-jira
75
+ uv tool install untaped-awx
76
+ uv tool install untaped-ansible
77
+ uv tool install untaped-workspace
78
+ uv tool install untaped-recipe
79
+ uv tool install git+https://github.com/alexisbeaulieu97/untaped-apple-health.git
80
+ ```
81
+
82
+ `untaped-apple-health` is outside the current PyPI release wave; install it from
83
+ git until that repo owns a package release workflow.
84
+
85
+ Because every tool reads the same `~/.untaped/config.yml` and shares the same
86
+ `--format pipe` envelope, independently installed tools interoperate and
87
+ compose:
88
+
89
+ ```bash
90
+ untaped-awx job-templates list --format raw --columns name \
91
+ | fzf \
92
+ | untaped-awx job-templates get --stdin --format json
93
+ ```
94
+
95
+ ## Documentation
96
+
97
+ User-facing docs live in [`docs/`](./docs/README.md):
98
+
99
+ - [Building a tool with the untaped SDK](./docs/plugins.md) — the guide to
100
+ declaring a `ToolSpec`, wiring `run_tool`, and packaging an independent CLI.
101
+ - [Configuration](./docs/configuration.md) — the `~/.untaped/config.yml`
102
+ format, profiles, secrets, and TLS.
103
+ - [Agent Skills](./docs/skills.md) — how each tool ships and installs
104
+ Codex/Claude agent skills.
105
+ - [Releasing](./docs/release.md) — PyPI/TestPyPI workflow, Trusted Publisher
106
+ setup, and recovery rules.
107
+ - [Architecture decisions](./docs/decisions.md) — the settled ADRs behind the
108
+ SDK-only direction.
109
+
110
+ Per-tool command references live in each tool's own repo:
111
+
112
+ - [GitHub](https://github.com/alexisbeaulieu97/untaped-github)
113
+ - [Jira](https://github.com/alexisbeaulieu97/untaped-jira)
114
+ - [AWX / AAP](https://github.com/alexisbeaulieu97/untaped-awx)
115
+ - [Ansible](https://github.com/alexisbeaulieu97/untaped-ansible)
116
+ - [Workspaces](https://github.com/alexisbeaulieu97/untaped-workspace)
117
+ - [Recipe](https://github.com/alexisbeaulieu97/untaped-recipe)
118
+ - [Apple Health](https://github.com/alexisbeaulieu97/untaped-apple-health)
119
+
120
+ ## Security
121
+
122
+ Please report suspected vulnerabilities privately. See
123
+ [SECURITY.md](./SECURITY.md).
124
+
125
+ ## Contributing
126
+
127
+ See [CONTRIBUTING.md](./CONTRIBUTING.md) and [AGENTS.md](./AGENTS.md) for the
128
+ local workflow, architecture rules, and recipes for extending the SDK and its
129
+ tools.
130
+
131
+ ## License
132
+
133
+ MIT. See [LICENSE](./LICENSE).
@@ -0,0 +1,117 @@
1
+ [project]
2
+ name = "untaped"
3
+ version = "2.4.4"
4
+ description = "A batteries-included CLI framework for building standalone DevOps tools."
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ license-files = ["LICENSE"]
8
+ authors = [
9
+ { name = "Alexis Beaulieu", email = "alexisbeaulieu97@gmail.com" },
10
+ ]
11
+ requires-python = ">=3.14"
12
+ dependencies = [
13
+ "cyclopts>=4.16.0,<5",
14
+ "filelock>=3.29.0",
15
+ "httpx>=0.28.1",
16
+ "prompt-toolkit>=3.0.52",
17
+ "pydantic>=2.13.3",
18
+ "pydantic-settings>=2.14.0",
19
+ "pyyaml>=6.0.3",
20
+ "rich>=15.0.0",
21
+ "truststore>=0.10.4",
22
+ ]
23
+
24
+ [build-system]
25
+ requires = ["uv_build>=0.11.8,<0.12.0"]
26
+ build-backend = "uv_build"
27
+
28
+ [dependency-groups]
29
+ dev = [
30
+ "mypy>=1.20.2",
31
+ "pre-commit>=4.6.0",
32
+ "pytest>=9.0.3",
33
+ "pytest-cov>=7.1.0",
34
+ "respx>=0.23.1",
35
+ "ruff>=0.15.12",
36
+ "types-pyyaml>=6.0.12.20260408",
37
+ ]
38
+
39
+ [tool.ruff]
40
+ line-length = 100
41
+ target-version = "py314"
42
+
43
+ [tool.ruff.lint]
44
+ select = [
45
+ "E", # pycodestyle errors
46
+ "F", # pyflakes
47
+ "I", # isort
48
+ "UP", # pyupgrade
49
+ "B", # flake8-bugbear
50
+ "SIM", # flake8-simplify
51
+ "TID", # flake8-tidy-imports
52
+ "C90", # mccabe complexity (gate set in [tool.ruff.lint.mccabe])
53
+ "RUF", # ruff-specific
54
+ ]
55
+ extend-select = ["PLC0415"]
56
+ ignore = []
57
+
58
+ [tool.ruff.lint.flake8-tidy-imports]
59
+ ban-relative-imports = "all"
60
+
61
+ [tool.ruff.lint.mccabe]
62
+ max-complexity = 12
63
+
64
+ [tool.ruff.lint.per-file-ignores]
65
+ # Tests can use assert statements; in-function imports are routine and
66
+ # idiomatic in tests (no startup-latency cost).
67
+ "**/tests/**" = ["S101", "PLC0415"]
68
+
69
+ [tool.ruff.format]
70
+ quote-style = "double"
71
+ indent-style = "space"
72
+
73
+ [tool.mypy]
74
+ python_version = "3.14"
75
+ strict = true
76
+ warn_unused_configs = true
77
+ warn_unreachable = true
78
+ warn_redundant_casts = true
79
+ warn_unused_ignores = true
80
+ disallow_any_generics = true
81
+ disallow_untyped_defs = true
82
+ no_implicit_optional = true
83
+ plugins = ["pydantic.mypy"]
84
+ # Type-check src/ only; tests are validated by running them.
85
+ packages = [
86
+ "untaped",
87
+ ]
88
+
89
+ [tool.pytest.ini_options]
90
+ minversion = "8.0"
91
+ testpaths = ["tests"]
92
+ addopts = [
93
+ "-ra",
94
+ "--strict-markers",
95
+ "--strict-config",
96
+ "--cov",
97
+ "--cov-report=term-missing",
98
+ "--import-mode=importlib",
99
+ ]
100
+ markers = [
101
+ "integration: cross-package or external-service tests",
102
+ ]
103
+
104
+ [tool.coverage.run]
105
+ branch = true
106
+ source = ["src"]
107
+ omit = ["**/tests/**", "**/__main__.py"]
108
+
109
+ [tool.coverage.report]
110
+ fail_under = 80
111
+ show_missing = true
112
+ skip_covered = false
113
+ exclude_also = [
114
+ "if TYPE_CHECKING:",
115
+ "raise NotImplementedError",
116
+ "@(abc\\.)?abstractmethod",
117
+ ]
@@ -0,0 +1,10 @@
1
+ """The untaped SDK — a batteries-included CLI framework built on cyclopts.
2
+
3
+ This package root re-exports the public surface defined in :mod:`untaped.api`,
4
+ so ``from untaped import X`` and ``from untaped.api import X`` are equivalent.
5
+ """
6
+
7
+ from untaped import api as _api
8
+ from untaped.api import * # noqa: F403
9
+
10
+ __all__ = list(_api.__all__)
@@ -0,0 +1,130 @@
1
+ """The untaped SDK surface.
2
+
3
+ Tools import from this module (``from untaped.api import ...``) instead of
4
+ reaching into SDK internals. Names listed in ``__all__`` are the SDK contract:
5
+ additions are backwards-compatible; removing a name or changing its behaviour
6
+ is a major SDK version event. Internal modules stay free to reorganize as long
7
+ as this surface keeps resolving. ``untaped`` (the package root) re-exports this
8
+ exact surface, so ``from untaped import X`` and ``from untaped.api import X``
9
+ are equivalent.
10
+ """
11
+
12
+ from __future__ import annotations
13
+
14
+ from untaped.app_context import AppContext, app_context
15
+ from untaped.batch import BatchOutcome, batch_apply
16
+ from untaped.cli import (
17
+ ColumnsOption,
18
+ FormatOption,
19
+ clamp_parallel,
20
+ create_app,
21
+ echo,
22
+ emit,
23
+ existing_directory,
24
+ existing_file,
25
+ parse_kv_pairs,
26
+ raise_usage,
27
+ render_rows,
28
+ report_errors,
29
+ resolve_each,
30
+ )
31
+ from untaped.config_file import ensure_config, mutate_tool_state, read_tool_state
32
+ from untaped.errors import (
33
+ ConfigError,
34
+ HttpError,
35
+ HttpStatusError,
36
+ HttpTransportError,
37
+ UntapedError,
38
+ first_validation_error,
39
+ )
40
+ from untaped.http import (
41
+ HttpClient,
42
+ RetryPolicy,
43
+ connected_client,
44
+ paginate_offset,
45
+ paginate_pages,
46
+ resolve_verify,
47
+ )
48
+ from untaped.output import OutputFormat
49
+ from untaped.pipe import PipeEnvelope, common_kind, is_envelope_line, parse_envelope_line
50
+ from untaped.progress import ProgressHandle
51
+ from untaped.prompts import PromptChoice
52
+ from untaped.run import build_tool_app, run_tool
53
+ from untaped.settings import (
54
+ HttpSettings,
55
+ get_config_section,
56
+ get_core_settings,
57
+ get_settings,
58
+ )
59
+ from untaped.stdin import read_identifiers, read_records, read_stdin
60
+ from untaped.theme import ThemeSpec
61
+ from untaped.tool import SkillAsset, ToolSpec, register_tool
62
+ from untaped.ui import UiContext, ui_context
63
+
64
+
65
+ def invalidate_settings_cache() -> None:
66
+ """Drop the cached settings instance so the next read re-resolves.
67
+
68
+ Root-option handlers (e.g. the built-in ``--profile``) call this after
69
+ changing process state that feeds settings resolution.
70
+ """
71
+ get_settings.cache_clear()
72
+
73
+
74
+ __all__ = [
75
+ "AppContext",
76
+ "BatchOutcome",
77
+ "ColumnsOption",
78
+ "ConfigError",
79
+ "FormatOption",
80
+ "HttpClient",
81
+ "HttpError",
82
+ "HttpSettings",
83
+ "HttpStatusError",
84
+ "HttpTransportError",
85
+ "OutputFormat",
86
+ "PipeEnvelope",
87
+ "ProgressHandle",
88
+ "PromptChoice",
89
+ "RetryPolicy",
90
+ "SkillAsset",
91
+ "ThemeSpec",
92
+ "ToolSpec",
93
+ "UiContext",
94
+ "UntapedError",
95
+ "app_context",
96
+ "batch_apply",
97
+ "build_tool_app",
98
+ "clamp_parallel",
99
+ "common_kind",
100
+ "connected_client",
101
+ "create_app",
102
+ "echo",
103
+ "emit",
104
+ "ensure_config",
105
+ "existing_directory",
106
+ "existing_file",
107
+ "first_validation_error",
108
+ "get_config_section",
109
+ "get_core_settings",
110
+ "get_settings",
111
+ "invalidate_settings_cache",
112
+ "is_envelope_line",
113
+ "mutate_tool_state",
114
+ "paginate_offset",
115
+ "paginate_pages",
116
+ "parse_envelope_line",
117
+ "parse_kv_pairs",
118
+ "raise_usage",
119
+ "read_identifiers",
120
+ "read_records",
121
+ "read_stdin",
122
+ "read_tool_state",
123
+ "register_tool",
124
+ "render_rows",
125
+ "report_errors",
126
+ "resolve_each",
127
+ "resolve_verify",
128
+ "run_tool",
129
+ "ui_context",
130
+ ]
@@ -0,0 +1,70 @@
1
+ """Per-invocation tool execution context.
2
+
3
+ ``app_context()`` resolves settings exactly once and hands a tool a frozen
4
+ value object. Profile (or any other scope) selection happens before command
5
+ dispatch via the root ``--profile`` option, so nothing about the resolution
6
+ leaks into ambient process state from here.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ from dataclasses import dataclass
12
+
13
+ from pydantic import BaseModel
14
+
15
+ from untaped.errors import ConfigError
16
+ from untaped.settings import HttpSettings, Settings, get_settings
17
+ from untaped.theme import UiSettings, resolve_theme_or_default
18
+ from untaped.ui import UiContext, ui_context
19
+
20
+
21
+ @dataclass(frozen=True)
22
+ class AppContext:
23
+ """Resolved settings plus typed accessors handed to a tool command."""
24
+
25
+ settings: Settings
26
+
27
+ def section[T: BaseModel](self, name: str, model_cls: type[T]) -> T:
28
+ """Return one typed, registered settings section.
29
+
30
+ Unlike :func:`untaped.settings.get_config_section`, this never builds
31
+ a one-off model for unregistered sections — the context is a frozen
32
+ snapshot, so it can only serve sections that were registered (via
33
+ :func:`untaped.tool.register_tool`) before it was created.
34
+ """
35
+ value = getattr(self.settings, name, None)
36
+ if value is None:
37
+ raise ConfigError(
38
+ f"config section {name!r} is not registered; register the tool's "
39
+ f"section with untaped.tool.register_tool before resolving a context"
40
+ )
41
+ if isinstance(value, model_cls):
42
+ return value
43
+ if isinstance(value, BaseModel):
44
+ return model_cls.model_validate(value.model_dump())
45
+ return model_cls.model_validate(value)
46
+
47
+ @property
48
+ def http(self) -> HttpSettings:
49
+ """Cross-cutting HTTP settings for building clients."""
50
+ return self.settings.http
51
+
52
+ def ui(self, *, strict: bool = True) -> UiContext:
53
+ """The themed UI context for messages and prompts.
54
+
55
+ Built from this context's frozen settings snapshot, so the theme is
56
+ stable for the life of the context even if the settings cache is later
57
+ invalidated. ``strict=False`` degrades a theme-resolution
58
+ :class:`ConfigError` (e.g. an unknown theme name) to the default theme.
59
+ """
60
+ theme = resolve_theme_or_default(lambda: self.section("ui", UiSettings), strict=strict)
61
+ return ui_context(theme=theme)
62
+
63
+
64
+ def app_context() -> AppContext:
65
+ """Resolve effective settings once and return a frozen :class:`AppContext`.
66
+
67
+ Profile selection happens before dispatch via the root ``--profile`` option,
68
+ so no parameters are needed here.
69
+ """
70
+ return AppContext(settings=get_settings())