Add Secret option to prompts (core + gRPC extension framework)#7982
Conversation
Agent-Logs-Url: https://github.com/Azure/azure-dev/sessions/16e356fd-a793-4859-a79e-e90916c46840 Co-authored-by: JeffreyCA <9157833+JeffreyCA@users.noreply.github.com>
jongio
left a comment
There was a problem hiding this comment.
Two things worth addressing before this lands:
-
When
Secret: trueis combined with aHelpMessage, the auto-generated[Type ? for hint]text still appears in the prompt output - but sinceIgnoreHintKeysis forced on, pressing?just adds it as input. The hint becomes dead UI that misleads the user. -
Test assertions use
len()(byte count) where the implementation masks by rune count. Works fine for the ASCII values currently in tests but would silently give wrong assertion counts if someone swaps in multi-byte test values later.
Secret option to prompts (core + gRPC extension framework)
There was a problem hiding this comment.
Pull request overview
Adds a Secret flag to the core ux.PromptOptions and the gRPC extension prompt API so callers can request masked (password-like) text input while keeping azd-styled prompt UX consistent across core and extensions.
Changes:
- Introduces
Secreton core prompts, masks rendered input by rune count, and adjusts hint/help behavior for secret prompts. - Exposes
secretvia gRPC (prompt.proto+ generatedprompt.pb.go) and forwards it inprompt_service.go. - Updates the demo extension and docs to exercise/document the new option; adds a cursor-positioning regression test.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| cli/azd/pkg/ux/prompt.go | Adds Secret option and masks rendered prompt value; adjusts cursor-position capture behavior. |
| cli/azd/pkg/ux/confirm_prompt_test.go | Adds regression tests for cursor capture and secret masking/options. |
| cli/azd/pkg/azdext/prompt.pb.go | Regenerated Go protobuf to include secret field. |
| cli/azd/internal/grpcserver/prompt_service.go | Forwards secret option from extensions into core prompt options. |
| cli/azd/grpc/proto/prompt.proto | Adds secret = 11 to PromptOptions over gRPC. |
| cli/azd/extensions/microsoft.azd.extensions/internal/resources/languages/proto/prompt.proto | Updates embedded proto used by extension scaffolding/templates to include secret. |
| cli/azd/extensions/microsoft.azd.demo/internal/cmd/prompt.go | Demonstrates secret prompt usage end-to-end via gRPC and adds demo masking helper. |
| cli/azd/extensions/microsoft.azd.demo/README.md | Documents the demo’s new “secret prompt” behavior. |
| cli/azd/docs/extensions/extension-framework.md | Documents the new secret option in the extension framework prompt API. |
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash: pwsh: WindowsPowerShell install MSI install Standalone Binary
MSI
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|
jongio
left a comment
There was a problem hiding this comment.
Addresses my previous feedback. The hint suppression and test rune-count fixes look correct. Expanded scope (gRPC threading, demo extension, cursor-position fix) is clean and well-tested. No new issues.
Resolves #7682
These changes lets callers - both core
azdcode and gRPC extensions - request a masked text prompt for passwords, API keys, and other secrets without dropping out of theazd-styled UX.This PR adds a single
Secret boolknob:ux.PromptOptions.Secret): typed input is rendered as*per rune (UTF-8 safe) while typing and after submission.?is accepted as an input character instead of triggering the hint affordance, and the auto-generated[Type ? for hint]text is suppressed. A caller-supplied Hint and HelpMessage are left untouched.azdext.PromptOptions.secret): same field exposed over gRPC, forwarded into the core option byprompt_service.go. Documented inextension-framework.md.This PR also fixes a small cursor-positioning bug in the prompt renderer: backspacing the last character of a prompt left the terminal cursor one column too far right (the character was deleted correctly — only the cursor was wrong). Caused by
p.cursorPositionbeing captured once and not refreshed when the value transitioned back to empty without a placeholder.Example
The
microsoft.azd.demoextension'spromptsubcommand now opens with a masked API key prompt to exercise the new field end-to-end via gRPC. For visibility the captured value is echoed back partially masked (first + last rune) with a "demo only" caveat.