diff --git a/paperforge/cli.py b/paperforge/cli.py index 1cf7b816..25bef9cc 100644 --- a/paperforge/cli.py +++ b/paperforge/cli.py @@ -464,7 +464,6 @@ def build_parser() -> argparse.ArgumentParser: p_paper_navigation = sub.add_parser("paper-navigation", help="Navigate paper structure through the Layer 4 gateway") p_paper_navigation.add_argument("query", help="Paper identifier or DOI for structural navigation") p_paper_navigation.add_argument("--json", action="store_true", help="Output JSON") - p_paper_navigation.add_argument("--limit", type=int, default=5, help="Max results (default 5)") p_scoped_fetch = sub.add_parser("scoped-fetch", help="Fetch paper content scoped by query through the Layer 4 gateway") p_scoped_fetch.add_argument("query", help="Paper identifier, title, or scoped query for targeted fetch") diff --git a/paperforge/commands/content_discovery.py b/paperforge/commands/content_discovery.py index 8147c472..555dec13 100644 --- a/paperforge/commands/content_discovery.py +++ b/paperforge/commands/content_discovery.py @@ -5,7 +5,7 @@ from __future__ import annotations from paperforge.retrieval import gateway -def run(args): +def run(args) -> int: """Execute ``content-discovery`` via the Layer 4 gateway.""" result = gateway.route_gateway( args.vault_path, diff --git a/paperforge/commands/paper_lookup.py b/paperforge/commands/paper_lookup.py index f732e556..35e022da 100644 --- a/paperforge/commands/paper_lookup.py +++ b/paperforge/commands/paper_lookup.py @@ -5,7 +5,7 @@ from __future__ import annotations from paperforge.retrieval import gateway -def run(args): +def run(args) -> int: """Execute ``paper-lookup`` via the Layer 4 gateway.""" result = gateway.route_gateway( args.vault_path, diff --git a/paperforge/retrieval/gateway.py b/paperforge/retrieval/gateway.py index cf0c494c..0bf85766 100644 --- a/paperforge/retrieval/gateway.py +++ b/paperforge/retrieval/gateway.py @@ -18,13 +18,6 @@ from paperforge.memory.db import get_connection, get_memory_db_path logger = logging.getLogger(__name__) -# Map gateway intent names to build_query_plan intent strings -INTENTS: dict[str, str] = { - "paper-lookup": "known-paper", - "content-discovery": "content", - "paper-navigation": "known-paper", - "scoped-fetch": "known-paper", -} def route_gateway( diff --git a/paperforge/retrieval/structure_tree.py b/paperforge/retrieval/structure_tree.py index 8bf184da..c0e00d17 100644 --- a/paperforge/retrieval/structure_tree.py +++ b/paperforge/retrieval/structure_tree.py @@ -13,12 +13,13 @@ def build_structure_tree(structured_blocks: list[dict[str, Any]]) -> dict[str, A role = block.get("role") text = str(block.get("text", "")).strip() if role in {"section_heading", "subsection_heading", "introduction_heading", "abstract_heading"} and text: + parent_title = nodes[-1]["title"] if nodes else "" current_section = { "node_id": f"sec:{block.get('block_id')}", "kind": "section", "title": text, "level": 1 if role != "subsection_heading" else 2, - "section_path": [text] if role != "subsection_heading" else [nodes[-1]["title"], text] if nodes else [text], + "section_path": [text] if role != "subsection_heading" else [parent_title, text], "page_span": [block.get("page", 0), block.get("page", 0)], "block_span": [[block.get("page", 0), block.get("block_id", "")]], "children": [],