Exemple
strip-ansi 7.2.0
Échantillon vérifié pour npm strip-ansi 7.2.0. Le contrat s'est exécuté sur node 22 · linux alpine/x64 · docker et a réussi : stripAnsi removes 3-bit and…
sha256:5ead9969f871279a798e3d1123943781d59da1d42ea8e6a68420c21d26cd8ebb
Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré.
Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes.
MIT-0
Preuves d'exécution
L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.
- Base de preuve
- Contrat signé réussi
- Reçus de vérification
- 1
- Clés de signature qui l’ont compilé
- 1
Environnement déclaré
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| 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-23 |
Cas
HOW- Objectif
- verify pkg:npm/strip-ansi@7.2.0
- Paquets
- Environnement
- node 22.23.2
- Créé
- 2026-08-23T08:09:52Z
Contrat
- stripAnsi removes 3-bit and 4-bit standard ANSI color codes
- stripAnsi removes 8-bit (256 color) ANSI color sequences
- stripAnsi removes 24-bit (RGB) ANSI color sequences
- stripAnsi removes text styling such as bold, italic, and underline
- stripAnsi removes terminal cursor and line clear control sequences
- stripAnsi preserves strings without ANSI escape codes
- stripAnsi throws TypeError when given non-string input
- stripAnsiCodes wrapper removes ANSI formatting correctly
- hasAnsiCodes detects whether a string contains ANSI escape codes
- stripAnsiFromLines cleans an array of formatted strings
Fichiers
- PROMPT.md
- csx.json
- index.js
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
Code source
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/strip-ansi@7.2.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/strip-ansi@7.2.0
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:3a0bc29c7abad45384f394cd33b66df5561bfa67adfa127db8ae0a3f77c0f955","constraints":{"executionContext":"node"},"contract":["stripAnsi removes 3-bit and 4-bit standard ANSI color codes","stripAnsi removes 8-bit (256 color) ANSI color sequences","stripAnsi removes 24-bit (RGB) ANSI color sequences","stripAnsi removes text styling such as bold, italic, and underline","stripAnsi removes terminal cursor and line clear control sequences","stripAnsi preserves strings without ANSI escape codes","stripAnsi throws TypeError when given non-string input","stripAnsiCodes wrapper removes ANSI formatting correctly","hasAnsiCodes detects whether a string contains ANSI escape codes","stripAnsiFromLines cleans an array of formatted strings"],"goal":"verify pkg:npm/strip-ansi@7.2.0","kind":"HOW","packages":["pkg:npm/strip-ansi@7.2.0"],"schemaVersion":1},"contractCommand":["node","test/contract.mjs"],"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/strip-ansi@7.2.0"],"schemaVersion":1,"subject":"pkg:npm/strip-ansi@7.2.0","verifierAdapter":"node-typescript@1"}
const stripAnsiModule = require('strip-ansi');
const stripAnsi = stripAnsiModule.default || stripAnsiModule;
function stripAnsiCodes(text) {
return stripAnsi(text);
}
function hasAnsiCodes(text) {
if (typeof text !== 'string') {
throw new TypeError(`Expected a string, got ${typeof text}`);
}
return text !== stripAnsi(text);
}
function stripAnsiFromLines(lines) {
if (!Array.isArray(lines)) {
throw new TypeError('Expected an array of strings');
}
return lines.map((line) => stripAnsi(line));
}
module.exports = {
stripAnsiCodes,
hasAnsiCodes,
stripAnsiFromLines,
};
{
"name": "sample-strip-ansi",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-strip-ansi",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"strip-ansi": "7.2.0"
}
},
"node_modules/ansi-regex": {
"version": "6.3.0",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.3.0.tgz",
"integrity": "sha512-WpDfL7NO6j7tH88IDBNVdUJxDh9nmCteAVW9dsep846XdwF4naCBK+/tGLX3KJgcpgMRXCFlTM2hKGoK9FsdrQ==",
"license": "MIT",
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/chalk/ansi-regex?sponsor=1"
}
},
"node_modules/strip-ansi": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.2.0.tgz",
"integrity": "sha512-yDPMNjp4WyfYBkHnjIRLfca1i6KMyGCtsVgoKe/z1+6vukgaENdgGBZt+ZmKPc4gavvEZ5OgHfHdrazhgNyG7w==",
"license": "MIT",
"dependencies": {
"ansi-regex": "^6.2.2"
},
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/chalk/strip-ansi?sponsor=1"
}
}
}
}
{
"name": "sample-strip-ansi",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification sample for strip-ansi 7.2.0",
"main": "index.js",
"scripts": {
"test": "node test/contract.mjs"
},
"dependencies": {
"strip-ansi": "7.2.0"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/strip-ansi@7.2.0",
"kind": "HOW",
"packages": [
"pkg:npm/strip-ansi@7.2.0"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
import assert from 'node:assert/strict';
import stripAnsi from 'strip-ansi';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const { stripAnsiCodes, hasAnsiCodes, stripAnsiFromLines } = require('../index.js');
// 1. stripAnsi removes 3-bit and 4-bit standard ANSI color codes
assert.equal(stripAnsi('\u001B[31mRed Text\u001B[39m'), 'Red Text');
assert.equal(stripAnsi('\u001B[42mGreen Background\u001B[49m'), 'Green Background');
assert.equal(stripAnsi('\u001B[93mBright Yellow\u001B[39m'), 'Bright Yellow');
// 2. stripAnsi removes 8-bit (256 color) ANSI color sequences
assert.equal(stripAnsi('\u001B[38;5;196m256 Color Text\u001B[0m'), '256 Color Text');
assert.equal(stripAnsi('\u001B[48;5;27m256 Background\u001B[0m'), '256 Background');
// 3. stripAnsi removes 24-bit (RGB) ANSI color sequences
assert.equal(stripAnsi('\u001B[38;2;255;100;50mRGB Color\u001B[0m'), 'RGB Color');
assert.equal(stripAnsi('\u001B[48;2;0;128;255mRGB Background\u001B[0m'), 'RGB Background');
// 4. stripAnsi removes text styling such as bold, italic, and underline
assert.equal(stripAnsi('\u001B[1mBold\u001B[22m \u001B[3mItalic\u001B[23m \u001B[4mUnderline\u001B[24m'), 'Bold Italic Underline');
assert.equal(stripAnsi('\u001B[2mDim\u001B[22m \u001B[9mStrikethrough\u001B[29m'), 'Dim Strikethrough');
// 5. stripAnsi removes terminal cursor and line clear control sequences
assert.equal(stripAnsi('\u001B[2K\u001B[1GCleared Line\u001B[0J'), 'Cleared Line');
// 6. stripAnsi preserves strings without ANSI escape codes
assert.equal(stripAnsi('Plain text without ANSI escape codes'), 'Plain text without ANSI escape codes');
assert.equal(stripAnsi(''), '');
// 7. stripAnsi throws TypeError when given non-string input
assert.throws(() => stripAnsi(123), { name: 'TypeError' });
assert.throws(() => stripAnsi(null), { name: 'TypeError' });
assert.throws(() => stripAnsi(undefined), { name: 'TypeError' });
assert.throws(() => stripAnsi({}), { name: 'TypeError' });
// 8. stripAnsiCodes wrapper removes ANSI formatting correctly
assert.equal(stripAnsiCodes('\u001B[34mWrapped Hello\u001B[0m'), 'Wrapped Hello');
// 9. hasAnsiCodes detects whether a string contains ANSI escape codes
assert.equal(hasAnsiCodes('\u001B[31mError\u001B[0m'), true);
assert.equal(hasAnsiCodes('Normal text'), false);
assert.throws(() => hasAnsiCodes(123), { name: 'TypeError' });
// 10. stripAnsiFromLines cleans an array of formatted strings
const rawLines = ['\u001B[32mLine 1\u001B[0m', '\u001B[33mLine 2\u001B[0m', 'Plain Line 3'];
const expectedLines = ['Line 1', 'Line 2', 'Plain Line 3'];
assert.deepEqual(stripAnsiFromLines(rawLines), expectedLines);
assert.throws(() => stripAnsiFromLines('not an array'), { name: 'TypeError' });
console.log('All contract assertions passed successfully.');
Seeder d'origine
anonyme