AeThex-OS/aethex-lang/aethex.js
MrPiglr a15b5b1015 feat: integrate AeThex Language across entire OS ecosystem
Major Features:
- Custom .aethex programming language with cross-platform compilation
- Compiles to JavaScript, Lua (Roblox), Verse (UEFN), and C# (Unity)
- Built-in COPPA compliance and PII detection for safe metaverse development

Integration Points:
1. Terminal Integration
   - Added 'aethex' command for in-terminal compilation
   - Support for all compilation targets with --target flag
   - Real-time error reporting and syntax highlighting

2. IDE Integration
   - Native .aethex file support in Monaco editor
   - One-click compilation with target selector
   - Download compiled code functionality
   - Two example files: hello.aethex and auth.aethex

3. Curriculum Integration
   - New "AeThex Language" section in Foundry tech tree
   - Three modules: Realities & Journeys, Cross-Platform Sync, COPPA Compliance
   - Certification path for students

4. Documentation Site
   - Complete docs at /docs route (client/src/pages/aethex-docs.tsx)
   - Searchable documentation with sidebar navigation
   - Language guide, standard library reference, and examples
   - Ready for deployment to aethex.dev

5. npm Package Publishing
   - @aethex.os/core@1.0.0 - Standard library (published)
   - @aethex.os/cli@1.0.1 - Command line compiler (published)
   - Both packages live on npm and globally installable

Domain Configuration:
- DNS setup for 29+ domains (aethex.app, aethex.co, etc.)
- nginx reverse proxy configuration
- CORS configuration for cross-domain requests
- OAuth redirect fixes for hash-based routing

Standard Library Features:
- Passport: Universal identity across platforms
- DataSync: Cross-platform data synchronization
- SafeInput: PII detection (phone, email, SSN, credit cards)
- Compliance: COPPA/FERPA age gates and audit logging

Documentation Package:
- Created aethex-dev-docs.zip with complete documentation
- Ready for static site deployment
- Includes examples, API reference, and quickstart guide

Technical Improvements:
- Fixed OAuth blank page issue (hash routing)
- Added .gitignore rules for temp files
- Cleaned up build artifacts and temporary files
- Updated all package references to @aethex.os namespace

Co-Authored-By: Claude <noreply@anthropic.com>
2026-02-11 22:28:05 -07:00

248 lines
5.9 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env node
const { program } = require('commander');
const fs = require('fs');
const path = require('path');
const AeThexCompiler = require('./aethex-compiler');
const chalk = require('chalk');
program
.name('aethex')
.description('AeThex Language CLI - Write once, deploy everywhere')
.version('1.0.0');
// Compile command
program
.command('compile <file>')
.description('Compile an AeThex file')
.option('-t, --target <platform>', 'Target platform: javascript, roblox, uefn, unity', 'javascript')
.option('-o, --output <file>', 'Output file path')
.option('-w, --watch', 'Watch for file changes')
.action((file, options) => {
compileFile(file, options);
if (options.watch) {
console.log(chalk.blue('👀 Watching for changes...'));
fs.watchFile(file, () => {
console.log(chalk.yellow('\n🔄 File changed, recompiling...'));
compileFile(file, options);
});
}
});
// New project command
program
.command('new <name>')
.description('Create a new AeThex project')
.option('-t, --template <type>', 'Project template: basic, passport, game', 'basic')
.action((name, options) => {
createProject(name, options.template);
});
// Init command
program
.command('init')
.description('Initialize AeThex in current directory')
.action(() => {
initProject();
});
program.parse();
// Helper functions
function compileFile(file, options) {
if (!fs.existsSync(file)) {
console.error(chalk.red(`❌ File not found: ${file}`));
process.exit(1);
}
const sourceCode = fs.readFileSync(file, 'utf-8');
const compiler = new AeThexCompiler({
target: options.target,
sourceFile: file
});
console.log(chalk.blue(`🔨 Compiling ${path.basename(file)} to ${options.target}...`));
const result = compiler.compile(sourceCode);
// Show errors/warnings
if (result.errors.length > 0) {
console.log(chalk.red('\n❌ Compilation failed:\n'));
result.errors.forEach(err => {
console.log(chalk.red(` ${err.file}:${err.line} - ${err.message}`));
});
process.exit(1);
}
if (result.warnings.length > 0) {
console.log(chalk.yellow('\n⚠ Warnings:\n'));
result.warnings.forEach(warn => {
console.log(chalk.yellow(` ${warn.file}:${warn.line} - ${warn.message}`));
});
}
if (result.success) {
// Determine output file
let outputFile = options.output;
if (!outputFile) {
const ext = {
'javascript': '.js',
'roblox': '.lua',
'uefn': '.verse',
'unity': '.cs'
}[options.target] || '.js';
outputFile = file.replace('.aethex', ext);
}
fs.writeFileSync(outputFile, result.code);
console.log(chalk.green(`\n✅ Compiled successfully to: ${outputFile}`));
}
}
function createProject(name, template) {
const projectDir = path.join(process.cwd(), name);
if (fs.existsSync(projectDir)) {
console.error(chalk.red(`❌ Directory ${name} already exists`));
process.exit(1);
}
console.log(chalk.blue(`📦 Creating new AeThex project: ${name}`));
fs.mkdirSync(projectDir);
fs.mkdirSync(path.join(projectDir, 'src'));
fs.mkdirSync(path.join(projectDir, 'build'));
// Create package.json
const packageJson = {
name: name,
version: '1.0.0',
description: 'An AeThex project',
main: 'src/main.aethex',
scripts: {
build: 'aethex compile src/main.aethex -o build/main.js',
'build:roblox': 'aethex compile src/main.aethex -t roblox -o build/main.lua',
watch: 'aethex compile src/main.aethex -w'
},
dependencies: {
'@aethex/core': '^1.0.0'
}
};
fs.writeFileSync(
path.join(projectDir, 'package.json'),
JSON.stringify(packageJson, null, 2)
);
// Create main.aethex based on template
let mainCode = '';
if (template === 'passport') {
mainCode = `# AeThex Passport Example
import { Passport } from "@aethex/core"
reality ${name} {
platforms: [roblox, web]
}
journey AuthenticateUser(username) {
platform: all
let passport = new Passport(username)
when passport.verify() {
sync passport across [roblox, web]
notify "Welcome, " + username + "!"
reveal passport
}
}
`;
} else {
mainCode = `# ${name}
# Created with AeThex CLI
reality ${name} {
platforms: all
}
journey Start() {
platform: all
notify "Hello from AeThex!"
}
`;
}
fs.writeFileSync(path.join(projectDir, 'src', 'main.aethex'), mainCode);
// Create README
const readme = `# ${name}
An AeThex project created with \`aethex new\`.
## Getting Started
\`\`\`bash
# Install dependencies
npm install
# Build (JavaScript)
npm run build
# Build (Roblox/Lua)
npm run build:roblox
# Watch mode
npm run watch
\`\`\`
## Project Structure
- \`src/\` - AeThex source files (.aethex)
- \`build/\` - Compiled output
## Learn More
- [AeThex Docs](https://aethex.dev/lang)
- [Examples](https://github.com/aethex/aethex-lang/tree/main/examples)
`;
fs.writeFileSync(path.join(projectDir, 'README.md'), readme);
console.log(chalk.green(`\n✅ Project created successfully!`));
console.log(chalk.blue(`\nNext steps:`));
console.log(chalk.white(` cd ${name}`));
console.log(chalk.white(` npm install`));
console.log(chalk.white(` npm run build`));
}
function initProject() {
const cwd = process.cwd();
console.log(chalk.blue('📦 Initializing AeThex project...'));
// Create directories if they don't exist
if (!fs.existsSync('src')) {
fs.mkdirSync('src');
}
if (!fs.existsSync('build')) {
fs.mkdirSync('build');
}
// Create aethex.config.json
const config = {
targets: ['javascript', 'roblox'],
srcDir: 'src',
outDir: 'build',
stdlib: true
};
fs.writeFileSync('aethex.config.json', JSON.stringify(config, null, 2));
console.log(chalk.green('✅ AeThex initialized!'));
console.log(chalk.blue('\nCreated:'));
console.log(chalk.white(' aethex.config.json'));
console.log(chalk.white(' src/'));
console.log(chalk.white(' build/'));
}