返回 DeepSeek-Reasonix
contributor.go
根目录 / internal / extension / contributor.go
1 package extension
2
3 import "context"
4
5 // Contributor offers contributions to the kernel. Implementations wrap one
6 // discovery source (built-in tools, a skill store, command roots, ...) and
7 // return everything that source currently provides. Contribute must be
8 // deterministic for a fixed underlying state: the Builder stamps per-
9 // contributor registration order, and determinism guarantees that two builds
10 // over the same state produce the same snapshot.
11 type Contributor interface {
12 // Name identifies the contributor in diagnostics and default Origins.
13 Name() string
14 // Contribute returns the contributor's current contributions.
15 Contribute(ctx context.Context) ([]Contribution, error)
16 }
17
18 // ContributorFunc adapts a function into a Contributor. The name is explicit
19 // because "the closure passed at some call site" is useless in a conflict
20 // report.
21 type ContributorFunc struct {
22 ContributorName string
23 Fn func(ctx context.Context) ([]Contribution, error)
24 }
25
26 // Name returns the declared contributor name.
27 func (f ContributorFunc) Name() string { return f.ContributorName }
28
29 // Contribute invokes the wrapped function.
30 func (f ContributorFunc) Contribute(ctx context.Context) ([]Contribution, error) {
31 return f.Fn(ctx)
32 }
33
33 lines GO