{"id":50348081,"url":"https://github.com/redredchen01/content-syndicator","last_synced_at":"2026-05-29T20:01:33.246Z","repository":{"id":355775698,"uuid":"1229452250","full_name":"redredchen01/content-syndicator","owner":"redredchen01","description":"第三方口吻外鏈分發工具 v0.2 — 7平台並發LLM內容生成、lint審查、隊列調度發布、T+24h/T+7d/T+30d存活監控","archived":false,"fork":false,"pushed_at":"2026-05-05T07:33:18.000Z","size":538,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-05T08:33:30.285Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/redredchen01.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-05T03:59:47.000Z","updated_at":"2026-05-05T03:59:58.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/redredchen01/content-syndicator","commit_stats":null,"previous_names":["redredchen01/content-syndicator"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/redredchen01/content-syndicator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redredchen01%2Fcontent-syndicator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redredchen01%2Fcontent-syndicator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redredchen01%2Fcontent-syndicator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redredchen01%2Fcontent-syndicator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/redredchen01","download_url":"https://codeload.github.com/redredchen01/content-syndicator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redredchen01%2Fcontent-syndicator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33668186,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-29T02:00:06.066Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-05-29T20:01:31.588Z","updated_at":"2026-05-29T20:01:33.240Z","avatar_url":"https://github.com/redredchen01.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Multi-Platform Content Syndicator Agent (v0.2)\n\n**第三方口吻外鏈分發工具** — 編輯粘貼草稿，系統生成 7 個平台差異化變體，自動 lint 審查，一鍵批量發布，T+24h/T+7d/T+30d 存活監控。\n\n\u003e v0.1 描述：A local-first Node.js CLI MVP designed to extract content from a URL, use LLM (OpenAI) to generate an engaging Markdown article, and syndicate it to multiple blogging platforms (Dev.to, Telegra.ph, Medium) after manual approval, then logging the results to Google Sheets.\n\n## Features\n\n- **Web Scraping:** Uses Playwright and Mozilla Readability to extract clean article content and images from any URL.\n- **LLM Re-writing:** Re-writes and formats the extracted content into publish-ready Markdown using OpenAI.\n- **Human-in-the-Loop (HITL):** Pauses execution to preview the generated title and content. Requires manual confirmation before publishing.\n- **Damping/Brake (Rate Limiting):** Applies 5-15s random sleep between API requests to mitigate spam-flagging risks.\n- **Google Sheets Sync:** Automatically logs timestamp, original URL, generated title, and published URLs to your Google Sheet.\n\n## Setup Instructions\n\n### 1. Install Dependencies\n\n```bash\nnpm install\n```\n\n### 2. Configure Environment Variables\n\nCopy the `.env.example` to `.env`:\n\n```bash\ncp .env.example .env\n```\n\nFill in the `.env` values:\n\n- `OPENAI_API_KEY`: Get from [OpenAI Dashboard](https://platform.openai.com/api-keys).\n- `DEVTO_API_KEY`: Generate an API key from your Dev.to Settings -\u003e Extensions.\n- `MEDIUM_INTEGRATION_TOKEN`: Generate from Medium Settings -\u003e Security and Apps -\u003e Integration Tokens.\n- `GOOGLE_APPLICATION_CREDENTIALS_JSON`: Create a Google Cloud Project, enable Google Sheets API, create a Service Account, generate a JSON key, and minify it (or pass the path to the file if modified in code). Provide the raw JSON string here.\n- `GOOGLE_SHEET_ID`: The ID of your Google Sheet (found in the URL: `https://docs.google.com/spreadsheets/d/\u003cTHIS_IS_THE_ID\u003e/edit`). *Don't forget to share your Sheet with the email address of the Service Account (e.g., `xxx@your-project.iam.gserviceaccount.com`).*\n\n**Note on Telegra.ph:** Telegra.ph adapter handles its own anonymous account creation. No token is needed in `.env`.\n\n### 3. Run the Agent\n\n```bash\nnpm start\n```\n\n## Example Usage\n\n1. **Input:** `https://example.com/some-great-article`\n2. **LLM Output:** \"A highly engaging title based on the original\" and generated markdown.\n3. **Approve:** Type `y` or `N`.\n4. **Publishing:** \n   - Publishes to Telegra.ph... sleeps for 8s.\n   - Publishes to Dev.to... sleeps for 12s.\n   - Publishes to Medium...\n5. **Google Sheets Sync:** Appends a row with the generated links.\n\n## Limitations / Out of Scope (MVP v0.1)\n\n- Supports 3 MVP platforms only. WordPress, Tumblr, etc. are deferred to future iterations.\n- Playwright is used for scraping, but publishing relies entirely on APIs.\n- Captcha bypass and automated browser publishing are not handled in this version.\n- Ensure your Google Service Account has `Editor` access to the target Google Sheet.\n\n---\n\n## v0.2 項目結構\n\n```\nsrc/\n├── routes/          # Express 路由（publish, config, history, admin）\n├── services/\n│   ├── variant-generator.ts  # Unit 5: 7 平台並發 LLM 生成\n│   ├── anchor-generator.ts   # Unit 6: 錨詞 mini-prompt + 禁用詞校驗\n│   ├── lint/                 # Unit 7: Jaccard + regex lint 管道\n│   ├── brand-profile.ts      # Unit 3: 品牌資料庫校驗\n│   ├── anchor-monitor.ts     # Unit 11: 錨詞集中度 + 周上限\n│   └── queue/\n│       ├── scheduler.ts       # Unit 9: SQLite polling 調度器\n│       ├── publish-worker.ts  # Unit 10: 發布 handler\n│       ├── liveness-worker.ts # Unit 13: 存活檢查 handler\n│       ├── digest-job.ts      # Unit 13: 日終 digest\n│       └── sheets-jobs.ts     # Unit 12b: Sheets 維護作業\n├── llm/\n│   ├── client.ts      # OpenAI/Gemini 客戶端單例\n│   ├── index.ts       # invokeLLM (內容生成)\n│   └── agent-llm.ts   # invokeLLMWithTools (Agent 工具調用)\n├── sheets/index.ts    # GoogleSheetsClient (12 欄 Posts + Aggregates)\n├── db/\n│   ├── schema.ts      # 8 張表 DDL\n│   └── repositories.ts # publishJobs / anchorHistory / linkChecks / ...\n├── prompts/\n│   ├── personas/       # tech_blogger.md / personal_essay.md / reviewer.md\n│   └── anchor-generator.md\n└── utils/\n    ├── browserManager.ts # Playwright 單例 + semaphore\n    ├── parallel.ts        # 並發執行器（fail-safe）\n    └── smartRetry.ts      # 錯誤分類 + 斷路器\npublic/index.html          # Alpine.js SPA 前端\n```\n\n## v0.2 日常操作 SOP\n\n### 啟動\n\n```bash\nnpm start          # 前台運行（開發）\n./start.sh         # 後台運行 + 日誌輸出到 server.nohup.log\n```\n\n### 首次配置\n\n1. 配置 `.env`（LLM key、平台 API tokens、Google Sheets）\n2. 打開 `http://localhost:3000` → 品牌資料庫 → 填寫品牌資訊\n3. 確認頂部顯示「✓ 品牌資料已就緒」\n\n### 日常發布流程\n\n1. **文章發佈** 頁面 → 粘貼草稿（≥ 600 字符）\n2. 點「生成 7 個平台變體」（約 60-90 秒）\n3. 逐 tab 預覽，確認 lint 無警告\n4. 可跳過不需要的 tab，或點「重新生成本 tab」\n5. 點「一鍵發佈」→ 任務進入佇列\n6. **佇列狀態** 頁查看發布進度（5 秒自動刷新）\n\n### 存活監控\n\n- 每篇發布後自動入隊 T+24h / T+7d / T+30d 存活檢查\n- 結果回寫 `link_checks` 表 + Sheets `t24h_alive` 欄\n- 每月 1 號查 T+30d 存活率 \u003c 70% 時觸發 `logger.error` 告警\n\n### 每日自動任務（scheduler 負責）\n\n| 時間 | 任務 | 說明 |\n|------|------|------|\n| 整日  | publish / health_check_t* | 按 scheduled_at 自動執行 |\n| 04:00 | aggregate_sheets | 刷新 Sheets Aggregates 匯總 |\n| 04:30 | reconciliation | SQLite → Sheets 偏差補行 |\n| 18:00 | daily_digest | 發送日報（Telegram / Email / none）|\n\n### 故障排查\n\n```bash\n# 查看殭屍作業\nsqlite3 .data/syndicator.db \"SELECT * FROM publish_jobs WHERE status='running' AND updated_at \u003c datetime('now','-10 minutes');\"\n\n# 重置殭屍作業（scheduler 每分鐘自動執行，也可手動）\nsqlite3 .data/syndicator.db \"UPDATE publish_jobs SET status='failed_retryable' WHERE status='running' AND updated_at \u003c datetime('now','-10 minutes');\"\n\n# 查看存活率\nsqlite3 .data/syndicator.db \"SELECT check_type, COUNT(*) total, SUM(CASE WHEN classification IN ('alive','redirect_alive') THEN 1 ELSE 0 END) alive FROM link_checks GROUP BY check_type;\"\n\n# 查看 LLM 花費\nsqlite3 .data/syndicator.db \"SELECT DATE(created_at) as day, ROUND(SUM(cost_usd),4) as usd FROM llm_calls GROUP BY day ORDER BY day DESC LIMIT 7;\"\n```\n\n### 重跑 preflight 平台健康檢查\n\n```bash\nnpx tsx scripts/preflight-check.ts\n```\n\n輸出各平台 API 可達性矩陣，結果影響 `PLATFORM_HEAD_SUPPORTED` 常量（`src/constants.ts`）。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredredchen01%2Fcontent-syndicator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fredredchen01%2Fcontent-syndicator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredredchen01%2Fcontent-syndicator/lists"}