15 lines
1.9 KiB
JavaScript
15 lines
1.9 KiB
JavaScript
/** Read only retained REA observations. No original filesystem access. */
|
|
import fs from 'node:fs'
|
|
import crypto from 'node:crypto'
|
|
const partial=JSON.parse(fs.readFileSync('.tmp/rea-cpp-plugins-analysis-20261016.json','utf8')).details.partial_observation
|
|
const modules=partial.normalized_result.graph.nodes.flatMap(n=>n.observations??[]).filter(o=>o.evidence?.extractor?.operation==='inventory-relevant-file')
|
|
const metadata=modules.filter(o=>/^marketplaces\/experts\/plugins\/[^/]+\/\.(?:codebuddy|workbuddy)-plugin\/plugin\.json$/.test(o.properties.path)).map(o=>({path:o.properties.path,sha256:o.evidence.artifact.sha256,bytes:o.properties.bytes}))
|
|
const exported=JSON.parse(fs.readFileSync('.tmp/rea-cpp-text-ev_5cc1639489033f42be3eef3c4eea6df9f41c54201a6c86f36680473cd278f8d2.json','utf8'))
|
|
for(const f of exported.normalized_result.files)if(crypto.createHash('sha256').update(f.text).digest('hex')!==f.sha256)throw Error('Retained export SHA mismatch')
|
|
const catalog=JSON.parse(exported.normalized_result.files.find(f=>f.path==='manifest.json').text),map=JSON.parse(exported.normalized_result.files.find(f=>f.path==='expert-bundle-map.json').text)
|
|
const matches=catalog.experts.filter(e=>/高级算法|小算|algorithm engineer|algorithm-engineer/i.test(JSON.stringify([e.id,e.name,e.displayName,e.profession,e.plugin,e.agentName])))
|
|
const otherCandidates=modules.filter(o=>!o.properties.path.includes('node_modules/')&&/algorithm|小算|算法/i.test(o.properties.path)).map(o=>({path:o.properties.path,sha256:o.evidence.artifact.sha256,bytes:o.properties.bytes}))
|
|
const report={partialEvidence:partial.evidence_id,partialScope:partial.normalized_result.graph.coverage,cacheEvidence:exported.evidence_id,metadata,catalogMatches:matches,bundleMap:map,otherCandidates}
|
|
fs.writeFileSync('.tmp/rea-algorithm-locate.json',JSON.stringify(report,null,2))
|
|
console.log(JSON.stringify(report,null,2))
|