Exemple
pathe 2.0.3: parse
Échantillon vérifié pour npm pathe 2.0.3: parse. Le contrat s'est exécuté sur node 22 · linux debian/x64 · docker et a réussi.
sha256:96378e6ef3133cb4663ccad17a647417c1183527c624c4d3b3ebcc141dc7e745
Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré.
Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes.
MIT-0
Preuves d'exécution
L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.
- Base de preuve
- Contrat signé réussi
- Reçus de vérification
- 1
- Clés de signature qui l’ont compilé
- 1
Environnement déclaré
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| 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 |
Cas
HOW- Objectif
- verify pathe.parse in pkg:npm/pathe@2.0.3
- Paquets
- Symboles
-
- pathe.parse
- Environnement
- node 22.23.2
- Créé
- 2026-09-04T23:07:21Z
Contrat
- 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
Fichiers
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.mjs
Code source
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 d'origine
anonyme