CodeSampleX

Sample

picomatch 4.0.5: Extract static base directory and glob pattern with picomatch.scan

Verified sample for npm picomatch 4.0.5: Extract static base directory and glob pattern with picomatch.scan. The contract ran on node 22 · linux alpine/x64 …

sha256:bacef5a3d6f663eaded7944b5fee59400273ba81c844446f242d92fcf2f5f097

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
2
Signing keys that built it
1
Declared environment linux 24 · ubuntu · glibc 2.39 x64 npm

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

Case

HOW
Goal
Extract static base directory and glob pattern with picomatch.scan
Packages
Symbols
  • picomatch.scan
Created
2026-08-26T09:41:26Z

Contract

  1. assert picomatch.scan('src/components/button.tsx').isGlob is false
  2. assert picomatch.scan('src/components/button.tsx').base is 'src/components/button.tsx'
  3. assert picomatch.scan('src/components/**/*.tsx').isGlob is true
  4. assert picomatch.scan('src/components/**/*.tsx').base is 'src/components'
  5. assert picomatch.scan('src/components/**/*.tsx').glob is '**/*.tsx'
  6. assert picomatch.scan('!dist/**/*.js').negated is true
  7. assert picomatch.scan('!dist/**/*.js').prefix is '!'
  8. assert picomatch.scan('!dist/**/*.js').base is 'dist'
  9. assert picomatch.scan('./lib/*.js').prefix is './'
  10. assert picomatch.scan('./lib/*.js').base is 'lib'

Files

  • NOTES.md
  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • test/contract.mjs

Download the source artifact (tar.gz)

Source

NOTES.md
# Picomatch Scan API Notes

`picomatch.scan(pattern, options)` parses a glob pattern and splits it into structural components:
- `base`: The non-glob base path prefix up to the first glob magic character.
- `glob`: The glob pattern segment following the static base path.
- `isGlob`: Boolean indicating whether glob characters were found in the pattern.
- `negated`: Boolean indicating whether the pattern begins with `!`.
- `prefix`: Leading prefix (such as `./` or `!`).

A common pitfall is expecting `./lib/*.js` to have `base: './lib'`, whereas `scan` extracts `./` into `prefix: './'` and leaves `base: 'lib'`.
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: Extract static base directory and glob pattern with picomatch.scan
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/picomatch@4.0.5
Demonstrate these symbols/APIs:
  - picomatch.scan

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:9001f087d7dfa825427f0dd07b8ddf7135c97c1c192ed7e55ddfb85c1b0cbf8a","contract":["assert picomatch.scan('src/components/button.tsx').isGlob is false","assert picomatch.scan('src/components/button.tsx').base is 'src/components/button.tsx'","assert picomatch.scan('src/components/**/*.tsx').isGlob is true","assert picomatch.scan('src/components/**/*.tsx').base is 'src/components'","assert picomatch.scan('src/components/**/*.tsx').glob is '**/*.tsx'","assert picomatch.scan('!dist/**/*.js').negated is true","assert picomatch.scan('!dist/**/*.js').prefix is '!'","assert picomatch.scan('!dist/**/*.js').base is 'dist'","assert picomatch.scan('./lib/*.js').prefix is './'","assert picomatch.scan('./lib/*.js').base is 'lib'"],"goal":"Extract static base directory and glob pattern with picomatch.scan","kind":"HOW","packages":["pkg:npm/picomatch@4.0.5"],"schemaVersion":1,"symbols":["picomatch.scan"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/picomatch@4.0.5"],"schemaVersion":1,"subject":"pkg:npm/picomatch@4.0.5","symbols":["picomatch.scan"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "npm-picomatch-api",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "npm-picomatch-api",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "picomatch": "4.0.5"
      }
    },
    "node_modules/picomatch": {
      "version": "4.0.5",
      "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.5.tgz",
      "integrity": "sha512-RvwwcruNjI1ncT5xRakeyS9Lf8lcItv34KD+aif+VH9kduAyfYBipGh12274xtenIPZ119/R9BdTBa8gAwSh0A==",
      "license": "MIT",
      "engines": {
        "node": ">=12"
      },
      "funding": {
        "url": "https://github.com/sponsors/jonschlinkert"
      }
    }
  }
}
package.json
{
  "name": "npm-picomatch-api",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "license": "MIT-0",
  "scripts": {
    "test": "node test/contract.mjs"
  },
  "dependencies": {
    "picomatch": "4.0.5"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "Extract static base directory and glob pattern with picomatch.scan",
  "kind": "HOW",
  "packages": [
    "pkg:npm/picomatch@4.0.5"
  ],
  "symbols": [
    "picomatch.scan"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import picomatch from 'picomatch';

// Test 1: Static path without glob magic
const staticPath = picomatch.scan('src/components/button.tsx');
assert.equal(staticPath.isGlob, false);
assert.equal(staticPath.base, 'src/components/button.tsx');
assert.equal(staticPath.glob, '');
assert.equal(staticPath.negated, false);
assert.equal(staticPath.prefix, '');

// Test 2: Standard glob pattern with base directory
const globPattern = picomatch.scan('src/components/**/*.tsx');
assert.equal(globPattern.isGlob, true);
assert.equal(globPattern.base, 'src/components');
assert.equal(globPattern.glob, '**/*.tsx');
assert.equal(globPattern.negated, false);

// Test 3: Negated glob pattern
const negatedPattern = picomatch.scan('!dist/**/*.js');
assert.equal(negatedPattern.isGlob, true);
assert.equal(negatedPattern.negated, true);
assert.equal(negatedPattern.prefix, '!');
assert.equal(negatedPattern.base, 'dist');
assert.equal(negatedPattern.glob, '**/*.js');

// Test 4: Leading './' prefix
const prefixPattern = picomatch.scan('./lib/*.js');
assert.equal(prefixPattern.isGlob, true);
assert.equal(prefixPattern.prefix, './');
assert.equal(prefixPattern.base, 'lib');
assert.equal(prefixPattern.glob, '*.js');

console.log('picomatch.contract.pass');

Origin Seeder

anonymous