-
Notifications
You must be signed in to change notification settings - Fork 5
Add Cursor rules for PowerShell scripts #155
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
Generated by 🚫 Danger |
…pts if it's not possible to make an original bash script compatible with Windows
|
Note: we should probably switch to use Though:
[EDIT] Conversion to |
|
I've created a draft PR #157 on top of this to check/demo how well those rules could help us use Cursor to improve our scripts and their documentation. |
mokagio
left a comment
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.
Thanks @AliSoftware !
Cursor rules are new to me, so I don't know how effective these would be. But I like how they are tracked in the repo so we can iterate 😄
Happy to merge and try them out.
| ```powershell | ||
| <# | ||
| .SYNOPSIS | ||
| Brief description of what the script does. | ||
|
|
||
| .DESCRIPTION | ||
| Detailed description of the script's purpose and functionality. | ||
|
|
||
| .PARAMETER ParameterName | ||
| Description of each parameter. | ||
|
|
||
| .EXAMPLE | ||
| Example-1 | ||
| Detailed description of the example. | ||
|
|
||
| .NOTES | ||
| Author: [Author name] | ||
| Last Edit: [Date] | ||
| Version 1.0 - Initial release | ||
| Requirements: Windows PowerShell 5.1 | ||
| Windows Requirements: | ||
| - Windows Server 2019 or later | ||
| - Required Windows Features: [list features] | ||
| - Required Windows Roles: [list roles] | ||
| - Administrator privileges: [Yes/No] | ||
|
|
||
| .OUTPUTS | ||
| Description of the script's output. | ||
|
|
||
| .RETURNVALUES | ||
| Description of possible return values and their meanings. | ||
| #> | ||
| ``` |
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 doc format is huge
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.
Yes indeed.
But I'd encorage you to test it by asking Cursor to Add documentation header in @bin/prepare_windows_host_for_app_distribution.ps1 as a prompt—which should make it detect that this file has the .ps1 extension so that it should pick the @rules for it automatically—and see what it generates.
In particular I believe it'd be smart enough to only add the sections of this documentation template that are relevant and used (e.g. not include .EXAMPLE if it doesn't have any to provide, same for .PARAMETER entries…
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.
PS: You might have to quit Cursor before switching to the git branch that have this .mdc files and restarting Cursor, as based on this bug report it seems that the files are parsed at Cursor launch (and the cursor executable has an open file handle on them from that point on…), so changes in the .mdc files might not be taken into account until you quit and restart the IDE…?
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.
Got Cursor to generate docs in #159
* Add Cursor rules for PowerShell scripts * Suggest Cursor to create a PowerShell script counterpart to bash scripts if it's not possible to make an original bash script compatible with Windows * Add more context at the top of `.cursorrules` * Migrate `.cursorrules` to `.cursor/rules/*.mdc` * Add rule for using backticks around command names * Add missing newline at EOF
What
As per my suggestion in paaHJt-7WG-p2#comment-10141, this is the result of me asking Cursor to add
.cursorrulesfor PowerShell in addition to the ones I recently added forbashHow
I used the following prompts to ask Cursor to generate those rules itself:
It then generated some rules, but including mentions of ensuring the
.ps1scripts would be Cross-Platform for Windows, Linux and macOS—based on us having a similar set of Compatibilty rules forbash, I assume… So I asked it to refine its suggestion:It then updated its suggestions to the ones I've pushed in cbf4991.
I then added some manual tweaks to the
.cursorrulesfile in 7766406 and e9c04a2.[EDIT] After all that I then moved the markdown section to separate
.cursor/rules/*.mdcfiles (instead of having them all in a single.cursorrules), since that seems to be the new suggested format to use for those in latest Cursor versions.