zettcode-presenters 0.4.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_presenters-0.4.0/.gitignore +37 -0
- zettcode_presenters-0.4.0/PKG-INFO +21 -0
- zettcode_presenters-0.4.0/pyproject.toml +52 -0
- zettcode_presenters-0.4.0/src/zettcode/presenters/__init__.py +17 -0
- zettcode_presenters-0.4.0/src/zettcode/presenters/brand.py +43 -0
- zettcode_presenters-0.4.0/src/zettcode/presenters/plugin.py +35 -0
- zettcode_presenters-0.4.0/src/zettcode/presenters/presenters.py +809 -0
- zettcode_presenters-0.4.0/src/zettcode/presenters/pulse.py +116 -0
- zettcode_presenters-0.4.0/src/zettcode/presenters/py.typed +0 -0
- zettcode_presenters-0.4.0/src/zettcode/presenters/text.py +304 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
**/.venv/
|
|
2
|
+
**/__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.egg-info/
|
|
5
|
+
build/
|
|
6
|
+
dist/
|
|
7
|
+
.smoke/
|
|
8
|
+
.coverage
|
|
9
|
+
**/.pytest_cache/
|
|
10
|
+
**/.ruff_cache/
|
|
11
|
+
.zett-tool-output/
|
|
12
|
+
.env
|
|
13
|
+
.DS_Store
|
|
14
|
+
|
|
15
|
+
# viztracer writes its trace here by default.
|
|
16
|
+
/result.json
|
|
17
|
+
|
|
18
|
+
# The docs site: dependencies, build output, and VitePress' cache.
|
|
19
|
+
node_modules/
|
|
20
|
+
docs/.vitepress/dist/
|
|
21
|
+
docs/.vitepress/cache/
|
|
22
|
+
docs/.vitepress/.temp/
|
|
23
|
+
|
|
24
|
+
# The TypeScript client is built from its sources; only dist/ is published.
|
|
25
|
+
clients/typescript/dist/
|
|
26
|
+
|
|
27
|
+
# The gateway's page is built from clients/gateway into the package when a distribution is made (`make gateway-ui`);
|
|
28
|
+
# the build output is not kept in the repository. pyproject's `artifacts` puts it in the wheel all the same.
|
|
29
|
+
packages/zettcode-gateway/src/zettcode/gateway/static/
|
|
30
|
+
|
|
31
|
+
# The palette gallery is generated by `make palettes`: every widget painted in
|
|
32
|
+
# every palette, written by docs/scripts/palette_gallery.py. Regenerate it
|
|
33
|
+
# rather than committing a 2 MB copy that goes stale the moment a colour moves.
|
|
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
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: zettcode-presenters
|
|
3
|
+
Version: 0.4.0
|
|
4
|
+
Summary: The conversation's rows and how ZettCode's terminal draws them
|
|
5
|
+
Project-URL: Repository, https://github.com/Chang-LeHung/zettcode
|
|
6
|
+
Author: Chang-LeHung
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
Keywords: presenters,transcript,zettcode
|
|
9
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
16
|
+
Classifier: Typing :: Typed
|
|
17
|
+
Requires-Python: >=3.10
|
|
18
|
+
Requires-Dist: zettcode-plugin-api
|
|
19
|
+
Requires-Dist: zettcode-tui
|
|
20
|
+
Provides-Extra: types
|
|
21
|
+
Requires-Dist: zettcode-sdk; extra == 'types'
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "zettcode-presenters"
|
|
3
|
+
description = "The conversation's rows and how ZettCode's terminal draws them"
|
|
4
|
+
requires-python = ">=3.10"
|
|
5
|
+
dynamic = ["version"]
|
|
6
|
+
license = "MIT"
|
|
7
|
+
authors = [{name = "Chang-LeHung"}]
|
|
8
|
+
keywords = ["zettcode", "presenters", "transcript"]
|
|
9
|
+
classifiers = [
|
|
10
|
+
"Development Status :: 5 - Production/Stable",
|
|
11
|
+
"Programming Language :: Python :: 3.10",
|
|
12
|
+
"Programming Language :: Python :: 3.11",
|
|
13
|
+
"Programming Language :: Python :: 3.12",
|
|
14
|
+
"Programming Language :: Python :: 3.13",
|
|
15
|
+
"Programming Language :: Python :: 3.14",
|
|
16
|
+
"Programming Language :: Python :: 3.15",
|
|
17
|
+
"Typing :: Typed",
|
|
18
|
+
]
|
|
19
|
+
dependencies = [
|
|
20
|
+
# Written against the plugin contract, which is where the row model and the presenter base class are defined.
|
|
21
|
+
"zettcode-plugin-api",
|
|
22
|
+
"zettcode-tui",
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
[project.optional-dependencies]
|
|
26
|
+
# The wording reads `Usage` figures the SDK defines; it is imported for the annotation only.
|
|
27
|
+
types = ["zettcode-sdk"]
|
|
28
|
+
|
|
29
|
+
# A part of the program, not a plugin: the `zettcode.plugins` group is what the plugin release line looks for.
|
|
30
|
+
[project.entry-points."zettcode.terminal"]
|
|
31
|
+
presenters = "zettcode.presenters.plugin:PresentersPlugin"
|
|
32
|
+
|
|
33
|
+
[project.urls]
|
|
34
|
+
Repository = "https://github.com/Chang-LeHung/zettcode"
|
|
35
|
+
|
|
36
|
+
[build-system]
|
|
37
|
+
requires = ["hatchling"]
|
|
38
|
+
build-backend = "hatchling.build"
|
|
39
|
+
|
|
40
|
+
[tool.hatch.version]
|
|
41
|
+
# One version for the whole repository: the engine ships the file.
|
|
42
|
+
path = "../zettcode-engine/src/zettcode/version.py"
|
|
43
|
+
|
|
44
|
+
[tool.hatch.build.targets.wheel]
|
|
45
|
+
packages = ["src/zettcode"]
|
|
46
|
+
|
|
47
|
+
[tool.hatch.build.targets.sdist]
|
|
48
|
+
include = ["/src", "/pyproject.toml"]
|
|
49
|
+
|
|
50
|
+
[tool.pytest.ini_options]
|
|
51
|
+
testpaths = ["tests"]
|
|
52
|
+
asyncio_mode = "auto"
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"""The conversation's rows and how the terminal draws them.
|
|
2
|
+
|
|
3
|
+
`entries` is the data — one class per kind of row a transcript can hold — and `presenters` is how one kind becomes
|
|
4
|
+
lines: a presenter per kind, the families inside a kind (a tool, a change, a relayed message), and the registry that
|
|
5
|
+
picks between them. `brand` is the pixel art the welcome row draws.
|
|
6
|
+
|
|
7
|
+
The terminal's transcript, the projector that fills it and the replay that rebuilds it stay in `zettcode.app`: this
|
|
8
|
+
distribution is the part of them that a plugin replaces — a front end registers its own presenter through
|
|
9
|
+
`ctx.tui.register_presenter`, and `zettcode-plugin-api` re-exports `Entry` and `Presenter` so it can.
|
|
10
|
+
|
|
11
|
+
The plugin that registers the built-ins lives in the program (`zettcode.app.plugins.builtins`), because drawing a row
|
|
12
|
+
is a terminal hook and the terminal's plugin base is there; it reads `presenters.BUILTIN_PRESENTERS`, so the program
|
|
13
|
+
installs them the way it installs every other built-in — by listing it, never by discovering it — and `[plugins]
|
|
14
|
+
disable` has nothing to name.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from __future__ import annotations
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"""The pixel robot shared by the terminal banner and documentation assets.
|
|
2
|
+
|
|
3
|
+
Each character is one square pixel: frame, ear, dark face, eye, or heart;
|
|
4
|
+
``.`` is transparent. One fifteen-by-ten map drives every rendering; the
|
|
5
|
+
terminal holds two vertically stacked pixels per cell for a five-row mark,
|
|
6
|
+
and the documentation scales those same pixels without resampling them.
|
|
7
|
+
The brand colours stay fixed in both themes; only the surrounding text follows
|
|
8
|
+
the reader's palette.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
from zettcode.plugin_api.pets import pixel_lines
|
|
14
|
+
from zettcode.tui.render.style import TextLine
|
|
15
|
+
|
|
16
|
+
LOGO_PALETTE: dict[str, str] = {
|
|
17
|
+
"F": "#84b795",
|
|
18
|
+
"E": "#558967",
|
|
19
|
+
"D": "#263d34",
|
|
20
|
+
"I": "#b9dfb3",
|
|
21
|
+
"H": "#e4b47c",
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
LOGO_PIXELS: tuple[str, ...] = (
|
|
25
|
+
"..FFFFFFFFFFF..",
|
|
26
|
+
".FFFFFFFFFFFFF.",
|
|
27
|
+
"EFFDIIDDDIIDFFE",
|
|
28
|
+
"EFFDIIDDDIIDFFE",
|
|
29
|
+
"EFFDDDDDDDDDFFE",
|
|
30
|
+
"EFFDDHHDHHDDFFE",
|
|
31
|
+
"EFFDDHHHHHDDFFE",
|
|
32
|
+
"EFFDDDDHDDDDFFE",
|
|
33
|
+
".FFFFFFFFFFFFF.",
|
|
34
|
+
"..FFFFFFFFFFF..",
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def logo_lines() -> tuple[TextLine, ...]:
|
|
39
|
+
"""Return the full-size mark: :data:`LOGO_PIXELS` in :data:`LOGO_PALETTE`, five rows of cells."""
|
|
40
|
+
return pixel_lines(LOGO_PIXELS, LOGO_PALETTE)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
LOGO_LINES: tuple[TextLine, ...] = logo_lines()
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"""The plugin that offers the program's own row drawing to the terminal.
|
|
2
|
+
|
|
3
|
+
It is an ordinary plugin, found through the ``zettcode.plugins`` entry point like any other, and the terminal lists it
|
|
4
|
+
as required: the program does not start without it, and ``[plugins] disable`` does not reach it. It needs nothing
|
|
5
|
+
else, and the plugins that draw more kinds of row depend on it (``deps = ("presenters",)``) so theirs register after.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from typing import TYPE_CHECKING
|
|
11
|
+
|
|
12
|
+
from zettcode.plugin_api.plugin import TuiPlugin
|
|
13
|
+
from zettcode.presenters.presenters import BUILTIN_PRESENTERS
|
|
14
|
+
|
|
15
|
+
if TYPE_CHECKING: # pragma: no cover - annotations only
|
|
16
|
+
from zettcode.plugin_api import PluginContext
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class PresentersPlugin(TuiPlugin):
|
|
20
|
+
"""How the program draws its own rows, offered the way any plugin offers a presenter.
|
|
21
|
+
|
|
22
|
+
They register at the priority their class declares, which is the lowest there is, so a plugin that draws the same
|
|
23
|
+
kind or family wins without having to outrank them. Adding a built-in kind of row is adding a presenter to
|
|
24
|
+
``BUNDLED`` in the conversation and nothing here.
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
name = "presenters"
|
|
28
|
+
description = "Draws the conversation: messages, tool calls, results and the rest"
|
|
29
|
+
|
|
30
|
+
def activate(self, ctx: PluginContext) -> None:
|
|
31
|
+
"""Register every built-in presenter at the priority its class declares."""
|
|
32
|
+
if ctx.tui is None:
|
|
33
|
+
return
|
|
34
|
+
for presenter in BUILTIN_PRESENTERS:
|
|
35
|
+
ctx.tui.register_presenter(presenter)
|