@yahyahammad/venastine 0.1.0

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 (143) hide show
  1. package/.env.example +14 -0
  2. package/LICENSE +201 -0
  3. package/NOTICE +14 -0
  4. package/PRIVACY.md +66 -0
  5. package/README.md +878 -0
  6. package/SECURITY.md +88 -0
  7. package/THIRD_PARTY_NOTICES.md +100 -0
  8. package/agents/builtin/compactor.md +75 -0
  9. package/agents/builtin/explore.md +77 -0
  10. package/agents/builtin/grill-me.md +27 -0
  11. package/agents/builtin/initializer.md +94 -0
  12. package/agents/builtin/pipeline-reviewer.md +100 -0
  13. package/agents/builtin/plan.md +88 -0
  14. package/agents/builtin/review.md +74 -0
  15. package/agents/manager.py +195 -0
  16. package/agents/subagent_tool.py +215 -0
  17. package/agents/tui_commands.py +136 -0
  18. package/bin/venastine.mjs +382 -0
  19. package/config.py +1198 -0
  20. package/core/__init__.py +0 -0
  21. package/core/approval.py +115 -0
  22. package/core/client.py +1548 -0
  23. package/core/compaction.py +959 -0
  24. package/core/config_loader.py +1563 -0
  25. package/core/events.py +61 -0
  26. package/core/interaction.py +328 -0
  27. package/core/loop.py +1353 -0
  28. package/core/memory.py +370 -0
  29. package/core/model_windows.py +175 -0
  30. package/core/pipeline_models.py +176 -0
  31. package/core/reasoning/__init__.py +0 -0
  32. package/core/reasoning/authorization.py +130 -0
  33. package/core/reasoning/base.py +219 -0
  34. package/core/reasoning/confidence_scoring.py +468 -0
  35. package/core/reasoning/events.py +149 -0
  36. package/core/reasoning/json_retry.py +219 -0
  37. package/core/reasoning/orchestrator.py +1382 -0
  38. package/core/reasoning/output_writer.py +286 -0
  39. package/core/reasoning/payload_validation.py +398 -0
  40. package/core/reasoning/pipeline_storage.py +361 -0
  41. package/core/reasoning/review.py +615 -0
  42. package/core/reasoning/scholar.py +434 -0
  43. package/core/reasoning/source_corpus.py +327 -0
  44. package/core/reasoning/source_scoring.py +855 -0
  45. package/core/replay.py +167 -0
  46. package/core/session.py +153 -0
  47. package/core/workspace_trust.py +207 -0
  48. package/credentials.py +180 -0
  49. package/database.py +252 -0
  50. package/env_secrets.py +77 -0
  51. package/json_store.py +123 -0
  52. package/logging_setup.py +185 -0
  53. package/main.py +1959 -0
  54. package/mcp_client/__init__.py +15 -0
  55. package/mcp_client/client.py +499 -0
  56. package/mcp_client/config.py +379 -0
  57. package/mcp_client/registration.py +182 -0
  58. package/memories/manager.py +132 -0
  59. package/memories/tui_commands.py +232 -0
  60. package/package.json +73 -0
  61. package/project_init/config_files.py +278 -0
  62. package/project_init/doc_sets.py +330 -0
  63. package/project_init/generator.py +564 -0
  64. package/project_init/manifest.py +406 -0
  65. package/project_init/tui_commands.py +144 -0
  66. package/prompts/__init__.py +0 -0
  67. package/prompts/annotate.md +14 -0
  68. package/prompts/assumption_audit.md +27 -0
  69. package/prompts/claim_extraction.md +34 -0
  70. package/prompts/completeness.md +18 -0
  71. package/prompts/confidence_tiers.md +23 -0
  72. package/prompts/critic_pass.md +24 -0
  73. package/prompts/final_synthesis.md +13 -0
  74. package/prompts/initial_generation.md +14 -0
  75. package/prompts/preliminary_plan.md +23 -0
  76. package/prompts/revalidate.md +25 -0
  77. package/prompts/revise.md +15 -0
  78. package/prompts/source_grounding.md +66 -0
  79. package/prompts/system_prompts.py +262 -0
  80. package/prompts/universal_system_prompt +7 -0
  81. package/prompts/untrusted_content +1 -0
  82. package/providers.json.example +92 -0
  83. package/pyproject.toml +100 -0
  84. package/requirements.txt +72 -0
  85. package/safety/__init__.py +0 -0
  86. package/safety/policy_enforcement.py +682 -0
  87. package/security/__init__.py +0 -0
  88. package/security/capability.py +177 -0
  89. package/security/permissions.py +190 -0
  90. package/security/posture.py +302 -0
  91. package/security/protected_paths.py +309 -0
  92. package/security/sandbox.py +985 -0
  93. package/skills/builtin/crypto/cryptography-verification.md +66 -0
  94. package/skills/builtin/math/formal-specification.md +67 -0
  95. package/skills/builtin/math/numerical-methods.md +66 -0
  96. package/skills/builtin/math/proof-writing.md +61 -0
  97. package/skills/builtin/research/experiment-design.md +62 -0
  98. package/skills/builtin/research/literature-review.md +65 -0
  99. package/skills/builtin/research/reproducibility.md +55 -0
  100. package/skills/builtin/research/source-evaluation.md +70 -0
  101. package/skills/builtin/research/statistical-inference.md +63 -0
  102. package/skills/builtin/research/technical-writing.md +59 -0
  103. package/skills/builtin/security/cybersecurity-research.md +63 -0
  104. package/skills/builtin/software/code-review.md +61 -0
  105. package/skills/builtin/software/debugging.md +61 -0
  106. package/skills/builtin/software/test-design.md +67 -0
  107. package/skills/manager.py +138 -0
  108. package/skills/tui_commands.py +111 -0
  109. package/storage.py +1005 -0
  110. package/tools/base.py +305 -0
  111. package/tools/builtin/__init__.py +0 -0
  112. package/tools/builtin/_math_common.py +377 -0
  113. package/tools/builtin/_net_common.py +61 -0
  114. package/tools/builtin/arxiv.py +223 -0
  115. package/tools/builtin/ask_user.py +213 -0
  116. package/tools/builtin/discrete_math.py +134 -0
  117. package/tools/builtin/fetch_url.py +153 -0
  118. package/tools/builtin/file_ops.py +412 -0
  119. package/tools/builtin/geometry.py +148 -0
  120. package/tools/builtin/get_time.py +20 -0
  121. package/tools/builtin/linear_algebra.py +155 -0
  122. package/tools/builtin/load_skill.py +66 -0
  123. package/tools/builtin/logic.py +96 -0
  124. package/tools/builtin/pin.py +193 -0
  125. package/tools/builtin/probability_stats.py +228 -0
  126. package/tools/builtin/project_docs.py +405 -0
  127. package/tools/builtin/remember.py +158 -0
  128. package/tools/builtin/shell.py +461 -0
  129. package/tools/builtin/symbolic_math.py +119 -0
  130. package/tools/builtin/todo.py +147 -0
  131. package/tools/builtin/web_search.py +151 -0
  132. package/tools/context.py +136 -0
  133. package/tools/isolation.py +314 -0
  134. package/tools/registry.py +897 -0
  135. package/tui/app.py +3423 -0
  136. package/tui/app.tcss +458 -0
  137. package/tui/commands.py +61 -0
  138. package/tui/diffs.py +265 -0
  139. package/tui/preferences.py +182 -0
  140. package/tui/ravens.py +146 -0
  141. package/tui/screens.py +943 -0
  142. package/tui/themes.py +366 -0
  143. package/tui/widgets.py +1239 -0
package/tui/themes.py ADDED
@@ -0,0 +1,366 @@
1
+ """
2
+ tui/themes.py
3
+
4
+ Fourteen themes: the eight-theme neutral grid (dark/light x
5
+ plain/red/green/blue) plus six standalone tinted themes (matrix,
6
+ nightmare, ember, midnight, glassy-lapis, paper) whose PANELS carry the
7
+ identity -- background/surface/panel are theirs, not the grid's shared
8
+ neutrals.
9
+
10
+ Pure presentation -- no import of core/, no harness state. Two things
11
+ outside this module carry a theme name: the persisted `tui.theme` setting,
12
+ validated by core/config_loader.py's _KNOWN_TUI, and tui/preferences.py's
13
+ remembered choice. The second deliberately does NOT validate against
14
+ THEME_NAMES -- it stores an opaque string and lets the App decide whether
15
+ it still resolves, because ctrl+p's command palette can select one of
16
+ Textual's own built-in themes and a whitelist here would silently forget
17
+ it.
18
+
19
+ Built on textual.theme.Theme (verified against the pinned textual 1.0.0,
20
+ per D22's rule about not assuming a dependency's API shape). Textual
21
+ derives the full variable set from these anchors, so each theme only
22
+ declares the colours that actually differ.
23
+ """
24
+
25
+ from textual.color import Color
26
+ from textual.theme import Theme
27
+
28
+ # Shared neutrals. The accent variants below change only the three hue
29
+ # slots (primary/secondary/accent), so a colour tweak to the base surfaces
30
+ # lands in all eight grid themes at once rather than eight near-copies
31
+ # drifting.
32
+ _DARK_BASE = {
33
+ "background": "#0f1115",
34
+ "surface": "#171a21",
35
+ "panel": "#1e222b",
36
+ "foreground": "#e4e6eb",
37
+ "warning": "#d9a441",
38
+ "error": "#cf5c4a",
39
+ "success": "#5aa86f",
40
+ "dark": True,
41
+ }
42
+
43
+ _LIGHT_BASE = {
44
+ "background": "#f7f7f5",
45
+ "surface": "#ffffff",
46
+ "panel": "#eceae6",
47
+ "foreground": "#1b1c1e",
48
+ "warning": "#9a6d10",
49
+ "error": "#a63a2a",
50
+ "success": "#2f7343",
51
+ "dark": False,
52
+ }
53
+
54
+ # (primary, secondary, accent) per variant. Dark and light get separate
55
+ # values because a hue readable on #0f1115 is usually too pale on #f7f7f5.
56
+ #
57
+ # The four DARK secondaries were lifted in batch 29 (#14): the pass role
58
+ # renders in `secondary`, and every original value sat below 3.5:1 against
59
+ # the shared dark background -- plain at 3.37 was the filed defect, red
60
+ # ~2.7 and blue ~3.0 were the same defect nobody had measured. The floor
61
+ # is pinned in tests/test_themes.py; these are the minimal luminance moves
62
+ # that clear it.
63
+ _ACCENTS_DARK = {
64
+ # dark-plain's ACCENT was lifted in batch 41 (X1), for batch 29's
65
+ # reason applied to a different axis. #14 measured contrast against
66
+ # the BACKGROUND; this is separation between two roles that sit on
67
+ # adjacent lines. `tool` renders in accent and `thinking` in
68
+ # secondary, and on a deliberately monochrome theme hue cannot
69
+ # separate them -- only lightness can. #a9b2c3 was 98.5 redmean
70
+ # units from #8792a2, the tightest secondary/accent pair of all
71
+ # fourteen themes (the next is paper at 143.8). #b8c1d1 is 142.7,
72
+ # which clears that floor while staying 111 units off the
73
+ # foreground -- go lighter and the assistant label melts into the
74
+ # body text it introduces, which is the same defect facing the
75
+ # other way.
76
+ "plain": ("#8a93a3", "#8792a2", "#b8c1d1"),
77
+ "red": ("#d4674f", "#b0513c", "#e8917b"),
78
+ "green": ("#5fa876", "#4d8f63", "#8ecba1"),
79
+ "blue": ("#5b90cc", "#4a76b3", "#8bb6e6"),
80
+ }
81
+
82
+ _ACCENTS_LIGHT = {
83
+ "plain": ("#5a6273", "#3c4252", "#7d8595"),
84
+ "red": ("#b04a33", "#7d3423", "#c9705a"),
85
+ "green": ("#3f7f57", "#2b5a3c", "#5d9c74"),
86
+ "blue": ("#3f6fa8", "#2b4d76", "#6091c7"),
87
+ }
88
+
89
+ # Standalone tinted themes (batch 29). Each OVERRIDES the shared base
90
+ # outright -- that is their identity: the panels themselves carry the
91
+ # palette, not just borders and text. Severity slots default to the grid
92
+ # trio and are overridden ONLY where contrast against the theme's own
93
+ # tint demands it, keeping the semantic hue family (danger stays
94
+ # red-ish); every override carries its reason, and the floors live in
95
+ # tests/test_themes.py (foreground >= 7:1, severity >= 4:1, identity
96
+ # >= 3.5:1, all against the theme's own background).
97
+ _STANDALONE = [
98
+ dict(
99
+ name="matrix", dark=True,
100
+ background="#0a120c", surface="#0f1a12", panel="#14231a",
101
+ foreground="#c8e6d0",
102
+ primary="#3dd968", secondary="#2f9e52", accent="#7dffb0",
103
+ # success overridden: the shared #5aa86f dissolves into matrix's
104
+ # own green-dark background.
105
+ success="#4ee08a",
106
+ ),
107
+ dict(
108
+ name="nightmare", dark=True,
109
+ background="#140b0e", surface="#1c0f14", panel="#251318",
110
+ foreground="#e8d5d8",
111
+ primary="#c94f5f", secondary="#a8556a", accent="#e88a96",
112
+ # error overridden: red-on-red -- the shared #cf5c4a loses the
113
+ # alarm against nightmare's blood background.
114
+ error="#ff7b6b",
115
+ ),
116
+ dict(
117
+ name="ember", dark=True,
118
+ background="#16100a", surface="#1f1610", panel="#291d13",
119
+ foreground="#ecdfd0",
120
+ primary="#e08a3c", secondary="#a86228", accent="#f2b06a",
121
+ # warning overridden yellower: the shared amber sat on top of
122
+ # ember's primary orange and read as emphasis, not as caution.
123
+ warning="#d9b83f",
124
+ ),
125
+ dict(
126
+ name="midnight", dark=True,
127
+ background="#0a0f1e", surface="#101830", panel="#16203c",
128
+ foreground="#d5dcea",
129
+ primary="#6f9fe8", secondary="#4a6fb0", accent="#9dbdf2",
130
+ ),
131
+ dict(
132
+ name="glassy-lapis", dark=True,
133
+ background="#14243f", surface="#1c2f52", panel="#243a63",
134
+ foreground="#e2ecf8",
135
+ primary="#7fb4ff", secondary="#5a8ac9", accent="#a8ccff",
136
+ # error overridden: lapis is the lightest dark background, and
137
+ # the shared #cf5c4a fell just under the severity floor on it.
138
+ error="#e06a58",
139
+ ),
140
+ dict(
141
+ name="paper", dark=False,
142
+ background="#f4efe6", surface="#fbf8f2", panel="#eae3d5",
143
+ foreground="#2b2620",
144
+ primary="#7a5c2e", secondary="#5c4a32", accent="#9c7b45",
145
+ ),
146
+ ]
147
+
148
+
149
+ def _build(variant: str, dark: bool) -> Theme:
150
+ base = _DARK_BASE if dark else _LIGHT_BASE
151
+ primary, secondary, accent = (
152
+ _ACCENTS_DARK if dark else _ACCENTS_LIGHT
153
+ )[variant]
154
+ return Theme(
155
+ name=f"{'dark' if dark else 'light'}-{variant}",
156
+ primary=primary,
157
+ secondary=secondary,
158
+ accent=accent,
159
+ **base,
160
+ )
161
+
162
+
163
+ def _build_standalone(spec: dict) -> Theme:
164
+ base = _DARK_BASE if spec["dark"] else _LIGHT_BASE
165
+ merged = {**base, **{k: v for k, v in spec.items() if k != "name"}}
166
+ return Theme(name=spec["name"], **merged)
167
+
168
+
169
+ ALL_THEMES = (
170
+ [
171
+ _build(variant, dark)
172
+ for dark in (True, False)
173
+ for variant in ("plain", "red", "green", "blue")
174
+ ]
175
+ + [_build_standalone(spec) for spec in _STANDALONE]
176
+ )
177
+
178
+ THEME_NAMES = [t.name for t in ALL_THEMES]
179
+ DEFAULT_THEME = "dark-plain"
180
+
181
+
182
+ def register_all(app) -> None:
183
+ """Register every theme on the app. Call before setting app.theme."""
184
+ for theme in ALL_THEMES:
185
+ app.register_theme(theme)
186
+
187
+
188
+ # ---------------------------------------------------------------------------
189
+ # ---- Role palette (ROADMAP_v2 §26) ----------------------------------------
190
+ # ---------------------------------------------------------------------------
191
+ #
192
+ # The transcript was uniformly white: a user message, the model's answer, a
193
+ # pipeline trace line and a tool call were the same colour, and the "you"
194
+ # label read as the first word of the message it introduced.
195
+ #
196
+ # WHY THIS IS A FUNCTION OF A THEME rather than a table of colour names.
197
+ # Everything else in the TUI styles itself through app.tcss, which uses
198
+ # theme variables ($panel, $primary) and so restyles across all fourteen
199
+ # themes without edits. A RichLog cannot do that -- it renders Rich Text
200
+ # objects, and a Rich style needs a concrete colour, not a variable to
201
+ # resolve later. So the resolution happens here, against the Theme
202
+ # object, and the same property holds: no literal appears below, and a
203
+ # new theme needs no change in this section.
204
+ #
205
+ # Severity colours. Across the eight GRID themes, warning/error/success
206
+ # are shared by _DARK_BASE and _LIGHT_BASE and mean the same thing
207
+ # everywhere; primary/secondary/accent are the per-variant hues. A
208
+ # STANDALONE theme may override a severity slot when its own panel tint
209
+ # would swallow the shared value (matrix's success, nightmare's error,
210
+ # ember's warning, glassy-lapis's error -- each with its reason above),
211
+ # keeping the semantic hue family. Either way severity uses the
212
+ # theme-resolved trio and identity uses the hues, rather than the
213
+ # reverse. Floors are pinned in tests/test_themes.py.
214
+
215
+ #: How far a diff row's background is blended TOWARD the theme's own
216
+ #: background (batch 41, X7). 0.8 leaves a band that stands off the
217
+ #: page by 1.22-1.53 across the fourteen themes while the foreground
218
+ #: still reads on it at 9.3:1 or better -- a highlight rather than a
219
+ #: slab. Both floors are pinned in tests/test_themes.py.
220
+ DIFF_TINT = 0.8
221
+
222
+
223
+ def _tint(colour: str, background: str, factor: float = DIFF_TINT) -> str:
224
+ """`colour` faded toward `background`, as a hex string.
225
+
226
+ Derived from the theme's own slots rather than written down, for
227
+ the reason the whole of this section exists (#116): a literal pair
228
+ of green and red backgrounds would be designed against one of the
229
+ fourteen palettes and wrong on the other thirteen -- and on the six
230
+ standalone themes, whose panels carry the identity, visibly so.
231
+ """
232
+ return Color.parse(colour).blend(Color.parse(background), factor).hex
233
+
234
+
235
+ def role_styles(theme: Theme) -> dict[str, str]:
236
+ """Rich style strings keyed by transcript role, for one theme.
237
+
238
+ Roles are what a line MEANS, not where it came from: `pass` covers a
239
+ research pass boundary whether the CLI or the TUI produced it, and
240
+ `tool_error` is a failed tool call rather than "amber".
241
+ """
242
+ return {
243
+ # Who is speaking. The hues, because these distinguish identity.
244
+ "user": f"bold {theme.primary}",
245
+ "user_label": f"bold {theme.primary}",
246
+ "assistant_label": f"bold {theme.accent}",
247
+ # The answer itself stays plain foreground DELIBERATELY. It is the
248
+ # longest text on screen and the thing most often actually read;
249
+ # tinting it costs contrast to say something the label already said.
250
+ "assistant": "",
251
+ # The harness talking about itself.
252
+ "system": "dim italic",
253
+ # §38: the model's reasoning, when tui.show_thinking renders it
254
+ # inline. `secondary` because thinking is the answer's quieter
255
+ # sibling rather than a severity or an identity -- it already
256
+ # clears the identity floor on every theme, so no theme constant
257
+ # moves for this. Italic separates it from `pass`/`pass_done`,
258
+ # which share the hue in the research view.
259
+ "thinking": f"italic {theme.secondary}",
260
+ "pass": f"bold {theme.secondary}",
261
+ "pass_done": theme.secondary,
262
+ # PLAIN accent, not `dim` (batch 41, X1). Two reasons, and the
263
+ # second is the one that generalises. `dim {accent}` sat a
264
+ # measured 98.5 redmean units from `thinking`'s
265
+ # `italic {secondary}` on dark-plain -- the shipped default,
266
+ # and the tightest pair of any theme (every other theme is
267
+ # >= 143) -- so a tool call and a reasoning line were one
268
+ # colour on the palette most people actually see. And `dim` is
269
+ # a Rich ATTRIBUTE, not a colour: tests/test_themes.py's
270
+ # contrast floors measure the undimmed hue and cannot see what
271
+ # the terminal paints, so the style on EVERY tool call was the
272
+ # one style whose real contrast nothing measured. Plain accent
273
+ # moves it up, away from secondary, into a number the floors
274
+ # can see.
275
+ "tool": theme.accent,
276
+ # How bad it is. The three shared colours.
277
+ "tool_error": theme.warning,
278
+ # BOLD, where tool_error is plain (X2). Both are non-fatal and
279
+ # keep the hue family; the weight separates the harness raising
280
+ # its voice from a tool that failed. They were the same string
281
+ # outright until batch 41, which was survivable only because
282
+ # nothing routed a WARNING here at all -- see
283
+ # TranscriptLogHandler, where that was the actual defect.
284
+ "warning": f"bold {theme.warning}",
285
+ "error": f"bold {theme.error}",
286
+ "success": theme.success,
287
+ # Confidence tiers, ordered worst-to-best in meaning rather than in
288
+ # this dict. UNVERIFIED_COVERAGE is a gap in what was asked, not a
289
+ # claim that failed, so it reads as absent rather than as wrong.
290
+ "HIGH": theme.success,
291
+ "MEDIUM": theme.foreground,
292
+ "LOW": theme.warning,
293
+ "UNVERIFIED": theme.error,
294
+ "UNVERIFIED_COVERAGE": f"dim {theme.error}",
295
+ # §41's inline diff for `write` and `edit`. The only roles in
296
+ # this table that set a BACKGROUND, because the whole point is
297
+ # that a changed row is marked across its full width rather
298
+ # than at the one character that carries the sign.
299
+ "diff_add": f"{theme.foreground} on {_tint(theme.success, theme.background)}",
300
+ "diff_del": f"{theme.foreground} on {_tint(theme.error, theme.background)}",
301
+ # Unchanged context recedes: it is there to place the change,
302
+ # not to be read. `secondary` rather than a dimmed foreground
303
+ # for X1's reason -- `dim` is an attribute no floor can
304
+ # measure.
305
+ "diff_context": theme.secondary,
306
+ # The file being changed. Bold foreground takes no hue at all,
307
+ # which is what keeps it out of the identity roles the same
308
+ # batch just separated -- a path is not a speaker.
309
+ "diff_header": f"bold {theme.foreground}",
310
+ }
311
+
312
+
313
+ def styles_for(app) -> dict[str, str]:
314
+ """The active theme's role styles, or unstyled when there is no app.
315
+
316
+ A widget is constructed before it is mounted and tests build them bare
317
+ (`ResearchProgress()` in test_pipeline_events.py), where `self.app`
318
+ RAISES rather than returning None. Falling back to empty strings keeps
319
+ a widget renderable in both cases -- Rich treats "" as no style -- so
320
+ presentation degrades instead of a NoActiveAppError reaching a test
321
+ that is not about theming at all.
322
+ """
323
+ try:
324
+ theme = app.get_theme(app.theme)
325
+ except Exception: # noqa: BLE001 -- no app, or a theme name we lost
326
+ theme = None
327
+ if theme is None:
328
+ return {}
329
+ return role_styles(theme)
330
+
331
+
332
+ def syntax_theme_for(app) -> str:
333
+ """Which Rich token theme code blocks highlight against (#116).
334
+
335
+ Rich ships exactly two: ansi_dark for dark backgrounds, ansi_light for
336
+ light ones. Half the shipped themes are light, and every one of them
337
+ was rendering every code block in a palette designed against the
338
+ opposite background -- on the one transcript element a reader is most
339
+ likely to read character by character.
340
+
341
+ Resolved here, against the Theme object's own `dark` flag, for the same
342
+ reason role_styles is: a RichLog cannot reach app.tcss variables, so
343
+ the lookup happens where the Theme object already is. No running app
344
+ (bare-built test widgets) defaults to dark, which preserves what the
345
+ unconditional version did.
346
+ """
347
+ try:
348
+ theme = app.get_theme(app.theme)
349
+ except Exception: # noqa: BLE001 -- no app, or a theme name we lost
350
+ theme = None
351
+ if theme is not None and not theme.dark:
352
+ return "ansi_light"
353
+ return "ansi_dark"
354
+
355
+
356
+ def resolve(name: str | None) -> str:
357
+ """Theme name to apply, falling back to the default.
358
+
359
+ Returns the default rather than raising: config_loader already
360
+ type-checks `tui.theme` as a string, but it cannot know the valid
361
+ names without importing this module, and a stale name in a settings
362
+ file should not stop the app from starting.
363
+ """
364
+ if name in THEME_NAMES:
365
+ return name
366
+ return DEFAULT_THEME