CodeSampleX

サンプル

ci-info 4.3.1

検証済みサンプル — npm ci-info 4.3.1. node 22 · linux alpine/x64 · docker で contract を実行し、成功しました: isCI exports a boolean indicating whether execution is within a…

sha256:838903abc40ea4bedcfc29ea36fd204d20f59d22a3f1a54993f844d148589cd5

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

実行証拠

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

証拠の基準
署名済みコントラクト合格
検証レシート
1
ビルドした署名鍵
1
宣言された環境 linux 24 · ubuntu · glibc 2.39 x64 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-23

ケース

HOW
ゴール
verify pkg:npm/ci-info@4.3.1
パッケージ
作成日
2026-08-23T13:43:22Z

コントラクト

  1. isCI exports a boolean indicating whether execution is within a continuous integration environment
  2. name exports a string or null indicating the detected continuous integration vendor name
  3. isPR exports a boolean or null indicating if a pull request is being tested
  4. id exports a string or null indicating the detected continuous integration vendor constant identifier
  5. vendor constants export boolean flags for specific CI providers including GITHUB_ACTIONS, GITLAB, TRAVIS, and CIRCLE
  6. _vendors exports an array of supported vendor constant identifiers
  7. evaluates environment variables dynamically to detect GitHub Actions CI and pull request state
  8. evaluates environment variables dynamically to detect GitLab CI and merge request state
  9. evaluates environment variables dynamically to detect Travis CI and pull request state
  10. bypasses CI vendor checks and sets isCI to false when CI environment variable is explicitly set to false

ファイル

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

ソースアーティファクトをダウンロード (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/ci-info@4.3.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/ci-info@4.3.1

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:14af9c4865154355589d06223c74cd8aa921e4f73e35fa474e2a898208709f20","contract":["isCI exports a boolean indicating whether execution is within a continuous integration environment","name exports a string or null indicating the detected continuous integration vendor name","isPR exports a boolean or null indicating if a pull request is being tested","id exports a string or null indicating the detected continuous integration vendor constant identifier","vendor constants export boolean flags for specific CI providers including GITHUB_ACTIONS, GITLAB, TRAVIS, and CIRCLE","_vendors exports an array of supported vendor constant identifiers","evaluates environment variables dynamically to detect GitHub Actions CI and pull request state","evaluates environment variables dynamically to detect GitLab CI and merge request state","evaluates environment variables dynamically to detect Travis CI and pull request state","bypasses CI vendor checks and sets isCI to false when CI environment variable is explicitly set to false"],"goal":"verify pkg:npm/ci-info@4.3.1","kind":"HOW","packages":["pkg:npm/ci-info@4.3.1"],"schemaVersion":1},"contractCommand":["node","test/contract.cjs"],"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/ci-info@4.3.1"],"schemaVersion":1,"subject":"pkg:npm/ci-info@4.3.1","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "ci-info-verification",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "ci-info-verification",
      "version": "1.0.0",
      "dependencies": {
        "ci-info": "4.3.1"
      }
    },
    "node_modules/ci-info": {
      "version": "4.3.1",
      "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-4.3.1.tgz",
      "integrity": "sha512-Wdy2Igu8OcBpI2pZePZ5oWjPC38tmDVx5WKUXKwlLYkA0ozo85sLsLvkBbBn/sZaSCMFOGZJ14fvW9t5/d7kdA==",
      "license": "MIT",
      "engines": {
        "node": ">=8"
      }
    }
  }
}
package.json
{
  "name": "ci-info-verification",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification for ci-info",
  "dependencies": {
    "ci-info": "4.3.1"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/ci-info@4.3.1",
  "kind": "HOW",
  "packages": [
    "pkg:npm/ci-info@4.3.1"
  ]
}
test/contract.cjs
const assert = require('node:assert');
const { execFileSync } = require('node:child_process');
const ci = require('ci-info');

// 1. isCI exports a boolean indicating whether execution is within a continuous integration environment
assert.strictEqual(typeof ci.isCI, 'boolean');

// 2. name exports a string or null indicating the detected continuous integration vendor name
assert.ok(ci.name === null || typeof ci.name === 'string');

// 3. isPR exports a boolean or null indicating if a pull request is being tested
assert.ok(ci.isPR === null || typeof ci.isPR === 'boolean');

// 4. id exports a string or null indicating the detected continuous integration vendor constant identifier
assert.ok(ci.id === null || typeof ci.id === 'string');

// 5. vendor constants export boolean flags for specific CI providers including GITHUB_ACTIONS, GITLAB, TRAVIS, and CIRCLE
assert.strictEqual(typeof ci.GITHUB_ACTIONS, 'boolean');
assert.strictEqual(typeof ci.GITLAB, 'boolean');
assert.strictEqual(typeof ci.TRAVIS, 'boolean');
assert.strictEqual(typeof ci.CIRCLE, 'boolean');

// 6. _vendors exports an array of supported vendor constant identifiers
assert.ok(Array.isArray(ci._vendors));
assert.ok(ci._vendors.length > 0);
assert.ok(ci._vendors.includes('GITHUB_ACTIONS'));
assert.ok(ci._vendors.includes('GITLAB'));
assert.ok(ci._vendors.includes('TRAVIS'));
assert.ok(ci._vendors.includes('CIRCLE'));

// 7. evaluates environment variables dynamically to detect GitHub Actions CI and pull request state
const testEnv = (envVars, checkFnStr) => {
  const result = execFileSync(
    process.execPath,
    ['-e', `const ci = require('ci-info'); const fn = ${checkFnStr}; if (!fn(ci)) process.exit(1);`],
    {
      env: {
        ...process.env,
        ...envVars
      }
    }
  );
  assert.ok(result);
};

testEnv(
  { CI: 'true', GITHUB_ACTIONS: 'true', GITHUB_EVENT_NAME: 'pull_request' },
  "(ci) => ci.isCI === true && ci.name === 'GitHub Actions' && ci.id === 'GITHUB_ACTIONS' && ci.GITHUB_ACTIONS === true && ci.isPR === true"
);

// 8. evaluates environment variables dynamically to detect GitLab CI and merge request state
testEnv(
  { CI: 'true', GITLAB_CI: 'true', CI_MERGE_REQUEST_ID: '42' },
  "(ci) => ci.isCI === true && ci.name === 'GitLab CI' && ci.id === 'GITLAB' && ci.GITLAB === true && ci.isPR === true"
);

// 9. evaluates environment variables dynamically to detect Travis CI and pull request state
testEnv(
  { CI: 'true', TRAVIS: 'true', TRAVIS_PULL_REQUEST: '100' },
  "(ci) => ci.isCI === true && ci.name === 'Travis CI' && ci.id === 'TRAVIS' && ci.TRAVIS === true && ci.isPR === true"
);

// 10. bypasses CI vendor checks and sets isCI to false when CI environment variable is explicitly set to false
testEnv(
  { CI: 'false', GITHUB_ACTIONS: 'true', GITLAB_CI: 'true' },
  "(ci) => ci.isCI === false && ci.name === null && ci.id === null && ci.isPR === null"
);

console.log('Contract passed');

オリジンシーダー

匿名