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
-112
View File
@@ -1,112 +0,0 @@
package claude
import (
"context"
"fmt"
"os"
"strings"
"time"
anthropic "github.com/anthropics/anthropic-sdk-go"
"github.com/anthropics/anthropic-sdk-go/option"
"coremarketing/internal/models"
)
const systemPrompt = `You are a product manager at a company that champions open source software. You write posts for X.com (Twitter) to help users get more value from open source SaaS applications.
Your voice:
- Knowledgeable but approachable — you know this product deeply and want to share that knowledge
- Practical — you share specific workflows, features, and tips users can immediately apply
- Community-minded — you reference the broader ecosystem and encourage engagement
- Authentic — no corporate buzzwords, write like a real PM sharing genuine insights
Your posts should:
- Lead with the most valuable insight or tip
- Be specific rather than generic
- Include a call to action when appropriate (question, try it yourself, share your experience)
- Stay within the character limit INCLUDING hashtags
- End with 2-3 relevant hashtags
- May include 1-2 emojis for visual interest
Output ONLY the post text. No explanations, no alternatives — just the post.`
type Client struct {
client *anthropic.Client
model string
logFile string
}
func New(apiKey, model, stateDir string) *Client {
c := anthropic.NewClient(option.WithAPIKey(apiKey))
return &Client{
client: c,
model: model,
logFile: stateDir + "/coremarketing.log",
}
}
// GeneratePost creates a post in the voice of a product manager based on
// selected content. maxLength is the space available for the post text itself,
// excluding anything appended at posting time (such as the source URL).
func (c *Client) GeneratePost(ctx context.Context, app *models.Application, items []models.ContentItem, maxLength int) (string, error) {
// Combine system instructions with the user prompt in a single user message.
// This avoids SDK version ambiguity around the System parameter content block type.
fullPrompt := systemPrompt + "\n\n---\n\n" + c.buildUserPrompt(app, items, maxLength)
msg, err := c.client.Messages.New(ctx, anthropic.MessageNewParams{
Model: anthropic.F(c.model),
MaxTokens: anthropic.F(int64(512)),
Messages: anthropic.F([]anthropic.MessageParam{
anthropic.NewUserMessage(anthropic.NewTextBlock(fullPrompt)),
}),
})
if err != nil {
c.log("GeneratePost error: %v", err)
return "", fmt.Errorf("claude API: %w", err)
}
for _, block := range msg.Content {
if block.Type == "text" {
return strings.TrimSpace(block.Text), nil
}
}
c.log("GeneratePost: no text block in response (stop_reason=%s)", msg.StopReason)
return "", fmt.Errorf("no text content in claude response (stop_reason=%s)", msg.StopReason)
}
func (c *Client) buildUserPrompt(app *models.Application, items []models.ContentItem, maxLength int) string {
var sb strings.Builder
sb.WriteString(fmt.Sprintf("Application: %s\n", app.Name))
sb.WriteString(fmt.Sprintf("Description: %s\n\n", app.Description))
sb.WriteString(fmt.Sprintf("Character limit: %d\n\n", maxLength))
sb.WriteString("Selected content from social media and community:\n\n")
for i, item := range items {
sb.WriteString(fmt.Sprintf("--- Item %d [%s] ---\n", i+1, string(item.Source)))
if item.Title != "" {
sb.WriteString(fmt.Sprintf("Title: %s\n", item.Title))
}
sb.WriteString(fmt.Sprintf("Author: @%s\n", item.AuthorHandle))
sb.WriteString(fmt.Sprintf("Date: %s\n", item.PublishedAt.Format("Jan 2, 2006")))
sb.WriteString(fmt.Sprintf("Content: %s\n", item.Body))
sb.WriteString(fmt.Sprintf("URL: %s\n\n", item.URL))
}
sb.WriteString(fmt.Sprintf(
"Based on this content, write ONE X.com post (max %d characters including hashtags) in the voice of a product manager helping users better use %s.",
maxLength, app.Name,
))
return sb.String()
}
func (c *Client) log(format string, args ...any) {
f, err := os.OpenFile(c.logFile, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0600)
if err != nil {
return
}
defer f.Close()
fmt.Fprintf(f, "[%s] %s\n", time.Now().Format(time.RFC3339), fmt.Sprintf(format, args...))
}
+1 -1
View File
@@ -11,7 +11,7 @@ import (
"strings"
"time"
"coremarketing/internal/models"
"supermarket/internal/models"
)
const apiBase = "https://api.twitter.com/2"
+1 -1
View File
@@ -10,7 +10,7 @@ import (
"strconv"
"time"
"coremarketing/internal/models"
"supermarket/internal/models"
)
const apiBase = "https://www.googleapis.com/youtube/v3"