Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 33 additions & 2 deletions labs/22-yield/yield/cmd/yskill/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,17 @@ func TestParseOnePositionalKeepsFlagFirstOrder(t *testing.T) {

func TestScaffoldSkillWritesLanguageSpecificEntrypoints(t *testing.T) {
previousVersion := version
previousTidyGoModule := tidyGoModule
version = "0.1.9"
t.Cleanup(func() { version = previousVersion })
tidyCalls := 0
tidyGoModule = func(string) error {
tidyCalls++
return nil
}
t.Cleanup(func() {
version = previousVersion
tidyGoModule = previousTidyGoModule
})

tests := []struct {
language string
Expand All @@ -64,7 +73,7 @@ func TestScaffoldSkillWritesLanguageSpecificEntrypoints(t *testing.T) {
}{
{"typescript", []string{"main.ts", "package.json", "skill.json"}, "npm exec -- yskill run .", `"@operatorstack/yield": "0.1.9"`},
{"python", []string{"main.py", "requirements.txt", "skill.json"}, "python -m yieldskill run .", "yieldskill==0.1.9"},
{"go", []string{"main.go", "go.mod"}, "yskill run .", "github.com/operatorstack/yield v0.1.9"},
{"go", []string{"main.go", "go.mod", "skill.json"}, "yskill run .", "github.com/operatorstack/yield v0.1.9"},
{"rust", []string{"src/main.rs", "Cargo.toml", ".cargo/config.toml", "skill.json"}, "yskill run .", `version = "=0.1.9"`},
}
for _, tt := range tests {
Expand Down Expand Up @@ -98,6 +107,28 @@ func TestScaffoldSkillWritesLanguageSpecificEntrypoints(t *testing.T) {
}
})
}
if tidyCalls != 1 {
t.Fatalf("go mod tidy calls = %d, want 1", tidyCalls)
}
}

func TestGoScaffoldCanResolveItsPinnedModuleOnFirstRun(t *testing.T) {
previousVersion := version
previousTidyGoModule := tidyGoModule
version = "0.1.9"
tidyGoModule = func(string) error { return nil }
t.Cleanup(func() {
version = previousVersion
tidyGoModule = previousTidyGoModule
})
dir := filepath.Join(t.TempDir(), "go-skill")
if err := scaffoldSkill(dir, "go", ""); err != nil {
t.Fatal(err)
}
manifest := readTestFile(t, filepath.Join(dir, "skill.json"))
if manifest != "{\"run\":[\"go\",\"run\",\"-mod=readonly\",\".\"]}\n" {
t.Fatalf("skill.json = %q", manifest)
}
}

func TestPythonScaffoldUsesInvokingInterpreter(t *testing.T) {
Expand Down
22 changes: 21 additions & 1 deletion labs/22-yield/yield/cmd/yskill/scaffold.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"fmt"
"os"
"os/exec"
"path/filepath"
"regexp"
"sort"
Expand All @@ -11,6 +12,16 @@ import (

var releaseVersionPattern = regexp.MustCompile(`^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$`)
var unsafePackageCharacter = regexp.MustCompile(`[^a-z0-9_-]+`)
var tidyGoModule = func(dir string) error {
cmd := exec.Command("go", "mod", "tidy")
cmd.Dir = dir
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err := cmd.Run(); err != nil {
return fmt.Errorf("prepare Go scaffold dependencies: %w", err)
}
return nil
}

func defaultLanguage() string {
if language := strings.TrimSpace(os.Getenv("YIELD_LANGUAGE")); language != "" {
Expand Down Expand Up @@ -69,6 +80,11 @@ func scaffoldSkill(dir, language, sdkPath string) error {
return err
}
}
if language == "go" {
if err := tidyGoModule(dir); err != nil {
return err
}
}
fmt.Printf("init: %s skill %q scaffolded in %s\n", language, name, dir)
return nil
}
Expand Down Expand Up @@ -109,7 +125,11 @@ func scaffoldFiles(name, language, sdkPath string) map[string]string {
if sdkPath != "" {
gomod += fmt.Sprintf("\nreplace github.com/operatorstack/yield => %s\n", sdkPath)
}
return map[string]string{"main.go": mainGo, "go.mod": gomod}
return map[string]string{
"main.go": mainGo,
"go.mod": gomod,
"skill.json": "{\"run\":[\"go\",\"run\",\"-mod=readonly\",\".\"]}\n",
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions labs/22-yield/yield/evals/results/latest.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"schema_version": 2,
"methodology_version": "1.0",
"generated_at": "2026-08-01T21:57:38.190Z",
"source_digest": "8fba9d25376a73e2a2230d8d10cfe8364a9b2db73e61b6974fa39928956ea9ef",
"generated_at": "2026-08-01T22:15:26.319Z",
"source_digest": "18c4620bc76291a4e8580b488f746cfb0085bf06629cf73ac38c5dbbec4bf099",
"status": "passed",
"workflow_conformance": {
"passed": 40,
Expand Down
Loading