Files
SuperCharged-Claude-Code-Up…/dexto/packages/agent-management/scripts/fix-dist-aliases.mjs
admin b52318eeae feat: Add intelligent auto-router and enhanced integrations
- Add intelligent-router.sh hook for automatic agent routing
- Add AUTO-TRIGGER-SUMMARY.md documentation
- Add FINAL-INTEGRATION-SUMMARY.md documentation
- Complete Prometheus integration (6 commands + 4 tools)
- Complete Dexto integration (12 commands + 5 tools)
- Enhanced Ralph with access to all agents
- Fix /clawd command (removed disable-model-invocation)
- Update hooks.json to v5 with intelligent routing
- 291 total skills now available
- All 21 commands with automatic routing

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-28 00:27:56 +04:00

103 lines
3.0 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.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env node
/* eslint-env node */
import console from 'node:console';
import { existsSync, readFileSync, readdirSync, statSync, writeFileSync } from 'node:fs';
import { dirname, extname, join, relative, resolve } from 'node:path';
import process from 'node:process';
import { fileURLToPath } from 'node:url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const DIST_DIR = resolve(__dirname, '../dist');
const PROCESS_EXTENSIONS = new Set(['.js', '.cjs', '.mjs', '.ts', '.mts', '.cts']);
const IMPORT_PATTERN = /(['"])@agent-management\/([^'"]+)\1/g;
function collectFiles(root) {
const entries = readdirSync(root);
const files = [];
for (const entry of entries) {
const fullPath = join(root, entry);
const stats = statSync(fullPath);
if (stats.isDirectory()) {
files.push(...collectFiles(fullPath));
} else {
files.push(fullPath);
}
}
return files;
}
function resolveImport(fromFile, subpath) {
const fromExt = extname(fromFile);
const preferredExt = fromExt === '.cjs' ? '.cjs' : '.js';
const candidateBase = subpath.replace(/\.(mjs|cjs|js)$/, '');
const bases = [candidateBase];
if (!candidateBase.endsWith('index')) {
bases.push(join(candidateBase, 'index'));
}
const candidates = [];
for (const base of bases) {
const exts = Array.from(new Set([preferredExt, '.mjs', '.js', '.cjs']));
for (const ext of exts) {
candidates.push(`${base}${ext}`);
}
}
for (const candidate of candidates) {
const absolute = resolve(DIST_DIR, candidate);
if (existsSync(absolute)) {
let relativePath = relative(dirname(fromFile), absolute).replace(/\\/g, '/');
if (!relativePath.startsWith('.')) {
relativePath = `./${relativePath}`;
}
return relativePath;
}
}
return null;
}
function rewriteAliases(filePath) {
const ext = extname(filePath);
if (!PROCESS_EXTENSIONS.has(ext)) {
return false;
}
const original = readFileSync(filePath, 'utf8');
let modified = false;
const updated = original.replace(IMPORT_PATTERN, (match, quote, requested) => {
const resolved = resolveImport(filePath, requested);
if (!resolved) {
console.warn(`⚠️ Unable to resolve alias @agent-management/${requested} in ${filePath}`);
return match;
}
modified = true;
return `${quote}${resolved}${quote}`;
});
if (modified) {
writeFileSync(filePath, updated, 'utf8');
}
return modified;
}
function main() {
if (!existsSync(DIST_DIR)) {
console.error(`❌ dist directory not found at ${DIST_DIR}`);
process.exit(1);
}
const files = collectFiles(DIST_DIR);
let changed = 0;
for (const file of files) {
if (rewriteAliases(file)) {
changed += 1;
}
}
console.log(` Fixed alias imports in ${changed} files.`);
}
main();