vigthoria-cli 1.13.18 → 1.13.22

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 (185) hide show
  1. package/completions/_vigthoria +49 -0
  2. package/completions/vigthoria.bash +6 -0
  3. package/completions/vigthoria.fish +41 -0
  4. package/dist/commands/auth.d.ts +1 -0
  5. package/dist/commands/auth.js +84 -135
  6. package/dist/commands/background.d.ts +0 -2
  7. package/dist/commands/background.js +26 -34
  8. package/dist/commands/bridge.js +45 -41
  9. package/dist/commands/cancel.d.ts +1 -0
  10. package/dist/commands/cancel.js +22 -16
  11. package/dist/commands/chat.d.ts +5 -42
  12. package/dist/commands/chat.js +462 -1122
  13. package/dist/commands/coding-registration.d.ts +4 -0
  14. package/dist/commands/coding-registration.js +24 -0
  15. package/dist/commands/config.js +32 -42
  16. package/dist/commands/conversation-registration.d.ts +4 -0
  17. package/dist/commands/conversation-registration.js +122 -0
  18. package/dist/commands/deploy.d.ts +8 -2
  19. package/dist/commands/deploy.js +92 -90
  20. package/dist/commands/device.d.ts +1 -2
  21. package/dist/commands/device.js +37 -21
  22. package/dist/commands/doctor-registration.d.ts +4 -0
  23. package/dist/commands/doctor-registration.js +200 -0
  24. package/dist/commands/edit.js +22 -33
  25. package/dist/commands/explain.js +7 -10
  26. package/dist/commands/fork.d.ts +1 -2
  27. package/dist/commands/fork.js +72 -22
  28. package/dist/commands/game.d.ts +1 -1
  29. package/dist/commands/game.js +17 -6
  30. package/dist/commands/generate.js +7 -9
  31. package/dist/commands/history.js +11 -7
  32. package/dist/commands/hub.d.ts +2 -2
  33. package/dist/commands/hub.js +34 -35
  34. package/dist/commands/legion.d.ts +0 -1
  35. package/dist/commands/legion.js +62 -79
  36. package/dist/commands/music.d.ts +1 -2
  37. package/dist/commands/music.js +62 -27
  38. package/dist/commands/platform-registration.d.ts +4 -0
  39. package/dist/commands/platform-registration.js +45 -0
  40. package/dist/commands/preview.d.ts +0 -1
  41. package/dist/commands/preview.js +82 -35
  42. package/dist/commands/product-run-registration.d.ts +4 -0
  43. package/dist/commands/product-run-registration.js +490 -0
  44. package/dist/commands/replay.d.ts +1 -2
  45. package/dist/commands/replay.js +15 -11
  46. package/dist/commands/repo.d.ts +14 -7
  47. package/dist/commands/repo.js +245 -196
  48. package/dist/commands/review.js +9 -12
  49. package/dist/commands/security.d.ts +1 -2
  50. package/dist/commands/security.js +12 -6
  51. package/dist/commands/update-registration.d.ts +3 -0
  52. package/dist/commands/update-registration.js +338 -0
  53. package/dist/commands/v4-registration.d.ts +4 -0
  54. package/dist/commands/v4-registration.js +24 -0
  55. package/dist/commands/v4.d.ts +1 -1
  56. package/dist/commands/v4.js +46 -8
  57. package/dist/commands/wallet.d.ts +1 -3
  58. package/dist/commands/wallet.js +18 -45
  59. package/dist/commands/workflow.d.ts +2 -0
  60. package/dist/commands/workflow.js +52 -39
  61. package/dist/index.js +122 -1498
  62. package/dist/utils/agent-stream-state.d.ts +27 -0
  63. package/dist/utils/agent-stream-state.js +93 -0
  64. package/dist/utils/agentRoute.d.ts +2 -1
  65. package/dist/utils/agentRoute.js +22 -9
  66. package/dist/utils/agentRunOutcome.d.ts +16 -0
  67. package/dist/utils/agentRunOutcome.js +37 -2
  68. package/dist/utils/api-client-factory.d.ts +8 -0
  69. package/dist/utils/api-client-factory.js +8 -0
  70. package/dist/utils/api.d.ts +45 -269
  71. package/dist/utils/api.js +664 -3210
  72. package/dist/utils/auth-session.d.ts +41 -0
  73. package/dist/utils/auth-session.js +224 -0
  74. package/dist/utils/brain-hub-client.d.ts +0 -4
  75. package/dist/utils/brain-hub-client.js +6 -3
  76. package/dist/utils/bridge-client.js +2 -0
  77. package/dist/utils/capability-health-service.d.ts +48 -0
  78. package/dist/utils/capability-health-service.js +64 -0
  79. package/dist/utils/chat-prompt-policy.d.ts +18 -0
  80. package/dist/utils/chat-prompt-policy.js +61 -0
  81. package/dist/utils/chat-tool-call-parser.d.ts +11 -0
  82. package/dist/utils/chat-tool-call-parser.js +71 -0
  83. package/dist/utils/cli-state.d.ts +22 -4
  84. package/dist/utils/cli-state.js +105 -47
  85. package/dist/utils/code-operations-service.d.ts +104 -0
  86. package/dist/utils/code-operations-service.js +837 -0
  87. package/dist/utils/codebase-indexer.d.ts +1 -0
  88. package/dist/utils/codebase-indexer.js +28 -8
  89. package/dist/utils/command-contract.d.ts +61 -0
  90. package/dist/utils/command-contract.js +149 -0
  91. package/dist/utils/command-policy.d.ts +10 -0
  92. package/dist/utils/command-policy.js +54 -0
  93. package/dist/utils/config.d.ts +13 -5
  94. package/dist/utils/config.js +227 -99
  95. package/dist/utils/context-ranker.js +11 -2
  96. package/dist/utils/context-state.d.ts +39 -0
  97. package/dist/utils/context-state.js +52 -0
  98. package/dist/utils/deckEvents.d.ts +0 -5
  99. package/dist/utils/deckEvents.js +3 -2
  100. package/dist/utils/desktop-bridge-client.js +2 -0
  101. package/dist/utils/direct-output-policy.d.ts +3 -0
  102. package/dist/utils/direct-output-policy.js +76 -0
  103. package/dist/utils/durable-json.d.ts +57 -0
  104. package/dist/utils/durable-json.js +319 -0
  105. package/dist/utils/fastAgentRouter.d.ts +6 -7
  106. package/dist/utils/fastAgentRouter.js +21 -30
  107. package/dist/utils/files.js +21 -13
  108. package/dist/utils/frontend-preview-service.d.ts +76 -0
  109. package/dist/utils/frontend-preview-service.js +482 -0
  110. package/dist/utils/goaEvents.d.ts +0 -4
  111. package/dist/utils/goaEvents.js +5 -2
  112. package/dist/utils/logger.d.ts +2 -1
  113. package/dist/utils/logger.js +27 -20
  114. package/dist/utils/mcp-context-client.d.ts +24 -0
  115. package/dist/utils/mcp-context-client.js +58 -0
  116. package/dist/utils/model-governance.d.ts +18 -0
  117. package/dist/utils/model-governance.js +75 -0
  118. package/dist/utils/model-transport-service.d.ts +44 -0
  119. package/dist/utils/model-transport-service.js +111 -0
  120. package/dist/utils/mutation-journal.d.ts +42 -0
  121. package/dist/utils/mutation-journal.js +387 -0
  122. package/dist/utils/network-policy.d.ts +24 -0
  123. package/dist/utils/network-policy.js +202 -0
  124. package/dist/utils/operator-client.d.ts +45 -0
  125. package/dist/utils/operator-client.js +159 -0
  126. package/dist/utils/post-write-validator.js +7 -9
  127. package/dist/utils/preview-screenshot-adapter.d.ts +13 -0
  128. package/dist/utils/preview-screenshot-adapter.js +36 -0
  129. package/dist/utils/process-policy.d.ts +23 -0
  130. package/dist/utils/process-policy.js +284 -0
  131. package/dist/utils/project-memory.d.ts +13 -3
  132. package/dist/utils/project-memory.js +70 -17
  133. package/dist/utils/prompt-workspace-resolver.d.ts +14 -0
  134. package/dist/utils/prompt-workspace-resolver.js +64 -0
  135. package/dist/utils/release-install.d.ts +11 -0
  136. package/dist/utils/release-install.js +155 -0
  137. package/dist/utils/release-policy.d.ts +64 -0
  138. package/dist/utils/release-policy.js +293 -0
  139. package/dist/utils/requestIntent.js +22 -3
  140. package/dist/utils/runtime-capability.d.ts +8 -0
  141. package/dist/utils/runtime-capability.js +16 -0
  142. package/dist/utils/secret-policy.d.ts +20 -0
  143. package/dist/utils/secret-policy.js +160 -0
  144. package/dist/utils/session.d.ts +34 -2
  145. package/dist/utils/session.js +354 -110
  146. package/dist/utils/tool-approval-service.d.ts +17 -0
  147. package/dist/utils/tool-approval-service.js +78 -0
  148. package/dist/utils/tool-capability-providers.d.ts +57 -0
  149. package/dist/utils/tool-capability-providers.js +57 -0
  150. package/dist/utils/tools.d.ts +2 -23
  151. package/dist/utils/tools.js +216 -508
  152. package/dist/utils/update-policy.d.ts +18 -0
  153. package/dist/utils/update-policy.js +137 -0
  154. package/dist/utils/v3-agent-client.d.ts +40 -0
  155. package/dist/utils/v3-agent-client.js +165 -0
  156. package/dist/utils/v3-workspace-service.d.ts +28 -0
  157. package/dist/utils/v3-workspace-service.js +279 -0
  158. package/dist/utils/vigflow-client.d.ts +95 -0
  159. package/dist/utils/vigflow-client.js +105 -0
  160. package/dist/utils/workspace-boundary.d.ts +45 -0
  161. package/dist/utils/workspace-boundary.js +377 -0
  162. package/dist/utils/workspace-brain-service.d.ts +2 -0
  163. package/dist/utils/workspace-brain-service.js +11 -1
  164. package/dist/utils/workspace-cache.js +37 -15
  165. package/dist/utils/workspace-stream.js +35 -10
  166. package/install.ps1 +86 -143
  167. package/install.sh +76 -81
  168. package/package.json +44 -9
  169. package/release-policy.json +43 -0
  170. package/scripts/release/LOCAL_MACHINE_USER_VERIFICATION.md +1 -1
  171. package/scripts/release/generate-completions.mjs +24 -0
  172. package/scripts/release/install-release.mjs +10 -0
  173. package/scripts/release/publish-cli-release.mjs +116 -0
  174. package/scripts/release/publish-cli-release.sh +2 -70
  175. package/scripts/release/resolve-release-manifest.mjs +26 -0
  176. package/scripts/release/test-balanced-model-live.sh +42 -0
  177. package/scripts/release/validate-live-service-gates.sh +90 -0
  178. package/scripts/release/validate-no-go-gates.sh +135 -172
  179. package/scripts/release/verify-runtime-consistency.mjs +4 -1
  180. package/dist/commands/index.d.ts +0 -12
  181. package/dist/commands/index.js +0 -194
  182. package/dist/commands/update.d.ts +0 -9
  183. package/dist/commands/update.js +0 -301
  184. package/dist/utils/templateInstantPath.d.ts +0 -18
  185. package/dist/utils/templateInstantPath.js +0 -228
@@ -0,0 +1,490 @@
1
+ import { HubCommand } from './hub.js';
2
+ import { MusicCommand } from './music.js';
3
+ import { RepoCommand } from './repo.js';
4
+ import { DeployCommand } from './deploy.js';
5
+ import { PreviewCommand } from './preview.js';
6
+ import { GameCommand } from './game.js';
7
+ import { LegionCommand } from './legion.js';
8
+ import { HistoryCommand } from './history.js';
9
+ import { ReplayCommand } from './replay.js';
10
+ import { ForkCommand } from './fork.js';
11
+ import { CancelCommand } from './cancel.js';
12
+ import { BackgroundCommand } from './background.js';
13
+ import { CliCommandError } from '../utils/command-contract.js';
14
+ export function registerProductAndRunCommands(program, config, logger) {
15
+ // ==================== HUB / MARKETPLACE COMMANDS ====================
16
+ // Hub command - Discover and activate API modules
17
+ const hubCommand = program
18
+ .command('hub')
19
+ .alias('marketplace')
20
+ .description('Discover, search, and activate Vigthoria API modules');
21
+ hubCommand
22
+ .command('discover')
23
+ .alias('d')
24
+ .description('Interactive module discovery - find the right APIs for your project')
25
+ .action(async () => {
26
+ const hub = new HubCommand(config, logger);
27
+ await hub.discover();
28
+ });
29
+ hubCommand
30
+ .command('list')
31
+ .alias('ls')
32
+ .description('List all available API modules')
33
+ .option('-c, --category <category>', 'Filter by category (payments, communication, ai, creative, media)')
34
+ .action(async (options) => {
35
+ const hub = new HubCommand(config, logger);
36
+ await hub.list(options);
37
+ });
38
+ hubCommand
39
+ .command('search <query>')
40
+ .alias('find')
41
+ .description('Semantic search for modules (e.g., "generate background music for my app")')
42
+ .action(async (query) => {
43
+ const hub = new HubCommand(config, logger);
44
+ await hub.search(query);
45
+ });
46
+ hubCommand
47
+ .command('activate <module>')
48
+ .alias('enable')
49
+ .description('Activate a module for your API key (enables pay-as-you-go)')
50
+ .action(async (module) => {
51
+ const hub = new HubCommand(config, logger);
52
+ await hub.activate(module);
53
+ });
54
+ hubCommand
55
+ .command('active')
56
+ .description('Show your currently active modules')
57
+ .action(async () => {
58
+ const hub = new HubCommand(config, logger);
59
+ await hub.active();
60
+ });
61
+ hubCommand
62
+ .command('info <module>')
63
+ .alias('details')
64
+ .description('Get detailed information about a module')
65
+ .action(async (module) => {
66
+ const hub = new HubCommand(config, logger);
67
+ await hub.info(module);
68
+ });
69
+ // Default hub action shows discover
70
+ hubCommand.action(async () => {
71
+ const hub = new HubCommand(config, logger);
72
+ await hub.discover();
73
+ });
74
+ const musicCommand = program
75
+ .command('music')
76
+ .alias('audio')
77
+ .description('Generate songs with Vigthoria Music AI / ACE-Step');
78
+ musicCommand
79
+ .command('generate [prompt]')
80
+ .alias('g')
81
+ .description('Queue full-song generation and return a task id')
82
+ .option('--lyrics <text>', 'Provide fixed lyrics instead of auto-writing lyrics')
83
+ .option('--duration <seconds>', 'Song duration in seconds', '120')
84
+ .option('--genre <genre>', 'Music genre', 'pop')
85
+ .option('--language <code>', 'Vocal language', 'en')
86
+ .option('--voice-type <type>', 'Voice type (female, male, mixed)', 'female')
87
+ .option('--style-tags <tags>', 'Additional style tags')
88
+ .option('--voice <path>', 'Upload a local voice reference for cloning')
89
+ .option('--wait', 'Poll until the task reaches a terminal state', false)
90
+ .option('--poll-interval <seconds>', 'Polling interval when --wait is used', '5')
91
+ .option('--json', 'Emit machine-readable JSON output', false)
92
+ .action(async (prompt, options) => {
93
+ const music = new MusicCommand(config, logger);
94
+ await music.generate(prompt, options);
95
+ });
96
+ musicCommand
97
+ .command('status <taskId>')
98
+ .description('Check a queued music generation task')
99
+ .option('--json', 'Emit machine-readable JSON output', false)
100
+ .action(async (taskId, options) => {
101
+ const music = new MusicCommand(config, logger);
102
+ await music.status(taskId, options);
103
+ });
104
+ // ==================== REPO COMMANDS ====================
105
+ // Repo command - Push/Pull projects to/from Vigthoria Community Repository
106
+ const repoCommand = program
107
+ .command('repo')
108
+ .alias('repository')
109
+ .description('Push and pull projects to/from your Vigthoria Community Repository');
110
+ repoCommand
111
+ .command('push [path]')
112
+ .alias('upload')
113
+ .description('Push current or specified project to Vigthoria Community Repository')
114
+ .option('-n, --name <projectName>', 'Project name override for the remote repo')
115
+ .option('-v, --visibility <type>', 'Set visibility (private, restricted, public)', 'private')
116
+ .option('-d, --description <text>', 'Project description')
117
+ .option('-f, --force', 'Overwrite existing project', false)
118
+ .option('-y, --yes', 'Run non-interactively with provided/default values', false)
119
+ .option('--retry <reviewId>', 'Link this corrected push to a repository security review')
120
+ .option('--open-in <engine>', 'After push, open project in engine: shop, visual, game')
121
+ .option('--browser', 'Open result URL in default browser', false)
122
+ .action(async (pathArg, options) => {
123
+ const repo = new RepoCommand(config, logger);
124
+ await repo.push({
125
+ path: pathArg,
126
+ name: options.name,
127
+ visibility: options.visibility,
128
+ description: options.description,
129
+ force: options.force,
130
+ yes: options.yes,
131
+ retry: options.retry
132
+ });
133
+ if (options.openIn) {
134
+ const engine = options.openIn;
135
+ if (!['shop', 'visual', 'game'].includes(engine)) {
136
+ logger.warn(`Unknown engine "${engine}". Use: shop, visual, game`);
137
+ }
138
+ else {
139
+ await repo.openIn(engine, options.name || undefined, { browser: options.browser });
140
+ }
141
+ }
142
+ });
143
+ repoCommand
144
+ .command('review [reviewId]')
145
+ .description('Show repository security review status, findings, and retry guidance')
146
+ .option('--json', 'Emit machine-readable JSON output', false)
147
+ .action(async (reviewId, options) => {
148
+ const repo = new RepoCommand(config, logger);
149
+ await repo.review(reviewId, { json: options.json });
150
+ });
151
+ repoCommand
152
+ .command('pull <name>')
153
+ .alias('download')
154
+ .description('Pull a project from your Vigthoria Community Repository')
155
+ .option('-o, --output <path>', 'Output directory path')
156
+ .option('-f, --force', 'Overwrite existing directory', false)
157
+ .action(async (name, options) => {
158
+ const repo = new RepoCommand(config, logger);
159
+ await repo.pull(name, {
160
+ output: options.output,
161
+ force: options.force
162
+ });
163
+ });
164
+ repoCommand
165
+ .command('list')
166
+ .alias('ls')
167
+ .description('List all your projects in Vigthoria Community Repository')
168
+ .option('-v, --visibility <type>', 'Filter by visibility (private, restricted, public)')
169
+ .action(async (options) => {
170
+ const repo = new RepoCommand(config, logger);
171
+ await repo.list({ visibility: options.visibility });
172
+ });
173
+ repoCommand
174
+ .command('status')
175
+ .description('Show sync status of current project')
176
+ .action(async () => {
177
+ const repo = new RepoCommand(config, logger);
178
+ await repo.status();
179
+ });
180
+ repoCommand
181
+ .command('share <name>')
182
+ .description('Generate a shareable link for a project')
183
+ .option('-e, --expires <duration>', 'Link expiration (e.g., 7d, 24h, 30m)', '7d')
184
+ .action(async (name, options) => {
185
+ const repo = new RepoCommand(config, logger);
186
+ await repo.share(name, { expires: options.expires });
187
+ });
188
+ repoCommand
189
+ .command('delete <name>')
190
+ .alias('rm')
191
+ .description('Remove a project from your Vigthoria Community Repository')
192
+ .option('-y, --yes', 'Skip the interactive confirmation', false)
193
+ .action(async (name, options) => {
194
+ const repo = new RepoCommand(config, logger);
195
+ await repo.delete(name, { yes: options.yes });
196
+ });
197
+ repoCommand
198
+ .command('clone <url>')
199
+ .description('Clone a public project from Vigthoria Community')
200
+ .option('-o, --output <path>', 'Output directory path')
201
+ .option('-f, --force', 'Overwrite existing directory', false)
202
+ .action(async (url, options) => {
203
+ const repo = new RepoCommand(config, logger);
204
+ await repo.clone(url, {
205
+ output: options.output,
206
+ force: options.force
207
+ });
208
+ });
209
+ repoCommand
210
+ .command('open-in <engine> [projectName]')
211
+ .description('Open a Vigthoria Community Repository project in the Shop Engine, Visual Editor, or Gaming Engine')
212
+ .option('--browser', 'Open result URL in default browser', false)
213
+ .option('--shop-id <id>', 'Target shop ID (for shop engine)', 'default')
214
+ .addHelpText('after', `
215
+ Examples:
216
+ vigthoria repo open-in shop my-store
217
+ vigthoria repo open-in visual my-website
218
+ vigthoria repo open-in game my-game --browser`)
219
+ .action(async (engine, projectName, options) => {
220
+ if (!['shop', 'visual', 'game'].includes(engine)) {
221
+ throw new CliCommandError(`Unknown engine "${engine}". Valid options: shop, visual, game`, {
222
+ code: 'REPOSITORY_ENGINE_INVALID', category: 'usage',
223
+ });
224
+ }
225
+ const repo = new RepoCommand(config, logger);
226
+ await repo.openIn(engine, projectName, {
227
+ browser: options.browser,
228
+ shopId: options.shopId
229
+ });
230
+ });
231
+ // Default repo action shows help with available subcommands
232
+ repoCommand.action(() => {
233
+ repoCommand.outputHelp();
234
+ });
235
+ // ==================== BACKGROUND AGENT JOBS ====================
236
+ const backgroundCommand = program
237
+ .command('background')
238
+ .alias('bg')
239
+ .description('Run and manage detached Vigthoria Agent jobs');
240
+ backgroundCommand
241
+ .command('start <prompt...>')
242
+ .description('Start an Agent job in the background and return immediately')
243
+ .option('--workspace <path>', 'Local workspace path', process.cwd())
244
+ .option('--model <model>', 'Execution lane: agent, cloud, cloud-reason, or ultra', 'agent')
245
+ .option('--json', 'Emit JSON output', false)
246
+ .action(async (prompt, options) => {
247
+ const bg = new BackgroundCommand(config, logger);
248
+ await bg.start(prompt, options);
249
+ });
250
+ backgroundCommand
251
+ .command('list')
252
+ .alias('ls')
253
+ .description('List recent background jobs')
254
+ .option('--limit <n>', 'Maximum jobs to show', '20')
255
+ .option('--json', 'Emit JSON output', false)
256
+ .action(async (options) => {
257
+ const bg = new BackgroundCommand(config, logger);
258
+ await bg.list({ ...options, limit: Number(options.limit) || 20 });
259
+ });
260
+ backgroundCommand
261
+ .command('status <jobId>')
262
+ .description('Show background job status')
263
+ .option('--json', 'Emit JSON output', false)
264
+ .action(async (jobId, options) => {
265
+ const bg = new BackgroundCommand(config, logger);
266
+ await bg.status(jobId, options);
267
+ });
268
+ backgroundCommand
269
+ .command('apply <jobId>')
270
+ .description('Apply completed background job file changes to the local workspace')
271
+ .option('--workspace <path>', 'Local workspace path', process.cwd())
272
+ .option('--json', 'Emit JSON output', false)
273
+ .action(async (jobId, options) => {
274
+ const bg = new BackgroundCommand(config, logger);
275
+ await bg.apply(jobId, options);
276
+ });
277
+ backgroundCommand
278
+ .command('cancel <jobId>')
279
+ .description('Cancel a running background job')
280
+ .option('--json', 'Emit JSON output', false)
281
+ .action(async (jobId, options) => {
282
+ const bg = new BackgroundCommand(config, logger);
283
+ await bg.cancel(jobId, options);
284
+ });
285
+ backgroundCommand
286
+ .command('approve <jobId> <approvalId>')
287
+ .description('Resolve a pending two-stage command gate for a background job')
288
+ .option('--deny', 'Deny the command instead of approving it', false)
289
+ .option('--json', 'Emit JSON output', false)
290
+ .action(async (jobId, approvalId, options) => {
291
+ const bg = new BackgroundCommand(config, logger);
292
+ await bg.approve(jobId, approvalId, options);
293
+ });
294
+ backgroundCommand.action(() => {
295
+ backgroundCommand.outputHelp();
296
+ });
297
+ // ==================== DEPLOY COMMANDS ====================
298
+ // Deploy command - Host projects on Vigthoria
299
+ const deployCommand = program
300
+ .command('deploy')
301
+ .alias('host')
302
+ .description('Deploy and host your project on Vigthoria infrastructure');
303
+ deployCommand
304
+ .command('preview')
305
+ .description('Deploy to free preview URL')
306
+ .option('-p, --project <path>', 'Project directory path', process.cwd())
307
+ .action(async (options) => {
308
+ const deploy = new DeployCommand(config, logger);
309
+ await deploy.deployToPreview(options.project);
310
+ });
311
+ deployCommand
312
+ .command('subdomain <name>')
313
+ .description('Deploy to yourname.vigthoria.io')
314
+ .option('-p, --project <path>', 'Project directory path', process.cwd())
315
+ .action(async (name, options) => {
316
+ const deploy = new DeployCommand(config, logger);
317
+ await deploy.deployToSubdomain(name, options.project);
318
+ });
319
+ deployCommand
320
+ .command('custom <domain>')
321
+ .description('Deploy to your custom domain')
322
+ .option('-p, --project <path>', 'Project directory path', process.cwd())
323
+ .action(async (domain, options) => {
324
+ const deploy = new DeployCommand(config, logger);
325
+ await deploy.deployToCustomDomain(domain, options.project);
326
+ });
327
+ deployCommand
328
+ .command('list')
329
+ .alias('ls')
330
+ .description('List all your deployments')
331
+ .action(async () => {
332
+ const deploy = new DeployCommand(config, logger);
333
+ await deploy.list();
334
+ });
335
+ deployCommand
336
+ .command('plans')
337
+ .description('Show hosting plans and pricing')
338
+ .action(async () => {
339
+ const deploy = new DeployCommand(config, logger);
340
+ await deploy.showPlans();
341
+ });
342
+ deployCommand
343
+ .command('status [domain]')
344
+ .description('Check deployment status')
345
+ .action(async (domain) => {
346
+ const deploy = new DeployCommand(config, logger);
347
+ await deploy.status(domain);
348
+ });
349
+ deployCommand
350
+ .command('verify <domain>')
351
+ .description('Verify DNS configuration for custom domain')
352
+ .action(async (domain) => {
353
+ const deploy = new DeployCommand(config, logger);
354
+ await deploy.verify(domain);
355
+ });
356
+ deployCommand
357
+ .command('remove <domain>')
358
+ .alias('rm')
359
+ .description('Remove a deployment')
360
+ .action(async (domain) => {
361
+ const deploy = new DeployCommand(config, logger);
362
+ await deploy.remove(domain);
363
+ });
364
+ // Default deploy action shows interactive wizard
365
+ deployCommand
366
+ .option('-s, --subdomain <name>', 'Deploy to subdomain')
367
+ .option('-d, --domain <domain>', 'Deploy to custom domain')
368
+ .option('-p, --project <path>', 'Project directory path', process.cwd())
369
+ .action(async (options) => {
370
+ const deploy = new DeployCommand(config, logger);
371
+ await deploy.deploy({
372
+ subdomain: options.subdomain,
373
+ domain: options.domain,
374
+ project: options.project
375
+ });
376
+ });
377
+ // ==================== PREVIEW COMMAND ====================
378
+ program
379
+ .command('preview')
380
+ .description('Preview project locally with visual diffs and proof validation')
381
+ .option('-p, --project <path>', 'Project directory path', process.cwd())
382
+ .option('-e, --entry <file>', 'Entry HTML file (auto-detected if omitted)')
383
+ .option('--port <number>', 'Local server port', parseInt)
384
+ .option('--no-open', 'Do not auto-open browser')
385
+ .option('--diff', 'Show consolidated diff of recent agent changes')
386
+ .option('--proof', 'Run Template Service preview gate and persist proof bundle')
387
+ .option('--screenshot', 'Capture screenshot via Puppeteer')
388
+ .action(async (options) => {
389
+ const preview = new PreviewCommand(config, logger);
390
+ await preview.run({
391
+ project: options.project,
392
+ entry: options.entry,
393
+ port: options.port,
394
+ open: options.open,
395
+ diff: options.diff,
396
+ proof: options.proof,
397
+ screenshot: options.screenshot,
398
+ });
399
+ });
400
+ // ==================== GAME COMMAND ====================
401
+ const gameCommand = program.command('game').description('Create, run, and validate Babylon/VGE game projects');
402
+ gameCommand.command('init [name]').description('Create a production-ready client-rendered Babylon/VGE game').option('--engine <engine>', 'Game engine', 'babylon').option('--no-install', 'Create files without installing dependencies').option('--package-manager <manager>', 'npm, pnpm, yarn, or bun').action(async (name, options) => { await new GameCommand(logger).init(name, options); });
403
+ gameCommand.command('run').description('Run the local game development server').option('-p, --project <path>', 'Game project directory', process.cwd()).option('--port <number>', 'Development server port', parseInt).option('--no-open', 'Do not open a browser').option('--package-manager <manager>', 'npm, pnpm, yarn, or bun').action(async (options) => { await new GameCommand(logger).run(options); });
404
+ gameCommand.command('validate').description('Build and validate a Babylon/VGE game project').option('-p, --project <path>', 'Game project directory', process.cwd()).option('--json', 'Print machine-readable validation results').option('--package-manager <manager>', 'npm, pnpm, yarn, or bun').action(async (options) => { await new GameCommand(logger).validate(options); });
405
+ gameCommand.action(() => gameCommand.outputHelp());
406
+ // ==================== LEGION COMMAND ====================
407
+ program
408
+ .command('legion [request]')
409
+ .description('Run parallel tasks via Hyper Loop Legion orchestrator')
410
+ .option('--workers', 'List available Legion workers')
411
+ .option('--status', 'Show Legion infrastructure status')
412
+ .option('--cortex', 'Vigthoria Cortex: maximum intelligence execution')
413
+ .option('--approve', 'Auto-approve Cortex execution prompt')
414
+ .option('--no-approve', 'Require interactive approval before execution')
415
+ .option('--auto-charge', 'Compatibility flag; low balances still require a verified User Hub top-up')
416
+ .option('--plan-only', 'Run Cortex estimator only; do not execute Legion job')
417
+ .option('--force-budget', 'Allow execution when estimated budget exceeds the hard safe-stop ceiling')
418
+ .option('--ignore-preflight', 'Bypass mandatory local preflight checks (no warranty)')
419
+ .option('--speed', 'Enable speed mode (allows optional role skips when convergence is detected)')
420
+ .option('--repro-cmd <command>', 'Local reproduction/preflight command to validate before cloud spend')
421
+ .option('--expect-repro-fail', 'Require repro command to fail (non-zero) before proceeding')
422
+ .option('--models <csv>', 'Comma-separated model IDs to constrain Cortex selection')
423
+ .option('-t, --timeout <seconds>', 'Override Legion execution timeout in seconds (defaults to server policy)')
424
+ .option('-w, --worker <name>', 'Execute a specific worker')
425
+ .option('-p, --project <path>', 'Project directory', process.cwd())
426
+ .action(async (request, options) => {
427
+ const legion = new LegionCommand(config, logger);
428
+ const parsedTimeout = Number.parseInt(String(options.timeout || ''), 10);
429
+ await legion.run(request, {
430
+ workers: options.workers,
431
+ status: options.status,
432
+ cortex: Boolean(options.cortex),
433
+ approve: options.approve,
434
+ noApprove: options.approve === false,
435
+ autoCharge: options.autoCharge,
436
+ planOnly: options.planOnly,
437
+ forceBudget: options.forceBudget,
438
+ ignorePreflight: options.ignorePreflight,
439
+ speed: options.speed,
440
+ reproCmd: options.reproCmd,
441
+ expectReproFail: options.expectReproFail,
442
+ models: options.models,
443
+ timeoutSec: Number.isFinite(parsedTimeout) && parsedTimeout > 0 ? parsedTimeout : undefined,
444
+ worker: options.worker,
445
+ project: options.project,
446
+ });
447
+ });
448
+ // ==================== REPLAY & FORK COMMANDS ====================
449
+ program
450
+ .command('history')
451
+ .alias('runs')
452
+ .description('List recent V3 agent runs')
453
+ .option('-n, --limit <count>', 'Number of runs to show', '20')
454
+ .option('-p, --project <path>', 'Project directory', process.cwd())
455
+ .option('--json', 'Machine-readable JSON output', false)
456
+ .action(async (options) => {
457
+ const history = new HistoryCommand(config, logger);
458
+ await history.run({ limit: parseInt(options.limit, 10) || 20, json: options.json, project: options.project });
459
+ });
460
+ program
461
+ .command('replay <runId>')
462
+ .description('Replay events from a V3 agent run step-by-step')
463
+ .option('-s, --speed <ms>', 'Delay between events in ms', '200')
464
+ .option('-p, --project <path>', 'Project directory', process.cwd())
465
+ .option('--json', 'Machine-readable JSON output', false)
466
+ .action(async (runId, options) => {
467
+ const replay = new ReplayCommand(config, logger);
468
+ await replay.run(runId, { speed: parseInt(options.speed, 10) || 200, json: options.json, project: options.project });
469
+ });
470
+ program
471
+ .command('fork <runId> [message]')
472
+ .description('Fork from an existing V3 agent run with new instructions')
473
+ .option('-e, --event-index <index>', 'Fork from specific event index', '0')
474
+ .option('-p, --project <path>', 'Project directory', process.cwd())
475
+ .option('--json', 'Machine-readable JSON output', false)
476
+ .action(async (runId, message, options) => {
477
+ const fork = new ForkCommand(config, logger);
478
+ await fork.run(runId, message || '', { eventIndex: parseInt(options.eventIndex, 10) || 0, project: options.project, json: options.json });
479
+ });
480
+ program
481
+ .command('cancel [contextId]')
482
+ .description('Cancel an in-flight V3 agent run (by context_id), or use --all to cancel every active run')
483
+ .option('-a, --all', 'Cancel all currently-active runs', false)
484
+ .option('-l, --list', 'List active runs without cancelling', false)
485
+ .option('--json', 'Machine-readable JSON output', false)
486
+ .action(async (contextId, options) => {
487
+ const cancel = new CancelCommand(config, logger);
488
+ await cancel.run(contextId, { all: options.all, list: options.list, json: options.json });
489
+ });
490
+ }
@@ -7,8 +7,7 @@ interface ReplayOptions {
7
7
  }
8
8
  export declare class ReplayCommand {
9
9
  private config;
10
- private logger;
11
- constructor(config: Config, logger: Logger);
10
+ constructor(config: Config, _logger: Logger);
12
11
  private getHeaders;
13
12
  private getBaseUrl;
14
13
  private resolveWorkspaceRoot;
@@ -1,17 +1,16 @@
1
- import { isServerRuntime } from '../utils/api.js';
1
+ import { hasLocalV3AgentCapability } from '../utils/runtime-capability.js';
2
2
  /**
3
3
  * replay.ts — Replay events from a V3 agent run step-by-step.
4
4
  */
5
5
  import chalk from 'chalk';
6
6
  import { createRequire } from 'node:module';
7
7
  import { createSpinner, CH } from '../utils/logger.js';
8
+ import { CliCommandError, commandFailure, formatSuccessJson } from '../utils/command-contract.js';
8
9
  const require = createRequire(import.meta.url);
9
10
  export class ReplayCommand {
10
11
  config;
11
- logger;
12
- constructor(config, logger) {
12
+ constructor(config, _logger) {
13
13
  this.config = config;
14
- this.logger = logger;
15
14
  }
16
15
  getHeaders() {
17
16
  const headers = { 'Content-Type': 'application/json' };
@@ -29,7 +28,7 @@ export class ReplayCommand {
29
28
  }
30
29
  getBaseUrl() {
31
30
  const configuredApiUrl = String(this.config.get('apiUrl') || 'https://coder.vigthoria.io').replace(/\/$/, '');
32
- const allowLocal = isServerRuntime() && process.env.VIGTHORIA_ALLOW_LOCAL_V3_AGENT === '1';
31
+ const allowLocal = hasLocalV3AgentCapability();
33
32
  return (process.env.VIGTHORIA_V3_AGENT_URL ||
34
33
  process.env.V3_AGENT_URL ||
35
34
  (allowLocal ? 'http://127.0.0.1:8030' : null) ||
@@ -65,20 +64,25 @@ export class ReplayCommand {
65
64
  if (!resp.ok) {
66
65
  spinner.stop();
67
66
  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.`);
67
+ throw new CliCommandError(`No event log found for run ${runId}. Events are only recorded for runs made after the replay system was deployed.`, {
68
+ code: 'RUN_EVENTS_NOT_FOUND', status: resp.status,
69
+ });
69
70
  }
70
71
  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
+ throw new CliCommandError(`V3 run-history route is not available on ${baseUrl}. Backend may not expose /api/runs.`, {
73
+ code: 'RUN_HISTORY_UNAVAILABLE', status: resp.status, category: 'network',
74
+ });
72
75
  }
73
76
  else {
74
- this.logger.error(`Failed to fetch events: ${resp.status} ${resp.statusText}`);
77
+ throw new CliCommandError(`Failed to fetch events: ${resp.status} ${resp.statusText}`, {
78
+ code: 'RUN_REPLAY_FAILED', status: resp.status,
79
+ });
75
80
  }
76
- return;
77
81
  }
78
82
  const data = (await resp.json());
79
83
  spinner.stop();
80
84
  if (options.json) {
81
- console.log(JSON.stringify(data, null, 2));
85
+ console.log(formatSuccessJson('replay', data));
82
86
  return;
83
87
  }
84
88
  console.log(chalk.bold(`\n${CH.success} Replaying run ${chalk.cyan(runId)} (${data.count} events)\n`));
@@ -150,7 +154,7 @@ export class ReplayCommand {
150
154
  }
151
155
  catch (err) {
152
156
  spinner.stop();
153
- this.logger.error(`Replay error: ${err.message}`);
157
+ throw commandFailure(err, { code: 'RUN_REPLAY_FAILED' });
154
158
  }
155
159
  }
156
160
  }
@@ -34,14 +34,22 @@ interface ListOptions {
34
34
  interface ShareOptions {
35
35
  expires?: string;
36
36
  }
37
+ export declare class RepositoryMutationAmbiguousError extends Error {
38
+ readonly operationId: string;
39
+ readonly mutationOutcome = "unknown";
40
+ readonly partialMutation = "unknown";
41
+ constructor(operationId: string, cause?: unknown);
42
+ }
43
+ export declare function canFallbackRepositoryRequest(method: string, status?: number): boolean;
37
44
  export declare class RepoCommand {
38
45
  private config;
39
- private logger;
40
46
  private apiBase;
41
47
  private communityBase;
42
48
  private communityToken;
43
- constructor(config: Config, logger: Logger);
49
+ constructor(config: Config, _logger: Logger);
44
50
  private getAuthHeaders;
51
+ private getRepositoryAudienceForUrl;
52
+ private getAuthHeadersForUrl;
45
53
  private ensureCommunityAuth;
46
54
  private repoFetch;
47
55
  private collectProjectFiles;
@@ -55,10 +63,6 @@ export declare class RepoCommand {
55
63
  * Detect project info from package.json, requirements.txt, etc.
56
64
  */
57
65
  private detectProjectInfo;
58
- /**
59
- * Create a zip archive of a project
60
- */
61
- private createProjectArchive;
62
66
  /**
63
67
  * Push a project to Vigthoria Repository
64
68
  */
@@ -69,6 +73,7 @@ export declare class RepoCommand {
69
73
  review(reviewId?: string, options?: {
70
74
  json?: boolean;
71
75
  }): Promise<void>;
76
+ private materializeProject;
72
77
  /**
73
78
  * Pull a project from Vigthoria Repository
74
79
  */
@@ -88,7 +93,9 @@ export declare class RepoCommand {
88
93
  /**
89
94
  * Delete a project from Vigthoria Repository
90
95
  */
91
- delete(projectName: string): Promise<void>;
96
+ delete(projectName: string, options?: {
97
+ yes?: boolean;
98
+ }): Promise<void>;
92
99
  /**
93
100
  * Open a project in a Vigthoria engine (shop, visual, game).
94
101
  * Pushes to community if not yet there, then triggers engine import.