[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>
This commit is contained in:
Matt Godbolt
2025-08-05 09:31:48 -05:00
committed by GitHub
parent 83c2b8b019
commit c29ad46f3a
27 changed files with 1964 additions and 6 deletions

View File

@@ -24,7 +24,7 @@
import {describe, expect, it} from 'vitest';
import {addDigitSeparator, escapeHTML, splitArguments} from '../shared/common-utils.js';
import {addDigitSeparator, capitaliseFirst, escapeHTML, splitArguments} from '../shared/common-utils.js';
describe('HTML Escape Test Cases', () => {
it('should prevent basic injection', () => {
@@ -167,3 +167,29 @@ describe('argument splitting', () => {
expect(splitArguments('"hello \\"world\\" \\\\"')).toEqual(['hello "world" \\']);
});
});
describe('capitalise first', () => {
it('should capitalise normal strings', () => {
expect(capitaliseFirst('hello')).toEqual('Hello');
expect(capitaliseFirst('world')).toEqual('World');
});
it('should handle empty strings', () => {
expect(capitaliseFirst('')).toEqual('');
});
it('should handle single characters', () => {
expect(capitaliseFirst('a')).toEqual('A');
expect(capitaliseFirst('z')).toEqual('Z');
});
it('should handle already capitalised strings', () => {
expect(capitaliseFirst('Hello')).toEqual('Hello');
expect(capitaliseFirst('WORLD')).toEqual('WORLD');
});
it('should handle non-alphabetic first characters', () => {
expect(capitaliseFirst('123abc')).toEqual('123abc');
expect(capitaliseFirst('!hello')).toEqual('!hello');
});
});