Forge
csharpc0b81713
1using System.Text.Json;
2
3namespace AgentNotesMcp.Status;
4
5internal static class AgentNotesStatusRuntimeFile
6{
7 internal static void TryWrite(string workspacePath, string statusUrl, string configPath)
8 {
9 if (string.IsNullOrWhiteSpace(workspacePath))
10 return;
11
12 try
13 {
14 var dir = Path.Combine(Path.GetFullPath(workspacePath.Trim()), ".cascade-ide");
15 Directory.CreateDirectory(dir);
16 var payload = new
17 {
18 pid = Environment.ProcessId,
19 port = new Uri(statusUrl).Port,
20 url = statusUrl,
21 config_source = configPath,
22 written_at_utc = DateTimeOffset.UtcNow.ToString("O")
23 };
24 var json = JsonSerializer.Serialize(payload, new JsonSerializerOptions { WriteIndented = true });
25 File.WriteAllText(Path.Combine(dir, "agent-notes-status.runtime.json"), json);
26 }
27 catch
28 {
29 // Best-effort; status HTTP must not fail if runtime file cannot be written.
30 }
31 }
32}
33
View only · write via MCP/CIDE