CodeSampleX

Beispiel

@types/babel__generator 7.27.0

Verifiziertes Beispiel für npm @types/babel__generator 7.27.0. Der Vertrag lief auf node 22 · linux alpine/x64 · docker und bestand.

sha256:71458dfe953ac3d617333f4fe61d26923e1e9d24ae63637a9ea38e1f21c0fef2

Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen. Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen. MIT-0

Ausführungsbelege

Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.

Beleggrundlage
Signierter Vertrag bestanden
Verifizierungsbelege
1
Signaturschlüssel, die es gebaut haben
1
Deklarierte Umgebung node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Umgebungen der Verifizierungsläufe

Umgebung Contract Stufen Lauf
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

Fall

HOW
Ziel
verify pkg:npm/%40types/babel__generator@7.27.0
Pakete
Umgebung
node 22.23.2
Erstellt
2026-08-21T09:26:55Z

Contract

  1. package manifest specifies index.d.ts type declarations and TypeScript version
  2. declares GeneratorOptions interface with formatting, comments, and jsesc configuration
  3. declares CodeGenerator class with constructor and generate method
  4. declares generate function and default export returning GeneratorResult
  5. declares GeneratorResult interface containing code string and source map object

Dateien

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

Quellartefakt herunterladen (tar.gz)

Quelltext

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/babel__generator@7.27.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40types/babel__generator@7.27.0
Constraints:
  - executionContext: node
Required runtime conditions:
  - ecosystem: npm
  - language: javascript
  - moduleSystem: cjs
  - packageManager: npm@10.9.8
  - runtime: node@22.23.2

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:3ca62b92247222842c806ec6e9dda32fad526e40c2ae22b4692fd58d9e5d14eb","constraints":{"executionContext":"node"},"contract":["package manifest specifies index.d.ts type declarations and TypeScript version","declares GeneratorOptions interface with formatting, comments, and jsesc configuration","declares CodeGenerator class with constructor and generate method","declares generate function and default export returning GeneratorResult","declares GeneratorResult interface containing code string and source map object"],"goal":"verify pkg:npm/%40types/babel__generator@7.27.0","kind":"HOW","packages":["pkg:npm/%40types/babel__generator@7.27.0"],"schemaVersion":1},"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/%40types/babel__generator@7.27.0"],"schemaVersion":1,"subject":"pkg:npm/%40types/babel__generator@7.27.0","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-types-babel-generator",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-types-babel-generator",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "@types/babel__generator": "7.27.0"
      }
    },
    "node_modules/@babel/helper-string-parser": {
      "version": "7.29.7",
      "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.29.7.tgz",
      "integrity": "sha512-Pb5ijPrZ89GDH8223L4UP8i6QApWxs04RbPQJTeWDV0/keR2E36MeKnyr6LYmUUvqRRI+Iv87SuF1W6ErINzYw==",
      "license": "MIT",
      "engines": {
        "node": ">=6.9.0"
      }
    },
    "node_modules/@babel/helper-validator-identifier": {
      "version": "7.29.7",
      "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.29.7.tgz",
      "integrity": "sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg==",
      "license": "MIT",
      "engines": {
        "node": ">=6.9.0"
      }
    },
    "node_modules/@babel/types": {
      "version": "7.29.8",
      "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.8.tgz",
      "integrity": "sha512-Vj1jF3cPfxg7OAfoI7QnVKLoILlm2JF9pnVHrX8qx7AHMiYWT+NDAA7jChlNgRS4WTLc/fD1lXLmPixluj+3Gg==",
      "license": "MIT",
      "dependencies": {
        "@babel/helper-string-parser": "^7.29.7",
        "@babel/helper-validator-identifier": "^7.29.7"
      },
      "engines": {
        "node": ">=6.9.0"
      }
    },
    "node_modules/@types/babel__generator": {
      "version": "7.27.0",
      "resolved": "https://registry.npmjs.org/@types/babel__generator/-/babel__generator-7.27.0.tgz",
      "integrity": "sha512-ufFd2Xi92OAVPYsy+P4n7/U7e68fex0+Ee8gSG9KX7eo084CWiQ4sdxktvdl0bOPupXtVJPY19zk6EwWqUQ8lg==",
      "license": "MIT",
      "dependencies": {
        "@babel/types": "^7.0.0"
      }
    }
  }
}
package.json
{
  "name": "sample-types-babel-generator",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "license": "MIT-0",
  "dependencies": {
    "@types/babel__generator": "7.27.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/%40types/babel__generator@7.27.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40types/babel__generator@7.27.0"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
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/babel__generator package manifest and verify type declaration entry points
const pkgPath = require.resolve('@types/babel__generator/package.json');
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));

assert.equal(pkg.name, '@types/babel__generator', 'Package name must be @types/babel__generator');
assert.equal(pkg.version, '7.27.0', 'Package version must be 7.27.0');
assert.equal(pkg.types, 'index.d.ts', 'Package types entry must point to index.d.ts');
assert.equal(pkg.typeScriptVersion, '5.1', 'TypeScript version must be 5.1');

const typesDir = path.dirname(pkgPath);
const dtsContent = fs.readFileSync(path.join(typesDir, 'index.d.ts'), 'utf8');

// 2. Verify GeneratorOptions interface and jsesc options
assert.ok(
  dtsContent.includes('export interface GeneratorOptions {') &&
  dtsContent.includes('auxiliaryCommentBefore?: string | undefined;') &&
  dtsContent.includes('auxiliaryCommentAfter?: string | undefined;') &&
  dtsContent.includes('shouldPrintComment?(comment: string): boolean;') &&
  dtsContent.includes('retainLines?: boolean | undefined;') &&
  dtsContent.includes('retainFunctionParens?: boolean | undefined;') &&
  dtsContent.includes('comments?: boolean | undefined;') &&
  dtsContent.includes('compact?: boolean | "auto" | undefined;') &&
  dtsContent.includes('minified?: boolean | undefined;') &&
  dtsContent.includes('concise?: boolean | undefined;') &&
  dtsContent.includes('filename?: string | undefined;') &&
  dtsContent.includes('sourceMaps?: boolean | undefined;') &&
  dtsContent.includes('sourceRoot?: string | undefined;') &&
  dtsContent.includes('sourceFileName?: string | undefined;') &&
  dtsContent.includes('jsonCompatibleStrings?: boolean | undefined;') &&
  dtsContent.includes('decoratorsBeforeExport?: boolean | undefined;') &&
  dtsContent.includes('importAttributesKeyword?: "with" | "assert" | "with-legacy";'),
  'GeneratorOptions interface must declare formatting, comment, and syntax options'
);
assert.ok(
  dtsContent.includes('jsescOption?: {') &&
  dtsContent.includes('quotes?: "single" | "double" | "backtick" | undefined;') &&
  dtsContent.includes('numbers?: "binary" | "octal" | "decimal" | "hexadecimal" | undefined;') &&
  dtsContent.includes('wrap?: boolean | undefined;') &&
  dtsContent.includes('es6?: boolean | undefined;') &&
  dtsContent.includes('escapeEverything?: boolean | undefined;') &&
  dtsContent.includes('minimal?: boolean | undefined;') &&
  dtsContent.includes('isScriptContext?: boolean | undefined;') &&
  dtsContent.includes('compact?: boolean | undefined;') &&
  dtsContent.includes('indent?: string | undefined;') &&
  dtsContent.includes('indentLevel?: number | undefined;') &&
  dtsContent.includes('json?: boolean | undefined;') &&
  dtsContent.includes('lowercaseHex?: boolean | undefined;'),
  'jsescOption nested interface must declare string and literal escaping options'
);

// 3. Verify CodeGenerator class declaration
assert.ok(
  dtsContent.includes('export class CodeGenerator {') &&
  dtsContent.includes('constructor(ast: t.Node, opts?: GeneratorOptions, code?: string);') &&
  dtsContent.includes('generate(): GeneratorResult;'),
  'CodeGenerator class must declare constructor taking AST and generate method'
);

// 4. Verify generate function and default export
assert.ok(
  dtsContent.includes('export function generate(') &&
  dtsContent.includes('ast: t.Node,') &&
  dtsContent.includes('opts?: GeneratorOptions,') &&
  dtsContent.includes('code?: string | { [filename: string]: string },') &&
  dtsContent.includes('): GeneratorResult;') &&
  dtsContent.includes('export default generate;'),
  'generate function and default export must be declared'
);

// 5. Verify GeneratorResult interface with code and map
assert.ok(
  dtsContent.includes('export interface GeneratorResult {') &&
  dtsContent.includes('code: string;') &&
  dtsContent.includes('map: {') &&
  dtsContent.includes('version: number;') &&
  dtsContent.includes('sources: string[];') &&
  dtsContent.includes('names: string[];') &&
  dtsContent.includes('sourceRoot?: string | undefined;') &&
  dtsContent.includes('sourcesContent?: string[] | undefined;') &&
  dtsContent.includes('mappings: string;') &&
  dtsContent.includes('file: string;') &&
  dtsContent.includes('} | null;'),
  'GeneratorResult interface must declare code string and sourcemap metadata'
);

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

Ursprungs-Seeder

anonym