-
Notifications
You must be signed in to change notification settings - Fork 357
Adding support for arguments for saved prompts #3388
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
| substituted | ||
| }, | ||
| Err(arg_error) => { | ||
| queue!( |
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.
We can just call execute! here.
| let mut positions = Vec::new(); | ||
|
|
||
| for cap in PLACEHOLDER_FINDER.captures_iter(content) { | ||
| let full_match = cap.get(0).unwrap().as_str(); |
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.
Use expect here
| "arg2".to_string(), | ||
| ]) | ||
| .unwrap(); | ||
| assert_eq!(result, "Command: Command arg1 arg2"); |
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.
If this test passes doesn't that mean your example in your description doesn't quite work?
In your example you have:
Example
Create a prompt
/prompts create -n test-prompt --content "read the file ${1} in the path ${2}. Print the git status of the ${1}. Before printing the git status show the complete file path ${@}.
Invoke the prompt
@test-prompt file1.js src/frontend
This would then create the following:
"read the file file1.js in the path src/frontend. Print the git status of the file1.js. Before printing the git status show the complete file path file1.js src/frontend."
Or is the example the problem here?
| static PLACEHOLDER_REGEX: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"\$\{([1-9]|10)\}").unwrap()); | ||
|
|
||
| /// Regex for validating $ARGS placeholder | ||
| static ARGS_PLACEHOLDER_REGEX: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"\$ARGS").unwrap()); | ||
|
|
||
| /// Regex for validating ${@} placeholder | ||
| static AT_PLACEHOLDER_REGEX: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"\$\{@\}").unwrap()); | ||
|
|
||
| /// Regex for finding all placeholders in content (${n}, $ARGS, and ${@}) | ||
| static PLACEHOLDER_FINDER: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"\$\{(\d+|@)\}|\$ARGS").unwrap()); |
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.
We should probably use expect here so that if it does go wrong it's easier to debug.
|
This feature is highly important, so thank you for implementing it. The spec-kit currently provides partial support for the q CLI, and this feature enables full support. |
Issue #, if available:
#3064 #3049
Description of changes:
Support arguments for saved prompts.
${1},${2}.${@}and$ARGScan be used as a placeholder for referencing all arguments.Example
Create a prompt
/prompts create -n test-prompt --content "read the file ${1} in the path ${2}. Print the git status of the ${1}. Before printing the git status show the complete file path ${@}.Invoke the prompt
@test-prompt file1.js src/frontendBy submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.