CodeSampleX

Sample

color-convert 2.0.1

Verified sample for npm color-convert 2.0.1. The contract ran on node 22 · linux alpine/x64 · docker and passed: converts RGB values to Hex string and Hex…

sha256:9ae5a8f3483c114578ad9e51137121366770cb1461a402d4ab4c49e2f53b63c9

This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured. How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people. MIT-0

Execution evidence

The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.

Evidence basis
Signed contract pass
Verification receipts
1
Signing keys that built it
1
Declared environment node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Verification-run environments

Environment Contract Stages Run
node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5…
2026-08-23

Case

HOW
Goal
verify pkg:npm/color-convert@2.0.1
Packages
Environment
node 22.23.2
Created
2026-08-23T08:13:39Z

Contract

  1. converts RGB values to Hex string and Hex string to RGB array
  2. converts RGB values to HSL array and HSL array to RGB array
  3. converts color keyword names to RGB array and RGB values to keyword names
  4. supports multi-hop conversions between Hex, HSL, CMYK, and HSV color models
  5. converts RGB values to ANSI 256 color codes and ANSI 256 codes to RGB array

Files

  • PROMPT.md
  • csx.json
  • index.js
  • package-lock.json
  • package.json
  • spec.json
  • test/contract.mjs

Download the source artifact (tar.gz)

Source

PROMPT.md
Clean-room public code sample — generation instructions

Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.

A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.

Goal: verify pkg:npm/color-convert@2.0.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/color-convert@2.0.1

Rules:
  - One focused purpose; the smallest project that proves the goal.
  - Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
  - Pin every dependency with a lockfile so resolution is reproducible.
  - No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
  - No personal names, emails, company names, or project identifiers of any kind.
  - No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
  - Keep it under 200 files and 256KB packed.
csx.json
{"case":{"caseId":"case:sha256:3d4db4b4d7bf940a85511b6e89d3d4e266d65fb2d6f5c8091411886500b25e2c","contract":["converts RGB values to Hex string and Hex string to RGB array","converts RGB values to HSL array and HSL array to RGB array","converts color keyword names to RGB array and RGB values to keyword names","supports multi-hop conversions between Hex, HSL, CMYK, and HSV color models","converts RGB values to ANSI 256 color codes and ANSI 256 codes to RGB array"],"goal":"verify pkg:npm/color-convert@2.0.1","kind":"HOW","packages":["pkg:npm/color-convert@2.0.1"],"schemaVersion":1},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/color-convert@2.0.1"],"schemaVersion":1,"subject":"pkg:npm/color-convert@2.0.1","verifierAdapter":"node-typescript@1"}
index.js
const convert = require('color-convert');

/**
 * Converts an RGB color to a hex string without hash.
 * @param {number} r
 * @param {number} g
 * @param {number} b
 * @returns {string} Hex color string (e.g. 'FF0000')
 */
function rgbToHex(r, g, b) {
  return convert.rgb.hex(r, g, b);
}

/**
 * Converts a hex string to RGB array.
 * @param {string} hex
 * @returns {[number, number, number]} RGB array
 */
function hexToRgb(hex) {
  return convert.hex.rgb(hex);
}

/**
 * Converts RGB color to HSL.
 * @param {number} r
 * @param {number} g
 * @param {number} b
 * @returns {[number, number, number]} HSL array [h, s, l]
 */
function rgbToHsl(r, g, b) {
  return convert.rgb.hsl(r, g, b);
}

/**
 * Converts HSL color to RGB.
 * @param {number} h
 * @param {number} s
 * @param {number} l
 * @returns {[number, number, number]} RGB array [r, g, b]
 */
function hslToRgb(h, s, l) {
  return convert.hsl.rgb(h, s, l);
}

/**
 * Converts a CSS color keyword name to RGB.
 * @param {string} keyword
 * @returns {[number, number, number]} RGB array
 */
function keywordToRgb(keyword) {
  return convert.keyword.rgb(keyword);
}

module.exports = {
  convert,
  rgbToHex,
  hexToRgb,
  rgbToHsl,
  hslToRgb,
  keywordToRgb,
};
package-lock.json
{
  "name": "sample-color-convert",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-color-convert",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "color-convert": "2.0.1"
      }
    },
    "node_modules/color-convert": {
      "version": "2.0.1",
      "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
      "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
      "license": "MIT",
      "dependencies": {
        "color-name": "~1.1.4"
      },
      "engines": {
        "node": ">=7.0.0"
      }
    },
    "node_modules/color-name": {
      "version": "1.1.4",
      "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
      "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
      "license": "MIT"
    }
  }
}
package.json
{
  "name": "sample-color-convert",
  "version": "1.0.0",
  "description": "Clean-room sample verifying color-convert functionality",
  "main": "index.js",
  "license": "MIT-0",
  "dependencies": {
    "color-convert": "2.0.1"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/color-convert@2.0.1",
  "kind": "HOW",
  "packages": [
    "pkg:npm/color-convert@2.0.1"
  ]
}
test/contract.mjs
import assert from 'node:assert';
import convert from 'color-convert';
import {
  rgbToHex,
  hexToRgb,
  rgbToHsl,
  hslToRgb,
  keywordToRgb,
} from '../index.js';

// 1. RGB to Hex conversion and reverse
assert.strictEqual(rgbToHex(255, 0, 0), 'FF0000');
assert.strictEqual(convert.rgb.hex([0, 255, 0]), '00FF00');
assert.deepStrictEqual(hexToRgb('FF0000'), [255, 0, 0]);
assert.deepStrictEqual(convert.hex.rgb('00ff00'), [0, 255, 0]);

// 2. RGB to HSL conversion and reverse
assert.deepStrictEqual(rgbToHsl(255, 0, 0), [0, 100, 50]);
assert.deepStrictEqual(hslToRgb(0, 100, 50), [255, 0, 0]);
assert.deepStrictEqual(convert.rgb.hsl(0, 255, 0), [120, 100, 50]);

// 3. Keyword conversions
assert.deepStrictEqual(keywordToRgb('red'), [255, 0, 0]);
assert.deepStrictEqual(convert.keyword.rgb('blue'), [0, 0, 255]);
assert.strictEqual(convert.rgb.keyword(255, 0, 0), 'red');
assert.strictEqual(convert.rgb.keyword(0, 0, 255), 'blue');

// 4. Multi-hop conversions (Hex to HSL, RGB to CMYK, RGB to HSV)
assert.deepStrictEqual(convert.hex.hsl('FF0000'), [0, 100, 50]);
assert.deepStrictEqual(convert.rgb.cmyk(0, 0, 0), [0, 0, 0, 100]);
assert.deepStrictEqual(convert.cmyk.rgb(0, 0, 0, 100), [0, 0, 0]);
assert.deepStrictEqual(convert.rgb.hsv(255, 255, 0), [60, 100, 100]);
assert.deepStrictEqual(convert.hsv.rgb(60, 100, 100), [255, 255, 0]);

// 5. ANSI conversions
assert.strictEqual(convert.rgb.ansi256(255, 255, 255), 231);
assert.deepStrictEqual(convert.ansi256.rgb(231), [255, 255, 255]);

console.log('All contract assertions passed.');

Origin Seeder

anonymous