Files
mesh-catalog/modules/mesh-build-node/cmd/mesh-build-node/tools.go
T
mesh-tools c33b83dce7
mesh/merge-gate head c33b83dce7d5 merged into trunk 940594b07478 — pass: builds mesh-build-go, mesh-build-node → g14, novox, shanks; no bus step; every mac…
mesh/repo-check head c33b83dce7d5 merged into trunk 940594b07478 — pass: its merge-check.sh passed, each part in its toolchain: merge-check.sh (go), merge-…
mesh/delivery covered: a later merge that contains it was delivered: novox/mesh-catalog@e023f69989ab (merged as b5dbfbb7 into main, walk plan-17925769516…
Read a build module's steps and toolchains states with its own tools, so a step's result and the reported toolchain can be checked live (issue 1562)
2026-10-21 09:57:16 +00:00

54 lines
2.0 KiB
Go

package main
import (
"context"
stdio "git.novox.be/novox/mesh-sdk/go"
)
// The tools this module serves. A tool is named as the module is: build_node_ and its verb (a tool name has no dot).
const (
StatusTool = "build_node_status"
HealthTool = "build_node_health"
)
// StepTool is one step tool of the module: fetch, test or build. Long is a step that answers at once and
// ends on its key (ADR 0469 §2); the others answer in their call. Both run behind the toolchain guard.
type StepTool struct {
Name string
Description string
Input map[string]any
Long bool
Run func(ctx context.Context, args map[string]any) (any, error)
}
// StepTools are the module's step tools. Each step's issue adds its own.
func (m *Module) StepTools() []StepTool {
return []StepTool{m.fetchTool(), m.testTool(), m.buildTool()}
}
// Tools is every tool the module serves: its step tools behind the guard, its status and its health.
func (m *Module) Tools(steps []StepTool) []stdio.Tool {
tools := []stdio.Tool{}
for _, s := range steps {
t := stdio.Tool{Name: s.Name, Description: s.Description, Input: s.Input}
if s.Long {
t.Run = m.Long(s.Name, s.Run)
} else {
t.Run = m.Short(s.Run)
}
tools = append(tools, t)
}
tools = append(tools, m.ReadTools()...)
return append(tools,
stdio.Tool{Name: StatusTool,
Description: "What the Node build module is on this machine: the Node version its recipe builds with and the one installed, " +
"the recipe version, the toolchain directory and whether it is installed, and why it refuses to build if it does. Read-only.",
Run: func(map[string]any) (any, error) { return m.Status(m.Ctx), nil }},
stdio.Tool{Name: HealthTool,
Description: "How the Node build module is: unhealthy while the Node installed on this machine is not the version its " +
"recipe builds with, saying both versions; healthy otherwise. Read-only.",
Run: func(map[string]any) (any, error) { return m.Health(m.Ctx), nil }},
)
}