Skip to content

Commit c1c87fd

Browse files
committed
Robust CLI
1 parent 1ac9acf commit c1c87fd

3 files changed

Lines changed: 31 additions & 8 deletions

File tree

aideator/__main__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from aideator.cli import main
2+
3+
if __name__ == "__main__":
4+
main()

aideator/cli.py

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,37 @@
1212

1313
import uvicorn
1414

15-
from aideator.paths import (
15+
# Ensure the project root is in sys.path for module imports (api, db, engine, etc.)
16+
_ROOT = str(Path(__file__).resolve().parents[1])
17+
if _ROOT not in sys.path:
18+
sys.path.insert(0, _ROOT)
19+
20+
# Critical check: verify if 'api' is accessible
21+
try:
22+
import api
23+
# If api has no __path__, it's a module, not a package
24+
if not hasattr(api, "__path__"):
25+
# This is the conflict!
26+
if (Path.cwd() / "api").exists():
27+
sys.path.insert(0, str(Path.cwd()))
28+
import importlib
29+
importlib.reload(api)
30+
except ImportError:
31+
if (Path.cwd() / "api").exists():
32+
sys.path.insert(0, str(Path.cwd()))
33+
34+
from aideator.paths import ( # noqa: E402
1635
ensure_dir,
1736
get_all_paths,
1837
get_default_config_path,
1938
resolve_path,
2039
)
21-
from aideator.rebuild_docs import rebuild_docs
22-
from aideator.search.registry import get_search_provider
23-
from api.config import load_settings, settings
24-
from db.ideas import Idea, save_idea
25-
from db.runs import Run, save_run
26-
from engine.orchestrator import execute_run
40+
from aideator.rebuild_docs import rebuild_docs # noqa: E402
41+
from aideator.search.registry import get_search_provider # noqa: E402
42+
from api.config import load_settings, settings # noqa: E402
43+
from db.ideas import Idea, save_idea # noqa: E402
44+
from db.runs import Run, save_run # noqa: E402
45+
from engine.orchestrator import execute_run # noqa: E402
2746

2847

2948
def run_server(

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "aideator"
7-
version = "0.9.7"
7+
version = "0.9.8"
88
authors = [
99
{ name = "Richard Abishai", email = "richard@richardabish.ai" }
1010
]

0 commit comments

Comments
 (0)