fix: empty-list scope, get_tree bool casing, md fence tracking; dedupe base URL

- local get_agent_tools: `set(doc_ids) if doc_ids is not None else None` so
  doc_ids=[] is a scope of nothing (reject all), not open mode. The public
  query path already guarded []; this hardens direct callers.
- legacy get_tree: send summary=true/false (lowercase) instead of Python's
  capitalized True/False, matching the modern CloudBackend and the API.
- markdown parser: track the opening fence character so a ```-fence isn't
  closed by a ~~~ line (CommonMark), keeping '#'-lines inside it out of headings.
- dedupe the cloud base URL: single API_BASE in cloud_api, referenced by
  CloudBackend and PageIndexClient (was three independent copies).

Regression tests for each.
This commit is contained in:
mountain 2026-07-10 11:17:20 +08:00
parent e18ccdeaf8
commit d97231b480
8 changed files with 83 additions and 15 deletions

View file

@ -100,3 +100,22 @@ def test_tilde_fenced_code_blocks_are_recognized(tmp_path):
titles = [n.title for n in result.nodes]
assert titles == ["Real Header", "Real Sub"]
assert "not a real header" not in " ".join(n.title for n in result.nodes)
def test_backtick_fence_is_not_closed_by_a_tilde_line(tmp_path):
"""CommonMark: a ```-opened fence is closed only by ```. A ~~~ line inside
it is content, so a '#'-prefixed line stays inside the still-open block and
a real heading after the real close is still recognized."""
md = tmp_path / "mixed.md"
md.write_text(
"# Real Header\n"
"```\n"
"~~~\n" # tilde line INSIDE the backtick fence — NOT a close
"# not a heading\n" # stays inside the still-open code block
"```\n" # this (matching char) closes the fence
"## Real Sub\n"
)
result = MarkdownParser().parse(str(md))
titles = [n.title for n in result.nodes]
assert titles == ["Real Header", "Real Sub"]
assert "not a heading" not in " ".join(n.title for n in result.nodes)