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
feat: improve html brief handoff
Trevin Chow9961d4396f7c
diff --git a/skills/last30days/SKILL.md b/skills/last30days/SKILL.mdindex cb15cd7c..1123be28 100644--- a/skills/last30days/SKILL.md+++ b/skills/last30days/SKILL.md@@ -1853,7 +1853,7 @@ Close with `I have all the links to the {N} {source list} I pulled from. Just as- Read `references/save-html-brief.md` BEFORE proceeding to WAIT FOR USER'S RESPONSE- Follow that file's instructions exactly - it is the canonical source for the save flow-- Append the confirmation line (`π Shareable brief saved to <path>`) to your already-emitted chat response+- End with the artifact handoff defined there: saved HTML path, local open/view affordance when available, and a concise confirmation for explicit `--emit=html` / `--html` requests**You MUST NOT:**@@ -1862,6 +1862,7 @@ Close with `I have all the links to the {N} {source list} I pulled from. Just as- Save to a different path than the reference specifies- Add data quality warnings, debug headers, or safety notes to the saved HTML- Re-research the topic for the HTML render - the engine cache covers the second invocation+- Upload or publish the HTML anywhere public in this flow**Why the directive is forceful:** the reference file is the only source of truth for the save flow. Skipping it produces broken artifacts - wrong path conventions, missing synthesis content, leaked engine debug output, or warnings that don't belong in shareable docs.diff --git a/skills/last30days/references/save-html-brief.md b/skills/last30days/references/save-html-brief.mdindex 686f2bcf..f654ce25 100644--- a/skills/last30days/references/save-html-brief.md+++ b/skills/last30days/references/save-html-brief.md@@ -2,11 +2,15 @@This reference file is loaded by the main `SKILL.md` when the user asked for an HTML brief (either explicitly via `--emit=html` / `--emit:html` / `--html`, or in natural language - "give me a shareable HTML brief", "for Slack", "for Notion", "export as HTML", etc.). The detection happens in `SKILL.md` so that the common no-HTML path stays short; the implementation lives here.-The contract: the synthesis still appears in chat as the primary output. The HTML is an additional artifact saved to disk for sharing. Both happen in the same turn.+The contract has two modes:++- **Explicit HTML export** (`--emit=html`, `--emit:html`, or `--html`): the HTML artifact is the primary output. Write the synthesis to the temp file, render the HTML, then give a concise artifact handoff in chat instead of pasting the full Markdown report again.+- **Normal report plus HTML copy** (the user asks in prose for an HTML brief while also expecting the report in chat): the synthesis still appears in chat as the primary output. The HTML is an additional artifact saved to disk for sharing. Both happen in the same turn.## When to fire this flow-- After you have already emitted the full chat response: badge, "What I learned:" (or comparison title), bold-lead-in paragraphs with citations, KEY PATTERNS list, engine footer pass-through, invitation block.+- For normal-report-plus-HTML mode: after you have already emitted the full chat response: badge, "What I learned:" (or comparison title), bold-lead-in paragraphs with citations, KEY PATTERNS list, engine footer pass-through, invitation block.+- For explicit-HTML-export mode: after you have drafted the synthesis that will go into the HTML, before emitting the final chat response.- BEFORE the WAIT FOR USER'S RESPONSE pause.- ONLY if the user asked. Do NOT save HTML when the user didn't ask for it.@@ -66,12 +70,50 @@ fi# For a scoped --hiring-signals brief, --hiring-signals MUST be here too so# the footer reflects the jobs-scoped board, not a generic crawl.-# 3. Append ONE line to your already-emitted chat response, after the-# invitation block. Use a paperclip emoji as a visible signal that an-# artifact was produced:-echo "π Shareable brief saved to $HTML_PATH"+# 3. Finish with the artifact handoff described below.+printf 'π Shareable brief saved to %s\n' "$HTML_PATH"```+## Chat handoff after saving++Use the mode that matches the request.++### Explicit HTML export++When the user explicitly supplied `--emit=html`, `--emit:html`, or `--html`, do **not** paste the full Markdown report back into chat after saving the artifact. The user asked for a file; repeating the Markdown makes the run feel like a normal report with an attachment bolted on.++Respond with a concise handoff:++```text+π last30days v{VERSION} Β· synced {YYYY-MM-DD}++π Shareable brief saved to <absolute HTML path>++Open it locally:+- macOS: `open "<absolute HTML path>"`+- Linux: `xdg-open "<absolute HTML path>"`+- Windows: `start "" "<absolute HTML path>"`++I saved the full HTML brief locally. It is not uploaded or published anywhere.+```++If the host can safely open local files for the user and doing so matches the user's request, run the local open command after the file is written, leave the saved-path line in chat, and add `Opened locally.` If the command fails or the host is headless, do not treat that as a failed report; show the path and manual open command.++### Normal report plus HTML copy++When the user asked for a normal `/last30days` report and also asked for an HTML copy, keep the full chat synthesis and append this artifact block after the invitation:++```text+π Shareable brief saved to <absolute HTML path>++Open it locally:+- macOS: `open "<absolute HTML path>"`+- Linux: `xdg-open "<absolute HTML path>"`+- Windows: `start "" "<absolute HTML path>"`+```++Do not offer public publishing or upload in this flow. Hosted sharing is a separate opt-in capability and must not happen automatically.+## What ends up in the HTML fileThe engine's `--emit=html` renderer combines:@@ -91,7 +133,7 @@ Same flow when the topic is `X vs Y` (or `X vs Y vs Z`). The engine routes throu## Follow-up turn-If the user runs `/last30days OpenClaw` normally, sees the synthesis in chat, and THEN says "save that as HTML" or "give me a shareable version" in a follow-up turn, do the same save flow on the synthesis you wrote in the previous turn. Do not re-research; the synthesis is already in the conversation history. Just write it to the temp file and call the engine with `--emit=html --synthesis-file`.+If the user runs `/last30days OpenClaw` normally, sees the synthesis in chat, and THEN says "save that as HTML" or "give me a shareable version" in a follow-up turn, do the same save flow on the synthesis you wrote in the previous turn. Do not re-research; the synthesis is already in the conversation history. Just write it to the temp file and call the engine with `--emit=html --synthesis-file`, then use the normal-report-plus-HTML artifact block.## What NOT to do@@ -99,8 +141,8 @@ If the user runs `/last30days OpenClaw` normally, sees the synthesis in chat, an- Do NOT add content to the temp file beyond your synthesis prose. The badge / footer / colophon come from the engine.- Do NOT change the file path convention. `${LAST30DAYS_MEMORY_DIR}/${SLUG}-brief.html` is the canonical location.- Do NOT silently overwrite an existing file. The `--emit=html` output is written via a shell redirect (`>| "$HTML_PATH"`), which OVERWRITES the collision-guarded path β use `>|` not `>` because `set -o noclobber` refuses plain `>` when the file already exists. The collision guard in step 2 handles same-topic re-runs: if `{slug}-brief.html` already exists it date-suffixes to `{slug}-brief-YYYY-MM-DD.html`. Always print whichever path the redirect actually used.-- Do NOT include the data quality warning text in the temp file or in your final chat line. Warnings are an engine-stderr concern, not an artifact concern.+- Do NOT publish, upload, or send the HTML to a third-party service. This reference only saves and opens local files.## Edge casesdiff --git a/tests/test_html_save_contract.py b/tests/test_html_save_contract.pynew file mode 100644index 00000000..c4810310--- /dev/null+++ b/tests/test_html_save_contract.py@@ -0,0 +1,45 @@+"""Contract tests for the /last30days HTML save handoff."""++from pathlib import Path++ROOT = Path(__file__).resolve().parents[1]+SKILL_MD = ROOT / "skills" / "last30days" / "SKILL.md"+SAVE_HTML = ROOT / "skills" / "last30days" / "references" / "save-html-brief.md"+++def test_skill_routes_html_to_reference_and_artifact_handoff():+ text = SKILL_MD.read_text(encoding="utf-8")+ start = text.index("## SHAREABLE HTML BRIEF")+ end = text.index("## WAIT FOR USER'S RESPONSE", start)+ section = text[start:end]++ assert "Read `references/save-html-brief.md`" in section+ assert "artifact handoff" in section+ assert "local open/view affordance" in section+ assert "Upload or publish" in section+ assert "Append the confirmation line" not in section+++def test_explicit_html_export_is_artifact_first_not_full_markdown_repeat():+ text = SAVE_HTML.read_text(encoding="utf-8")+ assert "**Explicit HTML export**" in text+ assert "the HTML artifact is the primary output" in text+ assert "do **not** paste the full Markdown report back into chat" in text+ assert "The user asked for a file" in text+++def test_html_handoff_includes_local_open_commands_without_requiring_success():+ text = SAVE_HTML.read_text(encoding="utf-8")+ for snippet in [+ 'open "<absolute HTML path>"',+ 'xdg-open "<absolute HTML path>"',+ 'start "" "<absolute HTML path>"',+ "If the command fails or the host is headless",+ ]:+ assert snippet in text+++def test_html_save_flow_does_not_publish_or_upload():+ text = SAVE_HTML.read_text(encoding="utf-8")+ assert "Do not offer public publishing or upload in this flow" in text+ assert "Do NOT publish, upload, or send the HTML to a third-party service" in text