refactor: root-package imports (svc/runtime/interfaces) and fix PYTHONPATH

- Rename platform/ to svc/ to avoid shadowing stdlib platform.
- Replace from oclaw.* with from svc/runtime/interfaces; update -m CLI paths.
- tests/conftest: prepend repo root to sys.path (no parent-folder package name).
- CI: paths and offline_eval script under repo root.
- Ops scripts: PYTHONPATH must be repo root for python -m runtime.* (fixes gateway/WhatsApp sidecar startup).
- Fix default oclaw.json path in tabular/file attachment limits; stabilize attachment test config.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-05-13 14:51:17 +08:00
parent 7941b27f58
commit 420abac9f1
405 changed files with 1316 additions and 1345 deletions

View file

@ -7,7 +7,7 @@ import sys
def test_build_hooks_status_report_empty_workspace(tmp_path, monkeypatch) -> None:
monkeypatch.chdir(tmp_path)
from oclaw.runtime.operations.hooks_cmd import build_hooks_status_report
from runtime.operations.hooks_cmd import build_hooks_status_report
r = build_hooks_status_report(str(tmp_path), config={"hooks": {"internal": {"enabled": True}}})
assert "summary" in r and "hooks" in r
@ -16,7 +16,7 @@ def test_build_hooks_status_report_empty_workspace(tmp_path, monkeypatch) -> Non
def test_hooks_list_json(capsys, tmp_path, monkeypatch) -> None:
monkeypatch.chdir(tmp_path)
from oclaw.runtime.operations.hooks_cmd import _cmd_hooks_list
from runtime.operations.hooks_cmd import _cmd_hooks_list
ns = argparse.Namespace(workspace=str(tmp_path), json=True, eligible=False, verbose=False)
assert _cmd_hooks_list(ns) == 0
@ -28,7 +28,7 @@ def test_hooks_list_json(capsys, tmp_path, monkeypatch) -> None:
def test_hooks_check_text(capsys, tmp_path, monkeypatch) -> None:
monkeypatch.chdir(tmp_path)
from oclaw.runtime.operations.hooks_cmd import _cmd_hooks_check
from runtime.operations.hooks_cmd import _cmd_hooks_check
ns = argparse.Namespace(workspace=str(tmp_path), json=False)
assert _cmd_hooks_check(ns) == 0
@ -37,7 +37,7 @@ def test_hooks_check_text(capsys, tmp_path, monkeypatch) -> None:
def test_hooks_info_missing(capsys, tmp_path, monkeypatch) -> None:
monkeypatch.chdir(tmp_path)
from oclaw.runtime.operations.hooks_cmd import _cmd_hooks_info
from runtime.operations.hooks_cmd import _cmd_hooks_info
ns = argparse.Namespace(workspace=str(tmp_path), name="nonexistent-hook-xyz", json=False)
assert _cmd_hooks_info(ns) == 1
@ -45,7 +45,7 @@ def test_hooks_info_missing(capsys, tmp_path, monkeypatch) -> None:
def test_hooks_install_deprecated_exits_2(capsys) -> None:
from oclaw.runtime.operations.hooks_cmd import _cmd_hooks_install
from runtime.operations.hooks_cmd import _cmd_hooks_install
ns = argparse.Namespace(spec="foo@1.0.0", link=False, pin=False)
assert _cmd_hooks_install(ns) == 2
@ -54,14 +54,14 @@ def test_hooks_install_deprecated_exits_2(capsys) -> None:
def test_hooks_install_missing_spec_exits_1(capsys) -> None:
from oclaw.runtime.operations.hooks_cmd import _cmd_hooks_install
from runtime.operations.hooks_cmd import _cmd_hooks_install
assert _cmd_hooks_install(argparse.Namespace(spec="", link=False, pin=False)) == 1
assert "missing" in capsys.readouterr().err.lower()
def test_hooks_update_deprecated_exits_2(capsys) -> None:
from oclaw.runtime.operations.hooks_cmd import _cmd_hooks_update
from runtime.operations.hooks_cmd import _cmd_hooks_update
assert _cmd_hooks_update(argparse.Namespace(hook_id="pack-a", all=False, dry_run=True)) == 2
err = capsys.readouterr().err
@ -69,7 +69,7 @@ def test_hooks_update_deprecated_exits_2(capsys) -> None:
def test_main_hooks_install_invocation(capsys) -> None:
from oclaw.runtime.operations import main as cli_main
from runtime.operations import main as cli_main
code = cli_main(["hooks", "install", "some-spec@1"])
assert code == 2
@ -78,7 +78,7 @@ def test_main_hooks_install_invocation(capsys) -> None:
def test_main_hooks_list_invocation(tmp_path, monkeypatch) -> None:
monkeypatch.chdir(tmp_path)
from oclaw.runtime.operations import main as cli_main
from runtime.operations import main as cli_main
old = sys.stdout
buf = StringIO()
@ -97,7 +97,7 @@ def test_resolve_cli_workspace_uses_env_over_cwd(tmp_path, monkeypatch) -> None:
expected = tmp_path / "repo-root"
expected.mkdir(parents=True)
monkeypatch.setenv("OCLAW_WORKSPACE", str(expected))
from oclaw.runtime.operations.hooks_cmd import _resolve_cli_workspace
from runtime.operations.hooks_cmd import _resolve_cli_workspace
ns = argparse.Namespace(workspace="")
assert _resolve_cli_workspace(ns) == str(expected)
@ -107,7 +107,7 @@ def test_resolve_cli_workspace_falls_back_to_workspace_root(tmp_path, monkeypatc
monkeypatch.chdir(tmp_path)
monkeypatch.delenv("OCLAW_WORKSPACE", raising=False)
monkeypatch.setenv("OPS_WORKSPACE_ROOT", str(tmp_path))
from oclaw.runtime.operations.hooks_cmd import _resolve_cli_workspace
from runtime.operations.hooks_cmd import _resolve_cli_workspace
ns = argparse.Namespace(workspace="")
assert _resolve_cli_workspace(ns) == str(tmp_path.resolve())