CodeSampleX

Beispiel

tinyrainbow 2.0.0

Verifiziertes Beispiel für npm tinyrainbow 2.0.0. Der Vertrag lief auf node 22 · linux alpine/x64 · docker und bestand: createColors returns color formatting…

sha256:0bbd7f63d5b3759acbcbe585485a5861df32ef0a1eeecb06deb1e554df9dfe25

Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen. Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen. MIT-0

Ausführungsbelege

Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.

Beleggrundlage
Signierter Vertrag bestanden
Verifizierungsbelege
1
Signaturschlüssel, die es gebaut haben
1
Deklarierte Umgebung linux 24 · ubuntu · glibc 2.39 x64 npm

Umgebungen der Verifizierungsläufe

Umgebung Contract Stufen Lauf
node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1
2026-08-21

Fall

HOW
Ziel
verify pkg:npm/tinyrainbow@2.0.0
Pakete
Erstellt
2026-08-21T12:10:00Z

Contract

  1. createColors returns color formatting functions that wrap text in ANSI escape codes when colors are enabled
  2. createColors returns no-op formatting functions that return plain text when colors are disabled
  3. getDefaultColors returns unformatted plain text functions with isColorSupported false
  4. nested color formatting restores the outer ANSI color code on close

Dateien

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

Quellartefakt herunterladen (tar.gz)

Quelltext

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/tinyrainbow@2.0.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/tinyrainbow@2.0.0

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:33c149464e21b9081f63f49a2397bb7858863f9602aaa049e3cd6b61b9dd81cd","contract":["createColors returns color formatting functions that wrap text in ANSI escape codes when colors are enabled","createColors returns no-op formatting functions that return plain text when colors are disabled","getDefaultColors returns unformatted plain text functions with isColorSupported false","nested color formatting restores the outer ANSI color code on close"],"goal":"verify pkg:npm/tinyrainbow@2.0.0","kind":"HOW","packages":["pkg:npm/tinyrainbow@2.0.0"],"schemaVersion":1},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/tinyrainbow@2.0.0"],"schemaVersion":1,"subject":"pkg:npm/tinyrainbow@2.0.0","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-tinyrainbow",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-tinyrainbow",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "tinyrainbow": "2.0.0"
      }
    },
    "node_modules/tinyrainbow": {
      "version": "2.0.0",
      "resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-2.0.0.tgz",
      "integrity": "sha512-op4nsTR47R6p0vMUUoYl/a+ljLFVtlfaXkLQmqfLR1qHma1h/ysYk4hEXZ880bf2CYgTskvTa/e196Vd5dDQXw==",
      "license": "MIT",
      "engines": {
        "node": ">=14.0.0"
      }
    }
  }
}
package.json
{
  "name": "sample-tinyrainbow",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "description": "Clean-room verification sample for tinyrainbow",
  "main": "src/index.js",
  "scripts": {
    "test": "node test/contract.mjs"
  },
  "dependencies": {
    "tinyrainbow": "2.0.0"
  },
  "license": "MIT-0"
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/tinyrainbow@2.0.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/tinyrainbow@2.0.0"
  ]
}
src/index.js
import c, { createColors, getDefaultColors, isSupported } from 'tinyrainbow';

export function formatMessage(text, colorName, forced = true) {
  const colors = createColors(forced);
  if (typeof colors[colorName] === 'function') {
    return colors[colorName](text);
  }
  return text;
}

export { c as defaultColors, createColors, getDefaultColors, isSupported };
test/contract.mjs
import assert from 'node:assert/strict';
import { createColors, getDefaultColors, isSupported } from 'tinyrainbow';
import { formatMessage } from '../src/index.js';

// 1. Basic properties and exports
assert.strictEqual(typeof createColors, 'function', 'createColors should be a function');
assert.strictEqual(typeof getDefaultColors, 'function', 'getDefaultColors should be a function');
assert.strictEqual(typeof isSupported, 'function', 'isSupported should be a function');

// 2. Default uncolored instance from getDefaultColors()
const defaultInstance = getDefaultColors();
assert.strictEqual(defaultInstance.isColorSupported, false, 'defaultInstance should have isColorSupported false');
assert.strictEqual(defaultInstance.red('test'), 'test', 'getDefaultColors red should return plain text');
assert.strictEqual(defaultInstance.bold('test'), 'test', 'getDefaultColors bold should return plain text');
assert.strictEqual(defaultInstance.red.open, '', 'getDefaultColors red.open should be empty');
assert.strictEqual(defaultInstance.red.close, '', 'getDefaultColors red.close should be empty');

// 3. Forced colors enabled with createColors(true) and FORCE_COLOR=1
process.env.FORCE_COLOR = '1';
delete process.env.NO_COLOR;
const enabled = createColors(true);
assert.strictEqual(enabled.isColorSupported, true, 'createColors(true) with FORCE_COLOR=1 should have isColorSupported true');

// Modifiers
assert.strictEqual(enabled.bold('bold'), '\x1b[1mbold\x1b[22m', 'bold should wrap with correct ANSI codes');
assert.strictEqual(enabled.dim('dim'), '\x1b[2mdim\x1b[22m', 'dim should wrap with correct ANSI codes');
assert.strictEqual(enabled.italic('italic'), '\x1b[3mitalic\x1b[23m', 'italic should wrap with correct ANSI codes');
assert.strictEqual(enabled.underline('under'), '\x1b[4munder\x1b[24m', 'underline should wrap with correct ANSI codes');
assert.strictEqual(enabled.inverse('inv'), '\x1b[7minv\x1b[27m', 'inverse should wrap with correct ANSI codes');
assert.strictEqual(enabled.hidden('hid'), '\x1b[8mhid\x1b[28m', 'hidden should wrap with correct ANSI codes');
assert.strictEqual(enabled.strikethrough('strike'), '\x1b[9mstrike\x1b[29m', 'strikethrough should wrap with correct ANSI codes');

// Foreground colors
assert.strictEqual(enabled.black('text'), '\x1b[30mtext\x1b[39m', 'black should wrap with correct ANSI codes');
assert.strictEqual(enabled.red('text'), '\x1b[31mtext\x1b[39m', 'red should wrap with correct ANSI codes');
assert.strictEqual(enabled.green('text'), '\x1b[32mtext\x1b[39m', 'green should wrap with correct ANSI codes');
assert.strictEqual(enabled.yellow('text'), '\x1b[33mtext\x1b[39m', 'yellow should wrap with correct ANSI codes');
assert.strictEqual(enabled.blue('text'), '\x1b[34mtext\x1b[39m', 'blue should wrap with correct ANSI codes');
assert.strictEqual(enabled.magenta('text'), '\x1b[35mtext\x1b[39m', 'magenta should wrap with correct ANSI codes');
assert.strictEqual(enabled.cyan('text'), '\x1b[36mtext\x1b[39m', 'cyan should wrap with correct ANSI codes');
assert.strictEqual(enabled.white('text'), '\x1b[37mtext\x1b[39m', 'white should wrap with correct ANSI codes');
assert.strictEqual(enabled.gray('text'), '\x1b[90mtext\x1b[39m', 'gray should wrap with correct ANSI codes');

// Background colors
assert.strictEqual(enabled.bgBlack('text'), '\x1b[40mtext\x1b[49m', 'bgBlack should wrap with correct ANSI codes');
assert.strictEqual(enabled.bgRed('text'), '\x1b[41mtext\x1b[49m', 'bgRed should wrap with correct ANSI codes');
assert.strictEqual(enabled.bgGreen('text'), '\x1b[42mtext\x1b[49m', 'bgGreen should wrap with correct ANSI codes');
assert.strictEqual(enabled.bgYellow('text'), '\x1b[43mtext\x1b[49m', 'bgYellow should wrap with correct ANSI codes');
assert.strictEqual(enabled.bgBlue('text'), '\x1b[44mtext\x1b[49m', 'bgBlue should wrap with correct ANSI codes');
assert.strictEqual(enabled.bgMagenta('text'), '\x1b[45mtext\x1b[49m', 'bgMagenta should wrap with correct ANSI codes');
assert.strictEqual(enabled.bgCyan('text'), '\x1b[46mtext\x1b[49m', 'bgCyan should wrap with correct ANSI codes');
assert.strictEqual(enabled.bgWhite('text'), '\x1b[47mtext\x1b[49m', 'bgWhite should wrap with correct ANSI codes');

// Open / close properties
assert.strictEqual(enabled.red.open, '\x1b[31m', 'red.open should be opening escape sequence');
assert.strictEqual(enabled.red.close, '\x1b[39m', 'red.close should be closing escape sequence');
assert.strictEqual(enabled.bold.open, '\x1b[1m', 'bold.open should be opening escape sequence');
assert.strictEqual(enabled.bold.close, '\x1b[22m', 'bold.close should be closing escape sequence');

// Nested formatting
const nested = enabled.red('hello ' + enabled.green('world') + ' again');
assert.strictEqual(nested, '\x1b[31mhello \x1b[32mworld\x1b[31m again\x1b[39m', 'nested colors should restore outer color on close');

// Wrapper function test
assert.strictEqual(formatMessage('status', 'green', true), '\x1b[32mstatus\x1b[39m', 'formatMessage helper should format text');

// 4. Forced colors disabled with NO_COLOR=1
process.env.NO_COLOR = '1';
delete process.env.FORCE_COLOR;
const disabled = createColors(false);
assert.strictEqual(disabled.isColorSupported, false, 'createColors(false) with NO_COLOR=1 should have isColorSupported false');
assert.strictEqual(disabled.red('plain'), 'plain', 'disabled red should return plain text');
assert.strictEqual(disabled.bold('plain'), 'plain', 'disabled bold should return plain text');
assert.strictEqual(disabled.bgBlue('plain'), 'plain', 'disabled bgBlue should return plain text');

console.log('Contract tests passed successfully.');

Ursprungs-Seeder

anonym