Exemplo
kleur 4.1.5: green
Amostra verificada para npm kleur 4.1.5: green. O contrato rodou em node 22 · linux alpine/x64 · docker e passou: kleur.green formats strings with green ANSI…
sha256:071493a41ad4cbcb9a40d7445a5b4800678928ff5ba130c31e5d9abf6000c7bc
Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu.
Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas.
MIT-0
Evidência de execução
O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.
- Base da evidência
- Contrato assinado aprovado
- Recibos de verificação
- 1
- Chaves de assinatura que o compilaram
- 1
Ambiente declarado
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
Ambientes das execuções de verificação
| Ambiente | Contrato | Etapas | Execução |
|---|---|---|---|
| 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 |
Caso
HOW- Objetivo
- verify kleur.green in pkg:npm/kleur@4.1.5
- Pacotes
- Símbolos
-
- kleur.green
- Ambiente
- node 22.23.2
- Criado
- 2026-08-27T12:11:17Z
Contrato
- kleur.green formats strings with green ANSI escape codes when enabled
- kleur.green supports chaining with text style modifiers such as bold, dim, and underline
- kleur.green supports chaining with background colors such as bgBlack and bgWhite
- kleur.green returns plain unformatted text when kleur.enabled is false
- kleur.green correctly restores and preserves nested styling
Arquivos
- PROMPT.md
- csx.json
- index.js
- package-lock.json
- package.json
- spec.json
- test/contract.cjs
Código-fonte
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 kleur.green in pkg:npm/kleur@4.1.5
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/kleur@4.1.5
Demonstrate these symbols/APIs:
- kleur.green
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:7d95744d7b273c676f011baa302bd353f35ffacdc36d417b481df4c1c900d717","contract":["kleur.green formats strings with green ANSI escape codes when enabled","kleur.green supports chaining with text style modifiers such as bold, dim, and underline","kleur.green supports chaining with background colors such as bgBlack and bgWhite","kleur.green returns plain unformatted text when kleur.enabled is false","kleur.green correctly restores and preserves nested styling"],"goal":"verify kleur.green in pkg:npm/kleur@4.1.5","kind":"HOW","packages":["pkg:npm/kleur@4.1.5"],"schemaVersion":1,"symbols":["kleur.green"]},"contractCommand":["node","test/contract.cjs"],"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/kleur@4.1.5"],"schemaVersion":1,"subject":"pkg:npm/kleur@4.1.5","symbols":["kleur.green"],"verifierAdapter":"node-typescript@1"}
'use strict';
const kleur = require('kleur');
/**
* Format text in green ANSI color.
* @param {string} text
* @returns {string}
*/
function formatGreen(text) {
return kleur.green(text);
}
/**
* Format text in bold green ANSI color.
* @param {string} text
* @returns {string}
*/
function formatGreenBold(text) {
return kleur.green().bold(text);
}
/**
* Format text in green with specified background color modifier.
* @param {string} text
* @param {'bgBlack' | 'bgWhite'} bg
* @returns {string}
*/
function formatGreenOnBg(text, bg) {
if (bg === 'bgWhite') {
return kleur.green().bgWhite(text);
}
return kleur.green().bgBlack(text);
}
/**
* Enable or disable color formatting.
* @param {boolean} flag
*/
function setColorsEnabled(flag) {
kleur.enabled = flag;
}
module.exports = {
kleur,
green: kleur.green,
formatGreen,
formatGreenBold,
formatGreenOnBg,
setColorsEnabled
};
{
"name": "sample-kleur-green",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-kleur-green",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"kleur": "4.1.5"
}
},
"node_modules/kleur": {
"version": "4.1.5",
"resolved": "https://registry.npmjs.org/kleur/-/kleur-4.1.5.tgz",
"integrity": "sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==",
"license": "MIT",
"engines": {
"node": ">=6"
}
}
}
}
{
"name": "sample-kleur-green",
"version": "1.0.0",
"private": true,
"description": "verify kleur.green in pkg:npm/kleur@4.1.5",
"main": "index.js",
"scripts": {
"test": "node test/contract.cjs"
},
"dependencies": {
"kleur": "4.1.5"
},
"license": "MIT-0"
}
{
"schemaVersion": 1,
"goal": "verify kleur.green in pkg:npm/kleur@4.1.5",
"kind": "HOW",
"packages": [
"pkg:npm/kleur@4.1.5"
],
"symbols": [
"kleur.green"
]
}
'use strict';
const assert = require('node:assert');
const kleur = require('kleur');
const { green, formatGreen, formatGreenBold, formatGreenOnBg, setColorsEnabled } = require('../index.js');
function testContract() {
const initialEnabled = kleur.enabled;
try {
// 1. kleur.green formats strings with green ANSI escape codes when enabled
kleur.enabled = true;
assert.strictEqual(kleur.green('sample'), '\x1b[32msample\x1b[39m');
assert.strictEqual(green('sample'), '\x1b[32msample\x1b[39m');
assert.strictEqual(formatGreen('sample'), '\x1b[32msample\x1b[39m');
// 2. kleur.green supports chaining with text style modifiers such as bold, dim, and underline
assert.strictEqual(kleur.green().bold('sample'), '\x1b[32m\x1b[1msample\x1b[39m\x1b[22m');
assert.strictEqual(kleur.green().dim('sample'), '\x1b[32m\x1b[2msample\x1b[39m\x1b[22m');
assert.strictEqual(kleur.green().underline('sample'), '\x1b[32m\x1b[4msample\x1b[39m\x1b[24m');
assert.strictEqual(formatGreenBold('sample'), '\x1b[32m\x1b[1msample\x1b[39m\x1b[22m');
// 3. kleur.green supports chaining with background colors such as bgBlack and bgWhite
assert.strictEqual(kleur.green().bgBlack('sample'), '\x1b[32m\x1b[40msample\x1b[39m\x1b[49m');
assert.strictEqual(kleur.green().bgWhite('sample'), '\x1b[32m\x1b[47msample\x1b[39m\x1b[49m');
assert.strictEqual(formatGreenOnBg('sample', 'bgBlack'), '\x1b[32m\x1b[40msample\x1b[39m\x1b[49m');
// 4. kleur.green returns plain unformatted text when kleur.enabled is false
setColorsEnabled(false);
assert.strictEqual(kleur.enabled, false);
assert.strictEqual(kleur.green('sample'), 'sample');
assert.strictEqual(green('sample'), 'sample');
assert.strictEqual(formatGreen('sample'), 'sample');
assert.strictEqual(formatGreenBold('sample'), 'sample');
// 5. kleur.green correctly restores and preserves nested styling
setColorsEnabled(true);
const inner = kleur.green('inner');
const nested = kleur.green(`outer ${inner} outer`);
assert.strictEqual(nested, '\x1b[32mouter \x1b[32minner\x1b[39m\x1b[32m outer\x1b[39m');
console.log('Contract tests passed successfully.');
process.exit(0);
} finally {
kleur.enabled = initialEnabled;
}
}
testContract();
Seeder de origem
anônimo