CodeSampleX

샘플

sisteransi 1.0.5: beep, cursor, erase

검증된 샘플 — npm sisteransi 1.0.5: beep, cursor, erase. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: beep returns ANSI audio bell escape code

sha256:5fae8172b0b60e66c27b81b20dd8bf4036edddbf57001e792a27cb3fc8a7d66f

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. 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

컨트랙트

  1. beep returns ANSI audio bell escape code
  2. cursor.to and cursor.move produce absolute and relative cursor positioning escape sequences
  3. cursor directional methods generate up, down, forward, backward, nextLine, and prevLine ANSI sequences
  4. cursor.hide, cursor.show, cursor.save, and cursor.restore produce cursor visibility and position save/restore escape sequences
  5. scroll.up and scroll.down generate terminal buffer scroll escape sequences
  6. 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

소스 아티팩트 내려받기 (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/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.
csx.json
{"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"}
index.cjs
'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,
};
package-lock.json
{
  "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"
    }
  }
}
package.json
{
  "name": "sample-sisteransi",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification of sisteransi",
  "dependencies": {
    "sisteransi": "1.0.5"
  }
}
spec.json
{
  "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"
  }
}
test/contract.cjs
'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.');

오리진 시더

익명