Skip to content

v3.0.5

Latest

Choose a tag to compare

@github-actions github-actions released this 05 Jun 20:52
3a753be
Cli dx improvements (#933)

<!-- greptile_comment -->

<h3>Greptile Summary</h3>

This PR makes two DX improvements to the Helix CLI: it allows `helix
add` to run inside a project that currently has zero instances (so users
can re-add an instance after deleting the last one), and it adds a new
`helix cluster indexes` subcommand that lists vector, equality, and
range indexes for an Enterprise cluster.

- **Zero-instance tolerance for `helix add`**: `HelixConfig::from_file`
and `ProjectContext::find_and_load` are each split into a strict and a
lenient variant; `helix add` now uses the lenient path, with new unit
tests covering both paths.
- **`helix cluster indexes` command**: A new `Indexes` subcommand
(aliased `indices`) is added under `ClusterConfigAction`; it
auto-resolves the cluster ID from the current project's Enterprise
instance when `--cluster-id` is omitted, and supports `--format json`.
- **Improved error hint**: The `MissingInstances` error now surfaces a
concrete `helix add` command as a hint.

<details><summary><h3>Important Files Changed</h3></summary>

| Filename | Overview |
|----------|----------|
| helix-cli/src/commands/config.rs | Adds `list_indexes_for_cluster`
handler and `resolve_cluster_id_for_indexes` fallback; error from
`find_and_load` is silently swallowed, which can hide config-parse
failures behind a generic hint message. |
| helix-cli/src/enterprise_cloud.rs | Adds
`CliClusterIndex`/`CliClusterIndexes` structs and
`fetch_indexes_for_cluster`; alias-only rename means `--format json`
serializes to `index_name`/`index_type` instead of the API's
`name`/`type`. |
| helix-cli/src/config.rs | Cleanly refactors `from_file` into a
`from_file_inner(require_instances)` gate; new tests cover both strict
and lenient validation paths. |
| helix-cli/src/project.rs | Adds `find_and_load_allow_no_instances` by
delegating to a shared `load_with(require_instances)` helper; logic is
straightforward. |
| helix-cli/src/commands/add.rs | Switches to
`find_and_load_allow_no_instances` so `helix add` can re-add an instance
when the last one was deleted. |
| helix-cli/src/lib.rs | Adds `Indexes` subcommand under
`ClusterConfigAction` with `--cluster-id`/`--format` args and `indices`
alias; clean. |
| helix-cli/src/errors.rs | Adds actionable `with_hint` to
`MissingInstances` error message; no logic changes. |
| helix-cli/src/main.rs | Adds a parser test for `cluster indexes
--cluster-id ent_123`; straightforward test coverage. |

</details>

</details>

<details><summary><h3>Flowchart</h3></summary>

```mermaid
%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[helix cluster indexes] --> B{--cluster-id provided?}
    B -- yes --> C[trim & validate non-empty]
    C --> D[Use provided cluster_id]
    B -- no --> E[ProjectContext::find_and_load\nrequire_instances=true]
    E -- error --> F[Return: Provide --cluster-id hint]
    E -- ok --> G{enterprise instances count}
    G -- 0 --> H[Error: No Enterprise instances\nin helix.toml]
    G -- 1 --> I[Use sole instance cluster_id]
    G -- many & interactive --> J[prompts::select_instance]
    G -- many & non-interactive --> K[Error: list available instances]
    J --> L[Lookup cluster_id from config]
    I --> L
    D --> M[require_auth + fetch_indexes_for_cluster]
    L --> M
    M --> N{--format json?}
    N -- yes --> O[print_json]
    N -- no --> P[print_cluster_indexes\nvector / equality / range]
```
</details>

<sub>Reviews (1): Last reviewed commit: ["Implement lenient
configuration loading
..."](https://github.com/helixdb/helix-db/commit/68e79ed16eaca0c0096908ac1ad30417fda42cb3)
| [Re-trigger
Greptile](https://app.greptile.com/api/retrigger?id=35920797)</sub>

> Greptile also left **2 inline comments** on this PR.

<!-- /greptile_comment -->