Browse Source

Merge pull request #963 from adikpb/cleanup/dead-code-sweep

refactor(config): dead-code sweep - remove 608 lines of unused exports
Alvin 1 week ago
parent
commit
ec2157fcea

+ 0 - 12
src/cli/config-io.ts

@@ -644,18 +644,6 @@ export function enableLspByDefault(): ConfigMergeResult {
   }
   }
 }
 }
 
 
-export function canModifyOpenCodeConfig(): boolean {
-  try {
-    const configPath = getExistingConfigPath();
-    if (!existsSync(configPath)) return true; // Will be created
-    const stat = statSync(configPath);
-    // Check if writable - simple check for now
-    return !!(stat.mode & 0o200);
-  } catch {
-    return false;
-  }
-}
-
 // Antigravity, Google provider, and Chutes provider functions removed in simplification refactor.
 // Antigravity, Google provider, and Chutes provider functions removed in simplification refactor.
 
 
 export function detectCurrentConfig(): DetectedConfig {
 export function detectCurrentConfig(): DetectedConfig {

+ 0 - 21
src/cli/model-key-normalization.test.ts

@@ -1,21 +0,0 @@
-/// <reference types="bun-types" />
-
-import { describe, expect, test } from 'bun:test';
-import { buildModelKeyAliases } from './model-key-normalization';
-
-describe('model key normalization', () => {
-  test('normalizes multi-segment chutes model ids', () => {
-    const aliases = buildModelKeyAliases(
-      'chutes/Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8-TEE',
-    );
-
-    expect(aliases).toContain('qwen/qwen3-coder-480b-a35b-instruct');
-    expect(aliases).toContain('qwen3-coder-480b-a35b-instruct');
-    expect(aliases).not.toContain('qwen3-coder-480b-a35b-instruct-fp8-tee');
-  });
-
-  test('treats spaces and hyphens as equivalent aliases', () => {
-    const aliases = buildModelKeyAliases('Qwen3 Coder 480B A35B Instruct');
-    expect(aliases).toContain('qwen3-coder-480b-a35b-instruct');
-  });
-});

+ 0 - 60
src/cli/model-key-normalization.ts

@@ -1,60 +0,0 @@
-function cleanupAlias(input: string, preserveSlash: boolean): string {
-  let value = input.toLowerCase().trim();
-  value = value.replace(/\bfp[a-z0-9.-]*\b/g, ' ');
-  value = value.replace(/\btee\b/g, ' ');
-
-  if (preserveSlash) {
-    value = value.replace(/[_\s]+/g, '-');
-    value = value.replace(/-+/g, '-');
-    value = value.replace(/\/+/g, '/');
-    value = value.replace(/\/-+/g, '/');
-    value = value.replace(/-+\//g, '/');
-    value = value.replace(/^\/+|\/+$/g, '');
-    value = value.replace(/^-+|-+$/g, '');
-    return value;
-  }
-
-  value = value.replace(/[/_\s]+/g, '-');
-  value = value.replace(/-+/g, '-');
-  value = value.replace(/^-+|-+$/g, '');
-  return value;
-}
-
-function addDerivedAliases(seed: string, aliases: Set<string>): void {
-  const slashAlias = cleanupAlias(seed, true);
-  const flatAlias = cleanupAlias(seed, false);
-
-  if (slashAlias) aliases.add(slashAlias);
-  if (flatAlias) aliases.add(flatAlias);
-
-  if (slashAlias) {
-    aliases.add(slashAlias.replace(/-(free|flash)$/i, ''));
-  }
-  if (flatAlias) {
-    aliases.add(flatAlias.replace(/-(free|flash)$/i, ''));
-  }
-
-  if (slashAlias.includes('/')) {
-    aliases.add(cleanupAlias(slashAlias.replace(/\//g, ' '), false));
-    aliases.add(cleanupAlias(slashAlias.replace(/\//g, '-'), false));
-    const lastPart = slashAlias.split('/').at(-1);
-    if (lastPart) {
-      addDerivedAliases(lastPart, aliases);
-    }
-  }
-}
-
-export function buildModelKeyAliases(input: string): string[] {
-  const normalized = input.trim().toLowerCase();
-  if (!normalized) return [];
-
-  const aliases = new Set<string>();
-  const slashIndex = normalized.indexOf('/');
-  const afterProvider =
-    slashIndex >= 0 ? normalized.slice(slashIndex + 1) : normalized;
-
-  addDerivedAliases(normalized, aliases);
-  addDerivedAliases(afterProvider, aliases);
-
-  return [...aliases].filter((alias) => alias.length > 0);
-}

+ 0 - 8
src/cli/providers.ts

@@ -58,14 +58,6 @@ export const MODEL_MAPPINGS = {
 export type PresetName = keyof typeof MODEL_MAPPINGS;
 export type PresetName = keyof typeof MODEL_MAPPINGS;
 export type GeneratedPresetName = (typeof GENERATED_PRESETS)[number];
 export type GeneratedPresetName = (typeof GENERATED_PRESETS)[number];
 
 
-export function isPresetName(value: string): value is PresetName {
-  return Object.hasOwn(MODEL_MAPPINGS, value);
-}
-
-export function getPresetNames(): PresetName[] {
-  return Object.keys(MODEL_MAPPINGS) as PresetName[];
-}
-
 export function isGeneratedPresetName(
 export function isGeneratedPresetName(
   value: string,
   value: string,
 ): value is GeneratedPresetName {
 ): value is GeneratedPresetName {

+ 0 - 1
src/config/codemap.md

@@ -134,7 +134,6 @@ This allows consumers to import directly from `src/config` rather than individua
 - `setActiveRuntimePreset(name)`: Set currently active preset
 - `setActiveRuntimePreset(name)`: Set currently active preset
 - `getActiveRuntimePreset()`: Get currently active preset
 - `getActiveRuntimePreset()`: Get currently active preset
 - `getPreviousRuntimePreset()`: Get previously active preset
 - `getPreviousRuntimePreset()`: Get previously active preset
-- `setActiveRuntimePresetWithPrevious(name)`: Set active with previous tracking
 
 
 ### MCP Management
 ### MCP Management
 
 

+ 0 - 6
src/config/constants.ts

@@ -74,12 +74,6 @@ export const NO_SHELL_READONLY_FILE_OPERATIONS_RULES = `**File Operations Rules*
 - Use glob/grep/ast_grep_search for discovery and read for file contents.
 - Use glob/grep/ast_grep_search for discovery and read for file contents.
 - Do not use bash or shell commands.`;
 - Do not use bash or shell commands.`;
 
 
-// Tmux pane spawn delay (ms) - gives TmuxSessionManager time to create pane
-export const TMUX_SPAWN_DELAY_MS = 500;
-
-// Stagger delay (ms) between parallel councillor launches to avoid tmux collisions
-export const COUNCILLOR_STAGGER_MS = 250;
-
 // Polling stability
 // Polling stability
 export const STABLE_POLLS_THRESHOLD = 3;
 export const STABLE_POLLS_THRESHOLD = 3;
 
 

+ 0 - 20
src/config/runtime-preset.test.ts

@@ -1,9 +1,7 @@
 import { describe, expect, test } from 'bun:test';
 import { describe, expect, test } from 'bun:test';
 import {
 import {
   getActiveRuntimePreset,
   getActiveRuntimePreset,
-  getPreviousRuntimePreset,
   setActiveRuntimePreset,
   setActiveRuntimePreset,
-  setActiveRuntimePresetWithPrevious,
 } from './runtime-preset';
 } from './runtime-preset';
 
 
 describe('runtime-preset', () => {
 describe('runtime-preset', () => {
@@ -20,22 +18,4 @@ describe('runtime-preset', () => {
     expect(getActiveRuntimePreset()).toBe('foo');
     expect(getActiveRuntimePreset()).toBe('foo');
     setActiveRuntimePreset(null);
     setActiveRuntimePreset(null);
   });
   });
-
-  test('setActiveRuntimePresetWithPrevious sets active and previous', () => {
-    setActiveRuntimePreset(null);
-    setActiveRuntimePreset('old');
-    setActiveRuntimePresetWithPrevious('new');
-    expect(getActiveRuntimePreset()).toBe('new');
-    expect(getPreviousRuntimePreset()).toBe('old');
-    setActiveRuntimePreset(null);
-  });
-
-  test('setActiveRuntimePresetWithPrevious with null sets previous to old', () => {
-    setActiveRuntimePreset(null);
-    setActiveRuntimePreset('old');
-    setActiveRuntimePresetWithPrevious(null);
-    expect(getActiveRuntimePreset()).toBeNull();
-    expect(getPreviousRuntimePreset()).toBe('old');
-    setActiveRuntimePreset(null);
-  });
 });
 });

+ 1 - 6
src/config/runtime-preset.ts

@@ -20,13 +20,8 @@ export function getActiveRuntimePreset(): string | null {
  * Returns the name of the previously active runtime preset (before the
  * Returns the name of the previously active runtime preset (before the
  * current one), used to compute reset diffs when switching presets.
  * current one), used to compute reset diffs when switching presets.
  */
  */
-let previousRuntimePreset: string | null = null;
+const previousRuntimePreset: string | null = null;
 
 
 export function getPreviousRuntimePreset(): string | null {
 export function getPreviousRuntimePreset(): string | null {
   return previousRuntimePreset;
   return previousRuntimePreset;
 }
 }
-
-export function setActiveRuntimePresetWithPrevious(name: string | null): void {
-  previousRuntimePreset = activeRuntimePreset;
-  activeRuntimePreset = name;
-}

+ 0 - 46
src/config/schema.ts

@@ -2,15 +2,6 @@ import { z } from 'zod';
 import { DEFAULT_MAX_RETAINED_SNAPSHOTS } from './constants';
 import { DEFAULT_MAX_RETAINED_SNAPSHOTS } from './constants';
 import { CouncilConfigSchema } from './council-schema';
 import { CouncilConfigSchema } from './council-schema';
 
 
-const MANUAL_AGENT_NAMES = [
-  'orchestrator',
-  'oracle',
-  'designer',
-  'explorer',
-  'librarian',
-  'fixer',
-] as const;
-
 export const ProviderModelIdSchema = z
 export const ProviderModelIdSchema = z
   .string()
   .string()
   .regex(
   .regex(
@@ -18,43 +9,6 @@ export const ProviderModelIdSchema = z
     'Expected provider/model format (provider/.../model)',
     'Expected provider/model format (provider/.../model)',
   );
   );
 
 
-export const ManualAgentPlanSchema = z
-  .object({
-    primary: ProviderModelIdSchema,
-    fallback1: ProviderModelIdSchema,
-    fallback2: ProviderModelIdSchema,
-    fallback3: ProviderModelIdSchema,
-  })
-  .superRefine((value, ctx) => {
-    const unique = new Set([
-      value.primary,
-      value.fallback1,
-      value.fallback2,
-      value.fallback3,
-    ]);
-    if (unique.size !== 4) {
-      ctx.addIssue({
-        code: z.ZodIssueCode.custom,
-        message: 'primary and fallbacks must be unique per agent',
-      });
-    }
-  });
-
-export const ManualPlanSchema = z
-  .object({
-    orchestrator: ManualAgentPlanSchema,
-    oracle: ManualAgentPlanSchema,
-    designer: ManualAgentPlanSchema,
-    explorer: ManualAgentPlanSchema,
-    librarian: ManualAgentPlanSchema,
-    fixer: ManualAgentPlanSchema,
-  })
-  .strict();
-
-export type ManualAgentName = (typeof MANUAL_AGENT_NAMES)[number];
-export type ManualAgentPlan = z.infer<typeof ManualAgentPlanSchema>;
-export type ManualPlan = z.infer<typeof ManualPlanSchema>;
-
 // Permission schemas — mirror the SDK's PermissionConfig type with shallow
 // Permission schemas — mirror the SDK's PermissionConfig type with shallow
 // validation. Action values are validated; unknown tool keys pass through.
 // validation. Action values are validated; unknown tool keys pass through.
 const PermissionActionSchema = z.enum(['ask', 'allow', 'deny']);
 const PermissionActionSchema = z.enum(['ask', 'allow', 'deny']);

+ 0 - 5
src/hooks/foreground-fallback/index.ts

@@ -176,11 +176,6 @@ export function isRetryableError(error: unknown): boolean {
   return isFailoverError(error);
   return isFailoverError(error);
 }
 }
 
 
-/** @deprecated Use isRetryableError instead. */
-export function isRateLimitError(error: unknown): boolean {
-  return isRetryableError(error);
-}
-
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
 // Helpers
 // Helpers
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------

+ 0 - 120
src/loop/loop-session.test.ts

@@ -1,120 +0,0 @@
-import { describe, expect, spyOn, test } from 'bun:test';
-import * as fs from 'node:fs';
-import {
-  compactAttempt,
-  createLoopSession,
-  type LoopDefinition,
-  loopDirname,
-  writeHistoryFile,
-} from './loop-session';
-
-function testDef(overrides?: Partial<LoopDefinition>): LoopDefinition {
-  return {
-    goal: 'test goal',
-    successCriteria: 'it works',
-    success: { type: 'test', command: 'bun test' },
-    maxAttempts: 3,
-    executeAgent: 'fixer',
-    verifyAgent: 'oracle',
-    ...overrides,
-  };
-}
-
-describe('loopDirname', () => {
-  test('creates human-readable dir name with short ID', () => {
-    const name = loopDirname('loop-mqwo5ddt', 'Fix typescript errors');
-    expect(name).toBe('fix-typescript-errors-mqwo5ddt');
-  });
-
-  test('slugifies the goal text', () => {
-    const name = loopDirname('loop-abc-123', 'Fix TypeScript & ESLint errors!');
-    expect(name).toBe('fix-typescript-eslint-errors-123');
-  });
-
-  test('truncates long goals', () => {
-    const longGoal = 'a'.repeat(50);
-    const name = loopDirname('xyz-999', longGoal);
-    expect(name.length).toBeLessThan(60);
-  });
-});
-
-describe('createLoopSession', () => {
-  test('creates a session with executing phase and attempt 1', () => {
-    const def = testDef();
-    const session = createLoopSession(def, 'loop-test-1');
-
-    expect(session.loopID).toBe('loop-test-1');
-    expect(session.definition).toBe(def);
-    expect(session.currentPhase).toBe('executing');
-    expect(session.attempts).toBe(1);
-    expect(session.history).toEqual([]);
-    expect(session.activeJobID).toBeUndefined();
-    expect(session.manualReviewPending).toBe(false);
-    expect(session.historyDir).toContain('test-goal');
-  });
-});
-
-describe('compactAttempt', () => {
-  test('formats a passed attempt', () => {
-    const result = compactAttempt({
-      attemptNumber: 1,
-      executionResult: 'bun test',
-      verificationResult: { passed: true, reason: 'all green' },
-    });
-    expect(result).toContain('## Attempt 1');
-    expect(result).toContain('**Outcome:** PASS');
-    expect(result).toContain('### Execution Result');
-  });
-
-  test('formats a failed attempt with reason', () => {
-    const result = compactAttempt({
-      attemptNumber: 2,
-      executionResult: 'bun test',
-      verificationResult: { passed: false, reason: 'tests failed' },
-    });
-    expect(result).toContain('## Attempt 2');
-    expect(result).toContain('FAIL: tests failed');
-  });
-
-  test('includes artifacts when present', () => {
-    const result = compactAttempt({
-      attemptNumber: 1,
-      executionResult: 'built',
-      verificationResult: { passed: true, reason: 'ok' },
-      artifactPaths: ['src/output.ts', 'src/output.test.ts'],
-    });
-    expect(result).toContain('artifacts: src/output.ts, src/output.test.ts');
-  });
-});
-
-describe('writeHistoryFile', () => {
-  test('uses the attempt number for the history filename', () => {
-    const mkdirSpy = spyOn(fs, 'mkdirSync').mockImplementation(() => undefined);
-    const writeSpy = spyOn(fs, 'writeFileSync').mockImplementation(
-      () => undefined,
-    );
-    const session = createLoopSession(testDef(), 'loop-test-1');
-    session.attempts = 99;
-    session.history.push({
-      attemptNumber: 4,
-      executionResult: 'bun test',
-      verificationResult: { passed: true, reason: 'ok' },
-    });
-
-    try {
-      writeHistoryFile(session);
-
-      expect(mkdirSpy).toHaveBeenCalledWith(session.historyDir, {
-        recursive: true,
-      });
-      expect(writeSpy).toHaveBeenCalledWith(
-        expect.stringContaining('history-004.md'),
-        expect.stringContaining('## Attempt 4'),
-        { encoding: 'utf-8' },
-      );
-    } finally {
-      mkdirSpy.mockRestore();
-      writeSpy.mockRestore();
-    }
-  });
-});

+ 0 - 117
src/loop/loop-session.ts

@@ -1,117 +0,0 @@
-import { mkdirSync, writeFileSync } from 'node:fs';
-import { join } from 'node:path';
-
-const HISTORY_DIR = join(process.cwd(), '.opencode', 'loop-history');
-
-function slugify(text: string): string {
-  return text
-    .toLowerCase()
-    .replace(/[^a-z0-9]+/g, '-')
-    .replace(/(^-|-$)/g, '')
-    .slice(0, 40);
-}
-
-export function loopDirname(loopID: string, goal: string): string {
-  const parts = loopID.split('-');
-  const shortID = parts[parts.length - 1] ?? loopID;
-  return `${slugify(goal)}-${shortID}`;
-}
-
-export type LoopPhase =
-  | 'executing'
-  | 'verifying'
-  | 'done'
-  | 'escalated'
-  | 'cancelled';
-
-export type ExecuteAgent = 'fixer' | 'designer' | 'explorer' | 'librarian';
-export type VerifyAgent = 'oracle' | 'observer' | 'test';
-
-export type SuccessCriterion =
-  | { type: 'test'; command: string }
-  | { type: 'build'; command: string }
-  | { type: 'lint'; command: string }
-  | { type: 'fileExists'; path: string }
-  | { type: 'command'; command: string; expectExitCode?: number }
-  | { type: 'oracle' }
-  | { type: 'observer' }
-  | { type: 'manual' };
-
-export interface LoopDefinition {
-  goal: string;
-  successCriteria: string;
-  success: SuccessCriterion;
-  maxAttempts: number;
-  executeAgent: ExecuteAgent;
-  verifyAgent: VerifyAgent;
-  contextFiles?: string[];
-  parentSessionID?: string;
-}
-
-export type VerificationResult =
-  | { passed: true; reason: string }
-  | { passed: false; reason: string; suggestedFix?: string };
-
-export interface AttemptRecord {
-  attemptNumber: number;
-  executionResult: string;
-  verificationResult: VerificationResult;
-  artifactPaths?: string[];
-}
-
-export interface LoopSession {
-  loopID: string;
-  definition: LoopDefinition;
-  currentPhase: LoopPhase;
-  attempts: number;
-  activeJobID?: string;
-  history: AttemptRecord[];
-  historyDir: string;
-  manualReviewPending: boolean;
-}
-
-export function createLoopSession(
-  definition: LoopDefinition,
-  loopID: string,
-): LoopSession {
-  const dir = join(HISTORY_DIR, loopDirname(loopID, definition.goal));
-  return {
-    loopID,
-    definition,
-    currentPhase: 'executing',
-    attempts: 1,
-    history: [],
-    manualReviewPending: false,
-    historyDir: dir,
-  };
-}
-
-export function compactAttempt(attempt: AttemptRecord): string {
-  const outcome = attempt.verificationResult.passed
-    ? 'PASS'
-    : `FAIL: ${attempt.verificationResult.reason}`;
-  const artifacts = attempt.artifactPaths?.length
-    ? `\n  → artifacts: ${attempt.artifactPaths.join(', ')}`
-    : '';
-  return `## Attempt ${attempt.attemptNumber}
-
-**Outcome:** ${outcome}${artifacts}
-
-### Execution Result
-\`\`\`
-${attempt.executionResult}
-\`\`\`
-`;
-}
-
-export function writeHistoryFile(session: LoopSession): void {
-  const lastAttempt = session.history.at(-1);
-  if (!lastAttempt) return;
-  const attemptFile = join(
-    session.historyDir,
-    `history-${String(lastAttempt.attemptNumber).padStart(3, '0')}.md`,
-  );
-  mkdirSync(session.historyDir, { recursive: true });
-  const content = compactAttempt(lastAttempt);
-  writeFileSync(attemptFile, content, { encoding: 'utf-8' });
-}

+ 1 - 6
src/multiplexer/types.ts

@@ -5,7 +5,7 @@
  * herdr, etc.) to spawn and manage panes for child agent sessions.
  * herdr, etc.) to spawn and manage panes for child agent sessions.
  */
  */
 
 
-import type { MultiplexerConfig, MultiplexerLayout } from '../config/schema';
+import type { MultiplexerLayout } from '../config/schema';
 
 
 export interface PaneResult {
 export interface PaneResult {
   success: boolean;
   success: boolean;
@@ -61,11 +61,6 @@ export interface Multiplexer {
   applyLayout(layout: MultiplexerLayout, mainPaneSize: number): Promise<void>;
   applyLayout(layout: MultiplexerLayout, mainPaneSize: number): Promise<void>;
 }
 }
 
 
-/**
- * Factory function type for creating multiplexer instances
- */
-export type MultiplexerFactory = (config: MultiplexerConfig) => Multiplexer;
-
 /**
 /**
  * Server health check utility (shared across implementations)
  * Server health check utility (shared across implementations)
  */
  */

+ 1 - 4
src/tools/ast-grep/codemap.md

@@ -34,14 +34,11 @@ The implementation follows a layered architecture:
   - Handles permissions and cleanup
   - Handles permissions and cleanup
 
 
 - **Environment & Constants** (`constants.ts`):
 - **Environment & Constants** (`constants.ts`):
-  - `checkEnvironment()`: Validates CLI availability at startup for early feedback
-  - `formatEnvironmentCheck()`: User-friendly status reporting
   - Defines supported languages, default limits (timeout, max output bytes, max matches), and language-to-extension mappings
   - Defines supported languages, default limits (timeout, max output bytes, max matches), and language-to-extension mappings
   - Implements path resolution logic that checks: cached binary → npm package → platform-specific package → Homebrew → PATH
   - Implements path resolution logic that checks: cached binary → npm package → platform-specific package → Homebrew → PATH
 
 
 - **Public API** (`index.ts`):
 - **Public API** (`index.ts`):
-  - Exports built-in tools for OpenCode integration
-  - Re-exports types, constants, and CLI utilities for external consumers
+  - Re-exports `ast_grep_replace`/`ast_grep_search` tools, types, and constants for external consumers
 
 
 ## Flow
 ## Flow
 
 

+ 0 - 63
src/tools/ast-grep/constants.ts

@@ -1,4 +1,3 @@
-import { spawnSync } from 'node:child_process';
 import { existsSync, statSync } from 'node:fs';
 import { existsSync, statSync } from 'node:fs';
 import { createRequire } from 'node:module';
 import { createRequire } from 'node:module';
 import { dirname, join } from 'node:path';
 import { dirname, join } from 'node:path';
@@ -150,65 +149,3 @@ export interface EnvironmentCheckResult {
     error?: string;
     error?: string;
   };
   };
 }
 }
-
-/**
- * Check if ast-grep CLI is available.
- * Call this at startup to provide early feedback about missing dependencies.
- */
-export function checkEnvironment(): EnvironmentCheckResult {
-  const cliPath = getSgCliPath();
-  const result: EnvironmentCheckResult = {
-    cli: {
-      available: false,
-      path: cliPath,
-    },
-  };
-
-  if (existsSync(cliPath)) {
-    result.cli.available = true;
-  } else if (cliPath === 'sg') {
-    try {
-      const whichResult = spawnSync(
-        process.platform === 'win32' ? 'where' : 'which',
-        ['sg'],
-        {
-          encoding: 'utf-8',
-          timeout: 5000,
-        },
-      );
-      result.cli.available =
-        whichResult.status === 0 && !!whichResult.stdout?.trim();
-      if (!result.cli.available) {
-        result.cli.error = 'sg binary not found in PATH';
-      }
-    } catch {
-      result.cli.error = 'Failed to check sg availability';
-    }
-  } else {
-    result.cli.error = `Binary not found: ${cliPath}`;
-  }
-
-  return result;
-}
-
-/**
- * Format environment check result as user-friendly message.
- */
-export function formatEnvironmentCheck(result: EnvironmentCheckResult): string {
-  const lines: string[] = ['ast-grep Environment Status:', ''];
-
-  if (result.cli.available) {
-    lines.push(`✓ CLI: Available (${result.cli.path})`);
-  } else {
-    lines.push(`✗ CLI: Not available`);
-    if (result.cli.error) {
-      lines.push(`  Error: ${result.cli.error}`);
-    }
-    lines.push(`  Install: bun add -D @ast-grep/cli`);
-  }
-
-  lines.push('');
-  lines.push(`CLI supports ${CLI_LANGUAGES.length} languages`);
-
-  return lines.join('\n');
-}

+ 0 - 7
src/tools/ast-grep/index.ts

@@ -1,11 +1,5 @@
-import type { ToolDefinition } from '@opencode-ai/plugin';
 import { ast_grep_replace, ast_grep_search } from './tools';
 import { ast_grep_replace, ast_grep_search } from './tools';
 
 
-export const builtinTools: Record<string, ToolDefinition> = {
-  ast_grep_search,
-  ast_grep_replace,
-};
-
 export {
 export {
   ensureCliAvailable,
   ensureCliAvailable,
   getAstGrepPath,
   getAstGrepPath,
@@ -13,7 +7,6 @@ export {
   startBackgroundInit,
   startBackgroundInit,
 } from './cli';
 } from './cli';
 export type { EnvironmentCheckResult } from './constants';
 export type { EnvironmentCheckResult } from './constants';
-export { checkEnvironment, formatEnvironmentCheck } from './constants';
 export {
 export {
   ensureAstGrepBinary,
   ensureAstGrepBinary,
   getCacheDir,
   getCacheDir,

+ 0 - 28
src/tools/preset-switch.test.ts

@@ -6,7 +6,6 @@ import type { PluginConfig } from '../config';
 import {
 import {
   buildPresetSummary,
   buildPresetSummary,
   deletePreset,
   deletePreset,
-  formatPresetOneLine,
   removeAgentFromPreset,
   removeAgentFromPreset,
   setAgentOverride,
   setAgentOverride,
   switchPresetOnDisk,
   switchPresetOnDisk,
@@ -442,33 +441,6 @@ describe('setAgentOverride / removeAgentFromPreset', () => {
   });
   });
 });
 });
 
 
-describe('formatPresetOneLine', () => {
-  test('joins agent → model pairs', () => {
-    const config: PluginConfig = {
-      presets: {
-        team: {
-          orchestrator: { model: 'ustc/glm-5.2' },
-          oracle: { model: 'ustc/glm-5.2' },
-        },
-      },
-    };
-
-    expect(formatPresetOneLine(config.presets?.team ?? {})).toBe(
-      'orchestrator → ustc/glm-5.2, oracle → ustc/glm-5.2',
-    );
-  });
-
-  test('falls back to agent name when model is absent', () => {
-    const config: PluginConfig = {
-      presets: {
-        bare: { oracle: { temperature: 0.3 } },
-      },
-    };
-
-    expect(formatPresetOneLine(config.presets?.bare ?? {})).toBe('oracle');
-  });
-});
-
 describe('buildPresetSummary', () => {
 describe('buildPresetSummary', () => {
   test('orders fields as model, variant, temp, options', () => {
   test('orders fields as model, variant, temp, options', () => {
     const summary = buildPresetSummary({
     const summary = buildPresetSummary({

+ 1 - 70
src/tools/preset-switch.ts

@@ -1,11 +1,6 @@
 import * as fs from 'node:fs';
 import * as fs from 'node:fs';
 import { stripJsonComments } from '../cli/config-io';
 import { stripJsonComments } from '../cli/config-io';
-import type {
-  AgentOverrideConfig,
-  ModelEntry,
-  PluginConfig,
-  Preset,
-} from '../config';
+import type { AgentOverrideConfig, PluginConfig, Preset } from '../config';
 import { AGENT_ALIASES } from '../config/constants';
 import { AGENT_ALIASES } from '../config/constants';
 import { findPluginConfigPaths } from '../config/loader';
 import { findPluginConfigPaths } from '../config/loader';
 
 
@@ -158,70 +153,6 @@ export function buildPresetSummary(
   return summaryParts;
   return summaryParts;
 }
 }
 
 
-/**
- * A single-line description of a preset for the TUI picker, e.g.
- * "orchestrator → glm-5.2, oracle → glm-5.2".
- */
-export function formatPresetOneLine(preset: Preset): string {
-  const lines: string[] = [];
-  for (const [agentName, override] of Object.entries(preset)) {
-    const modelStr =
-      typeof override.model === 'string'
-        ? override.model
-        : Array.isArray(override.model) && override.model.length > 0
-          ? resolveFirstModel(override.model)
-          : undefined;
-    lines.push(modelStr ? `${agentName} → ${modelStr}` : agentName);
-  }
-  return lines.join(', ');
-}
-
-/**
- * Format the full preset list with the active one highlighted. Used by
- * non-TUI surfaces (e.g. a future headless listing); the TUI uses the picker.
- */
-export function formatPresetList(
-  presets: Record<string, Preset>,
-  activePreset: string | null,
-): string {
-  const names = Object.keys(presets);
-  if (names.length === 0) {
-    return 'No presets configured. Define presets in oh-my-opencode-slim.jsonc under the "presets" field.';
-  }
-
-  const lines = ['Available presets:'];
-  for (const name of names) {
-    const marker = name === activePreset ? ' ← active' : '';
-    const preset = presets[name];
-    const agentNames = Object.keys(preset);
-    const models = agentNames
-      .map((a) => {
-        const cfg = preset[a];
-        const modelStr =
-          typeof cfg.model === 'string'
-            ? cfg.model
-            : Array.isArray(cfg.model) && cfg.model.length > 0
-              ? resolveFirstModel(cfg.model)
-              : undefined;
-        return modelStr ? `    ${a} → ${modelStr}` : `    ${a}`;
-      })
-      .join('\n');
-    lines.push(`  ${name}${marker}`);
-    lines.push(models);
-  }
-  lines.push('\nUsage: /preset <name> to switch.');
-
-  return lines.join('\n');
-}
-
-function resolveFirstModel(
-  models: Array<string | ModelEntry>,
-): string | undefined {
-  if (models.length === 0) return undefined;
-  const first = models[0];
-  return typeof first === 'string' ? first : first.id;
-}
-
 /**
 /**
  * Persist the preset name to the user-level config file so it survives
  * Persist the preset name to the user-level config file so it survives
  * restarts. Best-effort: a failure must not abort the switch, because the
  * restarts. Best-effort: a failure must not abort the switch, because the

+ 0 - 19
src/utils/session.ts

@@ -48,25 +48,6 @@ export async function abortSessionWithTimeout(
   );
   );
 }
 }
 
 
-/**
- * Extract the short model label from a "provider/model" string.
- * E.g. "openai/gpt-5.6-luna" → "gpt-5.6-luna"
- */
-export function shortModelLabel(model: string): string {
-  return model.split('/').pop() ?? model;
-}
-
-export type PromptBody = {
-  messageID?: string;
-  model?: { providerID: string; modelID: string };
-  agent?: string;
-  noReply?: boolean;
-  system?: string;
-  tools?: { [key: string]: boolean };
-  parts: Array<{ type: 'text'; text: string }>;
-  variant?: string;
-};
-
 /**
 /**
  * Parse a model reference string into provider and model IDs.
  * Parse a model reference string into provider and model IDs.
  * @param model - Model string in format "provider/model"
  * @param model - Model string in format "provider/model"