Files
krow_talent_app/scripts/owliver-baseline.mjs
Aravind 1775395256 chore(ts-migration): establish TypeScript migration checkpoint
Phases 0-3 of the JS/JSX -> TS/TSX migration. No runtime behaviour changes:
every converted file emits byte-identical JavaScript, verified file by file.

Phase 0 - harness hardening, before any rename:
  - scripts/ssr-resolve.mjs wraps `ssrLoadModule` so the ~170 literal module
    paths in the check scripts resolve .js/.jsx/.ts/.tsx. Without it the first
    rename would have silently destroyed the 1642-check suite that guards the
    Owliver flow.
  - eslint.config.js gains a TypeScript block. Its `files` globs listed only
    {js,mjs,cjs,jsx}, so a renamed file would have dropped out of the run while
    `eslint .` went on exiting 0 - the quietest failure mode available.
  - MIGRATION_BASELINE.md records the measured starting point, including the
    pre-existing seed-fixture failure and the already-broken standalone
    owliver-baseline.mjs, so neither is later mistaken for migration damage.

Phase 1 - tsconfig.json succeeds jsconfig.json, carrying every option across at
its old value. `types` moves from [] to ["vite/client"], which fixes the eight
import.meta errors; @types/node is deliberately excluded so setTimeout stays a
number in browser code. allowJs and checkJs stay on, strict stays off.

Phase 2 - src/types/{api,entities,user}.ts. Transport envelope, error shape,
the entity-name union (the same 18 names are written down twice today, in
httpClient and base44Client, with nothing checking they agree), and the user
record. Every field transcribed from the API contract, the migrations and the
/me projection in me.go - not inferred. Entity record shapes are deliberately
absent: derivable, but nothing consumes them yet.

Phase 3 - nine leaf utilities renamed to .ts with annotations added only where
they could be established from existing usage. Entity records are typed `any`
with a comment naming what they are, rather than a guessed interface.

Verified: tsc 64 errors (65 before; one pre-existing TS2559 genuinely fixed,
none introduced), lint unchanged at 0 errors, skill-check 1641/1642 with only
the known failure, Owliver baseline section 59/59 green, production build
succeeds with the API origin inlined.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HBG1wnuRfJKCstGB8Fekr8
2026-09-11 15:52:01 +05:30

60 lines
2.2 KiB
JavaScript

/**
* Writes the Owliver behaviour baseline.
*
* node scripts/owliver-baseline.mjs # report drift, write nothing
* node scripts/owliver-baseline.mjs --write # (re)generate the snapshot
*
* The snapshot is the existing product's behaviour, recorded before the Agent
* layer was built and asserted by `skill-check.mjs` on every run afterwards.
*
* Regenerating is a deliberate act with a reason attached. A baseline rewritten
* to make a red check go green records the regression instead of catching it,
* which is worse than having no baseline at all — it converts a caught bug into
* a documented one.
*/
import { readFileSync, writeFileSync, existsSync, mkdirSync } from 'node:fs';
import { dirname } from 'node:path';
import { createServer } from 'vite';
import { BASELINE_PATH, captureBaseline } from './owliver-capture.mjs';
import { withSourceResolution } from './ssr-resolve.mjs';
const ROOT = process.cwd();
const server = await createServer({
root: ROOT,
server: { middlewareMode: true },
appType: 'custom',
logLevel: 'error',
});
/* Resolves the capture's module paths whatever extension they carry during the
TypeScript migration. The comparison this script performs is unaffected: it
loads the same modules and serialises the same values. */
withSourceResolution(server, ROOT);
const captured = await captureBaseline(server);
await server.close();
const serialized = `${JSON.stringify(captured, null, 2)}\n`;
if (process.argv.includes('--write')) {
mkdirSync(dirname(BASELINE_PATH), { recursive: true });
writeFileSync(BASELINE_PATH, serialized);
const pages = Object.keys(captured.contexts).length;
console.log(`Baseline written — ${pages} contexts, ${captured.skillIds.length} skills, ${Object.keys(captured.routes).length} routes.`);
process.exit(0);
}
if (!existsSync(BASELINE_PATH)) {
console.error('No baseline recorded. Run `node scripts/owliver-baseline.mjs --write`.');
process.exit(1);
}
if (readFileSync(BASELINE_PATH, 'utf8') === serialized) {
console.log('Owliver behaviour matches the baseline.');
process.exit(0);
}
console.error('Owliver behaviour has DRIFTED from the baseline. Run `npm test` for the per-page detail.');
process.exit(1);