mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
refactor: remove dead code — 1,784 lines across 77 files (#9180)
Deep scan with vulture, pyflakes, and manual cross-referencing identified: - 41 dead functions/methods (zero callers in production) - 7 production-dead functions (only test callers, tests deleted) - 5 dead constants/variables - ~35 unused imports across agent/, hermes_cli/, tools/, gateway/ Categories of dead code removed: - Refactoring leftovers: _set_default_model, _setup_copilot_reasoning_selection, rebuild_lookups, clear_session_context, get_logs_dir, clear_session - Unused API surface: search_models_dev, get_pricing, skills_categories, get_read_files_summary, clear_read_tracker, menu_labels, get_spinner_list - Dead compatibility wrappers: schedule_cronjob, list_cronjobs, remove_cronjob - Stale debug helpers: get_debug_session_info copies in 4 tool files (centralized version in debug_helpers.py already exists) - Dead gateway methods: send_emote, send_notice (matrix), send_reaction (bluebubbles), _normalize_inbound_text (feishu), fetch_room_history (matrix), _start_typing_indicator (signal), parse_feishu_post_content - Dead constants: NOUS_API_BASE_URL, SKILLS_TOOL_DESCRIPTION, FILE_TOOLS, VALID_ASPECT_RATIOS, MEMORY_DIR - Unused UI code: _interactive_provider_selection, _interactive_model_selection (superseded by prompt_toolkit picker) Test suite verified: 609 tests covering affected files all pass. Tests for removed functions deleted. Tests using removed utilities (clear_read_tracker, MEMORY_DIR) updated to use internal APIs directly.
This commit is contained in:
parent
a66fc1365d
commit
8d023e43ed
77 changed files with 44 additions and 1784 deletions
|
|
@ -100,74 +100,6 @@ class TestGatewayIntegration(unittest.TestCase):
|
|||
self.assertIn("hermes-feishu", TOOLSETS["hermes-gateway"]["includes"])
|
||||
|
||||
|
||||
class TestFeishuPostParsing(unittest.TestCase):
|
||||
def test_parse_post_content_extracts_text_mentions_and_media_refs(self):
|
||||
from gateway.platforms.feishu import parse_feishu_post_content
|
||||
|
||||
result = parse_feishu_post_content(
|
||||
json.dumps(
|
||||
{
|
||||
"en_us": {
|
||||
"title": "Rich message",
|
||||
"content": [
|
||||
[{"tag": "img", "image_key": "img_1", "alt": "diagram"}],
|
||||
[{"tag": "at", "user_name": "Alice", "open_id": "ou_alice"}],
|
||||
[{"tag": "media", "file_key": "file_1", "file_name": "spec.pdf"}],
|
||||
],
|
||||
}
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
self.assertEqual(result.text_content, "Rich message\n[Image: diagram]\n@Alice\n[Attachment: spec.pdf]")
|
||||
self.assertEqual(result.image_keys, ["img_1"])
|
||||
self.assertEqual(result.mentioned_ids, ["ou_alice"])
|
||||
self.assertEqual(len(result.media_refs), 1)
|
||||
self.assertEqual(result.media_refs[0].file_key, "file_1")
|
||||
self.assertEqual(result.media_refs[0].file_name, "spec.pdf")
|
||||
self.assertEqual(result.media_refs[0].resource_type, "file")
|
||||
|
||||
def test_parse_post_content_uses_fallback_when_invalid(self):
|
||||
from gateway.platforms.feishu import FALLBACK_POST_TEXT, parse_feishu_post_content
|
||||
|
||||
result = parse_feishu_post_content("not-json")
|
||||
|
||||
self.assertEqual(result.text_content, FALLBACK_POST_TEXT)
|
||||
self.assertEqual(result.image_keys, [])
|
||||
self.assertEqual(result.media_refs, [])
|
||||
self.assertEqual(result.mentioned_ids, [])
|
||||
|
||||
def test_parse_post_content_preserves_rich_text_semantics(self):
|
||||
from gateway.platforms.feishu import parse_feishu_post_content
|
||||
|
||||
result = parse_feishu_post_content(
|
||||
json.dumps(
|
||||
{
|
||||
"en_us": {
|
||||
"title": "Plan *v2*",
|
||||
"content": [
|
||||
[
|
||||
{"tag": "text", "text": "Bold", "style": {"bold": True}},
|
||||
{"tag": "text", "text": " "},
|
||||
{"tag": "text", "text": "Italic", "style": {"italic": True}},
|
||||
{"tag": "text", "text": " "},
|
||||
{"tag": "text", "text": "Code", "style": {"code": True}},
|
||||
],
|
||||
[{"tag": "text", "text": "line1"}, {"tag": "br"}, {"tag": "text", "text": "line2"}],
|
||||
[{"tag": "hr"}],
|
||||
[{"tag": "code_block", "language": "python", "text": "print('hi')"}],
|
||||
],
|
||||
}
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
result.text_content,
|
||||
"Plan *v2*\n**Bold** *Italic* `Code`\nline1\nline2\n---\n```python\nprint('hi')\n```",
|
||||
)
|
||||
|
||||
|
||||
class TestFeishuMessageNormalization(unittest.TestCase):
|
||||
def test_normalize_merge_forward_preserves_summary_lines(self):
|
||||
from gateway.platforms.feishu import normalize_feishu_message
|
||||
|
|
@ -805,15 +737,6 @@ class TestAdapterBehavior(unittest.TestCase):
|
|||
|
||||
run_threadsafe.assert_not_called()
|
||||
|
||||
@patch.dict(os.environ, {}, clear=True)
|
||||
def test_normalize_inbound_text_strips_feishu_mentions(self):
|
||||
from gateway.config import PlatformConfig
|
||||
from gateway.platforms.feishu import FeishuAdapter
|
||||
|
||||
adapter = FeishuAdapter(PlatformConfig())
|
||||
cleaned = adapter._normalize_inbound_text("hi @_user_1 there @_user_2")
|
||||
self.assertEqual(cleaned, "hi there")
|
||||
|
||||
@patch.dict(os.environ, {"FEISHU_GROUP_POLICY": "open"}, clear=True)
|
||||
def test_group_message_requires_mentions_even_when_policy_open(self):
|
||||
from gateway.config import PlatformConfig
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue