-
Performance First
- Fast builds, responsive watch mode, efficient resource pooling
- Incremental rebuilds, O(1) lookups, parser and query caching
-
"Good Enough" Idiomatic Support
- Focus on common, idiomatic TypeScript/LitElement patterns
- Deep support for decorator-based components and standard practices
- Pragmatic approach: cover 95% of real-world usage efficiently
- Accept limitations rather than slow, comprehensive edge-case handling
-
Serializable Configuration
- Pure JSON/YAML configuration without JavaScript plugins
- Predictable, reproducible builds across environments
- Easy integration with CI/CD pipelines and toolchains
- Configuration as data, not code
-
Real-World Applicability
- All-in-one solution for typical web component development workflows
- Generate, validate, and query manifests in a single tool
- Built for practical project needs, not academic completeness
- Acknowledge that CEM may not be the right tool for every project
cem generate- Analyzes source code and generates manifest filescem list- Queries manifest files for component informationcem validate- Validates manifest files against schemas and best practices
- Language: Go 1.25
- Parsing: Tree-sitter for TypeScript, JavaScript, CSS, HTML, and JSDoc
- CLI Framework: Cobra with Viper for configuration
- Architecture: Modular package structure with clear separation of concerns
- Purpose: CLI command definitions and entry points
- Key Files:
generate.go,list.go,validate.go,root.go - Pattern: Cobra command structure with configuration management
- Purpose: Core manifest generation logic with incremental rebuild capabilities
- Architecture: Session-based processing with dependency tracking
- Key Components: GenerateSession, FileDependencyTracker, ModuleBatchProcessor
- Performance: 68% improvement with incremental rebuilds (1.1s → 350ms)
- Purpose: Go structs representing Custom Elements Manifest schema
- Features: JSON marshaling/unmarshaling, table rendering, validation helpers
- Schema Support: CEM 2.1.0 with backward compatibility
- Purpose: Manifest validation against schemas and best practices
- Features: Schema validation, intelligent warnings, deprecation detection
- Schemas: Support for CEM versions 0.1.0 through 2.1.1-speculative
- Purpose: Fast querying and flexible display of manifest data
- Features: Column filtering, table rendering, tree views
- Output: Markdown tables, structured data, custom formatting
- Purpose: LSP server for editor integration (completions, diagnostics, definitions, references)
- Architecture: Method-per-package pattern under
methods/textDocument/ - Document System: BaseDocument embedding with language-specific document types (HTML, TSX, TypeScript)
- Key Patterns: Tree-sitter tree ref-counting, UTF-16 offset conversion, parser pools
- Purpose: MCP server exposing manifest data to AI coding agents
- Features: Resources (element listings, details) and tools (generate HTML, validate HTML)
- Purpose: Local dev server with live reload for web component development
- Features: Import rewriting, TypeScript transform, frontend test runner integration
- Purpose: Unified interface for local and remote package access
- Implementations: FileSystem and Remote workspace contexts
- Key Features: Path resolution, file operations, configuration management
- Purpose: Declarative parsing of source code using tree-sitter
- Languages: TypeScript, CSS, HTML, JSDoc
- Components: QueryManager (compiled query cache), QueryMatcher (per-operation cursors), embedded
.scmquery files
- Purpose: Language-specific tree-sitter query definitions and parsing logic
- Structure:
typescript/ecmascript.go(shared JS/TS queries),registry/(language registry)
- Purpose: Tracks import/export relationships between modules
- Features: Lazy loading, transitive dependency resolution, metrics
- Purpose: UTF-16 code unit offset conversion for LSP protocol compliance
- Key Function: Converts between Go's UTF-8 byte offsets and LSP's UTF-16 character offsets
- Purpose: DTCG (Design Tokens Community Group) format support
- Integration: Merges design tokens into component manifests
- Purpose: Global HTML attribute data for validation and diagnostics
- Purpose: Generic set operations for data processing
- Purpose: Automatically discovers and links component demos
- Pattern: Convention-based discovery with manifest integration
GenerateSession orchestrates manifest generation cycles, maintaining tree-sitter parsers and query managers across runs for efficient watch mode. FileDependencyTracker enables incremental rebuilds via SHA256 content hashing and bidirectional dependency maps (incremental for ≤3 affected modules, full rebuild otherwise). ModuleBatchProcessor abstracts the worker pool pattern with dependency-tracking and simple processing modes.
All language-specific document types (HTML, TSX, TypeScript) embed base.BaseDocument, which provides tree-sitter tree lifecycle management, content storage, UTF-16 offset conversion, and parser pool integration. Language-specific documents implement only their unique parsing and query logic. Trees are ref-counted to prevent use-after-free when concurrent operations hold references during document updates.
- Tree-sitter queries compiled once per session, parsers pooled across workers, trees ref-counted
- Incremental rebuilds via SHA256 content hashing and dependency graphs with smart fallback to full rebuild
- O(1) module lookup via persistent index
- Dual manifest access: shallow copy for hot paths, deep copy for isolation
This project follows Conventional Commits with scopes based on top-level commands:
<type>(<scope>): <description>
[optional body]
[optional footer]
Types:
feat: New featurefix: Bug fixdocs: Documentation changesstyle: Code style changes (formatting, etc.)refactor: Code refactoringtest: Adding or modifying testschore: Maintenance tasks
Scopes:
generate: Manifest generation functionalitylist: Querying and display functionalityvalidate: Validation functionalitymanifest: Core manifest types and serializationlsp: Language server protocolmcp: Model context protocol serverserve: Dev servercmd: CLI command definitionsdeps: Dependencies and build system
Examples:
feat(generate): add --watch flag for incremental rebuilds
fix(manifest): handle deprecated field unmarshaling
docs(validate): update schema validation examples
test(generate): add comprehensive round-trip tests
Format: <type>/<description-with-hyphens>
Examples:
feat/watch-mode-implementationfix/manifest-serialization-bugtest/marshal-unmarshal-coveragedocs/architecture-documentationrefactor/generate-session-cleanup
- Create PRs for all non-trivial changes
- Use descriptive titles matching commit message format
- Include comprehensive description with:
- Summary of changes
- Test plan or coverage
- Breaking changes (if any)
- Ensure all tests pass before requesting review
- Add
🤖 Generated with [Claude Code](https://claude.ai/code)footer when AI-assisted
- Run tests:
make testbefore committing - Format code: Pre-commit hooks handle
go fmt - Race detection: Tests run with
-raceflag in CI - Linting:
golangci-lintprovides PR feedback - Documentation: Update relevant docs with functional changes