-
Notifications
You must be signed in to change notification settings - Fork 395
feat: automatically detects IDE - windsurf or cursor - for AI context files. #7280
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
Conversation
1160a60
to
e6214b2
Compare
e6214b2
to
0fbfd50
Compare
Added `--skip-detection` flag to skip the automatic IDE detection and fallback to choice list.
src/commands/recipes/index.ts
Outdated
@@ -17,6 +17,10 @@ export const createRecipesCommand = (program: BaseCommand) => { | |||
.argument('[name]', 'name of the recipe') | |||
.description(`Create and modify files in a project using pre-defined recipes`) | |||
.option('-n, --name <name>', 'recipe name to use') | |||
.option( |
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.
This will add a flag to the entire recipes
command, not just this recipe. Right now the command itself is fully decoupled from the individual recipes, by design, and is not aware of any specific recipe. The fact that you're adding a parameter that is specific to a recipe, accompanied by help text that says it is relevant only to a specific recipe, breaks that.
If we keep using this pattern, we'll end up with a myriad of flags, each associated with a given recipe. I think that will get messy.
Do we really need this flag? Can we not just do the selection automatically when we detect thr IDE? If we really want an opt-out mechanism, I would recommend an environment variable as a stopgap solution until we build support for flags into the recipes themselves.
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 agree, and will be happy to remove the --skip-detection
flag.
@sean-roberts can we drop it? Asking because you ensisted on adding it 🫢
@eduardoboucas, is there a way right now to easily add this flag only to the ai-context
receipe when user appends --help
to the name of the recipe - netlify recipes ai-contexg --help
?
src/recipes/ai-context/index.ts
Outdated
] | ||
|
||
const getPathByDetectingIDE = async (): Promise<string | null> => { | ||
const getIDEFromCommand = (command: string): IDE | null => { |
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: Any reason for this function to be declared inside another function?
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.
nope, I can move it outside
src/recipes/ai-context/index.ts
Outdated
return match ?? null | ||
} | ||
|
||
async function getCommandAndParentPID(pid: number): Promise<{ |
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: Any reason for this function to be declared inside another function? Also we have function declarations and function expressions in the same scope, might be good to standardise.
src/recipes/ai-context/index.ts
Outdated
while (result.parentPID !== 1 && !result.ide) { | ||
result = await getCommandAndParentPID(result.parentPID) | ||
} | ||
} catch (_) { |
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
} catch (_) { | |
} catch { |
@eduardoboucas removed |
src/recipes/ai-context/index.ts
Outdated
// Start the download in the background while we wait for the prompts. | ||
const download = downloadFile(version).catch(() => null) | ||
|
||
const filePath = args[0] || (await promptForPath()) | ||
const filePath = | ||
args[0] || ((options?.skipDetection ? null : await getPathByDetectingIDE()) ?? (await promptForPath())) |
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 now remove references to options.skipDetection
, right?
src/commands/recipes/recipes.ts
Outdated
@@ -14,15 +14,16 @@ const SUGGESTION_TIMEOUT = 1e4 | |||
export interface RunRecipeOptions { | |||
args: string[] | |||
command?: BaseCommand | |||
options?: OptionValues |
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 don't think we need this anymore?
Summary
Instead of asking the user for which IDE they are using when running

netlify recipes ai-context
:It now automatically detects from which IDE the command was run and adds the context files to the correctfolder:


If it didn't detect anything, it will continue to the original step where it presents a list to chose from.

User can also pass
--skip-detection
flag to skip the IDE detection logic:For us to review and ship your PR efficiently, please perform the following steps:
passes our tests.