diff --git a/content/code-security/code-scanning/managing-code-scanning-alerts/disabling-autofix-for-code-scanning.md b/content/code-security/code-scanning/managing-code-scanning-alerts/disabling-autofix-for-code-scanning.md index fadcbb8200ed..779b0e4f1498 100644 --- a/content/code-security/code-scanning/managing-code-scanning-alerts/disabling-autofix-for-code-scanning.md +++ b/content/code-security/code-scanning/managing-code-scanning-alerts/disabling-autofix-for-code-scanning.md @@ -49,7 +49,7 @@ Note that disabling {% data variables.copilot.copilot_autofix_short %} at the or {% data reusables.profile.access_org %} {% data reusables.profile.org_settings %} {% data reusables.security-configurations.display-global-settings %} -1. Under the "{% data variables.product.prodname_code_scanning_caps %}" section, deselect **{% data variables.copilot.copilot_autofix_short %}** or **{% data variables.copilot.copilot_autofix_short %} for third-party tools**. +1. Under the "{% data variables.product.prodname_code_scanning_caps %}" section, deselect **{% data variables.copilot.copilot_autofix_short %}**. For more information about configuring global {% data variables.product.prodname_code_scanning %} settings, see [AUTOTITLE](/code-security/securing-your-organization/enabling-security-features-in-your-organization/configuring-global-security-settings-for-your-organization#configuring-global-code-scanning-settings). @@ -60,4 +60,4 @@ If {% data variables.copilot.copilot_autofix_short %} is allowed at the enterpri {% data reusables.repositories.navigate-to-repo %} {% data reusables.repositories.sidebar-settings %} {% data reusables.repositories.navigate-to-code-security-and-analysis %} -1. In the "{% data variables.product.UI_code_security_scanning %}" section, deselect **{% data variables.copilot.copilot_autofix_short %}** or **{% data variables.copilot.copilot_autofix_short %} for third-party tools**. +1. In the "{% data variables.product.UI_code_security_scanning %}" section, deselect **{% data variables.copilot.copilot_autofix_short %}**. diff --git a/content/code-security/code-scanning/managing-code-scanning-alerts/resolving-code-scanning-alerts.md b/content/code-security/code-scanning/managing-code-scanning-alerts/resolving-code-scanning-alerts.md index 45ac755438ba..d637bb3fe3d1 100644 --- a/content/code-security/code-scanning/managing-code-scanning-alerts/resolving-code-scanning-alerts.md +++ b/content/code-security/code-scanning/managing-code-scanning-alerts/resolving-code-scanning-alerts.md @@ -36,7 +36,7 @@ With a {% data variables.copilot.copilot_enterprise %} license, you can ask {% d ## Generating suggested fixes for {% data variables.product.prodname_code_scanning %} alerts -{% data variables.copilot.copilot_autofix %} can generate fixes for alerts identified by {% data variables.product.prodname_code_scanning %} analysis. Most {% data variables.product.prodname_codeql %} alert types are supported and also some alerts from third-party tools. For more information, see [AUTOTITLE](/code-security/code-scanning/managing-code-scanning-alerts/responsible-use-autofix-code-scanning). +{% data variables.copilot.copilot_autofix %} can generate fixes for alerts identified by {% data variables.product.prodname_code_scanning %} analysis. Most {% data variables.product.prodname_codeql %} alert types are supported. For more information, see [AUTOTITLE](/code-security/code-scanning/managing-code-scanning-alerts/responsible-use-autofix-code-scanning). {% data reusables.rai.code-scanning.copilot-autofix-note %} diff --git a/content/code-security/securing-your-organization/enabling-security-features-in-your-organization/configuring-global-security-settings-for-your-organization.md b/content/code-security/securing-your-organization/enabling-security-features-in-your-organization/configuring-global-security-settings-for-your-organization.md index 3710c8f57fbf..5402d7ea3542 100644 --- a/content/code-security/securing-your-organization/enabling-security-features-in-your-organization/configuring-global-security-settings-for-your-organization.md +++ b/content/code-security/securing-your-organization/enabling-security-features-in-your-organization/configuring-global-security-settings-for-your-organization.md @@ -75,8 +75,7 @@ To update private dependencies of repositories in your organization, {% data var You can customize several {% data variables.product.prodname_global_settings %} for {% data variables.product.prodname_code_scanning %}: {% ifversion code-scanning-autofix %} -* [Enabling {% data variables.copilot.copilot_autofix_short %} for {% data variables.product.prodname_codeql %}](#enabling-copilot-autofix-for-codeql) -* [Enabling {% data variables.copilot.copilot_autofix_short %} for third-party {% data variables.product.prodname_code_scanning %} tools](#enabling-copilot-autofix-for-third-party-code-scanning-tools) {% endif %} +* [Enabling {% data variables.copilot.copilot_autofix_short %} for {% data variables.product.prodname_codeql %}](#enabling-copilot-autofix-for-codeql){% endif %} * [Recommending the extended query suite for default setup](#recommending-the-extended-query-suite-for-default-setup){% ifversion ghes < 3.17 %} * [Setting a failure threshold for {% data variables.product.prodname_code_scanning %} checks in pull requests](#setting-a-failure-threshold-for-code-scanning-checks-in-pull-requests) @@ -92,13 +91,6 @@ You can customize several {% data variables.product.prodname_global_settings %} You can select **{% data variables.copilot.copilot_autofix_short %}** to enable {% data variables.copilot.copilot_autofix_short %} for all the repositories in your organization that use {% data variables.product.prodname_codeql %} default setup or {% data variables.product.prodname_codeql %} advanced setup. {% data variables.copilot.copilot_autofix_short %} is an expansion of {% data variables.product.prodname_code_scanning %} that suggests fixes for {% data variables.product.prodname_code_scanning %} alerts. For more information, see [AUTOTITLE](/code-security/code-scanning/managing-code-scanning-alerts/responsible-use-autofix-code-scanning). -### Enabling {% data variables.copilot.copilot_autofix_short %} for third-party {% data variables.product.prodname_code_scanning %} tools - ->[!NOTE] -> Third-party {% data variables.product.prodname_code_scanning %} tool support is in {% data variables.release-phases.public_preview %}, and subject to change. Currently, the third-party tool ESLint is supported. For more information, see [AUTOTITLE](/code-security/code-scanning/managing-code-scanning-alerts/responsible-use-autofix-code-scanning). - -You can select **{% data variables.copilot.copilot_autofix_short %} for third-party tools** to enable {% data variables.copilot.copilot_autofix_short %} for all the repositories in your organization that use third-party tools. {% data variables.copilot.copilot_autofix_short %} is an expansion of {% data variables.product.prodname_code_scanning %} that suggests fixes for {% data variables.product.prodname_code_scanning %} alerts. - {% endif %} {% ifversion ghes < 3.17 %} diff --git a/content/copilot/concepts/billing/copilot-requests.md b/content/copilot/concepts/billing/copilot-requests.md index b53d8cb2e7e2..58316f2805f0 100644 --- a/content/copilot/concepts/billing/copilot-requests.md +++ b/content/copilot/concepts/billing/copilot-requests.md @@ -43,7 +43,7 @@ The following {% data variables.product.prodname_copilot_short %} features can u | [{% data variables.copilot.copilot_chat_short %}](/copilot/using-github-copilot/copilot-chat) | {% data variables.copilot.copilot_chat_short %} uses **one premium request** per user prompt, multiplied by the model's rate. | Copilot premium requests | | [{% data variables.copilot.copilot_cli_short %}](/copilot/concepts/agents/about-copilot-cli) | Each prompt to {% data variables.copilot.copilot_cli_short %} uses **one premium request** with the default model. For other models, this is multiplied by the model's rate. | Copilot premium requests | | [{% data variables.product.prodname_copilot_short %} code review](/copilot/using-github-copilot/code-review/using-copilot-code-review) | When you assign {% data variables.product.prodname_copilot_short %} as a reviewer for a pull request, **one premium request** is used each time {% data variables.product.prodname_copilot_short %} posts comments to the pull request. | Copilot premium requests | -| [{% data variables.copilot.copilot_coding_agent %}](/copilot/concepts/about-copilot-coding-agent) | {% data variables.copilot.copilot_coding_agent %} uses **one premium request** per session. A session begins when you ask {% data variables.product.prodname_copilot_short %} to create a pull request or make one or more changes to an existing pull request. | {% data variables.copilot.copilot_coding_agent %} premium requests | +| [{% data variables.copilot.copilot_coding_agent %}](/copilot/concepts/about-copilot-coding-agent) | {% data variables.copilot.copilot_coding_agent %} uses **one premium request** per session, plus **one premium request** for each real-time steering comment made during an active session. A session begins when you ask {% data variables.product.prodname_copilot_short %} to create a pull request or make one or more changes to an existing pull request. | {% data variables.copilot.copilot_coding_agent %} premium requests | | [{% data variables.copilot.copilot_extensions_short %}](/copilot/concepts/copilot-extensions/about-copilot-extensions) | {% data variables.copilot.copilot_extensions_short %} uses **one premium request** per user prompt, multiplied by the model's rate. | Copilot premium requests | | [{% data variables.copilot.copilot_spaces %}](/copilot/using-github-copilot/copilot-spaces/about-organizing-and-sharing-context-with-copilot-spaces) | {% data variables.copilot.copilot_spaces %} uses **one premium request** per user prompt, multiplied by the model's rate. | Copilot premium requests | | [{% data variables.product.prodname_spark_short %}](/copilot/tutorials/building-ai-app-prototypes) | Each prompt to {% data variables.product.prodname_spark_short %} uses a fixed rate of **four premium requests**. | {% data variables.product.prodname_spark_short %} premium requests | diff --git a/content/copilot/concepts/copilot-metrics.md b/content/copilot/concepts/copilot-metrics.md index c28c1c0efb03..f8f5d88125b1 100644 --- a/content/copilot/concepts/copilot-metrics.md +++ b/content/copilot/concepts/copilot-metrics.md @@ -12,9 +12,7 @@ redirect_from: - /early-access/copilot-metrics - /early-access/copilot-metrics/apis - /early-access/copilot-metrics/dashboards - - /early-access/copilot-metrics/LoC - /early-access/copilot-metrics/apis/about-the-copilot-metrics-apis - - /early-access/copilot-metrics/LoC/about-the-copilot-metrics-LoC - /early-access/copilot-metrics/dashboards/about-the-copilot-metrics-dashboard - /early-access/copilot-metrics/apis/rest-api-endpoints-for-copilot-enterprise-and-user-usage-metrics --- diff --git a/content/copilot/reference/copilot-usage-metrics.md b/content/copilot/reference/copilot-usage-metrics/copilot-usage-metrics.md similarity index 94% rename from content/copilot/reference/copilot-usage-metrics.md rename to content/copilot/reference/copilot-usage-metrics/copilot-usage-metrics.md index ff44e7ce3c0c..631059efed0b 100644 --- a/content/copilot/reference/copilot-usage-metrics.md +++ b/content/copilot/reference/copilot-usage-metrics/copilot-usage-metrics.md @@ -48,6 +48,7 @@ They provide granular daily records for each user in the enterprise. | Field | Description | |:--|:--| +| `agent_edit` | A dedicated bucket in the API and reports. Captures lines added and deleted directly by {% data variables.product.prodname_copilot_short %} Agent and Edit mode.
These are not included in suggested metrics, since agent edits don’t follow a simple suggestion to acceptance flow. | | `report_start_day` / `report_end_day` | Start and end dates for the 28-day reporting period. | | `day` | Calendar day this record represents. | | `enterprise_id` | Unique ID of the enterprise or organization. | diff --git a/content/copilot/reference/copilot-usage-metrics/index.md b/content/copilot/reference/copilot-usage-metrics/index.md new file mode 100644 index 000000000000..46a25f92c4e4 --- /dev/null +++ b/content/copilot/reference/copilot-usage-metrics/index.md @@ -0,0 +1,14 @@ +--- +title: GitHub Copilot usage metrics +shortTitle: Copilot usage metrics +intro: Find information about usage metrics for {% data variables.product.prodname_copilot %}. +versions: + feature: copilot +topics: + - Copilot +children: + - /copilot-usage-metrics + - /interpret-copilot-metrics + - /reconciling-usage-metrics + - /lines-of-code-metrics +--- diff --git a/content/copilot/reference/interpret-copilot-metrics.md b/content/copilot/reference/copilot-usage-metrics/interpret-copilot-metrics.md similarity index 95% rename from content/copilot/reference/interpret-copilot-metrics.md rename to content/copilot/reference/copilot-usage-metrics/interpret-copilot-metrics.md index 609212e3de13..cbd5e391a6f6 100644 --- a/content/copilot/reference/interpret-copilot-metrics.md +++ b/content/copilot/reference/copilot-usage-metrics/interpret-copilot-metrics.md @@ -11,6 +11,7 @@ contentType: reference allowTitleToDifferFromFilename: true redirect_from: - /early-access/copilot-metrics/dashboards/interpreting-the-metrics + - /copilot/reference/interpret-copilot-metrics --- >[!NOTE] The {% data variables.product.prodname_copilot %} usage metrics dashboard is currently in {% data variables.release-phases.public_preview %} and subject to change. @@ -72,4 +73,5 @@ Use trends in usage, feature adoption, and language activity to guide enablement ## Further reading -To learn how to access and navigate the {% data variables.product.prodname_copilot_short %} usage metrics dashboard, see [AUTOTITLE](/copilot/how-tos/administer-copilot/manage-for-enterprise/view-usage-and-adoption). +* [AUTOTITLE](/copilot/reference/copilot-usage-metrics/reconciling-usage-metrics) +* [AUTOTITLE](/copilot/reference/copilot-usage-metrics/lines-of-code-metrics) diff --git a/content/copilot/reference/copilot-usage-metrics/lines-of-code-metrics.md b/content/copilot/reference/copilot-usage-metrics/lines-of-code-metrics.md new file mode 100644 index 000000000000..eeaeb6db0c9d --- /dev/null +++ b/content/copilot/reference/copilot-usage-metrics/lines-of-code-metrics.md @@ -0,0 +1,100 @@ +--- +title: Lines of Code metrics +shortTitle: Copilot LoC metrics +intro: Understand how Lines of Code metrics measure {% data variables.product.prodname_copilot_short %}’s output and what factors affect their coverage and accuracy. +permissions: Enterprise owners and billing managers +versions: + feature: copilot +redirect_from: + - /early-access/copilot-metrics/LoC + - /early-access/copilot-metrics/LoC/about-the-copilot-metrics-LoC +topics: + - Copilot +contentType: reference +allowTitleToDifferFromFilename: true +--- + +{% data reusables.copilot.usage-metrics-preview %} + +Lines of Code (LoC) metrics offer a directional way to measure {% data variables.product.prodname_copilot_short %}’s tangible output. These metrics quantify how many lines {% data variables.product.prodname_copilot_short %} suggested, added, or deleted in the editor—helping enterprise administrators understand {% data variables.product.prodname_copilot_short %}’s contribution to the codebase over time. + +LoC metrics may vary across IDEs and versions. Keep the following considerations in mind: + +* **Coverage:** Not all IDEs and users will emit LoC telemetry until they upgrade to the required versions. Reports include the `last_known_ide_version` and `last_known_plugin_version` fields so you can monitor coverage across your enterprise. +* **Stability:** As {% data variables.product.prodname_copilot_short %} evolves, telemetry definitions may change. Expect small shifts in data as accuracy improves over time. + +## Version requirements + +LoC metrics require specific minimum versions of IDEs and {% data variables.product.prodname_copilot_short %} plugins to function. Users on older versions will not contribute LoC data, which may lead to underreporting until they upgrade. + +| IDE | Feature | Minimum IDE version | Minimum {% data variables.copilot.copilot_chat_short %} extension version | +|:--|:--|:--|:--| +| Eclipse | | 4.31 | 0.9.3.202507240902 | +| | | 4.31 | 0.11.0.202508291001 | +| | | 4.31 | 0.10.0.202508110512 | +| IntelliJ/JetBrains | | 2024.2.6 | 1.5.52-241 | +| {% data variables.product.prodname_vs %} | | 17.14.13 | 18.0.471.29466 | +| | | 17.14.14 | 18.0.471.29466 | +| {% data variables.product.prodname_vscode_shortname %} | | 1.104.0 | 0.31.0 | +| | | 1.102.0 | 0.29.0 | +| | | 1.103.2 | 0.30.3 | +| | | 1.103.0 | 0.30.0 | +| XCode | | 14.3.1 | 0.40.0 | +| | | 15.0 | 0.43.0 | +| | | 15.2 | 0.41.0 | + +## Available LoC metrics + +LoC metrics **are** included in: + +* The {% data variables.product.prodname_copilot_short %} user-level report +* The {% data variables.product.prodname_copilot_short %} usage metrics API + +They are **not** included in the {% data variables.product.prodname_copilot_short %} usage metrics dashboard. + +LoC metrics measure {% data variables.product.prodname_copilot_short %}’s activity across completions, chat, and agent features. For detailed field descriptions and definitions, see [AUTOTITLE](/copilot/reference/copilot-usage-metrics/copilot-usage-metrics#api-and-export-fields). + +## How agent mode affects LoC metrics + +Unlike completions or chat, {% data variables.copilot.copilot_agent_short %} does not follow a “suggest then accept” flow. Agents plan and execute multi-step tasks, often editing multiple files iteratively without explicit acceptance by the user. Because of this, LoC metrics for agent activity are measured differently. + +| Behavior | How it’s reflected in LoC metrics | +|:--|:--| +| Agent code suggestions | Counted as `loc_suggested_to_add_sum` when visible code blocks are shown in the chat panel. | +| Agent edits in files | Counted as `loc_added_sum` and `loc_deleted_sum` under the `agent_edit` feature bucket. These edits are not included in suggested metrics. | +| Multi-file operations | Each file edit contributes to total added and deleted lines, even if triggered by one prompt. | + +Example output for agent-related LoC activity: + +```json +"totals_by_language_feature": [ + { + "language": "unknown", + "feature": "chat_panel_agent_mode", + "code_generation_activity_count": 12, + "code_acceptance_activity_count": 0, + "loc_suggested_to_add_sum": 86, // code block suggestions in chat panel in agent mode + "loc_suggested_to_delete_sum": 0, + "loc_added_sum": 5, // only includes code block copy or apply in chat panel, not agent edits + "loc_deleted_sum": 0 + }, + { + "language": "unknown", + "feature": "agent_edit", + "code_generation_activity_count": 345, + "code_acceptance_activity_count": 0, + "loc_suggested_to_add_sum": 0, + "loc_suggested_to_delete_sum": 0, + "loc_added_sum": 2342, // agent and edit mode edits in files + "loc_deleted_sum": 947 + } +] +``` + +For a single agent edit, you may see metrics such as: + +```json +"user_initiated_interaction_count": 0, +"code_generation_activity_count": 1, +"code_acceptance_activity_count": 0 +``` diff --git a/content/copilot/reference/reconciling-usage-metrics.md b/content/copilot/reference/copilot-usage-metrics/reconciling-usage-metrics.md similarity index 98% rename from content/copilot/reference/reconciling-usage-metrics.md rename to content/copilot/reference/copilot-usage-metrics/reconciling-usage-metrics.md index 324cf9ad423a..c7ccde3495c6 100644 --- a/content/copilot/reference/reconciling-usage-metrics.md +++ b/content/copilot/reference/copilot-usage-metrics/reconciling-usage-metrics.md @@ -11,6 +11,7 @@ contentType: reference allowTitleToDifferFromFilename: true redirect_from: - /early-access/copilot-metrics/dashboards/best-practices-for-correlating-usage-metrics + - /copilot/reference/reconciling-usage-metrics --- {% data reusables.copilot.usage-metrics-preview %} diff --git a/content/copilot/reference/index.md b/content/copilot/reference/index.md index b9351cedaede..c79fd86e3247 100644 --- a/content/copilot/reference/index.md +++ b/content/copilot/reference/index.md @@ -18,7 +18,5 @@ children: - /agentic-audit-log-events - /extensions-glossary - /copilot-usage-metrics - - /interpret-copilot-metrics - - /reconciling-usage-metrics contentType: reference --- diff --git a/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/index.md b/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/index.md index ed923c15a4be..2cef8d6f62c7 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/index.md +++ b/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/index.md @@ -13,6 +13,7 @@ children: - /improve-code-readability - /fix-lint-errors - /refactor-for-optimization + - /refactor-for-sustainability - /refactor-design-patterns - /refactor-data-access-layers - /decouple-business-logic diff --git a/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/refactor-for-sustainability.md b/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/refactor-for-sustainability.md new file mode 100644 index 000000000000..065bcebc0719 --- /dev/null +++ b/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/refactor-for-sustainability.md @@ -0,0 +1,62 @@ +--- +title: Refactoring for environmental sustainability +shortTitle: Refactor for sustainability +intro: '{% data variables.copilot.copilot_chat_short %} can suggest ways to make code more environmentally friendly.' +versions: + feature: copilot +category: + - Refactoring code +complexity: + - Simple +octicon: rocket +topics: + - Copilot +contentType: tutorials +--- + +Code that is inefficient in its use of computational resources can lead to higher energy consumption, which has a negative impact on the environment. Examples of such code include algorithms with high time complexity, excessive memory usage, and unnecessary processing. + +{% data variables.copilot.copilot_chat_short %} can help identify inefficient algorithms or resource-intensive operations in your code that contribute to higher energy consumption. By suggesting more efficient alternatives, it can help reduce the environmental impact of your software. + +## Example scenario + +The following Python code reads a large text file and counts the number of lines. However, it loads the entire file into memory, which can be inefficient for large files and lead to higher energy consumption. It also manually counts the lines instead of using built-in functions. + +```python id=inefficient-code +def count_lines(filename): + with open(filename, 'r') as f: + data = f.read() + lines = data.split('\n') + count = 0 + for line in lines: + count += 1 + return count + +print(count_lines('largefile.txt')) +``` + +## Example prompt + +Here is an example prompt you can use with {% data variables.copilot.copilot_chat_short %} to refactor the above code for better environmental sustainability: + +```copilot copy prompt ref=inefficient-code +Refactor this code to improve its environmental sustainability by reducing memory usage and computational overhead. +``` + +## Example response + +> [!NOTE] {% data variables.copilot.copilot_chat_short %} responses are non-deterministic, so you may get a different response from the one shown here. + +{% data variables.product.prodname_copilot_short %} suggests using a generator expression to read the file line by line, which reduces memory usage. It also uses the built-in `sum` function to count the lines more efficiently. + +```python +def count_lines(filename): + with open(filename, 'r') as f: + return sum(1 for _ in f) # Efficiently counts lines without loading all into memory + +print(count_lines('largefile.txt')) +``` + +## Further reading + +{% data reusables.copilot.example-prompts.further-reading-items %}