draftify-cli 1.0.10 → 1.0.12
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/login.js +1 -1
- package/dist/repl.js +11 -2
- package/dist/utils/api.js +3 -15
- package/dist/utils/config.js +1 -1
- package/package.json +1 -1
package/dist/commands/login.js
CHANGED
|
@@ -11,7 +11,7 @@ const config_1 = require("../utils/config");
|
|
|
11
11
|
const ui_1 = require("../utils/ui");
|
|
12
12
|
const kleur_1 = require("kleur");
|
|
13
13
|
// Default Draftify URL, can be overridden by env
|
|
14
|
-
const DRAFTIFY_WEB_URL = process.env.DRAFTIFY_WEB_URL || "https://draftify
|
|
14
|
+
const DRAFTIFY_WEB_URL = process.env.DRAFTIFY_WEB_URL || "https://draftify.site";
|
|
15
15
|
async function loginCommand() {
|
|
16
16
|
const code = crypto_1.default.randomBytes(4).toString("hex");
|
|
17
17
|
const authUrl = `${DRAFTIFY_WEB_URL}/auth/cli?code=${code}`;
|
package/dist/repl.js
CHANGED
|
@@ -666,14 +666,23 @@ async function startRepl(initialUsername) {
|
|
|
666
666
|
diffApplied = true;
|
|
667
667
|
}
|
|
668
668
|
else {
|
|
669
|
-
// Fallback: try stripping leading/trailing empty lines/whitespace from the search block
|
|
669
|
+
// Fallback 1: try stripping leading/trailing empty lines/whitespace from the search block
|
|
670
670
|
const trimmedSearch = search.trim();
|
|
671
671
|
if (trimmedSearch && normalizedFile.includes(trimmedSearch)) {
|
|
672
672
|
fileContent = normalizedFile.replace(trimmedSearch, replace.trim());
|
|
673
673
|
diffApplied = true;
|
|
674
674
|
}
|
|
675
675
|
else {
|
|
676
|
-
|
|
676
|
+
// Fallback 2: Regex fuzzy matching that ignores exact whitespace differences (e.g. indentation or newlines)
|
|
677
|
+
const escapedSearch = trimmedSearch.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&').replace(/\\s+/g, '\\s+');
|
|
678
|
+
const regex = new RegExp(escapedSearch);
|
|
679
|
+
if (regex.test(normalizedFile)) {
|
|
680
|
+
fileContent = normalizedFile.replace(regex, replace.trim());
|
|
681
|
+
diffApplied = true;
|
|
682
|
+
}
|
|
683
|
+
else {
|
|
684
|
+
ui_1.ui.error(`Could not apply diff to ${filePath}: SEARCH block not exactly matched.`);
|
|
685
|
+
}
|
|
677
686
|
}
|
|
678
687
|
}
|
|
679
688
|
}
|
package/dist/utils/api.js
CHANGED
|
@@ -82,6 +82,8 @@ new lines
|
|
|
82
82
|
|
|
83
83
|
Always use these tags when you write code or ask questions so the CLI can apply it automatically! Keep explanations short and outside the tags.
|
|
84
84
|
|
|
85
|
+
CRITICAL RULE: If the user's request is too broad, underspecified, or ambiguous (e.g., "Create a beautiful landing page", "Make a website" without further details), YOU MUST NOT generate any code. Instead, you MUST use the <ASK_QUESTIONS> tag to ask 2-3 clarifying questions (about design, framework, functionality, target audience, etc.). Wait for the user's answers before making file modifications.
|
|
86
|
+
|
|
85
87
|
IMPORTANT: Do NOT include your own properties, name ('Draftify'), or AI identity in the code you generate (e.g., when creating a discord bot, landing page, or admin panel). Do not use 'Draftify' as a brand name or prefix in generated projects. If a fictional brand or name is needed, invent a new, unique one instead.`;
|
|
86
88
|
const responseStream = await ai.models.generateContentStream({
|
|
87
89
|
model: geminiModel,
|
|
@@ -121,21 +123,7 @@ IMPORTANT: Do NOT include your own properties, name ('Draftify'), or AI identity
|
|
|
121
123
|
signal: abortSignal
|
|
122
124
|
});
|
|
123
125
|
if (!response.ok) {
|
|
124
|
-
|
|
125
|
-
let errorMsg = errorText;
|
|
126
|
-
try {
|
|
127
|
-
const errorJson = JSON.parse(errorText);
|
|
128
|
-
errorMsg = errorJson.error || errorText;
|
|
129
|
-
}
|
|
130
|
-
catch { }
|
|
131
|
-
const status = response.status;
|
|
132
|
-
if (status === 401)
|
|
133
|
-
throw new Error("Unauthorized: Invalid or expired CLI token. Please login again.");
|
|
134
|
-
if (status === 403)
|
|
135
|
-
throw new Error(`Forbidden: ${errorMsg}`);
|
|
136
|
-
if (status === 429)
|
|
137
|
-
throw new Error(`Rate Limit Exceeded: ${errorMsg}`);
|
|
138
|
-
throw new Error(`Server Error (${status}): ${errorMsg}`);
|
|
126
|
+
throw new Error(`${response.status}`);
|
|
139
127
|
}
|
|
140
128
|
const reader = response.body?.getReader();
|
|
141
129
|
if (!reader)
|
package/dist/utils/config.js
CHANGED
|
@@ -51,7 +51,7 @@ function getToken() {
|
|
|
51
51
|
function getApiUrl() {
|
|
52
52
|
const config = getConfig();
|
|
53
53
|
// Fallback API URL, overrideable via config or DRAFTIFY_API_URL
|
|
54
|
-
return process.env.DRAFTIFY_API_URL || config.apiUrl || "https://draftify
|
|
54
|
+
return process.env.DRAFTIFY_API_URL || config.apiUrl || "https://draftify.site/api/cli";
|
|
55
55
|
}
|
|
56
56
|
function getModel() {
|
|
57
57
|
const config = getConfig();
|