CodeSampleX

샘플

@types/yargs 17.0.35

검증된 샘플 — npm @types/yargs 17.0.35. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: package manifest specifies index.d.ts type declarations and…

sha256:5eeae4f175cb4b0de600b97a1b540c2d3669daf409ffbd57ba759d5a4a949e7b

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. 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@1
2026-08-21

케이스

HOW
목표
verify pkg:npm/%40types/yargs@17.0.35
패키지
생성일
2026-08-21T05:39:56Z

컨트랙트

  1. package manifest specifies index.d.ts type declarations and TypeScript version
  2. declares Argv interface with alias, command, option, positional, parse, and middleware methods
  3. declares CommandModule interface with aliases, builder, command, describe, and handler
  4. declares Options and PositionalOptions interfaces with type and validation settings
  5. declares helper functions and export entry points in helpers and yargs submodules

파일

  • 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/%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.
csx.json
{"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"}
package-lock.json
{
  "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"
    }
  }
}
package.json
{
  "name": "sample-types-yargs",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "license": "MIT-0",
  "dependencies": {
    "@types/yargs": "17.0.35"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/%40types/yargs@17.0.35",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40types/yargs@17.0.35"
  ]
}
test/contract.mjs
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.');

오리진 시더

익명