Exemple
github.com/manifoldco/promptui v0.9.0: Prompt
Échantillon vérifié pour golang github.com/manifoldco/promptui v0.9.0: Prompt. Le contrat s'est exécuté sur go 1.26 · linux alpine/x64 · docker et a réussi.
sha256:099871f2f46c7ddce3b638b0f7f92de81ff7a56dd54c158be1cce506d75fd828
Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré.
Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes.
MIT-0
Preuves d'exécution
L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.
- Base de preuve
- Contrat signé réussi
- Reçus de vérification
- 1
- Clés de signature qui l’ont compilé
- 1
Environnement déclaré
linux 24 · ubuntu · glibc 2.39 x64 go
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| 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 |
Cas
HOW- Objectif
- verify github.com/manifoldco/promptui.Prompt in pkg:golang/github.com/manifoldco/promptui@v0.9.0
- Symboles
-
- github.com/manifoldco/promptui.Prompt
- Créé
- 2026-08-28T00:51:59Z
Contrat
- promptui.Prompt runs text input prompt and returns entered string
- promptui.Prompt with Default uses default value when empty input is submitted
- promptui.Prompt with Validate validates user input using ValidateFunc and rejects invalid values
- promptui.Prompt with Mask hides characters for confidential input
- promptui.Prompt with IsConfirm handles yes/no confirmation prompts
- promptui.Prompt with PromptTemplates renders custom prompt formatting with template colors
Fichiers
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract.go
Code source
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 github.com/manifoldco/promptui.Prompt in pkg:golang/github.com/manifoldco/promptui@v0.9.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/manifoldco/promptui@v0.9.0
Demonstrate these symbols/APIs:
- github.com/manifoldco/promptui.Prompt
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:522bb7d7618db98b7f6bbb28e3ed12137e1a14c25b0a61ca2656413678666d69","contract":["promptui.Prompt runs text input prompt and returns entered string","promptui.Prompt with Default uses default value when empty input is submitted","promptui.Prompt with Validate validates user input using ValidateFunc and rejects invalid values","promptui.Prompt with Mask hides characters for confidential input","promptui.Prompt with IsConfirm handles yes/no confirmation prompts","promptui.Prompt with PromptTemplates renders custom prompt formatting with template colors"],"goal":"verify github.com/manifoldco/promptui.Prompt in pkg:golang/github.com/manifoldco/promptui@v0.9.0","kind":"HOW","packages":["pkg:golang/github.com/manifoldco/promptui@v0.9.0"],"schemaVersion":1,"symbols":["github.com/manifoldco/promptui.Prompt"]},"contractCommand":["go","run","./test"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"golang","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"go","schemaVersion":1},"license":"MIT-0","packages":["pkg:golang/github.com/manifoldco/promptui@v0.9.0"],"schemaVersion":1,"subject":"pkg:golang/github.com/manifoldco/promptui@v0.9.0","symbols":["github.com/manifoldco/promptui.Prompt"],"verifierAdapter":"golang@1"}
module sample
go 1.26.6
require github.com/manifoldco/promptui v0.9.0
require (
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e // indirect
golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b // indirect
)
github.com/chzyer/logex v1.1.10 h1:Swpa1K6QvQznwJRcfTfQJmTE72DqScAa40E+fbHEXEE=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e h1:fY5BOSpyZCqRo5OhCuC+XN+r/bBCmeuuJtjz+bCNIf8=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1 h1:q763qf9huN11kDQavWsoZXJNW3xEE4JJyHa5Q25/sd8=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
github.com/manifoldco/promptui v0.9.0 h1:3V4HzJk1TtXW1MTZMP7mdlwbBpIinw3HztaIlYthEiA=
github.com/manifoldco/promptui v0.9.0/go.mod h1:ka04sppxSGFAtxX0qhlYQjISsg9mR4GWtQEhdbn6Pgg=
golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b h1:MQE+LT/ABUuuvEZ+YQAMSXindAdUh7slEmAkup74op4=
golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
package main
import (
"fmt"
"github.com/manifoldco/promptui"
)
func main() {
prompt := promptui.Prompt{
Label: "Username",
}
fmt.Printf("Configured prompt with label %q\n", prompt.Label)
}
{
"schemaVersion": 1,
"goal": "verify github.com/manifoldco/promptui.Prompt in pkg:golang/github.com/manifoldco/promptui@v0.9.0",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/manifoldco/promptui@v0.9.0"
],
"symbols": [
"github.com/manifoldco/promptui.Prompt"
]
}
package main
import (
"bytes"
"errors"
"fmt"
"io"
"os"
"strings"
"github.com/manifoldco/promptui"
)
type nopWriteCloser struct {
io.Writer
}
func (n nopWriteCloser) Close() error { return nil }
func main() {
if err := runContract(); err != nil {
fmt.Fprintf(os.Stderr, "Contract verification failed: %v\n", err)
os.Exit(1)
}
fmt.Println("All promptui.Prompt contract assertions passed successfully.")
}
func runContract() error {
// 1. promptui.Prompt runs text input prompt and returns entered string
var out1 bytes.Buffer
p1 := promptui.Prompt{
Label: "Username",
Stdin: io.NopCloser(strings.NewReader("octocat\n")),
Stdout: nopWriteCloser{&out1},
}
val1, err := p1.Run()
if err != nil {
return fmt.Errorf("p1.Run failed: %w", err)
}
if val1 != "octocat" {
return fmt.Errorf("expected val1 'octocat', got %q", val1)
}
// 2. promptui.Prompt with Default uses default value when empty input is submitted
var out2 bytes.Buffer
p2 := promptui.Prompt{
Label: "Port",
Default: "8080",
Stdin: io.NopCloser(strings.NewReader("\r\n")),
Stdout: nopWriteCloser{&out2},
}
val2, err := p2.Run()
if err != nil {
return fmt.Errorf("p2.Run failed: %w", err)
}
if val2 != "8080" {
return fmt.Errorf("expected default '8080', got %q", val2)
}
// 3. promptui.Prompt with Validate validates user input using ValidateFunc and rejects invalid values
validateEmail := func(s string) error {
if !strings.Contains(s, "@") {
return errors.New("missing @ symbol")
}
return nil
}
if err := validateEmail("invalid-email"); err == nil {
return fmt.Errorf("expected validation failure for invalid email")
}
if err := validateEmail("dev@example.com"); err != nil {
return fmt.Errorf("expected validation success for valid email, got: %w", err)
}
var out3 bytes.Buffer
p3 := promptui.Prompt{
Label: "Email",
Validate: validateEmail,
Stdin: io.NopCloser(strings.NewReader("dev@example.com\n")),
Stdout: nopWriteCloser{&out3},
}
val3, err := p3.Run()
if err != nil {
return fmt.Errorf("p3.Run failed: %w", err)
}
if val3 != "dev@example.com" {
return fmt.Errorf("expected email 'dev@example.com', got %q", val3)
}
// 4. promptui.Prompt with Mask hides characters for confidential input
var out4 bytes.Buffer
p4 := promptui.Prompt{
Label: "Password",
Mask: '*',
Stdin: io.NopCloser(strings.NewReader("secret123\n")),
Stdout: nopWriteCloser{&out4},
}
val4, err := p4.Run()
if err != nil {
return fmt.Errorf("p4.Run failed: %w", err)
}
if val4 != "secret123" {
return fmt.Errorf("expected mask prompt value 'secret123', got %q", val4)
}
// 5. promptui.Prompt with IsConfirm handles yes/no confirmation prompts
var out5 bytes.Buffer
p5 := promptui.Prompt{
Label: "Continue",
IsConfirm: true,
Stdin: io.NopCloser(strings.NewReader("y\n")),
Stdout: nopWriteCloser{&out5},
}
val5, err := p5.Run()
if err != nil {
return fmt.Errorf("p5.Run failed: %w", err)
}
if val5 != "y" && val5 != "Y" {
return fmt.Errorf("expected confirmation 'y' or 'Y', got %q", val5)
}
// 6. promptui.Prompt with PromptTemplates renders custom prompt formatting with template colors
var out6 bytes.Buffer
p6 := promptui.Prompt{
Label: "Custom Prompt",
Templates: &promptui.PromptTemplates{
Prompt: "{{ . | bold }} ",
Valid: "{{ . | green }} ",
Invalid: "{{ . | red }} ",
Success: "{{ . | bold | green }} ",
},
Stdin: io.NopCloser(strings.NewReader("custom-value\n")),
Stdout: nopWriteCloser{&out6},
}
val6, err := p6.Run()
if err != nil {
return fmt.Errorf("p6.Run failed: %w", err)
}
if val6 != "custom-value" {
return fmt.Errorf("expected custom prompt value 'custom-value', got %q", val6)
}
return nil
}
Seeder d'origine
anonyme