Skip to content

Conversation

@katzdave
Copy link
Collaborator

@katzdave katzdave commented Dec 18, 2025

Summary

Currently we split parameters at spacebar, and only the first word is sent to the first param.

Now everything is parsed as the first param (without a default, or just the first if they all have defaults).

If there are more than 2 required params, throw an error; I think this case is pretty hard to handle without some richer parameter filled UI; Since you aren't directly looking at the recipe you have little hope of remembering all the param names.

Screenshot 2025-12-18 at 4 40 30 PM

Copilot AI review requested due to automatic review settings December 18, 2025 20:38
@katzdave katzdave requested a review from angiejones December 18, 2025 20:40
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves recipe slash command parsing by treating all text after the command as a single parameter value instead of splitting on whitespace. It adds validation to prevent recipes with multiple required parameters from being used via slash commands, guiding users to the CLI's goose run --recipe with --params instead.

  • Changes parameter parsing to pass the full parameter string (spaces included) to recipes
  • Adds recipe validation to count required parameters and enforce single-parameter restriction
  • Improves error messages to guide users when recipes have too many required parameters

Copilot AI review requested due to automatic review settings December 18, 2025 21:33
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

.map(|params| params.iter().filter(|p| p.default.is_none()).count())
.unwrap_or(0);

if params_without_default <= 1 {
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When there are no required parameters (params_without_default == 0) but the user provides input, the code creates a vec with params_str. This will cause the parameter to be passed to a recipe that doesn't expect any positional parameters. The condition should be params_without_default == 1 instead of <= 1 to avoid this issue.

Suggested change
if params_without_default <= 1 {
if params_without_default == 1 {

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings December 18, 2025 21:41
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

.map(|params| params.iter().filter(|p| p.default.is_none()).count())
.unwrap_or(0);

if params_without_default <= 1 {
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When a recipe has only optional parameters (all with defaults) and the user provides a value, this code will pass that value as the first parameter. This could cause unexpected behavior since the recipe doesn't require any parameters. Consider checking if params_without_default is 0 and params_str is not empty, and either ignore the value or return an informative error.

Suggested change
if params_without_default <= 1 {
if params_without_default == 0 {
let error_message = format!(
"The /{} recipe does not require any parameters, \
but you provided: `{}`.\n\n\
Slash command recipes only support passing at most one \
required parameter.\n\n\
**To customize this recipe's optional parameters,** \
run it directly as a recipe (for example from the recipes sidebar).",
command,
params_str
);
return Err(anyhow!(error_message));
} else if params_without_default == 1 {

Copilot uses AI. Check for mistakes.
@katzdave katzdave merged commit bf95995 into main Dec 19, 2025
18 checks passed
@katzdave katzdave deleted the dkatz/recipe-params-parsing branch December 19, 2025 18:15
katzdave added a commit that referenced this pull request Dec 19, 2025
katzdave added a commit that referenced this pull request Dec 19, 2025
@angiejones angiejones mentioned this pull request Jan 5, 2026
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants