xtr-cli 6.1.0__tar.gz → 6.3.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.
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/PKG-INFO +6 -3
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/README.md +5 -2
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/pyproject.toml +1 -1
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/pyproject.toml.orig +1 -1
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/scaffolder.py +7 -0
- xtr_cli-6.3.0/src/xtr_cli/templates/cli/files/AGENTS.md.tmpl +53 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/templates/cli/files/README.md.tmpl +4 -1
- xtr_cli-6.3.0/src/xtr_cli/templates/cli/files/app/config/packages/dotenv.py.tmpl +31 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/templates/cli/files/app/kernel.py.tmpl +6 -2
- xtr_cli-6.3.0/src/xtr_cli/templates/cli/files/bin/console.tmpl +10 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/templates/cli/template.toml +5 -0
- xtr_cli-6.3.0/src/xtr_cli/templates/webapp/files/AGENTS.md.tmpl +57 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/templates/webapp/files/README.md.tmpl +4 -1
- xtr_cli-6.3.0/src/xtr_cli/templates/webapp/files/app/config/__init__.py.tmpl +5 -0
- xtr_cli-6.3.0/src/xtr_cli/templates/webapp/files/app/config/packages/__init__.py.tmpl +5 -0
- xtr_cli-6.3.0/src/xtr_cli/templates/webapp/files/app/config/packages/dotenv.py.tmpl +31 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/templates/webapp/files/app/kernel.py.tmpl +6 -2
- xtr_cli-6.3.0/src/xtr_cli/templates/webapp/files/bin/console.tmpl +10 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/templates/webapp/template.toml +3 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/LICENSE +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/__init__.py +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/__main__.py +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/command/__init__.py +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/command/init_command.py +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/command/new_command.py +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/command/serve_command.py +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/command_support.py +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/exception/__init__.py +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/exception/ambiguous_web_entry_point_error.py +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/exception/cli_error.py +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/exception/directory_not_empty_error.py +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/exception/invalid_project_name_error.py +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/exception/invalid_template_error.py +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/exception/project_not_found_error.py +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/exception/step_failed_error.py +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/exception/unknown_template_error.py +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/exception/unsupported_python_error.py +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/exception/web_entry_point_not_found_error.py +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/process_runner_interface.py +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/project_name.py +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/project_settings.py +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/py.typed +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/scaffold_plan.py +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/subprocess_runner.py +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/template.py +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/template_catalog.py +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/templates/__init__.py +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/templates/cli/files/app/__init__.py.tmpl +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/templates/cli/files/app/__main__.py.tmpl +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/templates/cli/files/app/command/__init__.py.tmpl +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/templates/cli/files/app/command/hello_command.py.tmpl +0 -0
- {xtr_cli-6.1.0/src/xtr_cli/templates/webapp → xtr_cli-6.3.0/src/xtr_cli/templates/cli}/files/app/config/__init__.py.tmpl +0 -0
- {xtr_cli-6.1.0/src/xtr_cli/templates/webapp → xtr_cli-6.3.0/src/xtr_cli/templates/cli}/files/app/config/packages/__init__.py.tmpl +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/templates/cli/files/app/py.typed.tmpl +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/templates/cli/files/gitignore.tmpl +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/templates/cli/files/pyproject.toml.tmpl +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/templates/cli/files/python-version.tmpl +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/templates/cli/files/tests/__init__.py.tmpl +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/templates/cli/files/tests/test_kernel.py.tmpl +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/templates/webapp/files/app/__init__.py.tmpl +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/templates/webapp/files/app/__main__.py.tmpl +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/templates/webapp/files/app/command/__init__.py.tmpl +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/templates/webapp/files/app/command/hello_command.py.tmpl +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/templates/webapp/files/app/config/packages/http_kernel.py.tmpl +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/templates/webapp/files/app/py.typed.tmpl +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/templates/webapp/files/app/web/__init__.py.tmpl +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/templates/webapp/files/app/web/__main__.py.tmpl +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/templates/webapp/files/app/web/app.py.tmpl +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/templates/webapp/files/app/web/routes.py.tmpl +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/templates/webapp/files/gitignore.tmpl +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/templates/webapp/files/pyproject.toml.tmpl +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/templates/webapp/files/python-version.tmpl +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/templates/webapp/files/tests/__init__.py.tmpl +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/templates/webapp/files/tests/test_kernel.py.tmpl +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/templates/webapp/files/tests/test_web.py.tmpl +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/web_entry_point.py +0 -0
- {xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/web_entry_point_finder.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: xtr-cli
|
|
3
|
-
Version: 6.
|
|
3
|
+
Version: 6.3.0
|
|
4
4
|
Summary: Scaffolds a new xtr application — a console application or a web application — in one command, and serves it.
|
|
5
5
|
Keywords: scaffold,new project,template,console,web,xtr-dependency-injection
|
|
6
6
|
Author: Xterr
|
|
@@ -176,8 +176,11 @@ application's shutdown hooks run.
|
|
|
176
176
|
| `webapp` | `xtr new <directory> --webapp` | the same, and `xtr-logging`, `xtr-http-kernel`, `xtr-orm[postgres]`, `xtr-messenger[amqp]`, `xtr-http-client`, `xtr-notifier`, `xtr-security`, `fastapi`, `uvicorn` | `<name>`, `<name>-web` |
|
|
177
177
|
|
|
178
178
|
Both write `pyproject.toml` (with ruff, basedpyright, ty and pytest configured), `.python-version`,
|
|
179
|
-
`.gitignore`, `README.md`, `
|
|
180
|
-
`
|
|
179
|
+
`.gitignore`, `README.md`, `AGENTS.md` (the rules for a coding agent that works in the
|
|
180
|
+
project), `bin/console` (the executable `uv run <name>` wrapper), `src/<app>/kernel.py`,
|
|
181
|
+
`src/<app>/config/packages/dotenv.py` (the one description of the `.env` cascade),
|
|
182
|
+
`src/<app>/__main__.py`, an example `app:hello` command and a test that builds the kernel.
|
|
183
|
+
`webapp` adds `src/<app>/web/` — the
|
|
181
184
|
FastAPI application served with `setup(app, kernel)`, its routes and a uvicorn entry point — a
|
|
182
185
|
kernel built with `concurrent_scoped_access=True` for the security bundle, and a test that
|
|
183
186
|
requests the home page.
|
|
@@ -155,8 +155,11 @@ application's shutdown hooks run.
|
|
|
155
155
|
| `webapp` | `xtr new <directory> --webapp` | the same, and `xtr-logging`, `xtr-http-kernel`, `xtr-orm[postgres]`, `xtr-messenger[amqp]`, `xtr-http-client`, `xtr-notifier`, `xtr-security`, `fastapi`, `uvicorn` | `<name>`, `<name>-web` |
|
|
156
156
|
|
|
157
157
|
Both write `pyproject.toml` (with ruff, basedpyright, ty and pytest configured), `.python-version`,
|
|
158
|
-
`.gitignore`, `README.md`, `
|
|
159
|
-
`
|
|
158
|
+
`.gitignore`, `README.md`, `AGENTS.md` (the rules for a coding agent that works in the
|
|
159
|
+
project), `bin/console` (the executable `uv run <name>` wrapper), `src/<app>/kernel.py`,
|
|
160
|
+
`src/<app>/config/packages/dotenv.py` (the one description of the `.env` cascade),
|
|
161
|
+
`src/<app>/__main__.py`, an example `app:hello` command and a test that builds the kernel.
|
|
162
|
+
`webapp` adds `src/<app>/web/` — the
|
|
160
163
|
FastAPI application served with `setup(app, kernel)`, its routes and a uvicorn entry point — a
|
|
161
164
|
kernel built with `concurrent_scoped_access=True` for the security bundle, and a test that
|
|
162
165
|
requests the home page.
|
|
@@ -103,6 +103,9 @@ class Scaffolder:
|
|
|
103
103
|
def apply(self, plan: ScaffoldPlan, report: Callable[[str], None]) -> None:
|
|
104
104
|
"""Make the project ``plan`` describes, reporting each step as it starts.
|
|
105
105
|
|
|
106
|
+
A file written under ``bin/`` is made executable: git tracks the mode,
|
|
107
|
+
so the scaffolded repository keeps the wrapper runnable.
|
|
108
|
+
|
|
106
109
|
Raises:
|
|
107
110
|
DirectoryNotEmptyError: When the directory filled up since it was
|
|
108
111
|
checked.
|
|
@@ -115,6 +118,10 @@ class Scaffolder:
|
|
|
115
118
|
target = plan.directory.joinpath(*path.split("/"))
|
|
116
119
|
target.parent.mkdir(parents=True, exist_ok=True)
|
|
117
120
|
_ = target.write_text(text, encoding="utf-8")
|
|
121
|
+
if path.startswith("bin/"):
|
|
122
|
+
# git tracks the mode, so the mode is part of what the scaffold
|
|
123
|
+
# writes: a wrapper under bin/ is an executable by convention.
|
|
124
|
+
target.chmod(0o755)
|
|
118
125
|
for argv in plan.commands:
|
|
119
126
|
report(f"run {shlex.join(argv)}")
|
|
120
127
|
code = self._runner.run(argv, plan.directory)
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# AGENTS.md — rules for a coding agent working in ${name}
|
|
2
|
+
|
|
3
|
+
A console application on the xtr packages. The kernel every entry point builds lives in
|
|
4
|
+
`src/${app}/kernel.py`, and the console commands live in `src/${app}/command/`. The xtr
|
|
5
|
+
packages teach themselves through agent skills; read *Skills first* before writing code.
|
|
6
|
+
|
|
7
|
+
## Skills first
|
|
8
|
+
|
|
9
|
+
Every xtr package installed here ships an agent skill, at its own version. Register them
|
|
10
|
+
all, and rerun the command after adding a package:
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
uvx library-skills --all
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Load the skill of a package before writing code that uses it. `uvx library-skills list`
|
|
17
|
+
shows what is registered, and `uvx library-skills --check` reports drift between the
|
|
18
|
+
installed packages and their registered skills, so it can run in CI.
|
|
19
|
+
|
|
20
|
+
## Commands
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
bin/console <command> # the console; `uv run ${name} <command>` is the same
|
|
24
|
+
uv run pytest
|
|
25
|
+
uv run ruff check && uv run ruff format --check
|
|
26
|
+
uv run basedpyright && uv run ty check
|
|
27
|
+
uv run xtr-recipes recipes:sync --check
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Add a package
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
uv run xtr-recipes recipes:add <package>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
It installs the package and applies its recipe — the bundle entry in
|
|
37
|
+
`src/${app}/config/bundles.py`, the configuration module under `src/${app}/config/packages/`,
|
|
38
|
+
the environment block, the ignore lines — and prints the steps it cannot do; do those by
|
|
39
|
+
hand. Then register the package's skill with `uvx library-skills --all`. Removing a package
|
|
40
|
+
is the same read backwards: `uv run xtr-recipes recipes:remove <package>`.
|
|
41
|
+
|
|
42
|
+
## Do not
|
|
43
|
+
|
|
44
|
+
- Do not hand-edit `src/${app}/config/bundles.py` into a shape the recipes tool cannot
|
|
45
|
+
read: `BUNDLES` stays a literal mapping of imported bundle classes to literal flag
|
|
46
|
+
mappings.
|
|
47
|
+
- Do not edit inside the `###> xtr-<name> ###` … `###< xtr-<name> ###` blocks in `.env`
|
|
48
|
+
and `.gitignore` — the recipes tool writes those; the lines outside them are the
|
|
49
|
+
project's own.
|
|
50
|
+
- Keep machine secrets in `.env.local`, never in a committed layer.
|
|
51
|
+
- Commit `xtr.lock`.
|
|
52
|
+
- Do not add an xtr package as an extra of another: install it beside, with
|
|
53
|
+
`uv run xtr-recipes recipes:add`.
|
|
@@ -7,6 +7,7 @@ A console application on the xtr packages.
|
|
|
7
7
|
```sh
|
|
8
8
|
uv run ${name} # every command
|
|
9
9
|
uv run ${name} app:hello Ada # the example command
|
|
10
|
+
bin/console app:hello Ada # the same command through the bin/console wrapper
|
|
10
11
|
uv run ${name} debug:bundles # the bundles and whether each is active
|
|
11
12
|
```
|
|
12
13
|
|
|
@@ -17,12 +18,14 @@ The environment is read from `.env`, then `.env.local`, then `.env.<APP_ENV>` an
|
|
|
17
18
|
## Layout
|
|
18
19
|
|
|
19
20
|
```
|
|
21
|
+
AGENTS.md the rules for a coding agent that works in this project
|
|
22
|
+
bin/console the console wrapper — `uv run ${name}` from anywhere
|
|
20
23
|
src/${app}/
|
|
21
24
|
├── __main__.py the console entry point
|
|
22
25
|
├── kernel.py the kernel every entry point builds, and the environment loader
|
|
23
26
|
├── config/
|
|
24
27
|
│ ├── bundles.py the active bundles — written by xtr-recipes
|
|
25
|
-
│ └── packages/ one @configure module per bundle
|
|
28
|
+
│ └── packages/ one @configure module per bundle — dotenv.py describes the .env cascade
|
|
26
29
|
└── command/ the console commands
|
|
27
30
|
```
|
|
28
31
|
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"""One description of the dotenv cascade: entry points and commands both read it.
|
|
2
|
+
|
|
3
|
+
``DOTENV`` is the single source of truth. ``kernel.py`` boots the environment from it
|
|
4
|
+
before the kernel builds, and ``dotenv:dump`` and ``debug:dotenv`` read the same object
|
|
5
|
+
from the container. Change the cascade here, and nowhere else.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from typing import Final
|
|
11
|
+
|
|
12
|
+
from xtr_dependency_injection import configure
|
|
13
|
+
from xtr_dotenv.bundle import DotenvConfig
|
|
14
|
+
|
|
15
|
+
__all__ = ["DOTENV", "dotenv"]
|
|
16
|
+
|
|
17
|
+
DOTENV: Final = DotenvConfig(
|
|
18
|
+
path="%kernel.project_dir%/.env",
|
|
19
|
+
env_key="APP_ENV",
|
|
20
|
+
debug_key="APP_DEBUG",
|
|
21
|
+
default_env="dev",
|
|
22
|
+
test_envs=("test",),
|
|
23
|
+
prod_envs=("prod",),
|
|
24
|
+
debug_envs=("dev", "local", "test"),
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@configure
|
|
29
|
+
def dotenv() -> DotenvConfig:
|
|
30
|
+
"""Hand the container the one cascade description."""
|
|
31
|
+
return DOTENV
|
|
@@ -10,7 +10,8 @@ from pathlib import Path
|
|
|
10
10
|
from typing import Final
|
|
11
11
|
|
|
12
12
|
from xtr_dependency_injection import Kernel, exclude
|
|
13
|
-
|
|
13
|
+
|
|
14
|
+
from ${app}.config.packages.dotenv import DOTENV
|
|
14
15
|
|
|
15
16
|
__all__ = ["PROJECT_DIR", "kernel", "load_environment"]
|
|
16
17
|
|
|
@@ -30,7 +31,10 @@ kernel: Final = Kernel(
|
|
|
30
31
|
def load_environment() -> None:
|
|
31
32
|
"""Load the layered ``.env`` files into the environment, before the kernel is built.
|
|
32
33
|
|
|
34
|
+
``DOTENV`` in ``config/packages/dotenv.py`` is the one description of the cascade — the
|
|
35
|
+
same object the dotenv commands read from the container.
|
|
36
|
+
|
|
33
37
|
``@exclude`` keeps this helper out of the container: it is an entry point's concern,
|
|
34
38
|
never a service.
|
|
35
39
|
"""
|
|
36
|
-
_ =
|
|
40
|
+
_ = DOTENV.boot(PROJECT_DIR)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/env sh
|
|
2
|
+
# The console entry point: `bin/console <command>`, the same as `uv run ${name} <command>`.
|
|
3
|
+
#
|
|
4
|
+
# uv keeps the environment — this runs from the lock and syncs what is missing — so the
|
|
5
|
+
# console works from a fresh clone, before any `uv sync`. On Windows, which has no sh,
|
|
6
|
+
# run `uv run ${name}` instead.
|
|
7
|
+
set -eu
|
|
8
|
+
root=$$(CDPATH= cd -- "$$(dirname -- "$$0")/.." && pwd -P)
|
|
9
|
+
cd -- "$$root"
|
|
10
|
+
exec uv run ${name} "$$@"
|
|
@@ -16,12 +16,17 @@ dev = ["xtr-recipes", "pytest", "ruff", "basedpyright", "ty"]
|
|
|
16
16
|
".python-version" = "files/python-version.tmpl"
|
|
17
17
|
".gitignore" = "files/gitignore.tmpl"
|
|
18
18
|
"README.md" = "files/README.md.tmpl"
|
|
19
|
+
"AGENTS.md" = "files/AGENTS.md.tmpl"
|
|
20
|
+
"bin/console" = "files/bin/console.tmpl"
|
|
19
21
|
"src/${app}/__init__.py" = "files/app/__init__.py.tmpl"
|
|
20
22
|
"src/${app}/__main__.py" = "files/app/__main__.py.tmpl"
|
|
21
23
|
"src/${app}/kernel.py" = "files/app/kernel.py.tmpl"
|
|
22
24
|
"src/${app}/py.typed" = "files/app/py.typed.tmpl"
|
|
23
25
|
"src/${app}/command/__init__.py" = "files/app/command/__init__.py.tmpl"
|
|
24
26
|
"src/${app}/command/hello_command.py" = "files/app/command/hello_command.py.tmpl"
|
|
27
|
+
"src/${app}/config/__init__.py" = "files/app/config/__init__.py.tmpl"
|
|
28
|
+
"src/${app}/config/packages/__init__.py" = "files/app/config/packages/__init__.py.tmpl"
|
|
29
|
+
"src/${app}/config/packages/dotenv.py" = "files/app/config/packages/dotenv.py.tmpl"
|
|
25
30
|
"tests/__init__.py" = "files/tests/__init__.py.tmpl"
|
|
26
31
|
"tests/test_kernel.py" = "files/tests/test_kernel.py.tmpl"
|
|
27
32
|
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# AGENTS.md — rules for a coding agent working in ${name}
|
|
2
|
+
|
|
3
|
+
A web application: FastAPI served from the kernel, with the console, a database, a message
|
|
4
|
+
bus and security. The kernel every entry point builds lives in `src/${app}/kernel.py`; the
|
|
5
|
+
console commands live in `src/${app}/command/`, the web entry point in `src/${app}/web/`,
|
|
6
|
+
its routes in `src/${app}/web/routes.py`, and its configuration modules in
|
|
7
|
+
`src/${app}/config/packages/` — one `@configure` module per bundle. The xtr packages teach
|
|
8
|
+
themselves through agent skills; read *Skills first* before writing code.
|
|
9
|
+
|
|
10
|
+
## Skills first
|
|
11
|
+
|
|
12
|
+
Every xtr package installed here ships an agent skill, at its own version. Register them
|
|
13
|
+
all, and rerun the command after adding a package:
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
uvx library-skills --all
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Load the skill of a package before writing code that uses it. `uvx library-skills list`
|
|
20
|
+
shows what is registered, and `uvx library-skills --check` reports drift between the
|
|
21
|
+
installed packages and their registered skills, so it can run in CI.
|
|
22
|
+
|
|
23
|
+
## Commands
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
uv run ${name}-web # the web server, on WEB_HOST:WEB_PORT
|
|
27
|
+
bin/console <command> # the console; `uv run ${name} <command>` is the same
|
|
28
|
+
uv run pytest
|
|
29
|
+
uv run ruff check && uv run ruff format --check
|
|
30
|
+
uv run basedpyright && uv run ty check
|
|
31
|
+
uv run xtr-recipes recipes:sync --check
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Add a package
|
|
35
|
+
|
|
36
|
+
```sh
|
|
37
|
+
uv run xtr-recipes recipes:add <package>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
It installs the package and applies its recipe — the bundle entry in
|
|
41
|
+
`src/${app}/config/bundles.py`, the configuration module under `src/${app}/config/packages/`,
|
|
42
|
+
the environment block, the ignore lines — and prints the steps it cannot do; do those by
|
|
43
|
+
hand. Then register the package's skill with `uvx library-skills --all`. Removing a package
|
|
44
|
+
is the same read backwards: `uv run xtr-recipes recipes:remove <package>`.
|
|
45
|
+
|
|
46
|
+
## Do not
|
|
47
|
+
|
|
48
|
+
- Do not hand-edit `src/${app}/config/bundles.py` into a shape the recipes tool cannot
|
|
49
|
+
read: `BUNDLES` stays a literal mapping of imported bundle classes to literal flag
|
|
50
|
+
mappings.
|
|
51
|
+
- Do not edit inside the `###> xtr-<name> ###` … `###< xtr-<name> ###` blocks in `.env`,
|
|
52
|
+
`.gitignore` and `compose.yaml` — the recipes tool writes those; the lines outside them
|
|
53
|
+
are the project's own.
|
|
54
|
+
- Keep machine secrets in `.env.local`, never in a committed layer.
|
|
55
|
+
- Commit `xtr.lock`.
|
|
56
|
+
- Do not add an xtr package as an extra of another: install it beside, with
|
|
57
|
+
`uv run xtr-recipes recipes:add`.
|
|
@@ -9,6 +9,7 @@ a database, a message bus, an HTTP client, notifications and security configured
|
|
|
9
9
|
docker compose up -d database # the PostgreSQL DATABASE_URL points at
|
|
10
10
|
uv run ${name}-web # serve on WEB_HOST:WEB_PORT, 127.0.0.1:8000 by default
|
|
11
11
|
uv run ${name} # every console command
|
|
12
|
+
bin/console app:hello # the console script ${name} through the bin/console wrapper
|
|
12
13
|
uv run ${name} debug:router # the routes
|
|
13
14
|
uv run ${name} debug:bundles # the bundles and whether each is active
|
|
14
15
|
```
|
|
@@ -22,12 +23,14 @@ machine. Nothing connects to either until it is used.
|
|
|
22
23
|
## Layout
|
|
23
24
|
|
|
24
25
|
```
|
|
26
|
+
AGENTS.md the rules for a coding agent that works in this project
|
|
27
|
+
bin/console the console wrapper — `uv run ${name}` from anywhere
|
|
25
28
|
src/${app}/
|
|
26
29
|
├── __main__.py the console entry point
|
|
27
30
|
├── kernel.py the kernel every entry point builds, and the environment loader
|
|
28
31
|
├── config/
|
|
29
32
|
│ ├── bundles.py the active bundles — written by xtr-recipes
|
|
30
|
-
│ └── packages/ one @configure module per bundle
|
|
33
|
+
│ └── packages/ one @configure module per bundle — dotenv.py describes the .env cascade
|
|
31
34
|
├── command/ the console commands
|
|
32
35
|
└── web/
|
|
33
36
|
├── __main__.py the web entry point
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"""One description of the dotenv cascade: entry points and commands both read it.
|
|
2
|
+
|
|
3
|
+
``DOTENV`` is the single source of truth. ``kernel.py`` boots the environment from it
|
|
4
|
+
before the kernel builds, and ``dotenv:dump`` and ``debug:dotenv`` read the same object
|
|
5
|
+
from the container. Change the cascade here, and nowhere else.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from typing import Final
|
|
11
|
+
|
|
12
|
+
from xtr_dependency_injection import configure
|
|
13
|
+
from xtr_dotenv.bundle import DotenvConfig
|
|
14
|
+
|
|
15
|
+
__all__ = ["DOTENV", "dotenv"]
|
|
16
|
+
|
|
17
|
+
DOTENV: Final = DotenvConfig(
|
|
18
|
+
path="%kernel.project_dir%/.env",
|
|
19
|
+
env_key="APP_ENV",
|
|
20
|
+
debug_key="APP_DEBUG",
|
|
21
|
+
default_env="dev",
|
|
22
|
+
test_envs=("test",),
|
|
23
|
+
prod_envs=("prod",),
|
|
24
|
+
debug_envs=("dev", "local", "test"),
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@configure
|
|
29
|
+
def dotenv() -> DotenvConfig:
|
|
30
|
+
"""Hand the container the one cascade description."""
|
|
31
|
+
return DOTENV
|
|
@@ -10,7 +10,8 @@ from pathlib import Path
|
|
|
10
10
|
from typing import Final
|
|
11
11
|
|
|
12
12
|
from xtr_dependency_injection import Kernel, exclude
|
|
13
|
-
|
|
13
|
+
|
|
14
|
+
from ${app}.config.packages.dotenv import DOTENV
|
|
14
15
|
|
|
15
16
|
__all__ = ["PROJECT_DIR", "kernel", "load_environment"]
|
|
16
17
|
|
|
@@ -37,7 +38,10 @@ kernel: Final = Kernel(
|
|
|
37
38
|
def load_environment() -> None:
|
|
38
39
|
"""Load the layered ``.env`` files into the environment, before the kernel is built.
|
|
39
40
|
|
|
41
|
+
``DOTENV`` in ``config/packages/dotenv.py`` is the one description of the cascade — the
|
|
42
|
+
same object the dotenv commands read from the container.
|
|
43
|
+
|
|
40
44
|
``@exclude`` keeps this helper out of the container: it is an entry point's concern,
|
|
41
45
|
never a service.
|
|
42
46
|
"""
|
|
43
|
-
_ =
|
|
47
|
+
_ = DOTENV.boot(PROJECT_DIR)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/env sh
|
|
2
|
+
# The console entry point: `bin/console <command>`, the same as `uv run ${name} <command>`.
|
|
3
|
+
#
|
|
4
|
+
# uv keeps the environment — this runs from the lock and syncs what is missing — so the
|
|
5
|
+
# console works from a fresh clone, before any `uv sync`. On Windows, which has no sh,
|
|
6
|
+
# run `uv run ${name}` instead.
|
|
7
|
+
set -eu
|
|
8
|
+
root=$$(CDPATH= cd -- "$$(dirname -- "$$0")/.." && pwd -P)
|
|
9
|
+
cd -- "$$root"
|
|
10
|
+
exec uv run ${name} "$$@"
|
|
@@ -30,6 +30,8 @@ dev = ["xtr-recipes", "pytest", "httpx", "ruff", "basedpyright", "ty"]
|
|
|
30
30
|
".python-version" = "files/python-version.tmpl"
|
|
31
31
|
".gitignore" = "files/gitignore.tmpl"
|
|
32
32
|
"README.md" = "files/README.md.tmpl"
|
|
33
|
+
"AGENTS.md" = "files/AGENTS.md.tmpl"
|
|
34
|
+
"bin/console" = "files/bin/console.tmpl"
|
|
33
35
|
"src/${app}/__init__.py" = "files/app/__init__.py.tmpl"
|
|
34
36
|
"src/${app}/__main__.py" = "files/app/__main__.py.tmpl"
|
|
35
37
|
"src/${app}/kernel.py" = "files/app/kernel.py.tmpl"
|
|
@@ -38,6 +40,7 @@ dev = ["xtr-recipes", "pytest", "httpx", "ruff", "basedpyright", "ty"]
|
|
|
38
40
|
"src/${app}/command/hello_command.py" = "files/app/command/hello_command.py.tmpl"
|
|
39
41
|
"src/${app}/config/__init__.py" = "files/app/config/__init__.py.tmpl"
|
|
40
42
|
"src/${app}/config/packages/__init__.py" = "files/app/config/packages/__init__.py.tmpl"
|
|
43
|
+
"src/${app}/config/packages/dotenv.py" = "files/app/config/packages/dotenv.py.tmpl"
|
|
41
44
|
"src/${app}/config/packages/http_kernel.py" = "files/app/config/packages/http_kernel.py.tmpl"
|
|
42
45
|
"src/${app}/web/__init__.py" = "files/app/web/__init__.py.tmpl"
|
|
43
46
|
"src/${app}/web/__main__.py" = "files/app/web/__main__.py.tmpl"
|
|
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
|
{xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/templates/cli/files/app/command/__init__.py.tmpl
RENAMED
|
File without changes
|
{xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/templates/cli/files/app/command/hello_command.py.tmpl
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
|
{xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/templates/webapp/files/app/command/__init__.py.tmpl
RENAMED
|
File without changes
|
{xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/templates/webapp/files/app/command/hello_command.py.tmpl
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
|
{xtr_cli-6.1.0 → xtr_cli-6.3.0}/src/xtr_cli/templates/webapp/files/tests/test_kernel.py.tmpl
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|