draftify-cli 1.0.13 → 1.0.17
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 +3 -0
- package/dist/utils/api.js +40 -15
- package/package.json +4 -1
package/dist/repl.js
CHANGED
|
@@ -1079,6 +1079,9 @@ async function startRepl(initialUsername) {
|
|
|
1079
1079
|
catch (err) {
|
|
1080
1080
|
ui_1.ui.error(`Command failed:\n${err}`);
|
|
1081
1081
|
commandOutputs.push(`Command: ${cmdToRun}\nFailed with error:\n${err}`);
|
|
1082
|
+
if (err === "Command aborted by user." || err?.name === "AbortError" || err?.message === "Command aborted by user.") {
|
|
1083
|
+
throw new Error("Aborted");
|
|
1084
|
+
}
|
|
1082
1085
|
}
|
|
1083
1086
|
}
|
|
1084
1087
|
}
|
package/dist/utils/api.js
CHANGED
|
@@ -85,23 +85,44 @@ Always use these tags when you write code or ask questions so the CLI can apply
|
|
|
85
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
86
|
|
|
87
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.`;
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
88
|
+
if (abortSignal?.aborted)
|
|
89
|
+
throw new Error("Aborted");
|
|
90
|
+
const fullResult = await new Promise(async (resolve, reject) => {
|
|
91
|
+
const onAbort = () => reject(new Error("Aborted"));
|
|
92
|
+
if (abortSignal) {
|
|
93
|
+
abortSignal.addEventListener("abort", onAbort);
|
|
93
94
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
95
|
+
try {
|
|
96
|
+
const responseStream = await ai.models.generateContentStream({
|
|
97
|
+
model: geminiModel,
|
|
98
|
+
contents: contents,
|
|
99
|
+
config: {
|
|
100
|
+
systemInstruction: systemInstruction
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
let tempResult = "";
|
|
104
|
+
for await (const chunk of responseStream) {
|
|
105
|
+
if (abortSignal?.aborted) {
|
|
106
|
+
reject(new Error("Aborted"));
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
if (chunk.text) {
|
|
110
|
+
tempResult += chunk.text;
|
|
111
|
+
if (onChunk)
|
|
112
|
+
onChunk(chunk.text);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
resolve(tempResult);
|
|
103
116
|
}
|
|
104
|
-
|
|
117
|
+
catch (err) {
|
|
118
|
+
reject(err);
|
|
119
|
+
}
|
|
120
|
+
finally {
|
|
121
|
+
if (abortSignal) {
|
|
122
|
+
abortSignal.removeEventListener("abort", onAbort);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
});
|
|
105
126
|
// Rough estimation of tokens
|
|
106
127
|
const estimatedTokens = Math.ceil((JSON.stringify(contents).length + fullResult.length) / 4);
|
|
107
128
|
(0, config_1.addTokensUsed)(estimatedTokens);
|
|
@@ -132,6 +153,10 @@ IMPORTANT: Do NOT include your own properties, name ('Draftify'), or AI identity
|
|
|
132
153
|
let buffer = "";
|
|
133
154
|
let fullResult = "";
|
|
134
155
|
while (true) {
|
|
156
|
+
if (abortSignal?.aborted) {
|
|
157
|
+
reader.cancel().catch(() => { });
|
|
158
|
+
throw new Error("Aborted");
|
|
159
|
+
}
|
|
135
160
|
const { done, value } = await reader.read();
|
|
136
161
|
if (done)
|
|
137
162
|
break;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "draftify-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.17",
|
|
4
4
|
"description": "Draftify AI CLI tool",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -38,5 +38,8 @@
|
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/node": "^20.14.2",
|
|
40
40
|
"typescript": "^5.4.5"
|
|
41
|
+
},
|
|
42
|
+
"overrides": {
|
|
43
|
+
"uuid": "^11.0.0"
|
|
41
44
|
}
|
|
42
45
|
}
|