CodeSampleX

Sample

picomatch 2.3.2

Verified sample for npm picomatch 2.3.2. The contract ran on node 22 · linux alpine/x64 · docker and passed: picomatch creates compiled matcher functions…

sha256:eb22deb580c1183937b491034ad7e0de6b41a97941dbc88293cebb76f51d7443

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 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

Case

HOW
Goal
verify pkg:npm/picomatch@2.3.2
Packages
Environment
node 22.23.2
Created
2026-08-27T15:29:24Z

Contract

  1. picomatch creates compiled matcher functions supporting wildcards, brace expansions, and negated patterns
  2. picomatch.isMatch evaluates paths against glob patterns with support for case-insensitivity, dotfiles, and ignore rules
  3. picomatch.scan parses glob patterns into components including static base directory, glob portion, and isGlob metadata
  4. picomatch.makeRe compiles glob patterns into RegExp instances for regular expression matching

Files

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

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 pkg:npm/picomatch@2.3.2
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/picomatch@2.3.2
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:4c8d305f92c97cfc254d87f30ab3ec866843a00e18d6b707d97faac9407398f1","constraints":{"executionContext":"node"},"contract":["picomatch creates compiled matcher functions supporting wildcards, brace expansions, and negated patterns","picomatch.isMatch evaluates paths against glob patterns with support for case-insensitivity, dotfiles, and ignore rules","picomatch.scan parses glob patterns into components including static base directory, glob portion, and isGlob metadata","picomatch.makeRe compiles glob patterns into RegExp instances for regular expression matching"],"goal":"verify pkg:npm/picomatch@2.3.2","kind":"HOW","packages":["pkg:npm/picomatch@2.3.2"],"schemaVersion":1},"contractCommand":["node","test/contract.js"],"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/picomatch@2.3.2"],"schemaVersion":1,"subject":"pkg:npm/picomatch@2.3.2","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "picomatch-sample",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "picomatch-sample",
      "version": "1.0.0",
      "dependencies": {
        "picomatch": "2.3.2"
      }
    },
    "node_modules/picomatch": {
      "version": "2.3.2",
      "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.2.tgz",
      "integrity": "sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==",
      "license": "MIT",
      "engines": {
        "node": ">=8.6"
      },
      "funding": {
        "url": "https://github.com/sponsors/jonschlinkert"
      }
    }
  }
}
package.json
{
  "name": "picomatch-sample",
  "version": "1.0.0",
  "dependencies": {
    "picomatch": "2.3.2"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/picomatch@2.3.2",
  "kind": "HOW",
  "packages": [
    "pkg:npm/picomatch@2.3.2"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
src/index.js
const picomatch = require('picomatch');

/**
 * Creates a compiled matcher function for one or more glob patterns.
 *
 * @param {string|string[]} patterns - Glob pattern or array of patterns.
 * @param {object} [options] - Picomatch options.
 * @returns {(input: string) => boolean} Matcher function.
 */
function createMatcher(patterns, options) {
  return picomatch(patterns, options);
}

/**
 * Tests whether a path string matches a glob pattern.
 *
 * @param {string} input - Path string to test.
 * @param {string|string[]} patterns - Glob pattern or patterns.
 * @param {object} [options] - Options such as ignore, nocase, dot.
 * @returns {boolean} True if matched.
 */
function matchPath(input, patterns, options) {
  return picomatch.isMatch(input, patterns, options);
}

/**
 * Scans a glob pattern string to extract static base path, glob component, and metadata.
 *
 * @param {string} pattern - Glob pattern to analyze.
 * @param {object} [options] - Scan options.
 * @returns {object} Scan result object.
 */
function scanPattern(pattern, options) {
  return picomatch.scan(pattern, options);
}

/**
 * Compiles a glob pattern into a regular expression.
 *
 * @param {string} pattern - Glob pattern.
 * @param {object} [options] - Regex options.
 * @returns {RegExp} Compiled RegExp.
 */
function compilePattern(pattern, options) {
  return picomatch.makeRe(pattern, options);
}

module.exports = {
  createMatcher,
  matchPath,
  scanPattern,
  compilePattern,
  picomatch,
};
test/contract.js
const assert = require('node:assert/strict');
const {
  createMatcher,
  matchPath,
  scanPattern,
  compilePattern,
} = require('../src/index.js');

// Contract 1: picomatch creates compiled matcher functions supporting wildcards, brace expansions, and negated patterns
{
  const isImage = createMatcher('*.{png,jpg,webp}');
  assert.strictEqual(isImage('photo.jpg'), true, 'Should match jpg via brace expansion');
  assert.strictEqual(isImage('banner.webp'), true, 'Should match webp via brace expansion');
  assert.strictEqual(isImage('vector.svg'), false, 'Should not match non-listed extension');

  const isSource = createMatcher(['src/**/*.js', 'src/**/*.ts']);
  assert.strictEqual(isSource('src/index.js'), true, 'Should match js file in src');
  assert.strictEqual(isSource('src/components/App.ts'), true, 'Should match ts file in nested src');
  assert.strictEqual(isSource('docs/readme.md'), false, 'Should not match md file outside src');

  const notTest = createMatcher('!**/*.test.js');
  assert.strictEqual(notTest('src/index.js'), true, 'Negated pattern matches non-test file');
  assert.strictEqual(notTest('src/index.test.js'), false, 'Negated pattern rejects test file');
}

// Contract 2: picomatch.isMatch evaluates paths against glob patterns with support for case-insensitivity, dotfiles, and ignore rules
{
  assert.strictEqual(matchPath('lib/utils.js', 'lib/*.js'), true, 'Direct match in lib directory');
  assert.strictEqual(matchPath('lib/sub/utils.js', 'lib/*.js'), false, 'Single star should not cross directory boundaries');

  assert.strictEqual(matchPath('README.MD', '*.md', { nocase: true }), true, 'nocase: true allows case-insensitive match');
  assert.strictEqual(matchPath('README.MD', '*.md', { nocase: false }), false, 'nocase: false enforces case sensitivity');

  assert.strictEqual(matchPath('.env', '*.env', { dot: true }), true, 'dot: true matches dotfiles');
  assert.strictEqual(matchPath('.env', '*.env', { dot: false }), false, 'dot: false ignores dotfiles by default');

  assert.strictEqual(
    matchPath('node_modules/pkg/index.js', '**/*.js', { ignore: '**/node_modules/**' }),
    false,
    'ignore option excludes matching paths'
  );
}

// Contract 3: picomatch.scan parses glob patterns into components including static base directory, glob portion, and isGlob metadata
{
  const scanned = scanPattern('src/assets/**/*.svg');
  assert.strictEqual(scanned.base, 'src/assets', 'Base directory before any glob characters');
  assert.strictEqual(scanned.glob, '**/*.svg', 'Glob portion extracted');
  assert.strictEqual(scanned.isGlob, true, 'isGlob should be true for wildcard pattern');

  const staticScan = scanPattern('src/config/settings.json');
  assert.strictEqual(staticScan.base, 'src/config/settings.json', 'Static path base equals full input');
  assert.strictEqual(staticScan.glob, '', 'Static path has empty glob portion');
  assert.strictEqual(staticScan.isGlob, false, 'isGlob should be false for static path');
}

// Contract 4: picomatch.makeRe compiles glob patterns into RegExp instances for regular expression matching
{
  const re = compilePattern('build/*.min.js');
  assert.ok(re instanceof RegExp, 'Should return a RegExp instance');
  assert.strictEqual(re.test('build/app.min.js'), true, 'Compiled regex matches expected target');
  assert.strictEqual(re.test('build/app.js'), false, 'Compiled regex rejects unmatched target');
  assert.strictEqual(re.test('dist/app.min.js'), false, 'Compiled regex respects directory prefix');
}

console.log('All pkg:npm/picomatch@2.3.2 contracts passed successfully.');

Origin Seeder

anonymous