zettcode-recap 0.1.0__tar.gz → 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {zettcode_recap-0.1.0 → zettcode_recap-0.2.0}/.gitignore +9 -1
- {zettcode_recap-0.1.0 → zettcode_recap-0.2.0}/PKG-INFO +18 -10
- {zettcode_recap-0.1.0 → zettcode_recap-0.2.0}/README.md +15 -7
- {zettcode_recap-0.1.0 → zettcode_recap-0.2.0}/pyproject.toml +16 -17
- {zettcode_recap-0.1.0/src/zettcode_recap → zettcode_recap-0.2.0/src/zettcode/recap}/__init__.py +15 -6
- zettcode_recap-0.2.0/src/zettcode/recap/py.typed +0 -0
- zettcode_recap-0.2.0/tests/conftest.py +23 -0
- {zettcode_recap-0.1.0 → zettcode_recap-0.2.0}/tests/test_recap.py +38 -7
- {zettcode_recap-0.1.0 → zettcode_recap-0.2.0}/LICENSE +0 -0
|
@@ -26,9 +26,17 @@ clients/typescript/dist/
|
|
|
26
26
|
|
|
27
27
|
# The gateway's page is built from clients/gateway into the package when a distribution is made (`make gateway-ui`);
|
|
28
28
|
# the build output is not kept in the repository. pyproject's `artifacts` puts it in the wheel all the same.
|
|
29
|
-
zettcode/src/zettcode/gateway/static/
|
|
29
|
+
packages/zettcode-gateway/src/zettcode/gateway/static/
|
|
30
30
|
|
|
31
31
|
# The palette gallery is generated by `make palettes`: every widget painted in
|
|
32
32
|
# every palette, written by docs/scripts/palette_gallery.py. Regenerate it
|
|
33
33
|
# rather than committing a 2 MB copy that goes stale the moment a colour moves.
|
|
34
34
|
docs/internal/palettes.html
|
|
35
|
+
|
|
36
|
+
# The release order is generated from the pyproject.toml files (`make order`); it is not kept in git.
|
|
37
|
+
packages/order.txt
|
|
38
|
+
|
|
39
|
+
# The desktop and phone apps build the gateway's page into their own folders, and electron-builder writes its
|
|
40
|
+
# installers under release/.
|
|
41
|
+
clients/desktop/renderer/
|
|
42
|
+
clients/desktop/release/
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: zettcode-recap
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: A ZettCode plugin: /recap sums up where the session is, and does so on its own when you step away
|
|
5
|
-
Project-URL: Repository, https://github.com/Chang-LeHung/zettcode/tree/main/
|
|
5
|
+
Project-URL: Repository, https://github.com/Chang-LeHung/zettcode/tree/main/packages/zettcode-recap
|
|
6
6
|
Project-URL: Issues, https://github.com/Chang-LeHung/zettcode/issues
|
|
7
7
|
Author: Chang-LeHung
|
|
8
8
|
License-Expression: MIT
|
|
@@ -19,7 +19,7 @@ Classifier: Programming Language :: Python :: 3.15
|
|
|
19
19
|
Classifier: Topic :: Software Development :: User Interfaces
|
|
20
20
|
Classifier: Typing :: Typed
|
|
21
21
|
Requires-Python: >=3.10
|
|
22
|
-
Requires-Dist: zettcode<0.
|
|
22
|
+
Requires-Dist: zettcode-plugin-api<0.5,>=0.4
|
|
23
23
|
Description-Content-Type: text/markdown
|
|
24
24
|
|
|
25
25
|
# zettcode-recap
|
|
@@ -64,15 +64,23 @@ waiting when the program exits ends with it.
|
|
|
64
64
|
|
|
65
65
|
From a checkout of this repository:
|
|
66
66
|
|
|
67
|
-
uv tool install --force --with ./
|
|
67
|
+
uv tool install --force --with ./packages/zettcode-recap zettcode
|
|
68
68
|
|
|
69
69
|
or, with pip in the environment ZettCode runs in:
|
|
70
70
|
|
|
71
|
-
pip install ./
|
|
71
|
+
pip install ./packages/zettcode-recap
|
|
72
72
|
|
|
73
|
-
|
|
74
|
-
carries would break `pip install "zettcode[recap]"`. The release workflow is in place (`recap-v*`), and the extra
|
|
75
|
-
lands with the first release.
|
|
73
|
+
ZettCode carries this plugin as an extra, so one command installs both into the same environment:
|
|
76
74
|
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
pip install "zettcode[recap]"
|
|
76
|
+
|
|
77
|
+
or, with `uv tool`:
|
|
78
|
+
|
|
79
|
+
uv tool install "zettcode[recap]"
|
|
80
|
+
|
|
81
|
+
`pip install "zettcode[all]"` adds it beside every other plugin this repository publishes.
|
|
82
|
+
|
|
83
|
+
It needs the ZettCode release that added `ask(origin=)` — the parameter that keeps the recap's own question out of a
|
|
84
|
+
resumed transcript — and one early enough to have the terminal group's turn hooks, which is every 0.3 line. Which
|
|
85
|
+
release carries `ask(origin=)` is settled by `RELEASING.md`; `pyproject.toml` still says
|
|
86
|
+
`zettcode-plugin-api>=0.3,<0.4`, and raising that floor belongs to the release commit that sets the number.
|
|
@@ -40,15 +40,23 @@ waiting when the program exits ends with it.
|
|
|
40
40
|
|
|
41
41
|
From a checkout of this repository:
|
|
42
42
|
|
|
43
|
-
uv tool install --force --with ./
|
|
43
|
+
uv tool install --force --with ./packages/zettcode-recap zettcode
|
|
44
44
|
|
|
45
45
|
or, with pip in the environment ZettCode runs in:
|
|
46
46
|
|
|
47
|
-
pip install ./
|
|
47
|
+
pip install ./packages/zettcode-recap
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
carries would break `pip install "zettcode[recap]"`. The release workflow is in place (`recap-v*`), and the extra
|
|
51
|
-
lands with the first release.
|
|
49
|
+
ZettCode carries this plugin as an extra, so one command installs both into the same environment:
|
|
52
50
|
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
pip install "zettcode[recap]"
|
|
52
|
+
|
|
53
|
+
or, with `uv tool`:
|
|
54
|
+
|
|
55
|
+
uv tool install "zettcode[recap]"
|
|
56
|
+
|
|
57
|
+
`pip install "zettcode[all]"` adds it beside every other plugin this repository publishes.
|
|
58
|
+
|
|
59
|
+
It needs the ZettCode release that added `ask(origin=)` — the parameter that keeps the recap's own question out of a
|
|
60
|
+
resumed transcript — and one early enough to have the terminal group's turn hooks, which is every 0.3 line. Which
|
|
61
|
+
release carries `ask(origin=)` is settled by `RELEASING.md`; `pyproject.toml` still says
|
|
62
|
+
`zettcode-plugin-api>=0.3,<0.4`, and raising that floor belongs to the release commit that sets the number.
|
|
@@ -22,41 +22,40 @@ classifiers = [
|
|
|
22
22
|
]
|
|
23
23
|
dependencies = [
|
|
24
24
|
# The plugin API: `PluginContext`, `TuiPlugin`, and the terminal group's focus and turn-end hooks, which the 0.3
|
|
25
|
-
# line added.
|
|
26
|
-
|
|
25
|
+
# line added. The recap also asks with `ask(origin=)`, which 0.3.0-0.3.3 do not take: raise this floor to the release
|
|
26
|
+
# that ships it, in the same commit that sets that version.
|
|
27
|
+
"zettcode-plugin-api>=0.4,<0.5",
|
|
27
28
|
]
|
|
28
29
|
|
|
29
30
|
[project.urls]
|
|
30
|
-
Repository = "https://github.com/Chang-LeHung/zettcode/tree/main/
|
|
31
|
+
Repository = "https://github.com/Chang-LeHung/zettcode/tree/main/packages/zettcode-recap"
|
|
31
32
|
Issues = "https://github.com/Chang-LeHung/zettcode/issues"
|
|
32
33
|
|
|
33
|
-
[project.entry-points."zettcode.
|
|
34
|
-
recap = "
|
|
34
|
+
[project.entry-points."zettcode.plugin"]
|
|
35
|
+
recap = "zettcode.recap:RecapPlugin"
|
|
36
|
+
|
|
37
|
+
[tool.zettcode]
|
|
38
|
+
# Published on its own line and installed by a reader: the group name no longer says which packages are plugins.
|
|
39
|
+
plugin = true
|
|
35
40
|
|
|
36
41
|
[build-system]
|
|
37
42
|
requires = ["hatchling"]
|
|
38
43
|
build-backend = "hatchling.build"
|
|
39
44
|
|
|
40
45
|
[tool.hatch.version]
|
|
41
|
-
path = "src/
|
|
46
|
+
path = "src/zettcode/recap/__init__.py"
|
|
42
47
|
|
|
43
48
|
[tool.hatch.build.targets.wheel]
|
|
44
|
-
packages = ["src/
|
|
49
|
+
packages = ["src/zettcode"]
|
|
45
50
|
|
|
46
51
|
[tool.hatch.build.targets.sdist]
|
|
47
52
|
include = ["/src", "/tests", "/README.md", "/LICENSE", "/pyproject.toml"]
|
|
48
53
|
|
|
49
54
|
[dependency-groups]
|
|
50
|
-
dev
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
target-version = "py310"
|
|
55
|
-
src = ["src", "tests"]
|
|
56
|
-
|
|
57
|
-
[tool.ruff.lint]
|
|
58
|
-
select = ["E", "F", "I", "UP", "B"]
|
|
59
|
-
ignore = ["E501"]
|
|
55
|
+
# What the tests import beyond the plugin itself. The workspace's own dev group carries the same names for `make test`;
|
|
56
|
+
# this one is what the release workflow installs into the fresh environment it tests the built plugin in, so a
|
|
57
|
+
# test-only import a plugin gains is declared here rather than guessed there.
|
|
58
|
+
dev = ["packaging>=24,<27", "pytest>=8,<9", "pytest-asyncio>=0.26,<2"]
|
|
60
59
|
|
|
61
60
|
[tool.pytest.ini_options]
|
|
62
61
|
testpaths = ["tests"]
|
{zettcode_recap-0.1.0/src/zettcode_recap → zettcode_recap-0.2.0/src/zettcode/recap}/__init__.py
RENAMED
|
@@ -31,18 +31,23 @@ from collections.abc import Coroutine
|
|
|
31
31
|
from contextlib import suppress
|
|
32
32
|
from typing import TYPE_CHECKING
|
|
33
33
|
|
|
34
|
-
from zettcode.
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
from zettcode.plugin_api import (
|
|
35
|
+
HOST_LINK,
|
|
36
|
+
CommandContext,
|
|
37
|
+
CommandHost,
|
|
38
|
+
CommandResult,
|
|
39
|
+
HostLink,
|
|
40
|
+
PluginContext,
|
|
41
|
+
TuiPlugin,
|
|
42
|
+
)
|
|
37
43
|
|
|
38
44
|
if TYPE_CHECKING: # pragma: no cover - annotations only
|
|
39
45
|
from collections.abc import Mapping
|
|
40
46
|
from typing import Any
|
|
41
47
|
|
|
42
|
-
from zettcode.app.commands import CommandHost
|
|
43
48
|
|
|
44
49
|
#: The one place the version is written; ``pyproject.toml`` reads it from here.
|
|
45
|
-
__version__ = "0.
|
|
50
|
+
__version__ = "0.2.0"
|
|
46
51
|
|
|
47
52
|
__all__ = ["RecapPlugin", "__version__"]
|
|
48
53
|
|
|
@@ -215,6 +220,10 @@ class RecapPlugin(TuiPlugin):
|
|
|
215
220
|
async def _ask(self) -> str:
|
|
216
221
|
"""Ask the model for the summary, as the shell's own side question.
|
|
217
222
|
|
|
223
|
+
``origin="recap"``: the question is the plugin's, not the reader's, so nothing of the exchange is drawn — the
|
|
224
|
+
projector drops it live — and nothing of it comes back when the session is resumed. The one line the reader
|
|
225
|
+
sees is the quote :meth:`_show` draws.
|
|
226
|
+
|
|
218
227
|
Raises:
|
|
219
228
|
RuntimeError: The shell is not built yet.
|
|
220
229
|
Exception: Whatever the ask raised — a run already going, the session locked, the provider failing.
|
|
@@ -222,7 +231,7 @@ class RecapPlugin(TuiPlugin):
|
|
|
222
231
|
host = self._host()
|
|
223
232
|
if host is None:
|
|
224
233
|
raise RuntimeError("The shell is not ready yet")
|
|
225
|
-
return await host.client.session.ask(PROMPT, cache="read", timeout=TIMEOUT_SECONDS)
|
|
234
|
+
return await host.client.session.ask(PROMPT, cache="read", timeout=TIMEOUT_SECONDS, origin="recap")
|
|
226
235
|
|
|
227
236
|
async def _recap(self, *, cancellable: bool) -> str:
|
|
228
237
|
"""Ask for the summary and return it, saying nothing itself.
|
|
File without changes
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"""The repository's shared isolation, when these tests run from it: see `support/conftest.py`.
|
|
2
|
+
|
|
3
|
+
A plugin's sdist carries its tests, and an unpacked sdist has no repository beside them: there the suite runs as it
|
|
4
|
+
did before the repository's suites shared one setup. From the checkout — where `make test` and the release job run
|
|
5
|
+
— the `HOME` redirect and the fixtures are the same as every other suite's.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import pathlib
|
|
11
|
+
import sys
|
|
12
|
+
|
|
13
|
+
ROOT = pathlib.Path(__file__).resolve().parents[3]
|
|
14
|
+
SUPPORT = ROOT / "support"
|
|
15
|
+
|
|
16
|
+
# The checkout, not merely a directory called `support`: an unpacked sdist sits anywhere, and running a
|
|
17
|
+
# stranger's conftest would be worse than running without the shared isolation.
|
|
18
|
+
if (ROOT / "pyproject.toml").is_file() and SUPPORT.is_dir():
|
|
19
|
+
sys.path.insert(0, str(SUPPORT))
|
|
20
|
+
for _suite in sorted((ROOT / "packages").glob("*/tests")):
|
|
21
|
+
sys.path.append(str(_suite))
|
|
22
|
+
_SHARED = SUPPORT / "conftest.py"
|
|
23
|
+
exec(compile(_SHARED.read_text(encoding="utf-8"), str(_SHARED), "exec"), globals())
|
|
@@ -6,12 +6,12 @@ import asyncio
|
|
|
6
6
|
from pathlib import Path
|
|
7
7
|
|
|
8
8
|
import pytest
|
|
9
|
-
|
|
9
|
+
|
|
10
10
|
from zettcode.app.plugins import HOST_LINK, HostLink
|
|
11
11
|
from zettcode.app.plugins.loader import terminal_context
|
|
12
12
|
from zettcode.config import ModelConfig, ZettCodeConfig
|
|
13
|
-
|
|
14
|
-
from
|
|
13
|
+
from zettcode.plugin_api.commands import CommandContext
|
|
14
|
+
from zettcode.recap import PROMPT, RecapPlugin
|
|
15
15
|
|
|
16
16
|
SESSION = "s-1"
|
|
17
17
|
|
|
@@ -22,7 +22,7 @@ class FakeSession:
|
|
|
22
22
|
def __init__(self, answer: str = "Fixing the parser; next, run the tests.") -> None:
|
|
23
23
|
self.id = SESSION
|
|
24
24
|
self.answer = answer
|
|
25
|
-
self.asked: list[tuple[str, float | None, str]] = []
|
|
25
|
+
self.asked: list[tuple[str, float | None, str, bool]] = []
|
|
26
26
|
self.locked = False
|
|
27
27
|
self.refuse: Exception | None = None
|
|
28
28
|
#: When set, ``ask`` waits for it, so a test can hold a recap in flight.
|
|
@@ -31,8 +31,10 @@ class FakeSession:
|
|
|
31
31
|
self.history_gate: asyncio.Event | None = None
|
|
32
32
|
self.history_messages: list[object] = []
|
|
33
33
|
|
|
34
|
-
async def ask(
|
|
35
|
-
self
|
|
34
|
+
async def ask(
|
|
35
|
+
self, question: str, *, on_event=None, timeout=None, cache="read", origin: str = "reader", watched=None
|
|
36
|
+
) -> str:
|
|
37
|
+
self.asked.append((question, timeout, cache, origin))
|
|
36
38
|
if self.gate is not None:
|
|
37
39
|
await self.gate.wait()
|
|
38
40
|
if self.refuse is not None:
|
|
@@ -256,7 +258,9 @@ async def test_a_reader_who_stayed_away_long_enough_gets_a_recap(tmp_path):
|
|
|
256
258
|
plugin.turn_ended(True)
|
|
257
259
|
await settled(lambda: bool(session.asked))
|
|
258
260
|
|
|
259
|
-
assert session.asked == [(PROMPT, 60.0, "read"
|
|
261
|
+
assert session.asked == [(PROMPT, 60.0, "read", "recap")], (
|
|
262
|
+
"one side question, read-only, with a deadline, asked by the plugin"
|
|
263
|
+
)
|
|
260
264
|
assert host.transcript.messages == ["> **Recap** \u00b7 Fixing the parser; next, run the tests."]
|
|
261
265
|
assert host.redraws == 1, "the frame that shows it is asked for"
|
|
262
266
|
plugin._cancel()
|
|
@@ -301,6 +305,7 @@ async def test_the_command_summarises_now_and_shows_the_answer(tmp_path):
|
|
|
301
305
|
assert result.notification == "Recap ready"
|
|
302
306
|
assert result.message == "> **Recap** \u00b7 Fixing the parser; next, run the tests.", "words are the answer"
|
|
303
307
|
assert session.asked[0][2] == "read"
|
|
308
|
+
assert session.asked[0][3] == "recap", "the plugin's own question, not the reader's"
|
|
304
309
|
|
|
305
310
|
|
|
306
311
|
async def test_the_command_tells_the_reader_why_there_is_no_recap(tmp_path):
|
|
@@ -355,3 +360,29 @@ def test_the_plugin_also_activates_without_a_screen(tmp_path):
|
|
|
355
360
|
plugin.activate(PluginContext(config, {}))
|
|
356
361
|
|
|
357
362
|
assert plugin._link is None
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
def test_the_zettcode_range_admits_the_release_the_plugin_runs_on():
|
|
366
|
+
"""The plugin installs beside zettcode, so the range it declares has to admit the version in this checkout.
|
|
367
|
+
|
|
368
|
+
uv resolves a workspace member for a dependency without checking the declared range, and the lock records no
|
|
369
|
+
specifier, so a zettcode bump past this cap — or a floor raised past what is published — locks, tests green and
|
|
370
|
+
fails only in a reader's environment. The release workflow installs `./zettcode` from this same checkout, which
|
|
371
|
+
satisfies every floor by construction, so it cannot catch it either: widening the range is part of the release
|
|
372
|
+
commit that sets the number.
|
|
373
|
+
"""
|
|
374
|
+
from importlib.metadata import version as installed
|
|
375
|
+
|
|
376
|
+
from packaging.requirements import Requirement
|
|
377
|
+
|
|
378
|
+
from zettcode._compat import tomllib
|
|
379
|
+
|
|
380
|
+
project = Path(__file__).resolve().parent.parent / "pyproject.toml"
|
|
381
|
+
settings = tomllib.loads(project.read_text(encoding="utf-8"))
|
|
382
|
+
ranges = [Requirement(line) for line in settings["project"]["dependencies"]]
|
|
383
|
+
(plugin,) = [requirement for requirement in ranges if requirement.name == "zettcode-plugin-api"]
|
|
384
|
+
|
|
385
|
+
current = installed("zettcode-plugin-api")
|
|
386
|
+
assert plugin.specifier.contains(current, prereleases=True), (
|
|
387
|
+
f"pyproject.toml requires {plugin}, which excludes zettcode-plugin-api {current}, the release this test runs on"
|
|
388
|
+
)
|
|
File without changes
|