← Files Guanyin Oracle · 观音灵签ARCHIVED FILE

scripts/draw-sign.mjs

563 Bytes · Oct 2, 2026 · 00:27 UTC

↓ Download file

import { randomInt } from 'node:crypto'
import { readFile } from 'node:fs/promises'

const corpusUrl = new URL('../data/guanyin-signs.json', import.meta.url)
const signs = JSON.parse(await readFile(corpusUrl, 'utf8'))

if (!Array.isArray(signs) || signs.length !== 100) {
  throw new Error('The Guanyin sign corpus must contain exactly 100 signs.')
}

const stick = signs[randomInt(signs.length)]

process.stdout.write(
  `${JSON.stringify(
    {
      ritual: '观音灵签',
      drawnAt: new Date().toISOString(),
      stick
    },
    null,
    2
  )}\n`
)

SHA-256: a9f9df19d06c34edbfb3e86f71909b9937d7421613ec8b9b60430639d1918469