示例
pathe 2.0.3: parse
已验证示例 — npm pathe 2.0.3: parse. contract 在 node 22 · linux debian/x64 · docker 上运行并通过: pathe.parse parses a POSIX absolute path into root, dir, base, ext…
sha256:96378e6ef3133cb4663ccad17a647417c1183527c624c4d3b3ebcc141dc7e745
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。
MIT-0
执行证据
声明的环境与签名的运行分开呈现,你可以看到这个样本究竟运行了什么、在哪里运行。
- 证据依据
- 签名契约通过
- 验证回执
- 1
- 构建过它的签名密钥
- 1
声明的环境
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
验证运行环境
| 环境 | 契约 | 阶段 | 运行日期 |
|---|---|---|---|
| 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 |
案例
HOW- 目标
- verify pathe.parse in pkg:npm/pathe@2.0.3
- 符号
-
- pathe.parse
- 环境
- node 22.23.2
- 创建时间
- 2026-09-04T23:07:21Z
契约
- 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
文件
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- 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 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.');
原始种子者
匿名