draftify-cli 1.0.89 → 1.0.90

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/repl.js +29 -0
  2. package/package.json +1 -1
package/dist/repl.js CHANGED
@@ -578,6 +578,35 @@ async function startRepl(initialUsername) {
578
578
  // 3. AI Chat Prompt (default)
579
579
  async function applyFileOperations(result) {
580
580
  let displayResult = result;
581
+ // Pre-process native tool calls (<tool_call> ... </tool_call>) to translate them to FILE_CREATE/FILE_MODIFY
582
+ const toolCallRegex = /<tool_call>([\s\S]*?)<\/(?:tool_call|tool)>/gi;
583
+ let tcMatch;
584
+ while ((tcMatch = toolCallRegex.exec(result)) !== null) {
585
+ const block = tcMatch[1];
586
+ // Find function name
587
+ const funcMatch = block.match(/<function\s+name=['"]([^'"]+)['"]>/i);
588
+ if (funcMatch) {
589
+ const funcName = funcMatch[1].toLowerCase();
590
+ // Find path and content parameters
591
+ const pathMatch = block.match(/<parameter\s+name=['"]path['"]>([\s\S]*?)<\/(?:parameter|param)>/i);
592
+ const contentMatch = block.match(/<parameter\s+name=['"](?:content|code|file_content|patch)['"]>([\s\S]*?)<\/(?:parameter|param)>/i);
593
+ if (pathMatch && contentMatch) {
594
+ const filePath = pathMatch[1].trim();
595
+ const content = contentMatch[1];
596
+ let replacement = "";
597
+ if (funcName.includes("create") || funcName.includes("write") || funcName.includes("new")) {
598
+ replacement = `<FILE_CREATE path="${filePath}">${content}</FILE_CREATE>`;
599
+ }
600
+ else if (funcName.includes("modify") || funcName.includes("edit") || funcName.includes("patch") || funcName.includes("update")) {
601
+ replacement = `<FILE_MODIFY path="${filePath}">${content}</FILE_MODIFY>`;
602
+ }
603
+ if (replacement) {
604
+ result = result.replace(tcMatch[0], replacement);
605
+ displayResult = displayResult.replace(tcMatch[0], replacement);
606
+ }
607
+ }
608
+ }
609
+ }
581
610
  const isSafePath = (targetPath) => {
582
611
  const relative = path_1.default.relative(process.cwd(), targetPath);
583
612
  return !relative.startsWith('..') && !path_1.default.isAbsolute(relative);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "draftify-cli",
3
- "version": "1.0.89",
3
+ "version": "1.0.90",
4
4
  "description": "Draftify AI CLI tool",
5
5
  "main": "dist/index.js",
6
6
  "bin": {