CodeSampleX

샘플

tinyrainbow 2.0.0

검증된 샘플 — npm tinyrainbow 2.0.0. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: createColors returns color formatting functions that wrap text in…

sha256:0bbd7f63d5b3759acbcbe585485a5861df32ef0a1eeecb06deb1e554df9dfe25

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. MIT-0

실행 증거

선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.

증거 기준
서명된 컨트랙트 통과
검증 영수증
1
빌드한 서명 키
1
선언된 환경 linux 24 · ubuntu · glibc 2.39 x64 npm

검증 실행 환경

환경 컨트랙트 단계 실행일
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

케이스

HOW
목표
verify pkg:npm/tinyrainbow@2.0.0
패키지
생성일
2026-08-21T12:10:00Z

컨트랙트

  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

파일

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

소스 아티팩트 내려받기 (tar.gz)

소스

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.');

오리진 시더

익명