can-algorithm
Version:
Cortex Algorithm Numeral - Intelligent development automation tool
108 lines (92 loc) • 3.33 kB
JavaScript
import { Command } from 'commander';
import chalk from 'chalk';
import ora from 'ora';
import { fileURLToPath } from 'url';
import { dirname } from 'path';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const program = new Command();
async function init() {
const { checkProtection, verifyLicense } = await import('./core/can-core.js');
const protection = await checkProtection();
if (!protection.valid) {
console.error(chalk.red('System protection compromised. Restoring...'));
const { restore } = await import('./core/protection.js');
await restore();
process.exit(1);
}
const license = await verifyLicense();
if (!license.valid) {
console.error(chalk.red('Invalid or missing license. Visit https://imators.systems/can/key'));
process.exit(1);
}
console.log(chalk.cyan(`Can Algorithm v1.2.5 - Licensed to: ${license.user}`));
}
program
.name('can')
.description('Cortex Algorithm Numeral - Intelligent automation')
.version('1.2.5');
program
.command('genconfig')
.description('Generate configuration file')
.action(async () => {
const { generateConfig } = await import('./core/config-manager.js');
await generateConfig();
});
program
.command('scan')
.description('Scan project structure')
.action(async () => {
await init();
const spinner = ora('Scanning project structure...').start();
const { scanProject } = await import('./core/can-core.js');
const results = await scanProject();
spinner.succeed('Scan complete');
console.log(results);
});
program
.command('ask <request>')
.description('Make a request to Can')
.action(async (request) => {
await init();
const spinner = ora('Processing request...').start();
const { processAsk } = await import('./core/can-core.js');
const result = await processAsk(request);
spinner.succeed();
console.log(chalk.green(result));
});
program
.command('proj <request>')
.description('Large-scale project implementation')
.action(async (request) => {
await init();
console.log(chalk.yellow('Project mode activated. This may take 2-6 hours.'));
const { processProject } = await import('./core/can-core.js');
await processProject(request);
});
program
.command('crypt <file>')
.description('Encrypt or compile file')
.action(async (file) => {
await init();
const { cryptFile } = await import('./core/can-core.js');
await cryptFile(file);
});
program
.command('custom <id>')
.description('Execute custom command')
.action(async (id) => {
await init();
const { executeCustom } = await import('./core/can-core.js');
await executeCustom(id);
});
program
.command('status')
.description('Check Can status and running tasks')
.action(async () => {
const { getStatus } = await import('./core/can-core.js');
const status = await getStatus();
console.log(status);
});
program.parse(process.argv);