CodeSampleX

Beispiel

which 5.0.0

Verifiziertes Beispiel für npm which 5.0.0. Der Vertrag lief auf node 22 · linux alpine/x64 · docker und bestand: which(cmd) resolves to executable path on…

sha256:acb536ea5763427676f53abd1cfcc6c46c562b389bbf9891f429ca3f1b063762

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

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/which@5.0.0
Pakete
Umgebung
node 22.23.2
Erstellt
2026-08-21T15:41:17Z

Contract

  1. which(cmd) resolves to executable path on PATH
  2. which.sync(cmd) synchronously returns executable path
  3. which.sync(cmd, { nothrow: true }) returns null when executable is not found
  4. which(cmd) rejects with ENOENT when executable is not found
  5. which.sync(cmd, { all: true }) returns an array of executable paths

Dateien

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

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/which@5.0.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/which@5.0.0
Constraints:
  - executionContext: node
Required runtime conditions:
  - ecosystem: npm
  - language: javascript
  - moduleSystem: cjs
  - 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:825e4d3327cce6ec5e83f51c584881b2a52eb5bd7d897ba5ecee902d2f6e50a2","constraints":{"executionContext":"node"},"contract":["which(cmd) resolves to executable path on PATH","which.sync(cmd) synchronously returns executable path","which.sync(cmd, { nothrow: true }) returns null when executable is not found","which(cmd) rejects with ENOENT when executable is not found","which.sync(cmd, { all: true }) returns an array of executable paths"],"goal":"verify pkg:npm/which@5.0.0","kind":"HOW","packages":["pkg:npm/which@5.0.0"],"schemaVersion":1},"contractCommand":["node","test/contract.js"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/which@5.0.0"],"schemaVersion":1,"subject":"pkg:npm/which@5.0.0","verifierAdapter":"node-typescript@1"}
index.js
'use strict';

const which = require('which');

async function findExecutable(cmd, options = {}) {
  return await which(cmd, options);
}

function findExecutableSync(cmd, options = {}) {
  return which.sync(cmd, options);
}

module.exports = {
  findExecutable,
  findExecutableSync,
};
package-lock.json
{
  "name": "sample-2364529473",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-2364529473",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "which": "5.0.0"
      }
    },
    "node_modules/isexe": {
      "version": "3.1.5",
      "resolved": "https://registry.npmjs.org/isexe/-/isexe-3.1.5.tgz",
      "integrity": "sha512-6B3tLtFqtQS4ekarvLVMZ+X+VlvQekbe4taUkf/rhVO3d/h0M2rfARm/pXLcPEsjjMsFgrFgSrhQIxcSVrBz8w==",
      "license": "BlueOak-1.0.0",
      "engines": {
        "node": ">=18"
      }
    },
    "node_modules/which": {
      "version": "5.0.0",
      "resolved": "https://registry.npmjs.org/which/-/which-5.0.0.tgz",
      "integrity": "sha512-JEdGzHwwkrbWoGOlIHqQ5gtprKGOenpDHpxE9zVR1bWbOtYRyPPHMe9FaP6x61CmNaTThSkb0DAJte5jD+DmzQ==",
      "license": "ISC",
      "dependencies": {
        "isexe": "^3.1.1"
      },
      "bin": {
        "node-which": "bin/which.js"
      },
      "engines": {
        "node": "^18.17.0 || >=20.5.0"
      }
    }
  }
}
package.json
{
  "name": "sample-2364529473",
  "version": "1.0.0",
  "description": "Minimal sample verifying which@5.0.0",
  "main": "index.js",
  "scripts": {
    "test": "node test/contract.js"
  },
  "keywords": [],
  "author": "",
  "license": "MIT-0",
  "dependencies": {
    "which": "5.0.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/which@5.0.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/which@5.0.0"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "runtime": "node@22.23.2"
  }
}
test/contract.js
'use strict';

const assert = require('assert');
const which = require('which');
const { findExecutable, findExecutableSync } = require('../index.js');

async function runContract() {
  // 1. which(cmd) resolves to executable path on PATH
  const nodePath = await which('node');
  assert(typeof nodePath === 'string' && nodePath.length > 0, 'which(node) should return non-empty path');

  const wrapperPath = await findExecutable('node');
  assert.strictEqual(wrapperPath, nodePath, 'findExecutable should match which');

  // 2. which.sync(cmd) synchronously returns executable path
  const syncPath = which.sync('node');
  assert.strictEqual(syncPath, nodePath, 'sync path should match async path');

  const wrapperSyncPath = findExecutableSync('node');
  assert.strictEqual(wrapperSyncPath, syncPath, 'findExecutableSync should match syncPath');

  // 3. which.sync(cmd, { nothrow: true }) returns null when executable is not found
  const missingSync = which.sync('nonexistent_binary_xyz_12345', { nothrow: true });
  assert.strictEqual(missingSync, null, 'nothrow should return null for missing binary');

  const missingWrapperSync = findExecutableSync('nonexistent_binary_xyz_12345', { nothrow: true });
  assert.strictEqual(missingWrapperSync, null, 'findExecutableSync should return null with nothrow');

  // 4. which(cmd) rejects with ENOENT when executable is not found
  let threwAsync = false;
  try {
    await which('nonexistent_binary_xyz_12345');
  } catch (err) {
    threwAsync = true;
    assert.strictEqual(err.code, 'ENOENT');
  }
  assert.strictEqual(threwAsync, true, 'which should reject with ENOENT for missing binary');

  let threwWrapperAsync = false;
  try {
    await findExecutable('nonexistent_binary_xyz_12345');
  } catch (err) {
    threwWrapperAsync = true;
    assert.strictEqual(err.code, 'ENOENT');
  }
  assert.strictEqual(threwWrapperAsync, true, 'findExecutable should reject with ENOENT for missing binary');

  // 5. which.sync(cmd, { all: true }) returns an array of executable paths
  const allSync = which.sync('node', { all: true });
  assert(Array.isArray(allSync) && allSync.length > 0, 'all: true should return a non-empty array');
  assert.strictEqual(allSync[0], nodePath, 'first entry should match default single resolve');

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

runContract().catch((err) => {
  console.error('Contract test failed:', err);
  process.exit(1);
});

Ursprungs-Seeder

anonym