chore(release): update EverOS to 1.1.0 (#307)

This commit is contained in:
Elliot Chen
2026-06-24 23:17:23 +08:00
committed by GitHub
parent 1ea44ca548
commit 0df88f5603
262 changed files with 20901 additions and 2595 deletions
@@ -21,6 +21,7 @@ scanner background task is started.
from __future__ import annotations
import asyncio
import os
from contextlib import asynccontextmanager
from pathlib import Path
from typing import Annotated
@@ -53,6 +54,19 @@ app = typer.Typer(
)
@app.callback()
def _cascade_callback(
root: str | None = typer.Option(
None,
"--root",
help="Memory root directory (env: EVEROS_ROOT, default: ~/.everos)",
),
) -> None:
"""Set memory root before any cascade subcommand runs."""
if root:
os.environ["EVEROS_ROOT"] = root
# ── shared runtime context ───────────────────────────────────────────────
@@ -0,0 +1,85 @@
"""``everos config show`` — display effective configuration."""
from __future__ import annotations
import os
import typer
from everos.config.settings import resolve_root
app = typer.Typer(
name="config",
help="Configuration management",
no_args_is_help=True,
)
_SECRET_FIELDS = {"api_key"}
_SECTION_NAMES = (
"memory",
"api",
"sqlite",
"lancedb",
"llm",
"multimodal",
"embedding",
"rerank",
"boundary_detection",
"memorize",
"clustering",
"search",
"knowledge",
)
def _mask(value: str) -> str:
"""Mask a secret value, keeping first/last 4 chars if long enough."""
if len(value) <= 8:
return "****"
return value[:4] + "****" + value[-4:]
@app.command("show")
def show(
root: str | None = typer.Option(
None,
"--root",
help="Memory root directory",
),
) -> None:
"""Print the effective configuration."""
if root:
os.environ["EVEROS_ROOT"] = root
resolved = resolve_root(root)
typer.echo(f"Root: {resolved}")
typer.echo()
everos_toml = resolved / "everos.toml"
if everos_toml.is_file():
typer.echo(f"Config: {everos_toml}")
else:
typer.echo("Config: (no everos.toml found, using defaults)")
ome_toml = resolved / "ome.toml"
if ome_toml.is_file():
typer.echo(f"Strategy: {ome_toml}")
typer.echo()
from everos.config import load_settings
load_settings.cache_clear()
settings = load_settings()
for section_name in _SECTION_NAMES:
section = getattr(settings, section_name, None)
if section is None:
continue
typer.secho(f"[{section_name}]", bold=True)
for field_name, value in section.model_dump().items():
display = str(value)
if field_name in _SECRET_FIELDS and value:
display = _mask(str(value))
typer.echo(f" {field_name} = {display}")
typer.echo()
+46 -140
View File
@@ -1,10 +1,9 @@
"""``everos init`` — generate a starter ``.env`` from the packaged template.
"""``everos init`` — generate starter config files in the memory root.
The ``env.template`` ships inside the wheel as package data at
``everos/templates/env.template``. ``init`` reads it via
:mod:`importlib.resources`, so the command works identically for pip-
installed users and source-tree users (the file is the single source
of truth).
Copies the shipped ``default.toml`` and ``default_ome.toml`` templates
into the resolved memory root as ``everos.toml`` and ``ome.toml``
respectively. Users then edit these files to fill in API keys and tune
strategy schedules.
Subcommand mounted as ``everos init`` (top-level leaf command — not a
Typer group), to match the idiomatic ``alembic init`` / ``django-admin
@@ -13,74 +12,14 @@ startproject`` shape.
from __future__ import annotations
import contextlib
import logging
import os
import sys
import tempfile
from importlib import resources
from pathlib import Path
import typer
_TEMPLATE_PACKAGE = "everos.templates"
_TEMPLATE_NAME = "env.template"
from everos.config.settings import resolve_root
_log = logging.getLogger("everos.cli.init")
def _read_template() -> str:
"""Read the packaged ``env.template`` from wheel resources.
Returns the file contents as a UTF-8 string. Raises ``RuntimeError``
on missing-file — if this fires it means the wheel was built from a
source tree where ``src/everos/templates/env.template`` was missing
(canonical location; auto-included via ``packages=["src/everos"]``
in ``pyproject.toml``).
"""
try:
return (
resources.files(_TEMPLATE_PACKAGE)
.joinpath(_TEMPLATE_NAME)
.read_text(encoding="utf-8")
)
except (FileNotFoundError, ModuleNotFoundError) as exc:
raise RuntimeError(
f"packaged template {_TEMPLATE_NAME!r} not found under "
f"{_TEMPLATE_PACKAGE!r}; the wheel is missing its "
"force-include entry (see pyproject.toml "
"[tool.hatch.build.targets.wheel.force-include])."
) from exc
def _xdg_default_path() -> Path:
"""``$XDG_CONFIG_HOME/everos/.env`` (default ``~/.config/everos/.env``)."""
xdg = os.environ.get("XDG_CONFIG_HOME") or "~/.config"
return Path(xdg).expanduser() / "everos" / ".env"
def _atomic_write(target: Path, content: str, mode: int = 0o600) -> None:
"""Write ``content`` to ``target`` atomically with ``mode`` permission.
Writes to a tempfile in the same directory then ``os.replace``s it
onto the target — guarantees either the full new file is visible or
the original (if any) is untouched. Permission bits applied before
the rename so the file is never readable by other users.
"""
target.parent.mkdir(parents=True, exist_ok=True)
fd, tmp_path = tempfile.mkstemp(
prefix=target.name + ".",
dir=target.parent,
)
try:
with os.fdopen(fd, "w", encoding="utf-8") as f:
f.write(content)
os.chmod(tmp_path, mode)
os.replace(tmp_path, target)
except Exception:
with contextlib.suppress(OSError):
os.unlink(tmp_path)
raise
_EVEROS_TEMPLATE = Path(__file__).resolve().parents[3] / "config" / "default.toml"
_OME_TEMPLATE = Path(__file__).resolve().parents[3] / "config" / "default_ome.toml"
def register(parent: typer.Typer) -> None:
@@ -88,98 +27,65 @@ def register(parent: typer.Typer) -> None:
@parent.command("init")
def init(
to: str | None = typer.Option(
root: str | None = typer.Option(
None,
"--to",
help=(
"Target path for the .env file (default: ./.env). "
"Parent directories are created if needed."
),
"--root",
help="Memory root directory (default: ~/.everos)",
),
force: bool = typer.Option(
False,
"--force",
help="Overwrite an existing file at the target path.",
help="Overwrite existing files",
),
print_: bool = typer.Option(
False,
"--print",
help="Print the template to stdout instead of writing to disk.",
),
xdg: bool = typer.Option(
False,
"--xdg",
help=(
"Shortcut for --to=${XDG_CONFIG_HOME:-~/.config}/everos/.env "
"(mutually exclusive with --to)."
),
help="Print the everos.toml template to stdout instead of writing to disk.",
),
) -> None:
"""Generate a starter ``.env`` from the packaged template.
"""Generate starter configuration files.
Common flows::
everos init # writes ./.env
everos init --xdg # writes ~/.config/everos/.env
everos init --to /etc/foo.env --force
everos init --print > custom.env
everos init # writes to ~/.everos/
everos init --root /data/everos # writes to /data/everos/
everos init --force # overwrites existing files
everos init --print # prints everos.toml to stdout
Exit codes:
- 0 — written successfully (or printed to stdout).
- 1 — target file already exists and ``--force`` was not given.
- 2 — packaged template missing (wheel build problem).
- 3 — write failed (permissions / disk full / parent unwritable).
- 0 — files created successfully (or printed to stdout).
- 1 — files already exist and ``--force`` was not given.
"""
if xdg and to is not None:
typer.secho(
"error: --xdg and --to are mutually exclusive",
fg=typer.colors.RED,
err=True,
)
raise typer.Exit(code=2)
try:
template = _read_template()
except RuntimeError as exc:
typer.secho(f"error: {exc}", fg=typer.colors.RED, err=True)
raise typer.Exit(code=2) from exc
if print_:
sys.stdout.write(template)
import sys
sys.stdout.write(_EVEROS_TEMPLATE.read_text(encoding="utf-8"))
return
if xdg:
target = _xdg_default_path()
elif to is not None:
target = Path(to).expanduser().resolve()
else:
target = Path.cwd() / ".env"
resolved = resolve_root(root)
resolved.mkdir(parents=True, exist_ok=True)
if target.exists() and not force:
typer.secho(
f"error: {target} already exists; pass --force to overwrite",
fg=typer.colors.RED,
err=True,
)
everos_toml = resolved / "everos.toml"
ome_toml = resolved / "ome.toml"
created: list[Path] = []
for target, template in [
(everos_toml, _EVEROS_TEMPLATE),
(ome_toml, _OME_TEMPLATE),
]:
if target.exists() and not force:
typer.echo(f" exists: {target} (skipped)")
continue
target.write_bytes(template.read_bytes())
created.append(target)
typer.secho(f" created: {target}", fg=typer.colors.GREEN)
if not created:
typer.echo("Nothing to create (use --force to overwrite).")
raise typer.Exit(code=1)
try:
_atomic_write(target, template)
except OSError as exc:
typer.secho(
f"error: failed to write {target}: {exc}",
fg=typer.colors.RED,
err=True,
)
raise typer.Exit(code=3) from exc
# Friendly next-step block (stdout — quiet enough for piping).
size_kb = target.stat().st_size / 1024
typer.secho(f"✓ wrote {target} ({size_kb:.1f} KB)", fg=typer.colors.GREEN)
typer.echo("Next steps:")
typer.echo(" 1. Edit the file and fill in the API keys (see comments inside).")
typer.echo(" 2. Run `everos server start`.")
typer.echo(
"Docs: https://github.com/EverMind-AI/EverOS/blob/main/QUICKSTART.md"
)
typer.echo("\nNext steps:")
typer.echo(f" 1. Edit {everos_toml} — fill in API keys (see comments inside)")
root_flag = f" --root {resolved}" if root else ""
typer.echo(f" 2. Run: everos server start{root_flag}")
+18 -75
View File
@@ -11,11 +11,12 @@ from __future__ import annotations
import logging
import os
import sys
from pathlib import Path
import typer
import uvicorn
from everos.config.settings import resolve_root
app = typer.Typer(
name="server",
help="Run / manage the HTTP API server",
@@ -23,58 +24,6 @@ app = typer.Typer(
)
def _resolve_env_file(explicit: str | None) -> Path | None:
"""Find the first existing ``.env`` along the four-layer search path.
Search order (highest-wins):
1. ``explicit`` — when the caller passed ``--env-file <path>``.
2. ``./.env`` — the current working directory (project-local convention).
3. ``${XDG_CONFIG_HOME:-~/.config}/everos/.env`` — XDG-standard user config.
4. ``~/.everos/.env`` — the project's default memory-root location.
Returns ``None`` if none of the layers exist (caller may then fall back
to inherited process env / CI secrets).
"""
candidates: list[Path] = []
if explicit:
candidates.append(Path(explicit).expanduser())
candidates.append(Path.cwd() / ".env")
xdg = os.environ.get("XDG_CONFIG_HOME") or "~/.config"
candidates.append(Path(xdg).expanduser() / "everos" / ".env")
candidates.append(Path("~/.everos/.env").expanduser())
for p in candidates:
try:
if p.is_file():
return p
except OSError:
# Path traversal / permission denied on a fallback candidate
# must not crash the search — skip and keep going.
continue
return None
def _load_env_file(path: str | None) -> Path | None:
"""Load environment variables from the resolved ``.env`` file.
Returns the path that was loaded, or ``None`` when no ``.env`` was
found anywhere along the search path. Existence of a ``.env`` is
optional — the user may rely entirely on inherited process env
(e.g. container / CI secret injection).
"""
resolved = _resolve_env_file(path)
if resolved is None:
return None
try:
from dotenv import load_dotenv
load_dotenv(resolved, override=False)
except ImportError:
# python-dotenv is in our deps; tolerate its absence anyway.
pass
return resolved
@app.command("start")
def start(
host: str | None = typer.Option(
@@ -87,14 +36,10 @@ def start(
"--port",
help="Bind port (env: EVEROS_API__PORT, default: 8000)",
),
env_file: str | None = typer.Option(
root: str | None = typer.Option(
None,
"--env-file",
help=(
"Path to a dotenv file (highest priority). When omitted, "
"the server searches: ./.env → ${XDG_CONFIG_HOME:-~/.config}"
"/everos/.env → ~/.everos/.env. Run `everos init` to create one."
),
"--root",
help="Memory root directory (env: EVEROS_ROOT, default: ~/.everos)",
),
reload: bool = typer.Option(
False,
@@ -108,10 +53,20 @@ def start(
),
) -> None:
"""Start the HTTP API server."""
loaded_env = _load_env_file(env_file)
if root:
os.environ["EVEROS_ROOT"] = root
resolved_root = resolve_root(root)
everos_toml = resolved_root / "everos.toml"
if not everos_toml.is_file():
typer.secho(
f"Error: {everos_toml} not found.\n"
f"Run `everos init` first to create configuration files.",
fg=typer.colors.RED,
err=True,
)
raise typer.Exit(code=1)
# Load settings AFTER .env is in place so EVEROS_API__HOST and
# EVEROS_API__PORT (and any other env override) are honored.
from everos.config import load_settings
settings = load_settings()
@@ -125,13 +80,6 @@ def start(
configure_logging(level=log_level_resolved)
bootstrap_logger = logging.getLogger("everos.cli.server")
if loaded_env is not None:
bootstrap_logger.info("loaded env file: %s", loaded_env)
else:
bootstrap_logger.info(
"no .env found along the search path; relying on inherited env vars "
"(run `everos init` to generate one)"
)
bootstrap_logger.info("starting everos on %s:%d", host_resolved, port_resolved)
if host_resolved == "0.0.0.0":
bootstrap_logger.warning(
@@ -147,11 +95,6 @@ def start(
reload=reload,
factory=True,
log_level=log_level_resolved.lower(),
# ``configure_logging()`` above already installed the root
# handler + structlog ProcessorFormatter. ``log_config=None``
# stops uvicorn from running its own ``dictConfig`` over
# ours; otherwise uvicorn / fastapi messages revert to the
# ``INFO:`` no-structlog format on every restart.
log_config=None,
)
except KeyboardInterrupt:
+2 -1
View File
@@ -13,7 +13,7 @@ from __future__ import annotations
import typer
from .commands import cascade, demo, init_cmd, server
from .commands import cascade, config_cmd, demo, init_cmd, server
app = typer.Typer(
name="everos",
@@ -24,6 +24,7 @@ app = typer.Typer(
app.add_typer(server.app, name="server")
app.add_typer(cascade.app, name="cascade")
app.add_typer(config_cmd.app, name="config")
# ``init`` is a top-level leaf command (not a Typer group) — match the
# idiomatic ``alembic init`` / ``django-admin startproject`` shape.