CodeSampleX

Sample

supports-color 9.4.0: stdout

Verified sample for npm supports-color 9.4.0: stdout. The contract ran on node 22 · linux debian/x64 · docker and passed: supportsColor default export…

sha256:e2547c80940339722ceb8e1b4b2de39787dc31c9961002a1309ac05bbd3618a8

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.stdout in pkg:npm/supports-color@9.4.0
Packages
Symbols
  • supports-color.stdout
Created
2026-10-21T16:52:44Z

Contract

  1. supportsColor default export provides stdout and stderr color capability properties
  2. supportsColor.stdout returns false when color is disabled on non-TTY stdout without FORCE_COLOR
  3. supportsColor.stdout respects FORCE_COLOR levels 0 through 3 and boolean string values
  4. supportsColor.stdout respects CLI color flags such as --color=16m, --color=256, and --no-color
  5. getStdoutColorSupport and hasStdoutColorLevel helper functions inspect supportsColor.stdout level

Files

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • src/index.mjs
  • test/contract.mjs

Download the source artifact (tar.gz)

Source

PROMPT.md
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.stdout 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.stdout

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.
csx.json
{"case":{"caseId":"case:sha256:274cc6e0ade545a2d87b9058dc8b765a5e5f9e64ee72d5f3337e9b11dc235a9c","contract":["supportsColor default export provides stdout and stderr color capability properties","supportsColor.stdout returns false when color is disabled on non-TTY stdout without FORCE_COLOR","supportsColor.stdout respects FORCE_COLOR levels 0 through 3 and boolean string values","supportsColor.stdout respects CLI color flags such as --color=16m, --color=256, and --no-color","getStdoutColorSupport and hasStdoutColorLevel helper functions inspect supportsColor.stdout level"],"goal":"verify supports-color.stdout in pkg:npm/supports-color@9.4.0","kind":"HOW","packages":["pkg:npm/supports-color@9.4.0"],"schemaVersion":1,"symbols":["supports-color.stdout"]},"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.stdout"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "supports-color-stdout-sample",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "supports-color-stdout-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"
      }
    }
  }
}
package.json
{
  "name": "supports-color-stdout-sample",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "scripts": {
    "test": "node test/contract.mjs"
  },
  "dependencies": {
    "supports-color": "9.4.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify supports-color.stdout in pkg:npm/supports-color@9.4.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/supports-color@9.4.0"
  ],
  "symbols": [
    "supports-color.stdout"
  ]
}
src/index.mjs
import supportsColor, { createSupportsColor } from 'supports-color';

export function getStdoutColorSupport() {
  return supportsColor.stdout;
}

export function hasStdoutColorLevel(minLevel = 1) {
  const info = supportsColor.stdout;
  if (info === false) {
    return minLevel <= 0;
  }
  return info.level >= minLevel;
}

export function evaluateStreamColorSupport(stream, options) {
  return createSupportsColor(stream, options);
}

export { supportsColor, createSupportsColor };
export default supportsColor;

test/contract.mjs
import assert from 'node:assert/strict';
import { execFileSync } from 'node:child_process';
import supportsColor, {
  createSupportsColor,
  getStdoutColorSupport,
  hasStdoutColorLevel,
  evaluateStreamColorSupport,
} from '../src/index.mjs';

function probeStdoutInSubprocess(envOverrides = {}, extraArgs = []) {
  const script =
    'import supportsColor from "supports-color"; process.stdout.write(JSON.stringify(supportsColor.stdout));';
  const cleanEnv = {
    PATH: process.env.PATH || '',
    HOME: process.env.HOME || '',
    ...envOverrides,
  };
  const output = execFileSync(
    process.execPath,
    ['--input-type=module', '-e', script, '--', ...extraArgs],
    {
      env: cleanEnv,
      encoding: 'utf8',
      stdio: ['pipe', 'pipe', 'pipe'],
    }
  );
  return JSON.parse(output);
}

// 1. Default export exposes stdout and stderr properties
assert.equal(typeof supportsColor, 'object');
assert.notEqual(supportsColor, null);
assert.ok('stdout' in supportsColor);
assert.ok('stderr' in supportsColor);
assert.equal(getStdoutColorSupport(), supportsColor.stdout);

// 2. Verify shape of supportsColor.stdout in current process
const currentStdout = supportsColor.stdout;
assert.ok(
  currentStdout === false ||
    (typeof currentStdout === 'object' &&
      currentStdout !== null &&
      typeof currentStdout.level === 'number' &&
      typeof currentStdout.hasBasic === 'boolean' &&
      typeof currentStdout.has256 === 'boolean' &&
      typeof currentStdout.has16m === 'boolean')
);

if (currentStdout === false) {
  assert.equal(hasStdoutColorLevel(1), false);
  assert.equal(hasStdoutColorLevel(0), true);
} else {
  assert.equal(hasStdoutColorLevel(1), currentStdout.level >= 1);
}

// 3. Subprocess non-TTY stdout without FORCE_COLOR returns false
assert.equal(probeStdoutInSubprocess({}), false);

// 4. supportsColor.stdout respects FORCE_COLOR levels 0..3 and boolean strings
assert.equal(probeStdoutInSubprocess({ FORCE_COLOR: '0' }), false);
assert.equal(probeStdoutInSubprocess({ FORCE_COLOR: 'false' }), false);

assert.deepEqual(probeStdoutInSubprocess({ FORCE_COLOR: '1' }), {
  level: 1,
  hasBasic: true,
  has256: false,
  has16m: false,
});
assert.deepEqual(probeStdoutInSubprocess({ FORCE_COLOR: 'true' }), {
  level: 1,
  hasBasic: true,
  has256: false,
  has16m: false,
});
assert.deepEqual(probeStdoutInSubprocess({ FORCE_COLOR: '' }), {
  level: 1,
  hasBasic: true,
  has256: false,
  has16m: false,
});

assert.deepEqual(probeStdoutInSubprocess({ FORCE_COLOR: '2' }), {
  level: 2,
  hasBasic: true,
  has256: true,
  has16m: false,
});

assert.deepEqual(probeStdoutInSubprocess({ FORCE_COLOR: '3' }), {
  level: 3,
  hasBasic: true,
  has256: true,
  has16m: true,
});

// 5. CLI flags affect supportsColor.stdout when FORCE_COLOR is unset
assert.deepEqual(probeStdoutInSubprocess({}, ['--color=16m']), {
  level: 3,
  hasBasic: true,
  has256: true,
  has16m: true,
});
assert.deepEqual(probeStdoutInSubprocess({}, ['--color=256']), {
  level: 2,
  hasBasic: true,
  has256: true,
  has16m: false,
});
assert.equal(probeStdoutInSubprocess({}, ['--no-color']), false);

// 6. createSupportsColor evaluates custom streams consistently
assert.equal(
  evaluateStreamColorSupport({ isTTY: false }, { sniffFlags: false }),
  false
);

Origin Seeder

anonymous