diff --git a/cheddahbot/tools/content_creation.py b/cheddahbot/tools/content_creation.py index bc070e6..96ddc66 100644 --- a/cheddahbot/tools/content_creation.py +++ b/cheddahbot/tools/content_creation.py @@ -310,6 +310,7 @@ def _build_phase2_prompt( cora_path: str, is_service_page: bool = False, capabilities_default: str = "", + content_path: str = "", ) -> str: """Build the Phase 2 prompt for writing full content from an approved outline. @@ -359,6 +360,14 @@ def _build_phase2_prompt( "\nWrite publication-ready content following the outline structure. " "Include all entity targets and keyword placements as noted in the outline." ) + + if content_path: + parts.append( + f"\n**IMPORTANT — Save the final content as HTML to this exact path:**\n" + f"`{content_path}`\n" + f"Do NOT save to the local project directory or working/ folder." + ) + return "\n".join(parts) @@ -1025,12 +1034,28 @@ def _run_phase2( if not cora_path: cora_path = existing_state.get("cora_path", "") + # Compute save path for the final content HTML (network share with local fallback) + slug = _slugify(keyword) or "unknown" + content_path = "" + if config.content.outline_dir: + primary = Path(config.content.outline_dir) / slug + try: + primary.mkdir(parents=True, exist_ok=True) + content_path = str(primary / "final-content.html") + except OSError as e: + log.warning("Network path unavailable (%s), falling back to local: %s", primary, e) + if not content_path: + local = _LOCAL_CONTENT_DIR / slug + local.mkdir(parents=True, exist_ok=True) + content_path = str(local / "final-content.html") + # ClickUp: move to automation underway if task_id: _sync_clickup_start(ctx, task_id) prompt = _build_phase2_prompt( - url, keyword, outline_text, cora_path, is_service_page, capabilities_default + url, keyword, outline_text, cora_path, is_service_page, capabilities_default, + content_path=content_path, ) log.info("Phase 2 — writing full content for '%s' (%s)", keyword, url)