CodeSampleX

サンプル

@types/stack-utils 2.0.3: clean stack trace and parse line with StackUtils

検証済みサンプル — npm @types/stack-utils 2.0.3: clean stack trace and parse line with StackUtils. node 22 · linux alpine/x64 · docker で contract を実行し、成功しました.

sha256:296cb5a337d2e20ee0879f3a52d1996dcdaccdda2f7b1e2b9f5aadb1e9f1c917

このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。 合格した契約受領証を提出した異なる署名鍵の数です。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-27

ケース

HOW
ゴール
clean stack trace and parse line with StackUtils
パッケージ
シンボル
  • StackUtils
作成日
2026-08-27T15:29:35Z

コントラクト

  1. package manifest specifies index.d.ts type declarations and TypeScript version
  2. declares StackUtils class with constructor, static nodeInternals, and methods clean, capture, captureString, at, parseLine
  3. declares Options interface with internals, ignoredPackages, cwd, and wrapCallSite
  4. declares CallSite and CallSiteLike interfaces with location and inspection methods
  5. declares StackLineData and StackData interfaces with line, column, file, and eval details

ファイル

  • 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: clean stack trace and parse line with StackUtils
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40types/stack-utils@2.0.3
Demonstrate these symbols/APIs:
  - StackUtils

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:15dba7b3b974ba667f57b387ed75c37fa6cd86111421202ded076a046ae19037","contract":["package manifest specifies index.d.ts type declarations and TypeScript version","declares StackUtils class with constructor, static nodeInternals, and methods clean, capture, captureString, at, parseLine","declares Options interface with internals, ignoredPackages, cwd, and wrapCallSite","declares CallSite and CallSiteLike interfaces with location and inspection methods","declares StackLineData and StackData interfaces with line, column, file, and eval details"],"goal":"clean stack trace and parse line with StackUtils","kind":"HOW","packages":["pkg:npm/%40types/stack-utils@2.0.3"],"schemaVersion":1,"symbols":["StackUtils"]},"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/%40types/stack-utils@2.0.3"],"schemaVersion":1,"subject":"pkg:npm/%40types/stack-utils@2.0.3","symbols":["StackUtils"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-types-stack-utils",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-types-stack-utils",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "@types/stack-utils": "2.0.3"
      }
    },
    "node_modules/@types/stack-utils": {
      "version": "2.0.3",
      "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.3.tgz",
      "integrity": "sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw==",
      "license": "MIT"
    }
  }
}
package.json
{
  "name": "sample-types-stack-utils",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "license": "MIT-0",
  "dependencies": {
    "@types/stack-utils": "2.0.3"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "clean stack trace and parse line with StackUtils",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40types/stack-utils@2.0.3"
  ],
  "symbols": [
    "StackUtils"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';
import fs from 'node:fs';
import path from 'node:path';

const require = createRequire(import.meta.url);

// 1. Resolve @types/stack-utils package manifest and verify type declaration entry points
const pkgPath = require.resolve('@types/stack-utils/package.json');
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));

assert.equal(pkg.name, '@types/stack-utils', 'Package name must be @types/stack-utils');
assert.equal(pkg.version, '2.0.3', 'Package version must be 2.0.3');
assert.equal(pkg.types, 'index.d.ts', 'Package types entry must point to index.d.ts');
assert.equal(pkg.typeScriptVersion, '4.5', 'TypeScript version must be 4.5');

const typesDir = path.dirname(pkgPath);
const dtsContent = fs.readFileSync(path.join(typesDir, 'index.d.ts'), 'utf8');

// 2. Verify StackUtils class declaration and methods
assert.ok(
  dtsContent.includes('export = StackUtils;'),
  'Must export StackUtils as CommonJS default export'
);
assert.ok(
  dtsContent.includes('declare class StackUtils {'),
  'Must declare StackUtils class'
);
assert.ok(
  dtsContent.includes('static nodeInternals(): RegExp[];'),
  'Must declare static nodeInternals method returning RegExp array'
);
assert.ok(
  dtsContent.includes('constructor(options?: StackUtils.Options);'),
  'Must declare constructor accepting optional StackUtils.Options'
);
assert.ok(
  dtsContent.includes('clean(stack: string | string[]): string;'),
  'Must declare clean method accepting string or string array'
);
assert.ok(
  dtsContent.includes('capture(limit?: number, startStackFunction?: Function): StackUtils.CallSite[];') &&
  dtsContent.includes('capture(startStackFunction: Function): StackUtils.CallSite[];'),
  'Must declare capture overloads returning CallSite array'
);
assert.ok(
  dtsContent.includes('captureString(limit?: number, startStackFunction?: Function): string;') &&
  dtsContent.includes('captureString(startStackFunction: Function): string;'),
  'Must declare captureString overloads returning string'
);
assert.ok(
  dtsContent.includes('at(startStackFunction?: Function): StackUtils.CallSiteLike;'),
  'Must declare at method returning CallSiteLike'
);
assert.ok(
  dtsContent.includes('parseLine(line: string): StackUtils.StackLineData | null;'),
  'Must declare parseLine method returning StackLineData or null'
);

// 3. Verify Options interface
assert.ok(
  dtsContent.includes('interface Options {') &&
  dtsContent.includes('internals?: RegExp[] | undefined;') &&
  dtsContent.includes('ignoredPackages?: string[] | undefined;') &&
  dtsContent.includes('cwd?: string | undefined;') &&
  dtsContent.includes('wrapCallSite?(callSite: CallSite): CallSite;'),
  'Options interface must define internals, ignoredPackages, cwd, and wrapCallSite'
);

// 4. Verify CallSite and CallSiteLike interfaces
assert.ok(
  dtsContent.includes('interface CallSite {') &&
  dtsContent.includes('getThis(): object | undefined;') &&
  dtsContent.includes('getTypeName(): string;') &&
  dtsContent.includes('getFunction(): Function | undefined;') &&
  dtsContent.includes('getFunctionName(): string;') &&
  dtsContent.includes('getMethodName(): string | null;') &&
  dtsContent.includes('getFileName(): string | undefined;') &&
  dtsContent.includes('getLineNumber(): number;') &&
  dtsContent.includes('getColumnNumber(): number;') &&
  dtsContent.includes('getEvalOrigin(): CallSite | string;') &&
  dtsContent.includes('isToplevel(): boolean;') &&
  dtsContent.includes('isEval(): boolean;') &&
  dtsContent.includes('isNative(): boolean;') &&
  dtsContent.includes('isConstructor(): boolean;'),
  'CallSite interface must define V8 CallSite accessor methods'
);

assert.ok(
  dtsContent.includes('interface CallSiteLike extends StackData {') &&
  dtsContent.includes('type?: string | undefined;'),
  'CallSiteLike interface must extend StackData and include optional type property'
);

// 5. Verify StackLineData and StackData interfaces
assert.ok(
  dtsContent.includes('interface StackLineData extends StackData {') &&
  dtsContent.includes('evalLine?: number | undefined;') &&
  dtsContent.includes('evalColumn?: number | undefined;') &&
  dtsContent.includes('evalFile?: string | undefined;'),
  'StackLineData interface must extend StackData and include evalLine, evalColumn, evalFile'
);

assert.ok(
  dtsContent.includes('interface StackData {') &&
  dtsContent.includes('line?: number | undefined;') &&
  dtsContent.includes('column?: number | undefined;') &&
  dtsContent.includes('file?: string | undefined;') &&
  dtsContent.includes('constructor?: boolean | undefined;') &&
  dtsContent.includes('evalOrigin?: string | undefined;') &&
  dtsContent.includes('native?: boolean | undefined;') &&
  dtsContent.includes('function?: string | undefined;') &&
  dtsContent.includes('method?: string | undefined;'),
  'StackData interface must define line, column, file, constructor, evalOrigin, native, function, method'
);

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

オリジンシーダー

匿名