refactor: swap pkg/framework imports to pkg/core
Some checks failed
Deploy / build (push) Failing after 4s
Security Scan / security (push) Successful in 19s

Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
Snider 2026-03-06 14:10:55 +00:00
parent 7f555c6f8a
commit 37a8ae8d31
5 changed files with 33 additions and 33 deletions

View file

@ -6,7 +6,7 @@ import (
"runtime/debug"
"forge.lthn.ai/core/go-crypt/crypt/openpgp"
"forge.lthn.ai/core/go/pkg/framework"
"forge.lthn.ai/core/go/pkg/core"
"forge.lthn.ai/core/go-log"
"forge.lthn.ai/core/go-io/workspace"
"github.com/spf13/cobra"
@ -66,7 +66,7 @@ func WithAppName(name string) {
// )
//
// Exits with code 1 on error or panic.
func Main(commands ...framework.Option) {
func Main(commands ...core.Option) {
// Recovery from panics
defer func() {
if r := recover(); r != nil {
@ -77,13 +77,13 @@ func Main(commands ...framework.Option) {
}()
// Core services load first, then command services
services := []framework.Option{
framework.WithName("i18n", NewI18nService(I18nOptions{})),
framework.WithName("log", NewLogService(log.Options{
services := []core.Option{
core.WithName("i18n", NewI18nService(I18nOptions{})),
core.WithName("log", NewLogService(log.Options{
Level: log.LevelInfo,
})),
framework.WithName("crypt", openpgp.New),
framework.WithName("workspace", workspace.New),
core.WithName("crypt", openpgp.New),
core.WithName("workspace", workspace.New),
}
services = append(services, commands...)

View file

@ -6,7 +6,7 @@ import (
"iter"
"sync"
"forge.lthn.ai/core/go/pkg/framework"
"forge.lthn.ai/core/go/pkg/core"
"github.com/spf13/cobra"
)
@ -18,14 +18,14 @@ import (
// cli.WithCommands("config", config.AddConfigCommands),
// cli.WithCommands("doctor", doctor.AddDoctorCommands),
// )
func WithCommands(name string, register func(root *Command)) framework.Option {
return framework.WithName("cmd."+name, func(c *framework.Core) (any, error) {
func WithCommands(name string, register func(root *Command)) core.Option {
return core.WithName("cmd."+name, func(c *core.Core) (any, error) {
return &commandService{core: c, register: register}, nil
})
}
type commandService struct {
core *framework.Core
core *core.Core
register func(root *Command)
}

View file

@ -4,13 +4,13 @@ import (
"context"
"sync"
"forge.lthn.ai/core/go/pkg/framework"
"forge.lthn.ai/core/go/pkg/core"
"forge.lthn.ai/core/go-i18n"
)
// I18nService wraps i18n as a Core service.
type I18nService struct {
*framework.ServiceRuntime[I18nOptions]
*core.ServiceRuntime[I18nOptions]
svc *i18n.Service
// Collect mode state
@ -27,8 +27,8 @@ type I18nOptions struct {
}
// NewI18nService creates an i18n service factory.
func NewI18nService(opts I18nOptions) func(*framework.Core) (any, error) {
return func(c *framework.Core) (any, error) {
func NewI18nService(opts I18nOptions) func(*core.Core) (any, error) {
return func(c *core.Core) (any, error) {
svc, err := i18n.New()
if err != nil {
return nil, err
@ -45,7 +45,7 @@ func NewI18nService(opts I18nOptions) func(*framework.Core) (any, error) {
i18n.SetDefault(svc)
return &I18nService{
ServiceRuntime: framework.NewServiceRuntime(c, opts),
ServiceRuntime: core.NewServiceRuntime(c, opts),
svc: svc,
missingKeys: make([]i18n.MissingKey, 0),
}, nil
@ -113,7 +113,7 @@ type QueryTranslate struct {
Args map[string]any
}
func (s *I18nService) handleQuery(c *framework.Core, q framework.Query) (any, bool, error) {
func (s *I18nService) handleQuery(c *core.Core, q core.Query) (any, bool, error) {
switch m := q.(type) {
case QueryTranslate:
return s.svc.T(m.Key, m.Args), true, nil
@ -157,7 +157,7 @@ func T(key string, args ...map[string]any) string {
return i18n.T(key)
}
svc, err := framework.ServiceFor[*I18nService](instance.core, "i18n")
svc, err := core.ServiceFor[*I18nService](instance.core, "i18n")
if err != nil {
// i18n service not registered, use global
if len(args) > 0 {

View file

@ -1,7 +1,7 @@
package cli
import (
"forge.lthn.ai/core/go/pkg/framework"
"forge.lthn.ai/core/go/pkg/core"
"forge.lthn.ai/core/go/pkg/log"
)
@ -31,8 +31,8 @@ type LogService struct {
type LogOptions = log.Options
// NewLogService creates a log service factory with CLI styling.
func NewLogService(opts LogOptions) func(*framework.Core) (any, error) {
return func(c *framework.Core) (any, error) {
func NewLogService(opts LogOptions) func(*core.Core) (any, error) {
return func(c *core.Core) (any, error) {
// Create the underlying service
factory := log.NewService(opts)
svc, err := factory(c)
@ -61,7 +61,7 @@ func Log() *LogService {
if instance == nil {
return nil
}
svc, err := framework.ServiceFor[*LogService](instance.core, "log")
svc, err := core.ServiceFor[*LogService](instance.core, "log")
if err != nil {
return nil
}

View file

@ -20,7 +20,7 @@ import (
"sync"
"syscall"
"forge.lthn.ai/core/go/pkg/framework"
"forge.lthn.ai/core/go/pkg/core"
"github.com/spf13/cobra"
)
@ -31,7 +31,7 @@ var (
// runtime is the CLI's internal Core runtime.
type runtime struct {
core *framework.Core
core *core.Core
root *cobra.Command
ctx context.Context
cancel context.CancelFunc
@ -41,7 +41,7 @@ type runtime struct {
type Options struct {
AppName string
Version string
Services []framework.Option // Additional services to register
Services []core.Option // Additional services to register
// OnReload is called when SIGHUP is received (daemon mode).
// Use for configuration reloading. Leave nil to ignore SIGHUP.
@ -73,14 +73,14 @@ func Init(opts Options) error {
}
// Build options: app, signal service + any additional services
coreOpts := []framework.Option{
framework.WithApp(rootCmd),
framework.WithName("signal", newSignalService(cancel, signalOpts...)),
coreOpts := []core.Option{
core.WithApp(rootCmd),
core.WithName("signal", newSignalService(cancel, signalOpts...)),
}
coreOpts = append(coreOpts, opts.Services...)
coreOpts = append(coreOpts, framework.WithServiceLock())
coreOpts = append(coreOpts, core.WithServiceLock())
c, err := framework.New(coreOpts...)
c, err := core.New(coreOpts...)
if err != nil {
initErr = err
cancel()
@ -111,7 +111,7 @@ func mustInit() {
// --- Core Access ---
// Core returns the CLI's framework Core instance.
func Core() *framework.Core {
func Core() *core.Core {
mustInit()
return instance.core
}
@ -164,8 +164,8 @@ func WithReloadHandler(fn func() error) SignalOption {
}
}
func newSignalService(cancel context.CancelFunc, opts ...SignalOption) func(*framework.Core) (any, error) {
return func(c *framework.Core) (any, error) {
func newSignalService(cancel context.CancelFunc, opts ...SignalOption) func(*core.Core) (any, error) {
return func(c *core.Core) (any, error) {
svc := &signalService{
cancel: cancel,
sigChan: make(chan os.Signal, 1),