-
Notifications
You must be signed in to change notification settings - Fork 292
feat(chat): expand support for /prompts command #2799
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
can we get this PR merged asap? Very important feature all othe major CLI AI tools already support! |
Can you add the test scenarios you did to validate this? For reviewers add repro steps and validated scenarios. |
Test1: Prompt creationTest 1.1: Create local prompt with content# Create a prompt with inline content
q chat
/prompts create hello --content "Hello! How can I help you today?"
# Expected: Success message with file path
# ✓ Created prompt hello at <project>/.amazonq/prompts/hello.md Test 1.2: Create local prompt without content (editor mode)/prompts create deploy
# Expected:
# - Default template content appears in editor
# - After saving and closing editor, success message appears Test 1.3: Attempt to create duplicate prompt/prompts create hello --content "Duplicate test"
# Expected: Prompt hello already exists. Use /prompts edit hello to modify it. 2. Prompt Listing and DiscoveryTest 2.1: Create global prompt and test listing# Create global prompt directory and file manually
mkdir -p ~/.aws/amazonq/prompts
echo "This is a global prompt for testing" > ~/.aws/amazonq/prompts/global-test.md
/prompts list
# Expected: Shows both sections:
# Global (.aws/amazonq/prompts):
# - global-test
#
# Local (.amazonq/prompts):
# - hello
# - deploy Test 2.2: Test search functionality (Please confirm that amazonq/prompts/hello.md exists.)
3. Priority System TestingTest 3.1: Create conflicting prompt names# Create global prompt with same name as local
echo "Global version of hello prompt" > ~/.aws/amazonq/prompts/hello.md
/prompts list
# Expected: Only shows one "hello" in Local section (local overrides global) Test 3.2: Test prompt loading priority@hello
# Expected: Should load the LOCAL version of hello prompt, not global
# Verify by checking the content that gets loaded 4. Prompt EditingTest 4.1: Edit existing local prompt/prompts edit hello
# Expected:
# - Editor opens with current content
# - After editing and saving, success message appears
# - ✓ Prompt edited successfully. Test 4.2: Edit global prompt (should edit local copy if exists)/prompts edit hello
# Expected: Opens the LOCAL version for editing (due to priority system) Test 4.3: Edit non-existent prompt/prompts edit nonexistent
# Expected: Error message suggesting to use /prompts create instead |
Thanks for the detailed explanation. Couple of comments:
Currently when a global prompt with same name as local is created, file is created but its not shown in the list. I see Global start showing in list once we remove the local, if global is expected to be overridden should UX be clear denoting this is happening?
Though editor is not opened either, interesting is that after that we see
But prompts list will now show it |
@kensave |
An additional comment is that, what are your though on removing global and local prompts? We do support create and update. |
It's definitely necessary. Let's add a delete function too. |
@kensave Commands:
list List available prompts from a tool or show all available prompt
get Get a specific prompt by name
create Create a new prompt
edit Edit an existing prompt
delete Delete an existing prompt
help Print this message or the help of the given subcommand(s) |
Thank you |
Can we use |
} | ||
|
||
// Check for path separators | ||
if name.contains('/') || name.contains('\\') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit - we could just use a regex here like [a-zA-Z_-]+
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it okay that this regex doesn't allow numbers?
Considering that numbers might be needed for like versioning and workflows, I defined it as [a-zA-Z0-9_-]+
.
execute!(session.stderr)?; | ||
|
||
// Ask for user confirmation | ||
let user_input = match session.read_user_input("Are you sure you want to remove this prompt? (y/n): ", false) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can user input be read using the util function like this instead? https://github.com/aws/amazon-q-developer-cli/blob/main/crates/chat-cli/src/cli/chat/cli/profile.rs#L310-L317
Otherwise the y/n
will be stored as part of the readline history
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Absolutely yes.
execute!(session.stderr)?; | ||
|
||
// Ask for user confirmation | ||
let user_input = match session.read_user_input("Do you want to continue? (y/n): ", false) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here for reading user input
} | ||
|
||
// Check for conflicts between global and local | ||
if !global { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A lot of this code seems a bit verbose - can this be restructured to instead be
struct Prompts {
local: Prompt
global: Prompt
}
struct Prompt {
name: String,
path: PathBuf,
}
Then the logic for getting local/global names, checking if something exists, validation, etc. could be added as methods on these structs rather than implicitly duplicated across these different methods.
The logic for creating/editing/deleting etc. shouldn't really need to concern itself with checking md
extensions for example, just more maintainable to add some structure around this IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've modified it to use structs.
@brandonskiser |
Does this support arguments? Perhaps a default "context" argument that appends to the bottom of the prompt or the ability to insert Thinking about integration with things like GitHub's new SpecKit where you may |
Issue #, if available:
resolve #2794
Description of changes:
This PR implements a comprehensive prompt management system that supports both global and local prompts. Users can now create, edit, and manage reusable prompt templates that are stored locally in their projects or globally across all projects.
Features added
Global and Local Prompt Support
New Commands
/prompts create <name>
- Create a new local prompt (--content <content>
argument is also supported)/prompts edit <name>
- Edit an existing prompt with automatic editor openingBy submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.