CodeSampleX

サンプル

env-paths 2.2.1

検証済みサンプル — npm env-paths 2.2.1. node 22 · linux alpine/x64 · docker で contract を実行し、成功しました: Calling envPaths returns standard XDG paths on Linux including…

sha256:7cb9d06d647edb45d2d6256d62cd9eb6300e3012c4d1381b32686b718aefc8ef

このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。 合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。 MIT-0

実行証拠

宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。

証拠の基準
署名済みコントラクト合格
検証レシート
1
ビルドした署名鍵
1
宣言された環境 linux 24 · ubuntu · glibc 2.39 x64 npm

検証実行環境

環境 コントラクト ステージ 実行日
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/env-paths@2.2.1
パッケージ
作成日
2026-08-23T13:29:34Z

コントラクト

  1. Calling envPaths returns standard XDG paths on Linux including data, config, cache, log, and temp directories
  2. Calling envPaths with default options appends the '-nodejs' suffix to the application directory name
  3. Setting suffix option to false disables the suffix and uses the bare application name
  4. Setting suffix option to a custom string appends the custom suffix to the application directory name
  5. Passing a non-string name argument throws a TypeError

ファイル

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

ソースアーティファクトをダウンロード (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/env-paths@2.2.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/env-paths@2.2.1

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:c192eef179b812cd173899e4a6bd06e84ba93d356d0e04567b3940e01200b438","contract":["Calling envPaths returns standard XDG paths on Linux including data, config, cache, log, and temp directories","Calling envPaths with default options appends the '-nodejs' suffix to the application directory name","Setting suffix option to false disables the suffix and uses the bare application name","Setting suffix option to a custom string appends the custom suffix to the application directory name","Passing a non-string name argument throws a TypeError"],"goal":"verify pkg:npm/env-paths@2.2.1","kind":"HOW","packages":["pkg:npm/env-paths@2.2.1"],"schemaVersion":1},"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/env-paths@2.2.1"],"schemaVersion":1,"subject":"pkg:npm/env-paths@2.2.1","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-env-paths",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-env-paths",
      "version": "1.0.0",
      "dependencies": {
        "env-paths": "2.2.1"
      }
    },
    "node_modules/env-paths": {
      "version": "2.2.1",
      "resolved": "https://registry.npmjs.org/env-paths/-/env-paths-2.2.1.tgz",
      "integrity": "sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==",
      "license": "MIT",
      "engines": {
        "node": ">=6"
      }
    }
  }
}
package.json
{
  "name": "sample-env-paths",
  "version": "1.0.0",
  "type": "module",
  "private": true,
  "dependencies": {
    "env-paths": "2.2.1"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/env-paths@2.2.1",
  "kind": "HOW",
  "packages": [
    "pkg:npm/env-paths@2.2.1"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import os from 'node:os';
import path from 'node:path';
import process from 'node:process';
import envPaths from 'env-paths';

// 1. envPaths returns an object containing data, config, cache, log, and temp directory paths
{
	const paths = envPaths('myapp', { suffix: false });
	assert.equal(typeof paths, 'object');
	assert.ok(typeof paths.data === 'string' && paths.data.length > 0);
	assert.ok(typeof paths.config === 'string' && paths.config.length > 0);
	assert.ok(typeof paths.cache === 'string' && paths.cache.length > 0);
	assert.ok(typeof paths.log === 'string' && paths.log.length > 0);
	assert.ok(typeof paths.temp === 'string' && paths.temp.length > 0);

	const homedir = os.homedir();
	const tmpdir = os.tmpdir();
	const username = path.basename(homedir);
	const expectedData = process.env.XDG_DATA_HOME || path.join(homedir, '.local', 'share');
	const expectedConfig = process.env.XDG_CONFIG_HOME || path.join(homedir, '.config');
	const expectedCache = process.env.XDG_CACHE_HOME || path.join(homedir, '.cache');
	const expectedLog = process.env.XDG_STATE_HOME || path.join(homedir, '.local', 'state');
	const expectedTemp = path.join(tmpdir, username, 'myapp');

	assert.equal(paths.data, path.join(expectedData, 'myapp'));
	assert.equal(paths.config, path.join(expectedConfig, 'myapp'));
	assert.equal(paths.cache, path.join(expectedCache, 'myapp'));
	assert.equal(paths.log, path.join(expectedLog, 'myapp'));
	assert.equal(paths.temp, expectedTemp);
}

// 2. envPaths defaults to appending '-nodejs' suffix to the provided application name
{
	const paths = envPaths('myapp');
	assert.ok(paths.data.endsWith('myapp-nodejs'));
	assert.ok(paths.config.endsWith('myapp-nodejs'));
	assert.ok(paths.cache.endsWith('myapp-nodejs'));
	assert.ok(paths.log.endsWith('myapp-nodejs'));
	assert.ok(paths.temp.endsWith('myapp-nodejs'));
}

// 3. envPaths with suffix option set to false disables suffixing and keeps the original application name
{
	const paths = envPaths('myapp', { suffix: false });
	assert.ok(paths.data.endsWith(path.sep + 'myapp'));
	assert.ok(!paths.data.endsWith('myapp-nodejs'));
}

// 4. envPaths with custom suffix option appends the custom suffix string to the application name
{
	const paths = envPaths('myapp', { suffix: 'server' });
	assert.ok(paths.data.endsWith('myapp-server'));
}

// 5. envPaths validates argument type and throws TypeError when name is not a string
{
	assert.throws(
		() => {
			envPaths(12345);
		},
		{
			name: 'TypeError',
			message: 'Expected string, got number',
		}
	);
}

オリジンシーダー

匿名