CodeSampleX

Beispiel

picocolors 1.1.1

Verifiziertes Beispiel für npm picocolors 1.1.1. Der Vertrag lief auf node 22 · linux alpine/x64 · docker und bestand: createColors(true).red formats text…

sha256:ac0bc21fcbbee9deeb1a9c89089a71ab23dd2007cd9cbc66c47f5be93e932ec1

Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen. Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen. MIT-0

Ausführungsbelege

Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.

Beleggrundlage
Signierter Vertrag bestanden
Verifizierungsbelege
2
Signaturschlüssel, die es gebaut haben
1
Deklarierte Umgebung linux 24 · ubuntu · glibc 2.39 x64 npm

Umgebungen der Verifizierungsläufe

Umgebung Contract Stufen Lauf
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
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-09-08

Fall

HOW
Ziel
verify pkg:npm/picocolors@1.1.1
Pakete
Erstellt
2026-08-23T06:41:57Z

Contract

  1. createColors(true).red formats text with red ANSI escape codes
  2. createColors(true).green formats text with green ANSI escape codes
  3. createColors(true).bold formats text with bold ANSI escape codes
  4. createColors(true).bgBlue formats text with blue background ANSI escape codes
  5. createColors(false) disables color formatting and returns input unchanged

Dateien

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

Quellartefakt herunterladen (tar.gz)

Quelltext

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 pkg:npm/picocolors@1.1.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/picocolors@1.1.1

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:53d714c534c9d567fa2246b74d4244d81338020d7b2d6c716560228e596d8c07","contract":["createColors(true).red formats text with red ANSI escape codes","createColors(true).green formats text with green ANSI escape codes","createColors(true).bold formats text with bold ANSI escape codes","createColors(true).bgBlue formats text with blue background ANSI escape codes","createColors(false) disables color formatting and returns input unchanged"],"goal":"verify pkg:npm/picocolors@1.1.1","kind":"HOW","packages":["pkg:npm/picocolors@1.1.1"],"schemaVersion":1},"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/picocolors@1.1.1"],"schemaVersion":1,"subject":"pkg:npm/picocolors@1.1.1","verifierAdapter":"node-typescript@1"}
index.mjs
import pc from "picocolors";

export function formatMessage(level, message) {
  const colors = pc.createColors(true);
  switch (level) {
    case "error":
      return colors.red(`[ERROR] ${message}`);
    case "warn":
      return colors.yellow(`[WARN] ${message}`);
    case "info":
      return colors.cyan(`[INFO] ${message}`);
    default:
      return colors.green(`[OK] ${message}`);
  }
}

export function formatHeading(title) {
  const colors = pc.createColors(true);
  return colors.bold(colors.underline(title));
}
package-lock.json
{
  "name": "sample-picocolors",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-picocolors",
      "version": "1.0.0",
      "dependencies": {
        "picocolors": "1.1.1"
      }
    },
    "node_modules/picocolors": {
      "version": "1.1.1",
      "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
      "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",
      "license": "ISC"
    }
  }
}
package.json
{
  "name": "sample-picocolors",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "dependencies": {
    "picocolors": "1.1.1"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/picocolors@1.1.1",
  "kind": "HOW",
  "packages": [
    "pkg:npm/picocolors@1.1.1"
  ]
}
test/contract.mjs
import assert from "node:assert/strict";
import pc from "picocolors";

// 1. Verify forced color formatting with createColors(true)
const colors = pc.createColors(true);
assert.equal(colors.isColorSupported, true, "isColorSupported should be true when enabled");

// Color functions produce expected ANSI escape sequences
assert.equal(colors.red("error"), "\x1b[31merror\x1b[39m");
assert.equal(colors.green("ok"), "\x1b[32mok\x1b[39m");
assert.equal(colors.yellow("warning"), "\x1b[33mwarning\x1b[39m");
assert.equal(colors.blue("info"), "\x1b[34minfo\x1b[39m");
assert.equal(colors.magenta("highlight"), "\x1b[35mhighlight\x1b[39m");
assert.equal(colors.cyan("link"), "\x1b[36mlink\x1b[39m");
assert.equal(colors.white("text"), "\x1b[37mtext\x1b[39m");
assert.equal(colors.gray("dimmed"), "\x1b[90mdimmed\x1b[39m");

// Modifiers
assert.equal(colors.bold("bold text"), "\x1b[1mbold text\x1b[22m");
assert.equal(colors.dim("dim text"), "\x1b[2mdim text\x1b[22m");
assert.equal(colors.italic("italic text"), "\x1b[3mitalic text\x1b[23m");
assert.equal(colors.underline("underlined"), "\x1b[4munderlined\x1b[24m");
assert.equal(colors.inverse("inverted"), "\x1b[7minverted\x1b[27m");
assert.equal(colors.strikethrough("strike"), "\x1b[9mstrike\x1b[29m");
assert.equal(colors.reset("reset"), "\x1b[0mreset\x1b[0m");

// Background colors
assert.equal(colors.bgBlack("black"), "\x1b[40mblack\x1b[49m");
assert.equal(colors.bgRed("red"), "\x1b[41mred\x1b[49m");
assert.equal(colors.bgGreen("green"), "\x1b[42mgreen\x1b[49m");
assert.equal(colors.bgYellow("yellow"), "\x1b[43myellow\x1b[49m");
assert.equal(colors.bgBlue("blue"), "\x1b[44mblue\x1b[49m");
assert.equal(colors.bgMagenta("magenta"), "\x1b[45mmagenta\x1b[49m");
assert.equal(colors.bgCyan("cyan"), "\x1b[46mcyan\x1b[49m");
assert.equal(colors.bgWhite("white"), "\x1b[47mwhite\x1b[49m");

// 2. Verify disabled color mode with createColors(false)
const disabled = pc.createColors(false);
assert.equal(disabled.isColorSupported, false, "isColorSupported should be false when disabled");
assert.equal(disabled.red("error"), "error");
assert.equal(disabled.green("ok"), "ok");
assert.equal(disabled.bold("bold text"), "bold text");
assert.equal(disabled.bgBlue("blue"), "blue");

// 3. Verify function nesting
assert.equal(colors.bold(colors.red("alert")), "\x1b[1m\x1b[31malert\x1b[39m\x1b[22m");

console.log("All contract tests passed successfully.");

Ursprungs-Seeder

anonym