Files
ai-for-dummies/.agents/scripts/snapshot-route.mjs
T
Marcos Paulo aae4d42229 docs: add .agents workspace and the Astro refactor plan
Adds the agent-facing workspace and a 20-task plan for migrating the site
to Astro. Nothing here implements the refactor; these are briefs, rules and
templates that the task agents read.

- .agents/ holds context, rules, checklists, skills, specialist agents,
  component/page/config templates and gate scripts. It is vendor-neutral so
  MiniMax, Gemini and Codex can all read it; CLAUDE.md just points at
  AGENTS.md.
- .husky/ plus .lintstagedrc.json wire the three gate tiers. gate.sh locks on
  the shared git-common-dir so parallel worktrees serialise, and guards the
  assertion count in scripts/verify.mjs against a coverage drop.
- plans/astro-refactor/ carries the phase graph, per-task briefs and the
  model-routing recommendation.

These files must be tracked before fanning out: a worktree only checks out
tracked files, so an untracked plan is invisible to every agent working in one.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-05 01:18:27 +00:00

38 lines
1.2 KiB
JavaScript
Executable File

#!/usr/bin/env node
// Rendered-text snapshot of one route. This is the migration's regression net:
// token matching in verify.mjs cannot catch a dropped paragraph, this can.
//
// Usage:
// node .agents/scripts/snapshot-route.mjs http://localhost:4173/models/
// node .agents/scripts/snapshot-route.mjs dist/models/index.html
//
// Take a snapshot from the vanilla site BEFORE migrating, then diff the built
// output against it. An empty diff is the proof that nothing was lost.
import { readFileSync } from 'node:fs';
const target = process.argv[2];
if (!target) {
console.error('usage: snapshot-route.mjs <url|path>');
process.exit(2);
}
const html = target.startsWith('http')
? await (await fetch(target)).text()
: readFileSync(target, 'utf8');
const text = html
// Drop anything that is not user-visible prose.
.replace(/<script[\s\S]*?<\/script>/gi, '')
.replace(/<style[\s\S]*?<\/style>/gi, '')
.replace(/<!--[\s\S]*?-->/g, '')
.replace(/<[^>]+>/g, '\n')
.replace(/&amp;/g, '&').replace(/&lt;/g, '<').replace(/&gt;/g, '>')
.replace(/&quot;/g, '"').replace(/&#0?39;/g, "'").replace(/&nbsp;/g, ' ')
.split('\n')
.map((line) => line.trim())
.filter(Boolean)
.join('\n');
console.log(text);