Phase 0: turn Supermarket into a Dockerized local web app
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>
This commit is contained in:
@@ -1,152 +1,130 @@
|
||||
# CoreMarketing Social Curator
|
||||
# Supermarket
|
||||
|
||||
A terminal UI app that monitors open source SaaS applications across X.com, YouTube, and Instagram, then uses Claude AI to generate posts in the voice of a product manager.
|
||||
A marketing suite for companies that run a [Federated Core](https://federated.computer), installed as a [CoreDesktop](https://gitea.federated.computer/Federated_Computer/coredesktop) sibling project. It runs as a web app in Docker on your computer, at <http://localhost:8470>, and only your computer can reach it.
|
||||
|
||||
## Prerequisites
|
||||
Everything starts from your **company profile** (what you sell, to whom, in what voice) and your **inventory** of partners and competitors. On top of those, Supermarket will:
|
||||
|
||||
- Go 1.22 or later
|
||||
- A [Claude API key](https://console.anthropic.com)
|
||||
- API credentials for whichever platforms you want to monitor (all are optional except Claude)
|
||||
| Module | What it does | Status |
|
||||
|--------|--------------|--------|
|
||||
| Content | Drafts posts from partner and competitor news and your own products; you review them and publish to X, LinkedIn and Reddit | Phase 1 |
|
||||
| Prospects | Finds companies and people who fit your targets; the ones you approve go into your Core's EspoCRM through Hermes | Phase 2 |
|
||||
| SEO | Audits your websites for Google, Bing/DuckDuckGo and Brave, and opens fixes as pull requests on your Hugo repositories | Phase 3 |
|
||||
| Metrics | Pipeline influence, CAC, CLV and NRR, from Stripe, EspoCRM and Plausible | Phase 4 |
|
||||
| Sites | Builds pages and sites from a component library and publishes them through Gitea | Phase 5 |
|
||||
|
||||
## Setup
|
||||
This version is Phase 0, the foundation: the web app, the company profile, the inventory, the AI provider, credentials, and the bridge to your Core through Hermes. The old terminal app's post queue is imported and kept for the Content module. See [PLAN.md](PLAN.md) for the whole plan.
|
||||
|
||||
**1. Configure credentials**
|
||||
## Install
|
||||
|
||||
`./install.sh` copies `config.example.yaml` to `~/.local/state/coremarketing/config.yaml` (the default location the app reads). Fill in your API keys there:
|
||||
On a CoreDesktop machine:
|
||||
|
||||
> **Never commit real credentials.** `config.yaml` is gitignored; only `config.example.yaml`, with blank credentials, belongs in the repo.
|
||||
```
|
||||
sibling add <this repository's git URL>
|
||||
```
|
||||
|
||||
This runs [install.sh](install.sh), which:
|
||||
|
||||
1. builds and starts Supermarket's container (Docker and Docker Compose come with CoreDesktop),
|
||||
2. adds Supermarket to GNOME's app grid with CoreDesktop's `webapp`,
|
||||
3. imports the old terminal app's settings, credentials and queued posts, if it finds them in `~/.local/state/coremarketing` (copied, not moved),
|
||||
4. connects Hermes to your Core's MCP hub and to Supermarket (see [Hermes](#hermes-and-your-core)), and
|
||||
5. offers to let Claude Code use Supermarket's tools.
|
||||
|
||||
After that, CoreDesktop's `update` keeps it current: it pulls this repository and runs [update.sh](update.sh), which rebuilds the container when the code has changed.
|
||||
|
||||
Then open Supermarket and:
|
||||
|
||||
1. **Profile**: enter your website and press *Draft*. Correct the draft and save it.
|
||||
2. **Settings > AI provider**: Anthropic (add your API key under *Credentials*) or an LLM server on your network, such as Ollama. Servers found by CoreDesktop's `configure ai-servers` are offered.
|
||||
3. **Inventory**: add your partners and competitors, or import a list.
|
||||
4. **Settings > Credentials**: connect X and LinkedIn.
|
||||
|
||||
## The `supermarket` command
|
||||
|
||||
```
|
||||
supermarket open it in the browser (starting it if needed)
|
||||
supermarket status running? which version?
|
||||
supermarket logs follow its log
|
||||
supermarket restart restart it
|
||||
supermarket stop stop it, until you start it again
|
||||
supermarket hermes set up Hermes' connection again (--reconfigure to change the MCP hub)
|
||||
supermarket token the token agents use for its MCP endpoint
|
||||
```
|
||||
|
||||
## Where things are
|
||||
|
||||
| What | Where |
|
||||
|------|-------|
|
||||
| Data: database, imported files | `~/.local/share/supermarket/` (`app.db`, `import/`) |
|
||||
| API keys and tokens | `~/.local/share/supermarket/secrets.json`, readable only by you. Never in the repository or the image |
|
||||
| MCP token | `~/.local/share/supermarket/mcp-token` |
|
||||
| The Core's settings | A copy of CoreDesktop's `~/.config/coredesktop/core.conf`, refreshed by every `update` |
|
||||
|
||||
Back up `~/.local/share/supermarket` to keep everything.
|
||||
|
||||
## Hermes and your Core
|
||||
|
||||
Supermarket never talks to your Core's MCP hub itself. CoreDesktop's Hermes agent does: it holds the hub's password, and carries out the CRM work Supermarket queues (from Phase 2). The two meet through Supermarket's own MCP endpoint at `http://127.0.0.1:8470/mcp`, which requires a bearer token.
|
||||
|
||||
`install.sh` (or `supermarket hermes`) adds both MCP servers to `~/.hermes/config.yaml`:
|
||||
|
||||
```yaml
|
||||
credentials:
|
||||
claude:
|
||||
api_key: "sk-ant-..." # Required
|
||||
|
||||
twitter:
|
||||
bearer_token: "" # Required for reading (X Basic plan, $100/mo)
|
||||
client_id: "" # Required for posting (OAuth 2.0 client ID)
|
||||
client_secret: "" # Confidential clients only — leave blank otherwise
|
||||
oauth2_access_token: "" # Set automatically by `coremarketing auth twitter`
|
||||
|
||||
youtube:
|
||||
api_key: "" # Free — get one at console.cloud.google.com
|
||||
|
||||
instagram:
|
||||
access_token: "" # Requires Facebook App review
|
||||
business_account_id: ""
|
||||
|
||||
posting:
|
||||
twitter_handle: "youraccount" # The @handle you post FROM
|
||||
mcp_servers:
|
||||
mcphub:
|
||||
url: "https://mcphub.<your Core's domain>/sse?as_user=<your user name>"
|
||||
headers:
|
||||
Authorization: "Basic ${MCPHUB_AUTH}"
|
||||
supermarket:
|
||||
url: "http://127.0.0.1:8470/mcp"
|
||||
headers:
|
||||
Authorization: "Bearer ${SUPERMARKET_MCP_TOKEN}"
|
||||
```
|
||||
|
||||
Missing credentials are skipped gracefully — the app works with only Claude plus whichever sources you have set up.
|
||||
Hermes fills in each `${...}` from `~/.hermes/.env` when it connects, so `config.yaml` holds no password:
|
||||
|
||||
**2. Add your applications**
|
||||
|
||||
In `config.yaml`, list the open source SaaS apps you want to track:
|
||||
|
||||
```yaml
|
||||
applications:
|
||||
- name: "Nextcloud"
|
||||
description: "Self-hosted file storage and collaboration platform"
|
||||
twitter_handle: "nextcloud"
|
||||
youtube_channel_id: "UCQGgrx2pSXQ2r0fk2cbQIFQ"
|
||||
instagram_handle: ""
|
||||
hashtags:
|
||||
- "nextcloud"
|
||||
- "selfhosted"
|
||||
```
|
||||
MCPHUB_AUTH=<base64 of user:password>
|
||||
SUPERMARKET_MCP_TOKEN=<from supermarket token>
|
||||
```
|
||||
|
||||
**2b. Authorize Twitter/X posting**
|
||||
Hermes runs in CoreDesktop's sandbox, so it can only reach the hub and Supermarket once they're in `network.allowedDomains` in `~/.config/coredesktop/sandbox/hermes.json`. The script asks before adding them, then restarts Hermes' gateway.
|
||||
|
||||
Once `client_id` is set, run the one-time auth flow to obtain a posting token:
|
||||
To check the connection, open **Core & Hermes** in Supermarket and ask Hermes the question shown there. Hermes lists the hub's tools and reports them back to Supermarket, which shows when it last heard from Hermes.
|
||||
|
||||
```bash
|
||||
coremarketing auth twitter
|
||||
## Signing in to X and LinkedIn
|
||||
|
||||
Sign-ins come back to Supermarket at `http://localhost:8470/auth/<provider>/callback`. Register these callback URLs in your apps:
|
||||
|
||||
- X developer portal, your app's *User authentication settings*: `http://localhost:8470/auth/x/callback`
|
||||
- LinkedIn developer portal, your app's *Auth* tab: `http://localhost:8470/auth/linkedin/callback`
|
||||
|
||||
The old terminal app used `http://localhost:8080/callback`; you can remove that one.
|
||||
|
||||
## Security
|
||||
|
||||
- The port is published on `127.0.0.1` only, so other machines can't reach it, whatever the firewall says.
|
||||
- The app has no login, so it protects itself from web pages open in the same browser: it only answers requests addressed to `localhost` (against DNS rebinding), and refuses form posts that don't come from its own pages.
|
||||
- The container runs as you, with a read-only filesystem, no Linux capabilities and `no-new-privileges`. It can write only its data folder.
|
||||
- `/mcp` requires the bearer token in `mcp-token`.
|
||||
|
||||
## Development
|
||||
|
||||
Requires Go (see `go.mod`).
|
||||
|
||||
```
|
||||
go test ./...
|
||||
SUPERMARKET_DATA=/tmp/cm SUPERMARKET_ADDR=127.0.0.1:8470 go run ./cmd/supermarket
|
||||
```
|
||||
|
||||
This opens a browser, handles the OAuth 2.0 PKCE redirect on `localhost:8080`, and writes `oauth2_access_token` directly into `config.yaml`. Re-run it any time the token expires.
|
||||
| Path | What |
|
||||
|------|------|
|
||||
| `cmd/supermarket` | The server |
|
||||
| `internal/web` | Pages (Go templates + [htmx](https://htmx.org), no JavaScript build) |
|
||||
| `internal/profile`, `internal/inventory` | The company profile and the inventory |
|
||||
| `internal/ai` | AI providers: Anthropic (official Go SDK) and OpenAI-compatible servers |
|
||||
| `internal/mcpserver`, `internal/bridge` | The `/mcp` endpoint and Hermes' check-ins |
|
||||
| `internal/legacy` | One-time import from the old terminal app |
|
||||
| `internal/api`, `internal/fetcher` | X, LinkedIn and YouTube clients, kept for the Content module |
|
||||
| `hermes/setup.sh` | Connects Hermes |
|
||||
|
||||
## Build & Install
|
||||
|
||||
To build and install the binary to `~/.local/bin/`:
|
||||
|
||||
```bash
|
||||
./install.sh
|
||||
```
|
||||
|
||||
The script auto-detects your Go installation. If `~/.local/bin` is not in your PATH, it will print a reminder to add it to your shell config.
|
||||
|
||||
To build locally without installing:
|
||||
|
||||
```bash
|
||||
go build -o coremarketing .
|
||||
```
|
||||
|
||||
## Run
|
||||
|
||||
```bash
|
||||
coremarketing
|
||||
```
|
||||
|
||||
Or, if running from the project directory without installing:
|
||||
|
||||
```bash
|
||||
./coremarketing
|
||||
```
|
||||
|
||||
To use a different config file:
|
||||
|
||||
```bash
|
||||
coremarketing /path/to/config.yaml
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
The app uses a two-stage workflow: first generate posts from curated content, then publish them when ready.
|
||||
|
||||
### Stage 1 — Research and generate
|
||||
|
||||
| Screen | Keys |
|
||||
|---|---|
|
||||
| **App list** — pick which application to research | `↑↓` navigate, `/` filter, `Enter` select, `p` view post queue, `q` quit |
|
||||
| **Fetching** — pulls content from all configured sources since last check | _(automatic)_ |
|
||||
| **Content browser** — review what was found | `↑↓` navigate, `Space` select/deselect, `Enter` generate post, `Esc` back |
|
||||
| **Post preview** — edit the Claude-generated post | `Enter` save to queue, `Ctrl+R` regenerate, `Esc` back |
|
||||
|
||||
### Stage 2 — Publish
|
||||
|
||||
From the app list, press `p` to open the post queue. The home screen shows a badge when posts are ready.
|
||||
|
||||
| Screen | Keys |
|
||||
|---|---|
|
||||
| **Generated Posts** — all saved posts waiting to be published | `↑↓` navigate, `Space` select/deselect, `Ctrl+P` post selected, `d` delete selected, `Esc` back |
|
||||
| **Result** — shows published URLs and any errors | `Enter` return to home |
|
||||
|
||||
You can queue posts for multiple applications before publishing them all at once.
|
||||
|
||||
## Data files
|
||||
|
||||
All data files are written next to `config.yaml`, regardless of where you run the binary from.
|
||||
|
||||
| File | Purpose |
|
||||
|---|---|
|
||||
| `state.json` | Tracks when content was last fetched per application |
|
||||
| `posts.json` | Stores generated posts waiting to be published |
|
||||
|
||||
## Lookback window
|
||||
|
||||
The lookback window always defaults to 7 days. It only advances (per application) when Claude successfully generates a post from that application's content — ensuring you never miss content between runs.
|
||||
|
||||
To reset the window for all applications:
|
||||
|
||||
```bash
|
||||
rm state.json
|
||||
```
|
||||
|
||||
To reset a single application, open `state.json` and delete that app's entry.
|
||||
|
||||
## Generated posts
|
||||
|
||||
Claude writes each post in the voice of a product manager — practical, specific, and helpful rather than promotional. Posts are capped at the `max_length` set in `config.yaml` (default: 280 characters for standard X accounts, up to 25,000 for X Premium).
|
||||
|
||||
You can edit the generated post in the preview screen before saving it to the queue.
|
||||
Database changes go in `internal/db/db.go` as a new migration; never edit one that has shipped.
|
||||
|
||||
Reference in New Issue
Block a user