Files
LocalAI/pkg/addons/packaging/platforms_test.go
T
Ettore Di Giacinto df14cf43e2 feat(addons): add the Short memory add-on
The add-on declares the three index files of the person's notes
(capabilities.contextFiles, manifest API 2), so the host loads them into
the prompt and serves their topics with context_read. It ships two skills:
memory, whose description asks the model to read the matching topic before
it answers almost anything and to save a note only as a proposal the person
confirms, and memory-check-own-files, which says what the model can and
cannot read. Its executable serves no tool, and its page explains the notes
and opens the Memory tab of the account.

The add-on joins the packaging matrix, the release workflow, the library
index and the case inventory. The declared capabilities the host hands to
an add-on now include the context files.

Assisted-by: Claude:claude-sonnet-5-5
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
2026-11-03 13:57:28 +00:00

85 lines
3.0 KiB
Go

// SPDX-License-Identifier: MIT
package packaging
import (
"os"
"path/filepath"
"sort"
"strings"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
// The release platforms of the packaged first-party add-ons, with the runner
// that builds and checks each one natively.
var releasePlatforms = map[string]string{
"linux/amd64": "ubuntu-24.04",
"linux/arm64": "ubuntu-24.04-arm",
"darwin/arm64": "macos-15",
"darwin/amd64": "macos-15-intel",
}
// nativeChecked records the platforms whose native check has passed on a runner
// of that platform. A task of group G adds a platform here in the same change
// that enables it in the five files and shows the passing legs in its pull
// request. Enabling without this record, or recording without enabling, fails.
var nativeChecked = map[string]bool{"linux/amd64": true, "linux/arm64": true, "darwin/arm64": true, "darwin/amd64": true}
// linuxOnly lists the add-ons whose code cannot run on macOS: their macOS
// platforms stay listed and disabled.
var linuxOnly = map[string]bool{"sandbox": true}
var packagedAddons = []string{"tables", "voice", "face", "fine-tuning", "quantization", "studio", "talk", "office", "sandbox", "web", "memory"}
var _ = Describe("the packaged add-ons", func() {
for _, id := range packagedAddons {
Context(id, func() {
It("lists every release platform with its runner", func() {
p, err := loadPlatforms(filepath.Join("..", "..", "..", "addons", id, "package", "platforms.yaml"))
Expect(err).ToNot(HaveOccurred())
Expect(p.Addon).To(Equal(id))
Expect(p.Executable).To(Equal(id))
got := map[string]string{}
for _, e := range p.Platforms {
got[e.Platform] = e.Runner
Expect(e.NativeCheck).To(Equal(NativeCheckKind), "%s: native check", e.Platform)
}
Expect(got).To(HaveLen(len(releasePlatforms)))
for platform, runner := range releasePlatforms {
Expect(got[platform]).To(Equal(runner), "platform %s", platform)
}
})
It("enables a platform exactly when its native check is recorded", func() {
p, err := loadPlatforms(filepath.Join("..", "..", "..", "addons", id, "package", "platforms.yaml"))
Expect(err).ToNot(HaveOccurred())
var enabled []string
for _, e := range p.Platforms {
if e.Enabled {
enabled = append(enabled, e.Platform)
}
}
var recorded []string
for platform := range nativeChecked {
if linuxOnly[id] && !strings.HasPrefix(platform, "linux/") {
continue
}
recorded = append(recorded, platform)
}
sort.Strings(enabled)
sort.Strings(recorded)
Expect(enabled).To(Equal(recorded), "enabled platforms and recorded native checks differ")
})
It("has a catalog template", func() {
b, err := os.ReadFile(filepath.Join("..", "..", "..", "gallery", "addons", id+".yaml.tmpl"))
Expect(err).ToNot(HaveOccurred())
for _, want := range []string{`id: "{{addon}}"`, "requireSignature: true"} {
Expect(strings.Contains(string(b), want)).To(BeTrue(), "template lacks %q", want)
}
})
})
}
})