Templates aus externen Dateien laden, globale USER.md generieren
- Templates/IDENTITY.md, SOUL.md, USER.md als externe Template-Dateien - gott.csproj: Templates werden beim Publish mitkopiert - MemoryService: ReadTemplate() liest aus Templates-Ordner - InitializeAgentFiles: nutzt Templates statt Inline-Strings - InitializeUserFile: erstellt globale USER.md in data/ - AgentEndpoint: HandleUpdate initialisiert fehlende Files beim Speichern
This commit is contained in:
1 parent
96af4a3421
commit
d067517252
6 files changed
+93
-56
No files matched your search
@@ -62,7 +62,7 @@ public static class AgentEndpoint
|
||||
await ctx.Response.WriteAsJsonAsync(agent);
|
||||
}
|
||||
|
||||
private static async Task HandleUpdate(HttpContext ctx, DatabaseService db, ImageService imageService)
|
||||
private static async Task HandleUpdate(HttpContext ctx, DatabaseService db, ImageService imageService, MemoryService memoryService)
|
||||
{
|
||||
var agentId = ctx.Request.RouteValues["agentId"]?.ToString();
|
||||
if (string.IsNullOrEmpty(agentId)) { ctx.Response.StatusCode = 400; return; }
|
||||
@@ -82,6 +82,7 @@ public static class AgentEndpoint
|
||||
if (body.TryGetProperty("autoCommit", out var ac)) agent.AutoCommit = ac.GetBoolean();
|
||||
|
||||
await db.UpdateAgent(agent);
|
||||
memoryService.InitializeAgentFiles(agentId, agent.Name);
|
||||
agent = await db.GetAgent(agentId);
|
||||
await ctx.Response.WriteAsJsonAsync(agent);
|
||||
}
|
||||
|
||||
+29
-26
@@ -8,12 +8,23 @@ namespace Gott.Services;
|
||||
public class MemoryService
|
||||
{
|
||||
private readonly string _dataDir;
|
||||
private readonly string _templateDir;
|
||||
|
||||
public string DataDir => _dataDir;
|
||||
|
||||
public MemoryService(string dataDir)
|
||||
{
|
||||
_dataDir = dataDir;
|
||||
_templateDir = Path.Combine(AppContext.BaseDirectory, "Templates");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Liest ein Template aus dem Templates-Ordner. Gibt null zurück wenn nicht vorhanden.
|
||||
/// </summary>
|
||||
private string ReadTemplate(string fileName)
|
||||
{
|
||||
var path = Path.Combine(_templateDir, fileName);
|
||||
return File.Exists(path) ? File.ReadAllText(path) : null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -85,7 +96,7 @@ public class MemoryService
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Erstellt die Standard-Files (IDENTITY.md, SOUL.md) für einen neuen Agent.
|
||||
/// Erstellt die Standard-Files (IDENTITY.md, SOUL.md) für einen Agent.
|
||||
/// Überschreibt NICHT, falls bereits vorhanden.
|
||||
/// </summary>
|
||||
public void InitializeAgentFiles(string agentId, string agentName)
|
||||
@@ -95,38 +106,30 @@ public class MemoryService
|
||||
var identityPath = Path.Combine(dir, "IDENTITY.md");
|
||||
if (!File.Exists(identityPath))
|
||||
{
|
||||
File.WriteAllText(identityPath,
|
||||
$@"# IDENTITY.md - Who Am I?
|
||||
|
||||
- **Name:** {agentName}
|
||||
- **Creature:** Unbekannt
|
||||
- **Vibe:** Unbekannt
|
||||
- **Language:** Deutsch
|
||||
");
|
||||
var template = ReadTemplate("IDENTITY.md") ?? "# IDENTITY.md\n";
|
||||
File.WriteAllText(identityPath, template.Replace("{NAME}", agentName));
|
||||
}
|
||||
|
||||
var soulPath = Path.Combine(dir, "SOUL.md");
|
||||
if (!File.Exists(soulPath))
|
||||
{
|
||||
File.WriteAllText(soulPath,
|
||||
@"# SOUL.md - Who You Are
|
||||
var template = ReadTemplate("SOUL.md") ?? "# SOUL.md\n";
|
||||
File.WriteAllText(soulPath, template);
|
||||
}
|
||||
|
||||
## Core Truths
|
||||
InitializeUserFile();
|
||||
}
|
||||
|
||||
**Be genuinely helpful, not performatively helpful.** Skip filler words - just help. Actions speak louder.
|
||||
|
||||
**Be resourceful before asking.** Try to figure it out. Read the file. Check the context. _Then_ ask if you're stuck.
|
||||
|
||||
**Earn trust through competence.** Be careful with external actions. Be bold with internal ones (reading, organizing, building).
|
||||
|
||||
## Continuity
|
||||
|
||||
Each session, you wake up fresh. These files _are_ your memory. Read them. Update them. They're how you persist.
|
||||
|
||||
---
|
||||
|
||||
_This file is yours to evolve. As you learn who you are, update it._
|
||||
");
|
||||
/// <summary>
|
||||
/// Erstellt die globale USER.md im Data-Ordner, falls nicht vorhanden.
|
||||
/// </summary>
|
||||
public void InitializeUserFile()
|
||||
{
|
||||
var userPath = Path.Combine(_dataDir, "USER.md");
|
||||
if (!File.Exists(userPath))
|
||||
{
|
||||
var template = ReadTemplate("USER.md") ?? "# USER.md\n";
|
||||
File.WriteAllText(userPath, template);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
# IDENTITY.md - Who Am I?
|
||||
|
||||
- **Name:** {NAME}
|
||||
- **Creature:** Unbekannt
|
||||
- **Vibe:** Unbekannt
|
||||
- **Language:** Deutsch
|
||||
@@ -0,0 +1,17 @@
|
||||
# SOUL.md - Who You Are
|
||||
|
||||
## Core Truths
|
||||
|
||||
**Be genuinely helpful, not performatively helpful.** Skip filler words - just help. Actions speak louder.
|
||||
|
||||
**Be resourceful before asking.** Try to figure it out. Read the file. Check the context. _Then_ ask if you're stuck.
|
||||
|
||||
**Earn trust through competence.** Be careful with external actions. Be bold with internal ones (reading, organizing, building).
|
||||
|
||||
## Continuity
|
||||
|
||||
Each session, you wake up fresh. These files _are_ your memory. Read them. Update them. They're how you persist.
|
||||
|
||||
---
|
||||
|
||||
_This file is yours to evolve. As you learn who you are, update it._
|
||||
@@ -0,0 +1,6 @@
|
||||
# USER.md - About Your Human
|
||||
|
||||
- **Name:** User
|
||||
- **What to call them:** User
|
||||
- **Timezone:** Europe/Vienna (AT)
|
||||
- **Language:** Deutsch
|
||||
+33
-29
@@ -1,29 +1,33 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<NoWarn>ASP0015;IDE0017;IDE0028;IDE0130;IDE0305;IDE1006;SYSLIB1045</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="publish/**" />
|
||||
<Content Remove="publish/**" />
|
||||
<EmbeddedResource Remove="publish/**" />
|
||||
<None Remove="publish/**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="data/**" />
|
||||
<Content Remove="data/**" />
|
||||
<EmbeddedResource Remove="data/**" />
|
||||
<None Remove="data/**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Anthropic" Version="12.8.0" />
|
||||
<PackageReference Include="Dapper" Version="2.1.66" />
|
||||
<PackageReference Include="Microsoft.Data.Sqlite" Version="10.0.3" />
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.12" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<NoWarn>ASP0015;IDE0017;IDE0028;IDE0130;IDE0305;IDE1006;SYSLIB1045</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="publish/**" />
|
||||
<Content Remove="publish/**" />
|
||||
<EmbeddedResource Remove="publish/**" />
|
||||
<None Remove="publish/**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="data/**" />
|
||||
<Content Remove="data/**" />
|
||||
<EmbeddedResource Remove="data/**" />
|
||||
<None Remove="data/**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="Templates/**" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="PreserveNewest" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Anthropic" Version="12.8.0" />
|
||||
<PackageReference Include="Dapper" Version="2.1.66" />
|
||||
<PackageReference Include="Microsoft.Data.Sqlite" Version="10.0.3" />
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.12" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in new issue
Block a user