2026-03-16 11:10:33 +00:00
|
|
|
// SPDX-License-Identifier: EUPL-1.2
|
|
|
|
|
|
2026-03-30 22:30:05 +00:00
|
|
|
// subsystem := brain.New(nil)
|
|
|
|
|
// core.Println(subsystem.Name()) // "brain"
|
2026-03-16 11:10:33 +00:00
|
|
|
package brain
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
|
refactor: migrate core/agent to Core primitives — reference implementation
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>
2026-03-22 06:13:41 +00:00
|
|
|
"dappco.re/go/agent/pkg/agentic"
|
2026-03-22 03:41:07 +00:00
|
|
|
core "dappco.re/go/core"
|
2026-03-29 20:15:58 +00:00
|
|
|
"forge.lthn.ai/core/mcp/pkg/mcp/ide"
|
2026-03-16 11:10:33 +00:00
|
|
|
"github.com/modelcontextprotocol/go-sdk/mcp"
|
|
|
|
|
)
|
|
|
|
|
|
2026-03-30 22:30:05 +00:00
|
|
|
// keyPath := core.JoinPath(home, ".claude", "brain.key")
|
refactor: migrate core/agent to Core primitives — reference implementation
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>
2026-03-22 06:13:41 +00:00
|
|
|
//
|
2026-03-30 21:11:06 +00:00
|
|
|
// if readResult := fs.Read(keyPath); readResult.OK {
|
|
|
|
|
// apiKey = core.Trim(readResult.Value.(string))
|
refactor: migrate core/agent to Core primitives — reference implementation
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>
2026-03-22 06:13:41 +00:00
|
|
|
// }
|
|
|
|
|
var fs = agentic.LocalFs()
|
|
|
|
|
|
2026-03-30 21:11:06 +00:00
|
|
|
func stringField(values map[string]any, key string) string {
|
refactor: migrate core/agent to Core primitives — reference implementation
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>
2026-03-22 06:13:41 +00:00
|
|
|
return core.Sprint(values[key])
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-30 22:30:05 +00:00
|
|
|
// core.E("brain", "bridge not available", nil)
|
2026-03-22 03:41:07 +00:00
|
|
|
var errBridgeNotAvailable = core.E("brain", "bridge not available", nil)
|
2026-03-16 11:10:33 +00:00
|
|
|
|
2026-03-30 22:30:05 +00:00
|
|
|
// subsystem := brain.New(nil)
|
|
|
|
|
// core.Println(subsystem.Name()) // "brain"
|
2026-03-16 11:10:33 +00:00
|
|
|
type Subsystem struct {
|
|
|
|
|
bridge *ide.Bridge
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-30 22:30:05 +00:00
|
|
|
// subsystem := brain.New(nil)
|
|
|
|
|
// core.Println(subsystem.Name())
|
2026-03-16 11:10:33 +00:00
|
|
|
func New(bridge *ide.Bridge) *Subsystem {
|
|
|
|
|
return &Subsystem{bridge: bridge}
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-30 22:30:05 +00:00
|
|
|
// name := subsystem.Name() // "brain"
|
2026-03-16 11:10:33 +00:00
|
|
|
func (s *Subsystem) Name() string { return "brain" }
|
|
|
|
|
|
2026-03-30 22:30:05 +00:00
|
|
|
// subsystem := brain.New(nil)
|
|
|
|
|
// subsystem.RegisterTools(server)
|
2026-03-16 11:10:33 +00:00
|
|
|
func (s *Subsystem) RegisterTools(server *mcp.Server) {
|
|
|
|
|
s.registerBrainTools(server)
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-30 22:30:05 +00:00
|
|
|
// _ = subsystem.Shutdown(context.Background())
|
2026-03-16 11:10:33 +00:00
|
|
|
func (s *Subsystem) Shutdown(_ context.Context) error {
|
|
|
|
|
return nil
|
|
|
|
|
}
|