Пример
github.com/chzyer/readline v1.5.1
Проверенный пример — golang github.com/chzyer/readline v1.5.1. Контракт выполнен на go 1.26 · linux alpine/x64 · docker и пройден.
sha256:c319db16fa04a7093c88cf05f5f71c9733f1d454989569c3ff0e00c1f243369c
Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла.
Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди.
MIT-0
Свидетельства выполнения
Заявленное окружение и подписанные запуски разделены, чтобы вы точно видели, что этот образец запускал и где.
- Основа свидетельства
- Подписанный контракт пройден
- Квитанции проверки
- 1
- Ключи подписи, собравшие его
- 1
Заявленная среда
go 1.26 linux 24 · ubuntu · glibc 2.39 amd64 go 1.26 go 1.26 go 1
Среды запусков проверки
| Окружение | Контракт | Этапы | Запуск |
|---|---|---|---|
| go 1.26 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · golang@1golang:1.26-alpine@sha256:28d89ee9cc0f… |
2026-08-28 |
Кейс
HOW- Цель
- verify pkg:golang/github.com/chzyer/readline@v1.5.1
- Окружение
- go 1.26.6
- Создан
- 2026-08-28T02:12:14Z
Контракт
- readline.PcItemDynamic dynamically computes candidate completions based on input prefix
- readline.NewFillableStdin creates fillable input streams for interactive input simulation
- readline.Instance.ReadlineWithDefault pre-populates the input line with a default value
- readline.Config with EnableMask and MaskRune configures masked input for sensitive data
- readline.FuncListener creates a listener that intercepts and modifies input events
- readline.Instance.SaveHistory and ResetHistory manage readline command history
Файлы
- PROMPT.md
- contract_test.go
- csx.json
- go.mod
- go.sum
- sample.go
- spec.json
Исходный код
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:golang/github.com/chzyer/readline@v1.5.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/chzyer/readline@v1.5.1
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.
package sample
import (
"bytes"
"io"
"os"
"strings"
"testing"
"time"
"github.com/chzyer/readline"
)
func TestContractReadline(t *testing.T) {
// 1. Verify readline.PcItemDynamic computes candidate completions dynamically
dynamicCompleter := NewDynamicCompleter(func(line string) []string {
return []string{"alpha", "alpine", "beta"}
})
cands, length := dynamicCompleter.Do([]rune("al"), 2)
if length != 2 {
t.Fatalf("expected prefix length 2, got %d", length)
}
if len(cands) != 2 {
t.Fatalf("expected 2 candidates for 'al', got %d: %v", len(cands), cands)
}
if string(cands[0]) != "pha " || string(cands[1]) != "pine " {
t.Fatalf("expected ['pha ', 'pine '], got %q, %q", string(cands[0]), string(cands[1]))
}
// 2. Verify readline.NewFillableStdin creates fillable input streams
pr, pw := io.Pipe()
defer pr.Close()
defer pw.Close()
fillableStdin, fillableWriter := readline.NewFillableStdin(pr)
defer fillableStdin.Close()
var stdout bytes.Buffer
cfg := &readline.Config{
Prompt: "> ",
Stdin: fillableStdin,
Stdout: &stdout,
Stderr: io.Discard,
}
rl, err := readline.NewEx(cfg)
if err != nil {
t.Fatalf("readline.NewEx failed: %v", err)
}
defer rl.Close()
if _, err := fillableWriter.Write([]byte("stream-input\n")); err != nil {
t.Fatalf("fillableWriter.Write failed: %v", err)
}
time.Sleep(10 * time.Millisecond)
line, err := rl.Readline()
if err != nil {
t.Fatalf("rl.Readline() failed: %v", err)
}
if line != "stream-input" {
t.Fatalf("expected 'stream-input', got %q", line)
}
// 3. Verify readline.Instance.ReadlineWithDefault pre-populates the input line with a default value
defaultStdin := io.NopCloser(strings.NewReader("\n"))
var defaultStdout bytes.Buffer
defaultCfg := &readline.Config{
Prompt: "> ",
Stdin: defaultStdin,
Stdout: &defaultStdout,
Stderr: io.Discard,
}
defaultRl, err := readline.NewEx(defaultCfg)
if err != nil {
t.Fatalf("readline.NewEx for default failed: %v", err)
}
defer defaultRl.Close()
defLine, err := ReadWithDefault(defaultRl, "prefilled-value")
if err != nil {
t.Fatalf("ReadWithDefault failed: %v", err)
}
if defLine != "prefilled-value" {
t.Fatalf("expected 'prefilled-value', got %q", defLine)
}
// 4. Verify readline masked input configuration with EnableMask and MaskRune
var maskStdout bytes.Buffer
maskRl, err := NewMaskedReadline("Pass: ", '*', strings.NewReader("secret\n"), &maskStdout)
if err != nil {
t.Fatalf("NewMaskedReadline failed: %v", err)
}
defer maskRl.Close()
if !maskRl.Config.EnableMask {
t.Fatalf("expected EnableMask true")
}
if maskRl.Config.MaskRune != '*' {
t.Fatalf("expected MaskRune '*', got %c", maskRl.Config.MaskRune)
}
maskRl.SetMaskRune('#')
if maskRl.Config.MaskRune != '#' {
t.Fatalf("expected updated MaskRune '#', got %c", maskRl.Config.MaskRune)
}
// 5. Verify readline.FuncListener creates a Listener that intercepts input events
listener := NewListener(func(line []rune, pos int, key rune) ([]rune, int, bool) {
return append(line, '!'), pos + 1, true
})
newLine, newPos, ok := listener.OnChange([]rune("hello"), 5, 'a')
if !ok {
t.Fatalf("expected listener OnChange ok=true")
}
if string(newLine) != "hello!" || newPos != 6 {
t.Fatalf("expected 'hello!' and pos 6, got %q and pos %d", string(newLine), newPos)
}
// 6. Verify readline command history operations
tempFile, err := os.CreateTemp("", "rl_history_*")
if err != nil {
t.Fatalf("CreateTemp failed: %v", err)
}
tempFilePath := tempFile.Name()
tempFile.Close()
defer os.Remove(tempFilePath)
historyStdin := io.NopCloser(strings.NewReader(""))
var historyStdout bytes.Buffer
historyCfg := &readline.Config{
Prompt: "> ",
Stdin: historyStdin,
Stdout: &historyStdout,
HistoryFile: tempFilePath,
}
historyRl, err := readline.NewEx(historyCfg)
if err != nil {
t.Fatalf("readline.NewEx for history failed: %v", err)
}
defer historyRl.Close()
if err := historyRl.SaveHistory("first-command"); err != nil {
t.Fatalf("historyRl.SaveHistory failed: %v", err)
}
historyRl.ResetHistory()
}
{"case":{"caseId":"case:sha256:a292b041c2f12c7c604e5366c28381b4e3554d18e7226293f7e26442314b610c","contract":["readline.PcItemDynamic dynamically computes candidate completions based on input prefix","readline.NewFillableStdin creates fillable input streams for interactive input simulation","readline.Instance.ReadlineWithDefault pre-populates the input line with a default value","readline.Config with EnableMask and MaskRune configures masked input for sensitive data","readline.FuncListener creates a listener that intercepts and modifies input events","readline.Instance.SaveHistory and ResetHistory manage readline command history"],"goal":"verify pkg:golang/github.com/chzyer/readline@v1.5.1","kind":"HOW","packages":["pkg:golang/github.com/chzyer/readline@v1.5.1"],"schemaVersion":1},"contractCommand":["go","test","./..."],"environment":{"arch":"amd64","compiler":"go","compilerVersion":"1.26.6","distro":"ubuntu","ecosystem":"golang","language":"go","languageVersion":"1.26.6","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"go","packageManagerVersion":"1.26.6","runtime":"go","runtimeVersion":"1.26.6","schemaVersion":1},"license":"MIT-0","packages":["pkg:golang/github.com/chzyer/readline@v1.5.1"],"schemaVersion":1,"subject":"pkg:golang/github.com/chzyer/readline@v1.5.1","verifierAdapter":"golang@1"}
module example.com/sample
go 1.26.6
require github.com/chzyer/readline v1.5.1
require golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5 // indirect
github.com/chzyer/logex v1.2.1 h1:XHDu3E6q+gdHgsdTPH6ImJMIp436vR6MPtH8gP05QzM=
github.com/chzyer/logex v1.2.1/go.mod h1:JLbx6lG2kDbNRFnfkgvh4eRJRPX1QCoOIWomwysCBrQ=
github.com/chzyer/readline v1.5.1 h1:upd/6fQk4src78LMRzh5vItIt361/o4uq553V8B5sGI=
github.com/chzyer/readline v1.5.1/go.mod h1:Eh+b79XXUwfKfcPLepksvw2tcLE/Ct21YObkaSkeBlk=
github.com/chzyer/test v1.0.0 h1:p3BQDXSxOhOG0P9z6/hGnII4LGiEPOYBhs8asl/fC04=
github.com/chzyer/test v1.0.0/go.mod h1:2JlltgoNkt4TW/z9V/IzDdFaMTM2JPIi26O1pF38GC8=
golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5 h1:y/woIyUBFbpQGKS0u1aHF/40WUDnek3fPOyD08H5Vng=
golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
package sample
import (
"io"
"github.com/chzyer/readline"
)
// NewDynamicCompleter creates a PrefixCompleter that evaluates candidate items dynamically.
func NewDynamicCompleter(callback readline.DynamicCompleteFunc) *readline.PrefixCompleter {
return readline.NewPrefixCompleter(
readline.PcItemDynamic(callback),
)
}
// NewMaskedReadline creates a Readline instance configured to mask sensitive input with maskRune.
func NewMaskedReadline(prompt string, mask rune, r io.Reader, w io.Writer) (*readline.Instance, error) {
cfg := &readline.Config{
Prompt: prompt,
Stdin: io.NopCloser(r),
Stdout: w,
Stderr: io.Discard,
EnableMask: true,
MaskRune: mask,
}
return readline.NewEx(cfg)
}
// ReadWithDefault reads a line from the readline instance, using defaultVal as the initial line buffer.
func ReadWithDefault(rl *readline.Instance, defaultVal string) (string, error) {
return rl.ReadlineWithDefault(defaultVal)
}
// NewListener creates a readline.Listener from a callback function.
func NewListener(fn func(line []rune, pos int, key rune) (newLine []rune, newPos int, ok bool)) readline.Listener {
return readline.FuncListener(fn)
}
{
"schemaVersion": 1,
"goal": "verify pkg:golang/github.com/chzyer/readline@v1.5.1",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/chzyer/readline@v1.5.1"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
Исходный сидер
аноним