Phase 1, part 1: fetch, write and publish posts from the web app

Brings back posting, which Phase 0 removed with the terminal interface.

- Content page: per inventory entry, fetch its X account, X hashtag
  search, YouTube channel and RSS/Atom feeds (new), then select, dismiss
  or restore the fetched items, which are kept in the database.
- Writing: one AI call returns a draft per channel (X and LinkedIn),
  prompted from the company profile, the entry's relationship, talking
  points and mention policy, and each channel's rules. Fetched text is
  quoted as untrusted. An over-long X draft gets one request to shorten.
- Drafts page: edit with a live length counter that counts like X, then
  publish each draft on its own. A draft is claimed before posting so it
  can't go out twice; failures are kept on the draft for a retry; X
  tokens are refreshed and saved.
- Migration 2 adds content_items and drafts, and turns queued posts into
  drafts for the platforms they hadn't reached.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-20 12:58:24 -07:00
co-authored by Claude Opus 5.5
parent abf410d097
commit 13bf18facc
29 changed files with 2484 additions and 95 deletions
+18
View File
@@ -329,6 +329,24 @@ mcphub failed.
- How reliable is a run of 50 queued actions?
### Phase 1: Content (today's pipeline, generalized) + Reddit
**Status (2026-11-20): part 1 of 4 built on `phase0-foundation`.** Phase 1 is
built in four parts, each committed on its own: (1) the pipeline, items 1–2
below, for X and LinkedIn; (2) the approval inbox, schedule and UTM tags,
item 5; (3) Reddit, item 4; (4) promoting our own products, the rest of
item 3. Part 1:
- One generation writes **one draft per channel** (a short X post, a longer
LinkedIn post), each edited, published and retried on its own. The old
`posts` table became the `drafts` table (migration 2), one row per
platform a queued post hadn't reached.
- Fetching reads the entry's X account, X hashtag search, YouTube and RSS
feeds (new). Items are stored in `content_items`. A fetch only moves the
entry's start time on if every source answered.
- Prompts come from the profile, the entry's relationship, talking points
and mention policy, and the channel. Fetched text is marked as untrusted
quotes. An X draft over the limit gets one request to shorten it.
- Publishing claims the draft first (`publishing`), so it can't post twice;
a draft left `publishing` by a restart is marked failed for review.
1. Port fetch → browse → select → generate → approve → publish into the web
UI, keeping the dismiss feature, tracking of what was posted where, partial
posting, and X length handling.