Repository navigation
Expand file tree
/
Copy pathinit_cmd.py
More file actions
104 lines (83 loc) · 3.45 KB
/
Copy pathinit_cmd.py
File metadata and controls
104 lines (83 loc) · 3.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
"""``everos init`` — generate starter config files in the memory root.
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
startproject`` shape.
"""
from __future__ import annotations
from pathlib import Path
import typer
from everos.config.settings import resolve_root
from everos.entrypoints.cli._log_setup import configure_cli_logging
from .server import MCP_GUIDE_URL
_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:
"""Attach the ``init`` command to the root CLI app."""
@parent.command("init")
def init(
root: str | None = typer.Option(
None,
"--root",
help="Memory root directory (default: ~/.everos)",
),
force: bool = typer.Option(
False,
"--force",
help="Overwrite existing files",
),
print_: bool = typer.Option(
False,
"--print",
help="Print the everos.toml template to stdout instead of writing to disk.",
),
verbose: bool = typer.Option(
False,
"--verbose",
"-v",
help="Emit INFO-level lifecycle logs (default: WARNING only).",
),
) -> None:
"""Generate starter configuration files.
Common flows::
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 — files created successfully (or printed to stdout).
- 1 — files already exist and ``--force`` was not given.
"""
configure_cli_logging(verbose=verbose)
if print_:
import sys
sys.stdout.write(_EVEROS_TEMPLATE.read_text(encoding="utf-8"))
return
resolved = resolve_root(root)
resolved.mkdir(parents=True, exist_ok=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)
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}")
typer.echo(
f" 3. Connect an MCP client (Claude Code, Codex, Cursor): {MCP_GUIDE_URL}"
)