From 58e91e14bd5659dd57acbb91e56b5fc6a6963c80 Mon Sep 17 00:00:00 2001 From: zayd / cold Date: Sun, 11 Oct 2026 01:07:44 -0700 Subject: [PATCH] fix(setup): preserve unrelated Hermes YAML line formatting Preserve unrelated long YAML scalars when editing an existing Hermes configuration. Co-authored-by: Zayd --- .../ClientConfigurationDocument.ts | 3 ++- .../hermesClientConfiguration.test.ts | 23 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/application/ClientConfigurationDocument.ts b/src/application/ClientConfigurationDocument.ts index c7f13ba66..a6a16f96c 100644 --- a/src/application/ClientConfigurationDocument.ts +++ b/src/application/ClientConfigurationDocument.ts @@ -1342,7 +1342,8 @@ const serializeHermesConfiguration = ( if (entry === undefined) yamlDocument.deleteIn([serversKey, PRODUCT_IDENTITY.mcpServerKey]); else yamlDocument.setIn([serversKey, PRODUCT_IDENTITY.mcpServerKey], entry); - return yamlDocument.toString(); + // Editing REA must not reflow unrelated user prompts or other YAML scalars. + return yamlDocument.toString({ lineWidth: 0 }); }; /** Build the stdio entry shape expected by one client's configuration dialect. */ diff --git a/tests/boundary/filesystem/hermesClientConfiguration.test.ts b/tests/boundary/filesystem/hermesClientConfiguration.test.ts index e2f2cf74c..20db28d9a 100644 --- a/tests/boundary/filesystem/hermesClientConfiguration.test.ts +++ b/tests/boundary/filesystem/hermesClientConfiguration.test.ts @@ -151,6 +151,29 @@ mcp_servers: }); }); + it("keeps unrelated long YAML scalars on their original lines", async () => { + const { home, client } = await hermesClient(); + const prompt = "Keep this sentence on one line. ".repeat(8).trim(); + const original = `# Hermes configuration +model: + personality: ${prompt} +mcp_servers: + other: + command: other-server +`; + await writeFile(client.configPath, original); + expect( + (await configureClientConfiguration(client, {}, command)).status, + ).toBe("configured"); + const text = await readFile(client.configPath, "utf8"); + expect(text).toContain(` personality: ${prompt}\n`); + expect(parseYaml(text)).toMatchObject({ model: { personality: prompt } }); + expect((await systemUninstallHost(home).removeClient(client)).status).toBe( + "removed", + ); + expect(await readFile(client.configPath, "utf8")).toBe(original); + }); + it("creates config.yaml when Hermes has no configuration yet", async () => { const { client } = await hermesClient(); expect(