CodeSampleX

示例

@inquirer/prompts 6.0.1: Separator

已验证示例 — npm @inquirer/prompts 6.0.1: Separator. contract 在 node 22 · linux debian/x64 · docker 上运行并通过: assert Separator is exported as a class constructor…

sha256:45cd15e12ae6f9fc18bc6a117d815173d4a9d2bef3b639cc7127e6e08ed96eba

本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。 提交了通过的契约回执的不同签名密钥数量。为 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 debian/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2…
2026-09-16

案例

HOW
目标
verify @inquirer/prompts.Separator in pkg:npm/%40inquirer/prompts@6.0.1
包
符号
  • @inquirer/prompts.Separator
环境
node 22.23.2
创建时间
2026-09-16T13:47:45Z

契约

  1. assert Separator is exported as a class constructor from @inquirer/prompts
  2. assert new Separator() creates an instance with default visual separator and type 'separator'
  3. assert new Separator(text) creates an instance with custom separator text and type 'separator'
  4. assert Separator.isSeparator returns true for Separator instances and objects with type 'separator'
  5. assert Separator.isSeparator returns false for non-separator choice objects and primitive values
  6. assert Separator items in choices collections can be identified and separated from selectable choices

文件

  • PROMPT.md
  • csx.json
  • index.mjs
  • 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 @inquirer/prompts.Separator in pkg:npm/%40inquirer/prompts@6.0.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40inquirer/prompts@6.0.1
Demonstrate these symbols/APIs:
  - @inquirer/prompts.Separator

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:1995328f371adfa90b214b1f469d442eb971f4ef088ec9bb7396d4ef05487098","contract":["assert Separator is exported as a class constructor from @inquirer/prompts","assert new Separator() creates an instance with default visual separator and type 'separator'","assert new Separator(text) creates an instance with custom separator text and type 'separator'","assert Separator.isSeparator returns true for Separator instances and objects with type 'separator'","assert Separator.isSeparator returns false for non-separator choice objects and primitive values","assert Separator items in choices collections can be identified and separated from selectable choices"],"goal":"verify @inquirer/prompts.Separator in pkg:npm/%40inquirer/prompts@6.0.1","kind":"HOW","packages":["pkg:npm/%40inquirer/prompts@6.0.1"],"schemaVersion":1,"symbols":["@inquirer/prompts.Separator"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"esm","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/%40inquirer/prompts@6.0.1"],"schemaVersion":1,"subject":"pkg:npm/%40inquirer/prompts@6.0.1","symbols":["@inquirer/prompts.Separator"],"verifierAdapter":"node-typescript@1"}
index.mjs
import { Separator } from '@inquirer/prompts';

/**
 * Creates a Separator instance with optional text.
 * @param {string} [text]
 * @returns {Separator}
 */
export function createSeparator(text) {
  return new Separator(text);
}

/**
 * Checks if a value is an Inquirer Separator.
 * @param {unknown} value
 * @returns {boolean}
 */
export function isSeparator(value) {
  return Separator.isSeparator(value);
}

/**
 * Filters selectable items from a list of choices containing separators.
 * @template T
 * @param {Array<T | Separator>} choices
 * @returns {Array<T>}
 */
export function filterSelectableChoices(choices) {
  return choices.filter((item) => !Separator.isSeparator(item));
}

/**
 * Extracts separators from a list of choices.
 * @template T
 * @param {Array<T | Separator>} choices
 * @returns {Array<Separator>}
 */
export function getSeparators(choices) {
  return choices.filter((item) => Separator.isSeparator(item));
}

export { Separator };
export default Separator;
package-lock.json
{
  "name": "sample-inquirer-prompts-separator",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-inquirer-prompts-separator",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "@inquirer/prompts": "6.0.1"
      }
    },
    "node_modules/@inquirer/checkbox": {
      "version": "3.0.1",
      "resolved": "https://registry.npmjs.org/@inquirer/checkbox/-/checkbox-3.0.1.tgz",
      "integrity": "sha512-0hm2nrToWUdD6/UHnel/UKGdk1//ke5zGUpHIvk5ZWmaKezlGxZkOJXNSWsdxO/rEqTkbB3lNC2J6nBElV2aAQ==",
      "license": "MIT",
      "dependencies": {
        "@inquirer/core": "^9.2.1",
        "@inquirer/figures": "^1.0.6",
        "@inquirer/type": "^2.0.0",
        "ansi-escapes": "^4.3.2",
        "yoctocolors-cjs": "^2.1.2"
      },
      "engines": {
        "node": ">=18"
      }
    },
    "node_modules/@inquirer/confirm": {
      "version": "4.0.1",
      "resolved": "https://registry.npmjs.org/@inquirer/confirm/-/confirm-4.0.1.tgz",
      "integrity": "sha512-46yL28o2NJ9doViqOy0VDcoTzng7rAb6yPQKU7VDLqkmbCaH4JqK4yk4XqlzNWy9PVC5pG1ZUXPBQv+VqnYs2w==",
      "license": "MIT",
      "dependencies": {
        "@inquirer/core": "^9.2.1",
        "@inquirer/type": "^2.0.0"
      },
      "engines": {
        "node": ">=18"
      }
    },
    "node_modules/@inquirer/core": {
      "version": "9.2.1",
      "resolved": "https://registry.npmjs.org/@inquirer/core/-/core-9.2.1.tgz",
      "integrity": "sha512-F2VBt7W/mwqEU4bL0RnHNZmC/OxzNx9cOYxHqnXX3MP6ruYvZUZAW9imgN9+h/uBT/oP8Gh888J2OZSbjSeWcg==",
      "license": "MIT",
      "dependencies": {
        "@inquirer/figures": "^1.0.6",
        "@inquirer/type": "^2.0.0",
        "@types/mute-stream": "^0.0.4",
        "@types/node": "^22.5.5",
        "@types/wrap-ansi": "^3.0.0",
        "ansi-escapes": "^4.3.2",
        "cli-width": "^4.1.0",
        "mute-stream": "^1.0.0",
        "signal-exit": "^4.1.0",
        "strip-ansi": "^6.0.1",
        "wrap-ansi": "^6.2.0",
        "yoctocolors-cjs": "^2.1.2"
      },
      "engines": {
        "node": ">=18"
      }
    },
    "node_modules/@inquirer/editor": {
      "version": "3.0.1",
      "resolved": "https://registry.npmjs.org/@inquirer/editor/-/editor-3.0.1.tgz",
      "integrity": "sha512-VA96GPFaSOVudjKFraokEEmUQg/Lub6OXvbIEZU1SDCmBzRkHGhxoFAVaF30nyiB4m5cEbDgiI2QRacXZ2hw9Q==",
      "license": "MIT",
      "dependencies": {
        "@inquirer/core": "^9.2.1",
        "@inquirer/type": "^2.0.0",
        "external-editor": "^3.1.0"
      },
      "engines": {
        "node": ">=18"
      }
    },
    "node_modules/@inquirer/expand": {
      "version": "3.0.1",
      "resolved": "https://registry.npmjs.org/@inquirer/expand/-/expand-3.0.1.tgz",
      "integrity": "sha512-ToG8d6RIbnVpbdPdiN7BCxZGiHOTomOX94C2FaT5KOHupV40tKEDozp12res6cMIfRKrXLJyexAZhWVHgbALSQ==",
      "license": "MIT",
      "dependencies": {
        "@inquirer/core": "^9.2.1",
        "@inquirer/type": "^2.0.0",
        "yoctocolors-cjs": "^2.1.2"
      },
      "engines": {
        "node": ">=18"
      }
    },
    "node_modules/@inquirer/figures": {
      "version": "1.0.15",
      "resolved": "https://registry.npmjs.org/@inquirer/figures/-/figures-1.0.15.tgz",
      "integrity": "sha512-t2IEY+unGHOzAaVM5Xx6DEWKeXlDDcNPeDyUpsRc6CUhBfU3VQOEl+Vssh7VNp1dR8MdUJBWhuObjXCsVpjN5g==",
      "license": "MIT",
      "engines": {
        "node": ">=18"
      }
    },
    "node_modules/@inquirer/input": {
      "version": "3.0.1",
      "resolved": "https://registry.npmjs.org/@inquirer/input/-/input-3.0.1.tgz",
      "integrity": "sha512-BDuPBmpvi8eMCxqC5iacloWqv+5tQSJlUafYWUe31ow1BVXjW2a5qe3dh4X/Z25Wp22RwvcaLCc2siHobEOfzg==",
      "license": "MIT",
      "dependencies": {
        "@inquirer/core": "^9.2.1",
        "@inquirer/type": "^2.0.0"
      },
      "engines": {
        "node": ">=18"
      }
    },
    "node_modules/@inquirer/number": {
      "version": "2.0.1",
      "resolved": "https://registry.npmjs.org/@inquirer/number/-/number-2.0.1.tgz",
      "integrity": "sha512-QpR8jPhRjSmlr/mD2cw3IR8HRO7lSVOnqUvQa8scv1Lsr3xoAMMworcYW3J13z3ppjBFBD2ef1Ci6AE5Qn8goQ==",
      "license": "MIT",
      "dependencies": {
        "@inquirer/core": "^9.2.1",
        "@inquirer/type": "^2.0.0"
      },
      "engines": {
        "node": ">=18"
      }
    },
    "node_modules/@inquirer/password": {
      "version": "3.0.1",
      "resolved": "https://registry.npmjs.org/@inquirer/password/-/password-3.0.1.tgz",
      "integrity": "sha512-haoeEPUisD1NeE2IanLOiFr4wcTXGWrBOyAyPZi1FfLJuXOzNmxCJPgUrGYKVh+Y8hfGJenIfz5Wb/DkE9KkMQ==",
      "license": "MIT",
      "dependencies": {
        "@inquirer/core": "^9.2.1",
        "@inquirer/type": "^2.0.0",
        "ansi-escapes": "^4.3.2"
      },
      "engines": {
        "node": ">=18"
      }
    },
    "node_modules/@inquirer/prompts": {
      "version": "6.0.1",
      "resolved": "https://registry.npmjs.org/@inquirer/prompts/-/prompts-6.0.1.tgz",
      "integrity": "sha512-yl43JD/86CIj3Mz5mvvLJqAOfIup7ncxfJ0Btnl0/v5TouVUyeEdcpknfgc+yMevS/48oH9WAkkw93m7otLb/A==",
      "license": "MIT",
      "dependencies": {
        "@inquirer/checkbox": "^3.0.1",
        "@inquirer/confirm": "^4.0.1",
        "@inquirer/editor": "^3.0.1",
        "@inquirer/expand": "^3.0.1",
        "@inquirer/input": "^3.0.1",
        "@inquirer/number": "^2.0.1",
        "@inquirer/password": "^3.0.1",
        "@inquirer/rawlist": "^3.0.1",
        "@inquirer/search": "^2.0.1",
        "@inquirer/select": "^3.0.1"
      },
      "engines": {
        "node": ">=18"
      }
    },
    "node_modules/@inquirer/rawlist": {
      "version": "3.0.1",
      "resolved": "https://registry.npmjs.org/@inquirer/rawlist/-/rawlist-3.0.1.tgz",
      "integrity": "sha512-VgRtFIwZInUzTiPLSfDXK5jLrnpkuSOh1ctfaoygKAdPqjcjKYmGh6sCY1pb0aGnCGsmhUxoqLDUAU0ud+lGXQ==",
      "license": "MIT",
      "dependencies": {
        "@inquirer/core": "^9.2.1",
        "@inquirer/type": "^2.0.0",
        "yoctocolors-cjs": "^2.1.2"
      },
      "engines": {
        "node": ">=18"
      }
    },
    "node_modules/@inquirer/search": {
      "version": "2.0.1",
      "resolved": "https://registry.npmjs.org/@inquirer/search/-/search-2.0.1.tgz",
      "integrity": "sha512-r5hBKZk3g5MkIzLVoSgE4evypGqtOannnB3PKTG9NRZxyFRKcfzrdxXXPcoJQsxJPzvdSU2Rn7pB7lw0GCmGAg==",
      "license": "MIT",
      "dependencies": {
        "@inquirer/core": "^9.2.1",
        "@inquirer/figures": "^1.0.6",
        "@inquirer/type": "^2.0.0",
        "yoctocolors-cjs": "^2.1.2"
      },
      "engines": {
        "node": ">=18"
      }
    },
    "node_modules/@inquirer/select": {
      "version": "3.0.1",
      "resolved": "https://registry.npmjs.org/@inquirer/select/-/select-3.0.1.tgz",
      "integrity": "sha512-lUDGUxPhdWMkN/fHy1Lk7pF3nK1fh/gqeyWXmctefhxLYxlDsc7vsPBEpxrfVGDsVdyYJsiJoD4bJ1b623cV1Q==",
      "license": "MIT",
      "dependencies": {
        "@inquirer/core": "^9.2.1",
        "@inquirer/figures": "^1.0.6",
        "@inquirer/type": "^2.0.0",
        "ansi-escapes": "^4.3.2",
        "yoctocolors-cjs": "^2.1.2"
      },
      "engines": {
        "node": ">=18"
      }
    },
    "node_modules/@inquirer/type": {
      "version": "2.0.0",
      "resolved": "https://registry.npmjs.org/@inquirer/type/-/type-2.0.0.tgz",
      "integrity": "sha512-XvJRx+2KR3YXyYtPUUy+qd9i7p+GO9Ko6VIIpWlBrpWwXDv8WLFeHTxz35CfQFUiBMLXlGHhGzys7lqit9gWag==",
      "license": "MIT",
      "dependencies": {
        "mute-stream": "^1.0.0"
      },
      "engines": {
        "node": ">=18"
      }
    },
    "node_modules/@types/mute-stream": {
      "version": "0.0.4",
      "resolved": "https://registry.npmjs.org/@types/mute-stream/-/mute-stream-0.0.4.tgz",
      "integrity": "sha512-CPM9nzrCPPJHQNA9keH9CVkVI+WR5kMa+7XEs5jcGQ0VoAGnLv242w8lIVgwAEfmE4oufJRaTc9PNLQl0ioAow==",
      "license": "MIT",
      "dependencies": {
        "@types/node": "*"
      }
    },
    "node_modules/@types/node": {
      "version": "22.20.3",
      "resolved": "https://registry.npmjs.org/@types/node/-/node-22.20.3.tgz",
      "integrity": "sha512-DZmzkmwHzXrLPAXPyKNDzlIwMMUZCVacoD25ywdy5YTKGbOx/2ld+Q38Im2zJ0vBuZP5Prd3VZutKZyXwkOS8A==",
      "license": "MIT",
      "dependencies": {
        "undici-types": "~6.21.0"
      }
    },
    "node_modules/@types/wrap-ansi": {
      "version": "3.0.0",
      "resolved": "https://registry.npmjs.org/@types/wrap-ansi/-/wrap-ansi-3.0.0.tgz",
      "integrity": "sha512-ltIpx+kM7g/MLRZfkbL7EsCEjfzCcScLpkg37eXEtx5kmrAKBkTJwd1GIAjDSL8wTpM6Hzn5YO4pSb91BEwu1g==",
      "license": "MIT"
    },
    "node_modules/ansi-escapes": {
      "version": "4.3.2",
      "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz",
      "integrity": "sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ==",
      "license": "MIT",
      "dependencies": {
        "type-fest": "^0.21.3"
      },
      "engines": {
        "node": ">=8"
      },
      "funding": {
        "url": "https://github.com/sponsors/sindresorhus"
      }
    },
    "node_modules/ansi-regex": {
      "version": "5.0.1",
      "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
      "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
      "license": "MIT",
      "engines": {
        "node": ">=8"
      }
    },
    "node_modules/ansi-styles": {
      "version": "4.3.0",
      "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
      "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
      "license": "MIT",
      "dependencies": {
        "color-convert": "^2.0.1"
      },
      "engines": {
        "node": ">=8"
      },
      "funding": {
        "url": "https://github.com/chalk/ansi-styles?sponsor=1"
      }
    },
    "node_modules/chardet": {
      "version": "0.7.0",
      "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz",
      "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==",
      "license": "MIT"
    },
    "node_modules/cli-width": {
      "version": "4.1.0",
      "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-4.1.0.tgz",
      "integrity": "sha512-ouuZd4/dm2Sw5Gmqy6bGyNNNe1qt9RpmxveLSO7KcgsTnU7RXfsw+/bukWGo1abgBiMAic068rclZsO4IWmmxQ==",
      "license": "ISC",
      "engines": {
        "node": ">= 12"
      }
    },
    "node_modules/color-convert": {
      "version": "2.0.1",
      "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
      "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
      "license": "MIT",
      "dependencies": {
        "color-name": "~1.1.4"
      },
      "engines": {
        "node": ">=7.0.0"
      }
    },
    "node_modules/color-name": {
      "version": "1.1.4",
      "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
      "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
      "license": "MIT"
    },
    "node_modules/emoji-regex": {
      "version": "8.0.0",
      "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
      "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==",
      "license": "MIT"
    },
    "node_modules/external-editor": {
      "version": "3.1.0",
      "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.1.0.tgz",
      "integrity": "sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew==",
      "license": "MIT",
      "dependencies": {
        "chardet": "^0.7.0",
        "iconv-lite": "^0.4.24",
        "tmp": "^0.0.33"
      },
      "engines": {
        "node": ">=4"
      }
    },
    "node_modules/iconv-lite": {
      "version": "0.4.24",
      "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
      "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
      "license": "MIT",
      "dependencies": {
        "safer-buffer": ">= 2.1.2 < 3"
      },
      "engines": {
        "node": ">=0.10.0"
      }
    },
    "node_modules/is-fullwidth-code-point": {
      "version": "3.0.0",
      "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz",
      "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==",
      "license": "MIT",
      "engines": {
        "node": ">=8"
      }
    },
    "node_modules/mute-stream": {
      "version": "1.0.0",
      "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-1.0.0.tgz",
      "integrity": "sha512-avsJQhyd+680gKXyG/sQc0nXaC6rBkPOfyHYcFb9+hdkqQkR9bdnkJ0AMZhke0oesPqIO+mFFJ+IdBc7mst4IA==",
      "license": "ISC",
      "engines": {
        "node": "^14.17.0 || ^16.13.0 || >=18.0.0"
      }
    },
    "node_modules/os-tmpdir": {
      "version": "1.0.2",
      "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz",
      "integrity": "sha512-D2FR03Vir7FIu45XBY20mTb+/ZSWB00sjU9jdQXt83gDrI4Ztz5Fs7/yy74g2N5SVQY4xY1qDr4rNddwYRVX0g==",
      "license": "MIT",
      "engines": {
        "node": ">=0.10.0"
      }
    },
    "node_modules/safer-buffer": {
      "version": "2.1.2",
      "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
      "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
      "license": "MIT"
    },
    "node_modules/signal-exit": {
      "version": "4.1.0",
      "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz",
      "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==",
      "license": "ISC",
      "engines": {
        "node": ">=14"
      },
      "funding": {
        "url": "https://github.com/sponsors/isaacs"
      }
    },
    "node_modules/string-width": {
      "version": "4.2.3",
      "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
      "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==",
      "license": "MIT",
      "dependencies": {
        "emoji-regex": "^8.0.0",
        "is-fullwidth-code-point": "^3.0.0",
        "strip-ansi": "^6.0.1"
      },
      "engines": {
        "node": ">=8"
      }
    },
    "node_modules/strip-ansi": {
      "version": "6.0.1",
      "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",
      "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
      "license": "MIT",
      "dependencies": {
        "ansi-regex": "^5.0.1"
      },
      "engines": {
        "node": ">=8"
      }
    },
    "node_modules/tmp": {
      "version": "0.0.33",
      "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz",
      "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==",
      "license": "MIT",
      "dependencies": {
        "os-tmpdir": "~1.0.2"
      },
      "engines": {
        "node": ">=0.6.0"
      }
    },
    "node_modules/type-fest": {
      "version": "0.21.3",
      "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.21.3.tgz",
      "integrity": "sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==",
      "license": "(MIT OR CC0-1.0)",
      "engines": {
        "node": ">=10"
      },
      "funding": {
        "url": "https://github.com/sponsors/sindresorhus"
      }
    },
    "node_modules/undici-types": {
      "version": "6.21.0",
      "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz",
      "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==",
      "license": "MIT"
    },
    "node_modules/wrap-ansi": {
      "version": "6.2.0",
      "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz",
      "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==",
      "license": "MIT",
      "dependencies": {
        "ansi-styles": "^4.0.0",
        "string-width": "^4.1.0",
        "strip-ansi": "^6.0.0"
      },
      "engines": {
        "node": ">=8"
      }
    },
    "node_modules/yoctocolors-cjs": {
      "version": "2.1.3",
      "resolved": "https://registry.npmjs.org/yoctocolors-cjs/-/yoctocolors-cjs-2.1.3.tgz",
      "integrity": "sha512-U/PBtDf35ff0D8X8D0jfdzHYEPFxAI7jJlxZXwCSez5M3190m+QobIfh+sWDWSHMCWWJN2AWamkegn6vr6YBTw==",
      "license": "MIT",
      "engines": {
        "node": ">=18"
      },
      "funding": {
        "url": "https://github.com/sponsors/sindresorhus"
      }
    }
  }
}
package.json
{
  "name": "sample-inquirer-prompts-separator",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "license": "MIT-0",
  "dependencies": {
    "@inquirer/prompts": "6.0.1"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify @inquirer/prompts.Separator in pkg:npm/%40inquirer/prompts@6.0.1",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40inquirer/prompts@6.0.1"
  ],
  "symbols": [
    "@inquirer/prompts.Separator"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import {
  Separator,
  createSeparator,
  isSeparator,
  filterSelectableChoices,
  getSeparators,
} from '../index.mjs';
import * as inquirerPrompts from '@inquirer/prompts';

// 1. assert Separator is exported as a class constructor from @inquirer/prompts
{
  assert.strictEqual(typeof Separator, 'function', 'Separator must be a constructor function');
  assert.strictEqual(Separator, inquirerPrompts.Separator, 'Separator must match @inquirer/prompts.Separator export');
}

// 2. assert new Separator() creates an instance with default visual separator and type 'separator'
{
  const sep = new Separator();
  assert.ok(sep instanceof Separator, 'sep must be an instance of Separator');
  assert.strictEqual(sep.type, 'separator', 'sep.type must equal "separator"');
  assert.strictEqual(typeof sep.separator, 'string', 'sep.separator must be a string');
  assert.ok(sep.separator.length > 0, 'sep.separator must not be empty');

  const helperSep = createSeparator();
  assert.ok(helperSep instanceof Separator, 'createSeparator() must return a Separator instance');
  assert.strictEqual(helperSep.type, 'separator');
}

// 3. assert new Separator(text) creates an instance with custom separator text and type 'separator'
{
  const customText = '--- Section Divider ---';
  const customSep = new Separator(customText);
  assert.ok(customSep instanceof Separator);
  assert.strictEqual(customSep.type, 'separator');
  assert.strictEqual(customSep.separator, customText, 'customSep.separator must match constructor text');

  const helperCustomSep = createSeparator(customText);
  assert.strictEqual(helperCustomSep.separator, customText);
}

// 4. assert Separator.isSeparator returns true for Separator instances and objects with type 'separator'
{
  const sep = new Separator();
  assert.strictEqual(Separator.isSeparator(sep), true, 'isSeparator must return true for Separator instance');
  assert.strictEqual(isSeparator(sep), true, 'helper isSeparator must return true for Separator instance');

  const duckTypeSeparator = { type: 'separator', separator: '===', line: 1 };
  assert.strictEqual(Separator.isSeparator(duckTypeSeparator), true, 'isSeparator must return true for objects with type "separator"');
}

// 5. assert Separator.isSeparator returns false for non-separator choice objects and primitive values
{
  const regularChoice = { name: 'Option A', value: 'opt_a' };
  assert.strictEqual(Separator.isSeparator(regularChoice), false, 'regular choice must not be separator');
  assert.strictEqual(isSeparator(regularChoice), false);

  assert.strictEqual(Separator.isSeparator(null), false, 'null is not separator');
  assert.strictEqual(Separator.isSeparator(undefined), false, 'undefined is not separator');
  assert.strictEqual(Separator.isSeparator('separator'), false, 'string is not separator');
  assert.strictEqual(Separator.isSeparator(123), false, 'number is not separator');
  assert.strictEqual(Separator.isSeparator({}), false, 'empty object is not separator');
  assert.strictEqual(Separator.isSeparator({ type: 'item' }), false, 'object with type "item" is not separator');
}

// 6. assert Separator items in choices collections can be identified and separated from selectable choices
{
  const choices = [
    { name: 'Apple', value: 'apple' },
    { name: 'Banana', value: 'banana' },
    new Separator('--- Vegetables ---'),
    { name: 'Carrot', value: 'carrot' },
    new Separator(),
  ];

  const selectable = filterSelectableChoices(choices);
  assert.strictEqual(selectable.length, 3, 'Must filter down to 3 selectable choices');
  assert.deepStrictEqual(selectable.map((c) => c.name), ['Apple', 'Banana', 'Carrot']);

  const separators = getSeparators(choices);
  assert.strictEqual(separators.length, 2, 'Must extract 2 separators');
  assert.strictEqual(separators[0].separator, '--- Vegetables ---');
  assert.strictEqual(separators[1].type, 'separator');
}

console.log('All @inquirer/prompts Separator contract assertions passed.');

原始种子者

匿名