From b08e9da31c1989d70b6c8c406f30362f554c3be8 Mon Sep 17 00:00:00 2001 From: mollierj-devel Date: Sat, 10 Jan 2026 19:19:45 +0100 Subject: [PATCH 1/2] fix(kilo): Fix malformed YAML in .kilocodemodes file generation ref : https://github.com/bmad-code-org/BMAD-METHOD/issues/1154 - Properly escape customInstructions content in KiloCode mode entries - Replace newlines with spaces to prevent YAML parsing errors - Escape double quotes in instruction text - Wrap customInstructions value in quotes for valid YAML format The issue was caused by direct injection of agent-command-header.md content containing unescaped newlines and special characters, resulting in malformed YAML structure with repeated "Read the full YAML from" text fragments. Fixes: Malformed .kilocodemodes YAML file generation --- tools/cli/installers/lib/ide/kilo.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/cli/installers/lib/ide/kilo.js b/tools/cli/installers/lib/ide/kilo.js index 66cb8c37..40fa7546 100644 --- a/tools/cli/installers/lib/ide/kilo.js +++ b/tools/cli/installers/lib/ide/kilo.js @@ -119,7 +119,9 @@ class KiloSetup extends BaseIdeSetup { modeEntry += ` name: '${icon} ${title}'\n`; modeEntry += ` roleDefinition: ${roleDefinition}\n`; modeEntry += ` whenToUse: ${whenToUse}\n`; - modeEntry += ` customInstructions: ${activationHeader} Read the full YAML from ${relativePath} start activation to alter your state of being follow startup section instructions stay in this being until told to exit this mode\n`; + const customInstructions = `${activationHeader} Read the full YAML from ${relativePath} start activation to alter your state of being follow startup section instructions stay in this being until told to exit this mode`; + const escapedInstructions = customInstructions.replace(/\n/g, ' ').replace(/"/g, '\\"').trim(); + modeEntry += ` customInstructions: "${escapedInstructions}"\n`; modeEntry += ` groups:\n`; modeEntry += ` - read\n`; modeEntry += ` - edit\n`; From 2a9919d16ab53afa19c74cf4765055c10536700f Mon Sep 17 00:00:00 2001 From: mollierj-devel Date: Sat, 10 Jan 2026 19:47:31 +0100 Subject: [PATCH 2/2] Update tools/cli/installers/lib/ide/kilo.js Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- tools/cli/installers/lib/ide/kilo.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/cli/installers/lib/ide/kilo.js b/tools/cli/installers/lib/ide/kilo.js index 40fa7546..0fb080b9 100644 --- a/tools/cli/installers/lib/ide/kilo.js +++ b/tools/cli/installers/lib/ide/kilo.js @@ -119,8 +119,8 @@ class KiloSetup extends BaseIdeSetup { modeEntry += ` name: '${icon} ${title}'\n`; modeEntry += ` roleDefinition: ${roleDefinition}\n`; modeEntry += ` whenToUse: ${whenToUse}\n`; - const customInstructions = `${activationHeader} Read the full YAML from ${relativePath} start activation to alter your state of being follow startup section instructions stay in this being until told to exit this mode`; - const escapedInstructions = customInstructions.replace(/\n/g, ' ').replace(/"/g, '\\"').trim(); + const customInstructions = `${activationHeader || ''} Read the full YAML from ${relativePath} start activation to alter your state of being follow startup section instructions stay in this being until told to exit this mode`; + const escapedInstructions = customInstructions.replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/\n/g, ' ').trim(); modeEntry += ` customInstructions: "${escapedInstructions}"\n`; modeEntry += ` groups:\n`; modeEntry += ` - read\n`;