AI context file for assistants (Claude Code, Cursor, Copilot) working with this open-source Web Components project.
Full docs: README.md | Team patterns: docs/team/
- LitElement 2.x + Web Components (Shadow DOM)
- AMF v4.0+ (API Modeling Framework - RAML/OAS/AsyncAPI/gRPC)
- npm workspace (18+ packages, main:
api-console, components:api-navigation,api-documentation, etc.) - @web/test-runner (testing, NOT Jest - poor Shadow DOM support)
- Rollup (builds), Playwright (visual regression)
src/ApiConsoleApp.js- Standalone app (routing, layout, OAuth)src/ApiConsole.js- Embeddable component (no routing/layout)
IMPORTANT: API Console does NOT parse API files directly. It requires pre-generated AMF models.
MuleSoft's unified model for RAML, OAS, AsyncAPI, gRPC. Format: JSON-LD (AMF v4.0+).
# 1. Define APIs in demo/apis.json: { "path/to/api.raml": "RAML 1.0" }
# 2. Generate models
npm run build:models
# 3. Models saved to demo/models/*.json// Direct model
apiConsole.amf = await generateApiModel();
// URL to JSON
apiConsole.modelLocation = 'models/my-api.json';IMPORTANT: Use custom events, NOT direct method calls.
// ✅ GOOD: Custom event (bubbles across Shadow DOM)
this.dispatchEvent(new CustomEvent('api-navigation-selection-changed', {
bubbles: true,
composed: true,
detail: { selected, type }
}));
// ❌ BAD: Direct method call (breaks encapsulation)
this.parentElement.onNavigationChange(selected);Why: Shadow DOM isolation requires composed events to bubble across boundaries.
IMPORTANT: Use AmfHelperMixin utilities, NOT direct JSON access.
// ✅ GOOD: AmfHelperMixin
import { AmfHelperMixin } from '@api-components/amf-helper-mixin';
class MyComponent extends AmfHelperMixin(LitElement) {
_computeEndpoints(model) {
return this._computeWebApi(model); // Helper method
}
}
// ❌ BAD: Direct JSON access (structure changes)
const endpoints = model['@graph'][0]['http://raml.org/vocabularies/http#endpoint'];Why: AMF model structure can change; helpers abstract this.
Use CSS custom properties for theming:
:host {
--api-console-primary-color: #00A1E0;
}❌ Never manipulate DOM styles directly (document.querySelector('#api-console').style...).
For large APIs, lazy load components on demand:
if (this.selectedShape) {
import('@api-components/api-documentation')
.then(() => this._renderDocumentation());
}npm test # All tests (chromium + firefox)
npm run test:watch # Watch mode
npm run test:visual # Visual regression
npm run test:visual:update # Update baselines (after intentional UI changes)IMPORTANT: Use @web/test-runner, NOT Jest (poor Shadow DOM support).
import { fixture, expect } from '@open-wc/testing';
it('renders navigation', async () => {
const el = await fixture('<api-console></api-console>');
expect(el.shadowRoot.querySelector('api-navigation')).to.exist;
});- IMPORTANT: Never parse API files directly → Use AMF models
- IMPORTANT: Never access AMF JSON directly → Use AmfHelperMixin
- IMPORTANT: Never use direct method calls between components → Use custom events
- Never use Jest → Use @web/test-runner
- Never use
anyin TypeScript → Proper types
- Never import CodeMirror/crypto as ES modules → Use
vendor.js(non-ES6 dependencies bundled separately) - Never modify AMF model structure → External standard, use helpers
- Never commit directly to master → Always create branch first (
fix/W-XXXXXXXX-descorbuild/X.X.X) - Never skip GPG signing → Run
mulesoft-gitbefore committing - Never commit large models → Generate locally (
npm run build:models)
Rule: Don't run build after every small change (saves tokens, avoids error loops).
Workflow:
- Implement feature
- Write tests
- Run
npm test(once) - Run
npm run buildonly when: user asks explicitly, before PR, or after major type changes
npm run prepare # Build vendor.js + generate AMF models (required after clone)
npm start # Dev server
npm test # Run all tests
npm run build # Production build
npm run build:models # Generate AMF models from demo/apis.json
npm update @api-components/* # Update workspace components- Runbooks: docs/team/runbooks/ - Release process, debugging
- Patterns: docs/team/patterns/ - Web Component communication, architecture
- Configs: docs/team/configs/ - Git GPG setup, IDE settings
- Full docs: https://docs.api-console.io
- AMF: https://github.com/aml-org/amf
- LitElement v2: https://lit.dev/docs/v2/
- @web/test-runner: https://modern-web.dev/docs/test-runner/overview/
Last Updated: 2026-03-20 (Ultra-optimized for AI context efficiency)