跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

Program.cs

25 行 · 1.7 KB历史下载
1using Cage.GuestClipboard;
2using System.Text;
3
4var root = Path.Combine(Path.GetTempPath(), "cage-editor-preferences-" + Guid.NewGuid().ToString("N"));
5var user = Path.Combine(root, "User");
6var file = Path.Combine(user, "settings.json");
7try
8{
9 if (WindowsEditorPreferences.TrustDefault(root) != false) throw new Exception("new Cage preference was not initialized");
10 var original = "{\n // retain this comment 中文\n \"editor.fontSize\": 19,\n}\n";
11 File.WriteAllText(file, original);
12 if (WindowsEditorPreferences.TrustDefault(root) != false || !File.ReadAllText(file).Contains(original[1..], StringComparison.Ordinal)) throw new Exception("existing comments/settings were replaced");
13 foreach (var encoding in new Encoding[] { new UTF8Encoding(true), Encoding.Unicode })
14 {
15 File.WriteAllText(file, "{\"security.workspace.trust.enabled\":true,\"editor.fontSize\":19}", encoding);
16 var before = File.ReadAllBytes(file);
17 if (WindowsEditorPreferences.TrustDefault(root) != true || !File.ReadAllBytes(file).SequenceEqual(before)) throw new Exception("explicit user true or its encoding changed");
18 }
19 File.WriteAllText(file, "{\"security.workspace.trust.enabled\":null}");
20 if (WindowsEditorPreferences.TrustDefault(root) is not null) throw new Exception("invalid explicit preference was overwritten");
21 File.WriteAllText(file, "{malformed user file}");
22 if (WindowsEditorPreferences.TrustDefault(root) is not null || File.ReadAllText(file) != "{malformed user file}") throw new Exception("malformed settings were replaced");
23 Console.WriteLine("Cage editor preference initialization/preservation passed.");
24}
25finally { Directory.Delete(root, true); }