qtsone/learning / skills/tutor
tutor
FlaggedTurn this agent into a personal programming tutor with a versioned 0-to-expert curriculum (Go available; more languages coming). Use when the user wants to learn a programming language, start or resume lessons, get their exercise code graded, check learning progress, or contribute curriculum fixes — e.g. "/tutor go", "/tutor resume", "teach me Go", "continue my lessons", "grade my exercise".
curriculum/content/focus/cli-tooling/terminal-ux/solution/prompt.go
View on GitHubpackage main
import (
"bufio"
"errors"
"fmt"
"io"
"strings"
)
// MaxPromptAttempts is how many answers Ask will consider before giving up.
const MaxPromptAttempts = 3
// ErrNotInteractive means there is nobody to answer: the input stream is not a
// terminal and the question has no default. Callers should suggest the flag
// that supplies the value instead.
var ErrNotInteractive = errors.New("not interactive: no terminal to prompt on")
// ErrTooManyAttempts means every answer failed validation.
var ErrTooManyAttempts = errors.New("too many invalid answers")
// Prompter asks questions on an injected pair of streams. It owns one
// bufio.Scanner for the whole session: a fresh reader per question would keep
// the bytes it buffered past the newline and lose the next answer.
type Prompter struct {
sc *bufio.Scanner
out io.Writer
isTerminal bool
}
// NewPrompter reads answers from in and writes questions to out — in a real
// program the diagnostic stream, so that a prompt never lands in piped data.
func NewPrompter(in io.Reader, out io.Writer, isTerminal bool) *Prompter {
return &Prompter{sc: bufio.NewScanner(in), out: out, isTerminal: isTerminal}
}
// Ask puts one question to the user and returns the answer. See the package
// tests for the exact contract: default handling, validation retries, and the
// non-interactive fallback.
func (p *Prompter) Ask(question, def string, validate func(string) error) (string, error) {
if !p.isTerminal {
return fallback(def)
}
for range MaxPromptAttempts {
fmt.Fprint(p.out, promptLine(question, def))
if !p.sc.Scan() {
// The stream is exhausted (or broken): asking again would spin
// forever against an empty reader.
return fallback(def)
}
answer := strings.TrimSpace(p.sc.Text())
if answer == "" {
answer = def
}
if validate != nil {
if err := validate(answer); err != nil {
fmt.Fprintf(p.out, "error: %v\n", err)
continue
}
}
return answer, nil
}
return "", ErrTooManyAttempts
}
func fallback(def string) (string, error) {
if def == "" {
return "", ErrNotInteractive
}
return def, nil
}
func promptLine(question, def string) string {
if def == "" {
return question + ": "
}
return fmt.Sprintf("%s [%s]: ", question, def)
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |