CodeSampleX

示例

bare-subprocess 6.1.0: spawn

已验证示例 — npm bare-subprocess 6.1.0: spawn. contract 在 node 22 · linux alpine/x64 · docker 上运行并通过: package manifest specifies Bare addon configuration, Bare…

sha256:917c805c156fa9a5986d0e6a9223a86a462eac13c242a2678e583b33d31c418a

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

案例

HOW
目标
verify pkg:npm/bare-subprocess@6.1.0
包
符号
  • spawn
创建时间
2026-08-27T13:01:36Z

契约

  1. package manifest specifies Bare addon configuration, Bare engine requirement, and exports for root, constants, errors, parent, and package subpaths
  2. bare-subprocess/errors exports SubprocessError class extending Error with static constructors for signal and IPC error conditions
  3. SubprocessJSONFramer encodes and consumes newline-delimited JSON IPC frame payloads
  4. declares spawn, spawnSync, Subprocess, SpawnOptions, and IO stream types in index.d.ts
  5. ships native Bare C addon binding, CMakeLists build configuration, and multi-platform prebuild artifacts

文件

  • 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/bare-subprocess@6.1.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/bare-subprocess@6.1.0
Demonstrate these symbols/APIs:
  - spawn

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:8044281417b647d3c78aa9ccb2c706a08932729bca205b49caa213630fbb0dbc","contract":["package manifest specifies Bare addon configuration, Bare engine requirement, and exports for root, constants, errors, parent, and package subpaths","bare-subprocess/errors exports SubprocessError class extending Error with static constructors for signal and IPC error conditions","SubprocessJSONFramer encodes and consumes newline-delimited JSON IPC frame payloads","declares spawn, spawnSync, Subprocess, SpawnOptions, and IO stream types in index.d.ts","ships native Bare C addon binding, CMakeLists build configuration, and multi-platform prebuild artifacts"],"goal":"verify pkg:npm/bare-subprocess@6.1.0","kind":"HOW","packages":["pkg:npm/bare-subprocess@6.1.0"],"schemaVersion":1,"symbols":["spawn"]},"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/bare-subprocess@6.1.0"],"schemaVersion":1,"subject":"pkg:npm/bare-subprocess@6.1.0","symbols":["spawn"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-bare-subprocess",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-bare-subprocess",
      "version": "1.0.0",
      "dependencies": {
        "bare-subprocess": "6.1.0"
      }
    },
    "node_modules/b4a": {
      "version": "1.8.1",
      "resolved": "https://registry.npmjs.org/b4a/-/b4a-1.8.1.tgz",
      "integrity": "sha512-aiqre1Nr0B/6DgE2N5vwTc+2/oQZ4Wh1t4NznYY4E00y8LCt6NqdRv81so00oo27D8MVKTpUa/MwUUtBLXCoDw==",
      "license": "Apache-2.0",
      "peerDependencies": {
        "react-native-b4a": "*"
      },
      "peerDependenciesMeta": {
        "react-native-b4a": {
          "optional": true
        }
      }
    },
    "node_modules/bare-buffer": {
      "version": "3.7.0",
      "resolved": "https://registry.npmjs.org/bare-buffer/-/bare-buffer-3.7.0.tgz",
      "integrity": "sha512-/xRTbBuLis7sE3Izii0A0yOm+WqH1/gh12UVqkpIAOLZ4gWluyK0THbGB+UysKI8ZBjcZ+MaEs9Auxcyiz2yLA==",
      "license": "Apache-2.0",
      "engines": {
        "bare": ">=1.20.0"
      }
    },
    "node_modules/bare-dns": {
      "version": "2.2.0",
      "resolved": "https://registry.npmjs.org/bare-dns/-/bare-dns-2.2.0.tgz",
      "integrity": "sha512-iEqjj122eXdbDP5gXwk/NG/XVI5xoGjQA24UlGBPafUeMIGesxUZ5rxDvjNXPBHDyTkO+H3IsV5izZ8T5IGAXA==",
      "license": "Apache-2.0",
      "engines": {
        "bare": ">=1.7.0"
      },
      "peerDependencies": {
        "bare-buffer": "*"
      },
      "peerDependenciesMeta": {
        "bare-buffer": {
          "optional": true
        }
      }
    },
    "node_modules/bare-env": {
      "version": "3.0.1",
      "resolved": "https://registry.npmjs.org/bare-env/-/bare-env-3.0.1.tgz",
      "integrity": "sha512-BdoLvnzaWR0YyyJreEx4zG2Od0AC/s9JSZ+EXyMZKunpn8zEgR/dGv37hdFUaY1bjDkcRKvcKkFyJIwlJ0CaYA==",
      "license": "Apache-2.0",
      "dependencies": {
        "bare-os": "^3.0.1"
      }
    },
    "node_modules/bare-events": {
      "version": "2.9.2",
      "resolved": "https://registry.npmjs.org/bare-events/-/bare-events-2.9.2.tgz",
      "integrity": "sha512-AIPKioV7/Y/8KfZ3AAhjPJxLLbY49S64Ym5DakZlUg75qQiTgUq9hEJoEwa4eUezPUlXRy/i5NpsKvo9jgKmoA==",
      "license": "Apache-2.0",
      "peerDependencies": {
        "bare-abort-controller": "*"
      },
      "peerDependenciesMeta": {
        "bare-abort-controller": {
          "optional": true
        }
      }
    },
    "node_modules/bare-os": {
      "version": "3.9.3",
      "resolved": "https://registry.npmjs.org/bare-os/-/bare-os-3.9.3.tgz",
      "integrity": "sha512-fF4Q7QsyKVF5Rj0qvI8BgUNjqzC2JvQlpTaPLjVJVxYVUX5Zr9un+y3w1HmA4nNKdFmRBT8z/WmrjvXzXVerKQ==",
      "license": "Apache-2.0",
      "engines": {
        "bare": ">=1.14.0"
      }
    },
    "node_modules/bare-path": {
      "version": "3.1.1",
      "resolved": "https://registry.npmjs.org/bare-path/-/bare-path-3.1.1.tgz",
      "integrity": "sha512-JprUlveX3QjApC1cTpsUOiscADftCGVWkzitbHsRqv84hzYwYHw2mbluddsq5TvI8mH/8Ov1f4BiMAdcB0oYnQ==",
      "license": "Apache-2.0"
    },
    "node_modules/bare-pipe": {
      "version": "4.2.3",
      "resolved": "https://registry.npmjs.org/bare-pipe/-/bare-pipe-4.2.3.tgz",
      "integrity": "sha512-MJYji+Vy8cNMAB2fwg1WQAm1hFIOe5ojw5V9EhEa/wEEYpKT8c36WjHBDwgkgAZfUSX6wQcEFX+Q7wN09SgRow==",
      "license": "Apache-2.0",
      "dependencies": {
        "bare-events": "^2.0.0",
        "bare-stream": "^2.0.0"
      },
      "engines": {
        "bare": ">=1.16.0"
      }
    },
    "node_modules/bare-stream": {
      "version": "2.13.4",
      "resolved": "https://registry.npmjs.org/bare-stream/-/bare-stream-2.13.4.tgz",
      "integrity": "sha512-PcrQ8lVLbiJscNm1Kez+Yp4Gy4AHGcN1lzwjvf5NybWen7VvEgUfyfnXYJ2zNqWnzOfCb1Abq6lH8ti0syQszA==",
      "license": "Apache-2.0",
      "dependencies": {
        "b4a": "^1.8.1",
        "streamx": "^2.25.0",
        "teex": "^1.0.1"
      },
      "peerDependencies": {
        "bare-abort-controller": "*",
        "bare-buffer": "*",
        "bare-events": "*"
      },
      "peerDependenciesMeta": {
        "bare-abort-controller": {
          "optional": true
        },
        "bare-buffer": {
          "optional": true
        },
        "bare-events": {
          "optional": true
        }
      }
    },
    "node_modules/bare-structured-clone": {
      "version": "1.6.0",
      "resolved": "https://registry.npmjs.org/bare-structured-clone/-/bare-structured-clone-1.6.0.tgz",
      "integrity": "sha512-AZjEERyqF7kAuudlmgrweT2KwwWM0LsGG4Gx/bWyFwJrKU7E3wNG8c09z2DIrdw93p3vDtfOX8fyHOcXfy5m+g==",
      "license": "Apache-2.0",
      "dependencies": {
        "bare-buffer": "^3.6.0",
        "bare-type": "^1.1.0",
        "bare-url": "^2.4.0",
        "compact-encoding": "^3.0.1"
      },
      "engines": {
        "bare": ">=1.2.0"
      }
    },
    "node_modules/bare-subprocess": {
      "version": "6.1.0",
      "resolved": "https://registry.npmjs.org/bare-subprocess/-/bare-subprocess-6.1.0.tgz",
      "integrity": "sha512-8L6KtbmreDy4Fc1BdDqaDo9fg0nbedUmTSFQxYPV0uHIM2BBAX8+E0LyMDKgkk0I+mlKto80WYzOnIhT8VDdOg==",
      "license": "Apache-2.0",
      "dependencies": {
        "bare-env": "^3.0.0",
        "bare-events": "^2.5.4",
        "bare-os": "^3.0.1",
        "bare-pipe": "^4.2.0",
        "bare-structured-clone": "^1.5.2",
        "bare-tcp": "^2.4.1",
        "bare-url": "^2.2.2"
      },
      "engines": {
        "bare": ">=1.7.0"
      },
      "peerDependencies": {
        "bare-buffer": "*"
      },
      "peerDependenciesMeta": {
        "bare-buffer": {
          "optional": true
        }
      }
    },
    "node_modules/bare-tcp": {
      "version": "2.5.4",
      "resolved": "https://registry.npmjs.org/bare-tcp/-/bare-tcp-2.5.4.tgz",
      "integrity": "sha512-o3weBBYeN3tgvTJyglSMpZOfHkfz1nG53M913fvhAKF9ubQ4XsljdX6Uq7H0g/CkyGnR4Ii3OdXJHz7PxgDLGA==",
      "license": "Apache-2.0",
      "dependencies": {
        "bare-dns": "^2.0.4",
        "bare-events": "^2.5.4",
        "bare-stream": "^2.6.4"
      },
      "engines": {
        "bare": ">=1.16.0"
      },
      "peerDependencies": {
        "bare-pipe": "*"
      },
      "peerDependenciesMeta": {
        "bare-pipe": {
          "optional": true
        }
      }
    },
    "node_modules/bare-type": {
      "version": "1.1.0",
      "resolved": "https://registry.npmjs.org/bare-type/-/bare-type-1.1.0.tgz",
      "integrity": "sha512-LdtnnEEYldOc87Dr4GpsKnStStZk3zfgoEMXy8yvEZkXrcCv9RtYDrUYWFsBQHtaB0s1EUWmcvS6XmEZYIj3Bw==",
      "license": "Apache-2.0",
      "engines": {
        "bare": ">=1.2.0"
      }
    },
    "node_modules/bare-url": {
      "version": "2.5.2",
      "resolved": "https://registry.npmjs.org/bare-url/-/bare-url-2.5.2.tgz",
      "integrity": "sha512-L13PCJzKG8RGvx8V1/DdMi12ERhC3tprr7/8a94BxpmnRsFqxh5XZNdhtMxu5HPkRshYOOWRGY8lDP7ZhpG9Cg==",
      "license": "Apache-2.0",
      "dependencies": {
        "bare-path": "^3.0.0"
      }
    },
    "node_modules/compact-encoding": {
      "version": "3.3.2",
      "resolved": "https://registry.npmjs.org/compact-encoding/-/compact-encoding-3.3.2.tgz",
      "integrity": "sha512-bgZ84oVSzjQmVHXBYWON+wQUkdVflrr8fM5+0X6UwQHZyzolsGIkdsjNK3vLLn22dhdASGFz5mS6Lf7rfrPdlg==",
      "license": "Apache-2.0",
      "dependencies": {
        "b4a": "^1.3.0"
      }
    },
    "node_modules/events-universal": {
      "version": "1.0.1",
      "resolved": "https://registry.npmjs.org/events-universal/-/events-universal-1.0.1.tgz",
      "integrity": "sha512-LUd5euvbMLpwOF8m6ivPCbhQeSiYVNb8Vs0fQ8QjXo0JTkEHpz8pxdQf0gStltaPpw0Cca8b39KxvK9cfKRiAw==",
      "license": "Apache-2.0",
      "dependencies": {
        "bare-events": "^2.7.0"
      }
    },
    "node_modules/fast-fifo": {
      "version": "1.3.2",
      "resolved": "https://registry.npmjs.org/fast-fifo/-/fast-fifo-1.3.2.tgz",
      "integrity": "sha512-/d9sfos4yxzpwkDkuN7k2SqFKtYNmCTzgfEpz82x34IM9/zc8KGxQoXg1liNC/izpRM/MBdt44Nmx41ZWqk+FQ==",
      "license": "MIT"
    },
    "node_modules/streamx": {
      "version": "2.28.1",
      "resolved": "https://registry.npmjs.org/streamx/-/streamx-2.28.1.tgz",
      "integrity": "sha512-zEzXb0s5Cds7tqMH6rhZ05lcJydCWiQPEwiNngVqzsxCc962vLY4Uw+mW7od8kDH258k2Uz/JrOkdIAAhSh9VA==",
      "license": "MIT",
      "dependencies": {
        "events-universal": "^1.0.0",
        "fast-fifo": "^1.3.2",
        "text-decoder": "^1.1.0"
      }
    },
    "node_modules/teex": {
      "version": "1.0.1",
      "resolved": "https://registry.npmjs.org/teex/-/teex-1.0.1.tgz",
      "integrity": "sha512-eYE6iEI62Ni1H8oIa7KlDU6uQBtqr4Eajni3wX7rpfXD8ysFx8z0+dri+KWEPWpBsxXfxu58x/0jvTVT1ekOSg==",
      "license": "MIT",
      "dependencies": {
        "streamx": "^2.12.5"
      }
    },
    "node_modules/text-decoder": {
      "version": "1.2.7",
      "resolved": "https://registry.npmjs.org/text-decoder/-/text-decoder-1.2.7.tgz",
      "integrity": "sha512-vlLytXkeP4xvEq2otHeJfSQIRyWxo/oZGEbXrtEEF9Hnmrdly59sUbzZ/QgyWuLYHctCHxFF4tRQZNQ9k60ExQ==",
      "license": "Apache-2.0",
      "dependencies": {
        "b4a": "^1.6.4"
      }
    }
  }
}
package.json
{
  "name": "sample-bare-subprocess",
  "version": "1.0.0",
  "type": "module",
  "private": true,
  "dependencies": {
    "bare-subprocess": "6.1.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/bare-subprocess@6.1.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/bare-subprocess@6.1.0"
  ],
  "symbols": [
    "spawn"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';
import fs from 'node:fs';
import path from 'node:path';

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

// 1. Package manifest verification
const pkgPath = require.resolve('bare-subprocess/package');
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));

assert.equal(pkg.name, 'bare-subprocess', 'Package name must be bare-subprocess');
assert.equal(pkg.version, '6.1.0', 'Package version must be 6.1.0');
assert.equal(pkg.license, 'Apache-2.0', 'Package license must be Apache-2.0');
assert.equal(pkg.addon, true, 'Package must specify addon: true');
assert.equal(pkg.engines?.bare, '>=1.7.0', 'Package must require bare >=1.7.0');

assert.ok(pkg.exports, 'Package must define export map');
assert.equal(pkg.exports['.'].types, './index.d.ts');
assert.equal(pkg.exports['.'].default, './index.js');
assert.equal(pkg.exports['./constants'].types, './lib/constants.d.ts');
assert.equal(pkg.exports['./constants'].default, './lib/constants.js');
assert.equal(pkg.exports['./errors'].types, './lib/errors.d.ts');
assert.equal(pkg.exports['./errors'].default, './lib/errors.js');
assert.equal(pkg.exports['./parent'].types, './lib/parent.d.ts');
assert.equal(pkg.exports['./parent'].default, './lib/parent.js');
assert.equal(pkg.exports['./package'], './package.json');

// 2. Errors submodule
const SubprocessError = require('bare-subprocess/errors');
assert.equal(typeof SubprocessError, 'function', 'SubprocessError must be exported');
assert.ok(SubprocessError.prototype instanceof Error, 'SubprocessError must extend Error');

const errUnknownSig = SubprocessError.UNKNOWN_SIGNAL('Invalid signal 999');
assert.ok(errUnknownSig instanceof SubprocessError);
assert.equal(errUnknownSig.name, 'SubprocessError');
assert.equal(errUnknownSig.code, 'UNKNOWN_SIGNAL');
assert.equal(errUnknownSig.message, 'UNKNOWN_SIGNAL: Invalid signal 999');

const errNoIpc = SubprocessError.NO_IPC_CHANNEL('BARE_CHANNEL_FD missing');
assert.equal(errNoIpc.code, 'NO_IPC_CHANNEL');

const errDisconnected = SubprocessError.CHANNEL_DISCONNECTED('IPC disconnected');
assert.equal(errDisconnected.code, 'CHANNEL_DISCONNECTED');

const errAlreadyDefined = SubprocessError.IPC_CHANNEL_ALREADY_DEFINED('Channel active');
assert.equal(errAlreadyDefined.code, 'IPC_CHANNEL_ALREADY_DEFINED');

const errTooLarge = SubprocessError.MESSAGE_TOO_LARGE('Payload too large');
assert.equal(errTooLarge.code, 'MESSAGE_TOO_LARGE');

const errUnknownMode = SubprocessError.UNKNOWN_SERIALIZATION_MODE('unknown mode');
assert.equal(errUnknownMode.code, 'UNKNOWN_SERIALIZATION_MODE');

// 3. JSON framer functionality
const pkgDir = path.dirname(pkgPath);
const JSONFramer = require(path.join(pkgDir, 'lib', 'framers', 'json.js'));
const framer = new JSONFramer();
const encoded = framer.encode({ action: 'ping', payload: 42 });
assert.ok(Buffer.isBuffer(encoded), 'encode must return Buffer');
assert.equal(encoded.toString('utf8'), '{"action":"ping","payload":42}\n');

let parsedMessage = null;
framer.push(encoded, (msg) => {
  parsedMessage = msg;
});
assert.deepEqual(parsedMessage, { action: 'ping', payload: 42 }, 'framer must parse newline-delimited JSON frame');

// 4. Type definitions surface
const indexDts = fs.readFileSync(path.join(pkgDir, 'index.d.ts'), 'utf8');
assert.ok(indexDts.includes('export function spawn('), 'index.d.ts must declare spawn');
assert.ok(indexDts.includes('export function spawnSync('), 'index.d.ts must declare spawnSync');
assert.ok(indexDts.includes('export interface SpawnOptions'), 'index.d.ts must declare SpawnOptions');
assert.ok(indexDts.includes('export interface SpawnSyncOptions'), 'index.d.ts must declare SpawnSyncOptions');
assert.ok(indexDts.includes('export interface SpawnSyncResult'), 'index.d.ts must declare SpawnSyncResult');
assert.ok(indexDts.includes('export interface Subprocess'), 'index.d.ts must declare Subprocess');
assert.ok(indexDts.includes('export interface SubprocessEvents'), 'index.d.ts must declare SubprocessEvents');
assert.ok(indexDts.includes("export type IO = 'inherit' | 'pipe' | 'overlapped' | 'ignore' | 'ipc'"));

// 5. C binding and prebuild artifacts
assert.ok(fs.existsSync(path.join(pkgDir, 'binding.c')), 'binding.c must exist');
assert.ok(fs.existsSync(path.join(pkgDir, 'binding.js')), 'binding.js must exist');
assert.ok(fs.existsSync(path.join(pkgDir, 'CMakeLists.txt')), 'CMakeLists.txt must exist');
assert.ok(fs.existsSync(path.join(pkgDir, 'prebuilds', 'linux-x64', 'bare-subprocess.bare')), 'linux-x64 prebuild must exist');
assert.ok(fs.existsSync(path.join(pkgDir, 'prebuilds', 'linux-arm64', 'bare-subprocess.bare')), 'linux-arm64 prebuild must exist');
assert.ok(fs.existsSync(path.join(pkgDir, 'prebuilds', 'darwin-arm64', 'bare-subprocess.bare')), 'darwin-arm64 prebuild must exist');
assert.ok(fs.existsSync(path.join(pkgDir, 'prebuilds', 'win32-x64', 'bare-subprocess.bare')), 'win32-x64 prebuild must exist');

console.log('Contract tests passed successfully.');

原始种子者

匿名