@@ -28,7 +28,6 @@ const (
2828 skillsRepoName = "databricks-agent-skills"
2929 stableSkillsRepoPath = "skills"
3030 experimentalRepoPath = "experimental"
31- experimentalSuffix = "-experimental"
3231)
3332
3433func manifestHasExperimental (m * Manifest ) bool {
@@ -40,41 +39,13 @@ func manifestHasExperimental(m *Manifest) bool {
4039 return false
4140}
4241
43- // alternateVariantKey maps between "foo" and "foo-experimental".
44- func alternateVariantKey (key string ) string {
45- if base , ok := strings .CutSuffix (key , experimentalSuffix ); ok {
46- return base
47- }
48- return key + experimentalSuffix
49- }
50-
51- // installedSkillVersion returns the recorded version for name, or for its
52- // stable/experimental alternate when only that variant is installed.
53- func installedSkillVersion (state * InstallState , name string ) (version string , selfInstalled , alternateInstalled bool ) {
54- version , selfInstalled = state .Skills [name ]
55- altVersion , alternateInstalled := state .Skills [alternateVariantKey (name )]
56- if ! selfInstalled && alternateInstalled {
57- version = altVersion
58- }
59- return version , selfInstalled , alternateInstalled
60- }
61-
62- func removeAlternateVariant (ctx context.Context , state * InstallState , baseDir , name , scope , cwd string ) {
63- if state == nil {
64- return
65- }
66- alt := alternateVariantKey (name )
67- if _ , ok := state .Skills [alt ]; ! ok {
68- return
69- }
70-
71- altDir := filepath .Join (baseDir , alt )
72- removeSymlinksFromAgents (ctx , alt , altDir , scope , cwd )
73- if err := os .RemoveAll (altDir ); err != nil {
74- log .Warnf (ctx , "Failed to remove previous variant %s: %v" , altDir , err )
42+ func stateRepoDir (state * InstallState , name string ) string {
43+ if state != nil && state .RepoDirs != nil {
44+ if repoDir := state .RepoDirs [name ]; repoDir != "" {
45+ return repoDir
46+ }
7547 }
76- delete (state .Skills , alt )
77- cmdio .LogString (ctx , fmt .Sprintf ("Replaced previous variant %s with %s" , alt , name ))
48+ return stableSkillsRepoPath
7849}
7950
8051// fetchFileFn is the function used to download individual skill files.
@@ -123,8 +94,7 @@ type SkillMeta struct {
12394 RepoDir string `json:"repo_dir,omitempty"`
12495
12596 // SourceName is the upstream skill directory name within RepoDir.
126- // For experimental skills the manifest key is suffixed (-experimental)
127- // but SourceName is not; set during normalization, not from JSON.
97+ // Set during normalization, not from JSON.
12898 SourceName string `json:"-"`
12999}
130100
@@ -262,11 +232,9 @@ func InstallSkillsForAgents(ctx context.Context, src ManifestSource, targetAgent
262232 for _ , name := range skillNames {
263233 meta := targetSkills [name ]
264234
265- removeAlternateVariant (ctx , state , baseDir , name , scope , cwd )
266-
267235 // Idempotency: skip if same version is already installed, the canonical
268236 // dir exists, AND every requested agent already has the skill on disk.
269- if state != nil && state .Skills [name ] == meta .Version {
237+ if state != nil && state .Skills [name ] == meta .Version && stateRepoDir ( state , name ) == meta . RepoDir {
270238 skillDir := filepath .Join (baseDir , name )
271239 if _ , statErr := os .Stat (skillDir ); statErr == nil && allAgentsHaveSkill (ctx , name , targetAgents , scope , cwd ) {
272240 log .Debugf (ctx , "%s v%s already installed for all agents, skipping" , name , meta .Version )
@@ -285,8 +253,12 @@ func InstallSkillsForAgents(ctx context.Context, src ManifestSource, targetAgent
285253 state = & InstallState {
286254 SchemaVersion : 1 ,
287255 Skills : make (map [string ]string , len (targetSkills )),
256+ RepoDirs : make (map [string ]string , len (targetSkills )),
288257 }
289258 }
259+ if state .RepoDirs == nil {
260+ state .RepoDirs = make (map [string ]string , len (state .Skills )+ len (targetSkills ))
261+ }
290262 state .Release = ref
291263 state .LastUpdated = time .Now ()
292264 // IncludeExperimental reflects the last invocation's flag value. The Skills
@@ -296,6 +268,7 @@ func InstallSkillsForAgents(ctx context.Context, src ManifestSource, targetAgent
296268 state .Scope = scope
297269 for name , meta := range targetSkills {
298270 state .Skills [name ] = meta .Version
271+ state .RepoDirs [name ] = meta .RepoDir
299272 }
300273 if err := SaveState (baseDir , state ); err != nil {
301274 return err
0 commit comments