-
Notifications
You must be signed in to change notification settings - Fork 83
Add AI Instructions Detection Check #1136
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
base: trunk
Are you sure you want to change the base?
Add AI Instructions Detection Check #1136
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
| */ | ||
| protected function check_unexpected_markdown_files( Check_Result $result, array $files, $is_error ) { | ||
| $plugin_path = $result->plugin()->path(); | ||
| $allowed_root_md_files = array( 'README.md', 'readme.txt', 'LICENSE', 'LICENSE.md', 'CHANGELOG.md', 'CONTRIBUTING.md' ); |
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.
| $allowed_root_md_files = array( 'README.md', 'readme.txt', 'LICENSE', 'LICENSE.md', 'CHANGELOG.md', 'CONTRIBUTING.md' ); | |
| $allowed_root_md_files = array( 'README.md', 'readme.txt', 'LICENSE', 'LICENSE.md', 'CHANGELOG.md', 'CONTRIBUTING.md', 'SECURITY.md' ); |
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.
Why non-MD files included here in the array?
| $is_error, | ||
| sprintf( | ||
| /* translators: %s: file name */ | ||
| __( 'Unexpected markdown file "%s" detected in plugin root. Only README.md, readme.txt, LICENSE, LICENSE.md, CHANGELOG.md, and CONTRIBUTING.md are expected in production plugins.', 'plugin-check' ), |
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.
Lets avoid list of files here in the message as this list would changing timely.
Adds a new check to detect AI instruction files and development-only directories that should not be included in production WordPress plugins.
Fixes #1065
Problem
Some WordPress plugins include AI-specific instructions and development-only files in their distributed packages:
.cursor,.claude,.aider, etc.).github)Including these files in production plugins:
Solution
Enhanced the
File_Type_Checkto detect and flag:AI Development Tool Directories:
.cursor- Cursor IDE configuration.claude- Claude AI assistant configuration.aider- Aider AI pair programming tool.continue- Continue.dev AI code assistant.windsurf- Windsurf AI IDE.ai- Generic AI configuration folder.github- GitHub workflows and actionsUnexpected Markdown Files in Plugin Root:
README.md,readme.txt,LICENSE,LICENSE.md,CHANGELOG.md,CONTRIBUTING.md.mdfiles in the plugin root directoryEnvironment-Based Behavior
Implementation Details
Files Modified:
includes/Checker/Checks/Plugin_Repo/File_Type_Check.phpTYPE_AI_INSTRUCTIONSconstant (256)TYPE_ALLto 511look_for_ai_instructions()- Main orchestratorcheck_ai_directories()- Detects AI tool directoriescheck_github_directory()- Detects GitHub workflowscheck_unexpected_markdown_files()- Validates root markdown filesTests Added:
tests/phpunit/tests/Checker/Checks/File_Type_Check_Tests.phptest_run_with_ai_instructions_errors()- Verifies detection workstest_run_with_ai_instructions_in_local_dev()- Confirms warnings in dev environmenttest_run_without_ai_instructions_errors()- Ensures clean plugins passTest Data:
tests/phpunit/testdata/plugins/test-plugin-ai-instructions-errors/- Plugin with AI filestests/phpunit/testdata/plugins/test-plugin-ai-instructions-without-errors/- Clean pluginExamples
Plugin with AI Instructions (detected):
Detection results:
Clean Plugin (passes):