Phase 1, part 3: Reddit

- Sign in with a Reddit web app; access tokens refresh automatically,
  and an app-only token reads rules before sign-in.
- Reddit drafts: a title and text for one subreddit, chosen when
  writing. The subreddit's guidelines and rules go into the prompt, which
  asks for a community member's post that discloses the affiliation and
  avoids marketing language.
- The Inbox shows the subreddit's rules (cached for a day, with Refresh)
  and warns, without blocking, about promotion rules, restricted
  subreddits, link-only subreddits, posting in the same subreddit within
  a week, more than 1 in 10 recent posts linking to the company's sites,
  and new accounts.
- Publishing makes a text post with the source link at the end, or a
  link post where the subreddit takes only links.
- Migration 4 adds the draft's title and subreddit, and the rules cache.
  Publishers now take a Post, which carries the title and subreddit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-20 13:51:16 -07:00
co-authored by Claude Opus 5.5
parent b0f06058ec
commit 0e34f574b7
27 changed files with 1404 additions and 91 deletions
+30 -18
View File
@@ -330,7 +330,7 @@ mcphub failed.
### Phase 1: Content (today's pipeline, generalized) + Reddit
**Status (2026-11-20): parts 1 and 2 of 4 built on `phase0-foundation`.** Phase 1 is
**Status (2026-11-20): parts 1, 2 and 3 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
@@ -366,7 +366,28 @@ Part 2 (commit `f275f03`):
- The container now runs in the computer's time zone (`SUPERMARKET_TZ` in
compose.env, from /etc/localtime), so times show and parse correctly.
**Not yet tried for real.** Parts 1 and 2 are covered by tests with fake AI
Part 3, Reddit:
- A third channel, `reddit`: a draft has a `title` and a `target`
subreddit (migration 4), chosen when writing, with suggestions from the
entry's and the profile's subreddits. Reddit is never pre-checked.
- Sign-in through a Reddit "web app" (`duration=permanent`; scopes
identity, submit, read, history). The hour-long access token is
refreshed on a 401 and saved. Before sign-in, rules are read with an
app-only token (client credentials).
- Subreddit info (description, posting guidelines, rules, allowed post
types) is cached in `subreddits` for a day. It goes into the prompt and
is shown with the draft, with a Refresh button.
- The prompt asks for a community member's post that says where they work:
no hashtags, emoji or marketing language, following the rules.
- Publishing: a text post with "Source: <link>" at the end, or a link post
where the subreddit takes only links.
- Warnings, never blocking (`content.RedditWarnings`): promotion-related
rules, restricted subreddits, wrong post type, a post in the same
subreddit in the past 7 days, more than 1 in 10 recent posts linking to
the company's own sites (counting this one), and a new account. They use
the account's last 100 posts, cached for 10 minutes.
**Not yet tried for real.** Parts 1–3 are covered by tests with fake AI
and channel clients, and the rebuilt app runs (schema 3). But the
installed app has no profile, AI key, inventory or social sign-ins yet, so no
real fetch, generation or post has been made. Before relying on it:
@@ -376,6 +397,9 @@ real fetch, generation or post has been made. Before relying on it:
3. Connect X and LinkedIn, publish one draft now, schedule one a few
minutes ahead, and check that both go out, with UTM tags on a link to
the company's site.
4. Register a Reddit web app, connect it, write a Reddit draft for a
subreddit, and check its rules and warnings. Post to a test subreddit
you moderate first.
The database before migration 2 is backed up at
`~/.local/share/supermarket/app.db.pre-phase1`. Commits on
@@ -384,23 +408,11 @@ so `git push` can't prompt from Claude Code). The branch stays off `main`
until the user decides to merge; posting works again now, which was the
condition for merging.
**To pick this up: part 3, Reddit** (item 4):
- OAuth for a Reddit "web app" (callback
`http://localhost:8470/auth/reddit/callback`), stored like X's and
LinkedIn's tokens, with refresh. A third channel, `reddit`: a draft is a
title plus body, written for one subreddit.
- Subreddits come from the profile's accounts and the inventory entries.
Show each subreddit's rules (`/r/<sub>/about/rules`) next to the draft,
and its self-promotion limits.
- Every Reddit post needs explicit approval, so never "publish all".
Warn about posting too often: per subreddit, and the share of the
account's posts that link to the company.
- Caveat: Reddit's Data API terms require approval for commercial use.
Low-volume, human-approved posting from a personal app is the intended
scope; say so in the README.
**To pick this up: part 4, own-product promotion** (the rest of item 3):
drafts from the product list, the company's blog RSS, site pages and
releases, with `kind` = `product`.
Then part 4, own-product promotion: drafts from the product list, the
company's blog RSS, site pages and releases, with `kind` = `product`.
The plan for Phase 1, as first written:
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.