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
+8 -7
View File
@@ -14,6 +14,7 @@ import (
"supermarket/internal/ai"
"supermarket/internal/bridge"
"supermarket/internal/content"
"supermarket/internal/core"
"supermarket/internal/inventory"
"supermarket/internal/profile"
@@ -51,6 +52,7 @@ type step struct {
type module struct {
Name, Phase, Body string
Link string // set once the module is usable
}
func (s *Server) dashboard(w http.ResponseWriter, r *http.Request) {
@@ -97,15 +99,14 @@ func (s *Server) dashboard(w http.ResponseWriter, r *http.Request) {
}
modules := []module{
{"Content", "Phase 1", "Draft posts from partner and competitor news and your own products; review and publish to X, LinkedIn and Reddit."},
{"Prospects", "Phase 2", "Find companies and people who fit your targets, and add the ones you approve to EspoCRM through Hermes."},
{"SEO", "Phase 3", "Audit your websites and open fixes as pull requests on your Hugo repositories."},
{"Metrics", "Phase 4", "Pipeline influence, CAC, CLV and NRR from Stripe, EspoCRM and Plausible."},
{"Sites", "Phase 5", "Build pages and sites from a component library and publish them through Gitea."},
{"Content", "Phase 1", "Draft posts from partner and competitor news and your own products; review and publish to X, LinkedIn and Reddit.", "/content"},
{"Prospects", "Phase 2", "Find companies and people who fit your targets, and add the ones you approve to EspoCRM through Hermes.", ""},
{"SEO", "Phase 3", "Audit your websites and open fixes as pull requests on your Hugo repositories.", ""},
{"Metrics", "Phase 4", "Pipeline influence, CAC, CLV and NRR from Stripe, EspoCRM and Plausible.", ""},
{"Sites", "Phase 5", "Build pages and sites from a component library and publish them through Gitea.", ""},
}
var queued int
_ = s.DB.QueryRow(`SELECT count(*) FROM posts`).Scan(&queued)
queued, _ := content.CountDrafts(s.DB)
s.render(w, r, "dashboard", page{Title: "Overview", Nav: "home", Data: map[string]any{
"Steps": steps,