diff --git a/SKILL.md b/SKILL.md index 5aa5286..89a97d8 100644 --- a/SKILL.md +++ b/SKILL.md @@ -429,6 +429,7 @@ python3 {skill_dir}/toolkit/cli.py preview {markdown} --theme {theme} --no-open title: "{标题}" topic_source: "热点抓取" # 或 "用户指定" topic_keywords: ["{词1}", "{词2}"] + output_file: "{output 文件路径}" # e.g. output/2026-03-31-zhangxue-slow-accumulation.md framework: "{框架}" enhance_strategy: "{增强策略}" # angle_discovery/density_boost/detail_anchoring/real_feel word_count: {字数} diff --git a/scripts/learn_edits.py b/scripts/learn_edits.py index 54119a3..543c0b6 100644 --- a/scripts/learn_edits.py +++ b/scripts/learn_edits.py @@ -111,13 +111,34 @@ def fetch_wechat_draft() -> tuple[str, str, str]: title = latest.get("title", "") # Find the local draft file + # Priority: output_file field → title slug match → largest file date = latest.get("date", "") output_dir = SKILL_DIR / "output" draft_path = None - if date: - candidates = list(output_dir.glob(f"{date}-*.md")) - if candidates: + + # First try: exact path from history + output_file = latest.get("output_file", "") + if output_file: + candidate = SKILL_DIR / output_file if not Path(output_file).is_absolute() else Path(output_file) + if candidate.exists(): + draft_path = candidate + + if not draft_path and date: + candidates = sorted(output_dir.glob(f"{date}-*.md")) + if len(candidates) == 1: draft_path = candidates[0] + elif len(candidates) > 1: + # Multiple files on same date — try to match by title keywords + title_lower = title.lower() + for c in candidates: + slug = c.stem.replace(date + "-", "").replace("-", " ") + # Check if slug words appear in title + if any(w in title_lower for w in slug.split() if len(w) > 1): + draft_path = c + break + if not draft_path: + # Fallback: use the largest file (likely the final version) + draft_path = max(candidates, key=lambda p: p.stat().st_size) if not draft_path or not draft_path.exists(): raise FileNotFoundError(