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

このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。 合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。 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.');

オリジンシーダー

匿名