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/files-processes/exercise/paths_test.go
View on GitHubpackage main
import (
"errors"
"os"
"path/filepath"
"strings"
"testing"
)
func TestAppDirJoinsAppOntoBase(t *testing.T) {
base := t.TempDir()
got, err := AppDir(func() (string, error) { return base, nil }, "runner")
if err != nil {
t.Fatalf("AppDir returned err = %v, want nil", err)
}
if want := filepath.Join(base, "runner"); got != want {
t.Errorf("AppDir = %q, want %q", got, want)
}
if _, err := os.Stat(got); !errors.Is(err, os.ErrNotExist) {
t.Errorf("AppDir created the directory; it must only compute the path")
}
}
func TestAppDirWrapsBaseFailure(t *testing.T) {
sentinel := errors.New("no home directory")
_, err := AppDir(func() (string, error) { return "", sentinel }, "runner")
if !errors.Is(err, sentinel) {
t.Fatalf("AppDir returned err = %v, want one wrapping the base error", err)
}
if !strings.Contains(err.Error(), "runner") {
t.Errorf("error = %q, want it to name the application", err)
}
}
func TestAppDirRejectsBadNames(t *testing.T) {
for _, app := range []string{"", "..", "a/b", "/etc", "."} {
t.Run(app, func(t *testing.T) {
_, err := AppDir(func() (string, error) { return "/base", nil }, app)
if !errors.Is(err, ErrUnsafePath) {
t.Errorf("AppDir(_, %q) returned err = %v, want one wrapping ErrUnsafePath",
app, err)
}
})
}
}
func TestAppDirWithRealUserDirs(t *testing.T) {
for name, base := range map[string]func() (string, error){
"config": os.UserConfigDir,
"cache": os.UserCacheDir,
} {
t.Run(name, func(t *testing.T) {
if _, err := base(); err != nil {
t.Skipf("this machine has no %s directory: %v", name, err)
}
got, err := AppDir(base, "runner")
if err != nil {
t.Fatalf("AppDir returned err = %v, want nil", err)
}
if !filepath.IsAbs(got) {
t.Errorf("AppDir = %q, want an absolute path", got)
}
if filepath.Base(got) != "runner" {
t.Errorf("AppDir = %q, want it to end in the application name", got)
}
if strings.Contains(got, "$") || strings.Contains(got, "~") {
t.Errorf("AppDir = %q — ask the os package, never hand-build a home path", got)
}
})
}
}
func TestSafeJoin(t *testing.T) {
root := filepath.Join("var", "data")
ok := []struct {
rel string
want string
}{
{"notes.txt", filepath.Join(root, "notes.txt")},
{"a/b/c.txt", filepath.Join(root, "a", "b", "c.txt")},
{"./a", filepath.Join(root, "a")},
{"a/../b", filepath.Join(root, "b")},
}
for _, c := range ok {
got, err := SafeJoin(root, c.rel)
if err != nil {
t.Errorf("SafeJoin(%q, %q) returned err = %v, want nil", root, c.rel, err)
continue
}
if got != c.want {
t.Errorf("SafeJoin(%q, %q) = %q, want %q", root, c.rel, got, c.want)
}
}
bad := []string{"", "..", "../etc/passwd", "a/../../etc", "/etc/passwd", "/"}
for _, rel := range bad {
got, err := SafeJoin(root, rel)
if !errors.Is(err, ErrUnsafePath) {
t.Errorf("SafeJoin(%q, %q) = %q, err = %v; want an error wrapping ErrUnsafePath",
root, rel, got, err)
continue
}
if rel != "" && !strings.Contains(err.Error(), rel) {
t.Errorf("error = %q, want it to name the rejected path %q", err, rel)
}
}
}
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: 470k | 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 |