diff --git a/cmd/agent.go b/cmd/agent.go index c72884bb..99e1094e 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,12 +406,24 @@ 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()) - state[key] = agentListState{ - Agent: &agent, - Filename: filepath.Join(agentSrcDir, key, agentFilename), - FoundLocal: util.Exists(filepath.Join(agentSrcDir, key, agentFilename)), - FoundRemote: true, + normalizedName := normalAgentName(agent.Name, theproject.Project.IsPython()) + key := normalizedName + agent.Name + 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) @@ -420,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()) + normalizedName := normalAgentName(agentName, theproject.Project.IsPython()) + key := normalizedName + agentName // var found bool // for _, agent := range remoteAgents { // if localAgent, ok := fileAgentsByID[agent.ID]; ok {