simplify(compat): skills_sync/skill_manager/kanban/computer_use — drop 37 re-exports/aliases, repoint 8 callers + 9 test files

This commit is contained in:
Teknium
2026-09-03 13:27:01 -07:00
parent 8e1a5b9f46
commit eb8a30cc2f
19 changed files with 37 additions and 59 deletions
+1 -1
View File
@@ -961,7 +961,7 @@ def _run_review_fork(
),
)
with suppress(Exception):
from tools.skill_manager_tool import _reset_background_review_read_marks
from tools.skill_manager_guards import _reset_background_review_read_marks
_reset_background_review_read_marks()
try:
+2 -1
View File
@@ -203,7 +203,8 @@ def _set_bundled_skills_opt_out(opt_out: bool, log_label: str, on_success=None,
"""Record the bundled-skills opt-out marker and sync (essential skills are always seeded);
``on_success(sync_result)`` / ``on_error(exc)`` report the outcome."""
try:
from tools.skills_sync import set_bundled_skills_opt_out, sync_skills
from tools.skills_sync import sync_skills
from tools.skills_sync_bundled_ops import set_bundled_skills_opt_out
set_bundled_skills_opt_out(opt_out)
result = sync_skills(quiet=True)
if on_success is not None:
+1 -1
View File
@@ -955,7 +955,7 @@ class AIAgent(
process_registry.kill_all(task_id=task_id)
def release_computer_use() -> None:
from tools.computer_use import release_computer_use_session
from tools.computer_use.tool import release_computer_use_session
release_computer_use_session(task_id)
for step in (kill_processes, lambda: cleanup_vm(task_id), lambda: cleanup_browser(task_id), release_computer_use):
+1 -1
View File
@@ -109,7 +109,7 @@ class TestEssentialSkillsUndisableable:
assert cfg["skills"]["disabled"] == ["other"]
def test_skill_manage_delete_refused(self):
from tools.skill_manager_tool import _pinned_guard
from tools.skill_manager_guards import _pinned_guard
msg = _pinned_guard("hermes-agent")
assert msg is not None
assert "essential" in msg.lower()
+1 -1
View File
@@ -116,7 +116,7 @@ class TestBlankSlateFork:
monkeypatch.setattr(s, "_blank_slate_walkthrough",
lambda cfg, home: walked.__setitem__("called", True))
opted_out = {"value": None}
monkeypatch.setattr("tools.skills_sync.set_bundled_skills_opt_out",
monkeypatch.setattr("tools.skills_sync_bundled_ops.set_bundled_skills_opt_out",
lambda enabled: opted_out.__setitem__("value", enabled))
cfg = {}
@@ -155,7 +155,7 @@ def test_read_file_registers_background_review_read_mark(tmp_path):
in this review turn" on the follow-up skill_manage patch (#61521).
"""
from tools.file_tools import read_file_tool
from tools.skill_manager_tool import (
from tools.skill_manager_guards import (
_background_review_has_read,
_reset_background_review_read_marks,
)
@@ -190,7 +190,7 @@ def test_read_file_registers_background_review_read_mark(tmp_path):
def test_read_file_outside_review_does_not_mark(tmp_path):
"""Foreground reads must not populate the review-fork read set."""
from tools.file_tools import read_file_tool
from tools.skill_manager_tool import (
from tools.skill_manager_guards import (
_background_review_has_read,
_reset_background_review_read_marks,
)
+1 -1
View File
@@ -63,7 +63,7 @@ def test_background_review_patch_ledgers_and_rolls_back(ledger_env, monkeypatch)
reset_current_write_origin,
set_current_write_origin,
)
from tools.skill_manager_tool import mark_background_review_skill_read
from tools.skill_manager_guards import mark_background_review_skill_read
token = set_current_write_origin(BACKGROUND_REVIEW)
try:
+4 -4
View File
@@ -835,7 +835,7 @@ class TestBackgroundOwnershipPolicyConsistency:
@staticmethod
def _bg_patch(tmp_path, name, old, new):
from tools.skill_manager_tool import mark_background_review_skill_read
from tools.skill_manager_guards import mark_background_review_skill_read
from tools.skill_provenance import (
BACKGROUND_REVIEW,
reset_current_write_origin,
@@ -1108,7 +1108,7 @@ class TestCuratorConsolidationDeleteGuard:
):
"""A view in one tool worker authorizes a patch in the next worker."""
from tools.skills_tool import skill_view
from tools.skill_manager_tool import _reset_background_review_read_marks
from tools.skill_manager_guards import _reset_background_review_read_marks
_reset_background_review_read_marks()
with _curator_pass(tmp_path, monkeypatch=monkeypatch):
@@ -1133,7 +1133,7 @@ class TestCuratorConsolidationDeleteGuard:
):
"""Copied tool contexts share only their own review's read marks."""
from tools.skills_tool import skill_view
from tools.skill_manager_tool import _reset_background_review_read_marks
from tools.skill_manager_guards import _reset_background_review_read_marks
_reset_background_review_read_marks()
with _curator_pass(tmp_path, monkeypatch=monkeypatch):
@@ -1161,7 +1161,7 @@ class TestCuratorConsolidationDeleteGuard:
def test_background_review_support_file_overwrite_requires_that_file_read(self, tmp_path, monkeypatch):
from tools.skills_tool import skill_view
from tools.skill_manager_tool import _reset_background_review_read_marks
from tools.skill_manager_guards import _reset_background_review_read_marks
_reset_background_review_read_marks()
with _curator_pass(tmp_path, monkeypatch=monkeypatch):
@@ -16,8 +16,8 @@ clears the modified state so the two stay consistent.
from contextlib import ExitStack
from unittest.mock import patch
from tools.skills_sync import (
sync_skills,
from tools.skills_sync import sync_skills
from tools.skills_sync_bundled_ops import (
reset_bundled_skill,
list_user_modified_bundled_skills,
diff_bundled_skill,
+5 -6
View File
@@ -17,9 +17,9 @@ from tools.skills_sync import (
_compute_relative_dest,
_dir_hash,
sync_skills,
reset_bundled_skill,
restore_official_optional_skill,
)
from tools.skills_sync_bundled_ops import reset_bundled_skill
from tools.skills_sync_optional import restore_official_optional_skill
class TestReadWriteManifest:
@@ -765,7 +765,7 @@ class TestOptOutToggleAndRemove:
return bundled
def test_marker_toggle(self, tmp_path):
from tools.skills_sync import set_bundled_skills_opt_out
from tools.skills_sync_bundled_ops import set_bundled_skills_opt_out
home = tmp_path / "home"
home.mkdir()
marker = home / ".no-bundled-skills"
@@ -783,9 +783,8 @@ class TestOptOutToggleAndRemove:
assert not marker.exists()
def test_remove_keeps_user_modified(self, tmp_path):
from tools.skills_sync import (
sync_skills, remove_pristine_bundled_skills,
)
from tools.skills_sync import sync_skills
from tools.skills_sync_bundled_ops import remove_pristine_bundled_skills
bundled = self._setup_bundled(tmp_path)
skills_dir = tmp_path / "user_skills"
manifest_file = skills_dir / ".bundled_manifest"
+3 -3
View File
@@ -110,7 +110,7 @@ class TestAgentCloseMethod:
with patch("tools.process_registry.process_registry") as mock_registry, \
patch("run_agent.cleanup_vm") as mock_cleanup_vm, \
patch("run_agent.cleanup_browser") as mock_cleanup_browser, \
patch("tools.computer_use.release_computer_use_session") as mock_cleanup_cua:
patch("tools.computer_use.tool.release_computer_use_session") as mock_cleanup_cua:
agent.close()
mock_registry.kill_all.assert_called_once_with(
@@ -152,7 +152,7 @@ class TestAgentCloseMethod:
"tools.process_registry.process_registry.kill_all",
side_effect=RuntimeError("process cleanup failed"),
), patch(
"tools.computer_use.release_computer_use_session",
"tools.computer_use.tool.release_computer_use_session",
) as mock_cleanup_cua:
agent.close()
@@ -173,7 +173,7 @@ class TestAgentCloseMethod:
agent.client = None
with patch(
"tools.computer_use.release_computer_use_session",
"tools.computer_use.tool.release_computer_use_session",
) as mock_cleanup_cua:
agent.release_clients()
+1 -1
View File
@@ -237,7 +237,7 @@ def _release_permission_mode_dependents(session_key: str) -> None:
sessions never load computer-use; releasing on BOTH edges makes enabling YOLO replace a
standard backend and disabling it revoke a private unrestricted daemon immediately."""
try:
from tools.computer_use import release_computer_use_session
from tools.computer_use.tool import release_computer_use_session
release_computer_use_session(session_key)
except Exception:
-10
View File
@@ -10,13 +10,3 @@ Modules: `tool.py` (handler, approval gate, response shaping), `backend.py` (abs
`ComputerUseBackend` + result dataclasses), `cua_backend.py` (default MCP-over-stdio
backend + `cua_backend_parse`/`_session`/`_daemon` siblings), `schema.py` (byte-frozen).
"""
from __future__ import annotations
from tools.computer_use.tool import ( # noqa: F401 (public re-exports)
handle_computer_use,
release_computer_use_session,
set_approval_callback,
check_computer_use_requirements,
get_computer_use_schema,
)
+1 -1
View File
@@ -529,7 +529,7 @@ def _record_successful_read(task_data: dict, task_id: str, path: str, resolved_s
# file is accepted. A partial read doesn't count — the guard requires the CURRENT full content
# to have been seen. No-op outside review forks (mark_background_review_skill_read gates on
# is_background_review).
from tools.skill_manager_tool import mark_background_review_skill_read
from tools.skill_manager_guards import mark_background_review_skill_read
mark_background_review_skill_read(Path(resolved_str))
except Exception:
logger.debug("background-review read-mark failed", exc_info=True)
+2 -2
View File
@@ -19,8 +19,8 @@ from agent.redact import redact_sensitive_text
from hermes_cli.goals import judge_goal
from tools.registry import registry, tool_error
from hermes_cli.config import cfg_get, load_config
from tools.kanban_tools_schemas import ( # noqa: F401 - re-exported for callers/tests
_DESC_BOARD, _DESC_TASK_ID_DEFAULT, _board_schema_prop, KANBAN_ATTACH_SCHEMA,
from tools.kanban_tools_schemas import (
KANBAN_ATTACH_SCHEMA,
KANBAN_ATTACH_URL_SCHEMA, KANBAN_ATTACHMENTS_SCHEMA, KANBAN_BLOCK_SCHEMA, KANBAN_COMMENT_SCHEMA,
KANBAN_COMPLETE_SCHEMA, KANBAN_CREATE_SCHEMA, KANBAN_HEARTBEAT_SCHEMA, KANBAN_LINK_SCHEMA,
KANBAN_LIST_SCHEMA, KANBAN_REQUEST_CHANGES_SCHEMA, KANBAN_REQUEST_REVIEW_SCHEMA,
+5 -9
View File
@@ -27,15 +27,11 @@ from agent.skill_utils import (
is_skill_description_truncated_for_prompt,
parse_frontmatter as _parse_frontmatter,
SKILL_PROMPT_DESC_LIMIT)
from tools.skill_manager_guards import ( # noqa: F401 — re-exported for callers/tests
_BackgroundReviewReadMarks, _background_review_has_read, _background_review_preflight,
_background_review_read_before_write_guard, _background_review_read_paths,
_background_review_write_guard, _containing_skills_root, _curator_consolidation_delete_guard,
_is_path_redirect, _maybe_auto_propose_org_edit, _org_mirror_write_guard, _pinned_guard,
_reset_background_review_read_marks, _validate_delete_target, _is_background_review,
mark_background_review_skill_read, _refusal as _err)
from tools.skill_manager_batch import ( # noqa: F401
_BATCH_MAX_OPS, _BATCH_OP_ACTIONS, _skill_manage_batch)
from tools.skill_manager_guards import (
_background_review_preflight, _background_review_read_before_write_guard, _background_review_write_guard,
_containing_skills_root, _curator_consolidation_delete_guard, _maybe_auto_propose_org_edit,
_org_mirror_write_guard, _pinned_guard, _validate_delete_target, _is_background_review, _refusal as _err)
from tools.skill_manager_batch import _skill_manage_batch
from tools.skills_guard import scan_skill, should_allow_install, format_scan_report
logger = logging.getLogger(__name__)
+3 -11
View File
@@ -24,7 +24,9 @@ for _stream in (sys.stdout, sys.stderr):
_stream.reconfigure(encoding="utf-8", errors="replace")
from hermes_constants import get_bundled_skills_dir, get_hermes_home, get_optional_skills_dir
from agent.skill_utils import ESSENTIAL_SKILLS, is_excluded_skill_path
from tools.skill_usage import _read_skill_name, read_suppressed_names # noqa: F401 (re-exported)
from tools.skill_usage import _read_skill_name, read_suppressed_names
from tools.skills_sync_bundled_ops import _is_tracked_user_modification
from tools.skills_sync_optional import _backfill_optional_provenance, _read_hub_install_paths
from utils import atomic_write_text
logger = logging.getLogger(__name__)
@@ -419,16 +421,6 @@ def _rmtree_writable(path: Path) -> None:
shutil.rmtree(path, onerror=_on_error)
# Re-exported so ``from tools.skills_sync import X`` / ``patch("tools.skills_sync.X")`` keep working.
from tools.skills_sync_bundled_ops import ( # noqa: E402,F401
_is_tracked_user_modification, _read_for_diff, diff_bundled_skill, list_user_modified_bundled_skills,
remove_pristine_bundled_skills, reset_bundled_skill, set_bundled_skills_opt_out)
from tools.skills_sync_optional import ( # noqa: E402,F401
_backfill_optional_provenance, _content_hash, _index_installed_skill_dirs_by_name, _move_to_restore_backup,
_optional_skill_index, _read_hub_install_paths, _safe_rel_install_path, _skill_file_list,
restore_official_optional_skill)
if __name__ == "__main__":
print("Syncing bundled skills into ~/.hermes/skills/ ...")
result = sync_skills(quiet=False)
+1 -1
View File
@@ -15,7 +15,7 @@ logger = logging.getLogger("tools.skills_sync")
def _ss():
"""Live ``tools.skills_sync`` module (imported lazily: it re-exports this module)."""
"""Live ``tools.skills_sync`` module (imported lazily: it imports helpers from this module)."""
from tools import skills_sync
return skills_sync
+1 -1
View File
@@ -104,7 +104,7 @@ def _serve_skill_file(
def _mark_background_review_read(path: Path) -> None:
try:
from tools.skill_manager_tool import mark_background_review_skill_read
from tools.skill_manager_guards import mark_background_review_skill_read
mark_background_review_skill_read(path)
except Exception:
logger.debug("Could not record background-review skill read for %s", path, exc_info=True)