Skip to content

Cli dx improvements#933

Merged
xav-db merged 4 commits into
mainfrom
cli-dx-improvements
Jun 5, 2026
Merged

Cli dx improvements#933
xav-db merged 4 commits into
mainfrom
cli-dx-improvements

Conversation

@xav-db

@xav-db xav-db commented Jun 5, 2026

Copy link
Copy Markdown
Member

Greptile Summary

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.

Important Files Changed

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.

Flowchart

%%{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]
Loading

Reviews (1): Last reviewed commit: "Implement lenient configuration loading ..." | Re-trigger Greptile

Greptile also left 2 inline comments on this PR.

xav-db added 2 commits June 5, 2026 21:14
This commit introduces functionality for listing indexes in an Enterprise cluster through a new `Indexes` command in the CLI. It adds the `CliClusterIndex` and `CliClusterIndexes` structs for managing index data, along with a new asynchronous function, `fetch_indexes_for_cluster`, to retrieve index information from the API. The command parsing has been updated to handle the new `Indexes` action, and tests have been added to ensure proper command parsing and functionality. These enhancements improve the CLI's capabilities for managing and interacting with cluster indexes.
This commit introduces two new methods in the HelixConfig and ProjectContext structs: `from_file_allow_no_instances` and `find_and_load_allow_no_instances`. These methods allow the loading of configurations that define zero instances, facilitating the re-adding of instances in scenarios where all instances have been removed. Additionally, the validation logic has been updated to support this lenient approach, ensuring that other necessary checks remain enforced. Tests have been added to verify the new behavior and ensure proper handling of configurations with no instances.
Comment thread helix-cli/src/commands/config.rs Outdated
Comment thread helix-cli/src/enterprise_cloud.rs
@xav-db xav-db merged commit 3a753be into main Jun 5, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant