Browse Source

fix: preserve build and plan agents during install

Alvin Unreal 2 months ago
parent
commit
04cdef5cf2
2 changed files with 9 additions and 18 deletions
  1. 8 12
      src/cli/config-io.test.ts
  2. 1 6
      src/cli/config-io.ts

+ 8 - 12
src/cli/config-io.test.ts

@@ -464,7 +464,7 @@ describe('config-io', () => {
     );
   });
 
-  test('disableDefaultAgents disables OpenCode built-in agents', () => {
+  test('disableDefaultAgents disables conflicting OpenCode built-in agents', () => {
     const configPath = join(tmpDir, 'opencode', 'opencode.json');
     paths.ensureConfigDir();
     writeFileSync(configPath, JSON.stringify({}));
@@ -475,11 +475,11 @@ describe('config-io', () => {
     const saved = JSON.parse(readFileSync(configPath, 'utf-8'));
     expect(saved.agent.explore.disable).toBe(true);
     expect(saved.agent.general.disable).toBe(true);
-    expect(saved.agent.build.disable).toBe(true);
-    expect(saved.agent.plan.disable).toBe(true);
+    expect(saved.agent.build).toBeUndefined();
+    expect(saved.agent.plan).toBeUndefined();
   });
 
-  test('disableDefaultAgents preserves existing built-in agent config', () => {
+  test('disableDefaultAgents preserves existing build and plan agent config', () => {
     const configPath = join(tmpDir, 'opencode', 'opencode.json');
     paths.ensureConfigDir();
     writeFileSync(
@@ -496,14 +496,10 @@ describe('config-io', () => {
     expect(result.success).toBe(true);
 
     const saved = JSON.parse(readFileSync(configPath, 'utf-8'));
-    expect(saved.agent.build).toEqual({
-      description: 'custom build agent',
-      disable: true,
-    });
-    expect(saved.agent.plan).toEqual({
-      permission: { edit: 'deny' },
-      disable: true,
-    });
+    expect(saved.agent.build).toEqual({ description: 'custom build agent' });
+    expect(saved.agent.plan).toEqual({ permission: { edit: 'deny' } });
+    expect(saved.agent.explore.disable).toBe(true);
+    expect(saved.agent.general.disable).toBe(true);
   });
 
   test('enableLspByDefault sets lsp true when missing', () => {

+ 1 - 6
src/cli/config-io.ts

@@ -28,12 +28,7 @@ import type {
 } from './types';
 
 const PACKAGE_NAME = 'oh-my-opencode-slim';
-const DEFAULT_OPENCODE_AGENTS_TO_DISABLE = [
-  'build',
-  'explore',
-  'general',
-  'plan',
-] as const;
+const DEFAULT_OPENCODE_AGENTS_TO_DISABLE = ['explore', 'general'] as const;
 
 function isString(value: unknown): value is string {
   return typeof value === 'string';