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>
Makes the Compiler Explorer app, and all the tooling ESM compatible.
Things that have been done:
1. The package.json has `type: module` now
2. All relative imports have a .js ending
3. All directory imports are now directory/index.js to comply with ESM
standards
4. Dependency node-graceful is now imported into tree, because the
package is broken under esm
5. Dependency p-queue has been bumped to 7.x with ESM support
6. Dependency profanities has been bumped to 3.x with ESM support
7. Webpack config is now both ESM and CommonJS compatible
8. Non-ESM compatible imports have been rewritten
9. ESLint configuration has been tweaked to not fail on .js imports
10. Mocha is now hacked together and ran with ts-node-esm
11. Webpack is now hacked together and ran with ts-node-esm
12. Webpack config is now ESM compatible, so that it can be used in the
dev server
13. Cypress code still runs commonjs, and has been excluded from the
tsconfig
14. All sinon mock tests have been commented out, because sinon module
mocks do not work with ESModules (because ESModules are immutable)
A lot of tests are now giving warnings/errors to stdout, yet still pass.
Docenizer codegenerator scripts have been updated, but I did not re-run
them, and instead just changed their code.
---------
Co-authored-by: Matt Godbolt <matt@godbolt.org>
* Fix type of tool id
Observed through the debugger it seems the tool id is a `string`, which leads to all sorts of downstream complaints comparing strings to ints when converting tools.js to ts (see #4166)
* Add tools to CE Options
* Fixings
The options were being properly passed in the state,
but the UI was being initialized before the value was set to the member,
causing it not to be displayed.
Closes#4207
* add compilationinfo and related types
* fix mtime type
* Add rest of compiler keys
* Make it compile
* Rename Compiler type to CompilerInfo as per Partouf's suggestion
* Get ready for #4077
* Linter fixes
Co-authored-by: Rubén Rincón Blanco <ruben@rinconblanco.es>
* Rename static/libs-widget-ext.js to static/libs-widget-ext.ts
* Initial Typescript copy&paste
* File now compiles its TS
* First TSfy pass
Types need to still be sorted out, but this now compiles and works
:)
* Further work towards porting libs widget to TS
* Expand the scope of the PR and fix some TS issues elsewhere
Still releated to libs though
* Renames
* Address PR review
* Fixes some minor errors and finishes the tests
* Remove unused interface properties
As suggested by partouf in the PR
* Remove unused this
Noticed by Partouf in the PR review
* Remove more unused options interface properties
* Fixes last issues with the ts libs widget
* Remove console.log