Files
compiler-explorer/views/templates/panes/compiler.pug
Matt Godbolt c29ad46f3a [Not Live; disabled by default] Add Claude Explain feature for AI-powered assembly explanations (#7749)
Add Claude Explain feature for AI-powered code explanations

This PR introduces Claude Explain, a new feature that provides AI-powered explanations of compiler output directly within Compiler Explorer.

Key features:

Claude Explain functionality:
  - New explain view pane
  - Explains compiler output with full context of source code and compilation output
  - Configurable audience level and explanation type
  - Response caching to improve performance and reduce API calls
  - Usage statistics display showing requests used and token counts

User experience:
  - Consent flow on first use explaining data handling and privacy
  - AI disclaimer banner warning about potential LLM inaccuracies
  - Respects "no-ai" directive in source code for users who don't want AI processing

Privacy and security:
  - Data sent to Anthropic's Claude API as documented in privacy policy
  - No data used for model training
  - Clear consent required before first use
  - Support for opting out via "no-ai" directive

The feature is marked as beta and can be enabled via configuration.

Co-authored-by: Claude <noreply@anthropic.com>
2025-08-05 09:31:48 -05:00

103 lines
7.2 KiB
Plaintext

mixin newPaneButton(classId, text, title, icon)
button(class="dropdown-item btn btn-sm btn-light new-pane-button " + classId title=title data-cy="new-" + classId + "-btn")
span(class="dropdown-icon " + icon)
| #{text}
#compiler
.top-bar.btn-toolbar.bg-light(role="toolbar")
.btn-group.btn-group-sm(role="group" aria-label="Compiler picker")
.input-group
select.compiler-picker
button.btn.btn-sm.btn-light.input-group-text.picker-popout-button(data-trigger="click" style="cursor: pointer;" role="button" title="Compiler picker popout")
span
i.fa-solid.fa-arrow-up-right-from-square
button.btn.btn-sm.btn-light.input-group-text.prepend-options(data-trigger="click" style="cursor: pointer;" role="button" title="All compilation options")
span.status-icon
input.options.form-control(type="text" placeholder="Compiler options..." size="256" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" aria-label="Compiler options")
.populararguments(title="Popular arguments")
button.btn.btn-sm.btn-light.btn-outline-secondary.dropdown-toggle.dropdown-toggle-split.popular-arguments-btn(type="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false")
span.visually-hidden Popular arguments
div.dropdown-menu.dropdown-menu-end
button.dropdown-item.btn.btn-light.btn-sm
.argmenuitem
span.argtitle Detailed Compiler Flags
span.argdescription Open a new window to edit verbose compiler flags
include ../../font-size
.btn-group.btn-group-sm.filters(role="group")
button.btn.btn-sm.btn-light.dropdown-toggle(type="button" title="Compiler output options" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false" aria-label="Change how the compiler's output is generated")
span.fas.fa-cog
span.hideable Output...
.dropdown-menu
include ../../options-output
.btn-group.btn-group-sm.filters(role="group")
button.btn.btn-sm.btn-light.dropdown-toggle(type="button" title="Compiler output filters" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false" aria-label="Change how the compiler output is filtered")
span.fas.fa-filter
span.hideable Filter...
.dropdown-menu
include ../../options-filters
.btn-group.btn-group-sm(role="group" aria-label="Compiler additions")
button.btn.btn-sm.btn-light.show-libs(title="Include libs" aria-label="Toggle libraries dropdown")
span.fas.fa-book
span.dp-text.hideable Libraries
.btn-group.btn-group-sm(role="group" aria-label="Compiler overrides")
button.btn.btn-sm.btn-light.show-overrides(title="Overrides" aria-label="Configure overrides for standards and architectures etc")
span.fas.fa-wrench
span.dp-text.hideable Overrides
.btn-group.btn-group-sm(role="group")
button.btn.btn-sm.btn-light.dropdown-toggle.add-pane(type="button" title="Add a new pane" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false" aria-label="Add new element for this compiler" data-cy="new-compiler-dropdown-btn")
span.fas.fa-plus
span.hideable Add new...
.dropdown-menu.dropdown-menu-end.new-pane-dropdown(data-cy="new-compiler-pane-dropdown")
+newPaneButton("add-compiler", "Clone Compiler", "Clone this compiler window (click or drag)", "far fa-clone")
+newPaneButton("create-executor", "Executor From This", "Create executor from this compiler", "fas fa-microchip")
+newPaneButton("view-optimization", "Opt Remarks", "Show optimization remarks", "fas fa-weight")
+newPaneButton("view-stack-usage", "Stack Usage", "Show stack usage", "fas fa-layer-group")
+newPaneButton("view-pp", "Preprocessor", "Show preprocessor output", "fas fa-hashtag")
+newPaneButton("view-ast", "AST", "Show AST output", "fas fa-leaf")
+newPaneButton("view-ir", "LLVM IR", "Show LLVM Intermediate Representation", "fas fa-align-center")
+newPaneButton("view-clangir", "ClangIR", "Show Clang Intermediate Representation", "fas fa-align-center")
+newPaneButton("view-opt-pipeline", "Opt Pipeline", "Show optimization pipeline output", "fas fa-compass")
+newPaneButton("view-device", "Device", "Show device output", "fas fa-tv")
+newPaneButton("view-rustmir", "Rust MIR", "Show Rust Mid-level Intermediate Representation", "fas fa-water")
+newPaneButton("view-rusthir", "Rust HIR", "Show Rust High-level Intermediate Representation", "fas fa-arrows-alt")
+newPaneButton("view-rustmacroexp", "Rust Macro Expansion", "Show Rust macro expansion", "fas fa-arrows-alt")
+newPaneButton("view-haskellCore", "GHC Core", "Show GHC Core Intermediate Representation", "fas fa-water")
+newPaneButton("view-haskellStg", "GHC STG", "Show GHC STG Intermediate Representation", "fas fa-water")
+newPaneButton("view-haskellCmm", "GHC Cmm", "Show GHC Cmm Intermediate Representation", "fas fa-water")
+newPaneButton("view-gccdump", "GCC Tree/RTL", "Show GCC Tree/RTL dump", "fas fa-tree")
+newPaneButton("view-gnatdebugtree", "GNAT Debug Tree", "Show GNAT debug tree", "fas fa-tree")
+newPaneButton("view-gnatdebug", "GNAT Debug Expanded Code", "Show GNAT debug expanded code", "fas fa-tree")
+newPaneButton("view-cfg", "Control Flow Graph", "Show assembly control flow graphs", "fas fa-exchange-alt")
+newPaneButton("view-explain", "Claude Explain", "Get AI-powered explanation of your code", "fas fa-robot")
.btn-group.btn-group-sm(role="group")
button.btn.btn-sm.btn-light.dropdown-toggle.add-tool(type="button" title="Add tool" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false" aria-label="Add tooling to this editor and compiler")
span.fas.fa-screwdriver
span.hideable Add tool...
.dropdown-menu.dropdown-menu-end.new-tool-dropdown
.monaco-placeholder
.bottom-bar.bg-light
if !embedded
.btn-group.btn-group-sm
.input-group
button.btn.btn-sm.btn-light.clear-cache(title="Clear cache & recompile" aria-label="Clear cache and recompile")
span.fas.fa-redo
button.btn.btn-sm.btn-light.output-btn(data-cy="new-output-pane-btn" aria-label="Show compiler output")
span.fas.fa-receipt.status-text
| &nbsp;Output
span.output-count(aria-live="polite")
| &nbsp;(
span.text-count
| 0
| /
span.err-count
| 0
| )
span.short-compiler-name.me-1(aria-hidden="true")
button.btn.btn-sm.btn-light.full-compiler-name(data-trigger="click" style="cursor: pointer;" role="button" aria-label="Show compiler information")
span.fas.fa-info
span.compile-info.me-1(title="Compilation info" aria-label="Compilation information")
button.btn.btn-sm.btn-light.full-timing-info(data-trigger="click" style="cursor: pointer;" role="button" aria-label="Show full timing information")
span.fas.fa-chart-bar
button.btn.btn-sm.btn-light.compiler-license(data-trigger="click" style="cursor: pointer;" role="button" aria-label="View compiler license")
span Compiler License