Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org'

- name: Configure Git identity
Expand Down
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
node
24
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20
24
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
],
"author": "Sagar Jadhav <sagarjadhav063@gmail.com>",
"license": "MIT",
"engines": {
"node": ">=24"
},
"devDependencies": {
"@commitlint/cli": "^20.2.0",
"@commitlint/config-conventional": "^20.2.0",
Expand Down
12 changes: 5 additions & 7 deletions src/commands/advanced-session.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ import readline from 'readline';
import chalk from 'chalk';
import fs from 'fs';
import path from 'path';
import { executeSystemCommand, analyzeCommand, requireApproval, spawnAgent, ToolRegistry } from '../utils/advanced-executioner.js';
import { executeSystemCommand, analyzeCommand, spawnAgent, ToolRegistry } from '../utils/advanced-executioner.js';
import { AIService } from '../services/ai.service.js';
import NamespacedVectorMemory from '../services/namespaced-memory.js';
import { TaxonomySystem } from '../services/taxonomy.js';
import { ContextScrubber } from '../utils/context-scrubber.js';
import SessionContext from '../utils/session-context.js';
import { UniversalPredictor } from '../services/universal-predictor.js';
import process from 'process';
import os from 'os';

Expand All @@ -19,7 +18,7 @@ const memory = process.env.NEBULA_INSTANT_MODE === '1' ? null : new NamespacedVe
const taxonomy = new TaxonomySystem();

// CRITICAL: Global error handler
process.on('unhandledRejection', (reason, promise) => {
process.on('unhandledRejection', (reason, _promise) => {
console.error(chalk.red('⚠️ Unhandled promise:', reason));
});

Expand Down Expand Up @@ -82,10 +81,9 @@ const NEBULA_COMMANDS = {
efficiency: async () => {
const history = SessionContext.getHistory();
const { ProjectID } = await import('../utils/project-id.js');
const pid = await ProjectID.getOrCreateUID(SessionContext.getCwd());
await ProjectID.getOrCreateUID(SessionContext.getCwd());

const localHits = history.filter(h => h.includes('Instant Fix')).length;
const aiCalls = history.filter(h => h.includes('ask')).length;

console.log(chalk.bold.cyan('\n📊 Nebula Token Currency Audit'));
console.log(chalk.gray('=============================================='));
Expand Down Expand Up @@ -483,7 +481,7 @@ async function handleAutoHealingSafe(command, result) {
const helpOutput = await executeSystemCommand(`${cmdName} --help 2>&1 || man ${cmdName} | head -n 200`, {
cwd: SessionContext.getCwd(),
silent: true
}).catch(e => '');
}).catch(_e => '');

if (helpOutput) {
const fixPrompt = `
Expand Down Expand Up @@ -514,7 +512,7 @@ Output ONLY the corrected command string. No explanation.
return;
}
}
} catch (e) {
} catch (_e) {
// Fallback
}
}
Expand Down
14 changes: 6 additions & 8 deletions src/commands/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import NamespacedVectorMemory from '../services/namespaced-memory.js';
import { TaxonomySystem } from '../services/taxonomy.js';
import { ContextScrubber } from '../utils/context-scrubber.js';
import SessionContext from '../utils/session-context.js';
import { UniversalPredictor } from '../services/universal-predictor.js';
import process from 'process';
import os from 'os';

Expand All @@ -21,7 +20,7 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
taxonomy.loadCommunityPatterns(path.join(__dirname, '../../data/community-patterns.json'));

// CRITICAL: Global error handler
process.on('unhandledRejection', (reason, promise) => {
process.on('unhandledRejection', (reason, _promise) => {
console.error(chalk.red('⚠️ Unhandled promise:', reason));
});

Expand Down Expand Up @@ -80,11 +79,10 @@ const NEBULA_COMMANDS = {
efficiency: async () => {
const history = SessionContext.getHistory();
const { ProjectID } = await import('../utils/project-id.js');
const pid = await ProjectID.getOrCreateUID(SessionContext.getCwd());
await ProjectID.getOrCreateUID(SessionContext.getCwd());

// Mock calculations / Heuristics
const localHits = history.filter(h => h.includes('Instant Fix')).length; // Rough heuristic if we tracked it better
const aiCalls = history.filter(h => h.includes('ask')).length;

console.log(chalk.bold.cyan('\n📊 Nebula Token Currency Audit'));
console.log(chalk.gray('=============================================='));
Expand Down Expand Up @@ -271,7 +269,7 @@ async function processCommand(command) {
}
}

async function handleAutoHealingSafe(command, result, rl) {
async function handleAutoHealingSafe(command, result, _rl) {
try {
const errorMsg = result.stderr || 'Unknown error';

Expand Down Expand Up @@ -342,7 +340,7 @@ async function handleAutoHealingSafe(command, result, rl) {
const helpOutput = await executeSystemCommand(`${cmdName} --help 2>&1 || man ${cmdName} | head -n 200`, {
cwd: SessionContext.getCwd(),
silent: true
}).catch(e => ''); // Ignore help fetch errors
}).catch(_e => ''); // Ignore help fetch errors

if (helpOutput) {
const fixPrompt = `
Expand Down Expand Up @@ -373,7 +371,7 @@ Output ONLY the corrected command string. No explanation.
return; // Handled
}
}
} catch (e) {
} catch (_e) {
// Fallback to normal healing if help fetch fails
}
}
Expand All @@ -383,7 +381,7 @@ Output ONLY the corrected command string. No explanation.
try {
// Check if yq exists
await executeSystemCommand('which yq', { cwd: SessionContext.getCwd(), silent: true });
} catch (e) {
} catch (_e) {
// yq likely missing
const heuristicFix = 'sudo snap install yq';
console.log(chalk.cyan(`\n💡 Suggested Fix (Heuristic): ${chalk.bold(heuristicFix)}`));
Expand Down
3 changes: 1 addition & 2 deletions src/commands/setup.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import inquirer from 'inquirer';
import chalk from 'chalk';
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
import { dirname, join } from 'path';

Expand All @@ -21,7 +20,7 @@ async function getOllamaModels() {
const data = await response.json();
return data.models.map(m => m.name);
}
} catch (e) {
} catch (_e) {
// Ollama not running or query failed
}
return [];
Expand Down
6 changes: 3 additions & 3 deletions src/dynamic-transparency.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class DynamicTransparency {
files.push(fullPath);
}
}
} catch (e) {
} catch (_e) {
// Ignore errors when scanning directory
}
return files;
Expand Down Expand Up @@ -219,7 +219,7 @@ class DynamicTransparency {
// Truncate to reasonable size
detectiveContext += `\n[FILE: ${filePath}]\n${content.slice(0, 2000)}\n`;
}
} catch (e) {
} catch (_e) {
// Ignore missing files or permission errors during investigation
}
}
Expand Down Expand Up @@ -286,7 +286,7 @@ class DynamicTransparency {
return diagnosis;
}

generateDynamicPhases(prompt) {
generateDynamicPhases(_prompt) {
const phases = [
{ icon: '🔍', text: `Analyzing ${this.dynamicPatterns.size > 0 ? Array.from(this.dynamicPatterns.keys())[0] : 'generic'} context...` },
{ icon: '🛡️', text: 'Applying dynamic guardrails...' },
Expand Down
7 changes: 3 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
#!/usr/bin/env node

import './utils/env-loader.js'; // Must be first
import { executeSystemCommand, analyzeCommand, requireApproval, ToolRegistry } from './utils/advanced-executioner.js';
import { executeSystemCommand, analyzeCommand } from './utils/advanced-executioner.js';
import { AIService } from './services/ai.service.js';
import NamespacedVectorMemory from './services/namespaced-memory.js';
import { isSafeCommand } from './utils/safe-guard.js';
import { startSession } from './commands/advanced-session.js';
import inquirer from 'inquirer';
import chalk from 'chalk';
import os from 'os';
import { execSync } from 'child_process';
import { registry } from './plugins/registry.js';

// CLI Flag Parser
Expand Down Expand Up @@ -153,7 +152,7 @@ function showInstantHint() {
console.log(chalk.gray('🧠 Learning this pattern...'));
await UniversalPredictor.learn(process.cwd(), prediction.command);

} catch (execErr) {
} catch (_execErr) {
console.log(chalk.yellow('\n⚠️ Command failed.'));
}
}
Expand Down Expand Up @@ -332,7 +331,7 @@ ${chalk.cyan('Commands:')}
if (tokenData.savings) {
console.log(chalk.green('Estimated Savings: ') + chalk.bold(tokenData.savings));
}
} catch (e) {
} catch (_e) {
console.log(chalk.yellow('Could not parse token file'));
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/services/ai.router.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { providers } from '../config/ai.providers.js';

export class AIRouter {
static getProviders(task = 'general', options = {}) {
static getProviders(task = 'general', _options = {}) {
const trainingMode = process.env.TRAINING_MODE === 'true';

// Training mode
Expand Down
10 changes: 5 additions & 5 deletions src/services/ai.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class AIService {
}

// Get fix for failed command
async getFix(prompt, context, options = {}) {
async getFix(prompt, context, _options = {}) {
const fullPrompt = `
Context: ${context || 'Shell Command'}
Task: Return JSON with commands to fix the issue.
Expand Down Expand Up @@ -46,7 +46,7 @@ User: ${prompt}
try {
yield* this.#streamProvider(provider, prompt);
return;
} catch (err) {
} catch (_err) {
continue;
}
}
Expand All @@ -72,14 +72,14 @@ User: ${prompt}
for (const provider of providers) {
try {
return await this.#executeProvider(provider, prompt, signal);
} catch (err) {
} catch (_err) {
continue;
}
}
throw new Error('All AI providers failed');
}

async #executeProvider(provider, prompt, signal) {
async #executeProvider(provider, prompt, _signal) {
let content;
if (provider.type === 'ollama') {
const response = await ollama.chat({
Expand Down Expand Up @@ -114,7 +114,7 @@ User: ${prompt}
try {
const { Telemetry } = await import('../utils/telemetry.js');
Telemetry.logCall(prompt, content, provider);
} catch (e) {
} catch (_e) {
// Ignore telemetry logging issues
}

Expand Down
8 changes: 4 additions & 4 deletions src/services/artifact-memory.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class ArtifactMemory {
});
}
}
} catch (e) {
} catch (_e) {
// Ignore read errors
}
}
Expand All @@ -87,7 +87,7 @@ class ArtifactMemory {
}
}
}
} catch (e) {
} catch (_e) {
// Ignore directory scan errors
}
return collected;
Expand All @@ -108,7 +108,7 @@ class ArtifactMemory {
prompt: text.slice(0, 8192)
});
return response.embedding;
} catch (e) {
} catch (_e) {
return this.deterministicEmbed(text); // Fallback
}
}
Expand Down Expand Up @@ -150,7 +150,7 @@ class ArtifactMemory {
if (fs.existsSync(ARTIFACT_DB)) {
this.artifacts = JSON.parse(fs.readFileSync(ARTIFACT_DB, 'utf8'));
}
} catch (e) {
} catch (_e) {
this.artifacts = {};
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/services/mcp-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export class MCPClient extends EventEmitter {
try {
const { stdout } = await execAsync('git status --short');
return { status: stdout };
} catch (e) {
} catch (_e) {
return { error: 'Not a git repository' };
}

Expand Down
4 changes: 2 additions & 2 deletions src/services/namespaced-memory.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class NamespacedVectorMemory {
}
try {
this.teamMemory = new TeamMemory();
} catch (e) {
} catch (_e) {
this.teamMemory = null;
}
}
Expand Down Expand Up @@ -172,7 +172,7 @@ class NamespacedVectorMemory {
prompt: text.slice(0, 8192)
});
return response.embedding;
} catch (e) {
} catch (_e) {
// console.warn('Embedding failed (Ollama/nomic-embed-text not ready?):', e.message);
// Fallback: Deterministic "hash" embedding for exact matching simulation
return this.deterministicEmbed(text);
Expand Down
22 changes: 1 addition & 21 deletions src/services/project-analyzer.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import chalk from 'chalk';
import inquirer from 'inquirer';
// Use CommandPredictor for deep scan (files, type detection)
import { CommandPredictor } from '../utils/project-scanner.js';
import { AIService } from './ai.service.js';
import { executeSystemCommand } from '../utils/executioner.js';
import SessionContext from '../utils/session-context.js';

const aiService = new AIService();

export class ProjectAnalyzer {
static async ask(question) {
// Use current session CWD if available, else process.cwd()
Expand All @@ -33,22 +29,6 @@ export class ProjectAnalyzer {
// Universal Project-Aware Prompt
const fileList = Array.isArray(fingerprint.files) ? fingerprint.files.map(f => f.path || f).join(', ') : 'scan failed';

// Project Brain Context
const projectMap = SessionContext.projectMap || {};
const readmeSummary = projectMap.readmeSummary || {};

const brainContext = `
PROJECT BRAIN:
- Entry Point: ${projectMap.entryPoint || 'Auto-detect'}
- Deploy Namespace: ${projectMap.deployNamespace || 'default'}
- README Instructions: ${JSON.stringify(readmeSummary)}
- Structure: ${JSON.stringify({
charts: fingerprint.charts,
values: fingerprint.valuesFiles,
rootFiles: fingerprint.files.map(f => f.path || f.name).filter(n => !n.includes('/'))
}, null, 2)}
`;

// History Context (Robust)
const recentHistory = SessionContext.getHistory?.()?.slice(-3).join('\n') || 'None';
const recentErrors = SessionContext.getResults?.()?.filter(r => !r.success).slice(-2).map(e => e.stderr?.slice(0, 100)).join('\n') || 'None';
Expand Down Expand Up @@ -173,7 +153,7 @@ OUTPUT 3 numbered SHELL COMMANDS using EXACT paths above.`;
if (parsed.steps && Array.isArray(parsed.steps)) {
steps = parsed.steps;
}
} catch (e) {
} catch (_e) {
// Fallback: Parsing failed, try regex/legacy methods
}

Expand Down
Loading
Loading