Files
skillshare/cmd/skillshare/project_runtime.go
T
Willie 1f1790b6be refactor: replace Registry with MetadataStore in reconcile, server, install context
Phase 1 of caller migration:
- projectRuntime: registry → skillsStore + agentsStore
- globalInstallContext: reg → store
- ReconcileGlobalSkills/ProjectSkills/ProjectAgents: take *MetadataStore
- Server struct: registry → skillsStore + agentsStore
- handler_install, handler_skills, handler_uninstall: use MetadataStore
- install.go, search.go: post-install reconciliation via MetadataStore
2026-04-08 10:59:13 +08:00

54 lines
1.2 KiB
Go

package main
import (
"path/filepath"
"skillshare/internal/config"
"skillshare/internal/install"
)
type projectRuntime struct {
root string
config *config.ProjectConfig
skillsStore *install.MetadataStore
agentsStore *install.MetadataStore
sourcePath string
agentsSourcePath string
targets map[string]config.TargetConfig
}
func loadProjectRuntime(root string) (*projectRuntime, error) {
cfg, err := config.LoadProject(root)
if err != nil {
return nil, err
}
targets, err := config.ResolveProjectTargets(root, cfg)
if err != nil {
return nil, err
}
skillsDir := filepath.Join(root, ".skillshare", "skills")
agentsDir := filepath.Join(root, ".skillshare", "agents")
skillsStore, err := install.LoadMetadataWithMigration(skillsDir, "")
if err != nil {
return nil, err
}
agentsStore, err := install.LoadMetadataWithMigration(agentsDir, "agent")
if err != nil {
return nil, err
}
return &projectRuntime{
root: root,
config: cfg,
skillsStore: skillsStore,
agentsStore: agentsStore,
sourcePath: skillsDir,
agentsSourcePath: agentsDir,
targets: targets,
}, nil
}