š SPECTRAL INSTALLATION & SETUP GUIDE
Quick Start - 3 Steps to Spectral
Step 1: Language Tools (Already Ready!)
The Spectral language tools are already integrated into the Ouro project:
# Navigate to project
cd /Users/arturczemiel/projects/aexol/ouro
# The language is ready to use:
# - Lexer: src/spectral/lexer.ts
# - Parser: src/spectral/parser.ts
# - Validator: src/spectral/validator.ts
# - CodeGen: src/spectral/codegen.ts
Step 2: Set Up VS Code Extension
# Navigate to extension
cd /Users/arturczemiel/projects/aexol/ouro/vscode-extension
# Install dependencies
npm install
# Compile TypeScript
npm run compile
Step 3: Test in VS Code
# In VS Code, open the extension folder
# Press F5 to launch extension host
# Create a test.spectral file and start coding!
ā Installation Verification
Check Language Tools
# Verify all modules exist
ls -la /Users/arturczemiel/projects/aexol/ouro/src/spectral/
# You should see:
# ā
lexer.ts
# ā
tokenizer.ts
# ā
parser.ts
# ā
validator.ts
# ā
codegen.ts
# ā
utils.ts
# ā
index.ts
# ā
README.md
# ā
examples/
Check VS Code Extension
# Verify extension files
ls -la /Users/arturczemiel/projects/aexol/ouro/vscode-extension/
# You should see:
# ā
package.json
# ā
tsconfig.json
# ā
language-configuration.json
# ā
README.md
# ā
DEVELOPMENT.md
# ā
src/
# ā
syntaxes/
Verify npm Installation
cd /Users/arturczemiel/projects/aexol/ouro/vscode-extension
# Check package.json
npm list
# You should see:
# [email protected]
šÆ Using the Language
Via CLI
cd /Users/arturczemiel/projects/aexol/ouro
# Parse a file
deno run -A src/main.ts parse --input examples/sample.spectral
# Validate
deno run -A src/main.ts validate --input examples/sample.spectral
# Generate code
deno run -A src/main.ts generate --input examples/sample.spectral --language typescript
# Analyze
deno run -A src/main.ts analyze --input examples/sample.spectral
Via Deno TypeScript
import { Parser, Validator } from "./src/spectral/index.ts";
// Create a parser
const parser = new Parser(spectralCode);
const ast = parser.parse();
// Validate
const validator = new Validator(ast);
const result = validator.validate();
// Check results
console.log(result.isValid);
console.log(result.errors);
In VS Code
-
Install Extension:
- Open vscode-extension folder in VS Code
- Run:
npm install && npm run compile - Press F5 to launch test instance
-
Create
.spectralFile:visitor UserCapabilities can read can list can view -
Features Work Automatically:
- ā Syntax highlighting
- ā Error checking
- ā Code completion (Ctrl+Space)
- ā Hover info
š¦ What's Included
Language Implementation (2,390+ lines)
src/spectral/
āāā lexer.ts # 550+ lines - Tokenization
āāā tokenizer.ts # 230+ lines - Token stream
āāā parser.ts # 750+ lines - AST building
āāā validator.ts # 200+ lines - Semantic analysis
āāā codegen.ts # 350+ lines - Code generation
āāā utils.ts # 310+ lines - Analysis tools
āāā index.ts # Exports
Capabilities:
- ā 50+ token types
- ā 14+ AST node types
- ā Full error recovery
- ā 5 language code generation
- ā Comprehensive analysis
VS Code Extension (1,837 lines)
vscode-extension/
āāā src/
ā āāā extension.ts # 100+ lines - Main extension
ā āāā language-provider.ts # 400+ lines - Language features
āāā syntaxes/
ā āāā spectral.tmLanguage.json # 150+ lines - Highlighting
āāā package.json # 90+ lines - Manifest
āāā tsconfig.json # 20+ lines - TypeScript config
āāā language-configuration.json # 25+ lines - Editor config
āāā README.md # 1,000+ lines - User guide
āāā DEVELOPMENT.md # 300+ lines - Dev guide
Features:
- ā Syntax highlighting
- ā Real-time error checking
- ā Code completion
- ā Hover information
- ā Symbol outline
- ā Commands and keybindings
Documentation (2,500+ lines)
docs/content/
āāā spectral.mdx # 700+ lines - Tutorial
āāā spectral-spec.mdx # 400+ lines - Specification
āāā spectral-quick-reference.mdx # 300+ lines - Reference
āāā spectral-index.mdx # Navigation
SPECTRAL_*.md files
āāā SPECTRAL_EXECUTIVE_SUMMARY.md
āāā SPECTRAL_COMPLETE_SOLUTION.md
āāā SPECTRAL_VSCODE_EXTENSION.md
āāā SPECTRAL_README.md
āāā SPECTRAL_IMPLEMENTATION.md
āāā SPECTRAL_COMPLETE.md
āāā SPECTRAL_DELIVERABLES.md
š Learning Resources
Start Here
-
Read:
docs/content/spectral.mdx- 700+ lines of tutorial and examples
- Covers all language features
- Best practices included
-
Try:
src/spectral/examples/todo.spectral- Simple exampleecommerce.spectral- Complex example (200+ lines)
-
Reference:
docs/content/spectral-quick-reference.mdx- Quick syntax guide
- Common patterns
- Command reference
For Developers
-
API:
src/spectral/README.md- Complete API documentation
- Function signatures
- Usage examples
-
Implementation:
src/spectral/parser.ts- Grammar specification
- AST types
- Parsing logic
-
Extension:
vscode-extension/DEVELOPMENT.md- Extension architecture
- Adding features
- Building and publishing
āļø Configuration
VS Code Settings
Create .vscode/settings.json in your workspace:
{
"spectral.enable": true,
"spectral.validateOnType": true,
"spectral.showDiagnostics": true,
"spectral.maxDiagnostics": 100
}
Language Configuration
Edit vscode-extension/language-configuration.json:
- Comments
- Bracket pairs
- Auto-closing pairs
- Word patterns
TextMate Grammar
Edit vscode-extension/syntaxes/spectral.tmLanguage.json:
- Add new keywords
- Adjust token scopes
- Customize highlighting
š§ Development Setup
For Language Development
cd /Users/arturczemiel/projects/aexol/ouro
# Check Deno installation
deno --version
# Run tests
deno test src/spectral/
# Generate documentation
deno run -A src/commands/docs.ts
For Extension Development
cd /Users/arturczemiel/projects/aexol/ouro/vscode-extension
# Install dependencies
npm install
# Watch TypeScript changes
npm run watch
# In VS Code, press F5 to debug
# Make changes and reload with Ctrl+R in extension host
For Documentation
# Read existing docs
cat docs/content/spectral.mdx
# Generate new docs
deno run -A src/commands/docs.ts --input src/spectral/examples/custom.spectral
šØ Troubleshooting
Extension Not Loading
Problem: .spectral files not recognized
Solution:
# Verify language registration
grep -n "spectral" vscode-extension/package.json
# Check file extension is .spectral
ls -la *.spectral
# Restart VS Code
No Syntax Highlighting
Problem: Code not colored
Solution:
# Verify grammar is loaded
cat vscode-extension/syntaxes/spectral.tmLanguage.json
# Rebuild extension
cd vscode-extension
npm run compile
Validation Not Working
Problem: No error messages
Solution:
// In settings.json, enable:
{
"spectral.validateOnType": true,
"spectral.showDiagnostics": true
}
Build Errors
Problem: TypeScript compilation fails
Solution:
# Clear and reinstall
rm -rf node_modules package-lock.json
npm install
# Update TypeScript
npm install -D typescript@latest
# Try compiling again
npm run compile
š System Requirements
For Language Tools
- Deno: 1.38+
- Node: 18+ (for TypeScript)
- OS: macOS, Linux, Windows
For VS Code Extension
- VS Code: 1.85+
- Node: 18+
- npm: 9+
- TypeScript: 5.3+
Disk Space
- Language tools: ~2 MB
- Extension (with dependencies): ~200 MB
- Total with docs: ~5 MB
šÆ Common Tasks
Create a New Spectral File
# Create file
touch myproject.spectral
# Edit with syntax highlighting in VS Code
code myproject.spectral
# Validate
deno run -A src/main.ts validate --input myproject.spectral
Parse and Analyze
# Parse file to see AST
deno run -A src/main.ts parse --input myproject.spectral
# Analyze structure
deno run -A src/main.ts analyze --input myproject.spectral
# Generate code
deno run -A src/main.ts generate --input myproject.spectral --language typescript
Generate Documentation
# From Spectral file
deno run -A src/main.ts docs --input myproject.spectral
# View generated docs
cat myproject.md
Integrate into Your Project
// In your Deno project
import { Parser, Validator } from "./src/spectral/index.ts";
const code = Deno.readTextFileSync("system.spectral");
const parser = new Parser(code);
const ast = parser.parse();
const validator = new Validator(ast);
const result = validator.validate();
š Next Steps
1. Try the Examples
# Look at todo example
cat src/spectral/examples/todo.spectral
# Look at e-commerce example
cat src/spectral/examples/ecommerce.spectral
2. Create Your First Spectral File
# Create and edit
code myagents.spectral
# In VS Code, type:
# visitor, role, workflow, agent, type
# Get full syntax highlighting and validation!
3. Integrate with Your Project
// Import the parser
import { Parser } from "./src/spectral/index.ts";
// Parse your Spectral files
const ast = new Parser(code).parse();
// Build on top of it!
4. Customize Extension
# Edit syntax
vim vscode-extension/syntaxes/spectral.tmLanguage.json
# Add completion items
vim vscode-extension/src/language-provider.ts
# Rebuild
npm run compile
ā Verification
Run this to verify everything is installed:
#!/bin/bash
echo "š Spectral Installation Check"
echo "================================"
# Check language tools
echo "ā
Language tools:"
ls -1 src/spectral/*.ts | wc -l | xargs echo " Files:"
# Check extension
echo "ā
Extension:"
ls -1 vscode-extension/src/*.ts | wc -l | xargs echo " Files:"
# Check documentation
echo "ā
Documentation:"
find . -name "SPECTRAL_*.md" | wc -l | xargs echo " Files:"
# Check examples
echo "ā
Examples:"
find src/spectral/examples -name "*.spectral" | wc -l | xargs echo " Files:"
echo ""
echo "š¢ Installation verified!"
š Getting Help
Documentation Resources
- Language Guide:
docs/content/spectral.mdx - Quick Reference:
docs/content/spectral-quick-reference.mdx - Specification:
docs/content/spectral-spec.mdx - Extension Guide:
vscode-extension/README.md - Developer Guide:
vscode-extension/DEVELOPMENT.md
Code Examples
- Simple:
src/spectral/examples/todo.spectral - Complex:
src/spectral/examples/ecommerce.spectral
API Reference
- Parser API:
src/spectral/README.md - CLI Usage:
src/commands/spectral.ts
When Something's Wrong
- Check relevant documentation
- Review examples
- Look at inline code comments
- Check troubleshooting section
š You're All Set!
ā
Language tools installed
ā
VS Code extension ready
ā
Documentation complete
ā
Examples available
ā
Ready to start!
Start Now!
# 1. Navigate to project
cd /Users/arturczemiel/projects/aexol/ouro
# 2. Create first Spectral file
echo 'visitor Test
can read
can list' > hello.spectral
# 3. Parse it
deno run -A src/main.ts parse --input hello.spectral
# 4. In VS Code
code vscode-extension/
npm install && npm run compile
# Press F5 to test!
š Welcome to Spectral!
For more information, see the documentation in the docs/ folder or README files.
Happy coding! š