@yahyahammad/venastine 0.3.8 → 0.3.9

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 (128) hide show
  1. package/.env.example +19 -19
  2. package/CONFIG_ARCHITECTURE.md +2030 -2002
  3. package/LICENSE +201 -201
  4. package/README.md +1034 -1034
  5. package/agents/builtin/compactor.md +75 -75
  6. package/agents/builtin/explore.md +77 -77
  7. package/agents/builtin/pipeline-reviewer.md +100 -100
  8. package/agents/builtin/plan.md +106 -106
  9. package/agents/builtin/review.md +74 -74
  10. package/agents/manager.py +261 -261
  11. package/agents/subagent_tool.py +472 -472
  12. package/agents/tui_commands.py +238 -146
  13. package/bin/venastine.mjs +528 -528
  14. package/bin/venastine.py +71 -71
  15. package/cli_commands.py +838 -835
  16. package/config.yaml +13 -0
  17. package/config_edit.py +1301 -1301
  18. package/config_schema.py +971 -966
  19. package/config_update.py +749 -749
  20. package/core/agent_activity.py +256 -256
  21. package/core/ansi.py +452 -452
  22. package/core/approval.py +137 -137
  23. package/core/call_view.py +364 -364
  24. package/core/cancel.py +121 -121
  25. package/core/chatgpt_auth.py +747 -747
  26. package/core/claims_view.py +107 -107
  27. package/core/client.py +2715 -2715
  28. package/core/commands.py +460 -454
  29. package/core/compaction.py +1735 -1735
  30. package/core/config_loader.py +1982 -1982
  31. package/core/connect.py +686 -686
  32. package/core/events.py +123 -123
  33. package/core/file_mentions.py +280 -280
  34. package/core/interaction.py +411 -411
  35. package/core/loop.py +2566 -2566
  36. package/core/memory.py +482 -482
  37. package/core/pipeline_models.py +190 -190
  38. package/core/provider_errors.py +234 -234
  39. package/core/reasoning/authorization.py +130 -130
  40. package/core/reasoning/base.py +219 -219
  41. package/core/reasoning/confidence_scoring.py +484 -484
  42. package/core/reasoning/events.py +149 -149
  43. package/core/reasoning/orchestrator.py +1561 -1561
  44. package/core/reasoning/output_writer.py +345 -345
  45. package/core/reasoning/payload_validation.py +524 -524
  46. package/core/reasoning/pipeline_storage.py +427 -427
  47. package/core/reasoning/scholar.py +458 -458
  48. package/core/reasoning/source_corpus.py +433 -433
  49. package/core/reasoning/source_scoring.py +855 -855
  50. package/core/replay.py +315 -315
  51. package/core/shell_sessions.py +1553 -1553
  52. package/credentials.py +307 -307
  53. package/database.py +333 -333
  54. package/docs/PRIVACY.md +78 -78
  55. package/docs/SECURITY.md +108 -108
  56. package/docs/THIRD_PARTY_NOTICES.md +148 -148
  57. package/env_secrets.py +118 -118
  58. package/json_store.py +343 -343
  59. package/logging_setup.py +295 -295
  60. package/main.py +3433 -3433
  61. package/mcp_client/client.py +733 -733
  62. package/mcp_client/config.py +484 -484
  63. package/mcp_client/registration.py +343 -343
  64. package/memories/manager.py +147 -147
  65. package/memories/tui_commands.py +319 -239
  66. package/package.json +303 -303
  67. package/project_init/config_files.py +282 -282
  68. package/project_init/generator.py +728 -728
  69. package/project_init/manifest.py +418 -418
  70. package/project_init/tui_commands.py +147 -147
  71. package/prompts/critic_pass.md +24 -24
  72. package/prompts/revalidate.md +25 -25
  73. package/prompts/revise.md +17 -17
  74. package/prompts/source_grounding.md +66 -66
  75. package/prompts/system_prompts.py +316 -316
  76. package/providers.json.example +94 -94
  77. package/pyproject.toml +149 -149
  78. package/requirements.txt +295 -295
  79. package/safety/policy_enforcement.py +1082 -1082
  80. package/security/askpass.py +419 -419
  81. package/security/capability.py +207 -207
  82. package/security/confine.py +484 -484
  83. package/security/hosted.py +182 -182
  84. package/security/permissions.py +237 -237
  85. package/security/protected_paths.py +501 -501
  86. package/security/sandbox.py +4108 -4108
  87. package/skills/builtin/math/formal-specification.md +67 -67
  88. package/skills/builtin/math/numerical-methods.md +66 -66
  89. package/skills/builtin/research/experiment-design.md +62 -62
  90. package/skills/builtin/research/reproducibility.md +55 -55
  91. package/skills/builtin/research/source-evaluation.md +70 -70
  92. package/skills/builtin/research/statistical-inference.md +63 -63
  93. package/skills/builtin/research/technical-writing.md +59 -59
  94. package/skills/builtin/software/code-review.md +61 -61
  95. package/skills/builtin/software/debugging.md +61 -61
  96. package/skills/builtin/software/test-design.md +67 -67
  97. package/skills/tui_commands.py +110 -110
  98. package/storage.py +1338 -1338
  99. package/tools/base.py +465 -465
  100. package/tools/builtin/_math_common.py +667 -667
  101. package/tools/builtin/_net_common.py +267 -267
  102. package/tools/builtin/arxiv.py +681 -681
  103. package/tools/builtin/fetch_url.py +371 -371
  104. package/tools/builtin/file_ops.py +720 -720
  105. package/tools/builtin/geometry.py +184 -184
  106. package/tools/builtin/load_skill.py +76 -76
  107. package/tools/builtin/pin.py +227 -227
  108. package/tools/builtin/probability_stats.py +224 -224
  109. package/tools/builtin/project_docs.py +464 -464
  110. package/tools/builtin/remember.py +175 -175
  111. package/tools/builtin/shell.py +980 -980
  112. package/tools/builtin/todo.py +149 -149
  113. package/tools/builtin/web_search.py +328 -328
  114. package/tools/context.py +159 -159
  115. package/tools/isolation.py +387 -387
  116. package/tools/registry.py +1242 -1242
  117. package/tui/app.py +8318 -8307
  118. package/tui/app.tcss +747 -739
  119. package/tui/commands.py +26 -26
  120. package/tui/diffs.py +286 -286
  121. package/tui/history.py +128 -128
  122. package/tui/hosted_driver.py +102 -102
  123. package/tui/markdown.py +1329 -1329
  124. package/tui/meters.py +364 -364
  125. package/tui/ravens.py +146 -146
  126. package/tui/screens.py +1255 -1197
  127. package/tui/themes.py +599 -599
  128. package/tui/widgets.py +3813 -3796
package/core/commands.py CHANGED
@@ -1,454 +1,460 @@
1
- """
2
- core/commands.py
3
-
4
- The slash-command CATALOG both shells bind to, and the registry mechanism
5
- each of them binds with (ROADMAP_v3 §89, #8).
6
-
7
- WHY ONE CATALOG. D12 makes the CLI a permanent fallback, and the failure
8
- mode issue #8 names is the two shells disagreeing about what a command IS
9
- -- what `/compact` is called, what it takes, what it says it does. So a
10
- command's name, summary, usage and aliases are declared here once, and a
11
- shell does not describe a command: it BINDS a handler to one by name.
12
- `core/replay.py`'s reason (§26 L6), one subject over: one place decides
13
- what exists, and each shell decides how to run it.
14
-
15
- WHY NOT ONE HANDLER. A handler is where the shells genuinely differ -- the
16
- TUI pushes a modal and runs a worker, the CLI prints and reads a line --
17
- so each shell keeps its own, and what they share is the CORE FUNCTIONS
18
- both handlers call (`attach_ref`, `summarize_thread`, `compact`,
19
- `render_claims`, `agent_turn`). The handlers are thin on purpose; a
20
- handler with policy inline is the copy that drifts.
21
-
22
- A COMMAND ONE SHELL CANNOT HAVE SAYS WHY. `absent` maps a shell to the
23
- sentence that explains it -- `/theme` has nothing to theme on a
24
- line-based terminal, `/call` is the CLI's spelling of the TUI's
25
- ctrl+click -- and both shells answer a name they lack with that sentence
26
- rather than with "unknown command". A shell absent from the map binds a
27
- handler, and `tests/test_command_catalog.py` holds every shell to that.
28
-
29
- THE MECHANISM MOVED HERE FROM `tui/commands.py` UNCHANGED, apart from the
30
- binding check: the CLI needs the same registry and must not import from
31
- `tui/` to get it. `tui/commands.py` re-exports it.
32
-
33
- A handler takes (shell_state, argument_string) and returns None. In the
34
- TUI the state is the app and the handler runs on the UI thread, so
35
- anything slow belongs in a worker; in the CLI it is `cli_commands.
36
- ChatSession` and the handler runs on the chat loop's own thread.
37
- """
38
-
39
- from __future__ import annotations
40
-
41
- import logging
42
- from collections.abc import Callable
43
- from dataclasses import dataclass, field
44
- from typing import Optional
45
-
46
- logger = logging.getLogger(__name__)
47
-
48
- #: The two shells. Strings rather than an enum because they are keys in
49
- #: each spec's `absent` map and appear in error text.
50
- TUI = "tui"
51
- CLI = "cli"
52
- SHELLS = (TUI, CLI)
53
-
54
- # The sentence most CLI absences share. Not "use the TUI" alone: the flag
55
- # beside it, where one exists, is what a scripted run can actually type.
56
- _IN_THE_TUI = "not yet; use it in the TUI (venastine --tui)."
57
-
58
-
59
- @dataclass(frozen=True)
60
- class CommandSpec:
61
- """One command as both shells know it."""
62
-
63
- name: str # without the leading slash
64
- summary: str # one line, shown by /help
65
- usage: Optional[str] = None # shown by /help when the shape is not obvious
66
- aliases: tuple[str, ...] = () # see SlashCommand.aliases
67
- # shell -> why that shell has no handler. A shell missing from the map
68
- # binds one; the census test holds it to that.
69
- absent: dict = field(default_factory=dict)
70
-
71
- def in_shell(self, shell: str) -> bool:
72
- return shell not in self.absent
73
-
74
-
75
- #: Alphabetical, which is the order `/help` prints in either shell.
76
- _SPECS = (
77
- CommandSpec("agent", "switch the active agent", "[name|default]"),
78
- CommandSpec("call", "list this thread's tool calls, or show one",
79
- "[number]",
80
- absent={TUI: "ctrl+click a ▸ line to open its call."}),
81
- CommandSpec("claims", "show a research run's claims and their tiers",
82
- "[run id]"),
83
- CommandSpec("compact", "summarize this conversation's older turns now",
84
- "[--strength 1-5]"),
85
- CommandSpec("config", "browse and set the harness configuration",
86
- "[key] [value]", absent={CLI: _IN_THE_TUI}),
87
- CommandSpec("connect", "connect a model provider: sign in or paste a key",
88
- "[name [--key]|custom <NAME> <url>|cancel]",
89
- absent={CLI: _IN_THE_TUI}),
90
- # tui/app.py's _COPY_TARGETS, spelled out; the census test pins the two.
91
- CommandSpec("copy", "copy text out of the session",
92
- "[last|report|claims|conversation|all] [--file <path>]",
93
- absent={CLI: "the CLI prints plain text, so the terminal's "
94
- "own selection copies it."}),
95
- CommandSpec("critic", "route the grounding and critic passes to another "
96
- "model", "[[PROVIDER] name|off]",
97
- absent={CLI: _IN_THE_TUI}),
98
- CommandSpec("disconnect", "remove a provider's key, or sign out of one",
99
- "[name [--forget]]", absent={CLI: _IN_THE_TUI}),
100
- CommandSpec("effort", "switch reasoning effort", "[level|auto]"),
101
- CommandSpec("embedder", "choose the model that scores source similarity",
102
- "[[PROVIDER] name|off]", absent={CLI: _IN_THE_TUI}),
103
- CommandSpec("forget", "delete one durable memory", "<id>"),
104
- CommandSpec("goal", "set the thread's persistent objective",
105
- "[text|clear]"),
106
- CommandSpec("grill-me", "surface what still needs a decision"),
107
- CommandSpec("help", "list commands"),
108
- CommandSpec("init", "generate this project's documentation set",
109
- "[--software|--research] [--config]",
110
- absent={CLI: "not yet; run venastine --init."}),
111
- CommandSpec("kill", "stop a background session", "[session-id]",
112
- absent={CLI: "the CLI's prompt waits until background "
113
- "sessions finish, and Ctrl+C while it waits "
114
- "stops them."}),
115
- CommandSpec("memories", "list durable memories visible here"),
116
- CommandSpec("mentions", "show file mention status or include ignored "
117
- "paths", "[ignored on|off]",
118
- absent={CLI: "it manages the TUI's @-file completion, which "
119
- "the CLI does not have."}),
120
- CommandSpec("model", "switch provider and/or model for this session",
121
- "[[PROVIDER] name]"),
122
- CommandSpec("new", "start a new thread"),
123
- CommandSpec("quit", "exit the harness", aliases=("exit", "bye")),
124
- CommandSpec("ref", "reference another conversation's summary",
125
- "[--list|--clear]"),
126
- CommandSpec("research", "run the deep-research pipeline",
127
- "[--attended] [--review|--no-review] [--grant[=a,b]] <query>",
128
- absent={CLI: 'not yet; run venastine --mode research '
129
- '"<query>".'}),
130
- CommandSpec("resume", "resume a thread by id, even an old one",
131
- "<thread-id>"),
132
- CommandSpec("secrets", "manage the harness-held secret store",
133
- "[status|list|set <name>|delete <name>|lock]",
134
- absent={CLI: "not yet; run venastine --secrets status."}),
135
- CommandSpec("skill", "activate a skill for this session",
136
- "[name|off <name>|clear]"),
137
- # ROADMAP_v3 §57: both shells (SM11), since the pair it stores reaches
138
- # either shell's spawns.
139
- CommandSpec("submodel", "run spawned subagents on another model",
140
- "[[PROVIDER] name|off]"),
141
- CommandSpec("summary", "distil this conversation without folding it"),
142
- CommandSpec("theme", "switch colour theme", "[name]",
143
- absent={CLI: "a line-based terminal has no colour theme to "
144
- "switch."}),
145
- CommandSpec("thinking", "show or hide reasoning inline", "[on|off]",
146
- absent={CLI: "not yet; the CLI prints reasoning whenever "
147
- "the model returns it."}),
148
- CommandSpec("threads", "resume a saved thread"),
149
- CommandSpec("trigger", "override when this chat compacts, for the "
150
- "session", "[tokens|off]",
151
- absent={CLI: _IN_THE_TUI}),
152
- CommandSpec("window", "override this model's context window for the "
153
- "session", "[tokens|off]",
154
- absent={CLI: _IN_THE_TUI}),
155
- )
156
-
157
-
158
- def _index(specs) -> tuple[dict, dict]:
159
- """(name -> spec, alias -> name), refusing what would shadow.
160
-
161
- At IMPORT, so a collision in the catalog fails the first test that
162
- imports either shell rather than reaching a keystroke.
163
- """
164
- catalog: dict = {}
165
- aliases: dict = {}
166
- for spec in specs:
167
- if spec.name in catalog or spec.name in aliases:
168
- raise ValueError(f"/{spec.name} is declared twice")
169
- unknown = set(spec.absent) - set(SHELLS)
170
- if unknown:
171
- raise ValueError(f"/{spec.name} names unknown shells {unknown}")
172
- if not all(spec.absent.values()):
173
- raise ValueError(f"/{spec.name} is absent without a reason")
174
- catalog[spec.name] = spec
175
- for alias in spec.aliases:
176
- if alias in catalog or alias in aliases:
177
- raise ValueError(f"/{alias} is declared twice")
178
- aliases[alias] = spec.name
179
- return catalog, aliases
180
-
181
-
182
- #: name -> CommandSpec. A test that registers a command of its own declares
183
- #: it here first (`mocker.patch.dict`), which is the rule it is testing.
184
- CATALOG, ALIASES = _index(_SPECS)
185
-
186
-
187
- def lookup(name: str) -> Optional[CommandSpec]:
188
- """The spec called `name`, by its own name or an alias."""
189
- name = name.lower()
190
- spec = CATALOG.get(name)
191
- if spec is not None:
192
- return spec
193
- canonical = ALIASES.get(name)
194
- return CATALOG.get(canonical) if canonical else None
195
-
196
-
197
- def absent_reason(name: str, shell: str) -> Optional[str]:
198
- """Why `shell` has no /`name`, or None when it has one or nobody does.
199
-
200
- What a shell says INSTEAD of "unknown command" for a command the other
201
- shell has: `/theme` typed in the CLI is not a typo, and answering it as
202
- one would send the reader to /help to find a command they already know.
203
- """
204
- spec = lookup(name)
205
- if spec is None or spec.in_shell(shell):
206
- return None
207
- return f"/{spec.name} is not in this shell: {spec.absent[shell]}"
208
-
209
-
210
- @dataclass
211
- class SlashCommand:
212
- name: str # without the leading slash
213
- summary: str # one line, shown by /help
214
- handler: Callable # (shell_state, args: str) -> None
215
- usage: Optional[str] = None # shown by /help when the shape is not obvious
216
- # Other names the same command answers to (batch 57). A FIELD rather
217
- # than two more registrations, and the difference is what the LISTS
218
- # say: `all()` and `names()` stay canonical, so `/help` prints one row
219
- # per command and a bare slash still offers the menu it always did.
220
- # Registering `/exit` and `/bye` outright would have sorted `bye`
221
- # second in that menu, ahead of `/claims`, for a name nobody browses
222
- # for -- and moved every window position batch 56 measured.
223
- aliases: tuple[str, ...] = ()
224
- # Batch 84. What to offer once this command's name has been typed and a
225
- # space follows it: `(argument_text) -> [SlashCommand]`, where each row's
226
- # `name` is the WHOLE line after the slash, because that is what the
227
- # panel draws and what completion writes into the prompt.
228
- #
229
- # Opt-in per command, and that is what keeps `/copy last` offering
230
- # nothing: a command without one behaves exactly as every command did
231
- # before this field existed, which is the contract
232
- # `test_a_space_ends_it_at_either_end` pins.
233
- complete: Optional[Callable] = None
234
-
235
-
236
- def bind(name: str, handler: Callable,
237
- complete: Optional[Callable] = None) -> SlashCommand:
238
- """A command built from its catalog entry -- the only way a shell
239
- should construct one, since everything but the handler is the
240
- catalog's to say."""
241
- spec = CATALOG[name]
242
- return SlashCommand(spec.name, spec.summary, handler, spec.usage,
243
- spec.aliases, complete)
244
-
245
-
246
- class CommandRegistry:
247
- def __init__(self, shell: Optional[str] = None) -> None:
248
- self._commands: dict[str, SlashCommand] = {}
249
- # alias -> canonical name. A second index rather than a scan, and
250
- # it is what makes an alias collision detectable at REGISTRATION
251
- # instead of at the keystroke that silently reached the wrong
252
- # handler.
253
- self._aliases: dict[str, str] = {}
254
- # §89. The shell this registry belongs to, which binds it to the
255
- # catalog. None is the bare mechanism, for a test of the mechanism.
256
- self.shell = shell
257
-
258
- def _check_bound(self, command: SlashCommand) -> None:
259
- """A shell's registry takes only what the catalog declares for it,
260
- exactly as declared (§89).
261
-
262
- AT REGISTRATION, the alias check's reason: a summary edited in one
263
- shell's registration would otherwise be the first thing the two
264
- disagree about, and nothing would say so until a reader compared
265
- two /help outputs.
266
- """
267
- spec = CATALOG.get(command.name)
268
- if spec is None:
269
- raise ValueError(
270
- f"/{command.name} is not in core/commands.py's catalog; "
271
- f"declare it there, then bind a handler to it")
272
- if not spec.in_shell(self.shell):
273
- raise ValueError(
274
- f"/{command.name} is declared absent from the {self.shell} "
275
- f"({spec.absent[self.shell]}); change the catalog first")
276
- declared = (spec.summary, spec.usage, tuple(spec.aliases))
277
- given = (command.summary, command.usage, tuple(command.aliases))
278
- if declared != given:
279
- raise ValueError(
280
- f"/{command.name} differs from its catalog entry "
281
- f"({given} vs {declared}); build it with bind()")
282
-
283
- def register(self, command: SlashCommand) -> None:
284
- """Register by name; re-registering the same name overwrites.
285
-
286
- Idempotent on purpose -- `register_builtin_commands()` runs on
287
- import AND is called again by tests, so a second pass must not
288
- duplicate or raise.
289
-
290
- An alias that would shadow something REFUSES, both ways round: a
291
- name already taken by a command, and a command name already taken
292
- by somebody's alias. Both resolve silently otherwise -- `get()`
293
- prefers real names, so the alias would simply stop working and
294
- nothing would say why.
295
-
296
- A shell's registry also refuses what the catalog does not declare
297
- for that shell, or declares differently (§89, `_check_bound`).
298
- """
299
- if self.shell is not None:
300
- self._check_bound(command)
301
- for alias in command.aliases:
302
- if alias in self._commands:
303
- raise ValueError(
304
- f"/{alias} is already a command; it cannot also be an "
305
- f"alias of /{command.name}")
306
- owner = self._aliases.get(alias)
307
- if owner is not None and owner != command.name:
308
- raise ValueError(
309
- f"/{alias} is already an alias of /{owner}; it cannot "
310
- f"also be an alias of /{command.name}")
311
- owner = self._aliases.get(command.name)
312
- if owner is not None and owner != command.name:
313
- raise ValueError(
314
- f"/{command.name} is already an alias of /{owner}")
315
- old = self._commands.get(command.name)
316
- if old is not None:
317
- for alias in old.aliases:
318
- if alias not in command.aliases \
319
- and self._aliases.get(alias) == command.name:
320
- del self._aliases[alias]
321
- self._commands[command.name] = command
322
- for alias in command.aliases:
323
- self._aliases[alias] = command.name
324
-
325
- def get(self, name: str) -> Optional[SlashCommand]:
326
- """The command called `name`, by its own name or by an alias.
327
-
328
- Names win over aliases, which is also the collision `register`
329
- refuses -- so the precedence can never actually be exercised.
330
- """
331
- command = self._commands.get(name)
332
- if command is not None:
333
- return command
334
- canonical = self._aliases.get(name)
335
- return self._commands.get(canonical) if canonical else None
336
-
337
- def names(self) -> list[str]:
338
- return sorted(self._commands)
339
-
340
- def all(self) -> list[SlashCommand]:
341
- return [self._commands[n] for n in self.names()]
342
-
343
- def matching(self, text: str) -> list[SlashCommand]:
344
- """Commands whose name starts with the token in `text`.
345
-
346
- The suggestion panel's source, and it reads `all()` so the panel and
347
- `/help` cannot disagree about what exists -- register a command
348
- anywhere and both change, which is the whole reason the matching
349
- lives here rather than in the widget.
350
-
351
- A BARE slash token offers commands: leading whitespace allowed
352
- (`dispatch` tolerates it, so `" /help"` runs and had better
353
- offer), a leading `/`, and no whitespace inside the name.
354
-
355
- PAST THE FIRST SPACE, the command itself answers (batch 84). If it
356
- declares a `complete` the rows come from there, and if it does not
357
- the answer is nothing, exactly as it was for every command before
358
- the field existed. `/config ` is the only one today.
359
-
360
- The split is on a SPACE and nothing else, because `dispatch`
361
- partitions on a space and nothing else: a line with a newline or a
362
- tab in it is not a command line there, so it must not look like one
363
- here. A panel that offered `/config` for a line `dispatch` would
364
- send to the model as chat is the disagreement this whole method is
365
- written to avoid.
366
-
367
- `lstrip`, not `strip`, and the difference is a bug this had: a
368
- TRAILING space survives `strip()`, so `"/copy "` read as `"/copy"`
369
- and the panel stayed open over a line that had already moved on to
370
- its arguments. Once a space is typed there is nothing left to
371
- complete, whichever end of the token it is on.
372
-
373
- Lowercased for the same reason `dispatch` lowercases: `/HELP` runs,
374
- so `/HEL` had better offer it.
375
-
376
- ALIASES join the list once a prefix is typed, and never on a bare
377
- slash (batch 57). The bare slash is the MENU -- it is what someone
378
- who does not know the commands presses, and a menu lists each
379
- thing once, under its own name. `/ex` is not browsing: it is a
380
- guess, and the answer to a guess is whether it works. So
381
- `matching("/") == all()` still holds exactly, and typing toward an
382
- alias surfaces it.
383
- """
384
- token = text.lstrip()
385
- if not token.startswith("/"):
386
- return []
387
- head, space, rest = token.partition(" ")
388
- if any(c.isspace() for c in head):
389
- # A newline or a tab before any space. Not a command line.
390
- return []
391
- if space:
392
- if any(c.isspace() and c != " " for c in rest):
393
- return []
394
- command = self.get(head[1:].lower())
395
- if command is None or command.complete is None:
396
- return []
397
- # CONTAINED HERE, unlike dispatch(), and the asymmetry is the
398
- # point rather than an inconsistency. `matching()` runs per
399
- # KEYSTROKE on the UI thread, and the right answer to a
400
- # completer that raises is "offer nothing" -- which is this
401
- # function's own vocabulary, already returned on four other
402
- # lines. There is no policy for the shell to decide, so there
403
- # is nothing to hand upward.
404
- #
405
- # dispatch() is the other way round: what a broken COMMAND does
406
- # to the session is the shell's call, so it is caught at the
407
- # call site in tui/app.py instead (batch 135). Uncontained,
408
- # this was the same exposure one layer over and on a hotter
409
- # path: an exception here reaches Textual's `_handle_exception`
410
- # and exits the application mid-keystroke, while the user is
411
- # still typing the command.
412
- try:
413
- return command.complete(rest)
414
- except Exception: # noqa: BLE001 -- see the comment above
415
- logger.exception(
416
- "The /%s completer raised; offering no rows.",
417
- command.name)
418
- return []
419
- prefix = token[1:].lower()
420
- matches = [c for c in self.all() if c.name.startswith(prefix)]
421
- if not prefix:
422
- return matches
423
- matches.extend(self._alias_row(a) for a in self._aliases
424
- if a.startswith(prefix))
425
- return sorted(matches, key=lambda command: command.name)
426
-
427
- def _alias_row(self, alias: str) -> SlashCommand:
428
- """One offer for `alias`, carrying the canonical command's handler.
429
-
430
- A real `SlashCommand` rather than a flag on the canonical one, so
431
- the panel needs to know nothing about aliases: it draws the name
432
- it is given and completes the name it drew, which has to be the
433
- alias the user was typing rather than the name they were not.
434
- """
435
- command = self._commands[self._aliases[alias]]
436
- return SlashCommand(
437
- alias, f"{command.summary} (alias of /{command.name})",
438
- command.handler, command.usage, complete=command.complete)
439
-
440
- def dispatch(self, app, raw: str) -> bool:
441
- """Run the command in `raw` (a line starting with '/').
442
-
443
- Returns True if a command handled the line, False if the name is
444
- unknown -- the caller decides what to do about it. Unknown names are
445
- NOT sent to the model: a mistyped slash command should say so, not
446
- silently become a chat turn that burns a request.
447
- """
448
- stripped = raw[1:].strip()
449
- name, _, args = stripped.partition(" ")
450
- command = self.get(name.lower())
451
- if command is None:
452
- return False
453
- command.handler(app, args.strip())
454
- return True
1
+ """
2
+ core/commands.py
3
+
4
+ The slash-command CATALOG both shells bind to, and the registry mechanism
5
+ each of them binds with (ROADMAP_v3 §89, #8).
6
+
7
+ WHY ONE CATALOG. D12 makes the CLI a permanent fallback, and the failure
8
+ mode issue #8 names is the two shells disagreeing about what a command IS
9
+ -- what `/compact` is called, what it takes, what it says it does. So a
10
+ command's name, summary, usage and aliases are declared here once, and a
11
+ shell does not describe a command: it BINDS a handler to one by name.
12
+ `core/replay.py`'s reason (§26 L6), one subject over: one place decides
13
+ what exists, and each shell decides how to run it.
14
+
15
+ WHY NOT ONE HANDLER. A handler is where the shells genuinely differ -- the
16
+ TUI pushes a modal and runs a worker, the CLI prints and reads a line --
17
+ so each shell keeps its own, and what they share is the CORE FUNCTIONS
18
+ both handlers call (`attach_ref`, `summarize_thread`, `compact`,
19
+ `render_claims`, `agent_turn`). The handlers are thin on purpose; a
20
+ handler with policy inline is the copy that drifts.
21
+
22
+ A COMMAND ONE SHELL CANNOT HAVE SAYS WHY. `absent` maps a shell to the
23
+ sentence that explains it -- `/theme` has nothing to theme on a
24
+ line-based terminal, `/call` is the CLI's spelling of the TUI's
25
+ ctrl+click -- and both shells answer a name they lack with that sentence
26
+ rather than with "unknown command". A shell absent from the map binds a
27
+ handler, and `tests/test_command_catalog.py` holds every shell to that.
28
+
29
+ THE MECHANISM MOVED HERE FROM `tui/commands.py` UNCHANGED, apart from the
30
+ binding check: the CLI needs the same registry and must not import from
31
+ `tui/` to get it. `tui/commands.py` re-exports it.
32
+
33
+ A handler takes (shell_state, argument_string) and returns None. In the
34
+ TUI the state is the app and the handler runs on the UI thread, so
35
+ anything slow belongs in a worker; in the CLI it is `cli_commands.
36
+ ChatSession` and the handler runs on the chat loop's own thread.
37
+ """
38
+
39
+ from __future__ import annotations
40
+
41
+ import logging
42
+ from collections.abc import Callable
43
+ from dataclasses import dataclass, field
44
+ from typing import Optional
45
+
46
+ logger = logging.getLogger(__name__)
47
+
48
+ #: The two shells. Strings rather than an enum because they are keys in
49
+ #: each spec's `absent` map and appear in error text.
50
+ TUI = "tui"
51
+ CLI = "cli"
52
+ SHELLS = (TUI, CLI)
53
+
54
+ # The sentence most CLI absences share. Not "use the TUI" alone: the flag
55
+ # beside it, where one exists, is what a scripted run can actually type.
56
+ _IN_THE_TUI = "not yet; use it in the TUI (venastine --tui)."
57
+
58
+
59
+ @dataclass(frozen=True)
60
+ class CommandSpec:
61
+ """One command as both shells know it."""
62
+
63
+ name: str # without the leading slash
64
+ summary: str # one line, shown by /help
65
+ usage: Optional[str] = None # shown by /help when the shape is not obvious
66
+ aliases: tuple[str, ...] = () # see SlashCommand.aliases
67
+ # shell -> why that shell has no handler. A shell missing from the map
68
+ # binds one; the census test holds it to that.
69
+ absent: dict = field(default_factory=dict)
70
+
71
+ def in_shell(self, shell: str) -> bool:
72
+ return shell not in self.absent
73
+
74
+
75
+ #: Alphabetical, which is the order `/help` prints in either shell.
76
+ _SPECS = (
77
+ CommandSpec("agent", "switch the active agent", "[name|default]"),
78
+ CommandSpec("call", "list this thread's tool calls, or show one",
79
+ "[number]",
80
+ absent={TUI: "ctrl+click a ▸ line to open its call."}),
81
+ CommandSpec("claims", "show a research run's claims and their tiers",
82
+ "[run id]"),
83
+ CommandSpec("compact", "summarize this conversation's older turns now",
84
+ "[--strength 1-5]"),
85
+ CommandSpec("config", "browse and set the harness configuration",
86
+ "[key] [value]", absent={CLI: _IN_THE_TUI}),
87
+ CommandSpec("connect", "connect a model provider: sign in or paste a key",
88
+ "[name [--key]|custom <NAME> <url>|cancel]",
89
+ absent={CLI: _IN_THE_TUI}),
90
+ # tui/app.py's _COPY_TARGETS, spelled out; the census test pins the two.
91
+ CommandSpec("copy", "copy text out of the session",
92
+ "[last|report|claims|conversation|all] [--file <path>]",
93
+ absent={CLI: "the CLI prints plain text, so the terminal's "
94
+ "own selection copies it."}),
95
+ CommandSpec("critic", "route the grounding and critic passes to another "
96
+ "model", "[[PROVIDER] name|off]",
97
+ absent={CLI: _IN_THE_TUI}),
98
+ CommandSpec("disconnect", "remove a provider's key, or sign out of one",
99
+ "[name [--forget]]", absent={CLI: _IN_THE_TUI}),
100
+ CommandSpec("effort", "switch reasoning effort", "[level|auto]"),
101
+ CommandSpec("embedder", "choose the model that scores source similarity",
102
+ "[[PROVIDER] name|off]", absent={CLI: _IN_THE_TUI}),
103
+ # ROADMAP_v3 §59: the id is optional in the TUI, where /forget alone
104
+ # opens a picker. The CLI's handler still asks for it, and says so.
105
+ # 49 characters with its name and usage, inside the slash panel's 50 at
106
+ # 80x24 (54 less SUGGEST_CONT): past 50 the entry wraps to two rows,
107
+ # which moves the window test_the_window_can_drop_one_and_gain_two
108
+ # measures.
109
+ CommandSpec("forget", "pick memories to delete, or by id", "[id]"),
110
+ CommandSpec("goal", "set the thread's persistent objective",
111
+ "[text|clear]"),
112
+ CommandSpec("grill-me", "surface what still needs a decision"),
113
+ CommandSpec("help", "list commands"),
114
+ CommandSpec("init", "generate this project's documentation set",
115
+ "[--software|--research] [--config]",
116
+ absent={CLI: "not yet; run venastine --init."}),
117
+ CommandSpec("kill", "stop a background session", "[session-id]",
118
+ absent={CLI: "the CLI's prompt waits until background "
119
+ "sessions finish, and Ctrl+C while it waits "
120
+ "stops them."}),
121
+ CommandSpec("memories", "list durable memories visible here"),
122
+ CommandSpec("mentions", "show file mention status or include ignored "
123
+ "paths", "[ignored on|off]",
124
+ absent={CLI: "it manages the TUI's @-file completion, which "
125
+ "the CLI does not have."}),
126
+ CommandSpec("model", "switch provider and/or model for this session",
127
+ "[[PROVIDER] name]"),
128
+ CommandSpec("new", "start a new thread"),
129
+ CommandSpec("quit", "exit the harness", aliases=("exit", "bye")),
130
+ CommandSpec("ref", "reference another conversation's summary",
131
+ "[--list|--clear]"),
132
+ CommandSpec("research", "run the deep-research pipeline",
133
+ "[--attended] [--review|--no-review] [--grant[=a,b]] <query>",
134
+ absent={CLI: 'not yet; run venastine --mode research '
135
+ '"<query>".'}),
136
+ CommandSpec("resume", "resume a thread by id, even an old one",
137
+ "<thread-id>"),
138
+ CommandSpec("secrets", "manage the harness-held secret store",
139
+ "[status|list|set <name>|delete <name>|lock]",
140
+ absent={CLI: "not yet; run venastine --secrets status."}),
141
+ CommandSpec("skill", "activate a skill for this session",
142
+ "[name|off <name>|clear]"),
143
+ # ROADMAP_v3 §57: both shells (SM11), since the pair it stores reaches
144
+ # either shell's spawns.
145
+ CommandSpec("submodel", "run spawned subagents on another model",
146
+ "[[PROVIDER] name|off]"),
147
+ CommandSpec("summary", "distil this conversation without folding it"),
148
+ CommandSpec("theme", "switch colour theme", "[name]",
149
+ absent={CLI: "a line-based terminal has no colour theme to "
150
+ "switch."}),
151
+ CommandSpec("thinking", "show or hide reasoning inline", "[on|off]",
152
+ absent={CLI: "not yet; the CLI prints reasoning whenever "
153
+ "the model returns it."}),
154
+ CommandSpec("threads", "resume a saved thread"),
155
+ CommandSpec("trigger", "override when this chat compacts, for the "
156
+ "session", "[tokens|off]",
157
+ absent={CLI: _IN_THE_TUI}),
158
+ CommandSpec("window", "override this model's context window for the "
159
+ "session", "[tokens|off]",
160
+ absent={CLI: _IN_THE_TUI}),
161
+ )
162
+
163
+
164
+ def _index(specs) -> tuple[dict, dict]:
165
+ """(name -> spec, alias -> name), refusing what would shadow.
166
+
167
+ At IMPORT, so a collision in the catalog fails the first test that
168
+ imports either shell rather than reaching a keystroke.
169
+ """
170
+ catalog: dict = {}
171
+ aliases: dict = {}
172
+ for spec in specs:
173
+ if spec.name in catalog or spec.name in aliases:
174
+ raise ValueError(f"/{spec.name} is declared twice")
175
+ unknown = set(spec.absent) - set(SHELLS)
176
+ if unknown:
177
+ raise ValueError(f"/{spec.name} names unknown shells {unknown}")
178
+ if not all(spec.absent.values()):
179
+ raise ValueError(f"/{spec.name} is absent without a reason")
180
+ catalog[spec.name] = spec
181
+ for alias in spec.aliases:
182
+ if alias in catalog or alias in aliases:
183
+ raise ValueError(f"/{alias} is declared twice")
184
+ aliases[alias] = spec.name
185
+ return catalog, aliases
186
+
187
+
188
+ #: name -> CommandSpec. A test that registers a command of its own declares
189
+ #: it here first (`mocker.patch.dict`), which is the rule it is testing.
190
+ CATALOG, ALIASES = _index(_SPECS)
191
+
192
+
193
+ def lookup(name: str) -> Optional[CommandSpec]:
194
+ """The spec called `name`, by its own name or an alias."""
195
+ name = name.lower()
196
+ spec = CATALOG.get(name)
197
+ if spec is not None:
198
+ return spec
199
+ canonical = ALIASES.get(name)
200
+ return CATALOG.get(canonical) if canonical else None
201
+
202
+
203
+ def absent_reason(name: str, shell: str) -> Optional[str]:
204
+ """Why `shell` has no /`name`, or None when it has one or nobody does.
205
+
206
+ What a shell says INSTEAD of "unknown command" for a command the other
207
+ shell has: `/theme` typed in the CLI is not a typo, and answering it as
208
+ one would send the reader to /help to find a command they already know.
209
+ """
210
+ spec = lookup(name)
211
+ if spec is None or spec.in_shell(shell):
212
+ return None
213
+ return f"/{spec.name} is not in this shell: {spec.absent[shell]}"
214
+
215
+
216
+ @dataclass
217
+ class SlashCommand:
218
+ name: str # without the leading slash
219
+ summary: str # one line, shown by /help
220
+ handler: Callable # (shell_state, args: str) -> None
221
+ usage: Optional[str] = None # shown by /help when the shape is not obvious
222
+ # Other names the same command answers to (batch 57). A FIELD rather
223
+ # than two more registrations, and the difference is what the LISTS
224
+ # say: `all()` and `names()` stay canonical, so `/help` prints one row
225
+ # per command and a bare slash still offers the menu it always did.
226
+ # Registering `/exit` and `/bye` outright would have sorted `bye`
227
+ # second in that menu, ahead of `/claims`, for a name nobody browses
228
+ # for -- and moved every window position batch 56 measured.
229
+ aliases: tuple[str, ...] = ()
230
+ # Batch 84. What to offer once this command's name has been typed and a
231
+ # space follows it: `(argument_text) -> [SlashCommand]`, where each row's
232
+ # `name` is the WHOLE line after the slash, because that is what the
233
+ # panel draws and what completion writes into the prompt.
234
+ #
235
+ # Opt-in per command, and that is what keeps `/copy last` offering
236
+ # nothing: a command without one behaves exactly as every command did
237
+ # before this field existed, which is the contract
238
+ # `test_a_space_ends_it_at_either_end` pins.
239
+ complete: Optional[Callable] = None
240
+
241
+
242
+ def bind(name: str, handler: Callable,
243
+ complete: Optional[Callable] = None) -> SlashCommand:
244
+ """A command built from its catalog entry -- the only way a shell
245
+ should construct one, since everything but the handler is the
246
+ catalog's to say."""
247
+ spec = CATALOG[name]
248
+ return SlashCommand(spec.name, spec.summary, handler, spec.usage,
249
+ spec.aliases, complete)
250
+
251
+
252
+ class CommandRegistry:
253
+ def __init__(self, shell: Optional[str] = None) -> None:
254
+ self._commands: dict[str, SlashCommand] = {}
255
+ # alias -> canonical name. A second index rather than a scan, and
256
+ # it is what makes an alias collision detectable at REGISTRATION
257
+ # instead of at the keystroke that silently reached the wrong
258
+ # handler.
259
+ self._aliases: dict[str, str] = {}
260
+ # §89. The shell this registry belongs to, which binds it to the
261
+ # catalog. None is the bare mechanism, for a test of the mechanism.
262
+ self.shell = shell
263
+
264
+ def _check_bound(self, command: SlashCommand) -> None:
265
+ """A shell's registry takes only what the catalog declares for it,
266
+ exactly as declared (§89).
267
+
268
+ AT REGISTRATION, the alias check's reason: a summary edited in one
269
+ shell's registration would otherwise be the first thing the two
270
+ disagree about, and nothing would say so until a reader compared
271
+ two /help outputs.
272
+ """
273
+ spec = CATALOG.get(command.name)
274
+ if spec is None:
275
+ raise ValueError(
276
+ f"/{command.name} is not in core/commands.py's catalog; "
277
+ f"declare it there, then bind a handler to it")
278
+ if not spec.in_shell(self.shell):
279
+ raise ValueError(
280
+ f"/{command.name} is declared absent from the {self.shell} "
281
+ f"({spec.absent[self.shell]}); change the catalog first")
282
+ declared = (spec.summary, spec.usage, tuple(spec.aliases))
283
+ given = (command.summary, command.usage, tuple(command.aliases))
284
+ if declared != given:
285
+ raise ValueError(
286
+ f"/{command.name} differs from its catalog entry "
287
+ f"({given} vs {declared}); build it with bind()")
288
+
289
+ def register(self, command: SlashCommand) -> None:
290
+ """Register by name; re-registering the same name overwrites.
291
+
292
+ Idempotent on purpose -- `register_builtin_commands()` runs on
293
+ import AND is called again by tests, so a second pass must not
294
+ duplicate or raise.
295
+
296
+ An alias that would shadow something REFUSES, both ways round: a
297
+ name already taken by a command, and a command name already taken
298
+ by somebody's alias. Both resolve silently otherwise -- `get()`
299
+ prefers real names, so the alias would simply stop working and
300
+ nothing would say why.
301
+
302
+ A shell's registry also refuses what the catalog does not declare
303
+ for that shell, or declares differently (§89, `_check_bound`).
304
+ """
305
+ if self.shell is not None:
306
+ self._check_bound(command)
307
+ for alias in command.aliases:
308
+ if alias in self._commands:
309
+ raise ValueError(
310
+ f"/{alias} is already a command; it cannot also be an "
311
+ f"alias of /{command.name}")
312
+ owner = self._aliases.get(alias)
313
+ if owner is not None and owner != command.name:
314
+ raise ValueError(
315
+ f"/{alias} is already an alias of /{owner}; it cannot "
316
+ f"also be an alias of /{command.name}")
317
+ owner = self._aliases.get(command.name)
318
+ if owner is not None and owner != command.name:
319
+ raise ValueError(
320
+ f"/{command.name} is already an alias of /{owner}")
321
+ old = self._commands.get(command.name)
322
+ if old is not None:
323
+ for alias in old.aliases:
324
+ if alias not in command.aliases \
325
+ and self._aliases.get(alias) == command.name:
326
+ del self._aliases[alias]
327
+ self._commands[command.name] = command
328
+ for alias in command.aliases:
329
+ self._aliases[alias] = command.name
330
+
331
+ def get(self, name: str) -> Optional[SlashCommand]:
332
+ """The command called `name`, by its own name or by an alias.
333
+
334
+ Names win over aliases, which is also the collision `register`
335
+ refuses -- so the precedence can never actually be exercised.
336
+ """
337
+ command = self._commands.get(name)
338
+ if command is not None:
339
+ return command
340
+ canonical = self._aliases.get(name)
341
+ return self._commands.get(canonical) if canonical else None
342
+
343
+ def names(self) -> list[str]:
344
+ return sorted(self._commands)
345
+
346
+ def all(self) -> list[SlashCommand]:
347
+ return [self._commands[n] for n in self.names()]
348
+
349
+ def matching(self, text: str) -> list[SlashCommand]:
350
+ """Commands whose name starts with the token in `text`.
351
+
352
+ The suggestion panel's source, and it reads `all()` so the panel and
353
+ `/help` cannot disagree about what exists -- register a command
354
+ anywhere and both change, which is the whole reason the matching
355
+ lives here rather than in the widget.
356
+
357
+ A BARE slash token offers commands: leading whitespace allowed
358
+ (`dispatch` tolerates it, so `" /help"` runs and had better
359
+ offer), a leading `/`, and no whitespace inside the name.
360
+
361
+ PAST THE FIRST SPACE, the command itself answers (batch 84). If it
362
+ declares a `complete` the rows come from there, and if it does not
363
+ the answer is nothing, exactly as it was for every command before
364
+ the field existed. `/config ` is the only one today.
365
+
366
+ The split is on a SPACE and nothing else, because `dispatch`
367
+ partitions on a space and nothing else: a line with a newline or a
368
+ tab in it is not a command line there, so it must not look like one
369
+ here. A panel that offered `/config` for a line `dispatch` would
370
+ send to the model as chat is the disagreement this whole method is
371
+ written to avoid.
372
+
373
+ `lstrip`, not `strip`, and the difference is a bug this had: a
374
+ TRAILING space survives `strip()`, so `"/copy "` read as `"/copy"`
375
+ and the panel stayed open over a line that had already moved on to
376
+ its arguments. Once a space is typed there is nothing left to
377
+ complete, whichever end of the token it is on.
378
+
379
+ Lowercased for the same reason `dispatch` lowercases: `/HELP` runs,
380
+ so `/HEL` had better offer it.
381
+
382
+ ALIASES join the list once a prefix is typed, and never on a bare
383
+ slash (batch 57). The bare slash is the MENU -- it is what someone
384
+ who does not know the commands presses, and a menu lists each
385
+ thing once, under its own name. `/ex` is not browsing: it is a
386
+ guess, and the answer to a guess is whether it works. So
387
+ `matching("/") == all()` still holds exactly, and typing toward an
388
+ alias surfaces it.
389
+ """
390
+ token = text.lstrip()
391
+ if not token.startswith("/"):
392
+ return []
393
+ head, space, rest = token.partition(" ")
394
+ if any(c.isspace() for c in head):
395
+ # A newline or a tab before any space. Not a command line.
396
+ return []
397
+ if space:
398
+ if any(c.isspace() and c != " " for c in rest):
399
+ return []
400
+ command = self.get(head[1:].lower())
401
+ if command is None or command.complete is None:
402
+ return []
403
+ # CONTAINED HERE, unlike dispatch(), and the asymmetry is the
404
+ # point rather than an inconsistency. `matching()` runs per
405
+ # KEYSTROKE on the UI thread, and the right answer to a
406
+ # completer that raises is "offer nothing" -- which is this
407
+ # function's own vocabulary, already returned on four other
408
+ # lines. There is no policy for the shell to decide, so there
409
+ # is nothing to hand upward.
410
+ #
411
+ # dispatch() is the other way round: what a broken COMMAND does
412
+ # to the session is the shell's call, so it is caught at the
413
+ # call site in tui/app.py instead (batch 135). Uncontained,
414
+ # this was the same exposure one layer over and on a hotter
415
+ # path: an exception here reaches Textual's `_handle_exception`
416
+ # and exits the application mid-keystroke, while the user is
417
+ # still typing the command.
418
+ try:
419
+ return command.complete(rest)
420
+ except Exception: # noqa: BLE001 -- see the comment above
421
+ logger.exception(
422
+ "The /%s completer raised; offering no rows.",
423
+ command.name)
424
+ return []
425
+ prefix = token[1:].lower()
426
+ matches = [c for c in self.all() if c.name.startswith(prefix)]
427
+ if not prefix:
428
+ return matches
429
+ matches.extend(self._alias_row(a) for a in self._aliases
430
+ if a.startswith(prefix))
431
+ return sorted(matches, key=lambda command: command.name)
432
+
433
+ def _alias_row(self, alias: str) -> SlashCommand:
434
+ """One offer for `alias`, carrying the canonical command's handler.
435
+
436
+ A real `SlashCommand` rather than a flag on the canonical one, so
437
+ the panel needs to know nothing about aliases: it draws the name
438
+ it is given and completes the name it drew, which has to be the
439
+ alias the user was typing rather than the name they were not.
440
+ """
441
+ command = self._commands[self._aliases[alias]]
442
+ return SlashCommand(
443
+ alias, f"{command.summary} (alias of /{command.name})",
444
+ command.handler, command.usage, complete=command.complete)
445
+
446
+ def dispatch(self, app, raw: str) -> bool:
447
+ """Run the command in `raw` (a line starting with '/').
448
+
449
+ Returns True if a command handled the line, False if the name is
450
+ unknown -- the caller decides what to do about it. Unknown names are
451
+ NOT sent to the model: a mistyped slash command should say so, not
452
+ silently become a chat turn that burns a request.
453
+ """
454
+ stripped = raw[1:].strip()
455
+ name, _, args = stripped.partition(" ")
456
+ command = self.get(name.lower())
457
+ if command is None:
458
+ return False
459
+ command.handler(app, args.strip())
460
+ return True