@sembix/cli 1.5.0 → 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,137 +608,269 @@ sembix workflow run stop --project-id proj_123 \
829
608
  --workflow-id wf_456 --run-id run_789
830
609
  ```
831
610
 
832
- ---
611
+ ## Common Workflows
612
+
613
+ **Start and monitor a workflow:**
614
+ ```bash
615
+ # Interactive mode (easiest)
616
+ sembix workflow start
617
+
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')
833
624
 
834
- ### Global Options
625
+ # Watch until completion
626
+ sembix workflow run status \
627
+ --workflow-id wf_456 \
628
+ --run-id $RUN_ID \
629
+ --watch
630
+ ```
835
631
 
836
- These options work with most commands:
632
+ **List recent failures:**
633
+ ```bash
634
+ sembix workflow run list --status FAILED --limit 10
635
+ ```
837
636
 
838
- #### `--token <token>` or `-t <token>`
637
+ **Use default project:**
638
+ ```bash
639
+ # Set default project once
640
+ sembix profile set-default-project production proj_123
839
641
 
840
- Override the GitHub token from all other sources.
642
+ # Now omit --project-id
643
+ sembix workflow start --workflow-id wf_456
644
+ ```
841
645
 
646
+ **Use inputs from file:**
842
647
  ```bash
843
- sembix studio create --token ghp_custom_token
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
656
+
657
+ # Use file
658
+ sembix workflow start \
659
+ --project-id proj_123 \
660
+ --workflow-id wf_456 \
661
+ --inputs @inputs.json
844
662
  ```
845
663
 
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)
664
+ ---
851
665
 
852
- #### `--profile <name>` or `-p <name>`
666
+ # Global Configuration
853
667
 
854
- Specify which Studio profile to use for API commands.
668
+ ## `sembix configure`
669
+
670
+ Interactive configuration for GitHub credentials and Studio profiles.
855
671
 
856
672
  ```bash
857
- sembix workflow start --profile production
673
+ sembix configure
858
674
  ```
859
675
 
860
- #### `--output <format>` or `--pretty`
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
683
+
684
+ Saves to `~/.sembix/config` with 0600 permissions.
685
+
686
+ ## Environment Variables
687
+
688
+ **GitHub (for environment management):**
689
+ - `GITHUB_TOKEN` - GitHub Personal Access Token
690
+ - `DEFAULT_GITHUB_ORG` - Default GitHub organization
691
+
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)
861
696
 
862
- Set output format for command results.
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)
863
702
 
864
- **Values:**
865
- - `json` (default) - Machine-readable JSON
866
- - `pretty` - Pretty-printed JSON with colors
867
- - `text` - Human-readable text (where supported)
703
+ ## Global Options
868
704
 
705
+ **Output Formatting:**
706
+ ```bash
707
+ --output <format> # json, pretty, or text
708
+ --pretty # Shorthand for --output pretty
709
+ ```
710
+
711
+ **Examples:**
869
712
  ```bash
870
- sembix project list --output pretty
871
- # or shorthand:
872
713
  sembix project list --pretty
714
+ sembix workflow list --output json
873
715
  ```
874
716
 
875
- #### `--help` or `-h`
717
+ **Other:**
718
+ ```bash
719
+ --help, -h # Show help
720
+ --version, -V # Show version
721
+ ```
722
+
723
+ ---
724
+
725
+ # Troubleshooting
876
726
 
877
- Display help information for a command.
727
+ ## Authentication Issues
878
728
 
729
+ **GitHub token required:**
879
730
  ```bash
880
- sembix --help
881
- sembix studio --help
882
- sembix studio create --help
731
+ sembix configure
883
732
  ```
884
733
 
885
- #### `--version` or `-V`
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
886
738
 
887
- Display the CLI version.
739
+ **Studio authentication required:**
740
+ ```bash
741
+ sembix login --profile production
742
+ ```
888
743
 
744
+ **Studio token expired:**
889
745
  ```bash
890
- sembix --version
746
+ sembix logout --profile production
747
+ sembix login --profile production
891
748
  ```
892
749
 
893
- ---
750
+ ## Common Errors
894
751
 
895
- ### Environment Variables
752
+ **Repository not found:**
753
+ - Verify repository name format: `owner/repo`
754
+ - Check token has access to repository
755
+ - For orgs, configure SSO authorization
896
756
 
897
- Configure the CLI via `.env` file or system environment variables:
757
+ **Environment already exists:**
758
+ ```bash
759
+ # Update existing environment
760
+ sembix studio update production --repo owner/repo
898
761
 
899
- ```env
900
- # GitHub Personal Access Token (required for deployment commands)
901
- GITHUB_TOKEN=ghp_your_token_here
762
+ # Or use different name
763
+ sembix studio create production-v2 --repo owner/repo
764
+ ```
902
765
 
903
- # Default GitHub organization (optional)
904
- DEFAULT_GITHUB_ORG=your-org
766
+ **Invalid environment name:**
767
+ - Must be lowercase letters, numbers, hyphens
768
+ - Minimum 3 characters
769
+ - No spaces or special characters
905
770
 
906
- # Studio default profile (optional)
907
- SEMBIX_DEFAULT_PROFILE=production
771
+ **Profile not found:**
772
+ ```bash
773
+ sembix configure # Add profile
774
+ sembix profile list # List available profiles
775
+ ```
908
776
 
909
- # Studio API client credentials (for CI/CD)
910
- SEMBIX_CLIENT_ID=7a8b9c0d1e2f3g4h
911
- SEMBIX_CLIENT_SECRET=abcdef123456...
777
+ **Workflow not found:**
778
+ ```bash
779
+ sembix workflow list --project-id proj_123 # List available workflows
780
+ sembix workflow start # Use interactive mode
912
781
  ```
913
782
 
914
- **Priority Order for Studio Profile Selection:**
915
- 1. `--profile` CLI flag (highest priority) - explicit user override
916
- 2. `SEMBIX_DEFAULT_PROFILE` environment variable - for CI/CD and scripting
917
- 3. `default_profile` in `~/.sembix/config` - user's persistent default
918
- 4. First available profile (lowest priority) - fallback
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
+ ```
795
+
796
+ ## Getting Help
919
797
 
920
- **Example Usage:**
921
798
  ```bash
922
- # Use specific profile via environment variable
923
- export SEMBIX_DEFAULT_PROFILE=production
924
- sembix workflow list # Uses production profile
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
925
803
 
926
- # Override with CLI flag
927
- sembix workflow list --profile staging # Uses staging profile (flag wins)
804
+ sembix --version # Check CLI version
805
+ sembix profile list # Check profile status
806
+ sembix studio list # Verify GitHub access
928
807
  ```
929
808
 
930
809
  ---
931
810
 
932
- ### Exit Codes
811
+ # Development
812
+
813
+ ## Project Structure
814
+
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
827
+ ```
828
+
829
+ ## Scripts
830
+
831
+ ```bash
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
836
+ ```
837
+
838
+ ## Adding Commands
933
839
 
934
- - `0` - Success
935
- - `1` - Error (validation failure, API error, user cancellation)
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`
936
845
 
937
846
  ---
938
847
 
939
- ### <a name="sembix-studio-create-all-options"></a>`sembix studio create` - All Options
848
+ # Complete Studio Options
940
849
 
941
- For reference, here's the complete list of all 50+ CLI flags for `sembix studio create`:
850
+ <a name="complete-studio-options"></a>
851
+
852
+ All options for `sembix studio create` and `sembix studio update`:
942
853
 
943
854
  **General:**
944
- - `-t, --token <token>` - GitHub personal access token
945
- - `-c, --config <path>` - Path to YAML configuration file
946
- - `-r, --repo <repo>` - Target repository (owner/repo format)
947
- - `-e, --env <environment>` - Environment name
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
948
859
 
949
- **AWS Basic Configuration:**
860
+ **AWS:**
950
861
  - `--aws-account-id <id>` - AWS Account ID (12 digits)
951
- - `--aws-region <region>` - AWS Region (e.g., us-east-1)
862
+ - `--aws-region <region>` - AWS Region
952
863
  - `--customer-role-arn <arn>` - GitHub Actions IAM role ARN
953
- - `--terraform-state-bucket <bucket>` - S3 bucket for Terraform state
864
+ - `--terraform-state-bucket <bucket>` - Terraform state S3 bucket
954
865
 
955
866
  **Database:**
956
867
  - `--database-name <name>` - PostgreSQL database name
957
868
  - `--database-user <user>` - PostgreSQL database user
958
869
 
959
870
  **Networking:**
960
- - `--enable-vpc-endpoints <boolean>` - Enable VPC endpoints (true/false)
961
- - `--use-custom-networking <boolean>` - Use existing VPC (true/false)
962
- - `--vpc-cidr <cidr>` - VPC CIDR block (e.g., 10.0.0.0/16)
871
+ - `--enable-vpc-endpoints <boolean>` - Enable VPC endpoints
872
+ - `--use-custom-networking <boolean>` - Use existing VPC
873
+ - `--vpc-cidr <cidr>` - VPC CIDR block
963
874
  - `--public-subnet-cidrs <json>` - Public subnet CIDRs (JSON array)
964
875
  - `--private-subnet-cidrs <json>` - Private subnet CIDRs (JSON array)
965
876
  - `--az-count <count>` - Number of AZs (2 or 3)
@@ -967,43 +878,46 @@ For reference, here's the complete list of all 50+ CLI flags for `sembix studio
967
878
  - `--custom-public-subnet-ids <ids>` - Existing public subnet IDs (comma-separated)
968
879
  - `--custom-private-subnet-ids <ids>` - Existing private subnet IDs (comma-separated)
969
880
 
970
- **Security - Security Groups:**
971
- - `--use-custom-security-groups <boolean>` - Use custom security groups (true/false)
972
- - `--sg-workflow-engine <id>` - Workflow Engine security group ID
973
- - `--sg-aurora <id>` - Aurora database security group ID
974
- - `--sg-rds-proxy <id>` - RDS Proxy security group ID
975
- - `--sg-bff-ecs <id>` - BFF ECS service security group ID
976
- - `--sg-bastion <id>` - Bastion host security group ID
977
- - `--sg-bff-alb <id>` - BFF ALB security group ID
978
-
979
- **Security - IAM Roles:**
980
- - `--use-custom-iam-roles <boolean>` - Use custom IAM roles (true/false)
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
981
893
  - `--iam-workflow-engine-exec <arn>` - Workflow Engine execution role ARN
982
894
  - `--iam-workflow-engine-task <arn>` - Workflow Engine task role ARN
983
- - `--iam-bff-ecs-exec <arn>` - BFF ECS task execution role ARN
895
+ - `--iam-bff-ecs-exec <arn>` - BFF ECS execution role ARN
984
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
985
899
  - `--iam-rds-proxy <arn>` - RDS Proxy role ARN
986
900
  - `--iam-studio-memory <arn>` - Studio Memory role ARN
987
901
  - `--iam-studio-notification <arn>` - Studio Notification role ARN
988
902
 
989
903
  **TLS/DNS:**
990
904
  - `--cloudfront-domain <domain>` - CloudFront custom domain
991
- - `--cloudfront-cert-arn <arn>` - CloudFront SSL certificate ARN (must be in us-east-1)
992
- - `--bff-alb-cert-arn <arn>` - BFF ALB SSL certificate ARN
905
+ - `--cloudfront-cert-arn <arn>` - CloudFront certificate ARN (us-east-1)
906
+ - `--bff-alb-cert-arn <arn>` - BFF ALB certificate ARN
993
907
  - `--hosted-zone-id <id>` - Route53 hosted zone ID
994
908
 
995
- **Feature Flags:**
996
- - `--deploy-studio-memory <boolean>` - Deploy Studio Memory service (true/false)
997
- - `--deploy-studio-notifications <boolean>` - Deploy Studio Notifications (true/false)
998
- - `--enable-bff-waf <boolean>` - Enable WAF for BFF (true/false)
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
999
913
 
1000
914
  **Frontend:**
1001
915
  - `--github-app-client-id <id>` - GitHub App OAuth client ID
1002
916
  - `--github-app-name <name>` - GitHub App name
1003
917
  - `--jira-client-id <id>` - Jira OAuth client ID
1004
918
 
1005
- **Hub Integration (Step 9):**
1006
- - `--skip-hub` - Skip Hub integration configuration
919
+ **Hub Integration:**
920
+ - `--skip-hub` - Skip Hub integration
1007
921
  - `--hub-engine-execution-role <arn>` - Hub Engine Execution Role ARN
1008
922
  - `--hub-consumer-role <arn>` - Hub Consumer Role ARN
1009
923
  - `--hub-admin-role <arn>` - Hub Admin Role ARN
@@ -1014,1641 +928,16 @@ For reference, here's the complete list of all 50+ CLI flags for `sembix studio
1014
928
 
1015
929
  ---
1016
930
 
1017
- ## Usage Examples
1018
-
1019
- Real-world examples showing different ways to use the CLI.
1020
-
1021
- ### Basic Usage Patterns
1022
-
1023
- #### 1. Fully Interactive (Beginner-Friendly)
1024
-
1025
- Perfect for first-time users:
1026
-
1027
- ```bash
1028
- sembix studio create
1029
- ```
1030
-
1031
- **What happens:**
1032
- - Prompts for repository selection
1033
- - Prompts for environment name
1034
- - Walks through all 9 configuration steps with explanations
1035
- - Creates environment with all settings
1036
-
1037
- #### 2. Specify Repository and Environment
1038
-
1039
- Fast setup when you know both values:
1040
-
1041
- ```bash
1042
- sembix studio create production --repo acme-corp/sembix-deployment
1043
- ```
1044
-
1045
- **What happens:**
1046
- - ✅ Validates repository exists
1047
- - ✅ Validates environment name format
1048
- - ✅ Checks environment doesn't already exist
1049
- - Skips repository and name prompts
1050
- - Walks through configuration steps
1051
- - Creates environment
1052
-
1053
- #### 3. Using Config Files
1054
-
1055
- For repeatable, version-controlled setups:
1056
-
1057
- ```bash
1058
- # Create environment from config file
1059
- sembix studio create --config production.yaml
1060
-
1061
- # Override specific values
1062
- sembix studio create --config base.yaml \
1063
- --env custom-name \
1064
- --aws-account-id 123456789012
1065
- ```
1066
-
1067
- ### Common Workflows
1068
-
1069
- #### Workflow 1: First-Time Setup (Learning Mode)
1070
-
1071
- ```bash
1072
- # Step 1: Configure credentials
1073
- sembix configure
1074
-
1075
- # Step 2: Create environment interactively
1076
- sembix studio create
1077
-
1078
- # Follow all prompts, read explanations...
1079
-
1080
- # Step 3: Deploy via GitHub Actions
1081
- # Go to https://github.com/owner/repo/actions
1082
- # Run deployment workflow
1083
- # Copy Hub role ARNs from output
1084
-
1085
- # Step 4: Add Hub integration
1086
- sembix studio add-hub
1087
-
1088
- # Select same repository and environment
1089
- # Enter Hub role ARNs
1090
- ```
1091
-
1092
- #### Workflow 2: Experienced User (Fast Mode)
1093
-
1094
- ```bash
1095
- # Create with known values
1096
- sembix studio create prod --repo acme/deploy
1097
-
1098
- # Answer remaining prompts
1099
- # ... deployment happens in GitHub Actions ...
1100
-
1101
- # Add Hub with known values
1102
- sembix studio add-hub prod --repo acme/deploy
1103
-
1104
- # Enter Hub role ARNs
1105
- ```
1106
-
1107
- #### Workflow 3: CI/CD / Automation
1108
-
1109
- For scripts and automation:
1110
-
1111
- ```bash
1112
- #!/bin/bash
1113
-
1114
- REPO="acme-corp/sembix-deployment"
1115
- ENV="client-${CLIENT_NAME}-production"
1116
-
1117
- # Create environment (with config file)
1118
- sembix studio create "${ENV}" \
1119
- --repo "${REPO}" \
1120
- --config base-config.yaml \
1121
- --token "${GITHUB_TOKEN}"
1122
-
1123
- # Later, after deployment...
1124
- sembix studio add-hub "${ENV}" \
1125
- --repo "${REPO}" \
1126
- --token "${GITHUB_TOKEN}"
1127
- ```
1128
-
1129
- #### Workflow 4: Multiple Environments
1130
-
1131
- Setting up multiple environments for the same repository:
1132
-
1133
- ```bash
1134
- # Production
1135
- sembix studio create production --repo acme/deploy
1136
-
1137
- # Staging
1138
- sembix studio create staging --repo acme/deploy
1139
-
1140
- # Development
1141
- sembix studio create development --repo acme/deploy
1142
-
1143
- # List all environments
1144
- sembix studio list acme/deploy
1145
- ```
1146
-
1147
- ### Profile Management Examples
1148
-
1149
- #### Working with Multiple Studio Instances
1150
-
1151
- ```bash
1152
- # Configure multiple profiles
1153
- sembix configure # Profile name: production
1154
- sembix configure # Profile name: staging
1155
-
1156
- # Set default profile
1157
- sembix profile set-default production
1158
-
1159
- # Set default projects for each profile
1160
- sembix profile set-default-project production proj_prod_123
1161
- sembix profile set-default-project staging proj_stage_456
1162
-
1163
- # List all profiles
1164
- sembix profile list
1165
-
1166
- # Login to each profile
1167
- sembix login production
1168
- sembix login staging
1169
-
1170
- # Use different profiles for different workflows
1171
- sembix workflow start --profile production --workflow-id wf_456
1172
- sembix workflow start --profile staging --workflow-id wf_789
1173
- ```
1174
-
1175
- ### Error Handling Examples
1176
-
1177
- #### Missing GitHub Token
1178
-
1179
- ```bash
1180
- $ sembix studio create
1181
- ✗ GitHub token is required. Please provide it using one of these methods:
1182
- 1. Run: sembix configure
1183
- 2. Set GITHUB_TOKEN environment variable
1184
- 3. Pass --token flag to the command
1185
- ```
1186
-
1187
- **Solution:**
1188
-
1189
- ```bash
1190
- sembix configure
1191
- ```
1192
-
1193
- #### Invalid Repository Format
1194
-
1195
- ```bash
1196
- $ sembix studio create prod --repo invalid_format
1197
- ✗ Invalid repository format. Use: owner/repo
1198
- ```
1199
-
1200
- #### Repository Not Found
1201
-
1202
- ```bash
1203
- $ sembix studio create prod --repo nonexistent/repo
1204
- ✗ Repository 'nonexistent/repo' not found or not accessible.
1205
-
1206
- 💡 Make sure:
1207
- • The repository name is correct (owner/repo)
1208
- • Your GitHub token has access to this repository
1209
- ```
1210
-
1211
- #### Invalid Environment Name
1212
-
1213
- ```bash
1214
- $ sembix studio create "My Environment" --repo acme/deploy
1215
- ✗ Invalid environment name. Must be lowercase letters, numbers, and hyphens (min 3 chars).
1216
- ```
1217
-
1218
- #### Environment Already Exists
1219
-
1220
- ```bash
1221
- $ sembix studio create production --repo acme/deploy
1222
- ✗ Environment 'production' already exists in acme/deploy
1223
-
1224
- 💡 Tip:
1225
- • Use a different environment name
1226
- • Or update the existing environment with: sembix studio update
1227
- ```
1228
-
1229
- #### Authentication Errors (Studio API)
1230
-
1231
- ```bash
1232
- # Error: Token expired
1233
- $ sembix workflow start
1234
- ✗ Authentication required. Please run: sembix login
1235
- ```
1236
-
1237
- **Solution:**
1238
-
1239
- ```bash
1240
- sembix login --profile production
1241
- ```
1242
-
1243
- ### Workflow Execution Patterns
1244
-
1245
- #### Start and Monitor a Workflow
1246
-
1247
- ```bash
1248
- # Start workflow and capture run ID
1249
- RUN_ID=$(sembix workflow start \
1250
- --project-id proj_123 \
1251
- --workflow-id wf_456 \
1252
- --inputs '{"env":"production"}' \
1253
- | grep "Run ID" | awk '{print $3}')
1254
-
1255
- # Watch until completion
1256
- sembix workflow run status \
1257
- --workflow-id wf_456 \
1258
- --run-id $RUN_ID \
1259
- --watch
1260
- ```
1261
-
1262
- #### List Recent Failures
1263
-
1264
- ```bash
1265
- sembix workflow run list \
1266
- --status FAILED \
1267
- --limit 10
1268
- ```
1269
-
1270
- #### Monitor Specific Workflow
931
+ # License
1271
932
 
1272
- ```bash
1273
- sembix workflow run list \
1274
- --workflow-id wf_456 \
1275
- --status RUNNING
1276
- ```
933
+ Proprietary - Sembix AI
1277
934
 
1278
- #### Using Workflow Inputs from Files
1279
-
1280
- ```bash
1281
- # Create inputs.json
1282
- cat > inputs.json <<EOF
1283
- {
1284
- "environment": "production",
1285
- "version": "1.2.3",
1286
- "config": {
1287
- "debug": false,
1288
- "replicas": 3
1289
- }
1290
- }
1291
- EOF
1292
-
1293
- # Use file in workflow start
1294
- sembix workflow start \
1295
- --project-id proj_123 \
1296
- --workflow-id wf_456 \
1297
- --inputs @inputs.json
1298
- ```
1299
-
1300
- ### Best Practices
1301
-
1302
- #### ✅ DO
1303
-
1304
- - Use `--repo` and `--env` for repeated operations
1305
- - Validate with `sembix studio list` first
1306
- - Use descriptive environment names (client-production, staging-v2)
1307
- - Store GitHub token in `~/.sembix/config` via `sembix configure`
1308
- - Keep environment names lowercase with hyphens
1309
- - Use config files for version-controlled setups
1310
- - Set default projects per profile for faster workflow execution
1311
- - Use `--pretty` for human-readable output
1312
- - Use `--watch` to monitor long-running workflows
1313
-
1314
- #### ❌ DON'T
1315
-
1316
- - Don't use uppercase in environment names
1317
- - Don't use spaces or special characters
1318
- - Don't share your GitHub token or client credentials
1319
- - Don't create environments without verifying repo access first
1320
- - Don't forget to run deployment between create and add-hub
1321
- - Don't commit sensitive credentials to git
1322
- - Don't use production credentials in development
1323
-
1324
- ### CI/CD Integration Examples
1325
-
1326
- #### GitHub Actions
1327
-
1328
- ```yaml
1329
- name: Deploy via Sembix
1330
-
1331
- on:
1332
- push:
1333
- branches: [main]
1334
-
1335
- jobs:
1336
- deploy:
1337
- runs-on: ubuntu-latest
1338
- steps:
1339
- - name: Install Sembix CLI
1340
- run: npm install -g @sembix/cli
1341
-
1342
- - name: Start Deployment Workflow
1343
- env:
1344
- SEMBIX_CLIENT_ID: ${{ secrets.SEMBIX_M2M_CLIENT_ID }}
1345
- SEMBIX_CLIENT_SECRET: ${{ secrets.SEMBIX_M2M_CLIENT_SECRET }}
1346
- run: |
1347
- sembix workflow start \
1348
- --profile production \
1349
- --project-id ${{ vars.PROJECT_ID }} \
1350
- --workflow-id ${{ vars.WORKFLOW_ID }} \
1351
- --inputs '{"version":"${{ github.sha }}"}'
1352
- ```
1353
-
1354
- #### GitLab CI
1355
-
1356
- ```yaml
1357
- deploy:
1358
- image: node:20
1359
- script:
1360
- - npm install -g @sembix/cli
1361
- - |
1362
- sembix workflow start \
1363
- --profile production \
1364
- --project-id ${PROJECT_ID} \
1365
- --workflow-id ${WORKFLOW_ID} \
1366
- --inputs "{\"version\":\"${CI_COMMIT_SHA}\"}"
1367
- variables:
1368
- SEMBIX_CLIENT_ID: ${M2M_CLIENT_ID}
1369
- SEMBIX_CLIENT_SECRET: ${M2M_CLIENT_SECRET}
1370
- ```
1371
-
1372
- ### Output Formatting Examples
1373
-
1374
- ```bash
1375
- # JSON output (default) - for scripts/automation
1376
- sembix project list --output json
1377
-
1378
- # Pretty JSON - for human reading
1379
- sembix project list --output pretty
1380
- # or shorthand:
1381
- sembix project list --pretty
1382
-
1383
- # Text output - for terminal display
1384
- sembix project list --output text
1385
- ```
1386
-
1387
- ### Quick Reference Cheat Sheet
1388
-
1389
- ```bash
1390
- # GitHub Deployment
1391
- sembix configure # First-time setup
1392
- sembix studio create # Interactive create
1393
- sembix studio create prod --repo owner/repo # Quick create
1394
- sembix studio add-hub prod --repo owner/repo # Add Hub integration
1395
- sembix studio list owner/repo # List environments
1396
-
1397
- # Studio API
1398
- sembix configure # Configure profile
1399
- sembix login # Authenticate
1400
- sembix profile list # List profiles
1401
- sembix profile set-default-project prod proj_123 # Set default project
1402
-
1403
- # Projects & Workflows
1404
- sembix project list # List projects
1405
- sembix workflow start # Start workflow (interactive)
1406
- sembix workflow run list # List workflow runs
1407
- sembix workflow run status --workflow-id wf_456 --run-id run_789 --watch
1408
-
1409
- # Troubleshooting
1410
- sembix --version # Check CLI version
1411
- sembix studio list owner/repo # Verify repo access
1412
- sembix profile list # Check profile status
1413
- sembix login --profile production # Re-authenticate
1414
- ```
1415
-
1416
- ## Studio CLI
1417
-
1418
- The Sembix CLI now supports direct integration with Sembix Studio instances for workflow execution and management.
1419
-
1420
- ### Studio Configuration
1421
-
1422
- Configure a Studio profile to connect to a Sembix Studio instance using the unified configure command:
1423
-
1424
- ```bash
1425
- sembix configure
1426
- ```
1427
-
1428
- This interactive command will first prompt for GitHub credentials, then optionally prompt you to configure a Studio profile with:
1429
- - **Profile name** (default: "default")
1430
- - **Studio API URL** (e.g., https://studio.example.com)
1431
- - **Cognito User Pool ID** (e.g., us-east-1_ABC123)
1432
- - **Cognito Client ID**
1433
- - **Cognito Region**
1434
- - **Cognito Domain** (e.g., https://auth.example.com)
1435
-
1436
- ### Authentication
1437
-
1438
- The Sembix CLI supports two authentication methods:
1439
- 1. **Browser-based OAuth** - For developers on local machines
1440
- 2. **Client Credentials** - For CI/CD pipelines and automated workflows
1441
-
1442
- #### Local Development (Browser-based OAuth)
1443
-
1444
- Authenticate with a Studio instance using browser-based OAuth:
1445
-
1446
- ```bash
1447
- # Login to default profile
1448
- sembix login
1449
-
1450
- # Login to specific profile
1451
- sembix login --profile production
1452
-
1453
- # Logout from profile
1454
- sembix logout --profile production
1455
-
1456
- # Logout from all profiles
1457
- sembix logout --all
1458
- ```
1459
-
1460
- **What happens during login:**
1461
- 1. Opens your default browser to Cognito hosted UI
1462
- 2. You authenticate with your Studio credentials
1463
- 3. Tokens are securely stored in `~/.sembix/tokens/<profile>.json`
1464
- 4. Tokens are automatically refreshed when expired
1465
-
1466
- #### CI/CD Pipelines (Client Credentials)
1467
-
1468
- For automated workflows, use OAuth 2.0 Client Credentials flow:
1469
-
1470
- **Prerequisites:**
1471
- - Obtain M2M (machine-to-machine) client credentials from your administrator:
1472
- - Client ID (e.g., `7a8b9c0d1e2f3g4h`)
1473
- - Client Secret (keep secure!)
1474
- - Required OAuth scopes:
1475
- - `sembix-api/projects.read` - List projects
1476
- - `sembix-api/workflows.read` - View workflows and runs
1477
- - `sembix-api/workflows.execute` - Start/stop workflows
1478
-
1479
- **Setup:**
1480
-
1481
- 1. **Add credentials to your CI/CD secrets:**
1482
-
1483
- GitHub Actions:
1484
- ```yaml
1485
- # In repository settings → Secrets and variables → Actions
1486
- SEMBIX_CLIENT_ID=7a8b9c0d1e2f3g4h5i6j7k8l
1487
- SEMBIX_CLIENT_SECRET=abcdef123456...
1488
- ```
1489
-
1490
- GitLab CI:
1491
- ```yaml
1492
- # In repository settings → CI/CD → Variables
1493
- SEMBIX_CLIENT_ID=7a8b9c0d1e2f3g4h5i6j7k8l
1494
- SEMBIX_CLIENT_SECRET=abcdef123456...
1495
- ```
1496
-
1497
- 2. **Use in your workflow:**
1498
-
1499
- ```yaml
1500
- - name: Start workflow
1501
- env:
1502
- SEMBIX_CLIENT_ID: ${{ secrets.SEMBIX_M2M_CLIENT_ID }}
1503
- SEMBIX_CLIENT_SECRET: ${{ secrets.SEMBIX_M2M_CLIENT_SECRET }}
1504
- run: |
1505
- sembix workflow start \
1506
- --project-id abc123 \
1507
- --workflow-id def456 \
1508
- --inputs '{"key": "value"}'
1509
- ```
1510
-
1511
- **How it works:**
1512
- - The CLI automatically detects `SEMBIX_CLIENT_ID` and `SEMBIX_CLIENT_SECRET` environment variables
1513
- - Authenticates using OAuth 2.0 Client Credentials flow
1514
- - No browser or interactive login needed
1515
- - Tokens obtained on-demand (not stored)
1516
-
1517
- **Testing credentials locally:**
1518
- ```bash
1519
- export SEMBIX_CLIENT_ID="your-client-id"
1520
- export SEMBIX_CLIENT_SECRET="your-client-secret"
1521
-
1522
- # Verify credentials work
1523
- sembix login
1524
- # Output: "Client credentials detected... Client credentials are valid!"
1525
- ```
1526
-
1527
- **Security best practices:**
1528
- - Never commit credentials to git
1529
- - Use CI/CD secret management (GitHub Secrets, AWS Secrets Manager, etc.)
1530
- - Rotate client secrets regularly (every 90 days recommended)
1531
- - Use separate credentials for different environments (dev, staging, prod)
1532
-
1533
- See the [CI/CD Setup Guide](./docs/CI-CD-SETUP.md) for complete examples and troubleshooting.
1534
-
1535
- ### Profile Management
1536
-
1537
- Manage Studio profiles:
1538
-
1539
- ```bash
1540
- # List all profiles
1541
- sembix profile list
1542
-
1543
- # Show profile details
1544
- sembix profile show production
1545
-
1546
- # Set default profile
1547
- sembix profile set-default production
1548
-
1549
- # Delete profile
1550
- sembix profile delete staging
1551
- ```
1552
-
1553
- **Profile list output:**
1554
- ```
1555
- Sembix Studio Profiles
1556
-
1557
- Name API URL Auth Status
1558
- ──────────────────────────────────────────────────────
1559
- * default https://studio.example.com ✓ Authenticated
1560
- production https://prod.example.com ✗ Not authenticated
1561
- staging https://staging.example.com ✓ Authenticated
1562
-
1563
- * = default profile
1564
- ```
1565
-
1566
- ### Profile Project Defaults
1567
-
1568
- Set default projects for profiles to avoid specifying `--project-id` repeatedly.
1569
-
1570
- **Set default project:**
1571
- ```bash
1572
- sembix profile set-default-project <profile> <project-id>
1573
-
1574
- # Example
1575
- sembix profile set-default-project production proj_abc123
1576
- ```
1577
-
1578
- **Get default project:**
1579
- ```bash
1580
- sembix profile get-default-project <profile>
1581
-
1582
- # Example
1583
- sembix profile get-default-project production
1584
- # Output: proj_abc123
1585
- ```
1586
-
1587
- **Clear default project:**
1588
- ```bash
1589
- sembix profile clear-default-project <profile>
1590
-
1591
- # Example
1592
- sembix profile clear-default-project production
1593
- ```
1594
-
1595
- **Usage with workflow commands:**
1596
- ```bash
1597
- # Set default project
1598
- sembix profile set-default-project production proj_abc123
1599
-
1600
- # Now you can omit --project-id
1601
- sembix workflow start --workflow-id wf_456 --inputs '{...}'
1602
- # Uses proj_abc123 automatically
1603
- ```
1604
-
1605
- ### Project Management
1606
-
1607
- List and view projects in your Studio instance.
1608
-
1609
- **List all projects:**
1610
- ```bash
1611
- # List all projects
1612
- sembix project list
1613
-
1614
- # Filter by name
1615
- sembix project list --name "My Project"
1616
-
1617
- # Filter by IDs
1618
- sembix project list --ids "proj_123,proj_456"
1619
-
1620
- # With specific profile
1621
- sembix project list --profile production
1622
- ```
1623
-
1624
- **Show project details:**
1625
- ```bash
1626
- sembix project show --project-id proj_abc123
1627
-
1628
- # With specific profile
1629
- sembix project show --project-id proj_abc123 --profile production
1630
- ```
1631
-
1632
- **Output:**
1633
- ```json
1634
- {
1635
- "projectId": "proj_abc123",
1636
- "name": "My Project",
1637
- "description": "Project description",
1638
- "state": "ACTIVE",
1639
- "createdAt": "2024-01-15T10:00:00Z",
1640
- "workflowPackConfigured": true
1641
- }
1642
- ```
1643
-
1644
- ### Workflow Operations
1645
-
1646
- Execute and manage workflows:
1647
-
1648
- #### Start a Workflow
1649
-
1650
- ```bash
1651
- # Interactive mode (prompts for project, workflow, and inputs)
1652
- sembix workflow start
1653
-
1654
- # With project ID and workflow ID
1655
- sembix workflow start --project-id abc123 --workflow-id def456
1656
-
1657
- # With workflow name instead of ID
1658
- sembix workflow start --project-id abc123 --workflow-name "Deploy to Production"
1659
-
1660
- # Start with inline JSON inputs
1661
- sembix workflow start --project-id abc123 --workflow-id def456 --inputs '{"key": "value"}'
1662
-
1663
- # Start with inputs from file
1664
- sembix workflow start --project-id abc123 --workflow-id def456 --inputs @inputs.json
1665
-
1666
- # Non-interactive mode (skip prompts)
1667
- sembix workflow start --project-id abc123 --workflow-id def456 --no-interactive
1668
-
1669
- # Using default project (set via profile set-default-project)
1670
- sembix workflow start --workflow-id def456 --inputs '{...}'
1671
-
1672
- # Start with workspace and issue context
1673
- sembix workflow start \
1674
- --project-id abc123 \
1675
- --workflow-id def456 \
1676
- --workspace-id ws-789 \
1677
- --issue-id issue-101 \
1678
- --inputs '{"param": "value"}'
1679
-
1680
- # Use specific profile
1681
- sembix workflow start \
1682
- --profile production \
1683
- --project-id abc123 \
1684
- --workflow-id def456 \
1685
- --inputs '{"key": "value"}'
1686
- ```
1687
-
1688
- **Example inputs.json:**
1689
- ```json
1690
- {
1691
- "inputVariables": {
1692
- "repositoryUrl": "https://github.com/acme/repo",
1693
- "branch": "main"
1694
- },
1695
- "workspaceId": "ws-123",
1696
- "workspaceName": "My Workspace",
1697
- "issueId": "issue-456",
1698
- "issueKey": "PROJ-123"
1699
- }
1700
- ```
1701
-
1702
- #### Check Workflow Status
1703
-
1704
- ```bash
1705
- # Get current status
1706
- sembix workflow run status --workflow-id wf_456 --run-id run_789
1707
-
1708
- # Watch workflow until completion (polls every 5 seconds)
1709
- sembix workflow run status --workflow-id wf_456 --run-id run_789 --watch
1710
- ```
1711
-
1712
- **Status output:**
1713
- ```
1714
- Workflow Run Status
1715
-
1716
- Run ID: run-789
1717
- Workflow ID: def456
1718
- Status: RUNNING
1719
- Progress: 45%
1720
- Created: 2024-01-15 10:30:00
1721
- Creator: user-123
1722
- ```
1723
-
1724
- #### List Workflow Runs
1725
-
1726
- ```bash
1727
- # List workflow instances (definitions)
1728
- sembix workflow list
1729
-
1730
- # Filter by project
1731
- sembix workflow list --project-id proj_123
1732
-
1733
- # Filter by template IDs
1734
- sembix workflow list --workflow-template-ids "tmpl_1,tmpl_2"
1735
-
1736
- # Show workflow instance details
1737
- sembix workflow show --project-id proj_123 --workflow-id wf_456
1738
-
1739
- # List workflow runs (executions) - excludes subflows by default
1740
- sembix workflow run list
1741
-
1742
- # Filter by workflow
1743
- sembix workflow run list --workflow-id wf_456
1744
-
1745
- # Filter by project
1746
- sembix workflow run list --project-id proj_123
1747
-
1748
- # Filter by status
1749
- sembix workflow run list --status RUNNING
1750
-
1751
- # Include sub-workflow runs
1752
- sembix workflow run list --include-subflows
1753
-
1754
- # Filter to top-level runs only
1755
- sembix workflow run list --parent-id NULL
1756
-
1757
- # Pagination
1758
- sembix workflow run list --limit 20 --offset 10
1759
-
1760
- # Show specific run details
1761
- sembix workflow run show --workflow-id wf_456 --run-id run_789
1762
-
1763
- # Watch run details until completion
1764
- sembix workflow run show --workflow-id wf_456 --run-id run_789 --watch
1765
- ```
1766
-
1767
- **List output:**
1768
- ```
1769
- Workflow Runs
1770
-
1771
- Run ID Workflow ID Status Progress Created
1772
- ────────────────────────────────────────────────────────
1773
- run-789 def456 RUNNING 45% 2 hours ago
1774
- run-788 def456 COMPLETED 100% 1 day ago
1775
- run-787 abc123 FAILED 30% 2 days ago
1776
-
1777
- Showing 1-3 of 15 results
1778
- ```
1779
-
1780
- #### Stop a Workflow Run
1781
-
1782
- ```bash
1783
- sembix workflow run stop --project-id proj_123 --workflow-id wf_456 --run-id run_789
1784
- ```
1785
-
1786
- ### Common Workflow Patterns
1787
-
1788
- **1. Start and monitor a workflow:**
1789
- ```bash
1790
- # Start workflow and capture run ID
1791
- RUN_ID=$(sembix workflow start \
1792
- --project-id abc123 \
1793
- --workflow-id def456 \
1794
- --inputs '{"key": "value"}' \
1795
- | grep "Run ID" | awk '{print $3}')
1796
-
1797
- # Watch until completion
1798
- sembix workflow run status \
1799
- --workflow-id def456 \
1800
- --run-id $RUN_ID \
1801
- --watch
1802
- ```
1803
-
1804
- **2. List recent failures:**
1805
- ```bash
1806
- sembix workflow run list \
1807
- --status FAILED \
1808
- --limit 10
1809
- ```
1810
-
1811
- **3. Monitor specific workflow:**
1812
- ```bash
1813
- sembix workflow run list \
1814
- --workflow-id def456 \
1815
- --status RUNNING
1816
- ```
1817
-
1818
- ### Output Formatting
1819
-
1820
- Control output format for all commands using global flags.
1821
-
1822
- **Available formats:**
1823
- - `json` (default) - Machine-readable JSON output
1824
- - `pretty` - Pretty-printed JSON with colors and indentation
1825
- - `text` - Human-readable text output (where applicable)
1826
-
1827
- **Usage:**
1828
-
1829
- ```bash
1830
- # JSON output (default)
1831
- sembix workflow run list --workflow-id wf_456
1832
-
1833
- # Pretty-printed JSON
1834
- sembix workflow run list --workflow-id wf_456 --output pretty
1835
- # or shorthand:
1836
- sembix workflow run list --workflow-id wf_456 --pretty
1837
-
1838
- # Text output
1839
- sembix project list --output text
1840
- ```
1841
-
1842
- **Examples:**
1843
-
1844
- ```bash
1845
- # JSON (default) - for scripts/automation
1846
- $ sembix project show --project-id proj_123
1847
- {"projectId":"proj_123","name":"My Project","state":"ACTIVE",...}
1848
-
1849
- # Pretty JSON - for human reading
1850
- $ sembix project show --project-id proj_123 --pretty
1851
- {
1852
- "projectId": "proj_123",
1853
- "name": "My Project",
1854
- "state": "ACTIVE",
1855
- ...
1856
- }
1857
-
1858
- # Text - for terminal display
1859
- $ sembix project list --output text
1860
- Projects:
1861
- 1. My Project (proj_123) - ACTIVE
1862
- 2. Another Project (proj_456) - ACTIVE
1863
- ```
1864
-
1865
- **Global flags:**
1866
- - `--output <format>` - Set output format: json, pretty, or text
1867
- - `--pretty` - Shorthand for `--output pretty`
1868
-
1869
- ### Error Handling
1870
-
1871
- **Authentication errors:**
1872
- ```bash
1873
- # If you see "Authentication required" or "Token expired"
1874
- sembix login --profile production
1875
- ```
1876
-
1877
- **Profile not found:**
1878
- ```bash
1879
- # Configure the profile first
1880
- sembix configure
1881
- # Choose to configure Studio profile with name: production
1882
- ```
1883
-
1884
- **Invalid inputs:**
1885
- ```bash
1886
- # Validate your JSON syntax
1887
- cat inputs.json | jq .
1888
- ```
1889
-
1890
- ## Workflow
1891
-
1892
- ### Two-Phased Deployment Process
1893
-
1894
- ```
1895
- ╔═══════════════════════════════════════════════════════════════════╗
1896
- ║ PHASE 1: BOOTSTRAP DEPLOYMENT ║
1897
- ╚═══════════════════════════════════════════════════════════════════╝
1898
-
1899
- ┌─────────────────────────────────────────────────┐
1900
- │ 1. Create Environment (Skip Hub) │
1901
- │ sembix studio create --skip-hub │
1902
- │ • Configure environment (Steps 1-8) │
1903
- │ • Skip Hub integration (Step 9) │
1904
- │ • Creates GitHub Actions environment │
1905
- └─────────────────────────────────────────────────┘
1906
-
1907
- ┌─────────────────────────────────────────────────┐
1908
- │ 2. Bootstrap Deployment via GitHub Actions │
1909
- │ • Go to repo → Actions → Run workflow │
1910
- │ • Deploys initial Terraform infrastructure │
1911
- │ • Creates IAM roles in your AWS account │
1912
- │ • Copy IAM ARNs from deployment output │
1913
- └─────────────────────────────────────────────────┘
1914
-
1915
- ┌─────────────────────────────────────────────────┐
1916
- │ 3. Coordinate with Sembix Support │
1917
- │ • Send IAM ARNs to Sembix support │
1918
- │ • Wait for Sembix to configure Hub │
1919
- │ • Receive Hub role ARNs from support: │
1920
- │ - Hub Engine Execution Role ARN │
1921
- │ - Hub Consumer Role ARN │
1922
- │ - Hub Admin Role ARN │
1923
- │ - Hub AppConfig Role ARN + IDs │
1924
- └─────────────────────────────────────────────────┘
1925
-
1926
- ╔═══════════════════════════════════════════════════════════════════╗
1927
- ║ PHASE 2: HUB INTEGRATION & FULL DEPLOYMENT ║
1928
- ╚═══════════════════════════════════════════════════════════════════╝
1929
-
1930
- ┌─────────────────────────────────────────────────┐
1931
- │ 4. Add Hub Integration │
1932
- │ sembix studio add-hub <environment> │
1933
- │ • Provide Hub role ARNs from support │
1934
- │ • Updates GitHub Actions environment │
1935
- │ • Configures cross-account access │
1936
- └─────────────────────────────────────────────────┘
1937
-
1938
- ┌─────────────────────────────────────────────────┐
1939
- │ 5. Full Deployment via GitHub Actions │
1940
- │ • Go to repo → Actions → Run workflow │
1941
- │ • Completes full Sembix Studio deployment │
1942
- │ • Enables Hub cross-account access │
1943
- │ • ✅ Studio environment fully operational │
1944
- └─────────────────────────────────────────────────┘
1945
- ```
1946
-
1947
- ## Configuration Priority
1948
-
1949
- The CLI follows this priority chain for configuration values:
1950
-
1951
- ```
1952
- CLI Flags > Config File > Interactive Prompts > Defaults
1953
- ```
1954
-
1955
- **Examples:**
1956
-
1957
- ```bash
1958
- # Config file provides base, CLI flags override specific values
1959
- sembix studio create --config base.yaml --env custom-name
1960
-
1961
- # Interactive prompts only for missing values
1962
- sembix studio create --repo acme/deploy --aws-account-id 123456789012
1963
- # Will prompt for all other fields
1964
-
1965
- # Fully automated (no prompts)
1966
- sembix studio create --config complete.yaml
1967
- # No prompts if config file is complete
1968
- ```
1969
-
1970
- ## Config File Reference
1971
-
1972
- See [`config.example.yaml`](./config.example.yaml) for a complete, documented example.
1973
-
1974
- **Minimal config:**
1975
-
1976
- ```yaml
1977
- repository:
1978
- owner: acme-corp
1979
- repo: sembix-deployment
1980
-
1981
- environmentName: production
1982
- awsAccountId: "123456789012"
1983
- awsRegion: us-east-1
1984
- customerRoleArn: arn:aws:iam::123456789012:role/GitHubActionsDeployRole
1985
- terraformStateBucket: my-terraform-state-bucket
1986
-
1987
- database:
1988
- name: sembix_studio
1989
- user: sembix_studio_user
1990
-
1991
- tls:
1992
- cloudfrontDomain: studio.acme.com
1993
- cloudfrontCertArn: arn:aws:acm:us-east-1:123456789012:certificate/abc123
1994
- bffAlbCertificateArn: arn:aws:acm:us-east-1:123456789012:certificate/def456
1995
- hostedZoneId: Z1234567890ABC
1996
-
1997
- frontend:
1998
- githubAppClientId: Iv1.0123456789abcdef
1999
- githubAppName: sembix-studio-app
2000
- jiraClientId: abc123def456
2001
- ```
2002
-
2003
- **Complete config with all options:**
2004
-
2005
- ```yaml
2006
- # See config.example.yaml for:
2007
- # - Networking configuration (VPC, subnets)
2008
- # - Custom security groups
2009
- # - Custom IAM roles
2010
- # - Feature flags
2011
- # - Hub integration
2012
- # - All advanced options
2013
- ```
2014
-
2015
- ## Use Cases
2016
-
2017
- ### 1. First-Time Setup (Interactive Learning)
2018
-
2019
- Perfect for understanding all configuration options:
2020
-
2021
- ```bash
2022
- sembix studio create
2023
- ```
2024
-
2025
- Follow all 9 steps with detailed explanations.
2026
-
2027
- ### 2. Rapid Iteration (Config Files)
2028
-
2029
- For creating multiple similar environments:
2030
-
2031
- ```bash
2032
- # Create base config once
2033
- cp config.example.yaml clients/base.yaml
2034
- # Edit base.yaml with common settings
2035
-
2036
- # Create client-specific environments
2037
- sembix studio create --config clients/base.yaml --env client-abc-prod
2038
- sembix studio create --config clients/base.yaml --env client-xyz-prod
2039
- ```
2040
-
2041
- ### 3. CI/CD Automation
2042
-
2043
- For automated environment creation in pipelines:
2044
-
2045
- ```bash
2046
- #!/bin/bash
2047
- CLIENT_NAME=$1
2048
- sembix studio create "${CLIENT_NAME}-production" \
2049
- --config ci/base-config.yaml \
2050
- --token "$GITHUB_TOKEN" \
2051
- --aws-account-id "$CLIENT_AWS_ACCOUNT" \
2052
- --cloudfront-domain "studio.${CLIENT_NAME}.example.com"
2053
- ```
2054
-
2055
- ### 4. Infrastructure as Code
2056
-
2057
- Version control your environment configurations:
2058
-
2059
- ```
2060
- configs/
2061
- ├── base.yaml # Common settings
2062
- ├── production.yaml # Production overrides
2063
- ├── staging.yaml # Staging overrides
2064
- └── development.yaml # Dev overrides
2065
- ```
2066
-
2067
- ```bash
2068
- # Create from version-controlled configs
2069
- sembix studio create --config configs/production.yaml
2070
- sembix studio create --config configs/staging.yaml
2071
- ```
2072
-
2073
- ### 5. Hub Integration After Deployment
2074
-
2075
- Add Hub configuration after initial deployment:
2076
-
2077
- ```bash
2078
- # Step 1: Create without Hub
2079
- sembix studio create production --repo acme/deploy --skip-hub
2080
-
2081
- # Step 2: Deploy and get Hub ARNs
2082
-
2083
- # Step 3: Add Hub integration
2084
- sembix studio update production --repo acme/deploy \
2085
- --hub-engine-execution-role arn:aws:iam::123456789012:role/HubEngine \
2086
- --hub-consumer-role arn:aws:iam::123456789012:role/HubConsumer \
2087
- --hub-admin-role arn:aws:iam::123456789012:role/HubAdmin
2088
- ```
2089
-
2090
- ## Development
2091
-
2092
- ### Project Structure
2093
-
2094
- ```
2095
- sembix-cli/
2096
- ├── src/
2097
- │ ├── commands/ # Command implementations
2098
- │ │ ├── setup.ts # Environment create command
2099
- │ │ ├── update.ts # Environment update command
2100
- │ │ └── hub-integration.ts # Deprecated hub command
2101
- │ ├── prompts/ # Interactive prompts
2102
- │ │ ├── environment-setup.ts # Main setup prompts
2103
- │ │ ├── hub-integration-step.ts # Hub integration prompts
2104
- │ │ └── hub-integration.ts # Deprecated hub prompts
2105
- │ ├── utils/ # Utility modules
2106
- │ │ ├── github.ts # GitHub API client
2107
- │ │ ├── ui.ts # Terminal UI utilities
2108
- │ │ └── config-loader.ts # Config file loading & merging
2109
- │ ├── types.ts # TypeScript types
2110
- │ ├── config-schema.ts # Zod schemas for config validation
2111
- │ ├── config.ts # Configuration management
2112
- │ └── index.ts # CLI entry point
2113
- ├── config.example.yaml # Example config file
2114
- ├── package.json
2115
- ├── tsconfig.json
2116
- ├── .env.example
2117
- └── README.md
2118
- ```
2119
-
2120
- ### Scripts
2121
-
2122
- ```bash
2123
- npm run build # Compile TypeScript to JavaScript
2124
- npm run dev # Run in development mode with tsx
2125
- npm run type-check # Type check without emitting files
2126
- ```
2127
-
2128
- ### Adding New Commands
2129
-
2130
- 1. Create a new file in `src/commands/`
2131
- 2. Implement the command logic
2132
- 3. Add prompts in `src/prompts/` if needed
2133
- 4. Register the command in `src/index.ts`
2134
-
2135
- Example:
2136
-
2137
- ```typescript
2138
- // src/commands/my-command.ts
2139
- export async function myCommand(githubToken: string, options: Record<string, any>): Promise<void> {
2140
- // Command implementation
2141
- }
2142
-
2143
- // src/index.ts
2144
- studio
2145
- .command('my-command')
2146
- .description('Description of my command')
2147
- .option('-r, --repo <repo>', 'Target repository')
2148
- .action(async (options) => {
2149
- const { myCommand } = await import('./commands/my-command.js');
2150
- await myCommand(config.githubToken, options);
2151
- });
2152
- ```
2153
-
2154
- ## Troubleshooting
2155
-
2156
- Comprehensive troubleshooting guide for common issues.
2157
-
2158
- ### Authentication Issues
2159
-
2160
- #### "GitHub token is required"
2161
-
2162
- **Error:**
2163
- ```
2164
- ✗ GitHub token is required. Please provide it using one of these methods:
2165
- 1. Run: sembix configure
2166
- 2. Set GITHUB_TOKEN environment variable
2167
- 3. Pass --token flag to the command
2168
- ```
2169
-
2170
- **Solution:**
2171
- ```bash
2172
- # Easiest method (recommended)
2173
- sembix configure
2174
-
2175
- # Alternative: Create .env file
2176
- echo "GITHUB_TOKEN=ghp_your_token_here" > .env
2177
-
2178
- # Or pass token directly
2179
- sembix studio create --token ghp_your_token_here
2180
- ```
2181
-
2182
- #### "Failed to create environment: Bad credentials"
2183
-
2184
- **Cause:** GitHub token is invalid or missing required scopes.
2185
-
2186
- **Solution:**
2187
- 1. Create a new Personal Access Token at: https://github.com/settings/tokens
2188
- 2. Required scopes:
2189
- - ✅ `repo` (all sub-scopes)
2190
- - ✅ `workflow`
2191
- 3. Update your configuration:
2192
- ```bash
2193
- sembix configure
2194
- ```
2195
-
2196
- #### "Authentication required" (Studio API)
2197
-
2198
- **Error:**
2199
- ```
2200
- ✗ Authentication required. Please run: sembix login
2201
- ```
2202
-
2203
- **Solution:**
2204
- ```bash
2205
- # Login with default profile
2206
- sembix login
2207
-
2208
- # Or specific profile
2209
- sembix login --profile production
2210
-
2211
- # If tokens expired, re-authenticate
2212
- sembix logout --profile production
2213
- sembix login --profile production
2214
- ```
2215
-
2216
- #### Browser did not open (Studio login)
2217
-
2218
- **Error:** Browser window doesn't open during `sembix login`
2219
-
2220
- **Solution:**
2221
- 1. Manually copy the URL displayed in terminal
2222
- 2. Open it in your browser
2223
- 3. Complete authentication within 5 minutes
2224
- 4. If timeout occurs, run `sembix login` again
2225
-
2226
- ### GitHub API Issues
2227
-
2228
- #### "No repositories found"
2229
-
2230
- **Cause:** GitHub token doesn't have access to repositories.
2231
-
2232
- **Solution:**
2233
- 1. Verify token has `repo` scope
2234
- 2. Check organization access:
2235
- - GitHub Settings → Personal Access Tokens → Your token → Configure SSO (if applicable)
2236
- - Click "Authorize" for your organization
2237
- 3. Verify repository name is correct (use `owner/repo` format)
2238
-
2239
- #### "Repository not found or not accessible"
2240
-
2241
- **Error:**
2242
- ```
2243
- ✗ Repository 'owner/repo' not found or not accessible.
2244
- ```
2245
-
2246
- **Solution:**
2247
- ```bash
2248
- # Verify repository name format
2249
- sembix studio list # Lists accessible repositories
2250
-
2251
- # Check token permissions
2252
- # Go to: https://github.com/settings/tokens
2253
- # Ensure 'repo' scope is enabled
2254
-
2255
- # If using organization repos, configure SSO
2256
- ```
2257
-
2258
- #### "Environment already exists"
2259
-
2260
- **Error:**
2261
- ```
2262
- ✗ Environment 'production' already exists in owner/repo
2263
- ```
2264
-
2265
- **Solution:**
2266
- ```bash
2267
- # Option 1: Update existing environment
2268
- sembix studio update production --repo owner/repo
2269
-
2270
- # Option 2: Use different environment name
2271
- sembix studio create production-v2 --repo owner/repo
2272
-
2273
- # Option 3: Delete and recreate (not recommended)
2274
- # Delete manually in GitHub UI, then:
2275
- sembix studio create production --repo owner/repo
2276
- ```
2277
-
2278
- ### Studio API Issues
2279
-
2280
- #### "Profile not found"
2281
-
2282
- **Error:**
2283
- ```
2284
- ✗ Profile 'production' not found
2285
- ```
2286
-
2287
- **Solution:**
2288
- ```bash
2289
- # List configured profiles
2290
- sembix profile list
2291
-
2292
- # Configure the profile
2293
- sembix configure
2294
- # Choose to configure Studio profile with name: production
2295
- ```
2296
-
2297
- #### "Cannot connect to Studio API"
2298
-
2299
- **Error:** Connection refused or timeout errors
2300
-
2301
- **Solution:**
2302
- 1. Verify API URL in profile configuration:
2303
- ```bash
2304
- sembix profile show production
2305
- ```
2306
-
2307
- 2. Check network connectivity:
2308
- ```bash
2309
- curl https://studio.example.com/health
2310
- ```
2311
-
2312
- 3. Reconfigure profile if URL is incorrect:
2313
- ```bash
2314
- sembix configure
2315
- # Use same profile name to update
2316
- ```
2317
-
2318
- #### "401 Unauthorized"
2319
-
2320
- **Error:** API returns 401 error
2321
-
2322
- **Solution:**
2323
- ```bash
2324
- # Token expired - re-authenticate
2325
- sembix login --profile production
2326
-
2327
- # If still failing, logout and login again
2328
- sembix logout --profile production
2329
- sembix login --profile production
2330
- ```
2331
-
2332
- #### "Workflow not found"
2333
-
2334
- **Error:**
2335
- ```
2336
- ✗ Workflow 'wf_456' not found
2337
- ```
2338
-
2339
- **Solution:**
2340
- ```bash
2341
- # List available workflows
2342
- sembix workflow list --project-id proj_123
2343
-
2344
- # Or use interactive mode to search
2345
- sembix workflow start
2346
- ```
2347
-
2348
- ### Common Errors
2349
-
2350
- #### "Failed to encrypt secret"
2351
-
2352
- **Error:** libsodium encryption error
2353
-
2354
- **Solution:**
2355
- ```bash
2356
- # Reinstall dependencies
2357
- rm -rf node_modules
2358
- npm install
2359
-
2360
- # If still failing, try:
2361
- npm install libsodium-wrappers --save
2362
- ```
2363
-
2364
- #### "Invalid YAML syntax"
2365
-
2366
- **Error:** When using config files
2367
-
2368
- **Solution:**
2369
- ```bash
2370
- # Validate YAML syntax
2371
- npm install -g js-yaml
2372
- js-yaml config.yaml
2373
-
2374
- # Or use online validator: yamllint.com
2375
-
2376
- # Common issues:
2377
- # - Incorrect indentation (use spaces, not tabs)
2378
- # - Missing quotes around special characters
2379
- # - Malformed arrays/objects
2380
- ```
2381
-
2382
- #### "Invalid environment name"
2383
-
2384
- **Error:**
2385
- ```
2386
- ✗ Invalid environment name. Must be lowercase letters, numbers, and hyphens (min 3 chars).
2387
- ```
2388
-
2389
- **Rules:**
2390
- - Lowercase letters only
2391
- - Numbers allowed
2392
- - Hyphens allowed (not at start/end)
2393
- - No spaces or special characters
2394
- - Minimum 3 characters
2395
-
2396
- **Valid examples:**
2397
- - `production`
2398
- - `client-abc-staging`
2399
- - `dev-environment-2`
2400
-
2401
- **Invalid examples:**
2402
- - `Production` (uppercase)
2403
- - `My Environment` (spaces)
2404
- - `prod_env` (underscores)
2405
-
2406
- #### "Permission denied writing tokens"
2407
-
2408
- **Error:** Cannot write to ~/.sembix directory
2409
-
2410
- **Solution:**
2411
- ```bash
2412
- # Check directory permissions
2413
- ls -la ~/.sembix
2414
-
2415
- # Fix permissions
2416
- chmod 700 ~/.sembix
2417
- chmod 600 ~/.sembix/tokens/*
2418
-
2419
- # If directory doesn't exist
2420
- mkdir -p ~/.sembix/tokens
2421
- chmod 700 ~/.sembix
2422
- ```
2423
-
2424
- #### "Invalid input format" (Workflows)
2425
-
2426
- **Error:** Workflow input validation failed
2427
-
2428
- **Solution:**
2429
- ```bash
2430
- # Validate JSON syntax
2431
- echo '{"key":"value"}' | jq .
2432
-
2433
- # Use file for complex inputs
2434
- cat inputs.json | jq . # Validate
2435
- sembix workflow start --project-id proj_123 --workflow-id wf_456 --inputs @inputs.json
2436
-
2437
- # Check required vs optional inputs
2438
- sembix workflow template show --project-id proj_123 --workflow-id wf_456
2439
- ```
2440
-
2441
- ### Configuration Issues
2442
-
2443
- #### Config file not found
2444
-
2445
- **Error:**
2446
- ```
2447
- ✗ Config file not found: production.yaml
2448
- ```
2449
-
2450
- **Solution:**
2451
- ```bash
2452
- # Use absolute path
2453
- sembix studio create --config /full/path/to/production.yaml
2454
-
2455
- # Or relative to current directory
2456
- sembix studio create --config ./configs/production.yaml
2457
-
2458
- # Verify file exists
2459
- ls -la production.yaml
2460
- ```
2461
-
2462
- #### Config validation failed
2463
-
2464
- **Error:** Config file validation errors
2465
-
2466
- **Solution:**
2467
- 1. Check config.example.yaml for correct format
2468
- 2. Ensure all required fields are present
2469
- 3. Validate data types (strings, booleans, numbers)
2470
- 4. Check ARN formats match AWS patterns
2471
- 5. Verify CIDR blocks are valid
2472
-
2473
- ### Build/Installation Issues
2474
-
2475
- #### "Cannot find module"
2476
-
2477
- **Error:** Module resolution errors
2478
-
2479
- **Solution:**
2480
- ```bash
2481
- # Reinstall dependencies
2482
- rm -rf node_modules package-lock.json
2483
- npm install
2484
-
2485
- # Rebuild TypeScript
2486
- npm run build
2487
-
2488
- # If still failing, check Node version
2489
- node --version # Should be 20 or higher
2490
- ```
2491
-
2492
- #### "Command not found: sembix"
2493
-
2494
- **Error:** CLI not in PATH after installation
2495
-
2496
- **Solution:**
2497
- ```bash
2498
- # Global install
2499
- npm install -g @sembix/cli
2500
-
2501
- # Verify installation
2502
- which sembix
2503
- sembix --version
2504
-
2505
- # If using npm link (development)
2506
- npm link
2507
-
2508
- # Add npm global bin to PATH if needed
2509
- export PATH="$PATH:$(npm config get prefix)/bin"
2510
- ```
2511
-
2512
- ### CI/CD Issues
2513
-
2514
- #### Client credentials not working
2515
-
2516
- **Error:** SEMBIX_CLIENT_ID and SEMBIX_CLIENT_SECRET set but authentication fails
2517
-
2518
- **Solution:**
2519
- 1. Verify credentials are correct (no extra spaces)
2520
- 2. Check client has required scopes:
2521
- - `sembix-api/projects.read`
2522
- - `sembix-api/workflows.read`
2523
- - `sembix-api/workflows.execute`
2524
- 3. Test credentials locally:
2525
- ```bash
2526
- export SEMBIX_CLIENT_ID="your-client-id"
2527
- export SEMBIX_CLIENT_SECRET="your-client-secret"
2528
- sembix login # Should show "Client credentials detected..."
2529
- ```
2530
-
2531
- #### Environment variables not recognized
2532
-
2533
- **Error:** CI/CD pipeline can't find credentials
2534
-
2535
- **Solution:**
2536
- ```bash
2537
- # GitHub Actions: Use secrets
2538
- env:
2539
- SEMBIX_CLIENT_ID: ${{ secrets.SEMBIX_M2M_CLIENT_ID }}
2540
- SEMBIX_CLIENT_SECRET: ${{ secrets.SEMBIX_M2M_CLIENT_SECRET }}
2541
-
2542
- # GitLab CI: Use variables
2543
- variables:
2544
- SEMBIX_CLIENT_ID: ${M2M_CLIENT_ID}
2545
- SEMBIX_CLIENT_SECRET: ${M2M_CLIENT_SECRET}
2546
-
2547
- # Verify secrets are set in CI/CD settings
2548
- ```
2549
-
2550
- ### Getting Help
2551
-
2552
- If you encounter an issue not covered here:
2553
-
2554
- 1. **Check version:**
2555
- ```bash
2556
- sembix --version
2557
- ```
2558
-
2559
- 2. **Enable verbose output:**
2560
- ```bash
2561
- sembix studio create --verbose # If supported
2562
- ```
2563
-
2564
- 3. **Check logs:**
2565
- - GitHub token permissions
2566
- - API endpoint reachability
2567
- - Config file syntax
2568
-
2569
- 4. **Common debugging steps:**
2570
- ```bash
2571
- # Verify GitHub access
2572
- sembix studio list
2573
-
2574
- # Check profile status
2575
- sembix profile list
2576
-
2577
- # Test authentication
2578
- sembix login --profile production
2579
-
2580
- # Validate config file
2581
- js-yaml config.yaml
2582
- ```
2583
-
2584
- 5. **Contact support:**
2585
- - Provide error message
2586
- - Include CLI version
2587
- - Share (sanitized) config file if applicable
2588
-
2589
- ## Advanced Topics
2590
-
2591
- ### Partial Updates
2592
-
2593
- The `update` command supports partial updates - only provide the flags you want to change:
2594
-
2595
- ```bash
2596
- # Only update feature flags
2597
- sembix studio update prod --repo acme/deploy \
2598
- --deploy-studio-memory true \
2599
- --enable-bff-waf false
2600
-
2601
- # Only update Hub integration
2602
- sembix studio update prod --repo acme/deploy \
2603
- --hub-consumer-role arn:aws:iam::123456789012:role/NewConsumer
2604
- ```
2605
-
2606
- ### Config File Inheritance
2607
-
2608
- Create a base config and override specific values:
2609
-
2610
- ```bash
2611
- # base.yaml has common settings
2612
- # production.yaml imports and overrides
2613
-
2614
- sembix studio create --config base.yaml --config production.yaml
2615
- # (Note: Multiple --config flags not yet supported, use CLI flags for overrides)
2616
-
2617
- # Current approach:
2618
- sembix studio create --config base.yaml \
2619
- --env production \
2620
- --cloudfront-domain studio.prod.acme.com
2621
- ```
2622
-
2623
- ### Batch Operations
2624
-
2625
- Create multiple environments with a script:
2626
-
2627
- ```bash
2628
- #!/bin/bash
2629
- for CLIENT in client-a client-b client-c; do
2630
- sembix studio create "${CLIENT}-production" \
2631
- --config base.yaml \
2632
- --cloudfront-domain "studio.${CLIENT}.example.com" \
2633
- --aws-account-id "${CLIENT_AWS_ACCOUNTS[$CLIENT]}"
2634
- done
2635
- ```
2636
-
2637
- ## License
2638
-
2639
- Proprietary - Sembix AI
2640
-
2641
- ## Support
935
+ # Support
2642
936
 
2643
937
  For issues or questions, contact the Sembix team or open an issue in the repository.
2644
938
 
2645
- ## See Also
2646
-
2647
- For additional detailed documentation, see these files included in the package:
2648
-
2649
- - [QUICKSTART.md](./QUICKSTART.md) - Step-by-step quick start guide with detailed walkthroughs
2650
- - [USAGE-EXAMPLES.md](./USAGE-EXAMPLES.md) - Comprehensive real-world usage examples and patterns
2651
- - [COMMANDS.md](./COMMANDS.md) - Complete command reference with all options and examples
2652
- - [config.example.yaml](./config.example.yaml) - Fully annotated configuration file example
939
+ # See Also
2653
940
 
2654
- **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