From 0d2c16172fceb97deb8db1b320620452edc0cd0d Mon Sep 17 00:00:00 2001 From: Research Assistant Date: Tue, 28 Apr 2026 23:58:02 +0800 Subject: [PATCH] fix: correct UPDATEABLE_PATHS repo paths; plugin install uses vault-first source; exclude table images from figure-map matching --- paperforge/__init__.py | 2 +- .../skills/literature-qa/scripts/ld_deep.py | 16 +++++++++++--- paperforge/worker/status.py | 2 +- paperforge/worker/update.py | 22 ++++++++++++------- 4 files changed, 29 insertions(+), 13 deletions(-) diff --git a/paperforge/__init__.py b/paperforge/__init__.py index d683afaa..9f405238 100644 --- a/paperforge/__init__.py +++ b/paperforge/__init__.py @@ -1,3 +1,3 @@ """paperforge — PaperForge package.""" -__version__ = "1.4.5" +__version__ = "1.4.6" diff --git a/paperforge/skills/literature-qa/scripts/ld_deep.py b/paperforge/skills/literature-qa/scripts/ld_deep.py index daaa1cc8..18734a9b 100644 --- a/paperforge/skills/literature-qa/scripts/ld_deep.py +++ b/paperforge/skills/literature-qa/scripts/ld_deep.py @@ -699,17 +699,27 @@ def build_figure_map(fulltext: str, zotero_key: str = "") -> dict: caption_text = m.group(2).strip() if len(m.groups()) > 1 else "" # Find nearest image within window of adjacent pages (current ± 2 pages) + # Filter: figure captions → exclude table images; table captions → prefer table images best_image = None min_distance = float("inf") + is_table_type = entry_type in ("main_table", "supplementary_table") for img in all_images: - # Check if image is within 2 pages of current page + img_name_lower = img.get("link", "").lower() + img_is_table = "table" in img_name_lower + + # Figure captions: skip images that are clearly table screenshots + if not is_table_type and img_is_table: + continue + if current_page is not None and img["page"] is not None: page_diff = abs(img["page"] - current_page) if page_diff <= 2: distance = abs(img["line_idx"] - idx) - if distance < min_distance: - min_distance = distance + # Table captions: boost score for table images (+ priority) + score = distance - 100 if (is_table_type and img_is_table) else distance + if score < min_distance: + min_distance = score best_image = img # Find additional images on the same page near the best image diff --git a/paperforge/worker/status.py b/paperforge/worker/status.py index 640158ed..a1793139 100644 --- a/paperforge/worker/status.py +++ b/paperforge/worker/status.py @@ -498,4 +498,4 @@ def run_status(vault: Path, verbose: bool = False, json_output: bool = False) -> GITHUB_REPO = "LLLin000/PaperForge" GITHUB_ZIP = f"https://github.com/{GITHUB_REPO}/archive/refs/heads/master.zip" -UPDATEABLE_PATHS = ["skills", "pipeline", "command", "scripts", "plugin"] +UPDATEABLE_PATHS = ["command", "scripts", "paperforge/skills", "paperforge/plugin"] diff --git a/paperforge/worker/update.py b/paperforge/worker/update.py index 2ce65f9f..57bf1379 100644 --- a/paperforge/worker/update.py +++ b/paperforge/worker/update.py @@ -216,17 +216,23 @@ def update_via_zip(vault: Path) -> bool: def _install_obsidian_plugin(vault: Path) -> bool: - """Copy Obsidian plugin files into .obsidian/plugins/paperforge/.""" - try: - import importlib - import paperforge - importlib.reload(paperforge) + """Copy Obsidian plugin files into .obsidian/plugins/paperforge/. - pkg_dir = Path(paperforge.__file__).parent.resolve() - plugin_src = pkg_dir / "plugin" + Source priority: vault copy (git/zip) → Python package (pip). + """ + try: plugin_dst = vault / ".obsidian" / "plugins" / "paperforge" - if not plugin_src.exists() or not plugin_src.is_dir(): + # Try vault copy first (works for git pull and zip updates) + plugin_src = vault / "paperforge" / "plugin" + if not plugin_src.is_dir(): + # Fallback: Python package location (works for pip) + import importlib + import paperforge + importlib.reload(paperforge) + plugin_src = Path(paperforge.__file__).parent.resolve() / "plugin" + + if not plugin_src.is_dir(): logger.warning("Plugin source not found: %s", plugin_src) return False