Phase 1: go-io/go-log → core.Fs{}, core.E(), core.Error/Info/Warn
Phase 2: strings/fmt → core.Contains, core.Sprintf, core.Split etc
Phase 3: embed.FS → core.Mount/core.Embed, core.Extract
Phase 4: cmd/main.go → core.Command(), c.Cli().Run(), no cli package
All packages migrated:
- pkg/lib (Codex): core.Mount, core.Extract, Result returns, AX comments
- pkg/setup (Codex): core.Fs, core.E, fixed missing lib helpers
- pkg/brain (Codex): Core primitives, AX comments
- pkg/monitor (Codex): Core string/logging primitives
- pkg/agentic (Codex): 20 files, Core primitives throughout
- cmd/main.go: pure Core CLI, no fmt/log/filepath/strings/cli
Remaining stdlib: path/filepath (Core doesn't wrap OS paths),
fmt.Sscanf/strings.Map (no Core equivalent).
Co-Authored-By: Virgil <virgil@lethean.io>
66 lines
1.8 KiB
Go
66 lines
1.8 KiB
Go
// SPDX-License-Identifier: EUPL-1.2
|
|
|
|
// Package brain provides an MCP subsystem that proxies OpenBrain knowledge
|
|
// store operations to the Laravel php-agentic backend via the IDE bridge.
|
|
package brain
|
|
|
|
import (
|
|
"context"
|
|
|
|
"dappco.re/go/agent/pkg/agentic"
|
|
core "dappco.re/go/core"
|
|
"forge.lthn.ai/core/mcp/pkg/mcp/ide"
|
|
"github.com/modelcontextprotocol/go-sdk/mcp"
|
|
)
|
|
|
|
// fs provides unrestricted filesystem access for shared brain credentials.
|
|
//
|
|
// keyPath := core.Concat(home, "/.claude/brain.key")
|
|
// if r := fs.Read(keyPath); r.OK {
|
|
// apiKey = core.Trim(r.Value.(string))
|
|
// }
|
|
var fs = agentic.LocalFs()
|
|
|
|
func fieldString(values map[string]any, key string) string {
|
|
return core.Sprint(values[key])
|
|
}
|
|
|
|
// errBridgeNotAvailable is returned when a tool requires the Laravel bridge
|
|
// but it has not been initialised (headless mode).
|
|
var errBridgeNotAvailable = core.E("brain", "bridge not available", nil)
|
|
|
|
// Subsystem proxies brain_* MCP tools through the shared IDE bridge.
|
|
//
|
|
// sub := brain.New(bridge)
|
|
// sub.RegisterTools(server)
|
|
type Subsystem struct {
|
|
bridge *ide.Bridge
|
|
}
|
|
|
|
// New creates a bridge-backed brain subsystem.
|
|
//
|
|
// sub := brain.New(bridge)
|
|
// _ = sub.Shutdown(context.Background())
|
|
func New(bridge *ide.Bridge) *Subsystem {
|
|
return &Subsystem{bridge: bridge}
|
|
}
|
|
|
|
// Name returns the MCP subsystem name.
|
|
//
|
|
// name := sub.Name() // "brain"
|
|
func (s *Subsystem) Name() string { return "brain" }
|
|
|
|
// RegisterTools adds the bridge-backed brain tools to an MCP server.
|
|
//
|
|
// sub := brain.New(bridge)
|
|
// sub.RegisterTools(server)
|
|
func (s *Subsystem) RegisterTools(server *mcp.Server) {
|
|
s.registerBrainTools(server)
|
|
}
|
|
|
|
// Shutdown closes the subsystem without additional cleanup.
|
|
//
|
|
// _ = sub.Shutdown(context.Background())
|
|
func (s *Subsystem) Shutdown(_ context.Context) error {
|
|
return nil
|
|
}
|