CodeSampleX

示例

@openai/codex 0.149.1

已验证示例 — npm @openai/codex 0.149.1. contract 在 node 22 · linux debian/x64 · docker 上运行并通过: @openai/codex package manifest defines version 0.149.1 and…

sha256:a53be5ed5f64af28895f1d9f20d7e3b214d8a4865540732bc6bd22d735dac946

本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。 提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。 MIT-0

执行证据

声明的环境与签名的运行分开呈现,你可以看到这个样本究竟运行了什么、在哪里运行。

证据依据
签名契约通过
验证回执
2
构建过它的签名密钥
1
声明的环境 node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

验证运行环境

环境 契约 阶段 运行日期
node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 SKIPPED compile:SKIPPED · contract:SKIPPED · load:SKIPPED · resolve:FAIL
CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2…
2026-09-08
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-08

案例

HOW
目标
verify pkg:npm/%40openai/codex@0.149.1
包
环境
node 22.23.2
创建时间
2026-09-07T16:39:03Z

契约

  1. @openai/codex package manifest defines version 0.149.1 and executable bin mapping for codex
  2. direct import of @openai/codex fails confirming CLI distribution without library export
  3. executing codex CLI with --version flag prints codex-cli version matching 0.149.1
  4. executing codex CLI with --help flag displays usage options and subcommand reference

文件

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • src/index.js
  • 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/%40openai/codex@0.149.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40openai/codex@0.149.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:c7628393cab5d1ec7d8126f5648bf242aaecdbdd324b8594a1fe6e1fbe6b508b","contract":["@openai/codex package manifest defines version 0.149.1 and executable bin mapping for codex","direct import of @openai/codex fails confirming CLI distribution without library export","executing codex CLI with --version flag prints codex-cli version matching 0.149.1","executing codex CLI with --help flag displays usage options and subcommand reference"],"goal":"verify pkg:npm/%40openai/codex@0.149.1","kind":"HOW","packages":["pkg:npm/%40openai/codex@0.149.1"],"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/%40openai/codex@0.149.1"],"schemaVersion":1,"subject":"pkg:npm/%40openai/codex@0.149.1","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-openai-codex",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-openai-codex",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "@openai/codex": "0.149.1"
      }
    },
    "node_modules/@openai/codex": {
      "version": "0.149.1",
      "resolved": "https://registry.npmjs.org/@openai/codex/-/codex-0.149.1.tgz",
      "integrity": "sha512-6q5pbcpFbJbqOpkubSDBwXmktQ55aD8eUzGzBF1zASob2DjwhBKDSNGtdZKalfrNJUdTDTPDMmzCXEXs5tMBYA==",
      "license": "Apache-2.0",
      "bin": {
        "codex": "bin/codex.js"
      },
      "engines": {
        "node": ">=16"
      },
      "optionalDependencies": {
        "@openai/codex-darwin-arm64": "npm:@openai/codex@0.149.1-darwin-arm64",
        "@openai/codex-darwin-x64": "npm:@openai/codex@0.149.1-darwin-x64",
        "@openai/codex-linux-arm64": "npm:@openai/codex@0.149.1-linux-arm64",
        "@openai/codex-linux-x64": "npm:@openai/codex@0.149.1-linux-x64",
        "@openai/codex-win32-arm64": "npm:@openai/codex@0.149.1-win32-arm64",
        "@openai/codex-win32-x64": "npm:@openai/codex@0.149.1-win32-x64"
      }
    },
    "node_modules/@openai/codex-darwin-arm64": {
      "name": "@openai/codex",
      "version": "0.149.1-darwin-arm64",
      "resolved": "https://registry.npmjs.org/@openai/codex/-/codex-0.149.1-darwin-arm64.tgz",
      "integrity": "sha512-6X84kTCbnTgPIJ2EdcPsrvwS0Wxsqpa+bCswGmRf4BjhcQ5nPMnBC6yCAaCMj+vrbXQHj+L6sa9FaR4QkmA1qw==",
      "cpu": [
        "arm64"
      ],
      "license": "Apache-2.0",
      "optional": true,
      "os": [
        "darwin"
      ],
      "engines": {
        "node": ">=16"
      }
    },
    "node_modules/@openai/codex-darwin-x64": {
      "name": "@openai/codex",
      "version": "0.149.1-darwin-x64",
      "resolved": "https://registry.npmjs.org/@openai/codex/-/codex-0.149.1-darwin-x64.tgz",
      "integrity": "sha512-MfLBQLfcElJL9tvj6y45qVHHMGSXCPnQOixuD3/Zq0g1BW/eFizkrGLdn48cFpc+l8cK+gt5nYG5pQYwVs6g4A==",
      "cpu": [
        "x64"
      ],
      "license": "Apache-2.0",
      "optional": true,
      "os": [
        "darwin"
      ],
      "engines": {
        "node": ">=16"
      }
    },
    "node_modules/@openai/codex-linux-arm64": {
      "name": "@openai/codex",
      "version": "0.149.1-linux-arm64",
      "resolved": "https://registry.npmjs.org/@openai/codex/-/codex-0.149.1-linux-arm64.tgz",
      "integrity": "sha512-OqxUfZ1TVvHd18zHPKK/8ZRlpk8Vy11mg5CMHaLxNWldTbwVImDKtSLWT+m8m4NM5Sz4PbjtZMrVT/RfpBW/mQ==",
      "cpu": [
        "arm64"
      ],
      "license": "Apache-2.0",
      "optional": true,
      "os": [
        "linux"
      ],
      "engines": {
        "node": ">=16"
      }
    },
    "node_modules/@openai/codex-linux-x64": {
      "name": "@openai/codex",
      "version": "0.149.1-linux-x64",
      "resolved": "https://registry.npmjs.org/@openai/codex/-/codex-0.149.1-linux-x64.tgz",
      "integrity": "sha512-Of5fGYgr7tAMsyj6vhXb4/RM/UoA3Zq8BLegUBDC09UNy1XTLGYP/2XD+UX8z3qh0NDwxYdCjFIWdDNijKZggQ==",
      "cpu": [
        "x64"
      ],
      "license": "Apache-2.0",
      "optional": true,
      "os": [
        "linux"
      ],
      "engines": {
        "node": ">=16"
      }
    },
    "node_modules/@openai/codex-win32-arm64": {
      "name": "@openai/codex",
      "version": "0.149.1-win32-arm64",
      "resolved": "https://registry.npmjs.org/@openai/codex/-/codex-0.149.1-win32-arm64.tgz",
      "integrity": "sha512-5K0DmOKGK9Bos627p8sK8ATHjovPK0sDyT6h9Cb+4v+5CW5SGw1HLgjGxoLfJ8g3cg6mtg/pRCXXo2L/j71UVA==",
      "cpu": [
        "arm64"
      ],
      "license": "Apache-2.0",
      "optional": true,
      "os": [
        "win32"
      ],
      "engines": {
        "node": ">=16"
      }
    },
    "node_modules/@openai/codex-win32-x64": {
      "name": "@openai/codex",
      "version": "0.149.1-win32-x64",
      "resolved": "https://registry.npmjs.org/@openai/codex/-/codex-0.149.1-win32-x64.tgz",
      "integrity": "sha512-G3QXGAg7nyyhqOeooAMUekBCeHd8a1QByhKcVAFyzNBaI06t6Ft7nsF+1SzFS0spuIdU4YyMi5YD26ukADBQUQ==",
      "cpu": [
        "x64"
      ],
      "license": "Apache-2.0",
      "optional": true,
      "os": [
        "win32"
      ],
      "engines": {
        "node": ">=16"
      }
    }
  }
}
package.json
{
  "name": "sample-openai-codex",
  "version": "1.0.0",
  "private": true,
  "description": "verify pkg:npm/%40openai/codex@0.149.1",
  "main": "src/index.js",
  "license": "MIT-0",
  "dependencies": {
    "@openai/codex": "0.149.1"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/%40openai/codex@0.149.1",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40openai/codex@0.149.1"
  ]
}
src/index.js
const { execFileSync } = require('node:child_process');
const fs = require('node:fs');
const path = require('node:path');

/**
 * Reads and returns the package.json manifest of the installed @openai/codex package.
 * @returns {object} The parsed package.json object.
 */
function getPackageManifest() {
  const manifestPath = require.resolve('@openai/codex/package.json');
  const content = fs.readFileSync(manifestPath, 'utf8');
  return JSON.parse(content);
}

/**
 * Resolves the path to the codex binary entry script.
 * @returns {string} Absolute path to bin/codex.js.
 */
function getCodexBinPath() {
  const manifest = getPackageManifest();
  const manifestDir = path.dirname(require.resolve('@openai/codex/package.json'));
  const binRelative = manifest.bin && manifest.bin.codex ? manifest.bin.codex : 'bin/codex.js';
  return path.resolve(manifestDir, binRelative);
}

/**
 * Runs the codex CLI with the specified arguments and returns stdout as a string.
 * @param {string[]} args Array of command-line arguments to pass to codex.
 * @returns {string} The standard output from the execution.
 */
function runCodex(args = []) {
  const binPath = getCodexBinPath();
  return execFileSync(process.execPath, [binPath, ...args], {
    encoding: 'utf8',
    env: { ...process.env },
  });
}

/**
 * Gets the version string reported by `codex --version`.
 * @returns {string} Trimmed version output (e.g. "codex-cli 0.149.1").
 */
function getCodexVersion() {
  return runCodex(['--version']).trim();
}

/**
 * Gets the help text reported by `codex --help`.
 * @returns {string} Help output from codex.
 */
function getCodexHelp() {
  return runCodex(['--help']);
}

module.exports = {
  getPackageManifest,
  getCodexBinPath,
  runCodex,
  getCodexVersion,
  getCodexHelp,
};
test/contract.mjs
import assert from 'node:assert';
import { createRequire } from 'node:module';
import fs from 'node:fs';

const require = createRequire(import.meta.url);
const {
  getPackageManifest,
  getCodexBinPath,
  runCodex,
  getCodexVersion,
  getCodexHelp,
} = require('../src/index.js');

// 1. @openai/codex package manifest defines version 0.149.1 and executable bin mapping for codex
const manifest = getPackageManifest();
assert.strictEqual(manifest.name, '@openai/codex', 'package name must be @openai/codex');
assert.strictEqual(manifest.version, '0.149.1', 'package version must be 0.149.1');
assert.ok(manifest.bin && typeof manifest.bin.codex === 'string', 'bin.codex must be defined');
assert.strictEqual(manifest.bin.codex, 'bin/codex.js', 'bin.codex must point to bin/codex.js');

const binPath = getCodexBinPath();
assert.ok(fs.existsSync(binPath), 'codex bin script file must exist on disk');

// 2. direct import of @openai/codex fails confirming CLI distribution without library export
assert.throws(
  () => {
    require('@openai/codex');
  },
  {
    code: 'MODULE_NOT_FOUND',
  },
  'direct require of @openai/codex should fail with MODULE_NOT_FOUND'
);

// 3. executing codex CLI with --version flag prints codex-cli version matching 0.149.1
const versionOutput = getCodexVersion();
assert.strictEqual(versionOutput, 'codex-cli 0.149.1', 'version output must match codex-cli 0.149.1');

// 4. executing codex CLI with --help flag displays usage options and subcommand reference
const helpOutput = getCodexHelp();
assert.ok(helpOutput.includes('Usage: codex [OPTIONS]'), 'help output must contain Usage: codex');
assert.ok(helpOutput.includes('--version'), 'help output must document --version');
assert.ok(helpOutput.includes('--help'), 'help output must document --help');

console.log('All contract tests passed.');

原始种子者

匿名