@sembix/cli 1.4.1 → 1.5.1

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/README.md CHANGED
@@ -1,310 +1,210 @@
1
1
  # Sembix CLI
2
2
 
3
- A terminal-based CLI tool for managing Sembix products. An intuitive command-line interface designed for technical users.
3
+ A unified CLI for managing Sembix Studio with two main capabilities:
4
+ 1. **Environment Management** (`sembix studio`) - Create and manage GitHub Actions environments for AWS deployments
5
+ 2. **Environment Interaction** (`sembix workflow`, `sembix project`) - Execute and manage workflows on running Studio instances
4
6
 
5
7
  ## Table of Contents
6
8
 
7
- - [Features](#features)
8
9
  - [Prerequisites](#prerequisites)
9
- - [Deployment Process](#deployment-process)
10
10
  - [Installation](#installation)
11
11
  - [Quick Start](#quick-start)
12
- - [GitHub Deployment Quick Start](#github-deployment-quick-start)
13
- - [Studio CLI Quick Start](#studio-cli-quick-start)
14
- - [Configuration](#configuration)
15
- - [Option 1: Interactive Configuration (Recommended)](#option-1-interactive-configuration-recommended)
16
- - [Option 2: Environment Variables (.env file)](#option-2-environment-variables-env-file)
17
- - [Option 3: Config File (Recommended for Automation)](#option-3-config-file-recommended-for-automation)
18
- - [Creating a GitHub Token](#creating-a-github-token)
19
- - [Credential Priority](#credential-priority)
20
- - [Commands](#commands)
21
- - [Global Commands](#global-commands)
22
- - [Studio Deployment Commands](#studio-deployment-commands)
23
- - [Studio API Commands](#studio-api-commands)
24
- - [Global Options](#global-options)
25
- - [Usage Examples](#usage-examples)
26
- - [Basic Usage Patterns](#basic-usage-patterns)
12
+ - **[Part 1: Environment Management](#part-1-environment-management)**
13
+ - [Concepts](#concepts)
14
+ - [Command Reference](#command-reference)
15
+ - [studio create](#sembix-studio-create-name)
16
+ - [studio update](#sembix-studio-update-name)
17
+ - [studio add-hub](#sembix-studio-add-hub-name)
18
+ - [studio list](#sembix-studio-list-repository)
19
+ - [Configuration](#configuration)
27
20
  - [Common Workflows](#common-workflows)
28
- - [Profile Management](#profile-management-examples)
29
- - [Error Handling](#error-handling-examples)
30
- - [Best Practices](#best-practices)
31
- - [Studio CLI](#studio-cli)
32
- - [Studio Configuration](#studio-configuration)
21
+ - **[Part 2: Environment Interaction](#part-2-environment-interaction)**
22
+ - [Concepts](#concepts-1)
33
23
  - [Authentication](#authentication)
34
- - [Workflow Operations](#workflow-operations)
35
- - [Workflow](#workflow)
36
- - [Configuration Priority](#configuration-priority)
37
- - [Config File Reference](#config-file-reference)
38
- - [Use Cases](#use-cases)
24
+ - [Command Reference](#command-reference-1)
25
+ - [Profile Management](#profile-management)
26
+ - [Project Management](#project-management)
27
+ - [Workflow Operations](#workflow-operations)
28
+ - [Common Workflows](#common-workflows-1)
29
+ - [Global Configuration](#global-configuration)
30
+ - [sembix configure](#sembix-configure)
31
+ - [Environment Variables](#environment-variables)
32
+ - [Global Options](#global-options)
39
33
  - [Troubleshooting](#troubleshooting)
40
- - [Authentication Issues](#authentication-issues)
41
- - [GitHub API Issues](#github-api-issues)
42
- - [Studio API Issues](#studio-api-issues)
43
- - [Common Errors](#common-errors)
44
34
  - [Development](#development)
45
- - [Advanced Topics](#advanced-topics)
46
- - [License](#license)
47
- - [Support](#support)
48
- - [See Also](#see-also)
49
-
50
- ## Features
51
-
52
- - 🚀 **Interactive Setup** - Guided prompts for environment configuration with detailed explanations
53
- - 📝 **Config File Support** - YAML configuration files for version-controlled, repeatable setups
54
- - 🎯 **50+ CLI Flags** - Complete automation support with flags for every configuration option
55
- - 🔐 **GitHub Integration** - Direct GitHub API integration for environment and secrets management
56
- - ✅ **Validation** - Real-time input validation for AWS resources, IAM roles, and more
57
- - 🔄 **Update Command** - Modify existing environments without recreation
58
- - 🔗 **Hub Integration** - Built-in Hub configuration as part of the main workflow
59
- - 🎨 **Beautiful UI** - Clean, colorful terminal interface with spinners and status updates
60
- - ⚡ **Priority Chain** - CLI flags > Config file > Interactive prompts > Defaults
61
- - 🌐 **Studio Integration** - Connect to Sembix Studio instances with profile-based configuration
62
- - 🔐 **Cognito Authentication** - Browser-based OAuth flow with automatic token refresh
63
- - 🔄 **Workflow Execution** - Start, monitor, and manage workflow runs remotely
64
- - 👤 **Profile Management** - Manage multiple Studio instances like AWS CLI profiles
65
- - 📊 **Output Formatting** - JSON, pretty-print, or text output for all commands
66
- - 🎯 **Project Management** - List, search, and view project details
67
- - 🔗 **Profile Defaults** - Set default projects per profile for faster workflow execution
35
+ - [Complete Studio Options](#complete-studio-options)
68
36
 
69
37
  ## Prerequisites
70
38
 
71
- - **Node.js** 20 or higher
72
- - **GitHub Personal Access Token** with the following scopes:
73
- - `repo` - Full control of private repositories
74
- - `workflow` - Update GitHub Action workflows
75
- - **Deployment Repository** - A GitHub repository set up for Sembix Studio deployments
76
-
77
- ### For Studio Integration (Optional)
78
- - **Sembix Studio Instance** - Access to a Sembix Studio deployment
79
- - **Cognito Configuration** - User Pool ID, Client ID, and Domain from Studio admin
80
-
81
- ## Deployment Process
82
-
83
- Sembix Studio uses a **two-phased deployment** process to establish secure cross-account access with the Sembix Hub:
84
-
85
- ### Phase 1: Bootstrap & Initial Deployment
86
-
87
- 1. **Create environment** - Run `sembix studio create` to configure your environment (Steps 1-8)
88
- - Skip Hub integration initially (use `--skip-hub` or skip Step 9)
89
- - Creates GitHub Actions environment with AWS configuration
90
-
91
- 2. **Bootstrap deployment** - Run the GitHub Actions workflow
92
- - Deploys initial Terraform infrastructure
93
- - Creates IAM roles and resources in your AWS account
94
- - Produces IAM ARNs needed for Hub integration
95
-
96
- 3. **Coordinate with Sembix Support** - Send the IAM ARNs to Sembix support
97
- - Sembix configures the Hub to trust your account
98
- - Sembix provides Hub role ARNs back to you:
99
- - Hub Engine Execution Role ARN
100
- - Hub Consumer Role ARN
101
- - Hub Admin Role ARN
102
- - Hub AppConfig Role ARN (plus Application ID, Environment ID, Profile ID)
103
-
104
- ### Phase 2: Hub Integration & Full Deployment
105
-
106
- 4. **Add Hub integration** - Run `sembix studio add-hub` with ARNs from Sembix support
107
- - Updates GitHub Actions environment with Hub role ARNs
108
- - Configures cross-account access to Sembix Hub
109
-
110
- 5. **Final deployment** - Run the GitHub Actions workflow again
111
- - Completes full Sembix Studio deployment
112
- - Enables Hub cross-account access
113
- - Your Studio environment is now fully operational
114
-
115
- **Important:** Do not skip Phase 1. The Hub integration requires IAM resources created during the bootstrap deployment.
39
+ - Node.js 20 or higher
40
+ - For environment management: GitHub Personal Access Token with `repo` and `workflow` scopes
41
+ - For environment interaction: Access to a Sembix Studio instance with Cognito credentials
116
42
 
117
43
  ## Installation
118
44
 
119
- ### From npm (Recommended)
120
-
121
45
  ```bash
46
+ # From npm
122
47
  npm install -g @sembix/cli
123
- ```
124
-
125
- ### From Source
126
48
 
127
- ```bash
128
- npm install
129
- npm run build
130
-
131
- # Link globally for development
49
+ # From source
50
+ git clone <repo>
51
+ npm install && npm run build
132
52
  npm link
133
53
  ```
134
54
 
135
- ### Development Mode
136
-
137
- ```bash
138
- npm install
139
- npm run dev -- studio create
140
- ```
141
-
142
55
  ## Quick Start
143
56
 
144
- Get started with the Sembix CLI in 5 minutes. Choose the workflow that matches your needs:
145
-
146
- ### GitHub Deployment Quick Start
147
-
148
- **Step 1: Configure credentials**
57
+ ### Initial Configuration
149
58
 
150
59
  ```bash
151
60
  sembix configure
152
61
  ```
153
62
 
154
63
  Prompts for:
155
- - GitHub Personal Access Token (required)
156
- - Default GitHub organization (optional)
157
-
158
- **Step 2: Create environment**
159
-
160
- ```bash
161
- # Interactive mode (recommended for first-time)
162
- sembix studio create
163
-
164
- # Or with repository specified
165
- sembix studio create --repo owner/repo
166
- ```
167
-
168
- This interactive wizard walks you through 9 configuration steps and creates your GitHub Actions environment with all required secrets.
169
-
170
- **Step 3: Deploy via GitHub Actions**
64
+ - GitHub token (for environment management)
65
+ - Optionally: Studio profile (for environment interaction)
171
66
 
172
- 1. Go to your repository's Actions tab
173
- 2. Select the deployment workflow
174
- 3. Choose your environment
175
- 4. Run the workflow
176
- 5. Copy the Hub role ARNs from deployment output
177
-
178
- **Step 4: Add Hub integration**
67
+ ### Environment Management (GitHub Deployment)
179
68
 
180
69
  ```bash
181
- sembix studio add-hub production
70
+ # Create GitHub Actions environment
71
+ sembix studio create production --repo owner/repo
182
72
 
183
- # Or with repository specified
73
+ # After first deployment, add Hub integration
184
74
  sembix studio add-hub production --repo owner/repo
185
- ```
186
75
 
187
- Enter the Hub role ARNs from the deployment output.
76
+ # List environments
77
+ sembix studio list owner/repo
78
+ ```
188
79
 
189
- **Step 5: Deploy again**
80
+ ### Environment Interaction (Studio API)
190
81
 
191
- Run the GitHub Actions workflow again with Hub enabled. Your Studio environment is now fully operational!
82
+ ```bash
83
+ # Authenticate with Studio instance
84
+ sembix login
192
85
 
193
- ### Studio CLI Quick Start
86
+ # Start a workflow
87
+ sembix workflow start
194
88
 
195
- **Step 1: Configure Studio profile**
89
+ # Monitor workflow status
90
+ sembix workflow run status --workflow-id wf_456 --run-id run_789 --watch
196
91
 
197
- ```bash
198
- sembix configure
92
+ # List projects
93
+ sembix project list
199
94
  ```
200
95
 
201
- After GitHub credentials, choose to configure a Studio profile with:
202
- - Profile name (e.g., "production")
203
- - Studio API URL
204
- - Cognito User Pool ID, Client ID, Domain, and Region
96
+ ---
205
97
 
206
- **Step 2: Authenticate**
98
+ # Part 1: Environment Management
207
99
 
208
- ```bash
209
- # Login with default profile
210
- sembix login
100
+ ## Concepts
211
101
 
212
- # Or specific profile
213
- sembix login --profile production
214
- ```
102
+ The `sembix studio` commands automate GitHub Actions environment creation for Sembix Studio AWS deployments. They create GitHub environments with encrypted secrets and variables required for Terraform-based infrastructure deployment.
215
103
 
216
- Opens your browser for Cognito authentication. Tokens are stored securely and refreshed automatically.
104
+ **Deployment Process:**
105
+ 1. **Bootstrap** - Create environment → Run GitHub Actions → Get IAM ARNs
106
+ 2. **Hub Integration** - Add Hub ARNs → Run GitHub Actions again → Full deployment
217
107
 
218
- **Step 3: Start a workflow**
108
+ ## Command Reference
219
109
 
220
- ```bash
221
- # Interactive mode (recommended)
222
- sembix workflow start
110
+ ### `sembix studio create [name]`
223
111
 
224
- # With explicit IDs
225
- sembix workflow start --project-id proj_123 --workflow-id wf_456
112
+ Create a new GitHub Actions environment for Studio deployment.
226
113
 
227
- # With workflow name
228
- sembix workflow start --project-id proj_123 --workflow-name "Deploy"
229
- ```
114
+ ```bash
115
+ # Interactive mode (guided prompts)
116
+ sembix studio create
230
117
 
231
- **Step 4: Monitor workflow**
118
+ # With repository and name
119
+ sembix studio create production --repo owner/repo
232
120
 
233
- ```bash
234
- # Check status
235
- sembix workflow run status --workflow-id wf_456 --run-id run_789
121
+ # With YAML config file
122
+ sembix studio create --config production.yaml
236
123
 
237
- # Watch until completion
238
- sembix workflow run status --workflow-id wf_456 --run-id run_789 --watch
124
+ # Skip Hub integration (add later)
125
+ sembix studio create production --repo owner/repo --skip-hub
239
126
  ```
240
127
 
241
- ### Common Tasks Cheat Sheet
242
-
243
- ```bash
244
- # List environments
245
- sembix studio list owner/repo
128
+ **Key Options:**
129
+ - `-r, --repo <repo>` - Target repository (owner/repo)
130
+ - `-c, --config <path>` - YAML configuration file
131
+ - `-t, --token <token>` - GitHub token (overrides config)
132
+ - `-e, --env <name>` - Environment name
133
+ - `--skip-hub` - Skip Hub integration step
246
134
 
247
- # List profiles
248
- sembix profile list
135
+ **Configuration Categories:**
136
+ - AWS: `--aws-account-id`, `--aws-region`, `--customer-role-arn`, `--terraform-state-bucket`
137
+ - Database: `--database-name`, `--database-user`
138
+ - Networking: `--vpc-cidr`, `--custom-vpc-id`, `--subnet-ids`, `--enable-vpc-endpoints`
139
+ - Security: `--sg-*` (security groups), `--iam-*` (IAM roles), `--use-custom-*`
140
+ - TLS/DNS: `--cloudfront-domain`, `--cloudfront-cert-arn`, `--bff-alb-cert-arn`, `--hosted-zone-id`
141
+ - Features: `--deploy-studio-memory`, `--deploy-studio-notifications`, `--enable-bff-waf`
142
+ - Frontend: `--github-app-client-id`, `--jira-client-id`
143
+ - Hub: `--hub-engine-execution-role`, `--hub-consumer-role`, `--hub-admin-role`
249
144
 
250
- # Set default project
251
- sembix profile set-default-project production proj_123
145
+ [See all 50+ options](#complete-studio-options)
252
146
 
253
- # List projects
254
- sembix project list
147
+ ### `sembix studio update [name]`
255
148
 
256
- # List workflows
257
- sembix workflow list
149
+ Update an existing GitHub Actions environment. Only provide flags you want to change.
258
150
 
259
- # List workflow runs
260
- sembix workflow run list --workflow-id wf_456
151
+ ```bash
152
+ # Add Hub integration
153
+ sembix studio update production --repo owner/repo \
154
+ --hub-engine-execution-role arn:aws:iam::123456789012:role/HubEngine \
155
+ --hub-consumer-role arn:aws:iam::123456789012:role/HubConsumer
261
156
 
262
- # Stop a workflow
263
- sembix workflow run stop --workflow-id wf_456 --run-id run_789
157
+ # Update feature flags
158
+ sembix studio update production --repo owner/repo \
159
+ --deploy-studio-memory true
264
160
  ```
265
161
 
266
- For detailed documentation, see the sections below.
162
+ ### `sembix studio add-hub [name]`
267
163
 
268
- ## Configuration
269
-
270
- ### Option 1: Interactive Configuration (Recommended)
271
-
272
- The easiest way to get started is using the interactive configuration command:
164
+ Add Sembix Hub integration to an existing environment (Phase 2 of deployment).
273
165
 
274
166
  ```bash
275
- sembix configure
167
+ sembix studio add-hub production --repo owner/repo
276
168
  ```
277
169
 
278
- This will prompt you for:
279
- - **GitHub Personal Access Token** (required)
280
- - **Default GitHub Organization** (optional)
281
-
282
- Your credentials will be securely stored in `~/.sembix/config` with restricted file permissions (0600).
170
+ Interactive prompts for Hub role ARNs (or use flags):
171
+ - `--hub-engine-execution-role <arn>` - Hub Engine Execution Role ARN
172
+ - `--hub-consumer-role <arn>` - Hub Consumer Role ARN
173
+ - `--hub-admin-role <arn>` - Hub Admin Role ARN
174
+ - `--hub-appconfig-role <arn>` - Hub AppConfig Role ARN (optional)
283
175
 
284
- ### Option 2: Environment Variables (.env file)
176
+ ### `sembix studio list [repository]`
285
177
 
286
- Alternatively, create a `.env` file in the project root directory:
178
+ List GitHub Actions environments.
287
179
 
288
180
  ```bash
289
- cp .env.example .env
181
+ sembix studio list # All accessible repositories
182
+ sembix studio list owner/repo # Specific repository
290
183
  ```
291
184
 
292
- Edit `.env` and add your GitHub token:
185
+ ## Configuration
293
186
 
294
- ```env
295
- # GitHub Personal Access Token
296
- GITHUB_TOKEN=ghp_your_token_here
187
+ ### Priority Chain
297
188
 
298
- # Optional: Default GitHub organization
299
- DEFAULT_GITHUB_ORG=your-org
300
- ```
189
+ Configuration values are resolved in this order (highest to lowest):
190
+ 1. **CLI Flags** - Explicit command-line options
191
+ 2. **Config File** - YAML file (via `--config`)
192
+ 3. **Interactive Prompts** - User input during execution
193
+ 4. **Defaults** - Built-in defaults
194
+
195
+ ### GitHub Token Priority
196
+
197
+ GitHub token is resolved in this order:
198
+ 1. `--token` flag
199
+ 2. `GITHUB_TOKEN` environment variable
200
+ 3. `~/.sembix/config` (via `sembix configure`)
201
+ 4. `.env` file
301
202
 
302
- ### Option 3: Config File (Recommended for Automation)
203
+ ### YAML Config File
303
204
 
304
- Create a YAML config file for your environment:
205
+ Create `production.yaml`:
305
206
 
306
207
  ```yaml
307
- # production.yaml
308
208
  repository:
309
209
  owner: acme-corp
310
210
  repo: sembix-deployment
@@ -319,330 +219,118 @@ database:
319
219
  name: sembix_studio
320
220
  user: sembix_studio_user
321
221
 
322
- # ... see config.example.yaml for complete structure
323
- ```
324
-
325
- See [`config.example.yaml`](./config.example.yaml) for a complete configuration example.
326
-
327
- ### Creating a GitHub Token
328
-
329
- 1. Go to GitHub Settings → Developer settings → Personal access tokens → Tokens (classic)
330
- 2. Click "Generate new token (classic)"
331
- 3. Select scopes:
332
- - ✅ `repo` (all sub-scopes)
333
- - ✅ `workflow`
334
- 4. Generate and copy the token
335
- 5. Run `sembix configure` to store it securely, or add to `.env` file, or use `--token` flag
336
-
337
- ### Credential Priority
338
-
339
- The CLI checks for credentials in this order (highest to lowest priority):
340
- 1. `--token` flag
341
- 2. `GITHUB_TOKEN` environment variable
342
- 3. `~/.sembix/config` (created by `sembix configure`)
343
- 4. Project `.env` file
344
-
345
- ## Commands
346
-
347
- Complete reference for all Sembix CLI commands.
348
-
349
- ### Command Structure
350
-
351
- ```
352
- sembix <product> <action> [options] [arguments]
353
- ```
354
-
355
- - **product**: The Sembix product (e.g., `studio`)
356
- - **action**: What you want to do (e.g., `create`, `list`, `add-hub`)
357
- - **options**: Flags like `--token` or `--repo`
358
- - **arguments**: Required or optional values (e.g., environment name)
359
-
360
- ---
361
-
362
- ### Global Commands
363
-
364
- #### `sembix configure`
365
-
366
- Configure Sembix CLI credentials and settings interactively.
367
-
368
- **Usage:**
369
-
370
- ```bash
371
- sembix configure
372
- ```
373
-
374
- **What it does:**
375
-
376
- 1. Prompts for your GitHub Personal Access Token
377
- 2. Prompts for your default GitHub organization (optional)
378
- 3. Optionally prompts to configure a Sembix Studio profile for API access:
379
- - Studio API URL
380
- - Cognito User Pool ID, Client ID, Region, and Domain
381
- 4. Saves configuration to `~/.sembix/config` with secure permissions (0600)
382
-
383
- **When to use:**
384
-
385
- - First time setup (recommended)
386
- - Updating your GitHub token
387
- - Changing your default organization
388
- - Adding or updating Studio profiles for API access
389
-
390
- **Example:**
391
-
392
- ```bash
393
- $ sembix configure
394
-
395
- Configure Sembix CLI
396
-
397
- This will store your configuration in:
398
- ~/.sembix/config
399
-
400
- ? GitHub Personal Access Token: ****
401
- ? Default GitHub Organization (optional): acme-corp
402
- ? Configure Sembix Studio profile? Yes
403
-
404
- ━━━ Studio Profile Configuration ━━━
405
-
406
- ? Profile name: production
407
- ? Studio API URL: https://studio.example.com
408
- ? Cognito User Pool ID: us-east-1_ABC123
409
- ? Cognito Client ID: 1a2b3c4d5e6f7g8h9i0j
410
- ? Cognito Region: us-east-1
411
- ? Cognito Domain: https://auth.example.com
412
-
413
- ✓ Configuration saved successfully!
414
- ✓ Studio profile 'production' configured successfully!
415
- ```
416
-
417
- ---
418
-
419
- ### Studio Deployment Commands
420
-
421
- Commands for managing Sembix Studio GitHub Actions deployments.
422
-
423
- #### `sembix studio create [name]`
424
-
425
- Create a new Sembix Studio environment with full interactive configuration.
426
-
427
- **Usage:**
428
-
429
- ```bash
430
- # Interactive mode
431
- sembix studio create
432
-
433
- # With environment name
434
- sembix studio create production
435
-
436
- # With name and repository
437
- sembix studio create production --repo acme/deploy
438
- ```
439
-
440
- **Key Options:**
441
-
442
- ```bash
443
- -r, --repo <repo> Target repository (owner/repo)
444
- -e, --env <environment> Environment name
445
- -t, --token <token> GitHub personal access token
446
- -c, --config <path> Path to YAML configuration file
447
-
448
- # AWS Configuration
449
- --aws-account-id <id> AWS Account ID (12 digits)
450
- --aws-region <region> AWS Region
451
- --customer-role-arn <arn> GitHub Actions IAM role ARN
452
- --terraform-state-bucket <bucket> Terraform state S3 bucket
453
-
454
- # Database
455
- --database-name <name> PostgreSQL database name
456
- --database-user <user> PostgreSQL database user
457
-
458
- # Networking
459
- --enable-vpc-endpoints <boolean> Enable VPC endpoints (true/false)
460
- --use-custom-networking <boolean> Use existing VPC (true/false)
461
- --vpc-cidr <cidr> VPC CIDR block (e.g., 10.0.0.0/16)
462
- --public-subnet-cidrs <json> Public subnet CIDRs (JSON array)
463
- --private-subnet-cidrs <json> Private subnet CIDRs (JSON array)
464
- --az-count <count> Number of AZs (2 or 3)
465
- --custom-vpc-id <id> Existing VPC ID
466
- --custom-public-subnet-ids <ids> Existing public subnet IDs (comma-separated)
467
- --custom-private-subnet-ids <ids> Existing private subnet IDs (comma-separated)
468
-
469
- # Security - Security Groups
470
- --use-custom-security-groups <boolean> Use custom security groups (true/false)
471
- --sg-workflow-engine <id> Workflow Engine security group ID
472
- --sg-aurora <id> Aurora database security group ID
473
- --sg-rds-proxy <id> RDS Proxy security group ID
474
- --sg-bff-ecs <id> BFF ECS service security group ID
475
- --sg-bastion <id> Bastion host security group ID
476
- --sg-bff-alb <id> BFF ALB security group ID
477
- --sg-semantic-event-engine <id> Semantic Event Engine security group ID
478
-
479
- # Security - IAM Roles
480
- --use-custom-iam-roles <boolean> Use custom IAM roles (true/false)
481
- --iam-workflow-engine-exec <arn> Workflow Engine execution role ARN
482
- --iam-workflow-engine-task <arn> Workflow Engine task role ARN
483
- --iam-bff-ecs-exec <arn> BFF ECS task execution role ARN
484
- --iam-bff-ecs-task <arn> BFF ECS task role ARN
485
- --iam-semantic-event-engine-exec <arn> Semantic Event Engine execution role ARN
486
- --iam-semantic-event-engine-task <arn> Semantic Event Engine task role ARN
487
- --iam-rds-proxy <arn> RDS Proxy role ARN
488
- --iam-studio-memory <arn> Studio Memory role ARN
489
- --iam-studio-notification <arn> Studio Notification role ARN
490
-
491
- # TLS/DNS
492
- --cloudfront-domain <domain> CloudFront custom domain
493
- --cloudfront-cert-arn <arn> CloudFront SSL certificate ARN (us-east-1)
494
- --bff-alb-cert-arn <arn> BFF ALB SSL certificate ARN
495
- --hosted-zone-id <id> Route53 hosted zone ID
496
-
497
- # Hub Integration
498
- --skip-hub Skip Hub integration
499
- --hub-engine-execution-role <arn> Hub Engine Execution Role ARN
500
- --hub-consumer-role <arn> Hub Consumer Role ARN
501
- --hub-admin-role <arn> Hub Admin Role ARN
502
- ```
222
+ networking:
223
+ enableVpcEndpoints: true
224
+ useCustomNetworking: false
225
+ vpcCidr: 10.0.0.0/16
226
+ azCount: 2
503
227
 
504
- **Examples:**
228
+ tls:
229
+ cloudfrontDomain: studio.acme.com
230
+ cloudfrontCertArn: arn:aws:acm:us-east-1:123456789012:certificate/abc123
231
+ bffAlbCertificateArn: arn:aws:acm:us-east-1:123456789012:certificate/def456
232
+ hostedZoneId: Z1234567890ABC
505
233
 
506
- ```bash
507
- # Fully interactive
508
- sembix studio create
234
+ frontend:
235
+ githubAppClientId: Iv1.0123456789abcdef
236
+ githubAppName: sembix-studio-app
237
+ jiraClientId: abc123def456
509
238
 
510
- # With config file
511
- sembix studio create --config production.yaml
239
+ features:
240
+ deployStudioMemory: true
241
+ deployStudioNotifications: false
242
+ enableBffWaf: false
512
243
 
513
- # Skip Hub (add later)
514
- sembix studio create production --repo acme/deploy --skip-hub
244
+ # Hub integration (optional, add after Phase 1)
245
+ hub:
246
+ engineExecutionRoleArn: arn:aws:iam::999888777666:role/HubEngine
247
+ consumerRoleArn: arn:aws:iam::999888777666:role/HubConsumer
248
+ adminRoleArn: arn:aws:iam::999888777666:role/HubAdmin
515
249
  ```
516
250
 
517
- **What it does:**
518
-
519
- 1. Validates repository and environment name
520
- 2. Walks through 9 configuration steps
521
- 3. Creates GitHub Actions environment
522
- 4. Sets environment variables and encrypted secrets
251
+ See [`config.example.yaml`](./config.example.yaml) for complete reference with all options.
523
252
 
524
- See [complete options list](#sembix-studio-create-all-options) below for all 50+ flags.
525
-
526
- #### `sembix studio update [name]`
527
-
528
- Update an existing Sembix Studio environment.
529
-
530
- **Usage:**
253
+ ## Common Workflows
531
254
 
255
+ **First-time setup:**
532
256
  ```bash
533
- sembix studio update production --repo acme/deploy
257
+ sembix studio create --config base.yaml --skip-hub
258
+ # → Run GitHub Actions → Get IAM ARNs → Send to Sembix
259
+ sembix studio add-hub production --repo owner/repo
260
+ # → Run GitHub Actions again → Full deployment
534
261
  ```
535
262
 
536
- **Options:** Same as `create` command
537
-
538
- **Examples:**
539
-
263
+ **Update existing environment:**
540
264
  ```bash
541
- # Add Hub integration
542
- sembix studio update production --repo acme/deploy \
543
- --hub-engine-execution-role arn:aws:iam::123456789012:role/HubEngine
544
-
545
- # Update feature flags
546
- sembix studio update production --repo acme/deploy \
265
+ sembix studio update production --repo owner/repo \
547
266
  --deploy-studio-memory true
548
267
  ```
549
268
 
550
- #### `sembix studio add-hub [name]`
551
-
552
- Add Sembix Hub integration to an existing environment (Phase 2 deployment).
553
-
554
- **Usage:**
555
-
556
- ```bash
557
- sembix studio add-hub production --repo acme/deploy
558
- ```
559
-
560
- **Options:**
561
-
562
- - `-r, --repo <repo>` - Target repository
563
- - `--hub-engine-execution-role <arn>` - Hub Engine Execution Role ARN
564
- - `--hub-consumer-role <arn>` - Hub Consumer Role ARN
565
- - `--hub-admin-role <arn>` - Hub Admin Role ARN
566
- - `--hub-appconfig-role <arn>` - Hub AppConfig Role ARN (optional)
567
- - `--hub-appconfig-app-id <id>` - Hub AppConfig Application ID (optional)
568
- - `--hub-appconfig-env-id <id>` - Hub AppConfig Environment ID (optional)
569
- - `--hub-appconfig-profile-id <id>` - Hub AppConfig Profile ID (optional)
570
-
571
- **Example:**
572
-
573
- ```bash
574
- sembix studio add-hub production \
575
- --repo acme/deploy \
576
- --hub-engine-execution-role arn:aws:iam::999888777666:role/HubEngineRole \
577
- --hub-consumer-role arn:aws:iam::999888777666:role/HubConsumerRole \
578
- --hub-admin-role arn:aws:iam::999888777666:role/HubAdminRole
579
- ```
580
-
581
- #### `sembix studio list [repository]`
582
-
583
- List GitHub Actions environments in a repository.
584
-
585
- **Usage:**
586
-
269
+ **Create multiple environments:**
587
270
  ```bash
588
- # List all your repositories
589
- sembix studio list
590
-
591
- # List environments in specific repository
592
- sembix studio list acme-corp/sembix-deployment
271
+ sembix studio create prod --repo owner/repo --config prod.yaml
272
+ sembix studio create staging --repo owner/repo --config staging.yaml
593
273
  ```
594
274
 
595
275
  ---
596
276
 
597
- ### Studio API Commands
277
+ # Part 2: Environment Interaction
278
+
279
+ ## Concepts
598
280
 
599
- Commands for authenticating with and managing Sembix Studio via API.
281
+ The Sembix CLI provides commands to interact with running Sembix Studio instances. Use these commands to execute workflows, manage projects, and monitor workflow runs.
600
282
 
601
- #### `sembix login [profile]`
283
+ **Two Authentication Methods:**
284
+ 1. **Browser OAuth** - For local development (interactive login)
285
+ 2. **Client Credentials** - For CI/CD (M2M authentication)
602
286
 
603
- Authenticate with Sembix Studio via Cognito OAuth.
287
+ ## Authentication
604
288
 
605
- **Usage:**
289
+ ### Local Development (Browser OAuth)
606
290
 
607
291
  ```bash
608
- # Login with default profile
292
+ # Login (opens browser)
609
293
  sembix login
610
294
 
611
- # Login with specific profile
612
- sembix login production
613
- # or
295
+ # Login to specific profile
614
296
  sembix login --profile production
615
- ```
616
297
 
617
- **What it does:**
618
-
619
- 1. Opens browser for Cognito authentication
620
- 2. Exchanges OAuth code for access tokens
621
- 3. Stores tokens securely in `~/.sembix/tokens/<profile>.json`
622
- 4. Tokens are automatically refreshed when expired
298
+ # Logout
299
+ sembix logout --profile production
623
300
 
624
- #### `sembix logout [profile]`
301
+ # Logout from all profiles
302
+ sembix logout --all
303
+ ```
625
304
 
626
- Log out from Sembix Studio by removing stored tokens.
305
+ Tokens are stored in `~/.sembix/tokens/<profile>.json` and automatically refreshed.
627
306
 
628
- **Usage:**
307
+ ### CI/CD (Client Credentials)
629
308
 
309
+ Set environment variables:
630
310
  ```bash
631
- # Logout from default profile
632
- sembix logout
311
+ export SEMBIX_CLIENT_ID="7a8b9c0d1e2f3g4h"
312
+ export SEMBIX_CLIENT_SECRET="your-secret"
313
+ ```
633
314
 
634
- # Logout from specific profile
635
- sembix logout production
315
+ No login required - CLI automatically uses client credentials when detected.
636
316
 
637
- # Logout from all profiles
638
- sembix logout --all
317
+ **GitHub Actions Example:**
318
+ ```yaml
319
+ - name: Start workflow
320
+ env:
321
+ SEMBIX_CLIENT_ID: ${{ secrets.SEMBIX_M2M_CLIENT_ID }}
322
+ SEMBIX_CLIENT_SECRET: ${{ secrets.SEMBIX_M2M_CLIENT_SECRET }}
323
+ run: |
324
+ sembix workflow start --project-id proj_123 --workflow-id wf_456
639
325
  ```
640
326
 
641
- #### Profile Commands
327
+ ## Command Reference
328
+
329
+ ### Profile Management
642
330
 
643
331
  **`sembix profile list`**
644
332
 
645
- List all configured Studio profiles with authentication status.
333
+ List all configured Studio profiles.
646
334
 
647
335
  ```bash
648
336
  sembix profile list
@@ -650,7 +338,7 @@ sembix profile list
650
338
 
651
339
  **`sembix profile show <name>`**
652
340
 
653
- Show detailed information for a specific profile.
341
+ Show profile details.
654
342
 
655
343
  ```bash
656
344
  sembix profile show production
@@ -658,7 +346,7 @@ sembix profile show production
658
346
 
659
347
  **`sembix profile set-default <name>`**
660
348
 
661
- Set a profile as the default.
349
+ Set default profile.
662
350
 
663
351
  ```bash
664
352
  sembix profile set-default production
@@ -666,7 +354,7 @@ sembix profile set-default production
666
354
 
667
355
  **`sembix profile delete <name>`**
668
356
 
669
- Delete a profile and its stored tokens.
357
+ Delete a profile and its tokens.
670
358
 
671
359
  ```bash
672
360
  sembix profile delete staging
@@ -674,33 +362,17 @@ sembix profile delete staging
674
362
 
675
363
  **`sembix profile set-default-project <profile> <project-id>`**
676
364
 
677
- Set a default project for a profile (allows omitting `--project-id` in commands).
365
+ Set default project for a profile (allows omitting `--project-id` in commands).
678
366
 
679
367
  ```bash
680
368
  sembix profile set-default-project production proj_abc123
681
369
  ```
682
370
 
683
- **`sembix profile get-default-project <profile>`**
684
-
685
- Get the default project for a profile.
686
-
687
- ```bash
688
- sembix profile get-default-project production
689
- ```
690
-
691
- **`sembix profile clear-default-project <profile>`**
692
-
693
- Clear the default project for a profile.
694
-
695
- ```bash
696
- sembix profile clear-default-project production
697
- ```
698
-
699
- #### Project Commands
371
+ ### Project Management
700
372
 
701
373
  **`sembix project list`**
702
374
 
703
- List and search projects in your Studio instance.
375
+ List projects in Studio instance.
704
376
 
705
377
  ```bash
706
378
  # List all projects
@@ -718,13 +390,33 @@ sembix project list --pretty
718
390
 
719
391
  **`sembix project show`**
720
392
 
721
- Show details for a specific project.
393
+ Show project details.
722
394
 
723
395
  ```bash
724
396
  sembix project show --project-id proj_abc123
725
397
  ```
726
398
 
727
- #### Workflow Commands
399
+ ### Workflow Operations
400
+
401
+ **`sembix workflow list`**
402
+
403
+ List workflow instances (definitions).
404
+
405
+ ```bash
406
+ # List all workflows
407
+ sembix workflow list
408
+
409
+ # Filter by project
410
+ sembix workflow list --project-id proj_123
411
+ ```
412
+
413
+ **`sembix workflow template show`**
414
+
415
+ Show workflow template with input variable details (useful for discovering input names).
416
+
417
+ ```bash
418
+ sembix workflow template show --project-id proj_123 --workflow-id wf_456
419
+ ```
728
420
 
729
421
  **`sembix workflow start`**
730
422
 
@@ -734,13 +426,13 @@ Start a workflow instance (creates a new run).
734
426
  # Interactive mode (prompts for project, workflow, inputs)
735
427
  sembix workflow start
736
428
 
737
- # With project ID and workflow ID
429
+ # With project and workflow IDs
738
430
  sembix workflow start --project-id proj_123 --workflow-id wf_456
739
431
 
740
- # With workflow name
432
+ # With workflow name instead of ID
741
433
  sembix workflow start --project-id proj_123 --workflow-name "Deploy"
742
434
 
743
- # With inline JSON inputs
435
+ # With inline JSON inputs (using input variable names)
744
436
  sembix workflow start --project-id proj_123 --workflow-id wf_456 \
745
437
  --inputs '{"environment":"production","version":"1.2.3"}'
746
438
 
@@ -749,31 +441,115 @@ sembix workflow start --project-id proj_123 --workflow-id wf_456 \
749
441
  --inputs @inputs.json
750
442
 
751
443
  # Using default project (set via profile set-default-project)
752
- sembix workflow start --workflow-id wf_456 --inputs '{...}'
444
+ sembix workflow start --workflow-id wf_456 --inputs '{"key":"value"}'
445
+
446
+ # Non-interactive mode
447
+ sembix workflow start --project-id proj_123 --workflow-id wf_456 --no-interactive
753
448
  ```
754
449
 
755
450
  **Options:**
756
-
757
451
  - `-p, --profile <name>` - Profile to use
758
452
  - `--project-id <id>` - Project ID (uses default if not specified)
759
- - `--workflow-id <id>` - Workflow ID (OR use --workflow-name)
760
- - `--workflow-name <name>` - Workflow name (OR use --workflow-id)
761
- - `--inputs <json>` - Input variables as JSON string or @file.json
453
+ - `--workflow-id <id>` - Workflow ID (or use `--workflow-name`)
454
+ - `--workflow-name <name>` - Workflow name (or use `--workflow-id`)
455
+ - `--inputs <json>` - Input variables as JSON or @file.json
762
456
  - `--workspace-id <id>` - Workspace ID (optional)
763
457
  - `--issue-id <id>` - Issue ID (optional)
764
458
  - `--no-interactive` - Disable interactive prompts
765
459
 
766
- **`sembix workflow list`**
460
+ **Input Formats:**
767
461
 
768
- List workflow instances (definitions).
462
+ The `--inputs` flag supports three formats:
769
463
 
770
- ```bash
771
- # List all workflows
772
- sembix workflow list
464
+ 1. **Name-based format (recommended):**
465
+ ```bash
466
+ --inputs '{"repositoryUrl": "https://github.com/acme/repo", "branch": "main"}'
467
+ ```
468
+ - Uses input variable names from the workflow template
469
+ - CLI automatically resolves names to IDs and validates inputs
470
+ - Required fields must be provided with non-empty values
471
+ - Optional fields can be omitted (will be filled with empty strings)
773
472
 
774
- # Filter by project
775
- sembix workflow list --project-id proj_123
776
- ```
473
+ 2. **ID-based format:**
474
+ ```bash
475
+ --inputs '[{"id": "var_123", "instruction": "value"}, {"id": "var_456", "instruction": "main"}]'
476
+ ```
477
+ - Uses input variable IDs directly
478
+ - Useful when you know the exact IDs
479
+ - Still validates required fields and data types
480
+
481
+ 3. **File-based format:**
482
+ ```bash
483
+ --inputs @inputs.json
484
+ ```
485
+ - Reads inputs from a JSON file
486
+ - File can contain name-based or ID-based format
487
+
488
+ **Input Validation:**
489
+
490
+ The CLI validates all inputs before starting the workflow:
491
+
492
+ - **Required fields**: Must have non-empty values
493
+ ```bash
494
+ # Error: Missing required field
495
+ --inputs '{"branch": "main"}'
496
+ # Error: Required input "repositoryUrl" is missing or empty
497
+ ```
498
+
499
+ - **Boolean fields**: Must be `true` or `false` (converted to strings)
500
+ ```bash
501
+ # Valid
502
+ --inputs '{"enabled": true, "dryRun": false}'
503
+ --inputs '{"enabled": "true", "dryRun": "false"}'
504
+ ```
505
+
506
+ - **Optional fields**: Automatically filled with empty strings if not provided
507
+ ```bash
508
+ # Input: Only required fields provided
509
+ --inputs '{"environment": "production"}'
510
+
511
+ # CLI adds optional fields:
512
+ # {"environment": "production", "optionalField": ""}
513
+ ```
514
+
515
+ **Validation Examples:**
516
+
517
+ ```bash
518
+ # ✓ Valid - all required fields provided
519
+ sembix workflow start --project-id proj_123 --workflow-id wf_456 \
520
+ --inputs '{"environment": "production", "version": "1.2.3"}'
521
+
522
+ # ✗ Invalid - missing required field
523
+ sembix workflow start --project-id proj_123 --workflow-id wf_456 \
524
+ --inputs '{"environment": "production"}'
525
+ # Error: Input validation failed:
526
+ # - Required input "version" is missing or empty
527
+
528
+ # ✗ Invalid - boolean field has invalid value
529
+ sembix workflow start --project-id proj_123 --workflow-id wf_456 \
530
+ --inputs '{"enabled": "yes"}'
531
+ # Error: Input validation failed:
532
+ # - Input "enabled" must be true or false (got: yes)
533
+
534
+ # ✓ Valid - optional fields can be omitted
535
+ sembix workflow start --project-id proj_123 --workflow-id wf_456 \
536
+ --inputs '{"environment": "prod"}'
537
+ # CLI automatically adds: {"environment": "prod", "optionalField": ""}
538
+ ```
539
+
540
+ **Interactive Mode:**
541
+
542
+ If `--inputs` is not provided, the CLI enters interactive mode and prompts for each input:
543
+
544
+ ```bash
545
+ sembix workflow start --project-id proj_123 --workflow-id wf_456
546
+
547
+ # Prompts appear:
548
+ # ? environment (required): production
549
+ # ? version (required): 1.2.3
550
+ # ? dryRun (optional): [y/n]
551
+ # ? notes (optional):
552
+ ```
777
553
 
778
554
  **`sembix workflow run list`**
779
555
 
@@ -786,6 +562,9 @@ sembix workflow run list
786
562
  # Filter by workflow
787
563
  sembix workflow run list --workflow-id wf_456
788
564
 
565
+ # Filter by project
566
+ sembix workflow run list --project-id proj_123
567
+
789
568
  # Filter by status
790
569
  sembix workflow run list --status RUNNING
791
570
 
@@ -829,1807 +608,336 @@ sembix workflow run stop --project-id proj_123 \
829
608
  --workflow-id wf_456 --run-id run_789
830
609
  ```
831
610
 
832
- ---
833
-
834
- ### Global Options
835
-
836
- These options work with most commands:
837
-
838
- #### `--token <token>` or `-t <token>`
839
-
840
- Override the GitHub token from all other sources.
611
+ ## Common Workflows
841
612
 
613
+ **Start and monitor a workflow:**
842
614
  ```bash
843
- sembix studio create --token ghp_custom_token
844
- ```
845
-
846
- **Credential Priority:**
847
- 1. `--token` flag (highest)
848
- 2. `GITHUB_TOKEN` environment variable
849
- 3. `~/.sembix/config` (created by `sembix configure`)
850
- 4. `.env` file (lowest)
851
-
852
- #### `--profile <name>` or `-p <name>`
615
+ # Interactive mode (easiest)
616
+ sembix workflow start
853
617
 
854
- Specify which Studio profile to use for API commands.
618
+ # Programmatic mode
619
+ RUN_ID=$(sembix workflow start \
620
+ --project-id proj_123 \
621
+ --workflow-id wf_456 \
622
+ --inputs '{"env":"production"}' \
623
+ | jq -r '.runId')
855
624
 
856
- ```bash
857
- sembix workflow start --profile production
625
+ # Watch until completion
626
+ sembix workflow run status \
627
+ --workflow-id wf_456 \
628
+ --run-id $RUN_ID \
629
+ --watch
858
630
  ```
859
631
 
860
- #### `--output <format>` or `--pretty`
861
-
862
- Set output format for command results.
863
-
864
- **Values:**
865
- - `json` (default) - Machine-readable JSON
866
- - `pretty` - Pretty-printed JSON with colors
867
- - `text` - Human-readable text (where supported)
868
-
632
+ **List recent failures:**
869
633
  ```bash
870
- sembix project list --output pretty
871
- # or shorthand:
872
- sembix project list --pretty
634
+ sembix workflow run list --status FAILED --limit 10
873
635
  ```
874
636
 
875
- #### `--help` or `-h`
876
-
877
- Display help information for a command.
878
-
637
+ **Use default project:**
879
638
  ```bash
880
- sembix --help
881
- sembix studio --help
882
- sembix studio create --help
883
- ```
884
-
885
- #### `--version` or `-V`
886
-
887
- Display the CLI version.
639
+ # Set default project once
640
+ sembix profile set-default-project production proj_123
888
641
 
889
- ```bash
890
- sembix --version
642
+ # Now omit --project-id
643
+ sembix workflow start --workflow-id wf_456
891
644
  ```
892
645
 
893
- ---
894
-
895
- ### Environment Variables
896
-
897
- Configure the CLI via `.env` file or system environment variables:
898
-
899
- ```env
900
- # GitHub Personal Access Token (required for deployment commands)
901
- GITHUB_TOKEN=ghp_your_token_here
902
-
903
- # Default GitHub organization (optional)
904
- DEFAULT_GITHUB_ORG=your-org
646
+ **Use inputs from file:**
647
+ ```bash
648
+ # Create inputs.json
649
+ cat > inputs.json <<EOF
650
+ {
651
+ "repositoryUrl": "https://github.com/acme/repo",
652
+ "branch": "main",
653
+ "environment": "production"
654
+ }
655
+ EOF
905
656
 
906
- # Studio API client credentials (for CI/CD)
907
- SEMBIX_CLIENT_ID=7a8b9c0d1e2f3g4h
908
- SEMBIX_CLIENT_SECRET=abcdef123456...
657
+ # Use file
658
+ sembix workflow start \
659
+ --project-id proj_123 \
660
+ --workflow-id wf_456 \
661
+ --inputs @inputs.json
909
662
  ```
910
663
 
911
664
  ---
912
665
 
913
- ### Exit Codes
914
-
915
- - `0` - Success
916
- - `1` - Error (validation failure, API error, user cancellation)
917
-
918
- ---
919
-
920
- ### <a name="sembix-studio-create-all-options"></a>`sembix studio create` - All Options
921
-
922
- For reference, here's the complete list of all 50+ CLI flags for `sembix studio create`:
923
-
924
- **General:**
925
- - `-t, --token <token>` - GitHub personal access token
926
- - `-c, --config <path>` - Path to YAML configuration file
927
- - `-r, --repo <repo>` - Target repository (owner/repo format)
928
- - `-e, --env <environment>` - Environment name
929
-
930
- **AWS Basic Configuration:**
931
- - `--aws-account-id <id>` - AWS Account ID (12 digits)
932
- - `--aws-region <region>` - AWS Region (e.g., us-east-1)
933
- - `--customer-role-arn <arn>` - GitHub Actions IAM role ARN
934
- - `--terraform-state-bucket <bucket>` - S3 bucket for Terraform state
935
-
936
- **Database:**
937
- - `--database-name <name>` - PostgreSQL database name
938
- - `--database-user <user>` - PostgreSQL database user
939
-
940
- **Networking:**
941
- - `--enable-vpc-endpoints <boolean>` - Enable VPC endpoints (true/false)
942
- - `--use-custom-networking <boolean>` - Use existing VPC (true/false)
943
- - `--vpc-cidr <cidr>` - VPC CIDR block (e.g., 10.0.0.0/16)
944
- - `--public-subnet-cidrs <json>` - Public subnet CIDRs (JSON array)
945
- - `--private-subnet-cidrs <json>` - Private subnet CIDRs (JSON array)
946
- - `--az-count <count>` - Number of AZs (2 or 3)
947
- - `--custom-vpc-id <id>` - Existing VPC ID
948
- - `--custom-public-subnet-ids <ids>` - Existing public subnet IDs (comma-separated)
949
- - `--custom-private-subnet-ids <ids>` - Existing private subnet IDs (comma-separated)
950
-
951
- **Security - Security Groups:**
952
- - `--use-custom-security-groups <boolean>` - Use custom security groups (true/false)
953
- - `--sg-workflow-engine <id>` - Workflow Engine security group ID
954
- - `--sg-aurora <id>` - Aurora database security group ID
955
- - `--sg-rds-proxy <id>` - RDS Proxy security group ID
956
- - `--sg-bff-ecs <id>` - BFF ECS service security group ID
957
- - `--sg-bastion <id>` - Bastion host security group ID
958
- - `--sg-bff-alb <id>` - BFF ALB security group ID
959
-
960
- **Security - IAM Roles:**
961
- - `--use-custom-iam-roles <boolean>` - Use custom IAM roles (true/false)
962
- - `--iam-workflow-engine-exec <arn>` - Workflow Engine execution role ARN
963
- - `--iam-workflow-engine-task <arn>` - Workflow Engine task role ARN
964
- - `--iam-bff-ecs-exec <arn>` - BFF ECS task execution role ARN
965
- - `--iam-bff-ecs-task <arn>` - BFF ECS task role ARN
966
- - `--iam-rds-proxy <arn>` - RDS Proxy role ARN
967
- - `--iam-studio-memory <arn>` - Studio Memory role ARN
968
- - `--iam-studio-notification <arn>` - Studio Notification role ARN
666
+ # Global Configuration
969
667
 
970
- **TLS/DNS:**
971
- - `--cloudfront-domain <domain>` - CloudFront custom domain
972
- - `--cloudfront-cert-arn <arn>` - CloudFront SSL certificate ARN (must be in us-east-1)
973
- - `--bff-alb-cert-arn <arn>` - BFF ALB SSL certificate ARN
974
- - `--hosted-zone-id <id>` - Route53 hosted zone ID
668
+ ## `sembix configure`
975
669
 
976
- **Feature Flags:**
977
- - `--deploy-studio-memory <boolean>` - Deploy Studio Memory service (true/false)
978
- - `--deploy-studio-notifications <boolean>` - Deploy Studio Notifications (true/false)
979
- - `--enable-bff-waf <boolean>` - Enable WAF for BFF (true/false)
670
+ Interactive configuration for GitHub credentials and Studio profiles.
980
671
 
981
- **Frontend:**
982
- - `--github-app-client-id <id>` - GitHub App OAuth client ID
983
- - `--github-app-name <name>` - GitHub App name
984
- - `--jira-client-id <id>` - Jira OAuth client ID
672
+ ```bash
673
+ sembix configure
674
+ ```
985
675
 
986
- **Hub Integration (Step 9):**
987
- - `--skip-hub` - Skip Hub integration configuration
988
- - `--hub-engine-execution-role <arn>` - Hub Engine Execution Role ARN
989
- - `--hub-consumer-role <arn>` - Hub Consumer Role ARN
990
- - `--hub-admin-role <arn>` - Hub Admin Role ARN
991
- - `--hub-appconfig-role <arn>` - Hub AppConfig Role ARN
992
- - `--hub-appconfig-app-id <id>` - Hub AppConfig Application ID
993
- - `--hub-appconfig-env-id <id>` - Hub AppConfig Environment ID
994
- - `--hub-appconfig-profile-id <id>` - Hub AppConfig Profile ID
676
+ Prompts for:
677
+ 1. GitHub Personal Access Token
678
+ 2. Default GitHub organization (optional)
679
+ 3. Optionally: Studio profile configuration
680
+ - Profile name
681
+ - Studio API URL
682
+ - Cognito User Pool ID, Client ID, Region, Domain
995
683
 
996
- ---
684
+ Saves to `~/.sembix/config` with 0600 permissions.
997
685
 
998
- ## Usage Examples
686
+ ## Environment Variables
999
687
 
1000
- Real-world examples showing different ways to use the CLI.
688
+ **GitHub (for environment management):**
689
+ - `GITHUB_TOKEN` - GitHub Personal Access Token
690
+ - `DEFAULT_GITHUB_ORG` - Default GitHub organization
1001
691
 
1002
- ### Basic Usage Patterns
692
+ **Studio (for environment interaction):**
693
+ - `SEMBIX_DEFAULT_PROFILE` - Default Studio profile
694
+ - `SEMBIX_CLIENT_ID` - M2M client ID (for CI/CD)
695
+ - `SEMBIX_CLIENT_SECRET` - M2M client secret (for CI/CD)
1003
696
 
1004
- #### 1. Fully Interactive (Beginner-Friendly)
697
+ **Profile Selection Priority:**
698
+ 1. `--profile` CLI flag (highest)
699
+ 2. `SEMBIX_DEFAULT_PROFILE` environment variable
700
+ 3. `default_profile` in `~/.sembix/config`
701
+ 4. First available profile (lowest)
1005
702
 
1006
- Perfect for first-time users:
703
+ ## Global Options
1007
704
 
705
+ **Output Formatting:**
1008
706
  ```bash
1009
- sembix studio create
707
+ --output <format> # json, pretty, or text
708
+ --pretty # Shorthand for --output pretty
1010
709
  ```
1011
710
 
1012
- **What happens:**
1013
- - Prompts for repository selection
1014
- - Prompts for environment name
1015
- - Walks through all 9 configuration steps with explanations
1016
- - Creates environment with all settings
1017
-
1018
- #### 2. Specify Repository and Environment
1019
-
1020
- Fast setup when you know both values:
1021
-
711
+ **Examples:**
1022
712
  ```bash
1023
- sembix studio create production --repo acme-corp/sembix-deployment
713
+ sembix project list --pretty
714
+ sembix workflow list --output json
1024
715
  ```
1025
716
 
1026
- **What happens:**
1027
- - ✅ Validates repository exists
1028
- - ✅ Validates environment name format
1029
- - ✅ Checks environment doesn't already exist
1030
- - Skips repository and name prompts
1031
- - Walks through configuration steps
1032
- - Creates environment
1033
-
1034
- #### 3. Using Config Files
1035
-
1036
- For repeatable, version-controlled setups:
1037
-
717
+ **Other:**
1038
718
  ```bash
1039
- # Create environment from config file
1040
- sembix studio create --config production.yaml
1041
-
1042
- # Override specific values
1043
- sembix studio create --config base.yaml \
1044
- --env custom-name \
1045
- --aws-account-id 123456789012
719
+ --help, -h # Show help
720
+ --version, -V # Show version
1046
721
  ```
1047
722
 
1048
- ### Common Workflows
723
+ ---
724
+
725
+ # Troubleshooting
1049
726
 
1050
- #### Workflow 1: First-Time Setup (Learning Mode)
727
+ ## Authentication Issues
1051
728
 
729
+ **GitHub token required:**
1052
730
  ```bash
1053
- # Step 1: Configure credentials
1054
731
  sembix configure
1055
-
1056
- # Step 2: Create environment interactively
1057
- sembix studio create
1058
-
1059
- # Follow all prompts, read explanations...
1060
-
1061
- # Step 3: Deploy via GitHub Actions
1062
- # Go to https://github.com/owner/repo/actions
1063
- # Run deployment workflow
1064
- # Copy Hub role ARNs from output
1065
-
1066
- # Step 4: Add Hub integration
1067
- sembix studio add-hub
1068
-
1069
- # Select same repository and environment
1070
- # Enter Hub role ARNs
1071
732
  ```
1072
733
 
1073
- #### Workflow 2: Experienced User (Fast Mode)
734
+ **GitHub token invalid:**
735
+ 1. Create new token at https://github.com/settings/tokens
736
+ 2. Required scopes: `repo`, `workflow`
737
+ 3. Run `sembix configure` to update
1074
738
 
739
+ **Studio authentication required:**
1075
740
  ```bash
1076
- # Create with known values
1077
- sembix studio create prod --repo acme/deploy
1078
-
1079
- # Answer remaining prompts
1080
- # ... deployment happens in GitHub Actions ...
1081
-
1082
- # Add Hub with known values
1083
- sembix studio add-hub prod --repo acme/deploy
1084
-
1085
- # Enter Hub role ARNs
741
+ sembix login --profile production
1086
742
  ```
1087
743
 
1088
- #### Workflow 3: CI/CD / Automation
1089
-
1090
- For scripts and automation:
1091
-
744
+ **Studio token expired:**
1092
745
  ```bash
1093
- #!/bin/bash
1094
-
1095
- REPO="acme-corp/sembix-deployment"
1096
- ENV="client-${CLIENT_NAME}-production"
1097
-
1098
- # Create environment (with config file)
1099
- sembix studio create "${ENV}" \
1100
- --repo "${REPO}" \
1101
- --config base-config.yaml \
1102
- --token "${GITHUB_TOKEN}"
1103
-
1104
- # Later, after deployment...
1105
- sembix studio add-hub "${ENV}" \
1106
- --repo "${REPO}" \
1107
- --token "${GITHUB_TOKEN}"
746
+ sembix logout --profile production
747
+ sembix login --profile production
1108
748
  ```
1109
749
 
1110
- #### Workflow 4: Multiple Environments
750
+ ## Common Errors
1111
751
 
1112
- Setting up multiple environments for the same repository:
752
+ **Repository not found:**
753
+ - Verify repository name format: `owner/repo`
754
+ - Check token has access to repository
755
+ - For orgs, configure SSO authorization
1113
756
 
757
+ **Environment already exists:**
1114
758
  ```bash
1115
- # Production
1116
- sembix studio create production --repo acme/deploy
1117
-
1118
- # Staging
1119
- sembix studio create staging --repo acme/deploy
1120
-
1121
- # Development
1122
- sembix studio create development --repo acme/deploy
759
+ # Update existing environment
760
+ sembix studio update production --repo owner/repo
1123
761
 
1124
- # List all environments
1125
- sembix studio list acme/deploy
762
+ # Or use different name
763
+ sembix studio create production-v2 --repo owner/repo
1126
764
  ```
1127
765
 
1128
- ### Profile Management Examples
1129
-
1130
- #### Working with Multiple Studio Instances
766
+ **Invalid environment name:**
767
+ - Must be lowercase letters, numbers, hyphens
768
+ - Minimum 3 characters
769
+ - No spaces or special characters
1131
770
 
771
+ **Profile not found:**
1132
772
  ```bash
1133
- # Configure multiple profiles
1134
- sembix configure # Profile name: production
1135
- sembix configure # Profile name: staging
773
+ sembix configure # Add profile
774
+ sembix profile list # List available profiles
775
+ ```
1136
776
 
1137
- # Set default profile
1138
- sembix profile set-default production
777
+ **Workflow not found:**
778
+ ```bash
779
+ sembix workflow list --project-id proj_123 # List available workflows
780
+ sembix workflow start # Use interactive mode
781
+ ```
1139
782
 
1140
- # Set default projects for each profile
1141
- sembix profile set-default-project production proj_prod_123
1142
- sembix profile set-default-project staging proj_stage_456
783
+ **Client credentials not working:**
784
+ 1. Verify credentials have no extra spaces
785
+ 2. Check required scopes:
786
+ - `sembix-api/projects.read`
787
+ - `sembix-api/workflows.read`
788
+ - `sembix-api/workflows.execute`
789
+ 3. Test locally:
790
+ ```bash
791
+ export SEMBIX_CLIENT_ID="your-id"
792
+ export SEMBIX_CLIENT_SECRET="your-secret"
793
+ sembix login
794
+ ```
1143
795
 
1144
- # List all profiles
1145
- sembix profile list
796
+ ## Getting Help
1146
797
 
1147
- # Login to each profile
1148
- sembix login production
1149
- sembix login staging
798
+ ```bash
799
+ sembix --help # Global help
800
+ sembix studio --help # Studio commands help
801
+ sembix studio create --help # Specific command help
802
+ sembix workflow start --help # Workflow command help
1150
803
 
1151
- # Use different profiles for different workflows
1152
- sembix workflow start --profile production --workflow-id wf_456
1153
- sembix workflow start --profile staging --workflow-id wf_789
804
+ sembix --version # Check CLI version
805
+ sembix profile list # Check profile status
806
+ sembix studio list # Verify GitHub access
1154
807
  ```
1155
808
 
1156
- ### Error Handling Examples
1157
-
1158
- #### Missing GitHub Token
809
+ ---
1159
810
 
1160
- ```bash
1161
- $ sembix studio create
1162
- ✗ GitHub token is required. Please provide it using one of these methods:
1163
- 1. Run: sembix configure
1164
- 2. Set GITHUB_TOKEN environment variable
1165
- 3. Pass --token flag to the command
1166
- ```
811
+ # Development
1167
812
 
1168
- **Solution:**
813
+ ## Project Structure
1169
814
 
1170
- ```bash
1171
- sembix configure
815
+ ```
816
+ sembix-cli/
817
+ ├── src/
818
+ │ ├── commands/ # Command implementations
819
+ │ ├── prompts/ # Interactive prompts
820
+ │ ├── services/ # Cognito auth, GitHub API
821
+ │ ├── utils/ # Utilities (config, UI)
822
+ │ ├── types.ts # TypeScript types
823
+ │ ├── config-schema.ts # Zod schemas
824
+ │ └── index.ts # CLI entry point
825
+ ├── config.example.yaml # Example config file
826
+ └── package.json
1172
827
  ```
1173
828
 
1174
- #### Invalid Repository Format
829
+ ## Scripts
1175
830
 
1176
831
  ```bash
1177
- $ sembix studio create prod --repo invalid_format
1178
- Invalid repository format. Use: owner/repo
832
+ npm run build # Compile TypeScript
833
+ npm run dev # Run with tsx (development)
834
+ npm run type-check # Type check only
835
+ npm test # Run tests
1179
836
  ```
1180
837
 
1181
- #### Repository Not Found
838
+ ## Adding Commands
1182
839
 
1183
- ```bash
1184
- $ sembix studio create prod --repo nonexistent/repo
1185
- Repository 'nonexistent/repo' not found or not accessible.
840
+ 1. Create file in `src/commands/`
841
+ 2. Add prompts in `src/prompts/` if needed
842
+ 3. Register command in `src/index.ts`
843
+ 4. Add types to `src/types.ts`
844
+ 5. Add validation to `src/config-schema.ts`
1186
845
 
1187
- 💡 Make sure:
1188
- • The repository name is correct (owner/repo)
1189
- • Your GitHub token has access to this repository
1190
- ```
846
+ ---
1191
847
 
1192
- #### Invalid Environment Name
848
+ # Complete Studio Options
1193
849
 
1194
- ```bash
1195
- $ sembix studio create "My Environment" --repo acme/deploy
1196
- ✗ Invalid environment name. Must be lowercase letters, numbers, and hyphens (min 3 chars).
1197
- ```
850
+ <a name="complete-studio-options"></a>
1198
851
 
1199
- #### Environment Already Exists
852
+ All options for `sembix studio create` and `sembix studio update`:
1200
853
 
1201
- ```bash
1202
- $ sembix studio create production --repo acme/deploy
1203
- Environment 'production' already exists in acme/deploy
854
+ **General:**
855
+ - `-t, --token <token>` - GitHub token
856
+ - `-c, --config <path>` - YAML config file
857
+ - `-r, --repo <repo>` - Repository (owner/repo)
858
+ - `-e, --env <name>` - Environment name
1204
859
 
1205
- 💡 Tip:
1206
- Use a different environment name
1207
- Or update the existing environment with: sembix studio update
1208
- ```
860
+ **AWS:**
861
+ - `--aws-account-id <id>` - AWS Account ID (12 digits)
862
+ - `--aws-region <region>` - AWS Region
863
+ - `--customer-role-arn <arn>` - GitHub Actions IAM role ARN
864
+ - `--terraform-state-bucket <bucket>` - Terraform state S3 bucket
1209
865
 
1210
- #### Authentication Errors (Studio API)
866
+ **Database:**
867
+ - `--database-name <name>` - PostgreSQL database name
868
+ - `--database-user <user>` - PostgreSQL database user
1211
869
 
1212
- ```bash
1213
- # Error: Token expired
1214
- $ sembix workflow start
1215
- Authentication required. Please run: sembix login
1216
- ```
870
+ **Networking:**
871
+ - `--enable-vpc-endpoints <boolean>` - Enable VPC endpoints
872
+ - `--use-custom-networking <boolean>` - Use existing VPC
873
+ - `--vpc-cidr <cidr>` - VPC CIDR block
874
+ - `--public-subnet-cidrs <json>` - Public subnet CIDRs (JSON array)
875
+ - `--private-subnet-cidrs <json>` - Private subnet CIDRs (JSON array)
876
+ - `--az-count <count>` - Number of AZs (2 or 3)
877
+ - `--custom-vpc-id <id>` - Existing VPC ID
878
+ - `--custom-public-subnet-ids <ids>` - Existing public subnet IDs (comma-separated)
879
+ - `--custom-private-subnet-ids <ids>` - Existing private subnet IDs (comma-separated)
1217
880
 
1218
- **Solution:**
881
+ **Security Groups:**
882
+ - `--use-custom-security-groups <boolean>` - Use custom security groups
883
+ - `--sg-workflow-engine <id>` - Workflow Engine SG
884
+ - `--sg-aurora <id>` - Aurora SG
885
+ - `--sg-rds-proxy <id>` - RDS Proxy SG
886
+ - `--sg-bff-ecs <id>` - BFF ECS SG
887
+ - `--sg-bastion <id>` - Bastion SG
888
+ - `--sg-bff-alb <id>` - BFF ALB SG
889
+ - `--sg-semantic-event-engine <id>` - Semantic Event Engine SG
890
+
891
+ **IAM Roles:**
892
+ - `--use-custom-iam-roles <boolean>` - Use custom IAM roles
893
+ - `--iam-workflow-engine-exec <arn>` - Workflow Engine execution role ARN
894
+ - `--iam-workflow-engine-task <arn>` - Workflow Engine task role ARN
895
+ - `--iam-bff-ecs-exec <arn>` - BFF ECS execution role ARN
896
+ - `--iam-bff-ecs-task <arn>` - BFF ECS task role ARN
897
+ - `--iam-semantic-event-engine-exec <arn>` - Semantic Event Engine execution role ARN
898
+ - `--iam-semantic-event-engine-task <arn>` - Semantic Event Engine task role ARN
899
+ - `--iam-rds-proxy <arn>` - RDS Proxy role ARN
900
+ - `--iam-studio-memory <arn>` - Studio Memory role ARN
901
+ - `--iam-studio-notification <arn>` - Studio Notification role ARN
1219
902
 
1220
- ```bash
1221
- sembix login --profile production
1222
- ```
903
+ **TLS/DNS:**
904
+ - `--cloudfront-domain <domain>` - CloudFront custom domain
905
+ - `--cloudfront-cert-arn <arn>` - CloudFront certificate ARN (us-east-1)
906
+ - `--bff-alb-cert-arn <arn>` - BFF ALB certificate ARN
907
+ - `--hosted-zone-id <id>` - Route53 hosted zone ID
1223
908
 
1224
- ### Workflow Execution Patterns
909
+ **Features:**
910
+ - `--deploy-studio-memory <boolean>` - Deploy Studio Memory service
911
+ - `--deploy-studio-notifications <boolean>` - Deploy Studio Notifications
912
+ - `--enable-bff-waf <boolean>` - Enable WAF for BFF
1225
913
 
1226
- #### Start and Monitor a Workflow
914
+ **Frontend:**
915
+ - `--github-app-client-id <id>` - GitHub App OAuth client ID
916
+ - `--github-app-name <name>` - GitHub App name
917
+ - `--jira-client-id <id>` - Jira OAuth client ID
1227
918
 
1228
- ```bash
1229
- # Start workflow and capture run ID
1230
- RUN_ID=$(sembix workflow start \
1231
- --project-id proj_123 \
1232
- --workflow-id wf_456 \
1233
- --inputs '{"env":"production"}' \
1234
- | grep "Run ID" | awk '{print $3}')
919
+ **Hub Integration:**
920
+ - `--skip-hub` - Skip Hub integration
921
+ - `--hub-engine-execution-role <arn>` - Hub Engine Execution Role ARN
922
+ - `--hub-consumer-role <arn>` - Hub Consumer Role ARN
923
+ - `--hub-admin-role <arn>` - Hub Admin Role ARN
924
+ - `--hub-appconfig-role <arn>` - Hub AppConfig Role ARN
925
+ - `--hub-appconfig-app-id <id>` - Hub AppConfig Application ID
926
+ - `--hub-appconfig-env-id <id>` - Hub AppConfig Environment ID
927
+ - `--hub-appconfig-profile-id <id>` - Hub AppConfig Profile ID
1235
928
 
1236
- # Watch until completion
1237
- sembix workflow run status \
1238
- --workflow-id wf_456 \
1239
- --run-id $RUN_ID \
1240
- --watch
1241
- ```
929
+ ---
1242
930
 
1243
- #### List Recent Failures
931
+ # License
1244
932
 
1245
- ```bash
1246
- sembix workflow run list \
1247
- --status FAILED \
1248
- --limit 10
1249
- ```
933
+ Proprietary - Sembix AI
1250
934
 
1251
- #### Monitor Specific Workflow
1252
-
1253
- ```bash
1254
- sembix workflow run list \
1255
- --workflow-id wf_456 \
1256
- --status RUNNING
1257
- ```
1258
-
1259
- #### Using Workflow Inputs from Files
1260
-
1261
- ```bash
1262
- # Create inputs.json
1263
- cat > inputs.json <<EOF
1264
- {
1265
- "environment": "production",
1266
- "version": "1.2.3",
1267
- "config": {
1268
- "debug": false,
1269
- "replicas": 3
1270
- }
1271
- }
1272
- EOF
1273
-
1274
- # Use file in workflow start
1275
- sembix workflow start \
1276
- --project-id proj_123 \
1277
- --workflow-id wf_456 \
1278
- --inputs @inputs.json
1279
- ```
1280
-
1281
- ### Best Practices
1282
-
1283
- #### ✅ DO
1284
-
1285
- - Use `--repo` and `--env` for repeated operations
1286
- - Validate with `sembix studio list` first
1287
- - Use descriptive environment names (client-production, staging-v2)
1288
- - Store GitHub token in `~/.sembix/config` via `sembix configure`
1289
- - Keep environment names lowercase with hyphens
1290
- - Use config files for version-controlled setups
1291
- - Set default projects per profile for faster workflow execution
1292
- - Use `--pretty` for human-readable output
1293
- - Use `--watch` to monitor long-running workflows
1294
-
1295
- #### ❌ DON'T
1296
-
1297
- - Don't use uppercase in environment names
1298
- - Don't use spaces or special characters
1299
- - Don't share your GitHub token or client credentials
1300
- - Don't create environments without verifying repo access first
1301
- - Don't forget to run deployment between create and add-hub
1302
- - Don't commit sensitive credentials to git
1303
- - Don't use production credentials in development
1304
-
1305
- ### CI/CD Integration Examples
1306
-
1307
- #### GitHub Actions
1308
-
1309
- ```yaml
1310
- name: Deploy via Sembix
1311
-
1312
- on:
1313
- push:
1314
- branches: [main]
1315
-
1316
- jobs:
1317
- deploy:
1318
- runs-on: ubuntu-latest
1319
- steps:
1320
- - name: Install Sembix CLI
1321
- run: npm install -g @sembix/cli
1322
-
1323
- - name: Start Deployment Workflow
1324
- env:
1325
- SEMBIX_CLIENT_ID: ${{ secrets.SEMBIX_M2M_CLIENT_ID }}
1326
- SEMBIX_CLIENT_SECRET: ${{ secrets.SEMBIX_M2M_CLIENT_SECRET }}
1327
- run: |
1328
- sembix workflow start \
1329
- --profile production \
1330
- --project-id ${{ vars.PROJECT_ID }} \
1331
- --workflow-id ${{ vars.WORKFLOW_ID }} \
1332
- --inputs '{"version":"${{ github.sha }}"}'
1333
- ```
1334
-
1335
- #### GitLab CI
1336
-
1337
- ```yaml
1338
- deploy:
1339
- image: node:20
1340
- script:
1341
- - npm install -g @sembix/cli
1342
- - |
1343
- sembix workflow start \
1344
- --profile production \
1345
- --project-id ${PROJECT_ID} \
1346
- --workflow-id ${WORKFLOW_ID} \
1347
- --inputs "{\"version\":\"${CI_COMMIT_SHA}\"}"
1348
- variables:
1349
- SEMBIX_CLIENT_ID: ${M2M_CLIENT_ID}
1350
- SEMBIX_CLIENT_SECRET: ${M2M_CLIENT_SECRET}
1351
- ```
1352
-
1353
- ### Output Formatting Examples
1354
-
1355
- ```bash
1356
- # JSON output (default) - for scripts/automation
1357
- sembix project list --output json
1358
-
1359
- # Pretty JSON - for human reading
1360
- sembix project list --output pretty
1361
- # or shorthand:
1362
- sembix project list --pretty
1363
-
1364
- # Text output - for terminal display
1365
- sembix project list --output text
1366
- ```
1367
-
1368
- ### Quick Reference Cheat Sheet
1369
-
1370
- ```bash
1371
- # GitHub Deployment
1372
- sembix configure # First-time setup
1373
- sembix studio create # Interactive create
1374
- sembix studio create prod --repo owner/repo # Quick create
1375
- sembix studio add-hub prod --repo owner/repo # Add Hub integration
1376
- sembix studio list owner/repo # List environments
1377
-
1378
- # Studio API
1379
- sembix configure # Configure profile
1380
- sembix login # Authenticate
1381
- sembix profile list # List profiles
1382
- sembix profile set-default-project prod proj_123 # Set default project
1383
-
1384
- # Projects & Workflows
1385
- sembix project list # List projects
1386
- sembix workflow start # Start workflow (interactive)
1387
- sembix workflow run list # List workflow runs
1388
- sembix workflow run status --workflow-id wf_456 --run-id run_789 --watch
1389
-
1390
- # Troubleshooting
1391
- sembix --version # Check CLI version
1392
- sembix studio list owner/repo # Verify repo access
1393
- sembix profile list # Check profile status
1394
- sembix login --profile production # Re-authenticate
1395
- ```
1396
-
1397
- ## Studio CLI
1398
-
1399
- The Sembix CLI now supports direct integration with Sembix Studio instances for workflow execution and management.
1400
-
1401
- ### Studio Configuration
1402
-
1403
- Configure a Studio profile to connect to a Sembix Studio instance using the unified configure command:
1404
-
1405
- ```bash
1406
- sembix configure
1407
- ```
1408
-
1409
- This interactive command will first prompt for GitHub credentials, then optionally prompt you to configure a Studio profile with:
1410
- - **Profile name** (default: "default")
1411
- - **Studio API URL** (e.g., https://studio.example.com)
1412
- - **Cognito User Pool ID** (e.g., us-east-1_ABC123)
1413
- - **Cognito Client ID**
1414
- - **Cognito Region**
1415
- - **Cognito Domain** (e.g., https://auth.example.com)
1416
-
1417
- ### Authentication
1418
-
1419
- The Sembix CLI supports two authentication methods:
1420
- 1. **Browser-based OAuth** - For developers on local machines
1421
- 2. **Client Credentials** - For CI/CD pipelines and automated workflows
1422
-
1423
- #### Local Development (Browser-based OAuth)
1424
-
1425
- Authenticate with a Studio instance using browser-based OAuth:
1426
-
1427
- ```bash
1428
- # Login to default profile
1429
- sembix login
1430
-
1431
- # Login to specific profile
1432
- sembix login --profile production
1433
-
1434
- # Logout from profile
1435
- sembix logout --profile production
1436
-
1437
- # Logout from all profiles
1438
- sembix logout --all
1439
- ```
1440
-
1441
- **What happens during login:**
1442
- 1. Opens your default browser to Cognito hosted UI
1443
- 2. You authenticate with your Studio credentials
1444
- 3. Tokens are securely stored in `~/.sembix/tokens/<profile>.json`
1445
- 4. Tokens are automatically refreshed when expired
1446
-
1447
- #### CI/CD Pipelines (Client Credentials)
1448
-
1449
- For automated workflows, use OAuth 2.0 Client Credentials flow:
1450
-
1451
- **Prerequisites:**
1452
- - Obtain M2M (machine-to-machine) client credentials from your administrator:
1453
- - Client ID (e.g., `7a8b9c0d1e2f3g4h`)
1454
- - Client Secret (keep secure!)
1455
- - Required OAuth scopes:
1456
- - `sembix-api/projects.read` - List projects
1457
- - `sembix-api/workflows.read` - View workflows and runs
1458
- - `sembix-api/workflows.execute` - Start/stop workflows
1459
-
1460
- **Setup:**
1461
-
1462
- 1. **Add credentials to your CI/CD secrets:**
1463
-
1464
- GitHub Actions:
1465
- ```yaml
1466
- # In repository settings → Secrets and variables → Actions
1467
- SEMBIX_CLIENT_ID=7a8b9c0d1e2f3g4h5i6j7k8l
1468
- SEMBIX_CLIENT_SECRET=abcdef123456...
1469
- ```
1470
-
1471
- GitLab CI:
1472
- ```yaml
1473
- # In repository settings → CI/CD → Variables
1474
- SEMBIX_CLIENT_ID=7a8b9c0d1e2f3g4h5i6j7k8l
1475
- SEMBIX_CLIENT_SECRET=abcdef123456...
1476
- ```
1477
-
1478
- 2. **Use in your workflow:**
1479
-
1480
- ```yaml
1481
- - name: Start workflow
1482
- env:
1483
- SEMBIX_CLIENT_ID: ${{ secrets.SEMBIX_M2M_CLIENT_ID }}
1484
- SEMBIX_CLIENT_SECRET: ${{ secrets.SEMBIX_M2M_CLIENT_SECRET }}
1485
- run: |
1486
- sembix workflow start \
1487
- --project-id abc123 \
1488
- --workflow-id def456 \
1489
- --inputs '{"key": "value"}'
1490
- ```
1491
-
1492
- **How it works:**
1493
- - The CLI automatically detects `SEMBIX_CLIENT_ID` and `SEMBIX_CLIENT_SECRET` environment variables
1494
- - Authenticates using OAuth 2.0 Client Credentials flow
1495
- - No browser or interactive login needed
1496
- - Tokens obtained on-demand (not stored)
1497
-
1498
- **Testing credentials locally:**
1499
- ```bash
1500
- export SEMBIX_CLIENT_ID="your-client-id"
1501
- export SEMBIX_CLIENT_SECRET="your-client-secret"
1502
-
1503
- # Verify credentials work
1504
- sembix login
1505
- # Output: "Client credentials detected... Client credentials are valid!"
1506
- ```
1507
-
1508
- **Security best practices:**
1509
- - Never commit credentials to git
1510
- - Use CI/CD secret management (GitHub Secrets, AWS Secrets Manager, etc.)
1511
- - Rotate client secrets regularly (every 90 days recommended)
1512
- - Use separate credentials for different environments (dev, staging, prod)
1513
-
1514
- See the [CI/CD Setup Guide](./docs/CI-CD-SETUP.md) for complete examples and troubleshooting.
1515
-
1516
- ### Profile Management
1517
-
1518
- Manage Studio profiles:
1519
-
1520
- ```bash
1521
- # List all profiles
1522
- sembix profile list
1523
-
1524
- # Show profile details
1525
- sembix profile show production
1526
-
1527
- # Set default profile
1528
- sembix profile set-default production
1529
-
1530
- # Delete profile
1531
- sembix profile delete staging
1532
- ```
1533
-
1534
- **Profile list output:**
1535
- ```
1536
- Sembix Studio Profiles
1537
-
1538
- Name API URL Auth Status
1539
- ──────────────────────────────────────────────────────
1540
- * default https://studio.example.com ✓ Authenticated
1541
- production https://prod.example.com ✗ Not authenticated
1542
- staging https://staging.example.com ✓ Authenticated
1543
-
1544
- * = default profile
1545
- ```
1546
-
1547
- ### Profile Project Defaults
1548
-
1549
- Set default projects for profiles to avoid specifying `--project-id` repeatedly.
1550
-
1551
- **Set default project:**
1552
- ```bash
1553
- sembix profile set-default-project <profile> <project-id>
1554
-
1555
- # Example
1556
- sembix profile set-default-project production proj_abc123
1557
- ```
1558
-
1559
- **Get default project:**
1560
- ```bash
1561
- sembix profile get-default-project <profile>
1562
-
1563
- # Example
1564
- sembix profile get-default-project production
1565
- # Output: proj_abc123
1566
- ```
1567
-
1568
- **Clear default project:**
1569
- ```bash
1570
- sembix profile clear-default-project <profile>
1571
-
1572
- # Example
1573
- sembix profile clear-default-project production
1574
- ```
1575
-
1576
- **Usage with workflow commands:**
1577
- ```bash
1578
- # Set default project
1579
- sembix profile set-default-project production proj_abc123
1580
-
1581
- # Now you can omit --project-id
1582
- sembix workflow start --workflow-id wf_456 --inputs '{...}'
1583
- # Uses proj_abc123 automatically
1584
- ```
1585
-
1586
- ### Project Management
1587
-
1588
- List and view projects in your Studio instance.
1589
-
1590
- **List all projects:**
1591
- ```bash
1592
- # List all projects
1593
- sembix project list
1594
-
1595
- # Filter by name
1596
- sembix project list --name "My Project"
1597
-
1598
- # Filter by IDs
1599
- sembix project list --ids "proj_123,proj_456"
1600
-
1601
- # With specific profile
1602
- sembix project list --profile production
1603
- ```
1604
-
1605
- **Show project details:**
1606
- ```bash
1607
- sembix project show --project-id proj_abc123
1608
-
1609
- # With specific profile
1610
- sembix project show --project-id proj_abc123 --profile production
1611
- ```
1612
-
1613
- **Output:**
1614
- ```json
1615
- {
1616
- "projectId": "proj_abc123",
1617
- "name": "My Project",
1618
- "description": "Project description",
1619
- "state": "ACTIVE",
1620
- "createdAt": "2024-01-15T10:00:00Z",
1621
- "workflowPackConfigured": true
1622
- }
1623
- ```
1624
-
1625
- ### Workflow Operations
1626
-
1627
- Execute and manage workflows:
1628
-
1629
- #### Start a Workflow
1630
-
1631
- ```bash
1632
- # Interactive mode (prompts for project, workflow, and inputs)
1633
- sembix workflow start
1634
-
1635
- # With project ID and workflow ID
1636
- sembix workflow start --project-id abc123 --workflow-id def456
1637
-
1638
- # With workflow name instead of ID
1639
- sembix workflow start --project-id abc123 --workflow-name "Deploy to Production"
1640
-
1641
- # Start with inline JSON inputs
1642
- sembix workflow start --project-id abc123 --workflow-id def456 --inputs '{"key": "value"}'
1643
-
1644
- # Start with inputs from file
1645
- sembix workflow start --project-id abc123 --workflow-id def456 --inputs @inputs.json
1646
-
1647
- # Non-interactive mode (skip prompts)
1648
- sembix workflow start --project-id abc123 --workflow-id def456 --no-interactive
1649
-
1650
- # Using default project (set via profile set-default-project)
1651
- sembix workflow start --workflow-id def456 --inputs '{...}'
1652
-
1653
- # Start with workspace and issue context
1654
- sembix workflow start \
1655
- --project-id abc123 \
1656
- --workflow-id def456 \
1657
- --workspace-id ws-789 \
1658
- --issue-id issue-101 \
1659
- --inputs '{"param": "value"}'
1660
-
1661
- # Use specific profile
1662
- sembix workflow start \
1663
- --profile production \
1664
- --project-id abc123 \
1665
- --workflow-id def456 \
1666
- --inputs '{"key": "value"}'
1667
- ```
1668
-
1669
- **Example inputs.json:**
1670
- ```json
1671
- {
1672
- "inputVariables": {
1673
- "repositoryUrl": "https://github.com/acme/repo",
1674
- "branch": "main"
1675
- },
1676
- "workspaceId": "ws-123",
1677
- "workspaceName": "My Workspace",
1678
- "issueId": "issue-456",
1679
- "issueKey": "PROJ-123"
1680
- }
1681
- ```
1682
-
1683
- #### Check Workflow Status
1684
-
1685
- ```bash
1686
- # Get current status
1687
- sembix workflow run status --workflow-id wf_456 --run-id run_789
1688
-
1689
- # Watch workflow until completion (polls every 5 seconds)
1690
- sembix workflow run status --workflow-id wf_456 --run-id run_789 --watch
1691
- ```
1692
-
1693
- **Status output:**
1694
- ```
1695
- Workflow Run Status
1696
-
1697
- Run ID: run-789
1698
- Workflow ID: def456
1699
- Status: RUNNING
1700
- Progress: 45%
1701
- Created: 2024-01-15 10:30:00
1702
- Creator: user-123
1703
- ```
1704
-
1705
- #### List Workflow Runs
1706
-
1707
- ```bash
1708
- # List workflow instances (definitions)
1709
- sembix workflow list
1710
-
1711
- # Filter by project
1712
- sembix workflow list --project-id proj_123
1713
-
1714
- # Filter by template IDs
1715
- sembix workflow list --workflow-template-ids "tmpl_1,tmpl_2"
1716
-
1717
- # Show workflow instance details
1718
- sembix workflow show --project-id proj_123 --workflow-id wf_456
1719
-
1720
- # List workflow runs (executions) - excludes subflows by default
1721
- sembix workflow run list
1722
-
1723
- # Filter by workflow
1724
- sembix workflow run list --workflow-id wf_456
1725
-
1726
- # Filter by project
1727
- sembix workflow run list --project-id proj_123
1728
-
1729
- # Filter by status
1730
- sembix workflow run list --status RUNNING
1731
-
1732
- # Include sub-workflow runs
1733
- sembix workflow run list --include-subflows
1734
-
1735
- # Filter to top-level runs only
1736
- sembix workflow run list --parent-id NULL
1737
-
1738
- # Pagination
1739
- sembix workflow run list --limit 20 --offset 10
1740
-
1741
- # Show specific run details
1742
- sembix workflow run show --workflow-id wf_456 --run-id run_789
1743
-
1744
- # Watch run details until completion
1745
- sembix workflow run show --workflow-id wf_456 --run-id run_789 --watch
1746
- ```
1747
-
1748
- **List output:**
1749
- ```
1750
- Workflow Runs
1751
-
1752
- Run ID Workflow ID Status Progress Created
1753
- ────────────────────────────────────────────────────────
1754
- run-789 def456 RUNNING 45% 2 hours ago
1755
- run-788 def456 COMPLETED 100% 1 day ago
1756
- run-787 abc123 FAILED 30% 2 days ago
1757
-
1758
- Showing 1-3 of 15 results
1759
- ```
1760
-
1761
- #### Stop a Workflow Run
1762
-
1763
- ```bash
1764
- sembix workflow run stop --project-id proj_123 --workflow-id wf_456 --run-id run_789
1765
- ```
1766
-
1767
- ### Common Workflow Patterns
1768
-
1769
- **1. Start and monitor a workflow:**
1770
- ```bash
1771
- # Start workflow and capture run ID
1772
- RUN_ID=$(sembix workflow start \
1773
- --project-id abc123 \
1774
- --workflow-id def456 \
1775
- --inputs '{"key": "value"}' \
1776
- | grep "Run ID" | awk '{print $3}')
1777
-
1778
- # Watch until completion
1779
- sembix workflow run status \
1780
- --workflow-id def456 \
1781
- --run-id $RUN_ID \
1782
- --watch
1783
- ```
1784
-
1785
- **2. List recent failures:**
1786
- ```bash
1787
- sembix workflow run list \
1788
- --status FAILED \
1789
- --limit 10
1790
- ```
1791
-
1792
- **3. Monitor specific workflow:**
1793
- ```bash
1794
- sembix workflow run list \
1795
- --workflow-id def456 \
1796
- --status RUNNING
1797
- ```
1798
-
1799
- ### Output Formatting
1800
-
1801
- Control output format for all commands using global flags.
1802
-
1803
- **Available formats:**
1804
- - `json` (default) - Machine-readable JSON output
1805
- - `pretty` - Pretty-printed JSON with colors and indentation
1806
- - `text` - Human-readable text output (where applicable)
1807
-
1808
- **Usage:**
1809
-
1810
- ```bash
1811
- # JSON output (default)
1812
- sembix workflow run list --workflow-id wf_456
1813
-
1814
- # Pretty-printed JSON
1815
- sembix workflow run list --workflow-id wf_456 --output pretty
1816
- # or shorthand:
1817
- sembix workflow run list --workflow-id wf_456 --pretty
1818
-
1819
- # Text output
1820
- sembix project list --output text
1821
- ```
1822
-
1823
- **Examples:**
1824
-
1825
- ```bash
1826
- # JSON (default) - for scripts/automation
1827
- $ sembix project show --project-id proj_123
1828
- {"projectId":"proj_123","name":"My Project","state":"ACTIVE",...}
1829
-
1830
- # Pretty JSON - for human reading
1831
- $ sembix project show --project-id proj_123 --pretty
1832
- {
1833
- "projectId": "proj_123",
1834
- "name": "My Project",
1835
- "state": "ACTIVE",
1836
- ...
1837
- }
1838
-
1839
- # Text - for terminal display
1840
- $ sembix project list --output text
1841
- Projects:
1842
- 1. My Project (proj_123) - ACTIVE
1843
- 2. Another Project (proj_456) - ACTIVE
1844
- ```
1845
-
1846
- **Global flags:**
1847
- - `--output <format>` - Set output format: json, pretty, or text
1848
- - `--pretty` - Shorthand for `--output pretty`
1849
-
1850
- ### Error Handling
1851
-
1852
- **Authentication errors:**
1853
- ```bash
1854
- # If you see "Authentication required" or "Token expired"
1855
- sembix login --profile production
1856
- ```
1857
-
1858
- **Profile not found:**
1859
- ```bash
1860
- # Configure the profile first
1861
- sembix configure
1862
- # Choose to configure Studio profile with name: production
1863
- ```
1864
-
1865
- **Invalid inputs:**
1866
- ```bash
1867
- # Validate your JSON syntax
1868
- cat inputs.json | jq .
1869
- ```
1870
-
1871
- ## Workflow
1872
-
1873
- ### Two-Phased Deployment Process
1874
-
1875
- ```
1876
- ╔═══════════════════════════════════════════════════════════════════╗
1877
- ║ PHASE 1: BOOTSTRAP DEPLOYMENT ║
1878
- ╚═══════════════════════════════════════════════════════════════════╝
1879
-
1880
- ┌─────────────────────────────────────────────────┐
1881
- │ 1. Create Environment (Skip Hub) │
1882
- │ sembix studio create --skip-hub │
1883
- │ • Configure environment (Steps 1-8) │
1884
- │ • Skip Hub integration (Step 9) │
1885
- │ • Creates GitHub Actions environment │
1886
- └─────────────────────────────────────────────────┘
1887
-
1888
- ┌─────────────────────────────────────────────────┐
1889
- │ 2. Bootstrap Deployment via GitHub Actions │
1890
- │ • Go to repo → Actions → Run workflow │
1891
- │ • Deploys initial Terraform infrastructure │
1892
- │ • Creates IAM roles in your AWS account │
1893
- │ • Copy IAM ARNs from deployment output │
1894
- └─────────────────────────────────────────────────┘
1895
-
1896
- ┌─────────────────────────────────────────────────┐
1897
- │ 3. Coordinate with Sembix Support │
1898
- │ • Send IAM ARNs to Sembix support │
1899
- │ • Wait for Sembix to configure Hub │
1900
- │ • Receive Hub role ARNs from support: │
1901
- │ - Hub Engine Execution Role ARN │
1902
- │ - Hub Consumer Role ARN │
1903
- │ - Hub Admin Role ARN │
1904
- │ - Hub AppConfig Role ARN + IDs │
1905
- └─────────────────────────────────────────────────┘
1906
-
1907
- ╔═══════════════════════════════════════════════════════════════════╗
1908
- ║ PHASE 2: HUB INTEGRATION & FULL DEPLOYMENT ║
1909
- ╚═══════════════════════════════════════════════════════════════════╝
1910
-
1911
- ┌─────────────────────────────────────────────────┐
1912
- │ 4. Add Hub Integration │
1913
- │ sembix studio add-hub <environment> │
1914
- │ • Provide Hub role ARNs from support │
1915
- │ • Updates GitHub Actions environment │
1916
- │ • Configures cross-account access │
1917
- └─────────────────────────────────────────────────┘
1918
-
1919
- ┌─────────────────────────────────────────────────┐
1920
- │ 5. Full Deployment via GitHub Actions │
1921
- │ • Go to repo → Actions → Run workflow │
1922
- │ • Completes full Sembix Studio deployment │
1923
- │ • Enables Hub cross-account access │
1924
- │ • ✅ Studio environment fully operational │
1925
- └─────────────────────────────────────────────────┘
1926
- ```
1927
-
1928
- ## Configuration Priority
1929
-
1930
- The CLI follows this priority chain for configuration values:
1931
-
1932
- ```
1933
- CLI Flags > Config File > Interactive Prompts > Defaults
1934
- ```
1935
-
1936
- **Examples:**
1937
-
1938
- ```bash
1939
- # Config file provides base, CLI flags override specific values
1940
- sembix studio create --config base.yaml --env custom-name
1941
-
1942
- # Interactive prompts only for missing values
1943
- sembix studio create --repo acme/deploy --aws-account-id 123456789012
1944
- # Will prompt for all other fields
1945
-
1946
- # Fully automated (no prompts)
1947
- sembix studio create --config complete.yaml
1948
- # No prompts if config file is complete
1949
- ```
1950
-
1951
- ## Config File Reference
1952
-
1953
- See [`config.example.yaml`](./config.example.yaml) for a complete, documented example.
1954
-
1955
- **Minimal config:**
1956
-
1957
- ```yaml
1958
- repository:
1959
- owner: acme-corp
1960
- repo: sembix-deployment
1961
-
1962
- environmentName: production
1963
- awsAccountId: "123456789012"
1964
- awsRegion: us-east-1
1965
- customerRoleArn: arn:aws:iam::123456789012:role/GitHubActionsDeployRole
1966
- terraformStateBucket: my-terraform-state-bucket
1967
-
1968
- database:
1969
- name: sembix_studio
1970
- user: sembix_studio_user
1971
-
1972
- tls:
1973
- cloudfrontDomain: studio.acme.com
1974
- cloudfrontCertArn: arn:aws:acm:us-east-1:123456789012:certificate/abc123
1975
- bffAlbCertificateArn: arn:aws:acm:us-east-1:123456789012:certificate/def456
1976
- hostedZoneId: Z1234567890ABC
1977
-
1978
- frontend:
1979
- githubAppClientId: Iv1.0123456789abcdef
1980
- githubAppName: sembix-studio-app
1981
- jiraClientId: abc123def456
1982
- ```
1983
-
1984
- **Complete config with all options:**
1985
-
1986
- ```yaml
1987
- # See config.example.yaml for:
1988
- # - Networking configuration (VPC, subnets)
1989
- # - Custom security groups
1990
- # - Custom IAM roles
1991
- # - Feature flags
1992
- # - Hub integration
1993
- # - All advanced options
1994
- ```
1995
-
1996
- ## Use Cases
1997
-
1998
- ### 1. First-Time Setup (Interactive Learning)
1999
-
2000
- Perfect for understanding all configuration options:
2001
-
2002
- ```bash
2003
- sembix studio create
2004
- ```
2005
-
2006
- Follow all 9 steps with detailed explanations.
2007
-
2008
- ### 2. Rapid Iteration (Config Files)
2009
-
2010
- For creating multiple similar environments:
2011
-
2012
- ```bash
2013
- # Create base config once
2014
- cp config.example.yaml clients/base.yaml
2015
- # Edit base.yaml with common settings
2016
-
2017
- # Create client-specific environments
2018
- sembix studio create --config clients/base.yaml --env client-abc-prod
2019
- sembix studio create --config clients/base.yaml --env client-xyz-prod
2020
- ```
2021
-
2022
- ### 3. CI/CD Automation
2023
-
2024
- For automated environment creation in pipelines:
2025
-
2026
- ```bash
2027
- #!/bin/bash
2028
- CLIENT_NAME=$1
2029
- sembix studio create "${CLIENT_NAME}-production" \
2030
- --config ci/base-config.yaml \
2031
- --token "$GITHUB_TOKEN" \
2032
- --aws-account-id "$CLIENT_AWS_ACCOUNT" \
2033
- --cloudfront-domain "studio.${CLIENT_NAME}.example.com"
2034
- ```
2035
-
2036
- ### 4. Infrastructure as Code
2037
-
2038
- Version control your environment configurations:
2039
-
2040
- ```
2041
- configs/
2042
- ├── base.yaml # Common settings
2043
- ├── production.yaml # Production overrides
2044
- ├── staging.yaml # Staging overrides
2045
- └── development.yaml # Dev overrides
2046
- ```
2047
-
2048
- ```bash
2049
- # Create from version-controlled configs
2050
- sembix studio create --config configs/production.yaml
2051
- sembix studio create --config configs/staging.yaml
2052
- ```
2053
-
2054
- ### 5. Hub Integration After Deployment
2055
-
2056
- Add Hub configuration after initial deployment:
2057
-
2058
- ```bash
2059
- # Step 1: Create without Hub
2060
- sembix studio create production --repo acme/deploy --skip-hub
2061
-
2062
- # Step 2: Deploy and get Hub ARNs
2063
-
2064
- # Step 3: Add Hub integration
2065
- sembix studio update production --repo acme/deploy \
2066
- --hub-engine-execution-role arn:aws:iam::123456789012:role/HubEngine \
2067
- --hub-consumer-role arn:aws:iam::123456789012:role/HubConsumer \
2068
- --hub-admin-role arn:aws:iam::123456789012:role/HubAdmin
2069
- ```
2070
-
2071
- ## Development
2072
-
2073
- ### Project Structure
2074
-
2075
- ```
2076
- sembix-cli/
2077
- ├── src/
2078
- │ ├── commands/ # Command implementations
2079
- │ │ ├── setup.ts # Environment create command
2080
- │ │ ├── update.ts # Environment update command
2081
- │ │ └── hub-integration.ts # Deprecated hub command
2082
- │ ├── prompts/ # Interactive prompts
2083
- │ │ ├── environment-setup.ts # Main setup prompts
2084
- │ │ ├── hub-integration-step.ts # Hub integration prompts
2085
- │ │ └── hub-integration.ts # Deprecated hub prompts
2086
- │ ├── utils/ # Utility modules
2087
- │ │ ├── github.ts # GitHub API client
2088
- │ │ ├── ui.ts # Terminal UI utilities
2089
- │ │ └── config-loader.ts # Config file loading & merging
2090
- │ ├── types.ts # TypeScript types
2091
- │ ├── config-schema.ts # Zod schemas for config validation
2092
- │ ├── config.ts # Configuration management
2093
- │ └── index.ts # CLI entry point
2094
- ├── config.example.yaml # Example config file
2095
- ├── package.json
2096
- ├── tsconfig.json
2097
- ├── .env.example
2098
- └── README.md
2099
- ```
2100
-
2101
- ### Scripts
2102
-
2103
- ```bash
2104
- npm run build # Compile TypeScript to JavaScript
2105
- npm run dev # Run in development mode with tsx
2106
- npm run type-check # Type check without emitting files
2107
- ```
2108
-
2109
- ### Adding New Commands
2110
-
2111
- 1. Create a new file in `src/commands/`
2112
- 2. Implement the command logic
2113
- 3. Add prompts in `src/prompts/` if needed
2114
- 4. Register the command in `src/index.ts`
2115
-
2116
- Example:
2117
-
2118
- ```typescript
2119
- // src/commands/my-command.ts
2120
- export async function myCommand(githubToken: string, options: Record<string, any>): Promise<void> {
2121
- // Command implementation
2122
- }
2123
-
2124
- // src/index.ts
2125
- studio
2126
- .command('my-command')
2127
- .description('Description of my command')
2128
- .option('-r, --repo <repo>', 'Target repository')
2129
- .action(async (options) => {
2130
- const { myCommand } = await import('./commands/my-command.js');
2131
- await myCommand(config.githubToken, options);
2132
- });
2133
- ```
2134
-
2135
- ## Troubleshooting
2136
-
2137
- Comprehensive troubleshooting guide for common issues.
2138
-
2139
- ### Authentication Issues
2140
-
2141
- #### "GitHub token is required"
2142
-
2143
- **Error:**
2144
- ```
2145
- ✗ GitHub token is required. Please provide it using one of these methods:
2146
- 1. Run: sembix configure
2147
- 2. Set GITHUB_TOKEN environment variable
2148
- 3. Pass --token flag to the command
2149
- ```
2150
-
2151
- **Solution:**
2152
- ```bash
2153
- # Easiest method (recommended)
2154
- sembix configure
2155
-
2156
- # Alternative: Create .env file
2157
- echo "GITHUB_TOKEN=ghp_your_token_here" > .env
2158
-
2159
- # Or pass token directly
2160
- sembix studio create --token ghp_your_token_here
2161
- ```
2162
-
2163
- #### "Failed to create environment: Bad credentials"
2164
-
2165
- **Cause:** GitHub token is invalid or missing required scopes.
2166
-
2167
- **Solution:**
2168
- 1. Create a new Personal Access Token at: https://github.com/settings/tokens
2169
- 2. Required scopes:
2170
- - ✅ `repo` (all sub-scopes)
2171
- - ✅ `workflow`
2172
- 3. Update your configuration:
2173
- ```bash
2174
- sembix configure
2175
- ```
2176
-
2177
- #### "Authentication required" (Studio API)
2178
-
2179
- **Error:**
2180
- ```
2181
- ✗ Authentication required. Please run: sembix login
2182
- ```
2183
-
2184
- **Solution:**
2185
- ```bash
2186
- # Login with default profile
2187
- sembix login
2188
-
2189
- # Or specific profile
2190
- sembix login --profile production
2191
-
2192
- # If tokens expired, re-authenticate
2193
- sembix logout --profile production
2194
- sembix login --profile production
2195
- ```
2196
-
2197
- #### Browser did not open (Studio login)
2198
-
2199
- **Error:** Browser window doesn't open during `sembix login`
2200
-
2201
- **Solution:**
2202
- 1. Manually copy the URL displayed in terminal
2203
- 2. Open it in your browser
2204
- 3. Complete authentication within 5 minutes
2205
- 4. If timeout occurs, run `sembix login` again
2206
-
2207
- ### GitHub API Issues
2208
-
2209
- #### "No repositories found"
2210
-
2211
- **Cause:** GitHub token doesn't have access to repositories.
2212
-
2213
- **Solution:**
2214
- 1. Verify token has `repo` scope
2215
- 2. Check organization access:
2216
- - GitHub Settings → Personal Access Tokens → Your token → Configure SSO (if applicable)
2217
- - Click "Authorize" for your organization
2218
- 3. Verify repository name is correct (use `owner/repo` format)
2219
-
2220
- #### "Repository not found or not accessible"
2221
-
2222
- **Error:**
2223
- ```
2224
- ✗ Repository 'owner/repo' not found or not accessible.
2225
- ```
2226
-
2227
- **Solution:**
2228
- ```bash
2229
- # Verify repository name format
2230
- sembix studio list # Lists accessible repositories
2231
-
2232
- # Check token permissions
2233
- # Go to: https://github.com/settings/tokens
2234
- # Ensure 'repo' scope is enabled
2235
-
2236
- # If using organization repos, configure SSO
2237
- ```
2238
-
2239
- #### "Environment already exists"
2240
-
2241
- **Error:**
2242
- ```
2243
- ✗ Environment 'production' already exists in owner/repo
2244
- ```
2245
-
2246
- **Solution:**
2247
- ```bash
2248
- # Option 1: Update existing environment
2249
- sembix studio update production --repo owner/repo
2250
-
2251
- # Option 2: Use different environment name
2252
- sembix studio create production-v2 --repo owner/repo
2253
-
2254
- # Option 3: Delete and recreate (not recommended)
2255
- # Delete manually in GitHub UI, then:
2256
- sembix studio create production --repo owner/repo
2257
- ```
2258
-
2259
- ### Studio API Issues
2260
-
2261
- #### "Profile not found"
2262
-
2263
- **Error:**
2264
- ```
2265
- ✗ Profile 'production' not found
2266
- ```
2267
-
2268
- **Solution:**
2269
- ```bash
2270
- # List configured profiles
2271
- sembix profile list
2272
-
2273
- # Configure the profile
2274
- sembix configure
2275
- # Choose to configure Studio profile with name: production
2276
- ```
2277
-
2278
- #### "Cannot connect to Studio API"
2279
-
2280
- **Error:** Connection refused or timeout errors
2281
-
2282
- **Solution:**
2283
- 1. Verify API URL in profile configuration:
2284
- ```bash
2285
- sembix profile show production
2286
- ```
2287
-
2288
- 2. Check network connectivity:
2289
- ```bash
2290
- curl https://studio.example.com/health
2291
- ```
2292
-
2293
- 3. Reconfigure profile if URL is incorrect:
2294
- ```bash
2295
- sembix configure
2296
- # Use same profile name to update
2297
- ```
2298
-
2299
- #### "401 Unauthorized"
2300
-
2301
- **Error:** API returns 401 error
2302
-
2303
- **Solution:**
2304
- ```bash
2305
- # Token expired - re-authenticate
2306
- sembix login --profile production
2307
-
2308
- # If still failing, logout and login again
2309
- sembix logout --profile production
2310
- sembix login --profile production
2311
- ```
2312
-
2313
- #### "Workflow not found"
2314
-
2315
- **Error:**
2316
- ```
2317
- ✗ Workflow 'wf_456' not found
2318
- ```
2319
-
2320
- **Solution:**
2321
- ```bash
2322
- # List available workflows
2323
- sembix workflow list --project-id proj_123
2324
-
2325
- # Or use interactive mode to search
2326
- sembix workflow start
2327
- ```
2328
-
2329
- ### Common Errors
2330
-
2331
- #### "Failed to encrypt secret"
2332
-
2333
- **Error:** libsodium encryption error
2334
-
2335
- **Solution:**
2336
- ```bash
2337
- # Reinstall dependencies
2338
- rm -rf node_modules
2339
- npm install
2340
-
2341
- # If still failing, try:
2342
- npm install libsodium-wrappers --save
2343
- ```
2344
-
2345
- #### "Invalid YAML syntax"
2346
-
2347
- **Error:** When using config files
2348
-
2349
- **Solution:**
2350
- ```bash
2351
- # Validate YAML syntax
2352
- npm install -g js-yaml
2353
- js-yaml config.yaml
2354
-
2355
- # Or use online validator: yamllint.com
2356
-
2357
- # Common issues:
2358
- # - Incorrect indentation (use spaces, not tabs)
2359
- # - Missing quotes around special characters
2360
- # - Malformed arrays/objects
2361
- ```
2362
-
2363
- #### "Invalid environment name"
2364
-
2365
- **Error:**
2366
- ```
2367
- ✗ Invalid environment name. Must be lowercase letters, numbers, and hyphens (min 3 chars).
2368
- ```
2369
-
2370
- **Rules:**
2371
- - Lowercase letters only
2372
- - Numbers allowed
2373
- - Hyphens allowed (not at start/end)
2374
- - No spaces or special characters
2375
- - Minimum 3 characters
2376
-
2377
- **Valid examples:**
2378
- - `production`
2379
- - `client-abc-staging`
2380
- - `dev-environment-2`
2381
-
2382
- **Invalid examples:**
2383
- - `Production` (uppercase)
2384
- - `My Environment` (spaces)
2385
- - `prod_env` (underscores)
2386
-
2387
- #### "Permission denied writing tokens"
2388
-
2389
- **Error:** Cannot write to ~/.sembix directory
2390
-
2391
- **Solution:**
2392
- ```bash
2393
- # Check directory permissions
2394
- ls -la ~/.sembix
2395
-
2396
- # Fix permissions
2397
- chmod 700 ~/.sembix
2398
- chmod 600 ~/.sembix/tokens/*
2399
-
2400
- # If directory doesn't exist
2401
- mkdir -p ~/.sembix/tokens
2402
- chmod 700 ~/.sembix
2403
- ```
2404
-
2405
- #### "Invalid input format" (Workflows)
2406
-
2407
- **Error:** Workflow input validation failed
2408
-
2409
- **Solution:**
2410
- ```bash
2411
- # Validate JSON syntax
2412
- echo '{"key":"value"}' | jq .
2413
-
2414
- # Use file for complex inputs
2415
- cat inputs.json | jq . # Validate
2416
- sembix workflow start --project-id proj_123 --workflow-id wf_456 --inputs @inputs.json
2417
-
2418
- # Check required vs optional inputs
2419
- sembix workflow template show --project-id proj_123 --workflow-id wf_456
2420
- ```
2421
-
2422
- ### Configuration Issues
2423
-
2424
- #### Config file not found
2425
-
2426
- **Error:**
2427
- ```
2428
- ✗ Config file not found: production.yaml
2429
- ```
2430
-
2431
- **Solution:**
2432
- ```bash
2433
- # Use absolute path
2434
- sembix studio create --config /full/path/to/production.yaml
2435
-
2436
- # Or relative to current directory
2437
- sembix studio create --config ./configs/production.yaml
2438
-
2439
- # Verify file exists
2440
- ls -la production.yaml
2441
- ```
2442
-
2443
- #### Config validation failed
2444
-
2445
- **Error:** Config file validation errors
2446
-
2447
- **Solution:**
2448
- 1. Check config.example.yaml for correct format
2449
- 2. Ensure all required fields are present
2450
- 3. Validate data types (strings, booleans, numbers)
2451
- 4. Check ARN formats match AWS patterns
2452
- 5. Verify CIDR blocks are valid
2453
-
2454
- ### Build/Installation Issues
2455
-
2456
- #### "Cannot find module"
2457
-
2458
- **Error:** Module resolution errors
2459
-
2460
- **Solution:**
2461
- ```bash
2462
- # Reinstall dependencies
2463
- rm -rf node_modules package-lock.json
2464
- npm install
2465
-
2466
- # Rebuild TypeScript
2467
- npm run build
2468
-
2469
- # If still failing, check Node version
2470
- node --version # Should be 20 or higher
2471
- ```
2472
-
2473
- #### "Command not found: sembix"
2474
-
2475
- **Error:** CLI not in PATH after installation
2476
-
2477
- **Solution:**
2478
- ```bash
2479
- # Global install
2480
- npm install -g @sembix/cli
2481
-
2482
- # Verify installation
2483
- which sembix
2484
- sembix --version
2485
-
2486
- # If using npm link (development)
2487
- npm link
2488
-
2489
- # Add npm global bin to PATH if needed
2490
- export PATH="$PATH:$(npm config get prefix)/bin"
2491
- ```
2492
-
2493
- ### CI/CD Issues
2494
-
2495
- #### Client credentials not working
2496
-
2497
- **Error:** SEMBIX_CLIENT_ID and SEMBIX_CLIENT_SECRET set but authentication fails
2498
-
2499
- **Solution:**
2500
- 1. Verify credentials are correct (no extra spaces)
2501
- 2. Check client has required scopes:
2502
- - `sembix-api/projects.read`
2503
- - `sembix-api/workflows.read`
2504
- - `sembix-api/workflows.execute`
2505
- 3. Test credentials locally:
2506
- ```bash
2507
- export SEMBIX_CLIENT_ID="your-client-id"
2508
- export SEMBIX_CLIENT_SECRET="your-client-secret"
2509
- sembix login # Should show "Client credentials detected..."
2510
- ```
2511
-
2512
- #### Environment variables not recognized
2513
-
2514
- **Error:** CI/CD pipeline can't find credentials
2515
-
2516
- **Solution:**
2517
- ```bash
2518
- # GitHub Actions: Use secrets
2519
- env:
2520
- SEMBIX_CLIENT_ID: ${{ secrets.SEMBIX_M2M_CLIENT_ID }}
2521
- SEMBIX_CLIENT_SECRET: ${{ secrets.SEMBIX_M2M_CLIENT_SECRET }}
2522
-
2523
- # GitLab CI: Use variables
2524
- variables:
2525
- SEMBIX_CLIENT_ID: ${M2M_CLIENT_ID}
2526
- SEMBIX_CLIENT_SECRET: ${M2M_CLIENT_SECRET}
2527
-
2528
- # Verify secrets are set in CI/CD settings
2529
- ```
2530
-
2531
- ### Getting Help
2532
-
2533
- If you encounter an issue not covered here:
2534
-
2535
- 1. **Check version:**
2536
- ```bash
2537
- sembix --version
2538
- ```
2539
-
2540
- 2. **Enable verbose output:**
2541
- ```bash
2542
- sembix studio create --verbose # If supported
2543
- ```
2544
-
2545
- 3. **Check logs:**
2546
- - GitHub token permissions
2547
- - API endpoint reachability
2548
- - Config file syntax
2549
-
2550
- 4. **Common debugging steps:**
2551
- ```bash
2552
- # Verify GitHub access
2553
- sembix studio list
2554
-
2555
- # Check profile status
2556
- sembix profile list
2557
-
2558
- # Test authentication
2559
- sembix login --profile production
2560
-
2561
- # Validate config file
2562
- js-yaml config.yaml
2563
- ```
2564
-
2565
- 5. **Contact support:**
2566
- - Provide error message
2567
- - Include CLI version
2568
- - Share (sanitized) config file if applicable
2569
-
2570
- ## Advanced Topics
2571
-
2572
- ### Partial Updates
2573
-
2574
- The `update` command supports partial updates - only provide the flags you want to change:
2575
-
2576
- ```bash
2577
- # Only update feature flags
2578
- sembix studio update prod --repo acme/deploy \
2579
- --deploy-studio-memory true \
2580
- --enable-bff-waf false
2581
-
2582
- # Only update Hub integration
2583
- sembix studio update prod --repo acme/deploy \
2584
- --hub-consumer-role arn:aws:iam::123456789012:role/NewConsumer
2585
- ```
2586
-
2587
- ### Config File Inheritance
2588
-
2589
- Create a base config and override specific values:
2590
-
2591
- ```bash
2592
- # base.yaml has common settings
2593
- # production.yaml imports and overrides
2594
-
2595
- sembix studio create --config base.yaml --config production.yaml
2596
- # (Note: Multiple --config flags not yet supported, use CLI flags for overrides)
2597
-
2598
- # Current approach:
2599
- sembix studio create --config base.yaml \
2600
- --env production \
2601
- --cloudfront-domain studio.prod.acme.com
2602
- ```
2603
-
2604
- ### Batch Operations
2605
-
2606
- Create multiple environments with a script:
2607
-
2608
- ```bash
2609
- #!/bin/bash
2610
- for CLIENT in client-a client-b client-c; do
2611
- sembix studio create "${CLIENT}-production" \
2612
- --config base.yaml \
2613
- --cloudfront-domain "studio.${CLIENT}.example.com" \
2614
- --aws-account-id "${CLIENT_AWS_ACCOUNTS[$CLIENT]}"
2615
- done
2616
- ```
2617
-
2618
- ## License
2619
-
2620
- Proprietary - Sembix AI
2621
-
2622
- ## Support
935
+ # Support
2623
936
 
2624
937
  For issues or questions, contact the Sembix team or open an issue in the repository.
2625
938
 
2626
- ## See Also
2627
-
2628
- For additional detailed documentation, see these files included in the package:
2629
-
2630
- - [QUICKSTART.md](./QUICKSTART.md) - Step-by-step quick start guide with detailed walkthroughs
2631
- - [USAGE-EXAMPLES.md](./USAGE-EXAMPLES.md) - Comprehensive real-world usage examples and patterns
2632
- - [COMMANDS.md](./COMMANDS.md) - Complete command reference with all options and examples
2633
- - [config.example.yaml](./config.example.yaml) - Fully annotated configuration file example
939
+ # See Also
2634
940
 
2635
- **Note:** After installing the package (`npm install -g @sembix/cli`), these files are available in your global node_modules directory. The README provides comprehensive documentation, but these supplementary files offer additional depth and examples.
941
+ - [config.example.yaml](./config.example.yaml) - Complete YAML configuration reference
942
+ - [CLAUDE.md](./CLAUDE.md) - Development guide for contributors
943
+ - [CI/CD Setup Guide](./docs/CI-CD-SETUP.md) - CI/CD integration examples