CodeSampleX

Sample

cmd-shim 7.0.0: cmdShim.ifExists

Verified sample for npm cmd-shim 7.0.0: cmdShim.ifExists. The contract ran on node 22 · linux debian/x64 · docker and passed: cmdShim.ifExists(from, to)…

sha256:601c251495132f57bbb0cdb549b03f7ba8d530b139a425832a414c090ae1af9e

This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured. How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people. MIT-0

Execution evidence

The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.

Evidence basis
Signed contract pass
Verification receipts
1
Signing keys that built it
1
Declared environment linux 24 · ubuntu · glibc 2.39 x64 npm

Verification-run environments

Environment Contract Stages Run
node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2…
2026-10-18

Case

HOW
Goal
verify cmdShim.ifExists in pkg:npm/cmd-shim@7.0.0
Packages
Symbols
  • cmdShim.ifExists
Created
2026-10-18T16:09:40Z

Contract

  1. cmdShim.ifExists(from, to) creates sh, .cmd, and .ps1 executable shims at `to` when `from` exists
  2. cmdShim.ifExists(from, to) resolves without error and does not create shim files when `from` does not exist

Files

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

Download the source artifact (tar.gz)

Source

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 cmdShim.ifExists in pkg:npm/cmd-shim@7.0.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/cmd-shim@7.0.0
Demonstrate these symbols/APIs:
  - cmdShim.ifExists

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:e2b8d790ee922495c45e1672b85dd25c0fa5de5ff8b4749460e4469954d31f8d","contract":["cmdShim.ifExists(from, to) creates sh, .cmd, and .ps1 executable shims at `to` when `from` exists","cmdShim.ifExists(from, to) resolves without error and does not create shim files when `from` does not exist"],"goal":"verify cmdShim.ifExists in pkg:npm/cmd-shim@7.0.0","kind":"HOW","packages":["pkg:npm/cmd-shim@7.0.0"],"schemaVersion":1,"symbols":["cmdShim.ifExists"]},"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/cmd-shim@7.0.0"],"schemaVersion":1,"subject":"pkg:npm/cmd-shim@7.0.0","symbols":["cmdShim.ifExists"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-cmd-shim",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-cmd-shim",
      "version": "1.0.0",
      "dependencies": {
        "cmd-shim": "7.0.0"
      }
    },
    "node_modules/cmd-shim": {
      "version": "7.0.0",
      "resolved": "https://registry.npmjs.org/cmd-shim/-/cmd-shim-7.0.0.tgz",
      "integrity": "sha512-rtpaCbr164TPPh+zFdkWpCyZuKkjpAzODfaZCf/SVJZzJN+4bHQb/LP3Jzq5/+84um3XXY8r548XiWKSborwVw==",
      "license": "ISC",
      "engines": {
        "node": "^18.17.0 || >=20.5.0"
      }
    }
  }
}
package.json
{
  "name": "sample-cmd-shim",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "dependencies": {
    "cmd-shim": "7.0.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify cmdShim.ifExists in pkg:npm/cmd-shim@7.0.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/cmd-shim@7.0.0"
  ],
  "symbols": [
    "cmdShim.ifExists"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import { mkdtemp, readFile, rm, stat, writeFile } from 'node:fs/promises';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import cmdShim from 'cmd-shim';

const workDir = await mkdtemp(join(tmpdir(), 'cmd-shim-contract-'));

try {
  // 1. When the source script exists, cmdShim.ifExists creates the shims (.sh, .cmd, .ps1)
  const srcScript = join(workDir, 'cli.js');
  const destShim = join(workDir, 'bin', 'my-cli');
  await writeFile(srcScript, '#!/usr/bin/env node\nconsole.log("ok");\n', 'utf8');

  await cmdShim.ifExists(srcScript, destShim);

  const shContent = await readFile(destShim, 'utf8');
  const cmdContent = await readFile(`${destShim}.cmd`, 'utf8');
  const ps1Content = await readFile(`${destShim}.ps1`, 'utf8');

  assert.ok(shContent.startsWith('#!/bin/sh'), 'Shell shim must start with #!/bin/sh');
  assert.ok(shContent.includes('cli.js'), 'Shell shim must reference target script');
  assert.ok(cmdContent.startsWith('@ECHO off'), 'Batch shim must start with @ECHO off');
  assert.ok(cmdContent.includes('cli.js'), 'Batch shim must reference target script');
  assert.ok(ps1Content.startsWith('#!/usr/bin/env pwsh'), 'PowerShell shim must start with #!/usr/bin/env pwsh');
  assert.ok(ps1Content.includes('cli.js'), 'PowerShell shim must reference target script');

  // 2. When the source script does NOT exist, cmdShim.ifExists resolves silently without creating shims
  const missingSrc = join(workDir, 'nonexistent.js');
  const missingShim = join(workDir, 'bin', 'missing-cli');

  const result = await cmdShim.ifExists(missingSrc, missingShim);
  assert.equal(result, undefined, 'cmdShim.ifExists resolves to undefined when source does not exist');

  await assert.rejects(
    () => stat(missingShim),
    { code: 'ENOENT' },
    'No shim file should be created when source does not exist'
  );
} finally {
  await rm(workDir, { recursive: true, force: true });
}

Origin Seeder

anonymous