CodeSampleX

Пример

progress 2.0.3

Проверенный пример — npm progress 2.0.3. Контракт выполнен на node 22 · linux alpine/x64 · docker и пройден: ProgressBar initializes with specified total…

sha256:a9457c39d969e808993b86c03c388cebc51d8c24c2ec44abf3dfd3a9e4bacd70

Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла. Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди. MIT-0

Свидетельства выполнения

Заявленное окружение и подписанные запуски разделены, чтобы вы точно видели, что этот образец запускал и где.

Основа свидетельства
Подписанный контракт пройден
Квитанции проверки
1
Ключи подписи, собравшие его
1
Заявленная среда linux 24 · ubuntu · glibc 2.39 x64 npm

Среды запусков проверки

Окружение Контракт Этапы Запуск
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

Кейс

HOW
Цель
verify pkg:npm/progress@2.0.3
Пакеты
Создан
2026-08-23T13:59:45Z

Контракт

  1. ProgressBar initializes with specified total, initial curr of 0, and uncompleted state
  2. tick increments the current progress count and triggers completion callback when reaching total
  3. update calculates and sets progress position based on a percentage ratio
  4. custom tokens and status tokens are rendered into format string placeholders
  5. interrupt writes a notification message to the stream while preserving progress bar context
  6. terminate ends the progress bar session and flushes the termination output

Файлы

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

Скачать артефакт с исходным кодом (tar.gz)

Исходный код

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/progress@2.0.3
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/progress@2.0.3

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:ede502ebdb8df645e337e75c2ff0706ab6d606e0784cc40a3eb29502c75f1d82","contract":["ProgressBar initializes with specified total, initial curr of 0, and uncompleted state","tick increments the current progress count and triggers completion callback when reaching total","update calculates and sets progress position based on a percentage ratio","custom tokens and status tokens are rendered into format string placeholders","interrupt writes a notification message to the stream while preserving progress bar context","terminate ends the progress bar session and flushes the termination output"],"goal":"verify pkg:npm/progress@2.0.3","kind":"HOW","packages":["pkg:npm/progress@2.0.3"],"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/progress@2.0.3"],"schemaVersion":1,"subject":"pkg:npm/progress@2.0.3","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-progress",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-progress",
      "version": "1.0.0",
      "dependencies": {
        "progress": "2.0.3"
      }
    },
    "node_modules/progress": {
      "version": "2.0.3",
      "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz",
      "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==",
      "license": "MIT",
      "engines": {
        "node": ">=0.4.0"
      }
    }
  }
}
package.json
{
  "name": "sample-progress",
  "version": "1.0.0",
  "type": "module",
  "private": true,
  "dependencies": {
    "progress": "2.0.3"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/progress@2.0.3",
  "kind": "HOW",
  "packages": [
    "pkg:npm/progress@2.0.3"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import { PassThrough } from 'node:stream';
import ProgressBar from 'progress';

function createMockStream() {
  const stream = new PassThrough();
  stream.isTTY = true;
  stream.columns = 80;
  stream.cursorTo = () => {};
  stream.clearLine = () => {};
  return stream;
}

// 1. ProgressBar initializes with specified total, initial curr of 0, and uncompleted state
{
  const stream = createMockStream();
  const bar = new ProgressBar('[:bar] :current/:total', { total: 10, stream, width: 10 });
  assert.equal(bar.total, 10);
  assert.equal(bar.curr, 0);
  assert.equal(Boolean(bar.complete), false);
}

// 2. tick increments the current progress count and triggers completion callback when reaching total
{
  let completed = false;
  const stream = createMockStream();
  const bar = new ProgressBar('[:bar]', {
    total: 5,
    stream,
    callback: () => {
      completed = true;
    },
  });

  bar.tick(2);
  assert.equal(bar.curr, 2);
  assert.equal(Boolean(bar.complete), false);
  assert.equal(completed, false);

  bar.tick(3);
  assert.equal(bar.curr, 5);
  assert.equal(bar.complete, true);
  assert.equal(completed, true);
}

// 3. update calculates and sets progress position based on a percentage ratio
{
  const stream = createMockStream();
  const bar = new ProgressBar('[:bar]', { total: 20, stream, renderThrottle: 0 });

  bar.update(0.5);
  assert.equal(bar.curr, 10);
  assert.equal(Boolean(bar.complete), false);

  bar.update(1.0);
  assert.equal(bar.curr, 20);
  assert.equal(bar.complete, true);
}

// 4. custom tokens and status tokens are rendered into format string placeholders
{
  let captured = '';
  const stream = createMockStream();
  stream.on('data', (chunk) => {
    captured += chunk.toString();
  });

  const bar = new ProgressBar(':status [:bar] :percent', { total: 10, stream, renderThrottle: 0 });
  bar.tick(5, { status: 'Processing' });

  assert.ok(captured.includes('Processing'));
  assert.ok(captured.includes('50%'));
}

// 5. interrupt writes a notification message to the stream while preserving progress bar context
{
  let interruptLogs = '';
  const stream = createMockStream();
  stream.on('data', (chunk) => {
    interruptLogs += chunk.toString();
  });

  const bar = new ProgressBar('[:bar]', { total: 10, stream, renderThrottle: 0 });
  bar.tick(1);
  bar.interrupt('status notification');

  assert.ok(interruptLogs.includes('status notification'));
}

// 6. terminate ends the progress bar session and flushes the termination output
{
  let termLogs = '';
  const stream = createMockStream();
  stream.on('data', (chunk) => {
    termLogs += chunk.toString();
  });

  const bar = new ProgressBar('[:bar]', { total: 100, stream });
  bar.terminate();

  assert.ok(termLogs.includes('\n'));
}

Исходный сидер

аноним