示例
cac 6.7.14: cac
已验证示例 — npm cac 6.7.14: cac. contract 在 node 22 · linux debian/x64 · docker 上运行并通过: cac initializes a CAC command-line application instance with an optional…
sha256:1de1e1c6f7e9997a9f2c1038eb45803f2d1e1736be1c871ba50c3f15c6412209
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。
MIT-0
执行证据
声明的环境与签名的运行分开呈现,你可以看到这个样本究竟运行了什么、在哪里运行。
- 证据依据
- 签名契约通过
- 验证回执
- 1
- 构建过它的签名密钥
- 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 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2… |
2026-09-06 |
案例
HOW- 目标
- verify cac.cac in pkg:npm/cac@6.7.14
- 符号
-
- cac.cac
- 环境
- node 22.23.2
- 创建时间
- 2026-09-06T11:45:42Z
契约
- cac initializes a CAC command-line application instance with an optional program name
- cac registers sub-commands and passes parsed arguments and command options to action callbacks
- cac registers global options with default values and parses user supplied option values
- cac parses negated boolean flags into false boolean option properties
- cac parses variadic arguments for sub-commands into an array of strings
文件
- .npmrc
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.mjs
- test/contract.mjs
源代码
audit=false
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 cac.cac in pkg:npm/cac@6.7.14
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/cac@6.7.14
Demonstrate these symbols/APIs:
- cac.cac
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.
{"case":{"caseId":"case:sha256:5af70f52992c783249849e3a37cb6701e94f437081cf94809b32a9925f3f2e56","contract":["cac initializes a CAC command-line application instance with an optional program name","cac registers sub-commands and passes parsed arguments and command options to action callbacks","cac registers global options with default values and parses user supplied option values","cac parses negated boolean flags into false boolean option properties","cac parses variadic arguments for sub-commands into an array of strings"],"goal":"verify cac.cac in pkg:npm/cac@6.7.14","kind":"HOW","packages":["pkg:npm/cac@6.7.14"],"schemaVersion":1,"symbols":["cac.cac"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"esm","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/cac@6.7.14"],"schemaVersion":1,"subject":"pkg:npm/cac@6.7.14","symbols":["cac.cac"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-cac",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-cac",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"cac": "6.7.14"
}
},
"node_modules/cac": {
"version": "6.7.14",
"resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz",
"integrity": "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==",
"license": "MIT",
"engines": {
"node": ">=8"
}
}
}
}
{
"name": "sample-cac",
"version": "1.0.0",
"type": "module",
"private": true,
"description": "verify cac.cac in pkg:npm/cac@6.7.14",
"main": "src/index.mjs",
"license": "MIT-0",
"dependencies": {
"cac": "6.7.14"
}
}
{
"schemaVersion": 1,
"goal": "verify cac.cac in pkg:npm/cac@6.7.14",
"kind": "HOW",
"packages": [
"pkg:npm/cac@6.7.14"
],
"symbols": [
"cac.cac"
]
}
import { cac, CAC, Command } from 'cac';
/**
* Creates a CAC CLI application instance.
*
* @param {string} [name] - Optional program name
* @returns {CAC} CAC application instance
*/
export function createCli(name) {
return cac(name);
}
export { cac, CAC, Command };
export default cac;
import assert from 'node:assert/strict';
import { cac, CAC, Command, createCli } from '../src/index.mjs';
// 1. cac initializes a CAC command-line application instance with an optional program name
{
const namedCli = cac('sample-app');
assert.equal(namedCli instanceof CAC, true);
assert.equal(namedCli.name, 'sample-app');
const defaultCli = cac();
assert.equal(defaultCli instanceof CAC, true);
assert.equal(defaultCli.name, '');
const helperCli = createCli('helper-app');
assert.equal(helperCli instanceof CAC, true);
assert.equal(helperCli.name, 'helper-app');
}
// 2. cac registers sub-commands and passes parsed arguments and command options to action callbacks
{
const cli = cac();
let actionInvoked = false;
let receivedTarget = null;
let receivedOptions = null;
const command = cli.command('build <target>', 'Build artifact')
.option('--minify', 'Minify output bundle')
.action((target, options) => {
actionInvoked = true;
receivedTarget = target;
receivedOptions = options;
});
assert.equal(command instanceof Command, true);
const parsed = cli.parse(['node', 'cli.js', 'build', 'bundle.js', '--minify']);
assert.equal(actionInvoked, true);
assert.equal(receivedTarget, 'bundle.js');
assert.equal(receivedOptions.minify, true);
assert.deepEqual(parsed.args, ['bundle.js']);
assert.equal(parsed.options.minify, true);
}
// 3. cac registers global options with default values and parses user supplied option values
{
const cli = cac();
cli.option('--format <type>', 'Output format', { default: 'esm' });
const parsedDefault = cli.parse(['node', 'cli.js']);
assert.equal(parsedDefault.options.format, 'esm');
const parsedCustom = cli.parse(['node', 'cli.js', '--format', 'cjs']);
assert.equal(parsedCustom.options.format, 'cjs');
}
// 4. cac parses negated boolean flags into false boolean option properties
{
const cli = cac();
cli.option('--sourcemap', 'Emit source maps', { default: true });
const parsed = cli.parse(['node', 'cli.js', '--no-sourcemap']);
assert.equal(parsed.options.sourcemap, false);
}
// 5. cac parses variadic arguments for sub-commands into an array of strings
{
const cli = cac();
let capturedFiles = null;
cli.command('lint [...files]', 'Lint specified files')
.action((files) => {
capturedFiles = files;
});
cli.parse(['node', 'cli.js', 'lint', 'file1.js', 'file2.js', 'file3.js']);
assert.deepEqual(capturedFiles, ['file1.js', 'file2.js', 'file3.js']);
}
原始种子者
匿名