Add plugin node in the manifest.json file if it already exists
When creating a plugin, we should add a plugin node to the MOS manifest.json file if there is a manifest.json file in the output directory. If there is no manifest.json file, we should not create the file.
Plugins node will be called “plugins” and it will be an array of plugins (currently only single plugin definition supported).
“id”: plugin-name provided by the user when creating the plugin. The id also needs to be unique in the array. if there is an existing id with the same name, the plugin-add should thrown an error.
“file”: Local reference to the file in app package. Note: URLs to plugin file hosted on a remote server are not supported
"plugins": [
{
"id": {plugin-name}
"file": "ai-plugin.json"
}
]
@maisarissi I'm a bit confused by a few statements here:
If there is no manifest.json file, we should not create the file: what's the rationale behind that? what should we do instead? warn the user?- is this issue referring to a new command? or are we talking about
kiota plugin add? - what's the value of having an array with unique ids? why not a map instead? unless this is dictated by the manifest format?
Thanks for clarifying all of that!
If there is no manifest.json file, we should not create the file : what's the rationale behind that? what should we do instead? warn the user?
We are not creating MOS files as part of the plugin generation at the time being, and we are not even sure whether we should. Our intention behind this feature is to automatically update the MOS file if existent to help the user with the publishing of the plugin. Also, I believe there is no value warning the user like "there is no MOS file in the output directory so we won't update it", probably the opposite direction and warning them we will add the plugin node would be interesting.
is this issue referring to a new command? or are we talking about kiota plugin add ?
This is related to plugin add when there is no --skip-generation and plugin generate
what's the value of having an array with unique ids? why not a map instead? unless this is dictated by the manifest format?
This is dictated by the MOS format file.
I don't understand why we wouldn't create a basic file if it doesn't exist. Otherwise, how do we have a standalone plugin story?
I've moved the task to backlog for now, as the ask will be impacted depending on future integrations we are planning to. After we figure out integration details, I'll add more info so we can implement this.
Here's what I believe we should do:
- Add a plugin node to the MOS manifest.json file if there is a manifest.json file in the output directory.
"copilotExtensions": {
"plugins": [
{
"id": {plugin-name}
"file": "<generated_plugin_file>.json"
}
]
},
- If there is no
copilotExtensions, add thecopilotExtensionsnode and thepluginsnode. - If there is already a
pluginsnode, ask the user whether they want to replace the existing plugin information and perform the action according to the user's response. - If there is no MOS
manifest.json, we should create a basic manifest with only required information as the following example:
{
"$schema": "https://developer.microsoft.com/json-schemas/teams/vDevPreview/MicrosoftTeams.schema.json",
"manifestVersion": "devPreview",
"version": "1.0.0",
"id": "<generated_GUID>",
"developer": {
"name": "<Defaults to `contact.name` from the OpenAPI document. If the `contact.name` is not available, it defaults to `Kiota Generator, Inc.`>",
"websiteUrl": "<Defaults to `contact.url` from the OpenAPI document. If the `contact.url` is not available, it defaults to `https://www.example.com/contact/`>",
"privacyUrl": "<Defaults to `x-privacy-policy-url` extension from the OpenAPI document. If the `x-privacy-policy-url` is not available, it defaults to `https://www.example.com/privacy/`>",
"termsOfUseUrl": "<Defaults to `termsOfService` from the OpenAPI document. If the `termsOfService` is not available, it defaults to `https://www.example.com/terms/`>"
},
"packageName": "com.microsoft.kiota.plugin.<pluginame>",
"name": {
"short": "<plugin_name>",
"full": "API Plugin <plugin_name> for <OpenAPI document title>"
},
"description": {
"short": "API Plugin for <description from the OpenAPI document>. If the description is not available, it defaults to `API Plugin for <OpenAPI document title>`",
"full": "API Plugin for <description from the OpenAPI document>. If the description is not available, it defaults to `API Plugin for <OpenAPI document title>`"
},
"icons": {
"color": "color.png", (we could default it to a color version of Kiota logo 192x192 pixels where the icon symbol is 96x96 pixels)
"outline": "outline.png" (we could default it to an outline Kiota icon 32x32 pixels.)
},
"accentColor": "#FFFFFF", (let's keep fixed to white)
"copilotExtensions": {
"plugins": [
{
"id": {plugin-name}
"file": "<generated_plugin_file>.json"
}
]
}
}
If there is no plugin with the same Id then I would just create it. If the id already exists, then I would replace. I don't think I would ask the user if they want to overwrite a plugin that has a different name.
This would be true if the manifest accepts more than 1 plugin. AFAIK, the manifest accepts only 1 plugin at time.
Manifest accepts up to 5 plugins, same with declarative copilots.
In that case, I agree with Darrel that we should replace if the plugin already exists in the manifest file or create a new one in case there is no plugin with the same id.
Opened a PR to include what was discussed here as part of the spec: https://github.com/microsoft/kiota/pull/4677/files
Based on last conversation, I have updated the initial issue to make clear Kiota should generate or modify manifest.json file for both VS Code extension and CLI.