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/capstone/exercise/scan.go
View on GitHubpackage main
import (
"bytes"
"context"
"io"
"os"
)
// NoExt is the bucket for files with no extension — including dotfiles such as
// .gitignore, whose "extension" filepath.Ext reports is the whole name.
const NoExt = "(none)"
type ExtStat struct {
Ext string `json:"ext"`
Files int `json:"files"`
Lines int `json:"lines"`
Bytes int64 `json:"bytes"`
}
type ScanResult struct {
Root string `json:"root"`
Files int `json:"files"`
Lines int `json:"lines"`
Bytes int64 `json:"bytes"`
Exts []ExtStat `json:"exts"`
}
// Scan walks root and totals regular files by extension.
//
// It takes a context and returns a plain result: cancellation is the caller's
// concern, and the walk is the only thing in here that touches the disk.
//
// TODO: implement it with filepath.WalkDir.
// - Check ctx.Err() once per entry and return it — that is what turns Ctrl-C
// into a stopped walk.
// - Return fs.SkipDir for an ignored directory (prune, do not walk), and skip
// ignored file names and anything that is not a regular file.
// - Propagate the walk's errors; a missing root must still match
// fs.ErrNotExist.
// - Sort Exts busiest first, ties broken by name: map iteration order is
// random and a report that reshuffles itself cannot be diffed.
func Scan(ctx context.Context, root string, ignore []string) (ScanResult, error) {
return ScanResult{}, nil
}
// extOf buckets a file name.
//
// TODO: lowercase the extension; return NoExt for a name that has none — and
// for a dotfile, since filepath.Ext(".gitignore") is ".gitignore".
func extOf(name string) string {
return NoExt
}
// TopExts keeps the n busiest extensions; n <= 0 means all of them.
//
// TODO: implement.
func TopExts(exts []ExtStat, n int) []ExtStat {
return exts
}
// countFile returns the number of lines and bytes in one file. A line is a
// newline-terminated run of bytes, plus a final unterminated line if the file
// does not end with a newline — so "a\nb" is two lines and "" is none.
//
// Provided complete: this is the boring half of the walk.
func countFile(path string) (lines int, size int64, err error) {
f, err := os.Open(path)
if err != nil {
return 0, 0, err
}
defer f.Close()
buf := make([]byte, 32*1024)
var last byte
for {
n, readErr := f.Read(buf)
if n > 0 {
size += int64(n)
lines += bytes.Count(buf[:n], []byte{'\n'})
last = buf[n-1]
}
if readErr == io.EOF {
break
}
if readErr != nil {
return 0, 0, readErr
}
}
if size > 0 && last != '\n' {
lines++
}
return lines, size, nil
}
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 |