@llm-dev-ops/agentics-cli 1.3.8 → 1.3.9
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/adapters/base-adapter.d.ts +58 -1
- package/dist/adapters/base-adapter.d.ts.map +1 -1
- package/dist/adapters/base-adapter.js +110 -0
- package/dist/adapters/base-adapter.js.map +1 -1
- package/dist/cli/index.js +992 -16
- package/dist/cli/index.js.map +1 -1
- package/dist/commands/deploy.d.ts +95 -13
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deploy.js +420 -14
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/erp.d.ts +302 -0
- package/dist/commands/erp.d.ts.map +1 -0
- package/dist/commands/erp.js +1064 -0
- package/dist/commands/erp.js.map +1 -0
- package/dist/commands/export.d.ts +40 -13
- package/dist/commands/export.d.ts.map +1 -1
- package/dist/commands/export.js +434 -14
- package/dist/commands/export.js.map +1 -1
- package/dist/commands/index.d.ts +20 -12
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +10 -6
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/inspect.d.ts +84 -18
- package/dist/commands/inspect.d.ts.map +1 -1
- package/dist/commands/inspect.js +585 -131
- package/dist/commands/inspect.js.map +1 -1
- package/dist/commands/logout.d.ts +34 -0
- package/dist/commands/logout.d.ts.map +1 -0
- package/dist/commands/logout.js +73 -0
- package/dist/commands/logout.js.map +1 -0
- package/dist/commands/plan.d.ts +147 -14
- package/dist/commands/plan.d.ts.map +1 -1
- package/dist/commands/plan.js +555 -16
- package/dist/commands/plan.js.map +1 -1
- package/dist/commands/policy.d.ts +136 -0
- package/dist/commands/policy.d.ts.map +1 -0
- package/dist/commands/policy.js +460 -0
- package/dist/commands/policy.js.map +1 -0
- package/dist/commands/quantify.d.ts +131 -13
- package/dist/commands/quantify.d.ts.map +1 -1
- package/dist/commands/quantify.js +425 -14
- package/dist/commands/quantify.js.map +1 -1
- package/dist/commands/simulate.d.ts +119 -13
- package/dist/commands/simulate.d.ts.map +1 -1
- package/dist/commands/simulate.js +363 -14
- package/dist/commands/simulate.js.map +1 -1
- package/dist/commands/usage.d.ts +110 -0
- package/dist/commands/usage.d.ts.map +1 -0
- package/dist/commands/usage.js +507 -0
- package/dist/commands/usage.js.map +1 -0
- package/dist/commands/whoami.d.ts +33 -0
- package/dist/commands/whoami.d.ts.map +1 -0
- package/dist/commands/whoami.js +93 -0
- package/dist/commands/whoami.js.map +1 -0
- package/dist/config/endpoints.d.ts.map +1 -1
- package/dist/config/endpoints.js +15 -0
- package/dist/config/endpoints.js.map +1 -1
- package/dist/modules/command-parser.d.ts +1 -1
- package/dist/modules/command-parser.d.ts.map +1 -1
- package/dist/modules/command-parser.js +6 -1
- package/dist/modules/command-parser.js.map +1 -1
- package/dist/modules/output-renderer.d.ts +1 -0
- package/dist/modules/output-renderer.d.ts.map +1 -1
- package/dist/modules/output-renderer.js +25 -1
- package/dist/modules/output-renderer.js.map +1 -1
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/package.json +4 -4
package/dist/cli/index.js
CHANGED
|
@@ -18,13 +18,18 @@ import { LocalhostInProductionError } from '../config/endpoints.js';
|
|
|
18
18
|
import { EXIT_CODES, parseFlexibleInput, isNaturalLanguage } from '../types/index.js';
|
|
19
19
|
// Import command executors
|
|
20
20
|
import { executeLoginCommand } from '../commands/login.js';
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
21
|
+
import { executeWhoamiCommand, formatWhoamiForDisplay } from '../commands/whoami.js';
|
|
22
|
+
import { executeLogoutCommand, formatLogoutForDisplay } from '../commands/logout.js';
|
|
23
|
+
import { executePlanCommand, executePlanListCommand, executePlanCreateCommand, executePlanInspectCommand, executePlanDeleteCommand, executePlanApproveCommand, formatPlansListForDisplay, formatPlanForDisplay, } from '../commands/plan.js';
|
|
24
|
+
import { executeSimulateCommand, executeSimulateListCommand, executeSimulateCreateCommand, executeSimulateInspectCommand, executeSimulateDeleteCommand, executeSimulateRunCommand, formatSimulationsListForDisplay, formatSimulationForDisplay, } from '../commands/simulate.js';
|
|
25
|
+
import { executeInspectCommand, executeInspectLatestCommand, executeInspectRunCommand, formatResultsForDisplay, } from '../commands/inspect.js';
|
|
26
|
+
import { executeQuantifyCommand, executeQuantifyCreateCommand, executeQuantifyListCommand, executeQuantifyInspectCommand, executeQuantifyDeleteCommand, executeQuantifyCompareCommand, formatQuantifyForDisplay, formatQuantifyListForDisplay, formatCompareForDisplay, } from '../commands/quantify.js';
|
|
27
|
+
import { executeDeployCommand, executeDeployPreviewCommand, executeDeployRunCommand, executeDeployStatusCommand, executeDeployRollbackCommand, executeDeployListCommand, formatDeployForDisplay, formatDeployListForDisplay, } from '../commands/deploy.js';
|
|
28
|
+
import { executeExportCommand, executeExportTerraformCommand, executeExportKubernetesCommand, executeExportErpCommand, formatExportForDisplay, } from '../commands/export.js';
|
|
27
29
|
import { executeDiligenceCommand } from '../commands/diligence.js';
|
|
30
|
+
import { executeUsageCommand, executeUsageHistoryCommand, executeUsageLimitsCommand, executeUsageResetCommand, formatUsageForDisplay, formatHistoryForDisplay, formatLimitsForDisplay, } from '../commands/usage.js';
|
|
31
|
+
import { executePolicyListCommand, executePolicyInspectCommand, executePolicyCreateCommand, executePolicyEditCommand, executePolicyDeleteCommand, executePolicyEnableCommand, executePolicyDisableCommand, formatPolicyForDisplay, formatPoliciesListForDisplay, } from '../commands/policy.js';
|
|
32
|
+
import { executeErpListCommand, executeErpInspectCommand, executeErpSurfaceCommand, executeErpMapCommand, executeErpExportCommand, formatErpListForDisplay, formatErpInspectForDisplay, formatErpSurfaceForDisplay, formatErpMapForDisplay, formatErpExportForDisplay, } from '../commands/erp.js';
|
|
28
33
|
// ============================================================================
|
|
29
34
|
// CLI Version
|
|
30
35
|
// ============================================================================
|
|
@@ -85,14 +90,262 @@ async function main() {
|
|
|
85
90
|
}
|
|
86
91
|
break;
|
|
87
92
|
}
|
|
88
|
-
case '
|
|
93
|
+
case 'whoami': {
|
|
94
|
+
const whoamiResult = await executeWhoamiCommand();
|
|
95
|
+
if (options.format === 'json') {
|
|
96
|
+
console.log(JSON.stringify(whoamiResult, null, parsed.flags['pretty'] ? 2 : 0));
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
console.log(formatWhoamiForDisplay(whoamiResult));
|
|
100
|
+
}
|
|
101
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
case 'logout': {
|
|
105
|
+
const logoutResult = await executeLogoutCommand();
|
|
106
|
+
if (options.format === 'json') {
|
|
107
|
+
console.log(JSON.stringify(logoutResult, null, parsed.flags['pretty'] ? 2 : 0));
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
console.log(formatLogoutForDisplay(logoutResult));
|
|
111
|
+
}
|
|
112
|
+
process.exit(logoutResult.success ? EXIT_CODES.SUCCESS : EXIT_CODES.GENERAL_ERROR);
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
case 'plan': {
|
|
116
|
+
// Handle subcommands: list, create, inspect, delete, approve
|
|
117
|
+
if (parsed.subcommand === 'list') {
|
|
118
|
+
const planListResult = await executePlanListCommand({
|
|
119
|
+
status: parsed.options['status'],
|
|
120
|
+
limit: parsed.options['limit'] ? parseInt(parsed.options['limit'], 10) : undefined,
|
|
121
|
+
}, options);
|
|
122
|
+
if (options.format === 'json') {
|
|
123
|
+
console.log(JSON.stringify({
|
|
124
|
+
plans: planListResult.plans,
|
|
125
|
+
count: planListResult.count,
|
|
126
|
+
timing: planListResult.timing,
|
|
127
|
+
}, null, parsed.flags['pretty'] ? 2 : 0));
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
console.log(formatPlansListForDisplay(planListResult.plans));
|
|
131
|
+
}
|
|
132
|
+
if (options.verbose) {
|
|
133
|
+
console.error(`Query completed in ${planListResult.timing}ms`);
|
|
134
|
+
}
|
|
135
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
136
|
+
}
|
|
137
|
+
if (parsed.subcommand === 'create') {
|
|
138
|
+
const planName = parsed.options['name'] ?? parsed.positionalArgs[0] ?? '';
|
|
139
|
+
const planCreateResult = await executePlanCreateCommand({
|
|
140
|
+
name: planName,
|
|
141
|
+
description: parsed.options['description'],
|
|
142
|
+
manifest_query: parsed.options['manifest-query'],
|
|
143
|
+
metadata: parsed.options['metadata'] ? JSON.parse(parsed.options['metadata']) : undefined,
|
|
144
|
+
}, options);
|
|
145
|
+
if (options.format === 'json') {
|
|
146
|
+
console.log(JSON.stringify({
|
|
147
|
+
plan: planCreateResult.plan,
|
|
148
|
+
timing: planCreateResult.timing,
|
|
149
|
+
}, null, parsed.flags['pretty'] ? 2 : 0));
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
console.log(`Plan created: ${planCreateResult.plan.id}`);
|
|
153
|
+
console.log(formatPlanForDisplay(planCreateResult.plan));
|
|
154
|
+
}
|
|
155
|
+
if (options.verbose) {
|
|
156
|
+
console.error(`Created in ${planCreateResult.timing}ms`);
|
|
157
|
+
}
|
|
158
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
159
|
+
}
|
|
160
|
+
if (parsed.subcommand === 'inspect') {
|
|
161
|
+
const planId = parsed.positionalArgs[0] ?? '';
|
|
162
|
+
const planInspectResult = await executePlanInspectCommand({ id: planId }, options);
|
|
163
|
+
if (options.format === 'json') {
|
|
164
|
+
console.log(JSON.stringify({
|
|
165
|
+
plan: planInspectResult.plan,
|
|
166
|
+
found: planInspectResult.found,
|
|
167
|
+
timing: planInspectResult.timing,
|
|
168
|
+
}, null, parsed.flags['pretty'] ? 2 : 0));
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
if (planInspectResult.found && planInspectResult.plan) {
|
|
172
|
+
console.log(formatPlanForDisplay(planInspectResult.plan));
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
console.log(`Plan not found: ${planId}`);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
if (options.verbose) {
|
|
179
|
+
console.error(`Query completed in ${planInspectResult.timing}ms`);
|
|
180
|
+
}
|
|
181
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
182
|
+
}
|
|
183
|
+
if (parsed.subcommand === 'delete') {
|
|
184
|
+
const planId = parsed.positionalArgs[0] ?? '';
|
|
185
|
+
const planDeleteResult = await executePlanDeleteCommand({ id: planId }, options);
|
|
186
|
+
if (options.format === 'json') {
|
|
187
|
+
console.log(JSON.stringify({
|
|
188
|
+
deleted: planDeleteResult.deleted,
|
|
189
|
+
id: planDeleteResult.id,
|
|
190
|
+
timing: planDeleteResult.timing,
|
|
191
|
+
}, null, parsed.flags['pretty'] ? 2 : 0));
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
console.log(`Plan deleted: ${planDeleteResult.id}`);
|
|
195
|
+
}
|
|
196
|
+
if (options.verbose) {
|
|
197
|
+
console.error(`Deleted in ${planDeleteResult.timing}ms`);
|
|
198
|
+
}
|
|
199
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
200
|
+
}
|
|
201
|
+
if (parsed.subcommand === 'approve') {
|
|
202
|
+
const planId = parsed.positionalArgs[0] ?? '';
|
|
203
|
+
const planApproveResult = await executePlanApproveCommand({
|
|
204
|
+
id: planId,
|
|
205
|
+
approved_by: parsed.options['approved-by'],
|
|
206
|
+
}, options);
|
|
207
|
+
if (options.format === 'json') {
|
|
208
|
+
console.log(JSON.stringify({
|
|
209
|
+
plan: planApproveResult.plan,
|
|
210
|
+
previous_status: planApproveResult.previous_status,
|
|
211
|
+
advisory: planApproveResult.advisory,
|
|
212
|
+
timing: planApproveResult.timing,
|
|
213
|
+
}, null, parsed.flags['pretty'] ? 2 : 0));
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
console.log(`Plan approved (advisory): ${planApproveResult.plan.id}`);
|
|
217
|
+
console.log(` Previous status: ${planApproveResult.previous_status}`);
|
|
218
|
+
console.log(` New status: ${planApproveResult.plan.status}`);
|
|
219
|
+
console.log(` Approved by: ${planApproveResult.plan.approved_by ?? 'cli-user'}`);
|
|
220
|
+
if (planApproveResult.advisory) {
|
|
221
|
+
console.log(' Note: This was an advisory approval (no real execution performed)');
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
if (options.verbose) {
|
|
225
|
+
console.error(`Approved in ${planApproveResult.timing}ms`);
|
|
226
|
+
}
|
|
227
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
228
|
+
}
|
|
229
|
+
// Default plan behavior (create plan via orchestration)
|
|
89
230
|
result = await executePlanCommand({
|
|
90
|
-
manifestQuery: parsed.positionalArgs[0] ?? '',
|
|
231
|
+
manifestQuery: parsed.subcommand ?? parsed.positionalArgs[0] ?? '',
|
|
91
232
|
params: parsed.options['params'] ? JSON.parse(parsed.options['params']) : undefined,
|
|
92
233
|
}, options);
|
|
93
234
|
break;
|
|
235
|
+
}
|
|
94
236
|
case 'simulate': {
|
|
95
|
-
|
|
237
|
+
// Handle subcommands: list, create, inspect, delete, run
|
|
238
|
+
if (parsed.subcommand === 'list') {
|
|
239
|
+
const simListResult = await executeSimulateListCommand({
|
|
240
|
+
status: parsed.options['status'],
|
|
241
|
+
limit: parsed.options['limit'] ? parseInt(parsed.options['limit'], 10) : undefined,
|
|
242
|
+
}, options);
|
|
243
|
+
if (options.format === 'json') {
|
|
244
|
+
console.log(JSON.stringify({
|
|
245
|
+
simulations: simListResult.simulations,
|
|
246
|
+
count: simListResult.count,
|
|
247
|
+
timing: simListResult.timing,
|
|
248
|
+
}, null, parsed.flags['pretty'] ? 2 : 0));
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
console.log(formatSimulationsListForDisplay(simListResult.simulations));
|
|
252
|
+
}
|
|
253
|
+
if (options.verbose) {
|
|
254
|
+
console.error(`Query completed in ${simListResult.timing}ms`);
|
|
255
|
+
}
|
|
256
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
257
|
+
}
|
|
258
|
+
if (parsed.subcommand === 'create') {
|
|
259
|
+
const simName = parsed.options['name'] ?? parsed.positionalArgs[0] ?? '';
|
|
260
|
+
const simCreateResult = await executeSimulateCreateCommand({
|
|
261
|
+
name: simName,
|
|
262
|
+
description: parsed.options['description'],
|
|
263
|
+
plan_id: parsed.options['plan-id'],
|
|
264
|
+
iterations: parsed.options['iterations'] ? parseInt(parsed.options['iterations'], 10) : undefined,
|
|
265
|
+
metadata: parsed.options['metadata'] ? JSON.parse(parsed.options['metadata']) : undefined,
|
|
266
|
+
}, options);
|
|
267
|
+
if (options.format === 'json') {
|
|
268
|
+
console.log(JSON.stringify({
|
|
269
|
+
simulation: simCreateResult.simulation,
|
|
270
|
+
timing: simCreateResult.timing,
|
|
271
|
+
}, null, parsed.flags['pretty'] ? 2 : 0));
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
console.log(`Simulation created: ${simCreateResult.simulation.id}`);
|
|
275
|
+
console.log(formatSimulationForDisplay(simCreateResult.simulation));
|
|
276
|
+
}
|
|
277
|
+
if (options.verbose) {
|
|
278
|
+
console.error(`Created in ${simCreateResult.timing}ms`);
|
|
279
|
+
}
|
|
280
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
281
|
+
}
|
|
282
|
+
if (parsed.subcommand === 'inspect') {
|
|
283
|
+
const simId = parsed.positionalArgs[0] ?? '';
|
|
284
|
+
const simInspectResult = await executeSimulateInspectCommand({ id: simId }, options);
|
|
285
|
+
if (options.format === 'json') {
|
|
286
|
+
console.log(JSON.stringify({
|
|
287
|
+
simulation: simInspectResult.simulation,
|
|
288
|
+
found: simInspectResult.found,
|
|
289
|
+
timing: simInspectResult.timing,
|
|
290
|
+
}, null, parsed.flags['pretty'] ? 2 : 0));
|
|
291
|
+
}
|
|
292
|
+
else {
|
|
293
|
+
if (simInspectResult.found && simInspectResult.simulation) {
|
|
294
|
+
console.log(formatSimulationForDisplay(simInspectResult.simulation));
|
|
295
|
+
}
|
|
296
|
+
else {
|
|
297
|
+
console.log(`Simulation not found: ${simId}`);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
if (options.verbose) {
|
|
301
|
+
console.error(`Query completed in ${simInspectResult.timing}ms`);
|
|
302
|
+
}
|
|
303
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
304
|
+
}
|
|
305
|
+
if (parsed.subcommand === 'delete') {
|
|
306
|
+
const simId = parsed.positionalArgs[0] ?? '';
|
|
307
|
+
const simDeleteResult = await executeSimulateDeleteCommand({ id: simId }, options);
|
|
308
|
+
if (options.format === 'json') {
|
|
309
|
+
console.log(JSON.stringify({
|
|
310
|
+
deleted: simDeleteResult.deleted,
|
|
311
|
+
id: simDeleteResult.id,
|
|
312
|
+
timing: simDeleteResult.timing,
|
|
313
|
+
}, null, parsed.flags['pretty'] ? 2 : 0));
|
|
314
|
+
}
|
|
315
|
+
else {
|
|
316
|
+
console.log(`Simulation deleted: ${simDeleteResult.id}`);
|
|
317
|
+
}
|
|
318
|
+
if (options.verbose) {
|
|
319
|
+
console.error(`Deleted in ${simDeleteResult.timing}ms`);
|
|
320
|
+
}
|
|
321
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
322
|
+
}
|
|
323
|
+
if (parsed.subcommand === 'run') {
|
|
324
|
+
const simId = parsed.positionalArgs[0] ?? '';
|
|
325
|
+
const simRunResult = await executeSimulateRunCommand({ id: simId }, options);
|
|
326
|
+
if (options.format === 'json') {
|
|
327
|
+
console.log(JSON.stringify({
|
|
328
|
+
simulation: simRunResult.simulation,
|
|
329
|
+
previous_status: simRunResult.previous_status,
|
|
330
|
+
advisory: simRunResult.advisory,
|
|
331
|
+
timing: simRunResult.timing,
|
|
332
|
+
}, null, parsed.flags['pretty'] ? 2 : 0));
|
|
333
|
+
}
|
|
334
|
+
else {
|
|
335
|
+
console.log(`Simulation run completed (advisory): ${simRunResult.simulation.id}`);
|
|
336
|
+
console.log(` Previous status: ${simRunResult.previous_status}`);
|
|
337
|
+
console.log(` New status: ${simRunResult.simulation.status}`);
|
|
338
|
+
if (simRunResult.advisory) {
|
|
339
|
+
console.log(' Note: This was an advisory execution (no real execution performed)');
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
if (options.verbose) {
|
|
343
|
+
console.error(`Run completed in ${simRunResult.timing}ms`);
|
|
344
|
+
}
|
|
345
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
346
|
+
}
|
|
347
|
+
// Default simulate behavior (execute simulation via orchestration)
|
|
348
|
+
const simInput = parsed.subcommand ?? parsed.positionalArgs[0] ?? '';
|
|
96
349
|
const simFlexibleInput = parseFlexibleInput(simInput);
|
|
97
350
|
result = await executeSimulateCommand({
|
|
98
351
|
planRef: isNaturalLanguage(simFlexibleInput)
|
|
@@ -104,9 +357,59 @@ async function main() {
|
|
|
104
357
|
break;
|
|
105
358
|
}
|
|
106
359
|
case 'inspect': {
|
|
107
|
-
|
|
360
|
+
// Handle subcommands: latest, run <id>
|
|
361
|
+
if (parsed.subcommand === 'latest') {
|
|
362
|
+
const latestResult = await executeInspectLatestCommand({
|
|
363
|
+
environment: parsed.options['environment'],
|
|
364
|
+
status: parsed.options['status'],
|
|
365
|
+
}, options);
|
|
366
|
+
if (options.format === 'json') {
|
|
367
|
+
console.log(JSON.stringify({
|
|
368
|
+
result: latestResult.result,
|
|
369
|
+
found: latestResult.found,
|
|
370
|
+
timing: latestResult.timing,
|
|
371
|
+
}, null, parsed.flags['pretty'] ? 2 : 0));
|
|
372
|
+
}
|
|
373
|
+
else {
|
|
374
|
+
if (latestResult.found && latestResult.result) {
|
|
375
|
+
console.log(formatResultsForDisplay([latestResult.result]));
|
|
376
|
+
}
|
|
377
|
+
else {
|
|
378
|
+
console.log('No matching simulation results found.');
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
if (options.verbose) {
|
|
382
|
+
console.error(`Query completed in ${latestResult.timing}ms`);
|
|
383
|
+
}
|
|
384
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
385
|
+
}
|
|
386
|
+
if (parsed.subcommand === 'run') {
|
|
387
|
+
const runId = parsed.positionalArgs[0] ?? '';
|
|
388
|
+
const runResult = await executeInspectRunCommand({ id: runId }, options);
|
|
389
|
+
if (options.format === 'json') {
|
|
390
|
+
console.log(JSON.stringify({
|
|
391
|
+
result: runResult.result,
|
|
392
|
+
found: runResult.found,
|
|
393
|
+
timing: runResult.timing,
|
|
394
|
+
}, null, parsed.flags['pretty'] ? 2 : 0));
|
|
395
|
+
}
|
|
396
|
+
else {
|
|
397
|
+
if (runResult.found && runResult.result) {
|
|
398
|
+
console.log(formatResultsForDisplay([runResult.result]));
|
|
399
|
+
}
|
|
400
|
+
else {
|
|
401
|
+
console.log(`No simulation result found with ID: ${runId}`);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
if (options.verbose) {
|
|
405
|
+
console.error(`Query completed in ${runResult.timing}ms`);
|
|
406
|
+
}
|
|
407
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
408
|
+
}
|
|
409
|
+
// Default inspect behavior (original)
|
|
410
|
+
const inspectInput = parsed.subcommand ?? parsed.positionalArgs[0] ?? '';
|
|
108
411
|
const inspectFlexibleInput = parseFlexibleInput(inspectInput);
|
|
109
|
-
|
|
412
|
+
const inspectResult = await executeInspectCommand({
|
|
110
413
|
simRef: isNaturalLanguage(inspectFlexibleInput)
|
|
111
414
|
? inspectFlexibleInput // Pass NL input directly
|
|
112
415
|
: inspectFlexibleInput,
|
|
@@ -114,9 +417,131 @@ async function main() {
|
|
|
114
417
|
includeMetrics: parsed.flags['include-metrics'] ?? false,
|
|
115
418
|
includeTraces: parsed.flags['include-traces'] ?? false,
|
|
116
419
|
}, options);
|
|
117
|
-
|
|
420
|
+
// Render inspect output based on format
|
|
421
|
+
if (options.format === 'json') {
|
|
422
|
+
console.log(JSON.stringify({
|
|
423
|
+
results: inspectResult.results,
|
|
424
|
+
query: inspectResult.query,
|
|
425
|
+
count: inspectResult.count,
|
|
426
|
+
}, null, parsed.flags['pretty'] ? 2 : 0));
|
|
427
|
+
}
|
|
428
|
+
else {
|
|
429
|
+
// Human-readable text output for terminal
|
|
430
|
+
console.log(formatResultsForDisplay(inspectResult.results));
|
|
431
|
+
}
|
|
432
|
+
if (options.verbose) {
|
|
433
|
+
console.error(`Query completed in ${inspectResult.timing}ms`);
|
|
434
|
+
}
|
|
435
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
118
436
|
}
|
|
119
437
|
case 'quantify': {
|
|
438
|
+
// Handle subcommands: create, list, inspect, delete, compare
|
|
439
|
+
if (parsed.subcommand === 'list') {
|
|
440
|
+
const quantifyListResult = await executeQuantifyListCommand({
|
|
441
|
+
status: parsed.options['status'],
|
|
442
|
+
limit: parsed.options['limit'] ? parseInt(parsed.options['limit'], 10) : undefined,
|
|
443
|
+
}, options);
|
|
444
|
+
if (options.format === 'json') {
|
|
445
|
+
console.log(JSON.stringify({
|
|
446
|
+
reports: quantifyListResult.reports,
|
|
447
|
+
count: quantifyListResult.count,
|
|
448
|
+
timing: quantifyListResult.timing,
|
|
449
|
+
}, null, parsed.flags['pretty'] ? 2 : 0));
|
|
450
|
+
}
|
|
451
|
+
else {
|
|
452
|
+
console.log(formatQuantifyListForDisplay(quantifyListResult.reports));
|
|
453
|
+
}
|
|
454
|
+
if (options.verbose) {
|
|
455
|
+
console.error(`Query completed in ${quantifyListResult.timing}ms`);
|
|
456
|
+
}
|
|
457
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
458
|
+
}
|
|
459
|
+
if (parsed.subcommand === 'create') {
|
|
460
|
+
const quantifyName = parsed.options['name'] ?? parsed.positionalArgs[0] ?? '';
|
|
461
|
+
const quantifyCreateResult = await executeQuantifyCreateCommand({
|
|
462
|
+
name: quantifyName,
|
|
463
|
+
description: parsed.options['description'],
|
|
464
|
+
simulation_id: parsed.options['simulation-id'],
|
|
465
|
+
report_type: (parsed.options['report-type'] ?? 'cfo-grade'),
|
|
466
|
+
metadata: parsed.options['metadata'] ? JSON.parse(parsed.options['metadata']) : undefined,
|
|
467
|
+
}, options);
|
|
468
|
+
if (options.format === 'json') {
|
|
469
|
+
console.log(JSON.stringify({
|
|
470
|
+
report: quantifyCreateResult.report,
|
|
471
|
+
timing: quantifyCreateResult.timing,
|
|
472
|
+
}, null, parsed.flags['pretty'] ? 2 : 0));
|
|
473
|
+
}
|
|
474
|
+
else {
|
|
475
|
+
console.log(`ROI report created: ${quantifyCreateResult.report.id}`);
|
|
476
|
+
console.log(formatQuantifyForDisplay(quantifyCreateResult.report));
|
|
477
|
+
}
|
|
478
|
+
if (options.verbose) {
|
|
479
|
+
console.error(`Created in ${quantifyCreateResult.timing}ms`);
|
|
480
|
+
}
|
|
481
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
482
|
+
}
|
|
483
|
+
if (parsed.subcommand === 'inspect') {
|
|
484
|
+
const quantifyId = parsed.positionalArgs[0] ?? '';
|
|
485
|
+
const quantifyInspectResult = await executeQuantifyInspectCommand({ id: quantifyId }, options);
|
|
486
|
+
if (options.format === 'json') {
|
|
487
|
+
console.log(JSON.stringify({
|
|
488
|
+
report: quantifyInspectResult.report,
|
|
489
|
+
found: quantifyInspectResult.found,
|
|
490
|
+
timing: quantifyInspectResult.timing,
|
|
491
|
+
}, null, parsed.flags['pretty'] ? 2 : 0));
|
|
492
|
+
}
|
|
493
|
+
else {
|
|
494
|
+
if (quantifyInspectResult.found && quantifyInspectResult.report) {
|
|
495
|
+
console.log(formatQuantifyForDisplay(quantifyInspectResult.report));
|
|
496
|
+
}
|
|
497
|
+
else {
|
|
498
|
+
console.log(`ROI report not found: ${quantifyId}`);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
if (options.verbose) {
|
|
502
|
+
console.error(`Query completed in ${quantifyInspectResult.timing}ms`);
|
|
503
|
+
}
|
|
504
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
505
|
+
}
|
|
506
|
+
if (parsed.subcommand === 'delete') {
|
|
507
|
+
const quantifyId = parsed.positionalArgs[0] ?? '';
|
|
508
|
+
const quantifyDeleteResult = await executeQuantifyDeleteCommand({ id: quantifyId }, options);
|
|
509
|
+
if (options.format === 'json') {
|
|
510
|
+
console.log(JSON.stringify({
|
|
511
|
+
deleted: quantifyDeleteResult.deleted,
|
|
512
|
+
id: quantifyDeleteResult.id,
|
|
513
|
+
timing: quantifyDeleteResult.timing,
|
|
514
|
+
}, null, parsed.flags['pretty'] ? 2 : 0));
|
|
515
|
+
}
|
|
516
|
+
else {
|
|
517
|
+
console.log(`ROI report deleted: ${quantifyDeleteResult.id}`);
|
|
518
|
+
}
|
|
519
|
+
if (options.verbose) {
|
|
520
|
+
console.error(`Deleted in ${quantifyDeleteResult.timing}ms`);
|
|
521
|
+
}
|
|
522
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
523
|
+
}
|
|
524
|
+
if (parsed.subcommand === 'compare') {
|
|
525
|
+
const idA = parsed.positionalArgs[0] ?? '';
|
|
526
|
+
const idB = parsed.positionalArgs[1] ?? '';
|
|
527
|
+
const quantifyCompareResult = await executeQuantifyCompareCommand({ idA, idB }, options);
|
|
528
|
+
if (options.format === 'json') {
|
|
529
|
+
console.log(JSON.stringify({
|
|
530
|
+
reportA: quantifyCompareResult.reportA,
|
|
531
|
+
reportB: quantifyCompareResult.reportB,
|
|
532
|
+
comparison: quantifyCompareResult.comparison,
|
|
533
|
+
timing: quantifyCompareResult.timing,
|
|
534
|
+
}, null, parsed.flags['pretty'] ? 2 : 0));
|
|
535
|
+
}
|
|
536
|
+
else {
|
|
537
|
+
console.log(formatCompareForDisplay(quantifyCompareResult));
|
|
538
|
+
}
|
|
539
|
+
if (options.verbose) {
|
|
540
|
+
console.error(`Comparison completed in ${quantifyCompareResult.timing}ms`);
|
|
541
|
+
}
|
|
542
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
543
|
+
}
|
|
544
|
+
// Default quantify behavior (execute via orchestration)
|
|
120
545
|
const quantifyInput = parsed.positionalArgs[0] ?? '';
|
|
121
546
|
const quantifyFlexibleInput = parseFlexibleInput(quantifyInput);
|
|
122
547
|
result = await executeQuantifyCommand({
|
|
@@ -128,6 +553,113 @@ async function main() {
|
|
|
128
553
|
break;
|
|
129
554
|
}
|
|
130
555
|
case 'deploy': {
|
|
556
|
+
// Handle subcommands: preview, run, status, rollback, list
|
|
557
|
+
if (parsed.subcommand === 'list') {
|
|
558
|
+
const deployListResult = await executeDeployListCommand(options);
|
|
559
|
+
if (options.format === 'json') {
|
|
560
|
+
console.log(JSON.stringify({
|
|
561
|
+
items: deployListResult.items,
|
|
562
|
+
count: deployListResult.count,
|
|
563
|
+
timing: deployListResult.timing,
|
|
564
|
+
}, null, parsed.flags['pretty'] ? 2 : 0));
|
|
565
|
+
}
|
|
566
|
+
else {
|
|
567
|
+
console.log(formatDeployListForDisplay(deployListResult.items));
|
|
568
|
+
}
|
|
569
|
+
if (options.verbose) {
|
|
570
|
+
console.error(`Query completed in ${deployListResult.timing}ms`);
|
|
571
|
+
}
|
|
572
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
573
|
+
}
|
|
574
|
+
if (parsed.subcommand === 'preview') {
|
|
575
|
+
const targetId = parsed.positionalArgs[0] ?? '';
|
|
576
|
+
const deployPreviewResult = await executeDeployPreviewCommand({
|
|
577
|
+
target_id: targetId,
|
|
578
|
+
environment: parsed.options['environment'],
|
|
579
|
+
}, options);
|
|
580
|
+
if (options.format === 'json') {
|
|
581
|
+
console.log(JSON.stringify({
|
|
582
|
+
result: deployPreviewResult.result,
|
|
583
|
+
timing: deployPreviewResult.timing,
|
|
584
|
+
}, null, parsed.flags['pretty'] ? 2 : 0));
|
|
585
|
+
}
|
|
586
|
+
else {
|
|
587
|
+
console.log(`Deployment preview created: ${deployPreviewResult.result.id}`);
|
|
588
|
+
console.log(formatDeployForDisplay(deployPreviewResult.result));
|
|
589
|
+
}
|
|
590
|
+
if (options.verbose) {
|
|
591
|
+
console.error(`Preview created in ${deployPreviewResult.timing}ms`);
|
|
592
|
+
}
|
|
593
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
594
|
+
}
|
|
595
|
+
if (parsed.subcommand === 'run') {
|
|
596
|
+
const deploymentId = parsed.positionalArgs[0] ?? '';
|
|
597
|
+
const deployRunResult = await executeDeployRunCommand({ deployment_id: deploymentId }, options);
|
|
598
|
+
if (options.format === 'json') {
|
|
599
|
+
console.log(JSON.stringify({
|
|
600
|
+
result: deployRunResult.result,
|
|
601
|
+
advisory: deployRunResult.advisory,
|
|
602
|
+
timing: deployRunResult.timing,
|
|
603
|
+
}, null, parsed.flags['pretty'] ? 2 : 0));
|
|
604
|
+
}
|
|
605
|
+
else {
|
|
606
|
+
console.log(`Deployment run completed (advisory): ${deployRunResult.result.id}`);
|
|
607
|
+
console.log(formatDeployForDisplay(deployRunResult.result));
|
|
608
|
+
if (deployRunResult.advisory) {
|
|
609
|
+
console.log('Note: This was an advisory execution (no real changes made)');
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
if (options.verbose) {
|
|
613
|
+
console.error(`Run completed in ${deployRunResult.timing}ms`);
|
|
614
|
+
}
|
|
615
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
616
|
+
}
|
|
617
|
+
if (parsed.subcommand === 'status') {
|
|
618
|
+
const deploymentId = parsed.positionalArgs[0] ?? '';
|
|
619
|
+
const deployStatusResult = await executeDeployStatusCommand({ deployment_id: deploymentId }, options);
|
|
620
|
+
if (options.format === 'json') {
|
|
621
|
+
console.log(JSON.stringify({
|
|
622
|
+
result: deployStatusResult.result,
|
|
623
|
+
found: deployStatusResult.found,
|
|
624
|
+
timing: deployStatusResult.timing,
|
|
625
|
+
}, null, parsed.flags['pretty'] ? 2 : 0));
|
|
626
|
+
}
|
|
627
|
+
else {
|
|
628
|
+
if (deployStatusResult.found && deployStatusResult.result) {
|
|
629
|
+
console.log(formatDeployForDisplay(deployStatusResult.result));
|
|
630
|
+
}
|
|
631
|
+
else {
|
|
632
|
+
console.log(`Deployment not found: ${deploymentId}`);
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
if (options.verbose) {
|
|
636
|
+
console.error(`Query completed in ${deployStatusResult.timing}ms`);
|
|
637
|
+
}
|
|
638
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
639
|
+
}
|
|
640
|
+
if (parsed.subcommand === 'rollback') {
|
|
641
|
+
const deploymentId = parsed.positionalArgs[0] ?? '';
|
|
642
|
+
const deployRollbackResult = await executeDeployRollbackCommand({ deployment_id: deploymentId }, options);
|
|
643
|
+
if (options.format === 'json') {
|
|
644
|
+
console.log(JSON.stringify({
|
|
645
|
+
result: deployRollbackResult.result,
|
|
646
|
+
advisory: deployRollbackResult.advisory,
|
|
647
|
+
timing: deployRollbackResult.timing,
|
|
648
|
+
}, null, parsed.flags['pretty'] ? 2 : 0));
|
|
649
|
+
}
|
|
650
|
+
else {
|
|
651
|
+
console.log(`Deployment rolled back (advisory): ${deployRollbackResult.result.id}`);
|
|
652
|
+
console.log(formatDeployForDisplay(deployRollbackResult.result));
|
|
653
|
+
if (deployRollbackResult.advisory) {
|
|
654
|
+
console.log('Note: This was an advisory rollback (no real changes made)');
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
if (options.verbose) {
|
|
658
|
+
console.error(`Rollback completed in ${deployRollbackResult.timing}ms`);
|
|
659
|
+
}
|
|
660
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
661
|
+
}
|
|
662
|
+
// Default deploy behavior (execute via orchestration)
|
|
131
663
|
const deployInput = parsed.positionalArgs[0] ?? '';
|
|
132
664
|
const deployFlexibleInput = parseFlexibleInput(deployInput);
|
|
133
665
|
result = await executeDeployCommand({
|
|
@@ -141,6 +673,80 @@ async function main() {
|
|
|
141
673
|
break;
|
|
142
674
|
}
|
|
143
675
|
case 'export': {
|
|
676
|
+
// Handle subcommands: terraform, kubernetes, erp
|
|
677
|
+
if (parsed.subcommand === 'terraform') {
|
|
678
|
+
const targetId = parsed.positionalArgs[0] ?? '';
|
|
679
|
+
const exportTerraformResult = await executeExportTerraformCommand({
|
|
680
|
+
target_id: targetId,
|
|
681
|
+
output_path: parsed.options['output'],
|
|
682
|
+
}, options);
|
|
683
|
+
if (options.format === 'json') {
|
|
684
|
+
console.log(JSON.stringify({
|
|
685
|
+
export_type: exportTerraformResult.export_type,
|
|
686
|
+
target_id: exportTerraformResult.target_id,
|
|
687
|
+
artifacts: exportTerraformResult.artifacts.map(a => ({ filename: a.filename, type: a.type })),
|
|
688
|
+
output_path: exportTerraformResult.output_path,
|
|
689
|
+
written: exportTerraformResult.written,
|
|
690
|
+
timing: exportTerraformResult.timing,
|
|
691
|
+
}, null, parsed.flags['pretty'] ? 2 : 0));
|
|
692
|
+
}
|
|
693
|
+
else {
|
|
694
|
+
console.log(formatExportForDisplay(exportTerraformResult));
|
|
695
|
+
}
|
|
696
|
+
if (options.verbose) {
|
|
697
|
+
console.error(`Export completed in ${exportTerraformResult.timing}ms`);
|
|
698
|
+
}
|
|
699
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
700
|
+
}
|
|
701
|
+
if (parsed.subcommand === 'kubernetes') {
|
|
702
|
+
const targetId = parsed.positionalArgs[0] ?? '';
|
|
703
|
+
const exportK8sResult = await executeExportKubernetesCommand({
|
|
704
|
+
target_id: targetId,
|
|
705
|
+
output_path: parsed.options['output'],
|
|
706
|
+
}, options);
|
|
707
|
+
if (options.format === 'json') {
|
|
708
|
+
console.log(JSON.stringify({
|
|
709
|
+
export_type: exportK8sResult.export_type,
|
|
710
|
+
target_id: exportK8sResult.target_id,
|
|
711
|
+
artifacts: exportK8sResult.artifacts.map(a => ({ filename: a.filename, type: a.type })),
|
|
712
|
+
output_path: exportK8sResult.output_path,
|
|
713
|
+
written: exportK8sResult.written,
|
|
714
|
+
timing: exportK8sResult.timing,
|
|
715
|
+
}, null, parsed.flags['pretty'] ? 2 : 0));
|
|
716
|
+
}
|
|
717
|
+
else {
|
|
718
|
+
console.log(formatExportForDisplay(exportK8sResult));
|
|
719
|
+
}
|
|
720
|
+
if (options.verbose) {
|
|
721
|
+
console.error(`Export completed in ${exportK8sResult.timing}ms`);
|
|
722
|
+
}
|
|
723
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
724
|
+
}
|
|
725
|
+
if (parsed.subcommand === 'erp') {
|
|
726
|
+
const targetId = parsed.positionalArgs[0] ?? '';
|
|
727
|
+
const exportErpResult = await executeExportErpCommand({
|
|
728
|
+
target_id: targetId,
|
|
729
|
+
output_path: parsed.options['output'],
|
|
730
|
+
}, options);
|
|
731
|
+
if (options.format === 'json') {
|
|
732
|
+
console.log(JSON.stringify({
|
|
733
|
+
export_type: exportErpResult.export_type,
|
|
734
|
+
target_id: exportErpResult.target_id,
|
|
735
|
+
artifacts: exportErpResult.artifacts.map(a => ({ filename: a.filename, type: a.type })),
|
|
736
|
+
output_path: exportErpResult.output_path,
|
|
737
|
+
written: exportErpResult.written,
|
|
738
|
+
timing: exportErpResult.timing,
|
|
739
|
+
}, null, parsed.flags['pretty'] ? 2 : 0));
|
|
740
|
+
}
|
|
741
|
+
else {
|
|
742
|
+
console.log(formatExportForDisplay(exportErpResult));
|
|
743
|
+
}
|
|
744
|
+
if (options.verbose) {
|
|
745
|
+
console.error(`Export completed in ${exportErpResult.timing}ms`);
|
|
746
|
+
}
|
|
747
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
748
|
+
}
|
|
749
|
+
// Default export behavior (execute via orchestration)
|
|
144
750
|
const exportInput = parsed.positionalArgs[0] ?? '';
|
|
145
751
|
const exportFlexibleInput = parseFlexibleInput(exportInput);
|
|
146
752
|
result = await executeExportCommand({
|
|
@@ -152,6 +758,127 @@ async function main() {
|
|
|
152
758
|
}, options);
|
|
153
759
|
break;
|
|
154
760
|
}
|
|
761
|
+
case 'erp': {
|
|
762
|
+
// Handle ERP subcommands: list, inspect, surface, map, export
|
|
763
|
+
if (parsed.subcommand === 'list' || !parsed.subcommand) {
|
|
764
|
+
const erpListResult = await executeErpListCommand(options);
|
|
765
|
+
if (options.format === 'json') {
|
|
766
|
+
console.log(JSON.stringify({
|
|
767
|
+
systems: erpListResult.systems,
|
|
768
|
+
count: erpListResult.count,
|
|
769
|
+
repositories_involved: erpListResult.repositories_involved,
|
|
770
|
+
timing: erpListResult.timing,
|
|
771
|
+
}, null, parsed.flags['pretty'] ? 2 : 0));
|
|
772
|
+
}
|
|
773
|
+
else {
|
|
774
|
+
console.log(formatErpListForDisplay(erpListResult.systems));
|
|
775
|
+
console.log(`\nRepositories involved: ${erpListResult.repositories_involved.length}`);
|
|
776
|
+
}
|
|
777
|
+
if (options.verbose) {
|
|
778
|
+
console.error(`Query completed in ${erpListResult.timing}ms`);
|
|
779
|
+
}
|
|
780
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
781
|
+
}
|
|
782
|
+
if (parsed.subcommand === 'inspect') {
|
|
783
|
+
const systemId = parsed.positionalArgs[0] ?? '';
|
|
784
|
+
const erpInspectResult = await executeErpInspectCommand({ system: systemId }, options);
|
|
785
|
+
if (options.format === 'json') {
|
|
786
|
+
console.log(JSON.stringify({
|
|
787
|
+
system: erpInspectResult.system,
|
|
788
|
+
found: erpInspectResult.found,
|
|
789
|
+
repositories_involved: erpInspectResult.repositories_involved,
|
|
790
|
+
timing: erpInspectResult.timing,
|
|
791
|
+
}, null, parsed.flags['pretty'] ? 2 : 0));
|
|
792
|
+
}
|
|
793
|
+
else {
|
|
794
|
+
if (erpInspectResult.found && erpInspectResult.system) {
|
|
795
|
+
console.log(formatErpInspectForDisplay(erpInspectResult.system));
|
|
796
|
+
console.log(`\nRepositories involved: ${erpInspectResult.repositories_involved.length}`);
|
|
797
|
+
}
|
|
798
|
+
else {
|
|
799
|
+
console.log(`ERP system not found: ${systemId}`);
|
|
800
|
+
console.log('Available systems: sap, oracle, netsuite, dynamics365, workday, sage');
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
if (options.verbose) {
|
|
804
|
+
console.error(`Query completed in ${erpInspectResult.timing}ms`);
|
|
805
|
+
}
|
|
806
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
807
|
+
}
|
|
808
|
+
if (parsed.subcommand === 'surface') {
|
|
809
|
+
const planId = parsed.options['plan'] ?? parsed.positionalArgs[0] ?? '';
|
|
810
|
+
const erpSurfaceResult = await executeErpSurfaceCommand({
|
|
811
|
+
plan_id: planId,
|
|
812
|
+
erp_systems: parsed.options['systems']?.split(','),
|
|
813
|
+
}, options);
|
|
814
|
+
if (options.format === 'json') {
|
|
815
|
+
console.log(JSON.stringify({
|
|
816
|
+
analysis: erpSurfaceResult.analysis,
|
|
817
|
+
repositories_involved: erpSurfaceResult.repositories_involved,
|
|
818
|
+
timing: erpSurfaceResult.timing,
|
|
819
|
+
}, null, parsed.flags['pretty'] ? 2 : 0));
|
|
820
|
+
}
|
|
821
|
+
else {
|
|
822
|
+
console.log(formatErpSurfaceForDisplay(erpSurfaceResult.analysis));
|
|
823
|
+
}
|
|
824
|
+
if (options.verbose) {
|
|
825
|
+
console.error(`Analysis completed in ${erpSurfaceResult.timing}ms`);
|
|
826
|
+
}
|
|
827
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
828
|
+
}
|
|
829
|
+
if (parsed.subcommand === 'map') {
|
|
830
|
+
const planId = parsed.positionalArgs[0] ?? '';
|
|
831
|
+
const erpMapResult = await executeErpMapCommand({
|
|
832
|
+
plan_id: planId,
|
|
833
|
+
target_systems: parsed.options['systems']?.split(','),
|
|
834
|
+
}, options);
|
|
835
|
+
if (options.format === 'json') {
|
|
836
|
+
console.log(JSON.stringify({
|
|
837
|
+
mapping: erpMapResult.mapping,
|
|
838
|
+
repositories_involved: erpMapResult.repositories_involved,
|
|
839
|
+
timing: erpMapResult.timing,
|
|
840
|
+
}, null, parsed.flags['pretty'] ? 2 : 0));
|
|
841
|
+
}
|
|
842
|
+
else {
|
|
843
|
+
console.log(formatErpMapForDisplay(erpMapResult.mapping));
|
|
844
|
+
}
|
|
845
|
+
if (options.verbose) {
|
|
846
|
+
console.error(`Mapping completed in ${erpMapResult.timing}ms`);
|
|
847
|
+
}
|
|
848
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
849
|
+
}
|
|
850
|
+
if (parsed.subcommand === 'export') {
|
|
851
|
+
const planId = parsed.positionalArgs[0] ?? '';
|
|
852
|
+
const erpExportResult = await executeErpExportCommand({
|
|
853
|
+
plan_id: planId,
|
|
854
|
+
output_path: parsed.options['output'],
|
|
855
|
+
format: (parsed.options['export-format'] ?? 'json'),
|
|
856
|
+
}, options);
|
|
857
|
+
if (options.format === 'json') {
|
|
858
|
+
console.log(JSON.stringify({
|
|
859
|
+
proposal: erpExportResult.proposal,
|
|
860
|
+
artifacts_written: erpExportResult.artifacts_written,
|
|
861
|
+
output_path: erpExportResult.output_path,
|
|
862
|
+
repositories_involved: erpExportResult.repositories_involved,
|
|
863
|
+
timing: erpExportResult.timing,
|
|
864
|
+
}, null, parsed.flags['pretty'] ? 2 : 0));
|
|
865
|
+
}
|
|
866
|
+
else {
|
|
867
|
+
console.log(formatErpExportForDisplay(erpExportResult.proposal));
|
|
868
|
+
if (erpExportResult.artifacts_written) {
|
|
869
|
+
console.log(`\nArtifacts written to: ${erpExportResult.output_path}`);
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
if (options.verbose) {
|
|
873
|
+
console.error(`Export completed in ${erpExportResult.timing}ms`);
|
|
874
|
+
}
|
|
875
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
876
|
+
}
|
|
877
|
+
// Unknown ERP subcommand
|
|
878
|
+
console.error(`Unknown ERP subcommand: ${parsed.subcommand}`);
|
|
879
|
+
console.error('Supported subcommands: list, inspect, surface, map, export');
|
|
880
|
+
process.exit(EXIT_CODES.USAGE_ERROR);
|
|
881
|
+
}
|
|
155
882
|
case 'diligence': {
|
|
156
883
|
const diligenceInput = parsed.positionalArgs[0] ?? '';
|
|
157
884
|
const diligenceFlexibleInput = parseFlexibleInput(diligenceInput);
|
|
@@ -163,6 +890,246 @@ async function main() {
|
|
|
163
890
|
}, options);
|
|
164
891
|
break;
|
|
165
892
|
}
|
|
893
|
+
case 'usage': {
|
|
894
|
+
// Handle subcommands: history, limits, reset
|
|
895
|
+
if (parsed.subcommand === 'history') {
|
|
896
|
+
const usageHistoryResult = await executeUsageHistoryCommand({
|
|
897
|
+
limit: parsed.options['limit'] ? parseInt(parsed.options['limit'], 10) : undefined,
|
|
898
|
+
}, options);
|
|
899
|
+
if (options.format === 'json') {
|
|
900
|
+
console.log(JSON.stringify({
|
|
901
|
+
history: usageHistoryResult.history,
|
|
902
|
+
count: usageHistoryResult.count,
|
|
903
|
+
timing: usageHistoryResult.timing,
|
|
904
|
+
}, null, parsed.flags['pretty'] ? 2 : 0));
|
|
905
|
+
}
|
|
906
|
+
else {
|
|
907
|
+
console.log(formatHistoryForDisplay(usageHistoryResult.history));
|
|
908
|
+
}
|
|
909
|
+
if (options.verbose) {
|
|
910
|
+
console.error(`Query completed in ${usageHistoryResult.timing}ms`);
|
|
911
|
+
}
|
|
912
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
913
|
+
}
|
|
914
|
+
if (parsed.subcommand === 'limits') {
|
|
915
|
+
const usageLimitsResult = await executeUsageLimitsCommand({}, options);
|
|
916
|
+
if (options.format === 'json') {
|
|
917
|
+
console.log(JSON.stringify({
|
|
918
|
+
limits: usageLimitsResult.limits,
|
|
919
|
+
timing: usageLimitsResult.timing,
|
|
920
|
+
}, null, parsed.flags['pretty'] ? 2 : 0));
|
|
921
|
+
}
|
|
922
|
+
else {
|
|
923
|
+
console.log(formatLimitsForDisplay(usageLimitsResult.limits));
|
|
924
|
+
}
|
|
925
|
+
if (options.verbose) {
|
|
926
|
+
console.error(`Query completed in ${usageLimitsResult.timing}ms`);
|
|
927
|
+
}
|
|
928
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
929
|
+
}
|
|
930
|
+
if (parsed.subcommand === 'reset') {
|
|
931
|
+
const usageResetResult = await executeUsageResetCommand({
|
|
932
|
+
force: parsed.flags['force'] ?? false,
|
|
933
|
+
}, options);
|
|
934
|
+
if (options.format === 'json') {
|
|
935
|
+
console.log(JSON.stringify({
|
|
936
|
+
reset: usageResetResult.reset,
|
|
937
|
+
previous_usage: usageResetResult.previous_usage,
|
|
938
|
+
advisory: usageResetResult.advisory,
|
|
939
|
+
message: usageResetResult.message,
|
|
940
|
+
timing: usageResetResult.timing,
|
|
941
|
+
}, null, parsed.flags['pretty'] ? 2 : 0));
|
|
942
|
+
}
|
|
943
|
+
else {
|
|
944
|
+
console.log(`Usage reset: ${usageResetResult.reset}`);
|
|
945
|
+
console.log(`Previous usage: ${usageResetResult.previous_usage}`);
|
|
946
|
+
console.log(usageResetResult.message);
|
|
947
|
+
}
|
|
948
|
+
if (options.verbose) {
|
|
949
|
+
console.error(`Reset completed in ${usageResetResult.timing}ms`);
|
|
950
|
+
}
|
|
951
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
952
|
+
}
|
|
953
|
+
// Default usage behavior (check connectivity and balance)
|
|
954
|
+
const usageResult = await executeUsageCommand(options);
|
|
955
|
+
// Render usage output based on format
|
|
956
|
+
if (options.format === 'json') {
|
|
957
|
+
console.log(JSON.stringify({
|
|
958
|
+
connected: usageResult.connected,
|
|
959
|
+
balance: usageResult.balance,
|
|
960
|
+
message: usageResult.message,
|
|
961
|
+
timing: usageResult.timing,
|
|
962
|
+
}, null, parsed.flags['pretty'] ? 2 : 0));
|
|
963
|
+
}
|
|
964
|
+
else {
|
|
965
|
+
// Human-readable text output for terminal
|
|
966
|
+
console.log(formatUsageForDisplay(usageResult));
|
|
967
|
+
}
|
|
968
|
+
if (options.verbose) {
|
|
969
|
+
console.error(`Query completed in ${usageResult.timing}ms`);
|
|
970
|
+
}
|
|
971
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
972
|
+
}
|
|
973
|
+
case 'policy': {
|
|
974
|
+
// Handle policy subcommands: list, inspect, create, edit, delete, enable, disable
|
|
975
|
+
if (parsed.subcommand === 'list' || !parsed.subcommand) {
|
|
976
|
+
const policyListResult = await executePolicyListCommand({
|
|
977
|
+
status: parsed.options['status'],
|
|
978
|
+
type: parsed.options['type'],
|
|
979
|
+
limit: parsed.options['limit'] ? parseInt(parsed.options['limit'], 10) : undefined,
|
|
980
|
+
}, options);
|
|
981
|
+
if (options.format === 'json') {
|
|
982
|
+
console.log(JSON.stringify({
|
|
983
|
+
policies: policyListResult.policies,
|
|
984
|
+
count: policyListResult.count,
|
|
985
|
+
timing: policyListResult.timing,
|
|
986
|
+
}, null, parsed.flags['pretty'] ? 2 : 0));
|
|
987
|
+
}
|
|
988
|
+
else {
|
|
989
|
+
console.log(formatPoliciesListForDisplay(policyListResult.policies));
|
|
990
|
+
}
|
|
991
|
+
if (options.verbose) {
|
|
992
|
+
console.error(`Query completed in ${policyListResult.timing}ms`);
|
|
993
|
+
}
|
|
994
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
995
|
+
}
|
|
996
|
+
if (parsed.subcommand === 'inspect') {
|
|
997
|
+
const policyId = parsed.positionalArgs[0] ?? '';
|
|
998
|
+
const policyInspectResult = await executePolicyInspectCommand({ id: policyId }, options);
|
|
999
|
+
if (options.format === 'json') {
|
|
1000
|
+
console.log(JSON.stringify({
|
|
1001
|
+
policy: policyInspectResult.policy,
|
|
1002
|
+
found: policyInspectResult.found,
|
|
1003
|
+
timing: policyInspectResult.timing,
|
|
1004
|
+
}, null, parsed.flags['pretty'] ? 2 : 0));
|
|
1005
|
+
}
|
|
1006
|
+
else {
|
|
1007
|
+
if (policyInspectResult.found && policyInspectResult.policy) {
|
|
1008
|
+
console.log(formatPolicyForDisplay(policyInspectResult.policy));
|
|
1009
|
+
}
|
|
1010
|
+
else {
|
|
1011
|
+
console.log(`Policy not found: ${policyId}`);
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
if (options.verbose) {
|
|
1015
|
+
console.error(`Query completed in ${policyInspectResult.timing}ms`);
|
|
1016
|
+
}
|
|
1017
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
1018
|
+
}
|
|
1019
|
+
if (parsed.subcommand === 'create') {
|
|
1020
|
+
const policyName = parsed.options['name'] ?? parsed.positionalArgs[0] ?? '';
|
|
1021
|
+
const policyCreateResult = await executePolicyCreateCommand({
|
|
1022
|
+
name: policyName,
|
|
1023
|
+
description: parsed.options['description'],
|
|
1024
|
+
type: parsed.options['type'],
|
|
1025
|
+
rules: parsed.options['rules'] ? JSON.parse(parsed.options['rules']) : undefined,
|
|
1026
|
+
metadata: parsed.options['metadata'] ? JSON.parse(parsed.options['metadata']) : undefined,
|
|
1027
|
+
}, options);
|
|
1028
|
+
if (options.format === 'json') {
|
|
1029
|
+
console.log(JSON.stringify({
|
|
1030
|
+
policy: policyCreateResult.policy,
|
|
1031
|
+
timing: policyCreateResult.timing,
|
|
1032
|
+
}, null, parsed.flags['pretty'] ? 2 : 0));
|
|
1033
|
+
}
|
|
1034
|
+
else {
|
|
1035
|
+
console.log(`Policy created: ${policyCreateResult.policy.id}`);
|
|
1036
|
+
console.log(formatPolicyForDisplay(policyCreateResult.policy));
|
|
1037
|
+
}
|
|
1038
|
+
if (options.verbose) {
|
|
1039
|
+
console.error(`Created in ${policyCreateResult.timing}ms`);
|
|
1040
|
+
}
|
|
1041
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
1042
|
+
}
|
|
1043
|
+
if (parsed.subcommand === 'edit') {
|
|
1044
|
+
const policyId = parsed.positionalArgs[0] ?? '';
|
|
1045
|
+
const policyEditResult = await executePolicyEditCommand({
|
|
1046
|
+
id: policyId,
|
|
1047
|
+
name: parsed.options['name'],
|
|
1048
|
+
description: parsed.options['description'],
|
|
1049
|
+
type: parsed.options['type'],
|
|
1050
|
+
rules: parsed.options['rules'] ? JSON.parse(parsed.options['rules']) : undefined,
|
|
1051
|
+
metadata: parsed.options['metadata'] ? JSON.parse(parsed.options['metadata']) : undefined,
|
|
1052
|
+
}, options);
|
|
1053
|
+
if (options.format === 'json') {
|
|
1054
|
+
console.log(JSON.stringify({
|
|
1055
|
+
policy: policyEditResult.policy,
|
|
1056
|
+
timing: policyEditResult.timing,
|
|
1057
|
+
}, null, parsed.flags['pretty'] ? 2 : 0));
|
|
1058
|
+
}
|
|
1059
|
+
else {
|
|
1060
|
+
console.log(`Policy updated: ${policyEditResult.policy.id} (v${policyEditResult.policy.version})`);
|
|
1061
|
+
console.log(formatPolicyForDisplay(policyEditResult.policy));
|
|
1062
|
+
}
|
|
1063
|
+
if (options.verbose) {
|
|
1064
|
+
console.error(`Updated in ${policyEditResult.timing}ms`);
|
|
1065
|
+
}
|
|
1066
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
1067
|
+
}
|
|
1068
|
+
if (parsed.subcommand === 'delete') {
|
|
1069
|
+
const policyId = parsed.positionalArgs[0] ?? '';
|
|
1070
|
+
const policyDeleteResult = await executePolicyDeleteCommand({ id: policyId }, options);
|
|
1071
|
+
if (options.format === 'json') {
|
|
1072
|
+
console.log(JSON.stringify({
|
|
1073
|
+
deleted: policyDeleteResult.deleted,
|
|
1074
|
+
id: policyDeleteResult.id,
|
|
1075
|
+
timing: policyDeleteResult.timing,
|
|
1076
|
+
}, null, parsed.flags['pretty'] ? 2 : 0));
|
|
1077
|
+
}
|
|
1078
|
+
else {
|
|
1079
|
+
console.log(`Policy deleted: ${policyDeleteResult.id}`);
|
|
1080
|
+
}
|
|
1081
|
+
if (options.verbose) {
|
|
1082
|
+
console.error(`Deleted in ${policyDeleteResult.timing}ms`);
|
|
1083
|
+
}
|
|
1084
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
1085
|
+
}
|
|
1086
|
+
if (parsed.subcommand === 'enable') {
|
|
1087
|
+
const policyId = parsed.positionalArgs[0] ?? '';
|
|
1088
|
+
const policyEnableResult = await executePolicyEnableCommand({ id: policyId }, options);
|
|
1089
|
+
if (options.format === 'json') {
|
|
1090
|
+
console.log(JSON.stringify({
|
|
1091
|
+
policy: policyEnableResult.policy,
|
|
1092
|
+
previous_status: policyEnableResult.previous_status,
|
|
1093
|
+
timing: policyEnableResult.timing,
|
|
1094
|
+
}, null, parsed.flags['pretty'] ? 2 : 0));
|
|
1095
|
+
}
|
|
1096
|
+
else {
|
|
1097
|
+
console.log(`Policy enabled: ${policyEnableResult.policy.id}`);
|
|
1098
|
+
if (policyEnableResult.previous_status !== 'enabled') {
|
|
1099
|
+
console.log(` Previous status: ${policyEnableResult.previous_status}`);
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
if (options.verbose) {
|
|
1103
|
+
console.error(`Enabled in ${policyEnableResult.timing}ms`);
|
|
1104
|
+
}
|
|
1105
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
1106
|
+
}
|
|
1107
|
+
if (parsed.subcommand === 'disable') {
|
|
1108
|
+
const policyId = parsed.positionalArgs[0] ?? '';
|
|
1109
|
+
const policyDisableResult = await executePolicyDisableCommand({ id: policyId }, options);
|
|
1110
|
+
if (options.format === 'json') {
|
|
1111
|
+
console.log(JSON.stringify({
|
|
1112
|
+
policy: policyDisableResult.policy,
|
|
1113
|
+
previous_status: policyDisableResult.previous_status,
|
|
1114
|
+
timing: policyDisableResult.timing,
|
|
1115
|
+
}, null, parsed.flags['pretty'] ? 2 : 0));
|
|
1116
|
+
}
|
|
1117
|
+
else {
|
|
1118
|
+
console.log(`Policy disabled: ${policyDisableResult.policy.id}`);
|
|
1119
|
+
if (policyDisableResult.previous_status !== 'disabled') {
|
|
1120
|
+
console.log(` Previous status: ${policyDisableResult.previous_status}`);
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
if (options.verbose) {
|
|
1124
|
+
console.error(`Disabled in ${policyDisableResult.timing}ms`);
|
|
1125
|
+
}
|
|
1126
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
1127
|
+
}
|
|
1128
|
+
// Unknown subcommand
|
|
1129
|
+
console.error(`Unknown policy subcommand: ${parsed.subcommand}`);
|
|
1130
|
+
console.error('Supported subcommands: list, inspect, create, edit, delete, enable, disable');
|
|
1131
|
+
process.exit(EXIT_CODES.USAGE_ERROR);
|
|
1132
|
+
}
|
|
166
1133
|
default:
|
|
167
1134
|
console.error(`Unknown command: ${parsed.command}`);
|
|
168
1135
|
console.error(`Supported commands: ${SUPPORTED_COMMANDS.join(', ')}`);
|
|
@@ -228,12 +1195,16 @@ WORKFLOW:
|
|
|
228
1195
|
COMMANDS:
|
|
229
1196
|
login Authenticate with the Agentics platform
|
|
230
1197
|
Opens browser for authorization, stores API key locally
|
|
1198
|
+
logout Clear local authentication state
|
|
1199
|
+
Removes credentials, requires re-login for protected commands
|
|
1200
|
+
whoami Show current identity and authentication status
|
|
1201
|
+
Reflects actual env/config state, no network calls
|
|
231
1202
|
plan Create a simulation plan from manifest
|
|
232
1203
|
Uses: agentics-simulation-planner
|
|
233
1204
|
simulate Execute a simulation from a plan
|
|
234
1205
|
Uses: agentics-simulation-runner → agentics-simulation-engine
|
|
235
|
-
inspect
|
|
236
|
-
Uses: agentics-
|
|
1206
|
+
inspect Query simulation results (read-only)
|
|
1207
|
+
Uses: agentics-results-index
|
|
237
1208
|
quantify Generate ROI/financial impact analysis
|
|
238
1209
|
Uses: enterprise-roi-engine
|
|
239
1210
|
deploy Resolve deployment intent from simulation
|
|
@@ -242,6 +1213,8 @@ COMMANDS:
|
|
|
242
1213
|
Uses: agentics-deployment-exporters
|
|
243
1214
|
diligence Package compliance artifacts
|
|
244
1215
|
Uses: diligence-artifacts
|
|
1216
|
+
usage Check usage balance and connectivity
|
|
1217
|
+
Uses: agentics-usage-ledger
|
|
245
1218
|
version Show version information
|
|
246
1219
|
help Show this help message
|
|
247
1220
|
|
|
@@ -265,8 +1238,9 @@ COMMAND OPTIONS:
|
|
|
265
1238
|
--iterations <n> Number of iterations (default: 1)
|
|
266
1239
|
|
|
267
1240
|
inspect:
|
|
268
|
-
--
|
|
269
|
-
|
|
1241
|
+
--depth <type> Output depth: summary, detailed, full (default: summary)
|
|
1242
|
+
--include-metrics Include metrics in output
|
|
1243
|
+
--include-traces Include trace data in output
|
|
270
1244
|
|
|
271
1245
|
quantify:
|
|
272
1246
|
--report-type <type> Report type: executive-summary, detailed-analysis,
|
|
@@ -316,10 +1290,12 @@ ENVIRONMENT VARIABLES:
|
|
|
316
1290
|
AGENTICS_PLANNER_URL Override planner service URL
|
|
317
1291
|
AGENTICS_RUNNER_URL Override runner service URL
|
|
318
1292
|
AGENTICS_SIMULATION_ENGINE_URL Override simulation engine URL
|
|
1293
|
+
AGENTICS_RESULTS_INDEX_URL Override results index URL
|
|
319
1294
|
ENTERPRISE_ROI_ENGINE_URL Override ROI engine URL
|
|
320
1295
|
AGENTICS_INTENT_URL Override intent service URL
|
|
321
1296
|
AGENTICS_EXPORTERS_URL Override exporters service URL
|
|
322
1297
|
DILIGENCE_URL Override diligence service URL
|
|
1298
|
+
AGENTICS_USAGE_LEDGER_URL Override usage ledger service URL
|
|
323
1299
|
|
|
324
1300
|
LOCALHOST SAFEGUARD:
|
|
325
1301
|
By default, the CLI targets production Cloud Run endpoints.
|