From f38905628a9a13d5d47ca287ecc785f9fbc9ae5b Mon Sep 17 00:00:00 2001 From: fxomo <59278250+fxomo@users.noreply.github.com> Date: Sun, 16 Nov 2025 14:36:32 +0800 Subject: [PATCH] Fix: Add prompts and memories merging from customize.yaml (#889) - Add merging logic for customizeYaml.prompts and customizeYaml.memories in loadAndMergeAgent() - Implement buildMemoriesXml() method to output memories XML section - Update buildPromptsXml() to use wrapper instead of CDATA for better compatibility - Integrate memories output into convertToXml() between persona and prompts sections Changes: 1. Line 123-131: Added prompts and memories append logic in loadAndMergeAgent() 2. Line 215-218: Added memories XML output in convertToXml() 3. Line 286-301: New buildMemoriesXml() method 4. Line 312-315: Updated prompts to use wrapper for consistency This allows users to customize agents via bmad/_cfg/agents/*.customize.yaml with: - prompts: Array of {id, content} objects for action handlers - memories: Array of strings for persistent agent memories --- tools/cli/lib/yaml-xml-builder.js | 38 ++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/tools/cli/lib/yaml-xml-builder.js b/tools/cli/lib/yaml-xml-builder.js index 2786d7f5..b4ad8cf8 100644 --- a/tools/cli/lib/yaml-xml-builder.js +++ b/tools/cli/lib/yaml-xml-builder.js @@ -119,6 +119,16 @@ class YamlXmlBuilder { if (customizeYaml.critical_actions) { merged.agent.critical_actions = [...(merged.agent.critical_actions || []), ...customizeYaml.critical_actions]; } + + // Append prompts + if (customizeYaml.prompts) { + merged.agent.prompts = [...(merged.agent.prompts || []), ...customizeYaml.prompts]; + } + + // Append memories + if (customizeYaml.memories) { + merged.agent.memories = [...(merged.agent.memories || []), ...customizeYaml.memories]; + } } } @@ -202,6 +212,11 @@ class YamlXmlBuilder { // Persona section xml += this.buildPersonaXml(agent.persona); + // Memories section (if exists) + if (agent.memories) { + xml += this.buildMemoriesXml(agent.memories); + } + // Prompts section (if exists) if (agent.prompts) { xml += this.buildPromptsXml(agent.prompts); @@ -268,6 +283,23 @@ class YamlXmlBuilder { return xml; } + /** + * Build memories XML section + */ + buildMemoriesXml(memories) { + if (!memories || memories.length === 0) return ''; + + let xml = ' \n'; + + for (const memory of memories) { + xml += ` ${this.escapeXml(memory)}\n`; + } + + xml += ' \n'; + + return xml; + } + /** * Build prompts XML section * Handles both array format and object/dictionary format @@ -296,9 +328,9 @@ class YamlXmlBuilder { for (const prompt of promptsArray) { xml += ` \n`; - xml += ` \n`; + xml += ` \n`; + xml += `${this.escapeXml(prompt.content || '')}\n`; + xml += ` \n`; xml += ` \n`; }