vigthoria-cli 1.10.47 → 1.10.49

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.
Files changed (60) hide show
  1. package/dist/commands/agent-session-menu.js +2 -8
  2. package/dist/commands/auth.js +51 -68
  3. package/dist/commands/bridge.js +42 -22
  4. package/dist/commands/cancel.js +15 -22
  5. package/dist/commands/chat.d.ts +3 -0
  6. package/dist/commands/chat.js +326 -295
  7. package/dist/commands/config.js +33 -73
  8. package/dist/commands/deploy.js +83 -123
  9. package/dist/commands/device.js +21 -61
  10. package/dist/commands/edit.js +32 -39
  11. package/dist/commands/explain.js +18 -25
  12. package/dist/commands/fork.d.ts +17 -0
  13. package/dist/commands/fork.js +164 -0
  14. package/dist/commands/generate.js +37 -44
  15. package/dist/commands/history.d.ts +17 -0
  16. package/dist/commands/history.js +113 -0
  17. package/dist/commands/hub.js +95 -102
  18. package/dist/commands/index.js +41 -46
  19. package/dist/commands/legion.js +146 -186
  20. package/dist/commands/preview.d.ts +55 -0
  21. package/dist/commands/preview.js +467 -0
  22. package/dist/commands/replay.d.ts +18 -0
  23. package/dist/commands/replay.js +156 -0
  24. package/dist/commands/repo.d.ts +97 -0
  25. package/dist/commands/repo.js +773 -0
  26. package/dist/commands/review.js +29 -36
  27. package/dist/commands/security.js +5 -12
  28. package/dist/commands/update.d.ts +9 -0
  29. package/dist/commands/update.js +201 -0
  30. package/dist/commands/wallet.js +28 -35
  31. package/dist/commands/workflow.js +13 -20
  32. package/dist/index.d.ts +21 -0
  33. package/dist/index.js +1652 -0
  34. package/dist/utils/api.d.ts +544 -0
  35. package/dist/utils/api.js +5486 -0
  36. package/dist/utils/brain-hub-client.js +1 -5
  37. package/dist/utils/bridge-client.js +11 -52
  38. package/dist/utils/cli-state.d.ts +54 -0
  39. package/dist/utils/cli-state.js +185 -0
  40. package/dist/utils/codebase-indexer.js +4 -41
  41. package/dist/utils/config.d.ts +82 -0
  42. package/dist/utils/config.js +269 -0
  43. package/dist/utils/context-ranker.js +15 -21
  44. package/dist/utils/desktop-bridge-client.d.ts +12 -0
  45. package/dist/utils/desktop-bridge-client.js +30 -0
  46. package/dist/utils/files.js +5 -42
  47. package/dist/utils/logger.js +42 -50
  48. package/dist/utils/persona.js +3 -8
  49. package/dist/utils/post-write-validator.js +26 -33
  50. package/dist/utils/project-memory.js +16 -23
  51. package/dist/utils/session.d.ts +118 -0
  52. package/dist/utils/session.js +423 -0
  53. package/dist/utils/task-display.js +13 -20
  54. package/dist/utils/tools.d.ts +269 -0
  55. package/dist/utils/tools.js +3450 -0
  56. package/dist/utils/workspace-brain-service.js +8 -45
  57. package/dist/utils/workspace-cache.js +18 -26
  58. package/dist/utils/workspace-stream.js +21 -63
  59. package/package.json +2 -1
  60. package/scripts/release/validate-no-go-gates.sh +7 -4
@@ -0,0 +1,269 @@
1
+ /**
2
+ * Vigthoria CLI Tools - Agentic Tool System
3
+ *
4
+ * This module provides Vigthoria Autonomous autonomous tool execution.
5
+ * Tools can be called by the AI to perform actions.
6
+ *
7
+ * Enhanced with:
8
+ * - Risk-based permission system
9
+ * - Automatic retry logic with exponential backoff
10
+ * - Undo functionality for file operations
11
+ * - Detailed error messages with suggestions
12
+ *
13
+ * @version 1.1.0
14
+ * @author Vigthoria Labs
15
+ */
16
+ import { Logger } from './logger.js';
17
+ export type StreamChunk = {
18
+ type: 'text' | 'delta' | 'error';
19
+ content: string;
20
+ };
21
+ export type UpdateInstallerResult = {
22
+ success: boolean;
23
+ platform: string;
24
+ error?: string;
25
+ };
26
+ export declare function installUpdateWindows(): Promise<UpdateInstallerResult>;
27
+ export declare function robustifyStreamResponse(res: any): AsyncIterable<StreamChunk>;
28
+ export type RiskLevel = 'low' | 'medium' | 'high' | 'critical';
29
+ export type SearchStatus = 'search_matches_found' | 'search_no_matches' | 'search_failed';
30
+ export interface ToolResult {
31
+ success: boolean;
32
+ output?: string;
33
+ error?: string;
34
+ suggestion?: string;
35
+ canRetry?: boolean;
36
+ undoable?: boolean;
37
+ /** True when VIGTHORIA_DRY_RUN / VIGTHORIA_READ_ONLY caused a mutating tool to short-circuit. */
38
+ dryRun?: boolean;
39
+ /** Optional human-readable message attached to a dry-run / informational result. */
40
+ message?: string;
41
+ metadata?: {
42
+ searchStatus?: SearchStatus;
43
+ [key: string]: any;
44
+ };
45
+ }
46
+ export interface ToolCall {
47
+ tool: string;
48
+ args: Record<string, string>;
49
+ }
50
+ export interface ToolDefinition {
51
+ name: string;
52
+ description: string;
53
+ parameters: {
54
+ name: string;
55
+ description: string;
56
+ required: boolean;
57
+ }[];
58
+ requiresPermission: boolean;
59
+ dangerous: boolean;
60
+ riskLevel: RiskLevel;
61
+ category: 'read' | 'write' | 'execute' | 'search';
62
+ }
63
+ interface UndoOperation {
64
+ id: string;
65
+ tool: string;
66
+ timestamp: number;
67
+ filePath?: string;
68
+ originalContent?: string | null;
69
+ description: string;
70
+ }
71
+ export declare enum ToolErrorType {
72
+ FILE_NOT_FOUND = "FILE_NOT_FOUND",
73
+ PERMISSION_DENIED = "PERMISSION_DENIED",
74
+ NETWORK_ERROR = "NETWORK_ERROR",
75
+ TIMEOUT = "TIMEOUT",
76
+ INVALID_ARGS = "INVALID_ARGS",
77
+ EXECUTION_FAILED = "EXECUTION_FAILED",
78
+ USER_CANCELLED = "USER_CANCELLED"
79
+ }
80
+ export declare class AgenticTools {
81
+ private logger;
82
+ private cwd;
83
+ private permissionCallback;
84
+ private autoApprove;
85
+ private undoStack;
86
+ private maxUndoStack;
87
+ private retryConfig;
88
+ private formatExternalToolError;
89
+ private externalToolFailure;
90
+ private cleanupAfterToolError;
91
+ private runExternalCommand;
92
+ private isNonEmptyString;
93
+ private describeInvalidValue;
94
+ private assertStringRecord;
95
+ private requireNonEmptyString;
96
+ private requireArgsObject;
97
+ private sessionApprovedTools;
98
+ private static permissionsFile;
99
+ constructor(logger: Logger, cwd: string, permissionCallback: (action: string, options?: {
100
+ batchApproval?: boolean;
101
+ }) => Promise<boolean | 'batch' | 'persist'>, autoApprove?: boolean);
102
+ private getErrorMessage;
103
+ private assertToolCall;
104
+ /**
105
+ * Load persistent permissions for the current project
106
+ */
107
+ private loadPersistentPermissions;
108
+ /**
109
+ * Save a persistent permission for a tool in the current project
110
+ */
111
+ private savePersistentPermission;
112
+ /**
113
+ * Check if a tool has persistent permission for the current project
114
+ */
115
+ private hasPersistentPermission;
116
+ /**
117
+ * Clear session-approved tools (call this at the start of each new AI turn)
118
+ */
119
+ clearSessionApprovals(): void;
120
+ /**
121
+ * Get currently approved tools for this session
122
+ */
123
+ getSessionApprovedTools(): string[];
124
+ /**
125
+ * Get the undo stack for inspection
126
+ */
127
+ getUndoStack(): UndoOperation[];
128
+ /**
129
+ * Undo the last file operation
130
+ */
131
+ undo(): Promise<ToolResult>;
132
+ /**
133
+ * List of available tools - Vigthoria's advanced
134
+ * Enhanced with risk levels and categories
135
+ */
136
+ static getToolDefinitions(): ToolDefinition[];
137
+ /**
138
+ * Execute a tool call with enhanced error handling and retry logic
139
+ */
140
+ execute(call: ToolCall): Promise<ToolResult>;
141
+ private normalizeToolCall;
142
+ /**
143
+ * Execute tool with automatic retry for transient failures
144
+ */
145
+ private executeWithRetry;
146
+ /**
147
+ * Tool names that mutate the user's filesystem, shell state, or remote
148
+ * services. Used by the dry-run / read-only gate below.
149
+ */
150
+ private static readonly MUTATING_TOOLS;
151
+ /**
152
+ * `VIGTHORIA_DRY_RUN=1` and `VIGTHORIA_READ_ONLY=1` are end-user safety
153
+ * switches: every mutating tool short-circuits with a clear "would have
154
+ * happened" result instead of touching the filesystem or network.
155
+ *
156
+ * The flags are checked at call-time (not at construction time) so they
157
+ * can be flipped per-prompt by users who want to inspect agent intent
158
+ * before committing.
159
+ */
160
+ private isDryRunActive;
161
+ /**
162
+ * Execute the actual tool operation
163
+ */
164
+ private executeTool;
165
+ /**
166
+ * Check if an error is retryable
167
+ */
168
+ private isRetryableError;
169
+ /**
170
+ * Safely stringify tool arguments without dumping very large payloads into logs.
171
+ */
172
+ private safeStringifyArgs;
173
+ /**
174
+ * Validate tool parameters
175
+ */
176
+ private validateParameters;
177
+ /**
178
+ * Create a standardized error result
179
+ */
180
+ private createErrorResult;
181
+ /**
182
+ * Enhanced permission request with risk visualization
183
+ */
184
+ private formatPermissionRequest;
185
+ private sleep;
186
+ /**
187
+ * Read file with enhanced error handling and suggestions
188
+ */
189
+ private readFile;
190
+ /**
191
+ * Write file with undo support
192
+ */
193
+ private writeFile;
194
+ /**
195
+ * Edit file with undo support and helpful error messages
196
+ */
197
+ private editFile;
198
+ private validateWrittenFile;
199
+ private validateJavaScriptSyntax;
200
+ private validateHtmlContent;
201
+ /**
202
+ * Execute bash command with enhanced error handling
203
+ * SECURITY: Commands are sandboxed to workspace directory
204
+ * WINDOWS: Detects Unix-specific commands and suggests alternatives
205
+ */
206
+ private bash;
207
+ private grep;
208
+ /**
209
+ * Windows grep: rg > Select-String > Node-native
210
+ */
211
+ private grepWindows;
212
+ /**
213
+ * Unix grep: rg > system grep (BSD/GNU)
214
+ */
215
+ private grepUnix;
216
+ /**
217
+ * Search using ripgrep (rg) — works on all platforms
218
+ */
219
+ private grepWithRg;
220
+ /**
221
+ * Search using PowerShell Select-String (Windows)
222
+ */
223
+ private grepWithSelectString;
224
+ /**
225
+ * Pure Node.js recursive file search — reliable on all platforms, no external deps
226
+ */
227
+ private grepNodeNative;
228
+ private listDir;
229
+ private glob;
230
+ private git;
231
+ /**
232
+ * Vigthoria Repository management tool
233
+ * Allows AI to push, pull, list, share, and manage projects in the Vigthoria Repository
234
+ */
235
+ private repo;
236
+ /**
237
+ * Fetch URL content - Cross-platform web fetching
238
+ * Uses Node.js native fetch (available in Node 18+)
239
+ */
240
+ private fetchUrl;
241
+ private browserTool;
242
+ /**
243
+ * Execute command via SSH on remote server
244
+ * Useful for running Unix commands from Windows
245
+ */
246
+ private sshExec;
247
+ /**
248
+ * Resolve and SANITIZE path - prevent path traversal outside workspace
249
+ * SECURITY: All paths MUST stay within the workspace (cwd)
250
+ */
251
+ private resolvePath;
252
+ /**
253
+ * Check if a path is within the allowed workspace
254
+ */
255
+ private isPathWithinWorkspace;
256
+ private task;
257
+ private multiEdit;
258
+ private codebaseSearch;
259
+ /**
260
+ * Parse tool calls from AI response (Vigthoria Agent format)
261
+ * Enhanced to handle various AI output formats including malformed JSON
262
+ */
263
+ static parseToolCalls(text: string): ToolCall[];
264
+ /**
265
+ * Get tools formatted for AI system prompt
266
+ */
267
+ static getToolsForPrompt(): string;
268
+ }
269
+ export {};