refac tools part 1

This commit is contained in:
Brian Madison
2025-12-22 13:12:25 +08:00
parent 1e721f7fd0
commit 34cfdddd3a
8 changed files with 36 additions and 56 deletions

View File

@@ -1,6 +1,6 @@
const path = require('node:path');
const fs = require('fs-extra');
const { escapeXml } = require('../../lib/xml-utils');
const { escapeXml } = require('./xml-utils');
const AgentPartyGenerator = {
/**

View File

@@ -124,13 +124,6 @@ class XmlHandler {
}
}
/**
* TODO: DELETE THIS METHOD
*/
injectActivationSimple(agentContent, metadata = {}) {
console.error('Error in simple injection:', error);
}
/**
* Build agent from YAML source
* @param {string} yamlPath - Path to .agent.yaml file

View File

@@ -4,7 +4,7 @@ const path = require('node:path');
const crypto = require('node:crypto');
const { AgentAnalyzer } = require('./agent-analyzer');
const { ActivationBuilder } = require('./activation-builder');
const { escapeXml } = require('../../../lib/xml-utils');
const { escapeXml } = require('../xml-utils');
const {
processAgentYaml,
extractInstallConfig,

View File

@@ -0,0 +1,13 @@
/**
* Escape XML special characters in a string
* @param {string} text - The text to escape
* @returns {string} The escaped text
*/
function escapeXml(text) {
if (!text) return '';
return text.replaceAll('&', '&amp;').replaceAll('<', '&lt;').replaceAll('>', '&gt;').replaceAll('"', '&quot;').replaceAll("'", '&apos;');
}
module.exports = {
escapeXml,
};