diff --git a/docs/automations/integrations/ai-assistance/flag-ai-pr/README.md b/docs/automations/integrations/ai-assistance/flag-ai-pr/README.md new file mode 100644 index 000000000..2f11d8c21 --- /dev/null +++ b/docs/automations/integrations/ai-assistance/flag-ai-pr/README.md @@ -0,0 +1,91 @@ +--- +title: Automation - Label AI-Assisted PRs +description: Automatically apply labels to PRs based on AI assistance. +category: [quality, genai, ai, quickstart] +starter_kits: [genai] +--- +# Automatically Label AI-Assisted PRs + +Automatically apply labels to PRs based on whether they were assisted by AI tools. Developers can indicate the specific AI tools or models used, or pre-add an AI-related label to skip the prompt. + +=== "Ask Developers About AI Assistance" + ### Ask Developers About AI Assistance + Prompt PR authors with a convenient checkbox survey to indicate which AI tools they used for the PR. Developers can pre-add any `🤖 ai-*` label to skip the question. The automation checks for existing labels before posting the prompt. + + ![Ask About AI Assistance](/automations/integrations/ai-assistance/flag-ai-pr/ask-ai-assistance.png) + + !!! info "Configuration Description" + Conditions: + + * A PR is created, and no `🤖 ai-*` label is pre-applied. + * The question hasn't been asked before. + + Automation Actions: + + * Post a comment with a checkbox survey about AI tools used. + * Apply labels based on the checkboxes selected. + + !!! example "Ask the PR author about AI assistance." + ```yaml+jinja + --8<-- "docs/downloads/automation-library/integrations/ai-assistance/comment_ai_prompt.cm" + ``` +
+ + [:octicons-download-24: Download this example as a CM file.](/downloads/automation-library/integrations/ai-assistance/comment_ai_prompt.cm){ .md-button } + +
+ + + ### Track AI Tools + Add labels to the PR according to the tools that the developer checked in the micro-survey above + ![Label AI Assistance](/automations/integrations/ai-assistance/flag-ai-pr/label-ai-assistance.png) + + !!! info "Configuration Description" + Conditions: + + * A PR with selected checkboxes for AI tools used. + * Optional: Details about AI Service and Model specified. + + Automation Actions: + + * Apply labels for specific AI tools (e.g., `🤖 ai-copilot`, `🤖 ai-cursor`). + * Apply labels for AI services and models if provided. + + !!! example "Track AI tools, models and services." + ```yaml+jinja + --8<-- "docs/downloads/automation-library/integrations/ai-assistance/track_ai_models.cm" + ``` +
+ + [:octicons-download-24: Download this example as a CM file.](/downloads/automation-library/integrations/ai-assistance/track_ai_models.cm){ .md-button } + +
+ +=== "Skip the survey for known users" + ### Ask Developers About AI Assistance + The automation will not prompt known users for AI assistance. This allows a smoother experience for users who were predefined as AI users, to avoid answering the same questions again. + !!! example "Skip the survey for known users." + ```yaml+jinja + --8<-- "docs/downloads/automation-library/integrations/ai-assistance/comment_ai_prompt_with_known_users.cm" + ``` +
+ + [:octicons-download-24: Download this example as a CM file.](/downloads/automation-library/integrations/ai-assistance/comment_ai_prompt_with_known_users.cm){ .md-button } + +
+ + ### Track AI Tools + Add labels to the PR according to the tools that the developer checked in the micro-survey above + ![Label AI Assistance](/automations/integrations/ai-assistance/flag-ai-pr/label-ai-assistance.png) + + !!! example "Track AI tools, models and services." + ```yaml+jinja + --8<-- "docs/downloads/automation-library/integrations/ai-assistance/track_ai_models.cm" + ``` +
+ + [:octicons-download-24: Download this example as a CM file.](/downloads/automation-library/integrations/ai-assistance/track_ai_models.cm){ .md-button } + +
+ + diff --git a/docs/automations/integrations/ai-assistance/flag-ai-pr/ask-ai-assistance.png b/docs/automations/integrations/ai-assistance/flag-ai-pr/ask-ai-assistance.png new file mode 100644 index 000000000..3ec2c1a56 Binary files /dev/null and b/docs/automations/integrations/ai-assistance/flag-ai-pr/ask-ai-assistance.png differ diff --git a/docs/automations/integrations/ai-assistance/flag-ai-pr/label-ai-assistance.png b/docs/automations/integrations/ai-assistance/flag-ai-pr/label-ai-assistance.png new file mode 100644 index 000000000..4acb95186 Binary files /dev/null and b/docs/automations/integrations/ai-assistance/flag-ai-pr/label-ai-assistance.png differ diff --git a/docs/downloads/automation-library/integrations/ai-assistance/comment_ai_prompt.cm b/docs/downloads/automation-library/integrations/ai-assistance/comment_ai_prompt.cm new file mode 100644 index 000000000..4c08b1e9d --- /dev/null +++ b/docs/downloads/automation-library/integrations/ai-assistance/comment_ai_prompt.cm @@ -0,0 +1,35 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +triggers: + on: + - pr_created + +automations: + comment_ai_assistance_prompt: + # Post a comment for all PRs to prompt the PR author to indicate whether they used AI to assist coding in this PR + # Only do this if there's no existing AI-related label and we haven't asked before + if: + - {{ pr.labels | match(regex=r/🤖 ai-*/) | nope }} + - {{ pr.comments | filter(attr='commenter', term='gitstream-cm') | filter(attr='content', regex=r/Please mark which AI tools you used/) | nope }} + run: + - action: add-comment@v1 + args: + comment: | + Please mark which AI tools you used for this PR by checking the appropriate boxes: + + - [ ] GitHub Copilot + - [ ] Cursor + - [ ] Tabnine + - [ ] JetBrains AI Assistant + - [ ] VSCode IntelliCode + - [ ] ChatGPT + - [ ] Claude + - [ ] Gemini + - [ ] Other AI tool + - [ ] No AI tools were used + + Tip: If you want to avoid this comment in the future, you can add a label of the format `🤖 ai-*` when creating your PR. + diff --git a/docs/downloads/automation-library/integrations/ai-assistance/comment_ai_prompt_with_known_users.cm b/docs/downloads/automation-library/integrations/ai-assistance/comment_ai_prompt_with_known_users.cm new file mode 100644 index 000000000..e951a62d7 --- /dev/null +++ b/docs/downloads/automation-library/integrations/ai-assistance/comment_ai_prompt_with_known_users.cm @@ -0,0 +1,65 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 +triggers: + on: + - pr_created + +automations: + comment_ai_assistance_prompt: + # Post a comment for all PRs to prompt the PR author to indicate whether they used AI to assist coding in this PR + # Only do this if there's no existing AI-related label and we haven't asked before + if: + - {{ pr.labels | match(regex=r/🤖 ai-*/) | nope }} + - {{ pr.author | match(list=copilot_contributors) | nope }} + - {{ pr.author | match(list=cursor_contributors) | nope }} + run: + - action: add-comment@v1 + args: + comment: | + Please mark which AI tools you used for this PR by checking the appropriate boxes: + + - [ ] GitHub Copilot + - [ ] Cursor + - [ ] Tabnine + - [ ] JetBrains AI Assistant + - [ ] VSCode IntelliCode + - [ ] ChatGPT + - [ ] Claude + - [ ] Gemini + - [ ] Other AI tool + - [ ] No AI tools were used + + **Tip**: If you want to avoid this comment in the future, add a label of the format `🤖 ai-*` when creating your PR, or ask your admin to add you to the pre-defined lists of known users + + label_copilot_known_users: + # For all PRs authored by someone who is specified in the genai_contributors list + if: + - {{ pr.author | match(list=copilot_contributors) | some }} + # Apply a label indicating the user has adopted Copilot + run: + - action: add-label@v1 + args: + label: '🤖 ai-copilot' + + label_cursor_known_users: + # For all PRs authored by someone who is specified in the genai_contributors list + if: + - {{ pr.author | match(list=cursor_contributors) | some }} + # Apply a label indicating the user has adopted Copilot + run: + - action: add-label@v1 + args: + label: '🤖 ai-cursor' + +copilot_contributors: + - username1 + - username2 + - usernameN + +cursor_contributors: + - username1 + - username2 + - usernameN + \ No newline at end of file diff --git a/docs/downloads/automation-library/integrations/ai-assistance/track_ai_models.cm b/docs/downloads/automation-library/integrations/ai-assistance/track_ai_models.cm new file mode 100644 index 000000000..73fb3b6c3 --- /dev/null +++ b/docs/downloads/automation-library/integrations/ai-assistance/track_ai_models.cm @@ -0,0 +1,71 @@ +# -*- mode: yaml -*- + +manifest: + version: 1.0 + +automations: + label_ai_tools_by_checkbox: + # Apply labels based on the checkboxes selected in the PR comment + if: + - {{ pr.comments | filter(attr='content', regex=r/\- \[x\] GitHub Copilot/) | some }} + run: + - action: add-label@v1 + args: + label: "🤖 ai-copilot" + + label_ai_cursor: + if: + - {{ pr.comments | filter(attr='content', regex=r/\- \[x\] Cursor/) | some }} + run: + - action: add-label@v1 + args: + label: "🤖 ai-cursor" + + label_ai_tabnine: + if: + - {{ pr.comments | filter(attr='content', regex=r/\- \[x\] Tabnine/) | some }} + run: + - action: add-label@v1 + args: + label: "🤖 ai-tabnine" + + label_ai_jetbrains: + if: + - {{ pr.comments | filter(attr='content', regex=r/\- \[x\] JetBrains AI Assistant/) | some }} + run: + - action: add-label@v1 + args: + label: "🤖 ai-jetbrains" + + label_ai_intellicode: + if: + - {{ pr.comments | filter(attr='content', regex=r/\- \[x\] VSCode IntelliCode/) | some }} + run: + - action: add-label@v1 + args: + label: "🤖 ai-intellicode" + + label_ai_chatgpt: + if: + - {{ pr.comments | filter(attr='content', regex=r/\- \[x\] ChatGPT/) | some }} + run: + - action: add-label@v1 + args: + label: "🤖 ai-chatgpt" + + label_ai_other: + if: + - {{ pr.comments | filter(attr='content', regex=r/\- \[x\] Other AI tool/) | some }} + run: + - action: add-label@v1 + args: + label: "🤖 ai-other" + + label_ai_none: + if: + - {{ pr.comments | filter(attr='content', regex=r/\- \[x\] No AI tools were used/) | some }} + run: + - action: add-label@v1 + args: + label: "🤖 ai-none" + \ No newline at end of file diff --git a/docs/downloads/automation-library/integrations/copilot/comment_copilot_prompt.cm b/docs/downloads/automation-library/integrations/copilot/comment_copilot_prompt.cm index 0ea82cae3..67a179be8 100644 --- a/docs/downloads/automation-library/integrations/copilot/comment_copilot_prompt.cm +++ b/docs/downloads/automation-library/integrations/copilot/comment_copilot_prompt.cm @@ -1,11 +1,11 @@ --*- mode: yaml -*- +# -*- mode: yaml -*- manifest: version: 1.0 on: - pr_created - + automations: comment_copilot_prompt: # Post a comment for all PRs to prompt the PR author to indicate whether they used Copilot to assist coding in this PR diff --git a/docs/downloads/automation-library/integrations/copilot/label_copilot_by_contributors.cm b/docs/downloads/automation-library/integrations/copilot/label_copilot_by_contributors.cm index 4bf4f3fc6..cf930ac08 100644 --- a/docs/downloads/automation-library/integrations/copilot/label_copilot_by_contributors.cm +++ b/docs/downloads/automation-library/integrations/copilot/label_copilot_by_contributors.cm @@ -4,17 +4,17 @@ manifest: version: 1.0 automations: - label_genai: + label_copilot_by_contributors: # For all PRs authored by someone who is specified in the genai_contributors list if: - - {{ pr.author | match(list=genai_contributors) | some }} + - {{ pr.author | match(list=genai_contributors) | some }} # Apply a label indicating the user has adopted Copilot run: - action: add-label@v1 args: - label: '🤖 Copilot' + label: '🤖 ai-copilot' genai_contributors: - username1 - username2 - - etc + - usernameN diff --git a/docs/integrations/README.md b/docs/integrations/README.md index 06d29f992..e244a47e5 100644 --- a/docs/integrations/README.md +++ b/docs/integrations/README.md @@ -7,6 +7,12 @@ visible: false
+
+
+[:material-assistant: AI Assistance](/automations/integrations/ai-assistance/flag-ai-pr) +
+
+