Open source AI coding agent. Designed for large projects and real world tasks.
Go aiai-agentsai-developer-toolsai-toolsclicommand-linedeveloper-toolsgitgolanggpt-4llmopenaipolyglot-programmingterminalterminal-basedterminal-ui
infra updates, other fixes
Dane Schneiderbc312f767394
diff --git a/app/Dockerfile.server b/app/Dockerfile.serverindex 8f883f80..17b34b9c 100644--- a/app/Dockerfile.server+++ b/app/Dockerfile.server@@ -1,7 +1,7 @@FROM golang:1.21.3RUN apt-get update && \- apt-get install -y git=2.43.0+ apt-get install -y gitWORKDIR /app@@ -14,7 +14,9 @@ RUN cd server && go mod downloadCOPY ./server ./serverCOPY ./shared ./shared-RUN cd server && go build -o plandex-server .+ENV GOOS=linux+ENV GOARCH=amd64+RUN cd server && (rm plandex-server || true) && go build -o plandex-server .ENV PORT=8080EXPOSE 8080diff --git a/app/cli/changes_tui/main_viewport.go b/app/cli/changes_tui/main_viewport.goindex 58e11a1e..ad830f9d 100644--- a/app/cli/changes_tui/main_viewport.go+++ b/app/cli/changes_tui/main_viewport.go@@ -114,7 +114,7 @@ func (m changesUIModel) renderMainViewFooter() string {sidebarWidth := lipgloss.Width(m.renderSidebar())style := lipgloss.NewStyle().Width(m.width - sidebarWidth).Inherit(topBorderStyle).Foreground(lipgloss.Color(helpTextColor))- footer := ` (d)rop selected change • (c)opy to clipboard`+ footer := ` (r)eject change • (c)opy to clipboard`return style.Render(footer)}diff --git a/app/cli/changes_tui/model.go b/app/cli/changes_tui/model.goindex 254e5952..05038669 100644--- a/app/cli/changes_tui/model.go+++ b/app/cli/changes_tui/model.go@@ -109,8 +109,8 @@ func initialModel() *changesUIModel {),reject: bubbleKey.NewBinding(- bubbleKey.WithKeys("d"),- bubbleKey.WithHelp("d", "drop change"),+ bubbleKey.WithKeys("r"),+ bubbleKey.WithHelp("r", "reject change"),),copy: bubbleKey.NewBinding(@@ -123,6 +123,11 @@ func initialModel() *changesUIModel {bubbleKey.WithHelp("ctrl+a", "apply all changes"),),+ rejectAll: bubbleKey.NewBinding(+ bubbleKey.WithKeys("ctrl+r"),+ bubbleKey.WithHelp("ctrl+r", "reject all changes"),+ ),+quit: bubbleKey.NewBinding(bubbleKey.WithKeys("q", "ctrl+c"),bubbleKey.WithHelp("q", "quit"),diff --git a/app/cli/changes_tui/view.go b/app/cli/changes_tui/view.goindex 4441a8bf..49d286a4 100644--- a/app/cli/changes_tui/view.go+++ b/app/cli/changes_tui/view.go@@ -135,7 +135,7 @@ func (m changesUIModel) renderHelp() string {help += "(↑/↓) select change • "}- help += "(ctrl+a) apply pending • (ctrl+d) drop all • (q)uit"+ help += "(ctrl+a) apply pending • (ctrl+r) reject all • (q)uit"style := lipgloss.NewStyle().Width(m.width).Inherit(topBorderStyle).Foreground(lipgloss.Color(helpTextColor))return style.Render(help)}diff --git a/app/server/db/db.go b/app/server/db/db.goindex 8fdcbd95..20dfc8d4 100644--- a/app/server/db/db.go+++ b/app/server/db/db.go@@ -18,11 +18,22 @@ var Conn *sqlx.DBfunc Connect() error {var err error- if os.Getenv("DATABASE_URL") == "" {- return errors.New("DATABASE_URL not set")+ dbUrl := os.Getenv("DATABASE_URL")+ if dbUrl == "" {+ if os.Getenv("DB_HOST") != "" &&+ os.Getenv("DB_PORT") != "" &&+ os.Getenv("DB_USER") != "" &&+ os.Getenv("DB_PASSWORD") != "" &&+ os.Getenv("DB_NAME") != "" {+ dbUrl = "postgres://" + os.Getenv("DB_USER") + ":" + os.Getenv("DB_PASSWORD") + "@" + os.Getenv("DB_HOST") + ":" + os.Getenv("DB_PORT") + "/" + os.Getenv("DB_NAME")+ }++ if dbUrl == "" {+ return errors.New("DATABASE_URL or DB_HOST, DB_PORT, DB_USER, DB_PASSWORD, and DB_NAME environment variables must be set")+ }}- Conn, err = sqlx.Connect("postgres", os.Getenv("DATABASE_URL"))+ Conn, err = sqlx.Connect("postgres", dbUrl)if err != nil {return err}diff --git a/infra/deploy.sh b/infra/deploy.shindex 6b2b66dc..2fa007c1 100755--- a/infra/deploy.sh+++ b/infra/deploy.sh@@ -78,7 +78,7 @@ ensure_ecr_repository_exists# Set variables for the ECR repository and image tagECR_REPOSITORY=$(aws ecr describe-repositories --repository-names plandex-ecr-repository | jq -r '.repositories[0].repositoryUri')-IMAGE_TAG=$(git rev-parse --short HEAD)+export IMAGE_TAG=$(git rev-parse --short HEAD)# Function to deploy or update the CloudFormation stack using AWS CDKdeploy_or_update_stack() {diff --git a/infra/src/main.ts b/infra/src/main.tsindex 813a27fa..1dda08f3 100644--- a/infra/src/main.ts+++ b/infra/src/main.ts@@ -21,7 +21,9 @@ const imageTag = process.env.IMAGE_TAG;export class PlandexStack extends cdk.Stack {constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {- if (!tag) throw new Error("STACK_TAG environment variable is not set");+ if (!tag) {+ throw new Error("STACK_TAG environment variable is not set");+ }if (!notifyEmail) {throw new Error("NOTIFY_EMAIL environment variable is not set");}@@ -55,6 +57,78 @@ export class PlandexStack extends cdk.Stack {],});+ const rdsSecurityGroup = new ec2.SecurityGroup(this, "RdsSecurityGroup", {+ vpc,+ description: "Security group for RDS instance",+ });++ const efsSecurityGroup = new ec2.SecurityGroup(+ this,+ `plandex-efs-sg-${tag}`,+ {+ vpc,+ }+ );++ const fargateServiceSecurityGroup = new ec2.SecurityGroup(+ this,+ `plandex-fargate-service-sg-${tag}`,+ {+ vpc,+ allowAllOutbound: true, // Allows the containers to access the internet+ }+ );++ const albSecurityGroup = new ec2.SecurityGroup(this, "AlbSecurityGroup", {+ vpc,+ description: "Security group for the ALB",+ });++ // RDS security group rules+ fargateServiceSecurityGroup.addEgressRule(+ rdsSecurityGroup,+ ec2.Port.tcp(5432),+ "Allow outbound traffic from Fargate service to RDS instance"+ );++ rdsSecurityGroup.addIngressRule(+ fargateServiceSecurityGroup,+ ec2.Port.tcp(5432),+ "Allow Fargate service to access RDS instance"+ );++ // EFS security group rules+ efsSecurityGroup.addIngressRule(+ fargateServiceSecurityGroup,+ ec2.Port.tcp(2049),+ "Allow inbound NFS traffic from Fargate service"+ );++ fargateServiceSecurityGroup.addEgressRule(+ ec2.Peer.ipv4(vpc.vpcCidrBlock),+ ec2.Port.tcp(2049),+ "Allow outbound NFS traffic to EFS"+ );++ // ALB security group rules+ // Allow inbound HTTP and HTTPS traffic+ albSecurityGroup.addIngressRule(+ ec2.Peer.anyIpv4(),+ ec2.Port.tcp(80),+ "Allow inbound HTTP traffic"+ );+ albSecurityGroup.addIngressRule(+ ec2.Peer.anyIpv4(),+ ec2.Port.tcp(443),+ "Allow inbound HTTPS traffic"+ );+ // Allow traffic from the alb to the fargate service+ fargateServiceSecurityGroup.addIngressRule(+ albSecurityGroup,+ ec2.Port.tcp(8080),+ "Allow inbound traffic from ALB"+ );+// Create a Secrets Manager secret to store the RDS database credentialsconst dbCredentialsSecret = new secretsmanager.Secret(this,@@ -77,6 +151,7 @@ export class PlandexStack extends cdk.Stack {engine: rds.DatabaseInstanceEngine.postgres({version: rds.PostgresEngineVersion.VER_14,}),+ storageEncrypted: true,instanceType: ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE4_GRAVITON,ec2.InstanceSize.MICRO@@ -85,6 +160,7 @@ export class PlandexStack extends cdk.Stack {vpcSubnets: {subnetType: ec2.SubnetType.PRIVATE_ISOLATED,},+ securityGroups: [rdsSecurityGroup],credentials: rds.Credentials.fromSecret(dbCredentialsSecret), // Use credentials from Secrets Manager});@@ -108,6 +184,12 @@ export class PlandexStack extends cdk.Stack {`plandex-efs-file-system-${tag}`,{vpc,+ securityGroup: efsSecurityGroup,+ vpcSubnets: {+ subnetType: ec2.SubnetType.PRIVATE_ISOLATED, // Deploy the file system in private subnets+ },+ encrypted: true,+ enableAutomaticBackups: true,});@@ -124,7 +206,10 @@ export class PlandexStack extends cdk.Stack {managedPolicies: [iam.ManagedPolicy.fromAwsManagedPolicyName("service-role/AmazonECSTaskExecutionRolePolicy"- ), // Default policy for task execution+ ),+ iam.ManagedPolicy.fromAwsManagedPolicyName(+ "AmazonElasticFileSystemClientReadWriteAccess"+ ),],});dbCredentialsSecret.grantRead(taskExecutionRole);@@ -184,49 +269,6 @@ export class PlandexStack extends cdk.Stack {readOnly: false,});- // Create a Fargate service with a security group that allows outbound internet access and access to the RDS database- const fargateServiceSecurityGroup = new ec2.SecurityGroup(- this,- `plandex-fargate-service-sg-${tag}`, {- vpc,- allowAllOutbound: true,- }- );-- fargateServiceSecurityGroup.addEgressRule(- ec2.Peer.ipv4(vpc.vpcCidrBlock),- ec2.Port.tcp(2049),- "Allow outbound NFS traffic to EFS"- );-- const efsSecurityGroup = new ec2.SecurityGroup(this, `plandex-efs-sg-${tag}`, {- vpc,- });-- efsSecurityGroup.addIngressRule(- fargateServiceSecurityGroup,- ec2.Port.tcp(2049),- "Allow inbound NFS traffic from Fargate service"- );-- const fileSystem = new efs.FileSystem(- this,- `plandex-efs-file-system-${tag}`, {- vpc,- securityGroup: efsSecurityGroup,- {- vpc,- allowAllOutbound: true, // Allows the containers to access the internet- }- );-- // Define the ingress rule for the security group to allow the Fargate service to communicate with the RDS instance- fargateServiceSecurityGroup.addIngressRule(- ec2.Peer.anyIpv4(),- ec2.Port.tcp(5432),- "Allow Fargate service to access RDS instance"- );-const fargateService = new ecs.FargateService(this,`plandex-fargate-service-${tag}`,@@ -274,6 +316,10 @@ export class PlandexStack extends cdk.Stack {const alb = new elbv2.ApplicationLoadBalancer(this, `plandex-alb-${tag}`, {vpc,internetFacing: true,+ securityGroup: albSecurityGroup,+ vpcSubnets: {+ subnetType: ec2.SubnetType.PUBLIC,+ },});// Create an HTTP listener and add a redirect to HTTPS@@ -304,22 +350,6 @@ export class PlandexStack extends cdk.Stack {targets: [fargateService],});- // Allow inbound HTTP and HTTPS traffic to the ALB- // HTTP will be redirected to HTTPS- alb.connections.allowFromAnyIpv4(- ec2.Port.tcp(80),- "Allow inbound HTTP traffic"- );-- alb.connections.allowFromAnyIpv4(- ec2.Port.tcp(443),- "Allow inbound HTTPS traffic"- );-- // Define CloudWatch metrics for monitoring CPU and memory utilization- const cpuUtilizationMetric = fargateService.metricCpuUtilization();- const memoryUtilizationMetric = fargateService.metricMemoryUtilization();-// Create CloudWatch alarms for high CPU and memory utilizationconst alarmNotificationTopic = new sns.Topic(this,