From 99d8f396132eff43796c5f7a326eb9e2db4112b5 Mon Sep 17 00:00:00 2001 From: Jon Saad-Falcon Date: Mon, 2 Mar 2026 20:57:52 +0000 Subject: [PATCH] refactor: move operators/ TOML data into src/openjarvis/operators/data/ Co-Authored-By: Claude Opus 4.6 --- src/openjarvis/cli/operators_cmd.py | 11 ++++++++--- .../openjarvis/operators/data}/knowledge_curator.toml | 0 .../openjarvis/operators/data}/news_digest.toml | 0 .../openjarvis/operators/data}/researcher.toml | 0 .../openjarvis/operators/data}/system_monitor.toml | 0 tests/operators/test_operator_recipes.py | 2 +- tests/operators/test_operators.py | 6 +++--- 7 files changed, 12 insertions(+), 7 deletions(-) rename {operators => src/openjarvis/operators/data}/knowledge_curator.toml (100%) rename {operators => src/openjarvis/operators/data}/news_digest.toml (100%) rename {operators => src/openjarvis/operators/data}/researcher.toml (100%) rename {operators => src/openjarvis/operators/data}/system_monitor.toml (100%) diff --git a/src/openjarvis/cli/operators_cmd.py b/src/openjarvis/cli/operators_cmd.py index 2ee55ead..6a6b33d1 100644 --- a/src/openjarvis/cli/operators_cmd.py +++ b/src/openjarvis/cli/operators_cmd.py @@ -10,6 +10,11 @@ from rich.console import Console from rich.table import Table +def _builtin_operators_dir() -> Path: + """Return the path to built-in operator manifests shipped with the package.""" + return Path(__file__).resolve().parents[1] / "operators" / "data" + + @click.group() def operators() -> None: """Manage operators — persistent, scheduled autonomous agents.""" @@ -32,7 +37,7 @@ def list_operators() -> None: # Also check project-local operators/ directory project_dirs = [manifests_dir] - local_ops = Path("operators") + local_ops = _builtin_operators_dir() if local_ops.is_dir(): project_dirs.append(local_ops) @@ -244,7 +249,7 @@ def _find_manifest(operator_id: str): from openjarvis.core.config import DEFAULT_CONFIG_DIR from openjarvis.operators.loader import load_operator - dirs = [DEFAULT_CONFIG_DIR / "operators", Path("operators")] + dirs = [DEFAULT_CONFIG_DIR / "operators", _builtin_operators_dir()] for d in dirs: if not d.is_dir(): continue @@ -271,7 +276,7 @@ def _build_system_with_operators(): # Discover from known directories from openjarvis.core.config import DEFAULT_CONFIG_DIR - for d in [DEFAULT_CONFIG_DIR / "operators", Path("operators")]: + for d in [DEFAULT_CONFIG_DIR / "operators", _builtin_operators_dir()]: if d.is_dir(): manager.discover(d) diff --git a/operators/knowledge_curator.toml b/src/openjarvis/operators/data/knowledge_curator.toml similarity index 100% rename from operators/knowledge_curator.toml rename to src/openjarvis/operators/data/knowledge_curator.toml diff --git a/operators/news_digest.toml b/src/openjarvis/operators/data/news_digest.toml similarity index 100% rename from operators/news_digest.toml rename to src/openjarvis/operators/data/news_digest.toml diff --git a/operators/researcher.toml b/src/openjarvis/operators/data/researcher.toml similarity index 100% rename from operators/researcher.toml rename to src/openjarvis/operators/data/researcher.toml diff --git a/operators/system_monitor.toml b/src/openjarvis/operators/data/system_monitor.toml similarity index 100% rename from operators/system_monitor.toml rename to src/openjarvis/operators/data/system_monitor.toml diff --git a/tests/operators/test_operator_recipes.py b/tests/operators/test_operator_recipes.py index 3f1624a0..2b642bb7 100644 --- a/tests/operators/test_operator_recipes.py +++ b/tests/operators/test_operator_recipes.py @@ -6,7 +6,7 @@ import pytest from openjarvis.operators.loader import load_operator -_OPERATORS_DIR = Path(__file__).parent.parent.parent / "recipes" / "operators" +_OPERATORS_DIR = Path(__file__).parent.parent.parent / "src" / "openjarvis" / "recipes" / "data" / "operators" class TestResearcherOperator: diff --git a/tests/operators/test_operators.py b/tests/operators/test_operators.py index 5517baf2..1964ab20 100644 --- a/tests/operators/test_operators.py +++ b/tests/operators/test_operators.py @@ -832,12 +832,12 @@ class TestLoadBundledOperators: @pytest.fixture def operators_dir(self): - # Find the project-level operators/ directory + # Find the package-level operators/data/ directory here = Path(__file__).resolve() project_root = here.parent.parent.parent - ops_dir = project_root / "operators" + ops_dir = project_root / "src" / "openjarvis" / "operators" / "data" if not ops_dir.is_dir(): - pytest.skip("operators/ directory not found") + pytest.skip("operators/data/ directory not found") return ops_dir def test_researcher_loads(self, operators_dir):