Exemplo
pathe 2.0.3: parse
Amostra verificada para npm pathe 2.0.3: parse. O contrato rodou em node 22 · linux debian/x64 · docker e passou: pathe.parse parses a POSIX absolute path…
sha256:96378e6ef3133cb4663ccad17a647417c1183527c624c4d3b3ebcc141dc7e745
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
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
Ambientes das execuções de verificação
| Ambiente | Contrato | Etapas | Execução |
|---|---|---|---|
| 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-09-04 |
Caso
HOW- Objetivo
- verify pathe.parse in pkg:npm/pathe@2.0.3
- Pacotes
- Símbolos
-
- pathe.parse
- Ambiente
- node 22.23.2
- Criado
- 2026-09-04T23:07:21Z
Contrato
- pathe.parse parses a POSIX absolute path into root, dir, base, ext, and name components
- pathe.parse extracts file extension and base name correctly for single and multiple dots
- pathe.parse normalizes Windows backslashes extracting base name and extension
- pathe.parse parses relative file paths and single filenames with current directory fallback
- pathe.parse parses root path and empty path with appropriate component fallbacks
- pathe.parse handles directory paths with trailing slashes extracting directory basename
Arquivos
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.mjs
Código-fonte
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 pathe.parse in pkg:npm/pathe@2.0.3
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/pathe@2.0.3
Demonstrate these symbols/APIs:
- pathe.parse
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:36280dbb87420b2207d5c00cfcaf239a1f400bec69ed25184ef42509c5a82b40","constraints":{"executionContext":"node"},"contract":["pathe.parse parses a POSIX absolute path into root, dir, base, ext, and name components","pathe.parse extracts file extension and base name correctly for single and multiple dots","pathe.parse normalizes Windows backslashes extracting base name and extension","pathe.parse parses relative file paths and single filenames with current directory fallback","pathe.parse parses root path and empty path with appropriate component fallbacks","pathe.parse handles directory paths with trailing slashes extracting directory basename"],"goal":"verify pathe.parse in pkg:npm/pathe@2.0.3","kind":"HOW","packages":["pkg:npm/pathe@2.0.3"],"schemaVersion":1,"symbols":["pathe.parse"]},"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/pathe@2.0.3"],"schemaVersion":1,"subject":"pkg:npm/pathe@2.0.3","symbols":["pathe.parse"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-pathe-parse",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-pathe-parse",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"pathe": "2.0.3"
}
},
"node_modules/pathe": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz",
"integrity": "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==",
"license": "MIT"
}
}
}
{
"name": "sample-pathe-parse",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification of pathe.parse in pkg:npm/pathe@2.0.3",
"main": "src/index.js",
"license": "MIT-0",
"dependencies": {
"pathe": "2.0.3"
}
}
{
"schemaVersion": 1,
"goal": "verify pathe.parse in pkg:npm/pathe@2.0.3",
"kind": "HOW",
"packages": [
"pkg:npm/pathe@2.0.3"
],
"symbols": [
"pathe.parse"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
const { parse } = require('pathe');
/**
* Parses a path string into an object with root, dir, base, ext, and name properties.
* Normalizes Windows-style backslashes to forward slashes.
*
* @param {string} path - The path string to parse.
* @returns {object} Object representing the path components.
*/
function parsePath(path) {
return parse(path);
}
module.exports = {
parse,
parsePath
};
import assert from 'node:assert';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const { parse, parsePath } = require('../src/index.js');
// 1. pathe.parse parses a POSIX absolute path into root, dir, base, ext, and name components
{
const parsed = parse('/path/to/file.ext');
assert.strictEqual(parsed.root, '/');
assert.strictEqual(parsed.dir, '/path/to');
assert.strictEqual(parsed.base, 'file.ext');
assert.strictEqual(parsed.ext, '.ext');
assert.strictEqual(parsed.name, 'file');
const wrapper = parsePath('/a/b/c.txt');
assert.strictEqual(wrapper.root, '/');
assert.strictEqual(wrapper.dir, '/a/b');
assert.strictEqual(wrapper.base, 'c.txt');
assert.strictEqual(wrapper.ext, '.txt');
assert.strictEqual(wrapper.name, 'c');
}
// 2. pathe.parse extracts file extension and base name correctly for single and multiple dots
{
const multiDot = parse('archive.tar.gz');
assert.strictEqual(multiDot.base, 'archive.tar.gz');
assert.strictEqual(multiDot.ext, '.gz');
assert.strictEqual(multiDot.name, 'archive.tar');
const noExt = parse('/a/b/c');
assert.strictEqual(noExt.base, 'c');
assert.strictEqual(noExt.ext, '');
assert.strictEqual(noExt.name, 'c');
const dotfile = parse('.gitignore');
assert.strictEqual(dotfile.base, '.gitignore');
assert.strictEqual(dotfile.ext, '');
assert.strictEqual(dotfile.name, '.gitignore');
}
// 3. pathe.parse normalizes Windows backslashes extracting base name and extension
{
const winPath = parse('foo\\bar\\file.txt');
assert.strictEqual(winPath.base, 'file.txt');
assert.strictEqual(winPath.ext, '.txt');
assert.strictEqual(winPath.name, 'file');
const winSubdir = parse('dir\\subdir\\test.json');
assert.strictEqual(winSubdir.base, 'test.json');
assert.strictEqual(winSubdir.ext, '.json');
assert.strictEqual(winSubdir.name, 'test');
}
// 4. pathe.parse parses relative file paths and single filenames with current directory fallback
{
const relPath = parse('src/components/button.jsx');
assert.strictEqual(relPath.root, '');
assert.strictEqual(relPath.dir, 'src/components');
assert.strictEqual(relPath.base, 'button.jsx');
assert.strictEqual(relPath.ext, '.jsx');
assert.strictEqual(relPath.name, 'button');
const bareFile = parse('index.js');
assert.strictEqual(bareFile.root, '');
assert.strictEqual(bareFile.dir, '.');
assert.strictEqual(bareFile.base, 'index.js');
assert.strictEqual(bareFile.ext, '.js');
assert.strictEqual(bareFile.name, 'index');
}
// 5. pathe.parse parses root path and empty path with appropriate component fallbacks
{
const rootPath = parse('/');
assert.strictEqual(rootPath.root, '/');
assert.strictEqual(rootPath.dir, '/');
assert.strictEqual(rootPath.base, '');
assert.strictEqual(rootPath.ext, '');
assert.strictEqual(rootPath.name, '');
const emptyPath = parse('');
assert.strictEqual(emptyPath.root, '');
assert.strictEqual(emptyPath.dir, '.');
assert.strictEqual(emptyPath.base, '');
assert.strictEqual(emptyPath.ext, '');
assert.strictEqual(emptyPath.name, '');
}
// 6. pathe.parse handles directory paths with trailing slashes extracting directory basename
{
const trailingSlash = parse('/dir/subdir/');
assert.strictEqual(trailingSlash.root, '/');
assert.strictEqual(trailingSlash.dir, '/dir');
assert.strictEqual(trailingSlash.base, 'subdir');
assert.strictEqual(trailingSlash.ext, '');
assert.strictEqual(trailingSlash.name, 'subdir');
}
console.log('Contract tests passed successfully.');
Seeder de origem
anônimo