From b60eb49603e98764842edfc02e43cfef3f14b927 Mon Sep 17 00:00:00 2001 From: Jeff Haynie Date: Sat, 31 May 2025 19:45:03 -0500 Subject: [PATCH 1/3] Fix issue with agent casing not being considered --- cmd/agent.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cmd/agent.go b/cmd/agent.go index c72884bb..c95f4366 100644 --- a/cmd/agent.go +++ b/cmd/agent.go @@ -395,7 +395,7 @@ func reconcileAgentList(logger logger.Logger, cmd *cobra.Command, apiUrl string, fileAgents := make(map[string]project.AgentConfig) fileAgentsByID := make(map[string]project.AgentConfig) for _, agent := range theproject.Project.Agents { - key := normalAgentName(agent.Name, theproject.Project.IsPython()) + key := normalAgentName(agent.Name, theproject.Project.IsPython()) + agent.Name fileAgents[key] = agent fileAgentsByID[agent.ID] = agent } @@ -406,11 +406,12 @@ func reconcileAgentList(logger logger.Logger, cmd *cobra.Command, apiUrl string, // perform the reconcilation state := make(map[string]agentListState) for _, agent := range remoteAgents { - key := normalAgentName(agent.Name, theproject.Project.IsPython()) + normalizedName := normalAgentName(agent.Name, theproject.Project.IsPython()) + key := normalizedName + agent.Name state[key] = agentListState{ Agent: &agent, - Filename: filepath.Join(agentSrcDir, key, agentFilename), - FoundLocal: util.Exists(filepath.Join(agentSrcDir, key, agentFilename)), + Filename: filepath.Join(agentSrcDir, normalizedName, agentFilename), + FoundLocal: util.Exists(filepath.Join(agentSrcDir, normalizedName, agentFilename)), FoundRemote: true, } } @@ -420,7 +421,7 @@ func reconcileAgentList(logger logger.Logger, cmd *cobra.Command, apiUrl string, } for _, filename := range localAgents { agentName := filepath.Base(filepath.Dir(filename)) - key := normalAgentName(agentName, theproject.Project.IsPython()) + key := normalAgentName(agentName, theproject.Project.IsPython()) + agentName // var found bool // for _, agent := range remoteAgents { // if localAgent, ok := fileAgentsByID[agent.ID]; ok { From ebdbdd03c7447baa3c4a0e4166145efe4eca5dee Mon Sep 17 00:00:00 2001 From: Jeff Haynie Date: Sat, 31 May 2025 19:50:59 -0500 Subject: [PATCH 2/3] make the filename matching a little more robust --- cmd/agent.go | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/cmd/agent.go b/cmd/agent.go index c95f4366..74f55aad 100644 --- a/cmd/agent.go +++ b/cmd/agent.go @@ -408,11 +408,22 @@ func reconcileAgentList(logger logger.Logger, cmd *cobra.Command, apiUrl string, for _, agent := range remoteAgents { normalizedName := normalAgentName(agent.Name, theproject.Project.IsPython()) key := normalizedName + agent.Name - state[key] = agentListState{ - Agent: &agent, - Filename: filepath.Join(agentSrcDir, normalizedName, agentFilename), - FoundLocal: util.Exists(filepath.Join(agentSrcDir, normalizedName, agentFilename)), - FoundRemote: true, + filename1 := filepath.Join(agentSrcDir, normalizedName, agentFilename) + filename2 := filepath.Join(agentSrcDir, agent.Name, agentFilename) + if util.Exists(filename1) { + state[key] = agentListState{ + Agent: &agent, + Filename: filename1, + FoundLocal: true, + FoundRemote: true, + } + } else if util.Exists(filename2) { + state[key] = agentListState{ + Agent: &agent, + Filename: filename2, + FoundLocal: true, + FoundRemote: true, + } } } localAgents, err := util.ListDir(agentSrcDir) @@ -421,7 +432,8 @@ func reconcileAgentList(logger logger.Logger, cmd *cobra.Command, apiUrl string, } for _, filename := range localAgents { agentName := filepath.Base(filepath.Dir(filename)) - key := normalAgentName(agentName, theproject.Project.IsPython()) + agentName + normalizedName := normalAgentName(agentName, theproject.Project.IsPython()) + key := normalizedName + agentName // var found bool // for _, agent := range remoteAgents { // if localAgent, ok := fileAgentsByID[agent.ID]; ok { @@ -445,7 +457,7 @@ func reconcileAgentList(logger logger.Logger, cmd *cobra.Command, apiUrl string, // if found { // continue // } - if filepath.Base(filename) == agentFilename { + if filepath.Base(filename) == agentFilename || filepath.Base(filename) == normalizedName { if found, ok := state[key]; ok { state[key] = agentListState{ Agent: found.Agent, From 795fc6791b8159fd4fb5315f3ef4f4b1af14619c Mon Sep 17 00:00:00 2001 From: Jeff Haynie Date: Sat, 31 May 2025 19:54:19 -0500 Subject: [PATCH 3/3] dont need 2nd check --- cmd/agent.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/agent.go b/cmd/agent.go index 74f55aad..99e1094e 100644 --- a/cmd/agent.go +++ b/cmd/agent.go @@ -457,7 +457,7 @@ func reconcileAgentList(logger logger.Logger, cmd *cobra.Command, apiUrl string, // if found { // continue // } - if filepath.Base(filename) == agentFilename || filepath.Base(filename) == normalizedName { + if filepath.Base(filename) == agentFilename { if found, ok := state[key]; ok { state[key] = agentListState{ Agent: found.Agent,