#!/usr/bin/env node
/**
* Test script to verify ACF npm installation
*/
const { spawn } = require('child_process');
const fs = require('fs');
const path = require('path');
console.log('=== ACF NPM Installation Test ===\n');
// Test 1: Check if binary is available
console.log('Test 1: Checking if agentic-control-framework binary is available...');
try {
const which = spawn('which', ['agentic-control-framework'], { shell: true });
which.on('close', (code) => {
if (code === 0) {
console.log('✅ Binary found in PATH');
} else {
console.log('❌ Binary not found in PATH');
}
});
} catch (e) {
console.log('❌ Error checking binary:', e.message);
}
// Test 2: Test MCP initialization without sharp
console.log('\nTest 2: Testing MCP server initialization (without sharp)...');
// Create a minimal test by directly requiring the core module
try {
const corePath = path.resolve(__dirname, 'src/core.js');
if (fs.existsSync(corePath)) {
console.log('✅ Core module found at:', corePath);
// Test basic functionality
const core = require(corePath);
if (typeof core.initTaskManager === 'function') {
console.log('✅ Core module loaded successfully');
console.log(' Available functions:', Object.keys(core).slice(0, 5).join(', '), '...');
}
} else {
console.log('❌ Core module not found');
}
} catch (e) {
console.log('❌ Error loading core module:', e.message);
}
// Test 3: Check package.json bin mappings
console.log('\nTest 3: Checking package.json bin mappings...');
try {
const pkg = require('./package.json');
console.log('Binary mappings:');
for (const [name, path] of Object.entries(pkg.bin)) {
const exists = fs.existsSync(path.replace('./', __dirname + '/'));
console.log(` ${exists ? '✅' : '❌'} ${name} -> ${path}`);
}
} catch (e) {
console.log('❌ Error reading package.json:', e.message);
}
// Test 4: Test simple MCP message without requiring sharp
console.log('\nTest 4: Testing simple MCP functionality...');
const testMessage = {
jsonrpc: '2.0',
id: 1,
method: 'initialize',
params: {
protocolVersion: '2025-03-26',
capabilities: {}
}
};
console.log('Input:', JSON.stringify(testMessage, null, 2));
console.log('\n(Note: Full MCP server test requires addressing the sharp dependency issue)');
console.log('\n=== Test Summary ===');
console.log('The ACF package structure is correct.');
console.log('The sharp dependency issue needs to be addressed for full functionality.');
console.log('Consider making sharp an optional dependency or removing screenshot features.');