CodeSampleX

サンプル

esquery 1.7.0

検証済みサンプル — npm esquery 1.7.0. node 22 · linux alpine/x64 · docker で contract を実行し、成功しました: query finds AST nodes matching a selector query string

sha256:e386296310260d8e4d3e443281b2a8fd640157461afd71477dc6cc1f75a6dc0e

このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。 合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。 MIT-0

実行証拠

宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。

証拠の基準
署名済みコントラクト合格
検証レシート
1
ビルドした署名鍵
1
宣言された環境 node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm

検証実行環境

環境 コントラクト ステージ 実行日
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

ケース

HOW
ゴール
verify pkg:npm/esquery@1.7.0
パッケージ
環境
node 22.23.2
作成日
2026-08-26T08:33:03Z

コントラクト

  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

ファイル

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

ソースアーティファクトをダウンロード (tar.gz)

ソース

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

オリジンシーダー

匿名