Switch from Asuka to MyGo, keeping the API client and the feature set: - servers: saved servers, passwordless and password login, proxy, self-signed certificates, per-server device tokens (Keystore), connect form, instance list sheet with switch/disconnect - sessions: virtualized list, search, new session, rename/archive/delete, running indicator, event stream keeps it live - chat: pushed window with system back bar, streaming Markdown via ui/markdown, reasoning and tool rows with image previews, footer menu (read aloud via a Kotlin TTS plugin, copy, fork), user message menu (copy, revert, fork), context usage ring and detail sheet, attachments (photos/files via the document picker), permissions - release builds allow plain http:// LAN servers (Go's net/http dials directly, no cleartext manifest needed) - a local fork of MyGo (third_party/mygo) lowers the Android host's minSdk to 24 (Android 7.0); Go 1.27.4 via mise Version 0.3.0.
93 lines
2.6 KiB
Go
93 lines
2.6 KiB
Go
package main
|
|
|
|
import (
|
|
"bytes"
|
|
"errors"
|
|
"flag"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
func TestInstallSkills(t *testing.T) {
|
|
for _, mode := range []string{"current directory", "explicit directory"} {
|
|
t.Run(mode, func(t *testing.T) {
|
|
dir := t.TempDir()
|
|
var args []string
|
|
if mode == "current directory" {
|
|
t.Chdir(dir)
|
|
} else {
|
|
args = []string{dir}
|
|
}
|
|
preserved := map[string]string{
|
|
"main.go": "package main\n",
|
|
".agents/skills/custom/SKILL.md": "custom skill",
|
|
".agents/skills/mygo-maintenance/references/local.md": "local guidance",
|
|
}
|
|
for path, content := range preserved {
|
|
full := filepath.Join(dir, filepath.FromSlash(path))
|
|
if err := os.MkdirAll(filepath.Dir(full), 0o755); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := os.WriteFile(full, []byte(content), 0o644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
for _, phase := range []string{"install", "update", "repeat"} {
|
|
if err := runInstallSkills(args); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
for _, name := range []string{"SKILL.md", "agents/openai.yaml"} {
|
|
path := ".agents/skills/mygo-maintenance/" + name
|
|
want, err := templateFS.ReadFile("template/shared/" + path)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
full := filepath.Join(dir, filepath.FromSlash(path))
|
|
got, err := os.ReadFile(full)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if !bytes.Equal(got, want) {
|
|
t.Errorf("%s: %s differs from the bundled skill", phase, path)
|
|
}
|
|
if phase == "install" {
|
|
if err := os.WriteFile(full, []byte("old skill content"), 0o644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
}
|
|
for path, want := range preserved {
|
|
got, err := os.ReadFile(filepath.Join(dir, filepath.FromSlash(path)))
|
|
if err != nil || string(got) != want {
|
|
t.Errorf("%s: %s was changed: %q, %v", phase, path, got, err)
|
|
}
|
|
}
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestInstallSkillsErrors(t *testing.T) {
|
|
if err := runInstallSkills([]string{"-h"}); !errors.Is(err, flag.ErrHelp) {
|
|
t.Fatalf("help: %v", err)
|
|
}
|
|
dir := t.TempDir()
|
|
file := filepath.Join(dir, "file")
|
|
if err := os.WriteFile(file, nil, 0o644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
for _, args := range [][]string{{"-unknown"}, {dir, dir}, {filepath.Join(dir, "missing")}, {file}} {
|
|
if err := runInstallSkills(args); err == nil {
|
|
t.Errorf("%v: expected an error", args)
|
|
}
|
|
}
|
|
// A file blocking the destination is an error, not a successful install.
|
|
if err := os.WriteFile(filepath.Join(dir, ".agents"), nil, 0o644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := runInstallSkills([]string{dir}); err == nil {
|
|
t.Error("blocked destination: expected an error")
|
|
}
|
|
}
|