Repository navigation
feat(content): keep on the brief what the pages AI cites have, and write toward it (learning C2) - #1723
Merged
gkhngyk merged 30 commits intoOct 29, 2026
Conversation
…y what they have that the brand's page doesn't Learning C1, part 1 (server). "Analyze competitor content" was a step for a person: nothing looked at the pages AI engines cite where the brand isn't named, so "why do they win?" went unanswered. - competitor-pages.js: from the brand's own tracked answers for the action's prompts over 14 days, the competitors' most cited pages, then pages cited where the brand isn't named (3 an action), and the brand's own page cited there. Each is read free (safe-fetch, public addresses only, never Scrape.do) and run through Site Audit's checks that read the page alone (15: structure, FAQ, schema, statistics, dates, length…). The result: each page's passing checks and the checks at least half the competitor pages pass that the brand's page doesn't. - 00369 cited_page_features: the checks' statuses and word count per brand and page, never the page's text; reused for 14 days; a brand reads at most 12 pages a day (config competitorPages). Service role only; applied on the dev DB. - The task gets the tool competitor_page_features, so the nightly runner carries it out (reading a public page changes nothing, no approval). A run with every read for the day spent leaves the task for the next night (retryLater: recorded as blocked, task untouched). - No AI summary, no paid scraping (user decision 2). The guide says so. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…etitor pages AI cites have that yours doesn't Learning C1, part 2 (web). The task now carries what the nightly read found (part 1); the action drawer shows it when the task is opened. - Task rows read `output`; Analyze competitor content's is parsed defensively (competitor-findings.ts: pages read, the brand's page, the gaps, pages left for tomorrow, why nothing was compared). - TaskDetailView shows "What the pages AI cites instead of yours have": each gap as "FAQ schema — on 2 of 3 of their pages, not on yours" (the check's name as Site Audit's rubric gives it), the pages read with their words and how many answers cited them, the brand's page, and a note that only what the checks found is kept. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ite toward it Learning C2, part 1 (brief). The brief's rebuild already reads a few of the pages AI cited for the draft's prompts to measure their length (CE-030), then threw the rest of what it read away: the writer guessed what those pages have. - content-cited-length.js: the same read also runs Site Audit's page checks (competitor-pages.js, C1) and citedFeatures keeps the checks at least half the pages read pass (two pages at least), with how many. No new read, nothing stored but the brief. - The brief keeps them as citedFeatures beside citedLength. - The writer's brief (briefText) says "What the pages AI cites for these prompts have (Site Audit's checks, 4 pages read): FAQ schema on 3; Tables on 2. Give the page these where they serve its readers." - The Brief tab shows "Cited pages have: FAQ schema (3 of 3) · Tables (2 of 3)" under Length. The guide says so. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… there is nothing to compare, and read every page of an action the same night
Review fixes before the PR (learning C1, server):
- An action that names no prompts (8 of the 9 plans with this task) reads
its topics' prompts (topicPromptIds, shared with basket-metrics), else
the brand's tracked prompts (at most 50), instead of ending on
"no_prompts".
- No prompts, no page cited, or none readable no longer completes the
task: ReadLaterError carries why as the task's output and retryDays (7);
runTask keeps it on the open task with retryAfter, and the nightly sweep
passes the task over until then without it taking a place under the
ceiling.
- An action's pages are all read the same night or none: with fewer reads
left than pages to read, nothing is read and the task waits for the next
night. No more partial runs ("capped" is gone).
- yourPageStatus says whether the brand's page was read, not cited, or
couldn't be read.
- A page with under 500 characters of text (a consent wall, a page drawn
by script) is unreadable.
- An unreadable page is kept as { unreadable: true }: it counts against the
day's reads and isn't read again while fresh. A row that can't be written
is logged, not counted as unreadable.
- Gaps need at least two competitor pages ("compared"); a check is a gap on
at least half of them.
- robots.txt: a site whose robots.txt shuts AnsvisorBot (or every crawler)
out of the whole site isn't read, nor one whose robots.txt can't be read
(RFC 9309); path rules aren't read yet (robotsGroups).
- 00369: the unreadable row shape in a comment (no schema change).
- The guide: the task is carried out by Ansvisor, not waiting for
approval; what it reads, the two-page minimum, robots.txt and the weekly
retry.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…or-page-features-ui
…f theirs is too few, or yours couldn't be read Review fixes before the PR (learning C1, web), after the server's: - The "N more pages wait for tomorrow's reads" line is gone: an action's pages are now read the same night or not at all, so nothing is capped. - With one competitor page read, the task says it takes at least two to compare, instead of "Your page passes…". - The brand's page that couldn't be read says so, rather than "None of your pages was cited". - "at least half of their pages" in the no-gap line, as the server counts; the no-prompts and none-cited reasons say what they now mean. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…titor-features-evidence
…s without Supabase FEATURE_CHECKS, pageContext, pageFeatures, featureGaps and MIN_PAGE_CHARACTERS move from competitor-pages.js to page-features.js, which reads no database. competitor-pages.js loads the supabase admin client, whose config exits when the SUPABASE_* env is absent (as in CI), so a pure module that needs only the checks (the brief, Improve) would take every test file reaching it down with it. competitor-pages.js re-exports them, so its imports keep working; their tests move next to the new module, with no supabase mock. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…titor-features-evidence
…or-page-features-ui
The brief's read of the cited pages needs only Site Audit's page checks, which now live in page-features.js; it no longer goes through competitor-pages.js and the Action Center's database reads for them. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…f's benchmark The brief's rebuild deduplicated the Sources' cited pages by their exact address, so one page cited as www and without, or with tracking parameters, was read twice and counted as two of the cited pages: in the median length, and toward "at least half the pages" for what they have. It now keeps the first address of each page, by the same key that leaves the draft's own page out. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…a page's body can carry The writer's brief listed every check the cited pages pass, FAQ schema, JSON-LD, date markup and freshness among them, though the writer only writes the page's body HTML: the site's template or CMS sets those, and a byline would name a person the writer doesn't know. The brief's line now names only the checks the body can give (WRITER_CHECKS), and none at all when that leaves nothing. The Brief tab still shows them all; the guide says so. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…lf of them pass citedFeatures keeps a check that at least half the pages read pass, not "most of them". Co-Authored-By: Claude Opus 5.5 <[email protected]>
…page-features # Conflicts: # supabase/schema.sql
…or-page-features-ui
…titor-features-evidence
# Conflicts: # supabase/schema.sql
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
8 of 12 tasks
A page of tens of thousands of empty elements held the server for a minute: removing scripts and styles before reading the text spliced each out of its parent, and readability's block find was quadratic in the elements it started from. Both are now one walk over the page, with the same words and blocks as before.
gkhngyk
approved these changes
Oct 29, 2026
gkhngyk
left a comment
Contributor
There was a problem hiding this comment.
Looks good. This PR's own diff needs no change. take-1723 (a145901) is this head d747c0e with take-1720 merged in. Merge it after #1720.
What I checked:
- No new reads. The brief's rebuild already read up to 5 cited pages for their length (CE-030). The page checks now run on those same reads (
readLength→pageFeatures), with no new fetch or cost. A failed check run leaves the length on its own (.catch(() => null)). A page cited under two addresses is now read once (linkKey), which also fixes the length median counting it twice. - Page text and the model. The writer's prompt gets only check labels from our rubric, with a count ("Tables on 3"). It gets no page text and no URL.
citedHavealso keeps only the checks a body can carry (WRITER_CHECKS): no schema, dates or byline asked of the writer. The labels come from the stored brief, which only the draft's own organization can edit. - Speed. These reads run in parallel on a person's request, so a 3 MB page's checks add up to its parse time. The quadratic step it shared with #1718 is fixed in
take-1718, which this branch merges. With it, a 3 MB page's checks take 0.6–4.7 s. Before it, a page of tens of thousands of empty elements took a minute. - Copy. The Brief tab's "The pages AI cites have" line and its docs line match what is kept: the checks at least half the pages read pass.
- Tests.
content-cited-length,content-briefandcontent-writerpass in the full server run on main merged with the stack._brief-tab.test.tsxandbrief.test.tspass, and webtscis clean. - Merge. Clean on main 72f602f, together with #1742–#1746 too.
8 of 9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Learning C2, part 1: the brief keeps what the pages AI cites have, and the Content Agent writes toward it.
Stacked on #1720 (itself on #1718). Review the last 5 commits: 34ee754, b189481, c6f107c, 057222f and e1a43dc. Merge order: #1718 → #1720 → this PR → C2 Improve. There's no migration of its own.
How the brief gets it
content-cited-length.js).page-features.js). There are no extra fetches, and no page text is kept.citedFeatures:{ pages, checks: [{ key, label, pages }] }. These are the checks that at least half of the pages read pass. It takes at least two pages, as for the length.Brief tab
en.jsonand the colors are theme tokens.Content Agent
briefTextadds one line to the brief: what the cited pages have, from the checks.WRITER_CHECKS, 057222f): tables, lists, statistics, quotes and the like.Validation
draftBriefSchemareadscitedFeatureswith bounds: at most 30 pages, 20 checks, and 60- and 120-character strings..catch(undefined), so a bad value is dropped instead of breaking the brief.Where people see it: Content › Editor › a draft › Brief tab, under Length, after Rebuild outline. The text the agent writes with it comes from Rewrite from brief or Suggest changes from brief.
Related issue
Agentic learning report, phase C (C2). No GitHub issue.
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
content-writer.test.jspins this.cd server && npx vitest run src/lib/content-brief.test.js src/lib/content-cited-length.test.js src/lib/content-writer.test.jscd web && npx vitest run "src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_brief-tab.test.tsx" src/lib/content/brief.test.tsChecklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/)yarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)What was run:
yarn lint: passed on the earlier merge with cfd8a35. On this tip,eslintandprettier --checkpass on the changed web and server files. The fullyarn format:checkwasn't run, so its box is unchecked.yarn typecheck: passes on the chain's top (C2 Improve), which holds this PR's web change.🤖 Generated with Claude Code