-
Notifications
You must be signed in to change notification settings - Fork 6
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
Experiment with Cursor-generated docs for PowerShell scripts (Olivier's take) #160
base: trunk
Are you sure you want to change the base?
Conversation
Clients should use the dedicated nvm plugin. See https://github.com/Automattic/nvm-buildkite-plugin
Co-authored-by: Olivier Halligon <[email protected]>
Tested it by running on my Windows VM first this time.
If one tries to change the position, the script will fail
Co-authored-by: Olivier Halligon <[email protected]>
`Write-Host` is for user interaction.
* Introduce basic .cursorrules for this repo * Add details about cross-platform considerations And which commands we can assume are available in our agents for each type of script * Add Script Validation section * Improve .cursorrules documentation formatting and clarity - Add backticks to code-like elements for better readability - Standardize formatting of command and code references - Enhance section formatting for improved visual consistency * Add rule about shebang * Reorder sections for consistency
* 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
Generated by 🚫 Danger |
.EXAMPLE | ||
.\install_windows_10_sdk.ps1 | ||
Installs the Windows 10 SDK version specified in .windows-10-sdk-version file | ||
|
||
.EXAMPLE | ||
.\install_windows_10_sdk.ps1 -DryRun | ||
Performs a dry run showing what would be installed without actual installation |
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.
Arguably those examples are not worth including in the doc. But to be fair, the .mdc
rule does include a mention of "Documentation must include […] examples", so maybe we want to tweak that part of the .mdc
rule to remove the "example" part of that bullet point (and only keep the "For complex logic, provide detailed examples of different use cases" bullet point to only tell it to generate examples if the logic is complex… which is also a bullet point in the rules we could refine the wording of, to better define for it what we mean by "complex"…
.NOTES | ||
Author: Automattic Inc. | ||
Requirements: Windows PowerShell 5.1 | ||
Windows Requirements: | ||
- Windows Server 2019 or later | ||
- Administrator privileges: Yes | ||
- Disk space: ~5GB for installation | ||
- Internet connection for downloading Visual Studio Build Tools |
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.
- The mention of "Administrator privileges: Yes", if correct, is an interesting information to have in the Notes imho. I have not double-checked if that requirement was correct though (but I assume we do indeed need admin role to be able to install the SDK, so it seems plausible?)
- The Disk space one is interesting… didn't expect it to document that, but in retrospect I think that's useful.
- The rest of the info in those notes is probably useless.
- The "Author" line is probably useless for our use case and context; we should add a rules telling it not to bother adding that line.
- The mention of internet connection being needed is not technically wrong… but not worth documenting for our case either imho. We should thus add in the rules an instruction telling that this is something we can assume is already available in all the agents/machines that will run those scripts, and that it's not necessary to document.
- As for the Windows Requirements (Windows Server 2019 + PowerShell 5.1)… To be fair, the rules did explicitly say to document Windows specific requirements, so that's probably why it did add those additional info. We should probably remove that bullet point from the rules file.
- Follow `PSScriptAnalyzer` recommendations | ||
- Use proper error handling and input validation | ||
- Use UTF-8 encoding without BOM for script files | ||
- Document Windows-specific requirements and dependencies |
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 probably want to remove that rule after all, given how verbose it can be in the generated doc while the info about Windows and PowerShell versions will likely not be super useful in the context we're using those scripts.
- Documentation must include: synopsis, description, parameters, examples | ||
- For complex logic, provide detailed examples of different use cases |
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.
- Documentation must include: synopsis, description, parameters, examples | |
- For complex logic, provide detailed examples of different use cases | |
- Documentation must include: synopsis, description, parameters | |
- For scripts that have a high complexity of possible parameters/arguments combinations, especially if some of them are only making sense when combined with others, or when the behavior of the script depending on the various parameters/arguments combinations could be hard to grasp, provide detailed examples of different use cases |
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] |
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.
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] | |
Requirements: | |
- Required Windows Features: [list features] | |
- Required Windows Roles: [list roles] | |
- Administrator privileges: [Yes/No] |
- Clearly document Windows version requirements or limitations | ||
- Document required Windows features or roles |
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.
- Clearly document Windows version requirements or limitations | |
- Document required Windows features or roles | |
- Clearly document potential limitations | |
- Document third-party tools the script depends on that are required to be installed explicitly first | |
- Document required Windows features or roles | |
- You can assume the agents will have access to internet; you don't need to document that as a requirement. |
Here's my attempt at asking Cursor to generate header docs for
.ps1
files, to compare with @mokagio 's attempt in #159 .Below are the prompts I used, and the answers Cursor gave me.
Notes
a8c-ci-toolkit
folder open in Cursormokagio/windows-10-experiments
branch to include the.cursor/rules/*.mdc
)a8c-ci-toolkit-buildkite-plugin
folder again in Cursorpowershell_scripts
rule automatically—without me having to mention something likeusing the @rules
explicitly to add them in the context—as it detected I asked it to work on files with.ps1
extension.*.ps1
files, it incorrectly suggested there could be more.ps1
scripts in@bin/
to update the documentation of, and listed some of our bash scripts—but hallucinating an added.ps1
extension to them. I course-corrected it by asking as a follow-up if it could check if there were other scripts to update with the.ps1
extension specifically and it realized there were none after all and stopped its hallucination right away.