Ejemplo
nopt 8.1.0: clean, typeDefs, lib.nopt
Muestra verificada para npm nopt 8.1.0: clean, typeDefs, lib.nopt. El contrato se ejecutó en node 22 · linux debian/x64 · docker y pasó.
sha256:79d20b6f0f959d11e14eb4609bd0f4bf4984046c065a01e1d317a965424bfeb8
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-10-18 |
Caso
HOW- Objetivo
- verify pkg:npm/nopt@8.1.0
- Paquetes
- Símbolos
-
- nopt
- nopt.clean
- nopt.typeDefs
- nopt.lib.nopt
- Entorno
- node 22.23.2
- Creado
- 2026-10-18T01:01:08Z
Contrato
- nopt parses typed CLI options including String, Number, Boolean, Array, path, Date, and url
- nopt expands single-flag and composite shorthands and handles --no- boolean negation and -- positional delimiters
- nopt.clean coerces and validates raw option objects in-place against type definitions
- nopt.lib.nopt parses argument arrays in non-singleton mode with explicit types, shorthands, and nopt.typeDefs
Archivos
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.mjs
Código fuente
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/nopt@8.1.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/nopt@8.1.0
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.
{"case":{"caseId":"case:sha256:ad306d48e01d95562fa6c0d3fd84b8f8c624dc2bf492f6edbc4ad1a9d83a65aa","contract":["nopt parses typed CLI options including String, Number, Boolean, Array, path, Date, and url","nopt expands single-flag and composite shorthands and handles --no- boolean negation and -- positional delimiters","nopt.clean coerces and validates raw option objects in-place against type definitions","nopt.lib.nopt parses argument arrays in non-singleton mode with explicit types, shorthands, and nopt.typeDefs"],"goal":"verify pkg:npm/nopt@8.1.0","kind":"HOW","packages":["pkg:npm/nopt@8.1.0"],"schemaVersion":1,"symbols":["nopt","nopt.clean","nopt.typeDefs","nopt.lib.nopt"]},"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/nopt@8.1.0"],"schemaVersion":1,"subject":"pkg:npm/nopt@8.1.0","symbols":["nopt","nopt.clean","nopt.typeDefs","nopt.lib.nopt"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-nopt-8",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-nopt-8",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"nopt": "8.1.0"
}
},
"node_modules/abbrev": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/abbrev/-/abbrev-3.0.1.tgz",
"integrity": "sha512-AO2ac6pjRB3SJmGJo+v5/aK6Omggp6fsLrs6wN9bd35ulu4cCwaAU9+7ZhXjeqHVkaHThLuzH0nZr0YpCDhygg==",
"license": "ISC",
"engines": {
"node": "^18.17.0 || >=20.5.0"
}
},
"node_modules/nopt": {
"version": "8.1.0",
"resolved": "https://registry.npmjs.org/nopt/-/nopt-8.1.0.tgz",
"integrity": "sha512-ieGu42u/Qsa4TFktmaKEwM6MQH0pOWnaB3htzh0JRtx84+Mebc0cbZYN5bC+6WTZ4+77xrL9Pn5m7CV6VIkV7A==",
"license": "ISC",
"dependencies": {
"abbrev": "^3.0.0"
},
"bin": {
"nopt": "bin/nopt.js"
},
"engines": {
"node": "^18.17.0 || >=20.5.0"
}
}
}
}
{
"name": "sample-nopt-8",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification sample for nopt 8.1.0",
"main": "src/index.js",
"scripts": {
"test": "node test/contract.mjs"
},
"dependencies": {
"nopt": "8.1.0"
},
"license": "MIT-0"
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/nopt@8.1.0",
"kind": "HOW",
"packages": [
"pkg:npm/nopt@8.1.0"
]
}
const nopt = require('nopt');
function parseCliArgs(types, shorthands, args, slice = 2) {
return nopt(types, shorthands, args, slice);
}
function sanitizeConfig(data, types, typeDefs) {
nopt.clean(data, types, typeDefs);
return data;
}
function parseIsolated(args, options) {
return nopt.lib.nopt(args, options);
}
module.exports = {
nopt,
parseCliArgs,
sanitizeConfig,
parseIsolated
};
import assert from 'node:assert/strict';
import path from 'node:path';
import url from 'node:url';
import indexModule from '../src/index.js';
const { nopt, parseCliArgs, sanitizeConfig, parseIsolated } = indexModule;
// 1. Parse typed CLI options (String, Number, Boolean, Array, path, Date, url)
{
const types = {
host: String,
port: Number,
verbose: Boolean,
tag: [String, Array],
config: path,
since: Date,
endpoint: url
};
const shorthands = {
h: ['--host'],
p: ['--port'],
v: ['--verbose'],
t: ['--tag']
};
const argv = [
'node',
'app.js',
'-h', 'localhost',
'-p', '8080',
'-v',
'-t', 'alpha',
'--tag', 'beta',
'--config', './settings.json',
'--since', '2026-01-15T00:00:00.000Z',
'--endpoint', 'http://example.com/api',
'positional-one',
'positional-two'
];
const parsed = parseCliArgs(types, shorthands, argv, 2);
assert.equal(parsed.host, 'localhost');
assert.equal(parsed.port, 8080);
assert.equal(parsed.verbose, true);
assert.deepEqual(parsed.tag, ['alpha', 'beta']);
assert.equal(parsed.config, path.resolve('./settings.json'));
assert.ok(parsed.since instanceof Date);
assert.equal(parsed.since.toISOString(), '2026-01-15T00:00:00.000Z');
assert.equal(parsed.endpoint, 'http://example.com/api');
assert.deepEqual(parsed.argv.remain, ['positional-one', 'positional-two']);
}
// 2. Expand single-flag and composite shorthands and handle boolean --no- negation and -- delimiter
{
const types = {
env: String,
watch: Boolean,
cache: Boolean,
workers: Number
};
const shorthands = {
dev: ['--env', 'development', '--watch', '--no-cache']
};
const argv = ['node', 'app.js', '--dev', '--workers', '4', '--', '--unparsed', 'item'];
const parsed = nopt(types, shorthands, argv, 2);
assert.equal(parsed.env, 'development');
assert.equal(parsed.watch, true);
assert.equal(parsed.cache, false);
assert.equal(parsed.workers, 4);
assert.deepEqual(parsed.argv.remain, ['--unparsed', 'item']);
}
// 3. Coerce and validate raw objects in-place with nopt.clean
{
const types = {
retries: Number,
enabled: Boolean,
label: String
};
const data = {
retries: '5',
enabled: 'false',
label: 404
};
sanitizeConfig(data, types);
assert.equal(data.retries, 5);
assert.equal(data.enabled, false);
assert.equal(data.label, '404');
}
// 4. Use non-singleton nopt.lib.nopt with explicit options and verify default nopt.typeDefs
{
assert.ok(nopt.typeDefs.String);
assert.ok(nopt.typeDefs.Number);
assert.ok(nopt.typeDefs.Boolean);
assert.ok(nopt.typeDefs.Array);
assert.ok(nopt.typeDefs.path);
assert.ok(nopt.typeDefs.Date);
assert.ok(nopt.typeDefs.url);
assert.ok(nopt.typeDefs.Stream);
const isolated = parseIsolated(['--count', '12', 'extra'], {
types: { count: Number },
shorthands: {},
typeDefs: nopt.typeDefs
});
assert.equal(isolated.count, 12);
assert.deepEqual(isolated.argv.remain, ['extra']);
}
Seeder de origen
anónimo