<idea-plugin>
    <dependencies>
        <module name="intellij.platform.frontend"/>
        <module name="kilo.jetbrains.shared"/>
    </dependencies>

    <resource-bundle>messages.KiloBundle</resource-bundle>

    <extensions defaultExtensionNs="com.intellij">
        <applicationService serviceImplementation="ai.kilocode.client.migration.KiloMigrationService"/>
        <applicationService serviceImplementation="ai.kilocode.client.autocomplete.KiloAutocompleteSettingsService"/>
        <customPasteProvider implementation="ai.kilocode.client.session.ui.prompt.PromptAttachmentPasteProvider"/>

        <notificationGroup id="Kilo Code"
                           displayType="BALLOON"
                           bundle="messages.KiloBundle"
                           key="notification.group.kilo"/>

        <toolWindow id="Kilo Code"
                    anchor="left"
                    icon="/icons/kilo.svg"
                    factoryClass="ai.kilocode.client.KiloToolWindowFactory"/>

        <fileEditorProvider id="KiloVfsEditor" implementation="ai.kilocode.client.vfs.KiloFileEditorProvider"/>

        <applicationConfigurable
                parentId="tools"
                id="ai.kilocode.jetbrains.settings"
                instance="ai.kilocode.client.settings.KiloSettingsConfigurable"
                bundle="messages.KiloBundle"
                key="settings.kilo.displayName"/>

        <applicationConfigurable
                parentId="ai.kilocode.jetbrains.settings"
                id="ai.kilocode.jetbrains.settings.profile"
                groupWeight="2"
                instance="ai.kilocode.client.settings.profile.UserProfileConfigurable"
                bundle="messages.KiloBundle"
                key="settings.profile.displayName"/>

        <applicationConfigurable
                parentId="ai.kilocode.jetbrains.settings"
                id="ai.kilocode.jetbrains.settings.models"
                groupWeight="1"
                instance="ai.kilocode.client.settings.models.ModelsConfigurable"
                bundle="messages.KiloBundle"
                key="settings.models.displayName"/>

        <applicationConfigurable
                parentId="ai.kilocode.jetbrains.settings"
                id="ai.kilocode.jetbrains.settings.providers"
                groupWeight="1"
                instance="ai.kilocode.client.settings.providers.ProvidersConfigurable"
                bundle="messages.KiloBundle"
                key="settings.providers.displayName"/>

        <registryKey key="kilo.session.condense"
                     description="Enable event condensing in the session update queue (merges redundant snapshots before model delivery)."
                     defaultValue="true"
                     restartRequired="false"
                     overrides="false"/>
        <registryKey key="kilo.session.flushMs"
                     description="Session update queue flush cadence in milliseconds."
                     defaultValue="150"
                     restartRequired="false"
                     overrides="false"/>
        <registryKey key="kilo.session.inactive.disposeTimeoutMs"
                     description="Milliseconds before hidden session UI is disposed after switching away."
                     defaultValue="180000"
                     restartRequired="false"
                     overrides="false"/>
    </extensions>

    <applicationListeners>
        <listener class="ai.kilocode.client.plugin.KiloFrontendDynamicPluginListener"
                  topic="com.intellij.ide.plugins.DynamicPluginListener"/>
    </applicationListeners>

    <actions>
        <action id="Kilo.Restart"
                class="ai.kilocode.client.actions.RestartKiloAction"/>

        <action id="Kilo.Reinstall"
                class="ai.kilocode.client.actions.ReinstallKiloAction"/>

        <action id="Kilo.OpenSettings"
                class="ai.kilocode.client.actions.OpenSettingsAction"/>

        <action id="Kilo.OpenLocalConfig"
                class="ai.kilocode.client.actions.OpenLocalConfigAction"/>

        <action id="Kilo.OpenGlobalConfig"
                class="ai.kilocode.client.actions.OpenGlobalConfigAction"/>

        <group id="Kilo.CliGroup" text="CLI" popup="true">
            <reference ref="Kilo.Restart"/>
            <reference ref="Kilo.Reinstall"/>
        </group>

        <group id="Kilo.OpenConfigGroup" text="Config Files" popup="true">
            <reference ref="Kilo.OpenLocalConfig"/>
            <reference ref="Kilo.OpenGlobalConfig"/>
        </group>

        <group id="Kilo.SettingsGroup">
            <reference ref="Kilo.OpenSettings"/>
            <separator/>
            <reference ref="Kilo.OpenConfigGroup"/>
            <separator/>
            <reference ref="Kilo.CliGroup"/>
        </group>

        <action id="Kilo.Settings"
                class="ai.kilocode.client.actions.KiloSettingsAction"
                icon="AllIcons.General.GearPlain"/>

        <action id="Kilo.NewSession"
                class="ai.kilocode.client.actions.NewSessionAction"/>

        <action id="Kilo.History"
                class="ai.kilocode.client.actions.HistoryAction"/>

        <!-- Declarative toolbar group for the Kilo tool window title bar -->
        <group id="Kilo.ToolWindowToolbar">
            <reference ref="Kilo.NewSession"/>
            <reference ref="Kilo.History"/>
            <reference ref="Kilo.Settings"/>
        </group>

        <action id="Kilo.SendPrompt"
                class="ai.kilocode.client.actions.SendPromptAction"
                text="Send Prompt"
                description="Send the current Kilo prompt">
            <keyboard-shortcut keymap="$default"
                               first-keystroke="ENTER"/>
            <keyboard-shortcut keymap="Mac OS X 10.5+"
                               first-keystroke="meta ENTER"/>
            <keyboard-shortcut keymap="$default"
                               first-keystroke="control ENTER"/>
        </action>

        <action id="Kilo.StopSession"
                class="ai.kilocode.client.actions.StopSessionAction"
                text="Stop Session"
                description="Stop the current Kilo session">
            <keyboard-shortcut keymap="$default"
                               first-keystroke="alt S"/>
        </action>

        <action id="Kilo.Session.Open"
                class="ai.kilocode.client.actions.OpenSessionAction">
            <keyboard-shortcut keymap="$default" first-keystroke="ENTER"/>
        </action>

        <action id="Kilo.Session.Rename"
                class="ai.kilocode.client.actions.RenameSessionAction"
                use-shortcut-of="RenameElement"/>

        <action id="Kilo.Session.Delete"
                class="ai.kilocode.client.actions.DeleteSessionAction"
                use-shortcut-of="$Delete"/>

        <group id="Kilo.History.ContextMenu">
            <reference ref="Kilo.Session.Open"/>
            <separator/>
            <reference ref="Kilo.Session.Rename"/>
            <reference ref="Kilo.Session.Delete"/>
        </group>

        <group id="Kilo.Session.ContextMenu">
            <reference ref="$Copy"/>
        </group>
    </actions>
</idea-plugin>
