AI agent skill that researches any topic across Reddit, X, YouTube, HN, Polymarket, and the web - then synthesizes a grounded summary
Python ai-promptsai-skillblueskyclaudeclaude-codeclawhubdeep-researchhackernewsinstagramopenclawpolymarketrecencyredditresearchsocial-mediatiktoktrendstwitterweb-searchyoutube
fix: preserve slash topics outside comparison mode (#1211)
Ilia Alshanetsky4e9ac0ebf2b2
diff --git a/changelog.d/+cr-006-comparison-intent.fixed.md b/changelog.d/+cr-006-comparison-intent.fixed.mdnew file mode 100644index 00000000..a24777c6--- /dev/null+++ b/changelog.d/+cr-006-comparison-intent.fixed.md@@ -0,0 +1 @@+Keep slash-containing research topics such as `CI/CD`, repository names, and URLs intact instead of launching unintended competitor comparisons. Preserve supported comparison forms, including `React/Vue/Svelte`, and slashes inside explicitly compared entities.diff --git a/skills/last30days/scripts/lib/planner.py b/skills/last30days/scripts/lib/planner.pyindex f0b1a703..08d9d7fe 100644--- a/skills/last30days/scripts/lib/planner.py+++ b/skills/last30days/scripts/lib/planner.py@@ -759,12 +759,15 @@ def _fallback_plan()+_SLASH_COMPARISON = re.compile(r"\b[A-Z][a-z]{2,}(?:/[A-Z][a-z]{2,})+\b")++def _infer_intent(topic: str) -> str:text = topic.lower().strip()if re.search(r"\b(vs|versus|compare|compared to|difference between)\b", text):return "comparison"# Slash-separated proper nouns: "React/Vue/Svelte" (not URLs, not acronyms like CI/CD or I/O)- if not re.search(r"https?://", topic) and re.search(r"\b[A-Z][a-z]{2,}(?:/[A-Z][a-z]{2,})+\b", topic):+ if not re.search(r"https?://", topic) and _SLASH_COMPARISON.search(topic):return "comparison"if re.search(r"\b(odds|predict|prediction|forecast|chance|probability|will .* win)\b", text):return "prediction"@@ -901,7 +904,13 @@ def _comparison_entities(topic: str, *, uncapped: bool = False) -> list[str]:Caps at ``competitors.COMPARISON_ENTITY_MAX`` unless ``uncapped`` (callertruncates and may warn about dropped entities).++ Standalone comparator tokens are syntax, including repeated tokens.+ Compact ``vs.`` separates entities only after a nonempty left entity."""+ if _infer_intent(topic) != "comparison":+ return []+# "difference between X and Y" -> "X vs Y" (replace "and" only in this context)normalized = re.sub(r"\bdifference between\s+(.+?)\s+and\s+",@@ -910,11 +919,25 @@ def _comparison_entities(topic: str, *, uncapped: bool = False) -> list[str]:flags=re.I,)normalized = re.sub(r"\b(compared to)\b", " vs ", normalized, flags=re.I)- parts = [- part.strip(" \t\r\n?.,:;!()[]{}\"'")- for part in re.split(r"\bvs\.?\b|\bversus\b|/", normalized, flags=re.I)- if part.strip(" \t\r\n?.,:;!()[]{}\"'")- ]+ separator = r"(?<!\S)(?:(?P<standalone>vs\.?|versus)(?!\S)|vs\.(?=\S))"+ if not re.search(separator, normalized, flags=re.I):+ if re.search(r"https?://", normalized):+ return []+ normalized = _SLASH_COMPARISON.sub(+ lambda match: match.group(0).replace("/", " vs "), normalized,+ )+ trim = " \t\r\n?.,:;!()[]{}\"'"+ parts = []+ part_start = 0+ for match in re.finditer(separator, normalized, flags=re.I):+ part = normalized[part_start:match.start()].strip(trim)+ if part:+ parts.append(part)+ if part or match.group("standalone") is not None:+ part_start = match.end()+ last_part = normalized[part_start:].strip(trim)+ if last_part:+ parts.append(last_part)# Strip trailing context from parts ("Svelte for frontend in 2026" -> "Svelte")if len(parts) < 2:return []diff --git a/tests/test_comparison_intent.py b/tests/test_comparison_intent.pynew file mode 100644index 00000000..b9bb4906--- /dev/null+++ b/tests/test_comparison_intent.py@@ -0,0 +1,127 @@+import json+import sys++import pytest++import last30days as cli+from lib import planner+++SINGLE_TOPICS = [+ "CI/CD",+ "I/O performance",+ "openai/openai-python",+ "https://example.com",+ "https://example.com/React/Vue",+ "https://example.com/vs/topic",+ "https://example.com/vs.Vue",+ "React vsVue",+ "vs.code",+ "vs.code/extension",+ "compare CI/CD workflows",+]++COMPARISONS = [+ ("React/Vue/Svelte", ["React", "Vue", "Svelte"]),+ ("React vs Vue", ["React", "Vue"]),+ ("React vs. Vue", ["React", "Vue"]),+ ("React vs. vs. Vue", ["React", "Vue"]),+ ("React vs.Vue", ["React", "Vue"]),+ ("React VS.Vue", ["React", "Vue"]),+ ("React versus Vue", ["React", "Vue"]),+ ("vs.code versus Vue", ["vs.code", "Vue"]),+ ("vs.code vs.Vue", ["vs.code", "Vue"]),+ ("vs.code/extension versus Vue", ["vs.code/extension", "Vue"]),+ ("React versus vs.code", ["React", "vs.code"]),+ ("React vs.vs.code", ["React", "vs.code"]),+ ("React versus vs.code/extension", ["React", "vs.code/extension"]),+ ("vs.code/extension versus vs.code/other", ["vs.code/extension", "vs.code/other"]),+ ("https://example.com/vs.code versus owner/repo",+ ["https://example.com/vs.code", "owner/repo"]),+ ("React versus https://example.com/vs.code", ["React", "https://example.com/vs.code"]),+ ("React compared to Vue", ["React", "Vue"]),+ ("difference between React and Vue", ["React", "Vue"]),+ ("React/Vue/Svelte for CI/CD", ["React", "Vue", "Svelte"]),+ ("CI/CD vs I/O", ["CI/CD", "I/O"]),+ ("CI/CD vs.I/O", ["CI/CD", "I/O"]),+ ("openai/openai-python vs anthropics/anthropic-sdk-python",+ ["openai/openai-python", "anthropics/anthropic-sdk-python"]),+]++[email protected]("topic", SINGLE_TOPICS)[email protected]("uncapped", [False, True])+def test_slashes_without_comparison_intent_do_not_produce_entities(topic, uncapped):+ assert planner._comparison_entities(topic, uncapped=uncapped) == []++[email protected]("topic,entities", COMPARISONS)+def test_comparison_entities_preserve_slashes_inside_explicit_entities(topic, entities):+ assert planner._comparison_entities(topic) == entities+++def run_cli(monkeypatch, tmp_path, capsys):+ monkeypatch.setattr(cli.env, "CONFIG_DIR", tmp_path)+ monkeypatch.setattr(cli.env, "get_config", lambda **kwargs: {})+ monkeypatch.setenv("PATH", "")+ monkeypatch.setenv("LAST30DAYS_STORE", "")++ def run(topic):+ monkeypatch.setattr(sys, "argv", [+ "last30days", topic, "--mock", "--quick", "--search=reddit",+ "--no-browser-cookies", "--emit=json", "--json-profile=raw",+ "--save-dir", "",+ ])+ result = cli.main()+ captured = capsys.readouterr()+ assert result == 0, captured.err+ return json.loads(captured.out)++ return run++[email protected]("topic", SINGLE_TOPICS)+def test_main_preserves_slash_topics_as_single_research_runs(topic, run_cli):+ payload = run_cli(topic)+ assert payload.get("comparison") is not True+ assert payload["topic"] == topic+ assert payload["query_plan"]["raw_topic"] == topic++[email protected]("topic,entities", COMPARISONS)+def test_main_keeps_supported_comparison_forms(topic, entities, run_cli):+ payload = run_cli(topic)+ assert payload["comparison"] is True+ assert payload["entities"] == entities+ assert [entry["report"]["topic"] for entry in payload["reports"]] == entities++[email protected]("left,right", [+ pytest.param("React", "Vue", id="plain"),+ pytest.param("vs.code", "vs.editor", id="dotted"),+ pytest.param("org/repo", "other/lib", id="repository"),+ pytest.param("vs.code/extension", "vs.editor/tool", id="dotted-repository"),+ pytest.param("https://example.com/vs.code", "https://example.org/vs.editor", id="url"),+])[email protected]("form", [+ pytest.param("{left} vs {right}", id="spaced-vs"),+ pytest.param("{left} vs. {right}", id="spaced-dotted-vs"),+ pytest.param("{left} versus {right}", id="versus"),+ pytest.param("{left} vs.{right}", id="compact-vs"),+ pytest.param("{left} vs vs {right}", id="repeated-vs"),+ pytest.param("{left} vs. vs. {right}", id="repeated-dotted-vs"),+ pytest.param("{left} versus versus {right}", id="repeated-versus"),+ pytest.param("{left} vs versus vs. {right}", id="mixed-separators"),+ pytest.param("vs {left} vs {right}", id="leading-vs"),+ pytest.param("vs. {left} vs.{right}", id="leading-dotted-vs"),+ pytest.param("versus {left} versus {right}", id="leading-versus"),+ pytest.param("vs vs. versus {left} versus vs. vs {right}", id="leading-and-repeated"),+])+def test_separator_tokens_preserve_entity_names(left, right, form, run_cli):+ topic = form.format(left=left, right=right)+ assert planner._comparison_entities(topic) == [left, right]+ payload = run_cli(topic)+ assert payload["comparison"] is True+ assert payload["entities"] == [left, right]+ assert [entry["report"]["topic"] for entry in payload["reports"]] == [left, right]diff --git a/tests/test_registers.py b/tests/test_registers.pyindex 6ebbde80..0ca53fd7 100644--- a/tests/test_registers.py+++ b/tests/test_registers.py@@ -269,7 +269,7 @@ def test_registers_do_not_shape_comparison_output():@pytest.mark.parametrize("topic",[- "alpha/beta",+ "React/Vue","alpha compared to beta","difference between alpha and beta",],@@ -282,6 +282,17 @@ def test_registers_use_canonical_comparison_detection(topic):).name == "default"[email protected]("topic", ["CI/CD", "alpha/beta", "https://example.com"])+def test_slash_topics_keep_single_topic_register_selection(topic):+ args = cli.build_parser().parse_args([topic])++ assert cli._audience_register_for_run(+ args, {"LAST30DAYS_REGISTER": "creator"}, None+ ).name == "creator"+ with pytest.raises(ValueError, match="unknown audience register 'board'"):+ cli._audience_register_for_run(args, {"LAST30DAYS_REGISTER": "board"}, None)++def test_registered_html_excludes_source_failure_diagnostics():report = fixture_report()report.source_status["x"] = schema.SourceOutcome(