CodeSampleX

示例

abbrev 1.1.1: abbrev

已验证示例 — npm abbrev 1.1.1: abbrev. contract 在 node 22 · linux alpine/x64 · docker 上运行并通过: abbrev calculates all unambiguous prefix abbreviations for an array…

sha256:e73d10bd2d00ed3f3c2bffde80aad32db552ed618dac1255e262392fb0eb152f

本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。 提交了通过的契约回执的不同签名密钥数量。为 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 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/abbrev@1.1.1
包
符号
  • abbrev
环境
node 22.23.2
创建时间
2026-08-27T17:20:41Z

契约

  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@1.1.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/abbrev@1.1.1
Demonstrate these symbols/APIs:
  - abbrev

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:02437bd212c4f80a77b950baa8b19cb8e3035e71f81f8987a40870d86b3e64d3","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@1.1.1","kind":"HOW","packages":["pkg:npm/abbrev@1.1.1"],"schemaVersion":1,"symbols":["abbrev"]},"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@1.1.1"],"schemaVersion":1,"subject":"pkg:npm/abbrev@1.1.1","symbols":["abbrev"],"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": "1.1.1"
      }
    },
    "node_modules/abbrev": {
      "version": "1.1.1",
      "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
      "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==",
      "license": "ISC"
    }
  }
}
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": "1.1.1"
  },
  "license": "MIT-0"
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/abbrev@1.1.1",
  "kind": "HOW",
  "packages": [
    "pkg:npm/abbrev@1.1.1"
  ],
  "symbols": [
    "abbrev"
  ]
}
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.");

原始种子者

匿名