Files
wehub-resource-sync a06f331eb8
CI / benchmark (push) Has been skipped
install-script / posix-syntax (push) Successful in 6m1s
CI / build-onnx (push) Failing after 6m43s
init-smoke / dry-run (push) Failing after 15m57s
security / govulncheck (push) Has been cancelled
security / trivy-fs (push) Has been cancelled
CI / test (1.26, ubuntu-latest) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
CI / test (1.26, macos-latest) (push) Has been cancelled
CI / build-windows (push) Has been cancelled
CI / lint (push) Has been cancelled
install-script / powershell-syntax (push) Has been cancelled
install-script / install (macos-14) (push) Has been cancelled
install-script / install (ubuntu-latest) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:33:42 +08:00

46 lines
1.2 KiB
Go

package skills
import (
"github.com/zzet/gortex/internal/analysis"
"github.com/zzet/gortex/internal/graph"
)
// BuildOpts tune community detection + skill generation in Build.
// Zero values fall back to the same defaults New() applies.
type BuildOpts struct {
MinSize int
MaxSkills int
}
// Build runs community detection and process discovery on g, then
// renders per-community SKILL.md files plus the routing block that
// `gortex init` injects into per-repo instructions files.
//
// Returns (nil, "") when no community meets the MinSize threshold —
// callers treat both outputs as opaque payloads and pass them through
// to adapters via agents.Env.
func Build(g graph.Store, opts BuildOpts) ([]GeneratedSkill, string) {
if g == nil {
return nil, ""
}
communities := analysis.DetectCommunities(g)
if communities == nil || len(communities.Communities) == 0 {
return nil, ""
}
processes := analysis.DiscoverProcesses(g)
gen := New(communities, processes, g)
if opts.MinSize > 0 {
gen.SetMinSize(opts.MinSize)
}
if opts.MaxSkills > 0 {
gen.SetMaxSkills(opts.MaxSkills)
}
generated := gen.GenerateAll()
if len(generated) == 0 {
return nil, ""
}
routing := gen.GenerateRouting(generated)
return generated, routing
}