Skip to content

armgit / ax

Public Imported from GitHub
0

Agent Executor (AX) is Google's open agentic orchestration runtime

Go

Remove skills.Available in favor of []skills.Group

Jaana Dogan91567b2844ba
diff --git a/cmd/ax/internal/cliutil/cliutil.go b/cmd/ax/internal/cliutil/cliutil.go
index f40fdb4..51933aa 100644
--- a/cmd/ax/internal/cliutil/cliutil.go
+++ b/cmd/ax/internal/cliutil/cliutil.go
@@ -87,10 +87,10 @@ func NewControllerFromConfig(ctx context.Context, cfg *Config) (*controller.Cont
// the interactions harness is fully wired.
var skillsPointer string
if !substrateMode {
- var avail skills.Available
- avail.Groups = append(avail.Groups, geminienterprise.Materialize(ctx, cfg.Skills).Groups...)
- avail.Groups = append(avail.Groups, local.Discover(cfg.Skills).Groups...)
- skillsPointer = antigravityinteractions.SkillsSystemInstruction(avail)
+ var groups []skills.Group
+ groups = append(groups, geminienterprise.Materialize(ctx, cfg.Skills)...)
+ groups = append(groups, local.Discover(cfg.Skills)...)
+ skillsPointer = antigravityinteractions.SkillsSystemInstruction(groups)
}
// Built-in Antigravity harness.
diff --git a/internal/harness/antigravityinteractions/skills.go b/internal/harness/antigravityinteractions/skills.go
index 20f6689..8e3ecc9 100644
--- a/internal/harness/antigravityinteractions/skills.go
+++ b/internal/harness/antigravityinteractions/skills.go
@@ -24,19 +24,19 @@ import (
// SkillsSystemInstruction builds a system-instruction pointer telling the agent
// where its skills live and lists them. It is source-agnostic: the skills may
// come from the Gemini Enterprise Skill Registry or from a local directory --
-// both produce the same skills.Available shape.
+// both produce []skills.Group.
//
// This is discovery logic specific to the Antigravity Interactions harness: it
// has no SKILLS_DIR concept, so it must be told where to find skills via its
// system instruction (its built-in file tools then read that directory).
// Harnesses that auto-discover a skills directory (e.g. the Antigravity SDK
// harness via SKILLS_DIR) do not use this.
-func SkillsSystemInstruction(avail skills.Available) string {
- if avail.Empty() {
+func SkillsSystemInstruction(groups []skills.Group) string {
+ if len(groups) == 0 {
return ""
}
var b strings.Builder
- for _, g := range avail.Groups {
+ for _, g := range groups {
if b.Len() > 0 {
b.WriteString("\n")
}
diff --git a/internal/harness/antigravityinteractions/skills_test.go b/internal/harness/antigravityinteractions/skills_test.go
index 02003df..9fa8edc 100644
--- a/internal/harness/antigravityinteractions/skills_test.go
+++ b/internal/harness/antigravityinteractions/skills_test.go
@@ -23,28 +23,28 @@ import (
func TestSkillsSystemInstruction(t *testing.T) {
t.Run("empty result yields empty pointer", func(t *testing.T) {
- if got := SkillsSystemInstruction(skills.Available{}); got != "" {
+ if got := SkillsSystemInstruction(nil); got != "" {
t.Errorf("empty result pointer = %q, want empty", got)
}
})
t.Run("mentions dir and skill ids", func(t *testing.T) {
- avail := skills.Available{Groups: []skills.Group{{
+ groups := []skills.Group{{
Dir: "/workspace",
Skills: []skills.Skill{{ID: "emoji"}, {ID: "lowercase"}},
- }}}
- got := SkillsSystemInstruction(avail)
+ }}
+ got := SkillsSystemInstruction(groups)
if !strings.Contains(got, "/workspace") || !strings.Contains(got, "emoji") || !strings.Contains(got, "lowercase") {
t.Errorf("pointer = %q, want it to mention dir and skill ids", got)
}
})
t.Run("multiple groups produce multiple lines", func(t *testing.T) {
- avail := skills.Available{Groups: []skills.Group{
+ groups := []skills.Group{
{Dir: "/a", Skills: []skills.Skill{{ID: "s1"}}},
{Dir: "/b", Skills: []skills.Skill{{ID: "s2"}}},
- }}
- got := SkillsSystemInstruction(avail)
+ }
+ got := SkillsSystemInstruction(groups)
if !strings.Contains(got, "/a") || !strings.Contains(got, "/b") || !strings.Contains(got, "\n") {
t.Errorf("pointer = %q, want both dirs on separate lines", got)
}
diff --git a/internal/skills/geminienterprise/materialize.go b/internal/skills/geminienterprise/materialize.go
index 4d9de0d..d48a715 100644
--- a/internal/skills/geminienterprise/materialize.go
+++ b/internal/skills/geminienterprise/materialize.go
@@ -17,10 +17,10 @@
// Skill Registry (a managed, versioned catalog exposed over the Vertex AI
// v1beta1 REST API) and writes each skill to <target_dir>/<skill-id>/.
//
-// It is harness-agnostic: it only writes files and reports what it wrote (as a
-// mode-agnostic skills.Available). It knows nothing about specific harnesses,
-// SKILLS_DIR, or discovery pointers — callers decide how a given harness is told
-// where its skills are.
+// // It is harness-agnostic: it only writes files and reports what it wrote (as
+// []skills.Group). It knows nothing about specific harnesses, SKILLS_DIR, or
+// discovery pointers — callers decide how a given harness is told where its
+// skills are.
//
// Scope: read-only. This package never creates, updates, or deletes registry
// skills (authoring is out of scope).
@@ -47,7 +47,7 @@ const (
// materializedSkill records one skill written to disk. It carries the resolved
// revision (registry-specific detail) internally; Materialize converts these to
-// the mode-agnostic skills.Available shape at its boundary.
+// []skills.Group at its boundary.
type materializedSkill struct {
SkillID string
Revision string
@@ -65,8 +65,8 @@ type materializedSkill struct {
// registry's selection, or across registries sharing a dir), the FIRST writer
// wins and later duplicates are skipped with a warning. Substrate/pod
// materialization is a separate, later path; this wires the local flow only.
-func Materialize(ctx context.Context, sc config.SkillsConfig) skills.Available {
- var avail skills.Available
+func Materialize(ctx context.Context, sc config.SkillsConfig) []skills.Group {
+ var groups []skills.Group
// claimed tracks (target_dir, skill-id) pairs already written across all
// registries so the FIRST writer of an id into a dir wins; later duplicates
// (within one registry's selection, or across registries sharing a dir) are
@@ -110,9 +110,9 @@ func Materialize(ctx context.Context, sc config.SkillsConfig) skills.Available {
for _, m := range out.materialized {
group.Skills = append(group.Skills, skills.Skill{ID: m.SkillID, Dir: m.Dir})
}
- avail.Groups = append(avail.Groups, group)
+ groups = append(groups, group)
}
- return avail
+ return groups
}
// claimSet tracks which (dir, skill-id) pairs have already been materialized, so
diff --git a/internal/skills/geminienterprise/materialize_test.go b/internal/skills/geminienterprise/materialize_test.go
index 2779a37..3f99951 100644
--- a/internal/skills/geminienterprise/materialize_test.go
+++ b/internal/skills/geminienterprise/materialize_test.go
@@ -82,7 +82,7 @@ func TestClaimSet_FirstWins(t *testing.T) {
func TestMaterialize_DisabledIsEmpty(t *testing.T) {
// Disabled config => no-op, empty result, no error/panic.
- if res := Materialize(context.Background(), config.SkillsConfig{}); !res.Empty() {
+ if res := Materialize(context.Background(), config.SkillsConfig{}); len(res) != 0 {
t.Errorf("disabled Materialize = %+v, want empty", res)
}
}
@@ -94,7 +94,7 @@ func TestMaterialize_EnabledNoProjectIsEmpty(t *testing.T) {
sc := config.SkillsConfig{Registries: []config.SkillsRegistryConfig{
{Enabled: true, TargetDir: t.TempDir()},
}}
- if res := Materialize(context.Background(), sc); !res.Empty() {
+ if res := Materialize(context.Background(), sc); len(res) != 0 {
t.Errorf("no-project Materialize = %+v, want empty", res)
}
}
diff --git a/internal/skills/local/local.go b/internal/skills/local/local.go
index 3dfc105..1a7cd1a 100644
--- a/internal/skills/local/local.go
+++ b/internal/skills/local/local.go
@@ -21,8 +21,8 @@
// each with a SKILL.md (the same layout as examples/skills and a registry's
// target_dir). Nothing is written; the directory is used as-is.
//
-// It is harness-agnostic and produces the mode-agnostic skills.Available shape,
-// so the same consumers that handle registry skills handle local ones.
+// It is harness-agnostic and produces []skills.Group, so the same consumers that
+// handle registry skills handle local ones.
package local
import (
@@ -47,8 +47,8 @@ const skillManifest = "SKILL.md"
// contains no skills is logged and skipped so a local-skills problem never
// blocks harness creation. Paths are resolved to absolute form so the reported
// directories are stable regardless of the process working directory.
-func Discover(sc config.SkillsConfig) skills.Available {
- var avail skills.Available
+func Discover(sc config.SkillsConfig) []skills.Group {
+ var groups []skills.Group
for i := range sc.Local {
lc := sc.Local[i]
if !lc.Enabled {
@@ -58,9 +58,9 @@ func Discover(sc config.SkillsConfig) skills.Available {
if !ok {
continue
}
- avail.Groups = append(avail.Groups, group)
+ groups = append(groups, group)
}
- return avail
+ return groups
}
// discoverOne scans a single local skills path. idx is the entry's index within
diff --git a/internal/skills/local/local_test.go b/internal/skills/local/local_test.go
index 7d78e21..38f90bf 100644
--- a/internal/skills/local/local_test.go
+++ b/internal/skills/local/local_test.go
@@ -48,16 +48,16 @@ func TestDiscover_FindsSkillSubdirs(t *testing.T) {
t.Fatal(err)
}
- avail := Discover(config.SkillsConfig{Local: []config.LocalSkillsConfig{
+ groups := Discover(config.SkillsConfig{Local: []config.LocalSkillsConfig{
{Enabled: true, Path: root},
}})
- if avail.Empty() {
+ if len(groups) == 0 {
t.Fatal("expected skills, got none")
}
- if len(avail.Groups) != 1 {
- t.Fatalf("groups = %d, want 1", len(avail.Groups))
+ if len(groups) != 1 {
+ t.Fatalf("groups = %d, want 1", len(groups))
}
- g := avail.Groups[0]
+ g := groups[0]
// Dir is reported as an absolute path.
if !filepath.IsAbs(g.Dir) {
t.Errorf("group Dir = %q, want absolute", g.Dir)
@@ -79,31 +79,31 @@ func TestDiscover_FindsSkillSubdirs(t *testing.T) {
func TestDiscover_DisabledIsSkipped(t *testing.T) {
root := t.TempDir()
writeSkillDir(t, root, "emoji")
- avail := Discover(config.SkillsConfig{Local: []config.LocalSkillsConfig{
+ groups := Discover(config.SkillsConfig{Local: []config.LocalSkillsConfig{
{Enabled: false, Path: root},
}})
- if !avail.Empty() {
- t.Errorf("disabled entry produced skills: %+v", avail)
+ if len(groups) != 0 {
+ t.Errorf("disabled entry produced skills: %+v", groups)
}
}
func TestDiscover_MissingPathDegrades(t *testing.T) {
// A non-existent path must not panic or error; it degrades to no skills.
- avail := Discover(config.SkillsConfig{Local: []config.LocalSkillsConfig{
+ groups := Discover(config.SkillsConfig{Local: []config.LocalSkillsConfig{
{Enabled: true, Path: filepath.Join(t.TempDir(), "does-not-exist")},
}})
- if !avail.Empty() {
- t.Errorf("missing path produced skills: %+v", avail)
+ if len(groups) != 0 {
+ t.Errorf("missing path produced skills: %+v", groups)
}
}
func TestDiscover_EmptyDirDegrades(t *testing.T) {
// A directory with no <skill-id>/SKILL.md subfolders yields no skills.
- avail := Discover(config.SkillsConfig{Local: []config.LocalSkillsConfig{
+ groups := Discover(config.SkillsConfig{Local: []config.LocalSkillsConfig{
{Enabled: true, Path: t.TempDir()},
}})
- if !avail.Empty() {
- t.Errorf("empty dir produced skills: %+v", avail)
+ if len(groups) != 0 {
+ t.Errorf("empty dir produced skills: %+v", groups)
}
}
@@ -112,15 +112,15 @@ func TestDiscover_MultiplePaths(t *testing.T) {
b := t.TempDir()
writeSkillDir(t, a, "s1")
writeSkillDir(t, b, "s2")
- avail := Discover(config.SkillsConfig{Local: []config.LocalSkillsConfig{
+ groups := Discover(config.SkillsConfig{Local: []config.LocalSkillsConfig{
{Enabled: true, Path: a},
{Enabled: true, Path: b},
}})
- if len(avail.Groups) != 2 {
- t.Fatalf("groups = %d, want 2", len(avail.Groups))
+ if len(groups) != 2 {
+ t.Fatalf("groups = %d, want 2", len(groups))
}
var got []string
- for _, g := range avail.Groups {
+ for _, g := range groups {
for _, s := range g.Skills {
got = append(got, s.ID)
}
@@ -141,14 +141,14 @@ func TestDiscover_ExamplesSkillsFixture(t *testing.T) {
if _, err := os.Stat(examples); err != nil {
t.Skipf("examples/skills not found (%v); skipping", err)
}
- avail := Discover(config.SkillsConfig{Local: []config.LocalSkillsConfig{
+ groups := Discover(config.SkillsConfig{Local: []config.LocalSkillsConfig{
{Enabled: true, Path: examples},
}})
- if avail.Empty() {
+ if len(groups) == 0 {
t.Fatal("expected skills from examples/skills, got none")
}
var got []string
- for _, g := range avail.Groups {
+ for _, g := range groups {
for _, s := range g.Skills {
got = append(got, s.ID)
}
diff --git a/internal/skills/skills.go b/internal/skills/skills.go
index f52f93a..1646a34 100644
--- a/internal/skills/skills.go
+++ b/internal/skills/skills.go
@@ -15,20 +15,11 @@
// Package skills defines the mode-agnostic result shape that describes which
// agent skills are available on disk and where. Both skill sources -- the
// Gemini Enterprise Skill Registry (internal/skills/geminienterprise) and the
-// local directory mode (internal/skills/local) -- produce this same shape so a
+// local directory mode (internal/skills/local) -- produce slices of Group so a
// single consumer (e.g. a harness system-instruction builder) can serve both
// without depending on either source package.
package skills
-// Available reports the skills discovered/materialized on disk, grouped by the
-// directory they live in. It is the common currency between skill sources and
-// consumers.
-type Available struct {
- // Groups is one entry per source that produced skills (a registry's
- // target_dir, or a local skills directory).
- Groups []Group
-}
-
// Group associates a set of skills with the directory that contains them. Each
// skill lives at <Dir>/<skill-id>/ (with a SKILL.md inside).
type Group struct {
@@ -44,6 +35,3 @@ type Skill struct {
// Dir is the absolute path of the skill's own folder (<group Dir>/<ID>/).
Dir string
}
-
-// Empty reports whether nothing is available.
-func (a Available) Empty() bool { return len(a.Groups) == 0 }