Repository Structure
April 22, 2026 · View on GitHub
Comprehensive guide to the templjs monorepo organization, naming conventions, and file locations.
This document is repository reference material.
- use release-process.md for branch and release operations
- use ci-cd.md for workflow behavior and required checks
Overview
templjs is organized as a pnpm workspace monorepo using Nx for build orchestration and caching. The repository contains multiple packages, extensions, documentation, and development infrastructure.
Directory Tree
templjs/
├── .agents/ # AI agent skills and configurations
│ ├── skills/ # Agent skill definitions
│ └── skills-manifest.md # Catalog of all skills
├── .changeset/ # Changesets for versioning
│ ├── config.json # Changeset configuration
│ └── *.md # Individual changesets
├── .doc-vader/ # Backlog consumer configuration
├── .github/ # GitHub configuration
│ ├── workflows/ # GitHub Actions workflows
│ │ ├── backlog-automation.yml # Backlog event ingestion automation
│ │ ├── ci.yml # CI workflow (tests, lint, build)
│ │ ├── release.yml # Release workflow (publish)
│ │ ├── codeql.yml # Security analysis
│ │ └── benchmark.yml # Benchmark publishing/comparison
│ ├── ISSUE_TEMPLATE/ # Issue templates
│ ├── organization-setup.md # Repository and org admin setup
│ ├── pull_request_template.md # PR template
│ ├── SECRETS.md # CI/CD secret reference
│ └── copilot-instructions.md # Copilot agent instructions
├── .husky/ # Git hooks (pre-commit, commit-msg)
├── .nx/ # Nx cache (ignored by Git)
├── backlog/ # Work items, evidence, and audit artifacts
│ ├── active/ # Active work items
│ │ └── work-item-*.md
│ ├── archive/ # Completed work items
│ │ └── work-item-*.md
│ ├── records/ # Evidence records
│ │ └── record-*.md
│ └── audit/ # Migration and reconciliation output
├── docs/ # Documentation
│ ├── adr/ # Architecture Decision Records
│ │ └── NNN-title.md # Individual ADRs
│ ├── prd/ # Product Requirements Documents
│ ├── ci-cd.md # CI/CD infrastructure guide
│ ├── coverage-strategy.md # Coverage policy reference
│ ├── repository-structure.md # This file
│ └── release-process.md # Release operations guide
├── examples/ # Example templates and usage
│ ├── README.md # Examples overview
│ └── *.templ # Example template files
├── src/
│ ├── extensions/ # IDE extensions
│ │ └── vscode/ # VS Code extension
│ │ ├── src/
│ │ ├── syntaxes/ # TextMate grammars
│ │ ├── package.json # Extension manifest
│ │ └── tsconfig.json
│ └── packages/ # Published packages
│ ├── core/ # @templjs/core
│ │ ├── src/
│ │ │ ├── lexer/ # Tokenization
│ │ │ ├── parser/ # AST generation
│ │ │ ├── renderer/ # Template rendering
│ │ │ ├── query/ # Query engine
│ │ │ └── __tests__/ # Tests (co-located)
│ │ ├── package.json
│ │ ├── tsconfig.json
│ │ ├── vitest.config.ts
│ │ └── README.md
│ ├── cli/ # @templjs/cli
│ │ ├── src/
│ │ │ ├── commands/ # CLI commands
│ │ │ ├── utils/ # Utilities
│ │ │ └── __tests__/
│ │ ├── bin/ # CLI entry point
│ │ ├── package.json
│ │ └── README.md
│ └── volar/ # @templjs/volar
│ ├── src/
│ │ ├── language-service/ # Language features
│ │ ├── utils/
│ │ └── __tests__/
│ ├── package.json
│ └── README.md
├── schemas/ # JSON schemas
│ └── frontmatter/ # Document frontmatter schemas
│ ├── by-type/ # Schemas selected by frontmatter `type`
│ │ ├── document/
│ │ │ ├── current.json
│ │ │ ├── v1.0.0.json
│ │ │ └── latest.json
│ │ └── work-item/
│ │ ├── current.json
│ │ ├── v1.0.0.json
│ │ └── latest.json
│ ├── support/ # Shared schema building blocks
│ │ ├── base/
│ │ ├── contracts/
│ │ ├── overlays/
│ │ └── payloads/
│ └── schema-map.json # Type -> schema routing map
│ └── work-management/ # Canonical backlog/work-management schemas
│ ├── frontmatter/
│ └── support/
├── .editorconfig # Editor configuration
├── .eslintrc.json # ESLint configuration
├── .gitignore # Git ignore rules
├── .markdownlint.yaml # Markdown linting rules
├── .npmrc # npm configuration
├── .prettierrc.json # Prettier configuration
├── codecov.yml # Codecov configuration
├── DEVELOPMENT.md # Development guide
├── migration-plan.md # Migration from Python version
├── nx.json # Nx configuration
├── package.json # Root package configuration
├── pnpm-lock.yaml # Dependency lockfile
├── pnpm-workspace.yaml # pnpm workspace configuration
├── README.md # Project overview
├── templjs.code-workspace # VS Code workspace file
└── tsconfig.base.json # Base TypeScript configuration
Package Organization
Backlog Organization
Backlog automation uses the canonical doc-vader work-management model.
- Work items use
work-item:*identifiers and live inbacklog/active/orbacklog/archive/. - Evidence uses
record:*identifiers and lives inbacklog/records/. backlog/audit/stores migration and reconciliation artifacts.- Use
pnpm run backlog:doc-vader -- ...for backlog mutations andpnpm run lint:frontmatterto validate the results.
Core Package (@templjs/core)
Purpose: Core template engine (lexer, parser, renderer, query engine)
Key Directories:
src/lexer/: Tokenization (Chevrotain lexer)src/parser/: Parsing (Chevrotain parser)src/renderer/: Template rendering enginesrc/query/: Query language (dot notation, JMESPath)src/types/: TypeScript type definitionssrc/__tests__/: Co-located tests
Entry Point: src/index.ts
Exports:
createLexer(): Lexer factorycreateParser(): Parser factoryrender(): Template renderingquery(): Query data- Types:
Token,AST,RenderOptions
CLI Package (@templjs/cli)
Purpose: Command-line interface for template processing
Key Directories:
src/commands/: CLI command implementations (render,validate,init)src/config/:.templjs.jsonconfig loading and schema validationsrc/formats/: JSON/YAML/TOML/XML input parserstest/: CLI integration and behavior tests
Entry Point: src/packages/cli/src/cli.ts
Path convention in this section: entry-point paths are repository-root relative (for package code, that means src/packages/<name>/...).
Commands:
templjs render --template <path> --input <path|->: Render templatetempljs render --watch: Watch template/input files and re-render on changestempljs validate --template <path>: Validate syntax and optional schema/inputtempljs init --format <markdown|html|json|yaml>: Generate starter templates
Volar Plugin (@templjs/volar)
Purpose: Volar language service plugin for IDE integration
Key Directories:
src/language-service/: Language features (hover, completion, diagnostics)src/utils/: Plugin utilitiessrc/__tests__/: Plugin tests
Entry Point: src/index.ts
Exports:
createVolarPlugin(): Plugin factory- Language service providers
VS Code Extension (vscode-templjs)
Purpose: VS Code integration via Volar
Key Directories:
src/: Extension source codesyntaxes/: TextMate grammar for syntax highlightingclient/: Language clientserver/: Language server (uses Volar)
Entry Point: src/extension.ts
Features:
- Syntax highlighting
- Diagnostics
- Hover information
- Auto-completion
- Go to definition
Documentation Organization
Architecture Decision Records (docs/adr/)
Purpose: Document significant architectural decisions
Naming Convention: NNN-title.md (e.g., 001-language-migration.md)
Format: MADR (Markdown Any Decision Records)
Sections:
- Status: accepted, proposed, deprecated, superseded
- Context: Problem statement
- Decision: What was decided
- Consequences: Implications of the decision
Index: Maintained in docs/adr/README.md
Product Requirements (docs/prd/)
Purpose: Product specifications and feature requirements
Naming Convention: feature-name.md
Format: Custom PRD template
Sections:
- Overview
- Goals
- User stories
- Technical specification
- Success metrics
Guides (docs/)
Purpose: User and developer documentation
Key Files:
ci-cd.md: CI/CD infrastructurerepository-structure.md: This filerelease-process.md: Release operations guideDEVELOPMENT.md: Development guide (root)
Work Item Organization
Active Work Items (backlog/)
Purpose: Track in-progress and planned work
Naming Convention: NNN_description.md (e.g., 005_chevrotain_lexer.md)
Numbering:
- Sequential numbering starting from 001
- Zero-padded to 3 digits (001, 002, ..., 099, 100)
- Gaps are acceptable (deleted/rejected items)
Frontmatter (see schemas/frontmatter/by-type/work-item/latest.json):
---
id: '005'
title: 'Implement Chevrotain Lexer'
status: in_progress # not_started, in_progress, testing, completed
priority: high # low, medium, high, critical
estimated_hours: 8
actual_hours: 6
started_date: 2026-02-18
completed_date: null
tags: [core, lexer, v1.0]
dependencies: ['002']
branch: feature/005-chevrotain-lexer
related_commits: [abc123, def456]
related_prs: [42]
---
Sections:
- Goal
- Background
- Tasks
- Deliverables
- Acceptance Criteria
- Notes
Archived Work Items (backlog/archive/)
Purpose: Historical record of completed work
When to Archive:
- Status: completed
- PR merged to main
- All acceptance criteria met
Process:
# Update final status
# Edit backlog/NNN_item.md frontmatter:
# status: completed
# completed_date: 2026-02-18
# actual_hours: X
# Move to archive
mv backlog/NNN_item.md backlog/archive/
# Commit
git add backlog/archive/NNN_item.md
git commit -m "chore: archive work item NNN"
Naming Conventions
Files
| Type | Convention | Example |
|---|---|---|
| Source files | kebab-case.ts | template-tokenizer.ts |
| Test files | *.test.ts | lexer.test.ts |
| Config files | lowercase.json | tsconfig.json |
| Documentation | kebab-case.md | release-process.md, ci-cd.md |
| Work items | NNN_description.md | 005_chevrotain_lexer.md |
| ADRs | NNN-title.md | 001-language-migration.md |
| Examples | descriptive.templ | user-profile.templ |
Exceptions:
- keep canonical special filenames uppercase where the toolchain expects them, such as
README.mdandAGENTS.md
Branches
| Type | Convention | Example |
|---|---|---|
| Staging | staging | staging |
| Main | main | main |
| Feature | feature/NNN-description | feature/005-chevrotain-lexer |
| Bugfix | fix/NNN-description | fix/042-parser-edge-case |
| Hotfix | hotfix/NNN-description | hotfix/101-critical-parser |
| Chore | chore/description | chore/update-deps |
Release publication is tag-based, not branch-based:
- npm package releases use
vX.Y.Z - VS Code extension releases use
vscode-vX.Y.Z
Commits
Format: Conventional Commits
<type>(<scope>): <subject>
<body>
<footer>
Types:
feat: New featurefix: Bug fixdocs: Documentation changeschore: Maintenance taskstest: Test changesrefactor: Code refactoringperf: Performance improvementsci: CI/CD changes
Scopes:
core: @templjs/core changescli: @templjs/cli changesvolar: @templjs/volar changesvscode: VS Code extension changesdeps: Dependency updatesdocs: Documentation updatesci: CI/CD updates
Examples:
feat(core): implement Chevrotain lexer
fix(parser): handle nested expressions correctly
docs: update README with installation steps
chore(deps): upgrade chevrotain to v11
test(lexer): add edge case for empty templates
ci: add secret scanning workflow
Pull Requests
Title Format: Same as commit message (conventional commits)
Label Conventions:
feat: New featurefix: Bug fixdocs: Documentationchore: Maintenancebreaking: Breaking changeneeds-review: Awaiting reviewwork-in-progress: Not ready for reviewblocked: Dependent on other work
PR Number: Auto-assigned by GitHub
Packages & Scopes
All published packages use @templjs/ scope:
@templjs/core: Core engine@templjs/cli: CLI tool@templjs/volar: Volar plugin
Non-scoped:
vscode-templjs: VS Code extension (marketplace requirement)
Configuration Files
Root Level
package.json: Root package, scripts, dev dependenciespnpm-workspace.yaml: Workspace configurationnx.json: Nx configuration (caching, affected commands)tsconfig.base.json: Base TypeScript configuration (extended by packages).eslintrc.json: Root ESLint configuration.prettierrc.json: Prettier configuration.editorconfig: Editor settings (indentation, line endings).markdownlint.yaml: Markdown linting rules.gitignore: Git ignore patterns.npmrc: npm configuration (registry, scope)codecov.yml: Codecov coverage thresholdspackage.jsontoolchain fields: Canonical Node.js/pnpm pins used locally and in CI
Package Level
Each package has:
package.json: Package metadata, scripts, dependenciestsconfig.json: TypeScript configuration (extends root)vitest.config.ts: Vitest test configurationREADME.md: Package documentation
Extension Level
VS Code extension has:
package.json: Extension manifest (contributes, activationEvents)tsconfig.json: TypeScript configuration.vscodeignore: Files to exclude from extension package
Special Directories
.nx/ (Git Ignored)
Nx computation cache. Contains cached task outputs for faster rebuilds.
Do not commit: Automatically regenerated
node_modules/ (Git Ignored)
Package dependencies installed by pnpm.
Do not commit: Installed via pnpm install
.husky/ (Committed)
Git hooks for pre-commit checks.
Commit: Ensures all contributors use same hooks
.changeset/ (Committed)
Changesets for version management. Individual changesets are committed, cache is ignored.
Commit: *.md files (changesets)
Ignore: .changeset/.cache/
Dependency Management
Dependency Types
{
"dependencies": {}, // Runtime dependencies
"devDependencies": {}, // Development-only dependencies
"peerDependencies": {}, // Required by consumers
"optionalDependencies": {} // Optional enhancements
}
Workspace Dependencies
Internal packages reference each other via workspace protocol:
{
"dependencies": {
"@templjs/core": "workspace:*"
}
}
This is resolved to the actual version on publish.
Dependency Versions
- ~: Patch updates only (
~1.2.3→1.2.x) - ^: Minor updates (
^1.2.3→1.x.x) - exact: No updates (
1.2.3→1.2.3)
Policy: Use ^ for most dependencies, exact for critical dependencies
Build Outputs
.gitignore Patterns
# Build outputs
dist/
*.tsbuildinfo
.nx/cache
# Dependencies
node_modules/
# Test coverage
coverage/
# Environment
.env
.env.local
# IDE
.vscode/*
!.vscode/settings.json
!.vscode/extensions.json
.idea/
# OS
.DS_Store
Thumbs.db
Build Artifacts
dist/: Compiled JavaScript (ESM + CJS)*.tsbuildinfo: TypeScript incremental build infocoverage/: Test coverage reports
Migration Context
From Python to TypeScript
This repository is the TypeScript rewrite of the original Python temple project.
Legacy Repository: /Users/macos/dev/temple/ (Python)
New Repository: /Users/macos/dev/templjs/ (TypeScript)
Migration Plan: See migration-plan.md for detailed roadmap
Coexistence: Both versions exist during migration period
Architectural Differences
| Aspect | Python (Legacy) | TypeScript (New) |
|---|---|---|
| Parser | Custom recursive descent | Chevrotain (parser combinator) |
| LSP | Custom Python LSP | Volar plugin (TypeScript) |
| Testing | pytest | Vitest |
| Build | setup.py | pnpm + Nx |
| Packaging | PyPI | npm + VS Code marketplace |
Reference
- Monorepo Structure: Defined by this file
- Naming Conventions: This file
- Build System: Nx (
nx.json) - Package Manager: pnpm (
pnpm-workspace.yaml) - Work Item Schema:
schemas/frontmatter/by-type/work-item/latest.json - Document Schema:
schemas/frontmatter/by-type/document/latest.json - Migration Plan:
migration-plan.md