vigthoria-cli 1.1.0 ā 1.4.0
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 +85 -2
- package/SECURITY_HARDENING.md +253 -0
- package/dist/commands/chat.d.ts +2 -2
- package/dist/commands/chat.js +4 -4
- package/dist/commands/chat.js.map +1 -1
- package/dist/commands/deploy.d.ts +80 -0
- package/dist/commands/deploy.d.ts.map +1 -0
- package/dist/commands/deploy.js +514 -0
- package/dist/commands/deploy.js.map +1 -0
- package/dist/commands/generate.d.ts +3 -0
- package/dist/commands/generate.d.ts.map +1 -1
- package/dist/commands/generate.js +45 -4
- package/dist/commands/generate.js.map +1 -1
- package/dist/commands/hub.d.ts +40 -0
- package/dist/commands/hub.d.ts.map +1 -0
- package/dist/commands/hub.js +289 -0
- package/dist/commands/hub.js.map +1 -0
- package/dist/commands/repo.d.ts +80 -0
- package/dist/commands/repo.d.ts.map +1 -0
- package/dist/commands/repo.js +607 -0
- package/dist/commands/repo.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +267 -10
- package/dist/index.js.map +1 -1
- package/dist/utils/api.d.ts +15 -0
- package/dist/utils/api.d.ts.map +1 -1
- package/dist/utils/api.js +62 -33
- package/dist/utils/api.js.map +1 -1
- package/dist/utils/config.js +1 -1
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/session.d.ts +1 -1
- package/dist/utils/session.js +1 -1
- package/dist/utils/tools.d.ts +18 -3
- package/dist/utils/tools.d.ts.map +1 -1
- package/dist/utils/tools.js +326 -20
- package/dist/utils/tools.js.map +1 -1
- package/install.sh +1 -1
- package/package.json +6 -3
- package/src/commands/chat.ts +4 -4
- package/src/commands/deploy.ts +609 -0
- package/src/commands/generate.ts +49 -4
- package/src/commands/hub.ts +382 -0
- package/src/commands/repo.ts +729 -0
- package/src/index.ts +297 -10
- package/src/utils/api.ts +78 -34
- package/src/utils/config.ts +1 -1
- package/src/utils/session.ts +1 -1
- package/src/utils/tools.ts +348 -21
package/src/index.ts
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
* vigthoria review <file> - Review code quality
|
|
12
12
|
* vigthoria login - Authenticate with Vigthoria
|
|
13
13
|
* vigthoria config - Configure settings
|
|
14
|
+
* vigthoria hub - Discover & activate API modules
|
|
14
15
|
*/
|
|
15
16
|
|
|
16
17
|
import { Command } from 'commander';
|
|
@@ -21,6 +22,9 @@ import { ExplainCommand } from './commands/explain.js';
|
|
|
21
22
|
import { AuthCommand } from './commands/auth.js';
|
|
22
23
|
import { ConfigCommand } from './commands/config.js';
|
|
23
24
|
import { ReviewCommand } from './commands/review.js';
|
|
25
|
+
import { HubCommand } from './commands/hub.js';
|
|
26
|
+
import { RepoCommand } from './commands/repo.js';
|
|
27
|
+
import { DeployCommand } from './commands/deploy.js';
|
|
24
28
|
import { Config } from './utils/config.js';
|
|
25
29
|
import { Logger } from './utils/logger.js';
|
|
26
30
|
import chalk from 'chalk';
|
|
@@ -47,22 +51,48 @@ function getVersion(): string {
|
|
|
47
51
|
} catch (e) {
|
|
48
52
|
// Fallback to hardcoded version
|
|
49
53
|
}
|
|
50
|
-
return '1.0
|
|
54
|
+
return '1.4.0';
|
|
51
55
|
}
|
|
52
56
|
const VERSION = getVersion();
|
|
53
57
|
|
|
58
|
+
/**
|
|
59
|
+
* Compare semantic versions properly
|
|
60
|
+
* Returns: -1 if v1 < v2, 0 if equal, 1 if v1 > v2
|
|
61
|
+
*/
|
|
62
|
+
function compareVersions(v1: string, v2: string): number {
|
|
63
|
+
const parts1 = v1.split('.').map(Number);
|
|
64
|
+
const parts2 = v2.split('.').map(Number);
|
|
65
|
+
|
|
66
|
+
for (let i = 0; i < Math.max(parts1.length, parts2.length); i++) {
|
|
67
|
+
const p1 = parts1[i] || 0;
|
|
68
|
+
const p2 = parts2[i] || 0;
|
|
69
|
+
if (p1 < p2) return -1;
|
|
70
|
+
if (p1 > p2) return 1;
|
|
71
|
+
}
|
|
72
|
+
return 0;
|
|
73
|
+
}
|
|
74
|
+
|
|
54
75
|
// Check for updates silently on startup (non-blocking)
|
|
55
76
|
async function checkForUpdatesQuietly(): Promise<void> {
|
|
56
77
|
try {
|
|
57
78
|
const { execSync } = await import('child_process');
|
|
58
|
-
const
|
|
79
|
+
const npmVersion = execSync('npm view vigthoria-cli version 2>/dev/null', {
|
|
59
80
|
encoding: 'utf8',
|
|
60
81
|
timeout: 5000
|
|
61
82
|
}).trim();
|
|
62
83
|
|
|
63
|
-
if
|
|
64
|
-
|
|
65
|
-
|
|
84
|
+
// Only show update message if npm version is NEWER than current (not older)
|
|
85
|
+
if (npmVersion && compareVersions(npmVersion, VERSION) > 0) {
|
|
86
|
+
// Check if this is a security update (1.4.0+)
|
|
87
|
+
if (compareVersions(npmVersion, '1.4.0') >= 0 && compareVersions(VERSION, '1.4.0') < 0) {
|
|
88
|
+
console.log(chalk.red.bold('\nā ļø SECURITY UPDATE AVAILABLE'));
|
|
89
|
+
console.log(chalk.red(` Version ${VERSION} has security vulnerabilities.`));
|
|
90
|
+
console.log(chalk.yellow(` Please update to ${npmVersion} immediately:`));
|
|
91
|
+
console.log(chalk.white.bold(' npm install -g vigthoria-cli@latest\n'));
|
|
92
|
+
} else {
|
|
93
|
+
console.log(chalk.yellow(`\nš¦ Update available: ${VERSION} ā ${npmVersion}`));
|
|
94
|
+
console.log(chalk.gray(' Run `vigthoria update` to install\n'));
|
|
95
|
+
}
|
|
66
96
|
}
|
|
67
97
|
} catch {
|
|
68
98
|
// Silently ignore - network issues shouldn't block CLI
|
|
@@ -99,14 +129,15 @@ async function main() {
|
|
|
99
129
|
.description('AI-powered terminal coding assistant for Vigthoria Coder subscribers')
|
|
100
130
|
.version(VERSION);
|
|
101
131
|
|
|
102
|
-
// Chat command - Interactive mode
|
|
132
|
+
// Chat command - Interactive mode (Agent mode is default for best results)
|
|
103
133
|
program
|
|
104
134
|
.command('chat')
|
|
105
135
|
.alias('c')
|
|
106
136
|
.description('Start interactive chat with Vigthoria AI')
|
|
107
|
-
.option('-m, --model <model>', 'Select AI model (fast, balanced, code, creative)', '
|
|
137
|
+
.option('-m, --model <model>', 'Select AI model (fast, balanced, code, creative)', 'code')
|
|
108
138
|
.option('-p, --project <path>', 'Set project context path', process.cwd())
|
|
109
|
-
.option('-a, --agent', 'Enable agentic mode (
|
|
139
|
+
.option('-a, --agent', 'Enable agentic mode (default: true for best quality)', true)
|
|
140
|
+
.option('--no-agent', 'Disable agentic mode (simple chat only)')
|
|
110
141
|
.option('-r, --resume', 'Resume last session for this project', false)
|
|
111
142
|
.option('--auto-approve', 'Auto-approve agent actions (dangerous!)', false)
|
|
112
143
|
.action(async (options) => {
|
|
@@ -120,7 +151,7 @@ async function main() {
|
|
|
120
151
|
});
|
|
121
152
|
});
|
|
122
153
|
|
|
123
|
-
// Agent command - Agentic mode (
|
|
154
|
+
// Agent command - Agentic mode (Vigthoria Autonomous)
|
|
124
155
|
program
|
|
125
156
|
.command('agent')
|
|
126
157
|
.alias('a')
|
|
@@ -155,9 +186,10 @@ async function main() {
|
|
|
155
186
|
.command('generate <description>')
|
|
156
187
|
.alias('g')
|
|
157
188
|
.description('Generate code from description')
|
|
158
|
-
.option('-l, --language <lang>', 'Target language', '
|
|
189
|
+
.option('-l, --language <lang>', 'Target language (html, typescript, python, etc.)', 'html')
|
|
159
190
|
.option('-o, --output <file>', 'Output file path')
|
|
160
191
|
.option('-m, --model <model>', 'Select AI model', 'code')
|
|
192
|
+
.option('-p, --pro', 'Senior Developer Mode: plan, generate, quality check (recommended)', false)
|
|
161
193
|
.action(async (description, options) => {
|
|
162
194
|
const generate = new GenerateCommand(config, logger);
|
|
163
195
|
await generate.run(description, options);
|
|
@@ -198,6 +230,261 @@ async function main() {
|
|
|
198
230
|
await review.run(file, options);
|
|
199
231
|
});
|
|
200
232
|
|
|
233
|
+
// ==================== HUB / MARKETPLACE COMMANDS ====================
|
|
234
|
+
|
|
235
|
+
// Hub command - Discover and activate API modules
|
|
236
|
+
const hubCommand = program
|
|
237
|
+
.command('hub')
|
|
238
|
+
.alias('marketplace')
|
|
239
|
+
.description('Discover, search, and activate Vigthoria API modules');
|
|
240
|
+
|
|
241
|
+
hubCommand
|
|
242
|
+
.command('discover')
|
|
243
|
+
.alias('d')
|
|
244
|
+
.description('Interactive module discovery - find the right APIs for your project')
|
|
245
|
+
.action(async () => {
|
|
246
|
+
const hub = new HubCommand(config, logger);
|
|
247
|
+
await hub.discover();
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
hubCommand
|
|
251
|
+
.command('list')
|
|
252
|
+
.alias('ls')
|
|
253
|
+
.description('List all available API modules')
|
|
254
|
+
.option('-c, --category <category>', 'Filter by category (payments, communication, ai, creative, media)')
|
|
255
|
+
.action(async (options) => {
|
|
256
|
+
const hub = new HubCommand(config, logger);
|
|
257
|
+
await hub.list(options);
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
hubCommand
|
|
261
|
+
.command('search <query>')
|
|
262
|
+
.alias('find')
|
|
263
|
+
.description('Semantic search for modules (e.g., "generate background music for my app")')
|
|
264
|
+
.action(async (query) => {
|
|
265
|
+
const hub = new HubCommand(config, logger);
|
|
266
|
+
await hub.search(query);
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
hubCommand
|
|
270
|
+
.command('activate <module>')
|
|
271
|
+
.alias('enable')
|
|
272
|
+
.description('Activate a module for your API key (enables pay-as-you-go)')
|
|
273
|
+
.action(async (module) => {
|
|
274
|
+
const hub = new HubCommand(config, logger);
|
|
275
|
+
await hub.activate(module);
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
hubCommand
|
|
279
|
+
.command('active')
|
|
280
|
+
.description('Show your currently active modules')
|
|
281
|
+
.action(async () => {
|
|
282
|
+
const hub = new HubCommand(config, logger);
|
|
283
|
+
await hub.active();
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
hubCommand
|
|
287
|
+
.command('info <module>')
|
|
288
|
+
.alias('details')
|
|
289
|
+
.description('Get detailed information about a module')
|
|
290
|
+
.action(async (module) => {
|
|
291
|
+
const hub = new HubCommand(config, logger);
|
|
292
|
+
await hub.info(module);
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
// Default hub action shows discover
|
|
296
|
+
hubCommand.action(async () => {
|
|
297
|
+
const hub = new HubCommand(config, logger);
|
|
298
|
+
await hub.discover();
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
// ==================== REPO COMMANDS ====================
|
|
302
|
+
|
|
303
|
+
// Repo command - Push/Pull projects to/from Vigthoria Repository
|
|
304
|
+
const repoCommand = program
|
|
305
|
+
.command('repo')
|
|
306
|
+
.alias('repository')
|
|
307
|
+
.description('Push and pull projects to/from your Vigthoria Repository');
|
|
308
|
+
|
|
309
|
+
repoCommand
|
|
310
|
+
.command('push [path]')
|
|
311
|
+
.alias('upload')
|
|
312
|
+
.description('Push current or specified project to Vigthoria Repo')
|
|
313
|
+
.option('-v, --visibility <type>', 'Set visibility (private, restricted, public)', 'private')
|
|
314
|
+
.option('-d, --description <text>', 'Project description')
|
|
315
|
+
.option('-f, --force', 'Overwrite existing project', false)
|
|
316
|
+
.action(async (pathArg, options) => {
|
|
317
|
+
const repo = new RepoCommand(config, logger);
|
|
318
|
+
await repo.push({
|
|
319
|
+
path: pathArg,
|
|
320
|
+
visibility: options.visibility,
|
|
321
|
+
description: options.description,
|
|
322
|
+
force: options.force
|
|
323
|
+
});
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
repoCommand
|
|
327
|
+
.command('pull <name>')
|
|
328
|
+
.alias('download')
|
|
329
|
+
.description('Pull a project from your Vigthoria Repo')
|
|
330
|
+
.option('-o, --output <path>', 'Output directory path')
|
|
331
|
+
.option('-f, --force', 'Overwrite existing directory', false)
|
|
332
|
+
.action(async (name, options) => {
|
|
333
|
+
const repo = new RepoCommand(config, logger);
|
|
334
|
+
await repo.pull(name, {
|
|
335
|
+
output: options.output,
|
|
336
|
+
force: options.force
|
|
337
|
+
});
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
repoCommand
|
|
341
|
+
.command('list')
|
|
342
|
+
.alias('ls')
|
|
343
|
+
.description('List all your projects in Vigthoria Repo')
|
|
344
|
+
.option('-v, --visibility <type>', 'Filter by visibility (private, restricted, public)')
|
|
345
|
+
.action(async (options) => {
|
|
346
|
+
const repo = new RepoCommand(config, logger);
|
|
347
|
+
await repo.list({ visibility: options.visibility });
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
repoCommand
|
|
351
|
+
.command('status')
|
|
352
|
+
.description('Show sync status of current project')
|
|
353
|
+
.action(async () => {
|
|
354
|
+
const repo = new RepoCommand(config, logger);
|
|
355
|
+
await repo.status();
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
repoCommand
|
|
359
|
+
.command('share <name>')
|
|
360
|
+
.description('Generate a shareable link for a project')
|
|
361
|
+
.option('-e, --expires <duration>', 'Link expiration (e.g., 7d, 24h, 30m)', '7d')
|
|
362
|
+
.action(async (name, options) => {
|
|
363
|
+
const repo = new RepoCommand(config, logger);
|
|
364
|
+
await repo.share(name, { expires: options.expires });
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
repoCommand
|
|
368
|
+
.command('delete <name>')
|
|
369
|
+
.alias('rm')
|
|
370
|
+
.description('Remove a project from your Vigthoria Repo')
|
|
371
|
+
.action(async (name) => {
|
|
372
|
+
const repo = new RepoCommand(config, logger);
|
|
373
|
+
await repo.delete(name);
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
repoCommand
|
|
377
|
+
.command('clone <url>')
|
|
378
|
+
.description('Clone a public project from Vigthoria Repo')
|
|
379
|
+
.option('-o, --output <path>', 'Output directory path')
|
|
380
|
+
.option('-f, --force', 'Overwrite existing directory', false)
|
|
381
|
+
.action(async (url, options) => {
|
|
382
|
+
const repo = new RepoCommand(config, logger);
|
|
383
|
+
await repo.clone(url, {
|
|
384
|
+
output: options.output,
|
|
385
|
+
force: options.force
|
|
386
|
+
});
|
|
387
|
+
});
|
|
388
|
+
|
|
389
|
+
// Default repo action shows list
|
|
390
|
+
repoCommand.action(async () => {
|
|
391
|
+
const repo = new RepoCommand(config, logger);
|
|
392
|
+
await repo.list({});
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
// ==================== DEPLOY COMMANDS ====================
|
|
396
|
+
|
|
397
|
+
// Deploy command - Host projects on Vigthoria
|
|
398
|
+
const deployCommand = program
|
|
399
|
+
.command('deploy')
|
|
400
|
+
.alias('host')
|
|
401
|
+
.description('Deploy and host your project on Vigthoria infrastructure');
|
|
402
|
+
|
|
403
|
+
deployCommand
|
|
404
|
+
.command('preview')
|
|
405
|
+
.description('Deploy to free preview URL')
|
|
406
|
+
.option('-p, --project <path>', 'Project directory path', process.cwd())
|
|
407
|
+
.action(async (options) => {
|
|
408
|
+
const deploy = new DeployCommand(config, logger);
|
|
409
|
+
await deploy.deployToPreview(options.project);
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
deployCommand
|
|
413
|
+
.command('subdomain <name>')
|
|
414
|
+
.description('Deploy to yourname.vigthoria.io')
|
|
415
|
+
.option('-p, --project <path>', 'Project directory path', process.cwd())
|
|
416
|
+
.action(async (name, options) => {
|
|
417
|
+
const deploy = new DeployCommand(config, logger);
|
|
418
|
+
await deploy.deployToSubdomain(name, options.project);
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
deployCommand
|
|
422
|
+
.command('custom <domain>')
|
|
423
|
+
.description('Deploy to your custom domain')
|
|
424
|
+
.option('-p, --project <path>', 'Project directory path', process.cwd())
|
|
425
|
+
.action(async (domain, options) => {
|
|
426
|
+
const deploy = new DeployCommand(config, logger);
|
|
427
|
+
await deploy.deployToCustomDomain(domain, options.project);
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
deployCommand
|
|
431
|
+
.command('list')
|
|
432
|
+
.alias('ls')
|
|
433
|
+
.description('List all your deployments')
|
|
434
|
+
.action(async () => {
|
|
435
|
+
const deploy = new DeployCommand(config, logger);
|
|
436
|
+
await deploy.list();
|
|
437
|
+
});
|
|
438
|
+
|
|
439
|
+
deployCommand
|
|
440
|
+
.command('plans')
|
|
441
|
+
.description('Show hosting plans and pricing')
|
|
442
|
+
.action(async () => {
|
|
443
|
+
const deploy = new DeployCommand(config, logger);
|
|
444
|
+
await deploy.showPlans();
|
|
445
|
+
});
|
|
446
|
+
|
|
447
|
+
deployCommand
|
|
448
|
+
.command('status [domain]')
|
|
449
|
+
.description('Check deployment status')
|
|
450
|
+
.action(async (domain) => {
|
|
451
|
+
const deploy = new DeployCommand(config, logger);
|
|
452
|
+
await deploy.status(domain);
|
|
453
|
+
});
|
|
454
|
+
|
|
455
|
+
deployCommand
|
|
456
|
+
.command('verify <domain>')
|
|
457
|
+
.description('Verify DNS configuration for custom domain')
|
|
458
|
+
.action(async (domain) => {
|
|
459
|
+
const deploy = new DeployCommand(config, logger);
|
|
460
|
+
await deploy.verify(domain);
|
|
461
|
+
});
|
|
462
|
+
|
|
463
|
+
deployCommand
|
|
464
|
+
.command('remove <domain>')
|
|
465
|
+
.alias('rm')
|
|
466
|
+
.description('Remove a deployment')
|
|
467
|
+
.action(async (domain) => {
|
|
468
|
+
const deploy = new DeployCommand(config, logger);
|
|
469
|
+
await deploy.remove(domain);
|
|
470
|
+
});
|
|
471
|
+
|
|
472
|
+
// Default deploy action shows interactive wizard
|
|
473
|
+
deployCommand
|
|
474
|
+
.option('-s, --subdomain <name>', 'Deploy to subdomain')
|
|
475
|
+
.option('-d, --domain <domain>', 'Deploy to custom domain')
|
|
476
|
+
.option('-p, --project <path>', 'Project directory path', process.cwd())
|
|
477
|
+
.action(async (options) => {
|
|
478
|
+
const deploy = new DeployCommand(config, logger);
|
|
479
|
+
await deploy.deploy({
|
|
480
|
+
subdomain: options.subdomain,
|
|
481
|
+
domain: options.domain,
|
|
482
|
+
project: options.project
|
|
483
|
+
});
|
|
484
|
+
});
|
|
485
|
+
|
|
486
|
+
// ==================== AUTH COMMANDS ====================
|
|
487
|
+
|
|
201
488
|
// Auth commands
|
|
202
489
|
program
|
|
203
490
|
.command('login')
|
package/src/utils/api.ts
CHANGED
|
@@ -252,7 +252,29 @@ export class APIClient {
|
|
|
252
252
|
}
|
|
253
253
|
}
|
|
254
254
|
|
|
255
|
-
// Strategy 1: Try
|
|
255
|
+
// Strategy 1: Try Vigthoria Inference Server directly (NATIVE models on port 8010)
|
|
256
|
+
try {
|
|
257
|
+
const response = await axios.post('http://localhost:8010/v1/chat/completions', {
|
|
258
|
+
model: resolvedModel,
|
|
259
|
+
messages,
|
|
260
|
+
max_tokens: this.config.get('preferences').maxTokens,
|
|
261
|
+
temperature: 0.7,
|
|
262
|
+
stream: false,
|
|
263
|
+
}, { timeout: 120000 });
|
|
264
|
+
|
|
265
|
+
if (response.data.choices && response.data.choices.length > 0) {
|
|
266
|
+
return {
|
|
267
|
+
id: response.data.id || `vigthoria-native-${Date.now()}`,
|
|
268
|
+
message: response.data.choices[0].message?.content || response.data.choices[0].text,
|
|
269
|
+
model: response.data.model || model,
|
|
270
|
+
usage: response.data.usage,
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
} catch (error) {
|
|
274
|
+
this.logger.debug('Vigthoria Inference Server (8010) failed, trying Model Router...');
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// Strategy 2: Try local Model Router's Vigthoria chat endpoint
|
|
256
278
|
try {
|
|
257
279
|
const response = await axios.post('http://localhost:4009/api/vigthoria/chat', {
|
|
258
280
|
messages,
|
|
@@ -271,10 +293,10 @@ export class APIClient {
|
|
|
271
293
|
};
|
|
272
294
|
}
|
|
273
295
|
} catch (error) {
|
|
274
|
-
this.logger.debug('Model
|
|
296
|
+
this.logger.debug('Model Router (4009) failed, trying Ollama directly...');
|
|
275
297
|
}
|
|
276
298
|
|
|
277
|
-
// Strategy
|
|
299
|
+
// Strategy 3: Try Ollama directly (for local development/testing)
|
|
278
300
|
try {
|
|
279
301
|
const ollamaModel = this.resolveToOllamaModel(model);
|
|
280
302
|
const prompt = this.formatMessagesForOllama(messages);
|
|
@@ -299,39 +321,23 @@ export class APIClient {
|
|
|
299
321
|
this.logger.debug('Ollama failed...');
|
|
300
322
|
}
|
|
301
323
|
|
|
302
|
-
|
|
303
|
-
if (this.config.isAuthenticated()) {
|
|
304
|
-
try {
|
|
305
|
-
const response = await this.client.post('/viagen6/api/ai/generate', {
|
|
306
|
-
prompt: messages.map(m => `${m.role}: ${m.content}`).join('\n'),
|
|
307
|
-
model: resolvedModel,
|
|
308
|
-
max_tokens: this.config.get('preferences').maxTokens,
|
|
309
|
-
});
|
|
310
|
-
|
|
311
|
-
return {
|
|
312
|
-
id: `viagen6-${Date.now()}`,
|
|
313
|
-
message: response.data.code || response.data.response || response.data.content,
|
|
314
|
-
model: model,
|
|
315
|
-
};
|
|
316
|
-
} catch (fallbackError) {
|
|
317
|
-
// Continue to error
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
throw new Error('All AI backends unavailable. Please check your connection or authentication.');
|
|
324
|
+
throw new Error('AI service unavailable. Please check your authentication with `vigthoria login` or try again later.');
|
|
322
325
|
}
|
|
323
326
|
|
|
324
|
-
// Map CLI model names to Ollama model names (for local fallback)
|
|
327
|
+
// Map CLI model names to Ollama model names (for local/offline fallback)
|
|
328
|
+
// Vigthoria_v3_Code_30B runs on qwen3-coder base via Vigthoria Cloud
|
|
329
|
+
// Local users with Ollama can use the base model for offline work
|
|
325
330
|
private resolveToOllamaModel(model: string): string {
|
|
326
331
|
const ollamaMap: Record<string, string> = {
|
|
327
332
|
'fast': 'qwen3:0.6b',
|
|
328
333
|
'mini': 'smollm2:135m',
|
|
329
|
-
'code': '
|
|
334
|
+
'code': 'qwen3-coder:latest', // Vigthoria_v3_Code_30B (cloud) / qwen3-coder (local fallback)
|
|
330
335
|
'balanced': 'phi3:mini',
|
|
331
336
|
'creative': 'gemma3:latest',
|
|
332
337
|
'vigthoria-fast-1.7b': 'qwen3:0.6b',
|
|
333
338
|
'vigthoria-mini-0.6b': 'smollm2:135m',
|
|
334
|
-
'vigthoria-
|
|
339
|
+
'vigthoria-v3-code-30b': 'qwen3-coder:latest', // Vigthoria_v3_Code_30B
|
|
340
|
+
'vigthoria-v2-code-8b': 'qwen3-coder:latest', // Legacy v2
|
|
335
341
|
'vigthoria-balanced-4b': 'phi3:mini',
|
|
336
342
|
'vigthoria-creative-9b-v4': 'gemma3:latest',
|
|
337
343
|
};
|
|
@@ -444,9 +450,9 @@ export class APIClient {
|
|
|
444
450
|
});
|
|
445
451
|
}
|
|
446
452
|
|
|
447
|
-
// Code operations
|
|
453
|
+
// Code operations - Using Vigthoria Centralized API
|
|
448
454
|
async generateCode(prompt: string, language: string, model: string): Promise<string> {
|
|
449
|
-
const response = await this.client.post('/ai/generate', {
|
|
455
|
+
const response = await this.client.post('/api/ai/generate', {
|
|
450
456
|
prompt,
|
|
451
457
|
language,
|
|
452
458
|
model: this.resolveModelId(model),
|
|
@@ -455,8 +461,39 @@ export class APIClient {
|
|
|
455
461
|
return response.data.code;
|
|
456
462
|
}
|
|
457
463
|
|
|
464
|
+
// Senior Developer Mode - Planning + Generation + Quality Check
|
|
465
|
+
async generateProject(prompt: string, projectType: string, model: string): Promise<{
|
|
466
|
+
code: string;
|
|
467
|
+
plan?: any;
|
|
468
|
+
quality?: {
|
|
469
|
+
lineCount: number;
|
|
470
|
+
score: number;
|
|
471
|
+
checks: {
|
|
472
|
+
hasAnimations: boolean;
|
|
473
|
+
hasNeonEffects: boolean;
|
|
474
|
+
hasResponsive: boolean;
|
|
475
|
+
hasFontAwesome: boolean;
|
|
476
|
+
hasGoogleFonts: boolean;
|
|
477
|
+
};
|
|
478
|
+
};
|
|
479
|
+
}> {
|
|
480
|
+
const response = await this.client.post('/api/ai/generate-project', {
|
|
481
|
+
prompt,
|
|
482
|
+
projectType,
|
|
483
|
+
model: this.resolveModelId(model),
|
|
484
|
+
}, {
|
|
485
|
+
timeout: 300000, // 5 minutes for complex generation
|
|
486
|
+
});
|
|
487
|
+
|
|
488
|
+
return {
|
|
489
|
+
code: response.data.code,
|
|
490
|
+
plan: response.data.plan,
|
|
491
|
+
quality: response.data.quality,
|
|
492
|
+
};
|
|
493
|
+
}
|
|
494
|
+
|
|
458
495
|
async explainCode(code: string, language: string): Promise<string> {
|
|
459
|
-
const response = await this.client.post('/ai/explain', {
|
|
496
|
+
const response = await this.client.post('/api/ai/explain', {
|
|
460
497
|
code,
|
|
461
498
|
language,
|
|
462
499
|
});
|
|
@@ -469,7 +506,7 @@ export class APIClient {
|
|
|
469
506
|
issues: { type: string; line: number; message: string; severity: string }[];
|
|
470
507
|
suggestions: string[];
|
|
471
508
|
}> {
|
|
472
|
-
const response = await this.client.post('/ai/review', {
|
|
509
|
+
const response = await this.client.post('/api/ai/review', {
|
|
473
510
|
code,
|
|
474
511
|
language,
|
|
475
512
|
});
|
|
@@ -481,7 +518,7 @@ export class APIClient {
|
|
|
481
518
|
fixed: string;
|
|
482
519
|
changes: { line: number; before: string; after: string; reason: string }[];
|
|
483
520
|
}> {
|
|
484
|
-
const response = await this.client.post('/ai/fix', {
|
|
521
|
+
const response = await this.client.post('/api/ai/fix', {
|
|
485
522
|
code,
|
|
486
523
|
language,
|
|
487
524
|
fixType,
|
|
@@ -557,10 +594,17 @@ export class APIClient {
|
|
|
557
594
|
// Health check
|
|
558
595
|
async healthCheck(): Promise<boolean> {
|
|
559
596
|
try {
|
|
560
|
-
|
|
561
|
-
|
|
597
|
+
// Try the main API health endpoint first
|
|
598
|
+
const response = await this.client.get('/api/health');
|
|
599
|
+
return response.data?.status === 'ok' || response.data?.healthy === true;
|
|
562
600
|
} catch {
|
|
563
|
-
|
|
601
|
+
// Fallback: try root health endpoint
|
|
602
|
+
try {
|
|
603
|
+
await this.client.get('/health');
|
|
604
|
+
return true;
|
|
605
|
+
} catch {
|
|
606
|
+
return false;
|
|
607
|
+
}
|
|
564
608
|
}
|
|
565
609
|
}
|
|
566
610
|
}
|
package/src/utils/config.ts
CHANGED
|
@@ -206,7 +206,7 @@ export class Config {
|
|
|
206
206
|
// Pro plans get code and creative models
|
|
207
207
|
if (sub.plan === 'developer' || sub.plan === 'pro' || sub.plan === 'ultra' || sub.plan === 'enterprise') {
|
|
208
208
|
models.push(
|
|
209
|
-
{ id: 'code', name: '
|
|
209
|
+
{ id: 'code', name: 'Vigthoria_v3_Code_30B', description: 'Advanced code specialist with agent mode' },
|
|
210
210
|
{ id: 'creative', name: 'Vigthoria Creative 9B v4', description: 'Creative writing, lyrics' },
|
|
211
211
|
);
|
|
212
212
|
}
|