CodeSampleX

Beispiel

esquery 1.7.0

Verifiziertes Beispiel für npm esquery 1.7.0. Der Vertrag lief auf node 22 · linux alpine/x64 · docker und bestand: query finds AST nodes matching a selector…

sha256:e386296310260d8e4d3e443281b2a8fd640157461afd71477dc6cc1f75a6dc0e

Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen. Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen. MIT-0

Ausführungsbelege

Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.

Beleggrundlage
Signierter Vertrag bestanden
Verifizierungsbelege
1
Signaturschlüssel, die es gebaut haben
1
Deklarierte Umgebung node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm

Umgebungen der Verifizierungsläufe

Umgebung Contract Stufen Lauf
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

Fall

HOW
Ziel
verify pkg:npm/esquery@1.7.0
Pakete
Umgebung
node 22.23.2
Erstellt
2026-08-26T08:33:03Z

Contract

  1. query finds AST nodes matching a selector query string
  2. parse parses a selector string into an AST query selector object
  3. match finds AST nodes matching a pre-parsed selector object
  4. matches evaluates whether an individual AST node satisfies a selector object

Dateien

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

Quellartefakt herunterladen (tar.gz)

Quelltext

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/esquery@1.7.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/esquery@1.7.0

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:382e5c810a5ff13a9f6be449f864e71922666685ee4f986405bccb69f22a6fed","contract":["query finds AST nodes matching a selector query string","parse parses a selector string into an AST query selector object","match finds AST nodes matching a pre-parsed selector object","matches evaluates whether an individual AST node satisfies a selector object"],"goal":"verify pkg:npm/esquery@1.7.0","kind":"HOW","packages":["pkg:npm/esquery@1.7.0"],"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","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/esquery@1.7.0"],"schemaVersion":1,"subject":"pkg:npm/esquery@1.7.0","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-esquery",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-esquery",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "esquery": "1.7.0"
      }
    },
    "node_modules/esquery": {
      "version": "1.7.0",
      "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.7.0.tgz",
      "integrity": "sha512-Ap6G0WQwcU/LHsvLwON1fAQX9Zp0A2Y6Y/cJBl9r/JbW90Zyg4/zbG6zzKa2OTALELarYHmKu0GhpM5EO+7T0g==",
      "license": "BSD-3-Clause",
      "dependencies": {
        "estraverse": "^5.1.0"
      },
      "engines": {
        "node": ">=0.10"
      }
    },
    "node_modules/estraverse": {
      "version": "5.3.0",
      "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz",
      "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==",
      "license": "BSD-2-Clause",
      "engines": {
        "node": ">=4.0"
      }
    }
  }
}
package.json
{
  "name": "sample-esquery",
  "version": "1.0.0",
  "type": "module",
  "license": "MIT-0",
  "dependencies": {
    "esquery": "1.7.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/esquery@1.7.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/esquery@1.7.0"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';

const require = createRequire(import.meta.url);
const esquery = require('esquery');

// Simple AST for:
// function greet(name) {
//   let message = "hello";
//   return message;
// }
const ast = {
  type: 'Program',
  body: [
    {
      type: 'FunctionDeclaration',
      id: { type: 'Identifier', name: 'greet' },
      params: [{ type: 'Identifier', name: 'name' }],
      body: {
        type: 'BlockStatement',
        body: [
          {
            type: 'VariableDeclaration',
            kind: 'let',
            declarations: [
              {
                type: 'VariableDeclarator',
                id: { type: 'Identifier', name: 'message' },
                init: { type: 'Literal', value: 'hello', raw: '"hello"' }
              }
            ]
          },
          {
            type: 'ReturnStatement',
            argument: { type: 'Identifier', name: 'message' }
          }
        ]
      }
    }
  ]
};

// 1. query finds AST nodes matching a selector query string
const identifiers = esquery(ast, 'Identifier');
assert.equal(identifiers.length, 4);
assert.deepEqual(identifiers.map((node) => node.name), ['greet', 'name', 'message', 'message']);

const letDeclarations = esquery.query(ast, 'VariableDeclaration[kind="let"]');
assert.equal(letDeclarations.length, 1);
assert.equal(letDeclarations[0].kind, 'let');

// 2. parse parses a selector string into an AST query selector object
const selector = esquery.parse('FunctionDeclaration > BlockStatement');
assert.equal(typeof selector, 'object');
assert.equal(selector.type, 'child');
assert.equal(selector.left.type, 'identifier');
assert.equal(selector.left.value, 'FunctionDeclaration');
assert.equal(selector.right.type, 'identifier');
assert.equal(selector.right.value, 'BlockStatement');

// 3. match finds AST nodes matching a pre-parsed selector object
const matchedBlocks = esquery.match(ast, selector);
assert.equal(matchedBlocks.length, 1);
assert.equal(matchedBlocks[0].type, 'BlockStatement');

// 4. matches evaluates whether an individual AST node satisfies a selector object
const funcNode = ast.body[0];
const isFunction = esquery.matches(funcNode, esquery.parse('FunctionDeclaration'));
assert.equal(isFunction, true);

const isVariable = esquery.matches(funcNode, esquery.parse('VariableDeclaration'));
assert.equal(isVariable, false);

Ursprungs-Seeder

anonym