feat(brand-evolution): per-target design-token extraction + wayback CDX fix#84
Open
feat(brand-evolution): per-target design-token extraction + wayback CDX fix#84
Conversation
A wayback-source job with since=2012, until=2024, snapshotsPerUrl=4 against a popular site returned all four snapshots clustered in 2012-2013, not spread across 2012-2024. CDX's `limit` truncates captures *before* we sample, so for sites with thousands of captures the first 50 chronologically are all in the start of the window. Drop `limit`, use `collapse=timestamp:6` (one capture per month). Bounded by window length, properly distributed. Verified: stripe.com 2012-2024 with count=5 → 2012-02, 2015-03, 2018-03, 2021-02, 2024-01.
…ution template Adds AuditOptions.extractTokens. When true, every target in a comparative-audit job runs the existing deterministic extractDesignTokens after the audit and persists tokens.json to the per-target output dir. The runner threads tokensPath through JobResultEntry. src/reports/tokens.ts — aggregateTokens / diffTokens / groupByUrl. Pure functions over on-disk data. Same contract as aggregate.ts. renderBrandEvolution renders per-URL chronological evolution with snapshot-to-snapshot deltas (colors added/removed, font family swaps, brand-meta changes, library adoption). AI SDK tools: fetchTokens, diffTokens. renderTemplate gains template: 'brand-evolution'. Verified on stripe.com 2014→2024: Whitney → Camphor → sohne-var progression, primary color #008cdd → #6772e5 → #635bff, type-scale grew 25 → 38 → 61 entries. +12 tests. Total: 1460 passing.
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
Two additions on top of the freshly-merged jobs+reports infra (#83):
1. Brand-kit / design-system extraction at every audit target. Comparative-audit jobs now optionally run the existing deterministic `extractDesignTokens` after each audit, persisting `tokens.json` alongside `report.json`. Combined with wayback discovery, this means a single declarative spec produces a full chronological brand evolution for any site.
2. Wayback CDX fix. The previous `limit` param truncated CDX results before `sampleEvenly` ran, so longitudinal jobs over popular sites returned all snapshots clustered in the early window. Replaced with `collapse=timestamp:6` (one capture per month), which bounds payload size while preserving the full window.
What you get
```json
{
"discover": { "source": "wayback", "urls": ["https://stripe.com/"], "snapshotsPerUrl": 3, "since": "2014-01-01", "until": "2024-01-01" },
"audit": { "pages": 1, "extractTokens": true }
}
```
`bad jobs create --spec wayback-tokens.json` → 3 audits + 3 token bundles.
`bad reports generate --template brand-evolution --job ` →
That's the actual stripe.com brand evolution — Whitney → Camphor → sohne-var, primary blue `#008cdd` → purple `#6772e5` → indigo `#635bff`. Pure deterministic DOM extraction. No LLM.
What's in it
```
src/jobs/types.ts AuditOptions.extractTokens, JobResultEntry.tokensPath
src/jobs/queue.ts AuditFn return adds tokensPath
src/cli-jobs.ts wires extractDesignTokens after each audit
src/reports/tokens.ts aggregateTokens / diffTokens / groupByUrl (pure)
src/reports/templates.ts renderBrandEvolution
src/reports/tools.ts fetchTokens + diffTokens AI SDK tools
renderTemplate accepts 'brand-evolution'
src/discover/wayback.ts CDX collapse=timestamp:6 (was: limit=count*4)
```
Tests
+12 across `reports-tokens` and queue/tools touch-ups. Total: 1460 passing (up from 1448).
Test plan
Notes