Exemplo
@babel/code-frame 7.29.7: highlight
Amostra verificada para npm @babel/code-frame 7.29.7: highlight. O contrato rodou em node 22 · linux alpine/x64 · docker e passou.
sha256:e032b48d1433bb9e905245b2629521af6ad8f39b1d10fd938b9767665e356bbf
Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu.
Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas.
MIT-0
Evidência de execução
O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.
- Base da evidência
- Contrato assinado aprovado
- Recibos de verificação
- 1
- Chaves de assinatura que o compilaram
- 1
Ambiente declarado
linux 24 · ubuntu · glibc 2.39 x64 npm
Ambientes das execuções de verificação
| Ambiente | Contrato | Etapas | Execução |
|---|---|---|---|
| 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 |
Caso
HOW- Objetivo
- verify @babel/code-frame.highlight in pkg:npm/%40babel/code-frame@7.29.7
- Pacotes
- Símbolos
-
- @babel/code-frame.highlight
- Criado
- 2026-08-23T04:29:30Z
Contrato
- highlight returns an empty string when given an empty input string
- highlight formats JavaScript keywords with cyan ANSI escape sequences
- highlight formats string literals with green ANSI color codes and numeric literals with magenta
- highlight formats comments with gray ANSI escape codes and punctuators with yellow
- highlight colors JSX syntax elements including tags and component names
- stripAnsiEscapeCodes restores the original source code text from highlighted output
Arquivos
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.mjs
- test/contract.mjs
Código-fonte
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 @babel/code-frame.highlight in pkg:npm/%40babel/code-frame@7.29.7
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/%40babel/code-frame@7.29.7
Demonstrate these symbols/APIs:
- @babel/code-frame.highlight
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:78aaab708b3fd8ce7a3d521b4a6f0051de70114c43bbf36b3d4305a86000693c","contract":["highlight returns an empty string when given an empty input string","highlight formats JavaScript keywords with cyan ANSI escape sequences","highlight formats string literals with green ANSI color codes and numeric literals with magenta","highlight formats comments with gray ANSI escape codes and punctuators with yellow","highlight colors JSX syntax elements including tags and component names","stripAnsiEscapeCodes restores the original source code text from highlighted output"],"goal":"verify @babel/code-frame.highlight in pkg:npm/%40babel/code-frame@7.29.7","kind":"HOW","packages":["pkg:npm/%40babel/code-frame@7.29.7"],"schemaVersion":1,"symbols":["@babel/code-frame.highlight"]},"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/%40babel/code-frame@7.29.7"],"schemaVersion":1,"subject":"pkg:npm/%40babel/code-frame@7.29.7","symbols":["@babel/code-frame.highlight"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-babel-code-frame-highlight",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-babel-code-frame-highlight",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"@babel/code-frame": "7.29.7"
}
},
"node_modules/@babel/code-frame": {
"version": "7.29.7",
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.29.7.tgz",
"integrity": "sha512-Aup7aUOfpbAUg2ROOJN6Iw5f9DMBlzu0mIkm/malLQFN/YQgO48wCj0Kxa3sEHJvPVFg7siR+qRInwXd2qhQKw==",
"license": "MIT",
"dependencies": {
"@babel/helper-validator-identifier": "^7.29.7",
"js-tokens": "^4.0.0",
"picocolors": "^1.1.1"
},
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/helper-validator-identifier": {
"version": "7.29.7",
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.29.7.tgz",
"integrity": "sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg==",
"license": "MIT",
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/js-tokens": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
"integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==",
"license": "MIT"
},
"node_modules/picocolors": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
"integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",
"license": "ISC"
}
}
}
{
"name": "sample-babel-code-frame-highlight",
"version": "1.0.0",
"private": true,
"type": "module",
"license": "MIT-0",
"dependencies": {
"@babel/code-frame": "7.29.7"
}
}
{
"schemaVersion": 1,
"goal": "verify @babel/code-frame.highlight in pkg:npm/%40babel/code-frame@7.29.7",
"kind": "HOW",
"packages": [
"pkg:npm/%40babel/code-frame@7.29.7"
],
"symbols": [
"@babel/code-frame.highlight"
]
}
import { highlight } from "@babel/code-frame";
export function highlightCode(code) {
return highlight(code);
}
export function stripAnsiEscapeCodes(str) {
return str.replace(/\u001b\[[0-9;]*m/g, "");
}
import assert from "node:assert/strict";
import { highlight } from "@babel/code-frame";
import { highlightCode, stripAnsiEscapeCodes } from "../src/index.mjs";
// Test 1: highlight returns an empty string when given an empty input string
{
const result = highlightCode("");
assert.equal(result, "");
}
// Test 2: highlight formats JavaScript keywords with cyan ANSI escape sequences
{
const code = "const x = 1; function test() { return true; }";
const highlighted = highlightCode(code);
assert.ok(highlighted.includes("\u001b[36mconst\u001b[39m"), "const should be colored cyan");
assert.ok(highlighted.includes("\u001b[36mfunction\u001b[39m"), "function should be colored cyan");
assert.ok(highlighted.includes("\u001b[36mreturn\u001b[39m"), "return should be colored cyan");
}
// Test 3: highlight formats string literals with green ANSI color codes and numeric literals with magenta
{
const code = 'const greeting = "hello"; const count = 42;';
const highlighted = highlightCode(code);
assert.ok(highlighted.includes('\u001b[32m"hello"\u001b[39m'), 'string literal should be colored green');
assert.ok(highlighted.includes('\u001b[35m42\u001b[39m'), 'numeric literal should be colored magenta');
}
// Test 4: highlight formats comments with gray ANSI escape codes and punctuators with yellow
{
const code = "// calculate total\na = b + c;";
const highlighted = highlightCode(code);
assert.ok(highlighted.includes("\u001b[90m// calculate total\u001b[39m"), "comment should be colored gray");
assert.ok(highlighted.includes("\u001b[33m=\u001b[39m"), "= should be colored yellow");
assert.ok(highlighted.includes("\u001b[33m+\u001b[39m"), "+ should be colored yellow");
assert.ok(highlighted.includes("\u001b[33m;\u001b[39m"), "; should be colored yellow");
}
// Test 5: highlight colors JSX syntax elements including tags and component names
{
const code = "<AppContainer title=\"main\"><Button>Click</Button></AppContainer>";
const highlighted = highlightCode(code);
assert.ok(highlighted.includes("\u001b[33m<\u001b[39m"), "< should be colored yellow");
assert.ok(highlighted.includes("\u001b[33mAppContainer\u001b[39m"), "component name should be colored yellow");
assert.ok(highlighted.includes("\u001b[33mButton\u001b[39m"), "nested component name should be colored yellow");
}
// Test 6: stripAnsiEscapeCodes restores the original source code text from highlighted output
{
const inputs = [
"",
"const value = 100;",
"function render() {\n return <Component key={1}>{'text'}</Component>;\n}",
"// single line comment\nlet x = 'string';"
];
for (const input of inputs) {
const highlighted = highlightCode(input);
const restored = stripAnsiEscapeCodes(highlighted);
assert.equal(restored, input, "Restored text must match original input exactly");
}
}
console.log("All @babel/code-frame.highlight contract tests passed successfully.");
Seeder de origem
anônimo