draftify-cli 1.0.80 → 1.0.82

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.
package/dist/repl.js CHANGED
@@ -555,7 +555,7 @@ async function startRepl(initialUsername) {
555
555
  const relative = path_1.default.relative(process.cwd(), targetPath);
556
556
  return !relative.startsWith('..') && !path_1.default.isAbsolute(relative);
557
557
  };
558
- const deleteRegex = /<FILE_DELETE\s+path="([^"]+)"\s*(?:\/>|>[\s\S]*?<\/FILE_DELETE>)/gi;
558
+ const deleteRegex = /<FILE_DELETE\s+path=['"]([^'"]+)['"]\s*(?:\/>|>[\s\S]*?<\/FILE_DELETE>)/gi;
559
559
  let match;
560
560
  while ((match = deleteRegex.exec(result)) !== null) {
561
561
  const filePath = match[1];
@@ -576,7 +576,7 @@ async function startRepl(initialUsername) {
576
576
  }
577
577
  }
578
578
  }
579
- const createRegex = /<FILE_CREATE\s+path="([^"]+)">([\s\S]*?)<\/FILE_CREATE>/g;
579
+ const createRegex = /<FILE_CREATE\s+path=['"]([^'"]+)['"]>([\s\S]*?)<\/FILE_CREATE>/gi;
580
580
  while ((match = createRegex.exec(result)) !== null) {
581
581
  const filePath = match[1];
582
582
  const fullPath = path_1.default.resolve(process.cwd(), filePath);
@@ -587,7 +587,10 @@ async function startRepl(initialUsername) {
587
587
  }
588
588
  // Remove leading/trailing newlines that the LLM might have added immediately inside the tag,
589
589
  // but preserve the rest. A simple trim is usually enough, but let's be safe.
590
- const content = match[2].replace(/^\n|\n$/g, '');
590
+ let content = match[2].replace(/^\n|\n$/g, '');
591
+ const mdMatch = content.match(/^```[a-z]*\n([\s\S]*?)```$/i);
592
+ if (mdMatch)
593
+ content = mdMatch[1];
591
594
  try {
592
595
  fs_1.default.mkdirSync(path_1.default.dirname(fullPath), { recursive: true });
593
596
  fs_1.default.writeFileSync(fullPath, content, 'utf-8');
@@ -598,7 +601,7 @@ async function startRepl(initialUsername) {
598
601
  ui_1.ui.error(`Failed to create ${filePath}: ${e.message}`);
599
602
  }
600
603
  }
601
- const modifyRegex = /<FILE_MODIFY\s+path="([^"]+)">([\s\S]*?)<\/FILE_MODIFY>/g;
604
+ const modifyRegex = /<FILE_MODIFY\s+path=['"]([^'"]+)['"]>([\s\S]*?)<\/FILE_MODIFY>/gi;
602
605
  while ((match = modifyRegex.exec(result)) !== null) {
603
606
  const filePath = match[1];
604
607
  const block = match[2];
@@ -773,20 +776,20 @@ async function startRepl(initialUsername) {
773
776
  }
774
777
  }
775
778
  const commandsToRun = [];
776
- const runRegex = /<RUN_COMMAND>([\s\S]*?)<\/RUN_COMMAND>/g;
777
- while ((match = runRegex.exec(result)) !== null) {
779
+ const runCmdRegex = /<RUN_COMMAND>([\s\S]*?)<\/RUN_COMMAND>/gi;
780
+ while ((match = runCmdRegex.exec(result)) !== null) {
778
781
  commandsToRun.push(match[1].trim());
779
782
  displayResult = displayResult.replace(match[0], '');
780
783
  }
781
784
  const filesToReadAuto = [];
782
- const readRegex = /<READ_FILE\s+path="([^"]+)"\s*(?:\/>|>[\s\S]*?<\/READ_FILE>)/gi;
785
+ const readRegex = /<READ_FILE\s+path=['"]([^'"]+)['"]\s*(?:\/>|>[\s\S]*?<\/READ_FILE>)/gi;
783
786
  while ((match = readRegex.exec(result)) !== null) {
784
787
  filesToReadAuto.push(match[1]);
785
788
  displayResult = displayResult.replace(match[0], '');
786
789
  }
787
790
  const dirsToListAuto = [];
788
- const listRegex = /<LIST_DIR\s+path="([^"]+)"\s*(?:\/>|>[\s\S]*?<\/LIST_DIR>)/gi;
789
- while ((match = listRegex.exec(result)) !== null) {
791
+ const listDirRegex = /<LIST_DIR\s+path=['"]([^'"]+)['"]\s*(?:\/>|>[\s\S]*?<\/LIST_DIR>)/gi;
792
+ while ((match = listDirRegex.exec(result)) !== null) {
790
793
  dirsToListAuto.push(match[1]);
791
794
  displayResult = displayResult.replace(match[0], '');
792
795
  }
@@ -49,7 +49,7 @@ function getToken() {
49
49
  function getApiUrl() {
50
50
  const config = getConfig();
51
51
  // Fallback API URL, overrideable via config or DRAFTIFY_API_URL
52
- return process.env.DRAFTIFY_API_URL || config.apiUrl || "https://www.draftify.site/api/cli";
52
+ return process.env.DRAFTIFY_API_URL || config.apiUrl || "http://localhost:3000/api/cli";
53
53
  }
54
54
  function getModel() {
55
55
  const config = getConfig();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "draftify-cli",
3
- "version": "1.0.80",
3
+ "version": "1.0.82",
4
4
  "description": "Draftify AI CLI tool",
5
5
  "main": "dist/index.js",
6
6
  "bin": {