draftify-cli 1.0.33 → 1.0.37
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 +76 -38
- package/dist/utils/api.js +1 -1
- package/package.json +1 -1
package/dist/repl.js
CHANGED
|
@@ -745,50 +745,88 @@ async function startRepl(initialUsername) {
|
|
|
745
745
|
activeSkillsData = allAvailable.filter((s) => activeSkillNames.includes(s.name));
|
|
746
746
|
}
|
|
747
747
|
const activeActions = new Set();
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
spinner.stop();
|
|
761
|
-
ui_1.ui.fileCreate(filePath);
|
|
762
|
-
spinner.start();
|
|
748
|
+
let rawResult = "";
|
|
749
|
+
let retryCount = 0;
|
|
750
|
+
let success = false;
|
|
751
|
+
let partialText = "";
|
|
752
|
+
while (retryCount < 3 && !success) {
|
|
753
|
+
try {
|
|
754
|
+
let retryHistory = [...conversationHistory];
|
|
755
|
+
let retryPrompt = finalPrompt;
|
|
756
|
+
if (partialText) {
|
|
757
|
+
retryHistory.push({ role: "user", content: finalPrompt });
|
|
758
|
+
retryHistory.push({ role: "assistant", content: partialText });
|
|
759
|
+
retryPrompt = "Continue exactly from where you left off. Do not repeat what you already said, just continue the exact code or sentence you were writing.";
|
|
763
760
|
}
|
|
764
|
-
spinner
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
const filePath = modifyMatch[1];
|
|
768
|
-
const actionKey = `modify:${filePath}`;
|
|
769
|
-
if (!activeActions.has(actionKey)) {
|
|
770
|
-
activeActions.add(actionKey);
|
|
771
|
-
spinner.stop();
|
|
772
|
-
ui_1.ui.fileModify(filePath);
|
|
773
|
-
spinner.start();
|
|
761
|
+
spinner = (0, ui_1.createSpinner)("Thinking...").start();
|
|
762
|
+
if (retryCount > 0) {
|
|
763
|
+
spinner.setPrefix(`Retrying... (${retryCount}/3)`);
|
|
774
764
|
}
|
|
775
|
-
|
|
765
|
+
let thisAttemptText = "";
|
|
766
|
+
const attemptResult = await (0, api_1.refactorCodeApi)(requestPayloadFileName, requestPayloadCode, retryPrompt, retryHistory, currentModel, activeSkillsData, (0, config_1.getThinkingLevel)(), (chunk) => {
|
|
767
|
+
thisAttemptText += chunk;
|
|
768
|
+
currentStreamedText = partialText + thisAttemptText;
|
|
769
|
+
// Find the last opened tag that hasn't been closed yet
|
|
770
|
+
const createMatch = currentStreamedText.match(/<FILE_CREATE\s+path="([^"]+)"[^>]*>(?![\s\S]*<\/FILE_CREATE>)/);
|
|
771
|
+
const modifyMatch = currentStreamedText.match(/<FILE_MODIFY\s+path="([^"]+)"[^>]*>(?![\s\S]*<\/FILE_MODIFY>)/);
|
|
772
|
+
const deleteMatch = currentStreamedText.match(/<FILE_DELETE\s+path="([^"]+)"/);
|
|
773
|
+
if (createMatch) {
|
|
774
|
+
const filePath = createMatch[1];
|
|
775
|
+
const actionKey = `create:${filePath}`;
|
|
776
|
+
if (!activeActions.has(actionKey)) {
|
|
777
|
+
activeActions.add(actionKey);
|
|
778
|
+
spinner.stop();
|
|
779
|
+
ui_1.ui.fileCreate(filePath);
|
|
780
|
+
spinner.start();
|
|
781
|
+
}
|
|
782
|
+
spinner.setPrefix(`Creating ${filePath}...`);
|
|
783
|
+
}
|
|
784
|
+
else if (modifyMatch) {
|
|
785
|
+
const filePath = modifyMatch[1];
|
|
786
|
+
const actionKey = `modify:${filePath}`;
|
|
787
|
+
if (!activeActions.has(actionKey)) {
|
|
788
|
+
activeActions.add(actionKey);
|
|
789
|
+
spinner.stop();
|
|
790
|
+
ui_1.ui.fileModify(filePath);
|
|
791
|
+
spinner.start();
|
|
792
|
+
}
|
|
793
|
+
spinner.setPrefix(`Modifying ${filePath}...`);
|
|
794
|
+
}
|
|
795
|
+
else if (deleteMatch) {
|
|
796
|
+
const filePath = deleteMatch[1];
|
|
797
|
+
const actionKey = `delete:${filePath}`;
|
|
798
|
+
if (!activeActions.has(actionKey)) {
|
|
799
|
+
activeActions.add(actionKey);
|
|
800
|
+
spinner.stop();
|
|
801
|
+
ui_1.ui.fileDelete(filePath);
|
|
802
|
+
spinner.start();
|
|
803
|
+
}
|
|
804
|
+
spinner.setPrefix(`Deleting ${filePath}...`);
|
|
805
|
+
}
|
|
806
|
+
else if (currentStreamedText.length > 10) {
|
|
807
|
+
spinner.setPrefix("Analyzing...");
|
|
808
|
+
}
|
|
809
|
+
}, exports.globalAbortController.signal);
|
|
810
|
+
rawResult = partialText + attemptResult;
|
|
811
|
+
success = true;
|
|
776
812
|
}
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
813
|
+
catch (e) {
|
|
814
|
+
if (e.name === "AbortError" || e.message === "terminated") {
|
|
815
|
+
throw e;
|
|
816
|
+
}
|
|
817
|
+
if (spinner)
|
|
782
818
|
spinner.stop();
|
|
783
|
-
|
|
784
|
-
|
|
819
|
+
const errStr = e.message || String(e);
|
|
820
|
+
// Only print error code / concise message
|
|
821
|
+
ui_1.ui.error(`API Error: ${errStr}. (Attempt ${retryCount + 1}/3)`);
|
|
822
|
+
retryCount++;
|
|
823
|
+
partialText = currentStreamedText;
|
|
824
|
+
if (retryCount >= 3) {
|
|
825
|
+
throw new Error(`Generálás leállt 3 sikertelen próbálkozás után. (Utolsó hiba: ${errStr})`);
|
|
785
826
|
}
|
|
786
|
-
|
|
787
|
-
}
|
|
788
|
-
else if (currentStreamedText.length > 10) {
|
|
789
|
-
spinner.setPrefix("Analyzing...");
|
|
827
|
+
await new Promise(r => setTimeout(r, 2000));
|
|
790
828
|
}
|
|
791
|
-
}
|
|
829
|
+
}
|
|
792
830
|
spinner.stop();
|
|
793
831
|
const { cleanResult, commandsToRun, filesToReadAuto, dirsToListAuto } = await applyFileOperations(rawResult);
|
|
794
832
|
// --- PARSE CLARIFICATION QUESTIONS ---
|
package/dist/utils/api.js
CHANGED
|
@@ -62,7 +62,7 @@ TONE & FORMATTING:
|
|
|
62
62
|
- Warm, but never sycophantic. Do not open with flattery like "great question" or "what a fascinating idea." Just engage with the substance.
|
|
63
63
|
- Default to natural prose. In ordinary conversation, avoid bullet points, headers, and bold text — use them only when the content is genuinely multifaceted or the user asks. A few plain sentences is a fine answer to a simple question.
|
|
64
64
|
- For reports, documentation, and explanations, still write in prose rather than bullet soup, unless a list is actually the clearest format.
|
|
65
|
-
- Keep responses EXTREMELY concise. Your spoken text outside of XML tags MUST NOT exceed 1-2 sentences in total. Get straight to the point without filler.
|
|
65
|
+
- Keep responses EXTREMELY concise. Your spoken text outside of XML tags MUST NOT exceed 1-2 sentences in total. Get straight to the point without filler. HOWEVER, this length limit ONLY applies to conversational text! You MUST still output all necessary <FILE_CREATE>, <FILE_MODIFY>, or other XML tags in the SAME response. Never stop generating just because you reached the 2-sentence limit if you still need to output code tags.
|
|
66
66
|
- Ask at most one question per response, and don't always ask one — try to address the request first, even if it's slightly ambiguous.
|
|
67
67
|
- No emojis unless the user uses them first, and even then, sparingly.
|
|
68
68
|
- Don't curse unless the user does. Don't use pet names or terms of endearment.
|