From 4d278a5172d55d32e17332787bed5bccf91c56b8 Mon Sep 17 00:00:00 2001 From: Virgil Date: Mon, 30 Mar 2026 20:05:47 +0000 Subject: [PATCH] fix(ax): use declarative core options in core-agent Co-Authored-By: Virgil --- cmd/core-agent/commands_example_test.go | 2 +- cmd/core-agent/commands_test.go | 2 +- cmd/core-agent/main.go | 4 ++-- cmd/core-agent/mcp_service.go | 3 ++- cmd/core-agent/mcp_service_example_test.go | 2 +- cmd/core-agent/mcp_service_test.go | 4 ++-- 6 files changed, 9 insertions(+), 8 deletions(-) diff --git a/cmd/core-agent/commands_example_test.go b/cmd/core-agent/commands_example_test.go index 5a4d046..322349c 100644 --- a/cmd/core-agent/commands_example_test.go +++ b/cmd/core-agent/commands_example_test.go @@ -7,7 +7,7 @@ import ( ) func Example_registerAppCommands() { - c := core.New(core.WithOption("name", "core-agent")) + c := core.New(core.WithOptions(core.NewOptions(core.Option{Key: "name", Value: "core-agent"}))) registerAppCommands(c) core.Println(len(c.Commands())) diff --git a/cmd/core-agent/commands_test.go b/cmd/core-agent/commands_test.go index 2075f70..5951509 100644 --- a/cmd/core-agent/commands_test.go +++ b/cmd/core-agent/commands_test.go @@ -15,7 +15,7 @@ import ( // newTestCore creates a minimal Core with app commands registered. func newTestCore(t *testing.T) *core.Core { t.Helper() - c := core.New(core.WithOption("name", "core-agent")) + c := core.New(core.WithOptions(core.NewOptions(core.Option{Key: "name", Value: "core-agent"}))) c.App().Version = "test" registerAppCommands(c) c.Cli().SetOutput(&bytes.Buffer{}) diff --git a/cmd/core-agent/main.go b/cmd/core-agent/main.go index f1b6638..a2878e9 100644 --- a/cmd/core-agent/main.go +++ b/cmd/core-agent/main.go @@ -29,13 +29,13 @@ func main() { // core.Println(c.App().Version) // "dev" or linked version func newCoreAgent() *core.Core { c := core.New( - core.WithOption("name", "core-agent"), + core.WithOptions(core.NewOptions(core.Option{Key: "name", Value: "core-agent"})), core.WithService(agentic.ProcessRegister), core.WithService(agentic.Register), core.WithService(runner.Register), core.WithService(monitor.Register), core.WithService(brain.Register), - core.WithName("mcp", registerMCPService), + core.WithService(registerMCPService), ) c.App().Version = appVersion() diff --git a/cmd/core-agent/mcp_service.go b/cmd/core-agent/mcp_service.go index d214ed3..0faca67 100644 --- a/cmd/core-agent/mcp_service.go +++ b/cmd/core-agent/mcp_service.go @@ -12,7 +12,8 @@ import ( // registerMCPService builds the MCP service from registered AX subsystems. // -// r := registerMCPService(c) +// c := core.New(core.WithService(registerMCPService)) +// _, ok := core.ServiceFor[*mcp.Service](c, "mcp") func registerMCPService(c *core.Core) core.Result { if c == nil { return core.Result{Value: core.E("main.registerMCPService", "core is required", nil), OK: false} diff --git a/cmd/core-agent/mcp_service_example_test.go b/cmd/core-agent/mcp_service_example_test.go index 15a3d80..ad6c934 100644 --- a/cmd/core-agent/mcp_service_example_test.go +++ b/cmd/core-agent/mcp_service_example_test.go @@ -7,7 +7,7 @@ import ( ) func Example_registerMCPService() { - result := registerMCPService(core.New(core.WithOption("name", "core-agent"))) + result := registerMCPService(core.New(core.WithOptions(core.NewOptions(core.Option{Key: "name", Value: "core-agent"})))) core.Println(result.OK) // Output: true diff --git a/cmd/core-agent/mcp_service_test.go b/cmd/core-agent/mcp_service_test.go index cbf06bc..40b2ffe 100644 --- a/cmd/core-agent/mcp_service_test.go +++ b/cmd/core-agent/mcp_service_test.go @@ -15,7 +15,7 @@ import ( ) func TestMCP_RegisterMCPService_Good(t *testing.T) { - result := registerMCPService(core.New(core.WithOption("name", "core-agent"))) + result := registerMCPService(core.New(core.WithOptions(core.NewOptions(core.Option{Key: "name", Value: "core-agent"})))) require.True(t, result.OK) _, ok := result.Value.(*mcp.Service) @@ -31,7 +31,7 @@ func TestMCP_RegisterMCPService_Bad(t *testing.T) { func TestMCP_RegisterMCPService_Ugly(t *testing.T) { c := core.New( - core.WithOption("name", "core-agent"), + core.WithOptions(core.NewOptions(core.Option{Key: "name", Value: "core-agent"})), core.WithService(agentic.ProcessRegister), core.WithService(agentic.Register), core.WithService(monitor.Register),