nucli 0.2.0__py3-none-any.whl

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.
nu/_cli/__init__.py ADDED
@@ -0,0 +1,6 @@
1
+ """The `nu` command — entrypoint package."""
2
+
3
+ from nu._cli.main import cli, main
4
+
5
+
6
+ __all__ = ["cli", "main"]
nu/_cli/__main__.py ADDED
@@ -0,0 +1,7 @@
1
+ """Enables `python -m nu._cli`."""
2
+
3
+ from nu._cli.main import main
4
+
5
+
6
+ if __name__ == "__main__":
7
+ main()
nu/_cli/_meta.py ADDED
@@ -0,0 +1,26 @@
1
+ """Shared helpers for CLI commands."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import importlib.resources as resources
6
+ from importlib.metadata import PackageNotFoundError, version
7
+ from pathlib import Path
8
+
9
+
10
+ def nu_version() -> str:
11
+ try:
12
+ return version("nucore")
13
+ except PackageNotFoundError:
14
+ return "0.0.0+dev"
15
+
16
+
17
+ def demos_root() -> Path:
18
+ """Locate packaged demo scripts (ships as nu._cli.demos)."""
19
+ return Path(str(resources.files("nu._cli").joinpath("demos")))
20
+
21
+
22
+ def demos() -> dict[str, Path]:
23
+ root = demos_root()
24
+ if not root.is_dir():
25
+ return {}
26
+ return {p.stem: p for p in sorted(root.glob("*.py")) if not p.stem.startswith("_")}
@@ -0,0 +1 @@
1
+ """Individual click commands wired into the `nu` group."""
@@ -0,0 +1,72 @@
1
+ """`nu demo` — list bundled demos, or run one by name."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import ast
6
+ import runpy
7
+ import sys
8
+ from typing import TYPE_CHECKING
9
+
10
+ import rich_click as click
11
+ from rich.console import Console
12
+ from rich.table import Table
13
+ from rich.text import Text
14
+
15
+ from nu._cli._meta import demos
16
+ from nu._config.branding import BLUE, PURPLE
17
+
18
+
19
+ if TYPE_CHECKING:
20
+ from pathlib import Path
21
+
22
+
23
+ _console = Console()
24
+
25
+
26
+ def _description(path: Path) -> str:
27
+ """Return the first line of the module docstring, or empty string."""
28
+ try:
29
+ tree = ast.parse(path.read_text(), filename=str(path))
30
+ except (OSError, SyntaxError):
31
+ return ""
32
+ doc = ast.get_docstring(tree) or ""
33
+ return doc.strip().splitlines()[0] if doc else ""
34
+
35
+
36
+ def _list(found: dict[str, Path]) -> None:
37
+ if not found:
38
+ _console.print("[yellow]no demos found[/yellow]")
39
+ sys.exit(1)
40
+ table = Table(show_header=False, box=None, padding=(0, 2))
41
+ table.add_column(style=f"bold {BLUE}")
42
+ table.add_column(style="dim")
43
+ for name, path in found.items():
44
+ table.add_row(name, _description(path))
45
+ _console.print(Text("demos", style=f"bold {PURPLE}"))
46
+ _console.print(table)
47
+ _console.print(Text.assemble(("run with: ", "dim"), ("nu demo <name>", f"bold {BLUE}")))
48
+
49
+
50
+ @click.command(help="List bundled demos, or run one by name (nu demo <name>).")
51
+ @click.argument("name", required=False)
52
+ def demo(name: str | None) -> None:
53
+ """No arg -> list; name -> run that demo."""
54
+ found = demos()
55
+ if name is None:
56
+ _list(found)
57
+ return
58
+ if name not in found:
59
+ _console.print(f"[red]unknown demo:[/red] [bold]{name}[/bold]", highlight=False)
60
+ _console.print(
61
+ Text.assemble(
62
+ ("available: ", "dim"),
63
+ (", ".join(found) or "(none)", BLUE),
64
+ ),
65
+ )
66
+ sys.exit(2)
67
+ try:
68
+ runpy.run_path(str(found[name]), run_name="__main__")
69
+ except KeyboardInterrupt:
70
+ # Ctrl+C during a demo: nudle already printed its stopped banner;
71
+ # don't let click surface its default "Aborted!" line on top of it.
72
+ pass
@@ -0,0 +1,57 @@
1
+ """`nu doctor` — report python + which fabric extras resolve."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import importlib.util
6
+ import sys
7
+
8
+ import rich_click as click
9
+ from rich.console import Console
10
+ from rich.table import Table
11
+ from rich.text import Text
12
+
13
+ from nu._cli._meta import nu_version
14
+ from nu._config.branding import BLUE, PURPLE
15
+
16
+
17
+ # Fabric extras (as declared in packages/nustd/pyproject.toml) and the import
18
+ # that proves they resolve. The backends live in the `nustd` distribution;
19
+ # this kernel-side command only probes for them, it never imports the fabric.
20
+ _FABRICS: dict[str, str] = {
21
+ "kv": "virtuals",
22
+ "mem": "janus",
23
+ "ui": "nudle",
24
+ "cluster": "ray",
25
+ "proxy": "invisibles",
26
+ "http": "httpx",
27
+ "llm": "httpx",
28
+ "cc": "claude_agent_sdk",
29
+ }
30
+
31
+
32
+ @click.command(help="Report installed fabrics and versions.")
33
+ def doctor() -> None:
34
+ """Report installed fabrics and versions."""
35
+ console = Console()
36
+ header = Text.assemble(
37
+ ("nu ", f"bold {PURPLE}"),
38
+ (nu_version(), f"bold {BLUE}"),
39
+ (" · python ", "dim"),
40
+ (sys.version.split()[0], BLUE),
41
+ )
42
+ console.print(header)
43
+ console.print()
44
+ table = Table(show_header=True, header_style=f"bold {PURPLE}", box=None, padding=(0, 2))
45
+ table.add_column("fabric", style="bold")
46
+ table.add_column("status")
47
+ table.add_column("install", style="dim")
48
+ for name, probe in _FABRICS.items():
49
+ if importlib.util.find_spec(probe) is not None:
50
+ table.add_row(name, Text("● ok", style="green"), "")
51
+ else:
52
+ table.add_row(
53
+ name,
54
+ Text("○ missing", style="yellow"),
55
+ f"pip install 'nustd[{name}]'",
56
+ )
57
+ console.print(table)
@@ -0,0 +1,53 @@
1
+ """`nu telemetry` — inspect and toggle the anonymous usage ping."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import rich_click as click
6
+ from rich.console import Console
7
+ from rich.text import Text
8
+
9
+ from nu._config import config as _config
10
+ from nu._config.branding import BLUE
11
+
12
+
13
+ _console = Console()
14
+
15
+
16
+ def _state_line(on: bool) -> Text:
17
+ label = Text("telemetry: ", style="dim")
18
+ label.append("on" if on else "off", style="bold green" if on else "bold yellow")
19
+ return label
20
+
21
+
22
+ @click.group(invoke_without_command=True, help="Anonymous usage telemetry.")
23
+ @click.pass_context
24
+ def telemetry(ctx: click.Context) -> None:
25
+ """`nu telemetry` — default action shows current status."""
26
+ if ctx.invoked_subcommand is None:
27
+ ctx.invoke(status)
28
+
29
+
30
+ @telemetry.command("status", help="Show current telemetry state.")
31
+ def status() -> None:
32
+ """Print on/off, distinct_id, and config path."""
33
+ on = _config.telemetry_enabled()
34
+ dev = _config.is_dev_install()
35
+ _console.print(_state_line(on))
36
+ if dev:
37
+ _console.print("[dim]dev install detected — no events sent regardless[/dim]")
38
+ _console.print(Text.assemble(("distinct_id: ", "dim"), (_config.distinct_id(), BLUE)))
39
+ _console.print(Text.assemble(("config: ", "dim"), (str(_config.CONFIG_PATH), BLUE)))
40
+
41
+
42
+ @telemetry.command("enable", help="Turn telemetry on.")
43
+ def enable() -> None:
44
+ """Set the config flag to on."""
45
+ _config.set_telemetry(True)
46
+ _console.print(_state_line(True))
47
+
48
+
49
+ @telemetry.command("disable", help="Turn telemetry off.")
50
+ def disable() -> None:
51
+ """Set the config flag to off."""
52
+ _config.set_telemetry(False)
53
+ _console.print(_state_line(False))
@@ -0,0 +1 @@
1
+ """Bundled runnable demos, discoverable via `nu demo`."""
@@ -0,0 +1,89 @@
1
+ """Counter: rocksdb-backed counter ticking every second, live in the browser."""
2
+
3
+ from pathlib import Path
4
+
5
+ import nu
6
+
7
+
8
+ _DB = Path.home() / ".nu" / "demos" / "counter"
9
+ _DB.parent.mkdir(parents=True, exist_ok=True)
10
+
11
+
12
+ class Counter(nu.Shape):
13
+ """Persistent counter state."""
14
+
15
+ value: nu.kv.IntRef
16
+
17
+
18
+ class Links(nu.ui.Row):
19
+ docs = nu.ui.LinkRef.slot(
20
+ label="Read the docs", href="https://nustack.dev/docs", target="_blank"
21
+ )
22
+ github = nu.ui.LinkRef.slot(
23
+ label="Star on GitHub", href="https://github.com/nustackdev/nu", target="_blank"
24
+ )
25
+ examples = nu.ui.LinkRef.slot(
26
+ label="Browse more demos",
27
+ href="https://github.com/nustackdev/nu/tree/main/examples",
28
+ target="_blank",
29
+ )
30
+
31
+
32
+ class Dashboard(nu.ui.Page):
33
+ """Live counter page with description and source."""
34
+
35
+ heading = nu.ui.HeadingRef.slot(label="Persistent counter, live")
36
+ count = nu.ui.StatRef.slot(label="Count")
37
+ about_heading = nu.ui.HeadingRef.slot(label="How it works")
38
+ about = nu.ui.MarkdownRef.slot(
39
+ value=(
40
+ "- Stores counter value in rocksdb.\n"
41
+ "- App increments the counter once a second.\n"
42
+ "- `ReactForever` pushes every change to the browser.\n"
43
+ "- Same Ref system used for rocksdb and UI.\n"
44
+ "- Same Interactions used to orchestrate storage and UI update.\n"
45
+ ),
46
+ )
47
+ links_heading = nu.ui.HeadingRef.slot(label="Try Nu yourself")
48
+ links_intro = nu.ui.TextRef.slot(
49
+ value="Persistent state, live browser, no glue. See how far the primitive goes.",
50
+ )
51
+ links = Links.slot(gap=4, align="center", wrap=True)
52
+ source_heading = nu.ui.HeadingRef.slot(label="Source")
53
+ source_intro = nu.ui.TextRef.slot(
54
+ value="The whole app, one file. Storage, UI, and the wires between them.",
55
+ )
56
+ source = nu.ui.CodeBlockRef.slot(
57
+ code=Path(__file__).read_text(),
58
+ language="python",
59
+ )
60
+
61
+
62
+ class App(nu.ui.Index):
63
+ """UI index with one page."""
64
+
65
+ pages = nu.ui.Pages({"/": Dashboard})
66
+
67
+
68
+ app = nu.With(
69
+ nu.kv.rocksdb_navigator(str(_DB)),
70
+ nu.ui.server(
71
+ nu.kv.auto_flow_atomic(
72
+ nu.ReactForever(
73
+ Counter.value.on_change(),
74
+ Dashboard.count.set_value(nu.str(Counter.value)),
75
+ ),
76
+ ),
77
+ ),
78
+ body=nu.kv.auto_flow_atomic(
79
+ nu.IfDo(Counter.value.missing(), Counter.value.set(0))
80
+ >> nu.ForeverDo(
81
+ Counter.value.inc() >> nu.Delay(1.0),
82
+ )
83
+ ),
84
+ )
85
+
86
+ if __name__ == "__main__":
87
+ import asyncio
88
+
89
+ asyncio.run(nu.arun(app))
@@ -0,0 +1,476 @@
1
+ """Movies: personal tracker. Form, filterable table, detail pages, all persisted."""
2
+
3
+ from pathlib import Path
4
+
5
+ import nu
6
+
7
+
8
+ _DB = Path.home() / ".nu" / "demos" / "movies"
9
+ _DB.parent.mkdir(parents=True, exist_ok=True)
10
+
11
+
12
+ _GENRES = [
13
+ {"value": "action", "label": "Action"},
14
+ {"value": "drama", "label": "Drama"},
15
+ {"value": "scifi", "label": "Sci-fi"},
16
+ {"value": "doc", "label": "Documentary"},
17
+ {"value": "anim", "label": "Animation"},
18
+ ]
19
+
20
+ _GENRES_WITH_ANY = [{"value": "", "label": "Any genre"}, *_GENRES]
21
+
22
+
23
+ # ---- UI ---------------------------------------------------------------------
24
+
25
+
26
+ class TitleField(nu.ui.Field):
27
+ input = nu.ui.InputRef.slot(placeholder="e.g. Arrival")
28
+
29
+
30
+ class TextAreaField(nu.ui.Field):
31
+ input = nu.ui.TextAreaRef.slot(placeholder="Quick thoughts...", rows=2)
32
+
33
+
34
+ class YearField(nu.ui.Field):
35
+ input = nu.ui.NumberInputRef.slot(
36
+ min=1900.0,
37
+ max=2100.0,
38
+ step=1.0,
39
+ default=2020.0,
40
+ )
41
+
42
+
43
+ class RatingField(nu.ui.Field):
44
+ input = nu.ui.NumberInputRef.slot(
45
+ min=1.0,
46
+ max=10.0,
47
+ step=0.5,
48
+ default=7.0,
49
+ )
50
+
51
+
52
+ class GenreField(nu.ui.Field):
53
+ input = nu.ui.SelectRef.slot(options=_GENRES, selected="drama")
54
+
55
+
56
+ class SwitchField(nu.ui.Field):
57
+ input = nu.ui.SwitchRef.slot(default=True)
58
+
59
+
60
+ class DetailsFieldset(nu.ui.Fieldset):
61
+ title = TitleField.slot(label="Title", help="Movie title", required=True)
62
+ year = YearField.slot(label="Year")
63
+ genre = GenreField.slot(label="Genre")
64
+
65
+
66
+ class ScoreFieldset(nu.ui.Fieldset):
67
+ rating = RatingField.slot(label="Rating", help="How much you liked it")
68
+ watched = SwitchField.slot(label="Watched?", help="Off means still on the pile")
69
+ notes = TextAreaField.slot(label="Notes")
70
+
71
+
72
+ class AddMovieForm(nu.ui.Form):
73
+ details = DetailsFieldset.slot(legend="Movie", gap="md")
74
+ score = ScoreFieldset.slot(legend="Your take", gap="md")
75
+ submit = nu.ui.ButtonRef.slot(label="Log it", variant="primary")
76
+ feedback = nu.ui.AlertRef.slot(variant="ok", dismissible=True)
77
+
78
+
79
+ class MinRatingField(nu.ui.Field):
80
+ input = nu.ui.NumberInputRef.slot(min=1.0, max=10.0, step=0.5, default=1.0)
81
+
82
+
83
+ class FilterGenreField(nu.ui.Field):
84
+ input = nu.ui.SelectRef.slot(options=_GENRES_WITH_ANY, selected="")
85
+
86
+
87
+ class WatchedOnlyField(nu.ui.Field):
88
+ input = nu.ui.SwitchRef.slot(default=False)
89
+
90
+
91
+ class FilterRow(nu.ui.Row):
92
+ min_rating = MinRatingField.slot(label="Min rating")
93
+ genre = FilterGenreField.slot(label="Genre")
94
+ watched_only = WatchedOnlyField.slot(label="Already watched")
95
+ apply = nu.ui.ButtonRef.slot(label="Apply", variant="secondary")
96
+ clear = nu.ui.ButtonRef.slot(label="Clear", variant="ghost")
97
+
98
+
99
+ class FilterCard(nu.ui.Card):
100
+ body = FilterRow.slot(gap=3, align="center", wrap=True)
101
+
102
+
103
+ class StatsRow(nu.ui.Row):
104
+ total = nu.ui.StatRef.slot(label="Total")
105
+ watched = nu.ui.StatRef.slot(label="Watched")
106
+ unseen = nu.ui.StatRef.slot(label="Unseen")
107
+ latest = nu.ui.TextRef.slot()
108
+ health = nu.ui.BadgeRef.slot(label="Fresh", variant="ok")
109
+
110
+
111
+ class StatsCard(nu.ui.Card):
112
+ body = StatsRow.slot(gap=6, align="center", wrap=True)
113
+
114
+
115
+ class TableBody(nu.ui.Column):
116
+ table = nu.ui.TableRef.slot(
117
+ columns=["title", "year", "genre", "rating", "watched", "notes"],
118
+ striped=True,
119
+ dense=True,
120
+ clickable_rows=True,
121
+ max_rows=200,
122
+ )
123
+ empty = nu.ui.AlertRef.slot(
124
+ variant="info",
125
+ body="No movies match",
126
+ dismissible=False,
127
+ )
128
+
129
+
130
+ class TableCard(nu.ui.Card):
131
+ body = TableBody.slot(gap=3)
132
+
133
+
134
+ class Links(nu.ui.Row):
135
+ docs = nu.ui.LinkRef.slot(
136
+ label="Read the docs", href="https://nustack.dev/docs", target="_blank"
137
+ )
138
+ github = nu.ui.LinkRef.slot(
139
+ label="Star on GitHub", href="https://github.com/nustackdev/nu", target="_blank"
140
+ )
141
+ examples = nu.ui.LinkRef.slot(
142
+ label="Browse more demos",
143
+ href="https://github.com/nustackdev/nu/tree/main/examples",
144
+ target="_blank",
145
+ )
146
+
147
+
148
+ # ---- Pages ------------------------------------------------------------------
149
+
150
+
151
+ class TopBar(nu.ui.Row):
152
+ about = nu.ui.ButtonRef.slot(label="About this demo", variant="ghost")
153
+
154
+
155
+ class Movies(nu.ui.Page):
156
+ heading = nu.ui.HeadingRef.slot(label="Your movies")
157
+ intro = nu.ui.TextRef.slot(
158
+ value="Log what you watch. Filter the shelf, click a row for details.",
159
+ )
160
+ topbar = TopBar.slot(gap=3, align="center")
161
+
162
+ stats = StatsCard.slot(title="Your shelf")
163
+ form = AddMovieForm.slot(title="Log a movie", gap=4, padding=4)
164
+ filters = FilterCard.slot(title="Filter")
165
+ shelf = TableCard.slot(title="Movies")
166
+
167
+
168
+ class AboutActions(nu.ui.Row):
169
+ back = nu.ui.ButtonRef.slot(label="Back to app", variant="ghost")
170
+
171
+
172
+ class About(nu.ui.Page):
173
+ heading = nu.ui.HeadingRef.slot(label="How it works")
174
+ about = nu.ui.MarkdownRef.slot(
175
+ value=(
176
+ "- Real app: form, filterable table, stats row, per-item detail page.\n"
177
+ "- Every row lives in rocksdb. Restart, everything is still there.\n"
178
+ "- Same Ref system used for storage, form inputs, table, and navigation.\n"
179
+ "- Same Interactions handle add, delete, filter, and page routing.\n"
180
+ ),
181
+ )
182
+ links_heading = nu.ui.HeadingRef.slot(label="Try Nu yourself")
183
+ links_intro = nu.ui.TextRef.slot(
184
+ value="Full apps, forms, routing, no glue. See how far the primitive goes.",
185
+ )
186
+ links = Links.slot(gap=4, align="center", wrap=True)
187
+ source_heading = nu.ui.HeadingRef.slot(label="Source")
188
+ source_intro = nu.ui.TextRef.slot(
189
+ value="The whole app, one file. Storage, UI, and the wires between them.",
190
+ )
191
+ source = nu.ui.CodeBlockRef.slot(
192
+ code=Path(__file__).read_text(),
193
+ language="python",
194
+ )
195
+ actions = AboutActions.slot(gap=3, align="center")
196
+
197
+
198
+ class DetailRow(nu.ui.Row):
199
+ year = nu.ui.StatRef.slot(label="Year")
200
+ genre = nu.ui.StatRef.slot(label="Genre")
201
+ rating = nu.ui.StatRef.slot(label="Rating")
202
+ watched = nu.ui.BadgeRef.slot(label="Watched", variant="ok")
203
+
204
+
205
+ class MetaCard(nu.ui.Card):
206
+ meta = DetailRow.slot(gap=6, align="center", wrap=True)
207
+
208
+
209
+ class NotesCard(nu.ui.Card):
210
+ body = nu.ui.MarkdownRef.slot()
211
+
212
+
213
+ class DetailActions(nu.ui.Row):
214
+ back = nu.ui.ButtonRef.slot(label="Back", variant="ghost")
215
+ remove = nu.ui.ButtonRef.slot(label="Delete", variant="danger")
216
+
217
+
218
+ class MovieDetail(nu.ui.Page):
219
+ heading = nu.ui.HeadingRef.slot()
220
+ meta = MetaCard.slot(title="Details")
221
+ notes = NotesCard.slot(title="Notes")
222
+ actions = DetailActions.slot(gap=3, align="center")
223
+
224
+
225
+ class App(nu.ui.Index):
226
+ title: nu.ui.TitleRef
227
+ nav: nu.ui.NavRef
228
+ pages = nu.ui.Pages({"/": Movies, "/detail": MovieDetail, "/about": About})
229
+
230
+
231
+ # ---- State ------------------------------------------------------------------
232
+
233
+
234
+ class Movie(nu.Shape):
235
+ title = nu.kv.StrRef.slot()
236
+ year = nu.kv.IntRef.slot()
237
+ genre = nu.kv.StrRef.slot()
238
+ rating = nu.kv.FloatRef.slot()
239
+ watched = nu.kv.BoolRef.slot()
240
+ notes = nu.kv.StrRef.slot()
241
+
242
+
243
+ class State(nu.Shape):
244
+ movies = nu.kv.ShapesListRef.slot(Movie)
245
+ total = nu.kv.IntRef.slot()
246
+ watched = nu.kv.IntRef.slot()
247
+ latest_title = nu.kv.StrRef.slot()
248
+ selected = nu.kv.IntRef.slot() # index of the movie open in MovieDetail
249
+
250
+
251
+ # ---- Seed ------------------------------------------------------------------
252
+
253
+ _SEED_MOVIES: list[dict] = [
254
+ {
255
+ "title": "Arrival",
256
+ "year": 2016,
257
+ "genre": "scifi",
258
+ "rating": 8.5,
259
+ "watched": True,
260
+ "notes": "linguists save the world",
261
+ },
262
+ {
263
+ "title": "Dune: Part Two",
264
+ "year": 2024,
265
+ "genre": "scifi",
266
+ "rating": 9.0,
267
+ "watched": True,
268
+ "notes": "worm ride > sequel",
269
+ },
270
+ {
271
+ "title": "The Menu",
272
+ "year": 2022,
273
+ "genre": "drama",
274
+ "rating": 7.0,
275
+ "watched": True,
276
+ "notes": "eat the rich, literally",
277
+ },
278
+ {
279
+ "title": "Perfect Days",
280
+ "year": 2023,
281
+ "genre": "drama",
282
+ "rating": 8.0,
283
+ "watched": False,
284
+ "notes": "tokyo, tapes, toilets",
285
+ },
286
+ ]
287
+
288
+
289
+ # ---- Wire -------------------------------------------------------------------
290
+
291
+
292
+ _ROW_TRANSFORM = nu.List.of(
293
+ nu.DictAttrRef("r")["title"],
294
+ nu.DictAttrRef("r")["year"],
295
+ nu.DictAttrRef("r")["genre"],
296
+ nu.DictAttrRef("r")["rating"],
297
+ nu.If(nu.DictAttrRef("r")["watched"], "yes", "no"),
298
+ nu.DictAttrRef("r")["notes"],
299
+ )
300
+
301
+
302
+ def _rows_form() -> nu.Nu:
303
+ """Map each stored movie dict into a positional row TableRef expects."""
304
+ return nu.Dict.of(
305
+ rows=nu.Collect(
306
+ nu.Map(nu.Iter(State.movies), transform=_ROW_TRANSFORM, key="r"),
307
+ ),
308
+ )
309
+
310
+
311
+ def _rows_filtered() -> nu.Nu:
312
+ """Same shape as _rows_form, but honors the current FilterRow inputs."""
313
+ min_r = nu.Float(FilterRow.min_rating.input)
314
+ genre = nu.Str(FilterRow.genre.input)
315
+ watched_only = nu.Bool(FilterRow.watched_only.input)
316
+ predicate = nu.And(
317
+ nu.Ge(nu.DictAttrRef("r")["rating"], min_r),
318
+ nu.Or(nu.Eq(genre, ""), nu.Eq(nu.DictAttrRef("r")["genre"], genre)),
319
+ nu.Or(nu.Not(watched_only), nu.DictAttrRef("r")["watched"]),
320
+ )
321
+ return nu.Dict.of(
322
+ rows=nu.Collect(
323
+ nu.Map(
324
+ nu.Filter(nu.Iter(State.movies), predicate=predicate, key="r"),
325
+ transform=_ROW_TRANSFORM,
326
+ key="r",
327
+ ),
328
+ ),
329
+ )
330
+
331
+
332
+ # Seed once, on a store that has never been written. A restart then keeps what
333
+ # the user logged instead of replacing the shelf with the samples again.
334
+ # `selected` stays unconditional: it is a cursor into the detail page, not data.
335
+ init = nu.kv.Transaction(
336
+ nu.IfDo(
337
+ State.total.missing(),
338
+ State.total.set(len(_SEED_MOVIES))
339
+ | State.watched.set(sum(1 for m in _SEED_MOVIES if m["watched"]))
340
+ | State.latest_title.set(_SEED_MOVIES[-1]["title"])
341
+ | State.movies.set(_SEED_MOVIES),
342
+ )
343
+ | State.selected.set(0),
344
+ )
345
+
346
+
347
+ hydrate = nu.kv.Snapshot(
348
+ Movies.stats.body.total.set_value(nu.str(State.total))
349
+ | Movies.stats.body.watched.set_value(nu.str(State.watched))
350
+ | Movies.stats.body.unseen.set_value(nu.str(State.total - State.watched))
351
+ | Movies.stats.body.latest.set(State.latest_title)
352
+ | Movies.shelf.body.table.set(_rows_form())
353
+ )
354
+
355
+
356
+ on_add = nu.ReactForever(
357
+ AddMovieForm.submit.clicked(),
358
+ nu.kv.Transaction(
359
+ State.movies.append(
360
+ nu.Dict.of(
361
+ title=nu.Str(AddMovieForm.details.title.input),
362
+ year=nu.Int(AddMovieForm.details.year.input),
363
+ genre=nu.Str(AddMovieForm.details.genre.input),
364
+ rating=nu.Float(AddMovieForm.score.rating.input),
365
+ watched=nu.Bool(AddMovieForm.score.watched.input),
366
+ notes=nu.Str(AddMovieForm.score.notes.input),
367
+ ),
368
+ )
369
+ | State.total.set(State.total + 1)
370
+ | State.watched.set(
371
+ State.watched + nu.If(nu.Bool(AddMovieForm.score.watched.input), 1, 0),
372
+ )
373
+ | State.latest_title.set(nu.Str(AddMovieForm.details.title.input)),
374
+ )
375
+ >> nu.kv.Snapshot(
376
+ Movies.shelf.body.table.set(_rows_form())
377
+ | Movies.stats.body.total.set_value(nu.str(State.total))
378
+ | Movies.stats.body.watched.set_value(nu.str(State.watched))
379
+ | Movies.stats.body.unseen.set_value(nu.str(State.total - State.watched))
380
+ | Movies.stats.body.latest.set(State.latest_title)
381
+ | Movies.form.feedback.set(
382
+ title="Logged",
383
+ body="Added " + nu.Str(AddMovieForm.details.title.input),
384
+ )
385
+ ),
386
+ )
387
+
388
+
389
+ on_row_click = nu.ReactForever(
390
+ Movies.shelf.body.table.row_clicked(),
391
+ nu.IfDo(
392
+ nu.Contains(nu.DictAttrRef("row_click"), "row_index"),
393
+ nu.kv.Transaction(State.selected.set(nu.DictAttrRef("row_click")["row_index"]))
394
+ >> nu.kv.Snapshot(
395
+ MovieDetail.heading.set(State.movies[State.selected].title)
396
+ | MovieDetail.meta.meta.year.set_value(nu.str(State.movies[State.selected].year))
397
+ | MovieDetail.meta.meta.genre.set_value(State.movies[State.selected].genre)
398
+ | MovieDetail.meta.meta.rating.set_value(nu.str(State.movies[State.selected].rating))
399
+ | MovieDetail.meta.meta.watched.set(
400
+ label=nu.If(State.movies[State.selected].watched, "Watched", "Unseen"),
401
+ )
402
+ | MovieDetail.notes.body.set(State.movies[State.selected].notes)
403
+ )
404
+ >> App.nav.set("/detail"),
405
+ ),
406
+ changed_key="row_click",
407
+ )
408
+
409
+
410
+ on_delete = nu.ReactForever(
411
+ MovieDetail.actions.remove.clicked(),
412
+ nu.kv.Transaction(
413
+ State.movies.del_at(State.selected) >> State.total.set(nu.Len(State.movies)),
414
+ )
415
+ >> nu.kv.Snapshot(
416
+ Movies.shelf.body.table.set(_rows_form())
417
+ | Movies.stats.body.total.set_value(nu.str(State.total))
418
+ | Movies.stats.body.unseen.set_value(nu.str(State.total - State.watched))
419
+ )
420
+ >> App.nav.set("/"),
421
+ )
422
+
423
+
424
+ on_back = nu.ReactForever(MovieDetail.actions.back.clicked(), App.nav.set("/"))
425
+
426
+
427
+ on_about_open = nu.ReactForever(Movies.topbar.about.clicked(), App.nav.set("/about"))
428
+
429
+
430
+ on_about_back = nu.ReactForever(About.actions.back.clicked(), App.nav.set("/"))
431
+
432
+
433
+ on_filter_apply = nu.ReactForever(
434
+ FilterRow.apply.clicked(),
435
+ nu.kv.Snapshot(Movies.shelf.body.table.set(_rows_filtered())),
436
+ )
437
+
438
+
439
+ on_filter_clear = nu.ReactForever(
440
+ FilterRow.clear.clicked(),
441
+ nu.kv.Snapshot(
442
+ FilterRow.min_rating.input.set(1.0)
443
+ | FilterRow.genre.input.set("")
444
+ | FilterRow.watched_only.input.set(False)
445
+ | Movies.shelf.body.table.set(_rows_form())
446
+ ),
447
+ )
448
+
449
+
450
+ ui = (
451
+ App.title.set("Movies")
452
+ >> hydrate
453
+ >> (
454
+ on_add
455
+ | on_row_click
456
+ | on_delete
457
+ | on_back
458
+ | on_filter_apply
459
+ | on_filter_clear
460
+ | on_about_open
461
+ | on_about_back
462
+ )
463
+ )
464
+
465
+
466
+ app = nu.With(
467
+ nu.kv.rocksdb_navigator(str(_DB)),
468
+ nu.ui.server(nu.kv.auto_flow_atomic(ui)),
469
+ body=nu.kv.auto_flow_atomic(init >> nu.ForeverDo(nu.Delay(3600))),
470
+ )
471
+
472
+
473
+ if __name__ == "__main__":
474
+ import asyncio
475
+
476
+ asyncio.run(nu.arun(app))
@@ -0,0 +1,93 @@
1
+ """Sampled: kh57-backed series grows forever; the chart repaints a live reservoir sample."""
2
+
3
+ from pathlib import Path
4
+
5
+ import nu
6
+
7
+
8
+ _DB = Path.home() / ".nu" / "demos" / "sampled"
9
+ _DB.parent.mkdir(parents=True, exist_ok=True)
10
+
11
+
12
+ class State(nu.Shape):
13
+ """Persistent series and write cursor."""
14
+
15
+ nums = nu.kv.Kh57Ref.slot(int)
16
+ cursor = nu.kv.IntRef.slot()
17
+
18
+
19
+ class Links(nu.ui.Row):
20
+ docs = nu.ui.LinkRef.slot(
21
+ label="Read the docs", href="https://nustack.dev/docs", target="_blank"
22
+ )
23
+ github = nu.ui.LinkRef.slot(
24
+ label="Star on GitHub", href="https://github.com/nustackdev/nu", target="_blank"
25
+ )
26
+ examples = nu.ui.LinkRef.slot(
27
+ label="Browse more demos",
28
+ href="https://github.com/nustackdev/nu/tree/main/examples",
29
+ target="_blank",
30
+ )
31
+
32
+
33
+ class Dashboard(nu.ui.Page):
34
+ """Live chart page with description and source."""
35
+
36
+ heading = nu.ui.HeadingRef.slot(label="Unbounded series, instant chart")
37
+ chart = nu.ui.LineChart.slot()
38
+ about_heading = nu.ui.HeadingRef.slot(label="How it works")
39
+ about = nu.ui.MarkdownRef.slot(
40
+ value=(
41
+ "- Writes 50 numbers a second into a **kh57-backed** series. Grows without limit.\n"
42
+ "- Chart repaints from a 200-point reservoir sample. Same cost at 1k rows or 1B.\n"
43
+ "- `ReactForever` triggers the resample on every write.\n"
44
+ "- Same Ref system used for storage, sampling, and chart.\n"
45
+ "- Same Interactions used to orchestrate the feed and the redraw.\n"
46
+ ),
47
+ )
48
+ links_heading = nu.ui.HeadingRef.slot(label="Try Nu yourself")
49
+ links_intro = nu.ui.TextRef.slot(
50
+ value="Billion-row backends, live UIs, no glue. See how far the primitive goes.",
51
+ )
52
+ links = Links.slot(gap=4, align="center", wrap=True)
53
+ source_heading = nu.ui.HeadingRef.slot(label="Source")
54
+ source_intro = nu.ui.TextRef.slot(
55
+ value="The whole app, one file. Storage, UI, and the wires between them.",
56
+ )
57
+ source = nu.ui.CodeBlockRef.slot(
58
+ code=Path(__file__).read_text(),
59
+ language="python",
60
+ )
61
+
62
+
63
+ class App(nu.ui.Index):
64
+ """UI index with one page."""
65
+
66
+ pages = nu.ui.Pages({"/": Dashboard})
67
+
68
+
69
+ # reactive wire: repaint the chart on every write to `nums`
70
+ ui = nu.ReactForever(
71
+ State.nums.on_change(),
72
+ Dashboard.chart.set_points(
73
+ nu.Collect(nu.Sorted(nu.Iter(State.nums.sample(200, 0, State.cursor)))),
74
+ ),
75
+ )
76
+
77
+ # feed: append one number to `nums` at 50 Hz, forever
78
+ feed = State.cursor.init(0) >> nu.ForeverDo(
79
+ State.nums.set_item(State.cursor, State.cursor) >> State.cursor.inc() >> nu.Delay(0.02),
80
+ )
81
+
82
+ # assemble: rocksdb-backed, served over the browser
83
+ app = nu.With(
84
+ nu.kv.rocksdb_navigator(str(_DB)),
85
+ nu.ui.server(nu.kv.auto_flow_atomic(ui)),
86
+ body=nu.kv.auto_flow_atomic(feed),
87
+ )
88
+
89
+
90
+ if __name__ == "__main__":
91
+ import asyncio
92
+
93
+ asyncio.run(nu.arun(app))
nu/_cli/main.py ADDED
@@ -0,0 +1,49 @@
1
+ """Root click group for the `nu` CLI (rendered via rich-click)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import rich_click as click
6
+
7
+ from nu._cli._meta import nu_version
8
+ from nu._cli.commands.demo import demo
9
+ from nu._cli.commands.doctor import doctor
10
+ from nu._cli.commands.telemetry import telemetry
11
+ from nu._config.branding import BLUE, PURPLE, render_header
12
+
13
+
14
+ # Rich-click styling: strict brand duo -- purple headers, blue values.
15
+ click.rich_click.USE_RICH_MARKUP = True
16
+ click.rich_click.STYLE_HEADER_TEXT = f"bold {PURPLE}"
17
+ click.rich_click.STYLE_USAGE = f"bold {PURPLE}"
18
+ click.rich_click.STYLE_SWITCH = f"bold {PURPLE}"
19
+ click.rich_click.STYLE_OPTION = f"bold {BLUE}"
20
+ click.rich_click.STYLE_COMMAND = f"bold {BLUE}"
21
+ click.rich_click.STYLE_METAVAR = BLUE
22
+ click.rich_click.STYLE_HELPTEXT_FIRST_LINE = "bold"
23
+ click.rich_click.STYLE_HELPTEXT = ""
24
+ click.rich_click.SHOW_ARGUMENTS = True
25
+ click.rich_click.MAX_WIDTH = 100
26
+
27
+
28
+ @click.group(
29
+ invoke_without_command=True,
30
+ context_settings={"help_option_names": ["-h", "--help"]},
31
+ help="Nu: the interaction primitive.",
32
+ )
33
+ @click.version_option(nu_version(), "-V", "--version", prog_name="nu")
34
+ @click.pass_context
35
+ def cli(ctx: click.Context) -> None:
36
+ """Root `nu` group; individual commands are attached below."""
37
+ if ctx.invoked_subcommand is None:
38
+ render_header()
39
+ click.echo(ctx.get_help())
40
+
41
+
42
+ cli.add_command(demo)
43
+ cli.add_command(doctor)
44
+ cli.add_command(telemetry)
45
+
46
+
47
+ def main() -> None:
48
+ """Console-script entrypoint for `nu`."""
49
+ cli()
@@ -0,0 +1,44 @@
1
+ Metadata-Version: 2.5
2
+ Name: nucli
3
+ Version: 0.2.0
4
+ Summary: The `nu` command line: doctor, demos, telemetry. Ships alongside the nucore kernel and the nustd fabrics.
5
+ Project-URL: Repository, https://github.com/nustackdev/nu
6
+ Author-email: Gor Arakelyan <gorarkln@gmail.com>
7
+ License-Expression: Apache-2.0
8
+ License-File: LICENSE.md
9
+ Keywords: agentic,ai-agents,cli,database,distributed-systems,key-value-store,llm,nu,nustack,observability,python,ray,real-time,rocksdb,state-management,ui
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: License :: OSI Approved :: Apache Software License
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Requires-Python: >=3.10
18
+ Requires-Dist: click>=8.0
19
+ Requires-Dist: nustd>=0.2.0
20
+ Requires-Dist: rich-click>=1.6
21
+ Requires-Dist: rich>=10.7
22
+ Description-Content-Type: text/markdown
23
+
24
+ # nucli
25
+
26
+ The `nu` command line for [Nu](https://nustack.dev).
27
+
28
+ Installing this gives you the `nu` executable:
29
+
30
+ ```bash
31
+ nu --version
32
+ nu doctor # environment + fabric backend check
33
+ nu demo movies # run a packaged demo app
34
+ nu telemetry # see / change telemetry settings
35
+ ```
36
+
37
+ It ships `nu._cli` into the `nu.` namespace and depends on
38
+ [`nustd`](https://pypi.org/project/nustd/) (which pulls the
39
+ [`nucore`](https://pypi.org/project/nucore/) kernel) because the
40
+ packaged demos run on `nu.ui` and `nu.kv` at runtime.
41
+
42
+ You normally do not install this directly - `pip install "nustd[all]" nucli`
43
+ brings it along. Released in lockstep with the kernel. Docs at
44
+ [nustack.dev](https://nustack.dev).
@@ -0,0 +1,17 @@
1
+ nu/_cli/__init__.py,sha256=FxdfZJiiRLr98joIgkgcaeH5Vp7lZrDxRTzvZ8nA1dE,111
2
+ nu/_cli/__main__.py,sha256=6I6DMcmu-eP3NcwYE9Yz4rOCqbPIBwat4dzcgaXqQ2U,106
3
+ nu/_cli/_meta.py,sha256=AVFflKVac7SYTND5DyfypuL3TxDkKcG03CKPLDeAgSw,681
4
+ nu/_cli/main.py,sha256=JbjDej_3-8BGmcER1mk932OWzs9Wi5RWZV-gOHhdN_w,1520
5
+ nu/_cli/commands/__init__.py,sha256=OLY7moehHM4Eqn6H_ql7cOWGUgHw3mOb5bgtZQYGs_A,59
6
+ nu/_cli/commands/demo.py,sha256=1qR3baLX_F1dCTPsFSHNfEmwY_lbQOgmHIaOJmiANJw,2160
7
+ nu/_cli/commands/doctor.py,sha256=C4rhGSB8yMAmVJ6Fr9h-NJCBOyjsYoo6thYPlXcccW8,1751
8
+ nu/_cli/commands/telemetry.py,sha256=SRaF3kvWPEostc5QGgJMi-ULPozB7wNGN51H3AcRrJ4,1672
9
+ nu/_cli/demos/__init__.py,sha256=CdIVCl-Je_xf3-3t0C10fXg3MS-7tRevKtpSbv3-zmE,58
10
+ nu/_cli/demos/counter.py,sha256=GxaFfE1FBawgK3-LrgZIZ-7LQtqT_RnsQgA7OLyYN6Q,2603
11
+ nu/_cli/demos/movies.py,sha256=ob2wfLB4rJ77w_oFZt-ghQ1sU7keCqq-LgqjPcV_2jQ,14232
12
+ nu/_cli/demos/sampled.py,sha256=R-DaM5TCtAOr8jf8mSRtRTdziaIgIe3jDDUKfgnR4nI,2918
13
+ nucli-0.2.0.dist-info/METADATA,sha256=sCP_dGEd54SbFOXeY6uju6JILcsff_JtxObja_3V4Yc,1723
14
+ nucli-0.2.0.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
15
+ nucli-0.2.0.dist-info/entry_points.txt,sha256=8YwI05yDK6NTzBFGVitum_iUW6UiYs-X8hvgXPK44OM,36
16
+ nucli-0.2.0.dist-info/licenses/LICENSE.md,sha256=PEpG4wYlyvGfSdM5PUoedv96Dey3luSgiLaQpN_QSF8,11285
17
+ nucli-0.2.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.32.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ nu = nu._cli:main
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for describing the origin of the Work and
141
+ reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Support. While redistributing the Work or
166
+ Derivative Works thereof, You may choose to offer, and charge a
167
+ fee for, acceptance of support, warranty, indemnity, or other
168
+ liability obligations and/or rights consistent with this License.
169
+ However, in accepting such obligations, You may act only on Your
170
+ own behalf and on Your sole responsibility, not on behalf of any
171
+ other Contributor, and only if You agree to indemnify, defend,
172
+ and hold each Contributor harmless for any liability incurred by,
173
+ or claims asserted against, such Contributor by reason of your
174
+ accepting any such warranty or support.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2025 Gor Arakelyan
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
200
+ implied. See the License for the specific language governing
201
+ permissions and limitations under the License.