Files
wehub-resource-sync 26f897c1ec
release / release-please (push) Failing after 1m49s
docs / build (push) Failing after 6m34s
release / build-and-upload (arm64, linux) (push) Has been cancelled
release / build-and-upload (arm64, windows) (push) Has been cancelled
release / build-darwin (amd64, darwin) (push) Has been cancelled
release / checksums (push) Has been cancelled
release / finalize (push) Has been cancelled
release / build-darwin (arm64, darwin) (push) Has been cancelled
release / build-and-upload (amd64, linux) (push) Has been cancelled
release / build-and-upload (amd64, windows) (push) Has been cancelled
docs / deploy (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:34:16 +08:00

57 lines
1.7 KiB
Go

// Command genskill renders the canonical no-mistakes SKILL.md from the
// internal/skill package into skills/no-mistakes/SKILL.md. The same rendering
// is what `no-mistakes init` installs into the user-level agent skill
// directories, so the committed file and the installed copies never drift.
//
// Usage:
//
// go run ./cmd/genskill # (re)write the skill file
// go run ./cmd/genskill --check # fail if the committed file is stale
//
// The --check form is meant for CI so the committed skill never drifts from
// the generator, which is the single source of truth.
package main
import (
"flag"
"fmt"
"os"
"path/filepath"
"github.com/kunchenguid/no-mistakes/internal/skill"
)
func main() {
check := flag.Bool("check", false, "verify the committed skill matches the generator instead of writing it")
flag.Parse()
// The canonical public skill that `npx skills add` discovers, relative to
// the repo root.
rel := filepath.Join("skills", skill.Name, "SKILL.md")
want := skill.Markdown()
if *check {
got, err := os.ReadFile(rel)
if err != nil {
fmt.Fprintf(os.Stderr, "genskill --check: read %s: %v\n", rel, err)
os.Exit(1)
}
if string(got) != want {
fmt.Fprintf(os.Stderr, "genskill --check: %s is stale; run `go run ./cmd/genskill` and commit the result\n", rel)
os.Exit(1)
}
fmt.Printf("genskill: %s is up to date\n", rel)
return
}
if err := os.MkdirAll(filepath.Dir(rel), 0o755); err != nil {
fmt.Fprintf(os.Stderr, "genskill: mkdir: %v\n", err)
os.Exit(1)
}
if err := os.WriteFile(rel, []byte(want), 0o644); err != nil {
fmt.Fprintf(os.Stderr, "genskill: write %s: %v\n", rel, err)
os.Exit(1)
}
fmt.Printf("genskill: wrote %s\n", rel)
}