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
@@ -7,13 +7,14 @@
7
7
  */
8
8
  import chalk from 'chalk';
9
9
  import { Config } from '../utils/config.js';
10
- import { Logger } from '../utils/logger.js';
10
+ import { AuthSessionService } from '../utils/auth-session.js';
11
+ import { CliCommandError, commandFailure, formatSuccessJson } from '../utils/command-contract.js';
11
12
  export class WalletCommand {
12
13
  config;
13
- logger;
14
+ authSession;
14
15
  constructor() {
15
16
  this.config = new Config();
16
- this.logger = new Logger();
17
+ this.authSession = new AuthSessionService(this.config);
17
18
  }
18
19
  register(program) {
19
20
  const wallet = program
@@ -44,36 +45,7 @@ export class WalletCommand {
44
45
  return String(this.config.get('apiUrl') || 'https://coder.vigthoria.io').replace(/\/$/, '');
45
46
  }
46
47
  getToken() {
47
- return this.config.get('authToken') || null;
48
- }
49
- getRefreshToken() {
50
- return this.config.get('refreshToken') || null;
51
- }
52
- async refreshAccessToken() {
53
- const refreshToken = this.getRefreshToken();
54
- if (!refreshToken)
55
- return false;
56
- try {
57
- const response = await fetch(`${this.getBaseUrl()}/api/token/refresh`, {
58
- method: 'POST',
59
- headers: { 'Content-Type': 'application/json' },
60
- body: JSON.stringify({ refresh_token: refreshToken }),
61
- });
62
- if (!response.ok)
63
- return false;
64
- const payload = await response.json();
65
- const nextToken = payload.token || payload.access_token;
66
- if (!nextToken)
67
- return false;
68
- this.config.set('authToken', nextToken);
69
- if (payload.refresh_token) {
70
- this.config.set('refreshToken', payload.refresh_token);
71
- }
72
- return true;
73
- }
74
- catch {
75
- return false;
76
- }
48
+ return this.authSession.getAccessToken();
77
49
  }
78
50
  async parseResponseBody(resp) {
79
51
  const raw = await resp.text();
@@ -96,10 +68,10 @@ export class WalletCommand {
96
68
  });
97
69
  let token = this.getToken();
98
70
  if (!token)
99
- throw new Error('Not authenticated. Run: vigthoria login');
71
+ throw new CliCommandError('Not authenticated. Run: vigthoria login', { code: 'AUTH_REQUIRED', category: 'authentication' });
100
72
  let resp = await runRequest(token);
101
73
  if (resp.status === 401 || resp.status === 403) {
102
- const refreshed = await this.refreshAccessToken();
74
+ const refreshed = await this.authSession.refresh();
103
75
  if (refreshed) {
104
76
  token = this.getToken();
105
77
  if (token) {
@@ -112,7 +84,11 @@ export class WalletCommand {
112
84
  const err = body.error
113
85
  || body.message
114
86
  || `HTTP ${resp.status}`;
115
- throw new Error(err);
87
+ throw new CliCommandError(err, {
88
+ code: resp.status === 401 ? 'AUTH_SESSION_INVALID' : 'WALLET_REQUEST_FAILED',
89
+ category: resp.status === 401 ? 'authentication' : resp.status === 403 ? 'authorization' : undefined,
90
+ status: resp.status,
91
+ });
116
92
  }
117
93
  return body;
118
94
  }
@@ -120,7 +96,7 @@ export class WalletCommand {
120
96
  try {
121
97
  const data = await this.apiFetch('/api/user/vigcoin/balance');
122
98
  if (opts.json) {
123
- console.log(JSON.stringify(data, null, 2));
99
+ console.log(formatSuccessJson('wallet balance', data));
124
100
  return;
125
101
  }
126
102
  console.log('');
@@ -142,8 +118,7 @@ export class WalletCommand {
142
118
  console.log('');
143
119
  }
144
120
  catch (err) {
145
- this.logger.error(err.message);
146
- process.exit(1);
121
+ throw commandFailure(err, { code: 'WALLET_BALANCE_FAILED' });
147
122
  }
148
123
  }
149
124
  async showHistory(opts = {}) {
@@ -151,7 +126,7 @@ export class WalletCommand {
151
126
  try {
152
127
  const data = await this.apiFetch(`/api/user/vigcoin/transactions?limit=${limit}`);
153
128
  if (opts.json) {
154
- console.log(JSON.stringify(data, null, 2));
129
+ console.log(formatSuccessJson('wallet history', data));
155
130
  return;
156
131
  }
157
132
  const txs = data.transactions || [];
@@ -172,15 +147,14 @@ export class WalletCommand {
172
147
  console.log('');
173
148
  }
174
149
  catch (err) {
175
- this.logger.error(err.message);
176
- process.exit(1);
150
+ throw commandFailure(err, { code: 'WALLET_HISTORY_FAILED' });
177
151
  }
178
152
  }
179
153
  async showCloudStatus(opts = {}) {
180
154
  try {
181
155
  const data = await this.apiFetch('/api/user/cloud-access/status');
182
156
  if (opts.json) {
183
- console.log(JSON.stringify(data, null, 2));
157
+ console.log(formatSuccessJson('wallet cloud-status', data));
184
158
  return;
185
159
  }
186
160
  console.log('');
@@ -213,8 +187,7 @@ export class WalletCommand {
213
187
  console.log('');
214
188
  }
215
189
  catch (err) {
216
- this.logger.error(err.message);
217
- process.exit(1);
190
+ throw commandFailure(err, { code: 'WALLET_CLOUD_STATUS_FAILED' });
218
191
  }
219
192
  }
220
193
  }
@@ -1,3 +1,4 @@
1
+ import type { Command } from 'commander';
1
2
  import { Config } from '../utils/config.js';
2
3
  import { Logger } from '../utils/logger.js';
3
4
  interface WorkflowOutputOptions {
@@ -35,4 +36,5 @@ export declare class WorkflowCommand {
35
36
  run(workflowId: string, options: WorkflowRunOptions): Promise<void>;
36
37
  status(executionId: string, options: WorkflowStatusOptions): Promise<void>;
37
38
  }
39
+ export declare function registerWorkflowCommands(program: Command, config: Config, logger: Logger): void;
38
40
  export {};
@@ -1,6 +1,7 @@
1
1
  import chalk from 'chalk';
2
- import { APIClient, } from '../utils/api.js';
2
+ import { createAPIClient } from '../utils/api-client-factory.js';
3
3
  import { ProjectMemoryService } from '../utils/project-memory.js';
4
+ import { CliCommandError, commandFailure, formatSuccessJson } from '../utils/command-contract.js';
4
5
  export class WorkflowCommand {
5
6
  config;
6
7
  logger;
@@ -8,20 +9,16 @@ export class WorkflowCommand {
8
9
  constructor(config, logger) {
9
10
  this.config = config;
10
11
  this.logger = logger;
11
- this.api = new APIClient(config, logger);
12
+ this.api = createAPIClient(config, logger);
12
13
  }
13
- ensureAuthenticated(json = false) {
14
+ ensureAuthenticated() {
14
15
  if (this.config.isAuthenticated()) {
15
16
  return;
16
17
  }
17
- const message = 'Not authenticated. Run vigthoria login first.';
18
- if (json) {
19
- console.log(JSON.stringify({ success: false, error: message }, null, 2));
20
- }
21
- else {
22
- this.logger.error(message);
23
- }
24
- throw new Error(message);
18
+ throw new CliCommandError('Not authenticated. Run vigthoria login first.', {
19
+ code: 'AUTH_REQUIRED',
20
+ category: 'authentication',
21
+ });
25
22
  }
26
23
  parseJsonOption(rawValue, fieldName) {
27
24
  if (!rawValue) {
@@ -30,16 +27,18 @@ export class WorkflowCommand {
30
27
  try {
31
28
  const parsed = JSON.parse(rawValue);
32
29
  if (!parsed || Array.isArray(parsed) || typeof parsed !== 'object') {
33
- throw new Error(`${fieldName} must be a JSON object.`);
30
+ throw new CliCommandError(`${fieldName} must be a JSON object.`, { code: 'INVALID_JSON_OPTION', category: 'usage' });
34
31
  }
35
32
  return parsed;
36
33
  }
37
34
  catch (error) {
38
- throw new Error(`Invalid ${fieldName} JSON: ${error.message}`);
35
+ if (error instanceof CliCommandError)
36
+ throw error;
37
+ throw new CliCommandError(`Invalid ${fieldName} JSON: ${error.message}`, { code: 'INVALID_JSON_OPTION', category: 'usage', cause: error });
39
38
  }
40
39
  }
41
- printJson(payload) {
42
- console.log(JSON.stringify(payload, null, 2));
40
+ printJson(command, payload) {
41
+ console.log(formatSuccessJson(command, payload));
43
42
  }
44
43
  createProjectMemory() {
45
44
  return new ProjectMemoryService(process.cwd());
@@ -70,7 +69,7 @@ export class WorkflowCommand {
70
69
  }
71
70
  }
72
71
  async templates(options) {
73
- this.ensureAuthenticated(Boolean(options.json));
72
+ this.ensureAuthenticated();
74
73
  let templates;
75
74
  try {
76
75
  templates = await this.api.listVigFlowTemplates({
@@ -83,16 +82,10 @@ export class WorkflowCommand {
83
82
  const msg = /not available|not reachable|not deployed/i.test(raw)
84
83
  ? raw
85
84
  : `Workflow service is not reachable: ${raw}`;
86
- if (options.json) {
87
- this.printJson({ success: false, error: msg, templates: [] });
88
- }
89
- else {
90
- this.logger.error(msg);
91
- }
92
- return;
85
+ throw commandFailure(error, { code: 'WORKFLOW_TEMPLATES_FAILED', message: msg });
93
86
  }
94
87
  if (options.json) {
95
- this.printJson({ success: true, templates });
88
+ this.printJson('workflow templates', { templates });
96
89
  return;
97
90
  }
98
91
  this.logger.section('Workflow Templates');
@@ -108,7 +101,7 @@ export class WorkflowCommand {
108
101
  ]));
109
102
  }
110
103
  async list(options) {
111
- this.ensureAuthenticated(Boolean(options.json));
104
+ this.ensureAuthenticated();
112
105
  let workflows;
113
106
  try {
114
107
  workflows = await this.api.listVigFlowWorkflows();
@@ -118,16 +111,10 @@ export class WorkflowCommand {
118
111
  const msg = /not available|not reachable|not deployed/i.test(raw)
119
112
  ? raw
120
113
  : `Workflow service is not reachable: ${raw}`;
121
- if (options.json) {
122
- this.printJson({ success: false, error: msg, workflows: [] });
123
- }
124
- else {
125
- this.logger.error(msg);
126
- }
127
- return;
114
+ throw commandFailure(error, { code: 'WORKFLOW_LIST_FAILED', message: msg });
128
115
  }
129
116
  if (options.json) {
130
- this.printJson({ success: true, workflows });
117
+ this.printJson('workflow list', { workflows });
131
118
  return;
132
119
  }
133
120
  this.logger.section('Workflows');
@@ -144,14 +131,14 @@ export class WorkflowCommand {
144
131
  ]));
145
132
  }
146
133
  async useTemplate(templateId, options) {
147
- this.ensureAuthenticated(Boolean(options.json));
134
+ this.ensureAuthenticated();
148
135
  const variables = this.parseJsonOption(options.variables, 'variables');
149
136
  const workflow = await this.api.useVigFlowTemplate(templateId, {
150
137
  name: options.name,
151
138
  variables,
152
139
  });
153
140
  if (options.json) {
154
- this.printJson({ success: true, workflow });
141
+ this.printJson('workflow use-template', { workflow });
155
142
  return;
156
143
  }
157
144
  this.logger.success(`Created workflow ${workflow.name}`);
@@ -161,7 +148,7 @@ export class WorkflowCommand {
161
148
  }
162
149
  }
163
150
  async run(workflowId, options) {
164
- this.ensureAuthenticated(Boolean(options.json));
151
+ this.ensureAuthenticated();
165
152
  const data = this.parseJsonOption(options.data, 'data');
166
153
  const executionData = { ...data };
167
154
  if (options.brain !== false) {
@@ -174,7 +161,7 @@ export class WorkflowCommand {
174
161
  const execution = await this.api.runVigFlowWorkflow(workflowId, { data: executionData });
175
162
  this.rememberWorkflowEvent(execution.error ? 'issue' : 'validation', `VigFlow workflow ${workflowId} execution ${execution.executionId || 'unknown'} finished with status ${execution.status}; nodes executed ${execution.nodesExecuted ?? 0}${execution.error ? `; error: ${execution.error}` : ''}.`);
176
163
  if (options.json) {
177
- this.printJson({ success: true, execution });
164
+ this.printJson('workflow run', { execution });
178
165
  return;
179
166
  }
180
167
  this.logger.success(`Workflow execution ${execution.status}`);
@@ -185,13 +172,13 @@ export class WorkflowCommand {
185
172
  }
186
173
  }
187
174
  async status(executionId, options) {
188
- this.ensureAuthenticated(Boolean(options.json));
175
+ this.ensureAuthenticated();
189
176
  const execution = await this.api.getVigFlowExecutionStatus(executionId);
190
177
  if (options.brain !== false) {
191
178
  this.rememberWorkflowEvent(execution.status === 'failed' ? 'issue' : 'validation', `VigFlow execution ${execution.id} for workflow ${execution.workflowId} status ${execution.status}; nodes ${execution.nodesExecuted ?? 0}/${execution.totalNodes ?? '-'}.`);
192
179
  }
193
180
  if (options.json) {
194
- this.printJson({ success: true, execution });
181
+ this.printJson('workflow status', { execution });
195
182
  return;
196
183
  }
197
184
  this.logger.box([
@@ -204,3 +191,29 @@ export class WorkflowCommand {
204
191
  ].join('\n'), 'Workflow Status');
205
192
  }
206
193
  }
194
+ export function registerWorkflowCommands(program, config, logger) {
195
+ const workflowCommand = program.command('workflow').alias('flow')
196
+ .description('List, instantiate, and run repeatable VigFlow workflows');
197
+ workflowCommand.command('templates').alias('catalog').description('List available VigFlow templates')
198
+ .option('-c, --category <category>', 'Filter templates by category')
199
+ .option('-s, --search <query>', 'Search template names, descriptions, and tags')
200
+ .option('--json', 'Emit machine-readable JSON output', false)
201
+ .action(async (options) => new WorkflowCommand(config, logger).templates(options));
202
+ workflowCommand.command('list').alias('ls').description('List workflows created for the current account')
203
+ .option('--json', 'Emit machine-readable JSON output', false)
204
+ .action(async (options) => new WorkflowCommand(config, logger).list(options));
205
+ workflowCommand.command('use-template <templateId>').description('Create a workflow from a built-in or saved template')
206
+ .option('-n, --name <name>', 'Override the workflow name').option('-v, --variables <json>', 'Template variables as a JSON object')
207
+ .option('--json', 'Emit machine-readable JSON output', false)
208
+ .action(async (templateId, options) => new WorkflowCommand(config, logger).useTemplate(templateId, options));
209
+ workflowCommand.command('run <workflowId>').description('Run a workflow immediately')
210
+ .option('-d, --data <json>', 'Execution input data as a JSON object')
211
+ .option('--no-brain', 'Do not attach local Project Brain context to this workflow run')
212
+ .option('--json', 'Emit machine-readable JSON output', false)
213
+ .action(async (workflowId, options) => new WorkflowCommand(config, logger).run(workflowId, options));
214
+ workflowCommand.command('status <executionId>').description('Get the current or final status of a workflow execution')
215
+ .option('--no-brain', 'Do not remember this workflow status in local Project Brain')
216
+ .option('--json', 'Emit machine-readable JSON output', false)
217
+ .action(async (executionId, options) => new WorkflowCommand(config, logger).status(executionId, options));
218
+ workflowCommand.action(async () => new WorkflowCommand(config, logger).templates({}));
219
+ }