|
| 1 | +#!/usr/bin/env bash |
| 2 | +# |
| 3 | +# enrich-post.sh — dogfood pipeline: enrich a (possibly stale) blog post with |
| 4 | +# live data, composing tabstack's extract, generate, and research commands. |
| 5 | +# |
| 6 | +# 1. extract markdown — pull the post itself |
| 7 | +# 2. generate json — structure the post's leaderboard claims (stars, pricing) |
| 8 | +# 3. extract json ×N — re-extract LIVE star counts from each GitHub repo page |
| 9 | +# 4. research — what changed in the landscape since the post's date |
| 10 | +# 5. generate json — FAQ JSON-LD for the post (SEO/GEO enrichment) |
| 11 | +# |
| 12 | +# Output: enrichment/<slug>/ with raw artifacts + report.md (star-drift table, |
| 13 | +# landscape update with citations, ready-to-paste FAQ schema). |
| 14 | +# |
| 15 | +# Usage: scripts/enrich-post.sh [post-url] |
| 16 | + |
| 17 | +set -euo pipefail |
| 18 | + |
| 19 | +POST_URL="${1:-https://zero8.dev/blog/state-of-agentic-harnesses-march-2026}" |
| 20 | +SLUG=$(basename "$POST_URL") |
| 21 | +OUT="enrichment/$SLUG" |
| 22 | +TAB="bun run src/index.ts" |
| 23 | +mkdir -p "$OUT" |
| 24 | + |
| 25 | +echo "→ [1/5] extracting post" >&2 |
| 26 | +$TAB extract markdown "$POST_URL" --json > "$OUT/post.json" |
| 27 | + |
| 28 | +echo "→ [2/5] structuring the post's leaderboard claims" >&2 |
| 29 | +$TAB generate json "$POST_URL" \ |
| 30 | + --instructions "From the leaderboard section, list every coding tool that has a GitHub repo link. For each: tool name, the owner/repo slug from its github.com link, and the star count the article claims (convert 130.7K to 130700). Also record the article's data date." \ |
| 31 | + --schema '{ |
| 32 | + "type": "object", |
| 33 | + "properties": { |
| 34 | + "data_date": {"type": "string"}, |
| 35 | + "tools": {"type": "array", "items": {"type": "object", "properties": { |
| 36 | + "name": {"type": "string"}, |
| 37 | + "repo": {"type": "string"}, |
| 38 | + "claimed_stars": {"type": "number"} |
| 39 | + }, "required": ["name", "repo", "claimed_stars"]}} |
| 40 | + } |
| 41 | + }' > "$OUT/claims.json" |
| 42 | + |
| 43 | +echo "→ [3/5] re-extracting live star counts from GitHub (parallel)" >&2 |
| 44 | +mkdir -p "$OUT/live" |
| 45 | +while IFS=$'\t' read -r name repo; do |
| 46 | + ( |
| 47 | + $TAB extract json "https://github.com/$repo" --effort min --nocache \ |
| 48 | + --schema '{"type":"object","properties":{"stars":{"type":"number","description":"the repository star count as a full number, e.g. 130700 not 130.7K"}},"required":["stars"]}' \ |
| 49 | + > "$OUT/live/${repo//\//__}.json" 2>/dev/null \ |
| 50 | + || echo '{"stars": null}' > "$OUT/live/${repo//\//__}.json" |
| 51 | + ) & |
| 52 | +done < <(jq -r '.tools[] | [.name, .repo] | @tsv' "$OUT/claims.json") |
| 53 | +wait |
| 54 | + |
| 55 | +echo "→ [4/5] researching what changed since the post's date" >&2 |
| 56 | +DATA_DATE=$(jq -r '.data_date // "March 2026"' "$OUT/claims.json") |
| 57 | +$TAB research "What has changed in the AI agentic coding tool landscape since $DATA_DATE (today is June 2026)? Cover: major releases or new features in Claude Code, OpenCode, Gemini CLI, Codex CLI, Cursor, Cline, Aider, Goose, and Copilot; any pricing changes; any new credible entrants or notable shutdowns/acquisitions." \ |
| 58 | + --mode fast --json > "$OUT/research.ndjson" |
| 59 | +jq -r 'select(.event=="complete") | .data.report' "$OUT/research.ndjson" > "$OUT/research.md" |
| 60 | +jq -c 'select(.event=="complete") | .data.metadata.citedPages // .data.metadata.cited_pages // []' "$OUT/research.ndjson" > "$OUT/citations.json" |
| 61 | + |
| 62 | +echo "→ [5/5] generating FAQ JSON-LD from the post" >&2 |
| 63 | +$TAB generate json "$POST_URL" \ |
| 64 | + --instructions "Write 5 FAQ question/answer pairs a developer choosing an agentic coding tool would ask, answered strictly from this article's content. Questions should match real search queries." \ |
| 65 | + --schema '{ |
| 66 | + "type": "object", |
| 67 | + "properties": {"faq": {"type": "array", "items": {"type": "object", "properties": { |
| 68 | + "question": {"type": "string"}, |
| 69 | + "answer": {"type": "string"} |
| 70 | + }, "required": ["question", "answer"]}}} |
| 71 | + }' > "$OUT/faq.json" |
| 72 | + |
| 73 | +# ---- stitch the report ----------------------------------------------------- |
| 74 | + |
| 75 | +echo "→ assembling $OUT/report.md" >&2 |
| 76 | +{ |
| 77 | + echo "# Enrichment report: $SLUG" |
| 78 | + echo |
| 79 | + echo "Post: $POST_URL · article data date: $DATA_DATE · enriched: $(date +%Y-%m-%d)" |
| 80 | + echo |
| 81 | + echo "## Star drift (claimed vs live)" |
| 82 | + echo |
| 83 | + echo "| Tool | Repo | Article | Live now | Δ |" |
| 84 | + echo "|------|------|--------:|---------:|--:|" |
| 85 | + while IFS=$'\t' read -r name repo claimed; do |
| 86 | + live=$(jq -r '.stars // empty' "$OUT/live/${repo//\//__}.json" 2>/dev/null || true) |
| 87 | + if [[ -n "$live" && "$live" != "null" ]]; then |
| 88 | + delta=$(( ${live%.*} - ${claimed%.*} )) |
| 89 | + printf '| %s | %s | %s | %s | %+d |\n' "$name" "$repo" "$claimed" "$live" "$delta" |
| 90 | + else |
| 91 | + printf '| %s | %s | %s | _extract failed_ | — |\n' "$name" "$repo" "$claimed" |
| 92 | + fi |
| 93 | + done < <(jq -r '.tools[] | [.name, .repo, .claimed_stars] | @tsv' "$OUT/claims.json") |
| 94 | + echo |
| 95 | + echo "## What changed since $DATA_DATE (researched, with citations)" |
| 96 | + echo |
| 97 | + cat "$OUT/research.md" |
| 98 | + echo |
| 99 | + echo "### Sources" |
| 100 | + echo |
| 101 | + jq -r '.[] | "- [\(.title // "untitled")](\(.url))"' "$OUT/citations.json" |
| 102 | + echo |
| 103 | + echo "## FAQ JSON-LD (paste into the post's <head>)" |
| 104 | + echo |
| 105 | + echo '```html' |
| 106 | + echo '<script type="application/ld+json">' |
| 107 | + jq '{"@context": "https://schema.org", "@type": "FAQPage", "mainEntity": [.faq[] | {"@type": "Question", "name": .question, "acceptedAnswer": {"@type": "Answer", "text": .answer}}]}' "$OUT/faq.json" |
| 108 | + echo '</script>' |
| 109 | + echo '```' |
| 110 | +} > "$OUT/report.md" |
| 111 | + |
| 112 | +echo "done: $OUT/report.md" >&2 |
0 commit comments