Sample
supports-color 9.4.0: createSupportsColor
Verified sample for npm supports-color 9.4.0: createSupportsColor. The contract ran on node 22 · linux debian/x64 · docker and passed.
sha256:197ba711ce87c0c48901582ab9b5944ba67c1f06788f3974c7a6d9dd8d61a6f5
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
linux 24 · ubuntu · glibc 2.39 x64 npm
Verification-run environments
| Environment | Contract | Stages | Run |
|---|---|---|---|
| node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2… |
2026-10-21 |
Case
HOW- Goal
- verify supports-color.createSupportsColor in pkg:npm/supports-color@9.4.0
- Packages
- Symbols
-
- supports-color.createSupportsColor
- Created
- 2026-10-21T16:34:50Z
Contract
- createSupportsColor({ isTTY: false }, { sniffFlags: false }) returns false when no force-color flags or environment variables are set
- createSupportsColor({ isTTY: true }, { sniffFlags: false }) returns { level: 1, hasBasic: true, has256: false, has16m: false } when TERM=xterm
- createSupportsColor({ isTTY: true }, { sniffFlags: false }) returns { level: 2, hasBasic: true, has256: true, has16m: false } when TERM=xterm-256color
- createSupportsColor({ isTTY: true }, { sniffFlags: false }) returns { level: 3, hasBasic: true, has256: true, has16m: true } when COLORTERM=truecolor
- createSupportsColor({ isTTY: false }, { sniffFlags: true }) inspects process.argv for --color=256 while { sniffFlags: false } ignores CLI flags
- FORCE_COLOR environment variable overrides non-TTY streams when set to a level and disables color support when set to 'false'
Files
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.mjs
- 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 supports-color.createSupportsColor in pkg:npm/supports-color@9.4.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/supports-color@9.4.0
Demonstrate these symbols/APIs:
- supports-color.createSupportsColor
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:0793578f2662a2073ec6697efad204fa53cc09b4cbd755c251a600bb88cb5439","contract":["createSupportsColor({ isTTY: false }, { sniffFlags: false }) returns false when no force-color flags or environment variables are set","createSupportsColor({ isTTY: true }, { sniffFlags: false }) returns { level: 1, hasBasic: true, has256: false, has16m: false } when TERM=xterm","createSupportsColor({ isTTY: true }, { sniffFlags: false }) returns { level: 2, hasBasic: true, has256: true, has16m: false } when TERM=xterm-256color","createSupportsColor({ isTTY: true }, { sniffFlags: false }) returns { level: 3, hasBasic: true, has256: true, has16m: true } when COLORTERM=truecolor","createSupportsColor({ isTTY: false }, { sniffFlags: true }) inspects process.argv for --color=256 while { sniffFlags: false } ignores CLI flags","FORCE_COLOR environment variable overrides non-TTY streams when set to a level and disables color support when set to 'false'"],"goal":"verify supports-color.createSupportsColor in pkg:npm/supports-color@9.4.0","kind":"HOW","packages":["pkg:npm/supports-color@9.4.0"],"schemaVersion":1,"symbols":["supports-color.createSupportsColor"]},"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/supports-color@9.4.0"],"schemaVersion":1,"subject":"pkg:npm/supports-color@9.4.0","symbols":["supports-color.createSupportsColor"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample",
"version": "1.0.0",
"dependencies": {
"supports-color": "9.4.0"
}
},
"node_modules/supports-color": {
"version": "9.4.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-9.4.0.tgz",
"integrity": "sha512-VL+lNrEoIXww1coLPOmiEmK/0sGigko5COxI09KzHc2VJXJsQ37UaQ+8quuxjDeA7+KnLGTWRyOXSLLR2Wb4jw==",
"license": "MIT",
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/chalk/supports-color?sponsor=1"
}
}
}
}
{
"name": "sample",
"version": "1.0.0",
"private": true,
"type": "module",
"scripts": {
"test": "node test/contract.mjs"
},
"dependencies": {
"supports-color": "9.4.0"
}
}
{
"schemaVersion": 1,
"goal": "verify supports-color.createSupportsColor in pkg:npm/supports-color@9.4.0",
"kind": "HOW",
"packages": [
"pkg:npm/supports-color@9.4.0"
],
"symbols": [
"supports-color.createSupportsColor"
]
}
import { createSupportsColor } from 'supports-color';
export function checkStreamColorSupport(stream, options = {}) {
return createSupportsColor(stream, options);
}
import assert from 'node:assert/strict';
import process from 'node:process';
import { createSupportsColor } from 'supports-color';
import { checkStreamColorSupport } from '../src/index.mjs';
// Isolate environment variables that influence color detection
const envKeys = [
'FORCE_COLOR',
'TF_BUILD',
'AGENT_NAME',
'TERM',
'CI',
'GITHUB_ACTIONS',
'GITEA_ACTIONS',
'TRAVIS',
'CIRCLECI',
'APPVEYOR',
'GITLAB_CI',
'BUILDKITE',
'DRONE',
'CI_NAME',
'TEAMCITY_VERSION',
'COLORTERM',
'TERM_PROGRAM',
'TERM_PROGRAM_VERSION',
];
for (const key of envKeys) {
delete process.env[key];
}
// 1. Non-TTY stream without force flags returns false
const nonTtyResult = checkStreamColorSupport({ isTTY: false }, { sniffFlags: false });
assert.equal(nonTtyResult, false);
// 2. TTY stream with basic xterm returns level 1 (basic 16 colors)
process.env.TERM = 'xterm';
const level1Result = createSupportsColor({ isTTY: true }, { sniffFlags: false });
assert.deepEqual(level1Result, {
level: 1,
hasBasic: true,
has256: false,
has16m: false,
});
// 3. TTY stream with xterm-256color returns level 2 (256 colors)
process.env.TERM = 'xterm-256color';
const level2Result = createSupportsColor({ isTTY: true }, { sniffFlags: false });
assert.deepEqual(level2Result, {
level: 2,
hasBasic: true,
has256: true,
has16m: false,
});
// 4. TTY stream with COLORTERM=truecolor returns level 3 (16m colors)
process.env.COLORTERM = 'truecolor';
const level3Result = createSupportsColor({ isTTY: true }, { sniffFlags: false });
assert.deepEqual(level3Result, {
level: 3,
hasBasic: true,
has256: true,
has16m: true,
});
// 5. sniffFlags option respects CLI flags (--color=256 vs sniffFlags: false)
delete process.env.COLORTERM;
process.env.TERM = 'dumb';
process.argv.push('--color=256');
try {
const sniffedResult = createSupportsColor({ isTTY: false }, { sniffFlags: true });
assert.deepEqual(sniffedResult, {
level: 2,
hasBasic: true,
has256: true,
has16m: false,
});
const unsniffedResult = createSupportsColor({ isTTY: false }, { sniffFlags: false });
assert.equal(unsniffedResult, false);
} finally {
process.argv.pop();
}
// 6. FORCE_COLOR overrides non-TTY stream and disables color when 'false'
process.env.FORCE_COLOR = '3';
assert.deepEqual(createSupportsColor({ isTTY: false }, { sniffFlags: false }), {
level: 3,
hasBasic: true,
has256: true,
has16m: true,
});
process.env.FORCE_COLOR = 'false';
assert.equal(createSupportsColor({ isTTY: true }, { sniffFlags: false }), false);
Origin Seeder
anonymous