You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This commit was created on GitHub.com and signed with GitHub’s verified signature.
feat(cli): helix sync + integrating with dashboard and backend (#868)
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
This PR implements `helix sync` to pull schema and query files from
Helix Cloud clusters, integrating the CLI with the dashboard backend. It
adds comprehensive workspace/project/cluster management flows for both
standard and enterprise deployments.
**Major additions:**
- New `helix sync` command with three flows: workspace-based,
project-based, and instance-specific syncing
- Interactive workspace/project/cluster selection using `cliclack`
prompts
- Enterprise cluster support across `add`, `init`, `sync`, and `delete`
commands
- Path sanitization for remote files to prevent directory traversal
attacks
- Workspace config persistence to `~/.helix/config`
- New `intersect` graph traversal operator in the query engine
- Fixed `Ord` implementation in `Value` type to use consistent variant
ordering
**Critical issues found:**
1. `helix-cli/src/commands/sync.rs:495` - `config.enterprise.clear()`
unconditionally removes ALL enterprise instances, not just those from
the selected project (similar to the already-flagged issue with cloud
instances)
2. `helix-cli/src/commands/delete.rs:93,99` - `todo!()` macros will
panic when users delete enterprise instances
3. `helix-db/src/protocol/value.rs:237-249` - Ord/PartialEq
inconsistency in Date↔String comparison due to reversed ordering
**Recommendations:**
- Replace `config.enterprise.clear()` with selective removal logic (like
`config.cloud.retain()`)
- Implement enterprise instance deletion instead of using `todo!()`
- Fix the Date/String comparison ordering to maintain Ord/PartialEq
consistency
<details><summary><h3>Important Files Changed</h3></summary>
| Filename | Overview |
|----------|----------|
| helix-cli/src/commands/sync.rs | New 1410-line file implementing
`helix sync` command with workspace/project/cluster selection flows,
file syncing from cloud, and path sanitization. Notable issue:
`reconcile_project_config_from_cloud` clears all enterprise entries
(line 495) which could delete unrelated instances. |
| helix-cli/src/commands/workspace_flow.rs | New 456-line file
implementing workspace → project → cluster creation flow for `helix add`
and `helix init`. Clean implementation with proper workspace caching,
billing checks, and enterprise cluster support. |
| helix-cli/src/prompts.rs | New 551-line file providing interactive CLI
prompts using `cliclack`. Implements workspace/cluster selection, input
validation, and deployment configuration flows. Well-structured with
proper validation logic. |
| helix-cli/src/config.rs | Added `WorkspaceConfig` for persisting
workspace selections to `~/.helix/config`, and
`EnterpriseInstanceConfig` for enterprise cluster support. Clean
additions with proper error handling. |
| helix-cli/src/commands/delete.rs | Added enterprise instance handling
with `todo!()` placeholders on lines 93 and 99. Will panic when users
try to delete enterprise instances created via `helix add cloud` or
`helix init cloud`. |
| helix-db/src/protocol/value.rs | Fixed `Ord` implementation to use
consistent variant ordering instead of returning `Equal` for
incomparable types (which violated Ord contract). Added `Date`↔`String`
comparison logic. |
</details>
</details>
<details><summary><h3>Flowchart</h3></summary>
```mermaid
flowchart TD
A[helix sync] --> B{Project context<br/>exists?}
B -->|No| C[Workspace Sync Flow]
B -->|Yes, with instance| D[Instance-specific Sync]
B -->|Yes, interactive| E[Project Sync Flow]
C --> F[Load/Select Workspace]
F --> G[Fetch Workspace Clusters]
G --> H{Cluster Type?}
H -->|Standard| I[Sync .hx files from cluster]
H -->|Enterprise| J[Sync .rs files from cluster]
E --> K[Authenticate & Select Workspace]
K --> L[Resolve/Create Project]
L --> M[Fetch Project Clusters]
M --> N[User Selects Cluster]
N --> O{Cluster Type?}
O -->|Standard| P[Sync .hx files into project]
O -->|Enterprise| Q[Sync .rs files into project]
P --> R[Reconcile helix.toml]
Q --> R
R --> S[Update cloud/enterprise instances]
D --> T{Instance Type?}
T -->|Helix Cloud| U[Pull from cloud cluster]
T -->|Enterprise| V[Pull from enterprise cluster]
T -->|Local| W[Not implemented - warn user]
U --> X[Fetch cluster metadata]
X --> Y[Reconcile helix.toml]
V --> Z[Fetch enterprise files]
style R fill:#ff9999
style S fill:#ff9999
style Y fill:#ff9999
```
</details>
<sub>Last reviewed commit: a330ecb</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->