vigthoria-cli 1.10.36 → 1.10.47
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/agent-session-menu.d.ts +19 -0
- package/dist/commands/agent-session-menu.js +155 -0
- package/dist/commands/auth.js +68 -51
- package/dist/commands/bridge.js +19 -12
- package/dist/commands/cancel.js +22 -15
- package/dist/commands/chat.d.ts +0 -22
- package/dist/commands/chat.js +402 -1084
- package/dist/commands/config.js +73 -33
- package/dist/commands/deploy.js +123 -83
- package/dist/commands/device.js +61 -21
- package/dist/commands/edit.js +39 -32
- package/dist/commands/explain.js +25 -18
- package/dist/commands/generate.js +44 -37
- package/dist/commands/hub.js +102 -95
- package/dist/commands/index.js +46 -41
- package/dist/commands/legion.js +186 -146
- package/dist/commands/review.js +36 -29
- package/dist/commands/security.js +12 -5
- package/dist/commands/wallet.js +35 -28
- package/dist/commands/workflow.js +20 -13
- package/dist/utils/brain-hub-client.d.ts +32 -0
- package/dist/utils/brain-hub-client.js +52 -0
- package/dist/utils/bridge-client.js +52 -11
- package/dist/utils/codebase-indexer.d.ts +59 -0
- package/dist/utils/codebase-indexer.js +351 -0
- package/dist/utils/context-ranker.js +21 -15
- package/dist/utils/files.js +42 -5
- package/dist/utils/logger.js +50 -42
- package/dist/utils/persona.js +8 -3
- package/dist/utils/post-write-validator.js +29 -22
- package/dist/utils/project-memory.js +23 -16
- package/dist/utils/task-display.js +20 -13
- package/dist/utils/workspace-brain-service.d.ts +43 -0
- package/dist/utils/workspace-brain-service.js +158 -0
- package/dist/utils/workspace-cache.js +26 -18
- package/dist/utils/workspace-stream.js +63 -21
- package/package.json +3 -6
- package/scripts/release/validate-no-go-gates.sh +1 -1
- package/dist/commands/fork.d.ts +0 -17
- package/dist/commands/fork.js +0 -164
- package/dist/commands/history.d.ts +0 -17
- package/dist/commands/history.js +0 -113
- package/dist/commands/preview.d.ts +0 -55
- package/dist/commands/preview.js +0 -467
- package/dist/commands/replay.d.ts +0 -18
- package/dist/commands/replay.js +0 -156
- package/dist/commands/repo.d.ts +0 -97
- package/dist/commands/repo.js +0 -773
- package/dist/commands/update.d.ts +0 -9
- package/dist/commands/update.js +0 -201
- package/dist/index.d.ts +0 -21
- package/dist/index.js +0 -1823
- package/dist/utils/api.d.ts +0 -572
- package/dist/utils/api.js +0 -6548
- package/dist/utils/cli-state.d.ts +0 -54
- package/dist/utils/cli-state.js +0 -185
- package/dist/utils/config.d.ts +0 -85
- package/dist/utils/config.js +0 -267
- package/dist/utils/session.d.ts +0 -118
- package/dist/utils/session.js +0 -423
- package/dist/utils/tools.d.ts +0 -274
- package/dist/utils/tools.js +0 -3502
package/dist/commands/device.js
CHANGED
|
@@ -1,12 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.DeviceCommand = void 0;
|
|
40
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
41
|
+
const fs = __importStar(require("fs"));
|
|
42
|
+
const os = __importStar(require("os"));
|
|
43
|
+
const path = __importStar(require("path"));
|
|
44
|
+
const child_process_1 = require("child_process");
|
|
45
|
+
const util_1 = require("util");
|
|
46
|
+
const logger_js_1 = require("../utils/logger.js");
|
|
47
|
+
const execFileAsync = (0, util_1.promisify)(child_process_1.execFile);
|
|
48
|
+
class DeviceCommand {
|
|
10
49
|
logger;
|
|
11
50
|
constructor(_config, logger) {
|
|
12
51
|
this.logger = logger;
|
|
@@ -25,23 +64,23 @@ export class DeviceCommand {
|
|
|
25
64
|
return;
|
|
26
65
|
}
|
|
27
66
|
console.log();
|
|
28
|
-
console.log(
|
|
29
|
-
console.log(
|
|
67
|
+
console.log(chalk_1.default.bold.white(` ${logger_js_1.CH.hLine.repeat(3)} Vigthoria Android Developer Bridge ${logger_js_1.CH.hLine.repeat(20)}`));
|
|
68
|
+
console.log(chalk_1.default.gray(' ADB: ') + (adbPath ? chalk_1.default.green(adbPath) : chalk_1.default.yellow('not found')));
|
|
30
69
|
if (!adbPath) {
|
|
31
|
-
console.log(
|
|
70
|
+
console.log(chalk_1.default.gray(' Install Android SDK Platform Tools, then make adb available on PATH.'));
|
|
32
71
|
console.log();
|
|
33
72
|
return;
|
|
34
73
|
}
|
|
35
74
|
if (devices.length === 0) {
|
|
36
|
-
console.log(
|
|
37
|
-
console.log(
|
|
75
|
+
console.log(chalk_1.default.yellow(' No Android devices visible.'));
|
|
76
|
+
console.log(chalk_1.default.gray(' Enable Developer Options + USB debugging, then run `vigthoria device list`.'));
|
|
38
77
|
console.log();
|
|
39
78
|
return;
|
|
40
79
|
}
|
|
41
80
|
for (const device of devices) {
|
|
42
81
|
const label = device.model || device.product || 'Android device';
|
|
43
|
-
const state = device.state === 'device' ?
|
|
44
|
-
console.log(` ${
|
|
82
|
+
const state = device.state === 'device' ? chalk_1.default.green(device.state) : chalk_1.default.yellow(device.state);
|
|
83
|
+
console.log(` ${chalk_1.default.white(device.id)} ${state} ${chalk_1.default.gray(label)}`);
|
|
45
84
|
}
|
|
46
85
|
console.log();
|
|
47
86
|
}
|
|
@@ -53,11 +92,11 @@ export class DeviceCommand {
|
|
|
53
92
|
return;
|
|
54
93
|
}
|
|
55
94
|
if (devices.length === 0) {
|
|
56
|
-
console.log(
|
|
95
|
+
console.log(chalk_1.default.yellow('No Android devices found.'));
|
|
57
96
|
return;
|
|
58
97
|
}
|
|
59
98
|
for (const device of devices) {
|
|
60
|
-
console.log(`${
|
|
99
|
+
console.log(`${chalk_1.default.white(device.id)}\t${device.state}\t${device.model || device.product || ''}`.trim());
|
|
61
100
|
}
|
|
62
101
|
}
|
|
63
102
|
async screenshot(options = {}) {
|
|
@@ -67,7 +106,7 @@ export class DeviceCommand {
|
|
|
67
106
|
const args = this.withDevice(deviceId, ['exec-out', 'screencap', '-p']);
|
|
68
107
|
const result = await execFileAsync(adbPath, args, { encoding: 'buffer', maxBuffer: 20 * 1024 * 1024 });
|
|
69
108
|
fs.writeFileSync(output, result.stdout);
|
|
70
|
-
console.log(
|
|
109
|
+
console.log(chalk_1.default.green(`Saved screenshot: ${output}`));
|
|
71
110
|
}
|
|
72
111
|
async install(apkPath, options = {}) {
|
|
73
112
|
if (!apkPath)
|
|
@@ -98,7 +137,7 @@ export class DeviceCommand {
|
|
|
98
137
|
const args = this.withDevice(deviceId, options.follow ? ['logcat'] : ['logcat', '-d', '-t', lines]);
|
|
99
138
|
if (options.follow) {
|
|
100
139
|
await new Promise((resolve, reject) => {
|
|
101
|
-
const child = spawn(adbPath, args, { stdio: 'inherit' });
|
|
140
|
+
const child = (0, child_process_1.spawn)(adbPath, args, { stdio: 'inherit' });
|
|
102
141
|
child.on('error', reject);
|
|
103
142
|
child.on('exit', (code) => {
|
|
104
143
|
if (code && code !== 0)
|
|
@@ -196,7 +235,7 @@ export class DeviceCommand {
|
|
|
196
235
|
if (result.stdout)
|
|
197
236
|
console.log(result.stdout);
|
|
198
237
|
if (result.stderr)
|
|
199
|
-
console.error(result.success ?
|
|
238
|
+
console.error(result.success ? chalk_1.default.gray(result.stderr) : chalk_1.default.red(result.stderr));
|
|
200
239
|
if (!result.success)
|
|
201
240
|
process.exitCode = 1;
|
|
202
241
|
}
|
|
@@ -237,3 +276,4 @@ export class DeviceCommand {
|
|
|
237
276
|
return new Date().toISOString().replace(/[:.]/g, '-');
|
|
238
277
|
}
|
|
239
278
|
}
|
|
279
|
+
exports.DeviceCommand = DeviceCommand;
|
package/dist/commands/edit.js
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* Edit Command - File editing with AI assistance
|
|
3
4
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
6
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.EditCommand = void 0;
|
|
10
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
11
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
12
|
+
const logger_js_1 = require("../utils/logger.js");
|
|
13
|
+
const api_js_1 = require("../utils/api.js");
|
|
14
|
+
const files_js_1 = require("../utils/files.js");
|
|
15
|
+
class EditCommand {
|
|
10
16
|
config;
|
|
11
17
|
logger;
|
|
12
18
|
api;
|
|
@@ -14,8 +20,8 @@ export class EditCommand {
|
|
|
14
20
|
constructor(config, logger) {
|
|
15
21
|
this.config = config;
|
|
16
22
|
this.logger = logger;
|
|
17
|
-
this.api = new APIClient(config, logger);
|
|
18
|
-
this.fileUtils = new FileUtils(process.cwd(), config.get('project').ignorePatterns);
|
|
23
|
+
this.api = new api_js_1.APIClient(config, logger);
|
|
24
|
+
this.fileUtils = new files_js_1.FileUtils(process.cwd(), config.get('project').ignorePatterns);
|
|
19
25
|
}
|
|
20
26
|
async run(filePath, options) {
|
|
21
27
|
// Check auth
|
|
@@ -36,7 +42,7 @@ export class EditCommand {
|
|
|
36
42
|
return;
|
|
37
43
|
}
|
|
38
44
|
this.logger.section(`Editing: ${file.relativePath}`);
|
|
39
|
-
console.log(
|
|
45
|
+
console.log(chalk_1.default.gray(`Language: ${file.language} | Lines: ${file.lines}`));
|
|
40
46
|
console.log();
|
|
41
47
|
// Get instruction
|
|
42
48
|
let instruction = options.instruction;
|
|
@@ -51,7 +57,7 @@ export class EditCommand {
|
|
|
51
57
|
this.logger.error('No --instruction provided and stdin is not interactive. Use: vigthoria edit file.ts --instruction "..."');
|
|
52
58
|
return;
|
|
53
59
|
}
|
|
54
|
-
const answer = await
|
|
60
|
+
const answer = await inquirer_1.default.prompt([
|
|
55
61
|
{
|
|
56
62
|
type: 'input',
|
|
57
63
|
name: 'instruction',
|
|
@@ -62,7 +68,7 @@ export class EditCommand {
|
|
|
62
68
|
instruction = answer.instruction;
|
|
63
69
|
}
|
|
64
70
|
// Generate edit
|
|
65
|
-
const spinner = createSpinner({
|
|
71
|
+
const spinner = (0, logger_js_1.createSpinner)({
|
|
66
72
|
text: 'Generating changes...',
|
|
67
73
|
spinner: 'dots',
|
|
68
74
|
}).start();
|
|
@@ -116,8 +122,8 @@ Return the complete modified file content:`,
|
|
|
116
122
|
}
|
|
117
123
|
catch (error) {
|
|
118
124
|
spinner.stop();
|
|
119
|
-
const cliErr = error instanceof CLIError ? error : classifyError(error);
|
|
120
|
-
this.logger.error(formatCLIError(cliErr));
|
|
125
|
+
const cliErr = error instanceof api_js_1.CLIError ? error : (0, api_js_1.classifyError)(error);
|
|
126
|
+
this.logger.error((0, api_js_1.formatCLIError)(cliErr));
|
|
121
127
|
}
|
|
122
128
|
}
|
|
123
129
|
async fix(filePath, options) {
|
|
@@ -139,9 +145,9 @@ Return the complete modified file content:`,
|
|
|
139
145
|
return;
|
|
140
146
|
}
|
|
141
147
|
this.logger.section(`Fixing: ${file.relativePath}`);
|
|
142
|
-
console.log(
|
|
148
|
+
console.log(chalk_1.default.gray(`Fix type: ${options.type} | Language: ${file.language}`));
|
|
143
149
|
console.log();
|
|
144
|
-
const spinner = createSpinner({
|
|
150
|
+
const spinner = (0, logger_js_1.createSpinner)({
|
|
145
151
|
text: `Analyzing for ${options.type} issues...`,
|
|
146
152
|
spinner: 'dots',
|
|
147
153
|
}).start();
|
|
@@ -156,7 +162,7 @@ Return the complete modified file content:`,
|
|
|
156
162
|
// diff and let the user decide instead of silently discarding.
|
|
157
163
|
if (result.fixed && result.fixed !== file.content) {
|
|
158
164
|
this.logger.section('Found 1 issue(s)');
|
|
159
|
-
console.log(
|
|
165
|
+
console.log(chalk_1.default.yellow('1. Operator/character-level fix detected'));
|
|
160
166
|
console.log();
|
|
161
167
|
if (options.apply) {
|
|
162
168
|
await this.applyFix(file.path, file.content, result.fixed);
|
|
@@ -172,10 +178,10 @@ Return the complete modified file content:`,
|
|
|
172
178
|
// Show fixes
|
|
173
179
|
this.logger.section(`Found ${result.changes.length} issue(s)`);
|
|
174
180
|
result.changes.forEach((change, i) => {
|
|
175
|
-
console.log(
|
|
176
|
-
console.log(
|
|
177
|
-
console.log(
|
|
178
|
-
console.log(
|
|
181
|
+
console.log(chalk_1.default.yellow(`${i + 1}. Line ${change.line}:`));
|
|
182
|
+
console.log(chalk_1.default.red(` - ${change.before}`));
|
|
183
|
+
console.log(chalk_1.default.green(` + ${change.after}`));
|
|
184
|
+
console.log(chalk_1.default.gray(` Reason: ${change.reason}`));
|
|
179
185
|
console.log();
|
|
180
186
|
});
|
|
181
187
|
// Apply or confirm
|
|
@@ -188,8 +194,8 @@ Return the complete modified file content:`,
|
|
|
188
194
|
}
|
|
189
195
|
catch (error) {
|
|
190
196
|
spinner.stop();
|
|
191
|
-
const cliErr = error instanceof CLIError ? error : classifyError(error);
|
|
192
|
-
this.logger.error(formatCLIError(cliErr));
|
|
197
|
+
const cliErr = error instanceof api_js_1.CLIError ? error : (0, api_js_1.classifyError)(error);
|
|
198
|
+
this.logger.error((0, api_js_1.formatCLIError)(cliErr));
|
|
193
199
|
}
|
|
194
200
|
}
|
|
195
201
|
extractCode(response, language) {
|
|
@@ -352,10 +358,10 @@ Return the complete modified file content:`,
|
|
|
352
358
|
// Show diff
|
|
353
359
|
this.logger.section('Changes');
|
|
354
360
|
diff.removed.forEach(line => {
|
|
355
|
-
console.log(
|
|
361
|
+
console.log(chalk_1.default.red(line));
|
|
356
362
|
});
|
|
357
363
|
diff.added.forEach(line => {
|
|
358
|
-
console.log(
|
|
364
|
+
console.log(chalk_1.default.green(line));
|
|
359
365
|
});
|
|
360
366
|
console.log();
|
|
361
367
|
// Confirm
|
|
@@ -370,7 +376,7 @@ Return the complete modified file content:`,
|
|
|
370
376
|
this.logger.info('Non-interactive mode. Re-run with --apply to apply changes.');
|
|
371
377
|
return;
|
|
372
378
|
}
|
|
373
|
-
const { action } = await
|
|
379
|
+
const { action } = await inquirer_1.default.prompt([
|
|
374
380
|
{
|
|
375
381
|
type: 'list',
|
|
376
382
|
name: 'action',
|
|
@@ -388,7 +394,7 @@ Return the complete modified file content:`,
|
|
|
388
394
|
break;
|
|
389
395
|
case 'view':
|
|
390
396
|
this.showFullDiff(original, modified);
|
|
391
|
-
const { confirm } = await
|
|
397
|
+
const { confirm } = await inquirer_1.default.prompt([
|
|
392
398
|
{
|
|
393
399
|
type: 'confirm',
|
|
394
400
|
name: 'confirm',
|
|
@@ -409,7 +415,7 @@ Return the complete modified file content:`,
|
|
|
409
415
|
const originalLines = original.split('\n');
|
|
410
416
|
const modifiedLines = modified.split('\n');
|
|
411
417
|
console.log();
|
|
412
|
-
console.log(
|
|
418
|
+
console.log(chalk_1.default.gray('─'.repeat(60)));
|
|
413
419
|
// Use LCS-based diff to avoid line-shift inflation
|
|
414
420
|
const m = originalLines.length;
|
|
415
421
|
const n = modifiedLines.length;
|
|
@@ -448,26 +454,26 @@ Return the complete modified file content:`,
|
|
|
448
454
|
if (op.type === 'keep') {
|
|
449
455
|
displayLine++;
|
|
450
456
|
const lineNum = String(displayLine).padStart(4, ' ');
|
|
451
|
-
console.log(
|
|
457
|
+
console.log(chalk_1.default.gray(`${lineNum} │ ${op.text || ''}`));
|
|
452
458
|
}
|
|
453
459
|
else if (op.type === 'remove') {
|
|
454
460
|
displayLine++;
|
|
455
461
|
const lineNum = String(displayLine).padStart(4, ' ');
|
|
456
|
-
console.log(
|
|
462
|
+
console.log(chalk_1.default.red(`${lineNum} - ${op.text}`));
|
|
457
463
|
}
|
|
458
464
|
else {
|
|
459
465
|
const lineNum = ' +';
|
|
460
|
-
console.log(
|
|
466
|
+
console.log(chalk_1.default.green(`${lineNum} + ${op.text}`));
|
|
461
467
|
}
|
|
462
468
|
}
|
|
463
|
-
console.log(
|
|
469
|
+
console.log(chalk_1.default.gray('─'.repeat(60)));
|
|
464
470
|
console.log();
|
|
465
471
|
}
|
|
466
472
|
async applyFix(filePath, original, modified) {
|
|
467
473
|
// Create backup
|
|
468
474
|
const backup = this.fileUtils.backupFile(filePath);
|
|
469
475
|
if (backup) {
|
|
470
|
-
this.logger.info(`Backup: ${
|
|
476
|
+
this.logger.info(`Backup: ${chalk_1.default.gray(backup)}`);
|
|
471
477
|
}
|
|
472
478
|
// Apply changes
|
|
473
479
|
if (this.fileUtils.writeFile(filePath, modified)) {
|
|
@@ -478,3 +484,4 @@ Return the complete modified file content:`,
|
|
|
478
484
|
}
|
|
479
485
|
}
|
|
480
486
|
}
|
|
487
|
+
exports.EditCommand = EditCommand;
|
package/dist/commands/explain.js
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* Explain Command - Explain code in files
|
|
3
4
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
6
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.ExplainCommand = void 0;
|
|
10
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
11
|
+
const marked_1 = require("marked");
|
|
12
|
+
const marked_terminal_1 = require("marked-terminal");
|
|
13
|
+
const logger_js_1 = require("../utils/logger.js");
|
|
14
|
+
const api_js_1 = require("../utils/api.js");
|
|
15
|
+
const files_js_1 = require("../utils/files.js");
|
|
16
|
+
class ExplainCommand {
|
|
11
17
|
config;
|
|
12
18
|
logger;
|
|
13
19
|
api;
|
|
@@ -16,10 +22,10 @@ export class ExplainCommand {
|
|
|
16
22
|
constructor(config, logger) {
|
|
17
23
|
this.config = config;
|
|
18
24
|
this.logger = logger;
|
|
19
|
-
this.api = new APIClient(config, logger);
|
|
20
|
-
this.fileUtils = new FileUtils(process.cwd(), config.get('project').ignorePatterns);
|
|
21
|
-
this.marked = new Marked();
|
|
22
|
-
this.marked.use(markedTerminal({
|
|
25
|
+
this.api = new api_js_1.APIClient(config, logger);
|
|
26
|
+
this.fileUtils = new files_js_1.FileUtils(process.cwd(), config.get('project').ignorePatterns);
|
|
27
|
+
this.marked = new marked_1.Marked();
|
|
28
|
+
this.marked.use((0, marked_terminal_1.markedTerminal)({
|
|
23
29
|
showSectionPrefix: false,
|
|
24
30
|
tab: 2,
|
|
25
31
|
width: 80,
|
|
@@ -56,17 +62,17 @@ export class ExplainCommand {
|
|
|
56
62
|
}
|
|
57
63
|
}
|
|
58
64
|
this.logger.section(`Explaining: ${file.relativePath}${lineInfo}`);
|
|
59
|
-
console.log(
|
|
65
|
+
console.log(chalk_1.default.gray(`Language: ${file.language} | Detail: ${options.detail}`));
|
|
60
66
|
console.log();
|
|
61
67
|
// Show the code being explained
|
|
62
|
-
console.log(
|
|
68
|
+
console.log(chalk_1.default.gray('─'.repeat(60)));
|
|
63
69
|
codeToExplain.split('\n').forEach((line, i) => {
|
|
64
|
-
const lineNum =
|
|
70
|
+
const lineNum = chalk_1.default.gray(String(i + 1).padStart(4, ' ') + ' │ ');
|
|
65
71
|
console.log(lineNum + line);
|
|
66
72
|
});
|
|
67
|
-
console.log(
|
|
73
|
+
console.log(chalk_1.default.gray('─'.repeat(60)));
|
|
68
74
|
console.log();
|
|
69
|
-
const spinner = createSpinner({
|
|
75
|
+
const spinner = (0, logger_js_1.createSpinner)({
|
|
70
76
|
text: 'Analyzing code...',
|
|
71
77
|
spinner: 'dots',
|
|
72
78
|
}).start();
|
|
@@ -80,8 +86,8 @@ export class ExplainCommand {
|
|
|
80
86
|
}
|
|
81
87
|
catch (error) {
|
|
82
88
|
spinner.stop();
|
|
83
|
-
const cliErr = error instanceof CLIError ? error : classifyError(error);
|
|
84
|
-
this.logger.error(formatCLIError(cliErr));
|
|
89
|
+
const cliErr = error instanceof api_js_1.CLIError ? error : (0, api_js_1.classifyError)(error);
|
|
90
|
+
this.logger.error((0, api_js_1.formatCLIError)(cliErr));
|
|
85
91
|
}
|
|
86
92
|
}
|
|
87
93
|
/**
|
|
@@ -126,3 +132,4 @@ export class ExplainCommand {
|
|
|
126
132
|
}
|
|
127
133
|
}
|
|
128
134
|
}
|
|
135
|
+
exports.ExplainCommand = ExplainCommand;
|
|
@@ -1,14 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* Generate Command - Generate code from description
|
|
3
4
|
*
|
|
4
5
|
* Now with Senior Developer Mode (--pro) for impressive, production-ready output
|
|
5
6
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
8
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
9
|
+
};
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.GenerateCommand = void 0;
|
|
12
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
13
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
14
|
+
const logger_js_1 = require("../utils/logger.js");
|
|
15
|
+
const api_js_1 = require("../utils/api.js");
|
|
16
|
+
const files_js_1 = require("../utils/files.js");
|
|
17
|
+
class GenerateCommand {
|
|
12
18
|
config;
|
|
13
19
|
logger;
|
|
14
20
|
api;
|
|
@@ -16,8 +22,8 @@ export class GenerateCommand {
|
|
|
16
22
|
constructor(config, logger) {
|
|
17
23
|
this.config = config;
|
|
18
24
|
this.logger = logger;
|
|
19
|
-
this.api = new APIClient(config, logger);
|
|
20
|
-
this.fileUtils = new FileUtils(process.cwd(), config.get('project').ignorePatterns);
|
|
25
|
+
this.api = new api_js_1.APIClient(config, logger);
|
|
26
|
+
this.fileUtils = new files_js_1.FileUtils(process.cwd(), config.get('project').ignorePatterns);
|
|
21
27
|
}
|
|
22
28
|
async run(description, options) {
|
|
23
29
|
// Check auth
|
|
@@ -37,14 +43,14 @@ export class GenerateCommand {
|
|
|
37
43
|
if (!options.language) {
|
|
38
44
|
options.language = this.detectLanguageFromDescription(description);
|
|
39
45
|
}
|
|
40
|
-
this.logger.section(proMode ? `${CH.rocket} Senior Developer Mode` : 'Code Generation');
|
|
41
|
-
console.log(
|
|
42
|
-
console.log(
|
|
46
|
+
this.logger.section(proMode ? `${logger_js_1.CH.rocket} Senior Developer Mode` : 'Code Generation');
|
|
47
|
+
console.log(chalk_1.default.gray(`Language: ${options.language}`));
|
|
48
|
+
console.log(chalk_1.default.gray(`Description: ${description}`));
|
|
43
49
|
if (proMode) {
|
|
44
|
-
console.log(
|
|
50
|
+
console.log(chalk_1.default.cyan('Pro Mode: Planning → Generating → Quality Check'));
|
|
45
51
|
}
|
|
46
52
|
console.log();
|
|
47
|
-
const spinner = createSpinner({
|
|
53
|
+
const spinner = (0, logger_js_1.createSpinner)({
|
|
48
54
|
text: proMode ? 'Phase 1: Planning project structure...' : 'Generating code...',
|
|
49
55
|
spinner: 'dots',
|
|
50
56
|
}).start();
|
|
@@ -63,20 +69,20 @@ export class GenerateCommand {
|
|
|
63
69
|
if (quality) {
|
|
64
70
|
console.log();
|
|
65
71
|
this.logger.section('Quality Report');
|
|
66
|
-
console.log(
|
|
67
|
-
console.log(
|
|
72
|
+
console.log(chalk_1.default.gray(`Lines of code: ${quality.lineCount}`));
|
|
73
|
+
console.log(chalk_1.default.gray(`Quality score: ${quality.score}/5`));
|
|
68
74
|
console.log();
|
|
69
|
-
console.log(
|
|
70
|
-
console.log(` ${quality.checks?.hasAnimations ?
|
|
71
|
-
console.log(` ${quality.checks?.hasNeonEffects ?
|
|
72
|
-
console.log(` ${quality.checks?.hasResponsive ?
|
|
73
|
-
console.log(` ${quality.checks?.hasFontAwesome ?
|
|
74
|
-
console.log(` ${quality.checks?.hasGoogleFonts ?
|
|
75
|
+
console.log(chalk_1.default.gray('Visual Checks:'));
|
|
76
|
+
console.log(` ${quality.checks?.hasAnimations ? chalk_1.default.green('✓') : chalk_1.default.red('✗')} CSS Animations (@keyframes)`);
|
|
77
|
+
console.log(` ${quality.checks?.hasNeonEffects ? chalk_1.default.green('✓') : chalk_1.default.red('✗')} Neon/Glow Effects`);
|
|
78
|
+
console.log(` ${quality.checks?.hasResponsive ? chalk_1.default.green('✓') : chalk_1.default.red('✗')} Responsive Design (@media)`);
|
|
79
|
+
console.log(` ${quality.checks?.hasFontAwesome ? chalk_1.default.green('✓') : chalk_1.default.red('✗')} Font Awesome Icons`);
|
|
80
|
+
console.log(` ${quality.checks?.hasGoogleFonts ? chalk_1.default.green('✓') : chalk_1.default.red('✗')} Google Fonts`);
|
|
75
81
|
console.log();
|
|
76
|
-
console.log(
|
|
77
|
-
console.log(` ${quality.checks?.hasEmbeddedCSS ?
|
|
78
|
-
console.log(` ${quality.checks?.hasEmbeddedJS ?
|
|
79
|
-
console.log(` ${quality.checks?.singleFile ?
|
|
82
|
+
console.log(chalk_1.default.gray('Structure Checks:'));
|
|
83
|
+
console.log(` ${quality.checks?.hasEmbeddedCSS ? chalk_1.default.green('✓') : chalk_1.default.red('✗')} Embedded CSS (<style> tag)`);
|
|
84
|
+
console.log(` ${quality.checks?.hasEmbeddedJS ? chalk_1.default.green('✓') : chalk_1.default.red('✗')} Embedded JavaScript (<script> tag)`);
|
|
85
|
+
console.log(` ${quality.checks?.singleFile ? chalk_1.default.green('✓') : chalk_1.default.red('✗')} Single-file (no external CSS/JS)`);
|
|
80
86
|
console.log();
|
|
81
87
|
}
|
|
82
88
|
}
|
|
@@ -90,9 +96,9 @@ export class GenerateCommand {
|
|
|
90
96
|
// Display generated code (skip display when --output is set to avoid noise)
|
|
91
97
|
if (!options.output) {
|
|
92
98
|
this.logger.section('Generated Code');
|
|
93
|
-
console.log(
|
|
99
|
+
console.log(chalk_1.default.gray('─'.repeat(60)));
|
|
94
100
|
console.log(this.highlightCode(code, options.language));
|
|
95
|
-
console.log(
|
|
101
|
+
console.log(chalk_1.default.gray('─'.repeat(60)));
|
|
96
102
|
console.log();
|
|
97
103
|
}
|
|
98
104
|
// Save options — when --output is specified, save directly (non-interactive)
|
|
@@ -106,8 +112,8 @@ export class GenerateCommand {
|
|
|
106
112
|
}
|
|
107
113
|
catch (error) {
|
|
108
114
|
spinner.stop();
|
|
109
|
-
const cliErr = error instanceof CLIError ? error : classifyError(error);
|
|
110
|
-
this.logger.error(formatCLIError(cliErr));
|
|
115
|
+
const cliErr = error instanceof api_js_1.CLIError ? error : (0, api_js_1.classifyError)(error);
|
|
116
|
+
this.logger.error((0, api_js_1.formatCLIError)(cliErr));
|
|
111
117
|
}
|
|
112
118
|
}
|
|
113
119
|
/**
|
|
@@ -134,7 +140,7 @@ export class GenerateCommand {
|
|
|
134
140
|
// In production, use a proper library like highlight.js
|
|
135
141
|
const lines = code.split('\n');
|
|
136
142
|
return lines.map((line, i) => {
|
|
137
|
-
const lineNum =
|
|
143
|
+
const lineNum = chalk_1.default.gray(String(i + 1).padStart(4, ' ') + ' │ ');
|
|
138
144
|
return lineNum + this.highlightLine(line, language);
|
|
139
145
|
}).join('\n');
|
|
140
146
|
}
|
|
@@ -152,14 +158,14 @@ export class GenerateCommand {
|
|
|
152
158
|
// Highlight keywords
|
|
153
159
|
langKeywords.forEach(kw => {
|
|
154
160
|
const regex = new RegExp(`\\b${kw}\\b`, 'g');
|
|
155
|
-
highlighted = highlighted.replace(regex,
|
|
161
|
+
highlighted = highlighted.replace(regex, chalk_1.default.magenta(kw));
|
|
156
162
|
});
|
|
157
163
|
// Highlight strings
|
|
158
|
-
highlighted = highlighted.replace(/(["'`])(?:(?!\1)[^\\]|\\.)*\1/g, (match) =>
|
|
164
|
+
highlighted = highlighted.replace(/(["'`])(?:(?!\1)[^\\]|\\.)*\1/g, (match) => chalk_1.default.green(match));
|
|
159
165
|
// Highlight comments
|
|
160
|
-
highlighted = highlighted.replace(/(\/\/.*$|#.*$)/g, (match) =>
|
|
166
|
+
highlighted = highlighted.replace(/(\/\/.*$|#.*$)/g, (match) => chalk_1.default.gray(match));
|
|
161
167
|
// Highlight numbers
|
|
162
|
-
highlighted = highlighted.replace(/\b(\d+)\b/g, (match) =>
|
|
168
|
+
highlighted = highlighted.replace(/\b(\d+)\b/g, (match) => chalk_1.default.yellow(match));
|
|
163
169
|
return highlighted;
|
|
164
170
|
}
|
|
165
171
|
async saveToFile(filePath, code) {
|
|
@@ -171,7 +177,7 @@ export class GenerateCommand {
|
|
|
171
177
|
}
|
|
172
178
|
}
|
|
173
179
|
async promptForAction(code, language) {
|
|
174
|
-
const { action } = await
|
|
180
|
+
const { action } = await inquirer_1.default.prompt([
|
|
175
181
|
{
|
|
176
182
|
type: 'list',
|
|
177
183
|
name: 'action',
|
|
@@ -188,10 +194,10 @@ export class GenerateCommand {
|
|
|
188
194
|
case 'copy':
|
|
189
195
|
// Note: Clipboard access requires additional setup
|
|
190
196
|
this.logger.info('Code copied to clipboard');
|
|
191
|
-
console.log(
|
|
197
|
+
console.log(chalk_1.default.gray('(Note: Clipboard access may require additional permissions)'));
|
|
192
198
|
break;
|
|
193
199
|
case 'save':
|
|
194
|
-
const { filename } = await
|
|
200
|
+
const { filename } = await inquirer_1.default.prompt([
|
|
195
201
|
{
|
|
196
202
|
type: 'input',
|
|
197
203
|
name: 'filename',
|
|
@@ -256,3 +262,4 @@ export class GenerateCommand {
|
|
|
256
262
|
return 'javascript';
|
|
257
263
|
}
|
|
258
264
|
}
|
|
265
|
+
exports.GenerateCommand = GenerateCommand;
|