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