refactor: cleanup dead code, fix model confusion, streamline CLI

- Remove 3 dead modules: academic/, wechat/, social/ (merged into engines/)
- Remove 4 stale news scripts (tech_news.py, wallstreetcn.py, cls.py, rss.py)
- scripts/core/base.py: canonical SearchResult + BaseEngine (was in engines/base.py)
- scripts/engines/base.py: re-exports from core.base for compatibility
- scripts/engines/news_engine.py: Bing News + RSS unified (was in scripts/news/rss.py)
- scripts/engines/academic_engine.py: ArXiv + CrossRef unified (was in scripts/academic/arxiv.py)
- scripts/cli.py: complete rewrite — 10 commands (search/web/news/academic/wechat/social/rss/baidu/health/sources)
- scripts/unified_search.py: clean async Python API (was a stub)
- ws.py: lightweight launcher
- README.md + SKILL.md: updated to reflect actual 15+ engines
- All EngineResult → SearchResult
- All engines return list[SearchResult]
This commit is contained in:
openbot-coder committed 2026-05-30 16:25:41 +08:00
1 parent e20478fcbd
commit c077a7ae40
31 files changed
+1188 -3148

No files matched your search

+12 -23
View File
@@ -1,25 +1,22 @@
"""
Pydantic 数据模型定义。
Data models — re-exports from scripts.core.base for backwards compatibility.
从 bot-search-mcp 移植,适配 web-search-skills 的数据结构。
提供类型安全的搜索数据模型。
依赖: pydantic (>=2.0)
The canonical source of truth is scripts.core.base.SearchResult.
This module exists so old import paths (e.g. from scripts.models import SearchQuery)
continue to work without changes.
"""
from __future__ import annotations
from scripts.core.base import BaseEngine, SearchResult
from dataclasses import dataclass, field
from datetime import datetime
from typing import Any, Optional
# ============================================================
# 搜索结果模型(兼容 dataclass + pydantic 双模式)
# ============================================================
# Backwards-compatible thin wrappers (no functionality changes needed for now)
@dataclass
class SearchQuery:
"""搜索查询封装。"""
"""Search query wrapper."""
query: str
sources: Optional[list[str]] = None
max_results: int = 10
@@ -31,20 +28,16 @@ class SearchQuery:
@dataclass
class SourceRef:
"""引用来源。"""
"""Reference to a result source."""
index: int
title: str
url: str
source: str
# ============================================================
# 性能计时模型
# ============================================================
@dataclass
class EngineTiming:
"""单个引擎耗时记录。"""
"""Per-engine timing record."""
engine_name: str
success: bool
duration_ms: int
@@ -54,7 +47,7 @@ class EngineTiming:
@dataclass
class SearchMetadata:
"""搜索元数据(全链路计时)。"""
"""Search metadata (full-chain timing)."""
total_engines: int = 0
total_raw_results: int = 0
engines_used: list[str] = field(default_factory=list)
@@ -63,13 +56,9 @@ class SearchMetadata:
timed_out_engines: list[str] = field(default_factory=list)
# ============================================================
# 最终响应
# ============================================================
@dataclass
class SearchResponse:
"""完整搜索响应。"""
"""Complete search response."""
query: str
results: list[Any] = field(default_factory=list)
sources: list[SourceRef] = field(default_factory=list)