CodeSampleX

Exemplo

@types/graceful-fs 4.1.9: gracefulify

Amostra verificada para npm @types/graceful-fs 4.1.9: gracefulify. O contrato rodou em node 22 · linux alpine/x64 · docker e passou.

sha256:ddc319ace51338f86e9dc8d06c628e28997aea146942233e08d6ee0fc6e8e399

Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu. Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas. MIT-0

Evidência de execução

O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.

Base da evidência
Contrato assinado aprovado
Recibos de verificação
1
Chaves de assinatura que o compilaram
1
Ambiente declarado linux 24 · ubuntu · glibc 2.39 x64 npm

Ambientes das execuções de verificação

Ambiente Contrato Etapas Execução
node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5…
2026-08-27

Caso

HOW
Objetivo
verify pkg:npm/%40types/graceful-fs@4.1.9
Pacotes
Símbolos
  • gracefulify
Criado
2026-08-27T23:00:03Z

Contrato

  1. package manifest specifies index.d.ts type declarations and TypeScript 4.5 minimum version
  2. declares node type dependency reference for Node.js fs module types
  3. re-exports all types and members from the fs module
  4. declares generic gracefulify function signature accepting and returning fsModule T
  5. documents gracefulify JSDoc annotations and parameter description

Arquivos

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

Baixar o artefato de código-fonte (tar.gz)

Código-fonte

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/graceful-fs@4.1.9
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40types/graceful-fs@4.1.9
Demonstrate these symbols/APIs:
  - gracefulify

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:1eeee5e7b804650b00bd69ef75c57b2efee5f58c7f97912ec792f35eb8b4659b","contract":["package manifest specifies index.d.ts type declarations and TypeScript 4.5 minimum version","declares node type dependency reference for Node.js fs module types","re-exports all types and members from the fs module","declares generic gracefulify function signature accepting and returning fsModule T","documents gracefulify JSDoc annotations and parameter description"],"goal":"verify pkg:npm/%40types/graceful-fs@4.1.9","kind":"HOW","packages":["pkg:npm/%40types/graceful-fs@4.1.9"],"schemaVersion":1,"symbols":["gracefulify"]},"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/graceful-fs@4.1.9"],"schemaVersion":1,"subject":"pkg:npm/%40types/graceful-fs@4.1.9","symbols":["gracefulify"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-types-graceful-fs",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-types-graceful-fs",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "@types/graceful-fs": "4.1.9"
      }
    },
    "node_modules/@types/graceful-fs": {
      "version": "4.1.9",
      "resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.9.tgz",
      "integrity": "sha512-olP3sd1qOEe5dXTSaFvQG+02VdRXcdytWLAZsAq1PecU8uqQAhkrnbli7DagjtXKW/Bl7YJbUsa8MPcuc8LHEQ==",
      "license": "MIT",
      "dependencies": {
        "@types/node": "*"
      }
    },
    "node_modules/@types/node": {
      "version": "26.4.0",
      "resolved": "https://registry.npmjs.org/@types/node/-/node-26.4.0.tgz",
      "integrity": "sha512-faiGnoIrLH/V8cibOMEAZ8pMw6oXqSukl29ra4mN8GdaB2ZewzeaLj+INpV5N+Z1eKWzY+IzaIZH2EIR6YZRNQ==",
      "license": "MIT",
      "dependencies": {
        "undici-types": "~8.3.0"
      }
    },
    "node_modules/undici-types": {
      "version": "8.3.0",
      "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-8.3.0.tgz",
      "integrity": "sha512-j375ScV60dom+YkPFIfTLcOiPxkN/buHz5GobjLhixFuANaNs3C9l4GmrWqejgXWJ7BbJcFYpTEUkS1Ge8bpZQ==",
      "license": "MIT"
    }
  }
}
package.json
{
  "name": "sample-types-graceful-fs",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "license": "MIT-0",
  "dependencies": {
    "@types/graceful-fs": "4.1.9"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/%40types/graceful-fs@4.1.9",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40types/graceful-fs@4.1.9"
  ],
  "symbols": [
    "gracefulify"
  ]
}
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/graceful-fs package manifest and verify type declaration entry points
const pkgPath = require.resolve('@types/graceful-fs/package.json');
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));

assert.equal(pkg.name, '@types/graceful-fs', 'Package name must be @types/graceful-fs');
assert.equal(pkg.version, '4.1.9', 'Package version must be 4.1.9');
assert.equal(pkg.types, 'index.d.ts', 'Package types entry must point to index.d.ts');
assert.equal(pkg.typeScriptVersion, '4.5', 'TypeScript version must be 4.5');
assert.ok(pkg.dependencies && pkg.dependencies['@types/node'], 'Package must declare dependency on @types/node');

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

// 2. Verify triple-slash reference to node types
assert.ok(
  dtsContent.includes('/// <reference types="node" />'),
  'index.d.ts must reference node types'
);

// 3. Verify re-export of fs module members
assert.ok(
  dtsContent.includes('export * from "fs";'),
  'index.d.ts must re-export all members from fs'
);

// 4. Verify generic gracefulify function declaration
assert.ok(
  dtsContent.includes('export function gracefulify<T>(fsModule: T): T;'),
  'index.d.ts must declare generic gracefulify<T>(fsModule: T): T'
);

// 5. Verify JSDoc documentation annotations for gracefulify
assert.ok(
  dtsContent.includes('Use this method to patch the global fs module (or any other fs-like module).'),
  'index.d.ts must include JSDoc explanation for gracefulify'
);
assert.ok(
  dtsContent.includes('@param fsModule The reference to the fs module or an fs-like module.'),
  'index.d.ts must document the fsModule parameter'
);

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

Seeder de origem

anônimo