forked from HKUDS/DeepCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig_errors.py
More file actions
30 lines (23 loc) · 1.2 KB
/
Copy pathconfig_errors.py
File metadata and controls
30 lines (23 loc) · 1.2 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
"""Turn a :class:`core.config.ConfigError` into a clean, actionable CLI message.
Shared by every entrypoint that builds an agent (TUI, headless exec, ...) so a
misconfiguration prints one friendly block — never a Python traceback — and,
when DeepCode has no config at all, points the user at ``deepcode init``.
"""
from __future__ import annotations
from core.config import ConfigError, default_config_path, home_config_path
def is_unconfigured() -> bool:
"""True when neither config layer exists on disk (a first-run situation)."""
return not home_config_path().exists() and not default_config_path().exists()
def format_config_error(exc: ConfigError) -> str:
lines = [f"Configuration error: {exc}"]
if is_unconfigured():
lines += [
"",
"DeepCode is not configured yet — no deepcode_config.json was found at",
f" {home_config_path()} (user base)",
" or in the current directory / its parents (project).",
"",
"Run deepcode init to create the user base, then add a provider key",
'under "providers" in that file. After that, deepcode works in any directory.',
]
return "\n".join(lines)