CodeSampleX

Sample

minimatch 9.0.9

Verified sample for npm minimatch 9.0.9. The contract ran on node 22 · linux alpine/x64 · docker and passed: matchPath tests file paths against glob patterns…

sha256:bd6d3e054d0c0e5105ccbace0b3714afa38ef995cd3aecfb209526468b51bf15

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@1
2026-08-21

Case

HOW
Goal
verify pkg:npm/minimatch@9.0.9
Packages
Environment
node 22.23.2
Created
2026-08-21T03:55:20Z

Contract

  1. matchPath tests file paths against glob patterns with wildcards, single character matches, and character classes
  2. createFilter generates a predicate function for filtering path arrays with glob patterns
  3. matchFiles filters an array of paths matching a glob pattern directly
  4. globToRegex converts glob patterns into RegExp instances for pattern matching
  5. Minimatch class instantiates glob matchers with match and hasMagic methods
  6. expandBraces expands brace alternative patterns into multiple glob combinations
  7. escapeGlob and unescapeGlob escape and unescape glob magic characters
  8. matchPath supports dot, nocase, and matchBase options for specialized glob matching

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 pkg:npm/minimatch@9.0.9
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/minimatch@9.0.9
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:61837f036038392e784f8fdd478f2b225c8dfa356554543638bbfef3633f0627","constraints":{"executionContext":"node"},"contract":["matchPath tests file paths against glob patterns with wildcards, single character matches, and character classes","createFilter generates a predicate function for filtering path arrays with glob patterns","matchFiles filters an array of paths matching a glob pattern directly","globToRegex converts glob patterns into RegExp instances for pattern matching","Minimatch class instantiates glob matchers with match and hasMagic methods","expandBraces expands brace alternative patterns into multiple glob combinations","escapeGlob and unescapeGlob escape and unescape glob magic characters","matchPath supports dot, nocase, and matchBase options for specialized glob matching"],"goal":"verify pkg:npm/minimatch@9.0.9","kind":"HOW","packages":["pkg:npm/minimatch@9.0.9"],"schemaVersion":1},"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/minimatch@9.0.9"],"schemaVersion":1,"subject":"pkg:npm/minimatch@9.0.9","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-minimatch",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-minimatch",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "minimatch": "9.0.9"
      }
    },
    "node_modules/balanced-match": {
      "version": "1.0.2",
      "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
      "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
      "license": "MIT"
    },
    "node_modules/brace-expansion": {
      "version": "2.1.4",
      "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.4.tgz",
      "integrity": "sha512-hGfVzPxthbf3+2yjg/RBs60cB0FhqBS/zvdV/4wn4/BmN0bNMMHPc4V/BbFieqf1TKAGGAHnY4eSjajCl0f2Xg==",
      "license": "MIT",
      "dependencies": {
        "balanced-match": "^1.0.0"
      }
    },
    "node_modules/minimatch": {
      "version": "9.0.9",
      "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.9.tgz",
      "integrity": "sha512-OBwBN9AL4dqmETlpS2zasx+vTeWclWzkblfZk7KTA5j3jeOONz/tRCnZomUyvNg83wL5Zv9Ss6HMJXAgL8R2Yg==",
      "license": "ISC",
      "dependencies": {
        "brace-expansion": "^2.0.2"
      },
      "engines": {
        "node": ">=16 || 14 >=14.17"
      },
      "funding": {
        "url": "https://github.com/sponsors/isaacs"
      }
    }
  }
}
package.json
{
  "name": "sample-minimatch",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification of minimatch",
  "main": "src/index.js",
  "license": "MIT-0",
  "dependencies": {
    "minimatch": "9.0.9"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/minimatch@9.0.9",
  "kind": "HOW",
  "packages": [
    "pkg:npm/minimatch@9.0.9"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
src/index.js
'use strict';

const minimatchPkg = require('minimatch');
const minimatch = typeof minimatchPkg === 'function' ? minimatchPkg : minimatchPkg.minimatch;
const {
  filter = minimatch.filter,
  match = minimatch.match,
  makeRe = minimatch.makeRe,
  braceExpand = minimatch.braceExpand,
  escape = minimatch.escape,
  unescape = minimatch.unescape,
  Minimatch = minimatch.Minimatch
} = minimatchPkg;

/**
 * Tests whether a path string matches a glob pattern.
 * @param {string} p - File path to test
 * @param {string} pattern - Glob pattern
 * @param {object} [options] - Matching options
 * @returns {boolean}
 */
function matchPath(p, pattern, options) {
  return minimatch(p, pattern, options);
}

/**
 * Returns a filter predicate function for arrays.
 * @param {string} pattern - Glob pattern
 * @param {object} [options] - Matching options
 * @returns {Function}
 */
function createFilter(pattern, options) {
  return filter(pattern, options);
}

/**
 * Filters a list of path strings matching a pattern.
 * @param {string[]} list - Array of path strings
 * @param {string} pattern - Glob pattern
 * @param {object} [options] - Matching options
 * @returns {string[]}
 */
function matchFiles(list, pattern, options) {
  return match(list, pattern, options);
}

/**
 * Converts a glob pattern into a regular expression.
 * @param {string} pattern - Glob pattern
 * @param {object} [options] - Matching options
 * @returns {RegExp|null}
 */
function globToRegex(pattern, options) {
  return makeRe(pattern, options);
}

/**
 * Expands brace patterns into an array of glob strings.
 * @param {string} pattern - Glob pattern containing braces
 * @param {object} [options] - Matching options
 * @returns {string[]}
 */
function expandBraces(pattern, options) {
  return braceExpand(pattern, options);
}

/**
 * Escapes glob magic characters in a string.
 * @param {string} pattern - Glob pattern
 * @returns {string}
 */
function escapeGlob(pattern) {
  return escape(pattern);
}

/**
 * Unescapes glob magic characters in a string.
 * @param {string} pattern - Glob pattern
 * @returns {string}
 */
function unescapeGlob(pattern) {
  return unescape(pattern);
}

/**
 * Creates a Minimatch class instance for compiled glob operations.
 * @param {string} pattern - Glob pattern
 * @param {object} [options] - Matching options
 * @returns {Minimatch}
 */
function createMinimatch(pattern, options) {
  return new Minimatch(pattern, options);
}

module.exports = {
  minimatch,
  Minimatch,
  matchPath,
  createFilter,
  matchFiles,
  globToRegex,
  expandBraces,
  escapeGlob,
  unescapeGlob,
  createMinimatch
};
test/contract.mjs
import assert from 'node:assert';
import { createRequire } from 'node:module';

const require = createRequire(import.meta.url);
const {
  minimatch,
  Minimatch,
  matchPath,
  createFilter,
  matchFiles,
  globToRegex,
  expandBraces,
  escapeGlob,
  unescapeGlob,
  createMinimatch
} = require('../src/index.js');

// 1. Direct glob matching with wildcards, single character matches, and character classes
assert.strictEqual(matchPath('file.txt', '*.txt'), true, '*.txt matches file.txt');
assert.strictEqual(matchPath('file.js', '*.txt'), false, '*.txt does not match file.js');
assert.strictEqual(matchPath('foo1.js', 'foo?.js'), true, 'foo?.js matches foo1.js');
assert.strictEqual(matchPath('foo12.js', 'foo?.js'), false, 'foo?.js does not match foo12.js');
assert.strictEqual(matchPath('file3.txt', 'file[0-9].txt'), true, 'character class [0-9] matches 3');
assert.strictEqual(matchPath('fileA.txt', 'file[0-9].txt'), false, 'character class [0-9] rejects A');

// 2. filter creates a predicate function for Array.prototype.filter
const fileList = ['src/a.ts', 'src/b.js', 'test/a.test.js', 'package.json'];
const jsFilter = createFilter('**/*.js');
assert.deepStrictEqual(fileList.filter(jsFilter), ['src/b.js', 'test/a.test.js'], 'filter should filter matching paths');

// 3. match filters an array of strings directly
const matchedJson = matchFiles(fileList, '*.json');
assert.deepStrictEqual(matchedJson, ['package.json'], 'matchFiles should filter top-level json file');

// 4. makeRe converts glob pattern into a regular expression
const re = globToRegex('*.spec.js');
assert.ok(re instanceof RegExp, 'makeRe must return a RegExp instance');
assert.strictEqual(re.test('index.spec.js'), true, 'makeRe RegExp matches index.spec.js');
assert.strictEqual(re.test('index.js'), false, 'makeRe RegExp rejects index.js');

// 5. Minimatch class instantiation and match method
const mm = createMinimatch('src/**/*.ts');
assert.strictEqual(mm.match('src/components/Button.ts'), true, 'Minimatch instance matches nested ts file');
assert.strictEqual(mm.match('dist/index.js'), false, 'Minimatch instance rejects dist/index.js');
assert.strictEqual(mm.hasMagic(), true, 'hasMagic returns true for glob pattern');

// 6. braceExpand expands brace patterns into multiple glob strings
const expanded = expandBraces('{src,test}/**/*.{js,ts}');
assert.deepStrictEqual(
  expanded,
  ['src/**/*.js', 'src/**/*.ts', 'test/**/*.js', 'test/**/*.ts'],
  'expandBraces expands brace options'
);

// 7. escape and unescape handle glob special characters
const escaped = escapeGlob('hello*[world]?');
assert.strictEqual(escaped, 'hello\\*\\[world\\]\\?', 'escape backslashes special glob characters');
const unescaped = unescapeGlob('hello\\[world\\]');
assert.strictEqual(unescaped, 'hello[world]', 'unescape unescapes bracket characters');

// 8. Pattern matching options: dot, nocase, and matchBase
assert.strictEqual(matchPath('.env', '*.env'), false, 'dotfiles not matched by default wildcard');
assert.strictEqual(matchPath('.env', '*.env', { dot: true }), true, 'dot:true matches dotfiles');
assert.strictEqual(matchPath('README.MD', '*.md'), false, 'case-sensitive by default');
assert.strictEqual(matchPath('README.MD', '*.md', { nocase: true }), true, 'nocase:true ignores case');
assert.strictEqual(matchPath('nested/dir/app.js', '*.js', { matchBase: true }), true, 'matchBase matches filename in subdirectories');

console.log('Contract tests passed successfully.');

Origin Seeder

anonymous