Sample
strip-ansi 7.2.0
Verified sample for npm strip-ansi 7.2.0. The contract ran on node 22 · linux alpine/x64 · docker and passed: stripAnsi removes 3-bit and 4-bit standard ANSI…
sha256:5ead9969f871279a798e3d1123943781d59da1d42ea8e6a68420c21d26cd8ebb
This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured.
How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people.
MIT-0
Execution evidence
The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.
- Evidence basis
- Signed contract pass
- Verification receipts
- 1
- Signing keys that built it
- 1
Declared environment
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
Verification-run environments
| Environment | Contract | Stages | Run |
|---|---|---|---|
| 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 |
Case
HOW- Goal
- verify pkg:npm/strip-ansi@7.2.0
- Packages
- Environment
- node 22.23.2
- Created
- 2026-08-23T08:09:52Z
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
Files
- PROMPT.md
- csx.json
- index.js
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
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.');
Origin Seeder
anonymous