Browse Source

Merge pull request #726 from umi008/fix/audit-dead-code

refactor: remove dead code and unused exports
Alvin 1 month ago
parent
commit
562a7ef530

+ 0 - 26
src/agents/index.test.ts

@@ -12,7 +12,6 @@ import {
   createAgents,
   getAgentConfigs,
   getDisabledAgents,
-  getEnabledAgentNames,
   isSubagent,
 } from './index';
 
@@ -977,31 +976,6 @@ describe('disabled_agents', () => {
     expect(disabled.has('councillor')).toBe(false);
   });
 
-  test('getEnabledAgentNames filters correctly', () => {
-    const config: PluginConfig = {
-      disabled_agents: ['designer', 'fixer'],
-    };
-    const enabled = getEnabledAgentNames(config);
-    expect(enabled).not.toContain('designer');
-    expect(enabled).not.toContain('fixer');
-    expect(enabled).toContain('orchestrator');
-    expect(enabled).toContain('explorer');
-  });
-
-  test('getEnabledAgentNames includes enabled custom agents', () => {
-    const config: PluginConfig = {
-      disabled_agents: ['janitor'],
-      agents: {
-        janitor: { model: 'openai/gpt-5.6-luna' },
-        reviewer: { model: 'openai/gpt-5.6-luna' },
-      },
-    };
-
-    const enabled = getEnabledAgentNames(config);
-    expect(enabled).toContain('reviewer');
-    expect(enabled).not.toContain('janitor');
-  });
-
   test('empty disabled_agents creates observer but not unconfigured council', () => {
     const config: PluginConfig = {
       disabled_agents: [],

+ 0 - 20
src/agents/index.ts

@@ -729,23 +729,3 @@ export function getDisabledAgents(config?: PluginConfig): Set<string> {
   return disabled;
 }
 
-/**
- * Get the list of enabled (non-disabled) agent names.
- */
-export function getEnabledAgentNames(config?: PluginConfig): string[] {
-  const disabled = getDisabledAgents(config);
-  if (!config?.council) {
-    disabled.add('council');
-  }
-  const customAgentNames = getCustomAgentNames(config).filter(
-    (name) => !disabled.has(name),
-  );
-  const acpAgentNames = getAcpAgentNames(config).filter(
-    (name) => !disabled.has(name),
-  );
-  return [
-    ...ALL_AGENT_NAMES.filter((name) => !disabled.has(name)),
-    ...customAgentNames,
-    ...acpAgentNames,
-  ];
-}

+ 0 - 24
src/multiplexer/factory.ts

@@ -80,30 +80,6 @@ export function getMultiplexer(config: MultiplexerConfig): Multiplexer | null {
   return multiplexer;
 }
 
-/**
- * Clear the multiplexer cache (useful for testing)
- */
-export function clearMultiplexerCache(): void {
-  // No-op: multiplexers are no longer cached.
-}
-
-/**
- * Get the effective multiplexer type for auto mode
- * Returns the actual type that would be used (tmux/zellij/herdr/none)
- */
-export function getAutoMultiplexerType(): 'tmux' | 'zellij' | 'herdr' | 'none' {
-  if (process.env.TMUX) {
-    return 'tmux';
-  }
-  if (process.env.ZELLIJ) {
-    return 'zellij';
-  }
-  if (process.env.HERDR_ENV || process.env.HERDR_PANE_ID) {
-    return 'herdr';
-  }
-  return 'none';
-}
-
 /**
  * Start background availability check for a multiplexer
  */

+ 0 - 1
src/multiplexer/index.ts

@@ -3,7 +3,6 @@
  */
 
 export {
-  clearMultiplexerCache,
   getMultiplexer,
   startAvailabilityCheck,
 } from './factory';

+ 1 - 1
src/utils/index.ts

@@ -3,7 +3,7 @@ export * from './background-job-board';
 export * from './background-job-coordinator';
 export * from './background-job-store';
 export * from './internal-initiator';
-export { getLogDir, initLogger, log } from './logger';
+export { initLogger, log } from './logger';
 export * from './polling';
 export * from './session';
 export * from './task';

+ 1 - 26
src/utils/logger.test.ts

@@ -2,13 +2,7 @@ import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
 import * as fs from 'node:fs';
 import * as os from 'node:os';
 import * as path from 'node:path';
-import {
-  flushLoggerForTesting,
-  getLogDir,
-  initLogger,
-  log,
-  resetLogger,
-} from './logger';
+import { flushLoggerForTesting, initLogger, log, resetLogger } from './logger';
 
 describe('logger', () => {
   let tmpDir: string;
@@ -179,25 +173,6 @@ describe('logger', () => {
     expect(content).toContain('[unserializable]');
   });
 
-  test('getLogDir returns OPENCODE_LOG_DIR when set', () => {
-    expect(getLogDir()).toBe(tmpDir);
-  });
-
-  test('getLogDir falls back to os.homedir when env not set', () => {
-    delete process.env.OPENCODE_LOG_DIR;
-    try {
-      expect(getLogDir()).toBe(
-        path.join(os.homedir(), '.local/share/opencode/log'),
-      );
-    } finally {
-      if (origLogDir === undefined) {
-        delete process.env.OPENCODE_LOG_DIR;
-      } else {
-        process.env.OPENCODE_LOG_DIR = origLogDir;
-      }
-    }
-  });
-
   test('handles complex data structures', async () => {
     initLogger('session1');
     log('complex data', {

+ 0 - 2
src/utils/logger.ts

@@ -76,8 +76,6 @@ export function initLogger(sessionId: string): void {
   cleanupOldLogs(dir);
 }
 
-export { getLogDir };
-
 /** @internal Reset logger state for testing */
 export function resetLogger(): void {
   logFile = null;