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
|
@@ -1,46 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Workspace Brain — local codebase index + Brain Hub sync for CLI.
|
|
4
3
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
-
}
|
|
11
|
-
Object.defineProperty(o, k2, desc);
|
|
12
|
-
}) : (function(o, m, k, k2) {
|
|
13
|
-
if (k2 === undefined) k2 = k;
|
|
14
|
-
o[k2] = m[k];
|
|
15
|
-
}));
|
|
16
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
-
}) : function(o, v) {
|
|
19
|
-
o["default"] = v;
|
|
20
|
-
});
|
|
21
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
-
var ownKeys = function(o) {
|
|
23
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
-
var ar = [];
|
|
25
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
-
return ar;
|
|
27
|
-
};
|
|
28
|
-
return ownKeys(o);
|
|
29
|
-
};
|
|
30
|
-
return function (mod) {
|
|
31
|
-
if (mod && mod.__esModule) return mod;
|
|
32
|
-
var result = {};
|
|
33
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
-
__setModuleDefault(result, mod);
|
|
35
|
-
return result;
|
|
36
|
-
};
|
|
37
|
-
})();
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.WorkspaceBrainService = void 0;
|
|
40
|
-
const path = __importStar(require("path"));
|
|
41
|
-
const brain_hub_client_js_1 = require("./brain-hub-client.js");
|
|
42
|
-
const codebase_indexer_js_1 = require("./codebase-indexer.js");
|
|
43
|
-
class WorkspaceBrainService {
|
|
4
|
+
import * as path from 'path';
|
|
5
|
+
import { BrainHubClient } from './brain-hub-client.js';
|
|
6
|
+
import { CodebaseIndexer } from './codebase-indexer.js';
|
|
7
|
+
export class WorkspaceBrainService {
|
|
44
8
|
workspacePath;
|
|
45
9
|
indexer;
|
|
46
10
|
brainClient;
|
|
@@ -49,8 +13,8 @@ class WorkspaceBrainService {
|
|
|
49
13
|
accountContextCache = null;
|
|
50
14
|
constructor(options) {
|
|
51
15
|
this.workspacePath = path.resolve(options.workspacePath);
|
|
52
|
-
this.indexer = new
|
|
53
|
-
this.brainClient = new
|
|
16
|
+
this.indexer = new CodebaseIndexer(this.workspacePath);
|
|
17
|
+
this.brainClient = new BrainHubClient({
|
|
54
18
|
apiBase: options.apiBase,
|
|
55
19
|
getAuthToken: options.getAuthToken,
|
|
56
20
|
});
|
|
@@ -67,7 +31,7 @@ class WorkspaceBrainService {
|
|
|
67
31
|
indexedFileCount: status.indexedFileCount,
|
|
68
32
|
totalChunks: status.totalChunks,
|
|
69
33
|
isIndexing: status.isIndexing,
|
|
70
|
-
meta:
|
|
34
|
+
meta: CodebaseIndexer.loadMeta(this.workspacePath),
|
|
71
35
|
};
|
|
72
36
|
}
|
|
73
37
|
async ensureIndexed(options = {}) {
|
|
@@ -77,7 +41,7 @@ class WorkspaceBrainService {
|
|
|
77
41
|
return { indexed: true, fileCount: meta.indexedFileCount, chunkCount: meta.totalChunks };
|
|
78
42
|
}
|
|
79
43
|
if (this.indexer.hasLocalIndex()) {
|
|
80
|
-
const meta =
|
|
44
|
+
const meta = CodebaseIndexer.loadMeta(this.workspacePath);
|
|
81
45
|
return {
|
|
82
46
|
indexed: true,
|
|
83
47
|
fileCount: meta?.indexedFileCount || this.indexer.getStatus().indexedFileCount,
|
|
@@ -155,4 +119,3 @@ class WorkspaceBrainService {
|
|
|
155
119
|
}).catch(() => undefined);
|
|
156
120
|
}
|
|
157
121
|
}
|
|
158
|
-
exports.WorkspaceBrainService = WorkspaceBrainService;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Vigthoria CLI — Workspace Hash Cache
|
|
4
3
|
*
|
|
@@ -7,24 +6,17 @@
|
|
|
7
6
|
* - Changed/new files → sent first (highest budget priority)
|
|
8
7
|
* - Unchanged files → sent last (trimmed by budget if token limit reached)
|
|
9
8
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.getChangedFiles = getChangedFiles;
|
|
15
|
-
exports.updateWorkspaceCache = updateWorkspaceCache;
|
|
16
|
-
exports.summarizeChanges = summarizeChanges;
|
|
17
|
-
const node_crypto_1 = require("node:crypto");
|
|
18
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
19
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
+
import { createHash } from 'node:crypto';
|
|
10
|
+
import fs from 'node:fs';
|
|
11
|
+
import path from 'node:path';
|
|
20
12
|
const CACHE_SUBDIR = '.vigthoria';
|
|
21
13
|
const CACHE_FILENAME = 'file-hashes.json';
|
|
22
14
|
function getCachePath(workspacePath) {
|
|
23
|
-
return
|
|
15
|
+
return path.join(workspacePath, CACHE_SUBDIR, CACHE_FILENAME);
|
|
24
16
|
}
|
|
25
17
|
function hashFile(absPath) {
|
|
26
18
|
try {
|
|
27
|
-
return
|
|
19
|
+
return createHash('sha256').update(fs.readFileSync(absPath)).digest('hex');
|
|
28
20
|
}
|
|
29
21
|
catch {
|
|
30
22
|
return '';
|
|
@@ -32,7 +24,7 @@ function hashFile(absPath) {
|
|
|
32
24
|
}
|
|
33
25
|
function loadCache(workspacePath) {
|
|
34
26
|
try {
|
|
35
|
-
return JSON.parse(
|
|
27
|
+
return JSON.parse(fs.readFileSync(getCachePath(workspacePath), 'utf-8'));
|
|
36
28
|
}
|
|
37
29
|
catch {
|
|
38
30
|
return {};
|
|
@@ -40,10 +32,10 @@ function loadCache(workspacePath) {
|
|
|
40
32
|
}
|
|
41
33
|
function persistCache(workspacePath, hashes) {
|
|
42
34
|
try {
|
|
43
|
-
const cacheDir =
|
|
44
|
-
if (!
|
|
45
|
-
|
|
46
|
-
|
|
35
|
+
const cacheDir = path.join(workspacePath, CACHE_SUBDIR);
|
|
36
|
+
if (!fs.existsSync(cacheDir))
|
|
37
|
+
fs.mkdirSync(cacheDir, { recursive: true });
|
|
38
|
+
fs.writeFileSync(getCachePath(workspacePath), JSON.stringify(hashes, null, 2), 'utf-8');
|
|
47
39
|
}
|
|
48
40
|
catch { /* non-fatal */ }
|
|
49
41
|
}
|
|
@@ -53,13 +45,13 @@ function persistCache(workspacePath, hashes) {
|
|
|
53
45
|
* @param workspacePath Absolute project root.
|
|
54
46
|
* @param relativePaths Workspace-relative (or absolute) file paths to check.
|
|
55
47
|
*/
|
|
56
|
-
function getChangedFiles(workspacePath, relativePaths) {
|
|
48
|
+
export function getChangedFiles(workspacePath, relativePaths) {
|
|
57
49
|
const cache = loadCache(workspacePath);
|
|
58
50
|
const changed = [];
|
|
59
51
|
const unchanged = [];
|
|
60
52
|
for (const rel of relativePaths) {
|
|
61
|
-
const abs =
|
|
62
|
-
const key =
|
|
53
|
+
const abs = path.isAbsolute(rel) ? rel : path.join(workspacePath, rel);
|
|
54
|
+
const key = path.relative(workspacePath, abs).replace(/\\/g, '/');
|
|
63
55
|
const currentHash = hashFile(abs);
|
|
64
56
|
if (!currentHash || cache[key] !== currentHash) {
|
|
65
57
|
changed.push(rel);
|
|
@@ -74,13 +66,13 @@ function getChangedFiles(workspacePath, relativePaths) {
|
|
|
74
66
|
* Write current hashes for the given files into the persistent cache.
|
|
75
67
|
* Call this after an agent run completes successfully.
|
|
76
68
|
*/
|
|
77
|
-
function updateWorkspaceCache(workspacePath, relativePaths) {
|
|
78
|
-
if (!workspacePath || !
|
|
69
|
+
export function updateWorkspaceCache(workspacePath, relativePaths) {
|
|
70
|
+
if (!workspacePath || !fs.existsSync(workspacePath))
|
|
79
71
|
return;
|
|
80
72
|
const cache = loadCache(workspacePath);
|
|
81
73
|
for (const rel of relativePaths) {
|
|
82
|
-
const abs =
|
|
83
|
-
const key =
|
|
74
|
+
const abs = path.isAbsolute(rel) ? rel : path.join(workspacePath, rel);
|
|
75
|
+
const key = path.relative(workspacePath, abs).replace(/\\/g, '/');
|
|
84
76
|
const hash = hashFile(abs);
|
|
85
77
|
if (hash)
|
|
86
78
|
cache[key] = hash;
|
|
@@ -90,7 +82,7 @@ function updateWorkspaceCache(workspacePath, relativePaths) {
|
|
|
90
82
|
/**
|
|
91
83
|
* Return a human-readable summary of changes since last cache update.
|
|
92
84
|
*/
|
|
93
|
-
function summarizeChanges(workspacePath, relativePaths) {
|
|
85
|
+
export function summarizeChanges(workspacePath, relativePaths) {
|
|
94
86
|
const { changed, unchanged, total } = getChangedFiles(workspacePath, relativePaths);
|
|
95
87
|
return `${changed.length} changed, ${unchanged.length} unchanged of ${total} files tracked`;
|
|
96
88
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Workspace Stream — Real-time bidirectional file sync between CLI and V3.
|
|
4
3
|
*
|
|
@@ -18,51 +17,12 @@
|
|
|
18
17
|
* {"type": "file_sync", "path": "rel/path", "content": "...", "action": "write"|"delete"}
|
|
19
18
|
* {"type": "file_batch", "files": [{path, content}, ...]}
|
|
20
19
|
*/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
Object.defineProperty(o, k2, desc);
|
|
28
|
-
}) : (function(o, m, k, k2) {
|
|
29
|
-
if (k2 === undefined) k2 = k;
|
|
30
|
-
o[k2] = m[k];
|
|
31
|
-
}));
|
|
32
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
33
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
34
|
-
}) : function(o, v) {
|
|
35
|
-
o["default"] = v;
|
|
36
|
-
});
|
|
37
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
38
|
-
var ownKeys = function(o) {
|
|
39
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
40
|
-
var ar = [];
|
|
41
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
42
|
-
return ar;
|
|
43
|
-
};
|
|
44
|
-
return ownKeys(o);
|
|
45
|
-
};
|
|
46
|
-
return function (mod) {
|
|
47
|
-
if (mod && mod.__esModule) return mod;
|
|
48
|
-
var result = {};
|
|
49
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
50
|
-
__setModuleDefault(result, mod);
|
|
51
|
-
return result;
|
|
52
|
-
};
|
|
53
|
-
})();
|
|
54
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
55
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
56
|
-
};
|
|
57
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
58
|
-
exports.WorkspaceWSClient = exports.WorkspaceWatcher = void 0;
|
|
59
|
-
exports.applyFileMutation = applyFileMutation;
|
|
60
|
-
const chokidar = __importStar(require("chokidar"));
|
|
61
|
-
const fs_1 = __importDefault(require("fs"));
|
|
62
|
-
const path_1 = __importDefault(require("path"));
|
|
63
|
-
const ws_1 = __importDefault(require("ws"));
|
|
64
|
-
const logger_js_1 = require("./logger.js");
|
|
65
|
-
const logger = new logger_js_1.Logger();
|
|
20
|
+
import * as chokidar from 'chokidar';
|
|
21
|
+
import fs from 'fs';
|
|
22
|
+
import path from 'path';
|
|
23
|
+
import WebSocket from 'ws';
|
|
24
|
+
import { Logger } from './logger.js';
|
|
25
|
+
const logger = new Logger();
|
|
66
26
|
logger.setVerbose(!!process.env.VIGTHORIA_DEBUG);
|
|
67
27
|
// Files/dirs to ignore in the watcher
|
|
68
28
|
const IGNORE_PATTERNS = [
|
|
@@ -109,27 +69,27 @@ const _v3MuteTimeout = 2000; // 2s mute window after V3 writes a file
|
|
|
109
69
|
* Apply a file_mutation event from V3's SSE stream to the local workspace.
|
|
110
70
|
* Call this from the SSE event handler for real-time file application.
|
|
111
71
|
*/
|
|
112
|
-
function applyFileMutation(event, workspaceRoot) {
|
|
72
|
+
export function applyFileMutation(event, workspaceRoot) {
|
|
113
73
|
if (event.type !== 'file_mutation')
|
|
114
74
|
return false;
|
|
115
75
|
if (!event.path || !workspaceRoot)
|
|
116
76
|
return false;
|
|
117
|
-
const absPath =
|
|
77
|
+
const absPath = path.resolve(workspaceRoot, event.path);
|
|
118
78
|
// Safety: ensure the resolved path is within the workspace
|
|
119
|
-
if (!absPath.startsWith(
|
|
79
|
+
if (!absPath.startsWith(path.resolve(workspaceRoot) + path.sep) && absPath !== path.resolve(workspaceRoot)) {
|
|
120
80
|
logger.warn(`Refusing to apply mutation outside workspace: ${event.path}`);
|
|
121
81
|
return false;
|
|
122
82
|
}
|
|
123
83
|
try {
|
|
124
84
|
if (event.action === 'delete') {
|
|
125
|
-
if (
|
|
126
|
-
|
|
85
|
+
if (fs.existsSync(absPath)) {
|
|
86
|
+
fs.unlinkSync(absPath);
|
|
127
87
|
logger.debug(`Deleted: ${event.path}`);
|
|
128
88
|
}
|
|
129
89
|
}
|
|
130
90
|
else if (typeof event.content === 'string') {
|
|
131
|
-
|
|
132
|
-
|
|
91
|
+
fs.mkdirSync(path.dirname(absPath), { recursive: true });
|
|
92
|
+
fs.writeFileSync(absPath, event.content, 'utf8');
|
|
133
93
|
// Mute the watcher for this file to prevent echo
|
|
134
94
|
_v3MutatedFiles.add(absPath);
|
|
135
95
|
setTimeout(() => _v3MutatedFiles.delete(absPath), _v3MuteTimeout);
|
|
@@ -142,13 +102,13 @@ function applyFileMutation(event, workspaceRoot) {
|
|
|
142
102
|
return false;
|
|
143
103
|
}
|
|
144
104
|
}
|
|
145
|
-
class WorkspaceWatcher {
|
|
105
|
+
export class WorkspaceWatcher {
|
|
146
106
|
watcher = null;
|
|
147
107
|
workspaceRoot;
|
|
148
108
|
onFileChange;
|
|
149
109
|
_ready = false;
|
|
150
110
|
constructor(options) {
|
|
151
|
-
this.workspaceRoot =
|
|
111
|
+
this.workspaceRoot = path.resolve(options.workspaceRoot);
|
|
152
112
|
this.onFileChange = options.onFileChange;
|
|
153
113
|
}
|
|
154
114
|
start() {
|
|
@@ -213,10 +173,10 @@ class WorkspaceWatcher {
|
|
|
213
173
|
// Skip if this file was just written by V3 (echo prevention)
|
|
214
174
|
if (_v3MutatedFiles.has(filePath))
|
|
215
175
|
return;
|
|
216
|
-
const ext =
|
|
176
|
+
const ext = path.extname(filePath).toLowerCase();
|
|
217
177
|
if (BINARY_EXTENSIONS.has(ext))
|
|
218
178
|
return;
|
|
219
|
-
const relativePath =
|
|
179
|
+
const relativePath = path.relative(this.workspaceRoot, filePath);
|
|
220
180
|
if (relativePath.startsWith('..'))
|
|
221
181
|
return; // safety
|
|
222
182
|
if (action === 'delete') {
|
|
@@ -224,10 +184,10 @@ class WorkspaceWatcher {
|
|
|
224
184
|
return;
|
|
225
185
|
}
|
|
226
186
|
try {
|
|
227
|
-
const stat =
|
|
187
|
+
const stat = fs.statSync(filePath);
|
|
228
188
|
if (stat.size > MAX_SYNC_FILE_BYTES)
|
|
229
189
|
return;
|
|
230
|
-
const content =
|
|
190
|
+
const content = fs.readFileSync(filePath, 'utf8');
|
|
231
191
|
this.onFileChange?.(relativePath, content, 'write');
|
|
232
192
|
}
|
|
233
193
|
catch {
|
|
@@ -235,8 +195,7 @@ class WorkspaceWatcher {
|
|
|
235
195
|
}
|
|
236
196
|
}
|
|
237
197
|
}
|
|
238
|
-
|
|
239
|
-
class WorkspaceWSClient {
|
|
198
|
+
export class WorkspaceWSClient {
|
|
240
199
|
ws = null;
|
|
241
200
|
opts;
|
|
242
201
|
reconnectTimer = null;
|
|
@@ -250,7 +209,7 @@ class WorkspaceWSClient {
|
|
|
250
209
|
if (this.ws)
|
|
251
210
|
return;
|
|
252
211
|
const url = `${this.opts.serverUrl}/ws/workspace`;
|
|
253
|
-
this.ws = new
|
|
212
|
+
this.ws = new WebSocket(url);
|
|
254
213
|
this.ws.on('open', () => {
|
|
255
214
|
this._connected = true;
|
|
256
215
|
this._send({
|
|
@@ -343,4 +302,3 @@ class WorkspaceWSClient {
|
|
|
343
302
|
}
|
|
344
303
|
}
|
|
345
304
|
}
|
|
346
|
-
exports.WorkspaceWSClient = WorkspaceWSClient;
|