fix(setup): preserve unrelated Hermes YAML line formatting
Preserve unrelated long YAML scalars when editing an existing Hermes configuration. Co-authored-by: Zayd <iam@zayd.wtf>
This commit is contained in:
@@ -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. */
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user