render-self.mjs

Renders this repo's own standards artifacts with the CLI's TypeScript renderer, profile tooling.

What this is

Renders this repository's own standards artifacts (AGENTS.md, CLAUDE.md, .github/copilot-instructions.md) using the same TypeScript renderer (cli/render/standards.ts) that product repos get via redline init, profile tooling.

How to onboard it

Nothing to onboard, and nothing an onboarded repository ever runs. This is maintainer tooling: it ships in this repository and runs where it already has an environment.

  • Runs in: This (source) repo.
  • Trigger: CI (.github/workflows/ci.yml), job validate, step "Rendered artifacts are current", always with --check. Also referenced by workflows/redline-sync.yml, which is disabled in Phase 1 — see the Workflows section.

To run it yourself you need a checkout of this repository and Node 22 or newer. There are no runtime dependencies to install — every script uses only Node builtins — so a clone and the environment below is the whole setup.

How to use it

terminal
$ node scripts/render-self.mjs         # re-render and write the artifacts
$ node scripts/render-self.mjs --check  # fail if the checked-in artifacts are stale — what CI runs

Run it (without --check) locally after editing standards/ so the checked-in AGENTS.md/CLAUDE.md/copilot-instructions.md stay in sync — otherwise CI's --check step fails your PR.

Expected output

Without --check: writes/prunes the rendered files and lists each with `write` or `prune`. With --check: exits 1 and names the stale files if the checked-in output doesn't match a fresh render; exits 0 otherwise.

How to edit it

  1. Edit the .mjs file directlyNothing generates these — scripts/ is hand-written maintainer tooling with no runtime dependencies. Keep it that way: package.json declares none, and these run in CI with only Node's builtins available.
  2. node --check scripts/<file>.mjsCI's lint job parses every script in scripts/. A syntax error there fails the build without running anything.
  3. Run it locally with the same env CI gives itEach script is env-configured with no argument parsing, so a local run is the CI run. The environment variables it needs are listed above.

The full file

scripts/render-self.mjs · 19 lines · 0.8 KB
#!/usr/bin/env node
// Renders this repository's own standards artifacts. The estate-wide renderer lives
// in cli/render/standards.ts; this is the two-line shim CI calls.
import { resolve, dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
import { render } from '../cli/render/standards.ts';

const root = resolve(dirname(fileURLToPath(import.meta.url)), '..');
const check = process.argv.includes('--check');
const result = render({ root, profile: 'tooling', out: root, check });

if (result.stale.length) {
  console.error(`Rendered output is stale. Run: node scripts/render-self.mjs\n  ${result.stale.join('\n  ')}`);
  process.exit(1);
}
result.written.forEach((f) => console.log(`  write  ${f}`));
result.removed.forEach((f) => console.log(`  prune  ${f}`));
if (!result.written.length && !result.removed.length) console.log('  up to date');