샘플
chalk 4.1.2
검증된 샘플 — npm chalk 4.1.2. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: chalk styles terminal text with foreground colors, background colors…
sha256:af420db0115b2b548c363f73f273b92231b8be663d8fd051f3515d934e0af195
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-19 |
케이스
HOW- 목표
- verify pkg:npm/chalk@4.1.2
- 패키지
- 환경
- node 22.23.2
- 생성일
- 2026-08-19T18:31:31Z
컨트랙트
- chalk styles terminal text with foreground colors, background colors, and text modifiers
- chalk supports style chaining and truecolor models including RGB and Hex
- chalk Instance level configuration allows controlling ANSI color support and disabling styles deterministically
파일
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.js
소스
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/chalk@4.1.2
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/chalk@4.1.2
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- packageManager: npm@10.9.8
- runtime: node@22.23.2
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:40ee748ff7076525c89f4c453b8ddb99f18432b01ec562101d280e615754f97c","constraints":{"executionContext":"node"},"contract":["chalk styles terminal text with foreground colors, background colors, and text modifiers","chalk supports style chaining and truecolor models including RGB and Hex","chalk Instance level configuration allows controlling ANSI color support and disabling styles deterministically"],"goal":"verify pkg:npm/chalk@4.1.2","kind":"HOW","packages":["pkg:npm/chalk@4.1.2"],"schemaVersion":1},"contractCommand":["node","test/contract.js"],"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/chalk@4.1.2"],"schemaVersion":1,"verifierAdapter":"node-typescript@1"}
{
"name": "chalk-sample",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "chalk-sample",
"version": "1.0.0",
"dependencies": {
"chalk": "4.1.2"
}
},
"node_modules/ansi-styles": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"license": "MIT",
"dependencies": {
"color-convert": "^2.0.1"
},
"engines": {
"node": ">=8"
},
"funding": {
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
}
},
"node_modules/chalk": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
"integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
"license": "MIT",
"dependencies": {
"ansi-styles": "^4.1.0",
"supports-color": "^7.1.0"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/chalk/chalk?sponsor=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"
},
"node_modules/has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/supports-color": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
"license": "MIT",
"dependencies": {
"has-flag": "^4.0.0"
},
"engines": {
"node": ">=8"
}
}
}
}
{
"name": "chalk-sample",
"version": "1.0.0",
"dependencies": {
"chalk": "4.1.2"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/chalk@4.1.2",
"kind": "HOW",
"packages": [
"pkg:npm/chalk@4.1.2"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
const chalk = require('chalk');
/**
* Creates a configured Chalk instance with explicit color level support.
*
* @param {number} [level=3] - Color level (0: disabled, 1: 16 colors, 2: 256 colors, 3: 16M truecolor).
* @returns {import('chalk').Chalk}
*/
function createFormatter(level = 3) {
return new chalk.Instance({ level });
}
/**
* Formats text with standard foreground color and optional bold modifier.
*
* @param {import('chalk').Chalk} instance
* @param {string} text
* @param {'blue'|'green'|'red'|'yellow'} color
* @param {boolean} [bold=false]
* @returns {string}
*/
function formatColor(instance, text, color, bold = false) {
let fn = instance[color];
if (bold) {
fn = fn.bold;
}
return fn(text);
}
/**
* Formats text with background color.
*
* @param {import('chalk').Chalk} instance
* @param {string} text
* @param {'bgBlue'|'bgGreen'|'bgRed'|'bgYellow'} bgColor
* @returns {string}
*/
function formatBackground(instance, text, bgColor) {
return instance[bgColor](text);
}
/**
* Formats text using custom RGB truecolor.
*
* @param {import('chalk').Chalk} instance
* @param {string} text
* @param {number} r
* @param {number} g
* @param {number} b
* @returns {string}
*/
function formatRgb(instance, text, r, g, b) {
return instance.rgb(r, g, b)(text);
}
/**
* Formats text using custom Hex color.
*
* @param {import('chalk').Chalk} instance
* @param {string} text
* @param {string} hexCode
* @returns {string}
*/
function formatHex(instance, text, hexCode) {
return instance.hex(hexCode)(text);
}
/**
* Formats text with chained styling.
*
* @param {import('chalk').Chalk} instance
* @param {string} text
* @returns {string}
*/
function formatChainedHighlight(instance, text) {
return instance.bold.underline.red(text);
}
module.exports = {
createFormatter,
formatColor,
formatBackground,
formatRgb,
formatHex,
formatChainedHighlight,
chalk,
};
const assert = require('node:assert/strict');
const {
createFormatter,
formatColor,
formatBackground,
formatRgb,
formatHex,
formatChainedHighlight,
} = require('../src/index.js');
// Contract 1: chalk styles terminal text with foreground colors, background colors, and text modifiers
{
const formatter = createFormatter(3);
const blueText = formatColor(formatter, 'blue test', 'blue');
assert.strictEqual(blueText, '\u001b[34mblue test\u001b[39m', 'Should wrap string in ANSI blue foreground escape codes');
const boldGreenText = formatColor(formatter, 'green bold test', 'green', true);
assert.strictEqual(boldGreenText, '\u001b[32m\u001b[1mgreen bold test\u001b[22m\u001b[39m', 'Should apply bold modifier and green foreground codes');
const bgRedText = formatBackground(formatter, 'bg test', 'bgRed');
assert.strictEqual(bgRedText, '\u001b[41mbg test\u001b[49m', 'Should wrap string in ANSI bgRed background escape codes');
}
// Contract 2: chalk supports style chaining and truecolor models including RGB and Hex
{
const formatter = createFormatter(3);
const rgbText = formatRgb(formatter, 'rgb test', 255, 128, 0);
assert.strictEqual(rgbText, '\u001b[38;2;255;128;0mrgb test\u001b[39m', 'Should format text with 24-bit truecolor RGB escape sequence');
const hexText = formatHex(formatter, 'hex test', '#DEADED');
assert.strictEqual(hexText, '\u001b[38;2;222;173;237mhex test\u001b[39m', 'Should convert hex code to 24-bit RGB ANSI escape sequence');
const chainedText = formatChainedHighlight(formatter, 'highlight');
assert.strictEqual(chainedText, '\u001b[1m\u001b[4m\u001b[31mhighlight\u001b[39m\u001b[24m\u001b[22m', 'Should compose bold, underline, and red styling');
}
// Contract 3: chalk Instance level configuration allows controlling ANSI color support and disabling styles deterministically
{
const disabledFormatter = createFormatter(0);
assert.strictEqual(disabledFormatter.level, 0, 'Instance color level should be 0');
const plainBlue = formatColor(disabledFormatter, 'plain text', 'blue');
assert.strictEqual(plainBlue, 'plain text', 'Level 0 formatter should return unmodified plain text for color styles');
const plainChained = formatChainedHighlight(disabledFormatter, 'plain text');
assert.strictEqual(plainChained, 'plain text', 'Level 0 formatter should return unmodified plain text for chained styles');
const level1Formatter = createFormatter(1);
assert.strictEqual(level1Formatter.level, 1, 'Instance color level should be 1');
const level1Blue = formatColor(level1Formatter, 'basic blue', 'blue');
assert.strictEqual(level1Blue, '\u001b[34mbasic blue\u001b[39m', 'Level 1 basic color returns standard ANSI code');
}
console.log('All pkg:npm/chalk@4.1.2 contracts passed successfully.');
오리진 시더
익명