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:
2026-11-19 08:38:09 -07:00
co-authored by Claude Opus 5.5
parent 4d304cd65b
commit d039484a4a
68 changed files with 6288 additions and 2914 deletions
+63
View File
@@ -0,0 +1,63 @@
// Package bridge records Hermes' visits through the app's MCP endpoint. Hermes
// holds the connection to the Core's MCP hub; the app never does. In Phase 0
// a visit is a check-in that proves the route works and lists the hub's
// tools; later phases add the CRM queue on the same route.
package bridge
import (
"database/sql"
"encoding/json"
"errors"
"time"
"supermarket/internal/db"
)
// Checkin is one visit from Hermes.
type Checkin struct {
At time.Time
Agent string
MCPHubTools []string
Note string
}
// Record stores a check-in.
func Record(d *db.DB, c Checkin) error {
tools, err := json.Marshal(c.MCPHubTools)
if err != nil {
return err
}
if c.MCPHubTools == nil {
tools = []byte("[]")
}
_, err = d.Exec(`INSERT INTO bridge_checkins (agent, mcphub_tools, note) VALUES (?, ?, ?)`,
c.Agent, string(tools), c.Note)
if err != nil {
return err
}
// Keep the last 100; older ones say nothing new.
_, err = d.Exec(`DELETE FROM bridge_checkins WHERE id NOT IN
(SELECT id FROM bridge_checkins ORDER BY id DESC LIMIT 100)`)
return err
}
// Last returns the latest check-in, or nil if Hermes never checked in.
func Last(d *db.DB) (*Checkin, error) {
var at, tools string
c := &Checkin{}
err := d.QueryRow(`SELECT at, agent, mcphub_tools, note FROM bridge_checkins ORDER BY id DESC LIMIT 1`).
Scan(&at, &c.Agent, &tools, &c.Note)
if errors.Is(err, sql.ErrNoRows) {
return nil, nil
}
if err != nil {
return nil, err
}
c.At, _ = time.Parse(time.RFC3339, at)
_ = json.Unmarshal([]byte(tools), &c.MCPHubTools)
return c, nil
}
// CheckinPrompt is what to ask Hermes to test the route end to end. Hermes
// must reach both MCP servers for it to work.
const CheckinPrompt = `Run the Supermarket bridge check: list the names of all the tools you have from the "mcphub" MCP server, then call the "bridge_checkin" tool of the "supermarket" MCP server with agent "hermes", mcphub_tools set to that list, and a one-line note on anything that failed. Don't call any other tool.`