fix(skills): remove ineffective app detection gate
This commit is contained in:
1 parent
9abcdb4deb
commit
04f78bcb15
4 files changed
+21
-29
No files matched your search
@@ -127,7 +127,6 @@ var (
|
||||
skillSetupExecutable = os.Executable
|
||||
skillSetupGetwd = os.Getwd
|
||||
skillSetupUserHomeDir = os.UserHomeDir
|
||||
skillSetupSystemHomeDir = os.UserHomeDir
|
||||
skillSetupRemoveAll = os.RemoveAll
|
||||
skillSetupBackupAndRemove = upgrade.BackupAndRemoveSkillDir
|
||||
skillSetupRestoreBackup = upgrade.RestoreSkillPath
|
||||
@@ -1097,24 +1096,20 @@ func detectExistingAgentHomes(home, mode string) []string {
|
||||
dests := []string{canonical}
|
||||
canonicalKey := skillSetupPathKey(canonical)
|
||||
seen := map[string]bool{canonicalKey: true}
|
||||
systemHome, _ := skillSetupSystemHomeDir()
|
||||
allowSystemApps := sameSkillSetupPath(home, systemHome)
|
||||
addDetected := func(rel, base string) {
|
||||
detectedDir := filepath.Dir(base)
|
||||
switch filepath.ToSlash(filepath.Clean(rel)) {
|
||||
case ".config/kimchi/harness/skills", ".tabnine/agent/skills":
|
||||
detectedDir = filepath.Dir(filepath.Dir(base))
|
||||
case ".zcode/skills":
|
||||
if allowSystemApps {
|
||||
if info, err := skillSetupStat(filepath.Join(string(filepath.Separator), "Applications", "ZCode.app")); err == nil && info.IsDir() {
|
||||
detectedDir = ""
|
||||
}
|
||||
// Application bundles are machine-scoped detection signals. Keep this
|
||||
// independent of HOME so setup matches npm, Shell, and PowerShell.
|
||||
if info, err := skillSetupStat(filepath.Join(string(filepath.Separator), "Applications", "ZCode.app")); err == nil && info.IsDir() {
|
||||
detectedDir = ""
|
||||
}
|
||||
case ".minimax/skills":
|
||||
if allowSystemApps {
|
||||
if info, err := skillSetupStat(filepath.Join(string(filepath.Separator), "Applications", "MiniMax Code.app")); err == nil && info.IsDir() {
|
||||
detectedDir = ""
|
||||
}
|
||||
if info, err := skillSetupStat(filepath.Join(string(filepath.Separator), "Applications", "MiniMax Code.app")); err == nil && info.IsDir() {
|
||||
detectedDir = ""
|
||||
}
|
||||
}
|
||||
if detectedDir != "" {
|
||||
|
||||
@@ -101,8 +101,9 @@ func TestCrossPlatformCoverageSkillSetupCanonicalTargetsAndAgentCapabilities(t *
|
||||
}
|
||||
|
||||
func TestCrossPlatformCoverageSkillSetupDetectsShallowAndApplicationAgents(t *testing.T) {
|
||||
// Keep the destination HOME synthetic: app-bundle detection is deliberately
|
||||
// machine-scoped and must not depend on the selected installation HOME.
|
||||
home := t.TempDir()
|
||||
testseam.Swap(t, &skillSetupSystemHomeDir, func() (string, error) { return home, nil })
|
||||
testseam.Swap(t, &skillSetupGetenv, func(string) string { return "" })
|
||||
for _, dir := range []string{filepath.Join(home, ".config", "kimchi"), filepath.Join(home, ".tabnine")} {
|
||||
if err := os.MkdirAll(dir, 0o755); err != nil {
|
||||
|
||||
@@ -162,8 +162,9 @@ func TestCrossPlatformCoverageCanonicalSkillLinksFallBackToCopies(t *testing.T)
|
||||
}
|
||||
|
||||
func TestCrossPlatformCoverageConfiguredRootsDetectShallowAndApplicationAgents(t *testing.T) {
|
||||
// Keep the destination HOME synthetic: app-bundle detection is deliberately
|
||||
// machine-scoped and must not depend on the selected installation HOME.
|
||||
home := t.TempDir()
|
||||
testseam.Swap(t, &upgradeSystemHomeDir, func() (string, error) { return home, nil })
|
||||
testseam.Swap(t, &upgradeGetenv, func(string) string { return "" })
|
||||
for _, dir := range []string{filepath.Join(home, ".config", "kimchi"), filepath.Join(home, ".tabnine")} {
|
||||
if err := os.MkdirAll(dir, 0o755); err != nil {
|
||||
@@ -196,7 +197,7 @@ func TestCrossPlatformCoverageConfiguredRootsDetectShallowAndApplicationAgents(t
|
||||
for _, root := range configuredSkillRoots(home) {
|
||||
label := filepath.ToSlash(root.label)
|
||||
if _, ok := want[label]; ok {
|
||||
want[label] = skillRootDetectedBase(home, root)
|
||||
want[label] = skillRootDetectedBase(root)
|
||||
}
|
||||
}
|
||||
for label, detected := range want {
|
||||
|
||||
+10
-15
@@ -141,7 +141,6 @@ var universalSkillDirs = map[string]bool{
|
||||
|
||||
var (
|
||||
upgradeUserHomeDir = os.UserHomeDir
|
||||
upgradeSystemHomeDir = os.UserHomeDir
|
||||
upgradeExecutable = os.Executable
|
||||
upgradeEvalSymlinks = filepath.EvalSymlinks
|
||||
upgradeCopyDir = copyDir
|
||||
@@ -693,26 +692,22 @@ func configuredSkillRoots(homeDir string) []resolvedSkillRoot {
|
||||
return roots
|
||||
}
|
||||
|
||||
func skillRootDetectedBase(homeDir string, root resolvedSkillRoot) bool {
|
||||
func skillRootDetectedBase(root resolvedSkillRoot) bool {
|
||||
detectedDir := filepath.Dir(root.base)
|
||||
systemHome, _ := upgradeSystemHomeDir()
|
||||
allowSystemApps := skillRootPathKey(homeDir) == skillRootPathKey(systemHome)
|
||||
switch filepath.ToSlash(filepath.Clean(root.label)) {
|
||||
case ".config/kimchi/harness/skills":
|
||||
detectedDir = filepath.Dir(filepath.Dir(root.base))
|
||||
case ".tabnine/agent/skills":
|
||||
detectedDir = filepath.Dir(filepath.Dir(root.base))
|
||||
case ".zcode/skills":
|
||||
if allowSystemApps {
|
||||
if info, err := upgradeStat(filepath.Join(string(filepath.Separator), "Applications", "ZCode.app")); err == nil && info.IsDir() {
|
||||
return true
|
||||
}
|
||||
// Application bundles are machine-scoped detection signals. Keep this
|
||||
// independent of HOME so upgrade matches npm, Shell, and PowerShell.
|
||||
if info, err := upgradeStat(filepath.Join(string(filepath.Separator), "Applications", "ZCode.app")); err == nil && info.IsDir() {
|
||||
return true
|
||||
}
|
||||
case ".minimax/skills":
|
||||
if allowSystemApps {
|
||||
if info, err := upgradeStat(filepath.Join(string(filepath.Separator), "Applications", "MiniMax Code.app")); err == nil && info.IsDir() {
|
||||
return true
|
||||
}
|
||||
if info, err := upgradeStat(filepath.Join(string(filepath.Separator), "Applications", "MiniMax Code.app")); err == nil && info.IsDir() {
|
||||
return true
|
||||
}
|
||||
}
|
||||
info, err := upgradeStat(detectedDir)
|
||||
@@ -738,7 +733,7 @@ func skillRootPathKey(path string) string {
|
||||
|
||||
func hasDependentSkillRoot(homeDir, canonicalBase string) bool {
|
||||
for _, root := range configuredSkillRoots(homeDir) {
|
||||
if root.canonical || root.universal || isBlacklisted(root.label) || !skillRootDetectedBase(homeDir, root) {
|
||||
if root.canonical || root.universal || isBlacklisted(root.label) || !skillRootDetectedBase(root) {
|
||||
continue
|
||||
}
|
||||
if !samePhysicalSkillRoot(root.base, canonicalBase) {
|
||||
@@ -848,7 +843,7 @@ func upgradeMonoSkillLocations(homeDir, skillSrc string) (*SkillUpgradeResult, e
|
||||
result.Results = append(result.Results, SkillDirResult{Dir: destDir, Status: SkillDirBlacklisted})
|
||||
continue
|
||||
}
|
||||
if !skillRootDetectedBase(homeDir, root) {
|
||||
if !skillRootDetectedBase(root) {
|
||||
result.Results = append(result.Results, SkillDirResult{Dir: destDir, Status: SkillDirSkipped})
|
||||
continue
|
||||
}
|
||||
@@ -920,7 +915,7 @@ func upgradeMultiSkillLocations(homeDir, multiRoot string, skills []string) (*Sk
|
||||
result.Results = append(result.Results, SkillDirResult{Dir: destBase, Status: SkillDirBlacklisted})
|
||||
continue
|
||||
}
|
||||
if !skillRootDetectedBase(homeDir, root) {
|
||||
if !skillRootDetectedBase(root) {
|
||||
result.Results = append(result.Results, SkillDirResult{Dir: destBase, Status: SkillDirSkipped})
|
||||
continue
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user