- Add full Telegram bot functionality with Z.AI API integration
- Implement 4 tools: Bash, FileEdit, WebSearch, Git
- Add 3 agents: Code Reviewer, Architect, DevOps Engineer
- Add 6 skills for common coding tasks
- Add systemd service file for 24/7 operation
- Add nginx configuration for HTTPS webhook
- Add comprehensive documentation
- Implement WebSocket server for real-time updates
- Add logging system with Winston
- Add environment validation
🤖 zCode CLI X - Agentic coder with Z.AI + Telegram integration
37 lines
1.5 KiB
JavaScript
37 lines
1.5 KiB
JavaScript
import { getAttr } from "../lib";
|
|
export const evaluateTemplate = (template, options) => {
|
|
const evaluatedTemplateArr = [];
|
|
const templateContext = {
|
|
...options.endpointParams,
|
|
...options.referenceRecord,
|
|
};
|
|
let currentIndex = 0;
|
|
while (currentIndex < template.length) {
|
|
const openingBraceIndex = template.indexOf("{", currentIndex);
|
|
if (openingBraceIndex === -1) {
|
|
evaluatedTemplateArr.push(template.slice(currentIndex));
|
|
break;
|
|
}
|
|
evaluatedTemplateArr.push(template.slice(currentIndex, openingBraceIndex));
|
|
const closingBraceIndex = template.indexOf("}", openingBraceIndex);
|
|
if (closingBraceIndex === -1) {
|
|
evaluatedTemplateArr.push(template.slice(openingBraceIndex));
|
|
break;
|
|
}
|
|
if (template[openingBraceIndex + 1] === "{" && template[closingBraceIndex + 1] === "}") {
|
|
evaluatedTemplateArr.push(template.slice(openingBraceIndex + 1, closingBraceIndex));
|
|
currentIndex = closingBraceIndex + 2;
|
|
}
|
|
const parameterName = template.substring(openingBraceIndex + 1, closingBraceIndex);
|
|
if (parameterName.includes("#")) {
|
|
const [refName, attrName] = parameterName.split("#");
|
|
evaluatedTemplateArr.push(getAttr(templateContext[refName], attrName));
|
|
}
|
|
else {
|
|
evaluatedTemplateArr.push(templateContext[parameterName]);
|
|
}
|
|
currentIndex = closingBraceIndex + 1;
|
|
}
|
|
return evaluatedTemplateArr.join("");
|
|
};
|