interactive.jsā¢6.1 kB
#!/usr/bin/env node
import { spawn } from 'child_process';
import readline from 'readline';
import path from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
console.log('š Organizational Data Manager');
console.log('===============================');
console.log('This is your interactive data management system!');
console.log('You can perform CRUD operations on your organizational data using natural language.');
console.log('');
console.log('Available datasets:');
console.log('š employees, companies, departments, domains, projects, customers');
console.log('š assets, policies, roles, accesslogs, training, performance');
console.log('š tickets, vendors, locations, and many more...');
console.log('');
console.log('Example commands:');
console.log('⢠"Show me all employees"');
console.log('⢠"Add a new customer with name John Doe"');
console.log('⢠"Update project status to completed"');
console.log('⢠"Find all vendors in California"');
console.log('⢠"Delete old access logs"');
console.log('');
console.log('Type "help" for more commands or "exit" to quit.');
console.log('===============================');
function ask(question) {
return new Promise((resolve) => {
rl.question(question, resolve);
});
}
async function processCommand(command) {
const lowerCommand = command.toLowerCase().trim();
if (lowerCommand === 'exit') {
console.log('š Goodbye!');
rl.close();
process.exit(0);
}
if (lowerCommand === 'help') {
console.log('\nš Available Commands:');
console.log('');
console.log('š DATA QUERIES:');
console.log(' ⢠"show employees" - List all employees');
console.log(' ⢠"show projects" - List all projects');
console.log(' ⢠"show companies" - List all companies');
console.log(' ⢠"count employees" - Count total employees');
console.log('');
console.log('š SEARCH & FILTER:');
console.log(' ⢠"find employees at Google" - Filter employees by company');
console.log(' ⢠"search projects containing web" - Search in project names');
console.log(' ⢠"filter vendors by location California" - Filter by location');
console.log('');
console.log('ā ADD DATA:');
console.log(' ⢠"add employee John Doe, Engineering, Senior Developer"');
console.log(' ⢠"add project Website Redesign, Active, High Priority"');
console.log('');
console.log('āļø UPDATE DATA:');
console.log(' ⢠"update employee id 123 salary to 75000"');
console.log(' ⢠"update project status to completed"');
console.log('');
console.log('šļø DELETE DATA:');
console.log(' ⢠"delete employee id 456"');
console.log(' ⢠"delete old access logs"');
console.log('');
console.log('š ANALYTICS:');
console.log(' ⢠"analyze employee performance"');
console.log(' ⢠"summary of projects by status"');
console.log(' ⢠"department statistics"');
console.log('');
return;
}
// For now, we'll show available data files and basic operations
if (lowerCommand.includes('show') && lowerCommand.includes('datasets')) {
console.log('\nš Available Datasets:');
console.log('');
console.log('š„ People & Organizations:');
console.log(' ⢠employees.json - Employee records and details');
console.log(' ⢠companies.json - Company information');
console.log(' ⢠departments.json - Department structure');
console.log(' ⢠teams.json - Team compositions');
console.log('');
console.log('š¼ Projects & Work:');
console.log(' ⢠projects.json - Project tracking');
console.log(' ⢠project_assignments.json - Project assignments');
console.log(' ⢠project_management.json - Project management data');
console.log('');
console.log('š¢ Assets & Resources:');
console.log(' ⢠assets.json - Company assets');
console.log(' ⢠office_spaces.json - Office space information');
console.log(' ⢠vendors.json - Vendor relationships');
console.log('');
console.log('š Performance & Analytics:');
console.log(' ⢠performance.json - Performance metrics');
console.log(' ⢠feedback.json - Feedback data');
console.log(' ⢠training.json - Training records');
console.log('');
console.log('š« Operations:');
console.log(' ⢠tickets.json - Support tickets');
console.log(' ⢠accesslogs.json - Access logs');
console.log(' ⢠policies.json - Company policies');
console.log('');
return;
}
console.log(`\nš¤ Processing: "${command}"`);
console.log('š” Connecting to MCP server...');
// Here we would connect to the MCP server and process the command
// For now, we'll simulate the response
if (lowerCommand.includes('show') || lowerCommand.includes('list')) {
console.log('ā
Query executed successfully!');
console.log('š Sample results would appear here...');
} else if (lowerCommand.includes('add') || lowerCommand.includes('create')) {
console.log('ā
Record added successfully!');
} else if (lowerCommand.includes('update') || lowerCommand.includes('modify')) {
console.log('ā
Record updated successfully!');
} else if (lowerCommand.includes('delete') || lowerCommand.includes('remove')) {
console.log('ā
Record deleted successfully!');
} else {
console.log('š Understanding your request...');
console.log('š” Tip: Try commands like "show employees", "add customer", or "help" for more options.');
}
}
async function main() {
while (true) {
try {
const command = await ask('\nš¬ Enter your command: ');
if (command.trim() === '') {
continue;
}
await processCommand(command);
} catch (error) {
console.error('ā Error:', error.message);
}
}
}
main().catch(console.error);