vigthoria-cli 1.9.2 → 1.9.5
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/README.md +15 -5
- package/dist/commands/auth.d.ts +28 -38
- package/dist/commands/auth.js +389 -320
- package/dist/commands/chat.d.ts +3 -0
- package/dist/commands/chat.js +66 -15
- package/dist/commands/index.js +1 -1
- package/dist/commands/legion.d.ts +22 -19
- package/dist/commands/legion.js +550 -132
- package/dist/commands/preview.js +32 -7
- package/dist/commands/repo.js +19 -13
- package/dist/commands/update.d.ts +9 -0
- package/dist/commands/update.js +235 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +114 -33
- package/dist/utils/api.d.ts +25 -70
- package/dist/utils/api.js +784 -695
- package/dist/utils/tools.d.ts +11 -0
- package/dist/utils/tools.js +222 -0
- package/package.json +7 -1
package/dist/commands/chat.d.ts
CHANGED
|
@@ -90,6 +90,9 @@ export declare class ChatCommand {
|
|
|
90
90
|
*/
|
|
91
91
|
private sanitizeServerPath;
|
|
92
92
|
private describeV3AgentTool;
|
|
93
|
+
private isRawV3StreamPayload;
|
|
94
|
+
private consumeV3StreamPayload;
|
|
95
|
+
private writeV3StreamText;
|
|
93
96
|
private updateV3AgentSpinner;
|
|
94
97
|
private updateOperatorSpinner;
|
|
95
98
|
constructor(config: Config, logger: Logger);
|
package/dist/commands/chat.js
CHANGED
|
@@ -476,7 +476,67 @@ class ChatCommand {
|
|
|
476
476
|
}
|
|
477
477
|
return 'Working';
|
|
478
478
|
}
|
|
479
|
+
isRawV3StreamPayload(event) {
|
|
480
|
+
if (!event) {
|
|
481
|
+
return false;
|
|
482
|
+
}
|
|
483
|
+
if (typeof event === 'string' || Buffer.isBuffer(event) || event instanceof Uint8Array) {
|
|
484
|
+
return true;
|
|
485
|
+
}
|
|
486
|
+
const body = event?.body ?? event?.stream ?? event?.response;
|
|
487
|
+
return Boolean(body && (typeof body[Symbol.asyncIterator] === 'function' || typeof body.getReader === 'function'));
|
|
488
|
+
}
|
|
489
|
+
async consumeV3StreamPayload(spinner, event) {
|
|
490
|
+
try {
|
|
491
|
+
const source = (event && typeof event === 'object' && !Buffer.isBuffer(event) && !(event instanceof Uint8Array))
|
|
492
|
+
? (event.body ?? event.stream ?? event.response ?? event)
|
|
493
|
+
: event;
|
|
494
|
+
for await (const chunk of (0, tools_js_1.robustifyStreamResponse)(source)) {
|
|
495
|
+
this.v3LastActivity = Date.now();
|
|
496
|
+
if (chunk.type === 'error') {
|
|
497
|
+
if (spinner.isSpinning)
|
|
498
|
+
spinner.stop();
|
|
499
|
+
process.stderr.write(chalk_1.default.red(`\nStream error: ${chunk.content}\n`));
|
|
500
|
+
continue;
|
|
501
|
+
}
|
|
502
|
+
if (chunk.content) {
|
|
503
|
+
this.writeV3StreamText(spinner, chunk.content);
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
catch (error) {
|
|
508
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
509
|
+
if (spinner.isSpinning)
|
|
510
|
+
spinner.stop();
|
|
511
|
+
process.stderr.write(chalk_1.default.red(`\nStream error: ${message}\n`));
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
writeV3StreamText(spinner, text) {
|
|
515
|
+
if (!text) {
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
if (!this.v3StreamingStarted) {
|
|
519
|
+
this.v3StreamingStarted = true;
|
|
520
|
+
spinner.stop();
|
|
521
|
+
if (!this.directPromptMode) {
|
|
522
|
+
console.log();
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
else {
|
|
526
|
+
spinner.stop();
|
|
527
|
+
}
|
|
528
|
+
process.stdout.write(text);
|
|
529
|
+
}
|
|
479
530
|
updateV3AgentSpinner(spinner, event) {
|
|
531
|
+
if (this.isRawV3StreamPayload(event)) {
|
|
532
|
+
this.consumeV3StreamPayload(spinner, event).catch((error) => {
|
|
533
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
534
|
+
if (spinner.isSpinning)
|
|
535
|
+
spinner.stop();
|
|
536
|
+
process.stderr.write(chalk_1.default.red(`\nStream error: ${message}\n`));
|
|
537
|
+
});
|
|
538
|
+
return;
|
|
539
|
+
}
|
|
480
540
|
if (!event || typeof event !== 'object') {
|
|
481
541
|
return;
|
|
482
542
|
}
|
|
@@ -543,17 +603,8 @@ class ChatCommand {
|
|
|
543
603
|
? (event.delta?.text || '')
|
|
544
604
|
: (event.content || '');
|
|
545
605
|
if (text) {
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
spinner.stop();
|
|
549
|
-
if (!this.directPromptMode) {
|
|
550
|
-
console.log();
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
else {
|
|
554
|
-
spinner.stop();
|
|
555
|
-
}
|
|
556
|
-
process.stdout.write(text);
|
|
606
|
+
this.v3LastActivity = Date.now();
|
|
607
|
+
this.writeV3StreamText(spinner, text);
|
|
557
608
|
}
|
|
558
609
|
else {
|
|
559
610
|
spinner.text = chalk_1.default.cyan('[Response] ') + 'Writing response...';
|
|
@@ -2481,10 +2532,10 @@ class ChatCommand {
|
|
|
2481
2532
|
isProtectedFileReference(prompt, filePath) {
|
|
2482
2533
|
const escapedPath = filePath.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
2483
2534
|
const protectedPatterns = [
|
|
2484
|
-
new RegExp(`do not modify\\s+[
|
|
2485
|
-
new RegExp(`don't modify\\s+[
|
|
2486
|
-
new RegExp(`leave\\s+[
|
|
2487
|
-
new RegExp(`without modifying\\s+[
|
|
2535
|
+
new RegExp(`do not modify\\s+[-\u001f\s\-\"][` + "'" + `]?${escapedPath}[` + "'" + `]?`, 'i'),
|
|
2536
|
+
new RegExp(`don't modify\\s+[-\u001f\s\-\"][` + "'" + `]?${escapedPath}[` + "'" + `]?`, 'i'),
|
|
2537
|
+
new RegExp(`leave\\s+[-\u001f\s\-\"][` + "'" + `]?${escapedPath}[` + "'" + `]?\\s+unchanged`, 'i'),
|
|
2538
|
+
new RegExp(`without modifying\\s+[-\u001f\s\-\"][` + "'" + `]?${escapedPath}[` + "'" + `]?`, 'i'),
|
|
2488
2539
|
];
|
|
2489
2540
|
return protectedPatterns.some((pattern) => pattern.test(prompt));
|
|
2490
2541
|
}
|
package/dist/commands/index.js
CHANGED
|
@@ -10,19 +10,15 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import { Config } from '../utils/config.js';
|
|
12
12
|
import { Logger } from '../utils/logger.js';
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
planOnly?: boolean;
|
|
23
|
-
models?: string;
|
|
24
|
-
timeoutSec?: number;
|
|
25
|
-
}
|
|
13
|
+
export type LegionOptions = {
|
|
14
|
+
/** Enables Vigthoria Cortex maximum-intelligence execution when --cortex is supplied. */
|
|
15
|
+
cortex?: boolean;
|
|
16
|
+
/** Model tier: 'heavy' (default — strongest LLMs) or 'lite' (cost-efficient, high quality). */
|
|
17
|
+
tier?: 'heavy' | 'lite';
|
|
18
|
+
email?: string;
|
|
19
|
+
password?: string;
|
|
20
|
+
[key: string]: any;
|
|
21
|
+
};
|
|
26
22
|
export declare class LegionCommand {
|
|
27
23
|
private config;
|
|
28
24
|
private logger;
|
|
@@ -32,15 +28,20 @@ export declare class LegionCommand {
|
|
|
32
28
|
private readJsonResponse;
|
|
33
29
|
private propagateLegionApiError;
|
|
34
30
|
run(request: string | undefined, options: LegionOptions): Promise<void>;
|
|
35
|
-
private
|
|
31
|
+
private runCortex;
|
|
32
|
+
private isCriticalRoleFailure;
|
|
33
|
+
private isOptionalRepairRoleFailure;
|
|
34
|
+
private estimateAdditionalLoopQuote;
|
|
35
|
+
private confirmAdditionalLoopCharge;
|
|
36
|
+
private runMandatoryPreflight;
|
|
36
37
|
private scanProject;
|
|
37
38
|
private resolveModelProfiles;
|
|
38
39
|
private buildRoleQuote;
|
|
39
|
-
private
|
|
40
|
+
private buildCortexExplicitSteps;
|
|
40
41
|
private buildBillingQuote;
|
|
41
42
|
private evaluateBillingGate;
|
|
42
43
|
private parseBooleanCandidate;
|
|
43
|
-
private
|
|
44
|
+
private fetchCortexEntitlement;
|
|
44
45
|
private isMasterAdminFree;
|
|
45
46
|
private getBillingBaseUrl;
|
|
46
47
|
private parseNumericCandidate;
|
|
@@ -51,18 +52,20 @@ export declare class LegionCommand {
|
|
|
51
52
|
private collectExecutionCharge;
|
|
52
53
|
private resolveBillingInsufficientFunds;
|
|
53
54
|
private printBillingGateSummary;
|
|
54
|
-
private
|
|
55
|
+
private printCortexQuote;
|
|
55
56
|
private confirmExecution;
|
|
56
57
|
/**
|
|
57
58
|
* SSE streaming URL for the Legion execution endpoint.
|
|
58
59
|
* Always hits Hyper Loop directly (port 8020) with the service key to avoid
|
|
59
|
-
* gateway JWT expiry killing long-running
|
|
60
|
+
* gateway JWT expiry killing long-running Cortex jobs.
|
|
60
61
|
*/
|
|
61
62
|
private getLegionStreamUrl;
|
|
62
63
|
private getLegionServiceKey;
|
|
63
64
|
private planAndExecute;
|
|
65
|
+
private buildCortexRunReport;
|
|
66
|
+
private extractModifiedFiles;
|
|
67
|
+
private writeCortexSummaryReport;
|
|
64
68
|
private formatLegionError;
|
|
65
69
|
private showWorkers;
|
|
66
70
|
private showStatus;
|
|
67
71
|
}
|
|
68
|
-
export {};
|