Files
mudler-agentandEttore Di Giacinto 6e3222922e feat(addons): show the tool count of each add-on before install (#12898)
The add-on cards, the Find add-ons tab and the install dialog said
"Adds a page" for a library entry but nothing about chat tools, so the
tools only showed once the add-on was installed.

The library index now carries toolCount and tools on each entry, with
the same names as the installed view. They come from capabilities.tools
of the manifest; admin tools are not chat tools and are not counted.
Tools is capped at 32 names and toolCount stays the full number. The
catalog reader validates the hint and refuses it on a backend entry.
addonpkg catalog writes the fields. The new catalog-tools subcommand adds
them to an existing index from addons/<id>/manifest.json, and leaves
every digest and artifact as it was.

The UI reads the fields through the same helper as the installed view and
shows "Adds N tools" when N is above zero.

Assisted-by: Claude:claude-sonnet-5-5 [Claude Code]

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Co-authored-by: Ettore Di Giacinto <mudler@localai.io>
2026-10-25 19:13:30 +01:00

50 lines
1.3 KiB
Go

// SPDX-License-Identifier: MIT
// Package packaging builds, checks, merges and publishes first-party add-on
// OCI packages. It is the code behind scripts/addons/package.sh,
// scripts/addons/channel.sh and the add-on package workflow, so the rules
// that workflow relies on are code that a test can run.
//
// Every operation fails closed: a missing input is an error, never a default.
package packaging
import (
"fmt"
"io"
"os"
)
// stdout receives the key=value result lines of the subcommands.
var stdout io.Writer = os.Stdout
var commands = map[string]func(args []string) error{
"matrix": cmdMatrix,
"channel": cmdChannel,
"build": cmdBuild,
"verify": cmdVerify,
"extract": cmdExtract,
"native-check": cmdNativeCheck,
"merge": cmdMerge,
"publish": cmdPublish,
"promote": cmdPromote,
"target": cmdTarget,
"catalog": cmdCatalog,
"catalog-tools": cmdCatalogTools,
"policy": cmdPolicy,
}
// Run executes one subcommand of the addonpkg command line.
func Run(args []string, out io.Writer) error {
if len(args) == 0 {
return fmt.Errorf("usage: addonpkg <subcommand> [flags]")
}
cmd, ok := commands[args[0]]
if !ok {
return fmt.Errorf("unknown subcommand %q", args[0])
}
previous := stdout
stdout = out
defer func() { stdout = previous }()
return cmd(args[1:])
}