Skip to content

Flatten template options in envio init prompt#890

Merged
DZakh merged 8 commits into
mainfrom
claude/flatten-envio-init-templates-AU0gX
Jan 13, 2026
Merged

Flatten template options in envio init prompt#890
DZakh merged 8 commits into
mainfrom
claude/flatten-envio-init-templates-AU0gX

Conversation

@DZakh

@DZakh DZakh commented Jan 10, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Refactor

    • Redesigned interactive init experience to favor per-ecosystem, language-aware choices and simplified flows.
    • Flattened prompts into single-step options for EVM, Fuel and SVM and removed legacy multi-step fallback prompting.
  • New Features

    • Introduced clearer, language-specific init options and streamlined import/template pathways, including improved handling when an ecosystem restricts languages.

✏️ Tip: You can customize this high-level summary in your review settings.

- 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
@coderabbitai

coderabbitai Bot commented Jan 10, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Removed 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

Cohort / File(s) Summary
Central interactive init routing
codegenerator/cli/src/cli_args/interactive_init/mod.rs
Rewrote initialization orchestration: added EcosystemPromptResult, per-language enums (EvmInitOption, FuelInitOption), language-override logic, async flows to resolve CLI vs interactive choices, and new prompt handlers (prompt_evm_init_option, prompt_fuel_init_option, prompt_ecosystem, etc.).
Fuel prompt adjustments
codegenerator/cli/src/cli_args/interactive_init/fuel_prompts.rs
Removed prompt_init_flow_missing and dropped ClapInitFlow aliasing; Fuel init options folded into the central flattened prompt flow and imports consolidated.
SVM prompt simplification
codegenerator/cli/src/cli_args/interactive_init/svm_prompts.rs
Removed prompt_init_flow_missing; prompt_template_init_flow now accepts TemplateArgs and returns InitFlow::Template after template selection (no standalone missing-InitFlow prompt).

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 I hopped through prompts and tidied the rows,
One path now chosen where the option grows,
Templates picked with a nimble hop,
Fewer questions, fewer stops,
A carrot-cheer as the new flow goes 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 69.23% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Flatten template options in envio init prompt' accurately summarizes the main change: refactoring the initialization flow to flatten and reorganize template selection options based on language and ecosystem choices.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
codegenerator/cli/src/cli_args/interactive_init/fuel_prompts.rs (1)

102-104: The todo!() 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

📥 Commits

Reviewing files that changed from the base of the PR and between 1ea763b and 3845956.

📒 Files selected for processing (3)
  • codegenerator/cli/src/cli_args/interactive_init/fuel_prompts.rs
  • codegenerator/cli/src/cli_args/interactive_init/mod.rs
  • codegenerator/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.rs
  • codegenerator/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_flow function 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 since get_local_or_explorer_import always returns a Local variant 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 manual all_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 InitFlow variants are handled appropriately:

  • Fuel and SVM delegate to ecosystem-specific handlers
  • Template defaults to evm::Template::Greeter when 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_flow and handle_svm_cli_init_flow properly 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 EvmInitOption variant is properly mapped to the corresponding Ecosystem::Evm with the appropriate init_flow. The use of Default::default() with struct update syntax for ContractImportArgs is 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_template from 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
@DZakh DZakh requested a review from JasoonS January 10, 2026 15:38

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 returns Ecosystem::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 template can produce an unsupported config and fail later (or worse, generate broken output). Same concern likely applies to Fuel templates via handle_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 via crate::init_config::svm only.
This file now uses crate::init_config::svm::* fully-qualified (Line 240-242) while importing evm/fuel (Line 15-16). That’s fine, but it’s easy to drift into inconsistent patterns—consider importing svm too 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, if InitFlow::Template is 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 build clap_definitions::evm::ContractImportArgs with only local_or_explorer differing (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

📥 Commits

Reviewing files that changed from the base of the PR and between 3845956 and e791737.

📒 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), but handle_fuel_cli_init_flow accepts fuel::InitFlow::Template(args) unconditionally (Line 143-146). Add a Language::ReScript check here (or inside fuel_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 verbatim
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`

Comment thread codegenerator/cli/src/cli_args/interactive_init/mod.rs
Comment thread codegenerator/cli/src/cli_args/interactive_init/mod.rs Outdated
Comment on lines 287 to 289
let ecosystem = prompt_ecosystem(init_args.init_commands, &language)
.await
.context("Failed getting template")?;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

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.

Suggested change
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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e791737 and fe4f75e.

📒 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.

Comment thread codegenerator/cli/src/cli_args/interactive_init/mod.rs
@DZakh DZakh requested a review from JonoPrest January 13, 2026 07:49
@DZakh DZakh enabled auto-merge (squash) January 13, 2026 10:37
Comment on lines +52 to +58
Language::TypeScript => vec![
Self::ContractImportExplorer,
Self::ContractImportLocal,
Self::TemplateErc20,
Self::TemplateGreeter,
Self::FeatureFactory,
],

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be nice to use strum iterator

Comment on lines +112 to +114
println!(
"Note: SVM templates are only available in TypeScript. Creating a TypeScript project."
);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Investigate colour text

@DZakh DZakh merged commit 01d1b9e into main Jan 13, 2026
2 checks passed
@DZakh DZakh deleted the claude/flatten-envio-init-templates-AU0gX branch January 13, 2026 10:46
@coderabbitai coderabbitai Bot mentioned this pull request Apr 2, 2026
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.

3 participants