{"_id":"@blockhash/slonks-core","name":"@blockhash/slonks-core","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@blockhash/slonks-core","version":"0.1.0","description":"Shared Slonks model, merge, rendering, and diff utilities.","type":"module","scripts":{"test":"cd ../.. && bun test packages/core"},"exports":{"./attributes":"./src/attributes.ts","./blend":"./src/blend.ts","./diff":"./src/diff.ts","./hex":"./src/hex.ts","./imageModel":"./src/imageModel.ts","./palette":"./src/palette.ts"},"repository":{"type":"git","url":"git+ssh://git@github.com/blockhash-xyz/slonks-api.git","directory":"packages/core"},"bugs":{"url":"https://github.com/blockhash-xyz/slonks-api/issues"},"homepage":"https://github.com/blockhash-xyz/slonks-api/tree/main/packages/core#readme","publishConfig":{"access":"public"},"keywords":["slonks","nft","ethereum","image-model"],"license":"MIT","dependencies":{"viem":"^2.38.4"},"_id":"@blockhash/slonks-core@0.1.0","gitHead":"26d6912db3197f382879d9bc52acf4bb81e602c4","_nodeVersion":"22.12.0","_npmVersion":"10.9.0","dist":{"integrity":"sha512-pFI3pmocTFbAk8cVmeRCl1DY4XIjLsXd+jGq4ZmBg8PMCz2i5xp6+v2o0H2Cf4SyewbBcbei+2Dvyzk+hsutug==","shasum":"62c5bbcb4892be54558f92caf36cbf354d8a0976","tarball":"https://registry.npmjs.org/@blockhash/slonks-core/-/slonks-core-0.1.0.tgz","fileCount":16,"unpackedSize":240607,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDqr3azGb+vjJa2h9RTGq170fxsA6tNuz0LDvJWuxBm1QIhAMYmGDYzSetlsmghAbxfCAbUolfTrdaBl9/NQUd+BweL"}]},"_npmUser":{"name":"hirsch","email":"michael@hirsch.me"},"directories":{},"maintainers":[{"name":"hirsch","email":"michael@hirsch.me"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/slonks-core_0.1.0_1778040680736_0.1426422687939113"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-06T04:11:20.587Z","0.1.0":"2026-05-06T04:11:21.002Z","modified":"2026-05-06T04:11:21.288Z"},"maintainers":[{"name":"hirsch","email":"michael@hirsch.me"}],"description":"Shared Slonks model, merge, rendering, and diff utilities.","homepage":"https://github.com/blockhash-xyz/slonks-api/tree/main/packages/core#readme","keywords":["slonks","nft","ethereum","image-model"],"repository":{"type":"git","url":"git+ssh://git@github.com/blockhash-xyz/slonks-api.git","directory":"packages/core"},"bugs":{"url":"https://github.com/blockhash-xyz/slonks-api/issues"},"license":"MIT","readme":"# @blockhash/slonks-core\n\nShared Slonks utilities for the API and CLI. This package keeps the local\nrendering, merge, palette, attribute, and slop logic in one place so API\npreviews and CLI mining use the same math.\n\n## Install\n\n```bash\nbun add @blockhash/slonks-core\n```\n\nInside this monorepo it is consumed by `@blockhash/slonks-api` and\n`@blockhash/slonks`.\n\n## Exports\n\n- `@blockhash/slonks-core/attributes`: parse CryptoPunks attribute text into token traits.\n- `@blockhash/slonks-core/blend`: blend two 10-byte embeddings with Solidity-compatible integer rounding.\n- `@blockhash/slonks-core/diff`: compare generated palette pixels to original RGBA and produce slop, slop level, and mask.\n- `@blockhash/slonks-core/hex`: convert between `Uint8Array` and `0x` hex.\n- `@blockhash/slonks-core/imageModel`: load bundled model weights, render source/merge embeddings, and compute rendered slop locally.\n- `@blockhash/slonks-core/palette`: CryptoPunks palette constants and decoder.\n\n## Model Data\n\nThe package includes `assets/model_weights_slonk_candidate_10k_18x10_canonical.bin`.\nBy default `imageModel` loads that bundled file. Set\n`SLONKS_MODEL_WEIGHTS_PATH` to point at another compatible weights file when\ntesting a different model artifact.\n\nImportant dimensions:\n\n- Source vocabulary: `10,000`\n- Embedding width: `10` signed bytes\n- Output image: `24 x 24`, or `576` palette indexes\n- Original image input: `2304` RGBA bytes\n- Slop mask: `72` bytes, MSB-first within each byte\n\n## Examples\n\nBlend two source embeddings and compute slop for the rendered result against one original:\n\n```ts\nimport { blendEmbeddings } from \"@blockhash/slonks-core/blend\";\nimport { diffRenderedEmbeddingLocal, sourceEmbeddingLocal } from \"@blockhash/slonks-core/imageModel\";\n\nconst survivorEmbedding = sourceEmbeddingLocal(1819);\nconst donorEmbedding = sourceEmbeddingLocal(7606);\nconst blended = blendEmbeddings(survivorEmbedding, donorEmbedding);\n\nconst originalRgba = new Uint8Array(24 * 24 * 4);\nconst slopResult = diffRenderedEmbeddingLocal(blended, originalRgba);\n```\n\nParse CryptoPunks attribute text:\n\n```ts\nimport { parseAttributesText } from \"@blockhash/slonks-core/attributes\";\n\nconst { punkType, attributes } = parseAttributesText(\"Male, Hoodie, Earring\");\n```\n\nCompute slop from already-rendered palette pixels:\n\n```ts\nimport { diffPixels } from \"@blockhash/slonks-core/diff\";\n\nconst generatedPixels = new Uint8Array(24 * 24);\nconst originalRgba = new Uint8Array(24 * 24 * 4);\nconst { count, slopLevel, mask } = diffPixels(generatedPixels, originalRgba);\n```\n\n## Development\n\nRun from the repo root:\n\n```bash\nbun test packages/core\nbun run test:core\n```\n\n## License\n\nMIT\n","readmeFilename":"README.md","_rev":"1-68190300f57c7ee9db8c3565cce2b5a9"}