CodeSampleX

Ejemplo

object-inspect 1.13.4

Muestra verificada para npm object-inspect 1.13.4. El contrato se ejecutó en node 22 · linux alpine/x64 · docker y pasó: formatValue returns formatted string…

sha256:d288f274c1109d7a141e8179af8ee2b0d3fc78029569b6bca6562801bf918fb8

Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido. Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas. MIT-0

Evidencia de ejecución

El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.

Base de evidencia
Contrato firmado aprobado
Recibos de verificación
2
Claves de firma que lo compilaron
1
Entorno declarado node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Entornos de las ejecuciones de verificación

Entorno Contrato Etapas Ejecución
node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1
2026-08-20
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-07

Caso

HOW
Objetivo
verify pkg:npm/object-inspect@1.13.4
Paquetes
Entorno
node 22.23.2
Creado
2026-08-20T13:26:05Z

Contrato

  1. formatValue returns formatted string representations for objects and primitives
  2. formatObject safely inspects circular data structures without throwing
  3. supports depth option to limit inspection depth of nested structures
  4. supports quoteStyle option for choosing single or double string quotes
  5. supports maxStringLength option to truncate strings exceeding maximum length

Archivos

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

Descargar el artefacto de código fuente (tar.gz)

Código fuente

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/object-inspect@1.13.4
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/object-inspect@1.13.4
Constraints:
  - executionContext: node
Required runtime conditions:
  - ecosystem: npm
  - language: javascript
  - moduleSystem: cjs
  - packageManager: npm@10.9.8
  - runtime: node@22.23.2

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:ca4ad612bbf6d228537016f382bdc9b7c71bc6adae6aa20876ae0283effa10e4","constraints":{"executionContext":"node"},"contract":["formatValue returns formatted string representations for objects and primitives","formatObject safely inspects circular data structures without throwing","supports depth option to limit inspection depth of nested structures","supports quoteStyle option for choosing single or double string quotes","supports maxStringLength option to truncate strings exceeding maximum length"],"goal":"verify pkg:npm/object-inspect@1.13.4","kind":"HOW","packages":["pkg:npm/object-inspect@1.13.4"],"schemaVersion":1},"contractCommand":["node","test/contract.mjs"],"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/object-inspect@1.13.4"],"schemaVersion":1,"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-object-inspect",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-object-inspect",
      "version": "1.0.0",
      "dependencies": {
        "object-inspect": "1.13.4"
      }
    },
    "node_modules/object-inspect": {
      "version": "1.13.4",
      "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz",
      "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==",
      "license": "MIT",
      "engines": {
        "node": ">= 0.4"
      },
      "funding": {
        "url": "https://github.com/sponsors/ljharb"
      }
    }
  }
}
package.json
{
  "name": "sample-object-inspect",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification of object-inspect",
  "main": "src/index.js",
  "dependencies": {
    "object-inspect": "1.13.4"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/object-inspect@1.13.4",
  "kind": "HOW",
  "packages": [
    "pkg:npm/object-inspect@1.13.4"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
src/index.js
const inspect = require('object-inspect');

/**
 * Format a value or object using object-inspect with optional custom options.
 * @param {*} value - The value to inspect
 * @param {object} [options] - Options passed to object-inspect
 * @returns {string} Formatted string representation
 */
function formatValue(value, options) {
  return inspect(value, options);
}

/**
 * Format an object safely even with circular references or deep nesting.
 * @param {object} obj - Object to format safely
 * @param {object} [options] - Options
 * @returns {string} Formatted string representation
 */
function formatObject(obj, options = {}) {
  return inspect(obj, {
    depth: 5,
    ...options
  });
}

module.exports = {
  formatValue,
  formatObject,
  inspect
};
test/contract.mjs
import assert from 'node:assert';
import { createRequire } from 'node:module';

const require = createRequire(import.meta.url);
const { formatValue, formatObject, inspect } = require('../src/index.js');

// 1. Export verification
assert.strictEqual(typeof inspect, 'function', 'inspect should be exported as a function');
assert.strictEqual(typeof formatValue, 'function', 'formatValue should be a function');
assert.strictEqual(typeof formatObject, 'function', 'formatObject should be a function');

// 2. Format primitive and object structures
const obj = { name: 'sample', count: 42, active: true };
const objFormatted = formatValue(obj);
assert.strictEqual(objFormatted, "{ name: 'sample', count: 42, active: true }");

const arr = [1, 2, 'three'];
assert.strictEqual(formatValue(arr), "[ 1, 2, 'three' ]");

// 3. Handle circular references safely without throwing
const circular = { id: 1 };
circular.self = circular;
const circularResult = formatObject(circular);
assert.strictEqual(circularResult, '{ id: 1, self: [Circular] }');

// 4. Respect depth option for nested structures
const deep = { level1: { level2: { level3: 'deepValue' } } };
const shallowResult = formatValue(deep, { depth: 1 });
assert.strictEqual(shallowResult, '{ level1: [Object] }');

// 5. Support quoteStyle and maxStringLength options
const doubleQuote = formatValue('hello world', { quoteStyle: 'double' });
assert.strictEqual(doubleQuote, '"hello world"');

const truncated = formatValue('supercalifragilistic', { maxStringLength: 5 });
assert.strictEqual(truncated, "'super'... 15 more characters");

console.log('Contract tests passed successfully.');

Seeder de origen

anónimo