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
+14 -3
View File
@@ -6,13 +6,13 @@ Everything starts from your **company profile** (what you sell, to whom, in what
| Module | What it does | Status |
|--------|--------------|--------|
| Content | Drafts posts from partner and competitor news and your own products; you review them and publish to X, LinkedIn and Reddit | Phase 1 |
| Content | Drafts posts from partner and competitor news and your own products; you review them and publish to X, LinkedIn and Reddit | Phase 1, in progress: X and LinkedIn work |
| Prospects | Finds companies and people who fit your targets; the ones you approve go into your Core's EspoCRM through Hermes | Phase 2 |
| SEO | Audits your websites for Google, Bing/DuckDuckGo and Brave, and opens fixes as pull requests on your Hugo repositories | Phase 3 |
| Metrics | Pipeline influence, CAC, CLV and NRR, from Stripe, EspoCRM and Plausible | Phase 4 |
| Sites | Builds pages and sites from a component library and publishes them through Gitea | Phase 5 |
This version is Phase 0, the foundation: the web app, the company profile, the inventory, the AI provider, credentials, and the bridge to your Core through Hermes. The old terminal app's post queue is imported and kept for the Content module. See [PLAN.md](PLAN.md) for the whole plan.
This version has the foundation (Phase 0): the web app, the company profile, the inventory, the AI provider, credentials, and the bridge to your Core through Hermes. It also has the first part of the Content module (Phase 1): fetching, writing drafts, and publishing to X and LinkedIn. See [PLAN.md](PLAN.md) for the whole plan.
## Install
@@ -90,6 +90,16 @@ Hermes' sandbox can only reach the hub once it's in `network.allowedDomains` in
To check the connection, open **Core & Hermes** in Supermarket and ask Hermes the question shown there. Hermes lists the hub's tools and reports them back to Supermarket, which shows when it last heard from Hermes.
## Writing and publishing posts
1. Fill in the **Profile** (posts are written in its voice) and choose an **AI provider** under Settings.
2. Add partners and competitors to the **Inventory**, with the places to watch: an X handle, hashtags, a YouTube channel, RSS feeds.
3. Under **Content**, open an entry and press **Fetch new**. Supermarket reads every source that has credentials, starting where the last fetch ended (or a week back).
4. Select items, choose the channels, and press **Write drafts**: one post from all of them, or one per item. Each channel gets its own draft.
5. On **Drafts**, edit and publish each one. The source link is added when publishing (on X it counts toward the 280 characters, and the counter includes it). A failed draft keeps its error and can be published again; the other channel's draft is unaffected.
Reading X needs a bearer token from an X API plan with read access; YouTube needs a free API key; RSS needs nothing. Posting needs the sign-ins below.
## Signing in to X and LinkedIn
Sign-ins come back to Supermarket at `http://localhost:8470/auth/<provider>/callback`. Register these callback URLs in your apps:
@@ -123,7 +133,8 @@ SUPERMARKET_DATA=/tmp/cm SUPERMARKET_ADDR=127.0.0.1:8470 go run ./cmd/supermarke
| `internal/ai` | AI providers: Anthropic (official Go SDK) and OpenAI-compatible servers |
| `internal/mcpserver`, `internal/bridge` | The `/mcp` endpoint and Hermes' check-ins |
| `internal/legacy` | One-time import from the old terminal app |
| `internal/api`, `internal/fetcher` | X, LinkedIn and YouTube clients, kept for the Content module |
| `internal/content` | The Content module: fetched items, per-channel drafts, prompts, publishing |
| `internal/api`, `internal/fetcher` | X, LinkedIn, YouTube and RSS clients, and fetching for an inventory entry |
| `hermes/setup.sh` | Connects Hermes |
Database changes go in `internal/db/db.go` as a new migration; never edit one that has shipped.