@build-astron-co/nimbus 0.2.0
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/LICENSE +21 -0
- package/README.md +628 -0
- package/bin/nimbus +38 -0
- package/package.json +80 -0
- package/src/__tests__/app.test.ts +76 -0
- package/src/__tests__/audit.test.ts +877 -0
- package/src/__tests__/circuit-breaker.test.ts +116 -0
- package/src/__tests__/cli-run.test.ts +115 -0
- package/src/__tests__/context-manager.test.ts +502 -0
- package/src/__tests__/context.test.ts +242 -0
- package/src/__tests__/enterprise.test.ts +401 -0
- package/src/__tests__/generator.test.ts +433 -0
- package/src/__tests__/hooks.test.ts +582 -0
- package/src/__tests__/init.test.ts +436 -0
- package/src/__tests__/intent-parser.test.ts +229 -0
- package/src/__tests__/llm-router.test.ts +209 -0
- package/src/__tests__/lsp.test.ts +293 -0
- package/src/__tests__/modes.test.ts +336 -0
- package/src/__tests__/permissions.test.ts +338 -0
- package/src/__tests__/serve.test.ts +275 -0
- package/src/__tests__/sessions.test.ts +227 -0
- package/src/__tests__/sharing.test.ts +288 -0
- package/src/__tests__/snapshots.test.ts +581 -0
- package/src/__tests__/state-db.test.ts +334 -0
- package/src/__tests__/stream-with-tools.test.ts +732 -0
- package/src/__tests__/subagents.test.ts +176 -0
- package/src/__tests__/system-prompt.test.ts +169 -0
- package/src/__tests__/tool-converter.test.ts +256 -0
- package/src/__tests__/tool-schemas.test.ts +397 -0
- package/src/__tests__/tools.test.ts +143 -0
- package/src/__tests__/version.test.ts +49 -0
- package/src/agent/compaction-agent.ts +227 -0
- package/src/agent/context-manager.ts +435 -0
- package/src/agent/context.ts +427 -0
- package/src/agent/deploy-preview.ts +426 -0
- package/src/agent/index.ts +68 -0
- package/src/agent/loop.ts +717 -0
- package/src/agent/modes.ts +429 -0
- package/src/agent/permissions.ts +466 -0
- package/src/agent/subagents/base.ts +116 -0
- package/src/agent/subagents/cost.ts +51 -0
- package/src/agent/subagents/explore.ts +42 -0
- package/src/agent/subagents/general.ts +54 -0
- package/src/agent/subagents/index.ts +102 -0
- package/src/agent/subagents/infra.ts +59 -0
- package/src/agent/subagents/security.ts +69 -0
- package/src/agent/system-prompt.ts +436 -0
- package/src/app.ts +122 -0
- package/src/audit/activity-log.ts +290 -0
- package/src/audit/compliance-checker.ts +540 -0
- package/src/audit/cost-tracker.ts +318 -0
- package/src/audit/index.ts +23 -0
- package/src/audit/security-scanner.ts +596 -0
- package/src/auth/guard.ts +75 -0
- package/src/auth/index.ts +56 -0
- package/src/auth/oauth.ts +455 -0
- package/src/auth/providers.ts +470 -0
- package/src/auth/sso.ts +113 -0
- package/src/auth/store.ts +505 -0
- package/src/auth/types.ts +187 -0
- package/src/build.ts +141 -0
- package/src/cli/index.ts +16 -0
- package/src/cli/init.ts +854 -0
- package/src/cli/openapi-spec.ts +356 -0
- package/src/cli/run.ts +237 -0
- package/src/cli/serve-auth.ts +80 -0
- package/src/cli/serve.ts +462 -0
- package/src/cli/web.ts +67 -0
- package/src/cli.ts +1417 -0
- package/src/clients/core-engine-client.ts +227 -0
- package/src/clients/enterprise-client.ts +334 -0
- package/src/clients/generator-client.ts +351 -0
- package/src/clients/git-client.ts +627 -0
- package/src/clients/github-client.ts +410 -0
- package/src/clients/helm-client.ts +504 -0
- package/src/clients/index.ts +80 -0
- package/src/clients/k8s-client.ts +497 -0
- package/src/clients/llm-client.ts +161 -0
- package/src/clients/rest-client.ts +130 -0
- package/src/clients/service-discovery.ts +33 -0
- package/src/clients/terraform-client.ts +482 -0
- package/src/clients/tools-client.ts +1843 -0
- package/src/clients/ws-client.ts +115 -0
- package/src/commands/analyze/index.ts +352 -0
- package/src/commands/apply/helm.ts +473 -0
- package/src/commands/apply/index.ts +213 -0
- package/src/commands/apply/k8s.ts +454 -0
- package/src/commands/apply/terraform.ts +582 -0
- package/src/commands/ask.ts +167 -0
- package/src/commands/audit/index.ts +238 -0
- package/src/commands/auth-cloud.ts +294 -0
- package/src/commands/auth-list.ts +134 -0
- package/src/commands/auth-profile.ts +121 -0
- package/src/commands/auth-status.ts +141 -0
- package/src/commands/aws/ec2.ts +501 -0
- package/src/commands/aws/iam.ts +397 -0
- package/src/commands/aws/index.ts +133 -0
- package/src/commands/aws/lambda.ts +396 -0
- package/src/commands/aws/rds.ts +439 -0
- package/src/commands/aws/s3.ts +439 -0
- package/src/commands/aws/vpc.ts +393 -0
- package/src/commands/aws-discover.ts +649 -0
- package/src/commands/aws-terraform.ts +805 -0
- package/src/commands/azure/aks.ts +376 -0
- package/src/commands/azure/functions.ts +253 -0
- package/src/commands/azure/index.ts +116 -0
- package/src/commands/azure/storage.ts +478 -0
- package/src/commands/azure/vm.ts +355 -0
- package/src/commands/billing/index.ts +256 -0
- package/src/commands/chat.ts +314 -0
- package/src/commands/config.ts +346 -0
- package/src/commands/cost/cloud-cost-estimator.ts +266 -0
- package/src/commands/cost/estimator.ts +79 -0
- package/src/commands/cost/index.ts +594 -0
- package/src/commands/cost/parsers/terraform.ts +273 -0
- package/src/commands/cost/parsers/types.ts +25 -0
- package/src/commands/cost/pricing/aws.ts +544 -0
- package/src/commands/cost/pricing/azure.ts +499 -0
- package/src/commands/cost/pricing/gcp.ts +396 -0
- package/src/commands/cost/pricing/index.ts +40 -0
- package/src/commands/demo.ts +250 -0
- package/src/commands/doctor.ts +794 -0
- package/src/commands/drift/index.ts +439 -0
- package/src/commands/explain.ts +277 -0
- package/src/commands/feedback.ts +389 -0
- package/src/commands/fix.ts +324 -0
- package/src/commands/fs/index.ts +402 -0
- package/src/commands/gcp/compute.ts +325 -0
- package/src/commands/gcp/functions.ts +271 -0
- package/src/commands/gcp/gke.ts +438 -0
- package/src/commands/gcp/iam.ts +344 -0
- package/src/commands/gcp/index.ts +129 -0
- package/src/commands/gcp/storage.ts +284 -0
- package/src/commands/generate-helm.ts +1249 -0
- package/src/commands/generate-k8s.ts +1560 -0
- package/src/commands/generate-terraform.ts +1460 -0
- package/src/commands/gh/index.ts +863 -0
- package/src/commands/git/index.ts +1343 -0
- package/src/commands/helm/index.ts +1126 -0
- package/src/commands/help.ts +539 -0
- package/src/commands/history.ts +142 -0
- package/src/commands/import.ts +868 -0
- package/src/commands/index.ts +367 -0
- package/src/commands/init.ts +1046 -0
- package/src/commands/k8s/index.ts +1137 -0
- package/src/commands/login.ts +631 -0
- package/src/commands/logout.ts +83 -0
- package/src/commands/onboarding.ts +228 -0
- package/src/commands/plan/display.ts +279 -0
- package/src/commands/plan/index.ts +599 -0
- package/src/commands/preview.ts +452 -0
- package/src/commands/questionnaire.ts +1270 -0
- package/src/commands/resume.ts +55 -0
- package/src/commands/team/index.ts +346 -0
- package/src/commands/template.ts +232 -0
- package/src/commands/tf/index.ts +1034 -0
- package/src/commands/upgrade.ts +550 -0
- package/src/commands/usage/index.ts +134 -0
- package/src/commands/version.ts +170 -0
- package/src/compat/index.ts +2 -0
- package/src/compat/runtime.ts +12 -0
- package/src/compat/sqlite.ts +107 -0
- package/src/config/index.ts +17 -0
- package/src/config/manager.ts +530 -0
- package/src/config/safety-policy.ts +358 -0
- package/src/config/schema.ts +125 -0
- package/src/config/types.ts +527 -0
- package/src/context/context-db.ts +199 -0
- package/src/demo/index.ts +349 -0
- package/src/demo/scenarios/full-journey.ts +229 -0
- package/src/demo/scenarios/getting-started.ts +127 -0
- package/src/demo/scenarios/helm-release.ts +341 -0
- package/src/demo/scenarios/k8s-deployment.ts +194 -0
- package/src/demo/scenarios/terraform-vpc.ts +170 -0
- package/src/demo/types.ts +92 -0
- package/src/engine/cost-estimator.ts +438 -0
- package/src/engine/diagram-generator.ts +256 -0
- package/src/engine/drift-detector.ts +902 -0
- package/src/engine/executor.ts +1035 -0
- package/src/engine/index.ts +76 -0
- package/src/engine/orchestrator.ts +636 -0
- package/src/engine/planner.ts +720 -0
- package/src/engine/safety.ts +743 -0
- package/src/engine/verifier.ts +770 -0
- package/src/enterprise/audit.ts +348 -0
- package/src/enterprise/auth.ts +270 -0
- package/src/enterprise/billing.ts +822 -0
- package/src/enterprise/index.ts +17 -0
- package/src/enterprise/teams.ts +443 -0
- package/src/generator/best-practices.ts +1608 -0
- package/src/generator/helm.ts +630 -0
- package/src/generator/index.ts +37 -0
- package/src/generator/intent-parser.ts +514 -0
- package/src/generator/kubernetes.ts +976 -0
- package/src/generator/terraform.ts +1867 -0
- package/src/history/index.ts +8 -0
- package/src/history/manager.ts +322 -0
- package/src/history/types.ts +34 -0
- package/src/hooks/config.ts +432 -0
- package/src/hooks/engine.ts +391 -0
- package/src/hooks/index.ts +4 -0
- package/src/llm/auth-bridge.ts +198 -0
- package/src/llm/circuit-breaker.ts +140 -0
- package/src/llm/config-loader.ts +201 -0
- package/src/llm/cost-calculator.ts +171 -0
- package/src/llm/index.ts +8 -0
- package/src/llm/model-aliases.ts +115 -0
- package/src/llm/provider-registry.ts +63 -0
- package/src/llm/providers/anthropic.ts +433 -0
- package/src/llm/providers/bedrock.ts +477 -0
- package/src/llm/providers/google.ts +405 -0
- package/src/llm/providers/ollama.ts +767 -0
- package/src/llm/providers/openai-compatible.ts +340 -0
- package/src/llm/providers/openai.ts +328 -0
- package/src/llm/providers/openrouter.ts +338 -0
- package/src/llm/router.ts +1035 -0
- package/src/llm/types.ts +232 -0
- package/src/lsp/client.ts +298 -0
- package/src/lsp/languages.ts +116 -0
- package/src/lsp/manager.ts +278 -0
- package/src/mcp/client.ts +402 -0
- package/src/mcp/index.ts +5 -0
- package/src/mcp/manager.ts +133 -0
- package/src/nimbus.ts +214 -0
- package/src/plugins/index.ts +27 -0
- package/src/plugins/loader.ts +334 -0
- package/src/plugins/manager.ts +376 -0
- package/src/plugins/types.ts +284 -0
- package/src/scanners/cicd-scanner.ts +258 -0
- package/src/scanners/cloud-scanner.ts +466 -0
- package/src/scanners/framework-scanner.ts +469 -0
- package/src/scanners/iac-scanner.ts +388 -0
- package/src/scanners/index.ts +539 -0
- package/src/scanners/language-scanner.ts +276 -0
- package/src/scanners/package-manager-scanner.ts +277 -0
- package/src/scanners/types.ts +172 -0
- package/src/sessions/manager.ts +365 -0
- package/src/sessions/types.ts +44 -0
- package/src/sharing/sync.ts +296 -0
- package/src/sharing/viewer.ts +97 -0
- package/src/snapshots/index.ts +2 -0
- package/src/snapshots/manager.ts +530 -0
- package/src/state/artifacts.ts +147 -0
- package/src/state/audit.ts +137 -0
- package/src/state/billing.ts +240 -0
- package/src/state/checkpoints.ts +117 -0
- package/src/state/config.ts +67 -0
- package/src/state/conversations.ts +14 -0
- package/src/state/credentials.ts +154 -0
- package/src/state/db.ts +58 -0
- package/src/state/index.ts +26 -0
- package/src/state/messages.ts +115 -0
- package/src/state/projects.ts +123 -0
- package/src/state/schema.ts +236 -0
- package/src/state/sessions.ts +147 -0
- package/src/state/teams.ts +200 -0
- package/src/telemetry.ts +108 -0
- package/src/tools/aws-ops.ts +952 -0
- package/src/tools/azure-ops.ts +579 -0
- package/src/tools/file-ops.ts +593 -0
- package/src/tools/gcp-ops.ts +625 -0
- package/src/tools/git-ops.ts +773 -0
- package/src/tools/github-ops.ts +799 -0
- package/src/tools/helm-ops.ts +943 -0
- package/src/tools/index.ts +17 -0
- package/src/tools/k8s-ops.ts +819 -0
- package/src/tools/schemas/converter.ts +184 -0
- package/src/tools/schemas/devops.ts +612 -0
- package/src/tools/schemas/index.ts +73 -0
- package/src/tools/schemas/standard.ts +1144 -0
- package/src/tools/schemas/types.ts +705 -0
- package/src/tools/terraform-ops.ts +862 -0
- package/src/types/ambient.d.ts +193 -0
- package/src/types/config.ts +83 -0
- package/src/types/drift.ts +116 -0
- package/src/types/enterprise.ts +335 -0
- package/src/types/index.ts +20 -0
- package/src/types/plan.ts +44 -0
- package/src/types/request.ts +65 -0
- package/src/types/response.ts +54 -0
- package/src/types/service.ts +51 -0
- package/src/ui/App.tsx +997 -0
- package/src/ui/DeployPreview.tsx +169 -0
- package/src/ui/Header.tsx +68 -0
- package/src/ui/InputBox.tsx +350 -0
- package/src/ui/MessageList.tsx +585 -0
- package/src/ui/PermissionPrompt.tsx +151 -0
- package/src/ui/StatusBar.tsx +158 -0
- package/src/ui/ToolCallDisplay.tsx +409 -0
- package/src/ui/chat-ui.ts +853 -0
- package/src/ui/index.ts +33 -0
- package/src/ui/ink/index.ts +711 -0
- package/src/ui/streaming.ts +176 -0
- package/src/ui/types.ts +57 -0
- package/src/utils/analytics.ts +72 -0
- package/src/utils/cost-warning.ts +27 -0
- package/src/utils/env.ts +46 -0
- package/src/utils/errors.ts +69 -0
- package/src/utils/event-bus.ts +38 -0
- package/src/utils/index.ts +24 -0
- package/src/utils/logger.ts +171 -0
- package/src/utils/rate-limiter.ts +121 -0
- package/src/utils/service-auth.ts +49 -0
- package/src/utils/validation.ts +53 -0
- package/src/version.ts +4 -0
- package/src/watcher/index.ts +163 -0
- package/src/wizard/approval.ts +383 -0
- package/src/wizard/index.ts +25 -0
- package/src/wizard/prompts.ts +338 -0
- package/src/wizard/types.ts +171 -0
- package/src/wizard/ui.ts +556 -0
- package/src/wizard/wizard.ts +304 -0
- package/tsconfig.json +24 -0
|
@@ -0,0 +1,539 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Help Command
|
|
3
|
+
*
|
|
4
|
+
* Display help documentation for CLI commands
|
|
5
|
+
*
|
|
6
|
+
* Usage: nimbus help [command]
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { logger } from '../utils';
|
|
10
|
+
import { ui } from '../wizard';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Command options
|
|
14
|
+
*/
|
|
15
|
+
export interface HelpOptions {
|
|
16
|
+
command?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Command documentation structure
|
|
21
|
+
*/
|
|
22
|
+
interface CommandDoc {
|
|
23
|
+
name: string;
|
|
24
|
+
description: string;
|
|
25
|
+
usage: string;
|
|
26
|
+
options?: Array<{
|
|
27
|
+
flag: string;
|
|
28
|
+
description: string;
|
|
29
|
+
default?: string;
|
|
30
|
+
}>;
|
|
31
|
+
examples?: string[];
|
|
32
|
+
subcommands?: Array<{
|
|
33
|
+
name: string;
|
|
34
|
+
description: string;
|
|
35
|
+
}>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Command documentation
|
|
40
|
+
*/
|
|
41
|
+
const COMMANDS: Record<string, CommandDoc> = {
|
|
42
|
+
chat: {
|
|
43
|
+
name: 'chat',
|
|
44
|
+
description: 'Interactive AI chat for cloud engineering assistance',
|
|
45
|
+
usage: 'nimbus chat [options]',
|
|
46
|
+
options: [
|
|
47
|
+
{ flag: '-m, --message <text>', description: 'Send a single message (non-interactive)' },
|
|
48
|
+
{ flag: '-M, --model <model>', description: 'Specify LLM model to use' },
|
|
49
|
+
{ flag: '--system-prompt <prompt>', description: 'Custom system prompt' },
|
|
50
|
+
{ flag: '--show-tokens', description: 'Display token count for each message' },
|
|
51
|
+
{
|
|
52
|
+
flag: '--ui <mode>',
|
|
53
|
+
description: 'UI mode: ink (default rich TUI) or readline (simple)',
|
|
54
|
+
default: 'ink',
|
|
55
|
+
},
|
|
56
|
+
{ flag: '--non-interactive', description: 'Run in non-interactive mode' },
|
|
57
|
+
],
|
|
58
|
+
examples: [
|
|
59
|
+
'nimbus chat',
|
|
60
|
+
'nimbus chat -m "How do I create an S3 bucket?"',
|
|
61
|
+
'nimbus chat --model gpt-4',
|
|
62
|
+
'nimbus chat --ui=readline',
|
|
63
|
+
],
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
'generate-terraform': {
|
|
67
|
+
name: 'generate terraform',
|
|
68
|
+
description: 'Generate Terraform configurations from existing AWS infrastructure',
|
|
69
|
+
usage: 'nimbus generate terraform [options]',
|
|
70
|
+
options: [
|
|
71
|
+
{ flag: '--profile <name>', description: 'AWS profile to use' },
|
|
72
|
+
{ flag: '--regions <list>', description: 'Comma-separated list of AWS regions' },
|
|
73
|
+
{ flag: '--services <list>', description: 'Comma-separated list of services to scan' },
|
|
74
|
+
{ flag: '--output <path>', description: 'Output directory for generated files' },
|
|
75
|
+
{ flag: '--non-interactive', description: 'Run in non-interactive mode' },
|
|
76
|
+
{ flag: '--accept-all-improvements', description: 'Accept all suggested improvements' },
|
|
77
|
+
{ flag: '--reject-all-improvements', description: 'Reject all suggested improvements' },
|
|
78
|
+
],
|
|
79
|
+
examples: [
|
|
80
|
+
'nimbus generate terraform',
|
|
81
|
+
'nimbus generate terraform --profile production --regions us-east-1,us-west-2',
|
|
82
|
+
'nimbus generate terraform --services EC2,S3,RDS --output ./infra',
|
|
83
|
+
],
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
'generate-k8s': {
|
|
87
|
+
name: 'generate k8s',
|
|
88
|
+
description: 'Generate Kubernetes manifests for your application',
|
|
89
|
+
usage: 'nimbus generate k8s [options]',
|
|
90
|
+
options: [
|
|
91
|
+
{
|
|
92
|
+
flag: '--type, --workload-type <type>',
|
|
93
|
+
description: 'Workload type: deployment, statefulset, daemonset, job, cronjob',
|
|
94
|
+
default: 'deployment',
|
|
95
|
+
},
|
|
96
|
+
{ flag: '--name <name>', description: 'Application name' },
|
|
97
|
+
{ flag: '-n, --namespace <ns>', description: 'Kubernetes namespace', default: 'default' },
|
|
98
|
+
{ flag: '--image <image>', description: 'Container image (e.g., nginx:latest)' },
|
|
99
|
+
{ flag: '--replicas <count>', description: 'Number of replicas', default: '2' },
|
|
100
|
+
{ flag: '--port <port>', description: 'Container port', default: '8080' },
|
|
101
|
+
{
|
|
102
|
+
flag: '--service-type <type>',
|
|
103
|
+
description: 'Service type: ClusterIP, NodePort, LoadBalancer',
|
|
104
|
+
default: 'ClusterIP',
|
|
105
|
+
},
|
|
106
|
+
{ flag: '-o, --output <path>', description: 'Output directory' },
|
|
107
|
+
{ flag: '--include-ingress', description: 'Generate Ingress resource' },
|
|
108
|
+
{ flag: '--include-hpa', description: 'Generate HorizontalPodAutoscaler' },
|
|
109
|
+
{ flag: '--include-pdb', description: 'Generate PodDisruptionBudget' },
|
|
110
|
+
{ flag: '--include-configmap', description: 'Generate ConfigMap' },
|
|
111
|
+
{ flag: '--include-secret', description: 'Generate Secret template' },
|
|
112
|
+
{ flag: '--non-interactive', description: 'Run in non-interactive mode' },
|
|
113
|
+
],
|
|
114
|
+
examples: [
|
|
115
|
+
'nimbus generate k8s',
|
|
116
|
+
'nimbus generate k8s --name myapp --image nginx:latest',
|
|
117
|
+
'nimbus generate k8s --type deployment --name api --image myregistry/api:v1 --replicas 3',
|
|
118
|
+
'nimbus generate-k8s --name myapp --image nginx --non-interactive',
|
|
119
|
+
],
|
|
120
|
+
},
|
|
121
|
+
|
|
122
|
+
'generate-helm': {
|
|
123
|
+
name: 'generate helm',
|
|
124
|
+
description: 'Generate Helm values files for chart deployment',
|
|
125
|
+
usage: 'nimbus generate helm [options]',
|
|
126
|
+
options: [
|
|
127
|
+
{ flag: '--chart <name>', description: 'Helm chart name (e.g., bitnami/nginx)' },
|
|
128
|
+
{ flag: '--release, --release-name <name>', description: 'Release name' },
|
|
129
|
+
{ flag: '-n, --namespace <ns>', description: 'Kubernetes namespace', default: 'default' },
|
|
130
|
+
{
|
|
131
|
+
flag: '--environment <env>',
|
|
132
|
+
description: 'Target environment: dev, staging, production',
|
|
133
|
+
default: 'dev',
|
|
134
|
+
},
|
|
135
|
+
{ flag: '--version <version>', description: 'Chart version' },
|
|
136
|
+
{ flag: '-o, --output <path>', description: 'Output directory' },
|
|
137
|
+
{ flag: '--include-secrets', description: 'Generate separate secrets values file' },
|
|
138
|
+
{ flag: '--no-secrets', description: 'Skip secrets file generation' },
|
|
139
|
+
{ flag: '--non-interactive', description: 'Run in non-interactive mode' },
|
|
140
|
+
],
|
|
141
|
+
examples: [
|
|
142
|
+
'nimbus generate helm',
|
|
143
|
+
'nimbus generate helm --chart bitnami/nginx --release my-nginx',
|
|
144
|
+
'nimbus generate helm --chart bitnami/postgresql --release mydb --environment production',
|
|
145
|
+
'nimbus generate-helm --chart bitnami/redis --release cache --non-interactive',
|
|
146
|
+
],
|
|
147
|
+
},
|
|
148
|
+
|
|
149
|
+
apply: {
|
|
150
|
+
name: 'apply',
|
|
151
|
+
description: 'Apply infrastructure changes',
|
|
152
|
+
usage: 'nimbus apply <type> [options]',
|
|
153
|
+
subcommands: [
|
|
154
|
+
{ name: 'terraform', description: 'Apply Terraform configuration' },
|
|
155
|
+
{ name: 'k8s', description: 'Apply Kubernetes manifests' },
|
|
156
|
+
{ name: 'helm', description: 'Install or upgrade Helm release' },
|
|
157
|
+
],
|
|
158
|
+
options: [
|
|
159
|
+
{ flag: '--dry-run', description: 'Show what would be applied without making changes' },
|
|
160
|
+
{ flag: '--auto-approve', description: 'Skip confirmation prompts' },
|
|
161
|
+
{ flag: '-n, --namespace <ns>', description: 'Kubernetes namespace (for k8s/helm)' },
|
|
162
|
+
],
|
|
163
|
+
examples: [
|
|
164
|
+
'nimbus apply terraform',
|
|
165
|
+
'nimbus apply k8s ./manifests/',
|
|
166
|
+
'nimbus apply helm myrelease ./chart',
|
|
167
|
+
],
|
|
168
|
+
},
|
|
169
|
+
|
|
170
|
+
plan: {
|
|
171
|
+
name: 'plan',
|
|
172
|
+
description: 'Preview infrastructure changes',
|
|
173
|
+
usage: 'nimbus plan [options]',
|
|
174
|
+
options: [
|
|
175
|
+
{
|
|
176
|
+
flag: '--type <type>',
|
|
177
|
+
description: 'Infrastructure type: terraform, k8s, helm, auto',
|
|
178
|
+
default: 'auto',
|
|
179
|
+
},
|
|
180
|
+
{ flag: '--target <path>', description: 'Target directory or file' },
|
|
181
|
+
{ flag: '--out <file>', description: 'Save plan to file (Terraform)' },
|
|
182
|
+
{ flag: '--detailed', description: 'Show detailed plan output' },
|
|
183
|
+
],
|
|
184
|
+
examples: [
|
|
185
|
+
'nimbus plan',
|
|
186
|
+
'nimbus plan --type terraform',
|
|
187
|
+
'nimbus plan --type k8s --target ./manifests',
|
|
188
|
+
],
|
|
189
|
+
},
|
|
190
|
+
|
|
191
|
+
ask: {
|
|
192
|
+
name: 'ask',
|
|
193
|
+
description: 'Quick question and answer with AI',
|
|
194
|
+
usage: 'nimbus ask "<question>" [options]',
|
|
195
|
+
options: [
|
|
196
|
+
{ flag: '--context <file>', description: 'Include file content as context' },
|
|
197
|
+
{ flag: '--model <model>', description: 'Specify LLM model to use' },
|
|
198
|
+
],
|
|
199
|
+
examples: [
|
|
200
|
+
'nimbus ask "How do I create an EKS cluster?"',
|
|
201
|
+
'nimbus ask "What is the best practice for IAM roles?" --model gpt-4',
|
|
202
|
+
'nimbus ask "Explain this config" --context ./terraform/main.tf',
|
|
203
|
+
],
|
|
204
|
+
},
|
|
205
|
+
|
|
206
|
+
explain: {
|
|
207
|
+
name: 'explain',
|
|
208
|
+
description: 'Get AI explanations for code, infrastructure, or errors',
|
|
209
|
+
usage: 'nimbus explain <target> [options]',
|
|
210
|
+
options: [
|
|
211
|
+
{
|
|
212
|
+
flag: '--type <type>',
|
|
213
|
+
description: 'Content type: code, infra, error, auto',
|
|
214
|
+
default: 'auto',
|
|
215
|
+
},
|
|
216
|
+
{ flag: '--file <path>', description: 'Read content from file' },
|
|
217
|
+
{ flag: '--verbose', description: 'Show detailed explanations' },
|
|
218
|
+
],
|
|
219
|
+
examples: [
|
|
220
|
+
'nimbus explain ./main.tf',
|
|
221
|
+
'nimbus explain "Error: resource not found" --type error',
|
|
222
|
+
'nimbus explain --file ./deployment.yaml --verbose',
|
|
223
|
+
],
|
|
224
|
+
},
|
|
225
|
+
|
|
226
|
+
fix: {
|
|
227
|
+
name: 'fix',
|
|
228
|
+
description: 'AI-assisted error fixing',
|
|
229
|
+
usage: 'nimbus fix <error-or-file> [options]',
|
|
230
|
+
options: [
|
|
231
|
+
{ flag: '--file <path>', description: 'File to fix' },
|
|
232
|
+
{ flag: '--auto-apply', description: 'Automatically apply the fix' },
|
|
233
|
+
{ flag: '--dry-run', description: 'Show fix without applying' },
|
|
234
|
+
],
|
|
235
|
+
examples: [
|
|
236
|
+
'nimbus fix "Error: undefined variable"',
|
|
237
|
+
'nimbus fix ./broken.tf',
|
|
238
|
+
'nimbus fix --file ./app.ts --auto-apply',
|
|
239
|
+
],
|
|
240
|
+
},
|
|
241
|
+
|
|
242
|
+
doctor: {
|
|
243
|
+
name: 'doctor',
|
|
244
|
+
description: 'Run diagnostic checks on your Nimbus installation',
|
|
245
|
+
usage: 'nimbus doctor [options]',
|
|
246
|
+
options: [
|
|
247
|
+
{ flag: '--fix', description: 'Attempt to fix issues automatically' },
|
|
248
|
+
{ flag: '--verbose', description: 'Show detailed diagnostic information' },
|
|
249
|
+
],
|
|
250
|
+
examples: ['nimbus doctor', 'nimbus doctor --fix', 'nimbus doctor --verbose'],
|
|
251
|
+
},
|
|
252
|
+
|
|
253
|
+
init: {
|
|
254
|
+
name: 'init',
|
|
255
|
+
description: 'Initialize a Nimbus workspace in the current directory',
|
|
256
|
+
usage: 'nimbus init [options]',
|
|
257
|
+
options: [
|
|
258
|
+
{ flag: '-n, --name <name>', description: 'Project name' },
|
|
259
|
+
{ flag: '--provider <provider>', description: 'Cloud provider' },
|
|
260
|
+
{ flag: '-o, --output <path>', description: 'Output directory' },
|
|
261
|
+
{ flag: '-f, --force', description: 'Overwrite existing configuration' },
|
|
262
|
+
{ flag: '--non-interactive', description: 'Run in non-interactive mode' },
|
|
263
|
+
],
|
|
264
|
+
examples: ['nimbus init', 'nimbus init --name my-project --provider aws'],
|
|
265
|
+
},
|
|
266
|
+
|
|
267
|
+
login: {
|
|
268
|
+
name: 'login',
|
|
269
|
+
description: 'Set up authentication and configure LLM providers',
|
|
270
|
+
usage: 'nimbus login [options]',
|
|
271
|
+
options: [
|
|
272
|
+
{ flag: '--provider <name>', description: 'LLM provider: anthropic, openai, bedrock' },
|
|
273
|
+
{ flag: '--api-key <key>', description: 'API key for the provider' },
|
|
274
|
+
{ flag: '--model <model>', description: 'Default model to use' },
|
|
275
|
+
{ flag: '--skip-github', description: 'Skip GitHub authentication' },
|
|
276
|
+
{ flag: '--sso', description: 'Use SSO authentication' },
|
|
277
|
+
{ flag: '--non-interactive', description: 'Run in non-interactive mode' },
|
|
278
|
+
],
|
|
279
|
+
examples: ['nimbus login', 'nimbus login --provider anthropic --api-key sk-...'],
|
|
280
|
+
},
|
|
281
|
+
|
|
282
|
+
logout: {
|
|
283
|
+
name: 'logout',
|
|
284
|
+
description: 'Clear all stored credentials',
|
|
285
|
+
usage: 'nimbus logout [options]',
|
|
286
|
+
options: [{ flag: '-f, --force', description: 'Skip confirmation prompt' }],
|
|
287
|
+
examples: ['nimbus logout', 'nimbus logout --force'],
|
|
288
|
+
},
|
|
289
|
+
|
|
290
|
+
config: {
|
|
291
|
+
name: 'config',
|
|
292
|
+
description: 'Manage Nimbus configuration',
|
|
293
|
+
usage: 'nimbus config <subcommand> [options]',
|
|
294
|
+
subcommands: [
|
|
295
|
+
{ name: 'list', description: 'List all configuration values' },
|
|
296
|
+
{ name: 'get <key>', description: 'Get a specific configuration value' },
|
|
297
|
+
{ name: 'set <key> <value>', description: 'Set a configuration value' },
|
|
298
|
+
{ name: 'init', description: 'Initialize configuration interactively' },
|
|
299
|
+
{ name: 'reset', description: 'Reset configuration to defaults' },
|
|
300
|
+
],
|
|
301
|
+
examples: [
|
|
302
|
+
'nimbus config list',
|
|
303
|
+
'nimbus config get llm.provider',
|
|
304
|
+
'nimbus config set llm.model gpt-4',
|
|
305
|
+
],
|
|
306
|
+
},
|
|
307
|
+
|
|
308
|
+
tf: {
|
|
309
|
+
name: 'tf',
|
|
310
|
+
description: 'Terraform operations',
|
|
311
|
+
usage: 'nimbus tf <subcommand> [options]',
|
|
312
|
+
subcommands: [
|
|
313
|
+
{ name: 'init', description: 'Initialize Terraform working directory' },
|
|
314
|
+
{ name: 'plan', description: 'Generate execution plan' },
|
|
315
|
+
{ name: 'apply', description: 'Apply changes' },
|
|
316
|
+
{ name: 'validate', description: 'Validate configuration' },
|
|
317
|
+
{ name: 'destroy', description: 'Destroy infrastructure' },
|
|
318
|
+
{ name: 'show', description: 'Show state' },
|
|
319
|
+
],
|
|
320
|
+
examples: ['nimbus tf init', 'nimbus tf plan', 'nimbus tf apply --auto-approve'],
|
|
321
|
+
},
|
|
322
|
+
|
|
323
|
+
k8s: {
|
|
324
|
+
name: 'k8s',
|
|
325
|
+
description: 'Kubernetes operations',
|
|
326
|
+
usage: 'nimbus k8s <subcommand> [options]',
|
|
327
|
+
subcommands: [
|
|
328
|
+
{ name: 'get <resource>', description: 'Get Kubernetes resources' },
|
|
329
|
+
{ name: 'apply <manifest>', description: 'Apply manifests' },
|
|
330
|
+
{ name: 'delete <resource> <name>', description: 'Delete resources' },
|
|
331
|
+
{ name: 'logs <pod>', description: 'Get pod logs' },
|
|
332
|
+
{ name: 'describe <resource> <name>', description: 'Describe resource' },
|
|
333
|
+
{ name: 'scale <resource> <name> <replicas>', description: 'Scale deployment' },
|
|
334
|
+
],
|
|
335
|
+
examples: [
|
|
336
|
+
'nimbus k8s get pods',
|
|
337
|
+
'nimbus k8s apply ./deployment.yaml',
|
|
338
|
+
'nimbus k8s logs my-pod -f',
|
|
339
|
+
],
|
|
340
|
+
},
|
|
341
|
+
|
|
342
|
+
helm: {
|
|
343
|
+
name: 'helm',
|
|
344
|
+
description: 'Helm operations',
|
|
345
|
+
usage: 'nimbus helm <subcommand> [options]',
|
|
346
|
+
subcommands: [
|
|
347
|
+
{ name: 'list', description: 'List releases' },
|
|
348
|
+
{ name: 'install <name> <chart>', description: 'Install a chart' },
|
|
349
|
+
{ name: 'upgrade <name> <chart>', description: 'Upgrade a release' },
|
|
350
|
+
{ name: 'uninstall <name>', description: 'Uninstall a release' },
|
|
351
|
+
{ name: 'rollback <name> <rev>', description: 'Rollback to revision' },
|
|
352
|
+
{ name: 'history <name>', description: 'Show release history' },
|
|
353
|
+
{ name: 'search <keyword>', description: 'Search for charts' },
|
|
354
|
+
{ name: 'repo add <name> <url>', description: 'Add repository' },
|
|
355
|
+
{ name: 'repo update', description: 'Update repositories' },
|
|
356
|
+
],
|
|
357
|
+
examples: [
|
|
358
|
+
'nimbus helm list',
|
|
359
|
+
'nimbus helm install nginx bitnami/nginx',
|
|
360
|
+
'nimbus helm upgrade nginx bitnami/nginx -f values.yaml',
|
|
361
|
+
],
|
|
362
|
+
},
|
|
363
|
+
|
|
364
|
+
history: {
|
|
365
|
+
name: 'history',
|
|
366
|
+
description: 'View command history',
|
|
367
|
+
usage: 'nimbus history [options]',
|
|
368
|
+
options: [
|
|
369
|
+
{ flag: '-n, --limit <count>', description: 'Number of entries to show' },
|
|
370
|
+
{ flag: '-f, --filter <term>', description: 'Filter entries by term' },
|
|
371
|
+
{ flag: '--since <date>', description: 'Show entries since date' },
|
|
372
|
+
{ flag: '--until <date>', description: 'Show entries until date' },
|
|
373
|
+
{ flag: '--status <status>', description: 'Filter by status: success, failure, pending' },
|
|
374
|
+
{ flag: '--json', description: 'Output as JSON' },
|
|
375
|
+
{ flag: '--clear', description: 'Clear all history' },
|
|
376
|
+
],
|
|
377
|
+
subcommands: [{ name: 'show <id>', description: 'Show details for a specific entry' }],
|
|
378
|
+
examples: ['nimbus history', 'nimbus history -n 20', 'nimbus history show abc123'],
|
|
379
|
+
},
|
|
380
|
+
|
|
381
|
+
version: {
|
|
382
|
+
name: 'version',
|
|
383
|
+
description: 'Display version information',
|
|
384
|
+
usage: 'nimbus version [options]',
|
|
385
|
+
options: [
|
|
386
|
+
{ flag: '--verbose', description: 'Show detailed version info including components' },
|
|
387
|
+
{ flag: '--json', description: 'Output as JSON' },
|
|
388
|
+
],
|
|
389
|
+
examples: ['nimbus version', 'nimbus version --verbose'],
|
|
390
|
+
},
|
|
391
|
+
|
|
392
|
+
team: {
|
|
393
|
+
name: 'team',
|
|
394
|
+
description: 'Team management (Enterprise)',
|
|
395
|
+
usage: 'nimbus team <subcommand> [options]',
|
|
396
|
+
subcommands: [
|
|
397
|
+
{ name: 'create <name>', description: 'Create a new team' },
|
|
398
|
+
{ name: 'invite <email>', description: 'Invite a member' },
|
|
399
|
+
{ name: 'members', description: 'List team members' },
|
|
400
|
+
{ name: 'remove <email>', description: 'Remove a member' },
|
|
401
|
+
{ name: 'switch', description: 'Switch active team' },
|
|
402
|
+
],
|
|
403
|
+
examples: [
|
|
404
|
+
'nimbus team create my-team',
|
|
405
|
+
'nimbus team invite user@example.com',
|
|
406
|
+
'nimbus team members',
|
|
407
|
+
],
|
|
408
|
+
},
|
|
409
|
+
};
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* Show help for a specific command
|
|
413
|
+
*/
|
|
414
|
+
function showCommandHelp(commandName: string): void {
|
|
415
|
+
// Normalize command name (handle aliases like "generate k8s" -> "generate-k8s")
|
|
416
|
+
const normalizedName = commandName.replace(/^generate /, 'generate-');
|
|
417
|
+
|
|
418
|
+
const doc = COMMANDS[normalizedName] || COMMANDS[commandName];
|
|
419
|
+
|
|
420
|
+
if (!doc) {
|
|
421
|
+
ui.error(`Unknown command: ${commandName}`);
|
|
422
|
+
ui.newLine();
|
|
423
|
+
ui.info('Run "nimbus help" to see available commands');
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
ui.header(`nimbus ${doc.name}`);
|
|
428
|
+
ui.print(doc.description);
|
|
429
|
+
ui.newLine();
|
|
430
|
+
|
|
431
|
+
ui.print('Usage:');
|
|
432
|
+
ui.print(` ${doc.usage}`);
|
|
433
|
+
ui.newLine();
|
|
434
|
+
|
|
435
|
+
if (doc.subcommands?.length) {
|
|
436
|
+
ui.print('Subcommands:');
|
|
437
|
+
for (const sub of doc.subcommands) {
|
|
438
|
+
ui.print(` ${sub.name.padEnd(28)} ${sub.description}`);
|
|
439
|
+
}
|
|
440
|
+
ui.newLine();
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
if (doc.options?.length) {
|
|
444
|
+
ui.print('Options:');
|
|
445
|
+
for (const opt of doc.options) {
|
|
446
|
+
const flagStr = opt.flag.padEnd(30);
|
|
447
|
+
const defaultStr = opt.default ? ` (default: ${opt.default})` : '';
|
|
448
|
+
ui.print(` ${flagStr} ${opt.description}${defaultStr}`);
|
|
449
|
+
}
|
|
450
|
+
ui.newLine();
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
if (doc.examples?.length) {
|
|
454
|
+
ui.print('Examples:');
|
|
455
|
+
for (const ex of doc.examples) {
|
|
456
|
+
ui.print(` ${ex}`);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* Show general help
|
|
463
|
+
*/
|
|
464
|
+
function showGeneralHelp(): void {
|
|
465
|
+
ui.header('Nimbus CLI');
|
|
466
|
+
ui.print('AI-powered Cloud Engineering Agent');
|
|
467
|
+
ui.newLine();
|
|
468
|
+
|
|
469
|
+
ui.print('Usage:');
|
|
470
|
+
ui.print(' nimbus <command> [options]');
|
|
471
|
+
ui.newLine();
|
|
472
|
+
|
|
473
|
+
ui.print('Chat & AI:');
|
|
474
|
+
ui.print(' chat Interactive AI chat');
|
|
475
|
+
ui.print(' ask Quick question/answer');
|
|
476
|
+
ui.print(' explain Explain code or infrastructure');
|
|
477
|
+
ui.print(' fix Fix errors with AI assistance');
|
|
478
|
+
ui.newLine();
|
|
479
|
+
|
|
480
|
+
ui.print('Infrastructure Generation:');
|
|
481
|
+
ui.print(' generate terraform Generate Terraform from AWS infrastructure');
|
|
482
|
+
ui.print(' generate k8s Generate Kubernetes manifests');
|
|
483
|
+
ui.print(' generate helm Generate Helm values files');
|
|
484
|
+
ui.newLine();
|
|
485
|
+
|
|
486
|
+
ui.print('Infrastructure Operations:');
|
|
487
|
+
ui.print(' plan Preview infrastructure changes');
|
|
488
|
+
ui.print(' apply Apply infrastructure changes');
|
|
489
|
+
ui.print(' tf <cmd> Terraform operations');
|
|
490
|
+
ui.print(' k8s <cmd> Kubernetes operations');
|
|
491
|
+
ui.print(' helm <cmd> Helm operations');
|
|
492
|
+
ui.newLine();
|
|
493
|
+
|
|
494
|
+
ui.print('Setup & Configuration:');
|
|
495
|
+
ui.print(' init Initialize Nimbus workspace');
|
|
496
|
+
ui.print(' login Set up authentication');
|
|
497
|
+
ui.print(' logout Clear credentials');
|
|
498
|
+
ui.print(' config Manage configuration');
|
|
499
|
+
ui.newLine();
|
|
500
|
+
|
|
501
|
+
ui.print('Utilities:');
|
|
502
|
+
ui.print(' history View command history');
|
|
503
|
+
ui.print(' doctor Run diagnostic checks');
|
|
504
|
+
ui.print(' version Show version info');
|
|
505
|
+
ui.print(' help Show this help message');
|
|
506
|
+
ui.newLine();
|
|
507
|
+
|
|
508
|
+
ui.print('Git & GitHub:');
|
|
509
|
+
ui.print(' git <cmd> Git operations');
|
|
510
|
+
ui.print(' gh <cmd> GitHub operations');
|
|
511
|
+
ui.newLine();
|
|
512
|
+
|
|
513
|
+
ui.print('Enterprise:');
|
|
514
|
+
ui.print(' team <cmd> Team management');
|
|
515
|
+
ui.print(' billing <cmd> Billing management');
|
|
516
|
+
ui.print(' usage Usage dashboard');
|
|
517
|
+
ui.print(' audit Audit logs');
|
|
518
|
+
ui.newLine();
|
|
519
|
+
|
|
520
|
+
ui.print('Get detailed help for a command:');
|
|
521
|
+
ui.print(' nimbus help <command>');
|
|
522
|
+
ui.print(' nimbus <command> --help');
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* Run the help command
|
|
527
|
+
*/
|
|
528
|
+
export async function helpCommand(options: HelpOptions = {}): Promise<void> {
|
|
529
|
+
logger.debug('Running help command', { options });
|
|
530
|
+
|
|
531
|
+
if (options.command) {
|
|
532
|
+
showCommandHelp(options.command);
|
|
533
|
+
} else {
|
|
534
|
+
showGeneralHelp();
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
// Export as default command
|
|
539
|
+
export default helpCommand;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* History Command
|
|
3
|
+
*
|
|
4
|
+
* CLI command for viewing command history
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { historyManager, type HistoryQueryOptions } from '../history';
|
|
8
|
+
import { ui } from '../wizard/ui';
|
|
9
|
+
|
|
10
|
+
export interface HistoryOptions {
|
|
11
|
+
limit?: number;
|
|
12
|
+
filter?: string;
|
|
13
|
+
since?: string;
|
|
14
|
+
until?: string;
|
|
15
|
+
status?: 'success' | 'failure' | 'pending';
|
|
16
|
+
json?: boolean;
|
|
17
|
+
clear?: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Format a timestamp for display
|
|
22
|
+
*/
|
|
23
|
+
function formatTimestamp(timestamp: string): string {
|
|
24
|
+
const date = new Date(timestamp);
|
|
25
|
+
return date.toLocaleString();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Format duration in ms to human readable
|
|
30
|
+
*/
|
|
31
|
+
function formatDuration(duration?: number): string {
|
|
32
|
+
if (!duration) {
|
|
33
|
+
return '-';
|
|
34
|
+
}
|
|
35
|
+
if (duration < 1000) {
|
|
36
|
+
return `${duration}ms`;
|
|
37
|
+
}
|
|
38
|
+
if (duration < 60000) {
|
|
39
|
+
return `${(duration / 1000).toFixed(1)}s`;
|
|
40
|
+
}
|
|
41
|
+
return `${(duration / 60000).toFixed(1)}m`;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* History command - view and manage command history
|
|
46
|
+
*/
|
|
47
|
+
export async function historyCommand(options: HistoryOptions = {}): Promise<void> {
|
|
48
|
+
// Handle clear
|
|
49
|
+
if (options.clear) {
|
|
50
|
+
ui.header('Clear History');
|
|
51
|
+
historyManager.clear();
|
|
52
|
+
ui.success('History cleared');
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
ui.header('Command History');
|
|
57
|
+
|
|
58
|
+
// Build query options
|
|
59
|
+
const queryOptions: HistoryQueryOptions = {
|
|
60
|
+
limit: options.limit || 20,
|
|
61
|
+
command: options.filter,
|
|
62
|
+
since: options.since,
|
|
63
|
+
until: options.until,
|
|
64
|
+
status: options.status,
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const entries = await historyManager.getEntries(queryOptions);
|
|
68
|
+
|
|
69
|
+
if (entries.length === 0) {
|
|
70
|
+
ui.info('No history entries found');
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// JSON output
|
|
75
|
+
if (options.json) {
|
|
76
|
+
console.log(JSON.stringify(entries, null, 2));
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Display as table
|
|
81
|
+
ui.info(`Showing ${entries.length} entries`);
|
|
82
|
+
ui.newLine();
|
|
83
|
+
|
|
84
|
+
ui.table({
|
|
85
|
+
columns: [
|
|
86
|
+
{ key: 'timestamp', header: 'Time' },
|
|
87
|
+
{ key: 'command', header: 'Command' },
|
|
88
|
+
{ key: 'status', header: 'Status' },
|
|
89
|
+
{ key: 'duration', header: 'Duration' },
|
|
90
|
+
],
|
|
91
|
+
data: entries.map(entry => ({
|
|
92
|
+
timestamp: formatTimestamp(entry.timestamp),
|
|
93
|
+
command: `${entry.command} ${entry.args.join(' ')}`.substring(0, 40),
|
|
94
|
+
status:
|
|
95
|
+
entry.status === 'success'
|
|
96
|
+
? ui.color('success', 'green')
|
|
97
|
+
: entry.status === 'failure'
|
|
98
|
+
? ui.color('failure', 'red')
|
|
99
|
+
: ui.color('pending', 'yellow'),
|
|
100
|
+
duration: formatDuration(entry.duration),
|
|
101
|
+
})),
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Show detailed history for a specific entry
|
|
107
|
+
*/
|
|
108
|
+
export async function historyShowCommand(id: string): Promise<void> {
|
|
109
|
+
ui.header('History Entry Details');
|
|
110
|
+
|
|
111
|
+
const entry = historyManager.getEntry(id);
|
|
112
|
+
|
|
113
|
+
if (!entry) {
|
|
114
|
+
ui.error(`Entry not found: ${id}`);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
ui.info(`ID: ${entry.id}`);
|
|
119
|
+
ui.info(`Command: ${entry.command}`);
|
|
120
|
+
ui.info(`Args: ${entry.args.join(' ')}`);
|
|
121
|
+
ui.info(`Time: ${formatTimestamp(entry.timestamp)}`);
|
|
122
|
+
ui.info(`Status: ${entry.status}`);
|
|
123
|
+
ui.info(`Duration: ${formatDuration(entry.duration)}`);
|
|
124
|
+
|
|
125
|
+
if (entry.result?.output) {
|
|
126
|
+
ui.newLine();
|
|
127
|
+
ui.box({ title: 'Output', content: entry.result.output });
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (entry.result?.error) {
|
|
131
|
+
ui.newLine();
|
|
132
|
+
ui.box({ title: 'Error', content: entry.result.error, borderColor: 'red' });
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (entry.metadata && Object.keys(entry.metadata).length > 0) {
|
|
136
|
+
ui.newLine();
|
|
137
|
+
ui.info('Metadata:');
|
|
138
|
+
for (const [key, value] of Object.entries(entry.metadata)) {
|
|
139
|
+
ui.info(` ${key}: ${JSON.stringify(value)}`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|