sharkcode 0.2.0 → 0.2.1
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/cli.mjs +41 -8
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -216,6 +216,29 @@ function createProvider(config) {
|
|
|
216
216
|
}
|
|
217
217
|
|
|
218
218
|
// src/agent.ts
|
|
219
|
+
var PURPLE = chalk2.hex("#a855f7");
|
|
220
|
+
function createSpinner() {
|
|
221
|
+
const frames = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
222
|
+
let i = 0;
|
|
223
|
+
let timer = null;
|
|
224
|
+
return {
|
|
225
|
+
start() {
|
|
226
|
+
process.stdout.write("\n");
|
|
227
|
+
timer = setInterval(() => {
|
|
228
|
+
process.stdout.write(
|
|
229
|
+
`\r${PURPLE(frames[i++ % frames.length])} ${chalk2.gray("thinking...")}`
|
|
230
|
+
);
|
|
231
|
+
}, 80);
|
|
232
|
+
},
|
|
233
|
+
stop() {
|
|
234
|
+
if (timer) {
|
|
235
|
+
clearInterval(timer);
|
|
236
|
+
timer = null;
|
|
237
|
+
process.stdout.write("\r\x1B[K");
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
}
|
|
219
242
|
function buildSystemPrompt() {
|
|
220
243
|
return `You are Shark Code, an AI coding assistant. You help users with coding tasks by reading, writing, and editing files, and running shell commands.
|
|
221
244
|
|
|
@@ -246,7 +269,14 @@ async function runAgent(messages, config) {
|
|
|
246
269
|
stopWhen: stepCountIs(30)
|
|
247
270
|
});
|
|
248
271
|
let currentStep = 0;
|
|
272
|
+
const spinner = createSpinner();
|
|
273
|
+
let spinnerStopped = false;
|
|
274
|
+
spinner.start();
|
|
249
275
|
for await (const event of result.fullStream) {
|
|
276
|
+
if (!spinnerStopped && (event.type === "text-delta" || event.type === "tool-call" || event.type === "error")) {
|
|
277
|
+
spinner.stop();
|
|
278
|
+
spinnerStopped = true;
|
|
279
|
+
}
|
|
250
280
|
switch (event.type) {
|
|
251
281
|
case "text-delta":
|
|
252
282
|
process.stdout.write(event.text);
|
|
@@ -282,6 +312,9 @@ async function runAgent(messages, config) {
|
|
|
282
312
|
break;
|
|
283
313
|
}
|
|
284
314
|
}
|
|
315
|
+
if (!spinnerStopped) {
|
|
316
|
+
spinner.stop();
|
|
317
|
+
}
|
|
285
318
|
process.stdout.write("\n");
|
|
286
319
|
const usage = await result.totalUsage;
|
|
287
320
|
if (usage) {
|
|
@@ -314,7 +347,7 @@ function truncate(str, max) {
|
|
|
314
347
|
}
|
|
315
348
|
|
|
316
349
|
// src/cli.ts
|
|
317
|
-
var
|
|
350
|
+
var PURPLE2 = chalk3.hex("#a855f7");
|
|
318
351
|
var GLYPHS = {
|
|
319
352
|
S: [[0, 1, 1, 1, 1], [1, 0, 0, 0, 0], [0, 1, 1, 1, 0], [0, 0, 0, 0, 1], [1, 1, 1, 1, 0]],
|
|
320
353
|
H: [[1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1]],
|
|
@@ -338,7 +371,7 @@ function renderWord(word, padLeft = 2) {
|
|
|
338
371
|
}
|
|
339
372
|
if (i < letters.length - 1) line += " ";
|
|
340
373
|
}
|
|
341
|
-
rows.push(
|
|
374
|
+
rows.push(PURPLE2(line));
|
|
342
375
|
}
|
|
343
376
|
return rows;
|
|
344
377
|
}
|
|
@@ -361,9 +394,9 @@ async function main() {
|
|
|
361
394
|
const args = process.argv.slice(2);
|
|
362
395
|
if (args[0] === "--help" || args[0] === "-h") {
|
|
363
396
|
console.log(BANNER);
|
|
364
|
-
console.log(
|
|
365
|
-
console.log(" " +
|
|
366
|
-
console.log(" " +
|
|
397
|
+
console.log(PURPLE2(" Usage:"));
|
|
398
|
+
console.log(" " + PURPLE2("sharkcode") + chalk3.gray(" \u2014 interactive mode"));
|
|
399
|
+
console.log(" " + PURPLE2("sharkcode") + chalk3.yellow(' "prompt"') + chalk3.gray(" \u2014 single-shot mode\n"));
|
|
367
400
|
return;
|
|
368
401
|
}
|
|
369
402
|
if (args[0] === "--version" || args[0] === "-v") {
|
|
@@ -372,7 +405,7 @@ async function main() {
|
|
|
372
405
|
}
|
|
373
406
|
const config = loadConfig();
|
|
374
407
|
if (args.length > 0) {
|
|
375
|
-
console.log(
|
|
408
|
+
console.log(PURPLE2("\n\u{1F988} SharkCode") + chalk3.gray(` | model: ${config.model}
|
|
376
409
|
`));
|
|
377
410
|
const messages2 = [{ role: "user", content: args.join(" ") }];
|
|
378
411
|
await runAgent(messages2, config);
|
|
@@ -380,11 +413,11 @@ async function main() {
|
|
|
380
413
|
}
|
|
381
414
|
console.log(BANNER);
|
|
382
415
|
console.log(
|
|
383
|
-
|
|
416
|
+
PURPLE2(" \u25C6") + chalk3.gray(` model: ${config.model}`) + chalk3.gray(' type "exit" to quit\n')
|
|
384
417
|
);
|
|
385
418
|
let messages = [];
|
|
386
419
|
while (true) {
|
|
387
|
-
const input = await readLine(
|
|
420
|
+
const input = await readLine(PURPLE2("\n\u25C6 "));
|
|
388
421
|
if (input === null) {
|
|
389
422
|
console.log(chalk3.gray("\nBye! \u{1F988}"));
|
|
390
423
|
break;
|