Phase 3 part 6: briefs and pages

A brief for a search (a new page) or a page (a rewrite) starts from what
Search Console shows the page for, reads the live top 5 with Claude's web
search (unread results marked, never guessed), and gives the title,
description, H1, angle, sections, questions, internal links to pages we
have, and the questions only the owner can answer. The page is drafted
around those answers, with no invented tests, prices or customers; every
sentence claiming an experience must be confirmed before a pull request
adds or rewrites the page, checked with a Hugo build. Merged pages are
followed to the live site. Schema 17.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-22 08:18:49 -07:00
co-authored by Claude Opus 5.5
parent c0a5ddf77f
commit 68c224f51b
19 changed files with 1440 additions and 22 deletions
+30 -18
View File
@@ -524,20 +524,22 @@ func (ap *Applier) Apply(ctx context.Context, d *db.DB, id int64) error {
return err
}
func (ap *Applier) apply(ctx context.Context, d *db.DB, c *Change) error {
// workingCopy is a fresh copy of the site's published branch, with the
// repository's full name and that branch.
func (ap *Applier) workingCopy(ctx context.Context) (*hugorepo.Repo, string, string, error) {
if ap.Gitea == nil {
return errors.New("save a Gitea token under Settings → Search engines first")
return nil, "", "", errors.New("save a Gitea token under Settings → Search engines first")
}
_, full, err := gitea.ParseRepo(ap.Repo)
if err != nil {
return fmt.Errorf("set this website's Hugo repository in the profile first (%v)", err)
return nil, "", "", fmt.Errorf("set this website's Hugo repository in the profile first (%v)", err)
}
repo, err := ap.Gitea.GetRepo(ctx, full)
if err != nil {
return err
return nil, "", "", err
}
if !repo.Permissions.Push {
return fmt.Errorf("the Gitea token can't push to %s", full)
return nil, "", "", fmt.Errorf("the Gitea token can't push to %s", full)
}
branch := ap.Branch
if branch == "" {
@@ -546,6 +548,28 @@ func (ap *Applier) apply(ctx context.Context, d *db.DB, c *Change) error {
wc := &hugorepo.Repo{Dir: filepath.Join(ap.ReposDir, strings.ReplaceAll(full, "/", "__")), CloneURL: repo.CloneURL,
Token: ap.Gitea.Token(), Branch: branch, Author: ap.Author}
if err := wc.Sync(ctx); err != nil {
return nil, "", "", err
}
return wc, full, branch, nil
}
// buildCheck says whether Hugo can build the site as it is; when it can't,
// the note says why, for the pull request.
func buildCheck(ctx context.Context, wc *hugorepo.Repo) (bool, string) {
if hugorepo.HugoVersion(ctx) == "" {
return false, "Not checked with a build: there's no Hugo in Supermarket's image."
}
out, err := wc.Build(ctx)
if err != nil {
return false, "Not checked with a build: " + err.Error() + " (before the change too)."
}
os.RemoveAll(out)
return true, ""
}
func (ap *Applier) apply(ctx context.Context, d *db.DB, c *Change) error {
wc, full, branch, err := ap.workingCopy(ctx)
if err != nil {
return err
}
u, err := url.Parse(c.Page)
@@ -560,19 +584,7 @@ func (ap *Applier) apply(ctx context.Context, d *db.DB, c *Change) error {
}
// Can Hugo build the site as it is? If not, the change can't be checked
// by a build, and the pull request says so.
note := ""
canBuild := hugorepo.HugoVersion(ctx) != ""
if canBuild {
out, err := wc.Build(ctx)
if err != nil {
canBuild = false
note = "Not checked with a build: " + err.Error() + " (before the change too)."
} else {
os.RemoveAll(out)
}
} else {
note = "Not checked with a build: there's no Hugo in Supermarket's image."
}
canBuild, note := buildCheck(ctx, wc)
work := fmt.Sprintf("supermarket/seo-%d", c.ID)
if err := wc.NewBranch(ctx, work); err != nil {
return err