Ejemplo
import-local 3.2.0: importLocal
Muestra verificada para npm import-local 3.2.0: importLocal. El contrato se ejecutó en node 22 · linux alpine/x64 · docker y pasó.
sha256:5e86ad77451266da99a77f1114ae0225a3406647ba9d9dd57101847849fbd38c
Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido.
Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas.
MIT-0
Evidencia de ejecución
El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.
- Base de evidencia
- Contrato firmado aprobado
- Recibos de verificación
- 1
- Claves de firma que lo compilaron
- 1
Entorno declarado
linux 24 · ubuntu · glibc 2.39 x64 npm
Entornos de las ejecuciones de verificación
| Entorno | Contrato | Etapas | Ejecución |
|---|---|---|---|
| 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/import-local@3.2.0
- Paquetes
- Símbolos
-
- importLocal
- Creado
- 2026-08-27T15:41:52Z
Contrato
- importLocal is exported as a function that checks for a locally installed version of a package
- importLocal returns falsy when called on a file with no corresponding local installation in the current working directory
- importLocal accepts file:// URLs and file paths to package entry points
- importLocal imports and returns the local package module when a matching package exists in the current working directory's node_modules
- importLocal returns false when invoked from within the local node_modules directory to prevent recursive imports
Archivos
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.mjs
Código fuente
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/import-local@3.2.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/import-local@3.2.0
Demonstrate these symbols/APIs:
- importLocal
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.
{"case":{"caseId":"case:sha256:db00048acace335bf663bb2ea6636a2c893de02a8fc27c37364a63bfdfbaab1e","contract":["importLocal is exported as a function that checks for a locally installed version of a package","importLocal returns falsy when called on a file with no corresponding local installation in the current working directory","importLocal accepts file:// URLs and file paths to package entry points","importLocal imports and returns the local package module when a matching package exists in the current working directory's node_modules","importLocal returns false when invoked from within the local node_modules directory to prevent recursive imports"],"goal":"verify pkg:npm/import-local@3.2.0","kind":"HOW","packages":["pkg:npm/import-local@3.2.0"],"schemaVersion":1,"symbols":["importLocal"]},"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/import-local@3.2.0"],"schemaVersion":1,"subject":"pkg:npm/import-local@3.2.0","symbols":["importLocal"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-import-local",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-import-local",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"import-local": "3.2.0"
}
},
"node_modules/find-up": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz",
"integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==",
"license": "MIT",
"dependencies": {
"locate-path": "^5.0.0",
"path-exists": "^4.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/import-local": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/import-local/-/import-local-3.2.0.tgz",
"integrity": "sha512-2SPlun1JUPWoM6t3F0dw0FkCF/jWY8kttcY4f599GLTSjh2OCuuhdTkJQsEcZzBqbXZGKMK2OqW1oZsjtf/gQA==",
"license": "MIT",
"dependencies": {
"pkg-dir": "^4.2.0",
"resolve-cwd": "^3.0.0"
},
"bin": {
"import-local-fixture": "fixtures/cli.js"
},
"engines": {
"node": ">=8"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/locate-path": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz",
"integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==",
"license": "MIT",
"dependencies": {
"p-locate": "^4.1.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/p-limit": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz",
"integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==",
"license": "MIT",
"dependencies": {
"p-try": "^2.0.0"
},
"engines": {
"node": ">=6"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/p-locate": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz",
"integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==",
"license": "MIT",
"dependencies": {
"p-limit": "^2.2.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/p-try": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz",
"integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==",
"license": "MIT",
"engines": {
"node": ">=6"
}
},
"node_modules/path-exists": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz",
"integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==",
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/pkg-dir": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz",
"integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==",
"license": "MIT",
"dependencies": {
"find-up": "^4.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/resolve-cwd": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/resolve-cwd/-/resolve-cwd-3.0.0.tgz",
"integrity": "sha512-OrZaX2Mb+rJCpH/6CpSqt9xFVpN++x01XnN2ie9g6P5/3xelLAkXWVADpdz1IHD/KFfEXyE6V0U01OQ3UO2rEg==",
"license": "MIT",
"dependencies": {
"resolve-from": "^5.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/resolve-from": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz",
"integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==",
"license": "MIT",
"engines": {
"node": ">=8"
}
}
}
}
{
"name": "sample-import-local",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification sample for import-local",
"main": "src/index.js",
"scripts": {
"test": "node test/contract.mjs"
},
"dependencies": {
"import-local": "3.2.0"
},
"license": "MIT-0"
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/import-local@3.2.0",
"kind": "HOW",
"packages": [
"pkg:npm/import-local@3.2.0"
],
"symbols": [
"importLocal"
]
}
const importLocal = require('import-local');
function tryImportLocal(filePath) {
return importLocal(filePath);
}
module.exports = {
importLocal,
tryImportLocal
};
import assert from 'node:assert/strict';
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import { pathToFileURL } from 'node:url';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const importLocal = require('import-local');
const { tryImportLocal } = require('../src/index.js');
// 1. Symbol and function contract
assert.strictEqual(typeof importLocal, 'function', 'importLocal is exported as a callable function');
assert.strictEqual(typeof tryImportLocal, 'function', 'tryImportLocal helper wraps importLocal');
// 2. Returns falsy when no local duplicate exists in the working directory
const notLocalResult = importLocal(import.meta.url);
assert.strictEqual(!notLocalResult, true, 'importLocal returns falsy when local duplicate is not found in cwd');
// 3. Supports file:// URLs
const urlResult = tryImportLocal(import.meta.url);
assert.strictEqual(!urlResult, true, 'importLocal accepts file:// URLs and processes them without throwing');
// 4. Resolves and requires local package when called from outside local node_modules
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'csx-import-local-contract-'));
try {
// Global simulation
const globalPkgDir = path.join(tempDir, 'global-env', 'node_modules', 'contract-fixture-cli');
fs.mkdirSync(path.join(globalPkgDir, 'bin'), { recursive: true });
fs.writeFileSync(path.join(globalPkgDir, 'package.json'), JSON.stringify({
name: 'contract-fixture-cli',
version: '1.0.0',
bin: { 'contract-fixture-cli': 'bin/cli.js' }
}));
const globalCliFile = path.join(globalPkgDir, 'bin', 'cli.js');
fs.writeFileSync(globalCliFile, 'module.exports = { isLocal: false, version: "1.0.0" };');
// Local project simulation with local installation of contract-fixture-cli
const localProjectDir = path.join(tempDir, 'project-dir');
const localPkgDir = path.join(localProjectDir, 'node_modules', 'contract-fixture-cli');
fs.mkdirSync(path.join(localPkgDir, 'bin'), { recursive: true });
fs.writeFileSync(path.join(localPkgDir, 'package.json'), JSON.stringify({
name: 'contract-fixture-cli',
version: '2.5.0',
bin: { 'contract-fixture-cli': 'bin/cli.js' }
}));
const localCliFile = path.join(localPkgDir, 'bin', 'cli.js');
fs.writeFileSync(localCliFile, 'module.exports = { isLocal: true, version: "2.5.0", loaded: true };');
const previousCwd = process.cwd();
try {
process.chdir(localProjectDir);
// Call importLocal from global binary path
const resolvedLocal = importLocal(globalCliFile);
assert.ok(resolvedLocal, 'importLocal imports the local module when available in cwd node_modules');
assert.strictEqual(resolvedLocal.isLocal, true, 'imported module is the local version');
assert.strictEqual(resolvedLocal.version, '2.5.0', 'imported module matches local version 2.5.0');
assert.strictEqual(resolvedLocal.loaded, true, 'local module exports are returned');
// Call importLocal via file:// URL
const resolvedLocalFromUrl = importLocal(pathToFileURL(globalCliFile).href);
assert.ok(resolvedLocalFromUrl, 'importLocal resolves correctly when given file:// URL');
assert.strictEqual(resolvedLocalFromUrl.version, '2.5.0', 'version matches local module');
// Call importLocal from inside the local node_modules file itself (should not re-import)
const selfImportResult = importLocal(localCliFile);
assert.strictEqual(selfImportResult, false, 'importLocal returns false when the file is already inside local node_modules');
// Call importLocal in empty project directory
const emptyDir = path.join(tempDir, 'empty-dir');
fs.mkdirSync(emptyDir, { recursive: true });
process.chdir(emptyDir);
const emptyResult = importLocal(globalCliFile);
assert.strictEqual(!emptyResult, true, 'importLocal returns falsy when local package is absent');
} finally {
process.chdir(previousCwd);
}
} finally {
fs.rmSync(tempDir, { recursive: true, force: true });
}
console.log('Contract tests passed successfully.');
Seeder de origen
anónimo