CodeSampleX

Ejemplo

shebang-regex 3.0.0: source

Muestra verificada para npm shebang-regex 3.0.0: source. El contrato se ejecutó en node 22 · linux debian/x64 · docker y pasó.

sha256:9973bcbbb33eff70ce4ae47c2a018430d5184b4503e0c1aa88d020e5802f3ada

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 node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Entornos de las ejecuciones de verificación

Entorno Contrato Etapas Ejecución
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-05

Caso

HOW
Objetivo
verify shebang-regex.source in pkg:npm/shebang-regex@3.0.0
Paquetes
Símbolos
  • shebang-regex.source
Entorno
node 22.23.2
Creado
2026-09-05T16:01:06Z

Contrato

  1. shebang-regex.source is a string returning the raw regular expression pattern
  2. shebang-regex.source starts with ^#! to anchor matching at the beginning of the line
  3. shebang-regex.source contains a capturing group (.*) to extract the interpreter path
  4. shebang-regex.source does not include enclosing slashes or regex flags
  5. shebang-regex.source can be used to construct a new equivalent RegExp instance
  6. shebang-regex.source constructed RegExp correctly matches shebang strings and rejects non-shebang strings

Archivos

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

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 shebang-regex.source in pkg:npm/shebang-regex@3.0.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/shebang-regex@3.0.0
Demonstrate these symbols/APIs:
  - shebang-regex.source

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:3e8941a37e1ad2e2d17bbd561ae318ff788a768b3ab3ac8258a0cdcf61d60972","constraints":{"executionContext":"node"},"contract":["shebang-regex.source is a string returning the raw regular expression pattern","shebang-regex.source starts with ^#! to anchor matching at the beginning of the line","shebang-regex.source contains a capturing group (.*) to extract the interpreter path","shebang-regex.source does not include enclosing slashes or regex flags","shebang-regex.source can be used to construct a new equivalent RegExp instance","shebang-regex.source constructed RegExp correctly matches shebang strings and rejects non-shebang strings"],"goal":"verify shebang-regex.source in pkg:npm/shebang-regex@3.0.0","kind":"HOW","packages":["pkg:npm/shebang-regex@3.0.0"],"schemaVersion":1,"symbols":["shebang-regex.source"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/shebang-regex@3.0.0"],"schemaVersion":1,"subject":"pkg:npm/shebang-regex@3.0.0","symbols":["shebang-regex.source"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-shebang-regex",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-shebang-regex",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "shebang-regex": "3.0.0"
      }
    },
    "node_modules/shebang-regex": {
      "version": "3.0.0",
      "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz",
      "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==",
      "license": "MIT",
      "engines": {
        "node": ">=8"
      }
    }
  }
}
package.json
{
  "name": "sample-shebang-regex",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room code sample for shebang-regex source",
  "main": "src/index.js",
  "license": "MIT-0",
  "dependencies": {
    "shebang-regex": "3.0.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify shebang-regex.source in pkg:npm/shebang-regex@3.0.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/shebang-regex@3.0.0"
  ],
  "symbols": [
    "shebang-regex.source"
  ]
}
src/index.js
'use strict';

const shebangRegex = require('shebang-regex');

module.exports = shebangRegex;
test/contract.mjs
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';

const require = createRequire(import.meta.url);
const shebangRegex = require('../src/index.js');

// 1. shebang-regex.source is a string returning the raw regular expression pattern
assert.equal(typeof shebangRegex.source, 'string', 'shebangRegex.source should be a string');
assert.equal(shebangRegex.source, '^#!(.*)', 'shebangRegex.source should equal ^#!(.*)');

// 2. shebang-regex.source starts with ^#! to anchor matching at the beginning of the line
assert.equal(shebangRegex.source.startsWith('^#!'), true, 'shebangRegex.source should start with ^#!');

// 3. shebang-regex.source contains a capturing group (.*) to extract the interpreter path
assert.equal(shebangRegex.source.includes('(.*)'), true, 'shebangRegex.source should contain capturing group (.*)');

// 4. shebang-regex.source does not include enclosing slashes or regex flags
assert.equal(shebangRegex.source.startsWith('/'), false, 'shebangRegex.source should not start with a slash');
assert.equal(shebangRegex.source.endsWith('/'), false, 'shebangRegex.source should not end with a slash');

// 5. shebang-regex.source can be used to construct a new equivalent RegExp instance
const reconstructed = new RegExp(shebangRegex.source);
assert.equal(reconstructed instanceof RegExp, true, 'new RegExp(shebangRegex.source) should create a RegExp instance');
assert.equal(reconstructed.source, shebangRegex.source, 'reconstructed RegExp should have identical source pattern');

// 6. shebang-regex.source constructed RegExp correctly matches shebang strings and rejects non-shebang strings
const match = reconstructed.exec('#!/usr/bin/env node');
assert.notEqual(match, null, 'reconstructed RegExp should match valid shebang line');
assert.equal(match[0], '#!/usr/bin/env node', 'reconstructed RegExp match[0] should be full shebang');
assert.equal(match[1], '/usr/bin/env node', 'reconstructed RegExp match[1] should be captured interpreter');

assert.equal(reconstructed.test('console.log("hello");'), false, 'reconstructed RegExp should reject non-shebang line');
assert.equal(reconstructed.test(''), false, 'reconstructed RegExp should reject empty string');

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

Seeder de origen

anónimo