zettcode-engine 0.4.7__tar.gz → 0.5.1__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.
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/PKG-INFO +2 -2
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/pyproject.toml +1 -1
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/config.py +8 -5
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/core.py +19 -3
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/plugins/loader.py +35 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/plugins/plugin.py +7 -1
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/plugins/switches.py +182 -34
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/service_contracts.py +10 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/version.py +1 -1
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/.gitignore +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/_compat.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/budget.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/config_edit.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/__init__.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/agent/__init__.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/agent/base.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/agent/context.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/agent/exports.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/agent/interaction.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/agent/sessions.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/agent/settings.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/agent/turns.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/delivery.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/delivery_runtime.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/dialogue/__init__.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/dialogue/ask.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/dialogue/side.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/dialogue/title.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/export/__init__.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/export/trace/script.js +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/export/trace/style.css +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/export/trace/template.html +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/extensions/__init__.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/extensions/capabilities.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/extensions/compaction.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/extensions/context.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/extensions/files.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/extensions/guidance.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/extensions/harness_switch.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/extensions/mcp_notice.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/extensions/relay.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/extensions/subagents.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/extensions/usage.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/harness_paths.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/inbox.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/permission/__init__.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/permission/approval.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/permission/readonly.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/permission/sandbox.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/pipeline.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/plugins/__init__.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/plugins/cli.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/plugins/commands.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/plugins/context.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/plugins/extension.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/plugins/graph.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/plugins/groups.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/plugins/llm.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/plugins/mixins.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/plugins/services.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/plugins/settings.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/plugins/state.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/plugins/triggers.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/provided.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/py.typed +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/server_tools.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/storage/__init__.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/storage/layout.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/storage/ledger.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/storage/locks.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/storage/metadata.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/storage/records.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/storage/store.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/error_text.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/filelock.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/logging_setup.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/mention.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/modes.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/paths.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/plugin_tui.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/processes.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/prompt.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/providers.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/py.typed +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/registry.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/relay.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/statusline_parts.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/wire.py +0 -0
- {zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/wording.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: zettcode-engine
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.1
|
|
4
4
|
Summary: The agent core of ZettCode: the runtime over zett-agent, and the leaf types it is written on
|
|
5
5
|
Project-URL: Repository, https://github.com/Chang-LeHung/zettcode
|
|
6
6
|
Author: Chang-LeHung
|
|
@@ -19,6 +19,6 @@ Requires-Dist: exceptiongroup<2,>=1.2; python_version < '3.11'
|
|
|
19
19
|
Requires-Dist: pydantic<3,>=2
|
|
20
20
|
Requires-Dist: tomli<3,>=2; python_version < '3.11'
|
|
21
21
|
Requires-Dist: zett-agent<0.3,>=0.2.10
|
|
22
|
-
Requires-Dist: zettcode-tools<0.
|
|
22
|
+
Requires-Dist: zettcode-tools<0.6,>=0.5.1
|
|
23
23
|
Provides-Extra: tiktoken
|
|
24
24
|
Requires-Dist: tiktoken<1,>=0.12; extra == 'tiktoken'
|
|
@@ -18,7 +18,7 @@ classifiers = [
|
|
|
18
18
|
]
|
|
19
19
|
dependencies = [
|
|
20
20
|
# The coding tools the runtime hands the model, a leaf of its own beneath the engine.
|
|
21
|
-
"zettcode-tools>=0.
|
|
21
|
+
"zettcode-tools>=0.5.1,<0.6",
|
|
22
22
|
# The runtime this is a core over. Imported directly: the agent, the message types, the approval mode.
|
|
23
23
|
"zett-agent>=0.2.10,<0.3",
|
|
24
24
|
# The session store's records are pydantic models.
|
|
@@ -490,7 +490,9 @@ class ZettCodeConfig:
|
|
|
490
490
|
``[plugins] disable`` list; the names the older switch file adds are merged in by
|
|
491
491
|
:attr:`off_names`, so a switch can tell the two apart.
|
|
492
492
|
enabled_plugins: Entry-point names to load although the plugin itself says it is off by default
|
|
493
|
-
(``Plugin.default_enabled``); this is the configuration file's ``[plugins] enable`` list.
|
|
493
|
+
(``Plugin.default_enabled``); this is the configuration file's ``[plugins] enable`` list. A switch that
|
|
494
|
+
turns a plugin on writes it here as well as taking it out of ``disable``, so one press means the same
|
|
495
|
+
for a plugin that is off until named and one that is on until dropped.
|
|
494
496
|
plugin_settings: The ``[plugins.<name>]`` tables, by plugin name, exactly as written. A plugin declares
|
|
495
497
|
what its own keys mean and what they default to (``ctx.settings``); the configuration only carries the
|
|
496
498
|
reader's values, so a key no plugin knows is harmless and a plugin that ships later needs no change
|
|
@@ -504,8 +506,9 @@ class ZettCodeConfig:
|
|
|
504
506
|
shows in its plan panel. Off by default: a plan is a turn spent
|
|
505
507
|
updating it, and not every session wants one.
|
|
506
508
|
jit_harness: Start with the just-in-time harness on: the model may write small Python tools of its own
|
|
507
|
-
and run them.
|
|
508
|
-
|
|
509
|
+
and run them. On by default; what it writes runs in a child process of its own, and inside the shell's
|
|
510
|
+
sandbox at every level below ``full``. ``[harness] jit = false`` (or the terminal's ``/plugins`` switch)
|
|
511
|
+
turns it off for the next start.
|
|
509
512
|
shell_network: Let a command that runs in the ``safe`` sandbox use the network. Off by default; ``[shell]
|
|
510
513
|
network = true`` turns it on. ``full`` always has the network, and so does a machine with no sandbox.
|
|
511
514
|
sessions_enabled: Register with the background session broker, so this session can be
|
|
@@ -558,7 +561,7 @@ class ZettCodeConfig:
|
|
|
558
561
|
subagent_max_iterations: int = DEFAULT_SUBAGENT_MAX_ITERATIONS
|
|
559
562
|
subagent_messaging: bool = False
|
|
560
563
|
todowrite_enabled: bool = False
|
|
561
|
-
jit_harness: bool =
|
|
564
|
+
jit_harness: bool = True
|
|
562
565
|
shell_network: bool = False
|
|
563
566
|
sessions_enabled: bool = True
|
|
564
567
|
update_enabled: bool = True
|
|
@@ -1132,7 +1135,7 @@ def load_config(
|
|
|
1132
1135
|
),
|
|
1133
1136
|
subagent_messaging=bool(_setting(harness, "subagent_messaging", bool, False)),
|
|
1134
1137
|
todowrite_enabled=bool(_setting(harness, "todowrite", bool, False)),
|
|
1135
|
-
jit_harness=bool(_setting(harness, "jit", bool,
|
|
1138
|
+
jit_harness=bool(_setting(harness, "jit", bool, True)),
|
|
1136
1139
|
shell_network=bool(_setting(shell, "network", bool, False)),
|
|
1137
1140
|
sessions_enabled=bool(_setting(sessions, "enabled", bool, True)),
|
|
1138
1141
|
update_enabled=bool(_setting(update, "enabled", bool, True)),
|
|
@@ -428,8 +428,9 @@ class ZettCodeEngine:
|
|
|
428
428
|
os.chdir(config.workspace)
|
|
429
429
|
file_models = config.models
|
|
430
430
|
# A machine that has never been set up has no model to start on; the shell opens anyway and says so (see
|
|
431
|
-
# the invariant S23), and `use_model` sizes this runtime the moment `/config` writes the first entry.
|
|
432
|
-
#
|
|
431
|
+
# the invariant S23), and `use_model` sizes this runtime the moment `/config` writes the first entry. The
|
|
432
|
+
# first entry is also the one a run starts on: the file's, or — when it has none — the first model a plugin
|
|
433
|
+
# offers, chosen below once the plugins have been loaded.
|
|
433
434
|
selected = file_models[0] if file_models else None
|
|
434
435
|
effort = config.reasoning_effort if selected is None else selected.accepted_effort(config.reasoning_effort)
|
|
435
436
|
# One policy, read by everything that decides whether a command is asked
|
|
@@ -471,6 +472,15 @@ class ZettCodeEngine:
|
|
|
471
472
|
if shared:
|
|
472
473
|
provided.update(shared)
|
|
473
474
|
plugins = (load or _load_engine_plugins)(config, provided)
|
|
475
|
+
offered = entries(plugins.providers)
|
|
476
|
+
# The file is the reader's own order, so its first entry is the one a run starts on. With no entry there, the
|
|
477
|
+
# first model a plugin offers takes that place: a key in the environment is then enough to type at once,
|
|
478
|
+
# instead of the shell asking for a `/model` choice before it will do anything.
|
|
479
|
+
first_offered: ModelConfig | None = None
|
|
480
|
+
if selected is None and offered:
|
|
481
|
+
first_offered = offered[0]
|
|
482
|
+
selected = first_offered
|
|
483
|
+
effort = selected.accepted_effort(config.reasoning_effort)
|
|
474
484
|
runtime = cls(
|
|
475
485
|
config=config,
|
|
476
486
|
persistence=persistence,
|
|
@@ -486,8 +496,14 @@ class ZettCodeEngine:
|
|
|
486
496
|
plugins=plugins,
|
|
487
497
|
_models=models,
|
|
488
498
|
file_models=file_models,
|
|
489
|
-
provided_models=
|
|
499
|
+
provided_models=offered,
|
|
490
500
|
)
|
|
501
|
+
if first_offered is not None:
|
|
502
|
+
# The compaction policy asked for the selected model while it activated and was given none: this is the
|
|
503
|
+
# same sizing a switch does. A runtime whose plugins provide no policy (an engine preview with no agent
|
|
504
|
+
# parts) has nothing to size, and `use_model` would look it up in vain.
|
|
505
|
+
if runtime.plugins.find(COMPACTION, OnDemandCompaction) is not None:
|
|
506
|
+
runtime.use_model(first_offered)
|
|
491
507
|
context_reports.bind(runtime)
|
|
492
508
|
context_page.bind(runtime)
|
|
493
509
|
# The plugins are loaded, so the models they offered are known: a plugin that lists the models sees its own.
|
|
@@ -95,6 +95,7 @@ PROGRAM_DISTRIBUTIONS: dict[str, frozenset[str]] = {
|
|
|
95
95
|
"zettcode-tool-output",
|
|
96
96
|
"zettcode-truncation",
|
|
97
97
|
"zettcode-guidance",
|
|
98
|
+
"zettcode-one-system",
|
|
98
99
|
}
|
|
99
100
|
),
|
|
100
101
|
TERMINAL_ROLE: frozenset({"zettcode-app", "zettcode-commands", "zettcode-pets", "zettcode-presenters"}),
|
|
@@ -204,6 +205,23 @@ def _file_plugins(path: Path) -> tuple[list[Plugin[Any]], list[tuple[str, BaseEx
|
|
|
204
205
|
return plugins, failures
|
|
205
206
|
|
|
206
207
|
|
|
208
|
+
def file_off_by_default(path: Path) -> bool | None:
|
|
209
|
+
"""Return whether a single-file plugin loads nothing unless ``[plugins] enable`` names it.
|
|
210
|
+
|
|
211
|
+
The answer is on the class, so the file is imported here the way a start imports it: its module is executed and
|
|
212
|
+
its plugin classes are built, but nothing is activated and no command of the plugin runs. ``None`` when the file
|
|
213
|
+
cannot be read as a plugin at all — a failure the next start reports, and one a list must not turn into a
|
|
214
|
+
traceback. A file that defines several classes is off by default when every one of them asks to be.
|
|
215
|
+
"""
|
|
216
|
+
try:
|
|
217
|
+
plugins, _failures = _file_plugins(path)
|
|
218
|
+
except KeyboardInterrupt:
|
|
219
|
+
raise
|
|
220
|
+
except BaseException: # noqa: BLE001 - an unreadable plugin file is the loader's to report, not a caller's
|
|
221
|
+
return None
|
|
222
|
+
return bool(plugins) and not any(plugin.default_enabled() for plugin in plugins)
|
|
223
|
+
|
|
224
|
+
|
|
207
225
|
def load_plugins(
|
|
208
226
|
config: ZettCodeConfig,
|
|
209
227
|
*,
|
|
@@ -444,6 +462,19 @@ def run(
|
|
|
444
462
|
kept.extend(extra)
|
|
445
463
|
kept_ids.update(id(candidate) for candidate in extra)
|
|
446
464
|
needed.update(dep for candidate in extra for dep in candidate.deps)
|
|
465
|
+
# The plugins dropped for exactly one reason — they say they are off by default — are remembered, so a list can
|
|
466
|
+
# draw the row as off and a switch knows which line of the configuration file turns one on. An origin that kept
|
|
467
|
+
# another candidate is not one of them: a single file may define a class that loads and one that does not, and the
|
|
468
|
+
# file it names did its work, so neither list may call the file off by default.
|
|
469
|
+
kept_origins = {candidate.origin for candidate in candidates if id(candidate) in kept_ids}
|
|
470
|
+
loader.off_by_default.extend(
|
|
471
|
+
candidate.origin
|
|
472
|
+
for candidate in candidates
|
|
473
|
+
if id(candidate) not in kept_ids
|
|
474
|
+
and candidate.origin not in kept_origins
|
|
475
|
+
and candidate.plugin is not None
|
|
476
|
+
and not candidate.plugin.default_enabled()
|
|
477
|
+
)
|
|
447
478
|
candidates = kept
|
|
448
479
|
# Within the program's own groups the stated rank decides, then the name; the stable sort keeps everything else.
|
|
449
480
|
at = [i for i, c in enumerate(candidates) if c.agent]
|
|
@@ -552,6 +583,9 @@ class Loader:
|
|
|
552
583
|
#: One ``(name, why)`` per plugin that lost a name to one loaded before it; the winner did nothing wrong,
|
|
553
584
|
#: so these are notes rather than failures, and a list shows them without a switch.
|
|
554
585
|
self.taken: list[tuple[str, str]] = []
|
|
586
|
+
#: The origins of the plugins left out only because they say they are off by default, in discovery order; a
|
|
587
|
+
#: list shows one as off and a switch writes it into ``[plugins] enable``.
|
|
588
|
+
self.off_by_default: list[str] = []
|
|
555
589
|
#: The origins of the compiled-in plugins, in load order, so a bundle can say which rows are the program's.
|
|
556
590
|
self.builtins: list[str] = []
|
|
557
591
|
#: Whether the plugin being accepted is the program's own (built in, or one of its parts); read by ``merge``.
|
|
@@ -652,6 +686,7 @@ class Loader:
|
|
|
652
686
|
builtins=tuple(self.builtins),
|
|
653
687
|
triggers=tuple(self.triggers),
|
|
654
688
|
taken=tuple(self.taken),
|
|
689
|
+
default_off=tuple(dict.fromkeys(self.off_by_default)),
|
|
655
690
|
)
|
|
656
691
|
|
|
657
692
|
# -- the same for every front end --
|
|
@@ -84,7 +84,9 @@ class Plugin(PluginAgentMixin, Generic[_C], ABC):
|
|
|
84
84
|
when the entry-point name is not the label you want in
|
|
85
85
|
diagnostics. When it is empty the entry-point name is used, and a
|
|
86
86
|
plugin that declares neither falls back to the class name.
|
|
87
|
-
description: One-line summary of what the plugin adds,
|
|
87
|
+
description: One-line summary of what the plugin adds, shown beside its switch on ``/plugins`` and used in
|
|
88
|
+
diagnostics. A plugin a reader can switch should say something here: a listed row with nothing to say
|
|
89
|
+
costs the reader the one line that tells the two plugins called alike apart.
|
|
88
90
|
priority: Hook order against every other extension: lower runs first,
|
|
89
91
|
and equal priorities keep registration order.
|
|
90
92
|
setting: The configuration key that turns its work off, for a plugin compiled into the program; ``None`` when
|
|
@@ -183,6 +185,9 @@ class Plugins:
|
|
|
183
185
|
itself (see :class:`~zettcode.engine.plugins.triggers.TriggerHost`).
|
|
184
186
|
taken: The plugins that lost a name to one loaded before them, each as ``(name, why)``; they are not failures
|
|
185
187
|
of the plugin that kept it, and a list shows them without a switch.
|
|
188
|
+
default_off: The origins of the plugins this process left out only because they say they are off by default
|
|
189
|
+
(:meth:`Plugin.default_enabled`). A list draws each as off and says which line turns it on; it is not a
|
|
190
|
+
failure, since the reader never asked for it.
|
|
186
191
|
"""
|
|
187
192
|
|
|
188
193
|
host: PluginExtension | None = None
|
|
@@ -195,6 +200,7 @@ class Plugins:
|
|
|
195
200
|
builtins: tuple[str, ...] = ()
|
|
196
201
|
triggers: tuple[TriggerRegistration, ...] = ()
|
|
197
202
|
taken: tuple[tuple[str, str], ...] = ()
|
|
203
|
+
default_off: tuple[str, ...] = ()
|
|
198
204
|
|
|
199
205
|
@property
|
|
200
206
|
def failures(self) -> tuple[str, ...]:
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
Two things decide it, and both are written now for the process that starts next:
|
|
4
4
|
|
|
5
5
|
* A plugin installed as a distribution is switched by `[plugins] disable` in the configuration file; an older
|
|
6
|
-
file of names beside the session store is still read and merged.
|
|
6
|
+
file of names beside the session store is still read and merged. A plugin that says it is off by default
|
|
7
|
+
(:meth:`~zettcode.engine.plugins.plugin.Plugin.default_enabled`) is the other way round: it stays off until
|
|
8
|
+
`[plugins] enable` names it, and that is the line a switch turning one on writes.
|
|
7
9
|
* A plugin compiled into the program has no file of its own. What turns its work off is a setting the reader already
|
|
8
10
|
has — ``[skills] enabled``, ``[mcp] enabled`` — which the plugin declares (see
|
|
9
11
|
:attr:`~zettcode.engine.plugins.plugin.Plugin.setting`). A compiled-in plugin that declares none cannot be switched
|
|
@@ -57,6 +59,10 @@ class PluginEntry:
|
|
|
57
59
|
why: Why it cannot be switched, when it cannot; empty otherwise.
|
|
58
60
|
note: What else a list should say about the row — a plugin that lost its name to one loaded before it has no
|
|
59
61
|
switch and is not a failure, and this says so.
|
|
62
|
+
description: What the plugin adds, in one line. It is derived, not stored: the plugin's own
|
|
63
|
+
:attr:`~zettcode.engine.plugins.plugin.Plugin.description` once it has loaded, and otherwise the summary
|
|
64
|
+
its distribution declares — which is a sentence about the distribution the row's second column names,
|
|
65
|
+
not about one plugin inside it. Empty when neither says anything.
|
|
60
66
|
"""
|
|
61
67
|
|
|
62
68
|
name: str
|
|
@@ -68,6 +74,7 @@ class PluginEntry:
|
|
|
68
74
|
switchable: bool = True
|
|
69
75
|
why: str = ""
|
|
70
76
|
note: str = ""
|
|
77
|
+
description: str = ""
|
|
71
78
|
|
|
72
79
|
|
|
73
80
|
@dataclass(frozen=True, slots=True)
|
|
@@ -77,6 +84,7 @@ class SwitchState:
|
|
|
77
84
|
plugins_file: Path
|
|
78
85
|
plugins_enabled: bool = True
|
|
79
86
|
disabled_plugins: tuple[str, ...] = ()
|
|
87
|
+
enabled_plugins: tuple[str, ...] = ()
|
|
80
88
|
|
|
81
89
|
|
|
82
90
|
def off_names(config: ZettCodeConfig) -> tuple[str, ...]:
|
|
@@ -106,6 +114,10 @@ def catalog(
|
|
|
106
114
|
"""
|
|
107
115
|
builtins = set(bundle.builtins)
|
|
108
116
|
off = set(off_names(config))
|
|
117
|
+
# The two lists a reader wrote, and the plugins the loader left out only because they ask to be: a row is on when
|
|
118
|
+
# it was named, or when nothing holds it back and it wants to be on.
|
|
119
|
+
turned_on = set(config.enabled_plugins)
|
|
120
|
+
by_default = set(bundle.default_off)
|
|
109
121
|
compiled: list[PluginEntry] = []
|
|
110
122
|
installed: list[PluginEntry] = []
|
|
111
123
|
for plugin in bundle.plugins:
|
|
@@ -120,10 +132,21 @@ def catalog(
|
|
|
120
132
|
builtin=True,
|
|
121
133
|
enabled=bool(getattr(config, setting.field)),
|
|
122
134
|
setting=setting.path,
|
|
135
|
+
description=plugin.description,
|
|
123
136
|
)
|
|
124
137
|
)
|
|
125
138
|
continue
|
|
126
|
-
installed.append(
|
|
139
|
+
installed.append(
|
|
140
|
+
_installed(
|
|
141
|
+
plugin.name,
|
|
142
|
+
origin,
|
|
143
|
+
config,
|
|
144
|
+
off=off,
|
|
145
|
+
turned_on=turned_on,
|
|
146
|
+
by_default=by_default,
|
|
147
|
+
description=plugin.description,
|
|
148
|
+
)
|
|
149
|
+
)
|
|
127
150
|
points = tuple(entry_points) if entry_points is not None else loader.installed_entry_points()
|
|
128
151
|
seen = {entry.origin for entry in installed} | {origin for origin, _why in bundle.failed}
|
|
129
152
|
for point in points:
|
|
@@ -136,12 +159,26 @@ def catalog(
|
|
|
136
159
|
if loader.part_group(point) is not None:
|
|
137
160
|
if point.name not in off:
|
|
138
161
|
continue
|
|
139
|
-
|
|
162
|
+
# This one never loaded, so there is no object to ask: its distribution's summary is what it has to say. The
|
|
163
|
+
# metadata is read here and not for every entry point, because a row that loaded speaks for itself.
|
|
164
|
+
installed.append(
|
|
165
|
+
_installed(
|
|
166
|
+
point.name,
|
|
167
|
+
point.name,
|
|
168
|
+
config,
|
|
169
|
+
off=off,
|
|
170
|
+
turned_on=turned_on,
|
|
171
|
+
by_default=by_default,
|
|
172
|
+
description=_summary(point),
|
|
173
|
+
)
|
|
174
|
+
)
|
|
140
175
|
# A single-file plugin that is switched off is not in the bundle (the loader never imported it), so the folder is
|
|
141
176
|
# what says it exists: it stays on the page, off, where it can be switched back on.
|
|
142
177
|
for path in loader.installed_files(config.plugins_dir):
|
|
143
178
|
if path.stem not in seen:
|
|
144
|
-
installed.append(
|
|
179
|
+
installed.append(
|
|
180
|
+
_installed(path.stem, path.stem, config, off=off, turned_on=turned_on, by_default=by_default)
|
|
181
|
+
)
|
|
145
182
|
# A file can load some of its classes and fail others: every reason belongs on the file's one row, not on a
|
|
146
183
|
# second row named after the class, which no switch could ever write. A file that fails all of its classes still
|
|
147
184
|
# gets one row, with every reason joined.
|
|
@@ -159,8 +196,17 @@ def catalog(
|
|
|
159
196
|
for origin, why in bundle.failed:
|
|
160
197
|
if origin in builtins or origin not in loaded_origins:
|
|
161
198
|
failures.setdefault(origin, []).append(why)
|
|
199
|
+
by_name = {point.name: point for point in points}
|
|
162
200
|
failed = [
|
|
163
|
-
_failed(
|
|
201
|
+
_failed(
|
|
202
|
+
origin,
|
|
203
|
+
"; ".join(whys),
|
|
204
|
+
config,
|
|
205
|
+
builtin=origin in builtins,
|
|
206
|
+
off=off,
|
|
207
|
+
# A row that failed has no object either: the summary of the point it came from is all there is.
|
|
208
|
+
description=_summary(by_name[origin]) if origin in by_name else "",
|
|
209
|
+
)
|
|
164
210
|
for origin, whys in failures.items()
|
|
165
211
|
]
|
|
166
212
|
lost = [PluginEntry(name, name, enabled=False, switchable=False, note=note) for name, note in bundle.taken]
|
|
@@ -176,23 +222,42 @@ def catalog(
|
|
|
176
222
|
)
|
|
177
223
|
|
|
178
224
|
|
|
179
|
-
def _installed(
|
|
180
|
-
|
|
225
|
+
def _installed(
|
|
226
|
+
name: str,
|
|
227
|
+
origin: str,
|
|
228
|
+
config: ZettCodeConfig,
|
|
229
|
+
*,
|
|
230
|
+
off: set[str],
|
|
231
|
+
turned_on: set[str] | frozenset[str] = frozenset(),
|
|
232
|
+
by_default: set[str] | frozenset[str] = frozenset(),
|
|
233
|
+
description: str = "",
|
|
234
|
+
) -> PluginEntry:
|
|
235
|
+
"""Return one installed plugin's row: whether the next start loads it, and whether its switch can move.
|
|
236
|
+
|
|
237
|
+
A plugin that asks to be off until it is named is off here too, and its row says so: the loader leaves it out
|
|
238
|
+
for that reason, and a switch turning it on writes ``[plugins] enable``. A name in ``[plugins] disable`` is a
|
|
239
|
+
reader's decision about it, so the row is off and the note is not shown for one.
|
|
240
|
+
"""
|
|
181
241
|
why = (
|
|
182
242
|
"installed plugins are off entirely: [plugins] enabled = false in the configuration file"
|
|
183
243
|
if not config.plugins_enabled
|
|
184
244
|
else ""
|
|
185
245
|
)
|
|
246
|
+
off_by_default = origin in by_default and origin not in turned_on and origin not in off
|
|
186
247
|
return PluginEntry(
|
|
187
248
|
name,
|
|
188
249
|
origin,
|
|
189
|
-
enabled=config.plugins_enabled and origin not in off,
|
|
250
|
+
enabled=config.plugins_enabled and origin not in off and not off_by_default,
|
|
190
251
|
switchable=why == "",
|
|
191
252
|
why=why,
|
|
253
|
+
note="off by default; [plugins] enable turns it on" if off_by_default and config.plugins_enabled else "",
|
|
254
|
+
description=description,
|
|
192
255
|
)
|
|
193
256
|
|
|
194
257
|
|
|
195
|
-
def _failed(
|
|
258
|
+
def _failed(
|
|
259
|
+
origin: str, why: str, config: ZettCodeConfig, *, builtin: bool, off: set[str], description: str = ""
|
|
260
|
+
) -> PluginEntry:
|
|
196
261
|
"""Return the row of a plugin that could not load.
|
|
197
262
|
|
|
198
263
|
A compiled-in one has no switch here: the object that declares its setting never loaded. An installed one keeps
|
|
@@ -207,8 +272,9 @@ def _failed(origin: str, why: str, config: ZettCodeConfig, *, builtin: bool, off
|
|
|
207
272
|
failure=why,
|
|
208
273
|
switchable=False,
|
|
209
274
|
why="it could not load, so there is no switch to move",
|
|
275
|
+
description=description,
|
|
210
276
|
)
|
|
211
|
-
row = _installed(origin, origin, config, off=off)
|
|
277
|
+
row = _installed(origin, origin, config, off=off, description=description)
|
|
212
278
|
return PluginEntry(
|
|
213
279
|
row.name,
|
|
214
280
|
row.origin,
|
|
@@ -216,9 +282,31 @@ def _failed(origin: str, why: str, config: ZettCodeConfig, *, builtin: bool, off
|
|
|
216
282
|
failure=why,
|
|
217
283
|
switchable=row.switchable,
|
|
218
284
|
why=row.why,
|
|
285
|
+
description=row.description,
|
|
219
286
|
)
|
|
220
287
|
|
|
221
288
|
|
|
289
|
+
def _summary(point: EntryPoint) -> str:
|
|
290
|
+
"""Return the one-line summary the distribution behind an entry point declares, or ``""`` when it declares none.
|
|
291
|
+
|
|
292
|
+
The plugin says what it does itself once it loads (:attr:`~zettcode.engine.plugins.plugin.Plugin.description`);
|
|
293
|
+
this is for the rows where it never got that far — the distribution switched off, or a part this process does not
|
|
294
|
+
load — and for those the package metadata is all there is. The summary describes the *distribution*, which is what
|
|
295
|
+
the row's second column names; for a distribution carrying several plugins it is one sentence about all of them.
|
|
296
|
+
A stand-in entry point that has no distribution beside it (a test's own) says nothing rather than failing the page,
|
|
297
|
+
and so does a metadata file that cannot be opened or parsed: a nicety costs its cell, never the page.
|
|
298
|
+
"""
|
|
299
|
+
try:
|
|
300
|
+
# `getattr` for the same reason the loader asks a point for its distribution that way: a stand-in that has
|
|
301
|
+
# none is a point with nothing to say, not a page that cannot open.
|
|
302
|
+
dist = getattr(point, "dist", None)
|
|
303
|
+
metadata = getattr(dist, "metadata", None)
|
|
304
|
+
summary = metadata["Summary"] if metadata is not None else ""
|
|
305
|
+
except (OSError, TypeError, ValueError):
|
|
306
|
+
return ""
|
|
307
|
+
return " ".join(str(summary or "").split())
|
|
308
|
+
|
|
309
|
+
|
|
222
310
|
def _config_disabled(path: Path) -> list[str]:
|
|
223
311
|
"""Return the names ``[plugins] disable`` holds in the configuration file, validating the shape."""
|
|
224
312
|
from zettcode._compat import tomllib
|
|
@@ -254,33 +342,73 @@ def _drop_legacy_names(path: Path, names: set[str]) -> bool:
|
|
|
254
342
|
return True
|
|
255
343
|
|
|
256
344
|
|
|
257
|
-
def
|
|
258
|
-
"""
|
|
345
|
+
def _config_enabled(path: Path) -> list[str]:
|
|
346
|
+
"""Return the names ``[plugins] enable`` holds in the configuration file, validating the shape."""
|
|
347
|
+
from zettcode._compat import tomllib
|
|
348
|
+
|
|
349
|
+
if not path.is_file():
|
|
350
|
+
return []
|
|
351
|
+
try:
|
|
352
|
+
text = path.read_text(encoding="utf-8")
|
|
353
|
+
except OSError:
|
|
354
|
+
return []
|
|
355
|
+
data = tomllib.loads(text) if text.strip() else {}
|
|
356
|
+
plugins = data.get("plugins", {})
|
|
357
|
+
if not isinstance(plugins, dict):
|
|
358
|
+
raise ValueError(f"{path} writes [plugins] in a way /plugins cannot edit; edit the file by hand")
|
|
359
|
+
values = plugins.get("enable", [])
|
|
360
|
+
if not isinstance(values, list) or any(not isinstance(name, str) or not name.strip() for name in values):
|
|
361
|
+
raise ValueError(f"{path} has a [plugins] enable that is not an array of names; edit the file by hand")
|
|
362
|
+
return [name.strip() for name in values]
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
def _write_switches(
|
|
366
|
+
config: ZettCodeConfig | SwitchState,
|
|
367
|
+
*,
|
|
368
|
+
turn_on: set[str] | frozenset[str] = frozenset(),
|
|
369
|
+
turn_off: set[str] | frozenset[str] = frozenset(),
|
|
370
|
+
by_default: set[str] | frozenset[str] = frozenset(),
|
|
371
|
+
forget: set[str] | frozenset[str] = frozenset(),
|
|
372
|
+
) -> None:
|
|
373
|
+
"""Write a switch into ``[plugins] disable`` and, for a plugin that asks to be off, ``[plugins] enable``.
|
|
374
|
+
|
|
375
|
+
``by_default`` names the plugins that are off until they are named
|
|
376
|
+
(:meth:`~zettcode.engine.plugins.plugin.Plugin.default_enabled`); turning one on is what writes `[plugins]
|
|
377
|
+
enable`, and turning it off takes the name out again. A plugin that is on unless it is dropped needs no line
|
|
378
|
+
when it is turned on, so a switch that changes nothing still writes nothing. ``forget`` takes a name out of both
|
|
379
|
+
lists — an uninstall retires it rather than switching it.
|
|
259
380
|
|
|
260
381
|
The configuration file is the one the reader edits and the one ``load_config`` reads, so the switch is written
|
|
261
382
|
there; a file that does not exist yet gets one with the table, and the models are added when the reader sets one.
|
|
262
|
-
|
|
263
|
-
|
|
383
|
+
The read and the replace are held under a lock, so two plugin switches (or two plugin-settings edits) cannot
|
|
384
|
+
lose one another.
|
|
264
385
|
"""
|
|
265
386
|
target = config_path()
|
|
266
387
|
if target.exists() and not target.is_file():
|
|
267
388
|
raise ValueError(f"{target} is not a file; edit the plugin switches by hand")
|
|
389
|
+
on, off, named_for, gone = set(turn_on), set(turn_off), set(by_default), set(forget)
|
|
268
390
|
changed = False
|
|
269
391
|
try:
|
|
270
392
|
with _lock(target):
|
|
271
393
|
text = target.read_text(encoding="utf-8") if target.is_file() else ""
|
|
272
394
|
current = set(_config_disabled(target))
|
|
273
|
-
names = (current |
|
|
395
|
+
names = (current | (off - named_for)) - on - gone
|
|
274
396
|
if names != current:
|
|
275
397
|
text = set_string_list(text, "plugins", "disable", sorted(names), where=target, command="/plugins")
|
|
276
|
-
write_text_atomically(target, text)
|
|
277
398
|
changed = True
|
|
399
|
+
asked = set(_config_enabled(target))
|
|
400
|
+
wanted = (asked | (on & named_for)) - off - gone
|
|
401
|
+
if wanted != asked:
|
|
402
|
+
text = set_string_list(text, "plugins", "enable", sorted(wanted), where=target, command="/plugins")
|
|
403
|
+
changed = True
|
|
404
|
+
if changed:
|
|
405
|
+
write_text_atomically(target, text)
|
|
278
406
|
except (OSError, ValueError) as error:
|
|
279
407
|
raise ValueError(f"the plugin switch could not be written: {error}") from error
|
|
280
|
-
if not _drop_legacy_names(config.plugins_file,
|
|
408
|
+
if not _drop_legacy_names(config.plugins_file, on | off | gone) and on:
|
|
281
409
|
if changed:
|
|
282
|
-
raise ValueError(f"the configuration was changed, but {_still_in_legacy(
|
|
283
|
-
raise ValueError(_still_in_legacy(
|
|
410
|
+
raise ValueError(f"the configuration was changed, but {_still_in_legacy(on)}")
|
|
411
|
+
raise ValueError(_still_in_legacy(on))
|
|
284
412
|
|
|
285
413
|
|
|
286
414
|
def _still_in_legacy(enable: set[str]) -> str:
|
|
@@ -368,10 +496,11 @@ def set_many(
|
|
|
368
496
|
written[name] = enabled
|
|
369
497
|
if off_changes:
|
|
370
498
|
try:
|
|
371
|
-
|
|
499
|
+
_write_switches(
|
|
372
500
|
config,
|
|
373
|
-
|
|
374
|
-
|
|
501
|
+
turn_on={name for name, enabled in off_changes.items() if enabled},
|
|
502
|
+
turn_off={name for name, enabled in off_changes.items() if not enabled},
|
|
503
|
+
by_default=set(bundle.default_off),
|
|
375
504
|
)
|
|
376
505
|
except ValueError as error:
|
|
377
506
|
# Nothing of this batch was written, so the refusals above are still worth reporting with it.
|
|
@@ -451,23 +580,37 @@ def applied(config: ZettCodeConfig, setting: PluginSetting, enabled: bool) -> Ze
|
|
|
451
580
|
return replace(config, **{setting.field: enabled}) # type: ignore[arg-type]
|
|
452
581
|
|
|
453
582
|
|
|
454
|
-
def applied_installed(
|
|
455
|
-
|
|
583
|
+
def applied_installed(
|
|
584
|
+
config: ZettCodeConfig, changes: Mapping[str, bool], *, by_default: set[str] | frozenset[str] = frozenset()
|
|
585
|
+
) -> ZettCodeConfig:
|
|
586
|
+
"""Return ``config`` with the installed names a switch wrote reflected in the two lists a row reads.
|
|
456
587
|
|
|
457
|
-
|
|
458
|
-
|
|
588
|
+
A name turned off is taken out of ``[plugins] enable`` and put in ``disable``, except that a plugin which is off
|
|
589
|
+
by default rests there unnamed. A name turned on is taken out of ``disable`` and named in ``enable`` only when it
|
|
590
|
+
asks to be off — a plugin that is on unless dropped gains no line, so this must not invent one in memory either.
|
|
591
|
+
``by_default`` says which names those are.
|
|
459
592
|
"""
|
|
460
|
-
|
|
593
|
+
off = set(config.disabled_plugins)
|
|
594
|
+
on = set(config.enabled_plugins)
|
|
595
|
+
named_for = set(by_default)
|
|
461
596
|
for name, enabled in changes.items():
|
|
462
|
-
|
|
463
|
-
|
|
597
|
+
if enabled:
|
|
598
|
+
off.discard(name)
|
|
599
|
+
if name in named_for:
|
|
600
|
+
on.add(name)
|
|
601
|
+
else:
|
|
602
|
+
on.discard(name)
|
|
603
|
+
if name not in named_for:
|
|
604
|
+
off.add(name)
|
|
605
|
+
return replace(config, disabled_plugins=tuple(sorted(off)), enabled_plugins=tuple(sorted(on)))
|
|
464
606
|
|
|
465
607
|
|
|
466
|
-
def set_installed(config: ZettCodeConfig | SwitchState, name: str, *, enabled: bool) -> None:
|
|
467
|
-
"""Write one installed plugin's switch
|
|
608
|
+
def set_installed(config: ZettCodeConfig | SwitchState, name: str, *, enabled: bool, by_default: bool = False) -> None:
|
|
609
|
+
"""Write one installed plugin's switch, without loading any plugin.
|
|
468
610
|
|
|
469
611
|
A management command asks this for a name it has already checked exists (an entry point, a single file in
|
|
470
|
-
:attr:`ZettCodeConfig.plugins_dir`, or a name the file already holds).
|
|
612
|
+
:attr:`ZettCodeConfig.plugins_dir`, or a name the file already holds). ``by_default`` says the plugin is off
|
|
613
|
+
until ``[plugins] enable`` names it, which is the line turning it on writes. Nothing is written while
|
|
471
614
|
``[plugins] enabled`` is off; a name in ``[plugins] disable`` is an ordinary switch and can be turned on.
|
|
472
615
|
|
|
473
616
|
Raises:
|
|
@@ -481,7 +624,12 @@ def set_installed(config: ZettCodeConfig | SwitchState, name: str, *, enabled: b
|
|
|
481
624
|
"[plugins] enabled = false in the configuration file turns every installed plugin off; edit that line "
|
|
482
625
|
"to load them again"
|
|
483
626
|
)
|
|
484
|
-
|
|
627
|
+
_write_switches(
|
|
628
|
+
config,
|
|
629
|
+
turn_on={name} if enabled else set(),
|
|
630
|
+
turn_off=set() if enabled else {name},
|
|
631
|
+
by_default={name} if by_default else set(),
|
|
632
|
+
)
|
|
485
633
|
|
|
486
634
|
|
|
487
635
|
def forget_installed(config: ZettCodeConfig | SwitchState, name: str) -> bool:
|
|
@@ -502,7 +650,7 @@ def forget_installed(config: ZettCodeConfig | SwitchState, name: str) -> bool:
|
|
|
502
650
|
if not found:
|
|
503
651
|
return False
|
|
504
652
|
try:
|
|
505
|
-
|
|
653
|
+
_write_switches(config, forget={name})
|
|
506
654
|
except ValueError:
|
|
507
655
|
return False
|
|
508
656
|
return True
|
|
@@ -12,6 +12,8 @@ from dataclasses import dataclass
|
|
|
12
12
|
from typing import TYPE_CHECKING, ClassVar
|
|
13
13
|
|
|
14
14
|
if TYPE_CHECKING: # pragma: no cover - annotations only
|
|
15
|
+
from pathlib import Path
|
|
16
|
+
|
|
15
17
|
from zettcode.engine.extensions.context import ContextReport
|
|
16
18
|
from zettcode.engine.storage.ledger import Ledger
|
|
17
19
|
from zettcode.engine.storage.metadata import SessionInfo
|
|
@@ -31,6 +33,14 @@ class SessionStoreService(ABC):
|
|
|
31
33
|
async def list_sessions(self, *, limit: int = 100, offset: int = 0) -> list[SessionInfo]:
|
|
32
34
|
"""Return the workspace's sessions, newest first."""
|
|
33
35
|
|
|
36
|
+
@abstractmethod
|
|
37
|
+
def session_path(self, session_id: str) -> Path:
|
|
38
|
+
"""Return the file one session's conversation is stored in; it may not exist yet.
|
|
39
|
+
|
|
40
|
+
Raises:
|
|
41
|
+
ValueError: For an id that would leave the store.
|
|
42
|
+
"""
|
|
43
|
+
|
|
34
44
|
|
|
35
45
|
class UsageLedgerService(ABC):
|
|
36
46
|
"""The workspace's usage ledger, read from the stored conversations."""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/export/trace/template.html
RENAMED
|
File without changes
|
|
File without changes
|
{zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/extensions/capabilities.py
RENAMED
|
File without changes
|
{zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/extensions/compaction.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/extensions/harness_switch.py
RENAMED
|
File without changes
|
{zettcode_engine-0.4.7 → zettcode_engine-0.5.1}/src/zettcode/engine/extensions/mcp_notice.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|