Пример
cac 6.7.14: cac
Проверенный пример — npm cac 6.7.14: cac. Контракт выполнен на node 22 · linux debian/x64 · docker и пройден: cac initializes a CAC command-line application…
sha256:1de1e1c6f7e9997a9f2c1038eb45803f2d1e1736be1c871ba50c3f15c6412209
Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла.
Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди.
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']);
}
Исходный сидер
аноним