CodeSampleX

Sample

pathe 2.0.3: parse

Verified sample for npm pathe 2.0.3: parse. The contract ran on node 22 · linux debian/x64 · docker and passed: pathe.parse parses a POSIX absolute path into…

sha256:96378e6ef3133cb4663ccad17a647417c1183527c624c4d3b3ebcc141dc7e745

This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured. How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people. MIT-0

Execution evidence

The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.

Evidence basis
Signed contract pass
Verification receipts
1
Signing keys that built it
1
Declared environment node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Verification-run environments

Environment Contract Stages Run
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

Case

HOW
Goal
verify pathe.parse in pkg:npm/pathe@2.0.3
Packages
Symbols
  • pathe.parse
Environment
node 22.23.2
Created
2026-09-04T23:07:21Z

Contract

  1. pathe.parse parses a POSIX absolute path into root, dir, base, ext, and name components
  2. pathe.parse extracts file extension and base name correctly for single and multiple dots
  3. pathe.parse normalizes Windows backslashes extracting base name and extension
  4. pathe.parse parses relative file paths and single filenames with current directory fallback
  5. pathe.parse parses root path and empty path with appropriate component fallbacks
  6. pathe.parse handles directory paths with trailing slashes extracting directory basename

Files

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • src/index.js
  • test/contract.mjs

Download the source artifact (tar.gz)

Source

PROMPT.md
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.
csx.json
{"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"}
package-lock.json
{
  "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"
    }
  }
}
package.json
{
  "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"
  }
}
spec.json
{
  "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"
  }
}
src/index.js
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
};
test/contract.mjs
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.');

Origin Seeder

anonymous