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

+10 -78
View File
@@ -1,90 +1,22 @@
#!/usr/bin/env python3
"""
web-search-skills: Open-source diversified search in <5s.
Lightweight launcher — delegates to scripts.cli:main().
Usage:
python3 ws.py search <query> [--max-results 5]
python3 ws.py health
python3 ws.py serve # (future) MCP server mode
python3 ws.py search "quantum computing" --max-results 5
python3 ws.py health
python3 ws.py --help
"""
from __future__ import annotations
import argparse
import asyncio
import json
import sys
import time
from pathlib import Path
# Ensure the project root is on the path
_root = Path(__file__).parent
if str(_root) not in sys.path:
sys.path.insert(0, str(_root))
async def cmd_search(args: argparse.Namespace):
from scripts.unified_search import UnifiedSearch
us = UnifiedSearch()
t0 = time.time()
resp = await us.search(args.query, max_results=args.max_results)
elapsed = time.time() - t0
if args.json:
output = {
"query": resp.query,
"sources": [
{
"index": s.index,
"title": s.title,
"url": s.url,
"source": s.source,
}
for s in resp.sources
],
"time_ms": elapsed * 1000,
}
print(json.dumps(output, ensure_ascii=False, indent=2))
else:
print(f"\n🔍 「{resp.query}」 — {elapsed:.2f}s")
print(f" {len(resp.sources)} results from {len(resp.metadata.engines_used)} engines\n")
for i, s in enumerate(resp.sources, 1):
print(f" {i}. [{s.source}] {s.title}")
print(f" {s.url}")
print()
await us.close()
async def cmd_health(args: argparse.Namespace):
from scripts.unified_search import UnifiedSearch
us = UnifiedSearch()
status = await us.health()
if args.json:
print(json.dumps(status, ensure_ascii=False, indent=2))
else:
print("📊 Search Health")
print(f" Status: {status.get('status', 'unknown')}")
print(f" Engines: {', '.join(status.get('engines', []))}")
await us.close()
def main():
parser = argparse.ArgumentParser(description="web-search-skills")
sub = parser.add_subparsers(dest="command", required=True)
# search
sp = sub.add_parser("search", help="Search across multiple sources")
sp.add_argument("query", help="Search query")
sp.add_argument("--max-results", type=int, default=5)
sp.add_argument("--json", action="store_true", help="JSON output")
# health
hp = sub.add_parser("health", help="Check engine health")
hp.add_argument("--json", action="store_true", help="JSON output")
args = parser.parse_args()
if args.command == "search":
asyncio.run(cmd_search(args))
elif args.command == "health":
asyncio.run(cmd_health(args))
from scripts.cli import main
if __name__ == "__main__":
main()