You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Show project-derived defaults in template prompts - #21420
Template authors can already derive generated values from the project name, but interactive prompts currently display only the parameter's literal default. An optional override therefore shows an empty default even when pressing Enter will generate a meaningful name.
Add a generic, opt-in defaultValueSource setting to the selected template host file. The CLI displays the parameter's native coalesce fallback using the already-entered project name, without hiding the prompt or introducing a new expression language.
Use the template engine's public macro and dependency APIs to evaluate deterministic native regex/coalesce graphs.
Preserve omission when accepting the displayed fallback, including typing that same value. Different answers remain explicit overrides.
Limit the opt-in to optional, empty-default string parameters whose source is their native coalesce symbol. Reject conflicting computed value sources, invalid graphs, cycles, and unsupported dependencies before prompting or writing output.
Leave existing literal defaults, choices, required/conditional prompts, hidden parameters, and noninteractive generation behavior unchanged for templates without the opt-in.
Document the contract and add 23 focused regression cases with generated-output snapshots.
This is a focused change based on current main; it does not include inherited template-source configuration work.
In template.json, displayName and shortName remain optional string parameters with defaultValue: "". Their corresponding generated symbols use native coalesce, with fallbacks to name and a native regex-normalized name respectively. The full generic example is documented in docs/specs/git-templating.md.
aspire new --template-path ./template --name "Demo.Project Name" --output ./generated --suppress-agent-init
The questionnaire still prompts:
Service display name (Demo.Project Name):
Service short name (Demo-Project-Name):
Pressing Enter at both prompts generates those values while leaving the override parameters unset. Explicit different answers replace the fallbacks.
Screenshots / Recordings
This PR includes UI changes. The screenshot below shows the real CLI prompts from this branch's build using a generic local template, with the display-name fallback accepted and the short-name prompt awaiting Enter. The viewport includes only the prompts.
Validation
After rebasing onto main, the following command passed: 426 tests, 0 failures, 0 skipped:
The suite covers actual displayed defaults, dotted/spaced names, prompted project names, default acceptance, explicit overrides, omission semantics, invalid sources, and existing template behavior.
A real Hex1b terminal run against the rebuilt CLI, using an isolated ASPIRE_HOME and a generic local fixture, also passed: Enter accepted both displayed defaults and generated:
Display=Demo.Project Name
Short=Demo-Project-Name
RawDisplay=
RawShort=
Security considerations
The new setting projects values from untrusted template metadata earlier, during prompting. The supported dependency graph is restricted to the project name, the omitted override parameter, and native regex/coalesce symbols. Bound values, other parameters that might contain secrets, and nondeterministic generators are rejected rather than previewed. Evaluation uses the existing engine implementations; no scripts, post-actions, additional configuration acquisition, or new network operations are introduced.
Fixes # (issue)
Checklist
Is this feature complete?
Yes. Ready to ship.
No. Follow-up changes expected.
Are you including unit tests for the changes and scenario tests if relevant?
Yes
No
Did you add public API?
Yes
If yes, did you have an API Review for it?
Yes
No
Did you add <remarks /> and <code /> elements on your triple slash comments?
Yes
No
No
Does the change make any security assumptions or guarantees?
Yes
If yes, have you done a threat model and had a security review?
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Default previews can disagree with generated values, and incomplete, delayed graph validation allows invalid references to reach prompting and generation.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The name shortcut does not verify that the symbol is the engine’s project-name parameter, allowing redefined symbols to bypass dependency restrictions and generate a value different from the prompt preview.
Validate name against the loaded template's IsName metadata rather than cached discovery definitions. Cover constant, random, and parameter redefinitions without changing ordinary project-name defaults.
Co-authored-by: Copilot App <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Default resolution and dependency validation ignore additional configuration files, allowing the displayed default to differ from the value used during generation.
TemplateConfigModel.FromStream reads only the primary file, while generation merges additionalConfigFiles, so a split configuration that changes a reachable symbol can produce a different value from the displayed default. Those changes also bypass this dependency validation. Use the engine's effective merged configuration, or reject split configurations when this opt-in is present, and add a regression where an additional file changes a reachable symbol.
⚠️ Documentation was required for this change, but a docs PR could not be drafted automatically.
Docs are required (signals: cli_resource_strings_changed, defaults_or_constants_file_changed, pr_body_has_cli_flag_mention, pr_body_has_user_facing_section), but no docs PR was drafted. The defaultValueSource setting extends .template.config/aspirecli.host.json and aspire new --template-path. Neither is documented anywhere in src/frontend/src/content/docs/. A grep for template-path, .template.config, aspirecli.host, symbolInfo and defaultValueSource found no matches. The only contract documentation is the source repo's docs/specs/git-templating.md. A new page would need the base git-templating feature to be documented first. That is a larger decision for the SME than this PR's incremental change. Please decide where custom-template authoring docs should live. The PR body's user-facing section and the spec are the source material.
## Description
Show templates from configured Git and directory sources alongside
built-in templates in interactive `aspire new`, without a separate
source submenu. This builds on #21329, #21388, and #21420; it does not
close those already-merged issues/PRs.
The terminal picker uses nonselectable source headings, retains built-in
ordering and defaults, and selects the exact discovered template object
even when names collide. Leaves use `Template Name (Template
Description)` without repeating the source or short name; missing
descriptions leave just the name. The separate search action has been
removed from the initial picker; explicit template search/invocation
support is unchanged.
Template source objects support optional `displayName` in global and
accepted init-source configuration, for example:
```json
{
"templateSources": {
"company": {
"repository": "https://github.com/example/templates",
"displayName": "Company templates"
}
}
}
```
Missing, null, empty, or space-only display names use the alias. Other
types and control characters fail existing strict configuration
validation. `aspire config set templateSources.company.displayName
"Company templates" --global` edits an existing source; no new flag is
added. Typed load/save, source listing, configuration edits and runtime
inheritance preserve the field. Global-over-inherited alias collisions
replace the entire definition, including the display name. Inherited
values are never persisted to global or generated-project configuration.
Aliases remain the stable group identity, command reference and
source-disambiguating flat label; identical display names do not merge
sources or select a different source. Headings now use bold/default
foreground, following existing CLI section headings such as `aspire
doctor`, rather than Spectre's faded disabled grey. Leaf-only navigation
is unchanged.
Grouped console labels normalize multiline whitespace and truncate the
combined name/description with an ellipsis to the available
terminal-cell width, reserving arrow, indentation and padding. Source
headings and the selected-value echo also fit the width. Spectre's
cell-aware cropping preserves grapheme clusters, wide characters and
combining sequences; metadata is safely escaped. Full template metadata
is retained.
The pinned Spectre.Console 0.57.2 uses the same converter for display
and search and has no separate search predicate. Following the explicit
UX decision to keep Spectre and truncate in the CLI, case-insensitive
search matches only the visible prefix of a truncated label, not its
hidden tail. No dependency update or custom prompt is introduced.
Type-to-search moves to a matching choice; it does not filter the list.
Grouping and terminal display labels are optional interaction-service
metadata. VS Code retains the unchanged flat `string[]` RPC and complete
unique source-qualified labels; extension grouping and description
search remain deferred. Existing inherited-source consent/no-fetch
boundaries, explicit and noninteractive flows, source acquisition
warnings, cached snapshots, authentication protections, and post-action
authorization remain intact.
Validation for the latest friendly-heading revision:
```bash
dotnet test --project tests/Aspire.Cli.Tests/Aspire.Cli.Tests.csproj --no-launch-profile -- --filter-class '*.ConsoleInteractionServiceTests' --filter-class '*.ExtensionInteractionServiceTests' --filter-class '*.NewCommandLocalTemplateTests' --filter-class '*.TemplateSourceConfigurationTests' --filter-class '*.AspireConfigFileTests' --filter-class '*.ConfigSourceServiceTests' --filter-class '*.SettingsSchemaBuilderTests' --filter-class '*.ConfigCommandTests' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true'
```
Result: **1048 passed, 0 failed, 1 skipped**. Covers typed serialization
and schema, strict field validation, source updates/listing, inherited
display names without persistence, complete global alias precedence,
duplicate friendly headings and exact template generation,
consent/no-fetch, unchanged extension fallback, terminal cell-width
thresholds and narrow terminals, Unicode/combining sequences, escaped
markup, normalized multiline labels and visible-prefix-only search.
Rendering and configuration snapshots were reviewed and the suite rerun
successfully.
```bash
dotnet build /t:UpdateXlf src/Aspire.Cli/Aspire.Cli.csproj -v:q
git diff --check
```
Result: **both passed**. Localized display-name validation and
allowed-field diagnostics regenerated.
A refreshed screenshot of the actual repository-built CLI, with friendly
source names, bold/default headings and a long description cropped with
an ellipsis, is provided in the associated Copilot handoff, not uploaded
GitHub media. Earlier screenshots and the description-search recording
predate these latest formatting changes. No cloud resources or external
account changes were used.
## Checklist
- Is this feature complete?
- [x] Yes. Ready to ship.
- [ ] No. Follow-up changes expected.
- Are you including unit tests for the changes and scenario tests if
relevant?
- [x] Yes
- [ ] No
- Did you add public API?
- [ ] Yes
- If yes, did you have an API Review for it?
- [ ] Yes
- [ ] No
- Did you add `<remarks />` and `<code />` elements on your triple slash
comments?
- [ ] Yes
- [ ] No
- [x] No
- Does the change make any security assumptions or guarantees?
- [ ] Yes
- If yes, have you done a threat model and had a security review?
- [ ] Yes
- [ ] No
- [x] No
---------
Co-authored-by: Copilot App <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Template authors can already derive generated values from the project name, but interactive prompts currently display only the parameter's literal default. An optional override therefore shows an empty default even when pressing Enter will generate a meaningful name.
Add a generic, opt-in
defaultValueSourcesetting to the selected template host file. The CLI displays the parameter's nativecoalescefallback using the already-entered project name, without hiding the prompt or introducing a new expression language.regex/coalescegraphs.coalescesymbol. Reject conflicting computed value sources, invalid graphs, cycles, and unsupported dependencies before prompting or writing output.This is a focused change based on current
main; it does not include inherited template-source configuration work.User-facing usage
In
.template.config/aspirecli.host.json:{ "symbolInfo": { "displayName": { "defaultValueSource": "displayNameValue" }, "shortName": { "defaultValueSource": "shortNameValue" } } }In
template.json,displayNameandshortNameremain optional string parameters withdefaultValue: "". Their corresponding generated symbols use nativecoalesce, with fallbacks tonameand a native regex-normalized name respectively. The full generic example is documented indocs/specs/git-templating.md.aspire new --template-path ./template --name "Demo.Project Name" --output ./generated --suppress-agent-initThe questionnaire still prompts:
Pressing Enter at both prompts generates those values while leaving the override parameters unset. Explicit different answers replace the fallbacks.
Screenshots / Recordings
Validation
After rebasing onto
main, the following command passed: 426 tests, 0 failures, 0 skipped:The suite covers actual displayed defaults, dotted/spaced names, prompted project names, default acceptance, explicit overrides, omission semantics, invalid sources, and existing template behavior.
A real Hex1b terminal run against the rebuilt CLI, using an isolated
ASPIRE_HOMEand a generic local fixture, also passed: Enter accepted both displayed defaults and generated:Security considerations
The new setting projects values from untrusted template metadata earlier, during prompting. The supported dependency graph is restricted to the project name, the omitted override parameter, and native
regex/coalescesymbols. Bound values, other parameters that might contain secrets, and nondeterministic generators are rejected rather than previewed. Evaluation uses the existing engine implementations; no scripts, post-actions, additional configuration acquisition, or new network operations are introduced.Fixes # (issue)
Checklist
<remarks />and<code />elements on your triple slash comments?