Replace the old Go TUI with a web app (port 8470) that runs in a container as a CoreDesktop sibling: - cmd/supermarket server with htmx web UI: dashboard, company profile, inventory (partners/competitors), AI and credential settings, and a Core & Hermes page - SQLite storage and a secrets store under ~/.local/share/supermarket - AI providers (Anthropic, OpenAI-compatible) behind one interface - MCP server and a Hermes bridge to the Federated Core MCP hub - Import of the old Coremarketing TUI's state - install.sh / update.sh / lib.sh, Dockerfile, compose.yaml, the bin/supermarket launcher and hermes/setup.sh Posting is not wired back up yet; that comes in Phase 1. See PLAN.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
23 KiB
Supermarket transformation plan
From a single-purpose "Social Curator" TUI for Federated Computer to a general marketing suite: a local web app, run in Docker, that any company running a Federated Core can install as a CoreDesktop sibling.
1. Decisions so far
| Topic | Decision |
|---|---|
| Name | Supermarket (renamed from Coremarketing on 2026-11-19; the old TUI's data path ~/.local/state/coremarketing keeps its name) |
| Distribution | A CoreDesktop sibling: sibling add <url> installs it, update keeps it current |
| Interface | A local web app in Docker at http://localhost:8470, on this machine only |
| Scope | One company per install. A company can have several websites |
| Core MCP / EspoCRM | Reached through the local Hermes agent, which gets an mcp_servers entry for the Core's MCP hub |
| Billing data | Stripe first, for CAC, CLV and NRR |
| Existing content work | Kept. The hard-coded app list becomes the Inventory of partners and competitors |
| Websites and components | The suite builds the company's websites from a reusable component library |
| Publishing | Sites are pushed to a Gitea repository. The user sets up the hooks that publish it to the Hugo server |
| Contact enrichment | Third-party services allowed, behind a pluggable interface (section 6) |
| Suite shape | One repo, one app with modules (Content, Prospects, SEO, Metrics, Sites), plus an MCP endpoint for agents |
2. Requirements from the notes
| Note | Where it lands |
|---|---|
| Coredesktop sibling | Phase 0: install.sh / update.sh run Docker Compose and set up Hermes |
| Generalize for any company | Phase 0: the company profile replaces everything Federated-specific |
| Company description and targets | Company profile: products, ideal customer profile, voice, websites, accounts |
| Connect to AI provider | Phase 0: Anthropic, or any OpenAI-compatible server (Ollama, LM Studio, …) |
| Create and send content to X, LinkedIn, Reddit | Phase 1: Content module, built on today's pipeline, + Reddit |
| Find prospects → EspoCRM via Core MCP | Phase 2: Prospects module; CRM writes go through Hermes |
| SEO suggestions, change the Hugo repo | Phase 3: SEO module, with changes opened as PRs on Gitea |
| SEO for Google, Brave, DuckDuckGo | Phase 3: Search Console, Bing Webmaster + IndexNow (DuckDuckGo results come mostly from Bing), Brave Search API for rank tracking |
| Top-of-funnel lead generation | Content + SEO + prospecting + landing-page forms that create EspoCRM Leads |
| Pipeline influence, CAC, CLV, NRR | Phase 4: Metrics module (Stripe + EspoCRM via Hermes + Plausible) |
| Website, components | Phase 5: Sites module and component library |
| Static file hosting on Core | Phase 5: push to a Gitea repo; the user's hooks deploy it |
3. Architecture
Runtime
Browser / GNOME app-grid launcher (CoreDesktop `webapp add`)
│ http://localhost:8470
▼
┌──────────────── supermarket container ────────────────┐
│ Go server: web UI (HTML + htmx) · JSON API · /mcp │
│ Background jobs: fetch, generate, publish, Stripe sync, │
│ SEO crawls, scheduled posts │
│ Tools in the image: git, hugo │
└───────┬───────────────────────────────▲─────────────────┘
│ bind mount │ /mcp (bearer token)
▼ │
~/.local/share/supermarket/ ┌──────┴─────── Hermes (sandboxed) ──┐
app.db (SQLite) · secrets │ mcp_servers: │
sites/ · logs/ │ supermarket → localhost:8470 │
~/.config/coredesktop/core.conf │ mcphub → Core MCP hub ───────────┼──► EspoCRM
(read-only: domain, email) │ cron job: run the CRM queue │ (and other
└────────────────────────────────────┘ Core apps)
- Go stays. The fetchers, AI client, X/LinkedIn clients, OAuth flows, X weighted-length counting and the atomic store all carry over. The Bubble Tea UI is replaced by server-rendered pages with htmx: no Node build step, a single small image, and the existing code is reused nearly as is.
- Localhost only. The port is published as
127.0.0.1:8470:8080, so other machines can't reach it (it doesn't depend on ufw-docker), and the app needs no login of its own. The/mcpendpoint requires a bearer token. - OAuth for X, LinkedIn, Reddit, Google and Bing redirects back to
http://localhost:8470/auth/<provider>/callback. This replaces today'ssupermarket authcommand onlocalhost:8080. Developer apps need the new redirect URI registered. - Local AI servers. The container reaches a server on this machine through
host.docker.internal(extra_hosts: host-gateway), and LAN or tailnet servers through the host's routing. The app offers the servers that CoreDesktop'sconfigure ai-serversset up. - Secrets. The container can't reach GNOME's keyring, so the app's own
tokens live in
/data/secrets(mode 0600, never in the repo or the image). The Core MCP hub credential is not held by the app; it lives in Hermes'~/.hermes/.env. - No inbound webhooks. Nothing on the internet can reach the app, so Stripe and the social platforms are polled. Stripe's Events API makes this cheap.
- Data in SQLite. That means one file to back up. The existing
posts.json,dismissed.jsonandstate.jsonare imported on first start.
The Hermes bridge (Core MCP → EspoCRM)
Hermes is the only thing that talks to the Core's MCP hub. The app and Hermes meet through the app's own MCP endpoint, so Hermes is configured with two MCP servers.
The block install.sh adds to ~/.hermes/config.yaml. The hub URL comes
from core.conf and the user confirms it. Each ${…} reference is resolved
from ~/.hermes/.env, so config.yaml holds no secret:
mcp_servers:
mcphub:
url: "https://mcphub.<CORE_DOMAIN>/sse?as_user=<CORE_USER>"
headers:
Authorization: "Basic ${MCPHUB_AUTH}"
supermarket:
url: "http://127.0.0.1:8470/mcp"
headers:
Authorization: "Bearer ${SUPERMARKET_MCP_TOKEN}"
~/.hermes/.env (written through hermes config set, which routes
UPPER_SNAKE names to .env):
MCPHUB_AUTH=<base64 of user:password, from a hidden prompt>
SUPERMARKET_MCP_TOKEN=<random, generated by install.sh, also in /data/secrets>
How install.sh does it, safely and idempotently:
- It uses
unsandboxed hermes config set mcp_servers.<name>.…, the way CoreDesktop'sconfigure hermescalls Hermes. Hermes edits its YAML with comment-preserving ruamel, so we never hand-edit its 2,400-line config. If anmcphubentry already exists, it's left alone. - It asks whether Hermes may reach
mcphub.<CORE_DOMAIN>and127.0.0.1:8470. On yes, it adds them tonetwork.allowedDomainsin~/.config/coredesktop/sandbox/hermes.json. Hermes' sandbox blocks both by default, and that file is the one no sandbox can write. - It stops the gateway (
hermes gateway stop; Hermes starts it on demand) so the servers load, then checks that Hermes lists the hub's tools. - The README documents the same block, with placeholders, for anyone setting it up by hand.
How work flows through Hermes:
- Writes (the CRM queue). The app never calls EspoCRM itself. Approved
actions (create Lead, update Lead, add note, link Account) wait in a queue
with their exact payloads and an idempotency key. A Hermes cron job
installed by
install.shruns every 15 minutes. It callssupermarket.crm_pending_actions, searches EspoCRM for duplicates, runs each action throughmcphub's EspoCRM tools, and reports back withsupermarket.crm_report_result(id, espo_id | error). You can also trigger a run by asking Hermes, in its terminal or over Matrix. - Reads (for dedupe and metrics). The same job pulls Leads, Accounts and
Opportunities changed since the last sync and hands them to
supermarket.crm_ingest. The app keeps a cached copy in SQLite. - Guardrails. Hermes only carries out actions the app has queued; it doesn't decide what goes into the CRM. Every result is checked against the next read sync, and failures show in the app's CRM queue page with a retry button.
- Fallback. The
crmpackage has an interface. If having an LLM in the loop proves too slow or unreliable for bulk writes, a direct MCP client in the app can replace Hermes without changing the modules.
Repo layout
cmd/supermarket/ server entry point
internal/
profile/ company, products, ICP, voice, websites
inventory/ partners & competitors (was config `applications:`)
ai/ provider interface: anthropic, openai-compatible
core/ core.conf, Core service URLs (Gitea, Plausible, MCP hub)
crm/ CRM queue + cached CRM data; executed by Hermes via mcphub
enrich/ contact-enrichment providers (Hunter, Apollo, …)
channels/ Publisher interface: x, linkedin, reddit
sources/ fetchers: x, youtube, rss/blog, reddit, (instagram)
content/ generation, drafts, approval, schedule, history ← today's pipeline
prospects/ discovery, enrichment, review, queue to CRM
seo/ crawler, checks, search-engine APIs, Hugo change sets
gitea/ clone, branch, PR, repo creation (SEO + Sites)
billing/ Stripe sync, MRR model, customer↔account matching
metrics/ pipeline influence, CAC, CLV, NRR
sites/ component library, page generation, publishing
mcp/ MCP tools over the modules (incl. the CRM bridge tools)
web/ handlers, templates, static assets
store/ SQLite + migrations
hermes/ cron job prompt + skill for the CRM bridge
Dockerfile · compose.yaml · install.sh · update.sh
Sibling scripts
install.sh(safe to re-run; it may prompt):- Checks that Docker is running and that the user is in the
dockergroup. - Creates
~/.local/share/supermarketand migrates~/.local/state/coremarketing/config.yamlif it's there. - Runs
docker compose up -d --build. - Adds the app-grid launcher with
webapp add Supermarket http://localhost:8470. - Sets up the Hermes bridge as described above, or explains how to run
configure hermesfirst if Hermes has no model provider yet. - Registers
/mcpwith Claude Code (claude mcp add --transport http …) so it can drive the suite too.
- Checks that Docker is running and that the user is in the
update.sh(doesn't prompt): runsdocker compose up -d --build, which only rebuilds when the source changed, and refreshes the Hermes cron job and skill if they changed. It never touches the Hermes credentials. Schema migrations run when the app starts.restart: unless-stoppedkeeps the app running across reboots, so scheduled posts and syncs run without the browser open.
4. Domain model
Company profile (one per install)
- Name, description, positioning, voice and tone, words to avoid
- Products: name, description, URL, pricing summary, key benefits
- Ideal customer profile / targets: industries, company size, roles, regions, problems, buying signals, technologies they use
- Websites (many): URL, Gitea repo and branch, Plausible site, Search Console property, Bing site
- Accounts: X handle, LinkedIn org/author, Reddit user, subreddits
- Keywords to rank for
The first time it runs, a wizard drafts the profile from the company's main website with the AI, and the user edits it.
Inventory (partners and competitors)
The current applications: list becomes the Inventory. Each entry has the same
fields as today (name, description, X handle, YouTube channel, Instagram,
hashtags) plus:
| Field | Purpose |
|---|---|
relationship |
partner, competitor or watch |
websites, linkedin, subreddits, rss |
More places to watch |
keywords |
Terms they own or compete on |
talking_points |
Partners: how we work together. Competitors: how we differ, where we win, what not to claim |
mention_policy |
Competitors: name them, or speak about the category without naming them |
What each relationship drives:
- Partner: today's behavior. Their news is fetched, and posts that amplify it in our voice (co-promotion) are drafted for review.
- Competitor: counter-programming. Their launches, price changes, outages
and announcements trigger drafts that position our product, under the
entry's
mention_policy. Also: " alternative" landing-page ideas, keyword-gap analysis against their sites, and prospects: companies that use the competitor's product (technographics), and people asking for alternatives on Reddit and X. - Watch: only ecosystem news to curate, with no promotion either way.
Migration: entries from the old config are imported as partner (they are
the apps on a Federated Core), and the user re-labels them. The Federated list
ships as an example import file, examples/federated-inventory.yaml, not as a
default.
5. Phases
Each phase ends usable and with a release tag (v0.x.0).
Phase 0: Foundation: web app, sibling, profile, Hermes bridge
Status (2026-11-18): built on branch phase0-foundation. Items 1–7 are
done, and so is the tooling for item 8. What changed from the plan:
- No Hermes cron job yet. Until Phase 2 there's no queued work, and every run of the job is an LLM call. The bridge is tested by asking Hermes the check-in question shown on the app's "Core & Hermes" page. The cron job arrives with the CRM queue.
- AI per task: each task can use its own model, on the same provider.
- The old TUI is gone. Its post queue, dismissed items and last-checked times are imported into SQLite, and its X/LinkedIn/YouTube clients and fetcher are kept for Phase 1. Until Phase 1 lands, there's no way to post.
Still to do for item 8, on a real CoreDesktop machine: run install.sh,
ask Hermes the check-in question, and confirm that sandboxed Hermes reaches
127.0.0.1:8470 and lists the hub's EspoCRM tools.
- Restructure into the layout above. Port config and the JSON stores to SQLite, with import from the old files.
- Dockerfile (multi-stage: Go build → slim runtime with git and hugo) and
compose.yaml. install.sh/update.shas above, followingcoredesktop/skills/sibling-project-format.md.- Web shell: navigation between the modules, a settings page, a credentials
page with OAuth "Connect" buttons, and a Core status page (whether
core.confwas found, whether Gitea and Plausible answer, and when the Hermes bridge last ran). - Company profile + the wizard that drafts it from the website.
- AI provider layer: choose the provider and model per task, and test the connection.
- Inventory module: list, edit, import (from the old config and from YAML), and relationship labels.
- Hermes bridge test (do this early, since Phases 2 and 4 depend on it):
- Can sandboxed Hermes reach
127.0.0.1:8470once it's inhermes.json? Each sandbox has its own network; LAN servers work this way, but this machine's loopback is untested. - Does
hermes config setwrite nestedmcp_servers.*.headerskeys correctly? - What EspoCRM tools does the hub expose?
- Can Hermes cron jobs call MCP tools?
- How reliable is a run of 50 queued actions?
- Can sandboxed Hermes reach
Phase 1: Content (today's pipeline, generalized) + Reddit
- 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.
- Generation prompts are built from the profile, the inventory entry's relationship and talking points, and the target channel.
- Content types: partner amplification, competitor counter-programming, promotion of our own products (from the product list, site pages, blog RSS, and releases).
- Reddit: OAuth, subreddit list, each subreddit's rules shown with the draft, approval always required, warnings about posting too often.
- Scheduling queue, an approval inbox for drafts from all modules, and UTM tags on every link so Metrics can attribute visits.
Phase 2: Prospects → EspoCRM
- Discovery from the profile's targets, from these sources:
- company search (enrichment provider, Brave Search API)
- technographics (companies using a competitor's product)
- intent signals on Reddit and X
- Enrichment through the
enrichproviders: people by role at a target company, work email, LinkedIn profile URL, and email verification. LinkedIn itself isn't scraped. - Review screen: why each prospect fits, where each contact came from, verification status, dedupe against the cached CRM data, then accept → the CRM queue → Hermes → an EspoCRM Lead with source and campaign set.
- Compliance: the source and date are recorded for every contact, plus a suppression list that is checked before anything is queued.
- Inbound: the lead-form component (Phase 5) queues a Lead the same way.
Phase 3: SEO, for all of the company's websites
- Audit each website: titles, meta descriptions, headings, canonical URLs, sitemap, robots.txt, JSON-LD, Open Graph, broken links, alt text, Core Web Vitals (PageSpeed Insights API).
- Content gaps: the profile's keywords and the competitors' sites from the Inventory, compared with ours.
- Search engines: Google Search Console API, Bing Webmaster API, IndexNow on publish, and Brave Search API rank tracking.
- Apply fixes: clone the site's Gitea repo into
/data/sites/, make the changes on a branch, check thathugostill builds, show the diff in the UI, and open a PR on Gitea. Nothing is pushed to the default branch. Merging the PR is the user's decision, and their hooks publish it. - Before/after tracking for each change.
Phase 4: Metrics, with Stripe
- Stripe sync: a restricted, read-only key; customers, subscriptions, invoices, credit notes and refunds; a full backfill, then incremental updates through the Events API.
- MRR model: MRR per customer per month, normalized from subscription items (annual ÷ 12, with discounts, trials and pauses handled), classified as new, expansion, contraction, churn or reactivation.
- Matching Stripe customers to EspoCRM Accounts (from the cached CRM data) by email domain or stored ID, with a screen to fix the matches it gets wrong.
- Spend log for CAC: entered by hand or imported from CSV, by channel and month (Stripe has no marketing spend). Enrichment provider costs can be logged automatically.
| Metric | Definition | Sources |
|---|---|---|
| Pipeline influence | Value of open and won opportunities with at least one marketing touch (UTM visit, form, prospect push, engagement with a post), by channel | EspoCRM (via Hermes), Plausible, the app's own history |
| CAC | Spend ÷ new paying customers, per month and per channel | Spend log, Stripe (first paid invoice) |
| CLV | ARPA × gross margin ÷ monthly churn rate, plus actual cumulative revenue per cohort | Stripe; gross margin set in settings |
| NRR | (Starting MRR + expansion − contraction − churn) ÷ starting MRR, monthly and trailing-12-month, by cohort | Stripe MRR model |
- A dashboard with CSV export. It can also be published as a page on one of the company's sites.
Phase 5: Sites and components
- Component library: a Hugo theme module with section partials (hero,
features, cards, steps, pricing, stats, FAQ, comparison table, testimonial,
lead form, final CTA) on the
sections:front-matter pattern fromwebcoredesktop, themed from the profile (colors, fonts, logo). It lives in its own Gitea repo and is versioned, so the company's sites can pull updates. - Site builder: create a new site from the library (which creates its
Gitea repo through the API), or add pages to an existing one (landing,
product, " alternative" and comparison pages, blog posts) from
the profile, the Inventory and SEO findings. Changes are always PRs.
Preview runs
hugo serverinside the container. - Publishing = merging into the site repo's publish branch on Gitea. The user's Gitea hooks deploy it to their Hugo server. The app shows the last merge, and checks the live site afterwards to confirm it changed.
6. Contact enrichment: suggested services
"Enrichment" means: given a target company (or a person's name), find the people in the roles you sell to, their work email and LinkedIn URL, and check that the email is deliverable. These are good candidates; check current pricing before choosing:
| Service | What it's good for | Notes |
|---|---|---|
| Hunter.io | Emails at a company's domain, email finder by name, verification | Simple API, small free tier, cheap paid plans. A good first provider |
| Apollo.io | Searching people by title, seniority, industry and company size; returns email and LinkedIn URL | Largest database here. API access requires a paid plan. A strong second |
| People Data Labs | Person and company enrichment API for developers, paid per record | Good for bulk; little UI, which suits us |
| Snov.io / Prospeo | Finder + verifier, lower cost | Alternatives to Hunter |
| BuiltWith or Wappalyzer | Technographics: which companies use a given product | Feeds competitor counter-programming |
| ZeroBounce / NeverBounce | Verification only | Use if the finder's own verification isn't enough |
Recommendation: build the enrich interface with Hunter first (company
domain → people → verified email). Add Apollo for searching people by role,
and BuiltWith/Wappalyzer to find companies that use a competitor. Each user
brings their own API keys, and the app logs credits used as spend for CAC.
7. Order and dependencies
Phase 0 (incl. Hermes bridge test) ──► Phase 1 (content)
│
├──► Phase 2 (prospects) ── needs: Hermes bridge, mcphub EspoCRM tools
├──► Phase 3 (SEO) ──────── needs: Gitea token
├──► Phase 4 (metrics) ──── needs: Stripe key; CRM reads for pipeline
└──► Phase 5 (sites) ────── needs: Gitea token
Phases 1, 3, 5 and the Stripe half of 4 depend only on Phase 0.
8. Open questions
- MCP hub credentials: the example authenticates as an admin and uses
as_user=to act as the user. Can the hub issue per-user credentials or tokens instead? An admin password in each desktop's Hermes.envgives an agent that reads untrusted web content admin access to the Core. - MCP hub URL: is it always
mcphub.<CORE_DOMAIN>, so it can be worked out fromcore.conf? - Gitea: which Gitea do sites live on (the Core's, at
gitea.<CORE_DOMAIN>?), and should the app get its token from the user or from Gitea's OAuth?