示例
sisteransi 1.0.5: beep, cursor, erase
已验证示例 — npm sisteransi 1.0.5: beep, cursor, erase. contract 在 node 22 · linux alpine/x64 · docker 上运行并通过: beep returns ANSI audio bell escape code
sha256:5fae8172b0b60e66c27b81b20dd8bf4036edddbf57001e792a27cb3fc8a7d66f
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。
MIT-0
执行证据
声明的环境与签名的运行分开呈现,你可以看到这个样本究竟运行了什么、在哪里运行。
- 证据依据
- 签名契约通过
- 验证回执
- 2
- 构建过它的签名密钥
- 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-23 |
| 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 |
案例
HOW- 目标
- verify pkg:npm/sisteransi@1.0.5
- 符号
-
- sisteransi.beep
- sisteransi.cursor
- sisteransi.erase
- sisteransi.scroll
- 环境
- node 22.23.2
- 创建时间
- 2026-08-23T17:06:55Z
契约
- beep returns ANSI audio bell escape code
- cursor.to and cursor.move produce absolute and relative cursor positioning escape sequences
- cursor directional methods generate up, down, forward, backward, nextLine, and prevLine ANSI sequences
- cursor.hide, cursor.show, cursor.save, and cursor.restore produce cursor visibility and position save/restore escape sequences
- scroll.up and scroll.down generate terminal buffer scroll escape sequences
- erase.screen, erase.line, erase.lineEnd, erase.lineStart, and erase.lines generate display and line clearing ANSI sequences
文件
- PROMPT.md
- csx.json
- index.cjs
- package-lock.json
- package.json
- spec.json
- test/contract.cjs
源代码
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/sisteransi@1.0.5
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/sisteransi@1.0.5
Demonstrate these symbols/APIs:
- sisteransi.beep
- sisteransi.cursor
- sisteransi.erase
- sisteransi.scroll
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.
{"case":{"caseId":"case:sha256:2153332118adeef97613ce84b909edd29b36dfe62f66e21a99b4c23bef9444c1","constraints":{"executionContext":"node"},"contract":["beep returns ANSI audio bell escape code","cursor.to and cursor.move produce absolute and relative cursor positioning escape sequences","cursor directional methods generate up, down, forward, backward, nextLine, and prevLine ANSI sequences","cursor.hide, cursor.show, cursor.save, and cursor.restore produce cursor visibility and position save/restore escape sequences","scroll.up and scroll.down generate terminal buffer scroll escape sequences","erase.screen, erase.line, erase.lineEnd, erase.lineStart, and erase.lines generate display and line clearing ANSI sequences"],"goal":"verify pkg:npm/sisteransi@1.0.5","kind":"HOW","packages":["pkg:npm/sisteransi@1.0.5"],"schemaVersion":1,"symbols":["sisteransi.beep","sisteransi.cursor","sisteransi.erase","sisteransi.scroll"]},"contractCommand":["node","test/contract.cjs"],"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/sisteransi@1.0.5"],"schemaVersion":1,"subject":"pkg:npm/sisteransi@1.0.5","symbols":["sisteransi.beep","sisteransi.cursor","sisteransi.erase","sisteransi.scroll"],"verifierAdapter":"node-typescript@1"}
'use strict';
const ansi = require('sisteransi');
/**
* Demonstrates ANSI cursor navigation, screen/line erasing, scrolling, and bell signals using sisteransi.
*/
function getCursorPosition(x, y) {
return ansi.cursor.to(x, y);
}
function moveCursor(x, y) {
return ansi.cursor.move(x, y);
}
function clearLines(count) {
return ansi.erase.lines(count);
}
function scrollBuffer(direction, count = 1) {
if (direction === 'up') {
return ansi.scroll.up(count);
} else if (direction === 'down') {
return ansi.scroll.down(count);
}
throw new Error('Invalid scroll direction');
}
function getBeep() {
return ansi.beep;
}
module.exports = {
ansi,
getCursorPosition,
moveCursor,
clearLines,
scrollBuffer,
getBeep,
};
{
"name": "sample-sisteransi",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-sisteransi",
"version": "1.0.0",
"dependencies": {
"sisteransi": "1.0.5"
}
},
"node_modules/sisteransi": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz",
"integrity": "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==",
"license": "MIT"
}
}
}
{
"name": "sample-sisteransi",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification of sisteransi",
"dependencies": {
"sisteransi": "1.0.5"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/sisteransi@1.0.5",
"kind": "HOW",
"packages": [
"pkg:npm/sisteransi@1.0.5"
],
"symbols": [
"sisteransi.beep",
"sisteransi.cursor",
"sisteransi.erase",
"sisteransi.scroll"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
'use strict';
const assert = require('node:assert/strict');
const ansi = require('sisteransi');
const {
getCursorPosition,
moveCursor,
clearLines,
scrollBuffer,
getBeep,
} = require('../index.cjs');
// 1. sisteransi exports
assert.equal(typeof ansi, 'object', 'sisteransi must export an object');
assert.equal(typeof ansi.cursor, 'object', 'cursor must be an object');
assert.equal(typeof ansi.scroll, 'object', 'scroll must be an object');
assert.equal(typeof ansi.erase, 'object', 'erase must be an object');
assert.equal(typeof ansi.beep, 'string', 'beep must be a string');
// 2. Beep escape character
assert.equal(ansi.beep, '\u0007', 'beep matches ASCII BEL code');
assert.equal(getBeep(), '\u0007', 'getBeep returns ASCII BEL code');
// 3. Cursor positioning and movement
assert.equal(ansi.cursor.to(2), '\x1b[3G', 'cursor.to single coordinate (x)');
assert.equal(ansi.cursor.to(2, 1), '\x1b[2;3H', 'cursor.to x and y coordinates');
assert.equal(getCursorPosition(2, 1), '\x1b[2;3H', 'getCursorPosition helper');
assert.equal(ansi.cursor.move(2, -3), '\x1b[2C\x1b[3A', 'cursor.move forward and up');
assert.equal(ansi.cursor.move(-1, 4), '\x1b[1D\x1b[4B', 'cursor.move backward and down');
assert.equal(moveCursor(2, -3), '\x1b[2C\x1b[3A', 'moveCursor helper');
assert.equal(ansi.cursor.up(2), '\x1b[2A', 'cursor.up with count');
assert.equal(ansi.cursor.up(), '\x1b[1A', 'cursor.up default count');
assert.equal(ansi.cursor.down(3), '\x1b[3B', 'cursor.down with count');
assert.equal(ansi.cursor.forward(4), '\x1b[4C', 'cursor.forward with count');
assert.equal(ansi.cursor.backward(1), '\x1b[1D', 'cursor.backward with count');
assert.equal(ansi.cursor.nextLine(2), '\x1b[E\x1b[E', 'cursor.nextLine with count');
assert.equal(ansi.cursor.prevLine(1), '\x1b[F', 'cursor.prevLine with count');
assert.equal(ansi.cursor.left, '\x1b[G', 'cursor.left');
assert.equal(ansi.cursor.hide, '\x1b[?25l', 'cursor.hide');
assert.equal(ansi.cursor.show, '\x1b[?25h', 'cursor.show');
assert.equal(ansi.cursor.save, '\x1b7', 'cursor.save');
assert.equal(ansi.cursor.restore, '\x1b8', 'cursor.restore');
// 4. Scroll operations
assert.equal(ansi.scroll.up(), '\x1b[S', 'scroll.up default count');
assert.equal(ansi.scroll.up(2), '\x1b[S\x1b[S', 'scroll.up with count');
assert.equal(ansi.scroll.down(2), '\x1b[T\x1b[T', 'scroll.down with count');
assert.equal(scrollBuffer('up', 2), '\x1b[S\x1b[S', 'scrollBuffer helper up');
assert.equal(scrollBuffer('down', 1), '\x1b[T', 'scrollBuffer helper down');
assert.throws(() => scrollBuffer('left'), /Invalid scroll direction/);
// 5. Erase operations
assert.equal(ansi.erase.screen, '\x1b[2J', 'erase.screen');
assert.equal(ansi.erase.up(2), '\x1b[1J\x1b[1J', 'erase.up with count');
assert.equal(ansi.erase.down(1), '\x1b[J', 'erase.down with count');
assert.equal(ansi.erase.line, '\x1b[2K', 'erase.line');
assert.equal(ansi.erase.lineEnd, '\x1b[K', 'erase.lineEnd');
assert.equal(ansi.erase.lineStart, '\x1b[1K', 'erase.lineStart');
assert.equal(ansi.erase.lines(0), '', 'erase.lines 0');
assert.equal(ansi.erase.lines(2), '\x1b[2K\x1b[1A\x1b[2K\x1b[G', 'erase.lines 2');
assert.equal(clearLines(2), '\x1b[2K\x1b[1A\x1b[2K\x1b[G', 'clearLines helper');
console.log('Contract test passed.');
原始种子者
匿名