From faaeb99ae497919475f577ee2c501a2ed9890214 Mon Sep 17 00:00:00 2001 From: Sagar Date: Fri, 25 Sep 2026 22:36:16 +0530 Subject: [PATCH] fix: resolve failing integration tests and ESLint unused-var warnings --- .github/workflows/release.yml | 2 +- .node-version | 2 +- .nvmrc | 2 +- package-lock.json | 1 + package.json | 3 +++ src/commands/advanced-session.js | 12 +++++------- src/commands/session.js | 14 ++++++-------- src/commands/setup.js | 3 +-- src/dynamic-transparency.js | 6 +++--- src/index.js | 7 +++---- src/services/ai.router.js | 2 +- src/services/ai.service.js | 10 +++++----- src/services/artifact-memory.js | 8 ++++---- src/services/mcp-client.js | 2 +- src/services/namespaced-memory.js | 4 ++-- src/services/project-analyzer.js | 22 +--------------------- src/services/team-auth.js | 4 ++-- src/services/team-memory.js | 1 - src/services/universal-predictor.js | 4 ++-- src/utils/advanced-executioner.js | 11 ++++------- src/utils/cache.js | 3 +-- src/utils/enhanced-scanner.js | 4 ++-- src/utils/executioner.js | 4 +--- src/utils/project-id.js | 2 +- src/utils/project-scanner.js | 4 ++-- src/utils/safe-guard.js | 3 +-- src/utils/session-context.js | 6 +++--- src/utils/streaming-executioner.js | 12 ------------ src/utils/telemetry.js | 7 +++---- test/chaos/memory_stress.js | 3 ++- test/chaos_tyk/seed_memory.js | 2 +- test/integration/cli-commands.test.js | 2 +- test/unit/telemetry.test.js | 1 - 33 files changed, 65 insertions(+), 108 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 985db7d..d17db1d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 diff --git a/.node-version b/.node-version index 64f5a0a..a45fd52 100644 --- a/.node-version +++ b/.node-version @@ -1 +1 @@ -node +24 diff --git a/.nvmrc b/.nvmrc index 209e3ef..a45fd52 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -20 +24 diff --git a/package-lock.json b/package-lock.json index de2b15f..93e8166 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2930,6 +2930,7 @@ "version": "13.0.3", "resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-13.0.3.tgz", "integrity": "sha512-RbOBxmLBG8uvFUc15X9+9SFemKcQ0WBuISBVkpuiaUB2qblC8UWlHEjdWVoZ8AdhSwmoEgsiXKfopX0CQxaACQ==", + "hasInstallScript": true, "license": "MIT", "dependencies": { "node-addon-api": "^8.0.0" diff --git a/package.json b/package.json index 8959fb1..18b9817 100644 --- a/package.json +++ b/package.json @@ -48,6 +48,9 @@ ], "author": "Sagar Jadhav ", "license": "MIT", + "engines": { + "node": ">=24" + }, "devDependencies": { "@commitlint/cli": "^20.2.0", "@commitlint/config-conventional": "^20.2.0", diff --git a/src/commands/advanced-session.js b/src/commands/advanced-session.js index 0995197..951eba4 100644 --- a/src/commands/advanced-session.js +++ b/src/commands/advanced-session.js @@ -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'; @@ -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)); }); @@ -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('==============================================')); @@ -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 = ` @@ -514,7 +512,7 @@ Output ONLY the corrected command string. No explanation. return; } } - } catch (e) { + } catch (_e) { // Fallback } } diff --git a/src/commands/session.js b/src/commands/session.js index ddf044a..bfa5531 100644 --- a/src/commands/session.js +++ b/src/commands/session.js @@ -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'; @@ -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)); }); @@ -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('==============================================')); @@ -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'; @@ -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 = ` @@ -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 } } @@ -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)}`)); diff --git a/src/commands/setup.js b/src/commands/setup.js index b7ce5ff..7f9d4fb 100644 --- a/src/commands/setup.js +++ b/src/commands/setup.js @@ -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'; @@ -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 []; diff --git a/src/dynamic-transparency.js b/src/dynamic-transparency.js index f806ef0..c92710d 100644 --- a/src/dynamic-transparency.js +++ b/src/dynamic-transparency.js @@ -74,7 +74,7 @@ class DynamicTransparency { files.push(fullPath); } } - } catch (e) { + } catch (_e) { // Ignore errors when scanning directory } return files; @@ -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 } } @@ -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...' }, diff --git a/src/index.js b/src/index.js index cd22696..d88c3cf 100755 --- a/src/index.js +++ b/src/index.js @@ -1,7 +1,7 @@ #!/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'; @@ -9,7 +9,6 @@ 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 @@ -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.')); } } @@ -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 { diff --git a/src/services/ai.router.js b/src/services/ai.router.js index f7abb29..aacf5dd 100644 --- a/src/services/ai.router.js +++ b/src/services/ai.router.js @@ -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 diff --git a/src/services/ai.service.js b/src/services/ai.service.js index 0b1bc53..e8e2454 100644 --- a/src/services/ai.service.js +++ b/src/services/ai.service.js @@ -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. @@ -46,7 +46,7 @@ User: ${prompt} try { yield* this.#streamProvider(provider, prompt); return; - } catch (err) { + } catch (_err) { continue; } } @@ -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({ @@ -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 } diff --git a/src/services/artifact-memory.js b/src/services/artifact-memory.js index 3c7b325..236b1b8 100644 --- a/src/services/artifact-memory.js +++ b/src/services/artifact-memory.js @@ -61,7 +61,7 @@ class ArtifactMemory { }); } } - } catch (e) { + } catch (_e) { // Ignore read errors } } @@ -87,7 +87,7 @@ class ArtifactMemory { } } } - } catch (e) { + } catch (_e) { // Ignore directory scan errors } return collected; @@ -108,7 +108,7 @@ class ArtifactMemory { prompt: text.slice(0, 8192) }); return response.embedding; - } catch (e) { + } catch (_e) { return this.deterministicEmbed(text); // Fallback } } @@ -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 = {}; } } diff --git a/src/services/mcp-client.js b/src/services/mcp-client.js index cb26073..048896d 100644 --- a/src/services/mcp-client.js +++ b/src/services/mcp-client.js @@ -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' }; } diff --git a/src/services/namespaced-memory.js b/src/services/namespaced-memory.js index 796c690..5604d0a 100644 --- a/src/services/namespaced-memory.js +++ b/src/services/namespaced-memory.js @@ -19,7 +19,7 @@ class NamespacedVectorMemory { } try { this.teamMemory = new TeamMemory(); - } catch (e) { + } catch (_e) { this.teamMemory = null; } } @@ -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); diff --git a/src/services/project-analyzer.js b/src/services/project-analyzer.js index e297661..e8742e6 100644 --- a/src/services/project-analyzer.js +++ b/src/services/project-analyzer.js @@ -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() @@ -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'; @@ -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 } diff --git a/src/services/team-auth.js b/src/services/team-auth.js index d623e33..65b6c9c 100644 --- a/src/services/team-auth.js +++ b/src/services/team-auth.js @@ -17,7 +17,7 @@ export class TeamAuth { const data = await fs.readFile(this.tokenFile, 'utf8'); const parsed = JSON.parse(data); return parsed.token || null; - } catch (error) { + } catch (_error) { return null; } } @@ -31,7 +31,7 @@ export class TeamAuth { try { const data = JSON.parse(await fs.readFile(this.tokenFile, 'utf8')); return data.username || 'me'; - } catch (error) { + } catch (_error) { return 'me'; } } diff --git a/src/services/team-memory.js b/src/services/team-memory.js index 4189745..b9dac0f 100644 --- a/src/services/team-memory.js +++ b/src/services/team-memory.js @@ -4,7 +4,6 @@ import os from 'os'; import crypto from 'crypto'; const TEAM_MEMORY_DIR = path.join(os.homedir(), '.nebula-cli', 'team'); -const TEAM_DB_FILE = path.join(TEAM_MEMORY_DIR, 'team-patterns.json'); /** * TeamMemory — shared workflow memory for teams. diff --git a/src/services/universal-predictor.js b/src/services/universal-predictor.js index 5fd23c8..6fc464c 100644 --- a/src/services/universal-predictor.js +++ b/src/services/universal-predictor.js @@ -34,7 +34,7 @@ export class UniversalPredictor { rationale: 'Recognized similar project structure from memory' }; } - } catch (e) { + } catch (_e) { // Vector db optional fail-safe } @@ -68,7 +68,7 @@ Reply ONLY with the one-line command to run/deploy. No markdown. rationale: 'AI analyzed project structure' }; } - } catch (e) { + } catch (_e) { // Fallback to simpler heuristics if Ollama fails/not installed } diff --git a/src/utils/advanced-executioner.js b/src/utils/advanced-executioner.js index f475b6c..ab1e6c4 100644 --- a/src/utils/advanced-executioner.js +++ b/src/utils/advanced-executioner.js @@ -1,8 +1,6 @@ -import { spawn, execSync } from 'child_process'; -import os from 'os'; +import { spawn } from 'child_process'; import chalk from 'chalk'; import readline from 'readline'; -import { z } from 'zod'; import { logAudit, getAuditFilePath } from './audit-logger.js'; import { getSafetyScore } from './safe-guard.js'; @@ -10,7 +8,7 @@ let nodePty; try { nodePty = require('node-pty'); -} catch (e) { +} catch (_e) { // node-pty not available } @@ -82,7 +80,7 @@ function startSpinner(message = '') { frame(); } -function stopSpinner(success = false) { +function stopSpinner(_success = false) { spinnerActive = false; if (spinnerTimeout) { clearTimeout(spinnerTimeout); @@ -381,7 +379,6 @@ function maskSecrets(text) { function classifyCommand(command) { if (!command) return 'short'; - const cmd = command.split(' ')[0].toLowerCase(); if (command.includes('minikube')) return 'minikube'; if (command.includes('helm')) return 'helm'; if (new RegExp(/kubectl.*(apply|create|scale)/).test(command)) return 'kubectl_long'; @@ -390,7 +387,7 @@ function classifyCommand(command) { return 'short'; } -function getDynamicTimeout(type, command) { +function getDynamicTimeout(type, _command) { const timeouts = { minikube: 180, helm: 240, diff --git a/src/utils/cache.js b/src/utils/cache.js index 9dd3dfb..602ef6b 100644 --- a/src/utils/cache.js +++ b/src/utils/cache.js @@ -53,10 +53,9 @@ export class SemanticCache { #readCache() { try { - const start = Date.now(); const content = fs.readFileSync(this.cacheFile, 'utf-8'); return JSON.parse(content); - } catch (err) { + } catch (_err) { return {}; } } diff --git a/src/utils/enhanced-scanner.js b/src/utils/enhanced-scanner.js index ab2b449..38e261d 100644 --- a/src/utils/enhanced-scanner.js +++ b/src/utils/enhanced-scanner.js @@ -102,7 +102,7 @@ export const getProjectInfo = (cwd = process.cwd()) => { info.scripts = info.packageJson.scripts || {}; info.dependencies = info.packageJson.dependencies || {}; info.devDependencies = info.packageJson.devDependencies || {}; - } catch (e) { + } catch (_e) { // Ignore parse errors } } @@ -148,7 +148,7 @@ export const scanProjectFiles = (cwd = process.cwd(), options = {}) => { scan(fullPath, depth + 1); } } - } catch (e) { + } catch (_e) { // Ignore permission errors } }; diff --git a/src/utils/executioner.js b/src/utils/executioner.js index c95c777..29b7433 100644 --- a/src/utils/executioner.js +++ b/src/utils/executioner.js @@ -1,5 +1,4 @@ import { spawn } from 'child_process'; -import os from 'os'; import chalk from 'chalk'; @@ -104,7 +103,6 @@ function maskSecrets(text) { function classifyCommand(command) { if (!command) return 'short'; - const cmd = command.split(' ')[0].toLowerCase(); if (command.includes('minikube')) return 'minikube'; if (command.includes('helm')) return 'helm'; if (new RegExp(/kubectl.*(apply|create|scale)/).test(command)) return 'kubectl_long'; @@ -113,7 +111,7 @@ function classifyCommand(command) { return 'short'; } -function getDynamicTimeout(type, command) { +function getDynamicTimeout(type, _command) { const timeouts = { minikube: 180, // start/stop/delete helm: 240, // install/upgrade heavy diff --git a/src/utils/project-id.js b/src/utils/project-id.js index 4fe354e..6bbecb7 100644 --- a/src/utils/project-id.js +++ b/src/utils/project-id.js @@ -34,7 +34,7 @@ export class ProjectID { try { fs.writeFileSync(uidFile, uid); console.log(`šŸ†• Created project ID: [${uid}] for ${path.basename(cwd)}`); - } catch (e) { + } catch (_e) { // If write fails (e.g. read-only), just return the calculated ID but warn // console.warn('Could not persist project ID:', e.message); } diff --git a/src/utils/project-scanner.js b/src/utils/project-scanner.js index 823192f..f3af5dc 100644 --- a/src/utils/project-scanner.js +++ b/src/utils/project-scanner.js @@ -30,7 +30,7 @@ export class CommandPredictor { insights.push(result.stdout.slice(0, 1000)); // Keep it light for prediction context // console.log(`🧠 Gathered: ${safeCmd}`); } - } catch (e) { + } catch (_e) { // Ignore failures in gathering } } @@ -194,7 +194,7 @@ export class CommandPredictor { if (entry.name === 'Route.yaml' || entry.name === 'DeploymentConfig.yaml') fingerprint.openshiftFile = true; } } - } catch (e) { + } catch (_e) { // Ignore permission errors etc } }; diff --git a/src/utils/safe-guard.js b/src/utils/safe-guard.js index 9117dc6..3f158c5 100644 --- a/src/utils/safe-guard.js +++ b/src/utils/safe-guard.js @@ -168,7 +168,6 @@ export const isSafeCommand = (command) => { } else if (cmdName === 'git') { // Block destructive git commands - const dangerousGitCommands = ['reset', 'clean', 'push']; const gitSubcommand = node.suffix?.[0]?.text; if (gitSubcommand === 'reset' && node.suffix?.some(s => s.text?.includes('--hard'))) { @@ -221,7 +220,7 @@ export const isSafeCommand = (command) => { } return scanNode(ast); - } catch (e) { + } catch (_e) { // Fail Closed on Parser Error (Chaos Hardened) // If we cannot parse it, we cannot trust it. return false; diff --git a/src/utils/session-context.js b/src/utils/session-context.js index b52fb1a..32d00ae 100644 --- a/src/utils/session-context.js +++ b/src/utils/session-context.js @@ -46,7 +46,7 @@ class SessionContext { console.log(chalk.gray('🧠 Project Map Loaded (Cached)')); shouldUpdate = false; } - } catch (e) { + } catch (_e) { console.log(chalk.yellow('āš ļø Map check failed, regenerating...')); shouldUpdate = true; } @@ -77,7 +77,7 @@ class SessionContext { if (mtime > latest) latest = mtime; } } - } catch (e) { + } catch (_e) { // ignore permission errors } }; @@ -118,7 +118,7 @@ class SessionContext { // Short timeout 2s for checks to be fast await executeSystemCommand(check.cmd, { cwd: this.cwd, timeout: 2000, silent: true }); return check.id; - } catch (e) { + } catch (_e) { // ignore } } diff --git a/src/utils/streaming-executioner.js b/src/utils/streaming-executioner.js index 70eb5c3..e9a9c15 100644 --- a/src/utils/streaming-executioner.js +++ b/src/utils/streaming-executioner.js @@ -1,7 +1,5 @@ // 2026 Streaming Executioner with Real-time Output import { spawn } from 'child_process'; -import os from 'os'; -import chalk from 'chalk'; export class StreamingExecutor { constructor() { @@ -18,7 +16,6 @@ export class StreamingExecutor { shell = true, } = options; - const cmdType = this.#classifyCommand(command); const startTime = Date.now(); const processId = `proc_${Date.now()}`; @@ -170,15 +167,6 @@ export class StreamingExecutor { return finalOutput; } - #classifyCommand(command) { - const cmd = command.toLowerCase().trim(); - const shortCmds = ['ls', 'pwd', 'date', 'whoami', 'echo', 'cd', 'cat']; - - if (shortCmds.includes(cmd.split(' ')[0])) return 'short'; - if (cmd.includes('docker') || cmd.includes('kubectl') || cmd.includes('npm install')) return 'long'; - return 'medium'; - } - // List active processes listActive() { return Array.from(this.activeProcesses.entries()).map(([id, proc]) => ({ diff --git a/src/utils/telemetry.js b/src/utils/telemetry.js index 5033982..534343e 100644 --- a/src/utils/telemetry.js +++ b/src/utils/telemetry.js @@ -1,5 +1,4 @@ import fs from 'fs'; -import path from 'path'; const TOKEN_FILE = '.nebula_tokens.json'; @@ -13,7 +12,7 @@ export class Telemetry { * @param {string} response - The response received. * @param {object} provider - The provider configuration object. */ - static logCall(prompt, response, provider) { + static logCall(prompt, response, _provider) { try { // Determine if this is a prompt cache hit // We hash/identify the static context prefix (first 150 chars) of the prompt @@ -29,7 +28,7 @@ export class Telemetry { if (fs.existsSync(TOKEN_FILE)) { try { data = JSON.parse(fs.readFileSync(TOKEN_FILE, 'utf8')); - } catch (e) { + } catch (_e) { // Reset on error } } @@ -56,7 +55,7 @@ export class Telemetry { data.cacheHitRate = `${((data.cacheHits / data.calls) * 100).toFixed(1)}%`; fs.writeFileSync(TOKEN_FILE, JSON.stringify(data, null, 2)); - } catch (err) { + } catch (_err) { // Fail silently to avoid breaking the CLI on write errors } } diff --git a/test/chaos/memory_stress.js b/test/chaos/memory_stress.js index 333c587..f70d61e 100644 --- a/test/chaos/memory_stress.js +++ b/test/chaos/memory_stress.js @@ -32,7 +32,8 @@ stream.on('finish', async () => { // Simulate splitting/processing for AI context window // This effectively needlessly duplicates strings, stressing the GC const tokens = content.split(' '); - const vectorish = tokens.map(t => t.length); + // Result intentionally discarded: allocates throwaway data to stress the GC + tokens.map(t => t.length); const finalMem = process.memoryUsage(); console.log(chalk.bold('\nšŸ“Š Peak Memory Usage:')); diff --git a/test/chaos_tyk/seed_memory.js b/test/chaos_tyk/seed_memory.js index 44d6179..bfa7ea1 100644 --- a/test/chaos_tyk/seed_memory.js +++ b/test/chaos_tyk/seed_memory.js @@ -6,7 +6,7 @@ import path from 'path'; const cwd = path.resolve('.'); console.log('Seeding memory for:', cwd); - const pid = await ProjectID.getOrCreateUID(cwd); + await ProjectID.getOrCreateUID(cwd); const memory = new NamespacedVectorMemory(); await memory.initialize(cwd); diff --git a/test/integration/cli-commands.test.js b/test/integration/cli-commands.test.js index 9895aa2..4f01749 100644 --- a/test/integration/cli-commands.test.js +++ b/test/integration/cli-commands.test.js @@ -1,4 +1,4 @@ -import { describe, it, expect, beforeEach } from 'vitest'; +import { describe, it, expect } from 'vitest'; import { exec } from 'child_process'; import { promisify } from 'util'; diff --git a/test/unit/telemetry.test.js b/test/unit/telemetry.test.js index 9a96afd..4222497 100644 --- a/test/unit/telemetry.test.js +++ b/test/unit/telemetry.test.js @@ -1,6 +1,5 @@ import { describe, it, expect, beforeEach, afterEach } from 'vitest'; import fs from 'fs'; -import path from 'path'; import { Telemetry } from '../../src/utils/telemetry.js'; describe('Telemetry', () => {