agent: pi-magpie's source pattern compiles on first use (TestNoEagerPackageRegexps)

d52e2feaf added piMagpieExt as a package-level regexp.MustCompile, so
TestNoEagerPackageRegexps in the root package was red on main
("internal/agent/pimagpie.go:13:19: a package-level regexp is compiled
at launch; use lazyre.New"). It is lazyre.New now, as the rest of
internal/agent's patterns are.

Run on mica: go test -run TestNoEagerPackageRegexps . ok (red before,
in the full suite at 70f4593e6); go test -run Pi ./internal/agent ok;
go vet ./internal/agent ok; gofmt clean.
This commit is contained in:
yetone
2026-11-13 12:10:08 +08:00
parent 5e51e241c2
commit 6a506e2834
+2 -2
View File
@@ -3,14 +3,14 @@ package agent
import (
"encoding/json"
"os"
"regexp"
"github.com/yetone/magpie/internal/edit"
"github.com/yetone/magpie/internal/lazyre"
)
// piMagpieExt matches a Pi package source for the pi-magpie extension:
// npm:pi-magpie, npm:pi-magpie@0.1.6, or a path or git source ending in it.
var piMagpieExt = regexp.MustCompile(`(^|[:/\\])pi-magpie(@[^/\\]*)?(#.*)?$`)
var piMagpieExt = lazyre.New(`(^|[:/\\])pi-magpie(@[^/\\]*)?(#.*)?$`)
// piMagpieInstalled says Pi's settings.json lists the pi-magpie extension
// in "packages". It serves provider "magpie" from magpie's live catalog,