<idea-plugin>
    <id>com.envforge.ide</id>
    <name>EnvForge</name>
    <version>0.1.6</version>
    <vendor email="emre@envforge.dev" url="https://github.com/emreerinc/envforge">Emre Erinc</vendor>

  <description><![CDATA[
<p>Environment variable management with schema validation, secret scanning, and multi-profile support.</p>
<ul>
<li><b>Diagnostics</b> — Missing required vars, type errors, secret leak warnings</li>
<li><b>Hover</b> — Schema info: type, description, default, example</li>
<li><b>Completions</b> — Key names from .env.schema</li>
<li><b>Go-to-definition</b> — Jump from .env key to .env.schema section</li>
<li><b>Commands</b> — Validate, scan, export, sync, profile switch</li>
<li><b>Security Dashboard</b> — Fence, Guard, MCP Scan, Canary Tokens</li>
<li><b>AI Safety</b> — Fence blocks AI from reading env vars; Guard detects prompt injection</li>
</ul>
<p>Requires <code>envforge</code> CLI installed. Get it: <code>cargo install env-forge-tui</code></p>
  ]]></description>

    <depends>com.intellij.modules.platform</depends>
    <depends>com.redhat.devtools.lsp4ij</depends>
    <depends>org.toml.lang</depends>

    <extensions defaultExtensionNs="com.redhat.devtools.lsp4ij">
        <server id="envforgeLsp"
                name="EnvForge"
                factoryClass="com.envforge.intellij.EnvForgeLspFactory"/>

        <languageMapping language="EnvForgeEnv"
                         serverId="envforgeLsp"/>
        <!-- Schema files are TOML-typed for highlighting; LSP attaches by filename. -->
        <languageMapping language="TOML"
                         serverId="envforgeLsp"
                         fileNamePattern=".env.schema.toml"/>
        <languageMapping language="TOML"
                         serverId="envforgeLsp"
                         fileNamePattern=".env.schema"/>
        <!--
        Source-language mappings: enable goto-definition from code that
        reads env vars (process.env.X, os.environ["X"], std::env::var,
        os.Getenv, System.getenv, etc.) back to the .env.schema entry.
        Each mapping is best-effort — if the IDE edition lacks the
        language plugin (e.g. Python on IntelliJ Community), lsp4ij
        silently skips that mapping.
        -->
        <languageMapping language="JAVA" serverId="envforgeLsp"/>
        <languageMapping language="kotlin" serverId="envforgeLsp"/>
        <languageMapping language="Python" serverId="envforgeLsp"/>
        <languageMapping language="TypeScript" serverId="envforgeLsp"/>
        <languageMapping language="JavaScript" serverId="envforgeLsp"/>
        <languageMapping language="ECMAScript 6" serverId="envforgeLsp"/>
        <languageMapping language="go" serverId="envforgeLsp"/>
        <languageMapping language="Rust" serverId="envforgeLsp"/>
        <languageMapping language="ruby" serverId="envforgeLsp"/>
        <languageMapping language="PHP" serverId="envforgeLsp"/>
        <languageMapping language="C#" serverId="envforgeLsp"/>
        <languageMapping language="Shell Script" serverId="envforgeLsp"/>
        <!--
        MCP configuration files. Routed by filename only (JSON language
        binding picks up arbitrary JSON files; we filter to mcp/claude
        files via fileNamePattern). LSP server emits inline diagnostics
        for hardcoded credentials in these files.
        -->
        <languageMapping language="JSON" serverId="envforgeLsp" fileNamePattern="mcp.json"/>
        <languageMapping language="JSON" serverId="envforgeLsp" fileNamePattern=".mcp.json"/>
        <languageMapping language="JSON" serverId="envforgeLsp" fileNamePattern="claude_desktop_config.json"/>
        <languageMapping language="JSON" serverId="envforgeLsp" fileNamePattern="settings.json"/>
    </extensions>

  <extensions defaultExtensionNs="com.intellij">
    <fileType name="EnvForge .env"
              implementationClass="com.envforge.intellij.EnvFileType"
              fieldName="INSTANCE"
              language="EnvForgeEnv"
              extensions="env"
              fileNames=".env"
              patterns=".env.*;*.env"/>
    <!-- Schema files → TOML (exact fileNames beat EnvForge .env glob). -->
    <fileType name="TOML"
              fileNames=".env.schema.toml;.env.schema"/>
    <lang.parserDefinition language="EnvForgeEnv"
                           implementationClass="com.envforge.intellij.EnvParserDefinition"/>
    <toolWindow id="EnvForge"
                anchor="right"
                icon="/icons/envforge.svg"
                factoryClass="com.envforge.intellij.EnvForgeToolWindowFactory"/>
    <statusBarWidgetFactory id="EnvForgeStatus"
                            implementation="com.envforge.intellij.EnvForgeStatusBarFactory"
                            order="after Position"/>
    <notificationGroup id="EnvForge"
                       displayType="BALLOON"/>
    <editorFactoryListener implementation="com.envforge.intellij.EnvForgeExposureEditorListener"/>
    <projectViewNodeDecorator implementation="com.envforge.intellij.EnvForgeProjectViewDecorator"/>
    <localInspection id="FenceInactive"
                     language=""
                     groupName="EnvForge"
                     displayName="Fence Inactive"
                     enabledByDefault="true"
                     level="WARNING"
                     implementationClass="com.envforge.intellij.FenceInactiveInspection"/>
  </extensions>

    <actions>
        <!-- File context menu: appears on right-click in project tree and editor for .env files -->
        <group id="EnvForge.FileMenu"
               class="com.envforge.intellij.actions.EnvForgeFileActionGroup"
               text="EnvForge" popup="true"
               icon="/icons/envforge.svg">
            <add-to-group group-id="ProjectViewPopupMenu" anchor="last"/>
            <add-to-group group-id="EditorPopupMenu" anchor="last"/>
        </group>

  <group id="EnvForge.Menu" text="EnvForge" popup="true">
        <add-to-group group-id="ToolsMenu" anchor="last"/>

        <action id="EnvForge.RunWizard"
                class="com.envforge.intellij.actions.RunWizardAction"
                text="Run Project Wizard"
                description="Launch guided EnvForge project setup wizard"/>

        <action id="EnvForge.ProjectInit"
                class="com.envforge.intellij.actions.ProjectInitAction"
                text="Initialize Project (non-interactive)"
                description="Scaffold a new EnvForge project with defaults"/>

        <separator/>

        <action id="EnvForge.List"
                class="com.envforge.intellij.actions.ListAction"
                text="List Variables"
                description="List all environment variables"/>

        <action id="EnvForge.ProfileSwitch"
                class="com.envforge.intellij.actions.ProfileSwitchAction"
                text="Switch Profile..."
                description="Switch to a different profile"/>

        <action id="EnvForge.ProfileDiff"
                class="com.envforge.intellij.actions.ProfileDiffAction"
                text="Diff Profiles..."
                description="Compare two profiles"/>

        <separator/>

        <action id="EnvForge.ToggleFence"
                class="com.envforge.intellij.actions.ToggleFenceAction"
                text="Toggle Fence"
                description="Toggle EnvForge Fence on/off"/>

        <action id="EnvForge.ToggleGuard"
                class="com.envforge.intellij.actions.ToggleGuardAction"
                text="Toggle Guard"
                description="Toggle EnvForge AI-guard on/off"/>

        <action id="EnvForge.RunMcpScan"
                class="com.envforge.intellij.actions.RunMcpScanAction"
                text="Run MCP Scan"
                description="Scan MCP server configs for security issues"/>

        <action id="EnvForge.AddCanary"
                class="com.envforge.intellij.actions.AddCanaryAction"
                text="Add Canary Token..."
                description="Add a canary token to detect secret exfiltration"/>

        <action id="EnvForge.RemoveCanary"
                class="com.envforge.intellij.actions.RemoveCanaryAction"
                text="Remove Canary Token..."
                description="Remove a canary token"/>

        <separator/>

        <action id="EnvForge.Validate"
                class="com.envforge.intellij.actions.ValidateAction"
                text="Validate Against Schema"
                description="Run envforge schema validation"/>

        <action id="EnvForge.Scan"
                class="com.envforge.intellij.actions.ScanAction"
                text="Scan for Secret Leaks"
                description="Scan for leaked secrets"/>

        <action id="EnvForge.Doctor"
                class="com.envforge.intellij.actions.DoctorAction"
                text="Health Check"
                description="Run envforge health check"/>

        <action id="EnvForge.Check"
                class="com.envforge.intellij.actions.CheckAction"
                text="Run All Checks"
                description="Run doctor + validate + scan + age + drift"/>

        <action id="EnvForge.Export"
                class="com.envforge.intellij.actions.ExportAction"
                text="Export Variables..."
                description="Export env vars to different formats"/>

        <action id="EnvForge.SyncPush"
                class="com.envforge.intellij.actions.SyncPushAction"
                text="Sync Push"
                description="Push env changes to remote"/>

        <action id="EnvForge.SyncPull"
                class="com.envforge.intellij.actions.SyncPullAction"
                text="Sync Pull"
                description="Pull env changes from remote"/>

        <action id="EnvForge.SchemaGenerate"
                class="com.envforge.intellij.actions.SchemaGenerateAction"
                text="Generate Schema"
                description="Generate .env.schema from current variables"/>

        <separator/>

        <action id="EnvForge.RunVolatile"
                class="com.envforge.intellij.actions.RunVolatileAction"
                text="Run Command (Volatile Session)..."
                description="Wrap a shell command in a short-lived envforge session"/>

        <action id="EnvForge.RevealValue"
                class="com.envforge.intellij.actions.RevealValueAction"
                text="Reveal Value (Audit-logged)..."
                description="Show a single env var value; reveal is recorded to the envforge audit stream"/>

        <action id="EnvForge.CanaryCheck"
                class="com.envforge.intellij.actions.CanaryCheckAction"
                text="Check Triggered Canaries"
                description="List canary tripwires that have fired"/>

        <action id="EnvForge.CanaryScan"
                class="com.envforge.intellij.actions.CanaryScanAction"
                text="Scan Text/File for Canary Tokens..."
                description="Scan pasted text, a file, or the editor selection for registered canary tokens"/>

        <action id="EnvForge.ExtendLease"
                class="com.envforge.intellij.actions.ExtendLeaseAction"
                text="Extend Volatile Lease..."
                description="Extend the soonest-expiring active envforge lease"/>
      </group>
    </actions>
</idea-plugin>
