Skip to content

prompt user for template variables at apply time #2165

Description

@Paras14

Feature idea

As an IDEasy user, I want to be asked for configuration values that cannot be preconfigured in the settings repo (like a backend URL or an API key) when the template is applied, so that plugins like AI assistants can be preconfigured without committing project-specific or secret values.
This came out of #412: to preconfigure AI coding assistants (Kilo Code, Cline) pointing to a self-hosted backend, we need config with a backend URL and an API key/token. The URL is project-specific and the key is a secret, so neither can be hardcoded in ide-settings. This is also the reason devonfw/ide-settings#67 was closed back then.
We already have variable substitution with the $[...] syntax (VariableSyntax.SQUARE) that gets resolved when templates are merged. But if a variable is not defined, AbstractEnvironmentVariables.resolveRecursive just logs a warning ("Undefined variable...") and leaves the placeholder in the file. So the resolution engine exists, but there is no way to acquire a missing value.
Interestingly we already solved this once, hardcoded for maven: Mvn.java scans settings.xml for $[...] variables, prompts via IdeContext.askForInput ("Please enter secret value for variable..."), and encrypts the value with mvn --encrypt-password. The idea of this issue is to make that generic instead of maven-only.

Ideas

  • a template (or variable definition) can declare that a variable should be prompted from the user at apply time if undefined
    distinguish two kinds of values:

    • plain values (e.g. AI_BACKEND_URL) will have normal input.
    • secrets (e.g. AI_API_KEY) will have inputs that should be masked (****). Note: askForInput currently echoes input in plain text, so a masked input mode is needed.
  • storing the entered value as plain text is acceptable for now, since we have no generic encryption for external config files anyway (only maven has its own settings-security.xml mechanism). Encryption could be a follow-up.

  • the syntax should be aligned with allow expressions in template variable definitions #989, which already proposes function expressions inside $[...] like $[@path(...)], prompting could be another such function, e.g. $[@ask('AI_API_KEY', 'secret')] (just a first idea, to be discussed).

Related: #412, #449, #987, #989

Additional context

No response

Metadata

Metadata

Assignees

Labels

configurationshould be configurable or configuration changeenhancementNew feature or requestmergerworkspace template merger (XML, JSON, properties)ready-to-implementsettingside-settings repo and replated processes and features

Fields

No fields configured for Feature.

Projects

Status
🏗 In progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions