Added importing of configurations exported from AI Studio (#1007)

Co-authored-by: Thorsten Sommer <SommerEngineering@users.noreply.github.com>
This commit is contained in:
Peer HogeterpandThorsten Sommer authored and GitHub committed 2026-10-16 17:22:23 +02:00
1 parent f8c0232cfd
commit 22065783c2
49 files changed
+3257 -263

No files matched your search

@@ -1,7 +1,9 @@
using AIStudio.Provider;
using AIStudio.Tools.PluginSystem;
using Lua;
using SharedTools;
using LuaTable = Lua.LuaTable;
namespace AIStudio.Settings.DataModel;
@@ -177,7 +179,56 @@ public sealed record DataDocumentAnalysisPolicy : ConfigurationBaseObject
IsEnterpriseConfiguration = true,
EnterpriseConfigurationPluginId = configPluginId,
};
return true;
}
/// <summary>
/// Exports the policy as a Lua configuration section.
/// </summary>
/// <remarks>
/// Unlike the other exports, this one keeps the ID of the policy.
/// </remarks>
/// <returns>A Lua configuration section string.</returns>
public string ExportAsConfigurationSection()
{
var preselectedProvider = string.IsNullOrWhiteSpace(this.PreselectedProvider) ? string.Empty : this.PreselectedProvider;
var preselectedProfile = string.IsNullOrWhiteSpace(this.PreselectedProfile) ? string.Empty : this.PreselectedProfile;
var id = string.IsNullOrWhiteSpace(this.Id) ? Guid.NewGuid().ToString() : this.Id;
var allowedToolIds = string.Join(", ", this.AllowedToolIds.OrderBy(x => x, StringComparer.Ordinal).Select(x => LuaTools.ToLuaStringLiteral(x)));
return $$"""
CONFIG["DOCUMENT_ANALYSIS_POLICIES"][#CONFIG["DOCUMENT_ANALYSIS_POLICIES"]+1] = {
["Id"] = "{{id}}",
["PolicyName"] = {{LuaTools.ToLuaStringLiteral(this.PolicyName.Trim())}},
["PolicyDescription"] = {{LuaTools.ToLuaStringLiteral(this.PolicyDescription.Trim())}},
["AnalysisRules"] = {{LuaTools.ToLuaStringLiteral(this.AnalysisRules.Trim(), forceLongString: true)}},
["OutputRules"] = {{LuaTools.ToLuaStringLiteral(this.OutputRules.Trim(), forceLongString: true)}},
-- Optional: minimum provider confidence required for this policy.
-- Allowed values are: NONE, VERY_LOW, LOW, MODERATE, MEDIUM, HIGH
["MinimumProviderConfidence"] = "{{this.MinimumProviderConfidence}}",
-- The tools an analysis with this policy may use, by tool ID.
-- This is a limit, not a preselection: a tool which is not listed here cannot
-- be used for this policy. An empty list means no tools. A listed tool must
-- still meet the confidence requirements of the provider in use.
["AllowedToolIds"] = { {{allowedToolIds}} },
-- Optional: preselect a provider or profile by ID.
-- The IDs must exist in CONFIG["LLM_PROVIDERS"] or CONFIG["PROFILES"].
["PreselectedProvider"] = "{{preselectedProvider}}",
["PreselectedProfile"] = "{{preselectedProfile}}",
-- Optional: hide the policy definition section in the UI.
-- When set to true, users will only see the document selection interface
-- and cannot view or modify the policy settings.
-- This is useful for enterprise configurations where policy details should remain hidden.
-- Allowed values are: true, false (default: false)
["HidePolicyDefinition"] = {{this.HidePolicyDefinition.ToString().ToLowerInvariant()}},
}
""";
}
}