Ship Assistent 0.11.9: esbuild bundle and patch-keys manifest.
Replace split Assets JS with a built bundle and aligned C#/config so SwarmUI loads one script and patch apply stays consistent; drop legacy terse persona and memory seed. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -9,13 +9,12 @@ using SwarmUI.Utils;
|
||||
|
||||
namespace Mrleo1nid.SwarmAssistent;
|
||||
|
||||
/// <summary>Runtime store in the same sqlite file: chats, ui-state, taste.
|
||||
/// <summary>Runtime store in the same sqlite file: chats, ui-state.
|
||||
/// Config overlays, sidecar cards, and ollama-roles stay on disk.</summary>
|
||||
public sealed partial class AssistentMemory
|
||||
{
|
||||
public const int MaxChatsStored = 200;
|
||||
public const string KvUiState = "ui_state";
|
||||
public const string KvTaste = "taste";
|
||||
|
||||
void EnsureStoreSchema()
|
||||
{
|
||||
@@ -39,7 +38,6 @@ public sealed partial class AssistentMemory
|
||||
CREATE INDEX IF NOT EXISTS idx_chats_updated ON chats(updated_at DESC);
|
||||
""");
|
||||
EnsureChatsFts();
|
||||
MigrateJsonStoreOnce();
|
||||
}
|
||||
|
||||
void EnsureChatsFts()
|
||||
@@ -96,102 +94,6 @@ public sealed partial class AssistentMemory
|
||||
}
|
||||
}
|
||||
|
||||
void MigrateJsonStoreOnce()
|
||||
{
|
||||
if (GetMeta("json_store_migrated") == "1")
|
||||
{
|
||||
return;
|
||||
}
|
||||
string root = Path.Combine(_dataRoot, "Assistent");
|
||||
int chats = 0;
|
||||
string chatsDir = Path.Combine(root, "chats");
|
||||
if (Directory.Exists(chatsDir))
|
||||
{
|
||||
foreach (string file in Directory.EnumerateFiles(chatsDir, "*.json"))
|
||||
{
|
||||
try
|
||||
{
|
||||
JObject chat = JObject.Parse(File.ReadAllText(file, Encoding.UTF8));
|
||||
string id = (chat["id"]?.ToString() ?? Path.GetFileNameWithoutExtension(file) ?? "").Trim();
|
||||
if (string.IsNullOrWhiteSpace(id) || GetChatUnlocked(id) is not null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
UpsertChatUnlocked(chat, id);
|
||||
chats++;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logs.Debug($"AssistentMemory migrate chat {file}: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
ImportKvFile(Path.Combine(root, "ui-state.json"), KvUiState);
|
||||
ImportKvFile(Path.Combine(root, "taste.json"), KvTaste);
|
||||
SetMeta("json_store_migrated", "1");
|
||||
TryArchiveMigratedJson(root, chatsDir);
|
||||
if (chats > 0)
|
||||
{
|
||||
Logs.Debug($"AssistentMemory: migrated {chats} chats from JSON into sqlite");
|
||||
}
|
||||
}
|
||||
|
||||
void ImportKvFile(string path, string key)
|
||||
{
|
||||
if (!File.Exists(path) || !string.IsNullOrEmpty(GetKvUnlocked(key)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
SetKvUnlocked(key, File.ReadAllText(path, Encoding.UTF8));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logs.Debug($"AssistentMemory migrate {key}: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
void TryArchiveMigratedJson(string root, string chatsDir)
|
||||
{
|
||||
try
|
||||
{
|
||||
string dest = Path.Combine(root, "_migrated_json");
|
||||
Directory.CreateDirectory(dest);
|
||||
MoveIfExists(Path.Combine(root, "ui-state.json"), Path.Combine(dest, "ui-state.json"));
|
||||
MoveIfExists(Path.Combine(root, "taste.json"), Path.Combine(dest, "taste.json"));
|
||||
if (!Directory.Exists(chatsDir))
|
||||
{
|
||||
return;
|
||||
}
|
||||
string chatsDest = Path.Combine(dest, "chats");
|
||||
Directory.CreateDirectory(chatsDest);
|
||||
foreach (string file in Directory.EnumerateFiles(chatsDir, "*.json"))
|
||||
{
|
||||
MoveIfExists(file, Path.Combine(chatsDest, Path.GetFileName(file)));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logs.Debug($"AssistentMemory archive json: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
static void MoveIfExists(string src, string dest)
|
||||
{
|
||||
if (!File.Exists(src))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (File.Exists(dest))
|
||||
{
|
||||
File.Delete(src);
|
||||
return;
|
||||
}
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(dest)!);
|
||||
File.Move(src, dest);
|
||||
}
|
||||
|
||||
public string GetKv(string key)
|
||||
{
|
||||
lock (_lock)
|
||||
|
||||
Reference in New Issue
Block a user