draftify-cli 1.0.79 → 1.0.80
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/commands/refactor.js +1 -3
- package/dist/repl.js +6 -36
- package/dist/utils/api.js +2 -2
- package/dist/utils/config.js +0 -9
- package/dist/utils/ui.js +2 -2
- package/package.json +1 -1
|
@@ -47,9 +47,7 @@ async function refactorCommand(file, options) {
|
|
|
47
47
|
}
|
|
48
48
|
const spinner = (0, ui_1.createSpinner)("Analyzing and refactoring...").start();
|
|
49
49
|
try {
|
|
50
|
-
const result = await (0, api_1.refactorCodeApi)(path_1.default.basename(file), code, instruction, [], (0, config_1.getModel)(), []
|
|
51
|
-
"Medium" // default thinking level
|
|
52
|
-
);
|
|
50
|
+
const result = await (0, api_1.refactorCodeApi)(path_1.default.basename(file), code, instruction, [], (0, config_1.getModel)(), []);
|
|
53
51
|
spinner.stop();
|
|
54
52
|
ui_1.ui.success("Refactoring complete");
|
|
55
53
|
ui_1.ui.divider();
|
package/dist/repl.js
CHANGED
|
@@ -275,7 +275,7 @@ async function startRepl(initialUsername) {
|
|
|
275
275
|
}
|
|
276
276
|
const renderWelcome = () => {
|
|
277
277
|
console.clear();
|
|
278
|
-
ui_1.ui.welcomeScreen(repoName, currentModel, username, plan
|
|
278
|
+
ui_1.ui.welcomeScreen(repoName, currentModel, username, plan);
|
|
279
279
|
};
|
|
280
280
|
renderWelcome();
|
|
281
281
|
let conversationHistory = [];
|
|
@@ -291,7 +291,7 @@ async function startRepl(initialUsername) {
|
|
|
291
291
|
ui_1.ui.info(`Answers automatically sent to the AI.`);
|
|
292
292
|
}
|
|
293
293
|
else {
|
|
294
|
-
const commandsList = ['/new-chat', '/chats', '/skills', '/model', '/
|
|
294
|
+
const commandsList = ['/new-chat', '/chats', '/skills', '/model', '/usage', '/login', '/logout', '/help', '/exit', '/quit'];
|
|
295
295
|
ui_1.ui.divider();
|
|
296
296
|
let answer = await getInteractiveInput((0, kleur_1.dim)("> "), commandsList);
|
|
297
297
|
ui_1.ui.divider();
|
|
@@ -377,7 +377,6 @@ async function startRepl(initialUsername) {
|
|
|
377
377
|
console.log(` ${(0, kleur_1.cyan)("/chats")} - List and load previous chats`);
|
|
378
378
|
console.log(` ${(0, kleur_1.cyan)("/skills")} - Manage and configure skills`);
|
|
379
379
|
console.log(` ${(0, kleur_1.cyan)("/model")} - Switch model (e.g., /model Opus 4.8-level)`);
|
|
380
|
-
console.log(` ${(0, kleur_1.cyan)("/thinking-level")} - Adjust the AI's thinking process depth`);
|
|
381
380
|
console.log(` ${(0, kleur_1.cyan)("/login")} - Log in to your Draftify account`);
|
|
382
381
|
console.log(` ${(0, kleur_1.cyan)("/logout")} - Log out of your account`);
|
|
383
382
|
console.log(` ${(0, kleur_1.cyan)("/usage")} - Show your token usage and quota`);
|
|
@@ -491,34 +490,6 @@ async function startRepl(initialUsername) {
|
|
|
491
490
|
}
|
|
492
491
|
}
|
|
493
492
|
}
|
|
494
|
-
else if (cmd === "thinking-level") {
|
|
495
|
-
const { Select } = require('enquirer');
|
|
496
|
-
try {
|
|
497
|
-
const prompt = new Select({
|
|
498
|
-
name: 'level',
|
|
499
|
-
message: 'Select Thinking Level:',
|
|
500
|
-
choices: [
|
|
501
|
-
{ name: 'Adaptive', message: 'Adaptive - Auto-detect (best)' },
|
|
502
|
-
{ name: 'Low', message: 'Low - Ultra-fast' },
|
|
503
|
-
{ name: 'Medium', message: 'Medium - Balanced' },
|
|
504
|
-
{ name: 'High', message: 'High - Deep logic' },
|
|
505
|
-
{ name: 'Cancel', message: 'Cancel' }
|
|
506
|
-
]
|
|
507
|
-
});
|
|
508
|
-
const answer = await prompt.run();
|
|
509
|
-
if (answer !== 'Cancel') {
|
|
510
|
-
(0, config_1.setThinkingLevel)(answer);
|
|
511
|
-
renderWelcome();
|
|
512
|
-
ui_1.ui.success(`Thinking level updated to: ${answer}`);
|
|
513
|
-
}
|
|
514
|
-
else {
|
|
515
|
-
ui_1.ui.info("Thinking level selection aborted.");
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
catch (e) {
|
|
519
|
-
ui_1.ui.info("Thinking level selection aborted.");
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
493
|
else {
|
|
523
494
|
ui_1.ui.error(`Unknown command: /${cmd}`);
|
|
524
495
|
}
|
|
@@ -857,12 +828,12 @@ async function startRepl(initialUsername) {
|
|
|
857
828
|
retryHistory.push({ role: "assistant", content: partialText });
|
|
858
829
|
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.";
|
|
859
830
|
}
|
|
860
|
-
spinner = (0, ui_1.createSpinner)("
|
|
831
|
+
spinner = (0, ui_1.createSpinner)("Working...").start();
|
|
861
832
|
if (retryCount > 0) {
|
|
862
833
|
spinner.setPrefix(`Retrying... (${retryCount}/3)`);
|
|
863
834
|
}
|
|
864
835
|
let thisAttemptText = "";
|
|
865
|
-
const attemptResult = await (0, api_1.refactorCodeApi)(requestPayloadFileName, requestPayloadCode, retryPrompt, retryHistory, currentModel, activeSkillsData, (
|
|
836
|
+
const attemptResult = await (0, api_1.refactorCodeApi)(requestPayloadFileName, requestPayloadCode, retryPrompt, retryHistory, currentModel, activeSkillsData, (chunk) => {
|
|
866
837
|
thisAttemptText += chunk;
|
|
867
838
|
currentStreamedText = partialText + thisAttemptText;
|
|
868
839
|
// Find the last opened tag that hasn't been closed yet
|
|
@@ -962,9 +933,8 @@ async function startRepl(initialUsername) {
|
|
|
962
933
|
.replace(/<RUN_COMMAND([\s\S]*?)>([\s\S]*?)<\/RUN_COMMAND>/g, '<RUN_COMMAND$1>[Command execution parsed]</RUN_COMMAND>');
|
|
963
934
|
conversationHistory.push({ role: "user", content: tokenOptimizedInput });
|
|
964
935
|
conversationHistory.push({ role: "assistant", content: tokenOptimizedResult });
|
|
965
|
-
// Keep
|
|
966
|
-
const
|
|
967
|
-
const maxHistory = currentThinking === "High" ? 18 : (currentThinking === "Medium" ? 10 : 6);
|
|
936
|
+
// Keep a reasonable history length to prevent infinite token growth
|
|
937
|
+
const maxHistory = 10;
|
|
968
938
|
if (conversationHistory.length > maxHistory) {
|
|
969
939
|
conversationHistory = conversationHistory.slice(conversationHistory.length - maxHistory);
|
|
970
940
|
}
|
package/dist/utils/api.js
CHANGED
|
@@ -9,7 +9,7 @@ exports.getUserUsage = getUserUsage;
|
|
|
9
9
|
const config_1 = require("./config");
|
|
10
10
|
const dotenv_1 = __importDefault(require("dotenv"));
|
|
11
11
|
dotenv_1.default.config();
|
|
12
|
-
async function refactorCodeApi(fileName, code, instruction, history, modelName, skillsData,
|
|
12
|
+
async function refactorCodeApi(fileName, code, instruction, history, modelName, skillsData, onChunk, abortSignal) {
|
|
13
13
|
const token = (0, config_1.getToken)();
|
|
14
14
|
if (!token) {
|
|
15
15
|
throw new Error("No token found. Please run 'draftify login' first.");
|
|
@@ -21,7 +21,7 @@ async function refactorCodeApi(fileName, code, instruction, history, modelName,
|
|
|
21
21
|
"Content-Type": "application/json",
|
|
22
22
|
Authorization: `Bearer ${token}`
|
|
23
23
|
},
|
|
24
|
-
body: JSON.stringify({ fileName, code, instruction: `[SYSTEM NOTE: You are the ${modelName} model. If asked about your identity, you MUST state exactly: "Én a ${modelName} modell vagyok a Draftify platformon."]\n\n` + instruction, history, modelName, skillsData
|
|
24
|
+
body: JSON.stringify({ fileName, code, instruction: `[SYSTEM NOTE: You are the ${modelName} model. If asked about your identity, you MUST state exactly: "Én a ${modelName} modell vagyok a Draftify platformon."]\n\n` + instruction, history, modelName, skillsData }),
|
|
25
25
|
signal: abortSignal
|
|
26
26
|
});
|
|
27
27
|
if (!response.ok) {
|
package/dist/utils/config.js
CHANGED
|
@@ -11,8 +11,6 @@ exports.getModel = getModel;
|
|
|
11
11
|
exports.setModel = setModel;
|
|
12
12
|
exports.getSkills = getSkills;
|
|
13
13
|
exports.setSkills = setSkills;
|
|
14
|
-
exports.getThinkingLevel = getThinkingLevel;
|
|
15
|
-
exports.setThinkingLevel = setThinkingLevel;
|
|
16
14
|
exports.getGeminiApiKey = getGeminiApiKey;
|
|
17
15
|
exports.getTokensUsed = getTokensUsed;
|
|
18
16
|
exports.addTokensUsed = addTokensUsed;
|
|
@@ -67,13 +65,6 @@ function getSkills() {
|
|
|
67
65
|
function setSkills(skills) {
|
|
68
66
|
saveConfig({ skills });
|
|
69
67
|
}
|
|
70
|
-
function getThinkingLevel() {
|
|
71
|
-
const config = getConfig();
|
|
72
|
-
return config.thinkingLevel || 'Medium';
|
|
73
|
-
}
|
|
74
|
-
function setThinkingLevel(level) {
|
|
75
|
-
saveConfig({ thinkingLevel: level });
|
|
76
|
-
}
|
|
77
68
|
function getGeminiApiKey() {
|
|
78
69
|
const config = getConfig();
|
|
79
70
|
return config.geminiApiKey || null;
|
package/dist/utils/ui.js
CHANGED
|
@@ -106,7 +106,7 @@ exports.ui = {
|
|
|
106
106
|
const text = `Draftify Scale | Engine: ${model} | Repo: ${repoName}`;
|
|
107
107
|
console.log(`\n ${(0, kleur_1.dim)(`[${text}]`)}`);
|
|
108
108
|
},
|
|
109
|
-
welcomeScreen: (repoName, model, username, plan = "Draftify Scale"
|
|
109
|
+
welcomeScreen: (repoName, model, username, plan = "Draftify Scale") => {
|
|
110
110
|
resetInline();
|
|
111
111
|
// Borderless Claude Code style with strong orange logo
|
|
112
112
|
const orange = (s) => `\x1b[38;5;208m${s}\x1b[0m`;
|
|
@@ -116,7 +116,7 @@ exports.ui = {
|
|
|
116
116
|
const greeting = username ? `Welcome ${username} to Draftify Code!` : "Welcome to Draftify Code!";
|
|
117
117
|
console.log(` ${orange("█ █ █ █")} ${white(greeting)}`);
|
|
118
118
|
console.log(` ${orange("█████████")} ${white("Draftify Code ")}${gray("v1.0.0")}`);
|
|
119
|
-
console.log(` ${orange("█ █████ █")} ${gray(`${model}
|
|
119
|
+
console.log(` ${orange("█ █████ █")} ${gray(`${model} [${plan}]`)}`);
|
|
120
120
|
console.log(` ${orange("█████████")} ${gray(process.cwd())}`);
|
|
121
121
|
console.log(` ${orange(" █ █ ")}`);
|
|
122
122
|
console.log("");
|