vigthoria-cli 1.10.47 → 1.10.48
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/auth.js +51 -68
- package/dist/commands/bridge.js +12 -19
- package/dist/commands/cancel.js +15 -22
- package/dist/commands/chat.d.ts +28 -0
- package/dist/commands/config.js +33 -73
- package/dist/commands/deploy.js +83 -123
- package/dist/commands/device.js +21 -61
- package/dist/commands/edit.js +32 -39
- package/dist/commands/explain.js +18 -25
- package/dist/commands/fork.d.ts +17 -0
- package/dist/commands/fork.js +164 -0
- package/dist/commands/generate.js +37 -44
- package/dist/commands/history.d.ts +17 -0
- package/dist/commands/history.js +113 -0
- package/dist/commands/hub.js +95 -102
- package/dist/commands/index.js +41 -46
- package/dist/commands/legion.js +146 -186
- package/dist/commands/preview.d.ts +55 -0
- package/dist/commands/preview.js +467 -0
- package/dist/commands/replay.d.ts +18 -0
- package/dist/commands/replay.js +156 -0
- package/dist/commands/repo.d.ts +97 -0
- package/dist/commands/repo.js +773 -0
- package/dist/commands/review.js +29 -36
- package/dist/commands/security.js +5 -12
- package/dist/commands/update.d.ts +9 -0
- package/dist/commands/update.js +201 -0
- package/dist/commands/wallet.js +28 -35
- package/dist/commands/workflow.js +13 -20
- package/dist/index.d.ts +21 -0
- package/dist/index.js +1826 -0
- package/dist/utils/api.d.ts +572 -0
- package/dist/utils/api.js +6629 -0
- package/dist/utils/brain-hub-client.js +1 -5
- package/dist/utils/bridge-client.js +11 -52
- package/dist/utils/cli-state.d.ts +54 -0
- package/dist/utils/cli-state.js +185 -0
- package/dist/utils/codebase-indexer.js +4 -41
- package/dist/utils/config.d.ts +85 -0
- package/dist/utils/config.js +267 -0
- package/dist/utils/context-ranker.js +15 -21
- package/dist/utils/files.js +5 -42
- package/dist/utils/logger.js +42 -50
- package/dist/utils/persona.js +3 -8
- package/dist/utils/post-write-validator.js +22 -29
- package/dist/utils/project-memory.js +16 -23
- package/dist/utils/session.d.ts +118 -0
- package/dist/utils/session.js +423 -0
- package/dist/utils/task-display.js +13 -20
- package/dist/utils/tools.d.ts +276 -0
- package/dist/utils/tools.js +3522 -0
- package/dist/utils/workspace-brain-service.js +8 -45
- package/dist/utils/workspace-cache.js +18 -26
- package/dist/utils/workspace-stream.js +21 -63
- package/package.json +1 -1
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { isServerRuntime } from '../utils/api.js';
|
|
2
|
+
/**
|
|
3
|
+
* replay.ts — Replay events from a V3 agent run step-by-step.
|
|
4
|
+
*/
|
|
5
|
+
import chalk from 'chalk';
|
|
6
|
+
import { createRequire } from 'node:module';
|
|
7
|
+
import { createSpinner, CH } from '../utils/logger.js';
|
|
8
|
+
const require = createRequire(import.meta.url);
|
|
9
|
+
export class ReplayCommand {
|
|
10
|
+
config;
|
|
11
|
+
logger;
|
|
12
|
+
constructor(config, logger) {
|
|
13
|
+
this.config = config;
|
|
14
|
+
this.logger = logger;
|
|
15
|
+
}
|
|
16
|
+
getHeaders() {
|
|
17
|
+
const headers = { 'Content-Type': 'application/json' };
|
|
18
|
+
const token = process.env.VIGTHORIA_TOKEN ||
|
|
19
|
+
process.env.VIGTHORIA_AUTH_TOKEN ||
|
|
20
|
+
this.config.get('authToken');
|
|
21
|
+
if (token) {
|
|
22
|
+
headers['Authorization'] = `Bearer ${token}`;
|
|
23
|
+
headers['Cookie'] = `vigthoria-auth-token=${token}`;
|
|
24
|
+
}
|
|
25
|
+
const serviceKey = process.env.VIGTHORIA_V3_SERVICE_KEY;
|
|
26
|
+
if (serviceKey)
|
|
27
|
+
headers['X-Service-Key'] = serviceKey;
|
|
28
|
+
return headers;
|
|
29
|
+
}
|
|
30
|
+
getBaseUrl() {
|
|
31
|
+
const configuredApiUrl = String(this.config.get('apiUrl') || 'https://coder.vigthoria.io').replace(/\/$/, '');
|
|
32
|
+
const allowLocal = !isServerRuntime() || process.env.VIGTHORIA_ALLOW_LOCAL_V3_AGENT === '1';
|
|
33
|
+
return (process.env.VIGTHORIA_V3_AGENT_URL ||
|
|
34
|
+
process.env.V3_AGENT_URL ||
|
|
35
|
+
(allowLocal ? 'http://127.0.0.1:8030' : null) ||
|
|
36
|
+
configuredApiUrl);
|
|
37
|
+
}
|
|
38
|
+
resolveWorkspaceRoot(project) {
|
|
39
|
+
if (/^[a-zA-Z]:[\\/]/.test(project) || /^\\\\/.test(project))
|
|
40
|
+
return '';
|
|
41
|
+
if (typeof require !== 'undefined') {
|
|
42
|
+
try {
|
|
43
|
+
const path = require('path');
|
|
44
|
+
if (!path.isAbsolute(project))
|
|
45
|
+
return '';
|
|
46
|
+
}
|
|
47
|
+
catch { }
|
|
48
|
+
}
|
|
49
|
+
return project;
|
|
50
|
+
}
|
|
51
|
+
sleep(ms) {
|
|
52
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
53
|
+
}
|
|
54
|
+
async run(runId, options) {
|
|
55
|
+
const speed = options.speed || 200;
|
|
56
|
+
const project = options.project || process.cwd();
|
|
57
|
+
const workspace = this.resolveWorkspaceRoot(project);
|
|
58
|
+
const spinner = createSpinner(`Loading events for run ${runId}...`).start();
|
|
59
|
+
try {
|
|
60
|
+
const baseUrl = this.getBaseUrl();
|
|
61
|
+
const params = new URLSearchParams({ workspace_root: workspace });
|
|
62
|
+
const resp = await fetch(`${baseUrl}/api/runs/${encodeURIComponent(runId)}/events?${params}`, {
|
|
63
|
+
headers: this.getHeaders(),
|
|
64
|
+
});
|
|
65
|
+
if (!resp.ok) {
|
|
66
|
+
spinner.stop();
|
|
67
|
+
if (resp.status === 404) {
|
|
68
|
+
this.logger.error(`No event log found for run ${runId}. Events are only recorded for runs made after the replay system was deployed.`);
|
|
69
|
+
}
|
|
70
|
+
else if (resp.status === 502 || resp.status === 503) {
|
|
71
|
+
this.logger.error(`V3 run-history route is not available on ${baseUrl}. Backend may not expose /api/runs.`);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
this.logger.error(`Failed to fetch events: ${resp.status} ${resp.statusText}`);
|
|
75
|
+
}
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const data = (await resp.json());
|
|
79
|
+
spinner.stop();
|
|
80
|
+
if (options.json) {
|
|
81
|
+
console.log(JSON.stringify(data, null, 2));
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
console.log(chalk.bold(`\n${CH.success} Replaying run ${chalk.cyan(runId)} (${data.count} events)\n`));
|
|
85
|
+
let toolCallNum = 0;
|
|
86
|
+
for (let i = 0; i < data.events.length; i++) {
|
|
87
|
+
const evt = data.events[i];
|
|
88
|
+
const type = evt.type || 'unknown';
|
|
89
|
+
const idx = chalk.dim(`[${String(i + 1).padStart(3)}/${data.count}]`);
|
|
90
|
+
switch (type) {
|
|
91
|
+
case 'context':
|
|
92
|
+
console.log(`${idx} ${chalk.blue('context')} workspace=${evt.workspace_root || '?'}`);
|
|
93
|
+
break;
|
|
94
|
+
case 'start':
|
|
95
|
+
console.log(`${idx} ${chalk.green('▶ START')} task=${evt.task_id || '?'} ${evt.continuation ? chalk.dim(`(continuation #${evt.continuation})`) : ''}`);
|
|
96
|
+
break;
|
|
97
|
+
case 'thinking':
|
|
98
|
+
console.log(`${idx} ${chalk.dim('💭 thinking')} ${(evt.content || '').substring(0, 100)}`);
|
|
99
|
+
break;
|
|
100
|
+
case 'plan':
|
|
101
|
+
const taskCount = evt.tasks?.length || 0;
|
|
102
|
+
console.log(`${idx} ${chalk.magenta('📋 PLAN')} ${taskCount} tasks`);
|
|
103
|
+
if (evt.tasks) {
|
|
104
|
+
for (const t of evt.tasks.slice(0, 5)) {
|
|
105
|
+
console.log(` ${chalk.dim('├')} ${t.id || '?'}: ${(t.title || '').substring(0, 60)}`);
|
|
106
|
+
}
|
|
107
|
+
if (taskCount > 5)
|
|
108
|
+
console.log(` ${chalk.dim('└')} ...and ${taskCount - 5} more`);
|
|
109
|
+
}
|
|
110
|
+
break;
|
|
111
|
+
case 'tool_call':
|
|
112
|
+
toolCallNum++;
|
|
113
|
+
console.log(`${idx} ${chalk.yellow(`🔧 tool_call #${toolCallNum}`)} ${chalk.bold(evt.name || '?')}(${JSON.stringify(evt.arguments || {}).substring(0, 80)})`);
|
|
114
|
+
break;
|
|
115
|
+
case 'tool_result': {
|
|
116
|
+
const success = evt.success !== false;
|
|
117
|
+
const icon = success ? chalk.green('✓') : chalk.red('✗');
|
|
118
|
+
const output = (evt.output || '').substring(0, 120);
|
|
119
|
+
console.log(`${idx} ${icon} ${evt.name || '?'}: ${chalk.dim(output)}`);
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
case 'message':
|
|
123
|
+
console.log(`${idx} ${chalk.cyan('💬 message')} ${(evt.content || '').substring(0, 120)}`);
|
|
124
|
+
break;
|
|
125
|
+
case 'complete': {
|
|
126
|
+
const summary = (evt.summary || '').substring(0, 200);
|
|
127
|
+
const seal = evt.seal_score ? ` [${evt.seal_score.tier} ${evt.seal_score.overall}]` : '';
|
|
128
|
+
console.log(`${idx} ${chalk.green(`✅ COMPLETE`)}${chalk.yellow(seal)} ${evt.iterations || '?'} iterations, ${evt.tool_calls || '?'} tool calls`);
|
|
129
|
+
if (summary)
|
|
130
|
+
console.log(` ${chalk.dim(summary)}`);
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
case 'error':
|
|
134
|
+
console.log(`${idx} ${chalk.red('❌ ERROR')} ${(evt.message || '').substring(0, 200)}`);
|
|
135
|
+
if (evt.checkpointed)
|
|
136
|
+
console.log(` ${chalk.yellow('Checkpointed — can be continued or forked')}`);
|
|
137
|
+
break;
|
|
138
|
+
case 'file_mutation':
|
|
139
|
+
console.log(`${idx} ${chalk.blue('📁 file_mutation')} ${evt.kind || '?'} ${evt.path || '?'}`);
|
|
140
|
+
break;
|
|
141
|
+
default:
|
|
142
|
+
console.log(`${idx} ${chalk.dim(type)} ${JSON.stringify(evt).substring(0, 100)}`);
|
|
143
|
+
}
|
|
144
|
+
// Delay between events for replay effect
|
|
145
|
+
if (i < data.events.length - 1) {
|
|
146
|
+
await this.sleep(speed);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
console.log(chalk.bold(`\n${CH.success} Replay complete (${data.count} events)\n`));
|
|
150
|
+
}
|
|
151
|
+
catch (err) {
|
|
152
|
+
spinner.stop();
|
|
153
|
+
this.logger.error(`Replay error: ${err.message}`);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vigthoria CLI - Repo Commands
|
|
3
|
+
*
|
|
4
|
+
* Push and pull projects to/from Vigthoria Repository
|
|
5
|
+
* Enables version control and project sharing through the Vigthoria platform
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* vigthoria repo push [path] - Push current/specified project to Vigthoria Repo
|
|
9
|
+
* vigthoria repo pull <name> - Pull a project from your Vigthoria Repo
|
|
10
|
+
* vigthoria repo list - List all your projects in Vigthoria Repo
|
|
11
|
+
* vigthoria repo status - Show sync status of current project
|
|
12
|
+
* vigthoria repo share <name> - Generate shareable link for a project
|
|
13
|
+
* vigthoria repo delete <name> - Remove a project from your Vigthoria Repo
|
|
14
|
+
*/
|
|
15
|
+
import { Config } from '../utils/config.js';
|
|
16
|
+
import { Logger } from '../utils/logger.js';
|
|
17
|
+
interface PushOptions {
|
|
18
|
+
path?: string;
|
|
19
|
+
name?: string;
|
|
20
|
+
visibility?: 'public' | 'private' | 'restricted';
|
|
21
|
+
description?: string;
|
|
22
|
+
force?: boolean;
|
|
23
|
+
yes?: boolean;
|
|
24
|
+
}
|
|
25
|
+
interface PullOptions {
|
|
26
|
+
output?: string;
|
|
27
|
+
force?: boolean;
|
|
28
|
+
}
|
|
29
|
+
interface ListOptions {
|
|
30
|
+
visibility?: string;
|
|
31
|
+
showAll?: boolean;
|
|
32
|
+
}
|
|
33
|
+
interface ShareOptions {
|
|
34
|
+
expires?: string;
|
|
35
|
+
}
|
|
36
|
+
export declare class RepoCommand {
|
|
37
|
+
private config;
|
|
38
|
+
private logger;
|
|
39
|
+
private apiBase;
|
|
40
|
+
private communityBase;
|
|
41
|
+
private communityToken;
|
|
42
|
+
constructor(config: Config, logger: Logger);
|
|
43
|
+
private getAuthHeaders;
|
|
44
|
+
private ensureCommunityAuth;
|
|
45
|
+
private repoFetch;
|
|
46
|
+
private collectProjectFiles;
|
|
47
|
+
private getMyRepos;
|
|
48
|
+
private resolveRepoByName;
|
|
49
|
+
private formatRepoError;
|
|
50
|
+
private isAuthenticated;
|
|
51
|
+
private requireAuth;
|
|
52
|
+
/**
|
|
53
|
+
* Detect project info from package.json, requirements.txt, etc.
|
|
54
|
+
*/
|
|
55
|
+
private detectProjectInfo;
|
|
56
|
+
/**
|
|
57
|
+
* Create a zip archive of a project
|
|
58
|
+
*/
|
|
59
|
+
private createProjectArchive;
|
|
60
|
+
/**
|
|
61
|
+
* Push a project to Vigthoria Repository
|
|
62
|
+
*/
|
|
63
|
+
push(options?: PushOptions): Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Pull a project from Vigthoria Repository
|
|
66
|
+
*/
|
|
67
|
+
pull(projectName: string, options?: PullOptions): Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* List all projects in user's Vigthoria Repository
|
|
70
|
+
*/
|
|
71
|
+
list(options?: ListOptions): Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Show sync status of current project
|
|
74
|
+
*/
|
|
75
|
+
status(): Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* Generate a shareable link for a project
|
|
78
|
+
*/
|
|
79
|
+
share(projectName: string, options?: ShareOptions): Promise<void>;
|
|
80
|
+
/**
|
|
81
|
+
* Delete a project from Vigthoria Repository
|
|
82
|
+
*/
|
|
83
|
+
delete(projectName: string): Promise<void>;
|
|
84
|
+
/**
|
|
85
|
+
* Open a project in a Vigthoria engine (shop, visual, game).
|
|
86
|
+
* Pushes to community if not yet there, then triggers engine import.
|
|
87
|
+
*/
|
|
88
|
+
openIn(engine: 'shop' | 'visual' | 'game', projectName?: string, options?: {
|
|
89
|
+
browser?: boolean;
|
|
90
|
+
shopId?: string;
|
|
91
|
+
}): Promise<void>;
|
|
92
|
+
/**
|
|
93
|
+
* Clone a public project from Vigthoria Repository
|
|
94
|
+
*/
|
|
95
|
+
clone(projectUrl: string, options?: PullOptions): Promise<void>;
|
|
96
|
+
}
|
|
97
|
+
export {};
|