Пример
tinyrainbow 2.0.0
Проверенный пример — npm tinyrainbow 2.0.0. Контракт выполнен на node 22 · linux alpine/x64 · docker и пройден: createColors returns formatting functions…
sha256:ee8e509fe779ba3016f34b129ba0baabd7d0f2ac35ad8e470708ca585bccb4ff
Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла.
Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди.
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@1node:22-alpine@sha256:c610fcdfb1d5… |
2026-08-27 |
Кейс
HOW- Цель
- verify pkg:npm/tinyrainbow@2.0.0
- Пакеты
- Создан
- 2026-08-27T17:44:45Z
Контракт
- createColors returns formatting functions that apply ANSI escape sequences for basic and bright colors when color support is enabled
- createColors returns plain string passthrough functions with empty open and close delimiters when color support is disabled
- getDefaultColors returns an uncolored formatting instance with isColorSupported false
- isSupported returns boolean terminal color capability based on environment variables and TTY status
- nested colors restore parent foreground escape code and nested modifiers restore parent open escape code
Файлы
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.mjs
Исходный код
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.
{"case":{"caseId":"case:sha256:6d801f99d64b2f159d510dfdd88eaf2be2308049480c401ca109006c0279c64f","contract":["createColors returns formatting functions that apply ANSI escape sequences for basic and bright colors when color support is enabled","createColors returns plain string passthrough functions with empty open and close delimiters when color support is disabled","getDefaultColors returns an uncolored formatting instance with isColorSupported false","isSupported returns boolean terminal color capability based on environment variables and TTY status","nested colors restore parent foreground escape code and nested modifiers restore parent open escape code"],"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"}
{
"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"
}
}
}
}
{
"name": "sample-tinyrainbow",
"version": "1.0.0",
"private": true,
"type": "module",
"description": "Clean-room verification sample for tinyrainbow ANSI color and style formatting",
"main": "src/index.js",
"scripts": {
"test": "node test/contract.mjs"
},
"dependencies": {
"tinyrainbow": "2.0.0"
},
"license": "MIT-0"
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/tinyrainbow@2.0.0",
"kind": "HOW",
"packages": [
"pkg:npm/tinyrainbow@2.0.0"
]
}
import colors, { createColors, getDefaultColors, isSupported } from 'tinyrainbow';
export function formatStatus(message, type = 'info') {
const c = createColors();
switch (type) {
case 'error':
return c.redBright(message);
case 'success':
return c.greenBright(message);
case 'warn':
return c.yellowBright(message);
default:
return c.cyanBright(message);
}
}
export { colors as default, createColors, getDefaultColors, isSupported };
import assert from 'node:assert/strict';
import colors, { createColors, getDefaultColors, isSupported } from 'tinyrainbow';
import { formatStatus } from '../src/index.js';
// 1. Module exports and functions
assert.strictEqual(typeof createColors, 'function', 'createColors should be exported as a function');
assert.strictEqual(typeof getDefaultColors, 'function', 'getDefaultColors should be exported as a function');
assert.strictEqual(typeof isSupported, 'function', 'isSupported should be exported as a function');
// 2. Color formatting enabled with FORCE_COLOR=1
process.env.FORCE_COLOR = '1';
delete process.env.NO_COLOR;
const c = createColors();
assert.strictEqual(isSupported(), true, 'isSupported should return true when FORCE_COLOR is set');
assert.strictEqual(c.isColorSupported, true, 'isColorSupported should be true');
// Basic foreground and background colors
assert.strictEqual(c.red('error'), '\x1b[31merror\x1b[39m', 'red should wrap text in ANSI escape code 31/39');
assert.strictEqual(c.green('success'), '\x1b[32msuccess\x1b[39m', 'green should wrap text in ANSI escape code 32/39');
assert.strictEqual(c.yellow('warn'), '\x1b[33mwarn\x1b[39m', 'yellow should wrap text in ANSI escape code 33/39');
assert.strictEqual(c.blue('info'), '\x1b[34minfo\x1b[39m', 'blue should wrap text in ANSI escape code 34/39');
assert.strictEqual(c.magenta('debug'), '\x1b[35mdebug\x1b[39m', 'magenta should wrap text in ANSI escape code 35/39');
assert.strictEqual(c.cyan('trace'), '\x1b[36mtrace\x1b[39m', 'cyan should wrap text in ANSI escape code 36/39');
assert.strictEqual(c.gray('muted'), '\x1b[90mmuted\x1b[39m', 'gray should wrap text in ANSI escape code 90/39');
assert.strictEqual(c.bgRed('bg-err'), '\x1b[41mbg-err\x1b[49m', 'bgRed should wrap text in ANSI escape code 41/49');
assert.strictEqual(c.bgGreen('bg-ok'), '\x1b[42mbg-ok\x1b[49m', 'bgGreen should wrap text in ANSI escape code 42/49');
// Bright colors
assert.strictEqual(c.redBright('bright-red'), '\x1b[91mbright-red\x1b[39m', 'redBright should wrap text in ANSI escape code 91/39');
assert.strictEqual(c.greenBright('bright-green'), '\x1b[92mbright-green\x1b[39m', 'greenBright should wrap text in ANSI escape code 92/39');
assert.strictEqual(c.yellowBright('bright-yellow'), '\x1b[93mbright-yellow\x1b[39m', 'yellowBright should wrap text in ANSI escape code 93/39');
assert.strictEqual(c.blueBright('bright-blue'), '\x1b[94mbright-blue\x1b[39m', 'blueBright should wrap text in ANSI escape code 94/39');
assert.strictEqual(c.bgRedBright('bg-bright-red'), '\x1b[101mbg-bright-red\x1b[49m', 'bgRedBright should wrap text in ANSI escape code 101/49');
assert.strictEqual(c.bgGreenBright('bg-bright-green'), '\x1b[102mbg-bright-green\x1b[49m', 'bgGreenBright should wrap text in ANSI escape code 102/49');
// Modifiers and reset
assert.strictEqual(c.bold('bold-txt'), '\x1b[1mbold-txt\x1b[22m', 'bold should wrap text in ANSI escape code 1/22');
assert.strictEqual(c.dim('dim-txt'), '\x1b[2mdim-txt\x1b[22m', 'dim should wrap text in ANSI escape code 2/22');
assert.strictEqual(c.italic('italic-txt'), '\x1b[3mitalic-txt\x1b[23m', 'italic should wrap text in ANSI escape code 3/23');
assert.strictEqual(c.underline('underline-txt'), '\x1b[4munderline-txt\x1b[24m', 'underline should wrap text in ANSI escape code 4/24');
assert.strictEqual(c.inverse('inverse-txt'), '\x1b[7minverse-txt\x1b[27m', 'inverse should wrap text in ANSI escape code 7/27');
assert.strictEqual(c.strikethrough('strikethrough-txt'), '\x1b[9mstrikethrough-txt\x1b[29m', 'strikethrough should wrap text in ANSI escape code 9/29');
assert.strictEqual(c.reset('reset-txt'), '\x1b[0mreset-txt\x1b[0m', 'reset should wrap text in ANSI escape code 0/0');
// Open and close delimiter properties
assert.strictEqual(c.bold.open, '\x1b[1m', 'bold.open should return opening escape sequence');
assert.strictEqual(c.bold.close, '\x1b[22m', 'bold.close should return closing escape sequence');
assert.strictEqual(c.red.open, '\x1b[31m', 'red.open should return opening escape sequence');
assert.strictEqual(c.red.close, '\x1b[39m', 'red.close should return closing escape sequence');
assert.strictEqual(c.redBright.open, '\x1b[91m', 'redBright.open should return opening escape sequence');
assert.strictEqual(c.redBright.close, '\x1b[39m', 'redBright.close should return closing escape sequence');
// Nested color formatting
const nestedColor = c.red('outer ' + c.yellow('nested') + ' text');
assert.strictEqual(nestedColor, '\x1b[31mouter \x1b[33mnested\x1b[31m text\x1b[39m', 'nested foreground colors should restore outer color code upon close');
// Nested modifier formatting
const nestedBold = c.bold('bold ' + c.bold('nested') + ' end');
assert.strictEqual(nestedBold, '\x1b[1mbold \x1b[1mnested\x1b[22m\x1b[1m end\x1b[22m', 'nested bold styling should re-apply outer bold upon nested close');
// Helper function
assert.strictEqual(formatStatus('failed', 'error'), '\x1b[91mfailed\x1b[39m', 'formatStatus error should return redBright formatted text');
assert.strictEqual(formatStatus('done', 'success'), '\x1b[92mdone\x1b[39m', 'formatStatus success should return greenBright formatted text');
// 3. Default uncolored instance from getDefaultColors()
const uncolored = getDefaultColors();
assert.strictEqual(uncolored.isColorSupported, false, 'uncolored instance should have isColorSupported false');
assert.strictEqual(uncolored.red('plain'), 'plain', 'uncolored red should return plain text');
assert.strictEqual(uncolored.bold('plain'), 'plain', 'uncolored bold should return plain text');
assert.strictEqual(uncolored.redBright('plain'), 'plain', 'uncolored redBright should return plain text');
assert.strictEqual(uncolored.red.open, '', 'uncolored red.open should be empty string');
assert.strictEqual(uncolored.red.close, '', 'uncolored red.close should be empty string');
// 4. Color formatting disabled with NO_COLOR=1
process.env.NO_COLOR = '1';
delete process.env.FORCE_COLOR;
const disabled = createColors();
assert.strictEqual(disabled.isColorSupported, false, 'disabled instance should have isColorSupported false');
assert.strictEqual(disabled.green('plain-text'), 'plain-text', 'disabled green should return plain text');
assert.strictEqual(disabled.bgBlue('plain-text'), 'plain-text', 'disabled bgBlue should return plain text');
assert.strictEqual(disabled.redBright('plain-text'), 'plain-text', 'disabled redBright should return plain text');
assert.strictEqual(isSupported(), false, 'isSupported should return false when NO_COLOR is set');
console.log('Contract tests passed successfully.');
Исходный сидер
аноним