kiota icon indicating copy to clipboard operation
kiota copied to clipboard

Add plugin node in the manifest.json file if it already exists

Open maisarissi opened this issue 1 year ago • 10 comments

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 avatar Apr 10 '24 16:04 maisarissi

@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!

baywet avatar Apr 16 '24 15:04 baywet

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.

maisarissi avatar Apr 17 '24 17:04 maisarissi

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?

darrelmiller avatar Apr 17 '24 17:04 darrelmiller

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.

maisarissi avatar Apr 24 '24 13:04 maisarissi

Here's what I believe we should do:

  1. 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"
            }
        ]
    },
  1. If there is no copilotExtensions, add the copilotExtensions node and the plugins node.
  2. If there is already a plugins node, ask the user whether they want to replace the existing plugin information and perform the action according to the user's response.
  3. 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"
            }
        ]
    }
}

maisarissi avatar May 14 '24 19:05 maisarissi

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.

darrelmiller avatar May 14 '24 20:05 darrelmiller

This would be true if the manifest accepts more than 1 plugin. AFAIK, the manifest accepts only 1 plugin at time.

maisarissi avatar May 14 '24 20:05 maisarissi

Manifest accepts up to 5 plugins, same with declarative copilots.

sebastienlevert avatar May 14 '24 20:05 sebastienlevert

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.

maisarissi avatar May 15 '24 15:05 maisarissi

Opened a PR to include what was discussed here as part of the spec: https://github.com/microsoft/kiota/pull/4677/files

maisarissi avatar May 17 '24 19:05 maisarissi

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.

maisarissi avatar Jun 20 '24 14:06 maisarissi