Repository: microsoft/kiota (csharp)

Issue:
We shouldn't delete the declarativeCopilot node when adding the plugins node in the manifest.json
When creating a plugin, we are adding the plugins node if there is a manifest.json file in the output directory.

I have created a declarative copilot using TTK, which creates the project with a declarativeCopilot.json and a manifest.json files.
The manifest.json is created with the following copilotExtension node:

```jsonc
"copilotExtensions": {
        "declarativeCopilots": [            
            {
                "id": "declarativeCopilot",
                "file": "declarativeCopilot.json"
            }
        ]
}
```

However, when Kiota is creating the plugin, its replace the above with the following:

```jsonc
"copilotExtensions": {
        "plugins": [
            {
                "id": "myplugin",
                "file": "myplugin-apiplugin.json"
            }
        ]
}
```

The expected behaviour would be to keep what is in it, and add the plugins node:

```jsonc
"copilotExtensions": {
        "declarativeCopilots": [            
            {
                "id": "declarativeCopilot",
                "file": "declarativeCopilot.json"
            }
        ],
        "plugins": [
            {
                "id": "myplugin",
                "file": "myplugin-apiplugin.json"
            }
        ]
}
```

Also, if there is already a plugin node like the above, when adding another plugin to the same project, the expected behavior is the following:

```jsonc
"copilotExtensions": {
        "declarativeCopilots": [            
            {
                "id": "declarativeCopilot",
                "file": "declarativeCopilot.json"
            }
        ],
        "plugins": [
            {
                "id": "myplugin",
                "file": "myplugin-apiplugin.json"
            },
            {
                "id": "anotherplugin",
                "file": "anotherplugin-apiplugin.json"
            }
        ]
}
```

Pull request description:
fixes #4935

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8811159f84..7250b88e23 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 - Implemented partial class model declarations. [4894](https://github.com/microsoft/kiota/issues/4894)
 - Fixed a bug where the Go file names were too long
+- Fixed a bug where the declarative copilot information would be erased if any. [#4935](https://github.com/microsoft/kiota/issues/4935)
 - Fixes bug with model names in Go generated from camel case namespace. [https://github.com/microsoftgraph/msgraph-sdk-go/issues/721]
 - Plugins OpenAPI extensions are only added when generating plugins to reduce the risk of parsing errors. [#4834](https://github.com/microsoft/kiota/issues/4834)
 - TypeScript imports are now using ES6 imports with the .js extension.
diff --git a/src/Kiota.Builder/Plugins/Models/AppManifestModel.cs b/src/Kiota.Builder/Plugins/Models/AppManifestModel.cs
index 5ef0fae47a..d277469cb4 100644
--- a/src/Kiota.Builder/Plugins/Models/AppManifestModel.cs
+++ b/src/Kiota.Builder/Plugins/Models/AppManifestModel.cs
@@ -144,7 +144,10 @@ public string? Outline
 
 internal class CopilotExtensions
 {
-    public IList<Plugin> Plugins { get; set; } = new List<Plugin>();
+    public IList<Plugin> Plugins { get; set; } = [];
+    public IList<DeclarativeCopilot> DeclarativeCopilots { get; set; } = [];
+    [JsonExtensionData]
+    public Dictionary<string, Object> AdditionalData { get; set; } = new();
 }
 
 internal class Plugin
@@ -158,3 +161,15 @@ public string? File
         get; set;
     }
 }
+
+internal class DeclarativeCopilot
+{
+    public string? Id
+    {
+        get; set;
+    }
+    public string? File
+    {
+        get; set;
+    }
+}


Test patch:
diff --git a/tests/Kiota.Builder.Tests/Plugins/PluginsGenerationServiceTests.cs b/tests/Kiota.Builder.Tests/Plugins/PluginsGenerationServiceTests.cs
index 77469edd74..3390e7d49e 100644
--- a/tests/Kiota.Builder.Tests/Plugins/PluginsGenerationServiceTests.cs
+++ b/tests/Kiota.Builder.Tests/Plugins/PluginsGenerationServiceTests.cs
@@ -586,6 +586,12 @@ public async Task GeneratesManifestAndUpdatesExistingAppManifestWithExistingPlug
                 ""id"": ""client"",
                 ""file"": ""dummyFile.json""
             }
+        ],
+        ""declarativeCopilots"": [
+            {
+                ""id"": ""client"",
+                ""file"": ""dummyFile.json""
+            }
         ]
     }
 }";
@@ -612,6 +618,9 @@ public async Task GeneratesManifestAndUpdatesExistingAppManifestWithExistingPlug
         Assert.NotNull(originalAppManifestModelObject.CopilotExtensions);
         Assert.Single(originalAppManifestModelObject.CopilotExtensions.Plugins);//one plugin present
         Assert.Equal("dummyFile.json", originalAppManifestModelObject.CopilotExtensions.Plugins[0].File); // no plugins present
+        Assert.Single(originalAppManifestModelObject.CopilotExtensions.DeclarativeCopilots);// one declarative copilot present
+        Assert.Equal("dummyFile.json", originalAppManifestModelObject.CopilotExtensions.DeclarativeCopilots[0].File); // no plugins present
+
 
         // Run the plugin generation
         var pluginsGenerationService = new PluginsGenerationService(openApiDocument, urlTreeNode, generationConfiguration, workingDirectory);
@@ -629,6 +638,8 @@ public async Task GeneratesManifestAndUpdatesExistingAppManifestWithExistingPlug
         Assert.Equal("Test Name", originalAppManifestModelObject.Developer.Name); // developer name is same
         Assert.Equal("client", appManifestModelObject.CopilotExtensions.Plugins[0].Id);
         Assert.Equal(ManifestFileName, appManifestModelObject.CopilotExtensions.Plugins[0].File);// file name is updated
+        Assert.Single(appManifestModelObject.CopilotExtensions.DeclarativeCopilots);// we didn't erase the existing declarative copilots
+        Assert.Equal("dummyFile.json", appManifestModelObject.CopilotExtensions.DeclarativeCopilots[0].File); // no plugins present
     }
     [Fact]
     public async Task GeneratesManifestAndCleansUpInputDescription()