Skip to content

Commit 5a5c21d

Browse files
authored
impr (cli): adding support for loading env variables & selecting embedding model, also made docker auto start (#703)
## Description This PR adds three major improvements to the CLI: automatic cleanup on init/add failures, Docker auto-start functionality, and support for loading environment variables (API keys) and selecting embedding models. **Key Changes:** - Added `CleanupTracker` to rollback filesystem and config changes when init/add operations fail - Docker daemon now auto-starts on macOS/Windows/Linux with user confirmation - Environment variables (`.env` file) now loaded and passed to containers for `OPENAI_API_KEY` and `GEMINI_API_KEY` - `embedding_model` field added to config with `text-embedding-ada-002` as default - Install script checks for Docker Desktop on macOS and offers homebrew installation - Improved null-safety in HQL analyzer to prevent panics **Critical Issues:** - In `init.rs`, config backup is called after save instead of before, breaking rollback functionality - In `docker.rs`, `dotenvy::dotenv()` is called repeatedly in `environment_variables()`, polluting process environment state <details><summary><h3>Important Files Changed</h3></summary> File Analysis | Filename | Score | Overview | |----------|-------|----------| | helix-cli/src/cleanup.rs | 5/5 | added new cleanup tracker for rollback on init/add failures - well-structured with tests | | helix-cli/src/commands/init.rs | 2/5 | integrated cleanup tracker but backup timing is incorrect - backup called after save instead of before | | helix-cli/src/docker.rs | 2/5 | added auto-start docker functionality and env loading - dotenvy called repeatedly causing environment pollution | | helix-cli/src/config.rs | 5/5 | added embedding model selection with proper defaults and serialization handling | </details> </details> <details><summary><h3>Sequence Diagram</h3></summary> ```mermaid sequenceDiagram participant User participant CLI as Helix CLI participant Cleanup as CleanupTracker participant Docker as DockerManager participant Env as .env File participant Config as helix.toml Note over User,Config: Init Command Flow User->>CLI: helix init [options] CLI->>Cleanup: Create CleanupTracker CLI->>Env: dotenvy::dotenv() (load env vars) CLI->>Config: Create helix.toml Cleanup->>Cleanup: Track created file CLI->>Cleanup: Track directories/files alt Cloud deployment selected CLI->>Cleanup: backup_config() CLI->>Config: Save cloud config end alt Error occurs CLI->>Cleanup: cleanup() Cleanup->>Config: Restore backup Cleanup->>Cleanup: Remove tracked files/dirs Cleanup-->>User: Cleanup summary end Note over User,Config: Docker Auto-Start Flow User->>CLI: helix build/run CLI->>Docker: check_docker_available() alt Docker not running Docker->>User: Prompt to start Docker alt User accepts Docker->>Docker: start_docker_daemon() Docker->>Docker: wait_for_docker(15s) Docker->>Docker: Verify running end end Docker->>Env: dotenvy::dotenv() Docker->>Docker: environment_variables() Note right of Docker: Loads OPENAI_API_KEY,<br/>GEMINI_API_KEY from env Docker->>Config: Generate docker-compose.yml Note right of Config: Includes dynamic env vars ``` </details> <!-- greptile_other_comments_section --> **Context used:** - Rule from `dashboard` - When using OnceLock::new() in Rust code, wrap it in a `const { ... }` block to satisfy clippy lints.... ([source](https://app.greptile.com/review/custom-context?memory=7f3c5d9b-5a5e-41cd-9e7e-1992245f637c)) <!-- /greptile_comment -->
2 parents 634fa94 + eb2d47e commit 5a5c21d

File tree

35 files changed

+1771
-514
lines changed

35 files changed

+1771
-514
lines changed

.github/workflows/clippy_check.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@ jobs:
2020

2121
- name: Cache cargo dependencies
2222
uses: actions/cache@v4
23+
continue-on-error: true
2324
with:
2425
path: |
2526
~/.cargo/registry
2627
~/.cargo/git
2728
target
28-
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
29+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') || 'fallback' }}
2930
restore-keys: |
3031
${{ runner.os }}-cargo-
3132

.github/workflows/dashboard_check.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@ jobs:
2020

2121
- name: Cache cargo dependencies
2222
uses: actions/cache@v4
23+
continue-on-error: true
2324
with:
2425
path: |
2526
~/.cargo/registry
2627
~/.cargo/git
2728
target
28-
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
29+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') || 'fallback' }}
2930
restore-keys: |
3031
${{ runner.os }}-cargo-
3132

.github/workflows/db_tests.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@ jobs:
2222

2323
- name: Cache cargo dependencies
2424
uses: actions/cache@v4
25+
continue-on-error: true
2526
with:
2627
path: |
2728
~/.cargo/registry
2829
~/.cargo/git
2930
target
30-
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
31+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') || 'fallback' }}
3132
restore-keys: |
3233
${{ runner.os }}-cargo-
3334

.github/workflows/hql_tests.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,13 @@ jobs:
2929

3030
- name: Cache cargo registry
3131
uses: actions/cache@v3
32+
continue-on-error: true
3233
with:
3334
path: |
3435
~/.cargo/registry
3536
~/.cargo/git
3637
target
37-
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
38+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') || 'fallback' }}
3839
restore-keys: |
3940
${{ runner.os }}-cargo-
4041

.github/workflows/s3_push.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Push to S3
2+
3+
on:
4+
release:
5+
types: [published, created]
6+
create:
7+
tags:
8+
- 'v*'
9+
workflow_dispatch:
10+
11+
permissions:
12+
id-token: write
13+
contents: read
14+
15+
jobs:
16+
upload-to-s3:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
23+
- name: Configure AWS credentials using OIDC
24+
uses: aws-actions/configure-aws-credentials@v4
25+
with:
26+
role-to-assume: arn:aws:iam::${{ vars.AWS_ACCOUNT_ID }}:role/GitHubActionsS3Role
27+
aws-region: us-east-1
28+
29+
- name: Upload specified files and directories to S3
30+
run: |
31+
# Sync directories
32+
aws s3 sync helix-cli/ s3://helix-repo/template/helix-cli/ --exclude "target/*"
33+
aws s3 sync helix-container/ s3://helix-repo/template/helix-container/ --exclude "target/*"
34+
aws s3 sync helix-macros/ s3://helix-repo/template/helix-macros/ --exclude "target/*"
35+
aws s3 sync metrics/ s3://helix-repo/template/metrics/ --exclude "target/*"
36+
37+
# Upload root-level Cargo files
38+
aws s3 cp Cargo.lock s3://helix-repo/template/Cargo.lock
39+
aws s3 cp Cargo.toml s3://helix-repo/template/Cargo.toml
40+
41+
- name: Upload completion notification
42+
if: success()
43+
run: |
44+
echo "Successfully uploaded all files to S3 bucket: helix-repo"
45+
echo "Upload triggered by: ${{ github.event_name }}"
46+
echo "Reference: ${{ github.ref }}"

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

helix-cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "helix-cli"
3-
version = "2.1.2"
3+
version = "2.1.3"
44
edition = "2024"
55

66
[dependencies]

0 commit comments

Comments
 (0)