Add inline comments to core modules and code review notes

Added explanatory comments to server.py, freshrss_pipeline.py, pipeline.py,
freshrss.py, keyword_index.py, summary_loop.py, and filters/engine.py.
Also added CODE_REVIEW.md with prioritized improvement suggestions.
This commit is contained in:
wdm
2026-03-28 23:59:50 +08:00
parent 3940db1443
commit 41f7ac0e91
8 changed files with 56 additions and 0 deletions
+7
View File
@@ -1,5 +1,8 @@
from __future__ import annotations
# MCP 服务入口:将内容提取、过滤、FreshRSS 全链路管道暴露为 MCP 工具。
# 生产主入口是 run_freshrss_openclaw_pipeline,其余工具供单步调试使用。
import json
import tempfile
from datetime import date
@@ -22,6 +25,7 @@ mcp = FastMCP(name="content-extract-mcp")
@mcp.tool()
def extract_url_content(url: str, language_hint: str | None = None) -> dict:
# 从单个 URL 抓取并提取结构化文章内容,供单步调试使用
"""Extract structured article content from a single URL."""
result = extract_content(
ExtractionInput(
@@ -34,6 +38,7 @@ def extract_url_content(url: str, language_hint: str | None = None) -> dict:
@mcp.tool()
def extract_item_content(item: dict) -> dict:
# 从已标准化的 item 对象提取内容(跳过网络抓取,使用 RSS 内联内容)
"""Extract structured article content from a normalized item object."""
parsed_item = Item.model_validate(item)
result = extract_content(ExtractionInput(item=parsed_item))
@@ -47,6 +52,7 @@ def filter_summary_result(
item: dict | None = None,
context: dict | None = None,
) -> dict:
# 对结构化摘要结果运行确定性规则引擎,返回 keep/review/drop 决策
"""Apply deterministic filter rules to a structured summary result."""
parsed_summary = LlmSummaryResult.model_validate(summary_result)
parsed_article = ExtractedArticle.model_validate(extracted_article) if extracted_article else None
@@ -88,6 +94,7 @@ def run_freshrss_openclaw_pipeline(
include_item_reports: bool = False,
) -> dict:
"""Run the full FreshRSS -> extract -> LLM -> filter -> OpenClaw payload pipeline."""
# context 若传入则序列化为临时文件再传给 pipeline(TODO: pipeline 改为直接接受 dict)
temp_context_path: Path | None = None
try: