Advanced Easy Approach to Requirements Syntax - A formal requirements language tool that automatically generates UML diagrams from structured natural language requirements.
✨ Structured Requirements Syntax - Write requirements in natural language with formal structure
🎯 Automatic UML Generation - Generate PlantUML diagrams from requirements
🔍 Real-time Validation - Language server with syntax checking and auto-completion
📊 Requirements Analysis - Extract actors, use cases, and statistics
🛠️ CLI Tools - Command-line interface for validation, parsing, and generation
🧪 Type-Safe - Full TypeScript implementation with comprehensive testing
- Installation
- Quick Start
- AEARS Language Syntax
- CLI Usage
- Language Server (LSP)
- API Usage
- Development
- Testing
- Contributing
- License
- Node.js ≥ 22.0.0
- npm or yarn
# Clone the repository
git clone https://github.com/amir-arad/adv-ears.git
cd adv-ears
# Install dependencies
npm install
# Build the project
npm run buildCreate a file example.aears:
The system shall authenticate users
When login attempted the system shall validate credentials
The system shall not allow unauthorized access
While session active the system shall maintain state
If user authenticated then the system shall grant access
npm start validate example.aearsnpm start generate example.aears --title --statsOutput:
@startuml
title Requirements Use Case Diagram
!-- Actors --
actor "system" as system
actor "user" as user
!-- Use Cases --
usecase "authenticate users" as UC1
usecase "validate credentials" as UC2
usecase "allow unauthorized access" as UC3
usecase "maintain state" as UC4
usecase "grant access" as UC5
!-- Relationships --
system --> UC1
system ..> UC2
system --x UC3
system ==> UC4
system -.> UC5
@endumlAEARS supports six requirement types, each with specific syntax patterns:
The <entity> shall <functionality>
Example: The system shall authenticate users
When <precondition> the <entity> shall <functionality>
Example: When login attempted the system shall validate credentials
The <entity> shall not <functionality>
Example: The system shall not allow unauthorized access
While <state> the <entity> shall <functionality>
Example: While session active the system shall maintain state
If <condition> then the <entity> shall <functionality>
Where <condition> the <entity> shall <functionality>
Examples:
If user authenticated then the system shall grant accessWhere security enabled the system shall log activities
Complex conditional statements - feature in development.
- Case Insensitive: Keywords can be uppercase or lowercase (
IF/if,THEN/then) - Natural Language: Requirements remain readable while maintaining formal structure
- Actor Extraction: System automatically identifies entities as actors
- Use Case Generation: Functionalities become use cases in UML diagrams
The CLI provides five main commands for working with AEARS files:
Validate AEARS file syntax:
npm start validate <file.aears> [options]
Options:
-v, --verbose Show detailed output including statistics and actorsExamples:
# Basic validation
npm start validate requirements.aears
# Verbose output with statistics
npm start validate requirements.aears --verboseParse AEARS files and output the Abstract Syntax Tree:
npm start parse <file.aears> [options]
Options:
-o, --output <file> Output file (default: stdout)
-f, --format <format> Output format: json|pretty (default: pretty)Examples:
# Pretty-printed AST to console
npm start parse requirements.aears
# JSON output to file
npm start parse requirements.aears --format json --output ast.jsonGenerate UML diagrams from AEARS files:
npm start generate <file.aears> [options]
Options:
-o, --output <file> Output file (default: stdout)
-f, --format <format> Output format: plantuml|report (default: plantuml)
--title Include title in UML diagram
--stats Include statistics in UML diagram
--no-relationships Exclude relationships in UML diagramExamples:
# Basic PlantUML generation
npm start generate requirements.aears
# Full-featured diagram with title and stats
npm start generate requirements.aears --title --stats --output diagram.puml
# Text report instead of UML
npm start generate requirements.aears --format reportAnalyze AEARS files and show detailed metrics:
npm start analyze <file.aears>Output includes:
- Total requirement counts by type
- Identified actors and use cases
- Requirement type coverage analysis
- Missing requirement type warnings
Start the Language Server Protocol server:
npm start lsp [options]
Options:
--stdio Use stdio for communication
--socket <port> Use socket for communication
--node-ipc Use Node IPC for communicationAll CLI commands:
- Exit with code 0 on success
- Exit with code 1 on error
- Require
.aearsfile extension - Provide detailed error messages for syntax issues
The AEARS Language Server provides rich IDE support with real-time features:
- Syntax Validation: Real-time error detection and reporting
- Auto-completion: Intelligent suggestions for AEARS keywords
- Hover Information: Context-aware help for entities and keywords
- Diagnostics: Live error reporting with detailed messages
- Continuous Validation: Updates validation as you type
For local development with full VS Code integration:
- Build the project:
npm run build - Setup extension:
cd .vscode/extensions/aears-language-server npm install npm run compile - Launch extension: Press
F5in VS Code to open Extension Development Host - Test: Open
.aearsfiles in the new window to test language server features
The extension provides syntax highlighting, error diagnostics, and auto-completion for AEARS files.
- Text Document Sync: Incremental updates
- Completion Provider: Trigger characters and keyword suggestions
- Hover Provider: Contextual information on demand
- Diagnostic Publisher: Real-time error reporting
Use Adv-EARS as a TypeScript library in your projects:
import { parseAearsFile } from 'adv-ears';
import { UMLGenerator } from 'adv-ears';
// Parse AEARS content
const content = `
The system shall authenticate users
When login attempted the system shall validate credentials
`;
const result = parseAearsFile(content);
if (result.success) {
// Generate UML
const generator = new UMLGenerator();
const uml = generator.generatePlantUML(result.ast);
console.log(uml);
} else {
console.error('Parse errors:', result.errors);
}- Parses AEARS content and returns success/error result
- Returns AST on success or error list on failure
generatePlantUML(ast, options?): Create PlantUML diagramgenerateReport(ast): Create text analysis report
extractActors(ast): Get unique actors from requirementsextractUseCases(ast): Get actor-functionality pairsgetStatistics(ast): Get requirement type counts
The library uses result objects for error handling:
interface ParseResult {
success: boolean;
ast?: DocumentNode;
errors: string[];
}.aears files → SimpleParser → AST → ASTGenerator → UML/Analysis
- SimpleParser (
src/parser/simple-parser.ts): Regex-based parser for 6 requirement types - AST Types (
src/types/ast-types.ts): RequirementNode, DocumentNode definitions - ASTGenerator (
src/ast/ast-generator.ts): AST processing, actor/use case extraction - UMLGenerator (
src/generators/uml-generator.ts): PlantUML diagram generation - LSP Server (
src/lsp/server.ts): Language Server Protocol implementation
# Development with watch mode
npm run dev
# Type checking
npm run typecheck
# Code quality
npm run lint
npm run lint:fix
# Dependency analysis
npm run knip
# Full check (lint + typecheck + format + test)
npm run check
# Clean build artifacts
npm run clean- ESLint: TypeScript rules, max complexity 10
- Prettier: Consistent code formatting
- File Limits: Max 200 lines per file, 100 lines per function
- Type Safety: Avoid
any, useunknownwhen needed - Patterns: Functions over classes, pure functions, single responsibility
Tests derive directly from requirements and verify actual behavior:
// ✅ Good: Tests actual functionality
it('The parser shall tokenize aears files', () => {
const tokens = tokenize('The system shall work');
assert.ok(tokens.length > 0);
});
// ❌ Bad: Only tests syntax recognition
it('should parse requirement', () => {
parseAearsFile('The system shall work'); // Doesn't test actual behavior
});# Run all tests
npm test
# Watch mode
npm run test:watch
# Run specific test
npm test -- tests/unit/parser.test.ts- Unit Tests (
tests/unit/): Individual component testing - Integration Tests (
tests/integration/): End-to-end feature testing - Contract Tests (
tests/contract/): Requirements-derived behavioral tests - LSP Tests (
tests/integration/lsp-server.test.ts): Real protocol testing
- Behavior-Driven: Test what the requirement claims to do
- Real Protocol: LSP tests use actual JSON-RPC communication
- One Test Per Requirement: Each test validates one specific behavior
- No False Confidence: Tests must fail when functionality doesn't work
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature - Make your changes
- Run the full check:
npm run check - Commit your changes:
git commit -m 'Add some feature' - Push to the branch:
git push origin feature/my-feature - Submit a pull request
- Follow the existing code style and patterns
- Add tests for new functionality
- Update documentation as needed
- Ensure all checks pass:
npm run check - Write clear commit messages
- Keep pull requests focused and atomic
- Use TypeScript strict mode
- Prefer functions over classes unless classes are shorter
- Use explicit typing for parameters, infer return types
- Follow the established naming conventions
- Maintain file and function length limits
This project is licensed under the MIT License - see the LICENSE file for details.
Author: Amir Arad greenshade@gmail.com
Keywords: requirements, uml, parser, formal-language, diagram-generation