goose icon indicating copy to clipboard operation
goose copied to clipboard

Inject recipe_dir into the recipe template

Open lifeizhou-ap opened this issue 7 months ago • 3 comments

Please explain the motivation behind the feature request. Goose recipes often have a need of files that contain extra information. This could be a large csv or json document with records that can be accessed based on what Goose needs or even a sqlite database in combination with a matching MCP.

A reasonable place to put these files would be in the same folder as the recipe, but for that to work, the recipe needs to be able to find those files. The proposal here is to always have:

{{ recipe_dir }} resolve to the directory where the recipe resides. Note that this works well with the recipes in github since we clone that repository and so if you store a csv in github next to the recipe, you’ll have access. You then automatically get a mechanism to update that data

Describe the solution you'd like Add a built-in params "recipe_dir" in the recipe

  • [x] I have verified this does not duplicate an existing feature request

lifeizhou-ap avatar May 16 '25 03:05 lifeizhou-ap

This is super cool! Lately I've been thinking about how to have goose and cursor co-exist with a single source of truth in the custom prompts. Could this be extended so that my custom recipe file could read a file from a relative .cursor/rules/foo file?

bigethan avatar May 16 '25 16:05 bigethan

This is super cool! Lately I've been thinking about how to have goose and cursor co-exist with a single source of truth in the custom prompts. Could this be extended so that my custom recipe file could read a file from a relative .cursor/rules/foo file?

HI @bigethan Thanks for the feedback. Currently recipe_dir is a built-in param, and its value is the parent directory of the recipe file, and it cannot be modified. This was mainly considering the use case of people downloading the recipe from the github repo. The recipe file and the file with extra context are in the same directory.

Considering your requirement which is more of local recipe, originally I am thinking about to enable users to overwrite the recipe_dir params. However, I guess your recipe file and the file with extra context are not in the same directory, and using recipe_dir (as the param name to set the .cursor/rules/foo as the value) is a bit confusing.

Maybe we should rename the param name to recipe_context_dir? How do you think? cc @DOsinga

lifeizhou-ap avatar May 19 '25 04:05 lifeizhou-ap

I think the easiest way to get this done, is to have the recipe actually read from the .cursor/rules.

Since goose recipes are implemented as jinja templates, you should be able to use

{% include '/path/to/some/rule' %}

if that is an absolute path, that's not going to be easy to share of course, but it will work for now. @lifeizhou-ap - we could think about loading any include from the path variable and this would be a bit easier to access?

DOsinga avatar May 19 '25 05:05 DOsinga

closing since we have this now!

DOsinga avatar Aug 02 '25 22:08 DOsinga