CodeSampleX

Ejemplo

brace-expansion 2.1.4

Muestra verificada para npm brace-expansion 2.1.4. El contrato se ejecutó en node 22 · linux alpine/x64 · docker y pasó: expand expands comma-separated…

sha256:9d1f97b37d4d2855db41e317d7a795743e6a4a2f2cb37189d8d982f3b72825f7

Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido. Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas. MIT-0

Evidencia de ejecución

El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.

Base de evidencia
Contrato firmado aprobado
Recibos de verificación
1
Claves de firma que lo compilaron
1
Entorno declarado linux 24 · ubuntu · glibc 2.39 x64 npm

Entornos de las ejecuciones de verificación

Entorno Contrato Etapas Ejecución
node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1
2026-08-21

Caso

HOW
Objetivo
verify pkg:npm/brace-expansion@2.1.4
Paquetes
Creado
2026-08-21T13:09:07Z

Contrato

  1. expand expands comma-separated alternatives within curly braces into string combinations
  2. expand expands numeric and alphabetic sequences with optional step increments
  3. expand expands nested brace patterns and computes Cartesian products for adjacent brace groups
  4. expand handles numeric sequences with zero-padding and reverse ordering
  5. expand returns an empty array for empty input and preserves literal text when no braces are matched
  6. expand supports max and maxLength options to bound output results

Archivos

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

Descargar el artefacto de código fuente (tar.gz)

Código fuente

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/brace-expansion@2.1.4
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/brace-expansion@2.1.4

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:70bd8d08e308c8ef344b71fba39753a47845ea90c673c88b7ca8577aaa46a821","contract":["expand expands comma-separated alternatives within curly braces into string combinations","expand expands numeric and alphabetic sequences with optional step increments","expand expands nested brace patterns and computes Cartesian products for adjacent brace groups","expand handles numeric sequences with zero-padding and reverse ordering","expand returns an empty array for empty input and preserves literal text when no braces are matched","expand supports max and maxLength options to bound output results"],"goal":"verify pkg:npm/brace-expansion@2.1.4","kind":"HOW","packages":["pkg:npm/brace-expansion@2.1.4"],"schemaVersion":1},"contractCommand":["node","test/contract.js"],"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/brace-expansion@2.1.4"],"schemaVersion":1,"subject":"pkg:npm/brace-expansion@2.1.4","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-brace-expansion",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-brace-expansion",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "brace-expansion": "2.1.4"
      }
    },
    "node_modules/balanced-match": {
      "version": "1.0.2",
      "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
      "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
      "license": "MIT"
    },
    "node_modules/brace-expansion": {
      "version": "2.1.4",
      "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.4.tgz",
      "integrity": "sha512-hGfVzPxthbf3+2yjg/RBs60cB0FhqBS/zvdV/4wn4/BmN0bNMMHPc4V/BbFieqf1TKAGGAHnY4eSjajCl0f2Xg==",
      "license": "MIT",
      "dependencies": {
        "balanced-match": "^1.0.0"
      }
    }
  }
}
package.json
{
  "name": "sample-brace-expansion",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification sample for brace-expansion",
  "main": "src/index.js",
  "scripts": {
    "test": "node test/contract.js"
  },
  "dependencies": {
    "brace-expansion": "2.1.4"
  },
  "license": "MIT-0"
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/brace-expansion@2.1.4",
  "kind": "HOW",
  "packages": [
    "pkg:npm/brace-expansion@2.1.4"
  ]
}
src/index.js
const expand = require('brace-expansion');

function expandPattern(pattern, options) {
  return expand(pattern, options);
}

module.exports = {
  expandPattern,
  expand
};
test/contract.js
const assert = require('node:assert/strict');
const expand = require('brace-expansion');
const { expandPattern } = require('../src/index.js');

// 1. Comma-separated alternatives within curly braces
assert.deepStrictEqual(expand('file.{js,ts}'), ['file.js', 'file.ts'], 'should expand comma alternatives');
assert.deepStrictEqual(expand('http://example.com/{foo,bar}'), ['http://example.com/foo', 'http://example.com/bar'], 'should expand URLs');
assert.deepStrictEqual(expandPattern('item-{a,b,c}'), ['item-a', 'item-b', 'item-c'], 'wrapper should expand comma alternatives');

// 2. Numeric and alphabetic sequences with optional step increments
assert.deepStrictEqual(expand('{1..3}'), ['1', '2', '3'], 'should expand ascending numeric sequence');
assert.deepStrictEqual(expand('{a..c}'), ['a', 'b', 'c'], 'should expand ascending alphabetic sequence');
assert.deepStrictEqual(expand('{1..5..2}'), ['1', '3', '5'], 'should expand numeric sequence with step increment');
assert.deepStrictEqual(expand('{a..e..2}'), ['a', 'c', 'e'], 'should expand alphabetic sequence with step increment');

// 3. Nested brace expressions and Cartesian products
assert.deepStrictEqual(expand('a{b,c{d,e}}f'), ['abf', 'acdf', 'acef'], 'should resolve nested brace expressions');
assert.deepStrictEqual(expand('{a,b}{1,2}'), ['a1', 'a2', 'b1', 'b2'], 'should compute Cartesian products of adjacent groups');

// 4. Zero-padding and reverse ordering
assert.deepStrictEqual(expand('{01..03}'), ['01', '02', '03'], 'should preserve zero-padding in numeric sequence');
assert.deepStrictEqual(expand('{3..1}'), ['3', '2', '1'], 'should expand descending numeric sequence');
assert.deepStrictEqual(expand('{c..a}'), ['c', 'b', 'a'], 'should expand descending alphabetic sequence');

// 5. Empty input and literal text without braces
assert.deepStrictEqual(expand(''), [], 'should return empty array for empty string');
assert.deepStrictEqual(expand('plain-text'), ['plain-text'], 'should preserve literal text without braces');

// 6. Max and maxLength options
assert.deepStrictEqual(expand('{1..10}', { max: 3 }), ['1', '2', '3'], 'should respect max expansion option');
assert.deepStrictEqual(expand('{a,b,c}', { maxLength: 2 }), ['a', 'b'], 'should respect maxLength option');

console.log('Contract tests passed successfully.');

Seeder de origen

anónimo