chore: establish YCode replication baseline and TODO

This commit is contained in:
xiaohan.yuan committed 2026-10-17 02:43:49 +08:00
commit 6dc59f89ba
1118 files changed
+196002

No files matched your search

@@ -0,0 +1,35 @@
// Reads previously exported REA evidence only. Does not access or execute WorkBuddy.
import fs from 'node:fs/promises'
import path from 'node:path'
import crypto from 'node:crypto'
import { parse } from '@babel/parser'
import generatePackage from '@babel/generator'
const generate = generatePackage.default ?? generatePackage
const bundle = JSON.parse(await fs.readFile('.tmp/rea-runtime-scripts.json', 'utf8'))
const script = bundle.items.find(item => item.file_path?.endsWith('src-Cng7axVa.js'))
if (!script?.source?.included) throw new Error('Missing REA-captured Artifact source')
const source = script.source.artifact.text
const sha256 = crypto.createHash('sha256').update(source).digest('hex')
if (sha256 !== script.source.artifact.sha256) throw new Error('REA source digest mismatch')
const names = new Set(['ArtifactContentRenderer', 'MarkdownViewer', 'useCustomArtifactContent', 'useDiffContent',
'shouldRenderHtmlPreview', 'isHtmlPreviewSizeOversized', 'resolveHtmlPreviewSizeLimit', 'isHtmlFileName',
'shouldRemountMediaArtifactOnRefresh', 'rl', 'il', 'al'])
const output = path.resolve('.tmp/rea-artifact-recovered')
await fs.mkdir(output, { recursive: true })
const records = []
function visit(node) {
if (!node || typeof node !== 'object') return
const name = node.type === 'FunctionDeclaration' ? node.id?.name : node.type === 'AssignmentExpression' ? node.left?.name : undefined
if (names.has(name)) records.push({ name, start: node.start, end: node.end, text: generate(node).code })
for (const value of Object.values(node)) {
if (Array.isArray(value)) value.forEach(visit)
else if (value && typeof value === 'object') visit(value)
}
}
visit(parse(source, { sourceType: 'module' }).program)
for (const record of records) await fs.writeFile(path.join(output, `${record.name}.js`), record.text + '\n')
const manifest = { evidenceId: bundle.evidence_id, sourcePath: script.file_path, sourceSha256: sha256,
method: 'Babel parse/generate; reference only, not executed', units: 'UTF-16; end-exclusive',
definitions: records.map(({ text, ...record }) => ({ ...record, file: `${record.name}.js` })) }
await fs.writeFile(path.join(output, 'manifest.json'), JSON.stringify(manifest, null, 2))
console.log(JSON.stringify(manifest))