Files
davidandClaude Opus 5.5 e2a72d5ef9 Phase 5 part 5: check the live site after a merge
Merged Sites pages are checked on the live site until they answer with
their own words and title; removed ones until they're gone. The SEO loop,
the page, the signal's page and Sites → Publishing check (or Check now);
two hours without the page points at the deploy hook. Pages going live or
away go to IndexNow. Sites → Publishing lists what's waiting, open pull
requests and recent merges. Schema 24.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 14:28:42 -07:00

1479 lines
85 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 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) |
| AI for the app | Uses Hermes' Anthropic key and model when the user agrees (2026-11-20), copied to `hermes-ai.json` by `supermarket hermes` and `update.sh`. It calls the model directly, never through Hermes: post writing reads untrusted web text, which must not reach an agent with tools and CRM access |
| 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); rankings from Search Console (decided 2026-11-22) |
| 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 `/mcp` endpoint requires a bearer token.
- **OAuth** for X, LinkedIn, Reddit, Google and Bing redirects back to
`http://localhost:8470/auth/<provider>/callback`. This replaces today's
`supermarket auth` command on `localhost: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's `configure ai-servers` set 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 (see Future
enhancements: back up and restore). The existing
`posts.json`, `dismissed.json` and `state.json` are 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:
```yaml
mcp_servers:
mcphub:
url: "https://mcphub.<CORE_DOMAIN>/sse?as_user=<CORE_USER>"
transport: sse
headers:
Authorization: "Basic ${MCPHUB_AUTH}"
supermarket:
command: socat
args: ["STDIO", "UNIX-CONNECT:<data folder>/mcp.sock"]
```
**Why a socket, not `http://127.0.0.1:8470/mcp`** (found 2026-11-19).
CoreDesktop runs Hermes under srt, in its own network namespace. Hermes
always dials loopback directly, never through the proxy, and finds nothing
there. srt's proxy, in turn, refuses any name that resolves to loopback.
Unix sockets are allowed in Hermes' sandbox, so the app serves stdio-style
MCP on `/data/mcp.sock`, and Hermes runs `socat` as a stdio MCP server. The
socket is 0600, which is the same protection as the token file beside it.
The HTTP endpoint with its bearer token stays for unsandboxed agents
(Claude Code).
**`~/.hermes/.env`**:
```
MCPHUB_AUTH=<the user's own hub token from the Core (the part after "Basic "), from a hidden prompt>
```
How `install.sh` does it, safely and idempotently:
1. It uses `unsandboxed hermes config set mcp_servers.<name>.…`, the way
CoreDesktop's `configure hermes` calls Hermes. Hermes edits its YAML
with comment-preserving ruamel, so we never hand-edit its 2,400-line config.
If an `mcphub` entry already exists, it's left alone.
2. It asks whether Hermes may reach `mcphub.<CORE_DOMAIN>`. On yes, it adds
it to `network.allowedDomains` in
`~/.config/coredesktop/sandbox/hermes.json`. Hermes' sandbox blocks it
by default, and that file is the one no sandbox can write.
3. 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.
4. 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.sh` runs every 15 minutes. It calls
`supermarket.crm_pending_actions`, searches EspoCRM for duplicates, runs
each action through `mcphub`'s EspoCRM tools, and reports back with
`supermarket.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 `crm` package 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):
1. Checks that Docker is running and that the user is in the `docker` group.
2. Creates `~/.local/share/supermarket` and migrates
`~/.local/state/coremarketing/config.yaml` if it's there.
3. Runs `docker compose up -d --build`.
4. Adds the app-grid launcher with
`webapp add Supermarket http://localhost:8470`.
5. Sets up the Hermes bridge as described above, or explains how to run
`configure hermes` first if Hermes has no model provider yet.
6. Registers `/mcp` with Claude Code (`claude mcp add --transport http …`) so
it can drive the suite too.
- `update.sh` (doesn't prompt): runs `docker 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-stopped` keeps 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: "<competitor> 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.
**Status (2026-11-20): Phase 0 is done, on `phase0-foundation`.** Item 8
works end to end: Hermes loads the hub's tools and checks in with the app.
What item 8 turned up:
- Sandboxed Hermes **can't** reach `127.0.0.1:8470` (see "Why a socket" in
the Hermes bridge section), so it reaches the app through `/data/mcp.sock`
with `socat`.
- `hermes config set` writes nested `mcp_servers.*` keys correctly, lists
(`args`) included.
- The hub rejected the shared admin token (401 at Traefik). The Core moved
to per-user tokens, still sent as `Authorization: "Basic <token>"`, with
`as_user=<user>` kept. The setup asks for the token, checks it with the
hub, and `supermarket hermes --reconfigure` re-enters it.
- The hub (FastMCP "mcpserver-hub" 3.2.0) speaks only SSE: a POST to `/sse`
gets 405. Hermes tries Streamable HTTP first, and that try ran out of its
60-second connect time, so setup.sh sets `transport: sse`. `tools/list`
takes about 10 seconds.
- A running Hermes gateway keeps its old servers, and `gateway stop` from
outside the sandbox didn't always stop it. setup.sh now checks the pid
file and says so when the gateway is still running.
- The hub offers 213 tools: Nextcloud 155, Listmonk 29, Superpanel 9,
Baserow 8, Plausible 6 and EspoCRM 6 (`espocrm_search_records`,
`espocrm_get_record`, `espocrm_get_related_records`,
`espocrm_create_record`, `espocrm_update_record`,
`espocrm_delete_record`). Hermes reports them with its own `mcp__mcphub__`
prefix, and the app stores the hub's names. Phase 2 builds on the generic
EspoCRM record tools.
- The per-user token also sees `nextcloud_admin_list_users` and
`nextcloud_admin_get_contacts`, both described as admin-only. To raise with
the Core's developer: it isn't known yet whether the hub blocks them for
non-admins.
Next: Phase 1, under way (see below).
Supermarket's half can be checked before the token arrives: ask Hermes the
check-in question now. It should reach `bridge_checkin` and note that
mcphub failed.
1. Restructure into the layout above. Port config and the JSON stores to
SQLite, with import from the old files.
2. Dockerfile (multi-stage: Go build → slim runtime with git and hugo) and
`compose.yaml`.
3. `install.sh` / `update.sh` as above, following
`coredesktop/skills/sibling-project-format.md`.
4. Web shell: navigation between the modules, a settings page, a credentials
page with OAuth "Connect" buttons, and a Core status page (whether
`core.conf` was found, whether Gitea and Plausible answer, and when the
Hermes bridge last ran).
5. Company profile + the wizard that drafts it from the website.
6. AI provider layer: choose the provider and model per task, and test the
connection.
7. Inventory module: list, edit, import (from the old config and from YAML),
and relationship labels.
8. **Hermes bridge test** (do this early, since Phases 2 and 4 depend on it):
- ~~Can sandboxed Hermes reach `127.0.0.1:8470` once it's in
`hermes.json`?~~ No. Answered 2026-11-19: it uses the MCP socket instead.
- ~~Does `hermes config set` write nested `mcp_servers.*.headers` keys
correctly?~~ Yes.
- What EspoCRM tools does the hub expose?
- Can Hermes cron jobs call MCP tools?
- How reliable is a run of 50 queued actions?
### Phase 1: Content (today's pipeline, generalized) + Reddit
**Status (2026-11-20): Phase 1 is built (all 4 parts) 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. The user chose per-channel drafts and this order on 2026-11-20.
Part 1 (commit `13bf18f`):
- 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.
Part 2 (commit `f275f03`):
- **Inbox** (top-level menu, with a count): everything waiting for
approval, one section per module; Content's drafts for now. Phase 2's
prospects and Phase 3's SEO changes add sections.
- **Scheduling**: a draft is published now or scheduled (`scheduled`,
`publish_at`, migration 3). A scheduler in the app checks every 30
seconds. A post more than 12 hours overdue (the computer was off) goes
back to Posts rather than out stale, and so does one refused before
posting (signed out, too long). Content has Scheduled and Published tabs.
- **UTM tags** only on links to the company's websites and product URLs
(from the profile), added at publishing; drafts are stored untagged.
`utm_source` = channel, `utm_medium` = social, `utm_campaign` = kind of
post, `utm_content` = entry slug and draft ID.
- The container now runs in the computer's time zone (`SUPERMARKET_TZ` in
compose.env, from /etc/localtime), so times show and parse correctly.
Part 3, Reddit (commit `0e34f57`):
- 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.
Part 4, promoting our own products:
- A virtual inventory entry for the company (`content.OwnEntry`, items
stored under `_own`), shown first under Content as the company's name and
served at `/content/own`. It isn't stored in `inventory`.
- Products from the profile are kept in step as items
(`product:<slug>`, source `Product`), always there to pick from; they
don't count as waiting news.
- A new profile field, **Feeds**: the company's blog, news and release
feeds, fetched like an entry's RSS.
- Site pages: new or updated pages from each website's `sitemap.xml`
(sitemap indexes one level deep), newest 15 per fetch, with each page's
title and description. This runs only for the company's own sites.
- Drafts get kind `product` (so `utm_campaign=product`) and the company's
name. The prompt asks for posts that promote the company's own work with
claims the material supports. On Reddit it asks for the makers' voice and
invites feedback, and Posts warns that self-promotion is often
restricted.
**Tried for real on 2026-11-21:** publishing to X and LinkedIn worked (LinkedIn needed the "Sign In with LinkedIn using OpenID Connect" product; X's callback must use 127.0.0.1). Reddit refuses new API apps without approval, so Reddit drafts are posted by hand. The full hand-testing checklist is now TEST.md; the steps below were the first one.
**Originally deferred on 2026-11-21 for the UI redesign below.** Parts 1–4 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:
1. Fill in the Profile, add an Anthropic key, and add an inventory entry
with an RSS feed (needs no credentials).
2. Fetch, write drafts, and check Posts's prompts and lengths.
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.
5. Add a product and a blog or releases feed to the profile, open
Content → (company name), fetch, and write a post from a product.
The database before migration 2 is backed up at
`~/.local/share/supermarket/app.db.pre-phase1`. Commits on
`phase0-foundation` are pushed from a host terminal (no credential helper,
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.
**UI redesign (2026-11-21).** The user asked for brain
(gitea.federated.computer/Federated_Computer/brain, a Next.js + Tailwind
app) to be the UI basis from now on. Supermarket stays Go templates + htmx;
it takes brain's look rather than its stack: brain's colour tokens, type,
radius and shadows (and its dark theme, following the system setting), a
left sidebar with search at the top and Settings at the bottom, a top bar
with breadcrumbs, and Settings as grouped tabs on the left. The menu:
Search, Overview (module cards and setup), Inventory, then the modules
(Content with Posts (was Inbox, renamed 2026-11-21), Sources, Scheduled and Published; the later phases
shown greyed out). Settings holds Profile, Social accounts (was
Credentials; keys and sign-in together per network), Core & Hermes, and AI
(provider, model, and the API keys, which moved there from Credentials).
Old addresses (`/profile`, `/core`, `/settings/credentials`) redirect.
Search (`/search`) matches every word across posts, fetched items, the
inventory, products and settings pages. New modules add a `modules` entry
in `internal/web/server.go` and an icon in `layout.html`. brain's fonts
(DM Sans, Plus Jakarta Sans) are named but not bundled, so the system font
is used unless they're installed.
**To pick this up:** try Phase 1 for real (the checklist above), fix what
that turns up, then decide whether to merge `phase0-foundation` into `main`
and tag `v0.1.0`. Then Phase 2, Prospects → EspoCRM, which depends on the
hub's EspoCRM tools (see Phase 0: `espocrm_search_records`,
`espocrm_get_record`, `espocrm_get_related_records`,
`espocrm_create_record`, `espocrm_update_record`, `espocrm_delete_record`).
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.
2. Generation prompts are built from the profile, the inventory entry's
relationship and talking points, and the target channel.
3. Content types: partner amplification, competitor counter-programming,
promotion of our own products (from the product list, site pages, blog RSS,
and releases).
4. Reddit: OAuth, subreddit list, each subreddit's rules shown with the draft,
approval always required, warnings about posting too often.
5. Scheduling queue, an approval inbox for drafts from all modules, and UTM
tags on every link so Metrics can attribute visits.
### Phase 2: Buying signals, prospects and the funnel
**Started 2026-11-21** on branch `phase2-prospects`, after Phase 0 and 1
were merged into `main` and tagged `v0.1.0`. **Parts 1 to 7 built, and
merged into `main` on 2026-11-22** (d23d5e2). Part 8 (Hugo pages per
signal) waits for Phase 5. Not yet tried against the live services:
discovery's web search, outreach's mailbox, Stripe and Plausible (no keys
saved yet), and the CRM bridge, which waits on the Core's MCP hub.
**Reframed 2026-11-21 (the user's direction).** Phase 2 is built around
**buying signals**: hypotheses about why a company buys now, which are
defined, found, and then *tested* through direct action (email, LinkedIn)
and indirect action (social posts, blog posts, website and landing pages),
with results measured through the whole funnel to payment in Stripe.
Content is tested against signals and signals against content. Later, the
Hugo sites (Phase 5) create, duplicate and delete pages from this
feedback loop. origami.chat and explee.com, where signals and prospects
are already being tested, feed their results in.
**A signal** has: a name; the hypothesis ("teams complaining about the
Microsoft 365 price rise will switch within a quarter"); how to spot it
(Claude web search queries, social keywords, origami.chat / explee.com
criteria); the angle (pain and promise) for messages and content; a status
(idea, testing, proven, retired); and a slug used as `utm_campaign`.
**Everything is tagged with a signal and recorded in one funnel-event
log** (signal, channel, prospect/contact/content, stage, date, value), so
the scorecard is one query and new sources drop in without rework.
Stages, each of which counts as a success where it happens:
```
found → contacted/reached → replied → clicked the scheduling link / booked
→ visited the website or a landing page → signed up (trial, free tier) → paid
(then expanded or churned)
```
Channels: email, LinkedIn, social posts, blog posts, website pages,
origami.chat, explee.com. The **scorecard** shows, per signal and per
channel, the count at each stage and the conversion between them, revenue,
cost (AI, Hunter, origami.chat and explee.com fees) and CAC; and per piece
of content, which signal it serves and how it did. Numbers will be small:
it shows counts plainly, and a signal is "proven" only past a threshold
the user sets.
**How each stage is measured.** Supermarket runs on localhost and nothing
on the internet can reach it, so it can't use tracking pixels or its own
link redirects. Instead:
- *Replied*: IMAP on the Core's mail server reads replies to Supermarket's
emails (matched by Message-ID / thread). "STOP"-style replies go on the
suppression list.
- *Scheduling link*: the link carries UTM tags and goes through the website
or Cal.com on the Core; bookings come from Cal.com (stronger than a
click), visits from Plausible.
- *Website / landing page*: Plausible, by `utm_campaign` (the signal) and
`utm_content` (the piece of content or message). Measured per signal in
aggregate, not per person: following individuals around the website
would cut against Federated's privacy positioning.
- *Signed up / paid*: Stripe (read-only restricted key). A payment is tied
to a signal through the CRM (Stripe customer email/domain → EspoCRM
Account → prospect → signal), and, for self-serve sign-ups, through the
UTM campaign saved in Stripe metadata at sign-up. Customers buy through
Federated's shopping cart, which uses Stripe, so the cart has to pass the
visitor's UTM tags into the Stripe Checkout session's metadata.
- *origami.chat / explee.com*: their APIs.
**Sending email (the user's decision):** Supermarket sends through
mail.federated.computer on the Core (SMTP, with IMAP for replies). Every
email is drafted from the signal's angle, reviewed, and sent one by one at
a low daily limit, with a plain opt-out line; the suppression list is
checked before sending. Recommended: a dedicated mailbox, and SPF, DKIM
and DMARC checked first, so outreach can't hurt the domain's normal mail.
**LinkedIn** can't be automated (its API doesn't allow messaging, and
automation risks the account): Supermarket drafts the message and opens
the profile, the user sends it and marks it sent, as with Reddit posts.
**origami.chat and explee.com have APIs** (checked 2026-11-21, not yet
tried with a key): origami.chat has a typed API at
`https://origami.chat/api/v3` (Leads, Send, Account; long-running Jobs;
webhooks; an MCP server); explee.com has a public API at
`https://api.explee.com` (company search with natural-language queries and
`criteria` scoring; API key from Organization Settings; OpenAPI schema at
`/public/api/openapi.json`). Before building: what each returns for a
campaign's results (replies, meetings), and their terms on storing the
data. Each becomes an adapter behind a `leadsource` interface.
**Parts, in order, a commit after each:**
1. **The CRM bridge** (done, 1dc5476): the queue, the Hermes job, the read
sync, the CRM queue page. Its live test waits on the Core's MCP hub,
which connects to EspoCRM at a stale LAN address.
2. **Prospects and review** (done, 7633697): companies and contacts with
provenance, Review (accept → Account / Lead), adding by hand, CRM
duplicate warnings, the suppression list, search.
3. **Signals and the funnel**: the signal library, tagging prospects with
a signal, the funnel-event log, the scorecard (with what exists so far),
and importing origami.chat and explee.com results through their APIs,
so the scorecard starts with real data. **Built 2026-11-21**
(schema 7): `signals` (library, statuses, utm slug), `funnel_events`
(stage, channel, subject, email, campaign, source, external ID for
dedupe, count, value), `outside_campaigns` (assigned to a signal by the
user), the Signals scorecard (period and channel filters, people once
per stage, revenue, spend), the signal page (funnel by channel,
campaigns, latest steps), prospects tagged with a signal (filter, change,
"found" recorded), outcomes recorded by hand on prospects, and Settings
→ Lead sources. The explee.com import follows its typed OpenAPI schema
(campaigns, analytics, contacted leads, hot leads); the origami.chat
import reads loose JSON by the names in its docs (campaigns, stats,
enrolled people, replies) and its Test button shows the real responses,
to confirm with the user's key. Webhooks need a public address, so both
are polled every 6 hours.
4. **Discovery per signal**: saved Claude web searches belonging to a
signal, run on a schedule, each prospect with its citation; explee.com
company search as a second source. **Built 2026-11-21** (schema 8):
`internal/discovery`, `ai.Research` (the SDK's `web_search_20260209`
server tool, `pause_turn` resumed, sources gathered from search results
and citations), a company kept only when its evidence URL is among the
pages searched, exclusions (ours, inventory, prospects, CRM Accounts,
suppressed), explee.com `search/companies` with the hypothesis as a
criterion and strong matches only, `discovery_runs` with notes and
search counts, the signal page's Find companies card (polls while
running), and an every-7/14/30-days schedule. Not yet run against the
live API.
5. **Enrichment with Hunter**: the right people and verified emails at
accepted companies. **Built 2026-11-22** (schema 9):
`internal/api/hunter` (Domain Search, Email Finder, Email Verifier with
its 202 polling, Account; credits read from `X-Credits-Used`),
`internal/enrich` (find people at a company's domain by the departments,
seniority and number chosen in Settings → Lead sources; find a named
person's address; verify addresses, singly or all unchecked ones in New,
stopping when the key, credits or rate limit give out), and
`enrich_runs`, which keeps every call with its result and credits. The
buttons are on Review, for new and accepted companies alike; people
found go to New under their company. Nothing runs on a schedule, since
every call spends credits. Credits are counted but not yet turned into
spend for CAC (Hunter.io bills by plan, not per credit).
6. **Direct outreach**: email through the Core's mail server (drafted,
reviewed, sent, replies read over IMAP) and LinkedIn by hand; each
outcome recorded in the funnel. **Built 2026-11-22** (schema 10):
`internal/outreach` and the `outreach` table. Drafts come from the AI
(task "outreach") with the signal's hypothesis and angle, the person,
their company and their history. The queue sends one email at a time
(net/smtp, STARTTLS on 587 or TLS on 465) within the sending hours, the
daily limit and a gap. Before each send it checks the suppression list,
bouncing addresses, and anyone emailed in the last 14 days. Emails are
plain text with the signature, an opt-out line, `List-Unsubscribe`,
UTM-tagged links to our sites (utm_campaign = the signal) and a
Message-ID kept for matching replies; a copy goes to Sent via IMAP
APPEND. The inbox is read every 10 minutes with emersion/go-imap,
read-only (EXAMINE, BODY.PEEK), from the last UID. A reply is matched
by In-Reply-To/References, or else by sender. Out-of-office replies are
skipped. Bounces mark the address invalid. "Stop" replies go on the
suppression list. LinkedIn messages are copied and sent by hand, then
marked sent and replied. Sent counts as Contacted and a reply as Replied.
Settings → Email has the mailbox (password in `secrets.json`), the
limits, the signature, an optional scheduling link, and a check (SMTP
and IMAP sign-in, SPF, DKIM at common selectors, DMARC). Follow-up
sequences aren't automatic yet: a second draft to the same person is
written as a follow-up, and can go after 14 days.
7. **Indirect and the end of the funnel**: content drafts tagged with a
signal (UTM per signal), Plausible results per signal, Cal.com bookings,
and Stripe sign-ups and payments (pulled forward from Phase 4's Stripe
sync). **Built 2026-11-22** (schema 11):
- **Content.** Drafts can be written for a signal (`drafts.signal_id`).
The prompt gets the signal's hypothesis and angle, and the UTM
campaign becomes the signal's slug. The signal page lists its posts
and the websites tagged with its campaign.
- **Plausible.** `internal/api/plausible` (Stats API v2) and
`internal/tracking`. Once a day it reads the completed days' visitors,
filtered to the signals' campaigns, by day, source, medium and
content. These become aggregate Visited events, with the channel from
source and medium. Sites come from the profile.
- **Stripe.** `internal/api/stripe`, with a restricted key. It reads
completed Checkout Sessions and paid invoices every hour. A $0
checkout is Signed up. Paid invoices, and one-time payments without
an invoice, are Paid with their value. `stripe_customers` keeps each
customer's signal: from checkout metadata `utm_campaign` (or
`signal`), or else from the email matching a prospect person or
company domain.
- **Cal.com.** The Core's Cal.com has no API: /api/v1 and /api/v2 both
return 404 (checked 2026-11-22). The user chose to read booking
notices from the outreach mailbox instead: emails from the
configured Cal.com sender count as Booked for the first address
that isn't ours. Cancellations, reschedules, requests and reminders
are skipped.
- **Still to do.** The cart has to save the UTM tags in the Checkout
Session's metadata. Settings → Website & sales says how.
8. **Later, with Phase 5 (sites)**: Hugo pages per signal, created,
duplicated or deleted from the scorecard, through Gitea PRs. **Built in
Phase 5's part 4 (2026-11-22).**
Inbound: the lead-form component (Phase 5) queues a Lead the same way,
tagged with the signal from its UTM campaign.
### Phase 3: SEO, for all of the company's websites
**Started 2026-11-22** on branch `phase3-seo`, after Phase 2 was merged
into `main`. **All seven parts built, and merged into `main` on
2026-11-22** (2302fb0).
**Decisions (the user, 2026-11-22).**
- **chatseo.app:** borrow its ideas only, no subscription. It was reviewed
as the reminder asked. It's a paid chat-based SEO agent (from €39 a
month; MCP and API from €59) built on Search Console, DataForSEO and its
own crawler. Two ideas are worth taking: rank every issue by its Search
Console impressions and clicks, and check whether AI assistants can read
and cite the site.
- **Rankings come from Search Console only**: Google's own position per
query and page, free. There is no keyword-volume or SERP data provider.
Where the live top results matter (a brief, a keyword's competition),
they're read with Claude's web search, which costs searches, only when
the user asks.
- **The workflow follows a "full lifecycle" post** (@thwlf67, 18 Nov 2026,
saved by the user as a PDF). SEO for a small site is seven jobs that
come back every week: find what already ranks, find the next keywords,
write a brief, write the page, approve and publish, check Search Console
every morning, and write the Monday report. Supermarket does six of them;
the user keeps the approval. Its rules become the module's rules:
- Every number comes from the data, and none is invented: when a source
returns nothing, the report says "no data", not zero.
- Every recommendation carries the number that justifies it.
- Thresholds decide what's worth reporting, and "nothing real moved" is a
one-line answer.
- One job at a time, each with its own definition of done.
- Nothing changes on a site without the user's yes, given one change at a
time, never in bulk; at most 3 recommendations a week.
- Pages never claim tests or experience that didn't happen. A brief ends
with the questions only the user can answer, and the draft is written
around their answers, with what wasn't tested said plainly.
- The weekly report has a fixed format, so this Monday compares with the
last in seconds.
- Numbers are computed in code, from Search Console. The AI writes words
around them (titles, briefs, pages, the reasons in a report) and never
produces a number itself.
**Parts, in order, a commit after each:**
1. **Search Console and "what already ranks" (job 1).**
- Connect Google with OAuth (read-only `webmasters.readonly`), from
Settings. Choose the property for each website in the profile.
- Sync daily rows by page and query (and page alone, since Google hides
some queries) into SQLite. Start with 16 months of history, then the
latest final days. Search Console data is 2 to 3 days late, and the
app says so.
- An SEO page per site, showing:
- The 90-day totals and click rate.
- The best pages by clicks.
- The queries Google shows most where almost nobody clicks.
- The pages to **protect** (they carry the clicks) and to **push**
(they rank on page one and don't get clicked), each with the number
that justifies it.
- The share of clicks from queries Google doesn't name.
- **Built 2026-11-22** (schema 12):
- `oauth.GoogleStart` (PKCE, offline access) and `internal/api/gsc`
(sites and search analytics, paged at 25,000 rows).
- `internal/seo`: `Sync` reads 30-day chunks of date, date+page and
date+page+query rows. Position is stored × impressions. The last 4
days are re-read each time.
- `WhatRanks` computes job 1 over 90 days. *Protect* is the top 3
pages by clicks. *Push* is page-one pages (position ≤ 10.5) with at
least 100 impressions and under 1% click rate, each with its main
query and that query's share.
- Settings → Search engines: keys, the redirect URI, Connect, and the
property for each website, saved in the profile.
- SEO → What ranks, with a sync twice a day.
Committed as 5ea620a.
2. **Morning check and Monday report (jobs 6 and 7)**, computed in code.
- **Morning check:** the last 7 final days against the 7 before, by
page and by query. It reports only moves past the thresholds (default:
more than 5 clicks, or more than 3 positions on at least 300
impressions; both editable). Otherwise it says one line.
- Each move is explained where the data allows. The key case is "the
page didn't lose its ranking, Google showed its big query less, so
the average moved", found by splitting a page's position change by
query. A query that vanished is "no data", not a drop to zero.
- **Monday report**, on one page and the same every week:
1. Clicks, impressions and position, against the week before, with a
sentence on where the change came from: visibility, or rank and
click rate.
2. The 3 pages that moved most.
3. A list called "Waiting for your yes", with at most 3 changes.
- Kept as history, so reports can be compared. Optionally emailed to
the user through the Core's mail server.
- **Built 2026-11-22** (schema 13: `seo_reports`):
- `seo.MorningCheck` compares the last 7 final days with the 7
before, for pages and for searches. Pages that vanished show as
"no data". New ones count once they reach the impressions
threshold.
- A page's move is explained by the search whose clicks changed most,
and a like-for-like position: the searches it had both weeks,
weighted by this week's impressions. When that's under half the
move, the cause is the mix of searches. The search whose
impressions changed most is named.
- `seo.Weekly` writes the three numbers and a sentence on where the
change came from: rank and click rate, or visibility, plus "one
week is not a trend" under 200 clicks. It adds the 3 pages that
moved most, with causes. "Waiting for your yes" holds job 1's
*Push* pages until part 4 brings exact changes.
- Written on Mondays (or when the last report is over a week old),
stored, and optionally emailed through the outreach mailbox
(`outreach.SendToSelf`).
- The thresholds and the email option are under Settings → Search
engines; the pages are SEO → Morning check and Monday report.
3. **Technical audit, weighted by traffic, plus AI visibility.**
- A crawler (within the site's sitemap and links, polite, robots.txt
honoured) checks each page's:
- title and meta description (length in characters and pixels)
- H1 and heading order
- canonical, hreflang and noindex
- status, redirects and broken links
- images without alt text
- Open Graph and JSON-LD
- sitemap and robots.txt coverage
- Optionally, Core Web Vitals from the PageSpeed Insights API.
- Every issue is ranked by the page's Search Console impressions and
clicks, so a fix list starts with the pages that bring traffic.
- **AI visibility:** whether robots.txt lets AI crawlers in (GPTBot,
ClaudeBot, PerplexityBot, Google-Extended…), an `llms.txt`,
structured data, and pages readable without JavaScript.
- One more check, from job 3: a page's biggest query compared with its
title. When they don't say the same thing, that's the cheapest fix
there is.
- **Built 2026-11-22** (schema 14: `seo_audits`):
- `seo.RunAudit` reads robots.txt, llms.txt and the sitemaps. It then
reads up to 300 pages, in this order: the busiest pages from Search
Console, the sitemap's pages, then pages found through internal
links. A page robots.txt disallows is skipped.
- Redirects are counted. It checks up to 150 outside links (HEAD,
with GET as a fallback).
- Pages are parsed with `golang.org/x/net/html`.
- Issues have a severity:
- Error: 4xx/5xx, noindex on a page Google shows or the sitemap
lists, no title.
- Warning: title over about 600 px (Arial widths), no description,
no H1, a canonical pointing elsewhere, broken links, invalid
JSON-LD, and a title that covers under 3/4 of the main search's
words when that search brings 30%+ of the impressions.
- Notice: the rest.
- Issues are sorted by severity, then the page's 90-day clicks and
impressions.
- The AI checks: AI crawlers in robots.txt (GPTBot, OAI-SearchBot,
ChatGPT-User, ClaudeBot, Claude-User, Claude-SearchBot,
PerplexityBot, Google-Extended, Applebot-Extended, CCBot),
llms.txt, JSON-LD coverage, Organization or WebSite data, and text
in the HTML without JavaScript.
- Optionally, PageSpeed Insights (mobile, field data when there is
some) for the 5 busiest pages, with an optional API key.
- It runs in the background, once a week on its own or with *Audit
now*. The page is SEO → Audit.
4. **Changes, approval and pull requests (job 5), with before/after.**
- The AI proposes the exact change: a title, a meta description or an
H1. Each one comes with the number that pays for it and the title's
length in characters and pixels.
- The user says yes or no, one change at a time.
- A yes clones the site's Gitea repository into `/data/sites/` and
edits the page's front matter or content on a branch. It checks that
`hugo` still builds, shows the diff, and opens a pull request.
Nothing is pushed to the default branch, and merging is the user's
decision.
- Once merged and live, the change is checked on the site and pinged
with IndexNow. Its page's clicks, impressions and position are then
compared over the weeks before and after (PLAN item "before/after
tracking"). The morning check notices when a yes changed something.
- **Built 2026-11-22** (schema 15: `seo_changes`). Hugo 0.147 extended
is in the image.
- **Proposing.** `seo.Candidates` takes the *Push* pages first, then
the audit's title and description issues on pages with traffic,
then the rest. It skips pages with a change in the last 90 days.
`Proposer` reads the live page and its 90-day searches, and the AI
(task "seo") writes the title without the site's suffix (found
from the audit or the company name) and a description. Titles
over the pixel budget get one request to shorten. At most 3 wait.
*Propose a fix* is also on audit rows and *Push* pages.
- **Applying.** A yes runs `Applier` in the background. It gets the
repository from Gitea (push rights needed) and syncs a working copy
in `/data/sites/owner__name`; the token goes in as an HTTP header,
never into `.git/config`. It finds the content file (`index.md`,
`_index.md`, `url`, `slug`, language folders), works out the front
matter title from how the theme builds titles (`titleValue`), and
sets `title` and `description` (YAML or TOML). It builds before and
after: if the site builds, the built page's title and description
must come out as proposed. It then pushes `supermarket/seo-<id>`
and opens a pull request with the numbers.
- **Following up.** `Refresh`, every 30 minutes, notes a merge or a
close, then marks the change live once the live page shows it.
`ImpactOf` compares the page over equal windows (up to 28 days a
side, from 3 days of final data).
- The Monday report's "Waiting for your yes" lists the proposals.
- Settings → Search engines has Gitea's address (the Core's by
default), the token and a test. The repository and branch per
website stay in the profile.
- IndexNow moves to part 7.
5. **The next keywords (job 2).**
- Candidates come from four places:
- Search Console queries with impressions and no page that answers
them.
- The profile's keywords and targets.
- The signals' "How to spot it" lines.
- Content gaps against competitors' sites in the Inventory, from
their sitemaps and titles.
- Each candidate is checked against our own pages ("no page" must
really mean no page).
- On request, Claude's web search reads who holds the live top 3. A
keyword is ranked by who has to be beaten, not by volume; volume and
difficulty aren't available and say "not available".
- Pick one a month.
- **Built 2026-11-22** (schema 16: `seo_keywords`):
- `seo.FindKeywords` gathers candidates from:
- Search Console searches with 20+ impressions in 90 days at an
average position below 20;
- the profile's keywords and its customers' problems (not product
names: nobody searches a name they don't know, and "X
alternative" is what people search to leave X);
- the active signals' "How to spot it" lines;
- competitors' sitemaps, using the words of each page's address
(up to 400 pages, with junk like about, tag or dates dropped).
- Each candidate is dropped when one of our pages (from the latest
audit, or the sitemap) covers 3/4 of its words in its title or
address.
- Intent is "buyer" for price, cost, best, review, vs, alternative,
buy, hosting, provider and the like.
- `ReadTop` asks Claude with web search (at most 3 searches) for the
live top 3, each typed: big brand, marketplace, forum, social,
small site, ours, or unread. A result not among the pages the
search returned is marked unread.
- The ranking puts read keywords first, easiest first (a big brand
or marketplace counts 3, the rest 1), then buyer intent, then
impressions.
- On SEO → Next keywords you can pick, dismiss or bring back a
keyword. Picks feed part 6's briefs.
6. **Briefs and pages (jobs 3 and 4).**
- A brief starts from what the page is really shown for in Search
Console, then the live top 5 (read with web search, and "couldn't
read" said where a fetch failed).
- It gives the title, meta description, H1, the sections in order, the
questions the page must answer, and 3 internal links to existing
pages.
- It ends with questions only the user can answer.
- From the brief and the user's answers, a draft page or rewrite is
written into the Hugo site as a pull request. The draft goes through
a check that underlines every sentence claiming an experience ("we
tried", "in our test") for the user to confirm.
- Pages can be tagged with a buying signal (Phase 2's campaign tags), so
landing pages count on its scorecard.
- **Built 2026-11-22** (schema 17: `seo_briefs`):
- **The brief.** `Writer.NewBrief` handles a picked search (a new
page) or an existing page (a rewrite; the search defaults to its
biggest). It reads the page and its 90-day Search Console searches,
then makes one Claude research call (at most 5 web searches). That
call returns the finding, the top 5 (each with what it promises,
what it lacks, and whether it was read), and the plan: title,
description, H1, angle, sections, questions, internal links (kept
only when they point to our pages), needs, and "ask", the questions
only the owner can answer. A result not among the pages searched
is marked unread.
- **The page.** `WritePage` refuses until every question is answered.
It drafts Markdown from the brief and the answers (plus the
current text for a rewrite), with experience only from the
answers and "not tested" said plainly. `Claims` flags sentences
like "we tested…", "in our test" or "after two months".
- **The pull request.** `ApplyBrief` needs every flagged claim
confirmed. It writes a new content file (YAML front matter: title,
description, date), or for a rewrite replaces the body and sets
title and description. It checks with a Hugo build that the page
exists, then pushes `supermarket/page-<id>` and opens a pull
request listing the confirmed claims and what's still to add by
hand.
- **Following up.** `RefreshBriefs` follows the merge, then the live
page. Entry points: a pick on Next keywords, *Push* on What ranks,
and SEO → Briefs and pages.
- Tagging a page with a signal is left for Phase 5's pages.
7. **Bing and IndexNow:**
- Bing Webmaster's API, for Bing's queries and crawl problems.
- IndexNow on every merge.
- The Search Console sitemap status.
- **Built 2026-11-22** (no schema change):
- `internal/api/bing` reads traffic, query stats and crawl issues,
with an API key and the profile's Bing site (or the website's
address).
- `gsc.Sitemaps` lists the sitemaps Search Console has.
- **IndexNow.** A 32-hex key is kept in settings. `KeyLive` checks the
site serves `<key>.txt`. Once it does, `NewlyLive` submits the
pages that went live through Changes or Briefs in the last 14 days
and haven't been submitted, every 30 minutes, to
api.indexnow.org. The last 30 submissions are kept.
- **Site setup.** `Applier.SetupSite` opens one pull request,
`supermarket/search-engines`, that adds `static/<key>.txt`, a
`static/robots.txt` naming the sitemap (unless the site has one),
and takes `sitemap` out of a one-line `disableKinds`. A build
checks that sitemap.xml, robots.txt and the key file come out.
- `hugorepo` gained `WriteFile`, `Exists`, `ConfigFile` and
`EnableSitemap`. Files written are tracked, so commits never pick
up Hugo's generated files.
- The page is SEO → Search engines; the Bing key is under Settings →
Search engines. Submitting a sitemap to Google needs a write
scope, so the page says to do it in Search Console.
- Fixed along the way: `NewlyLive` looked things up while a query
still held the database's only connection, and would hang. It now
reads all rows first.
Before the first part: a Google Cloud project with the Search Console API
turned on and an OAuth client (redirect
`http://localhost:8470/auth/google/callback`), and a Gitea token with access
to each site's repository (needed from part 4).
### Phase 4: Metrics, with Stripe
Phase 2 (part 7) brings in the Stripe sync and ties payments to buying
signals; this phase builds the full metrics on top of it.
1. **Stripe sync**: a restricted, read-only key; customers, subscriptions,
invoices, credit notes and refunds; a full backfill, then incremental
updates through the Events API.
2. **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.
3. **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.
4. **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 |
5. A dashboard with CSV export. It can also be published as a page on one of
the company's sites.
**Started 2026-11-22** on branch `phase4-metrics`, after Phase 3 was merged
into `main`. **Parts 1 to 6 built, and merged into `main` on 2026-11-22**
(152c14b). Part 7 (pipeline influence) waits for the CRM bridge.
**Design decisions:**
- **MRR comes from invoice line items, not subscriptions.** A subscription
object only says how things stand today. An invoice line says what a
customer was billed for which period: monthly value = the line's amount,
after discounts, ÷ the months its period covers. Past months can then be
rebuilt exactly, and trials ($0), pauses (no invoice) and cancellations
(no next period) fall out naturally.
- **Every number is computed in code** from the synced data, like Phase 3.
No estimates; where data is missing, the dashboard says so.
- **One currency.** Amounts in another currency are counted apart, never
added.
- **Gross margin is per product** (the user, 2026-11-22). The default is
**60%**, and each Stripe product can have its own margin, set on
Metrics. CLV weighs each customer's revenue by the margin of what they
buy. Products come from the sync; if the key can't read Products, their
names come from the invoice lines' descriptions.
**Parts, in order, a commit after each:**
1. **The full Stripe sync.**
- Read customers, invoices (with their lines), credit notes and refunds:
a full backfill, then the Events API every hour.
- Events are kept for 30 days, so an older watermark triggers a new
backfill.
- Use the same restricted, read-only key as Phase 2. The key also needs
read access to Customers, Credit notes, Events and Charges (for
refunds).
- **Built 2026-11-22** (schema 18: `stripe_objects`,
`stripe_invoice_lines`):
- `metrics.Sync` backfills customers, invoices (drafts skipped),
credit notes and refunds (with `expand[]=data.charge` for the
customer).
- It then applies the Events API for the followed types since the
watermark. `charge.refunded` reads its refunds, and
`customer.deleted` marks the customer deleted.
- Invoice lines are re-read in full when `has_more`.
`stripe.ParseLine` reads both the older line shape and the 2025
one, and stores the amount after discounts.
- It syncs every hour, on Metrics, with *Sync now* and *Read
everything again*.
- Per-product margins came in with it (schema 19 adds the lines'
descriptions). Products are read on every sync; without Products
access, the sync says so and names come from the line
descriptions. `metrics.Products` lists each product's last 12
months billed (paid and open invoices). Margins are a default plus
per-product overrides, under Metrics → Gross margin by product.
`WeightedMargin` gives the revenue-weighted margin.
- On the live account, the first full sync read 857 customers,
2,894 invoices, 21 credit notes, 346 refunds and 63 products, all
in USD.
2. **The MRR model and NRR.**
- MRR per customer per month, from invoice lines.
- Each month's movements: new, expansion, contraction, churn,
reactivation.
- NRR monthly and over the trailing 12 months, by signup cohort.
- **Built 2026-11-22** (no schema change):
- `metrics.Build` measures each customer's MRR at each month's last
second (the current month: now). It sums the recurring lines of
paid and open invoices in the main currency whose period covers
that moment.
- A normal line is divided by its interval (a year counts as 12
months, a week as 52/12). A proration is spread over its actual
part-period, so an upgrade counts from its day. Under a cent counts
as nothing (trials).
- Moves: new, expansion, contraction, churn, reactivation. Changes
under $1 or 1% are noise from the proration arithmetic.
- NRR for a month is what last month's customers pay now ÷ what they
paid then. NRR over 12 months is what the customers of 12 months
ago pay now ÷ what they paid then.
- Cohorts are by the first paid month, with the retained share of
starting MRR for up to 12 months.
- **Start month.** When 20+ customers and most of the MRR appear as
new in one month, the app suggests counting from it. That's what
happened in January 2025 on the live account: billing came back to
Stripe after a gap through most of 2024. Customers paying in the
start month are the base, not new. You can choose "count
everything" instead.
- The pages are Metrics (MRR now, ARR, ARPA, NRR, a 24-month SVG
chart, the month-by-month table, cohorts) and Metrics → a month
(each customer's move).
- On the live data, both large swings are real: in June 2026 a
customer paying about $2,075 a month left, and in July 2026 prices
rose across the plans.
3. **Matching Stripe customers to EspoCRM Accounts** (from the cached CRM
records), by stored ID, email or email domain, with a screen to fix
wrong matches. Customers already tied to prospects (Phase 2) keep that
tie.
- **Built 2026-11-22** (schema 20: `crm_matches`, the user's choices
only):
- `metrics.Matches` matches every customer with a paid or open
invoice, in this order:
1. the user's choice;
2. an Account Hermes created from here (a done `stripe-customer:`
CRM action);
3. a stored ID: `espocrm_id`, `espo_id`, `crm_id` or
`espocrm_account_id` in the customer's metadata, or a
`cus_…` in the Account's `stripeCustomerId`, `cStripeCustomerId`
or a similar field;
4. email, on the Account or one of its Contacts (via
`accountId`);
5. the email's domain, skipping free mail.
- When several Accounts fit, the user chooses.
- The page is Metrics → Customers and the CRM, with three tabs: to
fix, paying now, all. Each customer can be matched to an Account
(by name), marked "not in the CRM", put back to automatic, or
queued as a new Account for Hermes (the website comes from the
email's domain).
- On the live account, 385 customers have billing. None can be
matched until Hermes copies the CRM's Accounts, which waits on the
Core's MCP hub.
4. **The spend log and CAC.**
- Spend by channel and month, entered by hand or imported from CSV.
- Outside tools' spend comes in automatically (origami.chat and
explee.com campaigns already report it).
- CAC = spend ÷ new paying customers, per month and per channel, with
the channel taken from the customer's first funnel touch.
- **Built 2026-11-22** (schema 21: `spend`, `spend_seen`):
- Spend is logged by month and channel: the funnel's channels plus
"general" for overheads. It comes in by hand, or from a pasted CSV
of month,channel,amount,note (all or nothing).
- `SyncOutsideSpend` runs with the hourly metrics. It adds each
origami.chat or explee.com campaign's spend since last seen to the
current month. The first time, a campaign's whole lifetime spend
goes into that month, with a note saying so. On the live account,
that was explee.com's $344.51, in November 2026.
- `BuildCAC`: each month's spend ÷ its new customers (from the MRR
model), plus a trailing three-month figure. With no spend logged,
CAC is unknown, never $0.
- By channel, over 12 months: each new customer's channel is their
first funnel event, matched by email; Stripe's own steps don't
count, and customers with none are "unknown". Phase 2's
`stripe_customers.channel` defaults to "website", so it isn't
used. General spend counts toward monthly CAC, not toward any
channel.
- The page is Metrics → Spend and CAC.
5. **CLV and cohorts.**
- CLV = ARPA × gross margin ÷ monthly churn rate, with the margin
weighted by each product's share of the revenue.
- Each signup cohort's actual cumulative revenue, net of refunds and
credit notes.
- **Built 2026-11-22** (no schema change):
- **`BuildCLV`** measures on the last complete month:
- ARPA;
- the margin, weighted by each product's 12-month billings;
- customer churn, as customers lost ÷ customers at the start,
summed over up to the last 12 complete months;
- lifetime = 1 ÷ churn;
- CLV = ARPA × margin × lifetime;
- CAC = spend ÷ new customers over its own 12-month window (churn
needs the month before, so its window starts a month later);
- CLV:CAC.
- **`RevenueByCohort`** uses money that actually came in: paid
invoices' `amount_paid` at `paid_at`, minus refunds that
succeeded, minus post-payment credit notes less any part refunded
(pre-payment notes already lowered the amount paid). It's counted
by the month it happened, cumulative per customer, for each first
paid month, with a gross profit view.
- Cells mark months not reached yet separately from the amount,
because revenue can be negative when refunds exceed payments.
- The page is Metrics → CLV and cohorts. On the live account, CLV
is about $1,161 of gross profit per customer: $94 a month, 60%
margin, 4.9% monthly churn, a 20.6-month lifetime. CAC waits for
spend to be logged.
6. **The dashboard.**
- MRR over time with its movements, NRR, CAC, CLV and CLV:CAC.
- CSV export of every table.
- Optionally published as a page on one of the sites, through a pull
request.
- **Built 2026-11-22** (no schema change):
- The MRR and NRR page has a second strip: churn, CLV, CAC and
CLV:CAC.
- `metrics.Export` writes eight tables as CSV, amounts in dollars:
MRR month by month (every month), NRR by cohort and revenue by
cohort (24 months), CAC by month and by channel, the spend log,
products and margins, and customers with their MRR and CRM match.
Each is downloaded at `/metrics/export/<name>.csv`, linked under
its table.
- **Metrics → Publish** builds an open metrics page in Markdown,
with totals only: MRR and ARR, customers and ARPA, 12-month
growth, NRR, churn, and a 12-month table, chosen part by part.
- `seo.Applier.PublishPage` opens a pull request that adds or
updates the page (`hugorepo.UpsertPage`), checked with a Hugo
build. The options and the last pull request are kept. A test
checks that no customer's name, email or ID can appear on the
page.
7. **Pipeline influence**, once the CRM bridge works: the value of open and
won EspoCRM opportunities with at least one marketing touch, by channel.
### Phase 5: Sites and components
1. **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 from
`webcoredesktop`, 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.
2. **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, "<competitor> alternative" and comparison pages, blog posts) from
the profile, the Inventory and SEO findings. Changes are always PRs.
Preview runs `hugo server` inside the container.
3. **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.
**Started 2026-11-22** on branch `phase5-sites`, after Phase 4 was merged
into `main`.
**Decisions (the user, 2026-11-22):**
- **Pages are built from each site's own sections**, not a new shared
theme. federated-website (about 20 section types) and webcoredesktop
(about 15) already use the same `sections:` front matter pattern, each
with its own layouts. Supermarket reads a site's section types (the
partials in `layouts/partials/sections/`, the README's field table, and
how existing pages use them) and composes pages from them. Nothing in
the layouts changes. A shared theme can come later.
- **Previews are built and served by the app**, under
`localhost:8470/preview/…`: Hugo builds the branch, so no second port is
needed.
**Parts, in order, a commit after each:**
1. **Reading a site.**
- Sync the website's repository (Phase 3's working copy).
- The section catalogue: each section type with its fields (from the
README's table and from the pages that use it), an example from a
real page, and how many pages use it.
- The pages, with their address, title and section types.
- The last merge on the publish branch, from Gitea.
- A Sites page per website.
2. **Preview.** Build a branch (the published one, or a pull request's)
and serve it under `/preview/<site>/<branch>/`, so a page can be seen
before it's merged.
3. **The page builder.**
- New pages of a kind: landing page, product page, "<competitor>
alternative", comparison, blog post.
- Built from the profile, the Inventory, a buying signal (its angle,
with CTAs carrying its campaign tag) or an SEO brief.
- The AI composes `sections:` using only the site's own types and
fields, and code checks every type exists.
- Opened as a pull request, checked with a build, with a preview link.
4. **Pages per signal** (Phase 2's part 8): a landing page per buying
signal, created from the scorecard, and duplicated (to test a variant)
or deleted from it, always as pull requests.
5. **Publishing status.** After a merge, check the live site: the page is
there, its title matches, and the change shows. List the recent merges.
**Part 1 built (2026-11-22; no schema change).** `internal/sites` reads a
working copy: section types are the partials in
`layouts/partials/sections/`, less the helpers other partials call (head,
ctas, wrapper…); each type gets the README's description (table rows or
list items), the fields pages use (with list items' keys), the fields its
layout reads, the pages using it, and its fullest real use as YAML in the
page's own field order. Types pages use without a layout are flagged. Pages
list their address, title and section types; TOML pages are listed but not
read. `hugorepo` gained a per-copy lock (so two jobs can't reset one copy at
once; every SEO job now takes it), `Log` and `PathOf`. Sites → Sections and
pages (`/sites`) reads the repository on request and shows the latest
commits on the published branch. Live: federated-website has 25 section
types and 59 pages (22 built from sections).
**Part 2 built (2026-11-22; no schema change).** Sites → Previews lists the
repository's branches (the published one first) and builds any of them:
a fresh read, the branch checked out, `hugo --buildDrafts --buildFuture`
for `/`, then every root-relative address in the HTML and CSS rewritten to
`/preview/<site>/<branch>/`. The copy goes back to the published branch
afterwards. A failed build keeps serving the last good preview; a preview
older than its branch says so. Previews are served with a CSP `sandbox`
(no `allow-same-origin`): the site's scripts run, but each page has an
opaque origin, so the guard refuses anything it posts to the app; it can't
connect anywhere either, so analytics don't count previews. Folders show
only through their index.html.
**The image's Hugo** was Alpine's 0.147.2, too old for federated-website
(`hugo.Data` needs 0.156+), so even the SEO build check would have failed
on it. The Dockerfile now builds Hugo v0.170.1 from source in a Go 1.27
stage (the standard edition: sites needing Sass won't build). Hugo's
errors now show the innermost cause, with paths cut to the repository's.
**Part 3 built (2026-11-22; schema 22, `site_pages`).** Sites → New pages
builds a page of a kind (landing, product, alternative, comparison, blog
post) from the profile, optionally a product, a competitor from the
Inventory, a buying signal and an SEO brief, plus the user's notes. It
reads the repository fresh, then the AI (new task "sites") gets the
company, the page's purpose, the site's pages with their section
sequences, and the section catalogue (README, fields in use, layout
fields, one real example per type; about 34,000 characters for
federated-website). It answers with the sections as a YAML string (strict
JSON schemas can't hold free-form sections). Code then checks it: every
type must exist with a layout (an error to fix otherwise); unknown fields
and links to pages the site doesn't have (in url fields and Markdown links)
are warnings; with a signal, links to the site get `utm_campaign=<signal>`
and `utm_medium=landing`; experience claims are found as for briefs. The
user edits title, description, address and the YAML, then can *Write it
again* (from their notes and edits), *Push and preview* (its own branch
`supermarket/site-page-<id>`, built, previewed, no pull request) or *Open a
pull request* (claims confirmed first; the body lists the claims, what to
add by hand and the build check). The address is fixed once the file is on
a branch. Pages show merged or closed from Gitea. Not yet tried against the
live AI or the real repository: a build is a paid AI call and pushes a
branch.
**Part 4 built (2026-11-22; schema 23, the removal pull request's
columns).** Each signal's page has a *Landing pages* section: its pages on
every site (variants after their original), their status from Gitea
(refreshed on view), the live address, and each live page's visitors over
30 days from Plausible (`event:page`, per page, never per person). A form
there builds a landing page for the signal (the page builder, with the
signal preset). Per page:
- *Duplicate as a variant*: a copy at the original's address plus `-b`,
`-c`… (variants B, C; the original becomes A), optionally rewritten from
notes on what to change. A variant's links to the site also carry
`utm_content=<its address>`, so sign-ups that keep the tags can be told
apart; the original's links stay as they are, so a live page needn't
change when a variant is added.
- *Remove from the site* (published pages): a pull request on
`supermarket/remove-site-page-<id>` deleting the file, checked with a
build; merged, the page is *removed*; closed, it's back to *merged*.
- *Close the pull request*: closes an open one (adding or removing) on
Gitea without merging.
The scorecard shows how many landing pages each signal has live. Phase 2's
part 8 is done by this.
**Part 5 built (2026-11-22; schema 24: `live_at`, `gone_at`, `checked_at`,
`live_note`).** The SEO loop (every 30 minutes) now also follows Sites
pages' pull requests and checks the live site for pages waiting on it; so
do the page, the signal's page and Sites → Publishing whenever they're
opened (at most once a minute), and *Check the live site now*. A merged
page is live when its address answers 200 with its own words (the first
heading of its sections, without Markdown) and its title; words without
the title count as live, with a note; the title without the words means
the old version is still deployed. A removed page must answer 404 or 410,
or lead elsewhere. Two hours after a merge without the page, it says to
check the deploy hook. Badges read *merged, not live yet* / *live* and
*removal merged, still on the site* / *removed*. Pages that go live or
away are sent to IndexNow with the SEO changes (`seo.NewlyLive`). Sites →
Publishing lists what's waiting for the live site, open pull requests,
and the repository's latest merged pull requests (Supermarket's or
anyone's), each linked to its page. federated-website has no merged pull
requests: its changes are pushed straight to `main`, shown as commits
under Sections and pages.
**Phase 5 is complete** (parts 1–5). Not yet tried for real: building a
page (a paid AI call) and pushing it to the real repository.
### Future enhancements
Not in any phase yet; picked up when the user asks.
1. **Post to the LinkedIn company page** (deferred 2026-11-21). Today posts
go to the signed-in member's profile (`w_member_social`). Posting as the
Federated Computer page needs LinkedIn's **Community Management API**,
which LinkedIn approves by hand.
- The user's side: be an admin of the company page, with its website
and domain verified; create a *second* LinkedIn app linked to the page
(Community Management can only be requested on a new app with no other
products), have a page admin verify it, and request the Development
tier (an access form describing the use). It's likely enough: 500 calls
a day, though for up to 12 months. Standard tier needs a screen
recording and a privacy policy. A rejected app can't reapply; a new app
would be needed.
- Supermarket's side, once approved: a second set of LinkedIn keys and a
Connect button for the page app; list the pages the user administers
and pick one; on each LinkedIn draft, choose the profile or the page
(author `urn:li:organization:<id>`). Check the approved app's Auth tab
for the exact scopes (expected `w_organization_social`, plus one for
listing administered pages) before building.
- Docs: learn.microsoft.com/linkedin/marketing/community-management-app-review
and .../community-management/community-management-overview.
2. **Back up the database and restore from a backup** (asked for
2026-11-21). Today backups are copies made by hand before risky changes
(`app.db.pre-phase1`, `app.db.pre-dedupe`, …) in the data folder. A plain
`cp` of a running database in WAL mode can miss recent writes, so
backups must use SQLite's own backup (`VACUUM INTO` or the online backup
API). This doesn't depend on any phase.
- **Where they go:** `~/.local/share/supermarket/backups/`, named
`app-<date>-<time>[-<reason>].db`, e.g. `app-20261121-1830-before-schema-9.db`.
Each one is a single, consistent SQLite file you can open with `sqlite3`.
- **When they're made:**
- When you ask: `supermarket backup [note]` from the terminal, or
*Back up now* on Settings → Backups.
- Automatically before every schema migration, before a restore, and
before bulk changes such as merging duplicates. This replaces the
hand-made `app.db.pre-*` copies.
- Once a day while the app runs.
- **Keeping them:** the last 7 daily backups, plus 4 weekly ones. Backups
made before a migration or a restore, and the ones you make yourself,
are kept until you delete them. Settings → Backups shows each backup's
size and schema version, and lets you download or delete it.
- **Restoring:** `supermarket restore <file>`, or *Restore* on a backup in
Settings → Backups (after you confirm). The steps:
1. Check the file: `PRAGMA integrity_check`, and that its schema isn't
newer than this version of the app.
2. Back up the current database first.
3. Stop the background jobs and close the database.
4. Swap the file in, removing the old `-wal` and `-shm` files.
5. Start again. Any migrations the backup lacks run on start.
From the browser, the app exits after the swap and Docker's
`restart: unless-stopped` brings it back. You can also restore a
downloaded backup by uploading it.
- **Secrets aren't included.** Tokens and keys stay in `secrets.json`,
and a restore never touches them. Putting them in a file that gets
downloaded and copied around would spread credentials.
`supermarket backup --with-secrets` adds them for a move to a new
machine. The result is a mode-0600 `.tar.gz`, and the command warns
that the file holds credentials.
- **The `supermarket` command:** `backup`, `backups` (lists them) and
`restore` run the app's own binary inside the container
(`docker exec supermarket supermarket backup …`). That way the backup
comes from the process that holds the database, with no locking
surprises.
- **The existing `app.db.pre-*` files:** moved into `backups/` the first
time, so they show up in the list. Their `-shm` and `-wal` leftovers are
dropped after a check that each copy opens.
- **Later:** an optional copy off this machine, to Nextcloud on the Core.
A backup in the same folder as the database won't survive a lost disk.
## 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 (signals, prospects, funnel) ── needs: Hermes bridge, mcphub EspoCRM tools,
│ mail on the Core, Plausible, Stripe key
├──► Phase 3 (SEO) ──────── needs: Google OAuth (Search Console), 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
1. **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 `.env` gives an
agent that reads untrusted web content admin access to the Core.
*2026-11-19:* the Core's developer confirmed it's always the admin token
today. After the admin token failed with a 401, they said the hub will
likely move to per-user tokens.
*2026-11-20:* resolved. The hub now issues per-user tokens, still sent as
`Authorization: "Basic <token>"`, with `as_user=<user>` kept in the URL.
2. **MCP hub URL**: is it always `mcphub.<CORE_DOMAIN>`, so it can be worked out
from `core.conf`?
3. **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?
*2026-11-22:* resolved. Sites live on the Core's Gitea
(gitea.federated.computer, with Federated_Computer/federated-website for
the main site). The user gives the app an access token with the
`write:repository` scope, under Settings → Search engines.