Exemple
@types/yargs 17.0.35
Échantillon vérifié pour npm @types/yargs 17.0.35. Le contrat s'est exécuté sur node 22 · linux alpine/x64 · docker et a réussi.
sha256:5eeae4f175cb4b0de600b97a1b540c2d3669daf409ffbd57ba759d5a4a949e7b
Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré.
Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes.
MIT-0
Preuves d'exécution
L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.
- Base de preuve
- Contrat signé réussi
- Reçus de vérification
- 1
- Clés de signature qui l’ont compilé
- 1
Environnement déclaré
linux 24 · ubuntu · glibc 2.39 x64 npm
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| 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 |
Cas
HOW- Objectif
- verify pkg:npm/%40types/yargs@17.0.35
- Paquets
- Créé
- 2026-08-21T05:39:56Z
Contrat
- package manifest specifies index.d.ts type declarations and TypeScript version
- declares Argv interface with alias, command, option, positional, parse, and middleware methods
- declares CommandModule interface with aliases, builder, command, describe, and handler
- declares Options and PositionalOptions interfaces with type and validation settings
- declares helper functions and export entry points in helpers and yargs submodules
Fichiers
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
Code source
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/%40types/yargs@17.0.35
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/%40types/yargs@17.0.35
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:d1e6d8138a56c0cfde6c71b4586c5a595f18e3ee14cd04577359d9391160fa68","contract":["package manifest specifies index.d.ts type declarations and TypeScript version","declares Argv interface with alias, command, option, positional, parse, and middleware methods","declares CommandModule interface with aliases, builder, command, describe, and handler","declares Options and PositionalOptions interfaces with type and validation settings","declares helper functions and export entry points in helpers and yargs submodules"],"goal":"verify pkg:npm/%40types/yargs@17.0.35","kind":"HOW","packages":["pkg:npm/%40types/yargs@17.0.35"],"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/%40types/yargs@17.0.35"],"schemaVersion":1,"subject":"pkg:npm/%40types/yargs@17.0.35","verifierAdapter":"node-typescript@1"}
{
"name": "sample-types-yargs",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-types-yargs",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"@types/yargs": "17.0.35"
}
},
"node_modules/@types/yargs": {
"version": "17.0.35",
"resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.35.tgz",
"integrity": "sha512-qUHkeCyQFxMXg79wQfTtfndEC+N9ZZg76HJftDJp+qH2tV7Gj4OJi7l+PiWwJ+pWtW8GwSmqsDj/oymhrTWXjg==",
"license": "MIT",
"dependencies": {
"@types/yargs-parser": "*"
}
},
"node_modules/@types/yargs-parser": {
"version": "21.0.3",
"resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-21.0.3.tgz",
"integrity": "sha512-I4q9QU9MQv4oEOz4tAHJtNz1cwuLxn2F3xcc2iV5WdqLPpUnj30aUuxt1mAxYTG+oe8CZMV/+6rU4S4gRDzqtQ==",
"license": "MIT"
}
}
}
{
"name": "sample-types-yargs",
"version": "1.0.0",
"private": true,
"type": "module",
"license": "MIT-0",
"dependencies": {
"@types/yargs": "17.0.35"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/%40types/yargs@17.0.35",
"kind": "HOW",
"packages": [
"pkg:npm/%40types/yargs@17.0.35"
]
}
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';
import fs from 'node:fs';
import path from 'node:path';
const require = createRequire(import.meta.url);
// 1. Resolve @types/yargs package manifest and verify type declaration entry points
const pkgPath = require.resolve('@types/yargs/package.json');
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
assert.equal(pkg.name, '@types/yargs', 'Package name must be @types/yargs');
assert.equal(pkg.version, '17.0.35', 'Package version must be 17.0.35');
assert.equal(pkg.types, 'index.d.ts', 'Package types entry must point to index.d.ts');
assert.equal(pkg.typeScriptVersion, '5.2', 'TypeScript version must be 5.2');
assert.ok(pkg.exports, 'Package exports must be defined');
assert.equal(pkg.exports['.'].types.default, './index.d.ts', 'Root default export types must point to ./index.d.ts');
assert.equal(pkg.exports['.'].types.import, './index.d.mts', 'Root import export types must point to ./index.d.mts');
assert.equal(pkg.exports['./helpers'].types.default, './helpers.d.ts', 'helpers default export types must point to ./helpers.d.ts');
assert.equal(pkg.exports['./yargs'].types.default, './yargs.d.ts', 'yargs default export types must point to ./yargs.d.ts');
const typesDir = path.dirname(pkgPath);
const dtsContent = fs.readFileSync(path.join(typesDir, 'index.d.ts'), 'utf8');
// 2. Verify Argv interface declarations and core CLI configuration methods
assert.ok(
dtsContent.includes('interface Argv<T = {}> {'),
'Argv interface must be declared'
);
assert.ok(
dtsContent.includes('alias<K1 extends keyof T, K2 extends string>(') &&
dtsContent.includes('command<U = T>(') &&
dtsContent.includes('option<K extends keyof T, O extends Options>(') &&
dtsContent.includes('positional<K extends keyof T, O extends PositionalOptions>(') &&
dtsContent.includes('parse():') &&
dtsContent.includes('parseSync(') &&
dtsContent.includes('parseAsync(') &&
dtsContent.includes('middleware(') &&
dtsContent.includes('strict(): Argv<T>;'),
'Argv interface must declare alias, command, option, positional, parse, middleware, and strict methods'
);
// 3. Verify CommandModule interface and CommandBuilder type
assert.ok(
dtsContent.includes('interface CommandModule<T = {}, U = {}> {'),
'CommandModule interface must be declared'
);
assert.ok(
dtsContent.includes('aliases?: readonly string[] | string | undefined;') &&
dtsContent.includes('builder?: CommandBuilder<T, U> | undefined;') &&
dtsContent.includes('command?: readonly string[] | string | undefined;') &&
dtsContent.includes('describe?: string | false | undefined;') &&
dtsContent.includes('handler: (args: ArgumentsCamelCase<U>) => void | Promise<void>;'),
'CommandModule must declare aliases, builder, command, describe, and handler properties'
);
// 4. Verify Options and PositionalOptions interfaces
assert.ok(
dtsContent.includes('interface Options {') &&
dtsContent.includes('alias?: string | readonly string[] | undefined;') &&
dtsContent.includes('choices?: Choices | undefined;') &&
dtsContent.includes('coerce?: ((arg: any) => any) | undefined;') &&
dtsContent.includes('default?: any;') &&
dtsContent.includes('demandOption?: boolean | string | undefined;') &&
dtsContent.includes('type?: "array" | "count" | PositionalOptionsType | undefined;'),
'Options interface must declare alias, choices, coerce, default, demandOption, and type fields'
);
assert.ok(
dtsContent.includes('interface PositionalOptions {') &&
dtsContent.includes('type?: PositionalOptionsType | undefined;'),
'PositionalOptions interface must be declared with type field'
);
// 5. Verify submodule declaration files: helpers, yargs, and ESM wrapper
const helpersDts = fs.readFileSync(path.join(typesDir, 'helpers.d.ts'), 'utf8');
assert.ok(
helpersDts.includes('export function applyExtends(config: Record<string, any>, cwd: string, mergeExtends: boolean): Record<string, any>;') &&
helpersDts.includes('export function hideBin(argv: string[]): string[];'),
'helpers.d.ts must export applyExtends and hideBin functions'
);
const yargsDts = fs.readFileSync(path.join(typesDir, 'yargs.d.ts'), 'utf8');
assert.ok(
yargsDts.includes('declare function Yargs(') &&
yargsDts.includes('export = Yargs;'),
'yargs.d.ts must declare and export Yargs constructor function'
);
const indexMts = fs.readFileSync(path.join(typesDir, 'index.d.mts'), 'utf8');
assert.ok(
indexMts.includes('export default _instanceFactory;') &&
indexMts.includes('ArgumentsCamelCase,') &&
indexMts.includes('CommandModule,'),
'index.d.mts must export default instance factory and type definitions'
);
console.log('Contract tests passed successfully.');
Seeder d'origine
anonyme