CodeSampleX

Пример

abbrev 4.0.0

Проверенный пример — npm abbrev 4.0.0. Контракт выполнен на node 22 · linux alpine/x64 · docker и пройден: abbrev calculates all unambiguous prefix…

sha256:8ccc6ba32de541c20cd7481cbb52b0b28cd931b5caeb6523ed038ccf0713333b

Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла. Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди. MIT-0

Свидетельства выполнения

Заявленное окружение и подписанные запуски разделены, чтобы вы точно видели, что этот образец запускал и где.

Основа свидетельства
Подписанный контракт пройден
Квитанции проверки
1
Ключи подписи, собравшие его
1
Заявленная среда node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Среды запусков проверки

Окружение Контракт Этапы Запуск
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

Кейс

HOW
Цель
verify pkg:npm/abbrev@4.0.0
Пакеты
Окружение
node 22.23.2
Создан
2026-08-23T13:59:45Z

Контракт

  1. abbrev calculates all unambiguous prefix abbreviations for an array of strings or multiple arguments
  2. abbrev maps the full original word to itself for all input words
  3. abbrev removes ambiguous prefixes shared by multiple distinct words
  4. abbrev coerces non-string arguments to strings when generating abbreviations
  5. abbrev handles single string inputs and duplicate words without collision errors

Файлы

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • src/index.js
  • test/contract.js

Скачать артефакт с исходным кодом (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/abbrev@4.0.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/abbrev@4.0.0

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:f708df3a84dce9fed117c300bd46e35bc38cdc5350381c5715ea99c1e5463f74","contract":["abbrev calculates all unambiguous prefix abbreviations for an array of strings or multiple arguments","abbrev maps the full original word to itself for all input words","abbrev removes ambiguous prefixes shared by multiple distinct words","abbrev coerces non-string arguments to strings when generating abbreviations","abbrev handles single string inputs and duplicate words without collision errors"],"goal":"verify pkg:npm/abbrev@4.0.0","kind":"HOW","packages":["pkg:npm/abbrev@4.0.0"],"schemaVersion":1},"contractCommand":["node","test/contract.js"],"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/abbrev@4.0.0"],"schemaVersion":1,"subject":"pkg:npm/abbrev@4.0.0","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-abbrev",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-abbrev",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "abbrev": "4.0.0"
      }
    },
    "node_modules/abbrev": {
      "version": "4.0.0",
      "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-4.0.0.tgz",
      "integrity": "sha512-a1wflyaL0tHtJSmLSOVybYhy22vRih4eduhhrkcjgrWGnRfrZtovJ2FRjxuTtkkj47O/baf0R86QU5OuYpz8fA==",
      "license": "ISC",
      "engines": {
        "node": "^20.17.0 || >=22.9.0"
      }
    }
  }
}
package.json
{
  "name": "sample-abbrev",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification sample for abbrev",
  "main": "src/index.js",
  "scripts": {
    "test": "node test/contract.js"
  },
  "dependencies": {
    "abbrev": "4.0.0"
  },
  "license": "MIT-0"
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/abbrev@4.0.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/abbrev@4.0.0"
  ]
}
src/index.js
const abbrev = require("abbrev");

function getAbbrevs(...words) {
  return abbrev(...words);
}

module.exports = {
  abbrev,
  getAbbrevs
};
test/contract.js
const assert = require("node:assert");
const abbrev = require("abbrev");
const { getAbbrevs } = require("../src/index.js");

// 1. abbrev calculates all unambiguous prefix abbreviations for an array of strings or multiple arguments
const resArray = getAbbrevs(["cat", "dog", "duck"]);
assert.strictEqual(resArray["c"], "cat", "c should abbreviate cat");
assert.strictEqual(resArray["ca"], "cat", "ca should abbreviate cat");
assert.strictEqual(resArray["cat"], "cat", "cat should abbreviate cat");
assert.strictEqual(resArray["do"], "dog", "do should abbreviate dog");
assert.strictEqual(resArray["dog"], "dog", "dog should abbreviate dog");
assert.strictEqual(resArray["du"], "duck", "du should abbreviate duck");
assert.strictEqual(resArray["duc"], "duck", "duc should abbreviate duck");
assert.strictEqual(resArray["duck"], "duck", "duck should abbreviate duck");

const resArgs = abbrev("foo", "fool", "folding", "flop");
assert.strictEqual(resArgs["fl"], "flop", "fl should abbreviate flop");
assert.strictEqual(resArgs["flo"], "flop", "flo should abbreviate flop");
assert.strictEqual(resArgs["flop"], "flop", "flop should abbreviate flop");
assert.strictEqual(resArgs["fol"], "folding", "fol should abbreviate folding");
assert.strictEqual(resArgs["fold"], "folding", "fold should abbreviate folding");
assert.strictEqual(resArgs["foldi"], "folding", "foldi should abbreviate folding");
assert.strictEqual(resArgs["foldin"], "folding", "foldin should abbreviate folding");
assert.strictEqual(resArgs["folding"], "folding", "folding should abbreviate folding");

// 2. abbrev maps the full original word to itself for all input words
assert.strictEqual(resArgs["foo"], "foo", "full word foo should map to foo");
assert.strictEqual(resArgs["fool"], "fool", "full word fool should map to fool");
assert.strictEqual(resArray["cat"], "cat", "full word cat should map to cat");
assert.strictEqual(resArray["dog"], "dog", "full word dog should map to dog");
assert.strictEqual(resArray["duck"], "duck", "full word duck should map to duck");

// 3. abbrev removes ambiguous prefixes shared by multiple distinct words
assert.strictEqual(resArray["d"], undefined, "ambiguous prefix d should not be present");
assert.strictEqual(resArgs["f"], undefined, "ambiguous prefix f should not be present");
assert.strictEqual(resArgs["fo"], undefined, "ambiguous prefix fo should not be present");

// 4. abbrev coerces non-string arguments to strings when generating abbreviations
const resCoerce = getAbbrevs([10, 12]);
assert.strictEqual(resCoerce["10"], "10", "coerced full number 10 should map to 10");
assert.strictEqual(resCoerce["12"], "12", "coerced full number 12 should map to 12");
assert.strictEqual(resCoerce["1"], undefined, "ambiguous numeric prefix 1 should not be present");

// 5. abbrev handles single string inputs and duplicate words without collision errors
const resSingle = getAbbrevs("single");
assert.strictEqual(resSingle["s"], "single", "s should abbreviate single");
assert.strictEqual(resSingle["si"], "single", "si should abbreviate single");
assert.strictEqual(resSingle["sin"], "single", "sin should abbreviate single");
assert.strictEqual(resSingle["sing"], "single", "sing should abbreviate single");
assert.strictEqual(resSingle["singl"], "single", "singl should abbreviate single");
assert.strictEqual(resSingle["single"], "single", "single should abbreviate single");

const resDups = abbrev(["cat", "cat", "dog"]);
assert.strictEqual(resDups["c"], "cat", "duplicate words should not eliminate valid abbreviations");
assert.strictEqual(resDups["ca"], "cat", "ca should map to cat");
assert.strictEqual(resDups["cat"], "cat", "cat should map to cat");
assert.strictEqual(resDups["d"], "dog", "d should abbreviate dog when dog is the only word starting with d");
assert.strictEqual(resDups["do"], "dog", "do should map to dog");
assert.strictEqual(resDups["dog"], "dog", "dog should map to dog");

console.log("All abbrev contract tests passed successfully.");

Исходный сидер

аноним