fix: re-render press context with reader_mode=True in no-AI fallback path (#137)
_render_press_section_no_ai() was stripping AI instructions from the pre-rendered press-context.md file, which was generated WITHOUT reader_mode=True. This meant the narrative divergence format introduced in PR #136 was never used in the no-AI CI path. The fix loads the raw techcrunch and correlations JSON files and calls render_press_context(..., reader_mode=True) directly. The old strip-based approach is retained as a fallback when raw files are unavailable. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Juan Manuel Servera committed
May 19, 2026 at 21:58 UTC
6293e42700067e0283e827a89f0bdcebfe619be4
1 file changed
+17
scripts/analyze_fallback.py
+17
@@ -352,6 +352,23 @@ def _render_press_section_no_ai(press_context_path: Path | None) -> str:
352
"correlation analysis between developer activity and industry coverage, "
353
"highlighting press-driven hype versus organic growth patterns."
354
)
355
+
356
+ # Try to re-render from raw data using reader_mode=True so the narrative
357
+ # divergence format (from PR #136) is used instead of the AI-prompt format.
358
+ stem = press_context_path.stem # e.g. "2026-W21-press-context"
359
+ week = stem.replace("-press-context", "") # e.g. "2026-W21"
360
+ data_dir = press_context_path.parent.parent # data/analyzed/ -> data/
361
+ tc_path = data_dir / "raw" / f"{week}-techcrunch.json"
362
+ corr_path = data_dir / "analyzed" / f"{week}-correlations.json"
363
+
364
+ if tc_path.exists():
365
+ from scripts.render_press_context import render_press_context, load_json as rpc_load_json
366
+ tc_data = rpc_load_json(tc_path)
367
+ corr_data = rpc_load_json(corr_path) if corr_path.exists() else {}
368
+ if tc_data is not None:
369
+ return render_press_context(tc_data, corr_data or {}, week, reader_mode=True)
370
+
371
+ # Fallback: strip AI instructions from the pre-rendered file.
372
content = press_context_path.read_text(encoding="utf-8").strip()
373
return _strip_ai_instructions(content)
374