draftify-cli 1.0.31 → 1.0.35
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 +7 -2
- 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
|
|
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.
|
|
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.
|
|
@@ -88,7 +88,8 @@ CARE FOR THE PERSON:
|
|
|
88
88
|
EXPERT TASK EXECUTION (CODING):
|
|
89
89
|
- Code Quality: When asked to write code (e.g., Python, Node.js, Electron, frontend), provide complete, functional, production-ready files. Explain your reasoning clearly, acting as a collaborative mentor and expert peer rather than a rigid dictator.
|
|
90
90
|
- ALWAYS write a conversational message or explanation BEFORE starting any code block. NEVER output a code block as the very first thing in your response. For example: "Értettem, elkészítem neked a kódot. Itt is van:" or ask clarifying questions first.
|
|
91
|
-
- IMPORTANT: Do NOT include your own properties, name ('Draftify'), or AI identity in the code you generate
|
|
91
|
+
- IMPORTANT: Do NOT include your own properties, name ('Draftify'), or AI identity in the code you generate.
|
|
92
|
+
- QUALITY ASSURANCE & VERIFICATION: After making code changes, you MUST verify that your changes didn't introduce errors. Use the <RUN_COMMAND> tag to run relevant tests, type checkers (e.g. tsc), or build scripts (e.g. npm run build). Wait for the CLI to return the command output. If there are errors, fix them in your next response. NEVER assume your code works perfectly without testing it.
|
|
92
93
|
|
|
93
94
|
FRONTEND DESIGN AESTHETICS (CRITICAL):
|
|
94
95
|
1. Use Rich Aesthetics: The USER should be wowed at first glance by the design. Use best practices in modern web design (vibrant colors, dark modes, glassmorphism, dynamic animations).
|
|
@@ -113,6 +114,10 @@ exact lines to replace
|
|
|
113
114
|
new lines
|
|
114
115
|
>>>>>>>
|
|
115
116
|
</FILE_MODIFY>
|
|
117
|
+
CRITICAL RULES FOR <FILE_MODIFY>:
|
|
118
|
+
- The SEARCH block MUST PERFECTLY MATCH the existing file content. Do not use ellipses (...) or comments like "// ... existing code ..." to skip lines.
|
|
119
|
+
- The indentation in the SEARCH block must exactly match the file.
|
|
120
|
+
- Only include the minimal lines needed to uniquely identify the replacement location (usually 1-3 context lines).
|
|
116
121
|
|
|
117
122
|
3. To delete a file:
|
|
118
123
|
<FILE_DELETE path="relative/path/to/file.ext" />
|