import fs from 'node:fs'; import crypto from 'node:crypto'; const root='skills/ksf-workshop-runtime',sha=x=>crypto.createHash('sha256').update(x).digest('hex'); const hash=sha(fs.readFileSync(root+'/scripts/ksf-workshop.mjs')); const identityHash=sha(fs.readFileSync(root+'/scripts/ksf-identity.mjs')); const file=root+'/scripts/ksf-secure.mjs'; fs.writeFileSync(file,fs.readFileSync(file,'utf8') .replace(/const WORKSHOP_ENTRY_HASH = '[^']+';/,"const WORKSHOP_ENTRY_HASH = '"+hash+"';") .replace(/const IDENTITY_MODULE_HASH = '[^']+';/,"const IDENTITY_MODULE_HASH = '"+identityHash+"';")); const files=['SKILL.md','references/identity.md','references/workshop-tasks.md','references/write-tasks.md','runtime-lock.json','scripts/ksf-identity.mjs','scripts/ksf-identity-bridge.mjs','scripts/ksf-secure.mjs','scripts/ksf-workshop.mjs','scripts/ksf.mjs']; const entries=files.map(file=>sha(fs.readFileSync(root+'/'+file))+' '+file); fs.writeFileSync(root+'/FILES.sha256',entries.sort().join('\n')+'\n'); console.log(JSON.stringify({skill:root,files:entries.length,workshopEntrySha256:hash,identityModuleSha256:identityHash,legacyEntryPreserved:sha(fs.readFileSync(root+'/scripts/ksf.mjs'))==='7ef128f7d022bfbc15c0ec813bfd87995c6297c6efe407a563c840f014aba477'}));