Пример
bare-path 3.1.1: resolve
Проверенный пример — npm bare-path 3.1.1: resolve. Контракт выполнен на node 22 · linux alpine/x64 · docker и пройден: bare-path exports resolve function…
sha256:5d8194f07c7f92a55972ea610019005234b4c0bdb579867a8c0d3e0df18bae8f
Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла.
Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди.
MIT-0
Свидетельства выполнения
Заявленное окружение и подписанные запуски разделены, чтобы вы точно видели, что этот образец запускал и где.
- Основа свидетельства
- Подписанный контракт пройден
- Квитанции проверки
- 1
- Ключи подписи, собравшие его
- 1
Заявленная среда
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
Среды запусков проверки
| Окружение | Контракт | Этапы | Запуск |
|---|---|---|---|
| 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 |
Кейс
HOW- Цель
- verify bare-path.resolve in pkg:npm/bare-path@3.1.1
- Пакеты
- Символы
-
- bare-path.resolve
- Окружение
- node 22.23.2
- Создан
- 2026-08-27T16:13:55Z
Контракт
- bare-path exports resolve function directly and via posix/win32 sub-namespaces
- resolve resolves absolute and relative path segments into a normalized absolute path
- resolve defaults to current working directory when given relative paths or no arguments
- resolve ignores empty path segments and normalizes dot and dot-dot segments correctly
- resolve validates argument types and throws TypeError when non-string arguments are provided
Файлы
- PROMPT.md
- csx.json
- index.js
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
Исходный код
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 bare-path.resolve in pkg:npm/bare-path@3.1.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/bare-path@3.1.1
Demonstrate these symbols/APIs:
- bare-path.resolve
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.
{"case":{"caseId":"case:sha256:d14e1baf8d2bf1606e2a62474d50739b2163fea2eb9603400c7d43891558a244","constraints":{"executionContext":"node"},"contract":["bare-path exports resolve function directly and via posix/win32 sub-namespaces","resolve resolves absolute and relative path segments into a normalized absolute path","resolve defaults to current working directory when given relative paths or no arguments","resolve ignores empty path segments and normalizes dot and dot-dot segments correctly","resolve validates argument types and throws TypeError when non-string arguments are provided"],"goal":"verify bare-path.resolve in pkg:npm/bare-path@3.1.1","kind":"HOW","packages":["pkg:npm/bare-path@3.1.1"],"schemaVersion":1,"symbols":["bare-path.resolve"]},"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/bare-path@3.1.1"],"schemaVersion":1,"subject":"pkg:npm/bare-path@3.1.1","symbols":["bare-path.resolve"],"verifierAdapter":"node-typescript@1"}
import { createRequire } from 'node:module';
import path from 'node:path';
const require = createRequire(import.meta.url);
// Ensure native binding is provided in Node.js environments where Bare runtime is absent
if (typeof Bare === 'undefined') {
globalThis.Bare = {
platform: process.platform
};
const mainPath = require.resolve('bare-path');
const bindingPath = path.join(path.dirname(mainPath), 'binding.js');
require.cache[bindingPath] = {
id: bindingPath,
filename: bindingPath,
loaded: true,
exports: {
cwd() {
return process.cwd();
}
}
};
}
const barePath = require('bare-path');
/**
* Resolves a sequence of paths or path segments into an absolute path using bare-path.
* @param {...string} paths
* @returns {string}
*/
export function resolvePath(...paths) {
return barePath.resolve(...paths);
}
/**
* Resolves path segments specifically using bare-path posix resolver.
* @param {...string} paths
* @returns {string}
*/
export function resolvePosixPath(...paths) {
return barePath.posix.resolve(...paths);
}
export default barePath;
{
"name": "sample-bare-path-resolve",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-bare-path-resolve",
"version": "1.0.0",
"dependencies": {
"bare-path": "3.1.1"
}
},
"node_modules/bare-path": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/bare-path/-/bare-path-3.1.1.tgz",
"integrity": "sha512-JprUlveX3QjApC1cTpsUOiscADftCGVWkzitbHsRqv84hzYwYHw2mbluddsq5TvI8mH/8Ov1f4BiMAdcB0oYnQ==",
"license": "Apache-2.0"
}
}
}
{
"name": "sample-bare-path-resolve",
"version": "1.0.0",
"type": "module",
"private": true,
"dependencies": {
"bare-path": "3.1.1"
}
}
{
"schemaVersion": 1,
"goal": "verify bare-path.resolve in pkg:npm/bare-path@3.1.1",
"kind": "HOW",
"packages": [
"pkg:npm/bare-path@3.1.1"
],
"symbols": [
"bare-path.resolve"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
import assert from 'node:assert/strict';
import path from 'node:path';
import barePath, { resolvePath, resolvePosixPath } from '../index.js';
// 1. bare-path exports resolve function directly and via posix/win32 sub-namespaces
assert.strictEqual(typeof barePath.resolve, 'function', 'barePath.resolve must be a function');
assert.strictEqual(typeof barePath.posix.resolve, 'function', 'barePath.posix.resolve must be a function');
assert.strictEqual(typeof barePath.win32.resolve, 'function', 'barePath.win32.resolve must be a function');
assert.strictEqual(typeof resolvePath, 'function', 'resolvePath helper must be a function');
assert.strictEqual(typeof resolvePosixPath, 'function', 'resolvePosixPath helper must be a function');
// 2. resolve resolves absolute and relative path segments into a normalized absolute path
const posixAbs = barePath.posix.resolve('/a/b', 'c', 'd');
assert.strictEqual(posixAbs, '/a/b/c/d', 'posix.resolve must resolve segments into an absolute path');
const helperResolved = resolvePosixPath('/foo/bar', '../baz');
assert.strictEqual(helperResolved, '/foo/baz', 'resolvePosixPath helper must resolve relative path segments');
// 3. resolve defaults to current working directory when given relative paths or no arguments
const defaultCwd = barePath.posix.resolve();
assert.strictEqual(defaultCwd, process.cwd(), 'posix.resolve() with no arguments must return cwd');
const relResolved = barePath.posix.resolve('sample', 'test');
assert.strictEqual(relResolved, `${process.cwd()}/sample/test`, 'posix.resolve with relative path must prefix cwd');
// 4. resolve ignores empty path segments and normalizes dot and dot-dot segments correctly
const withEmpty = barePath.posix.resolve('/project', '', 'sub', '.', 'file.txt');
assert.strictEqual(withEmpty, '/project/sub/file.txt', 'posix.resolve must ignore empty segments and normalize dot');
const withParent = barePath.posix.resolve('/project/a/b/c', '../../d');
assert.strictEqual(withParent, '/project/a/d', 'posix.resolve must resolve parent directory dots');
// 5. resolve validates argument types and throws TypeError when non-string arguments are provided
assert.throws(
() => barePath.posix.resolve(123),
{
name: 'TypeError',
message: 'The "paths[0]" argument must be of type string. Received type number'
},
'posix.resolve must throw TypeError for non-string arguments'
);
assert.throws(
() => barePath.posix.resolve('/valid', null),
{
name: 'TypeError',
message: 'The "paths[1]" argument must be of type string. Received type object'
},
'posix.resolve must throw TypeError for null argument'
);
console.log('Contract verification finished successfully.');
Исходный сидер
аноним