feat(server): add brand kit management and project binding

Add a brand kit domain with memory and postgres stores, a BrandKitService
for CRUD and resolution, and REST endpoints to list, upsert, and delete
brand kits. Projects can bind a brand kit whose resolved context and
reference images feed into the agent's long-term memory and design prompts.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-10 20:58:55 +08:00
parent 3653474355
commit 789f51b29e
38 changed files with 2165 additions and 135 deletions
@@ -0,0 +1,38 @@
package brandkit
import (
"context"
"encoding/json"
"errors"
"time"
)
var (
ErrInvalidInput = errors.New("invalid brand kit")
ErrNotFound = errors.New("brand kit not found")
ErrConflict = errors.New("brand kit conflict")
)
type Kit struct {
ID string
UserID string
Name string
Document json.RawMessage
IsDefault bool
CreatedAt time.Time
UpdatedAt time.Time
}
type Store interface {
List(ctx context.Context, userID string) ([]Kit, error)
Get(ctx context.Context, userID string, id string) (Kit, error)
GetDefault(ctx context.Context, userID string) (Kit, error)
Upsert(ctx context.Context, kit Kit) (Kit, error)
Delete(ctx context.Context, userID string, id string) error
Close() error
}
func Clone(kit Kit) Kit {
kit.Document = append(json.RawMessage(nil), kit.Document...)
return kit
}
+11 -7
View File
@@ -201,6 +201,9 @@ type Project struct {
SnapshotID string
Canvas string
LastThreadID string
BrandKitID string
BrandContext string
BrandImages []string
Viewport Viewport
Nodes []Node
Connections []Connection
@@ -208,13 +211,14 @@ type Project struct {
}
type ProjectSummary struct {
ID string
UserID string
Title string
Brief string
Status ProjectStatus
Thumbnail string
UpdatedAt time.Time
ID string
UserID string
Title string
Brief string
Status ProjectStatus
Thumbnail string
BrandKitID string
UpdatedAt time.Time
}
type QuickAction struct {