Skip to content

Instantly share code, notes, and snippets.

@spinualexandru
Created September 22, 2025 18:36
Show Gist options
  • Save spinualexandru/212a25e357081cc11d3b07b56bf038af to your computer and use it in GitHub Desktop.
Save spinualexandru/212a25e357081cc11d3b07b56bf038af to your computer and use it in GitHub Desktop.
Example
import si from 'systeminformation';
import os from 'os';
// =============================================================================
// Interfaces & Data Schema
// =============================================================================
// Matches the system capabilities interface from your proposal.
interface SystemCapabilities {
cpu: {
cores: number;
architecture: string;
speed: number;
};
memory: {
totalGB: number;
availableGB: number;
};
gpu: {
available: boolean;
type: 'nvidia' | 'amd' | 'apple' | 'intel' | 'none';
model: string;
memoryGB?: number;
};
platform: NodeJS.Platform;
}
// Matches the model entry schema from your proposal.
interface ModelEntry {
name: string;
provider: string;
size: string; // "7B", "13B", "70B"
type: "local" | "api";
requirements: {
minMemoryGB: number;
recommendedMemoryGB: number;
minCpuCores: number;
gpuRequired: boolean;
gpuMemoryGB?: number;
};
capabilities: {
codingQuality: 1 | 2 | 3 | 4 | 5;
agenticTasks: 1 | 2 | 3 | 4 | 5;
contextHandling: 1 | 2 | 3 | 4 | 5;
longFormCoding: 1 | 2 | 3 | 4 | 5;
toolUsage: 1 | 2 | 3 | 4 | 5;
};
useCases: {
quickQuestions: boolean;
simpleEdits: boolean;
complexRefactoring: boolean;
multiFileProjects: boolean;
longWorkflows: boolean;
};
limitations: string[];
cost: {
type: "free" | "pay-per-use" | "subscription";
details: string;
estimatedDaily?: string;
};
}
// A curated database of models.
const MODEL_DATABASE: ModelEntry[] = [
// Local Models (Ollama)
{
name: "llama3.1:8b",
provider: "ollama",
size: "8B",
type: "local",
requirements: {
minMemoryGB: 8,
recommendedMemoryGB: 16,
minCpuCores: 4,
gpuRequired: false,
gpuMemoryGB: 6
},
capabilities: {
codingQuality: 4, agenticTasks: 2, contextHandling: 4, longFormCoding: 3, toolUsage: 3
},
useCases: {
quickQuestions: true, simpleEdits: true, complexRefactoring: true, multiFileProjects: false, longWorkflows: false
},
limitations: ["May lose context in long conversations", "Limited planning abilities for multi-step tasks"],
cost: { type: "free", details: "Local inference only" }
},
{
name: "qwen2.5-coder:32b",
provider: "ollama",
size: "32B",
type: "local",
requirements: {
minMemoryGB: 24,
recommendedMemoryGB: 32,
minCpuCores: 8,
gpuRequired: true, // Needs a powerful GPU
gpuMemoryGB: 20
},
capabilities: {
codingQuality: 5, agenticTasks: 4, contextHandling: 5, longFormCoding: 5, toolUsage: 4
},
useCases: {
quickQuestions: true, simpleEdits: true, complexRefactoring: true, multiFileProjects: true, longWorkflows: true
},
limitations: ["Requires significant RAM", "Slower inference on CPU-only systems"],
cost: { type: "free", details: "Local inference only" }
},
{
name: "phi3:3.8b-mini",
provider: "ollama",
size: "3.8B",
type: "local",
requirements: {
minMemoryGB: 4,
recommendedMemoryGB: 8,
minCpuCores: 2,
gpuRequired: false,
gpuMemoryGB: 4
},
capabilities: {
codingQuality: 3, agenticTasks: 1, contextHandling: 2, longFormCoding: 2, toolUsage: 1
},
useCases: {
quickQuestions: true, simpleEdits: false, complexRefactoring: false, multiFileProjects: false, longWorkflows: false
},
limitations: ["Not suitable for complex tasks"],
cost: { type: "free", details: "Local inference only" }
},
// API Models (OpenRouter/OpenAI)
{
name: "claude-3.5-sonnet",
provider: "anthropic",
size: "Unknown",
type: "api",
requirements: {
minMemoryGB: 1,
recommendedMemoryGB: 2,
minCpuCores: 1,
gpuRequired: false,
},
capabilities: {
codingQuality: 5, agenticTasks: 5, contextHandling: 5, longFormCoding: 5, toolUsage: 5
},
useCases: {
quickQuestions: true, simpleEdits: true, complexRefactoring: true, multiFileProjects: true, longWorkflows: true
},
limitations: ["Requires internet connection", "Usage costs apply"],
cost: {
type: "pay-per-use",
details: "$3/1M input tokens, $15/1M output tokens",
estimatedDaily: "$0.50-5.00 for typical coding sessions"
}
},
{
name: "deepseek-coder-v2.5",
provider: "openrouter",
size: "236B",
type: "api",
requirements: {
minMemoryGB: 1,
recommendedMemoryGB: 2,
minCpuCores: 1,
gpuRequired: false,
},
capabilities: {
codingQuality: 5, agenticTasks: 4, contextHandling: 5, longFormCoding: 5, toolUsage: 4
},
useCases: {
quickQuestions: true, simpleEdits: true, complexRefactoring: true, multiFileProjects: true, longWorkflows: true
},
limitations: ["Requires internet connection"],
cost: {
type: "pay-per-use",
details: "$0.14/1M input tokens, $0.28/1M output tokens",
estimatedDaily: "$0.10-1.00 for typical coding sessions"
}
},
];
// =============================================================================
// Logic to get system info, score models, and print recommendations
// =============================================================================
const getRecommendations = async () => {
try {
// 1. System Detection using systeminformation
const osInfo = await si.osInfo();
const cpuInfo = await si.cpu();
const memInfo = await si.mem();
const graphicsInfo = await si.graphics();
const system: SystemCapabilities = {
cpu: {
cores: cpuInfo.cores,
architecture: cpuInfo.arch,
speed: cpuInfo.speed
},
memory: {
totalGB: Math.round(memInfo.total / 1024 / 1024 / 1024),
availableGB: Math.round(memInfo.free / 1024 / 1024 / 1024),
},
gpu: {
available: graphicsInfo.controllers.length > 0,
type: 'none', // Placeholder, systeminformation doesn't easily provide vendor type
model: graphicsInfo.controllers.length > 0 ? graphicsInfo.controllers[0].model : 'N/A',
memoryGB: graphicsInfo.controllers.length > 0 ? Math.round(graphicsInfo.controllers[0].vram / 1024) : 0
},
platform: osInfo.platform,
};
// Attempt to determine GPU type based on model name
if (system.gpu.model.toLowerCase().includes('nvidia')) {
system.gpu.type = 'nvidia';
} else if (system.gpu.model.toLowerCase().includes('amd')) {
system.gpu.type = 'amd';
} else if (system.gpu.model.toLowerCase().includes('apple')) {
system.gpu.type = 'apple';
}
// 2. Model Scoring and Filtering Logic
const recommendations = MODEL_DATABASE.map(model => {
let score = 0;
let compatibility: 'perfect' | 'good' | 'marginal' | 'incompatible' = 'incompatible';
const warnings: string[] = [];
// Check basic compatibility
const hasEnoughMemory = system.memory.totalGB >= model.requirements.minMemoryGB;
const hasEnoughCores = system.cpu.cores >= model.requirements.minCpuCores;
const hasRequiredGpu = !model.requirements.gpuRequired || (system.gpu.available && system.gpu.type === 'nvidia' && system.gpu.memoryGB && system.gpu.memoryGB >= model.requirements.gpuMemoryGB!);
if (hasEnoughMemory && hasEnoughCores && hasRequiredGpu) {
// Model is compatible, now score it
score += 100; // Base score for compatibility
if (model.type === 'local') {
score += 50; // Bonus for local/privacy-first
if (system.memory.totalGB >= model.requirements.recommendedMemoryGB) {
score += 20; // Bonus for meeting recommended memory
}
}
// Add scores based on capability ratings
score += model.capabilities.codingQuality * 5;
score += model.capabilities.agenticTasks * 5;
score += model.capabilities.longFormCoding * 5;
// Determine compatibility status
if (hasEnoughMemory && system.memory.totalGB >= model.requirements.recommendedMemoryGB) {
compatibility = 'perfect';
} else if (hasEnoughMemory) {
compatibility = 'good';
}
// Add warnings for marginal models
if (compatibility === 'good') {
warnings.push(`Model may perform better with more memory. Recommended: ${model.requirements.recommendedMemoryGB} GB`);
}
}
// Add a warning if a powerful local model is incompatible due to system limitations
if (!hasEnoughMemory) {
warnings.push(`Incompatible: Requires a minimum of ${model.requirements.minMemoryGB} GB RAM. Your system has ${system.memory.totalGB} GB.`);
}
if (model.requirements.gpuRequired && !hasRequiredGpu) {
warnings.push(`Incompatible: Requires an NVIDIA GPU with at least ${model.requirements.gpuMemoryGB} GB VRAM.`);
}
return { model, score, compatibility, warnings };
})
.sort((a, b) => b.score - a.score);
// 3. Print the formatted output
console.log(`\nSystem detected:`);
console.log(`- CPU: ${system.cpu.cores} cores @ ${system.cpu.speed}MHz`);
console.log(`- Memory: ${system.memory.totalGB}GB RAM`);
console.log(`- GPU: ${system.gpu.model} (${system.gpu.memoryGB}GB VRAM)`);
console.log(`- OS: ${system.platform}`);
console.log(`\nπŸš€ RECOMMENDED FOR YOUR SYSTEM:`);
const bestRecommendation = recommendations.find(rec => rec.compatibility === 'perfect' || rec.compatibility === 'good');
if (bestRecommendation) {
const model = bestRecommendation.model;
const compatibilityIcon = bestRecommendation.compatibility === 'perfect' ? 'βœ…' : 'πŸ‘';
console.log(`${compatibilityIcon} ${model.name} (${model.type}, ${model.cost.type}) - ${model.size} | Recommended for: ${model.useCases.complexRefactoring ? 'complex refactoring' : 'general tasks'}`);
console.log(` - Good for: ${model.capabilities.codingQuality}/5 coding quality, ${model.capabilities.agenticTasks}/5 agentic tasks`);
} else {
console.log(`No highly compatible models found. See other options below.`);
}
console.log(`\nπŸ“‹ OTHER OPTIONS:`);
recommendations.forEach(rec => {
let prefix = '';
switch (rec.compatibility) {
case 'perfect': prefix = 'βœ…'; break;
case 'good': prefix = 'πŸ‘'; break;
case 'marginal': prefix = '⚠️'; break;
case 'incompatible': prefix = '❌'; break;
}
const model = rec.model;
const line = `${prefix} ${model.name} (${model.type}, ${model.cost.type}) - ${model.size}`;
console.log(line);
if (rec.warnings.length > 0) {
rec.warnings.forEach(warning => console.log(` - Warning: ${warning}`));
}
});
console.log(`\nπŸ’‘ RECOMMENDATIONS:`);
console.log(`β€’ For best results with your GPU, consider the local model recommended above.`);
console.log(`β€’ For advanced capabilities, try the API-based options. They handle long, complex workflows very well.`);
} catch (e) {
console.error(`An error occurred while getting system information:`, e);
}
};
getRecommendations();
@spinualexandru
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment