Flatten template options in envio init prompt#890
Conversation
- Replace two-step initialization flow with single flattened selection - EVM now shows all options at once: Contract Import, Greeter, ERC20, Factory - Fuel also flattened: Contract Import, Greeter - SVM skips unnecessary prompt since only one option exists (Block Handler) - Add descriptive labels to help users understand each option - Remove unused prompt_init_flow_missing functions
- EVM now shows split options: - Contract Import: Block Explorer - Contract Import: Local ABI - Template: Greeter - Template: ERC20 - Feature: Factory - Fuel updated with consistent prefixes: - Contract Import: Local ABI - Template: Greeter - Category prefixes help users understand option types at a glance
📝 WalkthroughWalkthroughRemoved per-ecosystem missing-init prompting functions and consolidated CLI initialization into a flattened, language-aware prompt system in the central interactive_init module; ecosystem modules now expose template-based prompt helpers and accept Template/Args-derived inputs rather than prompting for missing InitFlow. Changes
Sequence Diagram(s)sequenceDiagram
participant CLI
participant InteractiveInit
participant Prompt (EVM/Fuel/SVM)
participant TemplateSelector
CLI->>InteractiveInit: call prompt_missing_init_args(maybe_cli_args)
InteractiveInit->>InteractiveInit: determine ecosystem & language (apply override)
InteractiveInit->>Prompt: prompt_evm_init_option / prompt_fuel_init_option / prompt_template_init_flow
Prompt->>TemplateSelector: present templates / import options
TemplateSelector-->>Prompt: chosen template/import option
Prompt-->>InteractiveInit: selected InitFlow
InteractiveInit-->>CLI: resolved InitFlow
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
codegenerator/cli/src/cli_args/interactive_init/fuel_prompts.rs (1)
102-104: Thetodo!()macro will panic at runtime if invoked.While this is intentional given Fuel's current single-network limitation, consider using
unimplemented!()with a descriptive message or returning an error instead of panicking.Suggested improvement
fn add_network(&mut self) -> Result<()> { - todo!("Fuel supports only one network at the moment") + anyhow::bail!("Fuel currently supports only one network") }codegenerator/cli/src/cli_args/interactive_init/mod.rs (1)
215-226: Consider adding a comment explaining future extensibility.The decision to skip prompting when there's only one SVM option is pragmatic. The inline comments are helpful, but you might want to note that this should be updated when more SVM templates are added.
Optional: Add TODO for future templates
/// Prompt for SVM initialization /// Since SVM currently only has one option (Block Handler template), /// we skip the intermediate prompt and go directly to initialization +// TODO: Add prompt similar to prompt_fuel_init_option when more SVM templates are available fn prompt_svm_init_option() -> Result<Ecosystem> {
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
codegenerator/cli/src/cli_args/interactive_init/fuel_prompts.rscodegenerator/cli/src/cli_args/interactive_init/mod.rscodegenerator/cli/src/cli_args/interactive_init/svm_prompts.rs
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2026-01-05T11:20:07.222Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2026-01-05T11:20:07.222Z
Learning: Config parsing flows: `human_config.rs` → `system_config.rs` → `hbs_templating/codegen_templates.rs`
Applied to files:
codegenerator/cli/src/cli_args/interactive_init/fuel_prompts.rscodegenerator/cli/src/cli_args/interactive_init/mod.rs
🧬 Code graph analysis (1)
codegenerator/cli/src/cli_args/interactive_init/svm_prompts.rs (2)
codegenerator/cli/src/cli_args/interactive_init/shared_prompts.rs (1)
prompt_template(18-22)codegenerator/integration_tests/src/main.rs (1)
init_config(71-94)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build_and_test
🔇 Additional comments (9)
codegenerator/cli/src/cli_args/interactive_init/fuel_prompts.rs (2)
1-30: LGTM - Clean refactoring of imports and template flow.The simplified imports and
prompt_template_init_flowfunction correctly handle the optional template argument, falling back to prompting when not provided via CLI.
109-159: Well-structured contract import selection flow.The async function properly chains ABI parsing, event selection, contract naming, and network selection. The destructuring on line 111 (
let LocalOrExplorerImport::Local(local_import_args) = ...) is safe sinceget_local_or_explorer_importalways returns aLocalvariant for Fuel.codegenerator/cli/src/cli_args/interactive_init/mod.rs (6)
33-58: Well-designed flattened option enum for EVM.Using
#[strum(serialize = "...")]for human-readable display strings and a manualall_options()method provides good control over presentation order. The options cover the main initialization paths clearly.
60-73: Consistent pattern for Fuel options.Mirrors the EVM pattern appropriately with fewer options reflecting Fuel's current capabilities.
75-92: Clean separation of CLI-provided vs interactive flows.Early return for CLI-provided init flow avoids nested conditionals and keeps the interactive prompting path clear.
94-124: Comprehensive CLI init flow routing.All
InitFlowvariants are handled appropriately:
- Fuel and SVM delegate to ecosystem-specific handlers
- Template defaults to
evm::Template::Greeterwhen not specified- SubgraphMigration prompts for ID if missing
- ContractImport delegates to EVM prompts
126-151: Ecosystem-specific CLI handlers follow consistent patterns.Both
handle_fuel_cli_init_flowandhandle_svm_cli_init_flowproperly fall back to the interactive prompt functions when no sub-flow is specified via CLI.
153-193: EVM prompt implementation correctly maps options to init flows.Each
EvmInitOptionvariant is properly mapped to the correspondingEcosystem::Evmwith the appropriateinit_flow. The use ofDefault::default()with struct update syntax forContractImportArgsis clean.codegenerator/cli/src/cli_args/interactive_init/svm_prompts.rs (1)
1-18: LGTM - Clean and minimal SVM template prompt implementation.The simplified imports and function structure parallel the Fuel implementation, maintaining consistency across ecosystems. The use of
prompt_templatefrom shared_prompts keeps the code DRY.
- Put Template: ERC20 before Template: Greeter - Hide templates and features when language is ReScript (only show contract import options) - SVM errors for ReScript since it only has template options
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
codegenerator/cli/src/cli_args/interactive_init/mod.rs (1)
105-135: CLI template path can generate invalid ReScript configs (missing language gating).
InitFlow::Template(args)unconditionally returnsEcosystem::Evm { init_flow: Template(...) }(Line 111-116). But interactive EVM explicitly disallows templates/features for ReScript (Line 51-53). This mismatch means--language rescript --init templatecan produce an unsupported config and fail later (or worse, generate broken output). Same concern likely applies to Fuel templates viahandle_fuel_cli_init_flow.Proposed fix (fail fast for unsupported template flows)
async fn handle_cli_init_flow(init_flow: InitFlow, language: &Language) -> Result<Ecosystem> { match init_flow { InitFlow::Fuel { init_flow: maybe_init_flow, } => handle_fuel_cli_init_flow(maybe_init_flow, language).await, InitFlow::Template(args) => { + if matches!(language, Language::ReScript) { + anyhow::bail!( + "EVM templates are not available for ReScript. Please use TypeScript or choose contract import." + ); + } let chosen_template = args.template.unwrap_or(evm::Template::Greeter); Ok(Ecosystem::Evm { init_flow: evm::InitFlow::Template(chosen_template), }) } InitFlow::SubgraphMigration(args) => { let input_subgraph_id = match args.subgraph_id { Some(id) => id, None => Text::new("[BETA VERSION] What is the subgraph ID?") .prompt() .context("Prompting user for subgraph id")?, }; Ok(Ecosystem::Evm { init_flow: evm::InitFlow::SubgraphID(input_subgraph_id), }) } InitFlow::ContractImport(args) => Ok(Ecosystem::Evm { init_flow: evm_prompts::prompt_contract_import_init_flow(args).await?, }), InitFlow::Svm { init_flow: maybe_init_flow, } => handle_svm_cli_init_flow(maybe_init_flow, language), } }
🤖 Fix all issues with AI agents
In @codegenerator/cli/src/cli_args/interactive_init/mod.rs:
- Around line 153-165: handle_svm_cli_init_flow currently accepts a Template
init flow from CLI without re-checking language-specific prohibitions enforced
in prompt_svm_init_option, so add a guard in handle_svm_cli_init_flow: when
matching Some(clap_definitions::svm::InitFlow::Template(args)), validate that
the provided args are compatible with the passed-in language (e.g., reject or
map templates for ReScript the same way prompt_svm_init_option does); if
incompatible return an Err with an appropriate message or call
prompt_svm_init_option(language) to preserve the interactive restriction.
Reference: handle_svm_cli_init_flow, clap_definitions::svm::InitFlow::Template,
prompt_svm_init_option, and svm_prompts::prompt_template_init_flow.
- Around line 287-289: The error context for the call to prompt_ecosystem(...)
no longer accurately describes the operation; update the .context("Failed
getting template") on the await of prompt_ecosystem(init_args.init_commands,
&language) to a clearer message such as "Failed selecting ecosystem/init option"
(or similar) so failures reflect that this step chooses the ecosystem/init
option rather than fetching a template; modify the context string in the
expression that awaits prompt_ecosystem to the new message.
- Around line 33-82: The interactive enums restrict templates for
Language::ReScript, but the CLI flows still allow template routes; update
handle_cli_init_flow and handle_fuel_cli_init_flow to centrally validate
language support before dispatching to template/feature flows (e.g., add a
helper like language_supports_template_init or reuse EvmInitOption::all_options
/ FuelInitOption::all_options to check availability for the requested Language)
and return/emit an error or fallback to contract import when ReScript is
selected so CLI and interactive paths have identical validation.
🧹 Nitpick comments (3)
codegenerator/cli/src/cli_args/interactive_init/mod.rs (3)
15-16: Potentially missing/implicit module dependency:init_config::{evm, fuel, Ecosystem}import change—ensure SVM is intentionally referenced viacrate::init_config::svmonly.
This file now usescrate::init_config::svm::*fully-qualified (Line 240-242) while importingevm/fuel(Line 15-16). That’s fine, but it’s easy to drift into inconsistent patterns—consider importingsvmtoo for symmetry (or keep all fully-qualified).
83-103: Router looks good; minor UX nit: ecosystem ordering and label specificity.
EcosystemOption::iter()will present options in enum order (Evm, Svm, Fuel). If you intended a different UX (e.g., Evm, Fuel, Svm), reorder the enum variants. Also, ifInitFlow::Templateis EVM-only, consider mentioning EVM in the option prompt label (Line 94) or downstream option prompt labels.
166-207: Flattened EVM prompt looks solid; consider de-duplicating contract-import arg construction.
The two branches buildclap_definitions::evm::ContractImportArgswith onlylocal_or_explorerdiffering (Line 174-195). A tiny helper (or local closure) would reduce repetition and make it harder to introduce drift when fields change.
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
codegenerator/cli/src/cli_args/interactive_init/mod.rs
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2026-01-05T11:20:07.222Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2026-01-05T11:20:07.222Z
Learning: Config parsing flows: `human_config.rs` → `system_config.rs` → `hbs_templating/codegen_templates.rs`
Applied to files:
codegenerator/cli/src/cli_args/interactive_init/mod.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build_and_test
🔇 Additional comments (3)
codegenerator/cli/src/cli_args/interactive_init/mod.rs (3)
208-226: Fuel flattened prompt wiring looks consistent with the new model.
The options map cleanly to either contract import prompting or a fixed template (Line 215-225).
228-244: SVM “single option” fast-path is good; error message is fine, but keep behavior consistent with CLI routing.
Skipping the prompt when there’s only one choice is a nice UX improvement (Line 229-243). Main concern remains ensuring the same ReScript restriction applies when SVM is selected via CLI args (see earlier comment).
137-152: Fuel CLI template path likely needs the same ReScript guard as interactive.
Interactive Fuel disallows templates for ReScript (Line 76-79), buthandle_fuel_cli_init_flowacceptsfuel::InitFlow::Template(args)unconditionally (Line 143-146). Add aLanguage::ReScriptcheck here (or insidefuel_prompts::prompt_template_init_flow) to keep CLI + interactive consistent.⛔ Skipped due to learnings
Learnt from: CR Repo: enviodev/hyperindex PR: 0 File: .cursor/rules/navigation.mdc:0-0 Timestamp: 2026-01-05T11:20:07.222Z Learning: Applies to codegenerator/cli/templates/static/**/*.res : Static ReScript template files live under `codegenerator/cli/templates/static/` and are copied verbatimLearnt from: CR Repo: enviodev/hyperindex PR: 0 File: .cursor/rules/navigation.mdc:0-0 Timestamp: 2026-01-05T11:20:07.222Z Learning: Config parsing flows: `human_config.rs` → `system_config.rs` → `hbs_templating/codegen_templates.rs`
| let ecosystem = prompt_ecosystem(init_args.init_commands, &language) | ||
| .await | ||
| .context("Failed getting template")?; |
There was a problem hiding this comment.
Outdated error context message: “Failed getting template” should reflect ecosystem/init option.
prompt_ecosystem(...) no longer just “gets template” (Line 287-289). Update the context to reduce confusion during failures.
Proposed fix
- let ecosystem = prompt_ecosystem(init_args.init_commands, &language)
+ let ecosystem = prompt_ecosystem(init_args.init_commands, &language)
.await
- .context("Failed getting template")?;
+ .context("Failed getting ecosystem / initialization option")?;📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| let ecosystem = prompt_ecosystem(init_args.init_commands, &language) | |
| .await | |
| .context("Failed getting template")?; | |
| let ecosystem = prompt_ecosystem(init_args.init_commands, &language) | |
| .await | |
| .context("Failed getting ecosystem / initialization option")?; |
🤖 Prompt for AI Agents
In @codegenerator/cli/src/cli_args/interactive_init/mod.rs around lines 287 -
289, The error context for the call to prompt_ecosystem(...) no longer
accurately describes the operation; update the .context("Failed getting
template") on the await of prompt_ecosystem(init_args.init_commands, &language)
to a clearer message such as "Failed selecting ecosystem/init option" (or
similar) so failures reflect that this step chooses the ecosystem/init option
rather than fetching a template; modify the context string in the expression
that awaits prompt_ecosystem to the new message.
Instead of erroring when SVM is selected with ReScript language, log a note and create a TypeScript project since SVM templates are only available in TypeScript.
- Consolidate ecosystem selection into fewer, focused functions - Move language override logic to single apply_language_override function - Remove duplicated EcosystemPromptResult construction - Clearer separation: get_ecosystem_from_cli vs get_ecosystem_from_prompt
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
codegenerator/cli/src/cli_args/interactive_init/mod.rs
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2026-01-05T11:20:07.222Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2026-01-05T11:20:07.222Z
Learning: Config parsing flows: `human_config.rs` → `system_config.rs` → `hbs_templating/codegen_templates.rs`
Applied to files:
codegenerator/cli/src/cli_args/interactive_init/mod.rs
📚 Learning: 2025-12-04T12:12:49.547Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-12-04T12:12:49.547Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.ts : Use `string | undefined` for optional string fields in Envio types, not `string | null`, as generated types are strict about null vs undefined
Applied to files:
codegenerator/cli/src/cli_args/interactive_init/mod.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build_and_test
🔇 Additional comments (4)
codegenerator/cli/src/cli_args/interactive_init/mod.rs (4)
32-80: Well-structured language-aware initialization options.The flattened option enums with language-specific filtering provide a clean, consistent pattern across EVM and Fuel ecosystems. The restriction of ReScript to contract-import-only flows is correctly implemented.
121-195: LGTM on CLI argument handling.The ecosystem resolution from CLI arguments is well-structured with sensible defaults (Greeter template at line 127, FeatureBlockHandler for SVM at line 191). The inline prompting for missing subgraph ID (lines 130-135) provides good UX.
197-253: LGTM on flattened interactive prompts.The unified prompt functions for EVM and Fuel provide a streamlined user experience by eliminating nested menus. The mapping from user selections to appropriate InitFlow variants with correct argument construction is accurate.
263-335: LGTM on main initialization flow.The integration of the new
EcosystemPromptResult(lines 292-295) cleanly handles language overrides, and defaulting to TypeScript (line 290) aligns with its broader template support. The API token flow remains properly structured.
| Language::TypeScript => vec![ | ||
| Self::ContractImportExplorer, | ||
| Self::ContractImportLocal, | ||
| Self::TemplateErc20, | ||
| Self::TemplateGreeter, | ||
| Self::FeatureFactory, | ||
| ], |
There was a problem hiding this comment.
Can be nice to use strum iterator
| println!( | ||
| "Note: SVM templates are only available in TypeScript. Creating a TypeScript project." | ||
| ); |
There was a problem hiding this comment.
Investigate colour text
Summary by CodeRabbit
Refactor
New Features
✏️ Tip: You can customize this high-level summary in your review settings.