aiwg
Version:
Cognitive architecture for AI-augmented software development with structured memory, ensemble validation, and closed-loop correction. FAIR-aligned artifacts, 84% cost reduction via human-in-the-loop, standards adopted by 100+ organizations.
69 lines (58 loc) • 2.08 kB
JavaScript
/**
* AIWG CLI Entry Point
*
* This is the main entry point for the aiwg CLI when installed via npm.
* It handles:
* - Channel detection (stable vs edge mode)
* - Background update checking
* - Command routing to appropriate handlers (via facade)
*
* The facade allows switching between legacy and new routers via:
* - AIWG_USE_NEW_ROUTER environment variable
* - --experimental-router or --legacy-router CLI flags
*
* @module bin/aiwg
* @version 2026.1.7
* @implements @.aiwg/requirements/use-cases/UC-004-extension-system.md
* @source @src/cli/facade.mjs
*/
import { fileURLToPath } from 'url';
import path from 'path';
import { run } from '../src/cli/facade.mjs';
import { checkForUpdates } from '../src/update/checker.mjs';
import { getChannel, getPackageRoot } from '../src/channel/manager.mjs';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
// Get the package root (where package.json lives)
const packageRoot = path.resolve(__dirname, '..');
async function main() {
const args = process.argv.slice(2);
// Handle special channel switching commands first
if (args[0] === '--use-main' || args[0] === '--use-edge') {
const { switchToEdge } = await import('../src/channel/manager.mjs');
await switchToEdge();
return;
}
if (args[0] === '--use-stable' || args[0] === '--use-npm') {
const { switchToStable } = await import('../src/channel/manager.mjs');
await switchToStable();
return;
}
// Non-blocking update check (runs in background)
checkForUpdates().catch(() => {
// Silently ignore update check failures
});
// Run the CLI via facade (supports both legacy and new routers)
// The facade will determine which router to use based on:
// - AIWG_USE_NEW_ROUTER environment variable
// - --experimental-router or --legacy-router flags
await run(args, { cwd: process.cwd() });
}
main().catch((error) => {
console.error('Error:', error.message);
if (process.env.DEBUG) {
console.error(error.stack);
}
process.exit(1);
});